@sage-rsc/talking-head-react 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { jsxs as Pe, jsx as me } from "react/jsx-runtime";
2
- import { forwardRef as Me, useRef as O, useState as ce, useEffect as de, useCallback as F, useImperativeHandle as Ee, useLayoutEffect as Xe } from "react";
3
- import * as f from "three";
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 Be } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as _e } from "three/addons/environments/RoomEnvironment.js";
9
- import qe from "three/addons/libs/stats.module.js";
10
- let p, re, he;
11
- const A = [0, 0, 0, 0], z = new f.Vector3(), ze = new f.Vector3(), ie = new f.Vector3(), Ce = new f.Vector3();
12
- new f.Plane();
13
- new f.Ray();
14
- new f.Euler();
15
- const oe = new f.Quaternion(), Oe = new f.Quaternion(), fe = new f.Matrix4(), xe = new f.Matrix4();
16
- new f.Vector3();
17
- const He = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), $e = new f.Vector3(0, 1, 0), Je = new f.Vector3(0, 0, 1);
7
+ import { FBXLoader as Oe } from "three/addons/loaders/FBXLoader.js";
8
+ import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
9
+ import Ke from "three/addons/libs/stats.module.js";
10
+ let m, re, ue;
11
+ const A = [0, 0, 0, 0], w = 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();
@@ -264,7 +264,7 @@ class et {
264
264
  "pivot",
265
265
  "helper"
266
266
  ].forEach((n) => {
267
- p = this.getValue(t.name, n), p && (e[n] = p);
267
+ m = this.getValue(t.name, n), m && (e[n] = m);
268
268
  }), e;
269
269
  });
270
270
  }
