@algorisys/tinyfly 0.82.0 → 0.87.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.
Files changed (71) hide show
  1. package/README.md +13 -4
  2. package/bin/tinyfly.mjs +44 -6
  3. package/lib/addons/adapters.js +411 -248
  4. package/lib/addons/characters.js +1652 -1470
  5. package/lib/addons/dom-adapter-Cphr2HZn.js +372 -0
  6. package/lib/addons/gsap-compat.js +197 -187
  7. package/lib/addons/load-scene-vp14_Jj-.js +324 -0
  8. package/lib/addons/maps.js +1 -1
  9. package/lib/addons/scene-3d-webgl.js +240 -0
  10. package/lib/addons/scene-3d.js +306 -0
  11. package/lib/addons/shading-o5T_v9DT.js +89 -0
  12. package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
  13. package/lib/browser/tinyfly-scene-3d-webgl.iife.js +116 -0
  14. package/lib/browser/tinyfly-scene-3d.iife.js +3 -0
  15. package/lib/browser/tinyfly.iife.js +4 -4
  16. package/lib/browser/tinyfly.js +4333 -3726
  17. package/lib/browser/tinyfly.umd.js +4 -4
  18. package/lib/cli/tools.js +137 -22
  19. package/lib/embed/tinyfly-embed.iife.js +4 -4
  20. package/lib/embed/tinyfly-embed.js +921 -833
  21. package/lib/engine/tinyfly-engine.js +1022 -776
  22. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  23. package/lib/headless/headless.js +410 -8
  24. package/lib/player/tinyfly-player.es.js +459 -371
  25. package/lib/player/tinyfly-player.iife.js +2 -2
  26. package/lib/player/tinyfly-player.umd.js +2 -2
  27. package/lib/types/adapters/canvas/bloom.d.ts +33 -0
  28. package/lib/types/adapters/canvas/canvas-adapter.d.ts +36 -0
  29. package/lib/types/adapters/canvas/index.d.ts +2 -0
  30. package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
  31. package/lib/types/adapters/transform-3d.d.ts +99 -0
  32. package/lib/types/adapters/webgl/webgl-adapter.d.ts +17 -0
  33. package/lib/types/browser/index.d.ts +2 -0
  34. package/lib/types/characters/character.d.ts +20 -1
  35. package/lib/types/characters/index.d.ts +2 -0
  36. package/lib/types/characters/rig/body-plan.d.ts +3 -1
  37. package/lib/types/characters/rig/skeleton.d.ts +57 -0
  38. package/lib/types/characters/scene-objects.d.ts +2 -0
  39. package/lib/types/compat/gsap/vars.d.ts +8 -0
  40. package/lib/types/engine/core/bake.d.ts +3 -1
  41. package/lib/types/engine/index.d.ts +1 -0
  42. package/lib/types/engine/interpolation/interpolators.d.ts +10 -3
  43. package/lib/types/engine/math/index.d.ts +11 -0
  44. package/lib/types/engine/math/mat4.d.ts +37 -0
  45. package/lib/types/engine/math/quat.d.ts +39 -0
  46. package/lib/types/engine/math/vec3.d.ts +16 -0
  47. package/lib/types/engine/types.d.ts +23 -2
  48. package/lib/types/headless/index.d.ts +1 -0
  49. package/lib/types/headless/loop-check.d.ts +41 -0
  50. package/lib/types/headless/node-video.d.ts +8 -0
  51. package/lib/types/headless/video-scene.d.ts +7 -1
  52. package/lib/types/scene-3d/camera.d.ts +27 -0
  53. package/lib/types/scene-3d/canvas-2d-renderer.d.ts +21 -0
  54. package/lib/types/scene-3d/geometry/extrude.d.ts +17 -0
  55. package/lib/types/scene-3d/geometry/mesh.d.ts +36 -0
  56. package/lib/types/scene-3d/geometry/primitives.d.ts +16 -0
  57. package/lib/types/scene-3d/geometry/triangulate.d.ts +24 -0
  58. package/lib/types/scene-3d/index.d.ts +20 -0
  59. package/lib/types/scene-3d/load-scene.d.ts +31 -0
  60. package/lib/types/scene-3d/object-kind.d.ts +54 -0
  61. package/lib/types/scene-3d/resolve-scene.d.ts +122 -0
  62. package/lib/types/scene-3d/scene-3d-adapter.d.ts +46 -0
  63. package/lib/types/scene-3d/scene-types.d.ts +192 -0
  64. package/lib/types/scene-3d/shading.d.ts +20 -0
  65. package/lib/types/scene-3d/validate-scene.d.ts +11 -0
  66. package/lib/types/scene-3d/webgl/gl-data.d.ts +29 -0
  67. package/lib/types/scene-3d/webgl/index.d.ts +16 -0
  68. package/lib/types/scene-3d/webgl/shaders.d.ts +29 -0
  69. package/lib/types/scene-3d/webgl/webgl2-renderer.d.ts +33 -0
  70. package/package.json +10 -2
  71. package/lib/addons/dom-adapter-CrNwoomd.js +0 -243
@@ -1,70 +1,71 @@
1
- import { b as fn, s as Ge, p as It, c as rt } from "./sketch-CA8ZXhxI.js";
2
- import { a as al } from "./sketch-CA8ZXhxI.js";
3
- import { createRandom as cn, hashSeed as gn, getEasingFunction as _e } from "@algorisys/tinyfly";
4
- function Te(e, t, n) {
5
- const o = e.length;
6
- if (o < 2) return [];
7
- const r = [], l = [], i = (s) => t + (n - t) * s / (o - 1);
8
- return e.forEach((s, a) => {
9
- const h = e[Math.max(0, a - 1)], f = e[Math.min(o - 1, a + 1)], g = Math.hypot(f.x - h.x, f.y - h.y) || 1, p = i(a) / 2, c = -(f.y - h.y) / g * p, u = (f.x - h.x) / g * p;
10
- r.push({ x: s.x + c, y: s.y + u }), l.push({ x: s.x - c, y: s.y - u });
11
- }), [...r, ...l.reverse()];
12
- }
13
- function lt(e, t, n, o) {
14
- const r = t.length;
15
- if (r < 2) return;
16
- const l = Te(t, n, o), i = (s) => n + (o - n) * s / (r - 1);
17
- e.beginPath(), e.moveTo(l[0].x, l[0].y);
18
- for (const s of l.slice(1)) e.lineTo(s.x, s.y);
19
- e.closePath(), e.fill(), t.forEach((s, a) => {
20
- a !== 0 && a !== r - 1 && r > 3 || (e.beginPath(), e.arc(s.x, s.y, i(a) / 2, 0, Math.PI * 2), e.fill());
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-vp14_Jj-.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) {
15
+ const o = t.length;
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());
21
22
  });
22
23
  }
23
- function fe(e, t, n, o, r = 16) {
24
- const l = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, i = [];
25
- for (let s = 0; s <= r; s++) {
26
- const a = s / r, 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) }, f = 1 - a, g = {
27
- x: f * f * e.x + 2 * f * a * l.x + a * a * n.x,
28
- y: f * f * e.y + 2 * f * a * l.y + a * a * n.y
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
29
30
  };
30
- i.push({ x: h.x + (g.x - h.x) * o, y: h.y + (g.y - h.y) * o });
31
+ i.push({ x: h.x + (p.x - h.x) * r, y: h.y + (p.y - h.y) * r });
31
32
  }
32
33
  return i;
33
34
  }
34
- function dt(e, t, n, o, r, l = 0, i = 1, s = 40) {
35
- const a = Math.cos(r), h = Math.sin(r);
36
- return Array.from({ length: s + 1 }, (f, g) => {
37
- const p = l + Math.PI * 2 * i * g / s, c = Math.cos(p) * n, u = Math.sin(p) * o;
38
- return { x: e + c * a - u * h, y: t + c * h + u * a };
35
+ function kt(e, t, n, r, o, s = 0, i = 1, l = 40) {
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 };
39
40
  });
40
41
  }
41
- function $t(e, t) {
42
- return t.look === "pencil" ? bn(e, t) : un(e, t.ink, t.look);
42
+ function Yt(e, t) {
43
+ return t.look === "pencil" ? vn(e, t) : En(e, t.ink, t.look);
43
44
  }
44
- function Ke(e, t, n = !1) {
45
+ function Oe(e, t, n = !1) {
45
46
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
46
- for (const o of t.slice(1)) e.lineTo(o.x, o.y);
47
+ for (const r of t.slice(1)) e.lineTo(r.x, r.y);
47
48
  n && e.closePath();
48
49
  }
49
- function un(e, t, n) {
50
- const o = n === "silhouette", r = o ? 1.25 : 1;
50
+ function En(e, t, n) {
51
+ const r = n === "silhouette", o = r ? 1.25 : 1;
51
52
  return {
52
53
  look: n,
53
54
  ink: t,
54
- limb(l, i, s) {
55
- e.fillStyle = t, lt(e, l, i * r, s * r);
55
+ limb(s, i, l) {
56
+ e.fillStyle = t, it(e, s, i * o, l * o);
56
57
  },
57
- line(l, i) {
58
- l.length < 2 || (e.strokeStyle = t, e.lineWidth = i * r, e.lineCap = "round", e.lineJoin = "round", Ke(e, l), e.stroke());
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());
59
60
  },
60
- shape(l, i, s) {
61
- Ke(e, l, !0), (i !== null || o) && (e.fillStyle = o ? t : i, e.fill()), !(s <= 0) && (e.strokeStyle = t, e.lineWidth = s * r, e.lineJoin = "round", e.stroke());
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());
62
63
  },
63
- ellipse(l, i, s, a, h, f, g) {
64
- e.beginPath(), e.ellipse(l, i, s, a, h, 0, Math.PI * 2), (f !== null || o) && (e.fillStyle = o ? t : f, e.fill()), !(g <= 0) && (e.strokeStyle = t, e.lineWidth = g * r, e.stroke());
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());
65
66
  },
66
- dot(l, i, s) {
67
- e.fillStyle = t, e.beginPath(), e.arc(l, i, s * r, 0, Math.PI * 2), e.fill();
67
+ dot(s, i, l) {
68
+ e.fillStyle = t, e.beginPath(), e.arc(s, i, l * o, 0, Math.PI * 2), e.fill();
68
69
  },
69
70
  guide() {
70
71
  },
@@ -72,101 +73,101 @@ function un(e, t, n) {
72
73
  }
73
74
  };
74
75
  }
75
- function dn(e, t) {
76
+ function Hn(e, t) {
76
77
  const n = [e[0]];
77
- let o = 0;
78
+ let r = 0;
78
79
  for (let i = 1; i < e.length; i++) {
79
- const s = e[i - 1], a = e[i], h = Math.hypot(a.x - s.x, a.y - s.y);
80
- let f = t - o;
81
- for (; f < h; ) {
82
- const g = f / h;
83
- n.push({ x: s.x + (a.x - s.x) * g, y: s.y + (a.y - s.y) * g }), f += t;
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;
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;
84
85
  }
85
- o = h - (f - t);
86
+ r = h - (c - t);
86
87
  }
87
- const r = e[e.length - 1], l = n[n.length - 1];
88
- return Math.hypot(r.x - l.x, r.y - l.y) > t * 0.25 ? n.push(r) : n[n.length - 1] = r, n;
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;
89
90
  }
90
- function pn(e, t) {
91
+ function Mn(e, t) {
91
92
  const n = e.length;
92
- return e.map((o, r) => {
93
- const l = e[Math.max(0, r - 1)], i = e[Math.min(n - 1, r + 1)], s = Math.hypot(i.x - l.x, i.y - l.y) || 1, a = t(n === 1 ? 0 : r / (n - 1));
94
- return { x: o.x - (i.y - l.y) / s * a, y: o.y + (i.x - l.x) / s * a };
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 };
95
96
  });
96
97
  }
97
- function pt(e) {
98
- const t = [0.6, 1.4, 2.9].map((o) => ({
99
- frequency: o * (0.8 + e.next() * 0.4),
98
+ function St(e) {
99
+ const t = [0.6, 1.4, 2.9].map((r) => ({
100
+ frequency: r * (0.8 + e.next() * 0.4),
100
101
  phase: e.next() * Math.PI * 2,
101
102
  amount: 0.5 + e.next() * 0.5
102
- })), n = t.reduce((o, r) => o + r.amount, 0);
103
- return (o) => t.reduce((r, l) => r + l.amount * Math.sin(Math.PI * 2 * l.frequency * o + l.phase), 0) / n;
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;
104
105
  }
105
- function bn(e, t) {
106
- const n = t.pencil ?? {}, o = t.ink, r = n.roughness ?? Math.max(1, t.lineWidth * 0.12), l = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), s = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = fn(t.time, n.boil ?? 8);
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);
107
108
  let h = 0;
108
- const f = (u, d, b = !1) => cn(gn(`${t.seed}:${b ? "paper" : a}:${u}:${d}`)), g = (u, d, b, m, w, S = 0) => {
109
- if (u.length < 2) return;
110
- const M = u.slice(1).reduce((W, v, y) => W + Math.hypot(v.x - u[y].x, v.y - u[y].y), 0);
111
- let H = dn(u, Math.max(1.5, Math.min(t.lineWidth * 0.8, M / 24)));
112
- if (S > 0 && H.length >= 2) {
113
- const [W, v] = [H[H.length - 2], H[H.length - 1]], y = Math.hypot(v.x - W.x, v.y - W.y) || 1;
114
- H = [...H, { x: v.x + (v.x - W.x) / y * S, y: v.y + (v.y - W.y) / y * S }];
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 }];
115
116
  }
116
- const k = pt(b), E = pt(b), T = H.length, A = [], I = [];
117
- H.forEach((W, v) => {
118
- const y = T === 1 ? 0 : v / (T - 1), x = H[Math.max(0, v - 1)], O = H[Math.min(T - 1, v + 1)], K = Math.hypot(O.x - x.x, O.y - x.y) || 1, P = -(O.y - x.y) / K, B = (O.x - x.x) / K, $ = k(y) * w, _ = Math.min(1, y / 0.08, (1 - y) / 0.08), C = (0.55 + 0.45 * Math.sqrt(Math.max(0, _))) * (1 + i * E(y)), L = Math.max(0.3, d(y) * C / 2), Q = W.x + P * $, ne = W.y + B * $;
119
- A.push({ x: Q + P * L, y: ne + B * L }), I.push({ x: Q - P * L, y: ne - B * L });
120
- }), e.save(), e.globalAlpha *= m, e.fillStyle = o, Ke(e, [...A, ...I.reverse()], !0), e.fill(), e.restore();
121
- }, p = (u, d) => {
122
- const b = h++, m = f(b, 99, !0);
123
- if (m.next() < s) {
124
- const H = (m.next() * 2 - 1) * t.lineWidth * 1.4, k = (m.next() * 2 - 1) * t.lineWidth * 1.4, E = u.map((T) => ({ x: T.x + H, y: T.y + k }));
125
- g(E, (T) => d(T) * 1.8, f(b, 98, !0), 0.035, r), g(E, (T) => d(T) * 0.45, f(b, 97, !0), 0.12, r * 1.5);
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);
126
127
  }
127
- const w = u.slice(1).reduce((H, k, E) => H + Math.hypot(k.x - u[E].x, k.y - u[E].y), 0), S = d(0.5) > 4 && w > d(0.5) * 6, M = S ? [-0.3, 0.3, 0] : [0];
128
- for (let H = 0; H < l; H++) {
129
- const k = H === 0;
130
- M.forEach((E, T) => {
131
- const A = f(b, H * 10 + T), I = E === 0 ? u : pn(u, (v) => d(v) * E * Math.sqrt(Math.sin(Math.PI * v))), W = !k && E === 0 ? t.lineWidth * (0.3 + A.next() * 0.8) : 0;
132
- g(I, (v) => d(v) * (S ? 0.5 : 1) * (k ? 1 : 0.6), A, k ? 0.85 : 0.45, r * (k ? 0.6 : 1), W);
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);
133
134
  });
134
135
  }
135
- }, c = (u, d, b, m, w, S) => {
136
- const H = f(h, 50).next() * Math.PI * 2;
137
- p(dt(u, d, b, m, w, H, 1.08, 48), () => S);
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);
138
139
  };
139
140
  return {
140
141
  look: "pencil",
141
- ink: o,
142
- limb(u, d, b) {
143
- p(u, (m) => d + (b - d) * m);
142
+ ink: r,
143
+ limb(b, f, g) {
144
+ d(b, (m) => f + (g - f) * m);
144
145
  },
145
- line(u, d) {
146
- p(u, () => d);
146
+ line(b, f) {
147
+ d(b, () => f);
147
148
  },
148
- shape(u, d, b) {
149
- d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Ke(e, u, !0), e.fill(), e.restore()), b > 0 && p([...u, u[0]], () => b);
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);
150
151
  },
151
- ellipse(u, d, b, m, w, S, M) {
152
- S !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = S, e.beginPath(), e.ellipse(u, d, b, m, w, 0, Math.PI * 2), e.fill(), e.restore()), c(u, d, b, m, w, M);
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);
153
154
  },
154
- dot(u, d, b) {
155
- e.save(), e.globalAlpha *= 0.9, e.fillStyle = o, e.beginPath(), e.arc(u, d, b, 0, Math.PI * 2), e.fill(), e.restore();
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();
156
157
  },
157
- guide(u) {
158
- if (n.construction === !1 || u.length < 2) return;
159
- const d = h++;
160
- g(u, () => Math.max(0.6, t.lineWidth * 0.18), f(d, 0), 0.28, r * 1.2, t.lineWidth);
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);
161
162
  },
162
- guideEllipse(u, d, b, m, w) {
163
+ guideEllipse(b, f, g, m, k) {
163
164
  if (n.construction === !1) return;
164
- const S = h++, M = f(S, 0), H = dt(u, d, b, m, w, M.next() * Math.PI * 2, 1.12, 48);
165
- g(H, () => Math.max(0.6, t.lineWidth * 0.18), M, 0.28, r * 1.5);
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);
166
167
  }
167
168
  };
168
169
  }
