@fabi-play/sdk 0.4.0 → 0.7.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.
- package/README.md +59 -1
- package/dist/avatars.d.ts +3 -3
- package/dist/avatars.js +1 -1
- package/dist/chunks/{chunk-QUFAT4K5.js → chunk-WS2JRQ53.js} +73 -0
- package/dist/fabi-play.d.ts +100 -3
- package/dist/fabi-play.js +1 -1
- package/dist/fabi-play.schema.json +15 -0
- package/dist/fabi-play.umd.js +99 -4
- package/dist/fabi-play.umd.min.js +1 -1
- package/dist/index.d.ts +100 -3
- package/dist/index.js +34 -4
- package/dist/integrity.json +6 -6
- package/package.json +3 -3
package/dist/fabi-play.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fabi-play/sdk 0.
|
|
1
|
+
/*! @fabi-play/sdk 0.7.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); });
|
|
@@ -351,6 +351,73 @@ function parseView(v) {
|
|
|
351
351
|
return isNumber(x) && isNumber(y) && isNumber(w) && isNumber(h) && w > 0 && h > 0 ? { x, y, w, h } : void 0;
|
|
352
352
|
}
|
|
353
353
|
var toScreen = (view, p) => view ? { x: view.x + p.x * view.w, y: view.y + p.y * view.h } : { x: p.x, y: p.y };
|
|
354
|
+
var AIM_VISIBLE = 0.5;
|
|
355
|
+
var HAND_SPACE = { left: 1.6, top: 1.6, w: 3.2, h: 3 };
|
|
356
|
+
var TORSO_PER_SHOULDER_WIDTH = 1.2;
|
|
357
|
+
function aimPoint(who, side, opts = {}) {
|
|
358
|
+
const body = Array.isArray(who) ? who : who.body;
|
|
359
|
+
if (!Array.isArray(body)) return null;
|
|
360
|
+
const w = side === "left" ? P.leftWrist : P.rightWrist;
|
|
361
|
+
const at = (i) => isNumber(body[i * 3]) && isNumber(body[i * 3 + 1]) && (body[i * 3 + 2] ?? 0) >= AIM_VISIBLE ? i : -1;
|
|
362
|
+
if (at(w) < 0) return null;
|
|
363
|
+
const wx = body[w * 3];
|
|
364
|
+
const wy = body[w * 3 + 1];
|
|
365
|
+
if (opts.orientation !== "portrait") return toScreen(opts.view, { x: wx, y: wy });
|
|
366
|
+
if (at(P.leftShoulder) < 0 || at(P.rightShoulder) < 0) return null;
|
|
367
|
+
const ls = P.leftShoulder * 3;
|
|
368
|
+
const rs = P.rightShoulder * 3;
|
|
369
|
+
const sx = (body[ls] + body[rs]) / 2;
|
|
370
|
+
const sy = (body[ls + 1] + body[rs + 1]) / 2;
|
|
371
|
+
const lh = P.leftHip * 3;
|
|
372
|
+
const rh = P.rightHip * 3;
|
|
373
|
+
const hx = (body[lh] + body[rh]) / 2;
|
|
374
|
+
const hy = (body[lh + 1] + body[rh + 1]) / 2;
|
|
375
|
+
let torso = isNumber(hx) && isNumber(hy) ? Math.hypot(hx - sx, hy - sy) : 0;
|
|
376
|
+
if (at(P.leftHip) < 0 || at(P.rightHip) < 0) torso = Math.max(torso, TORSO_PER_SHOULDER_WIDTH * Math.hypot(body[ls] - body[rs], body[ls + 1] - body[rs + 1]));
|
|
377
|
+
torso = Math.max(torso, 0.01);
|
|
378
|
+
return {
|
|
379
|
+
x: clamp01((wx - sx + HAND_SPACE.left * torso) / (HAND_SPACE.w * torso)),
|
|
380
|
+
y: clamp01((wy - sy + HAND_SPACE.top * torso) / (HAND_SPACE.h * torso))
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
var AIM_HOLD_MS = 300;
|
|
384
|
+
var AimHold = class {
|
|
385
|
+
constructor(holdMs = AIM_HOLD_MS) {
|
|
386
|
+
__publicField(this, "holdMs", holdMs);
|
|
387
|
+
__publicField(this, "last", /* @__PURE__ */ new Map());
|
|
388
|
+
}
|
|
389
|
+
/** A number for a player's hand. */
|
|
390
|
+
static key(player, side) {
|
|
391
|
+
return player * 2 + (side === "right" ? 1 : 0);
|
|
392
|
+
}
|
|
393
|
+
/** The aim to use at time t (ms) for the hand key, given what aimPoint said now (p, or null if lost). */
|
|
394
|
+
at(key, p, t) {
|
|
395
|
+
const l = this.last.get(key);
|
|
396
|
+
if (p) {
|
|
397
|
+
if (l) {
|
|
398
|
+
l.x = p.x;
|
|
399
|
+
l.y = p.y;
|
|
400
|
+
l.t = t;
|
|
401
|
+
} else this.last.set(key, { x: p.x, y: p.y, t });
|
|
402
|
+
return p;
|
|
403
|
+
}
|
|
404
|
+
if (!l) return null;
|
|
405
|
+
if (t - l.t <= this.holdMs) return { x: l.x, y: l.y };
|
|
406
|
+
this.last.delete(key);
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
/** Forgets every hand. */
|
|
410
|
+
clear() {
|
|
411
|
+
this.last.clear();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var MAX_SAFE_INSET = 0.25;
|
|
415
|
+
var NO_SAFE_AREA = Object.freeze({ top: 0, bottom: 0, left: 0, right: 0 });
|
|
416
|
+
function parseSafeArea(v) {
|
|
417
|
+
if (!isObject(v)) return void 0;
|
|
418
|
+
const f2 = (n) => isNumber(n) ? Math.min(Math.max(n, 0), MAX_SAFE_INSET) : 0;
|
|
419
|
+
return { top: f2(v.top), bottom: f2(v.bottom), left: f2(v.left), right: f2(v.right) };
|
|
420
|
+
}
|
|
354
421
|
var DEVICE_TIERS = ["high", "medium", "low"];
|
|
355
422
|
function parseDeviceHint(v) {
|
|
356
423
|
if (!isObject(v)) return void 0;
|
|
@@ -384,8 +451,10 @@ function parseTurnOrder(v) {
|
|
|
384
451
|
if (!Array.isArray(v) || v.length < 1 || v.length > MAX_PLAYERS || !v.every(isPlayerId) || new Set(v).size !== v.length) return void 0;
|
|
385
452
|
return [...v];
|
|
386
453
|
}
|
|
454
|
+
var COVER_ASPECT = 16 / 9;
|
|
387
455
|
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
388
456
|
var isNumber = (v) => typeof v === "number" && Number.isFinite(v);
|
|
457
|
+
var clamp01 = (n) => Math.min(Math.max(n, 0), 1);
|
|
389
458
|
var POSE_HEADER = 12;
|
|
390
459
|
var POSE_BODY_BYTES = LANDMARKS * 4;
|
|
391
460
|
var poseBytes = (bodies) => POSE_HEADER + bodies * POSE_BODY_BYTES;
|
|
@@ -2788,7 +2857,7 @@ function easy(connecting) {
|
|
|
2788
2857
|
p.on("frame", (f2) => {
|
|
2789
2858
|
emit("players", { players: f2.players });
|
|
2790
2859
|
for (const pl of f2.players) {
|
|
2791
|
-
emit("hands", { player: pl.id, left: pl.leftHand, right: pl.rightHand });
|
|
2860
|
+
emit("hands", { player: pl.id, left: pl.leftHand, right: pl.rightHand, aim: { left: p.aim(pl, "left"), right: p.aim(pl, "right") } });
|
|
2792
2861
|
if (shapes.get(pl.id) !== pl.shape) {
|
|
2793
2862
|
shapes.set(pl.id, pl.shape);
|
|
2794
2863
|
emit("shape", { player: pl.id, shape: pl.shape });
|
|
@@ -2838,6 +2907,12 @@ function easy(connecting) {
|
|
|
2838
2907
|
get muted() {
|
|
2839
2908
|
return play?.muted ?? false;
|
|
2840
2909
|
},
|
|
2910
|
+
get orientation() {
|
|
2911
|
+
return play?.orientation ?? "landscape";
|
|
2912
|
+
},
|
|
2913
|
+
get safeArea() {
|
|
2914
|
+
return play?.safeArea ?? NO_SAFE_AREA;
|
|
2915
|
+
},
|
|
2841
2916
|
get view() {
|
|
2842
2917
|
return play?.view ?? null;
|
|
2843
2918
|
},
|
|
@@ -2846,13 +2921,14 @@ function easy(connecting) {
|
|
|
2846
2921
|
},
|
|
2847
2922
|
reportStats: (s) => play?.reportStats(s),
|
|
2848
2923
|
toScreen: (p) => play ? play.toScreen(p) : toScreen(null, p),
|
|
2924
|
+
aim: (player, side) => play ? play.aim(player, side) : null,
|
|
2849
2925
|
avatarOf: (player) => play ? play.avatarOf(player) : early.of(player),
|
|
2850
2926
|
drawAvatar: (...args) => play ? play.drawAvatar(...args) : drawEarly(...args),
|
|
2851
2927
|
smoothedBody: (...args) => play ? play.smoothedBody(...args) : early.smoothedBody(...args)
|
|
2852
2928
|
};
|
|
2853
2929
|
}
|
|
2854
2930
|
var none = Object.freeze([]);
|
|
2855
|
-
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, canSavePicture: p.canSavePicture, muted: p.muted });
|
|
2931
|
+
var startInfo = (p) => ({ ageRange: p.ageRange, players: p.players, locale: p.locale, mode: p.mode, orientation: p.orientation, safeArea: p.safeArea, backdrop: p.backdrop, view: p.view, device: p.device, turns: p.turns, input: p.input, pointer: p.pointer, canSavePicture: p.canSavePicture, muted: p.muted });
|
|
2856
2932
|
var playingNow = (p) => p.input === "remote" ? p.players[0] ?? 1 : 1;
|
|
2857
2933
|
function endOf(p, score, last) {
|
|
2858
2934
|
const now2 = playingNow(p);
|
|
@@ -2919,6 +2995,9 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
2919
2995
|
let started = false;
|
|
2920
2996
|
let backdrop = "none";
|
|
2921
2997
|
let view = null;
|
|
2998
|
+
let orientation = "landscape";
|
|
2999
|
+
let latest = [];
|
|
3000
|
+
const hold = new AimHold();
|
|
2922
3001
|
let input = "body";
|
|
2923
3002
|
let players = Object.freeze([]);
|
|
2924
3003
|
let turns = players;
|
|
@@ -2951,6 +3030,9 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
2951
3030
|
backdrop = m.backdrop === "video" ? "video" : "none";
|
|
2952
3031
|
view = parseView(m.view) ?? null;
|
|
2953
3032
|
const device = parseDeviceHint(m.device) ?? null;
|
|
3033
|
+
orientation = m.orientation === "portrait" ? "portrait" : "landscape";
|
|
3034
|
+
const safe = parseSafeArea(m.safeArea);
|
|
3035
|
+
const safeArea = safe ? Object.freeze(safe) : NO_SAFE_AREA;
|
|
2954
3036
|
input = m.input === "remote" ? "remote" : "body";
|
|
2955
3037
|
const pointer2 = input === "remote" && m.pointer === true;
|
|
2956
3038
|
pictures = m.pictures === true;
|
|
@@ -2977,6 +3059,8 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
2977
3059
|
input,
|
|
2978
3060
|
pointer: pointer2,
|
|
2979
3061
|
muted: m.muted,
|
|
3062
|
+
orientation,
|
|
3063
|
+
safeArea,
|
|
2980
3064
|
ageRange: m.ageRange ?? "6-8",
|
|
2981
3065
|
get backdrop() {
|
|
2982
3066
|
return backdrop;
|
|
@@ -2989,6 +3073,14 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
2989
3073
|
reported = parseGameStats(s);
|
|
2990
3074
|
},
|
|
2991
3075
|
toScreen: (p) => toScreen(view, p),
|
|
3076
|
+
aim(player, side) {
|
|
3077
|
+
const id = typeof player === "number" ? player : player?.id;
|
|
3078
|
+
const frame = typeof player === "number" ? latest.find((f2) => f2.id === player) : player;
|
|
3079
|
+
const portrait = orientation === "portrait";
|
|
3080
|
+
const body = frame ? (backdrop !== "video" || portrait ? smoothedBody(frame) : null) ?? frame.body : null;
|
|
3081
|
+
const p = body ? aimPoint(body, side, { orientation, view }) : null;
|
|
3082
|
+
return portrait && typeof id === "number" ? hold.at(AimHold.key(id, side), p, performance.now()) : p;
|
|
3083
|
+
},
|
|
2992
3084
|
avatarOf: (player) => avatars.of(player),
|
|
2993
3085
|
drawAvatar: drawAvatar2,
|
|
2994
3086
|
smoothedBody,
|
|
@@ -3034,7 +3126,10 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
3034
3126
|
} else if (!started) return;
|
|
3035
3127
|
else {
|
|
3036
3128
|
let message = m;
|
|
3037
|
-
if (m.type === "frame" && Array.isArray(m.players))
|
|
3129
|
+
if (m.type === "frame" && Array.isArray(m.players)) {
|
|
3130
|
+
avatars.note(m.players, m.t);
|
|
3131
|
+
latest = m.players;
|
|
3132
|
+
}
|
|
3038
3133
|
if (m.type === "backdrop") {
|
|
3039
3134
|
if (m.backdrop !== "video" && m.backdrop !== "none") return;
|
|
3040
3135
|
const next = parseView(m.view) ?? null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! @fabi-play/sdk 0.4.0 | Fabi Play Kit License | https://docs.fabiplay.app */(function(_e,ue){var Ce=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return ue(Ce)}):typeof module=="object"&&module&&module.exports?module.exports=ue(Ce):_e.FabiPlay=ue(Ce)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(_e){"use strict";var ue={exports:{}},Ce=ue.exports,Se=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ot=Object.getOwnPropertyNames,_t=Object.prototype.hasOwnProperty,It=(e,t,o)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,je=(e,t)=>{for(var o in t)Se(e,o,{get:t[o],enumerable:!0})},Lt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ot(t))!_t.call(e,a)&&a!==o&&Se(e,a,{get:()=>t[a],enumerable:!(r=Pt(t,a))||r.enumerable});return e},Rt=e=>Lt(Se({},"__esModule",{value:!0}),e),W=(e,t,o)=>It(e,typeof t!="symbol"?t+"":t,o),He={};je(He,{install:()=>Ar}),ue.exports=Rt(He);function Dt(e,t=window){const o=new Set,r=t.AudioContext;r&&(t.AudioContext=class extends r{constructor(...i){super(...i),o.add(this)}});let a=[],n=[];Promise.resolve(e).then(i=>{i.on("break-start",()=>{a=[...t.document.querySelectorAll("audio, video")].filter(c=>!c.paused),a.forEach(c=>c.pause()),n=[...o].filter(c=>c.state==="running"),n.forEach(c=>{c.suspend()})}),i.on("break-done",()=>{a.forEach(c=>{c.play().catch(()=>{})}),n.forEach(c=>{c.resume()}),a=[],n=[]})})}var Nt={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function Qt(e){if(e.trim()==="default")return;const t={};for(const o of e.split(",")){const[r,a]=o.split(":").map(n=>n.trim());r&&a&&(t[r]=a)}return t}var Bt={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function Fe(e){const t=Bt[e];if(t)return{key:t[0],code:e,keyCode:t[1]};const o=/^Key([A-Z])$/.exec(e);if(o)return{key:o[1].toLowerCase(),code:e,keyCode:o[1].charCodeAt(0)};const r=/^Digit([0-9])$/.exec(e);if(r)return{key:r[1],code:e,keyCode:48+Number(r[1])};throw new Error(`Fabi Play: unknown key "${e}" (use Space, Enter, Arrow\u2026, KeyA\u2026, Digit0\u2026)`)}var jt=(e=document)=>({dispatch(t,o){const r=new KeyboardEvent(t,{key:o.key,code:o.code,bubbles:!0,cancelable:!0});for(const a of["keyCode","which"])Object.defineProperty(r,a,{get:()=>o.keyCode});(e.activeElement??e.body??e).dispatchEvent(r)}}),We=80,Ht=800;function Ft(e,t=Nt,o={}){const r=o.player===void 0&&e.input==="remote";let a=o.player??(r?e.players?.[0]??1:1);const n=o.target??jt(),i=o.setTimeout??((y,b)=>setTimeout(y,b)),c=new Set;let u=0;const f=y=>{const b=t[y];!b||c.has(y)||(c.add(y),n.dispatch("keydown",Fe(b)))},s=y=>{const b=t[y];!b||!c.has(y)||(c.delete(y),n.dispatch("keyup",Fe(b)))},h=y=>{f(y),i(()=>s(y),We)},l=y=>{if(y.player!==a)return;const b={"lane-left":-1,"lane-center":0,"lane-right":1};switch(y.gesture){case"jump":f("jump"),i(()=>s("jump"),Ht);break;case"land":s("jump");break;case"squat":f("squat");break;case"stand":s("squat");break;case"clap":h("clap");break;default:{const m=b[y.gesture];if(m===void 0)break;const A=m>u?"right":"left";for(let M=0;M<Math.abs(m-u);M++)i(()=>h(A),M*(We*2));u=m}}},d=y=>{const b=y.players.find(m=>m.id===a);b&&(b.shape==="arms-up"?f("arms-up"):s("arms-up"))},p=[e.on("gesture",l),e.on("frame",d),e.on("break-start",()=>[...c].forEach(s)),e.on("turn",y=>{r&&([...c].forEach(s),a=y.players[0]??a,u=0)})];return()=>{p.forEach(y=>y()),[...c].forEach(s)}}function Wt(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 o=(r,a,...n)=>{const i=e.elementFromPoint(r,a)??e.body;for(const c of n){const u={bubbles:!0,cancelable:!0,clientX:r,clientY:a,pointerId:1,pointerType:"touch",isPrimary:!0};i.dispatchEvent(c.startsWith("pointer")?new PointerEvent(c,u):new MouseEvent(c,u))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(r,a)=>o(r,a,"pointermove","mousemove"),click:(r,a)=>o(r,a,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(r,a,n)=>{t.style.transform=`translate(${r}px, ${a}px) scale(${1-n*.35})`,t.style.borderColor=n>0?"#EE6A43":"#FBE7B8"}}}function Xt(e,t={}){const o=t.player??1,r=t.hand??"any",a=t.dwellMs??800,n=t.radius??.04,i=t.target??Wt();let c=null,u=!1;return e.on("frame",f=>{const s=f.players.find(M=>M.id===o);if(!s)return;const l=r==="left"?s.leftHand:r==="right"?s.rightHand:((M,S)=>M&&S?M.y<S.y?M:S:M??S)(s.leftHand,s.rightHand);if(!l)return;const{width:d,height:p}=i.size(),y=l.x*d,b=l.y*p;i.move(y,b),(!c||Math.hypot(y-c.x,b-c.y)>n*Math.hypot(d,p))&&(c={x:y,y:b,t:f.t},u=!1);const A=u?0:Math.min((f.t-c.t)/a,1);A>=1&&(u=!0,i.click(c.x,c.y)),i.cursor(y,b,u?0:A)})}function Yt(e=document){const t=e.defaultView,o=t?.PointerEvent,r=t?.MouseEvent??MouseEvent;let a=null,n=null;const i=(c,u,f,s,h,l=null)=>{const d={bubbles:!0,cancelable:!0,composed:!0,view:t,clientX:f,clientY:s,screenX:f,screenY:s,button:0,buttons:h,relatedTarget:l,pointerId:1,pointerType:"mouse",isPrimary:!0};u.startsWith("pointer")?o&&c.dispatchEvent(new o(u,d)):c.dispatchEvent(new r(u,d))};return{size:()=>({width:t?.innerWidth??e.documentElement.clientWidth,height:t?.innerHeight??e.documentElement.clientHeight}),dispatch(c,u,f,s){const h=e.elementFromPoint(u,f)??e.body??e.documentElement;if(c==="pointermove"&&h!==a){if(a?.isConnected)for(const l of["pointerout","mouseout"])i(a,l,u,f,s,h);for(const l of["pointerover","mouseover"])i(h,l,u,f,s,a);a=h}if(c==="pointerdown"&&(n=h),c==="click"){const l=n===h;if(n=null,!l)return}i(h,c,u,f,s)}}}function qt(e){let t=null;const o=(r,a,n,i)=>{const{width:c,height:u}=e.size();for(const f of r)e.dispatch(f,a*c,n*u,i)};return{update(r){const a=t?.down??!1;(!t||t.x!==r.x||t.y!==r.y)&&o(["pointermove","mousemove"],r.x,r.y,a?1:0),r.down&&!a&&o(["pointerdown","mousedown"],r.x,r.y,1),!r.down&&a&&o(["pointerup","mouseup","click"],r.x,r.y,0),t={x:r.x,y:r.y,down:r.down}},cancel(){t?.down&&(o(["pointercancel","mouseup"],t.x,t.y,0),t={...t,down:!1})}}}var Xe=3*1024*1024,$t=1920,Zt=.85,Kt=60,Gt=["sent","unavailable","too-big","error"],Vt=/^[A-Za-z0-9+/]*={0,2}$/,Ut={"image/jpeg":"/9j/","image/png":"iVBORw0KGg"},Jt=/^data:(image\/(?:jpeg|png));base64,/,eo=e=>e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0),to=Math.ceil(Xe/3)*4,oo=(e,t)=>t.length%4===0&&t.length>0&&t.startsWith(Ut[e])&&Vt.test(t);function Ye(e){if(typeof e!="string")return{error:"invalid"};const t=Jt.exec(e);if(!t)return{error:"invalid"};const o=t[1],r=e.slice(t[0].length);if(r.length>to)return{error:"too-big"};if(!oo(o,r))return{error:"invalid"};const a=eo(r);return a>Xe?{error:"too-big"}:{ok:{mime:o,base64:r,size:a}}}function ro(e){return typeof e!="string"?void 0:Array.from(e.replace(/[\p{Cc}\p{Cf}]/gu,"").trim()).slice(0,Kt).join("").trim()||void 0}var qe=1,$e=33,D={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},ao=["3-5","6-8","9-12"],no=e=>ao.includes(e),Ie=4,Ze={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},so=Ze["6-8"],Ke=(e,t)=>{const o=no(t)?Ze[t]:so;return o[Number.isInteger(e)&&e>=0?e%o.length:0]},Ge="fabi-play",pe=e=>({ns:Ge,...e});function Ve(e){if(!xe(e))return;const{x:t,y:o,w:r,h:a}=e;return ae(t)&&ae(o)&&ae(r)&&ae(a)&&r>0&&a>0?{x:t,y:o,w:r,h:a}:void 0}var Ue=(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 lo(e){if(!xe(e))return;const t={};return Je.includes(e.tier)&&(t.tier=e.tier),ae(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function io(e){const t={};return xe(e)&&(ae(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}function co(e){if(!xe(e)||!ae(e.x)||!ae(e.y)||typeof e.down!="boolean")return;const t=o=>Math.min(Math.max(o,0),1);return{type:"cursor",x:t(e.x),y:t(e.y),down:e.down}}function fo(e){if(!(!xe(e)||!Gt.includes(e.result)))return{type:"picture-result",...Number.isInteger(e.id)?{id:e.id}:{},result:e.result}}var et=e=>Number.isInteger(e)&&e>=1&&e<=Ie;function uo(e){return Array.isArray(e)&&e.length===1&&et(e[0])?[e[0]]:void 0}function ho(e){if(!(!Array.isArray(e)||e.length<1||e.length>Ie||!e.every(et)||new Set(e).size!==e.length))return[...e]}var xe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ae=e=>typeof e=="number"&&Number.isFinite(e),po=12,yo=$e*4,bo=e=>po+e*yo,Tr=bo(Ie),Y="#4a382c",H="#2b2118",K="#1c1f2b",tt="#fbefe3",V="#f4897a",me="#3a2a22",ot=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:tt,accent:"#ffd9c2",outline:H,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:me,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:tt,accent:"#5a3426",outline:H,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:me,muzzle:"band",cheeks:V},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:Y},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:V},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:Y},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:me,muzzle:"oval",cheeks:V},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:Y,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:V},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:Y,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:Y,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:Y},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",alsoIn:["3-5"],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:V},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:K,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:K,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:V},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:Y},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:V},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:Y,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:Y,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:K},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:Y,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:V},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:Y,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:me,muzzle:"oval",cheeks:V},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:Y,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:V},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:Y,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:V},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:me,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:K,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:K,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:K,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:K,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:K,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:K,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:K,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:K,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:K,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"]},{id:"trex",name:{en:"T-Rex",it:"T-Rex"},band:"6-8",alsoIn:["3-5"],palette:{body:"#6cb84e",limbs:"#6cb84e",belly:"#f4e8a8",accent:"#f4e8a8",outline:H},head:"snout-long",ears:"none",face:{eyes:"dot",mouth:"toothy",muzzle:"none",cheeks:"#f59b8f"},tail:"thick",headExtras:["stripes"],bodyExtras:["tiny-arms","strong-legs"],extraColors:["#4a9235","#58a23f"]},{id:"fairy",name:{en:"Fairy",it:"Fatina"},band:"6-8",alsoIn:["3-5"],palette:{body:"#b99af0",limbs:"#a8693f",belly:"#b99af0",accent:"#ffd84a",outline:H,skin:"#a8693f",hair:"#2e1d17",hands:"#a8693f",feet:"#f58cbc"},head:"round",ears:"pixie",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f0857a"},tail:"none",headExtras:["bun","flower-crown"],bodyExtras:["wings-fairy","petals","wand"],extraColors:["#c4ecff","#f7a8cf","#fff3a0","#ffffff"]}],B={M:0,L:1,Q:2,C:3,Z:4},rt=[2,2,4,6,0];function Le(e,t){for(const o of t)ko(e,o)}function ko(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),Le(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":xo(e,t);break;case"path":typeof t.d=="string"?wo(e,t.d):mo(e,t.d);break;case"line":e.moveTo(t.pts[0]??0,t.pts[1]??0);for(let o=2;o+1<t.pts.length;o+=2)e.lineTo(t.pts[o],t.pts[o+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 xo(e,t){const o=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 r=-t.w/2,a=-t.h/2;e.moveTo(r+o,a),e.lineTo(r+t.w-o,a),e.quadraticCurveTo(r+t.w,a,r+t.w,a+o),e.lineTo(r+t.w,a+t.h-o),e.quadraticCurveTo(r+t.w,a+t.h,r+t.w-o,a+t.h),e.lineTo(r+o,a+t.h),e.quadraticCurveTo(r,a+t.h,r,a+t.h-o),e.lineTo(r,a+o),e.quadraticCurveTo(r,a,r+o,a),e.closePath()}function mo(e,t){for(let o=0;o<t.length;){const r=t[o++];if(r===B.M)e.moveTo(t[o],t[o+1]);else if(r===B.L)e.lineTo(t[o],t[o+1]);else if(r===B.Q)e.quadraticCurveTo(t[o],t[o+1],t[o+2],t[o+3]);else if(r===B.C)e.bezierCurveTo(t[o],t[o+1],t[o+2],t[o+3],t[o+4],t[o+5]);else if(r===B.Z)e.closePath();else return;o+=rt[r]}}function go(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);const t=[];for(let o=0;o<e.length;){const r=rt[e[o++]];if(r===void 0)break;for(let a=0;a<r;a++)t.push(e[o+a]);o+=r}return t}function wo(e,t){const o=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let r="",a=0;const n=()=>Number(o[a++]);for(;a<o.length;){const i=o[a];if(/[MLQCZ]/i.test(i)&&(r=i.toUpperCase(),a++,r==="Z")){e.closePath();continue}r==="M"?(e.moveTo(n(),n()),r="L"):r==="L"?e.lineTo(n(),n()):r==="Q"?e.quadraticCurveTo(n(),n(),n(),n()):r==="C"?e.bezierCurveTo(n(),n(),n(),n(),n(),n()):a++}}var I=e=>{const t=Math.round(e*100)/100;return t===0?0:t};function R(e,t=.5){const o=e.length;if(o<3)return[];const r=(c,u,f)=>({x:c.x+(u.x-c.x)*f,y:c.y+(u.y-c.y)*f}),a=Math.min(Math.max(t,0),.5),n=r(e[0],e[1],a),i=[B.M,I(n.x),I(n.y)];for(let c=1;c<=o;c++){const u=e[(c-1)%o],f=e[c%o],s=e[(c+1)%o],h=r(u,f,1-a),l=r(f,s,a);i.push(B.L,I(h.x),I(h.y),B.Q,I(f.x),I(f.y),I(l.x),I(l.y))}return i.push(B.Z),i}function L(e,t=1){const o=e.length;if(o<3)return[];const r=[B.M,I(e[0].x),I(e[0].y)],a=t/6;for(let n=0;n<o;n++){const i=e[(n-1+o)%o],c=e[n],u=e[(n+1)%o],f=e[(n+2)%o];r.push(B.C,I(c.x+(u.x-i.x)*a),I(c.y+(u.y-i.y)*a),I(u.x-(f.x-c.x)*a),I(u.y-(f.y-c.y)*a),I(u.x),I(u.y))}return r.push(B.Z),r}function ge(e){const t=e.length;if(t<2)return[];const o=[B.M,I(e[0].x),I(e[0].y)];for(let r=0;r<t-1;r++){const a=e[Math.max(r-1,0)],n=e[r],i=e[r+1],c=e[Math.min(r+2,t-1)];o.push(B.C,I(n.x+(i.x-a.x)/6),I(n.y+(i.y-a.y)/6),I(i.x-(c.x-n.x)/6),I(i.y-(c.y-n.y)/6),I(i.x),I(i.y))}return o}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",j="#ffffff",C=[-1,1],at="#3a2420",nt="#f2808f",Re="#26324a",vo="#ffd84a",Q=(...e)=>{const t=[];for(let o=0;o+1<e.length;o+=2)t.push({x:e[o],y:e[o+1]});return t};function st(e,t){const o=e.palette,r=[],a={stroke:o.outline,lw:t},n=s=>e.headExtras.includes(s),i=(s,h)=>e.extraColors?.[s]??h;if(n("mane")){for(let h=0;h<12;h++){const l=h/12*Math.PI*2;r.push({k:"circle",x:Math.cos(l)*1.02,y:Math.sin(l)*1+.04,r:.42,fill:i(0,o.accent),...a})}r.push({k:"circle",x:0,y:.04,r:1.08,fill:i(0,o.accent)})}if(n("rainbow-mane")){const s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([l,d,p,y,b],m)=>r.push({k:"ellipse",x:l,y:d,rx:p,ry:y,rot:b,fill:s[m%s.length],...a}))}if(n("spikes"))for(const s of[-.55,0,.55]){const h=he(s,1.48),l=he(s-.32,.86),d=he(s+.32,.86);r.push({k:"path",d:R([l,h,d],.22),fill:o.accent,...a})}if(n("curl")&&r.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:o.body,...a}),n("wool"))for(let s=0;s<=8;s++){const h=-1.75+s/8*3.5;r.push({k:"circle",x:Math.sin(h)*.98,y:-Math.cos(h)*.92-.04,r:.34,fill:o.body,...a})}if(n("crest")&&[-.38,0,.38].forEach((s,h)=>{const l=he(s,1.12);r.push({k:"ellipse",x:l.x,y:l.y,rx:.15,ry:.42,rot:s,fill:i(h,o.accent),...a})}),n("plume")&&r.push({k:"path",d:L(Q(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:o.accent,...a}),n("locks")&&r.push({k:"path",d:L(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:o.hair??o.outline,...a}),n("bun")&&r.push({k:"circle",x:.04,y:-1.14,r:.4,fill:o.hair??o.outline,...a}),n("ninja-hood"))for(const[s,h]of[[.35,.5],[.85,.42]])r.push({k:"ellipse",x:1+Math.cos(s)*h*.8,y:-.5+Math.sin(s)*h*.8,rx:h,ry:.11,rot:s,fill:o.accent,...a});if(n("bandana"))for(const[s,h]of[[Math.PI-.5,.42],[Math.PI-1,.36]])r.push({k:"ellipse",x:-.98+Math.cos(s)*h*.8,y:-.36+Math.sin(s)*h*.8,rx:h,ry:.12,rot:s,fill:o.accent,...a});if(n("ruff"))for(const s of C)r.push({k:"path",d:R(Q(s*.7,-.3,s*1.32,0,s*1.02,.18,s*1.26,.46,s*.86,.56,s*.98,.84,s*.4,.7),.25),fill:o.body,...a});if(e.face.eyesOnTop)for(const s of C)r.push({k:"circle",x:s*.46,y:-.72,r:.38,fill:o.body,...a});r.push(...To(e,t)),r.push(Eo(e,a));const c=e.face.muzzle,u=o.belly;if(c==="oval"&&r.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:u}),c==="monkey"){for(const s of C)r.push({k:"circle",x:s*.32,y:-.04,r:.38,fill:u});r.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:u})}if(c==="heart"){for(const s of C)r.push({k:"circle",x:s*.36,y:.02,r:.5,fill:u});r.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:u})}if(c==="disc")for(const s of C)r.push({k:"circle",x:s*.4,y:.02,r:.44,fill:u});if(c==="cheeks")for(const s of C)r.push({k:"ellipse",x:s*.4,y:.44,rx:.44,ry:.32,fill:u});if(c==="band"&&r.push({k:"path",d:So(e,t),fill:u}),n("stripes")&&e.head==="snout-long"){const s=i(0,o.outline);for(const[h,l,d,p]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])r.push({k:"line",pts:[h,l,d,p],stroke:s,lw:.11})}else if(n("stripes")){const s=i(0,o.outline);r.push({k:"line",pts:[0,-.97,0,-.66],stroke:s,lw:.13});for(const h of C)r.push({k:"line",pts:[h*.3,-.93,h*.24,-.7],stroke:s,lw:.1}),r.push({k:"line",pts:[h*.98,-.05,h*.74,0],stroke:s,lw:.1}),r.push({k:"line",pts:[h*.94,.22,h*.74,.22],stroke:s,lw:.09})}if(n("spots")){const s=i(1,o.belly);r.push({k:"circle",x:-.55,y:-.5,r:.15,fill:s}),r.push({k:"circle",x:.58,y:-.42,r:.11,fill:s}),r.push({k:"circle",x:.22,y:-.76,r:.09,fill:s})}if(e.head==="snout-long")for(const[s,h,l]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])r.push({k:"ellipse",x:s,y:h,rx:l,ry:l*.8,rot:-.3,fill:o.outline,alpha:.85});if(n("forehead")&&r.push({k:"path",d:L(Q(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:i(0,o.accent)}),n("eye-spot")&&r.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:o.ears??o.accent}),n("gills"))for(const s of C)for(const h of[0,.12,.24])r.push({k:"path",d:`M${s*(.66+h)} 0.06 Q${s*(.6+h)} 0.22 ${s*(.66+h)} 0.38`,stroke:o.accent,lw:t*.9});const f=o.hair??o.outline;if(n("hair")&&r.push({k:"path",d:L(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,...a}),n("locks")&&r.push({k:"path",d:L(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,...a}),n("bun")&&r.push({k:"path",d:L(Q(-1.02,-.1,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1.02,-.1,.84,-.36,.5,-.56,.12,-.48,-.22,-.6,-.6,-.5,-.86,-.36)),fill:f,...a}),n("curls")){for(let s=0;s<7;s++){const h=he(-1.3+s/6*2.6,.86);r.push({k:"circle",x:h.x,y:h.y,r:.3,fill:f,...a})}r.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:f})}if(n("ninja-hood")&&(r.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:o.skin??j,stroke:o.outline,lw:t*.8}),r.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:o.accent,...a})),n("domino")){r.push({k:"path",d:L(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:o.accent,...a});for(const s of C)r.push({k:"ellipse",x:s*.38,y:0,rx:.19,ry:.13,fill:j})}if(r.push(...zo(e,t)),n("brows"))for(const s of C)r.push({k:"line",pts:[s*.72,-.5,s*.14,-.3],stroke:o.accent,lw:.16});if(e.face.brows)for(const s of C)r.push({k:"line",pts:[s*.2,-.2,s*.54,-.28],stroke:e.face.brows,lw:.09});if(r.push(...Po(e,t)),e.face.cheeks)for(const s of Ao(e))r.push({k:"ellipse",x:s.x,y:s.y,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(n("whiskers"))for(const s of C)for(const h of[-.1,.06])r.push({k:"line",pts:[s*.62,.38+h,s*1.06,.3+h*2.2],stroke:o.outline,lw:t*.7,alpha:.75});if(n("rainbow-mane")){const s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];r.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:s[0],...a}),r.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:s[1%s.length],...a})}if(e.ears==="unicorn"){const s=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];r.push({k:"path",d:R(s,.12),fill:o.accent,...a});for(const h of[-1,-1.2,-1.4]){const l=.16*((h+1.72)/.88);r.push({k:"line",pts:[-l,h+.04,l,h-.04],stroke:o.outline,lw:t*.7,alpha:.6})}}if(n("flower-crown")){const s=[i(1,"#f7a8cf"),i(2,"#fff3a0"),i(3,j)];for(const h of[-.84,-.28,.28,.84]){const l=he(h,.9);r.push({k:"ellipse",x:l.x,y:l.y,rx:.14,ry:.07,rot:h+.5,fill:"#7cc76a",stroke:o.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((h,l)=>{const d=he(h,.9),p=l===2?.13:.11;for(let y=0;y<5;y++){const b=h+y/5*Math.PI*2;r.push({k:"circle",x:d.x+Math.sin(b)*p,y:d.y-Math.cos(b)*p,r:p*.82,fill:s[l%s.length],stroke:o.outline,lw:t*.7})}r.push({k:"circle",x:d.x,y:d.y,r:p*.62,fill:s[l%s.length]}),r.push({k:"circle",x:d.x,y:d.y,r:p*.42,fill:o.accent})})}if(n("helmet")){for(const s of C)r.push({k:"rect",x:s*1,y:.05,w:.26,h:.56,r:.12,fill:o.accent,...a});r.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:j,lw:.1,alpha:.9})}if(n("bolts"))for(const s of C)r.push({k:"rect",x:s*1.08,y:.08,w:.2,h:.44,r:.08,fill:o.accent,...a});if(n("tuft")&&r.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:o.body,...a}),n("eggshell")&&r.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,j),...a}),n("wool"))for(const[s,h]of[[-.36,-.84],[.02,-.94],[.4,-.82]])r.push({k:"circle",x:s,y:h,r:.27,fill:o.body,...a});if(n("stripe")&&r.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:o.accent}),n("eye-patch")&&(r.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:o.outline,lw:.07}),r.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:o.outline})),n("bandana")){r.push({k:"path",d:L(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:o.accent,...a});for(const[s,h]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])r.push({k:"circle",x:s,y:h,r:.06,fill:j,alpha:.85});r.push({k:"circle",x:-.98,y:-.34,r:.15,fill:o.accent,...a})}if(n("cap")){for(const s of C)r.push({k:"line",pts:[s*.98,-.2,s*.5,.82,-s*.05,.98],stroke:o.outline,lw:.06});r.push({k:"path",d:L(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:o.accent,...a}),r.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:o.accent,...a}),r.push({k:"circle",x:.5,y:-.82,r:.15,fill:i(0,j),...a});for(const s of[-.42,-.14])r.push({k:"line",pts:[s,-1.04,s+.02,-.78],stroke:o.outline,lw:.07,alpha:.7})}if(n("safari-hat")&&(r.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:o.accent,...a}),r.push({k:"path",d:L(Q(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:o.accent,...a}),r.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,o.outline),stroke:o.outline,lw:t*.8})),n("wizard-hat")){r.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:o.accent,...a}),r.push({k:"path",d:R(Q(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:o.accent,...a});const s=i(0,vo);for(const[h,l,d]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])r.push({k:"group",x:h,y:l,s:d,items:[{k:"path",d:ye,fill:s}]})}if(n("dive-mask")){for(const h of C)r.push({k:"line",pts:[h*.7,-.04,h*1,-.12],stroke:o.outline,lw:.2},{k:"line",pts:[h*.7,-.04,h*1,-.12],stroke:o.accent,lw:.11});r.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),r.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:o.outline,lw:.2}),r.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:o.accent,lw:.11}),r.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:j,lw:.06,alpha:.9});const s="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";r.push({k:"path",d:s,stroke:o.outline,lw:.24},{k:"path",d:s,stroke:o.accent,lw:.13})}return r}function Eo(e,t){const o=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:o,...t};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:o,...t};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:o,...t};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:o,...t};case"bucket":return{k:"path",d:R(Q(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:o,...t};case"snout-long":return{k:"path",d:L(Mo,.95),fill:o,...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:o,...t}}}var Mo=Q(.7,-.88,.12,-1.04,-.3,-.98,-.72,-.74,-1.2,-.56,-1.5,-.32,-1.6,.04,-1.44,.42,-.9,.72,-.2,.92,.5,.88,.96,.56,1.08,0,.98,-.5);function lt(e,t,o){return e.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:C.map(r=>({x:r*t,y:o,k:1}))}function Ao(e){return e.head==="snout-long"?Q(-.66,-.14,.66,.1):C.map(t=>({x:t*.64,y:.3}))}function Co(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 So(e,t){const{cy:o,rx:r,ry:a}=Co(e),n=r-t/2,i=a-t/2,c=.15,u=Math.asin(Math.min(1,(c-o)/i)),f=Math.cos(u)*n,s=p=>Math.round(p*100)/100||0,h=[B.M,s(-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 p of l)h.push(B.C,...p.map(s));const d=24;for(let p=1;p<=d;p++){const y=u+(Math.PI-2*u)*p/d;h.push(B.L,s(Math.cos(y)*n),s(o+Math.sin(y)*i))}return h.push(B.Z),h}function To(e,t){const o=e.palette,r={stroke:o.outline,lw:t},a=[];for(const n of C)switch(e.ears){case"pointy":case"unicorn":{const i=e.ears==="unicorn"?.8:1,c={x:n*.3,y:-.82},u={x:n*.86,y:-.82-.62*i},f={x:n*.94,y:-.36};a.push({k:"path",d:R([c,u,f],.2),fill:o.body,...r});const s={x:(c.x+u.x+f.x)/3,y:(c.y+u.y+f.y)/3},h=[c,u,f].map(l=>({x:s.x+(l.x-s.x)*.55,y:s.y+(l.y-s.y)*.55+.04}));a.push({k:"path",d:R(h,.25),fill:o.accent});break}case"round":a.push({k:"circle",x:n*.72,y:-.72,r:.36,fill:o.ears??o.body,...r}),o.ears||a.push({k:"circle",x:n*.74,y:-.74,r:.19,fill:o.accent});break;case"big-round":a.push({k:"circle",x:n*.96,y:-.46,r:.52,fill:o.body,...r}),a.push({k:"circle",x:n*1,y:-.44,r:.32,fill:o.accent});break;case"long":a.push({k:"ellipse",x:n*.38,y:-1.42,rx:.25,ry:.68,rot:n*.14,fill:o.body,...r}),a.push({k:"ellipse",x:n*.39,y:-1.36,rx:.12,ry:.48,rot:n*.14,fill:o.accent});break;case"side":a.push({k:"circle",x:n*1,y:.02,r:.34,fill:o.body,...r}),a.push({k:"circle",x:n*1.02,y:.02,r:.2,fill:o.belly});break;case"tufts":a.push({k:"path",d:R([{x:n*.3,y:-.84},{x:n*1.22,y:-1.12},{x:n*.92,y:-.42}],.16),fill:o.body,...r}),a.push({k:"line",pts:[n*.62,-.78,n*1,-.98],stroke:o.accent,lw:.08});break;case"antennae":{const i={x:n*.62,y:-1.42};a.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${i.x} ${i.y}`,stroke:o.outline,lw:t*2.6}),a.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${i.x} ${i.y}`,stroke:o.body,lw:t*1.2}),a.push({k:"circle",x:i.x,y:i.y,r:.17,fill:o.accent,...r});break}case"floppy":a.push({k:"ellipse",x:n*.96,y:.02,rx:.3,ry:.62,rot:-n*.36,fill:o.ears??o.body,...r});break;case"droopy":a.push({k:"ellipse",x:n*1.04,y:-.22,rx:.4,ry:.18,rot:n*.32,fill:o.skin??o.body,...r}),a.push({k:"ellipse",x:n*1.08,y:-.2,rx:.24,ry:.08,rot:n*.32,fill:o.accent});break;case"pixie":a.push({k:"path",d:R(Q(n*.86,-.22,n*1.36,-.5,n*1.02,.26),.28),fill:o.skin??o.body,...r}),a.push({k:"line",pts:[n*.98,-.12,n*1.16,-.3],stroke:o.accent,lw:t*.8,alpha:.5});break;case"human":a.push({k:"ellipse",x:n*.98,y:.06,rx:.17,ry:.23,fill:o.skin??o.body,...r});break;case"horns":{const i=[{x:n*.3,y:-.84},{x:n*.6,y:-1.5},{x:n*.66,y:-.68}];a.push({k:"path",d:R(i,.18),fill:o.accent,...r});break}}return e.ears==="fin"&&a.push({k:"path",d:R(Q(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:o.body,...r}),e.ears==="antenna"&&(a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:o.outline,lw:t*2.6}),a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:o.limbs,lw:t*1.2}),a.push({k:"circle",x:0,y:-1.5,r:.18,fill:o.accent,...r})),a}function zo(e,t){const o=e.palette,r=e.face,a=[],n=o.outline,i=r.eyesOnTop?.46:.4,c=r.eyesOnTop?-.72:-.04,u=(f,s,h)=>({k:"circle",x:f,y:s,r:h,fill:j});switch(r.eyes){case"dot":for(const f of lt(e,i,c))a.push({k:"ellipse",x:f.x,y:f.y,rx:.12*f.k,ry:.155*f.k,fill:n}),a.push(u(f.x+.04*f.k,f.y-.06*f.k,.045*f.k));break;case"bead":for(const f of lt(e,i,c))a.push({k:"ellipse",x:f.x,y:f.y,rx:.16*f.k,ry:.22*f.k,fill:n}),a.push(u(f.x+.05*f.k,f.y-.08*f.k,.065*f.k));break;case"big":for(const f of C)r.eyeRing&&a.push({k:"circle",x:f*i,y:c,r:.36,fill:r.eyeRing,stroke:n,lw:t*.8}),a.push({k:"circle",x:f*i,y:c,r:.25,fill:j,stroke:n,lw:t*.8}),a.push({k:"circle",x:f*i+f*-.03,y:c+.03,r:.14,fill:r.eyeColor??n}),a.push(u(f*i+f*-.03+.05,c-.03,.05));break;case"mask":for(const f of C)a.push({k:"ellipse",x:f*.4,y:0,rx:.24,ry:.32,rot:f*-.55,fill:o.limbs}),a.push({k:"circle",x:f*.4,y:-.02,r:.11,fill:j}),a.push({k:"circle",x:f*.39,y:-0,r:.065,fill:n});break;case"screen":a.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 C)a.push({k:"ellipse",x:f*.36,y:0,rx:.2,ry:.24,fill:r.eyeColor??"#7ff0ff",alpha:.3}),a.push({k:"ellipse",x:f*.36,y:0,rx:.12,ry:.16,fill:r.eyeColor??"#7ff0ff"});break;case"almond":for(const f of C)a.push({k:"ellipse",x:f*.42,y:-.02,rx:.3,ry:.2,rot:-f*.5,fill:r.eyeColor??n}),a.push(u(f*.42-f*.07,-.08,.07));break;case"calm":for(const f of C)a.push({k:"ellipse",x:f*.38,y:.02,rx:.085,ry:.12,fill:n}),a.push(u(f*.38+.03,-.02,.03));break;case"slit":a.push({k:"line",pts:[0,-.98,0,-.2],stroke:n,lw:t*.8,alpha:.5}),a.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:Re,stroke:n,lw:t*.8}),a.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:Re,stroke:n,lw:t*.8});for(const f of C){a.push({k:"ellipse",x:f*.4,y:-.04,rx:.12,ry:.07,fill:r.eyeColor??j});for(const s of[.36,.56])a.push({k:"circle",x:f*.42,y:s,r:.05,fill:n,alpha:.6})}break;case"goggle":for(const f of C)a.push({k:"circle",x:f*.9,y:0,r:.13,fill:o.accent,stroke:n,lw:t*.8});a.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:Re,stroke:n,lw:t*.8}),a.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:j,lw:.07,alpha:.8});for(const f of C)a.push({k:"path",d:`M${f*.5} 0.04 Q${f*.34} -0.08 ${f*.16} 0.02`,stroke:r.eyeColor??"#7fd6ff",lw:.08});for(const f of[-.18,0,.18])a.push({k:"line",pts:[f,.56,f,.72],stroke:n,lw:t*.8,alpha:.6});break;case"visor":a.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:n,lw:t*.8}),a.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:j,lw:.08,alpha:.7});for(const f of C)a.push({k:"ellipse",x:f*.28,y:.04,rx:.1,ry:.14,fill:r.eyeColor??"#cfeeff"});break}return a}function Po(e,t){const o=e.palette,r=e.face,a=[],n=r.eyes==="visor"?"#cfeeff":at,i=t*1.05;switch(r.nose&&r.mouth!=="beak"&&(r.mouth==="cat"?a.push({k:"path",d:R([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:r.nose,stroke:r.nose,lw:t*.6}):e.ears==="big-round"?a.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:r.nose}):a.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:r.nose})),r.mouth){case"smile":a.push({k:"path",d:r.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:i});break;case"open":a.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}),a.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:nt});break;case"cat":a.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:i});break;case"beak":a.push({k:"path",d:R([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:o.accent,stroke:o.outline,lw:t*.8});break;case"teeth":a.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 c of C)a.push({k:"rect",x:c*.12,y:.43,w:.1,h:.1,r:.03,fill:j});break;case"grill":a.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:o.outline,lw:t*.7});for(const c of[-.15,0,.15])a.push({k:"line",pts:[c,.51,c,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":a.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:n});break;case"smirk":a.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:n,lw:i});break;case"bill":a.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:o.accent,stroke:o.outline,lw:t*.8}),a.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:o.outline,lw:t*.7});for(const c of C)a.push({k:"circle",x:c*.1,y:.28,r:.03,fill:o.outline});break;case"hook":a.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:at}),a.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:o.accent,stroke:o.outline,lw:t*.8});break;case"toothy":{a.push({k:"path",d:"M-1.4 0.1 Q-0.5 0.36 0.5 0.2 Q0.64 0.16 0.68 0.02 Q0.78 0.28 0.52 0.38 Q-0.4 0.78 -1.3 0.26 Z",fill:n,stroke:n,lw:t*.6}),a.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:nt});for(const c of[.12,.27,.42,.57,.72,.86]){const u=(1-c)*(1-c)*-1.4+2*(1-c)*c*-.5+c*c*.5,f=(1-c)*(1-c)*.1+2*(1-c)*c*.36+c*c*.2-.01;a.push({k:"path",d:R(Q(u-.08,f,u+.08,f,u,f+.14),.3),fill:j})}for(const c of[.3,.7]){const u=(1-c)*(1-c)*.52+2*(1-c)*c*-.4+c*c*-1.3,f=(1-c)*(1-c)*.38+2*(1-c)*c*.78+c*c*.26+.01;a.push({k:"path",d:R(Q(u-.07,f,u+.07,f,u,f-.12),.3),fill:j})}break}case"jaws":{a.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 c of[-.34,-.17,0,.17,.34]){const u=.3+.4*(c+.5)*(.5-c)-.01;a.push({k:"path",d:R(Q(c-.075,u,c+.075,u,c,u+.13),.15),fill:j})}break}}return a}var he=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t}),Oo=.5,ne={leftEye:2,rightEye:5,leftEar:7,rightEar:8},se={"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}},Te="6-8",it=(e,t)=>t!==void 0&&e.band!=="all"&&e.alsoIn?.includes(t)&&t in se?t:e.band in se?e.band:Te,zr=se[Te].head,_o=.3,Io=.12,Lo=.9,ct=.5,ft=.65,Ro=.35,Do=.2,No=.25,U=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),N=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),P=(e,t)=>({x:e.x*t,y:e.y*t}),de=e=>Math.hypot(e.x,e.y),ut=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),ze=e=>{const t=de(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},Qo=(...e)=>e.every(Number.isFinite),Bo=e=>Math.atan2(Math.sin(e),Math.cos(e)),jo=(e,t,o)=>Math.min(Math.max(e,t),o);function ht(e,t,o=!1){return r=>{const a=e[r*3],n=e[r*3+1],i=e[r*3+2];return a===void 0||n===void 0||i===void 0||!Qo(a,n,i)?{x:0,y:0,ok:!1}:{x:t.x+(o?1-a:a)*t.w,y:t.y+n*t.h,ok:i>=Oo}}}function De(e,t,o={}){const r=ht(e,t,o.mirrored),a=r(D.leftShoulder),n=r(D.rightShoulder);if(!a.ok||!n.ok)return null;const i=r(D.leftHip),c=r(D.rightHip),u=ut(a,n),f=de(U(n,a)),s=i.ok&&c.ok;let h=ze(U(n,a));f<1e-6&&(h={x:1,y:0});let l,d,p;if(s){const oe=ut(i,c);d=de(U(oe,u)),d>=f*No?l=ze(U(oe,u)):(l={x:-h.y,y:h.x},l.y<0&&(l=P(l,-1))),p=Math.max(d,f*1.15)}else l={x:-h.y,y:h.x},l.y<0&&(l=P(l,-1)),p=f*1.15,d=p;p=Math.max(p,1e-6);const y={x:l.y,y:-l.x},b=Math.atan2(y.y,y.x),m=P(l,-1),A=se[o.band??Te]??se[Te],M=A.head*p;let S=N(u,P(m,M*A.neck));const q=r(D.nose);if(q.ok){const oe=N(q,P(m,M*.15)),le=P(U(oe,S),Ro),J=Math.min(1,M*Do/Math.max(de(le),1e-6));S=N(S,P(le,J))}return{S:u,r:y,d:l,U:p,L:d,hipsOk:s,head:S,headR:M,headRot:b+Ho(e,r,b,p),angle:b}}function Ho(e,t,o,r){const a=[[ne.leftEar,ne.rightEar],[ne.leftEye,ne.rightEye]];for(const[n,i]of a){const c=t(n),u=t(i);if(!c.ok||!u.ok||!(e[n*3+2]>=ft&&e[i*3+2]>=ft)||de(U(u,c))<r*.05)continue;const f=Bo(Math.atan2(u.y-c.y,u.x-c.x)-o),s=Math.max(Math.abs(f)-Io,0),h=jo((Lo+ct-Math.abs(f))/ct,0,1);return Math.sign(f)*Math.min(s,_o)*h}return 0}function Ne(e,t,o,r={}){const a=it(t,r.band),n=se[a],i=De(e,o,{...r,band:a});if(!i)return[];const c=ht(e,o,r.mirrored),u=t.palette,{S:f,r:s,d:h,U:l,L:d}=i,p=k=>t.bodyExtras.includes(k),y=Math.max(1.2,l*.045),b={stroke:u.outline,lw:y},m=(k,g)=>({x:f.x+s.x*k+h.x*g,y:f.y+s.y*k+h.y*g}),A=k=>k.map(([g,w])=>m(g,w)),M=c(D.leftShoulder),S=c(D.rightShoulder),q=c(D.leftHip),oe=c(D.rightHip),le=de(U(S,M)),J=i.hipsOk?de(U(oe,q)):le*.7,x=Math.max(le/2+n.shoulderPad*l,n.shoulderMin*l),O=Math.max(J/2+n.hipPad*l,n.hipMin*l),E=-.1*l,F=d+n.bottom*l,$=[],T=[],v=[],X=[],be=[],we=(k,g,w,_)=>{const z=g.flatMap(Z=>[Z.x,Z.y]);k.push({k:"line",pts:z,stroke:u.outline,lw:w+y*2}),k.push({k:"line",pts:z,stroke:_,lw:w})},Qe=n.leg*l*(p("strong-legs")?1.3:1),Oe=n.arm*l*(p("tiny-arms")?.6:1),ve=Math.max(n.arm/.22,.9);if(i.hipsOk)for(const[k,g,w,_]of[[q,D.leftKnee,D.leftAnkle,-1],[oe,D.rightKnee,D.rightAnkle,1]]){const z=c(g),Z=c(w);if(!z.ok)continue;const Be=N(k,P(h,-.12*l)),ie=Z.ok?[Be,z,Z]:[Be,z];we(T,ie,Qe,u.limbs),p("joints")&&T.push({k:"circle",x:z.x,y:z.y,r:.15*l*ve,fill:u.accent,...b}),Z.ok&&T.push(...Xo(t,Z,i,_,y,n.foot))}for(const[k,g,w,_]of[[M,D.leftElbow,D.leftWrist,-1],[S,D.rightElbow,D.rightWrist,1]]){const z=c(g),Z=c(w);if(p("pauldrons")){const re=N(k,P(h,.02*l));X.push({k:"ellipse",x:re.x,y:re.y,rx:.25*l,ry:.17*l,rot:i.angle+_*.25,fill:u.body,...b});const ce=N(re,P(h,.05*l));X.push({k:"ellipse",x:ce.x,y:ce.y,rx:.17*l,ry:.07*l,rot:i.angle+_*.25,fill:u.belly})}if(!z.ok)continue;const ie=n.armsOverHead&&(z.x-f.x)*h.x+(z.y-f.y)*h.y<-.25*l?be:X,Tt=N(k,P(h,.04*l));if(we(ie,Z.ok?[Tt,z,Z]:[Tt,z],Oe,u.limbs),p("joints")&&ie.push({k:"circle",x:z.x,y:z.y,r:.13*l*ve,fill:u.accent,...b}),!Z.ok)continue;const te=ze(U(Z,z)),ke=N(Z,P(te,.05*l));if(p("feathers"))for(const re of[-.55,0,.55]){const ce=Math.cos(re),Me=Math.sin(re)*_,fe={x:te.x*ce-te.y*Me,y:te.x*Me+te.y*ce},Ae=N(ke,P(fe,.16*l));ie.push({k:"ellipse",x:Ae.x,y:Ae.y,rx:.2*l,ry:.09*l,rot:Math.atan2(fe.y,fe.x),fill:u.hands??u.accent,...b})}p("wand")&&_===1&&!r.portrait&&ie.push(...$o(t,ke,ze(N(P(te,.4),U(P(s,.6),h))),l,y));const Ee=n.hand*l*(p("tiny-arms")?.72:1);if(p("tiny-arms"))for(const re of[-.45,.45]){const ce=Math.cos(re),Me=Math.sin(re),fe={x:te.x*ce-te.y*Me,y:te.x*Me+te.y*ce},Ae=N(ke,P(fe,Ee*.75)),Sr=N(ke,P(fe,Ee*1.6)),zt={x:-fe.y*Ee*.32,y:fe.x*Ee*.32};ie.push({k:"path",d:R([N(Ae,zt),Sr,U(Ae,zt)],.2),fill:u.belly,...b})}ie.push({k:"circle",x:ke.x,y:ke.y,r:Ee,fill:u.hands??u.limbs,...b})}if(p("wings"))for(const k of[-1,1]){const g=A([[k*x*.5,.05*l],[k*(x+.85*l),-.6*l],[k*(x+.72*l),.05*l],[k*(x+.45*l),-.02*l],[k*(x+.3*l),.32*l],[k*x*.6,.55*l]]);$.push({k:"path",d:R(g,.18),fill:u.accent,...b})}if(p("wings-fairy")&&$.push(...Zo(t,m,x,l,y)),p("cape")){const k=d+.8*l,g=O+.36*l,w=A([[-x*.92,E+.04*l],[x*.92,E+.04*l],[x+.16*l,d*.5],[g,k],[g*.5,k-.1*l],[0,k],[-g*.5,k-.1*l],[-g,k],[-x-.16*l,d*.5]]);$.push({k:"path",d:L(w,.6),fill:u.accent,...b})}if(p("backpack")){const k=m(0,.35*l);$.push({k:"rect",x:k.x,y:k.y,w:x*2+.34*l,h:.8*l,r:.16*l,rot:i.angle,fill:t.extraColors?.[0]??u.limbs,...b})}if(p("tank")){const k=m(x*.95,.24*l),g=t.extraColors?.[0]??u.accent,w=m(x*.95,-.3*l);$.push({k:"rect",x:w.x,y:w.y,w:.14*l,h:.16*l,r:.04*l,rot:i.angle,fill:u.outline}),$.push({k:"rect",x:k.x,y:k.y,w:.34*l,h:1*l,r:.17*l,rot:i.angle,fill:g,...b})}if(i.hipsOk&&!r.portrait&&$.push(...qo(t,i,O,y)),p("tentacles")&&i.hipsOk)for(const k of[-1,1]){const g=A([[k*O*.7,d*.9],[k*(O+.22*l),d+.3*l],[k*(O+.48*l),d+.22*l],[k*(O+.5*l),d-.02*l],[k*(O+.34*l),d-.06*l]]);$.push({k:"path",d:ge(g),stroke:u.outline,lw:.2*l+y*2}),$.push({k:"path",d:ge(g),stroke:u.limbs,lw:.2*l})}const G=Math.max(x,O)*n.bulge;if(p("wool")){for(const[g,w]of[[x*.7,E+.02*l],[G,d*.3],[G*1.02,d*.62],[(G+O)/2,d*.92],[O*.55,F]])for(const _ of[-1,1]){const z=m(_*g,w);v.push({k:"circle",x:z.x,y:z.y,r:.2*l,fill:u.body,...b})}const k=m(0,F+.02*l);v.push({k:"circle",x:k.x,y:k.y,r:.2*l,fill:u.body,...b})}if(p("robe")){const k=d+.58*l,g=O*1.4;v.push({k:"path",d:L(A([[-x,E],[0,E-.04*l],[x,E],[G,d*.55],[g,k],[0,k+.06*l],[-g,k],[-G,d*.55]]),.7),fill:u.body,...b});const w=A([[-g*.94,k-.1*l],[0,k-.04*l],[g*.94,k-.1*l]]);v.push({k:"path",d:ge(w),stroke:t.extraColors?.[0]??u.accent,lw:.07*l})}else if(p("sheet")){const k=d+.78*l,g=O*1.3;v.push({k:"path",d:L(A([[-x,E],[x,E],[G,d*.55],[g,k],[g*.5,k-.2*l],[0,k],[-g*.5,k-.2*l],[-g,k],[-G,d*.55]]),.9),fill:u.body,...b})}else v.push({k:"path",d:L(A([[-x,E],[0,E-.04*l],[x,E],[G,d*.55],[O,F],[0,F+.03*l],[-O,F],[-G,d*.55]]),.85),fill:u.body,...b});const ee=Math.min(x,O);if(p("pocket")){const k=m(0,d*.74);v.push({k:"rect",x:k.x,y:k.y,w:ee*1.3,h:.3*l,r:.1*l,rot:i.angle,fill:u.belly,stroke:u.outline,lw:y*.8})}else if(p("racing-stripe"))for(const k of[-.1,.1]){const g=m(k*l,E+.02*l),w=m(k*l,F-.04*l);v.push({k:"line",pts:[g.x,g.y,w.x,w.y],stroke:u.belly,lw:.1*l})}else if(u.belly&&u.belly!==u.body&&!p("panel")&&!p("sheet")&&!p("stripes")){const k=m(0,d*.58);v.push({k:"ellipse",x:k.x,y:k.y,rx:ee*.64,ry:Math.max(d*.36,.2*l),rot:i.angle,fill:u.belly})}if(p("spots")){const k=t.extraColors?.[1]??u.belly;for(const[g,w,_]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){const z=m(g*ee,w*d);v.push({k:"circle",x:z.x,y:z.y,r:_*l,fill:k})}}if(p("stripes")){const k=t.extraColors?.[1]??u.accent;for(const g of[.22,.44,.66]){const w=m(-ee*.98,d*g),_=m(ee*.98,d*g);v.push({k:"line",pts:[w.x,w.y,_.x,_.y],stroke:k,lw:.1*l})}}if(p("straps")){const k=t.extraColors?.[1]??u.outline;for(const g of[-1,1]){const w=m(g*x*.62,E+.02*l),_=m(g*ee*.62,d*.72);v.push({k:"line",pts:[w.x,w.y,_.x,_.y],stroke:u.outline,lw:.13*l+y*2}),v.push({k:"line",pts:[w.x,w.y,_.x,_.y],stroke:k,lw:.13*l})}}if(p("belt")){const k=m(0,d*.9);v.push({k:"rect",x:k.x,y:k.y,w:O*1.92,h:.17*l,r:.06*l,rot:i.angle,fill:t.extraColors?.[2]??"#4a3426",...b}),v.push({k:"rect",x:k.x,y:k.y,w:.2*l,h:.19*l,r:.04*l,rot:i.angle,fill:"#ffd84a",...b})}if(p("emblem")){const k=m(0,d*.4),g=t.extraColors?.[0]??u.accent,w=R([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);v.push({k:"group",x:k.x,y:k.y,rot:i.angle,s:l,items:[{k:"path",d:w,fill:g,stroke:u.outline,lw:y/l},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ye,fill:g===u.accent?"#ffffff":u.accent}]}]})}if(p("panel")){const k=m(0,d*.5);v.push({k:"rect",x:k.x,y:k.y,w:ee*1.2,h:.38*l,r:.1*l,rot:i.angle,fill:"#24323d",...b}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,_)=>{const z=m((_-1)*ee*.34,d*.5);v.push({k:"circle",x:z.x,y:z.y,r:.075*l,fill:w})})}if(p("badge")){const k=m(-ee*.42,d*.36);v.push({k:"circle",x:k.x,y:k.y,r:.15*l,fill:u.accent,...b}),v.push({k:"group",x:k.x,y:k.y,rot:i.angle,s:.09*l,items:[{k:"path",d:ye,fill:"#ffffff"}]})}if(p("star")){const k=m(-ee*.5,d*.3),g=.15*l;v.push({k:"group",x:k.x,y:k.y,rot:i.angle-.2,s:g,items:[{k:"path",d:ye,fill:t.extraColors?.[0]??"#ffd84a",stroke:u.outline,lw:y*.8/g}]})}if(p("petals")&&v.push(...Ko(t,m,x,O,G,d,F,l,y,n)),p("scarf")){const k=Math.max(.04,n.head*(1-n.neck)-.06)*l,g=m(0,k),w=t.extraColors?.[0]??u.accent,_=m(x*.45,k+.28*l);v.push({k:"rect",x:_.x,y:_.y,w:.16*l,h:.42*l,r:.06*l,rot:i.angle+.15,fill:w,...b}),v.push({k:"rect",x:g.x,y:g.y,w:x*2.05,h:.2*l,r:.1*l,rot:i.angle,fill:w,...b})}const Cr={k:"group",x:i.head.x,y:i.head.y,rot:i.headRot,s:i.headR,items:Wo(t,y/i.headR)};return[...$,...T,...v,...X,Cr,...be]}var dt=new WeakMap,Fo=64;function Wo(e,t){const o=Number(t.toPrecision(4));let r=dt.get(e);r||dt.set(e,r=new Map);let a=r.get(o);return a||(r.size>=Fo&&r.clear(),r.set(o,a=st(e,o))),a}function Xo(e,t,o,r,a,n){const i=Yo(e,t,o,r,a,n);if(!e.bodyExtras.includes("strong-legs"))return[i];const c=o.U*n,u=N(N(t,P(o.d,.07*c)),P(o.r,r*.06*c)),f=[i];for(const s of[-1,0,1]){const h=N(N(u,P(o.r,s*.12*c)),P(o.d,.09*c));f.push({k:"ellipse",x:h.x,y:h.y,rx:.05*c,ry:.045*c,rot:o.angle,fill:e.palette.belly,stroke:e.palette.outline,lw:a*.8})}return f}function Yo(e,t,o,r,a,n){const i=e.palette,{d:c,r:u}=o,f=o.U*n,s=N(N(t,P(c,.07*f)),P(u,r*.06*f)),h={stroke:i.outline,lw:a},l=i.feet??i.limbs;if(e.bodyExtras.includes("fins")){const d=R([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:s.x,y:s.y,rot:o.angle,s:f,items:[{k:"path",d,fill:l,stroke:i.outline,lw:a/f},{k:"line",pts:[0,.06,0,.38],stroke:i.outline,lw:a/f,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:s.x,y:s.y,rx:.27*f,ry:.11*f,rot:o.angle,fill:l,...h}:e.bodyExtras.includes("boots")?{k:"rect",x:s.x,y:s.y,w:.4*f,h:.24*f,r:.09*f,rot:o.angle,fill:l,...h}:{k:"ellipse",x:s.x,y:s.y,rx:.2*f,ry:.13*f,rot:o.angle,fill:l,...h}}function qo(e,t,o,r){const a=e.palette,{U:n,L:i,S:c,r:u,d:f}=t,s=(y,b)=>({x:c.x+u.x*y+f.x*b,y:c.y+u.y*y+f.y*b}),h=y=>y.map(([b,m])=>s(b,m)),l={stroke:a.outline,lw:r},d=(y,b,m)=>[{k:"path",d:ge(y),stroke:a.outline,lw:b+r*2},{k:"path",d:ge(y),stroke:m,lw:b}],p=[];switch(e.tail){case"none":break;case"fluffy":{const y=h([[o*.5,i*.95],[o+.28*n,i*1],[o+.72*n,i*.62],[o+.78*n,i*.12],[o+.52*n,i*.32],[o+.3*n,i*.6],[o*.6,i*.7]]);p.push({k:"path",d:L(y),fill:a.body,...l});const b=s(o+.72*n,i*.2);p.push({k:"ellipse",x:b.x,y:b.y,rx:.13*n,ry:.2*n,rot:t.angle+.25,fill:a.belly,...l});break}case"brush":{const y=h([[o*.4,i*.98],[o+.42*n,i*1.06],[o+.98*n,i*.66],[o+1.06*n,i*.12],[o+.86*n,-.04*n],[o+.66*n,i*.36],[o+.3*n,i*.66],[o*.5,i*.68]]);p.push({k:"path",d:L(y),fill:a.body,...l});const b=h([[o+1.03*n,i*.36],[o+1.06*n,i*.12],[o+.86*n,-.04*n],[o+.72*n,i*.24],[o+.86*n,i*.34]]);p.push({k:"path",d:L(b),fill:a.belly,...l});break}case"pom":{const y=s(o+.06*n,i*.88);p.push({k:"circle",x:y.x,y:y.y,r:.2*n,fill:a.belly,...l});break}case"long":case"striped":case"tuft":{const y=h([[o*.6,i*.9],[o+.35*n,i*.85],[o+.58*n,i*.4],[o+.5*n,-.02*n]]);if(p.push(...d(y,.14*n,a.body)),e.tail==="tuft"){const b=y[y.length-1];p.push({k:"circle",x:b.x,y:b.y,r:.16*n,fill:e.extraColors?.[0]??a.accent,...l})}if(e.tail==="striped"){for(const m of[.35,.6,.85]){const A=s(o+.35*n+.22999999999999998*n*(m*1.4>1?1:m*1.4),i*(.85-.85*m));p.push({k:"line",pts:[A.x-u.x*.08*n,A.y-u.y*.08*n,A.x+u.x*.08*n,A.y+u.y*.08*n],stroke:e.extraColors?.[0]??a.outline,lw:.06*n})}const b=y[y.length-1];p.push({k:"circle",x:b.x,y:b.y,r:.07*n,fill:e.extraColors?.[0]??a.outline})}break}case"curl":{const y=h([[o*.6,i*.9],[o+.4*n,i*.88],[o+.62*n,i*.45],[o+.5*n,i*.12],[o+.3*n,i*.24],[o+.36*n,i*.42]]);p.push(...d(y,.12*n,a.limbs));break}case"fish":{const y=h([[o*.6,i*.9],[o+.36*n,i*.86],[o+.6*n,i*.5]]);p.push(...d(y,.17*n,a.body));const b=y[y.length-1],m=R([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);p.push({k:"group",x:b.x,y:b.y,rot:t.angle+.35,s:n,items:[{k:"path",d:m,fill:a.body,stroke:a.outline,lw:r/n}]});break}case"plume":{const y=e.extraColors??[a.accent];[0,1,2].forEach(b=>{const m=s(o+(.12+b*.13)*n,i+(.32-b*.06)*n);p.push({k:"ellipse",x:m.x,y:m.y,rx:.11*n,ry:.44*n,rot:t.angle-.55+b*.28,fill:y[(b+1)%y.length],...l})});break}case"thick":{const y=h([[o*.3,i*.42],[o+.42*n,i*.62],[o+.92*n,i*.96],[o+1.32*n,i*1.08],[o+1.44*n,i*.98],[o+.98*n,i*1.2],[o+.4*n,i*1.22],[o*.3,i*1.12]]);p.push({k:"path",d:L(y,.8),fill:a.body,...l});const b=e.extraColors?.[0]??a.accent;for(const[m,A,M]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){const S=s(o+m*n,i*A+.03*n),q=s(o+(m-.1)*n,i*A+M*n);p.push({k:"line",pts:[S.x,S.y,q.x,q.y],stroke:b,lw:.09*n})}break}case"spiky":case"arrow":{const y=h([[o*.3,i*.55],[o+.35*n,i*.68],[o+.95*n,i*.86],[o+.35*n,i*1.08],[o*.3,i*1.08]]);if(e.tail==="spiky"){for(const b of[.15,.45,.72]){const m=o+(.2+b*.7)*n,A=i*(.66+b*.19);p.push({k:"path",d:R(h([[m-.12*n,A+.05*n],[m,A-.2*n],[m+.12*n,A+.07*n]]),.2),fill:a.accent,...l})}p.push({k:"path",d:L(y,.7),fill:a.body,...l})}else{const b=h([[o*.6,i*.9],[o+.4*n,i*.92],[o+.62*n,i*.5],[o+.62*n,i*.18]]);p.push(...d(b,.13*n,a.body));const m=b[b.length-1];p.push({k:"group",x:m.x,y:m.y,rot:t.angle,s:n,items:[{k:"path",d:R([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:a.accent,stroke:a.outline,lw:r/n}]})}break}}return p}function $o(e,t,o,r,a){const n=e.palette,i=N(t,P(o,-.08*r)),c=N(t,P(o,.52*r)),u=.2*r;return[{k:"line",pts:[i.x,i.y,c.x,c.y],stroke:n.outline,lw:.06*r+a*2},{k:"line",pts:[i.x,i.y,c.x,c.y],stroke:"#fff3d6",lw:.06*r},{k:"circle",x:c.x,y:c.y,r:.24*r,fill:n.accent,alpha:.28},{k:"group",x:c.x,y:c.y,rot:Math.atan2(o.y,o.x)+Math.PI/2,s:u,items:[{k:"path",d:ye,fill:n.accent,stroke:n.outline,lw:a*.9/u}]}]}function Zo(e,t,o,r,a){const n=e.palette,i=e.extraColors?.[0]??"#cdeeff",c=[];for(const u of[-1,1]){const f=[[[u*o*.3,.12*r],[u*(o+.42*r),-.66*r],[u*(o+1*r),-.74*r],[u*(o+1.02*r),-.18*r],[u*(o+.5*r),.26*r]],[[u*o*.4,.3*r],[u*(o+.6*r),.36*r],[u*(o+.74*r),.78*r],[u*(o+.3*r),.9*r]]];for(const s of f){const h=L(s.map(([y,b])=>t(y,b)),.9);c.push({k:"path",d:h,fill:i,alpha:.6}),c.push({k:"path",d:h,stroke:n.outline,lw:a*.9});const l=s[Math.floor(s.length/2)],d=t(s[0][0],s[0][1]),p=t(s[0][0]+(l[0]-s[0][0])*.75,s[0][1]+(l[1]-s[0][1])*.75);c.push({k:"line",pts:[d.x,d.y,p.x,p.y],stroke:"#ffffff",lw:a*.9,alpha:.85})}for(const[s,h,l]of[[o+.72*r,-.42*r,.075*r],[o+.44*r,-.16*r,.05*r],[o+.5*r,.6*r,.055*r]]){const d=t(u*s,h);c.push({k:"group",x:d.x,y:d.y,s:l,items:[{k:"path",d:ye,fill:"#ffffff"}]})}}return c}function Ko(e,t,o,r,a,n,i,c,u,f){const s=e.palette,h=e.extraColors?.[1]??s.belly,l=[],d=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),p=5,y=Math.max(r,a*.92)*1.08,b=(n*.8+i)/2,m=[0,4,1,3,2];for(const M of m){const S=M/(p-1)-.5,q=t(S*2*y,b+(.5-Math.abs(S))*.1*c);l.push({k:"ellipse",x:q.x,y:q.y,rx:y*.3,ry:.34*c,rot:d-S*.6,fill:M%2?h:s.body,stroke:s.outline,lw:u})}const A=Math.max(.04,f.head*(1-f.neck)-.04)*c;for(const M of[-1,1,0]){const S=t(M*o*.32,A+(M?0:.05*c));l.push({k:"ellipse",x:S.x,y:S.y,rx:o*.26,ry:.12*c,rot:d+M*.5,fill:M?h:s.body,stroke:s.outline,lw:u*.9})}return l}var Go={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 Vo(e,{cx:t=.5,cy:o=.36,T:r=.18}={}){const a={...Go,...e},n=new Array($e*3).fill(0),i=(f,[s,h],l=.99)=>{n[f*3]=t+s*r,n[f*3+1]=o+h*r,n[f*3+2]=l};for(const f of Object.keys(D))i(D[f],a[f]);const c=a.tilt??0,u=(f,s)=>[a.nose[0]+f*Math.cos(c)-s*Math.sin(c),a.nose[1]+f*Math.sin(c)+s*Math.cos(c)];return i(ne.leftEye,u(-.1,-.08)),i(ne.rightEye,u(.1,-.08)),i(ne.leftEar,u(-.22,-.02)),i(ne.rightEar,u(.22,-.02)),n}var Uo=()=>Vo({}),pt=.5,Jo=.15,er=class{constructor(e={}){W(this,"tracks",new Map),W(this,"offset",NaN),W(this,"lastArrival",NaN),W(this,"interval",33),W(this,"lastT",NaN),W(this,"lostMs"),W(this,"maxExtrapolateMs"),this.lostMs=e.lostMs??250,this.maxExtrapolateMs=e.maxExtrapolateMs??25}get delayMs(){return this.interval}push(e,t,o,r=yt()){Number.isFinite(t)||(t=r),this.clock(t,r);const a=this.tracks.get(e);if(!a||t-a.tb>this.lostMs||t<a.tb-this.lostMs||o.length!==a.b.length){this.tracks.set(e,{a:null,ta:t,b:o,tb:t,out:null,outAt:NaN});return}if(o===a.b||t<=a.tb){t===a.tb&&o!==a.b&&(a.b=o,a.out=null);return}a.a=a.b,a.ta=a.tb,a.b=o,a.tb=t,a.out=null}at(e,t=yt()){const o=this.tracks.get(e);if(!o)return null;if(!o.a)return o.b;if(o.out&&o.outAt===t)return o.out;const r=t-this.offset-this.interval,a=o.tb-o.ta,n=Math.min(a*.5,this.maxExtrapolateMs),i=Math.min(Math.max((r-o.ta)/a,0),1+n/a);return o.out=tr(o.a,o.b,i),o.outAt=t,o.out}forget(e){this.tracks.delete(e)}clear(){this.tracks.clear()}clock(e,t){const o=t-e;if(!Number.isFinite(this.offset)||o<this.offset||o>this.offset+1e3?this.offset=o:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(o-this.offset,(t-this.lastArrival)/1e3)),this.lastArrival=t,Number.isFinite(this.lastT)&&e>this.lastT){const r=e-this.lastT;r<this.interval*3+20&&(this.interval+=(Math.min(Math.max(r,8),100)-this.interval)*.1)}e<=this.lastT||(this.lastT=e)}},yt=()=>globalThis.performance?.now()??Date.now();function tr(e,t,o){const r=t.slice(),a=o<.5?e:t;for(let n=0;n+2<t.length;n+=3){const i=e[n],c=e[n+1],u=t[n],f=t[n+1];e[n+2]>=pt&&t[n+2]>=pt&&Math.abs(u-i)+Math.abs(f-c)<Jo?(r[n]=i+(u-i)*o,r[n+1]=c+(f-c)*o,r[n+2]=e[n+2]+(t[n+2]-e[n+2])*Math.min(o,1)):(r[n]=a[n],r[n+1]=a[n+1],r[n+2]=a[n+2])}return r}var Pr=ot.map(e=>e.id),Pe=new Map(ot.map(e=>[e.id,e])),bt=Pe.get("fox"),or=e=>typeof e=="string"&&Pe.has(e),rr=e=>Pe.get(e),kt=e=>typeof e=="string"?Pe.get(e)??bt:e;function ar(e,t,o,r,a={}){const n=Ne(t,kt(o),r,{mirrored:a.mirrored,band:a.band});return n.length?(e.save(),a.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(a.alpha,0),1)),Le(e,n),e.restore(),!0):!1}function nr(e,t,o){const r=kt(e),a=Uo(),n=it(r,o),i=De(a,{x:0,y:0,w:1,h:1},{band:n}),c=mt(st(r,.05)),u=-c.minY,f=Math.min(.27,.43/Math.max(u,1))*t,s=r.head==="snout-long"?(c.minX+c.maxX)/2*f:0,h=f/se[n].head/i.U,l=.5*t+Math.min(0,(u-1.6)*.06*t),d={x:t/2-s-i.head.x*h,y:l-i.head.y*h,w:h,h};return Ne(a,r,d,{portrait:!0,band:n})}function sr(e,t,o=.5){if(!e||e.length!==t.length)return t.slice();const r=t.slice();for(let a=0;a+2<t.length;a+=3){const n=e[a+2],i=t[a+2],c=n>=.5,u=i>=.5;c&&i>=.3&&(r[a+2]=Math.max(i,.5));const f=Math.hypot(t[a]-e[a],t[a+1]-e[a+1]);if(c&&u&&f<.15){const s=o*Math.min(1,xt+(1-xt)*f/lr);r[a]=e[a]+(t[a]-e[a])*s,r[a+1]=e[a+1]+(t[a+1]-e[a+1])*s}else c&&!u&&r[a+2]>=.5&&(r[a]=e[a],r[a+1]=e[a+1])}return fr(e,t,r,o*ir),r}var xt=.1,lr=.03,ir=.35,cr=11;function fr(e,t,o,r){const a=D.leftShoulder*3,n=D.rightShoulder*3,i=(h,l)=>h[l+2]>=.5;if(!i(e,a)||!i(e,n)||!i(t,a)||!i(t,n))return;const c=(h,l)=>(h[a+l]+h[n+l])/2,u=[c(e,0),c(e,1)],f=[c(t,0),c(t,1)],s=[c(o,0),c(o,1)];for(let h=0;h<cr&&h*3+2<t.length;h++){const l=h*3;if(!i(e,l)||!i(t,l))continue;const d=[e[l]-u[0],e[l+1]-u[1]],p=[t[l]-f[0],t[l+1]-f[1]];Math.hypot(p[0]-d[0],p[1]-d[1])>=.15||(o[l]=s[0]+d[0]+(p[0]-d[0])*r,o[l+1]=s[1]+d[1]+(p[1]-d[1])*r)}}function mt(e){const t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},o=(r,a)=>{t.minX=Math.min(t.minX,r),t.minY=Math.min(t.minY,a),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,a)};for(const r of e){const a="lw"in r&&r.stroke?(r.lw??1)/2:0;switch(r.k){case"circle":o(r.x-r.r-a,r.y-r.r-a),o(r.x+r.r+a,r.y+r.r+a);break;case"ellipse":case"rect":{const n=r.k==="ellipse"?r.rx:r.w/2,i=r.k==="ellipse"?r.ry:r.h/2,c=Math.max(n,i)+a;o(r.x-c,r.y-c),o(r.x+c,r.y+c);break}case"path":{const n=go(r.d);for(let i=0;i+1<n.length;i+=2)o(n[i]-a,n[i+1]-a),o(n[i]+a,n[i+1]+a);break}case"line":for(let n=0;n+1<r.pts.length;n+=2)o(r.pts[n]-a,r.pts[n+1]-a),o(r.pts[n]+a,r.pts[n+1]+a);break;case"group":{const n=mt(r.items);if(!Number.isFinite(n.minX))break;const i=r.s??1,c=Math.cos(r.rot??0),u=Math.sin(r.rot??0);for(const[f,s]of[[n.minX,n.minY],[n.maxX,n.minY],[n.minX,n.maxY],[n.maxX,n.maxY]])o(r.x+(f*c-s*u)*i,r.y+(f*u+s*c)*i);break}}}return t}var ur=()=>{const e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},gt=()=>globalThis.performance?.now()??Date.now(),wt=class{constructor(e=ur){W(this,"now",e),W(this,"known",new Map),W(this,"smoothed",new Map),W(this,"times",new WeakMap),W(this,"lerp",new er),W(this,"drawnAt",NaN),W(this,"drawn",0),W(this,"smoothedBody",(t,o={})=>{const r=o.interpolate!==!1;if(typeof t=="number"){const a=this.smoothed.get(t);return a?r?this.lerp.at(t,this.tick())??a.body:a.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,vt(o.smooth),r)})}note(e,t,o=gt()){for(const r of e)this.known.set(r.id,this.resolve(r.id,r.avatar)),t!==void 0&&Number.isFinite(t)&&Array.isArray(r.body)&&this.times.set(r.body,{t,arrival:o})}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)??Ke(e-1)}posed(e,t,o,r=!0){const a=this.smooth(e,t,o);return r?this.lerp.at(e,this.tick())??a:a}smooth(e,t,o){const r=this.smoothed.get(e);if(r&&r.raw===t&&r.amount===o)return r.body;r&&r.amount!==o&&this.lerp.forget(e);const a=o<1?sr(r?.body,t,o):t;this.smoothed.set(e,{raw:t,body:a,amount:o});const n=this.times.get(t),i=n?.arrival??gt();return this.lerp.push(e,n?.t??i,a,i),a}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 or(t)?t:Ke(e-1)}};function hr(e,t){const o=typeof e.getTransform=="function"?e.getTransform():null,r=o&&Math.hypot(o.a,o.b)||1,a=o&&Math.hypot(o.c,o.d)||1,n=(e.canvas?.width??0)/r,i=(e.canvas?.height??0)/a;return t?{x:t.x*n,y:t.y*i,w:t.w*n,h:t.h*i}:{x:0,y:0,w:n,h:i}}var vt=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function Et(e,t){return(o,r,a,n,i={})=>{const c=Array.isArray(r)?null:r,u=c?c.body:r;if(!Array.isArray(u))return null;const f=typeof a=="string"?a:e.of(typeof a=="number"?a:c??1),s=typeof a=="number"?a:c?.id,h=s!==void 0?e.posed(s,u,vt(i.smooth),i.interpolate!==!1):u;return ar(o,h,f,n??hr(o,t().view),i.alpha!==void 0?{alpha:i.alpha}:{})?h:null}}function dr(e){const t=new Map,o=(s,h)=>t.get(s)?.forEach(l=>l(h));let r=null,a=null;const n=new Map,i=[],c=s=>r?s(r):i.push(s),u=new wt,f=Et(u,()=>({view:null}));return e.then(s=>{r=s;const h=new Map;s.on("gesture",l=>o(l.gesture,{player:l.player})),s.on("pause",l=>o("pause",{reason:l.reason==="distance"?"distance":"user"})),s.on("resume",()=>o("resume",{})),s.on("break-start",()=>o("break-start",{})),s.on("break-done",l=>o("break-end",{shown:l.shown})),s.onBackdrop((l,d)=>o("backdrop",{backdrop:l,view:d})),s.on("turn",l=>o("turn",{players:[...l.players]})),s.on("capabilities",l=>o("capabilities",{pictures:l.pictures})),s.on("frame",l=>{o("players",{players:l.players});for(const d of l.players)o("hands",{player:d.id,left:d.leftHand,right:d.rightHand}),h.get(d.id)!==d.shape&&(h.set(d.id,d.shape),o("shape",{player:d.id,shape:d.shape}))}),a=pr(s),o("start",a),i.splice(0).forEach(l=>l(s))}),{on(s,h){const l=t.get(s)??new Set;return t.set(s,l),l.add(h),s==="start"&&a&&h(a),()=>{l.delete(h)}},ready:()=>c(s=>s.ready()),score:(s,h)=>c(l=>{const d=h??At(l);n.set(d,s),l.score(d,s)}),break:s=>new Promise(h=>c(l=>{l.break(s).then(h)})),end:s=>c(h=>h.end(typeof s=="number"?yr(h,s,n):s.map(l=>({player:l.player,score:l.score,stars:l.stars??2})))),keys:(s,h)=>c(l=>{Ft(l,s,h)}),pointer:s=>c(h=>{Xt(h,s)}),get players(){return r?.players??Mt},get turns(){return r?.turns??Mt},get input(){return r?.input??"body"},get hasPointer(){return r?.pointer??!1},get canSavePicture(){return r?.canSavePicture??!1},savePicture:(s,h)=>new Promise(l=>c(d=>{d.savePicture(s,h).then(l)})),get muted(){return r?.muted??!1},get view(){return r?.view??null},get device(){return r?.device??null},reportStats:s=>r?.reportStats(s),toScreen:s=>r?r.toScreen(s):Ue(null,s),avatarOf:s=>r?r.avatarOf(s):u.of(s),drawAvatar:(...s)=>r?r.drawAvatar(...s):f(...s),smoothedBody:(...s)=>r?r.smoothedBody(...s):u.smoothedBody(...s)}}var Mt=Object.freeze([]),pr=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,canSavePicture:e.canSavePicture,muted:e.muted}),At=e=>e.input==="remote"?e.players[0]??1:1;function yr(e,t,o){const r=At(e);return e.input!=="remote"?[{player:r,score:t,stars:2}]:[...e.turns.slice(0,Math.max(e.turns.indexOf(r),0)).map(n=>({player:n,score:o.get(n)??0,stars:2})),{player:r,score:t,stars:2}]}var br=[Zt,.7,.55],Ct=.75,kr=320;function xr(e){if(typeof e=="string"){const t=Ye(e);return"ok"in t?{data:e}:{error:t.error==="too-big"?"too-big":"error"}}try{if(!e||typeof e.toDataURL!="function")return{error:"error"};const{width:t,height:o}=e;if(!(t>0&&o>0))return{error:"error"};const r=e.ownerDocument??document;let a=Math.min(1,$t/Math.max(t,o));for(;;){const n=Math.max(1,Math.round(t*a)),i=Math.max(1,Math.round(o*a)),c=r.createElement("canvas");c.width=n,c.height=i;const u=c.getContext("2d");if(!u)return{error:"error"};u.fillStyle="#fff",u.fillRect(0,0,n,i),u.drawImage(e,0,0,n,i);for(const f of br){const s=c.toDataURL("image/jpeg",f),h=Ye(s);if("ok"in h)return{data:s};if(h.error!=="too-big")return{error:"error"}}if(Math.max(n,i)*Ct<kr)return{error:"too-big"};a*=Ct}}catch{return{error:"error"}}}var mr=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",o=>o.source===e.parent&&t(o.data))}),gr=1e4,wr=1e3,vr=12e4;function Er(e=mr(),t={}){return new Promise((o,r)=>{const a=new Map,n=[];let i=!1,c=!1,u=!1,f="none",s=null,h="body",l=Object.freeze([]),d=l,p=!1,y=0;const b=new Map;let m;const A=()=>{if(m===void 0){const J=t.cursor!==void 0?t.cursor:typeof document<"u"?Yt():null;m=J?qt(J):null}return m},M=new Set,S=new wt,q=Et(S,()=>({view:s})),oe=S.smoothedBody,le=setTimeout(()=>r(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),gr);e.listen(J=>{if(typeof J!="object"||J===null||J.ns!==Ge)return;const x=J;if(x.type==="init"&&!u){if(x.v!==qe)return clearTimeout(le),r(new Error(`Fabi Play: protocol ${x.v}, this SDK speaks ${qe}`));u=!0,clearTimeout(le),f=x.backdrop==="video"?"video":"none",s=Ve(x.view)??null;const O=lo(x.device)??null;h=x.input==="remote"?"remote":"body";const E=h==="remote"&&x.pointer===!0;p=x.pictures===!0,l=Object.freeze(Array.isArray(x.players)?[...x.players]:[]);const F=h==="remote"&&l.length===1?ho(x.turns):void 0;d=Object.freeze(F&&F[0]===l[0]?F:[...l]);let $={};if(x.stats===!0){let T=performance.now();setInterval(()=>{const X=performance.now();e.post(pe({type:"stats",renderFps:Math.round(S.takeDrawn()*1e3/Math.max(X-T,1)),...$})),T=X},wr).unref?.()}o({locale:x.locale,mode:x.mode,get players(){return l},turns:d,input:h,pointer:E,muted:x.muted,ageRange:x.ageRange??"6-8",get backdrop(){return f},get view(){return s},device:O,reportStats:T=>{$=io(T)},toScreen:T=>Ue(s,T),avatarOf:T=>S.of(T),drawAvatar:q,smoothedBody:oe,onBackdrop(T){return M.add(T),()=>{M.delete(T)}},on(T,v){const X=a.get(T)??new Set;return a.set(T,X),X.add(v),()=>{X.delete(v)}},ready:()=>e.post(pe({type:"ready"})),score:(T,v)=>e.post(pe({type:"score",player:T,score:v})),break:(T="level")=>new Promise(v=>{n.push({reason:T,done:v}),e.post(pe({type:"break",reason:T}))}),end:T=>e.post(pe({type:"end",scores:T})),get canSavePicture(){return p},savePicture:async(T,v)=>{if(!p)return"unavailable";const X=xr(T);if("error"in X)return X.error;const be=++y,we=ro(v?.title);return new Promise(Qe=>{const Oe=setTimeout(()=>ve("error"),vr);Oe.unref?.();const ve=G=>{clearTimeout(Oe),b.delete(be),Qe(G)};b.set(be,ve),e.post(pe({type:"picture",data:X.data,id:be,...we?{title:we}:{}}))})}})}else if(u){let O=x;if(x.type==="frame"&&Array.isArray(x.players)&&S.note(x.players,x.t),x.type==="backdrop"){if(x.backdrop!=="video"&&x.backdrop!=="none")return;const E=Ve(x.view)??null;if(x.backdrop===f&&Mr(E,s))return;f=x.backdrop,s=E,O={type:"backdrop",backdrop:f,...s?{view:s}:{}};for(const F of[...M])F(f,s)}if(x.type==="turn"){const E=h==="remote"&&i&&!c&&n[0]?.reason==="turn"?uo(x.players):void 0,F=l[0];if(!E||F===void 0||d.indexOf(E[0])<=d.indexOf(F))return;c=!0,l=Object.freeze(E),O={type:"turn",players:[...E]}}if(x.type==="picture-result"){const E=fo(x);E?.id!==void 0&&b.get(E.id)?.(E.result);return}if(x.type==="capabilities"){if(typeof x.pictures!="boolean"||x.pictures===p)return;p=x.pictures,O={type:"capabilities",pictures:p}}if(x.type==="cursor"){const E=h==="remote"?co(x):void 0;if(!E)return;O=E,A()?.update(E)}(x.type==="pause"||x.type==="break-start"||x.type==="turn")&&m?.cancel(),x.type==="break-start"&&(i=n.length>0);for(const E of a.get(x.type)??[])E(O);x.type==="break-done"&&(i=c=!1,n.shift()?.done(x.shown))}else return})})}var Mr=(e,t)=>e===t||e!==null&&t!==null&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,St={};je(St,{BAND_BODY:()=>se,DEFAULT_AVATAR:()=>bt,avatarById:()=>rr,avatarShapes:()=>Ne,drawShapes:()=>Le,frameOf:()=>De,iconShapes:()=>nr});function Ar(e){const t=Er(),o=dr(t);e?.dataset.mute!=="manual"&&Dt(t);const r=Object.assign(o,{avatars:{...St}});window.FabiPlay=r;const a=e?.dataset.keys;a&&o.keys(Qt(a));const n=e?.dataset.pointer;return n&&o.pointer({hand:n==="left"||n==="right"?n:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?o.ready():window.addEventListener("load",()=>o.ready(),{once:!0})),r}return ue.exports.install(_e)});
|
|
1
|
+
/*! @fabi-play/sdk 0.7.0 | Fabi Play Kit License | https://docs.fabiplay.app */(function(Re,he){var ze=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return he(ze)}):typeof module=="object"&&module&&module.exports?module.exports=he(ze):Re.FabiPlay=he(ze)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(Re){"use strict";var he={exports:{}},ze=he.exports,Pe=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Dt=Object.getOwnPropertyNames,Nt=Object.prototype.hasOwnProperty,Ht=(e,t,r)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,We=(e,t)=>{for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})},Qt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Dt(t))!Nt.call(e,a)&&a!==r&&Pe(e,a,{get:()=>t[a],enumerable:!(o=Rt(t,a))||o.enumerable});return e},jt=e=>Qt(Pe({},"__esModule",{value:!0}),e),Y=(e,t,r)=>Ht(e,typeof t!="symbol"?t+"":t,r),Xe={};We(Xe,{install:()=>Dr}),he.exports=jt(Xe);function Bt(e,t=window){const r=new Set,o=t.AudioContext;o&&(t.AudioContext=class extends o{constructor(...i){super(...i),r.add(this)}});let a=[],n=[];Promise.resolve(e).then(i=>{i.on("break-start",()=>{a=[...t.document.querySelectorAll("audio, video")].filter(c=>!c.paused),a.forEach(c=>c.pause()),n=[...r].filter(c=>c.state==="running"),n.forEach(c=>{c.suspend()})}),i.on("break-done",()=>{a.forEach(c=>{c.play().catch(()=>{})}),n.forEach(c=>{c.resume()}),a=[],n=[]})})}var Ft={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function Wt(e){if(e.trim()==="default")return;const t={};for(const r of e.split(",")){const[o,a]=r.split(":").map(n=>n.trim());o&&a&&(t[o]=a)}return t}var Xt={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function Ye(e){const t=Xt[e];if(t)return{key:t[0],code:e,keyCode:t[1]};const r=/^Key([A-Z])$/.exec(e);if(r)return{key:r[1].toLowerCase(),code:e,keyCode:r[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 Yt=(e=document)=>({dispatch(t,r){const o=new KeyboardEvent(t,{key:r.key,code:r.code,bubbles:!0,cancelable:!0});for(const a of["keyCode","which"])Object.defineProperty(o,a,{get:()=>r.keyCode});(e.activeElement??e.body??e).dispatchEvent(o)}}),qe=80,qt=800;function $t(e,t=Ft,r={}){const o=r.player===void 0&&e.input==="remote";let a=r.player??(o?e.players?.[0]??1:1);const n=r.target??Yt(),i=r.setTimeout??((y,b)=>setTimeout(y,b)),c=new Set;let u=0;const f=y=>{const b=t[y];!b||c.has(y)||(c.add(y),n.dispatch("keydown",Ye(b)))},s=y=>{const b=t[y];!b||!c.has(y)||(c.delete(y),n.dispatch("keyup",Ye(b)))},h=y=>{f(y),i(()=>s(y),qe)},l=y=>{if(y.player!==a)return;const b={"lane-left":-1,"lane-center":0,"lane-right":1};switch(y.gesture){case"jump":f("jump"),i(()=>s("jump"),qt);break;case"land":s("jump");break;case"squat":f("squat");break;case"stand":s("squat");break;case"clap":h("clap");break;default:{const x=b[y.gesture];if(x===void 0)break;const S=x>u?"right":"left";for(let v=0;v<Math.abs(x-u);v++)i(()=>h(S),v*(qe*2));u=x}}},d=y=>{const b=y.players.find(x=>x.id===a);b&&(b.shape==="arms-up"?f("arms-up"):s("arms-up"))},p=[e.on("gesture",l),e.on("frame",d),e.on("break-start",()=>[...c].forEach(s)),e.on("turn",y=>{o&&([...c].forEach(s),a=y.players[0]??a,u=0)})];return()=>{p.forEach(y=>y()),[...c].forEach(s)}}function Zt(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 r=(o,a,...n)=>{const i=e.elementFromPoint(o,a)??e.body;for(const c of n){const u={bubbles:!0,cancelable:!0,clientX:o,clientY:a,pointerId:1,pointerType:"touch",isPrimary:!0};i.dispatchEvent(c.startsWith("pointer")?new PointerEvent(c,u):new MouseEvent(c,u))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(o,a)=>r(o,a,"pointermove","mousemove"),click:(o,a)=>r(o,a,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(o,a,n)=>{t.style.transform=`translate(${o}px, ${a}px) scale(${1-n*.35})`,t.style.borderColor=n>0?"#EE6A43":"#FBE7B8"}}}function Kt(e,t={}){const r=t.player??1,o=t.hand??"any",a=t.dwellMs??800,n=t.radius??.04,i=t.target??Zt();let c=null,u=!1;return e.on("frame",f=>{const s=f.players.find(v=>v.id===r);if(!s)return;const l=o==="left"?s.leftHand:o==="right"?s.rightHand:((v,z)=>v&&z?v.y<z.y?v:z:v??z)(s.leftHand,s.rightHand);if(!l)return;const{width:d,height:p}=i.size(),y=l.x*d,b=l.y*p;i.move(y,b),(!c||Math.hypot(y-c.x,b-c.y)>n*Math.hypot(d,p))&&(c={x:y,y:b,t:f.t},u=!1);const S=u?0:Math.min((f.t-c.t)/a,1);S>=1&&(u=!0,i.click(c.x,c.y)),i.cursor(y,b,u?0:S)})}function Gt(e=document){const t=e.defaultView,r=t?.PointerEvent,o=t?.MouseEvent??MouseEvent;let a=null,n=null;const i=(c,u,f,s,h,l=null)=>{const d={bubbles:!0,cancelable:!0,composed:!0,view:t,clientX:f,clientY:s,screenX:f,screenY:s,button:0,buttons:h,relatedTarget:l,pointerId:1,pointerType:"mouse",isPrimary:!0};u.startsWith("pointer")?r&&c.dispatchEvent(new r(u,d)):c.dispatchEvent(new o(u,d))};return{size:()=>({width:t?.innerWidth??e.documentElement.clientWidth,height:t?.innerHeight??e.documentElement.clientHeight}),dispatch(c,u,f,s){const h=e.elementFromPoint(u,f)??e.body??e.documentElement;if(c==="pointermove"&&h!==a){if(a?.isConnected)for(const l of["pointerout","mouseout"])i(a,l,u,f,s,h);for(const l of["pointerover","mouseover"])i(h,l,u,f,s,a);a=h}if(c==="pointerdown"&&(n=h),c==="click"){const l=n===h;if(n=null,!l)return}i(h,c,u,f,s)}}}function Vt(e){let t=null;const r=(o,a,n,i)=>{const{width:c,height:u}=e.size();for(const f of o)e.dispatch(f,a*c,n*u,i)};return{update(o){const a=t?.down??!1;(!t||t.x!==o.x||t.y!==o.y)&&r(["pointermove","mousemove"],o.x,o.y,a?1:0),o.down&&!a&&r(["pointerdown","mousedown"],o.x,o.y,1),!o.down&&a&&r(["pointerup","mouseup","click"],o.x,o.y,0),t={x:o.x,y:o.y,down:o.down}},cancel(){t?.down&&(r(["pointercancel","mouseup"],t.x,t.y,0),t={...t,down:!1})}}}var $e=3*1024*1024,Ut=1920,Jt=.85,eo=60,to=["sent","unavailable","too-big","error"],oo=/^[A-Za-z0-9+/]*={0,2}$/,ro={"image/jpeg":"/9j/","image/png":"iVBORw0KGg"},ao=/^data:(image\/(?:jpeg|png));base64,/,no=e=>e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0),so=Math.ceil($e/3)*4,lo=(e,t)=>t.length%4===0&&t.length>0&&t.startsWith(ro[e])&&oo.test(t);function Ze(e){if(typeof e!="string")return{error:"invalid"};const t=ao.exec(e);if(!t)return{error:"invalid"};const r=t[1],o=e.slice(t[0].length);if(o.length>so)return{error:"too-big"};if(!lo(r,o))return{error:"invalid"};const a=no(o);return a>$e?{error:"too-big"}:{ok:{mime:r,base64:o,size:a}}}function io(e){return typeof e!="string"?void 0:Array.from(e.replace(/[\p{Cc}\p{Cf}]/gu,"").trim()).slice(0,eo).join("").trim()||void 0}var Ke=1,Ge=33,A={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},co=["3-5","6-8","9-12"],fo=e=>co.includes(e),De=4,Ve={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},uo=Ve["6-8"],Ue=(e,t)=>{const r=fo(t)?Ve[t]:uo;return r[Number.isInteger(e)&&e>=0?e%r.length:0]},Je="fabi-play",ye=e=>({ns:Je,...e});function et(e){if(!be(e))return;const{x:t,y:r,w:o,h:a}=e;return G(t)&&G(r)&&G(o)&&G(a)&&o>0&&a>0?{x:t,y:r,w:o,h:a}:void 0}var Ne=(e,t)=>e?{x:e.x+t.x*e.w,y:e.y+t.y*e.h}:{x:t.x,y:t.y},ho=.5,_e={left:1.6,top:1.6,w:3.2,h:3},po=1.2;function yo(e,t,r={}){const o=Array.isArray(e)?e:e.body;if(!Array.isArray(o))return null;const a=t==="left"?A.leftWrist:A.rightWrist,n=x=>G(o[x*3])&&G(o[x*3+1])&&(o[x*3+2]??0)>=ho?x:-1;if(n(a)<0)return null;const i=o[a*3],c=o[a*3+1];if(r.orientation!=="portrait")return Ne(r.view,{x:i,y:c});if(n(A.leftShoulder)<0||n(A.rightShoulder)<0)return null;const u=A.leftShoulder*3,f=A.rightShoulder*3,s=(o[u]+o[f])/2,h=(o[u+1]+o[f+1])/2,l=A.leftHip*3,d=A.rightHip*3,p=(o[l]+o[d])/2,y=(o[l+1]+o[d+1])/2;let b=G(p)&&G(y)?Math.hypot(p-s,y-h):0;return(n(A.leftHip)<0||n(A.rightHip)<0)&&(b=Math.max(b,po*Math.hypot(o[u]-o[f],o[u+1]-o[f+1]))),b=Math.max(b,.01),{x:nt((i-s+_e.left*b)/(_e.w*b)),y:nt((c-h+_e.top*b)/(_e.h*b))}}var bo=300,tt=class{constructor(e=bo){Y(this,"holdMs",e),Y(this,"last",new Map)}static key(e,t){return e*2+(t==="right"?1:0)}at(e,t,r){const o=this.last.get(e);return t?(o?(o.x=t.x,o.y=t.y,o.t=r):this.last.set(e,{x:t.x,y:t.y,t:r}),t):o?r-o.t<=this.holdMs?{x:o.x,y:o.y}:(this.last.delete(e),null):null}clear(){this.last.clear()}},ko=.25,ot=Object.freeze({top:0,bottom:0,left:0,right:0});function xo(e){if(!be(e))return;const t=r=>G(r)?Math.min(Math.max(r,0),ko):0;return{top:t(e.top),bottom:t(e.bottom),left:t(e.left),right:t(e.right)}}var rt=["high","medium","low"];function mo(e){if(!be(e))return;const t={};return rt.includes(e.tier)&&(t.tier=e.tier),G(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function go(e){const t={};return be(e)&&(G(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),rt.includes(e.tier)&&(t.tier=e.tier)),t}function wo(e){if(!be(e)||!G(e.x)||!G(e.y)||typeof e.down!="boolean")return;const t=r=>Math.min(Math.max(r,0),1);return{type:"cursor",x:t(e.x),y:t(e.y),down:e.down}}function vo(e){if(!(!be(e)||!to.includes(e.result)))return{type:"picture-result",...Number.isInteger(e.id)?{id:e.id}:{},result:e.result}}var at=e=>Number.isInteger(e)&&e>=1&&e<=De;function Eo(e){return Array.isArray(e)&&e.length===1&&at(e[0])?[e[0]]:void 0}function Mo(e){if(!(!Array.isArray(e)||e.length<1||e.length>De||!e.every(at)||new Set(e).size!==e.length))return[...e]}var Hr=16/9,be=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),G=e=>typeof e=="number"&&Number.isFinite(e),nt=e=>Math.min(Math.max(e,0),1),Ao=12,So=Ge*4,Co=e=>Ao+e*So,Qr=Co(De),V="#4a382c",q="#2b2118",ee="#1c1f2b",st="#fbefe3",te="#f4897a",ve="#3a2a22",lt=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:st,accent:"#ffd9c2",outline:q,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:ve,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:st,accent:"#5a3426",outline:q,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:ve,muzzle:"band",cheeks:te},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:V},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:te},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:V},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:ve,muzzle:"oval",cheeks:te},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:V,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:te},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:V,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:V,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:V},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",alsoIn:["3-5"],palette:{body:"#f6c454",limbs:"#f6c454",belly:"#fde7b0",accent:"#fde7b0",outline:q},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:te},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:q,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:q},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:ee,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:ee,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:q},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:q,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:te},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:V},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:q},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:te},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:V,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:V,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:ee},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:q},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:q,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:V,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:te},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:V,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:ve,muzzle:"oval",cheeks:te},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:V,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:te},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:V,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:te},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:q,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:q,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:ve,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:q,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:q,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:ee,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:ee,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:ee,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:ee,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:ee,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:ee,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:ee,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:ee,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:ee,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"]},{id:"trex",name:{en:"T-Rex",it:"T-Rex"},band:"6-8",alsoIn:["3-5"],palette:{body:"#6cb84e",limbs:"#6cb84e",belly:"#f4e8a8",accent:"#f4e8a8",outline:q},head:"snout-long",ears:"none",face:{eyes:"dot",mouth:"toothy",muzzle:"none",cheeks:"#f59b8f"},tail:"thick",headExtras:["stripes"],bodyExtras:["tiny-arms","strong-legs"],extraColors:["#4a9235","#58a23f"]},{id:"fairy",name:{en:"Fairy",it:"Fatina"},band:"6-8",alsoIn:["3-5"],palette:{body:"#b99af0",limbs:"#a8693f",belly:"#b99af0",accent:"#ffd84a",outline:q,skin:"#a8693f",hair:"#2e1d17",hands:"#a8693f",feet:"#f58cbc"},head:"round",ears:"pixie",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f0857a"},tail:"none",headExtras:["bun","flower-crown"],bodyExtras:["wings-fairy","petals","wand"],extraColors:["#c4ecff","#f7a8cf","#fff3a0","#ffffff"]}],B={M:0,L:1,Q:2,C:3,Z:4},it=[2,2,4,6,0];function He(e,t){for(const r of t)To(e,r)}function To(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),He(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":zo(e,t);break;case"path":typeof t.d=="string"?Oo(e,t.d):Po(e,t.d);break;case"line":e.moveTo(t.pts[0]??0,t.pts[1]??0);for(let r=2;r+1<t.pts.length;r+=2)e.lineTo(t.pts[r],t.pts[r+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 zo(e,t){const r=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,a=-t.h/2;e.moveTo(o+r,a),e.lineTo(o+t.w-r,a),e.quadraticCurveTo(o+t.w,a,o+t.w,a+r),e.lineTo(o+t.w,a+t.h-r),e.quadraticCurveTo(o+t.w,a+t.h,o+t.w-r,a+t.h),e.lineTo(o+r,a+t.h),e.quadraticCurveTo(o,a+t.h,o,a+t.h-r),e.lineTo(o,a+r),e.quadraticCurveTo(o,a,o+r,a),e.closePath()}function Po(e,t){for(let r=0;r<t.length;){const o=t[r++];if(o===B.M)e.moveTo(t[r],t[r+1]);else if(o===B.L)e.lineTo(t[r],t[r+1]);else if(o===B.Q)e.quadraticCurveTo(t[r],t[r+1],t[r+2],t[r+3]);else if(o===B.C)e.bezierCurveTo(t[r],t[r+1],t[r+2],t[r+3],t[r+4],t[r+5]);else if(o===B.Z)e.closePath();else return;r+=it[o]}}function _o(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);const t=[];for(let r=0;r<e.length;){const o=it[e[r++]];if(o===void 0)break;for(let a=0;a<o;a++)t.push(e[r+a]);r+=o}return t}function Oo(e,t){const r=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let o="",a=0;const n=()=>Number(r[a++]);for(;a<r.length;){const i=r[a];if(/[MLQCZ]/i.test(i)&&(o=i.toUpperCase(),a++,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()):a++}}var L=e=>{const t=Math.round(e*100)/100;return t===0?0:t};function D(e,t=.5){const r=e.length;if(r<3)return[];const o=(c,u,f)=>({x:c.x+(u.x-c.x)*f,y:c.y+(u.y-c.y)*f}),a=Math.min(Math.max(t,0),.5),n=o(e[0],e[1],a),i=[B.M,L(n.x),L(n.y)];for(let c=1;c<=r;c++){const u=e[(c-1)%r],f=e[c%r],s=e[(c+1)%r],h=o(u,f,1-a),l=o(f,s,a);i.push(B.L,L(h.x),L(h.y),B.Q,L(f.x),L(f.y),L(l.x),L(l.y))}return i.push(B.Z),i}function R(e,t=1){const r=e.length;if(r<3)return[];const o=[B.M,L(e[0].x),L(e[0].y)],a=t/6;for(let n=0;n<r;n++){const i=e[(n-1+r)%r],c=e[n],u=e[(n+1)%r],f=e[(n+2)%r];o.push(B.C,L(c.x+(u.x-i.x)*a),L(c.y+(u.y-i.y)*a),L(u.x-(f.x-c.x)*a),L(u.y-(f.y-c.y)*a),L(u.x),L(u.y))}return o.push(B.Z),o}function Ee(e){const t=e.length;if(t<2)return[];const r=[B.M,L(e[0].x),L(e[0].y)];for(let o=0;o<t-1;o++){const a=e[Math.max(o-1,0)],n=e[o],i=e[o+1],c=e[Math.min(o+2,t-1)];r.push(B.C,L(n.x+(i.x-a.x)/6),L(n.y+(i.y-a.y)/6),L(i.x-(c.x-n.x)/6),L(i.y-(c.y-n.y)/6),L(i.x),L(i.y))}return r}var ke="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",F="#ffffff",C=[-1,1],ct="#3a2420",ft="#f2808f",Qe="#26324a",Io="#ffd84a",Q=(...e)=>{const t=[];for(let r=0;r+1<e.length;r+=2)t.push({x:e[r],y:e[r+1]});return t};function ut(e,t){const r=e.palette,o=[],a={stroke:r.outline,lw:t},n=s=>e.headExtras.includes(s),i=(s,h)=>e.extraColors?.[s]??h;if(n("mane")){for(let h=0;h<12;h++){const l=h/12*Math.PI*2;o.push({k:"circle",x:Math.cos(l)*1.02,y:Math.sin(l)*1+.04,r:.42,fill:i(0,r.accent),...a})}o.push({k:"circle",x:0,y:.04,r:1.08,fill:i(0,r.accent)})}if(n("rainbow-mane")){const s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([l,d,p,y,b],x)=>o.push({k:"ellipse",x:l,y:d,rx:p,ry:y,rot:b,fill:s[x%s.length],...a}))}if(n("spikes"))for(const s of[-.55,0,.55]){const h=de(s,1.48),l=de(s-.32,.86),d=de(s+.32,.86);o.push({k:"path",d:D([l,h,d],.22),fill:r.accent,...a})}if(n("curl")&&o.push({k:"path",d:R([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:r.body,...a}),n("wool"))for(let s=0;s<=8;s++){const h=-1.75+s/8*3.5;o.push({k:"circle",x:Math.sin(h)*.98,y:-Math.cos(h)*.92-.04,r:.34,fill:r.body,...a})}if(n("crest")&&[-.38,0,.38].forEach((s,h)=>{const l=de(s,1.12);o.push({k:"ellipse",x:l.x,y:l.y,rx:.15,ry:.42,rot:s,fill:i(h,r.accent),...a})}),n("plume")&&o.push({k:"path",d:R(Q(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:r.accent,...a}),n("locks")&&o.push({k:"path",d:R(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:r.hair??r.outline,...a}),n("bun")&&o.push({k:"circle",x:.04,y:-1.14,r:.4,fill:r.hair??r.outline,...a}),n("ninja-hood"))for(const[s,h]of[[.35,.5],[.85,.42]])o.push({k:"ellipse",x:1+Math.cos(s)*h*.8,y:-.5+Math.sin(s)*h*.8,rx:h,ry:.11,rot:s,fill:r.accent,...a});if(n("bandana"))for(const[s,h]of[[Math.PI-.5,.42],[Math.PI-1,.36]])o.push({k:"ellipse",x:-.98+Math.cos(s)*h*.8,y:-.36+Math.sin(s)*h*.8,rx:h,ry:.12,rot:s,fill:r.accent,...a});if(n("ruff"))for(const s of C)o.push({k:"path",d:D(Q(s*.7,-.3,s*1.32,0,s*1.02,.18,s*1.26,.46,s*.86,.56,s*.98,.84,s*.4,.7),.25),fill:r.body,...a});if(e.face.eyesOnTop)for(const s of C)o.push({k:"circle",x:s*.46,y:-.72,r:.38,fill:r.body,...a});o.push(...Qo(e,t)),o.push(Lo(e,a));const c=e.face.muzzle,u=r.belly;if(c==="oval"&&o.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:u}),c==="monkey"){for(const s of C)o.push({k:"circle",x:s*.32,y:-.04,r:.38,fill:u});o.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:u})}if(c==="heart"){for(const s of C)o.push({k:"circle",x:s*.36,y:.02,r:.5,fill:u});o.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:u})}if(c==="disc")for(const s of C)o.push({k:"circle",x:s*.4,y:.02,r:.44,fill:u});if(c==="cheeks")for(const s of C)o.push({k:"ellipse",x:s*.4,y:.44,rx:.44,ry:.32,fill:u});if(c==="band"&&o.push({k:"path",d:Ho(e,t),fill:u}),n("stripes")&&e.head==="snout-long"){const s=i(0,r.outline);for(const[h,l,d,p]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])o.push({k:"line",pts:[h,l,d,p],stroke:s,lw:.11})}else if(n("stripes")){const s=i(0,r.outline);o.push({k:"line",pts:[0,-.97,0,-.66],stroke:s,lw:.13});for(const h of C)o.push({k:"line",pts:[h*.3,-.93,h*.24,-.7],stroke:s,lw:.1}),o.push({k:"line",pts:[h*.98,-.05,h*.74,0],stroke:s,lw:.1}),o.push({k:"line",pts:[h*.94,.22,h*.74,.22],stroke:s,lw:.09})}if(n("spots")){const s=i(1,r.belly);o.push({k:"circle",x:-.55,y:-.5,r:.15,fill:s}),o.push({k:"circle",x:.58,y:-.42,r:.11,fill:s}),o.push({k:"circle",x:.22,y:-.76,r:.09,fill:s})}if(e.head==="snout-long")for(const[s,h,l]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])o.push({k:"ellipse",x:s,y:h,rx:l,ry:l*.8,rot:-.3,fill:r.outline,alpha:.85});if(n("forehead")&&o.push({k:"path",d:R(Q(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:i(0,r.accent)}),n("eye-spot")&&o.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:r.ears??r.accent}),n("gills"))for(const s of C)for(const h of[0,.12,.24])o.push({k:"path",d:`M${s*(.66+h)} 0.06 Q${s*(.6+h)} 0.22 ${s*(.66+h)} 0.38`,stroke:r.accent,lw:t*.9});const f=r.hair??r.outline;if(n("hair")&&o.push({k:"path",d:R(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,...a}),n("locks")&&o.push({k:"path",d:R(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,...a}),n("bun")&&o.push({k:"path",d:R(Q(-1.02,-.1,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1.02,-.1,.84,-.36,.5,-.56,.12,-.48,-.22,-.6,-.6,-.5,-.86,-.36)),fill:f,...a}),n("curls")){for(let s=0;s<7;s++){const h=de(-1.3+s/6*2.6,.86);o.push({k:"circle",x:h.x,y:h.y,r:.3,fill:f,...a})}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:r.skin??F,stroke:r.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:r.accent,...a})),n("domino")){o.push({k:"path",d:R(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:r.accent,...a});for(const s of C)o.push({k:"ellipse",x:s*.38,y:0,rx:.19,ry:.13,fill:F})}if(o.push(...jo(e,t)),n("brows"))for(const s of C)o.push({k:"line",pts:[s*.72,-.5,s*.14,-.3],stroke:r.accent,lw:.16});if(e.face.brows)for(const s of C)o.push({k:"line",pts:[s*.2,-.2,s*.54,-.28],stroke:e.face.brows,lw:.09});if(o.push(...Bo(e,t)),e.face.cheeks)for(const s of Do(e))o.push({k:"ellipse",x:s.x,y:s.y,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(n("whiskers"))for(const s of C)for(const h of[-.1,.06])o.push({k:"line",pts:[s*.62,.38+h,s*1.06,.3+h*2.2],stroke:r.outline,lw:t*.7,alpha:.75});if(n("rainbow-mane")){const s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];o.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:s[0],...a}),o.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:s[1%s.length],...a})}if(e.ears==="unicorn"){const s=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];o.push({k:"path",d:D(s,.12),fill:r.accent,...a});for(const h of[-1,-1.2,-1.4]){const l=.16*((h+1.72)/.88);o.push({k:"line",pts:[-l,h+.04,l,h-.04],stroke:r.outline,lw:t*.7,alpha:.6})}}if(n("flower-crown")){const s=[i(1,"#f7a8cf"),i(2,"#fff3a0"),i(3,F)];for(const h of[-.84,-.28,.28,.84]){const l=de(h,.9);o.push({k:"ellipse",x:l.x,y:l.y,rx:.14,ry:.07,rot:h+.5,fill:"#7cc76a",stroke:r.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((h,l)=>{const d=de(h,.9),p=l===2?.13:.11;for(let y=0;y<5;y++){const b=h+y/5*Math.PI*2;o.push({k:"circle",x:d.x+Math.sin(b)*p,y:d.y-Math.cos(b)*p,r:p*.82,fill:s[l%s.length],stroke:r.outline,lw:t*.7})}o.push({k:"circle",x:d.x,y:d.y,r:p*.62,fill:s[l%s.length]}),o.push({k:"circle",x:d.x,y:d.y,r:p*.42,fill:r.accent})})}if(n("helmet")){for(const s of C)o.push({k:"rect",x:s*1,y:.05,w:.26,h:.56,r:.12,fill:r.accent,...a});o.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:F,lw:.1,alpha:.9})}if(n("bolts"))for(const s of C)o.push({k:"rect",x:s*1.08,y:.08,w:.2,h:.44,r:.08,fill:r.accent,...a});if(n("tuft")&&o.push({k:"path",d:R([{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:r.body,...a}),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:i(0,F),...a}),n("wool"))for(const[s,h]of[[-.36,-.84],[.02,-.94],[.4,-.82]])o.push({k:"circle",x:s,y:h,r:.27,fill:r.body,...a});if(n("stripe")&&o.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:r.accent}),n("eye-patch")&&(o.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:r.outline,lw:.07}),o.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:r.outline})),n("bandana")){o.push({k:"path",d:R(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:r.accent,...a});for(const[s,h]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])o.push({k:"circle",x:s,y:h,r:.06,fill:F,alpha:.85});o.push({k:"circle",x:-.98,y:-.34,r:.15,fill:r.accent,...a})}if(n("cap")){for(const s of C)o.push({k:"line",pts:[s*.98,-.2,s*.5,.82,-s*.05,.98],stroke:r.outline,lw:.06});o.push({k:"path",d:R(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:r.accent,...a}),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:r.accent,...a}),o.push({k:"circle",x:.5,y:-.82,r:.15,fill:i(0,F),...a});for(const s of[-.42,-.14])o.push({k:"line",pts:[s,-1.04,s+.02,-.78],stroke:r.outline,lw:.07,alpha:.7})}if(n("safari-hat")&&(o.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:r.accent,...a}),o.push({k:"path",d:R(Q(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:r.accent,...a}),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:i(1,r.outline),stroke:r.outline,lw:t*.8})),n("wizard-hat")){o.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:r.accent,...a}),o.push({k:"path",d:D(Q(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:r.accent,...a});const s=i(0,Io);for(const[h,l,d]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])o.push({k:"group",x:h,y:l,s:d,items:[{k:"path",d:ke,fill:s}]})}if(n("dive-mask")){for(const h of C)o.push({k:"line",pts:[h*.7,-.04,h*1,-.12],stroke:r.outline,lw:.2},{k:"line",pts:[h*.7,-.04,h*1,-.12],stroke:r.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:r.outline,lw:.2}),o.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:r.accent,lw:.11}),o.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:F,lw:.06,alpha:.9});const s="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";o.push({k:"path",d:s,stroke:r.outline,lw:.24},{k:"path",d:s,stroke:r.accent,lw:.13})}return o}function Lo(e,t){const r=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:r,...t};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:r,...t};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:r,...t};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:r,...t};case"bucket":return{k:"path",d:D(Q(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:r,...t};case"snout-long":return{k:"path",d:R(Ro,.95),fill:r,...t};case"bulb":return{k:"path",d:R([{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:r,...t}}}var Ro=Q(.7,-.88,.12,-1.04,-.3,-.98,-.72,-.74,-1.2,-.56,-1.5,-.32,-1.6,.04,-1.44,.42,-.9,.72,-.2,.92,.5,.88,.96,.56,1.08,0,.98,-.5);function ht(e,t,r){return e.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:C.map(o=>({x:o*t,y:r,k:1}))}function Do(e){return e.head==="snout-long"?Q(-.66,-.14,.66,.1):C.map(t=>({x:t*.64,y:.3}))}function No(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 Ho(e,t){const{cy:r,rx:o,ry:a}=No(e),n=o-t/2,i=a-t/2,c=.15,u=Math.asin(Math.min(1,(c-r)/i)),f=Math.cos(u)*n,s=p=>Math.round(p*100)/100||0,h=[B.M,s(-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 p of l)h.push(B.C,...p.map(s));const d=24;for(let p=1;p<=d;p++){const y=u+(Math.PI-2*u)*p/d;h.push(B.L,s(Math.cos(y)*n),s(r+Math.sin(y)*i))}return h.push(B.Z),h}function Qo(e,t){const r=e.palette,o={stroke:r.outline,lw:t},a=[];for(const n of C)switch(e.ears){case"pointy":case"unicorn":{const i=e.ears==="unicorn"?.8:1,c={x:n*.3,y:-.82},u={x:n*.86,y:-.82-.62*i},f={x:n*.94,y:-.36};a.push({k:"path",d:D([c,u,f],.2),fill:r.body,...o});const s={x:(c.x+u.x+f.x)/3,y:(c.y+u.y+f.y)/3},h=[c,u,f].map(l=>({x:s.x+(l.x-s.x)*.55,y:s.y+(l.y-s.y)*.55+.04}));a.push({k:"path",d:D(h,.25),fill:r.accent});break}case"round":a.push({k:"circle",x:n*.72,y:-.72,r:.36,fill:r.ears??r.body,...o}),r.ears||a.push({k:"circle",x:n*.74,y:-.74,r:.19,fill:r.accent});break;case"big-round":a.push({k:"circle",x:n*.96,y:-.46,r:.52,fill:r.body,...o}),a.push({k:"circle",x:n*1,y:-.44,r:.32,fill:r.accent});break;case"long":a.push({k:"ellipse",x:n*.38,y:-1.42,rx:.25,ry:.68,rot:n*.14,fill:r.body,...o}),a.push({k:"ellipse",x:n*.39,y:-1.36,rx:.12,ry:.48,rot:n*.14,fill:r.accent});break;case"side":a.push({k:"circle",x:n*1,y:.02,r:.34,fill:r.body,...o}),a.push({k:"circle",x:n*1.02,y:.02,r:.2,fill:r.belly});break;case"tufts":a.push({k:"path",d:D([{x:n*.3,y:-.84},{x:n*1.22,y:-1.12},{x:n*.92,y:-.42}],.16),fill:r.body,...o}),a.push({k:"line",pts:[n*.62,-.78,n*1,-.98],stroke:r.accent,lw:.08});break;case"antennae":{const i={x:n*.62,y:-1.42};a.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${i.x} ${i.y}`,stroke:r.outline,lw:t*2.6}),a.push({k:"path",d:`M${n*.3} -0.8 Q${n*.36} -1.2 ${i.x} ${i.y}`,stroke:r.body,lw:t*1.2}),a.push({k:"circle",x:i.x,y:i.y,r:.17,fill:r.accent,...o});break}case"floppy":a.push({k:"ellipse",x:n*.96,y:.02,rx:.3,ry:.62,rot:-n*.36,fill:r.ears??r.body,...o});break;case"droopy":a.push({k:"ellipse",x:n*1.04,y:-.22,rx:.4,ry:.18,rot:n*.32,fill:r.skin??r.body,...o}),a.push({k:"ellipse",x:n*1.08,y:-.2,rx:.24,ry:.08,rot:n*.32,fill:r.accent});break;case"pixie":a.push({k:"path",d:D(Q(n*.86,-.22,n*1.36,-.5,n*1.02,.26),.28),fill:r.skin??r.body,...o}),a.push({k:"line",pts:[n*.98,-.12,n*1.16,-.3],stroke:r.accent,lw:t*.8,alpha:.5});break;case"human":a.push({k:"ellipse",x:n*.98,y:.06,rx:.17,ry:.23,fill:r.skin??r.body,...o});break;case"horns":{const i=[{x:n*.3,y:-.84},{x:n*.6,y:-1.5},{x:n*.66,y:-.68}];a.push({k:"path",d:D(i,.18),fill:r.accent,...o});break}}return e.ears==="fin"&&a.push({k:"path",d:D(Q(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:r.body,...o}),e.ears==="antenna"&&(a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:r.outline,lw:t*2.6}),a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:r.limbs,lw:t*1.2}),a.push({k:"circle",x:0,y:-1.5,r:.18,fill:r.accent,...o})),a}function jo(e,t){const r=e.palette,o=e.face,a=[],n=r.outline,i=o.eyesOnTop?.46:.4,c=o.eyesOnTop?-.72:-.04,u=(f,s,h)=>({k:"circle",x:f,y:s,r:h,fill:F});switch(o.eyes){case"dot":for(const f of ht(e,i,c))a.push({k:"ellipse",x:f.x,y:f.y,rx:.12*f.k,ry:.155*f.k,fill:n}),a.push(u(f.x+.04*f.k,f.y-.06*f.k,.045*f.k));break;case"bead":for(const f of ht(e,i,c))a.push({k:"ellipse",x:f.x,y:f.y,rx:.16*f.k,ry:.22*f.k,fill:n}),a.push(u(f.x+.05*f.k,f.y-.08*f.k,.065*f.k));break;case"big":for(const f of C)o.eyeRing&&a.push({k:"circle",x:f*i,y:c,r:.36,fill:o.eyeRing,stroke:n,lw:t*.8}),a.push({k:"circle",x:f*i,y:c,r:.25,fill:F,stroke:n,lw:t*.8}),a.push({k:"circle",x:f*i+f*-.03,y:c+.03,r:.14,fill:o.eyeColor??n}),a.push(u(f*i+f*-.03+.05,c-.03,.05));break;case"mask":for(const f of C)a.push({k:"ellipse",x:f*.4,y:0,rx:.24,ry:.32,rot:f*-.55,fill:r.limbs}),a.push({k:"circle",x:f*.4,y:-.02,r:.11,fill:F}),a.push({k:"circle",x:f*.39,y:-0,r:.065,fill:n});break;case"screen":a.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 C)a.push({k:"ellipse",x:f*.36,y:0,rx:.2,ry:.24,fill:o.eyeColor??"#7ff0ff",alpha:.3}),a.push({k:"ellipse",x:f*.36,y:0,rx:.12,ry:.16,fill:o.eyeColor??"#7ff0ff"});break;case"almond":for(const f of C)a.push({k:"ellipse",x:f*.42,y:-.02,rx:.3,ry:.2,rot:-f*.5,fill:o.eyeColor??n}),a.push(u(f*.42-f*.07,-.08,.07));break;case"calm":for(const f of C)a.push({k:"ellipse",x:f*.38,y:.02,rx:.085,ry:.12,fill:n}),a.push(u(f*.38+.03,-.02,.03));break;case"slit":a.push({k:"line",pts:[0,-.98,0,-.2],stroke:n,lw:t*.8,alpha:.5}),a.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:Qe,stroke:n,lw:t*.8}),a.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:Qe,stroke:n,lw:t*.8});for(const f of C){a.push({k:"ellipse",x:f*.4,y:-.04,rx:.12,ry:.07,fill:o.eyeColor??F});for(const s of[.36,.56])a.push({k:"circle",x:f*.42,y:s,r:.05,fill:n,alpha:.6})}break;case"goggle":for(const f of C)a.push({k:"circle",x:f*.9,y:0,r:.13,fill:r.accent,stroke:n,lw:t*.8});a.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:Qe,stroke:n,lw:t*.8}),a.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:F,lw:.07,alpha:.8});for(const f of C)a.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])a.push({k:"line",pts:[f,.56,f,.72],stroke:n,lw:t*.8,alpha:.6});break;case"visor":a.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:n,lw:t*.8}),a.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:F,lw:.08,alpha:.7});for(const f of C)a.push({k:"ellipse",x:f*.28,y:.04,rx:.1,ry:.14,fill:o.eyeColor??"#cfeeff"});break}return a}function Bo(e,t){const r=e.palette,o=e.face,a=[],n=o.eyes==="visor"?"#cfeeff":ct,i=t*1.05;switch(o.nose&&o.mouth!=="beak"&&(o.mouth==="cat"?a.push({k:"path",d:D([{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"?a.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:o.nose}):a.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:o.nose})),o.mouth){case"smile":a.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:i});break;case"open":a.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}),a.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:ft});break;case"cat":a.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:i});break;case"beak":a.push({k:"path",d:D([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:r.accent,stroke:r.outline,lw:t*.8});break;case"teeth":a.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 c of C)a.push({k:"rect",x:c*.12,y:.43,w:.1,h:.1,r:.03,fill:F});break;case"grill":a.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:r.outline,lw:t*.7});for(const c of[-.15,0,.15])a.push({k:"line",pts:[c,.51,c,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":a.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:n});break;case"smirk":a.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:n,lw:i});break;case"bill":a.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:r.accent,stroke:r.outline,lw:t*.8}),a.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:r.outline,lw:t*.7});for(const c of C)a.push({k:"circle",x:c*.1,y:.28,r:.03,fill:r.outline});break;case"hook":a.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:ct}),a.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:r.accent,stroke:r.outline,lw:t*.8});break;case"toothy":{a.push({k:"path",d:"M-1.4 0.1 Q-0.5 0.36 0.5 0.2 Q0.64 0.16 0.68 0.02 Q0.78 0.28 0.52 0.38 Q-0.4 0.78 -1.3 0.26 Z",fill:n,stroke:n,lw:t*.6}),a.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:ft});for(const c of[.12,.27,.42,.57,.72,.86]){const u=(1-c)*(1-c)*-1.4+2*(1-c)*c*-.5+c*c*.5,f=(1-c)*(1-c)*.1+2*(1-c)*c*.36+c*c*.2-.01;a.push({k:"path",d:D(Q(u-.08,f,u+.08,f,u,f+.14),.3),fill:F})}for(const c of[.3,.7]){const u=(1-c)*(1-c)*.52+2*(1-c)*c*-.4+c*c*-1.3,f=(1-c)*(1-c)*.38+2*(1-c)*c*.78+c*c*.26+.01;a.push({k:"path",d:D(Q(u-.07,f,u+.07,f,u,f-.12),.3),fill:F})}break}case"jaws":{a.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 c of[-.34,-.17,0,.17,.34]){const u=.3+.4*(c+.5)*(.5-c)-.01;a.push({k:"path",d:D(Q(c-.075,u,c+.075,u,c,u+.13),.15),fill:F})}break}}return a}var de=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t}),Fo=.5,le={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ie={"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}},Oe="6-8",dt=(e,t)=>t!==void 0&&e.band!=="all"&&e.alsoIn?.includes(t)&&t in ie?t:e.band in ie?e.band:Oe,jr=ie[Oe].head,Wo=.3,Xo=.12,Yo=.9,pt=.5,yt=.65,qo=.35,$o=.2,Zo=.25,oe=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),N=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),_=(e,t)=>({x:e.x*t,y:e.y*t}),pe=e=>Math.hypot(e.x,e.y),bt=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Ie=e=>{const t=pe(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},Ko=(...e)=>e.every(Number.isFinite),Go=e=>Math.atan2(Math.sin(e),Math.cos(e)),Vo=(e,t,r)=>Math.min(Math.max(e,t),r);function kt(e,t,r=!1){return o=>{const a=e[o*3],n=e[o*3+1],i=e[o*3+2];return a===void 0||n===void 0||i===void 0||!Ko(a,n,i)?{x:0,y:0,ok:!1}:{x:t.x+(r?1-a:a)*t.w,y:t.y+n*t.h,ok:i>=Fo}}}function je(e,t,r={}){const o=kt(e,t,r.mirrored),a=o(A.leftShoulder),n=o(A.rightShoulder);if(!a.ok||!n.ok)return null;const i=o(A.leftHip),c=o(A.rightHip),u=bt(a,n),f=pe(oe(n,a)),s=i.ok&&c.ok;let h=Ie(oe(n,a));f<1e-6&&(h={x:1,y:0});let l,d,p;if(s){const re=bt(i,c);d=pe(oe(re,u)),d>=f*Zo?l=Ie(oe(re,u)):(l={x:-h.y,y:h.x},l.y<0&&(l=_(l,-1))),p=Math.max(d,f*1.15)}else l={x:-h.y,y:h.x},l.y<0&&(l=_(l,-1)),p=f*1.15,d=p;p=Math.max(p,1e-6);const y={x:l.y,y:-l.x},b=Math.atan2(y.y,y.x),x=_(l,-1),S=ie[r.band??Oe]??ie[Oe],v=S.head*p;let z=N(u,_(x,v*S.neck));const U=o(A.nose);if(U.ok){const re=N(U,_(x,v*.15)),ae=_(oe(re,z),qo),Me=Math.min(1,v*$o/Math.max(pe(ae),1e-6));z=N(z,_(ae,Me))}return{S:u,r:y,d:l,U:p,L:d,hipsOk:s,head:z,headR:v,headRot:b+Uo(e,o,b,p),angle:b}}function Uo(e,t,r,o){const a=[[le.leftEar,le.rightEar],[le.leftEye,le.rightEye]];for(const[n,i]of a){const c=t(n),u=t(i);if(!c.ok||!u.ok||!(e[n*3+2]>=yt&&e[i*3+2]>=yt)||pe(oe(u,c))<o*.05)continue;const f=Go(Math.atan2(u.y-c.y,u.x-c.x)-r),s=Math.max(Math.abs(f)-Xo,0),h=Vo((Yo+pt-Math.abs(f))/pt,0,1);return Math.sign(f)*Math.min(s,Wo)*h}return 0}function Be(e,t,r,o={}){const a=dt(t,o.band),n=ie[a],i=je(e,r,{...o,band:a});if(!i)return[];const c=kt(e,r,o.mirrored),u=t.palette,{S:f,r:s,d:h,U:l,L:d}=i,p=k=>t.bodyExtras.includes(k),y=Math.max(1.2,l*.045),b={stroke:u.outline,lw:y},x=(k,m)=>({x:f.x+s.x*k+h.x*m,y:f.y+s.y*k+h.y*m}),S=k=>k.map(([m,w])=>x(m,w)),v=c(A.leftShoulder),z=c(A.rightShoulder),U=c(A.leftHip),re=c(A.rightHip),ae=pe(oe(z,v)),Me=i.hipsOk?pe(oe(re,U)):ae*.7,T=Math.max(ae/2+n.shoulderPad*l,n.shoulderMin*l),j=Math.max(Me/2+n.hipPad*l,n.hipMin*l),H=-.1*l,g=d+n.bottom*l,W=[],O=[],E=[],xe=[],me=[],Ae=(k,m,w,I)=>{const P=m.flatMap(J=>[J.x,J.y]);k.push({k:"line",pts:P,stroke:u.outline,lw:w+y*2}),k.push({k:"line",pts:P,stroke:I,lw:w})},M=n.leg*l*(p("strong-legs")?1.3:1),K=n.arm*l*(p("tiny-arms")?.6:1),$=Math.max(n.arm/.22,.9);if(i.hipsOk)for(const[k,m,w,I]of[[U,A.leftKnee,A.leftAnkle,-1],[re,A.rightKnee,A.rightAnkle,1]]){const P=c(m),J=c(w);if(!P.ok)continue;const Fe=N(k,_(h,-.12*l)),ce=J.ok?[Fe,P,J]:[Fe,P];Ae(O,ce,M,u.limbs),p("joints")&&O.push({k:"circle",x:P.x,y:P.y,r:.15*l*$,fill:u.accent,...b}),J.ok&&O.push(...tr(t,J,i,I,y,n.foot))}for(const[k,m,w,I]of[[v,A.leftElbow,A.leftWrist,-1],[z,A.rightElbow,A.rightWrist,1]]){const P=c(m),J=c(w);if(p("pauldrons")){const se=N(k,_(h,.02*l));xe.push({k:"ellipse",x:se.x,y:se.y,rx:.25*l,ry:.17*l,rot:i.angle+I*.25,fill:u.body,...b});const fe=N(se,_(h,.05*l));xe.push({k:"ellipse",x:fe.x,y:fe.y,rx:.17*l,ry:.07*l,rot:i.angle+I*.25,fill:u.belly})}if(!P.ok)continue;const ce=n.armsOverHead&&(P.x-f.x)*h.x+(P.y-f.y)*h.y<-.25*l?me:xe,It=N(k,_(h,.04*l));if(Ae(ce,J.ok?[It,P,J]:[It,P],K,u.limbs),p("joints")&&ce.push({k:"circle",x:P.x,y:P.y,r:.13*l*$,fill:u.accent,...b}),!J.ok)continue;const ne=Ie(oe(J,P)),we=N(J,_(ne,.05*l));if(p("feathers"))for(const se of[-.55,0,.55]){const fe=Math.cos(se),Ce=Math.sin(se)*I,ue={x:ne.x*fe-ne.y*Ce,y:ne.x*Ce+ne.y*fe},Te=N(we,_(ue,.16*l));ce.push({k:"ellipse",x:Te.x,y:Te.y,rx:.2*l,ry:.09*l,rot:Math.atan2(ue.y,ue.x),fill:u.hands??u.accent,...b})}p("wand")&&I===1&&!o.portrait&&ce.push(...ar(t,we,Ie(N(_(ne,.4),oe(_(s,.6),h))),l,y));const Se=n.hand*l*(p("tiny-arms")?.72:1);if(p("tiny-arms"))for(const se of[-.45,.45]){const fe=Math.cos(se),Ce=Math.sin(se),ue={x:ne.x*fe-ne.y*Ce,y:ne.x*Ce+ne.y*fe},Te=N(we,_(ue,Se*.75)),Nr=N(we,_(ue,Se*1.6)),Lt={x:-ue.y*Se*.32,y:ue.x*Se*.32};ce.push({k:"path",d:D([N(Te,Lt),Nr,oe(Te,Lt)],.2),fill:u.belly,...b})}ce.push({k:"circle",x:we.x,y:we.y,r:Se,fill:u.hands??u.limbs,...b})}if(p("wings"))for(const k of[-1,1]){const m=S([[k*T*.5,.05*l],[k*(T+.85*l),-.6*l],[k*(T+.72*l),.05*l],[k*(T+.45*l),-.02*l],[k*(T+.3*l),.32*l],[k*T*.6,.55*l]]);W.push({k:"path",d:D(m,.18),fill:u.accent,...b})}if(p("wings-fairy")&&W.push(...nr(t,x,T,l,y)),p("cape")){const k=d+.8*l,m=j+.36*l,w=S([[-T*.92,H+.04*l],[T*.92,H+.04*l],[T+.16*l,d*.5],[m,k],[m*.5,k-.1*l],[0,k],[-m*.5,k-.1*l],[-m,k],[-T-.16*l,d*.5]]);W.push({k:"path",d:R(w,.6),fill:u.accent,...b})}if(p("backpack")){const k=x(0,.35*l);W.push({k:"rect",x:k.x,y:k.y,w:T*2+.34*l,h:.8*l,r:.16*l,rot:i.angle,fill:t.extraColors?.[0]??u.limbs,...b})}if(p("tank")){const k=x(T*.95,.24*l),m=t.extraColors?.[0]??u.accent,w=x(T*.95,-.3*l);W.push({k:"rect",x:w.x,y:w.y,w:.14*l,h:.16*l,r:.04*l,rot:i.angle,fill:u.outline}),W.push({k:"rect",x:k.x,y:k.y,w:.34*l,h:1*l,r:.17*l,rot:i.angle,fill:m,...b})}if(i.hipsOk&&!o.portrait&&W.push(...rr(t,i,j,y)),p("tentacles")&&i.hipsOk)for(const k of[-1,1]){const m=S([[k*j*.7,d*.9],[k*(j+.22*l),d+.3*l],[k*(j+.48*l),d+.22*l],[k*(j+.5*l),d-.02*l],[k*(j+.34*l),d-.06*l]]);W.push({k:"path",d:Ee(m),stroke:u.outline,lw:.2*l+y*2}),W.push({k:"path",d:Ee(m),stroke:u.limbs,lw:.2*l})}const X=Math.max(T,j)*n.bulge;if(p("wool")){for(const[m,w]of[[T*.7,H+.02*l],[X,d*.3],[X*1.02,d*.62],[(X+j)/2,d*.92],[j*.55,g]])for(const I of[-1,1]){const P=x(I*m,w);E.push({k:"circle",x:P.x,y:P.y,r:.2*l,fill:u.body,...b})}const k=x(0,g+.02*l);E.push({k:"circle",x:k.x,y:k.y,r:.2*l,fill:u.body,...b})}if(p("robe")){const k=d+.58*l,m=j*1.4;E.push({k:"path",d:R(S([[-T,H],[0,H-.04*l],[T,H],[X,d*.55],[m,k],[0,k+.06*l],[-m,k],[-X,d*.55]]),.7),fill:u.body,...b});const w=S([[-m*.94,k-.1*l],[0,k-.04*l],[m*.94,k-.1*l]]);E.push({k:"path",d:Ee(w),stroke:t.extraColors?.[0]??u.accent,lw:.07*l})}else if(p("sheet")){const k=d+.78*l,m=j*1.3;E.push({k:"path",d:R(S([[-T,H],[T,H],[X,d*.55],[m,k],[m*.5,k-.2*l],[0,k],[-m*.5,k-.2*l],[-m,k],[-X,d*.55]]),.9),fill:u.body,...b})}else E.push({k:"path",d:R(S([[-T,H],[0,H-.04*l],[T,H],[X,d*.55],[j,g],[0,g+.03*l],[-j,g],[-X,d*.55]]),.85),fill:u.body,...b});const Z=Math.min(T,j);if(p("pocket")){const k=x(0,d*.74);E.push({k:"rect",x:k.x,y:k.y,w:Z*1.3,h:.3*l,r:.1*l,rot:i.angle,fill:u.belly,stroke:u.outline,lw:y*.8})}else if(p("racing-stripe"))for(const k of[-.1,.1]){const m=x(k*l,H+.02*l),w=x(k*l,g-.04*l);E.push({k:"line",pts:[m.x,m.y,w.x,w.y],stroke:u.belly,lw:.1*l})}else if(u.belly&&u.belly!==u.body&&!p("panel")&&!p("sheet")&&!p("stripes")){const k=x(0,d*.58);E.push({k:"ellipse",x:k.x,y:k.y,rx:Z*.64,ry:Math.max(d*.36,.2*l),rot:i.angle,fill:u.belly})}if(p("spots")){const k=t.extraColors?.[1]??u.belly;for(const[m,w,I]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){const P=x(m*Z,w*d);E.push({k:"circle",x:P.x,y:P.y,r:I*l,fill:k})}}if(p("stripes")){const k=t.extraColors?.[1]??u.accent;for(const m of[.22,.44,.66]){const w=x(-Z*.98,d*m),I=x(Z*.98,d*m);E.push({k:"line",pts:[w.x,w.y,I.x,I.y],stroke:k,lw:.1*l})}}if(p("straps")){const k=t.extraColors?.[1]??u.outline;for(const m of[-1,1]){const w=x(m*T*.62,H+.02*l),I=x(m*Z*.62,d*.72);E.push({k:"line",pts:[w.x,w.y,I.x,I.y],stroke:u.outline,lw:.13*l+y*2}),E.push({k:"line",pts:[w.x,w.y,I.x,I.y],stroke:k,lw:.13*l})}}if(p("belt")){const k=x(0,d*.9);E.push({k:"rect",x:k.x,y:k.y,w:j*1.92,h:.17*l,r:.06*l,rot:i.angle,fill:t.extraColors?.[2]??"#4a3426",...b}),E.push({k:"rect",x:k.x,y:k.y,w:.2*l,h:.19*l,r:.04*l,rot:i.angle,fill:"#ffd84a",...b})}if(p("emblem")){const k=x(0,d*.4),m=t.extraColors?.[0]??u.accent,w=D([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);E.push({k:"group",x:k.x,y:k.y,rot:i.angle,s:l,items:[{k:"path",d:w,fill:m,stroke:u.outline,lw:y/l},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ke,fill:m===u.accent?"#ffffff":u.accent}]}]})}if(p("panel")){const k=x(0,d*.5);E.push({k:"rect",x:k.x,y:k.y,w:Z*1.2,h:.38*l,r:.1*l,rot:i.angle,fill:"#24323d",...b}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,I)=>{const P=x((I-1)*Z*.34,d*.5);E.push({k:"circle",x:P.x,y:P.y,r:.075*l,fill:w})})}if(p("badge")){const k=x(-Z*.42,d*.36);E.push({k:"circle",x:k.x,y:k.y,r:.15*l,fill:u.accent,...b}),E.push({k:"group",x:k.x,y:k.y,rot:i.angle,s:.09*l,items:[{k:"path",d:ke,fill:"#ffffff"}]})}if(p("star")){const k=x(-Z*.5,d*.3),m=.15*l;E.push({k:"group",x:k.x,y:k.y,rot:i.angle-.2,s:m,items:[{k:"path",d:ke,fill:t.extraColors?.[0]??"#ffd84a",stroke:u.outline,lw:y*.8/m}]})}if(p("petals")&&E.push(...sr(t,x,T,j,X,d,g,l,y,n)),p("scarf")){const k=Math.max(.04,n.head*(1-n.neck)-.06)*l,m=x(0,k),w=t.extraColors?.[0]??u.accent,I=x(T*.45,k+.28*l);E.push({k:"rect",x:I.x,y:I.y,w:.16*l,h:.42*l,r:.06*l,rot:i.angle+.15,fill:w,...b}),E.push({k:"rect",x:m.x,y:m.y,w:T*2.05,h:.2*l,r:.1*l,rot:i.angle,fill:w,...b})}const ge={k:"group",x:i.head.x,y:i.head.y,rot:i.headRot,s:i.headR,items:er(t,y/i.headR)};return[...W,...O,...E,...xe,ge,...me]}var xt=new WeakMap,Jo=64;function er(e,t){const r=Number(t.toPrecision(4));let o=xt.get(e);o||xt.set(e,o=new Map);let a=o.get(r);return a||(o.size>=Jo&&o.clear(),o.set(r,a=ut(e,r))),a}function tr(e,t,r,o,a,n){const i=or(e,t,r,o,a,n);if(!e.bodyExtras.includes("strong-legs"))return[i];const c=r.U*n,u=N(N(t,_(r.d,.07*c)),_(r.r,o*.06*c)),f=[i];for(const s of[-1,0,1]){const h=N(N(u,_(r.r,s*.12*c)),_(r.d,.09*c));f.push({k:"ellipse",x:h.x,y:h.y,rx:.05*c,ry:.045*c,rot:r.angle,fill:e.palette.belly,stroke:e.palette.outline,lw:a*.8})}return f}function or(e,t,r,o,a,n){const i=e.palette,{d:c,r:u}=r,f=r.U*n,s=N(N(t,_(c,.07*f)),_(u,o*.06*f)),h={stroke:i.outline,lw:a},l=i.feet??i.limbs;if(e.bodyExtras.includes("fins")){const d=D([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:s.x,y:s.y,rot:r.angle,s:f,items:[{k:"path",d,fill:l,stroke:i.outline,lw:a/f},{k:"line",pts:[0,.06,0,.38],stroke:i.outline,lw:a/f,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:s.x,y:s.y,rx:.27*f,ry:.11*f,rot:r.angle,fill:l,...h}:e.bodyExtras.includes("boots")?{k:"rect",x:s.x,y:s.y,w:.4*f,h:.24*f,r:.09*f,rot:r.angle,fill:l,...h}:{k:"ellipse",x:s.x,y:s.y,rx:.2*f,ry:.13*f,rot:r.angle,fill:l,...h}}function rr(e,t,r,o){const a=e.palette,{U:n,L:i,S:c,r:u,d:f}=t,s=(y,b)=>({x:c.x+u.x*y+f.x*b,y:c.y+u.y*y+f.y*b}),h=y=>y.map(([b,x])=>s(b,x)),l={stroke:a.outline,lw:o},d=(y,b,x)=>[{k:"path",d:Ee(y),stroke:a.outline,lw:b+o*2},{k:"path",d:Ee(y),stroke:x,lw:b}],p=[];switch(e.tail){case"none":break;case"fluffy":{const y=h([[r*.5,i*.95],[r+.28*n,i*1],[r+.72*n,i*.62],[r+.78*n,i*.12],[r+.52*n,i*.32],[r+.3*n,i*.6],[r*.6,i*.7]]);p.push({k:"path",d:R(y),fill:a.body,...l});const b=s(r+.72*n,i*.2);p.push({k:"ellipse",x:b.x,y:b.y,rx:.13*n,ry:.2*n,rot:t.angle+.25,fill:a.belly,...l});break}case"brush":{const y=h([[r*.4,i*.98],[r+.42*n,i*1.06],[r+.98*n,i*.66],[r+1.06*n,i*.12],[r+.86*n,-.04*n],[r+.66*n,i*.36],[r+.3*n,i*.66],[r*.5,i*.68]]);p.push({k:"path",d:R(y),fill:a.body,...l});const b=h([[r+1.03*n,i*.36],[r+1.06*n,i*.12],[r+.86*n,-.04*n],[r+.72*n,i*.24],[r+.86*n,i*.34]]);p.push({k:"path",d:R(b),fill:a.belly,...l});break}case"pom":{const y=s(r+.06*n,i*.88);p.push({k:"circle",x:y.x,y:y.y,r:.2*n,fill:a.belly,...l});break}case"long":case"striped":case"tuft":{const y=h([[r*.6,i*.9],[r+.35*n,i*.85],[r+.58*n,i*.4],[r+.5*n,-.02*n]]);if(p.push(...d(y,.14*n,a.body)),e.tail==="tuft"){const b=y[y.length-1];p.push({k:"circle",x:b.x,y:b.y,r:.16*n,fill:e.extraColors?.[0]??a.accent,...l})}if(e.tail==="striped"){for(const x of[.35,.6,.85]){const S=s(r+.35*n+.22999999999999998*n*(x*1.4>1?1:x*1.4),i*(.85-.85*x));p.push({k:"line",pts:[S.x-u.x*.08*n,S.y-u.y*.08*n,S.x+u.x*.08*n,S.y+u.y*.08*n],stroke:e.extraColors?.[0]??a.outline,lw:.06*n})}const b=y[y.length-1];p.push({k:"circle",x:b.x,y:b.y,r:.07*n,fill:e.extraColors?.[0]??a.outline})}break}case"curl":{const y=h([[r*.6,i*.9],[r+.4*n,i*.88],[r+.62*n,i*.45],[r+.5*n,i*.12],[r+.3*n,i*.24],[r+.36*n,i*.42]]);p.push(...d(y,.12*n,a.limbs));break}case"fish":{const y=h([[r*.6,i*.9],[r+.36*n,i*.86],[r+.6*n,i*.5]]);p.push(...d(y,.17*n,a.body));const b=y[y.length-1],x=D([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);p.push({k:"group",x:b.x,y:b.y,rot:t.angle+.35,s:n,items:[{k:"path",d:x,fill:a.body,stroke:a.outline,lw:o/n}]});break}case"plume":{const y=e.extraColors??[a.accent];[0,1,2].forEach(b=>{const x=s(r+(.12+b*.13)*n,i+(.32-b*.06)*n);p.push({k:"ellipse",x:x.x,y:x.y,rx:.11*n,ry:.44*n,rot:t.angle-.55+b*.28,fill:y[(b+1)%y.length],...l})});break}case"thick":{const y=h([[r*.3,i*.42],[r+.42*n,i*.62],[r+.92*n,i*.96],[r+1.32*n,i*1.08],[r+1.44*n,i*.98],[r+.98*n,i*1.2],[r+.4*n,i*1.22],[r*.3,i*1.12]]);p.push({k:"path",d:R(y,.8),fill:a.body,...l});const b=e.extraColors?.[0]??a.accent;for(const[x,S,v]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){const z=s(r+x*n,i*S+.03*n),U=s(r+(x-.1)*n,i*S+v*n);p.push({k:"line",pts:[z.x,z.y,U.x,U.y],stroke:b,lw:.09*n})}break}case"spiky":case"arrow":{const y=h([[r*.3,i*.55],[r+.35*n,i*.68],[r+.95*n,i*.86],[r+.35*n,i*1.08],[r*.3,i*1.08]]);if(e.tail==="spiky"){for(const b of[.15,.45,.72]){const x=r+(.2+b*.7)*n,S=i*(.66+b*.19);p.push({k:"path",d:D(h([[x-.12*n,S+.05*n],[x,S-.2*n],[x+.12*n,S+.07*n]]),.2),fill:a.accent,...l})}p.push({k:"path",d:R(y,.7),fill:a.body,...l})}else{const b=h([[r*.6,i*.9],[r+.4*n,i*.92],[r+.62*n,i*.5],[r+.62*n,i*.18]]);p.push(...d(b,.13*n,a.body));const x=b[b.length-1];p.push({k:"group",x:x.x,y:x.y,rot:t.angle,s:n,items:[{k:"path",d:D([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:a.accent,stroke:a.outline,lw:o/n}]})}break}}return p}function ar(e,t,r,o,a){const n=e.palette,i=N(t,_(r,-.08*o)),c=N(t,_(r,.52*o)),u=.2*o;return[{k:"line",pts:[i.x,i.y,c.x,c.y],stroke:n.outline,lw:.06*o+a*2},{k:"line",pts:[i.x,i.y,c.x,c.y],stroke:"#fff3d6",lw:.06*o},{k:"circle",x:c.x,y:c.y,r:.24*o,fill:n.accent,alpha:.28},{k:"group",x:c.x,y:c.y,rot:Math.atan2(r.y,r.x)+Math.PI/2,s:u,items:[{k:"path",d:ke,fill:n.accent,stroke:n.outline,lw:a*.9/u}]}]}function nr(e,t,r,o,a){const n=e.palette,i=e.extraColors?.[0]??"#cdeeff",c=[];for(const u of[-1,1]){const f=[[[u*r*.3,.12*o],[u*(r+.42*o),-.66*o],[u*(r+1*o),-.74*o],[u*(r+1.02*o),-.18*o],[u*(r+.5*o),.26*o]],[[u*r*.4,.3*o],[u*(r+.6*o),.36*o],[u*(r+.74*o),.78*o],[u*(r+.3*o),.9*o]]];for(const s of f){const h=R(s.map(([y,b])=>t(y,b)),.9);c.push({k:"path",d:h,fill:i,alpha:.6}),c.push({k:"path",d:h,stroke:n.outline,lw:a*.9});const l=s[Math.floor(s.length/2)],d=t(s[0][0],s[0][1]),p=t(s[0][0]+(l[0]-s[0][0])*.75,s[0][1]+(l[1]-s[0][1])*.75);c.push({k:"line",pts:[d.x,d.y,p.x,p.y],stroke:"#ffffff",lw:a*.9,alpha:.85})}for(const[s,h,l]of[[r+.72*o,-.42*o,.075*o],[r+.44*o,-.16*o,.05*o],[r+.5*o,.6*o,.055*o]]){const d=t(u*s,h);c.push({k:"group",x:d.x,y:d.y,s:l,items:[{k:"path",d:ke,fill:"#ffffff"}]})}}return c}function sr(e,t,r,o,a,n,i,c,u,f){const s=e.palette,h=e.extraColors?.[1]??s.belly,l=[],d=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),p=5,y=Math.max(o,a*.92)*1.08,b=(n*.8+i)/2,x=[0,4,1,3,2];for(const v of x){const z=v/(p-1)-.5,U=t(z*2*y,b+(.5-Math.abs(z))*.1*c);l.push({k:"ellipse",x:U.x,y:U.y,rx:y*.3,ry:.34*c,rot:d-z*.6,fill:v%2?h:s.body,stroke:s.outline,lw:u})}const S=Math.max(.04,f.head*(1-f.neck)-.04)*c;for(const v of[-1,1,0]){const z=t(v*r*.32,S+(v?0:.05*c));l.push({k:"ellipse",x:z.x,y:z.y,rx:r*.26,ry:.12*c,rot:d+v*.5,fill:v?h:s.body,stroke:s.outline,lw:u*.9})}return l}var lr={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 ir(e,{cx:t=.5,cy:r=.36,T:o=.18}={}){const a={...lr,...e},n=new Array(Ge*3).fill(0),i=(f,[s,h],l=.99)=>{n[f*3]=t+s*o,n[f*3+1]=r+h*o,n[f*3+2]=l};for(const f of Object.keys(A))i(A[f],a[f]);const c=a.tilt??0,u=(f,s)=>[a.nose[0]+f*Math.cos(c)-s*Math.sin(c),a.nose[1]+f*Math.sin(c)+s*Math.cos(c)];return i(le.leftEye,u(-.1,-.08)),i(le.rightEye,u(.1,-.08)),i(le.leftEar,u(-.22,-.02)),i(le.rightEar,u(.22,-.02)),n}var cr=()=>ir({}),mt=.5,fr=.15,ur=class{constructor(e={}){Y(this,"tracks",new Map),Y(this,"offset",NaN),Y(this,"lastArrival",NaN),Y(this,"interval",33),Y(this,"lastT",NaN),Y(this,"lostMs"),Y(this,"maxExtrapolateMs"),this.lostMs=e.lostMs??250,this.maxExtrapolateMs=e.maxExtrapolateMs??25}get delayMs(){return this.interval}push(e,t,r,o=gt()){Number.isFinite(t)||(t=o),this.clock(t,o);const a=this.tracks.get(e);if(!a||t-a.tb>this.lostMs||t<a.tb-this.lostMs||r.length!==a.b.length){this.tracks.set(e,{a:null,ta:t,b:r,tb:t,out:null,outAt:NaN});return}if(r===a.b||t<=a.tb){t===a.tb&&r!==a.b&&(a.b=r,a.out=null);return}a.a=a.b,a.ta=a.tb,a.b=r,a.tb=t,a.out=null}at(e,t=gt()){const r=this.tracks.get(e);if(!r)return null;if(!r.a)return r.b;if(r.out&&r.outAt===t)return r.out;const o=t-this.offset-this.interval,a=r.tb-r.ta,n=Math.min(a*.5,this.maxExtrapolateMs),i=Math.min(Math.max((o-r.ta)/a,0),1+n/a);return r.out=hr(r.a,r.b,i),r.outAt=t,r.out}forget(e){this.tracks.delete(e)}clear(){this.tracks.clear()}clock(e,t){const r=t-e;if(!Number.isFinite(this.offset)||r<this.offset||r>this.offset+1e3?this.offset=r:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(r-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)}},gt=()=>globalThis.performance?.now()??Date.now();function hr(e,t,r){const o=t.slice(),a=r<.5?e:t;for(let n=0;n+2<t.length;n+=3){const i=e[n],c=e[n+1],u=t[n],f=t[n+1];e[n+2]>=mt&&t[n+2]>=mt&&Math.abs(u-i)+Math.abs(f-c)<fr?(o[n]=i+(u-i)*r,o[n+1]=c+(f-c)*r,o[n+2]=e[n+2]+(t[n+2]-e[n+2])*Math.min(r,1)):(o[n]=a[n],o[n+1]=a[n+1],o[n+2]=a[n+2])}return o}var Br=lt.map(e=>e.id),Le=new Map(lt.map(e=>[e.id,e])),wt=Le.get("fox"),dr=e=>typeof e=="string"&&Le.has(e),pr=e=>Le.get(e),vt=e=>typeof e=="string"?Le.get(e)??wt:e;function yr(e,t,r,o,a={}){const n=Be(t,vt(r),o,{mirrored:a.mirrored,band:a.band});return n.length?(e.save(),a.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(a.alpha,0),1)),He(e,n),e.restore(),!0):!1}function br(e,t,r){const o=vt(e),a=cr(),n=dt(o,r),i=je(a,{x:0,y:0,w:1,h:1},{band:n}),c=Mt(ut(o,.05)),u=-c.minY,f=Math.min(.27,.43/Math.max(u,1))*t,s=o.head==="snout-long"?(c.minX+c.maxX)/2*f:0,h=f/ie[n].head/i.U,l=.5*t+Math.min(0,(u-1.6)*.06*t),d={x:t/2-s-i.head.x*h,y:l-i.head.y*h,w:h,h};return Be(a,o,d,{portrait:!0,band:n})}function kr(e,t,r=.5){if(!e||e.length!==t.length)return t.slice();const o=t.slice();for(let a=0;a+2<t.length;a+=3){const n=e[a+2],i=t[a+2],c=n>=.5,u=i>=.5;c&&i>=.3&&(o[a+2]=Math.max(i,.5));const f=Math.hypot(t[a]-e[a],t[a+1]-e[a+1]);if(c&&u&&f<.15){const s=r*Math.min(1,Et+(1-Et)*f/xr);o[a]=e[a]+(t[a]-e[a])*s,o[a+1]=e[a+1]+(t[a+1]-e[a+1])*s}else c&&!u&&o[a+2]>=.5&&(o[a]=e[a],o[a+1]=e[a+1])}return wr(e,t,o,r*mr),o}var Et=.1,xr=.03,mr=.35,gr=11;function wr(e,t,r,o){const a=A.leftShoulder*3,n=A.rightShoulder*3,i=(h,l)=>h[l+2]>=.5;if(!i(e,a)||!i(e,n)||!i(t,a)||!i(t,n))return;const c=(h,l)=>(h[a+l]+h[n+l])/2,u=[c(e,0),c(e,1)],f=[c(t,0),c(t,1)],s=[c(r,0),c(r,1)];for(let h=0;h<gr&&h*3+2<t.length;h++){const l=h*3;if(!i(e,l)||!i(t,l))continue;const d=[e[l]-u[0],e[l+1]-u[1]],p=[t[l]-f[0],t[l+1]-f[1]];Math.hypot(p[0]-d[0],p[1]-d[1])>=.15||(r[l]=s[0]+d[0]+(p[0]-d[0])*o,r[l+1]=s[1]+d[1]+(p[1]-d[1])*o)}}function Mt(e){const t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},r=(o,a)=>{t.minX=Math.min(t.minX,o),t.minY=Math.min(t.minY,a),t.maxX=Math.max(t.maxX,o),t.maxY=Math.max(t.maxY,a)};for(const o of e){const a="lw"in o&&o.stroke?(o.lw??1)/2:0;switch(o.k){case"circle":r(o.x-o.r-a,o.y-o.r-a),r(o.x+o.r+a,o.y+o.r+a);break;case"ellipse":case"rect":{const n=o.k==="ellipse"?o.rx:o.w/2,i=o.k==="ellipse"?o.ry:o.h/2,c=Math.max(n,i)+a;r(o.x-c,o.y-c),r(o.x+c,o.y+c);break}case"path":{const n=_o(o.d);for(let i=0;i+1<n.length;i+=2)r(n[i]-a,n[i+1]-a),r(n[i]+a,n[i+1]+a);break}case"line":for(let n=0;n+1<o.pts.length;n+=2)r(o.pts[n]-a,o.pts[n+1]-a),r(o.pts[n]+a,o.pts[n+1]+a);break;case"group":{const n=Mt(o.items);if(!Number.isFinite(n.minX))break;const i=o.s??1,c=Math.cos(o.rot??0),u=Math.sin(o.rot??0);for(const[f,s]of[[n.minX,n.minY],[n.maxX,n.minY],[n.minX,n.maxY],[n.maxX,n.maxY]])r(o.x+(f*c-s*u)*i,o.y+(f*u+s*c)*i);break}}}return t}var vr=()=>{const e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},At=()=>globalThis.performance?.now()??Date.now(),St=class{constructor(e=vr){Y(this,"now",e),Y(this,"known",new Map),Y(this,"smoothed",new Map),Y(this,"times",new WeakMap),Y(this,"lerp",new ur),Y(this,"drawnAt",NaN),Y(this,"drawn",0),Y(this,"smoothedBody",(t,r={})=>{const o=r.interpolate!==!1;if(typeof t=="number"){const a=this.smoothed.get(t);return a?o?this.lerp.at(t,this.tick())??a.body:a.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,Ct(r.smooth),o)})}note(e,t,r=At()){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:r})}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)??Ue(e-1)}posed(e,t,r,o=!0){const a=this.smooth(e,t,r);return o?this.lerp.at(e,this.tick())??a:a}smooth(e,t,r){const o=this.smoothed.get(e);if(o&&o.raw===t&&o.amount===r)return o.body;o&&o.amount!==r&&this.lerp.forget(e);const a=r<1?kr(o?.body,t,r):t;this.smoothed.set(e,{raw:t,body:a,amount:r});const n=this.times.get(t),i=n?.arrival??At();return this.lerp.push(e,n?.t??i,a,i),a}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 dr(t)?t:Ue(e-1)}};function Er(e,t){const r=typeof e.getTransform=="function"?e.getTransform():null,o=r&&Math.hypot(r.a,r.b)||1,a=r&&Math.hypot(r.c,r.d)||1,n=(e.canvas?.width??0)/o,i=(e.canvas?.height??0)/a;return t?{x:t.x*n,y:t.y*i,w:t.w*n,h:t.h*i}:{x:0,y:0,w:n,h:i}}var Ct=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function Tt(e,t){return(r,o,a,n,i={})=>{const c=Array.isArray(o)?null:o,u=c?c.body:o;if(!Array.isArray(u))return null;const f=typeof a=="string"?a:e.of(typeof a=="number"?a:c??1),s=typeof a=="number"?a:c?.id,h=s!==void 0?e.posed(s,u,Ct(i.smooth),i.interpolate!==!1):u;return yr(r,h,f,n??Er(r,t().view),i.alpha!==void 0?{alpha:i.alpha}:{})?h:null}}function Mr(e){const t=new Map,r=(s,h)=>t.get(s)?.forEach(l=>l(h));let o=null,a=null;const n=new Map,i=[],c=s=>o?s(o):i.push(s),u=new St,f=Tt(u,()=>({view:null}));return e.then(s=>{o=s;const h=new Map;s.on("gesture",l=>r(l.gesture,{player:l.player})),s.on("pause",l=>r("pause",{reason:l.reason==="distance"?"distance":"user"})),s.on("resume",()=>r("resume",{})),s.on("break-start",()=>r("break-start",{})),s.on("break-done",l=>r("break-end",{shown:l.shown})),s.onBackdrop((l,d)=>r("backdrop",{backdrop:l,view:d})),s.on("turn",l=>r("turn",{players:[...l.players]})),s.on("capabilities",l=>r("capabilities",{pictures:l.pictures})),s.on("frame",l=>{r("players",{players:l.players});for(const d of l.players)r("hands",{player:d.id,left:d.leftHand,right:d.rightHand,aim:{left:s.aim(d,"left"),right:s.aim(d,"right")}}),h.get(d.id)!==d.shape&&(h.set(d.id,d.shape),r("shape",{player:d.id,shape:d.shape}))}),a=Ar(s),r("start",a),i.splice(0).forEach(l=>l(s))}),{on(s,h){const l=t.get(s)??new Set;return t.set(s,l),l.add(h),s==="start"&&a&&h(a),()=>{l.delete(h)}},ready:()=>c(s=>s.ready()),score:(s,h)=>c(l=>{const d=h??Pt(l);n.set(d,s),l.score(d,s)}),break:s=>new Promise(h=>c(l=>{l.break(s).then(h)})),end:s=>c(h=>h.end(typeof s=="number"?Sr(h,s,n):s.map(l=>({player:l.player,score:l.score,stars:l.stars??2})))),keys:(s,h)=>c(l=>{$t(l,s,h)}),pointer:s=>c(h=>{Kt(h,s)}),get players(){return o?.players??zt},get turns(){return o?.turns??zt},get input(){return o?.input??"body"},get hasPointer(){return o?.pointer??!1},get canSavePicture(){return o?.canSavePicture??!1},savePicture:(s,h)=>new Promise(l=>c(d=>{d.savePicture(s,h).then(l)})),get muted(){return o?.muted??!1},get orientation(){return o?.orientation??"landscape"},get safeArea(){return o?.safeArea??ot},get view(){return o?.view??null},get device(){return o?.device??null},reportStats:s=>o?.reportStats(s),toScreen:s=>o?o.toScreen(s):Ne(null,s),aim:(s,h)=>o?o.aim(s,h):null,avatarOf:s=>o?o.avatarOf(s):u.of(s),drawAvatar:(...s)=>o?o.drawAvatar(...s):f(...s),smoothedBody:(...s)=>o?o.smoothedBody(...s):u.smoothedBody(...s)}}var zt=Object.freeze([]),Ar=e=>({ageRange:e.ageRange,players:e.players,locale:e.locale,mode:e.mode,orientation:e.orientation,safeArea:e.safeArea,backdrop:e.backdrop,view:e.view,device:e.device,turns:e.turns,input:e.input,pointer:e.pointer,canSavePicture:e.canSavePicture,muted:e.muted}),Pt=e=>e.input==="remote"?e.players[0]??1:1;function Sr(e,t,r){const o=Pt(e);return e.input!=="remote"?[{player:o,score:t,stars:2}]:[...e.turns.slice(0,Math.max(e.turns.indexOf(o),0)).map(n=>({player:n,score:r.get(n)??0,stars:2})),{player:o,score:t,stars:2}]}var Cr=[Jt,.7,.55],_t=.75,Tr=320;function zr(e){if(typeof e=="string"){const t=Ze(e);return"ok"in t?{data:e}:{error:t.error==="too-big"?"too-big":"error"}}try{if(!e||typeof e.toDataURL!="function")return{error:"error"};const{width:t,height:r}=e;if(!(t>0&&r>0))return{error:"error"};const o=e.ownerDocument??document;let a=Math.min(1,Ut/Math.max(t,r));for(;;){const n=Math.max(1,Math.round(t*a)),i=Math.max(1,Math.round(r*a)),c=o.createElement("canvas");c.width=n,c.height=i;const u=c.getContext("2d");if(!u)return{error:"error"};u.fillStyle="#fff",u.fillRect(0,0,n,i),u.drawImage(e,0,0,n,i);for(const f of Cr){const s=c.toDataURL("image/jpeg",f),h=Ze(s);if("ok"in h)return{data:s};if(h.error!=="too-big")return{error:"error"}}if(Math.max(n,i)*_t<Tr)return{error:"too-big"};a*=_t}}catch{return{error:"error"}}}var Pr=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",r=>r.source===e.parent&&t(r.data))}),_r=1e4,Or=1e3,Ir=12e4;function Lr(e=Pr(),t={}){return new Promise((r,o)=>{const a=new Map,n=[];let i=!1,c=!1,u=!1,f="none",s=null,h="landscape",l=[];const d=new tt;let p="body",y=Object.freeze([]),b=y,x=!1,S=0;const v=new Map;let z;const U=()=>{if(z===void 0){const H=t.cursor!==void 0?t.cursor:typeof document<"u"?Gt():null;z=H?Vt(H):null}return z},re=new Set,ae=new St,Me=Tt(ae,()=>({view:s})),T=ae.smoothedBody,j=setTimeout(()=>o(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),_r);e.listen(H=>{if(typeof H!="object"||H===null||H.ns!==Je)return;const g=H;if(g.type==="init"&&!u){if(g.v!==Ke)return clearTimeout(j),o(new Error(`Fabi Play: protocol ${g.v}, this SDK speaks ${Ke}`));u=!0,clearTimeout(j),f=g.backdrop==="video"?"video":"none",s=et(g.view)??null;const W=mo(g.device)??null;h=g.orientation==="portrait"?"portrait":"landscape";const O=xo(g.safeArea),E=O?Object.freeze(O):ot;p=g.input==="remote"?"remote":"body";const xe=p==="remote"&&g.pointer===!0;x=g.pictures===!0,y=Object.freeze(Array.isArray(g.players)?[...g.players]:[]);const me=p==="remote"&&y.length===1?Mo(g.turns):void 0;b=Object.freeze(me&&me[0]===y[0]?me:[...y]);let Ae={};if(g.stats===!0){let M=performance.now();setInterval(()=>{const $=performance.now();e.post(ye({type:"stats",renderFps:Math.round(ae.takeDrawn()*1e3/Math.max($-M,1)),...Ae})),M=$},Or).unref?.()}r({locale:g.locale,mode:g.mode,get players(){return y},turns:b,input:p,pointer:xe,muted:g.muted,orientation:h,safeArea:E,ageRange:g.ageRange??"6-8",get backdrop(){return f},get view(){return s},device:W,reportStats:M=>{Ae=go(M)},toScreen:M=>Ne(s,M),aim(M,K){const $=typeof M=="number"?M:M?.id,X=typeof M=="number"?l.find(m=>m.id===M):M,Z=h==="portrait",ge=X?(f!=="video"||Z?T(X):null)??X.body:null,k=ge?yo(ge,K,{orientation:h,view:s}):null;return Z&&typeof $=="number"?d.at(tt.key($,K),k,performance.now()):k},avatarOf:M=>ae.of(M),drawAvatar:Me,smoothedBody:T,onBackdrop(M){return re.add(M),()=>{re.delete(M)}},on(M,K){const $=a.get(M)??new Set;return a.set(M,$),$.add(K),()=>{$.delete(K)}},ready:()=>e.post(ye({type:"ready"})),score:(M,K)=>e.post(ye({type:"score",player:M,score:K})),break:(M="level")=>new Promise(K=>{n.push({reason:M,done:K}),e.post(ye({type:"break",reason:M}))}),end:M=>e.post(ye({type:"end",scores:M})),get canSavePicture(){return x},savePicture:async(M,K)=>{if(!x)return"unavailable";const $=zr(M);if("error"in $)return $.error;const X=++S,Z=io(K?.title);return new Promise(ge=>{const k=setTimeout(()=>m("error"),Ir);k.unref?.();const m=w=>{clearTimeout(k),v.delete(X),ge(w)};v.set(X,m),e.post(ye({type:"picture",data:$.data,id:X,...Z?{title:Z}:{}}))})}})}else if(u){let W=g;if(g.type==="frame"&&Array.isArray(g.players)&&(ae.note(g.players,g.t),l=g.players),g.type==="backdrop"){if(g.backdrop!=="video"&&g.backdrop!=="none")return;const O=et(g.view)??null;if(g.backdrop===f&&Rr(O,s))return;f=g.backdrop,s=O,W={type:"backdrop",backdrop:f,...s?{view:s}:{}};for(const E of[...re])E(f,s)}if(g.type==="turn"){const O=p==="remote"&&i&&!c&&n[0]?.reason==="turn"?Eo(g.players):void 0,E=y[0];if(!O||E===void 0||b.indexOf(O[0])<=b.indexOf(E))return;c=!0,y=Object.freeze(O),W={type:"turn",players:[...O]}}if(g.type==="picture-result"){const O=vo(g);O?.id!==void 0&&v.get(O.id)?.(O.result);return}if(g.type==="capabilities"){if(typeof g.pictures!="boolean"||g.pictures===x)return;x=g.pictures,W={type:"capabilities",pictures:x}}if(g.type==="cursor"){const O=p==="remote"?wo(g):void 0;if(!O)return;W=O,U()?.update(O)}(g.type==="pause"||g.type==="break-start"||g.type==="turn")&&z?.cancel(),g.type==="break-start"&&(i=n.length>0);for(const O of a.get(g.type)??[])O(W);g.type==="break-done"&&(i=c=!1,n.shift()?.done(g.shown))}else return})})}var Rr=(e,t)=>e===t||e!==null&&t!==null&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,Ot={};We(Ot,{BAND_BODY:()=>ie,DEFAULT_AVATAR:()=>wt,avatarById:()=>pr,avatarShapes:()=>Be,drawShapes:()=>He,frameOf:()=>je,iconShapes:()=>br});function Dr(e){const t=Lr(),r=Mr(t);e?.dataset.mute!=="manual"&&Bt(t);const o=Object.assign(r,{avatars:{...Ot}});window.FabiPlay=o;const a=e?.dataset.keys;a&&r.keys(Wt(a));const n=e?.dataset.pointer;return n&&r.pointer({hand:n==="left"||n==="right"?n:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?r.ready():window.addEventListener("load",()=>r.ready(),{once:!0})),o}return he.exports.install(Re)});
|