@@ -279,11 +279,11 @@ class et {
279
279
  this.armature.traverse((o) => {
280
280
  e.has(o) || (e.set(o, t), t++);
281
281
  }), this.data.sort((o, l) => e.get(o.bone) - e.get(l.bone)), this.data.forEach((o) => {
282
- p = this.dict[o.boneParent.name], p && (p.children || (p.children = []), p.children.push(o));
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
@@ -321,7 +321,7 @@ class et {
321
321
  /// Bone's parent object
322
322
  vBasis: r.position.clone(),
323
323
  // Original local position
324
- vWorld: r.parent.getWorldPosition(z).clone(),
324
+ vWorld: r.parent.getWorldPosition(w).clone(),
325
325
  // World position, parent
326
326
  qBasis: r.parent.quaternion.clone(),
327
327
  // Original quaternion, parent
@@ -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(z, oe, ie), z.copy(He).applyQuaternion(oe).setY(0).normalize(), oe.premultiply(Oe.setFromUnitVectors(He, z).invert()).normalize(), h.qWorldInverseYaw = oe.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ u.boneParent.matrixWorld.decompose(w, ie, ne), w.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, w).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], z.copy(o.vWorld), fe.copy(o.boneParent.matrixWorld), xe.copy(fe).invert(), o.vWorld.setFromMatrixPosition(fe), z.applyMatrix4(xe), z.length() > 0.5 && (console.info("Info: Unrealistic jump of " + z.length().toFixed(2) + " meters."), z.setLength(0.5)), z.applyQuaternion(o.bone.quaternion), A[0] = z.x, A[1] = z.y, A[2] = -z.z, A[3] = z.length() / 3, o.children)
359
+ if (o = this.data[e], w.copy(o.vWorld), fe.copy(o.boneParent.matrixWorld), xe.copy(fe).invert(), o.vWorld.setFromMatrixPosition(fe), w.applyMatrix4(xe), w.length() > 0.5 && (console.info("Info: Unrealistic jump of " + w.length().toFixed(2) + " meters."), w.setLength(0.5)), w.applyQuaternion(o.bone.quaternion), A[0] = w.x, A[1] = w.y, A[2] = -w.z, A[3] = w.length() / 3, o.children)
360
360
  for (n = 0, s = o.children.length; n < s; n++)
361
- p = o.children[n], A[0] -= p.v[0] * t / 3, A[1] -= p.v[1] * t / 3, A[2] += p.v[2] * t / 3, A[3] -= p.v[3] * t / 3;
362
- if (p = this.opt.sensitivityFactor, A[0] *= o.ext * p, A[1] *= o.ext * p, A[2] *= o.ext * p, A[3] *= o.ext * p, o.isX && (p = A[0] / t, o.ea[0] = (p - o.ev[0]) / t, o.ev[0] = p, 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], p = o.v[0] + o.a[0] * t / 2, p = -o.k[0] * o.p[0] - o.c[0] * p - o.ea[0], o.v[0] = o.v[0] + (p + o.a[0]) * t / 2), o.isY && (p = A[1] / t, o.ea[1] = (p - o.ev[1]) / t, o.ev[1] = p, 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], p = o.v[1] + o.a[1] * t / 2, p = -o.k[1] * o.p[1] - o.c[1] * p - o.ea[1], o.v[1] = o.v[1] + (p + o.a[1]) * t / 2), o.isZ && (p = A[2] / t, o.ea[2] = (p - o.ev[2]) / t, o.ev[2] = p, 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], p = o.v[2] + o.a[2] * t / 2, p = -o.k[2] * o.p[2] - o.c[2] * p - o.ea[2], o.v[2] = o.v[2] + (p + o.a[2]) * t / 2), o.isT && (p = A[3] / t, o.ea[3] = (p - o.ev[3]) / t, o.ev[3] = p, 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], p = o.v[3] + o.a[3] * t / 2, p = -o.k[3] * o.p[3] - o.c[3] * p - o.ea[3], o.v[3] = o.v[3] + (p + 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], p = this.opt.movementFactor, A[0] *= p, A[1] *= p, A[2] *= p, A[3] *= p, o.dl && (p = o.dl, A[0] += p[0], A[1] += p[1], A[2] += p[2]), o.dw && (p = o.dw, z.set(
361
+ m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
362
+ if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, w.set(
363
363
  o.vBasis.x + A[0],
364
364
  o.vBasis.y + A[1],
365
365
  o.vBasis.z + A[2]
366
- ), z.applyMatrix4(fe), z.x += p[0], z.y += p[1], z.z += p[2], z.applyMatrix4(xe), A[0] += z.x - o.vBasis.x, A[1] += z.y - o.vBasis.y, A[2] += z.z - o.vBasis.z), o.limits && this.opt.isLimits && (p = o.limits, p[0] && (p[0][0] !== null && A[0] < p[0][0] && (A[0] = p[0][0]), p[0][1] !== null && A[0] > p[0][1] && (A[0] = p[0][1])), p[1] && (p[1][0] !== null && A[1] < p[1][0] && (A[1] = p[1][0]), p[1][1] !== null && A[1] > p[1][1] && (A[1] = p[1][1])), p[2] && (p[2][0] !== null && A[2] < p[2][0] && (A[2] = p[2][0]), p[2][1] !== null && A[2] > p[2][1] && (A[2] = p[2][1])), p[3] && (p[3][0] !== null && A[3] < p[3][0] && (A[3] = p[3][0]), p[3][1] !== null && A[3] > p[3][1] && (A[3] = p[3][1]))), o.isPoint)
366
+ ), w.applyMatrix4(fe), w.x += m[0], w.y += m[1], w.z += m[2], w.applyMatrix4(xe), A[0] += w.x - o.vBasis.x, A[1] += w.y - o.vBasis.y, A[2] += w.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(z, oe, ie), z.copy(He).applyQuaternion(oe).setY(0).normalize(), oe.premultiply(Oe.setFromUnitVectors(He, z).invert()).normalize(), o.boneParent.quaternion.multiply(oe.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (p = Math.atan(A[0] / o.l), oe.setFromAxisAngle(Je, -p), o.boneParent.quaternion.multiply(oe)), o.isY && (p = o.l / 3, p = p * Math.tanh(A[1] / p), o.bone.position.setLength(o.l + p)), o.isX && (p = Math.atan(A[2] / o.l), oe.setFromAxisAngle(Ke, -p), o.boneParent.quaternion.multiply(oe)), o.isT && (p = 1.5 * Math.tanh(A[3] * 1.5), oe.setFromAxisAngle($e, -p), o.boneParent.quaternion.multiply(oe)), 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(w, ie, ne), w.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, w).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
- p = o.excludes[n], ie.set(0, 0, 0), p.deltaLocal && (ie.x += p.deltaLocal[0], ie.y += p.deltaLocal[1], ie.z += p.deltaLocal[2]), ie.applyMatrix4(p.bone.matrixWorld), xe.copy(o.boneParent.matrixWorld).invert(), ie.applyMatrix4(xe), z.copy(o.bone.position), !(z.distanceToSquared(ie) >= p.radiusSq) && (he = z.length(), re = ie.length(), !(re > p.radius + he) && (re < Math.abs(p.radius - he) || (re = (re * re + he * he - p.radiusSq) / (2 * re), ie.normalize(), Ce.copy(ie).multiplyScalar(re), re = Math.sqrt(he * he - re * re), z.subVectors(z, Ce).projectOnPlane(ie).normalize().multiplyScalar(re), ze.subVectors(o.vBasis, Ce).projectOnPlane(ie).normalize(), he = ze.dot(z), he < 0 && (he = Math.sqrt(re * re - he * he), ze.multiplyScalar(he), z.add(ze)), z.add(Ce).normalize(), ie.copy(o.bone.position).normalize(), oe.setFromUnitVectors(ie, z), o.boneParent.quaternion.premultiply(oe), 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), w.copy(o.bone.position), !(w.distanceToSquared(ne) >= m.radiusSq) && (ue = w.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), w.subVectors(w, Ce).projectOnPlane(ne).normalize().multiplyScalar(re), ze.subVectors(o.vBasis, Ce).projectOnPlane(ne).normalize(), ue = ze.dot(w), ue < 0 && (ue = Math.sqrt(re * re - ue * ue), ze.multiplyScalar(ue), w.add(ze)), w.add(Ce).normalize(), ne.copy(o.bone.position).normalize(), ie.setFromUnitVectors(ne, w), o.boneParent.quaternion.premultiply(ie), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -382,18 +382,18 @@ class et {
382
382
  * @param {boolean} [keepSetting=false] If true, keep the previos all setting
383
383
  */
384
384
  showHelpers(t) {
385
- if (this.hideHelpers(), this.helpers.isShowAll = t === void 0 ? this.helpers.isShowAll : t === !0, p = this.helpers, this.data.forEach((e) => {
386
- (this.helpers.isShowAll || e.helper === !0) && (p.points.bones.push(e.bone), p.points.pivots.push(e.pivot), e.type !== 0 && p.lines.bones.push(e.bone), e.excludes && e.excludes.forEach((n) => {
385
+ if (this.hideHelpers(), this.helpers.isShowAll = t === void 0 ? this.helpers.isShowAll : t === !0, m = this.helpers, this.data.forEach((e) => {
386
+ (this.helpers.isShowAll || e.helper === !0) && (m.points.bones.push(e.bone), m.points.pivots.push(e.pivot), e.type !== 0 && m.lines.bones.push(e.bone), e.excludes && e.excludes.forEach((n) => {
387
387
  let i = !1;
388
- for (let s = 0; s < p.excludes.bones.length; s++)
389
- if (p.excludes.bones[s] === n.bone && p.excludes.radii[s] === n.radius && !(p.excludes.deltaLocals[s] === null && n.deltaLocal !== null) && !(p.excludes.deltaLocals[s] !== null && n.deltaLocal === null) && !(p.excludes.deltaLocals[s] !== null && p.excludes.deltaLocals[s].some((o, l) => o !== n.deltaLocal[l]))) {
388
+ for (let s = 0; s < m.excludes.bones.length; s++)
389
+ if (m.excludes.bones[s] === n.bone && m.excludes.radii[s] === n.radius && !(m.excludes.deltaLocals[s] === null && n.deltaLocal !== null) && !(m.excludes.deltaLocals[s] !== null && n.deltaLocal === null) && !(m.excludes.deltaLocals[s] !== null && m.excludes.deltaLocals[s].some((o, l) => o !== n.deltaLocal[l]))) {
390
390
  i = !0;
391
391
  break;
392
392
  }
393
- i || (p.excludes.bones.push(n.bone), p.excludes.radii.push(n.radius), p.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), p.excludes.objects.push(null));
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
- }), p = this.helpers.excludes, this.opt.isExcludes && p.bones.length && p.bones.forEach((e, n) => {
396
- const i = new f.SphereGeometry(p.radii[n], 6, 6), s = new f.MeshBasicMaterial({
395
+ }), m = this.helpers.excludes, this.opt.isExcludes && m.bones.length && m.bones.forEach((e, n) => {
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
- p.objects[n] = new f.Mesh(i, s), p.objects[n].renderOrder = 997, e.add(p.objects[n]), p.deltaLocals[n] && p.objects[n].position.set(
405
- p.deltaLocals[n][0],
406
- p.deltaLocals[n][1],
407
- p.deltaLocals[n][2]
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
+ m.deltaLocals[n][0],
406
+ m.deltaLocals[n][1],
407
+ m.deltaLocals[n][2]
408
408
  );
409
- }), p = this.helpers.points, p.bones.length) {
409
+ }), m = this.helpers.points, m.bones.length) {
410
410
  this.helpers.isActive = !0;
411
- const e = new f.BufferGeometry(), n = p.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 = p.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,40 +420,40 @@ class et {
420
420
  size: 0.2,
421
421
  vertexColors: !0
422
422
  });
423
- p.object = new f.Points(e, l), p.object.renderOrder = 998, p.object.matrix = this.armature.matrixWorld, p.object.matrixAutoUpdate = !1, this.scene.add(p.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
- if (p = this.helpers.lines, p.bones.length) {
426
- const e = new f.BufferGeometry(), n = p.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 = p.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({
425
+ if (m = this.helpers.lines, m.bones.length) {
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
- p.object = new f.LineSegments(e, l), p.object.renderOrder = 999, p.object.matrix = this.armature.matrixWorld, p.object.matrixAutoUpdate = !1, this.scene.add(p.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
  /**
441
441
  * Update the positions of dynamic bone helpers.
442
442
  */
443
443
  updateHelpers() {
444
- if (p = this.helpers.points, p.bones.length) {
444
+ if (m = this.helpers.points, m.bones.length) {
445
445
  xe.copy(this.armature.matrixWorld).invert();
446
- const t = p.object.geometry.getAttribute("position");
447
- for (let e = 0, n = p.bones.length; e < n; e++)
448
- fe.multiplyMatrices(xe, p.bones[e].matrixWorld), z.setFromMatrixPosition(fe), t.setXYZ(e, z.x, z.y, z.z);
449
- t.needsUpdate = !0, p.object.updateMatrixWorld();
446
+ const t = m.object.geometry.getAttribute("position");
447
+ for (let e = 0, n = m.bones.length; e < n; e++)
448
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), w.setFromMatrixPosition(fe), t.setXYZ(e, w.x, w.y, w.z);
449
+ t.needsUpdate = !0, m.object.updateMatrixWorld();
450
450
  }
451
- if (p = this.helpers.lines, p.bones.length) {
451
+ if (m = this.helpers.lines, m.bones.length) {
452
452
  xe.copy(this.armature.matrixWorld).invert();
453
- const t = p.object.geometry.getAttribute("position");
454
- for (let e = 0, n = 0, i = p.bones.length; e < i; e++, n += 2)
455
- fe.multiplyMatrices(xe, p.bones[e].matrixWorld), z.setFromMatrixPosition(fe), t.setXYZ(n, z.x, z.y, z.z), fe.multiplyMatrices(xe, p.bones[e].parent.matrixWorld), z.setFromMatrixPosition(fe), t.setXYZ(n + 1, z.x, z.y, z.z);
456
- t.needsUpdate = !0, p.object.updateMatrixWorld();
453
+ const t = m.object.geometry.getAttribute("position");
454
+ for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
455
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), w.setFromMatrixPosition(fe), t.setXYZ(n, w.x, w.y, w.z), fe.multiplyMatrices(xe, m.bones[e].parent.matrixWorld), w.setFromMatrixPosition(fe), t.setXYZ(n + 1, w.x, w.y, w.z);
456
+ t.needsUpdate = !0, m.object.updateMatrixWorld();
457
457
  }
458
458
  }
459
459
  /**
@@ -462,9 +462,9 @@ class et {
462
462
  hideHelpers() {
463
463
  [this.helpers.points, this.helpers.lines].forEach((t) => {
464
464
  t.bones = [], t.object && (this.scene.remove(t.object), t.object.geometry.dispose(), t.object.material.dispose(), t.object = null);
465
- }), p = this.helpers.excludes, p.objects.forEach((t, e) => {
466
- t && (p.bones[e].remove(t), t.geometry.dispose(), t.material.dispose());
467
- }), p.bones = [], p.deltaLocals = [], p.radii = [], p.objects = [], this.helpers.isActive = !1;
465
+ }), m = this.helpers.excludes, m.objects.forEach((t, e) => {
466
+ t && (m.bones[e].remove(t), t.geometry.dispose(), t.material.dispose());
467
+ }), m.bones = [], m.deltaLocals = [], m.radii = [], m.objects = [], this.helpers.isActive = !1;
468
468
  }
469
469
  /**
470
470
  * Start dynamic bones.
@@ -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);
525
- n.spectralCentroid.push(c);
526
- const d = this.calculateZeroCrossingRate(h);
527
- n.zeroCrossingRate.push(d);
528
- const g = this.calculateMFCC(h);
524
+ const d = this.calculateSpectralCentroid(u);
525
+ n.spectralCentroid.push(d);
526
+ const c = this.calculateZeroCrossingRate(u);
527
+ n.zeroCrossingRate.push(c);
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, x = 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 + x, n[(u + a + i / 2) * 2] = c - g, n[(u + a + i / 2) * 2 + 1] = d - x;
611
- const b = r * o - h * l, I = r * l + h * o;
612
- r = b, h = I;
609
+ const d = n[(h + a) * 2], c = 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] = d + g, n[(h + a) * 2 + 1] = c + y, n[(h + a + i / 2) * 2] = d - g, n[(h + a + i / 2) * 2 + 1] = c - y;
611
+ const b = r * o - u * l, R = r * l + u * o;
612
+ r = b, u = R;
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], d = t.energy[Math.floor(u / 0.023)] || 0, c = this.calculateVisemeDuration(a, d);
707
707
  i.push({
708
708
  viseme: a,
709
- startTime: u,
710
- endTime: u + d,
711
- duration: d,
712
- intensity: Math.min(1, c * 2)
709
+ startTime: h,
710
+ endTime: h + c,
711
+ duration: c,
712
+ intensity: Math.min(1, d * 2)
713
713
  // Map energy to viseme intensity
714
- }), u += d, l++;
714
+ }), h += c, 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: [] };
1210
- let c = "";
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) => {
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
+ let d = "";
1211
+ d += [...l].map((g) => t[g] || g).join("");
1212
+ const c = [...h];
1213
+ return c[0] = c[0].toLowerCase(), d += c.join(""), a.move = c.length, d += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(d), 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,17 +1376,17 @@ 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
- const c = 0.7 * (this.visemeDurations[a] || 1);
1384
- e.durations[e.durations.length - 1] += c, n += c;
1383
+ const d = 0.7 * (this.visemeDurations[a] || 1);
1384
+ e.durations[e.durations.length - 1] += d, n += d;
1385
1385
  } else {
1386
- const c = this.visemeDurations[a] || 1;
1387
- e.visemes.push(a), e.times.push(n), e.durations.push(c), n += c;
1386
+ const d = this.visemeDurations[a] || 1;
1387
+ e.visemes.push(a), e.times.push(n), e.durations.push(d), n += d;
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: [] };
1620
- let c = "";
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) => {
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
+ let d = "";
1621
+ d += [...l].map((g) => t[g] || g).join("");
1622
+ const c = [...h];
1623
+ return c[0] = c[0].toLowerCase(), d += c.join(""), a.move = c.length, d += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(d), u.length && u.split(" ").forEach((g) => {
1624
1624
  a.visemes.push(g);
1625
1625
  }), a;
1626
1626
  });
@@ -1732,16 +1732,16 @@ 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
- r.visemes.forEach((c) => {
1739
- if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
1740
- const d = 0.7 * (this.visemeDurations[c] || 1);
1741
- e.durations[e.durations.length - 1] += d, n += d;
1738
+ r.visemes.forEach((d) => {
1739
+ if (e.visemes.length && e.visemes[e.visemes.length - 1] === d) {
1740
+ const c = 0.7 * (this.visemeDurations[d] || 1);
1741
+ e.durations[e.durations.length - 1] += c, n += c;
1742
1742
  } else {
1743
- const d = this.visemeDurations[c] || 1;
1744
- e.visemes.push(c), e.times.push(n), e.durations.push(d), n += d;
1743
+ const c = this.visemeDurations[d] || 1;
1744
+ e.visemes.push(d), e.times.push(n), e.durations.push(c), n += c;
1745
1745
  }
1746
1746
  }), e.i += r.move, l = !0;
1747
1747
  break;
@@ -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: [] };
2135
- let c = "";
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) => {
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
+ let d = "";
2136
+ d += [...l].map((g) => t[g] || g).join("");
2137
+ const c = [...h];
2138
+ return c[0] = c[0].toLowerCase(), d += c.join(""), a.move = c.length, d += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(d, "i"), u.length && u.split(" ").forEach((g) => {
2139
2139
  g && a.visemes.push(g);
2140
2140
  }), a;
2141
2141
  });
@@ -2267,16 +2267,16 @@ 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
- r.visemes.forEach((c) => {
2274
- if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
2275
- const d = 0.7 * (this.visemeDurations[c] || 1);
2276
- e.durations[e.durations.length - 1] += d, n += d;
2273
+ r.visemes.forEach((d) => {
2274
+ if (e.visemes.length && e.visemes[e.visemes.length - 1] === d) {
2275
+ const c = 0.7 * (this.visemeDurations[d] || 1);
2276
+ e.durations[e.durations.length - 1] += c, n += c;
2277
2277
  } else {
2278
- const d = this.visemeDurations[c] || 1;
2279
- e.visemes.push(c), e.times.push(n), e.durations.push(d), n += d;
2278
+ const c = this.visemeDurations[d] || 1;
2279
+ e.visemes.push(d), e.times.push(n), e.durations.push(c), n += c;
2280
2280
  }
2281
2281
  }), e.i += r.move, l = !0;
2282
2282
  break;
@@ -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
2625
+ LipsyncLt: ht
2626
2626
  }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSBtZXRyaWNzQ2ZnLmVuYWJsZWQgIT09IGZhbHNlOwogICAgY29uc3QgaW50ZXJ2YWxIeiA9ICh0eXBlb2YgbWV0cmljc0NmZy5pbnRlcnZhbEh6ID09PSAibnVtYmVyIiAmJiBtZXRyaWNzQ2ZnLmludGVydmFsSHogPiAwKQogICAgICA/IG1ldHJpY3NDZmcuaW50ZXJ2YWxIeiA6IDI7CiAgICAvLyBNZXRyaWNzIHN0YXRlIChsb3ctb3ZlcmhlYWQpCiAgICB0aGlzLl9mcmFtZXNQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5fdW5kZXJydW5CbG9ja3MgPSAwOwogICAgdGhpcy5fbWF4UXVldWVTYW1wbGVzID0gMDsKICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSAwOwogICAgLy8gQ29udmVydCB0byBmcmFtZXMgYmV0d2VlbiByZXBvcnRzCiAgICB0aGlzLl9tZXRyaWNzSW50ZXJ2YWxGcmFtZXMgPSBNYXRoLm1heCgxMjgsIE1hdGgucm91bmQodGhpcy5fc2FtcGxlUmF0ZSAvIGludGVydmFsSHopKTsKCiAgICB0aGlzLnJlc2V0KCk7CiAgfQoKICAvKioKICAgKiBSZXNldHMgdGhlIHdvcmtsZXQgdG8gaXRzIGluaXRpYWwgSURMRSBzdGF0ZS4KICAgKi8KICByZXNldCgpIHsKICAgIHRoaXMuX2J1ZmZlclF1ZXVlID0gW107CiAgICB0aGlzLl9jdXJyZW50Q2h1bmsgPSBudWxsOwogICAgdGhpcy5fY3VycmVudENodW5rT2Zmc2V0ID0gMDsKICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFOwoKICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IGZhbHNlOwogICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsKICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IGZhbHNlOwogICAgLy8gUmVzZXQgbWF4IHF1ZXVlIHRyYWNrZXIgb25seSB3aGVuIGdvaW5nIGlkbGUKICAgIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IDA7CiAgfQoKICBoYW5kbGVNZXNzYWdlKGV2ZW50KSB7CiAgICBjb25zdCB7IHR5cGUsIGRhdGEgfSA9IGV2ZW50LmRhdGE7CgogICAgLy8gSU5URVJSVVBUOiBUaGUgbWFpbiB0aHJlYWQgd2FudHMgdG8gc3RvcCBpbW1lZGlhdGVseS4KICAgIGlmICh0eXBlID09PSAic3RvcCIpIHsKICAgICAgdGhpcy5yZXNldCgpOwogICAgICAvLyBTZW5kIGZpbmFsIG1ldHJpY3Mgc2hvd2luZyBjbGVhcmVkIHN0YXRlCiAgICAgIGlmICh0aGlzLl9tZXRyaWNzRW5hYmxlZCkgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICB0eXBlOiAibWV0cmljcyIsCiAgICAgICAgICAgIGRhdGE6IHsKICAgICAgICAgICAgICBzdGF0ZTogUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFLAogICAgICAgICAgICAgIHF1ZXVlZFNhbXBsZXM6IDAsCiAgICAgICAgICAgICAgcXVldWVkTXM6IDAsCiAgICAgICAgICAgICAgbWF4UXVldWVkTXM6IE1hdGgucm91bmQoKHRoaXMuX21heFF1ZXVlU2FtcGxlcyAvIHRoaXMuX3NhbXBsZVJhdGUpICogMTAwMCksCiAgICAgICAgICAgICAgdW5kZXJydW5CbG9ja3M6IHRoaXMuX3VuZGVycnVuQmxvY2tzLAogICAgICAgICAgICAgIGZyYW1lc1Byb2Nlc3NlZDogdGhpcy5fZnJhbWVzUHJvY2Vzc2VkCiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0gY2F0Y2ggKF8pIHsgfQogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBNYWluIHRocmVhZCBoYXMgc2lnbmFsZWQgdGhhdCBubyBtb3JlIGF1ZGlvIGNodW5rcyB3aWxsIGJlIHNlbnQgZm9yIHRoaXMgdXR0ZXJhbmNlLgogICAgaWYgKHR5cGUgPT09ICJuby1tb3JlLWRhdGEiKSB7CiAgICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IHRydWU7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBVcGRhdGUgbWV0cmljcyBjb25maWd1cmF0aW9uIGF0IHJ1bnRpbWUKICAgIGlmICh0eXBlID09PSAiY29uZmlnLW1ldHJpY3MiICYmIGRhdGEgJiYgdHlwZW9mIGRhdGEgPT09ICJvYmplY3QiKSB7CiAgICAgIGlmICgiZW5hYmxlZCIgaW4gZGF0YSkgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSAhIWRhdGEuZW5hYmxlZDsKICAgICAgaWYgKHR5cGVvZiBkYXRhLmludGVydmFsSHogPT09ICJudW1iZXIiICYmIGRhdGEuaW50ZXJ2YWxIeiA+IDApIHsKICAgICAgICBjb25zdCBpbnRlcnZhbEh6ID0gZGF0YS5pbnRlcnZhbEh6OwogICAgICAgIHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcyA9IE1hdGgubWF4KDEyOCwgTWF0aC5yb3VuZCh0aGlzLl9zYW1wbGVSYXRlIC8gaW50ZXJ2YWxIeikpOwogICAgICB9CiAgICAgIC8vIFJlc2V0IHBhY2luZyBzbyB0aGUgbmV4dCByZXBvcnQgYWxpZ25zIHdpdGggbmV3IGludGVydmFsCiAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBOZXcgYXVkaW8gZGF0YSBoYXMgYXJyaXZlZC4KICAgIGlmICh0eXBlID09PSAiYXVkaW9EYXRhIiAmJiBkYXRhIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIpIHsKICAgICAgdGhpcy5fbm9Nb3JlRGF0YVJlY2VpdmVkID0gZmFsc2U7CiAgICAgIC8vIElmIHdlIHdlcmUgaWRsZSwgdGhpcyBuZXcgZGF0YSBraWNrcyBvZmYgdGhlIHBsYXliYWNrLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uSURMRSkgewogICAgICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HOwogICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7IHR5cGU6ICJwbGF5YmFjay1zdGFydGVkIiB9KTsKICAgICAgfQoKICAgICAgLy8gV2Ugb25seSBxdWV1ZSBkYXRhIGlmIHdlIGFyZSBpbiB0aGUgUExBWUlORyBzdGF0ZS4gVGhpcyBwcmV2ZW50cwogICAgICAvLyBkYXRhIGZyb20gYSBwcmV2aW91cywgaW50ZXJydXB0ZWQgc3RyZWFtIGZyb20gbGluZ2VyaW5nLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uUExBWUlORykgewogICAgICAgIC8vIFN0b3JlIGFzIEludDE2QXJyYXkgdmlldyB0byBhdm9pZCBjb25zdHJ1Y3RpbmcgaXQgaW4gcHJvY2VzcygpCiAgICAgICAgdGhpcy5fYnVmZmVyUXVldWUucHVzaChuZXcgSW50MTZBcnJheShkYXRhKSk7CiAgICAgICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsgLy8gUmVzZXQgc2lsZW5jZSBjb3VudGVyIG9uIG5ldyBkYXRhCiAgICAgIH0KICAgIH0KICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBvdXRwdXRDaGFubmVsID0gb3V0cHV0c1swXT8uWzBdOwogICAgaWYgKCFvdXRwdXRDaGFubmVsKSB7CiAgICAgIHJldHVybiB0cnVlOyAvLyBLZWVwIGFsaXZlIGV2ZW4gaWYgb3V0cHV0IGlzIHRlbXBvcmFyaWx5IGRpc2Nvbm5lY3RlZAogICAgfQoKICAgIC8vIElmIHdlIGFyZSBub3QgcGxheWluZywganVzdCBvdXRwdXQgc2lsZW5jZSBhbmQgd2FpdC4KICAgIGlmICh0aGlzLl9zdGF0ZSAhPT0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HKSB7CiAgICAgIG91dHB1dENoYW5uZWwuZmlsbCgwKTsKICAgICAgcmV0dXJuIHRydWU7IC8vIEFsd2F5cyByZXR1cm4gdHJ1ZSB0byBrZWVwIHRoZSBwcm9jZXNzb3IgYWxpdmUKICAgIH0KCiAgICAvLyBDb3JlIFBMQVlJTkcgTG9naWMKICAgIGNvbnN0IGJsb2NrU2l6ZSA9IG91dHB1dENoYW5uZWwubGVuZ3RoOwogICAgbGV0IHNhbXBsZXNDb3BpZWQgPSAwOwoKICAgIHdoaWxlIChzYW1wbGVzQ29waWVkIDwgYmxvY2tTaXplKSB7CiAgICAgIGlmICghdGhpcy5fY3VycmVudENodW5rIHx8IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCA+PSB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoKSB7CiAgICAgICAgaWYgKHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aCA+IDApIHsKICAgICAgICAgIHRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykgewogICAgICAgIGNvbnN0IHNhbXBsZXNUb0NvcHkgPSBNYXRoLm1pbigKICAgICAgICAgIGJsb2NrU2l6ZSAtIHNhbXBsZXNDb3BpZWQsCiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoIC0gdGhpcy5fY3VycmVudENodW5rT2Zmc2V0CiAgICAgICAgKTsKICAgICAgICAvLyBEaXJlY3RseSB3cml0ZSB0byBvdXRwdXRDaGFubmVsIHRvIGF2b2lkIGV4dHJhIGNvcHkKICAgICAgICBjb25zdCBzcmMgPSB0aGlzLl9jdXJyZW50Q2h1bms7CiAgICAgICAgY29uc3QgYmFzZVNyYyA9IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldDsKICAgICAgICBjb25zdCBiYXNlRHN0ID0gc2FtcGxlc0NvcGllZDsKICAgICAgICBjb25zdCBzY2FsZSA9IHRoaXMuX3NjYWxlOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2FtcGxlc1RvQ29weTsgaSsrKSB7CiAgICAgICAgICBvdXRwdXRDaGFubmVsW2Jhc2VEc3QgKyBpXSA9IHNyY1tiYXNlU3JjICsgaV0gKiBzY2FsZTsKICAgICAgICB9CgogICAgICAgIHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCArPSBzYW1wbGVzVG9Db3B5OwogICAgICAgIHNhbXBsZXNDb3BpZWQgKz0gc2FtcGxlc1RvQ29weTsKICAgICAgfQogICAgfQoKICAgIC8vIFplcm8tZmlsbCB0aGUgcmVtYWluZGVyLCBpZiBhbnksIG9uY2UgcGVyIGJsb2NrCiAgICBpZiAoc2FtcGxlc0NvcGllZCA8IGJsb2NrU2l6ZSkgewogICAgICBvdXRwdXRDaGFubmVsLmZpbGwoMCwgc2FtcGxlc0NvcGllZCk7CiAgICB9CgogICAgLy8gVXBkYXRlIG1ldHJpY3MgKG9wdGlvbmFsKQogICAgaWYgKHRoaXMuX21ldHJpY3NFbmFibGVkKSB7CiAgICAgIHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZCArPSBibG9ja1NpemU7CgogICAgICAvLyBUcmFjayBxdWV1ZSBkZXB0aCBpbiBzYW1wbGVzIChhcHByb3hpbWF0ZSkKICAgICAgbGV0IHF1ZXVlZFNhbXBsZXMgPSAwOwogICAgICBpZiAodGhpcy5fY3VycmVudENodW5rKSBxdWV1ZWRTYW1wbGVzICs9IE1hdGgubWF4KDAsIHRoaXMuX2N1cnJlbnRDaHVuay5sZW5ndGggLSB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQpOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aDsgaSsrKSBxdWV1ZWRTYW1wbGVzICs9IHRoaXMuX2J1ZmZlclF1ZXVlW2ldLmxlbmd0aDsKICAgICAgaWYgKHF1ZXVlZFNhbXBsZXMgPiB0aGlzLl9tYXhRdWV1ZVNhbXBsZXMpIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IHF1ZXVlZFNhbXBsZXM7CgogICAgICAvLyBQZXJpb2RpY2FsbHkgc2VuZCBtZXRyaWNzIHRvIG1haW4gdGhyZWFkCiAgICAgIGlmICh0aGlzLl9mcmFtZXNQcm9jZXNzZWQgLSB0aGlzLl9sYXN0TWV0cmljc1NlbnRBdEZyYW1lID49IHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcykgewogICAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", 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
- }, _ = new f.Quaternion(), V = new f.Euler(), Re = new f.Vector3(), ve = new f.Vector3(), We = 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(), Ie = 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 qe(), 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 = {
@@ -4073,22 +4073,22 @@ class Ne {
4073
4073
  if (this.isAvatarOnly = this.opt.avatarOnly, this.isAvatarOnly)
4074
4074
  this.scene = this.opt.avatarOnlyScene, this.camera = this.opt.avatarOnlyCamera;
4075
4075
  else {
4076
- 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(
4077
- new f.Color(this.opt.lightAmbientColor),
4076
+ 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(
4077
+ new x.Color(this.opt.lightAmbientColor),
4078
4078
  this.opt.lightAmbientIntensity
4079
- ), this.lightDirect = new f.DirectionalLight(
4080
- new f.Color(this.opt.lightDirectColor),
4079
+ ), this.lightDirect = new x.DirectionalLight(
4080
+ new x.Color(this.opt.lightDirectColor),
4081
4081
  this.opt.lightDirectIntensity
4082
- ), this.lightSpot = new f.SpotLight(
4083
- new f.Color(this.opt.lightSpotColor),
4082
+ ), this.lightSpot = new x.SpotLight(
4083
+ new x.Color(this.opt.lightSpotColor),
4084
4084
  this.opt.lightSpotIntensity,
4085
4085
  0,
4086
4086
  this.opt.lightSpotDispersion
4087
4087
  ), this.setLighting(this.opt);
4088
- const l = new f.PMREMGenerator(this.renderer);
4089
- l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new _e()).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;
4088
+ const l = new x.PMREMGenerator(this.renderer);
4089
+ 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;
4090
4090
  }
4091
- this.ikMesh = new f.SkinnedMesh();
4091
+ this.ikMesh = new x.SkinnedMesh();
4092
4092
  const s = {
4093
4093
  LeftShoulder: null,
4094
4094
  LeftArm: "LeftShoulder",
@@ -4101,10 +4101,10 @@ class Ne {
4101
4101
  RightHand: "RightForeArm",
4102
4102
  RightHandMiddle1: "RightHand"
4103
4103
  }, o = [];
4104
- Object.entries(s).forEach((l, u) => {
4105
- const r = new f.Bone();
4104
+ Object.entries(s).forEach((l, h) => {
4105
+ const r = new x.Bone();
4106
4106
  r.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(r) : this.ikMesh.add(r), o.push(r);
4107
- }), 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 = [];
4107
+ }), 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 = [];
4108
4108
  }
4109
4109
  /**
4110
4110
  * Helper that re/creates the audio context and the other nodes.
@@ -4150,9 +4150,9 @@ class Ne {
4150
4150
  let e = 3 * t.length / 4;
4151
4151
  t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
4152
4152
  const n = new ArrayBuffer(e), i = new Uint8Array(n);
4153
- let s, o = 0, l, u, r, h;
4153
+ let s, o = 0, l, h, r, u;
4154
4154
  for (s = 0; s < t.length; s += 4)
4155
- 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;
4155
+ 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;
4156
4156
  return n;
4157
4157
  }
4158
4158
  /**
@@ -4193,8 +4193,8 @@ class Ne {
4193
4193
  const e = {};
4194
4194
  for (let [n, i] of Object.entries(t)) {
4195
4195
  const s = n.split(".");
4196
- 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;
4197
- 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());
4196
+ 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;
4197
+ 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());
4198
4198
  }
4199
4199
  return e;
4200
4200
  }
@@ -4222,23 +4222,23 @@ class Ne {
4222
4222
  t.forEach((s) => {
4223
4223
  if (!i && s.morphTargetDictionary.hasOwnProperty(e)) return;
4224
4224
  const o = s.geometry;
4225
- let l = null, u = null;
4226
- for (const [r, h] of Object.entries(n))
4225
+ let l = null, h = null;
4226
+ for (const [r, u] of Object.entries(n))
4227
4227
  if (s.morphTargetDictionary.hasOwnProperty(r)) {
4228
- const a = s.morphTargetDictionary[r], c = o.morphAttributes.position[a], d = o.morphAttributes.normal?.[a];
4229
- l || (l = new f.Float32BufferAttribute(c.count * 3, 3), d && (u = new f.Float32BufferAttribute(c.count * 3, 3)));
4230
- for (let g = 0; g < c.count; g++) {
4231
- const x = l.getX(g) + c.getX(g) * h, b = l.getY(g) + c.getY(g) * h, I = l.getZ(g) + c.getZ(g) * h;
4232
- l.setXYZ(g, x, b, I);
4228
+ const a = s.morphTargetDictionary[r], d = o.morphAttributes.position[a], c = o.morphAttributes.normal?.[a];
4229
+ l || (l = new x.Float32BufferAttribute(d.count * 3, 3), c && (h = new x.Float32BufferAttribute(d.count * 3, 3)));
4230
+ for (let g = 0; g < d.count; g++) {
4231
+ const y = l.getX(g) + d.getX(g) * u, b = l.getY(g) + d.getY(g) * u, R = l.getZ(g) + d.getZ(g) * u;
4232
+ l.setXYZ(g, y, b, R);
4233
4233
  }
4234
- if (d)
4235
- for (let g = 0; g < c.count; g++) {
4236
- const x = u.getX(g) + d.getX(g) * h, b = u.getY(g) + d.getY(g) * h, I = u.getZ(g) + d.getZ(g) * h;
4237
- u.setXYZ(g, x, b, I);
4234
+ if (c)
4235
+ for (let g = 0; g < d.count; g++) {
4236
+ const y = h.getX(g) + c.getX(g) * u, b = h.getY(g) + c.getY(g) * u, R = h.getZ(g) + c.getZ(g) * u;
4237
+ h.setXYZ(g, y, b, R);
4238
4238
  }
4239
4239
  }
4240
4240
  if (l) {
4241
- o.morphAttributes.position.push(l), u && o.morphAttributes.normal.push(u);
4241
+ o.morphAttributes.position.push(l), h && o.morphAttributes.normal.push(h);
4242
4242
  const r = o.morphAttributes.position.length - 1;
4243
4243
  s.morphTargetInfluences[r] = 0, s.morphTargetDictionary[e] = r;
4244
4244
  }
@@ -4268,7 +4268,7 @@ class Ne {
4268
4268
  throw new Error("Blend shapes not found");
4269
4269
  const o = new Set(this.mtCustoms);
4270
4270
  this.morphs.forEach((r) => {
4271
- Object.keys(r.morphTargetDictionary).forEach((h) => o.add(h));
4271
+ Object.keys(r.morphTargetDictionary).forEach((u) => o.add(u));
4272
4272
  }), this.mtExtras.forEach((r) => {
4273
4273
  o.has(r.key) || (this.addMixedMorphTarget(this.morphs, r.key, r.mix), o.add(r.key));
4274
4274
  });
@@ -4295,16 +4295,16 @@ class Ne {
4295
4295
  ms: [],
4296
4296
  is: []
4297
4297
  }, l[r].value = l[r].baseline, l[r].applied = l[r].baseline;
4298
- const h = this.mtAvatar[r];
4299
- h && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((a) => {
4300
- l[r][a] = h[a];
4298
+ const u = this.mtAvatar[r];
4299
+ u && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((a) => {
4300
+ l[r][a] = u[a];
4301
4301
  }), this.morphs.forEach((a) => {
4302
- const c = a.morphTargetDictionary[r];
4303
- c !== void 0 && (l[r].ms.push(a.morphTargetInfluences), l[r].is.push(c), a.morphTargetInfluences[c] = l[r].applied);
4302
+ const d = a.morphTargetDictionary[r];
4303
+ d !== void 0 && (l[r].ms.push(a.morphTargetInfluences), l[r].is.push(d), a.morphTargetInfluences[d] = l[r].applied);
4304
4304
  });
4305
4305
  }), this.mtAvatar = l, this.poseAvatar = { props: {} }, this.posePropNames.forEach((r) => {
4306
- const h = r.split("."), a = this.armature.getObjectByName(h[0]);
4307
- 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;
4306
+ const u = r.split("."), a = this.armature.getObjectByName(u[0]);
4307
+ 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;
4308
4308
  }), this.ikMesh.traverse((r) => {
4309
4309
  r.isBone && r.position.copy(this.armature.getObjectByName(r.name).position);
4310
4310
  }), 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"))
@@ -4314,8 +4314,8 @@ class Ne {
4314
4314
  console.error("Dynamic bones setup failed: " + r);
4315
4315
  }
4316
4316
  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");
4317
- const u = new f.Vector3();
4318
- 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.avatar.body === "M" && this.poseTemplates.wide && (this.poseName = "wide", this.setPoseFromTemplate(this.poseTemplates.wide, 0), console.log("Set initial male-appropriate pose: wide")), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
4317
+ const h = new x.Vector3();
4318
+ 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.avatar.body === "M" && this.poseTemplates.wide && (this.poseName = "wide", this.setPoseFromTemplate(this.poseTemplates.wide, 0), console.log("Set initial male-appropriate pose: wide")), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
4319
4319
  }
4320
4320
  /**
4321
4321
  * Get view names.
@@ -4343,29 +4343,29 @@ class Ne {
4343
4343
  return;
4344
4344
  }
4345
4345
  if (this.viewName = t || this.viewName, e = e || {}, this.isAvatarOnly) return;
4346
- 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);
4347
- let r = -n * Math.tan(u / 2), h = (1 - i) * Math.tan(u / 2), a = s;
4346
+ 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);
4347
+ let r = -n * Math.tan(h / 2), u = (1 - i) * Math.tan(h / 2), a = s;
4348
4348
  switch (this.viewName) {
4349
4349
  case "head":
4350
- a += 2, h = h * a + 4 * this.avatarHeight / 5;
4350
+ a += 2, u = u * a + 4 * this.avatarHeight / 5;
4351
4351
  break;
4352
4352
  case "upper":
4353
- a += 4.5, h = h * a + 2 * this.avatarHeight / 3;
4353
+ a += 4.5, u = u * a + 2 * this.avatarHeight / 3;
4354
4354
  break;
4355
4355
  case "mid":
4356
- a += 8, h = h * a + this.avatarHeight / 3;
4356
+ a += 8, u = u * a + this.avatarHeight / 3;
4357
4357
  break;
4358
4358
  default:
4359
- a += 12, h = h * a;
4359
+ a += 12, u = u * a;
4360
4360
  }
4361
- 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;
4361
+ 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;
4362
4362
  }
4363
4363
  /**
4364
4364
  * Change light colors and intensities.
4365
4365
  * @param {Object} opt Options
4366
4366
  */
4367
4367
  setLighting(t) {
4368
- 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));
4368
+ 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));
4369
4369
  }
4370
4370
  /**
4371
4371
  * Render scene.
@@ -4398,9 +4398,9 @@ class Ne {
4398
4398
  updatePoseDelta() {
4399
4399
  for (const [t, e] of Object.entries(this.poseDelta.props)) {
4400
4400
  if (e.x === 0 && e.y === 0 && e.z === 0) continue;
4401
- V.set(e.x, e.y, e.z);
4401
+ W.set(e.x, e.y, e.z);
4402
4402
  const n = this.poseAvatar.props[t];
4403
- n.isQuaternion ? (_.setFromEuler(V), n.multiply(_)) : n.isVector3 && n.add(V);
4403
+ n.isQuaternion ? (Q.setFromEuler(W), n.multiply(Q)) : n.isVector3 && n.add(W);
4404
4404
  }
4405
4405
  }
4406
4406
  /**
@@ -4455,17 +4455,17 @@ class Ne {
4455
4455
  "HandMiddle",
4456
4456
  "HandRing",
4457
4457
  "HandPinky"
4458
- ].forEach((h, a) => {
4459
- 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);
4458
+ ].forEach((u, a) => {
4459
+ 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);
4460
4460
  });
4461
4461
  break;
4462
4462
  case "chestInhale":
4463
- 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 };
4464
- this.poseDelta.props["Spine1.scale"] = u, this.poseDelta.props["Neck.scale"] = r, this.poseDelta.props["LeftArm.scale"] = r, this.poseDelta.props["RightArm.scale"] = r;
4463
+ 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 };
4464
+ this.poseDelta.props["Spine1.scale"] = h, this.poseDelta.props["Neck.scale"] = r, this.poseDelta.props["LeftArm.scale"] = r, this.poseDelta.props["RightArm.scale"] = r;
4465
4465
  break;
4466
4466
  default:
4467
- for (let h = 0, a = n.ms.length; h < a; h++)
4468
- n.ms[h][n.is[h]] = n.applied;
4467
+ for (let u = 0, a = n.ms.length; u < a; u++)
4468
+ n.ms[u][n.is[u]] = n.applied;
4469
4469
  }
4470
4470
  }
4471
4471
  }
@@ -4480,8 +4480,8 @@ class Ne {
4480
4480
  return Object.entries(t).forEach((i, s) => {
4481
4481
  const o = i[0].split(".");
4482
4482
  if (o[1] === "position" || o[1] === "rotation" || o[1] === "quaternion") {
4483
- const l = o[1] === "quaternion" ? o[0] + ".rotation" : i[0], u = i[1].isQuaternion ? new f.Euler().setFromQuaternion(i[1]) : i[1];
4484
- 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 += "}";
4483
+ const l = o[1] === "quaternion" ? o[0] + ".rotation" : i[0], h = i[1].isQuaternion ? new x.Euler().setFromQuaternion(i[1]) : i[1];
4484
+ 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 += "}";
4485
4485
  }
4486
4486
  }), n += "}", n;
4487
4487
  }
@@ -4551,8 +4551,8 @@ class Ne {
4551
4551
  if (n ? (this.poseCurrentTemplate = this.poseTemplates.oneknee, setTimeout(() => {
4552
4552
  this.setPoseFromTemplate(t, e);
4553
4553
  }, 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)
4554
- for (let [l, u] of Object.entries(this.gesture))
4555
- 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);
4554
+ for (let [l, h] of Object.entries(this.gesture))
4555
+ 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);
4556
4556
  Object.keys(this.poseDelta.props).forEach((l) => {
4557
4557
  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);
4558
4558
  });
@@ -4985,12 +4985,12 @@ class Ne {
4985
4985
  else if (l.hasOwnProperty("alt")) {
4986
4986
  let r = l.alt[0];
4987
4987
  if (l.alt.length > 1) {
4988
- const h = Math.random();
4988
+ const u = Math.random();
4989
4989
  let a = 0;
4990
- for (let c = 0; c < l.alt.length; c++) {
4991
- let d = this.valueFn(l.alt[c].p);
4992
- if (a += d === void 0 ? (1 - a) / (l.alt.length - 1 - c) : d, h < a) {
4993
- r = l.alt[c];
4990
+ for (let d = 0; d < l.alt.length; d++) {
4991
+ let c = this.valueFn(l.alt[d].p);
4992
+ if (a += c === void 0 ? (1 - a) / (l.alt.length - 1 - d) : c, u < a) {
4993
+ r = l.alt[d];
4994
4994
  break;
4995
4995
  }
4996
4996
  }
@@ -4999,20 +4999,20 @@ class Ne {
4999
4999
  continue;
5000
5000
  } else
5001
5001
  break;
5002
- let u = this.valueFn(l.delay) || 0;
5003
- if (Array.isArray(u) && (u = this.gaussianRandom(...u)), l.hasOwnProperty("dt"))
5004
- l.dt.forEach((r, h) => {
5002
+ let h = this.valueFn(l.delay) || 0;
5003
+ if (Array.isArray(h) && (h = this.gaussianRandom(...h)), l.hasOwnProperty("dt"))
5004
+ l.dt.forEach((r, u) => {
5005
5005
  let a = this.valueFn(r);
5006
- Array.isArray(a) && (a = this.gaussianRandom(...a)), o.ts[h + 1] = o.ts[h] + a;
5006
+ Array.isArray(a) && (a = this.gaussianRandom(...a)), o.ts[u + 1] = o.ts[u] + a;
5007
5007
  });
5008
5008
  else {
5009
- let r = Object.values(l.vs).reduce((h, a) => a.length > h ? a.length : h, 0);
5009
+ let r = Object.values(l.vs).reduce((u, a) => a.length > u ? a.length : u, 0);
5010
5010
  o.ts = Array(r + 1).fill(0);
5011
5011
  }
5012
- s ? o.ts = o.ts.map((r) => u + r * n) : o.ts = o.ts.map((r) => this.animClock + u + r * n), l.vs && l.vs.pose && console.log("Pose being selected from vs.pose:", l.vs.pose, "for avatar body:", this.avatar?.body);
5013
- for (let [r, h] of Object.entries(l.vs)) {
5014
- 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 ? r === "pose" && this.avatar && this.avatar.body === "M" && (d === "hip" || d === "side") ? (console.log("Intercepting pose", d, "in animation factory, overriding to wide for male avatar"), "wide") : 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));
5015
- 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];
5012
+ s ? o.ts = o.ts.map((r) => h + r * n) : o.ts = o.ts.map((r) => this.animClock + h + r * n), l.vs && l.vs.pose && console.log("Pose being selected from vs.pose:", l.vs.pose, "for avatar body:", this.avatar?.body);
5013
+ for (let [r, u] of Object.entries(l.vs)) {
5014
+ const a = this.getBaselineValue(r), d = u.map((c) => (c = this.valueFn(c), c === null ? null : typeof c == "function" ? c : typeof c == "string" || c instanceof String ? r === "pose" && this.avatar && this.avatar.body === "M" && (c === "hip" || c === "side") ? (console.log("Intercepting pose", c, "in animation factory, overriding to wide for male avatar"), "wide") : c.slice() : Array.isArray(c) ? r === "gesture" ? c.slice() : (a === void 0 ? 0 : a) + i * this.gaussianRandom(...c) : typeof c == "boolean" ? c : c instanceof Object && c.constructor === Object ? Object.assign({}, c) : (a === void 0 ? 0 : a) + i * c));
5015
+ r === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...d.map((c) => c > 0 ? c : 0)], o.vs.eyeLookInLeft = [null, ...d.map((c) => c > 0 ? 0 : -c)], o.vs.eyeLookOutRight = [null, ...d.map((c) => c > 0 ? 0 : -c)], o.vs.eyeLookInRight = [null, ...d.map((c) => c > 0 ? c : 0)]) : r === "eyesRotateX" ? (o.vs.eyesLookDown = [null, ...d.map((c) => c > 0 ? c : 0)], o.vs.eyesLookUp = [null, ...d.map((c) => c > 0 ? 0 : -c)]) : o.vs[r] = [null, ...d];
5016
5016
  }
5017
5017
  for (let r of Object.keys(o.vs))
5018
5018
  for (; o.vs[r].length <= o.ts.length; ) o.vs[r].push(o.vs[r][o.vs[r].length - 1]);
@@ -5093,26 +5093,26 @@ class Ne {
5093
5093
  if (this.isSpeaking)
5094
5094
  for (l = 0, this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData), n = 2, s = 10; n < s; n++)
5095
5095
  this.volumeFrequencyData[n] > l && (l = this.volumeFrequencyData[n]);
5096
- let u = null, r = null;
5097
- const h = [];
5096
+ let h = null, r = null;
5097
+ const u = [];
5098
5098
  for (n = 0, s = this.animQueue.length; n < s; n++) {
5099
5099
  const a = this.animQueue[n];
5100
5100
  if (!(!a || !a.ts || !a.ts.length || this.animClock < a.ts[0])) {
5101
5101
  for (i = a.ndx || 0, o = a.ts.length; i < o && !(this.animClock < a.ts[i]); i++)
5102
- for (let [c, d] of Object.entries(a.vs))
5103
- if (this.mtAvatar.hasOwnProperty(c)) {
5104
- if (d[i + 1] === null) continue;
5105
- const g = this.mtAvatar[c];
5106
- if (d[i] === null && (d[i] = g.value), i === o - 1)
5107
- g.newvalue = d[i];
5102
+ for (let [d, c] of Object.entries(a.vs))
5103
+ if (this.mtAvatar.hasOwnProperty(d)) {
5104
+ if (c[i + 1] === null) continue;
5105
+ const g = this.mtAvatar[d];
5106
+ if (c[i] === null && (c[i] = g.value), i === o - 1)
5107
+ g.newvalue = c[i];
5108
5108
  else {
5109
- g.newvalue = d[i + 1];
5110
- const x = a.ts[i + 1] - a.ts[i];
5109
+ g.newvalue = c[i + 1];
5110
+ const y = a.ts[i + 1] - a.ts[i];
5111
5111
  let b = 1;
5112
- x > 1e-4 && (b = (this.animClock - a.ts[i]) / x), 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;
5112
+ y > 1e-4 && (b = (this.animClock - a.ts[i]) / y), b < 1 && (g.easing && (b = g.easing(b)), g.newvalue = (1 - b) * c[i] + b * g.newvalue), g.ref && g.ref !== a.vs && g.ref.hasOwnProperty(d) && delete g.ref[d], g.ref = a.vs;
5113
5113
  }
5114
5114
  if (l)
5115
- switch (c) {
5115
+ switch (d) {
5116
5116
  case "viseme_aa":
5117
5117
  case "viseme_E":
5118
5118
  case "viseme_I":
@@ -5121,12 +5121,12 @@ class Ne {
5121
5121
  g.newvalue *= 1 + l / 255 - 0.5;
5122
5122
  }
5123
5123
  g.needsUpdate = !0;
5124
- } 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);
5124
+ } else d === "eyeContact" && c[i] !== null && h !== !1 ? h = !!c[i] : d === "headMove" && c[i] !== null && r !== !1 ? c[i] === 0 ? r = !1 : (Math.random() < c[i] && (r = !0), c[i] = null) : c[i] !== null && (u.push({ mt: d, val: c[i] }), c[i] = null);
5125
5125
  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;
5126
5126
  }
5127
5127
  }
5128
- for (let a = 0, c = h.length; a < c; a++)
5129
- switch (i = h[a].val, h[a].mt) {
5128
+ for (let a = 0, d = u.length; a < d; a++)
5129
+ switch (i = u[a].val, u[a].mt) {
5130
5130
  case "speak":
5131
5131
  this.speakText(i);
5132
5132
  break;
@@ -5143,8 +5143,8 @@ class Ne {
5143
5143
  i && typeof i == "function" && i();
5144
5144
  break;
5145
5145
  case "moveto":
5146
- Object.entries(i.props).forEach((d) => {
5147
- d[1] ? this.poseTarget.props[d[0]].copy(d[1]) : this.poseTarget.props[d[0]].copy(this.getPoseTemplateProp(d[0])), this.poseTarget.props[d[0]].t = this.animClock, this.poseTarget.props[d[0]].d = d[1] && d[1].d ? d[1].d : d.duration || 2e3;
5146
+ Object.entries(i.props).forEach((c) => {
5147
+ c[1] ? this.poseTarget.props[c[0]].copy(c[1]) : this.poseTarget.props[c[0]].copy(this.getPoseTemplateProp(c[0])), this.poseTarget.props[c[0]].t = this.animClock, this.poseTarget.props[c[0]].d = c[1] && c[1].d ? c[1].d : c.duration || 2e3;
5148
5148
  });
5149
5149
  break;
5150
5150
  case "handLeft":
@@ -5157,7 +5157,7 @@ class Ne {
5157
5157
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
5158
5158
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5159
5159
  ]
5160
- }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5160
+ }, i.x ? new x.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5161
5161
  break;
5162
5162
  case "handRight":
5163
5163
  this.ikSolve({
@@ -5169,10 +5169,10 @@ class Ne {
5169
5169
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2 },
5170
5170
  { link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5171
5171
  ]
5172
- }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5172
+ }, i.x ? new x.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5173
5173
  break;
5174
5174
  }
5175
- if ((u || r) && (V.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), V.x = Math.max(-0.9, Math.min(0.9, 2 * V.x - 0.5)), V.y = Math.max(-0.9, Math.min(0.9, -2.5 * V.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: V.x < 0 ? -V.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: V.x < 0 ? 0 : V.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: V.y < 0 ? -V.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: V.y < 0 ? 0 : V.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: V.y < 0 ? 0 : V.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: V.y < 0 ? -V.y : 0, needsUpdate: !0 }), r && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5175
+ 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({
5176
5176
  name: "headmove",
5177
5177
  dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
5178
5178
  vs: {
@@ -5193,13 +5193,13 @@ class Ne {
5193
5193
  eyeLookOutRight: [null, 0],
5194
5194
  eyeContact: [0]
5195
5195
  }
5196
- })))), 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 && (_.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(_)), We.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(Re), Re.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(ve), ve.sub(this.armature.position), this.objectHips.position.y -= We.min.y / 2, this.objectHips.position.x -= (Re.x + ve.x) / 4, this.objectHips.position.z -= (Re.z + ve.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5196
+ })))), 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(Ie), Ie.sub(this.armature.position), this.objectHips.position.y -= We.min.y / 2, this.objectHips.position.x -= (ve.x + Ie.x) / 4, this.objectHips.position.z -= (ve.z + Ie.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5197
5197
  this.stats && this.stats.end();
5198
5198
  else {
5199
5199
  if (this.cameraClock !== null && this.cameraClock < 1e3) {
5200
5200
  this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
5201
- let a = new f.Spherical().setFromVector3(this.cameraStart), c = new f.Spherical().setFromVector3(this.cameraEnd);
5202
- 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();
5201
+ let a = new x.Spherical().setFromVector3(this.cameraStart), d = new x.Spherical().setFromVector3(this.cameraEnd);
5202
+ a.phi += this.easing(this.cameraClock / 1e3) * (d.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (d.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (d.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), d.setFromVector3(this.controlsEnd), a.phi += this.easing(this.cameraClock / 1e3) * (d.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (d.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (d.radius - a.radius), a.makeSafe(), this.controls.target.setFromSpherical(a)), this.controls.update();
5203
5203
  }
5204
5204
  this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
5205
5205
  }
@@ -5260,49 +5260,49 @@ class Ne {
5260
5260
  */
5261
5261
  speakText(t, e = null, n = null, i = null) {
5262
5262
  e = e || {};
5263
- 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;
5264
- let h = "", a = "", c = 0, d = [], g = [];
5265
- const x = Array.from(this.segmenter.segment(t), (b) => b.segment);
5266
- for (let b = 0; b < x.length; b++) {
5267
- const I = b === x.length - 1, H = x[b].match(l);
5268
- let m = x[b].match(s);
5269
- const T = x[b].match(u), k = x[b].match(o);
5270
- if (m && !I && !T && x[b + 1].match(s) && (m = !1), n && (h += x[b]), H && (!i || i.every((y) => b < y[0] || b > y[1])) && (a += x[b]), (k || m || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5271
- mark: c,
5263
+ 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;
5264
+ let u = "", a = "", d = 0, c = [], g = [];
5265
+ const y = Array.from(this.segmenter.segment(t), (b) => b.segment);
5266
+ for (let b = 0; b < y.length; b++) {
5267
+ const R = b === y.length - 1, V = y[b].match(l);
5268
+ let p = y[b].match(s);
5269
+ const M = y[b].match(h), z = y[b].match(o);
5270
+ if (p && !R && !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]), (z || p || R) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && c.push({
5271
+ mark: d,
5272
5272
  word: a
5273
- })), h.length && (g.push({
5274
- mark: c,
5273
+ })), u.length && (g.push({
5274
+ mark: d,
5275
5275
  template: { name: "subtitles" },
5276
5276
  ts: [0],
5277
5277
  vs: {
5278
- subtitles: [h]
5278
+ subtitles: [u]
5279
5279
  }
5280
- }), h = ""), a.length)) {
5281
- const y = this.lipsyncWordsToVisemes(a, r);
5282
- if (y && y.visemes && y.visemes.length) {
5283
- const M = y.times[y.visemes.length - 1] + y.durations[y.visemes.length - 1];
5284
- for (let P = 0; P < y.visemes.length; P++)
5280
+ }), u = ""), a.length)) {
5281
+ const f = this.lipsyncWordsToVisemes(a, r);
5282
+ if (f && f.visemes && f.visemes.length) {
5283
+ const E = f.times[f.visemes.length - 1] + f.durations[f.visemes.length - 1];
5284
+ for (let P = 0; P < f.visemes.length; P++)
5285
5285
  g.push({
5286
- mark: c,
5286
+ mark: d,
5287
5287
  template: { name: "viseme" },
5288
- ts: [(y.times[P] - 0.6) / M, (y.times[P] + 0.5) / M, (y.times[P] + y.durations[P] + 0.5) / M],
5288
+ ts: [(f.times[P] - 0.6) / E, (f.times[P] + 0.5) / E, (f.times[P] + f.durations[P] + 0.5) / E],
5289
5289
  vs: {
5290
- ["viseme_" + y.visemes[P]]: [null, y.visemes[P] === "PP" || y.visemes[P] === "FF" ? 0.9 : 0.6, 0]
5290
+ ["viseme_" + f.visemes[P]]: [null, f.visemes[P] === "PP" || f.visemes[P] === "FF" ? 0.9 : 0.6, 0]
5291
5291
  }
5292
5292
  });
5293
5293
  }
5294
- a = "", c++;
5294
+ a = "", d++;
5295
5295
  }
5296
- if (m || I) {
5297
- if (d.length || I && g.length) {
5298
- const y = {
5296
+ if (p || R) {
5297
+ if (c.length || R && g.length) {
5298
+ const f = {
5299
5299
  anim: g
5300
5300
  };
5301
- n && (y.onSubtitles = n), d.length && !e.avatarMute && (y.text = d, e.avatarMood && (y.mood = e.avatarMood), e.ttsLang && (y.lang = e.ttsLang), e.ttsVoice && (y.voice = e.ttsVoice), e.ttsRate && (y.rate = e.ttsRate), e.ttsVoice && (y.pitch = e.ttsPitch), e.ttsVolume && (y.volume = e.ttsVolume)), this.speechQueue.push(y), d = [], a = "", c = 0, g = [];
5301
+ n && (f.onSubtitles = n), c.length && !e.avatarMute && (f.text = c, 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), c = [], a = "", d = 0, g = [];
5302
5302
  }
5303
- if (T) {
5304
- let y = this.animEmojis[x[b]];
5305
- y && y.link && (y = this.animEmojis[y.link]), y && this.speechQueue.push({ emoji: y });
5303
+ if (M) {
5304
+ let f = this.animEmojis[y[b]];
5305
+ f && f.link && (f = this.animEmojis[f.link]), f && this.speechQueue.push({ emoji: f });
5306
5306
  }
5307
5307
  this.speechQueue.push({ break: 100 });
5308
5308
  }
@@ -5383,27 +5383,27 @@ class Ne {
5383
5383
  if (t.words) {
5384
5384
  let o = [];
5385
5385
  for (let l = 0; l < t.words.length; l++) {
5386
- const u = t.words[l], r = t.wtimes[l];
5387
- let h = t.wdurations[l];
5388
- if (u.length && (n && o.push({
5386
+ const h = t.words[l], r = t.wtimes[l];
5387
+ let u = t.wdurations[l];
5388
+ if (h.length && (n && o.push({
5389
5389
  template: { name: "subtitles" },
5390
5390
  ts: [r],
5391
5391
  vs: {
5392
- subtitles: [" " + u]
5392
+ subtitles: [" " + h]
5393
5393
  }
5394
5394
  }), !t.visemes)) {
5395
- const a = this.lipsyncPreProcessText(u, i), c = this.lipsyncWordsToVisemes(a, i);
5396
- if (c && c.visemes && c.visemes.length) {
5397
- 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));
5398
- let x = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5399
- if (h = Math.min(h, c.visemes.length * 200), d > 0)
5400
- for (let b = 0; b < c.visemes.length; b++) {
5401
- const I = r + c.times[b] / d * h, H = c.durations[b] / d * h;
5395
+ const a = this.lipsyncPreProcessText(h, i), d = this.lipsyncWordsToVisemes(a, i);
5396
+ if (d && d.visemes && d.visemes.length) {
5397
+ const c = d.times[d.visemes.length - 1] + d.durations[d.visemes.length - 1], g = Math.min(u, Math.max(0, u - d.visemes.length * 150));
5398
+ let y = 0.6 + this.convertRange(g, [0, u], [0, 0.4]);
5399
+ if (u = Math.min(u, d.visemes.length * 200), c > 0)
5400
+ for (let b = 0; b < d.visemes.length; b++) {
5401
+ const R = r + d.times[b] / c * u, V = d.durations[b] / c * u;
5402
5402
  o.push({
5403
5403
  template: { name: "viseme" },
5404
- ts: [I - Math.min(60, 2 * H / 3), I + Math.min(25, H / 2), I + H + Math.min(60, H / 2)],
5404
+ ts: [R - Math.min(60, 2 * V / 3), R + Math.min(25, V / 2), R + V + Math.min(60, V / 2)],
5405
5405
  vs: {
5406
- ["viseme_" + c.visemes[b]]: [null, c.visemes[b] === "PP" || c.visemes[b] === "FF" ? 0.9 : x, 0]
5406
+ ["viseme_" + d.visemes[b]]: [null, d.visemes[b] === "PP" || d.visemes[b] === "FF" ? 0.9 : y, 0]
5407
5407
  }
5408
5408
  });
5409
5409
  }
@@ -5412,22 +5412,22 @@ class Ne {
5412
5412
  }
5413
5413
  if (t.visemes)
5414
5414
  for (let l = 0; l < t.visemes.length; l++) {
5415
- const u = t.visemes[l], r = t.vtimes[l], h = t.vdurations[l];
5415
+ const h = t.visemes[l], r = t.vtimes[l], u = t.vdurations[l];
5416
5416
  o.push({
5417
5417
  template: { name: "viseme" },
5418
- ts: [r - 2 * h / 3, r + h / 2, r + h + h / 2],
5418
+ ts: [r - 2 * u / 3, r + u / 2, r + u + u / 2],
5419
5419
  vs: {
5420
- ["viseme_" + u]: [null, u === "PP" || u === "FF" ? 0.9 : 0.6, 0]
5420
+ ["viseme_" + h]: [null, h === "PP" || h === "FF" ? 0.9 : 0.6, 0]
5421
5421
  }
5422
5422
  });
5423
5423
  }
5424
5424
  if (t.markers)
5425
5425
  for (let l = 0; l < t.markers.length; l++) {
5426
- const u = t.markers[l], r = t.mtimes[l];
5426
+ const h = t.markers[l], r = t.mtimes[l];
5427
5427
  o.push({
5428
5428
  template: { name: "markers" },
5429
5429
  ts: [r],
5430
- vs: { function: [u] }
5430
+ vs: { function: [h] }
5431
5431
  });
5432
5432
  }
5433
5433
  o.length && (s.anim = o);
@@ -5447,7 +5447,7 @@ class Ne {
5447
5447
  if (this.isAudioPlaying = !0, this.audioPlaylist.length) {
5448
5448
  const e = this.audioPlaylist.shift();
5449
5449
  if (this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") {
5450
- const s = this.audioCtx.resume(), o = new Promise((l, u) => setTimeout(() => u("p2"), 1e3));
5450
+ const s = this.audioCtx.resume(), o = new Promise((l, h) => setTimeout(() => h("p2"), 1e3));
5451
5451
  try {
5452
5452
  await Promise.race([s, o]);
5453
5453
  } catch {
@@ -5479,41 +5479,41 @@ class Ne {
5479
5479
  */
5480
5480
  async synthesizeWithBrowserTTS(t) {
5481
5481
  return new Promise((e, n) => {
5482
- const i = t.text.map((m) => m.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;
5483
- 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));
5484
- const h = speechSynthesis.getVoices(), a = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5485
- if (a && h.length > 0) {
5486
- const m = h.find((T) => T.name.includes(a) || T.lang === o);
5487
- m && (s.voice = m);
5482
+ 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;
5483
+ 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));
5484
+ const u = speechSynthesis.getVoices(), a = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5485
+ if (a && u.length > 0) {
5486
+ const p = u.find((M) => M.name.includes(a) || M.lang === o);
5487
+ p && (s.voice = p);
5488
5488
  }
5489
- 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", x = this.lipsyncPreProcessText(i, g), b = this.lipsyncWordsToVisemes(x, g);
5489
+ const d = i.length * 100 / s.rate, c = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (d / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", y = this.lipsyncPreProcessText(i, g), b = this.lipsyncWordsToVisemes(y, g);
5490
5490
  console.log("Browser TTS Lip-sync Debug:", {
5491
5491
  text: i,
5492
5492
  lipsyncLang: g,
5493
- processedText: x,
5493
+ processedText: y,
5494
5494
  lipsyncData: b,
5495
5495
  hasVisemes: b && b.visemes && b.visemes.length > 0,
5496
- estimatedDuration: c
5496
+ estimatedDuration: d
5497
5497
  });
5498
- const I = [];
5498
+ const R = [];
5499
5499
  if (b && b.visemes && b.visemes.length > 0) {
5500
- const m = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5501
- for (let T = 0; T < b.visemes.length; T++) {
5502
- const k = b.visemes[T], y = b.times[T] / m, M = b.durations[T] / m, P = y * c, D = M * c;
5503
- I.push({
5500
+ const p = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5501
+ for (let M = 0; M < b.visemes.length; M++) {
5502
+ const z = b.visemes[M], f = b.times[M] / p, E = b.durations[M] / p, P = f * d, U = E * d;
5503
+ R.push({
5504
5504
  template: { name: "viseme" },
5505
- ts: [P - Math.min(60, 2 * D / 3), P + Math.min(25, D / 2), P + D + Math.min(60, D / 2)],
5505
+ ts: [P - Math.min(60, 2 * U / 3), P + Math.min(25, U / 2), P + U + Math.min(60, U / 2)],
5506
5506
  vs: {
5507
- ["viseme_" + k]: [null, k === "PP" || k === "FF" ? 0.9 : 0.6, 0]
5507
+ ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5508
5508
  }
5509
5509
  });
5510
5510
  }
5511
5511
  }
5512
- const H = [...t.anim, ...I];
5513
- this.audioPlaylist.push({ anim: H, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5512
+ const V = [...t.anim, ...R];
5513
+ this.audioPlaylist.push({ anim: V, audio: c }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5514
5514
  e();
5515
- }, s.onerror = (m) => {
5516
- console.error("Speech synthesis error:", m.error), n(m.error);
5515
+ }, s.onerror = (p) => {
5516
+ console.error("Speech synthesis error:", p.error), n(p.error);
5517
5517
  }, speechSynthesis.speak(s);
5518
5518
  });
5519
5519
  }
@@ -5522,7 +5522,7 @@ class Ne {
5522
5522
  * @param {Object} line Speech line object
5523
5523
  */
5524
5524
  async synthesizeWithElevenLabsTTS(t) {
5525
- const e = t.text.map((c) => c.word).join(" "), n = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "21m00Tcm4TlvDq8ikWAM", i = {
5525
+ const e = t.text.map((d) => d.word).join(" "), n = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "21m00Tcm4TlvDq8ikWAM", i = {
5526
5526
  text: e,
5527
5527
  model_id: "eleven_monolingual_v1",
5528
5528
  voice_settings: {
@@ -5544,26 +5544,26 @@ class Ne {
5544
5544
  throw new Error(`ElevenLabs TTS error: ${s.status} ${s.statusText}`);
5545
5545
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5546
5546
  console.log("Using text-based lip-sync for debugging...");
5547
- const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5547
+ const h = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5548
5548
  let r;
5549
5549
  try {
5550
5550
  console.log("Lip-sync modules available:", {
5551
5551
  hasLipsync: !!this.lipsync,
5552
5552
  lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
5553
- lipsyncLang: u
5553
+ lipsyncLang: h
5554
5554
  });
5555
- const c = this.lipsyncPreProcessText(e, u), d = this.lipsyncWordsToVisemes(c, u);
5555
+ const d = this.lipsyncPreProcessText(e, h), c = this.lipsyncWordsToVisemes(d, h);
5556
5556
  if (console.log("Lip-sync data:", {
5557
- processedText: c,
5558
- lipsyncData: d,
5559
- hasVisemes: d && d.visemes && d.visemes.length > 0
5560
- }), d && d.visemes && d.visemes.length > 0)
5557
+ processedText: d,
5558
+ lipsyncData: c,
5559
+ hasVisemes: c && c.visemes && c.visemes.length > 0
5560
+ }), c && c.visemes && c.visemes.length > 0)
5561
5561
  r = {
5562
- visemes: d.visemes.map((g, x) => ({
5562
+ visemes: c.visemes.map((g, y) => ({
5563
5563
  viseme: g,
5564
- startTime: x * l.duration / d.visemes.length,
5565
- endTime: (x + 1) * l.duration / d.visemes.length,
5566
- duration: l.duration / d.visemes.length,
5564
+ startTime: y * l.duration / c.visemes.length,
5565
+ endTime: (y + 1) * l.duration / c.visemes.length,
5566
+ duration: l.duration / c.visemes.length,
5567
5567
  intensity: 0.7
5568
5568
  })),
5569
5569
  words: [],
@@ -5572,17 +5572,17 @@ class Ne {
5572
5572
  };
5573
5573
  else
5574
5574
  throw new Error("No visemes generated from text");
5575
- } catch (c) {
5576
- console.error("Text-based lip-sync failed, using fallback:", c);
5577
- const d = e.toLowerCase().split(/\s+/), g = [];
5578
- for (const x of d)
5579
- for (const b of x) {
5580
- let I = "aa";
5581
- "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);
5575
+ } catch (d) {
5576
+ console.error("Text-based lip-sync failed, using fallback:", d);
5577
+ const c = e.toLowerCase().split(/\s+/), g = [];
5578
+ for (const y of c)
5579
+ for (const b of y) {
5580
+ let R = "aa";
5581
+ "aeiou".includes(b) ? R = "aa" : "bp".includes(b) ? R = "PP" : "fv".includes(b) ? R = "FF" : "st".includes(b) ? R = "SS" : "dln".includes(b) ? R = "DD" : "kg".includes(b) ? R = "kk" : "rw".includes(b) && (R = "RR"), g.push(R);
5582
5582
  }
5583
5583
  r = {
5584
- visemes: g.map((x, b) => ({
5585
- viseme: x,
5584
+ visemes: g.map((y, b) => ({
5585
+ viseme: y,
5586
5586
  startTime: b * l.duration / g.length,
5587
5587
  endTime: (b + 1) * l.duration / g.length,
5588
5588
  duration: l.duration / g.length,
@@ -5605,31 +5605,31 @@ class Ne {
5605
5605
  visemes: r.visemes ? r.visemes.slice(0, 3) : []
5606
5606
  // Show first 3 visemes for debugging
5607
5607
  });
5608
- const h = [];
5608
+ const u = [];
5609
5609
  if (r.visemes && r.visemes.length > 0) {
5610
5610
  console.log("ElevenLabs: Generating lip-sync animation from", r.visemes.length, "visemes");
5611
- for (let c = 0; c < r.visemes.length; c++) {
5612
- const d = r.visemes[c], g = d.startTime * 1e3, x = d.duration * 1e3, b = d.intensity;
5613
- h.push({
5611
+ for (let d = 0; d < r.visemes.length; d++) {
5612
+ const c = r.visemes[d], g = c.startTime * 1e3, y = c.duration * 1e3, b = c.intensity;
5613
+ u.push({
5614
5614
  template: { name: "viseme" },
5615
- ts: [g - Math.min(60, 2 * x / 3), g + Math.min(25, x / 2), g + x + Math.min(60, x / 2)],
5615
+ ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
5616
5616
  vs: {
5617
- ["viseme_" + d.viseme]: [null, b, 0]
5617
+ ["viseme_" + c.viseme]: [null, b, 0]
5618
5618
  }
5619
5619
  });
5620
5620
  }
5621
- console.log("ElevenLabs: Generated", h.length, "lip-sync animation frames");
5621
+ console.log("ElevenLabs: Generated", u.length, "lip-sync animation frames");
5622
5622
  } else
5623
5623
  console.warn("ElevenLabs: No visemes available for lip-sync animation");
5624
- const a = [...t.anim, ...h];
5625
- 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();
5624
+ const a = [...t.anim, ...u];
5625
+ 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();
5626
5626
  }
5627
5627
  /**
5628
5628
  * Synthesize speech using Deepgram Aura-2 TTS
5629
5629
  * @param {Object} line Speech line object
5630
5630
  */
5631
5631
  async synthesizeWithDeepgramTTS(t) {
5632
- const e = t.text.map((c) => c.word).join(" "), n = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "aura-2-thalia-en", i = `${this.opt.ttsEndpoint}?model=${n}`, s = await fetch(i, {
5632
+ const e = t.text.map((d) => d.word).join(" "), n = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "aura-2-thalia-en", i = `${this.opt.ttsEndpoint}?model=${n}`, s = await fetch(i, {
5633
5633
  method: "POST",
5634
5634
  headers: {
5635
5635
  Authorization: `Token ${this.opt.ttsApikey}`,
@@ -5642,26 +5642,26 @@ class Ne {
5642
5642
  throw new Error(`Deepgram TTS error: ${s.status} ${s.statusText}`);
5643
5643
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5644
5644
  console.log("Using text-based lip-sync for Deepgram...");
5645
- const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5645
+ const h = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5646
5646
  let r;
5647
5647
  try {
5648
5648
  console.log("Lip-sync modules available:", {
5649
5649
  hasLipsync: !!this.lipsync,
5650
5650
  lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
5651
- lipsyncLang: u
5651
+ lipsyncLang: h
5652
5652
  });
5653
- const c = this.lipsyncPreProcessText(e, u), d = this.lipsyncWordsToVisemes(c, u);
5653
+ const d = this.lipsyncPreProcessText(e, h), c = this.lipsyncWordsToVisemes(d, h);
5654
5654
  if (console.log("Lip-sync data:", {
5655
- processedText: c,
5656
- lipsyncData: d,
5657
- hasVisemes: d && d.visemes && d.visemes.length > 0
5658
- }), d && d.visemes && d.visemes.length > 0)
5655
+ processedText: d,
5656
+ lipsyncData: c,
5657
+ hasVisemes: c && c.visemes && c.visemes.length > 0
5658
+ }), c && c.visemes && c.visemes.length > 0)
5659
5659
  r = {
5660
- visemes: d.visemes.map((g, x) => ({
5660
+ visemes: c.visemes.map((g, y) => ({
5661
5661
  viseme: g,
5662
- startTime: x * l.duration / d.visemes.length,
5663
- endTime: (x + 1) * l.duration / d.visemes.length,
5664
- duration: l.duration / d.visemes.length,
5662
+ startTime: y * l.duration / c.visemes.length,
5663
+ endTime: (y + 1) * l.duration / c.visemes.length,
5664
+ duration: l.duration / c.visemes.length,
5665
5665
  intensity: 0.7
5666
5666
  })),
5667
5667
  words: [],
@@ -5670,17 +5670,17 @@ class Ne {
5670
5670
  };
5671
5671
  else
5672
5672
  throw new Error("No visemes generated from text");
5673
- } catch (c) {
5674
- console.error("Text-based lip-sync failed, using fallback:", c);
5675
- const d = e.toLowerCase().split(/\s+/), g = [];
5676
- for (const x of d)
5677
- for (const b of x) {
5678
- let I = "aa";
5679
- "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);
5673
+ } catch (d) {
5674
+ console.error("Text-based lip-sync failed, using fallback:", d);
5675
+ const c = e.toLowerCase().split(/\s+/), g = [];
5676
+ for (const y of c)
5677
+ for (const b of y) {
5678
+ let R = "aa";
5679
+ "aeiou".includes(b) ? R = "aa" : "bp".includes(b) ? R = "PP" : "fv".includes(b) ? R = "FF" : "st".includes(b) ? R = "SS" : "dln".includes(b) ? R = "DD" : "kg".includes(b) ? R = "kk" : "rw".includes(b) && (R = "RR"), g.push(R);
5680
5680
  }
5681
5681
  r = {
5682
- visemes: g.map((x, b) => ({
5683
- viseme: x,
5682
+ visemes: g.map((y, b) => ({
5683
+ viseme: y,
5684
5684
  startTime: b * l.duration / g.length,
5685
5685
  endTime: (b + 1) * l.duration / g.length,
5686
5686
  duration: l.duration / g.length,
@@ -5703,24 +5703,24 @@ class Ne {
5703
5703
  visemes: r.visemes ? r.visemes.slice(0, 3) : []
5704
5704
  // Show first 3 visemes for debugging
5705
5705
  });
5706
- const h = [];
5706
+ const u = [];
5707
5707
  if (r.visemes && r.visemes.length > 0) {
5708
5708
  console.log("Deepgram: Generating lip-sync animation from", r.visemes.length, "visemes");
5709
- for (let c = 0; c < r.visemes.length; c++) {
5710
- const d = r.visemes[c], g = d.startTime * 1e3, x = d.duration * 1e3, b = d.intensity;
5711
- h.push({
5709
+ for (let d = 0; d < r.visemes.length; d++) {
5710
+ const c = r.visemes[d], g = c.startTime * 1e3, y = c.duration * 1e3, b = c.intensity;
5711
+ u.push({
5712
5712
  template: { name: "viseme" },
5713
- ts: [g - Math.min(60, 2 * x / 3), g + Math.min(25, x / 2), g + x + Math.min(60, x / 2)],
5713
+ ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
5714
5714
  vs: {
5715
- ["viseme_" + d.viseme]: [null, b, 0]
5715
+ ["viseme_" + c.viseme]: [null, b, 0]
5716
5716
  }
5717
5717
  });
5718
5718
  }
5719
- console.log("Deepgram: Generated", h.length, "lip-sync animation frames");
5719
+ console.log("Deepgram: Generated", u.length, "lip-sync animation frames");
5720
5720
  } else
5721
5721
  console.warn("Deepgram: No visemes available for lip-sync animation");
5722
- const a = [...t.anim, ...h];
5723
- 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();
5722
+ const a = [...t.anim, ...u];
5723
+ 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();
5724
5724
  }
5725
5725
  /**
5726
5726
  * Synthesize speech using Azure TTS
@@ -5746,30 +5746,30 @@ class Ne {
5746
5746
  throw new Error(`Azure TTS error: ${s.status} ${s.statusText}`);
5747
5747
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5748
5748
  console.log("Analyzing audio for precise lip-sync...");
5749
- const u = await this.audioAnalyzer.analyzeAudio(l, e);
5749
+ const h = await this.audioAnalyzer.analyzeAudio(l, e);
5750
5750
  console.log("Azure TTS Audio Analysis:", {
5751
5751
  text: e,
5752
5752
  audioDuration: l.duration,
5753
- visemeCount: u.visemes.length,
5754
- wordCount: u.words.length,
5753
+ visemeCount: h.visemes.length,
5754
+ wordCount: h.words.length,
5755
5755
  features: {
5756
- onsets: u.features.onsets.length,
5757
- boundaries: u.features.phonemeBoundaries.length
5756
+ onsets: h.features.onsets.length,
5757
+ boundaries: h.features.phonemeBoundaries.length
5758
5758
  }
5759
5759
  });
5760
5760
  const r = [];
5761
- for (let a = 0; a < u.visemes.length; a++) {
5762
- const c = u.visemes[a], d = c.startTime * 1e3, g = c.duration * 1e3, x = c.intensity;
5761
+ for (let a = 0; a < h.visemes.length; a++) {
5762
+ const d = h.visemes[a], c = d.startTime * 1e3, g = d.duration * 1e3, y = d.intensity;
5763
5763
  r.push({
5764
5764
  template: { name: "viseme" },
5765
- ts: [d - Math.min(60, 2 * g / 3), d + Math.min(25, g / 2), d + g + Math.min(60, g / 2)],
5765
+ ts: [c - Math.min(60, 2 * g / 3), c + Math.min(25, g / 2), c + g + Math.min(60, g / 2)],
5766
5766
  vs: {
5767
- ["viseme_" + c.viseme]: [null, x, 0]
5767
+ ["viseme_" + d.viseme]: [null, y, 0]
5768
5768
  }
5769
5769
  });
5770
5770
  }
5771
- const h = [...t.anim, ...r];
5772
- this.audioPlaylist.push({ anim: h, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5771
+ const u = [...t.anim, ...r];
5772
+ this.audioPlaylist.push({ anim: u, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5773
5773
  }
5774
5774
  /**
5775
5775
  * Synthesize speech using external TTS service (Google Cloud, etc.)
@@ -5808,27 +5808,27 @@ class Ne {
5808
5808
  if (i.status === 200 && s && s.audioContent) {
5809
5809
  const o = this.b64ToArrayBuffer(s.audioContent), l = await this.audioCtx.decodeAudioData(o);
5810
5810
  this.speakWithHands();
5811
- const u = [0];
5811
+ const h = [0];
5812
5812
  let r = 0;
5813
- t.text.forEach((c, d) => {
5814
- if (d > 0) {
5815
- let g = u[u.length - 1];
5816
- s.timepoints[r] && (g = s.timepoints[r].timeSeconds * 1e3, s.timepoints[r].markName === "" + c.mark && r++), u.push(g);
5813
+ t.text.forEach((d, c) => {
5814
+ if (c > 0) {
5815
+ let g = h[h.length - 1];
5816
+ s.timepoints[r] && (g = s.timepoints[r].timeSeconds * 1e3, s.timepoints[r].markName === "" + d.mark && r++), h.push(g);
5817
5817
  }
5818
5818
  });
5819
- const h = [{ mark: 0, time: 0 }];
5820
- u.forEach((c, d) => {
5821
- if (d > 0) {
5822
- let g = c - u[d - 1];
5823
- h[d - 1].duration = g, h.push({ mark: d, time: c });
5819
+ const u = [{ mark: 0, time: 0 }];
5820
+ h.forEach((d, c) => {
5821
+ if (c > 0) {
5822
+ let g = d - h[c - 1];
5823
+ u[c - 1].duration = g, u.push({ mark: c, time: d });
5824
5824
  }
5825
5825
  });
5826
5826
  let a = 1e3 * l.duration;
5827
- a > this.opt.ttsTrimEnd && (a = a - this.opt.ttsTrimEnd), h[h.length - 1].duration = a - h[h.length - 1].time, t.anim.forEach((c) => {
5828
- const d = h[c.mark];
5829
- if (d)
5830
- for (let g = 0; g < c.ts.length; g++)
5831
- c.ts[g] = d.time + c.ts[g] * d.duration + this.opt.ttsTrimStart;
5827
+ a > this.opt.ttsTrimEnd && (a = a - this.opt.ttsTrimEnd), u[u.length - 1].duration = a - u[u.length - 1].time, t.anim.forEach((d) => {
5828
+ const c = u[d.mark];
5829
+ if (c)
5830
+ for (let g = 0; g < d.ts.length; g++)
5831
+ d.ts[g] = c.time + d.ts[g] * c.duration + this.opt.ttsTrimStart;
5832
5832
  }), this.audioPlaylist.push({ anim: t.anim, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5833
5833
  } else
5834
5834
  this.startSpeaking(!0);
@@ -5908,10 +5908,10 @@ class Ne {
5908
5908
  }
5909
5909
  if (!this.workletLoaded)
5910
5910
  try {
5911
- const l = this.audioCtx.audioWorklet.addModule(dt.href), u = new Promise(
5912
- (r, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5911
+ const l = this.audioCtx.audioWorklet.addModule(dt.href), h = new Promise(
5912
+ (r, u) => setTimeout(() => u(new Error("Worklet loading timed out")), 5e3)
5913
5913
  );
5914
- await Promise.race([l, u]), this.workletLoaded = !0;
5914
+ await Promise.race([l, h]), this.workletLoaded = !0;
5915
5915
  } catch (l) {
5916
5916
  throw console.error("Failed to load audio worklet:", l), new Error("Failed to initialize streaming speech");
5917
5917
  }
@@ -5924,8 +5924,8 @@ class Ne {
5924
5924
  if (l.data.type === "playback-started" && (this.isSpeaking = !0, this.stateName = "speaking", this.streamWaitForAudioChunks && (this.streamAudioStartTime = this.animClock), this._processStreamLipsyncQueue(), this.speakWithHands(), this.onAudioStart))
5925
5925
  try {
5926
5926
  this.onAudioStart?.();
5927
- } catch (u) {
5928
- console.error(u);
5927
+ } catch (h) {
5928
+ console.error(h);
5929
5929
  }
5930
5930
  if (l.data.type === "playback-ended" && (this._streamPause(), this.onAudioEnd))
5931
5931
  try {
@@ -5945,9 +5945,9 @@ class Ne {
5945
5945
  } catch {
5946
5946
  }
5947
5947
  if (this.resetLips(), this.lookAtCamera(500), t.mood && this.setMood(t.mood), this.onSubtitles = i || null, this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") {
5948
- const l = this.audioCtx.resume(), u = new Promise((r, h) => setTimeout(() => h("p2"), 1e3));
5948
+ const l = this.audioCtx.resume(), h = new Promise((r, u) => setTimeout(() => u("p2"), 1e3));
5949
5949
  try {
5950
- await Promise.race([l, u]);
5950
+ await Promise.race([l, h]);
5951
5951
  } catch {
5952
5952
  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.");
5953
5953
  return;
@@ -6044,18 +6044,18 @@ class Ne {
6044
6044
  subtitles: [" " + i]
6045
6045
  }
6046
6046
  }), this.streamLipsyncType == "words")) {
6047
- const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, u = this.lipsyncPreProcessText(i, l), r = this.lipsyncWordsToVisemes(u, l);
6047
+ const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, h = this.lipsyncPreProcessText(i, l), r = this.lipsyncWordsToVisemes(h, l);
6048
6048
  if (r && r.visemes && r.visemes.length) {
6049
- 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));
6050
- let c = 0.6 + this.convertRange(a, [0, o], [0, 0.4]);
6051
- if (o = Math.min(o, r.visemes.length * 200), h > 0)
6052
- for (let d = 0; d < r.visemes.length; d++) {
6053
- const g = e + s + r.times[d] / h * o, x = r.durations[d] / h * o;
6049
+ 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));
6050
+ let d = 0.6 + this.convertRange(a, [0, o], [0, 0.4]);
6051
+ if (o = Math.min(o, r.visemes.length * 200), u > 0)
6052
+ for (let c = 0; c < r.visemes.length; c++) {
6053
+ const g = e + s + r.times[c] / u * o, y = r.durations[c] / u * o;
6054
6054
  this.animQueue.push({
6055
6055
  template: { name: "viseme" },
6056
- ts: [g - Math.min(60, 2 * x / 3), g + Math.min(25, x / 2), g + x + Math.min(60, x / 2)],
6056
+ ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
6057
6057
  vs: {
6058
- ["viseme_" + r.visemes[d]]: [null, r.visemes[d] === "PP" || r.visemes[d] === "FF" ? 0.9 : c, 0]
6058
+ ["viseme_" + r.visemes[c]]: [null, r.visemes[c] === "PP" || r.visemes[c] === "FF" ? 0.9 : d, 0]
6059
6059
  }
6060
6060
  });
6061
6061
  }
@@ -6146,7 +6146,7 @@ class Ne {
6146
6146
  */
6147
6147
  lookAtCamera(t) {
6148
6148
  let e;
6149
- 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), Re.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), ve.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(Re, ve).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) {
6149
+ 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), Ie.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ve, Ie).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) {
6150
6150
  if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
6151
6151
  if (this.avatar.avatarIgnoreCamera) {
6152
6152
  this.lookAhead(t);
@@ -6159,22 +6159,22 @@ class Ne {
6159
6159
  this.lookAt(null, null, t);
6160
6160
  return;
6161
6161
  }
6162
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), Re.setFromMatrixPosition(this.objectLeftEye.matrixWorld), ve.setFromMatrixPosition(this.objectRightEye.matrixWorld), Re.add(ve).divideScalar(2), _.copy(this.armature.quaternion), _.multiply(this.poseTarget.props["Hips.quaternion"]), _.multiply(this.poseTarget.props["Spine.quaternion"]), _.multiply(this.poseTarget.props["Spine1.quaternion"]), _.multiply(this.poseTarget.props["Spine2.quaternion"]), _.multiply(this.poseTarget.props["Neck.quaternion"]), _.multiply(this.poseTarget.props["Head.quaternion"]);
6163
- const n = new f.Vector3().subVectors(e, Re).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6164
- V.set(s, i, 0, "YXZ");
6165
- const l = new f.Quaternion().setFromEuler(V), u = new f.Quaternion().copy(l).multiply(_.clone().invert());
6166
- V.setFromQuaternion(u, "YXZ");
6167
- let r = V.x / (40 / 24) + 0.2, h = V.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;
6162
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ve.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Ie.setFromMatrixPosition(this.objectRightEye.matrixWorld), ve.add(Ie).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"]);
6163
+ const n = new x.Vector3().subVectors(e, ve).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6164
+ W.set(s, i, 0, "YXZ");
6165
+ const l = new x.Quaternion().setFromEuler(W), h = new x.Quaternion().copy(l).multiply(Q.clone().invert());
6166
+ W.setFromQuaternion(h, "YXZ");
6167
+ let r = W.x / (40 / 24) + 0.2, u = W.y / (9 / 4), a = Math.min(0.6, Math.max(-0.3, r)), d = Math.min(0.8, Math.max(-0.8, u)), c = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6168
6168
  if (t) {
6169
- let x = this.animQueue.findIndex((I) => I.template.name === "lookat");
6170
- x !== -1 && this.animQueue.splice(x, 1);
6169
+ let y = this.animQueue.findIndex((R) => R.template.name === "lookat");
6170
+ y !== -1 && this.animQueue.splice(y, 1);
6171
6171
  const b = {
6172
6172
  name: "lookat",
6173
6173
  dt: [750, t],
6174
6174
  vs: {
6175
- bodyRotateX: [a + d],
6176
- bodyRotateY: [c + g],
6177
- eyesRotateX: [-3 * d + 0.1],
6175
+ bodyRotateX: [a + c],
6176
+ bodyRotateY: [d + g],
6177
+ eyesRotateX: [-3 * c + 0.1],
6178
6178
  eyesRotateY: [-5 * g],
6179
6179
  browInnerUp: [[0, 0.7]],
6180
6180
  mouthLeft: [[0, 0.7]],
@@ -6196,24 +6196,24 @@ class Ne {
6196
6196
  if (!this.camera) return;
6197
6197
  const i = this.nodeAvatar.getBoundingClientRect();
6198
6198
  this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0);
6199
- 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);
6199
+ 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);
6200
6200
  l.project(this.camera);
6201
- let u = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6202
- t === null && (t = u), e === null && (e = r), _.copy(this.armature.quaternion), _.multiply(this.poseTarget.props["Hips.quaternion"]), _.multiply(this.poseTarget.props["Spine.quaternion"]), _.multiply(this.poseTarget.props["Spine1.quaternion"]), _.multiply(this.poseTarget.props["Spine2.quaternion"]), _.multiply(this.poseTarget.props["Neck.quaternion"]), _.multiply(this.poseTarget.props["Head.quaternion"]), V.setFromQuaternion(_);
6203
- let h = V.x / (40 / 24), a = V.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), x = Math.max(window.innerHeight - r, r), b = this.convertRange(e, [r - x, r + x], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - a + d;
6204
- b = Math.min(0.6, Math.max(-0.3, b)), I = Math.min(0.8, Math.max(-0.8, I));
6205
- let H = (Math.random() - 0.5) / 4, m = (Math.random() - 0.5) / 4;
6201
+ let h = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6202
+ 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);
6203
+ let u = W.x / (40 / 24), a = W.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), c = 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 + d, R = this.convertRange(t, [h - g, h + g], [-0.8, 0.8]) - a + c;
6204
+ b = Math.min(0.6, Math.max(-0.3, b)), R = Math.min(0.8, Math.max(-0.8, R));
6205
+ let V = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6206
6206
  if (n) {
6207
- let T = this.animQueue.findIndex((y) => y.template.name === "lookat");
6208
- T !== -1 && this.animQueue.splice(T, 1);
6209
- const k = {
6207
+ let M = this.animQueue.findIndex((f) => f.template.name === "lookat");
6208
+ M !== -1 && this.animQueue.splice(M, 1);
6209
+ const z = {
6210
6210
  name: "lookat",
6211
6211
  dt: [750, n],
6212
6212
  vs: {
6213
- bodyRotateX: [b + H],
6214
- bodyRotateY: [I + m],
6215
- eyesRotateX: [-3 * H + 0.1],
6216
- eyesRotateY: [-5 * m],
6213
+ bodyRotateX: [b + V],
6214
+ bodyRotateY: [R + p],
6215
+ eyesRotateX: [-3 * V + 0.1],
6216
+ eyesRotateY: [-5 * p],
6217
6217
  browInnerUp: [[0, 0.7]],
6218
6218
  mouthLeft: [[0, 0.7]],
6219
6219
  mouthRight: [[0, 0.7]],
@@ -6221,7 +6221,7 @@ class Ne {
6221
6221
  headMove: [0]
6222
6222
  }
6223
6223
  };
6224
- this.animQueue.push(this.animFactory(k));
6224
+ this.animQueue.push(this.animFactory(z));
6225
6225
  }
6226
6226
  }
6227
6227
  /**
@@ -6232,17 +6232,17 @@ class Ne {
6232
6232
  */
6233
6233
  touchAt(t, e) {
6234
6234
  if (!this.camera) return;
6235
- const n = this.nodeAvatar.getBoundingClientRect(), i = new f.Vector2(
6235
+ const n = this.nodeAvatar.getBoundingClientRect(), i = new x.Vector2(
6236
6236
  (t - n.left) / n.width * 2 - 1,
6237
6237
  -((e - n.top) / n.height) * 2 + 1
6238
- ), s = new f.Raycaster();
6238
+ ), s = new x.Raycaster();
6239
6239
  s.setFromCamera(i, this.camera);
6240
6240
  const o = s.intersectObject(this.armature);
6241
6241
  if (o.length > 0) {
6242
- const l = o[0].point, u = new f.Vector3(), r = new f.Vector3();
6243
- this.objectLeftArm.getWorldPosition(u), this.objectRightArm.getWorldPosition(r);
6244
- const h = u.distanceToSquared(l), a = r.distanceToSquared(l);
6245
- h < a ? (this.ikSolve({
6242
+ const l = o[0].point, h = new x.Vector3(), r = new x.Vector3();
6243
+ this.objectLeftArm.getWorldPosition(h), this.objectRightArm.getWorldPosition(r);
6244
+ const u = h.distanceToSquared(l), a = r.distanceToSquared(l);
6245
+ u < a ? (this.ikSolve({
6246
6246
  iterations: 20,
6247
6247
  root: "LeftShoulder",
6248
6248
  effector: "LeftHandMiddle1",
@@ -6263,8 +6263,8 @@ class Ne {
6263
6263
  }, l, !1, 1e3), this.setValue("handFistRight", 0));
6264
6264
  } else
6265
6265
  ["LeftArm", "LeftForeArm", "LeftHand", "RightArm", "RightForeArm", "RightHand"].forEach((l) => {
6266
- let u = l + ".quaternion";
6267
- this.poseTarget.props[u].copy(this.getPoseTemplateProp(u)), this.poseTarget.props[u].t = this.animClock, this.poseTarget.props[u].d = 1e3;
6266
+ let h = l + ".quaternion";
6267
+ this.poseTarget.props[h].copy(this.getPoseTemplateProp(h)), this.poseTarget.props[h].t = this.animClock, this.poseTarget.props[h].d = 1e3;
6268
6268
  });
6269
6269
  return o.length > 0;
6270
6270
  }
@@ -6283,7 +6283,7 @@ class Ne {
6283
6283
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
6284
6284
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -1, maxz: 3 }
6285
6285
  ]
6286
- }, new f.Vector3(
6286
+ }, new x.Vector3(
6287
6287
  this.gaussianRandom(0, 0.5),
6288
6288
  this.gaussianRandom(-0.8, -0.2),
6289
6289
  this.gaussianRandom(0, 0.5)
@@ -6295,15 +6295,15 @@ class Ne {
6295
6295
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5 },
6296
6296
  { link: "RightArm" }
6297
6297
  ]
6298
- }, new f.Vector3(
6298
+ }, new x.Vector3(
6299
6299
  this.gaussianRandom(-0.5, 0),
6300
6300
  this.gaussianRandom(-0.8, -0.2),
6301
6301
  this.gaussianRandom(0, 0.5)
6302
6302
  ), !0);
6303
6303
  const n = [], i = [];
6304
6304
  n.push(100 + Math.round(Math.random() * 500)), i.push({ duration: 1e3, props: {
6305
- "LeftHand.quaternion": new f.Quaternion().setFromEuler(new f.Euler(0, -1 - Math.random(), 0)),
6306
- "RightHand.quaternion": new f.Quaternion().setFromEuler(new f.Euler(0, 1 + Math.random(), 0))
6305
+ "LeftHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, -1 - Math.random(), 0)),
6306
+ "RightHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, 1 + Math.random(), 0))
6307
6307
  } }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm"].forEach((o) => {
6308
6308
  i[0].props[o + ".quaternion"] = this.ikMesh.getObjectByName(o).quaternion.clone();
6309
6309
  }), n.push(1e3 + Math.round(Math.random() * 500)), i.push({ duration: 2e3, props: {} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm", "LeftHand", "RightHand"].forEach((o) => {
@@ -6380,296 +6380,24 @@ class Ne {
6380
6380
  * @param {number} [ndx=0] Index of the clip
6381
6381
  * @param {number} [scale=0.01] Position scale factor
6382
6382
  */
6383
- /**
6384
- * Get all bone names from the avatar's armature
6385
- * @returns {Set<string>} Set of bone names
6386
- */
6387
- getAvailableBoneNames() {
6388
- const t = /* @__PURE__ */ new Set();
6389
- return this.armature && this.armature.traverse((e) => {
6390
- (e.isBone || e.type === "Bone") && t.add(e.name);
6391
- }), t;
6392
- }
6393
- /**
6394
- * Map bone names from different naming conventions to avatar bone names
6395
- * @param {string} fbxBoneName - Bone name from FBX animation
6396
- * @param {Set<string>} availableBones - Set of available bone names in avatar
6397
- * @returns {string|null} Mapped bone name or null if no match found
6398
- */
6399
- mapBoneName(t, e) {
6400
- if (e.has(t))
6401
- return t;
6402
- let n = t;
6403
- if (n.startsWith("CC_Base_") && (n = n.replace("CC_Base_", "")), n = n.replace(/^mixamorig/i, ""), e.has(n))
6404
- return n;
6405
- if (this._mappingDebugLog || (this._mappingDebugLog = /* @__PURE__ */ new Set()), this._mappingDebugLog.size < 5 && !this._mappingDebugLog.has(t) && (this._mappingDebugLog.add(t), console.debug(`Mapping attempt: "${t}" -> "${n}" (not found in available bones)`)), n.match(/^Spine\d+$/)) {
6406
- const a = n.match(/\d+/)?.[0];
6407
- if (a) {
6408
- const c = `Spine${parseInt(a)}`;
6409
- if (e.has(c))
6410
- return c;
6411
- if (a === "01" && e.has("Spine1"))
6412
- return "Spine1";
6413
- if (parseInt(a) >= 2 && e.has("Spine2"))
6414
- return "Spine2";
6415
- }
6416
- }
6417
- if (n.includes("Twist"))
6418
- return null;
6419
- const i = {
6420
- // Spine mapping
6421
- Spine01: "Spine1",
6422
- Spine02: "Spine2",
6423
- Spine03: "Spine2",
6424
- Spine1: "Spine1",
6425
- Spine2: "Spine2",
6426
- Spine: "Spine1",
6427
- // Head and neck
6428
- Head: "Head",
6429
- Neck: "Neck",
6430
- Neck1: "Neck",
6431
- Neck2: "Neck",
6432
- // Left arm mapping
6433
- L_Upperarm: "LeftArm",
6434
- L_Forearm: "LeftForeArm",
6435
- L_Hand: "LeftHand",
6436
- L_Shoulder: "LeftShoulder",
6437
- L_Clavicle: "LeftShoulder",
6438
- L_UpperArm: "LeftArm",
6439
- L_ForeArm: "LeftForeArm",
6440
- L_Index1: "LeftHandIndex1",
6441
- L_Index2: "LeftHandIndex2",
6442
- L_Index3: "LeftHandIndex3",
6443
- L_Middle1: "LeftHandMiddle1",
6444
- L_Middle2: "LeftHandMiddle2",
6445
- L_Middle3: "LeftHandMiddle3",
6446
- L_Mid1: "LeftHandMiddle1",
6447
- L_Mid2: "LeftHandMiddle2",
6448
- L_Mid3: "LeftHandMiddle3",
6449
- L_Ring1: "LeftHandRing1",
6450
- L_Ring2: "LeftHandRing2",
6451
- L_Ring3: "LeftHandRing3",
6452
- L_Pinky1: "LeftHandPinky1",
6453
- L_Pinky2: "LeftHandPinky2",
6454
- L_Pinky3: "LeftHandPinky3",
6455
- L_Thumb1: "LeftHandThumb1",
6456
- L_Thumb2: "LeftHandThumb2",
6457
- L_Thumb3: "LeftHandThumb3",
6458
- // Right arm mapping
6459
- R_Upperarm: "RightArm",
6460
- R_Forearm: "RightForeArm",
6461
- R_Hand: "RightHand",
6462
- R_Shoulder: "RightShoulder",
6463
- R_Clavicle: "RightShoulder",
6464
- R_UpperArm: "RightArm",
6465
- R_ForeArm: "RightForeArm",
6466
- R_Index1: "RightHandIndex1",
6467
- R_Index2: "RightHandIndex2",
6468
- R_Index3: "RightHandIndex3",
6469
- R_Middle1: "RightHandMiddle1",
6470
- R_Middle2: "RightHandMiddle2",
6471
- R_Middle3: "RightHandMiddle3",
6472
- R_Mid1: "RightHandMiddle1",
6473
- R_Mid2: "RightHandMiddle2",
6474
- R_Mid3: "RightHandMiddle3",
6475
- R_Ring1: "RightHandRing1",
6476
- R_Ring2: "RightHandRing2",
6477
- R_Ring3: "RightHandRing3",
6478
- R_Pinky1: "RightHandPinky1",
6479
- R_Pinky2: "RightHandPinky2",
6480
- R_Pinky3: "RightHandPinky3",
6481
- R_Thumb1: "RightHandThumb1",
6482
- R_Thumb2: "RightHandThumb2",
6483
- R_Thumb3: "RightHandThumb3",
6484
- // Leg mapping
6485
- L_Thigh: "LeftUpLeg",
6486
- L_Calf: "LeftLeg",
6487
- L_Foot: "LeftFoot",
6488
- L_UpLeg: "LeftUpLeg",
6489
- L_Leg: "LeftLeg",
6490
- R_Thigh: "RightUpLeg",
6491
- R_Calf: "RightLeg",
6492
- R_Foot: "RightFoot",
6493
- R_UpLeg: "RightUpLeg",
6494
- R_Leg: "RightLeg",
6495
- // Root/Hips
6496
- Hips: "Hips",
6497
- Root: "Hips",
6498
- Pelvis: "Hips"
6499
- };
6500
- if (i[n]) {
6501
- const a = i[n];
6502
- if (e.has(a))
6503
- return a;
6504
- }
6505
- const s = n.toLowerCase();
6506
- n.charAt(0).toUpperCase() + n.slice(1).toLowerCase();
6507
- const o = s.match(/^[rl]_index(\d+)$/);
6508
- if (o) {
6509
- const a = o[1], d = `${s.startsWith("r") ? "Right" : "Left"}HandIndex${a}`;
6510
- if (e.has(d))
6511
- return d;
6512
- }
6513
- const l = s.match(/^[rl]_pinky(\d+)$/);
6514
- if (l) {
6515
- const a = l[1], d = `${s.startsWith("r") ? "Right" : "Left"}HandPinky${a}`;
6516
- if (e.has(d))
6517
- return d;
6518
- }
6519
- const u = s.match(/^[rl]_ring(\d+)$/);
6520
- if (u) {
6521
- const a = u[1], d = `${s.startsWith("r") ? "Right" : "Left"}HandRing${a}`;
6522
- if (e.has(d))
6523
- return d;
6524
- }
6525
- const r = s.match(/^[rl]_(?:middle|mid)(\d+)$/);
6526
- if (r) {
6527
- const a = r[1], d = `${s.startsWith("r") ? "Right" : "Left"}HandMiddle${a}`;
6528
- if (e.has(d))
6529
- return d;
6530
- }
6531
- const h = s.match(/^[rl]_thumb(\d+)$/);
6532
- if (h) {
6533
- const a = h[1], d = `${s.startsWith("r") ? "Right" : "Left"}HandThumb${a}`;
6534
- if (e.has(d))
6535
- return d;
6536
- }
6537
- if (s.match(/^[rl]_upperarm/)) {
6538
- const c = `${s.startsWith("r") ? "Right" : "Left"}Arm`;
6539
- if (e.has(c))
6540
- return c;
6541
- }
6542
- if (s.includes("upperarmtwist") || s.includes("forearmtwist") || s.includes("ribstwist") || s.includes("breast") || s.includes("twist"))
6543
- return null;
6544
- if (s.match(/^[rl]_forearm/)) {
6545
- const c = `${s.startsWith("r") ? "Right" : "Left"}ForeArm`;
6546
- if (e.has(c))
6547
- return c;
6548
- }
6549
- if (s.match(/^[rl]_hand$/)) {
6550
- const c = `${s.startsWith("r") ? "Right" : "Left"}Hand`;
6551
- if (e.has(c))
6552
- return c;
6553
- }
6554
- if (s.match(/^[rl]_clavicle/)) {
6555
- const c = `${s.startsWith("r") ? "Right" : "Left"}Shoulder`;
6556
- if (e.has(c))
6557
- return c;
6558
- }
6559
- if (s.match(/^[rl]_shoulder/)) {
6560
- const c = `${s.startsWith("r") ? "Right" : "Left"}Shoulder`;
6561
- if (e.has(c))
6562
- return c;
6563
- }
6564
- if (s.match(/^spine0?(\d+)$/)) {
6565
- const a = s.match(/^spine0?(\d+)$/)[1];
6566
- if (a === "1") {
6567
- if (e.has("Spine1")) return "Spine1";
6568
- } else if ((a === "2" || a === "3") && e.has("Spine2"))
6569
- return "Spine2";
6570
- }
6571
- if (s.match(/^neck\d*$/) && e.has("Neck"))
6572
- return "Neck";
6573
- if (s === "head" && e.has("Head"))
6574
- return "Head";
6575
- if (s.match(/^(hips|pelvis|root)$/) && e.has("Hips"))
6576
- return "Hips";
6577
- for (const a of e)
6578
- if (a.toLowerCase() === s)
6579
- return a;
6580
- for (const a of e) {
6581
- const c = a.toLowerCase();
6582
- if ((c.includes(s) || s.includes(c)) && (c === s || c.replace(/[^a-z0-9]/g, "") === s.replace(/[^a-z0-9]/g, "")))
6583
- return a;
6584
- }
6585
- return null;
6586
- }
6587
- /**
6588
- * Filter animation tracks to only include bones that exist in the avatar
6589
- * Maps bone names from different naming conventions to avatar bone names
6590
- * @param {THREE.AnimationClip} clip - Animation clip to filter
6591
- * @param {Set<string>} availableBones - Set of available bone names
6592
- * @returns {THREE.AnimationClip} Filtered animation clip with mapped bone names
6593
- */
6594
- filterAnimationTracks(t, e) {
6595
- const n = [], i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
6596
- this._loggedAvailableBones || (console.log("Available avatar bones:", Array.from(e).sort().join(", ")), this._loggedAvailableBones = !0), t.tracks.forEach((u) => {
6597
- const h = u.name.split(".")[0];
6598
- o.add(h);
6599
- }), console.log(`
6600
- === FBX Animation "${t.name}" Bone Analysis ===`), console.log("FBX bone names in animation:", Array.from(o).sort().join(", ")), console.log(`Total FBX bones: ${o.size}, Avatar bones: ${e.size}
6601
- `), t.tracks.forEach((u) => {
6602
- const r = u.name.split("."), h = r[0], a = r[1], c = this.mapBoneName(h, e);
6603
- if (c) {
6604
- const d = `${c}.${a}`, g = u.clone();
6605
- g.name = d;
6606
- const x = c.includes("Arm") || c.includes("Hand") || c.includes("Shoulder"), b = c.includes("ForeArm");
6607
- if (x && (a === "quaternion" || a === "rotation")) {
6608
- if (a === "quaternion" && g.values && g.values.length >= 4) {
6609
- const I = g.times.length;
6610
- for (let H = 0; H < I; H++) {
6611
- const m = H * 4;
6612
- if (m + 3 < g.values.length) {
6613
- let T = g.values[m], k = g.values[m + 1], y = g.values[m + 2], M = g.values[m + 3];
6614
- if (b || c.includes("Hand")) {
6615
- const P = Math.PI, D = Math.cos(P / 2), J = Math.sin(P / 2), S = D * M - J * T, G = D * T + J * M, Q = D * k - J * y, Z = D * y + J * k;
6616
- T = G, k = Q, y = Z, M = S;
6617
- }
6618
- g.values[m] = T, g.values[m + 1] = k, g.values[m + 2] = y, g.values[m + 3] = M;
6619
- }
6620
- }
6621
- } else if (a === "rotation" && g.values && g.values.length >= 3) {
6622
- const I = g.times.length;
6623
- for (let H = 0; H < I; H++) {
6624
- const m = H * 3;
6625
- m + 2 < g.values.length && (b || c.includes("Hand")) && (g.values[m + 1] += Math.PI);
6626
- }
6627
- }
6628
- }
6629
- n.push(g), h !== c && s.set(h, c);
6630
- } else
6631
- i.add(h);
6632
- }), console.log(`
6633
- === Mapping Results for "${t.name}" ===`), s.size > 0 && (console.info(`✓ Successfully mapped ${s.size} bone(s):`), Array.from(s.entries()).forEach(([u, r]) => {
6634
- console.log(` ${u} → ${r}`);
6635
- })), i.size > 0 && (console.warn(`
6636
- ✗ Could not map ${i.size} bone(s):`), Array.from(i).sort().forEach((u) => {
6637
- console.log(` - ${u}`);
6638
- const r = u.replace(/^(CC_Base_|mixamorig)/i, "").replace(/^[RL]_/, (a) => a.toLowerCase()), h = [];
6639
- for (const a of e) {
6640
- const c = a.toLowerCase(), d = r.toLowerCase();
6641
- (c.includes(d) || d.includes(c)) && h.push(a);
6642
- }
6643
- h.length > 0 && console.log(` → Possible matches: ${h.slice(0, 3).join(", ")}`);
6644
- }));
6645
- const l = /* @__PURE__ */ new Set();
6646
- return o.forEach((u) => {
6647
- e.has(u) && !s.has(u) && l.add(u);
6648
- }), l.size > 0 && (console.info(`
6649
- ✓ Direct matches (no mapping needed): ${l.size} bone(s)`), Array.from(l).sort().slice(0, 10).forEach((u) => {
6650
- console.log(` - ${u}`);
6651
- }), l.size > 10 && console.log(` ... and ${l.size - 10} more`)), console.log(`
6652
- === Summary ===`), console.log(`Total FBX tracks: ${t.tracks.length}`), console.log(`Valid tracks: ${n.length}`), console.log(`Mapped bones: ${s.size}`), console.log(`Direct matches: ${l.size}`), console.log(`Missing bones: ${i.size}`), console.log(`========================================
6653
- `), n.length === 0 && console.error(`No valid tracks found for animation "${t.name}". All bones are missing or couldn't be mapped.`), n.length === 0 ? null : new f.AnimationClip(t.name, t.duration, n);
6654
- }
6655
6383
  async playAnimation(t, e = null, n = 10, i = 0, s = 0.01, o = !1) {
6656
6384
  if (!this.armature) return;
6657
6385
  this.positionWasLocked = !o, o ? console.log("Position locking disabled for FBX animation:", t) : (this.lockAvatarPosition(), console.log("Position locked immediately before FBX animation:", t));
6658
- let l = this.animClips.find((u) => u.url === t + "-" + i);
6386
+ let l = this.animClips.find((h) => h.url === t + "-" + i);
6659
6387
  if (l) {
6660
- let u = this.animQueue.find((a) => a.template.name === "pose");
6661
- u && (u.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((a) => {
6388
+ let h = this.animQueue.find((a) => a.template.name === "pose");
6389
+ h && (h.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((a) => {
6662
6390
  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;
6663
- }), 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 });
6664
- const r = Math.ceil(n / l.clip.duration), h = this.mixer.clipAction(l.clip);
6665
- h.setLoop(f.LoopRepeat, r), h.clampWhenFinished = !0, this.currentFBXAction = h;
6391
+ }), 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 });
6392
+ const r = Math.ceil(n / l.clip.duration), u = this.mixer.clipAction(l.clip);
6393
+ u.setLoop(x.LoopRepeat, r), u.clampWhenFinished = !0, this.currentFBXAction = u;
6666
6394
  try {
6667
- h.fadeIn(0.5).play(), console.log("FBX animation started successfully:", t);
6395
+ u.fadeIn(0.5).play(), console.log("FBX animation started successfully:", t);
6668
6396
  } catch (a) {
6669
6397
  console.warn("FBX animation failed to start:", a), this.stopAnimation();
6670
6398
  return;
6671
6399
  }
6672
- if (h.getClip().tracks.length === 0) {
6400
+ if (u.getClip().tracks.length === 0) {
6673
6401
  console.warn("FBX animation has no valid tracks, stopping"), this.stopAnimation();
6674
6402
  return;
6675
6403
  }
@@ -6680,64 +6408,58 @@ class Ne {
6680
6408
  }
6681
6409
  let r = !1;
6682
6410
  try {
6683
- const c = await fetch(t, { method: "HEAD" });
6684
- if (r = c.ok, !r) {
6685
- console.error(`FBX file not found at ${t}. Status: ${c.status}`), console.error("Please check:"), console.error("1. File path is correct (note: path is case-sensitive)"), console.error("2. File exists in your public folder"), console.error("3. File is accessible (not blocked by server)");
6411
+ const d = await fetch(t, { method: "HEAD" });
6412
+ if (r = d.ok, !r) {
6413
+ console.error(`FBX file not found at ${t}. Status: ${d.status}`), console.error("Please check:"), console.error("1. File path is correct (note: path is case-sensitive)"), console.error("2. File exists in your public folder"), console.error("3. File is accessible (not blocked by server)");
6686
6414
  return;
6687
6415
  }
6688
- } catch (c) {
6689
- console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
6416
+ } catch (d) {
6417
+ console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, d);
6690
6418
  }
6691
- const h = new Be();
6419
+ const u = new Oe();
6692
6420
  let a;
6693
6421
  try {
6694
- a = await h.loadAsync(t, e);
6695
- } catch (c) {
6696
- console.error(`Failed to load FBX animation from ${t}:`, c), console.error("Error details:", {
6697
- message: c.message,
6422
+ a = await u.loadAsync(t, e);
6423
+ } catch (d) {
6424
+ console.error(`Failed to load FBX animation from ${t}:`, d), console.error("Error details:", {
6425
+ message: d.message,
6698
6426
  url: t,
6699
6427
  suggestion: "Make sure the file is a valid FBX file and the path is correct"
6700
- }), c.message && c.message.includes("version number") && (console.error("FBX Loader Error: Cannot find version number"), console.error("This error usually means:"), console.error("1. The file is not a valid FBX file (might be GLB, corrupted, or wrong format)"), console.error("2. The file might be corrupted"), console.error("3. The file path might be incorrect"), console.error("4. The server returned an HTML error page instead of the FBX file"), console.error("5. The file might not exist at that path"), console.error(""), console.error("Solution: Please verify:"), console.error(` - File exists at: ${t}`), console.error(" - File is a valid FBX binary file"), console.error(" - File path matches your public folder structure"), console.error(" - File is not corrupted"));
6428
+ }), d.message && d.message.includes("version number") && (console.error("FBX Loader Error: Cannot find version number"), console.error("This error usually means:"), console.error("1. The file is not a valid FBX file (might be GLB, corrupted, or wrong format)"), console.error("2. The file might be corrupted"), console.error("3. The file path might be incorrect"), console.error("4. The server returned an HTML error page instead of the FBX file"), console.error("5. The file might not exist at that path"), console.error(""), console.error("Solution: Please verify:"), console.error(` - File exists at: ${t}`), console.error(" - File is a valid FBX binary file"), console.error(" - File path matches your public folder structure"), console.error(" - File is not corrupted"));
6701
6429
  try {
6702
- const d = await fetch(t), g = d.headers.get("content-type"), x = await d.text();
6430
+ const c = await fetch(t), g = c.headers.get("content-type"), y = await c.text();
6703
6431
  console.error("Response details:", {
6704
- status: d.status,
6432
+ status: c.status,
6705
6433
  contentType: g,
6706
- firstBytes: x.substring(0, 100),
6707
- isHTML: x.trim().startsWith("<!DOCTYPE") || x.trim().startsWith("<html")
6708
- }), (x.trim().startsWith("<!DOCTYPE") || x.trim().startsWith("<html")) && console.error("The server returned an HTML page instead of an FBX file. The file path is likely incorrect.");
6709
- } catch (d) {
6710
- console.error("Could not fetch file for debugging:", d);
6434
+ firstBytes: y.substring(0, 100),
6435
+ isHTML: y.trim().startsWith("<!DOCTYPE") || y.trim().startsWith("<html")
6436
+ }), (y.trim().startsWith("<!DOCTYPE") || y.trim().startsWith("<html")) && console.error("The server returned an HTML page instead of an FBX file. The file path is likely incorrect.");
6437
+ } catch (c) {
6438
+ console.error("Could not fetch file for debugging:", c);
6711
6439
  }
6712
6440
  return;
6713
6441
  }
6714
6442
  if (a && a.animations && a.animations[i]) {
6715
- let c = a.animations[i];
6716
- const d = this.getAvailableBoneNames(), g = this.filterAnimationTracks(c, d);
6717
- if (!g) {
6718
- console.error(`Cannot play FBX animation "${t}": No compatible bones found.`);
6719
- return;
6720
- }
6721
- c = g;
6722
- const x = {};
6723
- c.tracks.forEach((I) => {
6724
- I.name = I.name.replaceAll("mixamorig", "");
6725
- const H = I.name.split(".");
6726
- if (H[1] === "position") {
6727
- for (let m = 0; m < I.values.length; m++)
6728
- I.values[m] = I.values[m] * s;
6729
- x[I.name] = new f.Vector3(I.values[0], I.values[1], I.values[2]);
6730
- } else H[1] === "quaternion" ? x[I.name] = new f.Quaternion(I.values[0], I.values[1], I.values[2], I.values[3]) : H[1] === "rotation" && (x[H[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(I.values[0], I.values[1], I.values[2], "XYZ")).normalize());
6443
+ let d = a.animations[i];
6444
+ const c = {};
6445
+ d.tracks.forEach((y) => {
6446
+ y.name = y.name.replaceAll("mixamorig", "");
6447
+ const b = y.name.split(".");
6448
+ if (b[1] === "position") {
6449
+ for (let R = 0; R < y.values.length; R++)
6450
+ y.values[R] = y.values[R] * s;
6451
+ c[y.name] = new x.Vector3(y.values[0], y.values[1], y.values[2]);
6452
+ } else b[1] === "quaternion" ? c[y.name] = new x.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : b[1] === "rotation" && (c[b[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6731
6453
  });
6732
- const b = { props: x };
6733
- x["Hips.position"] && (x["Hips.position"].y < 0.5 ? b.lying = !0 : b.standing = !0), this.animClips.push({
6454
+ const g = { props: c };
6455
+ c["Hips.position"] && (c["Hips.position"].y < 0.5 ? g.lying = !0 : g.standing = !0), this.animClips.push({
6734
6456
  url: t + "-" + i,
6735
- clip: c,
6736
- pose: b
6457
+ clip: d,
6458
+ pose: g
6737
6459
  }), this.playAnimation(t, e, n, i, s);
6738
6460
  } else {
6739
- const c = "Animation " + t + " (ndx=" + i + ") not found";
6740
- console.error(c), a && a.animations ? console.error(`FBX file loaded but has ${a.animations.length} animation(s), requested index ${i}`) : console.error(a ? "FBX file loaded but contains no animations" : "FBX file failed to load or is invalid");
6461
+ const d = "Animation " + t + " (ndx=" + i + ") not found";
6462
+ console.error(d), a && a.animations ? console.error(`FBX file loaded but has ${a.animations.length} animation(s), requested index ${i}`) : console.error(a ? "FBX file loaded but contains no animations" : "FBX file failed to load or is invalid");
6741
6463
  }
6742
6464
  }
6743
6465
  }
@@ -6763,25 +6485,25 @@ class Ne {
6763
6485
  if (!this.armature) return;
6764
6486
  let o = this.poseTemplates[t];
6765
6487
  if (!o) {
6766
- const l = this.animPoses.find((u) => u.url === t + "-" + i);
6488
+ const l = this.animPoses.find((h) => h.url === t + "-" + i);
6767
6489
  l && (o = l.pose);
6768
6490
  }
6769
6491
  if (o) {
6770
6492
  this.poseName = t, this.mixer = null;
6771
- let l = this.animQueue.find((u) => u.template.name === "pose");
6493
+ let l = this.animQueue.find((h) => h.template.name === "pose");
6772
6494
  l && (l.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
6773
6495
  } else {
6774
- let u = await new Be().loadAsync(t, e);
6775
- if (u && u.animations && u.animations[i]) {
6776
- let r = u.animations[i];
6777
- const h = {};
6778
- r.tracks.forEach((c) => {
6779
- c.name = c.name.replaceAll("mixamorig", "");
6780
- const d = c.name.split(".");
6781
- 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());
6496
+ let h = await new Oe().loadAsync(t, e);
6497
+ if (h && h.animations && h.animations[i]) {
6498
+ let r = h.animations[i];
6499
+ const u = {};
6500
+ r.tracks.forEach((d) => {
6501
+ d.name = d.name.replaceAll("mixamorig", "");
6502
+ const c = d.name.split(".");
6503
+ c[1] === "position" ? u[d.name] = new x.Vector3(d.values[0] * s, d.values[1] * s, d.values[2] * s) : c[1] === "quaternion" ? u[d.name] = new x.Quaternion(d.values[0], d.values[1], d.values[2], d.values[3]) : c[1] === "rotation" && (u[c[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(d.values[0], d.values[1], d.values[2], "XYZ")).normalize());
6782
6504
  });
6783
- const a = { props: h };
6784
- h["Hips.position"] && (h["Hips.position"].y < 0.5 ? a.lying = !0 : a.standing = !0), this.animPoses.push({
6505
+ const a = { props: u };
6506
+ u["Hips.position"] && (u["Hips.position"].y < 0.5 ? a.lying = !0 : a.standing = !0), this.animPoses.push({
6785
6507
  url: t + "-" + i,
6786
6508
  pose: a
6787
6509
  }), this.playPose(t, e, n, i, s);
@@ -6810,10 +6532,10 @@ class Ne {
6810
6532
  let s = this.gestureTemplates[t];
6811
6533
  if (s) {
6812
6534
  this.gestureTimeout && (clearTimeout(this.gestureTimeout), this.gestureTimeout = null);
6813
- let l = this.animQueue.findIndex((u) => u.template.name === "talkinghands");
6814
- 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));
6815
- for (let [u, r] of Object.entries(this.gesture))
6816
- 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);
6535
+ let l = this.animQueue.findIndex((h) => h.template.name === "talkinghands");
6536
+ 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));
6537
+ for (let [h, r] of Object.entries(this.gesture))
6538
+ 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);
6817
6539
  e && Number.isFinite(e) && (this.gestureTimeout = setTimeout(this.stopGesture.bind(this, i), 1e3 * e));
6818
6540
  }
6819
6541
  let o = this.animEmojis[t];
@@ -6821,15 +6543,15 @@ class Ne {
6821
6543
  this.lookAtCamera(500);
6822
6544
  const l = this.animFactory(o);
6823
6545
  if (l.gesture = !0, e && Number.isFinite(e)) {
6824
- const u = l.ts[0], h = l.ts[l.ts.length - 1] - u;
6825
- if (e * 1e3 - h > 0) {
6826
- const c = [];
6827
- for (let x = 1; x < l.ts.length; x++) c.push(l.ts[x] - l.ts[x - 1]);
6828
- const d = o.template?.rescale || c.map((x) => x / h), g = e * 1e3 - h;
6829
- l.ts = l.ts.map((x, b, I) => b === 0 ? u : I[b - 1] + c[b - 1] + d[b - 1] * g);
6546
+ const h = l.ts[0], u = l.ts[l.ts.length - 1] - h;
6547
+ if (e * 1e3 - u > 0) {
6548
+ const d = [];
6549
+ for (let y = 1; y < l.ts.length; y++) d.push(l.ts[y] - l.ts[y - 1]);
6550
+ const c = o.template?.rescale || d.map((y) => y / u), g = e * 1e3 - u;
6551
+ l.ts = l.ts.map((y, b, R) => b === 0 ? h : R[b - 1] + d[b - 1] + c[b - 1] * g);
6830
6552
  } else {
6831
- const c = e * 1e3 / h;
6832
- l.ts = l.ts.map((d) => u + c * (d - u));
6553
+ const d = e * 1e3 / u;
6554
+ l.ts = l.ts.map((c) => h + d * (c - h));
6833
6555
  }
6834
6556
  }
6835
6557
  this.animQueue.push(l);
@@ -6859,34 +6581,34 @@ class Ne {
6859
6581
  * @param {numeric} [d=null] If set, apply in d milliseconds
6860
6582
  */
6861
6583
  ikSolve(t, e = null, n = !1, i = null) {
6862
- 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);
6863
- 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);
6864
- const g = this.ikMesh.getObjectByName(t.effector), x = t.links;
6865
- x.forEach((I) => {
6866
- I.bone = this.ikMesh.getObjectByName(I.link), I.bone.quaternion.copy(this.getPoseTemplateProp(I.link + ".quaternion"));
6867
- }), d.updateMatrixWorld(!0);
6584
+ 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(), d = new x.Vector3(), c = this.ikMesh.getObjectByName(t.root);
6585
+ c.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), c.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(c.position);
6586
+ const g = this.ikMesh.getObjectByName(t.effector), y = t.links;
6587
+ y.forEach((R) => {
6588
+ R.bone = this.ikMesh.getObjectByName(R.link), R.bone.quaternion.copy(this.getPoseTemplateProp(R.link + ".quaternion"));
6589
+ }), c.updateMatrixWorld(!0);
6868
6590
  const b = t.iterations || 10;
6869
6591
  if (e)
6870
- for (let I = 0; I < b; I++) {
6871
- let H = !1;
6872
- for (let m = 0, T = x.length; m < T; m++) {
6873
- const k = x[m].bone;
6874
- k.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();
6875
- let y = s.dot(l);
6876
- y > 1 ? y = 1 : y < -1 && (y = -1), y = Math.acos(y), !(y < 1e-5) && (x[m].minAngle !== void 0 && y < x[m].minAngle && (y = x[m].minAngle), x[m].maxAngle !== void 0 && y > x[m].maxAngle && (y = x[m].maxAngle), a.crossVectors(l, s), a.normalize(), _.setFromAxisAngle(a, y), k.quaternion.multiply(_), k.rotation.setFromVector3(c.setFromEuler(k.rotation).clamp(new f.Vector3(
6877
- x[m].minx !== void 0 ? x[m].minx : -1 / 0,
6878
- x[m].miny !== void 0 ? x[m].miny : -1 / 0,
6879
- x[m].minz !== void 0 ? x[m].minz : -1 / 0
6880
- ), new f.Vector3(
6881
- x[m].maxx !== void 0 ? x[m].maxx : 1 / 0,
6882
- x[m].maxy !== void 0 ? x[m].maxy : 1 / 0,
6883
- x[m].maxz !== void 0 ? x[m].maxz : 1 / 0
6884
- ))), k.updateMatrixWorld(!0), H = !0);
6592
+ for (let R = 0; R < b; R++) {
6593
+ let V = !1;
6594
+ for (let p = 0, M = y.length; p < M; p++) {
6595
+ const z = y[p].bone;
6596
+ z.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();
6597
+ let f = s.dot(l);
6598
+ 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), z.quaternion.multiply(Q), z.rotation.setFromVector3(d.setFromEuler(z.rotation).clamp(new x.Vector3(
6599
+ y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6600
+ y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6601
+ y[p].minz !== void 0 ? y[p].minz : -1 / 0
6602
+ ), new x.Vector3(
6603
+ y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6604
+ y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6605
+ y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6606
+ ))), z.updateMatrixWorld(!0), V = !0);
6885
6607
  }
6886
- if (!H) break;
6608
+ if (!V) break;
6887
6609
  }
6888
- i && x.forEach((I) => {
6889
- 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;
6610
+ i && y.forEach((R) => {
6611
+ this.poseTarget.props[R.link + ".quaternion"].copy(R.bone.quaternion), this.poseTarget.props[R.link + ".quaternion"].t = this.animClock, this.poseTarget.props[R.link + ".quaternion"].d = i;
6890
6612
  });
6891
6613
  }
6892
6614
  /**
@@ -6896,7 +6618,7 @@ class Ne {
6896
6618
  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();
6897
6619
  }
6898
6620
  }
6899
- const Ie = {
6621
+ const Re = {
6900
6622
  apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
6901
6623
  // Replace with your actual API key (should start with sk_)
6902
6624
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
@@ -6939,23 +6661,23 @@ const Ie = {
6939
6661
  function Fe() {
6940
6662
  return {
6941
6663
  service: "elevenlabs",
6942
- endpoint: Ie.endpoint,
6943
- apiKey: Ie.apiKey,
6944
- defaultVoice: Ie.defaultVoice,
6945
- voices: Ie.voices
6664
+ endpoint: Re.endpoint,
6665
+ apiKey: Re.apiKey,
6666
+ defaultVoice: Re.defaultVoice,
6667
+ voices: Re.voices
6946
6668
  };
6947
6669
  }
6948
6670
  function kt() {
6949
- const X = Fe(), t = [];
6950
- return Object.entries(X.voices).forEach(([e, n]) => {
6671
+ const G = Fe(), t = [];
6672
+ return Object.entries(G.voices).forEach(([e, n]) => {
6951
6673
  t.push({
6952
6674
  value: n,
6953
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${X.service})`
6675
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${G.service})`
6954
6676
  });
6955
6677
  }), t;
6956
6678
  }
6957
6679
  const Ve = Me(({
6958
- avatarUrl: X = "/avatars/brunette.glb",
6680
+ avatarUrl: G = "/avatars/brunette.glb",
6959
6681
  avatarBody: t = "F",
6960
6682
  mood: e = "neutral",
6961
6683
  ttsLang: n = "en",
@@ -6963,141 +6685,141 @@ const Ve = Me(({
6963
6685
  ttsVoice: s = null,
6964
6686
  ttsApiKey: o = null,
6965
6687
  bodyMovement: l = "idle",
6966
- movementIntensity: u = 0.5,
6688
+ movementIntensity: h = 0.5,
6967
6689
  showFullAvatar: r = !0,
6968
- cameraView: h = "upper",
6690
+ cameraView: u = "upper",
6969
6691
  onReady: a = () => {
6970
6692
  },
6971
- onLoading: c = () => {
6693
+ onLoading: d = () => {
6972
6694
  },
6973
- onError: d = () => {
6695
+ onError: c = () => {
6974
6696
  },
6975
6697
  className: g = "",
6976
- style: x = {},
6698
+ style: y = {},
6977
6699
  animations: b = {}
6978
- }, I) => {
6979
- const H = O(null), m = O(null), T = O(r), k = O(null), y = O(null), M = O(!1), P = O({ remainingText: null, originalText: null, options: null }), D = O([]), J = O(0), [S, G] = ce(!0), [Q, Z] = ce(null), [ee, se] = ce(!1), [ae, pe] = ce(!1);
6700
+ }, R) => {
6701
+ const V = D(null), p = D(null), M = D(r), z = 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);
6980
6702
  de(() => {
6981
- M.current = ae;
6703
+ E.current = ae;
6982
6704
  }, [ae]), de(() => {
6983
- T.current = r;
6705
+ M.current = r;
6984
6706
  }, [r]);
6985
- const te = Fe(), le = i || te.service;
6986
- let U;
6987
- le === "browser" ? U = {
6707
+ const ee = Fe(), le = i || ee.service;
6708
+ let O;
6709
+ le === "browser" ? O = {
6988
6710
  service: "browser",
6989
6711
  endpoint: "",
6990
6712
  apiKey: null,
6991
6713
  defaultVoice: "Google US English"
6992
- } : le === "elevenlabs" ? U = {
6714
+ } : le === "elevenlabs" ? O = {
6993
6715
  service: "elevenlabs",
6994
6716
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6995
- apiKey: o || te.apiKey,
6996
- defaultVoice: s || te.defaultVoice || Ie.defaultVoice,
6997
- voices: te.voices || Ie.voices
6998
- } : le === "deepgram" ? U = {
6717
+ apiKey: o || ee.apiKey,
6718
+ defaultVoice: s || ee.defaultVoice || Re.defaultVoice,
6719
+ voices: ee.voices || Re.voices
6720
+ } : le === "deepgram" ? O = {
6999
6721
  service: "deepgram",
7000
6722
  endpoint: "https://api.deepgram.com/v1/speak",
7001
- apiKey: o || te.apiKey,
7002
- defaultVoice: s || te.defaultVoice || Te.defaultVoice,
7003
- voices: te.voices || Te.voices
7004
- } : U = {
7005
- ...te,
6723
+ apiKey: o || ee.apiKey,
6724
+ defaultVoice: s || ee.defaultVoice || Te.defaultVoice,
6725
+ voices: ee.voices || Te.voices
6726
+ } : O = {
6727
+ ...ee,
7006
6728
  // Override API key if provided via props
7007
- apiKey: o !== null ? o : te.apiKey
6729
+ apiKey: o !== null ? o : ee.apiKey
7008
6730
  };
7009
- const R = {
7010
- url: X,
6731
+ const v = {
6732
+ url: G,
7011
6733
  body: t,
7012
6734
  avatarMood: e,
7013
6735
  ttsLang: le === "browser" ? "en-US" : n,
7014
- ttsVoice: s || U.defaultVoice,
6736
+ ttsVoice: s || O.defaultVoice,
7015
6737
  lipsyncLang: "en",
7016
6738
  showFullAvatar: r,
7017
6739
  bodyMovement: l,
7018
- movementIntensity: u
7019
- }, v = {
7020
- ttsEndpoint: U.endpoint,
7021
- ttsApikey: U.apiKey,
6740
+ movementIntensity: h
6741
+ }, I = {
6742
+ ttsEndpoint: O.endpoint,
6743
+ ttsApikey: O.apiKey,
7022
6744
  ttsService: le,
7023
6745
  lipsyncModules: ["en"],
7024
- cameraView: h
7025
- }, w = F(async () => {
7026
- if (!(!H.current || m.current))
6746
+ cameraView: u
6747
+ }, k = T(async () => {
6748
+ if (!(!V.current || p.current))
7027
6749
  try {
7028
- if (G(!0), Z(null), m.current = new Ne(H.current, v), m.current.controls && (m.current.controls.enableRotate = !1, m.current.controls.enableZoom = !1, m.current.controls.enablePan = !1, m.current.controls.enableDamping = !1), b && Object.keys(b).length > 0 && (m.current.customAnimations = b), await m.current.showAvatar(R, (B) => {
6750
+ if (Z(!0), X(null), p.current = new Be(V.current, I), 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) => {
7029
6751
  if (B.lengthComputable) {
7030
- const $ = Math.min(100, Math.round(B.loaded / B.total * 100));
7031
- c($);
6752
+ const J = Math.min(100, Math.round(B.loaded / B.total * 100));
6753
+ d(J);
7032
6754
  }
7033
6755
  }), await new Promise((B) => {
7034
- const $ = () => {
7035
- m.current.lipsync && Object.keys(m.current.lipsync).length > 0 ? B() : setTimeout($, 100);
6756
+ const J = () => {
6757
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? B() : setTimeout(J, 100);
7036
6758
  };
7037
- $();
7038
- }), m.current && m.current.setShowFullAvatar)
6759
+ J();
6760
+ }), p.current && p.current.setShowFullAvatar)
7039
6761
  try {
7040
- m.current.setShowFullAvatar(r);
6762
+ p.current.setShowFullAvatar(r);
7041
6763
  } catch (B) {
7042
6764
  console.warn("Error setting full body mode on initialization:", B);
7043
6765
  }
7044
- m.current && m.current.controls && (m.current.controls.enableRotate = !1, m.current.controls.enableZoom = !1, m.current.controls.enablePan = !1, m.current.controls.enableDamping = !1, m.current.controls.update()), G(!1), se(!0), a(m.current);
7045
- const N = () => {
7046
- document.visibilityState === "visible" ? m.current?.start() : m.current?.stop();
6766
+ 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);
6767
+ const F = () => {
6768
+ document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
7047
6769
  };
7048
- return document.addEventListener("visibilitychange", N), () => {
7049
- document.removeEventListener("visibilitychange", N);
6770
+ return document.addEventListener("visibilitychange", F), () => {
6771
+ document.removeEventListener("visibilitychange", F);
7050
6772
  };
7051
6773
  } catch (L) {
7052
- console.error("Error initializing TalkingHead:", L), Z(L.message || "Failed to initialize avatar"), G(!1), d(L);
6774
+ console.error("Error initializing TalkingHead:", L), X(L.message || "Failed to initialize avatar"), Z(!1), c(L);
7053
6775
  }
7054
- }, [X, t, e, n, i, s, o, r, l, u, h]);
7055
- de(() => (w(), () => {
7056
- m.current && (m.current.stop(), m.current.dispose(), m.current = null);
7057
- }), [w]), de(() => {
7058
- if (!H.current || !m.current) return;
6776
+ }, [G, t, e, n, i, s, o, r, l, h, u]);
6777
+ de(() => (k(), () => {
6778
+ p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6779
+ }), [k]), de(() => {
6780
+ if (!V.current || !p.current) return;
7059
6781
  const L = new ResizeObserver((B) => {
7060
- for (const $ of B)
7061
- m.current && m.current.onResize && m.current.onResize();
6782
+ for (const J of B)
6783
+ p.current && p.current.onResize && p.current.onResize();
7062
6784
  });
7063
- L.observe(H.current);
7064
- const N = () => {
7065
- m.current && m.current.onResize && m.current.onResize();
6785
+ L.observe(V.current);
6786
+ const F = () => {
6787
+ p.current && p.current.onResize && p.current.onResize();
7066
6788
  };
7067
- return window.addEventListener("resize", N), () => {
7068
- L.disconnect(), window.removeEventListener("resize", N);
6789
+ return window.addEventListener("resize", F), () => {
6790
+ L.disconnect(), window.removeEventListener("resize", F);
7069
6791
  };
7070
- }, [ee]);
7071
- const E = F(async () => {
7072
- if (m.current && m.current.audioCtx)
6792
+ }, [$]);
6793
+ const H = T(async () => {
6794
+ if (p.current && p.current.audioCtx)
7073
6795
  try {
7074
- (m.current.audioCtx.state === "suspended" || m.current.audioCtx.state === "interrupted") && (await m.current.audioCtx.resume(), console.log("Audio context resumed"));
6796
+ (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
7075
6797
  } catch (L) {
7076
6798
  console.warn("Failed to resume audio context:", L);
7077
6799
  }
7078
- }, []), W = F(async (L, N = {}) => {
7079
- if (m.current && ee)
6800
+ }, []), N = T(async (L, F = {}) => {
6801
+ if (p.current && $)
7080
6802
  try {
7081
- y.current && (clearInterval(y.current), y.current = null), k.current = { text: L, options: N }, P.current = { remainingText: null, originalText: null, options: null };
7082
- const B = /[!\.\?\n\p{Extended_Pictographic}]/ug, $ = L.split(B).map((Y) => Y.trim()).filter((Y) => Y.length > 0);
7083
- D.current = $, J.current = 0, pe(!1), M.current = !1, await E();
6803
+ f.current && (clearInterval(f.current), f.current = null), z.current = { text: L, options: F }, P.current = { remainingText: null, originalText: null, options: null };
6804
+ const B = /[!\.\?\n\p{Extended_Pictographic}]/ug, J = L.split(B).map((Y) => Y.trim()).filter((Y) => Y.length > 0);
6805
+ U.current = J, oe.current = 0, pe(!1), E.current = !1, await H();
7084
6806
  const ge = {
7085
- ...N,
7086
- lipsyncLang: N.lipsyncLang || R.lipsyncLang || "en"
6807
+ ...F,
6808
+ lipsyncLang: F.lipsyncLang || v.lipsyncLang || "en"
7087
6809
  };
7088
- if (N.onSpeechEnd && m.current) {
7089
- const Y = m.current;
7090
- let ue = null, Se = 0;
6810
+ if (F.onSpeechEnd && p.current) {
6811
+ const Y = p.current;
6812
+ let he = null, Se = 0;
7091
6813
  const Ae = 1200;
7092
6814
  let be = !1;
7093
- ue = setInterval(() => {
7094
- if (Se++, M.current)
6815
+ he = setInterval(() => {
6816
+ if (Se++, E.current)
7095
6817
  return;
7096
6818
  if (Se > Ae) {
7097
- if (ue && (clearInterval(ue), ue = null, y.current = null), !be && !M.current) {
6819
+ if (he && (clearInterval(he), he = null, f.current = null), !be && !E.current) {
7098
6820
  be = !0;
7099
6821
  try {
7100
- N.onSpeechEnd();
6822
+ F.onSpeechEnd();
7101
6823
  } catch (De) {
7102
6824
  console.error("Error in onSpeechEnd callback (timeout):", De);
7103
6825
  }
@@ -7105,179 +6827,179 @@ const Ve = Me(({
7105
6827
  return;
7106
6828
  }
7107
6829
  const ye = !Y.speechQueue || Y.speechQueue.length === 0, ke = !Y.audioPlaylist || Y.audioPlaylist.length === 0;
7108
- Y && Y.isSpeaking === !1 && ye && ke && Y.isAudioPlaying === !1 && !be && !M.current && setTimeout(() => {
7109
- if (Y && !M.current && Y.isSpeaking === !1 && (!Y.speechQueue || Y.speechQueue.length === 0) && (!Y.audioPlaylist || Y.audioPlaylist.length === 0) && Y.isAudioPlaying === !1 && !be && !M.current) {
7110
- be = !0, ue && (clearInterval(ue), ue = null, y.current = null);
6830
+ Y && Y.isSpeaking === !1 && ye && ke && Y.isAudioPlaying === !1 && !be && !E.current && setTimeout(() => {
6831
+ 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) {
6832
+ be = !0, he && (clearInterval(he), he = null, f.current = null);
7111
6833
  try {
7112
- N.onSpeechEnd();
6834
+ F.onSpeechEnd();
7113
6835
  } catch (Ze) {
7114
6836
  console.error("Error in onSpeechEnd callback:", Ze);
7115
6837
  }
7116
6838
  }
7117
6839
  }, 100);
7118
- }, 100), y.current = ue;
6840
+ }, 100), f.current = he;
7119
6841
  }
7120
- m.current.lipsync && Object.keys(m.current.lipsync).length > 0 ? (m.current.setSlowdownRate && m.current.setSlowdownRate(1.05), m.current.speakText(L, ge)) : setTimeout(async () => {
7121
- await E(), m.current && m.current.lipsync && (m.current.setSlowdownRate && m.current.setSlowdownRate(1.05), m.current.speakText(L, ge));
6842
+ 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 () => {
6843
+ await H(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ge));
7122
6844
  }, 100);
7123
6845
  } catch (B) {
7124
- console.error("Error speaking text:", B), Z(B.message || "Failed to speak text");
6846
+ console.error("Error speaking text:", B), X(B.message || "Failed to speak text");
7125
6847
  }
7126
- }, [ee, E, R.lipsyncLang]), K = F(() => {
7127
- m.current && (m.current.stopSpeaking(), m.current.setSlowdownRate && m.current.setSlowdownRate(1), k.current = null, pe(!1));
7128
- }, []), j = F(() => {
7129
- if (m.current && m.current.pauseSpeaking) {
7130
- const L = m.current;
6848
+ }, [$, H, v.lipsyncLang]), _ = T(() => {
6849
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, pe(!1));
6850
+ }, []), j = T(() => {
6851
+ if (p.current && p.current.pauseSpeaking) {
6852
+ const L = p.current;
7131
6853
  if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
7132
- y.current && (clearInterval(y.current), y.current = null);
6854
+ f.current && (clearInterval(f.current), f.current = null);
7133
6855
  let B = "";
7134
- if (k.current && D.current.length > 0) {
7135
- const $ = D.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, ue = ge + (Y ? 1 : 0), Se = $ - ue;
7136
- if (ue > 0 && Se < $ && (B = D.current.slice(Se).join(". ").trim(), !B && ge > 0 && L.speechQueue)) {
6856
+ if (z.current && U.current.length > 0) {
6857
+ 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;
6858
+ if (he > 0 && Se < J && (B = U.current.slice(Se).join(". ").trim(), !B && ge > 0 && L.speechQueue)) {
7137
6859
  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(" ");
7138
6860
  be && be.trim() && (B = be.trim());
7139
6861
  }
7140
6862
  }
7141
- k.current && (P.current = {
6863
+ z.current && (P.current = {
7142
6864
  remainingText: B || null,
7143
- originalText: k.current.text,
7144
- options: k.current.options
7145
- }), L.speechQueue && (L.speechQueue.length = 0), m.current.pauseSpeaking(), M.current = !0, pe(!0);
6865
+ originalText: z.current.text,
6866
+ options: z.current.options
6867
+ }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), E.current = !0, pe(!0);
7146
6868
  }
7147
6869
  }
7148
- }, []), q = F(async () => {
7149
- if (!m.current || !ae)
6870
+ }, []), q = T(async () => {
6871
+ if (!p.current || !ae)
7150
6872
  return;
7151
- let L = "", N = {};
6873
+ let L = "", F = {};
7152
6874
  if (P.current && P.current.remainingText)
7153
- L = P.current.remainingText, N = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
7154
- else if (k.current && k.current.text)
7155
- L = k.current.text, N = k.current.options || {};
6875
+ L = P.current.remainingText, F = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
6876
+ else if (z.current && z.current.text)
6877
+ L = z.current.text, F = z.current.options || {};
7156
6878
  else {
7157
- console.warn("Resume called but no paused speech found"), pe(!1), M.current = !1;
6879
+ console.warn("Resume called but no paused speech found"), pe(!1), E.current = !1;
7158
6880
  return;
7159
6881
  }
7160
- pe(!1), M.current = !1, await E();
6882
+ pe(!1), E.current = !1, await H();
7161
6883
  const B = {
7162
- ...N,
7163
- lipsyncLang: N.lipsyncLang || R.lipsyncLang || "en"
6884
+ ...F,
6885
+ lipsyncLang: F.lipsyncLang || v.lipsyncLang || "en"
7164
6886
  };
7165
6887
  try {
7166
- await W(L, B);
7167
- } catch ($) {
7168
- console.error("Error resuming speech:", $), pe(!1), M.current = !1;
6888
+ await N(L, B);
6889
+ } catch (J) {
6890
+ console.error("Error resuming speech:", J), pe(!1), E.current = !1;
7169
6891
  }
7170
- }, [E, ae, W, R]), Le = F((L) => {
7171
- m.current && m.current.setMood(L);
7172
- }, []), we = F((L) => {
7173
- m.current && m.current.setSlowdownRate && m.current.setSlowdownRate(L);
7174
- }, []), C = F((L, N = !1) => {
7175
- if (m.current && m.current.playAnimation) {
7176
- if (b && b[L] && (L = b[L]), m.current.setShowFullAvatar)
6892
+ }, [H, ae, N, v]), Le = T((L) => {
6893
+ p.current && p.current.setMood(L);
6894
+ }, []), we = T((L) => {
6895
+ p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6896
+ }, []), C = T((L, F = !1) => {
6897
+ if (p.current && p.current.playAnimation) {
6898
+ if (b && b[L] && (L = b[L]), p.current.setShowFullAvatar)
7177
6899
  try {
7178
- m.current.setShowFullAvatar(T.current);
7179
- } catch ($) {
7180
- console.warn("Error setting full body mode:", $);
6900
+ p.current.setShowFullAvatar(M.current);
6901
+ } catch (J) {
6902
+ console.warn("Error setting full body mode:", J);
7181
6903
  }
7182
6904
  if (L.includes("."))
7183
6905
  try {
7184
- m.current.playAnimation(L, null, 10, 0, 0.01, N);
7185
- } catch ($) {
7186
- console.warn(`Failed to play ${L}:`, $);
6906
+ p.current.playAnimation(L, null, 10, 0, 0.01, F);
6907
+ } catch (J) {
6908
+ console.warn(`Failed to play ${L}:`, J);
7187
6909
  try {
7188
- m.current.setBodyMovement("idle");
6910
+ p.current.setBodyMovement("idle");
7189
6911
  } catch (ge) {
7190
6912
  console.warn("Fallback animation also failed:", ge);
7191
6913
  }
7192
6914
  }
7193
6915
  else {
7194
- const $ = [".fbx", ".glb", ".gltf"];
6916
+ const J = [".fbx", ".glb", ".gltf"];
7195
6917
  let ge = !1;
7196
- for (const Y of $)
6918
+ for (const Y of J)
7197
6919
  try {
7198
- m.current.playAnimation(L + Y, null, 10, 0, 0.01, N), ge = !0;
6920
+ p.current.playAnimation(L + Y, null, 10, 0, 0.01, F), ge = !0;
7199
6921
  break;
7200
6922
  } catch {
7201
6923
  }
7202
6924
  if (!ge) {
7203
6925
  console.warn("Animation not found:", L);
7204
6926
  try {
7205
- m.current.setBodyMovement("idle");
6927
+ p.current.setBodyMovement("idle");
7206
6928
  } catch (Y) {
7207
6929
  console.warn("Fallback animation also failed:", Y);
7208
6930
  }
7209
6931
  }
7210
6932
  }
7211
6933
  }
7212
- }, [b]), ne = F(() => {
7213
- m.current && m.current.onResize && m.current.onResize();
6934
+ }, [b]), te = T(() => {
6935
+ p.current && p.current.onResize && p.current.onResize();
7214
6936
  }, []);
7215
- return Ee(I, () => ({
7216
- speakText: W,
7217
- stopSpeaking: K,
6937
+ return Ee(R, () => ({
6938
+ speakText: N,
6939
+ stopSpeaking: _,
7218
6940
  pauseSpeaking: j,
7219
6941
  resumeSpeaking: q,
7220
- resumeAudioContext: E,
6942
+ resumeAudioContext: H,
7221
6943
  setMood: Le,
7222
6944
  setTimingAdjustment: we,
7223
6945
  playAnimation: C,
7224
- isReady: ee,
6946
+ isReady: $,
7225
6947
  isPaused: ae,
7226
- talkingHead: m.current,
7227
- handleResize: ne,
6948
+ talkingHead: p.current,
6949
+ handleResize: te,
7228
6950
  setBodyMovement: (L) => {
7229
- if (m.current && m.current.setShowFullAvatar && m.current.setBodyMovement)
6951
+ if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
7230
6952
  try {
7231
- m.current.setShowFullAvatar(T.current), m.current.setBodyMovement(L);
7232
- } catch (N) {
7233
- console.warn("Error setting body movement:", N);
6953
+ p.current.setShowFullAvatar(M.current), p.current.setBodyMovement(L);
6954
+ } catch (F) {
6955
+ console.warn("Error setting body movement:", F);
7234
6956
  }
7235
6957
  },
7236
- setMovementIntensity: (L) => m.current?.setMovementIntensity(L),
6958
+ setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
7237
6959
  playRandomDance: () => {
7238
- if (m.current && m.current.setShowFullAvatar && m.current.playRandomDance)
6960
+ if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
7239
6961
  try {
7240
- m.current.setShowFullAvatar(T.current), m.current.playRandomDance();
6962
+ p.current.setShowFullAvatar(M.current), p.current.playRandomDance();
7241
6963
  } catch (L) {
7242
6964
  console.warn("Error playing random dance:", L);
7243
6965
  }
7244
6966
  },
7245
6967
  playReaction: (L) => {
7246
- if (m.current && m.current.setShowFullAvatar && m.current.playReaction)
6968
+ if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
7247
6969
  try {
7248
- m.current.setShowFullAvatar(T.current), m.current.playReaction(L);
7249
- } catch (N) {
7250
- console.warn("Error playing reaction:", N);
6970
+ p.current.setShowFullAvatar(M.current), p.current.playReaction(L);
6971
+ } catch (F) {
6972
+ console.warn("Error playing reaction:", F);
7251
6973
  }
7252
6974
  },
7253
6975
  playCelebration: () => {
7254
- if (m.current && m.current.setShowFullAvatar && m.current.playCelebration)
6976
+ if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
7255
6977
  try {
7256
- m.current.setShowFullAvatar(T.current), m.current.playCelebration();
6978
+ p.current.setShowFullAvatar(M.current), p.current.playCelebration();
7257
6979
  } catch (L) {
7258
6980
  console.warn("Error playing celebration:", L);
7259
6981
  }
7260
6982
  },
7261
6983
  setShowFullAvatar: (L) => {
7262
- if (m.current && m.current.setShowFullAvatar)
6984
+ if (p.current && p.current.setShowFullAvatar)
7263
6985
  try {
7264
- T.current = L, m.current.setShowFullAvatar(L);
7265
- } catch (N) {
7266
- console.warn("Error setting showFullAvatar:", N);
6986
+ M.current = L, p.current.setShowFullAvatar(L);
6987
+ } catch (F) {
6988
+ console.warn("Error setting showFullAvatar:", F);
7267
6989
  }
7268
6990
  },
7269
6991
  lockAvatarPosition: () => {
7270
- if (m.current && m.current.lockAvatarPosition)
6992
+ if (p.current && p.current.lockAvatarPosition)
7271
6993
  try {
7272
- m.current.lockAvatarPosition();
6994
+ p.current.lockAvatarPosition();
7273
6995
  } catch (L) {
7274
6996
  console.warn("Error locking avatar position:", L);
7275
6997
  }
7276
6998
  },
7277
6999
  unlockAvatarPosition: () => {
7278
- if (m.current && m.current.unlockAvatarPosition)
7000
+ if (p.current && p.current.unlockAvatarPosition)
7279
7001
  try {
7280
- m.current.unlockAvatarPosition();
7002
+ p.current.unlockAvatarPosition();
7281
7003
  } catch (L) {
7282
7004
  console.warn("Error unlocking avatar position:", L);
7283
7005
  }
@@ -7290,13 +7012,13 @@ const Ve = Me(({
7290
7012
  width: "100%",
7291
7013
  height: "100%",
7292
7014
  position: "relative",
7293
- ...x
7015
+ ...y
7294
7016
  },
7295
7017
  children: [
7296
7018
  /* @__PURE__ */ me(
7297
7019
  "div",
7298
7020
  {
7299
- ref: H,
7021
+ ref: V,
7300
7022
  className: "talking-head-viewer",
7301
7023
  style: {
7302
7024
  width: "100%",
@@ -7314,7 +7036,7 @@ const Ve = Me(({
7314
7036
  fontSize: "18px",
7315
7037
  zIndex: 10
7316
7038
  }, children: "Loading avatar..." }),
7317
- Q && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7039
+ K && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7318
7040
  position: "absolute",
7319
7041
  top: "50%",
7320
7042
  left: "50%",
@@ -7325,14 +7047,14 @@ const Ve = Me(({
7325
7047
  zIndex: 10,
7326
7048
  padding: "20px",
7327
7049
  borderRadius: "8px"
7328
- }, children: Q })
7050
+ }, children: K })
7329
7051
  ]
7330
7052
  }
7331
7053
  );
7332
7054
  });
7333
7055
  Ve.displayName = "TalkingHeadAvatar";
7334
7056
  const pt = Me(({
7335
- text: X = "Hello! I'm a talking avatar. How are you today?",
7057
+ text: G = "Hello! I'm a talking avatar. How are you today?",
7336
7058
  onLoading: t = () => {
7337
7059
  },
7338
7060
  onError: e = () => {
@@ -7343,7 +7065,7 @@ const pt = Me(({
7343
7065
  style: s = {},
7344
7066
  avatarConfig: o = {}
7345
7067
  }, l) => {
7346
- const u = O(null), r = O(null), [h, a] = ce(!0), [c, d] = ce(null), [g, x] = ce(!1), b = Fe(), I = o.ttsService || b.service, H = I === "browser" ? {
7068
+ const h = D(null), r = D(null), [u, a] = ce(!0), [d, c] = ce(null), [g, y] = ce(!1), b = Fe(), R = o.ttsService || b.service, V = R === "browser" ? {
7347
7069
  endpoint: "",
7348
7070
  apiKey: null,
7349
7071
  defaultVoice: "Google US English"
@@ -7352,14 +7074,14 @@ const pt = Me(({
7352
7074
  // Override API key if provided via avatarConfig
7353
7075
  apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : b.apiKey,
7354
7076
  // Override endpoint for ElevenLabs if service is explicitly set
7355
- endpoint: I === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : b.endpoint
7356
- }, m = {
7077
+ endpoint: R === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : b.endpoint
7078
+ }, p = {
7357
7079
  url: "/avatars/brunette.glb",
7358
7080
  // Use brunette avatar (working glTF file)
7359
7081
  body: "F",
7360
7082
  avatarMood: "neutral",
7361
- ttsLang: I === "browser" ? "en-US" : "en",
7362
- ttsVoice: o.ttsVoice || H.defaultVoice,
7083
+ ttsLang: R === "browser" ? "en-US" : "en",
7084
+ ttsVoice: o.ttsVoice || V.defaultVoice,
7363
7085
  lipsyncLang: "en",
7364
7086
  // English lip-sync
7365
7087
  showFullAvatar: !0,
@@ -7367,98 +7089,98 @@ const pt = Me(({
7367
7089
  bodyMovement: "idle",
7368
7090
  movementIntensity: 0.5,
7369
7091
  ...o
7370
- }, T = {
7371
- ttsEndpoint: H.endpoint,
7372
- ttsApikey: H.apiKey,
7373
- ttsService: I,
7092
+ }, M = {
7093
+ ttsEndpoint: V.endpoint,
7094
+ ttsApikey: V.apiKey,
7095
+ ttsService: R,
7374
7096
  lipsyncModules: ["en"],
7375
7097
  cameraView: "upper"
7376
- }, k = F(async () => {
7377
- if (!(!u.current || r.current))
7098
+ }, z = T(async () => {
7099
+ if (!(!h.current || r.current))
7378
7100
  try {
7379
- if (a(!0), d(null), r.current = new Ne(u.current, T), await r.current.showAvatar(m, (Q) => {
7380
- if (Q.lengthComputable) {
7381
- const Z = Math.min(100, Math.round(Q.loaded / Q.total * 100));
7382
- t(Z);
7101
+ if (a(!0), c(null), r.current = new Be(h.current, M), await r.current.showAvatar(p, (K) => {
7102
+ if (K.lengthComputable) {
7103
+ const X = Math.min(100, Math.round(K.loaded / K.total * 100));
7104
+ t(X);
7383
7105
  }
7384
7106
  }), r.current.morphs && r.current.morphs.length > 0) {
7385
- const Q = r.current.morphs[0].morphTargetDictionary;
7386
- console.log("Available morph targets:", Object.keys(Q));
7387
- const Z = Object.keys(Q).filter((ee) => ee.startsWith("viseme_"));
7388
- 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"));
7107
+ const K = r.current.morphs[0].morphTargetDictionary;
7108
+ console.log("Available morph targets:", Object.keys(K));
7109
+ const X = Object.keys(K).filter(($) => $.startsWith("viseme_"));
7110
+ 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"));
7389
7111
  }
7390
- if (await new Promise((Q) => {
7391
- const Z = () => {
7392
- r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), Q()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
7112
+ if (await new Promise((K) => {
7113
+ const X = () => {
7114
+ 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));
7393
7115
  };
7394
- Z();
7116
+ X();
7395
7117
  }), r.current && r.current.setShowFullAvatar)
7396
7118
  try {
7397
7119
  r.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7398
- } catch (Q) {
7399
- console.warn("Error setting full body mode on initialization:", Q);
7120
+ } catch (K) {
7121
+ console.warn("Error setting full body mode on initialization:", K);
7400
7122
  }
7401
- a(!1), x(!0), n(r.current);
7402
- const G = () => {
7123
+ a(!1), y(!0), n(r.current);
7124
+ const Z = () => {
7403
7125
  document.visibilityState === "visible" ? r.current?.start() : r.current?.stop();
7404
7126
  };
7405
- return document.addEventListener("visibilitychange", G), () => {
7406
- document.removeEventListener("visibilitychange", G);
7127
+ return document.addEventListener("visibilitychange", Z), () => {
7128
+ document.removeEventListener("visibilitychange", Z);
7407
7129
  };
7408
7130
  } catch (S) {
7409
- console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), a(!1), e(S);
7131
+ console.error("Error initializing TalkingHead:", S), c(S.message || "Failed to initialize avatar"), a(!1), e(S);
7410
7132
  }
7411
7133
  }, []);
7412
- de(() => (k(), () => {
7134
+ de(() => (z(), () => {
7413
7135
  r.current && (r.current.stop(), r.current.dispose(), r.current = null);
7414
- }), [k]);
7415
- const y = F((S) => {
7136
+ }), [z]);
7137
+ const f = T((S) => {
7416
7138
  if (r.current && g)
7417
7139
  try {
7418
- console.log("Speaking text:", S), console.log("Avatar config:", m), 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(() => {
7140
+ 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(() => {
7419
7141
  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");
7420
7142
  }, 500));
7421
- } catch (G) {
7422
- console.error("Error speaking text:", G), d(G.message || "Failed to speak text");
7143
+ } catch (Z) {
7144
+ console.error("Error speaking text:", Z), c(Z.message || "Failed to speak text");
7423
7145
  }
7424
7146
  else
7425
7147
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!r.current);
7426
- }, [g, m]), M = F(() => {
7148
+ }, [g, p]), E = T(() => {
7427
7149
  r.current && (r.current.stopSpeaking(), r.current.setSlowdownRate && (r.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7428
- }, []), P = F((S) => {
7150
+ }, []), P = T((S) => {
7429
7151
  r.current && r.current.setMood(S);
7430
- }, []), D = F((S) => {
7152
+ }, []), U = T((S) => {
7431
7153
  r.current && r.current.setSlowdownRate && (r.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7432
- }, []), J = F((S, G = !1) => {
7154
+ }, []), oe = T((S, Z = !1) => {
7433
7155
  if (r.current && r.current.playAnimation) {
7434
7156
  if (r.current.setShowFullAvatar)
7435
7157
  try {
7436
7158
  r.current.setShowFullAvatar(!0);
7437
- } catch (Z) {
7438
- console.warn("Error setting full body mode:", Z);
7159
+ } catch (X) {
7160
+ console.warn("Error setting full body mode:", X);
7439
7161
  }
7440
7162
  if (S.includes("."))
7441
7163
  try {
7442
- r.current.playAnimation(S, null, 10, 0, 0.01, G), console.log("Playing animation:", S);
7443
- } catch (Z) {
7444
- console.log(`Failed to play ${S}:`, Z);
7164
+ r.current.playAnimation(S, null, 10, 0, 0.01, Z), console.log("Playing animation:", S);
7165
+ } catch (X) {
7166
+ console.log(`Failed to play ${S}:`, X);
7445
7167
  try {
7446
7168
  r.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7447
- } catch (ee) {
7448
- console.warn("Fallback animation also failed:", ee);
7169
+ } catch ($) {
7170
+ console.warn("Fallback animation also failed:", $);
7449
7171
  }
7450
7172
  }
7451
7173
  else {
7452
- const Z = [".fbx", ".glb", ".gltf"];
7453
- let ee = !1;
7454
- for (const se of Z)
7174
+ const X = [".fbx", ".glb", ".gltf"];
7175
+ let $ = !1;
7176
+ for (const se of X)
7455
7177
  try {
7456
- r.current.playAnimation(S + se, null, 10, 0, 0.01, G), console.log("Playing animation:", S + se), ee = !0;
7178
+ r.current.playAnimation(S + se, null, 10, 0, 0.01, Z), console.log("Playing animation:", S + se), $ = !0;
7457
7179
  break;
7458
7180
  } catch {
7459
7181
  console.log(`Failed to play ${S}${se}, trying next format...`);
7460
7182
  }
7461
- if (!ee) {
7183
+ if (!$) {
7462
7184
  console.warn("Animation system not available or animation not found:", S);
7463
7185
  try {
7464
7186
  r.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
@@ -7471,19 +7193,19 @@ const pt = Me(({
7471
7193
  console.warn("Animation system not available or animation not found:", S);
7472
7194
  }, []);
7473
7195
  return Ee(l, () => ({
7474
- speakText: y,
7475
- stopSpeaking: M,
7196
+ speakText: f,
7197
+ stopSpeaking: E,
7476
7198
  setMood: P,
7477
- setTimingAdjustment: D,
7478
- playAnimation: J,
7199
+ setTimingAdjustment: U,
7200
+ playAnimation: oe,
7479
7201
  isReady: g,
7480
7202
  talkingHead: r.current,
7481
7203
  setBodyMovement: (S) => {
7482
7204
  if (r.current && r.current.setShowFullAvatar && r.current.setBodyMovement)
7483
7205
  try {
7484
7206
  r.current.setShowFullAvatar(!0), r.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7485
- } catch (G) {
7486
- console.warn("Error setting body movement:", G);
7207
+ } catch (Z) {
7208
+ console.warn("Error setting body movement:", Z);
7487
7209
  }
7488
7210
  },
7489
7211
  setMovementIntensity: (S) => r.current?.setMovementIntensity(S),
@@ -7499,8 +7221,8 @@ const pt = Me(({
7499
7221
  if (r.current && r.current.setShowFullAvatar && r.current.playReaction)
7500
7222
  try {
7501
7223
  r.current.setShowFullAvatar(!0), r.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7502
- } catch (G) {
7503
- console.warn("Error playing reaction:", G);
7224
+ } catch (Z) {
7225
+ console.warn("Error playing reaction:", Z);
7504
7226
  }
7505
7227
  },
7506
7228
  playCelebration: () => {
@@ -7515,8 +7237,8 @@ const pt = Me(({
7515
7237
  if (r.current && r.current.setShowFullAvatar)
7516
7238
  try {
7517
7239
  r.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7518
- } catch (G) {
7519
- console.warn("Error setting showFullAvatar:", G);
7240
+ } catch (Z) {
7241
+ console.warn("Error setting showFullAvatar:", Z);
7520
7242
  }
7521
7243
  },
7522
7244
  lockAvatarPosition: () => {
@@ -7539,7 +7261,7 @@ const pt = Me(({
7539
7261
  /* @__PURE__ */ me(
7540
7262
  "div",
7541
7263
  {
7542
- ref: u,
7264
+ ref: h,
7543
7265
  className: "talking-head-viewer",
7544
7266
  style: {
7545
7267
  width: "100%",
@@ -7548,7 +7270,7 @@ const pt = Me(({
7548
7270
  }
7549
7271
  }
7550
7272
  ),
7551
- h && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7273
+ u && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7552
7274
  position: "absolute",
7553
7275
  top: "50%",
7554
7276
  left: "50%",
@@ -7557,7 +7279,7 @@ const pt = Me(({
7557
7279
  fontSize: "18px",
7558
7280
  zIndex: 10
7559
7281
  }, children: "Loading avatar..." }),
7560
- c && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7282
+ d && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7561
7283
  position: "absolute",
7562
7284
  top: "50%",
7563
7285
  left: "50%",
@@ -7568,12 +7290,12 @@ const pt = Me(({
7568
7290
  zIndex: 10,
7569
7291
  padding: "20px",
7570
7292
  borderRadius: "8px"
7571
- }, children: c })
7293
+ }, children: d })
7572
7294
  ] });
7573
7295
  });
7574
7296
  pt.displayName = "TalkingHeadComponent";
7575
7297
  const gt = Me(({
7576
- text: X = null,
7298
+ text: G = null,
7577
7299
  avatarUrl: t = "/avatars/brunette.glb",
7578
7300
  avatarBody: e = "F",
7579
7301
  mood: n = "neutral",
@@ -7581,104 +7303,104 @@ const gt = Me(({
7581
7303
  ttsService: s = null,
7582
7304
  ttsVoice: o = null,
7583
7305
  ttsApiKey: l = null,
7584
- bodyMovement: u = "idle",
7306
+ bodyMovement: h = "idle",
7585
7307
  movementIntensity: r = 0.5,
7586
- showFullAvatar: h = !1,
7308
+ showFullAvatar: u = !1,
7587
7309
  cameraView: a = "upper",
7588
- onReady: c = () => {
7310
+ onReady: d = () => {
7589
7311
  },
7590
- onLoading: d = () => {
7312
+ onLoading: c = () => {
7591
7313
  },
7592
7314
  onError: g = () => {
7593
7315
  },
7594
- onSpeechEnd: x = () => {
7316
+ onSpeechEnd: y = () => {
7595
7317
  },
7596
7318
  className: b = "",
7597
- style: I = {},
7598
- animations: H = {},
7599
- autoSpeak: m = !1
7600
- }, T) => {
7601
- const k = O(null), y = O(null), M = O(h), P = O(null), D = O(null), J = O(!1), S = O({ remainingText: null, originalText: null, options: null }), G = O([]), [Q, Z] = ce(!0), [ee, se] = ce(null), [ae, pe] = ce(!1), [te, le] = ce(!1);
7319
+ style: R = {},
7320
+ animations: V = {},
7321
+ autoSpeak: p = !1
7322
+ }, M) => {
7323
+ const z = 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);
7602
7324
  de(() => {
7603
- J.current = te;
7604
- }, [te]), de(() => {
7605
- M.current = h;
7606
- }, [h]);
7607
- const U = Fe(), R = s || U.service;
7608
- let v;
7609
- R === "browser" ? v = {
7325
+ oe.current = ee;
7326
+ }, [ee]), de(() => {
7327
+ E.current = u;
7328
+ }, [u]);
7329
+ const O = Fe(), v = s || O.service;
7330
+ let I;
7331
+ v === "browser" ? I = {
7610
7332
  service: "browser",
7611
7333
  endpoint: "",
7612
7334
  apiKey: null,
7613
7335
  defaultVoice: "Google US English"
7614
- } : R === "elevenlabs" ? v = {
7336
+ } : v === "elevenlabs" ? I = {
7615
7337
  service: "elevenlabs",
7616
7338
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
7617
- apiKey: l || U.apiKey,
7618
- defaultVoice: o || U.defaultVoice || Ie.defaultVoice,
7619
- voices: U.voices || Ie.voices
7620
- } : R === "deepgram" ? v = {
7339
+ apiKey: l || O.apiKey,
7340
+ defaultVoice: o || O.defaultVoice || Re.defaultVoice,
7341
+ voices: O.voices || Re.voices
7342
+ } : v === "deepgram" ? I = {
7621
7343
  service: "deepgram",
7622
7344
  endpoint: "https://api.deepgram.com/v1/speak",
7623
- apiKey: l || U.apiKey,
7624
- defaultVoice: o || U.defaultVoice || Te.defaultVoice,
7625
- voices: U.voices || Te.voices
7626
- } : v = {
7627
- ...U,
7628
- apiKey: l !== null ? l : U.apiKey
7345
+ apiKey: l || O.apiKey,
7346
+ defaultVoice: o || O.defaultVoice || Te.defaultVoice,
7347
+ voices: O.voices || Te.voices
7348
+ } : I = {
7349
+ ...O,
7350
+ apiKey: l !== null ? l : O.apiKey
7629
7351
  };
7630
- const w = {
7352
+ const k = {
7631
7353
  url: t,
7632
7354
  body: e,
7633
7355
  avatarMood: n,
7634
- ttsLang: R === "browser" ? "en-US" : i,
7635
- ttsVoice: o || v.defaultVoice,
7356
+ ttsLang: v === "browser" ? "en-US" : i,
7357
+ ttsVoice: o || I.defaultVoice,
7636
7358
  lipsyncLang: "en",
7637
- showFullAvatar: h,
7638
- bodyMovement: u,
7359
+ showFullAvatar: u,
7360
+ bodyMovement: h,
7639
7361
  movementIntensity: r
7640
- }, E = {
7641
- ttsEndpoint: v.endpoint,
7642
- ttsApikey: v.apiKey,
7643
- ttsService: R,
7362
+ }, H = {
7363
+ ttsEndpoint: I.endpoint,
7364
+ ttsApikey: I.apiKey,
7365
+ ttsService: v,
7644
7366
  lipsyncModules: ["en"],
7645
7367
  cameraView: a
7646
- }, W = F(async () => {
7647
- if (!(!k.current || y.current))
7368
+ }, N = T(async () => {
7369
+ if (!(!z.current || f.current))
7648
7370
  try {
7649
- Z(!0), se(null), y.current = new Ne(k.current, E), console.log("Avatar config being passed:", {
7650
- url: w.url,
7651
- body: w.body,
7652
- avatarMood: w.avatarMood
7653
- }), await y.current.showAvatar(w, (ne) => {
7654
- if (ne.lengthComputable) {
7655
- const L = Math.min(100, Math.round(ne.loaded / ne.total * 100));
7656
- d(L);
7371
+ X(!0), se(null), f.current = new Be(z.current, H), console.log("Avatar config being passed:", {
7372
+ url: k.url,
7373
+ body: k.body,
7374
+ avatarMood: k.avatarMood
7375
+ }), await f.current.showAvatar(k, (te) => {
7376
+ if (te.lengthComputable) {
7377
+ const L = Math.min(100, Math.round(te.loaded / te.total * 100));
7378
+ c(L);
7657
7379
  }
7658
- }), y.current?.avatar && console.log("Avatar body after initialization:", y.current.avatar.body), Z(!1), pe(!0), c(y.current);
7380
+ }), f.current?.avatar && console.log("Avatar body after initialization:", f.current.avatar.body), X(!1), pe(!0), d(f.current);
7659
7381
  const C = () => {
7660
- document.visibilityState === "visible" ? y.current?.start() : y.current?.stop();
7382
+ document.visibilityState === "visible" ? f.current?.start() : f.current?.stop();
7661
7383
  };
7662
7384
  return document.addEventListener("visibilitychange", C), () => {
7663
7385
  document.removeEventListener("visibilitychange", C);
7664
7386
  };
7665
7387
  } catch (C) {
7666
- console.error("Error initializing TalkingHead:", C), se(C.message || "Failed to initialize avatar"), Z(!1), g(C);
7388
+ console.error("Error initializing TalkingHead:", C), se(C.message || "Failed to initialize avatar"), X(!1), g(C);
7667
7389
  }
7668
7390
  }, []);
7669
- de(() => (W(), () => {
7670
- y.current && (y.current.stop(), y.current.dispose(), y.current = null);
7671
- }), [W]);
7672
- const K = F(async () => {
7673
- if (y.current)
7391
+ de(() => (N(), () => {
7392
+ f.current && (f.current.stop(), f.current.dispose(), f.current = null);
7393
+ }), [N]);
7394
+ const _ = T(async () => {
7395
+ if (f.current)
7674
7396
  try {
7675
- const C = y.current.audioCtx || y.current.audioContext;
7397
+ const C = f.current.audioCtx || f.current.audioContext;
7676
7398
  C && (C.state === "suspended" || C.state === "interrupted") && (await C.resume(), console.log("Audio context resumed"));
7677
7399
  } catch (C) {
7678
7400
  console.warn("Failed to resume audio context:", C);
7679
7401
  }
7680
- }, []), j = F(async (C, ne = {}) => {
7681
- if (!y.current || !ae) {
7402
+ }, []), j = T(async (C, te = {}) => {
7403
+ if (!f.current || !ae) {
7682
7404
  console.warn("Avatar not ready for speaking");
7683
7405
  return;
7684
7406
  }
@@ -7686,78 +7408,78 @@ const gt = Me(({
7686
7408
  console.warn("No text provided to speak");
7687
7409
  return;
7688
7410
  }
7689
- await K(), S.current = { remainingText: null, originalText: null, options: null }, G.current = [], P.current = { text: C, options: ne }, D.current && (clearInterval(D.current), D.current = null), le(!1), J.current = !1;
7411
+ 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;
7690
7412
  const L = C.split(/[.!?]+/).filter((B) => B.trim().length > 0);
7691
- G.current = L;
7692
- const N = {
7693
- lipsyncLang: ne.lipsyncLang || "en",
7413
+ Z.current = L;
7414
+ const F = {
7415
+ lipsyncLang: te.lipsyncLang || "en",
7694
7416
  onSpeechEnd: () => {
7695
- D.current && (clearInterval(D.current), D.current = null), ne.onSpeechEnd && ne.onSpeechEnd(), x();
7417
+ U.current && (clearInterval(U.current), U.current = null), te.onSpeechEnd && te.onSpeechEnd(), y();
7696
7418
  }
7697
7419
  };
7698
7420
  try {
7699
- y.current.speakText(C, N);
7421
+ f.current.speakText(C, F);
7700
7422
  } catch (B) {
7701
7423
  console.error("Error speaking text:", B), se(B.message || "Failed to speak text");
7702
7424
  }
7703
- }, [ae, x, K]);
7425
+ }, [ae, y, _]);
7704
7426
  de(() => {
7705
- ae && X && m && y.current && j(X);
7706
- }, [ae, X, m, j]);
7707
- const q = F(() => {
7708
- if (y.current)
7427
+ ae && G && p && f.current && j(G);
7428
+ }, [ae, G, p, j]);
7429
+ const q = T(() => {
7430
+ if (f.current)
7709
7431
  try {
7710
- const C = y.current.isSpeaking || !1, ne = y.current.audioPlaylist || [], L = y.current.speechQueue || [];
7711
- if (C || ne.length > 0 || L.length > 0) {
7712
- D.current && (clearInterval(D.current), D.current = null);
7713
- let N = "";
7714
- L.length > 0 && (N = L.map((B) => B.text && Array.isArray(B.text) ? B.text.map(($) => $.word).join(" ") : B.text || "").join(" ")), S.current = {
7715
- remainingText: N || null,
7432
+ const C = f.current.isSpeaking || !1, te = f.current.audioPlaylist || [], L = f.current.speechQueue || [];
7433
+ if (C || te.length > 0 || L.length > 0) {
7434
+ U.current && (clearInterval(U.current), U.current = null);
7435
+ let F = "";
7436
+ 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 = {
7437
+ remainingText: F || null,
7716
7438
  originalText: P.current?.text || null,
7717
7439
  options: P.current?.options || null
7718
- }, y.current.speechQueue.length = 0, y.current.pauseSpeaking(), le(!0), J.current = !0;
7440
+ }, f.current.speechQueue.length = 0, f.current.pauseSpeaking(), le(!0), oe.current = !0;
7719
7441
  }
7720
7442
  } catch (C) {
7721
7443
  console.warn("Error pausing speech:", C);
7722
7444
  }
7723
- }, []), Le = F(async () => {
7724
- if (!(!y.current || !te))
7445
+ }, []), Le = T(async () => {
7446
+ if (!(!f.current || !ee))
7725
7447
  try {
7726
- await K(), le(!1), J.current = !1;
7727
- const C = S.current?.remainingText, ne = S.current?.originalText || P.current?.text, L = S.current?.options || P.current?.options || {}, N = C || ne;
7728
- N && j(N, L);
7448
+ await _(), le(!1), oe.current = !1;
7449
+ const C = S.current?.remainingText, te = S.current?.originalText || P.current?.text, L = S.current?.options || P.current?.options || {}, F = C || te;
7450
+ F && j(F, L);
7729
7451
  } catch (C) {
7730
- console.warn("Error resuming speech:", C), le(!1), J.current = !1;
7452
+ console.warn("Error resuming speech:", C), le(!1), oe.current = !1;
7731
7453
  }
7732
- }, [te, j, K]), we = F(() => {
7733
- y.current && (y.current.stopSpeaking(), D.current && (clearInterval(D.current), D.current = null), le(!1), J.current = !1);
7454
+ }, [ee, j, _]), we = T(() => {
7455
+ f.current && (f.current.stopSpeaking(), U.current && (clearInterval(U.current), U.current = null), le(!1), oe.current = !1);
7734
7456
  }, []);
7735
- return Ee(T, () => ({
7457
+ return Ee(M, () => ({
7736
7458
  speakText: j,
7737
7459
  pauseSpeaking: q,
7738
7460
  resumeSpeaking: Le,
7739
7461
  stopSpeaking: we,
7740
- resumeAudioContext: K,
7741
- isPaused: () => te,
7742
- setMood: (C) => y.current?.setMood(C),
7462
+ resumeAudioContext: _,
7463
+ isPaused: () => ee,
7464
+ setMood: (C) => f.current?.setMood(C),
7743
7465
  setBodyMovement: (C) => {
7744
- y.current && y.current.setBodyMovement(C);
7466
+ f.current && f.current.setBodyMovement(C);
7745
7467
  },
7746
- playAnimation: (C, ne = !1) => {
7747
- y.current && y.current.playAnimation && y.current.playAnimation(C, null, 10, 0, 0.01, ne);
7468
+ playAnimation: (C, te = !1) => {
7469
+ f.current && f.current.playAnimation && f.current.playAnimation(C, null, 10, 0, 0.01, te);
7748
7470
  },
7749
- playReaction: (C) => y.current?.playReaction(C),
7750
- playCelebration: () => y.current?.playCelebration(),
7471
+ playReaction: (C) => f.current?.playReaction(C),
7472
+ playCelebration: () => f.current?.playCelebration(),
7751
7473
  setShowFullAvatar: (C) => {
7752
- y.current && (M.current = C, y.current.setShowFullAvatar(C));
7474
+ f.current && (E.current = C, f.current.setShowFullAvatar(C));
7753
7475
  },
7754
7476
  isReady: ae,
7755
- talkingHead: y.current
7756
- })), /* @__PURE__ */ Pe("div", { className: `simple-talking-avatar-container ${b}`, style: I, children: [
7477
+ talkingHead: f.current
7478
+ })), /* @__PURE__ */ Pe("div", { className: `simple-talking-avatar-container ${b}`, style: R, children: [
7757
7479
  /* @__PURE__ */ me(
7758
7480
  "div",
7759
7481
  {
7760
- ref: k,
7482
+ ref: z,
7761
7483
  className: "talking-head-viewer",
7762
7484
  style: {
7763
7485
  width: "100%",
@@ -7766,7 +7488,7 @@ const gt = Me(({
7766
7488
  }
7767
7489
  }
7768
7490
  ),
7769
- Q && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7491
+ K && /* @__PURE__ */ me("div", { className: "loading-overlay", style: {
7770
7492
  position: "absolute",
7771
7493
  top: "50%",
7772
7494
  left: "50%",
@@ -7775,7 +7497,7 @@ const gt = Me(({
7775
7497
  fontSize: "18px",
7776
7498
  zIndex: 10
7777
7499
  }, children: "Loading avatar..." }),
7778
- ee && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7500
+ $ && /* @__PURE__ */ me("div", { className: "error-overlay", style: {
7779
7501
  position: "absolute",
7780
7502
  top: "50%",
7781
7503
  left: "50%",
@@ -7786,12 +7508,12 @@ const gt = Me(({
7786
7508
  zIndex: 10,
7787
7509
  padding: "20px",
7788
7510
  borderRadius: "8px"
7789
- }, children: ee })
7511
+ }, children: $ })
7790
7512
  ] });
7791
7513
  });
7792
7514
  gt.displayName = "SimpleTalkingAvatar";
7793
7515
  const yt = Me(({
7794
- curriculumData: X = null,
7516
+ curriculumData: G = null,
7795
7517
  avatarConfig: t = {},
7796
7518
  animations: e = {},
7797
7519
  onLessonStart: n = () => {
@@ -7804,9 +7526,9 @@ const yt = Me(({
7804
7526
  },
7805
7527
  onCustomAction: l = () => {
7806
7528
  },
7807
- autoStart: u = !1
7529
+ autoStart: h = !1
7808
7530
  }, r) => {
7809
- const h = O(null), a = O({
7531
+ const u = D(null), a = D({
7810
7532
  currentModuleIndex: 0,
7811
7533
  currentLessonIndex: 0,
7812
7534
  currentQuestionIndex: 0,
@@ -7816,18 +7538,18 @@ const yt = Me(({
7816
7538
  curriculumCompleted: !1,
7817
7539
  score: 0,
7818
7540
  totalQuestions: 0
7819
- }), c = O({
7541
+ }), d = D({
7820
7542
  onLessonStart: n,
7821
7543
  onLessonComplete: i,
7822
7544
  onQuestionAnswer: s,
7823
7545
  onCurriculumComplete: o,
7824
7546
  onCustomAction: l
7825
- }), d = O(null), g = O(null), x = O(null), b = O(null), I = O(null), H = O(null), m = O(null), T = O(X?.curriculum || {
7547
+ }), c = D(null), g = D(null), y = D(null), b = D(null), R = D(null), V = D(null), p = D(null), M = D(G?.curriculum || {
7826
7548
  title: "Default Curriculum",
7827
7549
  description: "No curriculum data provided",
7828
7550
  language: "en",
7829
7551
  modules: []
7830
- }), k = O({
7552
+ }), z = D({
7831
7553
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7832
7554
  avatarBody: t.avatarBody || "F",
7833
7555
  mood: t.mood || "happy",
@@ -7842,7 +7564,7 @@ const yt = Me(({
7842
7564
  lipsyncLang: "en"
7843
7565
  });
7844
7566
  de(() => {
7845
- c.current = {
7567
+ d.current = {
7846
7568
  onLessonStart: n,
7847
7569
  onLessonComplete: i,
7848
7570
  onQuestionAnswer: s,
@@ -7850,12 +7572,12 @@ const yt = Me(({
7850
7572
  onCustomAction: l
7851
7573
  };
7852
7574
  }, [n, i, s, o, l]), de(() => {
7853
- T.current = X?.curriculum || {
7575
+ M.current = G?.curriculum || {
7854
7576
  title: "Default Curriculum",
7855
7577
  description: "No curriculum data provided",
7856
7578
  language: "en",
7857
7579
  modules: []
7858
- }, k.current = {
7580
+ }, z.current = {
7859
7581
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7860
7582
  avatarBody: t.avatarBody || "F",
7861
7583
  mood: t.mood || "happy",
@@ -7869,293 +7591,293 @@ const yt = Me(({
7869
7591
  animations: e,
7870
7592
  lipsyncLang: "en"
7871
7593
  };
7872
- }, [X, t, e]);
7873
- const y = F(() => (T.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), M = F(() => y()?.questions[a.current.currentQuestionIndex], [y]), P = F((R, v) => v.type === "multiple_choice" || v.type === "true_false" ? R === v.answer : v.type === "code_test" && typeof R == "object" && R !== null ? R.passed === !0 : !1, []), D = F(() => {
7594
+ }, [G, t, e]);
7595
+ 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, I) => I.type === "multiple_choice" || I.type === "true_false" ? v === I.answer : I.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), U = T(() => {
7874
7596
  a.current.lessonCompleted = !0, a.current.isQuestionMode = !1;
7875
- const R = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7876
- let v = "Congratulations! You've completed this lesson";
7877
- if (a.current.totalQuestions > 0 ? v += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${R} percent. ` : v += "! ", R >= 80 ? v += "Excellent work! You have a great understanding of this topic." : R >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7597
+ const v = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7598
+ let I = "Congratulations! You've completed this lesson";
7599
+ if (a.current.totalQuestions > 0 ? I += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${v} percent. ` : I += "! ", v >= 80 ? I += "Excellent work! You have a great understanding of this topic." : v >= 60 ? I += "Good job! You understand most of the concepts." : I += "Keep practicing! You're making progress.", d.current.onLessonComplete({
7878
7600
  moduleIndex: a.current.currentModuleIndex,
7879
7601
  lessonIndex: a.current.currentLessonIndex,
7880
7602
  score: a.current.score,
7881
7603
  totalQuestions: a.current.totalQuestions,
7882
- percentage: R
7883
- }), c.current.onCustomAction({
7604
+ percentage: v
7605
+ }), d.current.onCustomAction({
7884
7606
  type: "lessonComplete",
7885
7607
  moduleIndex: a.current.currentModuleIndex,
7886
7608
  lessonIndex: a.current.currentLessonIndex,
7887
7609
  score: a.current.score,
7888
7610
  totalQuestions: a.current.totalQuestions,
7889
- percentage: R
7890
- }), h.current) {
7891
- if (h.current.setMood("happy"), e.lessonComplete)
7611
+ percentage: v
7612
+ }), u.current) {
7613
+ if (u.current.setMood("happy"), e.lessonComplete)
7892
7614
  try {
7893
- h.current.playAnimation(e.lessonComplete, !0);
7615
+ u.current.playAnimation(e.lessonComplete, !0);
7894
7616
  } catch {
7895
- h.current.playCelebration();
7617
+ u.current.playCelebration();
7896
7618
  }
7897
- const w = T.current || { modules: [] }, E = w.modules[a.current.currentModuleIndex], W = a.current.currentLessonIndex < (E?.lessons?.length || 0) - 1, K = a.current.currentModuleIndex < (w.modules?.length || 0) - 1, j = W || K, q = k.current || { lipsyncLang: "en" };
7898
- h.current.speakText(v, {
7619
+ const k = M.current || { modules: [] }, H = k.modules[a.current.currentModuleIndex], N = a.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, _ = a.current.currentModuleIndex < (k.modules?.length || 0) - 1, j = N || _, q = z.current || { lipsyncLang: "en" };
7620
+ u.current.speakText(I, {
7899
7621
  lipsyncLang: q.lipsyncLang,
7900
7622
  onSpeechEnd: () => {
7901
- c.current.onCustomAction({
7623
+ d.current.onCustomAction({
7902
7624
  type: "lessonCompleteFeedbackDone",
7903
7625
  moduleIndex: a.current.currentModuleIndex,
7904
7626
  lessonIndex: a.current.currentLessonIndex,
7905
7627
  score: a.current.score,
7906
7628
  totalQuestions: a.current.totalQuestions,
7907
- percentage: R,
7629
+ percentage: v,
7908
7630
  hasNextLesson: j
7909
7631
  });
7910
7632
  }
7911
7633
  });
7912
7634
  }
7913
- }, [e.lessonComplete]), J = F(() => {
7635
+ }, [e.lessonComplete]), oe = T(() => {
7914
7636
  a.current.curriculumCompleted = !0;
7915
- const R = T.current || { modules: [] };
7916
- if (c.current.onCurriculumComplete({
7917
- modules: R.modules.length,
7918
- totalLessons: R.modules.reduce((v, w) => v + w.lessons.length, 0)
7919
- }), h.current) {
7920
- if (h.current.setMood("celebrating"), e.curriculumComplete)
7637
+ const v = M.current || { modules: [] };
7638
+ if (d.current.onCurriculumComplete({
7639
+ modules: v.modules.length,
7640
+ totalLessons: v.modules.reduce((I, k) => I + k.lessons.length, 0)
7641
+ }), u.current) {
7642
+ if (u.current.setMood("celebrating"), e.curriculumComplete)
7921
7643
  try {
7922
- h.current.playAnimation(e.curriculumComplete, !0);
7644
+ u.current.playAnimation(e.curriculumComplete, !0);
7923
7645
  } catch {
7924
- h.current.playCelebration();
7646
+ u.current.playCelebration();
7925
7647
  }
7926
- const v = k.current || { lipsyncLang: "en" };
7927
- h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
7648
+ const I = z.current || { lipsyncLang: "en" };
7649
+ u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: I.lipsyncLang });
7928
7650
  }
7929
- }, [e.curriculumComplete]), S = F(() => {
7930
- const R = y();
7931
- a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = R?.questions?.length || 0, a.current.score = 0;
7932
- const v = M();
7933
- v && c.current.onCustomAction({
7651
+ }, [e.curriculumComplete]), S = T(() => {
7652
+ const v = f();
7653
+ a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = v?.questions?.length || 0, a.current.score = 0;
7654
+ const I = E();
7655
+ I && d.current.onCustomAction({
7934
7656
  type: "questionStart",
7935
7657
  moduleIndex: a.current.currentModuleIndex,
7936
7658
  lessonIndex: a.current.currentLessonIndex,
7937
7659
  questionIndex: a.current.currentQuestionIndex,
7938
7660
  totalQuestions: a.current.totalQuestions,
7939
- question: v,
7661
+ question: I,
7940
7662
  score: a.current.score
7941
7663
  });
7942
- const w = () => {
7943
- if (!h.current || !v) return;
7944
- if (h.current.setMood("happy"), e.questionStart)
7664
+ const k = () => {
7665
+ if (!u.current || !I) return;
7666
+ if (u.current.setMood("happy"), e.questionStart)
7945
7667
  try {
7946
- h.current.playAnimation(e.questionStart, !0);
7947
- } catch (W) {
7948
- console.warn("Failed to play questionStart animation:", W);
7668
+ u.current.playAnimation(e.questionStart, !0);
7669
+ } catch (N) {
7670
+ console.warn("Failed to play questionStart animation:", N);
7949
7671
  }
7950
- const E = k.current || { lipsyncLang: "en" };
7951
- v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: E.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: E.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: E.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: E.lipsyncLang });
7672
+ const H = z.current || { lipsyncLang: "en" };
7673
+ I.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${I.question}`, { lipsyncLang: H.lipsyncLang }) : I.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${I.question}`, { lipsyncLang: H.lipsyncLang }) : I.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${I.question}`, { lipsyncLang: H.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${I.question}`, { lipsyncLang: H.lipsyncLang });
7952
7674
  };
7953
- if (h.current && h.current.isReady && v)
7954
- w();
7955
- else if (h.current && h.current.isReady) {
7956
- const E = k.current || { lipsyncLang: "en" };
7957
- h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: E.lipsyncLang });
7675
+ if (u.current && u.current.isReady && I)
7676
+ k();
7677
+ else if (u.current && u.current.isReady) {
7678
+ const H = z.current || { lipsyncLang: "en" };
7679
+ u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: H.lipsyncLang });
7958
7680
  } else {
7959
- const E = setInterval(() => {
7960
- h.current && h.current.isReady && (clearInterval(E), v && w());
7681
+ const H = setInterval(() => {
7682
+ u.current && u.current.isReady && (clearInterval(H), I && k());
7961
7683
  }, 100);
7962
7684
  setTimeout(() => {
7963
- clearInterval(E);
7685
+ clearInterval(H);
7964
7686
  }, 5e3);
7965
7687
  }
7966
- }, [e.questionStart, y, M]), G = F(() => {
7967
- const R = y();
7968
- if (a.current.currentQuestionIndex < (R?.questions?.length || 0) - 1) {
7969
- h.current && h.current.stopSpeaking && h.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7970
- const v = M();
7971
- v && c.current.onCustomAction({
7688
+ }, [e.questionStart, f, E]), Z = T(() => {
7689
+ const v = f();
7690
+ if (a.current.currentQuestionIndex < (v?.questions?.length || 0) - 1) {
7691
+ u.current && u.current.stopSpeaking && u.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7692
+ const I = E();
7693
+ I && d.current.onCustomAction({
7972
7694
  type: "nextQuestion",
7973
7695
  moduleIndex: a.current.currentModuleIndex,
7974
7696
  lessonIndex: a.current.currentLessonIndex,
7975
7697
  questionIndex: a.current.currentQuestionIndex,
7976
7698
  totalQuestions: a.current.totalQuestions,
7977
- question: v,
7699
+ question: I,
7978
7700
  score: a.current.score
7979
7701
  });
7980
- const w = () => {
7981
- if (!h.current || !v) return;
7982
- if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
7702
+ const k = () => {
7703
+ if (!u.current || !I) return;
7704
+ if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
7983
7705
  try {
7984
- h.current.playAnimation(e.nextQuestion, !0);
7706
+ u.current.playAnimation(e.nextQuestion, !0);
7985
7707
  } catch (q) {
7986
7708
  console.warn("Failed to play nextQuestion animation:", q);
7987
7709
  }
7988
- const E = k.current || { lipsyncLang: "en" }, K = y()?.questions?.length || 0, j = a.current.currentQuestionIndex >= K - 1;
7989
- if (v.type === "code_test") {
7990
- const q = j ? `Great! Here's your final coding challenge: ${v.question}` : `Great! Now let's move on to your next coding challenge: ${v.question}`;
7991
- h.current.speakText(q, {
7992
- lipsyncLang: E.lipsyncLang
7710
+ const H = z.current || { lipsyncLang: "en" }, _ = f()?.questions?.length || 0, j = a.current.currentQuestionIndex >= _ - 1;
7711
+ if (I.type === "code_test") {
7712
+ const q = j ? `Great! Here's your final coding challenge: ${I.question}` : `Great! Now let's move on to your next coding challenge: ${I.question}`;
7713
+ u.current.speakText(q, {
7714
+ lipsyncLang: H.lipsyncLang
7993
7715
  });
7994
- } else if (v.type === "multiple_choice") {
7995
- const q = j ? `Alright! Here's your final question: ${v.question}` : `Alright! Here's your next question: ${v.question}`;
7996
- h.current.speakText(q, {
7997
- lipsyncLang: E.lipsyncLang
7716
+ } else if (I.type === "multiple_choice") {
7717
+ const q = j ? `Alright! Here's your final question: ${I.question}` : `Alright! Here's your next question: ${I.question}`;
7718
+ u.current.speakText(q, {
7719
+ lipsyncLang: H.lipsyncLang
7998
7720
  });
7999
- } else if (v.type === "true_false") {
8000
- const q = j ? `Now let's try this final one: ${v.question}` : `Now let's try this one: ${v.question}`;
8001
- h.current.speakText(q, {
8002
- lipsyncLang: E.lipsyncLang
7721
+ } else if (I.type === "true_false") {
7722
+ const q = j ? `Now let's try this final one: ${I.question}` : `Now let's try this one: ${I.question}`;
7723
+ u.current.speakText(q, {
7724
+ lipsyncLang: H.lipsyncLang
8003
7725
  });
8004
7726
  } else {
8005
- const q = j ? `Here's your final question: ${v.question}` : `Here's the next question: ${v.question}`;
8006
- h.current.speakText(q, {
8007
- lipsyncLang: E.lipsyncLang
7727
+ const q = j ? `Here's your final question: ${I.question}` : `Here's the next question: ${I.question}`;
7728
+ u.current.speakText(q, {
7729
+ lipsyncLang: H.lipsyncLang
8008
7730
  });
8009
7731
  }
8010
7732
  };
8011
- if (h.current && h.current.isReady && v)
8012
- w();
8013
- else if (v) {
8014
- const E = setInterval(() => {
8015
- h.current && h.current.isReady && (clearInterval(E), w());
7733
+ if (u.current && u.current.isReady && I)
7734
+ k();
7735
+ else if (I) {
7736
+ const H = setInterval(() => {
7737
+ u.current && u.current.isReady && (clearInterval(H), k());
8016
7738
  }, 100);
8017
7739
  setTimeout(() => {
8018
- clearInterval(E);
7740
+ clearInterval(H);
8019
7741
  }, 5e3);
8020
7742
  }
8021
7743
  } else
8022
- c.current.onCustomAction({
7744
+ d.current.onCustomAction({
8023
7745
  type: "allQuestionsComplete",
8024
7746
  moduleIndex: a.current.currentModuleIndex,
8025
7747
  lessonIndex: a.current.currentLessonIndex,
8026
7748
  totalQuestions: a.current.totalQuestions,
8027
7749
  score: a.current.score
8028
7750
  });
8029
- }, [e.nextQuestion, y, M]), Q = F(() => {
8030
- const R = T.current || { modules: [] }, v = R.modules[a.current.currentModuleIndex];
8031
- if (a.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7751
+ }, [e.nextQuestion, f, E]), K = T(() => {
7752
+ const v = M.current || { modules: [] }, I = v.modules[a.current.currentModuleIndex];
7753
+ if (a.current.currentLessonIndex < (I?.lessons?.length || 0) - 1) {
8032
7754
  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;
8033
- const E = R.modules[a.current.currentModuleIndex], W = a.current.currentLessonIndex < (E?.lessons?.length || 0) - 1, K = a.current.currentModuleIndex < (R.modules?.length || 0) - 1, j = W || K;
8034
- c.current.onCustomAction({
7755
+ 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 || _;
7756
+ d.current.onCustomAction({
8035
7757
  type: "lessonStart",
8036
7758
  moduleIndex: a.current.currentModuleIndex,
8037
7759
  lessonIndex: a.current.currentLessonIndex,
8038
7760
  hasNextLesson: j
8039
- }), c.current.onLessonStart({
7761
+ }), d.current.onLessonStart({
8040
7762
  moduleIndex: a.current.currentModuleIndex,
8041
7763
  lessonIndex: a.current.currentLessonIndex,
8042
- lesson: y()
8043
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
8044
- } else if (a.current.currentModuleIndex < (R.modules?.length || 0) - 1) {
7764
+ lesson: f()
7765
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
7766
+ } else if (a.current.currentModuleIndex < (v.modules?.length || 0) - 1) {
8045
7767
  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;
8046
- const W = R.modules[a.current.currentModuleIndex], K = a.current.currentLessonIndex < (W?.lessons?.length || 0) - 1, j = a.current.currentModuleIndex < (R.modules?.length || 0) - 1, q = K || j;
8047
- c.current.onCustomAction({
7768
+ 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;
7769
+ d.current.onCustomAction({
8048
7770
  type: "lessonStart",
8049
7771
  moduleIndex: a.current.currentModuleIndex,
8050
7772
  lessonIndex: a.current.currentLessonIndex,
8051
7773
  hasNextLesson: q
8052
- }), c.current.onLessonStart({
7774
+ }), d.current.onLessonStart({
8053
7775
  moduleIndex: a.current.currentModuleIndex,
8054
7776
  lessonIndex: a.current.currentLessonIndex,
8055
- lesson: y()
8056
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7777
+ lesson: f()
7778
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8057
7779
  } else
8058
- I.current && I.current();
8059
- }, []), Z = F(() => {
8060
- const R = y();
8061
- let v = null;
8062
- if (R?.avatar_script && R?.body) {
8063
- const w = R.avatar_script.trim(), E = R.body.trim(), W = w.match(/[.!?]$/) ? " " : ". ";
8064
- v = `${w}${W}${E}`;
7780
+ R.current && R.current();
7781
+ }, []), X = T(() => {
7782
+ const v = f();
7783
+ let I = null;
7784
+ if (v?.avatar_script && v?.body) {
7785
+ const k = v.avatar_script.trim(), H = v.body.trim(), N = k.match(/[.!?]$/) ? " " : ". ";
7786
+ I = `${k}${N}${H}`;
8065
7787
  } else
8066
- v = R?.avatar_script || R?.body || null;
8067
- if (h.current && h.current.isReady && v) {
8068
- a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, h.current.setMood("happy");
8069
- let w = !1;
7788
+ I = v?.avatar_script || v?.body || null;
7789
+ if (u.current && u.current.isReady && I) {
7790
+ a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, u.current.setMood("happy");
7791
+ let k = !1;
8070
7792
  if (e.teaching)
8071
7793
  try {
8072
- h.current.playAnimation(e.teaching, !0), w = !0;
8073
- } catch (W) {
8074
- console.warn("Failed to play teaching animation:", W);
7794
+ u.current.playAnimation(e.teaching, !0), k = !0;
7795
+ } catch (N) {
7796
+ console.warn("Failed to play teaching animation:", N);
8075
7797
  }
8076
- w || h.current.setBodyMovement("gesturing");
8077
- const E = k.current || { lipsyncLang: "en" };
8078
- c.current.onLessonStart({
7798
+ k || u.current.setBodyMovement("gesturing");
7799
+ const H = z.current || { lipsyncLang: "en" };
7800
+ d.current.onLessonStart({
8079
7801
  moduleIndex: a.current.currentModuleIndex,
8080
7802
  lessonIndex: a.current.currentLessonIndex,
8081
- lesson: R
8082
- }), c.current.onCustomAction({
7803
+ lesson: v
7804
+ }), d.current.onCustomAction({
8083
7805
  type: "teachingStart",
8084
7806
  moduleIndex: a.current.currentModuleIndex,
8085
7807
  lessonIndex: a.current.currentLessonIndex,
8086
- lesson: R
8087
- }), h.current.speakText(v, {
8088
- lipsyncLang: E.lipsyncLang,
7808
+ lesson: v
7809
+ }), u.current.speakText(I, {
7810
+ lipsyncLang: H.lipsyncLang,
8089
7811
  onSpeechEnd: () => {
8090
- a.current.isTeaching = !1, c.current.onCustomAction({
7812
+ a.current.isTeaching = !1, d.current.onCustomAction({
8091
7813
  type: "teachingComplete",
8092
7814
  moduleIndex: a.current.currentModuleIndex,
8093
7815
  lessonIndex: a.current.currentLessonIndex,
8094
- lesson: R,
8095
- hasQuestions: R.questions && R.questions.length > 0
8096
- }), R?.code_example && c.current.onCustomAction({
7816
+ lesson: v,
7817
+ hasQuestions: v.questions && v.questions.length > 0
7818
+ }), v?.code_example && d.current.onCustomAction({
8097
7819
  type: "codeExampleReady",
8098
7820
  moduleIndex: a.current.currentModuleIndex,
8099
7821
  lessonIndex: a.current.currentLessonIndex,
8100
- lesson: R,
8101
- codeExample: R.code_example
7822
+ lesson: v,
7823
+ codeExample: v.code_example
8102
7824
  });
8103
7825
  }
8104
7826
  });
8105
7827
  }
8106
- }, [e.teaching, y]), ee = F((R) => {
8107
- const v = M(), w = P(R, v);
8108
- if (w && (a.current.score += 1), c.current.onQuestionAnswer({
7828
+ }, [e.teaching, f]), $ = T((v) => {
7829
+ const I = E(), k = P(v, I);
7830
+ if (k && (a.current.score += 1), d.current.onQuestionAnswer({
8109
7831
  moduleIndex: a.current.currentModuleIndex,
8110
7832
  lessonIndex: a.current.currentLessonIndex,
8111
7833
  questionIndex: a.current.currentQuestionIndex,
8112
- answer: R,
8113
- isCorrect: w,
8114
- question: v
8115
- }), h.current)
8116
- if (w) {
8117
- if (h.current.setMood("happy"), e.correct)
7834
+ answer: v,
7835
+ isCorrect: k,
7836
+ question: I
7837
+ }), u.current)
7838
+ if (k) {
7839
+ if (u.current.setMood("happy"), e.correct)
8118
7840
  try {
8119
- h.current.playReaction("happy");
7841
+ u.current.playReaction("happy");
8120
7842
  } catch {
8121
- h.current.setBodyMovement("happy");
7843
+ u.current.setBodyMovement("happy");
8122
7844
  }
8123
- h.current.setBodyMovement("gesturing");
8124
- const W = y()?.questions?.length || 0;
8125
- a.current.currentQuestionIndex >= W - 1;
8126
- const K = a.current.currentQuestionIndex < W - 1;
8127
- console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", W, "hasNextQuestion:", K);
8128
- const j = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, q = k.current || { lipsyncLang: "en" };
8129
- h.current.speakText(j, {
7845
+ u.current.setBodyMovement("gesturing");
7846
+ const N = f()?.questions?.length || 0;
7847
+ a.current.currentQuestionIndex >= N - 1;
7848
+ const _ = a.current.currentQuestionIndex < N - 1;
7849
+ console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", _);
7850
+ const j = I.type === "code_test" ? `Great job! Your code passed all the tests! ${I.explanation || ""}` : `Excellent! That's correct! ${I.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
7851
+ u.current.speakText(j, {
8130
7852
  lipsyncLang: q.lipsyncLang,
8131
7853
  onSpeechEnd: () => {
8132
- c.current.onCustomAction({
7854
+ d.current.onCustomAction({
8133
7855
  type: "answerFeedbackComplete",
8134
7856
  moduleIndex: a.current.currentModuleIndex,
8135
7857
  lessonIndex: a.current.currentLessonIndex,
8136
7858
  questionIndex: a.current.currentQuestionIndex,
8137
7859
  isCorrect: !0,
8138
- hasNextQuestion: K,
7860
+ hasNextQuestion: _,
8139
7861
  score: a.current.score,
8140
7862
  totalQuestions: a.current.totalQuestions
8141
7863
  });
8142
7864
  }
8143
7865
  });
8144
7866
  } else {
8145
- if (h.current.setMood("sad"), e.incorrect)
7867
+ if (u.current.setMood("sad"), e.incorrect)
8146
7868
  try {
8147
- h.current.playAnimation(e.incorrect, !0);
7869
+ u.current.playAnimation(e.incorrect, !0);
8148
7870
  } catch {
8149
- h.current.setBodyMovement("idle");
7871
+ u.current.setBodyMovement("idle");
8150
7872
  }
8151
- h.current.setBodyMovement("gesturing");
8152
- const W = y()?.questions?.length || 0, K = a.current.currentQuestionIndex >= W - 1, j = a.current.currentQuestionIndex < W - 1;
8153
- console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", W, "hasNextQuestion:", j);
8154
- const q = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""}${K ? "" : " Let's move on to the next question."}`, Le = k.current || { lipsyncLang: "en" };
8155
- h.current.speakText(q, {
7873
+ u.current.setBodyMovement("gesturing");
7874
+ const N = f()?.questions?.length || 0, _ = a.current.currentQuestionIndex >= N - 1, j = a.current.currentQuestionIndex < N - 1;
7875
+ console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", j);
7876
+ const q = I.type === "code_test" ? `Your code didn't pass all the tests. ${I.explanation || "Try again!"}` : `Not quite right, but don't worry! ${I.explanation || ""}${_ ? "" : " Let's move on to the next question."}`, Le = z.current || { lipsyncLang: "en" };
7877
+ u.current.speakText(q, {
8156
7878
  lipsyncLang: Le.lipsyncLang,
8157
7879
  onSpeechEnd: () => {
8158
- c.current.onCustomAction({
7880
+ d.current.onCustomAction({
8159
7881
  type: "answerFeedbackComplete",
8160
7882
  moduleIndex: a.current.currentModuleIndex,
8161
7883
  lessonIndex: a.current.currentLessonIndex,
@@ -8169,184 +7891,184 @@ const yt = Me(({
8169
7891
  });
8170
7892
  }
8171
7893
  else {
8172
- const W = y()?.questions?.length || 0;
8173
- c.current.onCustomAction({
7894
+ const N = f()?.questions?.length || 0;
7895
+ d.current.onCustomAction({
8174
7896
  type: "answerFeedbackComplete",
8175
7897
  moduleIndex: a.current.currentModuleIndex,
8176
7898
  lessonIndex: a.current.currentLessonIndex,
8177
7899
  questionIndex: a.current.currentQuestionIndex,
8178
- isCorrect: w,
8179
- hasNextQuestion: a.current.currentQuestionIndex < W - 1,
7900
+ isCorrect: k,
7901
+ hasNextQuestion: a.current.currentQuestionIndex < N - 1,
8180
7902
  score: a.current.score,
8181
7903
  totalQuestions: a.current.totalQuestions,
8182
7904
  avatarNotReady: !0
8183
7905
  });
8184
7906
  }
8185
- }, [e.correct, e.incorrect, M, y, P]), se = F((R) => {
8186
- const v = M();
8187
- if (!R || typeof R != "object") {
7907
+ }, [e.correct, e.incorrect, E, f, P]), se = T((v) => {
7908
+ const I = E();
7909
+ if (!v || typeof v != "object") {
8188
7910
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
8189
7911
  return;
8190
7912
  }
8191
- if (v?.type !== "code_test") {
7913
+ if (I?.type !== "code_test") {
8192
7914
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
8193
7915
  return;
8194
7916
  }
8195
- const w = {
8196
- passed: R.passed === !0,
8197
- results: R.results || [],
8198
- output: R.output || "",
8199
- error: R.error || null,
8200
- executionTime: R.executionTime || null,
8201
- testCount: R.testCount || 0,
8202
- passedCount: R.passedCount || 0,
8203
- failedCount: R.failedCount || 0
7917
+ const k = {
7918
+ passed: v.passed === !0,
7919
+ results: v.results || [],
7920
+ output: v.output || "",
7921
+ error: v.error || null,
7922
+ executionTime: v.executionTime || null,
7923
+ testCount: v.testCount || 0,
7924
+ passedCount: v.passedCount || 0,
7925
+ failedCount: v.failedCount || 0
8204
7926
  };
8205
- c.current.onCustomAction({
7927
+ d.current.onCustomAction({
8206
7928
  type: "codeTestSubmitted",
8207
7929
  moduleIndex: a.current.currentModuleIndex,
8208
7930
  lessonIndex: a.current.currentLessonIndex,
8209
7931
  questionIndex: a.current.currentQuestionIndex,
8210
- testResult: w,
8211
- question: v
8212
- }), m.current && m.current(w);
8213
- }, [M, P]), ae = F(() => {
7932
+ testResult: k,
7933
+ question: I
7934
+ }), p.current && p.current(k);
7935
+ }, [E, P]), ae = T(() => {
8214
7936
  if (a.current.currentQuestionIndex > 0) {
8215
7937
  a.current.currentQuestionIndex -= 1;
8216
- const R = M();
8217
- R && c.current.onCustomAction({
7938
+ const v = E();
7939
+ v && d.current.onCustomAction({
8218
7940
  type: "questionStart",
8219
7941
  moduleIndex: a.current.currentModuleIndex,
8220
7942
  lessonIndex: a.current.currentLessonIndex,
8221
7943
  questionIndex: a.current.currentQuestionIndex,
8222
7944
  totalQuestions: a.current.totalQuestions,
8223
- question: R,
7945
+ question: v,
8224
7946
  score: a.current.score
8225
7947
  });
8226
- const v = () => {
8227
- if (!h.current || !R) return;
8228
- h.current.setMood("happy"), h.current.setBodyMovement("idle");
8229
- const w = k.current || { lipsyncLang: "en" };
8230
- R.type === "code_test" ? h.current.speakText(`Let's go back to this coding challenge: ${R.question}`, {
8231
- lipsyncLang: w.lipsyncLang
8232
- }) : h.current.speakText(`Going back to: ${R.question}`, {
8233
- lipsyncLang: w.lipsyncLang
7948
+ const I = () => {
7949
+ if (!u.current || !v) return;
7950
+ u.current.setMood("happy"), u.current.setBodyMovement("idle");
7951
+ const k = z.current || { lipsyncLang: "en" };
7952
+ v.type === "code_test" ? u.current.speakText(`Let's go back to this coding challenge: ${v.question}`, {
7953
+ lipsyncLang: k.lipsyncLang
7954
+ }) : u.current.speakText(`Going back to: ${v.question}`, {
7955
+ lipsyncLang: k.lipsyncLang
8234
7956
  });
8235
7957
  };
8236
- if (h.current && h.current.isReady && R)
8237
- v();
8238
- else if (R) {
8239
- const w = setInterval(() => {
8240
- h.current && h.current.isReady && (clearInterval(w), v());
7958
+ if (u.current && u.current.isReady && v)
7959
+ I();
7960
+ else if (v) {
7961
+ const k = setInterval(() => {
7962
+ u.current && u.current.isReady && (clearInterval(k), I());
8241
7963
  }, 100);
8242
7964
  setTimeout(() => {
8243
- clearInterval(w);
7965
+ clearInterval(k);
8244
7966
  }, 5e3);
8245
7967
  }
8246
7968
  }
8247
- }, [M]), pe = F(() => {
8248
- const R = T.current || { modules: [] };
8249
- if (R.modules[a.current.currentModuleIndex], a.current.currentLessonIndex > 0)
8250
- 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({
7969
+ }, [E]), pe = T(() => {
7970
+ const v = M.current || { modules: [] };
7971
+ if (v.modules[a.current.currentModuleIndex], a.current.currentLessonIndex > 0)
7972
+ 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, d.current.onCustomAction({
8251
7973
  type: "lessonStart",
8252
7974
  moduleIndex: a.current.currentModuleIndex,
8253
7975
  lessonIndex: a.current.currentLessonIndex
8254
- }), c.current.onLessonStart({
7976
+ }), d.current.onLessonStart({
8255
7977
  moduleIndex: a.current.currentModuleIndex,
8256
7978
  lessonIndex: a.current.currentLessonIndex,
8257
- lesson: y()
8258
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7979
+ lesson: f()
7980
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8259
7981
  else if (a.current.currentModuleIndex > 0) {
8260
- const E = R.modules[a.current.currentModuleIndex - 1];
8261
- a.current.currentModuleIndex -= 1, a.current.currentLessonIndex = (E?.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({
7982
+ const H = v.modules[a.current.currentModuleIndex - 1];
7983
+ 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, d.current.onCustomAction({
8262
7984
  type: "lessonStart",
8263
7985
  moduleIndex: a.current.currentModuleIndex,
8264
7986
  lessonIndex: a.current.currentLessonIndex
8265
- }), c.current.onLessonStart({
7987
+ }), d.current.onLessonStart({
8266
7988
  moduleIndex: a.current.currentModuleIndex,
8267
7989
  lessonIndex: a.current.currentLessonIndex,
8268
- lesson: y()
8269
- }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7990
+ lesson: f()
7991
+ }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8270
7992
  }
8271
- }, [y]), te = F(() => {
7993
+ }, [f]), ee = T(() => {
8272
7994
  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;
8273
- }, []), le = F((R) => {
8274
- console.log("Avatar is ready!", R);
8275
- const v = y(), w = v?.avatar_script || v?.body;
8276
- u && w && setTimeout(() => {
8277
- d.current && d.current();
7995
+ }, []), le = T((v) => {
7996
+ console.log("Avatar is ready!", v);
7997
+ const I = f(), k = I?.avatar_script || I?.body;
7998
+ h && k && setTimeout(() => {
7999
+ c.current && c.current();
8278
8000
  }, 10);
8279
- }, [u, y]);
8001
+ }, [h, f]);
8280
8002
  Xe(() => {
8281
- d.current = Z, g.current = Q, x.current = D, b.current = G, I.current = J, H.current = S, m.current = ee;
8003
+ c.current = X, g.current = K, y.current = U, b.current = Z, R.current = oe, V.current = S, p.current = $;
8282
8004
  }), Ee(r, () => ({
8283
8005
  // Curriculum control methods
8284
- startTeaching: Z,
8006
+ startTeaching: X,
8285
8007
  startQuestions: S,
8286
- handleAnswerSelect: ee,
8008
+ handleAnswerSelect: $,
8287
8009
  handleCodeTestResult: se,
8288
- nextQuestion: G,
8010
+ nextQuestion: Z,
8289
8011
  previousQuestion: ae,
8290
- nextLesson: Q,
8012
+ nextLesson: K,
8291
8013
  previousLesson: pe,
8292
- completeLesson: D,
8293
- completeCurriculum: J,
8294
- resetCurriculum: te,
8014
+ completeLesson: U,
8015
+ completeCurriculum: oe,
8016
+ resetCurriculum: ee,
8295
8017
  getState: () => ({ ...a.current }),
8296
- getCurrentQuestion: () => M(),
8297
- getCurrentLesson: () => y(),
8018
+ getCurrentQuestion: () => E(),
8019
+ getCurrentLesson: () => f(),
8298
8020
  // Direct access to avatar ref (always returns current value)
8299
- getAvatarRef: () => h.current,
8021
+ getAvatarRef: () => u.current,
8300
8022
  // Convenience methods that delegate to avatar (always check current ref)
8301
- speakText: async (R, v = {}) => {
8302
- await h.current?.resumeAudioContext?.();
8303
- const w = k.current || { lipsyncLang: "en" };
8304
- h.current?.speakText(R, { ...v, lipsyncLang: v.lipsyncLang || w.lipsyncLang });
8023
+ speakText: async (v, I = {}) => {
8024
+ await u.current?.resumeAudioContext?.();
8025
+ const k = z.current || { lipsyncLang: "en" };
8026
+ u.current?.speakText(v, { ...I, lipsyncLang: I.lipsyncLang || k.lipsyncLang });
8305
8027
  },
8306
8028
  resumeAudioContext: async () => {
8307
- if (h.current?.resumeAudioContext)
8308
- return await h.current.resumeAudioContext();
8309
- const R = h.current?.talkingHead;
8310
- if (R?.audioCtx) {
8311
- const v = R.audioCtx;
8312
- if (v.state === "suspended" || v.state === "interrupted")
8029
+ if (u.current?.resumeAudioContext)
8030
+ return await u.current.resumeAudioContext();
8031
+ const v = u.current?.talkingHead;
8032
+ if (v?.audioCtx) {
8033
+ const I = v.audioCtx;
8034
+ if (I.state === "suspended" || I.state === "interrupted")
8313
8035
  try {
8314
- await v.resume(), console.log("Audio context resumed via talkingHead");
8315
- } catch (w) {
8316
- console.warn("Failed to resume audio context:", w);
8036
+ await I.resume(), console.log("Audio context resumed via talkingHead");
8037
+ } catch (k) {
8038
+ console.warn("Failed to resume audio context:", k);
8317
8039
  }
8318
8040
  } else
8319
8041
  console.warn("Audio context not available yet");
8320
8042
  },
8321
- stopSpeaking: () => h.current?.stopSpeaking(),
8322
- pauseSpeaking: () => h.current?.pauseSpeaking(),
8323
- resumeSpeaking: async () => await h.current?.resumeSpeaking(),
8324
- isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
8325
- setMood: (R) => h.current?.setMood(R),
8326
- playAnimation: (R, v) => h.current?.playAnimation(R, v),
8327
- setBodyMovement: (R) => h.current?.setBodyMovement(R),
8328
- setMovementIntensity: (R) => h.current?.setMovementIntensity(R),
8329
- playRandomDance: () => h.current?.playRandomDance(),
8330
- playReaction: (R) => h.current?.playReaction(R),
8331
- playCelebration: () => h.current?.playCelebration(),
8332
- setShowFullAvatar: (R) => h.current?.setShowFullAvatar(R),
8333
- setTimingAdjustment: (R) => h.current?.setTimingAdjustment(R),
8334
- lockAvatarPosition: () => h.current?.lockAvatarPosition(),
8335
- unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
8043
+ stopSpeaking: () => u.current?.stopSpeaking(),
8044
+ pauseSpeaking: () => u.current?.pauseSpeaking(),
8045
+ resumeSpeaking: async () => await u.current?.resumeSpeaking(),
8046
+ isPaused: () => u.current && typeof u.current.isPaused < "u" ? u.current.isPaused : !1,
8047
+ setMood: (v) => u.current?.setMood(v),
8048
+ playAnimation: (v, I) => u.current?.playAnimation(v, I),
8049
+ setBodyMovement: (v) => u.current?.setBodyMovement(v),
8050
+ setMovementIntensity: (v) => u.current?.setMovementIntensity(v),
8051
+ playRandomDance: () => u.current?.playRandomDance(),
8052
+ playReaction: (v) => u.current?.playReaction(v),
8053
+ playCelebration: () => u.current?.playCelebration(),
8054
+ setShowFullAvatar: (v) => u.current?.setShowFullAvatar(v),
8055
+ setTimingAdjustment: (v) => u.current?.setTimingAdjustment(v),
8056
+ lockAvatarPosition: () => u.current?.lockAvatarPosition(),
8057
+ unlockAvatarPosition: () => u.current?.unlockAvatarPosition(),
8336
8058
  // Custom action trigger
8337
- triggerCustomAction: (R, v) => {
8338
- c.current.onCustomAction({
8339
- type: R,
8340
- ...v,
8059
+ triggerCustomAction: (v, I) => {
8060
+ d.current.onCustomAction({
8061
+ type: v,
8062
+ ...I,
8341
8063
  state: { ...a.current }
8342
8064
  });
8343
8065
  },
8344
8066
  // Responsive resize handler
8345
- handleResize: () => h.current?.handleResize(),
8067
+ handleResize: () => u.current?.handleResize(),
8346
8068
  // Avatar readiness check (always returns current value)
8347
- isAvatarReady: () => h.current?.isReady || !1
8348
- }), [Z, S, ee, se, G, Q, D, J, te, M, y]);
8349
- const U = k.current || {
8069
+ isAvatarReady: () => u.current?.isReady || !1
8070
+ }), [X, S, $, se, Z, K, U, oe, ee, E, f]);
8071
+ const O = z.current || {
8350
8072
  avatarUrl: "/avatars/brunette.glb",
8351
8073
  avatarBody: "F",
8352
8074
  mood: "happy",
@@ -8362,24 +8084,24 @@ const yt = Me(({
8362
8084
  return /* @__PURE__ */ me("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ me(
8363
8085
  Ve,
8364
8086
  {
8365
- ref: h,
8366
- avatarUrl: U.avatarUrl,
8367
- avatarBody: U.avatarBody,
8368
- mood: U.mood,
8369
- ttsLang: U.ttsLang,
8370
- ttsService: U.ttsService,
8371
- ttsVoice: U.ttsVoice,
8372
- ttsApiKey: U.ttsApiKey,
8373
- bodyMovement: U.bodyMovement,
8374
- movementIntensity: U.movementIntensity,
8375
- showFullAvatar: U.showFullAvatar,
8087
+ ref: u,
8088
+ avatarUrl: O.avatarUrl,
8089
+ avatarBody: O.avatarBody,
8090
+ mood: O.mood,
8091
+ ttsLang: O.ttsLang,
8092
+ ttsService: O.ttsService,
8093
+ ttsVoice: O.ttsVoice,
8094
+ ttsApiKey: O.ttsApiKey,
8095
+ bodyMovement: O.bodyMovement,
8096
+ movementIntensity: O.movementIntensity,
8097
+ showFullAvatar: O.showFullAvatar,
8376
8098
  cameraView: "upper",
8377
- animations: U.animations,
8099
+ animations: O.animations,
8378
8100
  onReady: le,
8379
8101
  onLoading: () => {
8380
8102
  },
8381
- onError: (R) => {
8382
- console.error("Avatar error:", R);
8103
+ onError: (v) => {
8104
+ console.error("Avatar error:", v);
8383
8105
  }
8384
8106
  }
8385
8107
  ) });
@@ -8488,7 +8210,7 @@ const Ge = {
8488
8210
  duration: 5e3,
8489
8211
  description: "Excited, energetic movement"
8490
8212
  }
8491
- }, wt = (X) => Ge[X] || null, zt = (X) => Ge.hasOwnProperty(X);
8213
+ }, wt = (G) => Ge[G] || null, zt = (G) => Ge.hasOwnProperty(G);
8492
8214
  export {
8493
8215
  yt as CurriculumLearning,
8494
8216
  gt as SimpleTalkingAvatar,