@streamoji/avatar-widget 0.4.1 → 0.4.2
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 +6 -6
- package/dist/avatar-widget.js +800 -775
- package/dist/avatar-widget.umd.js +162 -162
- package/dist/avatar-widget.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/avatar-widget.js
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useGLTF as
|
|
3
|
-
import { useFrame as
|
|
4
|
-
import { memo as
|
|
5
|
-
import * as
|
|
6
|
-
import { GLTFLoader as
|
|
7
|
-
const
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
(!
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
for (let
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
for (let
|
|
34
|
-
const
|
|
35
|
-
|
|
1
|
+
import { jsx as f, jsxs as _e } from "react/jsx-runtime";
|
|
2
|
+
import { useGLTF as Tt, Environment as pn } from "@react-three/drei";
|
|
3
|
+
import { useFrame as gn, Canvas as bn, useThree as _n } from "@react-three/fiber";
|
|
4
|
+
import { memo as wn, useMemo as It, useRef as a, useState as x, useEffect as j, useCallback as Qe, useLayoutEffect as yn, Suspense as Sn } from "react";
|
|
5
|
+
import * as st from "three";
|
|
6
|
+
import { GLTFLoader as Ln } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
7
|
+
const at = "https://ai.streamoji.com", N = (...m) => {
|
|
8
|
+
}, vn = (...m) => {
|
|
9
|
+
}, Jt = ({ analyser: m }) => {
|
|
10
|
+
const C = a(null), E = a(null);
|
|
11
|
+
return j(() => {
|
|
12
|
+
const y = C.current;
|
|
13
|
+
if (!y) return;
|
|
14
|
+
const v = y.getContext("2d", { alpha: !0 });
|
|
15
|
+
if (!v) return;
|
|
16
|
+
let J, P = null;
|
|
17
|
+
m && (m.fftSize = 128, P = new Uint8Array(m.frequencyBinCount));
|
|
18
|
+
const We = () => {
|
|
19
|
+
J = requestAnimationFrame(We), (y.width !== y.offsetWidth || y.height !== y.offsetHeight) && (y.width = y.offsetWidth, y.height = y.offsetHeight);
|
|
20
|
+
const me = y.width, T = y.height;
|
|
21
|
+
if (me === 0 || T === 0) return;
|
|
22
|
+
const xe = T / 2;
|
|
23
|
+
v.clearRect(0, 0, me, T), v.fillStyle = "#1e293b";
|
|
24
|
+
const oe = 2, d = oe + 2, ie = me * 0.95, w = Math.floor(ie / d);
|
|
25
|
+
(!E.current || E.current.length !== w) && (E.current = new Float32Array(w).fill(2));
|
|
26
|
+
const ue = w * d, I = (me - ue) / 2;
|
|
27
|
+
m && P && m.getByteFrequencyData(P);
|
|
28
|
+
const De = P ? P.length : 0, le = Math.floor(De * 0.7) / w, Te = new Float32Array(w);
|
|
29
|
+
for (let B = 0; B < w; B++) {
|
|
30
|
+
let Y = 0;
|
|
31
|
+
if (P && le > 0) {
|
|
32
|
+
const D = Math.floor(B * le), O = Math.floor((B + 1) * le);
|
|
33
|
+
for (let ee = D; ee < O; ee++) {
|
|
34
|
+
const K = P[ee] || 0;
|
|
35
|
+
K > Y && (Y = K);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
38
|
+
Y < 10 && (Y = 0);
|
|
39
|
+
const te = Y / 255, A = Y > 0 ? Math.max(2, Math.pow(te, 1.4) * T * 0.25) : 2;
|
|
40
|
+
Te[B] = A;
|
|
41
41
|
}
|
|
42
|
-
for (let
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
42
|
+
for (let B = 0; B < w; B++) {
|
|
43
|
+
const Y = w - 1 - B, te = Math.max(Te[B], Te[Y]), A = E.current[B] + (te - E.current[B]) * 0.3;
|
|
44
|
+
E.current[B] = A;
|
|
45
|
+
const D = I + B * d, O = xe - A / 2;
|
|
46
|
+
v.beginPath(), v.roundRect ? v.roundRect(D, O, oe, A, 4) : v.fillRect(D, O, oe, A), v.fill();
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
return
|
|
50
|
-
cancelAnimationFrame(
|
|
49
|
+
return We(), () => {
|
|
50
|
+
cancelAnimationFrame(J);
|
|
51
51
|
};
|
|
52
|
-
}, [
|
|
52
|
+
}, [m]), /* @__PURE__ */ f(
|
|
53
53
|
"canvas",
|
|
54
54
|
{
|
|
55
|
-
ref:
|
|
55
|
+
ref: C,
|
|
56
56
|
style: { width: "100%", height: "100%", display: "block" }
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
|
-
},
|
|
60
|
-
async function
|
|
61
|
-
const
|
|
59
|
+
}, Rn = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", qt = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/avatar-blue-suit.glb";
|
|
60
|
+
async function kn(m) {
|
|
61
|
+
const C = await crypto.subtle.digest(
|
|
62
62
|
"SHA-256",
|
|
63
|
-
new TextEncoder().encode(
|
|
63
|
+
new TextEncoder().encode(m)
|
|
64
64
|
);
|
|
65
|
-
return Array.from(new Uint8Array(
|
|
65
|
+
return Array.from(new Uint8Array(C)).map((E) => E.toString(16).padStart(2, "0")).join("");
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const [
|
|
69
|
-
return
|
|
70
|
-
if (!
|
|
71
|
-
|
|
67
|
+
function xn(m) {
|
|
68
|
+
const [C, E] = x(null);
|
|
69
|
+
return j(() => {
|
|
70
|
+
if (!m) {
|
|
71
|
+
E(null);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
let
|
|
75
|
-
return
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
fetch(
|
|
79
|
-
|
|
74
|
+
let y = !1;
|
|
75
|
+
return kn(m).then((v) => {
|
|
76
|
+
if (y) return;
|
|
77
|
+
const J = `${Rn}/${v}.glb`;
|
|
78
|
+
fetch(J, { method: "HEAD" }).then((P) => {
|
|
79
|
+
y || E(P.ok ? J : qt);
|
|
80
80
|
}).catch(() => {
|
|
81
|
-
|
|
81
|
+
y || E(qt);
|
|
82
82
|
});
|
|
83
83
|
}), () => {
|
|
84
|
-
|
|
84
|
+
y = !0;
|
|
85
85
|
};
|
|
86
|
-
}, [
|
|
86
|
+
}, [m]), C;
|
|
87
87
|
}
|
|
88
|
-
const
|
|
88
|
+
const Tn = [
|
|
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
|
+
], En = [
|
|
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
|
+
], Mn = [
|
|
98
98
|
{
|
|
99
99
|
id: "m_expr_01",
|
|
100
100
|
name: "Friendly Wave",
|
|
@@ -260,23 +260,23 @@ const _n = [
|
|
|
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
|
+
], An = [
|
|
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
|
-
],
|
|
267
|
+
], In = [
|
|
268
268
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_004.glb",
|
|
269
269
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_005.glb",
|
|
270
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
|
+
], Dn = {
|
|
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
|
+
}, On = [-0.45, 1.9, 0.1], Un = [-0.45, 1.75, 0.1], Cn = {
|
|
278
278
|
browInnerUp: 0.2
|
|
279
|
-
},
|
|
279
|
+
}, Et = 0.18, Fn = 1, Nn = 0.5, Gt = 3, pt = 0.55, Mt = 0.12, zt = 2, Yt = 2, gt = 4, Kt = 8, Pn = 1, Qt = 0.38, Xt = 0.32, Zt = "__branding__", bt = {
|
|
280
280
|
neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
|
|
281
281
|
happy: {
|
|
282
282
|
mouthSmileLeft: 0.2,
|
|
@@ -358,7 +358,7 @@ const _n = [
|
|
|
358
358
|
mouthUpperUpLeft: 0.1,
|
|
359
359
|
mouthUpperUpRight: 0.1
|
|
360
360
|
}
|
|
361
|
-
},
|
|
361
|
+
}, Bn = [
|
|
362
362
|
{
|
|
363
363
|
key: "viseme_aa",
|
|
364
364
|
mix: { jawOpen: 0.4, mouthSmileLeft: 0.15, mouthSmileRight: 0.15 },
|
|
@@ -593,7 +593,7 @@ const _n = [
|
|
|
593
593
|
}
|
|
594
594
|
},
|
|
595
595
|
{ key: "viseme_sil", mix: {} }
|
|
596
|
-
],
|
|
596
|
+
], Vn = {
|
|
597
597
|
aei: [
|
|
598
598
|
{ v: "E", w: 0.8 },
|
|
599
599
|
{ v: "I", w: 0.2 }
|
|
@@ -622,352 +622,377 @@ const _n = [
|
|
|
622
622
|
],
|
|
623
623
|
sil: [{ v: "sil", w: 1 }]
|
|
624
624
|
};
|
|
625
|
-
function
|
|
626
|
-
if (!
|
|
627
|
-
const
|
|
628
|
-
return
|
|
625
|
+
function Wn(m) {
|
|
626
|
+
if (!m) return [{ v: "sil", w: 1 }];
|
|
627
|
+
const C = m.toLowerCase();
|
|
628
|
+
return Vn[C] ?? [{ v: "sil", w: 1 }];
|
|
629
629
|
}
|
|
630
|
-
function
|
|
631
|
-
const { camera:
|
|
632
|
-
return
|
|
633
|
-
|
|
634
|
-
}, [
|
|
630
|
+
function $n({ target: m }) {
|
|
631
|
+
const { camera: C } = _n();
|
|
632
|
+
return j(() => {
|
|
633
|
+
C.lookAt(...m);
|
|
634
|
+
}, [C, m]), null;
|
|
635
635
|
}
|
|
636
|
-
function
|
|
637
|
-
if (!
|
|
636
|
+
function c(m, C, E) {
|
|
637
|
+
if (!m || !m.morphTargetDictionary)
|
|
638
638
|
return;
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
641
|
-
for (const
|
|
642
|
-
|
|
639
|
+
const y = m, v = y.morphTargetDictionary, J = y.morphTargetInfluences;
|
|
640
|
+
if (J)
|
|
641
|
+
for (const P in v)
|
|
642
|
+
P.toLowerCase() === C.toLowerCase() && (J[v[P]] = E);
|
|
643
643
|
}
|
|
644
|
-
function
|
|
645
|
-
if (!
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
for (let
|
|
649
|
-
|
|
644
|
+
function At(m, C = 0.97) {
|
|
645
|
+
if (!m) return;
|
|
646
|
+
const E = m;
|
|
647
|
+
if (E.morphTargetInfluences)
|
|
648
|
+
for (let y = 0; y < E.morphTargetInfluences.length; y++)
|
|
649
|
+
E.morphTargetInfluences[y] *= C;
|
|
650
650
|
}
|
|
651
|
-
const
|
|
651
|
+
const Hn = wn(
|
|
652
652
|
({
|
|
653
|
-
avatarUrl:
|
|
654
|
-
isPlayingRef:
|
|
655
|
-
visemeQueueRef:
|
|
656
|
-
audioContextRef:
|
|
657
|
-
responseAudioStartTimeRef:
|
|
658
|
-
adjustments:
|
|
659
|
-
mood:
|
|
660
|
-
expression:
|
|
661
|
-
agentResponse:
|
|
662
|
-
isSpeaking:
|
|
663
|
-
nextStartTimeRef:
|
|
664
|
-
stopPlayback:
|
|
665
|
-
setIsSpeaking:
|
|
666
|
-
expressionUrl:
|
|
667
|
-
onExpressionFinished:
|
|
668
|
-
isNudgeResponse:
|
|
669
|
-
avatarGender:
|
|
653
|
+
avatarUrl: m,
|
|
654
|
+
isPlayingRef: C,
|
|
655
|
+
visemeQueueRef: E,
|
|
656
|
+
audioContextRef: y,
|
|
657
|
+
responseAudioStartTimeRef: v,
|
|
658
|
+
adjustments: J,
|
|
659
|
+
mood: P,
|
|
660
|
+
expression: We,
|
|
661
|
+
agentResponse: me,
|
|
662
|
+
isSpeaking: T,
|
|
663
|
+
nextStartTimeRef: xe,
|
|
664
|
+
stopPlayback: oe,
|
|
665
|
+
setIsSpeaking: q,
|
|
666
|
+
expressionUrl: d,
|
|
667
|
+
onExpressionFinished: ie,
|
|
668
|
+
isNudgeResponse: w,
|
|
669
|
+
avatarGender: ue
|
|
670
670
|
}) => {
|
|
671
|
-
const { scene:
|
|
672
|
-
() =>
|
|
673
|
-
[
|
|
674
|
-
),
|
|
675
|
-
() =>
|
|
676
|
-
[
|
|
677
|
-
),
|
|
678
|
-
|
|
679
|
-
if (!(!
|
|
680
|
-
if (
|
|
681
|
-
const
|
|
682
|
-
if (!
|
|
683
|
-
const
|
|
684
|
-
|
|
671
|
+
const { scene: I } = Tt(m), Oe = Tt(ue === "female" ? En : Tn), le = It(
|
|
672
|
+
() => Oe.flatMap((g) => g.animations),
|
|
673
|
+
[Oe]
|
|
674
|
+
), B = Tt(ue === "female" ? In : An), Y = It(
|
|
675
|
+
() => B.flatMap((g) => g.animations),
|
|
676
|
+
[B]
|
|
677
|
+
), te = a(null), A = a(null), D = a(null), O = a(null), ee = a(null), K = a(null), $e = a([]), [Q] = x(() => new st.AnimationMixer(I)), V = a({}), G = a(null), Le = a(0), ve = a(!1), Re = a(0), Ue = a(!1), he = a(null), He = a(Gt), je = a(-1), Je = a("left"), ct = a(gt + Math.random() * (Kt - gt)), qe = a(0), Ge = a("smile");
|
|
678
|
+
j(() => {
|
|
679
|
+
if (!(!le || !I)) {
|
|
680
|
+
if (le.forEach((g, h) => {
|
|
681
|
+
const i = `idle_${h}`;
|
|
682
|
+
if (!V.current[i]) {
|
|
683
|
+
const n = Q.clipAction(g, I);
|
|
684
|
+
n.name = i, n.setLoop(st.LoopOnce, 1), n.clampWhenFinished = !0, V.current[i] = n;
|
|
685
685
|
}
|
|
686
|
-
}),
|
|
687
|
-
const
|
|
688
|
-
if (!
|
|
689
|
-
const
|
|
690
|
-
|
|
686
|
+
}), Y.forEach((g, h) => {
|
|
687
|
+
const i = `talk_${h}`;
|
|
688
|
+
if (!V.current[i]) {
|
|
689
|
+
const n = Q.clipAction(g, I);
|
|
690
|
+
n.name = i, n.setLoop(st.LoopOnce, 1), n.clampWhenFinished = !0, V.current[i] = n;
|
|
691
691
|
}
|
|
692
|
-
}),
|
|
693
|
-
const
|
|
694
|
-
|
|
692
|
+
}), le.length > 0) {
|
|
693
|
+
const g = V.current.idle_0, h = G.current && Q.existingAction(G.current.getClip());
|
|
694
|
+
g && !h && (g.reset().fadeIn(0.5).play(), G.current = g);
|
|
695
695
|
}
|
|
696
696
|
return () => {
|
|
697
|
-
|
|
697
|
+
Q.stopAllAction(), V.current = {}, G.current = null;
|
|
698
698
|
};
|
|
699
699
|
}
|
|
700
|
-
}, [
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
if (!
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
(
|
|
707
|
-
if (
|
|
708
|
-
const
|
|
709
|
-
if (
|
|
710
|
-
const
|
|
711
|
-
|
|
700
|
+
}, [le, Y, I, Q]);
|
|
701
|
+
const ut = a("");
|
|
702
|
+
j(() => {
|
|
703
|
+
if (!d || !I || d === ut.current) return;
|
|
704
|
+
ut.current = d, he.current = d, new Ln().load(
|
|
705
|
+
d,
|
|
706
|
+
(h) => {
|
|
707
|
+
if (h.animations && h.animations.length > 0) {
|
|
708
|
+
const i = h.animations[0], n = Q.clipAction(i, I);
|
|
709
|
+
if (n.name = `EXPR_${d}`, n.setLoop(st.LoopOnce, 1), n.clampWhenFinished = !0, V.current[`EXPR_${d}`] = n, T && he.current === d) {
|
|
710
|
+
const l = G.current;
|
|
711
|
+
n.reset().fadeIn(0.3).play(), l && l !== n && l.crossFadeTo(n, 0.3, !0), G.current = n, he.current = null;
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
},
|
|
715
715
|
void 0,
|
|
716
|
-
(
|
|
717
|
-
console.error(`[ANIMATION] Failed to load ${
|
|
716
|
+
(h) => {
|
|
717
|
+
console.error(`[ANIMATION] Failed to load ${d}`, h);
|
|
718
718
|
}
|
|
719
719
|
);
|
|
720
|
-
}, [
|
|
721
|
-
const
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
X && (X.reset().fadeIn(0.5).play(),
|
|
726
|
-
} else if (
|
|
727
|
-
if (
|
|
728
|
-
const
|
|
729
|
-
Math.random() *
|
|
730
|
-
),
|
|
731
|
-
|
|
720
|
+
}, [d, I, Q, T]), j(() => {
|
|
721
|
+
const g = (h) => {
|
|
722
|
+
const i = h.action, n = i.name || "";
|
|
723
|
+
if (n.startsWith("idle_")) {
|
|
724
|
+
const R = (parseInt(n.split("_")[1]) + 1) % le.length, X = V.current[`idle_${R}`];
|
|
725
|
+
X && (X.reset().fadeIn(0.5).play(), i.crossFadeTo(X, 0.5, !0), G.current = X);
|
|
726
|
+
} else if (n.startsWith("EXPR_")) {
|
|
727
|
+
if (T) {
|
|
728
|
+
const l = Math.floor(
|
|
729
|
+
Math.random() * Y.length
|
|
730
|
+
), R = V.current[`talk_${l}`];
|
|
731
|
+
R && (R.reset().fadeIn(0.5).play(), i.crossFadeTo(R, 0.5, !0), G.current = R);
|
|
732
732
|
} else {
|
|
733
|
-
const
|
|
734
|
-
|
|
733
|
+
const l = V.current.idle_0;
|
|
734
|
+
l && (l.reset().fadeIn(0.5).play(), i.crossFadeTo(l, 0.5, !0), G.current = l);
|
|
735
735
|
}
|
|
736
|
-
|
|
737
|
-
} else if (
|
|
738
|
-
if (
|
|
739
|
-
const
|
|
740
|
-
X && (X.reset().fadeIn(0.3).play(),
|
|
736
|
+
ie && ie();
|
|
737
|
+
} else if (n.startsWith("talk_"))
|
|
738
|
+
if (T && !w) {
|
|
739
|
+
const R = (parseInt(n.split("_")[1]) + 1) % Y.length, X = V.current[`talk_${R}`];
|
|
740
|
+
X && (X.reset().fadeIn(0.3).play(), i.crossFadeTo(X, 0.3, !0), G.current = X);
|
|
741
741
|
} else {
|
|
742
|
-
const
|
|
743
|
-
|
|
742
|
+
const l = V.current.idle_0;
|
|
743
|
+
l && (l.reset().fadeIn(0.5).play(), i.crossFadeTo(l, 0.5, !0), G.current = l);
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
|
-
return
|
|
746
|
+
return Q.addEventListener("finished", g), () => Q.removeEventListener("finished", g);
|
|
747
747
|
}, [
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
]),
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
const
|
|
759
|
-
if (
|
|
760
|
-
const
|
|
761
|
-
if (
|
|
762
|
-
|
|
748
|
+
Q,
|
|
749
|
+
le,
|
|
750
|
+
Y,
|
|
751
|
+
T,
|
|
752
|
+
w,
|
|
753
|
+
ie
|
|
754
|
+
]), j(() => {
|
|
755
|
+
if (T && I) {
|
|
756
|
+
const g = G.current, h = g?.name || "";
|
|
757
|
+
if (h.startsWith("idle_") || h.startsWith("talk_") || h === "") {
|
|
758
|
+
const i = he.current;
|
|
759
|
+
if (i) {
|
|
760
|
+
const n = V.current[`EXPR_${i}`];
|
|
761
|
+
if (n) {
|
|
762
|
+
n.reset().fadeIn(0.3).play(), g && g !== n && g.crossFadeTo(n, 0.3, !0), G.current = n, he.current = null;
|
|
763
763
|
return;
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
Math.random() *
|
|
769
|
-
),
|
|
770
|
-
|
|
766
|
+
if (h.startsWith("idle_") || h === "") {
|
|
767
|
+
const n = Math.floor(
|
|
768
|
+
Math.random() * Y.length
|
|
769
|
+
), l = V.current[`talk_${n}`];
|
|
770
|
+
l && (l.reset().fadeIn(0.5).play(), g && g.crossFadeTo(l, 0.5, !0), G.current = l);
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
|
-
} else if (!
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
776
|
-
const
|
|
777
|
-
|
|
773
|
+
} else if (!T && I) {
|
|
774
|
+
const g = G.current, h = g?.name || "";
|
|
775
|
+
if (h.startsWith("talk_") || h.startsWith("EXPR_")) {
|
|
776
|
+
const i = V.current.idle_0;
|
|
777
|
+
i && (i.reset().fadeIn(0.5).play(), g && g.crossFadeTo(i, 0.5, !0), G.current = i);
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
}, [
|
|
781
|
-
if (!
|
|
782
|
-
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
(
|
|
780
|
+
}, [T, I, d]), j(() => {
|
|
781
|
+
if (!I) return;
|
|
782
|
+
I.traverse((i) => {
|
|
783
|
+
if (i.isMesh && i.morphTargetDictionary) {
|
|
784
|
+
const n = i.name.toLowerCase();
|
|
785
|
+
(n.includes("head") || n.includes("avatar")) && (A.current = i, N(`[ANIMATION] Found head mesh: ${i.name}`)), n.includes("teeth") && (D.current = i, N(`[ANIMATION] Found teeth mesh: ${i.name}`)), n.includes("beard") && (O.current = i, N(`[ANIMATION] Found beard mesh: ${i.name}`)), n.includes("eyeleft") && (ee.current = i, N(`[ANIMATION] Found eye left mesh: ${i.name}`)), n.includes("eyeright") && (K.current = i, N(`[ANIMATION] Found eye right mesh: ${i.name}`));
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
(
|
|
788
|
+
const g = A.current?.morphTargetDictionary;
|
|
789
|
+
g && Object.keys(g).filter(
|
|
790
|
+
(i) => i.toLowerCase().includes("brow")
|
|
791
791
|
);
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
if (
|
|
795
|
-
const
|
|
796
|
-
|
|
792
|
+
const h = [];
|
|
793
|
+
I.traverse((i) => {
|
|
794
|
+
if (i.isMesh) {
|
|
795
|
+
const l = i.morphTargetDictionary;
|
|
796
|
+
l && Object.keys(l).some((R) => R.toLowerCase().includes("brow")) && h.push(i);
|
|
797
797
|
}
|
|
798
|
-
}),
|
|
799
|
-
}, [
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
for (const
|
|
804
|
-
const
|
|
805
|
-
|
|
798
|
+
}), $e.current = h, h.length > 0 && N("[ANIMATION] Meshes with brow morphs:", h.length);
|
|
799
|
+
}, [I]);
|
|
800
|
+
const _t = (g, h = 1) => {
|
|
801
|
+
const i = `viseme_${g}`.toLowerCase(), n = Bn.find((l) => l.key.toLowerCase() === i);
|
|
802
|
+
if (n) {
|
|
803
|
+
for (const l in n.mix) {
|
|
804
|
+
const R = n.mix[l] * h;
|
|
805
|
+
c(A.current, l, R), c(O.current, l, R), (!n.teethMix || !(l in n.teethMix)) && c(D.current, l, R);
|
|
806
806
|
}
|
|
807
|
-
if (
|
|
808
|
-
for (const
|
|
809
|
-
const
|
|
810
|
-
|
|
807
|
+
if (n.teethMix)
|
|
808
|
+
for (const l in n.teethMix) {
|
|
809
|
+
const R = n.teethMix[l] * h;
|
|
810
|
+
c(D.current, l, R);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
},
|
|
814
|
-
const
|
|
815
|
-
for (const
|
|
816
|
-
|
|
813
|
+
}, lt = (g) => {
|
|
814
|
+
const h = bt[g] ?? bt.neutral;
|
|
815
|
+
for (const i in h)
|
|
816
|
+
c(A.current, i, h[i]), c(D.current, i, h[i]), c(O.current, i, h[i]);
|
|
817
817
|
};
|
|
818
|
-
return
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
let
|
|
823
|
-
if (Math.floor(
|
|
824
|
-
let
|
|
825
|
-
|
|
826
|
-
|
|
818
|
+
return gn((g, h) => {
|
|
819
|
+
const i = Math.pow(0.88, 60 * h);
|
|
820
|
+
At(A.current, i), At(D.current, i), At(O.current, i), lt(P);
|
|
821
|
+
const n = g.clock.elapsedTime;
|
|
822
|
+
let l = 0;
|
|
823
|
+
if (Math.floor(n) % 5 === 0 && Math.floor((n - h) % 5) !== 0) {
|
|
824
|
+
let b = null;
|
|
825
|
+
I.traverse(($) => {
|
|
826
|
+
$.name.toLowerCase().includes("hips") && (b = $);
|
|
827
827
|
});
|
|
828
|
-
const
|
|
829
|
-
|
|
828
|
+
const ae = b ? `Hips Y: ${b.position.y.toFixed(4)}` : "Hips not found";
|
|
829
|
+
N(`[ANIMATION] Mixer Time: ${Q.time.toFixed(2)}, ${ae}`);
|
|
830
830
|
}
|
|
831
|
-
if (
|
|
832
|
-
const
|
|
833
|
-
if (
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
831
|
+
if (Q.update(h), n > Le.current && !ve.current && (ve.current = !0, Re.current = n), ve.current) {
|
|
832
|
+
const b = T ? 0.2 : 0.3, ae = (n - Re.current) / b;
|
|
833
|
+
if (ae >= 1)
|
|
834
|
+
if (ve.current = !1, Ue.current) {
|
|
835
|
+
const $ = T ? 1 : 2.5;
|
|
836
|
+
Le.current = n + $, Ue.current = !1;
|
|
837
|
+
} else
|
|
838
|
+
Le.current = n + 0.12, Ue.current = !0;
|
|
839
|
+
else {
|
|
840
|
+
const $ = ae < 0.5 ? ae * 2 : (1 - ae) * 2;
|
|
841
|
+
c(A.current, "eyeBlinkLeft", $), c(A.current, "eyeBlinkRight", $), c(D.current, "eyeBlinkLeft", $), c(D.current, "eyeBlinkRight", $), c(O.current, "eyeBlinkLeft", $), c(O.current, "eyeBlinkRight", $), l = $ * Cn.browInnerUp;
|
|
840
842
|
}
|
|
841
843
|
}
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
844
|
+
const R = bt[P] ?? bt.neutral, X = R.browInnerUp ?? 0, ht = R.browOuterUpLeft ?? 0, Xe = R.browOuterUpRight ?? 0, Ce = n * Fn, Dt = Et * Math.sin(Ce), wt = Et * 0.7 * Math.sin(Ce + 0.7), Ze = Et * 0.7 * Math.sin(Ce + 1.3), _ = (b) => Math.max(0, Math.min(1, b)), Fe = _(X + Dt), ze = _(ht + wt), Ye = _(Xe + Ze), ne = _(Fe + l);
|
|
845
|
+
c(A.current, "browInnerUp", ne), c(D.current, "browInnerUp", ne), c(O.current, "browInnerUp", ne), c(A.current, "browOuterUpLeft", ze), c(D.current, "browOuterUpLeft", ze), c(O.current, "browOuterUpLeft", ze), c(A.current, "browOuterUpRight", Ye), c(D.current, "browOuterUpRight", Ye), c(O.current, "browOuterUpRight", Ye);
|
|
846
|
+
const we = He.current, Ne = we + pt, dt = Ne + Mt;
|
|
847
|
+
n > dt && (He.current += pt + Mt + Gt);
|
|
848
|
+
const Ee = !T && n >= we && n < Ne, z = !T && n >= Ne && n < dt;
|
|
849
|
+
(Ee || z) && je.current !== we && (je.current = we, Je.current = Math.random() < 0.7 ? "left" : "up");
|
|
850
|
+
const pe = Ee ? n - we : z ? pt : 0, de = Ee || z ? Math.min(1, pe / pt) : 0, et = de <= 0 ? 0 : Math.sin(de * Math.PI), tt = z ? 1 - (n - Ne) / Mt : 1, Pe = Ee ? et : z ? et * tt : 0, Me = Nn * Pe, F = (b) => R[b] ?? 0;
|
|
851
|
+
if (Je.current === "up" ? (c(ee.current, "eyeLookUpLeft", _(F("eyeLookUpLeft") + Me)), c(ee.current, "eyeLookDownLeft", _(F("eyeLookDownLeft"))), c(ee.current, "eyeLookOutLeft", _(F("eyeLookOutLeft"))), c(ee.current, "eyeLookInLeft", _(F("eyeLookInLeft"))), c(K.current, "eyeLookUpRight", _(F("eyeLookUpRight") + Me)), c(K.current, "eyeLookDownRight", _(F("eyeLookDownRight"))), c(K.current, "eyeLookOutRight", _(F("eyeLookOutRight"))), c(K.current, "eyeLookInRight", _(F("eyeLookInRight")))) : (c(ee.current, "eyeLookUpLeft", _(F("eyeLookUpLeft"))), c(ee.current, "eyeLookDownLeft", _(F("eyeLookDownLeft"))), c(ee.current, "eyeLookOutLeft", _(F("eyeLookOutLeft"))), c(ee.current, "eyeLookInLeft", _(F("eyeLookInLeft") + Me)), c(K.current, "eyeLookUpRight", _(F("eyeLookUpRight"))), c(K.current, "eyeLookDownRight", _(F("eyeLookDownRight"))), c(K.current, "eyeLookOutRight", _(F("eyeLookOutRight") + Me)), c(K.current, "eyeLookInRight", _(F("eyeLookInRight")))), !T && n >= ct.current) {
|
|
852
|
+
qe.current = n, Ge.current = Math.random() < 0.5 ? "pucker" : "smile";
|
|
853
|
+
const b = Ge.current === "pucker" ? Yt : zt;
|
|
854
|
+
ct.current = n + b + gt + Math.random() * (Kt - gt);
|
|
855
|
+
}
|
|
856
|
+
const nt = Ge.current === "pucker" ? Yt : zt, rt = !T && n >= qe.current && n < qe.current + nt, se = rt ? (n - qe.current) / nt : 0, fe = se <= 0 ? 0 : se < 0.5 ? se * 2 : (() => {
|
|
857
|
+
const b = (se - 0.5) * 2;
|
|
858
|
+
return 1 - b * b * (3 - 2 * b);
|
|
859
|
+
})(), Ae = (b) => R[b] ?? 0;
|
|
860
|
+
if (rt)
|
|
861
|
+
if (Ge.current === "pucker") {
|
|
862
|
+
const b = _(Ae("mouthPucker") + Pn * fe);
|
|
863
|
+
c(A.current, "mouthPucker", b), c(D.current, "mouthPucker", b), c(O.current, "mouthPucker", b);
|
|
864
|
+
} else {
|
|
865
|
+
const b = _(Ae("mouthSmileLeft") + Qt * fe), ae = _(Ae("mouthSmileRight") + Qt * fe), $ = _(Ae("mouthDimpleLeft") + Xt * fe), Ie = _(Ae("mouthDimpleRight") + Xt * fe);
|
|
866
|
+
c(A.current, "mouthSmileLeft", b), c(A.current, "mouthSmileRight", ae), c(A.current, "mouthDimpleLeft", $), c(A.current, "mouthDimpleRight", Ie), c(D.current, "mouthSmileLeft", b), c(D.current, "mouthSmileRight", ae), c(D.current, "mouthDimpleLeft", $), c(D.current, "mouthDimpleRight", Ie), c(O.current, "mouthSmileLeft", b), c(O.current, "mouthSmileRight", ae), c(O.current, "mouthDimpleLeft", $), c(O.current, "mouthDimpleRight", Ie);
|
|
867
|
+
}
|
|
868
|
+
if (te.current) {
|
|
869
|
+
const b = C.current ? 0 : J.rotation[1];
|
|
870
|
+
te.current.rotation.y = st.MathUtils.lerp(
|
|
871
|
+
te.current.rotation.y,
|
|
872
|
+
b,
|
|
848
873
|
0.1
|
|
849
|
-
),
|
|
874
|
+
), te.current.position.set(...J.position), te.current.scale.setScalar(J.scale), te.current.rotation.x = J.rotation[0], te.current.rotation.z = J.rotation[2];
|
|
850
875
|
}
|
|
851
|
-
if (
|
|
852
|
-
const
|
|
853
|
-
for (let
|
|
854
|
-
const
|
|
855
|
-
|
|
876
|
+
if (C.current && y.current) {
|
|
877
|
+
const b = y.current.currentTime, Ie = (b - v.current) * 1e3 - -150;
|
|
878
|
+
for (let ot = 0; ot < E.current.length; ot++) {
|
|
879
|
+
const re = E.current[ot];
|
|
880
|
+
Ie >= re.vtime && Ie < re.vtime + re.vduration && _t(re.viseme, re.weight ?? 1);
|
|
856
881
|
}
|
|
857
|
-
|
|
882
|
+
b > xe.current + 0.5 && (oe(), q(!1));
|
|
858
883
|
}
|
|
859
|
-
}), /* @__PURE__ */
|
|
884
|
+
}), /* @__PURE__ */ f("group", { ref: te, children: /* @__PURE__ */ f("primitive", { object: I }) });
|
|
860
885
|
}
|
|
861
886
|
);
|
|
862
|
-
function
|
|
863
|
-
return
|
|
887
|
+
function jn(m) {
|
|
888
|
+
return m ? m.charAt(0).toUpperCase() + m.slice(1).toLowerCase() : "";
|
|
864
889
|
}
|
|
865
|
-
function
|
|
866
|
-
return
|
|
890
|
+
function en(m) {
|
|
891
|
+
return m.replace(/\*(.*?)\*/g, " $1 ").replace(/\[.*?\]/g, " ").replace(/<.*?\/>/g, " ").replace(/<.*?>.*?<\/.*?>/g, " ").replace(/\s+/g, " ").trim();
|
|
867
892
|
}
|
|
868
|
-
const
|
|
869
|
-
token:
|
|
870
|
-
agentToken:
|
|
871
|
-
onNavigationRequested:
|
|
872
|
-
avatarGender:
|
|
873
|
-
presetUserDetails:
|
|
874
|
-
onAvatarReady:
|
|
893
|
+
const Jn = ({
|
|
894
|
+
token: m,
|
|
895
|
+
agentToken: C,
|
|
896
|
+
onNavigationRequested: E,
|
|
897
|
+
avatarGender: y,
|
|
898
|
+
presetUserDetails: v,
|
|
899
|
+
onAvatarReady: J
|
|
875
900
|
} = {}) => {
|
|
876
|
-
const
|
|
901
|
+
const P = m ?? C ?? "", We = xn(P || void 0), [me, T] = x(""), [xe, oe] = x(""), [q, d] = x("Ready"), [ie, w] = x(!1), [ue, I] = x(!1), [De, Oe] = x([]), [le, Te] = x(""), B = a(null), [Y, te] = x(
|
|
877
902
|
() => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
|
|
878
903
|
);
|
|
879
|
-
|
|
880
|
-
const e = window.matchMedia("(max-width: 480px)"), t = () =>
|
|
904
|
+
j(() => {
|
|
905
|
+
const e = window.matchMedia("(max-width: 480px)"), t = () => te(e.matches);
|
|
881
906
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
882
907
|
}, []);
|
|
883
|
-
const
|
|
908
|
+
const A = Y ? 80 : 600, D = a(!1), O = a([]), ee = a(0), K = a(!1), $e = a([]), Q = a(null), V = a([]);
|
|
884
909
|
a([]);
|
|
885
|
-
const
|
|
910
|
+
const G = a([]), Le = a(0), ve = a(0), Re = a(0), Ue = a(0), he = a(!1), [He, je] = x(
|
|
886
911
|
null
|
|
887
|
-
),
|
|
912
|
+
), Je = a(null), [ct, qe] = x("neutral"), [Ge, ut] = x(""), [_t, lt] = x(""), [g, h] = x("Chat with us"), [i, n] = x(
|
|
888
913
|
null
|
|
889
|
-
), [
|
|
890
|
-
|
|
891
|
-
const [
|
|
892
|
-
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
if (
|
|
896
|
-
|
|
914
|
+
), [l, R] = x("hidden"), [X, ht] = x(""), Xe = a(null), Ce = a(l);
|
|
915
|
+
Ce.current = l;
|
|
916
|
+
const [Dt, wt] = x(null), Ze = a(null), _ = a(null), [Fe, ze] = x(!1), Ye = a(null), [ne, we] = x("hidden"), [Ne, dt] = x(""), Ee = a(ne);
|
|
917
|
+
Ee.current = ne;
|
|
918
|
+
const z = a(""), pe = a(!1), de = a(""), et = a(Date.now()), tt = a([]), Pe = a(!1), [Me, F] = x(!1), [nt, rt] = x(!1), se = a(null), fe = It(() => Fe ? "Try again" : q === "Busy" ? "Busy" : q === "Thinking..." || q === "Processing Voice..." ? q : i != null && i !== "" && i !== "none" && i !== "<none>" ? `Enter ${jn(i)}` : ne !== "hidden" || !nt ? null : Zt, [q, i, Fe, ne, nt]), Ae = !Fe && q !== "Busy" && q !== "Thinking..." && q !== "Processing Voice..." && (i == null || i === "" || i === "none" || i === "<none>");
|
|
919
|
+
j(() => {
|
|
920
|
+
if (ne !== "hidden" || !Ae) {
|
|
921
|
+
rt(!1), se.current != null && (clearTimeout(se.current), se.current = null);
|
|
897
922
|
return;
|
|
898
923
|
}
|
|
899
|
-
return
|
|
900
|
-
|
|
924
|
+
return se.current = setTimeout(() => {
|
|
925
|
+
se.current = null, rt(!0);
|
|
901
926
|
}, 400), () => {
|
|
902
|
-
|
|
927
|
+
se.current != null && (clearTimeout(se.current), se.current = null);
|
|
903
928
|
};
|
|
904
|
-
}, [
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
const e =
|
|
929
|
+
}, [ne, Ae]);
|
|
930
|
+
const b = fe != null && fe !== "";
|
|
931
|
+
j(() => {
|
|
932
|
+
const e = Ce.current;
|
|
908
933
|
if (!(e === "exiting" || e === "entering")) {
|
|
909
934
|
if (e === "hidden") {
|
|
910
|
-
|
|
935
|
+
b && (ht(fe ?? ""), R("entering"));
|
|
911
936
|
return;
|
|
912
937
|
}
|
|
913
|
-
e === "visible" && (!
|
|
938
|
+
e === "visible" && (!b || fe !== X) && (Xe.current = b ? fe : null, R("exiting"));
|
|
914
939
|
}
|
|
915
940
|
}, [
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
]),
|
|
921
|
-
if (
|
|
922
|
-
|
|
941
|
+
b,
|
|
942
|
+
fe,
|
|
943
|
+
l,
|
|
944
|
+
X
|
|
945
|
+
]), j(() => {
|
|
946
|
+
if (q !== "Busy") {
|
|
947
|
+
_.current != null && (clearTimeout(_.current), _.current = null);
|
|
923
948
|
return;
|
|
924
949
|
}
|
|
925
|
-
return
|
|
926
|
-
|
|
950
|
+
return _.current = setTimeout(() => {
|
|
951
|
+
_.current = null, d("Ready"), ze(!0);
|
|
927
952
|
}, 12e3), () => {
|
|
928
|
-
|
|
953
|
+
_.current != null && (clearTimeout(_.current), _.current = null);
|
|
929
954
|
};
|
|
930
|
-
}, [
|
|
931
|
-
if (!
|
|
932
|
-
const e = setTimeout(() =>
|
|
955
|
+
}, [q]), j(() => {
|
|
956
|
+
if (!Fe) return;
|
|
957
|
+
const e = setTimeout(() => ze(!1), 2500);
|
|
933
958
|
return () => clearTimeout(e);
|
|
934
|
-
}, [
|
|
935
|
-
const
|
|
936
|
-
const e =
|
|
959
|
+
}, [Fe]);
|
|
960
|
+
const ae = Qe(() => {
|
|
961
|
+
const e = Ce.current;
|
|
937
962
|
if (e === "exiting") {
|
|
938
|
-
|
|
939
|
-
const t =
|
|
940
|
-
|
|
941
|
-
} else e === "entering" &&
|
|
942
|
-
}, []),
|
|
963
|
+
R("hidden");
|
|
964
|
+
const t = Xe.current;
|
|
965
|
+
Xe.current = null, t != null && t !== "" && (ht(t), R("entering"));
|
|
966
|
+
} else e === "entering" && R("visible");
|
|
967
|
+
}, []), $ = (e) => {
|
|
943
968
|
if (!e) return;
|
|
944
969
|
if (e.mood != null) {
|
|
945
|
-
const
|
|
946
|
-
|
|
970
|
+
const o = String(e.mood).toLowerCase();
|
|
971
|
+
qe(o);
|
|
947
972
|
}
|
|
948
973
|
if (e.expression != null) {
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
(p) => p.name.toLowerCase() ===
|
|
974
|
+
const o = String(e.expression).trim();
|
|
975
|
+
ut(o);
|
|
976
|
+
const u = Mn.find(
|
|
977
|
+
(p) => p.name.toLowerCase() === o.toLowerCase()
|
|
953
978
|
);
|
|
954
|
-
|
|
955
|
-
`[STREAM] Animation match for "${
|
|
956
|
-
),
|
|
979
|
+
N(
|
|
980
|
+
`[STREAM] Animation match for "${o}": ${u ? u.name : "NONE"}`
|
|
981
|
+
), lt(u?.url ?? "");
|
|
957
982
|
}
|
|
958
983
|
if (e.navigation != null) {
|
|
959
|
-
const
|
|
960
|
-
|
|
984
|
+
const o = String(e.navigation).trim();
|
|
985
|
+
o !== "" && (E ? E(o) : window.open(o, "_blank"));
|
|
961
986
|
}
|
|
962
|
-
const t = e.ask_for || e.lead_capture?.ask_for,
|
|
963
|
-
if (t && !
|
|
964
|
-
const
|
|
965
|
-
if (
|
|
987
|
+
const t = e.ask_for || e.lead_capture?.ask_for, r = t ? String(t).trim().toLowerCase() : "", s = r === "none" || r === "<none>";
|
|
988
|
+
if (t && !s) {
|
|
989
|
+
const o = r;
|
|
990
|
+
if (v && (o === "email" && v.email || o === "name" && v.name || o === "phone" && v.phone))
|
|
966
991
|
return;
|
|
967
|
-
|
|
968
|
-
} else (
|
|
992
|
+
n(o || null), h(o === "email" ? "Enter your email" : o === "name" ? "Enter your name" : o === "phone" ? "Enter your phone number" : "Chat with us");
|
|
993
|
+
} else (s || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && (n(null), g !== "Chat with us" && h("Chat with us"));
|
|
969
994
|
e.collected, e.valid;
|
|
970
|
-
},
|
|
995
|
+
}, Ie = (e) => {
|
|
971
996
|
const t = e.trim();
|
|
972
997
|
if (!t) return null;
|
|
973
998
|
if (t.startsWith("{"))
|
|
@@ -977,127 +1002,127 @@ const Cn = ({
|
|
|
977
1002
|
return null;
|
|
978
1003
|
}
|
|
979
1004
|
if (t.includes(":")) {
|
|
980
|
-
const
|
|
981
|
-
return { [
|
|
1005
|
+
const r = t.split(":"), s = r[0].trim().toLowerCase(), o = r.slice(1).join(":").trim();
|
|
1006
|
+
return { [s]: o };
|
|
982
1007
|
}
|
|
983
1008
|
return null;
|
|
984
|
-
},
|
|
985
|
-
}, []),
|
|
986
|
-
for (;
|
|
1009
|
+
}, ot = Qe(() => {
|
|
1010
|
+
}, []), re = "§", yt = () => {
|
|
1011
|
+
for (; z.current.includes(`
|
|
987
1012
|
`); ) {
|
|
988
|
-
const e =
|
|
989
|
-
`), t =
|
|
990
|
-
|
|
991
|
-
const
|
|
992
|
-
|
|
1013
|
+
const e = z.current.indexOf(`
|
|
1014
|
+
`), t = z.current.slice(0, e).trim();
|
|
1015
|
+
z.current = z.current.slice(e + 1);
|
|
1016
|
+
const r = Ie(t);
|
|
1017
|
+
r && $(r);
|
|
993
1018
|
}
|
|
994
|
-
},
|
|
995
|
-
if (
|
|
996
|
-
if (e.includes(
|
|
997
|
-
const t = e.indexOf(
|
|
998
|
-
|
|
999
|
-
} else e ===
|
|
1000
|
-
else if (e.includes(
|
|
1001
|
-
const t = e.indexOf(
|
|
1002
|
-
|
|
1003
|
-
} else if (e ===
|
|
1004
|
-
|
|
1019
|
+
}, Ot = (e) => {
|
|
1020
|
+
if (pe.current)
|
|
1021
|
+
if (e.includes(re)) {
|
|
1022
|
+
const t = e.indexOf(re), r = e.slice(0, t), s = e.slice(t + re.length);
|
|
1023
|
+
r && (de.current += r, oe((o) => o + r)), pe.current = !1, s && (z.current += s, yt());
|
|
1024
|
+
} else e === re ? pe.current = !1 : (de.current += e, oe((t) => t + e));
|
|
1025
|
+
else if (e.includes(re)) {
|
|
1026
|
+
const t = e.indexOf(re), r = e.slice(0, t), s = e.slice(t + re.length);
|
|
1027
|
+
z.current += r, yt(), pe.current = !0, s && (de.current += s, oe((o) => o + s));
|
|
1028
|
+
} else if (e === re) {
|
|
1029
|
+
pe.current = !0;
|
|
1005
1030
|
return;
|
|
1006
1031
|
} else
|
|
1007
|
-
|
|
1032
|
+
z.current += e, yt();
|
|
1008
1033
|
};
|
|
1009
|
-
|
|
1034
|
+
j(() => {
|
|
1010
1035
|
(async () => {
|
|
1011
1036
|
if (!sessionStorage.getItem(
|
|
1012
1037
|
"STREAMOJI_LEADS_SESSION_LEAD_ID"
|
|
1013
1038
|
)) {
|
|
1014
|
-
const
|
|
1039
|
+
const o = "secret", u = Math.floor(Date.now() / 1e3).toString();
|
|
1015
1040
|
try {
|
|
1016
|
-
const p = new TextEncoder(),
|
|
1041
|
+
const p = new TextEncoder(), S = await crypto.subtle.importKey(
|
|
1017
1042
|
"raw",
|
|
1018
|
-
p.encode(
|
|
1043
|
+
p.encode(o),
|
|
1019
1044
|
{ name: "HMAC", hash: "SHA-256" },
|
|
1020
1045
|
!1,
|
|
1021
1046
|
["sign"]
|
|
1022
|
-
),
|
|
1047
|
+
), k = await crypto.subtle.sign(
|
|
1023
1048
|
"HMAC",
|
|
1024
|
-
|
|
1025
|
-
p.encode(
|
|
1026
|
-
),
|
|
1027
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
1049
|
+
S,
|
|
1050
|
+
p.encode(u)
|
|
1051
|
+
), L = Array.from(new Uint8Array(k)).map((U) => U.toString(16).padStart(2, "0")).join("");
|
|
1052
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", L), N("[SESSION] New HMAC UID generated and saved:", L);
|
|
1028
1053
|
} catch (p) {
|
|
1029
1054
|
console.error("[SESSION] HMAC generation failed:", p);
|
|
1030
|
-
const
|
|
1031
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
1055
|
+
const S = Math.random().toString(36) + Date.now().toString();
|
|
1056
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", S);
|
|
1032
1057
|
}
|
|
1033
1058
|
}
|
|
1034
|
-
const
|
|
1035
|
-
let
|
|
1036
|
-
if (
|
|
1059
|
+
const r = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES");
|
|
1060
|
+
let s = [];
|
|
1061
|
+
if (r)
|
|
1037
1062
|
try {
|
|
1038
|
-
|
|
1063
|
+
s = JSON.parse(r);
|
|
1039
1064
|
} catch {
|
|
1040
|
-
|
|
1065
|
+
s = [];
|
|
1041
1066
|
}
|
|
1042
|
-
|
|
1067
|
+
s.length === 0 && v && (v.name || v.email) ? (s = [{ role: "user", content: `PRESET_USER_DETAILS: Name is "${v.name || ""}" , Email is "${v.email || ""}"` }], sessionStorage.setItem(
|
|
1043
1068
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
1044
|
-
JSON.stringify(
|
|
1045
|
-
)) :
|
|
1069
|
+
JSON.stringify(s)
|
|
1070
|
+
)) : r || sessionStorage.setItem(
|
|
1046
1071
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
1047
1072
|
JSON.stringify([])
|
|
1048
1073
|
);
|
|
1049
1074
|
})();
|
|
1050
|
-
}, [
|
|
1075
|
+
}, [v]), j(() => {
|
|
1051
1076
|
const e = () => {
|
|
1052
|
-
|
|
1077
|
+
et.current = Date.now(), Pe.current && (Pe.current = !1, F(!1), Oe([]), Te(""), oe(""), I(!1));
|
|
1053
1078
|
};
|
|
1054
1079
|
window.addEventListener("mousemove", e), window.addEventListener("keydown", e), window.addEventListener("mousedown", e), window.addEventListener("touchstart", e);
|
|
1055
1080
|
const t = setInterval(async () => {
|
|
1056
|
-
if (Date.now() -
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1081
|
+
if (Date.now() - et.current >= 3e4 && !ue && !ie && q === "Ready" && !Pe.current)
|
|
1082
|
+
if (Pe.current = !0, tt.current.length > 0)
|
|
1083
|
+
F(!0), Oe(tt.current);
|
|
1059
1084
|
else
|
|
1060
1085
|
try {
|
|
1061
|
-
const
|
|
1086
|
+
const o = `${at}/nudgeUser`, u = {
|
|
1062
1087
|
navigationUrl: window.location.href,
|
|
1063
|
-
token:
|
|
1064
|
-
}, p = await fetch(
|
|
1088
|
+
token: P
|
|
1089
|
+
}, p = await fetch(o, {
|
|
1065
1090
|
method: "POST",
|
|
1066
1091
|
headers: {
|
|
1067
1092
|
"Content-Type": "application/json"
|
|
1068
1093
|
},
|
|
1069
|
-
body: JSON.stringify(
|
|
1094
|
+
body: JSON.stringify(u)
|
|
1070
1095
|
});
|
|
1071
1096
|
if (p.ok) {
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1097
|
+
const k = (await p.json()).nudge_questions;
|
|
1098
|
+
k && k.length > 0 && (N("[NUDGE] Received nudge questions from API:", k), tt.current = k, F(!0), Oe(k));
|
|
1074
1099
|
}
|
|
1075
|
-
} catch (
|
|
1076
|
-
console.error("[NUDGE] Error calling /nudgeUser:",
|
|
1100
|
+
} catch (o) {
|
|
1101
|
+
console.error("[NUDGE] Error calling /nudgeUser:", o), Pe.current = !1;
|
|
1077
1102
|
}
|
|
1078
1103
|
}, 1e3);
|
|
1079
1104
|
return () => {
|
|
1080
1105
|
window.removeEventListener("mousemove", e), window.removeEventListener("keydown", e), window.removeEventListener("mousedown", e), window.removeEventListener("touchstart", e), clearInterval(t);
|
|
1081
1106
|
};
|
|
1082
|
-
}, [
|
|
1083
|
-
if (
|
|
1084
|
-
let e = 0, t = 0,
|
|
1085
|
-
const
|
|
1086
|
-
const
|
|
1087
|
-
if (
|
|
1088
|
-
const p =
|
|
1089
|
-
|
|
1107
|
+
}, [P, ue, ie, q]), j(() => {
|
|
1108
|
+
if (De.length === 0) return;
|
|
1109
|
+
let e = 0, t = 0, r = !1, s = 100;
|
|
1110
|
+
const o = () => {
|
|
1111
|
+
const u = De[e];
|
|
1112
|
+
if (r) {
|
|
1113
|
+
const p = u.substring(0, t - 1);
|
|
1114
|
+
Te(p), t--, s = 50;
|
|
1090
1115
|
} else {
|
|
1091
|
-
const p =
|
|
1092
|
-
|
|
1116
|
+
const p = u.substring(0, t + 1);
|
|
1117
|
+
Te(p), t++, s = 100;
|
|
1093
1118
|
}
|
|
1094
|
-
!
|
|
1119
|
+
!r && t === u.length ? (r = !0, s = 3e3) : r && t === 0 && (r = !1, e = (e + 1) % De.length, s = 500), B.current = setTimeout(o, s);
|
|
1095
1120
|
};
|
|
1096
|
-
return
|
|
1097
|
-
|
|
1121
|
+
return o(), () => {
|
|
1122
|
+
B.current && clearTimeout(B.current);
|
|
1098
1123
|
};
|
|
1099
|
-
}, [
|
|
1100
|
-
const
|
|
1124
|
+
}, [De]);
|
|
1125
|
+
const Ut = () => {
|
|
1101
1126
|
try {
|
|
1102
1127
|
return JSON.parse(
|
|
1103
1128
|
sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]"
|
|
@@ -1105,176 +1130,176 @@ const Cn = ({
|
|
|
1105
1130
|
} catch {
|
|
1106
1131
|
return [];
|
|
1107
1132
|
}
|
|
1108
|
-
},
|
|
1133
|
+
}, tn = (e) => {
|
|
1109
1134
|
sessionStorage.setItem(
|
|
1110
1135
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
1111
1136
|
JSON.stringify(e)
|
|
1112
1137
|
);
|
|
1113
|
-
}, [
|
|
1138
|
+
}, [St, Lt] = x(!1), [Ct, vt] = x(0), ye = a(null), ft = a([]), Ft = a(0), [Nt, nn] = x(
|
|
1114
1139
|
null
|
|
1115
|
-
), [
|
|
1140
|
+
), [rn, Rt] = x(
|
|
1116
1141
|
null
|
|
1117
|
-
),
|
|
1142
|
+
), ke = a(null), Be = a(
|
|
1118
1143
|
null
|
|
1119
|
-
),
|
|
1120
|
-
e && (
|
|
1144
|
+
), it = Qe((e = !1) => {
|
|
1145
|
+
e && (he.current = !0, w(!1), d("Ready")), $e.current = [], O.current = [], K.current = !1, I(!1), Le.current = 0, ve.current = 0, Re.current = 0, V.current.forEach((t) => {
|
|
1121
1146
|
try {
|
|
1122
1147
|
t.stop();
|
|
1123
1148
|
} catch {
|
|
1124
1149
|
}
|
|
1125
|
-
}),
|
|
1126
|
-
}, []),
|
|
1150
|
+
}), Ze.current && (clearTimeout(Ze.current), Ze.current = null), wt(null), lt(""), V.current = [];
|
|
1151
|
+
}, []), on = async () => {
|
|
1127
1152
|
try {
|
|
1128
|
-
const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext,
|
|
1129
|
-
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
p.data.size > 0 &&
|
|
1133
|
-
},
|
|
1134
|
-
const p = Date.now() -
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1153
|
+
const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext, r = new t(), s = r.createMediaStreamSource(e), o = r.createAnalyser();
|
|
1154
|
+
o.fftSize = 64, s.connect(o), ke.current = r, Be.current = s, Rt(o);
|
|
1155
|
+
const u = new MediaRecorder(e);
|
|
1156
|
+
ye.current = u, ft.current = [], u.ondataavailable = (p) => {
|
|
1157
|
+
p.data.size > 0 && ft.current.push(p.data);
|
|
1158
|
+
}, u.onstop = async () => {
|
|
1159
|
+
const p = Date.now() - Ft.current;
|
|
1160
|
+
if (Rt(null), Be.current && (Be.current.disconnect(), Be.current = null), ke.current && ke.current.state !== "closed" && (ke.current.close(), ke.current = null), p < 1e3) {
|
|
1161
|
+
d("Recording too short. Hold or click longer."), w(!1);
|
|
1137
1162
|
return;
|
|
1138
1163
|
}
|
|
1139
|
-
const
|
|
1164
|
+
const S = new Blob(ft.current, {
|
|
1140
1165
|
type: "audio/wav"
|
|
1141
1166
|
});
|
|
1142
|
-
await
|
|
1143
|
-
},
|
|
1167
|
+
await un(S);
|
|
1168
|
+
}, Ft.current = Date.now(), u.start(100), Lt(!0), d("Listening...");
|
|
1144
1169
|
} catch (e) {
|
|
1145
|
-
console.error("Error accessing microphone:", e),
|
|
1170
|
+
console.error("Error accessing microphone:", e), d("Mic Access Error");
|
|
1146
1171
|
}
|
|
1147
|
-
},
|
|
1148
|
-
|
|
1149
|
-
},
|
|
1150
|
-
|
|
1172
|
+
}, sn = () => {
|
|
1173
|
+
ye.current && ye.current.state !== "inactive" && (ye.current.stop(), ye.current.stream.getTracks().forEach((e) => e.stop()), Lt(!1));
|
|
1174
|
+
}, an = () => {
|
|
1175
|
+
ye.current && ye.current.state !== "inactive" && (ye.current.onstop = null, ye.current.stop(), ye.current.stream.getTracks().forEach((e) => e.stop()), Rt(null), Be.current && (Be.current.disconnect(), Be.current = null), ke.current && ke.current.state !== "closed" && (ke.current.close(), ke.current = null), Lt(!1), ft.current = [], d("Ready"));
|
|
1151
1176
|
};
|
|
1152
|
-
|
|
1153
|
-
if (!
|
|
1177
|
+
j(() => {
|
|
1178
|
+
if (!ue) return;
|
|
1154
1179
|
const e = () => {
|
|
1155
|
-
const t =
|
|
1180
|
+
const t = Re.current;
|
|
1156
1181
|
if (t <= 0) return;
|
|
1157
|
-
const
|
|
1158
|
-
if (!
|
|
1159
|
-
const
|
|
1160
|
-
if (
|
|
1161
|
-
const
|
|
1162
|
-
Math.round(
|
|
1163
|
-
|
|
1182
|
+
const r = Q.current, s = Le.current;
|
|
1183
|
+
if (!r) return;
|
|
1184
|
+
const o = r.currentTime - s, u = Math.min(Math.max(0, o), t), S = en(xe).trim().length;
|
|
1185
|
+
if (S <= 0) return;
|
|
1186
|
+
const k = Math.min(
|
|
1187
|
+
Math.round(u / t * S),
|
|
1188
|
+
S
|
|
1164
1189
|
);
|
|
1165
|
-
|
|
1190
|
+
je(k);
|
|
1166
1191
|
};
|
|
1167
|
-
return clearInterval(
|
|
1168
|
-
}, [
|
|
1192
|
+
return clearInterval(Je.current ?? void 0), Je.current = setInterval(e, 90), () => clearInterval(Je.current ?? void 0);
|
|
1193
|
+
}, [ue, xe, Re.current]), j(() => {
|
|
1169
1194
|
let e;
|
|
1170
|
-
return
|
|
1171
|
-
|
|
1172
|
-
}, 1e3)) :
|
|
1173
|
-
}, [
|
|
1174
|
-
const
|
|
1175
|
-
const t = e.numberOfChannels,
|
|
1176
|
-
let
|
|
1177
|
-
const p = (
|
|
1178
|
-
|
|
1179
|
-
},
|
|
1180
|
-
|
|
1195
|
+
return St ? (vt(0), e = window.setInterval(() => {
|
|
1196
|
+
vt((t) => t + 1);
|
|
1197
|
+
}, 1e3)) : vt(0), () => clearInterval(e);
|
|
1198
|
+
}, [St]);
|
|
1199
|
+
const cn = (e) => {
|
|
1200
|
+
const t = e.numberOfChannels, r = e.length * t * 2 + 44, s = new ArrayBuffer(r), o = new DataView(s);
|
|
1201
|
+
let u = 0;
|
|
1202
|
+
const p = (L) => {
|
|
1203
|
+
o.setUint16(u, L, !0), u += 2;
|
|
1204
|
+
}, S = (L) => {
|
|
1205
|
+
o.setUint32(u, L, !0), u += 4;
|
|
1181
1206
|
};
|
|
1182
|
-
|
|
1183
|
-
const
|
|
1184
|
-
for (let
|
|
1185
|
-
let
|
|
1186
|
-
for (;
|
|
1187
|
-
for (let
|
|
1188
|
-
let
|
|
1189
|
-
|
|
1207
|
+
S(1179011410), S(r - 8), S(1163280727), S(544501094), S(16), p(1), p(t), S(e.sampleRate), S(e.sampleRate * 2 * t), p(t * 2), p(16), S(1635017060), S(r - u - 4);
|
|
1208
|
+
const k = [];
|
|
1209
|
+
for (let L = 0; L < t; L++) k.push(e.getChannelData(L));
|
|
1210
|
+
let M = 0;
|
|
1211
|
+
for (; u < r; ) {
|
|
1212
|
+
for (let L = 0; L < t; L++) {
|
|
1213
|
+
let U = Math.max(-1, Math.min(1, k[L][M]));
|
|
1214
|
+
U = U < 0 ? U * 32768 : U * 32767, o.setInt16(u, U, !0), u += 2;
|
|
1190
1215
|
}
|
|
1191
|
-
|
|
1216
|
+
M++;
|
|
1192
1217
|
}
|
|
1193
|
-
return new Blob([
|
|
1194
|
-
},
|
|
1195
|
-
if (!
|
|
1196
|
-
if (
|
|
1197
|
-
|
|
1218
|
+
return new Blob([s], { type: "audio/wav" });
|
|
1219
|
+
}, kt = async (e, t, r = !1) => {
|
|
1220
|
+
if (!he.current) {
|
|
1221
|
+
if (D.current) {
|
|
1222
|
+
O.current.push({
|
|
1198
1223
|
audio: e,
|
|
1199
1224
|
visemes: t,
|
|
1200
|
-
isNewSegment:
|
|
1225
|
+
isNewSegment: r
|
|
1201
1226
|
});
|
|
1202
1227
|
return;
|
|
1203
1228
|
}
|
|
1204
|
-
|
|
1229
|
+
D.current = !0;
|
|
1205
1230
|
try {
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
for (let
|
|
1210
|
-
p[
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
const
|
|
1214
|
-
let
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
let
|
|
1220
|
-
if ((!
|
|
1221
|
-
|
|
1231
|
+
const s = window.AudioContext || window.webkitAudioContext, o = Q.current ?? new s();
|
|
1232
|
+
o.state === "suspended" && await o.resume(), Q.current = o;
|
|
1233
|
+
const u = window.atob(e), p = new Uint8Array(u.length);
|
|
1234
|
+
for (let H = 0; H < u.length; H++)
|
|
1235
|
+
p[H] = u.charCodeAt(H);
|
|
1236
|
+
const S = await o.decodeAudioData(p.buffer.slice(0));
|
|
1237
|
+
Re.current += S.duration;
|
|
1238
|
+
const k = o.currentTime;
|
|
1239
|
+
let M = ve.current;
|
|
1240
|
+
const L = !K.current;
|
|
1241
|
+
M < k && (M = k + 0.1), ve.current = M + S.duration;
|
|
1242
|
+
const U = o.createBufferSource();
|
|
1243
|
+
U.buffer = S;
|
|
1244
|
+
let Z = Nt;
|
|
1245
|
+
if ((!Z || Z.context !== o) && (Z = o.createAnalyser(), Z.fftSize = 64, Z.connect(o.destination), nn(Z)), U.connect(Z), V.current.push(U), he.current) {
|
|
1246
|
+
V.current = V.current.filter((H) => H !== U);
|
|
1222
1247
|
return;
|
|
1223
1248
|
}
|
|
1224
|
-
if (
|
|
1225
|
-
|
|
1226
|
-
`[AUDIO] setIsSpeaking(true) - First chunk starting at ${
|
|
1249
|
+
if (L) {
|
|
1250
|
+
K.current = !0, I(!0), N(
|
|
1251
|
+
`[AUDIO] setIsSpeaking(true) - First chunk starting at ${M.toFixed(
|
|
1227
1252
|
3
|
|
1228
1253
|
)}`
|
|
1229
|
-
),
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
`[AUDIO] Response started. Initial startTime: ${
|
|
1254
|
+
), Le.current = M;
|
|
1255
|
+
const H = (M - k) * 1e3;
|
|
1256
|
+
ee.current = performance.now() + H, N(
|
|
1257
|
+
`[AUDIO] Response started. Initial startTime: ${M.toFixed(
|
|
1233
1258
|
3
|
|
1234
|
-
)}, CT: ${
|
|
1259
|
+
)}, CT: ${k.toFixed(3)}`
|
|
1235
1260
|
);
|
|
1236
1261
|
}
|
|
1237
|
-
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
`[AUDIO] New segment detected at +${
|
|
1262
|
+
U.start(M);
|
|
1263
|
+
const ce = (M - Le.current) * 1e3;
|
|
1264
|
+
r && (Ue.current = ce, N(
|
|
1265
|
+
`[AUDIO] New segment detected at +${ce.toFixed(
|
|
1241
1266
|
0
|
|
1242
1267
|
)}ms. Resetting segment offset.`
|
|
1243
|
-
)), t.forEach((
|
|
1244
|
-
const
|
|
1245
|
-
if (
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
`[AUDIO] Viseme "${
|
|
1268
|
+
)), t.forEach((H, ge) => {
|
|
1269
|
+
const W = H.symbol ?? "";
|
|
1270
|
+
if (W) {
|
|
1271
|
+
const be = Wn(W), Se = Math.round(H.start * 1e3), Ve = Math.round((H.duration ?? 0) * 1e3), Ht = Ue.current + Se;
|
|
1272
|
+
ge < 3 && N(
|
|
1273
|
+
`[AUDIO] Viseme "${W}": segment_relative=${Se}ms, segment_offset=${Ue.current.toFixed(
|
|
1249
1274
|
0
|
|
1250
|
-
)}ms => vtime=${
|
|
1251
|
-
),
|
|
1252
|
-
|
|
1253
|
-
viseme:
|
|
1254
|
-
weight:
|
|
1255
|
-
vtime:
|
|
1256
|
-
vduration:
|
|
1275
|
+
)}ms => vtime=${Ht}ms`
|
|
1276
|
+
), be.forEach((jt) => {
|
|
1277
|
+
$e.current.push({
|
|
1278
|
+
viseme: jt.v,
|
|
1279
|
+
weight: jt.w,
|
|
1280
|
+
vtime: Ht,
|
|
1281
|
+
vduration: Ve
|
|
1257
1282
|
});
|
|
1258
1283
|
});
|
|
1259
1284
|
}
|
|
1260
|
-
}),
|
|
1285
|
+
}), d("Speaking...");
|
|
1261
1286
|
} finally {
|
|
1262
|
-
if (
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1287
|
+
if (D.current = !1, O.current.length > 0) {
|
|
1288
|
+
const s = O.current.shift();
|
|
1289
|
+
s && kt(s.audio, s.visemes, s.isNewSegment);
|
|
1265
1290
|
}
|
|
1266
1291
|
}
|
|
1267
1292
|
}
|
|
1268
|
-
},
|
|
1293
|
+
}, un = async (e) => {
|
|
1269
1294
|
try {
|
|
1270
|
-
|
|
1271
|
-
const t = await e.arrayBuffer(),
|
|
1272
|
-
|
|
1273
|
-
const p =
|
|
1274
|
-
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
)}`,
|
|
1295
|
+
w(!0), F(!1), de.current = "", oe(""), d("Processing Voice...");
|
|
1296
|
+
const t = await e.arrayBuffer(), s = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), o = cn(s), u = new FileReader();
|
|
1297
|
+
u.readAsDataURL(o), u.onloadend = async () => {
|
|
1298
|
+
const p = u.result.split(",")[1];
|
|
1299
|
+
it(), T(""), z.current = "", pe.current = !1;
|
|
1300
|
+
const S = `${at}/stt?token=${encodeURIComponent(
|
|
1301
|
+
P
|
|
1302
|
+
)}`, k = await fetch(S, {
|
|
1278
1303
|
method: "POST",
|
|
1279
1304
|
headers: { "Content-Type": "application/json" },
|
|
1280
1305
|
body: JSON.stringify({
|
|
@@ -1282,55 +1307,55 @@ const Cn = ({
|
|
|
1282
1307
|
audio_format: "wav"
|
|
1283
1308
|
})
|
|
1284
1309
|
});
|
|
1285
|
-
if (
|
|
1310
|
+
if (k.status === 429) {
|
|
1286
1311
|
try {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1312
|
+
const ge = await k.text(), W = JSON.parse(ge);
|
|
1313
|
+
N("[STT] 429 agent at capacity:", W?.detail);
|
|
1289
1314
|
} catch {
|
|
1290
1315
|
}
|
|
1291
|
-
|
|
1316
|
+
T(""), d("Busy"), w(!1);
|
|
1292
1317
|
return;
|
|
1293
1318
|
}
|
|
1294
|
-
if (!
|
|
1295
|
-
const
|
|
1296
|
-
let
|
|
1319
|
+
if (!k.ok) {
|
|
1320
|
+
const ge = await k.text();
|
|
1321
|
+
let W = "STT Failed";
|
|
1297
1322
|
try {
|
|
1298
|
-
|
|
1323
|
+
W = JSON.parse(ge).error || W;
|
|
1299
1324
|
} catch {
|
|
1300
|
-
|
|
1325
|
+
ge && (W = ge.slice(0, 200));
|
|
1301
1326
|
}
|
|
1302
|
-
throw new Error(
|
|
1327
|
+
throw new Error(W);
|
|
1303
1328
|
}
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1329
|
+
const M = k.body;
|
|
1330
|
+
if (N("this is body" + M), !M) {
|
|
1331
|
+
d("STT Failed"), w(!1);
|
|
1307
1332
|
return;
|
|
1308
1333
|
}
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1311
|
-
const
|
|
1312
|
-
let
|
|
1313
|
-
const
|
|
1314
|
-
switch (
|
|
1334
|
+
const L = M.getReader();
|
|
1335
|
+
he.current = !1;
|
|
1336
|
+
const U = new TextDecoder();
|
|
1337
|
+
let Z = "", ce = !1;
|
|
1338
|
+
const H = async (ge, W) => {
|
|
1339
|
+
switch (ge) {
|
|
1315
1340
|
case "transcript":
|
|
1316
|
-
|
|
1341
|
+
W.transcript != null && T(String(W.transcript));
|
|
1317
1342
|
break;
|
|
1318
1343
|
case "text": {
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1344
|
+
const be = W.delta ?? W.text ?? "";
|
|
1345
|
+
be && Ot(be);
|
|
1321
1346
|
break;
|
|
1322
1347
|
}
|
|
1323
1348
|
case "audio": {
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1349
|
+
const be = W.chunk, Se = W.visemes ?? [], Ve = !!W.is_new_segment;
|
|
1350
|
+
be && await kt(be, Se, Ve);
|
|
1326
1351
|
break;
|
|
1327
1352
|
}
|
|
1328
1353
|
case "done": {
|
|
1329
|
-
|
|
1354
|
+
ce = !0, d("Ready"), w(!1);
|
|
1330
1355
|
break;
|
|
1331
1356
|
}
|
|
1332
1357
|
case "error": {
|
|
1333
|
-
|
|
1358
|
+
ce = !0, d("STT Failed"), w(!1);
|
|
1334
1359
|
break;
|
|
1335
1360
|
}
|
|
1336
1361
|
default:
|
|
@@ -1338,226 +1363,226 @@ const Cn = ({
|
|
|
1338
1363
|
}
|
|
1339
1364
|
};
|
|
1340
1365
|
for (; ; ) {
|
|
1341
|
-
const { done:
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1366
|
+
const { done: ge, value: W } = await L.read();
|
|
1367
|
+
W && (Z += U.decode(W, { stream: !0 }));
|
|
1368
|
+
const be = Z.split(`
|
|
1344
1369
|
|
|
1345
1370
|
`);
|
|
1346
|
-
|
|
1347
|
-
for (const
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1371
|
+
Z = be.pop() ?? "";
|
|
1372
|
+
for (const Se of be) {
|
|
1373
|
+
const Ve = Ke(Se);
|
|
1374
|
+
Ve && await H(Ve.event, Ve.data);
|
|
1350
1375
|
}
|
|
1351
|
-
if (
|
|
1352
|
-
if (
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1376
|
+
if (ge) {
|
|
1377
|
+
if (Z.trim()) {
|
|
1378
|
+
const Se = Ke(Z.trim());
|
|
1379
|
+
Se && await H(Se.event, Se.data);
|
|
1355
1380
|
}
|
|
1356
|
-
|
|
1381
|
+
ce || (d("Ready"), w(!1));
|
|
1357
1382
|
break;
|
|
1358
1383
|
}
|
|
1359
1384
|
}
|
|
1360
1385
|
};
|
|
1361
1386
|
} catch (t) {
|
|
1362
|
-
console.error("Audio Submission Error:", t),
|
|
1387
|
+
console.error("Audio Submission Error:", t), d("STT Failed"), w(!1);
|
|
1363
1388
|
}
|
|
1364
|
-
},
|
|
1365
|
-
e && e.preventDefault(),
|
|
1366
|
-
},
|
|
1389
|
+
}, ln = async (e) => {
|
|
1390
|
+
e && e.preventDefault(), F(!1), de.current = "", oe(""), !(!me || ie) && await hn(me);
|
|
1391
|
+
}, Ke = (e) => {
|
|
1367
1392
|
const t = e.split(/\r?\n/);
|
|
1368
|
-
let
|
|
1369
|
-
for (const
|
|
1370
|
-
|
|
1371
|
-
if (!
|
|
1372
|
-
let
|
|
1373
|
-
if (
|
|
1393
|
+
let r = "", s = "";
|
|
1394
|
+
for (const u of t)
|
|
1395
|
+
u.startsWith("event:") ? r = u.slice(6).trim() : u.startsWith("data:") && (s = u.slice(5).trim());
|
|
1396
|
+
if (!r) return null;
|
|
1397
|
+
let o = {};
|
|
1398
|
+
if (s)
|
|
1374
1399
|
try {
|
|
1375
|
-
|
|
1400
|
+
o = JSON.parse(s);
|
|
1376
1401
|
} catch {
|
|
1377
|
-
|
|
1402
|
+
o = { raw: s };
|
|
1378
1403
|
}
|
|
1379
|
-
return { event:
|
|
1380
|
-
},
|
|
1404
|
+
return { event: r, data: o };
|
|
1405
|
+
}, mt = (e, t) => {
|
|
1381
1406
|
switch (e) {
|
|
1382
1407
|
case "connected":
|
|
1383
|
-
|
|
1408
|
+
z.current = "", pe.current = !1;
|
|
1384
1409
|
break;
|
|
1385
1410
|
case "text": {
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1411
|
+
const r = t.delta ?? "";
|
|
1412
|
+
r && Ot(r);
|
|
1388
1413
|
break;
|
|
1389
1414
|
}
|
|
1390
1415
|
case "audio": {
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1416
|
+
const r = t.chunk, s = t.visemes ?? [];
|
|
1417
|
+
r && kt(r, s);
|
|
1393
1418
|
break;
|
|
1394
1419
|
}
|
|
1395
1420
|
case "done": {
|
|
1396
|
-
const
|
|
1397
|
-
...
|
|
1398
|
-
{ role: "user", content:
|
|
1399
|
-
{ role: "assistant", content:
|
|
1421
|
+
const r = Ut(), s = de.current.trim(), o = [
|
|
1422
|
+
...r,
|
|
1423
|
+
{ role: "user", content: me || "..." },
|
|
1424
|
+
{ role: "assistant", content: s }
|
|
1400
1425
|
];
|
|
1401
|
-
|
|
1426
|
+
tn(o), G.current = [...$e.current], d("Ready"), w(!1), T("");
|
|
1402
1427
|
break;
|
|
1403
1428
|
}
|
|
1404
1429
|
case "error": {
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1430
|
+
const r = t.message ?? "Unknown error";
|
|
1431
|
+
de.current = r, oe(r), d("Agent Failed"), w(!1);
|
|
1407
1432
|
break;
|
|
1408
1433
|
}
|
|
1409
1434
|
}
|
|
1410
|
-
},
|
|
1411
|
-
|
|
1435
|
+
}, Pt = async (e, t) => {
|
|
1436
|
+
w(!0), d("Thinking..."), de.current = "", z.current = "", pe.current = !1, it(), Re.current = 0, je(0);
|
|
1412
1437
|
try {
|
|
1413
|
-
const
|
|
1438
|
+
const r = await fetch(e, {
|
|
1414
1439
|
method: "POST",
|
|
1415
1440
|
headers: { "Content-Type": "application/json" },
|
|
1416
1441
|
body: JSON.stringify(t)
|
|
1417
1442
|
});
|
|
1418
|
-
if (
|
|
1419
|
-
|
|
1443
|
+
if (r.status === 429) {
|
|
1444
|
+
d("Busy"), w(!1);
|
|
1420
1445
|
return;
|
|
1421
1446
|
}
|
|
1422
|
-
if (!
|
|
1423
|
-
const
|
|
1424
|
-
if (!
|
|
1425
|
-
|
|
1447
|
+
if (!r.ok) throw new Error("Request failed");
|
|
1448
|
+
const s = r.body;
|
|
1449
|
+
if (!s) {
|
|
1450
|
+
d("Failed"), w(!1);
|
|
1426
1451
|
return;
|
|
1427
1452
|
}
|
|
1428
|
-
const
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1453
|
+
const o = s.getReader();
|
|
1454
|
+
he.current = !1;
|
|
1455
|
+
const u = new TextDecoder();
|
|
1431
1456
|
let p = "";
|
|
1432
1457
|
for (; ; ) {
|
|
1433
|
-
const { done:
|
|
1434
|
-
|
|
1435
|
-
const
|
|
1458
|
+
const { done: S, value: k } = await o.read();
|
|
1459
|
+
k && (p += u.decode(k, { stream: !0 }));
|
|
1460
|
+
const M = p.split(`
|
|
1436
1461
|
|
|
1437
1462
|
`);
|
|
1438
|
-
p =
|
|
1439
|
-
for (const
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1463
|
+
p = M.pop() ?? "";
|
|
1464
|
+
for (const L of M) {
|
|
1465
|
+
const U = Ke(L);
|
|
1466
|
+
U && mt(U.event, U.data);
|
|
1442
1467
|
}
|
|
1443
|
-
if (
|
|
1468
|
+
if (S) {
|
|
1444
1469
|
if (p.trim()) {
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1470
|
+
const L = Ke(p.trim());
|
|
1471
|
+
L && mt(L.event, L.data);
|
|
1447
1472
|
}
|
|
1448
|
-
|
|
1473
|
+
d("Ready"), w(!1);
|
|
1449
1474
|
break;
|
|
1450
1475
|
}
|
|
1451
1476
|
}
|
|
1452
|
-
} catch (
|
|
1453
|
-
console.error("Streaming Error:",
|
|
1477
|
+
} catch (r) {
|
|
1478
|
+
console.error("Streaming Error:", r), d("Failed"), w(!1);
|
|
1454
1479
|
}
|
|
1455
|
-
},
|
|
1456
|
-
const
|
|
1457
|
-
await
|
|
1458
|
-
}, []),
|
|
1459
|
-
const
|
|
1460
|
-
await
|
|
1461
|
-
}, []),
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
}, [
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
const t = `${
|
|
1468
|
-
|
|
1480
|
+
}, Bt = Qe(async (e, t, r) => {
|
|
1481
|
+
const s = `${at}/avatar_tts`;
|
|
1482
|
+
await Pt(s, { text: e, userQuery: t, llmPrompt: r });
|
|
1483
|
+
}, []), Vt = Qe(async (e, t, r, s) => {
|
|
1484
|
+
const o = `${at}/avatar_ttsWithKnowledge`;
|
|
1485
|
+
await Pt(o, { userQuery: e, llmPrompt: t, knowledge: r, history: s });
|
|
1486
|
+
}, []), Wt = a(!1);
|
|
1487
|
+
j(() => {
|
|
1488
|
+
J && !Wt.current && (J({ avatarSpeak: Bt, avatarRespond: Vt }), Wt.current = !0);
|
|
1489
|
+
}, [J, Bt, Vt]);
|
|
1490
|
+
const hn = async (e) => {
|
|
1491
|
+
w(!0), d("Thinking..."), de.current = "", z.current = "", pe.current = !1, it(), Re.current = 0, je(0);
|
|
1492
|
+
const t = `${at}/agent/chat?token=${encodeURIComponent(
|
|
1493
|
+
P
|
|
1469
1494
|
)}`;
|
|
1470
1495
|
try {
|
|
1471
|
-
const
|
|
1472
|
-
let
|
|
1473
|
-
|
|
1496
|
+
const r = Ut();
|
|
1497
|
+
let s = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
|
|
1498
|
+
s || (vn(
|
|
1474
1499
|
"[CHAT] Session UID missing at send time! Generating emergency backup."
|
|
1475
|
-
),
|
|
1476
|
-
const
|
|
1477
|
-
history:
|
|
1500
|
+
), s = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", s));
|
|
1501
|
+
const o = {
|
|
1502
|
+
history: r,
|
|
1478
1503
|
question: e,
|
|
1479
|
-
lead_id:
|
|
1504
|
+
lead_id: s
|
|
1480
1505
|
};
|
|
1481
|
-
|
|
1482
|
-
const
|
|
1506
|
+
N("[CHAT] Sending payload:", o);
|
|
1507
|
+
const u = await fetch(t, {
|
|
1483
1508
|
method: "POST",
|
|
1484
1509
|
headers: {
|
|
1485
1510
|
"Content-Type": "application/json"
|
|
1486
1511
|
},
|
|
1487
|
-
body: JSON.stringify(
|
|
1512
|
+
body: JSON.stringify(o),
|
|
1488
1513
|
cache: "default"
|
|
1489
1514
|
});
|
|
1490
|
-
if (
|
|
1515
|
+
if (u.status === 429) {
|
|
1491
1516
|
try {
|
|
1492
|
-
const
|
|
1493
|
-
|
|
1517
|
+
const L = await u.json();
|
|
1518
|
+
N("[CHAT] 429 agent at capacity:", L?.detail);
|
|
1494
1519
|
} catch {
|
|
1495
1520
|
}
|
|
1496
|
-
|
|
1521
|
+
T(""), d("Busy"), w(!1);
|
|
1497
1522
|
return;
|
|
1498
1523
|
}
|
|
1499
|
-
if (!
|
|
1524
|
+
if (!u.ok)
|
|
1500
1525
|
throw new Error("Agent request failed");
|
|
1501
|
-
const p =
|
|
1526
|
+
const p = u.body;
|
|
1502
1527
|
if (!p) {
|
|
1503
|
-
|
|
1528
|
+
d("Agent Failed"), w(!1);
|
|
1504
1529
|
return;
|
|
1505
1530
|
}
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
const
|
|
1509
|
-
let
|
|
1531
|
+
const S = p.getReader();
|
|
1532
|
+
he.current = !1;
|
|
1533
|
+
const k = new TextDecoder();
|
|
1534
|
+
let M = "";
|
|
1510
1535
|
for (; ; ) {
|
|
1511
|
-
const { done:
|
|
1512
|
-
|
|
1513
|
-
`[SSE] Chunk received. done=${
|
|
1514
|
-
),
|
|
1515
|
-
const
|
|
1536
|
+
const { done: L, value: U } = await S.read();
|
|
1537
|
+
N(
|
|
1538
|
+
`[SSE] Chunk received. done=${L}, length=${U?.length || 0}`
|
|
1539
|
+
), U && (M += k.decode(U, { stream: !0 }));
|
|
1540
|
+
const Z = M.split(`
|
|
1516
1541
|
|
|
1517
1542
|
`);
|
|
1518
|
-
|
|
1519
|
-
for (const
|
|
1520
|
-
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1543
|
+
M = Z.pop() ?? "";
|
|
1544
|
+
for (const ce of Z) {
|
|
1545
|
+
N(`[SSE] Processing block: ${ce.slice(0, 50)}...`);
|
|
1546
|
+
const H = Ke(ce);
|
|
1547
|
+
H && (N(`[SSE] Event: ${H.event}`), mt(H.event, H.data));
|
|
1523
1548
|
}
|
|
1524
|
-
if (
|
|
1525
|
-
if (
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1549
|
+
if (L) {
|
|
1550
|
+
if (N("[SSE] Stream finished"), M.trim()) {
|
|
1551
|
+
const ce = Ke(M.trim());
|
|
1552
|
+
ce && mt(ce.event, ce.data);
|
|
1528
1553
|
}
|
|
1529
|
-
|
|
1554
|
+
d("Ready"), w(!1), T("");
|
|
1530
1555
|
break;
|
|
1531
1556
|
}
|
|
1532
1557
|
}
|
|
1533
|
-
} catch (
|
|
1534
|
-
console.error("Chat Error:",
|
|
1558
|
+
} catch (r) {
|
|
1559
|
+
console.error("Chat Error:", r), d("Agent Failed"), w(!1);
|
|
1535
1560
|
}
|
|
1536
|
-
},
|
|
1561
|
+
}, dn = xe.trim(), $t = en(dn), xt = $t && ue ? $t.slice(
|
|
1537
1562
|
0,
|
|
1538
|
-
|
|
1563
|
+
He != null && He > 0 ? He : 0
|
|
1539
1564
|
) : "";
|
|
1540
|
-
|
|
1541
|
-
const e =
|
|
1542
|
-
e !== "exiting" && (
|
|
1543
|
-
}, [
|
|
1544
|
-
const
|
|
1545
|
-
const e =
|
|
1546
|
-
e === "entering" ?
|
|
1565
|
+
j(() => {
|
|
1566
|
+
const e = Ee.current;
|
|
1567
|
+
e !== "exiting" && (xt ? (dt(xt), e === "hidden" && we("entering")) : (e === "visible" || e === "entering") && we("exiting"));
|
|
1568
|
+
}, [xt, ne]);
|
|
1569
|
+
const fn = Qe(() => {
|
|
1570
|
+
const e = Ee.current;
|
|
1571
|
+
e === "entering" ? we("visible") : e === "exiting" && we("hidden");
|
|
1547
1572
|
}, []);
|
|
1548
|
-
|
|
1549
|
-
const e =
|
|
1573
|
+
yn(() => {
|
|
1574
|
+
const e = Ye.current;
|
|
1550
1575
|
e && (e.scrollTop = e.scrollHeight);
|
|
1551
|
-
}, [
|
|
1552
|
-
const
|
|
1553
|
-
return /* @__PURE__ */
|
|
1554
|
-
/* @__PURE__ */
|
|
1555
|
-
|
|
1576
|
+
}, [Ne]);
|
|
1577
|
+
const mn = y === "female" ? Un : On;
|
|
1578
|
+
return /* @__PURE__ */ _e("div", { className: "avatar-widget-container", children: [
|
|
1579
|
+
/* @__PURE__ */ _e("div", { className: "avatar-input-area", children: [
|
|
1580
|
+
l !== "hidden" ? /* @__PURE__ */ f(
|
|
1556
1581
|
"div",
|
|
1557
1582
|
{
|
|
1558
|
-
className: `avatar-thinking-tab${
|
|
1559
|
-
onAnimationEnd:
|
|
1560
|
-
children:
|
|
1583
|
+
className: `avatar-thinking-tab${l === "exiting" ? " avatar-thinking-tab--exiting" : l === "entering" ? " avatar-thinking-tab--entering" : ""}`,
|
|
1584
|
+
onAnimationEnd: ae,
|
|
1585
|
+
children: X === Zt ? /* @__PURE__ */ f(
|
|
1561
1586
|
"a",
|
|
1562
1587
|
{
|
|
1563
1588
|
href: "https://leads.streamoji.com",
|
|
@@ -1565,10 +1590,10 @@ const Cn = ({
|
|
|
1565
1590
|
rel: "noopener noreferrer",
|
|
1566
1591
|
children: "Made by Streamoji Leads"
|
|
1567
1592
|
}
|
|
1568
|
-
) :
|
|
1593
|
+
) : X
|
|
1569
1594
|
}
|
|
1570
1595
|
) : null,
|
|
1571
|
-
/* @__PURE__ */
|
|
1596
|
+
/* @__PURE__ */ f("div", { className: "avatar-input-container", children: /* @__PURE__ */ f(
|
|
1572
1597
|
"div",
|
|
1573
1598
|
{
|
|
1574
1599
|
style: {
|
|
@@ -1577,15 +1602,15 @@ const Cn = ({
|
|
|
1577
1602
|
width: "100%",
|
|
1578
1603
|
height: "100%"
|
|
1579
1604
|
},
|
|
1580
|
-
children:
|
|
1581
|
-
/* @__PURE__ */
|
|
1605
|
+
children: St ? /* @__PURE__ */ _e("div", { className: "avatar-input-recording", children: [
|
|
1606
|
+
/* @__PURE__ */ f(
|
|
1582
1607
|
"button",
|
|
1583
1608
|
{
|
|
1584
1609
|
type: "button",
|
|
1585
1610
|
className: "avatar-recording-cancel",
|
|
1586
|
-
onClick:
|
|
1611
|
+
onClick: an,
|
|
1587
1612
|
title: "Cancel",
|
|
1588
|
-
children: /* @__PURE__ */
|
|
1613
|
+
children: /* @__PURE__ */ _e(
|
|
1589
1614
|
"svg",
|
|
1590
1615
|
{
|
|
1591
1616
|
width: "18",
|
|
@@ -1598,14 +1623,14 @@ const Cn = ({
|
|
|
1598
1623
|
strokeLinejoin: "round",
|
|
1599
1624
|
style: { display: "block" },
|
|
1600
1625
|
children: [
|
|
1601
|
-
/* @__PURE__ */
|
|
1602
|
-
/* @__PURE__ */
|
|
1626
|
+
/* @__PURE__ */ f("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1627
|
+
/* @__PURE__ */ f("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1603
1628
|
]
|
|
1604
1629
|
}
|
|
1605
1630
|
)
|
|
1606
1631
|
}
|
|
1607
1632
|
),
|
|
1608
|
-
/* @__PURE__ */
|
|
1633
|
+
/* @__PURE__ */ _e(
|
|
1609
1634
|
"div",
|
|
1610
1635
|
{
|
|
1611
1636
|
style: {
|
|
@@ -1617,8 +1642,8 @@ const Cn = ({
|
|
|
1617
1642
|
minWidth: 0
|
|
1618
1643
|
},
|
|
1619
1644
|
children: [
|
|
1620
|
-
/* @__PURE__ */
|
|
1621
|
-
/* @__PURE__ */
|
|
1645
|
+
/* @__PURE__ */ f("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ f(Jt, { analyser: rn }) }),
|
|
1646
|
+
/* @__PURE__ */ _e(
|
|
1622
1647
|
"span",
|
|
1623
1648
|
{
|
|
1624
1649
|
style: {
|
|
@@ -1631,23 +1656,23 @@ const Cn = ({
|
|
|
1631
1656
|
fontVariantNumeric: "tabular-nums"
|
|
1632
1657
|
},
|
|
1633
1658
|
children: [
|
|
1634
|
-
Math.floor(
|
|
1659
|
+
Math.floor(Ct / 60),
|
|
1635
1660
|
":",
|
|
1636
|
-
String(
|
|
1661
|
+
String(Ct % 60).padStart(2, "0")
|
|
1637
1662
|
]
|
|
1638
1663
|
}
|
|
1639
1664
|
)
|
|
1640
1665
|
]
|
|
1641
1666
|
}
|
|
1642
1667
|
),
|
|
1643
|
-
/* @__PURE__ */
|
|
1668
|
+
/* @__PURE__ */ f(
|
|
1644
1669
|
"button",
|
|
1645
1670
|
{
|
|
1646
1671
|
type: "button",
|
|
1647
1672
|
className: "avatar-recording-confirm",
|
|
1648
|
-
onClick:
|
|
1673
|
+
onClick: sn,
|
|
1649
1674
|
title: "Send",
|
|
1650
|
-
children: /* @__PURE__ */
|
|
1675
|
+
children: /* @__PURE__ */ f(
|
|
1651
1676
|
"svg",
|
|
1652
1677
|
{
|
|
1653
1678
|
width: "18",
|
|
@@ -1659,13 +1684,13 @@ const Cn = ({
|
|
|
1659
1684
|
strokeLinecap: "round",
|
|
1660
1685
|
strokeLinejoin: "round",
|
|
1661
1686
|
style: { display: "block" },
|
|
1662
|
-
children: /* @__PURE__ */
|
|
1687
|
+
children: /* @__PURE__ */ f("polyline", { points: "20 6 9 17 4 12" })
|
|
1663
1688
|
}
|
|
1664
1689
|
)
|
|
1665
1690
|
}
|
|
1666
1691
|
)
|
|
1667
|
-
] }) :
|
|
1668
|
-
/* @__PURE__ */
|
|
1692
|
+
] }) : ue && !Me ? /* @__PURE__ */ _e("div", { className: "avatar-input-speaking", children: [
|
|
1693
|
+
/* @__PURE__ */ f(
|
|
1669
1694
|
"div",
|
|
1670
1695
|
{
|
|
1671
1696
|
style: {
|
|
@@ -1675,20 +1700,20 @@ const Cn = ({
|
|
|
1675
1700
|
alignItems: "center",
|
|
1676
1701
|
paddingRight: "8px"
|
|
1677
1702
|
},
|
|
1678
|
-
children: /* @__PURE__ */
|
|
1703
|
+
children: /* @__PURE__ */ f(Jt, { analyser: Nt })
|
|
1679
1704
|
}
|
|
1680
1705
|
),
|
|
1681
|
-
/* @__PURE__ */
|
|
1706
|
+
/* @__PURE__ */ f(
|
|
1682
1707
|
"button",
|
|
1683
1708
|
{
|
|
1684
1709
|
type: "button",
|
|
1685
1710
|
className: "avatar-speaking-stop",
|
|
1686
|
-
onClick: () =>
|
|
1711
|
+
onClick: () => it(!0),
|
|
1687
1712
|
title: "Stop",
|
|
1688
|
-
children: /* @__PURE__ */
|
|
1713
|
+
children: /* @__PURE__ */ f("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
|
|
1689
1714
|
}
|
|
1690
1715
|
)
|
|
1691
|
-
] }) :
|
|
1716
|
+
] }) : ie ? /* @__PURE__ */ f(
|
|
1692
1717
|
"div",
|
|
1693
1718
|
{
|
|
1694
1719
|
style: {
|
|
@@ -1698,12 +1723,12 @@ const Cn = ({
|
|
|
1698
1723
|
alignItems: "center",
|
|
1699
1724
|
justifyContent: "center"
|
|
1700
1725
|
},
|
|
1701
|
-
children: /* @__PURE__ */
|
|
1726
|
+
children: /* @__PURE__ */ f("div", { className: "avatar-input-loader" })
|
|
1702
1727
|
}
|
|
1703
|
-
) : /* @__PURE__ */
|
|
1728
|
+
) : /* @__PURE__ */ _e(
|
|
1704
1729
|
"form",
|
|
1705
1730
|
{
|
|
1706
|
-
onSubmit:
|
|
1731
|
+
onSubmit: ln,
|
|
1707
1732
|
style: {
|
|
1708
1733
|
flex: 1,
|
|
1709
1734
|
display: "flex",
|
|
@@ -1711,20 +1736,20 @@ const Cn = ({
|
|
|
1711
1736
|
alignItems: "center"
|
|
1712
1737
|
},
|
|
1713
1738
|
children: [
|
|
1714
|
-
/* @__PURE__ */
|
|
1739
|
+
/* @__PURE__ */ f(
|
|
1715
1740
|
"input",
|
|
1716
1741
|
{
|
|
1717
1742
|
id: "avatar-text-input",
|
|
1718
1743
|
type: "text",
|
|
1719
|
-
value:
|
|
1720
|
-
onChange: (e) =>
|
|
1721
|
-
placeholder:
|
|
1722
|
-
disabled:
|
|
1744
|
+
value: me,
|
|
1745
|
+
onChange: (e) => T(e.target.value),
|
|
1746
|
+
placeholder: q === "Busy" ? "Assisting another user" : le || "Ask me anything",
|
|
1747
|
+
disabled: ie || q === "Busy",
|
|
1723
1748
|
autoComplete: "off",
|
|
1724
1749
|
style: { width: "100%", height: "100%" }
|
|
1725
1750
|
}
|
|
1726
1751
|
),
|
|
1727
|
-
|
|
1752
|
+
q === "Busy" ? /* @__PURE__ */ f(
|
|
1728
1753
|
"button",
|
|
1729
1754
|
{
|
|
1730
1755
|
type: "button",
|
|
@@ -1732,7 +1757,7 @@ const Cn = ({
|
|
|
1732
1757
|
disabled: !0,
|
|
1733
1758
|
style: { backgroundColor: "#1e4a5e" },
|
|
1734
1759
|
title: "Agent at capacity",
|
|
1735
|
-
children: /* @__PURE__ */
|
|
1760
|
+
children: /* @__PURE__ */ f(
|
|
1736
1761
|
"svg",
|
|
1737
1762
|
{
|
|
1738
1763
|
width: "24",
|
|
@@ -1741,7 +1766,7 @@ const Cn = ({
|
|
|
1741
1766
|
fill: "none",
|
|
1742
1767
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1743
1768
|
"aria-hidden": "true",
|
|
1744
|
-
children: /* @__PURE__ */
|
|
1769
|
+
children: /* @__PURE__ */ f(
|
|
1745
1770
|
"path",
|
|
1746
1771
|
{
|
|
1747
1772
|
d: "M4 2L20 2L12 10L4 2z M12 14L4 22L20 22L12 14z",
|
|
@@ -1751,15 +1776,15 @@ const Cn = ({
|
|
|
1751
1776
|
}
|
|
1752
1777
|
)
|
|
1753
1778
|
}
|
|
1754
|
-
) :
|
|
1779
|
+
) : me.trim() === "" ? /* @__PURE__ */ f(
|
|
1755
1780
|
"button",
|
|
1756
1781
|
{
|
|
1757
1782
|
type: "button",
|
|
1758
1783
|
className: "mic-button",
|
|
1759
|
-
onClick:
|
|
1760
|
-
disabled:
|
|
1784
|
+
onClick: on,
|
|
1785
|
+
disabled: ie,
|
|
1761
1786
|
style: { backgroundColor: "#1e4a5e" },
|
|
1762
|
-
children: /* @__PURE__ */
|
|
1787
|
+
children: /* @__PURE__ */ _e(
|
|
1763
1788
|
"svg",
|
|
1764
1789
|
{
|
|
1765
1790
|
width: "28",
|
|
@@ -1768,14 +1793,14 @@ const Cn = ({
|
|
|
1768
1793
|
fill: "none",
|
|
1769
1794
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1770
1795
|
children: [
|
|
1771
|
-
/* @__PURE__ */
|
|
1796
|
+
/* @__PURE__ */ f(
|
|
1772
1797
|
"path",
|
|
1773
1798
|
{
|
|
1774
1799
|
d: "M12 14C13.66 14 15 12.66 15 11V5C15 3.34 13.66 2 12 2C10.34 2 9 3.34 9 5V11C9 12.66 10.34 14 12 14Z",
|
|
1775
1800
|
fill: "white"
|
|
1776
1801
|
}
|
|
1777
1802
|
),
|
|
1778
|
-
/* @__PURE__ */
|
|
1803
|
+
/* @__PURE__ */ f(
|
|
1779
1804
|
"path",
|
|
1780
1805
|
{
|
|
1781
1806
|
d: "M17 11C17 13.76 14.76 16 12 16C9.24 16 7 13.76 7 11H5C5 14.53 7.61 17.43 11 17.93V21H13V17.93C16.39 17.43 19 14.53 19 11H17Z",
|
|
@@ -1786,15 +1811,15 @@ const Cn = ({
|
|
|
1786
1811
|
}
|
|
1787
1812
|
)
|
|
1788
1813
|
}
|
|
1789
|
-
) : /* @__PURE__ */
|
|
1814
|
+
) : /* @__PURE__ */ f(
|
|
1790
1815
|
"button",
|
|
1791
1816
|
{
|
|
1792
1817
|
type: "submit",
|
|
1793
1818
|
className: "mic-button",
|
|
1794
|
-
disabled:
|
|
1819
|
+
disabled: ie,
|
|
1795
1820
|
style: { backgroundColor: "#1e4a5e" },
|
|
1796
1821
|
title: "Send",
|
|
1797
|
-
children: /* @__PURE__ */
|
|
1822
|
+
children: /* @__PURE__ */ f(
|
|
1798
1823
|
"svg",
|
|
1799
1824
|
{
|
|
1800
1825
|
width: 24,
|
|
@@ -1802,7 +1827,7 @@ const Cn = ({
|
|
|
1802
1827
|
viewBox: "0 0 24 24",
|
|
1803
1828
|
fill: "none",
|
|
1804
1829
|
"aria-hidden": "true",
|
|
1805
|
-
children: /* @__PURE__ */
|
|
1830
|
+
children: /* @__PURE__ */ f(
|
|
1806
1831
|
"path",
|
|
1807
1832
|
{
|
|
1808
1833
|
d: "M19 12H5M19 12L14 17M19 12L14 7",
|
|
@@ -1822,22 +1847,22 @@ const Cn = ({
|
|
|
1822
1847
|
}
|
|
1823
1848
|
) })
|
|
1824
1849
|
] }),
|
|
1825
|
-
/* @__PURE__ */
|
|
1826
|
-
|
|
1850
|
+
/* @__PURE__ */ f("div", { className: "avatar-wrapper", children: /* @__PURE__ */ _e("div", { className: "avatar-scene-wrapper", children: [
|
|
1851
|
+
ne !== "hidden" && /* @__PURE__ */ f(
|
|
1827
1852
|
"div",
|
|
1828
1853
|
{
|
|
1829
|
-
className: `avatar-bubble${
|
|
1830
|
-
onAnimationEnd:
|
|
1831
|
-
children: /* @__PURE__ */
|
|
1854
|
+
className: `avatar-bubble${ne === "entering" ? " avatar-bubble--entering" : ne === "exiting" ? " avatar-bubble--exiting" : ""}`,
|
|
1855
|
+
onAnimationEnd: fn,
|
|
1856
|
+
children: /* @__PURE__ */ f("div", { ref: Ye, className: `avatar-bubble__content${Me ? " avatar-bubble__content--nudge" : ""}`, children: Ne })
|
|
1832
1857
|
}
|
|
1833
1858
|
),
|
|
1834
|
-
/* @__PURE__ */
|
|
1859
|
+
/* @__PURE__ */ f(
|
|
1835
1860
|
"div",
|
|
1836
1861
|
{
|
|
1837
1862
|
className: "avatar-canvas-layer",
|
|
1838
|
-
style: { width:
|
|
1839
|
-
children: /* @__PURE__ */
|
|
1840
|
-
|
|
1863
|
+
style: { width: A, height: A },
|
|
1864
|
+
children: /* @__PURE__ */ _e(
|
|
1865
|
+
bn,
|
|
1841
1866
|
{
|
|
1842
1867
|
shadows: !0,
|
|
1843
1868
|
camera: { position: [0.2, 1.4, 3], fov: 42 },
|
|
@@ -1845,30 +1870,30 @@ const Cn = ({
|
|
|
1845
1870
|
dpr: 1.8,
|
|
1846
1871
|
style: { pointerEvents: "none", width: "100%", height: "100%" },
|
|
1847
1872
|
children: [
|
|
1848
|
-
/* @__PURE__ */
|
|
1849
|
-
/* @__PURE__ */
|
|
1850
|
-
/* @__PURE__ */
|
|
1851
|
-
/* @__PURE__ */
|
|
1852
|
-
/* @__PURE__ */
|
|
1853
|
-
|
|
1873
|
+
/* @__PURE__ */ f($n, { target: mn }),
|
|
1874
|
+
/* @__PURE__ */ f("ambientLight", { intensity: 0.7 }),
|
|
1875
|
+
/* @__PURE__ */ f("directionalLight", { position: [0, 2, 2], intensity: 1 }),
|
|
1876
|
+
/* @__PURE__ */ f(pn, { preset: "city" }),
|
|
1877
|
+
/* @__PURE__ */ f(Sn, { fallback: null, children: We !== null && /* @__PURE__ */ f(
|
|
1878
|
+
Hn,
|
|
1854
1879
|
{
|
|
1855
|
-
avatarUrl:
|
|
1856
|
-
isPlayingRef:
|
|
1857
|
-
visemeQueueRef:
|
|
1858
|
-
audioContextRef:
|
|
1859
|
-
responseAudioStartTimeRef:
|
|
1860
|
-
adjustments:
|
|
1861
|
-
mood:
|
|
1862
|
-
expression:
|
|
1863
|
-
agentResponse:
|
|
1864
|
-
isSpeaking:
|
|
1865
|
-
nextStartTimeRef:
|
|
1866
|
-
stopPlayback:
|
|
1867
|
-
setIsSpeaking:
|
|
1868
|
-
expressionUrl:
|
|
1869
|
-
onExpressionFinished:
|
|
1870
|
-
isNudgeResponse:
|
|
1871
|
-
avatarGender:
|
|
1880
|
+
avatarUrl: We,
|
|
1881
|
+
isPlayingRef: K,
|
|
1882
|
+
visemeQueueRef: $e,
|
|
1883
|
+
audioContextRef: Q,
|
|
1884
|
+
responseAudioStartTimeRef: Le,
|
|
1885
|
+
adjustments: Dn,
|
|
1886
|
+
mood: ct,
|
|
1887
|
+
expression: Ge,
|
|
1888
|
+
agentResponse: xe,
|
|
1889
|
+
isSpeaking: ue,
|
|
1890
|
+
nextStartTimeRef: ve,
|
|
1891
|
+
stopPlayback: it,
|
|
1892
|
+
setIsSpeaking: I,
|
|
1893
|
+
expressionUrl: _t,
|
|
1894
|
+
onExpressionFinished: ot,
|
|
1895
|
+
isNudgeResponse: Me,
|
|
1896
|
+
avatarGender: y
|
|
1872
1897
|
}
|
|
1873
1898
|
) })
|
|
1874
1899
|
]
|
|
@@ -1878,22 +1903,22 @@ const Cn = ({
|
|
|
1878
1903
|
)
|
|
1879
1904
|
] }) })
|
|
1880
1905
|
] });
|
|
1881
|
-
},
|
|
1882
|
-
token:
|
|
1883
|
-
avatarGender:
|
|
1884
|
-
onNavigationRequested:
|
|
1885
|
-
presetUserDetails:
|
|
1886
|
-
onAvatarReady:
|
|
1887
|
-
}) => /* @__PURE__ */
|
|
1888
|
-
|
|
1906
|
+
}, Qn = ({
|
|
1907
|
+
token: m,
|
|
1908
|
+
avatarGender: C,
|
|
1909
|
+
onNavigationRequested: E,
|
|
1910
|
+
presetUserDetails: y,
|
|
1911
|
+
onAvatarReady: v
|
|
1912
|
+
}) => /* @__PURE__ */ f(
|
|
1913
|
+
Jn,
|
|
1889
1914
|
{
|
|
1890
|
-
token:
|
|
1891
|
-
onNavigationRequested:
|
|
1892
|
-
avatarGender:
|
|
1893
|
-
presetUserDetails:
|
|
1894
|
-
onAvatarReady:
|
|
1915
|
+
token: m,
|
|
1916
|
+
onNavigationRequested: E,
|
|
1917
|
+
avatarGender: C,
|
|
1918
|
+
presetUserDetails: y,
|
|
1919
|
+
onAvatarReady: v
|
|
1895
1920
|
}
|
|
1896
1921
|
);
|
|
1897
1922
|
export {
|
|
1898
|
-
|
|
1923
|
+
Qn as AvatarWidget
|
|
1899
1924
|
};
|