@sage-rsc/talking-head-react 1.0.62 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { jsxs as Ee, jsx as ue } from "react/jsx-runtime";
2
- import { forwardRef as Ie, useRef as G, useState as de, useEffect as me, useCallback as T, useImperativeHandle as Le, useLayoutEffect as Ue } from "react";
2
+ import { forwardRef as Ie, useRef as G, useState as de, useEffect as me, useCallback as T, useImperativeHandle as Le, useLayoutEffect as We } from "react";
3
3
  import * as f from "three";
4
- import { OrbitControls as We } from "three/addons/controls/OrbitControls.js";
5
- import { GLTFLoader as Ve } from "three/addons/loaders/GLTFLoader.js";
6
- import { DRACOLoader as Ge } from "three/addons/loaders/DRACOLoader.js";
4
+ import { OrbitControls as Ve } from "three/addons/controls/OrbitControls.js";
5
+ import { GLTFLoader as Ge } from "three/addons/loaders/GLTFLoader.js";
6
+ import { DRACOLoader as Ze } from "three/addons/loaders/DRACOLoader.js";
7
7
  import { FBXLoader as ze } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as Ze } from "three/addons/environments/RoomEnvironment.js";
9
- import Xe from "three/addons/libs/stats.module.js";
10
- let m, J, ee;
11
- const L = [0, 0, 0, 0], k = new f.Vector3(), xe = new f.Vector3(), j = new f.Vector3(), be = new f.Vector3();
8
+ import { RoomEnvironment as Xe } from "three/addons/environments/RoomEnvironment.js";
9
+ import Ye from "three/addons/libs/stats.module.js";
10
+ let m, _, $;
11
+ const A = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(), Q = new f.Vector3(), ve = new f.Vector3();
12
12
  new f.Plane();
13
13
  new f.Ray();
14
14
  new f.Euler();
15
- const Q = new f.Quaternion(), Ce = new f.Quaternion(), ie = new f.Matrix4(), oe = new f.Matrix4();
15
+ const q = new f.Quaternion(), Ce = new f.Quaternion(), se = new f.Matrix4(), ae = new f.Matrix4();
16
16
  new f.Vector3();
