@sage-rsc/talking-head-react 1.0.69 → 1.0.71

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,20 +1,20 @@
1
- import { jsxs as Oe, jsx as ge } from "react/jsx-runtime";
2
- import { forwardRef as ze, useRef as N, useState as be, useEffect as Ie, useCallback as M, useImperativeHandle as Ce, useLayoutEffect as Xe } from "react";
3
- import * as f from "three";
1
+ import { jsxs as Pe, jsx as me } from "react/jsx-runtime";
2
+ import { forwardRef as Me, useRef as D, useState as ce, useEffect as de, useCallback as T, useImperativeHandle as Ee, useLayoutEffect as Xe } from "react";
3
+ import * as x from "three";
4
4
  import { OrbitControls as Ye } from "three/addons/controls/OrbitControls.js";
5
5
  import { GLTFLoader as je } from "three/addons/loaders/GLTFLoader.js";
6
6
  import { DRACOLoader as Qe } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as Ee } from "three/addons/loaders/FBXLoader.js";
7
+ import { FBXLoader as Oe } from "three/addons/loaders/FBXLoader.js";
8
8
  import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
9
- import _e from "three/addons/libs/stats.module.js";
10
- let m, te, ne;
11
- const A = [0, 0, 0, 0], k = new f.Vector3(), Se = new f.Vector3(), _ = new f.Vector3(), ke = new f.Vector3();
12
- new f.Plane();
13
- new f.Ray();
14
- new f.Euler();
15
- const K = new f.Quaternion(), Fe = new f.Quaternion(), le = new f.Matrix4(), he = new f.Matrix4();
16
- new f.Vector3();
17
- const we = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), Je = new f.Vector3(0, 1, 0), $e = new f.Vector3(0, 0, 1);
9
+ import Ke from "three/addons/libs/stats.module.js";
10
+ let m, re, ue;
11
+ const A = [0, 0, 0, 0], k = new x.Vector3(), ze = new x.Vector3(), ne = new x.Vector3(), Ce = new x.Vector3();
12
+ new x.Plane();
13
+ new x.Ray();
14
+ new x.Euler();
15
+ const ie = new x.Quaternion(), Ne = new x.Quaternion(), fe = new x.Matrix4(), xe = new x.Matrix4();
16
+ new x.Vector3();
17
+ const He = new x.Vector3(0, 0, 1), _e = new x.Vector3(1, 0, 0), Je = new x.Vector3(0, 1, 0), $e = new x.Vector3(0, 0, 1);
18
18
  class et {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
@@ -192,7 +192,7 @@ class et {
192
192
  const l = this.armature.getObjectByName(s.bone);
193
193
  if (!l) throw new Error("Bone '" + s.bone + "' not found in #" + o + " exclude.");
194
194
  if (Number.isNaN(s.radius) && s.radius >= 0) throw new Error("Radius must be a non-negative number in #" + o + " exclude.");
195
- const u = {
195
+ const h = {
196
196
  bone: l,
197
197
  // Bone object
198
198
  radius: s.radius,
@@ -203,9 +203,9 @@ class et {
203
203
  };
204
204
  if (s.deltaLocal) {
205
205
  if (!Array.isArray(s.deltaLocal) || s.deltaLocal.length !== 3 || s.deltaLocal.some((r) => Number.isNaN(r))) throw new Error("deltaLocal must be an array of three numbers in #" + o + " exclude.");
206
- u.deltaLocal = [...s.deltaLocal];
206
+ h.deltaLocal = [...s.deltaLocal];
207
207
  }
208
- i.excludes.push(u);
208
+ i.excludes.push(h);
209
209
  });
210
210
  }
211
211
  this.showHelpers();
@@ -282,8 +282,8 @@ class et {
282
282
  m = this.dict[o.boneParent.name], m && (m.children || (m.children = []), m.children.push(o));
283
283
  }), this.objectsUpdate = [];
