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