@sage-rsc/talking-head-react 1.0.48 → 1.0.50

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
- import { jsxs as Ce, jsx as oe } from "react/jsx-runtime";
2
- import { forwardRef as be, useRef as X, useState as re, useCallback as E, useEffect as he, useImperativeHandle as Re, useLayoutEffect as Pe } from "react";
1
+ import { jsxs as He, jsx as se } from "react/jsx-runtime";
2
+ import { forwardRef as Re, useRef as G, useState as he, useEffect as ue, useCallback as E, useImperativeHandle as ve, useLayoutEffect as Be } from "react";
3
3
  import * as f from "three";
4
- import { OrbitControls as Be } from "three/addons/controls/OrbitControls.js";
5
- import { GLTFLoader as De } from "three/addons/loaders/GLTFLoader.js";
6
- import { DRACOLoader as Oe } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as Le } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as Ne } from "three/addons/environments/RoomEnvironment.js";
9
- import Ue from "three/addons/libs/stats.module.js";
10
- let m, Q, J;
11
- const A = [0, 0, 0, 0], k = new f.Vector3(), me = new f.Vector3(), G = new f.Vector3(), pe = new f.Vector3();
4
+ import { OrbitControls as De } from "three/addons/controls/OrbitControls.js";
5
+ import { GLTFLoader as Oe } from "three/addons/loaders/GLTFLoader.js";
6
+ import { DRACOLoader as Ne } from "three/addons/loaders/DRACOLoader.js";
7
+ import { FBXLoader as Se } from "three/addons/loaders/FBXLoader.js";
8
+ import { RoomEnvironment as Ue } from "three/addons/environments/RoomEnvironment.js";
9
+ import We from "three/addons/libs/stats.module.js";
10
+ let m, q, K;
11
+ const A = [0, 0, 0, 0], k = new f.Vector3(), pe = new f.Vector3(), X = new f.Vector3(), ge = new f.Vector3();
12
12
  new f.Plane();
13
13
  new f.Ray();
14
14
  new f.Euler();
15
- const Z = new f.Quaternion(), Se = new f.Quaternion(), ee = new f.Matrix4(), te = new f.Matrix4();
15
+ const Y = new f.Quaternion(), ke = new f.Quaternion(), ee = new f.Matrix4(), te = new f.Matrix4();
16
16
  new f.Vector3();
17
- const ge = new f.Vector3(0, 0, 1), We = new f.Vector3(1, 0, 0), Ve = new f.Vector3(0, 1, 0), Ge = new f.Vector3(0, 0, 1);
18
- class Ze {
17
+ const ye = new f.Vector3(0, 0, 1), Ve = new f.Vector3(1, 0, 0), Ge = new f.Vector3(0, 1, 0), Ze = new f.Vector3(0, 0, 1);
18
+ class Xe {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
21
21
  warmupMs: 2e3,
@@ -338,7 +338,7 @@ class Ze {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- u.boneParent.matrixWorld.decompose(k, Z, G), k.copy(ge).applyQuaternion(Z).setY(0).normalize(), Z.premultiply(Se.setFromUnitVectors(ge, k).invert()).normalize(), u.qWorldInverseYaw = Z.clone().normalize(), this.data.push(u), this.dict[h] = u;
341
+ u.boneParent.matrixWorld.decompose(k, Y, X), k.copy(ye).applyQuaternion(Y).setY(0).normalize(), Y.premultiply(ke.setFromUnitVectors(ye, k).invert()).normalize(), u.qWorldInverseYaw = Y.clone().normalize(), this.data.push(u), this.dict[h] = u;
342
342
  try {
343
343
  this.setValue(h, "type", s.type), this.setValue(h, "stiffness", s.stiffness), this.setValue(h, "damping", s.damping), this.setValue(h, "external", s.external), this.setValue(h, "limits", s.limits), this.setValue(h, "excludes", s.excludes), this.setValue(h, "deltaLocal", s.deltaLocal), this.setValue(h, "deltaWorld", s.deltaWorld), this.setValue(h, "pivot", s.pivot), this.setValue(h, "helper", s.helper);
344
344
  } catch (l) {
@@ -369,9 +369,9 @@ class Ze {
369
369
  o.vBasis.y + A[1],
370
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, Z, G), k.copy(ge).applyQuaternion(Z).setY(0).normalize(), Z.premultiply(Se.setFromUnitVectors(ge, k).invert()).normalize(), o.boneParent.quaternion.multiply(Z.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), Z.setFromAxisAngle(Ge, -m), o.boneParent.quaternion.multiply(Z)), 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), Z.setFromAxisAngle(We, -m), o.boneParent.quaternion.multiply(Z)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), Z.setFromAxisAngle(Ve, -m), o.boneParent.quaternion.multiply(Z)), 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, Y, X), k.copy(ye).applyQuaternion(Y).setY(0).normalize(), Y.premultiply(ke.setFromUnitVectors(ye, k).invert()).normalize(), o.boneParent.quaternion.multiply(Y.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), Y.setFromAxisAngle(Ze, -m), o.boneParent.quaternion.multiply(Y)), 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), Y.setFromAxisAngle(Ve, -m), o.boneParent.quaternion.multiply(Y)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), Y.setFromAxisAngle(Ge, -m), o.boneParent.quaternion.multiply(Y)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (i = 0, s = o.excludes.length; i < s; i++)
374
- m = o.excludes[i], G.set(0, 0, 0), m.deltaLocal && (G.x += m.deltaLocal[0], G.y += m.deltaLocal[1], G.z += m.deltaLocal[2]), G.applyMatrix4(m.bone.matrixWorld), te.copy(o.boneParent.matrixWorld).invert(), G.applyMatrix4(te), k.copy(o.bone.position), !(k.distanceToSquared(G) >= m.radiusSq) && (J = k.length(), Q = G.length(), !(Q > m.radius + J) && (Q < Math.abs(m.radius - J) || (Q = (Q * Q + J * J - m.radiusSq) / (2 * Q), G.normalize(), pe.copy(G).multiplyScalar(Q), Q = Math.sqrt(J * J - Q * Q), k.subVectors(k, pe).projectOnPlane(G).normalize().multiplyScalar(Q), me.subVectors(o.vBasis, pe).projectOnPlane(G).normalize(), J = me.dot(k), J < 0 && (J = Math.sqrt(Q * Q - J * J), me.multiplyScalar(J), k.add(me)), k.add(pe).normalize(), G.copy(o.bone.position).normalize(), Z.setFromUnitVectors(G, k), o.boneParent.quaternion.premultiply(Z), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[i], X.set(0, 0, 0), m.deltaLocal && (X.x += m.deltaLocal[0], X.y += m.deltaLocal[1], X.z += m.deltaLocal[2]), X.applyMatrix4(m.bone.matrixWorld), te.copy(o.boneParent.matrixWorld).invert(), X.applyMatrix4(te), k.copy(o.bone.position), !(k.distanceToSquared(X) >= m.radiusSq) && (K = k.length(), q = X.length(), !(q > m.radius + K) && (q < Math.abs(m.radius - K) || (q = (q * q + K * K - m.radiusSq) / (2 * q), X.normalize(), ge.copy(X).multiplyScalar(q), q = Math.sqrt(K * K - q * q), k.subVectors(k, ge).projectOnPlane(X).normalize().multiplyScalar(q), pe.subVectors(o.vBasis, ge).projectOnPlane(X).normalize(), K = pe.dot(k), K < 0 && (K = Math.sqrt(q * q - K * K), pe.multiplyScalar(K), k.add(pe)), k.add(ge).normalize(), X.copy(o.bone.position).normalize(), Y.setFromUnitVectors(X, k), o.boneParent.quaternion.premultiply(Y), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -489,7 +489,7 @@ class Ze {
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 Xe {
492
+ class Ye {
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 Xe {
814
814
  return n * s;
815
815
  }
816
816
  }
817
- class Ye {
817
+ class je {
818
818
  /**
819
819
  * @constructor
820
820
  */
@@ -1396,11 +1396,11 @@ class Ye {
1396
1396
  return e;
1397
1397
  }
1398
1398
  }
1399
- const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1399
+ const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1400
1400
  __proto__: null,
1401
- LipsyncEn: Ye
1401
+ LipsyncEn: je
1402
1402
  }, Symbol.toStringTag, { value: "Module" }));
1403
- class Qe {
1403
+ class qe {
1404
1404
  /**
1405
1405
  * @constructor
1406
1406
  */
@@ -1754,11 +1754,11 @@ class Qe {
1754
1754
  return e;
1755
1755
  }
1756
1756
  }
1757
- const qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1757
+ const _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1758
1758
  __proto__: null,
1759
- LipsyncDe: Qe
1759
+ LipsyncDe: qe
1760
1760
  }, Symbol.toStringTag, { value: "Module" }));
1761
- class _e {
1761
+ class Ke {
1762
1762
  /**
1763
1763
  * @constructor
1764
1764
  */
@@ -2289,11 +2289,11 @@ class _e {
2289
2289
  return e;
2290
2290
  }
2291
2291
  }
2292
- const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2293
2293
  __proto__: null,
2294
- LipsyncFr: _e
2294
+ LipsyncFr: Ke
2295
2295
  }, Symbol.toStringTag, { value: "Module" }));
2296
- class Je {
2296
+ class $e {
2297
2297
  /**
2298
2298
  * @constructor
2299
2299
  */
@@ -2436,11 +2436,11 @@ class Je {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
- LipsyncFi: Je
2441
+ LipsyncFi: $e
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class et {
2443
+ class tt {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2620,24 +2620,24 @@ class et {
2620
2620
  return e;
2621
2621
  }
2622
2622
  }
2623
- const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
+ const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: et
2626
- }, Symbol.toStringTag, { value: "Module" })), it = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICB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ICAgICAgIHRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykgewogICAgICAgIGNvbnN0IHNhbXBsZXNUb0NvcHkgPSBNYXRoLm1pb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F0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), ke = {
2627
- en: je,
2628
- de: qe,
2629
- fr: Ke,
2630
- fi: $e,
2631
- lt: tt
2632
- }, N = new f.Quaternion(), M = new f.Euler(), ie = new f.Vector3(), ne = new f.Vector3(), we = new f.Box3();
2625
+ LipsyncLt: tt
2626
+ }, Symbol.toStringTag, { value: "Module" })), nt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU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gICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmx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zZWQ7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), we = {
2627
+ en: Qe,
2628
+ de: _e,
2629
+ fr: Je,
2630
+ fi: et,
2631
+ lt: it
2632
+ }, N = new f.Quaternion(), M = new f.Euler(), ie = new f.Vector3(), oe = new f.Vector3(), ze = 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 nt = new f.Vector3(1, 0, 0);
2637
+ const ot = new f.Vector3(1, 0, 0);
2638
2638
  new f.Vector3(0, 1, 0);
2639
2639
  new f.Vector3(0, 0, 1);
