@streamoji/avatar-widget 0.5.2 → 0.5.5

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