17
- const ve = new f.Vector3(0, 0, 1), Ye = new f.Vector3(1, 0, 0), je = new f.Vector3(0, 1, 0), Qe = new f.Vector3(0, 0, 1);
18
- class qe {
17
+ const Re = new f.Vector3(0, 0, 1), je = new f.Vector3(1, 0, 0), Qe = new f.Vector3(0, 1, 0), qe = new f.Vector3(0, 0, 1);
18
+ class _e {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
21
21
  warmupMs: 2e3,
@@ -338,7 +338,7 @@ class qe {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- h.boneParent.matrixWorld.decompose(k, Q, j), k.copy(ve).applyQuaternion(Q).setY(0).normalize(), Q.premultiply(Ce.setFromUnitVectors(ve, k).invert()).normalize(), h.qWorldInverseYaw = Q.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ h.boneParent.matrixWorld.decompose(k, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), h.qWorldInverseYaw = q.clone().normalize(), this.data.push(h), this.dict[u] = h;
342
342
  try {
343
343
  this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
344
344
  } catch (r) {
@@ -356,22 +356,22 @@ class qe {
356
356
  for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, i = this.objectsUpdate.length; e < i; e++)
357
357
  o = this.objectsUpdate[e], o.updateMatrix(), o.parent === null ? o.matrixWorld.copy(o.matrix) : o.matrixWorld.multiplyMatrices(o.parent.matrixWorld, o.matrix), o.matrixWorldNeedsUpdate = !1;
358
358
  for (e = 0, i = this.data.length; e < i; e++) {
359
- if (o = this.data[e], k.copy(o.vWorld), ie.copy(o.boneParent.matrixWorld), oe.copy(ie).invert(), o.vWorld.setFromMatrixPosition(ie), k.applyMatrix4(oe), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), L[0] = k.x, L[1] = k.y, L[2] = -k.z, L[3] = k.length() / 3, o.children)
359
+ if (o = this.data[e], k.copy(o.vWorld), se.copy(o.boneParent.matrixWorld), ae.copy(se).invert(), o.vWorld.setFromMatrixPosition(se), k.applyMatrix4(ae), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
360
360
  for (n = 0, s = o.children.length; n < s; n++)
361
- m = o.children[n], L[0] -= m.v[0] * t / 3, L[1] -= m.v[1] * t / 3, L[2] += m.v[2] * t / 3, L[3] -= m.v[3] * t / 3;
362
- if (m = this.opt.sensitivityFactor, L[0] *= o.ext * m, L[1] *= o.ext * m, L[2] *= o.ext * m, L[3] *= o.ext * m, o.isX && (m = L[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + L[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = L[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + L[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = L[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + L[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = L[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + L[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), L[0] = o.p[0], L[1] = o.p[1], L[2] = o.p[2], L[3] = o.p[3], m = this.opt.movementFactor, L[0] *= m, L[1] *= m, L[2] *= m, L[3] *= m, o.dl && (m = o.dl, L[0] += m[0], L[1] += m[1], L[2] += m[2]), o.dw && (m = o.dw, k.set(
363
- o.vBasis.x + L[0],
364
- o.vBasis.y + L[1],
365
- o.vBasis.z + L[2]
366
- ), k.applyMatrix4(ie), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(oe), L[0] += k.x - o.vBasis.x, L[1] += k.y - o.vBasis.y, L[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && L[0] < m[0][0] && (L[0] = m[0][0]), m[0][1] !== null && L[0] > m[0][1] && (L[0] = m[0][1])), m[1] && (m[1][0] !== null && L[1] < m[1][0] && (L[1] = m[1][0]), m[1][1] !== null && L[1] > m[1][1] && (L[1] = m[1][1])), m[2] && (m[2][0] !== null && L[2] < m[2][0] && (L[2] = m[2][0]), m[2][1] !== null && L[2] > m[2][1] && (L[2] = m[2][1])), m[3] && (m[3][0] !== null && L[3] < m[3][0] && (L[3] = m[3][0]), m[3][1] !== null && L[3] > m[3][1] && (L[3] = m[3][1]))), o.isPoint)
361
+ m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
362
+ if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, k.set(
363
+ o.vBasis.x + A[0],
364
+ o.vBasis.y + A[1],
365
+ o.vBasis.z + A[2]
366
+ ), k.applyMatrix4(se), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(ae), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
367
367
  o.bone.position.set(
368
- o.vBasis.x + L[0],
369
- o.vBasis.y + L[1],
370
- o.vBasis.z - L[2]
368
+ o.vBasis.x + A[0],
369
+ o.vBasis.y + A[1],
370
+ o.vBasis.z - A[2]
371
371
  );
372
- else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, Q, j), k.copy(ve).applyQuaternion(Q).setY(0).normalize(), Q.premultiply(Ce.setFromUnitVectors(ve, k).invert()).normalize(), o.boneParent.quaternion.multiply(Q.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(L[0] / o.l), Q.setFromAxisAngle(Qe, -m), o.boneParent.quaternion.multiply(Q)), o.isY && (m = o.l / 3, m = m * Math.tanh(L[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(L[2] / o.l), Q.setFromAxisAngle(Ye, -m), o.boneParent.quaternion.multiply(Q)), o.isT && (m = 1.5 * Math.tanh(L[3] * 1.5), Q.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(Q)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
372
+ else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), o.boneParent.quaternion.multiply(q.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), q.setFromAxisAngle(qe, -m), o.boneParent.quaternion.multiply(q)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), q.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(q)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), q.setFromAxisAngle(Qe, -m), o.boneParent.quaternion.multiply(q)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (n = 0, s = o.excludes.length; n < s; n++)
374
- m = o.excludes[n], j.set(0, 0, 0), m.deltaLocal && (j.x += m.deltaLocal[0], j.y += m.deltaLocal[1], j.z += m.deltaLocal[2]), j.applyMatrix4(m.bone.matrixWorld), oe.copy(o.boneParent.matrixWorld).invert(), j.applyMatrix4(oe), k.copy(o.bone.position), !(k.distanceToSquared(j) >= m.radiusSq) && (ee = k.length(), J = j.length(), !(J > m.radius + ee) && (J < Math.abs(m.radius - ee) || (J = (J * J + ee * ee - m.radiusSq) / (2 * J), j.normalize(), be.copy(j).multiplyScalar(J), J = Math.sqrt(ee * ee - J * J), k.subVectors(k, be).projectOnPlane(j).normalize().multiplyScalar(J), xe.subVectors(o.vBasis, be).projectOnPlane(j).normalize(), ee = xe.dot(k), ee < 0 && (ee = Math.sqrt(J * J - ee * ee), xe.multiplyScalar(ee), k.add(xe)), k.add(be).normalize(), j.copy(o.bone.position).normalize(), Q.setFromUnitVectors(j, k), o.boneParent.quaternion.premultiply(Q), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[n], Q.set(0, 0, 0), m.deltaLocal && (Q.x += m.deltaLocal[0], Q.y += m.deltaLocal[1], Q.z += m.deltaLocal[2]), Q.applyMatrix4(m.bone.matrixWorld), ae.copy(o.boneParent.matrixWorld).invert(), Q.applyMatrix4(ae), k.copy(o.bone.position), !(k.distanceToSquared(Q) >= m.radiusSq) && ($ = k.length(), _ = Q.length(), !(_ > m.radius + $) && (_ < Math.abs(m.radius - $) || (_ = (_ * _ + $ * $ - m.radiusSq) / (2 * _), Q.normalize(), ve.copy(Q).multiplyScalar(_), _ = Math.sqrt($ * $ - _ * _), k.subVectors(k, ve).projectOnPlane(Q).normalize().multiplyScalar(_), be.subVectors(o.vBasis, ve).projectOnPlane(Q).normalize(), $ = be.dot(k), $ < 0 && ($ = Math.sqrt(_ * _ - $ * $), be.multiplyScalar($), k.add(be)), k.add(ve).normalize(), Q.copy(o.bone.position).normalize(), q.setFromUnitVectors(Q, k), o.boneParent.quaternion.premultiply(q), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -442,17 +442,17 @@ class qe {
442
442
  */
443
443
  updateHelpers() {
444
444
  if (m = this.helpers.points, m.bones.length) {
445
- oe.copy(this.armature.matrixWorld).invert();
445
+ ae.copy(this.armature.matrixWorld).invert();
446
446
  const t = m.object.geometry.getAttribute("position");
447
447
  for (let e = 0, n = m.bones.length; e < n; e++)
448
- ie.multiplyMatrices(oe, m.bones[e].matrixWorld), k.setFromMatrixPosition(ie), t.setXYZ(e, k.x, k.y, k.z);
448
+ se.multiplyMatrices(ae, m.bones[e].matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(e, k.x, k.y, k.z);
449
449
  t.needsUpdate = !0, m.object.updateMatrixWorld();
450
450
  }
451
451
  if (m = this.helpers.lines, m.bones.length) {
452
- oe.copy(this.armature.matrixWorld).invert();
452
+ ae.copy(this.armature.matrixWorld).invert();
453
453
  const t = m.object.geometry.getAttribute("position");
454
454
  for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
455
- ie.multiplyMatrices(oe, m.bones[e].matrixWorld), k.setFromMatrixPosition(ie), t.setXYZ(n, k.x, k.y, k.z), ie.multiplyMatrices(oe, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(ie), t.setXYZ(n + 1, k.x, k.y, k.z);
455
+ se.multiplyMatrices(ae, m.bones[e].matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(n, k.x, k.y, k.z), se.multiplyMatrices(ae, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(n + 1, k.x, k.y, k.z);
456
456
  t.needsUpdate = !0, m.object.updateMatrixWorld();
457
457
  }
458
458
  }
@@ -489,7 +489,7 @@ class qe {
489
489
  this.stop(), this.scene = null, this.armature = null, this.config = [], this.data = [], this.dict = {}, this.objectsUpdate = [], this.timerMs = 0;
490
490
  }
491
491
  }
492
- class _e {
492
+ class Ke {
493
493
  constructor(t) {
494
494
  this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
495
495
  }
@@ -814,7 +814,7 @@ class _e {
814
814
  return i * s;
815
815
  }
816
816
  }
817
- class Ke {
817
+ class Je {
818
818
  /**
819
819
  * @constructor
820
820
  */
@@ -1396,11 +1396,11 @@ class Ke {
1396
1396
  return e;
1397
1397
  }
1398
1398
  }
1399
- const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1399
+ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1400
1400
  __proto__: null,
1401
- LipsyncEn: Ke
1401
+ LipsyncEn: Je
1402
1402
  }, Symbol.toStringTag, { value: "Module" }));
1403
- class $e {
1403
+ class et {
1404
1404
  /**
1405
1405
  * @constructor
1406
1406
  */
@@ -1754,11 +1754,11 @@ class $e {
1754
1754
  return e;
1755
1755
  }
1756
1756
  }
1757
- const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1757
+ const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1758
1758
  __proto__: null,
1759
- LipsyncDe: $e
1759
+ LipsyncDe: et
1760
1760
  }, Symbol.toStringTag, { value: "Module" }));
1761
- class tt {
1761
+ class nt {
1762
1762
  /**
1763
1763
  * @constructor
1764
1764
  */
@@ -2289,11 +2289,11 @@ class tt {
2289
2289
  return e;
2290
2290
  }
2291
2291
  }
2292
- const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2293
2293
  __proto__: null,
2294
- LipsyncFr: tt
2294
+ LipsyncFr: nt
2295
2295
  }, Symbol.toStringTag, { value: "Module" }));
2296
- class it {
2296
+ class ot {
2297
2297
  /**
2298
2298
  * @constructor
2299
2299
  */
@@ -2436,11 +2436,11 @@ class it {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
- LipsyncFi: it
2441
+ LipsyncFi: ot
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class st {
2443
+ class at {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2620,21 +2620,21 @@ class st {
2620
2620
  return e;
2621
2621
  }
2622
2622
  }
2623
- const at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
+ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: st
2626
- }, Symbol.toStringTag, { value: "Module" })), rt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2ls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NoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG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uZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), He = {
2627
- en: Je,
2628
- de: et,
2629
- fr: nt,
2630
- fi: ot,
2631
- lt: at
2632
- }, U = new f.Quaternion(), E = new f.Euler(), ae = new f.Vector3(), he = new f.Vector3(), Te = new f.Box3();
2625
+ LipsyncLt: at
2626
+ }, Symbol.toStringTag, { value: "Module" })), lt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9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ogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgIC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7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), He = {
2627
+ en: $e,
2628
+ de: tt,
2629
+ fr: it,
2630
+ fi: st,
2631
+ lt: rt
2632
+ }, W = new f.Quaternion(), F = new f.Euler(), le = new f.Vector3(), he = new f.Vector3(), Te = new f.Box3();
2633
2633
  new f.Matrix4();
2634
2634
  new f.Matrix4();
2635
2635
  new f.Vector3();
2636
2636
  new f.Vector3(0, 0, 1);
2637
- const lt = new f.Vector3(1, 0, 0);
2637
+ const ht = new f.Vector3(1, 0, 0);
2638
2638
  new f.Vector3(0, 1, 0);
2639
2639
  new f.Vector3(0, 0, 1);
2640
2640
  class Fe {
@@ -2763,7 +2763,7 @@ class Fe {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Xe(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
2766
+ }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Ye(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
2767
2767
  side: {
2768
2768
  standing: !0,
2769
2769
  props: {
@@ -4062,7 +4062,7 @@ class Fe {
4062
4062
  this.opt.lightSpotDispersion
4063
4063
  ), this.setLighting(this.opt);
4064
4064
  const l = new f.PMREMGenerator(this.renderer);
4065
- l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Ze()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new We(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4065
+ l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Xe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ve(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4066
4066
  }
4067
4067
  this.ikMesh = new f.SkinnedMesh();
4068
4068
  const s = {
@@ -4080,14 +4080,14 @@ class Fe {
4080
4080
  Object.entries(s).forEach((l, u) => {
4081
4081
  const a = new f.Bone();
4082
4082
  a.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(a) : this.ikMesh.add(a), o.push(a);
4083
- }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new qe(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4083
+ }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new _e(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4084
4084
  }
4085
4085
  /**
4086
4086
  * Helper that re/creates the audio context and the other nodes.
4087
4087
  * @param {number} sampleRate
4088
4088
  */
4089
4089
  initAudioGraph(t = null) {
4090
- if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new _e(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4090
+ if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new Ke(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4091
4091
  this.opt.mixerGainSpeech,
4092
4092
  this.opt.mixerGainBackground
4093
4093
  ), this.workletLoaded = !1, this.streamWorkletNode) {
@@ -4228,9 +4228,9 @@ class Fe {
4228
4228
  async showAvatar(t, e = null) {
4229
4229
  if (!t || !t.hasOwnProperty("url"))
4230
4230
  throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
4231
- const n = new Ve();
4231
+ const n = new Ge();
4232
4232
  if (this.dracoEnabled) {
4233
- const a = new Ge();
4233
+ const a = new Ze();
4234
4234
  a.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(a);
4235
4235
  }
4236
4236
  let i = await n.loadAsync(t.url, e);
@@ -4374,9 +4374,9 @@ class Fe {
4374
4374
  updatePoseDelta() {
4375
4375
  for (const [t, e] of Object.entries(this.poseDelta.props)) {
4376
4376
  if (e.x === 0 && e.y === 0 && e.z === 0) continue;
4377
- E.set(e.x, e.y, e.z);
4377
+ F.set(e.x, e.y, e.z);
4378
4378
  const n = this.poseAvatar.props[t];
4379
- n.isQuaternion ? (U.setFromEuler(E), n.multiply(U)) : n.isVector3 && n.add(E);
4379
+ n.isQuaternion ? (W.setFromEuler(F), n.multiply(W)) : n.isVector3 && n.add(F);
4380
4380
  }
4381
4381
  }
4382
4382
  /**
@@ -5159,7 +5159,7 @@ class Fe {
5159
5159
  }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5160
5160
  break;
5161
5161
  }
5162
- if ((u || a) && (E.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), E.x = Math.max(-0.9, Math.min(0.9, 2 * E.x - 0.5)), E.y = Math.max(-0.9, Math.min(0.9, -2.5 * E.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: E.x < 0 ? -E.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: E.x < 0 ? 0 : E.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), a && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5162
+ if ((u || a) && (F.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), F.x = Math.max(-0.9, Math.min(0.9, 2 * F.x - 0.5)), F.y = Math.max(-0.9, Math.min(0.9, -2.5 * F.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: F.x < 0 ? -F.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: F.x < 0 ? 0 : F.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), a && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5163
5163
  name: "headmove",
5164
5164
  dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
5165
5165
  vs: {
@@ -5180,7 +5180,7 @@ class Fe {
5180
5180
  eyeLookOutRight: [null, 0],
5181
5181
  eyeContact: [0]
5182
5182
  }
5183
- })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (U.setFromAxisAngle(lt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(U)), Te.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ae), ae.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(he), he.sub(this.armature.position), this.objectHips.position.y -= Te.min.y / 2, this.objectHips.position.x -= (ae.x + he.x) / 4, this.objectHips.position.z -= (ae.z + he.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5183
+ })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (W.setFromAxisAngle(ht, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(W)), Te.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(le), le.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(he), he.sub(this.armature.position), this.objectHips.position.y -= Te.min.y / 2, this.objectHips.position.x -= (le.x + he.x) / 4, this.objectHips.position.z -= (le.z + he.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5184
5184
  this.stats && this.stats.end();
5185
5185
  else {
5186
5186
  if (this.cameraClock !== null && this.cameraClock < 1e3) {
@@ -5251,10 +5251,10 @@ class Fe {
5251
5251
  let h = "", r = "", c = 0, d = [], g = [];
5252
5252
  const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
5253
5253
  for (let x = 0; x < y.length; x++) {
5254
- const I = x === y.length - 1, F = y[x].match(l);
5254
+ const I = x === y.length - 1, D = y[x].match(l);
5255
5255
  let p = y[x].match(s);
5256
5256
  const H = y[x].match(u), z = y[x].match(o);
5257
- if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), F && (!i || i.every((v) => x < v[0] || x > v[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
5257
+ if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), D && (!i || i.every((R) => x < R[0] || x > R[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
5258
5258
  mark: c,
5259
5259
  word: r
5260
5260
  })), h.length && (g.push({
@@ -5265,16 +5265,16 @@ class Fe {
5265
5265
  subtitles: [h]
5266
5266
  }
5267
5267
  }), h = ""), r.length)) {
5268
- const v = this.lipsyncWordsToVisemes(r, a);
5269
- if (v && v.visemes && v.visemes.length) {
5270
- const M = v.times[v.visemes.length - 1] + v.durations[v.visemes.length - 1];
5271
- for (let W = 0; W < v.visemes.length; W++)
5268
+ const R = this.lipsyncWordsToVisemes(r, a);
5269
+ if (R && R.visemes && R.visemes.length) {
5270
+ const M = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
5271
+ for (let P = 0; P < R.visemes.length; P++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(v.times[W] - 0.6) / M, (v.times[W] + 0.5) / M, (v.times[W] + v.durations[W] + 0.5) / M],
5275
+ ts: [(R.times[P] - 0.6) / M, (R.times[P] + 0.5) / M, (R.times[P] + R.durations[P] + 0.5) / M],
5276
5276
  vs: {
5277
- ["viseme_" + v.visemes[W]]: [null, v.visemes[W] === "PP" || v.visemes[W] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + R.visemes[P]]: [null, R.visemes[P] === "PP" || R.visemes[P] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
@@ -5282,14 +5282,14 @@ class Fe {
5282
5282
  }
5283
5283
  if (p || I) {
5284
5284
  if (d.length || I && g.length) {
5285
- const v = {
5285
+ const R = {
5286
5286
  anim: g
5287
5287
  };
5288
- n && (v.onSubtitles = n), d.length && !e.avatarMute && (v.text = d, e.avatarMood && (v.mood = e.avatarMood), e.ttsLang && (v.lang = e.ttsLang), e.ttsVoice && (v.voice = e.ttsVoice), e.ttsRate && (v.rate = e.ttsRate), e.ttsVoice && (v.pitch = e.ttsPitch), e.ttsVolume && (v.volume = e.ttsVolume)), this.speechQueue.push(v), d = [], r = "", c = 0, g = [];
5288
+ n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], r = "", c = 0, g = [];
5289
5289
  }
5290
5290
  if (H) {
5291
- let v = this.animEmojis[y[x]];
5292
- v && v.link && (v = this.animEmojis[v.link]), v && this.speechQueue.push({ emoji: v });
5291
+ let R = this.animEmojis[y[x]];
5292
+ R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
5293
5293
  }
5294
5294
  this.speechQueue.push({ break: 100 });
5295
5295
  }
@@ -5385,10 +5385,10 @@ class Fe {
5385
5385
  let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5386
5386
  if (h = Math.min(h, c.visemes.length * 200), d > 0)
5387
5387
  for (let x = 0; x < c.visemes.length; x++) {
5388
- const I = a + c.times[x] / d * h, F = c.durations[x] / d * h;
5388
+ const I = a + c.times[x] / d * h, D = c.durations[x] / d * h;
5389
5389
  o.push({
5390
5390
  template: { name: "viseme" },
5391
- ts: [I - Math.min(60, 2 * F / 3), I + Math.min(25, F / 2), I + F + Math.min(60, F / 2)],
5391
+ ts: [I - Math.min(60, 2 * D / 3), I + Math.min(25, D / 2), I + D + Math.min(60, D / 2)],
5392
5392
  vs: {
5393
5393
  ["viseme_" + c.visemes[x]]: [null, c.visemes[x] === "PP" || c.visemes[x] === "FF" ? 0.9 : y, 0]
5394
5394
  }
@@ -5486,18 +5486,18 @@ class Fe {
5486
5486
  if (x && x.visemes && x.visemes.length > 0) {
5487
5487
  const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
5488
5488
  for (let H = 0; H < x.visemes.length; H++) {
5489
- const z = x.visemes[H], v = x.times[H] / p, M = x.durations[H] / p, W = v * c, _ = M * c;
5489
+ const z = x.visemes[H], R = x.times[H] / p, M = x.durations[H] / p, P = R * c, ee = M * c;
5490
5490
  I.push({
5491
5491
  template: { name: "viseme" },
5492
- ts: [W - Math.min(60, 2 * _ / 3), W + Math.min(25, _ / 2), W + _ + Math.min(60, _ / 2)],
5492
+ ts: [P - Math.min(60, 2 * ee / 3), P + Math.min(25, ee / 2), P + ee + Math.min(60, ee / 2)],
5493
5493
  vs: {
5494
5494
  ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5495
5495
  }
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const F = [...t.anim, ...I];
5500
- this.audioPlaylist.push({ anim: F, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5499
+ const D = [...t.anim, ...I];
5500
+ this.audioPlaylist.push({ anim: D, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5501
5501
  e();
5502
5502
  }, s.onerror = (p) => {
5503
5503
  console.error("Speech synthesis error:", p.error), n(p.error);
@@ -5895,7 +5895,7 @@ class Fe {
5895
5895
  }
5896
5896
  if (!this.workletLoaded)
5897
5897
  try {
5898
- const l = this.audioCtx.audioWorklet.addModule(rt.href), u = new Promise(
5898
+ const l = this.audioCtx.audioWorklet.addModule(lt.href), u = new Promise(
5899
5899
  (a, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5900
5900
  );
5901
5901
  await Promise.race([l, u]), this.workletLoaded = !0;
@@ -6133,7 +6133,7 @@ class Fe {
6133
6133
  */
6134
6134
  lookAtCamera(t) {
6135
6135
  let e;
6136
- if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ae.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ae, he).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6136
+ if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), le.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(le, he).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6137
6137
  if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
6138
6138
  if (this.avatar.avatarIgnoreCamera) {
6139
6139
  this.lookAhead(t);
@@ -6146,12 +6146,12 @@ class Fe {
6146
6146
  this.lookAt(null, null, t);
6147
6147
  return;
6148
6148
  }
6149
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ae.setFromMatrixPosition(this.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.objectRightEye.matrixWorld), ae.add(he).divideScalar(2), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]);
6150
- const n = new f.Vector3().subVectors(e, ae).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
- E.set(s, i, 0, "YXZ");
6152
- const l = new f.Quaternion().setFromEuler(E), u = new f.Quaternion().copy(l).multiply(U.clone().invert());
6153
- E.setFromQuaternion(u, "YXZ");
6154
- let a = E.x / (40 / 24) + 0.2, h = E.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, a)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6149
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), le.setFromMatrixPosition(this.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.objectRightEye.matrixWorld), le.add(he).divideScalar(2), W.copy(this.armature.quaternion), W.multiply(this.poseTarget.props["Hips.quaternion"]), W.multiply(this.poseTarget.props["Spine.quaternion"]), W.multiply(this.poseTarget.props["Spine1.quaternion"]), W.multiply(this.poseTarget.props["Spine2.quaternion"]), W.multiply(this.poseTarget.props["Neck.quaternion"]), W.multiply(this.poseTarget.props["Head.quaternion"]);
6150
+ const n = new f.Vector3().subVectors(e, le).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
+ F.set(s, i, 0, "YXZ");
6152
+ const l = new f.Quaternion().setFromEuler(F), u = new f.Quaternion().copy(l).multiply(W.clone().invert());
6153
+ F.setFromQuaternion(u, "YXZ");
6154
+ let a = F.x / (40 / 24) + 0.2, h = F.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, a)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6155
6155
  if (t) {
6156
6156
  let y = this.animQueue.findIndex((I) => I.template.name === "lookat");
6157
6157
  y !== -1 && this.animQueue.splice(y, 1);
@@ -6186,20 +6186,20 @@ class Fe {
6186
6186
  const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new f.Vector3().addVectors(s, o).divideScalar(2);
6187
6187
  l.project(this.camera);
6188
6188
  let u = (l.x + 1) / 2 * i.width + i.left, a = -(l.y - 1) / 2 * i.height + i.top;
6189
- t === null && (t = u), e === null && (e = a), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(U);
6190
- let h = E.x / (40 / 24), r = E.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
6189
+ t === null && (t = u), e === null && (e = a), W.copy(this.armature.quaternion), W.multiply(this.poseTarget.props["Hips.quaternion"]), W.multiply(this.poseTarget.props["Spine.quaternion"]), W.multiply(this.poseTarget.props["Spine1.quaternion"]), W.multiply(this.poseTarget.props["Spine2.quaternion"]), W.multiply(this.poseTarget.props["Neck.quaternion"]), W.multiply(this.poseTarget.props["Head.quaternion"]), F.setFromQuaternion(W);
6190
+ let h = F.x / (40 / 24), r = F.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
6191
6191
  x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
6192
- let F = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6192
+ let D = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (n) {
6194
- let H = this.animQueue.findIndex((v) => v.template.name === "lookat");
6194
+ let H = this.animQueue.findIndex((R) => R.template.name === "lookat");
6195
6195
  H !== -1 && this.animQueue.splice(H, 1);
6196
6196
  const z = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, n],
6199
6199
  vs: {
6200
- bodyRotateX: [x + F],
6200
+ bodyRotateX: [x + D],
6201
6201
  bodyRotateY: [I + p],
6202
- eyesRotateX: [-3 * F + 0.1],
6202
+ eyesRotateX: [-3 * D + 0.1],
6203
6203
  eyesRotateY: [-5 * p],
6204
6204
  browInnerUp: [[0, 0.7]],
6205
6205
  mouthLeft: [[0, 0.7]],
@@ -6577,12 +6577,12 @@ class Fe {
6577
6577
  const x = t.iterations || 10;
6578
6578
  if (e)
6579
6579
  for (let I = 0; I < x; I++) {
6580
- let F = !1;
6580
+ let D = !1;
6581
6581
  for (let p = 0, H = y.length; p < H; p++) {
6582
6582
  const z = y[p].bone;
6583
6583
  z.matrixWorld.decompose(u, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(a), l.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
6584
- let v = s.dot(l);
6585
- v > 1 ? v = 1 : v < -1 && (v = -1), v = Math.acos(v), !(v < 1e-5) && (y[p].minAngle !== void 0 && v < y[p].minAngle && (v = y[p].minAngle), y[p].maxAngle !== void 0 && v > y[p].maxAngle && (v = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), U.setFromAxisAngle(r, v), z.quaternion.multiply(U), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6584
+ let R = s.dot(l);
6585
+ R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), W.setFromAxisAngle(r, R), z.quaternion.multiply(W), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6586
6586
  y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6587
6587
  y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6588
6588
  y[p].minz !== void 0 ? y[p].minz : -1 / 0
@@ -6590,9 +6590,9 @@ class Fe {
6590
6590
  y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6591
6591
  y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6592
6592
  y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6593
- ))), z.updateMatrixWorld(!0), F = !0);
6593
+ ))), z.updateMatrixWorld(!0), D = !0);
6594
6594
  }
6595
- if (!F) break;
6595
+ if (!D) break;
6596
6596
  }
6597
6597
  i && y.forEach((I) => {
6598
6598
  this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = i;
@@ -6605,7 +6605,7 @@ class Fe {
6605
6605
  this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
6606
6606
  }
6607
6607
  }
6608
- const ge = {
6608
+ const ye = {
6609
6609
  apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
6610
6610
  // Replace with your actual API key (should start with sk_)
6611
6611
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
@@ -6648,23 +6648,23 @@ const ge = {
6648
6648
  function Ae() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
- endpoint: ge.endpoint,
6652
- apiKey: ge.apiKey,
6653
- defaultVoice: ge.defaultVoice,
6654
- voices: ge.voices
6651
+ endpoint: ye.endpoint,
6652
+ apiKey: ye.apiKey,
6653
+ defaultVoice: ye.defaultVoice,
6654
+ voices: ye.voices
6655
6655
  };
6656
6656
  }
6657
- function vt() {
6658
- const N = Ae(), t = [];
6659
- return Object.entries(N.voices).forEach(([e, n]) => {
6657
+ function Rt() {
6658
+ const O = Ae(), t = [];
6659
+ return Object.entries(O.voices).forEach(([e, n]) => {
6660
6660
  t.push({
6661
6661
  value: n,
6662
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${N.service})`
6662
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${O.service})`
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
6666
  const Pe = Ie(({
6667
- avatarUrl: N = "/avatars/brunette.glb",
6667
+ avatarUrl: O = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
6670
6670
  ttsLang: n = "en",
@@ -6685,124 +6685,124 @@ const Pe = Ie(({
6685
6685
  style: y = {},
6686
6686
  animations: x = {}
6687
6687
  }, I) => {
6688
- const F = G(null), p = G(null), H = G(a), z = G(null), v = G(null), M = G(!1), [W, _] = de(!0), [re, S] = de(null), [D, Y] = de(!1), [O, q] = de(!1);
6688
+ const D = G(null), p = G(null), H = G(a), z = G(null), R = G(null), M = G(!1), P = G({ remainingText: null, originalText: null, options: null }), [ee, re] = de(!0), [S, N] = de(null), [Z, X] = de(!1), [j, K] = de(!1);
6689
6689
  me(() => {
6690
- M.current = O;
6691
- }, [O]), me(() => {
6690
+ M.current = j;
6691
+ }, [j]), me(() => {
6692
6692
  H.current = a;
6693
6693
  }, [a]);
6694
- const Z = Ae(), le = i || Z.service;
6695
- let se;
6696
- le === "browser" ? se = {
6694
+ const te = Ae(), ce = i || te.service;
6695
+ let oe;
6696
+ ce === "browser" ? oe = {
6697
6697
  service: "browser",
6698
6698
  endpoint: "",
6699
6699
  apiKey: null,
6700
6700
  defaultVoice: "Google US English"
6701
- } : le === "elevenlabs" ? se = {
6701
+ } : ce === "elevenlabs" ? oe = {
6702
6702
  service: "elevenlabs",
6703
6703
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6704
- apiKey: o || Z.apiKey,
6705
- defaultVoice: s || Z.defaultVoice || ge.defaultVoice,
6706
- voices: Z.voices || ge.voices
6707
- } : le === "deepgram" ? se = {
6704
+ apiKey: o || te.apiKey,
6705
+ defaultVoice: s || te.defaultVoice || ye.defaultVoice,
6706
+ voices: te.voices || ye.voices
6707
+ } : ce === "deepgram" ? oe = {
6708
6708
  service: "deepgram",
6709
6709
  endpoint: "https://api.deepgram.com/v1/speak",
6710
- apiKey: o || Z.apiKey,
6711
- defaultVoice: s || Z.defaultVoice || Me.defaultVoice,
6712
- voices: Z.voices || Me.voices
6713
- } : se = {
6714
- ...Z,
6710
+ apiKey: o || te.apiKey,
6711
+ defaultVoice: s || te.defaultVoice || Me.defaultVoice,
6712
+ voices: te.voices || Me.voices
6713
+ } : oe = {
6714
+ ...te,
6715
6715
  // Override API key if provided via props
6716
- apiKey: o !== null ? o : Z.apiKey
6716
+ apiKey: o !== null ? o : te.apiKey
6717
6717
  };
6718
- const ce = {
6719
- url: N,
6718
+ const pe = {
6719
+ url: O,
6720
6720
  body: t,
6721
6721
  avatarMood: e,
6722
- ttsLang: le === "browser" ? "en-US" : n,
6723
- ttsVoice: s || se.defaultVoice,
6722
+ ttsLang: ce === "browser" ? "en-US" : n,
6723
+ ttsVoice: s || oe.defaultVoice,
6724
6724
  lipsyncLang: "en",
6725
6725
  showFullAvatar: a,
6726
6726
  bodyMovement: l,
6727
6727
  movementIntensity: u
6728
- }, Re = {
6729
- ttsEndpoint: se.endpoint,
6730
- ttsApikey: se.apiKey,
6731
- ttsService: le,
6728
+ }, J = {
6729
+ ttsEndpoint: oe.endpoint,
6730
+ ttsApikey: oe.apiKey,
6731
+ ttsService: ce,
6732
6732
  lipsyncModules: ["en"],
6733
6733
  cameraView: h
6734
- }, K = T(async () => {
6735
- if (!(!F.current || p.current))
6734
+ }, b = T(async () => {
6735
+ if (!(!D.current || p.current))
6736
6736
  try {
6737
- if (_(!0), S(null), p.current = new Fe(F.current, Re), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(ce, (X) => {
6738
- if (X.lengthComputable) {
6739
- const P = Math.min(100, Math.round(X.loaded / X.total * 100));
6740
- c(P);
6737
+ if (re(!0), N(null), p.current = new Fe(D.current, J), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(pe, (U) => {
6738
+ if (U.lengthComputable) {
6739
+ const E = Math.min(100, Math.round(U.loaded / U.total * 100));
6740
+ c(E);
6741
6741
  }
6742
- }), await new Promise((X) => {
6743
- const P = () => {
6744
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? X() : setTimeout(P, 100);
6742
+ }), await new Promise((U) => {
6743
+ const E = () => {
6744
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? U() : setTimeout(E, 100);
6745
6745
  };
6746
- P();
6746
+ E();
6747
6747
  }), p.current && p.current.setShowFullAvatar)
6748
6748
  try {
6749
6749
  p.current.setShowFullAvatar(a);
6750
- } catch (X) {
6751
- console.warn("Error setting full body mode on initialization:", X);
6750
+ } catch (U) {
6751
+ console.warn("Error setting full body mode on initialization:", U);
6752
6752
  }
6753
- p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), _(!1), Y(!0), r(p.current);
6753
+ p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), re(!1), X(!0), r(p.current);
6754
6754
  const B = () => {
6755
6755
  document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6756
6756
  };
6757
6757
  return document.addEventListener("visibilitychange", B), () => {
6758
6758
  document.removeEventListener("visibilitychange", B);
6759
6759
  };
6760
- } catch (A) {
6761
- console.error("Error initializing TalkingHead:", A), S(A.message || "Failed to initialize avatar"), _(!1), d(A);
6760
+ } catch (L) {
6761
+ console.error("Error initializing TalkingHead:", L), N(L.message || "Failed to initialize avatar"), re(!1), d(L);
6762
6762
  }
6763
- }, [N, t, e, n, i, s, o, a, l, u, h]);
6764
- me(() => (K(), () => {
6763
+ }, [O, t, e, n, i, s, o, a, l, u, h]);
6764
+ me(() => (b(), () => {
6765
6765
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6766
- }), [K]), me(() => {
6767
- if (!F.current || !p.current) return;
6768
- const A = new ResizeObserver((X) => {
6769
- for (const P of X)
6766
+ }), [b]), me(() => {
6767
+ if (!D.current || !p.current) return;
6768
+ const L = new ResizeObserver((U) => {
6769
+ for (const E of U)
6770
6770
  p.current && p.current.onResize && p.current.onResize();
6771
6771
  });
6772
- A.observe(F.current);
6772
+ L.observe(D.current);
6773
6773
  const B = () => {
6774
6774
  p.current && p.current.onResize && p.current.onResize();
6775
6775
  };
6776
6776
  return window.addEventListener("resize", B), () => {
6777
- A.disconnect(), window.removeEventListener("resize", B);
6777
+ L.disconnect(), window.removeEventListener("resize", B);
6778
6778
  };
6779
- }, [D]);
6780
- const b = T(async () => {
6779
+ }, [Z]);
6780
+ const v = T(async () => {
6781
6781
  if (p.current && p.current.audioCtx)
6782
6782
  try {
6783
6783
  (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6784
- } catch (A) {
6785
- console.warn("Failed to resume audio context:", A);
6784
+ } catch (L) {
6785
+ console.warn("Failed to resume audio context:", L);
6786
6786
  }
6787
- }, []), R = T(async (A, B = {}) => {
6788
- if (p.current && D)
6787
+ }, []), w = T(async (L, B = {}) => {
6788
+ if (p.current && Z)
6789
6789
  try {
6790
- v.current && (clearInterval(v.current), v.current = null), z.current = { text: A, options: B }, q(!1), await b();
6791
- const X = {
6790
+ R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: B }, P.current = { remainingText: null, originalText: null, options: null }, K(!1), M.current = !1, await v();
6791
+ const U = {
6792
6792
  ...B,
6793
- lipsyncLang: B.lipsyncLang || ce.lipsyncLang || "en"
6793
+ lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
6794
6794
  };
6795
6795
  if (B.onSpeechEnd && p.current) {
6796
- const P = p.current;
6797
- let $ = null, pe = 0;
6796
+ const E = p.current;
6797
+ let Y = null, ge = 0;
6798
6798
  const ke = 1200;
6799
- let fe = !1;
6800
- $ = setInterval(() => {
6801
- if (pe++, M.current)
6799
+ let xe = !1;
6800
+ Y = setInterval(() => {
6801
+ if (ge++, M.current)
6802
6802
  return;
6803
- if (pe > ke) {
6804
- if ($ && (clearInterval($), $ = null, v.current = null), !fe && !M.current) {
6805
- fe = !0;
6803
+ if (ge > ke) {
6804
+ if (Y && (clearInterval(Y), Y = null, R.current = null), !xe && !M.current) {
6805
+ xe = !0;
6806
6806
  try {
6807
6807
  B.onSpeechEnd();
6808
6808
  } catch (we) {
@@ -6811,121 +6811,139 @@ const Pe = Ie(({
6811
6811
  }
6812
6812
  return;
6813
6813
  }
6814
- const De = !P.speechQueue || P.speechQueue.length === 0, Oe = !P.audioPlaylist || P.audioPlaylist.length === 0;
6815
- P && P.isSpeaking === !1 && De && Oe && P.isAudioPlaying === !1 && !fe && !M.current && setTimeout(() => {
6816
- if (P && !M.current && P.isSpeaking === !1 && (!P.speechQueue || P.speechQueue.length === 0) && (!P.audioPlaylist || P.audioPlaylist.length === 0) && P.isAudioPlaying === !1 && !fe && !M.current) {
6817
- fe = !0, $ && (clearInterval($), $ = null, v.current = null);
6814
+ const Oe = !E.speechQueue || E.speechQueue.length === 0, Ne = !E.audioPlaylist || E.audioPlaylist.length === 0;
6815
+ E && E.isSpeaking === !1 && Oe && Ne && E.isAudioPlaying === !1 && !xe && !M.current && setTimeout(() => {
6816
+ if (E && !M.current && E.isSpeaking === !1 && (!E.speechQueue || E.speechQueue.length === 0) && (!E.audioPlaylist || E.audioPlaylist.length === 0) && E.isAudioPlaying === !1 && !xe && !M.current) {
6817
+ xe = !0, Y && (clearInterval(Y), Y = null, R.current = null);
6818
6818
  try {
6819
6819
  B.onSpeechEnd();
6820
- } catch (Ne) {
6821
- console.error("Error in onSpeechEnd callback:", Ne);
6820
+ } catch (Ue) {
6821
+ console.error("Error in onSpeechEnd callback:", Ue);
6822
6822
  }
6823
6823
  }
6824
6824
  }, 100);
6825
- }, 100), v.current = $;
6825
+ }, 100), R.current = Y;
6826
6826
  }
6827
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A, X)) : setTimeout(async () => {
6828
- await b(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A, X));
6827
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, U)) : setTimeout(async () => {
6828
+ await v(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, U));
6829
6829
  }, 100);
6830
- } catch (X) {
6831
- console.error("Error speaking text:", X), S(X.message || "Failed to speak text");
6830
+ } catch (U) {
6831
+ console.error("Error speaking text:", U), N(U.message || "Failed to speak text");
6832
6832
  }
6833
- }, [D, b, ce.lipsyncLang]), w = T(() => {
6834
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, q(!1));
6835
- }, []), C = T(() => {
6833
+ }, [Z, v, pe.lipsyncLang]), C = T(() => {
6834
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, K(!1));
6835
+ }, []), V = T(() => {
6836
6836
  if (p.current && p.current.pauseSpeaking) {
6837
- const A = p.current;
6838
- (A.isSpeaking || A.audioPlaylist && A.audioPlaylist.length > 0 || A.speechQueue && A.speechQueue.length > 0) && (v.current && (clearInterval(v.current), v.current = null), A.speechQueue && (A.speechQueue.length = 0), p.current.pauseSpeaking(), M.current = !0, q(!0));
6837
+ const L = p.current;
6838
+ if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
6839
+ R.current && (clearInterval(R.current), R.current = null);
6840
+ let U = "";
6841
+ if (L.speechQueue && L.speechQueue.length > 0) {
6842
+ const E = L.speechQueue.filter((Y) => Y.text).map((Y) => Y.text).join(" ");
6843
+ E && (U = E.trim());
6844
+ }
6845
+ U && z.current && (P.current = {
6846
+ remainingText: U,
6847
+ originalText: z.current.text,
6848
+ options: z.current.options
6849
+ }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), M.current = !0, K(!0);
6850
+ }
6839
6851
  }
6840
- }, []), V = T(async () => {
6841
- if (p.current && O && z.current && z.current.text) {
6842
- const A = z.current, B = A.options || {};
6843
- q(!1), await b();
6844
- const X = {
6852
+ }, []), ne = T(async () => {
6853
+ if (p.current && j) {
6854
+ K(!1), M.current = !1, await v();
6855
+ let L = "", B = {};
6856
+ if (P.current && P.current.remainingText)
6857
+ L = P.current.remainingText, B = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
6858
+ else if (z.current && z.current.text)
6859
+ L = z.current.text, B = z.current.options || {};
6860
+ else
6861
+ return;
6862
+ const U = {
6845
6863
  ...B,
6846
- lipsyncLang: B.lipsyncLang || ce.lipsyncLang || "en"
6864
+ lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
6847
6865
  };
6848
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), await R(A.text, X));
6866
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), await w(L, U));
6849
6867
  }
6850
- }, [b, O, R]), te = T((A) => {
6851
- p.current && p.current.setMood(A);
6852
- }, []), ne = T((A) => {
6853
- p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(A);
6854
- }, []), ye = T((A, B = !1) => {
6868
+ }, [v, j, w]), ie = T((L) => {
6869
+ p.current && p.current.setMood(L);
6870
+ }, []), fe = T((L) => {
6871
+ p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6872
+ }, []), Se = T((L, B = !1) => {
6855
6873
  if (p.current && p.current.playAnimation) {
6856
- if (x && x[A] && (A = x[A]), p.current.setShowFullAvatar)
6874
+ if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
6857
6875
  try {
6858
6876
  p.current.setShowFullAvatar(H.current);
6859
- } catch (P) {
6860
- console.warn("Error setting full body mode:", P);
6877
+ } catch (E) {
6878
+ console.warn("Error setting full body mode:", E);
6861
6879
  }
6862
- if (A.includes("."))
6880
+ if (L.includes("."))
6863
6881
  try {
6864
- p.current.playAnimation(A, null, 10, 0, 0.01, B);
6865
- } catch (P) {
6866
- console.warn(`Failed to play ${A}:`, P);
6882
+ p.current.playAnimation(L, null, 10, 0, 0.01, B);
6883
+ } catch (E) {
6884
+ console.warn(`Failed to play ${L}:`, E);
6867
6885
  try {
6868
6886
  p.current.setBodyMovement("idle");
6869
- } catch ($) {
6870
- console.warn("Fallback animation also failed:", $);
6887
+ } catch (Y) {
6888
+ console.warn("Fallback animation also failed:", Y);
6871
6889
  }
6872
6890
  }
6873
6891
  else {
6874
- const P = [".fbx", ".glb", ".gltf"];
6875
- let $ = !1;
6876
- for (const pe of P)
6892
+ const E = [".fbx", ".glb", ".gltf"];
6893
+ let Y = !1;
6894
+ for (const ge of E)
6877
6895
  try {
6878
- p.current.playAnimation(A + pe, null, 10, 0, 0.01, B), $ = !0;
6896
+ p.current.playAnimation(L + ge, null, 10, 0, 0.01, B), Y = !0;
6879
6897
  break;
6880
6898
  } catch {
6881
6899
  }
6882
- if (!$) {
6883
- console.warn("Animation not found:", A);
6900
+ if (!Y) {
6901
+ console.warn("Animation not found:", L);
6884
6902
  try {
6885
6903
  p.current.setBodyMovement("idle");
6886
- } catch (pe) {
6887
- console.warn("Fallback animation also failed:", pe);
6904
+ } catch (ge) {
6905
+ console.warn("Fallback animation also failed:", ge);
6888
6906
  }
6889
6907
  }
6890
6908
  }
6891
6909
  }
6892
- }, [x]), Se = T(() => {
6910
+ }, [x]), De = T(() => {
6893
6911
  p.current && p.current.onResize && p.current.onResize();
6894
6912
  }, []);
6895
6913
  return Le(I, () => ({
6896
- speakText: R,
6897
- stopSpeaking: w,
6898
- pauseSpeaking: C,
6899
- resumeSpeaking: V,
6900
- resumeAudioContext: b,
6901
- setMood: te,
6902
- setTimingAdjustment: ne,
6903
- playAnimation: ye,
6904
- isReady: D,
6905
- isPaused: O,
6914
+ speakText: w,
6915
+ stopSpeaking: C,
6916
+ pauseSpeaking: V,
6917
+ resumeSpeaking: ne,
6918
+ resumeAudioContext: v,
6919
+ setMood: ie,
6920
+ setTimingAdjustment: fe,
6921
+ playAnimation: Se,
6922
+ isReady: Z,
6923
+ isPaused: j,
6906
6924
  talkingHead: p.current,
6907
- handleResize: Se,
6908
- setBodyMovement: (A) => {
6925
+ handleResize: De,
6926
+ setBodyMovement: (L) => {
6909
6927
  if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
6910
6928
  try {
6911
- p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(A);
6929
+ p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(L);
6912
6930
  } catch (B) {
6913
6931
  console.warn("Error setting body movement:", B);
6914
6932
  }
6915
6933
  },
6916
- setMovementIntensity: (A) => p.current?.setMovementIntensity(A),
6934
+ setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
6917
6935
  playRandomDance: () => {
6918
6936
  if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
6919
6937
  try {
6920
6938
  p.current.setShowFullAvatar(H.current), p.current.playRandomDance();
6921
- } catch (A) {
6922
- console.warn("Error playing random dance:", A);
6939
+ } catch (L) {
6940
+ console.warn("Error playing random dance:", L);
6923
6941
  }
6924
6942
  },
6925
- playReaction: (A) => {
6943
+ playReaction: (L) => {
6926
6944
  if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
6927
6945
  try {
6928
- p.current.setShowFullAvatar(H.current), p.current.playReaction(A);
6946
+ p.current.setShowFullAvatar(H.current), p.current.playReaction(L);
6929
6947
  } catch (B) {
6930
6948
  console.warn("Error playing reaction:", B);
6931
6949
  }
@@ -6934,14 +6952,14 @@ const Pe = Ie(({
6934
6952
  if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
6935
6953
  try {
6936
6954
  p.current.setShowFullAvatar(H.current), p.current.playCelebration();
6937
- } catch (A) {
6938
- console.warn("Error playing celebration:", A);
6955
+ } catch (L) {
6956
+ console.warn("Error playing celebration:", L);
6939
6957
  }
6940
6958
  },
6941
- setShowFullAvatar: (A) => {
6959
+ setShowFullAvatar: (L) => {
6942
6960
  if (p.current && p.current.setShowFullAvatar)
6943
6961
  try {
6944
- H.current = A, p.current.setShowFullAvatar(A);
6962
+ H.current = L, p.current.setShowFullAvatar(L);
6945
6963
  } catch (B) {
6946
6964
  console.warn("Error setting showFullAvatar:", B);
6947
6965
  }
@@ -6950,16 +6968,16 @@ const Pe = Ie(({
6950
6968
  if (p.current && p.current.lockAvatarPosition)
6951
6969
  try {
6952
6970
  p.current.lockAvatarPosition();
6953
- } catch (A) {
6954
- console.warn("Error locking avatar position:", A);
6971
+ } catch (L) {
6972
+ console.warn("Error locking avatar position:", L);
6955
6973
  }
6956
6974
  },
6957
6975
  unlockAvatarPosition: () => {
6958
6976
  if (p.current && p.current.unlockAvatarPosition)
6959
6977
  try {
6960
6978
  p.current.unlockAvatarPosition();
6961
- } catch (A) {
6962
- console.warn("Error unlocking avatar position:", A);
6979
+ } catch (L) {
6980
+ console.warn("Error unlocking avatar position:", L);
6963
6981
  }
6964
6982
  }
6965
6983
  })), /* @__PURE__ */ Ee(
@@ -6976,7 +6994,7 @@ const Pe = Ie(({
6976
6994
  /* @__PURE__ */ ue(
6977
6995
  "div",
6978
6996
  {
6979
- ref: F,
6997
+ ref: D,
6980
6998
  className: "talking-head-viewer",
6981
6999
  style: {
6982
7000
  width: "100%",
@@ -6985,7 +7003,7 @@ const Pe = Ie(({
6985
7003
  }
6986
7004
  }
6987
7005
  ),
6988
- W && /* @__PURE__ */ ue("div", { className: "loading-overlay", style: {
7006
+ ee && /* @__PURE__ */ ue("div", { className: "loading-overlay", style: {
6989
7007
  position: "absolute",
6990
7008
  top: "50%",
6991
7009
  left: "50%",
@@ -6994,7 +7012,7 @@ const Pe = Ie(({
6994
7012
  fontSize: "18px",
6995
7013
  zIndex: 10
6996
7014
  }, children: "Loading avatar..." }),
6997
- re && /* @__PURE__ */ ue("div", { className: "error-overlay", style: {
7015
+ S && /* @__PURE__ */ ue("div", { className: "error-overlay", style: {
6998
7016
  position: "absolute",
6999
7017
  top: "50%",
7000
7018
  left: "50%",
@@ -7005,14 +7023,14 @@ const Pe = Ie(({
7005
7023
  zIndex: 10,
7006
7024
  padding: "20px",
7007
7025
  borderRadius: "8px"
7008
- }, children: re })
7026
+ }, children: S })
7009
7027
  ]
7010
7028
  }
7011
7029
  );
7012
7030
  });
7013
7031
  Pe.displayName = "TalkingHeadAvatar";
7014
- const ht = Ie(({
7015
- text: N = "Hello! I'm a talking avatar. How are you today?",
7032
+ const ut = Ie(({
7033
+ text: O = "Hello! I'm a talking avatar. How are you today?",
7016
7034
  onLoading: t = () => {
7017
7035
  },
7018
7036
  onError: e = () => {
@@ -7023,7 +7041,7 @@ const ht = Ie(({
7023
7041
  style: s = {},
7024
7042
  avatarConfig: o = {}
7025
7043
  }, l) => {
7026
- const u = G(null), a = G(null), [h, r] = de(!0), [c, d] = de(null), [g, y] = de(!1), x = Ae(), I = o.ttsService || x.service, F = I === "browser" ? {
7044
+ const u = G(null), a = G(null), [h, r] = de(!0), [c, d] = de(null), [g, y] = de(!1), x = Ae(), I = o.ttsService || x.service, D = I === "browser" ? {
7027
7045
  endpoint: "",
7028
7046
  apiKey: null,
7029
7047
  defaultVoice: "Google US English"
@@ -7039,7 +7057,7 @@ const ht = Ie(({
7039
7057
  body: "F",
7040
7058
  avatarMood: "neutral",
7041
7059
  ttsLang: I === "browser" ? "en-US" : "en",
7042
- ttsVoice: o.ttsVoice || F.defaultVoice,
7060
+ ttsVoice: o.ttsVoice || D.defaultVoice,
7043
7061
  lipsyncLang: "en",
7044
7062
  // English lip-sync
7045
7063
  showFullAvatar: !0,
@@ -7048,42 +7066,42 @@ const ht = Ie(({
7048
7066
  movementIntensity: 0.5,
7049
7067
  ...o
7050
7068
  }, H = {
7051
- ttsEndpoint: F.endpoint,
7052
- ttsApikey: F.apiKey,
7069
+ ttsEndpoint: D.endpoint,
7070
+ ttsApikey: D.apiKey,
7053
7071
  ttsService: I,
7054
7072
  lipsyncModules: ["en"],
7055
7073
  cameraView: "upper"
7056
7074
  }, z = T(async () => {
7057
7075
  if (!(!u.current || a.current))
7058
7076
  try {
7059
- if (r(!0), d(null), a.current = new Fe(u.current, H), await a.current.showAvatar(p, (Y) => {
7060
- if (Y.lengthComputable) {
7061
- const O = Math.min(100, Math.round(Y.loaded / Y.total * 100));
7062
- t(O);
7077
+ if (r(!0), d(null), a.current = new Fe(u.current, H), await a.current.showAvatar(p, (Z) => {
7078
+ if (Z.lengthComputable) {
7079
+ const X = Math.min(100, Math.round(Z.loaded / Z.total * 100));
7080
+ t(X);
7063
7081
  }
7064
7082
  }), a.current.morphs && a.current.morphs.length > 0) {
7065
- const Y = a.current.morphs[0].morphTargetDictionary;
7066
- console.log("Available morph targets:", Object.keys(Y));
7067
- const O = Object.keys(Y).filter((q) => q.startsWith("viseme_"));
7068
- console.log("Viseme morph targets found:", O), O.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7083
+ const Z = a.current.morphs[0].morphTargetDictionary;
7084
+ console.log("Available morph targets:", Object.keys(Z));
7085
+ const X = Object.keys(Z).filter((j) => j.startsWith("viseme_"));
7086
+ console.log("Viseme morph targets found:", X), X.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7069
7087
  }
7070
- if (await new Promise((Y) => {
7071
- const O = () => {
7072
- a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), Y()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(O, 100));
7088
+ if (await new Promise((Z) => {
7089
+ const X = () => {
7090
+ a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), Z()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(X, 100));
7073
7091
  };
7074
- O();
7092
+ X();
7075
7093
  }), a.current && a.current.setShowFullAvatar)
7076
7094
  try {
7077
7095
  a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7078
- } catch (Y) {
7079
- console.warn("Error setting full body mode on initialization:", Y);
7096
+ } catch (Z) {
7097
+ console.warn("Error setting full body mode on initialization:", Z);
7080
7098
  }
7081
7099
  r(!1), y(!0), n(a.current);
7082
- const D = () => {
7100
+ const N = () => {
7083
7101
  document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
7084
7102
  };
7085
- return document.addEventListener("visibilitychange", D), () => {
7086
- document.removeEventListener("visibilitychange", D);
7103
+ return document.addEventListener("visibilitychange", N), () => {
7104
+ document.removeEventListener("visibilitychange", N);
7087
7105
  };
7088
7106
  } catch (S) {
7089
7107
  console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
@@ -7092,58 +7110,58 @@ const ht = Ie(({
7092
7110
  me(() => (z(), () => {
7093
7111
  a.current && (a.current.stop(), a.current.dispose(), a.current = null);
7094
7112
  }), [z]);
7095
- const v = T((S) => {
7113
+ const R = T((S) => {
7096
7114
  if (a.current && g)
7097
7115
  try {
7098
7116
  console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", a.current), a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7099
7117
  a.current && a.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
7100
7118
  }, 500));
7101
- } catch (D) {
7102
- console.error("Error speaking text:", D), d(D.message || "Failed to speak text");
7119
+ } catch (N) {
7120
+ console.error("Error speaking text:", N), d(N.message || "Failed to speak text");
7103
7121
  }
7104
7122
  else
7105
7123
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
7106
7124
  }, [g, p]), M = T(() => {
7107
7125
  a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7108
- }, []), W = T((S) => {
7126
+ }, []), P = T((S) => {
7109
7127
  a.current && a.current.setMood(S);
7110
- }, []), _ = T((S) => {
7128
+ }, []), ee = T((S) => {
7111
7129
  a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7112
- }, []), re = T((S, D = !1) => {
7130
+ }, []), re = T((S, N = !1) => {
7113
7131
  if (a.current && a.current.playAnimation) {
7114
7132
  if (a.current.setShowFullAvatar)
7115
7133
  try {
7116
7134
  a.current.setShowFullAvatar(!0);
7117
- } catch (O) {
7118
- console.warn("Error setting full body mode:", O);
7135
+ } catch (X) {
7136
+ console.warn("Error setting full body mode:", X);
7119
7137
  }
7120
7138
  if (S.includes("."))
7121
7139
  try {
7122
- a.current.playAnimation(S, null, 10, 0, 0.01, D), console.log("Playing animation:", S);
7123
- } catch (O) {
7124
- console.log(`Failed to play ${S}:`, O);
7140
+ a.current.playAnimation(S, null, 10, 0, 0.01, N), console.log("Playing animation:", S);
7141
+ } catch (X) {
7142
+ console.log(`Failed to play ${S}:`, X);
7125
7143
  try {
7126
7144
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7127
- } catch (q) {
7128
- console.warn("Fallback animation also failed:", q);
7145
+ } catch (j) {
7146
+ console.warn("Fallback animation also failed:", j);
7129
7147
  }
7130
7148
  }
7131
7149
  else {
7132
- const O = [".fbx", ".glb", ".gltf"];
7133
- let q = !1;
7134
- for (const Z of O)
7150
+ const X = [".fbx", ".glb", ".gltf"];
7151
+ let j = !1;
7152
+ for (const K of X)
7135
7153
  try {
7136
- a.current.playAnimation(S + Z, null, 10, 0, 0.01, D), console.log("Playing animation:", S + Z), q = !0;
7154
+ a.current.playAnimation(S + K, null, 10, 0, 0.01, N), console.log("Playing animation:", S + K), j = !0;
7137
7155
  break;
7138
7156
  } catch {
7139
- console.log(`Failed to play ${S}${Z}, trying next format...`);
7157
+ console.log(`Failed to play ${S}${K}, trying next format...`);
7140
7158
  }
7141
- if (!q) {
7159
+ if (!j) {
7142
7160
  console.warn("Animation system not available or animation not found:", S);
7143
7161
  try {
7144
7162
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7145
- } catch (Z) {
7146
- console.warn("Fallback animation also failed:", Z);
7163
+ } catch (K) {
7164
+ console.warn("Fallback animation also failed:", K);
7147
7165
  }
7148
7166
  }
7149
7167
  }
@@ -7151,10 +7169,10 @@ const ht = Ie(({
7151
7169
  console.warn("Animation system not available or animation not found:", S);
7152
7170
  }, []);
7153
7171
  return Le(l, () => ({
7154
- speakText: v,
7172
+ speakText: R,
7155
7173
  stopSpeaking: M,
7156
- setMood: W,
7157
- setTimingAdjustment: _,
7174
+ setMood: P,
7175
+ setTimingAdjustment: ee,
7158
7176
  playAnimation: re,
7159
7177
  isReady: g,
7160
7178
  talkingHead: a.current,
@@ -7162,8 +7180,8 @@ const ht = Ie(({
7162
7180
  if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
7163
7181
  try {
7164
7182
  a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7165
- } catch (D) {
7166
- console.warn("Error setting body movement:", D);
7183
+ } catch (N) {
7184
+ console.warn("Error setting body movement:", N);
7167
7185
  }
7168
7186
  },
7169
7187
  setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
@@ -7179,8 +7197,8 @@ const ht = Ie(({
7179
7197
  if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
7180
7198
  try {
7181
7199
  a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7182
- } catch (D) {
7183
- console.warn("Error playing reaction:", D);
7200
+ } catch (N) {
7201
+ console.warn("Error playing reaction:", N);
7184
7202
  }
7185
7203
  },
7186
7204
  playCelebration: () => {
@@ -7195,8 +7213,8 @@ const ht = Ie(({
7195
7213
  if (a.current && a.current.setShowFullAvatar)
7196
7214
  try {
7197
7215
  a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7198
- } catch (D) {
7199
- console.warn("Error setting showFullAvatar:", D);
7216
+ } catch (N) {
7217
+ console.warn("Error setting showFullAvatar:", N);
7200
7218
  }
7201
7219
  },
7202
7220
  lockAvatarPosition: () => {
@@ -7251,9 +7269,9 @@ const ht = Ie(({
7251
7269
  }, children: c })
7252
7270
  ] });
7253
7271
  });
7254
- ht.displayName = "TalkingHeadComponent";
7255
- const ut = Ie(({
7256
- curriculumData: N = null,
7272
+ ut.displayName = "TalkingHeadComponent";
7273
+ const ct = Ie(({
7274
+ curriculumData: O = null,
7257
7275
  avatarConfig: t = {},
7258
7276
  animations: e = {},
7259
7277
  onLessonStart: n = () => {
@@ -7284,7 +7302,7 @@ const ut = Ie(({
7284
7302
  onQuestionAnswer: s,
7285
7303
  onCurriculumComplete: o,
7286
7304
  onCustomAction: l
7287
- }), d = G(null), g = G(null), y = G(null), x = G(null), I = G(null), F = G(null), p = G(null), H = G(N?.curriculum || {
7305
+ }), d = G(null), g = G(null), y = G(null), x = G(null), I = G(null), D = G(null), p = G(null), H = G(O?.curriculum || {
7288
7306
  title: "Default Curriculum",
7289
7307
  description: "No curriculum data provided",
7290
7308
  language: "en",
@@ -7312,7 +7330,7 @@ const ut = Ie(({
7312
7330
  onCustomAction: l
7313
7331
  };
7314
7332
  }, [n, i, s, o, l]), me(() => {
7315
- H.current = N?.curriculum || {
7333
+ H.current = O?.curriculum || {
7316
7334
  title: "Default Curriculum",
7317
7335
  description: "No curriculum data provided",
7318
7336
  language: "en",
@@ -7331,12 +7349,12 @@ const ut = Ie(({
7331
7349
  animations: e,
7332
7350
  lipsyncLang: "en"
7333
7351
  };
7334
- }, [N, t, e]);
7335
- const v = T(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), M = T(() => v()?.questions[r.current.currentQuestionIndex], [v]), W = T((b, R) => R.type === "multiple_choice" || R.type === "true_false" ? b === R.answer : R.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), _ = T(() => {
7352
+ }, [O, t, e]);
7353
+ const R = T(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), M = T(() => R()?.questions[r.current.currentQuestionIndex], [R]), P = T((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), ee = T(() => {
7336
7354
  r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
7337
7355
  const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
7338
- let R = "Congratulations! You've completed this lesson";
7339
- if (r.current.totalQuestions > 0 ? R += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : R += "! ", b >= 80 ? R += "Excellent work! You have a great understanding of this topic." : b >= 60 ? R += "Good job! You understand most of the concepts." : R += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7356
+ let v = "Congratulations! You've completed this lesson";
7357
+ if (r.current.totalQuestions > 0 ? v += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7340
7358
  moduleIndex: r.current.currentModuleIndex,
7341
7359
  lessonIndex: r.current.currentLessonIndex,
7342
7360
  score: r.current.score,
@@ -7356,9 +7374,9 @@ const ut = Ie(({
7356
7374
  } catch {
7357
7375
  h.current.playCelebration();
7358
7376
  }
7359
- const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, ne = V || te, ye = z.current || { lipsyncLang: "en" };
7360
- h.current.speakText(R, {
7361
- lipsyncLang: ye.lipsyncLang,
7377
+ const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, ie = V || ne, fe = z.current || { lipsyncLang: "en" };
7378
+ h.current.speakText(v, {
7379
+ lipsyncLang: fe.lipsyncLang,
7362
7380
  onSpeechEnd: () => {
7363
7381
  c.current.onCustomAction({
7364
7382
  type: "lessonCompleteFeedbackDone",
@@ -7367,7 +7385,7 @@ const ut = Ie(({
7367
7385
  score: r.current.score,
7368
7386
  totalQuestions: r.current.totalQuestions,
7369
7387
  percentage: b,
7370
- hasNextLesson: ne
7388
+ hasNextLesson: ie
7371
7389
  });
7372
7390
  }
7373
7391
  });
@@ -7377,7 +7395,7 @@ const ut = Ie(({
7377
7395
  const b = H.current || { modules: [] };
7378
7396
  if (c.current.onCurriculumComplete({
7379
7397
  modules: b.modules.length,
7380
- totalLessons: b.modules.reduce((R, w) => R + w.lessons.length, 0)
7398
+ totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
7381
7399
  }), h.current) {
7382
7400
  if (h.current.setMood("celebrating"), e.curriculumComplete)
7383
7401
  try {
@@ -7385,24 +7403,24 @@ const ut = Ie(({
7385
7403
  } catch {
7386
7404
  h.current.playCelebration();
7387
7405
  }
7388
- const R = z.current || { lipsyncLang: "en" };
7389
- h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
7406
+ const v = z.current || { lipsyncLang: "en" };
7407
+ h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
7390
7408
  }
7391
7409
  }, [e.curriculumComplete]), S = T(() => {
7392
- const b = v();
7410
+ const b = R();
7393
7411
  r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = b?.questions?.length || 0, r.current.score = 0;
7394
- const R = M();
7395
- R && c.current.onCustomAction({
7412
+ const v = M();
7413
+ v && c.current.onCustomAction({
7396
7414
  type: "questionStart",
7397
7415
  moduleIndex: r.current.currentModuleIndex,
7398
7416
  lessonIndex: r.current.currentLessonIndex,
7399
7417
  questionIndex: r.current.currentQuestionIndex,
7400
7418
  totalQuestions: r.current.totalQuestions,
7401
- question: R,
7419
+ question: v,
7402
7420
  score: r.current.score
7403
7421
  });
7404
7422
  const w = () => {
7405
- if (!h.current || !R) return;
7423
+ if (!h.current || !v) return;
7406
7424
  if (h.current.setMood("happy"), e.questionStart)
7407
7425
  try {
7408
7426
  h.current.playAnimation(e.questionStart, !0);
@@ -7410,37 +7428,37 @@ const ut = Ie(({
7410
7428
  console.warn("Failed to play questionStart animation:", V);
7411
7429
  }
7412
7430
  const C = z.current || { lipsyncLang: "en" };
7413
- R.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang });
7431
+ v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang });
7414
7432
  };
7415
- if (h.current && h.current.isReady && R)
7433
+ if (h.current && h.current.isReady && v)
7416
7434
  w();
7417
7435
  else if (h.current && h.current.isReady) {
7418
7436
  const C = z.current || { lipsyncLang: "en" };
7419
7437
  h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
7420
7438
  } else {
7421
7439
  const C = setInterval(() => {
7422
- h.current && h.current.isReady && (clearInterval(C), R && w());
7440
+ h.current && h.current.isReady && (clearInterval(C), v && w());
7423
7441
  }, 100);
7424
7442
  setTimeout(() => {
7425
7443
  clearInterval(C);
7426
7444
  }, 5e3);
7427
7445
  }
7428
- }, [e.questionStart, v, M]), D = T(() => {
7429
- const b = v();
7446
+ }, [e.questionStart, R, M]), N = T(() => {
7447
+ const b = R();
7430
7448
  if (r.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7431
7449
  h.current && h.current.stopSpeaking && h.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
7432
- const R = M();
7433
- R && c.current.onCustomAction({
7450
+ const v = M();
7451
+ v && c.current.onCustomAction({
7434
7452
  type: "nextQuestion",
7435
7453
  moduleIndex: r.current.currentModuleIndex,
7436
7454
  lessonIndex: r.current.currentLessonIndex,
7437
7455
  questionIndex: r.current.currentQuestionIndex,
7438
7456
  totalQuestions: r.current.totalQuestions,
7439
- question: R,
7457
+ question: v,
7440
7458
  score: r.current.score
7441
7459
  });
7442
7460
  const w = () => {
7443
- if (!h.current || !R) return;
7461
+ if (!h.current || !v) return;
7444
7462
  if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
7445
7463
  try {
7446
7464
  h.current.playAnimation(e.nextQuestion, !0);
@@ -7448,19 +7466,19 @@ const ut = Ie(({
7448
7466
  console.warn("Failed to play nextQuestion animation:", V);
7449
7467
  }
7450
7468
  const C = z.current || { lipsyncLang: "en" };
7451
- R.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${R.question}`, {
7469
+ v.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${v.question}`, {
7452
7470
  lipsyncLang: C.lipsyncLang
7453
- }) : R.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${R.question}`, {
7471
+ }) : v.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${v.question}`, {
7454
7472
  lipsyncLang: C.lipsyncLang
7455
- }) : R.type === "true_false" ? h.current.speakText(`Now let's try this one: ${R.question}`, {
7473
+ }) : v.type === "true_false" ? h.current.speakText(`Now let's try this one: ${v.question}`, {
7456
7474
  lipsyncLang: C.lipsyncLang
7457
- }) : h.current.speakText(`Here's the next question: ${R.question}`, {
7475
+ }) : h.current.speakText(`Here's the next question: ${v.question}`, {
7458
7476
  lipsyncLang: C.lipsyncLang
7459
7477
  });
7460
7478
  };
7461
- if (h.current && h.current.isReady && R)
7479
+ if (h.current && h.current.isReady && v)
7462
7480
  w();
7463
- else if (R) {
7481
+ else if (v) {
7464
7482
  const C = setInterval(() => {
7465
7483
  h.current && h.current.isReady && (clearInterval(C), w());
7466
7484
  }, 100);
@@ -7476,45 +7494,45 @@ const ut = Ie(({
7476
7494
  totalQuestions: r.current.totalQuestions,
7477
7495
  score: r.current.score
7478
7496
  });
7479
- }, [e.nextQuestion, v, M]), Y = T(() => {
7480
- const b = H.current || { modules: [] }, R = b.modules[r.current.currentModuleIndex];
7481
- if (r.current.currentLessonIndex < (R?.lessons?.length || 0) - 1) {
7497
+ }, [e.nextQuestion, R, M]), Z = T(() => {
7498
+ const b = H.current || { modules: [] }, v = b.modules[r.current.currentModuleIndex];
7499
+ if (r.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7482
7500
  r.current.currentLessonIndex += 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
7483
- const C = b.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ne = V || te;
7501
+ const C = b.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ie = V || ne;
7484
7502
  c.current.onCustomAction({
7485
7503
  type: "lessonStart",
7486
7504
  moduleIndex: r.current.currentModuleIndex,
7487
7505
  lessonIndex: r.current.currentLessonIndex,
7488
- hasNextLesson: ne
7506
+ hasNextLesson: ie
7489
7507
  }), c.current.onLessonStart({
7490
7508
  moduleIndex: r.current.currentModuleIndex,
7491
7509
  lessonIndex: r.current.currentLessonIndex,
7492
- lesson: v()
7510
+ lesson: R()
7493
7511
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7494
7512
  } else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7495
7513
  r.current.currentModuleIndex += 1, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
7496
- const V = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (V?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ye = te || ne;
7514
+ const V = b.modules[r.current.currentModuleIndex], ne = r.current.currentLessonIndex < (V?.lessons?.length || 0) - 1, ie = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, fe = ne || ie;
7497
7515
  c.current.onCustomAction({
7498
7516
  type: "lessonStart",
7499
7517
  moduleIndex: r.current.currentModuleIndex,
7500
7518
  lessonIndex: r.current.currentLessonIndex,
7501
- hasNextLesson: ye
7519
+ hasNextLesson: fe
7502
7520
  }), c.current.onLessonStart({
7503
7521
  moduleIndex: r.current.currentModuleIndex,
7504
7522
  lessonIndex: r.current.currentLessonIndex,
7505
- lesson: v()
7523
+ lesson: R()
7506
7524
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7507
7525
  } else
7508
7526
  I.current && I.current();
7509
- }, []), O = T(() => {
7510
- const b = v();
7511
- let R = null;
7527
+ }, []), X = T(() => {
7528
+ const b = R();
7529
+ let v = null;
7512
7530
  if (b?.avatar_script && b?.body) {
7513
7531
  const w = b.avatar_script.trim(), C = b.body.trim(), V = w.match(/[.!?]$/) ? " " : ". ";
7514
- R = `${w}${V}${C}`;
7532
+ v = `${w}${V}${C}`;
7515
7533
  } else
7516
- R = b?.avatar_script || b?.body || null;
7517
- if (h.current && h.current.isReady && R) {
7534
+ v = b?.avatar_script || b?.body || null;
7535
+ if (h.current && h.current.isReady && v) {
7518
7536
  r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, h.current.setMood("happy");
7519
7537
  let w = !1;
7520
7538
  if (e.teaching)
@@ -7534,7 +7552,7 @@ const ut = Ie(({
7534
7552
  moduleIndex: r.current.currentModuleIndex,
7535
7553
  lessonIndex: r.current.currentLessonIndex,
7536
7554
  lesson: b
7537
- }), h.current.speakText(R, {
7555
+ }), h.current.speakText(v, {
7538
7556
  lipsyncLang: C.lipsyncLang,
7539
7557
  onSpeechEnd: () => {
7540
7558
  r.current.isTeaching = !1, c.current.onCustomAction({
@@ -7547,15 +7565,15 @@ const ut = Ie(({
7547
7565
  }
7548
7566
  });
7549
7567
  }
7550
- }, [e.teaching, v]), q = T((b) => {
7551
- const R = M(), w = W(b, R);
7568
+ }, [e.teaching, R]), j = T((b) => {
7569
+ const v = M(), w = P(b, v);
7552
7570
  if (w && (r.current.score += 1), c.current.onQuestionAnswer({
7553
7571
  moduleIndex: r.current.currentModuleIndex,
7554
7572
  lessonIndex: r.current.currentLessonIndex,
7555
7573
  questionIndex: r.current.currentQuestionIndex,
7556
7574
  answer: b,
7557
7575
  isCorrect: w,
7558
- question: R
7576
+ question: v
7559
7577
  }), h.current)
7560
7578
  if (w) {
7561
7579
  if (h.current.setMood("happy"), e.correct)
@@ -7565,18 +7583,18 @@ const ut = Ie(({
7565
7583
  h.current.setBodyMovement("happy");
7566
7584
  }
7567
7585
  h.current.setBodyMovement("gesturing");
7568
- const C = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, V = z.current || { lipsyncLang: "en" };
7586
+ const C = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, V = z.current || { lipsyncLang: "en" };
7569
7587
  h.current.speakText(C, {
7570
7588
  lipsyncLang: V.lipsyncLang,
7571
7589
  onSpeechEnd: () => {
7572
- const ne = v()?.questions?.length || 0;
7590
+ const ie = R()?.questions?.length || 0;
7573
7591
  c.current.onCustomAction({
7574
7592
  type: "answerFeedbackComplete",
7575
7593
  moduleIndex: r.current.currentModuleIndex,
7576
7594
  lessonIndex: r.current.currentLessonIndex,
7577
7595
  questionIndex: r.current.currentQuestionIndex,
7578
7596
  isCorrect: !0,
7579
- hasNextQuestion: r.current.currentQuestionIndex < ne - 1,
7597
+ hasNextQuestion: r.current.currentQuestionIndex < ie - 1,
7580
7598
  score: r.current.score,
7581
7599
  totalQuestions: r.current.totalQuestions
7582
7600
  });
@@ -7590,18 +7608,18 @@ const ut = Ie(({
7590
7608
  h.current.setBodyMovement("idle");
7591
7609
  }
7592
7610
  h.current.setBodyMovement("gesturing");
7593
- const C = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""} Let's move on to the next question.`, V = z.current || { lipsyncLang: "en" };
7611
+ const C = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""} Let's move on to the next question.`, V = z.current || { lipsyncLang: "en" };
7594
7612
  h.current.speakText(C, {
7595
7613
  lipsyncLang: V.lipsyncLang,
7596
7614
  onSpeechEnd: () => {
7597
- const ne = v()?.questions?.length || 0;
7615
+ const ie = R()?.questions?.length || 0;
7598
7616
  c.current.onCustomAction({
7599
7617
  type: "answerFeedbackComplete",
7600
7618
  moduleIndex: r.current.currentModuleIndex,
7601
7619
  lessonIndex: r.current.currentLessonIndex,
7602
7620
  questionIndex: r.current.currentQuestionIndex,
7603
7621
  isCorrect: !1,
7604
- hasNextQuestion: r.current.currentQuestionIndex < ne - 1,
7622
+ hasNextQuestion: r.current.currentQuestionIndex < ie - 1,
7605
7623
  score: r.current.score,
7606
7624
  totalQuestions: r.current.totalQuestions
7607
7625
  });
@@ -7609,7 +7627,7 @@ const ut = Ie(({
7609
7627
  });
7610
7628
  }
7611
7629
  else {
7612
- const V = v()?.questions?.length || 0;
7630
+ const V = R()?.questions?.length || 0;
7613
7631
  c.current.onCustomAction({
7614
7632
  type: "answerFeedbackComplete",
7615
7633
  moduleIndex: r.current.currentModuleIndex,
@@ -7622,13 +7640,13 @@ const ut = Ie(({
7622
7640
  avatarNotReady: !0
7623
7641
  });
7624
7642
  }
7625
- }, [e.correct, e.incorrect, M, v, W]), Z = T((b) => {
7626
- const R = M();
7643
+ }, [e.correct, e.incorrect, M, R, P]), K = T((b) => {
7644
+ const v = M();
7627
7645
  if (!b || typeof b != "object") {
7628
7646
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
7629
7647
  return;
7630
7648
  }
7631
- if (R?.type !== "code_test") {
7649
+ if (v?.type !== "code_test") {
7632
7650
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
7633
7651
  return;
7634
7652
  }
@@ -7648,9 +7666,9 @@ const ut = Ie(({
7648
7666
  lessonIndex: r.current.currentLessonIndex,
7649
7667
  questionIndex: r.current.currentQuestionIndex,
7650
7668
  testResult: w,
7651
- question: R
7669
+ question: v
7652
7670
  }), p.current && p.current(w);
7653
- }, [M, W]), le = T(() => {
7671
+ }, [M, P]), te = T(() => {
7654
7672
  if (r.current.currentQuestionIndex > 0) {
7655
7673
  r.current.currentQuestionIndex -= 1;
7656
7674
  const b = M();
@@ -7663,7 +7681,7 @@ const ut = Ie(({
7663
7681
  question: b,
7664
7682
  score: r.current.score
7665
7683
  });
7666
- const R = () => {
7684
+ const v = () => {
7667
7685
  if (!h.current || !b) return;
7668
7686
  h.current.setMood("happy"), h.current.setBodyMovement("idle");
7669
7687
  const w = z.current || { lipsyncLang: "en" };
@@ -7674,17 +7692,17 @@ const ut = Ie(({
7674
7692
  });
7675
7693
  };
7676
7694
  if (h.current && h.current.isReady && b)
7677
- R();
7695
+ v();
7678
7696
  else if (b) {
7679
7697
  const w = setInterval(() => {
7680
- h.current && h.current.isReady && (clearInterval(w), R());
7698
+ h.current && h.current.isReady && (clearInterval(w), v());
7681
7699
  }, 100);
7682
7700
  setTimeout(() => {
7683
7701
  clearInterval(w);
7684
7702
  }, 5e3);
7685
7703
  }
7686
7704
  }
7687
- }, [M]), se = T(() => {
7705
+ }, [M]), ce = T(() => {
7688
7706
  const b = H.current || { modules: [] };
7689
7707
  if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
7690
7708
  r.current.currentLessonIndex -= 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
@@ -7694,7 +7712,7 @@ const ut = Ie(({
7694
7712
  }), c.current.onLessonStart({
7695
7713
  moduleIndex: r.current.currentModuleIndex,
7696
7714
  lessonIndex: r.current.currentLessonIndex,
7697
- lesson: v()
7715
+ lesson: R()
7698
7716
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7699
7717
  else if (r.current.currentModuleIndex > 0) {
7700
7718
  const C = b.modules[r.current.currentModuleIndex - 1];
@@ -7705,53 +7723,53 @@ const ut = Ie(({
7705
7723
  }), c.current.onLessonStart({
7706
7724
  moduleIndex: r.current.currentModuleIndex,
7707
7725
  lessonIndex: r.current.currentLessonIndex,
7708
- lesson: v()
7726
+ lesson: R()
7709
7727
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7710
7728
  }
7711
- }, [v]), ce = T(() => {
7729
+ }, [R]), oe = T(() => {
7712
7730
  r.current.currentModuleIndex = 0, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.isTeaching = !1, r.current.isQuestionMode = !1, r.current.lessonCompleted = !1, r.current.curriculumCompleted = !1, r.current.score = 0, r.current.totalQuestions = 0;
7713
- }, []), Re = T((b) => {
7731
+ }, []), pe = T((b) => {
7714
7732
  console.log("Avatar is ready!", b);
7715
- const R = v(), w = R?.avatar_script || R?.body;
7733
+ const v = R(), w = v?.avatar_script || v?.body;
7716
7734
  u && w && setTimeout(() => {
7717
7735
  d.current && d.current();
7718
7736
  }, 10);
7719
- }, [u, v]);
7720
- Ue(() => {
7721
- d.current = O, g.current = Y, y.current = _, x.current = D, I.current = re, F.current = S, p.current = q;
7737
+ }, [u, R]);
7738
+ We(() => {
7739
+ d.current = X, g.current = Z, y.current = ee, x.current = N, I.current = re, D.current = S, p.current = j;
7722
7740
  }), Le(a, () => ({
7723
7741
  // Curriculum control methods
7724
- startTeaching: O,
7742
+ startTeaching: X,
7725
7743
  startQuestions: S,
7726
- handleAnswerSelect: q,
7727
- handleCodeTestResult: Z,
7728
- nextQuestion: D,
7729
- previousQuestion: le,
7730
- nextLesson: Y,
7731
- previousLesson: se,
7732
- completeLesson: _,
7744
+ handleAnswerSelect: j,
7745
+ handleCodeTestResult: K,
7746
+ nextQuestion: N,
7747
+ previousQuestion: te,
7748
+ nextLesson: Z,
7749
+ previousLesson: ce,
7750
+ completeLesson: ee,
7733
7751
  completeCurriculum: re,
7734
- resetCurriculum: ce,
7752
+ resetCurriculum: oe,
7735
7753
  getState: () => ({ ...r.current }),
7736
7754
  getCurrentQuestion: () => M(),
7737
- getCurrentLesson: () => v(),
7755
+ getCurrentLesson: () => R(),
7738
7756
  // Direct access to avatar ref (always returns current value)
7739
7757
  getAvatarRef: () => h.current,
7740
7758
  // Convenience methods that delegate to avatar (always check current ref)
7741
- speakText: async (b, R = {}) => {
7759
+ speakText: async (b, v = {}) => {
7742
7760
  await h.current?.resumeAudioContext?.();
7743
7761
  const w = z.current || { lipsyncLang: "en" };
7744
- h.current?.speakText(b, { ...R, lipsyncLang: R.lipsyncLang || w.lipsyncLang });
7762
+ h.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || w.lipsyncLang });
7745
7763
  },
7746
7764
  resumeAudioContext: async () => {
7747
7765
  if (h.current?.resumeAudioContext)
7748
7766
  return await h.current.resumeAudioContext();
7749
7767
  const b = h.current?.talkingHead;
7750
7768
  if (b?.audioCtx) {
7751
- const R = b.audioCtx;
7752
- if (R.state === "suspended" || R.state === "interrupted")
7769
+ const v = b.audioCtx;
7770
+ if (v.state === "suspended" || v.state === "interrupted")
7753
7771
  try {
7754
- await R.resume(), console.log("Audio context resumed via talkingHead");
7772
+ await v.resume(), console.log("Audio context resumed via talkingHead");
7755
7773
  } catch (w) {
7756
7774
  console.warn("Failed to resume audio context:", w);
7757
7775
  }
@@ -7763,7 +7781,7 @@ const ut = Ie(({
7763
7781
  resumeSpeaking: async () => await h.current?.resumeSpeaking(),
7764
7782
  isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
7765
7783
  setMood: (b) => h.current?.setMood(b),
7766
- playAnimation: (b, R) => h.current?.playAnimation(b, R),
7784
+ playAnimation: (b, v) => h.current?.playAnimation(b, v),
7767
7785
  setBodyMovement: (b) => h.current?.setBodyMovement(b),
7768
7786
  setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
7769
7787
  playRandomDance: () => h.current?.playRandomDance(),
@@ -7774,10 +7792,10 @@ const ut = Ie(({
7774
7792
  lockAvatarPosition: () => h.current?.lockAvatarPosition(),
7775
7793
  unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
7776
7794
  // Custom action trigger
7777
- triggerCustomAction: (b, R) => {
7795
+ triggerCustomAction: (b, v) => {
7778
7796
  c.current.onCustomAction({
7779
7797
  type: b,
7780
- ...R,
7798
+ ...v,
7781
7799
  state: { ...r.current }
7782
7800
  });
7783
7801
  },
@@ -7785,8 +7803,8 @@ const ut = Ie(({
7785
7803
  handleResize: () => h.current?.handleResize(),
7786
7804
  // Avatar readiness check (always returns current value)
7787
7805
  isAvatarReady: () => h.current?.isReady || !1
7788
- }), [O, S, q, Z, D, Y, _, re, ce, M, v]);
7789
- const K = z.current || {
7806
+ }), [X, S, j, K, N, Z, ee, re, oe, M, R]);
7807
+ const J = z.current || {
7790
7808
  avatarUrl: "/avatars/brunette.glb",
7791
7809
  avatarBody: "F",
7792
7810
  mood: "happy",
@@ -7803,19 +7821,19 @@ const ut = Ie(({
7803
7821
  Pe,
7804
7822
  {
7805
7823
  ref: h,
7806
- avatarUrl: K.avatarUrl,
7807
- avatarBody: K.avatarBody,
7808
- mood: K.mood,
7809
- ttsLang: K.ttsLang,
7810
- ttsService: K.ttsService,
7811
- ttsVoice: K.ttsVoice,
7812
- ttsApiKey: K.ttsApiKey,
7813
- bodyMovement: K.bodyMovement,
7814
- movementIntensity: K.movementIntensity,
7815
- showFullAvatar: K.showFullAvatar,
7824
+ avatarUrl: J.avatarUrl,
7825
+ avatarBody: J.avatarBody,
7826
+ mood: J.mood,
7827
+ ttsLang: J.ttsLang,
7828
+ ttsService: J.ttsService,
7829
+ ttsVoice: J.ttsVoice,
7830
+ ttsApiKey: J.ttsApiKey,
7831
+ bodyMovement: J.bodyMovement,
7832
+ movementIntensity: J.movementIntensity,
7833
+ showFullAvatar: J.showFullAvatar,
7816
7834
  cameraView: "upper",
7817
- animations: K.animations,
7818
- onReady: Re,
7835
+ animations: J.animations,
7836
+ onReady: pe,
7819
7837
  onLoading: () => {
7820
7838
  },
7821
7839
  onError: (b) => {
@@ -7824,7 +7842,7 @@ const ut = Ie(({
7824
7842
  }
7825
7843
  ) });
7826
7844
  });
7827
- ut.displayName = "CurriculumLearning";
7845
+ ct.displayName = "CurriculumLearning";
7828
7846
  const Be = {
7829
7847
  // Code-based dance animations (no FBX required)
7830
7848
  dance: {
@@ -7928,14 +7946,14 @@ const Be = {
7928
7946
  duration: 5e3,
7929
7947
  description: "Excited, energetic movement"
7930
7948
  }
7931
- }, Rt = (N) => Be[N] || null, It = (N) => Be.hasOwnProperty(N);
7949
+ }, It = (O) => Be[O] || null, Lt = (O) => Be.hasOwnProperty(O);
7932
7950
  export {
7933
- ut as CurriculumLearning,
7951
+ ct as CurriculumLearning,
7934
7952
  Pe as TalkingHeadAvatar,
7935
- ht as TalkingHeadComponent,
7953
+ ut as TalkingHeadComponent,
7936
7954
  Be as animations,
7937
7955
  Ae as getActiveTTSConfig,
7938
- Rt as getAnimation,
7939
- vt as getVoiceOptions,
7940
- It as hasAnimation
7956
+ It as getAnimation,
7957
+ Rt as getVoiceOptions,
7958
+ Lt as hasAnimation
7941
7959
  };