@algorisys/tinyfly 0.108.0 → 0.109.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.
@@ -0,0 +1,4205 @@
1
+ import { createRandom as bs, hashSeed as Mo, unknownName as Ms, TrackPlayer as Pn } from "@algorisys/tinyfly";
2
+ import { c as ks, s as An } from "./sketch-CYPUbk3Q.js";
3
+ import { c as vs, b as Es } from "./shots-DR_ViiAC.js";
4
+ const ht = (t) => ({ description: t, unit: "degrees" }), st = (t, e = 0, n = 1) => ({ description: t, unit: `${e}..${n}`, min: e, max: n }), Ss = {
5
+ lean: ht("Upper body tipped about the hips (+ toward the way it faces)"),
6
+ bend: ht("Line of action: the spine curved (+ curls forward, − arches back)"),
7
+ headTilt: ht("Head tilt"),
8
+ leftShoulder: ht("Left upper arm: 0 hangs down, 90 straight out to its side, 180 straight up; in profile, forward is negative for the left arm"),
9
+ rightShoulder: ht("Right upper arm: 0 hangs down, 90 straight out (forward, in profile), 180 straight up"),
10
+ leftElbow: ht("Left elbow bend, added to the upper arm"),
11
+ rightElbow: ht("Right elbow bend, added to the upper arm"),
12
+ leftHip: ht("Left thigh: 0 straight down; in profile negative is forward"),
13
+ rightHip: ht("Right thigh: 0 straight down; in profile positive is forward"),
14
+ leftKnee: ht("Left knee bend (negative folds the shin back)"),
15
+ rightKnee: ht("Right knee bend (positive folds the shin back)"),
16
+ leftWrist: ht("Left wrist bend, added to the forearm"),
17
+ rightWrist: ht("Right wrist bend, added to the forearm"),
18
+ leftAnkle: ht("Left ankle: + points the toe down (tiptoe), − onto the heel"),
19
+ rightAnkle: ht("Right ankle: + points the toe down (tiptoe), − onto the heel"),
20
+ leftFootOut: st("Left foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in", -1, 1),
21
+ rightFootOut: st("Right foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in", -1, 1),
22
+ mouth: st("Mouth open: 0 closed, 1 wide open"),
23
+ smile: st("−1 frown, 0 flat, 1 smile", -1, 1),
24
+ mouthWidth: { description: "Mouth width: 1 normal, 0.5 pursed, 1.5 wide", unit: "factor", min: 0.3, max: 2 },
25
+ blink: st("Eyes closed by a blink: 0 open, 1 shut"),
26
+ leftEye: { description: "Left eye openness: 0 shut, 1 normal, 1.6 wide", unit: "factor", min: 0, max: 2 },
27
+ rightEye: { description: "Right eye openness: 0 shut, 1 normal, 1.6 wide", unit: "factor", min: 0, max: 2 },
28
+ leftBrow: st("Left eyebrow: −1 lowered, 0 rest, 1 raised", -1, 1),
29
+ rightBrow: st("Right eyebrow: −1 lowered, 0 rest, 1 raised", -1, 1),
30
+ browTilt: st("Eyebrow slant: −1 angry, 1 worried", -1, 1),
31
+ lookX: st("Eyes look across: + the way it faces", -1, 1),
32
+ lookY: st("Eyes look down (+) or up (−)", -1, 1),
33
+ stretch: { description: "Squash and stretch: 1 normal, above taller (a jump), below squashed (a landing)", unit: "factor", min: 0.3, max: 3 },
34
+ turn: st("0 front-on, 1 in profile, turned the way it faces"),
35
+ sit: st("0 standing, 1 seated"),
36
+ spin: ht("Whole body turned about the hips: + rolls forward (a front flip), 360 a full turn"),
37
+ rise: { description: "Lift off the ground, as a fraction of its height (the arc of a jump)", unit: "× height" }
38
+ }, Ps = {
39
+ walk: { description: "Walk-cycle phase, in strides: animate 0 → n for n strides", unit: "strides" },
40
+ walking: st("How much of the walk cycle is applied (0 standing)"),
41
+ gait: { description: "How it walks: a gait name (walk, bouncy, doubleBounce, sneak, strut, tired, run, shove); a string track switches it", kind: "string" },
42
+ talk: st("How much the mouth chatters"),
43
+ rubber: st("Limbs from jointed (0) to rubber hose (1)"),
44
+ facing: { description: "Which way it faces: 1 right, −1 left (key the flip while turn is near 0)", unit: "±1", min: -1, max: 1 },
45
+ beat: { description: "Beats into its dance (with a dance)", unit: "beats" },
46
+ dancing: st("How much of the dance is applied")
47
+ }, As = {
48
+ "thumb.curl": st("Thumb curled in"),
49
+ "thumb.across": st("Thumb across the palm"),
50
+ "index.curl": st("Index finger curled"),
51
+ "middle.curl": st("Middle finger curled"),
52
+ "ring.curl": st("Ring finger curled"),
53
+ "pinky.curl": st("Little finger curled"),
54
+ spread: st("Fingers spread apart"),
55
+ turn: ht("Hand turned about the forearm"),
56
+ bend: ht("Hand bent at the wrist, palm-ward"),
57
+ tilt: ht("Hand tilted sideways"),
58
+ roll: ht("Hand rolled to show the back or the palm")
59
+ };
60
+ let ko;
61
+ function _a(t) {
62
+ ko = t;
63
+ }
64
+ function Os(t) {
65
+ return ko?.(t) ?? {};
66
+ }
67
+ function ut(t, e, n) {
68
+ const s = t.length;
69
+ if (s < 2) return [];
70
+ const o = [], r = [], i = (a) => e + (n - e) * a / (s - 1);
71
+ return t.forEach((a, l) => {
72
+ const c = t[Math.max(0, l - 1)], h = t[Math.min(s - 1, l + 1)], f = Math.hypot(h.x - c.x, h.y - c.y) || 1, y = i(l) / 2, u = -(h.y - c.y) / f * y, g = (h.x - c.x) / f * y;
73
+ o.push({ x: a.x + u, y: a.y + g }), r.push({ x: a.x - u, y: a.y - g });
74
+ }), [...o, ...r.reverse()];
75
+ }
76
+ function mn(t, e, n, s) {
77
+ const o = e.length;
78
+ if (o < 2) return;
79
+ const r = ut(e, n, s), i = (a) => n + (s - n) * a / (o - 1);
80
+ t.beginPath(), t.moveTo(r[0].x, r[0].y);
81
+ for (const a of r.slice(1)) t.lineTo(a.x, a.y);
82
+ t.closePath(), t.fill(), e.forEach((a, l) => {
83
+ l !== 0 && l !== o - 1 && o > 3 || (t.beginPath(), t.arc(a.x, a.y, i(l) / 2, 0, Math.PI * 2), t.fill());
84
+ });
85
+ }
86
+ function ne(t, e, n, s, o = 16) {
87
+ const r = { x: 2 * e.x - (t.x + n.x) / 2, y: 2 * e.y - (t.y + n.y) / 2 }, i = [];
88
+ for (let a = 0; a <= o; a++) {
89
+ const l = a / o, c = l < 0.5 ? { x: t.x + (e.x - t.x) * 2 * l, y: t.y + (e.y - t.y) * 2 * l } : { x: e.x + (n.x - e.x) * (2 * l - 1), y: e.y + (n.y - e.y) * (2 * l - 1) }, h = 1 - l, f = {
90
+ x: h * h * t.x + 2 * h * l * r.x + l * l * n.x,
91
+ y: h * h * t.y + 2 * h * l * r.y + l * l * n.y
92
+ };
93
+ i.push({ x: c.x + (f.x - c.x) * s, y: c.y + (f.y - c.y) * s });
94
+ }
95
+ return i;
96
+ }
97
+ function tn(t, e, n, s, o, r = 0, i = 1, a = 40) {
98
+ const l = Math.cos(o), c = Math.sin(o);
99
+ return Array.from({ length: a + 1 }, (h, f) => {
100
+ const y = r + Math.PI * 2 * i * f / a, u = Math.cos(y) * n, g = Math.sin(y) * s;
101
+ return { x: t + u * l - g * c, y: e + u * c + g * l };
102
+ });
103
+ }
104
+ function pn(t, e) {
105
+ return e.look === "pencil" ? Ts(t, e) : vo(t, e.ink, e.look);
106
+ }
107
+ function Oe(t, e, n = !1) {
108
+ t.beginPath(), t.moveTo(e[0].x, e[0].y);
109
+ for (const s of e.slice(1)) t.lineTo(s.x, s.y);
110
+ n && t.closePath();
111
+ }
112
+ function ge(t, e) {
113
+ return e.look === "silhouette" ? vo(t, e.ink, "silhouette", !1) : e;
114
+ }
115
+ function vo(t, e, n, s = !0) {
116
+ const o = n === "silhouette", r = o ? 1.25 : 1;
117
+ return {
118
+ look: n,
119
+ ink: e,
120
+ limb(i, a, l) {
121
+ t.fillStyle = e, mn(t, i, a * r, l * r);
122
+ },
123
+ line(i, a) {
124
+ i.length < 2 || (t.strokeStyle = e, t.lineWidth = a * r, t.lineCap = "round", t.lineJoin = "round", Oe(t, i), t.stroke());
125
+ },
126
+ shape(i, a, l) {
127
+ Oe(t, i, !0), (a !== null || o && s) && (t.fillStyle = o ? e : a, t.fill()), !(l <= 0) && (t.strokeStyle = e, t.lineWidth = l * r, t.lineJoin = "round", t.stroke());
128
+ },
129
+ ellipse(i, a, l, c, h, f, y) {
130
+ t.beginPath(), t.ellipse(i, a, l, c, h, 0, Math.PI * 2), (f !== null || o && s) && (t.fillStyle = o ? e : f, t.fill()), !(y <= 0) && (t.strokeStyle = e, t.lineWidth = y * r, t.stroke());
131
+ },
132
+ dot(i, a, l) {
133
+ t.fillStyle = e, t.beginPath(), t.arc(i, a, l * r, 0, Math.PI * 2), t.fill();
134
+ },
135
+ guide() {
136
+ },
137
+ guideEllipse() {
138
+ }
139
+ };
140
+ }
141
+ function Is(t, e) {
142
+ const n = [t[0]];
143
+ let s = 0;
144
+ for (let i = 1; i < t.length; i++) {
145
+ const a = t[i - 1], l = t[i], c = Math.hypot(l.x - a.x, l.y - a.y);
146
+ let h = e - s;
147
+ for (; h < c; ) {
148
+ const f = h / c;
149
+ n.push({ x: a.x + (l.x - a.x) * f, y: a.y + (l.y - a.y) * f }), h += e;
150
+ }
151
+ s = c - (h - e);
152
+ }
153
+ const o = t[t.length - 1], r = n[n.length - 1];
154
+ return Math.hypot(o.x - r.x, o.y - r.y) > e * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
155
+ }
156
+ function Ws(t, e) {
157
+ const n = t.length;
158
+ return t.map((s, o) => {
159
+ const r = t[Math.max(0, o - 1)], i = t[Math.min(n - 1, o + 1)], a = Math.hypot(i.x - r.x, i.y - r.y) || 1, l = e(n === 1 ? 0 : o / (n - 1));
160
+ return { x: s.x - (i.y - r.y) / a * l, y: s.y + (i.x - r.x) / a * l };
161
+ });
162
+ }
163
+ function On(t) {
164
+ const e = [0.6, 1.4, 2.9].map((s) => ({
165
+ frequency: s * (0.8 + t.next() * 0.4),
166
+ phase: t.next() * Math.PI * 2,
167
+ amount: 0.5 + t.next() * 0.5
168
+ })), n = e.reduce((s, o) => s + o.amount, 0);
169
+ return (s) => e.reduce((o, r) => o + r.amount * Math.sin(Math.PI * 2 * r.frequency * s + r.phase), 0) / n;
170
+ }
171
+ function Ts(t, e) {
172
+ const n = e.pencil ?? {}, s = e.ink, o = n.roughness ?? Math.max(1, e.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), a = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), l = ks(e.time, n.boil ?? 8);
173
+ let c = 0;
174
+ const h = (g, m, d = !1) => bs(Mo(`${e.seed}:${d ? "paper" : l}:${g}:${m}`)), f = (g, m, d, x, b, k = 0) => {
175
+ if (g.length < 2) return;
176
+ const v = g.slice(1).reduce((C, w, E) => C + Math.hypot(w.x - g[E].x, w.y - g[E].y), 0);
177
+ let P = Is(g, Math.max(1.5, Math.min(e.lineWidth * 0.8, v / 24)));
178
+ if (k > 0 && P.length >= 2) {
179
+ const [C, w] = [P[P.length - 2], P[P.length - 1]], E = Math.hypot(w.x - C.x, w.y - C.y) || 1;
180
+ P = [...P, { x: w.x + (w.x - C.x) / E * k, y: w.y + (w.y - C.y) / E * k }];
181
+ }
182
+ const R = On(d), O = On(d), $ = P.length, A = [], z = [];
183
+ P.forEach((C, w) => {
184
+ const E = $ === 1 ? 0 : w / ($ - 1), H = P[Math.max(0, w - 1)], N = P[Math.min($ - 1, w + 1)], D = Math.hypot(N.x - H.x, N.y - H.y) || 1, X = -(N.y - H.y) / D, K = (N.x - H.x) / D, q = R(E) * b, J = Math.min(1, E / 0.08, (1 - E) / 0.08), j = (0.55 + 0.45 * Math.sqrt(Math.max(0, J))) * (1 + i * O(E)), Q = Math.max(0.3, m(E) * j / 2), nt = C.x + X * q, lt = C.y + K * q;
185
+ A.push({ x: nt + X * Q, y: lt + K * Q }), z.push({ x: nt - X * Q, y: lt - K * Q });
186
+ }), t.save(), t.globalAlpha *= x, t.fillStyle = s, Oe(t, [...A, ...z.reverse()], !0), t.fill(), t.restore();
187
+ }, y = (g, m) => {
188
+ const d = c++, x = h(d, 99, !0);
189
+ if (x.next() < a) {
190
+ const P = (x.next() * 2 - 1) * e.lineWidth * 1.4, R = (x.next() * 2 - 1) * e.lineWidth * 1.4, O = g.map(($) => ({ x: $.x + P, y: $.y + R }));
191
+ f(O, ($) => m($) * 1.8, h(d, 98, !0), 0.035, o), f(O, ($) => m($) * 0.45, h(d, 97, !0), 0.12, o * 1.5);
192
+ }
193
+ const b = g.slice(1).reduce((P, R, O) => P + Math.hypot(R.x - g[O].x, R.y - g[O].y), 0), k = m(0.5) > 4 && b > m(0.5) * 6, v = k ? [-0.3, 0.3, 0] : [0];
194
+ for (let P = 0; P < r; P++) {
195
+ const R = P === 0;
196
+ v.forEach((O, $) => {
197
+ const A = h(d, P * 10 + $), z = O === 0 ? g : Ws(g, (w) => m(w) * O * Math.sqrt(Math.sin(Math.PI * w))), C = !R && O === 0 ? e.lineWidth * (0.3 + A.next() * 0.8) : 0;
198
+ f(z, (w) => m(w) * (k ? 0.5 : 1) * (R ? 1 : 0.6), A, R ? 0.85 : 0.45, o * (R ? 0.6 : 1), C);
199
+ });
200
+ }
201
+ }, u = (g, m, d, x, b, k) => {
202
+ const P = h(c, 50).next() * Math.PI * 2;
203
+ y(tn(g, m, d, x, b, P, 1.08, 48), () => k);
204
+ };
205
+ return {
206
+ look: "pencil",
207
+ ink: s,
208
+ limb(g, m, d) {
209
+ y(g, (x) => m + (d - m) * x);
210
+ },
211
+ line(g, m) {
212
+ y(g, () => m);
213
+ },
214
+ shape(g, m, d) {
215
+ m !== null && (t.save(), t.globalAlpha *= 0.88, t.fillStyle = m, Oe(t, g, !0), t.fill(), t.restore()), d > 0 && y([...g, g[0]], () => d);
216
+ },
217
+ ellipse(g, m, d, x, b, k, v) {
218
+ k !== null && (t.save(), t.globalAlpha *= 0.9, t.fillStyle = k, t.beginPath(), t.ellipse(g, m, d, x, b, 0, Math.PI * 2), t.fill(), t.restore()), u(g, m, d, x, b, v);
219
+ },
220
+ dot(g, m, d) {
221
+ t.save(), t.globalAlpha *= 0.9, t.fillStyle = s, t.beginPath(), t.arc(g, m, d, 0, Math.PI * 2), t.fill(), t.restore();
222
+ },
223
+ guide(g) {
224
+ if (n.construction === !1 || g.length < 2) return;
225
+ const m = c++;
226
+ f(g, () => Math.max(0.6, e.lineWidth * 0.18), h(m, 0), 0.28, o * 1.2, e.lineWidth);
227
+ },
228
+ guideEllipse(g, m, d, x, b) {
229
+ if (n.construction === !1) return;
230
+ const k = c++, v = h(k, 0), P = tn(g, m, d, x, b, v.next() * Math.PI * 2, 1.12, 48);
231
+ f(P, () => Math.max(0.6, e.lineWidth * 0.18), v, 0.28, o * 1.5);
232
+ }
233
+ };
234
+ }
235
+ const Hs = ["thumb", "index", "middle", "ring", "pinky"], Ot = {
236
+ "thumb.curl": 0.15,
237
+ "thumb.across": 0.15,
238
+ "index.curl": 0.12,
239
+ "middle.curl": 0.16,
240
+ "ring.curl": 0.2,
241
+ "pinky.curl": 0.25,
242
+ spread: 0.25,
243
+ turn: 0,
244
+ bend: 0,
245
+ tilt: 0,
246
+ roll: 0
247
+ };
248
+ function wt(t = {}) {
249
+ return { ...Ot, ...t };
250
+ }
251
+ const bt = (t, e, n, s, o) => ({
252
+ "thumb.curl": t,
253
+ "index.curl": e,
254
+ "middle.curl": n,
255
+ "ring.curl": s,
256
+ "pinky.curl": o
257
+ }), La = {
258
+ relaxed: Ot,
259
+ open: wt({ ...bt(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
260
+ spread: wt({ ...bt(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
261
+ flat: wt({ ...bt(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
262
+ fist: wt({ ...bt(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
263
+ point: wt({ ...bt(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
264
+ /** The fist on its side, knuckles toward the viewer, the thumb up */
265
+ thumbsUp: wt({ ...bt(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
266
+ peace: wt({ ...bt(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
267
+ ok: wt({ ...bt(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
268
+ pinch: wt({ ...bt(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
269
+ cupped: wt({ ...bt(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
270
+ wave: wt({ ...bt(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
271
+ /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
272
+ pencilGrip: wt({ ...bt(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
273
+ /** Holding a handle, a cup or a bar: every finger wrapped round it */
274
+ hold: wt({ ...bt(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
275
+ };
276
+ function $s(t, e, n) {
277
+ const s = { ...t };
278
+ for (const [o, r] of Object.entries(e)) {
279
+ const i = t[o] ?? r;
280
+ s[o] = i + (r - i) * n;
281
+ }
282
+ return s;
283
+ }
284
+ const _s = {
285
+ index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
286
+ middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
287
+ ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
288
+ pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
289
+ }, Ls = {
290
+ index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
291
+ middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
292
+ pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
293
+ }, Tt = {
294
+ base: [-0.11, 0.1, -0.05],
295
+ bones: [0.2, 0.15, 0.12],
296
+ widths: [0.2, 0.145, 0.135],
297
+ /** Where the thumb points with `across` 0 and 1 */
298
+ out: [-0.7, 0.68, -0.22],
299
+ across: [0.35, 0.5, -0.8]
300
+ }, Bs = [82, 100, 62], Rs = [48, 72], Cs = 3, Fs = 13, Ns = 0.035, Ys = -0.075, zs = [
301
+ [-0.17, 0],
302
+ [-0.215, 0.12],
303
+ [-0.235, 0.26],
304
+ [-0.225, 0.4],
305
+ [-0.185, 0.49],
306
+ [-0.075, 0.525],
307
+ [0.05, 0.51],
308
+ [0.16, 0.465],
309
+ [0.215, 0.4],
310
+ [0.225, 0.26],
311
+ [0.2, 0.1],
312
+ [0.16, 0]
313
+ ], Rt = (t) => t * Math.PI / 180, en = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], Se = (t, e) => [t[0] * e, t[1] * e, t[2] * e], nn = (t, e) => [t[1] * e[2] - t[2] * e[1], t[2] * e[0] - t[0] * e[2], t[0] * e[1] - t[1] * e[0]], re = (t) => {
314
+ const e = Math.hypot(t[0], t[1], t[2]) || 1;
315
+ return [t[0] / e, t[1] / e, t[2] / e];
316
+ };
317
+ function Dt(t, e, n) {
318
+ const s = Math.cos(n), o = Math.sin(n), r = nn(e, t), i = e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
319
+ return [
320
+ t[0] * s + r[0] * o + e[0] * i * (1 - s),
321
+ t[1] * s + r[1] * o + e[1] * i * (1 - s),
322
+ t[2] * s + r[2] * o + e[2] * i * (1 - s)
323
+ ];
324
+ }
325
+ const In = [1, 0, 0], Wn = [0, 1, 0], ae = [0, 0, 1];
326
+ function Ds(t, e, n) {
327
+ const s = Rt(t.fan * (Cs + Fs * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], i = [t.knuckle];
328
+ let a = 0;
329
+ t.bones.forEach((h, f) => {
330
+ a += Rt(Bs[f] * e), i.push(en(i[f], Se(Dt(o, r, -a), h)));
331
+ });
332
+ const l = Dt(ae, r, -a), c = i.map((h, f) => t.width * (1 - 0.14 * (f / (i.length - 1))));
333
+ return { joints: i, back: l, widths: c };
334
+ }
335
+ function qs(t, e, n = 1, s = 1) {
336
+ const o = Math.min(1, Math.max(0, e)), r = re(en(Se(re(Tt.out), 1 - o), Se(re(Tt.across), o))), i = re(nn(ae, r)), a = re(nn(r, i)), l = [[Tt.base[0] * s, Tt.base[1], Tt.base[2]]];
337
+ let c = 0;
338
+ Tt.bones.forEach((y, u) => {
339
+ u > 0 && (c += Rt(Rs[u - 1] * t)), l.push(en(l[u], Se(Dt(r, i, c), y)));
340
+ });
341
+ const h = Dt(a, i, c), f = [...Tt.widths, Tt.widths[Tt.widths.length - 1] * 0.92].map((y) => y * n);
342
+ return { joints: l, back: h, widths: f };
343
+ }
344
+ function Us(t, e = {}) {
345
+ const n = { ...Ot, ...t }, s = e.size ?? 100, o = e.side ?? "right", r = o === "left" ? -1 : 1, i = Rt(e.angle ?? 0), a = e.fingers === 4, l = Math.max(0.5, e.plump ?? 1), c = 1 + (l - 1) * 0.7, h = (w) => ({
346
+ ...w,
347
+ knuckle: [w.knuckle[0] * c, w.knuckle[1], w.knuckle[2]],
348
+ width: w.width * l
349
+ }), f = Rt(n.bend ?? 0), y = Rt(n.tilt ?? 0), u = Rt(90 * (n.turn ?? 0)), g = (w) => Dt(Dt(Dt(w, In, -f), ae, -y), Wn, u), m = Math.cos(i), d = Math.sin(i), x = Rt(n.roll ?? 0), b = Math.cos(x), k = Math.sin(x), v = (w) => {
350
+ const E = w[0] * s, H = -w[1] * s, N = (E * b - H * k) * r, D = E * k + H * b;
351
+ return { x: N * m - D * d, y: N * d + D * m };
352
+ }, P = (w) => {
353
+ const E = v(w), H = Math.hypot(E.x, E.y);
354
+ return H > 1e-6 * s ? { x: E.x / H, y: E.y / H } : { x: 0, y: 0 };
355
+ }, R = {
356
+ thumb: qs(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, l, c)
357
+ }, O = a ? Ls : _s;
358
+ for (const w of Hs) {
359
+ const E = O[w];
360
+ E && (R[w] = Ds(h(E), n[`${w}.curl`] ?? 0, n.spread ?? 0));
361
+ }
362
+ const $ = {};
363
+ for (const [w, E] of Object.entries(R)) {
364
+ const H = E.joints.map(g), N = g(E.back);
365
+ $[w] = {
366
+ points: H.map(v),
367
+ depths: H.map((D) => D[2] * s),
368
+ widths: E.widths.map((D) => D * s),
369
+ nail: N[2],
370
+ back: P(N)
371
+ };
372
+ }
373
+ const A = zs.flatMap(([w, E]) => [g([w * c, E, Ns]), g([w * c, E, Ys])]), z = Gs(A.map(v)), C = A.reduce((w, E) => w + E[2], 0) / A.length * s;
374
+ return {
375
+ size: s,
376
+ side: o,
377
+ wrist: { x: 0, y: 0 },
378
+ palm: z,
379
+ palmDepth: C,
380
+ palmFacing: -g(ae)[2],
381
+ fingers: $,
382
+ axes: { up: P(g(Wn)), across: P(g(In)), out: P(g(ae)) },
383
+ curls: Object.fromEntries(Object.keys($).map((w) => [w, n[`${w}.curl`] ?? 0]))
384
+ };
385
+ }
386
+ function Xs(t, e) {
387
+ const n = (o) => ({ x: o.x + e.x - t.wrist.x, y: o.y + e.y - t.wrist.y }), s = {};
388
+ for (const [o, r] of Object.entries(t.fingers))
389
+ s[o] = { ...r, points: r.points.map(n) };
390
+ return { ...t, wrist: n(t.wrist), palm: t.palm.map(n), fingers: s };
391
+ }
392
+ function Gs(t) {
393
+ const e = [...t].sort((r, i) => r.x - i.x || r.y - i.y);
394
+ if (e.length < 3) return e;
395
+ const n = (r, i, a) => (i.x - r.x) * (a.y - r.y) - (i.y - r.y) * (a.x - r.x), s = [];
396
+ for (const r of e) {
397
+ for (; s.length >= 2 && n(s[s.length - 2], s[s.length - 1], r) <= 0; ) s.pop();
398
+ s.push(r);
399
+ }
400
+ const o = [];
401
+ for (const r of [...e].reverse()) {
402
+ for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], r) <= 0; ) o.pop();
403
+ o.push(r);
404
+ }
405
+ return [...s.slice(0, -1), ...o.slice(0, -1)];
406
+ }
407
+ function Eo(t, e, n, s) {
408
+ if (s.mode !== "cel" || e.length < 3) return;
409
+ const o = Math.hypot(...s.light), r = e.map((a) => {
410
+ const l = a.x - n.x, c = a.y - n.y, h = (l * s.light[0] + c * s.light[1]) / ((Math.hypot(l, c) || 1) * o), f = Math.max(0, -h) * 0.24;
411
+ return { x: a.x - l * f, y: a.y - c * f };
412
+ }), i = (a) => {
413
+ t.beginPath(), t.moveTo(a[0].x, a[0].y);
414
+ for (const l of a.slice(1)) t.lineTo(l.x, l.y);
415
+ t.closePath();
416
+ };
417
+ t.save(), i(e), t.clip(), i([...e, ...r.reverse()]), t.globalAlpha *= s.opacity, t.fillStyle = s.shadow, t.fill(), t.restore();
418
+ }
419
+ const Ks = "#f1c9a5", Vs = "#2f2f33";
420
+ function So(t, e, n, s = {}, o = 0) {
421
+ const r = Xs(Us(n, s), e), i = s.ink ?? Vs, a = s.lineWidth ?? r.size * 0.035;
422
+ let l = s.pen ?? pn(t, {
423
+ look: s.look ?? "clean",
424
+ ink: i,
425
+ lineWidth: a,
426
+ seed: s.seed ?? 1,
427
+ time: o,
428
+ pencil: { construction: !1, ...s.pencil }
429
+ });
430
+ const c = s.skin ?? Ks;
431
+ c === "none" && (l = ge(t, l));
432
+ const h = s.nails ?? !0, f = [
433
+ {
434
+ depth: r.palmDepth,
435
+ draw: () => Js(t, l, r, c, a, s)
436
+ }
437
+ ];
438
+ for (const y of Object.values(r.fingers)) {
439
+ const u = y.depths.reduce((g, m) => g + m, 0) / y.depths.length;
440
+ f.push({
441
+ depth: u,
442
+ draw: () => Zs(t, l, y, c, a, h)
443
+ });
444
+ }
445
+ if (s.prop) {
446
+ const y = s.prop;
447
+ f.push({ depth: y.depth, draw: () => y.draw(l) });
448
+ }
449
+ t.save(), t.lineCap = "round", t.lineJoin = "round";
450
+ for (const y of [...f].sort((u, g) => u.depth - g.depth)) y.draw();
451
+ return t.restore(), r;
452
+ }
453
+ function Js(t, e, n, s, o, r) {
454
+ if (e.shape(n.palm, s === "none" ? null : s, r.connected ? 0 : o), s !== "none" && r.shading && e.look === "clean") {
455
+ const i = n.palm.reduce((a, l) => ({ x: a.x + l.x / n.palm.length, y: a.y + l.y / n.palm.length }), { x: 0, y: 0 });
456
+ Eo(t, n.palm, i, r.shading);
457
+ }
458
+ if (r.connected && o > 0 && (e.look !== "silhouette" || s === "none")) {
459
+ const { up: i } = n.axes;
460
+ let a = [];
461
+ for (let l = 0; l <= n.palm.length; l++) {
462
+ const c = n.palm[l % n.palm.length], h = n.palm[(l + 1) % n.palm.length];
463
+ ((c.x + h.x) / 2 - n.wrist.x) * i.x + ((c.y + h.y) / 2 - n.wrist.y) * i.y < n.size * 0.08 ? (a.length > 1 && e.line(a, o), a = []) : (a.length === 0 && a.push(c), a.push(h));
464
+ }
465
+ a.length > 1 && e.line(a, o);
466
+ }
467
+ if (n.palmFacing < -0.3 && e.look !== "silhouette") {
468
+ const { up: i } = n.axes;
469
+ for (const [a, l] of Object.entries(n.fingers)) {
470
+ const c = n.curls[a] ?? 0;
471
+ if (a === "thumb" || c < 0.5) continue;
472
+ const h = l.points[0], f = l.widths[0] * 0.42, y = { x: h.x - i.x * f * 0.2, y: h.y - i.y * f * 0.2 }, u = Math.atan2(i.y, i.x), g = Array.from({ length: 7 }, (m, d) => {
473
+ const x = u - Math.PI / 2 + Math.PI * d / 6;
474
+ return { x: y.x + Math.cos(x) * f, y: y.y + Math.sin(x) * f };
475
+ });
476
+ e.line(g, o * 0.6);
477
+ }
478
+ }
479
+ if (n.palmFacing > 0.45 && e.look !== "silhouette") {
480
+ const { up: i, across: a } = n.axes, l = n.size, c = n.wrist, h = (y, u) => ({
481
+ x: c.x + (a.x * y + i.x * u) * l,
482
+ y: c.y + (a.y * y + i.y * u) * l
483
+ }), f = n.side === "left" ? -1 : 1;
484
+ e.line([h(-0.15 * f, 0.36), h(-0.04 * f, 0.3), h(0.1 * f, 0.33)], o * 0.5);
485
+ }
486
+ }
487
+ function Zs(t, e, n, s, o, r) {
488
+ const { widths: i } = n, a = Qs(n.points, 2), l = n.points[0], c = a[a.length - 1], h = i[0], f = i[i.length - 1];
489
+ if (t.save(), e.look !== "silhouette" || s === "none") {
490
+ t.beginPath(), t.rect(l.x - 1e5, l.y - 1e5, 2e5, 2e5);
491
+ const m = h / 2 + o * 1.6;
492
+ t.moveTo(l.x + m, l.y), t.arc(l.x, l.y, m, 0, Math.PI * 2), t.clip("evenodd");
493
+ }
494
+ if (s === "none") {
495
+ const m = ut(a, h, f), d = a[a.length - 2], x = Math.atan2(c.y - d.y, c.x - d.x), b = Array.from({ length: 13 }, (k, v) => {
496
+ const P = x + Math.PI / 2 - v * Math.PI / 12;
497
+ return { x: c.x + Math.cos(P) * f / 2, y: c.y + Math.sin(P) * f / 2 };
498
+ });
499
+ e.shape([...m.slice(0, a.length), ...b.slice(1), ...m.slice(a.length)], null, o);
500
+ } else e.limb(a, h + 2 * o, f + 2 * o);
501
+ if (t.restore(), s !== "none" && e.look !== "silhouette" && (t.fillStyle = s, mn(t, a, h, f)), s === "none" || e.look === "silhouette" || !r || n.nail < 0.25) return;
502
+ const y = a[a.length - 2], u = js({ x: c.x - y.x, y: c.y - y.y }) ?? {
503
+ x: 0,
504
+ y: -1
505
+ }, g = {
506
+ x: c.x - u.x * f * 0.22 + n.back.x * f * 0.1,
507
+ y: c.y - u.y * f * 0.22 + n.back.y * f * 0.1
508
+ };
509
+ e.ellipse(g.x, g.y, f * 0.24 * Math.max(0.35, n.nail), f * 0.19, Math.atan2(u.y, u.x), "#f8e3d3", o * 0.45);
510
+ }
511
+ function Qs(t, e) {
512
+ let n = t;
513
+ for (let s = 0; s < e; s++) {
514
+ if (n.length < 3) return n;
515
+ const o = [n[0]];
516
+ for (let r = 0; r < n.length - 1; r++) {
517
+ const i = n[r], a = n[r + 1];
518
+ r > 0 && o.push({ x: i.x * 0.75 + a.x * 0.25, y: i.y * 0.75 + a.y * 0.25 }), r < n.length - 2 && o.push({ x: i.x * 0.25 + a.x * 0.75, y: i.y * 0.25 + a.y * 0.75 });
519
+ }
520
+ o.push(n[n.length - 1]), n = o;
521
+ }
522
+ return n;
523
+ }
524
+ const js = (t) => {
525
+ const e = Math.hypot(t.x, t.y);
526
+ return e > 1e-6 ? { x: t.x / e, y: t.y / e } : null;
527
+ }, le = {
528
+ walk: { swing: 24, knee: 30, arm: 22, elbow: 28, lean: 4 },
529
+ bouncy: { swing: 26, knee: 45, arm: 34, elbow: 30, lean: 2, bend: -4, bounce: 0.035, squash: 0.06 },
530
+ doubleBounce: { swing: 22, knee: 40, arm: 26, elbow: 24, lean: 3, bounce: 0.02, bounces: 2, squash: 0.04 },
531
+ sneak: { swing: 28, knee: 70, arm: 6, elbow: 0, forearm: 110, shoulder: 55, lean: 16, bend: 14, headTilt: -8, crouch: 50, tiptoe: 25 },
532
+ strut: { swing: 26, knee: 30, arm: 30, elbow: 20, lean: -4, bend: -10, headTilt: -6, sway: 4, bounce: 0.01 },
533
+ tired: { swing: 14, knee: 14, arm: 6, elbow: 6, lean: 10, bend: 16, headTilt: 12 },
534
+ run: { swing: 40, knee: 95, arm: 45, elbow: 0, forearm: 90, lean: 16, bend: 6, bounce: 0.05, squash: 0.06 },
535
+ shove: { swing: 18, knee: 28, arm: 0, elbow: 0, lean: 0 }
536
+ }, tr = 40;
537
+ function Be(t) {
538
+ return t === void 0 ? le.walk : typeof t == "string" ? le[t] ?? le.walk : t;
539
+ }
540
+ function er(t, e, n = Gt, s = 1) {
541
+ const o = Be(t);
542
+ if (o === le.walk) return rr(e, n, s);
543
+ const r = e * Math.PI * 2, i = Math.sin(r) * s, a = Math.cos(r) * s, l = (x) => Math.abs(x) <= tr, c = o.shoulder ?? 0, h = (x, b) => l(x) ? b * c + o.arm * i : x, f = o.forearm ?? 0, y = l(n.leftShoulder) ? n.leftElbow - f - o.elbow * Math.max(0, -i) : n.leftElbow, u = l(n.rightShoulder) ? n.rightElbow + f + o.elbow * Math.max(0, i) : n.rightElbow, g = o.bounces ?? 1, m = (1 + Math.cos(r * 2 * g)) / 2, d = o.crouch ?? 0;
544
+ return {
545
+ ...n,
546
+ lean: n.lean + o.lean * s + (o.sway ?? 0) * Math.sin(r) * (1 - (n.turn ?? 0)),
547
+ bend: (n.bend ?? 0) + (o.bend ?? 0),
548
+ headTilt: n.headTilt - o.lean * 0.5 * s + (o.headTilt ?? 0),
549
+ leftElbow: y,
550
+ rightElbow: u,
551
+ // A crouch brings both thighs forward and folds both shins back.
552
+ leftHip: -o.swing * i - d * 0.5,
553
+ rightHip: -o.swing * i + d * 0.5,
554
+ // The leg swinging forward lifts its knee; a crouch keeps both bent. A positive
555
+ // knee folds toward the centre, which is backward only for the right leg.
556
+ leftKnee: -o.knee * Math.max(0, a) - d,
557
+ rightKnee: o.knee * Math.max(0, -a) + d,
558
+ leftAnkle: (n.leftAnkle ?? 0) + (o.tiptoe ?? 0),
559
+ rightAnkle: (n.rightAnkle ?? 0) + (o.tiptoe ?? 0),
560
+ leftShoulder: h(n.leftShoulder, -1),
561
+ rightShoulder: h(n.rightShoulder, 1),
562
+ rise: (n.rise ?? 0) + (o.bounce ?? 0) * s * m,
563
+ stretch: n.stretch * (1 + (o.squash ?? 0) * (m - 0.5))
564
+ };
565
+ }
566
+ function Ba(t, e, n = 1) {
567
+ const s = Be(t), o = le.walk.swing, r = (i) => Math.sin(i * Math.PI / 180);
568
+ return ir(e, n) * r(s.swing * n) / r(o * n);
569
+ }
570
+ const Gt = {
571
+ lean: 0,
572
+ bend: 0,
573
+ headTilt: 0,
574
+ leftShoulder: 18,
575
+ rightShoulder: 18,
576
+ leftElbow: -6,
577
+ rightElbow: -6,
578
+ leftHip: 8,
579
+ rightHip: 8,
580
+ leftKnee: 0,
581
+ rightKnee: 0,
582
+ leftWrist: 0,
583
+ rightWrist: 0,
584
+ leftAnkle: 0,
585
+ rightAnkle: 0,
586
+ leftFootOut: 0,
587
+ rightFootOut: 0,
588
+ mouth: 0,
589
+ smile: 0.6,
590
+ mouthWidth: 1,
591
+ blink: 0,
592
+ leftEye: 1,
593
+ rightEye: 1,
594
+ leftBrow: 0,
595
+ rightBrow: 0,
596
+ browTilt: 0,
597
+ lookX: 0,
598
+ lookY: 0,
599
+ stretch: 1,
600
+ turn: 0,
601
+ sit: 0,
602
+ spin: 0,
603
+ rise: 0
604
+ };
605
+ function ft(t) {
606
+ return { ...Gt, ...t };
607
+ }
608
+ const Po = {
609
+ mouth: 0,
610
+ smile: 0,
611
+ mouthWidth: 1,
612
+ leftEye: 1,
613
+ rightEye: 1,
614
+ leftBrow: 0,
615
+ rightBrow: 0,
616
+ browTilt: 0,
617
+ lookX: 0,
618
+ lookY: 0
619
+ }, ct = (t) => ({ ...Po, ...t }), kt = {
620
+ neutral: Po,
621
+ happy: ct({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
622
+ joyful: ct({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
623
+ sad: ct({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
624
+ crying: ct({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
625
+ surprised: ct({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
626
+ shocked: ct({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
627
+ angry: ct({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
628
+ furious: ct({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
629
+ worried: ct({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
630
+ scared: ct({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
631
+ confused: ct({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
632
+ skeptical: ct({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
633
+ thinking: ct({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
634
+ sleepy: ct({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
635
+ disgusted: ct({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
636
+ smug: ct({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
637
+ wink: ct({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
638
+ };
639
+ function nr(t, e) {
640
+ return { ...t, ...typeof e == "string" ? kt[e] : e };
641
+ }
642
+ const or = {
643
+ rest: Gt,
644
+ wave: ft({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...kt.happy }),
645
+ cheer: ft({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...kt.joyful }),
646
+ shrug: ft({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...kt.confused, lookX: 0, lookY: 0 }),
647
+ point: ft({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
648
+ // The forearm passes 180° to fold back in, so the hand reaches the chin.
649
+ think: ft({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...kt.thinking }),
650
+ handsOnHips: ft({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
651
+ sad: ft({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...kt.sad }),
652
+ surprised: ft({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...kt.surprised }),
653
+ // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
654
+ crouch: ft({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
655
+ // Seated, hands resting on the knees. Arm angles spread outward per side, so
656
+ // reaching forward (+x, the way the figure faces) is negative for the left arm.
657
+ sit: ft({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
658
+ jump: ft({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...kt.joyful }),
659
+ // Ducking: squashed low, bent over, arms over the head.
660
+ duck: ft({ stretch: 0.62, bend: 28, headTilt: -8, leftShoulder: 150, rightShoulder: 150, leftElbow: 130, rightElbow: 130, leftHip: 25, rightHip: 25, ...kt.scared }),
661
+ // Lying on its back on the floor (rolled back about the hips and lowered), hands behind the head.
662
+ lie: ft({ spin: -90, rise: -0.42, leftShoulder: 165, rightShoulder: 165, leftElbow: 150, rightElbow: 150, ...kt.sleepy }),
663
+ // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
664
+ // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
665
+ sideSplit: ft({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...kt.happy }),
666
+ // Front split, in profile: the left leg forward (+x), the right leg back.
667
+ frontSplit: ft({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...kt.happy })
668
+ }, Ao = Object.keys(Gt);
669
+ function Tn(t, e, n) {
670
+ const s = { ...t };
671
+ for (const o of Ao) s[o] = t[o] + (e[o] - t[o]) * n;
672
+ return s;
673
+ }
674
+ const on = 24, Hn = 4, $n = 28, sr = 40;
675
+ function rr(t, e = Gt, n = 1) {
676
+ const s = Math.sin(t * Math.PI * 2) * n, o = Math.cos(t * Math.PI * 2) * n, r = (c) => Math.abs(c) <= sr, i = (c) => r(c) ? 22 * s : c, a = r(e.leftShoulder) ? e.leftElbow - $n * Math.max(0, -s) : e.leftElbow, l = r(e.rightShoulder) ? e.rightElbow + $n * Math.max(0, s) : e.rightElbow;
677
+ return {
678
+ ...e,
679
+ // Lean into the walk, and keep the head a little more level than the body.
680
+ lean: e.lean + Hn * n,
681
+ headTilt: e.headTilt - Hn * 0.5 * n,
682
+ leftElbow: a,
683
+ rightElbow: l,
684
+ // Left foot forward while swing > 0, right foot back; then the other way.
685
+ leftHip: -on * s,
686
+ rightHip: -on * s,
687
+ // The leg swinging forward lifts, its shin trailing backward (-x). A positive
688
+ // knee folds toward the centre, which is backward only for the right leg.
689
+ leftKnee: -30 * Math.max(0, o),
690
+ rightKnee: 30 * Math.max(0, -o),
691
+ // Arms swing against the legs: left arm back while the left foot is forward.
692
+ leftShoulder: i(e.leftShoulder),
693
+ rightShoulder: i(e.rightShoulder)
694
+ };
695
+ }
696
+ function ir(t, e = 1) {
697
+ return 4 * ((sn + Ie) * t) * Math.sin(on * e * Math.PI / 180);
698
+ }
699
+ function ar(t) {
700
+ const e = Math.abs(Math.sin(t / 65)), n = 0.55 + 0.45 * Math.sin(t / 310);
701
+ return e * n;
702
+ }
703
+ const Oo = 0.12, _n = 0.46, lr = 1 - 2 * Oo, hr = 0.1, cr = 0.21, fr = 0.19, sn = 0.24, Ie = 0.22, Io = 0.12, ur = 0.14, Wo = 0.33, Ln = 0.7, Bn = 0.3, dr = 0.35, gr = [1.7, 1.05], yr = [1.3, 0.75], Rn = [1.45, 0.85], mr = [1.15, 0.75], Cn = 0.06, pr = 0.7, xr = 0.65, To = 0.075, wr = 0.3, br = 0.02, Mr = 0.012, kr = 12, vr = 0.25, xe = 90, Er = 0.25, Sr = 0.04, Ho = 0.01, zt = (t) => Math.min(1, Math.max(0, t ?? 0));
704
+ function Ra(t, e = 1) {
705
+ return Ie * t * e;
706
+ }
707
+ const rn = -0.12, $o = 0.4, St = (t) => t * Math.PI / 180, Pr = (t, e) => ({ x: e * Math.sin(St(t)), y: Math.cos(St(t)) }), _o = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), Lo = (t, e, n, s) => t - 0.3 * e - n * 0.14 * e - Math.max(0, s - 1) * 0.12 * e;
708
+ function Ar(t, e, n, s, o, r) {
709
+ const i = Math.max(1, Math.min(r * 0.6, ur * n)), a = zt(e.turn), l = (Io + Wo * a) * n, c = s + rn * n, h = l + e.lookX * 0.08 * n, f = e.lookY * 0.07 * n, y = [
710
+ // The left eye is on the far side; turning closes it up more than the near one.
711
+ { x: -0.34 * n * (1 - Ln * a), squeeze: 1 - Ln * a, open: e.leftEye, brow: e.leftBrow, side: -1 },
712
+ { x: 0.34 * n * (1 - Bn * a), squeeze: 1 - Bn * a, open: e.rightEye, brow: e.rightBrow, side: 1 }
713
+ ];
714
+ t.fillStyle = o, t.strokeStyle = o, t.lineWidth = i;
715
+ for (const x of y) {
716
+ const b = _o(x.open, e.blink);
717
+ if (b < 0.2) {
718
+ const R = e.smile > 0.5 ? -0.12 * n : 0.06 * n;
719
+ t.beginPath(), t.moveTo(x.x + l - 0.12 * n, c), t.quadraticCurveTo(x.x + l, c + R, x.x + l + 0.12 * n, c), t.stroke();
720
+ } else {
721
+ if (b > 1.2) {
722
+ const O = 0.13 * n * b;
723
+ t.beginPath(), t.ellipse(x.x + l, c, O * 0.85, O, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = o;
724
+ }
725
+ const R = b > 1.2 ? 0.075 * n : 0.1 * n;
726
+ t.beginPath(), t.ellipse(x.x + h, c + f, R, R * 1.1 * Math.min(b, 1), 0, 0, Math.PI * 2), t.fill();
727
+ }
728
+ const k = Lo(c, n, x.brow, b), v = x.x + l - x.side * 0.13 * n * x.squeeze, P = x.x + l + x.side * 0.13 * n * x.squeeze;
729
+ t.beginPath(), t.moveTo(P, k), t.lineTo(v, k - e.browTilt * 0.1 * n), t.stroke();
730
+ }
731
+ const u = s + $o * n, g = 0.25 * n * Math.max(0.3, e.mouthWidth) * (1 - dr * a), m = Math.min(1, Math.max(0, e.mouth));
732
+ if (t.beginPath(), m <= 0.05) {
733
+ t.moveTo(l - g, u), t.quadraticCurveTo(l, u + e.smile * 0.25 * n, l + g, u), t.stroke();
734
+ return;
735
+ }
736
+ const d = 0.3 * n * m;
737
+ e.smile > 0.3 ? (t.moveTo(l - g, u - 0.05 * n), t.lineTo(l + g, u - 0.05 * n), t.quadraticCurveTo(l, u + d * 2, l - g, u - 0.05 * n)) : e.smile < -0.3 ? (t.moveTo(l - g, u + d * 0.6), t.lineTo(l + g, u + d * 0.6), t.quadraticCurveTo(l, u - d * 1.4, l - g, u + d * 0.6)) : t.ellipse(l, u, g * 0.8, d, 0, 0, Math.PI * 2), t.fill();
738
+ }
739
+ function Bo(t, e) {
740
+ const n = e.height ?? 300, s = Math.min(3, Math.max(0.3, t.stretch ?? 1)), o = Math.sqrt(s), r = e.armLength ?? 1;
741
+ if (!Number.isFinite(r) || r <= 0) throw new Error("stick figure: armLength must be a positive finite multiplier");
742
+ const i = (e.headSize ?? 2 * Oo) / 2, a = e.headSize === void 0 ? lr : 1 - 2 * i, l = i * n, c = zt(t.sit), h = t.leftHip + (-xe - t.leftHip) * c, f = t.leftKnee + (-xe - t.leftKnee) * c, y = t.rightHip + (xe - t.rightHip) * c, u = t.rightKnee + (xe - t.rightKnee) * c, g = e.classic === !0, m = zt(t.turn), d = (q, J, j, Q, nt) => {
743
+ const lt = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(St(J - j) / 2) + St(Q))), xt = Math.max(-1, Math.min(1, pr + nt)), p = m + (1 - m) * q * xt;
744
+ return g ? { x: 0, y: 0 } : { x: Math.cos(lt) * Cn * p, y: Math.sin(lt) * Cn };
745
+ }, x = { left: t.leftAnkle ?? 0, right: t.rightAnkle ?? 0 }, b = { left: t.leftFootOut ?? 0, right: t.rightFootOut ?? 0 };
746
+ let k = 0;
747
+ if (c > 0 || !g) {
748
+ const q = (nt, lt, xt, p, M) => sn * Math.cos(St(lt)) + Ie * Math.cos(St(lt - xt)) + Math.max(0, d(nt, lt, xt, p, M).y), J = Math.max(
749
+ q(-1, h, f, x.left, b.left),
750
+ q(1, y, u, x.right, b.right)
751
+ ), j = 1 - zt((t.rise ?? 0) / Sr), Q = (g ? Math.min(1, c / Er) : 1) * j;
752
+ k = (_n - J) * Q * n * s;
753
+ }
754
+ const v = -_n * n * s + k, P = -a * n * s + k, R = g ? 0 : (br * zt(t.turn) + Mr * c) * n * s, O = St(t.bend ?? 0), $ = { end: Nn(v, P, O, 1), bend: O };
755
+ let A;
756
+ if (O !== 0) {
757
+ A = [];
758
+ for (let q = 0; q <= Fn; q++) {
759
+ const J = q / Fn, j = Nn(v, P, O, J);
760
+ A.push({ x: j.x - R * Math.sin(Math.PI * J), y: j.y });
761
+ }
762
+ } else
763
+ A = R === 0 ? [{ x: 0, y: v }, { x: 0, y: P }] : ne({ x: 0, y: v }, { x: -R, y: (v + P) / 2 }, { x: 0, y: P }, 1, 8);
764
+ const z = P + hr * n * s, C = (e.shoulderWidth ?? 0) * n * Math.cos(m * Math.PI / 2), w = (q, J, j, Q, nt) => {
765
+ const lt = Pr(j, Q);
766
+ return { x: q + lt.x * nt * n, y: J + lt.y * nt * n };
767
+ }, E = (q, J, j) => {
768
+ const Q = w(0, v, J, q, sn * s);
769
+ return { root: { x: 0, y: v }, joint: Q, end: w(Q.x, Q.y, J - j, q, Ie * s) };
770
+ }, H = (q, J, j) => {
771
+ const Q = { x: q * C, y: z }, nt = w(Q.x, Q.y, J, q, cr * o * r);
772
+ return { root: Q, joint: nt, end: w(nt.x, nt.y, J + j, q, fr * o * r) };
773
+ }, N = { left: E(-1, h, f), right: E(1, y, u) }, D = (q, J, j, Q, nt, lt) => {
774
+ const xt = d(q, j, Q, nt, lt);
775
+ return { x: J.end.x + xt.x * n * s, y: J.end.y + xt.y * n * s };
776
+ }, X = (q, J, j, Q, nt) => w(J.end.x, J.end.y, j + Q + nt, q, To * o), K = {
777
+ left: H(-1, t.leftShoulder, t.leftElbow),
778
+ right: H(1, t.rightShoulder, t.rightElbow)
779
+ };
780
+ return {
781
+ height: n,
782
+ facing: (e.facing ?? 1) < 0 ? -1 : 1,
783
+ stretch: s,
784
+ lineWidth: e.lineWidth ?? n * 0.025,
785
+ rubber: Math.min(1, Math.max(g ? 0 : wr, e.rubber ?? 0)),
786
+ r: l,
787
+ // The head keeps its area: taller and narrower when stretched.
788
+ headRx: l / Math.sqrt(s),
789
+ headRy: l * Math.sqrt(s),
790
+ hipY: v,
791
+ neckY: P,
792
+ drop: k,
793
+ lean: g ? t.lean : t.lean + kr * Math.sin(Math.PI * c),
794
+ classic: g,
795
+ legs: N,
796
+ toes: {
797
+ left: D(-1, N.left, h, f, x.left, b.left),
798
+ right: D(1, N.right, y, u, x.right, b.right)
799
+ },
800
+ spine: A,
801
+ chest: $,
802
+ arms: K,
803
+ handTips: {
804
+ left: X(-1, K.left, t.leftShoulder, t.leftElbow, t.leftWrist ?? 0),
805
+ right: X(1, K.right, t.rightShoulder, t.rightElbow, t.rightWrist ?? 0)
806
+ }
807
+ };
808
+ }
809
+ const Fn = 10;
810
+ function Nn(t, e, n, s) {
811
+ const o = t - e, r = n * s;
812
+ if (Math.abs(n) < 1e-9) return { x: 0, y: t - o * s };
813
+ const i = o / n;
814
+ return { x: i * (1 - Math.cos(r)), y: t - i * Math.sin(r) };
815
+ }
816
+ function Or(t, e) {
817
+ if (t.chest.bend === 0) return e;
818
+ const n = ce(e, { x: 0, y: t.neckY }, t.chest.bend);
819
+ return { x: n.x + t.chest.end.x, y: n.y + t.chest.end.y - t.neckY };
820
+ }
821
+ const ie = (t, e) => e === 0 ? [t.root, t.joint, t.end] : ne(t.root, t.joint, t.end, e);
822
+ function ce(t, e, n) {
823
+ const s = Math.cos(n), o = Math.sin(n), r = t.x - e.x, i = t.y - e.y;
824
+ return { x: e.x + r * s - i * o, y: e.y + r * o + i * s };
825
+ }
826
+ function Ro(t, e, n = !0) {
827
+ const s = Wr(t, e), o = e.spin ?? 0, r = e.rise ?? 0;
828
+ return n && (o !== 0 || r !== 0) ? Ir(s, t, o, r) : s;
829
+ }
830
+ function Co(t, e, n) {
831
+ return { pivot: { x: 0, y: t.hipY }, angle: t.facing * St(e), lift: n * t.height };
832
+ }
833
+ function Ir(t, e, n, s) {
834
+ const { pivot: o, angle: r, lift: i } = Co(e, n, s), a = (y) => {
835
+ const u = ce(y, o, r);
836
+ return { x: u.x, y: u.y - i };
837
+ }, l = (y) => ({ left: a(y.left), right: a(y.right) }), c = { left: Math.max(a(t.feet.left).y, a(t.toes.left).y), right: Math.max(a(t.feet.right).y, a(t.toes.right).y) }, h = Math.max(c.left, c.right), f = Ho * e.height;
838
+ return {
839
+ ...t,
840
+ hip: a(t.hip),
841
+ neck: a(t.neck),
842
+ shoulders: l(t.shoulders),
843
+ elbows: l(t.elbows),
844
+ hands: l(t.hands),
845
+ fingertips: l(t.fingertips),
846
+ knees: l(t.knees),
847
+ feet: l(t.feet),
848
+ toes: l(t.toes),
849
+ feetY: h,
850
+ grounded: { left: c.left >= h - f, right: c.right >= h - f },
851
+ handAngle: { left: t.handAngle.left + r, right: t.handAngle.right + r },
852
+ limbs: {
853
+ leftArm: t.limbs.leftArm.map(a),
854
+ rightArm: t.limbs.rightArm.map(a),
855
+ leftLeg: t.limbs.leftLeg.map(a),
856
+ rightLeg: t.limbs.rightLeg.map(a),
857
+ spine: t.limbs.spine.map(a)
858
+ },
859
+ head: { ...t.head, center: a(t.head.center), angle: t.head.angle + r }
860
+ };
861
+ }
862
+ function Wr(t, e) {
863
+ const n = St(t.lean), s = St(e.headTilt), o = { x: 0, y: t.hipY }, r = (v) => ({ x: t.facing * v.x, y: v.y }), i = (v) => r(ce(v, o, n)), a = (v) => i(Or(t, v)), l = (v) => a(ce({ x: v.x, y: v.y + t.neckY }, { x: 0, y: t.neckY }, s)), c = ie(t.arms.left, t.rubber).map(a), h = ie(t.arms.right, t.rubber).map(a), f = (v, P) => Math.atan2(P.y - v.y, P.x - v.x), y = { left: a(t.handTips.left), right: a(t.handTips.right) }, u = (v, P) => {
864
+ const [R, O] = v.slice(-2), $ = t.arms[P], A = f(a($.end), y[P]) - f(a($.joint), a($.end));
865
+ return f(R, O) + A;
866
+ };
867
+ let g = 1 / 0;
868
+ for (const [v, P] of [
869
+ [e.leftBrow, e.leftEye],
870
+ [e.rightBrow, e.rightEye]
871
+ ]) {
872
+ const R = Lo(rn, 1, v, _o(P, e.blink));
873
+ g = Math.min(g, R, R - e.browTilt * 0.1);
874
+ }
875
+ const m = { left: r(t.legs.left.end), right: r(t.legs.right.end) }, d = { left: r(t.toes.left), right: r(t.toes.right) }, x = { left: Math.max(m.left.y, d.left.y), right: Math.max(m.right.y, d.right.y) }, b = Math.max(x.left, x.right), k = Ho * t.height;
876
+ return {
877
+ facing: t.facing,
878
+ height: t.height,
879
+ stretch: t.stretch,
880
+ lineWidth: t.lineWidth,
881
+ hip: o,
882
+ neck: a({ x: 0, y: t.neckY }),
883
+ shoulders: { left: a(t.arms.left.root), right: a(t.arms.right.root) },
884
+ elbows: { left: a(t.arms.left.joint), right: a(t.arms.right.joint) },
885
+ hands: { left: a(t.arms.left.end), right: a(t.arms.right.end) },
886
+ knees: { left: r(t.legs.left.joint), right: r(t.legs.right.joint) },
887
+ feet: m,
888
+ toes: d,
889
+ feetY: b,
890
+ grounded: { left: x.left >= b - k, right: x.right >= b - k },
891
+ fingertips: y,
892
+ handAngle: { left: u(c, "left"), right: u(h, "right") },
893
+ limbs: {
894
+ leftArm: c,
895
+ rightArm: h,
896
+ leftLeg: ie(t.legs.left, t.rubber).map(r),
897
+ rightLeg: ie(t.legs.right, t.rubber).map(r),
898
+ spine: t.spine.map(i)
899
+ },
900
+ head: {
901
+ center: l({ x: 0, y: -t.headRy }),
902
+ rx: t.headRx,
903
+ ry: t.headRy,
904
+ // Mirroring a turn reverses it.
905
+ angle: t.facing * (n + t.chest.bend + s),
906
+ eyeY: rn,
907
+ browTopY: g,
908
+ mouthY: $o,
909
+ faceX: t.facing * (Io + Wo * zt(e.turn))
910
+ }
911
+ };
912
+ }
913
+ function Tr(t, e = {}) {
914
+ return Ro(Bo(t, e), t);
915
+ }
916
+ function Ca(t, e, n) {
917
+ return ce({ x: t.center.x + e * t.rx, y: t.center.y + n * t.ry }, t.center, t.angle);
918
+ }
919
+ function Hr(t, e, n) {
920
+ const s = (r) => ({ x: r.x + e, y: r.y + n }), o = (r) => ({ left: s(r.left), right: s(r.right) });
921
+ return {
922
+ ...t,
923
+ hip: s(t.hip),
924
+ neck: s(t.neck),
925
+ shoulders: o(t.shoulders),
926
+ elbows: o(t.elbows),
927
+ hands: o(t.hands),
928
+ fingertips: o(t.fingertips),
929
+ knees: o(t.knees),
930
+ feet: o(t.feet),
931
+ toes: o(t.toes),
932
+ feetY: t.feetY + n,
933
+ grounded: { ...t.grounded },
934
+ handAngle: { ...t.handAngle },
935
+ limbs: {
936
+ leftArm: t.limbs.leftArm.map(s),
937
+ rightArm: t.limbs.rightArm.map(s),
938
+ leftLeg: t.limbs.leftLeg.map(s),
939
+ rightLeg: t.limbs.rightLeg.map(s),
940
+ spine: t.limbs.spine.map(s)
941
+ },
942
+ head: { ...t.head, center: s(t.head.center) }
943
+ };
944
+ }
945
+ function $r(t, e, n = {}, s = 0) {
946
+ const o = Bo(e, n), r = n.color ?? "#1e293b", i = n.layers ?? {}, a = n.layers ? Ro(o, e, !1) : void 0, l = n.sketch ? An(t, n.sketch, s) : void 0, c = n.sketch && n.layers ? An(t, n.sketch, s) : void 0, h = (O) => {
947
+ t.save(), O(), t.restore();
948
+ }, f = (O) => {
949
+ O && a && h(() => O(t, a, s, c));
950
+ }, y = () => t.scale(o.facing, 1), u = () => {
951
+ y(), t.translate(0, o.hipY), t.rotate(St(o.lean)), t.translate(0, -o.hipY);
952
+ }, g = () => {
953
+ u(), o.chest.bend !== 0 && (t.translate(o.chest.end.x, o.chest.end.y), t.rotate(o.chest.bend), t.translate(0, -o.neckY));
954
+ }, m = (O, $, A) => {
955
+ if (l) return $ ? l.curve(O) : l.line(O);
956
+ if (o.classic) {
957
+ t.beginPath(), t.moveTo(O[0].x, O[0].y);
958
+ for (const z of O.slice(1)) t.lineTo(z.x, z.y);
959
+ t.stroke();
960
+ return;
961
+ }
962
+ mn(t, O, A[0] * o.lineWidth, A[1] * o.lineWidth);
963
+ }, d = (O, $) => m(ie(O, o.rubber), o.rubber > 0, $), x = (O) => {
964
+ o.classic || m([o.legs[O].end, o.toes[O]], !1, mr);
965
+ }, b = (O) => {
966
+ if (n.hands && !o.classic) return v(O);
967
+ if (o.classic || l) return;
968
+ const $ = o.arms[O].end;
969
+ t.beginPath(), t.arc($.x, $.y, xr * o.lineWidth, 0, Math.PI * 2), t.fill();
970
+ };
971
+ t.save(), t.strokeStyle = r, t.fillStyle = r, t.lineWidth = o.lineWidth, t.lineCap = "round", t.lineJoin = "round";
972
+ const k = Co(o, e.spin ?? 0, e.rise ?? 0);
973
+ (k.angle !== 0 || k.lift !== 0) && (t.translate(0, -k.lift), t.translate(k.pivot.x, k.pivot.y), t.rotate(k.angle), t.translate(-k.pivot.x, -k.pivot.y));
974
+ function v(O) {
975
+ const $ = n.hands ?? {}, A = o.arms[O].end, z = o.handTips[O], C = n.headFill ?? "#ffffff";
976
+ So(t, A, $[O] ?? Ot, {
977
+ side: O,
978
+ // Degrees clockwise from straight up, in the frame the hand is drawn in.
979
+ angle: Math.atan2(z.x - A.x, A.y - z.y) * 180 / Math.PI,
980
+ size: ($.size ?? To) * o.height * Math.sqrt(o.stretch),
981
+ skin: $.skin ?? (C === "none" ? void 0 : C),
982
+ ink: r,
983
+ lineWidth: o.lineWidth * 0.45,
984
+ fingers: $.fingers,
985
+ plump: $.plump,
986
+ look: n.sketch ? "pencil" : "clean",
987
+ seed: n.sketch?.seed
988
+ }, s);
989
+ }
990
+ const P = (O) => {
991
+ h(() => {
992
+ g(), d(o.arms[O], yr), b(O);
993
+ });
994
+ const $ = i.sleeve;
995
+ $ && a && h(() => $(t, a, O, s, c));
996
+ }, R = zt(e.turn) > vr;
997
+ f(i.behind), h(() => {
998
+ y(), d(o.legs.left, Rn), x("left"), d(o.legs.right, Rn), x("right");
999
+ }), R && P("left"), h(() => {
1000
+ u(), m(o.spine, o.spine.length > 2, gr);
1001
+ }), h(() => {
1002
+ g();
1003
+ const { left: O, right: $ } = { left: o.arms.left.root, right: o.arms.right.root };
1004
+ if (O.x !== $.x)
1005
+ if (o.classic) m([O, $], !1, [1, 1]);
1006
+ else {
1007
+ const A = { x: (O.x + $.x) / 2, y: O.y - 0.3 * Math.abs($.x - O.x) };
1008
+ m(ne(O, A, $, 1, 8), !0, [1.1, 1.1]);
1009
+ }
1010
+ }), f(i.body), R || P("left"), P("right"), f(i.behindHead), h(() => {
1011
+ g(), t.translate(0, o.neckY), t.rotate(St(e.headTilt));
1012
+ const O = -o.headRy;
1013
+ t.beginPath(), t.ellipse(0, O, o.headRx, o.headRy, 0, 0, Math.PI * 2);
1014
+ const $ = n.headFill ?? "#ffffff";
1015
+ if ($ !== "none" && (t.fillStyle = $, t.fill()), l) {
1016
+ l.ellipse(0, O, o.headRx, o.headRy);
1017
+ const A = l.nudge();
1018
+ t.translate(A.x, A.y);
1019
+ } else
1020
+ t.stroke();
1021
+ t.translate(0, O), t.scale(o.headRx / o.r, o.headRy / o.r), Ar(t, e, o.r, 0, r, o.lineWidth);
1022
+ }), f(i.overHead), f(i.front), t.restore(), n.label && (t.save(), t.fillStyle = r, t.font = n.labelFont ?? `700 ${Math.round(o.height * 0.11)}px sans-serif`, t.textAlign = "center", t.textBaseline = "bottom", t.fillText(n.label, 0, -o.height * o.stretch - 0.04 * o.height + o.drop), t.restore());
1023
+ }
1024
+ function Fo(t, e, n, s) {
1025
+ const o = { ...t }, r = t.gait && s?.[t.gait] || t.gait;
1026
+ let i = t.walking > 0 ? Tn(o, er(r, t.walk, o), t.walking) : o, a = Lr(t);
1027
+ const l = t.dancing ?? 0;
1028
+ if (n && l > 0) {
1029
+ const c = n(t.beat ?? 0);
1030
+ if (i = Tn(i, c.pose, l), c.hands) {
1031
+ const h = (f, y) => y ? $s(f ?? Ot, y, l) : f;
1032
+ a = { left: h(a?.left, c.hands.left), right: h(a?.right, c.hands.right) };
1033
+ }
1034
+ }
1035
+ return t.talk > 0 && (i = { ...i, mouth: Math.max(i.mouth, t.talk * ar(e)) }), { pose: i, hands: a };
1036
+ }
1037
+ function _r(t, e, n, s) {
1038
+ return Fo(t, e, n, s).pose;
1039
+ }
1040
+ const No = (t, e) => (t.facing ?? e.facing ?? 1) < 0 ? -1 : 1, an = (t, e) => `hand.${t}.${e}`;
1041
+ function Lr(t) {
1042
+ const e = (o) => {
1043
+ if (typeof t[an(o, "spread")] == "number")
1044
+ return Object.fromEntries(Object.keys(Ot).map((r) => [r, t[an(o, r)]]));
1045
+ }, n = e("left"), s = e("right");
1046
+ return n || s ? { left: n, right: s } : void 0;
1047
+ }
1048
+ function Br(t, e) {
1049
+ return !e || !t.hands ? t : { ...t, hands: { ...t.hands, left: e.left ?? t.hands.left, right: e.right ?? t.hands.right } };
1050
+ }
1051
+ function Fa(t) {
1052
+ const e = t.style ?? {}, n = e.height ?? 300, s = n * 0.8, o = { ...ft(t.pose ?? {}), walk: 0, walking: 0, gait: "walk", facing: (e.facing ?? 1) < 0 ? -1 : 1, talk: 0, rubber: e.rubber ?? 0, beat: 0, dancing: 0 }, r = {};
1053
+ if (e.hands)
1054
+ for (const i of ["left", "right"]) {
1055
+ const a = e.hands[i] ?? Ot;
1056
+ for (const l of Object.keys(Ot)) r[an(i, l)] = a[l] ?? Ot[l];
1057
+ }
1058
+ return {
1059
+ type: "custom",
1060
+ x: t.x - s / 2,
1061
+ y: t.y - n,
1062
+ width: s,
1063
+ height: n,
1064
+ props: { ...o, ...r },
1065
+ about: Rr(Object.keys(r), t.cast),
1066
+ figureStyle: e,
1067
+ figureDance: t.dance,
1068
+ figureGaits: t.cast?.gaits,
1069
+ draw(i, a, l) {
1070
+ const c = a.props, h = Fo(c, l, t.dance, t.cast?.gaits);
1071
+ i.translate(s / 2, n), $r(i, h.pose, Br({ ...e, rubber: c.rubber, facing: No(c, e) }, h.hands), l);
1072
+ }
1073
+ };
1074
+ }
1075
+ function Rr(t, e) {
1076
+ const n = { ...Ss, ...Ps };
1077
+ for (const s of t) {
1078
+ const [, o, ...r] = s.split("."), i = As[r.join(".")];
1079
+ i && (n[s] = { ...i, description: `${o === "left" ? "Left" : "Right"} hand: ${i.description.toLowerCase()}` });
1080
+ }
1081
+ return {
1082
+ kind: "stick figure",
1083
+ summary: "A poseable stick figure: pose it with joint tracks, or give it beats (`scriptTracks`) that compile into acted tracks.",
1084
+ props: n,
1085
+ // Read when asked: the list is registered by the acting module (see figure-actions).
1086
+ get actions() {
1087
+ return Os(e);
1088
+ }
1089
+ };
1090
+ }
1091
+ function Na(t, e, n) {
1092
+ const s = t.figureStyle;
1093
+ if (!s) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
1094
+ const o = { ...t.props };
1095
+ let r = 0, i = 0;
1096
+ for (const [c, h] of e.state?.values.get(n) ?? [])
1097
+ c === "gait" && typeof h == "string" && (o.gait = h), typeof h == "number" && (c === "x" || c === "motionPathX" ? r = h : c === "y" || c === "motionPathY" ? i = h : c in o && (o[c] = h));
1098
+ const a = _r(o, e.time, t.figureDance, t.figureGaits), l = Tr(a, { ...s, rubber: o.rubber, facing: No(o, s) });
1099
+ return { pose: a, joints: Hr(l, t.x + r + t.width / 2, t.y + i + t.height) };
1100
+ }
1101
+ function Cr(t) {
1102
+ const e = [];
1103
+ return t.forEach((n, s) => {
1104
+ const o = s === 0 ? Gt : e[s - 1], r = typeof n.pose == "string" ? or[n.pose] : { ...o, ...n.pose };
1105
+ e.push(n.expression ? nr(r, n.expression) : r);
1106
+ }), e;
1107
+ }
1108
+ function Ya(t, e) {
1109
+ const n = Cr(e);
1110
+ return Ao.filter((s) => n.some((o) => o[s] !== Gt[s])).map((s) => ({
1111
+ id: `${t}-${s}`,
1112
+ target: t,
1113
+ property: s,
1114
+ keyframes: e.map((o, r) => ({
1115
+ time: o.time,
1116
+ value: n[r][s],
1117
+ ...o.easing ? { easing: o.easing } : {}
1118
+ }))
1119
+ }));
1120
+ }
1121
+ const Yn = {
1122
+ standard: {},
1123
+ slim: { headSize: 0.24, shoulderWidth: 0.05, hipWidth: 0.02 },
1124
+ tall: { headSize: 0.25, legLength: 1.1, armLength: 1.05 },
1125
+ short: { headSize: 0.33, legLength: 0.92, shoulderWidth: 0.065, hipWidth: 0.03 },
1126
+ broad: { shoulderWidth: 0.11, hipWidth: 0.04 },
1127
+ curvy: { shoulderWidth: 0.055, hipWidth: 0.065 },
1128
+ stocky: { headSize: 0.34, shoulderWidth: 0.1, hipWidth: 0.06 },
1129
+ kid: { headSize: 0.42 },
1130
+ child: { headSize: 0.4, legLength: 0.88, armLength: 0.9, shoulderWidth: 0.05, hipWidth: 0.02 },
1131
+ toddler: { headSize: 0.46, legLength: 0.78, armLength: 0.82, shoulderWidth: 0.05, hipWidth: 0.025 }
1132
+ }, qe = 0.215, Ue = 0.205, Fr = 0.065, zn = 0.035, Nr = 0.165, Yr = 0.155, zr = 12, Dr = 0.3, qr = 0.7, Ur = 0.35, Xr = (t) => t * Math.PI / 180, at = {
1133
+ turn: 0,
1134
+ lean: 0,
1135
+ bend: 0,
1136
+ side: 0,
1137
+ "head.turn": 0,
1138
+ "head.nod": 0,
1139
+ "head.tilt": 0,
1140
+ "arm.left.swing": 0,
1141
+ "arm.left.spread": 12,
1142
+ "arm.left.elbow": 8,
1143
+ "arm.left.bend": 0,
1144
+ "arm.right.swing": 0,
1145
+ "arm.right.spread": 12,
1146
+ "arm.right.elbow": 8,
1147
+ "arm.right.bend": 0,
1148
+ "leg.left.swing": 0,
1149
+ "leg.left.spread": 3,
1150
+ "leg.left.knee": 0,
1151
+ "leg.left.ankle": 0,
1152
+ "leg.left.toeOut": 0,
1153
+ "leg.left.rotate": 0,
1154
+ "leg.right.swing": 0,
1155
+ "leg.right.spread": 3,
1156
+ "leg.right.knee": 0,
1157
+ "leg.right.ankle": 0,
1158
+ "leg.right.toeOut": 0,
1159
+ "leg.right.rotate": 0,
1160
+ stretch: 1,
1161
+ lift: 0,
1162
+ roll: 0,
1163
+ mouth: 0,
1164
+ smile: 0.5,
1165
+ mouthWidth: 1,
1166
+ blink: 0,
1167
+ "eye.left": 1,
1168
+ "eye.right": 1,
1169
+ pupil: 1,
1170
+ lid: 0,
1171
+ bulge: 0,
1172
+ "brow.left": 0,
1173
+ "brow.right": 0,
1174
+ browTilt: 0,
1175
+ lookX: 0,
1176
+ lookY: 0,
1177
+ blush: 0,
1178
+ tears: 0,
1179
+ sweat: 0,
1180
+ "hair.swing": 0,
1181
+ "hair.trail": 0,
1182
+ "hair.lift": 0,
1183
+ "held.left": 1,
1184
+ "held.right": 1,
1185
+ "held.both": 1
1186
+ };
1187
+ function tt(t = {}) {
1188
+ return { ...at, ...t };
1189
+ }
1190
+ const Gr = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX", "hair.swing"]);
1191
+ function za(t) {
1192
+ const e = {};
1193
+ for (const [n, s] of Object.entries(t)) {
1194
+ const o = n.replace(/(^|\.)(left|right)(\.|$)/, (r, i, a, l) => `${i}${a === "left" ? "right" : "left"}${l}`);
1195
+ e[o] = Gr.has(n) ? -s : s;
1196
+ }
1197
+ return e;
1198
+ }
1199
+ function ot(t, e) {
1200
+ const n = {};
1201
+ for (const s of ["left", "right"]) for (const [o, r] of Object.entries(e)) n[`${t}.${s}.${o}`] = r;
1202
+ return n;
1203
+ }
1204
+ const Kr = {
1205
+ rest: at,
1206
+ wave: tt({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
1207
+ cheer: tt({ ...ot("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
1208
+ point: tt({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
1209
+ handsOnHips: tt({ ...ot("arm", { spread: 50, bend: -105, elbow: 0 }), ...ot("leg", { spread: 9 }), smile: 0.8 }),
1210
+ think: tt({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
1211
+ shrug: tt({ ...ot("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
1212
+ sit: tt({ ...ot("leg", { swing: 90, knee: 90, spread: 4 }), ...ot("arm", { swing: 25, elbow: 45, spread: 8 }) }),
1213
+ kneel: tt({
1214
+ "leg.left.swing": 90,
1215
+ "leg.left.knee": 90,
1216
+ // The back thigh leans back a little so its knee meets the ground beside the
1217
+ // front foot; the shin slopes up from it and the foot points down to tucked toes.
1218
+ "leg.right.swing": -18,
1219
+ "leg.right.knee": 108,
1220
+ "leg.right.ankle": 16,
1221
+ ...ot("arm", { swing: 20, elbow: 30 })
1222
+ }),
1223
+ crouch: tt({ ...ot("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...ot("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
1224
+ // On hands and knees: the back nearly level, arms straight down, the toes
1225
+ // pointed back along the ground.
1226
+ crawl: tt({ lean: 82, "head.nod": -35, ...ot("arm", { swing: 80, elbow: 0, spread: 4 }), ...ot("leg", { knee: 92, ankle: -88 }) }),
1227
+ lieDown: tt({ roll: 90, ...ot("arm", { spread: 8 }), "head.nod": 0 }),
1228
+ // Everyday actions (the motion and everyday-life reference sheets). Hands that hold
1229
+ // something are where its grip goes: see `holding` and `handGrip`.
1230
+ sleep: tt({ roll: 90, ...ot("arm", { spread: 8, swing: 20, elbow: 40 }), "leg.left.knee": 20, "leg.left.swing": 15, blink: 1, smile: 0.2 }),
1231
+ stretch: tt({ side: -16, "arm.left.spread": 165, "arm.left.bend": 35, "arm.left.elbow": 0, "arm.right.spread": 40, "arm.right.bend": -110, "arm.right.elbow": 0, "head.tilt": -10, "eye.left": 0, "eye.right": 0, smile: 0.4 }),
1232
+ sitFloor: tt({ ...ot("leg", { swing: 80, spread: 22, rotate: 75, knee: 145 }), ...ot("arm", { swing: 25, spread: 18, elbow: 30 }), lean: 5, smile: 0.5 }),
1233
+ carry: tt({ ...ot("arm", { spread: 16, elbow: 4 }), lean: -3, smile: 0.4 }),
1234
+ cane: tt({ "arm.right.swing": 16, "arm.right.spread": 10, "arm.right.elbow": 0, "arm.right.bend": 0, "arm.left.swing": 2, side: -3, lean: 4, "leg.right.swing": 4, smile: 0.3 }),
1235
+ lift: tt({ ...ot("arm", { swing: 28, spread: 24, elbow: 85, bend: -45 }), ...ot("leg", { swing: 12, knee: 22, spread: 6 }), lean: -4, smile: 0.2 }),
1236
+ push: tt({ lean: 28, ...ot("arm", { swing: 82, spread: 12, elbow: 18 }), "leg.left.swing": 28, "leg.left.knee": 30, "leg.right.swing": -28, "leg.right.knee": 6, "head.nod": -20, browTilt: -0.6, smile: -0.2 }),
1237
+ pull: tt({ lean: -22, ...ot("arm", { swing: 70, spread: 6, elbow: 0 }), "leg.left.swing": 32, "leg.left.knee": 8, "leg.right.swing": -8, "leg.right.knee": 34, "head.nod": 12, browTilt: -0.6, smile: -0.2 }),
1238
+ drink: tt({ "arm.right.swing": 85, "arm.right.spread": 8, "arm.right.elbow": 120, "arm.right.bend": 0, "head.nod": -14, "eye.left": 0.5, "eye.right": 0.5, smile: 0 }),
1239
+ phone: tt({ "arm.right.swing": 80, "arm.right.spread": 8, "arm.right.elbow": 80, "arm.right.bend": -10, "head.nod": 18, lookY: 0.7, lookX: -0.3, smile: 0.4 }),
1240
+ read: tt({ ...ot("arm", { swing: 32, spread: 10, elbow: 82, bend: -28 }), "head.nod": 22, lookY: 0.8, smile: 0.2 }),
1241
+ type: tt({ ...ot("leg", { swing: 90, knee: 90, spread: 4 }), ...ot("arm", { swing: 40, spread: 10, elbow: 55, bend: -20 }), lean: 8, "head.nod": 10, lookY: 0.5, smile: 0 })
1242
+ }, Da = ["round", "flat", "pointed", "big"], Vr = {
1243
+ round: { length: 1, width: [0.95, 0.7] },
1244
+ flat: { length: 1.12, width: [0.85, 0.85] },
1245
+ pointed: { length: 1.25, width: [1, 0.3] },
1246
+ big: { length: 1.5, width: [1.25, 1.1] }
1247
+ };
1248
+ function Jr(t = {}) {
1249
+ const e = t.headSize ?? 0.3, n = t.shoulderWidth ?? 0.06, s = t.hipWidth ?? 0.022, o = t.legLength ?? 1, r = t.armLength ?? 1, i = Vr[t.feet ?? "round"], a = Math.max(0.12, 1 - e - zn - (qe + Ue) * o), l = (f) => ({
1250
+ id: `arm.${f}`,
1251
+ parent: "spine",
1252
+ offset: [(f === "left" ? 1 : -1) * n, -0.035, 0],
1253
+ rest: [0, -1, 0],
1254
+ side: f === "left" ? 1 : -1,
1255
+ bones: [
1256
+ { length: Nr * r, width: [1.25, 0.9] },
1257
+ { length: Yr * r, width: [0.9, 0.75] }
1258
+ ]
1259
+ }), c = (f) => ({
1260
+ id: `leg.${f}`,
1261
+ parent: null,
1262
+ offset: [(f === "left" ? 1 : -1) * s, 0, 0],
1263
+ rest: [0, -1, 0],
1264
+ side: f === "left" ? 1 : -1,
1265
+ bones: [
1266
+ { length: qe * o, width: [1.45, 1.05] },
1267
+ { length: Ue * o, width: [1.05, 0.85] },
1268
+ { length: Fr * Math.sqrt(o) * i.length, width: i.width }
1269
+ ]
1270
+ }), h = (f, y) => f[y] ?? at[y] ?? 0;
1271
+ return {
1272
+ id: "human",
1273
+ hipHeight: (qe + Ue) * o,
1274
+ // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
1275
+ chains: [
1276
+ c("left"),
1277
+ c("right"),
1278
+ {
1279
+ id: "spine",
1280
+ parent: null,
1281
+ rest: [0, 1, 0],
1282
+ bones: [
1283
+ { length: a / 2, width: [1.7, 1.4] },
1284
+ { length: a / 2, width: [1.4, 1.1] }
1285
+ ]
1286
+ },
1287
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: zn, width: [1, 0.9] }] },
1288
+ l("left"),
1289
+ l("right")
1290
+ ],
1291
+ head: { on: "neck", size: e },
1292
+ contacts: [
1293
+ ...["left", "right"].flatMap((f) => [
1294
+ { chain: `leg.${f}`, joint: 1 },
1295
+ { chain: `leg.${f}`, joint: 2 },
1296
+ { chain: `leg.${f}`, joint: 3 },
1297
+ { chain: `arm.${f}`, joint: 1 },
1298
+ { chain: `arm.${f}`, joint: 2 }
1299
+ ]),
1300
+ { chain: "spine", joint: 0 },
1301
+ { chain: "spine", joint: 1 },
1302
+ { chain: "spine", joint: 2 },
1303
+ { head: "top" }
1304
+ ],
1305
+ angles(f, y) {
1306
+ if (y.id === "spine") {
1307
+ const b = -h(f, "lean") / 2, k = h(f, "side") / 2, v = -h(f, "bend");
1308
+ return [
1309
+ { swing: b + v * Dr, spread: k },
1310
+ { swing: b + v * qr, spread: k }
1311
+ ];
1312
+ }
1313
+ if (y.id === "neck") return [{ swing: -h(f, "bend") * Ur, spread: 0 }];
1314
+ const [u, g] = y.id.split("."), m = (b) => h(f, `${u}.${g}.${b}`);
1315
+ if (u === "arm")
1316
+ return [
1317
+ { swing: m("swing"), spread: m("spread") },
1318
+ { swing: m("elbow"), spread: m("bend") }
1319
+ ];
1320
+ const d = (y.side ?? 1) * m("rotate"), x = 1 - Math.cos(Xr(m("rotate")));
1321
+ return [
1322
+ { swing: m("swing"), spread: m("spread"), yaw: d },
1323
+ { swing: -m("knee"), spread: 0, yaw: d },
1324
+ // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
1325
+ { swing: 90 + m("ankle") - x * (m("swing") - m("knee")), spread: 0, yaw: (zr + m("toeOut")) * (y.side ?? 1) }
1326
+ ];
1327
+ },
1328
+ withAngles(f, y, u) {
1329
+ const [g, m] = y.id.split("."), d = (x) => `${g}.${m}.${x}`;
1330
+ return g === "arm" ? {
1331
+ ...f,
1332
+ [d("swing")]: u[0].swing,
1333
+ [d("spread")]: u[0].spread,
1334
+ [d("elbow")]: u[1].swing,
1335
+ [d("bend")]: u[1].spread
1336
+ } : g === "leg" ? { ...f, [d("swing")]: u[0].swing, [d("spread")]: u[0].spread, [d("knee")]: -u[1].swing } : f;
1337
+ },
1338
+ boneScale(f, y) {
1339
+ const u = Math.min(3, Math.max(0.3, h(f, "stretch")));
1340
+ return y?.id.startsWith("arm.") ? Math.sqrt(u) : u;
1341
+ },
1342
+ headPose(f) {
1343
+ const y = Math.min(3, Math.max(0.3, h(f, "stretch")));
1344
+ return {
1345
+ yaw: h(f, "head.turn"),
1346
+ nod: h(f, "head.nod"),
1347
+ tilt: h(f, "head.tilt"),
1348
+ // The head keeps its area: taller and narrower when stretched.
1349
+ sx: 1 / Math.sqrt(y),
1350
+ sy: Math.sqrt(y)
1351
+ };
1352
+ },
1353
+ landmarks: {
1354
+ neck: ["neck", 0],
1355
+ "shoulder.left": ["arm.left", 0],
1356
+ "elbow.left": ["arm.left", 1],
1357
+ "hand.left": ["arm.left", 2],
1358
+ "shoulder.right": ["arm.right", 0],
1359
+ "elbow.right": ["arm.right", 1],
1360
+ "hand.right": ["arm.right", 2],
1361
+ "hip.left": ["leg.left", 0],
1362
+ "knee.left": ["leg.left", 1],
1363
+ "ankle.left": ["leg.left", 2],
1364
+ "toe.left": ["leg.left", 3],
1365
+ "hip.right": ["leg.right", 0],
1366
+ "knee.right": ["leg.right", 1],
1367
+ "ankle.right": ["leg.right", 2],
1368
+ "toe.right": ["leg.right", 3]
1369
+ }
1370
+ };
1371
+ }
1372
+ function qa(t) {
1373
+ const e = t.split(".");
1374
+ if (e[0] === "hand" && e.length >= 3) {
1375
+ const s = `${e[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, r = e.slice(2).join(".");
1376
+ return `${s} · ${o[r] ?? r.replace(".curl", " curl").replace(".across", " across")}`;
1377
+ }
1378
+ if (e.length === 3) {
1379
+ const [s, o, r] = e;
1380
+ return `${`${o === "left" ? "Left" : "Right"} ${s}`} · ${{
1381
+ swing: "forward / back",
1382
+ spread: "out / in",
1383
+ elbow: "elbow bend",
1384
+ bend: "forearm out / in",
1385
+ knee: "knee bend",
1386
+ ankle: "foot tilt",
1387
+ toeOut: "toes out / in",
1388
+ rotate: "turn out at the hip"
1389
+ }[r] ?? r}`;
1390
+ }
1391
+ return {
1392
+ turn: "View (front → side → back)",
1393
+ lean: "Lean forward / back",
1394
+ bend: "Back curve (line of action)",
1395
+ side: "Lean sideways",
1396
+ "head.turn": "Head · turn",
1397
+ "head.nod": "Head · nod",
1398
+ "head.tilt": "Head · tilt",
1399
+ stretch: "Squash / stretch",
1400
+ lift: "Lift off the ground",
1401
+ roll: "Roll (whole figure)",
1402
+ mouth: "Mouth open",
1403
+ smile: "Smile",
1404
+ mouthWidth: "Mouth width",
1405
+ blink: "Blink",
1406
+ "eye.left": "Left eye open",
1407
+ "eye.right": "Right eye open",
1408
+ pupil: "Pupil size",
1409
+ lid: "Eyelids lowered",
1410
+ bulge: "Eyes bulging",
1411
+ "brow.left": "Left brow",
1412
+ "brow.right": "Right brow",
1413
+ browTilt: "Brow slant",
1414
+ lookX: "Look left / right",
1415
+ lookY: "Look up / down",
1416
+ blush: "Blush",
1417
+ tears: "Tears",
1418
+ sweat: "Sweat",
1419
+ "hair.swing": "Hair · swing",
1420
+ "hair.trail": "Hair · trail",
1421
+ "hair.lift": "Hair · lift",
1422
+ "held.left": "Left hand · holding",
1423
+ "held.right": "Right hand · holding",
1424
+ "held.both": "Both hands · holding"
1425
+ }[t] ?? t;
1426
+ }
1427
+ const Zr = {
1428
+ leftEye: "eye.left",
1429
+ rightEye: "eye.right",
1430
+ leftBrow: "brow.left",
1431
+ rightBrow: "brow.right"
1432
+ }, Qr = { blush: 0, tears: 0, sweat: 0, pupil: 1, lid: 0, bulge: 0 }, Kt = Object.fromEntries(
1433
+ Object.entries(kt).map(([t, e]) => [
1434
+ t,
1435
+ { ...Object.fromEntries(Object.entries(e).map(([n, s]) => [Zr[n] ?? n, s])), ...Qr }
1436
+ ])
1437
+ );
1438
+ Kt.crying.tears = 1;
1439
+ Kt.scared.sweat = 0.8;
1440
+ Kt.scared.bulge = 0.4;
1441
+ Kt.sleepy.lid = 0.5;
1442
+ Kt.worried.sweat = 0.6;
1443
+ const vt = (t) => ({ ...Kt.neutral, ...t }), jr = {
1444
+ ...Kt,
1445
+ laughing: vt({ mouth: 0.75, smile: 1, mouthWidth: 1.25, "eye.left": 0, "eye.right": 0, "brow.left": 0.5, "brow.right": 0.5 }),
1446
+ afraid: vt({ mouth: 0.4, smile: -0.6, mouthWidth: 0.9, "eye.left": 1.3, "eye.right": 1.3, "brow.left": 0.6, "brow.right": 0.6, browTilt: 1, sweat: 1, pupil: 0.8, bulge: 0.5 }),
1447
+ bored: vt({ smile: -0.05, mouthWidth: 0.6, "eye.left": 0.45, "eye.right": 0.45, "brow.left": -0.4, "brow.right": -0.4, lookX: 0.5 }),
1448
+ tired: vt({ mouth: 0.2, smile: -0.3, mouthWidth: 0.7, "eye.left": 0.3, "eye.right": 0.3, "brow.left": -0.1, "brow.right": -0.1, browTilt: 0.6, lookY: 0.6 }),
1449
+ embarrassed: vt({ smile: 0.4, mouthWidth: 0.7, "eye.left": 0.9, "eye.right": 0.9, browTilt: 0.7, "brow.left": 0.2, "brow.right": 0.2, lookX: -0.6, lookY: 0.5, blush: 1 }),
1450
+ proud: vt({ smile: 0.75, mouthWidth: 1, "eye.left": 0.75, "eye.right": 0.75, "brow.left": 0.5, "brow.right": 0.5, lookY: -0.2 }),
1451
+ determined: vt({ smile: 0.35, mouthWidth: 0.8, "eye.left": 0.85, "eye.right": 0.85, "brow.left": -0.5, "brow.right": -0.5, browTilt: -0.9 }),
1452
+ affectionate: vt({ smile: 0.85, "eye.left": 0, "eye.right": 0, "brow.left": 0.3, "brow.right": 0.3, blush: 0.8 }),
1453
+ hurt: vt({ smile: -0.7, mouthWidth: 0.8, "eye.left": 1.1, "eye.right": 1.1, "brow.left": 0.2, "brow.right": 0.2, browTilt: 1, lookY: 0.3, tears: 0.35 }),
1454
+ suspicious: vt({ smile: -0.25, mouthWidth: 0.7, "eye.left": 0.5, "eye.right": 0.85, "brow.left": -0.6, "brow.right": 0.4, browTilt: -0.3, lookX: 0.8, lid: 0.3 }),
1455
+ relieved: vt({ smile: 0.7, "eye.left": 0, "eye.right": 0, "brow.left": 0.4, "brow.right": 0.4, browTilt: 0.4 }),
1456
+ excited: vt({ mouth: 0.6, smile: 1, mouthWidth: 1.1, "eye.left": 1.4, "eye.right": 1.4, "brow.left": 0.9, "brow.right": 0.9, blush: 0.4, pupil: 1.3 })
1457
+ }, Et = (t) => t * Math.PI / 180;
1458
+ function Yo([t, e, n], s) {
1459
+ const o = Math.cos(s), r = Math.sin(s);
1460
+ return [t, e * o + n * r, -e * r + n * o];
1461
+ }
1462
+ function Re([t, e, n], s) {
1463
+ const o = Math.cos(s), r = Math.sin(s);
1464
+ return [t * o - e * r, t * r + e * o, n];
1465
+ }
1466
+ function Pt([t, e, n], s) {
1467
+ const o = Math.cos(s), r = Math.sin(s);
1468
+ return [t * o + n * r, e, -t * r + n * o];
1469
+ }
1470
+ const _t = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], We = (t, e) => [t[0] * e, t[1] * e, t[2] * e], Pe = (t, e) => Re(Yo(t, e.swing), e.spread);
1471
+ function we(t, e) {
1472
+ const n = Pt(t, e);
1473
+ return { point: { x: n[0], y: -n[1] }, depth: n[2] };
1474
+ }
1475
+ function xn(t, e, n) {
1476
+ const s = n, r = [0, t.hipHeight * s * (t.boneScale?.(e, null) ?? 1), 0], i = {};
1477
+ for (const m of t.chains) {
1478
+ const d = m.parent ? i[m.parent] : void 0;
1479
+ if (m.parent && !d) throw new Error(`body plan ${t.id}: chain ${m.id} comes before its parent ${m.parent}`);
1480
+ const x = m.at ?? (d ? d.joints3.length - 1 : 0), b = d ? d.joints3[x] : r, k = d ? d.frames[Math.max(0, x - 1)] : { swing: 0, spread: 0 }, v = m.offset ? _t(b, Pe(We(m.offset, s), k)) : b, P = m.side ?? 1, R = t.boneScale?.(e, m) ?? 1, O = t.angles(e, m), $ = [v], A = [];
1481
+ let z = k.swing, C = k.spread;
1482
+ m.bones.forEach((w, E) => {
1483
+ const H = O[E] ?? { swing: 0, spread: 0 };
1484
+ z += Et(H.swing), C += Et(H.spread) * P, A.push({ swing: z, spread: C });
1485
+ const N = Pt(Pe(m.rest, { swing: z, spread: C }), Et(H.yaw ?? 0));
1486
+ $.push(_t($[E], We(N, w.length * s * R)));
1487
+ }), i[m.id] = { joints3: $, frames: A };
1488
+ }
1489
+ const a = i[t.head.on], l = t.headPose?.(e) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, c = a.frames[a.frames.length - 1], h = t.head.size / 2 * s, f = h * l.sx, y = h * l.sy, u = (m) => Pe(Pt(Yo(Re(m, -Et(l.tilt)), -Et(l.nod)), Et(l.yaw)), c), g = _t(a.joints3[a.joints3.length - 1], u([0, y, 0]));
1490
+ return { height: s, root: r, chains: i, head: { center: g, rx: f, ry: y, toBody: u } };
1491
+ }
1492
+ function wn(t, e, n) {
1493
+ const s = n.height, o = Et(90 * (e.turn ?? 0)), r = xn(t, e, s), { root: i } = r, a = r.chains, { rx: l, ry: c } = r.head, h = r.head.toBody, f = r.head.center, y = {};
1494
+ for (const A of t.chains) {
1495
+ const { joints3: z, frames: C } = a[A.id], w = z.map((E) => we(E, o));
1496
+ y[A.id] = {
1497
+ id: A.id,
1498
+ joints3: z,
1499
+ frames: C,
1500
+ points: w.map((E) => E.point),
1501
+ depths: w.map((E) => E.depth)
1502
+ };
1503
+ }
1504
+ const u = we(f, o), g = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((A) => Pt(h(A), o)), m = we(i, o).point, d = Et(e.roll ?? 0), x = (A) => {
1505
+ const z = A.x - m.x, C = A.y - m.y;
1506
+ return { x: m.x + z * Math.cos(d) - C * Math.sin(d), y: m.y + z * Math.sin(d) + C * Math.cos(d) };
1507
+ }, b = ([A, z, C]) => [A * Math.cos(d) + z * Math.sin(d), -A * Math.sin(d) + z * Math.cos(d), C];
1508
+ for (const A of Object.values(y)) A.points = A.points.map(x);
1509
+ const k = {
1510
+ center: x(u.point),
1511
+ depth: u.depth,
1512
+ rx: l,
1513
+ ry: c,
1514
+ angle: 0,
1515
+ axes: g.map(b)
1516
+ }, v = k.axes[1];
1517
+ k.angle = Math.atan2(v[0], v[1]);
1518
+ const P = (A) => {
1519
+ if ("head" in A) return { x: k.center.x + v[0] * c, y: k.center.y - v[1] * c };
1520
+ const z = y[A.chain];
1521
+ return z.points[Math.min(A.joint, z.points.length - 1)];
1522
+ };
1523
+ let R = 0;
1524
+ (n.contact ?? "ground") === "ground" && (R = -Math.max(...t.contacts.map((A) => P(A).y))), R -= (e.lift ?? 0) * s;
1525
+ const O = (A) => ({ x: A.x, y: A.y + R });
1526
+ for (const A of Object.values(y)) A.points = A.points.map(O);
1527
+ k.center = O(k.center);
1528
+ const $ = t.contacts.map((A) => ({ spec: A, point: P(A) }));
1529
+ return {
1530
+ height: s,
1531
+ view: o,
1532
+ chains: y,
1533
+ head: k,
1534
+ hip: O(x(m)),
1535
+ hipDepth: we(i, o).depth,
1536
+ contacts: $,
1537
+ groundY: Math.max(...$.map((A) => A.point.y))
1538
+ };
1539
+ }
1540
+ const Te = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], ln = (t) => {
1541
+ const e = Math.hypot(t[0], t[1], t[2]) || 1;
1542
+ return [t[0] / e, t[1] / e, t[2] / e];
1543
+ };
1544
+ function ti(t, e, n) {
1545
+ const s = n.height, o = Et(90 * (e.turn ?? 0)), r = Et(e.roll ?? 0), i = xn(t, e, s), a = Pt(i.root, o), l = (d) => _t(Re(Te(Pt(d, o), a), -r), a), c = {};
1546
+ for (const d of t.chains) c[d.id] = i.chains[d.id].joints3.map(l);
1547
+ const h = l(i.head.center), f = (d) => ln(Te(l(_t(i.head.center, i.head.toBody(d))), h)), y = [f([1, 0, 0]), f([0, 1, 0]), f([0, 0, 1])], u = (d) => {
1548
+ if ("head" in d) return _t(h, We(y[1], i.head.ry));
1549
+ const x = c[d.chain];
1550
+ return x[Math.min(d.joint, x.length - 1)];
1551
+ };
1552
+ let g = 0;
1553
+ (n.contact ?? "ground") === "ground" && (g = -Math.min(...t.contacts.map((d) => u(d)[1]))), g += (e.lift ?? 0) * s;
1554
+ const m = (d) => [d[0], d[1] + g, d[2]];
1555
+ return {
1556
+ height: s,
1557
+ hip: m(a),
1558
+ chains: Object.fromEntries(Object.entries(c).map(([d, x]) => [d, x.map(m)])),
1559
+ head: { center: m(h), rx: i.head.rx, ry: i.head.ry, axes: y }
1560
+ };
1561
+ }
1562
+ function bn(t, e, n, s) {
1563
+ const o = n.height, r = Et(90 * (e.turn ?? 0)), i = xn(t, e, o), a = ti(t, e, n), l = a.hip, c = a.chains, h = a.head.center, f = (C) => {
1564
+ if ("head" in C) return _t(h, We(a.head.axes[1], a.head.ry));
1565
+ const w = c[C.chain];
1566
+ return w[Math.min(C.joint, w.length - 1)];
1567
+ }, y = s.toView(l), u = Re(Pt([0, 0, 1], r), -Et(e.roll ?? 0)), g = ln(Te(s.toView(_t(l, u)), y)), m = s.toScreen(y), d = s.toScreen([y[0] + 1, y[1], y[2]]), x = Math.hypot(d.x - m.x, d.y - m.y), b = (C) => {
1568
+ const w = s.toView(C);
1569
+ return { point: s.toScreen(w), depth: w[2] * x };
1570
+ }, k = {};
1571
+ for (const C of t.chains) {
1572
+ const w = c[C.id].map(b);
1573
+ k[C.id] = {
1574
+ id: C.id,
1575
+ joints3: i.chains[C.id].joints3,
1576
+ frames: i.chains[C.id].frames,
1577
+ points: w.map((E) => E.point),
1578
+ depths: w.map((E) => E.depth)
1579
+ };
1580
+ }
1581
+ const v = s.toView(h), P = s.toScreen(v), R = s.toScreen([v[0] + 1, v[1], v[2]]), O = Math.hypot(R.x - P.x, R.y - P.y), $ = a.head.axes.map((C) => ln(Te(s.toView(_t(h, C)), v))), A = {
1582
+ center: P,
1583
+ depth: v[2] * x,
1584
+ rx: i.head.rx * O,
1585
+ ry: i.head.ry * O,
1586
+ angle: Math.atan2($[1][0], $[1][1]),
1587
+ axes: $
1588
+ }, z = t.contacts.map((C) => ({ spec: C, point: b(f(C)).point }));
1589
+ return {
1590
+ height: o * x,
1591
+ view: r,
1592
+ bodyForward: g,
1593
+ chains: k,
1594
+ head: A,
1595
+ hip: m,
1596
+ hipDepth: y[2] * x,
1597
+ contacts: z,
1598
+ groundY: Math.max(...z.map((C) => C.point.y))
1599
+ };
1600
+ }
1601
+ function oe(t, [e, n, s]) {
1602
+ const [o, r, i] = t.axes, a = [
1603
+ o[0] * e * t.rx + r[0] * n * t.ry + i[0] * s * t.rx,
1604
+ o[1] * e * t.rx + r[1] * n * t.ry + i[1] * s * t.rx,
1605
+ o[2] * e * t.rx + r[2] * n * t.ry + i[2] * s * t.rx
1606
+ ], l = Math.hypot(e, n, s) || 1, c = (o[2] * e + r[2] * n + i[2] * s) / l;
1607
+ return { point: { x: t.center.x + a[0], y: t.center.y - a[1] }, depth: t.depth + a[2], facing: c };
1608
+ }
1609
+ const be = (t) => t * 180 / Math.PI, Nt = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], Xe = (t, e) => t[0] * e[0] + t[1] * e[1] + t[2] * e[2], Qt = (t) => Math.hypot(t[0], t[1], t[2]), hn = (t) => {
1610
+ const e = Qt(t) || 1;
1611
+ return [t[0] / e, t[1] / e, t[2] / e];
1612
+ }, Me = (t) => Math.atan2(Math.sin(t), Math.cos(t));
1613
+ function Dn(t) {
1614
+ const [e, n, s] = hn(t);
1615
+ return { swing: Math.asin(Math.max(-1, Math.min(1, s))), spread: Math.atan2(e, -n) };
1616
+ }
1617
+ function ei(t, e, n, s, o) {
1618
+ const r = t.chains.find((w) => w.id === n);
1619
+ if (!r) throw new Error(`reach: no chain ${n} in ${t.id}`);
1620
+ if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
1621
+ if (!t.withAngles) throw new Error(`reach: the ${t.id} plan cannot set angles`);
1622
+ const i = wn(t, { ...e, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), a = i.chains[n];
1623
+ if (Qt(Nt(s, a.joints3[2])) < o.height * 1e-12) return e;
1624
+ const l = a.joints3[0], c = Qt(Nt(a.joints3[1], a.joints3[0])), h = Qt(Nt(a.joints3[2], a.joints3[1])), f = r.parent ? i.chains[r.parent].frames[Math.max(0, (r.at ?? i.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, y = Nt(s, l), u = t.angles(e, r), g = (w) => (u[w]?.yaw ?? 0) * Math.PI / 180, m = Math.min(c + h - 1e-6, Math.max(Math.abs(c - h) + 1e-6, Qt(y))), d = hn(y), x = r.parent !== null, b = Pt(Pe(r.pole ?? (x ? [0, -0.35, -1] : [0, 0, 1]), f), g(0));
1625
+ let k = Nt(b, [d[0] * Xe(b, d), d[1] * Xe(b, d), d[2] * Xe(b, d)]);
1626
+ Qt(k) < 1e-6 && (k = Pt([1, 0, 0], g(0))), k = hn(k);
1627
+ const v = (c * c + m * m - h * h) / (2 * c * m), P = Math.sqrt(Math.max(0, 1 - v * v)), R = [
1628
+ l[0] + c * (v * d[0] + P * k[0]),
1629
+ l[1] + c * (v * d[1] + P * k[1]),
1630
+ l[2] + c * (v * d[2] + P * k[2])
1631
+ ], O = [l[0] + d[0] * m, l[1] + d[1] * m, l[2] + d[2] * m], $ = r.side ?? 1, A = Dn(Pt(Nt(R, l), -g(0))), z = Dn(Pt(Nt(O, R), -g(1))), C = [
1632
+ { swing: be(Me(A.swing - f.swing)), spread: be(Me(A.spread - f.spread)) * $ },
1633
+ { swing: be(Me(z.swing - A.swing)), spread: be(Me(z.spread - A.spread)) * $ }
1634
+ ];
1635
+ return t.withAngles(e, r, C);
1636
+ }
1637
+ function jt(t, e, n, s) {
1638
+ if (!Number.isFinite(t) || t < n || t > s) throw new Error(`organic body: ${e} must be ${n}..${s}`);
1639
+ return t;
1640
+ }
1641
+ function ke(t, e) {
1642
+ if (t.length < 2 || t[0].at !== 0 || t.at(-1).at !== 1) throw new Error(`organic body: ${e} must run from 0 to 1`);
1643
+ return t.map((n, s) => {
1644
+ if (jt(n.at, `${e}.at`, 0, 1), jt(n.width, `${e}.width`, 1e-3, 0.3), s > 0 && n.at <= t[s - 1].at) throw new Error(`organic body: ${e} positions must increase`);
1645
+ return { at: n.at, width: n.width };
1646
+ });
1647
+ }
1648
+ function ni(t, e) {
1649
+ const n = Math.max(0.095, e.shoulderWidth + 0.025), s = Math.max(0.085, e.hipWidth + 0.032), o = t.shading ?? {}, r = o.light ?? [-0.8, -0.6];
1650
+ if (r.length !== 2 || !r.every(Number.isFinite) || Math.hypot(...r) === 0) throw new Error("organic body: light must be a finite nonzero 2D vector");
1651
+ if (o.mode !== void 0 && o.mode !== "none" && o.mode !== "cel") throw new Error("organic body: unknown shading mode");
1652
+ return {
1653
+ torso: ke(t.torso ?? [
1654
+ { at: 0, width: s },
1655
+ { at: 0.2, width: s },
1656
+ { at: 0.42, width: s * 0.72 },
1657
+ { at: 0.68, width: n * 0.9 },
1658
+ { at: 0.86, width: n },
1659
+ { at: 1, width: 0.024 }
1660
+ ], "torso"),
1661
+ arm: ke(t.arm ?? [
1662
+ { at: 0, width: 0.028 },
1663
+ { at: 0.22, width: 0.027 },
1664
+ { at: 0.5, width: 0.019 },
1665
+ { at: 0.68, width: 0.023 },
1666
+ { at: 1, width: 0.012 }
1667
+ ], "arm"),
1668
+ leg: ke(t.leg ?? [
1669
+ { at: 0, width: 0.04 },
1670
+ { at: 0.24, width: 0.042 },
1671
+ { at: 0.5, width: 0.027 },
1672
+ { at: 0.68, width: 0.032 },
1673
+ { at: 1, width: 0.016 }
1674
+ ], "leg"),
1675
+ neck: ke(t.neck ?? [{ at: 0, width: 0.024 }, { at: 1, width: 0.023 }], "neck"),
1676
+ depth: jt(t.depth ?? 0.55, "depth", 0.2, 1),
1677
+ fill: t.fill ?? e.skin,
1678
+ outline: { color: t.outline?.color ?? e.ink, width: jt(t.outline?.width ?? e.lineWidth, "outline.width", 0, 100) },
1679
+ shading: {
1680
+ mode: o.mode ?? "cel",
1681
+ light: [...r],
1682
+ shadow: o.shadow ?? "#633923",
1683
+ opacity: jt(o.opacity ?? 0.17, "shading.opacity", 0, 1),
1684
+ highlight: jt(o.highlight ?? 0.12, "shading.highlight", 0, 1)
1685
+ }
1686
+ };
1687
+ }
1688
+ function oi(t, e) {
1689
+ const n = Math.min(1, Math.max(0, e)), s = t.findIndex((a) => a.at >= n);
1690
+ if (s <= 0) return t[0].width;
1691
+ const o = t[s - 1], r = t[s], i = (n - o.at) / (r.at - o.at);
1692
+ return o.width + (r.width - o.width) * i * i * (3 - 2 * i);
1693
+ }
1694
+ const qn = 8, si = (t, e, n) => ({ x: t.x + (e.x - t.x) * n, y: t.y + (e.y - t.y) * n }), Yt = (t, e) => {
1695
+ const n = Math.hypot(e.x - t.x, e.y - t.y) || 1;
1696
+ return { x: (e.x - t.x) / n, y: (e.y - t.y) / n };
1697
+ }, He = (t, e, n) => ({ x: t.x + e.x * n, y: t.y + e.y * n });
1698
+ function ve(t, e = 12) {
1699
+ if (!Number.isInteger(e) || e < 1 || e > 128) throw new Error("organicCenterLine: steps must be an integer from 1 to 128");
1700
+ if (t.length < 2) return t.map((o) => ({ ...o }));
1701
+ const n = t.map((o, r) => {
1702
+ const i = Yt(t[Math.max(0, r - 1)], o), a = Yt(o, t[Math.min(t.length - 1, r + 1)]), l = Math.hypot(i.x + a.x, i.y + a.y);
1703
+ return l > 1e-6 ? { x: (i.x + a.x) / l, y: (i.y + a.y) / l } : a;
1704
+ }), s = [];
1705
+ for (let o = 0; o < t.length - 1; o++) {
1706
+ const r = t[o], i = t[o + 1], a = Math.hypot(i.x - r.x, i.y - r.y) * 0.28, l = He(r, n[o], a), c = He(i, n[o + 1], -a);
1707
+ for (let h = o === 0 ? 0 : 1; h <= e; h++) {
1708
+ const f = h / e, y = 1 - f;
1709
+ s.push({
1710
+ x: y ** 3 * r.x + 3 * y * y * f * l.x + 3 * y * f * f * c.x + f ** 3 * i.x,
1711
+ y: y ** 3 * r.y + 3 * y * y * f * l.y + 3 * y * f * f * c.y + f ** 3 * i.y
1712
+ });
1713
+ }
1714
+ }
1715
+ return s;
1716
+ }
1717
+ function Ee(t, e, n, s = 1, o = 1) {
1718
+ const r = t.map((h, f) => {
1719
+ const y = t[Math.max(0, f - 1)], u = t[Math.min(t.length - 1, f + 1)];
1720
+ let g = Yt(y, u);
1721
+ Math.hypot(g.x, g.y) < 1e-6 && (g = { x: 0, y: 1 });
1722
+ const m = { x: -g.y, y: g.x }, d = f / Math.max(1, t.length - 1), x = oi(e, d) * n * s, b = Yt(y, h), k = Yt(h, u), v = b.x * k.y - b.y * k.x, P = Math.acos(Math.min(1, Math.max(-1, b.x * k.x + b.y * k.y))), R = (Math.hypot(h.x - y.x, h.y - y.y) + Math.hypot(u.x - h.x, u.y - h.y)) / (2 * Math.max(1e-6, P)), O = Math.min(x, Math.max(x * 0.2, R * 0.8));
1723
+ return { center: h, width: x, at: d, left: He(h, m, v > 0 ? O : x), right: He(h, m, v < 0 ? -O : -x) };
1724
+ }), i = [], a = [], l = (h, f) => {
1725
+ i.push(h), a.push(f);
1726
+ };
1727
+ for (const h of r) l(h.left, h.at);
1728
+ const c = (h, f, y) => {
1729
+ const u = { x: -f.y, y: f.x };
1730
+ for (let g = 1; g < qn; g++) {
1731
+ const m = g * Math.PI / qn, d = (y ? 1 : -1) * Math.cos(m), x = (y ? 1 : -o) * Math.sin(m);
1732
+ l({
1733
+ x: h.center.x + h.width * (u.x * d + f.x * x),
1734
+ y: h.center.y + h.width * (u.y * d + f.y * x)
1735
+ }, h.at);
1736
+ }
1737
+ };
1738
+ c(r.at(-1), Yt(t[Math.max(0, t.length - 2)], t.at(-1)), !0);
1739
+ for (const h of [...r].reverse()) l(h.right, h.at);
1740
+ return c(r[0], Yt(t[0], t[Math.min(1, t.length - 1)]), !1), { outline: i, samples: r, positions: a };
1741
+ }
1742
+ function ri(t, e, n) {
1743
+ const s = {}, o = e.height, r = e.chains.spine;
1744
+ if (r?.length >= 2) {
1745
+ const i = e.points["shoulder.left"], a = e.points["shoulder.right"], l = n.chains.find((u) => u.id === "arm.left")?.offset?.[0] ?? 0.07, c = Math.max(1e-6, Math.abs(l) * o * 2), h = i && a ? Math.min(1, Math.hypot(i.x - a.x, i.y - a.y) / c) : Math.abs(Math.cos(e.turn * Math.PI / 2)), f = Math.sqrt(h * h + t.depth * t.depth * (1 - h * h)), y = [si(r[0], r[1], -0.16), ...r.slice(1)];
1746
+ s.spine = Ee(ve(y), t.torso, o, f, 0.25);
1747
+ }
1748
+ e.chains.neck?.length >= 2 && (s.neck = Ee(ve(e.chains.neck), t.neck, o));
1749
+ for (const i of ["left", "right"])
1750
+ for (const a of ["arm", "leg"]) {
1751
+ const l = e.chains[`${a}.${i}`];
1752
+ !l || l.length < 3 || (s[`${a}.${i}`] = Ee(ve(l.slice(0, 3)), t[a], o), a === "leg" && l.length > 3 && (s[`foot.${i}`] = Ee(ve(l.slice(2)), [{ at: 0, width: 0.019 }, { at: 1, width: 0.014 }], o)));
1753
+ }
1754
+ return s;
1755
+ }
1756
+ function zo(t, e) {
1757
+ let n = !1;
1758
+ for (let s = 0, o = e.length - 1; s < e.length; o = s++) {
1759
+ const r = e[s], i = e[o];
1760
+ r.y > t.y != i.y > t.y && t.x < (i.x - r.x) * (t.y - r.y) / (i.y - r.y) + r.x && (n = !n);
1761
+ }
1762
+ return n;
1763
+ }
1764
+ function Ge(t, e, n, s = 0) {
1765
+ const o = t.samples.filter((a) => a.at >= e && a.at <= n), r = (a, l) => {
1766
+ const c = a[l], h = a.center, f = Math.hypot(c.x - h.x, c.y - h.y) || 1;
1767
+ return { x: c.x + (c.x - h.x) * s / f, y: c.y + (c.y - h.y) * s / f };
1768
+ }, i = [...o.map((a) => r(a, "left")), ...[...o].reverse().map((a) => r(a, "right"))];
1769
+ {
1770
+ const a = t.samples[0].center;
1771
+ for (const l of t.outline.slice(-7)) {
1772
+ const c = Math.hypot(l.x - a.x, l.y - a.y) || 1;
1773
+ i.push({ x: l.x + (l.x - a.x) * s / c, y: l.y + (l.y - a.y) * s / c });
1774
+ }
1775
+ }
1776
+ return i;
1777
+ }
1778
+ function Un(t, e) {
1779
+ t.beginPath(), t.moveTo(e[0].x, e[0].y);
1780
+ for (const n of e.slice(1)) t.lineTo(n.x, n.y);
1781
+ t.closePath();
1782
+ }
1783
+ function ii(t, e, n) {
1784
+ const s = n.shading;
1785
+ if (s.mode === "none" || n.fill === "none") return;
1786
+ const o = Math.hypot(...s.light), r = { x: s.light[0] / o, y: s.light[1] / o }, i = t.globalAlpha;
1787
+ t.save(), Un(t, e.outline), t.clip();
1788
+ for (const a of ["left", "right"]) {
1789
+ const l = e.samples.map((h) => h[a]), c = e.samples.map((h) => {
1790
+ const f = h[a], y = h.center, u = f.x - y.x, g = f.y - y.y, m = (u * r.x + g * r.y) / (Math.hypot(u, g) || 1), d = Math.max(0, -m) * 0.44;
1791
+ return { x: f.x + (y.x - f.x) * d, y: f.y + (y.y - f.y) * d };
1792
+ });
1793
+ if (Un(t, [...l, ...c.reverse()]), t.fillStyle = s.shadow, t.globalAlpha = i * s.opacity, t.fill(), s.highlight > 0) {
1794
+ const h = e.samples.map((u) => {
1795
+ const g = u[a], m = u.center;
1796
+ return { x: g.x + (m.x - g.x) * 0.2, y: g.y + (m.y - g.y) * 0.2 };
1797
+ }), f = e.samples[Math.floor(e.samples.length / 2)][a], y = e.samples[Math.floor(e.samples.length / 2)].center;
1798
+ if ((f.x - y.x) * r.x + (f.y - y.y) * r.y > 0) {
1799
+ t.globalAlpha = i * s.highlight, t.strokeStyle = "#ffffff", t.lineWidth = Math.max(1, e.samples[0].width * 0.16), t.beginPath(), t.moveTo(h[0].x, h[0].y);
1800
+ for (const u of h.slice(1)) t.lineTo(u.x, u.y);
1801
+ t.stroke();
1802
+ }
1803
+ }
1804
+ }
1805
+ t.restore();
1806
+ }
1807
+ function ai(t, e, n, s) {
1808
+ const o = s.bodyContours, r = (i) => o[i] && zo(t, o[i].outline);
1809
+ if (n.startsWith("arm.")) return e < 0.2 && r("spine");
1810
+ if (n.startsWith("leg.")) return e < 0.2 && r("spine") || e > 0.85 && r(n.replace("leg.", "foot."));
1811
+ if (n.startsWith("foot.")) return e < 0.25 && r(n.replace("foot.", "leg."));
1812
+ if (n === "neck") return e < 0.6 && r("spine");
1813
+ if (n === "spine") {
1814
+ if (e > 0.85 && r("neck")) return !0;
1815
+ for (const i of ["left", "right"]) {
1816
+ if (e > 0.6 && r(`arm.${i}`)) {
1817
+ const a = s.chains[`arm.${i}`]?.[0];
1818
+ if (a && Math.hypot(a.x - t.x, a.y - t.y) < s.height * 0.07) return !0;
1819
+ }
1820
+ if (e < 0.25 && r(`leg.${i}`)) return !0;
1821
+ }
1822
+ }
1823
+ return !1;
1824
+ }
1825
+ function Xn(t, e, n, s, o) {
1826
+ const r = s.bodyContours?.[o];
1827
+ if (!r) return !1;
1828
+ if (n.fill === "none" && (e = ge(t, e)), e.shape(r.outline, n.fill === "none" ? null : n.fill, 0), e.look === "clean" && ii(t, r, n), (e.look !== "silhouette" || n.fill === "none") && s.lineWidth > 0) {
1829
+ let i = [];
1830
+ for (let a = 0; a <= r.outline.length; a++) {
1831
+ const l = a % r.outline.length, c = r.outline[l], h = r.outline[(l + 1) % r.outline.length], f = { x: (c.x + h.x) / 2, y: (c.y + h.y) / 2 };
1832
+ o.startsWith("arm.") && r.positions[l] === 1 || ai(f, r.positions[l], o, s) ? (i.length >= 2 && e.line(i, s.lineWidth), i = []) : (i.length === 0 && i.push(c), i.push(h));
1833
+ }
1834
+ i.length >= 2 && e.line(i, s.lineWidth);
1835
+ }
1836
+ return !0;
1837
+ }
1838
+ function Do(t) {
1839
+ return [[0.01, -0.12, 0.8], [0, -0.25, 0.98], [-0.04, -0.31, 0.8]].map((e) => oe(t, e).point);
1840
+ }
1841
+ function qo(t, e) {
1842
+ const n = e.shape === "angular" ? li(t, e) : e.projection === "volume" ? hi(t) : tn(t.center.x, t.center.y, t.rx, t.ry, t.angle);
1843
+ if (e.projection !== "volume" || !e.nose) return n;
1844
+ const s = Math.cos(t.angle), o = Math.sin(t.angle), r = (f) => ({
1845
+ x: ((f.x - t.center.x) * s + (f.y - t.center.y) * o) / t.rx,
1846
+ y: ((f.x - t.center.x) * o - (f.y - t.center.y) * s) / t.ry
1847
+ }), i = r(Do(t)[1]), a = Math.sign(i.x), l = i.y, c = n.flatMap((f, y) => {
1848
+ const u = r(f), g = r(n[(y + 1) % n.length]);
1849
+ if (u.y > l == g.y > l) return [];
1850
+ const m = (l - u.y) / (g.y - u.y);
1851
+ return [(u.x + (g.x - u.x) * m) * a];
1852
+ }), h = Math.max(0, i.x * a - Math.max(...c));
1853
+ return !Number.isFinite(h) || h === 0 ? n : n.flatMap((f, y) => {
1854
+ const u = n[(y + 1) % n.length], g = r(f), m = r(u), d = Math.max(1, Math.ceil(Math.hypot(m.x - g.x, m.y - g.y) / 0.025));
1855
+ return Array.from({ length: d }, (x, b) => {
1856
+ const k = b / d, v = { x: f.x + (u.x - f.x) * k, y: f.y + (u.y - f.y) * k }, P = r(v), R = (P.y - l + 0.115) / 0.23;
1857
+ if (P.x * a < 0.5 || R <= 0 || R >= 1) return v;
1858
+ const O = Math.sin(R * Math.PI) ** 2 * h * t.rx * a;
1859
+ return { x: v.x + O * s, y: v.y + O * o };
1860
+ });
1861
+ });
1862
+ }
1863
+ function li(t, e) {
1864
+ const n = Math.min(0.95, Math.max(0.55, e.jawWidth ?? 0.74)), s = Math.min(0.35, Math.max(0.03, e.chinWidth ?? 0.14)), o = [[-1, 0], [-0.92, s], [-0.5, n], [-0.12, Math.sqrt(1 - 0.12 ** 2)]];
1865
+ for (let r = 0; r <= 12; r++) {
1866
+ const i = r * Math.PI / 24;
1867
+ o.push([Math.sin(i), Math.cos(i)]);
1868
+ }
1869
+ return Uo(t, o, e.jawRoundness ?? 0, e.projection === "volume");
1870
+ }
1871
+ function hi(t) {
1872
+ const e = Array.from({ length: 41 }, (n, s) => {
1873
+ const o = -Math.PI / 2 + s * Math.PI / 40;
1874
+ return [Math.sin(o), Math.cos(o)];
1875
+ });
1876
+ return Uo(t, e, 0, !0);
1877
+ }
1878
+ function Uo(t, e, n, s) {
1879
+ const o = [];
1880
+ for (const [a, l] of e)
1881
+ for (let c = 0; c < 40; c++) {
1882
+ const h = c * Math.PI / 20, f = l * Math.sin(h);
1883
+ o.push(oe(t, [l * Math.cos(h), a, s ? Math.min(f, 0.82) : f]).point);
1884
+ }
1885
+ let r = Mn(o);
1886
+ if (n = Math.min(1, Math.max(0, n)), n === 0) return r;
1887
+ const i = n * 0.25;
1888
+ for (let a = 0; a < 3; a++)
1889
+ r = r.flatMap((l, c) => {
1890
+ const h = r[(c + 1) % r.length];
1891
+ return [
1892
+ { x: l.x + (h.x - l.x) * i, y: l.y + (h.y - l.y) * i },
1893
+ { x: h.x + (l.x - h.x) * i, y: h.y + (l.y - h.y) * i }
1894
+ ];
1895
+ });
1896
+ return r;
1897
+ }
1898
+ function Mn(t) {
1899
+ const e = t.sort((o, r) => o.x - r.x || o.y - r.y), n = (o, r, i) => (r.x - o.x) * (i.y - o.y) - (r.y - o.y) * (i.x - o.x), s = (o) => {
1900
+ const r = [];
1901
+ for (const i of o) {
1902
+ for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], i) <= 0; ) r.pop();
1903
+ r.push(i);
1904
+ }
1905
+ return r.slice(0, -1);
1906
+ };
1907
+ return [...s(e), ...s([...e].reverse())];
1908
+ }
1909
+ const Xo = 0.34, yt = 0.12, dt = -0.4, gt = (t, e, n) => t[e] ?? n, ci = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), fi = 0.45, ui = 0.35, di = 0.7, Gn = 0.78;
1910
+ function et(t, e, n, s = "cartoon") {
1911
+ const o = (u) => Math.sqrt(Math.max(0, 1 - u.x * u.x - u.y * u.y));
1912
+ let r = oe(t, [n.x, n.y, o(n)]).facing;
1913
+ const i = t.axes[2];
1914
+ s === "volume" && n.x * i[0] > 0 && (r = Math.max(r, i[2]));
1915
+ const a = Math.atan2(i[0], i[2]), l = Math.cos(a), c = Math.max(ui, l), h = Math.max(di, l), f = Math.cos(t.angle), y = Math.sin(t.angle);
1916
+ if (s === "volume") {
1917
+ const u = oe(t, [n.x, n.y, o(n) * Gn]).point, g = Math.abs(n.x) > 0.1 ? Math.min(1, Math.max(0, r) / 0.25) : 1, m = Math.max(n.x * i[0] > 0 ? 0.2 : 0.5, l);
1918
+ return { facing: r, points: e.map((d) => {
1919
+ const x = (d.x - n.x) * m * t.rx * g, b = (d.y - n.y + i[1] * (o(d) - o(n)) * Gn) * t.ry * g;
1920
+ return { x: u.x + x * f + b * y, y: u.y + x * y - b * f };
1921
+ }) };
1922
+ }
1923
+ return {
1924
+ facing: r,
1925
+ points: e.map((u) => {
1926
+ const g = fi * Math.sin(a) + n.x * c + (u.x - n.x) * h, m = u.y + i[1] * o(u), d = g * t.rx, x = m * t.ry;
1927
+ return { x: t.center.x + d * f + x * y, y: t.center.y + d * y - x * f };
1928
+ })
1929
+ };
1930
+ }
1931
+ const Ct = (t, e, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
1932
+ const i = r / s, a = 1 - i;
1933
+ return { x: a * a * t.x + 2 * a * i * e.x + i * i * n.x, y: a * a * t.y + 2 * a * i * e.y + i * i * n.y };
1934
+ }), he = (t, e, n, s) => {
1935
+ const o = Math.min(1, Math.max(0, (s - t.x) / (n.x - t.x))), r = 1 - o;
1936
+ return r * r * t.y + 2 * r * o * e.y + o * o * n.y;
1937
+ }, $t = (t, e, n, s, o = 16) => Array.from({ length: o }, (r, i) => {
1938
+ const a = Math.PI * 2 * i / o;
1939
+ return { x: t + Math.cos(a) * n, y: e + Math.sin(a) * s };
1940
+ }), qt = 0.05, gi = 0.3, yi = "#e06b7d";
1941
+ function mi(t, e, n, s, o = {}, r) {
1942
+ const i = Math.max(1, Math.min(s * 0.6, 0.14 * e.rx)), a = (w, E) => et(e, w, E, o.projection).points, l = (w, E) => et(e, [], { x: w, y: E }, o.projection).facing, c = gt(n, "smile", 0), h = gt(n, "blink", 0), f = gt(n, "lookX", 0), y = gt(n, "lookY", 0), u = gt(n, "browTilt", 0), g = Math.max(0.2, gt(n, "pupil", 1)), m = Math.min(1, Math.max(0, gt(n, "lid", 0))), d = Math.min(1, Math.max(0, gt(n, "bulge", 0)));
1943
+ for (const w of [1, -1]) {
1944
+ const E = w === 1 ? "left" : "right", H = Xo * w;
1945
+ if (l(H, yt) < qt) continue;
1946
+ const N = { x: H, y: yt }, D = ci(gt(n, `eye.${E}`, 1), h);
1947
+ if (D < 0.2 || o.style === "anime" && m >= 0.98) {
1948
+ const J = c > 0.5 ? 0.12 : -0.06;
1949
+ t.line(a(Ct({ x: H - 0.12, y: yt }, { x: H, y: yt + J }, { x: H + 0.12, y: yt }), N), i);
1950
+ } else if (o.style === "anime")
1951
+ pi(t, e, N, w, D, m, d, g, f, y, i, o, r);
1952
+ else {
1953
+ const J = D > 1.2 || d > 0.02, j = 0.13 * Math.max(D, 1) * (1 + d * 0.7);
1954
+ J && t.shape(a($t(H, yt, j * 0.85, j), N), "#ffffff", i);
1955
+ const Q = (D > 1.2 ? 0.075 : 0.1) * g * (1 + d * 0.3), nt = H + f * 0.08, lt = yt - y * 0.07, xt = $t(nt, lt, Q, Q * 1.1 * Math.min(D, 1));
1956
+ if (t.shape(a(xt, N), t.ink, 0), o.inPupil && r) {
1957
+ const [p] = a([{ x: nt, y: lt }], N), M = a(xt, N), I = Math.min(...M.map((W) => Math.hypot(W.x - p.x, W.y - p.y)));
1958
+ I > 0.5 && (r.save(), r.beginPath(), r.arc(p.x, p.y, I, 0, Math.PI * 2), r.clip(), o.inPupil(r, { x: p.x, y: p.y, r: I, side: E }), r.restore());
1959
+ }
1960
+ if (m > 0.02) {
1961
+ const p = J ? j * 1.15 : Q * 1.4, M = yt + p, I = M - p * 2 * m, W = p * 1.1;
1962
+ t.shape(a([{ x: H - W, y: M + 0.02 }, { x: H + W, y: M + 0.02 }, { x: H + W, y: I }, { x: H - W, y: I }], N), o.skin ?? "#ffffff", 0), t.line(a([{ x: H - W, y: I }, { x: H + W, y: I }], N), i);
1963
+ }
1964
+ }
1965
+ const X = yt + (o.style === "anime" ? 0.38 : 0.3) + gt(n, `brow.${E}`, 0) * 0.14 + Math.max(0, D - 1) * 0.12, K = { x: H + w * 0.13, y: X }, q = { x: H - w * 0.13, y: X + u * 0.1 };
1966
+ t.line(a([K, { x: (K.x + q.x) / 2, y: (K.y + q.y) / 2 }, q], { x: H, y: X }), i);
1967
+ }
1968
+ wi(t, e, n, i, o.projection), xi(t, e, o.ageLines ?? 0, i, o.projection);
1969
+ const x = { x: 0, y: dt };
1970
+ if (l(0, dt) < -qt) return;
1971
+ o.nose && l(0, yt - 0.15) >= qt && (o.projection === "volume" ? t.line(Do(e), i) : t.line(a([{ x: 0.01, y: yt - 0.1 }, { x: 0.03, y: dt + 0.2 }, { x: -0.05, y: dt + 0.17 }], { x: 0, y: dt + 0.22 }), i));
1972
+ const b = 0.25 * Math.max(0.3, gt(n, "mouthWidth", 1)), k = Math.min(1, Math.max(0, gt(n, "mouth", 0)));
1973
+ if (k <= 0.05) {
1974
+ t.line(a(Ct({ x: -b, y: dt }, { x: 0, y: dt - c * 0.25 }, { x: b, y: dt }), x), i);
1975
+ return;
1976
+ }
1977
+ const v = 0.3 * k;
1978
+ let P, R, O, $;
1979
+ if (c > 0.3) {
1980
+ const w = dt + 0.05, E = { x: 0, y: dt - v * 2 };
1981
+ P = [...Ct({ x: b, y: w }, E, { x: -b, y: w })], R = () => w, O = (H) => he({ x: b, y: w }, E, { x: -b, y: w }, H), $ = 0.85;
1982
+ } else if (c < -0.3) {
1983
+ const w = dt - v * 0.6, E = { x: 0, y: dt + v * 1.4 };
1984
+ P = [...Ct({ x: b, y: w }, E, { x: -b, y: w })], R = (H) => he({ x: b, y: w }, E, { x: -b, y: w }, H), O = () => w, $ = 0.5;
1985
+ } else {
1986
+ const w = b * 0.8;
1987
+ P = $t(0, dt, w, v);
1988
+ const E = (H) => v * Math.sqrt(Math.max(0, 1 - (H / w) ** 2));
1989
+ R = (H) => dt + E(H), O = (H) => dt - E(H), $ = 0.5;
1990
+ }
1991
+ if (t.shape(a(P, x), t.ink, 0), k < gi) return;
1992
+ const A = R(0) - O(0), z = b * $, C = (w, E, H = 8) => Array.from({ length: H + 1 }, (N, D) => w + (E - w) * D / H);
1993
+ if (o.tongue) {
1994
+ const w = z * 0.55, E = C(w, -w).map((N) => ({ x: N, y: O(N) })), H = Ct({ x: -w, y: O(-w) }, { x: 0, y: O(0) + A * 0.8 }, { x: w, y: O(w) }, 8);
1995
+ t.shape(a([...E, ...H.slice(1, -1)], x), yi, 0);
1996
+ }
1997
+ if (o.teeth) {
1998
+ const w = Math.min(0.06, A * 0.4), E = C(-z, z).map((N) => ({ x: N, y: R(N) })), H = E.map(({ x: N, y: D }) => ({ x: N * 0.92, y: D - w })).reverse();
1999
+ t.shape(a([...E, ...H], x), "#ffffff", 0);
2000
+ for (const N of [-0.5, 0, 0.5]) {
2001
+ const D = z * N;
2002
+ t.line(a([{ x: D, y: R(D) }, { x: D * 0.92, y: R(D) - w }], x), i * 0.6);
2003
+ }
2004
+ }
2005
+ }
2006
+ function pi(t, e, n, s, o, r, i, a, l, c, h, f, y) {
2007
+ const { x: u, y: g } = n, m = Math.min(1.2, Math.max(0.5, f.eyeScale ?? 1)), d = Math.min(1.2, Math.max(0.45, f.eyeAspect ?? 1)), x = 0.21 * m * (1 + i * 0.15), b = 0.25 * m * d * Math.min(o, 1.6) * (1 - r) * (1 + i * 0.3), k = { x: u - x, y: g }, v = { x: u + x, y: g }, P = { x: u, y: g + b * 1.9 }, R = { x: u, y: g - b * 1.35 }, O = Ct(k, P, v), $ = Ct(v, R, k), A = (X) => et(e, X, n, f.projection).points, z = (X) => X.map((K) => {
2008
+ const q = Math.min(v.x, Math.max(k.x, K.x));
2009
+ return { x: q, y: Math.min(he(k, P, v, q), Math.max(he(v, R, k, q), K.y)) };
2010
+ });
2011
+ t.shape(A([...O, ...$.slice(1, -1)]), "#ffffff", h * 0.5);
2012
+ const C = u + Math.max(-1, Math.min(1, l)) * 0.07 * m, w = g - Math.max(-1, Math.min(1, c)) * 0.055 * m, E = 0.115 * m, H = 0.185 * m;
2013
+ t.shape(A(z($t(C, w, E, H, 24))), f.iris ?? "#4b7fce", h * 0.4), t.shape(A(z($t(C, w - 0.075 * m, E * 0.7, H * 0.35))), "rgba(255,255,255,0.25)", 0);
2014
+ const N = Math.min(0.085, 0.042 * a) * m, D = z($t(C, w, N, N * 1.35));
2015
+ if (t.shape(A(D), t.ink, 0), f.inPupil && y) {
2016
+ const [X] = A([{ x: C, y: w }]), K = Math.min(...A(D).map((q) => Math.hypot(q.x - X.x, q.y - X.y)));
2017
+ K > 0.5 && (y.save(), y.beginPath(), y.arc(X.x, X.y, K, 0, Math.PI * 2), y.clip(), f.inPupil(y, { ...X, r: K, side: s === 1 ? "left" : "right" }), y.restore());
2018
+ }
2019
+ if (t.shape(A(z($t(C - 0.038 * m, w + 0.075 * m, 0.035 * m, 0.045 * m))), "#ffffff", 0), t.shape(A(z($t(C + 0.04 * m, w - 0.04 * m, 0.014 * m, 0.02 * m))), "#ffffff", 0), t.line(A(O), h * 1.1), f.lashes !== !1)
2020
+ for (const X of [0, 0.035]) {
2021
+ const K = u + s * (x - X), q = he(k, P, v, K);
2022
+ t.line(A([{ x: K, y: q }, { x: K + s * 0.055, y: q + 0.07 }]), h * 0.75);
2023
+ }
2024
+ }
2025
+ function xi(t, e, n, s, o) {
2026
+ const r = Math.min(1, Math.max(0, n));
2027
+ if (!(r <= 0))
2028
+ for (const i of [-1, 1]) {
2029
+ const a = { x: i * 0.59, y: yt };
2030
+ if (et(e, [], a, o).facing < qt) continue;
2031
+ for (const h of [-0.06, 0.035]) {
2032
+ const f = [{ x: a.x, y: a.y }, { x: a.x + i * 0.1, y: a.y + h }];
2033
+ t.line(et(e, f, a, o).points, s * 0.45 * r);
2034
+ }
2035
+ const l = { x: i * 0.3, y: -0.38 }, c = Ct({ x: l.x, y: -0.31 }, { x: l.x + i * 0.07, y: -0.4 }, { x: l.x + i * 0.035, y: -0.49 });
2036
+ t.line(et(e, c, l, o).points, s * 0.35 * r);
2037
+ }
2038
+ }
2039
+ const Kn = "#8fd0f5", Vn = (t, e, n) => Array.from({ length: 18 }, (s, o) => {
2040
+ const r = Math.PI * 2 * o / 18, i = Math.sin(r / 2);
2041
+ return { x: t + Math.sin(r) * n * i, y: e - n * 0.9 + Math.cos(r) * n * 1.6 * (0.55 + 0.45 * i) - n * 0.4 };
2042
+ });
2043
+ function wi(t, e, n, s, o) {
2044
+ const r = Math.min(1, Math.max(0, gt(n, "blush", 0))), i = Math.min(1, Math.max(0, gt(n, "tears", 0))), a = Math.min(1, Math.max(0, gt(n, "sweat", 0)));
2045
+ if (!(r + i + a <= 0.01)) {
2046
+ for (const l of [1, -1]) {
2047
+ const c = { x: 0.5 * l, y: -0.16 }, h = et(e, [], c, o).facing >= qt;
2048
+ if (r > 0.01 && h) {
2049
+ const { points: y } = et(e, $t(c.x, c.y, 0.17, 0.1), c, o);
2050
+ if (t.shape(y, `rgba(240, 120, 140, ${(0.75 * r).toFixed(3)})`, 0), r > 0.5)
2051
+ for (const u of [-0.07, 0, 0.07]) {
2052
+ const g = [{ x: c.x + u - 0.018, y: c.y - 0.03 }, { x: c.x + u + 0.018, y: c.y + 0.03 }];
2053
+ t.line(et(e, g, c, o).points, s * 0.3);
2054
+ }
2055
+ }
2056
+ const f = { x: Xo * l, y: yt };
2057
+ if (i > 0.01 && et(e, [], f, o).facing >= qt) {
2058
+ const y = 0.05 + 0.04 * i, u = { x: f.x + 0.06 * l, y: yt - 0.2 - 0.12 * i };
2059
+ if (t.shape(et(e, Vn(u.x, u.y, y), u, o).points, Kn, s * 0.35), i > 0.6) {
2060
+ const g = [{ x: f.x + 0.05 * l, y: yt - 0.1 }, { x: u.x, y: u.y + y * 0.8 }];
2061
+ t.line(et(e, g, u, o).points, s * 0.3);
2062
+ }
2063
+ }
2064
+ }
2065
+ if (a > 0.01) {
2066
+ const l = { x: 0.64, y: 0.42 };
2067
+ et(e, [], l, o).facing >= qt && t.shape(et(e, Vn(l.x, l.y, 0.05 + 0.05 * a), l, o).points, Kn, s * 0.35);
2068
+ }
2069
+ }
2070
+ }
2071
+ const bi = 15;
2072
+ function It(t, e) {
2073
+ const n = Math.sqrt(Math.max(0, 1 - e * e));
2074
+ return [n * Math.sin(t), e, n * Math.cos(t)];
2075
+ }
2076
+ const Mi = ([t, e, n]) => {
2077
+ const s = Math.hypot(t, e, n) || 1;
2078
+ return [t / s, e / s, n / s];
2079
+ };
2080
+ function pt(t, [e, n, s]) {
2081
+ const [o, r, i] = t.axes;
2082
+ return o[2] * e + r[2] * n + i[2] * s;
2083
+ }
2084
+ function it(t, e) {
2085
+ return oe(t, e).point;
2086
+ }
2087
+ function $e(t, e) {
2088
+ const n = Math.abs(t - e) % (Math.PI * 2);
2089
+ return n > Math.PI ? Math.PI * 2 - n : n;
2090
+ }
2091
+ function Ce(t, e, n = 64) {
2092
+ const s = e.top ?? 1, o = e.bottom ?? -1, r = Math.max(8, Math.ceil((s - o) * bi)), i = (g) => Math.min(s, Math.max(o, s - (s - o) * (g - 1) / r)), a = (g) => -Math.PI + Math.PI * 2 * g / n, l = (g, m) => e.normal ? e.normal(g, m) : Mi(e.position(g, m)), c = r + 3, h = new Float64Array(n * c), f = new Float64Array(n * c);
2093
+ for (let g = 0; g < c; g++) {
2094
+ const m = g === 0 || g === c - 1, d = i(g);
2095
+ for (let x = 0; x < n; x++) {
2096
+ const b = g * n + x;
2097
+ if (m) {
2098
+ h[b] = -1;
2099
+ continue;
2100
+ }
2101
+ const k = a(x);
2102
+ h[b] = e.inside(k, d), f[b] = h[b] > -0.35 ? pt(t, l(k, d)) : 0;
2103
+ }
2104
+ }
2105
+ const y = (g) => (g % n + n) % n, u = (g) => {
2106
+ const m = n + 1, d = new Float64Array(m * c);
2107
+ for (let w = 0; w < c; w++)
2108
+ for (let E = 0; E <= n; E++) {
2109
+ const H = w * n + (E === n ? 0 : E);
2110
+ d[w * m + E] = Math.min(h[H], g * f[H]);
2111
+ }
2112
+ const x = (w, E) => d[E * m + w], b = (w, E, H, N) => {
2113
+ const D = x(w, E), X = x(H, N), K = D === X ? 0.5 : Math.min(1, Math.max(0, D / (D - X)));
2114
+ return it(t, e.position(a(w + (H - w) * K), i(E + (N - E) * K)));
2115
+ }, k = n * c * 2, v = new Int32Array(k).fill(-1), P = new Int32Array(k).fill(-1), R = /* @__PURE__ */ new Map(), O = (w, E, H) => {
2116
+ const N = (H * n + y(E)) * 2 + (w ? 1 : 0);
2117
+ return R.has(N) || R.set(N, w ? b(y(E), H, y(E), H + 1) : b(E, H, E + 1, H)), N;
2118
+ }, $ = (w, E) => {
2119
+ v[w] === -1 ? v[w] = E : P[w] = E;
2120
+ }, A = (w, E) => {
2121
+ $(w, E), $(E, w);
2122
+ };
2123
+ for (let w = 0; w < c - 1; w++)
2124
+ for (let E = 0; E < n; E++) {
2125
+ const H = w * m + E, N = (d[H] > 0 ? 8 : 0) | (d[H + 1] > 0 ? 4 : 0) | (d[H + m + 1] > 0 ? 2 : 0) | (d[H + m] > 0 ? 1 : 0);
2126
+ if (N === 0 || N === 15) continue;
2127
+ const D = () => O(!1, E, w), X = () => O(!1, E, w + 1), K = () => O(!0, E, w), q = () => O(!0, E + 1, w);
2128
+ switch (N) {
2129
+ case 1:
2130
+ case 14:
2131
+ A(K(), X());
2132
+ break;
2133
+ case 2:
2134
+ case 13:
2135
+ A(X(), q());
2136
+ break;
2137
+ case 3:
2138
+ case 12:
2139
+ A(K(), q());
2140
+ break;
2141
+ case 4:
2142
+ case 11:
2143
+ A(D(), q());
2144
+ break;
2145
+ case 6:
2146
+ case 9:
2147
+ A(D(), X());
2148
+ break;
2149
+ case 7:
2150
+ case 8:
2151
+ A(K(), D());
2152
+ break;
2153
+ case 5:
2154
+ case 10: {
2155
+ const J = (x(E, w) + x(E + 1, w) + x(E + 1, w + 1) + x(E, w + 1)) / 4 > 0;
2156
+ N === 5 === J ? (A(K(), D()), A(X(), q())) : (A(K(), X()), A(D(), q()));
2157
+ break;
2158
+ }
2159
+ }
2160
+ }
2161
+ const z = [], C = new Uint8Array(k);
2162
+ for (const w of R.keys()) {
2163
+ if (C[w]) continue;
2164
+ const E = [];
2165
+ let H = -1, N = w;
2166
+ for (; N !== -1 && !C[N]; ) {
2167
+ C[N] = 1, E.push(R.get(N));
2168
+ const D = v[N], X = P[N], K = D !== -1 && D !== H && !C[D] ? D : X !== -1 && X !== H && !C[X] ? X : -1;
2169
+ H = N, N = K;
2170
+ }
2171
+ E.length >= 3 && z.push(E);
2172
+ }
2173
+ return z;
2174
+ };
2175
+ return { near: u(1), far: u(-1) };
2176
+ }
2177
+ const Jn = /* @__PURE__ */ new WeakMap();
2178
+ function kn(t, e, n) {
2179
+ let s = Jn.get(t);
2180
+ s || Jn.set(t, s = /* @__PURE__ */ new Map());
2181
+ let o = s.get(e);
2182
+ return o || s.set(e, o = n()), o;
2183
+ }
2184
+ function vn(t, e, n, s) {
2185
+ if (t.save(), t.beginPath(), t.rect(-1e5, -1e5, 2e5, 2e5), s?.length) {
2186
+ t.moveTo(s[0].x, s[0].y);
2187
+ for (const o of s.slice(1)) t.lineTo(o.x, o.y);
2188
+ t.closePath();
2189
+ } else
2190
+ t.ellipse(e.center.x, e.center.y, e.rx, e.ry, e.angle, 0, Math.PI * 2);
2191
+ t.clip("evenodd"), n(), t.restore();
2192
+ }
2193
+ function Go(t, e, n, s = 0.04) {
2194
+ const o = [];
2195
+ let r = [];
2196
+ return e.forEach((i, a) => {
2197
+ pt(t, n[a]) > s ? r.push(it(t, i)) : (r.length >= 2 && o.push(r), r = []);
2198
+ }), r.length >= 2 && o.push(r), o;
2199
+ }
2200
+ const Zn = (t) => t * Math.PI / 180, cn = (t) => {
2201
+ const e = Math.hypot(...t) || 1;
2202
+ return t.map((n) => n / e);
2203
+ }, ki = (t, e) => [t[1] * e[2] - t[2] * e[1], t[2] * e[0] - t[0] * e[2], t[0] * e[1] - t[1] * e[0]];
2204
+ function Qn(t, e, n) {
2205
+ return t >= e + n ? t : t <= e - n ? e : e + (t - e + n) ** 2 / (4 * n);
2206
+ }
2207
+ function Ke(t, e, n) {
2208
+ const s = cn(n), o = t.reduce((c, h, f) => c + h * s[f], 0), i = t.map((c, h) => c - o * s[h]).reduce((c, h) => c + h * h, 0), a = Math.sqrt(Qn(1 - i, e * e, e * e)), l = Qn(o, a, e) - o;
2209
+ return l === 0 ? t : t.map((c, h) => c + s[h] * l);
2210
+ }
2211
+ function vi(t) {
2212
+ if (t.path.length < 4 || (t.path.length - 1) % 3 !== 0) throw new Error("hair: a lock path needs a root and groups of three cubic points");
2213
+ if (!Number.isFinite(t.width) || t.width <= 0 || t.follow !== void 0 && (!Number.isFinite(t.follow) || t.follow < 0))
2214
+ throw new Error("hair: lock width must be positive and follow must be nonnegative");
2215
+ for (const n of t.path)
2216
+ if (!Number.isFinite(n.around) || !Number.isFinite(n.up) || n.up > 1 || n.lift !== void 0 && (!Number.isFinite(n.lift) || n.lift < 0))
2217
+ throw new Error("hair: lock points need finite around/up values, up <= 1 and nonnegative lift");
2218
+ const e = t.path[0];
2219
+ if (e.up < 0 || (e.lift ?? 0) !== 0) throw new Error("hair: a lock root must lie on the scalp (up 0..1, lift 0)");
2220
+ return { ...t, path: t.path.map((n) => ({ ...n })) };
2221
+ }
2222
+ function Ei(t, e, n, s) {
2223
+ const o = (t.path.length - 1) / 3, r = o * 20, i = [], a = [], l = s.trail !== 0 || s.lift !== 0, c = Math.max(0, e + n);
2224
+ for (let h = 0; h <= r; h++) {
2225
+ const f = h / r, y = Math.min(o - 1, Math.floor(f * o)), u = f * o - y, g = 1 - u, m = [g ** 3, 3 * g * g * u, 3 * g * u * u, u ** 3], d = t.path.slice(y * 3, y * 3 + 4), x = Zn(d.reduce((H, N, D) => H + N.around * m[D], 0)), b = d.reduce((H, N, D) => H + N.up * m[D], 0), k = d.reduce((H, N, D) => H + (N.lift ?? 0) * m[D], 0), v = 1 + e + n + k, P = b >= 0 ? Math.sqrt(Math.max(0, 1 - b * b)) : 1, R = f * f * (t.follow ?? 1), O = Zn(s.swing) * R, $ = x - O, A = [Math.sin($) * P * v, b * (b >= 0 ? v : 1), Math.cos($) * P * v], z = [A[0], A[1] + s.lift * R, A[2] - s.trail * R], C = [Math.sin($) * P, Math.max(0, b), Math.cos($) * P], w = cn(A), E = l && R > 0 ? Ke(z, c, w) : z;
2226
+ a.push(w), i.push({ center: E, normal: C, left: E, right: E, t: f });
2227
+ }
2228
+ return i.forEach((h, f) => {
2229
+ const y = i[Math.max(0, f - 1)].center, g = i[Math.min(r, f + 1)].center.map((x, b) => x - y[b]), m = cn(ki(h.normal, g)), d = t.width * Math.sin(Math.PI * h.t) ** 0.6 * 0.5;
2230
+ h.left = h.center.map((x, b) => x + m[b] * d), h.right = h.center.map((x, b) => x - m[b] * d), l && h.t > 0 && (t.follow ?? 1) > 0 && (h.left = Ke(h.left, c, a[f]), h.right = Ke(h.right, c, a[f]));
2231
+ }), i;
2232
+ }
2233
+ const te = (t, e, n) => t.map((s, o) => s + (e[o] - s) * n);
2234
+ function Si(t, e, n) {
2235
+ const s = n ? 1 : -1, o = [];
2236
+ let r = [];
2237
+ for (let i = 0; i < e.length; i++) {
2238
+ const a = e[i], l = s * pt(t, a.normal) >= 0;
2239
+ if (i > 0) {
2240
+ const c = e[i - 1], h = s * pt(t, c.normal), f = s * pt(t, a.normal);
2241
+ if (h >= 0 !== l) {
2242
+ const y = h / (h - f), u = {
2243
+ center: te(c.center, a.center, y),
2244
+ left: te(c.left, a.left, y),
2245
+ right: te(c.right, a.right, y),
2246
+ normal: te(c.normal, a.normal, y),
2247
+ t: c.t + (a.t - c.t) * y
2248
+ };
2249
+ l ? r = [u] : (r.push(u), r.length >= 2 && o.push(r), r = []);
2250
+ }
2251
+ }
2252
+ l && r.push(a);
2253
+ }
2254
+ return r.length >= 2 && o.push(r), o;
2255
+ }
2256
+ function Ko(t, e, n, s, o, r, i) {
2257
+ const a = (n.locks ?? []).map((h) => Ei(h, n.volume, s, o)), l = (h) => h.reduce((f, y) => f + pt(e, y.center), 0) / h.length;
2258
+ a.sort((h, f) => l(h) - l(f));
2259
+ const c = Math.max(0.7, r * 0.35);
2260
+ for (const h of a)
2261
+ for (const f of Si(e, h, i)) {
2262
+ const y = f.map((m) => it(e, m.left)), u = f.map((m) => it(e, m.right));
2263
+ if (t.shape([...y, ...u.slice().reverse()], n.color, 0), t.look === "clean" && (n.shine ?? 0) > 0) {
2264
+ const m = f.filter((d) => d.t >= 0.2 && d.t <= 0.75);
2265
+ if (m.length >= 3) {
2266
+ const d = m.map((b, k) => {
2267
+ const v = 0.16 * Math.sin(Math.PI * k / (m.length - 1));
2268
+ return it(e, te(b.center, b.left, 0.16 + v));
2269
+ }), x = m.map((b) => it(e, te(b.center, b.left, 0.16)));
2270
+ t.shape([...d, ...x.reverse()], `rgba(255,255,255,${n.shine})`, 0);
2271
+ }
2272
+ }
2273
+ const g = f.filter((m) => m.t > 0.3);
2274
+ g.length >= 2 && t.line(g.map((m) => it(e, m.left)), c);
2275
+ }
2276
+ }
2277
+ const rt = (t, e, n = 0) => ({ around: t, up: e, lift: n }), Ve = () => [
2278
+ { width: 0.66, follow: 0.22, path: [rt(-38, 0.88), rt(-12, 0.94, 0.08), rt(58, 0.76, 0.09), rt(94, 0.16, 0.03)] },
2279
+ { width: 0.58, follow: 0.3, path: [rt(-42, 0.8), rt(-24, 0.7, 0.12), rt(18, 0.57, 0.09), rt(64, 0.3)] },
2280
+ { width: 0.36, follow: 0.18, path: [rt(-58, 0.76), rt(-76, 0.56, 0.07), rt(-90, 0.12, 0.06), rt(-102, -0.36)] }
2281
+ ];
2282
+ function jn(t) {
2283
+ return [-100, -130, -160, -190, -220, -250, -280].map((e, n) => {
2284
+ const s = n % 2 === 0 ? 1 : -1, o = t ? -2.45 - n % 3 * 0.12 : -1.06 - n % 3 * 0.09;
2285
+ return {
2286
+ width: t ? 0.88 : 0.92,
2287
+ follow: t ? 0.8 + n % 3 * 0.12 : 0.38 + n % 3 * 0.08,
2288
+ path: t ? [
2289
+ rt(e, 0.7),
2290
+ rt(e + s * 9, 0.2, 0.12),
2291
+ rt(e - s * 13, -0.5, 0.2),
2292
+ rt(e - s * 8, -0.95, 0.16),
2293
+ rt(e - s * 3, -1.4, 0.12),
2294
+ rt(e + s * 18, o + 0.35, 0.22),
2295
+ rt(e + s * 12, o, 0.03)
2296
+ ] : [
2297
+ rt(e, 0.7),
2298
+ rt(e + s * 7, 0.15, 0.2),
2299
+ rt(e - s * 8, -0.75, 0.25),
2300
+ rt(e + s * 5, o)
2301
+ ]
2302
+ };
2303
+ });
2304
+ }
2305
+ const Pi = {
2306
+ softSweep: {
2307
+ volume: 0.12,
2308
+ shine: 0.16,
2309
+ part: -38,
2310
+ strands: "part",
2311
+ sweep: -0.08,
2312
+ hairline: { front: 0.64, side: 0.12, back: -0.8 },
2313
+ locks: Ve()
2314
+ },
2315
+ flowingBob: {
2316
+ volume: 0.15,
2317
+ shine: 0.16,
2318
+ length: 0.96,
2319
+ fall: { taper: 0.08, wave: 0.08 },
2320
+ part: -38,
2321
+ strands: "part",
2322
+ sweep: -0.08,
2323
+ hairline: { front: 0.64, side: 0.08, back: -0.8 },
2324
+ coversEars: !0,
2325
+ locks: [...jn(!1), ...Ve()]
2326
+ },
2327
+ cascadingWaves: {
2328
+ volume: 0.16,
2329
+ shine: 0.16,
2330
+ length: 2.38,
2331
+ fall: { taper: 0.18, wave: 0.12 },
2332
+ part: -38,
2333
+ strands: "part",
2334
+ sweep: -0.08,
2335
+ hairline: { front: 0.64, side: 0.08, back: -0.8 },
2336
+ coversEars: !0,
2337
+ locks: [...jn(!0), ...Ve()]
2338
+ }
2339
+ }, fe = { swing: 0, trail: 0, lift: 0 };
2340
+ function _e(t) {
2341
+ if (!t) return fe;
2342
+ const e = t["hair.swing"] ?? 0, n = t["hair.trail"] ?? 0, s = t["hair.lift"] ?? 0;
2343
+ return e === 0 && n === 0 && s === 0 ? fe : { swing: e, trail: n, lift: s };
2344
+ }
2345
+ const Vo = (t) => t.swing === 0 && t.trail === 0 && t.lift === 0;
2346
+ function Ua(t) {
2347
+ return t.length > 0 || t.ties.some((e) => e.kind !== "bun") || (t.locks ?? []).some((e) => (e.follow ?? 1) > 0);
2348
+ }
2349
+ function fn([t, e, n], s) {
2350
+ if (s === 0) return [t, e, n];
2351
+ const o = Math.cos(s), r = Math.sin(s);
2352
+ return [t * o - n * r, e, n * o + t * r];
2353
+ }
2354
+ const to = {
2355
+ color: "#6b4630",
2356
+ volume: 0.1,
2357
+ hairline: { front: 0.5, side: 0.12, back: -0.82 },
2358
+ sweep: 0,
2359
+ recede: 0,
2360
+ length: 0,
2361
+ opening: 84,
2362
+ texture: "smooth",
2363
+ textureAmount: 0,
2364
+ quiff: 0,
2365
+ flat: 0,
2366
+ part: null,
2367
+ strands: "none",
2368
+ fill: "solid",
2369
+ ties: [],
2370
+ coversEars: !1
2371
+ }, eo = 1.75, Ai = {
2372
+ ...Pi,
2373
+ // Short hair and hairlines
2374
+ bald: { volume: 0, hairline: { front: 2, side: 2, back: 2 } },
2375
+ buzzCut: { volume: 0, fill: "stipple", hairline: { front: 0.52, side: 0.1, back: -0.8 } },
2376
+ crewCut: { volume: 0.1, texture: "spiky", textureAmount: 0.07, hairline: { front: 0.55, side: 0.1, back: -0.8 } },
2377
+ short: { volume: 0.12, texture: "spiky", textureAmount: 0.1, hairline: { front: 0.42, side: 0.1, back: -0.82 }, sweep: 0.12 },
2378
+ sidePart: { volume: 0.14, part: 35, strands: "sweep", sweep: -0.22, hairline: { front: 0.5, side: 0.08, back: -0.82 } },
2379
+ sideSwept: { volume: 0.15, part: 45, strands: "sweep", sweep: -0.38, hairline: { front: 0.42, side: 0.05, back: -0.82 } },
2380
+ slickBack: { volume: 0.12, strands: "combed", hairline: { front: 0.62, side: 0.15, back: -0.8 } },
2381
+ quiff: { volume: 0.12, quiff: 0.42, strands: "combed", hairline: { front: 0.6, side: 0.15, back: -0.8 } },
2382
+ spiky: { volume: 0.12, texture: "spiky", textureAmount: 0.34, hairline: { front: 0.5, side: 0.12, back: -0.8 } },
2383
+ mangaSpikes: { volume: 0.12, texture: "spiky", textureAmount: 0.08, hairline: { front: 0.55, side: 0.12, back: -0.7 }, spikes: [
2384
+ { around: -100, up: 0.4, length: 0.55, width: 0.24 },
2385
+ { around: -65, up: 0.7, length: 0.6, width: 0.25 },
2386
+ { around: -25, up: 0.93, length: 0.6, width: 0.24 },
2387
+ { around: 40, up: 0.87, length: 0.7, width: 0.25 },
2388
+ { around: 85, up: 0.55, length: 0.55, width: 0.24 },
2389
+ { around: 160, up: 0.8, length: 0.5, width: 0.24 },
2390
+ { around: -160, up: 0.65, length: 0.55, width: 0.24 }
2391
+ ] },
2392
+ mangaSweep: { volume: 0.14, texture: "spiky", textureAmount: 0.1, sweep: -0.35, hairline: { front: 0.5, side: 0.08, back: -0.8 }, spikes: [
2393
+ { around: -95, up: 0.45, length: 0.35, width: 0.2 },
2394
+ { around: -60, up: 0.8, length: 0.4, width: 0.24 },
2395
+ { around: 75, up: 0.55, length: 0.4, width: 0.23 },
2396
+ { around: 150, up: 0.75, length: 0.35, width: 0.2 }
2397
+ ] },
2398
+ undercut: { volume: 0.16, quiff: 0.18, part: 40, strands: "sweep", sweep: -0.15, hairline: { front: 0.55, side: 0.42, back: -0.3 } },
2399
+ curlyCrop: { volume: 0.14, texture: "curly", textureAmount: 0.12, hairline: { front: 0.5, side: 0.1, back: -0.8 } },
2400
+ afro: { volume: 0.5, texture: "curly", textureAmount: 0.12, hairline: { front: 0.5, side: -0.1, back: -0.85 }, coversEars: !0 },
2401
+ wavyCrop: { volume: 0.16, texture: "wavy", textureAmount: 0.08, part: 30, hairline: { front: 0.45, side: 0.05, back: -0.82 } },
2402
+ shortLocs: { volume: 0.16, texture: "locs", textureAmount: 0.1, hairline: { front: 0.38, side: -0.25, back: -0.85 }, strands: "hanging", coversEars: !0 },
2403
+ flatTop: { volume: 0.1, flat: 0.42, hairline: { front: 0.5, side: 0.15, back: -0.78 } },
2404
+ receding: { volume: 0.14, recede: 0.28, strands: "thin", hairline: { front: 0.74, side: 0.1, back: -0.8 } },
2405
+ thinning: { volume: 0.05, strands: "thin", hairline: { front: 0.72, side: 0.05, back: -0.78 } },
2406
+ // Medium and long hair
2407
+ pixie: { volume: 0.16, texture: "spiky", textureAmount: 0.07, sweep: 0.3, hairline: { front: 0.32, side: -0.1, back: -0.82 } },
2408
+ bob: { volume: 0.2, length: 1.05, opening: 84, sweep: 0.2, part: -25, hairline: { front: 0.34, side: 0.05, back: -0.85 }, coversEars: !0 },
2409
+ longBob: { volume: 0.18, length: 1.35, opening: 84, part: 0, strands: "part", hairline: { front: 0.5, side: 0.05, back: -0.85 }, coversEars: !0 },
2410
+ wavyBob: { volume: 0.22, length: 1.2, opening: 84, part: 18, texture: "wavy", textureAmount: 0.1, hairline: { front: 0.45, side: 0.05, back: -0.85 }, coversEars: !0 },
2411
+ shoulderStraight: { volume: 0.16, length: eo, opening: 84, part: 0, strands: "part", hairline: { front: 0.5, side: 0.05, back: -0.85 }, coversEars: !0 },
2412
+ shoulderWaves: { volume: 0.22, length: eo, opening: 84, part: 22, texture: "wavy", textureAmount: 0.12, hairline: { front: 0.45, side: 0.05, back: -0.85 }, coversEars: !0 },
2413
+ longStraight: { volume: 0.14, length: 2.6, opening: 84, part: 0, strands: "hanging", hairline: { front: 0.5, side: 0.05, back: -0.85 }, coversEars: !0 },
2414
+ longWaves: { volume: 0.2, length: 2.5, opening: 84, part: 20, texture: "wavy", textureAmount: 0.14, hairline: { front: 0.45, side: 0.05, back: -0.85 }, coversEars: !0 },
2415
+ longCurls: { volume: 0.26, length: 2.5, opening: 84, texture: "curly", textureAmount: 0.13, hairline: { front: 0.45, side: 0.05, back: -0.85 }, coversEars: !0 },
2416
+ longLocs: { volume: 0.2, length: 2.6, opening: 84, texture: "locs", textureAmount: 0.12, strands: "hanging", part: 0, hairline: { front: 0.45, side: 0.05, back: -0.85 }, coversEars: !0 },
2417
+ lowPonytail: { volume: 0.12, part: 0, strands: "combed", hairline: { front: 0.5, side: 0.1, back: -0.82 }, ties: [{ kind: "ponytail", at: "low", length: 1.5 }] },
2418
+ highPonytail: { volume: 0.12, part: 18, strands: "combed", hairline: { front: 0.45, side: 0.1, back: -0.78 }, ties: [{ kind: "ponytail", at: "high", length: 2 }] },
2419
+ ponytail: { volume: 0.12, sweep: 0.2, hairline: { front: 0.42, side: 0.1, back: -0.78 }, ties: [{ kind: "ponytail", at: "high", length: 1.8 }] },
2420
+ sidePonytail: { volume: 0.12, part: -20, strands: "combed", hairline: { front: 0.45, side: 0.1, back: -0.82 }, ties: [{ kind: "ponytail", at: "left", length: 1.5 }] },
2421
+ topBun: { volume: 0.12, part: 0, strands: "combed", hairline: { front: 0.5, side: 0.1, back: -0.8 }, ties: [{ kind: "bun", at: "top", size: 0.32 }] },
2422
+ lowBun: { volume: 0.12, part: 0, strands: "combed", hairline: { front: 0.5, side: 0.1, back: -0.8 }, ties: [{ kind: "bun", at: "low", size: 0.34 }] },
2423
+ singleBraid: { volume: 0.12, part: 0, strands: "combed", hairline: { front: 0.5, side: 0.1, back: -0.82 }, ties: [{ kind: "braid", at: "low", length: 2.2 }] },
2424
+ twinBraids: { volume: 0.12, part: 0, strands: "part", hairline: { front: 0.5, side: 0.05, back: -0.82 }, ties: [{ kind: "braid", at: "left", length: 1.9 }, { kind: "braid", at: "right", length: 1.9 }], coversEars: !0 },
2425
+ braids: { volume: 0.12, part: 0, strands: "part", hairline: { front: 0.5, side: 0.05, back: -0.82 }, ties: [{ kind: "braid", at: "left", length: 1.6 }, { kind: "braid", at: "right", length: 1.6 }], coversEars: !0 }
2426
+ }, Xa = {
2427
+ black: "#22201f",
2428
+ brown: "#6b4630",
2429
+ chestnut: "#7b4a2b",
2430
+ auburn: "#9a4426",
2431
+ blond: "#d9b55a",
2432
+ ginger: "#c8662f",
2433
+ gray: "#a7a29c",
2434
+ white: "#ecebe7"
2435
+ };
2436
+ function Oi(t) {
2437
+ const e = typeof t == "string" ? { style: t } : t, n = e.style ? Ai[e.style] : {};
2438
+ if (e.style && !n) throw new Error(`hair: unknown style '${e.style}'`);
2439
+ const { style: s, hairline: o, ...r } = e, i = {
2440
+ ...to,
2441
+ ...n,
2442
+ ...r,
2443
+ hairline: { ...to.hairline, ...n.hairline, ...o },
2444
+ ties: (r.ties ?? n.ties ?? []).map((a) => ({ ...a })),
2445
+ ...r.spikes ?? n.spikes ? { spikes: (r.spikes ?? n.spikes).map((a) => ({ ...a })) } : {},
2446
+ ...r.locks ?? n.locks ? { locks: (r.locks ?? n.locks).map(vi) } : {},
2447
+ ...r.fall ?? n.fall ? { fall: { ...r.fall ?? n.fall } } : {}
2448
+ };
2449
+ if (i.shine !== void 0 && (!Number.isFinite(i.shine) || i.shine < 0 || i.shine > 1)) throw new Error("hair: shine must be between 0 and 1");
2450
+ if (i.fall && (!Number.isFinite(i.fall.taper) || i.fall.taper < 0 || i.fall.taper > 1 || !Number.isFinite(i.fall.wave) || i.fall.wave < 0))
2451
+ throw new Error("hair: fall needs taper between 0 and 1 and nonnegative wave");
2452
+ return i;
2453
+ }
2454
+ const Ut = (t) => t * Math.PI / 180, ee = (t, e, n) => {
2455
+ const s = Math.min(1, Math.max(0, (n - t) / (e - t)));
2456
+ return s * s * (3 - 2 * s);
2457
+ }, un = (t) => 1 - Math.abs(2 * (t - Math.floor(t)) - 1);
2458
+ function Le(t, e) {
2459
+ const { front: n, side: s, back: o } = t.hairline, r = (n - o) / 2, i = (n + o) / 2, a = (i + s) / 2, l = (i - s) / 2, c = Math.max(0, Math.cos(e));
2460
+ let h = a + r * Math.cos(e) + l * Math.cos(2 * e);
2461
+ return h -= t.sweep * Math.sin(e) * c, h += t.recede * Math.exp(-(((Math.abs(e) - 0.75) / 0.32) ** 2)), (t.texture === "spiky" || t.texture === "curly") && (h -= t.textureAmount * 0.6 * un(e * 11 / (Math.PI * 2)) * c), h;
2462
+ }
2463
+ function no(t, e, n) {
2464
+ const s = t.textureAmount;
2465
+ switch (t.texture) {
2466
+ case "spiky":
2467
+ return s * (un(e * 11 / (Math.PI * 2)) * un(n * 2.6 + 0.5)) ** 1.2 * ee(-0.3, 0.4, n);
2468
+ case "curly":
2469
+ return s * Math.sqrt(Math.abs(Math.sin(e * 7)) * Math.abs(Math.sin(n * Math.PI * 2.6)));
2470
+ case "wavy":
2471
+ return s * (0.5 + 0.5 * Math.sin(e * 6 + n * 6));
2472
+ case "locs":
2473
+ return s * Math.abs(Math.sin(e * 10)) ** 0.6;
2474
+ default:
2475
+ return 0;
2476
+ }
2477
+ }
2478
+ function Jo(t, e, n = fe) {
2479
+ const s = t.length > 0, o = /* @__PURE__ */ new Map(), r = (h) => {
2480
+ let f = o.get(h);
2481
+ return f === void 0 && o.set(h, f = Le(t, h)), f;
2482
+ }, i = Ut(t.opening), a = (h) => t.length + (t.texture === "wavy" || t.texture === "curly" || t.texture === "locs" ? 0.12 * Math.sin(h * 9) : 0) + (t.fall?.wave ?? 0) * Math.cos(h * 3 + 0.6), l = (h, f, y) => {
2483
+ if (t.flat <= 0 || f < 0.45) return null;
2484
+ const u = (f - 0.45) / 0.55, g = Math.sqrt(1 - 0.45 * 0.45) * y * (1 - u ** 5), m = 0.45 + (1 + t.flat - 0.45) * Math.min(1, u * 1.8);
2485
+ return [g * Math.sin(h), m * (1 + e), g * Math.cos(h)];
2486
+ }, c = {
2487
+ top: 1,
2488
+ bottom: s ? -(t.length + 0.25 + Math.abs(t.fall?.wave ?? 0)) : -1,
2489
+ inside(h, f) {
2490
+ const y = f - r(h);
2491
+ if (!s) return y;
2492
+ const u = Math.min(f + a(h), $e(h, 0) - i);
2493
+ return Math.max(y, u);
2494
+ },
2495
+ position(h, f) {
2496
+ if (s && f < 0) {
2497
+ const k = t.length < 1.5 ? 0.14 * ee(-t.length + 0.45, -t.length - 0.1, f) : 0, v = (t.fall?.taper ?? 0) * ee(0, -Math.max(0.1, a(h)), f), P = 1 + e + t.volume * (1 - k * 2.5) + no(t, h, f) - k - v;
2498
+ return [P * Math.sin(h), f, P * Math.cos(h)];
2499
+ }
2500
+ const y = 0.4 + 0.6 * ee(0, 0.3, f - Le(t, h)), u = 1 + e + (t.volume + no(t, h, f)) * y, g = l(h, f, u);
2501
+ if (g) return g;
2502
+ const [m, d, x] = It(h, f), b = [m * u, d * u, x * u];
2503
+ if (t.quiff > 0) {
2504
+ const k = t.quiff * Math.exp(-((h / 0.7) ** 2)) * ee(0.15, 0.85, f);
2505
+ b[1] += k * 0.7, b[2] += k * 0.45;
2506
+ }
2507
+ return b;
2508
+ },
2509
+ normal(h, f) {
2510
+ return s && f < 0 ? [Math.sin(h), 0, Math.cos(h)] : It(h, f);
2511
+ }
2512
+ };
2513
+ return s && !Vo(n) ? Ii(c, t, n) : c;
2514
+ }
2515
+ function Ii(t, e, n) {
2516
+ const s = (r) => r < 0 ? ee(-0.15, -Math.max(0.7, e.length), r) : 0, o = (r) => Ut(n.swing) * s(r);
2517
+ return {
2518
+ top: t.top,
2519
+ bottom: t.bottom,
2520
+ inside: (r, i) => t.inside(r + o(i), i),
2521
+ position(r, i) {
2522
+ const a = s(i);
2523
+ if (a === 0) return t.position(r, i);
2524
+ const l = o(i), [c, h, f] = fn(t.position(r + l, i), l);
2525
+ return [c, h + n.lift * a, f - n.trail * a];
2526
+ },
2527
+ normal: (r, i) => fn(t.normal(r + o(i), i), o(i))
2528
+ };
2529
+ }
2530
+ const Wi = (t) => t.texture === "spiky" || t.texture === "curly" || t.texture === "locs" ? 104 : t.texture === "wavy" ? 80 : 64;
2531
+ function Zo(t, e, n, s) {
2532
+ return kn(t, Hi(e, s), () => Ce(t, n, Wi(e)));
2533
+ }
2534
+ const oo = /* @__PURE__ */ new WeakMap();
2535
+ let Ti = 1;
2536
+ function Hi(t, e) {
2537
+ if (Vo(e)) return t;
2538
+ let n = oo.get(t);
2539
+ return n || oo.set(t, n = Ti++), `${n}:${e.swing}:${e.trail}:${e.lift}`;
2540
+ }
2541
+ function Qo(t) {
2542
+ switch (t) {
2543
+ case "top":
2544
+ return { point: [0, 1.02, -0.12], out: [0, 1, -0.15] };
2545
+ case "high":
2546
+ return { point: [0, 0.72, -0.78], out: [0, 0.55, -0.85] };
2547
+ case "low":
2548
+ return { point: [0, -0.2, -1.02], out: [0, -0.1, -1] };
2549
+ case "left":
2550
+ return { point: [0.82, -0.32, -0.45], out: [0.8, -0.2, -0.5] };
2551
+ case "right":
2552
+ return { point: [-0.82, -0.32, -0.45], out: [-0.8, -0.2, -0.5] };
2553
+ }
2554
+ }
2555
+ function Je(t, [e, n, s]) {
2556
+ const o = it(t, [e, n, s]);
2557
+ return { x: o.x - t.center.x, y: o.y - t.center.y };
2558
+ }
2559
+ function $i(t, e, n, s = 16) {
2560
+ return Array.from({ length: s + 1 }, (o, r) => {
2561
+ const i = r / s, a = 1 - i;
2562
+ return { x: a * a * t.x + 2 * a * i * e.x + i * i * n.x, y: a * a * t.y + 2 * a * i * e.y + i * i * n.y };
2563
+ });
2564
+ }
2565
+ function _i(t, e, n, s, o) {
2566
+ const r = t.ry, i = (e.length ?? 1.8) * r, a = Je(t, fn(s, Ut(o.swing))), l = Je(t, [0, o.lift, -o.trail]), c = Math.hypot(a.x, a.y) || 1, h = e.at === "high" || e.at === "low" || e.at === "top" ? Je(t, [0.95, 0, 0]) : { x: 0 }, f = e.kind === "braid" ? 0.15 : 0.5, y = {
2567
+ x: n.x + a.x / c * r * f + h.x * 0.9 + l.x * 0.5,
2568
+ y: n.y + a.y / c * r * f * 0.6 + l.y * 0.5
2569
+ }, u = { x: n.x + a.x / c * r * f * 0.6 + h.x * 1.3 + l.x, y: n.y + i + l.y };
2570
+ return $i(n, y, u);
2571
+ }
2572
+ const Fe = (t) => Math.max(1, t * 0.5), jo = (t, e) => Math.max(0.8, Math.min(t * 0.4, 0.1 * e.rx));
2573
+ function ts(t, e, n, s, o, r) {
2574
+ const { point: i, out: a } = Qo(s.at), l = 1 + n.volume, c = it(e, [i[0] * l, i[1] * l, i[2] * l]), h = Fe(o), f = jo(o, e);
2575
+ if (s.kind === "bun") {
2576
+ const m = s.size ?? 0.32, d = it(e, [i[0] * l + a[0] * m, i[1] * l + a[1] * m, i[2] * l + a[2] * m]);
2577
+ t.ellipse(d.x, d.y, m * e.rx, m * e.ry, e.angle, n.color, h);
2578
+ const x = m * e.rx * 0.55;
2579
+ t.line(
2580
+ Array.from({ length: 9 }, (b, k) => {
2581
+ const v = -0.4 + k / 8 * Math.PI * 1.3;
2582
+ return { x: d.x + Math.cos(v) * x, y: d.y + Math.sin(v) * x * 0.8 };
2583
+ }),
2584
+ f
2585
+ );
2586
+ return;
2587
+ }
2588
+ const y = _i(e, s, c, a, r), u = (s.size ?? (s.kind === "braid" ? 0.2 : 0.34)) * e.rx * 2;
2589
+ if (s.kind === "ponytail")
2590
+ t.shape(ut(y, u, u * 0.15), n.color, h), t.line(y.slice(3, y.length - 3), f);
2591
+ else {
2592
+ const d = y.slice(0, y.length - 3);
2593
+ for (let k = 0; k < 7; k++) {
2594
+ const v = d[Math.floor(k / 7 * (d.length - 1))], P = d[Math.floor((k + 1) / 7 * (d.length - 1))], R = Math.atan2(P.y - v.y, P.x - v.x), O = Math.hypot(P.x - v.x, P.y - v.y), $ = u * (1 - k / (7 * 2.2)), A = (k % 2 === 0 ? 1 : -1) * 0.35, z = { x: (v.x + P.x) / 2, y: (v.y + P.y) / 2 };
2595
+ t.ellipse(z.x, z.y, O * 0.62, $ * 0.5, R + A, n.color, h * 0.8);
2596
+ }
2597
+ const x = d[d.length - 1], b = y[y.length - 1];
2598
+ t.shape(ut([x, b], u * 0.7, u * 0.2), n.color, h * 0.8);
2599
+ }
2600
+ const g = y[s.kind === "braid" ? y.length - 4 : 2];
2601
+ t.ellipse(g.x, g.y, u * 0.32, u * 0.22, e.angle, n.color, h);
2602
+ }
2603
+ function es(t, e) {
2604
+ return pt(t, Qo(e.at).out) < -0.2;
2605
+ }
2606
+ function Li(t) {
2607
+ const e = (o, r, i = 0, a = 14) => Array.from({ length: a + 1 }, (l, c) => {
2608
+ const h = c / a;
2609
+ return [o[0] + (r[0] - o[0]) * h + i * Math.sin(Math.PI * h), o[1] + (r[1] - o[1]) * h];
2610
+ }), n = Ut(t.part ?? 0), s = (o) => Le(t, o) + 0.04;
2611
+ switch (t.strands) {
2612
+ case "part":
2613
+ return [e([n, s(n)], [n, 0.97])];
2614
+ case "sweep": {
2615
+ const o = Math.sign(t.sweep || -1), r = [0.9, 0.72, 0.55].map((i, a) => {
2616
+ const l = n + o * (0.6 + a * 0.35);
2617
+ return e([n, i], [l, Math.max(s(l) + 0.05, i - 0.35)], 0.05 * o);
2618
+ });
2619
+ return [e([n, s(n)], [n, 0.97]), ...r];
2620
+ }
2621
+ case "combed":
2622
+ return [-0.75, -0.35, 0.35, 0.75].map((o) => e([o, s(o) + 0.02], [o * 0.3, 0.86]));
2623
+ case "thin":
2624
+ return [-0.5, 0.05, 0.6].map((o) => e([o, s(o) + 0.02], [o * 0.5, 0.95], 0.12));
2625
+ case "hanging": {
2626
+ const o = t.length > 0 ? -t.length + 0.25 : -0.4, r = [-2.6, -2, -1.4, 1.4, 2, 2.6, 3.05].map((i) => e([i, Le(t, i) < 0.9 ? 0.6 : 0.9], [i, o], 0));
2627
+ return t.part !== null && r.push(e([n, s(n)], [n, 0.97])), r;
2628
+ }
2629
+ default:
2630
+ return [];
2631
+ }
2632
+ }
2633
+ function Bi(t, e, n, s, o) {
2634
+ if (s.fill === "stipple" || s.hairline.front > 1.5) return;
2635
+ const r = o.motion ?? fe, i = o.lineWidth * 0.45 / n.rx, { far: a } = Zo(n, s, Jo(s, i, r), r);
2636
+ vn(e, n, () => {
2637
+ for (const l of s.ties) es(n, l) && ts(t, n, s, l, o.lineWidth, r);
2638
+ ns(t, n, s, o.lineWidth, i, !1);
2639
+ for (const l of a) t.shape(l, s.color, Fe(o.lineWidth));
2640
+ Ko(t, n, s, i, r, o.lineWidth, !1);
2641
+ }, o.headOutline);
2642
+ }
2643
+ function dn(t, e, n, s) {
2644
+ if (n.hairline.front > 1.5) return;
2645
+ const o = s.motion ?? fe, r = s.lineWidth * 0.45 / e.rx, i = Jo(n, r, o), a = jo(s.lineWidth, e);
2646
+ if (n.fill === "stipple") {
2647
+ for (let h = 0.97; h > -1; h -= 0.17)
2648
+ for (let f = -Math.PI; f < Math.PI; f += 0.27) {
2649
+ const y = Math.round(h * 100) % 2 * 0.13;
2650
+ if (i.inside(f + y, h) < 0.02) continue;
2651
+ const u = It(f + y, h);
2652
+ if (pt(e, u) < 0.12) continue;
2653
+ const g = it(e, u);
2654
+ t.dot(g.x, g.y, a * 0.4);
2655
+ }
2656
+ return;
2657
+ }
2658
+ const { near: l } = Zo(e, n, i, o), c = Fe(s.lineWidth);
2659
+ ns(t, e, n, s.lineWidth, r, !0);
2660
+ for (const h of l) t.shape(h, n.color, c);
2661
+ Ko(t, e, n, r, o, s.lineWidth, !0);
2662
+ for (const h of Li(n)) {
2663
+ const f = h.map(([u, g]) => {
2664
+ const [m, d, x] = i.position(u, g);
2665
+ return [m * 0.985, d * 0.985, x * 0.985];
2666
+ }), y = h.map(([u, g]) => i.normal(u, g));
2667
+ for (const u of Go(e, f, y, 0.12)) t.line(u, a);
2668
+ }
2669
+ for (const h of n.ties) es(e, h) || ts(t, e, n, h, s.lineWidth, o);
2670
+ }
2671
+ function ns(t, e, n, s, o, r) {
2672
+ for (const i of n.spikes ?? []) {
2673
+ const a = It(Ut(i.around), Math.max(-1, Math.min(1, i.up)));
2674
+ if (pt(e, a) >= 0 !== r) continue;
2675
+ const l = [Math.cos(Ut(i.around)), 0, -Math.sin(Ut(i.around))], c = [a[1] * l[2], a[2] * l[0] - a[0] * l[2], -a[1] * l[0]], h = 1 + n.volume + o, f = Math.max(0, i.width), y = Math.max(0, i.length), u = [it(e, a.map((g) => g * (h + y)))];
2676
+ for (let g = 0; g < 8; g++) {
2677
+ const m = g * Math.PI / 4, d = a.map((x, b) => x * h + f * (l[b] * Math.cos(m) + c[b] * Math.sin(m)));
2678
+ u.push(it(e, d));
2679
+ }
2680
+ t.shape(Mn(u), n.color, Fe(s));
2681
+ }
2682
+ }
2683
+ const os = 0.35, En = (t) => ({ centre: [t * 0.98, -0.02, -0.08], out: [t, 0, -0.12] });
2684
+ function ss(t, e, n, s, o) {
2685
+ const { centre: r, out: i } = En(n), a = pt(e, i), l = Math.max(1, s.lineWidth * 0.55), c = s.skin === "none" ? null : s.skin, h = e.ry * 0.27;
2686
+ if (!o) {
2687
+ const d = it(e, [r[0] * 1.06, r[1], r[2]]);
2688
+ t.ellipse(d.x, d.y, e.rx * 0.17, h, e.angle, c, l);
2689
+ return;
2690
+ }
2691
+ const f = it(e, r), y = e.rx * (0.12 + 0.08 * a);
2692
+ t.ellipse(f.x, f.y, y, h, e.angle, c, l);
2693
+ const u = Math.cos(e.angle), g = Math.sin(e.angle), m = Array.from({ length: 9 }, (d, x) => {
2694
+ const b = -Math.PI * 0.55 + x / 8 * Math.PI * 1.1, k = Math.cos(b) * y * 0.45 * -n, v = Math.sin(b) * h * 0.55;
2695
+ return { x: f.x + k * u - v * g, y: f.y + k * g + v * u };
2696
+ });
2697
+ t.line(m, Math.max(0.8, l * 0.7));
2698
+ }
2699
+ function Ri(t, e, n, s) {
2700
+ vn(e, n, () => {
2701
+ for (const o of [1, -1]) pt(n, En(o).out) < os && ss(t, n, o, s, !1);
2702
+ }, s.headOutline);
2703
+ }
2704
+ function Ci(t, e, n) {
2705
+ for (const s of [1, -1]) pt(e, En(s).out) >= os && ss(t, e, s, n, !0);
2706
+ }
2707
+ const Fi = {
2708
+ cleanShaven: { moustache: "none", beard: "none" },
2709
+ stubble: { moustache: "none", beard: "stubble" },
2710
+ pencilMoustache: { moustache: "pencil", beard: "none" },
2711
+ shortMoustache: { moustache: "short", beard: "none" },
2712
+ chevron: { moustache: "chevron", beard: "none" },
2713
+ handlebar: { moustache: "handlebar", beard: "none" },
2714
+ walrus: { moustache: "walrus", beard: "none" },
2715
+ goatee: { moustache: "none", beard: "goatee" },
2716
+ vanDyke: { moustache: "chevron", beard: "goatee" },
2717
+ circleBeard: { moustache: "short", beard: "circle" },
2718
+ shortBoxed: { moustache: "short", beard: "boxed" },
2719
+ fullBeard: { moustache: "chevron", beard: "full" },
2720
+ longBeard: { moustache: "walrus", beard: "long" },
2721
+ roundedBeard: { moustache: "chevron", beard: "rounded" },
2722
+ pointedBeard: { moustache: "chevron", beard: "pointed" },
2723
+ chinStrap: { moustache: "none", beard: "chinStrap" },
2724
+ soulPatch: { moustache: "none", beard: "soulPatch" },
2725
+ sideburns: { moustache: "none", beard: "sideburns" },
2726
+ muttonChops: { moustache: "none", beard: "muttonChops" },
2727
+ moustacheStubble: { moustache: "short", beard: "stubble" }
2728
+ };
2729
+ function Ni(t, e) {
2730
+ const n = typeof t == "string" ? { style: t } : t, s = n.style ? Fi[n.style] : void 0;
2731
+ if (n.style && !s) throw new Error(`facialHair: unknown style '${n.style}'`);
2732
+ return {
2733
+ color: n.color ?? e ?? "#6b4630",
2734
+ moustache: n.moustache ?? s?.moustache ?? "none",
2735
+ beard: n.beard ?? s?.beard ?? "none"
2736
+ };
2737
+ }
2738
+ const Bt = (t) => t * Math.PI / 180, Ae = (t, e, n) => {
2739
+ const s = Math.min(1, Math.max(0, (n - t) / (e - t)));
2740
+ return s * s * (3 - 2 * s);
2741
+ }, rs = {
2742
+ goatee: { top: [-0.55, -0.55], reach: 22, band: 0, length: 0.22, shape: "point", volume: 0.06, aroundMouth: !1 },
2743
+ circle: { top: [-0.24, -0.3], reach: 42, band: 0, length: 0.08, shape: "round", volume: 0.06, aroundMouth: !0 },
2744
+ boxed: { top: [-0.38, 0.02], reach: 100, band: 0, length: 0.18, shape: "square", volume: 0.08, aroundMouth: !0 },
2745
+ full: { top: [-0.36, 0.05], reach: 100, band: 0, length: 0.32, shape: "round", volume: 0.12, aroundMouth: !0 },
2746
+ rounded: { top: [-0.36, 0.05], reach: 100, band: 0, length: 0.55, shape: "round", volume: 0.14, aroundMouth: !0 },
2747
+ pointed: { top: [-0.36, 0.05], reach: 100, band: 0, length: 0.8, shape: "point", volume: 0.12, aroundMouth: !0 },
2748
+ long: { top: [-0.36, 0.05], reach: 100, band: 0, length: 1.4, shape: "round", volume: 0.14, aroundMouth: !0 },
2749
+ chinStrap: { top: [-0.68, 0.05], reach: 100, band: 0.18, length: 0, shape: "round", volume: 0.04, aroundMouth: !1 },
2750
+ sideburns: { top: [0.08, 0.08], reach: 100, band: 0.42, length: 0, shape: "round", volume: 0.05, aroundMouth: !1 },
2751
+ muttonChops: { top: [0.08, 0.08], reach: 100, band: 0.75, length: 0, shape: "round", volume: 0.08, aroundMouth: !1 }
2752
+ }, Yi = (t, e) => {
2753
+ const n = Ae(Bt(48), Bt(100), $e(e, 0));
2754
+ return t.top[0] + (t.top[1] - t.top[0]) * n;
2755
+ }, zi = (t) => t === "sideburns" || t === "muttonChops";
2756
+ function gn(t, e) {
2757
+ const n = rs[t];
2758
+ if (!n) return null;
2759
+ const s = Bt(n.reach), o = (r) => {
2760
+ const i = $e(r, 0);
2761
+ return n.shape === "point" ? Math.exp(-((i / 0.42) ** 2)) : n.shape === "square" ? 1 - Ae(Bt(45), Bt(85), i) : Math.cos(Math.min(i, Math.PI / 2)) ** 0.7;
2762
+ };
2763
+ return {
2764
+ top: Math.max(n.top[0], n.top[1]) + 0.05,
2765
+ bottom: -1,
2766
+ inside(r, i) {
2767
+ const a = $e(r, 0), l = Yi(n, r);
2768
+ let c = Math.min(l - i, s - a);
2769
+ if (n.band > 0 && (c = Math.min(c, i - (l - n.band))), zi(t)) {
2770
+ const h = t === "muttonChops" ? Bt(70) - Bt(22) * Ae(0.08, -0.6, i) : Bt(72);
2771
+ c = Math.min(c, a - h);
2772
+ }
2773
+ return c;
2774
+ },
2775
+ position(r, i) {
2776
+ const [a, l, c] = It(r, i), h = 1 + e + n.volume, f = n.length * o(r) * Ae(-0.45, -1, i);
2777
+ return [a * h, l * h - f, c * h + f * 0.25];
2778
+ },
2779
+ normal: (r, i) => It(r, i)
2780
+ };
2781
+ }
2782
+ function Di(t) {
2783
+ const n = (s) => s.map(([o, r]) => ({ x: o, y: -0.24 + r }));
2784
+ switch (t) {
2785
+ case "short":
2786
+ return n([[-0.17, -0.02], [-0.1, 0.04], [0, 0.03], [0.1, 0.04], [0.17, -0.02], [0.08, -0.05], [0, -0.03], [-0.08, -0.05]]);
2787
+ case "chevron":
2788
+ return n([[-0.28, -0.1], [-0.16, 0.05], [0, 0.07], [0.16, 0.05], [0.28, -0.1], [0.12, -0.08], [0, -0.06], [-0.12, -0.08]]);
2789
+ case "walrus":
2790
+ return n([[-0.38, -0.2], [-0.3, 0.02], [-0.12, 0.09], [0, 0.07], [0.12, 0.09], [0.3, 0.02], [0.38, -0.2], [0.2, -0.13], [0, -0.11], [-0.2, -0.13]]);
2791
+ case "handlebar":
2792
+ return n([[-0.24, -0.03], [-0.12, 0.04], [0, 0.03], [0.12, 0.04], [0.24, -0.03], [0.1, -0.05], [0, -0.03], [-0.1, -0.05]]);
2793
+ default:
2794
+ return null;
2795
+ }
2796
+ }
2797
+ const ue = (t) => Math.max(1, t * 0.45);
2798
+ function qi(t, e, n, s) {
2799
+ for (let o = 0.1; o > -1; o -= 0.13)
2800
+ for (let r = -Math.PI / 1.7; r < Math.PI / 1.7; r += 0.2) {
2801
+ const i = Math.round(o * 100) % 2 * 0.1;
2802
+ if (n.inside(r + i, o) < 0.02) continue;
2803
+ const a = It(r + i, o);
2804
+ if (pt(e, a) < 0.15) continue;
2805
+ const l = it(e, a);
2806
+ t.dot(l.x, l.y, s);
2807
+ }
2808
+ }
2809
+ function Ui(t, e, n, s, o) {
2810
+ const r = s.beard === "stubble" ? null : gn(s.beard, o.lineWidth * 0.45 / n.rx);
2811
+ if (!r) return;
2812
+ const { far: i } = kn(n, s, () => Ce(n, r));
2813
+ vn(e, n, () => {
2814
+ for (const a of i) t.shape(a, s.color, ue(o.lineWidth));
2815
+ }, o.headOutline);
2816
+ }
2817
+ function Xi(t, e, n, s, o) {
2818
+ if (n.beard === "none") return;
2819
+ const r = s.lineWidth * 0.45 / e.rx;
2820
+ if (n.beard === "stubble") {
2821
+ qi(t, e, gn("full", r), Math.max(0.5, s.lineWidth * 0.09));
2822
+ return;
2823
+ }
2824
+ if (n.beard === "soulPatch") {
2825
+ const l = [{ x: -0.05, y: -0.55 }, { x: 0.05, y: -0.55 }, { x: 0, y: -0.68 }], { points: c, facing: h } = et(e, l, { x: 0, y: -0.6 }, s.face?.projection);
2826
+ h > -0.05 && t.shape(c, n.color, ue(s.lineWidth) * 0.7);
2827
+ return;
2828
+ }
2829
+ const i = gn(n.beard, r);
2830
+ if (!i) return;
2831
+ const { near: a } = kn(e, n, () => Ce(e, i));
2832
+ for (const l of a) t.shape(l, n.color, ue(s.lineWidth));
2833
+ if (rs[n.beard]?.aroundMouth) {
2834
+ const l = 0.27 * Math.max(0.3, o), c = Array.from({ length: 20 }, (y, u) => {
2835
+ const g = Math.PI * 2 * u / 20;
2836
+ return { x: Math.cos(g) * l, y: -0.42 + Math.sin(g) * 0.13 };
2837
+ }), { points: h, facing: f } = et(e, c, { x: 0, y: -0.42 }, s.face?.projection);
2838
+ f > -0.05 && t.shape(h, s.skin === "none" ? "#ffffff" : s.skin, 0);
2839
+ }
2840
+ }
2841
+ function Gi(t, e, n, s) {
2842
+ if (n.moustache === "none") return;
2843
+ const o = { x: 0, y: -0.24 };
2844
+ if (n.moustache === "pencil") {
2845
+ const l = [-0.2, -0.1, 0, 0.1, 0.2].map((f) => ({ x: f, y: -0.25 + 0.03 * Math.cos(f / 0.2 * Math.PI) })), { points: c, facing: h } = et(e, l, o, s.face?.projection);
2846
+ h > -0.05 && t.line(c, Math.max(1, s.lineWidth * 0.32));
2847
+ return;
2848
+ }
2849
+ const r = Di(n.moustache);
2850
+ if (!r) return;
2851
+ const { points: i, facing: a } = et(e, r, o, s.face?.projection);
2852
+ if (!(a <= -0.05) && (t.shape(i, n.color, ue(s.lineWidth) * 0.8), n.moustache === "handlebar"))
2853
+ for (const l of [1, -1]) {
2854
+ const c = Array.from({ length: 10 }, (h, f) => {
2855
+ const y = -Math.PI / 2 + f / 9 * Math.PI * 1.4;
2856
+ return { x: l * (0.27 + 0.05 * Math.cos(y)), y: -0.21 + 0.05 * (1 + Math.sin(y)) };
2857
+ });
2858
+ c.unshift({ x: l * 0.22, y: -0.27 }), t.line(et(e, c, o, s.face?.projection).points, ue(s.lineWidth) * 0.8);
2859
+ }
2860
+ }
2861
+ const Ki = { round: !0, square: !0, sunglasses: !0 };
2862
+ function Vi(t) {
2863
+ const n = (typeof t == "string" ? { style: t } : t).style ?? "round";
2864
+ if (!(n in Ki)) throw new Error(`glasses: unknown style '${n}'`);
2865
+ return { style: n };
2866
+ }
2867
+ const so = 0.34, At = 0.12, Ji = 0.05;
2868
+ function Zi(t, e) {
2869
+ return Array.from({ length: 28 }, (s, o) => {
2870
+ const r = Math.PI * 2 * o / 28;
2871
+ if (t === "round") return { x: e + Math.cos(r) * 0.2, y: At + Math.sin(r) * 0.19 };
2872
+ const i = Math.cos(r), a = Math.sin(r), l = t === "sunglasses" ? 0.22 : 0.21, c = t === "sunglasses" ? 0.17 : 0.16;
2873
+ return { x: e + Math.sign(i) * Math.abs(i) ** 0.45 * l, y: At - 0.01 + Math.sign(a) * Math.abs(a) ** 0.45 * c };
2874
+ });
2875
+ }
2876
+ function Qi(t, e, n, s) {
2877
+ const o = Math.max(1, Math.min(s.lineWidth * 0.5, 0.11 * e.rx)), r = [];
2878
+ for (const i of [1, -1]) {
2879
+ const a = so * i, { points: l, facing: c } = et(e, Zi(n.style, a), { x: a, y: At }, s.face?.projection);
2880
+ if (c < Ji) continue;
2881
+ r.push(i), t.shape(l, n.style === "sunglasses" ? "#1f2328" : null, o);
2882
+ const h = [i * 0.97, At + 0.02, -0.1];
2883
+ if (pt(e, [i, 0, 0]) > 0.15) {
2884
+ const f = et(e, [{ x: a + i * 0.21, y: At + 0.02 }], { x: a, y: At }, s.face?.projection).points[0];
2885
+ t.line([f, it(e, h)], o * 0.9);
2886
+ }
2887
+ }
2888
+ if (r.length === 2) {
2889
+ const i = [
2890
+ { x: so - 0.2, y: At + 0.02 },
2891
+ { x: 0, y: At + 0.07 },
2892
+ { x: -0.14, y: At + 0.02 }
2893
+ ];
2894
+ t.line(et(e, i, { x: 0, y: At }, s.face?.projection).points, o);
2895
+ }
2896
+ }
2897
+ const is = {
2898
+ cap: { color: "#d64535", brim: [0.36, 0.16], height: 1, peak: 0.7, detail: "seams" },
2899
+ beanie: { color: "#3a6ea5", brim: [0.3, 0.12], height: 1.08, detail: "fold" },
2900
+ hardHat: { color: "#f2c230", brim: [0.34, 0.22], height: 1.12, ring: 0.16, detail: "ridge" },
2901
+ sunHat: { color: "#e3c98f", brim: [0.36, 0.3], height: 1.02, ring: 0.62, detail: "band" },
2902
+ bowler: { color: "#2f2b2a", brim: [0.36, 0.28], height: 1.15, ring: 0.2, detail: "band" }
2903
+ };
2904
+ function ji(t) {
2905
+ const e = typeof t == "string" ? { style: t } : t, n = e.style ?? "cap", s = is[n];
2906
+ if (!s) throw new Error(`hat: unknown style '${n}'`);
2907
+ return { style: n, color: e.color ?? s.color };
2908
+ }
2909
+ const Xt = (t, e) => t.brim[1] + (t.brim[0] - t.brim[1]) * (1 + Math.cos(e)) / 2;
2910
+ function ta(t, e) {
2911
+ return {
2912
+ top: 1,
2913
+ bottom: Math.min(...t.brim) - 0.05,
2914
+ inside: (n, s) => s - Xt(t, n),
2915
+ position(n, s) {
2916
+ const [o, r, i] = It(n, s), a = Xt(t, n), l = s > a ? (r - a) * (t.height - 1) : 0;
2917
+ return [o * e, r * e + l, i * e];
2918
+ },
2919
+ normal: (n, s) => It(n, s)
2920
+ };
2921
+ }
2922
+ function ea(t, e, n) {
2923
+ const o = (r, i, a) => {
2924
+ const l = Xt(e, r) * n - a;
2925
+ return [Math.sin(r) * i, l, Math.cos(r) * i];
2926
+ };
2927
+ if (e.peak) {
2928
+ const r = [], i = [];
2929
+ for (let a = 0; a <= 24; a++) {
2930
+ const l = (-80 + 160 * a / 24) * (Math.PI / 180), c = e.peak * Math.cos(l) ** 0.6;
2931
+ r.push(it(t, [Math.sin(l) * (n + c * 0.25), Xt(e, l) * n - 0.07 * Math.cos(l), Math.cos(l) * (n + c)])), i.push(it(t, o(l, n, 0)));
2932
+ }
2933
+ return [...r, ...i.reverse()];
2934
+ }
2935
+ return e.ring ? Array.from({ length: 48 }, (r, i) => it(t, o(Math.PI * 2 * i / 48, n + e.ring, 0.07))) : null;
2936
+ }
2937
+ function na(t) {
2938
+ const e = (s) => Array.from({ length: 13 }, (o, r) => [s, Xt(t, s) + (0.97 - Xt(t, s)) * r / 12]), n = (s) => Array.from({ length: 49 }, (o, r) => {
2939
+ const i = -Math.PI + Math.PI * 2 * r / 48;
2940
+ return [i, Xt(t, i) + s];
2941
+ });
2942
+ switch (t.detail) {
2943
+ case "seams":
2944
+ return [e(0.55), e(-0.55)];
2945
+ case "fold":
2946
+ return [n(0.2)];
2947
+ case "ridge":
2948
+ return [e(0), e(Math.PI)];
2949
+ case "band":
2950
+ return [n(0.12)];
2951
+ }
2952
+ }
2953
+ function as(t, e, n, s) {
2954
+ const o = is[n.style], i = 1 + s.lineWidth * 0.45 / e.rx + Math.max(0.05, Math.min(0.3, s.hairVolume) + 0.04), a = Math.max(1, s.lineWidth * 0.5), l = ea(e, o, i);
2955
+ l && t.shape(l, n.color, a);
2956
+ const c = ta(o, i), { near: h, far: f } = Ce(e, c);
2957
+ for (const u of [...f, ...h]) t.shape(u, n.color, a);
2958
+ const y = Math.max(0.8, a * 0.7);
2959
+ for (const u of na(o)) {
2960
+ const g = u.map(([d, x]) => {
2961
+ const [b, k, v] = c.position(d, x);
2962
+ return [b * 0.99, k * 0.99, v * 0.99];
2963
+ }), m = u.map(([d, x]) => It(d, x));
2964
+ for (const d of Go(e, g, m, 0.1)) t.line(d, y);
2965
+ }
2966
+ if (o.detail === "seams") {
2967
+ const u = it(e, [0, i * 1.01, 0]);
2968
+ t.dot(u.x, u.y, a * 0.9);
2969
+ }
2970
+ }
2971
+ function oa(t) {
2972
+ const e = t.hair ? Oi(t.hair) : null;
2973
+ return {
2974
+ hair: e,
2975
+ facialHair: t.facialHair ? Ni(t.facialHair, e?.color) : null,
2976
+ glasses: t.glasses ? Vi(t.glasses) : null,
2977
+ hat: t.hat ? ji(t.hat) : null,
2978
+ ears: t.ears ?? !1
2979
+ };
2980
+ }
2981
+ const ls = (t) => !t.hair && !t.facialHair && !t.glasses && !t.hat && !t.ears, hs = (t) => t.axes[2][2] < -0.3, cs = (t) => t.ears && !t.hair?.coversEars;
2982
+ function fs(t, e, n, s, o, r) {
2983
+ if (ls(n)) return;
2984
+ const i = { ...r, headOutline: r.face && (r.face.shape === "angular" || r.face.projection === "volume") ? qo(s, r.face) : void 0 };
2985
+ n.hair && Bi(e, t, s, n.hair, { ...i, motion: _e(o) }), n.facialHair && Ui(e, t, s, n.facialHair, i), cs(n) && Ri(e, t, s, i);
2986
+ }
2987
+ function sa(t, e, n, s, o, r, i) {
2988
+ if (ls(n)) {
2989
+ i();
2990
+ return;
2991
+ }
2992
+ const a = hs(s);
2993
+ cs(n) && Ci(e, s, r), n.hair && !a && !r.faceUnderHair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.facialHair && Xi(e, s, n.facialHair, r, o.mouthWidth ?? 1), i(), n.hair && !a && r.faceUnderHair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.facialHair && Gi(e, s, n.facialHair, r), n.glasses && Qi(e, s, n.glasses, r), n.hat && !a && as(e, s, n.hat, { lineWidth: r.lineWidth, hairVolume: n.hair?.volume ?? 0 });
2994
+ }
2995
+ function us(t, e, n, s, o, r) {
2996
+ hs(s) && (n.hair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.hat && as(e, s, n.hat, { lineWidth: r.lineWidth, hairVolume: n.hair?.volume ?? 0 }));
2997
+ }
2998
+ const ro = 40, ra = 0.215 + 0.205, Mt = (t, e) => {
2999
+ const n = {};
3000
+ for (const s of ["left", "right"]) for (const [o, r] of Object.entries(e)) n[`${t}.${s}.${o}`] = r;
3001
+ return n;
3002
+ }, G = (t, e) => t[e] ?? at[e] ?? 0;
3003
+ function ia(t, e, n = at, s = 1) {
3004
+ const o = Be(t), r = e * Math.PI * 2, i = Math.sin(r) * s, a = Math.cos(r) * s, l = (1 + Math.cos(r * 2 * (o.bounces ?? 1))) / 2, c = o.crouch ?? 0, h = o.shoulder ?? 0, f = o.forearm ?? 0, y = { ...at, ...n };
3005
+ y["leg.left.swing"] = o.swing * i + c * 0.6, y["leg.right.swing"] = -o.swing * i + c * 0.6, y["leg.left.knee"] = o.knee * Math.max(0, a) + c * 1.2, y["leg.right.knee"] = o.knee * Math.max(0, -a) + c * 1.2, y["leg.left.ankle"] = G(n, "leg.left.ankle") - (o.tiptoe ?? 0), y["leg.right.ankle"] = G(n, "leg.right.ankle") - (o.tiptoe ?? 0);
3006
+ for (const [u, g] of [["left", -1], ["right", 1]])
3007
+ G(n, `arm.${u}.spread`) > ro || G(n, `arm.${u}.swing`) > ro || (y[`arm.${u}.swing`] = h + g * o.arm * i, y[`arm.${u}.elbow`] = G(n, `arm.${u}.elbow`) + f + o.elbow * Math.max(0, g * i));
3008
+ return y.lean = G(n, "lean") + o.lean * s, y.bend = G(n, "bend") + (o.bend ?? 0), y["head.nod"] = G(n, "head.nod") - o.lean * 0.5 * s + (o.headTilt ?? 0), y.side = G(n, "side") + (o.sway ?? 0) * Math.sin(r), y.lift = G(n, "lift") + (o.bounce ?? 0) * s * l, y.stretch = G(n, "stretch") * (1 + (o.squash ?? 0) * (l - 0.5)), y;
3009
+ }
3010
+ function Ga(t, e, n = 1, s = 1) {
3011
+ const o = Be(t);
3012
+ return 4 * ra * s * e * Math.sin(o.swing * n * Math.PI / 180);
3013
+ }
3014
+ const Vt = (t) => jr[t], aa = {
3015
+ /** Squash down in a squint, shoot up stretched with arms flung up, hang, land squashed, end surprised. */
3016
+ take: (t) => [
3017
+ { after: 140, pose: { stretch: 0.8, bend: 10, lean: G(t, "lean") - 4, ...Mt("arm", { spread: 6, swing: 0, elbow: 10 }), "eye.left": 0.35, "eye.right": 0.35, "brow.left": -0.6, "brow.right": -0.6, mouth: 0 }, easing: "ease-in-out" },
3018
+ { after: 260, pose: { stretch: 0.78 } },
3019
+ { after: 360, pose: { lift: 0.22, stretch: 1.35, bend: -14, ...Mt("arm", { spread: 150, bend: 35, swing: 0, elbow: 0 }), ...Mt("leg", { swing: 25, knee: 60 }), ...Vt("shocked") }, easing: "ease-out-cubic" },
3020
+ { after: 720, pose: { lift: 0.25, stretch: 1.25, bend: -10, ...Mt("arm", { spread: 140 }) }, easing: "ease-in-out" },
3021
+ { after: 900, pose: { lift: 0, stretch: 0.74, bend: 12, ...Mt("arm", { spread: 70, bend: 0 }), ...Mt("leg", { swing: 30, knee: 60 }) }, easing: "ease-in-quad" },
3022
+ {
3023
+ after: 1060,
3024
+ pose: {
3025
+ stretch: 1.06,
3026
+ bend: -3,
3027
+ ...Mt("arm", { spread: 60 }),
3028
+ "leg.left.swing": G(t, "leg.left.swing"),
3029
+ "leg.right.swing": G(t, "leg.right.swing"),
3030
+ "leg.left.knee": G(t, "leg.left.knee"),
3031
+ "leg.right.knee": G(t, "leg.right.knee")
3032
+ },
3033
+ easing: "ease-out"
3034
+ },
3035
+ { after: 1260, pose: { stretch: G(t, "stretch"), bend: G(t, "bend"), ...Vt("surprised"), ...Mt("arm", { spread: 55, bend: 60 }) }, easing: "ease-in-out" }
3036
+ ],
3037
+ /** Glance ahead, look away unbothered, then snap back in shock with a little hop. */
3038
+ doubleTake: (t) => [
3039
+ { after: 160, pose: { lookX: 1, lookY: 0, "head.turn": 0 }, easing: "ease-out" },
3040
+ { after: 520, pose: { lookX: -0.6, "head.turn": 30, "head.nod": G(t, "head.nod") - 4, smile: 0.6, mouth: 0 }, easing: "ease-in-out" },
3041
+ { after: 1100, pose: { lookX: -0.6 } },
3042
+ { after: 1180, pose: { "head.turn": 0, "head.nod": G(t, "head.nod") - 10, bend: G(t, "bend") - 10, lift: 0.05, stretch: 1.18, ...Vt("shocked"), lookX: 1, lookY: 0 }, easing: "ease-out-cubic" },
3043
+ { after: 1360, pose: { lift: 0, stretch: 0.88, "head.nod": G(t, "head.nod") - 4, bend: G(t, "bend") + 4 }, easing: "ease-in-quad" },
3044
+ { after: 1560, pose: { stretch: G(t, "stretch"), "head.nod": G(t, "head.nod"), bend: G(t, "bend") }, easing: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 } }
3045
+ ],
3046
+ /** Rear back for a zip-off: lean back, a knee up, arms cocked; hold; pitch forward ready to run. */
3047
+ windUp: () => [
3048
+ {
3049
+ after: 220,
3050
+ pose: {
3051
+ lean: -18,
3052
+ bend: -16,
3053
+ "head.nod": -6,
3054
+ "arm.left.swing": 60,
3055
+ "arm.left.elbow": 100,
3056
+ "arm.right.swing": -40,
3057
+ "arm.right.elbow": 90,
3058
+ "leg.left.swing": 55,
3059
+ "leg.left.knee": 95,
3060
+ stretch: 0.92,
3061
+ ...Vt("angry"),
3062
+ lookX: 1
3063
+ },
3064
+ easing: "ease-out"
3065
+ },
3066
+ { after: 620, pose: { lean: -20, bend: -18, stretch: 0.9 } },
3067
+ { after: 700, pose: { lean: 28, bend: 14, "head.nod": 6, "arm.left.swing": -30, "arm.right.swing": 60, "leg.left.swing": -20, "leg.left.knee": 30, "leg.right.swing": 20, stretch: 1.12 }, easing: "ease-out-cubic" }
3068
+ ],
3069
+ /** Coming down: stretched in the fall, squashed on contact, a spring back up. */
3070
+ land: (t) => [
3071
+ { after: 120, pose: { lift: 0, stretch: 0.7, bend: 14, ...Mt("arm", { spread: 75 }), ...Mt("leg", { swing: 25, knee: 50 }) }, easing: "ease-in-quad" },
3072
+ { after: 300, pose: { stretch: 1.05, bend: -4, "arm.left.spread": G(t, "arm.left.spread"), "arm.right.spread": G(t, "arm.right.spread") }, easing: "ease-out" },
3073
+ { after: 460, pose: { lift: 0, stretch: G(t, "stretch"), bend: G(t, "bend"), ...Mt("leg", { swing: 0, knee: 0 }) }, easing: "ease-in-out" }
3074
+ ],
3075
+ /** A frightened shiver: paws up, fast small shakes side to side, then still. */
3076
+ tremble: (t) => {
3077
+ const e = [{ after: 80, pose: { ...Vt("scared"), ...Mt("arm", { swing: 40, elbow: 110, spread: 14 }), stretch: 0.94, bend: G(t, "bend") + 8 }, easing: "ease-out" }];
3078
+ for (let n = 1; n <= 14; n++) {
3079
+ const s = n % 2 === 0 ? 1 : -1;
3080
+ e.push({ after: 80 + n * 45, pose: { side: G(t, "side") + 2.5 * s, "head.tilt": G(t, "head.tilt") - 2 * s } });
3081
+ }
3082
+ return e.push({ after: 755, pose: { side: G(t, "side"), "head.tilt": G(t, "head.tilt"), bend: G(t, "bend") } }), e;
3083
+ },
3084
+ /** A sigh: the body sags, the back curls, the head and arms drop. */
3085
+ deflate: (t) => [
3086
+ { after: 260, pose: { stretch: 1.04, "head.nod": G(t, "head.nod") - 4, "brow.left": 0.3, "brow.right": 0.3 }, easing: "ease-in-out" },
3087
+ { after: 900, pose: { ...Vt("sad"), bend: 18, stretch: 0.92, lean: G(t, "lean") + 5, "head.nod": 14, ...Mt("arm", { spread: 6, swing: 0, elbow: 4, bend: 0 }) }, easing: "ease-in-out" }
3088
+ ]
3089
+ };
3090
+ function Ka(t, e) {
3091
+ const n = tt(e.from ?? {}), s = e.speed ?? 1;
3092
+ let o = n;
3093
+ return [
3094
+ { time: e.at, pose: n },
3095
+ ...aa[t](n).map((r) => (o = { ...o, ...r.pose }, { time: e.at + r.after * s, pose: o, act: !1, ...r.easing ? { easing: r.easing } : {} }))
3096
+ ];
3097
+ }
3098
+ function la(t, e = at) {
3099
+ const n = t * Math.PI * 2, s = Math.sin(n);
3100
+ return {
3101
+ ...e,
3102
+ lean: (e.lean ?? 0) + 14,
3103
+ bend: (e.bend ?? 0) + 8,
3104
+ side: 5 * s,
3105
+ "head.nod": 22,
3106
+ "arm.right.swing": 38 + 22 * s,
3107
+ "arm.right.spread": 6,
3108
+ "arm.right.elbow": 20 + 10 * Math.max(0, -s),
3109
+ "arm.right.bend": -10,
3110
+ "arm.left.swing": 52 + 22 * s,
3111
+ "arm.left.spread": 14,
3112
+ "arm.left.elbow": 35 + 10 * Math.max(0, s),
3113
+ "arm.left.bend": -20,
3114
+ "leg.left.swing": 10,
3115
+ "leg.right.swing": -10,
3116
+ "leg.left.knee": 8,
3117
+ "leg.right.knee": 4,
3118
+ "leg.left.spread": 8,
3119
+ "leg.right.spread": 8
3120
+ };
3121
+ }
3122
+ function ha(t, e = at) {
3123
+ const n = t * Math.PI * 2, s = Math.sin(n), o = Math.cos(n);
3124
+ return {
3125
+ ...e,
3126
+ lean: (e.lean ?? 0) + 4,
3127
+ side: 2 * s,
3128
+ "head.nod": 6,
3129
+ "arm.right.swing": 62,
3130
+ "arm.right.spread": 18 + 16 * s,
3131
+ "arm.right.elbow": 48 - 18 * Math.abs(s),
3132
+ "arm.right.bend": -30 + 8 * o,
3133
+ "arm.left.swing": 12,
3134
+ "arm.left.spread": 14,
3135
+ "arm.left.elbow": 12,
3136
+ "leg.left.spread": 6,
3137
+ "leg.right.spread": 6
3138
+ };
3139
+ }
3140
+ const io = { sweeping: la, brushing: ha };
3141
+ function Va(t, e, n = at) {
3142
+ const s = io[t];
3143
+ if (!s) throw new Error(`humanCyclePose: ${Ms("cycle", t, Object.keys(io))}`);
3144
+ return s(e, n);
3145
+ }
3146
+ function ds(t) {
3147
+ const e = t.top ?? !0, n = t.length ?? 0.32, s = t.color ?? "#638c39", o = t.accent ?? "#87ae4e";
3148
+ if (typeof e != "boolean") throw new Error("leafOutfit: top must be a boolean");
3149
+ if (!Number.isFinite(n) || n < 0.2 || n > 0.45) throw new Error("leafOutfit: length must be 0.2..0.45");
3150
+ if (typeof s != "string" || typeof o != "string") throw new Error("leafOutfit: color and accent must be strings");
3151
+ return { top: e, length: n, color: s, accent: o };
3152
+ }
3153
+ function ao(t, e) {
3154
+ const n = t.flatMap((o) => Array.from({ length: 8 }, (r, i) => ({
3155
+ x: o.x + Math.cos(i * Math.PI / 4) * e,
3156
+ y: o.y + Math.sin(i * Math.PI / 4) * e
3157
+ })));
3158
+ let s = Mn(n);
3159
+ for (let o = 0; o < 2; o++) s = s.flatMap((r, i) => {
3160
+ const a = s[(i + 1) % s.length];
3161
+ return [{ x: r.x * 0.75 + a.x * 0.25, y: r.y * 0.75 + a.y * 0.25 }, { x: r.x * 0.25 + a.x * 0.75, y: r.y * 0.25 + a.y * 0.75 }];
3162
+ });
3163
+ return s;
3164
+ }
3165
+ const lo = (t) => t.flatMap((e) => [e.left, e.right]);
3166
+ function gs(t, e = {}) {
3167
+ const { top: n, length: s } = ds(e), o = t.bodyContours;
3168
+ if (!o?.spine) throw new Error("leafOutfit requires organic body contours");
3169
+ const r = o.spine.samples.filter((a) => a.at <= 0.3), i = ["left", "right"].flatMap((a) => o[`leg.${a}`]?.samples.filter((l) => l.at <= s) ?? []);
3170
+ return {
3171
+ ...n ? { top: ao(lo(o.spine.samples.filter((a) => a.at >= 0.52 && a.at <= 0.91)), t.height * 0.01) } : {},
3172
+ skirt: ao(lo([...r, ...i]), t.height * 0.012)
3173
+ };
3174
+ }
3175
+ function ca(t, e) {
3176
+ t.beginPath(), t.moveTo(e[0].x, e[0].y);
3177
+ for (const n of e.slice(1)) t.lineTo(n.x, n.y);
3178
+ t.closePath();
3179
+ }
3180
+ function fa(t, e, n) {
3181
+ const s = e.x - t.x, o = e.y - t.y, r = Math.hypot(s, o) || 1, i = -o / r, a = s / r, l = [];
3182
+ for (const c of [1, -1]) for (let h = 0; h <= 16; h++) {
3183
+ const f = c === 1 ? h / 16 : 1 - h / 16, u = 3 * (1 - f) * f * n * c;
3184
+ l.push({ x: t.x + s * f + i * u, y: t.y + o * f + a * u });
3185
+ }
3186
+ return l;
3187
+ }
3188
+ function ho(t, e, n, s, o, r) {
3189
+ const i = e.lineWidth * 0.7;
3190
+ if (n.shape(s, o, i), n.look === "silhouette") return;
3191
+ t.save(), ca(t, s), t.clip();
3192
+ const a = Math.min(...s.map((u) => u.x)), l = Math.max(...s.map((u) => u.x)), c = Math.min(...s.map((u) => u.y)), h = Math.max(...s.map((u) => u.y)), f = l - a, y = h - c;
3193
+ for (let u = 0; u < 2; u++) for (let g = 0; g < 5; g++) {
3194
+ const m = { x: a + f * (g / 4 + (u ? 0.07 : -0.04)), y: c + y * (u ? 0.38 : -0.1) }, d = { x: m.x + f * 0.09, y: m.y + y * 0.78 };
3195
+ n.shape(fa(m, d, f * 0.13), (g + u) % 2 ? o : r, i * 0.6), n.line([m, { x: m.x * 0.45 + d.x * 0.55, y: m.y * 0.45 + d.y * 0.55 }, d], i * 0.45);
3196
+ for (const x of [0.32, 0.52, 0.7]) {
3197
+ const b = { x: m.x + (d.x - m.x) * x, y: m.y + (d.y - m.y) * x };
3198
+ n.line([{ x: b.x - f * 0.045, y: b.y - y * 0.065 }, b, { x: b.x + f * 0.045, y: b.y - y * 0.05 }], i * 0.3);
3199
+ }
3200
+ }
3201
+ t.restore();
3202
+ }
3203
+ function ua(t = {}) {
3204
+ const e = ds(t), { color: n, accent: s } = e, o = (r) => (i, a, l) => {
3205
+ const c = gs(a, e);
3206
+ r === "spine" && c.top && ho(i, a, l, c.top, n, s);
3207
+ const h = ["spine", "leg.left", "leg.right"].reduce((f, y) => a.parts[f].order > a.parts[y].order ? f : y);
3208
+ r === h && ho(i, a, l, c.skirt, n, s);
3209
+ };
3210
+ return { parts: { spine: { over: o("spine") }, "leg.left": { over: o("leg.left") }, "leg.right": { over: o("leg.right") } } };
3211
+ }
3212
+ const da = { apron: "#d8b48a", labCoat: "#f4f6f8", hoodie: "#6b7280", cardigan: "#6b8e4e", overalls: "", sari: "#16a34a" }, Ze = (t, e, n) => t.slice(Math.floor((t.length - 1) * e), Math.ceil((t.length - 1) * n) + 1), Z = (t, e, n) => ({ x: t.x + (e.x - t.x) * n, y: t.y + (e.y - t.y) * n });
3213
+ function ga(t) {
3214
+ return t.parts["leg.left"].order > t.parts["leg.right"].order ? "left" : "right";
3215
+ }
3216
+ const co = (t) => Math.max(t.parts["leg.left"].order, t.parts["leg.right"].order) > t.parts.spine.order, mt = (t) => t.bodyForward?.[2] ?? Math.cos(t.turn * Math.PI / 2), Ht = (t) => t.bodyForward?.[0] ?? Math.sin(t.turn * Math.PI / 2);
3217
+ function fo(t, e, n) {
3218
+ t.save(), t.beginPath(), t.moveTo(e[0].x, e[0].y);
3219
+ for (const s of e.slice(1)) t.lineTo(s.x, s.y);
3220
+ t.closePath(), t.clip(), n(), t.restore();
3221
+ }
3222
+ function uo(t, e, n = 0) {
3223
+ const s = e * (t.length - 1), o = Math.min(t.length - 2, Math.floor(s)), r = t[o], i = t[o + 1], a = Z(r, i, s - o), l = Math.hypot(i.x - r.x, i.y - r.y) || 1;
3224
+ return { x: a.x + (i.y - r.y) / l * n, y: a.y - (i.x - r.x) / l * n };
3225
+ }
3226
+ function ya(t = {}) {
3227
+ if (t = { ...t }, t.top !== void 0 && !["tshirt", "shirt", "blouse", "dress"].includes(t.top)) throw new Error(`basicOutfit: unknown top '${t.top}'`);
3228
+ if (t.trouserStyle !== void 0 && !["plain", "jeans", "cargo"].includes(t.trouserStyle)) throw new Error(`basicOutfit: unknown trouser style '${t.trouserStyle}'`);
3229
+ const e = t.top, n = t.trouserStyle ?? "plain", s = t.collar ?? e === "shirt", o = t.shirt ?? "#e2493b", r = e === "dress" ? o : t.trousers ?? "#24476b", i = t.sleeves ?? "short", a = e === "dress" ? "skirt" : t.bottom ?? "trousers", l = t.over === "labCoat", c = t.over === "hoodie", h = t.over === "cardigan", f = t.over === "overalls", y = t.over === "sari", u = t.overColor ?? (t.over && t.over !== "overalls" ? da[t.over] : r), g = t.shoes === "boots", m = t.shoeColor ?? "#3b2a1e", d = (p) => p.lineWidth * 0.45, x = (p, M, I, W) => {
3230
+ const _ = M.parts[`leg.${W}`].points;
3231
+ if (a === "skirt" && !f) return;
3232
+ const T = a === "shorts" && !f, L = M.bodyContours?.[`leg.${W}`], F = L ? Ge(L, 0, T ? 0.5 : 1, M.height * 6e-3) : ut(T ? Ze(_, 0, 0.5) : _, M.height * (T ? 0.085 : 0.08), M.height * (T ? 0.07 : 0.05));
3233
+ I.shape(F, r, d(M)), !(n === "plain" || mt(M) < 0.15) && fo(p, F, () => {
3234
+ const S = (B, Y = 0) => uo(_, B, Y * M.height);
3235
+ if (n === "jeans")
3236
+ I.line([S(0.07, -0.018), S(0.17, -0.02), S(0.23, 0), S(0.17, 0.02), S(0.07, 0.018)], d(M) * 0.65), I.line([S(0.27, 0.013), ...[0.4, 0.55, 0.7, 0.85, 0.96].filter((B) => !T || B < 0.5).map((B) => S(B, 0.013))], d(M) * 0.5);
3237
+ else {
3238
+ const B = [S(0.25, -0.024), S(0.25, 0.024), S(0.43, 0.024), S(0.43, -0.024)];
3239
+ I.shape(B, r, d(M) * 0.65), I.line([S(0.28, -0.024), S(0.32, 0), S(0.28, 0.024)], d(M) * 0.65);
3240
+ const Y = S(0.32);
3241
+ I.dot(Y.x, Y.y, d(M) * 0.8);
3242
+ }
3243
+ });
3244
+ }, b = (p, M, I) => {
3245
+ const W = p.parts[`leg.${I}`].points, _ = Ze(W, 0.7, 1);
3246
+ if (_.length < 2) return;
3247
+ M.shape(ut(_, p.height * 0.075, p.height * 0.07), m, d(p));
3248
+ const T = _[0], L = _[1], F = L.x - T.x, S = L.y - T.y, B = Math.hypot(F, S) || 1, Y = p.height * 0.04;
3249
+ M.line([{ x: T.x - S / B * Y, y: T.y + F / B * Y }, { x: T.x + S / B * Y, y: T.y - F / B * Y }], d(p) * 0.9);
3250
+ }, k = (p) => {
3251
+ const M = p.chains.spine, I = M[0], W = M[M.length - 1], _ = { x: I.x - (W.x - I.x) * 0.25, y: I.y - (W.y - I.y) * 0.25 };
3252
+ return { hip: I, top: W, below: _, line: [_, ...p.parts.spine.points] };
3253
+ }, v = (p) => {
3254
+ if (p.bodyContours?.spine) return Ge(p.bodyContours.spine, 0, 0.97, p.height * (c ? 0.014 : 6e-3));
3255
+ const M = c ? 1.14 : 1, I = Math.hypot(p.points["hip.left"].x - p.points["hip.right"].x, p.points["hip.left"].y - p.points["hip.right"].y), W = Math.max(p.height * 0.15 * M, I + Math.max(p.height * 0.08, p.lineWidth * 1.45) + d(p));
3256
+ return ut(k(p).line, W, p.height * 0.14 * M);
3257
+ }, P = (p, M) => {
3258
+ const I = [v(M)], { top: W, hip: _ } = k(M);
3259
+ h && I.push(ut([W, Z(W, _, 0.5), Z(W, _, 1.08)], M.height * 0.155, M.height * 0.15)), l && I.push(ut([W, Z(W, _, 0.5), _], M.height * 0.14, M.height * 0.15));
3260
+ const T = Object.values(M.points), L = Math.min(...T.map((Y) => Y.x)) - M.height, F = Math.min(...T.map((Y) => Y.y)) - M.height, S = Math.max(...T.map((Y) => Y.x)) + M.height, B = Math.max(...T.map((Y) => Y.y)) + M.height;
3261
+ for (const Y of I) {
3262
+ p.beginPath(), p.rect(L, F, S - L, B - F), p.moveTo(Y[0].x, Y[0].y);
3263
+ for (const V of Y.slice(1)) p.lineTo(V.x, V.y);
3264
+ p.closePath(), p.clip("evenodd");
3265
+ }
3266
+ }, R = (p, M) => {
3267
+ const I = c ? u : o;
3268
+ M.shape(v(p), I, d(p));
3269
+ }, O = (p, M, I) => {
3270
+ const W = mt(M);
3271
+ if (!e || W < 0.2 || c) return;
3272
+ const { top: _, hip: T } = k(M), L = Ht(M) * M.height * 0.025, F = [_, T], S = (B, Y = 0) => uo(F, B, L + Y * M.height * W);
3273
+ fo(p, v(M), () => {
3274
+ if (e === "shirt") {
3275
+ I.line([S(0.12), S(0.92)], d(M) * 0.65);
3276
+ for (const B of [0.24, 0.4, 0.56, 0.72, 0.88]) {
3277
+ const Y = S(B, 8e-3);
3278
+ I.dot(Y.x, Y.y, d(M) * 0.9);
3279
+ }
3280
+ } else if (e === "blouse") {
3281
+ I.line([S(0.025, -0.04), S(0.24), S(0.025, 0.04)], d(M) * 0.75);
3282
+ const B = S(0.31);
3283
+ I.dot(B.x, B.y, d(M));
3284
+ } else e === "dress" ? I.line([S(0.04, -0.035), S(0.17, -0.028), S(0.17, 0.028), S(0.04, 0.035)], d(M) * 0.75) : I.line([S(0.025, -0.035), S(0.1, -0.02), S(0.12), S(0.1, 0.02), S(0.025, 0.035)], d(M) * 0.65);
3285
+ });
3286
+ }, $ = (p, M) => {
3287
+ const I = mt(p), { top: W, hip: _ } = k(p), T = p.height * 0.07, L = { x: (W.x - _.x) * 0.16, y: (W.y - _.y) * 0.16 };
3288
+ if (I >= 0) {
3289
+ M.shape(
3290
+ [
3291
+ { x: W.x - T, y: W.y + L.y * 0.25 },
3292
+ { x: W.x - T * 0.8 + L.x, y: W.y + L.y },
3293
+ { x: W.x + L.x * 1.2, y: W.y + L.y * 1.35 },
3294
+ { x: W.x + T * 0.8 + L.x, y: W.y + L.y },
3295
+ { x: W.x + T, y: W.y + L.y * 0.25 }
3296
+ ],
3297
+ u,
3298
+ d(p)
3299
+ );
3300
+ return;
3301
+ }
3302
+ const F = Z(W, _, 0.42);
3303
+ M.shape(
3304
+ [
3305
+ { x: W.x - T * 0.9, y: W.y },
3306
+ { x: W.x + T * 0.9, y: W.y },
3307
+ { x: F.x + T * 0.7, y: F.y },
3308
+ { x: F.x, y: F.y + p.height * 0.02 },
3309
+ { x: F.x - T * 0.7, y: F.y }
3310
+ ],
3311
+ u,
3312
+ d(p)
3313
+ );
3314
+ }, A = (p, M) => {
3315
+ const I = mt(p);
3316
+ if (I < 0.2) return;
3317
+ const { top: W, hip: _ } = k(p), T = Ht(p) * p.height * 0.03, L = p.height * 0.06 * I, F = Z(W, _, 0.62), S = Z(W, _, 0.9);
3318
+ M.line([{ x: F.x + T - L, y: F.y }, { x: S.x + T - L * 1.1, y: S.y }], d(p) * 0.7), M.line([{ x: F.x + T + L, y: F.y }, { x: S.x + T + L * 1.1, y: S.y }], d(p) * 0.7);
3319
+ const B = Z(W, _, 0.1);
3320
+ for (const Y of [-1, 1]) M.line([{ x: B.x + T + Y * L * 0.2, y: B.y }, { x: B.x + T + Y * L * 0.35, y: B.y + p.height * 0.07 }], d(p) * 0.6);
3321
+ }, z = (p, M) => {
3322
+ const { top: I, hip: W } = k(p), _ = mt(p);
3323
+ if (M.shape(ut([I, Z(I, W, 0.5), Z(I, W, 1.08)], p.height * 0.155, p.height * 0.15), u, d(p)), _ < 0.2) return;
3324
+ const T = Ht(p) * p.height * 0.03, L = p.height * 0.02 * _, F = Z(I, W, 0.12), S = Z(I, W, 1.05);
3325
+ M.shape([{ x: F.x + T - L, y: F.y }, { x: F.x + T + L, y: F.y }, { x: S.x + T + L * 1.3, y: S.y }, { x: S.x + T - L * 1.3, y: S.y }], o, d(p) * 0.7);
3326
+ for (const B of [0.35, 0.55, 0.75]) {
3327
+ const Y = Z(I, W, B);
3328
+ M.dot(Y.x + T + L * 1.6, Y.y, d(p) * 1.2);
3329
+ }
3330
+ }, C = (p, M) => {
3331
+ const I = mt(p), { top: W, hip: _ } = k(p), T = Ht(p) * p.height * 0.04, L = Z(_, W, 0.12), F = Z(_, W, 0.74);
3332
+ if (I < 0.15) {
3333
+ if (I < -0.3) {
3334
+ const V = p.points["shoulder.left"], U = p.points["shoulder.right"];
3335
+ M.line([V, { x: L.x + p.height * 0.03, y: L.y }], d(p) * 0.8), M.line([U, { x: L.x - p.height * 0.03, y: L.y }], d(p) * 0.8);
3336
+ }
3337
+ return;
3338
+ }
3339
+ const S = p.height * 0.07 * I;
3340
+ M.shape(
3341
+ [
3342
+ { x: F.x + T - S * 0.75, y: F.y },
3343
+ { x: F.x + T + S * 0.75, y: F.y },
3344
+ { x: L.x + T + S * 1.1, y: L.y },
3345
+ { x: L.x + T - S * 1.1, y: L.y }
3346
+ ],
3347
+ r,
3348
+ d(p)
3349
+ );
3350
+ for (const V of ["left", "right"]) {
3351
+ const U = p.points[`shoulder.${V}`], Wt = { x: F.x + T + (U.x > F.x + T ? 1 : -1) * S * 0.55, y: F.y };
3352
+ M.line([Wt, { x: U.x + (Wt.x - U.x) * 0.15, y: U.y + (Wt.y - U.y) * 0.15 }], d(p) * 1.6);
3353
+ }
3354
+ const B = Z(F, L, 0.3), Y = S * 0.4;
3355
+ M.line([{ x: B.x + T - Y, y: B.y }, { x: B.x + T - Y, y: B.y + Y * 1.4 }, { x: B.x + T + Y, y: B.y + Y * 1.4 }, { x: B.x + T + Y, y: B.y }], d(p) * 0.6);
3356
+ }, w = (p, M) => {
3357
+ const { hip: I, top: W } = k(p), _ = Z(I, W, 0.2), T = [p.points["ankle.left"], p.points["ankle.right"]], L = Z(I, { x: (T[0].x + T[1].x) / 2, y: (T[0].y + T[1].y) / 2 }, 0.98), F = p.height * 0.075, S = Math.max(p.height * 0.12, Math.abs(T[0].x - T[1].x) / 2 + p.height * 0.07), B = L.x - _.x, Y = L.y - _.y, V = Math.hypot(B, Y) || 1, U = { x: -Y / V, y: B / V };
3358
+ if (M.shape(
3359
+ [
3360
+ { x: _.x + U.x * F, y: _.y + U.y * F },
3361
+ { x: L.x + U.x * S, y: L.y + U.y * S },
3362
+ { x: L.x - U.x * S, y: L.y - U.y * S },
3363
+ { x: _.x - U.x * F, y: _.y - U.y * F }
3364
+ ],
3365
+ u,
3366
+ d(p)
3367
+ ), mt(p) > 0.2) {
3368
+ const Ft = Ht(p) * p.height * 0.03;
3369
+ for (const se of [-0.35, 0, 0.35]) {
3370
+ const ye = F * 0.5 * se, me = S * 0.45 * se;
3371
+ M.line([{ x: _.x + Ft + U.x * ye, y: _.y + U.y * ye + p.height * 0.02 }, { x: L.x + Ft + U.x * me, y: L.y + U.y * me }], d(p) * 0.5);
3372
+ }
3373
+ }
3374
+ }, E = (p, M) => {
3375
+ const I = mt(p), { top: W, hip: _ } = k(p), T = Ht(p), L = T >= 0 ? "left" : "right", F = L === "left" ? "right" : "left", S = p.points[`shoulder.${L}`], B = p.height * 0.035;
3376
+ if (I < 0.15) {
3377
+ const U = Z(W, _, 0.9);
3378
+ M.shape(ut([S, { x: U.x + (S.x - W.x) * 0.5, y: U.y }], B * 2.2, B * 2.6), u, d(p));
3379
+ return;
3380
+ }
3381
+ const Y = { x: _.x + (p.points[`hip.${F}`].x - _.x) * 1.2, y: Z(_, W, 0.08).y };
3382
+ M.shape(ut([Y, Z(Y, S, 0.5), S], B * 2.4, B * 2), u, d(p));
3383
+ const V = { x: S.x - (_.x - S.x) * 0.05 - T * p.height * 0.03, y: S.y + p.height * 0.16 };
3384
+ M.shape(ut([S, V], B * 2, B * 1.6), u, d(p));
3385
+ }, H = (p, M) => {
3386
+ if (p.bodyContours) {
3387
+ M.shape(gs(p, { top: !1, length: 0.45 }).skirt, r, d(p));
3388
+ return;
3389
+ }
3390
+ const { hip: I, top: W } = k(p), _ = Z(I, W, 0.18), T = [p.points["knee.left"], p.points["knee.right"]], L = Z(I, { x: (T[0].x + T[1].x) / 2, y: (T[0].y + T[1].y) / 2 }, 1.05), F = p.height * 0.075, S = Math.max(p.height * 0.13, Math.abs(T[0].x - T[1].x) / 2 + p.height * 0.08), B = L.x - _.x, Y = L.y - _.y, V = Math.hypot(B, Y) || 1, U = { x: -Y / V, y: B / V };
3391
+ M.shape(
3392
+ [
3393
+ { x: _.x + U.x * F, y: _.y + U.y * F },
3394
+ { x: L.x + U.x * S, y: L.y + U.y * S },
3395
+ { x: L.x - U.x * S, y: L.y - U.y * S },
3396
+ { x: _.x - U.x * F, y: _.y - U.y * F }
3397
+ ],
3398
+ r,
3399
+ d(p)
3400
+ );
3401
+ }, N = (p, M) => {
3402
+ const I = mt(p);
3403
+ if (I < 0.2) return;
3404
+ const { top: W, hip: _ } = k(p), T = { x: (_.x - W.x) * 0.12, y: (_.y - W.y) * 0.12 }, L = p.height * 0.045 * I;
3405
+ for (const F of [-1, 1])
3406
+ M.shape(
3407
+ [
3408
+ { x: W.x + F * L * 0.2, y: W.y + T.y * 0.1 },
3409
+ { x: W.x + F * L * 1.3, y: W.y - T.y * 0.1 },
3410
+ { x: W.x + F * L * 0.6 + T.x, y: W.y + T.y }
3411
+ ],
3412
+ o,
3413
+ d(p) * 0.8
3414
+ );
3415
+ }, D = (p, M, I) => {
3416
+ const W = mt(p);
3417
+ if (W < 0.25) return;
3418
+ const { top: _, hip: T } = k(p), L = Ht(p) * p.height * 0.03, F = (V) => ({ x: Z(_, T, V).x + L, y: Z(_, T, V).y }), S = p.height * 0.022 * W, B = F(0.08), Y = F(0.62);
3419
+ M.shape([{ x: B.x - S, y: B.y - S }, { x: B.x + S, y: B.y - S }, { x: B.x + S * 0.6, y: B.y + S }, { x: B.x - S * 0.6, y: B.y + S }], I, d(p) * 0.7), M.shape([{ x: B.x - S * 0.6, y: B.y + S }, { x: B.x + S * 0.6, y: B.y + S }, { x: Y.x + S * 1.4, y: Y.y - S * 2 }, Y, { x: Y.x - S * 1.4, y: Y.y - S * 2 }], I, d(p) * 0.7);
3420
+ }, X = (p, M) => {
3421
+ const I = mt(p), { top: W, hip: _ } = k(p), T = Z(_, W, 0.72), L = [p.points["knee.left"], p.points["knee.right"]], F = Z(_, { x: (L[0].x + L[1].x) / 2, y: (L[0].y + L[1].y) / 2 }, 0.9), S = Ht(p) * p.height * 0.04;
3422
+ if (I < 0.15) {
3423
+ const V = Z(_, W, 0.2);
3424
+ I < -0.3 && M.line([{ x: V.x - p.height * 0.05, y: V.y }, { x: V.x + p.height * 0.05, y: V.y }], d(p));
3425
+ return;
3426
+ }
3427
+ const B = p.height * 0.075 * I, Y = Z(_, W, 0.2);
3428
+ M.shape(
3429
+ [
3430
+ { x: T.x + S - B * 0.7, y: T.y },
3431
+ { x: T.x + S + B * 0.7, y: T.y },
3432
+ { x: Y.x + S + B, y: Y.y },
3433
+ { x: F.x + S + B * 1.15, y: F.y },
3434
+ { x: F.x + S - B * 1.15, y: F.y },
3435
+ { x: Y.x + S - B, y: Y.y }
3436
+ ],
3437
+ u,
3438
+ d(p)
3439
+ ), M.line([{ x: T.x + S - B * 0.6, y: T.y }, { x: W.x - B * 0.2, y: W.y }, { x: T.x + S + B * 0.6, y: T.y }], d(p) * 0.8);
3440
+ }, K = (p, M, I) => {
3441
+ const { top: W, hip: _ } = k(p), T = [p.points["knee.left"], p.points["knee.right"]], L = Z(_, { x: (T[0].x + T[1].x) / 2, y: (T[0].y + T[1].y) / 2 }, 0.95);
3442
+ I ? M.shape(ut([Z(W, _, 0.8), _, L], p.height * 0.145, p.height * 0.17), u, d(p)) : M.shape(ut([W, Z(W, _, 0.5), _], p.height * 0.14, p.height * 0.15), u, d(p));
3443
+ const F = mt(p);
3444
+ if (F > 0.2) {
3445
+ const S = Ht(p) * p.height * 0.03, [B, Y] = I ? [_, L] : [W, _];
3446
+ if (M.line([{ x: B.x + S, y: B.y }, { x: Y.x + S, y: Y.y }], d(p) * 0.8), !I) {
3447
+ const V = Z(W, _, 0.35), U = p.height * 0.025 * F;
3448
+ M.shape([{ x: V.x + S - U * 2.4, y: V.y }, { x: V.x + S - U * 0.6, y: V.y }, { x: V.x + S - U * 0.6, y: V.y + U * 1.6 }, { x: V.x + S - U * 2.4, y: V.y + U * 1.6 }], u, d(p) * 0.6);
3449
+ }
3450
+ }
3451
+ }, q = (p, M, I, W, _) => {
3452
+ const T = p.bodyContours?.[`arm.${I}`];
3453
+ if (T) {
3454
+ const Lt = Ge(T, 0, _, p.height * 6e-3);
3455
+ M.shape(Lt, W, 0);
3456
+ const ws = v(p);
3457
+ for (let pe = 0; pe < Lt.length; pe++) {
3458
+ const ze = Lt[pe], De = Lt[(pe + 1) % Lt.length];
3459
+ zo({ x: (ze.x + De.x) / 2, y: (ze.y + De.y) / 2 }, ws) || M.line([ze, De], d(p));
3460
+ }
3461
+ return;
3462
+ }
3463
+ const L = p.parts[`arm.${I}`].points, F = L[0], S = p.chains.spine[p.chains.spine.length - 1], Y = [{ x: F.x + (S.x - F.x) * 0.45, y: F.y + (S.y - F.y) * 0.45 }, ...Ze(L, 0, _)], V = ut(Y, p.height * 0.085, p.height * (_ > 0.6 ? 0.045 : 0.06)), U = Y.length, Wt = V.slice(0, U), Ft = V.slice(U).reverse();
3464
+ M.shape(V, W, 0);
3465
+ const se = (Lt) => Math.hypot(Lt[1].x - S.x, Lt[1].y - S.y), [ye, me] = se(Wt) > se(Ft) ? [Wt, Ft] : [Ft, Wt];
3466
+ M.line(ye.slice(1), d(p)), M.line(me.slice(Math.ceil(U * 0.45)), d(p)), M.line([Wt[U - 1], Ft[U - 1]], d(p));
3467
+ }, J = l || c || h, j = J ? u : o, Q = J || i === "long" ? 0.95 : 0.45, nt = J || i !== "none", lt = (p, M) => {
3468
+ a === "skirt" && !f && !y && H(p, M), y && w(p, M), l && K(p, M, !0), t.over === "apron" && X(p, M);
3469
+ }, xt = (p) => (M, I, W) => {
3470
+ M.save(), P(M, I), x(M, I, W, p), g && b(I, W, p), M.restore(), ga(I) === p && co(I) && lt(I, W);
3471
+ };
3472
+ return {
3473
+ parts: {
3474
+ "leg.left": { clip: P, over: xt("left") },
3475
+ "leg.right": { clip: P, over: xt("right") },
3476
+ spine: {
3477
+ over: (p, M, I) => {
3478
+ c && mt(M) >= 0 && $(M, I), R(M, I), O(p, M, I), s && !c && N(M, I), t.tie && !c && D(M, I, t.tie), l && K(M, I, !1), h && z(M, I), c && (mt(M) < 0 && $(M, I), A(M, I)), f && C(M, I), y && E(M, I), co(M) || lt(M, I);
3479
+ }
3480
+ },
3481
+ "arm.left": { over: nt ? (p, M, I) => q(M, I, "left", j, Q) : void 0 },
3482
+ "arm.right": { over: nt ? (p, M, I) => q(M, I, "right", j, Q) : void 0 }
3483
+ }
3484
+ };
3485
+ }
3486
+ const ma = {
3487
+ mug: { color: "#e2493b", hands: "one" },
3488
+ phone: { color: "#2b2f36", hands: "one" },
3489
+ book: { color: "#3a6ea5", hands: "either" },
3490
+ bag: { color: "#e9d8b4", hands: "one" },
3491
+ briefcase: { color: "#6b4630", hands: "one" },
3492
+ umbrella: { color: "#3c9a6e", hands: "one" },
3493
+ broom: { color: "#c8963e", hands: "one" },
3494
+ cane: { color: "#6b4630", hands: "one" },
3495
+ parcel: { color: "#c9a06a", hands: "both" }
3496
+ };
3497
+ function pa(t) {
3498
+ const e = {};
3499
+ for (const n of ["left", "right", "both"]) {
3500
+ const s = t[n];
3501
+ if (!s) continue;
3502
+ const o = typeof s == "string" ? s : s.item, r = ma[o];
3503
+ if (!r) throw new Error(`holding: unknown item '${o}'`);
3504
+ if (n === "both" && r.hands === "one") throw new Error(`holding: a ${o} is held in one hand ('left' or 'right'), not 'both'`);
3505
+ if (n !== "both" && r.hands === "both") throw new Error(`holding: a ${o} is held in both hands ('both')`);
3506
+ e[n] = { item: o, color: (typeof s == "object" ? s.color : void 0) ?? r.color };
3507
+ }
3508
+ return e;
3509
+ }
3510
+ function Qe(t, e) {
3511
+ const n = t.chains[`arm.${e}`], s = n[n.length - 1], o = n[n.length - 2], r = Math.hypot(s.x - o.x, s.y - o.y) || 1, i = { x: (s.x - o.x) / r, y: (s.y - o.y) / r }, a = t.lineWidth * 0.5;
3512
+ return { point: { x: s.x + i.x * a, y: s.y + i.y * a }, along: i, depth: t.parts[`arm.${e}`]?.depth ?? 0 };
3513
+ }
3514
+ function Jt(t, e, n, s = 0) {
3515
+ const o = Math.cos(s), r = Math.sin(s);
3516
+ return [
3517
+ [-e / 2, -n / 2],
3518
+ [e / 2, -n / 2],
3519
+ [e / 2, n / 2],
3520
+ [-e / 2, n / 2]
3521
+ ].map(([i, a]) => ({ x: t.x + i * o - a * r, y: t.y + i * r + a * o }));
3522
+ }
3523
+ const Zt = (t, e, n, s, o = 12) => Array.from({ length: o + 1 }, (r, i) => {
3524
+ const a = n + (s - n) * i / o;
3525
+ return { x: t.x + Math.cos(a) * e, y: t.y + Math.sin(a) * e };
3526
+ });
3527
+ function go(t, e, n, s, o, r = 1, i) {
3528
+ const { point: a, along: l } = n, c = s / 300;
3529
+ switch (e.item) {
3530
+ case "mug": {
3531
+ const h = Jt({ x: a.x, y: a.y - 4 * c }, 20 * c, 24 * c);
3532
+ t.line(Zt({ x: a.x + 10 * c * Math.sign(r || 1), y: a.y - 4 * c }, 7 * c, -Math.PI / 2, Math.PI / 2).map((f) => ({ x: a.x + (f.x - a.x) * Math.sign(r || 1), y: f.y })), o), t.shape(h, e.color, o);
3533
+ return;
3534
+ }
3535
+ case "phone": {
3536
+ const h = Math.atan2(l.y, l.x) - Math.PI / 2;
3537
+ t.shape(Jt(a, 13 * c, 24 * c, h), e.color, o), t.shape(Jt(a, 9 * c, 17 * c, h), "#8fd0f5", 0);
3538
+ return;
3539
+ }
3540
+ case "book": {
3541
+ const h = 26 * c, f = 34 * c;
3542
+ t.shape([{ x: a.x, y: a.y - f / 2 }, { x: a.x - h, y: a.y - f / 2 - 3 * c }, { x: a.x - h, y: a.y + f / 2 - 3 * c }, { x: a.x, y: a.y + f / 2 }], e.color, o), t.shape([{ x: a.x, y: a.y - f / 2 }, { x: a.x + h, y: a.y - f / 2 - 3 * c }, { x: a.x + h, y: a.y + f / 2 - 3 * c }, { x: a.x, y: a.y + f / 2 }], e.color, o);
3543
+ for (const y of [-1, 1])
3544
+ for (const u of [0.3, 0.5, 0.7]) {
3545
+ const g = a.y - f / 2 + f * u;
3546
+ t.line([{ x: a.x + y * 5 * c, y: g }, { x: a.x + y * (h - 5 * c), y: g - 2 * c }], Math.max(0.8, o * 0.5));
3547
+ }
3548
+ return;
3549
+ }
3550
+ case "bag": {
3551
+ const h = a.y + 10 * c;
3552
+ t.line([{ x: a.x - 9 * c, y: h }, { x: a.x - 5 * c, y: a.y - 2 * c }, { x: a.x + 5 * c, y: a.y - 2 * c }, { x: a.x + 9 * c, y: h }], o), t.shape([{ x: a.x - 17 * c, y: h }, { x: a.x + 17 * c, y: h }, { x: a.x + 20 * c, y: h + 40 * c }, { x: a.x - 20 * c, y: h + 40 * c }], e.color, o);
3553
+ return;
3554
+ }
3555
+ case "briefcase": {
3556
+ t.line(Zt({ x: a.x, y: a.y + 6 * c }, 7 * c, Math.PI, Math.PI * 2), o), t.shape(Jt({ x: a.x, y: a.y + 22 * c }, 46 * c, 32 * c), e.color, o), t.line([{ x: a.x - 23 * c, y: a.y + 14 * c }, { x: a.x + 23 * c, y: a.y + 14 * c }], Math.max(0.8, o * 0.6));
3557
+ return;
3558
+ }
3559
+ case "umbrella": {
3560
+ const h = 78 * c, f = (i ?? a.y - 120 * c) - 14 * c, y = { x: a.x, y: Math.min(a.y - 60 * c, f - h * 0.55) };
3561
+ t.line([{ x: a.x, y: a.y + 10 * c }, y], o), t.line(Zt({ x: a.x + 5 * c, y: a.y + 10 * c }, 5 * c, Math.PI, 0, 8), o);
3562
+ const u = [...Zt({ x: y.x, y: y.y + h * 0.55 }, h, Math.PI, Math.PI * 2, 24)], g = [];
3563
+ for (let m = 4; m >= 0; m--) {
3564
+ const d = y.x - h + 2 * h * m / 5;
3565
+ g.push(...Zt({ x: d + h / 5, y: y.y + h * 0.55 }, h / 5, 0, -Math.PI, 6).reverse());
3566
+ }
3567
+ t.shape([...u, ...g], e.color, o);
3568
+ return;
3569
+ }
3570
+ case "broom": {
3571
+ const h = { x: l.x * 0.4 + 0.25 * Math.sign(r || 1), y: Math.max(0.6, l.y) }, f = Math.hypot(h.x, h.y), y = { x: h.x / f, y: h.y / f }, u = { x: a.x - y.x * 40 * c, y: a.y - y.y * 40 * c }, g = { x: a.x + y.x * 120 * c, y: a.y + y.y * 120 * c };
3572
+ t.line([u, g], o * 1.1);
3573
+ const m = { x: -y.y, y: y.x }, d = [
3574
+ { x: g.x + m.x * 6 * c, y: g.y + m.y * 6 * c },
3575
+ { x: g.x - m.x * 6 * c, y: g.y - m.y * 6 * c },
3576
+ { x: g.x - m.x * 16 * c + y.x * 34 * c, y: g.y - m.y * 16 * c + y.y * 34 * c },
3577
+ { x: g.x + m.x * 16 * c + y.x * 34 * c, y: g.y + m.y * 16 * c + y.y * 34 * c }
3578
+ ];
3579
+ t.shape(d, e.color, o);
3580
+ return;
3581
+ }
3582
+ case "cane": {
3583
+ const h = Math.min(0.56 * s, Math.max(0.3 * s, -a.y)), f = 0.12 * Math.sign(r || 1), y = { x: f / Math.hypot(f, 1), y: 1 / Math.hypot(f, 1) }, u = { x: a.x + y.x * h, y: a.y + y.y * h }, g = Zt({ x: a.x + 7 * c * Math.sign(r || 1), y: a.y - 2 * c }, 7 * c, Math.PI, Math.PI * 2, 8).map((m) => ({ x: a.x + (m.x - a.x) * Math.sign(r || 1), y: m.y }));
3584
+ t.line([...g, { x: a.x, y: a.y + 2 * c }, u], o * 1.2), t.shape(Jt({ x: u.x, y: u.y - 3 * c }, 9 * c, 7 * c), e.color, 0);
3585
+ return;
3586
+ }
3587
+ case "parcel": {
3588
+ const h = { x: a.x, y: a.y - 6 * c };
3589
+ t.shape(Jt(h, 50 * c, 40 * c), e.color, o), t.line([{ x: h.x - 25 * c, y: h.y - 6 * c }, { x: h.x + 25 * c, y: h.y - 6 * c }], Math.max(0.8, o * 0.7)), t.line([{ x: h.x, y: h.y - 20 * c }, { x: h.x, y: h.y + 20 * c }], Math.max(0.8, o * 0.7));
3590
+ return;
3591
+ }
3592
+ }
3593
+ }
3594
+ const yo = (t, e) => (t[`held.${e}`] ?? 1) >= 0.5, mo = (t) => Math.sin(t * Math.PI / 2);
3595
+ function xa(t) {
3596
+ const e = (r) => Math.max(1, r.lineWidth * 0.45), n = (r) => (i, a, l, c, h) => {
3597
+ const f = t[r];
3598
+ f && yo(h ?? {}, r) && go(l, f, Qe(a, r), a.height, e(a), mo(a.turn), a.head.center.y - a.head.ry);
3599
+ }, s = (r, i, a, l, c) => {
3600
+ const h = t.both;
3601
+ if (!h || !yo(c ?? {}, "both")) return;
3602
+ const f = Qe(i, "left"), y = Qe(i, "right"), u = {
3603
+ point: { x: (f.point.x + y.point.x) / 2, y: (f.point.y + y.point.y) / 2 },
3604
+ along: { x: (f.along.x + y.along.x) / 2, y: (f.along.y + y.along.y) / 2 },
3605
+ depth: (f.depth + y.depth) / 2
3606
+ };
3607
+ go(a, h, u, i.height, e(i), mo(i.turn), i.head.center.y - i.head.ry);
3608
+ }, o = { parts: {} };
3609
+ if (t.left && (o.parts["arm.left"] = { over: n("left") }), t.right && (o.parts["arm.right"] = { over: n("right") }), t.both) {
3610
+ const r = (i) => (a, l, c, h, f) => {
3611
+ const y = i === "left" ? "right" : "left";
3612
+ (i === "left" ? l.parts["arm.left"].depth >= l.parts["arm.right"].depth : l.parts["arm.right"].depth > l.parts[`arm.${y}`].depth) && s(a, l, c, h, f);
3613
+ };
3614
+ for (const i of ["left", "right"]) o.parts[`arm.${i}`] = { ...o.parts[`arm.${i}`], over: wa(o.parts[`arm.${i}`]?.over, r(i)) };
3615
+ }
3616
+ return o;
3617
+ }
3618
+ function wa(t, e) {
3619
+ return t ? (n, s, o, r, i) => {
3620
+ t(n, s, o, r, i), e(n, s, o, r, i);
3621
+ } : e;
3622
+ }
3623
+ function je(t, e) {
3624
+ const n = (o, r) => o && r ? (i, a, l, c, h) => {
3625
+ o(i, a, l, c, h), r(i, a, l, c, h);
3626
+ } : o ?? r, s = {};
3627
+ for (const o of /* @__PURE__ */ new Set([...Object.keys(t.parts ?? {}), ...Object.keys(e.parts ?? {})])) {
3628
+ const r = t.parts?.[o], i = e.parts?.[o];
3629
+ s[o] = { under: n(r?.under, i?.under), clip: n(r?.clip, i?.clip), over: n(r?.over, i?.over) };
3630
+ }
3631
+ return { behind: n(t.behind, e.behind), parts: s, front: n(t.front, e.front) };
3632
+ }
3633
+ function ba(t = {}) {
3634
+ if (t.build && !(t.build in Yn)) throw new Error(`character: unknown build '${t.build}'`);
3635
+ const e = t.build ? Yn[t.build] : {}, n = (t.proportions ?? "bold") === "bold", s = t.figure ?? "fluid", o = t.look ?? "clean", r = t.height ?? 300, i = s === "stick", a = s === "organic", l = t.shoulderWidth ?? e.shoulderWidth ?? (a ? 0.07 : 0.06), c = t.hipWidth ?? e.hipWidth ?? (a ? 0.045 : 0.022), h = t.lineWidth ?? r * (a ? 5e-3 : n ? 0.045 : 0.022), f = t.ink ?? (a ? "#53362d" : o === "pencil" ? "#2f2f33" : "#1e293b"), y = t.skin ?? (a ? "#f1bf98" : o === "pencil" ? "none" : "#ffffff"), u = a ? ni(t.body ?? {}, { skin: y, ink: f, lineWidth: h, shoulderWidth: l, hipWidth: c }) : void 0;
3636
+ if (t.leafOutfit && !a) throw new Error("character: leafOutfit requires figure: 'organic'");
3637
+ const g = t.outfit ? ya(t.outfit) : null, m = t.holding ? pa(t.holding) : {};
3638
+ let d = g ? je(g, t.layers ?? {}) : t.layers ?? {};
3639
+ return t.leafOutfit && (d = je(ua(t.leafOutfit), d)), Object.keys(m).length > 0 && (d = je(d, xa(m))), {
3640
+ plan: t.plan ?? Jr({
3641
+ headSize: t.headSize ?? e.headSize ?? (a ? 0.27 : n ? 0.3 : 0.24),
3642
+ shoulderWidth: i ? 0 : l,
3643
+ hipWidth: i ? 0 : c,
3644
+ legLength: t.legLength ?? e.legLength ?? 1,
3645
+ armLength: t.armLength ?? e.armLength ?? 1,
3646
+ feet: t.feet ?? e.feet
3647
+ }),
3648
+ figure: s,
3649
+ ...u ? { body: u } : {},
3650
+ look: o,
3651
+ height: r,
3652
+ lineWidth: u?.outline.width ?? h,
3653
+ ink: u?.outline.color ?? f,
3654
+ skin: u?.fill ?? y,
3655
+ seed: t.seed ?? 1,
3656
+ pencil: a ? { construction: !1, ...t.pencil } : t.pencil ?? {},
3657
+ layers: d,
3658
+ holding: m,
3659
+ contact: t.contact ?? "ground",
3660
+ hands: t.hands ?? (a ? "cartoon" : "dot"),
3661
+ handStyle: t.handStyle ?? (a ? "natural" : "glove"),
3662
+ handSize: t.handSize ?? (a ? 0.073 : t.handStyle === "natural" ? 0.14 : 0.17),
3663
+ head: oa(t),
3664
+ face: { ...a ? { style: "anime", projection: "volume", iris: "#66422e", nose: !0 } : {}, ...t.face, teeth: t.face?.teeth ?? !1, tongue: t.face?.tongue ?? !1 }
3665
+ };
3666
+ }
3667
+ function Ja(t, e, n, s) {
3668
+ const { point: o, facing: r } = oe(t, [e, n, s]);
3669
+ return { point: o, facing: r };
3670
+ }
3671
+ const yn = (t) => t.rest[1] < -0.5, Ma = 0.3;
3672
+ function ka(t, e, n) {
3673
+ return t.figure === "stick" ? yn(e) ? n.slice(0, 3) : n : yn(e) && n.length >= 3 ? ne(n[0], n[1], n[2], Ma) : n.length === 3 ? ne(n[0], n[1], n[2], 1) : n;
3674
+ }
3675
+ function de(t, e) {
3676
+ const n = t.plan.id === "human" ? { ...at, ...e } : e;
3677
+ return Ne(t, n, wn(t.plan, n, { height: t.height, contact: t.contact }));
3678
+ }
3679
+ function Ne(t, e, n) {
3680
+ const s = {}, o = {}, r = {}, i = 0.01 * t.height;
3681
+ t.plan.chains.forEach((u) => {
3682
+ const g = n.chains[u.id];
3683
+ s[u.id] = g.points;
3684
+ const m = g.depths.reduce((k, v) => k + v, 0) / g.depths.length, d = u.parent ? n.chains[u.parent] : void 0, x = d ? d.depths[u.at ?? d.depths.length - 1] : n.hipDepth, b = m - x;
3685
+ r[u.id] = Math.abs(b) < i ? 0 : b, o[u.id] = { points: ka(t, u, g.points), depth: m, order: 0 };
3686
+ }), o.head = { points: [n.head.center], depth: n.head.depth, order: 0 }, r.head = 0;
3687
+ const a = [...t.plan.chains.map((u) => u.id), "head"], l = (u) => t.body && u.startsWith("arm.") && r[u] >= 0 ? 1 : 0, c = [...a].sort((u, g) => l(u) - l(g) || r[u] - r[g] || a.indexOf(u) - a.indexOf(g));
3688
+ c.forEach((u, g) => {
3689
+ o[u].order = g;
3690
+ });
3691
+ const h = { hip: n.hip };
3692
+ for (const [u, [g, m]] of Object.entries(t.plan.landmarks ?? {})) {
3693
+ const d = n.chains[g]?.points;
3694
+ d && (h[u] = d[Math.min(m, d.length - 1)]);
3695
+ }
3696
+ const f = {};
3697
+ for (const [u, g] of Object.entries(h)) f[u] = g.y >= n.groundY - 0.01 * t.height;
3698
+ const y = {
3699
+ height: t.height,
3700
+ lineWidth: t.lineWidth,
3701
+ turn: e.turn ?? 0,
3702
+ ...n.bodyForward ? { bodyForward: n.bodyForward } : {},
3703
+ points: h,
3704
+ chains: s,
3705
+ parts: o,
3706
+ head: n.head,
3707
+ groundY: n.groundY,
3708
+ grounded: f
3709
+ };
3710
+ return t.body && (y.bodyContours = ri(t.body, y, t.plan)), { skeleton: n, joints: y, order: c };
3711
+ }
3712
+ function va(t, e) {
3713
+ return de(t, e).joints;
3714
+ }
3715
+ function ys(t, e, n) {
3716
+ const { head: s } = n;
3717
+ t.guideEllipse(s.center.x, s.center.y, s.rx * 1.03, s.ry * 1.03, s.angle);
3718
+ const o = Array.from({ length: 13 }, (l, c) => ({ x: 0, y: -0.95 + 1.9 * c / 12 })), r = Array.from({ length: 13 }, (l, c) => ({ x: -0.95 + 1.9 * c / 12, y: 0.12 })), i = et(s, o, { x: 0, y: 0 });
3719
+ i.facing > 0 && t.guide(i.points), t.guide(et(s, r, { x: 0, y: 0.12 }).points), t.guide(n.chains.spine ?? []);
3720
+ const a = e.lineWidth * 0.9;
3721
+ for (const l of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
3722
+ const c = n.points[l];
3723
+ c && t.guideEllipse(c.x, c.y, a, a, 0);
3724
+ }
3725
+ }
3726
+ function ms(t, e, n, s, o, r) {
3727
+ const i = n.lineWidth;
3728
+ if (n.body && n.skin === "none" && (e = ge(t, e)), o === "head") {
3729
+ const { head: u } = s;
3730
+ let g;
3731
+ const m = () => g ??= qo(u, n.face), d = n.skin === "none" ? null : n.skin;
3732
+ n.face.projection === "volume" || n.face.shape === "angular" ? e.shape(m(), d, i) : e.ellipse(u.center.x, u.center.y, u.rx, u.ry, u.angle, d, i), n.body && n.skin !== "none" && e.look === "clean" && Eo(t, m(), u.center, n.body.shading), sa(t, e, n.head, u, r, { lineWidth: i, skin: n.skin, face: n.face, faceUnderHair: !!n.body }, () => {
3733
+ e.look !== "silhouette" && (t.save(), n.body && (t.beginPath(), m().forEach((x, b) => b ? t.lineTo(x.x, x.y) : t.moveTo(x.x, x.y)), t.closePath(), t.clip()), mi(e, u, r, i, { ...n.face, skin: n.skin === "none" ? "#ffffff" : n.skin }, t), t.restore());
3734
+ });
3735
+ return;
3736
+ }
3737
+ const a = n.plan.chains.find((u) => u.id === o), l = s.chains[o], c = s.parts[o].points;
3738
+ if (n.body && Xn(t, e, n.body, s, o)) {
3739
+ if (o.startsWith("leg.") && Xn(t, e, n.body, s, o.replace("leg.", "foot.")), o.startsWith("arm."))
3740
+ if (n.hands === "cartoon") po(t, e, n, l, o.endsWith(".left") ? "left" : "right", r);
3741
+ else {
3742
+ const u = l.at(-1);
3743
+ e.ellipse(u.x, u.y, n.height * 0.014, n.height * 0.014, 0, n.skin === "none" ? null : n.skin, i);
3744
+ }
3745
+ return;
3746
+ }
3747
+ if (n.figure === "stick") {
3748
+ if (o === "neck") return;
3749
+ const u = o === "spine" ? [...l, ...s.chains.neck?.slice(1) ?? []] : c;
3750
+ e.line(u, i);
3751
+ return;
3752
+ }
3753
+ const h = (u, g) => [a.bones[u].width[0] * i, a.bones[g].width[1] * i];
3754
+ if (yn(a)) {
3755
+ const [u, g] = h(0, 1);
3756
+ if (e.limb(c, u, g), a.bones.length >= 3)
3757
+ e.limb([l[2], l[3]], a.bones[2].width[0] * i, a.bones[2].width[1] * i);
3758
+ else if (n.hands === "cartoon" && o.startsWith("arm."))
3759
+ po(t, e, n, l, o.endsWith(".left") ? "left" : "right", r);
3760
+ else {
3761
+ const m = l[l.length - 1];
3762
+ e.dot(m.x, m.y, i * 0.62);
3763
+ }
3764
+ return;
3765
+ }
3766
+ if (o === "spine") {
3767
+ const u = s.points["hip.left"], g = s.points["hip.right"];
3768
+ u && g && Math.hypot(u.x - g.x, u.y - g.y) > 0.5 && e.limb([u, g], i * 1.3, i * 1.3);
3769
+ const [m, d] = h(0, a.bones.length - 1);
3770
+ e.limb(c, m, d);
3771
+ const x = s.points["shoulder.left"], b = s.points["shoulder.right"];
3772
+ x && b && Math.hypot(x.x - b.x, x.y - b.y) > 0.5 && e.limb(ne(x, l[l.length - 1], b, 1, 10), i * 1.15, i * 1.15);
3773
+ return;
3774
+ }
3775
+ const [f, y] = h(0, a.bones.length - 1);
3776
+ e.limb(c, f, y);
3777
+ }
3778
+ function Ea(t, e) {
3779
+ const n = `hand.${e}.`, s = {};
3780
+ for (const [i, a] of Object.entries(t)) i.startsWith(n) && (s[i.slice(n.length)] = a);
3781
+ const o = t.turn ?? 0, r = e === "right" ? 1 - o : 1 + o;
3782
+ return { ...Ot, ...s, turn: r + (s.turn ?? 0) };
3783
+ }
3784
+ function po(t, e, n, s, o, r) {
3785
+ const i = s[s.length - 1], a = s[s.length - 2], l = Math.atan2(i.x - a.x, -(i.y - a.y)) * 180 / Math.PI;
3786
+ So(t, i, Ea(r, o), {
3787
+ size: n.handSize * n.height,
3788
+ side: o,
3789
+ angle: l,
3790
+ pen: e,
3791
+ skin: n.skin === "none" && !n.body ? "#ffffff" : n.skin,
3792
+ // A cartoon glove: three fingers and a thumb, plump enough to match the limbs.
3793
+ // Natural: five fingers, a little fuller than a real hand so they hold up against the limbs.
3794
+ fingers: n.handStyle === "natural" ? 5 : 4,
3795
+ plump: n.handStyle === "natural" ? 1.15 : 1.6,
3796
+ lineWidth: n.lineWidth * (n.body ? 0.65 : 0.3),
3797
+ connected: !!n.body,
3798
+ shading: n.body?.shading,
3799
+ nails: n.body ? !1 : void 0
3800
+ });
3801
+ }
3802
+ function Sa(t, e, n, s = 0) {
3803
+ const o = e.plan.id === "human" ? { ...at, ...n } : n;
3804
+ Sn(t, e, o, de(e, o), s);
3805
+ }
3806
+ function Ye(t, e) {
3807
+ const n = e / t.height;
3808
+ return { ...t, height: e, lineWidth: t.lineWidth * n };
3809
+ }
3810
+ function Za(t, e, n, s) {
3811
+ const o = t.plan.id === "human" ? { ...at, ...e } : e, r = bn(t.plan, o, { height: s.height, contact: t.contact }, n);
3812
+ return Ne(Ye(t, r.height), o, r).joints;
3813
+ }
3814
+ function Qa(t, e, n, s, o) {
3815
+ const r = e.plan.id === "human" ? { ...at, ...n } : n, i = bn(e.plan, r, { height: o.height, contact: e.contact }, s), a = Ye(e, i.height);
3816
+ Sn(t, a, r, Ne(a, r, i), o.time ?? 0);
3817
+ }
3818
+ function ja(t, e, n, s) {
3819
+ const o = t.plan.id === "human" ? { ...at, ...e } : e, r = bn(t.plan, o, { height: s.height, contact: t.contact }, n), i = Ye(t, r.height), { joints: a, order: l } = Ne(i, o, r), c = r.height / s.height, h = l.map((g) => (a.parts[g]?.depth ?? 0) / c), f = l.filter((g) => g === "spine" || g.startsWith("leg.")), y = Math.max(...f.map((g) => a.parts[g].depth / c)), u = Math.max(...f.map((g) => a.parts[g].order));
3820
+ return l.map((g, m) => ({
3821
+ part: g,
3822
+ depth: h[m],
3823
+ ...i.body ? { sortDepth: g.startsWith("arm.") && m > u ? Math.max(h[m], y) : h[m] } : {},
3824
+ draw(d, x = 0) {
3825
+ const b = pn(d, { look: i.look, ink: i.ink, lineWidth: i.lineWidth, seed: Mo(`${i.seed}:${g}`), time: x, pencil: i.pencil }), k = (P) => {
3826
+ P && (d.save(), P(d, a, b, x, o), d.restore());
3827
+ };
3828
+ d.save(), d.lineCap = "round", d.lineJoin = "round", m === 0 && (i.look === "pencil" && i.pencil.construction !== !1 && ys(b, i, a), k(i.layers.behind), fs(d, i.body && i.skin === "none" ? ge(d, b) : b, i.head, a.head, o, { lineWidth: i.lineWidth, skin: i.skin, face: i.face }));
3829
+ const v = i.layers.parts?.[g];
3830
+ k(v?.under), d.save(), v?.clip?.(d, a, b, x, o), ms(d, b, i, a, g, o), d.restore(), k(v?.over), m === l.length - 1 && (us(d, b, i.head, a.head, o, { lineWidth: i.lineWidth, skin: i.skin }), k(i.layers.front)), d.restore();
3831
+ }
3832
+ }));
3833
+ }
3834
+ function Sn(t, e, n, s, o, r) {
3835
+ const { joints: i } = s, a = r ? s.order.filter((h) => r.has(h)) : s.order, l = pn(t, {
3836
+ look: e.look,
3837
+ ink: e.ink,
3838
+ lineWidth: e.lineWidth,
3839
+ seed: e.seed,
3840
+ time: o,
3841
+ pencil: e.pencil
3842
+ }), c = (h) => {
3843
+ h && (t.save(), h(t, i, l, o, n), t.restore());
3844
+ };
3845
+ t.save(), t.lineCap = "round", t.lineJoin = "round", !r && e.look === "pencil" && e.pencil.construction !== !1 && ys(l, e, i), r || c(e.layers.behind), fs(t, e.body && e.skin === "none" ? ge(t, l) : l, e.head, i.head, n, { lineWidth: e.lineWidth, skin: e.skin, face: e.face });
3846
+ for (const h of a) {
3847
+ const f = e.layers.parts?.[h];
3848
+ c(f?.under), t.save(), f?.clip?.(t, i, l, o, n), ms(t, l, e, i, h, n), t.restore(), c(f?.over);
3849
+ }
3850
+ us(t, l, e.head, i.head, n, { lineWidth: e.lineWidth, skin: e.skin }), r || c(e.layers.front), t.restore();
3851
+ }
3852
+ function t0(t, e, n, s) {
3853
+ const o = e.plan.id === "human" ? { ...at, ...n } : n, r = de(e, o).joints.head.rx, i = Ye(e, e.height * s.radius / Math.max(1e-6, r)), a = de(i, o);
3854
+ t.save(), t.translate(s.x - a.joints.head.center.x, s.y - a.joints.head.center.y), Sn(t, i, o, a, s.time ?? 0, /* @__PURE__ */ new Set(["head"])), t.restore();
3855
+ }
3856
+ function e0(t, e, n) {
3857
+ const s = { ...t };
3858
+ for (const [o, r] of Object.entries(e)) {
3859
+ const i = t[o] ?? r;
3860
+ s[o] = i + (r - i) * n;
3861
+ }
3862
+ return s;
3863
+ }
3864
+ function n0(t, e, n, s) {
3865
+ const o = t.plan.id === "human" ? { ...at, ...e } : e;
3866
+ let r;
3867
+ if (Array.isArray(s))
3868
+ r = s;
3869
+ else {
3870
+ const { skeleton: i } = de(t, o), a = wn(t.plan, { ...o, roll: 0 }, { height: t.height, contact: "none" }), l = (o.roll ?? 0) * Math.PI / 180, c = s.x - i.hip.x, h = s.y - i.hip.y, f = a.hip.x + c * Math.cos(-l) - h * Math.sin(-l), y = a.hip.y + c * Math.sin(-l) + h * Math.cos(-l), u = Math.PI / 2 * (o.turn ?? 0), g = s.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], m = Math.cos(u), d = Math.sin(u);
3871
+ r = [f * m - g * d, -y, f * d + g * m];
3872
+ }
3873
+ return ei(t.plan, o, n, r, { height: t.height });
3874
+ }
3875
+ const ps = /* @__PURE__ */ new Set(["walk", "walking", "gait"]);
3876
+ function xs(t, e = at, n) {
3877
+ let s = { ...e };
3878
+ for (const [r, i] of Object.entries(t))
3879
+ typeof i == "number" && !ps.has(r) && (s[r] = i);
3880
+ const o = Math.max(0, Math.min(1, typeof t.walking == "number" ? t.walking : 0));
3881
+ if (o > 0) {
3882
+ const r = typeof t.gait == "string" ? t.gait : void 0, i = r ? n?.[r] ?? r : void 0, a = ia(i, typeof t.walk == "number" ? t.walk : 0, s);
3883
+ s = Object.fromEntries(Object.keys({ ...s, ...a }).map((l) => [l, (s[l] ?? 0) + ((a[l] ?? 0) - (s[l] ?? 0)) * o]));
3884
+ }
3885
+ return s;
3886
+ }
3887
+ function o0(t) {
3888
+ const { character: e } = t, n = e.height * 0.8, s = e.height, o = e.plan.id === "human" ? at : {};
3889
+ return {
3890
+ type: "custom",
3891
+ x: t.x - n / 2,
3892
+ y: t.y - s,
3893
+ width: n,
3894
+ height: s,
3895
+ props: { ...o, ...t.pose },
3896
+ character: e,
3897
+ ...t.gaits ? { gaits: t.gaits } : {},
3898
+ draw(r, i, a) {
3899
+ r.translate(n / 2, s), Sa(r, e, xs(i.props ?? {}, o, t.gaits), a);
3900
+ }
3901
+ };
3902
+ }
3903
+ function Pa(t, e, n) {
3904
+ const s = (r) => ({ x: r.x + e, y: r.y + n }), o = (r) => Object.fromEntries(Object.entries(r).map(([i, a]) => [i, a.map(s)]));
3905
+ return {
3906
+ ...t,
3907
+ ...t.bodyContours ? { bodyContours: Object.fromEntries(Object.entries(t.bodyContours).map(([r, i]) => [r, {
3908
+ ...i,
3909
+ outline: i.outline.map(s),
3910
+ samples: i.samples.map((a) => ({ ...a, center: s(a.center), left: s(a.left), right: s(a.right) }))
3911
+ }])) } : {},
3912
+ points: Object.fromEntries(Object.entries(t.points).map(([r, i]) => [r, s(i)])),
3913
+ chains: o(t.chains),
3914
+ parts: Object.fromEntries(Object.entries(t.parts).map(([r, i]) => [r, { ...i, points: i.points.map(s) }])),
3915
+ head: { ...t.head, center: s(t.head.center) },
3916
+ groundY: t.groundY + n
3917
+ };
3918
+ }
3919
+ function s0(t, e, n) {
3920
+ const s = t.character;
3921
+ if (!s) throw new Error("characterAt: the target was not made by characterTarget");
3922
+ const o = { ...t.props };
3923
+ let r = 0, i = 0;
3924
+ for (const [c, h] of e.state?.values.get(n) ?? [])
3925
+ c === "x" || c === "motionPathX" ? r = typeof h == "number" ? h : r : c === "y" || c === "motionPathY" ? i = typeof h == "number" ? h : i : (typeof h == "number" || ps.has(c)) && (o[c] = h);
3926
+ const a = xs(o, s.plan.id === "human" ? at : {}, t.gaits), l = va(s, a);
3927
+ return { pose: a, joints: Pa(l, t.x + r + t.width / 2, t.y + i + t.height) };
3928
+ }
3929
+ function Aa(t, e = at) {
3930
+ const n = [];
3931
+ return t.forEach((s, o) => {
3932
+ const r = o === 0 ? e : n[o - 1], i = typeof s.pose == "string" ? Kr[s.pose] : void 0;
3933
+ n.push(i ? { ...i, turn: r.turn ?? 0 } : { ...r, ...s.pose });
3934
+ }), n;
3935
+ }
3936
+ function r0(t, e, n = at) {
3937
+ const s = Aa(e, n);
3938
+ return Object.keys(n).filter((r) => s.some((i) => (i[r] ?? n[r]) !== n[r])).map((r) => ({
3939
+ id: `${t}-${r}`,
3940
+ target: t,
3941
+ property: r,
3942
+ keyframes: e.map((i, a) => ({
3943
+ time: i.time,
3944
+ value: s[a][r] ?? n[r],
3945
+ ...i.easing ? { easing: i.easing } : {}
3946
+ }))
3947
+ }));
3948
+ }
3949
+ function xo() {
3950
+ return {
3951
+ torso: [{ at: 0, width: 0.083 }, { at: 0.25, width: 0.08 }, { at: 0.5, width: 0.075 }, { at: 0.8, width: 0.085 }, { at: 1, width: 0.023 }],
3952
+ arm: [{ at: 0, width: 0.026 }, { at: 0.3, width: 0.024 }, { at: 0.5, width: 0.018 }, { at: 0.7, width: 0.021 }, { at: 1, width: 0.012 }],
3953
+ leg: [{ at: 0, width: 0.036 }, { at: 0.3, width: 0.037 }, { at: 0.5, width: 0.026 }, { at: 0.7, width: 0.029 }, { at: 1, width: 0.015 }]
3954
+ };
3955
+ }
3956
+ const wo = {
3957
+ youngMan: {
3958
+ figure: "organic",
3959
+ skin: "#edb98d",
3960
+ ink: "#53372d",
3961
+ headSize: 0.28,
3962
+ shoulderWidth: 0.074,
3963
+ hipWidth: 0.045,
3964
+ handSize: 0.078,
3965
+ hair: { style: "softSweep", color: "#38291f" },
3966
+ ears: !0,
3967
+ face: { style: "anime", shape: "angular", jawWidth: 0.83, chinWidth: 0.35, jawRoundness: 1, eyeScale: 0.95, eyeAspect: 1.1, nose: !0, iris: "#6a472d" },
3968
+ outfit: { shirt: "#bc7050", trousers: "#495a67", sleeves: "short" }
3969
+ },
3970
+ youngWoman: {
3971
+ figure: "organic",
3972
+ skin: "#f1c299",
3973
+ ink: "#53372d",
3974
+ headSize: 0.28,
3975
+ shoulderWidth: 0.065,
3976
+ hipWidth: 0.054,
3977
+ handSize: 0.075,
3978
+ body: { torso: [{ at: 0, width: 0.098 }, { at: 0.18, width: 0.097 }, { at: 0.44, width: 0.061 }, { at: 0.7, width: 0.087 }, { at: 0.85, width: 0.09 }, { at: 1, width: 0.024 }] },
3979
+ hair: { style: "flowingBob", color: "#38291f" },
3980
+ ears: !0,
3981
+ face: { style: "anime", shape: "angular", jawWidth: 0.78, chinWidth: 0.32, jawRoundness: 1, eyeScale: 0.95, eyeAspect: 1.1, nose: !0, iris: "#6a472d", lashes: !0 },
3982
+ outfit: { shirt: "#72958b", trousers: "#6b6888", sleeves: "short", bottom: "skirt" }
3983
+ },
3984
+ childBoy: {
3985
+ figure: "organic",
3986
+ height: 230,
3987
+ skin: "#edb98d",
3988
+ ink: "#53372d",
3989
+ headSize: 0.36,
3990
+ shoulderWidth: 0.052,
3991
+ hipWidth: 0.038,
3992
+ legLength: 0.82,
3993
+ armLength: 0.8,
3994
+ handSize: 0.074,
3995
+ body: xo(),
3996
+ hair: { style: "softSweep", color: "#38291f" },
3997
+ ears: !0,
3998
+ face: { style: "anime", shape: "round", eyeScale: 1, eyeAspect: 1.1, nose: !0, iris: "#6a472d" },
3999
+ outfit: { shirt: "#d99843", trousers: "#497b91", sleeves: "short", bottom: "shorts" }
4000
+ },
4001
+ childGirl: {
4002
+ figure: "organic",
4003
+ height: 225,
4004
+ skin: "#f1c299",
4005
+ ink: "#53372d",
4006
+ headSize: 0.36,
4007
+ shoulderWidth: 0.052,
4008
+ hipWidth: 0.038,
4009
+ legLength: 0.82,
4010
+ armLength: 0.8,
4011
+ handSize: 0.074,
4012
+ body: xo(),
4013
+ hair: { style: "flowingBob", color: "#38291f" },
4014
+ ears: !0,
4015
+ face: { style: "anime", shape: "round", eyeScale: 1, eyeAspect: 1.1, nose: !0, iris: "#6a472d", lashes: !0 },
4016
+ outfit: { shirt: "#ae7396", trousers: "#648769", sleeves: "short", bottom: "skirt" }
4017
+ }
4018
+ };
4019
+ function i0(t, e = {}) {
4020
+ if (!Object.prototype.hasOwnProperty.call(wo, t)) throw new Error(`softCartoonCharacter: unknown actor '${t}'`);
4021
+ const n = wo[t];
4022
+ return ba({ ...n, ...e, body: { ...n.body, ...e.body }, face: { ...n.face, ...e.face } });
4023
+ }
4024
+ const bo = Object.freeze({
4025
+ everyday: Object.freeze({ shirt: "#bc7050", trousers: "#495a67", sleeves: "short", bottom: "trousers", collar: !1, tie: null }),
4026
+ formal: Object.freeze({ top: "shirt", shirt: "#f4ede2", trousers: "#394653", sleeves: "long", bottom: "trousers", trouserStyle: "plain", collar: !0, tie: "#804453" }),
4027
+ casual: Object.freeze({ top: "tshirt", shirt: "#648a83", trousers: "#426683", sleeves: "short", bottom: "trousers", trouserStyle: "jeans", collar: !1, tie: null })
4028
+ });
4029
+ function a0(t, e = {}) {
4030
+ if (!Object.prototype.hasOwnProperty.call(bo, t)) throw new Error(`outfitPreset: unknown category '${t}'`);
4031
+ const n = { ...bo[t], ...e };
4032
+ return e.top && e.top !== "shirt" && (n.collar = e.collar ?? !1, n.tie = e.tie ?? null), n.top === "dress" && (n.bottom = "skirt"), n;
4033
+ }
4034
+ const l0 = Object.freeze({
4035
+ test: Object.freeze({ name: "Test", inningsPerSide: 2, oversPerInnings: null, ballsPerOver: 6, freeHitAfterNoBall: !1, summary: "Multi-day cricket. Each side can have two innings; there is no innings over limit." }),
4036
+ odi: Object.freeze({ name: "ODI", inningsPerSide: 1, oversPerInnings: 50, ballsPerOver: 6, freeHitAfterNoBall: !0, summary: "One innings per side, up to 50 overs. A no-ball gives a free hit on the next legitimate delivery." }),
4037
+ t20: Object.freeze({ name: "T20", inningsPerSide: 1, oversPerInnings: 20, ballsPerOver: 6, freeHitAfterNoBall: !0, summary: "One innings per side, up to 20 overs. A no-ball gives a free hit on the next legitimate delivery." })
4038
+ }), h0 = Object.freeze(Object.fromEntries(Object.entries({
4039
+ bowling: { name: "Pace bowling", summary: "Run up, deliver with a straight arm, bounce and follow through." },
4040
+ spin: { name: "Spin bowling", summary: "A shorter approach and a curved illustrative flight before the bounce." },
4041
+ batting: { name: "Drive", summary: "Two hands on the bat, a backlift, contact and a follow-through." },
4042
+ defend: { name: "Defensive block", summary: "Meet the ball with a controlled bat and keep it close." },
4043
+ running: { name: "Running between wickets", summary: "Both batters make the opposite ground to complete one run." },
4044
+ four: { name: "Boundary four", summary: "A struck ball reaches the boundary after touching the ground." },
4045
+ six: { name: "Boundary six", summary: "A struck ball clears the boundary before touching the ground." },
4046
+ catch: { name: "Catch", summary: "A fielder controls the struck ball before it touches the ground." },
4047
+ fielding: { name: "Ground field", summary: "A fielder moves to the ball, bends and gathers it." },
4048
+ throw: { name: "Field and throw", summary: "Gather, wind up, release and return the ball to the keeper." },
4049
+ bowled: { name: "Bowled", summary: "A legal delivery hits the wicket and removes a bail." },
4050
+ lbw: { name: "LBW illustration", summary: "Pad contact and a projected path to the stumps illustrate an authored LBW decision." },
4051
+ stumping: { name: "Stumping", summary: "The keeper holds the ball and breaks the wicket while the striker is out of ground, not attempting a run." },
4052
+ "run-out": { name: "Run-out", summary: "A direct throw breaks the wicket before the running batter makes that ground." },
4053
+ "no-ball": { name: "Front-foot no-ball", summary: "The landing front foot oversteps the popping crease at release; one extra, no legal ball." },
4054
+ wide: { name: "Wide ball", summary: "An untouched delivery passes beyond reach for a normal stroke; one extra, no legal ball." }
4055
+ }).map(([t, e]) => [t, Object.freeze(e)])));
4056
+ function Oa(t, e, n) {
4057
+ if (!Object.prototype.hasOwnProperty.call(t, e)) throw new Error(`${n}: unknown choice '${e}'`);
4058
+ return e;
4059
+ }
4060
+ const Ia = Object.freeze({ pitch: "Whole pitch", batter: "Batter close-up", bowler: "Bowler close-up", keeper: "Keeper close-up", field: "Whole ground", overhead: "Overhead ground", orbit: "360° ground orbit", "follow-ball": "Follow the ball" }), Wa = Object.freeze({ pitch: 75, batter: 145, bowler: 35, keeper: 145, field: 75, overhead: 75, orbit: 75, "follow-ball": 75 });
4061
+ function c0(t, e = {}) {
4062
+ const n = Oa(Ia, e.view ?? "pitch", "cricketCamera.view"), s = e.yaw ?? Wa[n];
4063
+ if (!Number.isFinite(s)) throw new Error("cricketCamera: yaw must be finite");
4064
+ const o = (s % 360 + 360) % 360, r = e.every ?? 40;
4065
+ if (!Number.isFinite(r) || r < 16 || r > 1e3) throw new Error("cricketCamera: every must be between 16 and 1000 ms");
4066
+ if (n === "follow-ball") {
4067
+ const h = ["x", "y", "z"].map((f) => {
4068
+ const y = t.timeline.tracks.find((d) => d.target === `${t.scene.id}/ball` && d.property === f);
4069
+ if (!y || !("keyframes" in y) || !y.keyframes.length) throw new Error(`cricketCamera: missing ball ${f} keyframes`);
4070
+ const u = y.keyframes;
4071
+ let g = 0, m = new Pn({ ...y, keyframes: u.slice(0, 2) });
4072
+ return (d) => {
4073
+ const x = g;
4074
+ for (; g < u.length - 2 && d - (y.delay ?? 0) > u[g + 1].time; ) g++;
4075
+ return g !== x && (m = new Pn({ ...y, keyframes: u.slice(g, g + 2) })), m.getValueAtTime(d);
4076
+ };
4077
+ });
4078
+ return vs({ scene: t.scene.id, camera: "camera", start: 0, end: t.duration, every: r, offset: [5, 3, 6], subjectAt: (f) => h.map((y) => y(f)) });
4079
+ }
4080
+ const i = n === "field" || n === "overhead" || n === "orbit", a = n === "batter" ? [0.1, 0.85, 9.3] : n === "bowler" ? [0.68, 1, -9.55] : n === "keeper" ? [0, 0.7, 10.1] : [0, 0.65, 0], l = i ? t.boundaryRadius * 2.8 : n === "pitch" ? 29 : 4.3, c = n === "overhead" ? 89 : i ? 52 : n === "pitch" ? 16 : 12;
4081
+ return Es({ scene: t.scene.id, camera: "camera", start: 0, end: t.duration, every: r, easing: "linear", from: { target: a, yaw: o, pitch: c, distance: l, fov: i ? 48 : n === "pitch" ? 50 : 46 }, to: { yaw: n === "orbit" ? o + 360 : o } });
4082
+ }
4083
+ export {
4084
+ Da as $,
4085
+ Ka as A,
4086
+ aa as B,
4087
+ l0 as C,
4088
+ Us as D,
4089
+ So as E,
4090
+ Xa as F,
4091
+ le as G,
4092
+ at as H,
4093
+ n0 as I,
4094
+ va as J,
4095
+ Ua as K,
4096
+ xs as L,
4097
+ Aa as M,
4098
+ Cr as N,
4099
+ kt as O,
4100
+ or as P,
4101
+ Na as Q,
4102
+ Gt as R,
4103
+ wo as S,
4104
+ _a as T,
4105
+ Ba as U,
4106
+ Tr as V,
4107
+ Fa as W,
4108
+ ft as X,
4109
+ za as Y,
4110
+ tt as Z,
4111
+ Yo as _,
4112
+ ba as a,
4113
+ ar as a$,
4114
+ As as a0,
4115
+ Ps as a1,
4116
+ Ss as a2,
4117
+ ma as a3,
4118
+ is as a4,
4119
+ Ki as a5,
4120
+ Fi as a6,
4121
+ Ai as a7,
4122
+ Yn as a8,
4123
+ jr as a9,
4124
+ qa as aA,
4125
+ yo as aB,
4126
+ Pa as aC,
4127
+ Hr as aD,
4128
+ ua as aE,
4129
+ gs as aF,
4130
+ ri as aG,
4131
+ ve as aH,
4132
+ Ja as aI,
4133
+ Ya as aJ,
4134
+ Ni as aK,
4135
+ Be as aL,
4136
+ Vi as aM,
4137
+ Oi as aN,
4138
+ ji as aO,
4139
+ oa as aP,
4140
+ pa as aQ,
4141
+ ni as aR,
4142
+ Fo as aS,
4143
+ _r as aT,
4144
+ Dt as aU,
4145
+ ne as aV,
4146
+ Ra as aW,
4147
+ bn as aX,
4148
+ i0 as aY,
4149
+ ir as aZ,
4150
+ la as a_,
4151
+ Hs as aa,
4152
+ fe as ab,
4153
+ io as ac,
4154
+ bo as ad,
4155
+ ya as ae,
4156
+ oi as af,
4157
+ ha as ag,
4158
+ s0 as ah,
4159
+ Ea as ai,
4160
+ Za as aj,
4161
+ r0 as ak,
4162
+ o0 as al,
4163
+ Sa as am,
4164
+ t0 as an,
4165
+ Qa as ao,
4166
+ go as ap,
4167
+ $r as aq,
4168
+ tn as ar,
4169
+ er as as,
4170
+ _e as at,
4171
+ Le as au,
4172
+ Qe as av,
4173
+ Xs as aw,
4174
+ Ca as ax,
4175
+ xa as ay,
4176
+ Va as az,
4177
+ xn as b,
4178
+ mn as b0,
4179
+ ut as b1,
4180
+ rr as b2,
4181
+ Oa as c,
4182
+ Pt as d,
4183
+ ei as e,
4184
+ La as f,
4185
+ h0 as g,
4186
+ Ga as h,
4187
+ ia as i,
4188
+ Wa as j,
4189
+ Ia as k,
4190
+ c0 as l,
4191
+ wt as m,
4192
+ Ot as n,
4193
+ a0 as o,
4194
+ $s as p,
4195
+ Tn as q,
4196
+ Re as r,
4197
+ ti as s,
4198
+ an as t,
4199
+ Jr as u,
4200
+ e0 as v,
4201
+ nr as w,
4202
+ pn as x,
4203
+ ja as y,
4204
+ Kr as z
4205
+ };