284
284
  const n = /* @__PURE__ */ new WeakSet(), i = (o) => o.parent?.isBone ? [o, ...i(o.parent)] : [o], s = (o) => {
285
- i(o).forEach((u) => {
286
- n.has(u) || (this.objectsUpdate.push(u), n.add(u));
285
+ i(o).forEach((h) => {
286
+ n.has(h) || (this.objectsUpdate.push(h), n.add(h));
287
287
  });
288
288
  };
289
289
  this.data.forEach((o) => {
@@ -308,12 +308,12 @@ class et {
308
308
  i(t?.isScene, "First parameter must be Scene."), this.scene = t, i(e?.isObject3D, "Second parameter must be the armature Object3D."), this.armature = e, i(Array.isArray(n), "Third parameter must be an array of bone configs."), this.config = n, this.config.forEach((s, o) => {
309
309
  const l = "Config item #" + o + ": ";
310
310
  i(s.bone, l + "Bone not specified.");
311
- const u = s.bone;
312
- i(typeof u == "string" && u.length > 0, l + "Bone name must be a non-empty string.");
313
- const r = this.armature.getObjectByName(u);
314
- i(r, l + "Bone '" + u + "' not found."), i(r.parent?.isBone, l + "Bone must have a parent bone."), i(this.data.every((a) => a.bone !== r), l + "Bone '" + u + "' already exists."), r.updateMatrixWorld(!0);
315
- const h = {
316
- name: u,
311
+ const h = s.bone;
312
+ i(typeof h == "string" && h.length > 0, l + "Bone name must be a non-empty string.");
313
+ const r = this.armature.getObjectByName(h);
314
+ i(r, l + "Bone '" + h + "' not found."), i(r.parent?.isBone, l + "Bone must have a parent bone."), i(this.data.every((a) => a.bone !== r), l + "Bone '" + h + "' already exists."), r.updateMatrixWorld(!0);
315
+ const u = {
316
+ name: h,
317
317
  // Bone name
318
318
  bone: r,
319
319
  // Bone object
@@ -338,9 +338,9 @@ class et {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- h.boneParent.matrixWorld.decompose(k, K, _), k.copy(we).applyQuaternion(K).setY(0).normalize(), K.premultiply(Fe.setFromUnitVectors(we, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ u.boneParent.matrixWorld.decompose(k, ie, ne), k.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, k).invert()).normalize(), u.qWorldInverseYaw = ie.clone().normalize(), this.data.push(u), this.dict[h] = u;
342
342
  try {
343
- this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
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 (a) {
345
345
  i(!1, l + a);
346
346
  }
@@ -356,22 +356,22 @@ class et {
356
356
  for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, i = this.objectsUpdate.length; e < i; e++)
357
357
  o = this.objectsUpdate[e], o.updateMatrix(), o.parent === null ? o.matrixWorld.copy(o.matrix) : o.matrixWorld.multiplyMatrices(o.parent.matrixWorld, o.matrix), o.matrixWorldNeedsUpdate = !1;
358
358
  for (e = 0, i = this.data.length; e < i; e++) {
359
- if (o = this.data[e], k.copy(o.vWorld), le.copy(o.boneParent.matrixWorld), he.copy(le).invert(), o.vWorld.setFromMatrixPosition(le), k.applyMatrix4(he), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
359
+ if (o = this.data[e], k.copy(o.vWorld), fe.copy(o.boneParent.matrixWorld), xe.copy(fe).invert(), o.vWorld.setFromMatrixPosition(fe), k.applyMatrix4(xe), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
360
360
  for (n = 0, s = o.children.length; n < s; n++)
361
361
  m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
362
362
  if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, k.set(
363
363
  o.vBasis.x + A[0],
364
364
  o.vBasis.y + A[1],
365
365
  o.vBasis.z + A[2]
366
- ), k.applyMatrix4(le), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(he), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
366
+ ), k.applyMatrix4(fe), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(xe), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
367
367
  o.bone.position.set(
368
368
  o.vBasis.x + A[0],
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, K, _), k.copy(we).applyQuaternion(K).setY(0).normalize(), K.premultiply(Fe.setFromUnitVectors(we, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(K)), 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), K.setFromAxisAngle(Ke, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(K)), 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, ie, ne), k.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, k).invert()).normalize(), o.boneParent.quaternion.multiply(ie.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), ie.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(ie)), 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), ie.setFromAxisAngle(_e, -m), o.boneParent.quaternion.multiply(ie)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), ie.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(ie)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (n = 0, s = o.excludes.length; n < s; n++)
374
- m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), he.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(he), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), te = _.length(), !(te > m.radius + ne) && (te < Math.abs(m.radius - ne) || (te = (te * te + ne * ne - m.radiusSq) / (2 * te), _.normalize(), ke.copy(_).multiplyScalar(te), te = Math.sqrt(ne * ne - te * te), k.subVectors(k, ke).projectOnPlane(_).normalize().multiplyScalar(te), Se.subVectors(o.vBasis, ke).projectOnPlane(_).normalize(), ne = Se.dot(k), ne < 0 && (ne = Math.sqrt(te * te - ne * ne), Se.multiplyScalar(ne), k.add(Se)), k.add(ke).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[n], ne.set(0, 0, 0), m.deltaLocal && (ne.x += m.deltaLocal[0], ne.y += m.deltaLocal[1], ne.z += m.deltaLocal[2]), ne.applyMatrix4(m.bone.matrixWorld), xe.copy(o.boneParent.matrixWorld).invert(), ne.applyMatrix4(xe), k.copy(o.bone.position), !(k.distanceToSquared(ne) >= m.radiusSq) && (ue = k.length(), re = ne.length(), !(re > m.radius + ue) && (re < Math.abs(m.radius - ue) || (re = (re * re + ue * ue - m.radiusSq) / (2 * re), ne.normalize(), Ce.copy(ne).multiplyScalar(re), re = Math.sqrt(ue * ue - re * re), k.subVectors(k, Ce).projectOnPlane(ne).normalize().multiplyScalar(re), ze.subVectors(o.vBasis, Ce).projectOnPlane(ne).normalize(), ue = ze.dot(k), ue < 0 && (ue = Math.sqrt(re * re - ue * ue), ze.multiplyScalar(ue), k.add(ze)), k.add(Ce).normalize(), ne.copy(o.bone.position).normalize(), ie.setFromUnitVectors(ne, k), o.boneParent.quaternion.premultiply(ie), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -393,7 +393,7 @@ class et {
393
393
  i || (m.excludes.bones.push(n.bone), m.excludes.radii.push(n.radius), m.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), m.excludes.objects.push(null));
394
394
  }));
395
395
  }), m = this.helpers.excludes, this.opt.isExcludes && m.bones.length && m.bones.forEach((e, n) => {
396
- const i = new f.SphereGeometry(m.radii[n], 6, 6), s = new f.MeshBasicMaterial({
396
+ const i = new x.SphereGeometry(m.radii[n], 6, 6), s = new x.MeshBasicMaterial({
397
397
  depthTest: !1,
398
398
  depthWrite: !1,
399
399
  toneMapped: !1,
@@ -401,18 +401,18 @@ class et {
401
401
  wireframe: !0,
402
402
  color: this.opt.helperExcludesColor
403
403
  });
404
- m.objects[n] = new f.Mesh(i, s), m.objects[n].renderOrder = 997, e.add(m.objects[n]), m.deltaLocals[n] && m.objects[n].position.set(
404
+ m.objects[n] = new x.Mesh(i, s), m.objects[n].renderOrder = 997, e.add(m.objects[n]), m.deltaLocals[n] && m.objects[n].position.set(
405
405
  m.deltaLocals[n][0],
406
406
  m.deltaLocals[n][1],
407
407
  m.deltaLocals[n][2]
408
408
  );
409
409
  }), m = this.helpers.points, m.bones.length) {
410
410
  this.helpers.isActive = !0;
411
- const e = new f.BufferGeometry(), n = m.bones.map((u) => [0, 0, 0]).flat();
412
- e.setAttribute("position", new f.Float32BufferAttribute(n, 3));
413
- const i = new f.Color(this.opt.helperBoneColor1), s = new f.Color(this.opt.helperBoneColor2), o = m.pivots.map((u) => u && this.opt.isPivots ? [s.r, s.g, s.b] : [i.r, i.g, i.b]).flat();
414
- e.setAttribute("color", new f.Float32BufferAttribute(o, 3));
415
- const l = new f.PointsMaterial({
411
+ const e = new x.BufferGeometry(), n = m.bones.map((h) => [0, 0, 0]).flat();
412
+ e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
413
+ const i = new x.Color(this.opt.helperBoneColor1), s = new x.Color(this.opt.helperBoneColor2), o = m.pivots.map((h) => h && this.opt.isPivots ? [s.r, s.g, s.b] : [i.r, i.g, i.b]).flat();
414
+ e.setAttribute("color", new x.Float32BufferAttribute(o, 3));
415
+ const l = new x.PointsMaterial({
416
416
  depthTest: !1,
417
417
  depthWrite: !1,
418
418
  toneMapped: !1,
@@ -420,21 +420,21 @@ class et {
420
420
  size: 0.2,
421
421
  vertexColors: !0
422
422
  });
423
- m.object = new f.Points(e, l), m.object.renderOrder = 998, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
423
+ m.object = new x.Points(e, l), m.object.renderOrder = 998, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
424
424
  }
425
425
  if (m = this.helpers.lines, m.bones.length) {
426
- const e = new f.BufferGeometry(), n = m.bones.map((u) => [0, 0, 0, 0, 0, 0]).flat();
427
- e.setAttribute("position", new f.Float32BufferAttribute(n, 3));
428
- const i = new f.Color(this.opt.helperLinkColor1), s = new f.Color(this.opt.helperLinkColor2), o = m.bones.map((u) => [i.r, i.g, i.b, s.r, s.g, s.b]).flat();
429
- e.setAttribute("color", new f.Float32BufferAttribute(o, 3));
430
- const l = new f.LineBasicMaterial({
426
+ const e = new x.BufferGeometry(), n = m.bones.map((h) => [0, 0, 0, 0, 0, 0]).flat();
427
+ e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
428
+ const i = new x.Color(this.opt.helperLinkColor1), s = new x.Color(this.opt.helperLinkColor2), o = m.bones.map((h) => [i.r, i.g, i.b, s.r, s.g, s.b]).flat();
429
+ e.setAttribute("color", new x.Float32BufferAttribute(o, 3));
430
+ const l = new x.LineBasicMaterial({
431
431
  vertexColors: !0,
432
432
  depthTest: !1,
433
433
  depthWrite: !1,
434
434
  toneMapped: !1,
435
435
  transparent: !0
436
436
  });
437
- m.object = new f.LineSegments(e, l), m.object.renderOrder = 999, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
437
+ m.object = new x.LineSegments(e, l), m.object.renderOrder = 999, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
438
438
  }
439
439
  }
440
440
  /**
@@ -442,17 +442,17 @@ class et {
442
442
  */
443
443
  updateHelpers() {
444
444
  if (m = this.helpers.points, m.bones.length) {
445
- he.copy(this.armature.matrixWorld).invert();
445
+ xe.copy(this.armature.matrixWorld).invert();
446
446
  const t = m.object.geometry.getAttribute("position");
447
447
  for (let e = 0, n = m.bones.length; e < n; e++)
448
- le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(e, k.x, k.y, k.z);
448
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(e, k.x, k.y, k.z);
449
449
  t.needsUpdate = !0, m.object.updateMatrixWorld();
450
450
  }
451
451
  if (m = this.helpers.lines, m.bones.length) {
452
- he.copy(this.armature.matrixWorld).invert();
452
+ xe.copy(this.armature.matrixWorld).invert();
453
453
  const t = m.object.geometry.getAttribute("position");
454
454
  for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
455
- le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(n, k.x, k.y, k.z), le.multiplyMatrices(he, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(n + 1, k.x, k.y, k.z);
455
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(n, k.x, k.y, k.z), fe.multiplyMatrices(xe, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(n + 1, k.x, k.y, k.z);
456
456
  t.needsUpdate = !0, m.object.updateMatrixWorld();
457
457
  }
458
458
  }
@@ -519,13 +519,13 @@ class tt {
519
519
  phonemeBoundaries: []
520
520
  }, i = 1024, s = 512, o = Math.floor((t.length - i) / s) + 1;
521
521
  for (let l = 0; l < o; l++) {
522
- const u = l * s, r = Math.min(u + i, t.length), h = t.slice(u, r), a = this.calculateEnergy(h);
522
+ const h = l * s, r = Math.min(h + i, t.length), u = t.slice(h, r), a = this.calculateEnergy(u);
523
523
  n.energy.push(a);
524
- const c = this.calculateSpectralCentroid(h);
524
+ const c = this.calculateSpectralCentroid(u);
525
525
  n.spectralCentroid.push(c);
526
- const d = this.calculateZeroCrossingRate(h);
526
+ const d = this.calculateZeroCrossingRate(u);
527
527
  n.zeroCrossingRate.push(d);
528
- const g = this.calculateMFCC(h);
528
+ const g = this.calculateMFCC(u);
529
529
  n.mfcc.push(g);
530
530
  }
531
531
  return n.onsets = this.detectOnsets(n.energy), n.phonemeBoundaries = this.detectPhonemeBoundaries(n), n;
@@ -597,19 +597,19 @@ class tt {
597
597
  for (; s & o; )
598
598
  s ^= o, o >>= 1;
599
599
  if (s ^= o, i < s) {
600
- const l = n[i * 2], u = n[i * 2 + 1];
601
- n[i * 2] = n[s * 2], n[i * 2 + 1] = n[s * 2 + 1], n[s * 2] = l, n[s * 2 + 1] = u;
600
+ const l = n[i * 2], h = n[i * 2 + 1];
601
+ n[i * 2] = n[s * 2], n[i * 2 + 1] = n[s * 2 + 1], n[s * 2] = l, n[s * 2 + 1] = h;
602
602
  }
603
603
  }
604
604
  for (let i = 2; i <= e; i <<= 1) {
605
605
  const s = -2 * Math.PI / i, o = Math.cos(s), l = Math.sin(s);
606
- for (let u = 0; u < e; u += i) {
607
- let r = 1, h = 0;
606
+ for (let h = 0; h < e; h += i) {
607
+ let r = 1, u = 0;
608
608
  for (let a = 0; a < i / 2; a++) {
609
- const c = n[(u + a) * 2], d = n[(u + a) * 2 + 1], g = n[(u + a + i / 2) * 2] * r - n[(u + a + i / 2) * 2 + 1] * h, y = n[(u + a + i / 2) * 2] * h + n[(u + a + i / 2) * 2 + 1] * r;
610
- n[(u + a) * 2] = c + g, n[(u + a) * 2 + 1] = d + y, n[(u + a + i / 2) * 2] = c - g, n[(u + a + i / 2) * 2 + 1] = d - y;
611
- const x = r * o - h * l, v = r * l + h * o;
612
- r = x, h = v;
609
+ const c = n[(h + a) * 2], d = n[(h + a) * 2 + 1], g = n[(h + a + i / 2) * 2] * r - n[(h + a + i / 2) * 2 + 1] * u, y = n[(h + a + i / 2) * 2] * u + n[(h + a + i / 2) * 2 + 1] * r;
610
+ n[(h + a) * 2] = c + g, n[(h + a) * 2 + 1] = d + y, n[(h + a + i / 2) * 2] = c - g, n[(h + a + i / 2) * 2 + 1] = d - y;
611
+ const b = r * o - u * l, I = r * l + u * o;
612
+ r = b, u = I;
613
613
  }
614
614
  }
615
615
  }
@@ -624,8 +624,8 @@ class tt {
624
624
  const e = [];
625
625
  let s = -0.1;
626
626
  for (let o = 1; o < t.length; o++) {
627
- const l = t[o] - t[o - 1], u = o * 0.023;
628
- l > 0.1 && u - s > 0.1 && (e.push(u), s = u);
627
+ const l = t[o] - t[o - 1], h = o * 0.023;
628
+ l > 0.1 && h - s > 0.1 && (e.push(h), s = h);
629
629
  }
630
630
  return e;
631
631
  }
@@ -637,8 +637,8 @@ class tt {
637
637
  detectPhonemeBoundaries(t) {
638
638
  const e = [], { energy: n, spectralCentroid: i, zeroCrossingRate: s } = t;
639
639
  for (let o = 1; o < n.length; o++) {
640
- const l = o * 0.023, u = Math.abs(n[o] - n[o - 1]), r = Math.abs(i[o] - i[o - 1]), h = Math.abs(s[o] - s[o - 1]);
641
- u + r * 0.1 + h * 0.5 > 0.2 && e.push(l);
640
+ const l = o * 0.023, h = Math.abs(n[o] - n[o - 1]), r = Math.abs(i[o] - i[o - 1]), u = Math.abs(s[o] - s[o - 1]);
641
+ h + r * 0.1 + u * 0.5 > 0.2 && e.push(l);
642
642
  }
643
643
  return e;
644
644
  }
@@ -654,14 +654,14 @@ class tt {
654
654
  t.phonemeBoundaries, t.onsets;
655
655
  const s = [];
656
656
  let o = 0;
657
- for (let u = 0; u < i.length; u++) {
658
- const r = i[u], h = this.estimateWordDuration(r, n / i.length);
657
+ for (let h = 0; h < i.length; h++) {
658
+ const r = i[h], u = this.estimateWordDuration(r, n / i.length);
659
659
  s.push({
660
660
  word: r,
661
661
  startTime: o,
662
- endTime: o + h,
663
- duration: h
664
- }), o += h;
662
+ endTime: o + u,
663
+ duration: u
664
+ }), o += u;
665
665
  }
666
666
  const l = this.generateVisemeTimings(t, e, n);
667
667
  return {
@@ -701,27 +701,27 @@ class tt {
701
701
  const i = [], s = t.phonemeBoundaries;
702
702
  t.onsets;
703
703
  const o = this.textToVisemes(e);
704
- let l = 0, u = 0;
704
+ let l = 0, h = 0;
705
705
  for (let r = 0; r < s.length && l < o.length; r++) {
706
- const h = s[r], a = o[l], c = t.energy[Math.floor(h / 0.023)] || 0, d = this.calculateVisemeDuration(a, c);
706
+ const u = s[r], a = o[l], c = t.energy[Math.floor(u / 0.023)] || 0, d = this.calculateVisemeDuration(a, c);
707
707
  i.push({
708
708
  viseme: a,
709
- startTime: u,
710
- endTime: u + d,
709
+ startTime: h,
710
+ endTime: h + d,
711
711
  duration: d,
712
712
  intensity: Math.min(1, c * 2)
713
713
  // Map energy to viseme intensity
714
- }), u += d, l++;
714
+ }), h += d, l++;
715
715
  }
716
716
  for (; l < o.length; ) {
717
- const r = o[l], h = this.calculateVisemeDuration(r, 0.5);
717
+ const r = o[l], u = this.calculateVisemeDuration(r, 0.5);
718
718
  i.push({
719
719
  viseme: r,
720
- startTime: u,
721
- endTime: u + h,
722
- duration: h,
720
+ startTime: h,
721
+ endTime: h + u,
722
+ duration: u,
723
723
  intensity: 0.6
724
- }), u += h, l++;
724
+ }), h += u, l++;
725
725
  }
726
726
  return i;
727
727
  }
@@ -775,16 +775,16 @@ class tt {
775
775
  let o = 0;
776
776
  for (; o < s.length; ) {
777
777
  let l = !1;
778
- for (let u = 3; u >= 2; u--) {
779
- const r = s.substr(o, u);
778
+ for (let h = 3; h >= 2; h--) {
779
+ const r = s.substr(o, h);
780
780
  if (e[r]) {
781
- n.push(e[r]), o += u, l = !0;
781
+ n.push(e[r]), o += h, l = !0;
782
782
  break;
783
783
  }
784
784
  }
785
785
  if (!l) {
786
- const u = s[o];
787
- e[u] && n.push(e[u]), o++;
786
+ const h = s[o];
787
+ e[h] && n.push(e[h]), o++;
788
788
  }
789
789
  }
790
790
  }
@@ -1206,11 +1206,11 @@ class nt {
1206
1206
  };
1207
1207
  Object.keys(this.rules).forEach((e) => {
1208
1208
  this.rules[e] = this.rules[e].map((n) => {
1209
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1209
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), h = n.substring(i + 1, s), r = n.substring(s + 1, o), u = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1210
1210
  let c = "";
1211
1211
  c += [...l].map((g) => t[g] || g).join("");
1212
- const d = [...u];
1213
- return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1212
+ const d = [...h];
1213
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), u.length && u.split(" ").forEach((g) => {
1214
1214
  a.visemes.push(g);
1215
1215
  }), a;
1216
1216
  });
@@ -1324,8 +1324,8 @@ class nt {
1324
1324
  */
1325
1325
  convertDecade(t) {
1326
1326
  const e = parseInt(t), n = !isNaN(e) && t.length === 2, i = !isNaN(e) && t.length > 2 && e > 0 && e <= 3e3, s = i && e % 1e3 === 0 ? Math.floor(e / 1e3) : null, o = i && !s ? Math.floor(e / 100) : null, l = n || i ? Math.floor(e % 100 / 10) * 10 : null;
1327
- let u = [];
1328
- return s ? u.push(this.convertNumberToWords(s).trim(), "thousands") : (o && u.push(this.convertNumberToWords(o).trim()), l ? u.push(this.decades[l] || this.convertNumberToWords(l).trim() + "s") : o ? u.push("hundreds") : u.push(t)), u.join(" ");
1327
+ let h = [];
1328
+ return s ? h.push(this.convertNumberToWords(s).trim(), "thousands") : (o && h.push(this.convertNumberToWords(o).trim()), l ? h.push(this.decades[l] || this.convertNumberToWords(l).trim() + "s") : o ? h.push("hundreds") : h.push(t)), h.join(" ");
1329
1329
  }
1330
1330
  /**
1331
1331
  * Convert ordinal number to text.
@@ -1376,9 +1376,9 @@ class nt {
1376
1376
  const s = i[e.i], o = this.rules[s];
1377
1377
  if (o)
1378
1378
  for (let l = 0; l < o.length; l++) {
1379
- const u = o[l];
1380
- if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(u.regex)) {
1381
- u.visemes.forEach((a) => {
1379
+ const h = o[l];
1380
+ if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(h.regex)) {
1381
+ h.visemes.forEach((a) => {
1382
1382
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === a) {
1383
1383
  const c = 0.7 * (this.visemeDurations[a] || 1);
1384
1384
  e.durations[e.durations.length - 1] += c, n += c;
@@ -1386,7 +1386,7 @@ class nt {
1386
1386
  const c = this.visemeDurations[a] || 1;
1387
1387
  e.visemes.push(a), e.times.push(n), e.durations.push(c), n += c;
1388
1388
  }
1389
- }), e.i += u.move;
1389
+ }), e.i += h.move;
1390
1390
  break;
1391
1391
  }
1392
1392
  }
@@ -1616,11 +1616,11 @@ class ot {
1616
1616
  };
1617
1617
  Object.keys(this.rules).forEach((e) => {
1618
1618
  this.rules[e] = this.rules[e].map((n) => {
1619
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1619
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), h = n.substring(i + 1, s), r = n.substring(s + 1, o), u = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1620
1620
  let c = "";
1621
1621
  c += [...l].map((g) => t[g] || g).join("");
1622
- const d = [...u];
1623
- return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1622
+ const d = [...h];
1623
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), u.length && u.split(" ").forEach((g) => {
1624
1624
  a.visemes.push(g);
1625
1625
  }), a;
1626
1626
  });
@@ -1732,8 +1732,8 @@ class ot {
1732
1732
  const s = i[e.i], o = this.rules[s];
1733
1733
  if (o) {
1734
1734
  let l = !1;
1735
- for (let u = 0; u < o.length; u++) {
1736
- const r = o[u];
1735
+ for (let h = 0; h < o.length; h++) {
1736
+ const r = o[h];
1737
1737
  if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(r.regex)) {
1738
1738
  r.visemes.forEach((c) => {
1739
1739
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
@@ -2131,11 +2131,11 @@ class at {
2131
2131
  };
2132
2132
  Object.keys(this.rules).forEach((e) => {
2133
2133
  this.rules[e] = this.rules[e].map((n) => {
2134
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
2134
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), h = n.substring(i + 1, s), r = n.substring(s + 1, o), u = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
2135
2135
  let c = "";
2136
2136
  c += [...l].map((g) => t[g] || g).join("");
2137
- const d = [...u];
2138
- return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c, "i"), h.length && h.split(" ").forEach((g) => {
2137
+ const d = [...h];
2138
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c, "i"), u.length && u.split(" ").forEach((g) => {
2139
2139
  g && a.visemes.push(g);
2140
2140
  }), a;
2141
2141
  });
@@ -2267,8 +2267,8 @@ class at {
2267
2267
  const s = i[e.i], o = this.rules[s];
2268
2268
  if (o) {
2269
2269
  let l = !1;
2270
- for (let u = 0; u < o.length; u++) {
2271
- const r = o[u];
2270
+ for (let h = 0; h < o.length; h++) {
2271
+ const r = o[h];
2272
2272
  if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(r.regex)) {
2273
2273
  r.visemes.forEach((c) => {
2274
2274
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
@@ -2381,10 +2381,10 @@ class lt {
2381
2381
  const e = [];
2382
2382
  let n = parseFloat(t);
2383
2383
  if (n === void 0) return t;
2384
- let i = (s, o, l, u, r) => {
2384
+ let i = (s, o, l, h, r) => {
2385
2385
  if (s < o) return s;
2386
- const h = Math.floor(s / o);
2387
- return e.push(l + (h === 1 ? u : this.numberToFinnishWords(h.toString()) + r)), s - h * o;
2386
+ const u = Math.floor(s / o);
2387
+ return e.push(l + (u === 1 ? h : this.numberToFinnishWords(u.toString()) + r)), s - u * o;
2388
2388
  };
2389
2389
  if (n < 0 && (e.push("miinus "), n = Math.abs(n)), n = i(n, 1e9, " ", "miljardi", " miljardia"), n = i(n, 1e6, " ", "miljoona", " miljoonaa"), n = i(n, 1e3, "", "tuhat", "tuhatta"), n = i(n, 100, " ", "sata", "sataa"), n > 20 && (n = i(n, 10, "", "", "kymmentä")), n >= 1) {
2390
2390
  let s = Math.floor(n);
@@ -2436,11 +2436,11 @@ class lt {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
2441
  LipsyncFi: lt
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class ut {
2443
+ class ht {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2559,10 +2559,10 @@ class ut {
2559
2559
  const e = [];
2560
2560
  let n = parseFloat(t);
2561
2561
  if (n === void 0) return t;
2562
- let i = (s, o, l, u, r) => {
2562
+ let i = (s, o, l, h, r) => {
2563
2563
  if (s < o) return s;
2564
- const h = Math.floor(s / o);
2565
- return h === 1 ? e.push(this.numbers[1]) : e.push(this.numberToLithuanianWords(h.toString())), h % 10 === 1 ? e.push(l) : h % 10 === 0 || h % 100 > 10 && h % 100 < 20 ? e.push(r) : e.push(u), s - h * o;
2564
+ const u = Math.floor(s / o);
2565
+ return u === 1 ? e.push(this.numbers[1]) : e.push(this.numberToLithuanianWords(u.toString())), u % 10 === 1 ? e.push(l) : u % 10 === 0 || u % 100 > 10 && u % 100 < 20 ? e.push(r) : e.push(h), s - u * o;
2566
2566
  };
2567
2567
  n < 0 && (e.push("minus"), n = Math.abs(n)), n = i(n, 1e9, "milijardas", "milijardai", "milijardų"), n = i(n, 1e6, "milijonas", "milijonai", "milijonų"), n = i(n, 1e3, "tūkstantis", "tūkstančiai", "tūkstančių"), n = i(n, 100, "šimtas", "šimtai", "šimtų");
2568
2568
  for (let s = this.tens.length - 1; s >= 1; s--)
@@ -2608,11 +2608,11 @@ class ut {
2608
2608
  const o = i[s].toLowerCase(), l = this.visemes[o];
2609
2609
  if (l)
2610
2610
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === l) {
2611
- const u = 0.7 * (this.durations[o] || 1);
2612
- e.durations[e.durations.length - 1] += u, n += u;
2611
+ const h = 0.7 * (this.durations[o] || 1);
2612
+ e.durations[e.durations.length - 1] += h, n += h;
2613
2613
  } else {
2614
- const u = this.durations[o] || 1;
2615
- e.visemes.push(l), e.times.push(n), e.durations.push(u), n += u;
2614
+ const h = this.durations[o] || 1;
2615
+ e.visemes.push(l), e.times.push(n), e.durations.push(h), n += h;
2616
2616
  }
2617
2617
  else
2618
2618
  n += this.pauses[i[s]] || 0;
@@ -2622,22 +2622,22 @@ class ut {
2622
2622
  }
2623
2623
  const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: ut
2626
- }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25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aHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1Z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AgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Pe = {
2625
+ LipsyncLt: ht
2626
+ }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5f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1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYS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YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Ue = {
2627
2627
  en: it,
2628
2628
  de: st,
2629
2629
  fr: rt,
2630
- fi: ht,
2630
+ fi: ut,
2631
2631
  lt: ct
2632
- }, G = new f.Quaternion(), E = new f.Euler(), ce = new f.Vector3(), pe = new f.Vector3(), Be = new f.Box3();
2633
- new f.Matrix4();
2634
- new f.Matrix4();
2635
- new f.Vector3();
2636
- new f.Vector3(0, 0, 1);
2637
- const mt = new f.Vector3(1, 0, 0);
2638
- new f.Vector3(0, 1, 0);
2639
- new f.Vector3(0, 0, 1);
2640
- class Ne {
2632
+ }, Q = new x.Quaternion(), W = new x.Euler(), ve = new x.Vector3(), Re = new x.Vector3(), We = new x.Box3();
2633
+ new x.Matrix4();
2634
+ new x.Matrix4();
2635
+ new x.Vector3();
2636
+ new x.Vector3(0, 0, 1);
2637
+ const mt = new x.Vector3(1, 0, 0);
2638
+ new x.Vector3(0, 1, 0);
2639
+ new x.Vector3(0, 0, 1);
2640
+ class Be {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -2763,7 +2763,7 @@ class Ne {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new _e(), 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 Ke(), 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: {
@@ -3569,15 +3569,15 @@ class Ne {
3569
3569
  "RightArm.scale": { x: 0, y: 0, z: 0 }
3570
3570
  }
3571
3571
  }, ["Left", "Right"].forEach((l) => {
3572
- ["Leg", "UpLeg", "Arm", "ForeArm", "Hand"].forEach((u) => {
3573
- this.poseDelta.props[l + u + ".quaternion"] = { x: 0, y: 0, z: 0 };
3574
- }), ["HandThumb", "HandIndex", "HandMiddle", "HandRing", "HandPinky"].forEach((u) => {
3575
- this.poseDelta.props[l + u + "1.quaternion"] = { x: 0, y: 0, z: 0 }, this.poseDelta.props[l + u + "2.quaternion"] = { x: 0, y: 0, z: 0 }, this.poseDelta.props[l + u + "3.quaternion"] = { x: 0, y: 0, z: 0 };
3572
+ ["Leg", "UpLeg", "Arm", "ForeArm", "Hand"].forEach((h) => {
3573
+ this.poseDelta.props[l + h + ".quaternion"] = { x: 0, y: 0, z: 0 };
3574
+ }), ["HandThumb", "HandIndex", "HandMiddle", "HandRing", "HandPinky"].forEach((h) => {
3575
+ this.poseDelta.props[l + h + "1.quaternion"] = { x: 0, y: 0, z: 0 }, this.poseDelta.props[l + h + "2.quaternion"] = { x: 0, y: 0, z: 0 }, this.poseDelta.props[l + h + "3.quaternion"] = { x: 0, y: 0, z: 0 };
3576
3576
  });
3577
3577
  });
3578
3578
  const n = /* @__PURE__ */ new Set();
3579
3579
  Object.values(this.poseTemplates).forEach((l) => {
3580
- Object.keys(this.propsToThreeObjects(l.props)).forEach((u) => n.add(u));
3580
+ Object.keys(this.propsToThreeObjects(l.props)).forEach((h) => n.add(h));
3581
3581
  }), Object.keys(this.poseDelta.props).forEach((l) => {
3582
3582
  n.add(l);
3583
3583
  }), this.posePropNames = [...n], this.poseName = "side", this.poseWeightOnLeft = !0, this.gesture = null, this.poseCurrentTemplate = this.poseTemplates[this.poseName], this.poseStraight = this.propsToThreeObjects(this.poseTemplates.straight.props), this.poseBase = this.poseFactory(this.poseCurrentTemplate), this.poseTarget = this.poseFactory(this.poseCurrentTemplate), this.poseAvatar = null, this.avatarHeight = 1.7, this.animTemplateEyes = {
@@ -4049,22 +4049,22 @@ class Ne {
4049
4049
  if (this.isAvatarOnly = this.opt.avatarOnly, this.isAvatarOnly)
4050
4050
  this.scene = this.opt.avatarOnlyScene, this.camera = this.opt.avatarOnlyCamera;
4051
4051
  else {
4052
- this.renderer = new f.WebGLRenderer({ antialias: !0, alpha: !0 }), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.renderer.outputColorSpace = f.SRGBColorSpace, this.renderer.toneMapping = f.ACESFilmicToneMapping, this.renderer.shadowMap.enabled = !1, this.nodeAvatar.appendChild(this.renderer.domElement), this.camera = new f.PerspectiveCamera(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2e3), this.scene = new f.Scene(), this.lightAmbient = new f.AmbientLight(
4053
- new f.Color(this.opt.lightAmbientColor),
4052
+ this.renderer = new x.WebGLRenderer({ antialias: !0, alpha: !0 }), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.renderer.outputColorSpace = x.SRGBColorSpace, this.renderer.toneMapping = x.ACESFilmicToneMapping, this.renderer.shadowMap.enabled = !1, this.nodeAvatar.appendChild(this.renderer.domElement), this.camera = new x.PerspectiveCamera(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2e3), this.scene = new x.Scene(), this.lightAmbient = new x.AmbientLight(
4053
+ new x.Color(this.opt.lightAmbientColor),
4054
4054
  this.opt.lightAmbientIntensity
4055
- ), this.lightDirect = new f.DirectionalLight(
4056
- new f.Color(this.opt.lightDirectColor),
4055
+ ), this.lightDirect = new x.DirectionalLight(
4056
+ new x.Color(this.opt.lightDirectColor),
4057
4057
  this.opt.lightDirectIntensity
4058
- ), this.lightSpot = new f.SpotLight(
4059
- new f.Color(this.opt.lightSpotColor),
4058
+ ), this.lightSpot = new x.SpotLight(
4059
+ new x.Color(this.opt.lightSpotColor),
4060
4060
  this.opt.lightSpotIntensity,
4061
4061
  0,
4062
4062
  this.opt.lightSpotDispersion
4063
4063
  ), this.setLighting(this.opt);
4064
- const l = new f.PMREMGenerator(this.renderer);
4064
+ const l = new x.PMREMGenerator(this.renderer);
4065
4065
  l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new qe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ye(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
- this.ikMesh = new f.SkinnedMesh();
4067
+ this.ikMesh = new x.SkinnedMesh();
4068
4068
  const s = {
4069
4069
  LeftShoulder: null,
4070
4070
  LeftArm: "LeftShoulder",
@@ -4077,10 +4077,10 @@ class Ne {
4077
4077
  RightHand: "RightForeArm",
4078
4078
  RightHandMiddle1: "RightHand"
4079
4079
  }, o = [];
4080
- Object.entries(s).forEach((l, u) => {
4081
- const r = new f.Bone();
4080
+ Object.entries(s).forEach((l, h) => {
4081
+ const r = new x.Bone();
4082
4082
  r.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(r) : this.ikMesh.add(r), o.push(r);
4083
- }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new et(), 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 x.Skeleton(o)), this.dynamicbones = new et(), 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.
@@ -4126,9 +4126,9 @@ class Ne {
4126
4126
  let e = 3 * t.length / 4;
4127
4127
  t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
4128
4128
  const n = new ArrayBuffer(e), i = new Uint8Array(n);
4129
- let s, o = 0, l, u, r, h;
4129
+ let s, o = 0, l, h, r, u;
4130
4130
  for (s = 0; s < t.length; s += 4)
4131
- l = this.b64Lookup[t.charCodeAt(s)], u = this.b64Lookup[t.charCodeAt(s + 1)], r = this.b64Lookup[t.charCodeAt(s + 2)], h = this.b64Lookup[t.charCodeAt(s + 3)], i[o++] = l << 2 | u >> 4, i[o++] = (u & 15) << 4 | r >> 2, i[o++] = (r & 3) << 6 | h & 63;
4131
+ l = this.b64Lookup[t.charCodeAt(s)], h = this.b64Lookup[t.charCodeAt(s + 1)], r = this.b64Lookup[t.charCodeAt(s + 2)], u = this.b64Lookup[t.charCodeAt(s + 3)], i[o++] = l << 2 | h >> 4, i[o++] = (h & 15) << 4 | r >> 2, i[o++] = (r & 3) << 6 | u & 63;
4132
4132
  return n;
4133
4133
  }
4134
4134
  /**
@@ -4169,8 +4169,8 @@ class Ne {
4169
4169
  const e = {};
4170
4170
  for (let [n, i] of Object.entries(t)) {
4171
4171
  const s = n.split(".");
4172
- let o = Array.isArray(i.x) ? this.gaussianRandom(...i.x) : i.x, l = Array.isArray(i.y) ? this.gaussianRandom(...i.y) : i.y, u = Array.isArray(i.z) ? this.gaussianRandom(...i.z) : i.z;
4173
- s[1] === "position" || s[1] === "scale" ? e[n] = new f.Vector3(o, l, u) : s[1] === "rotation" ? (n = s[0] + ".quaternion", e[n] = new f.Quaternion().setFromEuler(new f.Euler(o, l, u, "XYZ")).normalize()) : s[1] === "quaternion" && (e[n] = new f.Quaternion(o, l, u, i.w).normalize());
4172
+ let o = Array.isArray(i.x) ? this.gaussianRandom(...i.x) : i.x, l = Array.isArray(i.y) ? this.gaussianRandom(...i.y) : i.y, h = Array.isArray(i.z) ? this.gaussianRandom(...i.z) : i.z;
4173
+ s[1] === "position" || s[1] === "scale" ? e[n] = new x.Vector3(o, l, h) : s[1] === "rotation" ? (n = s[0] + ".quaternion", e[n] = new x.Quaternion().setFromEuler(new x.Euler(o, l, h, "XYZ")).normalize()) : s[1] === "quaternion" && (e[n] = new x.Quaternion(o, l, h, i.w).normalize());
4174
4174
  }
4175
4175
  return e;
4176
4176
  }
@@ -4198,23 +4198,23 @@ class Ne {
4198
4198
  t.forEach((s) => {
4199
4199
  if (!i && s.morphTargetDictionary.hasOwnProperty(e)) return;
4200
4200
  const o = s.geometry;
4201
- let l = null, u = null;
4202
- for (const [r, h] of Object.entries(n))
4201
+ let l = null, h = null;
4202
+ for (const [r, u] of Object.entries(n))
4203
4203
  if (s.morphTargetDictionary.hasOwnProperty(r)) {
4204
4204
  const a = s.morphTargetDictionary[r], c = o.morphAttributes.position[a], d = o.morphAttributes.normal?.[a];
4205
- l || (l = new f.Float32BufferAttribute(c.count * 3, 3), d && (u = new f.Float32BufferAttribute(c.count * 3, 3)));
4205
+ l || (l = new x.Float32BufferAttribute(c.count * 3, 3), d && (h = new x.Float32BufferAttribute(c.count * 3, 3)));
4206
4206
  for (let g = 0; g < c.count; g++) {
4207
- const y = l.getX(g) + c.getX(g) * h, x = l.getY(g) + c.getY(g) * h, v = l.getZ(g) + c.getZ(g) * h;
4208
- l.setXYZ(g, y, x, v);
4207
+ const y = l.getX(g) + c.getX(g) * u, b = l.getY(g) + c.getY(g) * u, I = l.getZ(g) + c.getZ(g) * u;
4208
+ l.setXYZ(g, y, b, I);
4209
4209
  }
4210
4210
  if (d)
4211
4211
  for (let g = 0; g < c.count; g++) {
4212
- const y = u.getX(g) + d.getX(g) * h, x = u.getY(g) + d.getY(g) * h, v = u.getZ(g) + d.getZ(g) * h;
4213
- u.setXYZ(g, y, x, v);
4212
+ const y = h.getX(g) + d.getX(g) * u, b = h.getY(g) + d.getY(g) * u, I = h.getZ(g) + d.getZ(g) * u;
4213
+ h.setXYZ(g, y, b, I);
4214
4214
  }
4215
4215
  }
4216
4216
  if (l) {
4217
- o.morphAttributes.position.push(l), u && o.morphAttributes.normal.push(u);
4217
+ o.morphAttributes.position.push(l), h && o.morphAttributes.normal.push(h);
4218
4218
  const r = o.morphAttributes.position.length - 1;
4219
4219
  s.morphTargetInfluences[r] = 0, s.morphTargetDictionary[e] = r;
4220
4220
  }
@@ -4244,7 +4244,7 @@ class Ne {
4244
4244
  throw new Error("Blend shapes not found");
4245
4245
  const o = new Set(this.mtCustoms);
4246
4246
  this.morphs.forEach((r) => {
4247
- Object.keys(r.morphTargetDictionary).forEach((h) => o.add(h));
4247
+ Object.keys(r.morphTargetDictionary).forEach((u) => o.add(u));
4248
4248
  }), this.mtExtras.forEach((r) => {
4249
4249
  o.has(r.key) || (this.addMixedMorphTarget(this.morphs, r.key, r.mix), o.add(r.key));
4250
4250
  });
@@ -4271,16 +4271,16 @@ class Ne {
4271
4271
  ms: [],
4272
4272
  is: []
4273
4273
  }, l[r].value = l[r].baseline, l[r].applied = l[r].baseline;
4274
- const h = this.mtAvatar[r];
4275
- h && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((a) => {
4276
- l[r][a] = h[a];
4274
+ const u = this.mtAvatar[r];
4275
+ u && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((a) => {
4276
+ l[r][a] = u[a];
4277
4277
  }), this.morphs.forEach((a) => {
4278
4278
  const c = a.morphTargetDictionary[r];
4279
4279
  c !== void 0 && (l[r].ms.push(a.morphTargetInfluences), l[r].is.push(c), a.morphTargetInfluences[c] = l[r].applied);
4280
4280
  });
4281
4281
  }), this.mtAvatar = l, this.poseAvatar = { props: {} }, this.posePropNames.forEach((r) => {
4282
- const h = r.split("."), a = this.armature.getObjectByName(h[0]);
4283
- this.poseAvatar.props[r] = a[h[1]], this.poseBase.props.hasOwnProperty(r) ? this.poseAvatar.props[r].copy(this.poseBase.props[r]) : this.poseBase.props[r] = this.poseAvatar.props[r].clone(), this.poseDelta.props.hasOwnProperty(r) && !this.poseTarget.props.hasOwnProperty(r) && (this.poseTarget.props[r] = this.poseAvatar.props[r].clone()), this.poseTarget.props[r].t = this.animClock, this.poseTarget.props[r].d = 2e3;
4282
+ const u = r.split("."), a = this.armature.getObjectByName(u[0]);
4283
+ this.poseAvatar.props[r] = a[u[1]], this.poseBase.props.hasOwnProperty(r) ? this.poseAvatar.props[r].copy(this.poseBase.props[r]) : this.poseBase.props[r] = this.poseAvatar.props[r].clone(), this.poseDelta.props.hasOwnProperty(r) && !this.poseTarget.props.hasOwnProperty(r) && (this.poseTarget.props[r] = this.poseAvatar.props[r].clone()), this.poseTarget.props[r].t = this.animClock, this.poseTarget.props[r].d = 2e3;
4284
4284
  }), this.ikMesh.traverse((r) => {
4285
4285
  r.isBone && r.position.copy(this.armature.getObjectByName(r.name).position);
4286
4286
  }), this.isAvatarOnly ? this.scene && this.scene.add(this.armature) : (this.scene.add(i.scene), this.scene.add(this.lightAmbient), this.scene.add(this.lightDirect), this.scene.add(this.lightSpot), this.lightSpot.target = this.armature.getObjectByName("Head")), t.hasOwnProperty("modelDynamicBones"))
@@ -4290,8 +4290,8 @@ class Ne {
4290
4290
  console.error("Dynamic bones setup failed: " + r);
4291
4291
  }
4292
4292
  this.objectLeftToeBase = this.armature.getObjectByName("LeftToeBase"), this.objectRightToeBase = this.armature.getObjectByName("RightToeBase"), this.objectLeftEye = this.armature.getObjectByName("LeftEye"), this.objectRightEye = this.armature.getObjectByName("RightEye"), this.objectLeftArm = this.armature.getObjectByName("LeftArm"), this.objectRightArm = this.armature.getObjectByName("RightArm"), this.objectHips = this.armature.getObjectByName("Hips"), this.objectHead = this.armature.getObjectByName("Head"), this.objectNeck = this.armature.getObjectByName("Neck");
4293
- const u = new f.Vector3();
4294
- this.objectLeftEye.getWorldPosition(u), this.avatarHeight = u.y + 0.2, this.viewName || this.setView(this.opt.cameraView), this.setMood(this.avatar.avatarMood || this.moodName || this.opt.avatarMood), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
4293
+ const h = new x.Vector3();
4294
+ this.objectLeftEye.getWorldPosition(h), this.avatarHeight = h.y + 0.2, this.viewName || this.setView(this.opt.cameraView), this.setMood(this.avatar.avatarMood || this.moodName || this.opt.avatarMood), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
4295
4295
  }
4296
4296
  /**
4297
4297
  * Get view names.
@@ -4319,29 +4319,29 @@ class Ne {
4319
4319
  return;
4320
4320
  }
4321
4321
  if (this.viewName = t || this.viewName, e = e || {}, this.isAvatarOnly) return;
4322
- const n = e.hasOwnProperty("cameraX") ? e.cameraX : this.opt.cameraX, i = e.hasOwnProperty("cameraY") ? e.cameraY : this.opt.cameraY, s = e.hasOwnProperty("cameraDistance") ? e.cameraDistance : this.opt.cameraDistance, o = e.hasOwnProperty("cameraRotateX") ? e.cameraRotateX : this.opt.cameraRotateX, l = e.hasOwnProperty("cameraRotateY") ? e.cameraRotateY : this.opt.cameraRotateY, u = this.camera.fov * (Math.PI / 180);
4323
- let r = -n * Math.tan(u / 2), h = (1 - i) * Math.tan(u / 2), a = s;
4322
+ const n = e.hasOwnProperty("cameraX") ? e.cameraX : this.opt.cameraX, i = e.hasOwnProperty("cameraY") ? e.cameraY : this.opt.cameraY, s = e.hasOwnProperty("cameraDistance") ? e.cameraDistance : this.opt.cameraDistance, o = e.hasOwnProperty("cameraRotateX") ? e.cameraRotateX : this.opt.cameraRotateX, l = e.hasOwnProperty("cameraRotateY") ? e.cameraRotateY : this.opt.cameraRotateY, h = this.camera.fov * (Math.PI / 180);
4323
+ let r = -n * Math.tan(h / 2), u = (1 - i) * Math.tan(h / 2), a = s;
4324
4324
  switch (this.viewName) {
4325
4325
  case "head":
4326
- a += 2, h = h * a + 4 * this.avatarHeight / 5;
4326
+ a += 2, u = u * a + 4 * this.avatarHeight / 5;
4327
4327
  break;
4328
4328
  case "upper":
4329
- a += 4.5, h = h * a + 2 * this.avatarHeight / 3;
4329
+ a += 4.5, u = u * a + 2 * this.avatarHeight / 3;
4330
4330
  break;
4331
4331
  case "mid":
4332
- a += 8, h = h * a + this.avatarHeight / 3;
4332
+ a += 8, u = u * a + this.avatarHeight / 3;
4333
4333
  break;
4334
4334
  default:
4335
- a += 12, h = h * a;
4335
+ a += 12, u = u * a;
4336
4336
  }
4337
- r = r * a, this.controlsEnd = new f.Vector3(r, h, 0), this.cameraEnd = new f.Vector3(r, h, a).applyEuler(new f.Euler(o, l, 0)), this.cameraClock === null && (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)), this.controlsStart = this.controls.target.clone(), this.cameraStart = this.camera.position.clone(), this.cameraClock = 0;
4337
+ r = r * a, this.controlsEnd = new x.Vector3(r, u, 0), this.cameraEnd = new x.Vector3(r, u, a).applyEuler(new x.Euler(o, l, 0)), this.cameraClock === null && (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)), this.controlsStart = this.controls.target.clone(), this.cameraStart = this.camera.position.clone(), this.cameraClock = 0;
4338
4338
  }
4339
4339
  /**
4340
4340
  * Change light colors and intensities.
4341
4341
  * @param {Object} opt Options
4342
4342
  */
4343
4343
  setLighting(t) {
4344
- this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new f.Color(t.lightAmbientColor)), t.hasOwnProperty("lightAmbientIntensity") && (this.lightAmbient.intensity = t.lightAmbientIntensity, this.lightAmbient.visible = t.lightAmbientIntensity !== 0), t.hasOwnProperty("lightDirectColor") && this.lightDirect.color.set(new f.Color(t.lightDirectColor)), t.hasOwnProperty("lightDirectIntensity") && (this.lightDirect.intensity = t.lightDirectIntensity, this.lightDirect.visible = t.lightDirectIntensity !== 0), t.hasOwnProperty("lightDirectPhi") && t.hasOwnProperty("lightDirectTheta") && this.lightDirect.position.setFromSphericalCoords(2, t.lightDirectPhi, t.lightDirectTheta), t.hasOwnProperty("lightSpotColor") && this.lightSpot.color.set(new f.Color(t.lightSpotColor)), t.hasOwnProperty("lightSpotIntensity") && (this.lightSpot.intensity = t.lightSpotIntensity, this.lightSpot.visible = t.lightSpotIntensity !== 0), t.hasOwnProperty("lightSpotPhi") && t.hasOwnProperty("lightSpotTheta") && (this.lightSpot.position.setFromSphericalCoords(2, t.lightSpotPhi, t.lightSpotTheta), this.lightSpot.position.add(new f.Vector3(0, 1.5, 0))), t.hasOwnProperty("lightSpotDispersion") && (this.lightSpot.angle = t.lightSpotDispersion));
4344
+ this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new x.Color(t.lightAmbientColor)), t.hasOwnProperty("lightAmbientIntensity") && (this.lightAmbient.intensity = t.lightAmbientIntensity, this.lightAmbient.visible = t.lightAmbientIntensity !== 0), t.hasOwnProperty("lightDirectColor") && this.lightDirect.color.set(new x.Color(t.lightDirectColor)), t.hasOwnProperty("lightDirectIntensity") && (this.lightDirect.intensity = t.lightDirectIntensity, this.lightDirect.visible = t.lightDirectIntensity !== 0), t.hasOwnProperty("lightDirectPhi") && t.hasOwnProperty("lightDirectTheta") && this.lightDirect.position.setFromSphericalCoords(2, t.lightDirectPhi, t.lightDirectTheta), t.hasOwnProperty("lightSpotColor") && this.lightSpot.color.set(new x.Color(t.lightSpotColor)), t.hasOwnProperty("lightSpotIntensity") && (this.lightSpot.intensity = t.lightSpotIntensity, this.lightSpot.visible = t.lightSpotIntensity !== 0), t.hasOwnProperty("lightSpotPhi") && t.hasOwnProperty("lightSpotTheta") && (this.lightSpot.position.setFromSphericalCoords(2, t.lightSpotPhi, t.lightSpotTheta), this.lightSpot.position.add(new x.Vector3(0, 1.5, 0))), t.hasOwnProperty("lightSpotDispersion") && (this.lightSpot.angle = t.lightSpotDispersion));
4345
4345
  }
4346
4346
  /**
4347
4347
  * Render scene.
@@ -4374,9 +4374,9 @@ class Ne {
4374
4374
  updatePoseDelta() {
4375
4375
  for (const [t, e] of Object.entries(this.poseDelta.props)) {
4376
4376
  if (e.x === 0 && e.y === 0 && e.z === 0) continue;
4377
- E.set(e.x, e.y, e.z);
4377
+ W.set(e.x, e.y, e.z);
4378
4378
  const n = this.poseAvatar.props[t];
4379
- n.isQuaternion ? (G.setFromEuler(E), n.multiply(G)) : n.isVector3 && n.add(E);
4379
+ n.isQuaternion ? (Q.setFromEuler(W), n.multiply(Q)) : n.isVector3 && n.add(W);
4380
4380
  }
4381
4381
  }
4382
4382
  /**
@@ -4431,17 +4431,17 @@ class Ne {
4431
4431
  "HandMiddle",
4432
4432
  "HandRing",
4433
4433
  "HandPinky"
4434
- ].forEach((h, a) => {
4435
- a === 0 ? (this.poseDelta.props[o + h + "1.quaternion"].x = 0, this.poseDelta.props[o + h + "2.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied, this.poseDelta.props[o + h + "3.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied) : (this.poseDelta.props[o + h + "1.quaternion"].x = n.applied, this.poseDelta.props[o + h + "2.quaternion"].x = 1.5 * n.applied, this.poseDelta.props[o + h + "3.quaternion"].x = 1.5 * n.applied);
4434
+ ].forEach((u, a) => {
4435
+ a === 0 ? (this.poseDelta.props[o + u + "1.quaternion"].x = 0, this.poseDelta.props[o + u + "2.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied, this.poseDelta.props[o + u + "3.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied) : (this.poseDelta.props[o + u + "1.quaternion"].x = n.applied, this.poseDelta.props[o + u + "2.quaternion"].x = 1.5 * n.applied, this.poseDelta.props[o + u + "3.quaternion"].x = 1.5 * n.applied);
4436
4436
  });
4437
4437
  break;
4438
4438
  case "chestInhale":
4439
- const l = n.applied / 20, u = { x: l, y: l / 2, z: 3 * l }, r = { x: 1 / (1 + l) - 1, y: 1 / (1 + l / 2) - 1, z: 1 / (1 + 3 * l) - 1 };
4440
- this.poseDelta.props["Spine1.scale"] = u, this.poseDelta.props["Neck.scale"] = r, this.poseDelta.props["LeftArm.scale"] = r, this.poseDelta.props["RightArm.scale"] = r;
4439
+ const l = n.applied / 20, h = { x: l, y: l / 2, z: 3 * l }, r = { x: 1 / (1 + l) - 1, y: 1 / (1 + l / 2) - 1, z: 1 / (1 + 3 * l) - 1 };
4440
+ this.poseDelta.props["Spine1.scale"] = h, this.poseDelta.props["Neck.scale"] = r, this.poseDelta.props["LeftArm.scale"] = r, this.poseDelta.props["RightArm.scale"] = r;
4441
4441
  break;
4442
4442
  default:
4443
- for (let h = 0, a = n.ms.length; h < a; h++)
4444
- n.ms[h][n.is[h]] = n.applied;
4443
+ for (let u = 0, a = n.ms.length; u < a; u++)
4444
+ n.ms[u][n.is[u]] = n.applied;
4445
4445
  }
4446
4446
  }
4447
4447
  }
@@ -4456,8 +4456,8 @@ class Ne {
4456
4456
  return Object.entries(t).forEach((i, s) => {
4457
4457
  const o = i[0].split(".");
4458
4458
  if (o[1] === "position" || o[1] === "rotation" || o[1] === "quaternion") {
4459
- const l = o[1] === "quaternion" ? o[0] + ".rotation" : i[0], u = i[1].isQuaternion ? new f.Euler().setFromQuaternion(i[1]) : i[1];
4460
- n += (s ? ", " : "") + "'" + l + "':{", n += "x:" + Math.round(u.x * e) / e, n += ", y:" + Math.round(u.y * e) / e, n += ", z:" + Math.round(u.z * e) / e, n += "}";
4459
+ const l = o[1] === "quaternion" ? o[0] + ".rotation" : i[0], h = i[1].isQuaternion ? new x.Euler().setFromQuaternion(i[1]) : i[1];
4460
+ n += (s ? ", " : "") + "'" + l + "':{", n += "x:" + Math.round(h.x * e) / e, n += ", y:" + Math.round(h.y * e) / e, n += ", z:" + Math.round(h.z * e) / e, n += "}";
4461
4461
  }
4462
4462
  }), n += "}", n;
4463
4463
  }
@@ -4527,8 +4527,8 @@ class Ne {
4527
4527
  if (n ? (this.poseCurrentTemplate = this.poseTemplates.oneknee, setTimeout(() => {
4528
4528
  this.setPoseFromTemplate(t, e);
4529
4529
  }, o)) : this.poseCurrentTemplate = t || this.poseCurrentTemplate, this.poseTarget = this.poseFactory(this.poseCurrentTemplate, o), this.poseWeightOnLeft = !0, (!i && !s || i && s) && (this.poseTarget.props = this.mirrorPose(this.poseTarget.props), this.poseWeightOnLeft = !this.poseWeightOnLeft), this.gesture)
4530
- for (let [l, u] of Object.entries(this.gesture))
4531
- this.poseTarget.props.hasOwnProperty(l) && (this.poseTarget.props[l].copy(u), this.poseTarget.props[l].t = u.t, this.poseTarget.props[l].d = u.d);
4530
+ for (let [l, h] of Object.entries(this.gesture))
4531
+ this.poseTarget.props.hasOwnProperty(l) && (this.poseTarget.props[l].copy(h), this.poseTarget.props[l].t = h.t, this.poseTarget.props[l].d = h.d);
4532
4532
  Object.keys(this.poseDelta.props).forEach((l) => {
4533
4533
  this.poseTarget.props.hasOwnProperty(l) || (this.poseTarget.props[l] = this.poseBase.props[l].clone(), this.poseTarget.props[l].t = this.animClock, this.poseTarget.props[l].d = o);
4534
4534
  });
@@ -4973,11 +4973,11 @@ class Ne {
4973
4973
  else if (l.hasOwnProperty("alt")) {
4974
4974
  let r = l.alt[0];
4975
4975
  if (l.alt.length > 1) {
4976
- const h = Math.random();
4976
+ const u = Math.random();
4977
4977
  let a = 0;
4978
4978
  for (let c = 0; c < l.alt.length; c++) {
4979
4979
  let d = this.valueFn(l.alt[c].p);
4980
- if (a += d === void 0 ? (1 - a) / (l.alt.length - 1 - c) : d, h < a) {
4980
+ if (a += d === void 0 ? (1 - a) / (l.alt.length - 1 - c) : d, u < a) {
4981
4981
  r = l.alt[c];
4982
4982
  break;
4983
4983
  }
@@ -4986,19 +4986,19 @@ class Ne {
4986
4986
  l = r;
4987
4987
  } else
4988
4988
  break;
4989
- let u = this.valueFn(l.delay) || 0;
4990
- if (Array.isArray(u) && (u = this.gaussianRandom(...u)), l.hasOwnProperty("dt"))
4991
- l.dt.forEach((r, h) => {
4989
+ let h = this.valueFn(l.delay) || 0;
4990
+ if (Array.isArray(h) && (h = this.gaussianRandom(...h)), l.hasOwnProperty("dt"))
4991
+ l.dt.forEach((r, u) => {
4992
4992
  let a = this.valueFn(r);
4993
- Array.isArray(a) && (a = this.gaussianRandom(...a)), o.ts[h + 1] = o.ts[h] + a;
4993
+ Array.isArray(a) && (a = this.gaussianRandom(...a)), o.ts[u + 1] = o.ts[u] + a;
4994
4994
  });
4995
4995
  else {
4996
- let r = Object.values(l.vs).reduce((h, a) => a.length > h ? a.length : h, 0);
4996
+ let r = Object.values(l.vs).reduce((u, a) => a.length > u ? a.length : u, 0);
4997
4997
  o.ts = Array(r + 1).fill(0);
4998
4998
  }
4999
- s ? o.ts = o.ts.map((r) => u + r * n) : o.ts = o.ts.map((r) => this.animClock + u + r * n);
5000
- for (let [r, h] of Object.entries(l.vs)) {
5001
- const a = this.getBaselineValue(r), c = h.map((d) => (d = this.valueFn(d), d === null ? null : typeof d == "function" ? d : typeof d == "string" || d instanceof String ? d.slice() : Array.isArray(d) ? r === "gesture" ? d.slice() : (a === void 0 ? 0 : a) + i * this.gaussianRandom(...d) : typeof d == "boolean" ? d : d instanceof Object && d.constructor === Object ? Object.assign({}, d) : (a === void 0 ? 0 : a) + i * d));
4999
+ s ? o.ts = o.ts.map((r) => h + r * n) : o.ts = o.ts.map((r) => this.animClock + h + r * n);
5000
+ for (let [r, u] of Object.entries(l.vs)) {
5001
+ const a = this.getBaselineValue(r), c = u.map((d) => (d = this.valueFn(d), d === null ? null : typeof d == "function" ? d : typeof d == "string" || d instanceof String ? d.slice() : Array.isArray(d) ? r === "gesture" ? d.slice() : (a === void 0 ? 0 : a) + i * this.gaussianRandom(...d) : typeof d == "boolean" ? d : d instanceof Object && d.constructor === Object ? Object.assign({}, d) : (a === void 0 ? 0 : a) + i * d));
5002
5002
  r === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyeLookInLeft = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookOutRight = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookInRight = [null, ...c.map((d) => d > 0 ? d : 0)]) : r === "eyesRotateX" ? (o.vs.eyesLookDown = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyesLookUp = [null, ...c.map((d) => d > 0 ? 0 : -d)]) : o.vs[r] = [null, ...c];
5003
5003
  }
5004
5004
  for (let r of Object.keys(o.vs))
@@ -5080,8 +5080,8 @@ class Ne {
5080
5080
  if (this.isSpeaking)
5081
5081
  for (l = 0, this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData), n = 2, s = 10; n < s; n++)
5082
5082
  this.volumeFrequencyData[n] > l && (l = this.volumeFrequencyData[n]);
5083
- let u = null, r = null;
5084
- const h = [];
5083
+ let h = null, r = null;
5084
+ const u = [];
5085
5085
  for (n = 0, s = this.animQueue.length; n < s; n++) {
5086
5086
  const a = this.animQueue[n];
5087
5087
  if (!(!a || !a.ts || !a.ts.length || this.animClock < a.ts[0])) {
@@ -5095,8 +5095,8 @@ class Ne {
5095
5095
  else {
5096
5096
  g.newvalue = d[i + 1];
5097
5097
  const y = a.ts[i + 1] - a.ts[i];
5098
- let x = 1;
5099
- y > 1e-4 && (x = (this.animClock - a.ts[i]) / y), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) * d[i] + x * g.newvalue), g.ref && g.ref !== a.vs && g.ref.hasOwnProperty(c) && delete g.ref[c], g.ref = a.vs;
5098
+ let b = 1;
5099
+ y > 1e-4 && (b = (this.animClock - a.ts[i]) / y), b < 1 && (g.easing && (b = g.easing(b)), g.newvalue = (1 - b) * d[i] + b * g.newvalue), g.ref && g.ref !== a.vs && g.ref.hasOwnProperty(c) && delete g.ref[c], g.ref = a.vs;
5100
5100
  }
5101
5101
  if (l)
5102
5102
  switch (c) {
@@ -5108,12 +5108,12 @@ class Ne {
5108
5108
  g.newvalue *= 1 + l / 255 - 0.5;
5109
5109
  }
5110
5110
  g.needsUpdate = !0;
5111
- } else c === "eyeContact" && d[i] !== null && u !== !1 ? u = !!d[i] : c === "headMove" && d[i] !== null && r !== !1 ? d[i] === 0 ? r = !1 : (Math.random() < d[i] && (r = !0), d[i] = null) : d[i] !== null && (h.push({ mt: c, val: d[i] }), d[i] = null);
5111
+ } else c === "eyeContact" && d[i] !== null && h !== !1 ? h = !!d[i] : c === "headMove" && d[i] !== null && r !== !1 ? d[i] === 0 ? r = !1 : (Math.random() < d[i] && (r = !0), d[i] = null) : d[i] !== null && (u.push({ mt: c, val: d[i] }), d[i] = null);
5112
5112
  i === o ? (a.hasOwnProperty("mood") && this.setMood(a.mood), a.loop ? (o = this.isSpeaking && (a.template.name === "head" || a.template.name === "eyes") ? 4 : 1, this.animQueue[n] = this.animFactory(a.template, a.loop > 0 ? a.loop - 1 : a.loop, 1, 1 / o)) : (this.animQueue.splice(n--, 1), s--)) : a.ndx = i - 1;
5113
5113
  }
5114
5114
  }
5115
- for (let a = 0, c = h.length; a < c; a++)
5116
- switch (i = h[a].val, h[a].mt) {
5115
+ for (let a = 0, c = u.length; a < c; a++)
5116
+ switch (i = u[a].val, u[a].mt) {
5117
5117
  case "speak":
5118
5118
  this.speakText(i);
5119
5119
  break;
@@ -5144,7 +5144,7 @@ class Ne {
5144
5144
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
5145
5145
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5146
5146
  ]
5147
- }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5147
+ }, i.x ? new x.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5148
5148
  break;
5149
5149
  case "handRight":
5150
5150
  this.ikSolve({
@@ -5156,10 +5156,10 @@ class Ne {
5156
5156
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2 },
5157
5157
  { link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5158
5158
  ]
5159
- }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5159
+ }, i.x ? new x.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5160
5160
  break;
5161
5161
  }
5162
- if ((u || r) && (E.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), E.x = Math.max(-0.9, Math.min(0.9, 2 * E.x - 0.5)), E.y = Math.max(-0.9, Math.min(0.9, -2.5 * E.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: E.x < 0 ? -E.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: E.x < 0 ? 0 : E.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), r && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5162
+ if ((h || r) && (W.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), W.x = Math.max(-0.9, Math.min(0.9, 2 * W.x - 0.5)), W.y = Math.max(-0.9, Math.min(0.9, -2.5 * W.y)), h ? (Object.assign(this.mtAvatar.eyesLookDown, { system: W.x < 0 ? -W.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: W.x < 0 ? 0 : W.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: W.y < 0 ? -W.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: W.y < 0 ? 0 : W.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: W.y < 0 ? 0 : W.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: W.y < 0 ? -W.y : 0, needsUpdate: !0 }), r && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5163
5163
  name: "headmove",
5164
5164
  dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
5165
5165
  vs: {
@@ -5180,12 +5180,12 @@ class Ne {
5180
5180
  eyeLookOutRight: [null, 0],
5181
5181
  eyeContact: [0]
5182
5182
  }
5183
- })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (G.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(G)), Be.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(pe), pe.sub(this.armature.position), this.objectHips.position.y -= Be.min.y / 2, this.objectHips.position.x -= (ce.x + pe.x) / 4, this.objectHips.position.z -= (ce.z + pe.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5183
+ })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && h ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (Q.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(Q)), We.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ve), ve.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(Re), Re.sub(this.armature.position), this.objectHips.position.y -= We.min.y / 2, this.objectHips.position.x -= (ve.x + Re.x) / 4, this.objectHips.position.z -= (ve.z + Re.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) {
5187
5187
  this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
5188
- let a = new f.Spherical().setFromVector3(this.cameraStart), c = new f.Spherical().setFromVector3(this.cameraEnd);
5188
+ let a = new x.Spherical().setFromVector3(this.cameraStart), c = new x.Spherical().setFromVector3(this.cameraEnd);
5189
5189
  a.phi += this.easing(this.cameraClock / 1e3) * (c.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (c.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (c.radius - a.radius), a.makeSafe(), this.camera.position.setFromSpherical(a), this.controlsStart.x !== this.controlsEnd.x ? this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1e3))) : (a.setFromVector3(this.controlsStart), c.setFromVector3(this.controlsEnd), a.phi += this.easing(this.cameraClock / 1e3) * (c.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (c.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (c.radius - a.radius), a.makeSafe(), this.controls.target.setFromSpherical(a)), this.controls.update();
5190
5190
  }
5191
5191
  this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
@@ -5211,8 +5211,8 @@ class Ne {
5211
5211
  if (!this.lipsync.hasOwnProperty(t)) {
5212
5212
  const n = t.toLowerCase(), i = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5213
5213
  try {
5214
- const s = Pe[n];
5215
- s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Pe));
5214
+ const s = Ue[n];
5215
+ s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Ue));
5216
5216
  } catch (s) {
5217
5217
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5218
5218
  }
@@ -5247,49 +5247,49 @@ class Ne {
5247
5247
  */
5248
5248
  speakText(t, e = null, n = null, i = null) {
5249
5249
  e = e || {};
5250
- const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, o = /[ ]/ug, l = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, u = /[\p{Extended_Pictographic}]/ug, r = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
5251
- let h = "", a = "", c = 0, d = [], g = [];
5252
- const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
5253
- for (let x = 0; x < y.length; x++) {
5254
- const v = x === y.length - 1, B = y[x].match(l);
5255
- let p = y[x].match(s);
5256
- const H = y[x].match(u), z = y[x].match(o);
5257
- if (p && !v && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), B && (!i || i.every((I) => x < I[0] || x > I[1])) && (a += y[x]), (z || p || v) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5250
+ const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, o = /[ ]/ug, l = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, h = /[\p{Extended_Pictographic}]/ug, r = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
5251
+ let u = "", a = "", c = 0, d = [], g = [];
5252
+ const y = Array.from(this.segmenter.segment(t), (b) => b.segment);
5253
+ for (let b = 0; b < y.length; b++) {
5254
+ const I = b === y.length - 1, V = y[b].match(l);
5255
+ let p = y[b].match(s);
5256
+ const M = y[b].match(h), w = y[b].match(o);
5257
+ if (p && !I && !M && y[b + 1].match(s) && (p = !1), n && (u += y[b]), V && (!i || i.every((f) => b < f[0] || b > f[1])) && (a += y[b]), (w || p || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5258
5258
  mark: c,
5259
5259
  word: a
5260
- })), h.length && (g.push({
5260
+ })), u.length && (g.push({
5261
5261
  mark: c,
5262
5262
  template: { name: "subtitles" },
5263
5263
  ts: [0],
5264
5264
  vs: {
5265
- subtitles: [h]
5265
+ subtitles: [u]
5266
5266
  }
5267
- }), h = ""), a.length)) {
5268
- const I = this.lipsyncWordsToVisemes(a, r);
5269
- if (I && I.visemes && I.visemes.length) {
5270
- const T = I.times[I.visemes.length - 1] + I.durations[I.visemes.length - 1];
5271
- for (let F = 0; F < I.visemes.length; F++)
5267
+ }), u = ""), a.length)) {
5268
+ const f = this.lipsyncWordsToVisemes(a, r);
5269
+ if (f && f.visemes && f.visemes.length) {
5270
+ const E = f.times[f.visemes.length - 1] + f.durations[f.visemes.length - 1];
5271
+ for (let P = 0; P < f.visemes.length; P++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(I.times[F] - 0.6) / T, (I.times[F] + 0.5) / T, (I.times[F] + I.durations[F] + 0.5) / T],
5275
+ ts: [(f.times[P] - 0.6) / E, (f.times[P] + 0.5) / E, (f.times[P] + f.durations[P] + 0.5) / E],
5276
5276
  vs: {
5277
- ["viseme_" + I.visemes[F]]: [null, I.visemes[F] === "PP" || I.visemes[F] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + f.visemes[P]]: [null, f.visemes[P] === "PP" || f.visemes[P] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
5281
5281
  a = "", c++;
5282
5282
  }
5283
- if (p || v) {
5284
- if (d.length || v && g.length) {
5285
- const I = {
5283
+ if (p || I) {
5284
+ if (d.length || I && g.length) {
5285
+ const f = {
5286
5286
  anim: g
5287
5287
  };
5288
- n && (I.onSubtitles = n), d.length && !e.avatarMute && (I.text = d, e.avatarMood && (I.mood = e.avatarMood), e.ttsLang && (I.lang = e.ttsLang), e.ttsVoice && (I.voice = e.ttsVoice), e.ttsRate && (I.rate = e.ttsRate), e.ttsVoice && (I.pitch = e.ttsPitch), e.ttsVolume && (I.volume = e.ttsVolume)), this.speechQueue.push(I), d = [], a = "", c = 0, g = [];
5288
+ n && (f.onSubtitles = n), d.length && !e.avatarMute && (f.text = d, e.avatarMood && (f.mood = e.avatarMood), e.ttsLang && (f.lang = e.ttsLang), e.ttsVoice && (f.voice = e.ttsVoice), e.ttsRate && (f.rate = e.ttsRate), e.ttsVoice && (f.pitch = e.ttsPitch), e.ttsVolume && (f.volume = e.ttsVolume)), this.speechQueue.push(f), d = [], a = "", c = 0, g = [];
5289
5289
  }
5290
- if (H) {
5291
- let I = this.animEmojis[y[x]];
5292
- I && I.link && (I = this.animEmojis[I.link]), I && this.speechQueue.push({ emoji: I });
5290
+ if (M) {
5291
+ let f = this.animEmojis[y[b]];
5292
+ f && f.link && (f = this.animEmojis[f.link]), f && this.speechQueue.push({ emoji: f });
5293
5293
  }
5294
5294
  this.speechQueue.push({ break: 100 });
5295
5295
  }
@@ -5370,27 +5370,27 @@ class Ne {
5370
5370
  if (t.words) {
5371
5371
  let o = [];
5372
5372
  for (let l = 0; l < t.words.length; l++) {
5373
- const u = t.words[l], r = t.wtimes[l];
5374
- let h = t.wdurations[l];
5375
- if (u.length && (n && o.push({
5373
+ const h = t.words[l], r = t.wtimes[l];
5374
+ let u = t.wdurations[l];
5375
+ if (h.length && (n && o.push({
5376
5376
  template: { name: "subtitles" },
5377
5377
  ts: [r],
5378
5378
  vs: {
5379
- subtitles: [" " + u]
5379
+ subtitles: [" " + h]
5380
5380
  }
5381
5381
  }), !t.visemes)) {
5382
- const a = this.lipsyncPreProcessText(u, i), c = this.lipsyncWordsToVisemes(a, i);
5382
+ const a = this.lipsyncPreProcessText(h, i), c = this.lipsyncWordsToVisemes(a, i);
5383
5383
  if (c && c.visemes && c.visemes.length) {
5384
- const d = c.times[c.visemes.length - 1] + c.durations[c.visemes.length - 1], g = Math.min(h, Math.max(0, h - c.visemes.length * 150));
5385
- let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5386
- if (h = Math.min(h, c.visemes.length * 200), d > 0)
5387
- for (let x = 0; x < c.visemes.length; x++) {
5388
- const v = r + c.times[x] / d * h, B = c.durations[x] / d * h;
5384
+ const d = c.times[c.visemes.length - 1] + c.durations[c.visemes.length - 1], g = Math.min(u, Math.max(0, u - c.visemes.length * 150));
5385
+ let y = 0.6 + this.convertRange(g, [0, u], [0, 0.4]);
5386
+ if (u = Math.min(u, c.visemes.length * 200), d > 0)
5387
+ for (let b = 0; b < c.visemes.length; b++) {
5388
+ const I = r + c.times[b] / d * u, V = c.durations[b] / d * u;
5389
5389
  o.push({
5390
5390
  template: { name: "viseme" },
5391
- ts: [v - Math.min(60, 2 * B / 3), v + Math.min(25, B / 2), v + B + Math.min(60, B / 2)],
5391
+ ts: [I - Math.min(60, 2 * V / 3), I + Math.min(25, V / 2), I + V + Math.min(60, V / 2)],
5392
5392
  vs: {
5393
- ["viseme_" + c.visemes[x]]: [null, c.visemes[x] === "PP" || c.visemes[x] === "FF" ? 0.9 : y, 0]
5393
+ ["viseme_" + c.visemes[b]]: [null, c.visemes[b] === "PP" || c.visemes[b] === "FF" ? 0.9 : y, 0]
5394
5394
  }
5395
5395
  });
5396
5396
  }
@@ -5399,22 +5399,22 @@ class Ne {
5399
5399
  }
5400
5400
  if (t.visemes)
5401
5401
  for (let l = 0; l < t.visemes.length; l++) {
5402
- const u = t.visemes[l], r = t.vtimes[l], h = t.vdurations[l];
5402
+ const h = t.visemes[l], r = t.vtimes[l], u = t.vdurations[l];
5403
5403
  o.push({
5404
5404
  template: { name: "viseme" },
5405
- ts: [r - 2 * h / 3, r + h / 2, r + h + h / 2],
5405
+ ts: [r - 2 * u / 3, r + u / 2, r + u + u / 2],
5406
5406
  vs: {
5407
- ["viseme_" + u]: [null, u === "PP" || u === "FF" ? 0.9 : 0.6, 0]
5407
+ ["viseme_" + h]: [null, h === "PP" || h === "FF" ? 0.9 : 0.6, 0]
5408
5408
  }
5409
5409
  });
5410
5410
  }
5411
5411
  if (t.markers)
5412
5412
  for (let l = 0; l < t.markers.length; l++) {
5413
- const u = t.markers[l], r = t.mtimes[l];
5413
+ const h = t.markers[l], r = t.mtimes[l];
5414
5414
  o.push({
5415
5415
  template: { name: "markers" },
5416
5416
  ts: [r],
5417
- vs: { function: [u] }
5417
+ vs: { function: [h] }
5418
5418
  });
5419
5419
  }
5420
5420
  o.length && (s.anim = o);
@@ -5434,7 +5434,7 @@ class Ne {
5434
5434
  if (this.isAudioPlaying = !0, this.audioPlaylist.length) {
5435
5435
  const e = this.audioPlaylist.shift();
5436
5436
  if (this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") {
5437
- const s = this.audioCtx.resume(), o = new Promise((l, u) => setTimeout(() => u("p2"), 1e3));
5437
+ const s = this.audioCtx.resume(), o = new Promise((l, h) => setTimeout(() => h("p2"), 1e3));
5438
5438
  try {
5439
5439
  await Promise.race([s, o]);
5440
5440
  } catch {
@@ -5466,38 +5466,38 @@ class Ne {
5466
5466
  */
5467
5467
  async synthesizeWithBrowserTTS(t) {
5468
5468
  return new Promise((e, n) => {
5469
- const i = t.text.map((p) => p.word).join(" "), s = new SpeechSynthesisUtterance(i), o = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", l = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, u = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, r = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5470
- s.lang = o, s.rate = Math.max(0.1, Math.min(10, l)), s.pitch = Math.max(0, Math.min(2, u)), s.volume = Math.max(0, Math.min(1, r));
5471
- const h = speechSynthesis.getVoices(), a = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5472
- if (a && h.length > 0) {
5473
- const p = h.find((H) => H.name.includes(a) || H.lang === o);
5469
+ const i = t.text.map((p) => p.word).join(" "), s = new SpeechSynthesisUtterance(i), o = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", l = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, h = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, r = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5470
+ s.lang = o, s.rate = Math.max(0.1, Math.min(10, l)), s.pitch = Math.max(0, Math.min(2, h)), s.volume = Math.max(0, Math.min(1, r));
5471
+ const u = speechSynthesis.getVoices(), a = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5472
+ if (a && u.length > 0) {
5473
+ const p = u.find((M) => M.name.includes(a) || M.lang === o);
5474
5474
  p && (s.voice = p);
5475
5475
  }
5476
- const c = i.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(i, g), x = this.lipsyncWordsToVisemes(y, g);
5476
+ const c = i.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(i, g), b = this.lipsyncWordsToVisemes(y, g);
5477
5477
  console.log("Browser TTS Lip-sync Debug:", {
5478
5478
  text: i,
5479
5479
  lipsyncLang: g,
5480
5480
  processedText: y,
5481
- lipsyncData: x,
5482
- hasVisemes: x && x.visemes && x.visemes.length > 0,
5481
+ lipsyncData: b,
5482
+ hasVisemes: b && b.visemes && b.visemes.length > 0,
5483
5483
  estimatedDuration: c
5484
5484
  });
5485
- const v = [];
5486
- if (x && x.visemes && x.visemes.length > 0) {
5487
- const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
5488
- for (let H = 0; H < x.visemes.length; H++) {
5489
- const z = x.visemes[H], I = x.times[H] / p, T = x.durations[H] / p, F = I * c, J = T * c;
5490
- v.push({
5485
+ const I = [];
5486
+ if (b && b.visemes && b.visemes.length > 0) {
5487
+ const p = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5488
+ for (let M = 0; M < b.visemes.length; M++) {
5489
+ const w = b.visemes[M], f = b.times[M] / p, E = b.durations[M] / p, P = f * c, U = E * c;
5490
+ I.push({
5491
5491
  template: { name: "viseme" },
5492
- ts: [F - Math.min(60, 2 * J / 3), F + Math.min(25, J / 2), F + J + Math.min(60, J / 2)],
5492
+ ts: [P - Math.min(60, 2 * U / 3), P + Math.min(25, U / 2), P + U + Math.min(60, U / 2)],
5493
5493
  vs: {
5494
- ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5494
+ ["viseme_" + w]: [null, w === "PP" || w === "FF" ? 0.9 : 0.6, 0]
5495
5495
  }
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const B = [...t.anim, ...v];
5500
- this.audioPlaylist.push({ anim: B, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5499
+ const V = [...t.anim, ...I];
5500
+ this.audioPlaylist.push({ anim: V, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5501
5501
  e();
5502
5502
  }, s.onerror = (p) => {
5503
5503
  console.error("Speech synthesis error:", p.error), n(p.error);
@@ -5531,15 +5531,15 @@ class Ne {
5531
5531
  throw new Error(`ElevenLabs TTS error: ${s.status} ${s.statusText}`);
5532
5532
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5533
5533
  console.log("Using text-based lip-sync for debugging...");
5534
- const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5534
+ const h = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5535
5535
  let r;
5536
5536
  try {
5537
5537
  console.log("Lip-sync modules available:", {
5538
5538
  hasLipsync: !!this.lipsync,
5539
5539
  lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
5540
- lipsyncLang: u
5540
+ lipsyncLang: h
5541
5541
  });
5542
- const c = this.lipsyncPreProcessText(e, u), d = this.lipsyncWordsToVisemes(c, u);
5542
+ const c = this.lipsyncPreProcessText(e, h), d = this.lipsyncWordsToVisemes(c, h);
5543
5543
  if (console.log("Lip-sync data:", {
5544
5544
  processedText: c,
5545
5545
  lipsyncData: d,
@@ -5563,15 +5563,15 @@ class Ne {
5563
5563
  console.error("Text-based lip-sync failed, using fallback:", c);
5564
5564
  const d = e.toLowerCase().split(/\s+/), g = [];
5565
5565
  for (const y of d)
5566
- for (const x of y) {
5567
- let v = "aa";
5568
- "aeiou".includes(x) ? v = "aa" : "bp".includes(x) ? v = "PP" : "fv".includes(x) ? v = "FF" : "st".includes(x) ? v = "SS" : "dln".includes(x) ? v = "DD" : "kg".includes(x) ? v = "kk" : "rw".includes(x) && (v = "RR"), g.push(v);
5566
+ for (const b of y) {
5567
+ let I = "aa";
5568
+ "aeiou".includes(b) ? I = "aa" : "bp".includes(b) ? I = "PP" : "fv".includes(b) ? I = "FF" : "st".includes(b) ? I = "SS" : "dln".includes(b) ? I = "DD" : "kg".includes(b) ? I = "kk" : "rw".includes(b) && (I = "RR"), g.push(I);
5569
5569
  }
5570
5570
  r = {
5571
- visemes: g.map((y, x) => ({
5571
+ visemes: g.map((y, b) => ({
5572
5572
  viseme: y,
5573
- startTime: x * l.duration / g.length,
5574
- endTime: (x + 1) * l.duration / g.length,
5573
+ startTime: b * l.duration / g.length,
5574
+ endTime: (b + 1) * l.duration / g.length,
5575
5575
  duration: l.duration / g.length,
5576
5576
  intensity: 0.6
5577
5577
  })),
@@ -5592,24 +5592,24 @@ class Ne {
5592
5592
  visemes: r.visemes ? r.visemes.slice(0, 3) : []
5593
5593
  // Show first 3 visemes for debugging
5594
5594
  });
5595
- const h = [];
5595
+ const u = [];
5596
5596
  if (r.visemes && r.visemes.length > 0) {
5597
5597
  console.log("ElevenLabs: Generating lip-sync animation from", r.visemes.length, "visemes");
5598
5598
  for (let c = 0; c < r.visemes.length; c++) {
5599
- const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5600
- h.push({
5599
+ const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, b = d.intensity;
5600
+ u.push({
5601
5601
  template: { name: "viseme" },
5602
5602
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
5603
5603
  vs: {
5604
- ["viseme_" + d.viseme]: [null, x, 0]
5604
+ ["viseme_" + d.viseme]: [null, b, 0]
5605
5605
  }
5606
5606
  });
5607
5607
  }
5608
- console.log("ElevenLabs: Generated", h.length, "lip-sync animation frames");
5608
+ console.log("ElevenLabs: Generated", u.length, "lip-sync animation frames");
5609
5609
  } else
5610
5610
  console.warn("ElevenLabs: No visemes available for lip-sync animation");
5611
- const a = [...t.anim, ...h];
5612
- console.log("ElevenLabs: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5611
+ const a = [...t.anim, ...u];
5612
+ console.log("ElevenLabs: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", u.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5613
5613
  }
5614
5614
  /**
5615
5615
  * Synthesize speech using Deepgram Aura-2 TTS
@@ -5629,15 +5629,15 @@ class Ne {
5629
5629
  throw new Error(`Deepgram TTS error: ${s.status} ${s.statusText}`);
5630
5630
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5631
5631
  console.log("Using text-based lip-sync for Deepgram...");
5632
- const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5632
+ const h = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5633
5633
  let r;
5634
5634
  try {
5635
5635
  console.log("Lip-sync modules available:", {
5636
5636
  hasLipsync: !!this.lipsync,
5637
5637
  lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
5638
- lipsyncLang: u
5638
+ lipsyncLang: h
5639
5639
  });
5640
- const c = this.lipsyncPreProcessText(e, u), d = this.lipsyncWordsToVisemes(c, u);
5640
+ const c = this.lipsyncPreProcessText(e, h), d = this.lipsyncWordsToVisemes(c, h);
5641
5641
  if (console.log("Lip-sync data:", {
5642
5642
  processedText: c,
5643
5643
  lipsyncData: d,
@@ -5661,15 +5661,15 @@ class Ne {
5661
5661
  console.error("Text-based lip-sync failed, using fallback:", c);
5662
5662
  const d = e.toLowerCase().split(/\s+/), g = [];
5663
5663
  for (const y of d)
5664
- for (const x of y) {
5665
- let v = "aa";
5666
- "aeiou".includes(x) ? v = "aa" : "bp".includes(x) ? v = "PP" : "fv".includes(x) ? v = "FF" : "st".includes(x) ? v = "SS" : "dln".includes(x) ? v = "DD" : "kg".includes(x) ? v = "kk" : "rw".includes(x) && (v = "RR"), g.push(v);
5664
+ for (const b of y) {
5665
+ let I = "aa";
5666
+ "aeiou".includes(b) ? I = "aa" : "bp".includes(b) ? I = "PP" : "fv".includes(b) ? I = "FF" : "st".includes(b) ? I = "SS" : "dln".includes(b) ? I = "DD" : "kg".includes(b) ? I = "kk" : "rw".includes(b) && (I = "RR"), g.push(I);
5667
5667
  }
5668
5668
  r = {
5669
- visemes: g.map((y, x) => ({
5669
+ visemes: g.map((y, b) => ({
5670
5670
  viseme: y,
5671
- startTime: x * l.duration / g.length,
5672
- endTime: (x + 1) * l.duration / g.length,
5671
+ startTime: b * l.duration / g.length,
5672
+ endTime: (b + 1) * l.duration / g.length,
5673
5673
  duration: l.duration / g.length,
5674
5674
  intensity: 0.6
5675
5675
  })),
@@ -5690,24 +5690,24 @@ class Ne {
5690
5690
  visemes: r.visemes ? r.visemes.slice(0, 3) : []
5691
5691
  // Show first 3 visemes for debugging
5692
5692
  });
5693
- const h = [];
5693
+ const u = [];
5694
5694
  if (r.visemes && r.visemes.length > 0) {
5695
5695
  console.log("Deepgram: Generating lip-sync animation from", r.visemes.length, "visemes");
5696
5696
  for (let c = 0; c < r.visemes.length; c++) {
5697
- const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5698
- h.push({
5697
+ const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, b = d.intensity;
5698
+ u.push({
5699
5699
  template: { name: "viseme" },
5700
5700
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
5701
5701
  vs: {
5702
- ["viseme_" + d.viseme]: [null, x, 0]
5702
+ ["viseme_" + d.viseme]: [null, b, 0]
5703
5703
  }
5704
5704
  });
5705
5705
  }
5706
- console.log("Deepgram: Generated", h.length, "lip-sync animation frames");
5706
+ console.log("Deepgram: Generated", u.length, "lip-sync animation frames");
5707
5707
  } else
5708
5708
  console.warn("Deepgram: No visemes available for lip-sync animation");
5709
- const a = [...t.anim, ...h];
5710
- console.log("Deepgram: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5709
+ const a = [...t.anim, ...u];
5710
+ console.log("Deepgram: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", u.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5711
5711
  }
5712
5712
  /**
5713
5713
  * Synthesize speech using Azure TTS
@@ -5733,20 +5733,20 @@ class Ne {
5733
5733
  throw new Error(`Azure TTS error: ${s.status} ${s.statusText}`);
5734
5734
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5735
5735
  console.log("Analyzing audio for precise lip-sync...");
5736
- const u = await this.audioAnalyzer.analyzeAudio(l, e);
5736
+ const h = await this.audioAnalyzer.analyzeAudio(l, e);
5737
5737
  console.log("Azure TTS Audio Analysis:", {
5738
5738
  text: e,
5739
5739
  audioDuration: l.duration,
5740
- visemeCount: u.visemes.length,
5741
- wordCount: u.words.length,
5740
+ visemeCount: h.visemes.length,
5741
+ wordCount: h.words.length,
5742
5742
  features: {
5743
- onsets: u.features.onsets.length,
5744
- boundaries: u.features.phonemeBoundaries.length
5743
+ onsets: h.features.onsets.length,
5744
+ boundaries: h.features.phonemeBoundaries.length
5745
5745
  }
5746
5746
  });
5747
5747
  const r = [];
5748
- for (let a = 0; a < u.visemes.length; a++) {
5749
- const c = u.visemes[a], d = c.startTime * 1e3, g = c.duration * 1e3, y = c.intensity;
5748
+ for (let a = 0; a < h.visemes.length; a++) {
5749
+ const c = h.visemes[a], d = c.startTime * 1e3, g = c.duration * 1e3, y = c.intensity;
5750
5750
  r.push({
5751
5751
  template: { name: "viseme" },
5752
5752
  ts: [d - Math.min(60, 2 * g / 3), d + Math.min(25, g / 2), d + g + Math.min(60, g / 2)],
@@ -5755,8 +5755,8 @@ class Ne {
5755
5755
  }
5756
5756
  });
5757
5757
  }
5758
- const h = [...t.anim, ...r];
5759
- this.audioPlaylist.push({ anim: h, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5758
+ const u = [...t.anim, ...r];
5759
+ this.audioPlaylist.push({ anim: u, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5760
5760
  }
5761
5761
  /**
5762
5762
  * Synthesize speech using external TTS service (Google Cloud, etc.)
@@ -5795,24 +5795,24 @@ class Ne {
5795
5795
  if (i.status === 200 && s && s.audioContent) {
5796
5796
  const o = this.b64ToArrayBuffer(s.audioContent), l = await this.audioCtx.decodeAudioData(o);
5797
5797
  this.speakWithHands();
5798
- const u = [0];
5798
+ const h = [0];
5799
5799
  let r = 0;
5800
5800
  t.text.forEach((c, d) => {
5801
5801
  if (d > 0) {
5802
- let g = u[u.length - 1];
5803
- s.timepoints[r] && (g = s.timepoints[r].timeSeconds * 1e3, s.timepoints[r].markName === "" + c.mark && r++), u.push(g);
5802
+ let g = h[h.length - 1];
5803
+ s.timepoints[r] && (g = s.timepoints[r].timeSeconds * 1e3, s.timepoints[r].markName === "" + c.mark && r++), h.push(g);
5804
5804
  }
5805
5805
  });
5806
- const h = [{ mark: 0, time: 0 }];
5807
- u.forEach((c, d) => {
5806
+ const u = [{ mark: 0, time: 0 }];
5807
+ h.forEach((c, d) => {
5808
5808
  if (d > 0) {
5809
- let g = c - u[d - 1];
5810
- h[d - 1].duration = g, h.push({ mark: d, time: c });
5809
+ let g = c - h[d - 1];
5810
+ u[d - 1].duration = g, u.push({ mark: d, time: c });
5811
5811
  }
5812
5812
  });
5813
5813
  let a = 1e3 * l.duration;
5814
- a > this.opt.ttsTrimEnd && (a = a - this.opt.ttsTrimEnd), h[h.length - 1].duration = a - h[h.length - 1].time, t.anim.forEach((c) => {
5815
- const d = h[c.mark];
5814
+ a > this.opt.ttsTrimEnd && (a = a - this.opt.ttsTrimEnd), u[u.length - 1].duration = a - u[u.length - 1].time, t.anim.forEach((c) => {
5815
+ const d = u[c.mark];
5816
5816
  if (d)
5817
5817
  for (let g = 0; g < c.ts.length; g++)
5818
5818
  c.ts[g] = d.time + c.ts[g] * d.duration + this.opt.ttsTrimStart;
@@ -5895,10 +5895,10 @@ class Ne {
5895
5895
  }
5896
5896
  if (!this.workletLoaded)
5897
5897
  try {
5898
- const l = this.audioCtx.audioWorklet.addModule(dt.href), u = new Promise(
5899
- (r, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5898
+ const l = this.audioCtx.audioWorklet.addModule(dt.href), h = new Promise(
5899
+ (r, u) => setTimeout(() => u(new Error("Worklet loading timed out")), 5e3)
5900
5900
  );
5901
- await Promise.race([l, u]), this.workletLoaded = !0;
5901
+ await Promise.race([l, h]), this.workletLoaded = !0;
5902
5902
  } catch (l) {
5903
5903
  throw console.error("Failed to load audio worklet:", l), new Error("Failed to initialize streaming speech");
5904
5904
  }
@@ -5911,8 +5911,8 @@ class Ne {
5911
5911
  if (l.data.type === "playback-started" && (this.isSpeaking = !0, this.stateName = "speaking", this.streamWaitForAudioChunks && (this.streamAudioStartTime = this.animClock), this._processStreamLipsyncQueue(), this.speakWithHands(), this.onAudioStart))
5912
5912
  try {
5913
5913
  this.onAudioStart?.();
5914
- } catch (u) {
5915
- console.error(u);
5914
+ } catch (h) {
5915
+ console.error(h);
5916
5916
  }
5917
5917
  if (l.data.type === "playback-ended" && (this._streamPause(), this.onAudioEnd))
5918
5918
  try {
@@ -5932,9 +5932,9 @@ class Ne {
5932
5932
  } catch {
5933
5933
  }
5934
5934
  if (this.resetLips(), this.lookAtCamera(500), t.mood && this.setMood(t.mood), this.onSubtitles = i || null, this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") {
5935
- const l = this.audioCtx.resume(), u = new Promise((r, h) => setTimeout(() => h("p2"), 1e3));
5935
+ const l = this.audioCtx.resume(), h = new Promise((r, u) => setTimeout(() => u("p2"), 1e3));
5936
5936
  try {
5937
- await Promise.race([l, u]);
5937
+ await Promise.race([l, h]);
5938
5938
  } catch {
5939
5939
  console.warn("Can't play audio. Web Audio API suspended. This is often due to calling some speak method before the first user action, which is typically prevented by the browser.");
5940
5940
  return;
@@ -6031,13 +6031,13 @@ class Ne {
6031
6031
  subtitles: [" " + i]
6032
6032
  }
6033
6033
  }), this.streamLipsyncType == "words")) {
6034
- const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, u = this.lipsyncPreProcessText(i, l), r = this.lipsyncWordsToVisemes(u, l);
6034
+ const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, h = this.lipsyncPreProcessText(i, l), r = this.lipsyncWordsToVisemes(h, l);
6035
6035
  if (r && r.visemes && r.visemes.length) {
6036
- const h = r.times[r.visemes.length - 1] + r.durations[r.visemes.length - 1], a = Math.min(o, Math.max(0, o - r.visemes.length * 150));
6036
+ const u = r.times[r.visemes.length - 1] + r.durations[r.visemes.length - 1], a = Math.min(o, Math.max(0, o - r.visemes.length * 150));
6037
6037
  let c = 0.6 + this.convertRange(a, [0, o], [0, 0.4]);
6038
- if (o = Math.min(o, r.visemes.length * 200), h > 0)
6038
+ if (o = Math.min(o, r.visemes.length * 200), u > 0)
6039
6039
  for (let d = 0; d < r.visemes.length; d++) {
6040
- const g = e + s + r.times[d] / h * o, y = r.durations[d] / h * o;
6040
+ const g = e + s + r.times[d] / u * o, y = r.durations[d] / u * o;
6041
6041
  this.animQueue.push({
6042
6042
  template: { name: "viseme" },
6043
6043
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
@@ -6133,7 +6133,7 @@ class Ne {
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), ce.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ce, pe).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 x.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ve.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), Re.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ve, Re).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,16 +6146,16 @@ class Ne {
6146
6146
  this.lookAt(null, null, t);
6147
6147
  return;
6148
6148
  }
6149
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ce.setFromMatrixPosition(this.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.objectRightEye.matrixWorld), ce.add(pe).divideScalar(2), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]);
6150
- const n = new f.Vector3().subVectors(e, ce).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
- E.set(s, i, 0, "YXZ");
6152
- const l = new f.Quaternion().setFromEuler(E), u = new f.Quaternion().copy(l).multiply(G.clone().invert());
6153
- E.setFromQuaternion(u, "YXZ");
6154
- let r = E.x / (40 / 24) + 0.2, h = E.y / (9 / 4), a = Math.min(0.6, Math.max(-0.3, r)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6149
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ve.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Re.setFromMatrixPosition(this.objectRightEye.matrixWorld), ve.add(Re).divideScalar(2), Q.copy(this.armature.quaternion), Q.multiply(this.poseTarget.props["Hips.quaternion"]), Q.multiply(this.poseTarget.props["Spine.quaternion"]), Q.multiply(this.poseTarget.props["Spine1.quaternion"]), Q.multiply(this.poseTarget.props["Spine2.quaternion"]), Q.multiply(this.poseTarget.props["Neck.quaternion"]), Q.multiply(this.poseTarget.props["Head.quaternion"]);
6150
+ const n = new x.Vector3().subVectors(e, ve).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
+ W.set(s, i, 0, "YXZ");
6152
+ const l = new x.Quaternion().setFromEuler(W), h = new x.Quaternion().copy(l).multiply(Q.clone().invert());
6153
+ W.setFromQuaternion(h, "YXZ");
6154
+ let r = W.x / (40 / 24) + 0.2, u = W.y / (9 / 4), a = Math.min(0.6, Math.max(-0.3, r)), c = Math.min(0.8, Math.max(-0.8, u)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6155
6155
  if (t) {
6156
- let y = this.animQueue.findIndex((v) => v.template.name === "lookat");
6156
+ let y = this.animQueue.findIndex((I) => I.template.name === "lookat");
6157
6157
  y !== -1 && this.animQueue.splice(y, 1);
6158
- const x = {
6158
+ const b = {
6159
6159
  name: "lookat",
6160
6160
  dt: [750, t],
6161
6161
  vs: {
@@ -6170,7 +6170,7 @@ class Ne {
6170
6170
  headMove: [0]
6171
6171
  }
6172
6172
  };
6173
- this.animQueue.push(this.animFactory(x));
6173
+ this.animQueue.push(this.animFactory(b));
6174
6174
  }
6175
6175
  }
6176
6176
  /**
@@ -6183,23 +6183,23 @@ class Ne {
6183
6183
  if (!this.camera) return;
6184
6184
  const i = this.nodeAvatar.getBoundingClientRect();
6185
6185
  this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0);
6186
- const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new f.Vector3().addVectors(s, o).divideScalar(2);
6186
+ const s = new x.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new x.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new x.Vector3().addVectors(s, o).divideScalar(2);
6187
6187
  l.project(this.camera);
6188
- let u = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6189
- t === null && (t = u), e === null && (e = r), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(G);
6190
- let h = E.x / (40 / 24), a = E.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - r, r), x = this.convertRange(e, [r - y, r + y], [-0.3, 0.6]) - h + c, v = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - a + d;
6191
- x = Math.min(0.6, Math.max(-0.3, x)), v = Math.min(0.8, Math.max(-0.8, v));
6192
- let B = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6188
+ let h = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6189
+ t === null && (t = h), e === null && (e = r), Q.copy(this.armature.quaternion), Q.multiply(this.poseTarget.props["Hips.quaternion"]), Q.multiply(this.poseTarget.props["Spine.quaternion"]), Q.multiply(this.poseTarget.props["Spine1.quaternion"]), Q.multiply(this.poseTarget.props["Spine2.quaternion"]), Q.multiply(this.poseTarget.props["Neck.quaternion"]), Q.multiply(this.poseTarget.props["Head.quaternion"]), W.setFromQuaternion(Q);
6190
+ let u = W.x / (40 / 24), a = W.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - h, h), y = Math.max(window.innerHeight - r, r), b = this.convertRange(e, [r - y, r + y], [-0.3, 0.6]) - u + c, I = this.convertRange(t, [h - g, h + g], [-0.8, 0.8]) - a + d;
6191
+ b = Math.min(0.6, Math.max(-0.3, b)), I = Math.min(0.8, Math.max(-0.8, I));
6192
+ let V = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (n) {
6194
- let H = this.animQueue.findIndex((I) => I.template.name === "lookat");
6195
- H !== -1 && this.animQueue.splice(H, 1);
6196
- const z = {
6194
+ let M = this.animQueue.findIndex((f) => f.template.name === "lookat");
6195
+ M !== -1 && this.animQueue.splice(M, 1);
6196
+ const w = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, n],
6199
6199
  vs: {
6200
- bodyRotateX: [x + B],
6201
- bodyRotateY: [v + p],
6202
- eyesRotateX: [-3 * B + 0.1],
6200
+ bodyRotateX: [b + V],
6201
+ bodyRotateY: [I + p],
6202
+ eyesRotateX: [-3 * V + 0.1],
6203
6203
  eyesRotateY: [-5 * p],
6204
6204
  browInnerUp: [[0, 0.7]],
6205
6205
  mouthLeft: [[0, 0.7]],
@@ -6208,7 +6208,7 @@ class Ne {
6208
6208
  headMove: [0]
6209
6209
  }
6210
6210
  };
6211
- this.animQueue.push(this.animFactory(z));
6211
+ this.animQueue.push(this.animFactory(w));
6212
6212
  }
6213
6213
  }
6214
6214
  /**
@@ -6219,17 +6219,17 @@ class Ne {
6219
6219
  */
6220
6220
  touchAt(t, e) {
6221
6221
  if (!this.camera) return;
6222
- const n = this.nodeAvatar.getBoundingClientRect(), i = new f.Vector2(
6222
+ const n = this.nodeAvatar.getBoundingClientRect(), i = new x.Vector2(
6223
6223
  (t - n.left) / n.width * 2 - 1,
6224
6224
  -((e - n.top) / n.height) * 2 + 1
6225
- ), s = new f.Raycaster();
6225
+ ), s = new x.Raycaster();
6226
6226
  s.setFromCamera(i, this.camera);
6227
6227
  const o = s.intersectObject(this.armature);
6228
6228
  if (o.length > 0) {
6229
- const l = o[0].point, u = new f.Vector3(), r = new f.Vector3();
6230
- this.objectLeftArm.getWorldPosition(u), this.objectRightArm.getWorldPosition(r);
6231
- const h = u.distanceToSquared(l), a = r.distanceToSquared(l);
6232
- h < a ? (this.ikSolve({
6229
+ const l = o[0].point, h = new x.Vector3(), r = new x.Vector3();
6230
+ this.objectLeftArm.getWorldPosition(h), this.objectRightArm.getWorldPosition(r);
6231
+ const u = h.distanceToSquared(l), a = r.distanceToSquared(l);
6232
+ u < a ? (this.ikSolve({
6233
6233
  iterations: 20,
6234
6234
  root: "LeftShoulder",
6235
6235
  effector: "LeftHandMiddle1",
@@ -6250,8 +6250,8 @@ class Ne {
6250
6250
  }, l, !1, 1e3), this.setValue("handFistRight", 0));
6251
6251
  } else
6252
6252
  ["LeftArm", "LeftForeArm", "LeftHand", "RightArm", "RightForeArm", "RightHand"].forEach((l) => {
6253
- let u = l + ".quaternion";
6254
- this.poseTarget.props[u].copy(this.getPoseTemplateProp(u)), this.poseTarget.props[u].t = this.animClock, this.poseTarget.props[u].d = 1e3;
6253
+ let h = l + ".quaternion";
6254
+ this.poseTarget.props[h].copy(this.getPoseTemplateProp(h)), this.poseTarget.props[h].t = this.animClock, this.poseTarget.props[h].d = 1e3;
6255
6255
  });
6256
6256
  return o.length > 0;
6257
6257
  }
@@ -6270,7 +6270,7 @@ class Ne {
6270
6270
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
6271
6271
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -1, maxz: 3 }
6272
6272
  ]
6273
- }, new f.Vector3(
6273
+ }, new x.Vector3(
6274
6274
  this.gaussianRandom(0, 0.5),
6275
6275
  this.gaussianRandom(-0.8, -0.2),
6276
6276
  this.gaussianRandom(0, 0.5)
@@ -6282,15 +6282,15 @@ class Ne {
6282
6282
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5 },
6283
6283
  { link: "RightArm" }
6284
6284
  ]
6285
- }, new f.Vector3(
6285
+ }, new x.Vector3(
6286
6286
  this.gaussianRandom(-0.5, 0),
6287
6287
  this.gaussianRandom(-0.8, -0.2),
6288
6288
  this.gaussianRandom(0, 0.5)
6289
6289
  ), !0);
6290
6290
  const n = [], i = [];
6291
6291
  n.push(100 + Math.round(Math.random() * 500)), i.push({ duration: 1e3, props: {
6292
- "LeftHand.quaternion": new f.Quaternion().setFromEuler(new f.Euler(0, -1 - Math.random(), 0)),
6293
- "RightHand.quaternion": new f.Quaternion().setFromEuler(new f.Euler(0, 1 + Math.random(), 0))
6292
+ "LeftHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, -1 - Math.random(), 0)),
6293
+ "RightHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, 1 + Math.random(), 0))
6294
6294
  } }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm"].forEach((o) => {
6295
6295
  i[0].props[o + ".quaternion"] = this.ikMesh.getObjectByName(o).quaternion.clone();
6296
6296
  }), n.push(1e3 + Math.round(Math.random() * 500)), i.push({ duration: 2e3, props: {} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm", "LeftHand", "RightHand"].forEach((o) => {
@@ -6370,21 +6370,21 @@ class Ne {
6370
6370
  async playAnimation(t, e = null, n = 10, i = 0, s = 0.01, o = !1) {
6371
6371
  if (!this.armature) return;
6372
6372
  this.positionWasLocked = !o, o ? console.log("Position locking disabled for FBX animation:", t) : (this.lockAvatarPosition(), console.log("Position locked immediately before FBX animation:", t));
6373
- let l = this.animClips.find((u) => u.url === t + "-" + i);
6373
+ let l = this.animClips.find((h) => h.url === t + "-" + i);
6374
6374
  if (l) {
6375
- let u = this.animQueue.find((a) => a.template.name === "pose");
6376
- u && (u.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((a) => {
6375
+ let h = this.animQueue.find((a) => a.template.name === "pose");
6376
+ h && (h.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((a) => {
6377
6377
  this.poseBase.props[a[0]] = a[1].clone(), this.poseTarget.props[a[0]] = a[1].clone(), this.poseTarget.props[a[0]].t = 0, this.poseTarget.props[a[0]].d = 1e3;
6378
- }), this.mixer ? console.log("Using existing mixer for FBX animation, preserving morph targets") : (this.mixer = new f.AnimationMixer(this.armature), console.log("Created new mixer for FBX animation")), this.mixer.addEventListener("finished", this.stopAnimation.bind(this), { once: !0 });
6379
- const r = Math.ceil(n / l.clip.duration), h = this.mixer.clipAction(l.clip);
6380
- h.setLoop(f.LoopRepeat, r), h.clampWhenFinished = !0, this.currentFBXAction = h;
6378
+ }), this.mixer ? console.log("Using existing mixer for FBX animation, preserving morph targets") : (this.mixer = new x.AnimationMixer(this.armature), console.log("Created new mixer for FBX animation")), this.mixer.addEventListener("finished", this.stopAnimation.bind(this), { once: !0 });
6379
+ const r = Math.ceil(n / l.clip.duration), u = this.mixer.clipAction(l.clip);
6380
+ u.setLoop(x.LoopRepeat, r), u.clampWhenFinished = !0, this.currentFBXAction = u;
6381
6381
  try {
6382
- h.fadeIn(0.5).play(), console.log("FBX animation started successfully:", t);
6382
+ u.fadeIn(0.5).play(), console.log("FBX animation started successfully:", t);
6383
6383
  } catch (a) {
6384
6384
  console.warn("FBX animation failed to start:", a), this.stopAnimation();
6385
6385
  return;
6386
6386
  }
6387
- if (h.getClip().tracks.length === 0) {
6387
+ if (u.getClip().tracks.length === 0) {
6388
6388
  console.warn("FBX animation has no valid tracks, stopping"), this.stopAnimation();
6389
6389
  return;
6390
6390
  }
@@ -6403,10 +6403,10 @@ class Ne {
6403
6403
  } catch (c) {
6404
6404
  console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
6405
6405
  }
6406
- const h = new Ee();
6406
+ const u = new Oe();
6407
6407
  let a;
6408
6408
  try {
6409
- a = await h.loadAsync(t, e);
6409
+ a = await u.loadAsync(t, e);
6410
6410
  } catch (c) {
6411
6411
  console.error(`Failed to load FBX animation from ${t}:`, c), console.error("Error details:", {
6412
6412
  message: c.message,
@@ -6431,12 +6431,12 @@ class Ne {
6431
6431
  const d = {};
6432
6432
  c.tracks.forEach((y) => {
6433
6433
  y.name = y.name.replaceAll("mixamorig", "");
6434
- const x = y.name.split(".");
6435
- if (x[1] === "position") {
6436
- for (let v = 0; v < y.values.length; v++)
6437
- y.values[v] = y.values[v] * s;
6438
- d[y.name] = new f.Vector3(y.values[0], y.values[1], y.values[2]);
6439
- } else x[1] === "quaternion" ? d[y.name] = new f.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : x[1] === "rotation" && (d[x[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6434
+ const b = y.name.split(".");
6435
+ if (b[1] === "position") {
6436
+ for (let I = 0; I < y.values.length; I++)
6437
+ y.values[I] = y.values[I] * s;
6438
+ d[y.name] = new x.Vector3(y.values[0], y.values[1], y.values[2]);
6439
+ } else b[1] === "quaternion" ? d[y.name] = new x.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : b[1] === "rotation" && (d[b[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6440
6440
  });
6441
6441
  const g = { props: d };
6442
6442
  d["Hips.position"] && (d["Hips.position"].y < 0.5 ? g.lying = !0 : g.standing = !0), this.animClips.push({
@@ -6472,25 +6472,25 @@ class Ne {
6472
6472
  if (!this.armature) return;
6473
6473
  let o = this.poseTemplates[t];
6474
6474
  if (!o) {
6475
- const l = this.animPoses.find((u) => u.url === t + "-" + i);
6475
+ const l = this.animPoses.find((h) => h.url === t + "-" + i);
6476
6476
  l && (o = l.pose);
6477
6477
  }
6478
6478
  if (o) {
6479
6479
  this.poseName = t, this.mixer = null;
6480
- let l = this.animQueue.find((u) => u.template.name === "pose");
6480
+ let l = this.animQueue.find((h) => h.template.name === "pose");
6481
6481
  l && (l.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
6482
6482
  } else {
6483
- let u = await new Ee().loadAsync(t, e);
6484
- if (u && u.animations && u.animations[i]) {
6485
- let r = u.animations[i];
6486
- const h = {};
6483
+ let h = await new Oe().loadAsync(t, e);
6484
+ if (h && h.animations && h.animations[i]) {
6485
+ let r = h.animations[i];
6486
+ const u = {};
6487
6487
  r.tracks.forEach((c) => {
6488
6488
  c.name = c.name.replaceAll("mixamorig", "");
6489
6489
  const d = c.name.split(".");
6490
- d[1] === "position" ? h[c.name] = new f.Vector3(c.values[0] * s, c.values[1] * s, c.values[2] * s) : d[1] === "quaternion" ? h[c.name] = new f.Quaternion(c.values[0], c.values[1], c.values[2], c.values[3]) : d[1] === "rotation" && (h[d[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(c.values[0], c.values[1], c.values[2], "XYZ")).normalize());
6490
+ d[1] === "position" ? u[c.name] = new x.Vector3(c.values[0] * s, c.values[1] * s, c.values[2] * s) : d[1] === "quaternion" ? u[c.name] = new x.Quaternion(c.values[0], c.values[1], c.values[2], c.values[3]) : d[1] === "rotation" && (u[d[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(c.values[0], c.values[1], c.values[2], "XYZ")).normalize());
6491
6491
  });
6492
- const a = { props: h };
6493
- h["Hips.position"] && (h["Hips.position"].y < 0.5 ? a.lying = !0 : a.standing = !0), this.animPoses.push({
6492
+ const a = { props: u };
6493
+ u["Hips.position"] && (u["Hips.position"].y < 0.5 ? a.lying = !0 : a.standing = !0), this.animPoses.push({
6494
6494
  url: t + "-" + i,
6495
6495
  pose: a
6496
6496
  }), this.playPose(t, e, n, i, s);
@@ -6519,10 +6519,10 @@ class Ne {
6519
6519
  let s = this.gestureTemplates[t];
6520
6520
  if (s) {
6521
6521
  this.gestureTimeout && (clearTimeout(this.gestureTimeout), this.gestureTimeout = null);
6522
- let l = this.animQueue.findIndex((u) => u.template.name === "talkinghands");
6523
- l !== -1 && (this.animQueue[l].ts = this.animQueue[l].ts.map((u) => 0)), this.gesture = this.propsToThreeObjects(s), n && (this.gesture = this.mirrorPose(this.gesture)), t === "namaste" && this.avatar.body === "M" && (this.gesture["RightArm.quaternion"].rotateTowards(new f.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new f.Quaternion(0, 1, 0, 0), -0.25));
6524
- for (let [u, r] of Object.entries(this.gesture))
6525
- r.t = this.animClock, r.d = i, this.poseTarget.props.hasOwnProperty(u) && (this.poseTarget.props[u].copy(r), this.poseTarget.props[u].t = this.animClock, this.poseTarget.props[u].d = i);
6522
+ let l = this.animQueue.findIndex((h) => h.template.name === "talkinghands");
6523
+ l !== -1 && (this.animQueue[l].ts = this.animQueue[l].ts.map((h) => 0)), this.gesture = this.propsToThreeObjects(s), n && (this.gesture = this.mirrorPose(this.gesture)), t === "namaste" && this.avatar.body === "M" && (this.gesture["RightArm.quaternion"].rotateTowards(new x.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new x.Quaternion(0, 1, 0, 0), -0.25));
6524
+ for (let [h, r] of Object.entries(this.gesture))
6525
+ r.t = this.animClock, r.d = i, this.poseTarget.props.hasOwnProperty(h) && (this.poseTarget.props[h].copy(r), this.poseTarget.props[h].t = this.animClock, this.poseTarget.props[h].d = i);
6526
6526
  e && Number.isFinite(e) && (this.gestureTimeout = setTimeout(this.stopGesture.bind(this, i), 1e3 * e));
6527
6527
  }
6528
6528
  let o = this.animEmojis[t];
@@ -6530,15 +6530,15 @@ class Ne {
6530
6530
  this.lookAtCamera(500);
6531
6531
  const l = this.animFactory(o);
6532
6532
  if (l.gesture = !0, e && Number.isFinite(e)) {
6533
- const u = l.ts[0], h = l.ts[l.ts.length - 1] - u;
6534
- if (e * 1e3 - h > 0) {
6533
+ const h = l.ts[0], u = l.ts[l.ts.length - 1] - h;
6534
+ if (e * 1e3 - u > 0) {
6535
6535
  const c = [];
6536
6536
  for (let y = 1; y < l.ts.length; y++) c.push(l.ts[y] - l.ts[y - 1]);
6537
- const d = o.template?.rescale || c.map((y) => y / h), g = e * 1e3 - h;
6538
- l.ts = l.ts.map((y, x, v) => x === 0 ? u : v[x - 1] + c[x - 1] + d[x - 1] * g);
6537
+ const d = o.template?.rescale || c.map((y) => y / u), g = e * 1e3 - u;
6538
+ l.ts = l.ts.map((y, b, I) => b === 0 ? h : I[b - 1] + c[b - 1] + d[b - 1] * g);
6539
6539
  } else {
6540
- const c = e * 1e3 / h;
6541
- l.ts = l.ts.map((d) => u + c * (d - u));
6540
+ const c = e * 1e3 / u;
6541
+ l.ts = l.ts.map((d) => h + c * (d - h));
6542
6542
  }
6543
6543
  }
6544
6544
  this.animQueue.push(l);
@@ -6568,34 +6568,34 @@ class Ne {
6568
6568
  * @param {numeric} [d=null] If set, apply in d milliseconds
6569
6569
  */
6570
6570
  ikSolve(t, e = null, n = !1, i = null) {
6571
- const s = new f.Vector3(), o = new f.Vector3(), l = new f.Vector3(), u = new f.Vector3(), r = new f.Quaternion(), h = new f.Vector3(), a = new f.Vector3(), c = new f.Vector3(), d = this.ikMesh.getObjectByName(t.root);
6571
+ const s = new x.Vector3(), o = new x.Vector3(), l = new x.Vector3(), h = new x.Vector3(), r = new x.Quaternion(), u = new x.Vector3(), a = new x.Vector3(), c = new x.Vector3(), d = this.ikMesh.getObjectByName(t.root);
6572
6572
  d.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), d.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(d.position);
6573
6573
  const g = this.ikMesh.getObjectByName(t.effector), y = t.links;
6574
- y.forEach((v) => {
6575
- v.bone = this.ikMesh.getObjectByName(v.link), v.bone.quaternion.copy(this.getPoseTemplateProp(v.link + ".quaternion"));
6574
+ y.forEach((I) => {
6575
+ I.bone = this.ikMesh.getObjectByName(I.link), I.bone.quaternion.copy(this.getPoseTemplateProp(I.link + ".quaternion"));
6576
6576
  }), d.updateMatrixWorld(!0);
6577
- const x = t.iterations || 10;
6577
+ const b = t.iterations || 10;
6578
6578
  if (e)
6579
- for (let v = 0; v < x; v++) {
6580
- let B = !1;
6581
- for (let p = 0, H = y.length; p < H; p++) {
6582
- const z = y[p].bone;
6583
- z.matrixWorld.decompose(u, r, h), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(r), l.normalize(), s.subVectors(e, u), s.applyQuaternion(r), s.normalize();
6584
- let I = s.dot(l);
6585
- I > 1 ? I = 1 : I < -1 && (I = -1), I = Math.acos(I), !(I < 1e-5) && (y[p].minAngle !== void 0 && I < y[p].minAngle && (I = y[p].minAngle), y[p].maxAngle !== void 0 && I > y[p].maxAngle && (I = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), G.setFromAxisAngle(a, I), z.quaternion.multiply(G), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6579
+ for (let I = 0; I < b; I++) {
6580
+ let V = !1;
6581
+ for (let p = 0, M = y.length; p < M; p++) {
6582
+ const w = y[p].bone;
6583
+ w.matrixWorld.decompose(h, r, u), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, h), l.applyQuaternion(r), l.normalize(), s.subVectors(e, h), s.applyQuaternion(r), s.normalize();
6584
+ let f = s.dot(l);
6585
+ f > 1 ? f = 1 : f < -1 && (f = -1), f = Math.acos(f), !(f < 1e-5) && (y[p].minAngle !== void 0 && f < y[p].minAngle && (f = y[p].minAngle), y[p].maxAngle !== void 0 && f > y[p].maxAngle && (f = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), Q.setFromAxisAngle(a, f), w.quaternion.multiply(Q), w.rotation.setFromVector3(c.setFromEuler(w.rotation).clamp(new x.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
6589
- ), new f.Vector3(
6589
+ ), new x.Vector3(
6590
6590
  y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6591
6591
  y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6592
6592
  y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6593
- ))), z.updateMatrixWorld(!0), B = !0);
6593
+ ))), w.updateMatrixWorld(!0), V = !0);
6594
6594
  }
6595
- if (!B) break;
6595
+ if (!V) break;
6596
6596
  }
6597
- i && y.forEach((v) => {
6598
- this.poseTarget.props[v.link + ".quaternion"].copy(v.bone.quaternion), this.poseTarget.props[v.link + ".quaternion"].t = this.animClock, this.poseTarget.props[v.link + ".quaternion"].d = i;
6597
+ i && y.forEach((I) => {
6598
+ this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = i;
6599
6599
  });
6600
6600
  }
6601
6601
  /**
@@ -6605,7 +6605,7 @@ class Ne {
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 Re = {
6608
+ const Ie = {
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 Re = {
6625
6625
  josh: "VR6AewLTigWG4xSOukaG"
6626
6626
  // Male, American
6627
6627
  }
6628
- }, De = {
6628
+ }, Te = {
6629
6629
  defaultVoice: "aura-2-thalia-en",
6630
6630
  // Thalia (Female, English)
6631
6631
  voices: {
@@ -6645,26 +6645,26 @@ const Re = {
6645
6645
  // Male, English - Powerful
6646
6646
  }
6647
6647
  };
6648
- function He() {
6648
+ function Fe() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
- endpoint: Re.endpoint,
6652
- apiKey: Re.apiKey,
6653
- defaultVoice: Re.defaultVoice,
6654
- voices: Re.voices
6651
+ endpoint: Ie.endpoint,
6652
+ apiKey: Ie.apiKey,
6653
+ defaultVoice: Ie.defaultVoice,
6654
+ voices: Ie.voices
6655
6655
  };
6656
6656
  }
6657
- function St() {
6658
- const U = He(), t = [];
6659
- return Object.entries(U.voices).forEach(([e, n]) => {
6657
+ function kt() {
6658
+ const G = Fe(), t = [];
6659
+ return Object.entries(G.voices).forEach(([e, n]) => {
6660
6660
  t.push({
6661
6661
  value: n,
6662
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${U.service})`
6662
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${G.service})`
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
- const Ue = ze(({
6667
- avatarUrl: U = "/avatars/brunette.glb",
6666
+ const Ve = Me(({
6667
+ avatarUrl: G = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
6670
6670
  ttsLang: n = "en",
@@ -6672,9 +6672,9 @@ const Ue = ze(({
6672
6672
  ttsVoice: s = null,
6673
6673
  ttsApiKey: o = null,
6674
6674
  bodyMovement: l = "idle",
6675
- movementIntensity: u = 0.5,
6675
+ movementIntensity: h = 0.5,
6676
6676
  showFullAvatar: r = !0,
6677
- cameraView: h = "upper",
6677
+ cameraView: u = "upper",
6678
6678
  onReady: a = () => {
6679
6679
  },
6680
6680
  onLoading: c = () => {
@@ -6683,270 +6683,270 @@ const Ue = ze(({
6683
6683
  },
6684
6684
  className: g = "",
6685
6685
  style: y = {},
6686
- animations: x = {}
6687
- }, v) => {
6688
- const B = N(null), p = N(null), H = N(r), z = N(null), I = N(null), T = N(!1), F = N({ remainingText: null, originalText: null, options: null }), J = N([]), ye = N(0), [S, W] = be(!0), [j, Z] = be(null), [$, se] = be(!1), [de, me] = be(!1);
6689
- Ie(() => {
6690
- T.current = de;
6691
- }, [de]), Ie(() => {
6692
- H.current = r;
6686
+ animations: b = {}
6687
+ }, I) => {
6688
+ const V = D(null), p = D(null), M = D(r), w = D(null), f = D(null), E = D(!1), P = D({ remainingText: null, originalText: null, options: null }), U = D([]), oe = D(0), [S, Z] = ce(!0), [K, X] = ce(null), [$, se] = ce(!1), [ae, pe] = ce(!1);
6689
+ de(() => {
6690
+ E.current = ae;
6691
+ }, [ae]), de(() => {
6692
+ M.current = r;
6693
6693
  }, [r]);
6694
- const ie = He(), fe = i || ie.service;
6695
- let X;
6696
- fe === "browser" ? X = {
6694
+ const ee = Fe(), le = i || ee.service;
6695
+ let O;
6696
+ le === "browser" ? O = {
6697
6697
  service: "browser",
6698
6698
  endpoint: "",
6699
6699
  apiKey: null,
6700
6700
  defaultVoice: "Google US English"
6701
- } : fe === "elevenlabs" ? X = {
6701
+ } : le === "elevenlabs" ? O = {
6702
6702
  service: "elevenlabs",
6703
6703
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6704
- apiKey: o || ie.apiKey,
6705
- defaultVoice: s || ie.defaultVoice || Re.defaultVoice,
6706
- voices: ie.voices || Re.voices
6707
- } : fe === "deepgram" ? X = {
6704
+ apiKey: o || ee.apiKey,
6705
+ defaultVoice: s || ee.defaultVoice || Ie.defaultVoice,
6706
+ voices: ee.voices || Ie.voices
6707
+ } : le === "deepgram" ? O = {
6708
6708
  service: "deepgram",
6709
6709
  endpoint: "https://api.deepgram.com/v1/speak",
6710
- apiKey: o || ie.apiKey,
6711
- defaultVoice: s || ie.defaultVoice || De.defaultVoice,
6712
- voices: ie.voices || De.voices
6713
- } : X = {
6714
- ...ie,
6710
+ apiKey: o || ee.apiKey,
6711
+ defaultVoice: s || ee.defaultVoice || Te.defaultVoice,
6712
+ voices: ee.voices || Te.voices
6713
+ } : O = {
6714
+ ...ee,
6715
6715
  // Override API key if provided via props
6716
- apiKey: o !== null ? o : ie.apiKey
6716
+ apiKey: o !== null ? o : ee.apiKey
6717
6717
  };
6718
- const b = {
6719
- url: U,
6718
+ const v = {
6719
+ url: G,
6720
6720
  body: t,
6721
6721
  avatarMood: e,
6722
- ttsLang: fe === "browser" ? "en-US" : n,
6723
- ttsVoice: s || X.defaultVoice,
6722
+ ttsLang: le === "browser" ? "en-US" : n,
6723
+ ttsVoice: s || O.defaultVoice,
6724
6724
  lipsyncLang: "en",
6725
6725
  showFullAvatar: r,
6726
6726
  bodyMovement: l,
6727
- movementIntensity: u
6727
+ movementIntensity: h
6728
6728
  }, R = {
6729
- ttsEndpoint: X.endpoint,
6730
- ttsApikey: X.apiKey,
6731
- ttsService: fe,
6729
+ ttsEndpoint: O.endpoint,
6730
+ ttsApikey: O.apiKey,
6731
+ ttsService: le,
6732
6732
  lipsyncModules: ["en"],
6733
- cameraView: h
6734
- }, w = M(async () => {
6735
- if (!(!B.current || p.current))
6733
+ cameraView: u
6734
+ }, z = T(async () => {
6735
+ if (!(!V.current || p.current))
6736
6736
  try {
6737
- if (W(!0), Z(null), p.current = new Ne(B.current, R), 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(b, (V) => {
6738
- if (V.lengthComputable) {
6739
- const Q = Math.min(100, Math.round(V.loaded / V.total * 100));
6740
- c(Q);
6737
+ if (Z(!0), X(null), p.current = new Be(V.current, R), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), b && Object.keys(b).length > 0 && (p.current.customAnimations = b), await p.current.showAvatar(v, (B) => {
6738
+ if (B.lengthComputable) {
6739
+ const J = Math.min(100, Math.round(B.loaded / B.total * 100));
6740
+ c(J);
6741
6741
  }
6742
- }), await new Promise((V) => {
6743
- const Q = () => {
6744
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? V() : setTimeout(Q, 100);
6742
+ }), await new Promise((B) => {
6743
+ const J = () => {
6744
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? B() : setTimeout(J, 100);
6745
6745
  };
6746
- Q();
6746
+ J();
6747
6747
  }), p.current && p.current.setShowFullAvatar)
6748
6748
  try {
6749
6749
  p.current.setShowFullAvatar(r);
6750
- } catch (V) {
6751
- console.warn("Error setting full body mode on initialization:", V);
6750
+ } catch (B) {
6751
+ console.warn("Error setting full body mode on initialization:", B);
6752
6752
  }
6753
- p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), W(!1), se(!0), a(p.current);
6754
- const P = () => {
6753
+ p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), Z(!1), se(!0), a(p.current);
6754
+ const F = () => {
6755
6755
  document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6756
6756
  };
6757
- return document.addEventListener("visibilitychange", P), () => {
6758
- document.removeEventListener("visibilitychange", P);
6757
+ return document.addEventListener("visibilitychange", F), () => {
6758
+ document.removeEventListener("visibilitychange", F);
6759
6759
  };
6760
6760
  } catch (L) {
6761
- console.error("Error initializing TalkingHead:", L), Z(L.message || "Failed to initialize avatar"), W(!1), d(L);
6761
+ console.error("Error initializing TalkingHead:", L), X(L.message || "Failed to initialize avatar"), Z(!1), d(L);
6762
6762
  }
6763
- }, [U, t, e, n, i, s, o, r, l, u, h]);
6764
- Ie(() => (w(), () => {
6763
+ }, [G, t, e, n, i, s, o, r, l, h, u]);
6764
+ de(() => (z(), () => {
6765
6765
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6766
- }), [w]), Ie(() => {
6767
- if (!B.current || !p.current) return;
6768
- const L = new ResizeObserver((V) => {
6769
- for (const Q of V)
6766
+ }), [z]), de(() => {
6767
+ if (!V.current || !p.current) return;
6768
+ const L = new ResizeObserver((B) => {
6769
+ for (const J of B)
6770
6770
  p.current && p.current.onResize && p.current.onResize();
6771
6771
  });
6772
- L.observe(B.current);
6773
- const P = () => {
6772
+ L.observe(V.current);
6773
+ const F = () => {
6774
6774
  p.current && p.current.onResize && p.current.onResize();
6775
6775
  };
6776
- return window.addEventListener("resize", P), () => {
6777
- L.disconnect(), window.removeEventListener("resize", P);
6776
+ return window.addEventListener("resize", F), () => {
6777
+ L.disconnect(), window.removeEventListener("resize", F);
6778
6778
  };
6779
6779
  }, [$]);
6780
- const C = M(async () => {
6780
+ const H = T(async () => {
6781
6781
  if (p.current && p.current.audioCtx)
6782
6782
  try {
6783
6783
  (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6784
6784
  } catch (L) {
6785
6785
  console.warn("Failed to resume audio context:", L);
6786
6786
  }
6787
- }, []), D = M(async (L, P = {}) => {
6787
+ }, []), N = T(async (L, F = {}) => {
6788
6788
  if (p.current && $)
6789
6789
  try {
6790
- I.current && (clearInterval(I.current), I.current = null), z.current = { text: L, options: P }, F.current = { remainingText: null, originalText: null, options: null };
6791
- const V = /[!\.\?\n\p{Extended_Pictographic}]/ug, Q = L.split(V).map((O) => O.trim()).filter((O) => O.length > 0);
6792
- J.current = Q, ye.current = 0, me(!1), T.current = !1, await C();
6793
- const ae = {
6794
- ...P,
6795
- lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
6790
+ f.current && (clearInterval(f.current), f.current = null), w.current = { text: L, options: F }, P.current = { remainingText: null, originalText: null, options: null };
6791
+ const B = /[!\.\?\n\p{Extended_Pictographic}]/ug, J = L.split(B).map((Y) => Y.trim()).filter((Y) => Y.length > 0);
6792
+ U.current = J, oe.current = 0, pe(!1), E.current = !1, await H();
6793
+ const ge = {
6794
+ ...F,
6795
+ lipsyncLang: F.lipsyncLang || v.lipsyncLang || "en"
6796
6796
  };
6797
- if (P.onSpeechEnd && p.current) {
6798
- const O = p.current;
6799
- let oe = null, Le = 0;
6800
- const xe = 1200;
6801
- let ue = !1;
6802
- oe = setInterval(() => {
6803
- if (Le++, T.current)
6797
+ if (F.onSpeechEnd && p.current) {
6798
+ const Y = p.current;
6799
+ let he = null, Se = 0;
6800
+ const Ae = 1200;
6801
+ let be = !1;
6802
+ he = setInterval(() => {
6803
+ if (Se++, E.current)
6804
6804
  return;
6805
- if (Le > xe) {
6806
- if (oe && (clearInterval(oe), oe = null, I.current = null), !ue && !T.current) {
6807
- ue = !0;
6805
+ if (Se > Ae) {
6806
+ if (he && (clearInterval(he), he = null, f.current = null), !be && !E.current) {
6807
+ be = !0;
6808
6808
  try {
6809
- P.onSpeechEnd();
6810
- } catch (Me) {
6811
- console.error("Error in onSpeechEnd callback (timeout):", Me);
6809
+ F.onSpeechEnd();
6810
+ } catch (De) {
6811
+ console.error("Error in onSpeechEnd callback (timeout):", De);
6812
6812
  }
6813
6813
  }
6814
6814
  return;
6815
6815
  }
6816
- const re = !O.speechQueue || O.speechQueue.length === 0, Ae = !O.audioPlaylist || O.audioPlaylist.length === 0;
6817
- O && O.isSpeaking === !1 && re && Ae && O.isAudioPlaying === !1 && !ue && !T.current && setTimeout(() => {
6818
- if (O && !T.current && O.isSpeaking === !1 && (!O.speechQueue || O.speechQueue.length === 0) && (!O.audioPlaylist || O.audioPlaylist.length === 0) && O.isAudioPlaying === !1 && !ue && !T.current) {
6819
- ue = !0, oe && (clearInterval(oe), oe = null, I.current = null);
6816
+ const ye = !Y.speechQueue || Y.speechQueue.length === 0, ke = !Y.audioPlaylist || Y.audioPlaylist.length === 0;
6817
+ Y && Y.isSpeaking === !1 && ye && ke && Y.isAudioPlaying === !1 && !be && !E.current && setTimeout(() => {
6818
+ if (Y && !E.current && Y.isSpeaking === !1 && (!Y.speechQueue || Y.speechQueue.length === 0) && (!Y.audioPlaylist || Y.audioPlaylist.length === 0) && Y.isAudioPlaying === !1 && !be && !E.current) {
6819
+ be = !0, he && (clearInterval(he), he = null, f.current = null);
6820
6820
  try {
6821
- P.onSpeechEnd();
6821
+ F.onSpeechEnd();
6822
6822
  } catch (Ze) {
6823
6823
  console.error("Error in onSpeechEnd callback:", Ze);
6824
6824
  }
6825
6825
  }
6826
6826
  }, 100);
6827
- }, 100), I.current = oe;
6827
+ }, 100), f.current = he;
6828
6828
  }
6829
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae)) : setTimeout(async () => {
6830
- await C(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae));
6829
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ge)) : setTimeout(async () => {
6830
+ await H(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ge));
6831
6831
  }, 100);
6832
- } catch (V) {
6833
- console.error("Error speaking text:", V), Z(V.message || "Failed to speak text");
6832
+ } catch (B) {
6833
+ console.error("Error speaking text:", B), X(B.message || "Failed to speak text");
6834
6834
  }
6835
- }, [$, C, b.lipsyncLang]), ee = M(() => {
6836
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, me(!1));
6837
- }, []), q = M(() => {
6835
+ }, [$, H, v.lipsyncLang]), _ = T(() => {
6836
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), w.current = null, pe(!1));
6837
+ }, []), j = T(() => {
6838
6838
  if (p.current && p.current.pauseSpeaking) {
6839
6839
  const L = p.current;
6840
6840
  if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
6841
- I.current && (clearInterval(I.current), I.current = null);
6842
- let V = "";
6843
- if (z.current && J.current.length > 0) {
6844
- const Q = J.current.length, ae = L.speechQueue ? L.speechQueue.filter((xe) => xe && xe.text && Array.isArray(xe.text) && xe.text.length > 0).length : 0, O = L.audioPlaylist && L.audioPlaylist.length > 0, oe = ae + (O ? 1 : 0), Le = Q - oe;
6845
- if (oe > 0 && Le < Q && (V = J.current.slice(Le).join(". ").trim(), !V && ae > 0 && L.speechQueue)) {
6846
- const ue = L.speechQueue.filter((re) => re && re.text && Array.isArray(re.text) && re.text.length > 0).map((re) => re.text.map((Ae) => Ae.word || "").filter((Ae) => Ae.length > 0).join(" ")).filter((re) => re.length > 0).join(" ");
6847
- ue && ue.trim() && (V = ue.trim());
6841
+ f.current && (clearInterval(f.current), f.current = null);
6842
+ let B = "";
6843
+ if (w.current && U.current.length > 0) {
6844
+ const J = U.current.length, ge = L.speechQueue ? L.speechQueue.filter((Ae) => Ae && Ae.text && Array.isArray(Ae.text) && Ae.text.length > 0).length : 0, Y = L.audioPlaylist && L.audioPlaylist.length > 0, he = ge + (Y ? 1 : 0), Se = J - he;
6845
+ if (he > 0 && Se < J && (B = U.current.slice(Se).join(". ").trim(), !B && ge > 0 && L.speechQueue)) {
6846
+ const be = L.speechQueue.filter((ye) => ye && ye.text && Array.isArray(ye.text) && ye.text.length > 0).map((ye) => ye.text.map((ke) => ke.word || "").filter((ke) => ke.length > 0).join(" ")).filter((ye) => ye.length > 0).join(" ");
6847
+ be && be.trim() && (B = be.trim());
6848
6848
  }
6849
6849
  }
6850
- z.current && (F.current = {
6851
- remainingText: V || null,
6852
- originalText: z.current.text,
6853
- options: z.current.options
6854
- }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, me(!0);
6850
+ w.current && (P.current = {
6851
+ remainingText: B || null,
6852
+ originalText: w.current.text,
6853
+ options: w.current.options
6854
+ }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), E.current = !0, pe(!0);
6855
6855
  }
6856
6856
  }
6857
- }, []), Y = M(async () => {
6858
- if (!p.current || !de)
6857
+ }, []), q = T(async () => {
6858
+ if (!p.current || !ae)
6859
6859
  return;
6860
- let L = "", P = {};
6861
- if (F.current && F.current.remainingText)
6862
- L = F.current.remainingText, P = F.current.options || {}, F.current = { remainingText: null, originalText: null, options: null };
6863
- else if (z.current && z.current.text)
6864
- L = z.current.text, P = z.current.options || {};
6860
+ let L = "", F = {};
6861
+ if (P.current && P.current.remainingText)
6862
+ L = P.current.remainingText, F = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
6863
+ else if (w.current && w.current.text)
6864
+ L = w.current.text, F = w.current.options || {};
6865
6865
  else {
6866
- console.warn("Resume called but no paused speech found"), me(!1), T.current = !1;
6866
+ console.warn("Resume called but no paused speech found"), pe(!1), E.current = !1;
6867
6867
  return;
6868
6868
  }
6869
- me(!1), T.current = !1, await C();
6870
- const V = {
6871
- ...P,
6872
- lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
6869
+ pe(!1), E.current = !1, await H();
6870
+ const B = {
6871
+ ...F,
6872
+ lipsyncLang: F.lipsyncLang || v.lipsyncLang || "en"
6873
6873
  };
6874
6874
  try {
6875
- await D(L, V);
6876
- } catch (Q) {
6877
- console.error("Error resuming speech:", Q), me(!1), T.current = !1;
6875
+ await N(L, B);
6876
+ } catch (J) {
6877
+ console.error("Error resuming speech:", J), pe(!1), E.current = !1;
6878
6878
  }
6879
- }, [C, de, D, b]), ve = M((L) => {
6879
+ }, [H, ae, N, v]), Le = T((L) => {
6880
6880
  p.current && p.current.setMood(L);
6881
- }, []), Te = M((L) => {
6881
+ }, []), we = T((L) => {
6882
6882
  p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6883
- }, []), Ve = M((L, P = !1) => {
6883
+ }, []), C = T((L, F = !1) => {
6884
6884
  if (p.current && p.current.playAnimation) {
6885
- if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
6885
+ if (b && b[L] && (L = b[L]), p.current.setShowFullAvatar)
6886
6886
  try {
6887
- p.current.setShowFullAvatar(H.current);
6888
- } catch (Q) {
6889
- console.warn("Error setting full body mode:", Q);
6887
+ p.current.setShowFullAvatar(M.current);
6888
+ } catch (J) {
6889
+ console.warn("Error setting full body mode:", J);
6890
6890
  }
6891
6891
  if (L.includes("."))
6892
6892
  try {
6893
- p.current.playAnimation(L, null, 10, 0, 0.01, P);
6894
- } catch (Q) {
6895
- console.warn(`Failed to play ${L}:`, Q);
6893
+ p.current.playAnimation(L, null, 10, 0, 0.01, F);
6894
+ } catch (J) {
6895
+ console.warn(`Failed to play ${L}:`, J);
6896
6896
  try {
6897
6897
  p.current.setBodyMovement("idle");
6898
- } catch (ae) {
6899
- console.warn("Fallback animation also failed:", ae);
6898
+ } catch (ge) {
6899
+ console.warn("Fallback animation also failed:", ge);
6900
6900
  }
6901
6901
  }
6902
6902
  else {
6903
- const Q = [".fbx", ".glb", ".gltf"];
6904
- let ae = !1;
6905
- for (const O of Q)
6903
+ const J = [".fbx", ".glb", ".gltf"];
6904
+ let ge = !1;
6905
+ for (const Y of J)
6906
6906
  try {
6907
- p.current.playAnimation(L + O, null, 10, 0, 0.01, P), ae = !0;
6907
+ p.current.playAnimation(L + Y, null, 10, 0, 0.01, F), ge = !0;
6908
6908
  break;
6909
6909
  } catch {
6910
6910
  }
6911
- if (!ae) {
6911
+ if (!ge) {
6912
6912
  console.warn("Animation not found:", L);
6913
6913
  try {
6914
6914
  p.current.setBodyMovement("idle");
6915
- } catch (O) {
6916
- console.warn("Fallback animation also failed:", O);
6915
+ } catch (Y) {
6916
+ console.warn("Fallback animation also failed:", Y);
6917
6917
  }
6918
6918
  }
6919
6919
  }
6920
6920
  }
6921
- }, [x]), Ge = M(() => {
6921
+ }, [b]), te = T(() => {
6922
6922
  p.current && p.current.onResize && p.current.onResize();
6923
6923
  }, []);
6924
- return Ce(v, () => ({
6925
- speakText: D,
6926
- stopSpeaking: ee,
6927
- pauseSpeaking: q,
6928
- resumeSpeaking: Y,
6929
- resumeAudioContext: C,
6930
- setMood: ve,
6931
- setTimingAdjustment: Te,
6932
- playAnimation: Ve,
6924
+ return Ee(I, () => ({
6925
+ speakText: N,
6926
+ stopSpeaking: _,
6927
+ pauseSpeaking: j,
6928
+ resumeSpeaking: q,
6929
+ resumeAudioContext: H,
6930
+ setMood: Le,
6931
+ setTimingAdjustment: we,
6932
+ playAnimation: C,
6933
6933
  isReady: $,
6934
- isPaused: de,
6934
+ isPaused: ae,
6935
6935
  talkingHead: p.current,
6936
- handleResize: Ge,
6936
+ handleResize: te,
6937
6937
  setBodyMovement: (L) => {
6938
6938
  if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
6939
6939
  try {
6940
- p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(L);
6941
- } catch (P) {
6942
- console.warn("Error setting body movement:", P);
6940
+ p.current.setShowFullAvatar(M.current), p.current.setBodyMovement(L);
6941
+ } catch (F) {
6942
+ console.warn("Error setting body movement:", F);
6943
6943
  }
6944
6944
  },
6945
6945
  setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
6946
6946
  playRandomDance: () => {
6947
6947
  if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
6948
6948
  try {
6949
- p.current.setShowFullAvatar(H.current), p.current.playRandomDance();
6949
+ p.current.setShowFullAvatar(M.current), p.current.playRandomDance();
6950
6950
  } catch (L) {
6951
6951
  console.warn("Error playing random dance:", L);
6952
6952
  }
@@ -6954,15 +6954,15 @@ const Ue = ze(({
6954
6954
  playReaction: (L) => {
6955
6955
  if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
6956
6956
  try {
6957
- p.current.setShowFullAvatar(H.current), p.current.playReaction(L);
6958
- } catch (P) {
6959
- console.warn("Error playing reaction:", P);
6957
+ p.current.setShowFullAvatar(M.current), p.current.playReaction(L);
6958
+ } catch (F) {
6959
+ console.warn("Error playing reaction:", F);
6960
6960
  }
6961
6961
  },
6962
6962
  playCelebration: () => {
6963
6963
  if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
6964
6964
  try {
6965
- p.current.setShowFullAvatar(H.current), p.current.playCelebration();
6965
+ p.current.setShowFullAvatar(M.current), p.current.playCelebration();
6966
6966
  } catch (L) {
6967
6967
  console.warn("Error playing celebration:", L);
6968
6968
  }
@@ -6970,9 +6970,9 @@ const Ue = ze(({
6970
6970
  setShowFullAvatar: (L) => {
6971
6971
  if (p.current && p.current.setShowFullAvatar)
6972
6972
  try {
6973
- H.current = L, p.current.setShowFullAvatar(L);
6974
- } catch (P) {
6975
- console.warn("Error setting showFullAvatar:", P);
6973
+ M.current = L, p.current.setShowFullAvatar(L);
6974
+ } catch (F) {
6975
+ console.warn("Error setting showFullAvatar:", F);
6976
6976
  }
6977
6977
  },
6978
6978
  lockAvatarPosition: () => {
@@ -6991,7 +6991,7 @@ const Ue = ze(({
6991
6991
  console.warn("Error unlocking avatar position:", L);
6992
6992
  }
6993
6993
  }
6994
- })), /* @__PURE__ */ Oe(
6994
+ })), /* @__PURE__ */ Pe(
6995
6995
  "div",
6996
6996
  {
6997
6997
  className: `talking-head-avatar ${g}`,
@@ -7002,10 +7002,10 @@ const Ue = ze(({
7002
7002
  ...y
7003
7003
  },
7004
7004
  children: [
7005
- /* @__PURE__ */ ge(
7005
+ /* @__PURE__ */ me(
7006
7006
  "div",
7007
7007
  {
7008
- ref: B,
7008
+ ref: V,
7009
7009
  className: "talking-head-viewer",
7010
7010
  style: {
7011
7011
  width: "100%",
@@ -7014,7 +7014,7 @@ const Ue = ze(({
7014
7014
  }
7015
7015
  }
7016
7016
  ),
7017
- S && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
7017
+ S && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7018
7018
  position: "absolute",
7019
7019
  top: "50%",
7020
7020
  left: "50%",
@@ -7023,7 +7023,7 @@ const Ue = ze(({
7023
7023
  fontSize: "18px",
7024
7024
  zIndex: 10
7025
7025
  }, children: "Loading avatar..." }),
7026
- j && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7026
+ K && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7027
7027
  position: "absolute",
7028
7028
  top: "50%",
7029
7029
  left: "50%",
@@ -7034,14 +7034,14 @@ const Ue = ze(({
7034
7034
  zIndex: 10,
7035
7035
  padding: "20px",
7036
7036
  borderRadius: "8px"
7037
- }, children: j })
7037
+ }, children: K })
7038
7038
  ]
7039
7039
  }
7040
7040
  );
7041
7041
  });
7042
- Ue.displayName = "TalkingHeadAvatar";
7043
- const pt = ze(({
7044
- text: U = "Hello! I'm a talking avatar. How are you today?",
7042
+ Ve.displayName = "TalkingHeadAvatar";
7043
+ const pt = Me(({
7044
+ text: G = "Hello! I'm a talking avatar. How are you today?",
7045
7045
  onLoading: t = () => {
7046
7046
  },
7047
7047
  onError: e = () => {
@@ -7052,23 +7052,23 @@ const pt = ze(({
7052
7052
  style: s = {},
7053
7053
  avatarConfig: o = {}
7054
7054
  }, l) => {
7055
- const u = N(null), r = N(null), [h, a] = be(!0), [c, d] = be(null), [g, y] = be(!1), x = He(), v = o.ttsService || x.service, B = v === "browser" ? {
7055
+ const h = D(null), r = D(null), [u, a] = ce(!0), [c, d] = ce(null), [g, y] = ce(!1), b = Fe(), I = o.ttsService || b.service, V = I === "browser" ? {
7056
7056
  endpoint: "",
7057
7057
  apiKey: null,
7058
7058
  defaultVoice: "Google US English"
7059
7059
  } : {
7060
- ...x,
7060
+ ...b,
7061
7061
  // Override API key if provided via avatarConfig
7062
- apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : x.apiKey,
7062
+ apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : b.apiKey,
7063
7063
  // Override endpoint for ElevenLabs if service is explicitly set
7064
- endpoint: v === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : x.endpoint
7064
+ endpoint: I === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : b.endpoint
7065
7065
  }, p = {
7066
7066
  url: "/avatars/brunette.glb",
7067
7067
  // Use brunette avatar (working glTF file)
7068
7068
  body: "F",
7069
7069
  avatarMood: "neutral",
7070
- ttsLang: v === "browser" ? "en-US" : "en",
7071
- ttsVoice: o.ttsVoice || B.defaultVoice,
7070
+ ttsLang: I === "browser" ? "en-US" : "en",
7071
+ ttsVoice: o.ttsVoice || V.defaultVoice,
7072
7072
  lipsyncLang: "en",
7073
7073
  // English lip-sync
7074
7074
  showFullAvatar: !0,
@@ -7076,81 +7076,81 @@ const pt = ze(({
7076
7076
  bodyMovement: "idle",
7077
7077
  movementIntensity: 0.5,
7078
7078
  ...o
7079
- }, H = {
7080
- ttsEndpoint: B.endpoint,
7081
- ttsApikey: B.apiKey,
7082
- ttsService: v,
7079
+ }, M = {
7080
+ ttsEndpoint: V.endpoint,
7081
+ ttsApikey: V.apiKey,
7082
+ ttsService: I,
7083
7083
  lipsyncModules: ["en"],
7084
7084
  cameraView: "upper"
7085
- }, z = M(async () => {
7086
- if (!(!u.current || r.current))
7085
+ }, w = T(async () => {
7086
+ if (!(!h.current || r.current))
7087
7087
  try {
7088
- if (a(!0), d(null), r.current = new Ne(u.current, H), await r.current.showAvatar(p, (j) => {
7089
- if (j.lengthComputable) {
7090
- const Z = Math.min(100, Math.round(j.loaded / j.total * 100));
7091
- t(Z);
7088
+ if (a(!0), d(null), r.current = new Be(h.current, M), await r.current.showAvatar(p, (K) => {
7089
+ if (K.lengthComputable) {
7090
+ const X = Math.min(100, Math.round(K.loaded / K.total * 100));
7091
+ t(X);
7092
7092
  }
7093
7093
  }), r.current.morphs && r.current.morphs.length > 0) {
7094
- const j = r.current.morphs[0].morphTargetDictionary;
7095
- console.log("Available morph targets:", Object.keys(j));
7096
- const Z = Object.keys(j).filter(($) => $.startsWith("viseme_"));
7097
- console.log("Viseme morph targets found:", Z), Z.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"));
7094
+ const K = r.current.morphs[0].morphTargetDictionary;
7095
+ console.log("Available morph targets:", Object.keys(K));
7096
+ const X = Object.keys(K).filter(($) => $.startsWith("viseme_"));
7097
+ console.log("Viseme morph targets found:", X), X.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7098
7098
  }
7099
- if (await new Promise((j) => {
7100
- const Z = () => {
7101
- r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), j()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
7099
+ if (await new Promise((K) => {
7100
+ const X = () => {
7101
+ r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), K()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(X, 100));
7102
7102
  };
7103
- Z();
7103
+ X();
7104
7104
  }), r.current && r.current.setShowFullAvatar)
7105
7105
  try {
7106
7106
  r.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7107
- } catch (j) {
7108
- console.warn("Error setting full body mode on initialization:", j);
7107
+ } catch (K) {
7108
+ console.warn("Error setting full body mode on initialization:", K);
7109
7109
  }
7110
7110
  a(!1), y(!0), n(r.current);
7111
- const W = () => {
7111
+ const Z = () => {
7112
7112
  document.visibilityState === "visible" ? r.current?.start() : r.current?.stop();
7113
7113
  };
7114
- return document.addEventListener("visibilitychange", W), () => {
7115
- document.removeEventListener("visibilitychange", W);
7114
+ return document.addEventListener("visibilitychange", Z), () => {
7115
+ document.removeEventListener("visibilitychange", Z);
7116
7116
  };
7117
7117
  } catch (S) {
7118
7118
  console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), a(!1), e(S);
7119
7119
  }
7120
7120
  }, []);
7121
- Ie(() => (z(), () => {
7121
+ de(() => (w(), () => {
7122
7122
  r.current && (r.current.stop(), r.current.dispose(), r.current = null);
7123
- }), [z]);
7124
- const I = M((S) => {
7123
+ }), [w]);
7124
+ const f = T((S) => {
7125
7125
  if (r.current && g)
7126
7126
  try {
7127
7127
  console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", r.current), r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), r.current.setSlowdownRate && (r.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), r.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7128
7128
  r.current && r.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), r.current.setSlowdownRate && (r.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), r.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
7129
7129
  }, 500));
7130
- } catch (W) {
7131
- console.error("Error speaking text:", W), d(W.message || "Failed to speak text");
7130
+ } catch (Z) {
7131
+ console.error("Error speaking text:", Z), d(Z.message || "Failed to speak text");
7132
7132
  }
7133
7133
  else
7134
7134
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!r.current);
7135
- }, [g, p]), T = M(() => {
7135
+ }, [g, p]), E = T(() => {
7136
7136
  r.current && (r.current.stopSpeaking(), r.current.setSlowdownRate && (r.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7137
- }, []), F = M((S) => {
7137
+ }, []), P = T((S) => {
7138
7138
  r.current && r.current.setMood(S);
7139
- }, []), J = M((S) => {
7139
+ }, []), U = T((S) => {
7140
7140
  r.current && r.current.setSlowdownRate && (r.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7141
- }, []), ye = M((S, W = !1) => {
7141
+ }, []), oe = T((S, Z = !1) => {
7142
7142
  if (r.current && r.current.playAnimation) {
7143
7143
  if (r.current.setShowFullAvatar)
7144
7144
  try {
7145
7145
  r.current.setShowFullAvatar(!0);
7146
- } catch (Z) {
7147
- console.warn("Error setting full body mode:", Z);
7146
+ } catch (X) {
7147
+ console.warn("Error setting full body mode:", X);
7148
7148
  }
7149
7149
  if (S.includes("."))
7150
7150
  try {
7151
- r.current.playAnimation(S, null, 10, 0, 0.01, W), console.log("Playing animation:", S);
7152
- } catch (Z) {
7153
- console.log(`Failed to play ${S}:`, Z);
7151
+ r.current.playAnimation(S, null, 10, 0, 0.01, Z), console.log("Playing animation:", S);
7152
+ } catch (X) {
7153
+ console.log(`Failed to play ${S}:`, X);
7154
7154
  try {
7155
7155
  r.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7156
7156
  } catch ($) {
@@ -7158,11 +7158,11 @@ const pt = ze(({
7158
7158
  }
7159
7159
  }
7160
7160
  else {
7161
- const Z = [".fbx", ".glb", ".gltf"];
7161
+ const X = [".fbx", ".glb", ".gltf"];
7162
7162
  let $ = !1;
7163
- for (const se of Z)
7163
+ for (const se of X)
7164
7164
  try {
7165
- r.current.playAnimation(S + se, null, 10, 0, 0.01, W), console.log("Playing animation:", S + se), $ = !0;
7165
+ r.current.playAnimation(S + se, null, 10, 0, 0.01, Z), console.log("Playing animation:", S + se), $ = !0;
7166
7166
  break;
7167
7167
  } catch {
7168
7168
  console.log(`Failed to play ${S}${se}, trying next format...`);
@@ -7179,20 +7179,20 @@ const pt = ze(({
7179
7179
  } else
7180
7180
  console.warn("Animation system not available or animation not found:", S);
7181
7181
  }, []);
7182
- return Ce(l, () => ({
7183
- speakText: I,
7184
- stopSpeaking: T,
7185
- setMood: F,
7186
- setTimingAdjustment: J,
7187
- playAnimation: ye,
7182
+ return Ee(l, () => ({
7183
+ speakText: f,
7184
+ stopSpeaking: E,
7185
+ setMood: P,
7186
+ setTimingAdjustment: U,
7187
+ playAnimation: oe,
7188
7188
  isReady: g,
7189
7189
  talkingHead: r.current,
7190
7190
  setBodyMovement: (S) => {
7191
7191
  if (r.current && r.current.setShowFullAvatar && r.current.setBodyMovement)
7192
7192
  try {
7193
7193
  r.current.setShowFullAvatar(!0), r.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7194
- } catch (W) {
7195
- console.warn("Error setting body movement:", W);
7194
+ } catch (Z) {
7195
+ console.warn("Error setting body movement:", Z);
7196
7196
  }
7197
7197
  },
7198
7198
  setMovementIntensity: (S) => r.current?.setMovementIntensity(S),
@@ -7208,8 +7208,8 @@ const pt = ze(({
7208
7208
  if (r.current && r.current.setShowFullAvatar && r.current.playReaction)
7209
7209
  try {
7210
7210
  r.current.setShowFullAvatar(!0), r.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7211
- } catch (W) {
7212
- console.warn("Error playing reaction:", W);
7211
+ } catch (Z) {
7212
+ console.warn("Error playing reaction:", Z);
7213
7213
  }
7214
7214
  },
7215
7215
  playCelebration: () => {
@@ -7224,8 +7224,8 @@ const pt = ze(({
7224
7224
  if (r.current && r.current.setShowFullAvatar)
7225
7225
  try {
7226
7226
  r.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7227
- } catch (W) {
7228
- console.warn("Error setting showFullAvatar:", W);
7227
+ } catch (Z) {
7228
+ console.warn("Error setting showFullAvatar:", Z);
7229
7229
  }
7230
7230
  },
7231
7231
  lockAvatarPosition: () => {
@@ -7244,11 +7244,11 @@ const pt = ze(({
7244
7244
  console.warn("Error unlocking avatar position:", S);
7245
7245
  }
7246
7246
  }
7247
- })), /* @__PURE__ */ Oe("div", { className: `talking-head-container ${i}`, style: s, children: [
7248
- /* @__PURE__ */ ge(
7247
+ })), /* @__PURE__ */ Pe("div", { className: `talking-head-container ${i}`, style: s, children: [
7248
+ /* @__PURE__ */ me(
7249
7249
  "div",
7250
7250
  {
7251
- ref: u,
7251
+ ref: h,
7252
7252
  className: "talking-head-viewer",
7253
7253
  style: {
7254
7254
  width: "100%",
@@ -7257,7 +7257,7 @@ const pt = ze(({
7257
7257
  }
7258
7258
  }
7259
7259
  ),
7260
- h && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
7260
+ u && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7261
7261
  position: "absolute",
7262
7262
  top: "50%",
7263
7263
  left: "50%",
@@ -7266,7 +7266,7 @@ const pt = ze(({
7266
7266
  fontSize: "18px",
7267
7267
  zIndex: 10
7268
7268
  }, children: "Loading avatar..." }),
7269
- c && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7269
+ c && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7270
7270
  position: "absolute",
7271
7271
  top: "50%",
7272
7272
  left: "50%",
@@ -7281,8 +7281,222 @@ const pt = ze(({
7281
7281
  ] });
7282
7282
  });
7283
7283
  pt.displayName = "TalkingHeadComponent";
7284
- const gt = ze(({
7285
- curriculumData: U = null,
7284
+ const gt = Me(({
7285
+ text: G = null,
7286
+ avatarUrl: t = "/avatars/brunette.glb",
7287
+ avatarBody: e = "F",
7288
+ mood: n = "neutral",
7289
+ ttsLang: i = "en",
7290
+ ttsService: s = null,
7291
+ ttsVoice: o = null,
7292
+ ttsApiKey: l = null,
7293
+ bodyMovement: h = "idle",
7294
+ movementIntensity: r = 0.5,
7295
+ showFullAvatar: u = !1,
7296
+ cameraView: a = "upper",
7297
+ onReady: c = () => {
7298
+ },
7299
+ onLoading: d = () => {
7300
+ },
7301
+ onError: g = () => {
7302
+ },
7303
+ onSpeechEnd: y = () => {
7304
+ },
7305
+ className: b = "",
7306
+ style: I = {},
7307
+ animations: V = {},
7308
+ autoSpeak: p = !1
7309
+ }, M) => {
7310
+ const w = D(null), f = D(null), E = D(u), P = D(null), U = D(null), oe = D(!1), S = D({ remainingText: null, originalText: null, options: null }), Z = D([]), [K, X] = ce(!0), [$, se] = ce(null), [ae, pe] = ce(!1), [ee, le] = ce(!1);
7311
+ de(() => {
7312
+ oe.current = ee;
7313
+ }, [ee]), de(() => {
7314
+ E.current = u;
7315
+ }, [u]);
7316
+ const O = Fe(), v = s || O.service;
7317
+ let R;
7318
+ v === "browser" ? R = {
7319
+ service: "browser",
7320
+ endpoint: "",
7321
+ apiKey: null,
7322
+ defaultVoice: "Google US English"
7323
+ } : v === "elevenlabs" ? R = {
7324
+ service: "elevenlabs",
7325
+ endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
7326
+ apiKey: l || O.apiKey,
7327
+ defaultVoice: o || O.defaultVoice || Ie.defaultVoice,
7328
+ voices: O.voices || Ie.voices
7329
+ } : v === "deepgram" ? R = {
7330
+ service: "deepgram",
7331
+ endpoint: "https://api.deepgram.com/v1/speak",
7332
+ apiKey: l || O.apiKey,
7333
+ defaultVoice: o || O.defaultVoice || Te.defaultVoice,
7334
+ voices: O.voices || Te.voices
7335
+ } : R = {
7336
+ ...O,
7337
+ apiKey: l !== null ? l : O.apiKey
7338
+ };
7339
+ const z = {
7340
+ url: t,
7341
+ body: e,
7342
+ avatarMood: n,
7343
+ ttsLang: v === "browser" ? "en-US" : i,
7344
+ ttsVoice: o || R.defaultVoice,
7345
+ lipsyncLang: "en",
7346
+ showFullAvatar: u,
7347
+ bodyMovement: h,
7348
+ movementIntensity: r
7349
+ }, H = {
7350
+ ttsEndpoint: R.endpoint,
7351
+ ttsApikey: R.apiKey,
7352
+ ttsService: v,
7353
+ lipsyncModules: ["en"],
7354
+ cameraView: a
7355
+ }, N = T(async () => {
7356
+ if (!(!w.current || f.current))
7357
+ try {
7358
+ X(!0), se(null), f.current = new Be(w.current, H), await f.current.showAvatar(z, (te) => {
7359
+ if (te.lengthComputable) {
7360
+ const L = Math.min(100, Math.round(te.loaded / te.total * 100));
7361
+ d(L);
7362
+ }
7363
+ }), X(!1), pe(!0), c(f.current);
7364
+ const C = () => {
7365
+ document.visibilityState === "visible" ? f.current?.start() : f.current?.stop();
7366
+ };
7367
+ return document.addEventListener("visibilitychange", C), () => {
7368
+ document.removeEventListener("visibilitychange", C);
7369
+ };
7370
+ } catch (C) {
7371
+ console.error("Error initializing TalkingHead:", C), se(C.message || "Failed to initialize avatar"), X(!1), g(C);
7372
+ }
7373
+ }, []);
7374
+ de(() => (N(), () => {
7375
+ f.current && (f.current.stop(), f.current.dispose(), f.current = null);
7376
+ }), [N]);
7377
+ const _ = T(async () => {
7378
+ if (f.current)
7379
+ try {
7380
+ const C = f.current.audioCtx || f.current.audioContext;
7381
+ C && (C.state === "suspended" || C.state === "interrupted") && (await C.resume(), console.log("Audio context resumed"));
7382
+ } catch (C) {
7383
+ console.warn("Failed to resume audio context:", C);
7384
+ }
7385
+ }, []);
7386
+ de(() => {
7387
+ ae && G && p && f.current && j(G);
7388
+ }, [ae, G, p, j]);
7389
+ const j = T(async (C, te = {}) => {
7390
+ if (!f.current || !ae) {
7391
+ console.warn("Avatar not ready for speaking");
7392
+ return;
7393
+ }
7394
+ if (!C || C.trim() === "") {
7395
+ console.warn("No text provided to speak");
7396
+ return;
7397
+ }
7398
+ await _(), S.current = { remainingText: null, originalText: null, options: null }, Z.current = [], P.current = { text: C, options: te }, U.current && (clearInterval(U.current), U.current = null), le(!1), oe.current = !1;
7399
+ const L = C.split(/[.!?]+/).filter((B) => B.trim().length > 0);
7400
+ Z.current = L;
7401
+ const F = {
7402
+ lipsyncLang: te.lipsyncLang || "en",
7403
+ onSpeechEnd: () => {
7404
+ U.current && (clearInterval(U.current), U.current = null), te.onSpeechEnd && te.onSpeechEnd(), y();
7405
+ }
7406
+ };
7407
+ try {
7408
+ f.current.speakText(C, F);
7409
+ } catch (B) {
7410
+ console.error("Error speaking text:", B), se(B.message || "Failed to speak text");
7411
+ }
7412
+ }, [ae, y, _]), q = T(() => {
7413
+ if (f.current)
7414
+ try {
7415
+ const C = f.current.isSpeaking || !1, te = f.current.audioPlaylist || [], L = f.current.speechQueue || [];
7416
+ if (C || te.length > 0 || L.length > 0) {
7417
+ U.current && (clearInterval(U.current), U.current = null);
7418
+ let F = "";
7419
+ L.length > 0 && (F = L.map((B) => B.text && Array.isArray(B.text) ? B.text.map((J) => J.word).join(" ") : B.text || "").join(" ")), S.current = {
7420
+ remainingText: F || null,
7421
+ originalText: P.current?.text || null,
7422
+ options: P.current?.options || null
7423
+ }, f.current.speechQueue.length = 0, f.current.pauseSpeaking(), le(!0), oe.current = !0;
7424
+ }
7425
+ } catch (C) {
7426
+ console.warn("Error pausing speech:", C);
7427
+ }
7428
+ }, []), Le = T(async () => {
7429
+ if (!(!f.current || !ee))
7430
+ try {
7431
+ await _(), le(!1), oe.current = !1;
7432
+ const C = S.current?.remainingText, te = S.current?.originalText || P.current?.text, L = S.current?.options || P.current?.options || {}, F = C || te;
7433
+ F && j(F, L);
7434
+ } catch (C) {
7435
+ console.warn("Error resuming speech:", C), le(!1), oe.current = !1;
7436
+ }
7437
+ }, [ee, j, _]), we = T(() => {
7438
+ f.current && (f.current.stopSpeaking(), U.current && (clearInterval(U.current), U.current = null), le(!1), oe.current = !1);
7439
+ }, []);
7440
+ return Ee(M, () => ({
7441
+ speakText: j,
7442
+ pauseSpeaking: q,
7443
+ resumeSpeaking: Le,
7444
+ stopSpeaking: we,
7445
+ resumeAudioContext: _,
7446
+ isPaused: () => ee,
7447
+ setMood: (C) => f.current?.setMood(C),
7448
+ setBodyMovement: (C) => {
7449
+ f.current && f.current.setBodyMovement(C);
7450
+ },
7451
+ playAnimation: (C, te = !1) => {
7452
+ f.current && f.current.playAnimation && f.current.playAnimation(C, null, 10, 0, 0.01, te);
7453
+ },
7454
+ playReaction: (C) => f.current?.playReaction(C),
7455
+ playCelebration: () => f.current?.playCelebration(),
7456
+ setShowFullAvatar: (C) => {
7457
+ f.current && (E.current = C, f.current.setShowFullAvatar(C));
7458
+ },
7459
+ isReady: ae,
7460
+ talkingHead: f.current
7461
+ })), /* @__PURE__ */ Pe("div", { className: `simple-talking-avatar-container ${b}`, style: I, children: [
7462
+ /* @__PURE__ */ me(
7463
+ "div",
7464
+ {
7465
+ ref: w,
7466
+ className: "talking-head-viewer",
7467
+ style: {
7468
+ width: "100%",
7469
+ height: "100%",
7470
+ minHeight: "400px"
7471
+ }
7472
+ }
7473
+ ),
7474
+ K && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7475
+ position: "absolute",
7476
+ top: "50%",
7477
+ left: "50%",
7478
+ transform: "translate(-50%, -50%)",
7479
+ color: "white",
7480
+ fontSize: "18px",
7481
+ zIndex: 10
7482
+ }, children: "Loading avatar..." }),
7483
+ $ && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7484
+ position: "absolute",
7485
+ top: "50%",
7486
+ left: "50%",
7487
+ transform: "translate(-50%, -50%)",
7488
+ color: "#ff6b6b",
7489
+ fontSize: "16px",
7490
+ textAlign: "center",
7491
+ zIndex: 10,
7492
+ padding: "20px",
7493
+ borderRadius: "8px"
7494
+ }, children: $ })
7495
+ ] });
7496
+ });
7497
+ gt.displayName = "SimpleTalkingAvatar";
7498
+ const yt = Me(({
7499
+ curriculumData: G = null,
7286
7500
  avatarConfig: t = {},
7287
7501
  animations: e = {},
7288
7502
  onLessonStart: n = () => {
@@ -7295,9 +7509,9 @@ const gt = ze(({
7295
7509
  },
7296
7510
  onCustomAction: l = () => {
7297
7511
  },
7298
- autoStart: u = !1
7512
+ autoStart: h = !1
7299
7513
  }, r) => {
7300
- const h = N(null), a = N({
7514
+ const u = D(null), a = D({
7301
7515
  currentModuleIndex: 0,
7302
7516
  currentLessonIndex: 0,
7303
7517
  currentQuestionIndex: 0,
@@ -7307,18 +7521,18 @@ const gt = ze(({
7307
7521
  curriculumCompleted: !1,
7308
7522
  score: 0,
7309
7523
  totalQuestions: 0
7310
- }), c = N({
7524
+ }), c = D({
7311
7525
  onLessonStart: n,
7312
7526
  onLessonComplete: i,
7313
7527
  onQuestionAnswer: s,
7314
7528
  onCurriculumComplete: o,
7315
7529
  onCustomAction: l
7316
- }), d = N(null), g = N(null), y = N(null), x = N(null), v = N(null), B = N(null), p = N(null), H = N(U?.curriculum || {
7530
+ }), d = D(null), g = D(null), y = D(null), b = D(null), I = D(null), V = D(null), p = D(null), M = D(G?.curriculum || {
7317
7531
  title: "Default Curriculum",
7318
7532
  description: "No curriculum data provided",
7319
7533
  language: "en",
7320
7534
  modules: []
7321
- }), z = N({
7535
+ }), w = D({
7322
7536
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7323
7537
  avatarBody: t.avatarBody || "F",
7324
7538
  mood: t.mood || "happy",
@@ -7332,7 +7546,7 @@ const gt = ze(({
7332
7546
  animations: e,
7333
7547
  lipsyncLang: "en"
7334
7548
  });
7335
- Ie(() => {
7549
+ de(() => {
7336
7550
  c.current = {
7337
7551
  onLessonStart: n,
7338
7552
  onLessonComplete: i,
@@ -7340,13 +7554,13 @@ const gt = ze(({
7340
7554
  onCurriculumComplete: o,
7341
7555
  onCustomAction: l
7342
7556
  };
7343
- }, [n, i, s, o, l]), Ie(() => {
7344
- H.current = U?.curriculum || {
7557
+ }, [n, i, s, o, l]), de(() => {
7558
+ M.current = G?.curriculum || {
7345
7559
  title: "Default Curriculum",
7346
7560
  description: "No curriculum data provided",
7347
7561
  language: "en",
7348
7562
  modules: []
7349
- }, z.current = {
7563
+ }, w.current = {
7350
7564
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7351
7565
  avatarBody: t.avatarBody || "F",
7352
7566
  mood: t.mood || "happy",
@@ -7360,34 +7574,34 @@ const gt = ze(({
7360
7574
  animations: e,
7361
7575
  lipsyncLang: "en"
7362
7576
  };
7363
- }, [U, t, e]);
7364
- const I = M(() => (H.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), T = M(() => I()?.questions[a.current.currentQuestionIndex], [I]), F = M((b, R) => R.type === "multiple_choice" || R.type === "true_false" ? b === R.answer : R.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), J = M(() => {
7577
+ }, [G, t, e]);
7578
+ const f = T(() => (M.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), E = T(() => f()?.questions[a.current.currentQuestionIndex], [f]), P = T((v, R) => R.type === "multiple_choice" || R.type === "true_false" ? v === R.answer : R.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), U = T(() => {
7365
7579
  a.current.lessonCompleted = !0, a.current.isQuestionMode = !1;
7366
- const b = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7580
+ const v = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7367
7581
  let R = "Congratulations! You've completed this lesson";
7368
- if (a.current.totalQuestions > 0 ? R += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : R += "! ", b >= 80 ? R += "Excellent work! You have a great understanding of this topic." : b >= 60 ? R += "Good job! You understand most of the concepts." : R += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7582
+ if (a.current.totalQuestions > 0 ? R += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${v} percent. ` : R += "! ", v >= 80 ? R += "Excellent work! You have a great understanding of this topic." : v >= 60 ? R += "Good job! You understand most of the concepts." : R += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7369
7583
  moduleIndex: a.current.currentModuleIndex,
7370
7584
  lessonIndex: a.current.currentLessonIndex,
7371
7585
  score: a.current.score,
7372
7586
  totalQuestions: a.current.totalQuestions,
7373
- percentage: b
7587
+ percentage: v
7374
7588
  }), c.current.onCustomAction({
7375
7589
  type: "lessonComplete",
7376
7590
  moduleIndex: a.current.currentModuleIndex,
7377
7591
  lessonIndex: a.current.currentLessonIndex,
7378
7592
  score: a.current.score,
7379
7593
  totalQuestions: a.current.totalQuestions,
7380
- percentage: b
7381
- }), h.current) {
7382
- if (h.current.setMood("happy"), e.lessonComplete)
7594
+ percentage: v
7595
+ }), u.current) {
7596
+ if (u.current.setMood("happy"), e.lessonComplete)
7383
7597
  try {
7384
- h.current.playAnimation(e.lessonComplete, !0);
7598
+ u.current.playAnimation(e.lessonComplete, !0);
7385
7599
  } catch {
7386
- h.current.playCelebration();
7600
+ u.current.playCelebration();
7387
7601
  }
7388
- const w = H.current || { modules: [] }, C = w.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ee = a.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = D || ee, Y = z.current || { lipsyncLang: "en" };
7389
- h.current.speakText(R, {
7390
- lipsyncLang: Y.lipsyncLang,
7602
+ const z = M.current || { modules: [] }, H = z.modules[a.current.currentModuleIndex], N = a.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, _ = a.current.currentModuleIndex < (z.modules?.length || 0) - 1, j = N || _, q = w.current || { lipsyncLang: "en" };
7603
+ u.current.speakText(R, {
7604
+ lipsyncLang: q.lipsyncLang,
7391
7605
  onSpeechEnd: () => {
7392
7606
  c.current.onCustomAction({
7393
7607
  type: "lessonCompleteFeedbackDone",
@@ -7395,32 +7609,32 @@ const gt = ze(({
7395
7609
  lessonIndex: a.current.currentLessonIndex,
7396
7610
  score: a.current.score,
7397
7611
  totalQuestions: a.current.totalQuestions,
7398
- percentage: b,
7399
- hasNextLesson: q
7612
+ percentage: v,
7613
+ hasNextLesson: j
7400
7614
  });
7401
7615
  }
7402
7616
  });
7403
7617
  }
7404
- }, [e.lessonComplete]), ye = M(() => {
7618
+ }, [e.lessonComplete]), oe = T(() => {
7405
7619
  a.current.curriculumCompleted = !0;
7406
- const b = H.current || { modules: [] };
7620
+ const v = M.current || { modules: [] };
7407
7621
  if (c.current.onCurriculumComplete({
7408
- modules: b.modules.length,
7409
- totalLessons: b.modules.reduce((R, w) => R + w.lessons.length, 0)
7410
- }), h.current) {
7411
- if (h.current.setMood("celebrating"), e.curriculumComplete)
7622
+ modules: v.modules.length,
7623
+ totalLessons: v.modules.reduce((R, z) => R + z.lessons.length, 0)
7624
+ }), u.current) {
7625
+ if (u.current.setMood("celebrating"), e.curriculumComplete)
7412
7626
  try {
7413
- h.current.playAnimation(e.curriculumComplete, !0);
7627
+ u.current.playAnimation(e.curriculumComplete, !0);
7414
7628
  } catch {
7415
- h.current.playCelebration();
7629
+ u.current.playCelebration();
7416
7630
  }
7417
- const R = z.current || { lipsyncLang: "en" };
7418
- h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
7631
+ const R = w.current || { lipsyncLang: "en" };
7632
+ u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
7419
7633
  }
7420
- }, [e.curriculumComplete]), S = M(() => {
7421
- const b = I();
7422
- a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = b?.questions?.length || 0, a.current.score = 0;
7423
- const R = T();
7634
+ }, [e.curriculumComplete]), S = T(() => {
7635
+ const v = f();
7636
+ a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = v?.questions?.length || 0, a.current.score = 0;
7637
+ const R = E();
7424
7638
  R && c.current.onCustomAction({
7425
7639
  type: "questionStart",
7426
7640
  moduleIndex: a.current.currentModuleIndex,
@@ -7430,35 +7644,35 @@ const gt = ze(({
7430
7644
  question: R,
7431
7645
  score: a.current.score
7432
7646
  });
7433
- const w = () => {
7434
- if (!h.current || !R) return;
7435
- if (h.current.setMood("happy"), e.questionStart)
7647
+ const z = () => {
7648
+ if (!u.current || !R) return;
7649
+ if (u.current.setMood("happy"), e.questionStart)
7436
7650
  try {
7437
- h.current.playAnimation(e.questionStart, !0);
7438
- } catch (D) {
7439
- console.warn("Failed to play questionStart animation:", D);
7651
+ u.current.playAnimation(e.questionStart, !0);
7652
+ } catch (N) {
7653
+ console.warn("Failed to play questionStart animation:", N);
7440
7654
  }
7441
- const C = z.current || { lipsyncLang: "en" };
7442
- R.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang });
7655
+ const H = w.current || { lipsyncLang: "en" };
7656
+ R.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : R.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : R.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: H.lipsyncLang });
7443
7657
  };
7444
- if (h.current && h.current.isReady && R)
7445
- w();
7446
- else if (h.current && h.current.isReady) {
7447
- const C = z.current || { lipsyncLang: "en" };
7448
- h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
7658
+ if (u.current && u.current.isReady && R)
7659
+ z();
7660
+ else if (u.current && u.current.isReady) {
7661
+ const H = w.current || { lipsyncLang: "en" };
7662
+ u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: H.lipsyncLang });
7449
7663
  } else {
7450
- const C = setInterval(() => {
7451
- h.current && h.current.isReady && (clearInterval(C), R && w());
7664
+ const H = setInterval(() => {
7665
+ u.current && u.current.isReady && (clearInterval(H), R && z());
7452
7666
  }, 100);
7453
7667
  setTimeout(() => {
7454
- clearInterval(C);
7668
+ clearInterval(H);
7455
7669
  }, 5e3);
7456
7670
  }
7457
- }, [e.questionStart, I, T]), W = M(() => {
7458
- const b = I();
7459
- if (a.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7460
- h.current && h.current.stopSpeaking && h.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7461
- const R = T();
7671
+ }, [e.questionStart, f, E]), Z = T(() => {
7672
+ const v = f();
7673
+ if (a.current.currentQuestionIndex < (v?.questions?.length || 0) - 1) {
7674
+ u.current && u.current.stopSpeaking && u.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7675
+ const R = E();
7462
7676
  R && c.current.onCustomAction({
7463
7677
  type: "nextQuestion",
7464
7678
  moduleIndex: a.current.currentModuleIndex,
@@ -7468,45 +7682,45 @@ const gt = ze(({
7468
7682
  question: R,
7469
7683
  score: a.current.score
7470
7684
  });
7471
- const w = () => {
7472
- if (!h.current || !R) return;
7473
- if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
7685
+ const z = () => {
7686
+ if (!u.current || !R) return;
7687
+ if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
7474
7688
  try {
7475
- h.current.playAnimation(e.nextQuestion, !0);
7476
- } catch (Y) {
7477
- console.warn("Failed to play nextQuestion animation:", Y);
7689
+ u.current.playAnimation(e.nextQuestion, !0);
7690
+ } catch (q) {
7691
+ console.warn("Failed to play nextQuestion animation:", q);
7478
7692
  }
7479
- const C = z.current || { lipsyncLang: "en" }, ee = I()?.questions?.length || 0, q = a.current.currentQuestionIndex >= ee - 1;
7693
+ const H = w.current || { lipsyncLang: "en" }, _ = f()?.questions?.length || 0, j = a.current.currentQuestionIndex >= _ - 1;
7480
7694
  if (R.type === "code_test") {
7481
- const Y = q ? `Great! Here's your final coding challenge: ${R.question}` : `Great! Now let's move on to your next coding challenge: ${R.question}`;
7482
- h.current.speakText(Y, {
7483
- lipsyncLang: C.lipsyncLang
7695
+ const q = j ? `Great! Here's your final coding challenge: ${R.question}` : `Great! Now let's move on to your next coding challenge: ${R.question}`;
7696
+ u.current.speakText(q, {
7697
+ lipsyncLang: H.lipsyncLang
7484
7698
  });
7485
7699
  } else if (R.type === "multiple_choice") {
7486
- const Y = q ? `Alright! Here's your final question: ${R.question}` : `Alright! Here's your next question: ${R.question}`;
7487
- h.current.speakText(Y, {
7488
- lipsyncLang: C.lipsyncLang
7700
+ const q = j ? `Alright! Here's your final question: ${R.question}` : `Alright! Here's your next question: ${R.question}`;
7701
+ u.current.speakText(q, {
7702
+ lipsyncLang: H.lipsyncLang
7489
7703
  });
7490
7704
  } else if (R.type === "true_false") {
7491
- const Y = q ? `Now let's try this final one: ${R.question}` : `Now let's try this one: ${R.question}`;
7492
- h.current.speakText(Y, {
7493
- lipsyncLang: C.lipsyncLang
7705
+ const q = j ? `Now let's try this final one: ${R.question}` : `Now let's try this one: ${R.question}`;
7706
+ u.current.speakText(q, {
7707
+ lipsyncLang: H.lipsyncLang
7494
7708
  });
7495
7709
  } else {
7496
- const Y = q ? `Here's your final question: ${R.question}` : `Here's the next question: ${R.question}`;
7497
- h.current.speakText(Y, {
7498
- lipsyncLang: C.lipsyncLang
7710
+ const q = j ? `Here's your final question: ${R.question}` : `Here's the next question: ${R.question}`;
7711
+ u.current.speakText(q, {
7712
+ lipsyncLang: H.lipsyncLang
7499
7713
  });
7500
7714
  }
7501
7715
  };
7502
- if (h.current && h.current.isReady && R)
7503
- w();
7716
+ if (u.current && u.current.isReady && R)
7717
+ z();
7504
7718
  else if (R) {
7505
- const C = setInterval(() => {
7506
- h.current && h.current.isReady && (clearInterval(C), w());
7719
+ const H = setInterval(() => {
7720
+ u.current && u.current.isReady && (clearInterval(H), z());
7507
7721
  }, 100);
7508
7722
  setTimeout(() => {
7509
- clearInterval(C);
7723
+ clearInterval(H);
7510
7724
  }, 5e3);
7511
7725
  }
7512
7726
  } else
@@ -7517,108 +7731,108 @@ const gt = ze(({
7517
7731
  totalQuestions: a.current.totalQuestions,
7518
7732
  score: a.current.score
7519
7733
  });
7520
- }, [e.nextQuestion, I, T]), j = M(() => {
7521
- const b = H.current || { modules: [] }, R = b.modules[a.current.currentModuleIndex];
7734
+ }, [e.nextQuestion, f, E]), K = T(() => {
7735
+ const v = M.current || { modules: [] }, R = v.modules[a.current.currentModuleIndex];
7522
7736
  if (a.current.currentLessonIndex < (R?.lessons?.length || 0) - 1) {
7523
7737
  a.current.currentLessonIndex += 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7524
- const C = b.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ee = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = D || ee;
7738
+ const H = v.modules[a.current.currentModuleIndex], N = a.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, _ = a.current.currentModuleIndex < (v.modules?.length || 0) - 1, j = N || _;
7525
7739
  c.current.onCustomAction({
7526
7740
  type: "lessonStart",
7527
7741
  moduleIndex: a.current.currentModuleIndex,
7528
7742
  lessonIndex: a.current.currentLessonIndex,
7529
- hasNextLesson: q
7743
+ hasNextLesson: j
7530
7744
  }), c.current.onLessonStart({
7531
7745
  moduleIndex: a.current.currentModuleIndex,
7532
7746
  lessonIndex: a.current.currentLessonIndex,
7533
- lesson: I()
7534
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7535
- } else if (a.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7747
+ lesson: f()
7748
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
7749
+ } else if (a.current.currentModuleIndex < (v.modules?.length || 0) - 1) {
7536
7750
  a.current.currentModuleIndex += 1, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7537
- const D = b.modules[a.current.currentModuleIndex], ee = a.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, q = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, Y = ee || q;
7751
+ const N = v.modules[a.current.currentModuleIndex], _ = a.current.currentLessonIndex < (N?.lessons?.length || 0) - 1, j = a.current.currentModuleIndex < (v.modules?.length || 0) - 1, q = _ || j;
7538
7752
  c.current.onCustomAction({
7539
7753
  type: "lessonStart",
7540
7754
  moduleIndex: a.current.currentModuleIndex,
7541
7755
  lessonIndex: a.current.currentLessonIndex,
7542
- hasNextLesson: Y
7756
+ hasNextLesson: q
7543
7757
  }), c.current.onLessonStart({
7544
7758
  moduleIndex: a.current.currentModuleIndex,
7545
7759
  lessonIndex: a.current.currentLessonIndex,
7546
- lesson: I()
7547
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7760
+ lesson: f()
7761
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
7548
7762
  } else
7549
- v.current && v.current();
7550
- }, []), Z = M(() => {
7551
- const b = I();
7763
+ I.current && I.current();
7764
+ }, []), X = T(() => {
7765
+ const v = f();
7552
7766
  let R = null;
7553
- if (b?.avatar_script && b?.body) {
7554
- const w = b.avatar_script.trim(), C = b.body.trim(), D = w.match(/[.!?]$/) ? " " : ". ";
7555
- R = `${w}${D}${C}`;
7767
+ if (v?.avatar_script && v?.body) {
7768
+ const z = v.avatar_script.trim(), H = v.body.trim(), N = z.match(/[.!?]$/) ? " " : ". ";
7769
+ R = `${z}${N}${H}`;
7556
7770
  } else
7557
- R = b?.avatar_script || b?.body || null;
7558
- if (h.current && h.current.isReady && R) {
7559
- a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, h.current.setMood("happy");
7560
- let w = !1;
7771
+ R = v?.avatar_script || v?.body || null;
7772
+ if (u.current && u.current.isReady && R) {
7773
+ a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, u.current.setMood("happy");
7774
+ let z = !1;
7561
7775
  if (e.teaching)
7562
7776
  try {
7563
- h.current.playAnimation(e.teaching, !0), w = !0;
7564
- } catch (D) {
7565
- console.warn("Failed to play teaching animation:", D);
7777
+ u.current.playAnimation(e.teaching, !0), z = !0;
7778
+ } catch (N) {
7779
+ console.warn("Failed to play teaching animation:", N);
7566
7780
  }
7567
- w || h.current.setBodyMovement("gesturing");
7568
- const C = z.current || { lipsyncLang: "en" };
7781
+ z || u.current.setBodyMovement("gesturing");
7782
+ const H = w.current || { lipsyncLang: "en" };
7569
7783
  c.current.onLessonStart({
7570
7784
  moduleIndex: a.current.currentModuleIndex,
7571
7785
  lessonIndex: a.current.currentLessonIndex,
7572
- lesson: b
7786
+ lesson: v
7573
7787
  }), c.current.onCustomAction({
7574
7788
  type: "teachingStart",
7575
7789
  moduleIndex: a.current.currentModuleIndex,
7576
7790
  lessonIndex: a.current.currentLessonIndex,
7577
- lesson: b
7578
- }), h.current.speakText(R, {
7579
- lipsyncLang: C.lipsyncLang,
7791
+ lesson: v
7792
+ }), u.current.speakText(R, {
7793
+ lipsyncLang: H.lipsyncLang,
7580
7794
  onSpeechEnd: () => {
7581
7795
  a.current.isTeaching = !1, c.current.onCustomAction({
7582
7796
  type: "teachingComplete",
7583
7797
  moduleIndex: a.current.currentModuleIndex,
7584
7798
  lessonIndex: a.current.currentLessonIndex,
7585
- lesson: b,
7586
- hasQuestions: b.questions && b.questions.length > 0
7587
- }), b?.code_example && c.current.onCustomAction({
7799
+ lesson: v,
7800
+ hasQuestions: v.questions && v.questions.length > 0
7801
+ }), v?.code_example && c.current.onCustomAction({
7588
7802
  type: "codeExampleReady",
7589
7803
  moduleIndex: a.current.currentModuleIndex,
7590
7804
  lessonIndex: a.current.currentLessonIndex,
7591
- lesson: b,
7592
- codeExample: b.code_example
7805
+ lesson: v,
7806
+ codeExample: v.code_example
7593
7807
  });
7594
7808
  }
7595
7809
  });
7596
7810
  }
7597
- }, [e.teaching, I]), $ = M((b) => {
7598
- const R = T(), w = F(b, R);
7599
- if (w && (a.current.score += 1), c.current.onQuestionAnswer({
7811
+ }, [e.teaching, f]), $ = T((v) => {
7812
+ const R = E(), z = P(v, R);
7813
+ if (z && (a.current.score += 1), c.current.onQuestionAnswer({
7600
7814
  moduleIndex: a.current.currentModuleIndex,
7601
7815
  lessonIndex: a.current.currentLessonIndex,
7602
7816
  questionIndex: a.current.currentQuestionIndex,
7603
- answer: b,
7604
- isCorrect: w,
7817
+ answer: v,
7818
+ isCorrect: z,
7605
7819
  question: R
7606
- }), h.current)
7607
- if (w) {
7608
- if (h.current.setMood("happy"), e.correct)
7820
+ }), u.current)
7821
+ if (z) {
7822
+ if (u.current.setMood("happy"), e.correct)
7609
7823
  try {
7610
- h.current.playReaction("happy");
7824
+ u.current.playReaction("happy");
7611
7825
  } catch {
7612
- h.current.setBodyMovement("happy");
7826
+ u.current.setBodyMovement("happy");
7613
7827
  }
7614
- h.current.setBodyMovement("gesturing");
7615
- const D = I()?.questions?.length || 0;
7616
- a.current.currentQuestionIndex >= D - 1;
7617
- const ee = a.current.currentQuestionIndex < D - 1;
7618
- console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", D, "hasNextQuestion:", ee);
7619
- const q = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, Y = z.current || { lipsyncLang: "en" };
7620
- h.current.speakText(q, {
7621
- lipsyncLang: Y.lipsyncLang,
7828
+ u.current.setBodyMovement("gesturing");
7829
+ const N = f()?.questions?.length || 0;
7830
+ a.current.currentQuestionIndex >= N - 1;
7831
+ const _ = a.current.currentQuestionIndex < N - 1;
7832
+ console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", _);
7833
+ const j = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, q = w.current || { lipsyncLang: "en" };
7834
+ u.current.speakText(j, {
7835
+ lipsyncLang: q.lipsyncLang,
7622
7836
  onSpeechEnd: () => {
7623
7837
  c.current.onCustomAction({
7624
7838
  type: "answerFeedbackComplete",
@@ -7626,25 +7840,25 @@ const gt = ze(({
7626
7840
  lessonIndex: a.current.currentLessonIndex,
7627
7841
  questionIndex: a.current.currentQuestionIndex,
7628
7842
  isCorrect: !0,
7629
- hasNextQuestion: ee,
7843
+ hasNextQuestion: _,
7630
7844
  score: a.current.score,
7631
7845
  totalQuestions: a.current.totalQuestions
7632
7846
  });
7633
7847
  }
7634
7848
  });
7635
7849
  } else {
7636
- if (h.current.setMood("sad"), e.incorrect)
7850
+ if (u.current.setMood("sad"), e.incorrect)
7637
7851
  try {
7638
- h.current.playAnimation(e.incorrect, !0);
7852
+ u.current.playAnimation(e.incorrect, !0);
7639
7853
  } catch {
7640
- h.current.setBodyMovement("idle");
7854
+ u.current.setBodyMovement("idle");
7641
7855
  }
7642
- h.current.setBodyMovement("gesturing");
7643
- const D = I()?.questions?.length || 0, ee = a.current.currentQuestionIndex >= D - 1, q = a.current.currentQuestionIndex < D - 1;
7644
- console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", D, "hasNextQuestion:", q);
7645
- const Y = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${ee ? "" : " Let's move on to the next question."}`, ve = z.current || { lipsyncLang: "en" };
7646
- h.current.speakText(Y, {
7647
- lipsyncLang: ve.lipsyncLang,
7856
+ u.current.setBodyMovement("gesturing");
7857
+ const N = f()?.questions?.length || 0, _ = a.current.currentQuestionIndex >= N - 1, j = a.current.currentQuestionIndex < N - 1;
7858
+ console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", j);
7859
+ const q = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${_ ? "" : " Let's move on to the next question."}`, Le = w.current || { lipsyncLang: "en" };
7860
+ u.current.speakText(q, {
7861
+ lipsyncLang: Le.lipsyncLang,
7648
7862
  onSpeechEnd: () => {
7649
7863
  c.current.onCustomAction({
7650
7864
  type: "answerFeedbackComplete",
@@ -7652,7 +7866,7 @@ const gt = ze(({
7652
7866
  lessonIndex: a.current.currentLessonIndex,
7653
7867
  questionIndex: a.current.currentQuestionIndex,
7654
7868
  isCorrect: !1,
7655
- hasNextQuestion: q,
7869
+ hasNextQuestion: j,
7656
7870
  score: a.current.score,
7657
7871
  totalQuestions: a.current.totalQuestions
7658
7872
  });
@@ -7660,22 +7874,22 @@ const gt = ze(({
7660
7874
  });
7661
7875
  }
7662
7876
  else {
7663
- const D = I()?.questions?.length || 0;
7877
+ const N = f()?.questions?.length || 0;
7664
7878
  c.current.onCustomAction({
7665
7879
  type: "answerFeedbackComplete",
7666
7880
  moduleIndex: a.current.currentModuleIndex,
7667
7881
  lessonIndex: a.current.currentLessonIndex,
7668
7882
  questionIndex: a.current.currentQuestionIndex,
7669
- isCorrect: w,
7670
- hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7883
+ isCorrect: z,
7884
+ hasNextQuestion: a.current.currentQuestionIndex < N - 1,
7671
7885
  score: a.current.score,
7672
7886
  totalQuestions: a.current.totalQuestions,
7673
7887
  avatarNotReady: !0
7674
7888
  });
7675
7889
  }
7676
- }, [e.correct, e.incorrect, T, I, F]), se = M((b) => {
7677
- const R = T();
7678
- if (!b || typeof b != "object") {
7890
+ }, [e.correct, e.incorrect, E, f, P]), se = T((v) => {
7891
+ const R = E();
7892
+ if (!v || typeof v != "object") {
7679
7893
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
7680
7894
  return;
7681
7895
  }
@@ -7683,61 +7897,61 @@ const gt = ze(({
7683
7897
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
7684
7898
  return;
7685
7899
  }
7686
- const w = {
7687
- passed: b.passed === !0,
7688
- results: b.results || [],
7689
- output: b.output || "",
7690
- error: b.error || null,
7691
- executionTime: b.executionTime || null,
7692
- testCount: b.testCount || 0,
7693
- passedCount: b.passedCount || 0,
7694
- failedCount: b.failedCount || 0
7900
+ const z = {
7901
+ passed: v.passed === !0,
7902
+ results: v.results || [],
7903
+ output: v.output || "",
7904
+ error: v.error || null,
7905
+ executionTime: v.executionTime || null,
7906
+ testCount: v.testCount || 0,
7907
+ passedCount: v.passedCount || 0,
7908
+ failedCount: v.failedCount || 0
7695
7909
  };
7696
7910
  c.current.onCustomAction({
7697
7911
  type: "codeTestSubmitted",
7698
7912
  moduleIndex: a.current.currentModuleIndex,
7699
7913
  lessonIndex: a.current.currentLessonIndex,
7700
7914
  questionIndex: a.current.currentQuestionIndex,
7701
- testResult: w,
7915
+ testResult: z,
7702
7916
  question: R
7703
- }), p.current && p.current(w);
7704
- }, [T, F]), de = M(() => {
7917
+ }), p.current && p.current(z);
7918
+ }, [E, P]), ae = T(() => {
7705
7919
  if (a.current.currentQuestionIndex > 0) {
7706
7920
  a.current.currentQuestionIndex -= 1;
7707
- const b = T();
7708
- b && c.current.onCustomAction({
7921
+ const v = E();
7922
+ v && c.current.onCustomAction({
7709
7923
  type: "questionStart",
7710
7924
  moduleIndex: a.current.currentModuleIndex,
7711
7925
  lessonIndex: a.current.currentLessonIndex,
7712
7926
  questionIndex: a.current.currentQuestionIndex,
7713
7927
  totalQuestions: a.current.totalQuestions,
7714
- question: b,
7928
+ question: v,
7715
7929
  score: a.current.score
7716
7930
  });
7717
7931
  const R = () => {
7718
- if (!h.current || !b) return;
7719
- h.current.setMood("happy"), h.current.setBodyMovement("idle");
7720
- const w = z.current || { lipsyncLang: "en" };
7721
- b.type === "code_test" ? h.current.speakText(`Let's go back to this coding challenge: ${b.question}`, {
7722
- lipsyncLang: w.lipsyncLang
7723
- }) : h.current.speakText(`Going back to: ${b.question}`, {
7724
- lipsyncLang: w.lipsyncLang
7932
+ if (!u.current || !v) return;
7933
+ u.current.setMood("happy"), u.current.setBodyMovement("idle");
7934
+ const z = w.current || { lipsyncLang: "en" };
7935
+ v.type === "code_test" ? u.current.speakText(`Let's go back to this coding challenge: ${v.question}`, {
7936
+ lipsyncLang: z.lipsyncLang
7937
+ }) : u.current.speakText(`Going back to: ${v.question}`, {
7938
+ lipsyncLang: z.lipsyncLang
7725
7939
  });
7726
7940
  };
7727
- if (h.current && h.current.isReady && b)
7941
+ if (u.current && u.current.isReady && v)
7728
7942
  R();
7729
- else if (b) {
7730
- const w = setInterval(() => {
7731
- h.current && h.current.isReady && (clearInterval(w), R());
7943
+ else if (v) {
7944
+ const z = setInterval(() => {
7945
+ u.current && u.current.isReady && (clearInterval(z), R());
7732
7946
  }, 100);
7733
7947
  setTimeout(() => {
7734
- clearInterval(w);
7948
+ clearInterval(z);
7735
7949
  }, 5e3);
7736
7950
  }
7737
7951
  }
7738
- }, [T]), me = M(() => {
7739
- const b = H.current || { modules: [] };
7740
- if (b.modules[a.current.currentModuleIndex], a.current.currentLessonIndex > 0)
7952
+ }, [E]), pe = T(() => {
7953
+ const v = M.current || { modules: [] };
7954
+ if (v.modules[a.current.currentModuleIndex], a.current.currentLessonIndex > 0)
7741
7955
  a.current.currentLessonIndex -= 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0, c.current.onCustomAction({
7742
7956
  type: "lessonStart",
7743
7957
  moduleIndex: a.current.currentModuleIndex,
@@ -7745,99 +7959,99 @@ const gt = ze(({
7745
7959
  }), c.current.onLessonStart({
7746
7960
  moduleIndex: a.current.currentModuleIndex,
7747
7961
  lessonIndex: a.current.currentLessonIndex,
7748
- lesson: I()
7749
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7962
+ lesson: f()
7963
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
7750
7964
  else if (a.current.currentModuleIndex > 0) {
7751
- const C = b.modules[a.current.currentModuleIndex - 1];
7752
- a.current.currentModuleIndex -= 1, a.current.currentLessonIndex = (C?.lessons?.length || 1) - 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0, c.current.onCustomAction({
7965
+ const H = v.modules[a.current.currentModuleIndex - 1];
7966
+ a.current.currentModuleIndex -= 1, a.current.currentLessonIndex = (H?.lessons?.length || 1) - 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0, c.current.onCustomAction({
7753
7967
  type: "lessonStart",
7754
7968
  moduleIndex: a.current.currentModuleIndex,
7755
7969
  lessonIndex: a.current.currentLessonIndex
7756
7970
  }), c.current.onLessonStart({
7757
7971
  moduleIndex: a.current.currentModuleIndex,
7758
7972
  lessonIndex: a.current.currentLessonIndex,
7759
- lesson: I()
7760
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7973
+ lesson: f()
7974
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
7761
7975
  }
7762
- }, [I]), ie = M(() => {
7976
+ }, [f]), ee = T(() => {
7763
7977
  a.current.currentModuleIndex = 0, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.isTeaching = !1, a.current.isQuestionMode = !1, a.current.lessonCompleted = !1, a.current.curriculumCompleted = !1, a.current.score = 0, a.current.totalQuestions = 0;
7764
- }, []), fe = M((b) => {
7765
- console.log("Avatar is ready!", b);
7766
- const R = I(), w = R?.avatar_script || R?.body;
7767
- u && w && setTimeout(() => {
7978
+ }, []), le = T((v) => {
7979
+ console.log("Avatar is ready!", v);
7980
+ const R = f(), z = R?.avatar_script || R?.body;
7981
+ h && z && setTimeout(() => {
7768
7982
  d.current && d.current();
7769
7983
  }, 10);
7770
- }, [u, I]);
7984
+ }, [h, f]);
7771
7985
  Xe(() => {
7772
- d.current = Z, g.current = j, y.current = J, x.current = W, v.current = ye, B.current = S, p.current = $;
7773
- }), Ce(r, () => ({
7986
+ d.current = X, g.current = K, y.current = U, b.current = Z, I.current = oe, V.current = S, p.current = $;
7987
+ }), Ee(r, () => ({
7774
7988
  // Curriculum control methods
7775
- startTeaching: Z,
7989
+ startTeaching: X,
7776
7990
  startQuestions: S,
7777
7991
  handleAnswerSelect: $,
7778
7992
  handleCodeTestResult: se,
7779
- nextQuestion: W,
7780
- previousQuestion: de,
7781
- nextLesson: j,
7782
- previousLesson: me,
7783
- completeLesson: J,
7784
- completeCurriculum: ye,
7785
- resetCurriculum: ie,
7993
+ nextQuestion: Z,
7994
+ previousQuestion: ae,
7995
+ nextLesson: K,
7996
+ previousLesson: pe,
7997
+ completeLesson: U,
7998
+ completeCurriculum: oe,
7999
+ resetCurriculum: ee,
7786
8000
  getState: () => ({ ...a.current }),
7787
- getCurrentQuestion: () => T(),
7788
- getCurrentLesson: () => I(),
8001
+ getCurrentQuestion: () => E(),
8002
+ getCurrentLesson: () => f(),
7789
8003
  // Direct access to avatar ref (always returns current value)
7790
- getAvatarRef: () => h.current,
8004
+ getAvatarRef: () => u.current,
7791
8005
  // Convenience methods that delegate to avatar (always check current ref)
7792
- speakText: async (b, R = {}) => {
7793
- await h.current?.resumeAudioContext?.();
7794
- const w = z.current || { lipsyncLang: "en" };
7795
- h.current?.speakText(b, { ...R, lipsyncLang: R.lipsyncLang || w.lipsyncLang });
8006
+ speakText: async (v, R = {}) => {
8007
+ await u.current?.resumeAudioContext?.();
8008
+ const z = w.current || { lipsyncLang: "en" };
8009
+ u.current?.speakText(v, { ...R, lipsyncLang: R.lipsyncLang || z.lipsyncLang });
7796
8010
  },
7797
8011
  resumeAudioContext: async () => {
7798
- if (h.current?.resumeAudioContext)
7799
- return await h.current.resumeAudioContext();
7800
- const b = h.current?.talkingHead;
7801
- if (b?.audioCtx) {
7802
- const R = b.audioCtx;
8012
+ if (u.current?.resumeAudioContext)
8013
+ return await u.current.resumeAudioContext();
8014
+ const v = u.current?.talkingHead;
8015
+ if (v?.audioCtx) {
8016
+ const R = v.audioCtx;
7803
8017
  if (R.state === "suspended" || R.state === "interrupted")
7804
8018
  try {
7805
8019
  await R.resume(), console.log("Audio context resumed via talkingHead");
7806
- } catch (w) {
7807
- console.warn("Failed to resume audio context:", w);
8020
+ } catch (z) {
8021
+ console.warn("Failed to resume audio context:", z);
7808
8022
  }
7809
8023
  } else
7810
8024
  console.warn("Audio context not available yet");
7811
8025
  },
7812
- stopSpeaking: () => h.current?.stopSpeaking(),
7813
- pauseSpeaking: () => h.current?.pauseSpeaking(),
7814
- resumeSpeaking: async () => await h.current?.resumeSpeaking(),
7815
- isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
7816
- setMood: (b) => h.current?.setMood(b),
7817
- playAnimation: (b, R) => h.current?.playAnimation(b, R),
7818
- setBodyMovement: (b) => h.current?.setBodyMovement(b),
7819
- setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
7820
- playRandomDance: () => h.current?.playRandomDance(),
7821
- playReaction: (b) => h.current?.playReaction(b),
7822
- playCelebration: () => h.current?.playCelebration(),
7823
- setShowFullAvatar: (b) => h.current?.setShowFullAvatar(b),
7824
- setTimingAdjustment: (b) => h.current?.setTimingAdjustment(b),
7825
- lockAvatarPosition: () => h.current?.lockAvatarPosition(),
7826
- unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
8026
+ stopSpeaking: () => u.current?.stopSpeaking(),
8027
+ pauseSpeaking: () => u.current?.pauseSpeaking(),
8028
+ resumeSpeaking: async () => await u.current?.resumeSpeaking(),
8029
+ isPaused: () => u.current && typeof u.current.isPaused < "u" ? u.current.isPaused : !1,
8030
+ setMood: (v) => u.current?.setMood(v),
8031
+ playAnimation: (v, R) => u.current?.playAnimation(v, R),
8032
+ setBodyMovement: (v) => u.current?.setBodyMovement(v),
8033
+ setMovementIntensity: (v) => u.current?.setMovementIntensity(v),
8034
+ playRandomDance: () => u.current?.playRandomDance(),
8035
+ playReaction: (v) => u.current?.playReaction(v),
8036
+ playCelebration: () => u.current?.playCelebration(),
8037
+ setShowFullAvatar: (v) => u.current?.setShowFullAvatar(v),
8038
+ setTimingAdjustment: (v) => u.current?.setTimingAdjustment(v),
8039
+ lockAvatarPosition: () => u.current?.lockAvatarPosition(),
8040
+ unlockAvatarPosition: () => u.current?.unlockAvatarPosition(),
7827
8041
  // Custom action trigger
7828
- triggerCustomAction: (b, R) => {
8042
+ triggerCustomAction: (v, R) => {
7829
8043
  c.current.onCustomAction({
7830
- type: b,
8044
+ type: v,
7831
8045
  ...R,
7832
8046
  state: { ...a.current }
7833
8047
  });
7834
8048
  },
7835
8049
  // Responsive resize handler
7836
- handleResize: () => h.current?.handleResize(),
8050
+ handleResize: () => u.current?.handleResize(),
7837
8051
  // Avatar readiness check (always returns current value)
7838
- isAvatarReady: () => h.current?.isReady || !1
7839
- }), [Z, S, $, se, W, j, J, ye, ie, T, I]);
7840
- const X = z.current || {
8052
+ isAvatarReady: () => u.current?.isReady || !1
8053
+ }), [X, S, $, se, Z, K, U, oe, ee, E, f]);
8054
+ const O = w.current || {
7841
8055
  avatarUrl: "/avatars/brunette.glb",
7842
8056
  avatarBody: "F",
7843
8057
  mood: "happy",
@@ -7850,33 +8064,33 @@ const gt = ze(({
7850
8064
  showFullAvatar: !1,
7851
8065
  animations: e
7852
8066
  };
7853
- return /* @__PURE__ */ ge("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ge(
7854
- Ue,
8067
+ return /* @__PURE__ */ me("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ me(
8068
+ Ve,
7855
8069
  {
7856
- ref: h,
7857
- avatarUrl: X.avatarUrl,
7858
- avatarBody: X.avatarBody,
7859
- mood: X.mood,
7860
- ttsLang: X.ttsLang,
7861
- ttsService: X.ttsService,
7862
- ttsVoice: X.ttsVoice,
7863
- ttsApiKey: X.ttsApiKey,
7864
- bodyMovement: X.bodyMovement,
7865
- movementIntensity: X.movementIntensity,
7866
- showFullAvatar: X.showFullAvatar,
8070
+ ref: u,
8071
+ avatarUrl: O.avatarUrl,
8072
+ avatarBody: O.avatarBody,
8073
+ mood: O.mood,
8074
+ ttsLang: O.ttsLang,
8075
+ ttsService: O.ttsService,
8076
+ ttsVoice: O.ttsVoice,
8077
+ ttsApiKey: O.ttsApiKey,
8078
+ bodyMovement: O.bodyMovement,
8079
+ movementIntensity: O.movementIntensity,
8080
+ showFullAvatar: O.showFullAvatar,
7867
8081
  cameraView: "upper",
7868
- animations: X.animations,
7869
- onReady: fe,
8082
+ animations: O.animations,
8083
+ onReady: le,
7870
8084
  onLoading: () => {
7871
8085
  },
7872
- onError: (b) => {
7873
- console.error("Avatar error:", b);
8086
+ onError: (v) => {
8087
+ console.error("Avatar error:", v);
7874
8088
  }
7875
8089
  }
7876
8090
  ) });
7877
8091
  });
7878
- gt.displayName = "CurriculumLearning";
7879
- const We = {
8092
+ yt.displayName = "CurriculumLearning";
8093
+ const Ge = {
7880
8094
  // Code-based dance animations (no FBX required)
7881
8095
  dance: {
7882
8096
  name: "dance",
@@ -7979,14 +8193,15 @@ const We = {
7979
8193
  duration: 5e3,
7980
8194
  description: "Excited, energetic movement"
7981
8195
  }
7982
- }, kt = (U) => We[U] || null, wt = (U) => We.hasOwnProperty(U);
8196
+ }, wt = (G) => Ge[G] || null, zt = (G) => Ge.hasOwnProperty(G);
7983
8197
  export {
7984
- gt as CurriculumLearning,
7985
- Ue as TalkingHeadAvatar,
8198
+ yt as CurriculumLearning,
8199
+ gt as SimpleTalkingAvatar,
8200
+ Ve as TalkingHeadAvatar,
7986
8201
  pt as TalkingHeadComponent,
7987
- We as animations,
7988
- He as getActiveTTSConfig,
7989
- kt as getAnimation,
7990
- St as getVoiceOptions,
7991
- wt as hasAnimation
8202
+ Ge as animations,
8203
+ Fe as getActiveTTSConfig,
8204
+ wt as getAnimation,
8205
+ kt as getVoiceOptions,
8206
+ zt as hasAnimation
7992
8207
  };