2640
- class He {
2640
+ class Te {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -2763,7 +2763,7 @@ class He {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Ue(), 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 We(), 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 He {
4062
4062
  this.opt.lightSpotDispersion
4063
4063
  ), this.setLighting(this.opt);
4064
4064
  const r = new f.PMREMGenerator(this.renderer);
4065
- r.compileEquirectangularShader(), this.scene.environment = r.fromScene(new Ne()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Be(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
+ r.compileEquirectangularShader(), this.scene.environment = r.fromScene(new Ue()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new De(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 He {
4080
4080
  Object.entries(s).forEach((r, h) => {
4081
4081
  const a = new f.Bone();
4082
4082
  a.name = r[0], r[1] ? this.ikMesh.getObjectByName(r[1]).add(a) : this.ikMesh.add(a), o.push(a);
4083
- }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new Ze(), 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 Xe(), 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 Xe(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 Ye(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 He {
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 i = new De();
4231
+ const i = new Oe();
4232
4232
  if (this.dracoEnabled) {
4233
- const a = new Oe();
4233
+ const a = new Ne();
4234
4234
  a.setDecoderPath(this.dracoDecoderPath), i.setDRACOLoader(a);
4235
4235
  }
4236
4236
  let n = await i.loadAsync(t.url, e);
@@ -4596,7 +4596,7 @@ class He {
4596
4596
  * @param {string} movement Movement type (idle, walking, prancing, gesturing, dancing, excited).
4597
4597
  */
4598
4598
  setBodyMovement(t) {
4599
- this.bodyMovement = t, this.avatar && (this.avatar.bodyMovement = t), console.log("Body movement set to:", t), t !== "idle" ? this.setShowFullAvatar(!0) : this.unlockAvatarPosition(), this.applyBodyMovementAnimation();
4599
+ this.bodyMovement = t, this.avatar && (this.avatar.bodyMovement = t), console.log("Body movement set to:", t), t === "idle" && this.unlockAvatarPosition(), this.applyBodyMovementAnimation();
4600
4600
  }
4601
4601
  /**
4602
4602
  * Apply body movement animation based on current movement type.
@@ -5180,7 +5180,7 @@ class He {
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) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 0) + (1 + r / 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) && h ? r > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = r) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (N.setFromAxisAngle(nt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(N)), we.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ie), ie.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(ne), ne.sub(this.armature.position), this.objectHips.position.y -= we.min.y / 2, this.objectHips.position.x -= (ie.x + ne.x) / 4, this.objectHips.position.z -= (ie.z + ne.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) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 0) + (1 + r / 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) && h ? r > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = r) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (N.setFromAxisAngle(ot, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(N)), ze.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ie), ie.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(oe), oe.sub(this.armature.position), this.objectHips.position.y -= ze.min.y / 2, this.objectHips.position.x -= (ie.x + oe.x) / 4, this.objectHips.position.z -= (ie.z + oe.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) {
@@ -5211,8 +5211,8 @@ class He {
5211
5211
  if (!this.lipsync.hasOwnProperty(t)) {
5212
5212
  const i = t.toLowerCase(), n = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5213
5213
  try {
5214
- const s = ke[i];
5215
- s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(ke));
5214
+ const s = we[i];
5215
+ s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(we));
5216
5216
  } catch (s) {
5217
5217
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5218
5218
  }
@@ -5253,8 +5253,8 @@ class He {
5253
5253
  for (let x = 0; x < y.length; x++) {
5254
5254
  const I = x === y.length - 1, T = y[x].match(r);
5255
5255
  let p = y[x].match(s);
5256
- const F = y[x].match(h), C = y[x].match(o);
5257
- if (p && !I && !F && y[x + 1].match(s) && (p = !1), i && (u += y[x]), T && (!n || n.every((R) => x < R[0] || x > R[1])) && (l += y[x]), (C || p || I) && (l.length && (l = this.lipsyncPreProcessText(l, a), l.length && d.push({
5256
+ const C = y[x].match(h), H = y[x].match(o);
5257
+ if (p && !I && !C && y[x + 1].match(s) && (p = !1), i && (u += y[x]), T && (!n || n.every((b) => x < b[0] || x > b[1])) && (l += y[x]), (H || p || I) && (l.length && (l = this.lipsyncPreProcessText(l, a), l.length && d.push({
5258
5258
  mark: c,
5259
5259
  word: l
5260
5260
  })), u.length && (g.push({
@@ -5265,16 +5265,16 @@ class He {
5265
5265
  subtitles: [u]
5266
5266
  }
5267
5267
  }), u = ""), l.length)) {
5268
- const R = this.lipsyncWordsToVisemes(l, a);
5269
- if (R && R.visemes && R.visemes.length) {
5270
- const O = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
5271
- for (let B = 0; B < R.visemes.length; B++)
5268
+ const b = this.lipsyncWordsToVisemes(l, a);
5269
+ if (b && b.visemes && b.visemes.length) {
5270
+ const U = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5271
+ for (let B = 0; B < b.visemes.length; B++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(R.times[B] - 0.6) / O, (R.times[B] + 0.5) / O, (R.times[B] + R.durations[B] + 0.5) / O],
5275
+ ts: [(b.times[B] - 0.6) / U, (b.times[B] + 0.5) / U, (b.times[B] + b.durations[B] + 0.5) / U],
5276
5276
  vs: {
5277
- ["viseme_" + R.visemes[B]]: [null, R.visemes[B] === "PP" || R.visemes[B] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + b.visemes[B]]: [null, b.visemes[B] === "PP" || b.visemes[B] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
@@ -5282,14 +5282,14 @@ class He {
5282
5282
  }
5283
5283
  if (p || I) {
5284
5284
  if (d.length || I && g.length) {
5285
- const R = {
5285
+ const b = {
5286
5286
  anim: g
5287
5287
  };
5288
- i && (R.onSubtitles = i), 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 = [], l = "", c = 0, g = [];
5288
+ i && (b.onSubtitles = i), d.length && !e.avatarMute && (b.text = d, e.avatarMood && (b.mood = e.avatarMood), e.ttsLang && (b.lang = e.ttsLang), e.ttsVoice && (b.voice = e.ttsVoice), e.ttsRate && (b.rate = e.ttsRate), e.ttsVoice && (b.pitch = e.ttsPitch), e.ttsVolume && (b.volume = e.ttsVolume)), this.speechQueue.push(b), d = [], l = "", c = 0, g = [];
5289
5289
  }
5290
- if (F) {
5291
- let R = this.animEmojis[y[x]];
5292
- R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
5290
+ if (C) {
5291
+ let b = this.animEmojis[y[x]];
5292
+ b && b.link && (b = this.animEmojis[b.link]), b && this.speechQueue.push({ emoji: b });
5293
5293
  }
5294
5294
  this.speechQueue.push({ break: 100 });
5295
5295
  }
@@ -5470,7 +5470,7 @@ class He {
5470
5470
  s.lang = o, s.rate = Math.max(0.1, Math.min(10, r)), s.pitch = Math.max(0, Math.min(2, h)), s.volume = Math.max(0, Math.min(1, a));
5471
5471
  const u = speechSynthesis.getVoices(), l = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5472
5472
  if (l && u.length > 0) {
5473
- const p = u.find((F) => F.name.includes(l) || F.lang === o);
5473
+ const p = u.find((C) => C.name.includes(l) || C.lang === o);
5474
5474
  p && (s.voice = p);
5475
5475
  }
5476
5476
  const c = n.length * 100 / s.rate, d = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (c / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", y = this.lipsyncPreProcessText(n, g), x = this.lipsyncWordsToVisemes(y, g);
@@ -5485,13 +5485,13 @@ class He {
5485
5485
  const I = [];
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
- for (let F = 0; F < x.visemes.length; F++) {
5489
- const C = x.visemes[F], R = x.times[F] / p, O = x.durations[F] / p, B = R * c, $ = O * c;
5488
+ for (let C = 0; C < x.visemes.length; C++) {
5489
+ const H = x.visemes[C], b = x.times[C] / p, U = x.durations[C] / p, B = b * c, j = U * c;
5490
5490
  I.push({
5491
5491
  template: { name: "viseme" },
5492
- ts: [B - Math.min(60, 2 * $ / 3), B + Math.min(25, $ / 2), B + $ + Math.min(60, $ / 2)],
5492
+ ts: [B - Math.min(60, 2 * j / 3), B + Math.min(25, j / 2), B + j + Math.min(60, j / 2)],
5493
5493
  vs: {
5494
- ["viseme_" + C]: [null, C === "PP" || C === "FF" ? 0.9 : 0.6, 0]
5494
+ ["viseme_" + H]: [null, H === "PP" || H === "FF" ? 0.9 : 0.6, 0]
5495
5495
  }
5496
5496
  });
5497
5497
  }
@@ -5895,7 +5895,7 @@ class He {
5895
5895
  }
5896
5896
  if (!this.workletLoaded)
5897
5897
  try {
5898
- const r = this.audioCtx.audioWorklet.addModule(it.href), h = new Promise(
5898
+ const r = this.audioCtx.audioWorklet.addModule(nt.href), h = new Promise(
5899
5899
  (a, u) => setTimeout(() => u(new Error("Worklet loading timed out")), 5e3)
5900
5900
  );
5901
5901
  await Promise.race([r, h]), this.workletLoaded = !0;
@@ -6133,7 +6133,7 @@ class He {
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), ie.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), ne.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ie, ne).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), ie.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), oe.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ie, oe).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,7 +6146,7 @@ class He {
6146
6146
  this.lookAt(null, null, t);
6147
6147
  return;
6148
6148
  }
6149
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ie.setFromMatrixPosition(this.objectLeftEye.matrixWorld), ne.setFromMatrixPosition(this.objectRightEye.matrixWorld), ie.add(ne).divideScalar(2), N.copy(this.armature.quaternion), N.multiply(this.poseTarget.props["Hips.quaternion"]), N.multiply(this.poseTarget.props["Spine.quaternion"]), N.multiply(this.poseTarget.props["Spine1.quaternion"]), N.multiply(this.poseTarget.props["Spine2.quaternion"]), N.multiply(this.poseTarget.props["Neck.quaternion"]), N.multiply(this.poseTarget.props["Head.quaternion"]);
6149
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ie.setFromMatrixPosition(this.objectLeftEye.matrixWorld), oe.setFromMatrixPosition(this.objectRightEye.matrixWorld), ie.add(oe).divideScalar(2), N.copy(this.armature.quaternion), N.multiply(this.poseTarget.props["Hips.quaternion"]), N.multiply(this.poseTarget.props["Spine.quaternion"]), N.multiply(this.poseTarget.props["Spine1.quaternion"]), N.multiply(this.poseTarget.props["Spine2.quaternion"]), N.multiply(this.poseTarget.props["Neck.quaternion"]), N.multiply(this.poseTarget.props["Head.quaternion"]);
6150
6150
  const i = new f.Vector3().subVectors(e, ie).normalize(), n = Math.atan2(i.x, i.z), s = Math.asin(-i.y);
6151
6151
  M.set(s, n, 0, "YXZ");
6152
6152
  const r = new f.Quaternion().setFromEuler(M), h = new f.Quaternion().copy(r).multiply(N.clone().invert());
@@ -6191,9 +6191,9 @@ class He {
6191
6191
  x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
6192
6192
  let T = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (i) {
6194
- let F = this.animQueue.findIndex((R) => R.template.name === "lookat");
6195
- F !== -1 && this.animQueue.splice(F, 1);
6196
- const C = {
6194
+ let C = this.animQueue.findIndex((b) => b.template.name === "lookat");
6195
+ C !== -1 && this.animQueue.splice(C, 1);
6196
+ const H = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, i],
6199
6199
  vs: {
@@ -6208,7 +6208,7 @@ class He {
6208
6208
  headMove: [0]
6209
6209
  }
6210
6210
  };
6211
- this.animQueue.push(this.animFactory(C));
6211
+ this.animQueue.push(this.animFactory(H));
6212
6212
  }
6213
6213
  }
6214
6214
  /**
@@ -6403,7 +6403,7 @@ class He {
6403
6403
  } catch (c) {
6404
6404
  console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
6405
6405
  }
6406
- const u = new Le();
6406
+ const u = new Se();
6407
6407
  let l;
6408
6408
  try {
6409
6409
  l = await u.loadAsync(t, e);
@@ -6480,7 +6480,7 @@ class He {
6480
6480
  let r = this.animQueue.find((h) => h.template.name === "pose");
6481
6481
  r && (r.ts[0] = this.animClock + i * 1e3 + 2e3), this.setPoseFromTemplate(o);
6482
6482
  } else {
6483
- let h = await new Le().loadAsync(t, e);
6483
+ let h = await new Se().loadAsync(t, e);
6484
6484
  if (h && h.animations && h.animations[n]) {
6485
6485
  let a = h.animations[n];
6486
6486
  const u = {};
@@ -6578,11 +6578,11 @@ class He {
6578
6578
  if (e)
6579
6579
  for (let I = 0; I < x; I++) {
6580
6580
  let T = !1;
6581
- for (let p = 0, F = y.length; p < F; p++) {
6582
- const C = y[p].bone;
6583
- C.matrixWorld.decompose(h, a, u), a.invert(), o.setFromMatrixPosition(g.matrixWorld), r.subVectors(o, h), r.applyQuaternion(a), r.normalize(), s.subVectors(e, h), s.applyQuaternion(a), s.normalize();
6584
- let R = s.dot(r);
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), l.crossVectors(r, s), l.normalize(), N.setFromAxisAngle(l, R), C.quaternion.multiply(N), C.rotation.setFromVector3(c.setFromEuler(C.rotation).clamp(new f.Vector3(
6581
+ for (let p = 0, C = y.length; p < C; p++) {
6582
+ const H = y[p].bone;
6583
+ H.matrixWorld.decompose(h, a, u), a.invert(), o.setFromMatrixPosition(g.matrixWorld), r.subVectors(o, h), r.applyQuaternion(a), r.normalize(), s.subVectors(e, h), s.applyQuaternion(a), s.normalize();
6584
+ let b = s.dot(r);
6585
+ b > 1 ? b = 1 : b < -1 && (b = -1), b = Math.acos(b), !(b < 1e-5) && (y[p].minAngle !== void 0 && b < y[p].minAngle && (b = y[p].minAngle), y[p].maxAngle !== void 0 && b > y[p].maxAngle && (b = y[p].maxAngle), l.crossVectors(r, s), l.normalize(), N.setFromAxisAngle(l, b), H.quaternion.multiply(N), H.rotation.setFromVector3(c.setFromEuler(H.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,7 +6590,7 @@ class He {
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
- ))), C.updateMatrixWorld(!0), T = !0);
6593
+ ))), H.updateMatrixWorld(!0), T = !0);
6594
6594
  }
6595
6595
  if (!T) break;
6596
6596
  }
@@ -6605,7 +6605,7 @@ class He {
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 ae = {
6608
+ const le = {
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",
@@ -6625,7 +6625,7 @@ const ae = {
6625
6625
  josh: "VR6AewLTigWG4xSOukaG"
6626
6626
  // Male, American
6627
6627
  }
6628
- }, ze = {
6628
+ }, Ce = {
6629
6629
  defaultVoice: "aura-2-thalia-en",
6630
6630
  // Thalia (Female, English)
6631
6631
  voices: {
@@ -6645,26 +6645,26 @@ const ae = {
6645
6645
  // Male, English - Powerful
6646
6646
  }
6647
6647
  };
6648
- function ve() {
6648
+ function Ie() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
- endpoint: ae.endpoint,
6652
- apiKey: ae.apiKey,
6653
- defaultVoice: ae.defaultVoice,
6654
- voices: ae.voices
6651
+ endpoint: le.endpoint,
6652
+ apiKey: le.apiKey,
6653
+ defaultVoice: le.defaultVoice,
6654
+ voices: le.voices
6655
6655
  };
6656
6656
  }
6657
- function pt() {
6658
- const D = ve(), t = [];
6659
- return Object.entries(D.voices).forEach(([e, i]) => {
6657
+ function gt() {
6658
+ const O = Ie(), t = [];
6659
+ return Object.entries(O.voices).forEach(([e, i]) => {
6660
6660
  t.push({
6661
6661
  value: i,
6662
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${D.service})`
6662
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${O.service})`
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
- const Te = be(({
6667
- avatarUrl: D = "/avatars/brunette.glb",
6666
+ const Me = Re(({
6667
+ avatarUrl: O = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
6670
6670
  ttsLang: i = "en",
@@ -6685,277 +6685,281 @@ const Te = be(({
6685
6685
  style: y = {},
6686
6686
  animations: x = {}
6687
6687
  }, I) => {
6688
- const T = X(null), p = X(null), [F, C] = re(!0), [R, O] = re(null), [B, $] = re(!1), Y = ve(), S = n || Y.service;
6689
- let P;
6690
- S === "browser" ? P = {
6688
+ const T = G(null), p = G(null), C = G(a), [H, b] = he(!0), [U, B] = he(null), [j, ae] = he(!1);
6689
+ ue(() => {
6690
+ C.current = a;
6691
+ }, [a]);
6692
+ const L = Ie(), P = n || L.service;
6693
+ let D;
6694
+ P === "browser" ? D = {
6691
6695
  service: "browser",
6692
6696
  endpoint: "",
6693
6697
  apiKey: null,
6694
6698
  defaultVoice: "Google US English"
6695
- } : S === "elevenlabs" ? P = {
6699
+ } : P === "elevenlabs" ? D = {
6696
6700
  service: "elevenlabs",
6697
6701
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6698
- apiKey: o || Y.apiKey,
6699
- defaultVoice: s || Y.defaultVoice || ae.defaultVoice,
6700
- voices: Y.voices || ae.voices
6701
- } : S === "deepgram" ? P = {
6702
+ apiKey: o || L.apiKey,
6703
+ defaultVoice: s || L.defaultVoice || le.defaultVoice,
6704
+ voices: L.voices || le.voices
6705
+ } : P === "deepgram" ? D = {
6702
6706
  service: "deepgram",
6703
6707
  endpoint: "https://api.deepgram.com/v1/speak",
6704
- apiKey: o || Y.apiKey,
6705
- defaultVoice: s || Y.defaultVoice || ze.defaultVoice,
6706
- voices: Y.voices || ze.voices
6707
- } : P = {
6708
- ...Y,
6708
+ apiKey: o || L.apiKey,
6709
+ defaultVoice: s || L.defaultVoice || Ce.defaultVoice,
6710
+ voices: L.voices || Ce.voices
6711
+ } : D = {
6712
+ ...L,
6709
6713
  // Override API key if provided via props
6710
- apiKey: o !== null ? o : Y.apiKey
6714
+ apiKey: o !== null ? o : L.apiKey
6711
6715
  };
6712
6716
  const W = {
6713
- url: D,
6717
+ url: O,
6714
6718
  body: t,
6715
6719
  avatarMood: e,
6716
- ttsLang: S === "browser" ? "en-US" : i,
6717
- ttsVoice: s || P.defaultVoice,
6720
+ ttsLang: P === "browser" ? "en-US" : i,
6721
+ ttsVoice: s || D.defaultVoice,
6718
6722
  lipsyncLang: "en",
6719
6723
  showFullAvatar: a,
6720
6724
  bodyMovement: r,
6721
6725
  movementIntensity: h
6722
- }, V = {
6723
- ttsEndpoint: P.endpoint,
6724
- ttsApikey: P.apiKey,
6725
- ttsService: S,
6726
+ }, J = {
6727
+ ttsEndpoint: D.endpoint,
6728
+ ttsApikey: D.apiKey,
6729
+ ttsService: P,
6726
6730
  lipsyncModules: ["en"],
6727
6731
  cameraView: u
6728
- }, q = E(async () => {
6732
+ }, $ = E(async () => {
6729
6733
  if (!(!T.current || p.current))
6730
6734
  try {
6731
- if (C(!0), O(null), p.current = new He(T.current, V), 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(W, (U) => {
6732
- if (U.lengthComputable) {
6733
- const w = Math.min(100, Math.round(U.loaded / U.total * 100));
6735
+ if (b(!0), B(null), p.current = new Te(T.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(W, (V) => {
6736
+ if (V.lengthComputable) {
6737
+ const w = Math.min(100, Math.round(V.loaded / V.total * 100));
6734
6738
  c(w);
6735
6739
  }
6736
- }), await new Promise((U) => {
6740
+ }), await new Promise((V) => {
6737
6741
  const w = () => {
6738
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? U() : setTimeout(w, 100);
6742
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? V() : setTimeout(w, 100);
6739
6743
  };
6740
6744
  w();
6741
6745
  }), p.current && p.current.setShowFullAvatar)
6742
6746
  try {
6743
6747
  p.current.setShowFullAvatar(a);
6744
- } catch (U) {
6745
- console.warn("Error setting full body mode on initialization:", U);
6748
+ } catch (V) {
6749
+ console.warn("Error setting full body mode on initialization:", V);
6746
6750
  }
6747
- 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()), C(!1), $(!0), l(p.current);
6748
- const H = () => {
6751
+ 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()), b(!1), ae(!0), l(p.current);
6752
+ const F = () => {
6749
6753
  document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6750
6754
  };
6751
- return document.addEventListener("visibilitychange", H), () => {
6752
- document.removeEventListener("visibilitychange", H);
6755
+ return document.addEventListener("visibilitychange", F), () => {
6756
+ document.removeEventListener("visibilitychange", F);
6753
6757
  };
6754
- } catch (L) {
6755
- console.error("Error initializing TalkingHead:", L), O(L.message || "Failed to initialize avatar"), C(!1), d(L);
6758
+ } catch (S) {
6759
+ console.error("Error initializing TalkingHead:", S), B(S.message || "Failed to initialize avatar"), b(!1), d(S);
6756
6760
  }
6757
- }, [D, t, e, i, n, s, o, a, r, h, u]);
6758
- he(() => (q(), () => {
6761
+ }, [O, t, e, i, n, s, o, a, r, h, u]);
6762
+ ue(() => ($(), () => {
6759
6763
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6760
- }), [q]), he(() => {
6764
+ }), [$]), ue(() => {
6761
6765
  if (!T.current || !p.current) return;
6762
- const L = new ResizeObserver((U) => {
6763
- for (const w of U)
6766
+ const S = new ResizeObserver((V) => {
6767
+ for (const w of V)
6764
6768
  p.current && p.current.onResize && p.current.onResize();
6765
6769
  });
6766
- L.observe(T.current);
6767
- const H = () => {
6770
+ S.observe(T.current);
6771
+ const F = () => {
6768
6772
  p.current && p.current.onResize && p.current.onResize();
6769
6773
  };
6770
- return window.addEventListener("resize", H), () => {
6771
- L.disconnect(), window.removeEventListener("resize", H);
6774
+ return window.addEventListener("resize", F), () => {
6775
+ S.disconnect(), window.removeEventListener("resize", F);
6772
6776
  };
6773
- }, [B]);
6774
- const _ = E(async () => {
6777
+ }, [j]);
6778
+ const ne = E(async () => {
6775
6779
  if (p.current && p.current.audioCtx)
6776
6780
  try {
6777
6781
  (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6778
- } catch (L) {
6779
- console.warn("Failed to resume audio context:", L);
6782
+ } catch (S) {
6783
+ console.warn("Failed to resume audio context:", S);
6780
6784
  }
6781
- }, []), le = E(async (L, H = {}) => {
6782
- if (p.current && B)
6785
+ }, []), fe = E(async (S, F = {}) => {
6786
+ if (p.current && j)
6783
6787
  try {
6784
- await _();
6785
- const U = {
6786
- ...H,
6787
- lipsyncLang: H.lipsyncLang || W.lipsyncLang || "en"
6788
+ await ne();
6789
+ const V = {
6790
+ ...F,
6791
+ lipsyncLang: F.lipsyncLang || W.lipsyncLang || "en"
6788
6792
  };
6789
- if (H.onSpeechEnd && p.current) {
6793
+ if (F.onSpeechEnd && p.current) {
6790
6794
  const w = p.current;
6791
- let j = null, se = 0, ue = !1;
6792
- const Ee = 1200, Fe = 1e4;
6793
- let Ie = 0;
6794
- const fe = setInterval(() => {
6795
- Ie++, w && w.isSpeaking && (w.audioPlaylist && w.audioPlaylist.length > 0 || w.isAudioPlaying === !0) && (ue = !0, clearInterval(fe), j = setInterval(Ae, 50));
6796
- const de = !w.speechQueue || w.speechQueue.length === 0;
6797
- if (w && !w.isSpeaking && de && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1)) {
6798
- clearInterval(fe);
6795
+ let Q = null, re = 0, de = !1;
6796
+ const Fe = 1200, Pe = 1e4;
6797
+ let Ae = 0;
6798
+ const xe = setInterval(() => {
6799
+ Ae++, w && w.isSpeaking && (w.audioPlaylist && w.audioPlaylist.length > 0 || w.isAudioPlaying === !0) && (de = !0, clearInterval(xe), Q = setInterval(Le, 50));
6800
+ const ce = !w.speechQueue || w.speechQueue.length === 0;
6801
+ if (w && !w.isSpeaking && ce && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1)) {
6802
+ clearInterval(xe);
6799
6803
  try {
6800
- H.onSpeechEnd();
6801
- } catch (ce) {
6802
- console.error("Error in onSpeechEnd callback:", ce);
6804
+ F.onSpeechEnd();
6805
+ } catch (me) {
6806
+ console.error("Error in onSpeechEnd callback:", me);
6803
6807
  }
6804
6808
  return;
6805
6809
  }
6806
- if (Ie * 50 > Fe) {
6807
- if (clearInterval(fe), w && w.isSpeaking)
6808
- ue = !0, j = setInterval(Ae, 50);
6809
- else if (w && !w.isSpeaking && de && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1))
6810
+ if (Ae * 50 > Pe) {
6811
+ if (clearInterval(xe), w && w.isSpeaking)
6812
+ de = !0, Q = setInterval(Le, 50);
6813
+ else if (w && !w.isSpeaking && ce && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1))
6810
6814
  try {
6811
- H.onSpeechEnd();
6812
- } catch (ce) {
6813
- console.error("Error in onSpeechEnd callback:", ce);
6815
+ F.onSpeechEnd();
6816
+ } catch (me) {
6817
+ console.error("Error in onSpeechEnd callback:", me);
6814
6818
  }
6815
6819
  }
6816
- }, 50), Ae = () => {
6817
- if (se++, se > Ee) {
6818
- j && (clearInterval(j), j = null);
6820
+ }, 50), Le = () => {
6821
+ if (re++, re > Fe) {
6822
+ Q && (clearInterval(Q), Q = null);
6819
6823
  try {
6820
- H.onSpeechEnd();
6821
- } catch (xe) {
6822
- console.error("Error in onSpeechEnd callback:", xe);
6824
+ F.onSpeechEnd();
6825
+ } catch (be) {
6826
+ console.error("Error in onSpeechEnd callback:", be);
6823
6827
  }
6824
6828
  return;
6825
6829
  }
6826
- if (!ue)
6830
+ if (!de)
6827
6831
  return;
6828
- const de = !w.speechQueue || w.speechQueue.length === 0;
6829
- w && (!w.isSpeaking || w.isSpeaking === !1) && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1) && de && (j && (clearInterval(j), j = null), setTimeout(() => {
6832
+ const ce = !w.speechQueue || w.speechQueue.length === 0;
6833
+ w && (!w.isSpeaking || w.isSpeaking === !1) && (!w.audioPlaylist || w.audioPlaylist.length === 0) && (!w.isAudioPlaying || w.isAudioPlaying === !1) && ce && (Q && (clearInterval(Q), Q = null), setTimeout(() => {
6830
6834
  try {
6831
- H.onSpeechEnd();
6832
- } catch (xe) {
6833
- console.error("Error in onSpeechEnd callback:", xe);
6835
+ F.onSpeechEnd();
6836
+ } catch (be) {
6837
+ console.error("Error in onSpeechEnd callback:", be);
6834
6838
  }
6835
6839
  }, 50));
6836
6840
  };
6837
6841
  }
6838
- 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 () => {
6839
- await _(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, U));
6842
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(S, V)) : setTimeout(async () => {
6843
+ await ne(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(S, V));
6840
6844
  }, 100);
6841
- } catch (U) {
6842
- console.error("Error speaking text:", U), O(U.message || "Failed to speak text");
6845
+ } catch (V) {
6846
+ console.error("Error speaking text:", V), B(V.message || "Failed to speak text");
6843
6847
  }
6844
- }, [B, _, W.lipsyncLang]), ye = E(() => {
6848
+ }, [j, ne, W.lipsyncLang]), _ = E(() => {
6845
6849
  p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1));
6846
- }, []), K = E((L) => {
6847
- p.current && p.current.setMood(L);
6848
- }, []), b = E((L) => {
6849
- p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6850
- }, []), v = E((L, H = !1) => {
6850
+ }, []), R = E((S) => {
6851
+ p.current && p.current.setMood(S);
6852
+ }, []), v = E((S) => {
6853
+ p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(S);
6854
+ }, []), z = E((S, F = !1) => {
6851
6855
  if (p.current && p.current.playAnimation) {
6852
- if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
6856
+ if (x && x[S] && (S = x[S]), p.current.setShowFullAvatar)
6853
6857
  try {
6854
- p.current.setShowFullAvatar(!0);
6858
+ p.current.setShowFullAvatar(C.current);
6855
6859
  } catch (w) {
6856
6860
  console.warn("Error setting full body mode:", w);
6857
6861
  }
6858
- if (L.includes("."))
6862
+ if (S.includes("."))
6859
6863
  try {
6860
- p.current.playAnimation(L, null, 10, 0, 0.01, H);
6864
+ p.current.playAnimation(S, null, 10, 0, 0.01, F);
6861
6865
  } catch (w) {
6862
- console.warn(`Failed to play ${L}:`, w);
6866
+ console.warn(`Failed to play ${S}:`, w);
6863
6867
  try {
6864
6868
  p.current.setBodyMovement("idle");
6865
- } catch (j) {
6866
- console.warn("Fallback animation also failed:", j);
6869
+ } catch (Q) {
6870
+ console.warn("Fallback animation also failed:", Q);
6867
6871
  }
6868
6872
  }
6869
6873
  else {
6870
6874
  const w = [".fbx", ".glb", ".gltf"];
6871
- let j = !1;
6872
- for (const se of w)
6875
+ let Q = !1;
6876
+ for (const re of w)
6873
6877
  try {
6874
- p.current.playAnimation(L + se, null, 10, 0, 0.01, H), j = !0;
6878
+ p.current.playAnimation(S + re, null, 10, 0, 0.01, F), Q = !0;
6875
6879
  break;
6876
6880
  } catch {
6877
6881
  }
6878
- if (!j) {
6879
- console.warn("Animation not found:", L);
6882
+ if (!Q) {
6883
+ console.warn("Animation not found:", S);
6880
6884
  try {
6881
6885
  p.current.setBodyMovement("idle");
6882
- } catch (se) {
6883
- console.warn("Fallback animation also failed:", se);
6886
+ } catch (re) {
6887
+ console.warn("Fallback animation also failed:", re);
6884
6888
  }
6885
6889
  }
6886
6890
  }
6887
6891
  }
6888
- }, [x]), z = E(() => {
6892
+ }, [x]), Z = E(() => {
6889
6893
  p.current && p.current.onResize && p.current.onResize();
6890
6894
  }, []);
6891
- return Re(I, () => ({
6892
- speakText: le,
6893
- stopSpeaking: ye,
6894
- resumeAudioContext: _,
6895
- setMood: K,
6896
- setTimingAdjustment: b,
6897
- playAnimation: v,
6898
- isReady: B,
6895
+ return ve(I, () => ({
6896
+ speakText: fe,
6897
+ stopSpeaking: _,
6898
+ resumeAudioContext: ne,
6899
+ setMood: R,
6900
+ setTimingAdjustment: v,
6901
+ playAnimation: z,
6902
+ isReady: j,
6899
6903
  talkingHead: p.current,
6900
- handleResize: z,
6901
- setBodyMovement: (L) => {
6904
+ handleResize: Z,
6905
+ setBodyMovement: (S) => {
6902
6906
  if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
6903
6907
  try {
6904
- p.current.setShowFullAvatar(!0), p.current.setBodyMovement(L);
6905
- } catch (H) {
6906
- console.warn("Error setting body movement:", H);
6908
+ p.current.setShowFullAvatar(C.current), p.current.setBodyMovement(S);
6909
+ } catch (F) {
6910
+ console.warn("Error setting body movement:", F);
6907
6911
  }
6908
6912
  },
6909
- setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
6913
+ setMovementIntensity: (S) => p.current?.setMovementIntensity(S),
6910
6914
  playRandomDance: () => {
6911
6915
  if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
6912
6916
  try {
6913
- p.current.setShowFullAvatar(!0), p.current.playRandomDance();
6914
- } catch (L) {
6915
- console.warn("Error playing random dance:", L);
6917
+ p.current.setShowFullAvatar(C.current), p.current.playRandomDance();
6918
+ } catch (S) {
6919
+ console.warn("Error playing random dance:", S);
6916
6920
  }
6917
6921
  },
6918
- playReaction: (L) => {
6922
+ playReaction: (S) => {
6919
6923
  if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
6920
6924
  try {
6921
- p.current.setShowFullAvatar(!0), p.current.playReaction(L);
6922
- } catch (H) {
6923
- console.warn("Error playing reaction:", H);
6925
+ p.current.setShowFullAvatar(C.current), p.current.playReaction(S);
6926
+ } catch (F) {
6927
+ console.warn("Error playing reaction:", F);
6924
6928
  }
6925
6929
  },
6926
6930
  playCelebration: () => {
6927
6931
  if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
6928
6932
  try {
6929
- p.current.setShowFullAvatar(!0), p.current.playCelebration();
6930
- } catch (L) {
6931
- console.warn("Error playing celebration:", L);
6933
+ p.current.setShowFullAvatar(C.current), p.current.playCelebration();
6934
+ } catch (S) {
6935
+ console.warn("Error playing celebration:", S);
6932
6936
  }
6933
6937
  },
6934
- setShowFullAvatar: (L) => {
6938
+ setShowFullAvatar: (S) => {
6935
6939
  if (p.current && p.current.setShowFullAvatar)
6936
6940
  try {
6937
- p.current.setShowFullAvatar(L);
6938
- } catch (H) {
6939
- console.warn("Error setting showFullAvatar:", H);
6941
+ C.current = S, p.current.setShowFullAvatar(S);
6942
+ } catch (F) {
6943
+ console.warn("Error setting showFullAvatar:", F);
6940
6944
  }
6941
6945
  },
6942
6946
  lockAvatarPosition: () => {
6943
6947
  if (p.current && p.current.lockAvatarPosition)
6944
6948
  try {
6945
6949
  p.current.lockAvatarPosition();
6946
- } catch (L) {
6947
- console.warn("Error locking avatar position:", L);
6950
+ } catch (S) {
6951
+ console.warn("Error locking avatar position:", S);
6948
6952
  }
6949
6953
  },
6950
6954
  unlockAvatarPosition: () => {
6951
6955
  if (p.current && p.current.unlockAvatarPosition)
6952
6956
  try {
6953
6957
  p.current.unlockAvatarPosition();
6954
- } catch (L) {
6955
- console.warn("Error unlocking avatar position:", L);
6958
+ } catch (S) {
6959
+ console.warn("Error unlocking avatar position:", S);
6956
6960
  }
6957
6961
  }
6958
- })), /* @__PURE__ */ Ce(
6962
+ })), /* @__PURE__ */ He(
6959
6963
  "div",
6960
6964
  {
6961
6965
  className: `talking-head-avatar ${g}`,
@@ -6966,7 +6970,7 @@ const Te = be(({
6966
6970
  ...y
6967
6971
  },
6968
6972
  children: [
6969
- /* @__PURE__ */ oe(
6973
+ /* @__PURE__ */ se(
6970
6974
  "div",
6971
6975
  {
6972
6976
  ref: T,
@@ -6978,7 +6982,7 @@ const Te = be(({
6978
6982
  }
6979
6983
  }
6980
6984
  ),
6981
- F && /* @__PURE__ */ oe("div", { className: "loading-overlay", style: {
6985
+ H && /* @__PURE__ */ se("div", { className: "loading-overlay", style: {
6982
6986
  position: "absolute",
6983
6987
  top: "50%",
6984
6988
  left: "50%",
@@ -6987,7 +6991,7 @@ const Te = be(({
6987
6991
  fontSize: "18px",
6988
6992
  zIndex: 10
6989
6993
  }, children: "Loading avatar..." }),
6990
- R && /* @__PURE__ */ oe("div", { className: "error-overlay", style: {
6994
+ U && /* @__PURE__ */ se("div", { className: "error-overlay", style: {
6991
6995
  position: "absolute",
6992
6996
  top: "50%",
6993
6997
  left: "50%",
@@ -6998,14 +7002,14 @@ const Te = be(({
6998
7002
  zIndex: 10,
6999
7003
  padding: "20px",
7000
7004
  borderRadius: "8px"
7001
- }, children: R })
7005
+ }, children: U })
7002
7006
  ]
7003
7007
  }
7004
7008
  );
7005
7009
  });
7006
- Te.displayName = "TalkingHeadAvatar";
7007
- const ot = be(({
7008
- text: D = "Hello! I'm a talking avatar. How are you today?",
7010
+ Me.displayName = "TalkingHeadAvatar";
7011
+ const st = Re(({
7012
+ text: O = "Hello! I'm a talking avatar. How are you today?",
7009
7013
  onLoading: t = () => {
7010
7014
  },
7011
7015
  onError: e = () => {
@@ -7016,7 +7020,7 @@ const ot = be(({
7016
7020
  style: s = {},
7017
7021
  avatarConfig: o = {}
7018
7022
  }, r) => {
7019
- const h = X(null), a = X(null), [u, l] = re(!0), [c, d] = re(null), [g, y] = re(!1), x = ve(), I = o.ttsService || x.service, T = I === "browser" ? {
7023
+ const h = G(null), a = G(null), [u, l] = he(!0), [c, d] = he(null), [g, y] = he(!1), x = Ie(), I = o.ttsService || x.service, T = I === "browser" ? {
7020
7024
  endpoint: "",
7021
7025
  apiKey: null,
7022
7026
  defaultVoice: "Google US English"
@@ -7040,36 +7044,36 @@ const ot = be(({
7040
7044
  bodyMovement: "idle",
7041
7045
  movementIntensity: 0.5,
7042
7046
  ...o
7043
- }, F = {
7047
+ }, C = {
7044
7048
  ttsEndpoint: T.endpoint,
7045
7049
  ttsApikey: T.apiKey,
7046
7050
  ttsService: I,
7047
7051
  lipsyncModules: ["en"],
7048
7052
  cameraView: "upper"
7049
- }, C = E(async () => {
7053
+ }, H = E(async () => {
7050
7054
  if (!(!h.current || a.current))
7051
7055
  try {
7052
- if (l(!0), d(null), a.current = new He(h.current, F), await a.current.showAvatar(p, (W) => {
7053
- if (W.lengthComputable) {
7054
- const V = Math.min(100, Math.round(W.loaded / W.total * 100));
7055
- t(V);
7056
+ if (l(!0), d(null), a.current = new Te(h.current, C), await a.current.showAvatar(p, (D) => {
7057
+ if (D.lengthComputable) {
7058
+ const W = Math.min(100, Math.round(D.loaded / D.total * 100));
7059
+ t(W);
7056
7060
  }
7057
7061
  }), a.current.morphs && a.current.morphs.length > 0) {
7058
- const W = a.current.morphs[0].morphTargetDictionary;
7059
- console.log("Available morph targets:", Object.keys(W));
7060
- const V = Object.keys(W).filter((q) => q.startsWith("viseme_"));
7061
- console.log("Viseme morph targets found:", V), V.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"));
7062
+ const D = a.current.morphs[0].morphTargetDictionary;
7063
+ console.log("Available morph targets:", Object.keys(D));
7064
+ const W = Object.keys(D).filter((J) => J.startsWith("viseme_"));
7065
+ console.log("Viseme morph targets found:", W), W.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"));
7062
7066
  }
7063
- if (await new Promise((W) => {
7064
- const V = () => {
7065
- a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), W()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(V, 100));
7067
+ if (await new Promise((D) => {
7068
+ const W = () => {
7069
+ a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), D()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(W, 100));
7066
7070
  };
7067
- V();
7071
+ W();
7068
7072
  }), a.current && a.current.setShowFullAvatar)
7069
7073
  try {
7070
7074
  a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7071
- } catch (W) {
7072
- console.warn("Error setting full body mode on initialization:", W);
7075
+ } catch (D) {
7076
+ console.warn("Error setting full body mode on initialization:", D);
7073
7077
  }
7074
7078
  l(!1), y(!0), i(a.current);
7075
7079
  const P = () => {
@@ -7078,100 +7082,100 @@ const ot = be(({
7078
7082
  return document.addEventListener("visibilitychange", P), () => {
7079
7083
  document.removeEventListener("visibilitychange", P);
7080
7084
  };
7081
- } catch (S) {
7082
- console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), l(!1), e(S);
7085
+ } catch (L) {
7086
+ console.error("Error initializing TalkingHead:", L), d(L.message || "Failed to initialize avatar"), l(!1), e(L);
7083
7087
  }
7084
7088
  }, []);
7085
- he(() => (C(), () => {
7089
+ ue(() => (H(), () => {
7086
7090
  a.current && (a.current.stop(), a.current.dispose(), a.current = null);
7087
- }), [C]);
7088
- const R = E((S) => {
7091
+ }), [H]);
7092
+ const b = E((L) => {
7089
7093
  if (a.current && g)
7090
7094
  try {
7091
- 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(() => {
7092
- 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");
7095
+ console.log("Speaking text:", L), 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(L)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7096
+ 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(L)) : console.error("Lip-sync still not ready after waiting");
7093
7097
  }, 500));
7094
7098
  } catch (P) {
7095
7099
  console.error("Error speaking text:", P), d(P.message || "Failed to speak text");
7096
7100
  }
7097
7101
  else
7098
7102
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
7099
- }, [g, p]), O = E(() => {
7103
+ }, [g, p]), U = E(() => {
7100
7104
  a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7101
- }, []), B = E((S) => {
7102
- a.current && a.current.setMood(S);
7103
- }, []), $ = E((S) => {
7104
- a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7105
- }, []), Y = E((S, P = !1) => {
7105
+ }, []), B = E((L) => {
7106
+ a.current && a.current.setMood(L);
7107
+ }, []), j = E((L) => {
7108
+ a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(L), console.log("Timing adjustment set to:", L));
7109
+ }, []), ae = E((L, P = !1) => {
7106
7110
  if (a.current && a.current.playAnimation) {
7107
7111
  if (a.current.setShowFullAvatar)
7108
7112
  try {
7109
7113
  a.current.setShowFullAvatar(!0);
7110
- } catch (V) {
7111
- console.warn("Error setting full body mode:", V);
7114
+ } catch (W) {
7115
+ console.warn("Error setting full body mode:", W);
7112
7116
  }
7113
- if (S.includes("."))
7117
+ if (L.includes("."))
7114
7118
  try {
7115
- a.current.playAnimation(S, null, 10, 0, 0.01, P), console.log("Playing animation:", S);
7116
- } catch (V) {
7117
- console.log(`Failed to play ${S}:`, V);
7119
+ a.current.playAnimation(L, null, 10, 0, 0.01, P), console.log("Playing animation:", L);
7120
+ } catch (W) {
7121
+ console.log(`Failed to play ${L}:`, W);
7118
7122
  try {
7119
7123
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7120
- } catch (q) {
7121
- console.warn("Fallback animation also failed:", q);
7124
+ } catch (J) {
7125
+ console.warn("Fallback animation also failed:", J);
7122
7126
  }
7123
7127
  }
7124
7128
  else {
7125
- const V = [".fbx", ".glb", ".gltf"];
7126
- let q = !1;
7127
- for (const _ of V)
7129
+ const W = [".fbx", ".glb", ".gltf"];
7130
+ let J = !1;
7131
+ for (const $ of W)
7128
7132
  try {
7129
- a.current.playAnimation(S + _, null, 10, 0, 0.01, P), console.log("Playing animation:", S + _), q = !0;
7133
+ a.current.playAnimation(L + $, null, 10, 0, 0.01, P), console.log("Playing animation:", L + $), J = !0;
7130
7134
  break;
7131
7135
  } catch {
7132
- console.log(`Failed to play ${S}${_}, trying next format...`);
7136
+ console.log(`Failed to play ${L}${$}, trying next format...`);
7133
7137
  }
7134
- if (!q) {
7135
- console.warn("Animation system not available or animation not found:", S);
7138
+ if (!J) {
7139
+ console.warn("Animation system not available or animation not found:", L);
7136
7140
  try {
7137
7141
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7138
- } catch (_) {
7139
- console.warn("Fallback animation also failed:", _);
7142
+ } catch ($) {
7143
+ console.warn("Fallback animation also failed:", $);
7140
7144
  }
7141
7145
  }
7142
7146
  }
7143
7147
  } else
7144
- console.warn("Animation system not available or animation not found:", S);
7148
+ console.warn("Animation system not available or animation not found:", L);
7145
7149
  }, []);
7146
- return Re(r, () => ({
7147
- speakText: R,
7148
- stopSpeaking: O,
7150
+ return ve(r, () => ({
7151
+ speakText: b,
7152
+ stopSpeaking: U,
7149
7153
  setMood: B,
7150
- setTimingAdjustment: $,
7151
- playAnimation: Y,
7154
+ setTimingAdjustment: j,
7155
+ playAnimation: ae,
7152
7156
  isReady: g,
7153
7157
  talkingHead: a.current,
7154
- setBodyMovement: (S) => {
7158
+ setBodyMovement: (L) => {
7155
7159
  if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
7156
7160
  try {
7157
- a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7161
+ a.current.setShowFullAvatar(!0), a.current.setBodyMovement(L), console.log("Body movement set with full body mode:", L);
7158
7162
  } catch (P) {
7159
7163
  console.warn("Error setting body movement:", P);
7160
7164
  }
7161
7165
  },
7162
- setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
7166
+ setMovementIntensity: (L) => a.current?.setMovementIntensity(L),
7163
7167
  playRandomDance: () => {
7164
7168
  if (a.current && a.current.setShowFullAvatar && a.current.playRandomDance)
7165
7169
  try {
7166
7170
  a.current.setShowFullAvatar(!0), a.current.playRandomDance(), console.log("Random dance played with full body mode");
7167
- } catch (S) {
7168
- console.warn("Error playing random dance:", S);
7171
+ } catch (L) {
7172
+ console.warn("Error playing random dance:", L);
7169
7173
  }
7170
7174
  },
7171
- playReaction: (S) => {
7175
+ playReaction: (L) => {
7172
7176
  if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
7173
7177
  try {
7174
- a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7178
+ a.current.setShowFullAvatar(!0), a.current.playReaction(L), console.log("Reaction played with full body mode:", L);
7175
7179
  } catch (P) {
7176
7180
  console.warn("Error playing reaction:", P);
7177
7181
  }
@@ -7180,14 +7184,14 @@ const ot = be(({
7180
7184
  if (a.current && a.current.setShowFullAvatar && a.current.playCelebration)
7181
7185
  try {
7182
7186
  a.current.setShowFullAvatar(!0), a.current.playCelebration(), console.log("Celebration played with full body mode");
7183
- } catch (S) {
7184
- console.warn("Error playing celebration:", S);
7187
+ } catch (L) {
7188
+ console.warn("Error playing celebration:", L);
7185
7189
  }
7186
7190
  },
7187
- setShowFullAvatar: (S) => {
7191
+ setShowFullAvatar: (L) => {
7188
7192
  if (a.current && a.current.setShowFullAvatar)
7189
7193
  try {
7190
- a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7194
+ a.current.setShowFullAvatar(L), console.log("Show full avatar set to:", L);
7191
7195
  } catch (P) {
7192
7196
  console.warn("Error setting showFullAvatar:", P);
7193
7197
  }
@@ -7196,20 +7200,20 @@ const ot = be(({
7196
7200
  if (a.current && a.current.lockAvatarPosition)
7197
7201
  try {
7198
7202
  a.current.lockAvatarPosition();
7199
- } catch (S) {
7200
- console.warn("Error locking avatar position:", S);
7203
+ } catch (L) {
7204
+ console.warn("Error locking avatar position:", L);
7201
7205
  }
7202
7206
  },
7203
7207
  unlockAvatarPosition: () => {
7204
7208
  if (a.current && a.current.unlockAvatarPosition)
7205
7209
  try {
7206
7210
  a.current.unlockAvatarPosition();
7207
- } catch (S) {
7208
- console.warn("Error unlocking avatar position:", S);
7211
+ } catch (L) {
7212
+ console.warn("Error unlocking avatar position:", L);
7209
7213
  }
7210
7214
  }
7211
- })), /* @__PURE__ */ Ce("div", { className: `talking-head-container ${n}`, style: s, children: [
7212
- /* @__PURE__ */ oe(
7215
+ })), /* @__PURE__ */ He("div", { className: `talking-head-container ${n}`, style: s, children: [
7216
+ /* @__PURE__ */ se(
7213
7217
  "div",
7214
7218
  {
7215
7219
  ref: h,
@@ -7221,7 +7225,7 @@ const ot = be(({
7221
7225
  }
7222
7226
  }
7223
7227
  ),
7224
- u && /* @__PURE__ */ oe("div", { className: "loading-overlay", style: {
7228
+ u && /* @__PURE__ */ se("div", { className: "loading-overlay", style: {
7225
7229
  position: "absolute",
7226
7230
  top: "50%",
7227
7231
  left: "50%",
@@ -7230,7 +7234,7 @@ const ot = be(({
7230
7234
  fontSize: "18px",
7231
7235
  zIndex: 10
7232
7236
  }, children: "Loading avatar..." }),
7233
- c && /* @__PURE__ */ oe("div", { className: "error-overlay", style: {
7237
+ c && /* @__PURE__ */ se("div", { className: "error-overlay", style: {
7234
7238
  position: "absolute",
7235
7239
  top: "50%",
7236
7240
  left: "50%",
@@ -7244,9 +7248,9 @@ const ot = be(({
7244
7248
  }, children: c })
7245
7249
  ] });
7246
7250
  });
7247
- ot.displayName = "TalkingHeadComponent";
7248
- const st = be(({
7249
- curriculumData: D = null,
7251
+ st.displayName = "TalkingHeadComponent";
7252
+ const at = Re(({
7253
+ curriculumData: O = null,
7250
7254
  avatarConfig: t = {},
7251
7255
  animations: e = {},
7252
7256
  onLessonStart: i = () => {
@@ -7261,7 +7265,7 @@ const st = be(({
7261
7265
  },
7262
7266
  autoStart: h = !1
7263
7267
  }, a) => {
7264
- const u = X(null), l = X({
7268
+ const u = G(null), l = G({
7265
7269
  currentModuleIndex: 0,
7266
7270
  currentLessonIndex: 0,
7267
7271
  currentQuestionIndex: 0,
@@ -7271,18 +7275,18 @@ const st = be(({
7271
7275
  curriculumCompleted: !1,
7272
7276
  score: 0,
7273
7277
  totalQuestions: 0
7274
- }), c = X({
7278
+ }), c = G({
7275
7279
  onLessonStart: i,
7276
7280
  onLessonComplete: n,
7277
7281
  onQuestionAnswer: s,
7278
7282
  onCurriculumComplete: o,
7279
7283
  onCustomAction: r
7280
- }), d = X(null), g = X(null), y = X(null), x = X(null), I = X(null), T = X(null), p = X(null), F = X(D?.curriculum || {
7284
+ }), d = G(null), g = G(null), y = G(null), x = G(null), I = G(null), T = G(null), p = G(null), C = G(O?.curriculum || {
7281
7285
  title: "Default Curriculum",
7282
7286
  description: "No curriculum data provided",
7283
7287
  language: "en",
7284
7288
  modules: []
7285
- }), C = X({
7289
+ }), H = G({
7286
7290
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7287
7291
  avatarBody: t.avatarBody || "F",
7288
7292
  mood: t.mood || "happy",
@@ -7296,7 +7300,7 @@ const st = be(({
7296
7300
  animations: e,
7297
7301
  lipsyncLang: "en"
7298
7302
  });
7299
- he(() => {
7303
+ ue(() => {
7300
7304
  c.current = {
7301
7305
  onLessonStart: i,
7302
7306
  onLessonComplete: n,
@@ -7304,13 +7308,13 @@ const st = be(({
7304
7308
  onCurriculumComplete: o,
7305
7309
  onCustomAction: r
7306
7310
  };
7307
- }, [i, n, s, o, r]), he(() => {
7308
- F.current = D?.curriculum || {
7311
+ }, [i, n, s, o, r]), ue(() => {
7312
+ C.current = O?.curriculum || {
7309
7313
  title: "Default Curriculum",
7310
7314
  description: "No curriculum data provided",
7311
7315
  language: "en",
7312
7316
  modules: []
7313
- }, C.current = {
7317
+ }, H.current = {
7314
7318
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7315
7319
  avatarBody: t.avatarBody || "F",
7316
7320
  mood: t.mood || "happy",
@@ -7324,24 +7328,24 @@ const st = be(({
7324
7328
  animations: e,
7325
7329
  lipsyncLang: "en"
7326
7330
  };
7327
- }, [D, t, e]);
7328
- const R = E(() => (F.current || { modules: [] }).modules[l.current.currentModuleIndex]?.lessons[l.current.currentLessonIndex], []), O = E(() => R()?.questions[l.current.currentQuestionIndex], [R]), B = E((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, []), $ = E(() => {
7331
+ }, [O, t, e]);
7332
+ const b = E(() => (C.current || { modules: [] }).modules[l.current.currentModuleIndex]?.lessons[l.current.currentLessonIndex], []), U = E(() => b()?.questions[l.current.currentQuestionIndex], [b]), B = E((R, v) => v.type === "multiple_choice" || v.type === "true_false" ? R === v.answer : v.type === "code_test" && typeof R == "object" && R !== null ? R.passed === !0 : !1, []), j = E(() => {
7329
7333
  l.current.lessonCompleted = !0, l.current.isQuestionMode = !1;
7330
- const b = l.current.totalQuestions > 0 ? Math.round(l.current.score / l.current.totalQuestions * 100) : 100;
7334
+ const R = l.current.totalQuestions > 0 ? Math.round(l.current.score / l.current.totalQuestions * 100) : 100;
7331
7335
  let v = "Congratulations! You've completed this lesson";
7332
- if (l.current.totalQuestions > 0 ? v += ` with a score of ${l.current.score} out of ${l.current.totalQuestions} (${b}%). ` : 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({
7336
+ if (l.current.totalQuestions > 0 ? v += ` with a score of ${l.current.score} out of ${l.current.totalQuestions} (${R}%). ` : v += "! ", R >= 80 ? v += "Excellent work! You have a great understanding of this topic." : R >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7333
7337
  moduleIndex: l.current.currentModuleIndex,
7334
7338
  lessonIndex: l.current.currentLessonIndex,
7335
7339
  score: l.current.score,
7336
7340
  totalQuestions: l.current.totalQuestions,
7337
- percentage: b
7341
+ percentage: R
7338
7342
  }), c.current.onCustomAction({
7339
7343
  type: "lessonComplete",
7340
7344
  moduleIndex: l.current.currentModuleIndex,
7341
7345
  lessonIndex: l.current.currentLessonIndex,
7342
7346
  score: l.current.score,
7343
7347
  totalQuestions: l.current.totalQuestions,
7344
- percentage: b
7348
+ percentage: R
7345
7349
  }), u.current) {
7346
7350
  if (u.current.setMood("happy"), e.lessonComplete)
7347
7351
  try {
@@ -7349,9 +7353,9 @@ const st = be(({
7349
7353
  } catch {
7350
7354
  u.current.playCelebration();
7351
7355
  }
7352
- const z = F.current || { modules: [] }, L = z.modules[l.current.currentModuleIndex], H = l.current.currentLessonIndex < (L?.lessons?.length || 0) - 1, U = l.current.currentModuleIndex < (z.modules?.length || 0) - 1, w = H || U, j = C.current || { lipsyncLang: "en" };
7356
+ const z = C.current || { modules: [] }, Z = z.modules[l.current.currentModuleIndex], S = l.current.currentLessonIndex < (Z?.lessons?.length || 0) - 1, F = l.current.currentModuleIndex < (z.modules?.length || 0) - 1, V = S || F, w = H.current || { lipsyncLang: "en" };
7353
7357
  u.current.speakText(v, {
7354
- lipsyncLang: j.lipsyncLang,
7358
+ lipsyncLang: w.lipsyncLang,
7355
7359
  onSpeechEnd: () => {
7356
7360
  c.current.onCustomAction({
7357
7361
  type: "lessonCompleteFeedbackDone",
@@ -7359,18 +7363,18 @@ const st = be(({
7359
7363
  lessonIndex: l.current.currentLessonIndex,
7360
7364
  score: l.current.score,
7361
7365
  totalQuestions: l.current.totalQuestions,
7362
- percentage: b,
7363
- hasNextLesson: w
7366
+ percentage: R,
7367
+ hasNextLesson: V
7364
7368
  });
7365
7369
  }
7366
7370
  });
7367
7371
  }
7368
- }, [e.lessonComplete]), Y = E(() => {
7372
+ }, [e.lessonComplete]), ae = E(() => {
7369
7373
  l.current.curriculumCompleted = !0;
7370
- const b = F.current || { modules: [] };
7374
+ const R = C.current || { modules: [] };
7371
7375
  if (c.current.onCurriculumComplete({
7372
- modules: b.modules.length,
7373
- totalLessons: b.modules.reduce((v, z) => v + z.lessons.length, 0)
7376
+ modules: R.modules.length,
7377
+ totalLessons: R.modules.reduce((v, z) => v + z.lessons.length, 0)
7374
7378
  }), u.current) {
7375
7379
  if (u.current.setMood("celebrating"), e.curriculumComplete)
7376
7380
  try {
@@ -7378,13 +7382,13 @@ const st = be(({
7378
7382
  } catch {
7379
7383
  u.current.playCelebration();
7380
7384
  }
7381
- const v = C.current || { lipsyncLang: "en" };
7385
+ const v = H.current || { lipsyncLang: "en" };
7382
7386
  u.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 });
7383
7387
  }
7384
- }, [e.curriculumComplete]), S = E(() => {
7385
- const b = R();
7386
- l.current.isQuestionMode = !0, l.current.currentQuestionIndex = 0, l.current.totalQuestions = b?.questions?.length || 0;
7387
- const v = O();
7388
+ }, [e.curriculumComplete]), L = E(() => {
7389
+ const R = b();
7390
+ l.current.isQuestionMode = !0, l.current.currentQuestionIndex = 0, l.current.totalQuestions = R?.questions?.length || 0;
7391
+ const v = U();
7388
7392
  if (v && c.current.onCustomAction({
7389
7393
  type: "questionStart",
7390
7394
  moduleIndex: l.current.currentModuleIndex,
@@ -7396,23 +7400,23 @@ const st = be(({
7396
7400
  if (u.current.setMood("curious"), e.questionStart)
7397
7401
  try {
7398
7402
  u.current.playAnimation(e.questionStart, !0);
7399
- } catch (L) {
7400
- console.warn("Failed to play questionStart animation:", L);
7403
+ } catch (Z) {
7404
+ console.warn("Failed to play questionStart animation:", Z);
7401
7405
  }
7402
- const z = C.current || { lipsyncLang: "en" };
7406
+ const z = H.current || { lipsyncLang: "en" };
7403
7407
  v.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: z.lipsyncLang }) : v.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: z.lipsyncLang }) : v.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: z.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: z.lipsyncLang });
7404
7408
  } else if (u.current && u.current.isReady) {
7405
- const z = C.current || { lipsyncLang: "en" };
7409
+ const z = H.current || { lipsyncLang: "en" };
7406
7410
  u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: z.lipsyncLang });
7407
7411
  } else
7408
7412
  setTimeout(() => {
7409
7413
  T.current && T.current();
7410
7414
  }, 100);
7411
- }, [e.questionStart, R, O]), P = E(() => {
7412
- const b = R();
7413
- if (l.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7415
+ }, [e.questionStart, b, U]), P = E(() => {
7416
+ const R = b();
7417
+ if (l.current.currentQuestionIndex < (R?.questions?.length || 0) - 1) {
7414
7418
  l.current.currentQuestionIndex += 1;
7415
- const v = O();
7419
+ const v = U();
7416
7420
  if (v && c.current.onCustomAction({
7417
7421
  type: "nextQuestion",
7418
7422
  moduleIndex: l.current.currentModuleIndex,
@@ -7424,10 +7428,10 @@ const st = be(({
7424
7428
  if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
7425
7429
  try {
7426
7430
  u.current.playAnimation(e.nextQuestion, !0);
7427
- } catch (L) {
7428
- console.warn("Failed to play nextQuestion animation:", L);
7431
+ } catch (Z) {
7432
+ console.warn("Failed to play nextQuestion animation:", Z);
7429
7433
  }
7430
- const z = C.current || { lipsyncLang: "en" };
7434
+ const z = H.current || { lipsyncLang: "en" };
7431
7435
  v.type === "code_test" ? u.current.speakText(`Great! Now let's move on to your next coding challenge: ${v.question}`, {
7432
7436
  lipsyncLang: z.lipsyncLang
7433
7437
  }) : v.type === "multiple_choice" ? u.current.speakText(`Alright! Here's your next question: ${v.question}`, {
@@ -7446,8 +7450,8 @@ const st = be(({
7446
7450
  totalQuestions: l.current.totalQuestions,
7447
7451
  score: l.current.score
7448
7452
  });
7449
- }, [e.nextQuestion, R, O]), W = E(() => {
7450
- const b = F.current || { modules: [] }, v = b.modules[l.current.currentModuleIndex];
7453
+ }, [e.nextQuestion, b, U]), D = E(() => {
7454
+ const R = C.current || { modules: [] }, v = R.modules[l.current.currentModuleIndex];
7451
7455
  l.current.currentLessonIndex < (v?.lessons?.length || 0) - 1 ? (l.current.currentLessonIndex += 1, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0, c.current.onCustomAction({
7452
7456
  type: "lessonStart",
7453
7457
  moduleIndex: l.current.currentModuleIndex,
@@ -7455,64 +7459,64 @@ const st = be(({
7455
7459
  }), c.current.onLessonStart({
7456
7460
  moduleIndex: l.current.currentModuleIndex,
7457
7461
  lessonIndex: l.current.currentLessonIndex,
7458
- lesson: R()
7459
- }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"))) : l.current.currentModuleIndex < (b.modules?.length || 0) - 1 ? (l.current.currentModuleIndex += 1, l.current.currentLessonIndex = 0, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0, c.current.onCustomAction({
7462
+ lesson: b()
7463
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"))) : l.current.currentModuleIndex < (R.modules?.length || 0) - 1 ? (l.current.currentModuleIndex += 1, l.current.currentLessonIndex = 0, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0, c.current.onCustomAction({
7460
7464
  type: "lessonStart",
7461
7465
  moduleIndex: l.current.currentModuleIndex,
7462
7466
  lessonIndex: l.current.currentLessonIndex
7463
7467
  }), c.current.onLessonStart({
7464
7468
  moduleIndex: l.current.currentModuleIndex,
7465
7469
  lessonIndex: l.current.currentLessonIndex,
7466
- lesson: R()
7470
+ lesson: b()
7467
7471
  }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"))) : I.current && I.current();
7468
- }, []), V = E(() => {
7469
- const b = R();
7472
+ }, []), W = E(() => {
7473
+ const R = b();
7470
7474
  let v = null;
7471
- if (b?.avatar_script && b?.body) {
7472
- const z = b.avatar_script.trim(), L = b.body.trim(), H = z.match(/[.!?]$/) ? " " : ". ";
7473
- v = `${z}${H}${L}`;
7475
+ if (R?.avatar_script && R?.body) {
7476
+ const z = R.avatar_script.trim(), Z = R.body.trim(), S = z.match(/[.!?]$/) ? " " : ". ";
7477
+ v = `${z}${S}${Z}`;
7474
7478
  } else
7475
- v = b?.avatar_script || b?.body || null;
7479
+ v = R?.avatar_script || R?.body || null;
7476
7480
  if (u.current && u.current.isReady && v) {
7477
7481
  l.current.isTeaching = !0, l.current.isQuestionMode = !1, u.current.setMood("happy");
7478
7482
  let z = !1;
7479
7483
  if (e.teaching)
7480
7484
  try {
7481
7485
  u.current.playAnimation(e.teaching, !0), z = !0;
7482
- } catch (H) {
7483
- console.warn("Failed to play teaching animation:", H);
7486
+ } catch (S) {
7487
+ console.warn("Failed to play teaching animation:", S);
7484
7488
  }
7485
7489
  z || u.current.setBodyMovement("gesturing");
7486
- const L = C.current || { lipsyncLang: "en" };
7490
+ const Z = H.current || { lipsyncLang: "en" };
7487
7491
  c.current.onLessonStart({
7488
7492
  moduleIndex: l.current.currentModuleIndex,
7489
7493
  lessonIndex: l.current.currentLessonIndex,
7490
- lesson: b
7494
+ lesson: R
7491
7495
  }), c.current.onCustomAction({
7492
7496
  type: "teachingStart",
7493
7497
  moduleIndex: l.current.currentModuleIndex,
7494
7498
  lessonIndex: l.current.currentLessonIndex,
7495
- lesson: b
7499
+ lesson: R
7496
7500
  }), u.current.speakText(v, {
7497
- lipsyncLang: L.lipsyncLang,
7501
+ lipsyncLang: Z.lipsyncLang,
7498
7502
  onSpeechEnd: () => {
7499
7503
  l.current.isTeaching = !1, c.current.onCustomAction({
7500
7504
  type: "teachingComplete",
7501
7505
  moduleIndex: l.current.currentModuleIndex,
7502
7506
  lessonIndex: l.current.currentLessonIndex,
7503
- lesson: b,
7504
- hasQuestions: b.questions && b.questions.length > 0
7507
+ lesson: R,
7508
+ hasQuestions: R.questions && R.questions.length > 0
7505
7509
  });
7506
7510
  }
7507
7511
  });
7508
7512
  }
7509
- }, [e.teaching, R]), q = E((b) => {
7510
- const v = O(), z = B(b, v);
7513
+ }, [e.teaching, b]), J = E((R) => {
7514
+ const v = U(), z = B(R, v);
7511
7515
  if (z && (l.current.score += 1), c.current.onQuestionAnswer({
7512
7516
  moduleIndex: l.current.currentModuleIndex,
7513
7517
  lessonIndex: l.current.currentLessonIndex,
7514
7518
  questionIndex: l.current.currentQuestionIndex,
7515
- answer: b,
7519
+ answer: R,
7516
7520
  isCorrect: z,
7517
7521
  question: v
7518
7522
  }), u.current)
@@ -7524,9 +7528,9 @@ const st = be(({
7524
7528
  u.current.setBodyMovement("happy");
7525
7529
  }
7526
7530
  u.current.setBodyMovement("gesturing");
7527
- const L = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, H = C.current || { lipsyncLang: "en" };
7528
- u.current.speakText(L, {
7529
- lipsyncLang: H.lipsyncLang,
7531
+ const Z = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, S = H.current || { lipsyncLang: "en" };
7532
+ u.current.speakText(Z, {
7533
+ lipsyncLang: S.lipsyncLang,
7530
7534
  onSpeechEnd: () => {
7531
7535
  c.current.onCustomAction({
7532
7536
  type: "answerFeedbackComplete",
@@ -7534,7 +7538,7 @@ const st = be(({
7534
7538
  lessonIndex: l.current.currentLessonIndex,
7535
7539
  questionIndex: l.current.currentQuestionIndex,
7536
7540
  isCorrect: !0,
7537
- hasNextQuestion: l.current.currentQuestionIndex < (R()?.questions?.length || 0) - 1
7541
+ hasNextQuestion: l.current.currentQuestionIndex < (b()?.questions?.length || 0) - 1
7538
7542
  });
7539
7543
  }
7540
7544
  });
@@ -7546,9 +7550,9 @@ const st = be(({
7546
7550
  u.current.setBodyMovement("idle");
7547
7551
  }
7548
7552
  u.current.setBodyMovement("gesturing");
7549
- const L = 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.`, H = C.current || { lipsyncLang: "en" };
7550
- u.current.speakText(L, {
7551
- lipsyncLang: H.lipsyncLang,
7553
+ const Z = 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.`, S = H.current || { lipsyncLang: "en" };
7554
+ u.current.speakText(Z, {
7555
+ lipsyncLang: S.lipsyncLang,
7552
7556
  onSpeechEnd: () => {
7553
7557
  c.current.onCustomAction({
7554
7558
  type: "answerFeedbackComplete",
@@ -7556,7 +7560,7 @@ const st = be(({
7556
7560
  lessonIndex: l.current.currentLessonIndex,
7557
7561
  questionIndex: l.current.currentQuestionIndex,
7558
7562
  isCorrect: !1,
7559
- hasNextQuestion: l.current.currentQuestionIndex < (R()?.questions?.length || 0) - 1
7563
+ hasNextQuestion: l.current.currentQuestionIndex < (b()?.questions?.length || 0) - 1
7560
7564
  });
7561
7565
  }
7562
7566
  });
@@ -7568,12 +7572,12 @@ const st = be(({
7568
7572
  lessonIndex: l.current.currentLessonIndex,
7569
7573
  questionIndex: l.current.currentQuestionIndex,
7570
7574
  isCorrect: z,
7571
- hasNextQuestion: l.current.currentQuestionIndex < (R()?.questions?.length || 0) - 1,
7575
+ hasNextQuestion: l.current.currentQuestionIndex < (b()?.questions?.length || 0) - 1,
7572
7576
  avatarNotReady: !0
7573
7577
  });
7574
- }, [e.correct, e.incorrect, O, R, B]), _ = E((b) => {
7575
- const v = O();
7576
- if (!b || typeof b != "object") {
7578
+ }, [e.correct, e.incorrect, U, b, B]), $ = E((R) => {
7579
+ const v = U();
7580
+ if (!R || typeof R != "object") {
7577
7581
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
7578
7582
  return;
7579
7583
  }
@@ -7582,14 +7586,14 @@ const st = be(({
7582
7586
  return;
7583
7587
  }
7584
7588
  const z = {
7585
- passed: b.passed === !0,
7586
- results: b.results || [],
7587
- output: b.output || "",
7588
- error: b.error || null,
7589
- executionTime: b.executionTime || null,
7590
- testCount: b.testCount || 0,
7591
- passedCount: b.passedCount || 0,
7592
- failedCount: b.failedCount || 0
7589
+ passed: R.passed === !0,
7590
+ results: R.results || [],
7591
+ output: R.output || "",
7592
+ error: R.error || null,
7593
+ executionTime: R.executionTime || null,
7594
+ testCount: R.testCount || 0,
7595
+ passedCount: R.passedCount || 0,
7596
+ failedCount: R.failedCount || 0
7593
7597
  };
7594
7598
  c.current.onCustomAction({
7595
7599
  type: "codeTestSubmitted",
@@ -7599,45 +7603,45 @@ const st = be(({
7599
7603
  testResult: z,
7600
7604
  question: v
7601
7605
  }), p.current && p.current(z);
7602
- }, [O, B]), le = E(() => {
7606
+ }, [U, B]), ne = E(() => {
7603
7607
  l.current.currentModuleIndex = 0, l.current.currentLessonIndex = 0, l.current.currentQuestionIndex = 0, l.current.isTeaching = !1, l.current.isQuestionMode = !1, l.current.lessonCompleted = !1, l.current.curriculumCompleted = !1, l.current.score = 0, l.current.totalQuestions = 0;
7604
- }, []), ye = E((b) => {
7605
- console.log("Avatar is ready!", b);
7606
- const v = R(), z = v?.avatar_script || v?.body;
7608
+ }, []), fe = E((R) => {
7609
+ console.log("Avatar is ready!", R);
7610
+ const v = b(), z = v?.avatar_script || v?.body;
7607
7611
  h && z && setTimeout(() => {
7608
7612
  d.current && d.current();
7609
7613
  }, 10);
7610
- }, [h, R]);
7611
- Pe(() => {
7612
- d.current = V, g.current = W, y.current = $, x.current = P, I.current = Y, T.current = S, p.current = q;
7613
- }), Re(a, () => ({
7614
+ }, [h, b]);
7615
+ Be(() => {
7616
+ d.current = W, g.current = D, y.current = j, x.current = P, I.current = ae, T.current = L, p.current = J;
7617
+ }), ve(a, () => ({
7614
7618
  // Curriculum control methods
7615
- startTeaching: V,
7616
- startQuestions: S,
7617
- handleAnswerSelect: q,
7618
- handleCodeTestResult: _,
7619
+ startTeaching: W,
7620
+ startQuestions: L,
7621
+ handleAnswerSelect: J,
7622
+ handleCodeTestResult: $,
7619
7623
  nextQuestion: P,
7620
- nextLesson: W,
7621
- completeLesson: $,
7622
- completeCurriculum: Y,
7623
- resetCurriculum: le,
7624
+ nextLesson: D,
7625
+ completeLesson: j,
7626
+ completeCurriculum: ae,
7627
+ resetCurriculum: ne,
7624
7628
  getState: () => ({ ...l.current }),
7625
- getCurrentQuestion: () => O(),
7626
- getCurrentLesson: () => R(),
7629
+ getCurrentQuestion: () => U(),
7630
+ getCurrentLesson: () => b(),
7627
7631
  // Direct access to avatar ref (always returns current value)
7628
7632
  getAvatarRef: () => u.current,
7629
7633
  // Convenience methods that delegate to avatar (always check current ref)
7630
- speakText: async (b, v = {}) => {
7634
+ speakText: async (R, v = {}) => {
7631
7635
  await u.current?.resumeAudioContext?.();
7632
- const z = C.current || { lipsyncLang: "en" };
7633
- u.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || z.lipsyncLang });
7636
+ const z = H.current || { lipsyncLang: "en" };
7637
+ u.current?.speakText(R, { ...v, lipsyncLang: v.lipsyncLang || z.lipsyncLang });
7634
7638
  },
7635
7639
  resumeAudioContext: async () => {
7636
7640
  if (u.current?.resumeAudioContext)
7637
7641
  return await u.current.resumeAudioContext();
7638
- const b = u.current?.talkingHead;
7639
- if (b?.audioCtx) {
7640
- const v = b.audioCtx;
7642
+ const R = u.current?.talkingHead;
7643
+ if (R?.audioCtx) {
7644
+ const v = R.audioCtx;
7641
7645
  if (v.state === "suspended" || v.state === "interrupted")
7642
7646
  try {
7643
7647
  await v.resume(), console.log("Audio context resumed via talkingHead");
@@ -7648,21 +7652,21 @@ const st = be(({
7648
7652
  console.warn("Audio context not available yet");
7649
7653
  },
7650
7654
  stopSpeaking: () => u.current?.stopSpeaking(),
7651
- setMood: (b) => u.current?.setMood(b),
7652
- playAnimation: (b, v) => u.current?.playAnimation(b, v),
7653
- setBodyMovement: (b) => u.current?.setBodyMovement(b),
7654
- setMovementIntensity: (b) => u.current?.setMovementIntensity(b),
7655
+ setMood: (R) => u.current?.setMood(R),
7656
+ playAnimation: (R, v) => u.current?.playAnimation(R, v),
7657
+ setBodyMovement: (R) => u.current?.setBodyMovement(R),
7658
+ setMovementIntensity: (R) => u.current?.setMovementIntensity(R),
7655
7659
  playRandomDance: () => u.current?.playRandomDance(),
7656
- playReaction: (b) => u.current?.playReaction(b),
7660
+ playReaction: (R) => u.current?.playReaction(R),
7657
7661
  playCelebration: () => u.current?.playCelebration(),
7658
- setShowFullAvatar: (b) => u.current?.setShowFullAvatar(b),
7659
- setTimingAdjustment: (b) => u.current?.setTimingAdjustment(b),
7662
+ setShowFullAvatar: (R) => u.current?.setShowFullAvatar(R),
7663
+ setTimingAdjustment: (R) => u.current?.setTimingAdjustment(R),
7660
7664
  lockAvatarPosition: () => u.current?.lockAvatarPosition(),
7661
7665
  unlockAvatarPosition: () => u.current?.unlockAvatarPosition(),
7662
7666
  // Custom action trigger
7663
- triggerCustomAction: (b, v) => {
7667
+ triggerCustomAction: (R, v) => {
7664
7668
  c.current.onCustomAction({
7665
- type: b,
7669
+ type: R,
7666
7670
  ...v,
7667
7671
  state: { ...l.current }
7668
7672
  });
@@ -7671,8 +7675,8 @@ const st = be(({
7671
7675
  handleResize: () => u.current?.handleResize(),
7672
7676
  // Avatar readiness check (always returns current value)
7673
7677
  isAvatarReady: () => u.current?.isReady || !1
7674
- }), [V, S, q, _, P, W, $, Y, le, O, R]);
7675
- const K = C.current || {
7678
+ }), [W, L, J, $, P, D, j, ae, ne, U, b]);
7679
+ const _ = H.current || {
7676
7680
  avatarUrl: "/avatars/brunette.glb",
7677
7681
  avatarBody: "F",
7678
7682
  mood: "happy",
@@ -7685,33 +7689,33 @@ const st = be(({
7685
7689
  showFullAvatar: !1,
7686
7690
  animations: e
7687
7691
  };
7688
- return /* @__PURE__ */ oe("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ oe(
7689
- Te,
7692
+ return /* @__PURE__ */ se("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ se(
7693
+ Me,
7690
7694
  {
7691
7695
  ref: u,
7692
- avatarUrl: K.avatarUrl,
7693
- avatarBody: K.avatarBody,
7694
- mood: K.mood,
7695
- ttsLang: K.ttsLang,
7696
- ttsService: K.ttsService,
7697
- ttsVoice: K.ttsVoice,
7698
- ttsApiKey: K.ttsApiKey,
7699
- bodyMovement: K.bodyMovement,
7700
- movementIntensity: K.movementIntensity,
7701
- showFullAvatar: K.showFullAvatar,
7696
+ avatarUrl: _.avatarUrl,
7697
+ avatarBody: _.avatarBody,
7698
+ mood: _.mood,
7699
+ ttsLang: _.ttsLang,
7700
+ ttsService: _.ttsService,
7701
+ ttsVoice: _.ttsVoice,
7702
+ ttsApiKey: _.ttsApiKey,
7703
+ bodyMovement: _.bodyMovement,
7704
+ movementIntensity: _.movementIntensity,
7705
+ showFullAvatar: _.showFullAvatar,
7702
7706
  cameraView: "upper",
7703
- animations: K.animations,
7704
- onReady: ye,
7707
+ animations: _.animations,
7708
+ onReady: fe,
7705
7709
  onLoading: () => {
7706
7710
  },
7707
- onError: (b) => {
7708
- console.error("Avatar error:", b);
7711
+ onError: (R) => {
7712
+ console.error("Avatar error:", R);
7709
7713
  }
7710
7714
  }
7711
7715
  ) });
7712
7716
  });
7713
- st.displayName = "CurriculumLearning";
7714
- const Me = {
7717
+ at.displayName = "CurriculumLearning";
7718
+ const Ee = {
7715
7719
  // Code-based dance animations (no FBX required)
7716
7720
  dance: {
7717
7721
  name: "dance",
@@ -7814,14 +7818,14 @@ const Me = {
7814
7818
  duration: 5e3,
7815
7819
  description: "Excited, energetic movement"
7816
7820
  }
7817
- }, gt = (D) => Me[D] || null, yt = (D) => Me.hasOwnProperty(D);
7821
+ }, yt = (O) => Ee[O] || null, ft = (O) => Ee.hasOwnProperty(O);
7818
7822
  export {
7819
- st as CurriculumLearning,
7820
- Te as TalkingHeadAvatar,
7821
- ot as TalkingHeadComponent,
7822
- Me as animations,
7823
- ve as getActiveTTSConfig,
7824
- gt as getAnimation,
7825
- pt as getVoiceOptions,
7826
- yt as hasAnimation
7823
+ at as CurriculumLearning,
7824
+ Me as TalkingHeadAvatar,
7825
+ st as TalkingHeadComponent,
7826
+ Ee as animations,
7827
+ Ie as getActiveTTSConfig,
7828
+ yt as getAnimation,
7829
+ gt as getVoiceOptions,
7830
+ ft as hasAnimation
7827
7831
  };