@fabi-play/sdk 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! @fabi-play/sdk 0.1.0 | Fabi Play Kit License | https://docs.fabiplay.app */
1
+ /*! @fabi-play/sdk 0.3.0 | Fabi Play Kit License | https://docs.fabiplay.app */
2
2
  (function (root, factory) {
3
3
  var script = typeof document !== 'undefined' ? document.currentScript : null;
4
4
  if (typeof define === 'function' && define.amd) define([], function () { return factory(script); });
@@ -103,7 +103,8 @@ var domKeys = (doc = document) => ({
103
103
  var TAP_MS = 80;
104
104
  var MAX_HOLD_MS = 800;
105
105
  function keyboard(play, map = DEFAULT_KEYS, options = {}) {
106
- const player = options.player ?? 1;
106
+ const follow = options.player === void 0 && play.input === "remote";
107
+ let player = options.player ?? (follow ? play.players?.[0] ?? 1 : 1);
107
108
  const target = options.target ?? domKeys();
108
109
  const later = options.setTimeout ?? ((fn, ms) => setTimeout(fn, ms));
109
110
  const held = /* @__PURE__ */ new Set();
@@ -159,7 +160,17 @@ function keyboard(play, map = DEFAULT_KEYS, options = {}) {
159
160
  if (p.shape === "arms-up") down("arms-up");
160
161
  else up("arms-up");
161
162
  };
162
- const offs = [play.on("gesture", onGesture), play.on("frame", onFrame), play.on("break-start", () => [...held].forEach(up))];
163
+ const offs = [
164
+ play.on("gesture", onGesture),
165
+ play.on("frame", onFrame),
166
+ play.on("break-start", () => [...held].forEach(up)),
167
+ play.on("turn", (m) => {
168
+ if (!follow) return;
169
+ [...held].forEach(up);
170
+ player = m.players[0] ?? player;
171
+ lane = 0;
172
+ })
173
+ ];
163
174
  return () => {
164
175
  offs.forEach((off) => off());
165
176
  [...held].forEach(up);
@@ -274,6 +285,14 @@ function parseGameStats(v) {
274
285
  if (DEVICE_TIERS.includes(v.tier)) out.tier = v.tier;
275
286
  return out;
276
287
  }
288
+ var isPlayerId = (id) => Number.isInteger(id) && id >= 1 && id <= MAX_PLAYERS;
289
+ function parseTurnPlayers(v) {
290
+ return Array.isArray(v) && v.length === 1 && isPlayerId(v[0]) ? [v[0]] : void 0;
291
+ }
292
+ function parseTurnOrder(v) {
293
+ if (!Array.isArray(v) || v.length < 1 || v.length > MAX_PLAYERS || !v.every(isPlayerId) || new Set(v).size !== v.length) return void 0;
294
+ return [...v];
295
+ }
277
296
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
278
297
  var isNumber = (v) => typeof v === "number" && Number.isFinite(v);
279
298
  var POSE_HEADER = 12;
@@ -2221,9 +2240,11 @@ function smoothBody(prev, next, amount = 0.5) {
2221
2240
  const wasSeen = pv >= 0.5;
2222
2241
  const isSeen = nv >= 0.5;
2223
2242
  if (wasSeen && nv >= 0.3) out[i + 2] = Math.max(nv, 0.5);
2224
- if (wasSeen && isSeen && Math.hypot(next[i] - prev[i], next[i + 1] - prev[i + 1]) < 0.15) {
2225
- out[i] = prev[i] + (next[i] - prev[i]) * amount;
2226
- out[i + 1] = prev[i + 1] + (next[i + 1] - prev[i + 1]) * amount;
2243
+ const step = Math.hypot(next[i] - prev[i], next[i + 1] - prev[i + 1]);
2244
+ if (wasSeen && isSeen && step < 0.15) {
2245
+ const k = amount * Math.min(1, STILL_SHARE + (1 - STILL_SHARE) * step / STILL_FULL);
2246
+ out[i] = prev[i] + (next[i] - prev[i]) * k;
2247
+ out[i + 1] = prev[i + 1] + (next[i + 1] - prev[i + 1]) * k;
2227
2248
  } else if (wasSeen && !isSeen && out[i + 2] >= 0.5) {
2228
2249
  out[i] = prev[i];
2229
2250
  out[i + 1] = prev[i + 1];
@@ -2232,6 +2253,8 @@ function smoothBody(prev, next, amount = 0.5) {
2232
2253
  smoothFace(prev, next, out, amount * FACE_SMOOTHING);
2233
2254
  return out;
2234
2255
  }
2256
+ var STILL_SHARE = 0.1;
2257
+ var STILL_FULL = 0.03;
2235
2258
  var FACE_SMOOTHING = 0.35;
2236
2259
  var FACE_POINTS = 11;
2237
2260
  function smoothFace(prev, next, out, amount) {
@@ -2420,6 +2443,8 @@ function easy(connecting) {
2420
2443
  const listeners = /* @__PURE__ */ new Map();
2421
2444
  const emit = (event, data) => listeners.get(event)?.forEach((l) => l(data));
2422
2445
  let play = null;
2446
+ let start = null;
2447
+ const scores = /* @__PURE__ */ new Map();
2423
2448
  const queue = [];
2424
2449
  const withPlay = (fn) => play ? fn(play) : queue.push(fn);
2425
2450
  const early = new AvatarBook();
@@ -2433,6 +2458,7 @@ function easy(connecting) {
2433
2458
  p.on("break-start", () => emit("break-start", {}));
2434
2459
  p.on("break-done", (m) => emit("break-end", { shown: m.shown }));
2435
2460
  p.onBackdrop((backdrop, view) => emit("backdrop", { backdrop, view }));
2461
+ p.on("turn", (m) => emit("turn", { players: [...m.players] }));
2436
2462
  p.on("frame", (f2) => {
2437
2463
  emit("players", { players: f2.players });
2438
2464
  for (const pl of f2.players) {
@@ -2443,7 +2469,8 @@ function easy(connecting) {
2443
2469
  }
2444
2470
  }
2445
2471
  });
2446
- emit("start", startInfo(p));
2472
+ start = startInfo(p);
2473
+ emit("start", start);
2447
2474
  queue.splice(0).forEach((fn) => fn(p));
2448
2475
  });
2449
2476
  return {
@@ -2451,17 +2478,33 @@ function easy(connecting) {
2451
2478
  const set = listeners.get(event) ?? /* @__PURE__ */ new Set();
2452
2479
  listeners.set(event, set);
2453
2480
  set.add(listener);
2454
- if (event === "start" && play) listener(startInfo(play));
2481
+ if (event === "start" && start) listener(start);
2455
2482
  return () => void set.delete(listener);
2456
2483
  },
2457
2484
  ready: () => withPlay((p) => p.ready()),
2458
- score: (score, player = 1) => withPlay((p) => p.score(player, score)),
2485
+ score: (score, player) => withPlay((p) => {
2486
+ const who = player ?? playingNow(p);
2487
+ scores.set(who, score);
2488
+ p.score(who, score);
2489
+ }),
2459
2490
  break: (reason) => new Promise((resolve2) => withPlay((p) => void p.break(reason).then(resolve2))),
2460
2491
  end: (score) => withPlay(
2461
- (p) => p.end(typeof score === "number" ? [{ player: 1, score, stars: 2 }] : score.map((s) => ({ player: s.player, score: s.score, stars: s.stars ?? 2 })))
2492
+ (p) => p.end(typeof score === "number" ? endOf(p, score, scores) : score.map((s) => ({ player: s.player, score: s.score, stars: s.stars ?? 2 })))
2462
2493
  ),
2463
2494
  keys: (map, options) => withPlay((p) => void keyboard(p, map, options)),
2464
2495
  pointer: (options) => withPlay((p) => void pointer(p, options)),
2496
+ get players() {
2497
+ return play?.players ?? none;
2498
+ },
2499
+ get turns() {
2500
+ return play?.turns ?? none;
2501
+ },
2502
+ get input() {
2503
+ return play?.input ?? "body";
2504
+ },
2505
+ get hasPointer() {
2506
+ return play?.pointer ?? false;
2507
+ },
2465
2508
  get view() {
2466
2509
  return play?.view ?? null;
2467
2510
  },
@@ -2475,7 +2518,15 @@ function easy(connecting) {
2475
2518
  smoothedBody: (...args) => play ? play.smoothedBody(...args) : early.smoothedBody(...args)
2476
2519
  };
2477
2520
  }
2478
- var startInfo = (p) => ({ ageRange: p.ageRange, players: p.players, locale: p.locale, mode: p.mode, backdrop: p.backdrop, view: p.view, device: p.device });
2521
+ var none = Object.freeze([]);
2522
+ var startInfo = (p) => ({ ageRange: p.ageRange, players: p.players, locale: p.locale, mode: p.mode, backdrop: p.backdrop, view: p.view, device: p.device, turns: p.turns, input: p.input, pointer: p.pointer });
2523
+ var playingNow = (p) => p.input === "remote" ? p.players[0] ?? 1 : 1;
2524
+ function endOf(p, score, last) {
2525
+ const now2 = playingNow(p);
2526
+ if (p.input !== "remote") return [{ player: now2, score, stars: 2 }];
2527
+ const played = p.turns.slice(0, Math.max(p.turns.indexOf(now2), 0));
2528
+ return [...played.map((player) => ({ player, score: last.get(player) ?? 0, stars: 2 })), { player: now2, score, stars: 2 }];
2529
+ }
2479
2530
 
2480
2531
  // src/index.ts
2481
2532
  var windowChannel = (win = window) => ({
@@ -2489,9 +2540,14 @@ function connect(channel = windowChannel()) {
2489
2540
  return new Promise((resolve2, reject) => {
2490
2541
  const listeners = /* @__PURE__ */ new Map();
2491
2542
  const breaks = [];
2543
+ let inBreak = false;
2544
+ let turned = false;
2492
2545
  let started = false;
2493
2546
  let backdrop = "none";
2494
2547
  let view = null;
2548
+ let input = "body";
2549
+ let players = Object.freeze([]);
2550
+ let turns = players;
2495
2551
  const backdropListeners = /* @__PURE__ */ new Set();
2496
2552
  const avatars = new AvatarBook();
2497
2553
  const drawAvatar2 = avatarDrawer(avatars, () => ({ view }));
@@ -2510,6 +2566,11 @@ function connect(channel = windowChannel()) {
2510
2566
  backdrop = m.backdrop === "video" ? "video" : "none";
2511
2567
  view = parseView(m.view) ?? null;
2512
2568
  const device = parseDeviceHint(m.device) ?? null;
2569
+ input = m.input === "remote" ? "remote" : "body";
2570
+ const pointer2 = input === "remote" && m.pointer === true;
2571
+ players = Object.freeze(Array.isArray(m.players) ? [...m.players] : []);
2572
+ const order = input === "remote" && players.length === 1 ? parseTurnOrder(m.turns) : void 0;
2573
+ turns = Object.freeze(order && order[0] === players[0] ? order : [...players]);
2513
2574
  let reported = {};
2514
2575
  if (m.stats === true) {
2515
2576
  let since = performance.now();
@@ -2523,7 +2584,12 @@ function connect(channel = windowChannel()) {
2523
2584
  resolve2({
2524
2585
  locale: m.locale,
2525
2586
  mode: m.mode,
2526
- players: m.players,
2587
+ get players() {
2588
+ return players;
2589
+ },
2590
+ turns,
2591
+ input,
2592
+ pointer: pointer2,
2527
2593
  muted: m.muted,
2528
2594
  ageRange: m.ageRange ?? "6-8",
2529
2595
  get backdrop() {
@@ -2553,7 +2619,7 @@ function connect(channel = windowChannel()) {
2553
2619
  ready: () => channel.post(wire({ type: "ready" })),
2554
2620
  score: (player, score) => channel.post(wire({ type: "score", player, score })),
2555
2621
  break: (reason = "level") => new Promise((done) => {
2556
- breaks.push(done);
2622
+ breaks.push({ reason, done });
2557
2623
  channel.post(wire({ type: "break", reason }));
2558
2624
  }),
2559
2625
  end: (scores) => channel.post(wire({ type: "end", scores }))
@@ -2571,8 +2637,20 @@ function connect(channel = windowChannel()) {
2571
2637
  message = { type: "backdrop", backdrop, ...view ? { view } : {} };
2572
2638
  for (const l of [...backdropListeners]) l(backdrop, view);
2573
2639
  }
2640
+ if (m.type === "turn") {
2641
+ const next = input === "remote" && inBreak && !turned && breaks[0]?.reason === "turn" ? parseTurnPlayers(m.players) : void 0;
2642
+ const now2 = players[0];
2643
+ if (!next || now2 === void 0 || turns.indexOf(next[0]) <= turns.indexOf(now2)) return;
2644
+ turned = true;
2645
+ players = Object.freeze(next);
2646
+ message = { type: "turn", players: [...next] };
2647
+ }
2648
+ if (m.type === "break-start") inBreak = breaks.length > 0;
2574
2649
  for (const l of listeners.get(m.type) ?? []) l(message);
2575
- if (m.type === "break-done") breaks.shift()?.(m.shown);
2650
+ if (m.type === "break-done") {
2651
+ inBreak = turned = false;
2652
+ breaks.shift()?.done(m.shown);
2653
+ }
2576
2654
  }
2577
2655
  });
2578
2656
  });
@@ -1 +1 @@
1
- /*! @fabi-play/sdk 0.1.0 | Fabi Play Kit License | https://docs.fabiplay.app */(function(we,G){var de=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return G(de)}):typeof module=="object"&&module&&module.exports?module.exports=G(de):we.FabiPlay=G(de)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(we){"use strict";var G={exports:{}},de=G.exports,pe=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,mt=Object.prototype.hasOwnProperty,wt=(e,t,a)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Oe=(e,t)=>{for(var a in t)pe(e,a,{get:t[a],enumerable:!0})},gt=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!mt.call(e,s)&&s!==a&&pe(e,s,{get:()=>t[s],enumerable:!(o=kt(t,s))||o.enumerable});return e},vt=e=>gt(pe({},"__esModule",{value:!0}),e),D=(e,t,a)=>wt(e,typeof t!="symbol"?t+"":t,a),Le={};Oe(Le,{install:()=>Ra}),G.exports=vt(Le);function Et(e,t=window){const a=new Set,o=t.AudioContext;o&&(t.AudioContext=class extends o{constructor(...r){super(...r),a.add(this)}});let s=[],n=[];Promise.resolve(e).then(r=>{r.on("break-start",()=>{s=[...t.document.querySelectorAll("audio, video")].filter(h=>!h.paused),s.forEach(h=>h.pause()),n=[...a].filter(h=>h.state==="running"),n.forEach(h=>{h.suspend()})}),r.on("break-done",()=>{s.forEach(h=>{h.play().catch(()=>{})}),n.forEach(h=>{h.resume()}),s=[],n=[]})})}var Mt={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function At(e){if(e.trim()==="default")return;const t={};for(const a of e.split(",")){const[o,s]=a.split(":").map(n=>n.trim());o&&s&&(t[o]=s)}return t}var Ct={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function _e(e){const t=Ct[e];if(t)return{key:t[0],code:e,keyCode:t[1]};const a=/^Key([A-Z])$/.exec(e);if(a)return{key:a[1].toLowerCase(),code:e,keyCode:a[1].charCodeAt(0)};const o=/^Digit([0-9])$/.exec(e);if(o)return{key:o[1],code:e,keyCode:48+Number(o[1])};throw new Error(`Fabi Play: unknown key "${e}" (use Space, Enter, Arrow\u2026, KeyA\u2026, Digit0\u2026)`)}var St=(e=document)=>({dispatch(t,a){const o=new KeyboardEvent(t,{key:a.key,code:a.code,bubbles:!0,cancelable:!0});for(const s of["keyCode","which"])Object.defineProperty(o,s,{get:()=>a.keyCode});(e.activeElement??e.body??e).dispatchEvent(o)}}),De=80,Tt=800;function zt(e,t=Mt,a={}){const o=a.player??1,s=a.target??St(),n=a.setTimeout??((d,b)=>setTimeout(d,b)),r=new Set;let h=0;const i=d=>{const b=t[d];!b||r.has(d)||(r.add(d),s.dispatch("keydown",_e(b)))},f=d=>{const b=t[d];!b||!r.has(d)||(r.delete(d),s.dispatch("keyup",_e(b)))},l=d=>{i(d),n(()=>f(d),De)},u=d=>{if(d.player!==o)return;const b={"lane-left":-1,"lane-center":0,"lane-right":1};switch(d.gesture){case"jump":i("jump"),n(()=>f("jump"),Tt);break;case"land":f("jump");break;case"squat":i("squat");break;case"stand":f("squat");break;case"clap":l("clap");break;default:{const y=b[d.gesture];if(y===void 0)break;const k=y>h?"right":"left";for(let g=0;g<Math.abs(y-h);g++)n(()=>l(k),g*(De*2));h=y}}},c=d=>{const b=d.players.find(y=>y.id===o);b&&(b.shape==="arms-up"?i("arms-up"):f("arms-up"))},x=[e.on("gesture",u),e.on("frame",c),e.on("break-start",()=>[...r].forEach(f))];return()=>{x.forEach(d=>d()),[...r].forEach(f)}}function Pt(e=document){const t=e.createElement("div");t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:0;top:0;width:56px;height:56px;margin:-28px 0 0 -28px;border-radius:50%;border:6px solid #FBE7B8;background:rgba(251,231,184,.25);pointer-events:none;z-index:2147483647;box-sizing:border-box;transition:transform 60ms linear",e.body.appendChild(t);const a=(o,s,...n)=>{const r=e.elementFromPoint(o,s)??e.body;for(const h of n){const i={bubbles:!0,cancelable:!0,clientX:o,clientY:s,pointerId:1,pointerType:"touch",isPrimary:!0};r.dispatchEvent(h.startsWith("pointer")?new PointerEvent(h,i):new MouseEvent(h,i))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(o,s)=>a(o,s,"pointermove","mousemove"),click:(o,s)=>a(o,s,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(o,s,n)=>{t.style.transform=`translate(${o}px, ${s}px) scale(${1-n*.35})`,t.style.borderColor=n>0?"#EE6A43":"#FBE7B8"}}}function Ot(e,t={}){const a=t.player??1,o=t.hand??"any",s=t.dwellMs??800,n=t.radius??.04,r=t.target??Pt();let h=null,i=!1;return e.on("frame",f=>{const l=f.players.find(z=>z.id===a);if(!l)return;const c=o==="left"?l.leftHand:o==="right"?l.rightHand:((z,U)=>z&&U?z.y<U.y?z:U:z??U)(l.leftHand,l.rightHand);if(!c)return;const{width:x,height:d}=r.size(),b=c.x*x,y=c.y*d;r.move(b,y),(!h||Math.hypot(b-h.x,y-h.y)>n*Math.hypot(x,d))&&(h={x:b,y,t:f.t},i=!1);const g=i?0:Math.min((f.t-h.t)/s,1);g>=1&&(i=!0,r.click(h.x,h.y)),r.cursor(b,y,i?0:g)})}var Ne=1,Ie=33,T={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},Lt=["3-5","6-8","9-12"],_t=e=>Lt.includes(e),Dt=4,Re={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},Nt=Re["6-8"],Qe=(e,t)=>{const a=_t(t)?Re[t]:Nt;return a[Number.isInteger(e)&&e>=0?e%a.length:0]},Be="fabi-play",ne=e=>({ns:Be,...e});function Fe(e){if(!ge(e))return;const{x:t,y:a,w:o,h:s}=e;return te(t)&&te(a)&&te(o)&&te(s)&&o>0&&s>0?{x:t,y:a,w:o,h:s}:void 0}var He=(e,t)=>e?{x:e.x+t.x*e.w,y:e.y+t.y*e.h}:{x:t.x,y:t.y},je=["high","medium","low"];function It(e){if(!ge(e))return;const t={};return je.includes(e.tier)&&(t.tier=e.tier),te(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function Rt(e){const t={};return ge(e)&&(te(e.fps)&&e.fps>=0&&e.fps<1e3&&(t.fps=e.fps),typeof e.renderer=="string"&&/^[a-z0-9-]{1,16}$/.test(e.renderer)&&(t.renderer=e.renderer),je.includes(e.tier)&&(t.tier=e.tier)),t}var ge=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),te=e=>typeof e=="number"&&Number.isFinite(e),Qt=12,Bt=Ie*4,Ft=e=>Qt+e*Bt,Ha=Ft(Dt),B="#4a382c",R="#2b2118",j="#1c1f2b",Ue="#fbefe3",$="#f4897a",re="#3a2a22",$e=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:Ue,accent:"#ffd9c2",outline:R,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:re,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:Ue,accent:"#5a3426",outline:R,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:re,muzzle:"band",cheeks:$},tail:"brush",headExtras:[],bodyExtras:["star"],extraColors:["#ffd84a"]},{id:"bunny",name:{en:"Bunny",it:"Coniglietto"},band:"3-5",palette:{body:"#f9d0de",limbs:"#f9d0de",belly:"#fff6f8",accent:"#f4a0b9",outline:B},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:$},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:B},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:re,muzzle:"oval",cheeks:$},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:B,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:$},tail:"long",headExtras:["whiskers"],bodyExtras:[]},{id:"panda",name:{en:"Panda",it:"Panda"},band:"3-5",palette:{body:"#ffffff",limbs:"#6e6674",belly:"#ffffff",accent:"#6e6674",outline:B,ears:"#6e6674"},head:"wide",ears:"round",face:{eyes:"mask",mouth:"smile",nose:"#2f2a2c",muzzle:"none",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:[]},{id:"penguin",name:{en:"Penguin",it:"Pinguino"},band:"3-5",palette:{body:"#6c8fca",limbs:"#6c8fca",belly:"#ffffff",accent:"#f9b95c",outline:B,feet:"#f9b95c"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"heart",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:["flippers","scarf"],extraColors:["#f6907a"]},{id:"frog",name:{en:"Frog",it:"Ranocchio"},band:"3-5",palette:{body:"#8fd487",limbs:"#8fd487",belly:"#e6f7cc",accent:"#62ad62",outline:B},head:"wide",ears:"none",face:{eyes:"big",eyesOnTop:!0,mouth:"open",muzzle:"none",cheeks:"#f59b8f"},tail:"none",headExtras:[],bodyExtras:["flippers","spots"],extraColors:["#62ad62","#b0e6a4"]},{id:"lion",name:{en:"Lion",it:"Leoncino"},band:"6-8",palette:{body:"#f6c454",limbs:"#f6c454",belly:"#fde7b0",accent:"#fde7b0",outline:R},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:$},tail:"tuft",headExtras:["mane"],bodyExtras:[],extraColors:["#c8692e"]},{id:"unicorn",name:{en:"Unicorn",it:"Unicorno"},band:"6-8",palette:{body:"#fbf5ff",limbs:"#fbf5ff",belly:"#efe0ff",accent:"#fbd46a",outline:R,hands:"#c9a6f2",feet:"#c9a6f2"},head:"tall",ears:"unicorn",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["rainbow-mane"],bodyExtras:[],extraColors:["#f58cc0","#8fd3f4","#a98ff2"]},{id:"dragon",name:{en:"Little Dragon",it:"Draghetto"},band:"6-8",palette:{body:"#8a63d2",limbs:"#8a63d2",belly:"#fbd46a",accent:"#5fd0b5",outline:R},head:"wide",ears:"horns",face:{eyes:"big",eyeColor:"#3a2a6a",mouth:"teeth",muzzle:"none",cheeks:"#f59bc0"},tail:"arrow",headExtras:[],bodyExtras:["wings"]},{id:"robot",name:{en:"Robot",it:"Robot"},band:"9-12",palette:{body:"#b9c7d2",limbs:"#8b9aa6",belly:"#b9c7d2",accent:"#ee6a43",outline:j,hands:"#ee6a43",feet:"#6b7a86"},head:"square",ears:"antenna",face:{eyes:"screen",eyeColor:"#7ff0ff",mouth:"grill",muzzle:"none"},tail:"none",headExtras:["bolts"],bodyExtras:["panel","joints","boots"],extraColors:["#ff7a6b","#fbd46a","#7ff0ff"]},{id:"astronaut",name:{en:"Astronaut",it:"Astronauta"},band:"9-12",palette:{body:"#f4f1ec",limbs:"#f4f1ec",belly:"#f4f1ec",accent:"#ee6a43",outline:j,hands:"#9fb0bd",feet:"#9fb0bd"},head:"round",ears:"none",face:{eyes:"visor",mouth:"smile",muzzle:"none"},tail:"none",headExtras:["helmet"],bodyExtras:["backpack","badge","boots"],extraColors:["#c9d3db"]},{id:"dinosaur",name:{en:"Dinosaur",it:"Dinosauro"},band:"6-8",palette:{body:"#3fb3a6",limbs:"#3fb3a6",belly:"#c9f0d6",accent:"#f79a3e",outline:R},head:"wide",ears:"none",face:{eyes:"dot",mouth:"teeth",muzzle:"none",cheeks:"#f59b8f"},tail:"spiky",headExtras:["spikes","spots"],bodyExtras:[],extraColors:["#2b8f84","#7fd3c6"]},{id:"monkey",name:{en:"Monkey",it:"Scimmietta"},band:"6-8",palette:{body:"#7b5234",limbs:"#7b5234",belly:"#f2c9a0",accent:"#f2c9a0",outline:R,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:$},tail:"curl",headExtras:["tuft"],bodyExtras:[]},{id:"koala",name:{en:"Koala",it:"Koala"},band:"3-5",palette:{body:"#b7bcc6",limbs:"#b7bcc6",belly:"#eef0f3",accent:"#f4dbe2",outline:B},head:"wide",ears:"big-round",face:{eyes:"dot",mouth:"smile",nose:"#3b3438",muzzle:"none",cheeks:"#f4a3b0"},tail:"none",headExtras:[],bodyExtras:[]},{id:"tiger",name:{en:"Tiger",it:"Tigrotto"},band:"6-8",palette:{body:"#f9a33a",limbs:"#f9a33a",belly:"#fff1dc",accent:"#fff1dc",outline:R},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:$},tail:"striped",headExtras:["stripes","whiskers"],bodyExtras:[],extraColors:["#3a2a22"]},{id:"owl",name:{en:"Owl",it:"Gufetto"},band:"3-5",palette:{body:"#8ec0e6",limbs:"#8ec0e6",belly:"#e3f2fc",accent:"#639cc9",outline:B,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:B,eyeRing:"#fde08a",mouth:"beak",muzzle:"none",cheeks:"#f6a8b4"},tail:"none",headExtras:[],bodyExtras:["feathers"]},{id:"alien",name:{en:"Alien",it:"Alieno"},band:"9-12",palette:{body:"#9ee05a",limbs:"#9ee05a",belly:"#d8f5a8",accent:"#b07cf2",outline:j},head:"bulb",ears:"antennae",face:{eyes:"almond",eyeColor:"#1e1838",mouth:"smirk",muzzle:"none"},tail:"none",headExtras:[],bodyExtras:["spots"],extraColors:["#7cc23e","#7cc23e"]},{id:"ghost",name:{en:"Friendly Ghost",it:"Fantasmino"},band:"6-8",palette:{body:"#e6f4ff",limbs:"#e6f4ff",belly:"#e6f4ff",accent:"#bcd9f2",outline:R},head:"round",ears:"none",face:{eyes:"dot",mouth:"open",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["curl"],bodyExtras:["sheet"]},{id:"octopus",name:{en:"Octopus",it:"Polpetto"},band:"6-8",palette:{body:"#e0578a",limbs:"#e0578a",belly:"#f7b3cc",accent:"#f7b3cc",outline:R,hands:"#f7b3cc",feet:"#f7b3cc"},head:"tall",ears:"none",face:{eyes:"big",eyeColor:"#3a2140",mouth:"smile",muzzle:"none",cheeks:"#ffd0a0"},tail:"none",headExtras:["spots"],bodyExtras:["tentacles"],extraColors:["#f7b3cc","#f7b3cc"]},{id:"chick",name:{en:"Chick",it:"Pulcino"},band:"3-5",palette:{body:"#ffd45e",limbs:"#ffd45e",belly:"#fff2c2",accent:"#ffa04a",outline:B,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:$},tail:"none",headExtras:["eggshell"],bodyExtras:[],extraColors:["#fffaf0"]},{id:"puppy",name:{en:"Puppy",it:"Cucciolo"},band:"3-5",palette:{body:"#f4e4cf",limbs:"#f4e4cf",belly:"#fffaf2",accent:"#f29aa4",outline:B,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:re,muzzle:"oval",cheeks:$},tail:"curl",headExtras:["eye-spot"],bodyExtras:[]},{id:"lamb",name:{en:"Lamb",it:"Agnellino"},band:"3-5",palette:{body:"#fdf8ee",limbs:"#e3d1c2",belly:"#fffdf8",accent:"#f6bcc2",outline:B,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:$},tail:"pom",headExtras:["wool"],bodyExtras:["wool"]},{id:"duckling",name:{en:"Duckling",it:"Anatroccolo"},band:"3-5",palette:{body:"#fff1a6",limbs:"#fff1a6",belly:"#fffbe0",accent:"#ff9f43",outline:B,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:$},tail:"none",headExtras:["curl"],bodyExtras:["flippers","scarf"],extraColors:["#86cfe0"]},{id:"shark",name:{en:"Shark",it:"Squalo"},band:"6-8",palette:{body:"#6c95c4",limbs:"#6c95c4",belly:"#eef5fb",accent:"#4c76a8",outline:R,hands:"#eef5fb",feet:"#4c76a8"},head:"wide",ears:"fin",face:{eyes:"dot",mouth:"jaws",muzzle:"none",cheeks:"#f59bb0"},tail:"fish",headExtras:["gills"],bodyExtras:[]},{id:"wolf",name:{en:"Wolf",it:"Lupo"},band:"6-8",palette:{body:"#8f9bb3",limbs:"#8f9bb3",belly:"#eef1f6",accent:"#f3b8c4",outline:R,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:re,muzzle:"oval",cheeks:"#f4a3b0"},tail:"fluffy",headExtras:["ruff","forehead"],bodyExtras:[],extraColors:["#636d84"]},{id:"parrot",name:{en:"Parrot",it:"Pappagallo"},band:"6-8",palette:{body:"#e8503f",limbs:"#e8503f",belly:"#ffd25a",accent:"#f6e6c4",outline:R,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:R,eyeRing:"#ffffff",mouth:"hook",muzzle:"none",cheeks:"#ffb0a0"},tail:"plume",headExtras:["crest"],bodyExtras:["feathers"],extraColors:["#ffd25a","#3fae5a","#3a9bdc"]},{id:"ninja",name:{en:"Ninja",it:"Ninja"},band:"9-12",palette:{body:"#2f3a56",limbs:"#2f3a56",belly:"#2f3a56",accent:"#36c9bb",outline:j,skin:"#b07a52",hands:"#222a40",feet:"#222a40"},head:"round",ears:"none",face:{eyes:"calm",mouth:"none",muzzle:"none",brows:"#2a1d16"},tail:"none",headExtras:["ninja-hood"],bodyExtras:["belt"],extraColors:["#36c9bb","#36c9bb","#36c9bb"]},{id:"skater",name:{en:"Skater",it:"Skater"},band:"9-12",palette:{body:"#3a8fc0",limbs:"#2c3e57",belly:"#2f7aa6",accent:"#ffcf3a",outline:j,skin:"#f2c9a5",hair:"#7a4a2a",hands:"#f2c9a5",feet:"#eef1f5"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#5a3520"},tail:"none",headExtras:["hair","cap"],bodyExtras:["pocket","joints"],extraColors:["#ff5d73"]},{id:"explorer",name:{en:"Explorer",it:"Giramondo"},band:"9-12",palette:{body:"#5f8f5b",limbs:"#5f8f5b",belly:"#5f8f5b",accent:"#d9bb7e",outline:j,skin:"#7a4a30",hair:"#1d1410",hands:"#7a4a30",feet:"#6b4a2a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#1d1410"},tail:"none",headExtras:["curls","safari-hat"],bodyExtras:["backpack","straps","boots"],extraColors:["#e07b39","#6b4a2a"]},{id:"wizard",name:{en:"Wizard",it:"Mago"},band:"9-12",palette:{body:"#5b3fa0",limbs:"#5b3fa0",belly:"#5b3fa0",accent:"#3d5fc8",outline:j,skin:"#c98d62",hair:"#a8452a",hands:"#c98d62",feet:"#33255e"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#7a301c"},tail:"none",headExtras:["locks","wizard-hat"],bodyExtras:["robe","belt"],extraColors:["#ffd84a","#ffd84a","#ffd84a"]},{id:"knight",name:{en:"Knight",it:"Cavaliere"},band:"9-12",palette:{body:"#bcc7d3",limbs:"#8e9aa8",belly:"#dce3ea",accent:"#d8443a",outline:j,hands:"#6c7786",feet:"#6c7786"},head:"bucket",ears:"none",face:{eyes:"slit",eyeColor:"#bfefff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["plume"],bodyExtras:["pauldrons","emblem","boots"],extraColors:["#d8443a"]},{id:"racer",name:{en:"Racer",it:"Pilota"},band:"9-12",palette:{body:"#ff6a2b",limbs:"#ff6a2b",belly:"#ffffff",accent:"#ffffff",outline:j,hands:"#232838",feet:"#232838"},head:"round",ears:"none",face:{eyes:"goggle",eyeColor:"#7fd6ff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["stripe"],bodyExtras:["racing-stripe","boots"]},{id:"pirate",name:{en:"Pirate",it:"Pirata"},band:"9-12",palette:{body:"#f2efe6",limbs:"#2a3d6e",belly:"#f2efe6",accent:"#d94545",outline:j,skin:"#d9a072",hair:"#2b1a12",hands:"#d9a072",feet:"#3a2a20"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#2b1a12"},tail:"none",headExtras:["locks","bandana","eye-patch"],bodyExtras:["stripes","belt","boots"],extraColors:["#d94545","#2a3d6e","#4a3426"]},{id:"diver",name:{en:"Diver",it:"Sub"},band:"9-12",palette:{body:"#1f6582",limbs:"#1f6582",belly:"#1f6582",accent:"#ffb020",outline:j,skin:"#e8b48a",hair:"#c98f2e",hands:"#1b4f66",feet:"#ffb020"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#8a5a1a"},tail:"none",headExtras:["curls","dive-mask"],bodyExtras:["tank","fins"],extraColors:["#c9d3db"]},{id:"hero",name:{en:"Hero",it:"Supereroe"},band:"9-12",palette:{body:"#3557c8",limbs:"#3557c8",belly:"#3557c8",accent:"#e0403a",outline:j,skin:"#5a3825",hair:"#141010",hands:"#e0403a",feet:"#e0403a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#141010"},tail:"none",headExtras:["hair","domino"],bodyExtras:["cape","emblem","boots"],extraColors:["#ffd84a"]}],L={M:0,L:1,Q:2,C:3,Z:4},qe=[2,2,4,6,0];function ve(e,t){for(const a of t)Ht(e,a)}function Ht(e,t){if(t.k==="group"){e.save(),e.translate(t.x,t.y),t.rot&&e.rotate(t.rot),t.s!==void 0&&t.s!==1&&e.scale(t.s,t.s),t.alpha!==void 0&&(e.globalAlpha*=t.alpha),ve(e,t.items),e.restore();return}switch(e.save(),t.alpha!==void 0&&(e.globalAlpha*=t.alpha),e.beginPath(),t.k){case"circle":e.arc(t.x,t.y,Math.max(t.r,0),0,Math.PI*2);break;case"ellipse":e.ellipse(t.x,t.y,Math.max(t.rx,0),Math.max(t.ry,0),t.rot??0,0,Math.PI*2);break;case"rect":jt(e,t);break;case"path":typeof t.d=="string"?qt(e,t.d):Ut(e,t.d);break;case"line":e.moveTo(t.pts[0]??0,t.pts[1]??0);for(let a=2;a+1<t.pts.length;a+=2)e.lineTo(t.pts[a],t.pts[a+1]);break}e.lineCap="round",e.lineJoin="round",t.fill&&t.k!=="line"&&(e.fillStyle=t.fill,e.fill()),t.stroke&&(t.lw??1)>0&&(e.strokeStyle=t.stroke,e.lineWidth=t.lw??1,e.stroke()),e.restore()}function jt(e,t){const a=Math.max(0,Math.min(t.r,t.w/2,t.h/2));e.translate(t.x,t.y),t.rot&&e.rotate(t.rot);const o=-t.w/2,s=-t.h/2;e.moveTo(o+a,s),e.lineTo(o+t.w-a,s),e.quadraticCurveTo(o+t.w,s,o+t.w,s+a),e.lineTo(o+t.w,s+t.h-a),e.quadraticCurveTo(o+t.w,s+t.h,o+t.w-a,s+t.h),e.lineTo(o+a,s+t.h),e.quadraticCurveTo(o,s+t.h,o,s+t.h-a),e.lineTo(o,s+a),e.quadraticCurveTo(o,s,o+a,s),e.closePath()}function Ut(e,t){for(let a=0;a<t.length;){const o=t[a++];if(o===L.M)e.moveTo(t[a],t[a+1]);else if(o===L.L)e.lineTo(t[a],t[a+1]);else if(o===L.Q)e.quadraticCurveTo(t[a],t[a+1],t[a+2],t[a+3]);else if(o===L.C)e.bezierCurveTo(t[a],t[a+1],t[a+2],t[a+3],t[a+4],t[a+5]);else if(o===L.Z)e.closePath();else return;a+=qe[o]}}function $t(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);const t=[];for(let a=0;a<e.length;){const o=qe[e[a++]];if(o===void 0)break;for(let s=0;s<o;s++)t.push(e[a+s]);a+=o}return t}function qt(e,t){const a=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let o="",s=0;const n=()=>Number(a[s++]);for(;s<a.length;){const r=a[s];if(/[MLQCZ]/i.test(r)&&(o=r.toUpperCase(),s++,o==="Z")){e.closePath();continue}o==="M"?(e.moveTo(n(),n()),o="L"):o==="L"?e.lineTo(n(),n()):o==="Q"?e.quadraticCurveTo(n(),n(),n(),n()):o==="C"?e.bezierCurveTo(n(),n(),n(),n(),n(),n()):s++}}var A=e=>{const t=Math.round(e*100)/100;return t===0?0:t};function O(e,t=.5){const a=e.length;if(a<3)return[];const o=(h,i,f)=>({x:h.x+(i.x-h.x)*f,y:h.y+(i.y-h.y)*f}),s=Math.min(Math.max(t,0),.5),n=o(e[0],e[1],s),r=[L.M,A(n.x),A(n.y)];for(let h=1;h<=a;h++){const i=e[(h-1)%a],f=e[h%a],l=e[(h+1)%a],u=o(i,f,1-s),c=o(f,l,s);r.push(L.L,A(u.x),A(u.y),L.Q,A(f.x),A(f.y),A(c.x),A(c.y))}return r.push(L.Z),r}function P(e,t=1){const a=e.length;if(a<3)return[];const o=[L.M,A(e[0].x),A(e[0].y)],s=t/6;for(let n=0;n<a;n++){const r=e[(n-1+a)%a],h=e[n],i=e[(n+1)%a],f=e[(n+2)%a];o.push(L.C,A(h.x+(i.x-r.x)*s),A(h.y+(i.y-r.y)*s),A(i.x-(f.x-h.x)*s),A(i.y-(f.y-h.y)*s),A(i.x),A(i.y))}return o.push(L.Z),o}function le(e){const t=e.length;if(t<2)return[];const a=[L.M,A(e[0].x),A(e[0].y)];for(let o=0;o<t-1;o++){const s=e[Math.max(o-1,0)],n=e[o],r=e[o+1],h=e[Math.min(o+2,t-1)];a.push(L.C,A(n.x+(r.x-s.x)/6),A(n.y+(r.y-s.y)/6),A(r.x-(h.x-n.x)/6),A(r.y-(h.y-n.y)/6),A(r.x),A(r.y))}return a}var ye="M0 -1 L0.29 -0.4 L0.95 -0.31 L0.47 0.15 L0.59 0.81 L0 0.5 L-0.59 0.81 L-0.47 0.15 L-0.95 -0.31 L-0.29 -0.4 Z",N="#ffffff",v=[-1,1],Ye="#3a2420",Yt="#f2808f",Ee="#26324a",Zt="#ffd84a",Q=(...e)=>{const t=[];for(let a=0;a+1<e.length;a+=2)t.push({x:e[a],y:e[a+1]});return t};function Ze(e,t){const a=e.palette,o=[],s={stroke:a.outline,lw:t},n=l=>e.headExtras.includes(l),r=(l,u)=>e.extraColors?.[l]??u;if(n("mane")){for(let u=0;u<12;u++){const c=u/12*Math.PI*2;o.push({k:"circle",x:Math.cos(c)*1.02,y:Math.sin(c)*1+.04,r:.42,fill:r(0,a.accent),...s})}o.push({k:"circle",x:0,y:.04,r:1.08,fill:r(0,a.accent)})}if(n("rainbow-mane")){const l=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([c,x,d,b,y],k)=>o.push({k:"ellipse",x:c,y:x,rx:d,ry:b,rot:y,fill:l[k%l.length],...s}))}if(n("spikes"))for(const l of[-.55,0,.55]){const u=ie(l,1.48),c=ie(l-.32,.86),x=ie(l+.32,.86);o.push({k:"path",d:O([c,u,x],.22),fill:a.accent,...s})}if(n("curl")&&o.push({k:"path",d:P([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:a.body,...s}),n("wool"))for(let l=0;l<=8;l++){const u=-1.75+l/8*3.5;o.push({k:"circle",x:Math.sin(u)*.98,y:-Math.cos(u)*.92-.04,r:.34,fill:a.body,...s})}if(n("crest")&&[-.38,0,.38].forEach((l,u)=>{const c=ie(l,1.12);o.push({k:"ellipse",x:c.x,y:c.y,rx:.15,ry:.42,rot:l,fill:r(u,a.accent),...s})}),n("plume")&&o.push({k:"path",d:P(Q(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:a.accent,...s}),n("locks")&&o.push({k:"path",d:P(Q(-1.14,.58,-1.24,-.2,-.86,-.98,0,-1.2,.86,-.98,1.24,-.2,1.14,.58,.8,.66,0,.2,-.8,.66)),fill:a.hair??a.outline,...s}),n("ninja-hood"))for(const[l,u]of[[.35,.5],[.85,.42]])o.push({k:"ellipse",x:1+Math.cos(l)*u*.8,y:-.5+Math.sin(l)*u*.8,rx:u,ry:.11,rot:l,fill:a.accent,...s});if(n("bandana"))for(const[l,u]of[[Math.PI-.5,.42],[Math.PI-1,.36]])o.push({k:"ellipse",x:-.98+Math.cos(l)*u*.8,y:-.36+Math.sin(l)*u*.8,rx:u,ry:.12,rot:l,fill:a.accent,...s});if(n("ruff"))for(const l of v)o.push({k:"path",d:O(Q(l*.7,-.3,l*1.32,0,l*1.02,.18,l*1.26,.46,l*.86,.56,l*.98,.84,l*.4,.7),.25),fill:a.body,...s});if(e.face.eyesOnTop)for(const l of v)o.push({k:"circle",x:l*.46,y:-.72,r:.38,fill:a.body,...s});o.push(...Gt(e,t)),o.push(Kt(e,s));const h=e.face.muzzle,i=a.belly;if(h==="oval"&&o.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:i}),h==="monkey"){for(const l of v)o.push({k:"circle",x:l*.32,y:-.04,r:.38,fill:i});o.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:i})}if(h==="heart"){for(const l of v)o.push({k:"circle",x:l*.36,y:.02,r:.5,fill:i});o.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:i})}if(h==="disc")for(const l of v)o.push({k:"circle",x:l*.4,y:.02,r:.44,fill:i});if(h==="cheeks")for(const l of v)o.push({k:"ellipse",x:l*.4,y:.44,rx:.44,ry:.32,fill:i});if(h==="band"&&o.push({k:"path",d:Xt(e,t),fill:i}),n("stripes")){const l=r(0,a.outline);o.push({k:"line",pts:[0,-.97,0,-.66],stroke:l,lw:.13});for(const u of v)o.push({k:"line",pts:[u*.3,-.93,u*.24,-.7],stroke:l,lw:.1}),o.push({k:"line",pts:[u*.98,-.05,u*.74,0],stroke:l,lw:.1}),o.push({k:"line",pts:[u*.94,.22,u*.74,.22],stroke:l,lw:.09})}if(n("spots")){const l=r(1,a.belly);o.push({k:"circle",x:-.55,y:-.5,r:.15,fill:l}),o.push({k:"circle",x:.58,y:-.42,r:.11,fill:l}),o.push({k:"circle",x:.22,y:-.76,r:.09,fill:l})}if(n("forehead")&&o.push({k:"path",d:P(Q(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:r(0,a.accent)}),n("eye-spot")&&o.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:a.ears??a.accent}),n("gills"))for(const l of v)for(const u of[0,.12,.24])o.push({k:"path",d:`M${l*(.66+u)} 0.06 Q${l*(.6+u)} 0.22 ${l*(.66+u)} 0.38`,stroke:a.accent,lw:t*.9});const f=a.hair??a.outline;if(n("hair")&&o.push({k:"path",d:P(Q(-1.02,-.06,-1.02,-.58,-.62,-1.04,.08,-1.14,.76,-.92,1.05,-.42,1,-.06,.84,-.4,.42,-.5,.06,-.4,-.34,-.56,-.74,-.38)),fill:f,...s}),n("locks")&&o.push({k:"path",d:P(Q(-1,-.08,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1,-.08,.8,-.38,.36,-.44,0,-.4,-.36,-.44,-.8,-.38)),fill:f,...s}),n("curls")){for(let l=0;l<7;l++){const u=ie(-1.3+l/6*2.6,.86);o.push({k:"circle",x:u.x,y:u.y,r:.3,fill:f,...s})}o.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:f})}if(n("ninja-hood")&&(o.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:a.skin??N,stroke:a.outline,lw:t*.8}),o.push({k:"path",d:"M-0.98 -0.42 Q0 -0.74 0.98 -0.42 L1.0 -0.62 Q0 -0.94 -1.0 -0.62 Z",fill:a.accent,...s})),n("domino")){o.push({k:"path",d:P(Q(-.86,-.04,-.62,-.3,-.18,-.24,0,-.16,.18,-.24,.62,-.3,.86,-.04,.6,.22,.16,.16,0,.1,-.16,.16,-.6,.22),.9),fill:a.accent,...s});for(const l of v)o.push({k:"ellipse",x:l*.38,y:0,rx:.19,ry:.13,fill:N})}if(o.push(...Vt(e,t)),n("brows"))for(const l of v)o.push({k:"line",pts:[l*.72,-.5,l*.14,-.3],stroke:a.accent,lw:.16});if(e.face.brows)for(const l of v)o.push({k:"line",pts:[l*.2,-.2,l*.54,-.28],stroke:e.face.brows,lw:.09});if(o.push(...Jt(e,t)),e.face.cheeks)for(const l of v)o.push({k:"ellipse",x:l*.64,y:.3,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(n("whiskers"))for(const l of v)for(const u of[-.1,.06])o.push({k:"line",pts:[l*.62,.38+u,l*1.06,.3+u*2.2],stroke:a.outline,lw:t*.7,alpha:.75});if(n("rainbow-mane")){const l=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];o.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:l[0],...s}),o.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:l[1%l.length],...s})}if(e.ears==="unicorn"){const l=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];o.push({k:"path",d:O(l,.12),fill:a.accent,...s});for(const u of[-1,-1.2,-1.4]){const c=.16*((u+1.72)/.88);o.push({k:"line",pts:[-c,u+.04,c,u-.04],stroke:a.outline,lw:t*.7,alpha:.6})}}if(n("helmet")){for(const l of v)o.push({k:"rect",x:l*1,y:.05,w:.26,h:.56,r:.12,fill:a.accent,...s});o.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:N,lw:.1,alpha:.9})}if(n("bolts"))for(const l of v)o.push({k:"rect",x:l*1.08,y:.08,w:.2,h:.44,r:.08,fill:a.accent,...s});if(n("tuft")&&o.push({k:"path",d:P([{x:-.26,y:-.95},{x:-.12,y:-1.22},{x:.02,y:-1.04},{x:.16,y:-1.28},{x:.28,y:-.95},{x:0,y:-.86}]),fill:a.body,...s}),n("eggshell")&&o.push({k:"path",d:"M-0.88 -0.5 C-0.88 -1.12 -0.46 -1.42 0 -1.42 C0.46 -1.42 0.88 -1.12 0.88 -0.5 L0.66 -0.66 L0.44 -0.48 L0.22 -0.66 L0 -0.48 L-0.22 -0.66 L-0.44 -0.48 L-0.66 -0.66 Z",fill:r(0,N),...s}),n("wool"))for(const[l,u]of[[-.36,-.84],[.02,-.94],[.4,-.82]])o.push({k:"circle",x:l,y:u,r:.27,fill:a.body,...s});if(n("stripe")&&o.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:a.accent}),n("eye-patch")&&(o.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:a.outline,lw:.07}),o.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:a.outline})),n("bandana")){o.push({k:"path",d:P(Q(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:a.accent,...s});for(const[l,u]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])o.push({k:"circle",x:l,y:u,r:.06,fill:N,alpha:.85});o.push({k:"circle",x:-.98,y:-.34,r:.15,fill:a.accent,...s})}if(n("cap")){for(const l of v)o.push({k:"line",pts:[l*.98,-.2,l*.5,.82,-l*.05,.98],stroke:a.outline,lw:.06});o.push({k:"path",d:P(Q(-1.1,-.16,-1.04,-.66,-.6,-1.12,0,-1.24,.6,-1.12,1.04,-.66,1.1,-.16,.5,-.4,-.5,-.4)),fill:a.accent,...s}),o.push({k:"path",d:"M-0.74 -0.4 Q0 -0.6 0.74 -0.4 Q0.8 -0.24 0.6 -0.22 Q0 -0.36 -0.6 -0.22 Q-0.8 -0.24 -0.74 -0.4 Z",fill:a.accent,...s}),o.push({k:"circle",x:.5,y:-.82,r:.15,fill:r(0,N),...s});for(const l of[-.42,-.14])o.push({k:"line",pts:[l,-1.04,l+.02,-.78],stroke:a.outline,lw:.07,alpha:.7})}if(n("safari-hat")&&(o.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:a.accent,...s}),o.push({k:"path",d:P(Q(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:a.accent,...s}),o.push({k:"path",d:"M-0.77 -0.72 Q0 -0.62 0.77 -0.72 L0.74 -0.9 Q0 -0.8 -0.74 -0.9 Z",fill:r(1,a.outline),stroke:a.outline,lw:t*.8})),n("wizard-hat")){o.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:a.accent,...s}),o.push({k:"path",d:O(Q(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:a.accent,...s});const l=r(0,Zt);for(const[u,c,x]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])o.push({k:"group",x:u,y:c,s:x,items:[{k:"path",d:ye,fill:l}]})}if(n("dive-mask")){for(const u of v)o.push({k:"line",pts:[u*.7,-.04,u*1,-.12],stroke:a.outline,lw:.2},{k:"line",pts:[u*.7,-.04,u*1,-.12],stroke:a.accent,lw:.11});o.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),o.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:a.outline,lw:.2}),o.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:a.accent,lw:.11}),o.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:N,lw:.06,alpha:.9});const l="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";o.push({k:"path",d:l,stroke:a.outline,lw:.24},{k:"path",d:l,stroke:a.accent,lw:.13})}return o}function Kt(e,t){const a=e.headExtras.includes("ninja-hood")?e.palette.body:e.palette.skin??e.palette.body;switch(e.head){case"round":return{k:"circle",x:0,y:0,r:1,fill:a,...t};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:a,...t};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:a,...t};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:a,...t};case"bucket":return{k:"path",d:O(Q(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:a,...t};case"bulb":return{k:"path",d:P([{x:0,y:-1.02},{x:.86,y:-.74},{x:1.08,y:-.12},{x:.72,y:.62},{x:0,y:.92},{x:-.72,y:.62},{x:-1.08,y:-.12},{x:-.86,y:-.74}]),fill:a,...t}}}function Wt(e){return e.head==="round"?{cy:0,rx:1,ry:1}:e.head==="tall"?{cy:-.02,rx:.94,ry:1.04}:{cy:.03,rx:1.12,ry:.94}}function Xt(e,t){const{cy:a,rx:o,ry:s}=Wt(e),n=o-t/2,r=s-t/2,h=.15,i=Math.asin(Math.min(1,(h-a)/r)),f=Math.cos(i)*n,l=d=>Math.round(d*100)/100||0,u=[L.M,l(-f),h],c=[[-.84*f,.02,-.53*f,.06,-.32*f,.24],[-.17*f,.11,.17*f,.11,.32*f,.24],[.53*f,.06,.84*f,.02,f,h]];for(const d of c)u.push(L.C,...d.map(l));const x=24;for(let d=1;d<=x;d++){const b=i+(Math.PI-2*i)*d/x;u.push(L.L,l(Math.cos(b)*n),l(a+Math.sin(b)*r))}return u.push(L.Z),u}function Gt(e,t){const a=e.palette,o={stroke:a.outline,lw:t},s=[];for(const n of v)switch(e.ears){case"pointy":case"unicorn":{const r=e.ears==="unicorn"?.8:1,h={x:n*.3,y:-.82},i={x:n*.86,y:-.82-.62*r},f={x:n*.94,y:-.36};s.push({k:"path",d:O([h,i,f],.2),fill:a.body,...o});const l={x:(h.x+i.x+f.x)/3,y:(h.y+i.y+f.y)/3},u=[h,i,f].map(c=>({x:l.x+(c.x-l.x)*.55,y:l.y+(c.y-l.y)*.55+.04}));s.push({k:"path",d:O(u,.25),fill:a.accent});break}case"round":s.push({k:"circle",x:n*.72,y:-.72,r:.36,fill:a.ears??a.body,...o}),a.ears||s.push({k:"circle",x:n*.74,y:-.74,r:.19,fill:a.accent});break;case"big-round":s.push({k:"circle",x:n*.96,y:-.46,r:.52,fill:a.body,...o}),s.push({k:"circle",x:n*1,y:-.44,r:.32,fill:a.accent});break;case"long":s.push({k:"ellipse",x:n*.38,y:-1.42,rx:.25,ry:.68,rot:n*.14,fill:a.body,...o}),s.push({k:"ellipse",x:n*.39,y:-1.36,rx:.12,ry:.48,rot:n*.14,fill:a.accent});break;case"side":s.push({k:"circle",x:n*1,y:.02,r:.34,fill:a.body,...o}),s.push({k:"circle",x:n*1.02,y:.02,r:.2,fill:a.belly});break;case"tufts":s.push({k:"path",d:O([{x:n*.3,y:-.84},{x:n*1.22,y:-1.12},{x:n*.92,y:-.42}],.16),fill:a.body,...o}),s.push({k:"line",pts:[n*.62,-.78,n*1,-.98],stroke:a.accent,lw:.08});break;case"antennae":{const r={x:n*.62,y:-1.42};s.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${r.x} ${r.y}`,stroke:a.outline,lw:t*2.6}),s.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${r.x} ${r.y}`,stroke:a.body,lw:t*1.2}),s.push({k:"circle",x:r.x,y:r.y,r:.17,fill:a.accent,...o});break}case"floppy":s.push({k:"ellipse",x:n*.96,y:.02,rx:.3,ry:.62,rot:-n*.36,fill:a.ears??a.body,...o});break;case"droopy":s.push({k:"ellipse",x:n*1.04,y:-.22,rx:.4,ry:.18,rot:n*.32,fill:a.skin??a.body,...o}),s.push({k:"ellipse",x:n*1.08,y:-.2,rx:.24,ry:.08,rot:n*.32,fill:a.accent});break;case"human":s.push({k:"ellipse",x:n*.98,y:.06,rx:.17,ry:.23,fill:a.skin??a.body,...o});break;case"horns":{const r=[{x:n*.3,y:-.84},{x:n*.6,y:-1.5},{x:n*.66,y:-.68}];s.push({k:"path",d:O(r,.18),fill:a.accent,...o});break}}return e.ears==="fin"&&s.push({k:"path",d:O(Q(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:a.body,...o}),e.ears==="antenna"&&(s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:a.outline,lw:t*2.6}),s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:a.limbs,lw:t*1.2}),s.push({k:"circle",x:0,y:-1.5,r:.18,fill:a.accent,...o})),s}function Vt(e,t){const a=e.palette,o=e.face,s=[],n=a.outline,r=o.eyesOnTop?.46:.4,h=o.eyesOnTop?-.72:-.04,i=(f,l,u)=>({k:"circle",x:f,y:l,r:u,fill:N});switch(o.eyes){case"dot":for(const f of v)s.push({k:"ellipse",x:f*r,y:h,rx:.12,ry:.155,fill:n}),s.push(i(f*r+.04,h-.06,.045));break;case"bead":for(const f of v)s.push({k:"ellipse",x:f*r,y:h,rx:.16,ry:.22,fill:n}),s.push(i(f*r+.05,h-.08,.065));break;case"big":for(const f of v)o.eyeRing&&s.push({k:"circle",x:f*r,y:h,r:.36,fill:o.eyeRing,stroke:n,lw:t*.8}),s.push({k:"circle",x:f*r,y:h,r:.25,fill:N,stroke:n,lw:t*.8}),s.push({k:"circle",x:f*r+f*-.03,y:h+.03,r:.14,fill:o.eyeColor??n}),s.push(i(f*r+f*-.03+.05,h-.03,.05));break;case"mask":for(const f of v)s.push({k:"ellipse",x:f*.4,y:0,rx:.24,ry:.32,rot:f*-.55,fill:a.limbs}),s.push({k:"circle",x:f*.4,y:-.02,r:.11,fill:N}),s.push({k:"circle",x:f*.39,y:-0,r:.065,fill:n});break;case"screen":s.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:n,lw:t*.8});for(const f of v)s.push({k:"ellipse",x:f*.36,y:0,rx:.2,ry:.24,fill:o.eyeColor??"#7ff0ff",alpha:.3}),s.push({k:"ellipse",x:f*.36,y:0,rx:.12,ry:.16,fill:o.eyeColor??"#7ff0ff"});break;case"almond":for(const f of v)s.push({k:"ellipse",x:f*.42,y:-.02,rx:.3,ry:.2,rot:-f*.5,fill:o.eyeColor??n}),s.push(i(f*.42-f*.07,-.08,.07));break;case"calm":for(const f of v)s.push({k:"ellipse",x:f*.38,y:.02,rx:.085,ry:.12,fill:n}),s.push(i(f*.38+.03,-.02,.03));break;case"slit":s.push({k:"line",pts:[0,-.98,0,-.2],stroke:n,lw:t*.8,alpha:.5}),s.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:Ee,stroke:n,lw:t*.8}),s.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:Ee,stroke:n,lw:t*.8});for(const f of v){s.push({k:"ellipse",x:f*.4,y:-.04,rx:.12,ry:.07,fill:o.eyeColor??N});for(const l of[.36,.56])s.push({k:"circle",x:f*.42,y:l,r:.05,fill:n,alpha:.6})}break;case"goggle":for(const f of v)s.push({k:"circle",x:f*.9,y:0,r:.13,fill:a.accent,stroke:n,lw:t*.8});s.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:Ee,stroke:n,lw:t*.8}),s.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:N,lw:.07,alpha:.8});for(const f of v)s.push({k:"path",d:`M${f*.5} 0.04 Q${f*.34} -0.08 ${f*.16} 0.02`,stroke:o.eyeColor??"#7fd6ff",lw:.08});for(const f of[-.18,0,.18])s.push({k:"line",pts:[f,.56,f,.72],stroke:n,lw:t*.8,alpha:.6});break;case"visor":s.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:n,lw:t*.8}),s.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:N,lw:.08,alpha:.7});for(const f of v)s.push({k:"ellipse",x:f*.28,y:.04,rx:.1,ry:.14,fill:o.eyeColor??"#cfeeff"});break}return s}function Jt(e,t){const a=e.palette,o=e.face,s=[],n=o.eyes==="visor"?"#cfeeff":Ye,r=t*1.05;switch(o.nose&&o.mouth!=="beak"&&(o.mouth==="cat"?s.push({k:"path",d:O([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:o.nose,stroke:o.nose,lw:t*.6}):e.ears==="big-round"?s.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:o.nose}):s.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:o.nose})),o.mouth){case"smile":s.push({k:"path",d:o.eyes==="visor"?"M-0.16 0.32 Q0 0.46 0.16 0.32":"M-0.17 0.42 Q0 0.58 0.17 0.42",stroke:n,lw:r});break;case"open":s.push({k:"path",d:"M-0.21 0.4 Q0 0.46 0.21 0.4 Q0.19 0.68 0 0.68 Q-0.19 0.68 -0.21 0.4 Z",fill:n,stroke:n,lw:t*.5}),s.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:Yt});break;case"cat":s.push({k:"path",d:"M-0.19 0.4 Q-0.1 0.5 0 0.37 Q0.1 0.5 0.19 0.4",stroke:n,lw:r});break;case"beak":s.push({k:"path",d:O([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:a.accent,stroke:a.outline,lw:t*.8});break;case"teeth":s.push({k:"path",d:"M-0.36 0.34 Q0 0.44 0.36 0.34 Q0.28 0.66 0 0.66 Q-0.28 0.66 -0.36 0.34 Z",fill:n,stroke:n,lw:t*.5});for(const h of v)s.push({k:"rect",x:h*.12,y:.43,w:.1,h:.1,r:.03,fill:N});break;case"grill":s.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:a.outline,lw:t*.7});for(const h of[-.15,0,.15])s.push({k:"line",pts:[h,.51,h,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":s.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:n});break;case"smirk":s.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:n,lw:r});break;case"bill":s.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:a.accent,stroke:a.outline,lw:t*.8}),s.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:a.outline,lw:t*.7});for(const h of v)s.push({k:"circle",x:h*.1,y:.28,r:.03,fill:a.outline});break;case"hook":s.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:Ye}),s.push({k:"path",d:"M-0.3 0.12 Q0 -0.02 0.3 0.12 Q0.36 0.52 0.04 0.76 Q0.08 0.52 -0.08 0.46 Q-0.28 0.38 -0.3 0.12 Z",fill:a.accent,stroke:a.outline,lw:t*.8});break;case"jaws":{s.push({k:"path",d:"M-0.5 0.3 Q0 0.5 0.5 0.3 Q0.38 0.72 0 0.72 Q-0.38 0.72 -0.5 0.3 Z",fill:n,stroke:n,lw:t*.5});for(const h of[-.34,-.17,0,.17,.34]){const i=.3+.4*(h+.5)*(.5-h)-.01;s.push({k:"path",d:O(Q(h-.075,i,h+.075,i,h,i+.13),.15),fill:N})}break}}return s}var ie=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t}),ea=.5,X={leftEye:2,rightEye:5,leftEar:7,rightEar:8},V={"3-5":{head:.75,neck:.74,arm:.3,leg:.36,hand:.19,foot:1.2,shoulderMin:.4,shoulderPad:.07,hipMin:.5,hipPad:.22,bottom:.26,bulge:1.12,armsOverHead:!0},"6-8":{head:.6,neck:.78,arm:.22,leg:.28,hand:.15,foot:1,shoulderMin:.34,shoulderPad:.04,hipMin:.4,hipPad:.16,bottom:.14,bulge:1.04,armsOverHead:!1},"9-12":{head:.5,neck:.92,arm:.17,leg:.21,hand:.125,foot:.9,shoulderMin:.36,shoulderPad:.07,hipMin:.32,hipPad:.08,bottom:.1,bulge:1,armsOverHead:!1}},be="6-8",Ke=e=>e.band in V?e.band:be,ja=V[be].head,ta=.3,aa=.12,oa=.9,We=.5,Xe=.65,sa=.35,na=.2,ra=.25,Z=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),q=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),I=(e,t)=>({x:e.x*t,y:e.y*t}),J=e=>Math.hypot(e.x,e.y),Ge=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Me=e=>{const t=J(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},la=(...e)=>e.every(Number.isFinite),ia=e=>Math.atan2(Math.sin(e),Math.cos(e)),ca=(e,t,a)=>Math.min(Math.max(e,t),a);function Ve(e,t,a=!1){return o=>{const s=e[o*3],n=e[o*3+1],r=e[o*3+2];return s===void 0||n===void 0||r===void 0||!la(s,n,r)?{x:0,y:0,ok:!1}:{x:t.x+(a?1-s:s)*t.w,y:t.y+n*t.h,ok:r>=ea}}}function Ae(e,t,a={}){const o=Ve(e,t,a.mirrored),s=o(T.leftShoulder),n=o(T.rightShoulder);if(!s.ok||!n.ok)return null;const r=o(T.leftHip),h=o(T.rightHip),i=Ge(s,n),f=J(Z(n,s)),l=r.ok&&h.ok;let u=Me(Z(n,s));f<1e-6&&(u={x:1,y:0});let c,x,d;if(l){const ee=Ge(r,h);x=J(Z(ee,i)),x>=f*ra?c=Me(Z(ee,i)):(c={x:-u.y,y:u.x},c.y<0&&(c=I(c,-1))),d=Math.max(x,f*1.15)}else c={x:-u.y,y:u.x},c.y<0&&(c=I(c,-1)),d=f*1.15,x=d;d=Math.max(d,1e-6);const b={x:c.y,y:-c.x},y=Math.atan2(b.y,b.x),k=I(c,-1),g=V[a.band??be]??V[be],z=g.head*d;let U=q(i,I(k,z*g.neck));const ce=o(T.nose);if(ce.ok){const ee=q(ce,I(k,z*.15)),fe=I(Z(ee,U),sa),Se=Math.min(1,z*na/Math.max(J(fe),1e-6));U=q(U,I(fe,Se))}return{S:i,r:b,d:c,U:d,L:x,hipsOk:l,head:U,headR:z,headRot:y+fa(e,o,y,d),angle:y}}function fa(e,t,a,o){const s=[[X.leftEar,X.rightEar],[X.leftEye,X.rightEye]];for(const[n,r]of s){const h=t(n),i=t(r);if(!h.ok||!i.ok||!(e[n*3+2]>=Xe&&e[r*3+2]>=Xe)||J(Z(i,h))<o*.05)continue;const f=ia(Math.atan2(i.y-h.y,i.x-h.x)-a),l=Math.max(Math.abs(f)-aa,0),u=ca((oa+We-Math.abs(f))/We,0,1);return Math.sign(f)*Math.min(l,ta)*u}return 0}function Ce(e,t,a,o={}){const s=Ke(t),n=V[s],r=Ae(e,a,{...o,band:s});if(!r)return[];const h=Ve(e,a,o.mirrored),i=t.palette,{S:f,r:l,d:u,U:c,L:x}=r,d=p=>t.bodyExtras.includes(p),b=Math.max(1.2,c*.045),y={stroke:i.outline,lw:b},k=(p,m)=>({x:f.x+l.x*p+u.x*m,y:f.y+l.y*p+u.y*m}),g=p=>p.map(([m,w])=>k(m,w)),z=h(T.leftShoulder),U=h(T.rightShoulder),ce=h(T.leftHip),ee=h(T.rightHip),fe=J(Z(U,z)),Se=r.hipsOk?J(Z(ee,ce)):fe*.7,M=Math.max(fe/2+n.shoulderPad*c,n.shoulderMin*c),_=Math.max(Se/2+n.hipPad*c,n.hipMin*c),F=-.1*c,ae=x+n.bottom*c,K=[],xe=[],C=[],me=[],ht=[],ut=(p,m,w,S)=>{const E=m.flatMap(H=>[H.x,H.y]);p.push({k:"line",pts:E,stroke:i.outline,lw:w+b*2}),p.push({k:"line",pts:E,stroke:S,lw:w})},Qa=n.leg*c,Ba=n.arm*c,dt=Math.max(n.arm/.22,.9);if(r.hipsOk)for(const[p,m,w,S]of[[ce,T.leftKnee,T.leftAnkle,-1],[ee,T.rightKnee,T.rightAnkle,1]]){const E=h(m),H=h(w);if(!E.ok)continue;const Te=q(p,I(u,-.12*c)),oe=H.ok?[Te,E,H]:[Te,E];ut(xe,oe,Qa,i.limbs),d("joints")&&xe.push({k:"circle",x:E.x,y:E.y,r:.15*c*dt,fill:i.accent,...y}),H.ok&&xe.push(da(t,H,r,S,b,n.foot))}for(const[p,m,w,S]of[[z,T.leftElbow,T.leftWrist,-1],[U,T.rightElbow,T.rightWrist,1]]){const E=h(m),H=h(w);if(d("pauldrons")){const se=q(p,I(u,.02*c));me.push({k:"ellipse",x:se.x,y:se.y,rx:.25*c,ry:.17*c,rot:r.angle+S*.25,fill:i.body,...y});const ue=q(se,I(u,.05*c));me.push({k:"ellipse",x:ue.x,y:ue.y,rx:.17*c,ry:.07*c,rot:r.angle+S*.25,fill:i.belly})}if(!E.ok)continue;const oe=n.armsOverHead&&(E.x-f.x)*u.x+(E.y-f.y)*u.y<-.25*c?ht:me,pt=q(p,I(u,.04*c));if(ut(oe,H.ok?[pt,E,H]:[pt,E],Ba,i.limbs),d("joints")&&oe.push({k:"circle",x:E.x,y:E.y,r:.13*c*dt,fill:i.accent,...y}),!H.ok)continue;const he=Me(Z(H,E)),ze=q(H,I(he,.05*c));if(d("feathers"))for(const se of[-.55,0,.55]){const ue=Math.cos(se),yt=Math.sin(se)*S,Pe={x:he.x*ue-he.y*yt,y:he.x*yt+he.y*ue},bt=q(ze,I(Pe,.16*c));oe.push({k:"ellipse",x:bt.x,y:bt.y,rx:.2*c,ry:.09*c,rot:Math.atan2(Pe.y,Pe.x),fill:i.hands??i.accent,...y})}oe.push({k:"circle",x:ze.x,y:ze.y,r:n.hand*c,fill:i.hands??i.limbs,...y})}if(d("wings"))for(const p of[-1,1]){const m=g([[p*M*.5,.05*c],[p*(M+.85*c),-.6*c],[p*(M+.72*c),.05*c],[p*(M+.45*c),-.02*c],[p*(M+.3*c),.32*c],[p*M*.6,.55*c]]);K.push({k:"path",d:O(m,.18),fill:i.accent,...y})}if(d("cape")){const p=x+.8*c,m=_+.36*c,w=g([[-M*.92,F+.04*c],[M*.92,F+.04*c],[M+.16*c,x*.5],[m,p],[m*.5,p-.1*c],[0,p],[-m*.5,p-.1*c],[-m,p],[-M-.16*c,x*.5]]);K.push({k:"path",d:P(w,.6),fill:i.accent,...y})}if(d("backpack")){const p=k(0,.35*c);K.push({k:"rect",x:p.x,y:p.y,w:M*2+.34*c,h:.8*c,r:.16*c,rot:r.angle,fill:t.extraColors?.[0]??i.limbs,...y})}if(d("tank")){const p=k(M*.95,.24*c),m=t.extraColors?.[0]??i.accent,w=k(M*.95,-.3*c);K.push({k:"rect",x:w.x,y:w.y,w:.14*c,h:.16*c,r:.04*c,rot:r.angle,fill:i.outline}),K.push({k:"rect",x:p.x,y:p.y,w:.34*c,h:1*c,r:.17*c,rot:r.angle,fill:m,...y})}if(r.hipsOk&&!o.portrait&&K.push(...pa(t,r,_,b)),d("tentacles")&&r.hipsOk)for(const p of[-1,1]){const m=g([[p*_*.7,x*.9],[p*(_+.22*c),x+.3*c],[p*(_+.48*c),x+.22*c],[p*(_+.5*c),x-.02*c],[p*(_+.34*c),x-.06*c]]);K.push({k:"path",d:le(m),stroke:i.outline,lw:.2*c+b*2}),K.push({k:"path",d:le(m),stroke:i.limbs,lw:.2*c})}const W=Math.max(M,_)*n.bulge;if(d("wool")){for(const[m,w]of[[M*.7,F+.02*c],[W,x*.3],[W*1.02,x*.62],[(W+_)/2,x*.92],[_*.55,ae]])for(const S of[-1,1]){const E=k(S*m,w);C.push({k:"circle",x:E.x,y:E.y,r:.2*c,fill:i.body,...y})}const p=k(0,ae+.02*c);C.push({k:"circle",x:p.x,y:p.y,r:.2*c,fill:i.body,...y})}if(d("robe")){const p=x+.58*c,m=_*1.4;C.push({k:"path",d:P(g([[-M,F],[0,F-.04*c],[M,F],[W,x*.55],[m,p],[0,p+.06*c],[-m,p],[-W,x*.55]]),.7),fill:i.body,...y});const w=g([[-m*.94,p-.1*c],[0,p-.04*c],[m*.94,p-.1*c]]);C.push({k:"path",d:le(w),stroke:t.extraColors?.[0]??i.accent,lw:.07*c})}else if(d("sheet")){const p=x+.78*c,m=_*1.3;C.push({k:"path",d:P(g([[-M,F],[M,F],[W,x*.55],[m,p],[m*.5,p-.2*c],[0,p],[-m*.5,p-.2*c],[-m,p],[-W,x*.55]]),.9),fill:i.body,...y})}else C.push({k:"path",d:P(g([[-M,F],[0,F-.04*c],[M,F],[W,x*.55],[_,ae],[0,ae+.03*c],[-_,ae],[-W,x*.55]]),.85),fill:i.body,...y});const Y=Math.min(M,_);if(d("pocket")){const p=k(0,x*.74);C.push({k:"rect",x:p.x,y:p.y,w:Y*1.3,h:.3*c,r:.1*c,rot:r.angle,fill:i.belly,stroke:i.outline,lw:b*.8})}else if(d("racing-stripe"))for(const p of[-.1,.1]){const m=k(p*c,F+.02*c),w=k(p*c,ae-.04*c);C.push({k:"line",pts:[m.x,m.y,w.x,w.y],stroke:i.belly,lw:.1*c})}else if(i.belly&&i.belly!==i.body&&!d("panel")&&!d("sheet")&&!d("stripes")){const p=k(0,x*.58);C.push({k:"ellipse",x:p.x,y:p.y,rx:Y*.64,ry:Math.max(x*.36,.2*c),rot:r.angle,fill:i.belly})}if(d("spots")){const p=t.extraColors?.[1]??i.belly;for(const[m,w,S]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){const E=k(m*Y,w*x);C.push({k:"circle",x:E.x,y:E.y,r:S*c,fill:p})}}if(d("stripes")){const p=t.extraColors?.[1]??i.accent;for(const m of[.22,.44,.66]){const w=k(-Y*.98,x*m),S=k(Y*.98,x*m);C.push({k:"line",pts:[w.x,w.y,S.x,S.y],stroke:p,lw:.1*c})}}if(d("straps")){const p=t.extraColors?.[1]??i.outline;for(const m of[-1,1]){const w=k(m*M*.62,F+.02*c),S=k(m*Y*.62,x*.72);C.push({k:"line",pts:[w.x,w.y,S.x,S.y],stroke:i.outline,lw:.13*c+b*2}),C.push({k:"line",pts:[w.x,w.y,S.x,S.y],stroke:p,lw:.13*c})}}if(d("belt")){const p=k(0,x*.9);C.push({k:"rect",x:p.x,y:p.y,w:_*1.92,h:.17*c,r:.06*c,rot:r.angle,fill:t.extraColors?.[2]??"#4a3426",...y}),C.push({k:"rect",x:p.x,y:p.y,w:.2*c,h:.19*c,r:.04*c,rot:r.angle,fill:"#ffd84a",...y})}if(d("emblem")){const p=k(0,x*.4),m=t.extraColors?.[0]??i.accent,w=O([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);C.push({k:"group",x:p.x,y:p.y,rot:r.angle,s:c,items:[{k:"path",d:w,fill:m,stroke:i.outline,lw:b/c},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ye,fill:m===i.accent?"#ffffff":i.accent}]}]})}if(d("panel")){const p=k(0,x*.5);C.push({k:"rect",x:p.x,y:p.y,w:Y*1.2,h:.38*c,r:.1*c,rot:r.angle,fill:"#24323d",...y}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,S)=>{const E=k((S-1)*Y*.34,x*.5);C.push({k:"circle",x:E.x,y:E.y,r:.075*c,fill:w})})}if(d("badge")){const p=k(-Y*.42,x*.36);C.push({k:"circle",x:p.x,y:p.y,r:.15*c,fill:i.accent,...y}),C.push({k:"group",x:p.x,y:p.y,rot:r.angle,s:.09*c,items:[{k:"path",d:ye,fill:"#ffffff"}]})}if(d("star")){const p=k(-Y*.5,x*.3),m=.15*c;C.push({k:"group",x:p.x,y:p.y,rot:r.angle-.2,s:m,items:[{k:"path",d:ye,fill:t.extraColors?.[0]??"#ffd84a",stroke:i.outline,lw:b*.8/m}]})}if(d("scarf")){const p=Math.max(.04,n.head*(1-n.neck)-.06)*c,m=k(0,p),w=t.extraColors?.[0]??i.accent,S=k(M*.45,p+.28*c);C.push({k:"rect",x:S.x,y:S.y,w:.16*c,h:.42*c,r:.06*c,rot:r.angle+.15,fill:w,...y}),C.push({k:"rect",x:m.x,y:m.y,w:M*2.05,h:.2*c,r:.1*c,rot:r.angle,fill:w,...y})}const Fa={k:"group",x:r.head.x,y:r.head.y,rot:r.headRot,s:r.headR,items:ua(t,b/r.headR)};return[...K,...xe,...C,...me,Fa,...ht]}var Je=new WeakMap,ha=64;function ua(e,t){const a=Number(t.toPrecision(4));let o=Je.get(e);o||Je.set(e,o=new Map);let s=o.get(a);return s||(o.size>=ha&&o.clear(),o.set(a,s=Ze(e,a))),s}function da(e,t,a,o,s,n){const r=e.palette,{d:h,r:i}=a,f=a.U*n,l=q(q(t,I(h,.07*f)),I(i,o*.06*f)),u={stroke:r.outline,lw:s},c=r.feet??r.limbs;if(e.bodyExtras.includes("fins")){const x=O([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:l.x,y:l.y,rot:a.angle,s:f,items:[{k:"path",d:x,fill:c,stroke:r.outline,lw:s/f},{k:"line",pts:[0,.06,0,.38],stroke:r.outline,lw:s/f,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:l.x,y:l.y,rx:.27*f,ry:.11*f,rot:a.angle,fill:c,...u}:e.bodyExtras.includes("boots")?{k:"rect",x:l.x,y:l.y,w:.4*f,h:.24*f,r:.09*f,rot:a.angle,fill:c,...u}:{k:"ellipse",x:l.x,y:l.y,rx:.2*f,ry:.13*f,rot:a.angle,fill:c,...u}}function pa(e,t,a,o){const s=e.palette,{U:n,L:r,S:h,r:i,d:f}=t,l=(b,y)=>({x:h.x+i.x*b+f.x*y,y:h.y+i.y*b+f.y*y}),u=b=>b.map(([y,k])=>l(y,k)),c={stroke:s.outline,lw:o},x=(b,y,k)=>[{k:"path",d:le(b),stroke:s.outline,lw:y+o*2},{k:"path",d:le(b),stroke:k,lw:y}],d=[];switch(e.tail){case"none":break;case"fluffy":{const b=u([[a*.5,r*.95],[a+.28*n,r*1],[a+.72*n,r*.62],[a+.78*n,r*.12],[a+.52*n,r*.32],[a+.3*n,r*.6],[a*.6,r*.7]]);d.push({k:"path",d:P(b),fill:s.body,...c});const y=l(a+.72*n,r*.2);d.push({k:"ellipse",x:y.x,y:y.y,rx:.13*n,ry:.2*n,rot:t.angle+.25,fill:s.belly,...c});break}case"brush":{const b=u([[a*.4,r*.98],[a+.42*n,r*1.06],[a+.98*n,r*.66],[a+1.06*n,r*.12],[a+.86*n,-.04*n],[a+.66*n,r*.36],[a+.3*n,r*.66],[a*.5,r*.68]]);d.push({k:"path",d:P(b),fill:s.body,...c});const y=u([[a+1.03*n,r*.36],[a+1.06*n,r*.12],[a+.86*n,-.04*n],[a+.72*n,r*.24],[a+.86*n,r*.34]]);d.push({k:"path",d:P(y),fill:s.belly,...c});break}case"pom":{const b=l(a+.06*n,r*.88);d.push({k:"circle",x:b.x,y:b.y,r:.2*n,fill:s.belly,...c});break}case"long":case"striped":case"tuft":{const b=u([[a*.6,r*.9],[a+.35*n,r*.85],[a+.58*n,r*.4],[a+.5*n,-.02*n]]);if(d.push(...x(b,.14*n,s.body)),e.tail==="tuft"){const y=b[b.length-1];d.push({k:"circle",x:y.x,y:y.y,r:.16*n,fill:e.extraColors?.[0]??s.accent,...c})}if(e.tail==="striped"){for(const k of[.35,.6,.85]){const g=l(a+.35*n+.22999999999999998*n*(k*1.4>1?1:k*1.4),r*(.85-.85*k));d.push({k:"line",pts:[g.x-i.x*.08*n,g.y-i.y*.08*n,g.x+i.x*.08*n,g.y+i.y*.08*n],stroke:e.extraColors?.[0]??s.outline,lw:.06*n})}const y=b[b.length-1];d.push({k:"circle",x:y.x,y:y.y,r:.07*n,fill:e.extraColors?.[0]??s.outline})}break}case"curl":{const b=u([[a*.6,r*.9],[a+.4*n,r*.88],[a+.62*n,r*.45],[a+.5*n,r*.12],[a+.3*n,r*.24],[a+.36*n,r*.42]]);d.push(...x(b,.12*n,s.limbs));break}case"fish":{const b=u([[a*.6,r*.9],[a+.36*n,r*.86],[a+.6*n,r*.5]]);d.push(...x(b,.17*n,s.body));const y=b[b.length-1],k=O([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);d.push({k:"group",x:y.x,y:y.y,rot:t.angle+.35,s:n,items:[{k:"path",d:k,fill:s.body,stroke:s.outline,lw:o/n}]});break}case"plume":{const b=e.extraColors??[s.accent];[0,1,2].forEach(y=>{const k=l(a+(.12+y*.13)*n,r+(.32-y*.06)*n);d.push({k:"ellipse",x:k.x,y:k.y,rx:.11*n,ry:.44*n,rot:t.angle-.55+y*.28,fill:b[(y+1)%b.length],...c})});break}case"spiky":case"arrow":{const b=u([[a*.3,r*.55],[a+.35*n,r*.68],[a+.95*n,r*.86],[a+.35*n,r*1.08],[a*.3,r*1.08]]);if(e.tail==="spiky"){for(const y of[.15,.45,.72]){const k=a+(.2+y*.7)*n,g=r*(.66+y*.19);d.push({k:"path",d:O(u([[k-.12*n,g+.05*n],[k,g-.2*n],[k+.12*n,g+.07*n]]),.2),fill:s.accent,...c})}d.push({k:"path",d:P(b,.7),fill:s.body,...c})}else{const y=u([[a*.6,r*.9],[a+.4*n,r*.92],[a+.62*n,r*.5],[a+.62*n,r*.18]]);d.push(...x(y,.13*n,s.body));const k=y[y.length-1];d.push({k:"group",x:k.x,y:k.y,rot:t.angle,s:n,items:[{k:"path",d:O([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:s.accent,stroke:s.outline,lw:o/n}]})}break}}return d}var ya={nose:[0,-.62],leftShoulder:[-.42,0],rightShoulder:[.42,0],leftElbow:[-.58,.5],rightElbow:[.58,.5],leftWrist:[-.66,.98],rightWrist:[.66,.98],leftHip:[-.27,1],rightHip:[.27,1],leftKnee:[-.31,1.6],rightKnee:[.31,1.6],leftAnkle:[-.33,2.18],rightAnkle:[.33,2.18]};function ba(e,{cx:t=.5,cy:a=.36,T:o=.18}={}){const s={...ya,...e},n=new Array(Ie*3).fill(0),r=(f,[l,u],c=.99)=>{n[f*3]=t+l*o,n[f*3+1]=a+u*o,n[f*3+2]=c};for(const f of Object.keys(T))r(T[f],s[f]);const h=s.tilt??0,i=(f,l)=>[s.nose[0]+f*Math.cos(h)-l*Math.sin(h),s.nose[1]+f*Math.sin(h)+l*Math.cos(h)];return r(X.leftEye,i(-.1,-.08)),r(X.rightEye,i(.1,-.08)),r(X.leftEar,i(-.22,-.02)),r(X.rightEar,i(.22,-.02)),n}var ka=()=>ba({}),et=.5,xa=.15,ma=class{constructor(e={}){D(this,"tracks",new Map),D(this,"offset",NaN),D(this,"lastArrival",NaN),D(this,"interval",33),D(this,"lastT",NaN),D(this,"lostMs"),D(this,"maxExtrapolateMs"),this.lostMs=e.lostMs??250,this.maxExtrapolateMs=e.maxExtrapolateMs??25}get delayMs(){return this.interval}push(e,t,a,o=tt()){Number.isFinite(t)||(t=o),this.clock(t,o);const s=this.tracks.get(e);if(!s||t-s.tb>this.lostMs||t<s.tb-this.lostMs||a.length!==s.b.length){this.tracks.set(e,{a:null,ta:t,b:a,tb:t,out:null,outAt:NaN});return}if(a===s.b||t<=s.tb){t===s.tb&&a!==s.b&&(s.b=a,s.out=null);return}s.a=s.b,s.ta=s.tb,s.b=a,s.tb=t,s.out=null}at(e,t=tt()){const a=this.tracks.get(e);if(!a)return null;if(!a.a)return a.b;if(a.out&&a.outAt===t)return a.out;const o=t-this.offset-this.interval,s=a.tb-a.ta,n=Math.min(s*.5,this.maxExtrapolateMs),r=Math.min(Math.max((o-a.ta)/s,0),1+n/s);return a.out=wa(a.a,a.b,r),a.outAt=t,a.out}forget(e){this.tracks.delete(e)}clear(){this.tracks.clear()}clock(e,t){const a=t-e;if(!Number.isFinite(this.offset)||a<this.offset||a>this.offset+1e3?this.offset=a:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(a-this.offset,(t-this.lastArrival)/1e3)),this.lastArrival=t,Number.isFinite(this.lastT)&&e>this.lastT){const o=e-this.lastT;o<this.interval*3+20&&(this.interval+=(Math.min(Math.max(o,8),100)-this.interval)*.1)}e<=this.lastT||(this.lastT=e)}},tt=()=>globalThis.performance?.now()??Date.now();function wa(e,t,a){const o=t.slice(),s=a<.5?e:t;for(let n=0;n+2<t.length;n+=3){const r=e[n],h=e[n+1],i=t[n],f=t[n+1];e[n+2]>=et&&t[n+2]>=et&&Math.abs(i-r)+Math.abs(f-h)<xa?(o[n]=r+(i-r)*a,o[n+1]=h+(f-h)*a,o[n+2]=e[n+2]+(t[n+2]-e[n+2])*Math.min(a,1)):(o[n]=s[n],o[n+1]=s[n+1],o[n+2]=s[n+2])}return o}var Ua=$e.map(e=>e.id),ke=new Map($e.map(e=>[e.id,e])),at=ke.get("fox"),ga=e=>typeof e=="string"&&ke.has(e),va=e=>ke.get(e),ot=e=>typeof e=="string"?ke.get(e)??at:e;function Ea(e,t,a,o,s={}){const n=Ce(t,ot(a),o,{mirrored:s.mirrored});return n.length?(e.save(),s.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(s.alpha,0),1)),ve(e,n),e.restore(),!0):!1}function Ma(e,t){const a=ot(e),o=ka(),s=Ke(a),n=Ae(o,{x:0,y:0,w:1,h:1},{band:s}),r=-st(Ze(a,.05)).minY,i=Math.min(.27,.43/Math.max(r,1))*t/V[s].head/n.U,f=.5*t+Math.min(0,(r-1.6)*.06*t),l={x:t/2-n.head.x*i,y:f-n.head.y*i,w:i,h:i};return Ce(o,a,l,{portrait:!0})}function Aa(e,t,a=.5){if(!e||e.length!==t.length)return t.slice();const o=t.slice();for(let s=0;s+2<t.length;s+=3){const n=e[s+2],r=t[s+2],h=n>=.5,i=r>=.5;h&&r>=.3&&(o[s+2]=Math.max(r,.5)),h&&i&&Math.hypot(t[s]-e[s],t[s+1]-e[s+1])<.15?(o[s]=e[s]+(t[s]-e[s])*a,o[s+1]=e[s+1]+(t[s+1]-e[s+1])*a):h&&!i&&o[s+2]>=.5&&(o[s]=e[s],o[s+1]=e[s+1])}return Ta(e,t,o,a*Ca),o}var Ca=.35,Sa=11;function Ta(e,t,a,o){const s=T.leftShoulder*3,n=T.rightShoulder*3,r=(u,c)=>u[c+2]>=.5;if(!r(e,s)||!r(e,n)||!r(t,s)||!r(t,n))return;const h=(u,c)=>(u[s+c]+u[n+c])/2,i=[h(e,0),h(e,1)],f=[h(t,0),h(t,1)],l=[h(a,0),h(a,1)];for(let u=0;u<Sa&&u*3+2<t.length;u++){const c=u*3;if(!r(e,c)||!r(t,c))continue;const x=[e[c]-i[0],e[c+1]-i[1]],d=[t[c]-f[0],t[c+1]-f[1]];Math.hypot(d[0]-x[0],d[1]-x[1])>=.15||(a[c]=l[0]+x[0]+(d[0]-x[0])*o,a[c+1]=l[1]+x[1]+(d[1]-x[1])*o)}}function st(e){const t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=(o,s)=>{t.minX=Math.min(t.minX,o),t.minY=Math.min(t.minY,s),t.maxX=Math.max(t.maxX,o),t.maxY=Math.max(t.maxY,s)};for(const o of e){const s="lw"in o&&o.stroke?(o.lw??1)/2:0;switch(o.k){case"circle":a(o.x-o.r-s,o.y-o.r-s),a(o.x+o.r+s,o.y+o.r+s);break;case"ellipse":case"rect":{const n=o.k==="ellipse"?o.rx:o.w/2,r=o.k==="ellipse"?o.ry:o.h/2,h=Math.max(n,r)+s;a(o.x-h,o.y-h),a(o.x+h,o.y+h);break}case"path":{const n=$t(o.d);for(let r=0;r+1<n.length;r+=2)a(n[r]-s,n[r+1]-s),a(n[r]+s,n[r+1]+s);break}case"line":for(let n=0;n+1<o.pts.length;n+=2)a(o.pts[n]-s,o.pts[n+1]-s),a(o.pts[n]+s,o.pts[n+1]+s);break;case"group":{const n=st(o.items);if(!Number.isFinite(n.minX))break;const r=o.s??1,h=Math.cos(o.rot??0),i=Math.sin(o.rot??0);for(const[f,l]of[[n.minX,n.minY],[n.maxX,n.minY],[n.minX,n.maxY],[n.maxX,n.maxY]])a(o.x+(f*h-l*i)*r,o.y+(f*i+l*h)*r);break}}}return t}var za=()=>{const e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},nt=()=>globalThis.performance?.now()??Date.now(),rt=class{constructor(e=za){D(this,"now",e),D(this,"known",new Map),D(this,"smoothed",new Map),D(this,"times",new WeakMap),D(this,"lerp",new ma),D(this,"drawnAt",NaN),D(this,"drawn",0),D(this,"smoothedBody",(t,a={})=>{const o=a.interpolate!==!1;if(typeof t=="number"){const s=this.smoothed.get(t);return s?o?this.lerp.at(t,this.tick())??s.body:s.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,lt(a.smooth),o)})}note(e,t,a=nt()){for(const o of e)this.known.set(o.id,this.resolve(o.id,o.avatar)),t!==void 0&&Number.isFinite(t)&&Array.isArray(o.body)&&this.times.set(o.body,{t,arrival:a})}of(e){return typeof e=="object"&&e!==null?e.avatar!==void 0?this.resolve(e.id,e.avatar):this.of(e.id):this.known.get(e)??Qe(e-1)}posed(e,t,a,o=!0){const s=this.smooth(e,t,a);return o?this.lerp.at(e,this.tick())??s:s}smooth(e,t,a){const o=this.smoothed.get(e);if(o&&o.raw===t&&o.amount===a)return o.body;o&&o.amount!==a&&this.lerp.forget(e);const s=a<1?Aa(o?.body,t,a):t;this.smoothed.set(e,{raw:t,body:s,amount:a});const n=this.times.get(t),r=n?.arrival??nt();return this.lerp.push(e,n?.t??r,s,r),s}takeDrawn(){const e=this.drawn;return this.drawn=0,e}tick(){const e=this.now();return e!==this.drawnAt&&(this.drawnAt=e,this.drawn++),e}resolve(e,t){return ga(t)?t:Qe(e-1)}};function Pa(e,t){const a=typeof e.getTransform=="function"?e.getTransform():null,o=a&&Math.hypot(a.a,a.b)||1,s=a&&Math.hypot(a.c,a.d)||1,n=(e.canvas?.width??0)/o,r=(e.canvas?.height??0)/s;return t?{x:t.x*n,y:t.y*r,w:t.w*n,h:t.h*r}:{x:0,y:0,w:n,h:r}}var lt=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function it(e,t){return(a,o,s,n,r={})=>{const h=Array.isArray(o)?null:o,i=h?h.body:o;if(!Array.isArray(i))return null;const f=typeof s=="string"?s:e.of(typeof s=="number"?s:h??1),l=typeof s=="number"?s:h?.id,u=l!==void 0?e.posed(l,i,lt(r.smooth),r.interpolate!==!1):i;return Ea(a,u,f,n??Pa(a,t().view),r.alpha!==void 0?{alpha:r.alpha}:{})?u:null}}function Oa(e){const t=new Map,a=(i,f)=>t.get(i)?.forEach(l=>l(f));let o=null;const s=[],n=i=>o?i(o):s.push(i),r=new rt,h=it(r,()=>({view:null}));return e.then(i=>{o=i;const f=new Map;i.on("gesture",l=>a(l.gesture,{player:l.player})),i.on("pause",l=>a("pause",{reason:l.reason==="distance"?"distance":"user"})),i.on("resume",()=>a("resume",{})),i.on("break-start",()=>a("break-start",{})),i.on("break-done",l=>a("break-end",{shown:l.shown})),i.onBackdrop((l,u)=>a("backdrop",{backdrop:l,view:u})),i.on("frame",l=>{a("players",{players:l.players});for(const u of l.players)a("hands",{player:u.id,left:u.leftHand,right:u.rightHand}),f.get(u.id)!==u.shape&&(f.set(u.id,u.shape),a("shape",{player:u.id,shape:u.shape}))}),a("start",ct(i)),s.splice(0).forEach(l=>l(i))}),{on(i,f){const l=t.get(i)??new Set;return t.set(i,l),l.add(f),i==="start"&&o&&f(ct(o)),()=>{l.delete(f)}},ready:()=>n(i=>i.ready()),score:(i,f=1)=>n(l=>l.score(f,i)),break:i=>new Promise(f=>n(l=>{l.break(i).then(f)})),end:i=>n(f=>f.end(typeof i=="number"?[{player:1,score:i,stars:2}]:i.map(l=>({player:l.player,score:l.score,stars:l.stars??2})))),keys:(i,f)=>n(l=>{zt(l,i,f)}),pointer:i=>n(f=>{Ot(f,i)}),get view(){return o?.view??null},get device(){return o?.device??null},reportStats:i=>o?.reportStats(i),toScreen:i=>o?o.toScreen(i):He(null,i),avatarOf:i=>o?o.avatarOf(i):r.of(i),drawAvatar:(...i)=>o?o.drawAvatar(...i):h(...i),smoothedBody:(...i)=>o?o.smoothedBody(...i):r.smoothedBody(...i)}}var ct=e=>({ageRange:e.ageRange,players:e.players,locale:e.locale,mode:e.mode,backdrop:e.backdrop,view:e.view,device:e.device}),La=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",a=>a.source===e.parent&&t(a.data))}),_a=1e4,Da=1e3;function Na(e=La()){return new Promise((t,a)=>{const o=new Map,s=[];let n=!1,r="none",h=null;const i=new Set,f=new rt,l=it(f,()=>({view:h})),u=f.smoothedBody,c=setTimeout(()=>a(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),_a);e.listen(x=>{if(typeof x!="object"||x===null||x.ns!==Be)return;const d=x;if(d.type==="init"&&!n){if(d.v!==Ne)return clearTimeout(c),a(new Error(`Fabi Play: protocol ${d.v}, this SDK speaks ${Ne}`));n=!0,clearTimeout(c),r=d.backdrop==="video"?"video":"none",h=Fe(d.view)??null;const b=It(d.device)??null;let y={};if(d.stats===!0){let k=performance.now();setInterval(()=>{const z=performance.now();e.post(ne({type:"stats",renderFps:Math.round(f.takeDrawn()*1e3/Math.max(z-k,1)),...y})),k=z},Da).unref?.()}t({locale:d.locale,mode:d.mode,players:d.players,muted:d.muted,ageRange:d.ageRange??"6-8",get backdrop(){return r},get view(){return h},device:b,reportStats:k=>{y=Rt(k)},toScreen:k=>He(h,k),avatarOf:k=>f.of(k),drawAvatar:l,smoothedBody:u,onBackdrop(k){return i.add(k),()=>{i.delete(k)}},on(k,g){const z=o.get(k)??new Set;return o.set(k,z),z.add(g),()=>{z.delete(g)}},ready:()=>e.post(ne({type:"ready"})),score:(k,g)=>e.post(ne({type:"score",player:k,score:g})),break:(k="level")=>new Promise(g=>{s.push(g),e.post(ne({type:"break",reason:k}))}),end:k=>e.post(ne({type:"end",scores:k}))})}else if(n){let b=d;if(d.type==="frame"&&Array.isArray(d.players)&&f.note(d.players,d.t),d.type==="backdrop"){if(d.backdrop!=="video"&&d.backdrop!=="none")return;const y=Fe(d.view)??null;if(d.backdrop===r&&Ia(y,h))return;r=d.backdrop,h=y,b={type:"backdrop",backdrop:r,...h?{view:h}:{}};for(const k of[...i])k(r,h)}for(const y of o.get(d.type)??[])y(b);d.type==="break-done"&&s.shift()?.(d.shown)}else return})})}var Ia=(e,t)=>e===t||e!==null&&t!==null&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,ft={};Oe(ft,{BAND_BODY:()=>V,DEFAULT_AVATAR:()=>at,avatarById:()=>va,avatarShapes:()=>Ce,drawShapes:()=>ve,frameOf:()=>Ae,iconShapes:()=>Ma});function Ra(e){const t=Na(),a=Oa(t);e?.dataset.mute!=="manual"&&Et(t);const o=Object.assign(a,{avatars:{...ft}});window.FabiPlay=o;const s=e?.dataset.keys;s&&a.keys(At(s));const n=e?.dataset.pointer;return n&&a.pointer({hand:n==="left"||n==="right"?n:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?a.ready():window.addEventListener("load",()=>a.ready(),{once:!0})),o}return G.exports.install(we)});
1
+ /*! @fabi-play/sdk 0.3.0 | Fabi Play Kit License | https://docs.fabiplay.app */(function(we,te){var pe=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return te(pe)}):typeof module=="object"&&module&&module.exports?module.exports=te(pe):we.FabiPlay=te(pe)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(we){"use strict";var te={exports:{}},pe=te.exports,ye=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,vt=Object.getOwnPropertyNames,Et=Object.prototype.hasOwnProperty,Mt=(e,t,a)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Le=(e,t)=>{for(var a in t)ye(e,a,{get:t[a],enumerable:!0})},At=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vt(t))!Et.call(e,o)&&o!==a&&ye(e,o,{get:()=>t[o],enumerable:!(s=wt(t,o))||s.enumerable});return e},Ct=e=>At(ye({},"__esModule",{value:!0}),e),Q=(e,t,a)=>Mt(e,typeof t!="symbol"?t+"":t,a),_e={};Le(_e,{install:()=>qa}),te.exports=Ct(_e);function St(e,t=window){const a=new Set,s=t.AudioContext;s&&(t.AudioContext=class extends s{constructor(...i){super(...i),a.add(this)}});let o=[],r=[];Promise.resolve(e).then(i=>{i.on("break-start",()=>{o=[...t.document.querySelectorAll("audio, video")].filter(c=>!c.paused),o.forEach(c=>c.pause()),r=[...a].filter(c=>c.state==="running"),r.forEach(c=>{c.suspend()})}),i.on("break-done",()=>{o.forEach(c=>{c.play().catch(()=>{})}),r.forEach(c=>{c.resume()}),o=[],r=[]})})}var zt={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function Tt(e){if(e.trim()==="default")return;const t={};for(const a of e.split(",")){const[s,o]=a.split(":").map(r=>r.trim());s&&o&&(t[s]=o)}return t}var Ot={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function De(e){const t=Ot[e];if(t)return{key:t[0],code:e,keyCode:t[1]};const a=/^Key([A-Z])$/.exec(e);if(a)return{key:a[1].toLowerCase(),code:e,keyCode:a[1].charCodeAt(0)};const s=/^Digit([0-9])$/.exec(e);if(s)return{key:s[1],code:e,keyCode:48+Number(s[1])};throw new Error(`Fabi Play: unknown key "${e}" (use Space, Enter, Arrow\u2026, KeyA\u2026, Digit0\u2026)`)}var Pt=(e=document)=>({dispatch(t,a){const s=new KeyboardEvent(t,{key:a.key,code:a.code,bubbles:!0,cancelable:!0});for(const o of["keyCode","which"])Object.defineProperty(s,o,{get:()=>a.keyCode});(e.activeElement??e.body??e).dispatchEvent(s)}}),Ne=80,Lt=800;function _t(e,t=zt,a={}){const s=a.player===void 0&&e.input==="remote";let o=a.player??(s?e.players?.[0]??1:1);const r=a.target??Pt(),i=a.setTimeout??((y,k)=>setTimeout(y,k)),c=new Set;let h=0;const f=y=>{const k=t[y];!k||c.has(y)||(c.add(y),r.dispatch("keydown",De(k)))},n=y=>{const k=t[y];!k||!c.has(y)||(c.delete(y),r.dispatch("keyup",De(k)))},u=y=>{f(y),i(()=>n(y),Ne)},l=y=>{if(y.player!==o)return;const k={"lane-left":-1,"lane-center":0,"lane-right":1};switch(y.gesture){case"jump":f("jump"),i(()=>n("jump"),Lt);break;case"land":n("jump");break;case"squat":f("squat");break;case"stand":n("squat");break;case"clap":u("clap");break;default:{const x=k[y.gesture];if(x===void 0)break;const M=x>h?"right":"left";for(let g=0;g<Math.abs(x-h);g++)i(()=>u(M),g*(Ne*2));h=x}}},p=y=>{const k=y.players.find(x=>x.id===o);k&&(k.shape==="arms-up"?f("arms-up"):n("arms-up"))},b=[e.on("gesture",l),e.on("frame",p),e.on("break-start",()=>[...c].forEach(n)),e.on("turn",y=>{s&&([...c].forEach(n),o=y.players[0]??o,h=0)})];return()=>{b.forEach(y=>y()),[...c].forEach(n)}}function Dt(e=document){const t=e.createElement("div");t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:0;top:0;width:56px;height:56px;margin:-28px 0 0 -28px;border-radius:50%;border:6px solid #FBE7B8;background:rgba(251,231,184,.25);pointer-events:none;z-index:2147483647;box-sizing:border-box;transition:transform 60ms linear",e.body.appendChild(t);const a=(s,o,...r)=>{const i=e.elementFromPoint(s,o)??e.body;for(const c of r){const h={bubbles:!0,cancelable:!0,clientX:s,clientY:o,pointerId:1,pointerType:"touch",isPrimary:!0};i.dispatchEvent(c.startsWith("pointer")?new PointerEvent(c,h):new MouseEvent(c,h))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(s,o)=>a(s,o,"pointermove","mousemove"),click:(s,o)=>a(s,o,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(s,o,r)=>{t.style.transform=`translate(${s}px, ${o}px) scale(${1-r*.35})`,t.style.borderColor=r>0?"#EE6A43":"#FBE7B8"}}}function Nt(e,t={}){const a=t.player??1,s=t.hand??"any",o=t.dwellMs??800,r=t.radius??.04,i=t.target??Dt();let c=null,h=!1;return e.on("frame",f=>{const n=f.players.find(g=>g.id===a);if(!n)return;const l=s==="left"?n.leftHand:s==="right"?n.rightHand:((g,N)=>g&&N?g.y<N.y?g:N:g??N)(n.leftHand,n.rightHand);if(!l)return;const{width:p,height:b}=i.size(),y=l.x*p,k=l.y*b;i.move(y,k),(!c||Math.hypot(y-c.x,k-c.y)>r*Math.hypot(p,b))&&(c={x:y,y:k,t:f.t},h=!1);const M=h?0:Math.min((f.t-c.t)/o,1);M>=1&&(h=!0,i.click(c.x,c.y)),i.cursor(y,k,h?0:M)})}var Ie=1,Re=33,P={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},It=["3-5","6-8","9-12"],Rt=e=>It.includes(e),ve=4,Qe={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},Qt=Qe["6-8"],Be=(e,t)=>{const a=Rt(t)?Qe[t]:Qt;return a[Number.isInteger(e)&&e>=0?e%a.length:0]},Fe="fabi-play",ie=e=>({ns:Fe,...e});function He(e){if(!Ee(e))return;const{x:t,y:a,w:s,h:o}=e;return oe(t)&&oe(a)&&oe(s)&&oe(o)&&s>0&&o>0?{x:t,y:a,w:s,h:o}:void 0}var je=(e,t)=>e?{x:e.x+t.x*e.w,y:e.y+t.y*e.h}:{x:t.x,y:t.y},Ue=["high","medium","low"];function Bt(e){if(!Ee(e))return;const t={};return Ue.includes(e.tier)&&(t.tier=e.tier),oe(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function Ft(e){const t={};return Ee(e)&&(oe(e.fps)&&e.fps>=0&&e.fps<1e3&&(t.fps=e.fps),typeof e.renderer=="string"&&/^[a-z0-9-]{1,16}$/.test(e.renderer)&&(t.renderer=e.renderer),Ue.includes(e.tier)&&(t.tier=e.tier)),t}var $e=e=>Number.isInteger(e)&&e>=1&&e<=ve;function Ht(e){return Array.isArray(e)&&e.length===1&&$e(e[0])?[e[0]]:void 0}function jt(e){if(!(!Array.isArray(e)||e.length<1||e.length>ve||!e.every($e)||new Set(e).size!==e.length))return[...e]}var Ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),oe=e=>typeof e=="number"&&Number.isFinite(e),Ut=12,$t=Re*4,qt=e=>Ut+e*$t,Wa=qt(ve),U="#4a382c",H="#2b2118",Y="#1c1f2b",qe="#fbefe3",Z="#f4897a",ce="#3a2a22",Ye=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:qe,accent:"#ffd9c2",outline:H,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:ce,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:qe,accent:"#5a3426",outline:H,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:ce,muzzle:"band",cheeks:Z},tail:"brush",headExtras:[],bodyExtras:["star"],extraColors:["#ffd84a"]},{id:"bunny",name:{en:"Bunny",it:"Coniglietto"},band:"3-5",palette:{body:"#f9d0de",limbs:"#f9d0de",belly:"#fff6f8",accent:"#f4a0b9",outline:U},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:Z},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:U},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:ce,muzzle:"oval",cheeks:Z},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:U,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:Z},tail:"long",headExtras:["whiskers"],bodyExtras:[]},{id:"panda",name:{en:"Panda",it:"Panda"},band:"3-5",palette:{body:"#ffffff",limbs:"#6e6674",belly:"#ffffff",accent:"#6e6674",outline:U,ears:"#6e6674"},head:"wide",ears:"round",face:{eyes:"mask",mouth:"smile",nose:"#2f2a2c",muzzle:"none",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:[]},{id:"penguin",name:{en:"Penguin",it:"Pinguino"},band:"3-5",palette:{body:"#6c8fca",limbs:"#6c8fca",belly:"#ffffff",accent:"#f9b95c",outline:U,feet:"#f9b95c"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"heart",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:["flippers","scarf"],extraColors:["#f6907a"]},{id:"frog",name:{en:"Frog",it:"Ranocchio"},band:"3-5",palette:{body:"#8fd487",limbs:"#8fd487",belly:"#e6f7cc",accent:"#62ad62",outline:U},head:"wide",ears:"none",face:{eyes:"big",eyesOnTop:!0,mouth:"open",muzzle:"none",cheeks:"#f59b8f"},tail:"none",headExtras:[],bodyExtras:["flippers","spots"],extraColors:["#62ad62","#b0e6a4"]},{id:"lion",name:{en:"Lion",it:"Leoncino"},band:"6-8",palette:{body:"#f6c454",limbs:"#f6c454",belly:"#fde7b0",accent:"#fde7b0",outline:H},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:Z},tail:"tuft",headExtras:["mane"],bodyExtras:[],extraColors:["#c8692e"]},{id:"unicorn",name:{en:"Unicorn",it:"Unicorno"},band:"6-8",palette:{body:"#fbf5ff",limbs:"#fbf5ff",belly:"#efe0ff",accent:"#fbd46a",outline:H,hands:"#c9a6f2",feet:"#c9a6f2"},head:"tall",ears:"unicorn",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["rainbow-mane"],bodyExtras:[],extraColors:["#f58cc0","#8fd3f4","#a98ff2"]},{id:"dragon",name:{en:"Little Dragon",it:"Draghetto"},band:"6-8",palette:{body:"#8a63d2",limbs:"#8a63d2",belly:"#fbd46a",accent:"#5fd0b5",outline:H},head:"wide",ears:"horns",face:{eyes:"big",eyeColor:"#3a2a6a",mouth:"teeth",muzzle:"none",cheeks:"#f59bc0"},tail:"arrow",headExtras:[],bodyExtras:["wings"]},{id:"robot",name:{en:"Robot",it:"Robot"},band:"9-12",palette:{body:"#b9c7d2",limbs:"#8b9aa6",belly:"#b9c7d2",accent:"#ee6a43",outline:Y,hands:"#ee6a43",feet:"#6b7a86"},head:"square",ears:"antenna",face:{eyes:"screen",eyeColor:"#7ff0ff",mouth:"grill",muzzle:"none"},tail:"none",headExtras:["bolts"],bodyExtras:["panel","joints","boots"],extraColors:["#ff7a6b","#fbd46a","#7ff0ff"]},{id:"astronaut",name:{en:"Astronaut",it:"Astronauta"},band:"9-12",palette:{body:"#f4f1ec",limbs:"#f4f1ec",belly:"#f4f1ec",accent:"#ee6a43",outline:Y,hands:"#9fb0bd",feet:"#9fb0bd"},head:"round",ears:"none",face:{eyes:"visor",mouth:"smile",muzzle:"none"},tail:"none",headExtras:["helmet"],bodyExtras:["backpack","badge","boots"],extraColors:["#c9d3db"]},{id:"dinosaur",name:{en:"Dinosaur",it:"Dinosauro"},band:"6-8",palette:{body:"#3fb3a6",limbs:"#3fb3a6",belly:"#c9f0d6",accent:"#f79a3e",outline:H},head:"wide",ears:"none",face:{eyes:"dot",mouth:"teeth",muzzle:"none",cheeks:"#f59b8f"},tail:"spiky",headExtras:["spikes","spots"],bodyExtras:[],extraColors:["#2b8f84","#7fd3c6"]},{id:"monkey",name:{en:"Monkey",it:"Scimmietta"},band:"6-8",palette:{body:"#7b5234",limbs:"#7b5234",belly:"#f2c9a0",accent:"#f2c9a0",outline:H,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:Z},tail:"curl",headExtras:["tuft"],bodyExtras:[]},{id:"koala",name:{en:"Koala",it:"Koala"},band:"3-5",palette:{body:"#b7bcc6",limbs:"#b7bcc6",belly:"#eef0f3",accent:"#f4dbe2",outline:U},head:"wide",ears:"big-round",face:{eyes:"dot",mouth:"smile",nose:"#3b3438",muzzle:"none",cheeks:"#f4a3b0"},tail:"none",headExtras:[],bodyExtras:[]},{id:"tiger",name:{en:"Tiger",it:"Tigrotto"},band:"6-8",palette:{body:"#f9a33a",limbs:"#f9a33a",belly:"#fff1dc",accent:"#fff1dc",outline:H},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:Z},tail:"striped",headExtras:["stripes","whiskers"],bodyExtras:[],extraColors:["#3a2a22"]},{id:"owl",name:{en:"Owl",it:"Gufetto"},band:"3-5",palette:{body:"#8ec0e6",limbs:"#8ec0e6",belly:"#e3f2fc",accent:"#639cc9",outline:U,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:U,eyeRing:"#fde08a",mouth:"beak",muzzle:"none",cheeks:"#f6a8b4"},tail:"none",headExtras:[],bodyExtras:["feathers"]},{id:"alien",name:{en:"Alien",it:"Alieno"},band:"9-12",palette:{body:"#9ee05a",limbs:"#9ee05a",belly:"#d8f5a8",accent:"#b07cf2",outline:Y},head:"bulb",ears:"antennae",face:{eyes:"almond",eyeColor:"#1e1838",mouth:"smirk",muzzle:"none"},tail:"none",headExtras:[],bodyExtras:["spots"],extraColors:["#7cc23e","#7cc23e"]},{id:"ghost",name:{en:"Friendly Ghost",it:"Fantasmino"},band:"6-8",palette:{body:"#e6f4ff",limbs:"#e6f4ff",belly:"#e6f4ff",accent:"#bcd9f2",outline:H},head:"round",ears:"none",face:{eyes:"dot",mouth:"open",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["curl"],bodyExtras:["sheet"]},{id:"octopus",name:{en:"Octopus",it:"Polpetto"},band:"6-8",palette:{body:"#e0578a",limbs:"#e0578a",belly:"#f7b3cc",accent:"#f7b3cc",outline:H,hands:"#f7b3cc",feet:"#f7b3cc"},head:"tall",ears:"none",face:{eyes:"big",eyeColor:"#3a2140",mouth:"smile",muzzle:"none",cheeks:"#ffd0a0"},tail:"none",headExtras:["spots"],bodyExtras:["tentacles"],extraColors:["#f7b3cc","#f7b3cc"]},{id:"chick",name:{en:"Chick",it:"Pulcino"},band:"3-5",palette:{body:"#ffd45e",limbs:"#ffd45e",belly:"#fff2c2",accent:"#ffa04a",outline:U,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:Z},tail:"none",headExtras:["eggshell"],bodyExtras:[],extraColors:["#fffaf0"]},{id:"puppy",name:{en:"Puppy",it:"Cucciolo"},band:"3-5",palette:{body:"#f4e4cf",limbs:"#f4e4cf",belly:"#fffaf2",accent:"#f29aa4",outline:U,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:ce,muzzle:"oval",cheeks:Z},tail:"curl",headExtras:["eye-spot"],bodyExtras:[]},{id:"lamb",name:{en:"Lamb",it:"Agnellino"},band:"3-5",palette:{body:"#fdf8ee",limbs:"#e3d1c2",belly:"#fffdf8",accent:"#f6bcc2",outline:U,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:Z},tail:"pom",headExtras:["wool"],bodyExtras:["wool"]},{id:"duckling",name:{en:"Duckling",it:"Anatroccolo"},band:"3-5",palette:{body:"#fff1a6",limbs:"#fff1a6",belly:"#fffbe0",accent:"#ff9f43",outline:U,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:Z},tail:"none",headExtras:["curl"],bodyExtras:["flippers","scarf"],extraColors:["#86cfe0"]},{id:"shark",name:{en:"Shark",it:"Squalo"},band:"6-8",palette:{body:"#6c95c4",limbs:"#6c95c4",belly:"#eef5fb",accent:"#4c76a8",outline:H,hands:"#eef5fb",feet:"#4c76a8"},head:"wide",ears:"fin",face:{eyes:"dot",mouth:"jaws",muzzle:"none",cheeks:"#f59bb0"},tail:"fish",headExtras:["gills"],bodyExtras:[]},{id:"wolf",name:{en:"Wolf",it:"Lupo"},band:"6-8",palette:{body:"#8f9bb3",limbs:"#8f9bb3",belly:"#eef1f6",accent:"#f3b8c4",outline:H,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:ce,muzzle:"oval",cheeks:"#f4a3b0"},tail:"fluffy",headExtras:["ruff","forehead"],bodyExtras:[],extraColors:["#636d84"]},{id:"parrot",name:{en:"Parrot",it:"Pappagallo"},band:"6-8",palette:{body:"#e8503f",limbs:"#e8503f",belly:"#ffd25a",accent:"#f6e6c4",outline:H,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:H,eyeRing:"#ffffff",mouth:"hook",muzzle:"none",cheeks:"#ffb0a0"},tail:"plume",headExtras:["crest"],bodyExtras:["feathers"],extraColors:["#ffd25a","#3fae5a","#3a9bdc"]},{id:"ninja",name:{en:"Ninja",it:"Ninja"},band:"9-12",palette:{body:"#2f3a56",limbs:"#2f3a56",belly:"#2f3a56",accent:"#36c9bb",outline:Y,skin:"#b07a52",hands:"#222a40",feet:"#222a40"},head:"round",ears:"none",face:{eyes:"calm",mouth:"none",muzzle:"none",brows:"#2a1d16"},tail:"none",headExtras:["ninja-hood"],bodyExtras:["belt"],extraColors:["#36c9bb","#36c9bb","#36c9bb"]},{id:"skater",name:{en:"Skater",it:"Skater"},band:"9-12",palette:{body:"#3a8fc0",limbs:"#2c3e57",belly:"#2f7aa6",accent:"#ffcf3a",outline:Y,skin:"#f2c9a5",hair:"#7a4a2a",hands:"#f2c9a5",feet:"#eef1f5"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#5a3520"},tail:"none",headExtras:["hair","cap"],bodyExtras:["pocket","joints"],extraColors:["#ff5d73"]},{id:"explorer",name:{en:"Explorer",it:"Giramondo"},band:"9-12",palette:{body:"#5f8f5b",limbs:"#5f8f5b",belly:"#5f8f5b",accent:"#d9bb7e",outline:Y,skin:"#7a4a30",hair:"#1d1410",hands:"#7a4a30",feet:"#6b4a2a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#1d1410"},tail:"none",headExtras:["curls","safari-hat"],bodyExtras:["backpack","straps","boots"],extraColors:["#e07b39","#6b4a2a"]},{id:"wizard",name:{en:"Wizard",it:"Mago"},band:"9-12",palette:{body:"#5b3fa0",limbs:"#5b3fa0",belly:"#5b3fa0",accent:"#3d5fc8",outline:Y,skin:"#c98d62",hair:"#a8452a",hands:"#c98d62",feet:"#33255e"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#7a301c"},tail:"none",headExtras:["locks","wizard-hat"],bodyExtras:["robe","belt"],extraColors:["#ffd84a","#ffd84a","#ffd84a"]},{id:"knight",name:{en:"Knight",it:"Cavaliere"},band:"9-12",palette:{body:"#bcc7d3",limbs:"#8e9aa8",belly:"#dce3ea",accent:"#d8443a",outline:Y,hands:"#6c7786",feet:"#6c7786"},head:"bucket",ears:"none",face:{eyes:"slit",eyeColor:"#bfefff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["plume"],bodyExtras:["pauldrons","emblem","boots"],extraColors:["#d8443a"]},{id:"racer",name:{en:"Racer",it:"Pilota"},band:"9-12",palette:{body:"#ff6a2b",limbs:"#ff6a2b",belly:"#ffffff",accent:"#ffffff",outline:Y,hands:"#232838",feet:"#232838"},head:"round",ears:"none",face:{eyes:"goggle",eyeColor:"#7fd6ff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["stripe"],bodyExtras:["racing-stripe","boots"]},{id:"pirate",name:{en:"Pirate",it:"Pirata"},band:"9-12",palette:{body:"#f2efe6",limbs:"#2a3d6e",belly:"#f2efe6",accent:"#d94545",outline:Y,skin:"#d9a072",hair:"#2b1a12",hands:"#d9a072",feet:"#3a2a20"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#2b1a12"},tail:"none",headExtras:["locks","bandana","eye-patch"],bodyExtras:["stripes","belt","boots"],extraColors:["#d94545","#2a3d6e","#4a3426"]},{id:"diver",name:{en:"Diver",it:"Sub"},band:"9-12",palette:{body:"#1f6582",limbs:"#1f6582",belly:"#1f6582",accent:"#ffb020",outline:Y,skin:"#e8b48a",hair:"#c98f2e",hands:"#1b4f66",feet:"#ffb020"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#8a5a1a"},tail:"none",headExtras:["curls","dive-mask"],bodyExtras:["tank","fins"],extraColors:["#c9d3db"]},{id:"hero",name:{en:"Hero",it:"Supereroe"},band:"9-12",palette:{body:"#3557c8",limbs:"#3557c8",belly:"#3557c8",accent:"#e0403a",outline:Y,skin:"#5a3825",hair:"#141010",hands:"#e0403a",feet:"#e0403a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#141010"},tail:"none",headExtras:["hair","domino"],bodyExtras:["cape","emblem","boots"],extraColors:["#ffd84a"]}],D={M:0,L:1,Q:2,C:3,Z:4},Ze=[2,2,4,6,0];function Me(e,t){for(const a of t)Yt(e,a)}function Yt(e,t){if(t.k==="group"){e.save(),e.translate(t.x,t.y),t.rot&&e.rotate(t.rot),t.s!==void 0&&t.s!==1&&e.scale(t.s,t.s),t.alpha!==void 0&&(e.globalAlpha*=t.alpha),Me(e,t.items),e.restore();return}switch(e.save(),t.alpha!==void 0&&(e.globalAlpha*=t.alpha),e.beginPath(),t.k){case"circle":e.arc(t.x,t.y,Math.max(t.r,0),0,Math.PI*2);break;case"ellipse":e.ellipse(t.x,t.y,Math.max(t.rx,0),Math.max(t.ry,0),t.rot??0,0,Math.PI*2);break;case"rect":Zt(e,t);break;case"path":typeof t.d=="string"?Xt(e,t.d):Kt(e,t.d);break;case"line":e.moveTo(t.pts[0]??0,t.pts[1]??0);for(let a=2;a+1<t.pts.length;a+=2)e.lineTo(t.pts[a],t.pts[a+1]);break}e.lineCap="round",e.lineJoin="round",t.fill&&t.k!=="line"&&(e.fillStyle=t.fill,e.fill()),t.stroke&&(t.lw??1)>0&&(e.strokeStyle=t.stroke,e.lineWidth=t.lw??1,e.stroke()),e.restore()}function Zt(e,t){const a=Math.max(0,Math.min(t.r,t.w/2,t.h/2));e.translate(t.x,t.y),t.rot&&e.rotate(t.rot);const s=-t.w/2,o=-t.h/2;e.moveTo(s+a,o),e.lineTo(s+t.w-a,o),e.quadraticCurveTo(s+t.w,o,s+t.w,o+a),e.lineTo(s+t.w,o+t.h-a),e.quadraticCurveTo(s+t.w,o+t.h,s+t.w-a,o+t.h),e.lineTo(s+a,o+t.h),e.quadraticCurveTo(s,o+t.h,s,o+t.h-a),e.lineTo(s,o+a),e.quadraticCurveTo(s,o,s+a,o),e.closePath()}function Kt(e,t){for(let a=0;a<t.length;){const s=t[a++];if(s===D.M)e.moveTo(t[a],t[a+1]);else if(s===D.L)e.lineTo(t[a],t[a+1]);else if(s===D.Q)e.quadraticCurveTo(t[a],t[a+1],t[a+2],t[a+3]);else if(s===D.C)e.bezierCurveTo(t[a],t[a+1],t[a+2],t[a+3],t[a+4],t[a+5]);else if(s===D.Z)e.closePath();else return;a+=Ze[s]}}function Wt(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);const t=[];for(let a=0;a<e.length;){const s=Ze[e[a++]];if(s===void 0)break;for(let o=0;o<s;o++)t.push(e[a+o]);a+=s}return t}function Xt(e,t){const a=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let s="",o=0;const r=()=>Number(a[o++]);for(;o<a.length;){const i=a[o];if(/[MLQCZ]/i.test(i)&&(s=i.toUpperCase(),o++,s==="Z")){e.closePath();continue}s==="M"?(e.moveTo(r(),r()),s="L"):s==="L"?e.lineTo(r(),r()):s==="Q"?e.quadraticCurveTo(r(),r(),r(),r()):s==="C"?e.bezierCurveTo(r(),r(),r(),r(),r(),r()):o++}}var S=e=>{const t=Math.round(e*100)/100;return t===0?0:t};function _(e,t=.5){const a=e.length;if(a<3)return[];const s=(c,h,f)=>({x:c.x+(h.x-c.x)*f,y:c.y+(h.y-c.y)*f}),o=Math.min(Math.max(t,0),.5),r=s(e[0],e[1],o),i=[D.M,S(r.x),S(r.y)];for(let c=1;c<=a;c++){const h=e[(c-1)%a],f=e[c%a],n=e[(c+1)%a],u=s(h,f,1-o),l=s(f,n,o);i.push(D.L,S(u.x),S(u.y),D.Q,S(f.x),S(f.y),S(l.x),S(l.y))}return i.push(D.Z),i}function L(e,t=1){const a=e.length;if(a<3)return[];const s=[D.M,S(e[0].x),S(e[0].y)],o=t/6;for(let r=0;r<a;r++){const i=e[(r-1+a)%a],c=e[r],h=e[(r+1)%a],f=e[(r+2)%a];s.push(D.C,S(c.x+(h.x-i.x)*o),S(c.y+(h.y-i.y)*o),S(h.x-(f.x-c.x)*o),S(h.y-(f.y-c.y)*o),S(h.x),S(h.y))}return s.push(D.Z),s}function fe(e){const t=e.length;if(t<2)return[];const a=[D.M,S(e[0].x),S(e[0].y)];for(let s=0;s<t-1;s++){const o=e[Math.max(s-1,0)],r=e[s],i=e[s+1],c=e[Math.min(s+2,t-1)];a.push(D.C,S(r.x+(i.x-o.x)/6),S(r.y+(i.y-o.y)/6),S(i.x-(c.x-r.x)/6),S(i.y-(c.y-r.y)/6),S(i.x),S(i.y))}return a}var be="M0 -1 L0.29 -0.4 L0.95 -0.31 L0.47 0.15 L0.59 0.81 L0 0.5 L-0.59 0.81 L-0.47 0.15 L-0.95 -0.31 L-0.29 -0.4 Z",B="#ffffff",E=[-1,1],Ke="#3a2420",Gt="#f2808f",Ae="#26324a",Vt="#ffd84a",j=(...e)=>{const t=[];for(let a=0;a+1<e.length;a+=2)t.push({x:e[a],y:e[a+1]});return t};function We(e,t){const a=e.palette,s=[],o={stroke:a.outline,lw:t},r=n=>e.headExtras.includes(n),i=(n,u)=>e.extraColors?.[n]??u;if(r("mane")){for(let u=0;u<12;u++){const l=u/12*Math.PI*2;s.push({k:"circle",x:Math.cos(l)*1.02,y:Math.sin(l)*1+.04,r:.42,fill:i(0,a.accent),...o})}s.push({k:"circle",x:0,y:.04,r:1.08,fill:i(0,a.accent)})}if(r("rainbow-mane")){const n=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([l,p,b,y,k],x)=>s.push({k:"ellipse",x:l,y:p,rx:b,ry:y,rot:k,fill:n[x%n.length],...o}))}if(r("spikes"))for(const n of[-.55,0,.55]){const u=he(n,1.48),l=he(n-.32,.86),p=he(n+.32,.86);s.push({k:"path",d:_([l,u,p],.22),fill:a.accent,...o})}if(r("curl")&&s.push({k:"path",d:L([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:a.body,...o}),r("wool"))for(let n=0;n<=8;n++){const u=-1.75+n/8*3.5;s.push({k:"circle",x:Math.sin(u)*.98,y:-Math.cos(u)*.92-.04,r:.34,fill:a.body,...o})}if(r("crest")&&[-.38,0,.38].forEach((n,u)=>{const l=he(n,1.12);s.push({k:"ellipse",x:l.x,y:l.y,rx:.15,ry:.42,rot:n,fill:i(u,a.accent),...o})}),r("plume")&&s.push({k:"path",d:L(j(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:a.accent,...o}),r("locks")&&s.push({k:"path",d:L(j(-1.14,.58,-1.24,-.2,-.86,-.98,0,-1.2,.86,-.98,1.24,-.2,1.14,.58,.8,.66,0,.2,-.8,.66)),fill:a.hair??a.outline,...o}),r("ninja-hood"))for(const[n,u]of[[.35,.5],[.85,.42]])s.push({k:"ellipse",x:1+Math.cos(n)*u*.8,y:-.5+Math.sin(n)*u*.8,rx:u,ry:.11,rot:n,fill:a.accent,...o});if(r("bandana"))for(const[n,u]of[[Math.PI-.5,.42],[Math.PI-1,.36]])s.push({k:"ellipse",x:-.98+Math.cos(n)*u*.8,y:-.36+Math.sin(n)*u*.8,rx:u,ry:.12,rot:n,fill:a.accent,...o});if(r("ruff"))for(const n of E)s.push({k:"path",d:_(j(n*.7,-.3,n*1.32,0,n*1.02,.18,n*1.26,.46,n*.86,.56,n*.98,.84,n*.4,.7),.25),fill:a.body,...o});if(e.face.eyesOnTop)for(const n of E)s.push({k:"circle",x:n*.46,y:-.72,r:.38,fill:a.body,...o});s.push(...aa(e,t)),s.push(Jt(e,o));const c=e.face.muzzle,h=a.belly;if(c==="oval"&&s.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:h}),c==="monkey"){for(const n of E)s.push({k:"circle",x:n*.32,y:-.04,r:.38,fill:h});s.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:h})}if(c==="heart"){for(const n of E)s.push({k:"circle",x:n*.36,y:.02,r:.5,fill:h});s.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:h})}if(c==="disc")for(const n of E)s.push({k:"circle",x:n*.4,y:.02,r:.44,fill:h});if(c==="cheeks")for(const n of E)s.push({k:"ellipse",x:n*.4,y:.44,rx:.44,ry:.32,fill:h});if(c==="band"&&s.push({k:"path",d:ta(e,t),fill:h}),r("stripes")){const n=i(0,a.outline);s.push({k:"line",pts:[0,-.97,0,-.66],stroke:n,lw:.13});for(const u of E)s.push({k:"line",pts:[u*.3,-.93,u*.24,-.7],stroke:n,lw:.1}),s.push({k:"line",pts:[u*.98,-.05,u*.74,0],stroke:n,lw:.1}),s.push({k:"line",pts:[u*.94,.22,u*.74,.22],stroke:n,lw:.09})}if(r("spots")){const n=i(1,a.belly);s.push({k:"circle",x:-.55,y:-.5,r:.15,fill:n}),s.push({k:"circle",x:.58,y:-.42,r:.11,fill:n}),s.push({k:"circle",x:.22,y:-.76,r:.09,fill:n})}if(r("forehead")&&s.push({k:"path",d:L(j(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:i(0,a.accent)}),r("eye-spot")&&s.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:a.ears??a.accent}),r("gills"))for(const n of E)for(const u of[0,.12,.24])s.push({k:"path",d:`M${n*(.66+u)} 0.06 Q${n*(.6+u)} 0.22 ${n*(.66+u)} 0.38`,stroke:a.accent,lw:t*.9});const f=a.hair??a.outline;if(r("hair")&&s.push({k:"path",d:L(j(-1.02,-.06,-1.02,-.58,-.62,-1.04,.08,-1.14,.76,-.92,1.05,-.42,1,-.06,.84,-.4,.42,-.5,.06,-.4,-.34,-.56,-.74,-.38)),fill:f,...o}),r("locks")&&s.push({k:"path",d:L(j(-1,-.08,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1,-.08,.8,-.38,.36,-.44,0,-.4,-.36,-.44,-.8,-.38)),fill:f,...o}),r("curls")){for(let n=0;n<7;n++){const u=he(-1.3+n/6*2.6,.86);s.push({k:"circle",x:u.x,y:u.y,r:.3,fill:f,...o})}s.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:f})}if(r("ninja-hood")&&(s.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:a.skin??B,stroke:a.outline,lw:t*.8}),s.push({k:"path",d:"M-0.98 -0.42 Q0 -0.74 0.98 -0.42 L1.0 -0.62 Q0 -0.94 -1.0 -0.62 Z",fill:a.accent,...o})),r("domino")){s.push({k:"path",d:L(j(-.86,-.04,-.62,-.3,-.18,-.24,0,-.16,.18,-.24,.62,-.3,.86,-.04,.6,.22,.16,.16,0,.1,-.16,.16,-.6,.22),.9),fill:a.accent,...o});for(const n of E)s.push({k:"ellipse",x:n*.38,y:0,rx:.19,ry:.13,fill:B})}if(s.push(...sa(e,t)),r("brows"))for(const n of E)s.push({k:"line",pts:[n*.72,-.5,n*.14,-.3],stroke:a.accent,lw:.16});if(e.face.brows)for(const n of E)s.push({k:"line",pts:[n*.2,-.2,n*.54,-.28],stroke:e.face.brows,lw:.09});if(s.push(...oa(e,t)),e.face.cheeks)for(const n of E)s.push({k:"ellipse",x:n*.64,y:.3,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(r("whiskers"))for(const n of E)for(const u of[-.1,.06])s.push({k:"line",pts:[n*.62,.38+u,n*1.06,.3+u*2.2],stroke:a.outline,lw:t*.7,alpha:.75});if(r("rainbow-mane")){const n=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];s.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:n[0],...o}),s.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:n[1%n.length],...o})}if(e.ears==="unicorn"){const n=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];s.push({k:"path",d:_(n,.12),fill:a.accent,...o});for(const u of[-1,-1.2,-1.4]){const l=.16*((u+1.72)/.88);s.push({k:"line",pts:[-l,u+.04,l,u-.04],stroke:a.outline,lw:t*.7,alpha:.6})}}if(r("helmet")){for(const n of E)s.push({k:"rect",x:n*1,y:.05,w:.26,h:.56,r:.12,fill:a.accent,...o});s.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:B,lw:.1,alpha:.9})}if(r("bolts"))for(const n of E)s.push({k:"rect",x:n*1.08,y:.08,w:.2,h:.44,r:.08,fill:a.accent,...o});if(r("tuft")&&s.push({k:"path",d:L([{x:-.26,y:-.95},{x:-.12,y:-1.22},{x:.02,y:-1.04},{x:.16,y:-1.28},{x:.28,y:-.95},{x:0,y:-.86}]),fill:a.body,...o}),r("eggshell")&&s.push({k:"path",d:"M-0.88 -0.5 C-0.88 -1.12 -0.46 -1.42 0 -1.42 C0.46 -1.42 0.88 -1.12 0.88 -0.5 L0.66 -0.66 L0.44 -0.48 L0.22 -0.66 L0 -0.48 L-0.22 -0.66 L-0.44 -0.48 L-0.66 -0.66 Z",fill:i(0,B),...o}),r("wool"))for(const[n,u]of[[-.36,-.84],[.02,-.94],[.4,-.82]])s.push({k:"circle",x:n,y:u,r:.27,fill:a.body,...o});if(r("stripe")&&s.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:a.accent}),r("eye-patch")&&(s.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:a.outline,lw:.07}),s.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:a.outline})),r("bandana")){s.push({k:"path",d:L(j(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:a.accent,...o});for(const[n,u]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])s.push({k:"circle",x:n,y:u,r:.06,fill:B,alpha:.85});s.push({k:"circle",x:-.98,y:-.34,r:.15,fill:a.accent,...o})}if(r("cap")){for(const n of E)s.push({k:"line",pts:[n*.98,-.2,n*.5,.82,-n*.05,.98],stroke:a.outline,lw:.06});s.push({k:"path",d:L(j(-1.1,-.16,-1.04,-.66,-.6,-1.12,0,-1.24,.6,-1.12,1.04,-.66,1.1,-.16,.5,-.4,-.5,-.4)),fill:a.accent,...o}),s.push({k:"path",d:"M-0.74 -0.4 Q0 -0.6 0.74 -0.4 Q0.8 -0.24 0.6 -0.22 Q0 -0.36 -0.6 -0.22 Q-0.8 -0.24 -0.74 -0.4 Z",fill:a.accent,...o}),s.push({k:"circle",x:.5,y:-.82,r:.15,fill:i(0,B),...o});for(const n of[-.42,-.14])s.push({k:"line",pts:[n,-1.04,n+.02,-.78],stroke:a.outline,lw:.07,alpha:.7})}if(r("safari-hat")&&(s.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:a.accent,...o}),s.push({k:"path",d:L(j(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:a.accent,...o}),s.push({k:"path",d:"M-0.77 -0.72 Q0 -0.62 0.77 -0.72 L0.74 -0.9 Q0 -0.8 -0.74 -0.9 Z",fill:i(1,a.outline),stroke:a.outline,lw:t*.8})),r("wizard-hat")){s.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:a.accent,...o}),s.push({k:"path",d:_(j(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:a.accent,...o});const n=i(0,Vt);for(const[u,l,p]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])s.push({k:"group",x:u,y:l,s:p,items:[{k:"path",d:be,fill:n}]})}if(r("dive-mask")){for(const u of E)s.push({k:"line",pts:[u*.7,-.04,u*1,-.12],stroke:a.outline,lw:.2},{k:"line",pts:[u*.7,-.04,u*1,-.12],stroke:a.accent,lw:.11});s.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),s.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:a.outline,lw:.2}),s.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:a.accent,lw:.11}),s.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:B,lw:.06,alpha:.9});const n="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";s.push({k:"path",d:n,stroke:a.outline,lw:.24},{k:"path",d:n,stroke:a.accent,lw:.13})}return s}function Jt(e,t){const a=e.headExtras.includes("ninja-hood")?e.palette.body:e.palette.skin??e.palette.body;switch(e.head){case"round":return{k:"circle",x:0,y:0,r:1,fill:a,...t};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:a,...t};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:a,...t};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:a,...t};case"bucket":return{k:"path",d:_(j(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:a,...t};case"bulb":return{k:"path",d:L([{x:0,y:-1.02},{x:.86,y:-.74},{x:1.08,y:-.12},{x:.72,y:.62},{x:0,y:.92},{x:-.72,y:.62},{x:-1.08,y:-.12},{x:-.86,y:-.74}]),fill:a,...t}}}function ea(e){return e.head==="round"?{cy:0,rx:1,ry:1}:e.head==="tall"?{cy:-.02,rx:.94,ry:1.04}:{cy:.03,rx:1.12,ry:.94}}function ta(e,t){const{cy:a,rx:s,ry:o}=ea(e),r=s-t/2,i=o-t/2,c=.15,h=Math.asin(Math.min(1,(c-a)/i)),f=Math.cos(h)*r,n=b=>Math.round(b*100)/100||0,u=[D.M,n(-f),c],l=[[-.84*f,.02,-.53*f,.06,-.32*f,.24],[-.17*f,.11,.17*f,.11,.32*f,.24],[.53*f,.06,.84*f,.02,f,c]];for(const b of l)u.push(D.C,...b.map(n));const p=24;for(let b=1;b<=p;b++){const y=h+(Math.PI-2*h)*b/p;u.push(D.L,n(Math.cos(y)*r),n(a+Math.sin(y)*i))}return u.push(D.Z),u}function aa(e,t){const a=e.palette,s={stroke:a.outline,lw:t},o=[];for(const r of E)switch(e.ears){case"pointy":case"unicorn":{const i=e.ears==="unicorn"?.8:1,c={x:r*.3,y:-.82},h={x:r*.86,y:-.82-.62*i},f={x:r*.94,y:-.36};o.push({k:"path",d:_([c,h,f],.2),fill:a.body,...s});const n={x:(c.x+h.x+f.x)/3,y:(c.y+h.y+f.y)/3},u=[c,h,f].map(l=>({x:n.x+(l.x-n.x)*.55,y:n.y+(l.y-n.y)*.55+.04}));o.push({k:"path",d:_(u,.25),fill:a.accent});break}case"round":o.push({k:"circle",x:r*.72,y:-.72,r:.36,fill:a.ears??a.body,...s}),a.ears||o.push({k:"circle",x:r*.74,y:-.74,r:.19,fill:a.accent});break;case"big-round":o.push({k:"circle",x:r*.96,y:-.46,r:.52,fill:a.body,...s}),o.push({k:"circle",x:r*1,y:-.44,r:.32,fill:a.accent});break;case"long":o.push({k:"ellipse",x:r*.38,y:-1.42,rx:.25,ry:.68,rot:r*.14,fill:a.body,...s}),o.push({k:"ellipse",x:r*.39,y:-1.36,rx:.12,ry:.48,rot:r*.14,fill:a.accent});break;case"side":o.push({k:"circle",x:r*1,y:.02,r:.34,fill:a.body,...s}),o.push({k:"circle",x:r*1.02,y:.02,r:.2,fill:a.belly});break;case"tufts":o.push({k:"path",d:_([{x:r*.3,y:-.84},{x:r*1.22,y:-1.12},{x:r*.92,y:-.42}],.16),fill:a.body,...s}),o.push({k:"line",pts:[r*.62,-.78,r*1,-.98],stroke:a.accent,lw:.08});break;case"antennae":{const i={x:r*.62,y:-1.42};o.push({k:"path",d:`M${r*.3} -0.8 Q${r*.36} -1.2 ${i.x} ${i.y}`,stroke:a.outline,lw:t*2.6}),o.push({k:"path",d:`M${r*.3} -0.8 Q${r*.36} -1.2 ${i.x} ${i.y}`,stroke:a.body,lw:t*1.2}),o.push({k:"circle",x:i.x,y:i.y,r:.17,fill:a.accent,...s});break}case"floppy":o.push({k:"ellipse",x:r*.96,y:.02,rx:.3,ry:.62,rot:-r*.36,fill:a.ears??a.body,...s});break;case"droopy":o.push({k:"ellipse",x:r*1.04,y:-.22,rx:.4,ry:.18,rot:r*.32,fill:a.skin??a.body,...s}),o.push({k:"ellipse",x:r*1.08,y:-.2,rx:.24,ry:.08,rot:r*.32,fill:a.accent});break;case"human":o.push({k:"ellipse",x:r*.98,y:.06,rx:.17,ry:.23,fill:a.skin??a.body,...s});break;case"horns":{const i=[{x:r*.3,y:-.84},{x:r*.6,y:-1.5},{x:r*.66,y:-.68}];o.push({k:"path",d:_(i,.18),fill:a.accent,...s});break}}return e.ears==="fin"&&o.push({k:"path",d:_(j(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:a.body,...s}),e.ears==="antenna"&&(o.push({k:"line",pts:[0,-.85,0,-1.42],stroke:a.outline,lw:t*2.6}),o.push({k:"line",pts:[0,-.85,0,-1.42],stroke:a.limbs,lw:t*1.2}),o.push({k:"circle",x:0,y:-1.5,r:.18,fill:a.accent,...s})),o}function sa(e,t){const a=e.palette,s=e.face,o=[],r=a.outline,i=s.eyesOnTop?.46:.4,c=s.eyesOnTop?-.72:-.04,h=(f,n,u)=>({k:"circle",x:f,y:n,r:u,fill:B});switch(s.eyes){case"dot":for(const f of E)o.push({k:"ellipse",x:f*i,y:c,rx:.12,ry:.155,fill:r}),o.push(h(f*i+.04,c-.06,.045));break;case"bead":for(const f of E)o.push({k:"ellipse",x:f*i,y:c,rx:.16,ry:.22,fill:r}),o.push(h(f*i+.05,c-.08,.065));break;case"big":for(const f of E)s.eyeRing&&o.push({k:"circle",x:f*i,y:c,r:.36,fill:s.eyeRing,stroke:r,lw:t*.8}),o.push({k:"circle",x:f*i,y:c,r:.25,fill:B,stroke:r,lw:t*.8}),o.push({k:"circle",x:f*i+f*-.03,y:c+.03,r:.14,fill:s.eyeColor??r}),o.push(h(f*i+f*-.03+.05,c-.03,.05));break;case"mask":for(const f of E)o.push({k:"ellipse",x:f*.4,y:0,rx:.24,ry:.32,rot:f*-.55,fill:a.limbs}),o.push({k:"circle",x:f*.4,y:-.02,r:.11,fill:B}),o.push({k:"circle",x:f*.39,y:-0,r:.065,fill:r});break;case"screen":o.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:r,lw:t*.8});for(const f of E)o.push({k:"ellipse",x:f*.36,y:0,rx:.2,ry:.24,fill:s.eyeColor??"#7ff0ff",alpha:.3}),o.push({k:"ellipse",x:f*.36,y:0,rx:.12,ry:.16,fill:s.eyeColor??"#7ff0ff"});break;case"almond":for(const f of E)o.push({k:"ellipse",x:f*.42,y:-.02,rx:.3,ry:.2,rot:-f*.5,fill:s.eyeColor??r}),o.push(h(f*.42-f*.07,-.08,.07));break;case"calm":for(const f of E)o.push({k:"ellipse",x:f*.38,y:.02,rx:.085,ry:.12,fill:r}),o.push(h(f*.38+.03,-.02,.03));break;case"slit":o.push({k:"line",pts:[0,-.98,0,-.2],stroke:r,lw:t*.8,alpha:.5}),o.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:Ae,stroke:r,lw:t*.8}),o.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:Ae,stroke:r,lw:t*.8});for(const f of E){o.push({k:"ellipse",x:f*.4,y:-.04,rx:.12,ry:.07,fill:s.eyeColor??B});for(const n of[.36,.56])o.push({k:"circle",x:f*.42,y:n,r:.05,fill:r,alpha:.6})}break;case"goggle":for(const f of E)o.push({k:"circle",x:f*.9,y:0,r:.13,fill:a.accent,stroke:r,lw:t*.8});o.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:Ae,stroke:r,lw:t*.8}),o.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:B,lw:.07,alpha:.8});for(const f of E)o.push({k:"path",d:`M${f*.5} 0.04 Q${f*.34} -0.08 ${f*.16} 0.02`,stroke:s.eyeColor??"#7fd6ff",lw:.08});for(const f of[-.18,0,.18])o.push({k:"line",pts:[f,.56,f,.72],stroke:r,lw:t*.8,alpha:.6});break;case"visor":o.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:r,lw:t*.8}),o.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:B,lw:.08,alpha:.7});for(const f of E)o.push({k:"ellipse",x:f*.28,y:.04,rx:.1,ry:.14,fill:s.eyeColor??"#cfeeff"});break}return o}function oa(e,t){const a=e.palette,s=e.face,o=[],r=s.eyes==="visor"?"#cfeeff":Ke,i=t*1.05;switch(s.nose&&s.mouth!=="beak"&&(s.mouth==="cat"?o.push({k:"path",d:_([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:s.nose,stroke:s.nose,lw:t*.6}):e.ears==="big-round"?o.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:s.nose}):o.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:s.nose})),s.mouth){case"smile":o.push({k:"path",d:s.eyes==="visor"?"M-0.16 0.32 Q0 0.46 0.16 0.32":"M-0.17 0.42 Q0 0.58 0.17 0.42",stroke:r,lw:i});break;case"open":o.push({k:"path",d:"M-0.21 0.4 Q0 0.46 0.21 0.4 Q0.19 0.68 0 0.68 Q-0.19 0.68 -0.21 0.4 Z",fill:r,stroke:r,lw:t*.5}),o.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:Gt});break;case"cat":o.push({k:"path",d:"M-0.19 0.4 Q-0.1 0.5 0 0.37 Q0.1 0.5 0.19 0.4",stroke:r,lw:i});break;case"beak":o.push({k:"path",d:_([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:a.accent,stroke:a.outline,lw:t*.8});break;case"teeth":o.push({k:"path",d:"M-0.36 0.34 Q0 0.44 0.36 0.34 Q0.28 0.66 0 0.66 Q-0.28 0.66 -0.36 0.34 Z",fill:r,stroke:r,lw:t*.5});for(const c of E)o.push({k:"rect",x:c*.12,y:.43,w:.1,h:.1,r:.03,fill:B});break;case"grill":o.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:a.outline,lw:t*.7});for(const c of[-.15,0,.15])o.push({k:"line",pts:[c,.51,c,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":o.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:r});break;case"smirk":o.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:r,lw:i});break;case"bill":o.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:a.accent,stroke:a.outline,lw:t*.8}),o.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:a.outline,lw:t*.7});for(const c of E)o.push({k:"circle",x:c*.1,y:.28,r:.03,fill:a.outline});break;case"hook":o.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:Ke}),o.push({k:"path",d:"M-0.3 0.12 Q0 -0.02 0.3 0.12 Q0.36 0.52 0.04 0.76 Q0.08 0.52 -0.08 0.46 Q-0.28 0.38 -0.3 0.12 Z",fill:a.accent,stroke:a.outline,lw:t*.8});break;case"jaws":{o.push({k:"path",d:"M-0.5 0.3 Q0 0.5 0.5 0.3 Q0.38 0.72 0 0.72 Q-0.38 0.72 -0.5 0.3 Z",fill:r,stroke:r,lw:t*.5});for(const c of[-.34,-.17,0,.17,.34]){const h=.3+.4*(c+.5)*(.5-c)-.01;o.push({k:"path",d:_(j(c-.075,h,c+.075,h,c,h+.13),.15),fill:B})}break}}return o}var he=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t}),ra=.5,J={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ae={"3-5":{head:.75,neck:.74,arm:.3,leg:.36,hand:.19,foot:1.2,shoulderMin:.4,shoulderPad:.07,hipMin:.5,hipPad:.22,bottom:.26,bulge:1.12,armsOverHead:!0},"6-8":{head:.6,neck:.78,arm:.22,leg:.28,hand:.15,foot:1,shoulderMin:.34,shoulderPad:.04,hipMin:.4,hipPad:.16,bottom:.14,bulge:1.04,armsOverHead:!1},"9-12":{head:.5,neck:.92,arm:.17,leg:.21,hand:.125,foot:.9,shoulderMin:.36,shoulderPad:.07,hipMin:.32,hipPad:.08,bottom:.1,bulge:1,armsOverHead:!1}},ke="6-8",Xe=e=>e.band in ae?e.band:ke,Xa=ae[ke].head,na=.3,la=.12,ia=.9,Ge=.5,Ve=.65,ca=.35,fa=.2,ha=.25,X=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),K=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),F=(e,t)=>({x:e.x*t,y:e.y*t}),se=e=>Math.hypot(e.x,e.y),Je=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Ce=e=>{const t=se(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},ua=(...e)=>e.every(Number.isFinite),da=e=>Math.atan2(Math.sin(e),Math.cos(e)),pa=(e,t,a)=>Math.min(Math.max(e,t),a);function et(e,t,a=!1){return s=>{const o=e[s*3],r=e[s*3+1],i=e[s*3+2];return o===void 0||r===void 0||i===void 0||!ua(o,r,i)?{x:0,y:0,ok:!1}:{x:t.x+(a?1-o:o)*t.w,y:t.y+r*t.h,ok:i>=ra}}}function Se(e,t,a={}){const s=et(e,t,a.mirrored),o=s(P.leftShoulder),r=s(P.rightShoulder);if(!o.ok||!r.ok)return null;const i=s(P.leftHip),c=s(P.rightHip),h=Je(o,r),f=se(X(r,o)),n=i.ok&&c.ok;let u=Ce(X(r,o));f<1e-6&&(u={x:1,y:0});let l,p,b;if(n){const R=Je(i,c);p=se(X(R,h)),p>=f*ha?l=Ce(X(R,h)):(l={x:-u.y,y:u.x},l.y<0&&(l=F(l,-1))),b=Math.max(p,f*1.15)}else l={x:-u.y,y:u.x},l.y<0&&(l=F(l,-1)),b=f*1.15,p=b;b=Math.max(b,1e-6);const y={x:l.y,y:-l.x},k=Math.atan2(y.y,y.x),x=F(l,-1),M=ae[a.band??ke]??ae[ke],g=M.head*b;let N=K(h,F(x,g*M.neck));const I=s(P.nose);if(I.ok){const R=K(I,F(x,g*.15)),ee=F(X(R,N),ca),C=Math.min(1,g*fa/Math.max(se(ee),1e-6));N=K(N,F(ee,C))}return{S:h,r:y,d:l,U:b,L:p,hipsOk:n,head:N,headR:g,headRot:k+ya(e,s,k,b),angle:k}}function ya(e,t,a,s){const o=[[J.leftEar,J.rightEar],[J.leftEye,J.rightEye]];for(const[r,i]of o){const c=t(r),h=t(i);if(!c.ok||!h.ok||!(e[r*3+2]>=Ve&&e[i*3+2]>=Ve)||se(X(h,c))<s*.05)continue;const f=da(Math.atan2(h.y-c.y,h.x-c.x)-a),n=Math.max(Math.abs(f)-la,0),u=pa((ia+Ge-Math.abs(f))/Ge,0,1);return Math.sign(f)*Math.min(n,na)*u}return 0}function ze(e,t,a,s={}){const o=Xe(t),r=ae[o],i=Se(e,a,{...s,band:o});if(!i)return[];const c=et(e,a,s.mirrored),h=t.palette,{S:f,r:n,d:u,U:l,L:p}=i,b=d=>t.bodyExtras.includes(d),y=Math.max(1.2,l*.045),k={stroke:h.outline,lw:y},x=(d,m)=>({x:f.x+n.x*d+u.x*m,y:f.y+n.y*d+u.y*m}),M=d=>d.map(([m,w])=>x(m,w)),g=c(P.leftShoulder),N=c(P.rightShoulder),I=c(P.leftHip),R=c(P.rightHip),ee=se(X(N,g)),C=i.hipsOk?se(X(R,I)):ee*.7,v=Math.max(ee/2+r.shoulderPad*l,r.shoulderMin*l),O=Math.max(C/2+r.hipPad*l,r.hipMin*l),$=-.1*l,re=p+r.bottom*l,G=[],me=[],z=[],ge=[],yt=[],bt=(d,m,w,T)=>{const A=m.flatMap(q=>[q.x,q.y]);d.push({k:"line",pts:A,stroke:h.outline,lw:w+y*2}),d.push({k:"line",pts:A,stroke:T,lw:w})},Ya=r.leg*l,Za=r.arm*l,kt=Math.max(r.arm/.22,.9);if(i.hipsOk)for(const[d,m,w,T]of[[I,P.leftKnee,P.leftAnkle,-1],[R,P.rightKnee,P.rightAnkle,1]]){const A=c(m),q=c(w);if(!A.ok)continue;const Te=K(d,F(u,-.12*l)),ne=q.ok?[Te,A,q]:[Te,A];bt(me,ne,Ya,h.limbs),b("joints")&&me.push({k:"circle",x:A.x,y:A.y,r:.15*l*kt,fill:h.accent,...k}),q.ok&&me.push(xa(t,q,i,T,y,r.foot))}for(const[d,m,w,T]of[[g,P.leftElbow,P.leftWrist,-1],[N,P.rightElbow,P.rightWrist,1]]){const A=c(m),q=c(w);if(b("pauldrons")){const le=K(d,F(u,.02*l));ge.push({k:"ellipse",x:le.x,y:le.y,rx:.25*l,ry:.17*l,rot:i.angle+T*.25,fill:h.body,...k});const de=K(le,F(u,.05*l));ge.push({k:"ellipse",x:de.x,y:de.y,rx:.17*l,ry:.07*l,rot:i.angle+T*.25,fill:h.belly})}if(!A.ok)continue;const ne=r.armsOverHead&&(A.x-f.x)*u.x+(A.y-f.y)*u.y<-.25*l?yt:ge,xt=K(d,F(u,.04*l));if(bt(ne,q.ok?[xt,A,q]:[xt,A],Za,h.limbs),b("joints")&&ne.push({k:"circle",x:A.x,y:A.y,r:.13*l*kt,fill:h.accent,...k}),!q.ok)continue;const ue=Ce(X(q,A)),Oe=K(q,F(ue,.05*l));if(b("feathers"))for(const le of[-.55,0,.55]){const de=Math.cos(le),mt=Math.sin(le)*T,Pe={x:ue.x*de-ue.y*mt,y:ue.x*mt+ue.y*de},gt=K(Oe,F(Pe,.16*l));ne.push({k:"ellipse",x:gt.x,y:gt.y,rx:.2*l,ry:.09*l,rot:Math.atan2(Pe.y,Pe.x),fill:h.hands??h.accent,...k})}ne.push({k:"circle",x:Oe.x,y:Oe.y,r:r.hand*l,fill:h.hands??h.limbs,...k})}if(b("wings"))for(const d of[-1,1]){const m=M([[d*v*.5,.05*l],[d*(v+.85*l),-.6*l],[d*(v+.72*l),.05*l],[d*(v+.45*l),-.02*l],[d*(v+.3*l),.32*l],[d*v*.6,.55*l]]);G.push({k:"path",d:_(m,.18),fill:h.accent,...k})}if(b("cape")){const d=p+.8*l,m=O+.36*l,w=M([[-v*.92,$+.04*l],[v*.92,$+.04*l],[v+.16*l,p*.5],[m,d],[m*.5,d-.1*l],[0,d],[-m*.5,d-.1*l],[-m,d],[-v-.16*l,p*.5]]);G.push({k:"path",d:L(w,.6),fill:h.accent,...k})}if(b("backpack")){const d=x(0,.35*l);G.push({k:"rect",x:d.x,y:d.y,w:v*2+.34*l,h:.8*l,r:.16*l,rot:i.angle,fill:t.extraColors?.[0]??h.limbs,...k})}if(b("tank")){const d=x(v*.95,.24*l),m=t.extraColors?.[0]??h.accent,w=x(v*.95,-.3*l);G.push({k:"rect",x:w.x,y:w.y,w:.14*l,h:.16*l,r:.04*l,rot:i.angle,fill:h.outline}),G.push({k:"rect",x:d.x,y:d.y,w:.34*l,h:1*l,r:.17*l,rot:i.angle,fill:m,...k})}if(i.hipsOk&&!s.portrait&&G.push(...ma(t,i,O,y)),b("tentacles")&&i.hipsOk)for(const d of[-1,1]){const m=M([[d*O*.7,p*.9],[d*(O+.22*l),p+.3*l],[d*(O+.48*l),p+.22*l],[d*(O+.5*l),p-.02*l],[d*(O+.34*l),p-.06*l]]);G.push({k:"path",d:fe(m),stroke:h.outline,lw:.2*l+y*2}),G.push({k:"path",d:fe(m),stroke:h.limbs,lw:.2*l})}const V=Math.max(v,O)*r.bulge;if(b("wool")){for(const[m,w]of[[v*.7,$+.02*l],[V,p*.3],[V*1.02,p*.62],[(V+O)/2,p*.92],[O*.55,re]])for(const T of[-1,1]){const A=x(T*m,w);z.push({k:"circle",x:A.x,y:A.y,r:.2*l,fill:h.body,...k})}const d=x(0,re+.02*l);z.push({k:"circle",x:d.x,y:d.y,r:.2*l,fill:h.body,...k})}if(b("robe")){const d=p+.58*l,m=O*1.4;z.push({k:"path",d:L(M([[-v,$],[0,$-.04*l],[v,$],[V,p*.55],[m,d],[0,d+.06*l],[-m,d],[-V,p*.55]]),.7),fill:h.body,...k});const w=M([[-m*.94,d-.1*l],[0,d-.04*l],[m*.94,d-.1*l]]);z.push({k:"path",d:fe(w),stroke:t.extraColors?.[0]??h.accent,lw:.07*l})}else if(b("sheet")){const d=p+.78*l,m=O*1.3;z.push({k:"path",d:L(M([[-v,$],[v,$],[V,p*.55],[m,d],[m*.5,d-.2*l],[0,d],[-m*.5,d-.2*l],[-m,d],[-V,p*.55]]),.9),fill:h.body,...k})}else z.push({k:"path",d:L(M([[-v,$],[0,$-.04*l],[v,$],[V,p*.55],[O,re],[0,re+.03*l],[-O,re],[-V,p*.55]]),.85),fill:h.body,...k});const W=Math.min(v,O);if(b("pocket")){const d=x(0,p*.74);z.push({k:"rect",x:d.x,y:d.y,w:W*1.3,h:.3*l,r:.1*l,rot:i.angle,fill:h.belly,stroke:h.outline,lw:y*.8})}else if(b("racing-stripe"))for(const d of[-.1,.1]){const m=x(d*l,$+.02*l),w=x(d*l,re-.04*l);z.push({k:"line",pts:[m.x,m.y,w.x,w.y],stroke:h.belly,lw:.1*l})}else if(h.belly&&h.belly!==h.body&&!b("panel")&&!b("sheet")&&!b("stripes")){const d=x(0,p*.58);z.push({k:"ellipse",x:d.x,y:d.y,rx:W*.64,ry:Math.max(p*.36,.2*l),rot:i.angle,fill:h.belly})}if(b("spots")){const d=t.extraColors?.[1]??h.belly;for(const[m,w,T]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){const A=x(m*W,w*p);z.push({k:"circle",x:A.x,y:A.y,r:T*l,fill:d})}}if(b("stripes")){const d=t.extraColors?.[1]??h.accent;for(const m of[.22,.44,.66]){const w=x(-W*.98,p*m),T=x(W*.98,p*m);z.push({k:"line",pts:[w.x,w.y,T.x,T.y],stroke:d,lw:.1*l})}}if(b("straps")){const d=t.extraColors?.[1]??h.outline;for(const m of[-1,1]){const w=x(m*v*.62,$+.02*l),T=x(m*W*.62,p*.72);z.push({k:"line",pts:[w.x,w.y,T.x,T.y],stroke:h.outline,lw:.13*l+y*2}),z.push({k:"line",pts:[w.x,w.y,T.x,T.y],stroke:d,lw:.13*l})}}if(b("belt")){const d=x(0,p*.9);z.push({k:"rect",x:d.x,y:d.y,w:O*1.92,h:.17*l,r:.06*l,rot:i.angle,fill:t.extraColors?.[2]??"#4a3426",...k}),z.push({k:"rect",x:d.x,y:d.y,w:.2*l,h:.19*l,r:.04*l,rot:i.angle,fill:"#ffd84a",...k})}if(b("emblem")){const d=x(0,p*.4),m=t.extraColors?.[0]??h.accent,w=_([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);z.push({k:"group",x:d.x,y:d.y,rot:i.angle,s:l,items:[{k:"path",d:w,fill:m,stroke:h.outline,lw:y/l},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:be,fill:m===h.accent?"#ffffff":h.accent}]}]})}if(b("panel")){const d=x(0,p*.5);z.push({k:"rect",x:d.x,y:d.y,w:W*1.2,h:.38*l,r:.1*l,rot:i.angle,fill:"#24323d",...k}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,T)=>{const A=x((T-1)*W*.34,p*.5);z.push({k:"circle",x:A.x,y:A.y,r:.075*l,fill:w})})}if(b("badge")){const d=x(-W*.42,p*.36);z.push({k:"circle",x:d.x,y:d.y,r:.15*l,fill:h.accent,...k}),z.push({k:"group",x:d.x,y:d.y,rot:i.angle,s:.09*l,items:[{k:"path",d:be,fill:"#ffffff"}]})}if(b("star")){const d=x(-W*.5,p*.3),m=.15*l;z.push({k:"group",x:d.x,y:d.y,rot:i.angle-.2,s:m,items:[{k:"path",d:be,fill:t.extraColors?.[0]??"#ffd84a",stroke:h.outline,lw:y*.8/m}]})}if(b("scarf")){const d=Math.max(.04,r.head*(1-r.neck)-.06)*l,m=x(0,d),w=t.extraColors?.[0]??h.accent,T=x(v*.45,d+.28*l);z.push({k:"rect",x:T.x,y:T.y,w:.16*l,h:.42*l,r:.06*l,rot:i.angle+.15,fill:w,...k}),z.push({k:"rect",x:m.x,y:m.y,w:v*2.05,h:.2*l,r:.1*l,rot:i.angle,fill:w,...k})}const Ka={k:"group",x:i.head.x,y:i.head.y,rot:i.headRot,s:i.headR,items:ka(t,y/i.headR)};return[...G,...me,...z,...ge,Ka,...yt]}var tt=new WeakMap,ba=64;function ka(e,t){const a=Number(t.toPrecision(4));let s=tt.get(e);s||tt.set(e,s=new Map);let o=s.get(a);return o||(s.size>=ba&&s.clear(),s.set(a,o=We(e,a))),o}function xa(e,t,a,s,o,r){const i=e.palette,{d:c,r:h}=a,f=a.U*r,n=K(K(t,F(c,.07*f)),F(h,s*.06*f)),u={stroke:i.outline,lw:o},l=i.feet??i.limbs;if(e.bodyExtras.includes("fins")){const p=_([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:n.x,y:n.y,rot:a.angle,s:f,items:[{k:"path",d:p,fill:l,stroke:i.outline,lw:o/f},{k:"line",pts:[0,.06,0,.38],stroke:i.outline,lw:o/f,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:n.x,y:n.y,rx:.27*f,ry:.11*f,rot:a.angle,fill:l,...u}:e.bodyExtras.includes("boots")?{k:"rect",x:n.x,y:n.y,w:.4*f,h:.24*f,r:.09*f,rot:a.angle,fill:l,...u}:{k:"ellipse",x:n.x,y:n.y,rx:.2*f,ry:.13*f,rot:a.angle,fill:l,...u}}function ma(e,t,a,s){const o=e.palette,{U:r,L:i,S:c,r:h,d:f}=t,n=(y,k)=>({x:c.x+h.x*y+f.x*k,y:c.y+h.y*y+f.y*k}),u=y=>y.map(([k,x])=>n(k,x)),l={stroke:o.outline,lw:s},p=(y,k,x)=>[{k:"path",d:fe(y),stroke:o.outline,lw:k+s*2},{k:"path",d:fe(y),stroke:x,lw:k}],b=[];switch(e.tail){case"none":break;case"fluffy":{const y=u([[a*.5,i*.95],[a+.28*r,i*1],[a+.72*r,i*.62],[a+.78*r,i*.12],[a+.52*r,i*.32],[a+.3*r,i*.6],[a*.6,i*.7]]);b.push({k:"path",d:L(y),fill:o.body,...l});const k=n(a+.72*r,i*.2);b.push({k:"ellipse",x:k.x,y:k.y,rx:.13*r,ry:.2*r,rot:t.angle+.25,fill:o.belly,...l});break}case"brush":{const y=u([[a*.4,i*.98],[a+.42*r,i*1.06],[a+.98*r,i*.66],[a+1.06*r,i*.12],[a+.86*r,-.04*r],[a+.66*r,i*.36],[a+.3*r,i*.66],[a*.5,i*.68]]);b.push({k:"path",d:L(y),fill:o.body,...l});const k=u([[a+1.03*r,i*.36],[a+1.06*r,i*.12],[a+.86*r,-.04*r],[a+.72*r,i*.24],[a+.86*r,i*.34]]);b.push({k:"path",d:L(k),fill:o.belly,...l});break}case"pom":{const y=n(a+.06*r,i*.88);b.push({k:"circle",x:y.x,y:y.y,r:.2*r,fill:o.belly,...l});break}case"long":case"striped":case"tuft":{const y=u([[a*.6,i*.9],[a+.35*r,i*.85],[a+.58*r,i*.4],[a+.5*r,-.02*r]]);if(b.push(...p(y,.14*r,o.body)),e.tail==="tuft"){const k=y[y.length-1];b.push({k:"circle",x:k.x,y:k.y,r:.16*r,fill:e.extraColors?.[0]??o.accent,...l})}if(e.tail==="striped"){for(const x of[.35,.6,.85]){const M=n(a+.35*r+.22999999999999998*r*(x*1.4>1?1:x*1.4),i*(.85-.85*x));b.push({k:"line",pts:[M.x-h.x*.08*r,M.y-h.y*.08*r,M.x+h.x*.08*r,M.y+h.y*.08*r],stroke:e.extraColors?.[0]??o.outline,lw:.06*r})}const k=y[y.length-1];b.push({k:"circle",x:k.x,y:k.y,r:.07*r,fill:e.extraColors?.[0]??o.outline})}break}case"curl":{const y=u([[a*.6,i*.9],[a+.4*r,i*.88],[a+.62*r,i*.45],[a+.5*r,i*.12],[a+.3*r,i*.24],[a+.36*r,i*.42]]);b.push(...p(y,.12*r,o.limbs));break}case"fish":{const y=u([[a*.6,i*.9],[a+.36*r,i*.86],[a+.6*r,i*.5]]);b.push(...p(y,.17*r,o.body));const k=y[y.length-1],x=_([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);b.push({k:"group",x:k.x,y:k.y,rot:t.angle+.35,s:r,items:[{k:"path",d:x,fill:o.body,stroke:o.outline,lw:s/r}]});break}case"plume":{const y=e.extraColors??[o.accent];[0,1,2].forEach(k=>{const x=n(a+(.12+k*.13)*r,i+(.32-k*.06)*r);b.push({k:"ellipse",x:x.x,y:x.y,rx:.11*r,ry:.44*r,rot:t.angle-.55+k*.28,fill:y[(k+1)%y.length],...l})});break}case"spiky":case"arrow":{const y=u([[a*.3,i*.55],[a+.35*r,i*.68],[a+.95*r,i*.86],[a+.35*r,i*1.08],[a*.3,i*1.08]]);if(e.tail==="spiky"){for(const k of[.15,.45,.72]){const x=a+(.2+k*.7)*r,M=i*(.66+k*.19);b.push({k:"path",d:_(u([[x-.12*r,M+.05*r],[x,M-.2*r],[x+.12*r,M+.07*r]]),.2),fill:o.accent,...l})}b.push({k:"path",d:L(y,.7),fill:o.body,...l})}else{const k=u([[a*.6,i*.9],[a+.4*r,i*.92],[a+.62*r,i*.5],[a+.62*r,i*.18]]);b.push(...p(k,.13*r,o.body));const x=k[k.length-1];b.push({k:"group",x:x.x,y:x.y,rot:t.angle,s:r,items:[{k:"path",d:_([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:o.accent,stroke:o.outline,lw:s/r}]})}break}}return b}var ga={nose:[0,-.62],leftShoulder:[-.42,0],rightShoulder:[.42,0],leftElbow:[-.58,.5],rightElbow:[.58,.5],leftWrist:[-.66,.98],rightWrist:[.66,.98],leftHip:[-.27,1],rightHip:[.27,1],leftKnee:[-.31,1.6],rightKnee:[.31,1.6],leftAnkle:[-.33,2.18],rightAnkle:[.33,2.18]};function wa(e,{cx:t=.5,cy:a=.36,T:s=.18}={}){const o={...ga,...e},r=new Array(Re*3).fill(0),i=(f,[n,u],l=.99)=>{r[f*3]=t+n*s,r[f*3+1]=a+u*s,r[f*3+2]=l};for(const f of Object.keys(P))i(P[f],o[f]);const c=o.tilt??0,h=(f,n)=>[o.nose[0]+f*Math.cos(c)-n*Math.sin(c),o.nose[1]+f*Math.sin(c)+n*Math.cos(c)];return i(J.leftEye,h(-.1,-.08)),i(J.rightEye,h(.1,-.08)),i(J.leftEar,h(-.22,-.02)),i(J.rightEar,h(.22,-.02)),r}var va=()=>wa({}),at=.5,Ea=.15,Ma=class{constructor(e={}){Q(this,"tracks",new Map),Q(this,"offset",NaN),Q(this,"lastArrival",NaN),Q(this,"interval",33),Q(this,"lastT",NaN),Q(this,"lostMs"),Q(this,"maxExtrapolateMs"),this.lostMs=e.lostMs??250,this.maxExtrapolateMs=e.maxExtrapolateMs??25}get delayMs(){return this.interval}push(e,t,a,s=st()){Number.isFinite(t)||(t=s),this.clock(t,s);const o=this.tracks.get(e);if(!o||t-o.tb>this.lostMs||t<o.tb-this.lostMs||a.length!==o.b.length){this.tracks.set(e,{a:null,ta:t,b:a,tb:t,out:null,outAt:NaN});return}if(a===o.b||t<=o.tb){t===o.tb&&a!==o.b&&(o.b=a,o.out=null);return}o.a=o.b,o.ta=o.tb,o.b=a,o.tb=t,o.out=null}at(e,t=st()){const a=this.tracks.get(e);if(!a)return null;if(!a.a)return a.b;if(a.out&&a.outAt===t)return a.out;const s=t-this.offset-this.interval,o=a.tb-a.ta,r=Math.min(o*.5,this.maxExtrapolateMs),i=Math.min(Math.max((s-a.ta)/o,0),1+r/o);return a.out=Aa(a.a,a.b,i),a.outAt=t,a.out}forget(e){this.tracks.delete(e)}clear(){this.tracks.clear()}clock(e,t){const a=t-e;if(!Number.isFinite(this.offset)||a<this.offset||a>this.offset+1e3?this.offset=a:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(a-this.offset,(t-this.lastArrival)/1e3)),this.lastArrival=t,Number.isFinite(this.lastT)&&e>this.lastT){const s=e-this.lastT;s<this.interval*3+20&&(this.interval+=(Math.min(Math.max(s,8),100)-this.interval)*.1)}e<=this.lastT||(this.lastT=e)}},st=()=>globalThis.performance?.now()??Date.now();function Aa(e,t,a){const s=t.slice(),o=a<.5?e:t;for(let r=0;r+2<t.length;r+=3){const i=e[r],c=e[r+1],h=t[r],f=t[r+1];e[r+2]>=at&&t[r+2]>=at&&Math.abs(h-i)+Math.abs(f-c)<Ea?(s[r]=i+(h-i)*a,s[r+1]=c+(f-c)*a,s[r+2]=e[r+2]+(t[r+2]-e[r+2])*Math.min(a,1)):(s[r]=o[r],s[r+1]=o[r+1],s[r+2]=o[r+2])}return s}var Ga=Ye.map(e=>e.id),xe=new Map(Ye.map(e=>[e.id,e])),ot=xe.get("fox"),Ca=e=>typeof e=="string"&&xe.has(e),Sa=e=>xe.get(e),rt=e=>typeof e=="string"?xe.get(e)??ot:e;function za(e,t,a,s,o={}){const r=ze(t,rt(a),s,{mirrored:o.mirrored});return r.length?(e.save(),o.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(o.alpha,0),1)),Me(e,r),e.restore(),!0):!1}function Ta(e,t){const a=rt(e),s=va(),o=Xe(a),r=Se(s,{x:0,y:0,w:1,h:1},{band:o}),i=-lt(We(a,.05)).minY,h=Math.min(.27,.43/Math.max(i,1))*t/ae[o].head/r.U,f=.5*t+Math.min(0,(i-1.6)*.06*t),n={x:t/2-r.head.x*h,y:f-r.head.y*h,w:h,h};return ze(s,a,n,{portrait:!0})}function Oa(e,t,a=.5){if(!e||e.length!==t.length)return t.slice();const s=t.slice();for(let o=0;o+2<t.length;o+=3){const r=e[o+2],i=t[o+2],c=r>=.5,h=i>=.5;c&&i>=.3&&(s[o+2]=Math.max(i,.5));const f=Math.hypot(t[o]-e[o],t[o+1]-e[o+1]);if(c&&h&&f<.15){const n=a*Math.min(1,nt+(1-nt)*f/Pa);s[o]=e[o]+(t[o]-e[o])*n,s[o+1]=e[o+1]+(t[o+1]-e[o+1])*n}else c&&!h&&s[o+2]>=.5&&(s[o]=e[o],s[o+1]=e[o+1])}return Da(e,t,s,a*La),s}var nt=.1,Pa=.03,La=.35,_a=11;function Da(e,t,a,s){const o=P.leftShoulder*3,r=P.rightShoulder*3,i=(u,l)=>u[l+2]>=.5;if(!i(e,o)||!i(e,r)||!i(t,o)||!i(t,r))return;const c=(u,l)=>(u[o+l]+u[r+l])/2,h=[c(e,0),c(e,1)],f=[c(t,0),c(t,1)],n=[c(a,0),c(a,1)];for(let u=0;u<_a&&u*3+2<t.length;u++){const l=u*3;if(!i(e,l)||!i(t,l))continue;const p=[e[l]-h[0],e[l+1]-h[1]],b=[t[l]-f[0],t[l+1]-f[1]];Math.hypot(b[0]-p[0],b[1]-p[1])>=.15||(a[l]=n[0]+p[0]+(b[0]-p[0])*s,a[l+1]=n[1]+p[1]+(b[1]-p[1])*s)}}function lt(e){const t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=(s,o)=>{t.minX=Math.min(t.minX,s),t.minY=Math.min(t.minY,o),t.maxX=Math.max(t.maxX,s),t.maxY=Math.max(t.maxY,o)};for(const s of e){const o="lw"in s&&s.stroke?(s.lw??1)/2:0;switch(s.k){case"circle":a(s.x-s.r-o,s.y-s.r-o),a(s.x+s.r+o,s.y+s.r+o);break;case"ellipse":case"rect":{const r=s.k==="ellipse"?s.rx:s.w/2,i=s.k==="ellipse"?s.ry:s.h/2,c=Math.max(r,i)+o;a(s.x-c,s.y-c),a(s.x+c,s.y+c);break}case"path":{const r=Wt(s.d);for(let i=0;i+1<r.length;i+=2)a(r[i]-o,r[i+1]-o),a(r[i]+o,r[i+1]+o);break}case"line":for(let r=0;r+1<s.pts.length;r+=2)a(s.pts[r]-o,s.pts[r+1]-o),a(s.pts[r]+o,s.pts[r+1]+o);break;case"group":{const r=lt(s.items);if(!Number.isFinite(r.minX))break;const i=s.s??1,c=Math.cos(s.rot??0),h=Math.sin(s.rot??0);for(const[f,n]of[[r.minX,r.minY],[r.maxX,r.minY],[r.minX,r.maxY],[r.maxX,r.maxY]])a(s.x+(f*c-n*h)*i,s.y+(f*h+n*c)*i);break}}}return t}var Na=()=>{const e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},it=()=>globalThis.performance?.now()??Date.now(),ct=class{constructor(e=Na){Q(this,"now",e),Q(this,"known",new Map),Q(this,"smoothed",new Map),Q(this,"times",new WeakMap),Q(this,"lerp",new Ma),Q(this,"drawnAt",NaN),Q(this,"drawn",0),Q(this,"smoothedBody",(t,a={})=>{const s=a.interpolate!==!1;if(typeof t=="number"){const o=this.smoothed.get(t);return o?s?this.lerp.at(t,this.tick())??o.body:o.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,ft(a.smooth),s)})}note(e,t,a=it()){for(const s of e)this.known.set(s.id,this.resolve(s.id,s.avatar)),t!==void 0&&Number.isFinite(t)&&Array.isArray(s.body)&&this.times.set(s.body,{t,arrival:a})}of(e){return typeof e=="object"&&e!==null?e.avatar!==void 0?this.resolve(e.id,e.avatar):this.of(e.id):this.known.get(e)??Be(e-1)}posed(e,t,a,s=!0){const o=this.smooth(e,t,a);return s?this.lerp.at(e,this.tick())??o:o}smooth(e,t,a){const s=this.smoothed.get(e);if(s&&s.raw===t&&s.amount===a)return s.body;s&&s.amount!==a&&this.lerp.forget(e);const o=a<1?Oa(s?.body,t,a):t;this.smoothed.set(e,{raw:t,body:o,amount:a});const r=this.times.get(t),i=r?.arrival??it();return this.lerp.push(e,r?.t??i,o,i),o}takeDrawn(){const e=this.drawn;return this.drawn=0,e}tick(){const e=this.now();return e!==this.drawnAt&&(this.drawnAt=e,this.drawn++),e}resolve(e,t){return Ca(t)?t:Be(e-1)}};function Ia(e,t){const a=typeof e.getTransform=="function"?e.getTransform():null,s=a&&Math.hypot(a.a,a.b)||1,o=a&&Math.hypot(a.c,a.d)||1,r=(e.canvas?.width??0)/s,i=(e.canvas?.height??0)/o;return t?{x:t.x*r,y:t.y*i,w:t.w*r,h:t.h*i}:{x:0,y:0,w:r,h:i}}var ft=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function ht(e,t){return(a,s,o,r,i={})=>{const c=Array.isArray(s)?null:s,h=c?c.body:s;if(!Array.isArray(h))return null;const f=typeof o=="string"?o:e.of(typeof o=="number"?o:c??1),n=typeof o=="number"?o:c?.id,u=n!==void 0?e.posed(n,h,ft(i.smooth),i.interpolate!==!1):h;return za(a,u,f,r??Ia(a,t().view),i.alpha!==void 0?{alpha:i.alpha}:{})?u:null}}function Ra(e){const t=new Map,a=(n,u)=>t.get(n)?.forEach(l=>l(u));let s=null,o=null;const r=new Map,i=[],c=n=>s?n(s):i.push(n),h=new ct,f=ht(h,()=>({view:null}));return e.then(n=>{s=n;const u=new Map;n.on("gesture",l=>a(l.gesture,{player:l.player})),n.on("pause",l=>a("pause",{reason:l.reason==="distance"?"distance":"user"})),n.on("resume",()=>a("resume",{})),n.on("break-start",()=>a("break-start",{})),n.on("break-done",l=>a("break-end",{shown:l.shown})),n.onBackdrop((l,p)=>a("backdrop",{backdrop:l,view:p})),n.on("turn",l=>a("turn",{players:[...l.players]})),n.on("frame",l=>{a("players",{players:l.players});for(const p of l.players)a("hands",{player:p.id,left:p.leftHand,right:p.rightHand}),u.get(p.id)!==p.shape&&(u.set(p.id,p.shape),a("shape",{player:p.id,shape:p.shape}))}),o=Qa(n),a("start",o),i.splice(0).forEach(l=>l(n))}),{on(n,u){const l=t.get(n)??new Set;return t.set(n,l),l.add(u),n==="start"&&o&&u(o),()=>{l.delete(u)}},ready:()=>c(n=>n.ready()),score:(n,u)=>c(l=>{const p=u??dt(l);r.set(p,n),l.score(p,n)}),break:n=>new Promise(u=>c(l=>{l.break(n).then(u)})),end:n=>c(u=>u.end(typeof n=="number"?Ba(u,n,r):n.map(l=>({player:l.player,score:l.score,stars:l.stars??2})))),keys:(n,u)=>c(l=>{_t(l,n,u)}),pointer:n=>c(u=>{Nt(u,n)}),get players(){return s?.players??ut},get turns(){return s?.turns??ut},get input(){return s?.input??"body"},get hasPointer(){return s?.pointer??!1},get view(){return s?.view??null},get device(){return s?.device??null},reportStats:n=>s?.reportStats(n),toScreen:n=>s?s.toScreen(n):je(null,n),avatarOf:n=>s?s.avatarOf(n):h.of(n),drawAvatar:(...n)=>s?s.drawAvatar(...n):f(...n),smoothedBody:(...n)=>s?s.smoothedBody(...n):h.smoothedBody(...n)}}var ut=Object.freeze([]),Qa=e=>({ageRange:e.ageRange,players:e.players,locale:e.locale,mode:e.mode,backdrop:e.backdrop,view:e.view,device:e.device,turns:e.turns,input:e.input,pointer:e.pointer}),dt=e=>e.input==="remote"?e.players[0]??1:1;function Ba(e,t,a){const s=dt(e);return e.input!=="remote"?[{player:s,score:t,stars:2}]:[...e.turns.slice(0,Math.max(e.turns.indexOf(s),0)).map(r=>({player:r,score:a.get(r)??0,stars:2})),{player:s,score:t,stars:2}]}var Fa=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",a=>a.source===e.parent&&t(a.data))}),Ha=1e4,ja=1e3;function Ua(e=Fa()){return new Promise((t,a)=>{const s=new Map,o=[];let r=!1,i=!1,c=!1,h="none",f=null,n="body",u=Object.freeze([]),l=u;const p=new Set,b=new ct,y=ht(b,()=>({view:f})),k=b.smoothedBody,x=setTimeout(()=>a(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),Ha);e.listen(M=>{if(typeof M!="object"||M===null||M.ns!==Fe)return;const g=M;if(g.type==="init"&&!c){if(g.v!==Ie)return clearTimeout(x),a(new Error(`Fabi Play: protocol ${g.v}, this SDK speaks ${Ie}`));c=!0,clearTimeout(x),h=g.backdrop==="video"?"video":"none",f=He(g.view)??null;const N=Bt(g.device)??null;n=g.input==="remote"?"remote":"body";const I=n==="remote"&&g.pointer===!0;u=Object.freeze(Array.isArray(g.players)?[...g.players]:[]);const R=n==="remote"&&u.length===1?jt(g.turns):void 0;l=Object.freeze(R&&R[0]===u[0]?R:[...u]);let ee={};if(g.stats===!0){let C=performance.now();setInterval(()=>{const O=performance.now();e.post(ie({type:"stats",renderFps:Math.round(b.takeDrawn()*1e3/Math.max(O-C,1)),...ee})),C=O},ja).unref?.()}t({locale:g.locale,mode:g.mode,get players(){return u},turns:l,input:n,pointer:I,muted:g.muted,ageRange:g.ageRange??"6-8",get backdrop(){return h},get view(){return f},device:N,reportStats:C=>{ee=Ft(C)},toScreen:C=>je(f,C),avatarOf:C=>b.of(C),drawAvatar:y,smoothedBody:k,onBackdrop(C){return p.add(C),()=>{p.delete(C)}},on(C,v){const O=s.get(C)??new Set;return s.set(C,O),O.add(v),()=>{O.delete(v)}},ready:()=>e.post(ie({type:"ready"})),score:(C,v)=>e.post(ie({type:"score",player:C,score:v})),break:(C="level")=>new Promise(v=>{o.push({reason:C,done:v}),e.post(ie({type:"break",reason:C}))}),end:C=>e.post(ie({type:"end",scores:C}))})}else if(c){let N=g;if(g.type==="frame"&&Array.isArray(g.players)&&b.note(g.players,g.t),g.type==="backdrop"){if(g.backdrop!=="video"&&g.backdrop!=="none")return;const I=He(g.view)??null;if(g.backdrop===h&&$a(I,f))return;h=g.backdrop,f=I,N={type:"backdrop",backdrop:h,...f?{view:f}:{}};for(const R of[...p])R(h,f)}if(g.type==="turn"){const I=n==="remote"&&r&&!i&&o[0]?.reason==="turn"?Ht(g.players):void 0,R=u[0];if(!I||R===void 0||l.indexOf(I[0])<=l.indexOf(R))return;i=!0,u=Object.freeze(I),N={type:"turn",players:[...I]}}g.type==="break-start"&&(r=o.length>0);for(const I of s.get(g.type)??[])I(N);g.type==="break-done"&&(r=i=!1,o.shift()?.done(g.shown))}else return})})}var $a=(e,t)=>e===t||e!==null&&t!==null&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,pt={};Le(pt,{BAND_BODY:()=>ae,DEFAULT_AVATAR:()=>ot,avatarById:()=>Sa,avatarShapes:()=>ze,drawShapes:()=>Me,frameOf:()=>Se,iconShapes:()=>Ta});function qa(e){const t=Ua(),a=Ra(t);e?.dataset.mute!=="manual"&&St(t);const s=Object.assign(a,{avatars:{...pt}});window.FabiPlay=s;const o=e?.dataset.keys;o&&a.keys(Tt(o));const r=e?.dataset.pointer;return r&&a.pointer({hand:r==="left"||r==="right"?r:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?a.ready():window.addEventListener("load",()=>a.ready(),{once:!0})),s}return te.exports.install(we)});