169
- const mn = ["thumb", "index", "middle", "ring", "pinky"], R = {
170
+ const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
170
171
  "thumb.curl": 0.15,
171
172
  "thumb.across": 0.15,
172
173
  "index.curl": 0.12,
@@ -179,59 +180,59 @@ const mn = ["thumb", "index", "middle", "ring", "pinky"], R = {
179
180
  tilt: 0,
180
181
  roll: 0
181
182
  };
182
- function F(e = {}) {
183
- return { ...R, ...e };
183
+ function $(e = {}) {
184
+ return { ..._, ...e };
184
185
  }
185
- const q = (e, t, n, o, r) => ({
186
+ const q = (e, t, n, r, o) => ({
186
187
  "thumb.curl": e,
187
188
  "index.curl": t,
188
189
  "middle.curl": n,
189
- "ring.curl": o,
190
- "pinky.curl": r
191
- }), N = {
192
- relaxed: R,
193
- open: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
194
- spread: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
195
- flat: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
196
- fist: F({ ...q(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
197
- point: F({ ...q(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
190
+ "ring.curl": r,
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 }),
198
199
  /** The fist on its side, knuckles toward the viewer, the thumb up */
199
- thumbsUp: F({ ...q(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
200
- peace: F({ ...q(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
201
- ok: F({ ...q(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
202
- pinch: F({ ...q(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
203
- cupped: F({ ...q(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
204
- wave: F({ ...q(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
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 }),
205
206
  /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
206
- pencilGrip: F({ ...q(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
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
208
  /** Holding a handle, a cup or a bar: every finger wrapped round it */
208
- hold: F({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
+ hold: $({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
210
  };
210
- function ye(e, t, n) {
211
- const o = { ...e };
212
- for (const [r, l] of Object.entries(t)) {
213
- const i = e[r] ?? l;
214
- o[r] = i + (l - i) * n;
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;
215
216
  }
216
- return o;
217
+ return r;
217
218
  }
218
- const yn = {
219
+ const Tn = {
219
220
  index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
220
221
  middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
221
222
  ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
222
223
  pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
223
- }, wn = {
224
+ }, An = {
224
225
  index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
225
226
  middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
226
227
  pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
227
- }, V = {
228
+ }, ne = {
228
229
  base: [-0.11, 0.1, -0.05],
229
230
  bones: [0.2, 0.15, 0.12],
230
231
  widths: [0.2, 0.145, 0.135],
231
232
  /** Where the thumb points with `across` 0 and 1 */
232
233
  out: [-0.7, 0.68, -0.22],
233
234
  across: [0.35, 0.5, -0.8]
234
- }, kn = [82, 100, 62], Sn = [48, 72], En = 3, Hn = 13, Mn = 0.035, vn = -0.075, Tn = [
235
+ }, Kn = [82, 100, 62], Pn = [48, 72], Wn = 3, On = 13, In = 0.035, Bn = -0.075, $n = [
235
236
  [-0.17, 0],
236
237
  [-0.215, 0.12],
237
238
  [-0.235, 0.26],
@@ -244,185 +245,185 @@ const yn = {
244
245
  [0.225, 0.26],
245
246
  [0.2, 0.1],
246
247
  [0.16, 0]
247
- ], le = (e) => e * Math.PI / 180, Je = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], xe = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Ze = (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]], ge = (e) => {
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
249
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
249
250
  return [e[0] / t, e[1] / t, e[2] / t];
250
251
  };
251
- function ie(e, t, n) {
252
- const o = Math.cos(n), r = Math.sin(n), l = Ze(t, e), i = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
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];
253
254
  return [
254
- e[0] * o + l[0] * r + t[0] * i * (1 - o),
255
- e[1] * o + l[1] * r + t[1] * i * (1 - o),
256
- e[2] * o + l[2] * r + t[2] * i * (1 - o)
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)
257
258
  ];
258
259
  }
259
- const bt = [1, 0, 0], mt = [0, 1, 0], pe = [0, 0, 1];
260
- function xn(e, t, n) {
261
- const o = le(e.fan * (En + Hn * n)), r = [Math.sin(o), Math.cos(o), 0], l = [Math.cos(o), -Math.sin(o), 0], i = [e.knuckle];
262
- let s = 0;
263
- e.bones.forEach((f, g) => {
264
- s += le(kn[g] * t), i.push(Je(i[g], xe(ie(r, l, -s), f)));
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)));
265
266
  });
266
- const a = ie(pe, l, -s), h = i.map((f, g) => e.width * (1 - 0.14 * (g / (i.length - 1))));
267
+ const a = ae(ye, s, -l), h = i.map((c, p) => e.width * (1 - 0.14 * (p / (i.length - 1))));
267
268
  return { joints: i, back: a, widths: h };
268
269
  }
269
- function An(e, t, n = 1, o = 1) {
270
- const r = Math.min(1, Math.max(0, t)), l = ge(Je(xe(ge(V.out), 1 - r), xe(ge(V.across), r))), i = ge(Ze(pe, l)), s = ge(Ze(l, i)), a = [[V.base[0] * o, V.base[1], V.base[2]]];
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]]];
271
272
  let h = 0;
272
- V.bones.forEach((p, c) => {
273
- c > 0 && (h += le(Sn[c - 1] * e)), a.push(Je(a[c], xe(ie(l, i, h), p)));
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)));
274
275
  });
275
- const f = ie(s, i, h), g = [...V.widths, V.widths[V.widths.length - 1] * 0.92].map((p) => p * n);
276
- return { joints: a, back: f, widths: g };
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 };
277
278
  }
278
- function je(e, t = {}) {
279
- const n = { ...R, ...e }, o = t.size ?? 100, r = t.side ?? "right", l = r === "left" ? -1 : 1, i = le(t.angle ?? 0), s = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, f = (v) => ({
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) => ({
280
281
  ...v,
281
282
  knuckle: [v.knuckle[0] * h, v.knuckle[1], v.knuckle[2]],
282
283
  width: v.width * a
283
- }), g = le(n.bend ?? 0), p = le(n.tilt ?? 0), c = le(90 * (n.turn ?? 0)), u = (v) => ie(ie(ie(v, bt, -g), pe, -p), mt, c), d = Math.cos(i), b = Math.sin(i), m = le(n.roll ?? 0), w = Math.cos(m), S = Math.sin(m), M = (v) => {
284
- const y = v[0] * o, x = -v[1] * o, O = (y * w - x * S) * l, K = y * S + x * w;
285
- return { x: O * d - K * b, y: O * b + K * d };
286
- }, H = (v) => {
287
- const y = M(v), x = Math.hypot(y.x, y.y);
288
- return x > 1e-6 * o ? { x: y.x / x, y: y.y / x } : { x: 0, y: 0 };
289
- }, k = {
290
- thumb: An(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
291
- }, E = s ? wn : yn;
292
- for (const v of mn) {
293
- const y = E[v];
294
- y && (k[v] = xn(f(y), n[`${v}.curl`] ?? 0, n.spread ?? 0));
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));
295
296
  }
296
- const T = {};
297
- for (const [v, y] of Object.entries(k)) {
298
- const x = y.joints.map(u), O = u(y.back);
299
- T[v] = {
300
- points: x.map(M),
301
- depths: x.map((K) => K[2] * o),
302
- widths: y.widths.map((K) => K * o),
303
- nail: O[2],
304
- back: H(O)
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)
305
306
  };
306
307
  }
307
- const A = Tn.flatMap(([v, y]) => [u([v * h, y, Mn]), u([v * h, y, vn])]), I = Pn(A.map(M)), W = A.reduce((v, y) => v + y[2], 0) / A.length * o;
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
309
  return {
309
- size: o,
310
- side: r,
310
+ size: r,
311
+ side: o,
311
312
  wrist: { x: 0, y: 0 },
312
- palm: I,
313
- palmDepth: W,
314
- palmFacing: -u(pe)[2],
315
- fingers: T,
316
- axes: { up: H(u(mt)), across: H(u(bt)), out: H(u(pe)) },
317
- curls: Object.fromEntries(Object.keys(T).map((v) => [v, n[`${v}.curl`] ?? 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]))
318
319
  };
319
320
  }
320
- function Kn(e, t) {
321
- const n = (r) => ({ x: r.x + t.x - e.wrist.x, y: r.y + t.y - e.wrist.y }), o = {};
322
- for (const [r, l] of Object.entries(e.fingers))
323
- o[r] = { ...l, points: l.points.map(n) };
324
- return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: o };
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 };
325
326
  }
326
- function Pn(e) {
327
- const t = [...e].sort((l, i) => l.x - i.x || l.y - i.y);
327
+ function Yn(e) {
328
+ const t = [...e].sort((s, i) => s.x - i.x || s.y - i.y);
328
329
  if (t.length < 3) return t;
329
- const n = (l, i, s) => (i.x - l.x) * (s.y - l.y) - (i.y - l.y) * (s.x - l.x), o = [];
330
- for (const l of t) {
331
- for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], l) <= 0; ) o.pop();
332
- o.push(l);
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);
333
334
  }
334
- const r = [];
335
- for (const l of [...t].reverse()) {
336
- for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], l) <= 0; ) r.pop();
337
- r.push(l);
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);
338
339
  }
339
- return [...o.slice(0, -1), ...r.slice(0, -1)];
340
+ return [...r.slice(0, -1), ...o.slice(0, -1)];
340
341
  }
341
- const Wn = "#f1c9a5", On = "#2f2f33";
342
- function st(e, t, n, o = {}, r = 0) {
343
- const l = Kn(je(n, o), t), i = o.ink ?? On, s = o.lineWidth ?? l.size * 0.035, a = o.pen ?? $t(e, {
344
- look: o.look ?? "clean",
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",
345
346
  ink: i,
346
- lineWidth: s,
347
- seed: o.seed ?? 1,
348
- time: r,
349
- pencil: { construction: !1, ...o.pencil }
350
- }), h = o.skin ?? Wn, f = o.nails ?? !0, g = [
347
+ lineWidth: l,
348
+ seed: r.seed ?? 1,
349
+ time: o,
350
+ pencil: { construction: !1, ...r.pencil }
351
+ }), h = r.skin ?? Ln, c = r.nails ?? !0, p = [
351
352
  {
352
- depth: l.palmDepth,
353
- draw: () => In(a, l, h, s)
353
+ depth: s.palmDepth,
354
+ draw: () => Cn(a, s, h, l)
354
355
  }
355
356
  ];
356
- for (const p of Object.values(l.fingers)) {
357
- const c = p.depths.reduce((u, d) => u + d, 0) / p.depths.length;
358
- g.push({
359
- depth: c,
360
- draw: () => $n(e, a, p, h, s, f)
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)
361
362
  });
362
363
  }
363
- if (o.prop) {
364
- const p = o.prop;
365
- g.push({ depth: p.depth, draw: () => p.draw(a) });
364
+ if (r.prop) {
365
+ const d = r.prop;
366
+ p.push({ depth: d.depth, draw: () => d.draw(a) });
366
367
  }
367
368
  e.save(), e.lineCap = "round", e.lineJoin = "round";
368
- for (const p of [...g].sort((c, u) => c.depth - u.depth)) p.draw();
369
- return e.restore(), l;
370
- }
371
- function In(e, t, n, o) {
372
- if (e.shape(t.palm, n, o), t.palmFacing < -0.3 && e.look !== "silhouette") {
373
- const { up: r } = t.axes;
374
- for (const [l, i] of Object.entries(t.fingers)) {
375
- const s = t.curls[l] ?? 0;
376
- if (l === "thumb" || s < 0.5) continue;
377
- const a = i.points[0], h = i.widths[0] * 0.42, f = { x: a.x - r.x * h * 0.2, y: a.y - r.y * h * 0.2 }, g = Math.atan2(r.y, r.x), p = Array.from({ length: 7 }, (c, u) => {
378
- const d = g - Math.PI / 2 + Math.PI * u / 6;
379
- return { x: f.x + Math.cos(d) * h, y: f.y + Math.sin(d) * h };
369
+ for (const d of [...p].sort((u, b) => u.depth - b.depth)) d.draw();
370
+ return e.restore(), s;
371
+ }
372
+ function Cn(e, t, n, r) {
373
+ if (e.shape(t.palm, n, r), t.palmFacing < -0.3 && e.look !== "silhouette") {
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 };
380
381
  });
381
- e.line(p, o * 0.6);
382
+ e.line(d, r * 0.6);
382
383
  }
383
384
  }
384
385
  if (t.palmFacing > 0.45 && e.look !== "silhouette") {
385
- const { up: r, across: l } = t.axes, i = t.size, s = t.wrist, a = (f, g) => ({
386
- x: s.x + (l.x * f + r.x * g) * i,
387
- y: s.y + (l.y * f + r.y * g) * i
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
388
389
  }), h = t.side === "left" ? -1 : 1;
389
- e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], o * 0.5);
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
391
  }
391
392
  }
392
- function $n(e, t, n, o, r, l) {
393
- const { widths: i } = n, s = Bn(n.points, 2), a = n.points[0], h = s[s.length - 1], f = i[0], g = i[i.length - 1];
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];
394
395
  if (e.save(), t.look !== "silhouette") {
395
396
  e.beginPath(), e.rect(a.x - 1e5, a.y - 1e5, 2e5, 2e5);
396
- const d = f / 2 + r * 1.6;
397
- e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
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");
398
399
  }
399
- if (t.limb(s, f + 2 * r, g + 2 * r), e.restore(), t.look !== "silhouette" && (e.fillStyle = o, lt(e, s, f, g)), t.look === "silhouette" || !l || n.nail < 0.25) return;
400
- const p = s[s.length - 2], c = _n({ x: h.x - p.x, y: h.y - p.y }) ?? {
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 }) ?? {
401
402
  x: 0,
402
403
  y: -1
403
- }, u = {
404
- x: h.x - c.x * g * 0.22 + n.back.x * g * 0.1,
405
- y: h.y - c.y * g * 0.22 + n.back.y * g * 0.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
406
407
  };
407
- t.ellipse(u.x, u.y, g * 0.24 * Math.max(0.35, n.nail), g * 0.19, Math.atan2(c.y, c.x), "#f8e3d3", r * 0.45);
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
409
  }
409
- function Bn(e, t) {
410
+ function Xn(e, t) {
410
411
  let n = e;
411
- for (let o = 0; o < t; o++) {
412
+ for (let r = 0; r < t; r++) {
412
413
  if (n.length < 3) return n;
413
- const r = [n[0]];
414
- for (let l = 0; l < n.length - 1; l++) {
415
- const i = n[l], s = n[l + 1];
416
- l > 0 && r.push({ x: i.x * 0.75 + s.x * 0.25, y: i.y * 0.75 + s.y * 0.25 }), l < n.length - 2 && r.push({ x: i.x * 0.25 + s.x * 0.75, y: i.y * 0.25 + s.y * 0.75 });
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 });
417
418
  }
418
- r.push(n[n.length - 1]), n = r;
419
+ o.push(n[n.length - 1]), n = o;
419
420
  }
420
421
  return n;
421
422
  }
422
- const _n = (e) => {
423
+ const qn = (e) => {
423
424
  const t = Math.hypot(e.x, e.y);
424
425
  return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
425
- }, z = {
426
+ }, J = {
426
427
  lean: 0,
427
428
  headTilt: 0,
428
429
  leftShoulder: 18,
@@ -456,10 +457,10 @@ const _n = (e) => {
456
457
  spin: 0,
457
458
  rise: 0
458
459
  };
459
- function D(e) {
460
- return { ...z, ...e };
460
+ function C(e) {
461
+ return { ...J, ...e };
461
462
  }
462
- const Bt = {
463
+ const Lt = {
463
464
  mouth: 0,
464
465
  smile: 0,
465
466
  mouthWidth: 1,
@@ -470,200 +471,200 @@ const Bt = {
470
471
  browTilt: 0,
471
472
  lookX: 0,
472
473
  lookY: 0
473
- }, Y = (e) => ({ ...Bt, ...e }), J = {
474
- neutral: Bt,
475
- happy: Y({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
476
- joyful: Y({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
477
- sad: Y({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
478
- crying: Y({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
479
- surprised: Y({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
480
- shocked: Y({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
481
- angry: Y({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
482
- furious: Y({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
483
- worried: Y({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
484
- scared: Y({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
485
- confused: Y({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
486
- skeptical: Y({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
487
- thinking: Y({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
488
- sleepy: Y({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
489
- disgusted: Y({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
490
- smug: Y({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
491
- wink: Y({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
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 })
492
493
  };
493
- function _t(e, t) {
494
- return { ...e, ...typeof t == "string" ? J[t] : t };
495
- }
496
- const Fn = {
497
- rest: z,
498
- wave: D({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...J.happy }),
499
- cheer: D({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...J.joyful }),
500
- shrug: D({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...J.confused, lookX: 0, lookY: 0 }),
501
- point: D({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
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 }),
502
503
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
503
- think: D({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...J.thinking }),
504
- handsOnHips: D({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
505
- sad: D({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...J.sad }),
506
- surprised: D({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...J.surprised }),
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 }),
507
508
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
508
- crouch: D({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
509
+ crouch: C({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
509
510
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
510
511
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
511
- sit: D({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
512
- jump: D({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...J.joyful }),
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 }),
513
514
  // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
514
515
  // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
515
- sideSplit: D({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...J.happy }),
516
+ sideSplit: C({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Z.happy }),
516
517
  // Front split, in profile: the left leg forward (+x), the right leg back.
517
- frontSplit: D({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...J.happy })
518
- }, Ft = Object.keys(z);
519
- function we(e, t, n) {
520
- const o = { ...e };
521
- for (const r of Ft) o[r] = e[r] + (t[r] - e[r]) * n;
522
- return o;
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;
523
524
  }
524
- const Qe = 24, yt = 4, wt = 28, Rn = 40;
525
- function Yn(e, t = z, n = 1) {
526
- const o = Math.sin(e * Math.PI * 2) * n, r = Math.cos(e * Math.PI * 2) * n, l = (h) => h <= Rn, i = (h) => l(h) ? 22 * o : h, s = l(t.leftShoulder) ? t.leftElbow - wt * Math.max(0, -o) : t.leftElbow, a = l(t.rightShoulder) ? t.rightElbow + wt * Math.max(0, o) : t.rightElbow;
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;
527
528
  return {
528
529
  ...t,
529
530
  // Lean into the walk, and keep the head a little more level than the body.
530
- lean: t.lean + yt * n,
531
- headTilt: t.headTilt - yt * 0.5 * n,
532
- leftElbow: s,
531
+ lean: t.lean + Mt * n,
532
+ headTilt: t.headTilt - Mt * 0.5 * n,
533
+ leftElbow: l,
533
534
  rightElbow: a,
534
535
  // Left foot forward while swing > 0, right foot back; then the other way.
535
- leftHip: -Qe * o,
536
- rightHip: -Qe * o,
536
+ leftHip: -Qe * r,
537
+ rightHip: -Qe * r,
537
538
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
538
539
  // knee folds toward the centre, which is backward only for the right leg.
539
- leftKnee: -30 * Math.max(0, r),
540
- rightKnee: 30 * Math.max(0, -r),
540
+ leftKnee: -30 * Math.max(0, o),
541
+ rightKnee: 30 * Math.max(0, -o),
541
542
  // Arms swing against the legs: left arm back while the left foot is forward.
542
543
  leftShoulder: i(t.leftShoulder),
543
544
  rightShoulder: i(t.rightShoulder)
544
545
  };
545
546
  }
546
- function Kr(e, t = 1) {
547
- return 4 * ((Ve + Pe) * e) * Math.sin(Qe * t * Math.PI / 180);
547
+ function Ur(e, t = 1) {
548
+ return 4 * ((et + Ie) * e) * Math.sin(Qe * t * Math.PI / 180);
548
549
  }
549
- function Ln(e) {
550
+ function Jn(e) {
550
551
  const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
551
552
  return t * n;
552
553
  }
553
- const Rt = 0.12, kt = 0.46, Nn = 1 - 2 * Rt, Cn = 0.1, Dn = 0.21, Xn = 0.19, Ve = 0.24, Pe = 0.22, Yt = 0.12, qn = 0.14, Lt = 0.33, St = 0.7, Et = 0.3, Un = 0.35, zn = [1.7, 1.05], Gn = [1.3, 0.75], Ht = [1.45, 0.85], Jn = [1.15, 0.75], Mt = 0.06, Zn = 0.7, jn = 0.65, Nt = 0.075, Qn = 0.3, Vn = 0.02, eo = 0.012, to = 12, no = 0.25, ke = 90, oo = 0.25, ro = 0.04, Ct = 0.01, se = (e) => Math.min(1, Math.max(0, e ?? 0));
554
- function Pr(e, t = 1) {
555
- return Pe * e * t;
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;
556
557
  }
557
- const et = -0.12, Dt = 0.4, Z = (e) => e * Math.PI / 180, lo = (e, t) => ({ x: t * Math.sin(Z(e)), y: Math.cos(Z(e)) }), Xt = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), qt = (e, t, n, o) => e - 0.3 * t - n * 0.14 * t - Math.max(0, o - 1) * 0.12 * t;
558
- function so(e, t, n, o, r, l) {
559
- const i = Math.max(1, Math.min(l * 0.6, qn * n)), s = se(t.turn), a = (Yt + Lt * s) * n, h = o + et * n, f = a + t.lookX * 0.08 * n, g = t.lookY * 0.07 * n, p = [
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 = [
560
561
  // The left eye is on the far side; turning closes it up more than the near one.
561
- { x: -0.34 * n * (1 - St * s), squeeze: 1 - St * s, open: t.leftEye, brow: t.leftBrow, side: -1 },
562
- { x: 0.34 * n * (1 - Et * s), squeeze: 1 - Et * s, open: t.rightEye, brow: t.rightBrow, side: 1 }
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 }
563
564
  ];
564
- e.fillStyle = r, e.strokeStyle = r, e.lineWidth = i;
565
- for (const m of p) {
566
- const w = Xt(m.open, t.blink);
567
- if (w < 0.2) {
568
- const k = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
569
- e.beginPath(), e.moveTo(m.x + a - 0.12 * n, h), e.quadraticCurveTo(m.x + a, h + k, m.x + a + 0.12 * n, h), e.stroke();
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();
570
571
  } else {
571
- if (w > 1.2) {
572
- const E = 0.13 * n * w;
573
- e.beginPath(), e.ellipse(m.x + a, h, E * 0.85, E, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = r;
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;
574
575
  }
575
- const k = w > 1.2 ? 0.075 * n : 0.1 * n;
576
- e.beginPath(), e.ellipse(m.x + f, h + g, k, k * 1.1 * Math.min(w, 1), 0, 0, Math.PI * 2), e.fill();
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();
577
578
  }
578
- const S = qt(h, n, m.brow, w), M = m.x + a - m.side * 0.13 * n * m.squeeze, H = m.x + a + m.side * 0.13 * n * m.squeeze;
579
- e.beginPath(), e.moveTo(H, S), e.lineTo(M, S - t.browTilt * 0.1 * n), e.stroke();
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();
580
581
  }
581
- const c = o + Dt * n, u = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Un * s), d = Math.min(1, Math.max(0, t.mouth));
582
- if (e.beginPath(), d <= 0.05) {
583
- e.moveTo(a - u, c), e.quadraticCurveTo(a, c + t.smile * 0.25 * n, a + u, c), e.stroke();
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();
584
585
  return;
585
586
  }
586
- const b = 0.3 * n * d;
587
- t.smile > 0.3 ? (e.moveTo(a - u, c - 0.05 * n), e.lineTo(a + u, c - 0.05 * n), e.quadraticCurveTo(a, c + b * 2, a - u, c - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - u, c + b * 0.6), e.lineTo(a + u, c + b * 0.6), e.quadraticCurveTo(a, c - b * 1.4, a - u, c + b * 0.6)) : e.ellipse(a, c, u * 0.8, b, 0, 0, Math.PI * 2), e.fill();
588
- }
589
- function Ut(e, t) {
590
- const n = t.height ?? 300, o = Math.min(3, Math.max(0.3, e.stretch ?? 1)), r = Math.sqrt(o), l = (t.headSize ?? 2 * Rt) / 2, i = t.headSize === void 0 ? Nn : 1 - 2 * l, s = l * n, a = se(e.sit), h = e.leftHip + (-ke - e.leftHip) * a, f = e.leftKnee + (-ke - e.leftKnee) * a, g = e.rightHip + (ke - e.rightHip) * a, p = e.rightKnee + (ke - e.rightKnee) * a, c = t.classic === !0, u = se(e.turn), d = (K, P, B, $, _) => {
591
- const C = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Z(P - B) / 2) + Z($))), L = Math.max(-1, Math.min(1, Zn + _)), Q = u + (1 - u) * K * L;
592
- return c ? { x: 0, y: 0 } : { x: Math.cos(C) * Mt * Q, y: Math.sin(C) * Mt };
593
- }, b = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, m = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
594
- let w = 0;
595
- if (a > 0 || !c) {
596
- const K = (_, C, L, Q, ne) => Ve * Math.cos(Z(C)) + Pe * Math.cos(Z(C - L)) + Math.max(0, d(_, C, L, Q, ne).y), P = Math.max(
597
- K(-1, h, f, b.left, m.left),
598
- K(1, g, p, b.right, m.right)
599
- ), B = 1 - se((e.rise ?? 0) / ro), $ = (c ? Math.min(1, a / oo) : 1) * B;
600
- w = (kt - P) * $ * n * o;
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;
601
602
  }
602
- const S = -kt * n * o + w, M = -i * n * o + w, H = c ? 0 : (Vn * se(e.turn) + eo * a) * n * o, k = H === 0 ? [{ x: 0, y: S }, { x: 0, y: M }] : fe({ x: 0, y: S }, { x: -H, y: (S + M) / 2 }, { x: 0, y: M }, 1, 8), E = M + Cn * n * o, T = (t.shoulderWidth ?? 0) * n * Math.cos(u * Math.PI / 2), A = (K, P, B, $, _) => {
603
- const C = lo(B, $);
604
- return { x: K + C.x * _ * n, y: P + C.y * _ * n };
605
- }, I = (K, P, B) => {
606
- const $ = A(0, S, P, K, Ve * o);
607
- return { root: { x: 0, y: S }, joint: $, end: A($.x, $.y, P - B, K, Pe * o) };
608
- }, W = (K, P, B) => {
609
- const $ = { x: K * T, y: E }, _ = A($.x, $.y, P, K, Dn * r);
610
- return { root: $, joint: _, end: A(_.x, _.y, P + B, K, Xn * r) };
611
- }, v = { left: I(-1, h, f), right: I(1, g, p) }, y = (K, P, B, $, _, C) => {
612
- const L = d(K, B, $, _, C);
613
- return { x: P.end.x + L.x * n * o, y: P.end.y + L.y * n * o };
614
- }, x = (K, P, B, $, _) => A(P.end.x, P.end.y, B + $ + _, K, Nt * r), O = {
615
- left: W(-1, e.leftShoulder, e.leftElbow),
616
- right: W(1, e.rightShoulder, e.rightElbow)
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 = {
616
+ left: K(-1, e.leftShoulder, e.leftElbow),
617
+ right: K(1, e.rightShoulder, e.rightElbow)
617
618
  };
618
619
  return {
619
620
  height: n,
620
621
  facing: (t.facing ?? 1) < 0 ? -1 : 1,
621
- stretch: o,
622
+ stretch: r,
622
623
  lineWidth: t.lineWidth ?? n * 0.025,
623
- rubber: Math.min(1, Math.max(c ? 0 : Qn, t.rubber ?? 0)),
624
- r: s,
624
+ rubber: Math.min(1, Math.max(u ? 0 : io, t.rubber ?? 0)),
625
+ r: l,
625
626
  // The head keeps its area: taller and narrower when stretched.
626
- headRx: s / Math.sqrt(o),
627
- headRy: s * Math.sqrt(o),
628
- hipY: S,
629
- neckY: M,
630
- drop: w,
631
- lean: c ? e.lean : e.lean + to * Math.sin(Math.PI * a),
632
- classic: c,
627
+ headRx: l / Math.sqrt(r),
628
+ headRy: l * Math.sqrt(r),
629
+ hipY: y,
630
+ neckY: H,
631
+ drop: k,
632
+ lean: u ? e.lean : e.lean + co * Math.sin(Math.PI * a),
633
+ classic: u,
633
634
  legs: v,
634
635
  toes: {
635
- left: y(-1, v.left, h, f, b.left, m.left),
636
- right: y(1, v.right, g, p, b.right, m.right)
636
+ left: T(-1, v.left, h, c, g.left, m.left),
637
+ right: T(1, v.right, p, d, g.right, m.right)
637
638
  },
638
- spine: k,
639
- arms: O,
639
+ spine: w,
640
+ arms: B,
640
641
  handTips: {
641
- left: x(-1, O.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
642
- right: x(1, O.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
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)
643
644
  }
644
645
  };
645
646
  }
646
- const ue = (e, t) => t === 0 ? [e.root, e.joint, e.end] : fe(e.root, e.joint, e.end, t);
647
- function We(e, t, n) {
648
- const o = Math.cos(n), r = Math.sin(n), l = e.x - t.x, i = e.y - t.y;
649
- return { x: t.x + l * o - i * r, y: t.y + l * r + i * o };
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 };
650
651
  }
651
- function zt(e, t, n = !0) {
652
- const o = ao(e, t), r = t.spin ?? 0, l = t.rise ?? 0;
653
- return n && (r !== 0 || l !== 0) ? io(o, e, r, l) : o;
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;
654
655
  }
655
- function Gt(e, t, n) {
656
- return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Z(t), lift: n * e.height };
656
+ function Qt(e, t, n) {
657
+ return { pivot: { x: 0, y: e.hipY }, angle: e.facing * ee(t), lift: n * e.height };
657
658
  }
658
- function io(e, t, n, o) {
659
- const { pivot: r, angle: l, lift: i } = Gt(t, n, o), s = (p) => {
660
- const c = We(p, r, l);
661
- return { x: c.x, y: c.y - i };
662
- }, a = (p) => ({ left: s(p.left), right: s(p.right) }), h = { left: Math.max(s(e.feet.left).y, s(e.toes.left).y), right: Math.max(s(e.feet.right).y, s(e.toes.right).y) }, f = Math.max(h.left, h.right), g = Ct * t.height;
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;
663
664
  return {
664
665
  ...e,
665
- hip: s(e.hip),
666
- neck: s(e.neck),
666
+ hip: l(e.hip),
667
+ neck: l(e.neck),
667
668
  shoulders: a(e.shoulders),
668
669
  elbows: a(e.elbows),
669
670
  hands: a(e.hands),
@@ -671,298 +672,298 @@ function io(e, t, n, o) {
671
672
  knees: a(e.knees),
672
673
  feet: a(e.feet),
673
674
  toes: a(e.toes),
674
- feetY: f,
675
- grounded: { left: h.left >= f - g, right: h.right >= f - g },
676
- handAngle: { left: e.handAngle.left + l, right: e.handAngle.right + l },
675
+ 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 },
677
678
  limbs: {
678
- leftArm: e.limbs.leftArm.map(s),
679
- rightArm: e.limbs.rightArm.map(s),
680
- leftLeg: e.limbs.leftLeg.map(s),
681
- rightLeg: e.limbs.rightLeg.map(s),
682
- spine: e.limbs.spine.map(s)
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)
683
684
  },
684
- head: { ...e.head, center: s(e.head.center), angle: e.head.angle + l }
685
+ head: { ...e.head, center: l(e.head.center), angle: e.head.angle + s }
685
686
  };
686
687
  }
687
- function ao(e, t) {
688
- const n = Z(e.lean), o = Z(t.headTilt), r = { x: 0, y: e.hipY }, l = (S) => ({ x: e.facing * S.x, y: S.y }), i = (S) => l(We(S, r, n)), s = (S) => i(We({ x: S.x, y: S.y + e.neckY }, { x: 0, y: e.neckY }, o)), a = ue(e.arms.left, e.rubber).map(i), h = ue(e.arms.right, e.rubber).map(i), f = (S, M) => Math.atan2(M.y - S.y, M.x - S.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, p = (S, M) => {
689
- const [H, k] = S.slice(-2), E = e.arms[M], T = f(i(E.end), g[M]) - f(i(E.joint), i(E.end));
690
- return f(H, k) + T;
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;
691
692
  };
692
- let c = 1 / 0;
693
- for (const [S, M] of [
693
+ let u = 1 / 0;
694
+ for (const [y, H] of [
694
695
  [t.leftBrow, t.leftEye],
695
696
  [t.rightBrow, t.rightEye]
696
697
  ]) {
697
- const H = qt(et, 1, S, Xt(M, t.blink));
698
- c = Math.min(c, H, H - t.browTilt * 0.1);
698
+ const E = Vt(tt, 1, y, Jt(H, t.blink));
699
+ u = Math.min(u, E, E - t.browTilt * 0.1);
699
700
  }
700
- const u = { left: l(e.legs.left.end), right: l(e.legs.right.end) }, d = { left: l(e.toes.left), right: l(e.toes.right) }, b = { left: Math.max(u.left.y, d.left.y), right: Math.max(u.right.y, d.right.y) }, m = Math.max(b.left, b.right), w = Ct * e.height;
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;
701
702
  return {
702
703
  facing: e.facing,
703
704
  height: e.height,
704
705
  stretch: e.stretch,
705
706
  lineWidth: e.lineWidth,
706
- hip: r,
707
+ hip: o,
707
708
  neck: i({ x: 0, y: e.neckY }),
708
709
  shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
709
710
  elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
710
711
  hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
711
- knees: { left: l(e.legs.left.joint), right: l(e.legs.right.joint) },
712
- feet: u,
713
- toes: d,
712
+ knees: { left: s(e.legs.left.joint), right: s(e.legs.right.joint) },
713
+ feet: b,
714
+ toes: f,
714
715
  feetY: m,
715
- grounded: { left: b.left >= m - w, right: b.right >= m - w },
716
- fingertips: g,
717
- handAngle: { left: p(a, "left"), right: p(h, "right") },
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") },
718
719
  limbs: {
719
720
  leftArm: a,
720
721
  rightArm: h,
721
- leftLeg: ue(e.legs.left, e.rubber).map(l),
722
- rightLeg: ue(e.legs.right, e.rubber).map(l),
722
+ leftLeg: be(e.legs.left, e.rubber).map(s),
723
+ rightLeg: be(e.legs.right, e.rubber).map(s),
723
724
  spine: e.spine.map(i)
724
725
  },
725
726
  head: {
726
- center: s({ x: 0, y: -e.headRy }),
727
+ center: l({ x: 0, y: -e.headRy }),
727
728
  rx: e.headRx,
728
729
  ry: e.headRy,
729
730
  // Mirroring a turn reverses it.
730
- angle: e.facing * (n + o),
731
- eyeY: et,
732
- browTopY: c,
733
- mouthY: Dt,
734
- faceX: e.facing * (Yt + Lt * se(t.turn))
731
+ angle: e.facing * (n + r),
732
+ eyeY: tt,
733
+ browTopY: u,
734
+ mouthY: Gt,
735
+ faceX: e.facing * (Xt + qt * ie(t.turn))
735
736
  }
736
737
  };
737
738
  }
738
- function ho(e, t = {}) {
739
- return zt(Ut(e, t), e);
739
+ function wo(e, t = {}) {
740
+ return Zt(jt(e, t), e);
740
741
  }
741
- function Wr(e, t, n) {
742
- return We({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
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);
743
744
  }
744
- function fo(e, t, n) {
745
- const o = (l) => ({ x: l.x + t, y: l.y + n }), r = (l) => ({ left: o(l.left), right: o(l.right) });
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) });
746
747
  return {
747
748
  ...e,
748
- hip: o(e.hip),
749
- neck: o(e.neck),
750
- shoulders: r(e.shoulders),
751
- elbows: r(e.elbows),
752
- hands: r(e.hands),
753
- knees: r(e.knees),
754
- feet: r(e.feet),
755
- toes: r(e.toes),
749
+ hip: r(e.hip),
750
+ neck: r(e.neck),
751
+ shoulders: o(e.shoulders),
752
+ elbows: o(e.elbows),
753
+ hands: o(e.hands),
754
+ knees: o(e.knees),
755
+ feet: o(e.feet),
756
+ toes: o(e.toes),
756
757
  feetY: e.feetY + n,
757
758
  grounded: { ...e.grounded },
758
759
  handAngle: { ...e.handAngle },
759
760
  limbs: {
760
- leftArm: e.limbs.leftArm.map(o),
761
- rightArm: e.limbs.rightArm.map(o),
762
- leftLeg: e.limbs.leftLeg.map(o),
763
- rightLeg: e.limbs.rightLeg.map(o),
764
- spine: e.limbs.spine.map(o)
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)
765
766
  },
766
- head: { ...e.head, center: o(e.head.center) }
767
+ head: { ...e.head, center: r(e.head.center) }
767
768
  };
768
769
  }
769
- function co(e, t, n = {}, o = 0) {
770
- const r = Ut(t, n), l = n.color ?? "#1e293b", i = n.layers ?? {}, s = n.layers ? zt(r, t, !1) : void 0, a = n.sketch ? Ge(e, n.sketch, o) : void 0, h = n.sketch && n.layers ? Ge(e, n.sketch, o) : void 0, f = (k) => {
771
- e.save(), k(), e.restore();
772
- }, g = (k) => {
773
- k && s && f(() => k(e, s, o, h));
774
- }, p = () => e.scale(r.facing, 1), c = () => {
775
- p(), e.translate(0, r.hipY), e.rotate(Z(r.lean)), e.translate(0, -r.hipY);
776
- }, u = (k, E, T) => {
777
- if (a) return E ? a.curve(k) : a.line(k);
778
- if (r.classic) {
779
- e.beginPath(), e.moveTo(k[0].x, k[0].y);
780
- for (const A of k.slice(1)) e.lineTo(A.x, A.y);
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) => {
772
+ 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);
779
+ if (o.classic) {
780
+ e.beginPath(), e.moveTo(w[0].x, w[0].y);
781
+ for (const S of w.slice(1)) e.lineTo(S.x, S.y);
781
782
  e.stroke();
782
783
  return;
783
784
  }
784
- lt(e, k, T[0] * r.lineWidth, T[1] * r.lineWidth);
785
- }, d = (k, E) => u(ue(k, r.rubber), r.rubber > 0, E), b = (k) => {
786
- r.classic || u([r.legs[k].end, r.toes[k]], !1, Jn);
787
- }, m = (k) => {
788
- if (n.hands && !r.classic) return S(k);
789
- if (r.classic || a) return;
790
- const E = r.arms[k].end;
791
- e.beginPath(), e.arc(E.x, E.y, jn * r.lineWidth, 0, Math.PI * 2), e.fill();
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);
790
+ 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();
792
793
  };
793
- e.save(), e.strokeStyle = l, e.fillStyle = l, e.lineWidth = r.lineWidth, e.lineCap = "round", e.lineJoin = "round";
794
- const w = Gt(r, t.spin ?? 0, t.rise ?? 0);
795
- (w.angle !== 0 || w.lift !== 0) && (e.translate(0, -w.lift), e.translate(w.pivot.x, w.pivot.y), e.rotate(w.angle), e.translate(-w.pivot.x, -w.pivot.y));
796
- function S(k) {
797
- const E = n.hands ?? {}, T = r.arms[k].end, A = r.handTips[k], I = n.headFill ?? "#ffffff";
798
- st(e, T, E[k] ?? R, {
799
- side: k,
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] ?? _, {
800
+ side: w,
800
801
  // Degrees clockwise from straight up, in the frame the hand is drawn in.
801
- angle: Math.atan2(A.x - T.x, T.y - A.y) * 180 / Math.PI,
802
- size: (E.size ?? Nt) * r.height * Math.sqrt(r.stretch),
803
- skin: E.skin ?? (I === "none" ? void 0 : I),
804
- ink: l,
805
- lineWidth: r.lineWidth * 0.45,
806
- fingers: E.fingers,
807
- plump: E.plump,
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,
806
+ lineWidth: o.lineWidth * 0.45,
807
+ fingers: M.fingers,
808
+ plump: M.plump,
808
809
  look: n.sketch ? "pencil" : "clean",
809
810
  seed: n.sketch?.seed
810
- }, o);
811
+ }, r);
811
812
  }
812
- const M = (k) => {
813
- f(() => {
814
- c(), d(r.arms[k], Gn), m(k);
813
+ const H = (w) => {
814
+ c(() => {
815
+ u(), f(o.arms[w], oo), m(w);
815
816
  });
816
- const E = i.sleeve;
817
- E && s && f(() => E(e, s, k, o, h));
818
- }, H = se(t.turn) > no;
819
- g(i.behind), f(() => {
820
- p(), d(r.legs.left, Ht), b("left"), d(r.legs.right, Ht), b("right");
821
- }), H && M("left"), f(() => {
822
- c(), u(r.spine, r.spine.length > 2, zn);
823
- const { left: k, right: E } = { left: r.arms.left.root, right: r.arms.right.root };
824
- if (k.x !== E.x)
825
- if (r.classic) u([k, E], !1, [1, 1]);
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]);
826
827
  else {
827
- const T = { x: (k.x + E.x) / 2, y: k.y - 0.3 * Math.abs(E.x - k.x) };
828
- u(fe(k, T, E, 1, 8), !0, [1.1, 1.1]);
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]);
829
830
  }
830
- }), g(i.body), H || M("left"), M("right"), g(i.behindHead), f(() => {
831
- c(), e.translate(0, r.neckY), e.rotate(Z(t.headTilt));
832
- const k = -r.headRy;
833
- e.beginPath(), e.ellipse(0, k, r.headRx, r.headRy, 0, 0, Math.PI * 2);
834
- const E = n.headFill ?? "#ffffff";
835
- if (E !== "none" && (e.fillStyle = E, e.fill()), a) {
836
- a.ellipse(0, k, r.headRx, r.headRy);
837
- const T = a.nudge();
838
- e.translate(T.x, T.y);
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));
833
+ const w = -o.headRy;
834
+ 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) {
837
+ a.ellipse(0, w, o.headRx, o.headRy);
838
+ const x = a.nudge();
839
+ e.translate(x.x, x.y);
839
840
  } else
840
841
  e.stroke();
841
- e.translate(0, k), e.scale(r.headRx / r.r, r.headRy / r.r), so(e, t, r.r, 0, l, r.lineWidth);
842
- }), g(i.overHead), g(i.front), e.restore(), n.label && (e.save(), e.fillStyle = l, e.font = n.labelFont ?? `700 ${Math.round(r.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -r.height * r.stretch - 0.04 * r.height + r.drop), e.restore());
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());
843
844
  }
844
- function Jt(e, t, n) {
845
- const o = { ...e };
846
- let r = e.walking > 0 ? we(o, Yn(e.walk, o), e.walking) : o, l = uo(e);
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);
847
848
  const i = e.dancing ?? 0;
848
849
  if (n && i > 0) {
849
- const s = n(e.beat ?? 0);
850
- if (r = we(r, s.pose, i), s.hands) {
851
- const a = (h, f) => f ? ye(h ?? R, f, i) : h;
852
- l = { left: a(l?.left, s.hands.left), right: a(l?.right, s.hands.right) };
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) };
853
854
  }
854
855
  }
855
- return e.talk > 0 && (r = { ...r, mouth: Math.max(r.mouth, e.talk * Ln(t)) }), { pose: r, hands: l };
856
+ return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Jn(t)) }), { pose: o, hands: s };
856
857
  }
857
- function go(e, t, n) {
858
- return Jt(e, t, n).pose;
858
+ function Eo(e, t, n) {
859
+ return en(e, t, n).pose;
859
860
  }
860
- const Oe = (e, t) => `hand.${e}.${t}`;
861
- function uo(e) {
862
- const t = (r) => {
863
- if (typeof e[Oe(r, "spread")] == "number")
864
- return Object.fromEntries(Object.keys(R).map((l) => [l, e[Oe(r, l)]]));
865
- }, n = t("left"), o = t("right");
866
- return n || o ? { left: n, right: o } : void 0;
861
+ const $e = (e, t) => `hand.${e}.${t}`;
862
+ function Ho(e) {
863
+ 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;
867
868
  }
868
- function po(e, t) {
869
+ function Mo(e, t) {
869
870
  return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
870
871
  }
871
- function Or(e) {
872
- const t = e.style ?? {}, n = t.height ?? 300, o = n * 0.8, r = { ...D(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, l = {};
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 = {};
873
874
  if (t.hands)
874
875
  for (const i of ["left", "right"]) {
875
- const s = t.hands[i] ?? R;
876
- for (const a of Object.keys(R)) l[Oe(i, a)] = s[a] ?? R[a];
876
+ const l = t.hands[i] ?? _;
877
+ for (const a of Object.keys(_)) s[$e(i, a)] = l[a] ?? _[a];
877
878
  }
878
879
  return {
879
880
  type: "custom",
880
- x: e.x - o / 2,
881
+ x: e.x - r / 2,
881
882
  y: e.y - n,
882
- width: o,
883
+ width: r,
883
884
  height: n,
884
- props: { ...r, ...l },
885
+ props: { ...o, ...s },
885
886
  figureStyle: t,
886
887
  figureDance: e.dance,
887
- draw(i, s, a) {
888
- const h = s.props, f = Jt(h, a, e.dance);
889
- i.translate(o / 2, n), co(i, f.pose, po({ ...t, rubber: h.rubber }, f.hands), a);
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);
890
891
  }
891
892
  };
892
893
  }
893
- function Ir(e, t, n) {
894
- const o = e.figureStyle;
895
- if (!o) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
896
- const r = { ...e.props };
897
- let l = 0, i = 0;
898
- for (const [h, f] of t.state?.values.get(n) ?? [])
899
- typeof f == "number" && (h === "x" || h === "motionPathX" ? l = f : h === "y" || h === "motionPathY" ? i = f : h in r && (r[h] = f));
900
- const s = go(r, t.time, e.figureDance), a = ho(s, { ...o, rubber: r.rubber });
901
- return { pose: s, joints: fo(a, e.x + l + e.width / 2, e.y + i + e.height) };
902
- }
903
- function $r(e, t) {
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");
897
+ const o = { ...e.props };
898
+ let s = 0, i = 0;
899
+ 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) {
904
905
  const n = [];
905
- return t.forEach((o, r) => {
906
- const l = r === 0 ? z : n[r - 1], i = typeof o.pose == "string" ? Fn[o.pose] : { ...l, ...o.pose };
907
- n.push(o.expression ? _t(i, o.expression) : i);
908
- }), Ft.filter((o) => n.some((r) => r[o] !== z[o])).map((o) => ({
909
- id: `${e}-${o}`,
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}`,
910
911
  target: e,
911
- property: o,
912
- keyframes: t.map((r, l) => ({
913
- time: r.time,
914
- value: n[l][o],
915
- ...r.easing ? { easing: r.easing } : {}
912
+ property: r,
913
+ keyframes: t.map((o, s) => ({
914
+ time: o.time,
915
+ value: n[s][r],
916
+ ...o.easing ? { easing: o.easing } : {}
916
917
  }))
917
918
  }));
918
919
  }
919
- const Ye = 0.5, vt = {
920
+ const Ne = 0.5, Wt = {
920
921
  /** Flag: fingers together and straight, thumb bent in */
921
- pataka: F({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
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 }),
922
923
  /** Pataka with the ring finger bent */
923
- tripataka: F({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
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 }),
924
925
  /** Lotus in bloom: fingers fanned, each a little more curled than the last */
925
- alapadma: F({ "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 }),
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 }),
926
927
  /** Fist */
927
- mushti: N.fist,
928
+ mushti: L.fist,
928
929
  /** Fist, thumb up */
929
- shikhara: N.thumbsUp,
930
+ shikhara: L.thumbsUp,
930
931
  /** Swan's beak: thumb and index touch, the others fanned */
931
- hamsasya: F({ "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 }),
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 }),
932
933
  /** Bracelet: thumb, index and middle meet, ring and little finger out */
933
- katakamukha: F({ "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 })
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 })
934
935
  };
935
- function Ie(e) {
936
- return typeof e != "string" ? e : e in vt ? vt[e] : N[e];
936
+ function _e(e) {
937
+ return typeof e != "string" ? e : e in Wt ? Wt[e] : L[e];
937
938
  }
938
- function Zt(e, t, n) {
939
- const o = [];
940
- for (const r of e.keys) {
941
- const l = o[o.length - 1], i = !l || r.reset ? { pose: t, ...n } : l;
942
- o.push({
943
- beat: r.beat,
944
- pose: { ...i.pose, ...r.pose },
945
- left: r.hands?.left ? Ie(r.hands.left) : i.left,
946
- right: r.hands?.right ? Ie(r.hands.right) : i.right,
947
- easing: r.easing ?? e.easing
939
+ function tn(e, t, n) {
940
+ const r = [];
941
+ for (const o of e.keys) {
942
+ const s = r[r.length - 1], i = !s || o.reset ? { pose: t, ...n } : s;
943
+ r.push({
944
+ 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,
948
+ easing: o.easing ?? e.easing
948
949
  });
949
950
  }
950
- return o;
951
+ return r;
951
952
  }
952
- const it = (e, t) => (e % t + t) % t;
953
- function bo(e, t, n, o) {
954
- const r = Zt(e, n, o);
955
- if (r.length === 0) return { pose: n, hands: o };
956
- const l = it(t, e.beats);
957
- let i = r.length - 1;
958
- for (let c = 0; c < r.length; c++) r[c].beat <= l && (i = c);
959
- const s = r[i], a = r[(i + 1) % r.length], h = s.beat <= l ? s.beat : s.beat - e.beats, f = a.beat > h ? a.beat : a.beat + e.beats, g = f > h ? (l - h) / (f - h) : 0, p = _e(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, g)));
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)));
960
961
  return {
961
- pose: we(s.pose, a.pose, p),
962
- hands: { left: ye(s.left, a.left, p), right: ye(s.right, a.right, p) }
962
+ pose: Se(l.pose, a.pose, d),
963
+ hands: { left: ke(l.left, a.left, d), right: ke(l.right, a.right, d) }
963
964
  };
964
965
  }
965
- const mo = [
966
+ const xo = [
966
967
  ["leftShoulder", "rightShoulder"],
967
968
  ["leftElbow", "rightElbow"],
968
969
  ["leftWrist", "rightWrist"],
@@ -972,151 +973,151 @@ const mo = [
972
973
  ["leftFootOut", "rightFootOut"],
973
974
  ["leftEye", "rightEye"],
974
975
  ["leftBrow", "rightBrow"]
975
- ], yo = ["lean", "headTilt", "lookX", "spin"], wo = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
976
- function ko(e) {
976
+ ], To = ["lean", "headTilt", "lookX", "spin"], Ao = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
977
+ function Ko(e) {
977
978
  const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
978
- for (const [o, r] of mo) {
979
- const l = n && wo.has(o) ? -1 : 1;
980
- t[o] = l * e[r], t[r] = l * e[o];
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];
981
982
  }
982
- if (!n) for (const o of yo) t[o] = -e[o];
983
+ if (!n) for (const r of To) t[r] = -e[r];
983
984
  return t;
984
985
  }
985
- const So = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
986
- function Eo(e, t, n) {
987
- const o = it(n, 1), r = (1 + Math.cos(2 * Math.PI * o)) / 2, l = t.bounce * (t.accent === "up" ? 1 - r : r), i = Math.min(1, Math.max(0, e.turn ?? 0)), s = So(i);
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);
988
989
  return {
989
990
  ...e,
990
- leftHip: e.leftHip + s * l / 2,
991
- rightHip: e.rightHip + l / 2,
992
- leftKnee: e.leftKnee + s * l,
993
- rightKnee: e.rightKnee + l,
991
+ leftHip: e.leftHip + l * s / 2,
992
+ rightHip: e.rightHip + s / 2,
993
+ leftKnee: e.leftKnee + l * s,
994
+ rightKnee: e.rightKnee + s,
994
995
  lean: e.lean + (t.sway ?? 0) * (1 - i) * Math.sin(Math.PI * n)
995
996
  };
996
997
  }
997
- function tt(e) {
998
- const t = { ...z, ...e.stance };
999
- return e.expression ? _t(t, e.expression) : t;
998
+ function nt(e) {
999
+ const t = { ...J, ...e.stance };
1000
+ return e.expression ? Nt(t, e.expression) : t;
1000
1001
  }
1001
- function jt(e) {
1002
+ function nn(e) {
1002
1003
  return {
1003
- left: e.hands?.left ? Ie(e.hands.left) : R,
1004
- right: e.hands?.right ? Ie(e.hands.right) : R
1004
+ left: e.hands?.left ? _e(e.hands.left) : _,
1005
+ right: e.hands?.right ? _e(e.hands.right) : _
1005
1006
  };
1006
1007
  }
1007
- function Le(e, t, n) {
1008
- const o = e.moves[t.move];
1009
- if (!o) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1010
- const r = bo(o, n, tt(e), jt(e));
1011
- return t.mirror ? { pose: ko(r.pose), hands: { left: r.hands?.right, right: r.hands?.left } } : r;
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;
1012
1013
  }
1013
- function at(e, t, n = {}) {
1014
- const o = typeof e == "string" ? ce[e] : e;
1015
- let r;
1014
+ function ct(e, t, n = {}) {
1015
+ const r = typeof e == "string" ? ge[e] : e;
1016
+ let o;
1016
1017
  if (n.move)
1017
- r = Le(o, { move: n.move, mirror: n.mirror }, t);
1018
+ o = Ce(r, { move: n.move, mirror: n.mirror }, t);
1018
1019
  else {
1019
- const l = o.routine, i = l.reduce((g, p) => g + p.beats, 0), s = it(t, i);
1020
+ const s = r.routine, i = s.reduce((p, d) => p + d.beats, 0), l = ht(t, i);
1020
1021
  let a = 0, h = 0;
1021
- for (; h < l.length - 1 && s >= a + l[h].beats; ) a += l[h++].beats;
1022
- const f = s - a;
1023
- if (r = Le(o, l[h], f), f < Ye && l.length > 1 && t >= Ye) {
1024
- const g = l[(h - 1 + l.length) % l.length], p = Le(o, g, g.beats + f), c = _e("ease-in-out")(f / Ye);
1025
- r = {
1026
- pose: we(p.pose, r.pose, c),
1027
- hands: { left: ye(p.hands.left, r.hands.left, c), right: ye(p.hands.right, r.hands.right, c) }
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);
1026
+ 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) }
1028
1029
  };
1029
1030
  }
1030
1031
  }
1031
- return { ...r, pose: Eo(r.pose, o.groove, t) };
1032
+ return { ...o, pose: Wo(o.pose, r.groove, t) };
1032
1033
  }
1033
- function Br(e, t, n = {}) {
1034
- return at(e, t, n).pose;
1034
+ function Zr(e, t, n = {}) {
1035
+ return ct(e, t, n).pose;
1035
1036
  }
1036
- function ht(e) {
1037
- return (typeof e == "string" ? ce[e] : e).routine.reduce((n, o) => n + o.beats, 0);
1037
+ function ft(e) {
1038
+ return (typeof e == "string" ? ge[e] : e).routine.reduce((n, r) => n + r.beats, 0);
1038
1039
  }
1039
- const Ho = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1040
- function Tt(e, t, n, o, r, l, i) {
1041
- for (let s = 0; s * e.beats < n; s++)
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++)
1042
1043
  for (const a of e.keys) {
1043
- const h = s * e.beats + a.beat, f = t + h;
1044
- if (!(h >= n || f < l || f >= i))
1045
- for (const g of a.taps ?? []) r.push({ beat: f, tap: o ? Ho[g] : g });
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 });
1046
1047
  }
1047
1048
  }
1048
- function _r(e, t, n, o = {}) {
1049
- const r = typeof e == "string" ? ce[e] : e, l = [];
1050
- if (n <= t) return l;
1051
- if (o.move) {
1052
- const i = r.moves[o.move], s = Math.floor(t / i.beats) * i.beats;
1053
- Tt(i, s, Math.ceil((n - s) / i.beats) * i.beats, o.mirror, l, t, n);
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);
1054
1055
  } else {
1055
- const i = ht(r);
1056
- for (let s = Math.floor(t / i) * i; s < n; s += i) {
1057
- let a = s;
1058
- for (const h of r.routine)
1059
- Tt(r.moves[h.move], a, h.beats, h.mirror, l, t, n), a += h.beats;
1056
+ const i = ft(o);
1057
+ for (let l = Math.floor(t / i) * i; l < n; l += i) {
1058
+ let a = l;
1059
+ for (const h of o.routine)
1060
+ Ot(o.moves[h.move], a, h.beats, h.mirror, s, t, n), a += h.beats;
1060
1061
  }
1061
1062
  }
1062
- return l.sort((i, s) => i.beat - s.beat);
1063
+ return s.sort((i, l) => i.beat - l.beat);
1063
1064
  }
1064
- function xt(e, t) {
1065
+ function It(e, t) {
1065
1066
  const n = e.moves[t.move];
1066
1067
  if (!n?.travel) return 0;
1067
- const o = n.travel / n.beats;
1068
- return t.mirror ? (Zt(n, tt(e), jt(e))[0]?.pose.turn ?? tt(e).turn ?? 0) >= 0.5 ? o : -o : o;
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;
1069
1070
  }
1070
- function Qt(e, t) {
1071
+ function on(e, t) {
1071
1072
  return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
1072
1073
  }
1073
- function Ne(e, t, n = {}) {
1074
- const o = typeof e == "string" ? ce[e] : e, r = Qt(o, n), l = r.reduce((f, g) => f + g.beats, 0), i = r.reduce((f, g) => f + xt(o, g) * g.beats, 0), s = Math.floor(t / l);
1075
- let a = s * i, h = t - s * l;
1076
- for (const f of r) {
1077
- const g = Math.min(f.beats, h);
1078
- if (a += xt(o, f) * g, h -= g, h <= 0) break;
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;
1077
+ 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;
1079
1080
  }
1080
1081
  return a;
1081
1082
  }
1082
- function Mo(e, t, n) {
1083
- const o = Qt(e, n), r = [0];
1084
- let l = 0;
1085
- for (let i = 0; l < t; i = (i + 1) % o.length)
1086
- l += o[i].beats, r.push(Math.min(l, t));
1087
- return r;
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));
1088
+ return o;
1088
1089
  }
1089
- const vo = 8;
1090
- function To(e, t, n) {
1091
- const o = typeof t == "string" ? ce[t] : t, r = n.bpm ?? o.bpm, l = n.beats ?? (n.move ? o.moves[n.move].beats : ht(o)), i = Mo(o, l, n);
1092
- if (i.every((m) => Ne(o, m, n) === 0)) return;
1093
- const s = Math.min(n.fade ?? 1, l / 2), a = _e("ease-in-out"), h = (m) => s <= 0 ? 1 : Math.min(a(Math.min(1, m / s)), a(Math.min(1, (l - m) / s))), f = Math.ceil(s * vo), g = s <= 0 ? [] : Array.from({ length: f + 1 }, (m, w) => [w / f * s, l - w / f * s]).flat(), p = [.../* @__PURE__ */ new Set([...i, ...g])].sort((m, w) => m - w);
1094
- let c = 0;
1095
- const u = p.map((m, w) => {
1096
- if (w > 0) {
1097
- const S = p[w - 1], M = Math.max(1, Math.ceil((m - S) * 16));
1098
- for (let H = 0; H < M; H++) {
1099
- const k = S + (m - S) * H / M, E = S + (m - S) * (H + 1) / M;
1100
- c += (Ne(o, E, n) - Ne(o, k, n)) * h((k + E) / 2);
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);
1101
1102
  }
1102
1103
  }
1103
- return { beat: m, travel: c };
1104
- }), d = n.start ?? 0, b = n.x ?? 0;
1104
+ return { beat: m, travel: u };
1105
+ }), f = n.start ?? 0, g = n.x ?? 0;
1105
1106
  return {
1106
1107
  id: `${e}-x`,
1107
1108
  target: e,
1108
1109
  property: "x",
1109
- keyframes: u.map((m) => ({ time: d + m.beat * 6e4 / r, value: b + n.height * m.travel, easing: "linear" }))
1110
+ keyframes: b.map((m) => ({ time: f + m.beat * 6e4 / o, value: g + n.height * m.travel, easing: "linear" }))
1110
1111
  };
1111
1112
  }
1112
- function Fr(e, t, n = 0) {
1113
+ function es(e, t, n = 0) {
1113
1114
  return (e - n) * t / 6e4;
1114
1115
  }
1115
- function Rr(e, t = {}) {
1116
- return (n) => at(e, n, t);
1116
+ function ts(e, t = {}) {
1117
+ return (n) => ct(e, n, t);
1117
1118
  }
1118
- function Yr(e, t) {
1119
- const n = t.start ?? 0, o = 6e4 / t.bpm, r = n + t.beats * o, l = Math.min((t.fade ?? 1) * o, (r - n) / 2);
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);
1120
1121
  return [
1121
1122
  {
1122
1123
  id: `${e}-beat`,
@@ -1124,7 +1125,7 @@ function Yr(e, t) {
1124
1125
  property: "beat",
1125
1126
  keyframes: [
1126
1127
  { time: n, value: 0 },
1127
- { time: r, value: t.beats, easing: "linear" }
1128
+ { time: o, value: t.beats, easing: "linear" }
1128
1129
  ]
1129
1130
  },
1130
1131
  {
@@ -1133,33 +1134,33 @@ function Yr(e, t) {
1133
1134
  property: "dancing",
1134
1135
  keyframes: [
1135
1136
  { time: n, value: 0 },
1136
- { time: n + l, value: 1, easing: "ease-in-out" },
1137
- { time: r - l, value: 1 },
1138
- { time: r, value: 0, easing: "ease-in-out" }
1137
+ { time: n + s, value: 1, easing: "ease-in-out" },
1138
+ { time: o - s, value: 1 },
1139
+ { time: o, value: 0, easing: "ease-in-out" }
1139
1140
  ]
1140
1141
  }
1141
1142
  ];
1142
1143
  }
1143
- function Lr(e, t, n = {}) {
1144
- const o = typeof t == "string" ? ce[t] : t, r = n.bpm ?? o.bpm, l = n.beats ?? (n.move ? o.moves[n.move].beats : ht(o)), i = n.samplesPerBeat ?? 4, s = n.start ?? 0, a = Math.round(l * i), h = Array.from({ length: a + 1 }, (d, b) => {
1145
- const m = b / i;
1146
- return { time: s + m * 6e4 / r, frame: at(o, m, n) };
1147
- }), f = (d, b) => ({
1148
- id: `${e}-${d}`,
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}`,
1149
1150
  target: e,
1150
- property: d,
1151
- keyframes: h.map((m) => ({ time: m.time, value: b(m.frame) }))
1152
- }), p = Object.keys(z).filter((d) => h.some((b) => b.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== z[d]).map((d) => f(d, (b) => b.pose[d])), c = n.height === void 0 ? void 0 : To(e, o, { ...n, bpm: r, beats: l, start: s, height: n.height, fade: 0 });
1153
- if (c && p.push(c), n.hands === !1) return p;
1154
- const u = [];
1155
- for (const d of ["left", "right"])
1156
- for (const b of Object.keys(R)) {
1157
- const m = (w) => w.hands?.[d]?.[b] ?? R[b];
1158
- h.some((w) => m(w.frame) !== R[b]) && u.push(f(Oe(d, b), m));
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));
1159
1160
  }
1160
- return [...p, ...u];
1161
+ return [...d, ...b];
1161
1162
  }
1162
- const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic", xo = {
1163
+ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic", _o = {
1163
1164
  label: "Disco",
1164
1165
  bpm: 120,
1165
1166
  stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
@@ -1169,7 +1170,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1169
1170
  point: {
1170
1171
  label: "The point",
1171
1172
  beats: 2,
1172
- easing: X,
1173
+ easing: D,
1173
1174
  keys: [
1174
1175
  {
1175
1176
  beat: 0,
@@ -1194,9 +1195,9 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1194
1195
  label: "Bump and clap",
1195
1196
  beats: 4,
1196
1197
  keys: [
1197
- { 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: X },
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 },
1198
1199
  { 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" } },
1199
- { 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: X },
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 },
1200
1201
  { 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" } }
1201
1202
  ]
1202
1203
  }
@@ -1207,7 +1208,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1207
1208
  { move: "point", beats: 8, mirror: !0 },
1208
1209
  { move: "bump", beats: 8 }
1209
1210
  ]
1210
- }, Ao = {
1211
+ }, Fo = {
1211
1212
  label: "Hip hop",
1212
1213
  bpm: 95,
1213
1214
  stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
@@ -1259,7 +1260,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1259
1260
  { move: "armWave", beats: 8 },
1260
1261
  { move: "bounce", beats: 4 }
1261
1262
  ]
1262
- }, Ko = {
1263
+ }, Ro = {
1263
1264
  label: "Breaking (toprock)",
1264
1265
  bpm: 110,
1265
1266
  stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
@@ -1271,9 +1272,9 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1271
1272
  label: "Toprock (Indian step)",
1272
1273
  beats: 4,
1273
1274
  keys: [
1274
- { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: X },
1275
+ { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: D },
1275
1276
  { beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
1276
- { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: X },
1277
+ { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: D },
1277
1278
  { beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
1278
1279
  ]
1279
1280
  },
@@ -1281,7 +1282,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1281
1282
  label: "Kick out",
1282
1283
  beats: 2,
1283
1284
  keys: [
1284
- { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: X },
1285
+ { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: D },
1285
1286
  { beat: 1, reset: !0 }
1286
1287
  ]
1287
1288
  },
@@ -1289,7 +1290,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1289
1290
  label: "B-boy stance",
1290
1291
  beats: 4,
1291
1292
  keys: [
1292
- { 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: be },
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 },
1293
1294
  { beat: 2, pose: { headTilt: 14, lean: -6 } }
1294
1295
  ]
1295
1296
  }
@@ -1301,7 +1302,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1301
1302
  { move: "kick", beats: 4, mirror: !0 },
1302
1303
  { move: "freeze", beats: 4 }
1303
1304
  ]
1304
- }, Po = {
1305
+ }, Yo = {
1305
1306
  label: "Jazz",
1306
1307
  bpm: 130,
1307
1308
  stance: { leftHip: 10, rightHip: 10 },
@@ -1317,14 +1318,14 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1317
1318
  beat: e,
1318
1319
  // The hands shimmer: the wrists flick a little each quarter beat.
1319
1320
  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 },
1320
- hands: t === 0 ? { left: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } } : void 0
1321
+ hands: t === 0 ? { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } } : void 0
1321
1322
  }))
1322
1323
  },
1323
1324
  kickBallChange: {
1324
1325
  label: "Kick ball change",
1325
1326
  beats: 2,
1326
1327
  keys: [
1327
- { 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: X },
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 },
1328
1329
  { beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
1329
1330
  { beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
1330
1331
  ]
@@ -1362,7 +1363,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1362
1363
  { move: "jazzHands", beats: 4 },
1363
1364
  { move: "splitDrop", beats: 8 }
1364
1365
  ]
1365
- }, Wo = {
1366
+ }, Lo = {
1366
1367
  label: "K-pop",
1367
1368
  bpm: 125,
1368
1369
  stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
@@ -1372,7 +1373,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1372
1373
  pointCombo: {
1373
1374
  label: "Point combo",
1374
1375
  beats: 4,
1375
- easing: be,
1376
+ easing: we,
1376
1377
  keys: [
1377
1378
  { 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" } },
1378
1379
  { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
@@ -1384,16 +1385,16 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1384
1385
  label: "Big heart, finger heart",
1385
1386
  beats: 4,
1386
1387
  keys: [
1387
- { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: be },
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 },
1388
1389
  { beat: 1, pose: { headTilt: 8, lean: 4 } },
1389
- { 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: be },
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 },
1390
1391
  { beat: 3, pose: { headTilt: 4 } }
1391
1392
  ]
1392
1393
  },
1393
1394
  isolations: {
1394
1395
  label: "Isolations",
1395
1396
  beats: 2,
1396
- easing: X,
1397
+ easing: D,
1397
1398
  keys: [
1398
1399
  { beat: 0, reset: !0, pose: { lean: -9, headTilt: 11, leftShoulder: 55, leftElbow: -112, rightShoulder: 55, rightElbow: -112, rightHip: 18 }, hands: { left: "fist", right: "fist" } },
1399
1400
  { beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
@@ -1409,7 +1410,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1409
1410
  { move: "pointCombo", beats: 8, mirror: !0 },
1410
1411
  { move: "isolations", beats: 4 }
1411
1412
  ]
1412
- }, Oo = {
1413
+ }, No = {
1413
1414
  label: "Bollywood",
1414
1415
  bpm: 120,
1415
1416
  stance: { leftHip: 10, rightHip: 10 },
@@ -1420,19 +1421,19 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1420
1421
  label: "Screw the bulb, pat the dog",
1421
1422
  beats: 2,
1422
1423
  keys: [
1423
- { 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: { ...N.cupped, roll: -30 }, left: { ...N.flat, turn: 0 } } },
1424
- { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...N.cupped, roll: 30 } } },
1425
- { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...N.cupped, roll: -30 } } },
1426
- { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...N.cupped, roll: 30 } } }
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 } } }
1427
1428
  ]
1428
1429
  },
1429
1430
  thumka: {
1430
1431
  label: "Thumka",
1431
1432
  beats: 2,
1432
1433
  keys: [
1433
- { 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: { ...N.open, turn: 2 } }, easing: X },
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 },
1434
1435
  { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1435
- { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: X },
1436
+ { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: D },
1436
1437
  { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
1437
1438
  ]
1438
1439
  },
@@ -1441,9 +1442,9 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1441
1442
  beats: 4,
1442
1443
  keys: [
1443
1444
  { 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" } },
1444
- { 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: X },
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 },
1445
1446
  { 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" } },
1446
- { 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: X }
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 }
1447
1448
  ]
1448
1449
  }
1449
1450
  },
@@ -1454,7 +1455,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1454
1455
  { move: "thumka", beats: 4, mirror: !0 },
1455
1456
  { move: "lightBulb", beats: 8, mirror: !0 }
1456
1457
  ]
1457
- }, Io = {
1458
+ }, Co = {
1458
1459
  label: "Bhangra",
1459
1460
  bpm: 100,
1460
1461
  stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
@@ -1489,11 +1490,11 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1489
1490
  { move: "basic", beats: 8 },
1490
1491
  { move: "dhamaal", beats: 4 }
1491
1492
  ]
1492
- }, $o = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Bo = {
1493
+ }, Do = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Xo = {
1493
1494
  label: "Bharatanatyam",
1494
1495
  bpm: 80,
1495
1496
  // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1496
- stance: { ...$o, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1497
+ stance: { ...Do, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1497
1498
  expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1498
1499
  hands: { left: "pataka", right: "pataka" },
1499
1500
  groove: { bounce: 0 },
@@ -1535,21 +1536,21 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1535
1536
  { move: "alapadma", beats: 8 },
1536
1537
  { move: "tatta", beats: 4 }
1537
1538
  ]
1538
- }, _o = {
1539
+ }, qo = {
1539
1540
  label: "Charleston",
1540
1541
  bpm: 150,
1541
1542
  stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
1542
1543
  expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
1543
- hands: { left: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } },
1544
+ hands: { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } },
1544
1545
  groove: { bounce: 8, accent: "down" },
1545
1546
  moves: {
1546
1547
  basic: {
1547
1548
  label: "Kick forward, kick back",
1548
1549
  beats: 4,
1549
1550
  keys: [
1550
- { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: X },
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 },
1551
1552
  { beat: 1, reset: !0 },
1552
- { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: X },
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 },
1553
1554
  { beat: 3, reset: !0 }
1554
1555
  ]
1555
1556
  },
@@ -1585,7 +1586,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1585
1586
  { move: "basic", beats: 8, mirror: !0 },
1586
1587
  { move: "twist", beats: 4 }
1587
1588
  ]
1588
- }, Fo = {
1589
+ }, Uo = {
1589
1590
  label: "Tap",
1590
1591
  bpm: 120,
1591
1592
  // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
@@ -1671,7 +1672,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1671
1672
  { beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
1672
1673
  { beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
1673
1674
  // Arms flare on the finish: one up in front, one up behind.
1674
- { 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: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } } },
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 } } },
1675
1676
  { beat: 1.75, reset: !0 }
1676
1677
  ]
1677
1678
  }
@@ -1683,7 +1684,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1683
1684
  { move: "heelToe", beats: 8 },
1684
1685
  { move: "crampRoll", beats: 4 }
1685
1686
  ]
1686
- }, Ro = {
1687
+ }, zo = {
1687
1688
  label: "Popping (glides, moonwalk)",
1688
1689
  bpm: 100,
1689
1690
  stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
@@ -1743,7 +1744,7 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1743
1744
  reset: !0,
1744
1745
  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 },
1745
1746
  hands: { right: "fist", left: "fist" },
1746
- easing: be
1747
+ easing: we
1747
1748
  },
1748
1749
  { beat: 2, pose: { headTilt: -14, lean: -2 } }
1749
1750
  ]
@@ -1756,72 +1757,72 @@ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic",
1756
1757
  { move: "forwardGlide", beats: 8 },
1757
1758
  { move: "toeStand", beats: 4 }
1758
1759
  ]
1759
- }, ce = {
1760
- disco: xo,
1761
- hipHop: Ao,
1762
- breaking: Ko,
1763
- jazz: Po,
1764
- kpop: Wo,
1765
- bollywood: Oo,
1766
- bhangra: Io,
1767
- bharatanatyam: Bo,
1768
- charleston: _o,
1769
- tap: Fo,
1770
- popping: Ro
1771
- }, $e = (e) => Math.min(1, Math.max(0, e));
1772
- function Yo(e) {
1773
- const t = { ...z, turn: e.view }, n = [];
1774
- for (const o of e.keys) {
1775
- const r = n[n.length - 1], l = !r || o.reset ? t : r.pose;
1776
- n.push({ at: o.at, pose: { ...l, ...o.pose }, easing: o.easing });
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 });
1777
1778
  }
1778
1779
  return n;
1779
1780
  }
1780
- function Lo(e) {
1781
- return e - No * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1781
+ function Jo(e) {
1782
+ return e - Vo * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1782
1783
  }
1783
- const No = 0.5;
1784
- function Co(e, t) {
1784
+ const Vo = 0.5;
1785
+ function jo(e, t) {
1785
1786
  if (!(t <= e.takeoff || t >= e.landing))
1786
1787
  return (t - e.takeoff) / (e.landing - e.takeoff);
1787
1788
  }
1788
- function Do(e, t) {
1789
- const n = typeof e == "string" ? ft[e] : e, o = Yo(n), r = $e(t);
1790
- let l = 0;
1791
- for (let g = 0; g < o.length; g++) o[g].at <= r && (l = g);
1792
- const i = o[l], s = o[Math.min(l + 1, o.length - 1)], a = s.at > i.at ? (r - i.at) / (s.at - i.at) : 0, h = we(i.pose, s.pose, _e(s.easing ?? "ease-in-out")($e(a))), f = Co(n, r);
1793
- return f === void 0 ? { ...h, spin: 0, rise: 0 } : {
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);
1794
+ return c === void 0 ? { ...h, spin: 0, rise: 0 } : {
1794
1795
  ...h,
1795
- spin: n.spin * Lo(f),
1796
- rise: 4 * n.height * f * (1 - f)
1796
+ spin: n.spin * Jo(c),
1797
+ rise: 4 * n.height * c * (1 - c)
1797
1798
  };
1798
1799
  }
1799
- function Xo(e, t, n) {
1800
- const o = typeof e == "string" ? ft[e] : e, r = $e(t), l = $e((r - o.takeoff) / (o.landing - o.takeoff));
1801
- return o.travel * n * l;
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;
1802
1803
  }
1803
- function Nr(e, t, n = {}) {
1804
- const o = typeof t == "string" ? ft[t] : t, r = n.start ?? 0, l = n.duration ?? o.duration, i = n.samples ?? 48, s = Array.from({ length: i + 1 }, (f, g) => {
1805
- const p = g / i;
1806
- return { time: r + p * l, progress: p, pose: Do(o, p) };
1807
- }), h = Object.keys(z).filter((f) => s.some((g) => g.pose[f] !== z[f])).map((f) => ({
1808
- id: `${e}-${f}`,
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) => ({
1809
+ id: `${e}-${c}`,
1809
1810
  target: e,
1810
- property: f,
1811
- keyframes: s.map((g) => ({ time: g.time, value: g.pose[f] }))
1811
+ property: c,
1812
+ keyframes: l.map((p) => ({ time: p.time, value: p.pose[c] }))
1812
1813
  }));
1813
- if (n.height !== void 0 && o.travel !== 0) {
1814
- const f = (n.facing ?? 1) < 0 ? -1 : 1;
1814
+ if (n.height !== void 0 && r.travel !== 0) {
1815
+ const c = (n.facing ?? 1) < 0 ? -1 : 1;
1815
1816
  h.push({
1816
1817
  id: `${e}-x`,
1817
1818
  target: e,
1818
1819
  property: "x",
1819
- keyframes: s.map((g) => ({ time: g.time, value: (n.x ?? 0) + f * Xo(o, g.progress, n.height) }))
1820
+ keyframes: l.map((p) => ({ time: p.time, value: (n.x ?? 0) + c * Qo(r, p.progress, n.height) }))
1820
1821
  });
1821
1822
  }
1822
1823
  return h;
1823
1824
  }
1824
- const qo = {
1825
+ const er = {
1825
1826
  leftHip: -55,
1826
1827
  leftKnee: -95,
1827
1828
  rightHip: 55,
@@ -1833,7 +1834,7 @@ const qo = {
1833
1834
  lean: 22,
1834
1835
  stretch: 0.94,
1835
1836
  headTilt: 6
1836
- }, Uo = {
1837
+ }, tr = {
1837
1838
  leftHip: 0,
1838
1839
  leftKnee: 0,
1839
1840
  rightHip: 0,
@@ -1847,7 +1848,7 @@ const qo = {
1847
1848
  lean: 0,
1848
1849
  stretch: 1.08,
1849
1850
  headTilt: 0
1850
- }, Se = {
1851
+ }, Me = {
1851
1852
  leftHip: -128,
1852
1853
  leftKnee: -152,
1853
1854
  rightHip: 128,
@@ -1861,7 +1862,7 @@ const qo = {
1861
1862
  lean: 26,
1862
1863
  stretch: 1,
1863
1864
  headTilt: 14
1864
- }, zo = {
1865
+ }, nr = {
1865
1866
  leftHip: -22,
1866
1867
  leftKnee: -30,
1867
1868
  rightHip: 22,
@@ -1874,7 +1875,7 @@ const qo = {
1874
1875
  rightElbow: 0,
1875
1876
  lean: 8,
1876
1877
  headTilt: 0
1877
- }, Go = {
1878
+ }, or = {
1878
1879
  leftHip: -58,
1879
1880
  leftKnee: -100,
1880
1881
  rightHip: 58,
@@ -1888,42 +1889,42 @@ const qo = {
1888
1889
  lean: 20,
1889
1890
  stretch: 0.93
1890
1891
  };
1891
- function ae(e, t, n, o, r, l = 1300) {
1892
+ function fe(e, t, n, r, o, s = 1300) {
1892
1893
  return {
1893
1894
  label: e,
1894
1895
  view: 1,
1895
1896
  spin: t,
1896
1897
  height: n,
1897
- travel: o,
1898
+ travel: r,
1898
1899
  takeoff: 0.27,
1899
1900
  landing: 0.8,
1900
- duration: l,
1901
+ duration: s,
1901
1902
  keys: [
1902
1903
  { at: 0, reset: !0 },
1903
- { at: 0.16, pose: qo },
1904
- { at: 0.27, pose: Uo, easing: "ease-out-quad" },
1905
- ...r,
1906
- { at: 0.76, pose: zo },
1907
- { at: 0.86, pose: Go, easing: "ease-out-quad" },
1904
+ { at: 0.16, pose: er },
1905
+ { at: 0.27, pose: tr, easing: "ease-out-quad" },
1906
+ ...o,
1907
+ { at: 0.76, pose: nr },
1908
+ { at: 0.86, pose: or, easing: "ease-out-quad" },
1908
1909
  { at: 1, reset: !0 }
1909
1910
  ]
1910
1911
  };
1911
1912
  }
1912
- const ft = {
1913
- frontFlip: ae("Front flip (tuck)", 360, 0.56, 0.35, [
1914
- { at: 0.38, pose: Se, easing: "ease-out-cubic" },
1915
- { at: 0.64, pose: Se }
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 }
1916
1917
  ]),
1917
- backFlip: ae("Back flip (tuck)", -360, 0.58, -0.15, [
1918
- { at: 0.36, pose: { ...Se, lean: 18 }, easing: "ease-out-cubic" },
1919
- { at: 0.64, pose: { ...Se, lean: 18 } }
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 } }
1920
1921
  ]),
1921
- layout: ae("Back layout (straight body)", -360, 0.66, -0.2, [
1922
+ layout: fe("Back layout (straight body)", -360, 0.66, -0.2, [
1922
1923
  // Arched, arms overhead, legs together and long.
1923
1924
  { at: 0.4, pose: { leftHip: 8, rightHip: -8, leftKnee: 0, rightKnee: 0, leftAnkle: 60, rightAnkle: 60, leftShoulder: -178, rightShoulder: 178, lean: -18, headTilt: -14 } },
1924
1925
  { at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
1925
1926
  ], 1400),
1926
- scissorFlip: ae("Scissor flip", 360, 0.6, 0.45, [
1927
+ scissorFlip: fe("Scissor flip", 360, 0.6, 0.45, [
1927
1928
  // The legs scissor through the turn: left kicks high, then they switch.
1928
1929
  { 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" },
1929
1930
  { at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
@@ -1969,7 +1970,7 @@ const ft = {
1969
1970
  ]
1970
1971
  },
1971
1972
  // Leaps: no turn, the shape is the trick.
1972
- splitLeap: ae("Split leap (grand jeté)", 0, 0.36, 0.9, [
1973
+ splitLeap: fe("Split leap (grand jeté)", 0, 0.36, 0.9, [
1973
1974
  // A front split in the air: front leg reaching, back leg long, arms open.
1974
1975
  { 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" },
1975
1976
  { at: 0.64, pose: { lean: 2 } }
@@ -1995,12 +1996,12 @@ const ft = {
1995
1996
  { at: 1, reset: !0 }
1996
1997
  ]
1997
1998
  },
1998
- backHandspring: ae("Back handspring", -360, 0.16, -0.7, [
1999
+ backHandspring: fe("Back handspring", -360, 0.16, -0.7, [
1999
2000
  // Arms reach back overhead to the ground, legs snap over.
2000
2001
  { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
2001
2002
  { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
2002
2003
  ], 1200)
2003
- }, Ce = 0.215, De = 0.205, Jo = 0.065, At = 0.035, Zo = 0.165, jo = 0.155, Qo = 12, Vo = (e) => e * Math.PI / 180, te = {
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 = {
2004
2005
  turn: 0,
2005
2006
  lean: 0,
2006
2007
  side: 0,
@@ -2042,33 +2043,33 @@ const ft = {
2042
2043
  lookX: 0,
2043
2044
  lookY: 0
2044
2045
  };
2045
- function G(e = {}) {
2046
- return { ...te, ...e };
2046
+ function j(e = {}) {
2047
+ return { ...V, ...e };
2047
2048
  }
2048
- const er = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2049
- function Cr(e) {
2049
+ const hr = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2050
+ function ss(e) {
2050
2051
  const t = {};
2051
- for (const [n, o] of Object.entries(e)) {
2052
- const r = n.replace(/(^|\.)(left|right)(\.|$)/, (l, i, s, a) => `${i}${s === "left" ? "right" : "left"}${a}`);
2053
- t[r] = er.has(n) ? -o : o;
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;
2054
2055
  }
2055
2056
  return t;
2056
2057
  }
2057
- function U(e, t) {
2058
+ function G(e, t) {
2058
2059
  const n = {};
2059
- for (const o of ["left", "right"]) for (const [r, l] of Object.entries(t)) n[`${e}.${o}.${r}`] = l;
2060
+ for (const r of ["left", "right"]) for (const [o, s] of Object.entries(t)) n[`${e}.${r}.${o}`] = s;
2060
2061
  return n;
2061
2062
  }
2062
- const tr = {
2063
- rest: te,
2064
- wave: G({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2065
- cheer: G({ ...U("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2066
- point: G({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
2067
- handsOnHips: G({ ...U("arm", { spread: 50, bend: -105, elbow: 0 }), ...U("leg", { spread: 9 }), smile: 0.8 }),
2068
- think: G({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
2069
- shrug: G({ ...U("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
2070
- sit: G({ ...U("leg", { swing: 90, knee: 90, spread: 4 }), ...U("arm", { swing: 25, elbow: 45, spread: 8 }) }),
2071
- kneel: G({
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({
2072
2073
  "leg.left.swing": 90,
2073
2074
  "leg.left.knee": 90,
2074
2075
  // The back thigh leans back a little so its knee meets the ground beside the
@@ -2076,40 +2077,40 @@ const tr = {
2076
2077
  "leg.right.swing": -18,
2077
2078
  "leg.right.knee": 108,
2078
2079
  "leg.right.ankle": 16,
2079
- ...U("arm", { swing: 20, elbow: 30 })
2080
+ ...G("arm", { swing: 20, elbow: 30 })
2080
2081
  }),
2081
- crouch: G({ ...U("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...U("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2082
+ crouch: j({ ...G("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...G("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2082
2083
  // On hands and knees: the back nearly level, arms straight down, the toes
2083
2084
  // pointed back along the ground.
2084
- crawl: G({ lean: 82, "head.nod": -35, ...U("arm", { swing: 80, elbow: 0, spread: 4 }), ...U("leg", { knee: 92, ankle: -88 }) }),
2085
- lieDown: G({ roll: 90, ...U("arm", { spread: 8 }), "head.nod": 0 })
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 })
2086
2087
  };
2087
- function nr(e = {}) {
2088
- const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, o = e.hipWidth ?? 0.022, r = Math.max(0.12, 1 - t - At - (Ce + De)), l = (a) => ({
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) => ({
2089
2090
  id: `arm.${a}`,
2090
2091
  parent: "spine",
2091
2092
  offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
2092
2093
  rest: [0, -1, 0],
2093
2094
  side: a === "left" ? 1 : -1,
2094
2095
  bones: [
2095
- { length: Zo, width: [1.25, 0.9] },
2096
- { length: jo, width: [0.9, 0.75] }
2096
+ { length: sr, width: [1.25, 0.9] },
2097
+ { length: lr, width: [0.9, 0.75] }
2097
2098
  ]
2098
2099
  }), i = (a) => ({
2099
2100
  id: `leg.${a}`,
2100
2101
  parent: null,
2101
- offset: [(a === "left" ? 1 : -1) * o, 0, 0],
2102
+ offset: [(a === "left" ? 1 : -1) * r, 0, 0],
2102
2103
  rest: [0, -1, 0],
2103
2104
  side: a === "left" ? 1 : -1,
2104
2105
  bones: [
2105
- { length: Ce, width: [1.45, 1.05] },
2106
- { length: De, width: [1.05, 0.85] },
2107
- { length: Jo, width: [0.95, 0.7] }
2106
+ { length: Xe, width: [1.45, 1.05] },
2107
+ { length: qe, width: [1.05, 0.85] },
2108
+ { length: rr, width: [0.95, 0.7] }
2108
2109
  ]
2109
- }), s = (a, h) => a[h] ?? te[h] ?? 0;
2110
+ }), l = (a, h) => a[h] ?? V[h] ?? 0;
2110
2111
  return {
2111
2112
  id: "human",
2112
- hipHeight: Ce + De,
2113
+ hipHeight: Xe + qe,
2113
2114
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
2114
2115
  chains: [
2115
2116
  i("left"),
@@ -2119,13 +2120,13 @@ function nr(e = {}) {
2119
2120
  parent: null,
2120
2121
  rest: [0, 1, 0],
2121
2122
  bones: [
2122
- { length: r / 2, width: [1.7, 1.4] },
2123
- { length: r / 2, width: [1.4, 1.1] }
2123
+ { length: o / 2, width: [1.7, 1.4] },
2124
+ { length: o / 2, width: [1.4, 1.1] }
2124
2125
  ]
2125
2126
  },
2126
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: At, width: [1, 0.9] }] },
2127
- l("left"),
2128
- l("right")
2127
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Bt, width: [1, 0.9] }] },
2128
+ s("left"),
2129
+ s("right")
2129
2130
  ],
2130
2131
  head: { on: "neck", size: t },
2131
2132
  contacts: [
@@ -2143,47 +2144,47 @@ function nr(e = {}) {
2143
2144
  ],
2144
2145
  angles(a, h) {
2145
2146
  if (h.id === "spine") {
2146
- const d = -s(a, "lean") / 2, b = s(a, "side") / 2;
2147
+ const f = -l(a, "lean") / 2, g = l(a, "side") / 2;
2147
2148
  return [
2148
- { swing: d, spread: b },
2149
- { swing: d, spread: b }
2149
+ { swing: f, spread: g },
2150
+ { swing: f, spread: g }
2150
2151
  ];
2151
2152
  }
2152
2153
  if (h.id === "neck") return [{ swing: 0, spread: 0 }];
2153
- const [f, g] = h.id.split("."), p = (d) => s(a, `${f}.${g}.${d}`);
2154
- if (f === "arm")
2154
+ const [c, p] = h.id.split("."), d = (f) => l(a, `${c}.${p}.${f}`);
2155
+ if (c === "arm")
2155
2156
  return [
2156
- { swing: p("swing"), spread: p("spread") },
2157
- { swing: p("elbow"), spread: p("bend") }
2157
+ { swing: d("swing"), spread: d("spread") },
2158
+ { swing: d("elbow"), spread: d("bend") }
2158
2159
  ];
2159
- const c = (h.side ?? 1) * p("rotate"), u = 1 - Math.cos(Vo(p("rotate")));
2160
+ const u = (h.side ?? 1) * d("rotate"), b = 1 - Math.cos(ar(d("rotate")));
2160
2161
  return [
2161
- { swing: p("swing"), spread: p("spread"), yaw: c },
2162
- { swing: -p("knee"), spread: 0, yaw: c },
2162
+ { swing: d("swing"), spread: d("spread"), yaw: u },
2163
+ { swing: -d("knee"), spread: 0, yaw: u },
2163
2164
  // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2164
- { swing: 90 + p("ankle") - u * (p("swing") - p("knee")), spread: 0, yaw: (Qo + p("toeOut")) * (h.side ?? 1) }
2165
+ { swing: 90 + d("ankle") - b * (d("swing") - d("knee")), spread: 0, yaw: (ir + d("toeOut")) * (h.side ?? 1) }
2165
2166
  ];
2166
2167
  },
2167
- withAngles(a, h, f) {
2168
- const [g, p] = h.id.split("."), c = (u) => `${g}.${p}.${u}`;
2169
- return g === "arm" ? {
2168
+ withAngles(a, h, c) {
2169
+ const [p, d] = h.id.split("."), u = (b) => `${p}.${d}.${b}`;
2170
+ return p === "arm" ? {
2170
2171
  ...a,
2171
- [c("swing")]: f[0].swing,
2172
- [c("spread")]: f[0].spread,
2173
- [c("elbow")]: f[1].swing,
2174
- [c("bend")]: f[1].spread
2175
- } : g === "leg" ? { ...a, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : 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;
2176
2177
  },
2177
2178
  boneScale(a, h) {
2178
- const f = Math.min(3, Math.max(0.3, s(a, "stretch")));
2179
- return h?.id.startsWith("arm.") ? Math.sqrt(f) : f;
2179
+ const c = Math.min(3, Math.max(0.3, l(a, "stretch")));
2180
+ return h?.id.startsWith("arm.") ? Math.sqrt(c) : c;
2180
2181
  },
2181
2182
  headPose(a) {
2182
- const h = Math.min(3, Math.max(0.3, s(a, "stretch")));
2183
+ const h = Math.min(3, Math.max(0.3, l(a, "stretch")));
2183
2184
  return {
2184
- yaw: s(a, "head.turn"),
2185
- nod: s(a, "head.nod"),
2186
- tilt: s(a, "head.tilt"),
2185
+ yaw: l(a, "head.turn"),
2186
+ nod: l(a, "head.nod"),
2187
+ tilt: l(a, "head.tilt"),
2187
2188
  // The head keeps its area: taller and narrower when stretched.
2188
2189
  sx: 1 / Math.sqrt(h),
2189
2190
  sy: Math.sqrt(h)
@@ -2208,15 +2209,15 @@ function nr(e = {}) {
2208
2209
  }
2209
2210
  };
2210
2211
  }
2211
- function Dr(e) {
2212
+ function ls(e) {
2212
2213
  const t = e.split(".");
2213
2214
  if (t[0] === "hand" && t.length >= 3) {
2214
- const o = `${t[1] === "left" ? "Left" : "Right"} hand`, r = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, l = t.slice(2).join(".");
2215
- return `${o} · ${r[l] ?? l.replace(".curl", " curl").replace(".across", " across")}`;
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")}`;
2216
2217
  }
2217
2218
  if (t.length === 3) {
2218
- const [o, r, l] = t;
2219
- return `${`${r === "left" ? "Left" : "Right"} ${o}`} · ${{
2219
+ const [r, o, s] = t;
2220
+ return `${`${o === "left" ? "Left" : "Right"} ${r}`} · ${{
2220
2221
  swing: "forward / back",
2221
2222
  spread: "out / in",
2222
2223
  elbow: "elbow bend",
@@ -2225,7 +2226,7 @@ function Dr(e) {
2225
2226
  ankle: "foot tilt",
2226
2227
  toeOut: "toes out / in",
2227
2228
  rotate: "turn out at the hip"
2228
- }[l] ?? l}`;
2229
+ }[s] ?? s}`;
2229
2230
  }
2230
2231
  return {
2231
2232
  turn: "View (front → side → back)",
@@ -2250,396 +2251,284 @@ function Dr(e) {
2250
2251
  lookY: "Look up / down"
2251
2252
  }[e] ?? e;
2252
2253
  }
2253
- const or = {
2254
+ const ur = {
2254
2255
  leftEye: "eye.left",
2255
2256
  rightEye: "eye.right",
2256
2257
  leftBrow: "brow.left",
2257
2258
  rightBrow: "brow.right"
2258
- }, Xr = Object.fromEntries(
2259
- Object.entries(J).map(([e, t]) => [
2259
+ }, is = Object.fromEntries(
2260
+ Object.entries(Z).map(([e, t]) => [
2260
2261
  e,
2261
- Object.fromEntries(Object.entries(t).map(([n, o]) => [or[n] ?? n, o]))
2262
+ Object.fromEntries(Object.entries(t).map(([n, r]) => [ur[n] ?? n, r]))
2262
2263
  ])
2263
2264
  );
2264
- function qr(e, t) {
2265
- const n = Math.min(1, Math.max(0, e.turn ?? 0)), o = 1 - n, r = { ...te, turn: n }, l = [
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 = [
2266
2267
  { stick: "right", human: "left", s: 1 },
2267
2268
  { stick: "left", human: "right", s: -1 }
2268
2269
  ];
2269
- for (const { stick: i, human: s, s: a } of l) {
2270
- const h = e[`${i}Shoulder`], f = e[`${i}Elbow`];
2271
- r[`arm.${s}.spread`] = h * o, r[`arm.${s}.swing`] = a * h * n, r[`arm.${s}.bend`] = f * o, r[`arm.${s}.elbow`] = a * f * n;
2272
- const g = e[`${i}Hip`], p = e[`${i}Knee`], c = o + a * n;
2273
- r[`leg.${s}.rotate`] = 90 * o, r[`leg.${s}.spread`] = 0, r[`leg.${s}.swing`] = g * c, r[`leg.${s}.knee`] = p * c, r[`leg.${s}.ankle`] = -(e[`${i}Ankle`] ?? 0), r[`leg.${s}.toeOut`] = (e[`${i}FootOut`] ?? 0) * rr, r[`eye.${s}`] = e[`${i}Eye`], r[`brow.${s}`] = e[`${i}Brow`], t && Object.assign(r, lr(s, t[i] ?? R, e[`${i}Wrist`] ?? 0, n));
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));
2274
2275
  }
2275
- r.lean = e.lean * n, r.side = e.lean * o, r["head.tilt"] = e.headTilt * o, r["head.nod"] = e.headTilt * n;
2276
- for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) r[i] = e[i];
2277
- return r.lift = e.rise ?? 0, r.roll = e.spin ?? 0, r;
2278
- }
2279
- const rr = 70;
2280
- function lr(e, t, n, o) {
2281
- const r = e === "right" ? 1 - o : 1 + o, l = {};
2282
- for (const i of Object.keys(R)) l[`hand.${e}.${i}`] = t[i] ?? R[i];
2283
- return l[`hand.${e}.turn`] = (t.turn ?? 0) - r, l[`hand.${e}.roll`] = (t.roll ?? 0) + n, l;
2284
- }
2285
- function sr(e, t, n = {}, o) {
2286
- const r = n.length ?? 240, l = 9, i = 28, s = r - 22;
2287
- e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(i, -l, s - i, 2 * l), e.fillStyle = "#e8b4a0", e.fillRect(s, -l, r - s, 2 * l), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(i, -l), e.lineTo(i, l), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(i * 0.35, -l * 0.35), e.lineTo(i * 0.35, l * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2288
- const a = [
2289
- [{ x: 0, y: 0 }, { x: i, y: -l }, { x: r, y: -l }, { x: r, y: l }, { x: i, y: l }, { x: 0, y: 0 }],
2290
- [{ x: i, y: -l }, { x: i, y: l }],
2291
- [{ x: s, y: -l }, { x: s, y: l }]
2292
- ];
2293
- for (const h of a) nn(e, h, o);
2294
- e.restore();
2295
- }
2296
- function Vt(e, t, n = {}, o) {
2297
- const r = n.length ?? 90, l = n.thickness ?? 34;
2298
- e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
2299
- const i = -l / 2;
2300
- e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, i, r, l), e.fillStyle = "#e9edf2", e.fillRect(r * 0.45, i, r * 0.55, l), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2301
- const s = [
2302
- { x: 0, y: i },
2303
- { x: r, y: i },
2304
- { x: r, y: -i },
2305
- { x: 0, y: -i },
2306
- { x: 0, y: i }
2307
- ], a = [{ x: r * 0.45, y: i }, { x: r * 0.45, y: -i }];
2308
- if (o)
2309
- o.line(s), o.line(a);
2310
- else
2311
- for (const h of [s, a]) {
2312
- e.beginPath(), e.moveTo(h[0].x, h[0].y);
2313
- for (const f of h.slice(1)) e.lineTo(f.x, f.y);
2314
- e.stroke();
2315
- }
2316
- e.restore();
2317
- }
2318
- const en = 150, ir = { pencil: 44, eraser: 30 };
2319
- function tn(e, t, n = {}, o) {
2320
- const r = n.tool ?? "pencil", l = n.skin ?? "#f1c9a5", i = n.outline ?? "#2f2f33", s = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, f = o ? o.nudge(0.6) : { x: 0, y: 0 }, g = en * s * (1 + 0.05 * a);
2321
- a > 0 && (e.save(), e.fillStyle = i, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * s, 4 * s, 0, 0, Math.PI * 2), e.fill(), e.restore());
2322
- const p = { x: t.x + f.x + 6 * a * s, y: t.y + f.y - 18 * a * s }, c = N.pencilGrip, u = (E) => {
2323
- const T = E.fingers.thumb, A = E.fingers.index, I = E.fingers.middle, W = Kt([T.points[3], A.points[3], I.points[3]]), v = Kt([T.points[1], A.points[0]]), y = (T.depths[3] + A.depths[3] + I.depths[3]) / 3;
2324
- return { pinch: W, direction: Math.atan2(v.y - W.y, v.x - W.x), depth: y };
2325
- }, d = je(c, { size: g }), b = h - u(d).direction, m = je(c, { size: g, angle: b * 180 / Math.PI }), w = u(m), S = ir[r] * s, M = { x: w.pinch.x - Math.cos(h) * S, y: w.pinch.y - Math.sin(h) * S }, H = { x: p.x - M.x, y: p.y - M.y }, k = m.axes.up;
2326
- ar(e, H, { x: -k.x, y: -k.y }, g, n.arm ?? 300 * s, l, n.sleeve ?? "#5b7db1", i), st(e, H, c, {
2327
- size: g,
2328
- angle: b * 180 / Math.PI,
2329
- skin: l,
2330
- ink: i,
2331
- lineWidth: 3 * s,
2332
- prop: {
2333
- depth: w.depth,
2334
- draw: () => {
2335
- e.save(), e.translate(p.x, p.y), e.scale(s, s), r === "eraser" ? Vt(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: i }, o) : sr(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: i }, o), e.restore();
2336
- }
2337
- }
2338
- });
2276
+ o.lean = e.lean * n, o.side = e.lean * r, o["head.tilt"] = e.headTilt * r, o["head.nod"] = e.headTilt * n;
2277
+ for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
2278
+ return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
2279
+ }
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;
2285
+ }
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];
2290
+ }
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];
2294
+ }
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];
2298
+ }
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);
2302
+ return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2339
2303
  }
2340
- const Kt = (e) => ({
2341
- x: e.reduce((t, n) => t + n.x, 0) / e.length,
2342
- y: e.reduce((t, n) => t + n.y, 0) / e.length
2343
- });
2344
- function ar(e, t, n, o, r, l, i, s) {
2345
- const a = { x: -n.y, y: n.x }, h = o * 0.15, f = (d, b, m) => ({
2346
- x: t.x + n.x * d + a.x * b * m,
2347
- y: t.y + n.y * d + a.y * b * m
2348
- }), g = f(r, 0, 0), p = (d) => {
2349
- const b = e.createLinearGradient(t.x, t.y, g.x, g.y);
2350
- return b.addColorStop(0, d), b.addColorStop(0.6, d), b.addColorStop(1, hr(d)), b;
2351
- }, c = Math.min(o * 0.55, r * 0.35);
2352
- e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (o / en), e.beginPath(), e.moveTo(f(-o * 0.1, -1, h).x, f(-o * 0.1, -1, h).y), e.lineTo(f(c + 4, -1, h * 1.1).x, f(c + 4, -1, h * 1.1).y), e.lineTo(f(c + 4, 1, h * 1.1).x, f(c + 4, 1, h * 1.1).y), e.lineTo(f(-o * 0.1, 1, h).x, f(-o * 0.1, 1, h).y), e.closePath(), e.fillStyle = l, e.fill(), e.strokeStyle = s, e.beginPath(), e.moveTo(f(0, -1, h).x, f(0, -1, h).y), e.lineTo(f(c, -1, h * 1.1).x, f(c, -1, h * 1.1).y), e.moveTo(f(0, 1, h).x, f(0, 1, h).y), e.lineTo(f(c, 1, h * 1.1).x, f(c, 1, h * 1.1).y), e.stroke();
2353
- const u = [f(c, -1, h * 1.3), f(r, -1, h * 1.5), f(r, 1, h * 1.5), f(c, 1, h * 1.3)];
2354
- e.beginPath(), u.forEach((d, b) => b ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = p(i), e.fill(), e.strokeStyle = p(s), e.beginPath(), e.moveTo(u[1].x, u[1].y), e.lineTo(u[0].x, u[0].y), e.lineTo(u[3].x, u[3].y), e.lineTo(u[2].x, u[2].y), e.stroke(), e.restore();
2355
- }
2356
- function Ur(e, t, n = {}) {
2357
- const o = n.offstage ?? { x: 2e3, y: 1400 }, r = n.enter ?? 450, l = n.exit ?? 450, i = n.linger ?? 1500, s = [...e].filter((d) => d.path.length > 0).sort((d, b) => d.start - b.start), a = (d) => d.tool ?? "pencil", h = (d) => {
2358
- const b = Math.min(1, Math.max(0, d));
2359
- return b * b * (3 - 2 * b);
2360
- }, f = (d, b, m) => ({ x: d.x + (b.x - d.x) * m, y: d.y + (b.y - d.y) * m }), g = s.find((d) => t >= d.start && t <= d.end);
2361
- if (g) {
2362
- const d = g.end - g.start, b = d > 0 ? (t - g.start) / d : 1;
2363
- return { at: rt(g.path, b), tool: a(g), lift: 0, drawing: !0 };
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 };
2364
2317
  }
2365
- const p = [...s].reverse().find((d) => d.end < t), c = s.find((d) => d.start > t), u = (d) => d.path[d.path.length - 1];
2366
- if (p && c && c.start - p.end <= i) {
2367
- const d = (t - p.end) / (c.start - p.end), b = d < 0.5 ? a(p) : a(c);
2368
- return { at: f(u(p), c.path[0], h(d)), tool: b, lift: Math.sin(Math.PI * d), drawing: !1 };
2369
- }
2370
- if (c && c.start - t <= r) {
2371
- const d = 1 - (c.start - t) / r;
2372
- return { at: f(o, c.path[0], h(d)), tool: a(c), lift: 1 - h(d), drawing: !1 };
2373
- }
2374
- if (p && t - p.end <= l) {
2375
- const d = (t - p.end) / l;
2376
- return { at: f(u(p), o, h(d)), tool: a(p), lift: h(d), drawing: !1 };
2377
- }
2378
- return null;
2379
- }
2380
- function zr(e, t, n, o = 0.08, r = 32) {
2381
- const l = Math.PI * 2 * (1 + o), i = [];
2382
- for (let s = 0; s <= r; s++) {
2383
- const a = -Math.PI / 2 + l * s / r;
2384
- i.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
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)
2331
+ };
2385
2332
  }
2386
- return i;
2387
- }
2388
- function Gr(e) {
2389
- const { path: t } = e, n = t.map((s) => s.x), o = t.map((s) => s.y), r = Math.min(...n), l = Math.min(...o), i = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
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,
2341
+ rx: a,
2342
+ ry: h,
2343
+ 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)];
2351
+ };
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) }));
2390
2358
  return {
2391
- type: "custom",
2392
- x: r,
2393
- y: l,
2394
- width: Math.max(1, Math.max(...n) - r),
2395
- height: Math.max(1, Math.max(...o) - l),
2396
- props: { draw: 0 },
2397
- draw(s, a, h) {
2398
- const f = Math.min(1, Math.max(0, Number(a.props?.draw ?? 0)));
2399
- s.translate(-r, -l), s.strokeStyle = e.color ?? "#2f2f33", s.lineWidth = e.lineWidth ?? 5, s.lineCap = "round", s.lineJoin = "round";
2400
- const g = e.sketch ? Ge(s, e.sketch, h) : void 0;
2401
- f > 0 && (g ? e.smooth ? g.curve(t, f) : g.line(t, f) : nn(s, It(t, f))), i && f > 0 && f < 1 && tn(s, rt(t, f), i, g);
2402
- }
2359
+ height: r,
2360
+ 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))
2403
2366
  };
2404
2367
  }
2405
- function hr(e) {
2406
- const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2407
- if (!t) return "rgba(0, 0, 0, 0)";
2408
- const n = t[1].length === 3 ? [...t[1]].map((i) => i + i).join("") : t[1], [o, r, l] = [0, 2, 4].map((i) => parseInt(n.slice(i, i + 2), 16));
2409
- return `rgba(${o}, ${r}, ${l}, 0)`;
2410
- }
2411
- function nn(e, t, n) {
2412
- if (!(t.length < 2)) {
2413
- if (n) return n.line(t);
2414
- e.beginPath(), e.moveTo(t[0].x, t[0].y);
2415
- for (const o of t.slice(1)) e.lineTo(o.x, o.y);
2416
- e.stroke();
2417
- }
2418
- }
2419
- const Ee = 1e5;
2420
- function Jr(e, t, n, o, r = 6) {
2421
- const l = [], i = Math.max(1, Math.round(r));
2422
- for (let s = 0; s <= i; s++)
2423
- l.push({ x: s % 2 === 0 ? e : e + n, y: t + o * s / i });
2424
- return l;
2425
- }
2426
- function on(e, t, n, o) {
2427
- if (o <= 0 || t.length === 0) return;
2428
- const r = It(t, o), l = n / 2, i = (s) => {
2429
- e.beginPath(), e.rect(-Ee, -Ee, 2 * Ee, 2 * Ee), s(), e.clip("evenodd");
2368
+ const ot = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], sn = (e) => {
2369
+ const t = Math.hypot(e[0], e[1], e[2]) || 1;
2370
+ return [e[0] / t, e[1] / t, e[2] / t];
2371
+ };
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)];
2430
2379
  };
2431
- for (const s of r)
2432
- i(() => {
2433
- e.moveTo(s.x + l, s.y), e.arc(s.x, s.y, l, 0, Math.PI * 2);
2434
- });
2435
- for (let s = 1; s < r.length; s++) {
2436
- const a = r[s - 1], h = r[s], f = Math.hypot(h.x - a.x, h.y - a.y);
2437
- if (f === 0) continue;
2438
- const g = -(h.y - a.y) / f * l, p = (h.x - a.x) / f * l;
2439
- i(() => {
2440
- e.moveTo(a.x + g, a.y + p), e.lineTo(h.x + g, h.y + p), e.lineTo(h.x - g, h.y - p), e.lineTo(a.x - g, a.y - p), e.closePath();
2441
- });
2442
- }
2443
- }
2444
- function Zr(e, t, n, o, r) {
2445
- e.save(), on(e, t, n, o), r(), e.restore();
2446
- }
2447
- function jr(e, t) {
2448
- const n = t.width ?? 40, o = t.hand === !0 ? {} : t.hand || void 0, r = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
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]];
2449
2383
  return {
2450
- ...e,
2451
- props: { ...e.props, erase: 0 },
2452
- draw(l, i, s) {
2453
- const a = Number(i.props?.erase ?? 0);
2454
- if (l.save(), on(l, t.path, n, a), e.draw(l, i, s), l.restore(), !r || a <= 0 || a >= 1) return;
2455
- const h = rt(t.path, a);
2456
- o ? tn(l, h, { ...o, tool: "eraser" }) : Vt(l, h, r);
2457
- }
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 }
2458
2388
  };
2459
2389
  }
2460
- const oe = (e) => e * Math.PI / 180;
2461
- function rn([e, t, n], o) {
2462
- const r = Math.cos(o), l = Math.sin(o);
2463
- return [e, t * r + n * l, -t * l + n * r];
2464
- }
2465
- function ln([e, t, n], o) {
2466
- const r = Math.cos(o), l = Math.sin(o);
2467
- return [e * r - t * l, e * l + t * r, n];
2468
- }
2469
- function me([e, t, n], o) {
2470
- const r = Math.cos(o), l = Math.sin(o);
2471
- return [e * r + n * l, t, -e * l + n * r];
2472
- }
2473
- const Xe = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Pt = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Ae = (e, t) => ln(rn(e, t.swing), t.spread);
2474
- function qe(e, t) {
2475
- const n = me(e, t);
2476
- return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2477
- }
2478
- function ct(e, t, n) {
2479
- const o = n.height, r = oe(90 * (t.turn ?? 0)), i = [0, e.hipHeight * o * (e.boneScale?.(t, null) ?? 1), 0], s = {};
2480
- for (const y of e.chains) {
2481
- const x = y.parent ? s[y.parent] : void 0;
2482
- if (y.parent && !x) throw new Error(`body plan ${e.id}: chain ${y.id} comes before its parent ${y.parent}`);
2483
- const O = y.at ?? (x ? x.joints3.length - 1 : 0), K = x ? x.joints3[O] : i, P = x ? x.frames[Math.max(0, O - 1)] : { swing: 0, spread: 0 }, B = y.offset ? Xe(K, Ae(Pt(y.offset, o), P)) : K, $ = y.side ?? 1, _ = e.boneScale?.(t, y) ?? 1, C = e.angles(t, y), L = [B], Q = [];
2484
- let ne = P.swing, Fe = P.spread;
2485
- y.bones.forEach((an, ut) => {
2486
- const Re = C[ut] ?? { swing: 0, spread: 0 };
2487
- ne += oe(Re.swing), Fe += oe(Re.spread) * $, Q.push({ swing: ne, spread: Fe });
2488
- const hn = me(Ae(y.rest, { swing: ne, spread: Fe }), oe(Re.yaw ?? 0));
2489
- L.push(Xe(L[ut], Pt(hn, an.length * o * _)));
2490
- }), s[y.id] = { joints3: L, frames: Q };
2491
- }
2492
- const a = s[e.head.on], h = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, f = a.frames[a.frames.length - 1], g = e.head.size / 2 * o, p = g * h.sx, c = g * h.sy, u = (y) => Ae(me(rn(ln(y, -oe(h.tilt)), -oe(h.nod)), oe(h.yaw)), f), d = Xe(a.joints3[a.joints3.length - 1], u([0, c, 0])), b = {};
2493
- for (const y of e.chains) {
2494
- const { joints3: x, frames: O } = s[y.id], K = x.map((P) => qe(P, r));
2495
- b[y.id] = {
2496
- id: y.id,
2497
- joints3: x,
2498
- frames: O,
2499
- points: K.map((P) => P.point),
2500
- depths: K.map((P) => P.depth)
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)
2501
2407
  };
2502
2408
  }
2503
- const m = qe(d, r), w = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((y) => me(u(y), r)), S = qe(i, r).point, M = oe(t.roll ?? 0), H = (y) => {
2504
- const x = y.x - S.x, O = y.y - S.y;
2505
- return { x: S.x + x * Math.cos(M) - O * Math.sin(M), y: S.y + x * Math.sin(M) + O * Math.cos(M) };
2506
- }, k = ([y, x, O]) => [y * Math.cos(M) + x * Math.sin(M), -y * Math.sin(M) + x * Math.cos(M), O];
2507
- for (const y of Object.values(b)) y.points = y.points.map(H);
2508
- const E = {
2509
- center: H(m.point),
2510
- depth: m.depth,
2511
- rx: p,
2512
- ry: c,
2513
- angle: 0,
2514
- axes: w.map(k)
2515
- }, T = E.axes[1];
2516
- E.angle = Math.atan2(T[0], T[1]);
2517
- const A = (y) => {
2518
- if ("head" in y) return { x: E.center.x + T[0] * c, y: E.center.y - T[1] * c };
2519
- const x = b[y.chain];
2520
- return x.points[Math.min(y.joint, x.points.length - 1)];
2521
- };
2522
- let I = 0;
2523
- (n.contact ?? "ground") === "ground" && (I = -Math.max(...e.contacts.map((y) => A(y).y))), I -= (t.lift ?? 0) * o;
2524
- const W = (y) => ({ x: y.x, y: y.y + I });
2525
- for (const y of Object.values(b)) y.points = y.points.map(W);
2526
- E.center = W(E.center);
2527
- const v = e.contacts.map((y) => ({ spec: y, point: A(y) }));
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 }));
2528
2417
  return {
2529
- height: o,
2530
- view: r,
2531
- chains: b,
2532
- head: E,
2533
- hip: W(H(S)),
2534
- contacts: v,
2535
- groundY: Math.max(...v.map((y) => y.point.y))
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))
2536
2425
  };
2537
2426
  }
2538
- function sn(e, [t, n, o]) {
2539
- const [r, l, i] = e.axes, s = [
2540
- r[0] * t * e.rx + l[0] * n * e.ry + i[0] * o * e.rx,
2541
- r[1] * t * e.rx + l[1] * n * e.ry + i[1] * o * e.rx,
2542
- r[2] * t * e.rx + l[2] * n * e.ry + i[2] * o * e.rx
2543
- ], a = Math.hypot(t, n, o) || 1, h = (r[2] * t + l[2] * n + i[2] * o) / a;
2544
- return { point: { x: e.center.x + s[0], y: e.center.y - s[1] }, depth: e.depth + s[2], facing: h };
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 };
2545
2434
  }
2546
- const He = (e) => e * 180 / Math.PI, he = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ue = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], de = (e) => Math.hypot(e[0], e[1], e[2]), nt = (e) => {
2547
- const t = de(e) || 1;
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;
2548
2437
  return [e[0] / t, e[1] / t, e[2] / t];
2549
- }, Me = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2550
- function Wt(e) {
2551
- const [t, n, o] = nt(e);
2552
- return { swing: Math.asin(Math.max(-1, Math.min(1, o))), spread: Math.atan2(t, -n) };
2553
- }
2554
- function fr(e, t, n, o, r) {
2555
- const l = e.chains.find((I) => I.id === n);
2556
- if (!l) throw new Error(`reach: no chain ${n} in ${e.id}`);
2557
- if (l.bones.length < 2 || l.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
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`);
2558
2447
  if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
2559
- const i = ct(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: r.height, contact: "none" }), s = i.chains[n], a = s.joints3[0], h = de(he(s.joints3[1], s.joints3[0])), f = de(he(s.joints3[2], s.joints3[1])), g = l.parent ? i.chains[l.parent].frames[Math.max(0, (l.at ?? i.chains[l.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, p = he(o, a), c = Math.min(h + f - 1e-6, Math.max(Math.abs(h - f) + 1e-6, de(p))), u = nt(p), d = l.parent !== null, b = Ae(l.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), g);
2560
- let m = he(b, [u[0] * Ue(b, u), u[1] * Ue(b, u), u[2] * Ue(b, u)]);
2561
- de(m) < 1e-6 && (m = me([1, 0, 0], 0)), m = nt(m);
2562
- const w = (h * h + c * c - f * f) / (2 * h * c), S = Math.sqrt(Math.max(0, 1 - w * w)), M = [
2563
- a[0] + h * (w * u[0] + S * m[0]),
2564
- a[1] + h * (w * u[1] + S * m[1]),
2565
- a[2] + h * (w * u[2] + S * m[2])
2566
- ], H = [a[0] + u[0] * c, a[1] + u[1] * c, a[2] + u[2] * c], k = l.side ?? 1, E = Wt(he(M, a)), T = Wt(he(H, M)), A = [
2567
- { swing: He(Me(E.swing - g.swing)), spread: He(Me(E.spread - g.spread)) * k },
2568
- { swing: He(Me(T.swing - E.swing)), spread: He(Me(T.spread - E.spread)) * k }
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 }
2569
2458
  ];
2570
- return e.withAngles(t, l, A);
2459
+ return e.withAngles(t, s, S);
2571
2460
  }
2572
- const cr = 0.34, re = 0.12, j = -0.4, ee = (e, t, n) => e[t] ?? n, gr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), ur = 0.45, dr = 0.35, pr = 0.7;
2573
- function Be(e, t, n) {
2574
- const o = (c) => Math.sqrt(Math.max(0, 1 - c.x * c.x - c.y * c.y)), r = sn(e, [n.x, n.y, o(n)]).facing, l = e.axes[2], i = Math.atan2(l[0], l[2]), s = Math.cos(i), a = s >= 0 ? 1 : -1, h = a * Math.max(dr, Math.abs(s)), f = a * Math.max(pr, Math.abs(s)), g = Math.cos(e.angle), p = Math.sin(e.angle);
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);
2575
2464
  return {
2576
- facing: r,
2577
- points: t.map((c) => {
2578
- const u = ur * Math.sin(i) + n.x * h + (c.x - n.x) * f, d = c.y + l[1] * o(c), b = u * e.rx, m = d * e.ry;
2579
- return { x: e.center.x + b * g + m * p, y: e.center.y + b * p - m * g };
2465
+ 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 };
2580
2469
  })
2581
2470
  };
2582
2471
  }
2583
- const ve = (e, t, n, o = 12) => Array.from({ length: o + 1 }, (r, l) => {
2584
- const i = l / o, s = 1 - i;
2585
- return { x: s * s * e.x + 2 * s * i * t.x + i * i * n.x, y: s * s * e.y + 2 * s * i * t.y + i * i * n.y };
2586
- }), ze = (e, t, n, o, r = 16) => Array.from({ length: r }, (l, i) => {
2587
- const s = Math.PI * 2 * i / r;
2588
- return { x: e + Math.cos(s) * n, y: t + Math.sin(s) * o };
2589
- }), Ot = 0.05;
2590
- function br(e, t, n, o) {
2591
- const r = Math.max(1, Math.min(o * 0.6, 0.14 * t.rx)), l = (m, w) => Be(t, m, w).points, i = (m, w) => Be(t, [], { x: m, y: w }).facing, s = ee(n, "smile", 0), a = ee(n, "blink", 0), h = ee(n, "lookX", 0), f = ee(n, "lookY", 0), g = ee(n, "browTilt", 0);
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);
2592
2481
  for (const m of [1, -1]) {
2593
- const w = m === 1 ? "left" : "right", S = cr * m;
2594
- if (i(S, re) < Ot) continue;
2595
- const M = { x: S, y: re }, H = gr(ee(n, `eye.${w}`, 1), a);
2596
- if (H < 0.2) {
2597
- const A = s > 0.5 ? 0.12 : -0.06;
2598
- e.line(l(ve({ x: S - 0.12, y: re }, { x: S, y: re + A }, { x: S + 0.12, y: re }), M), r);
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);
2599
2488
  } else {
2600
- if (H > 1.2) {
2601
- const v = 0.13 * H;
2602
- e.shape(l(ze(S, re, v * 0.85, v), M), "#ffffff", r);
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);
2603
2492
  }
2604
- const A = H > 1.2 ? 0.075 : 0.1, I = S + h * 0.08, W = re - f * 0.07;
2605
- e.shape(l(ze(I, W, A, A * 1.1 * Math.min(H, 1)), M), e.ink, 0);
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);
2606
2495
  }
2607
- const k = re + 0.3 + ee(n, `brow.${w}`, 0) * 0.14 + Math.max(0, H - 1) * 0.12, E = { x: S + m * 0.13, y: k }, T = { x: S - m * 0.13, y: k + g * 0.1 };
2608
- e.line(l([E, { x: (E.x + T.x) / 2, y: (E.y + T.y) / 2 }, T], { x: S, y: k }), r);
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);
2609
2498
  }
2610
- const p = { x: 0, y: j };
2611
- if (i(0, j) < -Ot) return;
2612
- const c = 0.25 * Math.max(0.3, ee(n, "mouthWidth", 1)), u = Math.min(1, Math.max(0, ee(n, "mouth", 0)));
2613
- if (u <= 0.05) {
2614
- e.line(l(ve({ x: -c, y: j }, { x: 0, y: j - s * 0.25 }, { x: c, y: j }), p), r);
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);
2615
2504
  return;
2616
2505
  }
2617
- const d = 0.3 * u;
2618
- let b;
2619
- if (s > 0.3) {
2620
- const m = j + 0.05;
2621
- b = [...ve({ x: c, y: m }, { x: 0, y: j - d * 2 }, { x: -c, y: m })];
2622
- } else if (s < -0.3) {
2623
- const m = j - d * 0.6;
2624
- b = [...ve({ x: c, y: m }, { x: 0, y: j + d * 1.4 }, { x: -c, y: m })];
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 })];
2625
2514
  } else
2626
- b = ze(0, j, c * 0.8, d);
2627
- e.shape(l(b, p), e.ink, 0);
2515
+ g = Ge(0, te, u * 0.8, f);
2516
+ e.shape(s(g, d), e.ink, 0);
2628
2517
  }
2629
- function Qr(e = {}) {
2630
- const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", o = e.look ?? "clean", r = e.height ?? 300, l = n === "stick";
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";
2631
2520
  return {
2632
- plan: e.plan ?? nr({
2521
+ plan: e.plan ?? fr({
2633
2522
  headSize: e.headSize ?? (t ? 0.3 : 0.24),
2634
- shoulderWidth: l ? 0 : e.shoulderWidth ?? 0.06,
2635
- hipWidth: l ? 0 : e.hipWidth ?? 0.022
2523
+ shoulderWidth: s ? 0 : e.shoulderWidth ?? 0.06,
2524
+ hipWidth: s ? 0 : e.hipWidth ?? 0.022
2636
2525
  }),
2637
2526
  figure: n,
2638
- look: o,
2639
- height: r,
2640
- lineWidth: e.lineWidth ?? r * (t ? 0.045 : 0.022),
2641
- ink: e.ink ?? (o === "pencil" ? "#2f2f33" : "#1e293b"),
2642
- skin: e.skin ?? (o === "pencil" ? "none" : "#ffffff"),
2527
+ look: r,
2528
+ height: o,
2529
+ 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"),
2643
2532
  seed: e.seed ?? 1,
2644
2533
  pencil: e.pencil ?? {},
2645
2534
  layers: e.layers ?? {},
@@ -2649,106 +2538,110 @@ function Qr(e = {}) {
2649
2538
  handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
2650
2539
  };
2651
2540
  }
2652
- function Vr(e, t, n, o) {
2653
- const { point: r, facing: l } = sn(e, [t, n, o]);
2654
- return { point: r, facing: l };
2655
- }
2656
- const ot = (e) => e.rest[1] < -0.5, mr = 0.3;
2657
- function yr(e, t, n) {
2658
- return e.figure === "stick" ? ot(t) ? n.slice(0, 3) : n : ot(t) && n.length >= 3 ? fe(n[0], n[1], n[2], mr) : n.length === 3 ? fe(n[0], n[1], n[2], 1) : n;
2659
- }
2660
- function gt(e, t) {
2661
- const n = e.plan.id === "human" ? { ...te, ...t } : t, o = ct(e.plan, n, { height: e.height, contact: e.contact }), r = {}, l = {}, i = {}, s = 0.01 * e.height;
2662
- e.plan.chains.forEach((c) => {
2663
- const u = o.chains[c.id];
2664
- r[c.id] = u.points;
2665
- const d = u.depths.reduce((S, M) => S + M, 0) / u.depths.length, b = c.parent ? o.chains[c.parent] : void 0, m = b ? b.depths[c.at ?? b.depths.length - 1] : 0, w = d - m;
2666
- i[c.id] = Math.abs(w) < s ? 0 : w, l[c.id] = { points: yr(e, c, u.points), depth: d };
2667
- }), l.head = { points: [o.head.center], depth: o.head.depth }, i.head = 0;
2668
- const a = [...e.plan.chains.map((c) => c.id), "head"], h = [...a].sort((c, u) => i[c] - i[u] || a.indexOf(c) - a.indexOf(u)), f = { hip: o.hip };
2669
- for (const [c, [u, d]] of Object.entries(e.plan.landmarks ?? {})) {
2670
- const b = o.chains[u]?.points;
2671
- b && (f[c] = b[Math.min(d, b.length - 1)]);
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)]);
2672
2565
  }
2673
- const g = {};
2674
- for (const [c, u] of Object.entries(f)) g[c] = u.y >= o.groundY - 0.01 * e.height;
2566
+ const c = {};
2567
+ for (const [d, u] of Object.entries(h)) c[d] = u.y >= n.groundY - 0.01 * e.height;
2675
2568
  const p = {
2676
2569
  height: e.height,
2677
2570
  lineWidth: e.lineWidth,
2678
- turn: n.turn ?? 0,
2679
- points: f,
2571
+ turn: t.turn ?? 0,
2572
+ points: h,
2680
2573
  chains: r,
2681
- parts: l,
2682
- head: o.head,
2683
- groundY: o.groundY,
2684
- grounded: g
2574
+ parts: o,
2575
+ head: n.head,
2576
+ groundY: n.groundY,
2577
+ grounded: c
2685
2578
  };
2686
- return { skeleton: o, joints: p, order: h };
2579
+ return { skeleton: n, joints: p, order: a };
2687
2580
  }
2688
- function wr(e, t) {
2689
- return gt(e, t).joints;
2581
+ function vr(e, t) {
2582
+ return bt(e, t).joints;
2690
2583
  }
2691
- function kr(e, t, n) {
2692
- const { head: o } = n;
2693
- e.guideEllipse(o.center.x, o.center.y, o.rx * 1.03, o.ry * 1.03, o.angle);
2694
- const r = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), l = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), i = Be(o, r, { x: 0, y: 0 });
2695
- i.facing > 0 && e.guide(i.points), e.guide(Be(o, l, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2696
- const s = t.lineWidth * 0.9;
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;
2697
2590
  for (const a of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
2698
2591
  const h = n.points[a];
2699
- h && e.guideEllipse(h.x, h.y, s, s, 0);
2592
+ h && e.guideEllipse(h.x, h.y, l, l, 0);
2700
2593
  }
2701
2594
  }
2702
- function Sr(e, t, n, o, r, l) {
2595
+ function Tr(e, t, n, r, o, s) {
2703
2596
  const i = n.lineWidth;
2704
- if (r === "head") {
2705
- const { head: c } = o, u = n.skin === "none" ? null : n.skin;
2706
- t.ellipse(c.center.x, c.center.y, c.rx, c.ry, c.angle, u, i), t.look !== "silhouette" && br(t, c, l, i);
2597
+ 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);
2707
2600
  return;
2708
2601
  }
2709
- const s = n.plan.chains.find((c) => c.id === r), a = o.chains[r], h = o.parts[r].points;
2602
+ const l = n.plan.chains.find((u) => u.id === o), a = r.chains[o], h = r.parts[o].points;
2710
2603
  if (n.figure === "stick") {
2711
- if (r === "neck") return;
2712
- const c = r === "spine" ? [...a, ...o.chains.neck?.slice(1) ?? []] : h;
2713
- t.line(c, i);
2604
+ if (o === "neck") return;
2605
+ const u = o === "spine" ? [...a, ...r.chains.neck?.slice(1) ?? []] : h;
2606
+ t.line(u, i);
2714
2607
  return;
2715
2608
  }
2716
- const f = (c, u) => [s.bones[c].width[0] * i, s.bones[u].width[1] * i];
2717
- if (ot(s)) {
2718
- const [c, u] = f(0, 1);
2719
- if (t.limb(h, c, u), s.bones.length >= 3)
2720
- t.limb([a[2], a[3]], s.bones[2].width[0] * i, s.bones[2].width[1] * i);
2721
- else if (n.hands === "cartoon" && r.startsWith("arm."))
2722
- Hr(e, t, n, a, r.endsWith(".left") ? "left" : "right", l);
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);
2614
+ else if (n.hands === "cartoon" && o.startsWith("arm."))
2615
+ Kr(e, t, n, a, o.endsWith(".left") ? "left" : "right", s);
2723
2616
  else {
2724
- const d = a[a.length - 1];
2725
- t.dot(d.x, d.y, i * 0.62);
2617
+ const f = a[a.length - 1];
2618
+ t.dot(f.x, f.y, i * 0.62);
2726
2619
  }
2727
2620
  return;
2728
2621
  }
2729
- if (r === "spine") {
2730
- const c = o.points["hip.left"], u = o.points["hip.right"];
2731
- c && u && Math.hypot(c.x - u.x, c.y - u.y) > 0.5 && t.limb([c, u], i * 1.3, i * 1.3);
2732
- const [d, b] = f(0, s.bones.length - 1);
2733
- t.limb(h, d, b);
2734
- const m = o.points["shoulder.left"], w = o.points["shoulder.right"];
2735
- m && w && Math.hypot(m.x - w.x, m.y - w.y) > 0.5 && t.limb(fe(m, a[a.length - 1], w, 1, 10), i * 1.15, i * 1.15);
2622
+ 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);
2736
2629
  return;
2737
2630
  }
2738
- const [g, p] = f(0, s.bones.length - 1);
2739
- t.limb(h, g, p);
2740
- }
2741
- function Er(e, t) {
2742
- const n = `hand.${t}.`, o = {};
2743
- for (const [i, s] of Object.entries(e)) i.startsWith(n) && (o[i.slice(n.length)] = s);
2744
- const r = e.turn ?? 0, l = t === "right" ? 1 - r : 1 + r;
2745
- return { ...R, ...o, turn: l + (o.turn ?? 0) };
2746
- }
2747
- function Hr(e, t, n, o, r, l) {
2748
- const i = o[o.length - 1], s = o[o.length - 2], a = Math.atan2(i.x - s.x, -(i.y - s.y)) * 180 / Math.PI;
2749
- st(e, i, Er(l, r), {
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), {
2750
2643
  size: n.handSize * n.height,
2751
- side: r,
2644
+ side: o,
2752
2645
  angle: a,
2753
2646
  pen: t,
2754
2647
  skin: n.skin === "none" ? "#ffffff" : n.skin,
@@ -2759,8 +2652,24 @@ function Hr(e, t, n, o, r, l) {
2759
2652
  lineWidth: n.lineWidth * 0.3
2760
2653
  });
2761
2654
  }
2762
- function Mr(e, t, n, o = 0) {
2763
- const r = t.plan.id === "human" ? { ...te, ...n } : n, { joints: l, order: i } = gt(t, r), s = $t(e, {
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);
2658
+ }
2659
+ function cn(e, t) {
2660
+ const n = t / e.height;
2661
+ return { ...e, height: t, lineWidth: e.lineWidth * n };
2662
+ }
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;
2666
+ }
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);
2670
+ }
2671
+ function fn(e, t, n, r, o) {
2672
+ const { joints: s, order: i } = r, l = Yt(e, {
2764
2673
  look: t.look,
2765
2674
  ink: t.ink,
2766
2675
  lineWidth: t.lineWidth,
@@ -2768,197 +2677,470 @@ function Mr(e, t, n, o = 0) {
2768
2677
  time: o,
2769
2678
  pencil: t.pencil
2770
2679
  }), a = (h) => {
2771
- h && (e.save(), h(e, l, s, o), e.restore());
2680
+ h && (e.save(), h(e, s, l, o), e.restore());
2772
2681
  };
2773
- e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && kr(s, t, l), a(t.layers.behind);
2682
+ e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && xr(l, t, s), a(t.layers.behind);
2774
2683
  for (const h of i) {
2775
- const f = t.layers.parts?.[h];
2776
- a(f?.under), Sr(e, s, t, l, h, r), a(f?.over);
2684
+ const c = t.layers.parts?.[h];
2685
+ a(c?.under), Tr(e, l, t, s, h, n), a(c?.over);
2777
2686
  }
2778
2687
  a(t.layers.front), e.restore();
2779
2688
  }
2780
- function el(e, t, n) {
2781
- const o = { ...e };
2782
- for (const [r, l] of Object.entries(t)) {
2783
- const i = e[r] ?? l;
2784
- o[r] = i + (l - i) * n;
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;
2785
2694
  }
2786
- return o;
2695
+ return r;
2787
2696
  }
2788
- function tl(e, t, n, o) {
2789
- const r = e.plan.id === "human" ? { ...te, ...t } : t;
2790
- let l;
2791
- if (Array.isArray(o))
2792
- l = o;
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;
2793
2702
  else {
2794
- const { skeleton: i } = gt(e, r), s = ct(e.plan, { ...r, roll: 0 }, { height: e.height, contact: "none" }), a = (r.roll ?? 0) * Math.PI / 180, h = o.x - i.hip.x, f = o.y - i.hip.y, g = s.hip.x + h * Math.cos(-a) - f * Math.sin(-a), p = s.hip.y + h * Math.sin(-a) + f * Math.cos(-a), c = Math.PI / 2 * (r.turn ?? 0), u = o.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], d = Math.cos(c), b = Math.sin(c);
2795
- l = [g * d - u * b, -p, g * b + u * d];
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];
2796
2705
  }
2797
- return fr(e.plan, r, n, l, { height: e.height });
2706
+ return pr(e.plan, o, n, s, { height: e.height });
2798
2707
  }
2799
- function nl(e) {
2800
- const { character: t } = e, n = t.height * 0.8, o = t.height, r = t.plan.id === "human" ? te : {};
2708
+ function ds(e) {
2709
+ const { character: t } = e, n = t.height * 0.8, r = t.height, o = t.plan.id === "human" ? V : {};
2801
2710
  return {
2802
2711
  type: "custom",
2803
2712
  x: e.x - n / 2,
2804
- y: e.y - o,
2713
+ y: e.y - r,
2805
2714
  width: n,
2806
- height: o,
2807
- props: { ...r, ...e.pose },
2715
+ height: r,
2716
+ props: { ...o, ...e.pose },
2808
2717
  character: t,
2809
- draw(l, i, s) {
2810
- l.translate(n / 2, o), Mr(l, t, i.props, s);
2718
+ draw(s, i, l) {
2719
+ s.translate(n / 2, r), Pr(s, t, i.props, l);
2811
2720
  }
2812
2721
  };
2813
2722
  }
2814
- function vr(e, t, n) {
2815
- const o = (l) => ({ x: l.x + t, y: l.y + n }), r = (l) => Object.fromEntries(Object.entries(l).map(([i, s]) => [i, s.map(o)]));
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)]));
2816
2725
  return {
2817
2726
  ...e,
2818
- points: Object.fromEntries(Object.entries(e.points).map(([l, i]) => [l, o(i)])),
2819
- chains: r(e.chains),
2820
- parts: Object.fromEntries(Object.entries(e.parts).map(([l, i]) => [l, { ...i, points: i.points.map(o) }])),
2821
- head: { ...e.head, center: o(e.head.center) },
2727
+ points: Object.fromEntries(Object.entries(e.points).map(([s, i]) => [s, r(i)])),
2728
+ 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) },
2822
2731
  groundY: e.groundY + n
2823
2732
  };
2824
2733
  }
2825
- function ol(e, t, n) {
2826
- const o = e.character;
2827
- if (!o) throw new Error("characterAt: the target was not made by characterTarget");
2828
- const r = { ...e.props };
2829
- let l = 0, i = 0;
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");
2737
+ const o = { ...e.props };
2738
+ let s = 0, i = 0;
2830
2739
  for (const [a, h] of t.state?.values.get(n) ?? [])
2831
- typeof h == "number" && (a === "x" || a === "motionPathX" ? l = h : a === "y" || a === "motionPathY" ? i = h : a in r && (r[a] = h));
2832
- const s = wr(o, r);
2833
- return { pose: r, joints: vr(s, e.x + l + e.width / 2, e.y + i + e.height) };
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) };
2834
2743
  }
2835
- function rl(e, t, n = te) {
2836
- const o = [];
2837
- return t.forEach((l, i) => {
2838
- const s = i === 0 ? n : o[i - 1], a = typeof l.pose == "string" ? tr[l.pose] : void 0;
2839
- o.push(a ? { ...a, turn: s.turn ?? 0 } : { ...s, ...l.pose });
2840
- }), Object.keys(n).filter((l) => o.some((i) => (i[l] ?? n[l]) !== n[l])).map((l) => ({
2841
- id: `${e}-${l}`,
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}`,
2842
2751
  target: e,
2843
- property: l,
2844
- keyframes: t.map((i, s) => ({
2752
+ property: s,
2753
+ keyframes: t.map((i, l) => ({
2845
2754
  time: i.time,
2846
- value: o[s][l] ?? n[l],
2755
+ value: r[l][s] ?? n[s],
2847
2756
  ...i.easing ? { easing: i.easing } : {}
2848
2757
  }))
2849
2758
  }));
2850
2759
  }
2851
- const Tr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
2852
- function ll(e = {}) {
2853
- const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", o = (s) => s.lineWidth * 0.45, r = (s, a, h) => {
2854
- const f = s.parts[`leg.${h}`].points;
2855
- a.shape(Te(f, s.height * 0.08, s.height * 0.05), n, o(s));
2856
- }, l = (s, a) => {
2857
- const h = s.chains.spine, f = h[0], g = h[h.length - 1], p = { x: f.x - (g.x - f.x) * 0.25, y: f.y - (g.y - f.y) * 0.25 };
2858
- a.shape(Te([p, ...s.parts.spine.points], s.height * 0.15, s.height * 0.14), t, o(s));
2859
- }, i = (s, a, h) => {
2860
- const f = s.parts[`arm.${h}`].points, g = f[0], p = s.chains.spine[s.chains.spine.length - 1], u = [{ x: g.x + (p.x - g.x) * 0.45, y: g.y + (p.y - g.y) * 0.45 }, ...Tr(f, 0, 0.45)], d = Te(u, s.height * 0.085, s.height * 0.06), b = u.length, m = d.slice(0, b), w = d.slice(b).reverse();
2861
- a.shape(d, t, 0);
2862
- const S = (k) => Math.hypot(k[1].x - p.x, k[1].y - p.y), [M, H] = S(m) > S(w) ? [m, w] : [w, m];
2863
- a.line(M.slice(1), o(s)), a.line(H.slice(Math.ceil(b * 0.45)), o(s)), a.line([m[b - 1], w[b - 1]], o(s));
2760
+ const Ir = /* @__PURE__ */ new Set([
2761
+ "x",
2762
+ "y",
2763
+ "z",
2764
+ "position",
2765
+ "rotateX",
2766
+ "rotateY",
2767
+ "rotateZ",
2768
+ "quaternion",
2769
+ "scale",
2770
+ "scaleX",
2771
+ "scaleY",
2772
+ "scaleZ",
2773
+ "visible",
2774
+ "opacity",
2775
+ "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;
2781
+ });
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);
2800
+ }
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);
2803
+ }
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);
2809
+ }
2810
+ return p;
2811
+ }
2812
+ const bs = {
2813
+ kind: "character",
2814
+ validate(e) {
2815
+ const t = e;
2816
+ return t.height !== void 0 && !(t.height > 0) ? ["a character's height must be positive"] : [];
2817
+ },
2818
+ prepare(e) {
2819
+ return {
2820
+ who: Er({ ...e.character, height: 1 }),
2821
+ cylinder: wt(Sn(1, 1, 16)),
2822
+ sphere: wt(kn(1, 20))
2823
+ };
2824
+ },
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 };
2838
+ }
2839
+ return {
2840
+ drawables: [
2841
+ ...f,
2842
+ {
2843
+ depth: b,
2844
+ draw(g, m) {
2845
+ g.lineCap = "round", g.lineJoin = "round", Wr(g, a, h, d, { height: c, time: m.time });
2846
+ }
2847
+ }
2848
+ ]
2849
+ };
2850
+ }
2851
+ };
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";
2855
+ 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 }]
2859
+ ];
2860
+ for (const h of a) pn(e, h, r);
2861
+ e.restore();
2862
+ }
2863
+ function un(e, t, n = {}, r) {
2864
+ const o = n.length ?? 90, s = n.thickness ?? 34;
2865
+ 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);
2877
+ else
2878
+ for (const h of [l, a]) {
2879
+ e.beginPath(), e.moveTo(h[0].x, h[0].y);
2880
+ for (const c of h.slice(1)) e.lineTo(c.x, c.y);
2881
+ e.stroke();
2882
+ }
2883
+ e.restore();
2884
+ }
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,
2899
+ prop: {
2900
+ depth: k.depth,
2901
+ 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();
2903
+ }
2904
+ }
2905
+ });
2906
+ }
2907
+ const Ft = (e) => ({
2908
+ x: e.reduce((t, n) => t + n.x, 0) / e.length,
2909
+ y: e.reduce((t, n) => t + n.y, 0) / e.length
2910
+ });
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 };
2944
+ }
2945
+ return null;
2946
+ }
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 });
2952
+ }
2953
+ return i;
2954
+ }
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;
2957
+ return {
2958
+ type: "custom",
2959
+ x: o,
2960
+ y: s,
2961
+ width: Math.max(1, Math.max(...n) - o),
2962
+ height: Math.max(1, Math.max(...r) - s),
2963
+ props: { draw: 0 },
2964
+ draw(l, a, h) {
2965
+ 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);
2969
+ }
2970
+ };
2971
+ }
2972
+ function Nr(e) {
2973
+ const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2974
+ 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)`;
2977
+ }
2978
+ function pn(e, t, n) {
2979
+ if (!(t.length < 2)) {
2980
+ if (n) return n.line(t);
2981
+ e.beginPath(), e.moveTo(t[0].x, t[0].y);
2982
+ for (const r of t.slice(1)) e.lineTo(r.x, r.y);
2983
+ e.stroke();
2984
+ }
2985
+ }
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;
2992
+ }
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");
2997
+ };
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);
3001
+ });
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);
3004
+ 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();
3008
+ });
3009
+ }
3010
+ }
3011
+ function Ss(e, t, n, r, o) {
3012
+ e.save(), bn(e, t, n, r), o(), e.restore();
3013
+ }
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;
3016
+ return {
3017
+ ...e,
3018
+ 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);
3024
+ }
3025
+ };
3026
+ }
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));
2864
3040
  };
2865
3041
  return {
2866
3042
  parts: {
2867
- "leg.left": { over: (s, a, h) => r(a, h, "left") },
2868
- "leg.right": { over: (s, a, h) => r(a, h, "right") },
2869
- spine: { over: (s, a, h) => l(a, h) },
2870
- "arm.left": { over: (s, a, h) => i(a, h, "left") },
2871
- "arm.right": { over: (s, a, h) => i(a, h, "right") }
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") }
2872
3048
  }
2873
3049
  };
2874
3050
  }
2875
3051
  export {
2876
- ce as DANCE_STYLES,
2877
- J as EXPRESSIONS,
2878
- mn as FINGERS,
2879
- ft as FLIPS,
2880
- R as HAND_REST,
2881
- N as HAND_SHAPES,
2882
- Xr as HUMAN_EXPRESSIONS,
2883
- tr as HUMAN_POSES,
2884
- te as HUMAN_REST,
2885
- vt as MUDRAS,
2886
- Fn as POSES,
2887
- z as REST_POSE,
2888
- Eo as applyGroove,
2889
- Lr as bakeDanceTracks,
2890
- ll as basicOutfit,
2891
- Fr as beatAt,
2892
- we as blendPose,
2893
- fn as boilFrame,
2894
- Qr as character,
2895
- ol as characterAt,
2896
- Er as characterHandPose,
2897
- wr as characterJoints,
2898
- rl as characterPoseTracks,
2899
- nl as characterTarget,
2900
- zr as circlePath,
2901
- on as clipErased,
2902
- $t as createPen,
2903
- at as danceFrame,
2904
- Br as dancePose,
2905
- tt as danceStance,
2906
- _r as danceTaps,
2907
- Yr as danceTracks,
2908
- Ne as danceTravel,
2909
- To as danceTravelTrack,
2910
- Rr as dancer,
2911
- st as drawCartoonHand,
2912
- Mr as drawCharacter,
2913
- Vt as drawEraser,
2914
- tn as drawHand,
2915
- sr as drawPencil,
2916
- co as drawStickFigure,
2917
- Gr as drawnPathTarget,
2918
- dt as ellipsePoints,
2919
- jr as erasable,
2920
- Do as flipPose,
2921
- Nr as flipTracks,
2922
- Xo as flipTravel,
2923
- Ur as handAt,
2924
- je as handJoints,
2925
- Kn as handJointsAt,
2926
- F as handPose,
2927
- Oe as handProp,
2928
- Wr as headPoint,
2929
- Dr as humanFieldLabel,
2930
- nr as humanPlan,
2931
- G as humanPose,
2932
- vr as jointsInScene,
2933
- fo as jointsToScene,
2934
- Cr as mirrorHumanPose,
2935
- ko as mirrorPose,
2936
- ye as mixHandPoses,
2937
- el as mixPoses,
2938
- It as partialPath,
2939
- al as pathLength,
2940
- rt as pointAlong,
2941
- Vr as pointOnHead,
2942
- D as pose,
2943
- $r as poseTracks,
2944
- tl as reachCharacter,
2945
- Jt as resolveStickFrame,
2946
- go as resolveStickPose,
2947
- ie as rotateAbout,
2948
- ht as routineBeats,
2949
- fe as rubberLimb,
2950
- Jr as scrubPath,
2951
- Pr as seatHeight,
2952
- Ge as sketchPen,
2953
- Ir as stickFigureAt,
2954
- ho as stickFigureJoints,
2955
- Or as stickFigureTarget,
2956
- qr as stickToHuman,
2957
- Kr as strideLength,
2958
- Ln as talkingMouth,
2959
- lt as taperedLine,
2960
- Te as taperedOutline,
2961
- Yn as walkPose,
2962
- Zr as withErased,
2963
- _t as withExpression
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
2964
3146
  };