@algorisys/tinyfly 0.88.0 → 0.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,71 +1,71 @@
1
- import { c as mn, s as Je, p as Rt, b as lt } from "./sketch-CYPUbk3Q.js";
2
- import { a as xs } from "./sketch-CYPUbk3Q.js";
3
- import { createRandom as yn, hashSeed as wn, getEasingFunction as Le, mat4 as N, vec3 as U, quat as yt } from "@algorisys/tinyfly";
4
- import { f as wt, h as kn, a as Sn } from "./load-scene-CQvcFWGJ.js";
5
- function Ke(e, t, n) {
6
- const r = e.length;
7
- if (r < 2) return [];
8
- const o = [], s = [], i = (l) => t + (n - t) * l / (r - 1);
9
- return e.forEach((l, a) => {
10
- const h = e[Math.max(0, a - 1)], c = e[Math.min(r - 1, a + 1)], p = Math.hypot(c.x - h.x, c.y - h.y) || 1, d = i(a) / 2, u = -(c.y - h.y) / p * d, b = (c.x - h.x) / p * d;
11
- o.push({ x: l.x + u, y: l.y + b }), s.push({ x: l.x - u, y: l.y - b });
12
- }), [...o, ...s.reverse()];
13
- }
14
- function it(e, t, n, r) {
1
+ import { c as to, s as ut, p as mn, b as Ht } from "./sketch-CYPUbk3Q.js";
2
+ import { a as Zi } from "./sketch-CYPUbk3Q.js";
3
+ import { createRandom as no, hashSeed as Ze, getEasingFunction as Qe, mat4 as D, vec3 as J, quat as Ft, Timeline as oo } from "@algorisys/tinyfly";
4
+ import { f as Rt, h as so, a as ro } from "./load-scene-CQvcFWGJ.js";
5
+ function Ye(e, t, n) {
6
+ const s = e.length;
7
+ if (s < 2) return [];
8
+ const o = [], r = [], l = (i) => t + (n - t) * i / (s - 1);
9
+ return e.forEach((i, a) => {
10
+ const h = e[Math.max(0, a - 1)], c = e[Math.min(s - 1, a + 1)], u = Math.hypot(c.x - h.x, c.y - h.y) || 1, g = l(a) / 2, f = -(c.y - h.y) / u * g, p = (c.x - h.x) / u * g;
11
+ o.push({ x: i.x + f, y: i.y + p }), r.push({ x: i.x - f, y: i.y - p });
12
+ }), [...o, ...r.reverse()];
13
+ }
14
+ function vt(e, t, n, s) {
15
15
  const o = t.length;
16
16
  if (o < 2) return;
17
- const s = Ke(t, n, r), i = (l) => n + (r - n) * l / (o - 1);
18
- e.beginPath(), e.moveTo(s[0].x, s[0].y);
19
- for (const l of s.slice(1)) e.lineTo(l.x, l.y);
20
- e.closePath(), e.fill(), t.forEach((l, a) => {
21
- a !== 0 && a !== o - 1 && o > 3 || (e.beginPath(), e.arc(l.x, l.y, i(a) / 2, 0, Math.PI * 2), e.fill());
17
+ const r = Ye(t, n, s), l = (i) => n + (s - n) * i / (o - 1);
18
+ e.beginPath(), e.moveTo(r[0].x, r[0].y);
19
+ for (const i of r.slice(1)) e.lineTo(i.x, i.y);
20
+ e.closePath(), e.fill(), t.forEach((i, a) => {
21
+ a !== 0 && a !== o - 1 && o > 3 || (e.beginPath(), e.arc(i.x, i.y, l(a) / 2, 0, Math.PI * 2), e.fill());
22
22
  });
23
23
  }
24
- function de(e, t, n, r, o = 16) {
25
- const s = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, i = [];
26
- for (let l = 0; l <= o; l++) {
27
- const a = l / o, h = a < 0.5 ? { x: e.x + (t.x - e.x) * 2 * a, y: e.y + (t.y - e.y) * 2 * a } : { x: t.x + (n.x - t.x) * (2 * a - 1), y: t.y + (n.y - t.y) * (2 * a - 1) }, c = 1 - a, p = {
28
- x: c * c * e.x + 2 * c * a * s.x + a * a * n.x,
29
- y: c * c * e.y + 2 * c * a * s.y + a * a * n.y
24
+ function ke(e, t, n, s, o = 16) {
25
+ const r = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, l = [];
26
+ for (let i = 0; i <= o; i++) {
27
+ const a = i / o, h = a < 0.5 ? { x: e.x + (t.x - e.x) * 2 * a, y: e.y + (t.y - e.y) * 2 * a } : { x: t.x + (n.x - t.x) * (2 * a - 1), y: t.y + (n.y - t.y) * (2 * a - 1) }, c = 1 - a, u = {
28
+ x: c * c * e.x + 2 * c * a * r.x + a * a * n.x,
29
+ y: c * c * e.y + 2 * c * a * r.y + a * a * n.y
30
30
  };
31
- i.push({ x: h.x + (p.x - h.x) * r, y: h.y + (p.y - h.y) * r });
31
+ l.push({ x: h.x + (u.x - h.x) * s, y: h.y + (u.y - h.y) * s });
32
32
  }
33
- return i;
33
+ return l;
34
34
  }
35
- function kt(e, t, n, r, o, s = 0, i = 1, l = 40) {
35
+ function Lt(e, t, n, s, o, r = 0, l = 1, i = 40) {
36
36
  const a = Math.cos(o), h = Math.sin(o);
37
- return Array.from({ length: l + 1 }, (c, p) => {
38
- const d = s + Math.PI * 2 * i * p / l, u = Math.cos(d) * n, b = Math.sin(d) * r;
39
- return { x: e + u * a - b * h, y: t + u * h + b * a };
37
+ return Array.from({ length: i + 1 }, (c, u) => {
38
+ const g = r + Math.PI * 2 * l * u / i, f = Math.cos(g) * n, p = Math.sin(g) * s;
39
+ return { x: e + f * a - p * h, y: t + f * h + p * a };
40
40
  });
41
41
  }
42
- function Yt(e, t) {
43
- return t.look === "pencil" ? vn(e, t) : En(e, t.ink, t.look);
42
+ function bn(e, t) {
43
+ return t.look === "pencil" ? ho(e, t) : io(e, t.ink, t.look);
44
44
  }
45
- function Oe(e, t, n = !1) {
45
+ function Xe(e, t, n = !1) {
46
46
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
47
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
47
+ for (const s of t.slice(1)) e.lineTo(s.x, s.y);
48
48
  n && e.closePath();
49
49
  }
50
- function En(e, t, n) {
51
- const r = n === "silhouette", o = r ? 1.25 : 1;
50
+ function io(e, t, n) {
51
+ const s = n === "silhouette", o = s ? 1.25 : 1;
52
52
  return {
53
53
  look: n,
54
54
  ink: t,
55
- limb(s, i, l) {
56
- e.fillStyle = t, it(e, s, i * o, l * o);
55
+ limb(r, l, i) {
56
+ e.fillStyle = t, vt(e, r, l * o, i * o);
57
57
  },
58
- line(s, i) {
59
- s.length < 2 || (e.strokeStyle = t, e.lineWidth = i * o, e.lineCap = "round", e.lineJoin = "round", Oe(e, s), e.stroke());
58
+ line(r, l) {
59
+ r.length < 2 || (e.strokeStyle = t, e.lineWidth = l * o, e.lineCap = "round", e.lineJoin = "round", Xe(e, r), e.stroke());
60
60
  },
61
- shape(s, i, l) {
62
- Oe(e, s, !0), (i !== null || r) && (e.fillStyle = r ? t : i, e.fill()), !(l <= 0) && (e.strokeStyle = t, e.lineWidth = l * o, e.lineJoin = "round", e.stroke());
61
+ shape(r, l, i) {
62
+ Xe(e, r, !0), (l !== null || s) && (e.fillStyle = s ? t : l, e.fill()), !(i <= 0) && (e.strokeStyle = t, e.lineWidth = i * o, e.lineJoin = "round", e.stroke());
63
63
  },
64
- ellipse(s, i, l, a, h, c, p) {
65
- e.beginPath(), e.ellipse(s, i, l, a, h, 0, Math.PI * 2), (c !== null || r) && (e.fillStyle = r ? t : c, e.fill()), !(p <= 0) && (e.strokeStyle = t, e.lineWidth = p * o, e.stroke());
64
+ ellipse(r, l, i, a, h, c, u) {
65
+ e.beginPath(), e.ellipse(r, l, i, a, h, 0, Math.PI * 2), (c !== null || s) && (e.fillStyle = s ? t : c, e.fill()), !(u <= 0) && (e.strokeStyle = t, e.lineWidth = u * o, e.stroke());
66
66
  },
67
- dot(s, i, l) {
68
- e.fillStyle = t, e.beginPath(), e.arc(s, i, l * o, 0, Math.PI * 2), e.fill();
67
+ dot(r, l, i) {
68
+ e.fillStyle = t, e.beginPath(), e.arc(r, l, i * o, 0, Math.PI * 2), e.fill();
69
69
  },
70
70
  guide() {
71
71
  },
@@ -73,101 +73,101 @@ function En(e, t, n) {
73
73
  }
74
74
  };
75
75
  }
76
- function Hn(e, t) {
76
+ function lo(e, t) {
77
77
  const n = [e[0]];
78
- let r = 0;
79
- for (let i = 1; i < e.length; i++) {
80
- const l = e[i - 1], a = e[i], h = Math.hypot(a.x - l.x, a.y - l.y);
81
- let c = t - r;
78
+ let s = 0;
79
+ for (let l = 1; l < e.length; l++) {
80
+ const i = e[l - 1], a = e[l], h = Math.hypot(a.x - i.x, a.y - i.y);
81
+ let c = t - s;
82
82
  for (; c < h; ) {
83
- const p = c / h;
84
- n.push({ x: l.x + (a.x - l.x) * p, y: l.y + (a.y - l.y) * p }), c += t;
83
+ const u = c / h;
84
+ n.push({ x: i.x + (a.x - i.x) * u, y: i.y + (a.y - i.y) * u }), c += t;
85
85
  }
86
- r = h - (c - t);
86
+ s = h - (c - t);
87
87
  }
88
- const o = e[e.length - 1], s = n[n.length - 1];
89
- return Math.hypot(o.x - s.x, o.y - s.y) > t * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
88
+ const o = e[e.length - 1], r = n[n.length - 1];
89
+ return Math.hypot(o.x - r.x, o.y - r.y) > t * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
90
90
  }
91
- function Mn(e, t) {
91
+ function ao(e, t) {
92
92
  const n = e.length;
93
- return e.map((r, o) => {
94
- const s = e[Math.max(0, o - 1)], i = e[Math.min(n - 1, o + 1)], l = Math.hypot(i.x - s.x, i.y - s.y) || 1, a = t(n === 1 ? 0 : o / (n - 1));
95
- return { x: r.x - (i.y - s.y) / l * a, y: r.y + (i.x - s.x) / l * a };
93
+ return e.map((s, o) => {
94
+ const r = e[Math.max(0, o - 1)], l = e[Math.min(n - 1, o + 1)], i = Math.hypot(l.x - r.x, l.y - r.y) || 1, a = t(n === 1 ? 0 : o / (n - 1));
95
+ return { x: s.x - (l.y - r.y) / i * a, y: s.y + (l.x - r.x) / i * a };
96
96
  });
97
97
  }
98
- function St(e) {
99
- const t = [0.6, 1.4, 2.9].map((r) => ({
100
- frequency: r * (0.8 + e.next() * 0.4),
98
+ function Nt(e) {
99
+ const t = [0.6, 1.4, 2.9].map((s) => ({
100
+ frequency: s * (0.8 + e.next() * 0.4),
101
101
  phase: e.next() * Math.PI * 2,
102
102
  amount: 0.5 + e.next() * 0.5
103
- })), n = t.reduce((r, o) => r + o.amount, 0);
104
- return (r) => t.reduce((o, s) => o + s.amount * Math.sin(Math.PI * 2 * s.frequency * r + s.phase), 0) / n;
103
+ })), n = t.reduce((s, o) => s + o.amount, 0);
104
+ return (s) => t.reduce((o, r) => o + r.amount * Math.sin(Math.PI * 2 * r.frequency * s + r.phase), 0) / n;
105
105
  }
106
- function vn(e, t) {
107
- const n = t.pencil ?? {}, r = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), s = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), l = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = mn(t.time, n.boil ?? 8);
106
+ function ho(e, t) {
107
+ const n = t.pencil ?? {}, s = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), l = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = to(t.time, n.boil ?? 8);
108
108
  let h = 0;
109
- const c = (b, f, g = !1) => yn(wn(`${t.seed}:${g ? "paper" : a}:${b}:${f}`)), p = (b, f, g, m, k, y = 0) => {
110
- if (b.length < 2) return;
111
- const H = b.slice(1).reduce((K, v, T) => K + Math.hypot(v.x - b[T].x, v.y - b[T].y), 0);
112
- let E = Hn(b, Math.max(1.5, Math.min(t.lineWidth * 0.8, H / 24)));
113
- if (y > 0 && E.length >= 2) {
114
- const [K, v] = [E[E.length - 2], E[E.length - 1]], T = Math.hypot(v.x - K.x, v.y - K.y) || 1;
115
- E = [...E, { x: v.x + (v.x - K.x) / T * y, y: v.y + (v.y - K.y) / T * y }];
109
+ const c = (p, d, m = !1) => no(Ze(`${t.seed}:${m ? "paper" : a}:${p}:${d}`)), u = (p, d, m, b, y, E = 0) => {
110
+ if (p.length < 2) return;
111
+ const H = p.slice(1).reduce((v, T, K) => v + Math.hypot(T.x - p[K].x, T.y - p[K].y), 0);
112
+ let M = lo(p, Math.max(1.5, Math.min(t.lineWidth * 0.8, H / 24)));
113
+ if (E > 0 && M.length >= 2) {
114
+ const [v, T] = [M[M.length - 2], M[M.length - 1]], K = Math.hypot(T.x - v.x, T.y - v.y) || 1;
115
+ M = [...M, { x: T.x + (T.x - v.x) / K * E, y: T.y + (T.y - v.y) / K * E }];
116
116
  }
117
- const w = St(g), M = St(g), x = E.length, S = [], A = [];
118
- E.forEach((K, v) => {
119
- const T = x === 1 ? 0 : v / (x - 1), W = E[Math.max(0, v - 1)], B = E[Math.min(x - 1, v + 1)], P = Math.hypot(B.x - W.x, B.y - W.y) || 1, O = -(B.y - W.y) / P, F = (B.x - W.x) / P, I = w(T) * k, Y = Math.min(1, T / 0.08, (1 - T) / 0.08), X = (0.55 + 0.45 * Math.sqrt(Math.max(0, Y))) * (1 + i * M(T)), z = Math.max(0.3, f(T) * X / 2), ce = K.x + O * I, Ee = K.y + F * I;
120
- S.push({ x: ce + O * z, y: Ee + F * z }), A.push({ x: ce - O * z, y: Ee - F * z });
121
- }), e.save(), e.globalAlpha *= m, e.fillStyle = r, Oe(e, [...S, ...A.reverse()], !0), e.fill(), e.restore();
122
- }, d = (b, f) => {
123
- const g = h++, m = c(g, 99, !0);
124
- if (m.next() < l) {
125
- const E = (m.next() * 2 - 1) * t.lineWidth * 1.4, w = (m.next() * 2 - 1) * t.lineWidth * 1.4, M = b.map((x) => ({ x: x.x + E, y: x.y + w }));
126
- p(M, (x) => f(x) * 1.8, c(g, 98, !0), 0.035, o), p(M, (x) => f(x) * 0.45, c(g, 97, !0), 0.12, o * 1.5);
117
+ const A = Nt(m), w = Nt(m), S = M.length, k = [], x = [];
118
+ M.forEach((v, T) => {
119
+ const K = S === 1 ? 0 : T / (S - 1), P = M[Math.max(0, T - 1)], I = M[Math.min(S - 1, T + 1)], q = Math.hypot(I.x - P.x, I.y - P.y) || 1, G = -(I.y - P.y) / q, W = (I.x - P.x) / q, O = A(K) * y, F = Math.min(1, K / 0.08, (1 - K) / 0.08), $ = (0.55 + 0.45 * Math.sqrt(Math.max(0, F))) * (1 + l * w(K)), B = Math.max(0.3, d(K) * $ / 2), U = v.x + G * O, ne = v.y + W * O;
120
+ k.push({ x: U + G * B, y: ne + W * B }), x.push({ x: U - G * B, y: ne - W * B });
121
+ }), e.save(), e.globalAlpha *= b, e.fillStyle = s, Xe(e, [...k, ...x.reverse()], !0), e.fill(), e.restore();
122
+ }, g = (p, d) => {
123
+ const m = h++, b = c(m, 99, !0);
124
+ if (b.next() < i) {
125
+ const M = (b.next() * 2 - 1) * t.lineWidth * 1.4, A = (b.next() * 2 - 1) * t.lineWidth * 1.4, w = p.map((S) => ({ x: S.x + M, y: S.y + A }));
126
+ u(w, (S) => d(S) * 1.8, c(m, 98, !0), 0.035, o), u(w, (S) => d(S) * 0.45, c(m, 97, !0), 0.12, o * 1.5);
127
127
  }
128
- const k = b.slice(1).reduce((E, w, M) => E + Math.hypot(w.x - b[M].x, w.y - b[M].y), 0), y = f(0.5) > 4 && k > f(0.5) * 6, H = y ? [-0.3, 0.3, 0] : [0];
129
- for (let E = 0; E < s; E++) {
130
- const w = E === 0;
131
- H.forEach((M, x) => {
132
- const S = c(g, E * 10 + x), A = M === 0 ? b : Mn(b, (v) => f(v) * M * Math.sqrt(Math.sin(Math.PI * v))), K = !w && M === 0 ? t.lineWidth * (0.3 + S.next() * 0.8) : 0;
133
- p(A, (v) => f(v) * (y ? 0.5 : 1) * (w ? 1 : 0.6), S, w ? 0.85 : 0.45, o * (w ? 0.6 : 1), K);
128
+ const y = p.slice(1).reduce((M, A, w) => M + Math.hypot(A.x - p[w].x, A.y - p[w].y), 0), E = d(0.5) > 4 && y > d(0.5) * 6, H = E ? [-0.3, 0.3, 0] : [0];
129
+ for (let M = 0; M < r; M++) {
130
+ const A = M === 0;
131
+ H.forEach((w, S) => {
132
+ const k = c(m, M * 10 + S), x = w === 0 ? p : ao(p, (T) => d(T) * w * Math.sqrt(Math.sin(Math.PI * T))), v = !A && w === 0 ? t.lineWidth * (0.3 + k.next() * 0.8) : 0;
133
+ u(x, (T) => d(T) * (E ? 0.5 : 1) * (A ? 1 : 0.6), k, A ? 0.85 : 0.45, o * (A ? 0.6 : 1), v);
134
134
  });
135
135
  }
136
- }, u = (b, f, g, m, k, y) => {
137
- const E = c(h, 50).next() * Math.PI * 2;
138
- d(kt(b, f, g, m, k, E, 1.08, 48), () => y);
136
+ }, f = (p, d, m, b, y, E) => {
137
+ const M = c(h, 50).next() * Math.PI * 2;
138
+ g(Lt(p, d, m, b, y, M, 1.08, 48), () => E);
139
139
  };
140
140
  return {
141
141
  look: "pencil",
142
- ink: r,
143
- limb(b, f, g) {
144
- d(b, (m) => f + (g - f) * m);
142
+ ink: s,
143
+ limb(p, d, m) {
144
+ g(p, (b) => d + (m - d) * b);
145
145
  },
146
- line(b, f) {
147
- d(b, () => f);
146
+ line(p, d) {
147
+ g(p, () => d);
148
148
  },
149
- shape(b, f, g) {
150
- f !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = f, Oe(e, b, !0), e.fill(), e.restore()), g > 0 && d([...b, b[0]], () => g);
149
+ shape(p, d, m) {
150
+ d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Xe(e, p, !0), e.fill(), e.restore()), m > 0 && g([...p, p[0]], () => m);
151
151
  },
152
- ellipse(b, f, g, m, k, y, H) {
153
- y !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = y, e.beginPath(), e.ellipse(b, f, g, m, k, 0, Math.PI * 2), e.fill(), e.restore()), u(b, f, g, m, k, H);
152
+ ellipse(p, d, m, b, y, E, H) {
153
+ E !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = E, e.beginPath(), e.ellipse(p, d, m, b, y, 0, Math.PI * 2), e.fill(), e.restore()), f(p, d, m, b, y, H);
154
154
  },
155
- dot(b, f, g) {
156
- e.save(), e.globalAlpha *= 0.9, e.fillStyle = r, e.beginPath(), e.arc(b, f, g, 0, Math.PI * 2), e.fill(), e.restore();
155
+ dot(p, d, m) {
156
+ e.save(), e.globalAlpha *= 0.9, e.fillStyle = s, e.beginPath(), e.arc(p, d, m, 0, Math.PI * 2), e.fill(), e.restore();
157
157
  },
158
- guide(b) {
159
- if (n.construction === !1 || b.length < 2) return;
160
- const f = h++;
161
- p(b, () => Math.max(0.6, t.lineWidth * 0.18), c(f, 0), 0.28, o * 1.2, t.lineWidth);
158
+ guide(p) {
159
+ if (n.construction === !1 || p.length < 2) return;
160
+ const d = h++;
161
+ u(p, () => Math.max(0.6, t.lineWidth * 0.18), c(d, 0), 0.28, o * 1.2, t.lineWidth);
162
162
  },
163
- guideEllipse(b, f, g, m, k) {
163
+ guideEllipse(p, d, m, b, y) {
164
164
  if (n.construction === !1) return;
165
- const y = h++, H = c(y, 0), E = kt(b, f, g, m, k, H.next() * Math.PI * 2, 1.12, 48);
166
- p(E, () => Math.max(0.6, t.lineWidth * 0.18), H, 0.28, o * 1.5);
165
+ const E = h++, H = c(E, 0), M = Lt(p, d, m, b, y, H.next() * Math.PI * 2, 1.12, 48);
166
+ u(M, () => Math.max(0.6, t.lineWidth * 0.18), H, 0.28, o * 1.5);
167
167
  }
168
168
  };
169
169
  }
170
- const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
170
+ const co = ["thumb", "index", "middle", "ring", "pinky"], L = {
171
171
  "thumb.curl": 0.15,
172
172
  "thumb.across": 0.15,
173
173
  "index.curl": 0.12,
@@ -180,59 +180,59 @@ const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
180
180
  tilt: 0,
181
181
  roll: 0
182
182
  };
183
- function $(e = {}) {
184
- return { ..._, ...e };
183
+ function R(e = {}) {
184
+ return { ...L, ...e };
185
185
  }
186
- const q = (e, t, n, r, o) => ({
186
+ const j = (e, t, n, s, o) => ({
187
187
  "thumb.curl": e,
188
188
  "index.curl": t,
189
189
  "middle.curl": n,
190
- "ring.curl": r,
190
+ "ring.curl": s,
191
191
  "pinky.curl": o
192
- }), L = {
193
- relaxed: _,
194
- open: $({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
195
- spread: $({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
196
- flat: $({ ...q(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
197
- fist: $({ ...q(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
198
- point: $({ ...q(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
192
+ }), C = {
193
+ relaxed: L,
194
+ open: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
195
+ spread: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
196
+ flat: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
197
+ fist: R({ ...j(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
198
+ point: R({ ...j(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
199
199
  /** The fist on its side, knuckles toward the viewer, the thumb up */
200
- thumbsUp: $({ ...q(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
201
- peace: $({ ...q(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
202
- ok: $({ ...q(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
203
- pinch: $({ ...q(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
204
- cupped: $({ ...q(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
205
- wave: $({ ...q(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
200
+ thumbsUp: R({ ...j(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
201
+ peace: R({ ...j(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
202
+ ok: R({ ...j(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
203
+ pinch: R({ ...j(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
204
+ cupped: R({ ...j(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
205
+ wave: R({ ...j(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
206
206
  /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
207
- pencilGrip: $({ ...q(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
207
+ pencilGrip: R({ ...j(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
208
208
  /** Holding a handle, a cup or a bar: every finger wrapped round it */
209
- hold: $({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
+ hold: R({ ...j(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
210
210
  };
211
- function ke(e, t, n) {
212
- const r = { ...e };
213
- for (const [o, s] of Object.entries(t)) {
214
- const i = e[o] ?? s;
215
- r[o] = i + (s - i) * n;
211
+ function Ke(e, t, n) {
212
+ const s = { ...e };
213
+ for (const [o, r] of Object.entries(t)) {
214
+ const l = e[o] ?? r;
215
+ s[o] = l + (r - l) * n;
216
216
  }
217
- return r;
217
+ return s;
218
218
  }
219
- const Tn = {
219
+ const fo = {
220
220
  index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
221
221
  middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
222
222
  ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
223
223
  pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
224
- }, An = {
224
+ }, uo = {
225
225
  index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
226
226
  middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
227
227
  pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
228
- }, ne = {
228
+ }, se = {
229
229
  base: [-0.11, 0.1, -0.05],
230
230
  bones: [0.2, 0.15, 0.12],
231
231
  widths: [0.2, 0.145, 0.135],
232
232
  /** Where the thumb points with `across` 0 and 1 */
233
233
  out: [-0.7, 0.68, -0.22],
234
234
  across: [0.35, 0.5, -0.8]
235
- }, Kn = [82, 100, 62], Pn = [48, 72], Wn = 3, On = 13, In = 0.035, Bn = -0.075, $n = [
235
+ }, go = [82, 100, 62], po = [48, 72], mo = 3, bo = 13, wo = 0.035, yo = -0.075, ko = [
236
236
  [-0.17, 0],
237
237
  [-0.215, 0.12],
238
238
  [-0.235, 0.26],
@@ -245,186 +245,229 @@ const Tn = {
245
245
  [0.225, 0.26],
246
246
  [0.2, 0.1],
247
247
  [0.16, 0]
248
- ], se = (e) => e * Math.PI / 180, Ve = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Pe = (e, t) => [e[0] * t, e[1] * t, e[2] * t], je = (e, t) => [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]], pe = (e) => {
248
+ ], ae = (e) => e * Math.PI / 180, dt = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Ce = (e, t) => [e[0] * t, e[1] * t, e[2] * t], gt = (e, t) => [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]], Ee = (e) => {
249
249
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
250
250
  return [e[0] / t, e[1] / t, e[2] / t];
251
251
  };
252
- function ae(e, t, n) {
253
- const r = Math.cos(n), o = Math.sin(n), s = je(t, e), i = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
252
+ function de(e, t, n) {
253
+ const s = Math.cos(n), o = Math.sin(n), r = gt(t, e), l = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
254
254
  return [
255
- e[0] * r + s[0] * o + t[0] * i * (1 - r),
256
- e[1] * r + s[1] * o + t[1] * i * (1 - r),
257
- e[2] * r + s[2] * o + t[2] * i * (1 - r)
255
+ e[0] * s + r[0] * o + t[0] * l * (1 - s),
256
+ e[1] * s + r[1] * o + t[1] * l * (1 - s),
257
+ e[2] * s + r[2] * o + t[2] * l * (1 - s)
258
258
  ];
259
259
  }
260
- const Et = [1, 0, 0], Ht = [0, 1, 0], ye = [0, 0, 1];
261
- function _n(e, t, n) {
262
- const r = se(e.fan * (Wn + On * n)), o = [Math.sin(r), Math.cos(r), 0], s = [Math.cos(r), -Math.sin(r), 0], i = [e.knuckle];
263
- let l = 0;
264
- e.bones.forEach((c, p) => {
265
- l += se(Kn[p] * t), i.push(Ve(i[p], Pe(ae(o, s, -l), c)));
260
+ const Yt = [1, 0, 0], Ct = [0, 1, 0], Ae = [0, 0, 1];
261
+ function So(e, t, n) {
262
+ const s = ae(e.fan * (mo + bo * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], l = [e.knuckle];
263
+ let i = 0;
264
+ e.bones.forEach((c, u) => {
265
+ i += ae(go[u] * t), l.push(dt(l[u], Ce(de(o, r, -i), c)));
266
266
  });
267
- const a = ae(ye, s, -l), h = i.map((c, p) => e.width * (1 - 0.14 * (p / (i.length - 1))));
268
- return { joints: i, back: a, widths: h };
267
+ const a = de(Ae, r, -i), h = l.map((c, u) => e.width * (1 - 0.14 * (u / (l.length - 1))));
268
+ return { joints: l, back: a, widths: h };
269
269
  }
270
- function Fn(e, t, n = 1, r = 1) {
271
- const o = Math.min(1, Math.max(0, t)), s = pe(Ve(Pe(pe(ne.out), 1 - o), Pe(pe(ne.across), o))), i = pe(je(ye, s)), l = pe(je(s, i)), a = [[ne.base[0] * r, ne.base[1], ne.base[2]]];
270
+ function Eo(e, t, n = 1, s = 1) {
271
+ const o = Math.min(1, Math.max(0, t)), r = Ee(dt(Ce(Ee(se.out), 1 - o), Ce(Ee(se.across), o))), l = Ee(gt(Ae, r)), i = Ee(gt(r, l)), a = [[se.base[0] * s, se.base[1], se.base[2]]];
272
272
  let h = 0;
273
- ne.bones.forEach((d, u) => {
274
- u > 0 && (h += se(Pn[u - 1] * e)), a.push(Ve(a[u], Pe(ae(s, i, h), d)));
273
+ se.bones.forEach((g, f) => {
274
+ f > 0 && (h += ae(po[f - 1] * e)), a.push(dt(a[f], Ce(de(r, l, h), g)));
275
275
  });
276
- const c = ae(l, i, h), p = [...ne.widths, ne.widths[ne.widths.length - 1] * 0.92].map((d) => d * n);
277
- return { joints: a, back: c, widths: p };
278
- }
279
- function Ze(e, t = {}) {
280
- const n = { ..._, ...e }, r = t.size ?? 100, o = t.side ?? "right", s = o === "left" ? -1 : 1, i = se(t.angle ?? 0), l = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (v) => ({
281
- ...v,
282
- knuckle: [v.knuckle[0] * h, v.knuckle[1], v.knuckle[2]],
283
- width: v.width * a
284
- }), p = se(n.bend ?? 0), d = se(n.tilt ?? 0), u = se(90 * (n.turn ?? 0)), b = (v) => ae(ae(ae(v, Et, -p), ye, -d), Ht, u), f = Math.cos(i), g = Math.sin(i), m = se(n.roll ?? 0), k = Math.cos(m), y = Math.sin(m), H = (v) => {
285
- const T = v[0] * r, W = -v[1] * r, B = (T * k - W * y) * s, P = T * y + W * k;
286
- return { x: B * f - P * g, y: B * g + P * f };
287
- }, E = (v) => {
288
- const T = H(v), W = Math.hypot(T.x, T.y);
289
- return W > 1e-6 * r ? { x: T.x / W, y: T.y / W } : { x: 0, y: 0 };
290
- }, w = {
291
- thumb: Fn(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
292
- }, M = l ? An : Tn;
293
- for (const v of xn) {
294
- const T = M[v];
295
- T && (w[v] = _n(c(T), n[`${v}.curl`] ?? 0, n.spread ?? 0));
296
- }
297
- const x = {};
298
- for (const [v, T] of Object.entries(w)) {
299
- const W = T.joints.map(b), B = b(T.back);
300
- x[v] = {
301
- points: W.map(H),
302
- depths: W.map((P) => P[2] * r),
303
- widths: T.widths.map((P) => P * r),
304
- nail: B[2],
305
- back: E(B)
276
+ const c = de(i, l, h), u = [...se.widths, se.widths[se.widths.length - 1] * 0.92].map((g) => g * n);
277
+ return { joints: a, back: c, widths: u };
278
+ }
279
+ function pt(e, t = {}) {
280
+ const n = { ...L, ...e }, s = t.size ?? 100, o = t.side ?? "right", r = o === "left" ? -1 : 1, l = ae(t.angle ?? 0), i = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (T) => ({
281
+ ...T,
282
+ knuckle: [T.knuckle[0] * h, T.knuckle[1], T.knuckle[2]],
283
+ width: T.width * a
284
+ }), u = ae(n.bend ?? 0), g = ae(n.tilt ?? 0), f = ae(90 * (n.turn ?? 0)), p = (T) => de(de(de(T, Yt, -u), Ae, -g), Ct, f), d = Math.cos(l), m = Math.sin(l), b = ae(n.roll ?? 0), y = Math.cos(b), E = Math.sin(b), H = (T) => {
285
+ const K = T[0] * s, P = -T[1] * s, I = (K * y - P * E) * r, q = K * E + P * y;
286
+ return { x: I * d - q * m, y: I * m + q * d };
287
+ }, M = (T) => {
288
+ const K = H(T), P = Math.hypot(K.x, K.y);
289
+ return P > 1e-6 * s ? { x: K.x / P, y: K.y / P } : { x: 0, y: 0 };
290
+ }, A = {
291
+ thumb: Eo(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
292
+ }, w = i ? uo : fo;
293
+ for (const T of co) {
294
+ const K = w[T];
295
+ K && (A[T] = So(c(K), n[`${T}.curl`] ?? 0, n.spread ?? 0));
296
+ }
297
+ const S = {};
298
+ for (const [T, K] of Object.entries(A)) {
299
+ const P = K.joints.map(p), I = p(K.back);
300
+ S[T] = {
301
+ points: P.map(H),
302
+ depths: P.map((q) => q[2] * s),
303
+ widths: K.widths.map((q) => q * s),
304
+ nail: I[2],
305
+ back: M(I)
306
306
  };
307
307
  }
308
- const S = $n.flatMap(([v, T]) => [b([v * h, T, In]), b([v * h, T, Bn])]), A = Yn(S.map(H)), K = S.reduce((v, T) => v + T[2], 0) / S.length * r;
308
+ const k = ko.flatMap(([T, K]) => [p([T * h, K, wo]), p([T * h, K, yo])]), x = Ho(k.map(H)), v = k.reduce((T, K) => T + K[2], 0) / k.length * s;
309
309
  return {
310
- size: r,
310
+ size: s,
311
311
  side: o,
312
312
  wrist: { x: 0, y: 0 },
313
- palm: A,
314
- palmDepth: K,
315
- palmFacing: -b(ye)[2],
316
- fingers: x,
317
- axes: { up: E(b(Ht)), across: E(b(Et)), out: E(b(ye)) },
318
- curls: Object.fromEntries(Object.keys(x).map((v) => [v, n[`${v}.curl`] ?? 0]))
313
+ palm: x,
314
+ palmDepth: v,
315
+ palmFacing: -p(Ae)[2],
316
+ fingers: S,
317
+ axes: { up: M(p(Ct)), across: M(p(Yt)), out: M(p(Ae)) },
318
+ curls: Object.fromEntries(Object.keys(S).map((T) => [T, n[`${T}.curl`] ?? 0]))
319
319
  };
320
320
  }
321
- function Rn(e, t) {
322
- const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), r = {};
323
- for (const [o, s] of Object.entries(e.fingers))
324
- r[o] = { ...s, points: s.points.map(n) };
325
- return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: r };
321
+ function Mo(e, t) {
322
+ const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), s = {};
323
+ for (const [o, r] of Object.entries(e.fingers))
324
+ s[o] = { ...r, points: r.points.map(n) };
325
+ return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: s };
326
326
  }
327
- function Yn(e) {
328
- const t = [...e].sort((s, i) => s.x - i.x || s.y - i.y);
327
+ function Ho(e) {
328
+ const t = [...e].sort((r, l) => r.x - l.x || r.y - l.y);
329
329
  if (t.length < 3) return t;
330
- const n = (s, i, l) => (i.x - s.x) * (l.y - s.y) - (i.y - s.y) * (l.x - s.x), r = [];
331
- for (const s of t) {
332
- for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], s) <= 0; ) r.pop();
333
- r.push(s);
330
+ const n = (r, l, i) => (l.x - r.x) * (i.y - r.y) - (l.y - r.y) * (i.x - r.x), s = [];
331
+ for (const r of t) {
332
+ for (; s.length >= 2 && n(s[s.length - 2], s[s.length - 1], r) <= 0; ) s.pop();
333
+ s.push(r);
334
334
  }
335
335
  const o = [];
336
- for (const s of [...t].reverse()) {
337
- for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], s) <= 0; ) o.pop();
338
- o.push(s);
339
- }
340
- return [...r.slice(0, -1), ...o.slice(0, -1)];
341
- }
342
- const Ln = "#f1c9a5", Nn = "#2f2f33";
343
- function at(e, t, n, r = {}, o = 0) {
344
- const s = Rn(Ze(n, r), t), i = r.ink ?? Nn, l = r.lineWidth ?? s.size * 0.035, a = r.pen ?? Yt(e, {
345
- look: r.look ?? "clean",
346
- ink: i,
347
- lineWidth: l,
348
- seed: r.seed ?? 1,
336
+ for (const r of [...t].reverse()) {
337
+ for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], r) <= 0; ) o.pop();
338
+ o.push(r);
339
+ }
340
+ return [...s.slice(0, -1), ...o.slice(0, -1)];
341
+ }
342
+ const vo = "#f1c9a5", To = "#2f2f33";
343
+ function Tt(e, t, n, s = {}, o = 0) {
344
+ const r = Mo(pt(n, s), t), l = s.ink ?? To, i = s.lineWidth ?? r.size * 0.035, a = s.pen ?? bn(e, {
345
+ look: s.look ?? "clean",
346
+ ink: l,
347
+ lineWidth: i,
348
+ seed: s.seed ?? 1,
349
349
  time: o,
350
- pencil: { construction: !1, ...r.pencil }
351
- }), h = r.skin ?? Ln, c = r.nails ?? !0, p = [
350
+ pencil: { construction: !1, ...s.pencil }
351
+ }), h = s.skin ?? vo, c = s.nails ?? !0, u = [
352
352
  {
353
- depth: s.palmDepth,
354
- draw: () => Cn(a, s, h, l)
353
+ depth: r.palmDepth,
354
+ draw: () => Ao(a, r, h, i)
355
355
  }
356
356
  ];
357
- for (const d of Object.values(s.fingers)) {
358
- const u = d.depths.reduce((b, f) => b + f, 0) / d.depths.length;
359
- p.push({
360
- depth: u,
361
- draw: () => Dn(e, a, d, h, l, c)
357
+ for (const g of Object.values(r.fingers)) {
358
+ const f = g.depths.reduce((p, d) => p + d, 0) / g.depths.length;
359
+ u.push({
360
+ depth: f,
361
+ draw: () => xo(e, a, g, h, i, c)
362
362
  });
363
363
  }
364
- if (r.prop) {
365
- const d = r.prop;
366
- p.push({ depth: d.depth, draw: () => d.draw(a) });
364
+ if (s.prop) {
365
+ const g = s.prop;
366
+ u.push({ depth: g.depth, draw: () => g.draw(a) });
367
367
  }
368
368
  e.save(), e.lineCap = "round", e.lineJoin = "round";
369
- for (const d of [...p].sort((u, b) => u.depth - b.depth)) d.draw();
370
- return e.restore(), s;
369
+ for (const g of [...u].sort((f, p) => f.depth - p.depth)) g.draw();
370
+ return e.restore(), r;
371
371
  }
372
- function Cn(e, t, n, r) {
373
- if (e.shape(t.palm, n, r), t.palmFacing < -0.3 && e.look !== "silhouette") {
372
+ function Ao(e, t, n, s) {
373
+ if (e.shape(t.palm, n, s), t.palmFacing < -0.3 && e.look !== "silhouette") {
374
374
  const { up: o } = t.axes;
375
- for (const [s, i] of Object.entries(t.fingers)) {
376
- const l = t.curls[s] ?? 0;
377
- if (s === "thumb" || l < 0.5) continue;
378
- const a = i.points[0], h = i.widths[0] * 0.42, c = { x: a.x - o.x * h * 0.2, y: a.y - o.y * h * 0.2 }, p = Math.atan2(o.y, o.x), d = Array.from({ length: 7 }, (u, b) => {
379
- const f = p - Math.PI / 2 + Math.PI * b / 6;
380
- return { x: c.x + Math.cos(f) * h, y: c.y + Math.sin(f) * h };
375
+ for (const [r, l] of Object.entries(t.fingers)) {
376
+ const i = t.curls[r] ?? 0;
377
+ if (r === "thumb" || i < 0.5) continue;
378
+ const a = l.points[0], h = l.widths[0] * 0.42, c = { x: a.x - o.x * h * 0.2, y: a.y - o.y * h * 0.2 }, u = Math.atan2(o.y, o.x), g = Array.from({ length: 7 }, (f, p) => {
379
+ const d = u - Math.PI / 2 + Math.PI * p / 6;
380
+ return { x: c.x + Math.cos(d) * h, y: c.y + Math.sin(d) * h };
381
381
  });
382
- e.line(d, r * 0.6);
382
+ e.line(g, s * 0.6);
383
383
  }
384
384
  }
385
385
  if (t.palmFacing > 0.45 && e.look !== "silhouette") {
386
- const { up: o, across: s } = t.axes, i = t.size, l = t.wrist, a = (c, p) => ({
387
- x: l.x + (s.x * c + o.x * p) * i,
388
- y: l.y + (s.y * c + o.y * p) * i
386
+ const { up: o, across: r } = t.axes, l = t.size, i = t.wrist, a = (c, u) => ({
387
+ x: i.x + (r.x * c + o.x * u) * l,
388
+ y: i.y + (r.y * c + o.y * u) * l
389
389
  }), h = t.side === "left" ? -1 : 1;
390
- e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], r * 0.5);
390
+ e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], s * 0.5);
391
391
  }
392
392
  }
393
- function Dn(e, t, n, r, o, s) {
394
- const { widths: i } = n, l = Xn(n.points, 2), a = n.points[0], h = l[l.length - 1], c = i[0], p = i[i.length - 1];
393
+ function xo(e, t, n, s, o, r) {
394
+ const { widths: l } = n, i = Ko(n.points, 2), a = n.points[0], h = i[i.length - 1], c = l[0], u = l[l.length - 1];
395
395
  if (e.save(), t.look !== "silhouette") {
396
396
  e.beginPath(), e.rect(a.x - 1e5, a.y - 1e5, 2e5, 2e5);
397
- const f = c / 2 + o * 1.6;
398
- e.moveTo(a.x + f, a.y), e.arc(a.x, a.y, f, 0, Math.PI * 2), e.clip("evenodd");
397
+ const d = c / 2 + o * 1.6;
398
+ e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
399
399
  }
400
- if (t.limb(l, c + 2 * o, p + 2 * o), e.restore(), t.look !== "silhouette" && (e.fillStyle = r, it(e, l, c, p)), t.look === "silhouette" || !s || n.nail < 0.25) return;
401
- const d = l[l.length - 2], u = qn({ x: h.x - d.x, y: h.y - d.y }) ?? {
400
+ if (t.limb(i, c + 2 * o, u + 2 * o), e.restore(), t.look !== "silhouette" && (e.fillStyle = s, vt(e, i, c, u)), t.look === "silhouette" || !r || n.nail < 0.25) return;
401
+ const g = i[i.length - 2], f = Po({ x: h.x - g.x, y: h.y - g.y }) ?? {
402
402
  x: 0,
403
403
  y: -1
404
- }, b = {
405
- x: h.x - u.x * p * 0.22 + n.back.x * p * 0.1,
406
- y: h.y - u.y * p * 0.22 + n.back.y * p * 0.1
404
+ }, p = {
405
+ x: h.x - f.x * u * 0.22 + n.back.x * u * 0.1,
406
+ y: h.y - f.y * u * 0.22 + n.back.y * u * 0.1
407
407
  };
408
- t.ellipse(b.x, b.y, p * 0.24 * Math.max(0.35, n.nail), p * 0.19, Math.atan2(u.y, u.x), "#f8e3d3", o * 0.45);
408
+ t.ellipse(p.x, p.y, u * 0.24 * Math.max(0.35, n.nail), u * 0.19, Math.atan2(f.y, f.x), "#f8e3d3", o * 0.45);
409
409
  }
410
- function Xn(e, t) {
410
+ function Ko(e, t) {
411
411
  let n = e;
412
- for (let r = 0; r < t; r++) {
412
+ for (let s = 0; s < t; s++) {
413
413
  if (n.length < 3) return n;
414
414
  const o = [n[0]];
415
- for (let s = 0; s < n.length - 1; s++) {
416
- const i = n[s], l = n[s + 1];
417
- s > 0 && o.push({ x: i.x * 0.75 + l.x * 0.25, y: i.y * 0.75 + l.y * 0.25 }), s < n.length - 2 && o.push({ x: i.x * 0.25 + l.x * 0.75, y: i.y * 0.25 + l.y * 0.75 });
415
+ for (let r = 0; r < n.length - 1; r++) {
416
+ const l = n[r], i = n[r + 1];
417
+ r > 0 && o.push({ x: l.x * 0.75 + i.x * 0.25, y: l.y * 0.75 + i.y * 0.25 }), r < n.length - 2 && o.push({ x: l.x * 0.25 + i.x * 0.75, y: l.y * 0.25 + i.y * 0.75 });
418
418
  }
419
419
  o.push(n[n.length - 1]), n = o;
420
420
  }
421
421
  return n;
422
422
  }
423
- const qn = (e) => {
423
+ const Po = (e) => {
424
424
  const t = Math.hypot(e.x, e.y);
425
425
  return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
426
- }, J = {
426
+ }, we = {
427
+ walk: { swing: 24, knee: 30, arm: 22, elbow: 28, lean: 4 },
428
+ bouncy: { swing: 26, knee: 45, arm: 34, elbow: 30, lean: 2, bend: -4, bounce: 0.035, squash: 0.06 },
429
+ doubleBounce: { swing: 22, knee: 40, arm: 26, elbow: 24, lean: 3, bounce: 0.02, bounces: 2, squash: 0.04 },
430
+ sneak: { swing: 28, knee: 70, arm: 6, elbow: 0, forearm: 110, shoulder: 55, lean: 16, bend: 14, headTilt: -8, crouch: 50, tiptoe: 25 },
431
+ strut: { swing: 26, knee: 30, arm: 30, elbow: 20, lean: -4, bend: -10, headTilt: -6, sway: 4, bounce: 0.01 },
432
+ tired: { swing: 14, knee: 14, arm: 6, elbow: 6, lean: 10, bend: 16, headTilt: 12 },
433
+ run: { swing: 40, knee: 95, arm: 45, elbow: 0, forearm: 90, lean: 16, bend: 6, bounce: 0.05, squash: 0.06 }
434
+ }, Wo = 40;
435
+ function wn(e) {
436
+ return e === void 0 ? we.walk : typeof e == "string" ? we[e] ?? we.walk : e;
437
+ }
438
+ function Oo(e, t, n = _, s = 1) {
439
+ const o = wn(e);
440
+ if (o === we.walk) return $o(t, n, s);
441
+ const r = t * Math.PI * 2, l = Math.sin(r) * s, i = Math.cos(r) * s, a = (b) => b <= Wo, h = o.shoulder ?? 0, c = (b, y) => a(b) ? y * h + o.arm * l : b, u = o.forearm ?? 0, g = a(n.leftShoulder) ? n.leftElbow - u - o.elbow * Math.max(0, -l) : n.leftElbow, f = a(n.rightShoulder) ? n.rightElbow + u + o.elbow * Math.max(0, l) : n.rightElbow, p = o.bounces ?? 1, d = (1 + Math.cos(r * 2 * p)) / 2, m = o.crouch ?? 0;
442
+ return {
443
+ ...n,
444
+ lean: n.lean + o.lean * s + (o.sway ?? 0) * Math.sin(r) * (1 - (n.turn ?? 0)),
445
+ bend: (n.bend ?? 0) + (o.bend ?? 0),
446
+ headTilt: n.headTilt - o.lean * 0.5 * s + (o.headTilt ?? 0),
447
+ leftElbow: g,
448
+ rightElbow: f,
449
+ // A crouch brings both thighs forward and folds both shins back.
450
+ leftHip: -o.swing * l - m * 0.5,
451
+ rightHip: -o.swing * l + m * 0.5,
452
+ // The leg swinging forward lifts its knee; a crouch keeps both bent. A positive
453
+ // knee folds toward the centre, which is backward only for the right leg.
454
+ leftKnee: -o.knee * Math.max(0, i) - m,
455
+ rightKnee: o.knee * Math.max(0, -i) + m,
456
+ leftAnkle: (n.leftAnkle ?? 0) + (o.tiptoe ?? 0),
457
+ rightAnkle: (n.rightAnkle ?? 0) + (o.tiptoe ?? 0),
458
+ leftShoulder: c(n.leftShoulder, -1),
459
+ rightShoulder: c(n.rightShoulder, 1),
460
+ rise: (n.rise ?? 0) + (o.bounce ?? 0) * s * d,
461
+ stretch: n.stretch * (1 + (o.squash ?? 0) * (d - 0.5))
462
+ };
463
+ }
464
+ function Io(e, t, n = 1) {
465
+ const s = wn(e), o = we.walk.swing, r = (l) => Math.sin(l * Math.PI / 180);
466
+ return Bo(t, n) * r(s.swing * n) / r(o * n);
467
+ }
468
+ const _ = {
427
469
  lean: 0,
470
+ bend: 0,
428
471
  headTilt: 0,
429
472
  leftShoulder: 18,
430
473
  rightShoulder: 18,
@@ -457,10 +500,10 @@ const qn = (e) => {
457
500
  spin: 0,
458
501
  rise: 0
459
502
  };
460
- function C(e) {
461
- return { ...J, ...e };
503
+ function z(e) {
504
+ return { ..._, ...e };
462
505
  }
463
- const Lt = {
506
+ const yn = {
464
507
  mouth: 0,
465
508
  smile: 0,
466
509
  mouthWidth: 1,
@@ -471,200 +514,223 @@ const Lt = {
471
514
  browTilt: 0,
472
515
  lookX: 0,
473
516
  lookY: 0
474
- }, R = (e) => ({ ...Lt, ...e }), Z = {
475
- neutral: Lt,
476
- happy: R({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
477
- joyful: R({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
478
- sad: R({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
479
- crying: R({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
480
- surprised: R({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
481
- shocked: R({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
482
- angry: R({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
483
- furious: R({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
484
- worried: R({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
485
- scared: R({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
486
- confused: R({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
487
- skeptical: R({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
488
- thinking: R({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
489
- sleepy: R({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
490
- disgusted: R({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
491
- smug: R({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
492
- wink: R({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
517
+ }, N = (e) => ({ ...yn, ...e }), Y = {
518
+ neutral: yn,
519
+ happy: N({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
520
+ joyful: N({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
521
+ sad: N({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
522
+ crying: N({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
523
+ surprised: N({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
524
+ shocked: N({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
525
+ angry: N({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
526
+ furious: N({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
527
+ worried: N({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
528
+ scared: N({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
529
+ confused: N({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
530
+ skeptical: N({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
531
+ thinking: N({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
532
+ sleepy: N({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
533
+ disgusted: N({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
534
+ smug: N({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
535
+ wink: N({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
493
536
  };
494
- function Nt(e, t) {
495
- return { ...e, ...typeof t == "string" ? Z[t] : t };
496
- }
497
- const Un = {
498
- rest: J,
499
- wave: C({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...Z.happy }),
500
- cheer: C({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...Z.joyful }),
501
- shrug: C({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...Z.confused, lookX: 0, lookY: 0 }),
502
- point: C({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
537
+ function qe(e, t) {
538
+ return { ...e, ...typeof t == "string" ? Y[t] : t };
539
+ }
540
+ const Oe = {
541
+ rest: _,
542
+ wave: z({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...Y.happy }),
543
+ cheer: z({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...Y.joyful }),
544
+ shrug: z({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...Y.confused, lookX: 0, lookY: 0 }),
545
+ point: z({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
503
546
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
504
- think: C({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...Z.thinking }),
505
- handsOnHips: C({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
506
- sad: C({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...Z.sad }),
507
- surprised: C({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...Z.surprised }),
547
+ think: z({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...Y.thinking }),
548
+ handsOnHips: z({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
549
+ sad: z({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...Y.sad }),
550
+ surprised: z({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...Y.surprised }),
508
551
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
509
- crouch: C({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
552
+ crouch: z({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
510
553
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
511
554
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
512
- sit: C({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
513
- jump: C({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...Z.joyful }),
555
+ sit: z({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
556
+ jump: z({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...Y.joyful }),
514
557
  // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
515
558
  // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
516
- sideSplit: C({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Z.happy }),
559
+ sideSplit: z({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Y.happy }),
517
560
  // Front split, in profile: the left leg forward (+x), the right leg back.
518
- frontSplit: C({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...Z.happy })
519
- }, Ct = Object.keys(J);
520
- function Se(e, t, n) {
521
- const r = { ...e };
522
- for (const o of Ct) r[o] = e[o] + (t[o] - e[o]) * n;
523
- return r;
561
+ frontSplit: z({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...Y.happy })
562
+ }, kn = Object.keys(_);
563
+ function Pe(e, t, n) {
564
+ const s = { ...e };
565
+ for (const o of kn) s[o] = e[o] + (t[o] - e[o]) * n;
566
+ return s;
524
567
  }
525
- const Qe = 24, Mt = 4, vt = 28, zn = 40;
526
- function Gn(e, t = J, n = 1) {
527
- const r = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, s = (h) => h <= zn, i = (h) => s(h) ? 22 * r : h, l = s(t.leftShoulder) ? t.leftElbow - vt * Math.max(0, -r) : t.leftElbow, a = s(t.rightShoulder) ? t.rightElbow + vt * Math.max(0, r) : t.rightElbow;
568
+ const mt = 24, Dt = 4, Xt = 28, _o = 40;
569
+ function $o(e, t = _, n = 1) {
570
+ const s = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, r = (h) => h <= _o, l = (h) => r(h) ? 22 * s : h, i = r(t.leftShoulder) ? t.leftElbow - Xt * Math.max(0, -s) : t.leftElbow, a = r(t.rightShoulder) ? t.rightElbow + Xt * Math.max(0, s) : t.rightElbow;
528
571
  return {
529
572
  ...t,
530
573
  // Lean into the walk, and keep the head a little more level than the body.
531
- lean: t.lean + Mt * n,
532
- headTilt: t.headTilt - Mt * 0.5 * n,
533
- leftElbow: l,
574
+ lean: t.lean + Dt * n,
575
+ headTilt: t.headTilt - Dt * 0.5 * n,
576
+ leftElbow: i,
534
577
  rightElbow: a,
535
578
  // Left foot forward while swing > 0, right foot back; then the other way.
536
- leftHip: -Qe * r,
537
- rightHip: -Qe * r,
579
+ leftHip: -mt * s,
580
+ rightHip: -mt * s,
538
581
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
539
582
  // knee folds toward the centre, which is backward only for the right leg.
540
583
  leftKnee: -30 * Math.max(0, o),
541
584
  rightKnee: 30 * Math.max(0, -o),
542
585
  // Arms swing against the legs: left arm back while the left foot is forward.
543
- leftShoulder: i(t.leftShoulder),
544
- rightShoulder: i(t.rightShoulder)
586
+ leftShoulder: l(t.leftShoulder),
587
+ rightShoulder: l(t.rightShoulder)
545
588
  };
546
589
  }
547
- function Ur(e, t = 1) {
548
- return 4 * ((et + Ie) * e) * Math.sin(Qe * t * Math.PI / 180);
590
+ function Bo(e, t = 1) {
591
+ return 4 * ((bt + Ge) * e) * Math.sin(mt * t * Math.PI / 180);
549
592
  }
550
- function Jn(e) {
593
+ function Fo(e) {
551
594
  const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
552
595
  return t * n;
553
596
  }
554
- const Dt = 0.12, xt = 0.46, Vn = 1 - 2 * Dt, jn = 0.1, Zn = 0.21, Qn = 0.19, et = 0.24, Ie = 0.22, Xt = 0.12, eo = 0.14, qt = 0.33, Tt = 0.7, At = 0.3, to = 0.35, no = [1.7, 1.05], oo = [1.3, 0.75], Kt = [1.45, 0.85], ro = [1.15, 0.75], Pt = 0.06, so = 0.7, lo = 0.65, Ut = 0.075, io = 0.3, ao = 0.02, ho = 0.012, co = 12, fo = 0.25, He = 90, uo = 0.25, go = 0.04, zt = 0.01, ie = (e) => Math.min(1, Math.max(0, e ?? 0));
555
- function zr(e, t = 1) {
556
- return Ie * e * t;
597
+ const Sn = 0.12, qt = 0.46, Ro = 1 - 2 * Sn, Lo = 0.1, No = 0.21, Yo = 0.19, bt = 0.24, Ge = 0.22, En = 0.12, Co = 0.14, Mn = 0.33, Gt = 0.7, Ut = 0.3, Do = 0.35, Xo = [1.7, 1.05], qo = [1.3, 0.75], zt = [1.45, 0.85], Go = [1.15, 0.75], Vt = 0.06, Uo = 0.7, zo = 0.65, Hn = 0.075, Vo = 0.3, jo = 0.02, Jo = 0.012, Zo = 12, Qo = 0.25, Ie = 90, es = 0.25, ts = 0.04, vn = 0.01, fe = (e) => Math.min(1, Math.max(0, e ?? 0));
598
+ function gi(e, t = 1) {
599
+ return Ge * e * t;
557
600
  }
558
- const tt = -0.12, Gt = 0.4, ee = (e) => e * Math.PI / 180, po = (e, t) => ({ x: t * Math.sin(ee(e)), y: Math.cos(ee(e)) }), Jt = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), Vt = (e, t, n, r) => e - 0.3 * t - n * 0.14 * t - Math.max(0, r - 1) * 0.12 * t;
559
- function bo(e, t, n, r, o, s) {
560
- const i = Math.max(1, Math.min(s * 0.6, eo * n)), l = ie(t.turn), a = (Xt + qt * l) * n, h = r + tt * n, c = a + t.lookX * 0.08 * n, p = t.lookY * 0.07 * n, d = [
601
+ const wt = -0.12, Tn = 0.4, Q = (e) => e * Math.PI / 180, ns = (e, t) => ({ x: t * Math.sin(Q(e)), y: Math.cos(Q(e)) }), An = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), xn = (e, t, n, s) => e - 0.3 * t - n * 0.14 * t - Math.max(0, s - 1) * 0.12 * t;
602
+ function os(e, t, n, s, o, r) {
603
+ const l = Math.max(1, Math.min(r * 0.6, Co * n)), i = fe(t.turn), a = (En + Mn * i) * n, h = s + wt * n, c = a + t.lookX * 0.08 * n, u = t.lookY * 0.07 * n, g = [
561
604
  // The left eye is on the far side; turning closes it up more than the near one.
562
- { x: -0.34 * n * (1 - Tt * l), squeeze: 1 - Tt * l, open: t.leftEye, brow: t.leftBrow, side: -1 },
563
- { x: 0.34 * n * (1 - At * l), squeeze: 1 - At * l, open: t.rightEye, brow: t.rightBrow, side: 1 }
605
+ { x: -0.34 * n * (1 - Gt * i), squeeze: 1 - Gt * i, open: t.leftEye, brow: t.leftBrow, side: -1 },
606
+ { x: 0.34 * n * (1 - Ut * i), squeeze: 1 - Ut * i, open: t.rightEye, brow: t.rightBrow, side: 1 }
564
607
  ];
565
- e.fillStyle = o, e.strokeStyle = o, e.lineWidth = i;
566
- for (const m of d) {
567
- const k = Jt(m.open, t.blink);
568
- if (k < 0.2) {
569
- const w = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
570
- e.beginPath(), e.moveTo(m.x + a - 0.12 * n, h), e.quadraticCurveTo(m.x + a, h + w, m.x + a + 0.12 * n, h), e.stroke();
608
+ e.fillStyle = o, e.strokeStyle = o, e.lineWidth = l;
609
+ for (const b of g) {
610
+ const y = An(b.open, t.blink);
611
+ if (y < 0.2) {
612
+ const A = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
613
+ e.beginPath(), e.moveTo(b.x + a - 0.12 * n, h), e.quadraticCurveTo(b.x + a, h + A, b.x + a + 0.12 * n, h), e.stroke();
571
614
  } else {
572
- if (k > 1.2) {
573
- const M = 0.13 * n * k;
574
- e.beginPath(), e.ellipse(m.x + a, h, M * 0.85, M, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
615
+ if (y > 1.2) {
616
+ const w = 0.13 * n * y;
617
+ e.beginPath(), e.ellipse(b.x + a, h, w * 0.85, w, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
575
618
  }
576
- const w = k > 1.2 ? 0.075 * n : 0.1 * n;
577
- e.beginPath(), e.ellipse(m.x + c, h + p, w, w * 1.1 * Math.min(k, 1), 0, 0, Math.PI * 2), e.fill();
619
+ const A = y > 1.2 ? 0.075 * n : 0.1 * n;
620
+ e.beginPath(), e.ellipse(b.x + c, h + u, A, A * 1.1 * Math.min(y, 1), 0, 0, Math.PI * 2), e.fill();
578
621
  }
579
- const y = Vt(h, n, m.brow, k), H = m.x + a - m.side * 0.13 * n * m.squeeze, E = m.x + a + m.side * 0.13 * n * m.squeeze;
580
- e.beginPath(), e.moveTo(E, y), e.lineTo(H, y - t.browTilt * 0.1 * n), e.stroke();
622
+ const E = xn(h, n, b.brow, y), H = b.x + a - b.side * 0.13 * n * b.squeeze, M = b.x + a + b.side * 0.13 * n * b.squeeze;
623
+ e.beginPath(), e.moveTo(M, E), e.lineTo(H, E - t.browTilt * 0.1 * n), e.stroke();
581
624
  }
582
- const u = r + Gt * n, b = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - to * l), f = Math.min(1, Math.max(0, t.mouth));
583
- if (e.beginPath(), f <= 0.05) {
584
- e.moveTo(a - b, u), e.quadraticCurveTo(a, u + t.smile * 0.25 * n, a + b, u), e.stroke();
625
+ const f = s + Tn * n, p = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Do * i), d = Math.min(1, Math.max(0, t.mouth));
626
+ if (e.beginPath(), d <= 0.05) {
627
+ e.moveTo(a - p, f), e.quadraticCurveTo(a, f + t.smile * 0.25 * n, a + p, f), e.stroke();
585
628
  return;
586
629
  }
587
- const g = 0.3 * n * f;
588
- t.smile > 0.3 ? (e.moveTo(a - b, u - 0.05 * n), e.lineTo(a + b, u - 0.05 * n), e.quadraticCurveTo(a, u + g * 2, a - b, u - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - b, u + g * 0.6), e.lineTo(a + b, u + g * 0.6), e.quadraticCurveTo(a, u - g * 1.4, a - b, u + g * 0.6)) : e.ellipse(a, u, b * 0.8, g, 0, 0, Math.PI * 2), e.fill();
589
- }
590
- function jt(e, t) {
591
- const n = t.height ?? 300, r = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(r), s = (t.headSize ?? 2 * Dt) / 2, i = t.headSize === void 0 ? Vn : 1 - 2 * s, l = s * n, a = ie(e.sit), h = e.leftHip + (-He - e.leftHip) * a, c = e.leftKnee + (-He - e.leftKnee) * a, p = e.rightHip + (He - e.rightHip) * a, d = e.rightKnee + (He - e.rightKnee) * a, u = t.classic === !0, b = ie(e.turn), f = (P, O, F, I, Y) => {
592
- const X = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(ee(O - F) / 2) + ee(I))), z = Math.max(-1, Math.min(1, so + Y)), ce = b + (1 - b) * P * z;
593
- return u ? { x: 0, y: 0 } : { x: Math.cos(X) * Pt * ce, y: Math.sin(X) * Pt };
594
- }, g = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, m = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
595
- let k = 0;
596
- if (a > 0 || !u) {
597
- const P = (Y, X, z, ce, Ee) => et * Math.cos(ee(X)) + Ie * Math.cos(ee(X - z)) + Math.max(0, f(Y, X, z, ce, Ee).y), O = Math.max(
598
- P(-1, h, c, g.left, m.left),
599
- P(1, p, d, g.right, m.right)
600
- ), F = 1 - ie((e.rise ?? 0) / go), I = (u ? Math.min(1, a / uo) : 1) * F;
601
- k = (xt - O) * I * n * r;
602
- }
603
- const y = -xt * n * r + k, H = -i * n * r + k, E = u ? 0 : (ao * ie(e.turn) + ho * a) * n * r, w = E === 0 ? [{ x: 0, y }, { x: 0, y: H }] : de({ x: 0, y }, { x: -E, y: (y + H) / 2 }, { x: 0, y: H }, 1, 8), M = H + jn * n * r, x = (t.shoulderWidth ?? 0) * n * Math.cos(b * Math.PI / 2), S = (P, O, F, I, Y) => {
604
- const X = po(F, I);
605
- return { x: P + X.x * Y * n, y: O + X.y * Y * n };
606
- }, A = (P, O, F) => {
607
- const I = S(0, y, O, P, et * r);
608
- return { root: { x: 0, y }, joint: I, end: S(I.x, I.y, O - F, P, Ie * r) };
609
- }, K = (P, O, F) => {
610
- const I = { x: P * x, y: M }, Y = S(I.x, I.y, O, P, Zn * o);
611
- return { root: I, joint: Y, end: S(Y.x, Y.y, O + F, P, Qn * o) };
612
- }, v = { left: A(-1, h, c), right: A(1, p, d) }, T = (P, O, F, I, Y, X) => {
613
- const z = f(P, F, I, Y, X);
614
- return { x: O.end.x + z.x * n * r, y: O.end.y + z.y * n * r };
615
- }, W = (P, O, F, I, Y) => S(O.end.x, O.end.y, F + I + Y, P, Ut * o), B = {
630
+ const m = 0.3 * n * d;
631
+ t.smile > 0.3 ? (e.moveTo(a - p, f - 0.05 * n), e.lineTo(a + p, f - 0.05 * n), e.quadraticCurveTo(a, f + m * 2, a - p, f - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - p, f + m * 0.6), e.lineTo(a + p, f + m * 0.6), e.quadraticCurveTo(a, f - m * 1.4, a - p, f + m * 0.6)) : e.ellipse(a, f, p * 0.8, m, 0, 0, Math.PI * 2), e.fill();
632
+ }
633
+ function Kn(e, t) {
634
+ const n = t.height ?? 300, s = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(s), r = (t.headSize ?? 2 * Sn) / 2, l = t.headSize === void 0 ? Ro : 1 - 2 * r, i = r * n, a = fe(e.sit), h = e.leftHip + (-Ie - e.leftHip) * a, c = e.leftKnee + (-Ie - e.leftKnee) * a, u = e.rightHip + (Ie - e.rightHip) * a, g = e.rightKnee + (Ie - e.rightKnee) * a, f = t.classic === !0, p = fe(e.turn), d = (W, O, F, $, B) => {
635
+ const U = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Q(O - F) / 2) + Q($))), ne = Math.max(-1, Math.min(1, Uo + B)), et = p + (1 - p) * W * ne;
636
+ return f ? { x: 0, y: 0 } : { x: Math.cos(U) * Vt * et, y: Math.sin(U) * Vt };
637
+ }, m = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, b = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
638
+ let y = 0;
639
+ if (a > 0 || !f) {
640
+ const W = (B, U, ne, et, eo) => bt * Math.cos(Q(U)) + Ge * Math.cos(Q(U - ne)) + Math.max(0, d(B, U, ne, et, eo).y), O = Math.max(
641
+ W(-1, h, c, m.left, b.left),
642
+ W(1, u, g, m.right, b.right)
643
+ ), F = 1 - fe((e.rise ?? 0) / ts), $ = (f ? Math.min(1, a / es) : 1) * F;
644
+ y = (qt - O) * $ * n * s;
645
+ }
646
+ const E = -qt * n * s + y, H = -l * n * s + y, M = f ? 0 : (jo * fe(e.turn) + Jo * a) * n * s, A = Q(e.bend ?? 0), w = { end: Jt(E, H, A, 1), bend: A };
647
+ let S;
648
+ if (A !== 0) {
649
+ S = [];
650
+ for (let W = 0; W <= jt; W++) {
651
+ const O = W / jt, F = Jt(E, H, A, O);
652
+ S.push({ x: F.x - M * Math.sin(Math.PI * O), y: F.y });
653
+ }
654
+ } else
655
+ S = M === 0 ? [{ x: 0, y: E }, { x: 0, y: H }] : ke({ x: 0, y: E }, { x: -M, y: (E + H) / 2 }, { x: 0, y: H }, 1, 8);
656
+ const k = H + Lo * n * s, x = (t.shoulderWidth ?? 0) * n * Math.cos(p * Math.PI / 2), v = (W, O, F, $, B) => {
657
+ const U = ns(F, $);
658
+ return { x: W + U.x * B * n, y: O + U.y * B * n };
659
+ }, T = (W, O, F) => {
660
+ const $ = v(0, E, O, W, bt * s);
661
+ return { root: { x: 0, y: E }, joint: $, end: v($.x, $.y, O - F, W, Ge * s) };
662
+ }, K = (W, O, F) => {
663
+ const $ = { x: W * x, y: k }, B = v($.x, $.y, O, W, No * o);
664
+ return { root: $, joint: B, end: v(B.x, B.y, O + F, W, Yo * o) };
665
+ }, P = { left: T(-1, h, c), right: T(1, u, g) }, I = (W, O, F, $, B, U) => {
666
+ const ne = d(W, F, $, B, U);
667
+ return { x: O.end.x + ne.x * n * s, y: O.end.y + ne.y * n * s };
668
+ }, q = (W, O, F, $, B) => v(O.end.x, O.end.y, F + $ + B, W, Hn * o), G = {
616
669
  left: K(-1, e.leftShoulder, e.leftElbow),
617
670
  right: K(1, e.rightShoulder, e.rightElbow)
618
671
  };
619
672
  return {
620
673
  height: n,
621
674
  facing: (t.facing ?? 1) < 0 ? -1 : 1,
622
- stretch: r,
675
+ stretch: s,
623
676
  lineWidth: t.lineWidth ?? n * 0.025,
624
- rubber: Math.min(1, Math.max(u ? 0 : io, t.rubber ?? 0)),
625
- r: l,
677
+ rubber: Math.min(1, Math.max(f ? 0 : Vo, t.rubber ?? 0)),
678
+ r: i,
626
679
  // The head keeps its area: taller and narrower when stretched.
627
- headRx: l / Math.sqrt(r),
628
- headRy: l * Math.sqrt(r),
629
- hipY: y,
680
+ headRx: i / Math.sqrt(s),
681
+ headRy: i * Math.sqrt(s),
682
+ hipY: E,
630
683
  neckY: H,
631
- drop: k,
632
- lean: u ? e.lean : e.lean + co * Math.sin(Math.PI * a),
633
- classic: u,
634
- legs: v,
684
+ drop: y,
685
+ lean: f ? e.lean : e.lean + Zo * Math.sin(Math.PI * a),
686
+ classic: f,
687
+ legs: P,
635
688
  toes: {
636
- left: T(-1, v.left, h, c, g.left, m.left),
637
- right: T(1, v.right, p, d, g.right, m.right)
689
+ left: I(-1, P.left, h, c, m.left, b.left),
690
+ right: I(1, P.right, u, g, m.right, b.right)
638
691
  },
639
- spine: w,
640
- arms: B,
692
+ spine: S,
693
+ chest: w,
694
+ arms: G,
641
695
  handTips: {
642
- left: W(-1, B.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
643
- right: W(1, B.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
696
+ left: q(-1, G.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
697
+ right: q(1, G.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
644
698
  }
645
699
  };
646
700
  }
647
- const be = (e, t) => t === 0 ? [e.root, e.joint, e.end] : de(e.root, e.joint, e.end, t);
648
- function Be(e, t, n) {
649
- const r = Math.cos(n), o = Math.sin(n), s = e.x - t.x, i = e.y - t.y;
650
- return { x: t.x + s * r - i * o, y: t.y + s * o + i * r };
651
- }
652
- function Zt(e, t, n = !0) {
653
- const r = yo(e, t), o = t.spin ?? 0, s = t.rise ?? 0;
654
- return n && (o !== 0 || s !== 0) ? mo(r, e, o, s) : r;
655
- }
656
- function Qt(e, t, n) {
657
- return { pivot: { x: 0, y: e.hipY }, angle: e.facing * ee(t), lift: n * e.height };
658
- }
659
- function mo(e, t, n, r) {
660
- const { pivot: o, angle: s, lift: i } = Qt(t, n, r), l = (d) => {
661
- const u = Be(d, o, s);
662
- return { x: u.x, y: u.y - i };
663
- }, a = (d) => ({ left: l(d.left), right: l(d.right) }), h = { left: Math.max(l(e.feet.left).y, l(e.toes.left).y), right: Math.max(l(e.feet.right).y, l(e.toes.right).y) }, c = Math.max(h.left, h.right), p = zt * t.height;
701
+ const jt = 10;
702
+ function Jt(e, t, n, s) {
703
+ const o = e - t, r = n * s;
704
+ if (Math.abs(n) < 1e-9) return { x: 0, y: e - o * s };
705
+ const l = o / n;
706
+ return { x: l * (1 - Math.cos(r)), y: e - l * Math.sin(r) };
707
+ }
708
+ function ss(e, t) {
709
+ if (e.chest.bend === 0) return t;
710
+ const n = We(t, { x: 0, y: e.neckY }, e.chest.bend);
711
+ return { x: n.x + e.chest.end.x, y: n.y + e.chest.end.y - e.neckY };
712
+ }
713
+ const ve = (e, t) => t === 0 ? [e.root, e.joint, e.end] : ke(e.root, e.joint, e.end, t);
714
+ function We(e, t, n) {
715
+ const s = Math.cos(n), o = Math.sin(n), r = e.x - t.x, l = e.y - t.y;
716
+ return { x: t.x + r * s - l * o, y: t.y + r * o + l * s };
717
+ }
718
+ function Pn(e, t, n = !0) {
719
+ const s = is(e, t), o = t.spin ?? 0, r = t.rise ?? 0;
720
+ return n && (o !== 0 || r !== 0) ? rs(s, e, o, r) : s;
721
+ }
722
+ function Wn(e, t, n) {
723
+ return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Q(t), lift: n * e.height };
724
+ }
725
+ function rs(e, t, n, s) {
726
+ const { pivot: o, angle: r, lift: l } = Wn(t, n, s), i = (g) => {
727
+ const f = We(g, o, r);
728
+ return { x: f.x, y: f.y - l };
729
+ }, a = (g) => ({ left: i(g.left), right: i(g.right) }), h = { left: Math.max(i(e.feet.left).y, i(e.toes.left).y), right: Math.max(i(e.feet.right).y, i(e.toes.right).y) }, c = Math.max(h.left, h.right), u = vn * t.height;
664
730
  return {
665
731
  ...e,
666
- hip: l(e.hip),
667
- neck: l(e.neck),
732
+ hip: i(e.hip),
733
+ neck: i(e.neck),
668
734
  shoulders: a(e.shoulders),
669
735
  elbows: a(e.elbows),
670
736
  hands: a(e.hands),
@@ -673,32 +739,32 @@ function mo(e, t, n, r) {
673
739
  feet: a(e.feet),
674
740
  toes: a(e.toes),
675
741
  feetY: c,
676
- grounded: { left: h.left >= c - p, right: h.right >= c - p },
677
- handAngle: { left: e.handAngle.left + s, right: e.handAngle.right + s },
742
+ grounded: { left: h.left >= c - u, right: h.right >= c - u },
743
+ handAngle: { left: e.handAngle.left + r, right: e.handAngle.right + r },
678
744
  limbs: {
679
- leftArm: e.limbs.leftArm.map(l),
680
- rightArm: e.limbs.rightArm.map(l),
681
- leftLeg: e.limbs.leftLeg.map(l),
682
- rightLeg: e.limbs.rightLeg.map(l),
683
- spine: e.limbs.spine.map(l)
745
+ leftArm: e.limbs.leftArm.map(i),
746
+ rightArm: e.limbs.rightArm.map(i),
747
+ leftLeg: e.limbs.leftLeg.map(i),
748
+ rightLeg: e.limbs.rightLeg.map(i),
749
+ spine: e.limbs.spine.map(i)
684
750
  },
685
- head: { ...e.head, center: l(e.head.center), angle: e.head.angle + s }
751
+ head: { ...e.head, center: i(e.head.center), angle: e.head.angle + r }
686
752
  };
687
753
  }
688
- function yo(e, t) {
689
- const n = ee(e.lean), r = ee(t.headTilt), o = { x: 0, y: e.hipY }, s = (y) => ({ x: e.facing * y.x, y: y.y }), i = (y) => s(Be(y, o, n)), l = (y) => i(Be({ x: y.x, y: y.y + e.neckY }, { x: 0, y: e.neckY }, r)), a = be(e.arms.left, e.rubber).map(i), h = be(e.arms.right, e.rubber).map(i), c = (y, H) => Math.atan2(H.y - y.y, H.x - y.x), p = { left: i(e.handTips.left), right: i(e.handTips.right) }, d = (y, H) => {
690
- const [E, w] = y.slice(-2), M = e.arms[H], x = c(i(M.end), p[H]) - c(i(M.joint), i(M.end));
691
- return c(E, w) + x;
754
+ function is(e, t) {
755
+ const n = Q(e.lean), s = Q(t.headTilt), o = { x: 0, y: e.hipY }, r = (H) => ({ x: e.facing * H.x, y: H.y }), l = (H) => r(We(H, o, n)), i = (H) => l(ss(e, H)), a = (H) => i(We({ x: H.x, y: H.y + e.neckY }, { x: 0, y: e.neckY }, s)), h = ve(e.arms.left, e.rubber).map(i), c = ve(e.arms.right, e.rubber).map(i), u = (H, M) => Math.atan2(M.y - H.y, M.x - H.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, f = (H, M) => {
756
+ const [A, w] = H.slice(-2), S = e.arms[M], k = u(i(S.end), g[M]) - u(i(S.joint), i(S.end));
757
+ return u(A, w) + k;
692
758
  };
693
- let u = 1 / 0;
694
- for (const [y, H] of [
759
+ let p = 1 / 0;
760
+ for (const [H, M] of [
695
761
  [t.leftBrow, t.leftEye],
696
762
  [t.rightBrow, t.rightEye]
697
763
  ]) {
698
- const E = Vt(tt, 1, y, Jt(H, t.blink));
699
- u = Math.min(u, E, E - t.browTilt * 0.1);
764
+ const A = xn(wt, 1, H, An(M, t.blink));
765
+ p = Math.min(p, A, A - t.browTilt * 0.1);
700
766
  }
701
- const b = { left: s(e.legs.left.end), right: s(e.legs.right.end) }, f = { left: s(e.toes.left), right: s(e.toes.right) }, g = { left: Math.max(b.left.y, f.left.y), right: Math.max(b.right.y, f.right.y) }, m = Math.max(g.left, g.right), k = zt * e.height;
767
+ const d = { left: r(e.legs.left.end), right: r(e.legs.right.end) }, m = { left: r(e.toes.left), right: r(e.toes.right) }, b = { left: Math.max(d.left.y, m.left.y), right: Math.max(d.right.y, m.right.y) }, y = Math.max(b.left, b.right), E = vn * e.height;
702
768
  return {
703
769
  facing: e.facing,
704
770
  height: e.height,
@@ -709,45 +775,45 @@ function yo(e, t) {
709
775
  shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
710
776
  elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
711
777
  hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
712
- knees: { left: s(e.legs.left.joint), right: s(e.legs.right.joint) },
713
- feet: b,
714
- toes: f,
715
- feetY: m,
716
- grounded: { left: g.left >= m - k, right: g.right >= m - k },
717
- fingertips: p,
718
- handAngle: { left: d(a, "left"), right: d(h, "right") },
778
+ knees: { left: r(e.legs.left.joint), right: r(e.legs.right.joint) },
779
+ feet: d,
780
+ toes: m,
781
+ feetY: y,
782
+ grounded: { left: b.left >= y - E, right: b.right >= y - E },
783
+ fingertips: g,
784
+ handAngle: { left: f(h, "left"), right: f(c, "right") },
719
785
  limbs: {
720
- leftArm: a,
721
- rightArm: h,
722
- leftLeg: be(e.legs.left, e.rubber).map(s),
723
- rightLeg: be(e.legs.right, e.rubber).map(s),
724
- spine: e.spine.map(i)
786
+ leftArm: h,
787
+ rightArm: c,
788
+ leftLeg: ve(e.legs.left, e.rubber).map(r),
789
+ rightLeg: ve(e.legs.right, e.rubber).map(r),
790
+ spine: e.spine.map(l)
725
791
  },
726
792
  head: {
727
- center: l({ x: 0, y: -e.headRy }),
793
+ center: a({ x: 0, y: -e.headRy }),
728
794
  rx: e.headRx,
729
795
  ry: e.headRy,
730
796
  // Mirroring a turn reverses it.
731
- angle: e.facing * (n + r),
732
- eyeY: tt,
733
- browTopY: u,
734
- mouthY: Gt,
735
- faceX: e.facing * (Xt + qt * ie(t.turn))
797
+ angle: e.facing * (n + e.chest.bend + s),
798
+ eyeY: wt,
799
+ browTopY: p,
800
+ mouthY: Tn,
801
+ faceX: e.facing * (En + Mn * fe(t.turn))
736
802
  }
737
803
  };
738
804
  }
739
- function wo(e, t = {}) {
740
- return Zt(jt(e, t), e);
805
+ function ls(e, t = {}) {
806
+ return Pn(Kn(e, t), e);
741
807
  }
742
- function Gr(e, t, n) {
743
- return Be({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
808
+ function pi(e, t, n) {
809
+ return We({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
744
810
  }
745
- function ko(e, t, n) {
746
- const r = (s) => ({ x: s.x + t, y: s.y + n }), o = (s) => ({ left: r(s.left), right: r(s.right) });
811
+ function as(e, t, n) {
812
+ const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => ({ left: s(r.left), right: s(r.right) });
747
813
  return {
748
814
  ...e,
749
- hip: r(e.hip),
750
- neck: r(e.neck),
815
+ hip: s(e.hip),
816
+ neck: s(e.neck),
751
817
  shoulders: o(e.shoulders),
752
818
  elbows: o(e.elbows),
753
819
  hands: o(e.hands),
@@ -758,212 +824,220 @@ function ko(e, t, n) {
758
824
  grounded: { ...e.grounded },
759
825
  handAngle: { ...e.handAngle },
760
826
  limbs: {
761
- leftArm: e.limbs.leftArm.map(r),
762
- rightArm: e.limbs.rightArm.map(r),
763
- leftLeg: e.limbs.leftLeg.map(r),
764
- rightLeg: e.limbs.rightLeg.map(r),
765
- spine: e.limbs.spine.map(r)
827
+ leftArm: e.limbs.leftArm.map(s),
828
+ rightArm: e.limbs.rightArm.map(s),
829
+ leftLeg: e.limbs.leftLeg.map(s),
830
+ rightLeg: e.limbs.rightLeg.map(s),
831
+ spine: e.limbs.spine.map(s)
766
832
  },
767
- head: { ...e.head, center: r(e.head.center) }
833
+ head: { ...e.head, center: s(e.head.center) }
768
834
  };
769
835
  }
770
- function So(e, t, n = {}, r = 0) {
771
- const o = jt(t, n), s = n.color ?? "#1e293b", i = n.layers ?? {}, l = n.layers ? Zt(o, t, !1) : void 0, a = n.sketch ? Je(e, n.sketch, r) : void 0, h = n.sketch && n.layers ? Je(e, n.sketch, r) : void 0, c = (w) => {
836
+ function hs(e, t, n = {}, s = 0) {
837
+ const o = Kn(t, n), r = n.color ?? "#1e293b", l = n.layers ?? {}, i = n.layers ? Pn(o, t, !1) : void 0, a = n.sketch ? ut(e, n.sketch, s) : void 0, h = n.sketch && n.layers ? ut(e, n.sketch, s) : void 0, c = (w) => {
772
838
  e.save(), w(), e.restore();
773
- }, p = (w) => {
774
- w && l && c(() => w(e, l, r, h));
775
- }, d = () => e.scale(o.facing, 1), u = () => {
776
- d(), e.translate(0, o.hipY), e.rotate(ee(o.lean)), e.translate(0, -o.hipY);
777
- }, b = (w, M, x) => {
778
- if (a) return M ? a.curve(w) : a.line(w);
839
+ }, u = (w) => {
840
+ w && i && c(() => w(e, i, s, h));
841
+ }, g = () => e.scale(o.facing, 1), f = () => {
842
+ g(), e.translate(0, o.hipY), e.rotate(Q(o.lean)), e.translate(0, -o.hipY);
843
+ }, p = () => {
844
+ f(), o.chest.bend !== 0 && (e.translate(o.chest.end.x, o.chest.end.y), e.rotate(o.chest.bend), e.translate(0, -o.neckY));
845
+ }, d = (w, S, k) => {
846
+ if (a) return S ? a.curve(w) : a.line(w);
779
847
  if (o.classic) {
780
848
  e.beginPath(), e.moveTo(w[0].x, w[0].y);
781
- for (const S of w.slice(1)) e.lineTo(S.x, S.y);
849
+ for (const x of w.slice(1)) e.lineTo(x.x, x.y);
782
850
  e.stroke();
783
851
  return;
784
852
  }
785
- it(e, w, x[0] * o.lineWidth, x[1] * o.lineWidth);
786
- }, f = (w, M) => b(be(w, o.rubber), o.rubber > 0, M), g = (w) => {
787
- o.classic || b([o.legs[w].end, o.toes[w]], !1, ro);
788
- }, m = (w) => {
789
- if (n.hands && !o.classic) return y(w);
853
+ vt(e, w, k[0] * o.lineWidth, k[1] * o.lineWidth);
854
+ }, m = (w, S) => d(ve(w, o.rubber), o.rubber > 0, S), b = (w) => {
855
+ o.classic || d([o.legs[w].end, o.toes[w]], !1, Go);
856
+ }, y = (w) => {
857
+ if (n.hands && !o.classic) return H(w);
790
858
  if (o.classic || a) return;
791
- const M = o.arms[w].end;
792
- e.beginPath(), e.arc(M.x, M.y, lo * o.lineWidth, 0, Math.PI * 2), e.fill();
859
+ const S = o.arms[w].end;
860
+ e.beginPath(), e.arc(S.x, S.y, zo * o.lineWidth, 0, Math.PI * 2), e.fill();
793
861
  };
794
- e.save(), e.strokeStyle = s, e.fillStyle = s, e.lineWidth = o.lineWidth, e.lineCap = "round", e.lineJoin = "round";
795
- const k = Qt(o, t.spin ?? 0, t.rise ?? 0);
796
- (k.angle !== 0 || k.lift !== 0) && (e.translate(0, -k.lift), e.translate(k.pivot.x, k.pivot.y), e.rotate(k.angle), e.translate(-k.pivot.x, -k.pivot.y));
797
- function y(w) {
798
- const M = n.hands ?? {}, x = o.arms[w].end, S = o.handTips[w], A = n.headFill ?? "#ffffff";
799
- at(e, x, M[w] ?? _, {
862
+ e.save(), e.strokeStyle = r, e.fillStyle = r, e.lineWidth = o.lineWidth, e.lineCap = "round", e.lineJoin = "round";
863
+ const E = Wn(o, t.spin ?? 0, t.rise ?? 0);
864
+ (E.angle !== 0 || E.lift !== 0) && (e.translate(0, -E.lift), e.translate(E.pivot.x, E.pivot.y), e.rotate(E.angle), e.translate(-E.pivot.x, -E.pivot.y));
865
+ function H(w) {
866
+ const S = n.hands ?? {}, k = o.arms[w].end, x = o.handTips[w], v = n.headFill ?? "#ffffff";
867
+ Tt(e, k, S[w] ?? L, {
800
868
  side: w,
801
869
  // Degrees clockwise from straight up, in the frame the hand is drawn in.
802
- angle: Math.atan2(S.x - x.x, x.y - S.y) * 180 / Math.PI,
803
- size: (M.size ?? Ut) * o.height * Math.sqrt(o.stretch),
804
- skin: M.skin ?? (A === "none" ? void 0 : A),
805
- ink: s,
870
+ angle: Math.atan2(x.x - k.x, k.y - x.y) * 180 / Math.PI,
871
+ size: (S.size ?? Hn) * o.height * Math.sqrt(o.stretch),
872
+ skin: S.skin ?? (v === "none" ? void 0 : v),
873
+ ink: r,
806
874
  lineWidth: o.lineWidth * 0.45,
807
- fingers: M.fingers,
808
- plump: M.plump,
875
+ fingers: S.fingers,
876
+ plump: S.plump,
809
877
  look: n.sketch ? "pencil" : "clean",
810
878
  seed: n.sketch?.seed
811
- }, r);
879
+ }, s);
812
880
  }
813
- const H = (w) => {
881
+ const M = (w) => {
814
882
  c(() => {
815
- u(), f(o.arms[w], oo), m(w);
883
+ p(), m(o.arms[w], qo), y(w);
816
884
  });
817
- const M = i.sleeve;
818
- M && l && c(() => M(e, l, w, r, h));
819
- }, E = ie(t.turn) > fo;
820
- p(i.behind), c(() => {
821
- d(), f(o.legs.left, Kt), g("left"), f(o.legs.right, Kt), g("right");
822
- }), E && H("left"), c(() => {
823
- u(), b(o.spine, o.spine.length > 2, no);
824
- const { left: w, right: M } = { left: o.arms.left.root, right: o.arms.right.root };
825
- if (w.x !== M.x)
826
- if (o.classic) b([w, M], !1, [1, 1]);
885
+ const S = l.sleeve;
886
+ S && i && c(() => S(e, i, w, s, h));
887
+ }, A = fe(t.turn) > Qo;
888
+ u(l.behind), c(() => {
889
+ g(), m(o.legs.left, zt), b("left"), m(o.legs.right, zt), b("right");
890
+ }), A && M("left"), c(() => {
891
+ f(), d(o.spine, o.spine.length > 2, Xo);
892
+ }), c(() => {
893
+ p();
894
+ const { left: w, right: S } = { left: o.arms.left.root, right: o.arms.right.root };
895
+ if (w.x !== S.x)
896
+ if (o.classic) d([w, S], !1, [1, 1]);
827
897
  else {
828
- const x = { x: (w.x + M.x) / 2, y: w.y - 0.3 * Math.abs(M.x - w.x) };
829
- b(de(w, x, M, 1, 8), !0, [1.1, 1.1]);
898
+ const k = { x: (w.x + S.x) / 2, y: w.y - 0.3 * Math.abs(S.x - w.x) };
899
+ d(ke(w, k, S, 1, 8), !0, [1.1, 1.1]);
830
900
  }
831
- }), p(i.body), E || H("left"), H("right"), p(i.behindHead), c(() => {
832
- u(), e.translate(0, o.neckY), e.rotate(ee(t.headTilt));
901
+ }), u(l.body), A || M("left"), M("right"), u(l.behindHead), c(() => {
902
+ p(), e.translate(0, o.neckY), e.rotate(Q(t.headTilt));
833
903
  const w = -o.headRy;
834
904
  e.beginPath(), e.ellipse(0, w, o.headRx, o.headRy, 0, 0, Math.PI * 2);
835
- const M = n.headFill ?? "#ffffff";
836
- if (M !== "none" && (e.fillStyle = M, e.fill()), a) {
905
+ const S = n.headFill ?? "#ffffff";
906
+ if (S !== "none" && (e.fillStyle = S, e.fill()), a) {
837
907
  a.ellipse(0, w, o.headRx, o.headRy);
838
- const x = a.nudge();
839
- e.translate(x.x, x.y);
908
+ const k = a.nudge();
909
+ e.translate(k.x, k.y);
840
910
  } else
841
911
  e.stroke();
842
- e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r), bo(e, t, o.r, 0, s, o.lineWidth);
843
- }), p(i.overHead), p(i.front), e.restore(), n.label && (e.save(), e.fillStyle = s, e.font = n.labelFont ?? `700 ${Math.round(o.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -o.height * o.stretch - 0.04 * o.height + o.drop), e.restore());
844
- }
845
- function en(e, t, n) {
846
- const r = { ...e };
847
- let o = e.walking > 0 ? Se(r, Gn(e.walk, r), e.walking) : r, s = Ho(e);
848
- const i = e.dancing ?? 0;
849
- if (n && i > 0) {
850
- const l = n(e.beat ?? 0);
851
- if (o = Se(o, l.pose, i), l.hands) {
852
- const a = (h, c) => c ? ke(h ?? _, c, i) : h;
853
- s = { left: a(s?.left, l.hands.left), right: a(s?.right, l.hands.right) };
912
+ e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r), os(e, t, o.r, 0, r, o.lineWidth);
913
+ }), u(l.overHead), u(l.front), e.restore(), n.label && (e.save(), e.fillStyle = r, e.font = n.labelFont ?? `700 ${Math.round(o.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -o.height * o.stretch - 0.04 * o.height + o.drop), e.restore());
914
+ }
915
+ function On(e, t, n) {
916
+ const s = { ...e };
917
+ let o = e.walking > 0 ? Pe(s, Oo(e.gait, e.walk, s), e.walking) : s, r = fs(e);
918
+ const l = e.dancing ?? 0;
919
+ if (n && l > 0) {
920
+ const i = n(e.beat ?? 0);
921
+ if (o = Pe(o, i.pose, l), i.hands) {
922
+ const a = (h, c) => c ? Ke(h ?? L, c, l) : h;
923
+ r = { left: a(r?.left, i.hands.left), right: a(r?.right, i.hands.right) };
854
924
  }
855
925
  }
856
- return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Jn(t)) }), { pose: o, hands: s };
926
+ return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Fo(t)) }), { pose: o, hands: r };
857
927
  }
858
- function Eo(e, t, n) {
859
- return en(e, t, n).pose;
928
+ function cs(e, t, n) {
929
+ return On(e, t, n).pose;
860
930
  }
861
- const $e = (e, t) => `hand.${e}.${t}`;
862
- function Ho(e) {
931
+ const In = (e, t) => (e.facing ?? t.facing ?? 1) < 0 ? -1 : 1, Ue = (e, t) => `hand.${e}.${t}`;
932
+ function fs(e) {
863
933
  const t = (o) => {
864
- if (typeof e[$e(o, "spread")] == "number")
865
- return Object.fromEntries(Object.keys(_).map((s) => [s, e[$e(o, s)]]));
866
- }, n = t("left"), r = t("right");
867
- return n || r ? { left: n, right: r } : void 0;
934
+ if (typeof e[Ue(o, "spread")] == "number")
935
+ return Object.fromEntries(Object.keys(L).map((r) => [r, e[Ue(o, r)]]));
936
+ }, n = t("left"), s = t("right");
937
+ return n || s ? { left: n, right: s } : void 0;
868
938
  }
869
- function Mo(e, t) {
939
+ function us(e, t) {
870
940
  return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
871
941
  }
872
- function Jr(e) {
873
- const t = e.style ?? {}, n = t.height ?? 300, r = n * 0.8, o = { ...C(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, s = {};
942
+ function mi(e) {
943
+ const t = e.style ?? {}, n = t.height ?? 300, s = n * 0.8, o = { ...z(e.pose ?? {}), walk: 0, walking: 0, gait: "walk", facing: (t.facing ?? 1) < 0 ? -1 : 1, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, r = {};
874
944
  if (t.hands)
875
- for (const i of ["left", "right"]) {
876
- const l = t.hands[i] ?? _;
877
- for (const a of Object.keys(_)) s[$e(i, a)] = l[a] ?? _[a];
945
+ for (const l of ["left", "right"]) {
946
+ const i = t.hands[l] ?? L;
947
+ for (const a of Object.keys(L)) r[Ue(l, a)] = i[a] ?? L[a];
878
948
  }
879
949
  return {
880
950
  type: "custom",
881
- x: e.x - r / 2,
951
+ x: e.x - s / 2,
882
952
  y: e.y - n,
883
- width: r,
953
+ width: s,
884
954
  height: n,
885
- props: { ...o, ...s },
955
+ props: { ...o, ...r },
886
956
  figureStyle: t,
887
957
  figureDance: e.dance,
888
- draw(i, l, a) {
889
- const h = l.props, c = en(h, a, e.dance);
890
- i.translate(r / 2, n), So(i, c.pose, Mo({ ...t, rubber: h.rubber }, c.hands), a);
958
+ draw(l, i, a) {
959
+ const h = i.props, c = On(h, a, e.dance);
960
+ l.translate(s / 2, n), hs(l, c.pose, us({ ...t, rubber: h.rubber, facing: In(h, t) }, c.hands), a);
891
961
  }
892
962
  };
893
963
  }
894
- function Vr(e, t, n) {
895
- const r = e.figureStyle;
896
- if (!r) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
964
+ function ds(e, t, n) {
965
+ const s = e.figureStyle;
966
+ if (!s) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
897
967
  const o = { ...e.props };
898
- let s = 0, i = 0;
968
+ let r = 0, l = 0;
899
969
  for (const [h, c] of t.state?.values.get(n) ?? [])
900
- typeof c == "number" && (h === "x" || h === "motionPathX" ? s = c : h === "y" || h === "motionPathY" ? i = c : h in o && (o[h] = c));
901
- const l = Eo(o, t.time, e.figureDance), a = wo(l, { ...r, rubber: o.rubber });
902
- return { pose: l, joints: ko(a, e.x + s + e.width / 2, e.y + i + e.height) };
903
- }
904
- function jr(e, t) {
905
- const n = [];
906
- return t.forEach((r, o) => {
907
- const s = o === 0 ? J : n[o - 1], i = typeof r.pose == "string" ? Un[r.pose] : { ...s, ...r.pose };
908
- n.push(r.expression ? Nt(i, r.expression) : i);
909
- }), Ct.filter((r) => n.some((o) => o[r] !== J[r])).map((r) => ({
910
- id: `${e}-${r}`,
970
+ h === "gait" && typeof c == "string" && (o.gait = c), typeof c == "number" && (h === "x" || h === "motionPathX" ? r = c : h === "y" || h === "motionPathY" ? l = c : h in o && (o[h] = c));
971
+ const i = cs(o, t.time, e.figureDance), a = ls(i, { ...s, rubber: o.rubber, facing: In(o, s) });
972
+ return { pose: i, joints: as(a, e.x + r + e.width / 2, e.y + l + e.height) };
973
+ }
974
+ function _n(e) {
975
+ const t = [];
976
+ return e.forEach((n, s) => {
977
+ const o = s === 0 ? _ : t[s - 1], r = typeof n.pose == "string" ? Oe[n.pose] : { ...o, ...n.pose };
978
+ t.push(n.expression ? qe(r, n.expression) : r);
979
+ }), t;
980
+ }
981
+ function bi(e, t) {
982
+ const n = _n(t);
983
+ return kn.filter((s) => n.some((o) => o[s] !== _[s])).map((s) => ({
984
+ id: `${e}-${s}`,
911
985
  target: e,
912
- property: r,
913
- keyframes: t.map((o, s) => ({
986
+ property: s,
987
+ keyframes: t.map((o, r) => ({
914
988
  time: o.time,
915
- value: n[s][r],
989
+ value: n[r][s],
916
990
  ...o.easing ? { easing: o.easing } : {}
917
991
  }))
918
992
  }));
919
993
  }
920
- const Ne = 0.5, Wt = {
994
+ const tt = 0.5, Zt = {
921
995
  /** Flag: fingers together and straight, thumb bent in */
922
- pataka: $({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
996
+ pataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
923
997
  /** Pataka with the ring finger bent */
924
- tripataka: $({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
998
+ tripataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
925
999
  /** Lotus in bloom: fingers fanned, each a little more curled than the last */
926
- alapadma: $({ "thumb.curl": 0.1, "thumb.across": 0, "index.curl": 0.05, "middle.curl": 0.15, "ring.curl": 0.25, "pinky.curl": 0.35, spread: 1, turn: 2 }),
1000
+ alapadma: R({ "thumb.curl": 0.1, "thumb.across": 0, "index.curl": 0.05, "middle.curl": 0.15, "ring.curl": 0.25, "pinky.curl": 0.35, spread: 1, turn: 2 }),
927
1001
  /** Fist */
928
- mushti: L.fist,
1002
+ mushti: C.fist,
929
1003
  /** Fist, thumb up */
930
- shikhara: L.thumbsUp,
1004
+ shikhara: C.thumbsUp,
931
1005
  /** Swan's beak: thumb and index touch, the others fanned */
932
- hamsasya: $({ "thumb.curl": 0.15, "thumb.across": 0.6, "index.curl": 0.6, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0.7, turn: 2 }),
1006
+ hamsasya: R({ "thumb.curl": 0.15, "thumb.across": 0.6, "index.curl": 0.6, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0.7, turn: 2 }),
933
1007
  /** Bracelet: thumb, index and middle meet, ring and little finger out */
934
- katakamukha: $({ "thumb.curl": 0.2, "thumb.across": 0.6, "index.curl": 0.65, "middle.curl": 0.7, "ring.curl": 0, "pinky.curl": 0, spread: 0.4, turn: 2 })
1008
+ katakamukha: R({ "thumb.curl": 0.2, "thumb.across": 0.6, "index.curl": 0.65, "middle.curl": 0.7, "ring.curl": 0, "pinky.curl": 0, spread: 0.4, turn: 2 })
935
1009
  };
936
- function _e(e) {
937
- return typeof e != "string" ? e : e in Wt ? Wt[e] : L[e];
1010
+ function ze(e) {
1011
+ return typeof e != "string" ? e : e in Zt ? Zt[e] : C[e];
938
1012
  }
939
- function tn(e, t, n) {
940
- const r = [];
1013
+ function $n(e, t, n) {
1014
+ const s = [];
941
1015
  for (const o of e.keys) {
942
- const s = r[r.length - 1], i = !s || o.reset ? { pose: t, ...n } : s;
943
- r.push({
1016
+ const r = s[s.length - 1], l = !r || o.reset ? { pose: t, ...n } : r;
1017
+ s.push({
944
1018
  beat: o.beat,
945
- pose: { ...i.pose, ...o.pose },
946
- left: o.hands?.left ? _e(o.hands.left) : i.left,
947
- right: o.hands?.right ? _e(o.hands.right) : i.right,
1019
+ pose: { ...l.pose, ...o.pose },
1020
+ left: o.hands?.left ? ze(o.hands.left) : l.left,
1021
+ right: o.hands?.right ? ze(o.hands.right) : l.right,
948
1022
  easing: o.easing ?? e.easing
949
1023
  });
950
1024
  }
951
- return r;
1025
+ return s;
952
1026
  }
953
- const ht = (e, t) => (e % t + t) % t;
954
- function vo(e, t, n, r) {
955
- const o = tn(e, n, r);
956
- if (o.length === 0) return { pose: n, hands: r };
957
- const s = ht(t, e.beats);
958
- let i = o.length - 1;
959
- for (let u = 0; u < o.length; u++) o[u].beat <= s && (i = u);
960
- const l = o[i], a = o[(i + 1) % o.length], h = l.beat <= s ? l.beat : l.beat - e.beats, c = a.beat > h ? a.beat : a.beat + e.beats, p = c > h ? (s - h) / (c - h) : 0, d = Le(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, p)));
1027
+ const At = (e, t) => (e % t + t) % t;
1028
+ function gs(e, t, n, s) {
1029
+ const o = $n(e, n, s);
1030
+ if (o.length === 0) return { pose: n, hands: s };
1031
+ const r = At(t, e.beats);
1032
+ let l = o.length - 1;
1033
+ for (let f = 0; f < o.length; f++) o[f].beat <= r && (l = f);
1034
+ const i = o[l], a = o[(l + 1) % o.length], h = i.beat <= r ? i.beat : i.beat - e.beats, c = a.beat > h ? a.beat : a.beat + e.beats, u = c > h ? (r - h) / (c - h) : 0, g = Qe(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, u)));
961
1035
  return {
962
- pose: Se(l.pose, a.pose, d),
963
- hands: { left: ke(l.left, a.left, d), right: ke(l.right, a.right, d) }
1036
+ pose: Pe(i.pose, a.pose, g),
1037
+ hands: { left: Ke(i.left, a.left, g), right: Ke(i.right, a.right, g) }
964
1038
  };
965
1039
  }
966
- const xo = [
1040
+ const ps = [
967
1041
  ["leftShoulder", "rightShoulder"],
968
1042
  ["leftElbow", "rightElbow"],
969
1043
  ["leftWrist", "rightWrist"],
@@ -973,151 +1047,151 @@ const xo = [
973
1047
  ["leftFootOut", "rightFootOut"],
974
1048
  ["leftEye", "rightEye"],
975
1049
  ["leftBrow", "rightBrow"]
976
- ], To = ["lean", "headTilt", "lookX", "spin"], Ao = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
977
- function Ko(e) {
1050
+ ], ms = ["lean", "headTilt", "lookX", "spin"], bs = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
1051
+ function ws(e) {
978
1052
  const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
979
- for (const [r, o] of xo) {
980
- const s = n && Ao.has(r) ? -1 : 1;
981
- t[r] = s * e[o], t[o] = s * e[r];
1053
+ for (const [s, o] of ps) {
1054
+ const r = n && bs.has(s) ? -1 : 1;
1055
+ t[s] = r * e[o], t[o] = r * e[s];
982
1056
  }
983
- if (!n) for (const r of To) t[r] = -e[r];
1057
+ if (!n) for (const s of ms) t[s] = -e[s];
984
1058
  return t;
985
1059
  }
986
- const Po = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
987
- function Wo(e, t, n) {
988
- const r = ht(n, 1), o = (1 + Math.cos(2 * Math.PI * r)) / 2, s = t.bounce * (t.accent === "up" ? 1 - o : o), i = Math.min(1, Math.max(0, e.turn ?? 0)), l = Po(i);
1060
+ const ys = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
1061
+ function ks(e, t, n) {
1062
+ const s = At(n, 1), o = (1 + Math.cos(2 * Math.PI * s)) / 2, r = t.bounce * (t.accent === "up" ? 1 - o : o), l = Math.min(1, Math.max(0, e.turn ?? 0)), i = ys(l);
989
1063
  return {
990
1064
  ...e,
991
- leftHip: e.leftHip + l * s / 2,
992
- rightHip: e.rightHip + s / 2,
993
- leftKnee: e.leftKnee + l * s,
994
- rightKnee: e.rightKnee + s,
995
- lean: e.lean + (t.sway ?? 0) * (1 - i) * Math.sin(Math.PI * n)
1065
+ leftHip: e.leftHip + i * r / 2,
1066
+ rightHip: e.rightHip + r / 2,
1067
+ leftKnee: e.leftKnee + i * r,
1068
+ rightKnee: e.rightKnee + r,
1069
+ lean: e.lean + (t.sway ?? 0) * (1 - l) * Math.sin(Math.PI * n)
996
1070
  };
997
1071
  }
998
- function nt(e) {
999
- const t = { ...J, ...e.stance };
1000
- return e.expression ? Nt(t, e.expression) : t;
1072
+ function yt(e) {
1073
+ const t = { ..._, ...e.stance };
1074
+ return e.expression ? qe(t, e.expression) : t;
1001
1075
  }
1002
- function nn(e) {
1076
+ function Bn(e) {
1003
1077
  return {
1004
- left: e.hands?.left ? _e(e.hands.left) : _,
1005
- right: e.hands?.right ? _e(e.hands.right) : _
1078
+ left: e.hands?.left ? ze(e.hands.left) : L,
1079
+ right: e.hands?.right ? ze(e.hands.right) : L
1006
1080
  };
1007
1081
  }
1008
- function Ce(e, t, n) {
1009
- const r = e.moves[t.move];
1010
- if (!r) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1011
- const o = vo(r, n, nt(e), nn(e));
1012
- return t.mirror ? { pose: Ko(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
1082
+ function nt(e, t, n) {
1083
+ const s = e.moves[t.move];
1084
+ if (!s) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1085
+ const o = gs(s, n, yt(e), Bn(e));
1086
+ return t.mirror ? { pose: ws(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
1013
1087
  }
1014
- function ct(e, t, n = {}) {
1015
- const r = typeof e == "string" ? ge[e] : e;
1088
+ function xt(e, t, n = {}) {
1089
+ const s = typeof e == "string" ? Se[e] : e;
1016
1090
  let o;
1017
1091
  if (n.move)
1018
- o = Ce(r, { move: n.move, mirror: n.mirror }, t);
1092
+ o = nt(s, { move: n.move, mirror: n.mirror }, t);
1019
1093
  else {
1020
- const s = r.routine, i = s.reduce((p, d) => p + d.beats, 0), l = ht(t, i);
1094
+ const r = s.routine, l = r.reduce((u, g) => u + g.beats, 0), i = At(t, l);
1021
1095
  let a = 0, h = 0;
1022
- for (; h < s.length - 1 && l >= a + s[h].beats; ) a += s[h++].beats;
1023
- const c = l - a;
1024
- if (o = Ce(r, s[h], c), c < Ne && s.length > 1 && t >= Ne) {
1025
- const p = s[(h - 1 + s.length) % s.length], d = Ce(r, p, p.beats + c), u = Le("ease-in-out")(c / Ne);
1096
+ for (; h < r.length - 1 && i >= a + r[h].beats; ) a += r[h++].beats;
1097
+ const c = i - a;
1098
+ if (o = nt(s, r[h], c), c < tt && r.length > 1 && t >= tt) {
1099
+ const u = r[(h - 1 + r.length) % r.length], g = nt(s, u, u.beats + c), f = Qe("ease-in-out")(c / tt);
1026
1100
  o = {
1027
- pose: Se(d.pose, o.pose, u),
1028
- hands: { left: ke(d.hands.left, o.hands.left, u), right: ke(d.hands.right, o.hands.right, u) }
1101
+ pose: Pe(g.pose, o.pose, f),
1102
+ hands: { left: Ke(g.hands.left, o.hands.left, f), right: Ke(g.hands.right, o.hands.right, f) }
1029
1103
  };
1030
1104
  }
1031
1105
  }
1032
- return { ...o, pose: Wo(o.pose, r.groove, t) };
1106
+ return { ...o, pose: ks(o.pose, s.groove, t) };
1033
1107
  }
1034
- function Zr(e, t, n = {}) {
1035
- return ct(e, t, n).pose;
1108
+ function wi(e, t, n = {}) {
1109
+ return xt(e, t, n).pose;
1036
1110
  }
1037
- function ft(e) {
1038
- return (typeof e == "string" ? ge[e] : e).routine.reduce((n, r) => n + r.beats, 0);
1111
+ function Kt(e) {
1112
+ return (typeof e == "string" ? Se[e] : e).routine.reduce((n, s) => n + s.beats, 0);
1039
1113
  }
1040
- const Oo = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1041
- function Ot(e, t, n, r, o, s, i) {
1042
- for (let l = 0; l * e.beats < n; l++)
1114
+ const Ss = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1115
+ function Qt(e, t, n, s, o, r, l) {
1116
+ for (let i = 0; i * e.beats < n; i++)
1043
1117
  for (const a of e.keys) {
1044
- const h = l * e.beats + a.beat, c = t + h;
1045
- if (!(h >= n || c < s || c >= i))
1046
- for (const p of a.taps ?? []) o.push({ beat: c, tap: r ? Oo[p] : p });
1118
+ const h = i * e.beats + a.beat, c = t + h;
1119
+ if (!(h >= n || c < r || c >= l))
1120
+ for (const u of a.taps ?? []) o.push({ beat: c, tap: s ? Ss[u] : u });
1047
1121
  }
1048
1122
  }
1049
- function Qr(e, t, n, r = {}) {
1050
- const o = typeof e == "string" ? ge[e] : e, s = [];
1051
- if (n <= t) return s;
1052
- if (r.move) {
1053
- const i = o.moves[r.move], l = Math.floor(t / i.beats) * i.beats;
1054
- Ot(i, l, Math.ceil((n - l) / i.beats) * i.beats, r.mirror, s, t, n);
1123
+ function yi(e, t, n, s = {}) {
1124
+ const o = typeof e == "string" ? Se[e] : e, r = [];
1125
+ if (n <= t) return r;
1126
+ if (s.move) {
1127
+ const l = o.moves[s.move], i = Math.floor(t / l.beats) * l.beats;
1128
+ Qt(l, i, Math.ceil((n - i) / l.beats) * l.beats, s.mirror, r, t, n);
1055
1129
  } else {
1056
- const i = ft(o);
1057
- for (let l = Math.floor(t / i) * i; l < n; l += i) {
1058
- let a = l;
1130
+ const l = Kt(o);
1131
+ for (let i = Math.floor(t / l) * l; i < n; i += l) {
1132
+ let a = i;
1059
1133
  for (const h of o.routine)
1060
- Ot(o.moves[h.move], a, h.beats, h.mirror, s, t, n), a += h.beats;
1134
+ Qt(o.moves[h.move], a, h.beats, h.mirror, r, t, n), a += h.beats;
1061
1135
  }
1062
1136
  }
1063
- return s.sort((i, l) => i.beat - l.beat);
1137
+ return r.sort((l, i) => l.beat - i.beat);
1064
1138
  }
1065
- function It(e, t) {
1139
+ function en(e, t) {
1066
1140
  const n = e.moves[t.move];
1067
1141
  if (!n?.travel) return 0;
1068
- const r = n.travel / n.beats;
1069
- return t.mirror ? (tn(n, nt(e), nn(e))[0]?.pose.turn ?? nt(e).turn ?? 0) >= 0.5 ? r : -r : r;
1142
+ const s = n.travel / n.beats;
1143
+ return t.mirror ? ($n(n, yt(e), Bn(e))[0]?.pose.turn ?? yt(e).turn ?? 0) >= 0.5 ? s : -s : s;
1070
1144
  }
1071
- function on(e, t) {
1145
+ function Fn(e, t) {
1072
1146
  return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
1073
1147
  }
1074
- function De(e, t, n = {}) {
1075
- const r = typeof e == "string" ? ge[e] : e, o = on(r, n), s = o.reduce((c, p) => c + p.beats, 0), i = o.reduce((c, p) => c + It(r, p) * p.beats, 0), l = Math.floor(t / s);
1076
- let a = l * i, h = t - l * s;
1148
+ function ot(e, t, n = {}) {
1149
+ const s = typeof e == "string" ? Se[e] : e, o = Fn(s, n), r = o.reduce((c, u) => c + u.beats, 0), l = o.reduce((c, u) => c + en(s, u) * u.beats, 0), i = Math.floor(t / r);
1150
+ let a = i * l, h = t - i * r;
1077
1151
  for (const c of o) {
1078
- const p = Math.min(c.beats, h);
1079
- if (a += It(r, c) * p, h -= p, h <= 0) break;
1152
+ const u = Math.min(c.beats, h);
1153
+ if (a += en(s, c) * u, h -= u, h <= 0) break;
1080
1154
  }
1081
1155
  return a;
1082
1156
  }
1083
- function Io(e, t, n) {
1084
- const r = on(e, n), o = [0];
1085
- let s = 0;
1086
- for (let i = 0; s < t; i = (i + 1) % r.length)
1087
- s += r[i].beats, o.push(Math.min(s, t));
1157
+ function Es(e, t, n) {
1158
+ const s = Fn(e, n), o = [0];
1159
+ let r = 0;
1160
+ for (let l = 0; r < t; l = (l + 1) % s.length)
1161
+ r += s[l].beats, o.push(Math.min(r, t));
1088
1162
  return o;
1089
1163
  }
1090
- const Bo = 8;
1091
- function $o(e, t, n) {
1092
- const r = typeof t == "string" ? ge[t] : t, o = n.bpm ?? r.bpm, s = n.beats ?? (n.move ? r.moves[n.move].beats : ft(r)), i = Io(r, s, n);
1093
- if (i.every((m) => De(r, m, n) === 0)) return;
1094
- const l = Math.min(n.fade ?? 1, s / 2), a = Le("ease-in-out"), h = (m) => l <= 0 ? 1 : Math.min(a(Math.min(1, m / l)), a(Math.min(1, (s - m) / l))), c = Math.ceil(l * Bo), p = l <= 0 ? [] : Array.from({ length: c + 1 }, (m, k) => [k / c * l, s - k / c * l]).flat(), d = [.../* @__PURE__ */ new Set([...i, ...p])].sort((m, k) => m - k);
1095
- let u = 0;
1096
- const b = d.map((m, k) => {
1097
- if (k > 0) {
1098
- const y = d[k - 1], H = Math.max(1, Math.ceil((m - y) * 16));
1099
- for (let E = 0; E < H; E++) {
1100
- const w = y + (m - y) * E / H, M = y + (m - y) * (E + 1) / H;
1101
- u += (De(r, M, n) - De(r, w, n)) * h((w + M) / 2);
1164
+ const Ms = 8;
1165
+ function Hs(e, t, n) {
1166
+ const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = Es(s, r, n);
1167
+ if (l.every((b) => ot(s, b, n) === 0)) return;
1168
+ const i = Math.min(n.fade ?? 1, r / 2), a = Qe("ease-in-out"), h = (b) => i <= 0 ? 1 : Math.min(a(Math.min(1, b / i)), a(Math.min(1, (r - b) / i))), c = Math.ceil(i * Ms), u = i <= 0 ? [] : Array.from({ length: c + 1 }, (b, y) => [y / c * i, r - y / c * i]).flat(), g = [.../* @__PURE__ */ new Set([...l, ...u])].sort((b, y) => b - y);
1169
+ let f = 0;
1170
+ const p = g.map((b, y) => {
1171
+ if (y > 0) {
1172
+ const E = g[y - 1], H = Math.max(1, Math.ceil((b - E) * 16));
1173
+ for (let M = 0; M < H; M++) {
1174
+ const A = E + (b - E) * M / H, w = E + (b - E) * (M + 1) / H;
1175
+ f += (ot(s, w, n) - ot(s, A, n)) * h((A + w) / 2);
1102
1176
  }
1103
1177
  }
1104
- return { beat: m, travel: u };
1105
- }), f = n.start ?? 0, g = n.x ?? 0;
1178
+ return { beat: b, travel: f };
1179
+ }), d = n.start ?? 0, m = n.x ?? 0;
1106
1180
  return {
1107
1181
  id: `${e}-x`,
1108
1182
  target: e,
1109
1183
  property: "x",
1110
- keyframes: b.map((m) => ({ time: f + m.beat * 6e4 / o, value: g + n.height * m.travel, easing: "linear" }))
1184
+ keyframes: p.map((b) => ({ time: d + b.beat * 6e4 / o, value: m + n.height * b.travel, easing: "linear" }))
1111
1185
  };
1112
1186
  }
1113
- function es(e, t, n = 0) {
1187
+ function ki(e, t, n = 0) {
1114
1188
  return (e - n) * t / 6e4;
1115
1189
  }
1116
- function ts(e, t = {}) {
1117
- return (n) => ct(e, n, t);
1190
+ function Si(e, t = {}) {
1191
+ return (n) => xt(e, n, t);
1118
1192
  }
1119
- function ns(e, t) {
1120
- const n = t.start ?? 0, r = 6e4 / t.bpm, o = n + t.beats * r, s = Math.min((t.fade ?? 1) * r, (o - n) / 2);
1193
+ function Ei(e, t) {
1194
+ const n = t.start ?? 0, s = 6e4 / t.bpm, o = n + t.beats * s, r = Math.min((t.fade ?? 1) * s, (o - n) / 2);
1121
1195
  return [
1122
1196
  {
1123
1197
  id: `${e}-beat`,
@@ -1134,33 +1208,33 @@ function ns(e, t) {
1134
1208
  property: "dancing",
1135
1209
  keyframes: [
1136
1210
  { time: n, value: 0 },
1137
- { time: n + s, value: 1, easing: "ease-in-out" },
1138
- { time: o - s, value: 1 },
1211
+ { time: n + r, value: 1, easing: "ease-in-out" },
1212
+ { time: o - r, value: 1 },
1139
1213
  { time: o, value: 0, easing: "ease-in-out" }
1140
1214
  ]
1141
1215
  }
1142
1216
  ];
1143
1217
  }
1144
- function os(e, t, n = {}) {
1145
- const r = typeof t == "string" ? ge[t] : t, o = n.bpm ?? r.bpm, s = n.beats ?? (n.move ? r.moves[n.move].beats : ft(r)), i = n.samplesPerBeat ?? 4, l = n.start ?? 0, a = Math.round(s * i), h = Array.from({ length: a + 1 }, (f, g) => {
1146
- const m = g / i;
1147
- return { time: l + m * 6e4 / o, frame: ct(r, m, n) };
1148
- }), c = (f, g) => ({
1149
- id: `${e}-${f}`,
1218
+ function Mi(e, t, n = {}) {
1219
+ const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = n.samplesPerBeat ?? 4, i = n.start ?? 0, a = Math.round(r * l), h = Array.from({ length: a + 1 }, (d, m) => {
1220
+ const b = m / l;
1221
+ return { time: i + b * 6e4 / o, frame: xt(s, b, n) };
1222
+ }), c = (d, m) => ({
1223
+ id: `${e}-${d}`,
1150
1224
  target: e,
1151
- property: f,
1152
- keyframes: h.map((m) => ({ time: m.time, value: g(m.frame) }))
1153
- }), d = Object.keys(J).filter((f) => h.some((g) => g.frame.pose[f] !== h[0].frame.pose[f]) || h[0].frame.pose[f] !== J[f]).map((f) => c(f, (g) => g.pose[f])), u = n.height === void 0 ? void 0 : $o(e, r, { ...n, bpm: o, beats: s, start: l, height: n.height, fade: 0 });
1154
- if (u && d.push(u), n.hands === !1) return d;
1155
- const b = [];
1156
- for (const f of ["left", "right"])
1157
- for (const g of Object.keys(_)) {
1158
- const m = (k) => k.hands?.[f]?.[g] ?? _[g];
1159
- h.some((k) => m(k.frame) !== _[g]) && b.push(c($e(f, g), m));
1225
+ property: d,
1226
+ keyframes: h.map((b) => ({ time: b.time, value: m(b.frame) }))
1227
+ }), g = Object.keys(_).filter((d) => h.some((m) => m.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== _[d]).map((d) => c(d, (m) => m.pose[d])), f = n.height === void 0 ? void 0 : Hs(e, s, { ...n, bpm: o, beats: r, start: i, height: n.height, fade: 0 });
1228
+ if (f && g.push(f), n.hands === !1) return g;
1229
+ const p = [];
1230
+ for (const d of ["left", "right"])
1231
+ for (const m of Object.keys(L)) {
1232
+ const b = (y) => y.hands?.[d]?.[m] ?? L[m];
1233
+ h.some((y) => b(y.frame) !== L[m]) && p.push(c(Ue(d, m), b));
1160
1234
  }
1161
- return [...d, ...b];
1235
+ return [...g, ...p];
1162
1236
  }
1163
- const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic", _o = {
1237
+ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic", vs = {
1164
1238
  label: "Disco",
1165
1239
  bpm: 120,
1166
1240
  stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
@@ -1170,7 +1244,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1170
1244
  point: {
1171
1245
  label: "The point",
1172
1246
  beats: 2,
1173
- easing: D,
1247
+ easing: V,
1174
1248
  keys: [
1175
1249
  {
1176
1250
  beat: 0,
@@ -1195,9 +1269,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1195
1269
  label: "Bump and clap",
1196
1270
  beats: 4,
1197
1271
  keys: [
1198
- { beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: D },
1272
+ { beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: V },
1199
1273
  { beat: 1, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } },
1200
- { beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: D },
1274
+ { beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: V },
1201
1275
  { beat: 3, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } }
1202
1276
  ]
1203
1277
  }
@@ -1208,7 +1282,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1208
1282
  { move: "point", beats: 8, mirror: !0 },
1209
1283
  { move: "bump", beats: 8 }
1210
1284
  ]
1211
- }, Fo = {
1285
+ }, Ts = {
1212
1286
  label: "Hip hop",
1213
1287
  bpm: 95,
1214
1288
  stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
@@ -1260,7 +1334,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1260
1334
  { move: "armWave", beats: 8 },
1261
1335
  { move: "bounce", beats: 4 }
1262
1336
  ]
1263
- }, Ro = {
1337
+ }, As = {
1264
1338
  label: "Breaking (toprock)",
1265
1339
  bpm: 110,
1266
1340
  stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
@@ -1272,9 +1346,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1272
1346
  label: "Toprock (Indian step)",
1273
1347
  beats: 4,
1274
1348
  keys: [
1275
- { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: D },
1349
+ { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: V },
1276
1350
  { beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
1277
- { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: D },
1351
+ { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: V },
1278
1352
  { beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
1279
1353
  ]
1280
1354
  },
@@ -1282,7 +1356,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1282
1356
  label: "Kick out",
1283
1357
  beats: 2,
1284
1358
  keys: [
1285
- { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: D },
1359
+ { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: V },
1286
1360
  { beat: 1, reset: !0 }
1287
1361
  ]
1288
1362
  },
@@ -1290,7 +1364,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1290
1364
  label: "B-boy stance",
1291
1365
  beats: 4,
1292
1366
  keys: [
1293
- { beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing: we },
1367
+ { beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing: xe },
1294
1368
  { beat: 2, pose: { headTilt: 14, lean: -6 } }
1295
1369
  ]
1296
1370
  }
@@ -1302,7 +1376,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1302
1376
  { move: "kick", beats: 4, mirror: !0 },
1303
1377
  { move: "freeze", beats: 4 }
1304
1378
  ]
1305
- }, Yo = {
1379
+ }, xs = {
1306
1380
  label: "Jazz",
1307
1381
  bpm: 130,
1308
1382
  stance: { leftHip: 10, rightHip: 10 },
@@ -1318,14 +1392,14 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1318
1392
  beat: e,
1319
1393
  // The hands shimmer: the wrists flick a little each quarter beat.
1320
1394
  pose: { leftShoulder: 128, rightShoulder: 128, leftElbow: 8, rightElbow: 8, leftWrist: t % 2 ? 4 : 26, rightWrist: t % 2 ? 26 : 4, leftHip: 16, rightHip: 16, leftKnee: e < 1 ? 26 : 8, rightKnee: e < 1 ? 26 : 8 },
1321
- hands: t === 0 ? { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } } : void 0
1395
+ hands: t === 0 ? { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } : void 0
1322
1396
  }))
1323
1397
  },
1324
1398
  kickBallChange: {
1325
1399
  label: "Kick ball change",
1326
1400
  beats: 2,
1327
1401
  keys: [
1328
- { beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing: D },
1402
+ { beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing: V },
1329
1403
  { beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
1330
1404
  { beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
1331
1405
  ]
@@ -1363,7 +1437,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1363
1437
  { move: "jazzHands", beats: 4 },
1364
1438
  { move: "splitDrop", beats: 8 }
1365
1439
  ]
1366
- }, Lo = {
1440
+ }, Ks = {
1367
1441
  label: "K-pop",
1368
1442
  bpm: 125,
1369
1443
  stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
@@ -1373,7 +1447,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1373
1447
  pointCombo: {
1374
1448
  label: "Point combo",
1375
1449
  beats: 4,
1376
- easing: we,
1450
+ easing: xe,
1377
1451
  keys: [
1378
1452
  { beat: 0, reset: !0, pose: { rightShoulder: 142, rightElbow: 0, leftShoulder: 25, leftElbow: -125, headTilt: 6, lean: -3, lookX: 0.6, lookY: -0.6 }, hands: { right: "point", left: "flat" } },
1379
1453
  { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
@@ -1385,16 +1459,16 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1385
1459
  label: "Big heart, finger heart",
1386
1460
  beats: 4,
1387
1461
  keys: [
1388
- { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: we },
1462
+ { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: xe },
1389
1463
  { beat: 1, pose: { headTilt: 8, lean: 4 } },
1390
- { beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing: we },
1464
+ { beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing: xe },
1391
1465
  { beat: 3, pose: { headTilt: 4 } }
1392
1466
  ]
1393
1467
  },
1394
1468
  isolations: {
1395
1469
  label: "Isolations",
1396
1470
  beats: 2,
1397
- easing: D,
1471
+ easing: V,
1398
1472
  keys: [
1399
1473
  { beat: 0, reset: !0, pose: { lean: -9, headTilt: 11, leftShoulder: 55, leftElbow: -112, rightShoulder: 55, rightElbow: -112, rightHip: 18 }, hands: { left: "fist", right: "fist" } },
1400
1474
  { beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
@@ -1410,7 +1484,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1410
1484
  { move: "pointCombo", beats: 8, mirror: !0 },
1411
1485
  { move: "isolations", beats: 4 }
1412
1486
  ]
1413
- }, No = {
1487
+ }, Ps = {
1414
1488
  label: "Bollywood",
1415
1489
  bpm: 120,
1416
1490
  stance: { leftHip: 10, rightHip: 10 },
@@ -1421,19 +1495,19 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1421
1495
  label: "Screw the bulb, pat the dog",
1422
1496
  beats: 2,
1423
1497
  keys: [
1424
- { beat: 0, reset: !0, pose: { rightShoulder: 160, rightElbow: 12, rightWrist: -15, leftShoulder: 40, leftElbow: -12, leftWrist: -45, lean: -4, rightHip: 16, lookX: 0.5, lookY: -0.6 }, hands: { right: { ...L.cupped, roll: -30 }, left: { ...L.flat, turn: 0 } } },
1425
- { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...L.cupped, roll: 30 } } },
1426
- { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...L.cupped, roll: -30 } } },
1427
- { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...L.cupped, roll: 30 } } }
1498
+ { beat: 0, reset: !0, pose: { rightShoulder: 160, rightElbow: 12, rightWrist: -15, leftShoulder: 40, leftElbow: -12, leftWrist: -45, lean: -4, rightHip: 16, lookX: 0.5, lookY: -0.6 }, hands: { right: { ...C.cupped, roll: -30 }, left: { ...C.flat, turn: 0 } } },
1499
+ { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } },
1500
+ { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...C.cupped, roll: -30 } } },
1501
+ { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } }
1428
1502
  ]
1429
1503
  },
1430
1504
  thumka: {
1431
1505
  label: "Thumka",
1432
1506
  beats: 2,
1433
1507
  keys: [
1434
- { beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...L.open, turn: 2 } }, easing: D },
1508
+ { beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...C.open, turn: 2 } }, easing: V },
1435
1509
  { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1436
- { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: D },
1510
+ { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: V },
1437
1511
  { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
1438
1512
  ]
1439
1513
  },
@@ -1442,9 +1516,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1442
1516
  beats: 4,
1443
1517
  keys: [
1444
1518
  { beat: 0, reset: !0, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26 }, hands: { left: "fist", right: "fist" } },
1445
- { beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing: D },
1519
+ { beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing: V },
1446
1520
  { beat: 2, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftWrist: 0, rightWrist: 0, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26, stretch: 1 }, hands: { left: "fist", right: "fist" } },
1447
- { beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing: D }
1521
+ { beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing: V }
1448
1522
  ]
1449
1523
  }
1450
1524
  },
@@ -1455,7 +1529,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1455
1529
  { move: "thumka", beats: 4, mirror: !0 },
1456
1530
  { move: "lightBulb", beats: 8, mirror: !0 }
1457
1531
  ]
1458
- }, Co = {
1532
+ }, Ws = {
1459
1533
  label: "Bhangra",
1460
1534
  bpm: 100,
1461
1535
  stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
@@ -1490,11 +1564,11 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1490
1564
  { move: "basic", beats: 8 },
1491
1565
  { move: "dhamaal", beats: 4 }
1492
1566
  ]
1493
- }, Do = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Xo = {
1567
+ }, Os = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Is = {
1494
1568
  label: "Bharatanatyam",
1495
1569
  bpm: 80,
1496
1570
  // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1497
- stance: { ...Do, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1571
+ stance: { ...Os, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1498
1572
  expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1499
1573
  hands: { left: "pataka", right: "pataka" },
1500
1574
  groove: { bounce: 0 },
@@ -1536,21 +1610,21 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1536
1610
  { move: "alapadma", beats: 8 },
1537
1611
  { move: "tatta", beats: 4 }
1538
1612
  ]
1539
- }, qo = {
1613
+ }, _s = {
1540
1614
  label: "Charleston",
1541
1615
  bpm: 150,
1542
1616
  stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
1543
1617
  expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
1544
- hands: { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } },
1618
+ hands: { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } },
1545
1619
  groove: { bounce: 8, accent: "down" },
1546
1620
  moves: {
1547
1621
  basic: {
1548
1622
  label: "Kick forward, kick back",
1549
1623
  beats: 4,
1550
1624
  keys: [
1551
- { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: D },
1625
+ { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: V },
1552
1626
  { beat: 1, reset: !0 },
1553
- { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: D },
1627
+ { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: V },
1554
1628
  { beat: 3, reset: !0 }
1555
1629
  ]
1556
1630
  },
@@ -1586,7 +1660,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1586
1660
  { move: "basic", beats: 8, mirror: !0 },
1587
1661
  { move: "twist", beats: 4 }
1588
1662
  ]
1589
- }, Uo = {
1663
+ }, $s = {
1590
1664
  label: "Tap",
1591
1665
  bpm: 120,
1592
1666
  // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
@@ -1672,7 +1746,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1672
1746
  { beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
1673
1747
  { beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
1674
1748
  // Arms flare on the finish: one up in front, one up behind.
1675
- { beat: 1, pose: { rightShoulder: 135, leftShoulder: 125, leftElbow: 0, rightElbow: 0, leftWrist: 0, rightWrist: 30, rightKnee: 8, leftKnee: -8, rightHip: 4, leftHip: -4 }, hands: { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } } },
1749
+ { beat: 1, pose: { rightShoulder: 135, leftShoulder: 125, leftElbow: 0, rightElbow: 0, leftWrist: 0, rightWrist: 30, rightKnee: 8, leftKnee: -8, rightHip: 4, leftHip: -4 }, hands: { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } },
1676
1750
  { beat: 1.75, reset: !0 }
1677
1751
  ]
1678
1752
  }
@@ -1684,7 +1758,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1684
1758
  { move: "heelToe", beats: 8 },
1685
1759
  { move: "crampRoll", beats: 4 }
1686
1760
  ]
1687
- }, zo = {
1761
+ }, Bs = {
1688
1762
  label: "Popping (glides, moonwalk)",
1689
1763
  bpm: 100,
1690
1764
  stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
@@ -1744,7 +1818,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1744
1818
  reset: !0,
1745
1819
  pose: { leftHip: 6, rightHip: 6, leftKnee: 0, rightKnee: 0, leftAnkle: 65, rightAnkle: 65, rightShoulder: 150, rightElbow: 75, leftShoulder: 30, leftElbow: 20, headTilt: -10, lookY: 0.4 },
1746
1820
  hands: { right: "fist", left: "fist" },
1747
- easing: we
1821
+ easing: xe
1748
1822
  },
1749
1823
  { beat: 2, pose: { headTilt: -14, lean: -2 } }
1750
1824
  ]
@@ -1757,72 +1831,72 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1757
1831
  { move: "forwardGlide", beats: 8 },
1758
1832
  { move: "toeStand", beats: 4 }
1759
1833
  ]
1760
- }, ge = {
1761
- disco: _o,
1762
- hipHop: Fo,
1763
- breaking: Ro,
1764
- jazz: Yo,
1765
- kpop: Lo,
1766
- bollywood: No,
1767
- bhangra: Co,
1768
- bharatanatyam: Xo,
1769
- charleston: qo,
1770
- tap: Uo,
1771
- popping: zo
1772
- }, Fe = (e) => Math.min(1, Math.max(0, e));
1773
- function Go(e) {
1774
- const t = { ...J, turn: e.view }, n = [];
1775
- for (const r of e.keys) {
1776
- const o = n[n.length - 1], s = !o || r.reset ? t : o.pose;
1777
- n.push({ at: r.at, pose: { ...s, ...r.pose }, easing: r.easing });
1834
+ }, Se = {
1835
+ disco: vs,
1836
+ hipHop: Ts,
1837
+ breaking: As,
1838
+ jazz: xs,
1839
+ kpop: Ks,
1840
+ bollywood: Ps,
1841
+ bhangra: Ws,
1842
+ bharatanatyam: Is,
1843
+ charleston: _s,
1844
+ tap: $s,
1845
+ popping: Bs
1846
+ }, Ve = (e) => Math.min(1, Math.max(0, e));
1847
+ function Fs(e) {
1848
+ const t = { ..._, turn: e.view }, n = [];
1849
+ for (const s of e.keys) {
1850
+ const o = n[n.length - 1], r = !o || s.reset ? t : o.pose;
1851
+ n.push({ at: s.at, pose: { ...r, ...s.pose }, easing: s.easing });
1778
1852
  }
1779
1853
  return n;
1780
1854
  }
1781
- function Jo(e) {
1782
- return e - Vo * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1855
+ function Rs(e) {
1856
+ return e - Ls * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1783
1857
  }
1784
- const Vo = 0.5;
1785
- function jo(e, t) {
1858
+ const Ls = 0.5;
1859
+ function Ns(e, t) {
1786
1860
  if (!(t <= e.takeoff || t >= e.landing))
1787
1861
  return (t - e.takeoff) / (e.landing - e.takeoff);
1788
1862
  }
1789
- function Zo(e, t) {
1790
- const n = typeof e == "string" ? ut[e] : e, r = Go(n), o = Fe(t);
1791
- let s = 0;
1792
- for (let p = 0; p < r.length; p++) r[p].at <= o && (s = p);
1793
- const i = r[s], l = r[Math.min(s + 1, r.length - 1)], a = l.at > i.at ? (o - i.at) / (l.at - i.at) : 0, h = Se(i.pose, l.pose, Le(l.easing ?? "ease-in-out")(Fe(a))), c = jo(n, o);
1863
+ function Ys(e, t) {
1864
+ const n = typeof e == "string" ? Pt[e] : e, s = Fs(n), o = Ve(t);
1865
+ let r = 0;
1866
+ for (let u = 0; u < s.length; u++) s[u].at <= o && (r = u);
1867
+ const l = s[r], i = s[Math.min(r + 1, s.length - 1)], a = i.at > l.at ? (o - l.at) / (i.at - l.at) : 0, h = Pe(l.pose, i.pose, Qe(i.easing ?? "ease-in-out")(Ve(a))), c = Ns(n, o);
1794
1868
  return c === void 0 ? { ...h, spin: 0, rise: 0 } : {
1795
1869
  ...h,
1796
- spin: n.spin * Jo(c),
1870
+ spin: n.spin * Rs(c),
1797
1871
  rise: 4 * n.height * c * (1 - c)
1798
1872
  };
1799
1873
  }
1800
- function Qo(e, t, n) {
1801
- const r = typeof e == "string" ? ut[e] : e, o = Fe(t), s = Fe((o - r.takeoff) / (r.landing - r.takeoff));
1802
- return r.travel * n * s;
1874
+ function Cs(e, t, n) {
1875
+ const s = typeof e == "string" ? Pt[e] : e, o = Ve(t), r = Ve((o - s.takeoff) / (s.landing - s.takeoff));
1876
+ return s.travel * n * r;
1803
1877
  }
1804
- function rs(e, t, n = {}) {
1805
- const r = typeof t == "string" ? ut[t] : t, o = n.start ?? 0, s = n.duration ?? r.duration, i = n.samples ?? 48, l = Array.from({ length: i + 1 }, (c, p) => {
1806
- const d = p / i;
1807
- return { time: o + d * s, progress: d, pose: Zo(r, d) };
1808
- }), h = Object.keys(J).filter((c) => l.some((p) => p.pose[c] !== J[c])).map((c) => ({
1878
+ function Hi(e, t, n = {}) {
1879
+ const s = typeof t == "string" ? Pt[t] : t, o = n.start ?? 0, r = n.duration ?? s.duration, l = n.samples ?? 48, i = Array.from({ length: l + 1 }, (c, u) => {
1880
+ const g = u / l;
1881
+ return { time: o + g * r, progress: g, pose: Ys(s, g) };
1882
+ }), h = Object.keys(_).filter((c) => i.some((u) => u.pose[c] !== _[c])).map((c) => ({
1809
1883
  id: `${e}-${c}`,
1810
1884
  target: e,
1811
1885
  property: c,
1812
- keyframes: l.map((p) => ({ time: p.time, value: p.pose[c] }))
1886
+ keyframes: i.map((u) => ({ time: u.time, value: u.pose[c] }))
1813
1887
  }));
1814
- if (n.height !== void 0 && r.travel !== 0) {
1888
+ if (n.height !== void 0 && s.travel !== 0) {
1815
1889
  const c = (n.facing ?? 1) < 0 ? -1 : 1;
1816
1890
  h.push({
1817
1891
  id: `${e}-x`,
1818
1892
  target: e,
1819
1893
  property: "x",
1820
- keyframes: l.map((p) => ({ time: p.time, value: (n.x ?? 0) + c * Qo(r, p.progress, n.height) }))
1894
+ keyframes: i.map((u) => ({ time: u.time, value: (n.x ?? 0) + c * Cs(s, u.progress, n.height) }))
1821
1895
  });
1822
1896
  }
1823
1897
  return h;
1824
1898
  }
1825
- const er = {
1899
+ const Ds = {
1826
1900
  leftHip: -55,
1827
1901
  leftKnee: -95,
1828
1902
  rightHip: 55,
@@ -1834,7 +1908,7 @@ const er = {
1834
1908
  lean: 22,
1835
1909
  stretch: 0.94,
1836
1910
  headTilt: 6
1837
- }, tr = {
1911
+ }, Xs = {
1838
1912
  leftHip: 0,
1839
1913
  leftKnee: 0,
1840
1914
  rightHip: 0,
@@ -1848,7 +1922,7 @@ const er = {
1848
1922
  lean: 0,
1849
1923
  stretch: 1.08,
1850
1924
  headTilt: 0
1851
- }, Me = {
1925
+ }, _e = {
1852
1926
  leftHip: -128,
1853
1927
  leftKnee: -152,
1854
1928
  rightHip: 128,
@@ -1862,7 +1936,7 @@ const er = {
1862
1936
  lean: 26,
1863
1937
  stretch: 1,
1864
1938
  headTilt: 14
1865
- }, nr = {
1939
+ }, qs = {
1866
1940
  leftHip: -22,
1867
1941
  leftKnee: -30,
1868
1942
  rightHip: 22,
@@ -1875,7 +1949,7 @@ const er = {
1875
1949
  rightElbow: 0,
1876
1950
  lean: 8,
1877
1951
  headTilt: 0
1878
- }, or = {
1952
+ }, Gs = {
1879
1953
  leftHip: -58,
1880
1954
  leftKnee: -100,
1881
1955
  rightHip: 58,
@@ -1889,42 +1963,42 @@ const er = {
1889
1963
  lean: 20,
1890
1964
  stretch: 0.93
1891
1965
  };
1892
- function fe(e, t, n, r, o, s = 1300) {
1966
+ function pe(e, t, n, s, o, r = 1300) {
1893
1967
  return {
1894
1968
  label: e,
1895
1969
  view: 1,
1896
1970
  spin: t,
1897
1971
  height: n,
1898
- travel: r,
1972
+ travel: s,
1899
1973
  takeoff: 0.27,
1900
1974
  landing: 0.8,
1901
- duration: s,
1975
+ duration: r,
1902
1976
  keys: [
1903
1977
  { at: 0, reset: !0 },
1904
- { at: 0.16, pose: er },
1905
- { at: 0.27, pose: tr, easing: "ease-out-quad" },
1978
+ { at: 0.16, pose: Ds },
1979
+ { at: 0.27, pose: Xs, easing: "ease-out-quad" },
1906
1980
  ...o,
1907
- { at: 0.76, pose: nr },
1908
- { at: 0.86, pose: or, easing: "ease-out-quad" },
1981
+ { at: 0.76, pose: qs },
1982
+ { at: 0.86, pose: Gs, easing: "ease-out-quad" },
1909
1983
  { at: 1, reset: !0 }
1910
1984
  ]
1911
1985
  };
1912
1986
  }
1913
- const ut = {
1914
- frontFlip: fe("Front flip (tuck)", 360, 0.56, 0.35, [
1915
- { at: 0.38, pose: Me, easing: "ease-out-cubic" },
1916
- { at: 0.64, pose: Me }
1987
+ const Pt = {
1988
+ frontFlip: pe("Front flip (tuck)", 360, 0.56, 0.35, [
1989
+ { at: 0.38, pose: _e, easing: "ease-out-cubic" },
1990
+ { at: 0.64, pose: _e }
1917
1991
  ]),
1918
- backFlip: fe("Back flip (tuck)", -360, 0.58, -0.15, [
1919
- { at: 0.36, pose: { ...Me, lean: 18 }, easing: "ease-out-cubic" },
1920
- { at: 0.64, pose: { ...Me, lean: 18 } }
1992
+ backFlip: pe("Back flip (tuck)", -360, 0.58, -0.15, [
1993
+ { at: 0.36, pose: { ..._e, lean: 18 }, easing: "ease-out-cubic" },
1994
+ { at: 0.64, pose: { ..._e, lean: 18 } }
1921
1995
  ]),
1922
- layout: fe("Back layout (straight body)", -360, 0.66, -0.2, [
1996
+ layout: pe("Back layout (straight body)", -360, 0.66, -0.2, [
1923
1997
  // Arched, arms overhead, legs together and long.
1924
1998
  { at: 0.4, pose: { leftHip: 8, rightHip: -8, leftKnee: 0, rightKnee: 0, leftAnkle: 60, rightAnkle: 60, leftShoulder: -178, rightShoulder: 178, lean: -18, headTilt: -14 } },
1925
1999
  { at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
1926
2000
  ], 1400),
1927
- scissorFlip: fe("Scissor flip", 360, 0.6, 0.45, [
2001
+ scissorFlip: pe("Scissor flip", 360, 0.6, 0.45, [
1928
2002
  // The legs scissor through the turn: left kicks high, then they switch.
1929
2003
  { at: 0.36, pose: { leftHip: -105, leftKnee: 0, rightHip: -40, rightKnee: -20, leftAnkle: 50, rightAnkle: 50, leftShoulder: -150, rightShoulder: 150, leftElbow: 0, rightElbow: 0, lean: 12 }, easing: "ease-out-cubic" },
1930
2004
  { at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
@@ -1970,7 +2044,7 @@ const ut = {
1970
2044
  ]
1971
2045
  },
1972
2046
  // Leaps: no turn, the shape is the trick.
1973
- splitLeap: fe("Split leap (grand jeté)", 0, 0.36, 0.9, [
2047
+ splitLeap: pe("Split leap (grand jeté)", 0, 0.36, 0.9, [
1974
2048
  // A front split in the air: front leg reaching, back leg long, arms open.
1975
2049
  { at: 0.4, pose: { leftHip: -96, rightHip: -84, leftKnee: 0, rightKnee: 0, leftAnkle: 55, rightAnkle: 55, leftShoulder: -130, rightShoulder: -105, leftElbow: 0, rightElbow: 0, lean: 4, headTilt: -6 }, easing: "ease-out-cubic" },
1976
2050
  { at: 0.64, pose: { lean: 2 } }
@@ -1996,12 +2070,12 @@ const ut = {
1996
2070
  { at: 1, reset: !0 }
1997
2071
  ]
1998
2072
  },
1999
- backHandspring: fe("Back handspring", -360, 0.16, -0.7, [
2073
+ backHandspring: pe("Back handspring", -360, 0.16, -0.7, [
2000
2074
  // Arms reach back overhead to the ground, legs snap over.
2001
2075
  { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
2002
2076
  { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
2003
2077
  ], 1200)
2004
- }, Xe = 0.215, qe = 0.205, rr = 0.065, Bt = 0.035, sr = 0.165, lr = 0.155, ir = 12, ar = (e) => e * Math.PI / 180, V = {
2078
+ }, st = 0.215, rt = 0.205, Us = 0.065, tn = 0.035, zs = 0.165, Vs = 0.155, js = 12, Js = (e) => e * Math.PI / 180, X = {
2005
2079
  turn: 0,
2006
2080
  lean: 0,
2007
2081
  side: 0,
@@ -2043,33 +2117,33 @@ const ut = {
2043
2117
  lookX: 0,
2044
2118
  lookY: 0
2045
2119
  };
2046
- function j(e = {}) {
2047
- return { ...V, ...e };
2120
+ function ee(e = {}) {
2121
+ return { ...X, ...e };
2048
2122
  }
2049
- const hr = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2050
- function ss(e) {
2123
+ const Zs = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2124
+ function vi(e) {
2051
2125
  const t = {};
2052
- for (const [n, r] of Object.entries(e)) {
2053
- const o = n.replace(/(^|\.)(left|right)(\.|$)/, (s, i, l, a) => `${i}${l === "left" ? "right" : "left"}${a}`);
2054
- t[o] = hr.has(n) ? -r : r;
2126
+ for (const [n, s] of Object.entries(e)) {
2127
+ const o = n.replace(/(^|\.)(left|right)(\.|$)/, (r, l, i, a) => `${l}${i === "left" ? "right" : "left"}${a}`);
2128
+ t[o] = Zs.has(n) ? -s : s;
2055
2129
  }
2056
2130
  return t;
2057
2131
  }
2058
- function G(e, t) {
2132
+ function Z(e, t) {
2059
2133
  const n = {};
2060
- for (const r of ["left", "right"]) for (const [o, s] of Object.entries(t)) n[`${e}.${r}.${o}`] = s;
2134
+ for (const s of ["left", "right"]) for (const [o, r] of Object.entries(t)) n[`${e}.${s}.${o}`] = r;
2061
2135
  return n;
2062
2136
  }
2063
- const cr = {
2064
- rest: V,
2065
- wave: j({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2066
- cheer: j({ ...G("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2067
- point: j({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
2068
- handsOnHips: j({ ...G("arm", { spread: 50, bend: -105, elbow: 0 }), ...G("leg", { spread: 9 }), smile: 0.8 }),
2069
- think: j({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
2070
- shrug: j({ ...G("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
2071
- sit: j({ ...G("leg", { swing: 90, knee: 90, spread: 4 }), ...G("arm", { swing: 25, elbow: 45, spread: 8 }) }),
2072
- kneel: j({
2137
+ const Qs = {
2138
+ rest: X,
2139
+ wave: ee({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2140
+ cheer: ee({ ...Z("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2141
+ point: ee({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
2142
+ handsOnHips: ee({ ...Z("arm", { spread: 50, bend: -105, elbow: 0 }), ...Z("leg", { spread: 9 }), smile: 0.8 }),
2143
+ think: ee({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
2144
+ shrug: ee({ ...Z("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
2145
+ sit: ee({ ...Z("leg", { swing: 90, knee: 90, spread: 4 }), ...Z("arm", { swing: 25, elbow: 45, spread: 8 }) }),
2146
+ kneel: ee({
2073
2147
  "leg.left.swing": 90,
2074
2148
  "leg.left.knee": 90,
2075
2149
  // The back thigh leans back a little so its knee meets the ground beside the
@@ -2077,44 +2151,44 @@ const cr = {
2077
2151
  "leg.right.swing": -18,
2078
2152
  "leg.right.knee": 108,
2079
2153
  "leg.right.ankle": 16,
2080
- ...G("arm", { swing: 20, elbow: 30 })
2154
+ ...Z("arm", { swing: 20, elbow: 30 })
2081
2155
  }),
2082
- crouch: j({ ...G("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...G("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2156
+ crouch: ee({ ...Z("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...Z("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2083
2157
  // On hands and knees: the back nearly level, arms straight down, the toes
2084
2158
  // pointed back along the ground.
2085
- crawl: j({ lean: 82, "head.nod": -35, ...G("arm", { swing: 80, elbow: 0, spread: 4 }), ...G("leg", { knee: 92, ankle: -88 }) }),
2086
- lieDown: j({ roll: 90, ...G("arm", { spread: 8 }), "head.nod": 0 })
2159
+ crawl: ee({ lean: 82, "head.nod": -35, ...Z("arm", { swing: 80, elbow: 0, spread: 4 }), ...Z("leg", { knee: 92, ankle: -88 }) }),
2160
+ lieDown: ee({ roll: 90, ...Z("arm", { spread: 8 }), "head.nod": 0 })
2087
2161
  };
2088
- function fr(e = {}) {
2089
- const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, r = e.hipWidth ?? 0.022, o = Math.max(0.12, 1 - t - Bt - (Xe + qe)), s = (a) => ({
2162
+ function er(e = {}) {
2163
+ const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, s = e.hipWidth ?? 0.022, o = Math.max(0.12, 1 - t - tn - (st + rt)), r = (a) => ({
2090
2164
  id: `arm.${a}`,
2091
2165
  parent: "spine",
2092
2166
  offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
2093
2167
  rest: [0, -1, 0],
2094
2168
  side: a === "left" ? 1 : -1,
2095
2169
  bones: [
2096
- { length: sr, width: [1.25, 0.9] },
2097
- { length: lr, width: [0.9, 0.75] }
2170
+ { length: zs, width: [1.25, 0.9] },
2171
+ { length: Vs, width: [0.9, 0.75] }
2098
2172
  ]
2099
- }), i = (a) => ({
2173
+ }), l = (a) => ({
2100
2174
  id: `leg.${a}`,
2101
2175
  parent: null,
2102
- offset: [(a === "left" ? 1 : -1) * r, 0, 0],
2176
+ offset: [(a === "left" ? 1 : -1) * s, 0, 0],
2103
2177
  rest: [0, -1, 0],
2104
2178
  side: a === "left" ? 1 : -1,
2105
2179
  bones: [
2106
- { length: Xe, width: [1.45, 1.05] },
2107
- { length: qe, width: [1.05, 0.85] },
2108
- { length: rr, width: [0.95, 0.7] }
2180
+ { length: st, width: [1.45, 1.05] },
2181
+ { length: rt, width: [1.05, 0.85] },
2182
+ { length: Us, width: [0.95, 0.7] }
2109
2183
  ]
2110
- }), l = (a, h) => a[h] ?? V[h] ?? 0;
2184
+ }), i = (a, h) => a[h] ?? X[h] ?? 0;
2111
2185
  return {
2112
2186
  id: "human",
2113
- hipHeight: Xe + qe,
2187
+ hipHeight: st + rt,
2114
2188
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
2115
2189
  chains: [
2116
- i("left"),
2117
- i("right"),
2190
+ l("left"),
2191
+ l("right"),
2118
2192
  {
2119
2193
  id: "spine",
2120
2194
  parent: null,
@@ -2124,9 +2198,9 @@ function fr(e = {}) {
2124
2198
  { length: o / 2, width: [1.4, 1.1] }
2125
2199
  ]
2126
2200
  },
2127
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Bt, width: [1, 0.9] }] },
2128
- s("left"),
2129
- s("right")
2201
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: tn, width: [1, 0.9] }] },
2202
+ r("left"),
2203
+ r("right")
2130
2204
  ],
2131
2205
  head: { on: "neck", size: t },
2132
2206
  contacts: [
@@ -2144,47 +2218,47 @@ function fr(e = {}) {
2144
2218
  ],
2145
2219
  angles(a, h) {
2146
2220
  if (h.id === "spine") {
2147
- const f = -l(a, "lean") / 2, g = l(a, "side") / 2;
2221
+ const d = -i(a, "lean") / 2, m = i(a, "side") / 2;
2148
2222
  return [
2149
- { swing: f, spread: g },
2150
- { swing: f, spread: g }
2223
+ { swing: d, spread: m },
2224
+ { swing: d, spread: m }
2151
2225
  ];
2152
2226
  }
2153
2227
  if (h.id === "neck") return [{ swing: 0, spread: 0 }];
2154
- const [c, p] = h.id.split("."), d = (f) => l(a, `${c}.${p}.${f}`);
2228
+ const [c, u] = h.id.split("."), g = (d) => i(a, `${c}.${u}.${d}`);
2155
2229
  if (c === "arm")
2156
2230
  return [
2157
- { swing: d("swing"), spread: d("spread") },
2158
- { swing: d("elbow"), spread: d("bend") }
2231
+ { swing: g("swing"), spread: g("spread") },
2232
+ { swing: g("elbow"), spread: g("bend") }
2159
2233
  ];
2160
- const u = (h.side ?? 1) * d("rotate"), b = 1 - Math.cos(ar(d("rotate")));
2234
+ const f = (h.side ?? 1) * g("rotate"), p = 1 - Math.cos(Js(g("rotate")));
2161
2235
  return [
2162
- { swing: d("swing"), spread: d("spread"), yaw: u },
2163
- { swing: -d("knee"), spread: 0, yaw: u },
2236
+ { swing: g("swing"), spread: g("spread"), yaw: f },
2237
+ { swing: -g("knee"), spread: 0, yaw: f },
2164
2238
  // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2165
- { swing: 90 + d("ankle") - b * (d("swing") - d("knee")), spread: 0, yaw: (ir + d("toeOut")) * (h.side ?? 1) }
2239
+ { swing: 90 + g("ankle") - p * (g("swing") - g("knee")), spread: 0, yaw: (js + g("toeOut")) * (h.side ?? 1) }
2166
2240
  ];
2167
2241
  },
2168
2242
  withAngles(a, h, c) {
2169
- const [p, d] = h.id.split("."), u = (b) => `${p}.${d}.${b}`;
2170
- return p === "arm" ? {
2243
+ const [u, g] = h.id.split("."), f = (p) => `${u}.${g}.${p}`;
2244
+ return u === "arm" ? {
2171
2245
  ...a,
2172
- [u("swing")]: c[0].swing,
2173
- [u("spread")]: c[0].spread,
2174
- [u("elbow")]: c[1].swing,
2175
- [u("bend")]: c[1].spread
2176
- } : p === "leg" ? { ...a, [u("swing")]: c[0].swing, [u("spread")]: c[0].spread, [u("knee")]: -c[1].swing } : a;
2246
+ [f("swing")]: c[0].swing,
2247
+ [f("spread")]: c[0].spread,
2248
+ [f("elbow")]: c[1].swing,
2249
+ [f("bend")]: c[1].spread
2250
+ } : u === "leg" ? { ...a, [f("swing")]: c[0].swing, [f("spread")]: c[0].spread, [f("knee")]: -c[1].swing } : a;
2177
2251
  },
2178
2252
  boneScale(a, h) {
2179
- const c = Math.min(3, Math.max(0.3, l(a, "stretch")));
2253
+ const c = Math.min(3, Math.max(0.3, i(a, "stretch")));
2180
2254
  return h?.id.startsWith("arm.") ? Math.sqrt(c) : c;
2181
2255
  },
2182
2256
  headPose(a) {
2183
- const h = Math.min(3, Math.max(0.3, l(a, "stretch")));
2257
+ const h = Math.min(3, Math.max(0.3, i(a, "stretch")));
2184
2258
  return {
2185
- yaw: l(a, "head.turn"),
2186
- nod: l(a, "head.nod"),
2187
- tilt: l(a, "head.tilt"),
2259
+ yaw: i(a, "head.turn"),
2260
+ nod: i(a, "head.nod"),
2261
+ tilt: i(a, "head.tilt"),
2188
2262
  // The head keeps its area: taller and narrower when stretched.
2189
2263
  sx: 1 / Math.sqrt(h),
2190
2264
  sy: Math.sqrt(h)
@@ -2209,15 +2283,15 @@ function fr(e = {}) {
2209
2283
  }
2210
2284
  };
2211
2285
  }
2212
- function ls(e) {
2286
+ function Ti(e) {
2213
2287
  const t = e.split(".");
2214
2288
  if (t[0] === "hand" && t.length >= 3) {
2215
- const r = `${t[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, s = t.slice(2).join(".");
2216
- return `${r} · ${o[s] ?? s.replace(".curl", " curl").replace(".across", " across")}`;
2289
+ const s = `${t[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, r = t.slice(2).join(".");
2290
+ return `${s} · ${o[r] ?? r.replace(".curl", " curl").replace(".across", " across")}`;
2217
2291
  }
2218
2292
  if (t.length === 3) {
2219
- const [r, o, s] = t;
2220
- return `${`${o === "left" ? "Left" : "Right"} ${r}`} · ${{
2293
+ const [s, o, r] = t;
2294
+ return `${`${o === "left" ? "Left" : "Right"} ${s}`} · ${{
2221
2295
  swing: "forward / back",
2222
2296
  spread: "out / in",
2223
2297
  elbow: "elbow bend",
@@ -2226,7 +2300,7 @@ function ls(e) {
2226
2300
  ankle: "foot tilt",
2227
2301
  toeOut: "toes out / in",
2228
2302
  rotate: "turn out at the hip"
2229
- }[s] ?? s}`;
2303
+ }[r] ?? r}`;
2230
2304
  }
2231
2305
  return {
2232
2306
  turn: "View (front → side → back)",
@@ -2251,284 +2325,285 @@ function ls(e) {
2251
2325
  lookY: "Look up / down"
2252
2326
  }[e] ?? e;
2253
2327
  }
2254
- const ur = {
2328
+ const tr = {
2255
2329
  leftEye: "eye.left",
2256
2330
  rightEye: "eye.right",
2257
2331
  leftBrow: "brow.left",
2258
2332
  rightBrow: "brow.right"
2259
- }, is = Object.fromEntries(
2260
- Object.entries(Z).map(([e, t]) => [
2333
+ }, Ai = Object.fromEntries(
2334
+ Object.entries(Y).map(([e, t]) => [
2261
2335
  e,
2262
- Object.fromEntries(Object.entries(t).map(([n, r]) => [ur[n] ?? n, r]))
2336
+ Object.fromEntries(Object.entries(t).map(([n, s]) => [tr[n] ?? n, s]))
2263
2337
  ])
2264
2338
  );
2265
- function as(e, t) {
2266
- const n = Math.min(1, Math.max(0, e.turn ?? 0)), r = 1 - n, o = { ...V, turn: n }, s = [
2339
+ function xi(e, t) {
2340
+ const n = Math.min(1, Math.max(0, e.turn ?? 0)), s = 1 - n, o = { ...X, turn: n }, r = [
2267
2341
  { stick: "right", human: "left", s: 1 },
2268
2342
  { stick: "left", human: "right", s: -1 }
2269
2343
  ];
2270
- for (const { stick: i, human: l, s: a } of s) {
2271
- const h = e[`${i}Shoulder`], c = e[`${i}Elbow`];
2272
- o[`arm.${l}.spread`] = h * r, o[`arm.${l}.swing`] = a * h * n, o[`arm.${l}.bend`] = c * r, o[`arm.${l}.elbow`] = a * c * n;
2273
- const p = e[`${i}Hip`], d = e[`${i}Knee`], u = r + a * n;
2274
- o[`leg.${l}.rotate`] = 90 * r, o[`leg.${l}.spread`] = 0, o[`leg.${l}.swing`] = p * u, o[`leg.${l}.knee`] = d * u, o[`leg.${l}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${l}.toeOut`] = (e[`${i}FootOut`] ?? 0) * dr, o[`eye.${l}`] = e[`${i}Eye`], o[`brow.${l}`] = e[`${i}Brow`], t && Object.assign(o, gr(l, t[i] ?? _, e[`${i}Wrist`] ?? 0, n));
2344
+ for (const { stick: i, human: a, s: h } of r) {
2345
+ const c = e[`${i}Shoulder`], u = e[`${i}Elbow`];
2346
+ o[`arm.${a}.spread`] = c * s, o[`arm.${a}.swing`] = h * c * n, o[`arm.${a}.bend`] = u * s, o[`arm.${a}.elbow`] = h * u * n;
2347
+ const g = e[`${i}Hip`], f = e[`${i}Knee`], p = s + h * n;
2348
+ o[`leg.${a}.rotate`] = 90 * s, o[`leg.${a}.spread`] = 0, o[`leg.${a}.swing`] = g * p, o[`leg.${a}.knee`] = f * p, o[`leg.${a}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${a}.toeOut`] = (e[`${i}FootOut`] ?? 0) * nr, o[`eye.${a}`] = e[`${i}Eye`], o[`brow.${a}`] = e[`${i}Brow`], t && Object.assign(o, or(a, t[i] ?? L, e[`${i}Wrist`] ?? 0, n));
2275
2349
  }
2276
- o.lean = e.lean * n, o.side = e.lean * r, o["head.tilt"] = e.headTilt * r, o["head.nod"] = e.headTilt * n;
2350
+ const l = e.bend ?? 0;
2351
+ o.lean = (e.lean + l * 0.5) * n, o.side = (e.lean + l * 0.5) * s, o["head.tilt"] = (e.headTilt + l * 0.5) * s, o["head.nod"] = (e.headTilt + l * 0.5) * n;
2277
2352
  for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
2278
2353
  return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
2279
2354
  }
2280
- const dr = 70;
2281
- function gr(e, t, n, r) {
2282
- const o = e === "right" ? 1 - r : 1 + r, s = {};
2283
- for (const i of Object.keys(_)) s[`hand.${e}.${i}`] = t[i] ?? _[i];
2284
- return s[`hand.${e}.turn`] = (t.turn ?? 0) - o, s[`hand.${e}.roll`] = (t.roll ?? 0) + n, s;
2355
+ const nr = 70;
2356
+ function or(e, t, n, s) {
2357
+ const o = e === "right" ? 1 - s : 1 + s, r = {};
2358
+ for (const l of Object.keys(L)) r[`hand.${e}.${l}`] = t[l] ?? L[l];
2359
+ return r[`hand.${e}.turn`] = (t.turn ?? 0) - o, r[`hand.${e}.roll`] = (t.roll ?? 0) + n, r;
2285
2360
  }
2286
- const Q = (e) => e * Math.PI / 180;
2287
- function rn([e, t, n], r) {
2288
- const o = Math.cos(r), s = Math.sin(r);
2289
- return [e, t * o + n * s, -t * s + n * o];
2361
+ const te = (e) => e * Math.PI / 180;
2362
+ function Rn([e, t, n], s) {
2363
+ const o = Math.cos(s), r = Math.sin(s);
2364
+ return [e, t * o + n * r, -t * r + n * o];
2290
2365
  }
2291
- function dt([e, t, n], r) {
2292
- const o = Math.cos(r), s = Math.sin(r);
2293
- return [e * o - t * s, e * s + t * o, n];
2366
+ function Wt([e, t, n], s) {
2367
+ const o = Math.cos(s), r = Math.sin(s);
2368
+ return [e * o - t * r, e * r + t * o, n];
2294
2369
  }
2295
- function he([e, t, n], r) {
2296
- const o = Math.cos(r), s = Math.sin(r);
2297
- return [e * o + n * s, t, -e * s + n * o];
2370
+ function ge([e, t, n], s) {
2371
+ const o = Math.cos(s), r = Math.sin(s);
2372
+ return [e * o + n * r, t, -e * r + n * o];
2298
2373
  }
2299
- const le = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Re = (e, t) => [e[0] * t, e[1] * t, e[2] * t], We = (e, t) => dt(rn(e, t.swing), t.spread);
2300
- function Ue(e, t) {
2301
- const n = he(e, t);
2374
+ const he = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], je = (e, t) => [e[0] * t, e[1] * t, e[2] * t], De = (e, t) => Wt(Rn(e, t.swing), t.spread);
2375
+ function it(e, t) {
2376
+ const n = ge(e, t);
2302
2377
  return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2303
2378
  }
2304
- function gt(e, t, n) {
2305
- const r = n, s = [0, e.hipHeight * r * (e.boneScale?.(t, null) ?? 1), 0], i = {};
2306
- for (const f of e.chains) {
2307
- const g = f.parent ? i[f.parent] : void 0;
2308
- if (f.parent && !g) throw new Error(`body plan ${e.id}: chain ${f.id} comes before its parent ${f.parent}`);
2309
- const m = f.at ?? (g ? g.joints3.length - 1 : 0), k = g ? g.joints3[m] : s, y = g ? g.frames[Math.max(0, m - 1)] : { swing: 0, spread: 0 }, H = f.offset ? le(k, We(Re(f.offset, r), y)) : k, E = f.side ?? 1, w = e.boneScale?.(t, f) ?? 1, M = e.angles(t, f), x = [H], S = [];
2310
- let A = y.swing, K = y.spread;
2311
- f.bones.forEach((v, T) => {
2312
- const W = M[T] ?? { swing: 0, spread: 0 };
2313
- A += Q(W.swing), K += Q(W.spread) * E, S.push({ swing: A, spread: K });
2314
- const B = he(We(f.rest, { swing: A, spread: K }), Q(W.yaw ?? 0));
2315
- x.push(le(x[T], Re(B, v.length * r * w)));
2316
- }), i[f.id] = { joints3: x, frames: S };
2317
- }
2318
- const l = i[e.head.on], a = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, h = l.frames[l.frames.length - 1], c = e.head.size / 2 * r, p = c * a.sx, d = c * a.sy, u = (f) => We(he(rn(dt(f, -Q(a.tilt)), -Q(a.nod)), Q(a.yaw)), h), b = le(l.joints3[l.joints3.length - 1], u([0, d, 0]));
2319
- return { height: r, root: s, chains: i, head: { center: b, rx: p, ry: d, toBody: u } };
2320
- }
2321
- function pt(e, t, n) {
2322
- const r = n.height, o = Q(90 * (t.turn ?? 0)), s = gt(e, t, r), { root: i } = s, l = s.chains, { rx: a, ry: h } = s.head, c = s.head.toBody, p = s.head.center, d = {};
2323
- for (const S of e.chains) {
2324
- const { joints3: A, frames: K } = l[S.id], v = A.map((T) => Ue(T, o));
2325
- d[S.id] = {
2326
- id: S.id,
2327
- joints3: A,
2328
- frames: K,
2329
- points: v.map((T) => T.point),
2330
- depths: v.map((T) => T.depth)
2379
+ function Ot(e, t, n) {
2380
+ const s = n, r = [0, e.hipHeight * s * (e.boneScale?.(t, null) ?? 1), 0], l = {};
2381
+ for (const d of e.chains) {
2382
+ const m = d.parent ? l[d.parent] : void 0;
2383
+ if (d.parent && !m) throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);
2384
+ const b = d.at ?? (m ? m.joints3.length - 1 : 0), y = m ? m.joints3[b] : r, E = m ? m.frames[Math.max(0, b - 1)] : { swing: 0, spread: 0 }, H = d.offset ? he(y, De(je(d.offset, s), E)) : y, M = d.side ?? 1, A = e.boneScale?.(t, d) ?? 1, w = e.angles(t, d), S = [H], k = [];
2385
+ let x = E.swing, v = E.spread;
2386
+ d.bones.forEach((T, K) => {
2387
+ const P = w[K] ?? { swing: 0, spread: 0 };
2388
+ x += te(P.swing), v += te(P.spread) * M, k.push({ swing: x, spread: v });
2389
+ const I = ge(De(d.rest, { swing: x, spread: v }), te(P.yaw ?? 0));
2390
+ S.push(he(S[K], je(I, T.length * s * A)));
2391
+ }), l[d.id] = { joints3: S, frames: k };
2392
+ }
2393
+ const i = l[e.head.on], a = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, h = i.frames[i.frames.length - 1], c = e.head.size / 2 * s, u = c * a.sx, g = c * a.sy, f = (d) => De(ge(Rn(Wt(d, -te(a.tilt)), -te(a.nod)), te(a.yaw)), h), p = he(i.joints3[i.joints3.length - 1], f([0, g, 0]));
2394
+ return { height: s, root: r, chains: l, head: { center: p, rx: u, ry: g, toBody: f } };
2395
+ }
2396
+ function It(e, t, n) {
2397
+ const s = n.height, o = te(90 * (t.turn ?? 0)), r = Ot(e, t, s), { root: l } = r, i = r.chains, { rx: a, ry: h } = r.head, c = r.head.toBody, u = r.head.center, g = {};
2398
+ for (const k of e.chains) {
2399
+ const { joints3: x, frames: v } = i[k.id], T = x.map((K) => it(K, o));
2400
+ g[k.id] = {
2401
+ id: k.id,
2402
+ joints3: x,
2403
+ frames: v,
2404
+ points: T.map((K) => K.point),
2405
+ depths: T.map((K) => K.depth)
2331
2406
  };
2332
2407
  }
2333
- const u = Ue(p, o), b = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((S) => he(c(S), o)), f = Ue(i, o).point, g = Q(t.roll ?? 0), m = (S) => {
2334
- const A = S.x - f.x, K = S.y - f.y;
2335
- return { x: f.x + A * Math.cos(g) - K * Math.sin(g), y: f.y + A * Math.sin(g) + K * Math.cos(g) };
2336
- }, k = ([S, A, K]) => [S * Math.cos(g) + A * Math.sin(g), -S * Math.sin(g) + A * Math.cos(g), K];
2337
- for (const S of Object.values(d)) S.points = S.points.map(m);
2338
- const y = {
2339
- center: m(u.point),
2340
- depth: u.depth,
2408
+ const f = it(u, o), p = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((k) => ge(c(k), o)), d = it(l, o).point, m = te(t.roll ?? 0), b = (k) => {
2409
+ const x = k.x - d.x, v = k.y - d.y;
2410
+ return { x: d.x + x * Math.cos(m) - v * Math.sin(m), y: d.y + x * Math.sin(m) + v * Math.cos(m) };
2411
+ }, y = ([k, x, v]) => [k * Math.cos(m) + x * Math.sin(m), -k * Math.sin(m) + x * Math.cos(m), v];
2412
+ for (const k of Object.values(g)) k.points = k.points.map(b);
2413
+ const E = {
2414
+ center: b(f.point),
2415
+ depth: f.depth,
2341
2416
  rx: a,
2342
2417
  ry: h,
2343
2418
  angle: 0,
2344
- axes: b.map(k)
2345
- }, H = y.axes[1];
2346
- y.angle = Math.atan2(H[0], H[1]);
2347
- const E = (S) => {
2348
- if ("head" in S) return { x: y.center.x + H[0] * h, y: y.center.y - H[1] * h };
2349
- const A = d[S.chain];
2350
- return A.points[Math.min(S.joint, A.points.length - 1)];
2419
+ axes: p.map(y)
2420
+ }, H = E.axes[1];
2421
+ E.angle = Math.atan2(H[0], H[1]);
2422
+ const M = (k) => {
2423
+ if ("head" in k) return { x: E.center.x + H[0] * h, y: E.center.y - H[1] * h };
2424
+ const x = g[k.chain];
2425
+ return x.points[Math.min(k.joint, x.points.length - 1)];
2351
2426
  };
2352
- let w = 0;
2353
- (n.contact ?? "ground") === "ground" && (w = -Math.max(...e.contacts.map((S) => E(S).y))), w -= (t.lift ?? 0) * r;
2354
- const M = (S) => ({ x: S.x, y: S.y + w });
2355
- for (const S of Object.values(d)) S.points = S.points.map(M);
2356
- y.center = M(y.center);
2357
- const x = e.contacts.map((S) => ({ spec: S, point: E(S) }));
2427
+ let A = 0;
2428
+ (n.contact ?? "ground") === "ground" && (A = -Math.max(...e.contacts.map((k) => M(k).y))), A -= (t.lift ?? 0) * s;
2429
+ const w = (k) => ({ x: k.x, y: k.y + A });
2430
+ for (const k of Object.values(g)) k.points = k.points.map(w);
2431
+ E.center = w(E.center);
2432
+ const S = e.contacts.map((k) => ({ spec: k, point: M(k) }));
2358
2433
  return {
2359
- height: r,
2434
+ height: s,
2360
2435
  view: o,
2361
- chains: d,
2362
- head: y,
2363
- hip: M(m(f)),
2364
- contacts: x,
2365
- groundY: Math.max(...x.map((S) => S.point.y))
2436
+ chains: g,
2437
+ head: E,
2438
+ hip: w(b(d)),
2439
+ contacts: S,
2440
+ groundY: Math.max(...S.map((k) => k.point.y))
2366
2441
  };
2367
2442
  }
2368
- const ot = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], sn = (e) => {
2443
+ const kt = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ln = (e) => {
2369
2444
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
2370
2445
  return [e[0] / t, e[1] / t, e[2] / t];
2371
2446
  };
2372
- function ln(e, t, n) {
2373
- const r = n.height, o = Q(90 * (t.turn ?? 0)), s = Q(t.roll ?? 0), i = gt(e, t, r), l = he(i.root, o), a = (g) => le(dt(ot(he(g, o), l), -s), l), h = {};
2374
- for (const g of e.chains) h[g.id] = i.chains[g.id].joints3.map(a);
2375
- const c = a(i.head.center), p = (g) => sn(ot(a(le(i.head.center, i.head.toBody(g))), c)), d = [p([1, 0, 0]), p([0, 1, 0]), p([0, 0, 1])], u = (g) => {
2376
- if ("head" in g) return le(c, Re(d[1], i.head.ry));
2377
- const m = h[g.chain];
2378
- return m[Math.min(g.joint, m.length - 1)];
2447
+ function Nn(e, t, n) {
2448
+ const s = n.height, o = te(90 * (t.turn ?? 0)), r = te(t.roll ?? 0), l = Ot(e, t, s), i = ge(l.root, o), a = (m) => he(Wt(kt(ge(m, o), i), -r), i), h = {};
2449
+ for (const m of e.chains) h[m.id] = l.chains[m.id].joints3.map(a);
2450
+ const c = a(l.head.center), u = (m) => Ln(kt(a(he(l.head.center, l.head.toBody(m))), c)), g = [u([1, 0, 0]), u([0, 1, 0]), u([0, 0, 1])], f = (m) => {
2451
+ if ("head" in m) return he(c, je(g[1], l.head.ry));
2452
+ const b = h[m.chain];
2453
+ return b[Math.min(m.joint, b.length - 1)];
2379
2454
  };
2380
- let b = 0;
2381
- (n.contact ?? "ground") === "ground" && (b = -Math.min(...e.contacts.map((g) => u(g)[1]))), b += (t.lift ?? 0) * r;
2382
- const f = (g) => [g[0], g[1] + b, g[2]];
2455
+ let p = 0;
2456
+ (n.contact ?? "ground") === "ground" && (p = -Math.min(...e.contacts.map((m) => f(m)[1]))), p += (t.lift ?? 0) * s;
2457
+ const d = (m) => [m[0], m[1] + p, m[2]];
2383
2458
  return {
2384
- height: r,
2385
- hip: f(l),
2386
- chains: Object.fromEntries(Object.entries(h).map(([g, m]) => [g, m.map(f)])),
2387
- head: { center: f(c), rx: i.head.rx, ry: i.head.ry, axes: d }
2459
+ height: s,
2460
+ hip: d(i),
2461
+ chains: Object.fromEntries(Object.entries(h).map(([m, b]) => [m, b.map(d)])),
2462
+ head: { center: d(c), rx: l.head.rx, ry: l.head.ry, axes: g }
2388
2463
  };
2389
2464
  }
2390
- function an(e, t, n, r) {
2391
- const o = n.height, s = Q(90 * (t.turn ?? 0)), i = gt(e, t, o), l = ln(e, t, n), a = l.hip, h = l.chains, c = l.head.center, p = (S) => {
2392
- if ("head" in S) return le(c, Re(l.head.axes[1], l.head.ry));
2393
- const A = h[S.chain];
2394
- return A[Math.min(S.joint, A.length - 1)];
2395
- }, d = r.toView(a), u = r.toScreen(d), b = r.toScreen([d[0] + 1, d[1], d[2]]), f = Math.hypot(b.x - u.x, b.y - u.y), g = (S) => {
2396
- const A = r.toView(S);
2397
- return { point: r.toScreen(A), depth: A[2] * f };
2398
- }, m = {};
2399
- for (const S of e.chains) {
2400
- const A = h[S.id].map(g);
2401
- m[S.id] = {
2402
- id: S.id,
2403
- joints3: i.chains[S.id].joints3,
2404
- frames: i.chains[S.id].frames,
2405
- points: A.map((K) => K.point),
2406
- depths: A.map((K) => K.depth)
2465
+ function Yn(e, t, n, s) {
2466
+ const o = n.height, r = te(90 * (t.turn ?? 0)), l = Ot(e, t, o), i = Nn(e, t, n), a = i.hip, h = i.chains, c = i.head.center, u = (k) => {
2467
+ if ("head" in k) return he(c, je(i.head.axes[1], i.head.ry));
2468
+ const x = h[k.chain];
2469
+ return x[Math.min(k.joint, x.length - 1)];
2470
+ }, g = s.toView(a), f = s.toScreen(g), p = s.toScreen([g[0] + 1, g[1], g[2]]), d = Math.hypot(p.x - f.x, p.y - f.y), m = (k) => {
2471
+ const x = s.toView(k);
2472
+ return { point: s.toScreen(x), depth: x[2] * d };
2473
+ }, b = {};
2474
+ for (const k of e.chains) {
2475
+ const x = h[k.id].map(m);
2476
+ b[k.id] = {
2477
+ id: k.id,
2478
+ joints3: l.chains[k.id].joints3,
2479
+ frames: l.chains[k.id].frames,
2480
+ points: x.map((v) => v.point),
2481
+ depths: x.map((v) => v.depth)
2407
2482
  };
2408
2483
  }
2409
- const k = r.toView(c), y = r.toScreen(k), H = r.toScreen([k[0] + 1, k[1], k[2]]), E = Math.hypot(H.x - y.x, H.y - y.y), w = l.head.axes.map((S) => sn(ot(r.toView(le(c, S)), k))), M = {
2410
- center: y,
2411
- depth: k[2] * f,
2412
- rx: i.head.rx * E,
2413
- ry: i.head.ry * E,
2414
- angle: Math.atan2(w[1][0], w[1][1]),
2415
- axes: w
2416
- }, x = e.contacts.map((S) => ({ spec: S, point: g(p(S)).point }));
2484
+ const y = s.toView(c), E = s.toScreen(y), H = s.toScreen([y[0] + 1, y[1], y[2]]), M = Math.hypot(H.x - E.x, H.y - E.y), A = i.head.axes.map((k) => Ln(kt(s.toView(he(c, k)), y))), w = {
2485
+ center: E,
2486
+ depth: y[2] * d,
2487
+ rx: l.head.rx * M,
2488
+ ry: l.head.ry * M,
2489
+ angle: Math.atan2(A[1][0], A[1][1]),
2490
+ axes: A
2491
+ }, S = e.contacts.map((k) => ({ spec: k, point: m(u(k)).point }));
2417
2492
  return {
2418
- height: o * f,
2419
- view: s,
2420
- chains: m,
2421
- head: M,
2422
- hip: u,
2423
- contacts: x,
2424
- groundY: Math.max(...x.map((S) => S.point.y))
2493
+ height: o * d,
2494
+ view: r,
2495
+ chains: b,
2496
+ head: w,
2497
+ hip: f,
2498
+ contacts: S,
2499
+ groundY: Math.max(...S.map((k) => k.point.y))
2425
2500
  };
2426
2501
  }
2427
- function hn(e, [t, n, r]) {
2428
- const [o, s, i] = e.axes, l = [
2429
- o[0] * t * e.rx + s[0] * n * e.ry + i[0] * r * e.rx,
2430
- o[1] * t * e.rx + s[1] * n * e.ry + i[1] * r * e.rx,
2431
- o[2] * t * e.rx + s[2] * n * e.ry + i[2] * r * e.rx
2432
- ], a = Math.hypot(t, n, r) || 1, h = (o[2] * t + s[2] * n + i[2] * r) / a;
2433
- return { point: { x: e.center.x + l[0], y: e.center.y - l[1] }, depth: e.depth + l[2], facing: h };
2502
+ function Cn(e, [t, n, s]) {
2503
+ const [o, r, l] = e.axes, i = [
2504
+ o[0] * t * e.rx + r[0] * n * e.ry + l[0] * s * e.rx,
2505
+ o[1] * t * e.rx + r[1] * n * e.ry + l[1] * s * e.rx,
2506
+ o[2] * t * e.rx + r[2] * n * e.ry + l[2] * s * e.rx
2507
+ ], a = Math.hypot(t, n, s) || 1, h = (o[2] * t + r[2] * n + l[2] * s) / a;
2508
+ return { point: { x: e.center.x + i[0], y: e.center.y - i[1] }, depth: e.depth + i[2], facing: h };
2434
2509
  }
2435
- const ve = (e) => e * 180 / Math.PI, ue = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], ze = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], me = (e) => Math.hypot(e[0], e[1], e[2]), rt = (e) => {
2436
- const t = me(e) || 1;
2510
+ const $e = (e) => e * 180 / Math.PI, me = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], lt = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], Te = (e) => Math.hypot(e[0], e[1], e[2]), St = (e) => {
2511
+ const t = Te(e) || 1;
2437
2512
  return [e[0] / t, e[1] / t, e[2] / t];
2438
- }, xe = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2439
- function $t(e) {
2440
- const [t, n, r] = rt(e);
2441
- return { swing: Math.asin(Math.max(-1, Math.min(1, r))), spread: Math.atan2(t, -n) };
2442
- }
2443
- function pr(e, t, n, r, o) {
2444
- const s = e.chains.find((A) => A.id === n);
2445
- if (!s) throw new Error(`reach: no chain ${n} in ${e.id}`);
2446
- if (s.bones.length < 2 || s.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
2513
+ }, Be = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2514
+ function nn(e) {
2515
+ const [t, n, s] = St(e);
2516
+ return { swing: Math.asin(Math.max(-1, Math.min(1, s))), spread: Math.atan2(t, -n) };
2517
+ }
2518
+ function sr(e, t, n, s, o) {
2519
+ const r = e.chains.find((x) => x.id === n);
2520
+ if (!r) throw new Error(`reach: no chain ${n} in ${e.id}`);
2521
+ if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
2447
2522
  if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
2448
- const i = pt(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), l = i.chains[n], a = l.joints3[0], h = me(ue(l.joints3[1], l.joints3[0])), c = me(ue(l.joints3[2], l.joints3[1])), p = s.parent ? i.chains[s.parent].frames[Math.max(0, (s.at ?? i.chains[s.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, d = ue(r, a), u = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, me(d))), b = rt(d), f = s.parent !== null, g = We(s.pole ?? (f ? [0, -0.35, -1] : [0, 0, 1]), p);
2449
- let m = ue(g, [b[0] * ze(g, b), b[1] * ze(g, b), b[2] * ze(g, b)]);
2450
- me(m) < 1e-6 && (m = he([1, 0, 0], 0)), m = rt(m);
2451
- const k = (h * h + u * u - c * c) / (2 * h * u), y = Math.sqrt(Math.max(0, 1 - k * k)), H = [
2452
- a[0] + h * (k * b[0] + y * m[0]),
2453
- a[1] + h * (k * b[1] + y * m[1]),
2454
- a[2] + h * (k * b[2] + y * m[2])
2455
- ], E = [a[0] + b[0] * u, a[1] + b[1] * u, a[2] + b[2] * u], w = s.side ?? 1, M = $t(ue(H, a)), x = $t(ue(E, H)), S = [
2456
- { swing: ve(xe(M.swing - p.swing)), spread: ve(xe(M.spread - p.spread)) * w },
2457
- { swing: ve(xe(x.swing - M.swing)), spread: ve(xe(x.spread - M.spread)) * w }
2523
+ const l = It(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), i = l.chains[n], a = i.joints3[0], h = Te(me(i.joints3[1], i.joints3[0])), c = Te(me(i.joints3[2], i.joints3[1])), u = r.parent ? l.chains[r.parent].frames[Math.max(0, (r.at ?? l.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, g = me(s, a), f = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, Te(g))), p = St(g), d = r.parent !== null, m = De(r.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), u);
2524
+ let b = me(m, [p[0] * lt(m, p), p[1] * lt(m, p), p[2] * lt(m, p)]);
2525
+ Te(b) < 1e-6 && (b = ge([1, 0, 0], 0)), b = St(b);
2526
+ const y = (h * h + f * f - c * c) / (2 * h * f), E = Math.sqrt(Math.max(0, 1 - y * y)), H = [
2527
+ a[0] + h * (y * p[0] + E * b[0]),
2528
+ a[1] + h * (y * p[1] + E * b[1]),
2529
+ a[2] + h * (y * p[2] + E * b[2])
2530
+ ], M = [a[0] + p[0] * f, a[1] + p[1] * f, a[2] + p[2] * f], A = r.side ?? 1, w = nn(me(H, a)), S = nn(me(M, H)), k = [
2531
+ { swing: $e(Be(w.swing - u.swing)), spread: $e(Be(w.spread - u.spread)) * A },
2532
+ { swing: $e(Be(S.swing - w.swing)), spread: $e(Be(S.spread - w.spread)) * A }
2458
2533
  ];
2459
- return e.withAngles(t, s, S);
2534
+ return e.withAngles(t, r, k);
2460
2535
  }
2461
- const br = 0.34, re = 0.12, te = -0.4, oe = (e, t, n) => e[t] ?? n, mr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), yr = 0.45, wr = 0.35, kr = 0.7;
2462
- function Ye(e, t, n) {
2463
- const r = (u) => Math.sqrt(Math.max(0, 1 - u.x * u.x - u.y * u.y)), o = hn(e, [n.x, n.y, r(n)]).facing, s = e.axes[2], i = Math.atan2(s[0], s[2]), l = Math.cos(i), a = l >= 0 ? 1 : -1, h = a * Math.max(wr, Math.abs(l)), c = a * Math.max(kr, Math.abs(l)), p = Math.cos(e.angle), d = Math.sin(e.angle);
2536
+ const rr = 0.34, ie = 0.12, oe = -0.4, re = (e, t, n) => e[t] ?? n, ir = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), lr = 0.45, ar = 0.35, hr = 0.7;
2537
+ function Je(e, t, n) {
2538
+ const s = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), o = Cn(e, [n.x, n.y, s(n)]).facing, r = e.axes[2], l = Math.atan2(r[0], r[2]), i = Math.cos(l), a = i >= 0 ? 1 : -1, h = a * Math.max(ar, Math.abs(i)), c = a * Math.max(hr, Math.abs(i)), u = Math.cos(e.angle), g = Math.sin(e.angle);
2464
2539
  return {
2465
2540
  facing: o,
2466
- points: t.map((u) => {
2467
- const b = yr * Math.sin(i) + n.x * h + (u.x - n.x) * c, f = u.y + s[1] * r(u), g = b * e.rx, m = f * e.ry;
2468
- return { x: e.center.x + g * p + m * d, y: e.center.y + g * d - m * p };
2541
+ points: t.map((f) => {
2542
+ const p = lr * Math.sin(l) + n.x * h + (f.x - n.x) * c, d = f.y + r[1] * s(f), m = p * e.rx, b = d * e.ry;
2543
+ return { x: e.center.x + m * u + b * g, y: e.center.y + m * g - b * u };
2469
2544
  })
2470
2545
  };
2471
2546
  }
2472
- const Te = (e, t, n, r = 12) => Array.from({ length: r + 1 }, (o, s) => {
2473
- const i = s / r, l = 1 - i;
2474
- return { x: l * l * e.x + 2 * l * i * t.x + i * i * n.x, y: l * l * e.y + 2 * l * i * t.y + i * i * n.y };
2475
- }), Ge = (e, t, n, r, o = 16) => Array.from({ length: o }, (s, i) => {
2476
- const l = Math.PI * 2 * i / o;
2477
- return { x: e + Math.cos(l) * n, y: t + Math.sin(l) * r };
2478
- }), _t = 0.05;
2479
- function Sr(e, t, n, r) {
2480
- const o = Math.max(1, Math.min(r * 0.6, 0.14 * t.rx)), s = (m, k) => Ye(t, m, k).points, i = (m, k) => Ye(t, [], { x: m, y: k }).facing, l = oe(n, "smile", 0), a = oe(n, "blink", 0), h = oe(n, "lookX", 0), c = oe(n, "lookY", 0), p = oe(n, "browTilt", 0);
2481
- for (const m of [1, -1]) {
2482
- const k = m === 1 ? "left" : "right", y = br * m;
2483
- if (i(y, re) < _t) continue;
2484
- const H = { x: y, y: re }, E = mr(oe(n, `eye.${k}`, 1), a);
2485
- if (E < 0.2) {
2486
- const S = l > 0.5 ? 0.12 : -0.06;
2487
- e.line(s(Te({ x: y - 0.12, y: re }, { x: y, y: re + S }, { x: y + 0.12, y: re }), H), o);
2547
+ const Fe = (e, t, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
2548
+ const l = r / s, i = 1 - l;
2549
+ return { x: i * i * e.x + 2 * i * l * t.x + l * l * n.x, y: i * i * e.y + 2 * i * l * t.y + l * l * n.y };
2550
+ }), at = (e, t, n, s, o = 16) => Array.from({ length: o }, (r, l) => {
2551
+ const i = Math.PI * 2 * l / o;
2552
+ return { x: e + Math.cos(i) * n, y: t + Math.sin(i) * s };
2553
+ }), on = 0.05;
2554
+ function cr(e, t, n, s) {
2555
+ const o = Math.max(1, Math.min(s * 0.6, 0.14 * t.rx)), r = (b, y) => Je(t, b, y).points, l = (b, y) => Je(t, [], { x: b, y }).facing, i = re(n, "smile", 0), a = re(n, "blink", 0), h = re(n, "lookX", 0), c = re(n, "lookY", 0), u = re(n, "browTilt", 0);
2556
+ for (const b of [1, -1]) {
2557
+ const y = b === 1 ? "left" : "right", E = rr * b;
2558
+ if (l(E, ie) < on) continue;
2559
+ const H = { x: E, y: ie }, M = ir(re(n, `eye.${y}`, 1), a);
2560
+ if (M < 0.2) {
2561
+ const k = i > 0.5 ? 0.12 : -0.06;
2562
+ e.line(r(Fe({ x: E - 0.12, y: ie }, { x: E, y: ie + k }, { x: E + 0.12, y: ie }), H), o);
2488
2563
  } else {
2489
- if (E > 1.2) {
2490
- const v = 0.13 * E;
2491
- e.shape(s(Ge(y, re, v * 0.85, v), H), "#ffffff", o);
2564
+ if (M > 1.2) {
2565
+ const T = 0.13 * M;
2566
+ e.shape(r(at(E, ie, T * 0.85, T), H), "#ffffff", o);
2492
2567
  }
2493
- const S = E > 1.2 ? 0.075 : 0.1, A = y + h * 0.08, K = re - c * 0.07;
2494
- e.shape(s(Ge(A, K, S, S * 1.1 * Math.min(E, 1)), H), e.ink, 0);
2568
+ const k = M > 1.2 ? 0.075 : 0.1, x = E + h * 0.08, v = ie - c * 0.07;
2569
+ e.shape(r(at(x, v, k, k * 1.1 * Math.min(M, 1)), H), e.ink, 0);
2495
2570
  }
2496
- const w = re + 0.3 + oe(n, `brow.${k}`, 0) * 0.14 + Math.max(0, E - 1) * 0.12, M = { x: y + m * 0.13, y: w }, x = { x: y - m * 0.13, y: w + p * 0.1 };
2497
- e.line(s([M, { x: (M.x + x.x) / 2, y: (M.y + x.y) / 2 }, x], { x: y, y: w }), o);
2498
- }
2499
- const d = { x: 0, y: te };
2500
- if (i(0, te) < -_t) return;
2501
- const u = 0.25 * Math.max(0.3, oe(n, "mouthWidth", 1)), b = Math.min(1, Math.max(0, oe(n, "mouth", 0)));
2502
- if (b <= 0.05) {
2503
- e.line(s(Te({ x: -u, y: te }, { x: 0, y: te - l * 0.25 }, { x: u, y: te }), d), o);
2571
+ const A = ie + 0.3 + re(n, `brow.${y}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, w = { x: E + b * 0.13, y: A }, S = { x: E - b * 0.13, y: A + u * 0.1 };
2572
+ e.line(r([w, { x: (w.x + S.x) / 2, y: (w.y + S.y) / 2 }, S], { x: E, y: A }), o);
2573
+ }
2574
+ const g = { x: 0, y: oe };
2575
+ if (l(0, oe) < -on) return;
2576
+ const f = 0.25 * Math.max(0.3, re(n, "mouthWidth", 1)), p = Math.min(1, Math.max(0, re(n, "mouth", 0)));
2577
+ if (p <= 0.05) {
2578
+ e.line(r(Fe({ x: -f, y: oe }, { x: 0, y: oe - i * 0.25 }, { x: f, y: oe }), g), o);
2504
2579
  return;
2505
2580
  }
2506
- const f = 0.3 * b;
2507
- let g;
2508
- if (l > 0.3) {
2509
- const m = te + 0.05;
2510
- g = [...Te({ x: u, y: m }, { x: 0, y: te - f * 2 }, { x: -u, y: m })];
2511
- } else if (l < -0.3) {
2512
- const m = te - f * 0.6;
2513
- g = [...Te({ x: u, y: m }, { x: 0, y: te + f * 1.4 }, { x: -u, y: m })];
2581
+ const d = 0.3 * p;
2582
+ let m;
2583
+ if (i > 0.3) {
2584
+ const b = oe + 0.05;
2585
+ m = [...Fe({ x: f, y: b }, { x: 0, y: oe - d * 2 }, { x: -f, y: b })];
2586
+ } else if (i < -0.3) {
2587
+ const b = oe - d * 0.6;
2588
+ m = [...Fe({ x: f, y: b }, { x: 0, y: oe + d * 1.4 }, { x: -f, y: b })];
2514
2589
  } else
2515
- g = Ge(0, te, u * 0.8, f);
2516
- e.shape(s(g, d), e.ink, 0);
2590
+ m = at(0, oe, f * 0.8, d);
2591
+ e.shape(r(m, g), e.ink, 0);
2517
2592
  }
2518
- function Er(e = {}) {
2519
- const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", r = e.look ?? "clean", o = e.height ?? 300, s = n === "stick";
2593
+ function fr(e = {}) {
2594
+ const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", s = e.look ?? "clean", o = e.height ?? 300, r = n === "stick";
2520
2595
  return {
2521
- plan: e.plan ?? fr({
2596
+ plan: e.plan ?? er({
2522
2597
  headSize: e.headSize ?? (t ? 0.3 : 0.24),
2523
- shoulderWidth: s ? 0 : e.shoulderWidth ?? 0.06,
2524
- hipWidth: s ? 0 : e.hipWidth ?? 0.022
2598
+ shoulderWidth: r ? 0 : e.shoulderWidth ?? 0.06,
2599
+ hipWidth: r ? 0 : e.hipWidth ?? 0.022
2525
2600
  }),
2526
2601
  figure: n,
2527
- look: r,
2602
+ look: s,
2528
2603
  height: o,
2529
2604
  lineWidth: e.lineWidth ?? o * (t ? 0.045 : 0.022),
2530
- ink: e.ink ?? (r === "pencil" ? "#2f2f33" : "#1e293b"),
2531
- skin: e.skin ?? (r === "pencil" ? "none" : "#ffffff"),
2605
+ ink: e.ink ?? (s === "pencil" ? "#2f2f33" : "#1e293b"),
2606
+ skin: e.skin ?? (s === "pencil" ? "none" : "#ffffff"),
2532
2607
  seed: e.seed ?? 1,
2533
2608
  pencil: e.pencil ?? {},
2534
2609
  layers: e.layers ?? {},
@@ -2538,108 +2613,108 @@ function Er(e = {}) {
2538
2613
  handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
2539
2614
  };
2540
2615
  }
2541
- function hs(e, t, n, r) {
2542
- const { point: o, facing: s } = hn(e, [t, n, r]);
2543
- return { point: o, facing: s };
2544
- }
2545
- const st = (e) => e.rest[1] < -0.5, Hr = 0.3;
2546
- function Mr(e, t, n) {
2547
- return e.figure === "stick" ? st(t) ? n.slice(0, 3) : n : st(t) && n.length >= 3 ? de(n[0], n[1], n[2], Hr) : n.length === 3 ? de(n[0], n[1], n[2], 1) : n;
2548
- }
2549
- function bt(e, t) {
2550
- const n = e.plan.id === "human" ? { ...V, ...t } : t;
2551
- return mt(e, n, pt(e.plan, n, { height: e.height, contact: e.contact }));
2552
- }
2553
- function mt(e, t, n) {
2554
- const r = {}, o = {}, s = {}, i = 0.01 * e.height;
2555
- e.plan.chains.forEach((d) => {
2556
- const u = n.chains[d.id];
2557
- r[d.id] = u.points;
2558
- const b = u.depths.reduce((k, y) => k + y, 0) / u.depths.length, f = d.parent ? n.chains[d.parent] : void 0, g = f ? f.depths[d.at ?? f.depths.length - 1] : 0, m = b - g;
2559
- s[d.id] = Math.abs(m) < i ? 0 : m, o[d.id] = { points: Mr(e, d, u.points), depth: b };
2560
- }), o.head = { points: [n.head.center], depth: n.head.depth }, s.head = 0;
2561
- const l = [...e.plan.chains.map((d) => d.id), "head"], a = [...l].sort((d, u) => s[d] - s[u] || l.indexOf(d) - l.indexOf(u)), h = { hip: n.hip };
2562
- for (const [d, [u, b]] of Object.entries(e.plan.landmarks ?? {})) {
2563
- const f = n.chains[u]?.points;
2564
- f && (h[d] = f[Math.min(b, f.length - 1)]);
2616
+ function Ki(e, t, n, s) {
2617
+ const { point: o, facing: r } = Cn(e, [t, n, s]);
2618
+ return { point: o, facing: r };
2619
+ }
2620
+ const Et = (e) => e.rest[1] < -0.5, ur = 0.3;
2621
+ function dr(e, t, n) {
2622
+ return e.figure === "stick" ? Et(t) ? n.slice(0, 3) : n : Et(t) && n.length >= 3 ? ke(n[0], n[1], n[2], ur) : n.length === 3 ? ke(n[0], n[1], n[2], 1) : n;
2623
+ }
2624
+ function _t(e, t) {
2625
+ const n = e.plan.id === "human" ? { ...X, ...t } : t;
2626
+ return $t(e, n, It(e.plan, n, { height: e.height, contact: e.contact }));
2627
+ }
2628
+ function $t(e, t, n) {
2629
+ const s = {}, o = {}, r = {}, l = 0.01 * e.height;
2630
+ e.plan.chains.forEach((g) => {
2631
+ const f = n.chains[g.id];
2632
+ s[g.id] = f.points;
2633
+ const p = f.depths.reduce((y, E) => y + E, 0) / f.depths.length, d = g.parent ? n.chains[g.parent] : void 0, m = d ? d.depths[g.at ?? d.depths.length - 1] : 0, b = p - m;
2634
+ r[g.id] = Math.abs(b) < l ? 0 : b, o[g.id] = { points: dr(e, g, f.points), depth: p };
2635
+ }), o.head = { points: [n.head.center], depth: n.head.depth }, r.head = 0;
2636
+ const i = [...e.plan.chains.map((g) => g.id), "head"], a = [...i].sort((g, f) => r[g] - r[f] || i.indexOf(g) - i.indexOf(f)), h = { hip: n.hip };
2637
+ for (const [g, [f, p]] of Object.entries(e.plan.landmarks ?? {})) {
2638
+ const d = n.chains[f]?.points;
2639
+ d && (h[g] = d[Math.min(p, d.length - 1)]);
2565
2640
  }
2566
2641
  const c = {};
2567
- for (const [d, u] of Object.entries(h)) c[d] = u.y >= n.groundY - 0.01 * e.height;
2568
- const p = {
2642
+ for (const [g, f] of Object.entries(h)) c[g] = f.y >= n.groundY - 0.01 * e.height;
2643
+ const u = {
2569
2644
  height: e.height,
2570
2645
  lineWidth: e.lineWidth,
2571
2646
  turn: t.turn ?? 0,
2572
2647
  points: h,
2573
- chains: r,
2648
+ chains: s,
2574
2649
  parts: o,
2575
2650
  head: n.head,
2576
2651
  groundY: n.groundY,
2577
2652
  grounded: c
2578
2653
  };
2579
- return { skeleton: n, joints: p, order: a };
2654
+ return { skeleton: n, joints: u, order: a };
2580
2655
  }
2581
- function vr(e, t) {
2582
- return bt(e, t).joints;
2656
+ function gr(e, t) {
2657
+ return _t(e, t).joints;
2583
2658
  }
2584
- function xr(e, t, n) {
2585
- const { head: r } = n;
2586
- e.guideEllipse(r.center.x, r.center.y, r.rx * 1.03, r.ry * 1.03, r.angle);
2587
- const o = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), s = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), i = Ye(r, o, { x: 0, y: 0 });
2588
- i.facing > 0 && e.guide(i.points), e.guide(Ye(r, s, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2589
- const l = t.lineWidth * 0.9;
2659
+ function pr(e, t, n) {
2660
+ const { head: s } = n;
2661
+ e.guideEllipse(s.center.x, s.center.y, s.rx * 1.03, s.ry * 1.03, s.angle);
2662
+ const o = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), r = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), l = Je(s, o, { x: 0, y: 0 });
2663
+ l.facing > 0 && e.guide(l.points), e.guide(Je(s, r, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2664
+ const i = t.lineWidth * 0.9;
2590
2665
  for (const a of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
2591
2666
  const h = n.points[a];
2592
- h && e.guideEllipse(h.x, h.y, l, l, 0);
2667
+ h && e.guideEllipse(h.x, h.y, i, i, 0);
2593
2668
  }
2594
2669
  }
2595
- function Tr(e, t, n, r, o, s) {
2596
- const i = n.lineWidth;
2670
+ function mr(e, t, n, s, o, r) {
2671
+ const l = n.lineWidth;
2597
2672
  if (o === "head") {
2598
- const { head: u } = r, b = n.skin === "none" ? null : n.skin;
2599
- t.ellipse(u.center.x, u.center.y, u.rx, u.ry, u.angle, b, i), t.look !== "silhouette" && Sr(t, u, s, i);
2673
+ const { head: f } = s, p = n.skin === "none" ? null : n.skin;
2674
+ t.ellipse(f.center.x, f.center.y, f.rx, f.ry, f.angle, p, l), t.look !== "silhouette" && cr(t, f, r, l);
2600
2675
  return;
2601
2676
  }
2602
- const l = n.plan.chains.find((u) => u.id === o), a = r.chains[o], h = r.parts[o].points;
2677
+ const i = n.plan.chains.find((f) => f.id === o), a = s.chains[o], h = s.parts[o].points;
2603
2678
  if (n.figure === "stick") {
2604
2679
  if (o === "neck") return;
2605
- const u = o === "spine" ? [...a, ...r.chains.neck?.slice(1) ?? []] : h;
2606
- t.line(u, i);
2680
+ const f = o === "spine" ? [...a, ...s.chains.neck?.slice(1) ?? []] : h;
2681
+ t.line(f, l);
2607
2682
  return;
2608
2683
  }
2609
- const c = (u, b) => [l.bones[u].width[0] * i, l.bones[b].width[1] * i];
2610
- if (st(l)) {
2611
- const [u, b] = c(0, 1);
2612
- if (t.limb(h, u, b), l.bones.length >= 3)
2613
- t.limb([a[2], a[3]], l.bones[2].width[0] * i, l.bones[2].width[1] * i);
2684
+ const c = (f, p) => [i.bones[f].width[0] * l, i.bones[p].width[1] * l];
2685
+ if (Et(i)) {
2686
+ const [f, p] = c(0, 1);
2687
+ if (t.limb(h, f, p), i.bones.length >= 3)
2688
+ t.limb([a[2], a[3]], i.bones[2].width[0] * l, i.bones[2].width[1] * l);
2614
2689
  else if (n.hands === "cartoon" && o.startsWith("arm."))
2615
- Kr(e, t, n, a, o.endsWith(".left") ? "left" : "right", s);
2690
+ wr(e, t, n, a, o.endsWith(".left") ? "left" : "right", r);
2616
2691
  else {
2617
- const f = a[a.length - 1];
2618
- t.dot(f.x, f.y, i * 0.62);
2692
+ const d = a[a.length - 1];
2693
+ t.dot(d.x, d.y, l * 0.62);
2619
2694
  }
2620
2695
  return;
2621
2696
  }
2622
2697
  if (o === "spine") {
2623
- const u = r.points["hip.left"], b = r.points["hip.right"];
2624
- u && b && Math.hypot(u.x - b.x, u.y - b.y) > 0.5 && t.limb([u, b], i * 1.3, i * 1.3);
2625
- const [f, g] = c(0, l.bones.length - 1);
2626
- t.limb(h, f, g);
2627
- const m = r.points["shoulder.left"], k = r.points["shoulder.right"];
2628
- m && k && Math.hypot(m.x - k.x, m.y - k.y) > 0.5 && t.limb(de(m, a[a.length - 1], k, 1, 10), i * 1.15, i * 1.15);
2698
+ const f = s.points["hip.left"], p = s.points["hip.right"];
2699
+ f && p && Math.hypot(f.x - p.x, f.y - p.y) > 0.5 && t.limb([f, p], l * 1.3, l * 1.3);
2700
+ const [d, m] = c(0, i.bones.length - 1);
2701
+ t.limb(h, d, m);
2702
+ const b = s.points["shoulder.left"], y = s.points["shoulder.right"];
2703
+ b && y && Math.hypot(b.x - y.x, b.y - y.y) > 0.5 && t.limb(ke(b, a[a.length - 1], y, 1, 10), l * 1.15, l * 1.15);
2629
2704
  return;
2630
2705
  }
2631
- const [p, d] = c(0, l.bones.length - 1);
2632
- t.limb(h, p, d);
2633
- }
2634
- function Ar(e, t) {
2635
- const n = `hand.${t}.`, r = {};
2636
- for (const [i, l] of Object.entries(e)) i.startsWith(n) && (r[i.slice(n.length)] = l);
2637
- const o = e.turn ?? 0, s = t === "right" ? 1 - o : 1 + o;
2638
- return { ..._, ...r, turn: s + (r.turn ?? 0) };
2639
- }
2640
- function Kr(e, t, n, r, o, s) {
2641
- const i = r[r.length - 1], l = r[r.length - 2], a = Math.atan2(i.x - l.x, -(i.y - l.y)) * 180 / Math.PI;
2642
- at(e, i, Ar(s, o), {
2706
+ const [u, g] = c(0, i.bones.length - 1);
2707
+ t.limb(h, u, g);
2708
+ }
2709
+ function br(e, t) {
2710
+ const n = `hand.${t}.`, s = {};
2711
+ for (const [l, i] of Object.entries(e)) l.startsWith(n) && (s[l.slice(n.length)] = i);
2712
+ const o = e.turn ?? 0, r = t === "right" ? 1 - o : 1 + o;
2713
+ return { ...L, ...s, turn: r + (s.turn ?? 0) };
2714
+ }
2715
+ function wr(e, t, n, s, o, r) {
2716
+ const l = s[s.length - 1], i = s[s.length - 2], a = Math.atan2(l.x - i.x, -(l.y - i.y)) * 180 / Math.PI;
2717
+ Tt(e, l, br(r, o), {
2643
2718
  size: n.handSize * n.height,
2644
2719
  side: o,
2645
2720
  angle: a,
@@ -2652,24 +2727,24 @@ function Kr(e, t, n, r, o, s) {
2652
2727
  lineWidth: n.lineWidth * 0.3
2653
2728
  });
2654
2729
  }
2655
- function Pr(e, t, n, r = 0) {
2656
- const o = t.plan.id === "human" ? { ...V, ...n } : n;
2657
- fn(e, t, o, bt(t, o), r);
2730
+ function yr(e, t, n, s = 0) {
2731
+ const o = t.plan.id === "human" ? { ...X, ...n } : n;
2732
+ Xn(e, t, o, _t(t, o), s);
2658
2733
  }
2659
- function cn(e, t) {
2734
+ function Dn(e, t) {
2660
2735
  const n = t / e.height;
2661
2736
  return { ...e, height: t, lineWidth: e.lineWidth * n };
2662
2737
  }
2663
- function cs(e, t, n, r) {
2664
- const o = e.plan.id === "human" ? { ...V, ...t } : t, s = an(e.plan, o, { height: r.height, contact: e.contact }, n);
2665
- return mt(cn(e, s.height), o, s).joints;
2738
+ function Pi(e, t, n, s) {
2739
+ const o = e.plan.id === "human" ? { ...X, ...t } : t, r = Yn(e.plan, o, { height: s.height, contact: e.contact }, n);
2740
+ return $t(Dn(e, r.height), o, r).joints;
2666
2741
  }
2667
- function Wr(e, t, n, r, o) {
2668
- const s = t.plan.id === "human" ? { ...V, ...n } : n, i = an(t.plan, s, { height: o.height, contact: t.contact }, r), l = cn(t, i.height);
2669
- fn(e, l, s, mt(l, s, i), o.time ?? 0);
2742
+ function kr(e, t, n, s, o) {
2743
+ const r = t.plan.id === "human" ? { ...X, ...n } : n, l = Yn(t.plan, r, { height: o.height, contact: t.contact }, s), i = Dn(t, l.height);
2744
+ Xn(e, i, r, $t(i, r, l), o.time ?? 0);
2670
2745
  }
2671
- function fn(e, t, n, r, o) {
2672
- const { joints: s, order: i } = r, l = Yt(e, {
2746
+ function Xn(e, t, n, s, o) {
2747
+ const { joints: r, order: l } = s, i = bn(e, {
2673
2748
  look: t.look,
2674
2749
  ink: t.ink,
2675
2750
  lineWidth: t.lineWidth,
@@ -2677,87 +2752,91 @@ function fn(e, t, n, r, o) {
2677
2752
  time: o,
2678
2753
  pencil: t.pencil
2679
2754
  }), a = (h) => {
2680
- h && (e.save(), h(e, s, l, o), e.restore());
2755
+ h && (e.save(), h(e, r, i, o), e.restore());
2681
2756
  };
2682
- e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && xr(l, t, s), a(t.layers.behind);
2683
- for (const h of i) {
2757
+ e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && pr(i, t, r), a(t.layers.behind);
2758
+ for (const h of l) {
2684
2759
  const c = t.layers.parts?.[h];
2685
- a(c?.under), Tr(e, l, t, s, h, n), a(c?.over);
2760
+ a(c?.under), mr(e, i, t, r, h, n), a(c?.over);
2686
2761
  }
2687
2762
  a(t.layers.front), e.restore();
2688
2763
  }
2689
- function fs(e, t, n) {
2690
- const r = { ...e };
2691
- for (const [o, s] of Object.entries(t)) {
2692
- const i = e[o] ?? s;
2693
- r[o] = i + (s - i) * n;
2764
+ function Wi(e, t, n) {
2765
+ const s = { ...e };
2766
+ for (const [o, r] of Object.entries(t)) {
2767
+ const l = e[o] ?? r;
2768
+ s[o] = l + (r - l) * n;
2694
2769
  }
2695
- return r;
2770
+ return s;
2696
2771
  }
2697
- function us(e, t, n, r) {
2698
- const o = e.plan.id === "human" ? { ...V, ...t } : t;
2699
- let s;
2700
- if (Array.isArray(r))
2701
- s = r;
2772
+ function Oi(e, t, n, s) {
2773
+ const o = e.plan.id === "human" ? { ...X, ...t } : t;
2774
+ let r;
2775
+ if (Array.isArray(s))
2776
+ r = s;
2702
2777
  else {
2703
- const { skeleton: i } = bt(e, o), l = pt(e.plan, { ...o, roll: 0 }, { height: e.height, contact: "none" }), a = (o.roll ?? 0) * Math.PI / 180, h = r.x - i.hip.x, c = r.y - i.hip.y, p = l.hip.x + h * Math.cos(-a) - c * Math.sin(-a), d = l.hip.y + h * Math.sin(-a) + c * Math.cos(-a), u = Math.PI / 2 * (o.turn ?? 0), b = r.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], f = Math.cos(u), g = Math.sin(u);
2704
- s = [p * f - b * g, -d, p * g + b * f];
2778
+ const { skeleton: l } = _t(e, o), i = It(e.plan, { ...o, roll: 0 }, { height: e.height, contact: "none" }), a = (o.roll ?? 0) * Math.PI / 180, h = s.x - l.hip.x, c = s.y - l.hip.y, u = i.hip.x + h * Math.cos(-a) - c * Math.sin(-a), g = i.hip.y + h * Math.sin(-a) + c * Math.cos(-a), f = Math.PI / 2 * (o.turn ?? 0), p = s.depth ?? l.chains[n].depths[l.chains[n].depths.length - 1], d = Math.cos(f), m = Math.sin(f);
2779
+ r = [u * d - p * m, -g, u * m + p * d];
2705
2780
  }
2706
- return pr(e.plan, o, n, s, { height: e.height });
2781
+ return sr(e.plan, o, n, r, { height: e.height });
2707
2782
  }
2708
- function ds(e) {
2709
- const { character: t } = e, n = t.height * 0.8, r = t.height, o = t.plan.id === "human" ? V : {};
2783
+ function Ii(e) {
2784
+ const { character: t } = e, n = t.height * 0.8, s = t.height, o = t.plan.id === "human" ? X : {};
2710
2785
  return {
2711
2786
  type: "custom",
2712
2787
  x: e.x - n / 2,
2713
- y: e.y - r,
2788
+ y: e.y - s,
2714
2789
  width: n,
2715
- height: r,
2790
+ height: s,
2716
2791
  props: { ...o, ...e.pose },
2717
2792
  character: t,
2718
- draw(s, i, l) {
2719
- s.translate(n / 2, r), Pr(s, t, i.props, l);
2793
+ draw(r, l, i) {
2794
+ r.translate(n / 2, s), yr(r, t, l.props, i);
2720
2795
  }
2721
2796
  };
2722
2797
  }
2723
- function Or(e, t, n) {
2724
- const r = (s) => ({ x: s.x + t, y: s.y + n }), o = (s) => Object.fromEntries(Object.entries(s).map(([i, l]) => [i, l.map(r)]));
2798
+ function Sr(e, t, n) {
2799
+ const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => Object.fromEntries(Object.entries(r).map(([l, i]) => [l, i.map(s)]));
2725
2800
  return {
2726
2801
  ...e,
2727
- points: Object.fromEntries(Object.entries(e.points).map(([s, i]) => [s, r(i)])),
2802
+ points: Object.fromEntries(Object.entries(e.points).map(([r, l]) => [r, s(l)])),
2728
2803
  chains: o(e.chains),
2729
- parts: Object.fromEntries(Object.entries(e.parts).map(([s, i]) => [s, { ...i, points: i.points.map(r) }])),
2730
- head: { ...e.head, center: r(e.head.center) },
2804
+ parts: Object.fromEntries(Object.entries(e.parts).map(([r, l]) => [r, { ...l, points: l.points.map(s) }])),
2805
+ head: { ...e.head, center: s(e.head.center) },
2731
2806
  groundY: e.groundY + n
2732
2807
  };
2733
2808
  }
2734
- function gs(e, t, n) {
2735
- const r = e.character;
2736
- if (!r) throw new Error("characterAt: the target was not made by characterTarget");
2809
+ function _i(e, t, n) {
2810
+ const s = e.character;
2811
+ if (!s) throw new Error("characterAt: the target was not made by characterTarget");
2737
2812
  const o = { ...e.props };
2738
- let s = 0, i = 0;
2813
+ let r = 0, l = 0;
2739
2814
  for (const [a, h] of t.state?.values.get(n) ?? [])
2740
- typeof h == "number" && (a === "x" || a === "motionPathX" ? s = h : a === "y" || a === "motionPathY" ? i = h : a in o && (o[a] = h));
2741
- const l = vr(r, o);
2742
- return { pose: o, joints: Or(l, e.x + s + e.width / 2, e.y + i + e.height) };
2743
- }
2744
- function ps(e, t, n = V) {
2745
- const r = [];
2746
- return t.forEach((s, i) => {
2747
- const l = i === 0 ? n : r[i - 1], a = typeof s.pose == "string" ? cr[s.pose] : void 0;
2748
- r.push(a ? { ...a, turn: l.turn ?? 0 } : { ...l, ...s.pose });
2749
- }), Object.keys(n).filter((s) => r.some((i) => (i[s] ?? n[s]) !== n[s])).map((s) => ({
2750
- id: `${e}-${s}`,
2815
+ typeof h == "number" && (a === "x" || a === "motionPathX" ? r = h : a === "y" || a === "motionPathY" ? l = h : a in o && (o[a] = h));
2816
+ const i = gr(s, o);
2817
+ return { pose: o, joints: Sr(i, e.x + r + e.width / 2, e.y + l + e.height) };
2818
+ }
2819
+ function qn(e, t = X) {
2820
+ const n = [];
2821
+ return e.forEach((s, o) => {
2822
+ const r = o === 0 ? t : n[o - 1], l = typeof s.pose == "string" ? Qs[s.pose] : void 0;
2823
+ n.push(l ? { ...l, turn: r.turn ?? 0 } : { ...r, ...s.pose });
2824
+ }), n;
2825
+ }
2826
+ function $i(e, t, n = X) {
2827
+ const s = qn(t, n);
2828
+ return Object.keys(n).filter((r) => s.some((l) => (l[r] ?? n[r]) !== n[r])).map((r) => ({
2829
+ id: `${e}-${r}`,
2751
2830
  target: e,
2752
- property: s,
2753
- keyframes: t.map((i, l) => ({
2754
- time: i.time,
2755
- value: r[l][s] ?? n[s],
2756
- ...i.easing ? { easing: i.easing } : {}
2831
+ property: r,
2832
+ keyframes: t.map((l, i) => ({
2833
+ time: l.time,
2834
+ value: s[i][r] ?? n[r],
2835
+ ...l.easing ? { easing: l.easing } : {}
2757
2836
  }))
2758
2837
  }));
2759
2838
  }
2760
- const Ir = /* @__PURE__ */ new Set([
2839
+ const Er = /* @__PURE__ */ new Set([
2761
2840
  "x",
2762
2841
  "y",
2763
2842
  "z",
@@ -2773,43 +2852,43 @@ const Ir = /* @__PURE__ */ new Set([
2773
2852
  "visible",
2774
2853
  "opacity",
2775
2854
  "color"
2776
- ]), Br = 1.7;
2777
- function $r(e, t, n) {
2778
- const r = Array.from({ length: 24 }, (o, s) => {
2779
- const i = s / 24 * Math.PI * 2, l = t.toView([Math.cos(i) * n, 0, Math.sin(i) * n * 0.8]);
2780
- return l[2] < -1e-3 ? t.toScreen(l) : null;
2855
+ ]), Mr = 1.7;
2856
+ function Hr(e, t, n) {
2857
+ const s = Array.from({ length: 24 }, (o, r) => {
2858
+ const l = r / 24 * Math.PI * 2, i = t.toView([Math.cos(l) * n, 0, Math.sin(l) * n * 0.8]);
2859
+ return i[2] < -1e-3 ? t.toScreen(i) : null;
2781
2860
  });
2782
- r.some((o) => o === null) || (e.beginPath(), r.forEach((o, s) => s === 0 ? e.moveTo(o.x, o.y) : e.lineTo(o.x, o.y)), e.closePath(), e.fillStyle = "rgba(0, 0, 0, 0.22)", e.fill());
2783
- }
2784
- function _r(e) {
2785
- const t = U.dot([0, 1, 0], e);
2786
- if (t > 0.999999) return N.identity();
2787
- if (t < -0.999999) return N.fromQuat(yt.fromAxisAngle([1, 0, 0], 180));
2788
- const n = U.cross([0, 1, 0], e);
2789
- return N.fromQuat(yt.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
2790
- }
2791
- function Fr(e, t, n, r, o) {
2792
- const s = e.solid ?? {}, i = s.outline === !1 ? void 0 : s.outline ?? { width: 2, color: "#0f172a" }, l = { color: s.color ?? "#475569", shading: s.shading ?? "toon", outline: i }, a = { color: s.skin ?? "#f2c49b", shading: s.shading ?? "toon", outline: i }, h = { color: "#0f172a", shading: "unlit" }, c = r.height * 0.034, p = [], d = (y, H, E) => p.push({ mesh: y, world: N.multiply(o, H), material: E }), u = (y, H, E) => d(t.sphere, N.compose(y, [0, 0, 0, 1], [H, H, H]), E);
2793
- for (const y of n.chains) {
2794
- const H = r.chains[y.id], E = y.id === "spine" ? 1.9 : 1;
2795
- y.bones.forEach((w, M) => {
2796
- const x = H[M], S = H[M + 1], A = U.distance(x, S), [K, v] = w.width ?? [1, 1], T = c * E * (K + v) / 2;
2797
- if (A > 1e-6) {
2798
- const W = U.lerp(x, S, 0.5), B = _r(U.normalize(U.subtract(S, x)));
2799
- d(t.cylinder, N.multiply(N.translation(W), N.multiply(B, N.scaling([T, A, T]))), l);
2861
+ s.some((o) => o === null) || (e.beginPath(), s.forEach((o, r) => r === 0 ? e.moveTo(o.x, o.y) : e.lineTo(o.x, o.y)), e.closePath(), e.fillStyle = "rgba(0, 0, 0, 0.22)", e.fill());
2862
+ }
2863
+ function vr(e) {
2864
+ const t = J.dot([0, 1, 0], e);
2865
+ if (t > 0.999999) return D.identity();
2866
+ if (t < -0.999999) return D.fromQuat(Ft.fromAxisAngle([1, 0, 0], 180));
2867
+ const n = J.cross([0, 1, 0], e);
2868
+ return D.fromQuat(Ft.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
2869
+ }
2870
+ function Tr(e, t, n, s, o) {
2871
+ const r = e.solid ?? {}, l = r.outline === !1 ? void 0 : r.outline ?? { width: 2, color: "#0f172a" }, i = { color: r.color ?? "#475569", shading: r.shading ?? "toon", outline: l }, a = { color: r.skin ?? "#f2c49b", shading: r.shading ?? "toon", outline: l }, h = { color: "#0f172a", shading: "unlit" }, c = s.height * 0.034, u = [], g = (E, H, M) => u.push({ mesh: E, world: D.multiply(o, H), material: M }), f = (E, H, M) => g(t.sphere, D.compose(E, [0, 0, 0, 1], [H, H, H]), M);
2872
+ for (const E of n.chains) {
2873
+ const H = s.chains[E.id], M = E.id === "spine" ? 1.9 : 1;
2874
+ E.bones.forEach((A, w) => {
2875
+ const S = H[w], k = H[w + 1], x = J.distance(S, k), [v, T] = A.width ?? [1, 1], K = c * M * (v + T) / 2;
2876
+ if (x > 1e-6) {
2877
+ const P = J.lerp(S, k, 0.5), I = vr(J.normalize(J.subtract(k, S)));
2878
+ g(t.cylinder, D.multiply(D.translation(P), D.multiply(I, D.scaling([K, x, K]))), i);
2800
2879
  }
2801
- u(x, c * E * K, l), u(S, c * E * v, l);
2802
- }), y.id.startsWith("arm.") && u(H[H.length - 1], c * 1.5, a);
2880
+ f(S, c * M * v, i), f(k, c * M * T, i);
2881
+ }), E.id.startsWith("arm.") && f(H[H.length - 1], c * 1.5, a);
2803
2882
  }
2804
- const { center: b, rx: f, ry: g, axes: m } = r.head, k = [...m[0], 0, ...m[1], 0, ...m[2], 0, ...b, 1];
2805
- d(t.sphere, N.multiply(k, N.scaling([f, g, f])), a);
2806
- for (const y of [-1, 1]) {
2807
- const H = U.normalize([y * 0.36, 0.15, 0.92]), E = U.add(b, U.add(U.add(U.scale(m[0], H[0] * f * 1.04), U.scale(m[1], H[1] * g * 1.04)), U.scale(m[2], H[2] * f * 1.04))), w = [...m[0], 0, ...m[1], 0, ...m[2], 0, ...E, 1];
2808
- d(t.sphere, N.multiply(w, N.scaling([f * 0.11, g * 0.14, f * 0.03])), h);
2883
+ const { center: p, rx: d, ry: m, axes: b } = s.head, y = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...p, 1];
2884
+ g(t.sphere, D.multiply(y, D.scaling([d, m, d])), a);
2885
+ for (const E of [-1, 1]) {
2886
+ const H = J.normalize([E * 0.36, 0.15, 0.92]), M = J.add(p, J.add(J.add(J.scale(b[0], H[0] * d * 1.04), J.scale(b[1], H[1] * m * 1.04)), J.scale(b[2], H[2] * d * 1.04))), A = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...M, 1];
2887
+ g(t.sphere, D.multiply(A, D.scaling([d * 0.11, m * 0.14, d * 0.03])), h);
2809
2888
  }
2810
- return p;
2889
+ return u;
2811
2890
  }
2812
- const bs = {
2891
+ const Bi = {
2813
2892
  kind: "character",
2814
2893
  validate(e) {
2815
2894
  const t = e;
@@ -2817,330 +2896,973 @@ const bs = {
2817
2896
  },
2818
2897
  prepare(e) {
2819
2898
  return {
2820
- who: Er({ ...e.character, height: 1 }),
2821
- cylinder: wt(Sn(1, 1, 16)),
2822
- sphere: wt(kn(1, 20))
2899
+ who: fr({ ...e.character, height: 1 }),
2900
+ cylinder: Rt(ro(1, 1, 16)),
2901
+ sphere: Rt(so(1, 20))
2823
2902
  };
2824
2903
  },
2825
- resolve({ object: e, prepared: t, values: n, world: r, camera: o, toScreen: s }) {
2826
- const i = e, l = t, a = l.who, h = { ...V, ...i.pose };
2827
- for (const [g, m] of n)
2828
- typeof m == "number" && !Ir.has(g) && (h[g] = m);
2829
- const c = i.height ?? Br, p = N.multiply(o.view, r), d = {
2830
- toView: (g) => N.transformPoint(p, g),
2831
- toScreen: (g) => s(g)
2832
- }, b = -d.toView([0, c / 2, 0])[2];
2833
- if (b <= o.near) return null;
2834
- const f = i.shadow === !1 ? [] : [{ depth: b + c, draw: (g) => $r(g, d, c * 0.18) }];
2835
- if (i.look === "solid") {
2836
- const g = ln(a.plan, h, { height: c, contact: a.contact });
2837
- return { meshes: Fr(i, l, a.plan, g, r), drawables: f };
2904
+ resolve({ object: e, prepared: t, values: n, world: s, camera: o, toScreen: r }) {
2905
+ const l = e, i = t, a = i.who, h = { ...X, ...l.pose };
2906
+ for (const [m, b] of n)
2907
+ typeof b == "number" && !Er.has(m) && (h[m] = b);
2908
+ const c = l.height ?? Mr, u = D.multiply(o.view, s), g = {
2909
+ toView: (m) => D.transformPoint(u, m),
2910
+ toScreen: (m) => r(m)
2911
+ }, p = -g.toView([0, c / 2, 0])[2];
2912
+ if (p <= o.near) return null;
2913
+ const d = l.shadow === !1 ? [] : [{ depth: p + c, draw: (m) => Hr(m, g, c * 0.18) }];
2914
+ if (l.look === "solid") {
2915
+ const m = Nn(a.plan, h, { height: c, contact: a.contact });
2916
+ return { meshes: Tr(l, i, a.plan, m, s), drawables: d };
2838
2917
  }
2839
2918
  return {
2840
2919
  drawables: [
2841
- ...f,
2920
+ ...d,
2842
2921
  {
2843
- depth: b,
2844
- draw(g, m) {
2845
- g.lineCap = "round", g.lineJoin = "round", Wr(g, a, h, d, { height: c, time: m.time });
2922
+ depth: p,
2923
+ draw(m, b) {
2924
+ m.lineCap = "round", m.lineJoin = "round", kr(m, a, h, g, { height: c, time: b.time });
2846
2925
  }
2847
2926
  }
2848
2927
  ]
2849
2928
  };
2850
2929
  }
2851
2930
  };
2852
- function Rr(e, t, n = {}, r) {
2853
- const o = n.length ?? 240, s = 9, i = 28, l = o - 22;
2854
- e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(i, -s, l - i, 2 * s), e.fillStyle = "#e8b4a0", e.fillRect(l, -s, o - l, 2 * s), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(i, -s), e.lineTo(i, s), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(i * 0.35, -s * 0.35), e.lineTo(i * 0.35, s * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2931
+ function Ar(e, t, n = {}, s) {
2932
+ const o = n.length ?? 240, r = 9, l = 28, i = o - 22;
2933
+ e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(l, -r, i - l, 2 * r), e.fillStyle = "#e8b4a0", e.fillRect(i, -r, o - i, 2 * r), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(l, -r), e.lineTo(l, r), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(l * 0.35, -r * 0.35), e.lineTo(l * 0.35, r * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2855
2934
  const a = [
2856
- [{ x: 0, y: 0 }, { x: i, y: -s }, { x: o, y: -s }, { x: o, y: s }, { x: i, y: s }, { x: 0, y: 0 }],
2857
- [{ x: i, y: -s }, { x: i, y: s }],
2858
- [{ x: l, y: -s }, { x: l, y: s }]
2935
+ [{ x: 0, y: 0 }, { x: l, y: -r }, { x: o, y: -r }, { x: o, y: r }, { x: l, y: r }, { x: 0, y: 0 }],
2936
+ [{ x: l, y: -r }, { x: l, y: r }],
2937
+ [{ x: i, y: -r }, { x: i, y: r }]
2859
2938
  ];
2860
- for (const h of a) pn(e, h, r);
2939
+ for (const h of a) Vn(e, h, s);
2861
2940
  e.restore();
2862
2941
  }
2863
- function un(e, t, n = {}, r) {
2864
- const o = n.length ?? 90, s = n.thickness ?? 34;
2942
+ function Gn(e, t, n = {}, s) {
2943
+ const o = n.length ?? 90, r = n.thickness ?? 34;
2865
2944
  e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
2866
- const i = -s / 2;
2867
- e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, i, o, s), e.fillStyle = "#e9edf2", e.fillRect(o * 0.45, i, o * 0.55, s), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2868
- const l = [
2869
- { x: 0, y: i },
2870
- { x: o, y: i },
2871
- { x: o, y: -i },
2872
- { x: 0, y: -i },
2873
- { x: 0, y: i }
2874
- ], a = [{ x: o * 0.45, y: i }, { x: o * 0.45, y: -i }];
2875
- if (r)
2876
- r.line(l), r.line(a);
2945
+ const l = -r / 2;
2946
+ e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, l, o, r), e.fillStyle = "#e9edf2", e.fillRect(o * 0.45, l, o * 0.55, r), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2947
+ const i = [
2948
+ { x: 0, y: l },
2949
+ { x: o, y: l },
2950
+ { x: o, y: -l },
2951
+ { x: 0, y: -l },
2952
+ { x: 0, y: l }
2953
+ ], a = [{ x: o * 0.45, y: l }, { x: o * 0.45, y: -l }];
2954
+ if (s)
2955
+ s.line(i), s.line(a);
2877
2956
  else
2878
- for (const h of [l, a]) {
2957
+ for (const h of [i, a]) {
2879
2958
  e.beginPath(), e.moveTo(h[0].x, h[0].y);
2880
2959
  for (const c of h.slice(1)) e.lineTo(c.x, c.y);
2881
2960
  e.stroke();
2882
2961
  }
2883
2962
  e.restore();
2884
2963
  }
2885
- const dn = 150, Yr = { pencil: 44, eraser: 30 };
2886
- function gn(e, t, n = {}, r) {
2887
- const o = n.tool ?? "pencil", s = n.skin ?? "#f1c9a5", i = n.outline ?? "#2f2f33", l = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, c = r ? r.nudge(0.6) : { x: 0, y: 0 }, p = dn * l * (1 + 0.05 * a);
2888
- a > 0 && (e.save(), e.fillStyle = i, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * l, 4 * l, 0, 0, Math.PI * 2), e.fill(), e.restore());
2889
- const d = { x: t.x + c.x + 6 * a * l, y: t.y + c.y - 18 * a * l }, u = L.pencilGrip, b = (M) => {
2890
- const x = M.fingers.thumb, S = M.fingers.index, A = M.fingers.middle, K = Ft([x.points[3], S.points[3], A.points[3]]), v = Ft([x.points[1], S.points[0]]), T = (x.depths[3] + S.depths[3] + A.depths[3]) / 3;
2891
- return { pinch: K, direction: Math.atan2(v.y - K.y, v.x - K.x), depth: T };
2892
- }, f = Ze(u, { size: p }), g = h - b(f).direction, m = Ze(u, { size: p, angle: g * 180 / Math.PI }), k = b(m), y = Yr[o] * l, H = { x: k.pinch.x - Math.cos(h) * y, y: k.pinch.y - Math.sin(h) * y }, E = { x: d.x - H.x, y: d.y - H.y }, w = m.axes.up;
2893
- Lr(e, E, { x: -w.x, y: -w.y }, p, n.arm ?? 300 * l, s, n.sleeve ?? "#5b7db1", i), at(e, E, u, {
2894
- size: p,
2895
- angle: g * 180 / Math.PI,
2896
- skin: s,
2897
- ink: i,
2898
- lineWidth: 3 * l,
2964
+ const Un = 150, xr = { pencil: 44, eraser: 30 };
2965
+ function zn(e, t, n = {}, s) {
2966
+ const o = n.tool ?? "pencil", r = n.skin ?? "#f1c9a5", l = n.outline ?? "#2f2f33", i = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, c = s ? s.nudge(0.6) : { x: 0, y: 0 }, u = Un * i * (1 + 0.05 * a);
2967
+ a > 0 && (e.save(), e.fillStyle = l, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), e.fill(), e.restore());
2968
+ const g = { x: t.x + c.x + 6 * a * i, y: t.y + c.y - 18 * a * i }, f = C.pencilGrip, p = (w) => {
2969
+ const S = w.fingers.thumb, k = w.fingers.index, x = w.fingers.middle, v = sn([S.points[3], k.points[3], x.points[3]]), T = sn([S.points[1], k.points[0]]), K = (S.depths[3] + k.depths[3] + x.depths[3]) / 3;
2970
+ return { pinch: v, direction: Math.atan2(T.y - v.y, T.x - v.x), depth: K };
2971
+ }, d = pt(f, { size: u }), m = h - p(d).direction, b = pt(f, { size: u, angle: m * 180 / Math.PI }), y = p(b), E = xr[o] * i, H = { x: y.pinch.x - Math.cos(h) * E, y: y.pinch.y - Math.sin(h) * E }, M = { x: g.x - H.x, y: g.y - H.y }, A = b.axes.up;
2972
+ Kr(e, M, { x: -A.x, y: -A.y }, u, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", l), Tt(e, M, f, {
2973
+ size: u,
2974
+ angle: m * 180 / Math.PI,
2975
+ skin: r,
2976
+ ink: l,
2977
+ lineWidth: 3 * i,
2899
2978
  prop: {
2900
- depth: k.depth,
2979
+ depth: y.depth,
2901
2980
  draw: () => {
2902
- e.save(), e.translate(d.x, d.y), e.scale(l, l), o === "eraser" ? un(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: i }, r) : Rr(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: i }, r), e.restore();
2981
+ e.save(), e.translate(g.x, g.y), e.scale(i, i), o === "eraser" ? Gn(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: l }, s) : Ar(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: l }, s), e.restore();
2903
2982
  }
2904
2983
  }
2905
2984
  });
2906
2985
  }
2907
- const Ft = (e) => ({
2986
+ const sn = (e) => ({
2908
2987
  x: e.reduce((t, n) => t + n.x, 0) / e.length,
2909
2988
  y: e.reduce((t, n) => t + n.y, 0) / e.length
2910
2989
  });
2911
- function Lr(e, t, n, r, o, s, i, l) {
2912
- const a = { x: -n.y, y: n.x }, h = r * 0.15, c = (f, g, m) => ({
2913
- x: t.x + n.x * f + a.x * g * m,
2914
- y: t.y + n.y * f + a.y * g * m
2915
- }), p = c(o, 0, 0), d = (f) => {
2916
- const g = e.createLinearGradient(t.x, t.y, p.x, p.y);
2917
- return g.addColorStop(0, f), g.addColorStop(0.6, f), g.addColorStop(1, Nr(f)), g;
2918
- }, u = Math.min(r * 0.55, o * 0.35);
2919
- e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (r / dn), e.beginPath(), e.moveTo(c(-r * 0.1, -1, h).x, c(-r * 0.1, -1, h).y), e.lineTo(c(u + 4, -1, h * 1.1).x, c(u + 4, -1, h * 1.1).y), e.lineTo(c(u + 4, 1, h * 1.1).x, c(u + 4, 1, h * 1.1).y), e.lineTo(c(-r * 0.1, 1, h).x, c(-r * 0.1, 1, h).y), e.closePath(), e.fillStyle = s, e.fill(), e.strokeStyle = l, e.beginPath(), e.moveTo(c(0, -1, h).x, c(0, -1, h).y), e.lineTo(c(u, -1, h * 1.1).x, c(u, -1, h * 1.1).y), e.moveTo(c(0, 1, h).x, c(0, 1, h).y), e.lineTo(c(u, 1, h * 1.1).x, c(u, 1, h * 1.1).y), e.stroke();
2920
- const b = [c(u, -1, h * 1.3), c(o, -1, h * 1.5), c(o, 1, h * 1.5), c(u, 1, h * 1.3)];
2921
- e.beginPath(), b.forEach((f, g) => g ? e.lineTo(f.x, f.y) : e.moveTo(f.x, f.y)), e.closePath(), e.fillStyle = d(i), e.fill(), e.strokeStyle = d(l), e.beginPath(), e.moveTo(b[1].x, b[1].y), e.lineTo(b[0].x, b[0].y), e.lineTo(b[3].x, b[3].y), e.lineTo(b[2].x, b[2].y), e.stroke(), e.restore();
2922
- }
2923
- function ms(e, t, n = {}) {
2924
- const r = n.offstage ?? { x: 2e3, y: 1400 }, o = n.enter ?? 450, s = n.exit ?? 450, i = n.linger ?? 1500, l = [...e].filter((f) => f.path.length > 0).sort((f, g) => f.start - g.start), a = (f) => f.tool ?? "pencil", h = (f) => {
2925
- const g = Math.min(1, Math.max(0, f));
2926
- return g * g * (3 - 2 * g);
2927
- }, c = (f, g, m) => ({ x: f.x + (g.x - f.x) * m, y: f.y + (g.y - f.y) * m }), p = l.find((f) => t >= f.start && t <= f.end);
2928
- if (p) {
2929
- const f = p.end - p.start, g = f > 0 ? (t - p.start) / f : 1;
2930
- return { at: lt(p.path, g), tool: a(p), lift: 0, drawing: !0 };
2931
- }
2932
- const d = [...l].reverse().find((f) => f.end < t), u = l.find((f) => f.start > t), b = (f) => f.path[f.path.length - 1];
2933
- if (d && u && u.start - d.end <= i) {
2934
- const f = (t - d.end) / (u.start - d.end), g = f < 0.5 ? a(d) : a(u);
2935
- return { at: c(b(d), u.path[0], h(f)), tool: g, lift: Math.sin(Math.PI * f), drawing: !1 };
2936
- }
2937
- if (u && u.start - t <= o) {
2938
- const f = 1 - (u.start - t) / o;
2939
- return { at: c(r, u.path[0], h(f)), tool: a(u), lift: 1 - h(f), drawing: !1 };
2940
- }
2941
- if (d && t - d.end <= s) {
2942
- const f = (t - d.end) / s;
2943
- return { at: c(b(d), r, h(f)), tool: a(d), lift: h(f), drawing: !1 };
2990
+ function Kr(e, t, n, s, o, r, l, i) {
2991
+ const a = { x: -n.y, y: n.x }, h = s * 0.15, c = (d, m, b) => ({
2992
+ x: t.x + n.x * d + a.x * m * b,
2993
+ y: t.y + n.y * d + a.y * m * b
2994
+ }), u = c(o, 0, 0), g = (d) => {
2995
+ const m = e.createLinearGradient(t.x, t.y, u.x, u.y);
2996
+ return m.addColorStop(0, d), m.addColorStop(0.6, d), m.addColorStop(1, Pr(d)), m;
2997
+ }, f = Math.min(s * 0.55, o * 0.35);
2998
+ e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (s / Un), e.beginPath(), e.moveTo(c(-s * 0.1, -1, h).x, c(-s * 0.1, -1, h).y), e.lineTo(c(f + 4, -1, h * 1.1).x, c(f + 4, -1, h * 1.1).y), e.lineTo(c(f + 4, 1, h * 1.1).x, c(f + 4, 1, h * 1.1).y), e.lineTo(c(-s * 0.1, 1, h).x, c(-s * 0.1, 1, h).y), e.closePath(), e.fillStyle = r, e.fill(), e.strokeStyle = i, e.beginPath(), e.moveTo(c(0, -1, h).x, c(0, -1, h).y), e.lineTo(c(f, -1, h * 1.1).x, c(f, -1, h * 1.1).y), e.moveTo(c(0, 1, h).x, c(0, 1, h).y), e.lineTo(c(f, 1, h * 1.1).x, c(f, 1, h * 1.1).y), e.stroke();
2999
+ const p = [c(f, -1, h * 1.3), c(o, -1, h * 1.5), c(o, 1, h * 1.5), c(f, 1, h * 1.3)];
3000
+ e.beginPath(), p.forEach((d, m) => m ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = g(l), e.fill(), e.strokeStyle = g(i), e.beginPath(), e.moveTo(p[1].x, p[1].y), e.lineTo(p[0].x, p[0].y), e.lineTo(p[3].x, p[3].y), e.lineTo(p[2].x, p[2].y), e.stroke(), e.restore();
3001
+ }
3002
+ function Fi(e, t, n = {}) {
3003
+ const s = n.offstage ?? { x: 2e3, y: 1400 }, o = n.enter ?? 450, r = n.exit ?? 450, l = n.linger ?? 1500, i = [...e].filter((d) => d.path.length > 0).sort((d, m) => d.start - m.start), a = (d) => d.tool ?? "pencil", h = (d) => {
3004
+ const m = Math.min(1, Math.max(0, d));
3005
+ return m * m * (3 - 2 * m);
3006
+ }, c = (d, m, b) => ({ x: d.x + (m.x - d.x) * b, y: d.y + (m.y - d.y) * b }), u = i.find((d) => t >= d.start && t <= d.end);
3007
+ if (u) {
3008
+ const d = u.end - u.start, m = d > 0 ? (t - u.start) / d : 1;
3009
+ return { at: Ht(u.path, m), tool: a(u), lift: 0, drawing: !0 };
3010
+ }
3011
+ const g = [...i].reverse().find((d) => d.end < t), f = i.find((d) => d.start > t), p = (d) => d.path[d.path.length - 1];
3012
+ if (g && f && f.start - g.end <= l) {
3013
+ const d = (t - g.end) / (f.start - g.end), m = d < 0.5 ? a(g) : a(f);
3014
+ return { at: c(p(g), f.path[0], h(d)), tool: m, lift: Math.sin(Math.PI * d), drawing: !1 };
3015
+ }
3016
+ if (f && f.start - t <= o) {
3017
+ const d = 1 - (f.start - t) / o;
3018
+ return { at: c(s, f.path[0], h(d)), tool: a(f), lift: 1 - h(d), drawing: !1 };
3019
+ }
3020
+ if (g && t - g.end <= r) {
3021
+ const d = (t - g.end) / r;
3022
+ return { at: c(p(g), s, h(d)), tool: a(g), lift: h(d), drawing: !1 };
2944
3023
  }
2945
3024
  return null;
2946
3025
  }
2947
- function ys(e, t, n, r = 0.08, o = 32) {
2948
- const s = Math.PI * 2 * (1 + r), i = [];
2949
- for (let l = 0; l <= o; l++) {
2950
- const a = -Math.PI / 2 + s * l / o;
2951
- i.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
3026
+ function Ri(e, t, n, s = 0.08, o = 32) {
3027
+ const r = Math.PI * 2 * (1 + s), l = [];
3028
+ for (let i = 0; i <= o; i++) {
3029
+ const a = -Math.PI / 2 + r * i / o;
3030
+ l.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
2952
3031
  }
2953
- return i;
3032
+ return l;
2954
3033
  }
2955
- function ws(e) {
2956
- const { path: t } = e, n = t.map((l) => l.x), r = t.map((l) => l.y), o = Math.min(...n), s = Math.min(...r), i = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
3034
+ function Li(e) {
3035
+ const { path: t } = e, n = t.map((i) => i.x), s = t.map((i) => i.y), o = Math.min(...n), r = Math.min(...s), l = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
2957
3036
  return {
2958
3037
  type: "custom",
2959
3038
  x: o,
2960
- y: s,
3039
+ y: r,
2961
3040
  width: Math.max(1, Math.max(...n) - o),
2962
- height: Math.max(1, Math.max(...r) - s),
3041
+ height: Math.max(1, Math.max(...s) - r),
2963
3042
  props: { draw: 0 },
2964
- draw(l, a, h) {
3043
+ draw(i, a, h) {
2965
3044
  const c = Math.min(1, Math.max(0, Number(a.props?.draw ?? 0)));
2966
- l.translate(-o, -s), l.strokeStyle = e.color ?? "#2f2f33", l.lineWidth = e.lineWidth ?? 5, l.lineCap = "round", l.lineJoin = "round";
2967
- const p = e.sketch ? Je(l, e.sketch, h) : void 0;
2968
- c > 0 && (p ? e.smooth ? p.curve(t, c) : p.line(t, c) : pn(l, Rt(t, c))), i && c > 0 && c < 1 && gn(l, lt(t, c), i, p);
3045
+ i.translate(-o, -r), i.strokeStyle = e.color ?? "#2f2f33", i.lineWidth = e.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
3046
+ const u = e.sketch ? ut(i, e.sketch, h) : void 0;
3047
+ c > 0 && (u ? e.smooth ? u.curve(t, c) : u.line(t, c) : Vn(i, mn(t, c))), l && c > 0 && c < 1 && zn(i, Ht(t, c), l, u);
2969
3048
  }
2970
3049
  };
2971
3050
  }
2972
- function Nr(e) {
3051
+ function Pr(e) {
2973
3052
  const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2974
3053
  if (!t) return "rgba(0, 0, 0, 0)";
2975
- const n = t[1].length === 3 ? [...t[1]].map((i) => i + i).join("") : t[1], [r, o, s] = [0, 2, 4].map((i) => parseInt(n.slice(i, i + 2), 16));
2976
- return `rgba(${r}, ${o}, ${s}, 0)`;
3054
+ const n = t[1].length === 3 ? [...t[1]].map((l) => l + l).join("") : t[1], [s, o, r] = [0, 2, 4].map((l) => parseInt(n.slice(l, l + 2), 16));
3055
+ return `rgba(${s}, ${o}, ${r}, 0)`;
2977
3056
  }
2978
- function pn(e, t, n) {
3057
+ function Vn(e, t, n) {
2979
3058
  if (!(t.length < 2)) {
2980
3059
  if (n) return n.line(t);
2981
3060
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
2982
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
3061
+ for (const s of t.slice(1)) e.lineTo(s.x, s.y);
2983
3062
  e.stroke();
2984
3063
  }
2985
3064
  }
2986
- const Ae = 1e5;
2987
- function ks(e, t, n, r, o = 6) {
2988
- const s = [], i = Math.max(1, Math.round(o));
2989
- for (let l = 0; l <= i; l++)
2990
- s.push({ x: l % 2 === 0 ? e : e + n, y: t + r * l / i });
2991
- return s;
3065
+ const Re = 1e5;
3066
+ function Ni(e, t, n, s, o = 6) {
3067
+ const r = [], l = Math.max(1, Math.round(o));
3068
+ for (let i = 0; i <= l; i++)
3069
+ r.push({ x: i % 2 === 0 ? e : e + n, y: t + s * i / l });
3070
+ return r;
2992
3071
  }
2993
- function bn(e, t, n, r) {
2994
- if (r <= 0 || t.length === 0) return;
2995
- const o = Rt(t, r), s = n / 2, i = (l) => {
2996
- e.beginPath(), e.rect(-Ae, -Ae, 2 * Ae, 2 * Ae), l(), e.clip("evenodd");
3072
+ function jn(e, t, n, s) {
3073
+ if (s <= 0 || t.length === 0) return;
3074
+ const o = mn(t, s), r = n / 2, l = (i) => {
3075
+ e.beginPath(), e.rect(-Re, -Re, 2 * Re, 2 * Re), i(), e.clip("evenodd");
2997
3076
  };
2998
- for (const l of o)
2999
- i(() => {
3000
- e.moveTo(l.x + s, l.y), e.arc(l.x, l.y, s, 0, Math.PI * 2);
3077
+ for (const i of o)
3078
+ l(() => {
3079
+ e.moveTo(i.x + r, i.y), e.arc(i.x, i.y, r, 0, Math.PI * 2);
3001
3080
  });
3002
- for (let l = 1; l < o.length; l++) {
3003
- const a = o[l - 1], h = o[l], c = Math.hypot(h.x - a.x, h.y - a.y);
3081
+ for (let i = 1; i < o.length; i++) {
3082
+ const a = o[i - 1], h = o[i], c = Math.hypot(h.x - a.x, h.y - a.y);
3004
3083
  if (c === 0) continue;
3005
- const p = -(h.y - a.y) / c * s, d = (h.x - a.x) / c * s;
3006
- i(() => {
3007
- e.moveTo(a.x + p, a.y + d), e.lineTo(h.x + p, h.y + d), e.lineTo(h.x - p, h.y - d), e.lineTo(a.x - p, a.y - d), e.closePath();
3084
+ const u = -(h.y - a.y) / c * r, g = (h.x - a.x) / c * r;
3085
+ l(() => {
3086
+ e.moveTo(a.x + u, a.y + g), e.lineTo(h.x + u, h.y + g), e.lineTo(h.x - u, h.y - g), e.lineTo(a.x - u, a.y - g), e.closePath();
3008
3087
  });
3009
3088
  }
3010
3089
  }
3011
- function Ss(e, t, n, r, o) {
3012
- e.save(), bn(e, t, n, r), o(), e.restore();
3090
+ function Yi(e, t, n, s, o) {
3091
+ e.save(), jn(e, t, n, s), o(), e.restore();
3013
3092
  }
3014
- function Es(e, t) {
3015
- const n = t.width ?? 40, r = t.hand === !0 ? {} : t.hand || void 0, o = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
3093
+ function Ci(e, t) {
3094
+ const n = t.width ?? 40, s = t.hand === !0 ? {} : t.hand || void 0, o = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
3016
3095
  return {
3017
3096
  ...e,
3018
3097
  props: { ...e.props, erase: 0 },
3019
- draw(s, i, l) {
3020
- const a = Number(i.props?.erase ?? 0);
3021
- if (s.save(), bn(s, t.path, n, a), e.draw(s, i, l), s.restore(), !o || a <= 0 || a >= 1) return;
3022
- const h = lt(t.path, a);
3023
- r ? gn(s, h, { ...r, tool: "eraser" }) : un(s, h, o);
3098
+ draw(r, l, i) {
3099
+ const a = Number(l.props?.erase ?? 0);
3100
+ if (r.save(), jn(r, t.path, n, a), e.draw(r, l, i), r.restore(), !o || a <= 0 || a >= 1) return;
3101
+ const h = Ht(t.path, a);
3102
+ s ? zn(r, h, { ...s, tool: "eraser" }) : Gn(r, h, o);
3024
3103
  }
3025
3104
  };
3026
3105
  }
3027
- const Cr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
3028
- function Hs(e = {}) {
3029
- const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", r = (l) => l.lineWidth * 0.45, o = (l, a, h) => {
3030
- const c = l.parts[`leg.${h}`].points;
3031
- a.shape(Ke(c, l.height * 0.08, l.height * 0.05), n, r(l));
3032
- }, s = (l, a) => {
3033
- const h = l.chains.spine, c = h[0], p = h[h.length - 1], d = { x: c.x - (p.x - c.x) * 0.25, y: c.y - (p.y - c.y) * 0.25 };
3034
- a.shape(Ke([d, ...l.parts.spine.points], l.height * 0.15, l.height * 0.14), t, r(l));
3035
- }, i = (l, a, h) => {
3036
- const c = l.parts[`arm.${h}`].points, p = c[0], d = l.chains.spine[l.chains.spine.length - 1], b = [{ x: p.x + (d.x - p.x) * 0.45, y: p.y + (d.y - p.y) * 0.45 }, ...Cr(c, 0, 0.45)], f = Ke(b, l.height * 0.085, l.height * 0.06), g = b.length, m = f.slice(0, g), k = f.slice(g).reverse();
3037
- a.shape(f, t, 0);
3038
- const y = (w) => Math.hypot(w[1].x - d.x, w[1].y - d.y), [H, E] = y(m) > y(k) ? [m, k] : [k, m];
3039
- a.line(H.slice(1), r(l)), a.line(E.slice(Math.ceil(g * 0.45)), r(l)), a.line([m[g - 1], k[g - 1]], r(l));
3106
+ const Wr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
3107
+ function Di(e = {}) {
3108
+ const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", s = (i) => i.lineWidth * 0.45, o = (i, a, h) => {
3109
+ const c = i.parts[`leg.${h}`].points;
3110
+ a.shape(Ye(c, i.height * 0.08, i.height * 0.05), n, s(i));
3111
+ }, r = (i, a) => {
3112
+ const h = i.chains.spine, c = h[0], u = h[h.length - 1], g = { x: c.x - (u.x - c.x) * 0.25, y: c.y - (u.y - c.y) * 0.25 };
3113
+ a.shape(Ye([g, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), t, s(i));
3114
+ }, l = (i, a, h) => {
3115
+ const c = i.parts[`arm.${h}`].points, u = c[0], g = i.chains.spine[i.chains.spine.length - 1], p = [{ x: u.x + (g.x - u.x) * 0.45, y: u.y + (g.y - u.y) * 0.45 }, ...Wr(c, 0, 0.45)], d = Ye(p, i.height * 0.085, i.height * 0.06), m = p.length, b = d.slice(0, m), y = d.slice(m).reverse();
3116
+ a.shape(d, t, 0);
3117
+ const E = (A) => Math.hypot(A[1].x - g.x, A[1].y - g.y), [H, M] = E(b) > E(y) ? [b, y] : [y, b];
3118
+ a.line(H.slice(1), s(i)), a.line(M.slice(Math.ceil(m * 0.45)), s(i)), a.line([b[m - 1], y[m - 1]], s(i));
3040
3119
  };
3041
3120
  return {
3042
3121
  parts: {
3043
- "leg.left": { over: (l, a, h) => o(a, h, "left") },
3044
- "leg.right": { over: (l, a, h) => o(a, h, "right") },
3045
- spine: { over: (l, a, h) => s(a, h) },
3046
- "arm.left": { over: (l, a, h) => i(a, h, "left") },
3047
- "arm.right": { over: (l, a, h) => i(a, h, "right") }
3122
+ "leg.left": { over: (i, a, h) => o(a, h, "left") },
3123
+ "leg.right": { over: (i, a, h) => o(a, h, "right") },
3124
+ spine: { over: (i, a, h) => r(a, h) },
3125
+ "arm.left": { over: (i, a, h) => l(a, h, "left") },
3126
+ "arm.right": { over: (i, a, h) => l(a, h, "right") }
3127
+ }
3128
+ };
3129
+ }
3130
+ const ht = {
3131
+ full: {
3132
+ anticipation: 0.12,
3133
+ anticipationTime: 0.3,
3134
+ hold: 0,
3135
+ overshoot: 0.08,
3136
+ settle: 220,
3137
+ settleEase: "ease-in-out",
3138
+ actionEase: "ease-in-out-cubic",
3139
+ overlap: 45,
3140
+ eyeLead: 120,
3141
+ eyeDart: 160,
3142
+ drift: 0.12,
3143
+ blinks: !0,
3144
+ jumpSquash: 1
3145
+ },
3146
+ snappy: {
3147
+ anticipation: 0.2,
3148
+ anticipationTime: 0.35,
3149
+ hold: 0.12,
3150
+ overshoot: 0.12,
3151
+ settle: 320,
3152
+ settleEase: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 },
3153
+ actionEase: "ease-out-cubic",
3154
+ overlap: 35,
3155
+ eyeLead: 100,
3156
+ eyeDart: 100,
3157
+ drift: 0.1,
3158
+ blinks: !0,
3159
+ jumpSquash: 1.3
3160
+ },
3161
+ limited: {
3162
+ anticipation: 0.06,
3163
+ anticipationTime: 0.25,
3164
+ hold: 0,
3165
+ overshoot: 0,
3166
+ settle: 0,
3167
+ settleEase: "ease-out",
3168
+ actionEase: "ease-in-out",
3169
+ overlap: 30,
3170
+ eyeLead: 80,
3171
+ eyeDart: 120,
3172
+ drift: 0,
3173
+ blinks: !0,
3174
+ jumpSquash: 0.6
3175
+ },
3176
+ none: {
3177
+ anticipation: 0,
3178
+ anticipationTime: 0,
3179
+ hold: 0,
3180
+ overshoot: 0,
3181
+ settle: 0,
3182
+ settleEase: "linear",
3183
+ actionEase: "linear",
3184
+ overlap: 0,
3185
+ eyeLead: 0,
3186
+ eyeDart: 0,
3187
+ drift: 0,
3188
+ blinks: !1,
3189
+ jumpSquash: 0
3190
+ }
3191
+ };
3192
+ function Or(e) {
3193
+ if (e === void 0) return ht.full;
3194
+ if (typeof e == "string") return ht[e];
3195
+ const { base: t, ...n } = e;
3196
+ return { ...ht[t ?? "full"], ...n };
3197
+ }
3198
+ const Mt = 160, Ir = 120, _r = 700, ct = 60, $r = 90, Le = 3200, ye = 1, ue = 1e-6;
3199
+ function Jn(e, t, n = {}) {
3200
+ const s = Or(n.style), o = n.seed ?? 1, r = {};
3201
+ if (e.length === 0) return r;
3202
+ const l = Object.keys(e[0].pose).filter((u) => e.some((g) => Math.abs(g.pose[u] - e[0].pose[u]) > ue));
3203
+ for (const u of l) r[u] = Br(u, e, t, s, o);
3204
+ const i = t.blink, a = i !== void 0 && l.includes(i);
3205
+ if (s.blinks && i !== void 0 && !a && i in e[0].pose) {
3206
+ const u = Fr(e, t, s, o, e[0].pose[i]);
3207
+ u.length > 0 && (r[i] = u);
3208
+ }
3209
+ const { lift: h, stretch: c } = t;
3210
+ if (s.jumpSquash > 0 && h && c && l.includes(h) && !l.includes(c) && c in e[0].pose) {
3211
+ const u = Rr(e, h, e[0].pose[c], s.jumpSquash);
3212
+ u.length > 0 && (r[c] = u);
3213
+ }
3214
+ return r;
3215
+ }
3216
+ function Br(e, t, n, s, o) {
3217
+ const r = n.eyes.includes(e), l = n.limits[e], i = l !== void 0, a = r ? -s.eyeLead : (n.depth[e] ?? 1) * s.overlap, h = (f) => {
3218
+ const p = (t[f].time - t[f - 1].time) / 2;
3219
+ return Math.max(-p, Math.min(p, a));
3220
+ }, c = [{ time: t[0].time, value: t[0].pose[e] }], u = (f, p, d) => {
3221
+ const m = c[c.length - 1];
3222
+ if (f <= m.time + ye) {
3223
+ c[c.length - 1] = { ...m, value: p, ...d ? { easing: d } : {} };
3224
+ return;
3225
+ }
3226
+ c.push({ time: f, value: p, ...d ? { easing: d } : {} });
3227
+ };
3228
+ let g = t[0].pose[e];
3229
+ for (let f = 1; f < t.length; f++) {
3230
+ const p = t[f], d = t[f - 1].pose[e], m = p.pose[e], b = m - d, y = c[c.length - 1].time, E = p.act !== !1;
3231
+ if (Math.abs(b) <= ue) {
3232
+ const v = p.time + (E ? h(f) : 0);
3233
+ if (f === t.length - 1)
3234
+ Math.abs(g - m) > ue && u(Math.max(v, y + Mt), m, "ease-in-out"), g = m;
3235
+ else if (E && i && s.drift > 0 && n.drift.includes(e) && v - y >= _r) {
3236
+ const T = Ze(`${o}:${e}:${f}`) % 2 === 0 ? 1 : -1;
3237
+ g = m + T * s.drift * l, u(v, g, "ease-in-out");
3238
+ }
3239
+ continue;
3240
+ }
3241
+ if (!E) {
3242
+ u(t[f - 1].time, g), u(p.time, m, p.easing), g = m;
3243
+ continue;
3244
+ }
3245
+ const H = h(f), M = Math.max(t[f - 1].time + H, y);
3246
+ let A = p.time + H;
3247
+ r && s.eyeDart > 0 && (A = Math.min(A, M + s.eyeDart));
3248
+ const w = A - M;
3249
+ if (w <= ye) {
3250
+ u(p.time, m, p.easing), g = m;
3251
+ continue;
3048
3252
  }
3253
+ u(M, g);
3254
+ const S = Math.sign(b);
3255
+ if (i && s.anticipation > 0 && l > 0 && w >= Mt) {
3256
+ const v = g - S * Math.min(Math.abs(b) * s.anticipation, l), T = M + w * s.anticipationTime;
3257
+ u(T, v, "ease-in-out"), s.hold > 0 && u(T + w * s.hold, v);
3258
+ }
3259
+ const k = f + 1 < t.length ? t[f + 1].time - p.time : 1 / 0, x = Math.min(s.settle, k / 2);
3260
+ if (i && s.overshoot > 0 && l > 0 && w >= Ir && x > ye) {
3261
+ const v = Math.min(Math.abs(b) * s.overshoot, l);
3262
+ u(A, m + S * v, p.easing ?? s.actionEase), u(A + x, m, s.settleEase);
3263
+ } else
3264
+ u(A, m, p.easing ?? s.actionEase);
3265
+ g = m;
3266
+ }
3267
+ return c;
3268
+ }
3269
+ function Fr(e, t, n, s, o) {
3270
+ const r = [], l = ct + $r;
3271
+ for (let f = 1; f < e.length; f++) {
3272
+ const p = e[f - 1].pose, d = e[f].pose;
3273
+ Object.entries(t.headTurns).some(([b, y]) => Math.abs((d[b] ?? 0) - (p[b] ?? 0)) > y) && e[f].act !== !1 && r.push(Math.max(e[0].time, e[f - 1].time - n.eyeLead));
3274
+ }
3275
+ const i = e[0].time, a = e[e.length - 1].time, h = [...r];
3276
+ let c = i + Le * 0.6, u = 0;
3277
+ for (; c < a; ) {
3278
+ h.some((d) => Math.abs(d - c) < Le / 2) || r.push(c);
3279
+ const p = (Ze(`${s}:blink:${u++}`) % 1e3 / 1e3 - 0.5) * (Le * 0.66);
3280
+ c += Le + p;
3281
+ }
3282
+ r.sort((f, p) => f - p);
3283
+ const g = [{ time: i, value: o }];
3284
+ for (const f of r) {
3285
+ const p = g[g.length - 1].time;
3286
+ f + ct <= p + ye || (f > p + ye && g.push({ time: f, value: o }), g.push({ time: f + ct, value: 1, easing: "ease-in" }), g.push({ time: f + l, value: o, easing: "ease-out" }));
3287
+ }
3288
+ return g.length > 1 ? g : [];
3289
+ }
3290
+ function Rr(e, t, n, s) {
3291
+ const o = n * (1 - 0.18 * s), r = n * (1 + 0.14 * s), l = [{ time: e[0].time, value: n }], i = (a, h, c) => {
3292
+ const u = l[l.length - 1];
3293
+ a <= u.time + ye || l.push({ time: a, value: h, ...c ? { easing: c } : {} });
3049
3294
  };
3295
+ for (let a = 1; a < e.length; a++) {
3296
+ const h = e[a - 1].pose[t], c = e[a].pose[t], u = e[a - 1].time, g = e[a].time, f = g - u;
3297
+ if (!(f < Mt || e[a].act === !1)) {
3298
+ if (h <= ue && c > ue)
3299
+ i(u, n), i(u + f * 0.2, o, "ease-out"), i(u + f * 0.45, r, "ease-out"), i(g, n, "ease-in-out");
3300
+ else if (h > ue && c <= ue) {
3301
+ const p = a + 1 < e.length ? e[a + 1].time - g : 400;
3302
+ i(u + f * 0.5, n), i(g - Math.min(60, f * 0.15), r, "ease-in"), i(g, o, "ease-out"), i(g + Math.min(260, p / 2), n, { type: "back", mode: "out", overshoot: 1.4 });
3303
+ }
3304
+ }
3305
+ }
3306
+ return l.length > 1 ? l : [];
3307
+ }
3308
+ const Lr = {
3309
+ depth: {
3310
+ lean: 0,
3311
+ bend: 0,
3312
+ rise: 0,
3313
+ sit: 0,
3314
+ spin: 0,
3315
+ stretch: 0,
3316
+ turn: 0,
3317
+ leftHip: 0,
3318
+ rightHip: 0,
3319
+ headTilt: 1,
3320
+ leftShoulder: 1,
3321
+ rightShoulder: 1,
3322
+ leftKnee: 1,
3323
+ rightKnee: 1,
3324
+ leftBrow: 1,
3325
+ rightBrow: 1,
3326
+ browTilt: 1,
3327
+ leftEye: 1,
3328
+ rightEye: 1,
3329
+ leftElbow: 2,
3330
+ rightElbow: 2,
3331
+ leftAnkle: 2,
3332
+ rightAnkle: 2,
3333
+ leftFootOut: 2,
3334
+ rightFootOut: 2,
3335
+ mouth: 2,
3336
+ smile: 2,
3337
+ mouthWidth: 2,
3338
+ leftWrist: 3,
3339
+ rightWrist: 3
3340
+ },
3341
+ limits: {
3342
+ lean: 10,
3343
+ bend: 10,
3344
+ headTilt: 12,
3345
+ spin: 25,
3346
+ turn: 0.06,
3347
+ sit: 0.06,
3348
+ stretch: 0.08,
3349
+ rise: 0,
3350
+ leftShoulder: 20,
3351
+ rightShoulder: 20,
3352
+ leftElbow: 18,
3353
+ rightElbow: 18,
3354
+ leftWrist: 15,
3355
+ rightWrist: 15,
3356
+ leftHip: 12,
3357
+ rightHip: 12,
3358
+ leftKnee: 15,
3359
+ rightKnee: 15,
3360
+ leftAnkle: 10,
3361
+ rightAnkle: 10,
3362
+ leftBrow: 0.25,
3363
+ rightBrow: 0.25,
3364
+ leftEye: 0.15,
3365
+ rightEye: 0.15
3366
+ },
3367
+ eyes: ["lookX", "lookY"],
3368
+ blink: "blink",
3369
+ headTurns: { turn: 0.15, headTilt: 8, lookX: 0.5, spin: 45 },
3370
+ drift: ["lean", "bend", "headTilt", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow"],
3371
+ lift: "rise",
3372
+ stretch: "stretch"
3373
+ };
3374
+ function Nr(e) {
3375
+ return /^(turn|lean|side|lift|roll|stretch)$/.test(e) ? { depth: 0, limit: { turn: 0.06, lean: 10, side: 8, lift: 0, roll: 25, stretch: 0.08 }[e] } : /^leg\.\w+\.(swing|spread|rotate)$/.test(e) ? { depth: 0, limit: 12 } : /^head\./.test(e) ? { depth: 1, limit: 12 } : /^arm\.\w+\.(swing|spread)$/.test(e) ? { depth: 1, limit: 20 } : /^leg\.\w+\.knee$/.test(e) ? { depth: 1, limit: 15 } : /^(brow\.|browTilt$)/.test(e) ? { depth: 1, limit: e === "browTilt" ? void 0 : 0.25 } : /^eye\./.test(e) ? { depth: 1, limit: 0.15 } : /^arm\.\w+\.(elbow|bend)$/.test(e) ? { depth: 2, limit: 18 } : /^leg\.\w+\.(ankle|toeOut)$/.test(e) ? { depth: 2, limit: 10 } : /^(mouth|smile|mouthWidth)$/.test(e) ? { depth: 2 } : /^hand\./.test(e) ? { depth: 3 } : { depth: 1 };
3376
+ }
3377
+ function Yr() {
3378
+ const e = {}, t = {};
3379
+ for (const n of Object.keys(X)) {
3380
+ const s = Nr(n);
3381
+ e[n] = s.depth, s.limit !== void 0 && (t[n] = s.limit);
3382
+ }
3383
+ return {
3384
+ depth: e,
3385
+ limits: t,
3386
+ eyes: ["lookX", "lookY"],
3387
+ blink: "blink",
3388
+ headTurns: { turn: 0.15, "head.turn": 15, "head.nod": 12, lookX: 0.5, roll: 45 },
3389
+ drift: ["lean", "head.tilt", "head.nod", "arm.left.spread", "arm.right.spread", "arm.left.elbow", "arm.right.elbow"],
3390
+ lift: "lift",
3391
+ stretch: "stretch"
3392
+ };
3393
+ }
3394
+ const Cr = Yr();
3395
+ function Zn(e, t) {
3396
+ return Object.entries(t).map(([n, s]) => ({ id: `${e}-${n}`, target: e, property: n, keyframes: s }));
3397
+ }
3398
+ function Dr(e, t, n = {}) {
3399
+ const s = _n(t), o = t.map((r, l) => ({ time: r.time, pose: { ...s[l] }, easing: r.easing, act: r.act }));
3400
+ return Zn(e, Jn(o, n.rig ?? Lr, n));
3401
+ }
3402
+ function Xi(e, t, n = {}) {
3403
+ const s = n.rest ?? X, o = qn(t, s), r = t.map((l, i) => ({ time: l.time, pose: { ...s, ...o[i] }, easing: l.easing, act: l.act }));
3404
+ return Zn(e, Jn(r, n.rig ?? Cr, n));
3405
+ }
3406
+ const rn = Y.shocked, Xr = Y.scared, Bt = {
3407
+ /** The classic take: squash down in a squint, then shoot up stretched with eyes popping, hang, and land squashed. */
3408
+ take: (e) => [
3409
+ { after: 140, pose: { stretch: 0.8, bend: 10, lean: e.lean - 4, leftShoulder: 8, rightShoulder: 8, leftEye: 0.35, rightEye: 0.35, leftBrow: -0.6, rightBrow: -0.6, mouth: 0 }, easing: "ease-in-out" },
3410
+ { after: 260, pose: { stretch: 0.78 } },
3411
+ { after: 360, pose: { rise: 0.22, stretch: 1.35, bend: -14, leftShoulder: 150, rightShoulder: 150, leftElbow: 35, rightElbow: 35, leftHip: 22, rightHip: 22, leftKnee: 45, rightKnee: 45, ...rn, headTilt: 0 }, easing: "ease-out-cubic" },
3412
+ { after: 720, pose: { rise: 0.25, stretch: 1.25, bend: -10, leftShoulder: 140, rightShoulder: 140 }, easing: "ease-in-out" },
3413
+ { after: 900, pose: { rise: 0, stretch: 0.74, bend: 12, leftShoulder: 70, rightShoulder: 70, leftHip: 18, rightHip: 18, leftKnee: 30, rightKnee: 30 }, easing: "ease-in-quad" },
3414
+ { after: 1060, pose: { stretch: 1.06, bend: -3, leftShoulder: 60, rightShoulder: 60, leftHip: e.leftHip, rightHip: e.rightHip, leftKnee: e.leftKnee, rightKnee: e.rightKnee }, easing: "ease-out" },
3415
+ { after: 1260, pose: { stretch: e.stretch, bend: e.bend, ...Y.surprised, leftShoulder: 70, rightShoulder: 70, leftElbow: 60, rightElbow: 60 }, easing: "ease-in-out" }
3416
+ ],
3417
+ /** Glance at something, look away unbothered, then snap back to it in shock. */
3418
+ doubleTake: (e) => [
3419
+ { after: 160, pose: { lookX: 1, lookY: 0 }, easing: "ease-out" },
3420
+ { after: 520, pose: { lookX: -0.6, headTilt: e.headTilt - 4, smile: 0.6, mouth: 0 }, easing: "ease-in-out" },
3421
+ { after: 1100, pose: { lookX: -0.6 } },
3422
+ { after: 1180, pose: { bend: e.bend - 10, headTilt: e.headTilt + 10, rise: 0.05, stretch: 1.18, ...rn, lookX: 1, lookY: 0 }, easing: "ease-out-cubic" },
3423
+ { after: 1360, pose: { rise: 0, stretch: 0.88, bend: e.bend + 4, headTilt: e.headTilt + 4 }, easing: "ease-in-quad" },
3424
+ { after: 1560, pose: { stretch: e.stretch, bend: e.bend, headTilt: e.headTilt }, easing: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 } }
3425
+ ],
3426
+ /** Rear back for a zip-off: lean back, one knee up, arms cocked, hold, then pitch forward ready to run. */
3427
+ windUp: () => [
3428
+ { after: 220, pose: { lean: -18, bend: -16, headTilt: -6, leftShoulder: 70, leftElbow: -100, rightShoulder: 40, rightElbow: 100, leftHip: -45, leftKnee: -80, stretch: 0.92, ...Y.angry, lookX: 1 }, easing: "ease-out" },
3429
+ { after: 620, pose: { lean: -20, bend: -18, stretch: 0.9 } },
3430
+ { after: 700, pose: { lean: 28, bend: 14, headTilt: 6, leftShoulder: 30, rightShoulder: 60, leftHip: 30, leftKnee: -30, rightHip: -20, stretch: 1.12 }, easing: "ease-out-cubic" }
3431
+ ],
3432
+ /** Coming down to the ground: stretched in the fall, squashed on contact, a spring back up. */
3433
+ land: (e) => [
3434
+ { after: 120, pose: { rise: 0, stretch: 0.7, bend: 14, leftShoulder: 75, rightShoulder: 75, leftHip: 20, rightHip: 20, leftKnee: 35, rightKnee: 35 }, easing: "ease-in-quad" },
3435
+ { after: 300, pose: { stretch: 1.05, bend: -4, leftShoulder: e.leftShoulder, rightShoulder: e.rightShoulder }, easing: "ease-out" },
3436
+ { after: 460, pose: { rise: 0, stretch: e.stretch, bend: e.bend, leftHip: _.leftHip, rightHip: _.rightHip, leftKnee: 0, rightKnee: 0 }, easing: "ease-in-out" }
3437
+ ],
3438
+ /** A frightened shiver: small, fast shakes with wide eyes, then still. */
3439
+ tremble: (e) => {
3440
+ const t = [{ after: 80, pose: { ...Xr, bend: e.bend + 8, leftShoulder: 40, rightShoulder: 40, leftElbow: 110, rightElbow: 110, stretch: 0.94 }, easing: "ease-out" }];
3441
+ for (let n = 1; n <= 14; n++) t.push({ after: 80 + n * 45, pose: { lean: e.lean + (n % 2 === 0 ? 2.5 : -2.5), headTilt: e.headTilt + (n % 2 === 0 ? -2 : 2) } });
3442
+ return t.push({ after: 755, pose: { lean: e.lean, headTilt: e.headTilt, bend: e.bend } }), t;
3443
+ },
3444
+ /** A sigh: the body sags, shoulders drop, head and eyes go down. */
3445
+ deflate: (e) => [
3446
+ { after: 260, pose: { stretch: 1.04, headTilt: e.headTilt + 4, leftBrow: 0.3, rightBrow: 0.3 }, easing: "ease-in-out" },
3447
+ { after: 900, pose: { ...Oe.sad, bend: 18, stretch: 0.92, lean: e.lean + 5, turn: e.turn, sit: e.sit }, easing: "ease-in-out" }
3448
+ ]
3449
+ };
3450
+ function qr(e, t) {
3451
+ const n = typeof t.from == "string" ? Oe[t.from] : t.from ?? _, s = t.speed ?? 1;
3452
+ let o = n;
3453
+ return [
3454
+ // The move onto the starting pose is acted like any other; the gag itself is not.
3455
+ { time: t.at, pose: n },
3456
+ ...Bt[e](n).map((r) => (o = { ...o, ...r.pose }, { time: t.at + r.after * s, pose: o, act: !1, ...r.easing ? { easing: r.easing } : {} }))
3457
+ ];
3458
+ }
3459
+ function Gr(e, t = 1) {
3460
+ const n = Bt[e](_);
3461
+ return n[n.length - 1].after * t;
3462
+ }
3463
+ function Ur(e, t, n = {}) {
3464
+ if (t.length < 2) return;
3465
+ const s = Math.max(1, Math.round(n.lines ?? 3)), o = n.spacing ?? 5, r = n.lineWidth ?? 2, l = n.opacity ?? 0.7;
3466
+ e.save(), e.strokeStyle = n.color ?? "#222", e.lineCap = "round";
3467
+ for (let i = 0; i < s; i++) {
3468
+ const a = (i - (s - 1) / 2) * o, h = Math.floor(Math.abs(a) / Math.max(o, 1) * (t.length / 6));
3469
+ for (let c = h + 1; c < t.length; c++) {
3470
+ const u = t[c - 1], g = t[c], f = g.x - u.x, p = g.y - u.y, d = Math.hypot(f, p) || 1, m = -p / d, b = f / d, y = 1 - c / (t.length - 1);
3471
+ e.globalAlpha = l * (1 - y), e.lineWidth = r * (1 - y * 0.7), e.beginPath(), e.moveTo(u.x + m * a, u.y + b * a), e.lineTo(g.x + m * a, g.y + b * a), e.stroke();
3472
+ }
3473
+ }
3474
+ e.restore();
3475
+ }
3476
+ const zr = {
3477
+ hands: [
3478
+ { name: "left hand", at: (e) => e.hands.left },
3479
+ { name: "right hand", at: (e) => e.hands.right }
3480
+ ],
3481
+ toes: [
3482
+ { name: "left toe", at: (e) => e.toes.left },
3483
+ { name: "right toe", at: (e) => e.toes.right }
3484
+ ],
3485
+ head: [{ name: "head", at: (e) => e.head.center }],
3486
+ body: [
3487
+ { name: "hip", at: (e) => e.hip },
3488
+ { name: "neck", at: (e) => e.neck }
3489
+ ]
3490
+ };
3491
+ function qi(e, t, n, s, o = {}) {
3492
+ const r = n.stateAt;
3493
+ if (!r) return;
3494
+ const l = o.length ?? 120, i = Math.max(2, Math.round(o.samples ?? 8)), a = Math.max(0, n.time - l);
3495
+ if (n.time - a < 1) return;
3496
+ const h = [];
3497
+ for (let f = 0; f < i; f++) {
3498
+ const p = a + (n.time - a) * f / (i - 1);
3499
+ h.push(ds(t, { time: p, state: r(p) }, s).joints);
3500
+ }
3501
+ const c = h[h.length - 1].height, u = (o.threshold ?? 1.2) * c, g = (o.parts ?? ["hands", "toes", "head"]).flatMap((f) => zr[f]);
3502
+ for (const f of g) {
3503
+ const p = h.map(f.at);
3504
+ let d = 0;
3505
+ for (let y = 1; y < p.length; y++) d += Math.hypot(p[y].x - p[y - 1].x, p[y].y - p[y - 1].y);
3506
+ const m = d / ((n.time - a) / 1e3);
3507
+ if (m <= u) continue;
3508
+ const b = Math.min(1, (m - u) / (u * 0.5));
3509
+ Ur(e, p, { ...o, opacity: (o.opacity ?? 0.7) * b, spacing: o.spacing ?? c * 0.02 });
3510
+ }
3511
+ }
3512
+ function Gi(e, t, n, s = {}) {
3513
+ if (n <= 0 || n >= 1) return;
3514
+ const o = s.size ?? 40, r = s.seed ?? 1, l = 0.45 + 0.55 * (1 - (1 - n) ** 3);
3515
+ e.save(), e.strokeStyle = s.color ?? "#555", e.lineWidth = Math.max(1, o * 0.03), e.globalAlpha = Math.min(1, n / 0.08) * (1 - n);
3516
+ for (let i = 0; i < 5; i++) {
3517
+ const a = Ze(`${r}:puff:${i}`) % 1e3 / 1e3, h = i - 2, c = t.x + h * o * 0.3 * l, u = t.y - o * (0.06 + 0.12 * a) * l + Math.abs(h) * o * 0.03, g = o * (0.11 + 0.07 * a) * l;
3518
+ e.beginPath(), e.arc(c, u, g, Math.PI * 0.95, Math.PI * 2.05), e.stroke();
3519
+ }
3520
+ e.restore();
3521
+ }
3522
+ function Ui(e, t, n, s = {}) {
3523
+ if (n <= 0 || n >= 1) return;
3524
+ const o = s.size ?? 40, r = 5, l = 1 - (1 - n) ** 2;
3525
+ e.save(), e.strokeStyle = s.color ?? "#222", e.lineWidth = Math.max(1, o * 0.035), e.lineJoin = "round", e.globalAlpha = n < 0.7 ? 1 : (1 - n) / 0.3;
3526
+ for (let i = 0; i < r; i++) {
3527
+ const a = -Math.PI / 2 + (i - (r - 1) / 2) * Math.PI / (r + 1), h = o * (0.3 + 0.7 * l), c = t.x + Math.cos(a) * h, u = t.y + Math.sin(a) * h;
3528
+ Vr(e, c, u, o * 0.14, n * Math.PI + i), e.stroke();
3529
+ }
3530
+ e.restore();
3531
+ }
3532
+ function Vr(e, t, n, s, o) {
3533
+ e.beginPath();
3534
+ for (let r = 0; r < 10; r++) {
3535
+ const l = r % 2 === 0 ? s : s * 0.45, i = o + r * Math.PI / 5 - Math.PI / 2, a = t + Math.cos(i) * l, h = n + Math.sin(i) * l;
3536
+ r === 0 ? e.moveTo(a, h) : e.lineTo(a, h);
3537
+ }
3538
+ e.closePath();
3539
+ }
3540
+ const ce = {
3541
+ /** Closed and relaxed */
3542
+ rest: { mouth: 0, mouthWidth: 1 },
3543
+ /** "ah": open wide */
3544
+ a: { mouth: 0.75, mouthWidth: 1.1 },
3545
+ /** "eh": open, wide */
3546
+ e: { mouth: 0.45, mouthWidth: 1.3 },
3547
+ /** "ee": a little open, stretched wide */
3548
+ i: { mouth: 0.28, mouthWidth: 1.45 },
3549
+ /** "oh": round */
3550
+ o: { mouth: 0.6, mouthWidth: 0.7 },
3551
+ /** "oo": small and pursed */
3552
+ u: { mouth: 0.32, mouthWidth: 0.55 },
3553
+ /** m, b, p: lips pressed */
3554
+ m: { mouth: 0, mouthWidth: 0.9 },
3555
+ /** f, v: lip under the teeth */
3556
+ f: { mouth: 0.1, mouthWidth: 1.05 },
3557
+ /** l, th, n, d, t: tongue up, a little open */
3558
+ l: { mouth: 0.3, mouthWidth: 1 },
3559
+ /** Other consonants: slightly open */
3560
+ c: { mouth: 0.2, mouthWidth: 1 }
3561
+ }, Me = 1, Ne = 0.55, ln = 0.35, jr = 1.6, an = { a: "a", e: "e", i: "i", y: "i", o: "o", u: "u" }, hn = { m: "m", b: "m", p: "m", f: "f", v: "f", w: "u", q: "u", l: "l", n: "l", d: "l", t: "l" }, cn = {
3562
+ अ: "a",
3563
+ आ: "a",
3564
+ इ: "i",
3565
+ ई: "i",
3566
+ उ: "u",
3567
+ ऊ: "u",
3568
+ ऋ: "i",
3569
+ ए: "e",
3570
+ ऐ: "e",
3571
+ ओ: "o",
3572
+ औ: "o",
3573
+ ऍ: "e",
3574
+ ऑ: "o"
3575
+ }, fn = {
3576
+ "ा": "a",
3577
+ "ि": "i",
3578
+ "ी": "i",
3579
+ "ु": "u",
3580
+ "ू": "u",
3581
+ "ृ": "i",
3582
+ "े": "e",
3583
+ "ै": "e",
3584
+ "ो": "o",
3585
+ "ौ": "o",
3586
+ "ॅ": "e",
3587
+ "ॉ": "o"
3588
+ }, Jr = { प: "m", फ: "m", ब: "m", भ: "m", म: "m", व: "u" }, Zr = "्", un = "़", Qr = (e) => e >= "क" && e <= "ह", dn = /* @__PURE__ */ new Set([".", ",", "!", "?", ";", ":", "…", "।", "॥", "—", "-"]);
3589
+ function ei(e) {
3590
+ const t = [], n = Array.from(e.toLowerCase()), s = (o, r) => {
3591
+ const l = t[t.length - 1];
3592
+ l && l.viseme === o ? l.weight += r * 0.5 : t.push({ viseme: o, weight: r });
3593
+ };
3594
+ for (let o = 0; o < n.length; o++) {
3595
+ const r = n[o], l = n[o + 1];
3596
+ if (dn.has(r)) s("rest", jr);
3597
+ else if (/\s/.test(r)) {
3598
+ const i = t[t.length - 1];
3599
+ i && i.viseme !== "rest" && t.push({ viseme: "c", weight: ln });
3600
+ } else if ((r === "o" || r === "e") && l === r)
3601
+ s(r === "o" ? "u" : "i", Me), o++;
3602
+ else if (r in an) s(an[r], Me);
3603
+ else if (r in hn) s(hn[r], Ne);
3604
+ else {
3605
+ if (r === "h") continue;
3606
+ if (/[a-z]/.test(r)) s("c", Ne);
3607
+ else if (r in cn) s(cn[r], Me);
3608
+ else if (Qr(r)) {
3609
+ const i = l === un ? r === "फ" ? "f" : void 0 : Jr[r];
3610
+ s(i ?? "c", Ne);
3611
+ let a = o + 1;
3612
+ n[a] === un && a++;
3613
+ const h = n[a];
3614
+ h === Zr ? o = a : h && h in fn ? (s(fn[h], Me), o = a) : (!h || /\s/.test(h) || dn.has(h) || s("a", Me * 0.6), o = a - 1);
3615
+ } else (r === "ं" || r === "ँ") && s("l", Ne * 0.6);
3616
+ }
3617
+ }
3618
+ for (; t.length > 0 && (t[t.length - 1].viseme === "rest" || t[t.length - 1].weight === ln); ) t.pop();
3619
+ return t;
3620
+ }
3621
+ function Qn(e, t = {}) {
3622
+ const n = t.fields?.mouth ?? "mouth", s = t.fields?.mouthWidth ?? "mouthWidth", o = t.energy ?? 1, r = ei(e.text), l = [{ time: e.start, value: ce.rest.mouth }], i = [{ time: e.start, value: ce.rest.mouthWidth }], a = r.reduce((c, u) => c + u.weight, 0), h = e.end - e.start;
3623
+ if (a > 0 && h > 0) {
3624
+ let c = e.start;
3625
+ for (const u of r) {
3626
+ const g = h * u.weight / a, f = c + Math.min(g * 0.4, 60);
3627
+ if (f > l[l.length - 1].time) {
3628
+ const p = ce[u.viseme];
3629
+ l.push({ time: f, value: p.mouth * o, easing: "ease-out" }), i.push({ time: f, value: 1 + (p.mouthWidth - 1) * Math.min(1.3, o), easing: "ease-out" });
3630
+ }
3631
+ c += g;
3632
+ }
3633
+ }
3634
+ return e.end > l[l.length - 1].time && (l.push({ time: e.end, value: ce.rest.mouth, easing: "ease-in-out" }), i.push({ time: e.end, value: ce.rest.mouthWidth, easing: "ease-in-out" })), { [n]: l, [s]: i };
3635
+ }
3636
+ function zi(e, t, n = {}) {
3637
+ const s = {};
3638
+ for (const o of [...t].sort((r, l) => r.start - l.start))
3639
+ for (const [r, l] of Object.entries(Qn(o, n))) {
3640
+ const i = s[r] ??= [], a = i.length > 0 ? i[i.length - 1].time : -1 / 0;
3641
+ i.push(...l.filter((h) => h.time > a));
3642
+ }
3643
+ return Object.entries(s).map(([o, r]) => ({ id: `${e}-${o}`, target: e, property: o, keyframes: r }));
3644
+ }
3645
+ function ti(e, t, n, s = {}) {
3646
+ if (n.length === 0) return t;
3647
+ const o = s.fields?.mouth ?? "mouth", r = s.fields?.mouthWidth ?? "mouthWidth", l = { [o]: ce.rest.mouth, [r]: ce.rest.mouthWidth, ...s.rest }, i = new oo({ id: "before-speech", tracks: t }), a = (u, g) => i.getStateAtTime(g).values.get(e)?.get(u) ?? l[u], h = [o, r], c = t.filter((u) => u.target !== e || !h.includes(u.property));
3648
+ for (const u of h) {
3649
+ const g = t.find((p) => p.target === e && p.property === u);
3650
+ let f = g ? [...g.keyframes] : [{ time: 0, value: a(u, 0) }];
3651
+ for (const p of n) {
3652
+ const d = Qn(p, s)[u];
3653
+ d[0] = { ...d[0], value: a(u, p.start) }, d[d.length - 1] = { ...d[d.length - 1], value: a(u, p.end) }, f = [...f.filter((m) => m.time < p.start || m.time > p.end), ...d], f.sort((m, b) => m.time - b.time);
3654
+ }
3655
+ c.push({ id: g?.id ?? `${e}-${u}`, target: e, property: u, keyframes: f });
3656
+ }
3657
+ return c;
3658
+ }
3659
+ const ni = {
3660
+ walk: 1e3,
3661
+ bouncy: 900,
3662
+ doubleBounce: 1100,
3663
+ sneak: 1600,
3664
+ strut: 1100,
3665
+ tired: 1500,
3666
+ run: 560
3667
+ }, le = 450, gn = 1200, oi = 700, be = 320, He = 220, si = 65, ri = 700, ft = (e) => e in we, pn = (e) => e in Bt, ii = (e) => e in Oe;
3668
+ function li(e) {
3669
+ return Math.max(ri, Array.from(e).length * si);
3670
+ }
3671
+ function Vi(e, t, n = {}) {
3672
+ const s = n.from ?? 0, o = n.height ?? 300;
3673
+ let r = s, l = n.facing ?? 1, i = n.start ?? _, a = 0, h = 0;
3674
+ const c = [{ time: 0, pose: i }], u = [{ time: 0, value: 0 }], g = [{ time: 0, value: 0 }], f = [{ time: 0, value: 0 }], p = [{ time: 0, value: "walk" }], d = [{ time: 0, value: l }], m = [], b = [], y = (w, S, k, x) => {
3675
+ i = { ...i, ...S }, k && (i = qe(i, k)), c.push({ time: w, pose: i });
3676
+ }, E = (w, S, k) => (y(w + be / 2, { turn: 0 }, k), d.push({ time: w + be / 2, value: l }, { time: w + be / 2 + 1, value: S }), l = S, y(w + be, { turn: 1 }), w + be), H = (w) => w < r ? -1 : 1;
3677
+ for (const w of t) {
3678
+ const S = Math.max(w.at ?? h, h === 0 ? 0 : c[c.length - 1].time);
3679
+ let k = S;
3680
+ const x = w.pose ?? {};
3681
+ if (ft(w.do)) {
3682
+ const v = w.to ?? r, T = v === r ? l : H(v);
3683
+ let K = S;
3684
+ T !== l ? K = E(S, T, w.mood) : i.turn < 1 ? (K = S + He, y(K, { turn: 1, ...x }, w.mood)) : (w.mood || w.pose) && y(S + He, x, w.mood);
3685
+ const I = Math.abs(v - r) / Io(w.do, o), q = w.for ?? Math.max(He * 2, I * ni[w.do]), G = K + q;
3686
+ p.push({ time: K, value: w.do }), f.push({ time: K, value: 0 }, { time: K + He, value: 1, easing: "ease-out" }), f.push({ time: G - He, value: 1 }, { time: G, value: 0, easing: "ease-in" }), g.push({ time: K, value: a }, { time: G, value: a + I }), u.push({ time: K, value: r - s }, { time: G, value: v - s }), a += I, r = v, y(G, {}), k = G;
3687
+ } else if (pn(w.do)) {
3688
+ const v = qr(w.do, { at: S, from: w.mood ? qe(i, w.mood) : i });
3689
+ c.push(...v), i = v[v.length - 1].pose, k = S + Gr(w.do);
3690
+ } else if (w.do === "look" || w.do === "face") {
3691
+ const v = w.toward ?? "viewer", T = w.for ?? oi;
3692
+ if (v === "viewer") y(S + le, { turn: 0, lookX: 0, lookY: 0, ...x }, w.mood);
3693
+ else if (v === "ahead") y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3694
+ else if (v === "back") y(S + le, { turn: 0.2, lookX: -1, ...x }, w.mood);
3695
+ else {
3696
+ const K = H(v);
3697
+ K !== l && w.do === "face" ? (E(S, K, w.mood), y(S + be + 1, { lookX: 1, ...x })) : K !== l ? y(S + le, { turn: 0.25, lookX: -1, ...x }, w.mood) : y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3698
+ }
3699
+ k = S + Math.max(T, le);
3700
+ } else if (ii(w.do) || w.do === "stand") {
3701
+ const v = w.do === "stand" ? _ : Oe[w.do], T = v.turn !== _.turn ? v.turn : i.turn, K = w.mood ? Y[w.mood] : { lookX: i.lookX, lookY: i.lookY };
3702
+ y(S + le, { ...v, turn: T, ...K, ...x }), k = S + (w.for ?? gn);
3703
+ } else {
3704
+ const v = w.for ?? (w.say ? li(w.say) : gn);
3705
+ (w.mood || w.pose) && y(S + Math.min(le, v / 2), x, w.mood), k = S + v;
3706
+ }
3707
+ if (w.say) {
3708
+ const v = ft(w.do) || pn(w.do) ? S : S + Math.min(150, (k - S) / 4), T = ft(w.do) ? k : Math.max(v + 200, k - 100);
3709
+ m.push({ text: w.say, start: v, end: T }), w.do === "say" && ci(c, i, v, T);
3710
+ }
3711
+ k > c[c.length - 1].time && c.push({ time: k, pose: i }), b.push({ start: S, end: k }), h = k;
3712
+ }
3713
+ const M = Dr(e, hi(c), n), A = [
3714
+ { id: `${e}-x`, target: e, property: "x", keyframes: u },
3715
+ { id: `${e}-walk`, target: e, property: "walk", keyframes: g },
3716
+ { id: `${e}-walking`, target: e, property: "walking", keyframes: f },
3717
+ { id: `${e}-gait`, target: e, property: "gait", keyframes: p },
3718
+ { id: `${e}-facing`, target: e, property: "facing", keyframes: d }
3719
+ ].filter((w) => w.keyframes.length > 1 || w.property === "x");
3720
+ return {
3721
+ tracks: [...ti(e, M, m, { energy: n.energy }), ...A],
3722
+ duration: h,
3723
+ lines: m,
3724
+ keys: c,
3725
+ beats: b
3726
+ };
3727
+ }
3728
+ const ai = 30;
3729
+ function hi(e) {
3730
+ const t = [];
3731
+ for (const n of e) {
3732
+ const s = t[t.length - 1];
3733
+ s && n.time - s.time < ai ? t[t.length - 1] = { ...n, time: s.time } : t.push(n);
3734
+ }
3735
+ return t;
3736
+ }
3737
+ function ci(e, t, n, s) {
3738
+ const r = e.filter((a) => a.time > n), l = e.filter((a) => a.time <= n), i = [];
3739
+ for (let a = n + 520, h = 0; a < s - 520 / 2; a += 520, h++) {
3740
+ const c = h % 2 === 0 ? 3 : -2;
3741
+ i.push({ time: a, pose: { ...t, headTilt: t.headTilt + c, leftBrow: t.leftBrow + (h % 2 === 0 ? 0.25 : 0), rightBrow: t.rightBrow + (h % 2 === 0 ? 0.25 : 0) } });
3742
+ }
3743
+ i.length > 0 && i.push({ time: s, pose: t }), e.length = 0, e.push(...l, ...i.filter((a) => !r.some((h) => Math.abs(h.time - a.time) < 60)), ...r), e.sort((a, h) => a.time - h.time);
3050
3744
  }
3051
3745
  export {
3052
- ge as DANCE_STYLES,
3053
- Z as EXPRESSIONS,
3054
- xn as FINGERS,
3055
- ut as FLIPS,
3056
- _ as HAND_REST,
3057
- L as HAND_SHAPES,
3058
- is as HUMAN_EXPRESSIONS,
3059
- cr as HUMAN_POSES,
3060
- V as HUMAN_REST,
3061
- Wt as MUDRAS,
3062
- Un as POSES,
3063
- J as REST_POSE,
3064
- Wo as applyGroove,
3065
- os as bakeDanceTracks,
3066
- Hs as basicOutfit,
3067
- es as beatAt,
3068
- Se as blendPose,
3069
- mn as boilFrame,
3070
- Er as character,
3071
- gs as characterAt,
3072
- Ar as characterHandPose,
3073
- vr as characterJoints,
3074
- cs as characterJointsInView,
3075
- bs as characterObjects,
3076
- ps as characterPoseTracks,
3077
- ds as characterTarget,
3078
- ys as circlePath,
3079
- bn as clipErased,
3080
- Yt as createPen,
3081
- ct as danceFrame,
3082
- Zr as dancePose,
3083
- nt as danceStance,
3084
- Qr as danceTaps,
3085
- ns as danceTracks,
3086
- De as danceTravel,
3087
- $o as danceTravelTrack,
3088
- ts as dancer,
3089
- at as drawCartoonHand,
3090
- Pr as drawCharacter,
3091
- Wr as drawCharacterInView,
3092
- un as drawEraser,
3093
- gn as drawHand,
3094
- Rr as drawPencil,
3095
- So as drawStickFigure,
3096
- ws as drawnPathTarget,
3097
- kt as ellipsePoints,
3098
- Es as erasable,
3099
- Zo as flipPose,
3100
- rs as flipTracks,
3101
- Qo as flipTravel,
3102
- ms as handAt,
3103
- Ze as handJoints,
3104
- Rn as handJointsAt,
3105
- $ as handPose,
3106
- $e as handProp,
3107
- Gr as headPoint,
3108
- ls as humanFieldLabel,
3109
- fr as humanPlan,
3110
- j as humanPose,
3111
- Or as jointsInScene,
3112
- ko as jointsToScene,
3113
- ss as mirrorHumanPose,
3114
- Ko as mirrorPose,
3115
- ke as mixHandPoses,
3116
- fs as mixPoses,
3117
- Rt as partialPath,
3118
- xs as pathLength,
3119
- lt as pointAlong,
3120
- hs as pointOnHead,
3121
- C as pose,
3122
- jr as poseTracks,
3123
- us as reachCharacter,
3124
- en as resolveStickFrame,
3125
- Eo as resolveStickPose,
3126
- ae as rotateAbout,
3127
- ft as routineBeats,
3128
- de as rubberLimb,
3129
- ks as scrubPath,
3130
- zr as seatHeight,
3131
- an as skeletonInView,
3132
- Je as sketchPen,
3133
- gt as solvePlanSpace,
3134
- ln as stagePlanSpace,
3135
- Vr as stickFigureAt,
3136
- wo as stickFigureJoints,
3137
- Jr as stickFigureTarget,
3138
- as as stickToHuman,
3139
- Ur as strideLength,
3140
- Jn as talkingMouth,
3141
- it as taperedLine,
3142
- Ke as taperedOutline,
3143
- Gn as walkPose,
3144
- Ss as withErased,
3145
- Nt as withExpression
3746
+ ht as ACTING_STYLES,
3747
+ Se as DANCE_STYLES,
3748
+ Y as EXPRESSIONS,
3749
+ co as FINGERS,
3750
+ Pt as FLIPS,
3751
+ Bt as GAGS,
3752
+ we as GAITS,
3753
+ ni as GAIT_CYCLE_MS,
3754
+ L as HAND_REST,
3755
+ C as HAND_SHAPES,
3756
+ Cr as HUMAN_ACTING_RIG,
3757
+ Ai as HUMAN_EXPRESSIONS,
3758
+ Qs as HUMAN_POSES,
3759
+ X as HUMAN_REST,
3760
+ Zt as MUDRAS,
3761
+ Oe as POSES,
3762
+ _ as REST_POSE,
3763
+ Lr as STICK_ACTING_RIG,
3764
+ ce as VISEMES,
3765
+ Xi as actCharacterTracks,
3766
+ Jn as actKeyframes,
3767
+ Dr as actTracks,
3768
+ ks as applyGroove,
3769
+ Mi as bakeDanceTracks,
3770
+ Di as basicOutfit,
3771
+ ki as beatAt,
3772
+ Pe as blendPose,
3773
+ to as boilFrame,
3774
+ fr as character,
3775
+ _i as characterAt,
3776
+ br as characterHandPose,
3777
+ gr as characterJoints,
3778
+ Pi as characterJointsInView,
3779
+ Bi as characterObjects,
3780
+ $i as characterPoseTracks,
3781
+ Ii as characterTarget,
3782
+ Ri as circlePath,
3783
+ jn as clipErased,
3784
+ bn as createPen,
3785
+ xt as danceFrame,
3786
+ wi as dancePose,
3787
+ yt as danceStance,
3788
+ yi as danceTaps,
3789
+ Ei as danceTracks,
3790
+ ot as danceTravel,
3791
+ Hs as danceTravelTrack,
3792
+ Si as dancer,
3793
+ Tt as drawCartoonHand,
3794
+ yr as drawCharacter,
3795
+ kr as drawCharacterInView,
3796
+ Gi as drawDustPuff,
3797
+ Gn as drawEraser,
3798
+ zn as drawHand,
3799
+ Ui as drawImpactStars,
3800
+ Ar as drawPencil,
3801
+ Ur as drawSpeedLines,
3802
+ hs as drawStickFigure,
3803
+ qi as drawStickSmear,
3804
+ Li as drawnPathTarget,
3805
+ Lt as ellipsePoints,
3806
+ Ci as erasable,
3807
+ Ys as flipPose,
3808
+ Hi as flipTracks,
3809
+ Cs as flipTravel,
3810
+ qr as gag,
3811
+ Gr as gagDuration,
3812
+ Oo as gaitPose,
3813
+ Io as gaitStrideLength,
3814
+ Fi as handAt,
3815
+ pt as handJoints,
3816
+ Mo as handJointsAt,
3817
+ R as handPose,
3818
+ Ue as handProp,
3819
+ pi as headPoint,
3820
+ Ti as humanFieldLabel,
3821
+ er as humanPlan,
3822
+ ee as humanPose,
3823
+ Sr as jointsInScene,
3824
+ as as jointsToScene,
3825
+ Qn as lipSyncKeyframes,
3826
+ ti as lipSyncOver,
3827
+ zi as lipSyncTracks,
3828
+ vi as mirrorHumanPose,
3829
+ ws as mirrorPose,
3830
+ Ke as mixHandPoses,
3831
+ Wi as mixPoses,
3832
+ mn as partialPath,
3833
+ Zi as pathLength,
3834
+ Ht as pointAlong,
3835
+ Ki as pointOnHead,
3836
+ z as pose,
3837
+ bi as poseTracks,
3838
+ Oi as reachCharacter,
3839
+ Or as resolveActingStyle,
3840
+ qn as resolveCharacterPoseKeys,
3841
+ wn as resolveGait,
3842
+ _n as resolvePoseKeys,
3843
+ On as resolveStickFrame,
3844
+ cs as resolveStickPose,
3845
+ de as rotateAbout,
3846
+ Kt as routineBeats,
3847
+ ke as rubberLimb,
3848
+ Vi as scriptTracks,
3849
+ Ni as scrubPath,
3850
+ gi as seatHeight,
3851
+ Yn as skeletonInView,
3852
+ ut as sketchPen,
3853
+ Ot as solvePlanSpace,
3854
+ ei as soundsOf,
3855
+ li as speechDuration,
3856
+ Nn as stagePlanSpace,
3857
+ ds as stickFigureAt,
3858
+ ls as stickFigureJoints,
3859
+ mi as stickFigureTarget,
3860
+ xi as stickToHuman,
3861
+ Bo as strideLength,
3862
+ Fo as talkingMouth,
3863
+ vt as taperedLine,
3864
+ Ye as taperedOutline,
3865
+ $o as walkPose,
3866
+ Yi as withErased,
3867
+ qe as withExpression
3146
3868
  };