@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/dist/fabi-play.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var tt=Object.defineProperty;var nn=(e,t,n)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var rn=(e,t)=>{for(var n in t)tt(e,n,{get:t[n],enumerable:!0})};var H=(e,t,n)=>nn(e,typeof t!="symbol"?t+"":t,n);function ot(e,t=window){let n=new Set,r=t.AudioContext;r&&(t.AudioContext=class extends r{constructor(...l){super(...l),n.add(this)}});let a=[],o=[];Promise.resolve(e).then(l=>{l.on("break-start",()=>{a=[...t.document.querySelectorAll("audio, video")].filter(c=>!c.paused),a.forEach(c=>c.pause()),o=[...n].filter(c=>c.state==="running"),o.forEach(c=>{c.suspend()})}),l.on("break-done",()=>{a.forEach(c=>{c.play().catch(()=>{})}),o.forEach(c=>{c.resume()}),a=[],o=[]})})}var on={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function at(e){if(e.trim()==="default")return;let t={};for(let n of e.split(",")){let[r,a]=n.split(":").map(o=>o.trim());r&&a&&(t[r]=a)}return t}var an={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function nt(e){let t=an[e];if(t)return{key:t[0],code:e,keyCode:t[1]};let n=/^Key([A-Z])$/.exec(e);if(n)return{key:n[1].toLowerCase(),code:e,keyCode:n[1].charCodeAt(0)};let 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 sn=(e=document)=>({dispatch(t,n){let r=new KeyboardEvent(t,{key:n.key,code:n.code,bubbles:!0,cancelable:!0});for(let a of["keyCode","which"])Object.defineProperty(r,a,{get:()=>n.keyCode});(e.activeElement??e.body??e).dispatchEvent(r)}}),rt=80,ln=800;function st(e,t=on,n={}){let r=n.player===void 0&&e.input==="remote",a=n.player??(r?e.players?.[0]??1:1),o=n.target??sn(),l=n.setTimeout??((h,m)=>setTimeout(h,m)),c=new Set,p=0,u=h=>{let m=t[h];!m||c.has(h)||(c.add(h),o.dispatch("keydown",nt(m)))},s=h=>{let m=t[h];!m||!c.has(h)||(c.delete(h),o.dispatch("keyup",nt(m)))},f=h=>{u(h),l(()=>s(h),rt)},i=h=>{if(h.player!==a)return;let m={"lane-left":-1,"lane-center":0,"lane-right":1};switch(h.gesture){case"jump":u("jump"),l(()=>s("jump"),ln);break;case"land":s("jump");break;case"squat":u("squat");break;case"stand":s("squat");break;case"clap":f("clap");break;default:{let k=m[h.gesture];if(k===void 0)break;let A=k>p?"right":"left";for(let E=0;E<Math.abs(k-p);E++)l(()=>f(A),E*(rt*2));p=k}}},d=h=>{let m=h.players.find(k=>k.id===a);m&&(m.shape==="arms-up"?u("arms-up"):s("arms-up"))},y=[e.on("gesture",i),e.on("frame",d),e.on("break-start",()=>[...c].forEach(s)),e.on("turn",h=>{r&&([...c].forEach(s),a=h.players[0]??a,p=0)})];return()=>{y.forEach(h=>h()),[...c].forEach(s)}}function cn(e=document){let 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);let n=(r,a,...o)=>{let l=e.elementFromPoint(r,a)??e.body;for(let c of o){let p={bubbles:!0,cancelable:!0,clientX:r,clientY:a,pointerId:1,pointerType:"touch",isPrimary:!0};l.dispatchEvent(c.startsWith("pointer")?new PointerEvent(c,p):new MouseEvent(c,p))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(r,a)=>n(r,a,"pointermove","mousemove"),click:(r,a)=>n(r,a,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(r,a,o)=>{t.style.transform=`translate(${r}px, ${a}px) scale(${1-o*.35})`,t.style.borderColor=o>0?"#EE6A43":"#FBE7B8"}}}function it(e,t={}){let n=t.player??1,r=t.hand??"any",a=t.dwellMs??800,o=t.radius??.04,l=t.target??cn(),c=null,p=!1;return e.on("frame",u=>{let s=u.players.find(E=>E.id===n);if(!s)return;let i=r==="left"?s.leftHand:r==="right"?s.rightHand:((E,M)=>E&&M?E.y<M.y?E:M:E??M)(s.leftHand,s.rightHand);if(!i)return;let{width:d,height:y}=l.size(),h=i.x*d,m=i.y*y;l.move(h,m),(!c||Math.hypot(h-c.x,m-c.y)>o*Math.hypot(d,y))&&(c={x:h,y:m,t:u.t},p=!1);let A=p?0:Math.min((u.t-c.t)/a,1);A>=1&&(p=!0,l.click(c.x,c.y)),l.cursor(h,m,p?0:A)})}function lt(e=document){let t=e.defaultView,n=t?.PointerEvent,r=t?.MouseEvent??MouseEvent,a=null,o=null,l=(c,p,u,s,f,i=null)=>{let d={bubbles:!0,cancelable:!0,composed:!0,view:t,clientX:u,clientY:s,screenX:u,screenY:s,button:0,buttons:f,relatedTarget:i,pointerId:1,pointerType:"mouse",isPrimary:!0};p.startsWith("pointer")?n&&c.dispatchEvent(new n(p,d)):c.dispatchEvent(new r(p,d))};return{size:()=>({width:t?.innerWidth??e.documentElement.clientWidth,height:t?.innerHeight??e.documentElement.clientHeight}),dispatch(c,p,u,s){let f=e.elementFromPoint(p,u)??e.body??e.documentElement;if(c==="pointermove"&&f!==a){if(a?.isConnected)for(let i of["pointerout","mouseout"])l(a,i,p,u,s,f);for(let i of["pointerover","mouseover"])l(f,i,p,u,s,a);a=f}if(c==="pointerdown"&&(o=f),c==="click"){let i=o===f;if(o=null,!i)return}l(f,c,p,u,s)}}}function ct(e){let t=null,n=(r,a,o,l)=>{let{width:c,height:p}=e.size();for(let u of r)e.dispatch(u,a*c,o*p,l)};return{update(r){let a=t?.down??!1;(!t||t.x!==r.x||t.y!==r.y)&&n(["pointermove","mousemove"],r.x,r.y,a?1:0),r.down&&!a&&n(["pointerdown","mousedown"],r.x,r.y,1),!r.down&&a&&n(["pointerup","mouseup","click"],r.x,r.y,0),t={x:r.x,y:r.y,down:r.down}},cancel(){t?.down&&(n(["pointercancel","mouseup"],t.x,t.y,0),t={...t,down:!1})}}}var ut=["sent","unavailable","too-big","error"],un=/^[A-Za-z0-9+/]*={0,2}$/,pn={"image/jpeg":"/9j/","image/png":"iVBORw0KGg"},fn=/^data:(image\/(?:jpeg|png));base64,/,dn=e=>e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0),yn=Math.ceil(3145728/3)*4,hn=(e,t)=>t.length%4===0&&t.length>0&&t.startsWith(pn[e])&&un.test(t);function Ie(e){if(typeof e!="string")return{error:"invalid"};let t=fn.exec(e);if(!t)return{error:"invalid"};let n=t[1],r=e.slice(t[0].length);if(r.length>yn)return{error:"too-big"};if(!hn(n,r))return{error:"invalid"};let a=dn(r);return a>3145728?{error:"too-big"}:{ok:{mime:n,base64:r,size:a}}}function Ge(e){return typeof e!="string"?void 0:Array.from(e.replace(/[\p{Cc}\p{Cf}]/gu,"").trim()).slice(0,60).join("").trim()||void 0}var Fe=1,je=33,O={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},pt=["3-5","6-8","9-12"],mn=e=>pt.includes(e);var Ve=4;var ft={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},bn=ft["6-8"],Ke=(e,t)=>{let n=mn(t)?ft[t]:bn;return n[Number.isInteger(e)&&e>=0?e%n.length:0]};var Ue="fabi-play",fe=e=>({ns:Ue,...e});function Xe(e){if(!Me(e))return;let{x:t,y:n,w:r,h:a}=e;return pe(t)&&pe(n)&&pe(r)&&pe(a)&&r>0&&a>0?{x:t,y:n,w:r,h:a}:void 0}var Be=(e,t)=>e?{x:e.x+t.x*e.w,y:e.y+t.y*e.h}:{x:t.x,y:t.y},dt=["high","medium","low"];function yt(e){if(!Me(e))return;let t={};return dt.includes(e.tier)&&(t.tier=e.tier),pe(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function ht(e){let t={};return Me(e)&&(pe(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),dt.includes(e.tier)&&(t.tier=e.tier)),t}function mt(e){if(!Me(e)||!pe(e.x)||!pe(e.y)||typeof e.down!="boolean")return;let t=n=>Math.min(Math.max(n,0),1);return{type:"cursor",x:t(e.x),y:t(e.y),down:e.down}}function bt(e){if(!(!Me(e)||!ut.includes(e.result)))return{type:"picture-result",...Number.isInteger(e.id)?{id:e.id}:{},result:e.result}}var xt=e=>Number.isInteger(e)&&e>=1&&e<=Ve;function kt(e){return Array.isArray(e)&&e.length===1&&xt(e[0])?[e[0]]:void 0}function gt(e){if(!(!Array.isArray(e)||e.length<1||e.length>Ve||!e.every(xt)||new Set(e).size!==e.length))return[...e]}var Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),pe=e=>typeof e=="number"&&Number.isFinite(e);var xn=12,kn=je*4,gn=e=>xn+e*kn,Er=gn(Ve);var Y="#4a382c",j="#2b2118",q="#1c1f2b",wt="#fbefe3",Z="#f4897a",Ce="#3a2a22",Ye=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:wt,accent:"#ffd9c2",outline:j,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:Ce,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:wt,accent:"#5a3426",outline:j,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:Ce,muzzle:"band",cheeks:Z},tail:"brush",headExtras:[],bodyExtras:["star"],extraColors:["#ffd84a"]},{id:"bunny",name:{en:"Bunny",it:"Coniglietto"},band:"3-5",palette:{body:"#f9d0de",limbs:"#f9d0de",belly:"#fff6f8",accent:"#f4a0b9",outline:Y},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:Z},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:Y},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:Ce,muzzle:"oval",cheeks:Z},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:Y,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:Z},tail:"long",headExtras:["whiskers"],bodyExtras:[]},{id:"panda",name:{en:"Panda",it:"Panda"},band:"3-5",palette:{body:"#ffffff",limbs:"#6e6674",belly:"#ffffff",accent:"#6e6674",outline: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:j},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:Z},tail:"tuft",headExtras:["mane"],bodyExtras:[],extraColors:["#c8692e"]},{id:"unicorn",name:{en:"Unicorn",it:"Unicorno"},band:"6-8",palette:{body:"#fbf5ff",limbs:"#fbf5ff",belly:"#efe0ff",accent:"#fbd46a",outline:j,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:j},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:q,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:q,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:j},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:j,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:Z},tail:"curl",headExtras:["tuft"],bodyExtras:[]},{id:"koala",name:{en:"Koala",it:"Koala"},band:"3-5",palette:{body:"#b7bcc6",limbs:"#b7bcc6",belly:"#eef0f3",accent:"#f4dbe2",outline: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:j},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:Z},tail:"striped",headExtras:["stripes","whiskers"],bodyExtras:[],extraColors:["#3a2a22"]},{id:"owl",name:{en:"Owl",it:"Gufetto"},band:"3-5",palette:{body:"#8ec0e6",limbs:"#8ec0e6",belly:"#e3f2fc",accent:"#639cc9",outline: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:q},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:j},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:j,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:Z},tail:"none",headExtras:["eggshell"],bodyExtras:[],extraColors:["#fffaf0"]},{id:"puppy",name:{en:"Puppy",it:"Cucciolo"},band:"3-5",palette:{body:"#f4e4cf",limbs:"#f4e4cf",belly:"#fffaf2",accent:"#f29aa4",outline:Y,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:Ce,muzzle:"oval",cheeks:Z},tail:"curl",headExtras:["eye-spot"],bodyExtras:[]},{id:"lamb",name:{en:"Lamb",it:"Agnellino"},band:"3-5",palette:{body:"#fdf8ee",limbs:"#e3d1c2",belly:"#fffdf8",accent:"#f6bcc2",outline:Y,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:Z},tail:"pom",headExtras:["wool"],bodyExtras:["wool"]},{id:"duckling",name:{en:"Duckling",it:"Anatroccolo"},band:"3-5",palette:{body:"#fff1a6",limbs:"#fff1a6",belly:"#fffbe0",accent:"#ff9f43",outline:Y,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:Z},tail:"none",headExtras:["curl"],bodyExtras:["flippers","scarf"],extraColors:["#86cfe0"]},{id:"shark",name:{en:"Shark",it:"Squalo"},band:"6-8",palette:{body:"#6c95c4",limbs:"#6c95c4",belly:"#eef5fb",accent:"#4c76a8",outline:j,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:j,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:Ce,muzzle:"oval",cheeks:"#f4a3b0"},tail:"fluffy",headExtras:["ruff","forehead"],bodyExtras:[],extraColors:["#636d84"]},{id:"parrot",name:{en:"Parrot",it:"Pappagallo"},band:"6-8",palette:{body:"#e8503f",limbs:"#e8503f",belly:"#ffd25a",accent:"#f6e6c4",outline:j,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:j,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:q,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:q,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:q,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:q,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:q,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:q,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:q,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:q,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:q,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:j},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:j,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"]}];var L={M:0,L:1,Q:2,C:3,Z:4},vt=[2,2,4,6,0];function be(e,t){for(let n of t)wn(e,n)}function wn(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),be(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":vn(e,t);break;case"path":typeof t.d=="string"?En(e,t.d):Pn(e,t.d);break;case"line":e.moveTo(t.pts[0]??0,t.pts[1]??0);for(let n=2;n+1<t.pts.length;n+=2)e.lineTo(t.pts[n],t.pts[n+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 vn(e,t){let n=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);let r=-t.w/2,a=-t.h/2;e.moveTo(r+n,a),e.lineTo(r+t.w-n,a),e.quadraticCurveTo(r+t.w,a,r+t.w,a+n),e.lineTo(r+t.w,a+t.h-n),e.quadraticCurveTo(r+t.w,a+t.h,r+t.w-n,a+t.h),e.lineTo(r+n,a+t.h),e.quadraticCurveTo(r,a+t.h,r,a+t.h-n),e.lineTo(r,a+n),e.quadraticCurveTo(r,a,r+n,a),e.closePath()}function Pn(e,t){for(let n=0;n<t.length;){let r=t[n++];if(r===L.M)e.moveTo(t[n],t[n+1]);else if(r===L.L)e.lineTo(t[n],t[n+1]);else if(r===L.Q)e.quadraticCurveTo(t[n],t[n+1],t[n+2],t[n+3]);else if(r===L.C)e.bezierCurveTo(t[n],t[n+1],t[n+2],t[n+3],t[n+4],t[n+5]);else if(r===L.Z)e.closePath();else return;n+=vt[r]}}function Qe(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);let t=[];for(let n=0;n<e.length;){let r=vt[e[n++]];if(r===void 0)break;for(let a=0;a<r;a++)t.push(e[n+a]);n+=r}return t}function En(e,t){let n=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[],r="",a=0,o=()=>Number(n[a++]);for(;a<n.length;){let l=n[a];if(/[MLQCZ]/i.test(l)&&(r=l.toUpperCase(),a++,r==="Z")){e.closePath();continue}r==="M"?(e.moveTo(o(),o()),r="L"):r==="L"?e.lineTo(o(),o()):r==="Q"?e.quadraticCurveTo(o(),o(),o(),o()):r==="C"?e.bezierCurveTo(o(),o(),o(),o(),o(),o()):a++}}var _=e=>{let t=Math.round(e*100)/100;return t===0?0:t};function D(e,t=.5){let n=e.length;if(n<3)return[];let r=(c,p,u)=>({x:c.x+(p.x-c.x)*u,y:c.y+(p.y-c.y)*u}),a=Math.min(Math.max(t,0),.5),o=r(e[0],e[1],a),l=[L.M,_(o.x),_(o.y)];for(let c=1;c<=n;c++){let p=e[(c-1)%n],u=e[c%n],s=e[(c+1)%n],f=r(p,u,1-a),i=r(u,s,a);l.push(L.L,_(f.x),_(f.y),L.Q,_(u.x),_(u.y),_(i.x),_(i.y))}return l.push(L.Z),l}function T(e,t=1){let n=e.length;if(n<3)return[];let r=[L.M,_(e[0].x),_(e[0].y)],a=t/6;for(let o=0;o<n;o++){let l=e[(o-1+n)%n],c=e[o],p=e[(o+1)%n],u=e[(o+2)%n];r.push(L.C,_(c.x+(p.x-l.x)*a),_(c.y+(p.y-l.y)*a),_(p.x-(u.x-c.x)*a),_(p.y-(u.y-c.y)*a),_(p.x),_(p.y))}return r.push(L.Z),r}function xe(e){let t=e.length;if(t<2)return[];let n=[L.M,_(e[0].x),_(e[0].y)];for(let r=0;r<t-1;r++){let a=e[Math.max(r-1,0)],o=e[r],l=e[r+1],c=e[Math.min(r+2,t-1)];n.push(L.C,_(o.x+(l.x-a.x)/6),_(o.y+(l.y-a.y)/6),_(l.x-(c.x-o.x)/6),_(l.y-(c.y-o.y)/6),_(l.x),_(l.y))}return n}var se="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";var G="#ffffff",S=[-1,1],Pt="#3a2420",Et="#f2808f",qe="#26324a",An="#ffd84a",N=(...e)=>{let t=[];for(let n=0;n+1<e.length;n+=2)t.push({x:e[n],y:e[n+1]});return t};function De(e,t){let n=e.palette,r=[],a={stroke:n.outline,lw:t},o=s=>e.headExtras.includes(s),l=(s,f)=>e.extraColors?.[s]??f;if(o("mane")){for(let f=0;f<12;f++){let i=f/12*Math.PI*2;r.push({k:"circle",x:Math.cos(i)*1.02,y:Math.sin(i)*1+.04,r:.42,fill:l(0,n.accent),...a})}r.push({k:"circle",x:0,y:.04,r:1.08,fill:l(0,n.accent)})}if(o("rainbow-mane")){let s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([i,d,y,h,m],k)=>r.push({k:"ellipse",x:i,y:d,rx:y,ry:h,rot:m,fill:s[k%s.length],...a}))}if(o("spikes"))for(let s of[-.55,0,.55]){let f=de(s,1.48),i=de(s-.32,.86),d=de(s+.32,.86);r.push({k:"path",d:D([i,f,d],.22),fill:n.accent,...a})}if(o("curl")&&r.push({k:"path",d:T([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:n.body,...a}),o("wool"))for(let s=0;s<=8;s++){let f=-1.75+s/8*3.5;r.push({k:"circle",x:Math.sin(f)*.98,y:-Math.cos(f)*.92-.04,r:.34,fill:n.body,...a})}if(o("crest")&&[-.38,0,.38].forEach((s,f)=>{let i=de(s,1.12);r.push({k:"ellipse",x:i.x,y:i.y,rx:.15,ry:.42,rot:s,fill:l(f,n.accent),...a})}),o("plume")&&r.push({k:"path",d:T(N(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:n.accent,...a}),o("locks")&&r.push({k:"path",d:T(N(-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:n.hair??n.outline,...a}),o("bun")&&r.push({k:"circle",x:.04,y:-1.14,r:.4,fill:n.hair??n.outline,...a}),o("ninja-hood"))for(let[s,f]of[[.35,.5],[.85,.42]])r.push({k:"ellipse",x:1+Math.cos(s)*f*.8,y:-.5+Math.sin(s)*f*.8,rx:f,ry:.11,rot:s,fill:n.accent,...a});if(o("bandana"))for(let[s,f]of[[Math.PI-.5,.42],[Math.PI-1,.36]])r.push({k:"ellipse",x:-.98+Math.cos(s)*f*.8,y:-.36+Math.sin(s)*f*.8,rx:f,ry:.12,rot:s,fill:n.accent,...a});if(o("ruff"))for(let s of S)r.push({k:"path",d:D(N(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:n.body,...a});if(e.face.eyesOnTop)for(let s of S)r.push({k:"circle",x:s*.46,y:-.72,r:.38,fill:n.body,...a});r.push(...In(e,t)),r.push(Sn(e,a));let c=e.face.muzzle,p=n.belly;if(c==="oval"&&r.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:p}),c==="monkey"){for(let s of S)r.push({k:"circle",x:s*.32,y:-.04,r:.38,fill:p});r.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:p})}if(c==="heart"){for(let s of S)r.push({k:"circle",x:s*.36,y:.02,r:.5,fill:p});r.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:p})}if(c==="disc")for(let s of S)r.push({k:"circle",x:s*.4,y:.02,r:.44,fill:p});if(c==="cheeks")for(let s of S)r.push({k:"ellipse",x:s*.4,y:.44,rx:.44,ry:.32,fill:p});if(c==="band"&&r.push({k:"path",d:Tn(e,t),fill:p}),o("stripes")&&e.head==="snout-long"){let s=l(0,n.outline);for(let[f,i,d,y]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])r.push({k:"line",pts:[f,i,d,y],stroke:s,lw:.11})}else if(o("stripes")){let s=l(0,n.outline);r.push({k:"line",pts:[0,-.97,0,-.66],stroke:s,lw:.13});for(let f of S)r.push({k:"line",pts:[f*.3,-.93,f*.24,-.7],stroke:s,lw:.1}),r.push({k:"line",pts:[f*.98,-.05,f*.74,0],stroke:s,lw:.1}),r.push({k:"line",pts:[f*.94,.22,f*.74,.22],stroke:s,lw:.09})}if(o("spots")){let s=l(1,n.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(let[s,f,i]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])r.push({k:"ellipse",x:s,y:f,rx:i,ry:i*.8,rot:-.3,fill:n.outline,alpha:.85});if(o("forehead")&&r.push({k:"path",d:T(N(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:l(0,n.accent)}),o("eye-spot")&&r.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:n.ears??n.accent}),o("gills"))for(let s of S)for(let f of[0,.12,.24])r.push({k:"path",d:`M${s*(.66+f)} 0.06 Q${s*(.6+f)} 0.22 ${s*(.66+f)} 0.38`,stroke:n.accent,lw:t*.9});let u=n.hair??n.outline;if(o("hair")&&r.push({k:"path",d:T(N(-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:u,...a}),o("locks")&&r.push({k:"path",d:T(N(-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:u,...a}),o("bun")&&r.push({k:"path",d:T(N(-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:u,...a}),o("curls")){for(let s=0;s<7;s++){let f=de(-1.3+s/6*2.6,.86);r.push({k:"circle",x:f.x,y:f.y,r:.3,fill:u,...a})}r.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:u})}if(o("ninja-hood")&&(r.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:n.skin??G,stroke:n.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:n.accent,...a})),o("domino")){r.push({k:"path",d:T(N(-.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:n.accent,...a});for(let s of S)r.push({k:"ellipse",x:s*.38,y:0,rx:.19,ry:.13,fill:G})}if(r.push(...Bn(e,t)),o("brows"))for(let s of S)r.push({k:"line",pts:[s*.72,-.5,s*.14,-.3],stroke:n.accent,lw:.16});if(e.face.brows)for(let s of S)r.push({k:"line",pts:[s*.2,-.2,s*.54,-.28],stroke:e.face.brows,lw:.09});if(r.push(...Dn(e,t)),e.face.cheeks)for(let s of Cn(e))r.push({k:"ellipse",x:s.x,y:s.y,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(o("whiskers"))for(let s of S)for(let f of[-.1,.06])r.push({k:"line",pts:[s*.62,.38+f,s*1.06,.3+f*2.2],stroke:n.outline,lw:t*.7,alpha:.75});if(o("rainbow-mane")){let 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"){let s=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];r.push({k:"path",d:D(s,.12),fill:n.accent,...a});for(let f of[-1,-1.2,-1.4]){let i=.16*((f+1.72)/.88);r.push({k:"line",pts:[-i,f+.04,i,f-.04],stroke:n.outline,lw:t*.7,alpha:.6})}}if(o("flower-crown")){let s=[l(1,"#f7a8cf"),l(2,"#fff3a0"),l(3,G)];for(let f of[-.84,-.28,.28,.84]){let i=de(f,.9);r.push({k:"ellipse",x:i.x,y:i.y,rx:.14,ry:.07,rot:f+.5,fill:"#7cc76a",stroke:n.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((f,i)=>{let d=de(f,.9),y=i===2?.13:.11;for(let h=0;h<5;h++){let m=f+h/5*Math.PI*2;r.push({k:"circle",x:d.x+Math.sin(m)*y,y:d.y-Math.cos(m)*y,r:y*.82,fill:s[i%s.length],stroke:n.outline,lw:t*.7})}r.push({k:"circle",x:d.x,y:d.y,r:y*.62,fill:s[i%s.length]}),r.push({k:"circle",x:d.x,y:d.y,r:y*.42,fill:n.accent})})}if(o("helmet")){for(let s of S)r.push({k:"rect",x:s*1,y:.05,w:.26,h:.56,r:.12,fill:n.accent,...a});r.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:G,lw:.1,alpha:.9})}if(o("bolts"))for(let s of S)r.push({k:"rect",x:s*1.08,y:.08,w:.2,h:.44,r:.08,fill:n.accent,...a});if(o("tuft")&&r.push({k:"path",d:T([{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:n.body,...a}),o("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:l(0,G),...a}),o("wool"))for(let[s,f]of[[-.36,-.84],[.02,-.94],[.4,-.82]])r.push({k:"circle",x:s,y:f,r:.27,fill:n.body,...a});if(o("stripe")&&r.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:n.accent}),o("eye-patch")&&(r.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:n.outline,lw:.07}),r.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:n.outline})),o("bandana")){r.push({k:"path",d:T(N(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:n.accent,...a});for(let[s,f]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])r.push({k:"circle",x:s,y:f,r:.06,fill:G,alpha:.85});r.push({k:"circle",x:-.98,y:-.34,r:.15,fill:n.accent,...a})}if(o("cap")){for(let s of S)r.push({k:"line",pts:[s*.98,-.2,s*.5,.82,-s*.05,.98],stroke:n.outline,lw:.06});r.push({k:"path",d:T(N(-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:n.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:n.accent,...a}),r.push({k:"circle",x:.5,y:-.82,r:.15,fill:l(0,G),...a});for(let s of[-.42,-.14])r.push({k:"line",pts:[s,-1.04,s+.02,-.78],stroke:n.outline,lw:.07,alpha:.7})}if(o("safari-hat")&&(r.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:n.accent,...a}),r.push({k:"path",d:T(N(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:n.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:l(1,n.outline),stroke:n.outline,lw:t*.8})),o("wizard-hat")){r.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:n.accent,...a}),r.push({k:"path",d:D(N(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:n.accent,...a});let s=l(0,An);for(let[f,i,d]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])r.push({k:"group",x:f,y:i,s:d,items:[{k:"path",d:se,fill:s}]})}if(o("dive-mask")){for(let f of S)r.push({k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:n.outline,lw:.2},{k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:n.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:n.outline,lw:.2}),r.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:n.accent,lw:.11}),r.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:G,lw:.06,alpha:.9});let s="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";r.push({k:"path",d:s,stroke:n.outline,lw:.24},{k:"path",d:s,stroke:n.accent,lw:.13})}return r}function Sn(e,t){let n=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:n,...t};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:n,...t};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:n,...t};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:n,...t};case"bucket":return{k:"path",d:D(N(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:n,...t};case"snout-long":return{k:"path",d:T(Mn,.95),fill:n,...t};case"bulb":return{k:"path",d:T([{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:n,...t}}}var Mn=N(.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 At(e,t,n){return e.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:S.map(r=>({x:r*t,y:n,k:1}))}function Cn(e){return e.head==="snout-long"?N(-.66,-.14,.66,.1):S.map(t=>({x:t*.64,y:.3}))}function Rn(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 Tn(e,t){let{cy:n,rx:r,ry:a}=Rn(e),o=r-t/2,l=a-t/2,c=.15,p=Math.asin(Math.min(1,(c-n)/l)),u=Math.cos(p)*o,s=y=>Math.round(y*100)/100||0,f=[L.M,s(-u),c],i=[[-.84*u,.02,-.53*u,.06,-.32*u,.24],[-.17*u,.11,.17*u,.11,.32*u,.24],[.53*u,.06,.84*u,.02,u,c]];for(let y of i)f.push(L.C,...y.map(s));let d=24;for(let y=1;y<=d;y++){let h=p+(Math.PI-2*p)*y/d;f.push(L.L,s(Math.cos(h)*o),s(n+Math.sin(h)*l))}return f.push(L.Z),f}function In(e,t){let n=e.palette,r={stroke:n.outline,lw:t},a=[];for(let o of S)switch(e.ears){case"pointy":case"unicorn":{let l=e.ears==="unicorn"?.8:1,c={x:o*.3,y:-.82},p={x:o*.86,y:-.82-.62*l},u={x:o*.94,y:-.36};a.push({k:"path",d:D([c,p,u],.2),fill:n.body,...r});let s={x:(c.x+p.x+u.x)/3,y:(c.y+p.y+u.y)/3},f=[c,p,u].map(i=>({x:s.x+(i.x-s.x)*.55,y:s.y+(i.y-s.y)*.55+.04}));a.push({k:"path",d:D(f,.25),fill:n.accent});break}case"round":a.push({k:"circle",x:o*.72,y:-.72,r:.36,fill:n.ears??n.body,...r}),n.ears||a.push({k:"circle",x:o*.74,y:-.74,r:.19,fill:n.accent});break;case"big-round":a.push({k:"circle",x:o*.96,y:-.46,r:.52,fill:n.body,...r}),a.push({k:"circle",x:o*1,y:-.44,r:.32,fill:n.accent});break;case"long":a.push({k:"ellipse",x:o*.38,y:-1.42,rx:.25,ry:.68,rot:o*.14,fill:n.body,...r}),a.push({k:"ellipse",x:o*.39,y:-1.36,rx:.12,ry:.48,rot:o*.14,fill:n.accent});break;case"side":a.push({k:"circle",x:o*1,y:.02,r:.34,fill:n.body,...r}),a.push({k:"circle",x:o*1.02,y:.02,r:.2,fill:n.belly});break;case"tufts":a.push({k:"path",d:D([{x:o*.3,y:-.84},{x:o*1.22,y:-1.12},{x:o*.92,y:-.42}],.16),fill:n.body,...r}),a.push({k:"line",pts:[o*.62,-.78,o*1,-.98],stroke:n.accent,lw:.08});break;case"antennae":{let l={x:o*.62,y:-1.42};a.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${l.x} ${l.y}`,stroke:n.outline,lw:t*2.6}),a.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${l.x} ${l.y}`,stroke:n.body,lw:t*1.2}),a.push({k:"circle",x:l.x,y:l.y,r:.17,fill:n.accent,...r});break}case"floppy":a.push({k:"ellipse",x:o*.96,y:.02,rx:.3,ry:.62,rot:-o*.36,fill:n.ears??n.body,...r});break;case"droopy":a.push({k:"ellipse",x:o*1.04,y:-.22,rx:.4,ry:.18,rot:o*.32,fill:n.skin??n.body,...r}),a.push({k:"ellipse",x:o*1.08,y:-.2,rx:.24,ry:.08,rot:o*.32,fill:n.accent});break;case"pixie":a.push({k:"path",d:D(N(o*.86,-.22,o*1.36,-.5,o*1.02,.26),.28),fill:n.skin??n.body,...r}),a.push({k:"line",pts:[o*.98,-.12,o*1.16,-.3],stroke:n.accent,lw:t*.8,alpha:.5});break;case"human":a.push({k:"ellipse",x:o*.98,y:.06,rx:.17,ry:.23,fill:n.skin??n.body,...r});break;case"horns":{let l=[{x:o*.3,y:-.84},{x:o*.6,y:-1.5},{x:o*.66,y:-.68}];a.push({k:"path",d:D(l,.18),fill:n.accent,...r});break}}return e.ears==="fin"&&a.push({k:"path",d:D(N(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:n.body,...r}),e.ears==="antenna"&&(a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:n.outline,lw:t*2.6}),a.push({k:"line",pts:[0,-.85,0,-1.42],stroke:n.limbs,lw:t*1.2}),a.push({k:"circle",x:0,y:-1.5,r:.18,fill:n.accent,...r})),a}function Bn(e,t){let n=e.palette,r=e.face,a=[],o=n.outline,l=r.eyesOnTop?.46:.4,c=r.eyesOnTop?-.72:-.04,p=(u,s,f)=>({k:"circle",x:u,y:s,r:f,fill:G});switch(r.eyes){case"dot":for(let u of At(e,l,c))a.push({k:"ellipse",x:u.x,y:u.y,rx:.12*u.k,ry:.155*u.k,fill:o}),a.push(p(u.x+.04*u.k,u.y-.06*u.k,.045*u.k));break;case"bead":for(let u of At(e,l,c))a.push({k:"ellipse",x:u.x,y:u.y,rx:.16*u.k,ry:.22*u.k,fill:o}),a.push(p(u.x+.05*u.k,u.y-.08*u.k,.065*u.k));break;case"big":for(let u of S)r.eyeRing&&a.push({k:"circle",x:u*l,y:c,r:.36,fill:r.eyeRing,stroke:o,lw:t*.8}),a.push({k:"circle",x:u*l,y:c,r:.25,fill:G,stroke:o,lw:t*.8}),a.push({k:"circle",x:u*l+u*-.03,y:c+.03,r:.14,fill:r.eyeColor??o}),a.push(p(u*l+u*-.03+.05,c-.03,.05));break;case"mask":for(let u of S)a.push({k:"ellipse",x:u*.4,y:0,rx:.24,ry:.32,rot:u*-.55,fill:n.limbs}),a.push({k:"circle",x:u*.4,y:-.02,r:.11,fill:G}),a.push({k:"circle",x:u*.39,y:-0,r:.065,fill:o});break;case"screen":a.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:o,lw:t*.8});for(let u of S)a.push({k:"ellipse",x:u*.36,y:0,rx:.2,ry:.24,fill:r.eyeColor??"#7ff0ff",alpha:.3}),a.push({k:"ellipse",x:u*.36,y:0,rx:.12,ry:.16,fill:r.eyeColor??"#7ff0ff"});break;case"almond":for(let u of S)a.push({k:"ellipse",x:u*.42,y:-.02,rx:.3,ry:.2,rot:-u*.5,fill:r.eyeColor??o}),a.push(p(u*.42-u*.07,-.08,.07));break;case"calm":for(let u of S)a.push({k:"ellipse",x:u*.38,y:.02,rx:.085,ry:.12,fill:o}),a.push(p(u*.38+.03,-.02,.03));break;case"slit":a.push({k:"line",pts:[0,-.98,0,-.2],stroke:o,lw:t*.8,alpha:.5}),a.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:qe,stroke:o,lw:t*.8}),a.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:qe,stroke:o,lw:t*.8});for(let u of S){a.push({k:"ellipse",x:u*.4,y:-.04,rx:.12,ry:.07,fill:r.eyeColor??G});for(let s of[.36,.56])a.push({k:"circle",x:u*.42,y:s,r:.05,fill:o,alpha:.6})}break;case"goggle":for(let u of S)a.push({k:"circle",x:u*.9,y:0,r:.13,fill:n.accent,stroke:o,lw:t*.8});a.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:qe,stroke:o,lw:t*.8}),a.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:G,lw:.07,alpha:.8});for(let u of S)a.push({k:"path",d:`M${u*.5} 0.04 Q${u*.34} -0.08 ${u*.16} 0.02`,stroke:r.eyeColor??"#7fd6ff",lw:.08});for(let u of[-.18,0,.18])a.push({k:"line",pts:[u,.56,u,.72],stroke:o,lw:t*.8,alpha:.6});break;case"visor":a.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:o,lw:t*.8}),a.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:G,lw:.08,alpha:.7});for(let u of S)a.push({k:"ellipse",x:u*.28,y:.04,rx:.1,ry:.14,fill:r.eyeColor??"#cfeeff"});break}return a}function Dn(e,t){let n=e.palette,r=e.face,a=[],o=r.eyes==="visor"?"#cfeeff":Pt,l=t*1.05;switch(r.nose&&r.mouth!=="beak"&&(r.mouth==="cat"?a.push({k:"path",d:D([{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:o,lw:l});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:o,stroke:o,lw:t*.5}),a.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:Et});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:o,lw:l});break;case"beak":a.push({k:"path",d:D([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:n.accent,stroke:n.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:o,stroke:o,lw:t*.5});for(let c of S)a.push({k:"rect",x:c*.12,y:.43,w:.1,h:.1,r:.03,fill:G});break;case"grill":a.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:n.outline,lw:t*.7});for(let 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:o});break;case"smirk":a.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:o,lw:l});break;case"bill":a.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:n.accent,stroke:n.outline,lw:t*.8}),a.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:n.outline,lw:t*.7});for(let c of S)a.push({k:"circle",x:c*.1,y:.28,r:.03,fill:n.outline});break;case"hook":a.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:Pt}),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:n.accent,stroke:n.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:o,stroke:o,lw:t*.6}),a.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:Et});for(let c of[.12,.27,.42,.57,.72,.86]){let p=(1-c)*(1-c)*-1.4+2*(1-c)*c*-.5+c*c*.5,u=(1-c)*(1-c)*.1+2*(1-c)*c*.36+c*c*.2-.01;a.push({k:"path",d:D(N(p-.08,u,p+.08,u,p,u+.14),.3),fill:G})}for(let c of[.3,.7]){let p=(1-c)*(1-c)*.52+2*(1-c)*c*-.4+c*c*-1.3,u=(1-c)*(1-c)*.38+2*(1-c)*c*.78+c*c*.26+.01;a.push({k:"path",d:D(N(p-.07,u,p+.07,u,p,u-.12),.3),fill:G})}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:o,stroke:o,lw:t*.5});for(let c of[-.34,-.17,0,.17,.34]){let p=.3+.4*(c+.5)*(.5-c)-.01;a.push({k:"path",d:D(N(c-.075,p,c+.075,p,c,p+.13),.15),fill:G})}break}}return a}var de=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t});var Tt=.5,re={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ee={"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}},ze="6-8",_e=(e,t)=>t!==void 0&&e.band!=="all"&&e.alsoIn?.includes(t)&&t in ee?t:e.band in ee?e.band:ze,zn=ee[ze].head,It=.3,Bt=.12,On=.9,St=.5,Mt=.65,_n=.35,$n=.2,Ln=.25,J=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),$=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),z=(e,t)=>({x:e.x*t,y:e.y*t}),ye=e=>Math.hypot(e.x,e.y),Ct=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Oe=e=>{let t=ye(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},Nn=(...e)=>e.every(Number.isFinite),Hn=e=>Math.atan2(Math.sin(e),Math.cos(e)),Gn=(e,t,n)=>Math.min(Math.max(e,t),n);function Dt(e,t,n=!1){return r=>{let a=e[r*3],o=e[r*3+1],l=e[r*3+2];return a===void 0||o===void 0||l===void 0||!Nn(a,o,l)?{x:0,y:0,ok:!1}:{x:t.x+(n?1-a:a)*t.w,y:t.y+o*t.h,ok:l>=Tt}}}function ke(e,t,n={}){let r=Dt(e,t,n.mirrored),a=r(O.leftShoulder),o=r(O.rightShoulder);if(!a.ok||!o.ok)return null;let l=r(O.leftHip),c=r(O.rightHip),p=Ct(a,o),u=ye(J(o,a)),s=l.ok&&c.ok,f=Oe(J(o,a));u<1e-6&&(f={x:1,y:0});let i,d,y;if(s){let oe=Ct(l,c);d=ye(J(oe,p)),d>=u*Ln?i=Oe(J(oe,p)):(i={x:-f.y,y:f.x},i.y<0&&(i=z(i,-1))),y=Math.max(d,u*1.15)}else i={x:-f.y,y:f.x},i.y<0&&(i=z(i,-1)),y=u*1.15,d=y;y=Math.max(y,1e-6);let h={x:i.y,y:-i.x},m=Math.atan2(h.y,h.x),k=z(i,-1),A=ee[n.band??ze]??ee[ze],E=A.head*y,M=$(p,z(k,E*A.neck)),K=r(O.nose);if(K.ok){let oe=$(K,z(k,E*.15)),ie=z(J(oe,M),_n),W=Math.min(1,E*$n/Math.max(ye(ie),1e-6));M=$(M,z(ie,W))}return{S:p,r:h,d:i,U:y,L:d,hipsOk:s,head:M,headR:E,headRot:m+Fn(e,r,m,y),angle:m}}function Fn(e,t,n,r){let a=[[re.leftEar,re.rightEar],[re.leftEye,re.rightEye]];for(let[o,l]of a){let c=t(o),p=t(l);if(!c.ok||!p.ok||!(e[o*3+2]>=Mt&&e[l*3+2]>=Mt)||ye(J(p,c))<r*.05)continue;let u=Hn(Math.atan2(p.y-c.y,p.x-c.x)-n),s=Math.max(Math.abs(u)-Bt,0),f=Gn((On+St-Math.abs(u))/St,0,1);return Math.sign(u)*Math.min(s,It)*f}return 0}function ge(e,t,n,r={}){let a=_e(t,r.band),o=ee[a],l=ke(e,n,{...r,band:a});if(!l)return[];let c=Dt(e,n,r.mirrored),p=t.palette,{S:u,r:s,d:f,U:i,L:d}=l,y=b=>t.bodyExtras.includes(b),h=Math.max(1.2,i*.045),m={stroke:p.outline,lw:h},k=(b,g)=>({x:u.x+s.x*b+f.x*g,y:u.y+s.y*b+f.y*g}),A=b=>b.map(([g,w])=>k(g,w)),E=c(O.leftShoulder),M=c(O.rightShoulder),K=c(O.leftHip),oe=c(O.rightHip),ie=ye(J(M,E)),W=l.hipsOk?ye(J(oe,K)):ie*.7,x=Math.max(ie/2+o.shoulderPad*i,o.shoulderMin*i),I=Math.max(W/2+o.hipPad*i,o.hipMin*i),P=-.1*i,F=d+o.bottom*i,U=[],C=[],v=[],V=[],he=[],ve=(b,g,w,B)=>{let R=g.flatMap(X=>[X.x,X.y]);b.push({k:"line",pts:R,stroke:p.outline,lw:w+h*2}),b.push({k:"line",pts:R,stroke:B,lw:w})},Ne=o.leg*i*(y("strong-legs")?1.3:1),Te=o.arm*i*(y("tiny-arms")?.6:1),Pe=Math.max(o.arm/.22,.9);if(l.hipsOk)for(let[b,g,w,B]of[[K,O.leftKnee,O.leftAnkle,-1],[oe,O.rightKnee,O.rightAnkle,1]]){let R=c(g),X=c(w);if(!R.ok)continue;let He=$(b,z(f,-.12*i)),le=X.ok?[He,R,X]:[He,R];ve(C,le,Ne,p.limbs),y("joints")&&C.push({k:"circle",x:R.x,y:R.y,r:.15*i*Pe,fill:p.accent,...m}),X.ok&&C.push(...Kn(t,X,l,B,h,o.foot))}for(let[b,g,w,B]of[[E,O.leftElbow,O.leftWrist,-1],[M,O.rightElbow,O.rightWrist,1]]){let R=c(g),X=c(w);if(y("pauldrons")){let ae=$(b,z(f,.02*i));V.push({k:"ellipse",x:ae.x,y:ae.y,rx:.25*i,ry:.17*i,rot:l.angle+B*.25,fill:p.body,...m});let ce=$(ae,z(f,.05*i));V.push({k:"ellipse",x:ce.x,y:ce.y,rx:.17*i,ry:.07*i,rot:l.angle+B*.25,fill:p.belly})}if(!R.ok)continue;let le=o.armsOverHead&&(R.x-u.x)*f.x+(R.y-u.y)*f.y<-.25*i?he:V,Je=$(b,z(f,.04*i));if(ve(le,X.ok?[Je,R,X]:[Je,R],Te,p.limbs),y("joints")&&le.push({k:"circle",x:R.x,y:R.y,r:.13*i*Pe,fill:p.accent,...m}),!X.ok)continue;let ne=Oe(J(X,R)),me=$(X,z(ne,.05*i));if(y("feathers"))for(let ae of[-.55,0,.55]){let ce=Math.cos(ae),Ae=Math.sin(ae)*B,ue={x:ne.x*ce-ne.y*Ae,y:ne.x*Ae+ne.y*ce},Se=$(me,z(ue,.16*i));le.push({k:"ellipse",x:Se.x,y:Se.y,rx:.2*i,ry:.09*i,rot:Math.atan2(ue.y,ue.x),fill:p.hands??p.accent,...m})}y("wand")&&B===1&&!r.portrait&&le.push(...Yn(t,me,Oe($(z(ne,.4),J(z(s,.6),f))),i,h));let Ee=o.hand*i*(y("tiny-arms")?.72:1);if(y("tiny-arms"))for(let ae of[-.45,.45]){let ce=Math.cos(ae),Ae=Math.sin(ae),ue={x:ne.x*ce-ne.y*Ae,y:ne.x*Ae+ne.y*ce},Se=$(me,z(ue,Ee*.75)),tn=$(me,z(ue,Ee*1.6)),et={x:-ue.y*Ee*.32,y:ue.x*Ee*.32};le.push({k:"path",d:D([$(Se,et),tn,J(Se,et)],.2),fill:p.belly,...m})}le.push({k:"circle",x:me.x,y:me.y,r:Ee,fill:p.hands??p.limbs,...m})}if(y("wings"))for(let b of[-1,1]){let g=A([[b*x*.5,.05*i],[b*(x+.85*i),-.6*i],[b*(x+.72*i),.05*i],[b*(x+.45*i),-.02*i],[b*(x+.3*i),.32*i],[b*x*.6,.55*i]]);U.push({k:"path",d:D(g,.18),fill:p.accent,...m})}if(y("wings-fairy")&&U.push(...Qn(t,k,x,i,h)),y("cape")){let b=d+.8*i,g=I+.36*i,w=A([[-x*.92,P+.04*i],[x*.92,P+.04*i],[x+.16*i,d*.5],[g,b],[g*.5,b-.1*i],[0,b],[-g*.5,b-.1*i],[-g,b],[-x-.16*i,d*.5]]);U.push({k:"path",d:T(w,.6),fill:p.accent,...m})}if(y("backpack")){let b=k(0,.35*i);U.push({k:"rect",x:b.x,y:b.y,w:x*2+.34*i,h:.8*i,r:.16*i,rot:l.angle,fill:t.extraColors?.[0]??p.limbs,...m})}if(y("tank")){let b=k(x*.95,.24*i),g=t.extraColors?.[0]??p.accent,w=k(x*.95,-.3*i);U.push({k:"rect",x:w.x,y:w.y,w:.14*i,h:.16*i,r:.04*i,rot:l.angle,fill:p.outline}),U.push({k:"rect",x:b.x,y:b.y,w:.34*i,h:1*i,r:.17*i,rot:l.angle,fill:g,...m})}if(l.hipsOk&&!r.portrait&&U.push(...Xn(t,l,I,h)),y("tentacles")&&l.hipsOk)for(let b of[-1,1]){let g=A([[b*I*.7,d*.9],[b*(I+.22*i),d+.3*i],[b*(I+.48*i),d+.22*i],[b*(I+.5*i),d-.02*i],[b*(I+.34*i),d-.06*i]]);U.push({k:"path",d:xe(g),stroke:p.outline,lw:.2*i+h*2}),U.push({k:"path",d:xe(g),stroke:p.limbs,lw:.2*i})}let Q=Math.max(x,I)*o.bulge;if(y("wool")){for(let[g,w]of[[x*.7,P+.02*i],[Q,d*.3],[Q*1.02,d*.62],[(Q+I)/2,d*.92],[I*.55,F]])for(let B of[-1,1]){let R=k(B*g,w);v.push({k:"circle",x:R.x,y:R.y,r:.2*i,fill:p.body,...m})}let b=k(0,F+.02*i);v.push({k:"circle",x:b.x,y:b.y,r:.2*i,fill:p.body,...m})}if(y("robe")){let b=d+.58*i,g=I*1.4;v.push({k:"path",d:T(A([[-x,P],[0,P-.04*i],[x,P],[Q,d*.55],[g,b],[0,b+.06*i],[-g,b],[-Q,d*.55]]),.7),fill:p.body,...m});let w=A([[-g*.94,b-.1*i],[0,b-.04*i],[g*.94,b-.1*i]]);v.push({k:"path",d:xe(w),stroke:t.extraColors?.[0]??p.accent,lw:.07*i})}else if(y("sheet")){let b=d+.78*i,g=I*1.3;v.push({k:"path",d:T(A([[-x,P],[x,P],[Q,d*.55],[g,b],[g*.5,b-.2*i],[0,b],[-g*.5,b-.2*i],[-g,b],[-Q,d*.55]]),.9),fill:p.body,...m})}else v.push({k:"path",d:T(A([[-x,P],[0,P-.04*i],[x,P],[Q,d*.55],[I,F],[0,F+.03*i],[-I,F],[-Q,d*.55]]),.85),fill:p.body,...m});let te=Math.min(x,I);if(y("pocket")){let b=k(0,d*.74);v.push({k:"rect",x:b.x,y:b.y,w:te*1.3,h:.3*i,r:.1*i,rot:l.angle,fill:p.belly,stroke:p.outline,lw:h*.8})}else if(y("racing-stripe"))for(let b of[-.1,.1]){let g=k(b*i,P+.02*i),w=k(b*i,F-.04*i);v.push({k:"line",pts:[g.x,g.y,w.x,w.y],stroke:p.belly,lw:.1*i})}else if(p.belly&&p.belly!==p.body&&!y("panel")&&!y("sheet")&&!y("stripes")){let b=k(0,d*.58);v.push({k:"ellipse",x:b.x,y:b.y,rx:te*.64,ry:Math.max(d*.36,.2*i),rot:l.angle,fill:p.belly})}if(y("spots")){let b=t.extraColors?.[1]??p.belly;for(let[g,w,B]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){let R=k(g*te,w*d);v.push({k:"circle",x:R.x,y:R.y,r:B*i,fill:b})}}if(y("stripes")){let b=t.extraColors?.[1]??p.accent;for(let g of[.22,.44,.66]){let w=k(-te*.98,d*g),B=k(te*.98,d*g);v.push({k:"line",pts:[w.x,w.y,B.x,B.y],stroke:b,lw:.1*i})}}if(y("straps")){let b=t.extraColors?.[1]??p.outline;for(let g of[-1,1]){let w=k(g*x*.62,P+.02*i),B=k(g*te*.62,d*.72);v.push({k:"line",pts:[w.x,w.y,B.x,B.y],stroke:p.outline,lw:.13*i+h*2}),v.push({k:"line",pts:[w.x,w.y,B.x,B.y],stroke:b,lw:.13*i})}}if(y("belt")){let b=k(0,d*.9);v.push({k:"rect",x:b.x,y:b.y,w:I*1.92,h:.17*i,r:.06*i,rot:l.angle,fill:t.extraColors?.[2]??"#4a3426",...m}),v.push({k:"rect",x:b.x,y:b.y,w:.2*i,h:.19*i,r:.04*i,rot:l.angle,fill:"#ffd84a",...m})}if(y("emblem")){let b=k(0,d*.4),g=t.extraColors?.[0]??p.accent,w=D([{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:b.x,y:b.y,rot:l.angle,s:i,items:[{k:"path",d:w,fill:g,stroke:p.outline,lw:h/i},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:se,fill:g===p.accent?"#ffffff":p.accent}]}]})}if(y("panel")){let b=k(0,d*.5);v.push({k:"rect",x:b.x,y:b.y,w:te*1.2,h:.38*i,r:.1*i,rot:l.angle,fill:"#24323d",...m}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,B)=>{let R=k((B-1)*te*.34,d*.5);v.push({k:"circle",x:R.x,y:R.y,r:.075*i,fill:w})})}if(y("badge")){let b=k(-te*.42,d*.36);v.push({k:"circle",x:b.x,y:b.y,r:.15*i,fill:p.accent,...m}),v.push({k:"group",x:b.x,y:b.y,rot:l.angle,s:.09*i,items:[{k:"path",d:se,fill:"#ffffff"}]})}if(y("star")){let b=k(-te*.5,d*.3),g=.15*i;v.push({k:"group",x:b.x,y:b.y,rot:l.angle-.2,s:g,items:[{k:"path",d:se,fill:t.extraColors?.[0]??"#ffd84a",stroke:p.outline,lw:h*.8/g}]})}if(y("petals")&&v.push(...qn(t,k,x,I,Q,d,F,i,h,o)),y("scarf")){let b=Math.max(.04,o.head*(1-o.neck)-.06)*i,g=k(0,b),w=t.extraColors?.[0]??p.accent,B=k(x*.45,b+.28*i);v.push({k:"rect",x:B.x,y:B.y,w:.16*i,h:.42*i,r:.06*i,rot:l.angle+.15,fill:w,...m}),v.push({k:"rect",x:g.x,y:g.y,w:x*2.05,h:.2*i,r:.1*i,rot:l.angle,fill:w,...m})}let en={k:"group",x:l.head.x,y:l.head.y,rot:l.headRot,s:l.headR,items:Vn(t,h/l.headR)};return[...U,...C,...v,...V,en,...he]}var Rt=new WeakMap,jn=64;function Vn(e,t){let n=Number(t.toPrecision(4)),r=Rt.get(e);r||Rt.set(e,r=new Map);let a=r.get(n);return a||(r.size>=jn&&r.clear(),r.set(n,a=De(e,n))),a}function Kn(e,t,n,r,a,o){let l=Un(e,t,n,r,a,o);if(!e.bodyExtras.includes("strong-legs"))return[l];let c=n.U*o,p=$($(t,z(n.d,.07*c)),z(n.r,r*.06*c)),u=[l];for(let s of[-1,0,1]){let f=$($(p,z(n.r,s*.12*c)),z(n.d,.09*c));u.push({k:"ellipse",x:f.x,y:f.y,rx:.05*c,ry:.045*c,rot:n.angle,fill:e.palette.belly,stroke:e.palette.outline,lw:a*.8})}return u}function Un(e,t,n,r,a,o){let l=e.palette,{d:c,r:p}=n,u=n.U*o,s=$($(t,z(c,.07*u)),z(p,r*.06*u)),f={stroke:l.outline,lw:a},i=l.feet??l.limbs;if(e.bodyExtras.includes("fins")){let 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:n.angle,s:u,items:[{k:"path",d,fill:i,stroke:l.outline,lw:a/u},{k:"line",pts:[0,.06,0,.38],stroke:l.outline,lw:a/u,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:s.x,y:s.y,rx:.27*u,ry:.11*u,rot:n.angle,fill:i,...f}:e.bodyExtras.includes("boots")?{k:"rect",x:s.x,y:s.y,w:.4*u,h:.24*u,r:.09*u,rot:n.angle,fill:i,...f}:{k:"ellipse",x:s.x,y:s.y,rx:.2*u,ry:.13*u,rot:n.angle,fill:i,...f}}function Xn(e,t,n,r){let a=e.palette,{U:o,L:l,S:c,r:p,d:u}=t,s=(h,m)=>({x:c.x+p.x*h+u.x*m,y:c.y+p.y*h+u.y*m}),f=h=>h.map(([m,k])=>s(m,k)),i={stroke:a.outline,lw:r},d=(h,m,k)=>[{k:"path",d:xe(h),stroke:a.outline,lw:m+r*2},{k:"path",d:xe(h),stroke:k,lw:m}],y=[];switch(e.tail){case"none":break;case"fluffy":{let h=f([[n*.5,l*.95],[n+.28*o,l*1],[n+.72*o,l*.62],[n+.78*o,l*.12],[n+.52*o,l*.32],[n+.3*o,l*.6],[n*.6,l*.7]]);y.push({k:"path",d:T(h),fill:a.body,...i});let m=s(n+.72*o,l*.2);y.push({k:"ellipse",x:m.x,y:m.y,rx:.13*o,ry:.2*o,rot:t.angle+.25,fill:a.belly,...i});break}case"brush":{let h=f([[n*.4,l*.98],[n+.42*o,l*1.06],[n+.98*o,l*.66],[n+1.06*o,l*.12],[n+.86*o,-.04*o],[n+.66*o,l*.36],[n+.3*o,l*.66],[n*.5,l*.68]]);y.push({k:"path",d:T(h),fill:a.body,...i});let m=f([[n+1.03*o,l*.36],[n+1.06*o,l*.12],[n+.86*o,-.04*o],[n+.72*o,l*.24],[n+.86*o,l*.34]]);y.push({k:"path",d:T(m),fill:a.belly,...i});break}case"pom":{let h=s(n+.06*o,l*.88);y.push({k:"circle",x:h.x,y:h.y,r:.2*o,fill:a.belly,...i});break}case"long":case"striped":case"tuft":{let h=f([[n*.6,l*.9],[n+.35*o,l*.85],[n+.58*o,l*.4],[n+.5*o,-.02*o]]);if(y.push(...d(h,.14*o,a.body)),e.tail==="tuft"){let m=h[h.length-1];y.push({k:"circle",x:m.x,y:m.y,r:.16*o,fill:e.extraColors?.[0]??a.accent,...i})}if(e.tail==="striped"){for(let k of[.35,.6,.85]){let A=s(n+.35*o+.22999999999999998*o*(k*1.4>1?1:k*1.4),l*(.85-.85*k));y.push({k:"line",pts:[A.x-p.x*.08*o,A.y-p.y*.08*o,A.x+p.x*.08*o,A.y+p.y*.08*o],stroke:e.extraColors?.[0]??a.outline,lw:.06*o})}let m=h[h.length-1];y.push({k:"circle",x:m.x,y:m.y,r:.07*o,fill:e.extraColors?.[0]??a.outline})}break}case"curl":{let h=f([[n*.6,l*.9],[n+.4*o,l*.88],[n+.62*o,l*.45],[n+.5*o,l*.12],[n+.3*o,l*.24],[n+.36*o,l*.42]]);y.push(...d(h,.12*o,a.limbs));break}case"fish":{let h=f([[n*.6,l*.9],[n+.36*o,l*.86],[n+.6*o,l*.5]]);y.push(...d(h,.17*o,a.body));let m=h[h.length-1],k=D([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);y.push({k:"group",x:m.x,y:m.y,rot:t.angle+.35,s:o,items:[{k:"path",d:k,fill:a.body,stroke:a.outline,lw:r/o}]});break}case"plume":{let h=e.extraColors??[a.accent];[0,1,2].forEach(m=>{let k=s(n+(.12+m*.13)*o,l+(.32-m*.06)*o);y.push({k:"ellipse",x:k.x,y:k.y,rx:.11*o,ry:.44*o,rot:t.angle-.55+m*.28,fill:h[(m+1)%h.length],...i})});break}case"thick":{let h=f([[n*.3,l*.42],[n+.42*o,l*.62],[n+.92*o,l*.96],[n+1.32*o,l*1.08],[n+1.44*o,l*.98],[n+.98*o,l*1.2],[n+.4*o,l*1.22],[n*.3,l*1.12]]);y.push({k:"path",d:T(h,.8),fill:a.body,...i});let m=e.extraColors?.[0]??a.accent;for(let[k,A,E]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){let M=s(n+k*o,l*A+.03*o),K=s(n+(k-.1)*o,l*A+E*o);y.push({k:"line",pts:[M.x,M.y,K.x,K.y],stroke:m,lw:.09*o})}break}case"spiky":case"arrow":{let h=f([[n*.3,l*.55],[n+.35*o,l*.68],[n+.95*o,l*.86],[n+.35*o,l*1.08],[n*.3,l*1.08]]);if(e.tail==="spiky"){for(let m of[.15,.45,.72]){let k=n+(.2+m*.7)*o,A=l*(.66+m*.19);y.push({k:"path",d:D(f([[k-.12*o,A+.05*o],[k,A-.2*o],[k+.12*o,A+.07*o]]),.2),fill:a.accent,...i})}y.push({k:"path",d:T(h,.7),fill:a.body,...i})}else{let m=f([[n*.6,l*.9],[n+.4*o,l*.92],[n+.62*o,l*.5],[n+.62*o,l*.18]]);y.push(...d(m,.13*o,a.body));let k=m[m.length-1];y.push({k:"group",x:k.x,y:k.y,rot:t.angle,s:o,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:r/o}]})}break}}return y}function Yn(e,t,n,r,a){let o=e.palette,l=$(t,z(n,-.08*r)),c=$(t,z(n,.52*r)),p=.2*r;return[{k:"line",pts:[l.x,l.y,c.x,c.y],stroke:o.outline,lw:.06*r+a*2},{k:"line",pts:[l.x,l.y,c.x,c.y],stroke:"#fff3d6",lw:.06*r},{k:"circle",x:c.x,y:c.y,r:.24*r,fill:o.accent,alpha:.28},{k:"group",x:c.x,y:c.y,rot:Math.atan2(n.y,n.x)+Math.PI/2,s:p,items:[{k:"path",d:se,fill:o.accent,stroke:o.outline,lw:a*.9/p}]}]}function Qn(e,t,n,r,a){let o=e.palette,l=e.extraColors?.[0]??"#cdeeff",c=[];for(let p of[-1,1]){let u=[[[p*n*.3,.12*r],[p*(n+.42*r),-.66*r],[p*(n+1*r),-.74*r],[p*(n+1.02*r),-.18*r],[p*(n+.5*r),.26*r]],[[p*n*.4,.3*r],[p*(n+.6*r),.36*r],[p*(n+.74*r),.78*r],[p*(n+.3*r),.9*r]]];for(let s of u){let f=T(s.map(([h,m])=>t(h,m)),.9);c.push({k:"path",d:f,fill:l,alpha:.6}),c.push({k:"path",d:f,stroke:o.outline,lw:a*.9});let i=s[Math.floor(s.length/2)],d=t(s[0][0],s[0][1]),y=t(s[0][0]+(i[0]-s[0][0])*.75,s[0][1]+(i[1]-s[0][1])*.75);c.push({k:"line",pts:[d.x,d.y,y.x,y.y],stroke:"#ffffff",lw:a*.9,alpha:.85})}for(let[s,f,i]of[[n+.72*r,-.42*r,.075*r],[n+.44*r,-.16*r,.05*r],[n+.5*r,.6*r,.055*r]]){let d=t(p*s,f);c.push({k:"group",x:d.x,y:d.y,s:i,items:[{k:"path",d:se,fill:"#ffffff"}]})}}return c}function qn(e,t,n,r,a,o,l,c,p,u){let s=e.palette,f=e.extraColors?.[1]??s.belly,i=[],d=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),y=5,h=Math.max(r,a*.92)*1.08,m=(o*.8+l)/2,k=[0,4,1,3,2];for(let E of k){let M=E/(y-1)-.5,K=t(M*2*h,m+(.5-Math.abs(M))*.1*c);i.push({k:"ellipse",x:K.x,y:K.y,rx:h*.3,ry:.34*c,rot:d-M*.6,fill:E%2?f:s.body,stroke:s.outline,lw:p})}let A=Math.max(.04,u.head*(1-u.neck)-.04)*c;for(let E of[-1,1,0]){let M=t(E*n*.32,A+(E?0:.05*c));i.push({k:"ellipse",x:M.x,y:M.y,rx:n*.26,ry:.12*c,rot:d+E*.5,fill:E?f:s.body,stroke:s.outline,lw:p*.9})}return i}var Wn={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 Zn(e,{cx:t=.5,cy:n=.36,T:r=.18}={}){let a={...Wn,...e},o=new Array(je*3).fill(0),l=(u,[s,f],i=.99)=>{o[u*3]=t+s*r,o[u*3+1]=n+f*r,o[u*3+2]=i};for(let u of Object.keys(O))l(O[u],a[u]);let c=a.tilt??0,p=(u,s)=>[a.nose[0]+u*Math.cos(c)-s*Math.sin(c),a.nose[1]+u*Math.sin(c)+s*Math.cos(c)];return l(re.leftEye,p(-.1,-.08)),l(re.rightEye,p(.1,-.08)),l(re.leftEar,p(-.22,-.02)),l(re.rightEar,p(.22,-.02)),o}var zt=()=>Zn({});var Re=class{constructor(t={}){H(this,"tracks",new Map);H(this,"offset",NaN);H(this,"lastArrival",NaN);H(this,"interval",33);H(this,"lastT",NaN);H(this,"lostMs");H(this,"maxExtrapolateMs");this.lostMs=t.lostMs??250,this.maxExtrapolateMs=t.maxExtrapolateMs??25}get delayMs(){return this.interval}push(t,n,r,a=Ot()){Number.isFinite(n)||(n=a),this.clock(n,a);let o=this.tracks.get(t);if(!o||n-o.tb>this.lostMs||n<o.tb-this.lostMs||r.length!==o.b.length){this.tracks.set(t,{a:null,ta:n,b:r,tb:n,out:null,outAt:NaN});return}if(r===o.b||n<=o.tb){n===o.tb&&r!==o.b&&(o.b=r,o.out=null);return}o.a=o.b,o.ta=o.tb,o.b=r,o.tb=n,o.out=null}at(t,n=Ot()){let r=this.tracks.get(t);if(!r)return null;if(!r.a)return r.b;if(r.out&&r.outAt===n)return r.out;let a=n-this.offset-this.interval,o=r.tb-r.ta,l=Math.min(o*.5,this.maxExtrapolateMs),c=Math.min(Math.max((a-r.ta)/o,0),1+l/o);return r.out=_t(r.a,r.b,c),r.outAt=n,r.out}forget(t){this.tracks.delete(t)}clear(){this.tracks.clear()}clock(t,n){let r=n-t;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,(n-this.lastArrival)/1e3)),this.lastArrival=n,Number.isFinite(this.lastT)&&t>this.lastT){let a=t-this.lastT;a<this.interval*3+20&&(this.interval+=(Math.min(Math.max(a,8),100)-this.interval)*.1)}t<=this.lastT||(this.lastT=t)}},Ot=()=>globalThis.performance?.now()??Date.now();function _t(e,t,n){let r=t.slice(),a=n<.5?e:t;for(let o=0;o+2<t.length;o+=3){let l=e[o],c=e[o+1],p=t[o],u=t[o+1];e[o+2]>=.5&&t[o+2]>=.5&&Math.abs(p-l)+Math.abs(u-c)<.15?(r[o]=l+(p-l)*n,r[o+1]=c+(u-c)*n,r[o+2]=e[o+2]+(t[o+2]-e[o+2])*Math.min(n,1)):(r[o]=a[o],r[o+1]=a[o+1],r[o+2]=a[o+2])}return r}var Yr=Ye.map(e=>e.id);var $e=new Map(Ye.map(e=>[e.id,e])),We=$e.get("fox"),Lt=e=>typeof e=="string"&&$e.has(e),Nt=e=>$e.get(e);var Ht=e=>typeof e=="string"?$e.get(e)??We:e;function Gt(e,t,n,r,a={}){let o=ge(t,Ht(n),r,{mirrored:a.mirrored,band:a.band});return o.length?(e.save(),a.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(a.alpha,0),1)),be(e,o),e.restore(),!0):!1}function Ft(e,t,n){let r=Ht(e),a=zt(),o=_e(r,n),l=ke(a,{x:0,y:0,w:1,h:1},{band:o}),c=Vt(De(r,.05)),p=-c.minY,u=Math.min(.27,.43/Math.max(p,1))*t,s=r.head==="snout-long"?(c.minX+c.maxX)/2*u:0,f=u/ee[o].head/l.U,i=.5*t+Math.min(0,(p-1.6)*.06*t),d={x:t/2-s-l.head.x*f,y:i-l.head.y*f,w:f,h:f};return ge(a,r,d,{portrait:!0,band:o})}function jt(e,t,n=.5){if(!e||e.length!==t.length)return t.slice();let r=t.slice();for(let a=0;a+2<t.length;a+=3){let o=e[a+2],l=t[a+2],c=o>=.5,p=l>=.5;c&&l>=.3&&(r[a+2]=Math.max(l,.5));let u=Math.hypot(t[a]-e[a],t[a+1]-e[a+1]);if(c&&p&&u<.15){let s=n*Math.min(1,$t+(1-$t)*u/er);r[a]=e[a]+(t[a]-e[a])*s,r[a+1]=e[a+1]+(t[a+1]-e[a+1])*s}else c&&!p&&r[a+2]>=.5&&(r[a]=e[a],r[a+1]=e[a+1])}return rr(e,t,r,n*tr),r}var $t=.1,er=.03,tr=.35,nr=11;function rr(e,t,n,r){let a=O.leftShoulder*3,o=O.rightShoulder*3,l=(f,i)=>f[i+2]>=.5;if(!l(e,a)||!l(e,o)||!l(t,a)||!l(t,o))return;let c=(f,i)=>(f[a+i]+f[o+i])/2,p=[c(e,0),c(e,1)],u=[c(t,0),c(t,1)],s=[c(n,0),c(n,1)];for(let f=0;f<nr&&f*3+2<t.length;f++){let i=f*3;if(!l(e,i)||!l(t,i))continue;let d=[e[i]-p[0],e[i+1]-p[1]],y=[t[i]-u[0],t[i+1]-u[1]];Math.hypot(y[0]-d[0],y[1]-d[1])>=.15||(n[i]=s[0]+d[0]+(y[0]-d[0])*r,n[i+1]=s[1]+d[1]+(y[1]-d[1])*r)}}function Vt(e){let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},n=(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(let r of e){let a="lw"in r&&r.stroke?(r.lw??1)/2:0;switch(r.k){case"circle":n(r.x-r.r-a,r.y-r.r-a),n(r.x+r.r+a,r.y+r.r+a);break;case"ellipse":case"rect":{let o=r.k==="ellipse"?r.rx:r.w/2,l=r.k==="ellipse"?r.ry:r.h/2,c=Math.max(o,l)+a;n(r.x-c,r.y-c),n(r.x+c,r.y+c);break}case"path":{let o=Qe(r.d);for(let l=0;l+1<o.length;l+=2)n(o[l]-a,o[l+1]-a),n(o[l]+a,o[l+1]+a);break}case"line":for(let o=0;o+1<r.pts.length;o+=2)n(r.pts[o]-a,r.pts[o+1]-a),n(r.pts[o]+a,r.pts[o+1]+a);break;case"group":{let o=Vt(r.items);if(!Number.isFinite(o.minX))break;let l=r.s??1,c=Math.cos(r.rot??0),p=Math.sin(r.rot??0);for(let[u,s]of[[o.minX,o.minY],[o.maxX,o.minY],[o.minX,o.maxY],[o.maxX,o.maxY]])n(r.x+(u*c-s*p)*l,r.y+(u*p+s*c)*l);break}}}return t}var or=()=>{let e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},Kt=()=>globalThis.performance?.now()??Date.now(),we=class{constructor(t=or){H(this,"now",t);H(this,"known",new Map);H(this,"smoothed",new Map);H(this,"times",new WeakMap);H(this,"lerp",new Re);H(this,"drawnAt",NaN);H(this,"drawn",0);H(this,"smoothedBody",(t,n={})=>{let r=n.interpolate!==!1;if(typeof t=="number"){let 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,Ut(n.smooth),r)})}note(t,n,r=Kt()){for(let a of t)this.known.set(a.id,this.resolve(a.id,a.avatar)),n!==void 0&&Number.isFinite(n)&&Array.isArray(a.body)&&this.times.set(a.body,{t:n,arrival:r})}of(t){return typeof t=="object"&&t!==null?t.avatar!==void 0?this.resolve(t.id,t.avatar):this.of(t.id):this.known.get(t)??Ke(t-1)}posed(t,n,r,a=!0){let o=this.smooth(t,n,r);return a?this.lerp.at(t,this.tick())??o:o}smooth(t,n,r){let a=this.smoothed.get(t);if(a&&a.raw===n&&a.amount===r)return a.body;a&&a.amount!==r&&this.lerp.forget(t);let o=r<1?jt(a?.body,n,r):n;this.smoothed.set(t,{raw:n,body:o,amount:r});let l=this.times.get(n),c=l?.arrival??Kt();return this.lerp.push(t,l?.t??c,o,c),o}takeDrawn(){let t=this.drawn;return this.drawn=0,t}tick(){let t=this.now();return t!==this.drawnAt&&(this.drawnAt=t,this.drawn++),t}resolve(t,n){return Lt(n)?n:Ke(t-1)}};function ar(e,t){let n=typeof e.getTransform=="function"?e.getTransform():null,r=n&&Math.hypot(n.a,n.b)||1,a=n&&Math.hypot(n.c,n.d)||1,o=(e.canvas?.width??0)/r,l=(e.canvas?.height??0)/a;return t?{x:t.x*o,y:t.y*l,w:t.w*o,h:t.h*l}:{x:0,y:0,w:o,h:l}}var Ut=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function Le(e,t){return(n,r,a,o,l={})=>{let c=Array.isArray(r)?null:r,p=c?c.body:r;if(!Array.isArray(p))return null;let u=typeof a=="string"?a:e.of(typeof a=="number"?a:c??1),s=typeof a=="number"?a:c?.id,f=s!==void 0?e.posed(s,p,Ut(l.smooth),l.interpolate!==!1):p;return Gt(n,f,u,o??ar(n,t().view),l.alpha!==void 0?{alpha:l.alpha}:{})?f:null}}function Yt(e){let t=new Map,n=(s,f)=>t.get(s)?.forEach(i=>i(f)),r=null,a=null,o=new Map,l=[],c=s=>r?s(r):l.push(s),p=new we,u=Le(p,()=>({view:null}));return e.then(s=>{r=s;let f=new Map;s.on("gesture",i=>n(i.gesture,{player:i.player})),s.on("pause",i=>n("pause",{reason:i.reason==="distance"?"distance":"user"})),s.on("resume",()=>n("resume",{})),s.on("break-start",()=>n("break-start",{})),s.on("break-done",i=>n("break-end",{shown:i.shown})),s.onBackdrop((i,d)=>n("backdrop",{backdrop:i,view:d})),s.on("turn",i=>n("turn",{players:[...i.players]})),s.on("capabilities",i=>n("capabilities",{pictures:i.pictures})),s.on("frame",i=>{n("players",{players:i.players});for(let d of i.players)n("hands",{player:d.id,left:d.leftHand,right:d.rightHand}),f.get(d.id)!==d.shape&&(f.set(d.id,d.shape),n("shape",{player:d.id,shape:d.shape}))}),a=sr(s),n("start",a),l.splice(0).forEach(i=>i(s))}),{on(s,f){let i=t.get(s)??new Set;return t.set(s,i),i.add(f),s==="start"&&a&&f(a),()=>{i.delete(f)}},ready:()=>c(s=>s.ready()),score:(s,f)=>c(i=>{let d=f??Qt(i);o.set(d,s),i.score(d,s)}),break:s=>new Promise(f=>c(i=>{i.break(s).then(f)})),end:s=>c(f=>f.end(typeof s=="number"?ir(f,s,o):s.map(i=>({player:i.player,score:i.score,stars:i.stars??2})))),keys:(s,f)=>c(i=>{st(i,s,f)}),pointer:s=>c(f=>{it(f,s)}),get players(){return r?.players??Xt},get turns(){return r?.turns??Xt},get input(){return r?.input??"body"},get hasPointer(){return r?.pointer??!1},get canSavePicture(){return r?.canSavePicture??!1},savePicture:(s,f)=>new Promise(i=>c(d=>{d.savePicture(s,f).then(i)})),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):Be(null,s),avatarOf:s=>r?r.avatarOf(s):p.of(s),drawAvatar:(...s)=>r?r.drawAvatar(...s):u(...s),smoothedBody:(...s)=>r?r.smoothedBody(...s):p.smoothedBody(...s)}}var Xt=Object.freeze([]),sr=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}),Qt=e=>e.input==="remote"?e.players[0]??1:1;function ir(e,t,n){let r=Qt(e);return e.input!=="remote"?[{player:r,score:t,stars:2}]:[...e.turns.slice(0,Math.max(e.turns.indexOf(r),0)).map(o=>({player:o,score:n.get(o)??0,stars:2})),{player:r,score:t,stars:2}]}var ur=[.85,.7,.55],qt=.75,pr=320;function Wt(e){if(typeof e=="string"){let t=Ie(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"};let{width:t,height:n}=e;if(!(t>0&&n>0))return{error:"error"};let r=e.ownerDocument??document,a=Math.min(1,1920/Math.max(t,n));for(;;){let o=Math.max(1,Math.round(t*a)),l=Math.max(1,Math.round(n*a)),c=r.createElement("canvas");c.width=o,c.height=l;let p=c.getContext("2d");if(!p)return{error:"error"};p.fillStyle="#fff",p.fillRect(0,0,o,l),p.drawImage(e,0,0,o,l);for(let u of ur){let s=c.toDataURL("image/jpeg",u),f=Ie(s);if("ok"in f)return{data:s};if(f.error!=="too-big")return{error:"error"}}if(Math.max(o,l)*qt<pr)return{error:"too-big"};a*=qt}}catch{return{error:"error"}}}var fr=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",n=>n.source===e.parent&&t(n.data))}),dr=1e4,yr=1e3,hr=12e4;function Zt(e=fr(),t={}){return new Promise((n,r)=>{let a=new Map,o=[],l=!1,c=!1,p=!1,u="none",s=null,f="body",i=Object.freeze([]),d=i,y=!1,h=0,m=new Map,k,A=()=>{if(k===void 0){let W=t.cursor!==void 0?t.cursor:typeof document<"u"?lt():null;k=W?ct(W):null}return k},E=new Set,M=new we,K=Le(M,()=>({view:s})),oe=M.smoothedBody,ie=setTimeout(()=>r(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),dr);e.listen(W=>{if(typeof W!="object"||W===null||W.ns!==Ue)return;let x=W;if(x.type==="init"&&!p){if(x.v!==Fe)return clearTimeout(ie),r(new Error(`Fabi Play: protocol ${x.v}, this SDK speaks ${Fe}`));p=!0,clearTimeout(ie),u=x.backdrop==="video"?"video":"none",s=Xe(x.view)??null;let I=yt(x.device)??null;f=x.input==="remote"?"remote":"body";let P=f==="remote"&&x.pointer===!0;y=x.pictures===!0,i=Object.freeze(Array.isArray(x.players)?[...x.players]:[]);let F=f==="remote"&&i.length===1?gt(x.turns):void 0;d=Object.freeze(F&&F[0]===i[0]?F:[...i]);let U={};if(x.stats===!0){let C=performance.now();setInterval(()=>{let V=performance.now();e.post(fe({type:"stats",renderFps:Math.round(M.takeDrawn()*1e3/Math.max(V-C,1)),...U})),C=V},yr).unref?.()}n({locale:x.locale,mode:x.mode,get players(){return i},turns:d,input:f,pointer:P,muted:x.muted,ageRange:x.ageRange??"6-8",get backdrop(){return u},get view(){return s},device:I,reportStats:C=>{U=ht(C)},toScreen:C=>Be(s,C),avatarOf:C=>M.of(C),drawAvatar:K,smoothedBody:oe,onBackdrop(C){return E.add(C),()=>{E.delete(C)}},on(C,v){let V=a.get(C)??new Set;return a.set(C,V),V.add(v),()=>{V.delete(v)}},ready:()=>e.post(fe({type:"ready"})),score:(C,v)=>e.post(fe({type:"score",player:C,score:v})),break:(C="level")=>new Promise(v=>{o.push({reason:C,done:v}),e.post(fe({type:"break",reason:C}))}),end:C=>e.post(fe({type:"end",scores:C})),get canSavePicture(){return y},savePicture:async(C,v)=>{if(!y)return"unavailable";let V=Wt(C);if("error"in V)return V.error;let he=++h,ve=Ge(v?.title);return new Promise(Ne=>{let Te=setTimeout(()=>Pe("error"),hr);Te.unref?.();let Pe=Q=>{clearTimeout(Te),m.delete(he),Ne(Q)};m.set(he,Pe),e.post(fe({type:"picture",data:V.data,id:he,...ve?{title:ve}:{}}))})}})}else if(p){let I=x;if(x.type==="frame"&&Array.isArray(x.players)&&M.note(x.players,x.t),x.type==="backdrop"){if(x.backdrop!=="video"&&x.backdrop!=="none")return;let P=Xe(x.view)??null;if(x.backdrop===u&&mr(P,s))return;u=x.backdrop,s=P,I={type:"backdrop",backdrop:u,...s?{view:s}:{}};for(let F of[...E])F(u,s)}if(x.type==="turn"){let P=f==="remote"&&l&&!c&&o[0]?.reason==="turn"?kt(x.players):void 0,F=i[0];if(!P||F===void 0||d.indexOf(P[0])<=d.indexOf(F))return;c=!0,i=Object.freeze(P),I={type:"turn",players:[...P]}}if(x.type==="picture-result"){let P=bt(x);P?.id!==void 0&&m.get(P.id)?.(P.result);return}if(x.type==="capabilities"){if(typeof x.pictures!="boolean"||x.pictures===y)return;y=x.pictures,I={type:"capabilities",pictures:y}}if(x.type==="cursor"){let P=f==="remote"?mt(x):void 0;if(!P)return;I=P,A()?.update(P)}(x.type==="pause"||x.type==="break-start"||x.type==="turn")&&k?.cancel(),x.type==="break-start"&&(l=o.length>0);for(let P of a.get(x.type)??[])P(I);x.type==="break-done"&&(l=c=!1,o.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;var Ze={};rn(Ze,{BAND_BODY:()=>ee,DEFAULT_AVATAR:()=>We,avatarById:()=>Nt,avatarShapes:()=>ge,drawShapes:()=>be,frameOf:()=>ke,iconShapes:()=>Ft});function Jt(e){let t=Zt(),n=Yt(t);e?.dataset.mute!=="manual"&&ot(t);let r=Object.assign(n,{avatars:{...Ze}});window.FabiPlay=r;let a=e?.dataset.keys;a&&n.keys(at(a));let o=e?.dataset.pointer;return o&&n.pointer({hand:o==="left"||o==="right"?o:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?n.ready():window.addEventListener("load",()=>n.ready(),{once:!0})),r}Jt(document.currentScript);})();
1
+ "use strict";(()=>{var at=Object.defineProperty;var cn=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var un=(e,t)=>{for(var r in t)at(e,r,{get:t[r],enumerable:!0})};var L=(e,t,r)=>cn(e,typeof t!="symbol"?t+"":t,r);function lt(e,t=window){let r=new Set,n=t.AudioContext;n&&(t.AudioContext=class extends n{constructor(...l){super(...l),r.add(this)}});let a=[],o=[];Promise.resolve(e).then(l=>{l.on("break-start",()=>{a=[...t.document.querySelectorAll("audio, video")].filter(c=>!c.paused),a.forEach(c=>c.pause()),o=[...r].filter(c=>c.state==="running"),o.forEach(c=>{c.suspend()})}),l.on("break-done",()=>{a.forEach(c=>{c.play().catch(()=>{})}),o.forEach(c=>{c.resume()}),a=[],o=[]})})}var pn={jump:"Space",squat:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",clap:"Enter"};function ct(e){if(e.trim()==="default")return;let t={};for(let r of e.split(",")){let[n,a]=r.split(":").map(o=>o.trim());n&&a&&(t[n]=a)}return t}var fn={Space:[" ",32],Enter:["Enter",13],Escape:["Escape",27],ShiftLeft:["Shift",16],ArrowLeft:["ArrowLeft",37],ArrowUp:["ArrowUp",38],ArrowRight:["ArrowRight",39],ArrowDown:["ArrowDown",40]};function st(e){let t=fn[e];if(t)return{key:t[0],code:e,keyCode:t[1]};let r=/^Key([A-Z])$/.exec(e);if(r)return{key:r[1].toLowerCase(),code:e,keyCode:r[1].charCodeAt(0)};let n=/^Digit([0-9])$/.exec(e);if(n)return{key:n[1],code:e,keyCode:48+Number(n[1])};throw new Error(`Fabi Play: unknown key "${e}" (use Space, Enter, Arrow\u2026, KeyA\u2026, Digit0\u2026)`)}var dn=(e=document)=>({dispatch(t,r){let n=new KeyboardEvent(t,{key:r.key,code:r.code,bubbles:!0,cancelable:!0});for(let a of["keyCode","which"])Object.defineProperty(n,a,{get:()=>r.keyCode});(e.activeElement??e.body??e).dispatchEvent(n)}}),it=80,yn=800;function ut(e,t=pn,r={}){let n=r.player===void 0&&e.input==="remote",a=r.player??(n?e.players?.[0]??1:1),o=r.target??dn(),l=r.setTimeout??((h,m)=>setTimeout(h,m)),c=new Set,p=0,u=h=>{let m=t[h];!m||c.has(h)||(c.add(h),o.dispatch("keydown",st(m)))},s=h=>{let m=t[h];!m||!c.has(h)||(c.delete(h),o.dispatch("keyup",st(m)))},f=h=>{u(h),l(()=>s(h),it)},i=h=>{if(h.player!==a)return;let m={"lane-left":-1,"lane-center":0,"lane-right":1};switch(h.gesture){case"jump":u("jump"),l(()=>s("jump"),yn);break;case"land":s("jump");break;case"squat":u("squat");break;case"stand":s("squat");break;case"clap":f("clap");break;default:{let x=m[h.gesture];if(x===void 0)break;let S=x>p?"right":"left";for(let A=0;A<Math.abs(x-p);A++)l(()=>f(S),A*(it*2));p=x}}},d=h=>{let m=h.players.find(x=>x.id===a);m&&(m.shape==="arms-up"?u("arms-up"):s("arms-up"))},y=[e.on("gesture",i),e.on("frame",d),e.on("break-start",()=>[...c].forEach(s)),e.on("turn",h=>{n&&([...c].forEach(s),a=h.players[0]??a,p=0)})];return()=>{y.forEach(h=>h()),[...c].forEach(s)}}function hn(e=document){let 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);let r=(n,a,...o)=>{let l=e.elementFromPoint(n,a)??e.body;for(let c of o){let p={bubbles:!0,cancelable:!0,clientX:n,clientY:a,pointerId:1,pointerType:"touch",isPrimary:!0};l.dispatchEvent(c.startsWith("pointer")?new PointerEvent(c,p):new MouseEvent(c,p))}};return{size:()=>({width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}),move:(n,a)=>r(n,a,"pointermove","mousemove"),click:(n,a)=>r(n,a,"pointerdown","mousedown","pointerup","mouseup","click"),cursor:(n,a,o)=>{t.style.transform=`translate(${n}px, ${a}px) scale(${1-o*.35})`,t.style.borderColor=o>0?"#EE6A43":"#FBE7B8"}}}function pt(e,t={}){let r=t.player??1,n=t.hand??"any",a=t.dwellMs??800,o=t.radius??.04,l=t.target??hn(),c=null,p=!1;return e.on("frame",u=>{let s=u.players.find(A=>A.id===r);if(!s)return;let i=n==="left"?s.leftHand:n==="right"?s.rightHand:((A,R)=>A&&R?A.y<R.y?A:R:A??R)(s.leftHand,s.rightHand);if(!i)return;let{width:d,height:y}=l.size(),h=i.x*d,m=i.y*y;l.move(h,m),(!c||Math.hypot(h-c.x,m-c.y)>o*Math.hypot(d,y))&&(c={x:h,y:m,t:u.t},p=!1);let S=p?0:Math.min((u.t-c.t)/a,1);S>=1&&(p=!0,l.click(c.x,c.y)),l.cursor(h,m,p?0:S)})}function ft(e=document){let t=e.defaultView,r=t?.PointerEvent,n=t?.MouseEvent??MouseEvent,a=null,o=null,l=(c,p,u,s,f,i=null)=>{let d={bubbles:!0,cancelable:!0,composed:!0,view:t,clientX:u,clientY:s,screenX:u,screenY:s,button:0,buttons:f,relatedTarget:i,pointerId:1,pointerType:"mouse",isPrimary:!0};p.startsWith("pointer")?r&&c.dispatchEvent(new r(p,d)):c.dispatchEvent(new n(p,d))};return{size:()=>({width:t?.innerWidth??e.documentElement.clientWidth,height:t?.innerHeight??e.documentElement.clientHeight}),dispatch(c,p,u,s){let f=e.elementFromPoint(p,u)??e.body??e.documentElement;if(c==="pointermove"&&f!==a){if(a?.isConnected)for(let i of["pointerout","mouseout"])l(a,i,p,u,s,f);for(let i of["pointerover","mouseover"])l(f,i,p,u,s,a);a=f}if(c==="pointerdown"&&(o=f),c==="click"){let i=o===f;if(o=null,!i)return}l(f,c,p,u,s)}}}function dt(e){let t=null,r=(n,a,o,l)=>{let{width:c,height:p}=e.size();for(let u of n)e.dispatch(u,a*c,o*p,l)};return{update(n){let a=t?.down??!1;(!t||t.x!==n.x||t.y!==n.y)&&r(["pointermove","mousemove"],n.x,n.y,a?1:0),n.down&&!a&&r(["pointerdown","mousedown"],n.x,n.y,1),!n.down&&a&&r(["pointerup","mouseup","click"],n.x,n.y,0),t={x:n.x,y:n.y,down:n.down}},cancel(){t?.down&&(r(["pointercancel","mouseup"],t.x,t.y,0),t={...t,down:!1})}}}var yt=["sent","unavailable","too-big","error"],mn=/^[A-Za-z0-9+/]*={0,2}$/,bn={"image/jpeg":"/9j/","image/png":"iVBORw0KGg"},xn=/^data:(image\/(?:jpeg|png));base64,/,gn=e=>e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0),kn=Math.ceil(3145728/3)*4,wn=(e,t)=>t.length%4===0&&t.length>0&&t.startsWith(bn[e])&&mn.test(t);function ze(e){if(typeof e!="string")return{error:"invalid"};let t=xn.exec(e);if(!t)return{error:"invalid"};let r=t[1],n=e.slice(t[0].length);if(n.length>kn)return{error:"too-big"};if(!wn(r,n))return{error:"invalid"};let a=gn(n);return a>3145728?{error:"too-big"}:{ok:{mime:r,base64:n,size:a}}}function Ke(e){return typeof e!="string"?void 0:Array.from(e.replace(/[\p{Cc}\p{Cf}]/gu,"").trim()).slice(0,60).join("").trim()||void 0}var Ue=1,Xe=33,v={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},mt=["3-5","6-8","9-12"],vn=e=>mt.includes(e);var Ye=4;var bt={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},An=bt["6-8"],Qe=(e,t)=>{let r=vn(t)?bt[t]:An;return r[Number.isInteger(e)&&e>=0?e%r.length:0]};var We="fabi-play",de=e=>({ns:We,...e});function qe(e){if(!ke(e))return;let{x:t,y:r,w:n,h:a}=e;return Z(t)&&Z(r)&&Z(n)&&Z(a)&&n>0&&a>0?{x:t,y:r,w:n,h:a}:void 0}var Be=(e,t)=>e?{x:e.x+t.x*e.w,y:e.y+t.y*e.h}:{x:t.x,y:t.y},En=.5,_e={left:1.6,top:1.6,w:3.2,h:3},Pn=1.2;function xt(e,t,r={}){let n=Array.isArray(e)?e:e.body;if(!Array.isArray(n))return null;let a=t==="left"?v.leftWrist:v.rightWrist,o=x=>Z(n[x*3])&&Z(n[x*3+1])&&(n[x*3+2]??0)>=En?x:-1;if(o(a)<0)return null;let l=n[a*3],c=n[a*3+1];if(r.orientation!=="portrait")return Be(r.view,{x:l,y:c});if(o(v.leftShoulder)<0||o(v.rightShoulder)<0)return null;let p=v.leftShoulder*3,u=v.rightShoulder*3,s=(n[p]+n[u])/2,f=(n[p+1]+n[u+1])/2,i=v.leftHip*3,d=v.rightHip*3,y=(n[i]+n[d])/2,h=(n[i+1]+n[d+1])/2,m=Z(y)&&Z(h)?Math.hypot(y-s,h-f):0;return(o(v.leftHip)<0||o(v.rightHip)<0)&&(m=Math.max(m,Pn*Math.hypot(n[p]-n[u],n[p+1]-n[u+1]))),m=Math.max(m,.01),{x:ht((l-s+_e.left*m)/(_e.w*m)),y:ht((c-f+_e.top*m)/(_e.h*m))}}var Sn=300,Ie=class{constructor(t=Sn){L(this,"holdMs",t);L(this,"last",new Map)}static key(t,r){return t*2+(r==="right"?1:0)}at(t,r,n){let a=this.last.get(t);return r?(a?(a.x=r.x,a.y=r.y,a.t=n):this.last.set(t,{x:r.x,y:r.y,t:n}),r):a?n-a.t<=this.holdMs?{x:a.x,y:a.y}:(this.last.delete(t),null):null}clear(){this.last.clear()}},Mn=.25,$e=Object.freeze({top:0,bottom:0,left:0,right:0});function gt(e){if(!ke(e))return;let t=r=>Z(r)?Math.min(Math.max(r,0),Mn):0;return{top:t(e.top),bottom:t(e.bottom),left:t(e.left),right:t(e.right)}}var kt=["high","medium","low"];function wt(e){if(!ke(e))return;let t={};return kt.includes(e.tier)&&(t.tier=e.tier),Z(e.hz)&&e.hz>=20&&e.hz<=240&&(t.hz=Math.round(e.hz)),t.tier||t.hz?t:void 0}function vt(e){let t={};return ke(e)&&(Z(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),kt.includes(e.tier)&&(t.tier=e.tier)),t}function At(e){if(!ke(e)||!Z(e.x)||!Z(e.y)||typeof e.down!="boolean")return;let t=r=>Math.min(Math.max(r,0),1);return{type:"cursor",x:t(e.x),y:t(e.y),down:e.down}}function Et(e){if(!(!ke(e)||!yt.includes(e.result)))return{type:"picture-result",...Number.isInteger(e.id)?{id:e.id}:{},result:e.result}}var Pt=e=>Number.isInteger(e)&&e>=1&&e<=Ye;function St(e){return Array.isArray(e)&&e.length===1&&Pt(e[0])?[e[0]]:void 0}function Mt(e){if(!(!Array.isArray(e)||e.length<1||e.length>Ye||!e.every(Pt)||new Set(e).size!==e.length))return[...e]}var Dr=16/9;var ke=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Z=e=>typeof e=="number"&&Number.isFinite(e),ht=e=>Math.min(Math.max(e,0),1);var Cn=12,Rn=Xe*4,Tn=e=>Cn+e*Rn,zr=Tn(Ye);var J="#4a382c",Y="#2b2118",ee="#1c1f2b",Ct="#fbefe3",re="#f4897a",Oe="#3a2a22",Ze=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:Ct,accent:"#ffd9c2",outline:Y,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:Oe,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:Ct,accent:"#5a3426",outline:Y,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:Oe,muzzle:"band",cheeks:re},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:J},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:re},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:J},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:Oe,muzzle:"oval",cheeks:re},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:J,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:re},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:J,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:J,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:J},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:Y},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:re},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:Y,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:Y},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:Y},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:Y,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:re},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:J},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:Y},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:re},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:J,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:J,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:Y},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:Y,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:J,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:re},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:J,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:Oe,muzzle:"oval",cheeks:re},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:J,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:re},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:J,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:re},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:Y,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:Y,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:Oe,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:Y,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:Y,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:Y},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:Y,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"]}];var F={M:0,L:1,Q:2,C:3,Z:4},Rt=[2,2,4,6,0];function we(e,t){for(let r of t)In(e,r)}function In(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),we(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":Bn(e,t);break;case"path":typeof t.d=="string"?Dn(e,t.d):On(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 Bn(e,t){let 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);let n=-t.w/2,a=-t.h/2;e.moveTo(n+r,a),e.lineTo(n+t.w-r,a),e.quadraticCurveTo(n+t.w,a,n+t.w,a+r),e.lineTo(n+t.w,a+t.h-r),e.quadraticCurveTo(n+t.w,a+t.h,n+t.w-r,a+t.h),e.lineTo(n+r,a+t.h),e.quadraticCurveTo(n,a+t.h,n,a+t.h-r),e.lineTo(n,a+r),e.quadraticCurveTo(n,a,n+r,a),e.closePath()}function On(e,t){for(let r=0;r<t.length;){let n=t[r++];if(n===F.M)e.moveTo(t[r],t[r+1]);else if(n===F.L)e.lineTo(t[r],t[r+1]);else if(n===F.Q)e.quadraticCurveTo(t[r],t[r+1],t[r+2],t[r+3]);else if(n===F.C)e.bezierCurveTo(t[r],t[r+1],t[r+2],t[r+3],t[r+4],t[r+5]);else if(n===F.Z)e.closePath();else return;r+=Rt[n]}}function Je(e){if(typeof e=="string")return(e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);let t=[];for(let r=0;r<e.length;){let n=Rt[e[r++]];if(n===void 0)break;for(let a=0;a<n;a++)t.push(e[r+a]);r+=n}return t}function Dn(e,t){let r=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[],n="",a=0,o=()=>Number(r[a++]);for(;a<r.length;){let l=r[a];if(/[MLQCZ]/i.test(l)&&(n=l.toUpperCase(),a++,n==="Z")){e.closePath();continue}n==="M"?(e.moveTo(o(),o()),n="L"):n==="L"?e.lineTo(o(),o()):n==="Q"?e.quadraticCurveTo(o(),o(),o(),o()):n==="C"?e.bezierCurveTo(o(),o(),o(),o(),o(),o()):a++}}var _=e=>{let t=Math.round(e*100)/100;return t===0?0:t};function D(e,t=.5){let r=e.length;if(r<3)return[];let n=(c,p,u)=>({x:c.x+(p.x-c.x)*u,y:c.y+(p.y-c.y)*u}),a=Math.min(Math.max(t,0),.5),o=n(e[0],e[1],a),l=[F.M,_(o.x),_(o.y)];for(let c=1;c<=r;c++){let p=e[(c-1)%r],u=e[c%r],s=e[(c+1)%r],f=n(p,u,1-a),i=n(u,s,a);l.push(F.L,_(f.x),_(f.y),F.Q,_(u.x),_(u.y),_(i.x),_(i.y))}return l.push(F.Z),l}function I(e,t=1){let r=e.length;if(r<3)return[];let n=[F.M,_(e[0].x),_(e[0].y)],a=t/6;for(let o=0;o<r;o++){let l=e[(o-1+r)%r],c=e[o],p=e[(o+1)%r],u=e[(o+2)%r];n.push(F.C,_(c.x+(p.x-l.x)*a),_(c.y+(p.y-l.y)*a),_(p.x-(u.x-c.x)*a),_(p.y-(u.y-c.y)*a),_(p.x),_(p.y))}return n.push(F.Z),n}function ve(e){let t=e.length;if(t<2)return[];let r=[F.M,_(e[0].x),_(e[0].y)];for(let n=0;n<t-1;n++){let a=e[Math.max(n-1,0)],o=e[n],l=e[n+1],c=e[Math.min(n+2,t-1)];r.push(F.C,_(o.x+(l.x-a.x)/6),_(o.y+(l.y-a.y)/6),_(l.x-(c.x-o.x)/6),_(l.y-(c.y-o.y)/6),_(l.x),_(l.y))}return r}var ce="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";var K="#ffffff",C=[-1,1],Tt="#3a2420",It="#f2808f",et="#26324a",zn="#ffd84a",G=(...e)=>{let t=[];for(let r=0;r+1<e.length;r+=2)t.push({x:e[r],y:e[r+1]});return t};function Le(e,t){let r=e.palette,n=[],a={stroke:r.outline,lw:t},o=s=>e.headExtras.includes(s),l=(s,f)=>e.extraColors?.[s]??f;if(o("mane")){for(let f=0;f<12;f++){let i=f/12*Math.PI*2;n.push({k:"circle",x:Math.cos(i)*1.02,y:Math.sin(i)*1+.04,r:.42,fill:l(0,r.accent),...a})}n.push({k:"circle",x:0,y:.04,r:1.08,fill:l(0,r.accent)})}if(o("rainbow-mane")){let s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([i,d,y,h,m],x)=>n.push({k:"ellipse",x:i,y:d,rx:y,ry:h,rot:m,fill:s[x%s.length],...a}))}if(o("spikes"))for(let s of[-.55,0,.55]){let f=ye(s,1.48),i=ye(s-.32,.86),d=ye(s+.32,.86);n.push({k:"path",d:D([i,f,d],.22),fill:r.accent,...a})}if(o("curl")&&n.push({k:"path",d:I([{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}),o("wool"))for(let s=0;s<=8;s++){let f=-1.75+s/8*3.5;n.push({k:"circle",x:Math.sin(f)*.98,y:-Math.cos(f)*.92-.04,r:.34,fill:r.body,...a})}if(o("crest")&&[-.38,0,.38].forEach((s,f)=>{let i=ye(s,1.12);n.push({k:"ellipse",x:i.x,y:i.y,rx:.15,ry:.42,rot:s,fill:l(f,r.accent),...a})}),o("plume")&&n.push({k:"path",d:I(G(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:r.accent,...a}),o("locks")&&n.push({k:"path",d:I(G(-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}),o("bun")&&n.push({k:"circle",x:.04,y:-1.14,r:.4,fill:r.hair??r.outline,...a}),o("ninja-hood"))for(let[s,f]of[[.35,.5],[.85,.42]])n.push({k:"ellipse",x:1+Math.cos(s)*f*.8,y:-.5+Math.sin(s)*f*.8,rx:f,ry:.11,rot:s,fill:r.accent,...a});if(o("bandana"))for(let[s,f]of[[Math.PI-.5,.42],[Math.PI-1,.36]])n.push({k:"ellipse",x:-.98+Math.cos(s)*f*.8,y:-.36+Math.sin(s)*f*.8,rx:f,ry:.12,rot:s,fill:r.accent,...a});if(o("ruff"))for(let s of C)n.push({k:"path",d:D(G(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(let s of C)n.push({k:"circle",x:s*.46,y:-.72,r:.38,fill:r.body,...a});n.push(...Fn(e,t)),n.push(_n(e,a));let c=e.face.muzzle,p=r.belly;if(c==="oval"&&n.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:p}),c==="monkey"){for(let s of C)n.push({k:"circle",x:s*.32,y:-.04,r:.38,fill:p});n.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:p})}if(c==="heart"){for(let s of C)n.push({k:"circle",x:s*.36,y:.02,r:.5,fill:p});n.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:p})}if(c==="disc")for(let s of C)n.push({k:"circle",x:s*.4,y:.02,r:.44,fill:p});if(c==="cheeks")for(let s of C)n.push({k:"ellipse",x:s*.4,y:.44,rx:.44,ry:.32,fill:p});if(c==="band"&&n.push({k:"path",d:Nn(e,t),fill:p}),o("stripes")&&e.head==="snout-long"){let s=l(0,r.outline);for(let[f,i,d,y]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])n.push({k:"line",pts:[f,i,d,y],stroke:s,lw:.11})}else if(o("stripes")){let s=l(0,r.outline);n.push({k:"line",pts:[0,-.97,0,-.66],stroke:s,lw:.13});for(let f of C)n.push({k:"line",pts:[f*.3,-.93,f*.24,-.7],stroke:s,lw:.1}),n.push({k:"line",pts:[f*.98,-.05,f*.74,0],stroke:s,lw:.1}),n.push({k:"line",pts:[f*.94,.22,f*.74,.22],stroke:s,lw:.09})}if(o("spots")){let s=l(1,r.belly);n.push({k:"circle",x:-.55,y:-.5,r:.15,fill:s}),n.push({k:"circle",x:.58,y:-.42,r:.11,fill:s}),n.push({k:"circle",x:.22,y:-.76,r:.09,fill:s})}if(e.head==="snout-long")for(let[s,f,i]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])n.push({k:"ellipse",x:s,y:f,rx:i,ry:i*.8,rot:-.3,fill:r.outline,alpha:.85});if(o("forehead")&&n.push({k:"path",d:I(G(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:l(0,r.accent)}),o("eye-spot")&&n.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:r.ears??r.accent}),o("gills"))for(let s of C)for(let f of[0,.12,.24])n.push({k:"path",d:`M${s*(.66+f)} 0.06 Q${s*(.6+f)} 0.22 ${s*(.66+f)} 0.38`,stroke:r.accent,lw:t*.9});let u=r.hair??r.outline;if(o("hair")&&n.push({k:"path",d:I(G(-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:u,...a}),o("locks")&&n.push({k:"path",d:I(G(-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:u,...a}),o("bun")&&n.push({k:"path",d:I(G(-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:u,...a}),o("curls")){for(let s=0;s<7;s++){let f=ye(-1.3+s/6*2.6,.86);n.push({k:"circle",x:f.x,y:f.y,r:.3,fill:u,...a})}n.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:u})}if(o("ninja-hood")&&(n.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:r.skin??K,stroke:r.outline,lw:t*.8}),n.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})),o("domino")){n.push({k:"path",d:I(G(-.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(let s of C)n.push({k:"ellipse",x:s*.38,y:0,rx:.19,ry:.13,fill:K})}if(n.push(...Gn(e,t)),o("brows"))for(let s of C)n.push({k:"line",pts:[s*.72,-.5,s*.14,-.3],stroke:r.accent,lw:.16});if(e.face.brows)for(let s of C)n.push({k:"line",pts:[s*.2,-.2,s*.54,-.28],stroke:e.face.brows,lw:.09});if(n.push(...jn(e,t)),e.face.cheeks)for(let s of Ln(e))n.push({k:"ellipse",x:s.x,y:s.y,rx:.15,ry:.1,fill:e.face.cheeks,alpha:.8});if(o("whiskers"))for(let s of C)for(let f of[-.1,.06])n.push({k:"line",pts:[s*.62,.38+f,s*1.06,.3+f*2.2],stroke:r.outline,lw:t*.7,alpha:.75});if(o("rainbow-mane")){let s=e.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];n.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:s[0],...a}),n.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:s[1%s.length],...a})}if(e.ears==="unicorn"){let s=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];n.push({k:"path",d:D(s,.12),fill:r.accent,...a});for(let f of[-1,-1.2,-1.4]){let i=.16*((f+1.72)/.88);n.push({k:"line",pts:[-i,f+.04,i,f-.04],stroke:r.outline,lw:t*.7,alpha:.6})}}if(o("flower-crown")){let s=[l(1,"#f7a8cf"),l(2,"#fff3a0"),l(3,K)];for(let f of[-.84,-.28,.28,.84]){let i=ye(f,.9);n.push({k:"ellipse",x:i.x,y:i.y,rx:.14,ry:.07,rot:f+.5,fill:"#7cc76a",stroke:r.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((f,i)=>{let d=ye(f,.9),y=i===2?.13:.11;for(let h=0;h<5;h++){let m=f+h/5*Math.PI*2;n.push({k:"circle",x:d.x+Math.sin(m)*y,y:d.y-Math.cos(m)*y,r:y*.82,fill:s[i%s.length],stroke:r.outline,lw:t*.7})}n.push({k:"circle",x:d.x,y:d.y,r:y*.62,fill:s[i%s.length]}),n.push({k:"circle",x:d.x,y:d.y,r:y*.42,fill:r.accent})})}if(o("helmet")){for(let s of C)n.push({k:"rect",x:s*1,y:.05,w:.26,h:.56,r:.12,fill:r.accent,...a});n.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:K,lw:.1,alpha:.9})}if(o("bolts"))for(let s of C)n.push({k:"rect",x:s*1.08,y:.08,w:.2,h:.44,r:.08,fill:r.accent,...a});if(o("tuft")&&n.push({k:"path",d:I([{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}),o("eggshell")&&n.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:l(0,K),...a}),o("wool"))for(let[s,f]of[[-.36,-.84],[.02,-.94],[.4,-.82]])n.push({k:"circle",x:s,y:f,r:.27,fill:r.body,...a});if(o("stripe")&&n.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:r.accent}),o("eye-patch")&&(n.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:r.outline,lw:.07}),n.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:r.outline})),o("bandana")){n.push({k:"path",d:I(G(-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(let[s,f]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])n.push({k:"circle",x:s,y:f,r:.06,fill:K,alpha:.85});n.push({k:"circle",x:-.98,y:-.34,r:.15,fill:r.accent,...a})}if(o("cap")){for(let s of C)n.push({k:"line",pts:[s*.98,-.2,s*.5,.82,-s*.05,.98],stroke:r.outline,lw:.06});n.push({k:"path",d:I(G(-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}),n.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}),n.push({k:"circle",x:.5,y:-.82,r:.15,fill:l(0,K),...a});for(let s of[-.42,-.14])n.push({k:"line",pts:[s,-1.04,s+.02,-.78],stroke:r.outline,lw:.07,alpha:.7})}if(o("safari-hat")&&(n.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:r.accent,...a}),n.push({k:"path",d:I(G(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:r.accent,...a}),n.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:l(1,r.outline),stroke:r.outline,lw:t*.8})),o("wizard-hat")){n.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:r.accent,...a}),n.push({k:"path",d:D(G(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:r.accent,...a});let s=l(0,zn);for(let[f,i,d]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])n.push({k:"group",x:f,y:i,s:d,items:[{k:"path",d:ce,fill:s}]})}if(o("dive-mask")){for(let f of C)n.push({k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:r.outline,lw:.2},{k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:r.accent,lw:.11});n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:r.outline,lw:.2}),n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:r.accent,lw:.11}),n.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:K,lw:.06,alpha:.9});let s="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";n.push({k:"path",d:s,stroke:r.outline,lw:.24},{k:"path",d:s,stroke:r.accent,lw:.13})}return n}function _n(e,t){let 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(G(-.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:I($n,.95),fill:r,...t};case"bulb":return{k:"path",d:I([{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 $n=G(.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 Bt(e,t,r){return e.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:C.map(n=>({x:n*t,y:r,k:1}))}function Ln(e){return e.head==="snout-long"?G(-.66,-.14,.66,.1):C.map(t=>({x:t*.64,y:.3}))}function Hn(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 Nn(e,t){let{cy:r,rx:n,ry:a}=Hn(e),o=n-t/2,l=a-t/2,c=.15,p=Math.asin(Math.min(1,(c-r)/l)),u=Math.cos(p)*o,s=y=>Math.round(y*100)/100||0,f=[F.M,s(-u),c],i=[[-.84*u,.02,-.53*u,.06,-.32*u,.24],[-.17*u,.11,.17*u,.11,.32*u,.24],[.53*u,.06,.84*u,.02,u,c]];for(let y of i)f.push(F.C,...y.map(s));let d=24;for(let y=1;y<=d;y++){let h=p+(Math.PI-2*p)*y/d;f.push(F.L,s(Math.cos(h)*o),s(r+Math.sin(h)*l))}return f.push(F.Z),f}function Fn(e,t){let r=e.palette,n={stroke:r.outline,lw:t},a=[];for(let o of C)switch(e.ears){case"pointy":case"unicorn":{let l=e.ears==="unicorn"?.8:1,c={x:o*.3,y:-.82},p={x:o*.86,y:-.82-.62*l},u={x:o*.94,y:-.36};a.push({k:"path",d:D([c,p,u],.2),fill:r.body,...n});let s={x:(c.x+p.x+u.x)/3,y:(c.y+p.y+u.y)/3},f=[c,p,u].map(i=>({x:s.x+(i.x-s.x)*.55,y:s.y+(i.y-s.y)*.55+.04}));a.push({k:"path",d:D(f,.25),fill:r.accent});break}case"round":a.push({k:"circle",x:o*.72,y:-.72,r:.36,fill:r.ears??r.body,...n}),r.ears||a.push({k:"circle",x:o*.74,y:-.74,r:.19,fill:r.accent});break;case"big-round":a.push({k:"circle",x:o*.96,y:-.46,r:.52,fill:r.body,...n}),a.push({k:"circle",x:o*1,y:-.44,r:.32,fill:r.accent});break;case"long":a.push({k:"ellipse",x:o*.38,y:-1.42,rx:.25,ry:.68,rot:o*.14,fill:r.body,...n}),a.push({k:"ellipse",x:o*.39,y:-1.36,rx:.12,ry:.48,rot:o*.14,fill:r.accent});break;case"side":a.push({k:"circle",x:o*1,y:.02,r:.34,fill:r.body,...n}),a.push({k:"circle",x:o*1.02,y:.02,r:.2,fill:r.belly});break;case"tufts":a.push({k:"path",d:D([{x:o*.3,y:-.84},{x:o*1.22,y:-1.12},{x:o*.92,y:-.42}],.16),fill:r.body,...n}),a.push({k:"line",pts:[o*.62,-.78,o*1,-.98],stroke:r.accent,lw:.08});break;case"antennae":{let l={x:o*.62,y:-1.42};a.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${l.x} ${l.y}`,stroke:r.outline,lw:t*2.6}),a.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${l.x} ${l.y}`,stroke:r.body,lw:t*1.2}),a.push({k:"circle",x:l.x,y:l.y,r:.17,fill:r.accent,...n});break}case"floppy":a.push({k:"ellipse",x:o*.96,y:.02,rx:.3,ry:.62,rot:-o*.36,fill:r.ears??r.body,...n});break;case"droopy":a.push({k:"ellipse",x:o*1.04,y:-.22,rx:.4,ry:.18,rot:o*.32,fill:r.skin??r.body,...n}),a.push({k:"ellipse",x:o*1.08,y:-.2,rx:.24,ry:.08,rot:o*.32,fill:r.accent});break;case"pixie":a.push({k:"path",d:D(G(o*.86,-.22,o*1.36,-.5,o*1.02,.26),.28),fill:r.skin??r.body,...n}),a.push({k:"line",pts:[o*.98,-.12,o*1.16,-.3],stroke:r.accent,lw:t*.8,alpha:.5});break;case"human":a.push({k:"ellipse",x:o*.98,y:.06,rx:.17,ry:.23,fill:r.skin??r.body,...n});break;case"horns":{let l=[{x:o*.3,y:-.84},{x:o*.6,y:-1.5},{x:o*.66,y:-.68}];a.push({k:"path",d:D(l,.18),fill:r.accent,...n});break}}return e.ears==="fin"&&a.push({k:"path",d:D(G(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:r.body,...n}),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,...n})),a}function Gn(e,t){let r=e.palette,n=e.face,a=[],o=r.outline,l=n.eyesOnTop?.46:.4,c=n.eyesOnTop?-.72:-.04,p=(u,s,f)=>({k:"circle",x:u,y:s,r:f,fill:K});switch(n.eyes){case"dot":for(let u of Bt(e,l,c))a.push({k:"ellipse",x:u.x,y:u.y,rx:.12*u.k,ry:.155*u.k,fill:o}),a.push(p(u.x+.04*u.k,u.y-.06*u.k,.045*u.k));break;case"bead":for(let u of Bt(e,l,c))a.push({k:"ellipse",x:u.x,y:u.y,rx:.16*u.k,ry:.22*u.k,fill:o}),a.push(p(u.x+.05*u.k,u.y-.08*u.k,.065*u.k));break;case"big":for(let u of C)n.eyeRing&&a.push({k:"circle",x:u*l,y:c,r:.36,fill:n.eyeRing,stroke:o,lw:t*.8}),a.push({k:"circle",x:u*l,y:c,r:.25,fill:K,stroke:o,lw:t*.8}),a.push({k:"circle",x:u*l+u*-.03,y:c+.03,r:.14,fill:n.eyeColor??o}),a.push(p(u*l+u*-.03+.05,c-.03,.05));break;case"mask":for(let u of C)a.push({k:"ellipse",x:u*.4,y:0,rx:.24,ry:.32,rot:u*-.55,fill:r.limbs}),a.push({k:"circle",x:u*.4,y:-.02,r:.11,fill:K}),a.push({k:"circle",x:u*.39,y:-0,r:.065,fill:o});break;case"screen":a.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:o,lw:t*.8});for(let u of C)a.push({k:"ellipse",x:u*.36,y:0,rx:.2,ry:.24,fill:n.eyeColor??"#7ff0ff",alpha:.3}),a.push({k:"ellipse",x:u*.36,y:0,rx:.12,ry:.16,fill:n.eyeColor??"#7ff0ff"});break;case"almond":for(let u of C)a.push({k:"ellipse",x:u*.42,y:-.02,rx:.3,ry:.2,rot:-u*.5,fill:n.eyeColor??o}),a.push(p(u*.42-u*.07,-.08,.07));break;case"calm":for(let u of C)a.push({k:"ellipse",x:u*.38,y:.02,rx:.085,ry:.12,fill:o}),a.push(p(u*.38+.03,-.02,.03));break;case"slit":a.push({k:"line",pts:[0,-.98,0,-.2],stroke:o,lw:t*.8,alpha:.5}),a.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:et,stroke:o,lw:t*.8}),a.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:et,stroke:o,lw:t*.8});for(let u of C){a.push({k:"ellipse",x:u*.4,y:-.04,rx:.12,ry:.07,fill:n.eyeColor??K});for(let s of[.36,.56])a.push({k:"circle",x:u*.42,y:s,r:.05,fill:o,alpha:.6})}break;case"goggle":for(let u of C)a.push({k:"circle",x:u*.9,y:0,r:.13,fill:r.accent,stroke:o,lw:t*.8});a.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:et,stroke:o,lw:t*.8}),a.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:K,lw:.07,alpha:.8});for(let u of C)a.push({k:"path",d:`M${u*.5} 0.04 Q${u*.34} -0.08 ${u*.16} 0.02`,stroke:n.eyeColor??"#7fd6ff",lw:.08});for(let u of[-.18,0,.18])a.push({k:"line",pts:[u,.56,u,.72],stroke:o,lw:t*.8,alpha:.6});break;case"visor":a.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:o,lw:t*.8}),a.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:K,lw:.08,alpha:.7});for(let u of C)a.push({k:"ellipse",x:u*.28,y:.04,rx:.1,ry:.14,fill:n.eyeColor??"#cfeeff"});break}return a}function jn(e,t){let r=e.palette,n=e.face,a=[],o=n.eyes==="visor"?"#cfeeff":Tt,l=t*1.05;switch(n.nose&&n.mouth!=="beak"&&(n.mouth==="cat"?a.push({k:"path",d:D([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:n.nose,stroke:n.nose,lw:t*.6}):e.ears==="big-round"?a.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:n.nose}):a.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:n.nose})),n.mouth){case"smile":a.push({k:"path",d:n.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:o,lw:l});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:o,stroke:o,lw:t*.5}),a.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:It});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:o,lw:l});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:o,stroke:o,lw:t*.5});for(let c of C)a.push({k:"rect",x:c*.12,y:.43,w:.1,h:.1,r:.03,fill:K});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(let 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:o});break;case"smirk":a.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:o,lw:l});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(let 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:Tt}),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:o,stroke:o,lw:t*.6}),a.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:It});for(let c of[.12,.27,.42,.57,.72,.86]){let p=(1-c)*(1-c)*-1.4+2*(1-c)*c*-.5+c*c*.5,u=(1-c)*(1-c)*.1+2*(1-c)*c*.36+c*c*.2-.01;a.push({k:"path",d:D(G(p-.08,u,p+.08,u,p,u+.14),.3),fill:K})}for(let c of[.3,.7]){let p=(1-c)*(1-c)*.52+2*(1-c)*c*-.4+c*c*-1.3,u=(1-c)*(1-c)*.38+2*(1-c)*c*.78+c*c*.26+.01;a.push({k:"path",d:D(G(p-.07,u,p+.07,u,p,u-.12),.3),fill:K})}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:o,stroke:o,lw:t*.5});for(let c of[-.34,-.17,0,.17,.34]){let p=.3+.4*(c+.5)*(.5-c)-.01;a.push({k:"path",d:D(G(c-.075,p,c+.075,p,c,p+.13),.15),fill:K})}break}}return a}var ye=(e,t)=>({x:Math.sin(e)*t,y:-Math.cos(e)*t});var $t=.5,ie={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ae={"3-5":{head:.75,neck:.74,arm:.3,leg:.36,hand:.19,foot:1.2,shoulderMin:.4,shoulderPad:.07,hipMin:.5,hipPad:.22,bottom:.26,bulge:1.12,armsOverHead:!0},"6-8":{head:.6,neck:.78,arm:.22,leg:.28,hand:.15,foot:1,shoulderMin:.34,shoulderPad:.04,hipMin:.4,hipPad:.16,bottom:.14,bulge:1.04,armsOverHead:!1},"9-12":{head:.5,neck:.92,arm:.17,leg:.21,hand:.125,foot:.9,shoulderMin:.36,shoulderPad:.07,hipMin:.32,hipPad:.08,bottom:.1,bulge:1,armsOverHead:!1}},He="6-8",Fe=(e,t)=>t!==void 0&&e.band!=="all"&&e.alsoIn?.includes(t)&&t in ae?t:e.band in ae?e.band:He,Vn=ae[He].head,Lt=.3,Ht=.12,Kn=.9,Ot=.5,Dt=.65,Un=.35,Xn=.2,Yn=.25,oe=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),H=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),z=(e,t)=>({x:e.x*t,y:e.y*t}),he=e=>Math.hypot(e.x,e.y),zt=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Ne=e=>{let t=he(e);return t>1e-9?{x:e.x/t,y:e.y/t}:{x:0,y:1}},Qn=(...e)=>e.every(Number.isFinite),Wn=e=>Math.atan2(Math.sin(e),Math.cos(e)),qn=(e,t,r)=>Math.min(Math.max(e,t),r);function Nt(e,t,r=!1){return n=>{let a=e[n*3],o=e[n*3+1],l=e[n*3+2];return a===void 0||o===void 0||l===void 0||!Qn(a,o,l)?{x:0,y:0,ok:!1}:{x:t.x+(r?1-a:a)*t.w,y:t.y+o*t.h,ok:l>=$t}}}function Ae(e,t,r={}){let n=Nt(e,t,r.mirrored),a=n(v.leftShoulder),o=n(v.rightShoulder);if(!a.ok||!o.ok)return null;let l=n(v.leftHip),c=n(v.rightHip),p=zt(a,o),u=he(oe(o,a)),s=l.ok&&c.ok,f=Ne(oe(o,a));u<1e-6&&(f={x:1,y:0});let i,d,y;if(s){let te=zt(l,c);d=he(oe(te,p)),d>=u*Yn?i=Ne(oe(te,p)):(i={x:-f.y,y:f.x},i.y<0&&(i=z(i,-1))),y=Math.max(d,u*1.15)}else i={x:-f.y,y:f.x},i.y<0&&(i=z(i,-1)),y=u*1.15,d=y;y=Math.max(y,1e-6);let h={x:i.y,y:-i.x},m=Math.atan2(h.y,h.x),x=z(i,-1),S=ae[r.band??He]??ae[He],A=S.head*y,R=H(p,z(x,A*S.neck)),W=n(v.nose);if(W.ok){let te=H(W,z(x,A*.15)),ne=z(oe(te,R),Un),Se=Math.min(1,A*Xn/Math.max(he(ne),1e-6));R=H(R,z(ne,Se))}return{S:p,r:h,d:i,U:y,L:d,hipsOk:s,head:R,headR:A,headRot:m+Zn(e,n,m,y),angle:m}}function Zn(e,t,r,n){let a=[[ie.leftEar,ie.rightEar],[ie.leftEye,ie.rightEye]];for(let[o,l]of a){let c=t(o),p=t(l);if(!c.ok||!p.ok||!(e[o*3+2]>=Dt&&e[l*3+2]>=Dt)||he(oe(p,c))<n*.05)continue;let u=Wn(Math.atan2(p.y-c.y,p.x-c.x)-r),s=Math.max(Math.abs(u)-Ht,0),f=qn((Kn+Ot-Math.abs(u))/Ot,0,1);return Math.sign(u)*Math.min(s,Lt)*f}return 0}function Ee(e,t,r,n={}){let a=Fe(t,n.band),o=ae[a],l=Ae(e,r,{...n,band:a});if(!l)return[];let c=Nt(e,r,n.mirrored),p=t.palette,{S:u,r:s,d:f,U:i,L:d}=l,y=b=>t.bodyExtras.includes(b),h=Math.max(1.2,i*.045),m={stroke:p.outline,lw:h},x=(b,g)=>({x:u.x+s.x*b+f.x*g,y:u.y+s.y*b+f.y*g}),S=b=>b.map(([g,w])=>x(g,w)),A=c(v.leftShoulder),R=c(v.rightShoulder),W=c(v.leftHip),te=c(v.rightHip),ne=he(oe(R,A)),Se=l.hipsOk?he(oe(te,W)):ne*.7,M=Math.max(ne/2+o.shoulderPad*i,o.shoulderMin*i),N=Math.max(Se/2+o.hipPad*i,o.hipMin*i),$=-.1*i,k=d+o.bottom*i,j=[],B=[],E=[],me=[],be=[],Me=(b,g,w,O)=>{let T=g.flatMap(q=>[q.x,q.y]);b.push({k:"line",pts:T,stroke:p.outline,lw:w+h*2}),b.push({k:"line",pts:T,stroke:O,lw:w})},P=o.leg*i*(y("strong-legs")?1.3:1),Q=o.arm*i*(y("tiny-arms")?.6:1),U=Math.max(o.arm/.22,.9);if(l.hipsOk)for(let[b,g,w,O]of[[W,v.leftKnee,v.leftAnkle,-1],[te,v.rightKnee,v.rightAnkle,1]]){let T=c(g),q=c(w);if(!T.ok)continue;let Ve=H(b,z(f,-.12*i)),ue=q.ok?[Ve,T,q]:[Ve,T];Me(B,ue,P,p.limbs),y("joints")&&B.push({k:"circle",x:T.x,y:T.y,r:.15*i*U,fill:p.accent,...m}),q.ok&&B.push(...tr(t,q,l,O,h,o.foot))}for(let[b,g,w,O]of[[A,v.leftElbow,v.leftWrist,-1],[R,v.rightElbow,v.rightWrist,1]]){let T=c(g),q=c(w);if(y("pauldrons")){let le=H(b,z(f,.02*i));me.push({k:"ellipse",x:le.x,y:le.y,rx:.25*i,ry:.17*i,rot:l.angle+O*.25,fill:p.body,...m});let pe=H(le,z(f,.05*i));me.push({k:"ellipse",x:pe.x,y:pe.y,rx:.17*i,ry:.07*i,rot:l.angle+O*.25,fill:p.belly})}if(!T.ok)continue;let ue=o.armsOverHead&&(T.x-u.x)*f.x+(T.y-u.y)*f.y<-.25*i?be:me,rt=H(b,z(f,.04*i));if(Me(ue,q.ok?[rt,T,q]:[rt,T],Q,p.limbs),y("joints")&&ue.push({k:"circle",x:T.x,y:T.y,r:.13*i*U,fill:p.accent,...m}),!q.ok)continue;let se=Ne(oe(q,T)),ge=H(q,z(se,.05*i));if(y("feathers"))for(let le of[-.55,0,.55]){let pe=Math.cos(le),Re=Math.sin(le)*O,fe={x:se.x*pe-se.y*Re,y:se.x*Re+se.y*pe},Te=H(ge,z(fe,.16*i));ue.push({k:"ellipse",x:Te.x,y:Te.y,rx:.2*i,ry:.09*i,rot:Math.atan2(fe.y,fe.x),fill:p.hands??p.accent,...m})}y("wand")&&O===1&&!n.portrait&&ue.push(...or(t,ge,Ne(H(z(se,.4),oe(z(s,.6),f))),i,h));let Ce=o.hand*i*(y("tiny-arms")?.72:1);if(y("tiny-arms"))for(let le of[-.45,.45]){let pe=Math.cos(le),Re=Math.sin(le),fe={x:se.x*pe-se.y*Re,y:se.x*Re+se.y*pe},Te=H(ge,z(fe,Ce*.75)),ln=H(ge,z(fe,Ce*1.6)),ot={x:-fe.y*Ce*.32,y:fe.x*Ce*.32};ue.push({k:"path",d:D([H(Te,ot),ln,oe(Te,ot)],.2),fill:p.belly,...m})}ue.push({k:"circle",x:ge.x,y:ge.y,r:Ce,fill:p.hands??p.limbs,...m})}if(y("wings"))for(let b of[-1,1]){let g=S([[b*M*.5,.05*i],[b*(M+.85*i),-.6*i],[b*(M+.72*i),.05*i],[b*(M+.45*i),-.02*i],[b*(M+.3*i),.32*i],[b*M*.6,.55*i]]);j.push({k:"path",d:D(g,.18),fill:p.accent,...m})}if(y("wings-fairy")&&j.push(...ar(t,x,M,i,h)),y("cape")){let b=d+.8*i,g=N+.36*i,w=S([[-M*.92,$+.04*i],[M*.92,$+.04*i],[M+.16*i,d*.5],[g,b],[g*.5,b-.1*i],[0,b],[-g*.5,b-.1*i],[-g,b],[-M-.16*i,d*.5]]);j.push({k:"path",d:I(w,.6),fill:p.accent,...m})}if(y("backpack")){let b=x(0,.35*i);j.push({k:"rect",x:b.x,y:b.y,w:M*2+.34*i,h:.8*i,r:.16*i,rot:l.angle,fill:t.extraColors?.[0]??p.limbs,...m})}if(y("tank")){let b=x(M*.95,.24*i),g=t.extraColors?.[0]??p.accent,w=x(M*.95,-.3*i);j.push({k:"rect",x:w.x,y:w.y,w:.14*i,h:.16*i,r:.04*i,rot:l.angle,fill:p.outline}),j.push({k:"rect",x:b.x,y:b.y,w:.34*i,h:1*i,r:.17*i,rot:l.angle,fill:g,...m})}if(l.hipsOk&&!n.portrait&&j.push(...rr(t,l,N,h)),y("tentacles")&&l.hipsOk)for(let b of[-1,1]){let g=S([[b*N*.7,d*.9],[b*(N+.22*i),d+.3*i],[b*(N+.48*i),d+.22*i],[b*(N+.5*i),d-.02*i],[b*(N+.34*i),d-.06*i]]);j.push({k:"path",d:ve(g),stroke:p.outline,lw:.2*i+h*2}),j.push({k:"path",d:ve(g),stroke:p.limbs,lw:.2*i})}let V=Math.max(M,N)*o.bulge;if(y("wool")){for(let[g,w]of[[M*.7,$+.02*i],[V,d*.3],[V*1.02,d*.62],[(V+N)/2,d*.92],[N*.55,k]])for(let O of[-1,1]){let T=x(O*g,w);E.push({k:"circle",x:T.x,y:T.y,r:.2*i,fill:p.body,...m})}let b=x(0,k+.02*i);E.push({k:"circle",x:b.x,y:b.y,r:.2*i,fill:p.body,...m})}if(y("robe")){let b=d+.58*i,g=N*1.4;E.push({k:"path",d:I(S([[-M,$],[0,$-.04*i],[M,$],[V,d*.55],[g,b],[0,b+.06*i],[-g,b],[-V,d*.55]]),.7),fill:p.body,...m});let w=S([[-g*.94,b-.1*i],[0,b-.04*i],[g*.94,b-.1*i]]);E.push({k:"path",d:ve(w),stroke:t.extraColors?.[0]??p.accent,lw:.07*i})}else if(y("sheet")){let b=d+.78*i,g=N*1.3;E.push({k:"path",d:I(S([[-M,$],[M,$],[V,d*.55],[g,b],[g*.5,b-.2*i],[0,b],[-g*.5,b-.2*i],[-g,b],[-V,d*.55]]),.9),fill:p.body,...m})}else E.push({k:"path",d:I(S([[-M,$],[0,$-.04*i],[M,$],[V,d*.55],[N,k],[0,k+.03*i],[-N,k],[-V,d*.55]]),.85),fill:p.body,...m});let X=Math.min(M,N);if(y("pocket")){let b=x(0,d*.74);E.push({k:"rect",x:b.x,y:b.y,w:X*1.3,h:.3*i,r:.1*i,rot:l.angle,fill:p.belly,stroke:p.outline,lw:h*.8})}else if(y("racing-stripe"))for(let b of[-.1,.1]){let g=x(b*i,$+.02*i),w=x(b*i,k-.04*i);E.push({k:"line",pts:[g.x,g.y,w.x,w.y],stroke:p.belly,lw:.1*i})}else if(p.belly&&p.belly!==p.body&&!y("panel")&&!y("sheet")&&!y("stripes")){let b=x(0,d*.58);E.push({k:"ellipse",x:b.x,y:b.y,rx:X*.64,ry:Math.max(d*.36,.2*i),rot:l.angle,fill:p.belly})}if(y("spots")){let b=t.extraColors?.[1]??p.belly;for(let[g,w,O]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){let T=x(g*X,w*d);E.push({k:"circle",x:T.x,y:T.y,r:O*i,fill:b})}}if(y("stripes")){let b=t.extraColors?.[1]??p.accent;for(let g of[.22,.44,.66]){let w=x(-X*.98,d*g),O=x(X*.98,d*g);E.push({k:"line",pts:[w.x,w.y,O.x,O.y],stroke:b,lw:.1*i})}}if(y("straps")){let b=t.extraColors?.[1]??p.outline;for(let g of[-1,1]){let w=x(g*M*.62,$+.02*i),O=x(g*X*.62,d*.72);E.push({k:"line",pts:[w.x,w.y,O.x,O.y],stroke:p.outline,lw:.13*i+h*2}),E.push({k:"line",pts:[w.x,w.y,O.x,O.y],stroke:b,lw:.13*i})}}if(y("belt")){let b=x(0,d*.9);E.push({k:"rect",x:b.x,y:b.y,w:N*1.92,h:.17*i,r:.06*i,rot:l.angle,fill:t.extraColors?.[2]??"#4a3426",...m}),E.push({k:"rect",x:b.x,y:b.y,w:.2*i,h:.19*i,r:.04*i,rot:l.angle,fill:"#ffd84a",...m})}if(y("emblem")){let b=x(0,d*.4),g=t.extraColors?.[0]??p.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:b.x,y:b.y,rot:l.angle,s:i,items:[{k:"path",d:w,fill:g,stroke:p.outline,lw:h/i},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ce,fill:g===p.accent?"#ffffff":p.accent}]}]})}if(y("panel")){let b=x(0,d*.5);E.push({k:"rect",x:b.x,y:b.y,w:X*1.2,h:.38*i,r:.1*i,rot:l.angle,fill:"#24323d",...m}),(t.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((w,O)=>{let T=x((O-1)*X*.34,d*.5);E.push({k:"circle",x:T.x,y:T.y,r:.075*i,fill:w})})}if(y("badge")){let b=x(-X*.42,d*.36);E.push({k:"circle",x:b.x,y:b.y,r:.15*i,fill:p.accent,...m}),E.push({k:"group",x:b.x,y:b.y,rot:l.angle,s:.09*i,items:[{k:"path",d:ce,fill:"#ffffff"}]})}if(y("star")){let b=x(-X*.5,d*.3),g=.15*i;E.push({k:"group",x:b.x,y:b.y,rot:l.angle-.2,s:g,items:[{k:"path",d:ce,fill:t.extraColors?.[0]??"#ffd84a",stroke:p.outline,lw:h*.8/g}]})}if(y("petals")&&E.push(...sr(t,x,M,N,V,d,k,i,h,o)),y("scarf")){let b=Math.max(.04,o.head*(1-o.neck)-.06)*i,g=x(0,b),w=t.extraColors?.[0]??p.accent,O=x(M*.45,b+.28*i);E.push({k:"rect",x:O.x,y:O.y,w:.16*i,h:.42*i,r:.06*i,rot:l.angle+.15,fill:w,...m}),E.push({k:"rect",x:g.x,y:g.y,w:M*2.05,h:.2*i,r:.1*i,rot:l.angle,fill:w,...m})}let xe={k:"group",x:l.head.x,y:l.head.y,rot:l.headRot,s:l.headR,items:er(t,h/l.headR)};return[...j,...B,...E,...me,xe,...be]}var _t=new WeakMap,Jn=64;function er(e,t){let r=Number(t.toPrecision(4)),n=_t.get(e);n||_t.set(e,n=new Map);let a=n.get(r);return a||(n.size>=Jn&&n.clear(),n.set(r,a=Le(e,r))),a}function tr(e,t,r,n,a,o){let l=nr(e,t,r,n,a,o);if(!e.bodyExtras.includes("strong-legs"))return[l];let c=r.U*o,p=H(H(t,z(r.d,.07*c)),z(r.r,n*.06*c)),u=[l];for(let s of[-1,0,1]){let f=H(H(p,z(r.r,s*.12*c)),z(r.d,.09*c));u.push({k:"ellipse",x:f.x,y:f.y,rx:.05*c,ry:.045*c,rot:r.angle,fill:e.palette.belly,stroke:e.palette.outline,lw:a*.8})}return u}function nr(e,t,r,n,a,o){let l=e.palette,{d:c,r:p}=r,u=r.U*o,s=H(H(t,z(c,.07*u)),z(p,n*.06*u)),f={stroke:l.outline,lw:a},i=l.feet??l.limbs;if(e.bodyExtras.includes("fins")){let 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:u,items:[{k:"path",d,fill:i,stroke:l.outline,lw:a/u},{k:"line",pts:[0,.06,0,.38],stroke:l.outline,lw:a/u,alpha:.5}]}}return e.bodyExtras.includes("flippers")?{k:"ellipse",x:s.x,y:s.y,rx:.27*u,ry:.11*u,rot:r.angle,fill:i,...f}:e.bodyExtras.includes("boots")?{k:"rect",x:s.x,y:s.y,w:.4*u,h:.24*u,r:.09*u,rot:r.angle,fill:i,...f}:{k:"ellipse",x:s.x,y:s.y,rx:.2*u,ry:.13*u,rot:r.angle,fill:i,...f}}function rr(e,t,r,n){let a=e.palette,{U:o,L:l,S:c,r:p,d:u}=t,s=(h,m)=>({x:c.x+p.x*h+u.x*m,y:c.y+p.y*h+u.y*m}),f=h=>h.map(([m,x])=>s(m,x)),i={stroke:a.outline,lw:n},d=(h,m,x)=>[{k:"path",d:ve(h),stroke:a.outline,lw:m+n*2},{k:"path",d:ve(h),stroke:x,lw:m}],y=[];switch(e.tail){case"none":break;case"fluffy":{let h=f([[r*.5,l*.95],[r+.28*o,l*1],[r+.72*o,l*.62],[r+.78*o,l*.12],[r+.52*o,l*.32],[r+.3*o,l*.6],[r*.6,l*.7]]);y.push({k:"path",d:I(h),fill:a.body,...i});let m=s(r+.72*o,l*.2);y.push({k:"ellipse",x:m.x,y:m.y,rx:.13*o,ry:.2*o,rot:t.angle+.25,fill:a.belly,...i});break}case"brush":{let h=f([[r*.4,l*.98],[r+.42*o,l*1.06],[r+.98*o,l*.66],[r+1.06*o,l*.12],[r+.86*o,-.04*o],[r+.66*o,l*.36],[r+.3*o,l*.66],[r*.5,l*.68]]);y.push({k:"path",d:I(h),fill:a.body,...i});let m=f([[r+1.03*o,l*.36],[r+1.06*o,l*.12],[r+.86*o,-.04*o],[r+.72*o,l*.24],[r+.86*o,l*.34]]);y.push({k:"path",d:I(m),fill:a.belly,...i});break}case"pom":{let h=s(r+.06*o,l*.88);y.push({k:"circle",x:h.x,y:h.y,r:.2*o,fill:a.belly,...i});break}case"long":case"striped":case"tuft":{let h=f([[r*.6,l*.9],[r+.35*o,l*.85],[r+.58*o,l*.4],[r+.5*o,-.02*o]]);if(y.push(...d(h,.14*o,a.body)),e.tail==="tuft"){let m=h[h.length-1];y.push({k:"circle",x:m.x,y:m.y,r:.16*o,fill:e.extraColors?.[0]??a.accent,...i})}if(e.tail==="striped"){for(let x of[.35,.6,.85]){let S=s(r+.35*o+.22999999999999998*o*(x*1.4>1?1:x*1.4),l*(.85-.85*x));y.push({k:"line",pts:[S.x-p.x*.08*o,S.y-p.y*.08*o,S.x+p.x*.08*o,S.y+p.y*.08*o],stroke:e.extraColors?.[0]??a.outline,lw:.06*o})}let m=h[h.length-1];y.push({k:"circle",x:m.x,y:m.y,r:.07*o,fill:e.extraColors?.[0]??a.outline})}break}case"curl":{let h=f([[r*.6,l*.9],[r+.4*o,l*.88],[r+.62*o,l*.45],[r+.5*o,l*.12],[r+.3*o,l*.24],[r+.36*o,l*.42]]);y.push(...d(h,.12*o,a.limbs));break}case"fish":{let h=f([[r*.6,l*.9],[r+.36*o,l*.86],[r+.6*o,l*.5]]);y.push(...d(h,.17*o,a.body));let m=h[h.length-1],x=D([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);y.push({k:"group",x:m.x,y:m.y,rot:t.angle+.35,s:o,items:[{k:"path",d:x,fill:a.body,stroke:a.outline,lw:n/o}]});break}case"plume":{let h=e.extraColors??[a.accent];[0,1,2].forEach(m=>{let x=s(r+(.12+m*.13)*o,l+(.32-m*.06)*o);y.push({k:"ellipse",x:x.x,y:x.y,rx:.11*o,ry:.44*o,rot:t.angle-.55+m*.28,fill:h[(m+1)%h.length],...i})});break}case"thick":{let h=f([[r*.3,l*.42],[r+.42*o,l*.62],[r+.92*o,l*.96],[r+1.32*o,l*1.08],[r+1.44*o,l*.98],[r+.98*o,l*1.2],[r+.4*o,l*1.22],[r*.3,l*1.12]]);y.push({k:"path",d:I(h,.8),fill:a.body,...i});let m=e.extraColors?.[0]??a.accent;for(let[x,S,A]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){let R=s(r+x*o,l*S+.03*o),W=s(r+(x-.1)*o,l*S+A*o);y.push({k:"line",pts:[R.x,R.y,W.x,W.y],stroke:m,lw:.09*o})}break}case"spiky":case"arrow":{let h=f([[r*.3,l*.55],[r+.35*o,l*.68],[r+.95*o,l*.86],[r+.35*o,l*1.08],[r*.3,l*1.08]]);if(e.tail==="spiky"){for(let m of[.15,.45,.72]){let x=r+(.2+m*.7)*o,S=l*(.66+m*.19);y.push({k:"path",d:D(f([[x-.12*o,S+.05*o],[x,S-.2*o],[x+.12*o,S+.07*o]]),.2),fill:a.accent,...i})}y.push({k:"path",d:I(h,.7),fill:a.body,...i})}else{let m=f([[r*.6,l*.9],[r+.4*o,l*.92],[r+.62*o,l*.5],[r+.62*o,l*.18]]);y.push(...d(m,.13*o,a.body));let x=m[m.length-1];y.push({k:"group",x:x.x,y:x.y,rot:t.angle,s:o,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:n/o}]})}break}}return y}function or(e,t,r,n,a){let o=e.palette,l=H(t,z(r,-.08*n)),c=H(t,z(r,.52*n)),p=.2*n;return[{k:"line",pts:[l.x,l.y,c.x,c.y],stroke:o.outline,lw:.06*n+a*2},{k:"line",pts:[l.x,l.y,c.x,c.y],stroke:"#fff3d6",lw:.06*n},{k:"circle",x:c.x,y:c.y,r:.24*n,fill:o.accent,alpha:.28},{k:"group",x:c.x,y:c.y,rot:Math.atan2(r.y,r.x)+Math.PI/2,s:p,items:[{k:"path",d:ce,fill:o.accent,stroke:o.outline,lw:a*.9/p}]}]}function ar(e,t,r,n,a){let o=e.palette,l=e.extraColors?.[0]??"#cdeeff",c=[];for(let p of[-1,1]){let u=[[[p*r*.3,.12*n],[p*(r+.42*n),-.66*n],[p*(r+1*n),-.74*n],[p*(r+1.02*n),-.18*n],[p*(r+.5*n),.26*n]],[[p*r*.4,.3*n],[p*(r+.6*n),.36*n],[p*(r+.74*n),.78*n],[p*(r+.3*n),.9*n]]];for(let s of u){let f=I(s.map(([h,m])=>t(h,m)),.9);c.push({k:"path",d:f,fill:l,alpha:.6}),c.push({k:"path",d:f,stroke:o.outline,lw:a*.9});let i=s[Math.floor(s.length/2)],d=t(s[0][0],s[0][1]),y=t(s[0][0]+(i[0]-s[0][0])*.75,s[0][1]+(i[1]-s[0][1])*.75);c.push({k:"line",pts:[d.x,d.y,y.x,y.y],stroke:"#ffffff",lw:a*.9,alpha:.85})}for(let[s,f,i]of[[r+.72*n,-.42*n,.075*n],[r+.44*n,-.16*n,.05*n],[r+.5*n,.6*n,.055*n]]){let d=t(p*s,f);c.push({k:"group",x:d.x,y:d.y,s:i,items:[{k:"path",d:ce,fill:"#ffffff"}]})}}return c}function sr(e,t,r,n,a,o,l,c,p,u){let s=e.palette,f=e.extraColors?.[1]??s.belly,i=[],d=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),y=5,h=Math.max(n,a*.92)*1.08,m=(o*.8+l)/2,x=[0,4,1,3,2];for(let A of x){let R=A/(y-1)-.5,W=t(R*2*h,m+(.5-Math.abs(R))*.1*c);i.push({k:"ellipse",x:W.x,y:W.y,rx:h*.3,ry:.34*c,rot:d-R*.6,fill:A%2?f:s.body,stroke:s.outline,lw:p})}let S=Math.max(.04,u.head*(1-u.neck)-.04)*c;for(let A of[-1,1,0]){let R=t(A*r*.32,S+(A?0:.05*c));i.push({k:"ellipse",x:R.x,y:R.y,rx:r*.26,ry:.12*c,rot:d+A*.5,fill:A?f:s.body,stroke:s.outline,lw:p*.9})}return i}var ir={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 lr(e,{cx:t=.5,cy:r=.36,T:n=.18}={}){let a={...ir,...e},o=new Array(Xe*3).fill(0),l=(u,[s,f],i=.99)=>{o[u*3]=t+s*n,o[u*3+1]=r+f*n,o[u*3+2]=i};for(let u of Object.keys(v))l(v[u],a[u]);let c=a.tilt??0,p=(u,s)=>[a.nose[0]+u*Math.cos(c)-s*Math.sin(c),a.nose[1]+u*Math.sin(c)+s*Math.cos(c)];return l(ie.leftEye,p(-.1,-.08)),l(ie.rightEye,p(.1,-.08)),l(ie.leftEar,p(-.22,-.02)),l(ie.rightEar,p(.22,-.02)),o}var Ft=()=>lr({});var De=class{constructor(t={}){L(this,"tracks",new Map);L(this,"offset",NaN);L(this,"lastArrival",NaN);L(this,"interval",33);L(this,"lastT",NaN);L(this,"lostMs");L(this,"maxExtrapolateMs");this.lostMs=t.lostMs??250,this.maxExtrapolateMs=t.maxExtrapolateMs??25}get delayMs(){return this.interval}push(t,r,n,a=Gt()){Number.isFinite(r)||(r=a),this.clock(r,a);let o=this.tracks.get(t);if(!o||r-o.tb>this.lostMs||r<o.tb-this.lostMs||n.length!==o.b.length){this.tracks.set(t,{a:null,ta:r,b:n,tb:r,out:null,outAt:NaN});return}if(n===o.b||r<=o.tb){r===o.tb&&n!==o.b&&(o.b=n,o.out=null);return}o.a=o.b,o.ta=o.tb,o.b=n,o.tb=r,o.out=null}at(t,r=Gt()){let n=this.tracks.get(t);if(!n)return null;if(!n.a)return n.b;if(n.out&&n.outAt===r)return n.out;let a=r-this.offset-this.interval,o=n.tb-n.ta,l=Math.min(o*.5,this.maxExtrapolateMs),c=Math.min(Math.max((a-n.ta)/o,0),1+l/o);return n.out=jt(n.a,n.b,c),n.outAt=r,n.out}forget(t){this.tracks.delete(t)}clear(){this.tracks.clear()}clock(t,r){let n=r-t;if(!Number.isFinite(this.offset)||n<this.offset||n>this.offset+1e3?this.offset=n:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(n-this.offset,(r-this.lastArrival)/1e3)),this.lastArrival=r,Number.isFinite(this.lastT)&&t>this.lastT){let a=t-this.lastT;a<this.interval*3+20&&(this.interval+=(Math.min(Math.max(a,8),100)-this.interval)*.1)}t<=this.lastT||(this.lastT=t)}},Gt=()=>globalThis.performance?.now()??Date.now();function jt(e,t,r){let n=t.slice(),a=r<.5?e:t;for(let o=0;o+2<t.length;o+=3){let l=e[o],c=e[o+1],p=t[o],u=t[o+1];e[o+2]>=.5&&t[o+2]>=.5&&Math.abs(p-l)+Math.abs(u-c)<.15?(n[o]=l+(p-l)*r,n[o+1]=c+(u-c)*r,n[o+2]=e[o+2]+(t[o+2]-e[o+2])*Math.min(r,1)):(n[o]=a[o],n[o+1]=a[o+1],n[o+2]=a[o+2])}return n}var so=Ze.map(e=>e.id);var Ge=new Map(Ze.map(e=>[e.id,e])),tt=Ge.get("fox"),Kt=e=>typeof e=="string"&&Ge.has(e),Ut=e=>Ge.get(e);var Xt=e=>typeof e=="string"?Ge.get(e)??tt:e;function Yt(e,t,r,n,a={}){let o=Ee(t,Xt(r),n,{mirrored:a.mirrored,band:a.band});return o.length?(e.save(),a.alpha!==void 0&&(e.globalAlpha*=Math.min(Math.max(a.alpha,0),1)),we(e,o),e.restore(),!0):!1}function Qt(e,t,r){let n=Xt(e),a=Ft(),o=Fe(n,r),l=Ae(a,{x:0,y:0,w:1,h:1},{band:o}),c=qt(Le(n,.05)),p=-c.minY,u=Math.min(.27,.43/Math.max(p,1))*t,s=n.head==="snout-long"?(c.minX+c.maxX)/2*u:0,f=u/ae[o].head/l.U,i=.5*t+Math.min(0,(p-1.6)*.06*t),d={x:t/2-s-l.head.x*f,y:i-l.head.y*f,w:f,h:f};return Ee(a,n,d,{portrait:!0,band:o})}function Wt(e,t,r=.5){if(!e||e.length!==t.length)return t.slice();let n=t.slice();for(let a=0;a+2<t.length;a+=3){let o=e[a+2],l=t[a+2],c=o>=.5,p=l>=.5;c&&l>=.3&&(n[a+2]=Math.max(l,.5));let u=Math.hypot(t[a]-e[a],t[a+1]-e[a+1]);if(c&&p&&u<.15){let s=r*Math.min(1,Vt+(1-Vt)*u/ur);n[a]=e[a]+(t[a]-e[a])*s,n[a+1]=e[a+1]+(t[a+1]-e[a+1])*s}else c&&!p&&n[a+2]>=.5&&(n[a]=e[a],n[a+1]=e[a+1])}return dr(e,t,n,r*pr),n}var Vt=.1,ur=.03,pr=.35,fr=11;function dr(e,t,r,n){let a=v.leftShoulder*3,o=v.rightShoulder*3,l=(f,i)=>f[i+2]>=.5;if(!l(e,a)||!l(e,o)||!l(t,a)||!l(t,o))return;let c=(f,i)=>(f[a+i]+f[o+i])/2,p=[c(e,0),c(e,1)],u=[c(t,0),c(t,1)],s=[c(r,0),c(r,1)];for(let f=0;f<fr&&f*3+2<t.length;f++){let i=f*3;if(!l(e,i)||!l(t,i))continue;let d=[e[i]-p[0],e[i+1]-p[1]],y=[t[i]-u[0],t[i+1]-u[1]];Math.hypot(y[0]-d[0],y[1]-d[1])>=.15||(r[i]=s[0]+d[0]+(y[0]-d[0])*n,r[i+1]=s[1]+d[1]+(y[1]-d[1])*n)}}function qt(e){let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},r=(n,a)=>{t.minX=Math.min(t.minX,n),t.minY=Math.min(t.minY,a),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,a)};for(let n of e){let a="lw"in n&&n.stroke?(n.lw??1)/2:0;switch(n.k){case"circle":r(n.x-n.r-a,n.y-n.r-a),r(n.x+n.r+a,n.y+n.r+a);break;case"ellipse":case"rect":{let o=n.k==="ellipse"?n.rx:n.w/2,l=n.k==="ellipse"?n.ry:n.h/2,c=Math.max(o,l)+a;r(n.x-c,n.y-c),r(n.x+c,n.y+c);break}case"path":{let o=Je(n.d);for(let l=0;l+1<o.length;l+=2)r(o[l]-a,o[l+1]-a),r(o[l]+a,o[l+1]+a);break}case"line":for(let o=0;o+1<n.pts.length;o+=2)r(n.pts[o]-a,n.pts[o+1]-a),r(n.pts[o]+a,n.pts[o+1]+a);break;case"group":{let o=qt(n.items);if(!Number.isFinite(o.minX))break;let l=n.s??1,c=Math.cos(n.rot??0),p=Math.sin(n.rot??0);for(let[u,s]of[[o.minX,o.minY],[o.maxX,o.minY],[o.minX,o.maxY],[o.maxX,o.maxY]])r(n.x+(u*c-s*p)*l,n.y+(u*p+s*c)*l);break}}}return t}var yr=()=>{let e=typeof document<"u"?document.timeline?.currentTime:null;return typeof e=="number"&&Number.isFinite(e)?e:globalThis.performance?.now()??Date.now()},Zt=()=>globalThis.performance?.now()??Date.now(),Pe=class{constructor(t=yr){L(this,"now",t);L(this,"known",new Map);L(this,"smoothed",new Map);L(this,"times",new WeakMap);L(this,"lerp",new De);L(this,"drawnAt",NaN);L(this,"drawn",0);L(this,"smoothedBody",(t,r={})=>{let n=r.interpolate!==!1;if(typeof t=="number"){let a=this.smoothed.get(t);return a?n?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,Jt(r.smooth),n)})}note(t,r,n=Zt()){for(let a of t)this.known.set(a.id,this.resolve(a.id,a.avatar)),r!==void 0&&Number.isFinite(r)&&Array.isArray(a.body)&&this.times.set(a.body,{t:r,arrival:n})}of(t){return typeof t=="object"&&t!==null?t.avatar!==void 0?this.resolve(t.id,t.avatar):this.of(t.id):this.known.get(t)??Qe(t-1)}posed(t,r,n,a=!0){let o=this.smooth(t,r,n);return a?this.lerp.at(t,this.tick())??o:o}smooth(t,r,n){let a=this.smoothed.get(t);if(a&&a.raw===r&&a.amount===n)return a.body;a&&a.amount!==n&&this.lerp.forget(t);let o=n<1?Wt(a?.body,r,n):r;this.smoothed.set(t,{raw:r,body:o,amount:n});let l=this.times.get(r),c=l?.arrival??Zt();return this.lerp.push(t,l?.t??c,o,c),o}takeDrawn(){let t=this.drawn;return this.drawn=0,t}tick(){let t=this.now();return t!==this.drawnAt&&(this.drawnAt=t,this.drawn++),t}resolve(t,r){return Kt(r)?r:Qe(t-1)}};function hr(e,t){let r=typeof e.getTransform=="function"?e.getTransform():null,n=r&&Math.hypot(r.a,r.b)||1,a=r&&Math.hypot(r.c,r.d)||1,o=(e.canvas?.width??0)/n,l=(e.canvas?.height??0)/a;return t?{x:t.x*o,y:t.y*l,w:t.w*o,h:t.h*l}:{x:0,y:0,w:o,h:l}}var Jt=e=>e===!1?1:typeof e=="number"?Math.min(Math.max(e,.05),1):.5;function je(e,t){return(r,n,a,o,l={})=>{let c=Array.isArray(n)?null:n,p=c?c.body:n;if(!Array.isArray(p))return null;let u=typeof a=="string"?a:e.of(typeof a=="number"?a:c??1),s=typeof a=="number"?a:c?.id,f=s!==void 0?e.posed(s,p,Jt(l.smooth),l.interpolate!==!1):p;return Yt(r,f,u,o??hr(r,t().view),l.alpha!==void 0?{alpha:l.alpha}:{})?f:null}}function tn(e){let t=new Map,r=(s,f)=>t.get(s)?.forEach(i=>i(f)),n=null,a=null,o=new Map,l=[],c=s=>n?s(n):l.push(s),p=new Pe,u=je(p,()=>({view:null}));return e.then(s=>{n=s;let f=new Map;s.on("gesture",i=>r(i.gesture,{player:i.player})),s.on("pause",i=>r("pause",{reason:i.reason==="distance"?"distance":"user"})),s.on("resume",()=>r("resume",{})),s.on("break-start",()=>r("break-start",{})),s.on("break-done",i=>r("break-end",{shown:i.shown})),s.onBackdrop((i,d)=>r("backdrop",{backdrop:i,view:d})),s.on("turn",i=>r("turn",{players:[...i.players]})),s.on("capabilities",i=>r("capabilities",{pictures:i.pictures})),s.on("frame",i=>{r("players",{players:i.players});for(let d of i.players)r("hands",{player:d.id,left:d.leftHand,right:d.rightHand,aim:{left:s.aim(d,"left"),right:s.aim(d,"right")}}),f.get(d.id)!==d.shape&&(f.set(d.id,d.shape),r("shape",{player:d.id,shape:d.shape}))}),a=mr(s),r("start",a),l.splice(0).forEach(i=>i(s))}),{on(s,f){let i=t.get(s)??new Set;return t.set(s,i),i.add(f),s==="start"&&a&&f(a),()=>{i.delete(f)}},ready:()=>c(s=>s.ready()),score:(s,f)=>c(i=>{let d=f??nn(i);o.set(d,s),i.score(d,s)}),break:s=>new Promise(f=>c(i=>{i.break(s).then(f)})),end:s=>c(f=>f.end(typeof s=="number"?br(f,s,o):s.map(i=>({player:i.player,score:i.score,stars:i.stars??2})))),keys:(s,f)=>c(i=>{ut(i,s,f)}),pointer:s=>c(f=>{pt(f,s)}),get players(){return n?.players??en},get turns(){return n?.turns??en},get input(){return n?.input??"body"},get hasPointer(){return n?.pointer??!1},get canSavePicture(){return n?.canSavePicture??!1},savePicture:(s,f)=>new Promise(i=>c(d=>{d.savePicture(s,f).then(i)})),get muted(){return n?.muted??!1},get orientation(){return n?.orientation??"landscape"},get safeArea(){return n?.safeArea??$e},get view(){return n?.view??null},get device(){return n?.device??null},reportStats:s=>n?.reportStats(s),toScreen:s=>n?n.toScreen(s):Be(null,s),aim:(s,f)=>n?n.aim(s,f):null,avatarOf:s=>n?n.avatarOf(s):p.of(s),drawAvatar:(...s)=>n?n.drawAvatar(...s):u(...s),smoothedBody:(...s)=>n?n.smoothedBody(...s):p.smoothedBody(...s)}}var en=Object.freeze([]),mr=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}),nn=e=>e.input==="remote"?e.players[0]??1:1;function br(e,t,r){let n=nn(e);return e.input!=="remote"?[{player:n,score:t,stars:2}]:[...e.turns.slice(0,Math.max(e.turns.indexOf(n),0)).map(o=>({player:o,score:r.get(o)??0,stars:2})),{player:n,score:t,stars:2}]}var kr=[.85,.7,.55],rn=.75,wr=320;function on(e){if(typeof e=="string"){let 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"};let{width:t,height:r}=e;if(!(t>0&&r>0))return{error:"error"};let n=e.ownerDocument??document,a=Math.min(1,1920/Math.max(t,r));for(;;){let o=Math.max(1,Math.round(t*a)),l=Math.max(1,Math.round(r*a)),c=n.createElement("canvas");c.width=o,c.height=l;let p=c.getContext("2d");if(!p)return{error:"error"};p.fillStyle="#fff",p.fillRect(0,0,o,l),p.drawImage(e,0,0,o,l);for(let u of kr){let s=c.toDataURL("image/jpeg",u),f=ze(s);if("ok"in f)return{data:s};if(f.error!=="too-big")return{error:"error"}}if(Math.max(o,l)*rn<wr)return{error:"too-big"};a*=rn}}catch{return{error:"error"}}}var vr=(e=window)=>({post:t=>e.parent.postMessage(t,"*"),listen:t=>e.addEventListener("message",r=>r.source===e.parent&&t(r.data))}),Ar=1e4,Er=1e3,Pr=12e4;function an(e=vr(),t={}){return new Promise((r,n)=>{let a=new Map,o=[],l=!1,c=!1,p=!1,u="none",s=null,f="landscape",i=[],d=new Ie,y="body",h=Object.freeze([]),m=h,x=!1,S=0,A=new Map,R,W=()=>{if(R===void 0){let $=t.cursor!==void 0?t.cursor:typeof document<"u"?ft():null;R=$?dt($):null}return R},te=new Set,ne=new Pe,Se=je(ne,()=>({view:s})),M=ne.smoothedBody,N=setTimeout(()=>n(new Error("Fabi Play: no host, is the game opened from Fabi Play?")),Ar);e.listen($=>{if(typeof $!="object"||$===null||$.ns!==We)return;let k=$;if(k.type==="init"&&!p){if(k.v!==Ue)return clearTimeout(N),n(new Error(`Fabi Play: protocol ${k.v}, this SDK speaks ${Ue}`));p=!0,clearTimeout(N),u=k.backdrop==="video"?"video":"none",s=qe(k.view)??null;let j=wt(k.device)??null;f=k.orientation==="portrait"?"portrait":"landscape";let B=gt(k.safeArea),E=B?Object.freeze(B):$e;y=k.input==="remote"?"remote":"body";let me=y==="remote"&&k.pointer===!0;x=k.pictures===!0,h=Object.freeze(Array.isArray(k.players)?[...k.players]:[]);let be=y==="remote"&&h.length===1?Mt(k.turns):void 0;m=Object.freeze(be&&be[0]===h[0]?be:[...h]);let Me={};if(k.stats===!0){let P=performance.now();setInterval(()=>{let U=performance.now();e.post(de({type:"stats",renderFps:Math.round(ne.takeDrawn()*1e3/Math.max(U-P,1)),...Me})),P=U},Er).unref?.()}r({locale:k.locale,mode:k.mode,get players(){return h},turns:m,input:y,pointer:me,muted:k.muted,orientation:f,safeArea:E,ageRange:k.ageRange??"6-8",get backdrop(){return u},get view(){return s},device:j,reportStats:P=>{Me=vt(P)},toScreen:P=>Be(s,P),aim(P,Q){let U=typeof P=="number"?P:P?.id,V=typeof P=="number"?i.find(g=>g.id===P):P,X=f==="portrait",xe=V?(u!=="video"||X?M(V):null)??V.body:null,b=xe?xt(xe,Q,{orientation:f,view:s}):null;return X&&typeof U=="number"?d.at(Ie.key(U,Q),b,performance.now()):b},avatarOf:P=>ne.of(P),drawAvatar:Se,smoothedBody:M,onBackdrop(P){return te.add(P),()=>{te.delete(P)}},on(P,Q){let U=a.get(P)??new Set;return a.set(P,U),U.add(Q),()=>{U.delete(Q)}},ready:()=>e.post(de({type:"ready"})),score:(P,Q)=>e.post(de({type:"score",player:P,score:Q})),break:(P="level")=>new Promise(Q=>{o.push({reason:P,done:Q}),e.post(de({type:"break",reason:P}))}),end:P=>e.post(de({type:"end",scores:P})),get canSavePicture(){return x},savePicture:async(P,Q)=>{if(!x)return"unavailable";let U=on(P);if("error"in U)return U.error;let V=++S,X=Ke(Q?.title);return new Promise(xe=>{let b=setTimeout(()=>g("error"),Pr);b.unref?.();let g=w=>{clearTimeout(b),A.delete(V),xe(w)};A.set(V,g),e.post(de({type:"picture",data:U.data,id:V,...X?{title:X}:{}}))})}})}else if(p){let j=k;if(k.type==="frame"&&Array.isArray(k.players)&&(ne.note(k.players,k.t),i=k.players),k.type==="backdrop"){if(k.backdrop!=="video"&&k.backdrop!=="none")return;let B=qe(k.view)??null;if(k.backdrop===u&&Sr(B,s))return;u=k.backdrop,s=B,j={type:"backdrop",backdrop:u,...s?{view:s}:{}};for(let E of[...te])E(u,s)}if(k.type==="turn"){let B=y==="remote"&&l&&!c&&o[0]?.reason==="turn"?St(k.players):void 0,E=h[0];if(!B||E===void 0||m.indexOf(B[0])<=m.indexOf(E))return;c=!0,h=Object.freeze(B),j={type:"turn",players:[...B]}}if(k.type==="picture-result"){let B=Et(k);B?.id!==void 0&&A.get(B.id)?.(B.result);return}if(k.type==="capabilities"){if(typeof k.pictures!="boolean"||k.pictures===x)return;x=k.pictures,j={type:"capabilities",pictures:x}}if(k.type==="cursor"){let B=y==="remote"?At(k):void 0;if(!B)return;j=B,W()?.update(B)}(k.type==="pause"||k.type==="break-start"||k.type==="turn")&&R?.cancel(),k.type==="break-start"&&(l=o.length>0);for(let B of a.get(k.type)??[])B(j);k.type==="break-done"&&(l=c=!1,o.shift()?.done(k.shown))}else return})})}var Sr=(e,t)=>e===t||e!==null&&t!==null&&e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h;var nt={};un(nt,{BAND_BODY:()=>ae,DEFAULT_AVATAR:()=>tt,avatarById:()=>Ut,avatarShapes:()=>Ee,drawShapes:()=>we,frameOf:()=>Ae,iconShapes:()=>Qt});function sn(e){let t=an(),r=tn(t);e?.dataset.mute!=="manual"&&lt(t);let n=Object.assign(r,{avatars:{...nt}});window.FabiPlay=n;let a=e?.dataset.keys;a&&r.keys(ct(a));let o=e?.dataset.pointer;return o&&r.pointer({hand:o==="left"||o==="right"?o:"any"}),e?.dataset.ready!=="manual"&&(document.readyState==="complete"?r.ready():window.addEventListener("load",()=>r.ready(),{once:!0})),n}sn(document.currentScript);})();
@@ -113,6 +113,21 @@
113
113
  "enum": ["auto", "fixed"],
114
114
  "description": "Optional, \"auto\" by default: the screen zooms in on children standing far away (up to 1.8×), so every child's avatar is about the same size near or far; the view changes only at calibration and in breaks, never during play. \"fixed\": always the whole camera image (for a game drawn on exact spots of the live video)."
115
115
  },
116
+ "cover": {
117
+ "type": "string",
118
+ "description": "Optional: the game's cover, its card in the catalogue (TV carousel, phone, admin). A 16:9 image (1280×720 recommended, at most 150 KB; JPEG is the safest on old TV browsers): a path relative to the game's address, with the same rules as entry (no scheme, no leading /, no backslash, no \".\" or \"..\" segments), up to 128 characters, ending in lowercase .jpg, .jpeg, .png or .webp. The review checks the file; absent or broken, the catalogue shows another image.",
119
+ "pattern": "^(?:[A-Za-z0-9_][A-Za-z0-9_-]*(?:\\.[A-Za-z0-9_-]+)*/)*[A-Za-z0-9_][A-Za-z0-9_-]*(?:\\.[A-Za-z0-9_-]+)*\\.(?:jpg|jpeg|png|webp)$",
120
+ "maxLength": 128,
121
+ "examples": ["cover.jpg"]
122
+ },
123
+ "orientations": {
124
+ "type": "array",
125
+ "description": "Optional, [\"landscape\"] by default: the screen orientations the game can be played in. A phone alone (Play here) is held upright and offers only games that list \"portrait\"; the TV and the tablet are landscape. Lay out from the real viewport size all the same; the SDK's play.orientation says the one the game started in.",
126
+ "items": { "enum": ["landscape", "portrait"] },
127
+ "minItems": 1,
128
+ "uniqueItems": true,
129
+ "examples": [["landscape", "portrait"]]
130
+ },
116
131
  "intro": {
117
132
  "type": "object",
118
133
  "description": "Optional: Fabi explains the game on the TV before calibration, in 1 to 4 steps. Each step: one sentence (Italian and English, up to 90 characters; or one per age range) over an image of the game or a move shown with the children's avatars. The voice is generated by Fabi Play at publication from the text. Without intro the game goes straight to calibration; an invalid one is skipped by the TV.",