@fabiplay/engine 0.0.0-stage → 0.9.1
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/LICENSE +78 -0
- package/README.md +113 -2
- package/dist/fabi-play-engine.d.ts +2423 -0
- package/dist/fabi-play-engine.js +1 -0
- package/dist/fabi-play-engine.lite.d.ts +2423 -0
- package/dist/fabi-play-engine.lite.js +1 -0
- package/dist/fabi-play-engine.lite.umd.js +6969 -0
- package/dist/fabi-play-engine.lite.umd.min.js +1 -0
- package/dist/fabi-play-engine.umd.js +9340 -0
- package/dist/fabi-play-engine.umd.min.js +1 -0
- package/dist/index.d.ts +2406 -0
- package/dist/index.development.js +6850 -0
- package/dist/index.js +105 -0
- package/dist/integrity.json +15 -0
- package/package.json +80 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{var so=Object.defineProperty,bi=Object.defineProperties;var yi=Object.getOwnPropertyDescriptors;var hr=Object.getOwnPropertySymbols;var oo=Object.prototype.hasOwnProperty,ao=Object.prototype.propertyIsEnumerable;var wt=Math.pow,Gr=(r,t,e)=>t in r?so(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))oo.call(t,e)&&Gr(r,e,t[e]);if(hr)for(var e of hr(t))ao.call(t,e)&&Gr(r,e,t[e]);return r},Ie=(r,t)=>bi(r,yi(t));var en=(r,t)=>{var e={};for(var n in r)oo.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&hr)for(var n of hr(r))t.indexOf(n)<0&&ao.call(r,n)&&(e[n]=r[n]);return e};var xi=(r,t)=>{for(var e in t)so(r,e,{get:t[e],enumerable:!0})};var p=(r,t,e)=>Gr(r,typeof t!="symbol"?t+"":t,e);var lt=(r,t,e)=>new Promise((n,s)=>{var o=l=>{try{i(e.next(l))}catch(c){s(c)}},a=l=>{try{i(e.throw(l))}catch(c){s(c)}},i=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);i((e=e.apply(r,t)).next())});var $=typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{};var Ws={};xi(Ws,{AnimatedSprite:()=>Xe,Atlas:()=>Mt,AvatarPainter:()=>Wt,AvatarsNode:()=>tr,BitmapFont:()=>An,DEFAULT_FONT:()=>ps,EASE:()=>At,Group:()=>Vt,HALO:()=>Xt,MAX_LAYERS:()=>Vn,NameTags:()=>Rt,Node:()=>We,NodePool:()=>nr,Particles:()=>hn,STAGE_HEIGHT:()=>Se,Shape:()=>nt,ShelfPacker:()=>qn,Sound:()=>Tn,Sprite:()=>ze,TIERS:()=>at,Text:()=>ot,Timeline:()=>En,Tweens:()=>Rn,avatarPortrait:()=>Ra,blur:()=>ai,brightness:()=>Za,colorMatrix:()=>oi,contrast:()=>Ja,createAvatarRenderer:()=>Ea,createEngine:()=>Wa,createRenderer:()=>gn,dropShadow:()=>ii,grayscale:()=>ti,handsOf:()=>Ir,hits:()=>Jn,hueRotate:()=>ri,invert:()=>si,nodePool:()=>fi,packColor:()=>vt,parseBMFont:()=>Sn,parseColor:()=>Te,pickTier:()=>Br,playerColor:()=>Mn,rendererOrder:()=>fs,rng:()=>Ho,saturate:()=>ei,sepia:()=>ni,shader:()=>li,shapeBounds:()=>Or,tier:()=>mt,tint:()=>Qa,touching:()=>Nr,wrists:()=>ys});var Ur=33,q={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},lo=["3-5","6-8","9-12"],gi=r=>lo.includes(r);var ki=4,Bn=["#EE6A43","#6FA0E0","#8CC9A0","#C49BE0"];var co={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},wi=co["6-8"],Vr=(r,t)=>{let e=gi(t)?co[t]:wi;return e[Number.isInteger(r)&&r>=0?r%e.length:0]};var Wr=(r,t)=>r?{x:r.x+t.x*r.w,y:r.y+t.y*r.h}:{x:t.x,y:t.y},vi=.5,fr={left:1.6,top:1.6,w:3.2,h:3},Ai=1.2;function uo(r,t,e={}){let n=Array.isArray(r)?r:r.body;if(!Array.isArray(n))return null;let s=t==="left"?q.leftWrist:q.rightWrist,o=m=>{var g;return Dn(n[m*3])&&Dn(n[m*3+1])&&((g=n[m*3+2])!=null?g:0)>=vi?m:-1};if(o(s)<0)return null;let a=n[s*3],i=n[s*3+1];if(e.orientation!=="portrait")return Wr(e.view,{x:a,y:i});if(o(q.leftShoulder)<0||o(q.rightShoulder)<0)return null;let l=q.leftShoulder*3,c=q.rightShoulder*3,u=(n[l]+n[c])/2,f=(n[l+1]+n[c+1])/2,h=q.leftHip*3,b=q.rightHip*3,y=(n[h]+n[b])/2,x=(n[h+1]+n[b+1])/2,d=Dn(y)&&Dn(x)?Math.hypot(y-u,x-f):0;return(o(q.leftHip)<0||o(q.rightHip)<0)&&(d=Math.max(d,Ai*Math.hypot(n[l]-n[c],n[l+1]-n[c+1]))),d=Math.max(d,.01),{x:io((a-u+fr.left*d)/(fr.w*d)),y:io((i-f+fr.top*d)/(fr.h*d))}}var Si=300,tn=class{constructor(t=Si){p(this,"holdMs",t);p(this,"last",new Map)}static key(t,e){return t*2+(e==="right"?1:0)}at(t,e,n){let s=this.last.get(t);return e?(s?(s.x=e.x,s.y=e.y,s.t=n):this.last.set(t,{x:e.x,y:e.y,t:n}),e):s?n-s.t<=this.holdMs?{x:s.x,y:s.y}:(this.last.delete(t),null):null}clear(){this.last.clear()}},Mi=.25,ho=Object.freeze({top:0,bottom:0,left:0,right:0});function fo(r){if(!Ti(r))return;let t=e=>Dn(e)?Math.min(Math.max(e,0),Mi):0;return{top:t(r.top),bottom:t(r.bottom),left:t(r.left),right:t(r.right)}}var hc=16/9;var Ti=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),Dn=r=>typeof r=="number"&&Number.isFinite(r),io=r=>Math.min(Math.max(r,0),1);var Ei=12,Ri=Ur*4,Ci=r=>Ei+r*Ri,fc=Ci(ki);var Fi=r=>r.startsWith("fabi-play.")?"fablee-play.".concat(r.slice(10)):null;function po(r,t,e=Fi(t)){if(!(!r||!e))try{let n=r.getItem(e);if(n===null)return;r.getItem(t)===null&&r.setItem(t,n),r.removeItem(e)}catch(n){}}var Ne="#4a382c",ve="#2b2118",Ve="#1c1f2b",mo="#fbefe3",Ke="#f4897a",zn="#3a2a22",Xr=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:mo,accent:"#ffd9c2",outline:ve,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:zn,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:mo,accent:"#5a3426",outline:ve,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:zn,muzzle:"band",cheeks:Ke},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:Ne},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:Ke},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:Ne},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:zn,muzzle:"oval",cheeks:Ke},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:Ne,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:Ke},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:Ne,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:Ne,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:Ne},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:ve},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:Ke},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:ve,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:ve},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:Ve,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:Ve,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:ve},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:ve,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:Ke},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:Ne},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:ve},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:Ke},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:Ne,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:Ne,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:Ve},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:ve},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:ve,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:Ne,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:Ke},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:Ne,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:zn,muzzle:"oval",cheeks:Ke},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:Ne,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:Ke},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:Ne,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:Ke},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:ve,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:ve,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:zn,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:ve,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:ve,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:Ve,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:Ve,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:Ve,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:Ve,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:Ve,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:Ve,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:Ve,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:Ve,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:Ve,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:ve},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:ve,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 de={M:0,L:1,Q:2,C:3,Z:4},bo=[2,2,4,6,0];function nn(r,t){for(let e of t)Pi(r,e)}function Pi(r,t){var e,n,s,o,a;if(t.k==="group"){r.save(),r.translate(t.x,t.y),t.rot&&r.rotate(t.rot),t.s!==void 0&&t.s!==1&&r.scale(t.s,t.s),t.alpha!==void 0&&(r.globalAlpha*=t.alpha),nn(r,t.items),r.restore();return}switch(r.save(),t.alpha!==void 0&&(r.globalAlpha*=t.alpha),r.beginPath(),t.k){case"circle":r.arc(t.x,t.y,Math.max(t.r,0),0,Math.PI*2);break;case"ellipse":r.ellipse(t.x,t.y,Math.max(t.rx,0),Math.max(t.ry,0),(e=t.rot)!=null?e:0,0,Math.PI*2);break;case"rect":_i(r,t);break;case"path":typeof t.d=="string"?Oi(r,t.d):Li(r,t.d);break;case"line":r.moveTo((n=t.pts[0])!=null?n:0,(s=t.pts[1])!=null?s:0);for(let i=2;i+1<t.pts.length;i+=2)r.lineTo(t.pts[i],t.pts[i+1]);break}r.lineCap="round",r.lineJoin="round",t.fill&&t.k!=="line"&&(r.fillStyle=t.fill,r.fill()),t.stroke&&((o=t.lw)!=null?o:1)>0&&(r.strokeStyle=t.stroke,r.lineWidth=(a=t.lw)!=null?a:1,r.stroke()),r.restore()}function _i(r,t){let e=Math.max(0,Math.min(t.r,t.w/2,t.h/2));r.translate(t.x,t.y),t.rot&&r.rotate(t.rot);let n=-t.w/2,s=-t.h/2;r.moveTo(n+e,s),r.lineTo(n+t.w-e,s),r.quadraticCurveTo(n+t.w,s,n+t.w,s+e),r.lineTo(n+t.w,s+t.h-e),r.quadraticCurveTo(n+t.w,s+t.h,n+t.w-e,s+t.h),r.lineTo(n+e,s+t.h),r.quadraticCurveTo(n,s+t.h,n,s+t.h-e),r.lineTo(n,s+e),r.quadraticCurveTo(n,s,n+e,s),r.closePath()}function Li(r,t){for(let e=0;e<t.length;){let n=t[e++];if(n===de.M)r.moveTo(t[e],t[e+1]);else if(n===de.L)r.lineTo(t[e],t[e+1]);else if(n===de.Q)r.quadraticCurveTo(t[e],t[e+1],t[e+2],t[e+3]);else if(n===de.C)r.bezierCurveTo(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else if(n===de.Z)r.closePath();else return;e+=bo[n]}}function jr(r){var e;if(typeof r=="string")return((e=r.match(/-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?e:[]).map(Number);let t=[];for(let n=0;n<r.length;){let s=bo[r[n++]];if(s===void 0)break;for(let o=0;o<s;o++)t.push(r[n+o]);n+=s}return t}function Oi(r,t){var a;let e=(a=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?a:[],n="",s=0,o=()=>Number(e[s++]);for(;s<e.length;){let i=e[s];if(/[MLQCZ]/i.test(i)&&(n=i.toUpperCase(),s++,n==="Z")){r.closePath();continue}n==="M"?(r.moveTo(o(),o()),n="L"):n==="L"?r.lineTo(o(),o()):n==="Q"?r.quadraticCurveTo(o(),o(),o(),o()):n==="C"?r.bezierCurveTo(o(),o(),o(),o(),o(),o()):s++}}var ce=r=>{let t=Math.round(r*100)/100;return t===0?0:t};function ie(r,t=.5){let e=r.length;if(e<3)return[];let n=(i,l,c)=>({x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}),s=Math.min(Math.max(t,0),.5),o=n(r[0],r[1],s),a=[de.M,ce(o.x),ce(o.y)];for(let i=1;i<=e;i++){let l=r[(i-1)%e],c=r[i%e],u=r[(i+1)%e],f=n(l,c,1-s),h=n(c,u,s);a.push(de.L,ce(f.x),ce(f.y),de.Q,ce(c.x),ce(c.y),ce(h.x),ce(h.y))}return a.push(de.Z),a}function ae(r,t=1){let e=r.length;if(e<3)return[];let n=[de.M,ce(r[0].x),ce(r[0].y)],s=t/6;for(let o=0;o<e;o++){let a=r[(o-1+e)%e],i=r[o],l=r[(o+1)%e],c=r[(o+2)%e];n.push(de.C,ce(i.x+(l.x-a.x)*s),ce(i.y+(l.y-a.y)*s),ce(l.x-(c.x-i.x)*s),ce(l.y-(c.y-i.y)*s),ce(l.x),ce(l.y))}return n.push(de.Z),n}function rn(r){let t=r.length;if(t<2)return[];let e=[de.M,ce(r[0].x),ce(r[0].y)];for(let n=0;n<t-1;n++){let s=r[Math.max(n-1,0)],o=r[n],a=r[n+1],i=r[Math.min(n+2,t-1)];e.push(de.C,ce(o.x+(a.x-s.x)/6),ce(o.y+(a.y-s.y)/6),ce(a.x-(i.x-o.x)/6),ce(a.y-(i.y-o.y)/6),ce(a.x),ce(a.y))}return e}var ct="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 xe="#ffffff",Z=[-1,1],yo="#3a2420",xo="#f2808f",qr="#26324a",Ii="#ffd84a",me=(...r)=>{let t=[];for(let e=0;e+1<r.length;e+=2)t.push({x:r[e],y:r[e+1]});return t};function pr(r,t){var u,f,h,b,y,x,d;let e=r.palette,n=[],s={stroke:e.outline,lw:t},o=m=>r.headExtras.includes(m),a=(m,g)=>{var v,k;return(k=(v=r.extraColors)==null?void 0:v[m])!=null?k:g};if(o("mane")){for(let g=0;g<12;g++){let v=g/12*Math.PI*2;n.push(M({k:"circle",x:Math.cos(v)*1.02,y:Math.sin(v)*1+.04,r:.42,fill:a(0,e.accent)},s))}n.push({k:"circle",x:0,y:.04,r:1.08,fill:a(0,e.accent)})}if(o("rainbow-mane")){let m=(u=r.extraColors)!=null?u:["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([v,k,R,F,I],A)=>n.push(M({k:"ellipse",x:v,y:k,rx:R,ry:F,rot:I,fill:m[A%m.length]},s)))}if(o("spikes"))for(let m of[-.55,0,.55]){let g=Bt(m,1.48),v=Bt(m-.32,.86),k=Bt(m+.32,.86);n.push(M({k:"path",d:ie([v,g,k],.22),fill:e.accent},s))}if(o("curl")&&n.push(M({k:"path",d:ae([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:e.body},s)),o("wool"))for(let m=0;m<=8;m++){let g=-1.75+m/8*3.5;n.push(M({k:"circle",x:Math.sin(g)*.98,y:-Math.cos(g)*.92-.04,r:.34,fill:e.body},s))}if(o("crest")&&[-.38,0,.38].forEach((m,g)=>{let v=Bt(m,1.12);n.push(M({k:"ellipse",x:v.x,y:v.y,rx:.15,ry:.42,rot:m,fill:a(g,e.accent)},s))}),o("plume")&&n.push(M({k:"path",d:ae(me(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:e.accent},s)),o("locks")&&n.push(M({k:"path",d:ae(me(-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:(f=e.hair)!=null?f:e.outline},s)),o("bun")&&n.push(M({k:"circle",x:.04,y:-1.14,r:.4,fill:(h=e.hair)!=null?h:e.outline},s)),o("ninja-hood"))for(let[m,g]of[[.35,.5],[.85,.42]])n.push(M({k:"ellipse",x:1+Math.cos(m)*g*.8,y:-.5+Math.sin(m)*g*.8,rx:g,ry:.11,rot:m,fill:e.accent},s));if(o("bandana"))for(let[m,g]of[[Math.PI-.5,.42],[Math.PI-1,.36]])n.push(M({k:"ellipse",x:-.98+Math.cos(m)*g*.8,y:-.36+Math.sin(m)*g*.8,rx:g,ry:.12,rot:m,fill:e.accent},s));if(o("ruff"))for(let m of Z)n.push(M({k:"path",d:ie(me(m*.7,-.3,m*1.32,0,m*1.02,.18,m*1.26,.46,m*.86,.56,m*.98,.84,m*.4,.7),.25),fill:e.body},s));if(r.face.eyesOnTop)for(let m of Z)n.push(M({k:"circle",x:m*.46,y:-.72,r:.38,fill:e.body},s));n.push(...$i(r,t)),n.push(Ni(r,s));let i=r.face.muzzle,l=e.belly;if(i==="oval"&&n.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:l}),i==="monkey"){for(let m of Z)n.push({k:"circle",x:m*.32,y:-.04,r:.38,fill:l});n.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:l})}if(i==="heart"){for(let m of Z)n.push({k:"circle",x:m*.36,y:.02,r:.5,fill:l});n.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:l})}if(i==="disc")for(let m of Z)n.push({k:"circle",x:m*.4,y:.02,r:.44,fill:l});if(i==="cheeks")for(let m of Z)n.push({k:"ellipse",x:m*.4,y:.44,rx:.44,ry:.32,fill:l});if(i==="band"&&n.push({k:"path",d:Hi(r,t),fill:l}),o("stripes")&&r.head==="snout-long"){let m=a(0,e.outline);for(let[g,v,k,R]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])n.push({k:"line",pts:[g,v,k,R],stroke:m,lw:.11})}else if(o("stripes")){let m=a(0,e.outline);n.push({k:"line",pts:[0,-.97,0,-.66],stroke:m,lw:.13});for(let g of Z)n.push({k:"line",pts:[g*.3,-.93,g*.24,-.7],stroke:m,lw:.1}),n.push({k:"line",pts:[g*.98,-.05,g*.74,0],stroke:m,lw:.1}),n.push({k:"line",pts:[g*.94,.22,g*.74,.22],stroke:m,lw:.09})}if(o("spots")){let m=a(1,e.belly);n.push({k:"circle",x:-.55,y:-.5,r:.15,fill:m}),n.push({k:"circle",x:.58,y:-.42,r:.11,fill:m}),n.push({k:"circle",x:.22,y:-.76,r:.09,fill:m})}if(r.head==="snout-long")for(let[m,g,v]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])n.push({k:"ellipse",x:m,y:g,rx:v,ry:v*.8,rot:-.3,fill:e.outline,alpha:.85});if(o("forehead")&&n.push({k:"path",d:ae(me(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:a(0,e.accent)}),o("eye-spot")&&n.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:(b=e.ears)!=null?b:e.accent}),o("gills"))for(let m of Z)for(let g of[0,.12,.24])n.push({k:"path",d:"M".concat(m*(.66+g)," 0.06 Q").concat(m*(.6+g)," 0.22 ").concat(m*(.66+g)," 0.38"),stroke:e.accent,lw:t*.9});let c=(y=e.hair)!=null?y:e.outline;if(o("hair")&&n.push(M({k:"path",d:ae(me(-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:c},s)),o("locks")&&n.push(M({k:"path",d:ae(me(-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:c},s)),o("bun")&&n.push(M({k:"path",d:ae(me(-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:c},s)),o("curls")){for(let m=0;m<7;m++){let g=Bt(-1.3+m/6*2.6,.86);n.push(M({k:"circle",x:g.x,y:g.y,r:.3,fill:c},s))}n.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:c})}if(o("ninja-hood")&&(n.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:(x=e.skin)!=null?x:xe,stroke:e.outline,lw:t*.8}),n.push(M({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:e.accent},s))),o("domino")){n.push(M({k:"path",d:ae(me(-.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:e.accent},s));for(let m of Z)n.push({k:"ellipse",x:m*.38,y:0,rx:.19,ry:.13,fill:xe})}if(n.push(...Gi(r,t)),o("brows"))for(let m of Z)n.push({k:"line",pts:[m*.72,-.5,m*.14,-.3],stroke:e.accent,lw:.16});if(r.face.brows)for(let m of Z)n.push({k:"line",pts:[m*.2,-.2,m*.54,-.28],stroke:r.face.brows,lw:.09});if(n.push(...Ui(r,t)),r.face.cheeks)for(let m of Bi(r))n.push({k:"ellipse",x:m.x,y:m.y,rx:.15,ry:.1,fill:r.face.cheeks,alpha:.8});if(o("whiskers"))for(let m of Z)for(let g of[-.1,.06])n.push({k:"line",pts:[m*.62,.38+g,m*1.06,.3+g*2.2],stroke:e.outline,lw:t*.7,alpha:.75});if(o("rainbow-mane")){let m=(d=r.extraColors)!=null?d:["#f59ac0","#fbd46a","#8fd3f4"];n.push(M({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:m[0]},s)),n.push(M({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:m[1%m.length]},s))}if(r.ears==="unicorn"){let m=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];n.push(M({k:"path",d:ie(m,.12),fill:e.accent},s));for(let g of[-1,-1.2,-1.4]){let v=.16*((g+1.72)/.88);n.push({k:"line",pts:[-v,g+.04,v,g-.04],stroke:e.outline,lw:t*.7,alpha:.6})}}if(o("flower-crown")){let m=[a(1,"#f7a8cf"),a(2,"#fff3a0"),a(3,xe)];for(let g of[-.84,-.28,.28,.84]){let v=Bt(g,.9);n.push({k:"ellipse",x:v.x,y:v.y,rx:.14,ry:.07,rot:g+.5,fill:"#7cc76a",stroke:e.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((g,v)=>{let k=Bt(g,.9),R=v===2?.13:.11;for(let F=0;F<5;F++){let I=g+F/5*Math.PI*2;n.push({k:"circle",x:k.x+Math.sin(I)*R,y:k.y-Math.cos(I)*R,r:R*.82,fill:m[v%m.length],stroke:e.outline,lw:t*.7})}n.push({k:"circle",x:k.x,y:k.y,r:R*.62,fill:m[v%m.length]}),n.push({k:"circle",x:k.x,y:k.y,r:R*.42,fill:e.accent})})}if(o("helmet")){for(let m of Z)n.push(M({k:"rect",x:m*1,y:.05,w:.26,h:.56,r:.12,fill:e.accent},s));n.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:xe,lw:.1,alpha:.9})}if(o("bolts"))for(let m of Z)n.push(M({k:"rect",x:m*1.08,y:.08,w:.2,h:.44,r:.08,fill:e.accent},s));if(o("tuft")&&n.push(M({k:"path",d:ae([{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:e.body},s)),o("eggshell")&&n.push(M({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:a(0,xe)},s)),o("wool"))for(let[m,g]of[[-.36,-.84],[.02,-.94],[.4,-.82]])n.push(M({k:"circle",x:m,y:g,r:.27,fill:e.body},s));if(o("stripe")&&n.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:e.accent}),o("eye-patch")&&(n.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:e.outline,lw:.07}),n.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:e.outline})),o("bandana")){n.push(M({k:"path",d:ae(me(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:e.accent},s));for(let[m,g]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])n.push({k:"circle",x:m,y:g,r:.06,fill:xe,alpha:.85});n.push(M({k:"circle",x:-.98,y:-.34,r:.15,fill:e.accent},s))}if(o("cap")){for(let m of Z)n.push({k:"line",pts:[m*.98,-.2,m*.5,.82,-m*.05,.98],stroke:e.outline,lw:.06});n.push(M({k:"path",d:ae(me(-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:e.accent},s)),n.push(M({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:e.accent},s)),n.push(M({k:"circle",x:.5,y:-.82,r:.15,fill:a(0,xe)},s));for(let m of[-.42,-.14])n.push({k:"line",pts:[m,-1.04,m+.02,-.78],stroke:e.outline,lw:.07,alpha:.7})}if(o("safari-hat")&&(n.push(M({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:e.accent},s)),n.push(M({k:"path",d:ae(me(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:e.accent},s)),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:a(1,e.outline),stroke:e.outline,lw:t*.8})),o("wizard-hat")){n.push(M({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:e.accent},s)),n.push(M({k:"path",d:ie(me(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:e.accent},s));let m=a(0,Ii);for(let[g,v,k]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])n.push({k:"group",x:g,y:v,s:k,items:[{k:"path",d:ct,fill:m}]})}if(o("dive-mask")){for(let g of Z)n.push({k:"line",pts:[g*.7,-.04,g*1,-.12],stroke:e.outline,lw:.2},{k:"line",pts:[g*.7,-.04,g*1,-.12],stroke:e.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:e.outline,lw:.2}),n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:e.accent,lw:.11}),n.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:xe,lw:.06,alpha:.9});let m="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";n.push({k:"path",d:m,stroke:e.outline,lw:.24},{k:"path",d:m,stroke:e.accent,lw:.13})}return n}function Ni(r,t){var n;let e=r.headExtras.includes("ninja-hood")?r.palette.body:(n=r.palette.skin)!=null?n:r.palette.body;switch(r.head){case"round":return M({k:"circle",x:0,y:0,r:1,fill:e},t);case"wide":return M({k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:e},t);case"tall":return M({k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:e},t);case"square":return M({k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:e},t);case"bucket":return M({k:"path",d:ie(me(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:e},t);case"snout-long":return M({k:"path",d:ae(Di,.95),fill:e},t);case"bulb":return M({k:"path",d:ae([{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:e},t)}}var Di=me(.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 go(r,t,e){return r.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:Z.map(n=>({x:n*t,y:e,k:1}))}function Bi(r){return r.head==="snout-long"?me(-.66,-.14,.66,.1):Z.map(t=>({x:t*.64,y:.3}))}function zi(r){return r.head==="round"?{cy:0,rx:1,ry:1}:r.head==="tall"?{cy:-.02,rx:.94,ry:1.04}:{cy:.03,rx:1.12,ry:.94}}function Hi(r,t){let{cy:e,rx:n,ry:s}=zi(r),o=n-t/2,a=s-t/2,i=.15,l=Math.asin(Math.min(1,(i-e)/a)),c=Math.cos(l)*o,u=y=>Math.round(y*100)/100||0,f=[de.M,u(-c),i],h=[[-.84*c,.02,-.53*c,.06,-.32*c,.24],[-.17*c,.11,.17*c,.11,.32*c,.24],[.53*c,.06,.84*c,.02,c,i]];for(let y of h)f.push(de.C,...y.map(u));let b=24;for(let y=1;y<=b;y++){let x=l+(Math.PI-2*l)*y/b;f.push(de.L,u(Math.cos(x)*o),u(e+Math.sin(x)*a))}return f.push(de.Z),f}function $i(r,t){var o,a,i,l,c;let e=r.palette,n={stroke:e.outline,lw:t},s=[];for(let u of Z)switch(r.ears){case"pointy":case"unicorn":{let f=r.ears==="unicorn"?.8:1,h={x:u*.3,y:-.82},b={x:u*.86,y:-.82-.62*f},y={x:u*.94,y:-.36};s.push(M({k:"path",d:ie([h,b,y],.2),fill:e.body},n));let x={x:(h.x+b.x+y.x)/3,y:(h.y+b.y+y.y)/3},d=[h,b,y].map(m=>({x:x.x+(m.x-x.x)*.55,y:x.y+(m.y-x.y)*.55+.04}));s.push({k:"path",d:ie(d,.25),fill:e.accent});break}case"round":s.push(M({k:"circle",x:u*.72,y:-.72,r:.36,fill:(o=e.ears)!=null?o:e.body},n)),e.ears||s.push({k:"circle",x:u*.74,y:-.74,r:.19,fill:e.accent});break;case"big-round":s.push(M({k:"circle",x:u*.96,y:-.46,r:.52,fill:e.body},n)),s.push({k:"circle",x:u*1,y:-.44,r:.32,fill:e.accent});break;case"long":s.push(M({k:"ellipse",x:u*.38,y:-1.42,rx:.25,ry:.68,rot:u*.14,fill:e.body},n)),s.push({k:"ellipse",x:u*.39,y:-1.36,rx:.12,ry:.48,rot:u*.14,fill:e.accent});break;case"side":s.push(M({k:"circle",x:u*1,y:.02,r:.34,fill:e.body},n)),s.push({k:"circle",x:u*1.02,y:.02,r:.2,fill:e.belly});break;case"tufts":s.push(M({k:"path",d:ie([{x:u*.3,y:-.84},{x:u*1.22,y:-1.12},{x:u*.92,y:-.42}],.16),fill:e.body},n)),s.push({k:"line",pts:[u*.62,-.78,u*1,-.98],stroke:e.accent,lw:.08});break;case"antennae":{let f={x:u*.62,y:-1.42};s.push({k:"path",d:"M".concat(u*.3," -0.8 Q").concat(u*.36," -1.2 ").concat(f.x," ").concat(f.y),stroke:e.outline,lw:t*2.6}),s.push({k:"path",d:"M".concat(u*.3," -0.8 Q").concat(u*.36," -1.2 ").concat(f.x," ").concat(f.y),stroke:e.body,lw:t*1.2}),s.push(M({k:"circle",x:f.x,y:f.y,r:.17,fill:e.accent},n));break}case"floppy":s.push(M({k:"ellipse",x:u*.96,y:.02,rx:.3,ry:.62,rot:-u*.36,fill:(a=e.ears)!=null?a:e.body},n));break;case"droopy":s.push(M({k:"ellipse",x:u*1.04,y:-.22,rx:.4,ry:.18,rot:u*.32,fill:(i=e.skin)!=null?i:e.body},n)),s.push({k:"ellipse",x:u*1.08,y:-.2,rx:.24,ry:.08,rot:u*.32,fill:e.accent});break;case"pixie":s.push(M({k:"path",d:ie(me(u*.86,-.22,u*1.36,-.5,u*1.02,.26),.28),fill:(l=e.skin)!=null?l:e.body},n)),s.push({k:"line",pts:[u*.98,-.12,u*1.16,-.3],stroke:e.accent,lw:t*.8,alpha:.5});break;case"human":s.push(M({k:"ellipse",x:u*.98,y:.06,rx:.17,ry:.23,fill:(c=e.skin)!=null?c:e.body},n));break;case"horns":{let f=[{x:u*.3,y:-.84},{x:u*.6,y:-1.5},{x:u*.66,y:-.68}];s.push(M({k:"path",d:ie(f,.18),fill:e.accent},n));break}}return r.ears==="fin"&&s.push(M({k:"path",d:ie(me(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:e.body},n)),r.ears==="antenna"&&(s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.outline,lw:t*2.6}),s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.limbs,lw:t*1.2}),s.push(M({k:"circle",x:0,y:-1.5,r:.18,fill:e.accent},n))),s}function Gi(r,t){var c,u,f,h,b,y,x;let e=r.palette,n=r.face,s=[],o=e.outline,a=n.eyesOnTop?.46:.4,i=n.eyesOnTop?-.72:-.04,l=(d,m,g)=>({k:"circle",x:d,y:m,r:g,fill:xe});switch(n.eyes){case"dot":for(let d of go(r,a,i))s.push({k:"ellipse",x:d.x,y:d.y,rx:.12*d.k,ry:.155*d.k,fill:o}),s.push(l(d.x+.04*d.k,d.y-.06*d.k,.045*d.k));break;case"bead":for(let d of go(r,a,i))s.push({k:"ellipse",x:d.x,y:d.y,rx:.16*d.k,ry:.22*d.k,fill:o}),s.push(l(d.x+.05*d.k,d.y-.08*d.k,.065*d.k));break;case"big":for(let d of Z)n.eyeRing&&s.push({k:"circle",x:d*a,y:i,r:.36,fill:n.eyeRing,stroke:o,lw:t*.8}),s.push({k:"circle",x:d*a,y:i,r:.25,fill:xe,stroke:o,lw:t*.8}),s.push({k:"circle",x:d*a+d*-.03,y:i+.03,r:.14,fill:(c=n.eyeColor)!=null?c:o}),s.push(l(d*a+d*-.03+.05,i-.03,.05));break;case"mask":for(let d of Z)s.push({k:"ellipse",x:d*.4,y:0,rx:.24,ry:.32,rot:d*-.55,fill:e.limbs}),s.push({k:"circle",x:d*.4,y:-.02,r:.11,fill:xe}),s.push({k:"circle",x:d*.39,y:-0,r:.065,fill:o});break;case"screen":s.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:o,lw:t*.8});for(let d of Z)s.push({k:"ellipse",x:d*.36,y:0,rx:.2,ry:.24,fill:(u=n.eyeColor)!=null?u:"#7ff0ff",alpha:.3}),s.push({k:"ellipse",x:d*.36,y:0,rx:.12,ry:.16,fill:(f=n.eyeColor)!=null?f:"#7ff0ff"});break;case"almond":for(let d of Z)s.push({k:"ellipse",x:d*.42,y:-.02,rx:.3,ry:.2,rot:-d*.5,fill:(h=n.eyeColor)!=null?h:o}),s.push(l(d*.42-d*.07,-.08,.07));break;case"calm":for(let d of Z)s.push({k:"ellipse",x:d*.38,y:.02,rx:.085,ry:.12,fill:o}),s.push(l(d*.38+.03,-.02,.03));break;case"slit":s.push({k:"line",pts:[0,-.98,0,-.2],stroke:o,lw:t*.8,alpha:.5}),s.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:qr,stroke:o,lw:t*.8}),s.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:qr,stroke:o,lw:t*.8});for(let d of Z){s.push({k:"ellipse",x:d*.4,y:-.04,rx:.12,ry:.07,fill:(b=n.eyeColor)!=null?b:xe});for(let m of[.36,.56])s.push({k:"circle",x:d*.42,y:m,r:.05,fill:o,alpha:.6})}break;case"goggle":for(let d of Z)s.push({k:"circle",x:d*.9,y:0,r:.13,fill:e.accent,stroke:o,lw:t*.8});s.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:qr,stroke:o,lw:t*.8}),s.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:xe,lw:.07,alpha:.8});for(let d of Z)s.push({k:"path",d:"M".concat(d*.5," 0.04 Q").concat(d*.34," -0.08 ").concat(d*.16," 0.02"),stroke:(y=n.eyeColor)!=null?y:"#7fd6ff",lw:.08});for(let d of[-.18,0,.18])s.push({k:"line",pts:[d,.56,d,.72],stroke:o,lw:t*.8,alpha:.6});break;case"visor":s.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:o,lw:t*.8}),s.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:xe,lw:.08,alpha:.7});for(let d of Z)s.push({k:"ellipse",x:d*.28,y:.04,rx:.1,ry:.14,fill:(x=n.eyeColor)!=null?x:"#cfeeff"});break}return s}function Ui(r,t){let e=r.palette,n=r.face,s=[],o=n.eyes==="visor"?"#cfeeff":yo,a=t*1.05;switch(n.nose&&n.mouth!=="beak"&&(n.mouth==="cat"?s.push({k:"path",d:ie([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:n.nose,stroke:n.nose,lw:t*.6}):r.ears==="big-round"?s.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:n.nose}):s.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:n.nose})),n.mouth){case"smile":s.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:a});break;case"open":s.push({k:"path",d:"M-0.21 0.4 Q0 0.46 0.21 0.4 Q0.19 0.68 0 0.68 Q-0.19 0.68 -0.21 0.4 Z",fill:o,stroke:o,lw:t*.5}),s.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:xo});break;case"cat":s.push({k:"path",d:"M-0.19 0.4 Q-0.1 0.5 0 0.37 Q0.1 0.5 0.19 0.4",stroke:o,lw:a});break;case"beak":s.push({k:"path",d:ie([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:e.accent,stroke:e.outline,lw:t*.8});break;case"teeth":s.push({k:"path",d:"M-0.36 0.34 Q0 0.44 0.36 0.34 Q0.28 0.66 0 0.66 Q-0.28 0.66 -0.36 0.34 Z",fill:o,stroke:o,lw:t*.5});for(let i of Z)s.push({k:"rect",x:i*.12,y:.43,w:.1,h:.1,r:.03,fill:xe});break;case"grill":s.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:e.outline,lw:t*.7});for(let i of[-.15,0,.15])s.push({k:"line",pts:[i,.51,i,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":s.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:o});break;case"smirk":s.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:o,lw:a});break;case"bill":s.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:e.accent,stroke:e.outline,lw:t*.8}),s.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:e.outline,lw:t*.7});for(let i of Z)s.push({k:"circle",x:i*.1,y:.28,r:.03,fill:e.outline});break;case"hook":s.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:yo}),s.push({k:"path",d:"M-0.3 0.12 Q0 -0.02 0.3 0.12 Q0.36 0.52 0.04 0.76 Q0.08 0.52 -0.08 0.46 Q-0.28 0.38 -0.3 0.12 Z",fill:e.accent,stroke:e.outline,lw:t*.8});break;case"toothy":{s.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}),s.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:xo});for(let i of[.12,.27,.42,.57,.72,.86]){let l=(1-i)*(1-i)*-1.4+2*(1-i)*i*-.5+i*i*.5,c=(1-i)*(1-i)*.1+2*(1-i)*i*.36+i*i*.2-.01;s.push({k:"path",d:ie(me(l-.08,c,l+.08,c,l,c+.14),.3),fill:xe})}for(let i of[.3,.7]){let l=(1-i)*(1-i)*.52+2*(1-i)*i*-.4+i*i*-1.3,c=(1-i)*(1-i)*.38+2*(1-i)*i*.78+i*i*.26+.01;s.push({k:"path",d:ie(me(l-.07,c,l+.07,c,l,c-.12),.3),fill:xe})}break}case"jaws":{s.push({k:"path",d:"M-0.5 0.3 Q0 0.5 0.5 0.3 Q0.38 0.72 0 0.72 Q-0.38 0.72 -0.5 0.3 Z",fill:o,stroke:o,lw:t*.5});for(let i of[-.34,-.17,0,.17,.34]){let l=.3+.4*(i+.5)*(.5-i)-.01;s.push({k:"path",d:ie(me(i-.075,l,i+.075,l,i,l+.13),.15),fill:xe})}break}}return s}var Bt=(r,t)=>({x:Math.sin(r)*t,y:-Math.cos(r)*t});var So=.5,tt={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ut={"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}},dr="6-8",br=(r,t)=>{var e;return t!==void 0&&r.band!=="all"&&((e=r.alsoIn)!=null&&e.includes(t))&&t in ut?t:r.band in ut?r.band:dr},Vi=ut[dr].head,Mo=.3,To=.12,Wi=.9,ko=.5,wo=.65,Xi=.35,ji=.2,qi=.25,Qe=(r,t)=>({x:r.x-t.x,y:r.y-t.y}),pe=(r,t)=>({x:r.x+t.x,y:r.y+t.y}),le=(r,t)=>({x:r.x*t,y:r.y*t}),zt=r=>Math.hypot(r.x,r.y),vo=(r,t)=>({x:(r.x+t.x)/2,y:(r.y+t.y)/2}),mr=r=>{let t=zt(r);return t>1e-9?{x:r.x/t,y:r.y/t}:{x:0,y:1}},Yi=(...r)=>r.every(Number.isFinite),Ki=r=>Math.atan2(Math.sin(r),Math.cos(r)),Qi=(r,t,e)=>Math.min(Math.max(r,t),e);function Eo(r,t,e=!1){return n=>{let s=r[n*3],o=r[n*3+1],a=r[n*3+2];return s===void 0||o===void 0||a===void 0||!Yi(s,o,a)?{x:0,y:0,ok:!1}:{x:t.x+(e?1-s:s)*t.w,y:t.y+o*t.h,ok:a>=So}}}function sn(r,t,e={}){var F,I;let n=Eo(r,t,e.mirrored),s=n(q.leftShoulder),o=n(q.rightShoulder);if(!s.ok||!o.ok)return null;let a=n(q.leftHip),i=n(q.rightHip),l=vo(s,o),c=zt(Qe(o,s)),u=a.ok&&i.ok,f=mr(Qe(o,s));c<1e-6&&(f={x:1,y:0});let h,b,y;if(u){let A=vo(a,i);b=zt(Qe(A,l)),b>=c*qi?h=mr(Qe(A,l)):(h={x:-f.y,y:f.x},h.y<0&&(h=le(h,-1))),y=Math.max(b,c*1.15)}else h={x:-f.y,y:f.x},h.y<0&&(h=le(h,-1)),y=c*1.15,b=y;y=Math.max(y,1e-6);let x={x:h.y,y:-h.x},d=Math.atan2(x.y,x.x),m=le(h,-1),g=(I=ut[(F=e.band)!=null?F:dr])!=null?I:ut[dr],v=g.head*y,k=pe(l,le(m,v*g.neck)),R=n(q.nose);if(R.ok){let A=pe(R,le(m,v*.15)),S=le(Qe(A,k),Xi),P=Math.min(1,v*ji/Math.max(zt(S),1e-6));k=pe(k,le(S,P))}return{S:l,r:x,d:h,U:y,L:b,hipsOk:u,head:k,headR:v,headRot:d+Zi(r,n,d,y),angle:d}}function Zi(r,t,e,n){let s=[[tt.leftEar,tt.rightEar],[tt.leftEye,tt.rightEye]];for(let[o,a]of s){let i=t(o),l=t(a);if(!i.ok||!l.ok||!(r[o*3+2]>=wo&&r[a*3+2]>=wo)||zt(Qe(l,i))<n*.05)continue;let c=Ki(Math.atan2(l.y-i.y,l.x-i.x)-e),u=Math.max(Math.abs(c)-To,0),f=Qi((Wi+ko-Math.abs(c))/ko,0,1);return Math.sign(c)*Math.min(u,Mo)*f}return 0}function Hn(r,t,e,n={}){var he,Ct,Cn,Fn,Pn,Ft,xt,qt,_n,Ln,On,Pt,In,Yt,Kt,Qt,rr,sr,_t,gt,or,ar,Zt;let s=br(t,n.band),o=ut[s],a=sn(r,e,Ie(M({},n),{band:s}));if(!a)return[];let i=Eo(r,e,n.mirrored),l=t.palette,{S:c,r:u,d:f,U:h,L:b}=a,y=C=>t.bodyExtras.includes(C),x=Math.max(1.2,h*.045),d={stroke:l.outline,lw:x},m=(C,N)=>({x:c.x+u.x*C+f.x*N,y:c.y+u.y*C+f.y*N}),g=C=>C.map(([N,V])=>m(N,V)),v=i(q.leftShoulder),k=i(q.rightShoulder),R=i(q.leftHip),F=i(q.rightHip),I=zt(Qe(k,v)),A=a.hipsOk?zt(Qe(F,R)):I*.7,S=Math.max(I/2+o.shoulderPad*h,o.shoulderMin*h),P=Math.max(A/2+o.hipPad*h,o.hipMin*h),H=-.1*h,z=b+o.bottom*h,B=[],G=[],L=[],U=[],Y=[],Q=(C,N,V,J)=>{let K=N.flatMap(be=>[be.x,be.y]);C.push({k:"line",pts:K,stroke:l.outline,lw:V+x*2}),C.push({k:"line",pts:K,stroke:J,lw:V})},Ee=o.leg*h*(y("strong-legs")?1.3:1),ue=o.arm*h*(y("tiny-arms")?.6:1),ke=Math.max(o.arm/.22,.9);if(a.hipsOk)for(let[C,N,V,J]of[[R,q.leftKnee,q.leftAnkle,-1],[F,q.rightKnee,q.rightAnkle,1]]){let K=i(N),be=i(V);if(!K.ok)continue;let je=pe(C,le(f,-.12*h)),Oe=be.ok?[je,K,be]:[je,K];Q(G,Oe,Ee,l.limbs),y("joints")&&G.push(M({k:"circle",x:K.x,y:K.y,r:.15*h*ke,fill:l.accent},d)),be.ok&&G.push(...tl(t,be,a,J,x,o.foot))}for(let[C,N,V,J]of[[v,q.leftElbow,q.leftWrist,-1],[k,q.rightElbow,q.rightWrist,1]]){let K=i(N),be=i(V);if(y("pauldrons")){let Ue=pe(C,le(f,.02*h));U.push(M({k:"ellipse",x:Ue.x,y:Ue.y,rx:.25*h,ry:.17*h,rot:a.angle+J*.25,fill:l.body},d));let qe=pe(Ue,le(f,.05*h));U.push({k:"ellipse",x:qe.x,y:qe.y,rx:.17*h,ry:.07*h,rot:a.angle+J*.25,fill:l.belly})}if(!K.ok)continue;let Oe=o.armsOverHead&&(K.x-c.x)*f.x+(K.y-c.y)*f.y<-.25*h?Y:U,Jt=pe(C,le(f,.04*h));if(Q(Oe,be.ok?[Jt,K,be]:[Jt,K],ue,l.limbs),y("joints")&&Oe.push(M({k:"circle",x:K.x,y:K.y,r:.13*h*ke,fill:l.accent},d)),!be.ok)continue;let Ce=mr(Qe(be,K)),Ge=pe(be,le(Ce,.05*h));if(y("feathers"))for(let Ue of[-.55,0,.55]){let qe=Math.cos(Ue),Lt=Math.sin(Ue)*J,Ye={x:Ce.x*qe-Ce.y*Lt,y:Ce.x*Lt+Ce.y*qe},Ot=pe(Ge,le(Ye,.16*h));Oe.push(M({k:"ellipse",x:Ot.x,y:Ot.y,rx:.2*h,ry:.09*h,rot:Math.atan2(Ye.y,Ye.x),fill:(he=l.hands)!=null?he:l.accent},d))}y("wand")&&J===1&&!n.portrait&&Oe.push(...sl(t,Ge,mr(pe(le(Ce,.4),Qe(le(u,.6),f))),h,x));let et=o.hand*h*(y("tiny-arms")?.72:1);if(y("tiny-arms"))for(let Ue of[-.45,.45]){let qe=Math.cos(Ue),Lt=Math.sin(Ue),Ye={x:Ce.x*qe-Ce.y*Lt,y:Ce.x*Lt+Ce.y*qe},Ot=pe(Ge,le(Ye,et*.75)),ir=pe(Ge,le(Ye,et*1.6)),Nn={x:-Ye.y*et*.32,y:Ye.x*et*.32};Oe.push(M({k:"path",d:ie([pe(Ot,Nn),ir,Qe(Ot,Nn)],.2),fill:l.belly},d))}Oe.push(M({k:"circle",x:Ge.x,y:Ge.y,r:et,fill:(Ct=l.hands)!=null?Ct:l.limbs},d))}if(y("wings"))for(let C of[-1,1]){let N=g([[C*S*.5,.05*h],[C*(S+.85*h),-.6*h],[C*(S+.72*h),.05*h],[C*(S+.45*h),-.02*h],[C*(S+.3*h),.32*h],[C*S*.6,.55*h]]);B.push(M({k:"path",d:ie(N,.18),fill:l.accent},d))}if(y("wings-fairy")&&B.push(...ol(t,m,S,h,x)),y("cape")){let C=b+.8*h,N=P+.36*h,V=g([[-S*.92,H+.04*h],[S*.92,H+.04*h],[S+.16*h,b*.5],[N,C],[N*.5,C-.1*h],[0,C],[-N*.5,C-.1*h],[-N,C],[-S-.16*h,b*.5]]);B.push(M({k:"path",d:ae(V,.6),fill:l.accent},d))}if(y("backpack")){let C=m(0,.35*h);B.push(M({k:"rect",x:C.x,y:C.y,w:S*2+.34*h,h:.8*h,r:.16*h,rot:a.angle,fill:(Fn=(Cn=t.extraColors)==null?void 0:Cn[0])!=null?Fn:l.limbs},d))}if(y("tank")){let C=m(S*.95,.24*h),N=(Ft=(Pn=t.extraColors)==null?void 0:Pn[0])!=null?Ft:l.accent,V=m(S*.95,-.3*h);B.push({k:"rect",x:V.x,y:V.y,w:.14*h,h:.16*h,r:.04*h,rot:a.angle,fill:l.outline}),B.push(M({k:"rect",x:C.x,y:C.y,w:.34*h,h:1*h,r:.17*h,rot:a.angle,fill:N},d))}if(a.hipsOk&&!n.portrait&&B.push(...rl(t,a,P,x)),y("tentacles")&&a.hipsOk)for(let C of[-1,1]){let N=g([[C*P*.7,b*.9],[C*(P+.22*h),b+.3*h],[C*(P+.48*h),b+.22*h],[C*(P+.5*h),b-.02*h],[C*(P+.34*h),b-.06*h]]);B.push({k:"path",d:rn(N),stroke:l.outline,lw:.2*h+x*2}),B.push({k:"path",d:rn(N),stroke:l.limbs,lw:.2*h})}let we=Math.max(S,P)*o.bulge;if(y("wool")){for(let[N,V]of[[S*.7,H+.02*h],[we,b*.3],[we*1.02,b*.62],[(we+P)/2,b*.92],[P*.55,z]])for(let J of[-1,1]){let K=m(J*N,V);L.push(M({k:"circle",x:K.x,y:K.y,r:.2*h,fill:l.body},d))}let C=m(0,z+.02*h);L.push(M({k:"circle",x:C.x,y:C.y,r:.2*h,fill:l.body},d))}if(y("robe")){let C=b+.58*h,N=P*1.4;L.push(M({k:"path",d:ae(g([[-S,H],[0,H-.04*h],[S,H],[we,b*.55],[N,C],[0,C+.06*h],[-N,C],[-we,b*.55]]),.7),fill:l.body},d));let V=g([[-N*.94,C-.1*h],[0,C-.04*h],[N*.94,C-.1*h]]);L.push({k:"path",d:rn(V),stroke:(qt=(xt=t.extraColors)==null?void 0:xt[0])!=null?qt:l.accent,lw:.07*h})}else if(y("sheet")){let C=b+.78*h,N=P*1.3;L.push(M({k:"path",d:ae(g([[-S,H],[S,H],[we,b*.55],[N,C],[N*.5,C-.2*h],[0,C],[-N*.5,C-.2*h],[-N,C],[-we,b*.55]]),.9),fill:l.body},d))}else L.push(M({k:"path",d:ae(g([[-S,H],[0,H-.04*h],[S,H],[we,b*.55],[P,z],[0,z+.03*h],[-P,z],[-we,b*.55]]),.85),fill:l.body},d));let oe=Math.min(S,P);if(y("pocket")){let C=m(0,b*.74);L.push({k:"rect",x:C.x,y:C.y,w:oe*1.3,h:.3*h,r:.1*h,rot:a.angle,fill:l.belly,stroke:l.outline,lw:x*.8})}else if(y("racing-stripe"))for(let C of[-.1,.1]){let N=m(C*h,H+.02*h),V=m(C*h,z-.04*h);L.push({k:"line",pts:[N.x,N.y,V.x,V.y],stroke:l.belly,lw:.1*h})}else if(l.belly&&l.belly!==l.body&&!y("panel")&&!y("sheet")&&!y("stripes")){let C=m(0,b*.58);L.push({k:"ellipse",x:C.x,y:C.y,rx:oe*.64,ry:Math.max(b*.36,.2*h),rot:a.angle,fill:l.belly})}if(y("spots")){let C=(Ln=(_n=t.extraColors)==null?void 0:_n[1])!=null?Ln:l.belly;for(let[N,V,J]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){let K=m(N*oe,V*b);L.push({k:"circle",x:K.x,y:K.y,r:J*h,fill:C})}}if(y("stripes")){let C=(Pt=(On=t.extraColors)==null?void 0:On[1])!=null?Pt:l.accent;for(let N of[.22,.44,.66]){let V=m(-oe*.98,b*N),J=m(oe*.98,b*N);L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:C,lw:.1*h})}}if(y("straps")){let C=(Yt=(In=t.extraColors)==null?void 0:In[1])!=null?Yt:l.outline;for(let N of[-1,1]){let V=m(N*S*.62,H+.02*h),J=m(N*oe*.62,b*.72);L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:l.outline,lw:.13*h+x*2}),L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:C,lw:.13*h})}}if(y("belt")){let C=m(0,b*.9);L.push(M({k:"rect",x:C.x,y:C.y,w:P*1.92,h:.17*h,r:.06*h,rot:a.angle,fill:(Qt=(Kt=t.extraColors)==null?void 0:Kt[2])!=null?Qt:"#4a3426"},d)),L.push(M({k:"rect",x:C.x,y:C.y,w:.2*h,h:.19*h,r:.04*h,rot:a.angle,fill:"#ffd84a"},d))}if(y("emblem")){let C=m(0,b*.4),N=(sr=(rr=t.extraColors)==null?void 0:rr[0])!=null?sr:l.accent,V=ie([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);L.push({k:"group",x:C.x,y:C.y,rot:a.angle,s:h,items:[{k:"path",d:V,fill:N,stroke:l.outline,lw:x/h},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ct,fill:N===l.accent?"#ffffff":l.accent}]}]})}if(y("panel")){let C=m(0,b*.5);L.push(M({k:"rect",x:C.x,y:C.y,w:oe*1.2,h:.38*h,r:.1*h,rot:a.angle,fill:"#24323d"},d)),((_t=t.extraColors)!=null?_t:["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((V,J)=>{let K=m((J-1)*oe*.34,b*.5);L.push({k:"circle",x:K.x,y:K.y,r:.075*h,fill:V})})}if(y("badge")){let C=m(-oe*.42,b*.36);L.push(M({k:"circle",x:C.x,y:C.y,r:.15*h,fill:l.accent},d)),L.push({k:"group",x:C.x,y:C.y,rot:a.angle,s:.09*h,items:[{k:"path",d:ct,fill:"#ffffff"}]})}if(y("star")){let C=m(-oe*.5,b*.3),N=.15*h;L.push({k:"group",x:C.x,y:C.y,rot:a.angle-.2,s:N,items:[{k:"path",d:ct,fill:(or=(gt=t.extraColors)==null?void 0:gt[0])!=null?or:"#ffd84a",stroke:l.outline,lw:x*.8/N}]})}if(y("petals")&&L.push(...al(t,m,S,P,we,b,z,h,x,o)),y("scarf")){let C=Math.max(.04,o.head*(1-o.neck)-.06)*h,N=m(0,C),V=(Zt=(ar=t.extraColors)==null?void 0:ar[0])!=null?Zt:l.accent,J=m(S*.45,C+.28*h);L.push(M({k:"rect",x:J.x,y:J.y,w:.16*h,h:.42*h,r:.06*h,rot:a.angle+.15,fill:V},d)),L.push(M({k:"rect",x:N.x,y:N.y,w:S*2.05,h:.2*h,r:.1*h,rot:a.angle,fill:V},d))}let Re={k:"group",x:a.head.x,y:a.head.y,rot:a.headRot,s:a.headR,items:el(t,x/a.headR)};return[...B,...G,...L,...U,Re,...Y]}var Ao=new WeakMap,Ji=64;function el(r,t){let e=Number(t.toPrecision(4)),n=Ao.get(r);n||Ao.set(r,n=new Map);let s=n.get(e);return s||(n.size>=Ji&&n.clear(),n.set(e,s=pr(r,e))),s}function tl(r,t,e,n,s,o){let a=nl(r,t,e,n,s,o);if(!r.bodyExtras.includes("strong-legs"))return[a];let i=e.U*o,l=pe(pe(t,le(e.d,.07*i)),le(e.r,n*.06*i)),c=[a];for(let u of[-1,0,1]){let f=pe(pe(l,le(e.r,u*.12*i)),le(e.d,.09*i));c.push({k:"ellipse",x:f.x,y:f.y,rx:.05*i,ry:.045*i,rot:e.angle,fill:r.palette.belly,stroke:r.palette.outline,lw:s*.8})}return c}function nl(r,t,e,n,s,o){var b;let a=r.palette,{d:i,r:l}=e,c=e.U*o,u=pe(pe(t,le(i,.07*c)),le(l,n*.06*c)),f={stroke:a.outline,lw:s},h=(b=a.feet)!=null?b:a.limbs;if(r.bodyExtras.includes("fins")){let y=ie([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:u.x,y:u.y,rot:e.angle,s:c,items:[{k:"path",d:y,fill:h,stroke:a.outline,lw:s/c},{k:"line",pts:[0,.06,0,.38],stroke:a.outline,lw:s/c,alpha:.5}]}}return r.bodyExtras.includes("flippers")?M({k:"ellipse",x:u.x,y:u.y,rx:.27*c,ry:.11*c,rot:e.angle,fill:h},f):r.bodyExtras.includes("boots")?M({k:"rect",x:u.x,y:u.y,w:.4*c,h:.24*c,r:.09*c,rot:e.angle,fill:h},f):M({k:"ellipse",x:u.x,y:u.y,rx:.2*c,ry:.13*c,rot:e.angle,fill:h},f)}function rl(r,t,e,n){var x,d,m,g,v,k,R,F,I;let s=r.palette,{U:o,L:a,S:i,r:l,d:c}=t,u=(A,S)=>({x:i.x+l.x*A+c.x*S,y:i.y+l.y*A+c.y*S}),f=A=>A.map(([S,P])=>u(S,P)),h={stroke:s.outline,lw:n},b=(A,S,P)=>[{k:"path",d:rn(A),stroke:s.outline,lw:S+n*2},{k:"path",d:rn(A),stroke:P,lw:S}],y=[];switch(r.tail){case"none":break;case"fluffy":{let A=f([[e*.5,a*.95],[e+.28*o,a*1],[e+.72*o,a*.62],[e+.78*o,a*.12],[e+.52*o,a*.32],[e+.3*o,a*.6],[e*.6,a*.7]]);y.push(M({k:"path",d:ae(A),fill:s.body},h));let S=u(e+.72*o,a*.2);y.push(M({k:"ellipse",x:S.x,y:S.y,rx:.13*o,ry:.2*o,rot:t.angle+.25,fill:s.belly},h));break}case"brush":{let A=f([[e*.4,a*.98],[e+.42*o,a*1.06],[e+.98*o,a*.66],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.66*o,a*.36],[e+.3*o,a*.66],[e*.5,a*.68]]);y.push(M({k:"path",d:ae(A),fill:s.body},h));let S=f([[e+1.03*o,a*.36],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.72*o,a*.24],[e+.86*o,a*.34]]);y.push(M({k:"path",d:ae(S),fill:s.belly},h));break}case"pom":{let A=u(e+.06*o,a*.88);y.push(M({k:"circle",x:A.x,y:A.y,r:.2*o,fill:s.belly},h));break}case"long":case"striped":case"tuft":{let A=f([[e*.6,a*.9],[e+.35*o,a*.85],[e+.58*o,a*.4],[e+.5*o,-.02*o]]);if(y.push(...b(A,.14*o,s.body)),r.tail==="tuft"){let S=A[A.length-1];y.push(M({k:"circle",x:S.x,y:S.y,r:.16*o,fill:(d=(x=r.extraColors)==null?void 0:x[0])!=null?d:s.accent},h))}if(r.tail==="striped"){for(let P of[.35,.6,.85]){let H=u(e+.35*o+.22999999999999998*o*(P*1.4>1?1:P*1.4),a*(.85-.85*P));y.push({k:"line",pts:[H.x-l.x*.08*o,H.y-l.y*.08*o,H.x+l.x*.08*o,H.y+l.y*.08*o],stroke:(g=(m=r.extraColors)==null?void 0:m[0])!=null?g:s.outline,lw:.06*o})}let S=A[A.length-1];y.push({k:"circle",x:S.x,y:S.y,r:.07*o,fill:(k=(v=r.extraColors)==null?void 0:v[0])!=null?k:s.outline})}break}case"curl":{let A=f([[e*.6,a*.9],[e+.4*o,a*.88],[e+.62*o,a*.45],[e+.5*o,a*.12],[e+.3*o,a*.24],[e+.36*o,a*.42]]);y.push(...b(A,.12*o,s.limbs));break}case"fish":{let A=f([[e*.6,a*.9],[e+.36*o,a*.86],[e+.6*o,a*.5]]);y.push(...b(A,.17*o,s.body));let S=A[A.length-1],P=ie([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);y.push({k:"group",x:S.x,y:S.y,rot:t.angle+.35,s:o,items:[{k:"path",d:P,fill:s.body,stroke:s.outline,lw:n/o}]});break}case"plume":{let A=(R=r.extraColors)!=null?R:[s.accent];[0,1,2].forEach(S=>{let P=u(e+(.12+S*.13)*o,a+(.32-S*.06)*o);y.push(M({k:"ellipse",x:P.x,y:P.y,rx:.11*o,ry:.44*o,rot:t.angle-.55+S*.28,fill:A[(S+1)%A.length]},h))});break}case"thick":{let A=f([[e*.3,a*.42],[e+.42*o,a*.62],[e+.92*o,a*.96],[e+1.32*o,a*1.08],[e+1.44*o,a*.98],[e+.98*o,a*1.2],[e+.4*o,a*1.22],[e*.3,a*1.12]]);y.push(M({k:"path",d:ae(A,.8),fill:s.body},h));let S=(I=(F=r.extraColors)==null?void 0:F[0])!=null?I:s.accent;for(let[P,H,z]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){let B=u(e+P*o,a*H+.03*o),G=u(e+(P-.1)*o,a*H+z*o);y.push({k:"line",pts:[B.x,B.y,G.x,G.y],stroke:S,lw:.09*o})}break}case"spiky":case"arrow":{let A=f([[e*.3,a*.55],[e+.35*o,a*.68],[e+.95*o,a*.86],[e+.35*o,a*1.08],[e*.3,a*1.08]]);if(r.tail==="spiky"){for(let S of[.15,.45,.72]){let P=e+(.2+S*.7)*o,H=a*(.66+S*.19);y.push(M({k:"path",d:ie(f([[P-.12*o,H+.05*o],[P,H-.2*o],[P+.12*o,H+.07*o]]),.2),fill:s.accent},h))}y.push(M({k:"path",d:ae(A,.7),fill:s.body},h))}else{let S=f([[e*.6,a*.9],[e+.4*o,a*.92],[e+.62*o,a*.5],[e+.62*o,a*.18]]);y.push(...b(S,.13*o,s.body));let P=S[S.length-1];y.push({k:"group",x:P.x,y:P.y,rot:t.angle,s:o,items:[{k:"path",d:ie([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:s.accent,stroke:s.outline,lw:n/o}]})}break}}return y}function sl(r,t,e,n,s){let o=r.palette,a=pe(t,le(e,-.08*n)),i=pe(t,le(e,.52*n)),l=.2*n;return[{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:o.outline,lw:.06*n+s*2},{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:"#fff3d6",lw:.06*n},{k:"circle",x:i.x,y:i.y,r:.24*n,fill:o.accent,alpha:.28},{k:"group",x:i.x,y:i.y,rot:Math.atan2(e.y,e.x)+Math.PI/2,s:l,items:[{k:"path",d:ct,fill:o.accent,stroke:o.outline,lw:s*.9/l}]}]}function ol(r,t,e,n,s){var l,c;let o=r.palette,a=(c=(l=r.extraColors)==null?void 0:l[0])!=null?c:"#cdeeff",i=[];for(let u of[-1,1]){let f=[[[u*e*.3,.12*n],[u*(e+.42*n),-.66*n],[u*(e+1*n),-.74*n],[u*(e+1.02*n),-.18*n],[u*(e+.5*n),.26*n]],[[u*e*.4,.3*n],[u*(e+.6*n),.36*n],[u*(e+.74*n),.78*n],[u*(e+.3*n),.9*n]]];for(let h of f){let b=ae(h.map(([m,g])=>t(m,g)),.9);i.push({k:"path",d:b,fill:a,alpha:.6}),i.push({k:"path",d:b,stroke:o.outline,lw:s*.9});let y=h[Math.floor(h.length/2)],x=t(h[0][0],h[0][1]),d=t(h[0][0]+(y[0]-h[0][0])*.75,h[0][1]+(y[1]-h[0][1])*.75);i.push({k:"line",pts:[x.x,x.y,d.x,d.y],stroke:"#ffffff",lw:s*.9,alpha:.85})}for(let[h,b,y]of[[e+.72*n,-.42*n,.075*n],[e+.44*n,-.16*n,.05*n],[e+.5*n,.6*n,.055*n]]){let x=t(u*h,b);i.push({k:"group",x:x.x,y:x.y,s:y,items:[{k:"path",d:ct,fill:"#ffffff"}]})}}return i}function al(r,t,e,n,s,o,a,i,l,c){var v,k;let u=r.palette,f=(k=(v=r.extraColors)==null?void 0:v[1])!=null?k:u.belly,h=[],b=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),y=5,x=Math.max(n,s*.92)*1.08,d=(o*.8+a)/2,m=[0,4,1,3,2];for(let R of m){let F=R/(y-1)-.5,I=t(F*2*x,d+(.5-Math.abs(F))*.1*i);h.push({k:"ellipse",x:I.x,y:I.y,rx:x*.3,ry:.34*i,rot:b-F*.6,fill:R%2?f:u.body,stroke:u.outline,lw:l})}let g=Math.max(.04,c.head*(1-c.neck)-.04)*i;for(let R of[-1,1,0]){let F=t(R*e*.32,g+(R?0:.05*i));h.push({k:"ellipse",x:F.x,y:F.y,rx:e*.26,ry:.12*i,rot:b+R*.5,fill:R?f:u.body,stroke:u.outline,lw:l*.9})}return h}var il={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 ll(r,{cx:t=.5,cy:e=.36,T:n=.18}={}){var c;let s=M(M({},il),r),o=new Array(Ur*3).fill(0),a=(u,[f,h],b=.99)=>{o[u*3]=t+f*n,o[u*3+1]=e+h*n,o[u*3+2]=b};for(let u of Object.keys(q))a(q[u],s[u]);let i=(c=s.tilt)!=null?c:0,l=(u,f)=>[s.nose[0]+u*Math.cos(i)-f*Math.sin(i),s.nose[1]+u*Math.sin(i)+f*Math.cos(i)];return a(tt.leftEye,l(-.1,-.08)),a(tt.rightEye,l(.1,-.08)),a(tt.leftEar,l(-.22,-.02)),a(tt.rightEar,l(.22,-.02)),o}var Ro=()=>ll({});var Yr=Object.freeze({lag:.5,extrapolate:.75,maxExtrapolateMs:50}),on=class{constructor(t={}){p(this,"tracks",new Map);p(this,"offset",NaN);p(this,"lastArrival",NaN);p(this,"interval",33);p(this,"lastT",NaN);p(this,"lostMs");p(this,"maxExtrapolateMs");p(this,"lag");p(this,"extrapolate");var e,n;this.lostMs=(e=t.lostMs)!=null?e:250,this.maxExtrapolateMs=(n=t.maxExtrapolateMs)!=null?n:25,this.lag=Fo(t.lag,1),this.extrapolate=Fo(t.extrapolate,.5)}get delayMs(){return this.interval*this.lag}push(t,e,n,s=Co()){Number.isFinite(e)||(e=s),this.clock(e,s);let o=this.tracks.get(t);if(!o||e-o.tb>this.lostMs||e<o.tb-this.lostMs||n.length!==o.b.length){this.tracks.set(t,{a:null,ta:e,b:n,tb:e,out:null,outAt:NaN});return}if(n===o.b||e<=o.tb){e===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=e,o.out=null}at(t,e=Co()){let n=this.tracks.get(t);if(!n)return null;if(!n.a)return n.b;if(n.out&&n.outAt===e)return n.out;let s=e-this.offset-this.interval*this.lag,o=n.tb-n.ta,a=Math.min(o*this.extrapolate,this.maxExtrapolateMs),i=Math.min(Math.max((s-n.ta)/o,0),1+a/o);return n.out=Po(n.a,n.b,i),n.outAt=e,n.out}forget(t){this.tracks.delete(t)}clear(){this.tracks.clear()}clock(t,e){let n=e-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,(e-this.lastArrival)/1e3)),this.lastArrival=e,Number.isFinite(this.lastT)&&t>this.lastT){let s=t-this.lastT;s<this.interval*3+20&&(this.interval+=(Math.min(Math.max(s,8),100)-this.interval)*.1)}t<=this.lastT||(this.lastT=t)}},Co=()=>{var r,t;return(t=(r=$.performance)==null?void 0:r.now())!=null?t:Date.now()},Fo=(r,t)=>typeof r=="number"&&Number.isFinite(r)?Math.min(Math.max(r,0),1):t;function Po(r,t,e){let n=t.slice(),s=e<.5?r:t;for(let o=0;o+2<t.length;o+=3){let a=r[o],i=r[o+1],l=t[o],c=t[o+1];r[o+2]>=.5&&t[o+2]>=.5&&Math.abs(l-a)+Math.abs(c-i)<.15?(n[o]=a+(l-a)*e,n[o+1]=i+(c-i)*e,n[o+2]=r[o+2]+(t[o+2]-r[o+2])*Math.min(e,1)):(n[o]=s[o],n[o+1]=s[o+1],n[o+2]=s[o+2])}return n}var jc=Xr.map(r=>r.id);var yr=new Map(Xr.map(r=>[r.id,r])),Ht=yr.get("fox"),Lo=r=>typeof r=="string"&&yr.has(r),an=r=>yr.get(r);var ul=r=>{var t;return typeof r=="string"?(t=yr.get(r))!=null?t:Ht:r};function Oo(r,t,e){let n=ul(r),s=Ro(),o=br(n,e),a=sn(s,{x:0,y:0,w:1,h:1},{band:o}),i=Do(pr(n,.05)),l=-i.minY,c=Math.min(.27,.43/Math.max(l,1))*t,u=n.head==="snout-long"?(i.minX+i.maxX)/2*c:0,f=c/ut[o].head/a.U,h=.5*t+Math.min(0,(l-1.6)*.06*t),b={x:t/2-u-a.head.x*f,y:h-a.head.y*f,w:f,h:f};return Hn(s,n,b,{portrait:!0,band:o})}function Io(r,t,e=.5){if(!r||r.length!==t.length)return t.slice();let n=t.slice();for(let s=0;s+2<t.length;s+=3){let o=r[s+2],a=t[s+2],i=o>=.5,l=a>=.5;i&&a>=.3&&(n[s+2]=Math.max(a,.5));let c=Math.hypot(t[s]-r[s],t[s+1]-r[s+1]);if(i&&l&&c<.15){let u=e*Math.min(1,_o+(1-_o)*c/hl);n[s]=r[s]+(t[s]-r[s])*u,n[s+1]=r[s+1]+(t[s+1]-r[s+1])*u}else i&&!l&&n[s+2]>=.5&&(n[s]=r[s],n[s+1]=r[s+1])}return dl(r,t,n,e*fl),n}var No=.8,_o=.1,hl=.03,fl=.35,pl=11;function dl(r,t,e,n){let s=q.leftShoulder*3,o=q.rightShoulder*3,a=(f,h)=>f[h+2]>=.5;if(!a(r,s)||!a(r,o)||!a(t,s)||!a(t,o))return;let i=(f,h)=>(f[s+h]+f[o+h])/2,l=[i(r,0),i(r,1)],c=[i(t,0),i(t,1)],u=[i(e,0),i(e,1)];for(let f=0;f<pl&&f*3+2<t.length;f++){let h=f*3;if(!a(r,h)||!a(t,h))continue;let b=[r[h]-l[0],r[h+1]-l[1]],y=[t[h]-c[0],t[h+1]-c[1]];Math.hypot(y[0]-b[0],y[1]-b[1])>=.15||(e[h]=u[0]+b[0]+(y[0]-b[0])*n,e[h+1]=u[1]+b[1]+(y[1]-b[1])*n)}}function Do(r){var n,s,o,a;let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},e=(i,l)=>{t.minX=Math.min(t.minX,i),t.minY=Math.min(t.minY,l),t.maxX=Math.max(t.maxX,i),t.maxY=Math.max(t.maxY,l)};for(let i of r){let l="lw"in i&&i.stroke?((n=i.lw)!=null?n:1)/2:0;switch(i.k){case"circle":e(i.x-i.r-l,i.y-i.r-l),e(i.x+i.r+l,i.y+i.r+l);break;case"ellipse":case"rect":{let c=i.k==="ellipse"?i.rx:i.w/2,u=i.k==="ellipse"?i.ry:i.h/2,f=Math.max(c,u)+l;e(i.x-f,i.y-f),e(i.x+f,i.y+f);break}case"path":{let c=jr(i.d);for(let u=0;u+1<c.length;u+=2)e(c[u]-l,c[u+1]-l),e(c[u]+l,c[u+1]+l);break}case"line":for(let c=0;c+1<i.pts.length;c+=2)e(i.pts[c]-l,i.pts[c+1]-l),e(i.pts[c]+l,i.pts[c+1]+l);break;case"group":{let c=Do(i.items);if(!Number.isFinite(c.minX))break;let u=(s=i.s)!=null?s:1,f=Math.cos((o=i.rot)!=null?o:0),h=Math.sin((a=i.rot)!=null?a:0);for(let[b,y]of[[c.minX,c.minY],[c.maxX,c.minY],[c.minX,c.maxY],[c.maxX,c.maxY]])e(i.x+(b*f-y*h)*u,i.y+(b*h+y*f)*u);break}}}return t}var ht=()=>Float64Array.of(1,0,0,1,0,0);function De(r,t,e,n,s,o,a){let i=s?Math.cos(s):1,l=s?Math.sin(s):0,c=i*o,u=l*o,f=-l*a,h=i*a;if(!t)return r[0]=c,r[1]=u,r[2]=f,r[3]=h,r[4]=e,r[5]=n,r;let b=t[0],y=t[1],x=t[2],d=t[3];return r[0]=b*c+x*u,r[1]=y*c+d*u,r[2]=b*f+x*h,r[3]=y*f+d*h,r[4]=b*e+x*n+t[4],r[5]=y*e+d*n+t[5],r}function zo(r,t,e){let n=r[0]*r[3]-r[1]*r[2];if(Math.abs(n)<1e-12)return null;let s=t-r[4],o=e-r[5];return[(r[3]*s-r[2]*o)/n,(-r[1]*s+r[0]*o)/n]}var Bo={white:16777215,black:0,red:16711680,transparent:0},$n=new Map;function Te(r){var s,o;if(typeof r=="number")return[r&16777215,1];let t=$n.get(r);if(t)return t;let e=[16777215,1],n=r.trim().toLowerCase();if(n[0]==="#"){let a=n.slice(1),i=a.length<=4?[...a].map(c=>c+c).join(""):a,l=parseInt(i.slice(0,6),16);Number.isFinite(l)&&(e=[l,i.length===8?parseInt(i.slice(6,8),16)/255:1])}else if(n.startsWith("rgb")){let a=(o=(s=n.match(/-?\d*\.?\d+%?/g))==null?void 0:s.map(f=>f.endsWith("%")?parseFloat(f)/100*255:parseFloat(f)))!=null?o:[],[i=255,l=255,c=255]=a,u=a[3]===void 0?1:n.match(/,\s*[\d.]+%\s*\)$/)?a[3]/255:a[3];e=[(Kr(i)<<16|Kr(l)<<8|Kr(c))>>>0,Math.min(Math.max(u,0),1)]}else if(n in Bo)e=[Bo[n],n==="transparent"?0:1];else if(typeof document!="undefined"){let a=document.createElement("canvas").getContext("2d");if(a){a.fillStyle="#ffffff",a.fillStyle=n;let i=a.fillStyle;if(i!==n)return $n.set(r,e=Te(i)),e}}return $n.size>512&&$n.clear(),$n.set(r,e),e}var Kr=r=>Math.min(Math.max(Math.round(r),0),255);function vt(r,t,e=!1){let n=Math.min(Math.max(t,0),1),s=(r>>16&255)*n,o=(r>>8&255)*n,a=(r&255)*n,i=e?0:n*255;return(Math.round(i)<<24|Math.round(a)<<16|Math.round(o)<<8|Math.round(s))>>>0}var $t=(r,t=1)=>"rgba(".concat(r>>16&255,",").concat(r>>8&255,",").concat(r&255,",").concat(t,")");function Qr(r,t){if(r===16777215)return t;if(t===16777215)return r;let e=n=>Math.round((r>>n&255)*(t>>n&255)/255);return(e(16)<<16|e(8)<<8|e(0))>>>0}var At={linear:r=>r,quadIn:r=>r*r,quadOut:r=>r*(2-r),quadInOut:r=>r<.5?2*r*r:-1+(4-2*r)*r,cubicOut:r=>1-wt(1-r,3),sineInOut:r=>-(Math.cos(Math.PI*r)-1)/2,backOut:r=>1+(1.70158+1)*wt(r-1,3)+1.70158*wt(r-1,2),elasticOut:r=>r===0||r===1?r:wt(2,-10*r)*Math.sin((r*10-.75)*(2*Math.PI/3))+1,bounceOut:r=>r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375};function Ho(r){let t=r>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var _={cap:0,epoch:0,x:new Float64Array(0),y:new Float64Array(0),rot:new Float64Array(0),sx:new Float64Array(0),sy:new Float64Array(0),alpha:new Float64Array(0),la:new Float64Array(0),lb:new Float64Array(0),lc:new Float64Array(0),ld:new Float64Array(0),world:new Float64Array(0),tint:new Uint32Array(0),flags:new Uint8Array(0),moved:new Uint8Array(0),dirty:new Uint8Array(0),gen:new Uint32Array(0),parent:new Int32Array(0),first:new Int32Array(0),next:new Int32Array(0),prev:new Int32Array(0),stamp:new Uint32Array(0),pass:0,free:new Int32Array(0),freeHead:0,freeCount:0,top:2},St=[],ml="x y rot sx sy alpha la lb lc ld world tint flags moved dirty gen parent first next prev stamp".split(" ");function $o(r){let t=_;for(let n of ml){let s=t[n],o=new s.constructor(n==="world"?r*6:r);o.set(s),t[n]=o}let e=new Int32Array(r);for(let n=0;n<_.freeCount;n++)e[n]=_.free[(_.freeHead+n)%_.cap];for(_.free=e,_.freeHead=0,_.cap=r,_.epoch++;St.length<r;)St.push(null)}function Jr(r){_.x[r]=_.y[r]=_.rot[r]=0,_.sx[r]=_.sy[r]=_.alpha[r]=1,_.la[r]=_.ld[r]=1,_.lb[r]=_.lc[r]=0;let t=r*6,e=_.world;e[t]=e[t+3]=1,e[t+1]=e[t+2]=e[t+4]=e[t+5]=0,_.tint[r]=16777215,_.flags[r]=3,_.moved[r]=1,_.dirty[r]=0,_.parent[r]=_.first[r]=_.next[r]=_.prev[r]=-1}$o(256);Jr(0);_.flags[0]=0;Jr(1);_.flags[1]=0;function Go(){let r;if(_.freeCount){r=_.free[_.freeHead],_.freeHead=(_.freeHead+1)%_.cap,_.freeCount--;let t=St[r];t&&(t._i=0,t._g=-1,St[r]=null)}else _.top===_.cap&&$o(_.cap*2),r=_.top++;return Jr(r),r}function es(r,t){xr(r);for(let n=_.first[r];n>=0;){let s=_.next[n];_.parent[n]=_.next[n]=_.prev[n]=-1,n=s}_.first[r]=-1,_.flags[r]=_.flags[r]&-3,_.moved[r]=0;let e=_.gen[r]+1;_.gen[r]=e,e!==4294967295&&(t&&(St[r]=t),_.free[(_.freeHead+_.freeCount)%_.cap]=r,_.freeCount++)}function Uo(r){for(let t=0;t<St.length;t++){let e=St[t];e&&r(e)&&(e._i=0,e._g=-1,St[t]=null)}}function Vo(r,t){xr(r);let e=_.first[t];_.parent[r]=t,_.next[r]=e,_.prev[r]=-1,e>=0&&(_.prev[e]=r),_.first[t]=r,_.moved[r]=1}function xr(r){let t=_.parent[r];if(t<0)return;let e=_.next[r],n=_.prev[r];n>=0?_.next[n]=e:_.first[t]=e,e>=0&&(_.prev[e]=n),_.parent[r]=_.next[r]=_.prev[r]=-1}var Gn={root:-1,gen:-1,world:new Float64Array(6)};function Wo(r){let t=++_.pass,e=_.world,n=r*6,s=Gn.world,o=Gn.root!==r||Gn.gen!==_.gen[r];for(let a=0;a<6;a++)s[a]!==e[n+a]&&(o=!0),s[a]=e[n+a];Gn.root=r,Gn.gen=_.gen[r],_.stamp[r]=o?t:t-1}function Xo(r){_.stamp[r]=_.pass}function jo(r){for(let t=_.first[r];t>=0;){let e=_.next[t];jo(t),t=e}es(r)}var Zr=typeof FinalizationRegistry=="function"?new FinalizationRegistry(r=>_.gen[r.i]===r.g&&jo(r.i)):null;function ts(r){r._reg||!Zr||(r._reg=!0,Zr.register(r,{i:r._i,g:r._g},r))}function qo(r){r._reg&&Zr.unregister(r)}function Un(r){if(r){for(let t=0;t<r.length;t++)if(r[t].enabled)return!0}return!1}function Yo(r,t){let e=0;for(let n=0;n<r.length;n++){let s=r[n];s.enabled&&s.pad&&(e+=s.pad(t))}return e}var Be={gl:null,c2d:null,live:null};var se=new Float64Array(3),Vn=4,bl=1,Wn=()=>bl++;var ge=ht(),D=_,We=class{constructor(t){p(this,"kernel",t);p(this,"_i",Go());p(this,"_g",D.gen[this._i]);p(this,"_wv",null);p(this,"_wi",-1);p(this,"_we",-1);p(this,"blend","normal");p(this,"_data",null);p(this,"parent",null);p(this,"hitRadius",null);p(this,"clip",null);p(this,"mask",null);p(this,"filters",null);p(this,"_z",0);p(this,"anchorX",0);p(this,"anchorY",0);p(this,"_pool",null);p(this,"_free",!1);p(this,"_reg",!1)}get x(){return D.x[this._i]}set x(t){let e=this._i||1;D.x[e]=t,D.moved[e]=1}get y(){return D.y[this._i]}set y(t){let e=this._i||1;D.y[e]=t,D.moved[e]=1}get rotation(){return D.rot[this._i]}set rotation(t){let e=this._i||1;D.rot[e]=t,D.dirty[e]=D.moved[e]=1}get scaleX(){return D.sx[this._i]}set scaleX(t){let e=this._i||1;D.sx[e]=t,D.dirty[e]=D.moved[e]=1}get scaleY(){return D.sy[this._i]}set scaleY(t){let e=this._i||1;D.sy[e]=t,D.dirty[e]=D.moved[e]=1}get alpha(){return D.alpha[this._i]}set alpha(t){let e=this._i||1;D.alpha[e]=t,D.moved[e]=1}get visible(){return(D.flags[this._i]&1)!==0}set visible(t){let e=this._i||1;t?D.flags[e]=D.flags[e]|1:D.flags[e]=D.flags[e]&-2,D.moved[e]=1}get destroyed(){return D.gen[this._i]!==this._g}get world(){let t=this._i||1;return(this._wi!==t||this._we!==D.epoch)&&(this._wv=D.world.subarray(t*6,t*6+6),this._wi=t,this._we=D.epoch),this._wv}get data(){var t;return(t=this._data)!=null?t:this._data={}}set data(t){this._data=t}get scale(){return this.scaleX}set scale(t){this.scaleX=this.scaleY=t}get z(){return this._z}set z(t){t!==this._z&&(this._z=t,this.parent&&(this.parent.sortDirty=!0))}get tint(){return D.tint[this._i]}set tint(t){D.tint[this._i||1]=typeof t=="number"?t&16777215:Te(t)[0]}set anchor(t){typeof t=="number"?this.anchorX=this.anchorY=t:(this.anchorX=t.x,this.anchorY=t.y)}get width(){return 0}set width(t){}get height(){return 0}set height(t){}set(t){for(let e in t){let n=t[e];n!==void 0&&(this[e]=n)}return this}destroy(){var t;this.destroyed||(this.visible=!1,this.parent&&(this.parent.dead=!0,this.parent=null),es(this._i,this),qo(this),this.kernel.tweens.stopAll(this),(t=this._pool)==null||t.forget(this))}updateWorld(){let t=this.parent?this.parent.updateWorld():null;return De(this.world,t,this.x,this.y,this.rotation,this.scaleX,this.scaleY)}draw(t,e,n){}};function Jo(r){Uo(t=>t.kernel===r)}var ns=!1,Ko=Object.freeze([]),Vt=class r extends We{constructor(e){super(e);p(this,"children",Ko);p(this,"sortDirty",!1);p(this,"dead",!1);ts(this)}add(e,...n){this.adopt(e);for(let s=0;s<n.length;s++)this.adopt(n[s]);return e}adopt(e){e.parent&&e.parent.detach(e),e.parent=this,!e.destroyed&&!this.destroyed&&Vo(e._i,this._i),this.children===Ko&&(this.children=[]),this.children.push(e),(e.z!==0||this.sortDirty)&&(this.sortDirty=!0)}remove(e){this.detach(e),e._pool||ts(e)}detach(e){let n=this.children,s=n.indexOf(e);if(s>=0){for(let o=s+1;o<n.length;o++)n[o-1]=n[o];n.pop()}e.parent===this&&(e.parent=null,e.destroyed||xr(e._i))}clear(){for(let e of this.children)e.destroy()}destroy(){for(let e of this.children)e.destroy();super.destroy()}sweep(){if(this.dead){this.dead=!1;let e=0;for(let n of this.children)n.destroyed?n.parent===this&&(n.parent=null):this.children[e++]=n;this.children.length=e}for(let e of this.children)e instanceof r&&e.sweep()}draw(e,n,s){if(ns)return D.parent[this._i]<0&&!this.destroyed&&Xo(this._i),this.drawChildren(e,n,s);ns=!0;try{this.destroyed||Wo(this._i),this.drawChildren(e,n,s)}finally{ns=!1}}drawChildren(e,n,s){if(this.sortDirty){let l=new Map(this.children.map((c,u)=>[c,u]));this.children.sort((c,u)=>c.z-u.z||l.get(c)-l.get(u)),this.sortDirty=!1}let o=this.children,a=this._i,i=D.stamp[a]===D.pass;for(let l=0;l<o.length;l++){let c=o[l],u=c._i,f=D.alpha[u];if(D.gen[u]!==c._g||!(D.flags[u]&1)||f<=0)continue;if(i||D.moved[u]){D.moved[u]=0,D.stamp[u]=D.pass;let y,x,d,m;if(D.dirty[u]){D.dirty[u]=0;let H=D.rot[u],z=H?Math.cos(H):1,B=H?Math.sin(H):0,G=D.sx[u],L=D.sy[u];D.la[u]=y=z*G,D.lb[u]=x=B*G,D.lc[u]=d=-B*L,D.ld[u]=m=z*L}else y=D.la[u],x=D.lb[u],d=D.lc[u],m=D.ld[u];let g=D.world,v=D.x[u],k=D.y[u],R=u*6,F=a*6,I=g[F],A=g[F+1],S=g[F+2],P=g[F+3];g[R]=I*y+S*x,g[R+1]=A*y+P*x,g[R+2]=I*d+S*m,g[R+3]=A*d+P*m,g[R+4]=I*v+S*k+g[F+4],g[R+5]=A*v+P*k+g[F+5]}let h=n*f,b=Qr(s,D.tint[u]);c.clip||c.mask||c.filters?ea(e,c,h,b):c.draw(e,h,b)}}},_e=new Float64Array(128),Gt=0,rs=new Float64Array(8);function ss(r,t,e,n){t.clip||t.mask||t.filters?ea(r,t,e,n):t.draw(r,e,n)}function ea(r,t,e,n){let s=r.r,o=t.world,a=t.clip,i=!1,l=!1;if(a)if(Math.abs(o[1])<1e-9&&Math.abs(o[2])<1e-9&&Gt<32){let f=o[0]*a.x+o[4],h=o[0]*(a.x+a.width)+o[4],b=o[3]*a.y+o[5],y=o[3]*(a.y+a.height)+o[5],x=Math.min(f,h),d=Math.max(f,h),m=Math.min(b,y),g=Math.max(b,y);if(Gt){let k=(Gt-1)*4;x=Math.max(x,_e[k]),m=Math.max(m,_e[k+1]),d=Math.min(d,_e[k+2]),g=Math.min(g,_e[k+3])}let v=Gt++*4;_e[v]=x,_e[v+1]=m,_e[v+2]=d,_e[v+3]=g,s.clip(x,m,Math.max(d-x,0),Math.max(g-m,0)),l=!0}else i=!0;let c=t.mask&&t.mask.visible?t.mask:null,u=Un(t.filters)?t.filters:null;try{if(i&&s.beginLayer(),c&&s.beginLayer(),u?(t.draw(r,s.beginLayer()?1:e,n),s.endLayer(e,u)):t.draw(r,e,n),c&&(s.beginMask(),De(c.world,o,c.x,c.y,c.rotation,c.scaleX,c.scaleY),ss(r,c,c.alpha,16777215),s.endLayer(1)),i&&a){s.beginMask();for(let f=0;f<4;f++){let h=f===1||f===2?a.x+a.width:a.x,b=f>1?a.y+a.height:a.y;rs[f*2]=o[0]*h+o[2]*b+o[4],rs[f*2+1]=o[1]*h+o[3]*b+o[5]}s.polygon(rs,4,16777215,1),s.endLayer(1)}}finally{if(l)if(Gt--,Gt){let f=(Gt-1)*4;s.clip(_e[f],_e[f+1],_e[f+2]-_e[f],_e[f+3]-_e[f+1])}else s.unclip()}}var ze=class extends We{constructor(e,n,s){super(e);p(this,"_frame",null);p(this,"_w",null);p(this,"_h",null);p(this,"slice",0);p(this,"autoAnchor",!0);p(this,"frameName",null);n&&(this.frame=n),(s==null?void 0:s.anchor)===void 0&&this.useFrameAnchor(),s&&this.set(s)}get frame(){return this._frame}set frame(e){this.frameName=typeof e=="string"?e:null,this._frame=typeof e=="string"?this.kernel.frame(e):e,this.autoAnchor&&this.useFrameAnchor()}set anchor(e){this.autoAnchor=!1,super.anchor=e}get naturalWidth(){var n;let e=this.frameNow();return e?((n=e.sw)!=null?n:e.w)/e.scale-e.margin*2:0}get naturalHeight(){var n;let e=this.frameNow();return e?((n=e.sh)!=null?n:e.h)/e.scale-e.margin*2:0}get width(){var e;return(e=this._w)!=null?e:this.naturalWidth}set width(e){this._w=e}get height(){var e;return(e=this._h)!=null?e:this.naturalHeight}set height(e){this._h=e}sizeQ(e){var n,s,o,a;un[0]=(s=this._w)!=null?s:((n=e.sw)!=null?n:e.w)/e.scale-e.margin*2,un[1]=(a=this._h)!=null?a:((o=e.sh)!=null?o:e.h)/e.scale-e.margin*2}frameNow(){return this.frameName&&!this.kernel.atlas.valid(this._frame)&&(this._frame=this.kernel.frame(this.frameName)),this._frame}useFrameAnchor(){var o,a;let e=this._frame;if(!e)return;let n=((o=e.sw)!=null?o:e.w)/e.scale-e.margin*2,s=((a=e.sh)!=null?a:e.h)/e.scale-e.margin*2;this.anchorX=n>0?(e.ox-e.margin)/n:0,this.anchorY=s>0?(e.oy-e.margin)/s:0}draw(e,n,s){let o=this.frameNow();if(!o)return;let a=un;this.sizeQ(o),a[2]=this.anchorX,a[3]=this.anchorY,a[4]=n,yl(e,o,this.world,this.slice,s,this.blend)}},ln=new Float64Array(12),cn=new Float64Array(12),Xn={x:0,y:0,w:0,h:0};function Qo(r,t,e,n,s,o){t=Math.max(t,0),e=Math.max(e,0),n=Math.max(n,0);let a=e+n>s?e*s/(e+n):e,i=e+n>s?n*s/(e+n):n,l=a/o,c=i/o;if(l+c>t){let u=t/(l+c);l*=u,c*=u}r[0]=0,r[1]=l,r[2]=0,r[3]=a,r[4]=l,r[5]=t-l-c,r[6]=a,r[7]=s-a-i,r[8]=t-c,r[9]=c,r[10]=s-i,r[11]=i}var un=new Float64Array(5);function yl(r,t,e,n,s,o){var k,R,F,I,A,S,P,H,z,B,G;let a=un,i=a[0],l=a[1],c=a[2],u=a[3],f=a[4],h=r.tex(t.surface),b=n===0?(k=t.slice)!=null?k:0:n;if(b===0){let L=((R=t.sw)!=null?R:t.w)/t.scale-t.margin*2,U=((F=t.sh)!=null?F:t.h)/t.scale-t.margin*2,Y=L>0?i/L:1,Q=U>0?l/U:1,Ee=-c*i+(((I=t.tx)!=null?I:0)/t.scale-t.margin)*Y,ue=-u*l+(((A=t.ty)!=null?A:0)/t.scale-t.margin)*Q;jn(e,Ee,ue),se[0]=t.w/t.scale*Y,se[1]=t.h/t.scale*Q,se[2]=f,r.r.quadQ(h,t,ge,s,o);return}let y=(S=t.tx)!=null?S:0,x=(P=t.ty)!=null?P:0,d=((H=t.sw)!=null?H:t.w)-t.w-y,m=((z=t.sh)!=null?z:t.h)-t.h-x,g=-c*i-t.margin+y/t.scale,v=-u*l-t.margin+x/t.scale;if(Qo(ln,i+t.margin*2-(y+d)/t.scale,(typeof b=="number"?b:b[3])-y,(typeof b=="number"?b:b[1])-d,t.w,t.scale),Qo(cn,l+t.margin*2-(x+m)/t.scale,(typeof b=="number"?b:b[0])-x,(typeof b=="number"?b:b[2])-m,t.h,t.scale),jn(e,g,v),se[2]=f,!((G=(B=r.r).nineQ)!=null&&G.call(B,h,t,ln,cn,ge,s,o)))for(let L=0;L<12;L+=4){let U=cn[L+1],Y=cn[L+3];if(!(U<=0||Y<=0))for(let Q=0;Q<12;Q+=4){let Ee=ln[Q+1],ue=ln[Q+3];Ee<=0||ue<=0||(Xn.x=t.x+ln[Q+2],Xn.y=t.y+cn[L+2],Xn.w=ue,Xn.h=Y,jn(e,g+ln[Q],v+cn[L]),se[0]=Ee,se[1]=U,se[2]=f,r.r.quadQ(h,Xn,ge,s,o))}}}function jn(r,t,e){ge[0]=r[0],ge[1]=r[1],ge[2]=r[2],ge[3]=r[3],ge[4]=r[0]*t+r[2]*e+r[4],ge[5]=r[1]*t+r[3]*e+r[5]}var nt=class extends ze{constructor(e,n,s={}){super(e,null);p(this,"_spec");p(this,"baked",null);p(this,"bakedEffects",!0);this._spec=n,this.bake(),s.anchor===void 0&&this.useFrameAnchor(),this.set(s)}get spec(){return this._spec}set spec(e){this._spec=e,this.baked=null,this._w=this._h=null,this.bake()}bake(){let e=this.kernel;return this.baked&&e.atlas.valid(this.baked.frame)&&this.baked.frame.scale===e.pixelScale&&this.bakedEffects===e.effects?this.baked:(this.bakedEffects=e.effects,this.baked=e.shape(this._spec),this._frame=this.baked.frame,this.slice=this.baked.slice,this.autoAnchor&&this.useFrameAnchor(),this.baked)}frameNow(){return this.bake().frame}sizeQ(){var n,s;let e=this.bake();un[0]=(n=this._w)!=null?n:e.w,un[1]=(s=this._h)!=null?s:e.h}get width(){var e;return(e=this._w)!=null?e:this.bake().w}set width(e){this._w=e}get height(){var e;return(e=this._h)!=null?e:this.bake().h}set height(e){this._h=e}},Zo=(r,t,e)=>r===void 0?t:typeof r=="number"?r:r[0]+(r[1]-r[0])*e(),Ut=class Ut extends We{constructor(e,n,s={}){var o,a,i,l;super(e);p(this,"max");p(this,"f");p(this,"tints");p(this,"count",0);p(this,"gravity");p(this,"drag");p(this,"frameRef");p(this,"random",Math.random);this.frameRef=n,this.max=Math.max(1,Math.floor((o=s.max)!=null?o:200)),this.f=new Float32Array(this.max*Ut.W),this.tints=new Uint32Array(this.max),this.blend=(a=s.blend)!=null?a:"normal",this.gravity=(i=s.gravity)!=null?i:0,this.drag=(l=s.drag)!=null?l:1}get alive(){return this.count}burst(e,n,s,o={}){var c,u,f,h,b;let a=Ut.W,i=this.random,l=o.tint===void 0?16777215:Te(o.tint)[0];for(let y=0;y<s;y++){let x=this.count;if(x>=this.max){let R=0,F=1/0;for(let I=0;I<this.max;I++){let A=this.f[I*a+5]-this.f[I*a+4];A<F&&(F=A,R=I)}x=R}else this.count++;let d=((c=o.angle)!=null?c:0)+(o.spread===void 0?i()*Math.PI*2:(i()-.5)*o.spread),m=Zo(o.speed,200,i),g=Array.isArray(o.scale)?o.scale[0]:(u=o.scale)!=null?u:1,v=Array.isArray(o.scale)?o.scale[1]:(f=o.scale)!=null?f:1,k=x*a;this.f[k]=e,this.f[k+1]=n,this.f[k+2]=Math.cos(d)*m,this.f[k+3]=Math.sin(d)*m,this.f[k+4]=0,this.f[k+5]=Math.max(Zo(o.life,.8,i),.01),this.f[k+6]=i()*Math.PI*2,this.f[k+7]=(i()-.5)*2*((h=o.spin)!=null?h:0),this.f[k+8]=g,this.f[k+9]=v,this.f[k+10]=(b=o.alpha)!=null?b:1,this.tints[x]=l}}update(e){let n=Ut.W,s=this.f,o=this.drag>=1?1:Math.pow(Math.max(this.drag,0),e);for(let a=0;a<this.count;){let i=a*n;if(s[i+4]=s[i+4]+e,s[i+4]>=s[i+5]){let l=--this.count;a!==l&&(s.copyWithin(i,l*n,l*n+n),this.tints[a]=this.tints[l]);continue}s[i+3]=(s[i+3]+this.gravity*e)*o,s[i+2]=s[i+2]*o,s[i]=s[i]+s[i+2]*e,s[i+1]=s[i+1]+s[i+3]*e,s[i+6]=s[i+6]+s[i+7]*e,a++}}clear(){this.count=0}draw(e,n,s){if(!this.count)return;let o=typeof this.frameRef=="string"?this.frameRef=this.kernel.frame(this.frameRef):this.frameRef,a=Ut.W,i=this.f,l=this.world,c=o.w/o.scale,u=o.h/o.scale;for(let f=0;f<this.count;f++){let h=f*a,b=i[h+4]/i[h+5],y=i[h+8]+(i[h+9]-i[h+8])*b,x=n*i[h+10]*(1-b*b),d=i[h+6],m=Math.cos(d)*y,g=Math.sin(d)*y,v=i[h],k=i[h+1],R=l[0],F=l[1],I=l[2],A=l[3],S=R*m+I*g,P=F*m+A*g,H=I*m-R*g,z=A*m-F*g;ge[0]=S,ge[1]=P,ge[2]=H,ge[3]=z,ge[4]=R*v+I*k+l[4]-(S*c+H*u)/2,ge[5]=F*v+A*k+l[5]-(P*c+z*u)/2,se[0]=c,se[1]=u,se[2]=x,e.r.quadQ(e.tex(o.surface),o,ge,Qr(s,this.tints[f]),this.blend)}}};p(Ut,"W",11);var hn=Ut;var Xe=class extends ze{constructor(e,n,s={}){let f=s,{fps:o,loop:a,playing:i,speed:l,onComplete:c}=f,u=en(f,["fps","loop","playing","speed","onComplete"]);if(!n.frames.length)throw new Error("[engine] an animation needs at least one frame");super(e,n.frames[0],u);p(this,"frames");p(this,"durations");p(this,"fps");p(this,"loop");p(this,"speed");p(this,"onComplete");p(this,"_playing");p(this,"index",0);p(this,"t",0);this.frames=n.frames,this.durations=n.durations&&o===void 0?n.durations:null,this.fps=o!=null?o:12,this.loop=a!==!1,this.speed=l!=null?l:1,this.onComplete=c!=null?c:null,this._playing=i!==!1,this.speed<0&&this.show(n.frames.length-1)}get frameIndex(){return this.index}get frameCount(){return this.frames.length}get playing(){return this._playing}play(){return!this.loop&&!this._playing&&this.index===(this.speed<0?0:this.frames.length-1)&&this.show(this.speed<0?this.frames.length-1:0),this._playing=!0,this}stop(){return this._playing=!1,this}gotoFrame(e){let n=this.frames.length;return this.show((Math.floor(e)%n+n)%n),this.t=0,this}gotoAndPlay(e){return this._playing=!0,this.gotoFrame(e)}gotoAndStop(e){return this._playing=!1,this.gotoFrame(e)}show(e){e===this.index&&this._frame||(this.index=e,this.frame=this.frames[e])}secondsOf(e){var s;let n=(s=this.durations)==null?void 0:s[e];return n!==void 0&&n>0?n:1/Math.max(this.fps,.001)}update(e){var a;if(!this._playing||this.destroyed||this.speed===0)return;let n=this.frames.length,s=this.speed<0;this.t+=e*Math.abs(this.speed);let o=this.index;for(let i=0;i<1e3;i++){let l=this.secondsOf(o);if(this.t<l)break;this.t-=l;let c=s?o-1:o+1;if(c<0||c>=n){if(!this.loop){this.t=0,this._playing=!1,this.show(o),(a=this.onComplete)==null||a.call(this);return}o=s?n-1:0}else o=c}this.show(o)}},ta=(r,t)=>r.localeCompare(t,void 0,{numeric:!0});var qn=class{constructor(t,e,n=2){p(this,"width",t);p(this,"height",e);p(this,"padding",n);p(this,"shelves",[]);p(this,"free",[]);p(this,"bottom",0)}alloc(t,e){let n=Math.ceil(t)+this.padding*2,s=Math.ceil(e)+this.padding*2;if(n>this.width||s>this.height)return null;for(let i=0;i<this.free.length;i++){let l=this.free[i];if(l.w>=n&&l.h>=s&&l.w*l.h<=n*s*2)return this.free.splice(i,1),Ie(M({},this.inner(l.x,l.y,t,e)),{slot:l})}let o=null;for(let i of this.shelves)i.h>=s&&i.h<=s*1.5+8&&this.width-i.x>=n&&(!o||i.h<o.h)&&(o=i);if(!o)if(this.bottom+s>this.height){for(let i of this.shelves)i.h>=s&&this.width-i.x>=n&&(o=i);if(!o)return null}else o={y:this.bottom,h:s,x:0},this.shelves.push(o),this.bottom+=s;let a=o.x;return o.x+=n,this.inner(a,o.y,t,e)}release(t){this.free.push({x:t.x-this.padding,y:t.y-this.padding,w:Math.ceil(t.w)+this.padding*2,h:Math.ceil(t.h)+this.padding*2})}get fill(){return this.bottom/this.height}reset(){this.shelves=[],this.free=[],this.bottom=0}inner(t,e,n,s){return{x:t+this.padding,y:e+this.padding,w:n,h:s}}},fn=r=>({source:r,texture:null,pending:[]}),Mt=class{constructor(t=2048,e=4){p(this,"pageSize",t);p(this,"maxPages",e);p(this,"pages",[]);p(this,"gen",1);p(this,"onPage",()=>{});p(this,"onDrop",()=>{})}valid(t){return!!t&&(t.gen===this.gen||t.gen===0)}bake(t,e,n,s=1,o=0,a=0,i=0){let l=Math.max(1,Math.ceil(t)),c=Math.max(1,Math.ceil(e)),u=document.createElement("canvas");u.width=l,u.height=c;let f=u.getContext("2d");return n(f),this.put(u,l,c,s,o,a,i)}add(t,e=1,n=0,s=0){let o=document.createElement("canvas");return o.width=Math.max(1,t.width),o.height=Math.max(1,t.height),o.getContext("2d").drawImage(t,0,0),this.put(o,o.width,o.height,e,n,s,0)}release(t){if(t.gen!==this.gen)return;let e=this.pages.find(n=>n.surface===t.surface);e==null||e.packer.release(t)}rebake(t,e,n,s,o=t.w,a=t.h){if(!this.valid(t)||e>o||n>a)return null;let i=Math.max(1,Math.ceil(e)),l=Math.max(1,Math.ceil(n)),c=this.pages.find(f=>f.surface===t.surface);if(!c)return null;let u=document.createElement("canvas");return u.width=Math.ceil(o),u.height=Math.ceil(a),s(u.getContext("2d")),c.ctx.clearRect(t.x,t.y,u.width,u.height),c.ctx.drawImage(u,t.x,t.y),t.surface.pending.push([u,t.x,t.y]),t.w=i,t.h=l,t}put(t,e,n,s,o,a,i){let l=null,c=this.pages.find(f=>(l=f.packer.alloc(e,n))!==null);if(c||(!(Math.max(e,n)+4>this.pageSize)&&this.pages.length>=this.maxPages&&(this.wipe(),c=this.pages[0],l=c?c.packer.alloc(e,n):null),(!c||!l)&&(c=this.newPage(Math.max(e,n)),l=c.packer.alloc(e,n))),!l)throw new Error("[engine] ".concat(e,"\xD7").concat(n," does not fit an atlas page"));let u=l;if(u.slot){let f=u.slot;c.ctx.clearRect(f.x,f.y,f.w,f.h);let h=document.createElement("canvas");h.width=f.w,h.height=f.h,h.getContext("2d").drawImage(t,u.x-f.x,u.y-f.y),c.surface.pending.push([h,f.x,f.y])}else c.surface.pending.push([t,u.x,u.y]);return c.ctx.drawImage(t,u.x,u.y),{surface:c.surface,x:u.x,y:u.y,w:e,h:n,scale:s,gen:this.gen,ox:o,oy:a,margin:i}}newPage(t){let e=this.pageSize;for(;e<t+4;)e*=2;let n=document.createElement("canvas");n.width=n.height=e;let s=n.getContext("2d"),o=fn(n),a={surface:o,packer:new qn(e,e),ctx:s};return this.pages.push(a),this.onPage(o),a}wipe(){this.gen++;let t=0;for(let e=0;e<this.pages.length;e++){let n=this.pages[e];if(t<this.maxPages&&n.surface.source.width===this.pageSize){this.pages[t++]=n;continue}n.surface.pending=[],this.onDrop(n.surface)}this.pages.length=t;for(let e of this.pages)e.packer.reset(),e.ctx.clearRect(0,0,e.surface.source.width,e.surface.source.height),e.surface.pending=[],e.surface.pending.push([e.surface.source,0,0])}};var xl=()=>{var t,e,n;let r=typeof document!="undefined"?(t=document.timeline)==null?void 0:t.currentTime:null;return typeof r=="number"&&Number.isFinite(r)?r:(n=(e=$.performance)==null?void 0:e.now())!=null?n:Date.now()},na=()=>{var r,t;return(t=(r=$.performance)==null?void 0:r.now())!=null?t:Date.now()},kr=class{constructor(t=xl){p(this,"now",t);p(this,"known",new Map);p(this,"smoothed",new Map);p(this,"times",new WeakMap);p(this,"lerp",new on);p(this,"amount",os);p(this,"drawnAt",NaN);p(this,"drawn",0);p(this,"smoothedBody",(t,e={})=>{var s;let n=e.interpolate!==!1;if(typeof t=="number"){let o=this.smoothed.get(t);return o?n&&(s=this.lerp.at(t,this.tick()))!=null?s:o.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,gl(e.smooth,this.defaultAmount),n)})}setLocal(t){this.amount=t?No:os,this.lerp=new on(t?Yr:{}),this.smoothed.clear()}get defaultAmount(){return this.amount}note(t,e,n=na()){for(let s of t)this.known.set(s.id,this.resolve(s.id,s.avatar)),e!==void 0&&Number.isFinite(e)&&Array.isArray(s.body)&&this.times.set(s.body,{t:e,arrival:n})}of(t){var e;return typeof t=="object"&&t!==null?t.avatar!==void 0?this.resolve(t.id,t.avatar):this.of(t.id):(e=this.known.get(t))!=null?e:Vr(t-1)}posed(t,e,n,s=!0){var a;let o=this.smooth(t,e,n);return s&&(a=this.lerp.at(t,this.tick()))!=null?a:o}smooth(t,e,n){var l,c;let s=this.smoothed.get(t);if(s&&s.raw===e&&s.amount===n)return s.body;s&&s.amount!==n&&this.lerp.forget(t);let o=n<1?Io(s==null?void 0:s.body,e,n):e;this.smoothed.set(t,{raw:e,body:o,amount:n});let a=this.times.get(e),i=(l=a==null?void 0:a.arrival)!=null?l:na();return this.lerp.push(t,(c=a==null?void 0:a.t)!=null?c:i,o,i),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,e){return Lo(e)?e:Vr(t-1)}};var os=.5,gl=(r,t=os)=>r===!1?1:typeof r=="number"?Math.min(Math.max(r,.05),1):t;var oa=new Float64Array(1),ra=new Int32Array(oa.buffer),pn=(r,t)=>(r=Math.imul(r^t,1540483477),r^r>>>15);function pt(r,t=2538058380){return r!==r?pn(t,2146959360):(oa[0]=r===0?0:r,pn(pn(t,ra[0]),ra[1]))}function sa(r,t=2166136261){for(let e=0;e<r.length;e++)t=Math.imul(t^r.charCodeAt(e),16777619);return t}function Ze(r){switch(typeof r){case"number":return pt(r);case"string":return sa(r);case"boolean":return r?1013904242:461845907;case"object":{if(r===null)return 625341585;if(Array.isArray(r)||r instanceof Float64Array){let n=1779033703^r.length;for(let s=0;s<r.length;s++){let o=r[s];n=pn(n,typeof o=="number"?pt(o):Ze(o))}return n}let t=1359893119,e=r;for(let n in e){let s=e[n];s!==void 0&&(t=t+pn(sa(n),Ze(s))|0)}return pn(t,2600822924)}default:return 0}}function dn(r,t){if(r===t)return!0;if(typeof r!="object"||typeof t!="object"||r===null||t===null)return typeof r=="number"&&typeof t=="number"&&r!==r&&t!==t;let e=Array.isArray(r)||r instanceof Float64Array;if(e!==(Array.isArray(t)||t instanceof Float64Array))return!1;if(e){let o=r,a=t;if(o.length!==a.length)return!1;for(let i=0;i<o.length;i++)if(o[i]!==a[i]&&!dn(o[i],a[i]))return!1;return!0}let n=r,s=t;for(let o in n)if(n[o]!==void 0&&!dn(n[o],s[o]))return!1;for(let o in s)if(s[o]!==void 0&&n[o]===void 0)return!1;return!0}function Yn(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return r.map(Yn);if(r instanceof Float64Array)return r.slice();let t={};for(let e in r)r[e]!==void 0&&(t[e]=Yn(r[e]));return t}var mn=class{constructor(t=1/0){p(this,"max",t);p(this,"buckets",new Map);p(this,"n",0)}get size(){return this.n}get(t,e=Ze(t)){let n=this.buckets.get(e);if(n){for(let s=0;s<n.length;s++)if(dn(n[s].key,t))return n[s].value}}set(t,e,n=Ze(t)){let s=this.buckets.get(n);if(s){for(let o of s)if(dn(o.key,t)){o.value=e;return}}this.n>=this.max&&this.clear(),(!s||!this.buckets.has(n))&&this.buckets.set(n,s=[]),s.push({key:Yn(t),value:e}),this.n++}clear(){this.buckets.clear(),this.n=0}};var as=0,aa=1,wr=2,is=3,bn=class{constructor(){p(this,"scale",1);p(this,"cOn",!1);p(this,"px0",0);p(this,"py0",0);p(this,"px1",0);p(this,"py1",0);p(this,"clipVer",0);p(this,"stack",[]);p(this,"sp",0);p(this,"real",0);p(this,"mute",0);p(this,"bnd",new Float64Array(4*(Vn+1)));p(this,"rx0",0);p(this,"ry0",0);p(this,"rx1",0);p(this,"ry1",0);p(this,"maxBlur",1/0);p(this,"time",0);p(this,"skipped",0);p(this,"gq",new Float64Array(4))}resetLayers(t){this.scale=t,this.sp=this.real=this.mute=0,this.skipped=0,this.cOn=!1,this.clipVer++}growQ(){let t=this.gq;this.grow(t[0],t[1],t[2],t[3])}grow(t,e,n,s){if(!this.real)return;let o=this.bnd,a=(this.real-1)*4;t<o[a]&&(o[a]=t),e<o[a+1]&&(o[a+1]=e),n>o[a+2]&&(o[a+2]=n),s>o[a+3]&&(o[a+3]=s)}area(t,e){let n=this.bnd,s=t*4,o=this.scale;return this.rx0=Math.max(Math.floor((n[s]-e)*o)-1,0),this.ry0=Math.max(Math.floor((n[s+1]-e)*o)-1,0),this.rx1=Math.min(Math.ceil((n[s+2]+e)*o)+1,this.canvas.width),this.ry1=Math.min(Math.ceil((n[s+3]+e)*o)+1,this.canvas.height),this.rx1>this.rx0&&this.ry1>this.ry0}clip(t,e,n,s){let o=this.scale,a=this.canvas.width,i=this.canvas.height,l=Math.min(Math.max(Math.round(t*o),0),a),c=Math.min(Math.max(Math.round(e*o),0),i),u=Math.min(Math.max(Math.round((t+n)*o),l),a),f=Math.min(Math.max(Math.round((e+s)*o),c),i);this.cOn&&l===this.px0&&c===this.py0&&u===this.px1&&f===this.py1||(this.cOn=!0,this.px0=l,this.py0=c,this.px1=u,this.py1=f,this.clipVer++)}unclip(){this.cOn&&(this.cOn=!1,this.clipVer++)}push(t){if(t<wr&&(this.mute||this.real>=Vn||!this.pushLayer())&&(t+=2),t===is)this.mute++;else if(t!==wr){let e=this.real*4;this.bnd[e]=this.bnd[e+1]=1/0,this.bnd[e+2]=this.bnd[e+3]=-1/0,this.real++}return this.stack[this.sp++]=t,t<wr}beginLayer(){return this.push(as)}beginMask(){this.push(this.sp&&this.stack[this.sp-1]===as?aa:is)}endLayer(t,e){if(!this.sp)return;let n=this.stack[--this.sp];if(n===is){if(this.mute--,!this.sp)return;n=this.stack[--this.sp]}if(n===aa){let s=--this.real,o=this.popLayer();this.area(s-1,0)&&this.composite(o,!0,1,null);let a=this.bnd,i=(s-1)*4,l=s*4;a[i]=Math.max(a[i],a[l]),a[i+1]=Math.max(a[i+1],a[l+1]),a[i+2]=Math.min(a[i+2],a[l+2]),a[i+3]=Math.min(a[i+3],a[l+3]),n=this.stack[--this.sp]}if(n===wr)Un(e)&&(this.skipped+=e.length);else if(n===as){let s=--this.real,o=Un(e)?e:null,a=this.popLayer();if(this.area(s,o?Yo(o,this.maxBlur):0)){this.composite(a,!1,t,o);let i=this.scale;this.grow(this.rx0/i,this.ry0/i,this.rx1/i,this.ry1/i)}}}closeLayers(){for(;this.sp;)this.endLayer(1)}};var kl=256,ia=8<<20,He=new Float64Array(32),$e={x:0,y:0,w:0,h:0};function wl(r){if(typeof r.filter!="string")return!1;r.filter="blur(1px)";let t=r.filter==="blur(1px)";return r.filter="none",t}function yn(r){let t=r.getContext("2d",{alpha:!0});return t?new ls(r,t):null}var ls=class extends bn{constructor(e,n){super();p(this,"canvas",e);p(this,"ctx",n);p(this,"kind","canvas2d");p(this,"maxTextureSize",4096);p(this,"features",{});p(this,"info",{renderer:"canvas2d"});p(this,"support");p(this,"lost",!1);p(this,"fxr",null);p(this,"quads",0);p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"tinted",new Map);p(this,"tintedN",0);p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"base");p(this,"top");p(this,"layers",[]);p(this,"scratch",[]);p(this,"nines",new Map);p(this,"ninePx",0);p(this,"frame",0);p(this,"hit",!1);p(this,"missed",new Map);this.support={filters:wl(n),shaders:!1},this.base=this.top={ctx:n,clipped:!1,ver:0},e.addEventListener("contextlost",()=>{this.lost=!0,this.lostListeners.forEach(s=>s())}),e.addEventListener("contextrestored",()=>{this.lost=!1,this.tinted.clear(),this.tintedN=0,this.dropNines(),this.restoredListeners.forEach(s=>s())})}resize(e,n){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==n&&(this.canvas.height=n)}createTexture(e){return{id:Wn(),width:e.width,height:e.height,source:e}}updateTexture(e,n,s=0,o=0){let a=n?s+n.width:1/0,i=n?o+n.height:1/0;for(let l of this.nines.values()){let c=l.key;c[0]===e.id&&c[1]<a&&c[1]+c[3]>s&&c[2]<i&&c[2]+c[4]>o&&this.dropNine(l)}for(let[l,c]of this.tinted){let u=c.filter(f=>f.id!==e.id);this.tintedN-=c.length-u.length,u.length?this.tinted.set(l,u):this.tinted.delete(l)}}destroyTexture(e){this.updateTexture(e)}begin(e,n,s){var a;this.resetLayers(s),(a=this.fxr)==null||a.tick(),this.frame++,this.quads=0,this.top=this.base,this.ctx=this.base.ctx;let o=this.ctx;this.base.clipped&&o.restore(),this.base.clipped=!1,this.base.ver=this.clipVer,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,this.canvas.width,this.canvas.height),n>0&&(o.fillStyle=$t(e,n),o.fillRect(0,0,this.canvas.width,this.canvas.height))}quad(e,n,s,o,a,i,l,c){se[0]=o,se[1]=a,se[2]=l,this.quadQ(e,n,s,i,c)}quadQ(e,n,s,o,a){n.w<=0||n.h<=0||(o===16777215?this.blit(e.source,n.x,n.y,n.w,n.h,s,a):this.blit(this.tint(e,n,o),0,0,n.w,n.h,s,a))}blit(e,n,s,o,a,i,l){let c=se[0],u=se[1],f=se[2];if(f<=0||this.mute)return;this.sync();let h=this.ctx,b=this.scale;if(this.real){let y=i[0]*c,x=i[1]*c,d=i[2]*u,m=i[3]*u;this.grow(i[4]+Math.min(0,y,d,y+d),i[5]+Math.min(0,x,m,x+m),i[4]+Math.max(0,y,d,y+d),i[5]+Math.max(0,x,m,x+m))}h.setTransform(i[0]*b,i[1]*b,i[2]*b,i[3]*b,i[4]*b,i[5]*b),h.globalAlpha=Math.min(f,1),l==="add"&&(h.globalCompositeOperation="lighter"),h.drawImage(e,n,s,o,a,0,0,c,u),l==="add"&&(h.globalCompositeOperation="source-over"),this.quads++}nineQ(e,n,s,o,a,i,l){var x,d,m;let c=s[8]+s[9],u=o[8]+o[9],f=Math.ceil(c*Math.hypot(a[0],a[1])*this.scale-1e-6),h=Math.ceil(u*Math.hypot(a[2],a[3])*this.scale-1e-6);if(a[1]===0&&a[2]===0||f>4096||h>4096)return!1;if(!(f>0&&h>0&&se[2]>0)||this.mute)return!0;let b=this.kept(e,n,s,o,f,h,i),y=(b!=null?b:b=(m=(x=this.scratch)[d=13*Math.ceil(Math.log2(f))+Math.ceil(Math.log2(h))])!=null?m:x[d]=document.createElement("canvas").getContext("2d")).canvas;if(y.width<f&&(y.width=f),y.height<h&&(y.height=h),!this.hit){b.clearRect(0,0,f+2,h+2);for(let g=0;g<12;g+=4){let v=Math.round(o[g]*h/u),k=Math.round((o[g]+o[g+1])*h/u);for(let R=0;R<12;R+=4){let F=Math.round(s[R]*f/c),I=Math.round((s[R]+s[R+1])*f/c);$e.x=n.x+s[R+2],$e.y=n.y+o[g+2],$e.w=s[R+3],$e.h=o[g+3],!(I<=F||k<=v||$e.w<=0||$e.h<=0)&&(i===16777215?b.drawImage(e.source,$e.x,$e.y,$e.w,$e.h,F,v,I-F,k-v):b.drawImage(this.tint(e,$e,i),0,0,$e.w,$e.h,F,v,I-F,k-v))}}}return se[0]=c,se[1]=u,this.blit(y,0,0,f,h,a,l),!0}kept(e,n,s,o,a,i,l){He[0]=e.id,He[1]=n.x,He[2]=n.y,He[3]=n.w,He[4]=n.h,He[5]=a,He[6]=i,He[7]=l,He.set(s,8),He.set(o,20);let c=Ze(He),u=this.nines.get(c);if(this.hit=!1,u)return dn(u.key,He)?(u.used=this.frame,this.hit=!0,u.ctx):null;let f=this.missed,h=f.get(c);f.size>4096&&f.clear(),f.set(c,this.frame);let b=a*i;if(h!==this.frame-1||b>ia)return null;let y;for(;this.ninePx+b>ia;){let m;for(let k of this.nines.values())k.used<this.frame-1&&!(m&&m.used<=k.used)&&(m=k);if(!m)return null;let g=m.ctx.canvas,v=!y&&g.width>=a&&g.height>=i&&g.width*g.height<=2*b;this.dropNine(m,v),v&&(y=m.ctx)}let x=y!=null?y:document.createElement("canvas").getContext("2d"),d=x.canvas;return y||(d.width=a,d.height=i),this.ninePx+=d.width*d.height,this.nines.set(c,{key:Yn(He),ctx:x,used:this.frame}),x}dropNine(e,n=!1){this.nines.delete(Ze(e.key));let s=e.ctx.canvas;this.ninePx-=s.width*s.height,n||(s.width=0)}dropNines(){for(let e of this.nines.values())this.dropNine(e)}tint(e,n,s){let o=pt(s,pt(n.h,pt(n.w,pt(n.y,pt(n.x,pt(e.id)))))),a=this.tinted.get(o);if(a)for(let c=0;c<a.length;c++){let u=a[c];if(u.id===e.id&&u.x===n.x&&u.y===n.y&&u.w===n.w&&u.h===n.h&&u.color===s)return u.canvas}this.tintedN>=kl&&(this.tinted.clear(),this.tintedN=0,a=void 0);let i=document.createElement("canvas");i.width=Math.ceil(n.w),i.height=Math.ceil(n.h);let l=i.getContext("2d");return l.drawImage(e.source,n.x,n.y,n.w,n.h,0,0,n.w,n.h),l.globalCompositeOperation="multiply",l.fillStyle=$t(s),l.fillRect(0,0,n.w,n.h),l.globalCompositeOperation="destination-in",l.drawImage(e.source,n.x,n.y,n.w,n.h,0,0,n.w,n.h),a||this.tinted.set(o,a=[]),a.push({id:e.id,x:n.x,y:n.y,w:n.w,h:n.h,color:s,canvas:i}),this.tintedN++,i}paint(e,n){this.sync();let s=this.ctx,o=this.scale;return s.setTransform(o,0,0,o,0,0),s.globalAlpha=Math.min(n,1),$t(e)}ellipse(e,n,s,o,a,i,l){if(l<=0||s<=0||o<=0||this.mute)return;let c=Math.max(s,o);this.grow(e-c,n-c,e+c,n+c);let u=this.ctx;u.fillStyle=this.paint(i,l),u.beginPath(),u.ellipse(e,n,s,o,a,0,Math.PI*2),u.fill(),this.quads++}trace(e,n,s=0){if(this.real)for(let a=0;a<n;a++)this.grow(e[a*2]-s,e[a*2+1]-s,e[a*2]+s,e[a*2+1]+s);let o=this.ctx;o.beginPath(),o.moveTo(e[0],e[1]);for(let a=1;a<n;a++)o.lineTo(e[a*2],e[a*2+1])}polygon(e,n,s,o){if(o<=0||n<3||this.mute)return;let a=this.ctx;a.fillStyle=this.paint(s,o),this.trace(e,n),a.closePath(),a.fill(),this.quads++}stroke(e,n,s,o,a,i){if(a<=0||s<=0||n<1||this.mute)return;let l=this.ctx;l.strokeStyle=this.paint(o,a),l.lineWidth=s,l.lineCap="round",l.lineJoin="round",this.trace(e,n,s/2),n===1&&l.lineTo(e[0],e[1]),i&&l.closePath(),l.stroke(),this.quads++}sync(){let e=this.top;if(e.ver===this.clipVer)return;let n=e.ctx;e.clipped&&n.restore(),e.clipped=this.cOn,e.ver=this.clipVer,this.cOn&&(n.save(),n.setTransform(1,0,0,1,0,0),n.beginPath(),n.rect(this.px0,this.py0,this.px1-this.px0,this.py1-this.py0),n.clip())}pushLayer(){let e=this.canvas.width,n=this.canvas.height,s=this.layers[this.real];if(!s||s.ctx.canvas.width!==e||s.ctx.canvas.height!==n){let a=document.createElement("canvas");a.width=e,a.height=n;let i=a.getContext("2d");if(!i)return!1;s=this.layers[this.real]={ctx:i,clipped:!1,ver:-1}}let o=s.ctx;return s.clipped&&o.restore(),s.clipped=!1,s.ver=-1,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,e,n),this.top=s,this.ctx=o,!0}popLayer(){return this.top=this.real>0?this.layers[this.real-1]:this.base,this.ctx=this.top.ctx,this.layers[this.real].ctx.canvas}composite(e,n,s,o){var y;let a=e,i="none",l=o&&Be.c2d?(y=this.fxr)!=null?y:this.fxr=Be.c2d(this):null;l&&(a=l.chain(e,o),i=l.css),this.sync();let c=this.ctx,u=this.rx0,f=this.ry0,h=this.rx1-u,b=this.ry1-f;c.setTransform(1,0,0,1,0,0),c.globalAlpha=Math.min(s,1),c.globalCompositeOperation=n?"destination-in":"source-over",i!=="none"&&(c.filter=i),c.drawImage(a,u,f,h,b,u,f,h,b),i!=="none"&&(c.filter="none"),c.globalCompositeOperation="source-over",this.quads++}end(){this.closeLayers();let e=this.stats;return e.drawCalls=e.quads=this.quads,e.filtersSkipped=this.skipped,e}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){var e;this.tinted.clear(),this.dropNines(),this.layers=[],this.scratch=[],(e=this.fxr)==null||e.destroy(),this.fxr=null}};var vr=class{constructor(t,e,n=8192){p(this,"instanced",t);p(this,"slots",e);p(this,"capacity",n);p(this,"f32");p(this,"u32");p(this,"quads",0);p(this,"textures");p(this,"bound",0);this.textures=new Array(e).fill(null);let s=n*(t?14:24),o=new ArrayBuffer(s*4);this.f32=new Float32Array(o),this.u32=new Uint32Array(o)}slot(t){let e=this.textures;for(let n=0;n<this.bound;n++)if(e[n]===t)return n;return this.bound>=this.slots?-1:(e[this.bound]=t,this.bound++)}has(t){for(let e=0;e<this.bound;e++)if(this.textures[e]===t)return!0;return!1}get full(){return this.quads>=this.capacity}get words(){return this.quads*(this.instanced?14:24)}reset(){this.quads=0;for(let t=0;t<this.bound;t++)this.textures[t]=null;this.bound=0}push(t,e,n,s,o,a,i,l,c,u,f,h,b,y){let x=this.f32;if(this.instanced){let d=this.quads*14;x[d++]=t,x[d++]=e,x[d++]=n,x[d++]=s,x[d++]=o,x[d++]=a,x[d++]=i,x[d++]=l,x[d++]=c,x[d++]=u,x[d++]=f,x[d++]=h,this.u32[d++]=b,x[d]=y}else{let d=this.quads*6*4;this.vertex(d,t,e,c,u,b,y),this.vertex(d+6,n,s,f,u,b,y),this.vertex(d+12,o,a,f,h,b,y),this.vertex(d+18,i,l,c,h,b,y)}this.quads++}pushQ(t,e){let n=this.f32;if(this.instanced){let s=this.quads*14;for(let o=0;o<12;o++)n[s+o]=t[o];this.u32[s+12]=t[12],n[s+13]=e}else{let s=this.quads*6*4,o=t[12];for(let a=0;a<4;a++,s+=6)n[s]=t[a*2],n[s+1]=t[a*2+1],n[s+2]=a===1||a===2?t[10]:t[8],n[s+3]=a>=2?t[11]:t[9],this.u32[s+4]=o,n[s+5]=e}this.quads++}vertex(t,e,n,s,o,a,i){let l=this.f32;l[t]=e,l[t+1]=n,l[t+2]=s,l[t+3]=o,this.u32[t+4]=a,l[t+5]=i}};function la(r){let t=new Uint16Array(r*6);for(let e=0,n=0,s=0;e<r;e++,n+=6,s+=4)t[n]=s,t[n+1]=s+1,t[n+2]=s+2,t[n+3]=s,t[n+4]=s+2,t[n+5]=s+3;return t}var Le={M:0,L:1,Q:2,C:3,Z:4},ba=[2,2,4,6,0],vl={M:0,L:1,Q:2,C:3,Z:4};function Rr(r,t){if(r.length>=t)return r;let e=new Float64Array(Math.max(t,r.length*2,16));return e.set(r),e}var Ar=new Map;function Al(r){var s,o;if(typeof r!="string")return r;let t=Ar.get(r);if(t)return t;t=[];let e=(s=r.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?s:[],n=-1;for(let a=0;a<e.length;){let i=e[a],l=vl[i.toUpperCase()];if(l!==void 0){n=l,a++,l===Le.Z&&t.push(Le.Z);continue}if(n<0||n===Le.Z){a++;continue}let c=ba[n];t.push(n);for(let u=0;u<c;u++)t.push(Number((o=e[a+u])!=null?o:0));a+=c,n===Le.M&&(n=Le.L)}return Ar.size>256&&Ar.clear(),Ar.set(r,t),t}var Et={subs:[],count:0},cs=null,Tt=null;function Sr(r,t){var o;let e=Tt;e||(e=(o=Et.subs[Et.count])!=null?o:null,e||Et.subs.push(e={pts:new Float64Array(64),n:0,closed:!1}),e.n=0,e.closed=!1,Et.count++,Tt=e);let n=e.n*2;n+2>e.pts.length&&(e.pts=Rr(e.pts,n+2));let s=cs;s?(e.pts[n]=s[0]*r+s[2]*t+s[4],e.pts[n+1]=s[1]*r+s[3]*t+s[5]):(e.pts[n]=r,e.pts[n+1]=t),e.n++}function Cr(r,t=null,e=1,n=6){let s=Al(r);Et.count=0,Tt=null,cs=t;let o=0,a=0,i=0,l=0,c=e/n;for(let u=0;u<s.length;){let f=s[u++],h=s;if(f===Le.M)Tt=null,o=i=h[u],a=l=h[u+1],Sr(o,a);else if(f===Le.L)o=h[u],a=h[u+1],Sr(o,a);else if(f===Le.Q){let b=h[u],y=h[u+1],x=h[u+2],d=h[u+3],m=ca((rt(b-o,y-a)+rt(x-b,d-y))*c);for(let g=1;g<=m;g++){let v=g/m,k=1-v;Sr(k*k*o+2*k*v*b+v*v*x,k*k*a+2*k*v*y+v*v*d)}o=x,a=d}else if(f===Le.C){let b=h[u],y=h[u+1],x=h[u+2],d=h[u+3],m=h[u+4],g=h[u+5],v=ca((rt(b-o,y-a)+rt(x-b,d-y)+rt(m-x,g-d))*c);for(let k=1;k<=v;k++){let R=k/v,F=1-R,I=F*F*F,A=3*F*F*R,S=3*F*R*R,P=R*R*R;Sr(I*o+A*b+S*x+P*m,I*a+A*y+S*d+P*g)}o=m,a=g}else if(f===Le.Z){Tt&&(Tt.closed=!0),Tt=null,o=i,a=l;continue}else break;u+=ba[f]}Tt=null,cs=null;for(let u=0;u<Et.count;u++){let f=Et.subs[u],h=f.n*2;f.closed&&f.n>=2&&Math.abs(f.pts[0]-f.pts[h-2])<1e-6&&Math.abs(f.pts[1]-f.pts[h-1])<1e-6&&f.n--}return Et}var rt=(r,t)=>Math.sqrt(r*r+t*t),ca=r=>Math.min(Math.max(Math.ceil(r),2),24);function Sl(r,t){let e=0;for(let n=0,s=t-1;n<t;s=n++)e+=(r[s*2]-r[n*2])*(r[s*2+1]+r[n*2+1]);return e}var Mr=new Int32Array(64),Tr=(r,t,e,n,s)=>((r[n*2]-r[e*2])*(r[s*2+1]-r[e*2+1])-(r[n*2+1]-r[e*2+1])*(r[s*2]-r[e*2]))*t;function ya(r,t,e){if(t<3)return 0;Mr.length<t&&(Mr=new Int32Array(Math.max(t,Mr.length*2)));let n=Mr,s=t,o=0;for(let c=0;c<t;c++)n[c]=c;let a=Sl(r,t)>0?1:-1,i=t*t+8,l=0;for(;s>3&&i-- >0;){let c=n[(l+s-1)%s],u=n[l%s],f=n[(l+1)%s],h=Tr(r,a,c,u,f)>0;if(h)for(let b=0;b<s;b++){let y=n[b];if(!(y===c||y===u||y===f)&&Tr(r,a,c,u,y)>=0&&Tr(r,a,u,f,y)>=0&&Tr(r,a,f,c,y)>=0){h=!1;break}}h?(e[o++]=c,e[o++]=u,e[o++]=f,n.copyWithin(l%s,l%s+1,s),s--,l=Math.max(l-1,0)):l=(l+1)%s}if(s===3)e[o++]=n[0],e[o++]=n[1],e[o++]=n[2];else if(s>3)for(let c=1;c+1<s;c++)e[o++]=n[0],e[o++]=n[c],e[o++]=n[c+1];return o}var Ml=.85,Er=new Float64Array(64),ua=new Float64Array(64),ha=new Float64Array(64),fa=new Float64Array(64),pa=new Float64Array(64),da=new Float64Array(64),ma=new Uint8Array(64),Kn=new Float64Array(8);function xa(r,t,e,n,s,o){let a=Kn;if(Er.length<t){let d=Math.max(t,Er.length*2);Er=new Float64Array(d),ua=new Float64Array(d),ha=new Float64Array(d),fa=new Float64Array(d),pa=new Float64Array(d),da=new Float64Array(d),ma=new Uint8Array(d)}let i=Er,l=ua,c=0;for(let d=0;d<t;d++){let m=r[d*2],g=r[d*2+1];!Number.isFinite(m)||!Number.isFinite(g)||c&&Math.abs(i[c-1]-m)<.001&&Math.abs(l[c-1]-g)<.001||(i[c]=m,l[c]=g,c++)}if(n&&c>2&&Math.abs(i[0]-i[c-1])<.001&&Math.abs(l[0]-l[c-1])<.001&&c--,c===0)return;if(c===1)return a[0]=i[0],a[1]=l[0],o();let u=n?c:c-1,f=ha,h=fa;for(let d=0;d<u;d++){let m=(d+1)%c,g=i[m]-i[d],v=l[m]-l[d],k=rt(g,v)||1;f[d]=-v/k,h[d]=g/k}let b=pa,y=da,x=ma;for(let d=0;d<c;d++){let m=n?(d-1+u)%u:d-1,g=d<u?d:-1;if(x[d]=1,m<0||g<0||f[m]*f[g]+h[m]*h[g]<Ml)continue;let k=f[m]+f[g],R=h[m]+h[g],F=rt(k,R)||1;k/=F,R/=F;let I=e/Math.max(k*f[g]+R*h[g],.5);b[d]=k*I,y[d]=R*I,x[d]=0}for(let d=0;d<u;d++){let m=(d+1)%c,g=x[d]?f[d]*e:b[d],v=x[d]?h[d]*e:y[d],k=x[m]?f[d]*e:b[m],R=x[m]?h[d]*e:y[m];a[0]=i[d]+g,a[1]=l[d]+v,a[2]=i[m]+k,a[3]=l[m]+R,a[4]=i[m]-k,a[5]=l[m]-R,a[6]=i[d]-g,a[7]=l[d]-v,s()}for(let d=0;d<c;d++)x[d]&&(a[0]=i[d],a[1]=l[d],o())}function us(r,t){let e=0,n=1/0;for(let s=0;s<t.length;s++){let o=Math.abs(Math.log(Math.max(r,.5)/t[s]));o<n&&(n=o,e=s)}return e}var Fr=[{x:240,y:0,w:8,h:8,r:3},{x:224,y:0,w:16,h:16,r:7},{x:192,y:0,w:32,h:32,r:15},{x:128,y:0,w:64,h:64,r:31},{x:0,y:0,w:128,h:128,r:63}],Pr=[4,8,16,32,64,128].map((r,t)=>({x:t*4,y:128,w:4,h:r,r:r/2-1})),dt={x:248,y:248,w:8,h:8},ka=Fr.map(r=>r.r*2),wa=Pr.map(r=>r.r*2),ga=(r,t)=>Math.min(Math.max(r+.5-t,0),1);function Tl(){let r=new Uint8ClampedArray(262144),t=(e,n,s)=>{let o=(n*256+e)*4;r[o]=r[o+1]=r[o+2]=255,r[o+3]=Math.round(s*255)};for(let e of Fr){let n=e.w/2;for(let s=0;s<e.h;s++)for(let o=0;o<e.w;o++)t(e.x+o,e.y+s,ga(e.r,Math.hypot(o+.5-n,s+.5-n)))}for(let e of Pr){let n=e.h/2;for(let s=0;s<e.h;s++)for(let o=0;o<e.w;o++)t(e.x+o,e.y+s,ga(e.r,Math.abs(s+.5-n)))}for(let e=0;e<dt.h;e++)for(let n=0;n<dt.w;n++)t(dt.x+n,dt.y+e,1);return r}function va(){let r=document.createElement("canvas");return r.width=r.height=256,r.getContext("2d").putImageData(new ImageData(Tl(),256,256),0,0),r}var Aa=8,_r="\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n",Fl=r=>"".concat(_r,"\nuniform sampler2D uTex[").concat(r,"];\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vec4 c;\n ").concat(Array.from({length:r},(t,e)=>e===r-1?"c = texture2D(uTex[".concat(e,"], vUv);"):"if (vSlot < ".concat(e,".5) c = texture2D(uTex[").concat(e,"], vUv); else ")).join("\n "),"\n gl_FragColor = c * vColor;\n}"),Pl="\nattribute vec2 aPos;\nattribute vec2 aUv;\nattribute vec4 aColor;\nattribute float aSlot;\nuniform vec2 uScale;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vUv = aUv;\n vColor = aColor;\n vSlot = aSlot;\n gl_Position = vec4(aPos * uScale + vec2(-1.0, 1.0), 0.0, 1.0);\n}",_l="\nattribute vec4 aCorner;\nattribute vec4 aP01;\nattribute vec4 aP23;\nattribute vec4 aUvRect;\nattribute vec4 aColor;\nattribute float aSlot;\nuniform vec2 uScale;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vec2 p = aP01.xy * aCorner.x + aP01.zw * aCorner.y + aP23.xy * aCorner.z + aP23.zw * aCorner.w;\n vUv = vec2(mix(aUvRect.x, aUvRect.z, aCorner.y + aCorner.z), mix(aUvRect.y, aUvRect.w, aCorner.z + aCorner.w));\n vColor = aColor;\n vSlot = aSlot;\n gl_Position = vec4(p * uScale + vec2(-1.0, 1.0), 0.0, 1.0);\n}",Ll={alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance"},Ol=["aCorner","aP01","aP23","aUvRect","aColor","aSlot"],Il=["aPos","aUv","aColor","aSlot"];function Ma(r,t,e={}){var o,a;let n=Ie(M({},Ll),{failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat!==!1}),s=t===2?r.getContext("webgl2",n):(o=r.getContext("webgl",n))!=null?o:r.getContext("experimental-webgl",n);if(!s||s.isContextLost())return null;try{return new hs(r,s,t,e)}catch(i){return console.warn("[engine] WebGL setup failed:",i),(a=s.getExtension("WEBGL_lose_context"))==null||a.loseContext(),null}}var hs=class extends bn{constructor(e,n,s,o){super();p(this,"canvas",e);p(this,"gl",n);p(this,"opts",o);p(this,"kind");p(this,"maxTextureSize");p(this,"support",{filters:!0,shaders:!0});p(this,"features",{});p(this,"info",{});p(this,"lost",!1);p(this,"main");p(this,"cur");p(this,"unit",-1);p(this,"onUnit",new Array(Aa).fill(void 0));p(this,"fbNow");p(this,"mapped",!0);p(this,"calls",{useProgram:0,bindTexture:0,activeTexture:0,bindFramebuffer:0});p(this,"vsrc","");p(this,"attrs",[]);p(this,"fxr",null);p(this,"batch");p(this,"dynamic");p(this,"staticBuf",null);p(this,"index");p(this,"vao",null);p(this,"inst",null);p(this,"vaoApi",null);p(this,"uScale",null);p(this,"textures",new Map);p(this,"kit");p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"tris",new Int32Array(192));p(this,"sU",0);p(this,"sV0",0);p(this,"sV1",0);p(this,"sColor",0);p(this,"sPacked",0);p(this,"sAlpha",0);p(this,"sHw",0);p(this,"strokeSeg",()=>{let e=this.q;e.set(Kn),e[8]=e[10]=this.sU,e[9]=this.sV0,e[11]=this.sV1,e[12]=this.sPacked,this.put(this.kit)});p(this,"strokeDisc",()=>this.ellipse(Kn[0],Kn[1],this.sHw,this.sHw,0,this.sColor,this.sAlpha));p(this,"q",new Float64Array(13));p(this,"layers",[]);p(this,"layerTex",new Map);p(this,"bScis",!1);p(this,"bx0",0);p(this,"by0",0);p(this,"bx1",0);p(this,"by1",0);p(this,"onContextLost",e=>{e.preventDefault(),this.lost=!0;for(let n of this.lostListeners)n()});p(this,"onContextRestored",()=>{try{this.layers=[],this.layerTex.clear(),this.fxr=null,this.resetLayers(this.scale),this.setup();for(let e of this.textures.keys())this.textures.set(e,this.upload(e.source));this.lost=!1;for(let e of this.restoredListeners)e()}catch(e){console.warn("[engine] WebGL restore failed:",e)}});p(this,"views",new Map);this.kind=s===2?"webgl2":"webgl1",this.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),this.setup(),this.kit=this.createTexture(va()),Be.live=this,e.addEventListener("webglcontextlost",this.onContextLost,!1),e.addEventListener("webglcontextrestored",this.onContextRestored,!1)}setup(){let e=this.gl,n=this.kind==="webgl2"?e:null;if(this.inst=null,this.opts.instancing!==!1)if(n)this.inst={divisor:(f,h)=>n.vertexAttribDivisor(f,h),draw:(f,h)=>n.drawElementsInstanced(e.TRIANGLES,f,e.UNSIGNED_SHORT,0,h)};else{let f=e.getExtension("ANGLE_instanced_arrays");f&&(this.inst={divisor:(h,b)=>f.vertexAttribDivisorANGLE(h,b),draw:(h,b)=>f.drawElementsInstancedANGLE(e.TRIANGLES,h,e.UNSIGNED_SHORT,0,b)})}if(this.vaoApi=null,this.opts.vao!==!1)if(n)this.vaoApi={create:()=>n.createVertexArray(),bind:f=>n.bindVertexArray(f),remove:f=>n.deleteVertexArray(f)};else{let f=e.getExtension("OES_vertex_array_object");f&&(this.vaoApi={create:()=>f.createVertexArrayOES(),bind:h=>f.bindVertexArrayOES(h),remove:h=>f.deleteVertexArrayOES(h)})}let s=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),o=Math.max(1,Math.min(Aa,s)),a=this.inst!==null;this.vsrc=a?_l:Pl,this.attrs=a?Ol:Il,this.main=this.cur=this.build(Fl(o));let i=this.main.p;e.useProgram(i),this.calls.useProgram++,this.unit=-1,this.onUnit.fill(void 0),this.fbNow=void 0,this.uScale=this.main.uScale,e.uniform1iv(e.getUniformLocation(i,"uTex"),Int32Array.from({length:o},(f,h)=>h)),this.batch=new vr(a,o),this.vaoApi&&(this.vao=this.vaoApi.create(),this.vaoApi.bind(this.vao)),this.dynamic=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic),e.bufferData(e.ARRAY_BUFFER,this.batch.f32.byteLength,e.DYNAMIC_DRAW),this.index=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.index),e.bufferData(e.ELEMENT_ARRAY_BUFFER,la(a?1:8192),e.STATIC_DRAW);let l=f=>e.getAttribLocation(i,f),c=(f,h,b,y,x,d,m)=>{let g=l(f);g<0||(e.enableVertexAttribArray(g),e.vertexAttribPointer(g,h,b,y,x,d),this.inst&&this.inst.divisor(g,m))};if(a){let f=56;c("aP01",4,e.FLOAT,!1,f,0,1),c("aP23",4,e.FLOAT,!1,f,16,1),c("aUvRect",4,e.FLOAT,!1,f,32,1),c("aColor",4,e.UNSIGNED_BYTE,!0,f,48,1),c("aSlot",1,e.FLOAT,!1,f,52,1),this.staticBuf=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.staticBuf),e.bufferData(e.ARRAY_BUFFER,Float32Array.of(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),e.STATIC_DRAW),c("aCorner",4,e.FLOAT,!1,16,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic)}else{let f=24;c("aPos",2,e.FLOAT,!1,f,0,0),c("aUv",2,e.FLOAT,!1,f,8,0),c("aColor",4,e.UNSIGNED_BYTE,!0,f,16,0),c("aSlot",1,e.FLOAT,!1,f,20,0)}e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);let u=e.getExtension("WEBGL_debug_renderer_info");this.info={version:e.getParameter(e.VERSION),renderer:u?e.getParameter(u.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),vendor:u?e.getParameter(u.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR)},this.features={instancing:a,vao:this.vaoApi!==null,textureSlots:o,maxTextureSize:this.maxTextureSize}}upload(e){let n=this.gl,s=n.createTexture();return this.bindTex(s),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),s}resize(e,n){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==n&&(this.canvas.height=n)}createTexture(e){let n={id:Wn(),width:e.width,height:e.height,source:e};return this.textures.set(n,this.lost?null:this.upload(e)),n}updateTexture(e,n,s=0,o=0){if(this.lost)return;this.batch.has(e)&&this.flush();let a=this.gl,i=this.textures.get(e);i&&(this.bindTex(i),!n||n===e.source&&s===0&&o===0?a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,e.source):a.texSubImage2D(a.TEXTURE_2D,0,s,o,a.RGBA,a.UNSIGNED_BYTE,n))}destroyTexture(e){this.batch.has(e)&&this.flush();let n=this.textures.get(e);n&&!this.lost&&this.deleteTex(n),this.textures.delete(e)}begin(e,n,s){if(this.stats.drawCalls=this.stats.quads=this.stats.filtersSkipped=0,this.batch.reset(),this.resetLayers(s),this.bScis=!1,this.lost)return;let o=this.gl;o.disable(o.SCISSOR_TEST),this.bindFb(null),o.viewport(0,0,this.canvas.width,this.canvas.height);let a=n;o.clearColor((e>>16&255)/255*a,(e>>8&255)/255*a,(e&255)/255*a,a),o.clear(o.COLOR_BUFFER_BIT),this.use(this.main),o.uniform2f(this.uScale,2*s/this.canvas.width,-2*s/this.canvas.height),this.mapped=!0}build(e){var i;let n=this.gl,s=Sa(n,n.VERTEX_SHADER,this.vsrc),o;try{o=Sa(n,n.FRAGMENT_SHADER,e)}catch(l){throw n.deleteShader(s),l}let a=n.createProgram();if(n.attachShader(a,s),n.attachShader(a,o),this.attrs.forEach((l,c)=>n.bindAttribLocation(a,c,l)),n.linkProgram(a),n.deleteShader(s),n.deleteShader(o),!n.getProgramParameter(a,n.LINK_STATUS)){let l=(i=n.getProgramInfoLog(a))!=null?i:"?";throw n.deleteProgram(a),new Error("link: ".concat(l))}return{p:a,uScale:n.getUniformLocation(a,"uScale"),locs:new Map}}u(e,n){let s=e.locs.get(n);return s===void 0&&e.locs.set(n,s=this.gl.getUniformLocation(e.p,n)),s}use(e){this.cur!==e&&(this.cur=e,this.gl.useProgram(e.p),this.calls.useProgram++)}bindTex(e,n=this.unit<0?0:this.unit){let s=this.gl;this.onUnit[n]!==e&&(this.unit!==n&&(s.activeTexture(s.TEXTURE0+n),this.calls.activeTexture++,this.unit=n),s.bindTexture(s.TEXTURE_2D,e),this.calls.bindTexture++,this.onUnit[n]=e)}deleteTex(e){this.gl.deleteTexture(e);for(let n=0;n<this.onUnit.length;n++)this.onUnit[n]===e&&(this.onUnit[n]=null)}bindFb(e){if(e)for(let s=0;s<this.onUnit.length;s++)this.onUnit[s]===e.gl&&this.bindTex(null,s);let n=e?e.fb:null;this.fbNow!==n&&(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n),this.calls.bindFramebuffer++,this.fbNow=n)}slotOf(e){this.batch.full&&this.flush();let n=this.batch.slot(e);return n<0&&(this.flush(),n=this.batch.slot(e)),n}quad(e,n,s,o,a,i,l,c){se[0]=o,se[1]=a,se[2]=l,this.quadQ(e,n,s,i,c)}quadQ(e,n,s,o,a){let i=se[2];if(this.lost||i<=0)return;let l=this.q,c=se[0],u=se[1],f=s[4],h=s[5],b=s[0]*c,y=s[1]*c,x=s[2]*u,d=s[3]*u;l[0]=f,l[1]=h,l[2]=b+f,l[3]=y+h,l[4]=b+x+f,l[5]=y+d+h,l[6]=x+f,l[7]=d+h;let m=1/e.width,g=1/e.height;l[8]=n.x*m,l[9]=n.y*g,l[10]=(n.x+n.w)*m,l[11]=(n.y+n.h)*g,l[12]=vt(o,i,a==="add"),this.put(e)}put(e){if(this.mute)return;let n=this.q,s=!1,o=Math.min(n[0],n[2],n[4],n[6]),a=Math.max(n[0],n[2],n[4],n[6]),i=Math.min(n[1],n[3],n[5],n[7]),l=Math.max(n[1],n[3],n[5],n[7]);if(this.cOn){if(this.px1<=this.px0||this.py1<=this.py0)return;let u=this.scale,f=this.px0/u,h=this.py0/u,b=this.px1/u,y=this.py1/u;if(a<=f||o>=b||l<=h||i>=y)return;if(o<f||a>b||i<h||l>y){let x=n[0],d=n[1],m=n[2],g=n[5];if(d===n[3]&&m===n[4]&&g===n[7]&&n[6]===x){if(x!==m){let v=Math.min(Math.max(x,f),b),k=Math.min(Math.max(m,f),b),R=n[8],F=(n[10]-R)/(m-x);n[10]=R+(k-x)*F,n[8]=R+(v-x)*F,n[0]=n[6]=v,n[2]=n[4]=k}if(d!==g){let v=Math.min(Math.max(d,h),y),k=Math.min(Math.max(g,h),y),R=n[9],F=(n[11]-R)/(g-d);n[11]=R+(k-d)*F,n[9]=R+(v-d)*F,n[1]=n[3]=v,n[5]=n[7]=k}}else s=!0}}let c=this.bx0===this.px0&&this.by0===this.py0&&this.bx1===this.px1&&this.by1===this.py1;if(s?(!this.bScis||!c)&&(this.flush(),this.bScis=!0,this.bx0=this.px0,this.by0=this.py0,this.bx1=this.px1,this.by1=this.py1):this.bScis&&!(this.cOn&&c)&&(this.flush(),this.bScis=!1),this.real){let u=this.gq;u[0]=o,u[1]=i,u[2]=a,u[3]=l,this.growQ()}this.batch.pushQ(n,this.slotOf(e))}ellipse(e,n,s,o,a,i,l){if(this.lost||l<=0||s<=0||o<=0)return;let c=Fr[us(Math.max(s,o)*2*this.scale,ka)],u=c.w/2/c.r,f=s*u,h=o*u,b=Math.cos(a),y=Math.sin(a),x=b*f,d=y*f,m=-y*h,g=b*h,v=1/256,k=this.q;k[0]=e-x-m,k[1]=n-d-g,k[2]=e+x-m,k[3]=n+d-g,k[4]=e+x+m,k[5]=n+d+g,k[6]=e-x+m,k[7]=n-d+g,k[8]=c.x*v,k[9]=c.y*v,k[10]=(c.x+c.w)*v,k[11]=(c.y+c.h)*v,k[12]=vt(i,l),this.put(this.kit)}polygon(e,n,s,o){if(this.lost||o<=0||n<3)return;this.tris.length<n*3&&(this.tris=new Int32Array(Math.max(n*3,this.tris.length*2)));let a=this.tris,i=ya(e,n,a),l=vt(s,o),c=(dt.x+dt.w/2)/256,u=(dt.y+dt.h/2)/256;for(let f=0;f<i;f+=3){let h=a[f]*2,b=a[f+1]*2,y=a[f+2]*2,x=this.q;x[0]=e[h],x[1]=e[h+1],x[2]=e[b],x[3]=e[b+1],x[4]=x[6]=e[y],x[5]=x[7]=e[y+1],x[8]=x[10]=c,x[9]=x[11]=u,x[12]=l,this.put(this.kit)}}stroke(e,n,s,o,a,i){if(this.lost||a<=0||s<=0||n<1)return;let l=Pr[us(s*this.scale,wa)],c=s/2*(l.h/2/l.r);this.sPacked=vt(o,a),this.sColor=o,this.sAlpha=a,this.sU=(l.x+l.w/2)/256,this.sV0=l.y/256,this.sV1=(l.y+l.h)/256,this.sHw=s/2,xa(e,n,c,i,this.strokeSeg,this.strokeDisc)}target(e,n,s,o){let a=this.gl,i=a.createTexture();this.bindTex(i),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,e,n,0,a.RGBA,a.UNSIGNED_BYTE,null);let l=o?a.LINEAR:a.NEAREST;a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,l),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,l),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.bindTex(null);let c=a.createFramebuffer();a.bindFramebuffer(a.FRAMEBUFFER,c),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,i,0);let u=a.checkFramebufferStatus(a.FRAMEBUFFER)===a.FRAMEBUFFER_COMPLETE;if(this.fbNow=c,this.bindFb(this.parent()),!u)return this.deleteTex(i),a.deleteFramebuffer(c),null;let f={tex:{id:Wn(),width:e,height:n,source:this.canvas},gl:i,fb:c,w:e,h:n,f:s};return this.layerTex.set(f.tex,i),f}drop(e){this.batch.has(e.tex)&&this.flush(),this.deleteTex(e.gl),this.gl.deleteFramebuffer(e.fb),this.layerTex.delete(e.tex)}parent(){return this.real>0?this.layers[this.real-1]:null}layerAt(e){var a;let n=this.canvas.width,s=this.canvas.height,o=(a=this.layers[e])!=null?a:null;return o&&(o.w!==n||o.h!==s)&&(this.drop(o),o=this.layers[e]=null),o!=null?o:this.layers[e]=this.target(n,s,1,!1)}pushLayer(){if(this.lost)return!1;this.flush();let e=this.layerAt(this.real);if(!e)return!1;let n=this.gl;return this.bindFb(e),n.disable(n.SCISSOR_TEST),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),!0}popLayer(){return this.flush(),this.bindFb(this.parent()),this.layers[this.real].tex}filters(){var e;return this.lost||!Be.gl?null:(e=this.fxr)!=null?e:this.fxr=Be.gl(this)}composite(e,n,s,o){var i;if(o&&((i=this.filters())!=null&&i.chain(e,s,o)))return;let a=this.gl;n&&a.blendFunc(a.ZERO,a.SRC_ALPHA),this.final(this.main,e,1,s),n&&(this.flush(),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA))}final(e,n,s,o){let a=this.gl,i=this.canvas.width,l=this.canvas.height,c=this.scale;(e!==this.main||!this.mapped)&&(this.bindFb(this.parent()),a.viewport(0,0,i,l),this.use(e),a.uniform2f(e.uScale,2*c/i,-2*c/l),this.mapped=e===this.main);let u=this.rx0/c,f=this.ry0/c,h=this.rx1/c,b=this.ry1/c,y=1/(s*n.width),x=1/(s*n.height),d=this.q;d[0]=d[6]=u,d[1]=d[3]=f,d[2]=d[4]=h,d[5]=d[7]=b,d[8]=this.rx0*y,d[9]=1-this.ry0*x,d[10]=this.rx1*y,d[11]=1-this.ry1*x,d[12]=vt(16777215,o),this.put(n),e!==this.main&&this.flush()}remap(){let e=this.gl;this.bindFb(this.parent()),e.viewport(0,0,this.canvas.width,this.canvas.height),this.use(this.main),e.uniform2f(this.uScale,2*this.scale/this.canvas.width,-2*this.scale/this.canvas.height),this.mapped=!0}upload2(e){let n=this.gl,s=e.words;if(this.kind==="webgl2")return n.bufferSubData(n.ARRAY_BUFFER,0,e.f32,0,s);let o=this.views.get(s);o||(this.views.size>=256&&this.views.clear(),this.views.set(s,o=e.f32.subarray(0,s))),n.bufferSubData(n.ARRAY_BUFFER,0,o)}flush(){var s,o;let e=this.batch;if(!e.quads||this.lost)return e.reset();let n=this.gl;this.bScis?(n.enable(n.SCISSOR_TEST),n.scissor(this.bx0,this.canvas.height-this.by1,this.bx1-this.bx0,this.by1-this.by0)):n.disable(n.SCISSOR_TEST),this.upload2(e);for(let a=0;a<e.bound;a++){let i=e.textures[a];this.bindTex((o=(s=this.textures.get(i))!=null?s:this.layerTex.get(i))!=null?o:null,a)}this.inst?this.inst.draw(6,e.quads):n.drawElements(n.TRIANGLES,e.quads*6,n.UNSIGNED_SHORT,0),this.stats.drawCalls++,this.stats.quads+=e.quads,e.reset()}end(){return this.closeLayers(),this.flush(),this.stats.filtersSkipped=this.skipped,this.stats}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){var n,s;let e=this.gl;Be.live===this&&(Be.live=null),this.canvas.removeEventListener("webglcontextlost",this.onContextLost),this.canvas.removeEventListener("webglcontextrestored",this.onContextRestored);try{for(let o of this.textures.values())o&&e.deleteTexture(o);for(let o of this.layers)o&&(e.deleteTexture(o.gl),e.deleteFramebuffer(o.fb));(n=this.fxr)==null||n.destroy(),this.fxr=null,e.deleteBuffer(this.dynamic),e.deleteBuffer(this.index),this.staticBuf&&e.deleteBuffer(this.staticBuf),this.vao&&this.vaoApi&&this.vaoApi.remove(this.vao),e.deleteProgram(this.main.p),(s=e.getExtension("WEBGL_lose_context"))==null||s.loseContext()}catch(o){}this.textures.clear()}};function Sa(r,t,e){var s;let n=r.createShader(t);if(r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS)){let o=(s=r.getShaderInfoLog(n))!=null?s:"?";throw r.deleteShader(n),new Error(o)}return n}function fs(r="auto"){switch(r){case"canvas2d":return["canvas2d"];case"webgl1":return["webgl1","canvas2d"];default:return["webgl2","webgl1","canvas2d"]}}function gn(r,t={}){let e=r;for(let n of fs(t.renderer)){let s=n==="canvas2d"?yn(e):Ma(e,n==="webgl2"?2:1,t);if(s)return s;e=Qn(e)}throw new Error("No renderer: this browser has neither WebGL nor Canvas 2D")}function Qn(r){var e;let t=r.cloneNode(!1);return(e=r.parentNode)==null||e.replaceChild(t,r),t}function Ta(r=typeof location!="undefined"?location.search:""){let t=new URLSearchParams(r).get("renderer");return t==="canvas"?"canvas2d":t==="webgl2"||t==="webgl1"||t==="canvas2d"||t==="webgl"||t==="auto"?t:void 0}var Rt=class{constructor(t,e={}){p(this,"atlas",t);p(this,"tags",new Map);p(this,"count",0);p(this,"m",ht());p(this,"measure",null);p(this,"height");p(this,"font");var n,s;this.height=(n=e.tagHeight)!=null?n:34,this.font=(s=e.tagFont)!=null?s:"Nunito, sans-serif"}drop(){for(let t of this.tags.values())for(let e of t.values())for(let n of e.values())this.atlas.release(n);this.tags.clear(),this.count=0}get(t,e,n){let s=this.tags.get(t);s||this.tags.set(t,s=new Map);let o=s.get(e);o||s.set(e,o=new Map);let a=o.get(n);return a&&this.atlas.valid(a)?a:this.bake(t,e,n)}bake(t,e,n){var h;let s=this.height,o="700 ".concat(Math.round(s*.65),"px ").concat(this.font),a=(h=this.measure)!=null?h:this.measure=document.createElement("canvas").getContext("2d");a.font=o;let i=Math.round(s*.4),l=Math.ceil(a.measureText(t).width)+i*2,c=this.atlas.bake((l+2)*n,(s+2)*n,b=>{b.scale(n,n),b.translate(1,1);let y=s/2;b.beginPath(),b.moveTo(y,0),b.lineTo(l-y,0),b.arc(l-y,y,y,-Math.PI/2,Math.PI/2),b.lineTo(y,s),b.arc(y,y,y,Math.PI/2,Math.PI*3/2),b.closePath(),b.fillStyle=e,b.fill(),b.fillStyle="#fff",b.font=o,b.textAlign="center",b.textBaseline="middle",b.fillText(t,l/2,s/2+1)},n,1,1,1);++this.count>64&&(this.drop(),this.count=1);let u=this.tags.get(t);u||this.tags.set(t,u=new Map);let f=u.get(e);return f||u.set(e,f=new Map),f.set(n,c),c}draw(t,e,n,s,o,a,i,l,c,u,f){let h=sn(n,o,{band:Nl(s)});if(!h)return;let b=this.height,y=this.get(a,i,c),x=y.w/y.scale-2,d=Math.min(Math.max(h.head.x-x/2,4),u-x-4),m=Math.min(Math.max(h.head.y-h.headR*2.2-b,4),f-b-4);De(this.m,null,d-1,m-1,0,1,1),t.quad(e(y.surface),y,this.m,y.w/y.scale,y.h/y.scale,16777215,l,"normal")}},Nl=r=>r.band==="3-5"||r.band==="9-12"?r.band:"6-8";var Dl=(r,t=!1)=>t?Math.min(wt(2,Math.round(Math.log2(Math.max(r,8)))),256):Math.min(wt(2,Math.ceil(Math.log2(Math.max(r,8))*2)/2),512);function Or(r,t=null){var s,o,a,i;let e={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},n=(l,c,u)=>{let f=t?t[0]*l+t[2]*c+t[4]:l,h=t?t[1]*l+t[3]*c+t[5]:c,b=t?Math.hypot(t[0],t[1]):1;e.minX=Math.min(e.minX,f-u*b),e.minY=Math.min(e.minY,h-u*b),e.maxX=Math.max(e.maxX,f+u*b),e.maxY=Math.max(e.maxY,h+u*b)};for(let l of r){let c="lw"in l&&l.stroke?((s=l.lw)!=null?s:1)/2:0;switch(l.k){case"circle":n(l.x-l.r,l.y-l.r,c),n(l.x+l.r,l.y+l.r,c),n(l.x-l.r,l.y+l.r,c),n(l.x+l.r,l.y-l.r,c);break;case"ellipse":case"rect":{let u=l.k==="ellipse"?Math.max(l.rx,l.ry):Math.hypot(l.w,l.h)/2;n(l.x-u,l.y-u,c),n(l.x+u,l.y+u,c),n(l.x-u,l.y+u,c),n(l.x+u,l.y-u,c);break}case"path":{let u=Cr(l.d);for(let f=0;f<u.count;f++){let h=u.subs[f];for(let b=0;b<h.n;b++)n(h.pts[b*2],h.pts[b*2+1],c)}break}case"line":for(let u=0;u+1<l.pts.length;u+=2)n(l.pts[u],l.pts[u+1],c);break;case"group":{let u=De(ht(),t,l.x,l.y,(o=l.rot)!=null?o:0,(a=l.s)!=null?a:1,(i=l.s)!=null?i:1),f=Or(l.items,u);Number.isFinite(f.minX)&&(e.minX=Math.min(e.minX,f.minX),e.minY=Math.min(e.minY,f.minY),e.maxX=Math.max(e.maxX,f.maxX),e.maxY=Math.max(e.maxY,f.maxY));break}}}return e}var Wt=class{constructor(t){p(this,"atlas",t);p(this,"seen",new WeakSet);p(this,"baked",new WeakMap);p(this,"m",ht());p(this,"stack",[]);p(this,"local",ht());p(this,"pts",new Float64Array(128));p(this,"stats",{baked:0,vector:0});p(this,"bakeGroups",!0);p(this,"coarse",!1);p(this,"gen",0);p(this,"live",new Set)}setTier(t){let e=t==="low";if(e!==this.coarse){this.coarse=e,this.gen++;for(let n of this.live)this.atlas.release(n.frame);this.live.clear()}}draw(t,e,n,s,o,a,i){var u;let l=typeof s=="string"?(u=an(s))!=null?u:Ht:s,c=Hn(n,l,o);return c.length?(a<=0||(a<1?(this.paint(t,e,c,null,t.beginLayer()?1:a,i),t.endLayer(a)):this.paint(t,e,c,null,a,i)),!0):!1}paint(t,e,n,s,o,a,i=0){var l,c,u,f,h,b,y,x,d,m,g;for(let v=0;v<n.length;v++){let k=n[v];if(k.k==="group"){let z=De((c=(l=this.stack)[i])!=null?c:l[i]=ht(),s,k.x,k.y,(u=k.rot)!=null?u:0,(f=k.s)!=null?f:1,(h=k.s)!=null?h:1),B=o*((b=k.alpha)!=null?b:1);if(this.bakeGroups&&this.seen.has(k.items)){let G=rt(z[0],z[1])*a,L=this.bake(k.items,G);if(L){let U=L.frame,Y=this.m;Y.set(z),Y[4]=z[0]*-L.ox+z[2]*-L.oy+z[4],Y[5]=z[1]*-L.ox+z[3]*-L.oy+z[5],t.quad(e(U.surface),U,Y,U.w/L.k,U.h/L.k,16777215,B,"normal"),this.stats.baked++;continue}}this.seen.add(k.items),this.stats.vector++,this.paint(t,e,k.items,z,B,a,i+1);continue}let R=o*((y=k.alpha)!=null?y:1),F=s?rt(s[0],s[1]):1,I=s?Math.atan2(s[1],s[0]):0,A=((x=k.lw)!=null?x:1)*F,S=k.stroke&&((d=k.lw)!=null?d:1)>0?Te(k.stroke):null,P=k.fill&&k.k!=="line"?Te(k.fill):null;if(k.k==="circle"||k.k==="ellipse"){let z=s?s[0]*k.x+s[2]*k.y+s[4]:k.x,B=s?s[1]*k.x+s[3]*k.y+s[5]:k.y,G=(k.k==="circle"?k.r:k.rx)*F,L=(k.k==="circle"?k.r:k.ry)*F,U=(k.k==="ellipse"&&(m=k.rot)!=null?m:0)+I;if(P&&S)t.ellipse(z,B,G+A/2,L+A/2,U,S[0],R*S[1]),t.ellipse(z,B,Math.max(G-A/2,0),Math.max(L-A/2,0),U,P[0],R*P[1]);else if(P)t.ellipse(z,B,G,L,U,P[0],R*P[1]);else if(S){let Y=Math.min(Math.max(Math.ceil(Math.max(G,L)*a*.6),12),64),Q=this.pts=Rr(this.pts,Y*2),Ee=Math.cos(U),ue=Math.sin(U);for(let ke=0;ke<Y;ke++){let we=ke/Y*Math.PI*2,oe=Math.cos(we)*G,Re=Math.sin(we)*L;Q[ke*2]=z+oe*Ee-Re*ue,Q[ke*2+1]=B+oe*ue+Re*Ee}t.stroke(Q,Y,A,S[0],R*S[1],!0)}continue}if(k.k==="line"){if(!S)continue;let z=k.pts.length>>1,B=this.pts=Rr(this.pts,z*2);for(let G=0;G<z;G++){let L=k.pts[G*2],U=k.pts[G*2+1];B[G*2]=s?s[0]*L+s[2]*U+s[4]:L,B[G*2+1]=s?s[1]*L+s[3]*U+s[5]:U}t.stroke(B,z,A,S[0],R*S[1],!1);continue}let H=k.k==="path"?Cr(k.d,s,F*a):Bl(k,De(this.local,s,k.x,k.y,(g=k.rot)!=null?g:0,1,1),a*F);for(let z=0;z<H.count;z++){let B=H.subs[z],G=B.n,L=k.k==="rect"||B.closed;P&&G>=3&&(t.polygon(B.pts,G,P[0],R*P[1]),S||t.stroke(B.pts,G,1/a,P[0],R*P[1],!0)),S&&t.stroke(B.pts,G,A,S[0],R*S[1],L)}}}bake(t,e){let n=Dl(e,this.coarse),s=this.baked.get(t),o=s==null?void 0:s.get(n);if(o&&o.gen===this.gen&&this.atlas.valid(o.frame))return o;o&&this.live.delete(o);let a=Or(t);if(!Number.isFinite(a.minX))return null;let i=2/n,l=(a.maxX-a.minX+i*2)*n,c=(a.maxY-a.minY+i*2)*n;if(l>1024||c>1024)return null;let u=-a.minX+i,f=-a.minY+i,b={frame:this.atlas.bake(l,c,y=>{y.scale(n,n),y.translate(u,f),nn(y,t)}),k:n,ox:u,oy:f,gen:this.gen};return s||this.baked.set(t,s=new Map),s.set(n,b),this.live.add(b),b}},kn=new Array(36).fill(0),wn=0,st=(r,t=NaN,e=NaN,n=NaN,s=NaN)=>{kn[wn++]=r,r!==Le.Z&&(kn[wn++]=t,kn[wn++]=e,r===Le.Q&&(kn[wn++]=n,kn[wn++]=s))};function Bl(r,t,e){let n=Math.max(0,Math.min(r.r,r.w/2,r.h/2)),s=-r.w/2,o=-r.h/2,{M:a,L:i,Q:l,Z:c}=Le;return wn=0,st(a,s+n,o),st(i,s+r.w-n,o),st(l,s+r.w,o,s+r.w,o+n),st(i,s+r.w,o+r.h-n),st(l,s+r.w,o+r.h,s+r.w-n,o+r.h),st(i,s+n,o+r.h),st(l,s,o+r.h,s,o+r.h-n),st(i,s,o+n),st(l,s,o,s+n,o),st(c),Cr(kn,t,e)}function Ea(r,t={}){var F,I;let e=gn(r,t),n=new Mt(Math.min(1024,e.maxTextureSize),2);n.onDrop=A=>{A.texture&&e.destroyTexture(A.texture),A.texture=null};let s=new Wt(n),o=()=>{let A=new kr;return t.local&&A.setLocal(!0),A},a=o(),i=new Map,l=1e6,c=t.smooth===!1?1:typeof t.smooth=="number"?Math.min(Math.max(t.smooth,.05),1):a.defaultAmount,u=Zn(e),f=new Rt(n,t),h={w:1,h:1},b=1,y=0,x=!1,d=()=>f.drop(),m=typeof document!="undefined"?document.fonts:void 0;(F=m==null?void 0:m.ready)==null||F.then(()=>{x||d()}),(I=m==null?void 0:m.addEventListener)==null||I.call(m,"loadingdone",d);let g=()=>{let A=Qn(e.canvas),S=yn(A);if(S){console.warn("[engine] avatars: WebGL context lost for good, switching to Canvas 2D"),e.destroy(),e=S;for(let P of n.pages)P.surface.texture=null;u=Zn(e),y=0}},v=()=>{if(!e.lost)return y=0,!0;let A=performance.now();return y||(y=A),A-y>3e3&&g(),!e.lost},k=()=>{var S,P;let A=e.canvas;t.units?(b=(S=t.pixelRatio)!=null?S:1,h.w=t.units.width,h.h=t.units.height):(b=(P=t.pixelRatio)!=null?P:Math.min($.devicePixelRatio||1,2),h.w=A.clientWidth||A.width/b,h.h=A.clientHeight||A.height/b),e.resize(Math.max(1,Math.round(h.w*b)),Math.max(1,Math.round(h.h*b))),e.begin(0,0,b)},R=(A,S)=>{var H;if(A.key===void 0)return(H=A.id)!=null?H:S+1;let P=i.get(A.key);return P===void 0&&(i.size>256&&i.clear(),i.set(A.key,P=l++)),P};return{get renderer(){return e},get kind(){return e.kind},get lost(){return e.lost},get canvas(){return e.canvas},draw(A,S){var P,H,z,B;if(v()){k();for(let G=0;G<A.length;G++){let L=A[G];if(!Array.isArray(L.body))continue;let U=R(L,G),Y=c<1||t.interpolate!==!1?a.posed(U,L.body,c,t.interpolate!==!1):L.body,Q=(H=an((P=L.avatar)!=null?P:""))!=null?H:Ht,Ee=(z=L.alpha)!=null?z:1;!s.draw(e,u,Y,Q,S,Ee,b)||!L.name||f.draw(e,u,Y,Q,S,L.name,(B=L.color)!=null?B:"#6FA0E0",Ee,b,h.w,h.h)}e.end()}},clear(){v()&&(k(),e.end())},reset(){a=o(),i.clear()},destroy(){var A;x=!0,(A=m==null?void 0:m.removeEventListener)==null||A.call(m,"loadingdone",d),e.destroy()}}}var Lr=new Map;function Ra(r,t,e=Math.min($.devicePixelRatio||1,2)){var a;let n="".concat(r,"|").concat(t,"|").concat(e),s=Lr.get(n);if(s)return s;s=document.createElement("canvas"),s.width=s.height=Math.round(t*e);let o=s.getContext("2d");return o.scale(e,e),o.beginPath(),o.rect(0,0,t,t),o.clip(),nn(o,Oo((a=an(r))!=null?a:Ht,t)),Lr.size>64&&Lr.clear(),Lr.set(n,s),s}function Zn(r){return t=>{if(t.texture||(t.texture=r.createTexture(t.source),t.pending.length=0),t.pending.length){for(let[e,n,s]of t.pending)r.updateTexture(t.texture,e,n,s);t.pending.length=0}return t.texture}}var ps='Fredoka, Nunito, "Varela Round", system-ui, sans-serif',Xt="rgba(10,16,30,0.75)";function ds(r,t){var i,l,c,u,f,h;let e=(i=r.size)!=null?i:40,n=r.outline?r.outline===!0?Xt:r.outline:null,s=n?(l=r.outlineWidth)!=null?l:Math.max(e*.12,3):0,o=r.shadow&&t?r.shadow===!0?Xt:r.shadow:null,a=o?(c=r.shadowBlur)!=null?c:e*.25:0;return{size:e,font:(u=r.font)!=null?u:ps,weight:(f=r.weight)!=null?f:700,color:(h=r.color)!=null?h:"#FBEFE3",outline:n,ow:s,shadow:o,blur:a,pad:s/2+a*1.2+2,th:e*1.25}}var Ca=(r,t)=>"".concat(r.weight," ").concat(r.size*t,"px ").concat(r.font);function ms(r,t,e,n,s,o){r.scale(n,n),r.font=Ca(e,1),r.textBaseline="middle",r.textAlign="left",r.lineJoin="round",e.shadow&&(r.shadowColor=e.shadow,r.shadowBlur=e.blur*n),e.outline&&(r.strokeStyle=e.outline,r.lineWidth=e.ow,r.strokeText(t,s,o),r.shadowColor="transparent"),r.fillStyle=e.color,r.fillText(t,s,o)}var vn=null;function bs(r,t,e){return vn!=null||(vn=document.createElement("canvas").getContext("2d")),vn.font=Ca(t,e),vn.measureText(r).width/e}var ot=class extends ze{constructor(e,n,s={}){super(e,null);p(this,"_text");p(this,"_style");p(this,"dirty",!0);p(this,"bakedScale",0);p(this,"bakedFontGen",-1);p(this,"bakedEffects",!0);p(this,"capW",0);p(this,"capH",0);this._text=n;let F=s,{x:o,y:a,rotation:i,scale:l,scaleX:c,scaleY:u,alpha:f,visible:h,tint:b,blend:y,z:x,anchor:d,hitRadius:m,clip:g,mask:v,filters:k}=F,R=en(F,["x","y","rotation","scale","scaleX","scaleY","alpha","visible","tint","blend","z","anchor","hitRadius","clip","mask","filters"]);this._style=R,this.bake(),this.set({x:o,y:a,rotation:i,scale:l,scaleX:c,scaleY:u,alpha:f,visible:h,tint:b,blend:y,z:x,hitRadius:m,clip:g,mask:v,filters:k}),d!==void 0&&(this.anchor=d)}get text(){return this._text}set text(e){let n=String(e);n!==this._text&&(this._text=n,this.dirty=!0)}get style(){return this._style}set style(e){this._style=M(M({},this._style),e),this.dirty=!0}bitmap(){let e=this._style.bitmapFont;if(!e)return null;let n=typeof e=="string"?this.kernel.bitmapFont(e):e;if(this.autoAnchor){let s=this._style.align;this.anchorX=s==="left"?0:s==="right"?1:.5,this.anchorY=.5}return n}get naturalWidth(){var n;let e=this.bitmap();return e?e.measure(this._text)*(((n=this._style.size)!=null?n:e.size)/e.size):super.naturalWidth}get naturalHeight(){var n;let e=this.bitmap();return e?e.lineHeight*(((n=this._style.size)!=null?n:e.size)/e.size):super.naturalHeight}frameNow(){return this._style.bitmapFont?null:this.bake()}draw(e,n,s){var b;let o=this.bitmap();if(!o)return super.draw(e,n,s);let a=((b=this._style.size)!=null?b:o.size)/o.size,i=o.measure(this._text)*a,l=o.lineHeight*a,c=this.width,u=this.height,f=i>0?c/i:1,h=l>0?u/l:1;o.run(this._text,e,this.world,-this.anchorX*c,-this.anchorY*u,a*f,a*h,s,n,this.blend)}destroy(){this._frame&&this.kernel.atlas.release(this._frame),super.destroy()}bake(){let e=this.kernel;if(this._style.bitmapFont)return null;let n=e.pixelScale,s=e.effects;return!this.dirty&&n===this.bakedScale&&e.fontGen===this.bakedFontGen&&s===this.bakedEffects&&e.atlas.valid(this._frame)?this._frame:this.rebake()}rebake(){var d;let e=this.kernel,n=e.pixelScale,s=e.effects;this.dirty=!1,this.bakedScale=n,this.bakedFontGen=e.fontGen,this.bakedEffects=s;let o=ds(this._style,s),{pad:a,th:i}=o,l=bs(this._text,o,n),c=(l+a*2)*n,u=(i+a*2)*n,f=(d=this._style.align)!=null?d:"center",h=f==="left"?a:f==="right"?a+l:a+l/2,b=m=>ms(m,this._text,o,n,a,a+i/2),y=this._frame,x=null;return y&&e.atlas.valid(y)&&y.scale===n&&(x=e.atlas.rebake(y,c,u,b,this.capW,this.capH),x?Object.assign(x,{ox:h,oy:a+i/2,margin:a}):e.atlas.release(y)),x||(this.capW=Math.ceil(c*1.25+16),this.capH=Math.ceil(u),x=e.atlas.bake(this.capW,this.capH,b,n,h,a+i/2,a),x.w=Math.ceil(c),x.h=Math.ceil(u)),this._frame=x,this.autoAnchor&&this.useFrameAnchor(),this._w=this._h=null,x}};var Ae=(r,t=0)=>{let e=Number(r);return Number.isFinite(e)?e:t};function Sn(r){var n,s,o,a,i,l;typeof r=="string"&&/^\s*[{[]/.test(r)&&(r=JSON.parse(r));let t={size:0,lineHeight:0,base:0,pages:[],chars:[],kernings:[]},e=(c,u)=>{var f;c==="info"?t.size=Math.abs(Ae(u.size)):c==="common"?(t.lineHeight=Ae(u.lineHeight),t.base=Ae(u.base)):c==="page"?t.pages[Ae(u.id)]=String((f=u.file)!=null?f:""):c==="char"?t.chars.push({id:Ae(u.id),x:Ae(u.x),y:Ae(u.y),width:Ae(u.width),height:Ae(u.height),xoffset:Ae(u.xoffset),yoffset:Ae(u.yoffset),xadvance:Ae(u.xadvance),page:Ae(u.page)}):t.kernings.push({first:Ae(u.first),second:Ae(u.second),amount:Ae(u.amount)})};if(typeof r=="object"){let c=r;e("info",(n=c.info)!=null?n:{}),e("common",(s=c.common)!=null?s:{});for(let[u,f]of((o=c.pages)!=null?o:[]).entries())e("page",{id:u,file:f});for(let u of(a=c.chars)!=null?a:[])e("char",u);for(let u of(i=c.kernings)!=null?i:[])e("kerning",u)}else{let c=/(?:^|<)\s*(info|common|page|char|kerning)\s([^\n<>]*)/gm,u=/(\w+)=(?:"([^"]*)"|([^\s/>]+))/g;for(let f=c.exec(r);f;f=c.exec(r)){let h={};for(let b=u.exec(f[2]);b;b=u.exec(f[2]))h[b[1]]=(l=b[2])!=null?l:b[3];e(f[1],h)}}return t.size||(t.size=t.lineHeight),t}var An=class{constructor(t,e,n,s=null,o=null){p(this,"baker",s);p(this,"host",o);p(this,"size");p(this,"lineHeight");p(this,"base");p(this,"ascii",new Array(128));p(this,"more",new Map);p(this,"kern",new Map);p(this,"bScale",0);p(this,"bFontGen",-1);p(this,"bEffects",!1);p(this,"bGen",-1);this.size=t,this.lineHeight=e,this.base=n}set(t,e){t<128?this.ascii[t]=e:this.more.set(t,e)}setKerning(t,e,n){this.kern.set(t*1114112+e,n)}prepare(){let t=this.host;if(!(!t||t.pixelScale===this.bScale&&t.fontGen===this.bFontGen&&t.effects===this.bEffects&&t.atlas.gen===this.bGen)){this.bScale=t.pixelScale,this.bFontGen=t.fontGen,this.bEffects=t.effects,this.bGen=t.atlas.gen;for(let e of this.ascii)e&&t.atlas.release(e.frame);for(let e of this.more.values())e&&t.atlas.release(e.frame);this.ascii.fill(void 0),this.more.clear()}}glyph(t){let e=t<128?this.ascii[t]:this.more.get(t);return(e===void 0||e&&this.host&&!this.host.atlas.valid(e.frame))&&(e=this.baker?this.baker(t):null,this.set(t,e)),e}kerning(t,e){var n;return this.kern.size&&(n=this.kern.get(t*1114112+e))!=null?n:0}measure(t){return this.run(t)}run(t,e,n,s=0,o=0,a=1,i=1,l=0,c=1,u="normal"){this.prepare();let f=0,h=-1;for(let b=0;b<t.length;b++){let y=t.charCodeAt(b);y>=55296&&y<56320&&b+1<t.length&&(y=t.codePointAt(b),b++),h>=0&&(f+=this.kerning(h,y)),h=y;let x=this.glyph(y);x&&(e&&x.w>0&&x.h>0&&(jn(n,s+(f+x.x)*a,o+x.y*i),e.r.quad(e.tex(x.frame.surface),x.frame,ge,x.w*a,x.h*i,l,c,u)),f+=x.advance)}return f}};function Fa(r,t){let e=new An(r.size,r.lineHeight,r.base);for(let n of r.chars){let s=t[n.page];if(!s)continue;let o={surface:s,x:n.x,y:n.y,w:n.width,h:n.height,scale:1,gen:0,ox:0,oy:0,margin:0};e.set(n.id,{frame:o,x:n.xoffset,y:n.yoffset,w:n.width,h:n.height,advance:n.xadvance})}for(let n of r.kernings)e.setKerning(n.first,n.second,n.amount);return e}function Pa(r,t){var a,i;let e=M({},t),n=(a=t.size)!=null?a:40,s=l=>{let c=String.fromCodePoint(l),u=r.pixelScale,f=ds(e,r.effects),h=bs(c,f,u),b=r.atlas.bake((h+f.pad*2)*u,(f.th+f.pad*2)*u,y=>ms(y,c,f,u,f.pad,f.pad+f.th/2),u);return{frame:b,x:-f.pad,y:-f.pad,w:b.w/u,h:b.h/u,advance:h}},o=new An(n,n*1.25,n,s,r);o.prepare();for(let l of(i=t.chars)!=null?i:"0123456789")o.glyph(l.codePointAt(0));return o}var zl=.5;function ys(r){let t=[];for(let[e,n]of[["left",q.leftWrist],["right",q.rightWrist]]){let s=r[n*3],o=r[n*3+1],a=r[n*3+2];s!==void 0&&o!==void 0&&Number.isFinite(s)&&Number.isFinite(o)&&(a!=null?a:0)>=zl&&t.push({side:e,x:s,y:o})}return t}var Mn=r=>Bn[((r-1)%Bn.length+Bn.length)%Bn.length],Hl=["left","right"];function Ir(r,t,e,n,s=()=>null,o={}){var i,l;let a=[];for(let c of r){let u=(i=s(c))!=null?i:c.body;if(Array.isArray(u)){if(o.orientation==="portrait"){for(let f of Hl){let h=uo(u,f,{orientation:"portrait"});o.hold&&(h=o.hold.at(tn.key(c.id,f),h,(l=o.t)!=null?l:0)),h&&a.push({player:c.id,side:f,x:h.x*e,y:h.y*n,color:Mn(c.id)})}continue}for(let f of ys(u)){let h=t(f);a.push({player:c.id,side:f.side,x:h.x*e,y:h.y*n,color:Mn(c.id)})}}}return a}function Jn(r,t,e,n=0){let s=r.world,o=zo(s,t,e);if(!o)return!1;let a=Math.hypot(s[0],s[1])||1,i=Math.hypot(s[2],s[3])||1,[l,c]=o;if(r.hitRadius!=null){let y=r.hitRadius+n/((a+i)/2);return l*l+c*c<=y*y}let u=-r.anchorX*r.width-n/a,f=-r.anchorY*r.height-n/i,h=(1-r.anchorX)*r.width+n/a,b=(1-r.anchorY)*r.height+n/i;return l>=u&&l<=h&&c>=f&&c<=b}function Nr(r,t,e,n=0){for(let s of t)if((e===void 0||s.player===e)&&Jn(r,s.x,s.y,n))return s;return null}function $l(r){var t;switch(r.type){case"circle":case"ring":case"star":return[r.r*2,r.r*2];case"ellipse":return[r.rx*2,r.ry*2];case"roundRect":return[r.w,r.h];case"line":return[r.length,(t=r.lw)!=null?t:4];case"path":return r.r?[r.r*2,r.r*2]:[r.size,r.size]}}function Gl(r){var n,s,o;let t=r.type==="line"?0:r.stroke?((n=r.lw)!=null?n:2)/2:0,e=r.shadow?r.shadow.blur*1.5+Math.max(Math.abs((s=r.shadow.x)!=null?s:0),Math.abs((o=r.shadow.y)!=null?o:0)):0;return Math.ceil(t+e+1)}var _a=(r,t)=>t||!r.shadow?r:Ie(M({},r),{shadow:void 0});function xs(r,t,e){let n=Gl(t),s=t.type==="roundRect",[o,a]=s?[Math.min(t.w,t.r*2+4/e),Math.min(t.h,t.r*2+4/e)]:$l(t),i=(o+n*2)*e,l=(a+n*2)*e;return{frame:r.bake(i,l,u=>{u.scale(e,e),u.translate(n+o/2,n+a/2),Ul(u,t,o,a)},e,n+o/2,n+a/2,n),slice:s?Math.ceil((t.r+n)*e):0,w:s?t.w:o,h:s?t.h:a}}function Ul(r,t,e,n){var c,u,f,h,b,y,x;r.lineJoin="round",r.lineCap="round";let s=new Path2D;switch(t.type){case"circle":case"ring":s.arc(0,0,t.r,0,Math.PI*2);break;case"ellipse":s.ellipse(0,0,t.rx,t.ry,0,0,Math.PI*2);break;case"roundRect":s.roundRect(-e/2,-n/2,e,n,Math.min(t.r,e/2,n/2));break;case"star":{let d=(c=t.points)!=null?c:5,m=t.r*((u=t.inner)!=null?u:.5);for(let g=0;g<d*2;g++){let v=g%2?m:t.r,k=-Math.PI/2+g*Math.PI/d;g?s.lineTo(Math.cos(k)*v,Math.sin(k)*v):s.moveTo(Math.cos(k)*v,Math.sin(k)*v)}s.closePath();break}case"line":s.moveTo(-e/2+n/2,0),s.lineTo(e/2-n/2,0);break;case"path":{let d=t.r?t.r*2/t.size:1,m=new DOMMatrix([d,0,0,d,-t.size/2*d,-t.size/2*d]);s.addPath(new Path2D(t.d),m);break}}let o=t.shadow,a=()=>{var m,g;if(!o)return;let d=r.getTransform();r.shadowColor=o.color,r.shadowBlur=o.blur*d.a,r.shadowOffsetX=((m=o.x)!=null?m:0)*d.a,r.shadowOffsetY=((g=o.y)!=null?g:0)*d.a},i=()=>{r.shadowColor="transparent",r.shadowBlur=0};if(t.type==="line"){a(),r.strokeStyle=(h=(f=t.stroke)!=null?f:t.fill)!=null?h:"#fff",r.lineWidth=n,r.stroke(s);return}let l=t.type==="ring";if(t.outlineBelow&&t.fill&&t.stroke&&!l){a(),r.strokeStyle=t.stroke,r.lineWidth=(b=t.lw)!=null?b:2,r.stroke(s),i(),r.fillStyle=t.fill,r.fill(s);return}t.fill&&!l&&(a(),r.fillStyle=t.fill,r.fill(s),i()),(t.stroke||l)&&((!t.fill||l)&&a(),l&&t.fill&&(r.fillStyle=t.fill,r.fill(s)),r.strokeStyle=(y=t.stroke)!=null?y:"#fff",r.lineWidth=(x=t.lw)!=null?x:2,r.stroke(s),i())}var Tn=class{constructor(){p(this,"ctx",null);p(this,"master",null);p(this,"buffers",new Map);p(this,"held",!1);p(this,"muted",!1);p(this,"volume",1);if(typeof addEventListener=="function"){let t=()=>{var e;(e=this.context())==null?void 0:e.resume().catch(()=>{})};for(let e of["pointerdown","keydown","touchstart"])addEventListener(e,t,{once:!0,capture:!0})}}context(){var e;if(this.ctx)return this.ctx;let t=(e=$.AudioContext)!=null?e:$.webkitAudioContext;if(!t)return null;try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.connect(this.ctx.destination),this.held&&this.ctx.suspend()}catch(n){return null}return this.ctx}load(t,e){return lt(this,null,function*(){let n=this.context();if(!n)return;let s=yield(yield fetch(e)).arrayBuffer();this.buffers.set(t,yield n.decodeAudioData(s))})}has(t){return this.buffers.has(t)}play(t,e={}){var i,l,c;let n=this.context(),s=this.buffers.get(t);if(!n||!s||!this.audible)return()=>{};let o=n.createBufferSource();o.buffer=s,o.loop=(i=e.loop)!=null?i:!1,o.playbackRate.value=(l=e.rate)!=null?l:1;let a=n.createGain();return a.gain.value=((c=e.volume)!=null?c:1)*this.volume,o.connect(a).connect(this.master),o.start(),()=>{try{o.stop()}catch(u){}}}tone(t,e=.25,n={}){var o,a;let s=this.context();if(!(!s||!this.audible))try{let i=s.createOscillator(),l=s.createGain();i.type=(o=n.type)!=null?o:"sine",i.frequency.setValueAtTime(t,s.currentTime),n.to&&i.frequency.exponentialRampToValueAtTime(n.to,s.currentTime+e),l.gain.setValueAtTime(((a=n.volume)!=null?a:.12)*this.volume,s.currentTime),l.gain.exponentialRampToValueAtTime(.001,s.currentTime+e),i.connect(l).connect(this.master),i.start(),i.stop(s.currentTime+e)}catch(i){}}get audible(){return!this.muted&&!this.held}hold(){var t;this.held=!0,(t=this.ctx)==null||t.suspend().catch(()=>{})}release(){var t;this.held=!1,(t=this.ctx)==null||t.resume().catch(()=>{})}destroy(){var t;(t=this.ctx)==null||t.close().catch(()=>{}),this.ctx=null}};var Vl={high:{resolution:1.5,particles:1,effects:!0,maxBlur:32},medium:{resolution:1,particles:.5,effects:!1,maxBlur:16},low:{resolution:.75,particles:.2,effects:!1,maxBlur:0}},at=["high","medium","low"];function mt(r){let t=Vl[r];return Ie(M({name:r},t),{scale:e=>e<=0?0:Math.max(1,Math.round(e*t.particles))})}var La=r=>at[Math.min(at.indexOf(r)+1,at.length-1)],Dr=(r,t)=>{if(!r.length)return NaN;let e=[...r].sort((n,s)=>n-s);return e[Math.min(e.length-1,Math.max(0,Math.floor(t*(e.length-1)+.5)))]},Oa=12,Ia=r=>er(r,.5);function er(r,t=.1){let e=Dr(r,t);if(!Number.isFinite(e))return 1e3/60;let n=[144,120,90,75,60,50,30],s=60;for(let o of n)Math.abs(1e3/o-e)<Math.abs(1e3/s-e)&&(s=o);return 1e3/s}function Br(r,t){let e=t.refresh!==void 0&&Number.isFinite(t.refresh)&&t.refresh>0?t.refresh:er(t.intervals),n=Dr(t.intervals,.5),s=Dr(t.intervals,.9),o=Dr(t.cpu,.5);if(!Number.isFinite(n))return r==="canvas2d"?"low":"medium";let a=l=>l<=e*1.25,i=l=>!Number.isFinite(o)||o<e*l;return r==="canvas2d"?a(s)&&i(.25)?"medium":"low":a(s)&&i(.5)?"high":a(n)?"medium":"low"}function Na(r,t){return r.length<30?!1:r.filter(n=>n>t*1.5).length/r.length>.5}var Da="0.1.1",Wl=720*3600*1e3,Ba=(r,t,e)=>"fabi-play.engine-tier:".concat(Da,":").concat(r,":").concat(t,":").concat(e),za=(r,t,e)=>"fablee-engine-tier:".concat(Da,":").concat(r,":").concat(t,":").concat(e);function Ha(r,t,e=Date.now()){var n;try{let s=JSON.parse((n=r==null?void 0:r.getItem(t))!=null?n:"null");if(s&&at.includes(s.tier)&&typeof s.at=="number"&&e-s.at<Wl)return typeof s.refresh=="number"&&s.refresh>0?{name:s.tier,refresh:s.refresh}:{name:s.tier}}catch(s){}return null}function gs(r,t,e,n,s=Date.now()){try{r==null||r.setItem(t,JSON.stringify(n!==void 0&&Number.isFinite(n)?{tier:e,at:s,refresh:n}:{tier:e,at:s}))}catch(o){}}function $a(r=typeof location!="undefined"?location.search:""){let t=new URLSearchParams(r).get("tier");return at.includes(t)?t:void 0}function ks(r,t){let e=t==null?void 0:t.tier;if(at.includes(e))return r==="canvas2d"&&e==="high"?"medium":e}var ws=r=>typeof(r==null?void 0:r.hz)=="number"&&r.hz>=20&&r.hz<=240?er([1e3/r.hz],.5):NaN,vs=(r,t)=>at.indexOf(r)>=at.indexOf(t)?r:t;function Ga(r,t,e){return r?{name:r,from:"forced"}:t?{name:e?vs(t,e):t,from:"hint"}:e?{name:e,from:"cache"}:null}var Xl=/^\s*(<|>|[^+\-<>=\s][^+=]*?)?\s*(?:([+-])=\s*(\d*\.?\d+))?\s*$/,En=class{constructor(t={}){p(this,"steps",[]);p(this,"labels",new Map);p(this,"end",0);p(this,"prevStart",0);p(this,"elapsed",0);p(this,"iter",0);p(this,"last",0);p(this,"delayLeft");p(this,"_paused");p(this,"done",!1);p(this,"rewinding",!1);p(this,"promise");p(this,"resolve");p(this,"repeat");p(this,"yoyo");p(this,"onComplete");var e,n;this.repeat=Math.floor((e=t.repeat)!=null?e:0),this.yoyo=!!t.yoyo,this.delayLeft=(n=t.delay)!=null?n:0,this._paused=!!t.paused,this.onComplete=t.onComplete,this.promise=new Promise(s=>this.resolve=s)}get duration(){return this.end}get time(){return this.last}get paused(){return this._paused}get finished(){return this.done}at(t){if(t===void 0)return this.end;if(typeof t=="number")return Math.max(t,0);let e=Xl.exec(t);if(!e)throw new Error('[engine] timeline: bad position "'.concat(t,'"'));let[,n,s,o]=e,a=o?(s==="-"?-1:1)*Number(o):0,i=this.end;if(n==="<")i=this.prevStart;else if(n&&n!==">"){let l=this.labels.get(n.trim());l===void 0?this.labels.set(n.trim(),this.end):i=l}return Math.max(i+a,0)}add(t){let e=this.steps.length;for(;e>0&&this.steps[e-1].start>t.start;)e--;return this.steps.splice(e,0,t),this.prevStart=t.start,this.end=Math.max(this.end,t.start+t.dur),this}to(t,e,n,s="quadOut"){var i,l;let o=typeof s=="object"?s:{ease:s},a=typeof o.ease=="function"?o.ease:At[(i=o.ease)!=null?i:"quadOut"];return this.add({target:t,to:e,from:null,fn:null,start:this.at(o.at)+((l=o.delay)!=null?l:0),dur:Math.max(n,0),ease:a,onUpdate:o.onUpdate,p:-1})}set(t,e,n){return this.add({target:t,to:e,from:null,fn:null,start:this.at(n),dur:0,ease:At.linear,p:-1})}call(t,e){return this.add({target:null,to:null,from:null,fn:t,start:this.at(e),dur:0,ease:At.linear,p:-1})}label(t,e){return this.labels.set(t,this.at(e)),this}wait(t){return this.end+=Math.max(t,0),this.prevStart=this.end,this}pause(){return this._paused=!0,this}resume(){return this._paused=!1,this}stop(){this.done||(this.done=!0,this.resolve())}seek(t){let e=Math.min(typeof t=="string"&&this.labels.has(t)?this.labels.get(t):this.at(t),this.end),n=this.yoyo&&this.iter%2===1;return this.elapsed=this.iter*this.end+(n?this.end-e:e),this.render(e),this}then(t,e){return this.promise.then(t,e)}update(t){if(this._paused||this.done)return;if(this.delayLeft>0){if(this.delayLeft-=t,this.delayLeft>0)return;t=-this.delayLeft,this.delayLeft=0}let e=this.end;if(e<=0)return this.render(0),this.complete();this.elapsed+=t;let n=this.repeat<0?1/0:e*(this.repeat+1),s=Math.min(this.elapsed,n),o=s>=n?this.repeat:Math.floor(s/e);for(;this.iter<o;){let i=this.yoyo&&this.iter%2===1;this.render(i?0:e),this.iter++,this.yoyo||(this.rewinding=!0,this.render(0),this.rewinding=!1)}let a=s-o*e;this.render(this.yoyo&&o%2===1?e-a:a),s>=n&&this.complete()}complete(){var t;this.done||(this.done=!0,(t=this.onComplete)==null||t.call(this),this.resolve())}render(t){let e=this.steps;if(t>=this.last)for(let n=0;n<e.length;n++){let s=e[n];t>=s.start&&this.apply(s,t)}else for(let n=e.length-1;n>=0;n--){let s=e[n];s.p>=0&&this.apply(s,t)}this.last=t}apply(t,e){var i,l;let n=t.dur>0?Math.min(Math.max((e-t.start)/t.dur,0),1):e>t.start||e===t.start&&!this.rewinding?1:0;if(n===t.p)return;if(t.p=n,t.fn){this.rewinding||t.fn();return}let s=t.target;if(s.destroyed||s._free)return;let o=t.to;if(!t.from){t.from={};for(let c in o)t.from[c]=Number((i=s[c])!=null?i:0)}let a=t.ease(n);for(let c in o)s[c]=t.from[c]+(o[c]-t.from[c])*a;(l=t.onUpdate)==null||l.call(t,a)}};var Rn=class{constructor(){p(this,"list",[]);p(this,"timelines",[])}timeline(t){let e=new En(t);return this.timelines.push(e),e}tween(t,e,n,s="quadOut"){var c;let o=typeof s=="object"?s:{ease:s},a=typeof o.ease=="function"?o.ease:At[(c=o.ease)!=null?c:"quadOut"],i,l=new Promise(u=>{var b;let f=Object.keys(e),h=new Float64Array(f.length);f.forEach((y,x)=>h[x]=Number(e[y])),i={target:t,keys:f,to:h,from:new Float64Array(f.length),started:!1,duration:Math.max(n,0),time:0,delay:(b=o.delay)!=null?b:0,ease:a,onUpdate:o.onUpdate,done:u,dead:!1}});return this.list.push(i),Object.assign(l,{stop:()=>this.finish(i)})}stopAll(t){let e=this.list;for(let n=0;n<e.length;n++)e[n].target===t&&this.finish(e[n])}get size(){return this.list.length}update(t){if(this.timelines.length){let s=0,o=this.timelines;for(let a=0;a<o.length;a++){let i=o[a];i.update(t),i.finished||(o[s++]=i)}o.length=s}let e=this.list;if(!e.length)return;let n=0;for(let s=0;s<e.length;s++){let o=e[s];o.dead||this.step(o,t),o.dead||(e[n++]=o)}n!==e.length&&(e.length=n)}step(t,e){var i,l;if(t.target.destroyed)return this.finish(t);let n=e;if(t.delay>0){if(t.delay-=e,t.delay>0)return;n=-t.delay}let s=t.keys;if(!t.started){t.started=!0;for(let c=0;c<s.length;c++)t.from[c]=Number((i=t.target[s[c]])!=null?i:0)}t.time+=n;let o=t.duration>0?Math.min(t.time/t.duration,1):1,a=t.ease(o);for(let c=0;c<s.length;c++)t.target[s[c]]=t.from[c]+(t.to[c]-t.from[c])*a;(l=t.onUpdate)==null||l.call(t,a),o>=1&&this.finish(t)}finish(t){t.dead||(t.dead=!0,t.done())}clear(){for(let t of this.list)this.finish(t);this.list.length=0;for(let t of this.timelines)t.stop();this.timelines=[]}};var Se=720,tr=class extends We{constructor(e,n){super(e);p(this,"paintAll",n)}draw(e,n){this.paintAll(e,n)}},Ss=class extends We{constructor(e,n){super(e);p(this,"paintAll",n)}draw(e,n){this.paintAll(e,n)}},bt=()=>performance.now(),Ua=r=>{let t=fo(r);return t&&Object.freeze(t)};function Wa(){return lt(this,arguments,function*(r={}){var qs,Ys,Ks,Qs,Zs,Js,eo,to,no,cr,ro;let t=(qs=r.play)!=null?qs:null,e=(Ys=r.canvas)!=null?Ys:null;e||(e=document.createElement("canvas"),e.style.cssText="position:fixed;top:0;left:0;width:100%;height:100%;display:block;touch-action:none",document.body.appendChild(e));let n=gn(e,{renderer:(Ks=r.renderer)!=null?Ks:Ta(),failIfMajorPerformanceCaveat:r.failIfMajorPerformanceCaveat,instancing:r.instancing});e=n.canvas;let s=new Set,o=new Mt(Math.min(2048,n.maxTextureSize),4);o.onPage=w=>s.add(w),o.onDrop=w=>{s.delete(w),w.texture&&n.destroyTexture(w.texture),w.texture=null};let a=Zn(n),i=new Rn,l=new Tn,c=new Wt(o),u=new Map,f=new Map,h=new Map,b=new Map,y=new Map,x=new Set,d=0,m=(Qs=r.tier)!=null?Qs:$a(),g=String((Zs=n.info.renderer)!=null?Zs:""),v=(()=>{var w;try{return(w=$.localStorage)!=null?w:null}catch(T){return null}})(),k=typeof screen!="undefined"?"".concat(screen.width,"x").concat(screen.height):"",R=Ba(n.kind,g,k);po(v,R,za(n.kind,g,k));let F=Ha(v,R),I=Ga(m,ks(n.kind,t==null?void 0:t.device),F==null?void 0:F.name),A=(Js=I==null?void 0:I.name)!=null?Js:"medium",S=mt(A);c.setTier(A);let P=(I==null?void 0:I.from)==="hint",H=F==null?void 0:F.name,z=(eo=F==null?void 0:F.refresh)!=null?eo:ws(t==null?void 0:t.device),B=1,G=1,L=1,U={atlas:o,get pixelScale(){return B},get fontGen(){return d},get effects(){return S.effects},tweens:i,frame:w=>lr.frame(w),shape:w=>{let T=S.effects,O=T?B:-B,E=u.get(O);E||(u.size>=8&&u.clear(),u.set(O,E=new mn(2e3)));let X=Ze(w),j=E.get(w,X);return(!j||!o.valid(j.frame))&&E.set(w,j=xs(o,_a(w,T),B),X),j},bitmapFont:w=>lr.bitmapFont(w)},Y=1280,Q=null;class Ee extends Vt{get width(){return Y}set width(T){}get height(){return Se}set height(T){}get safe(){let T=Math.min(Y,Se*16/9);return{x:(Y-T)/2,y:0,w:T,h:Se}}}let ue=new Ee(U),ke=()=>{var X;let w=n.canvas,T=w.getBoundingClientRect();G=Math.max(1,T.width||w.clientWidth||innerWidth),L=Math.max(1,T.height||w.clientHeight||innerHeight),Y=Se*G/L;let O=Math.min($.devicePixelRatio||1,(X=r.maxPixelRatio)!=null?X:2);if(L*O/Se<=S.resolution){let j=Math.max(1,Math.round(L*O));B=j/Se,n.resize(Math.max(1,Math.round(G*O)),j)}else B=S.resolution,n.resize(Math.round(Y*B),Math.round(Se*B));Q&&Q.style.setProperty("--unit","".concat(L/Se,"px"))};addEventListener("resize",ke);let we=w=>{A=w,S=mt(w),c.setTier(w),ke()},oe=typeof ResizeObserver!="undefined"?new ResizeObserver(ke):null;oe==null||oe.observe(e);let Re=(t==null?void 0:t.backdrop)==="video"?"video":"none",he=(to=t==null?void 0:t.view)!=null?to:null,Ct=(t==null?void 0:t.orientation)==="portrait"?"portrait":"landscape",Cn=(no=Ua(t==null?void 0:t.safeArea))!=null?no:ho,Fn=[],Pn=-1/0,Ft=!1,xt=!1,qt=new Set,_n=()=>{let w=Re==="video"?"transparent":"";document.documentElement.style.background=w,document.body.style.background=w},Ln=(w,T)=>{let O=w==="video"?"video":"none",E=T!=null?T:null;if(!(O===Re&&(E===he||E&&he&&E.x===he.x&&E.y===he.y&&E.w===he.w&&E.h===he.h))){Re=O,he=E,_n();for(let X of[...qt])X(Re,he)}},On=[];if(t){let w=E=>{Array.isArray(E)&&(Fn=E,Pn=bt())},T=E=>{Ft=E,Pt()},O=E=>{if(m||P)return;Number.isFinite(z)||(z=ws(E));let X=ks(n.kind,E);X&&(P=!0,we(H?vs(X,H):X))};On.push(t.on("start",E=>O(E==null?void 0:E.device)),t.on("start",E=>{((E==null?void 0:E.orientation)==="portrait"||(E==null?void 0:E.orientation)==="landscape")&&(Ct=E.orientation);let X=Ua(E==null?void 0:E.safeArea);X&&(Cn=X)}),t.on("start",E=>{typeof(E==null?void 0:E.muted)=="boolean"&&(l.muted=E.muted)}),t.on("frame",E=>w(E==null?void 0:E.players)),t.on("players",E=>w(E==null?void 0:E.players)),t.on("backdrop",E=>Ln(E==null?void 0:E.backdrop,E==null?void 0:E.view)),t.on("start",E=>{var X;return Ln(E==null?void 0:E.backdrop,(X=E==null?void 0:E.view)!=null?X:t.view)}),t.on("pause",()=>T(!0)),t.on("resume",()=>T(!1)),t.on("break-start",()=>T(!0)),t.on("break-done",()=>T(!1)),t.on("break-end",()=>T(!1))),l.muted=t.muted===!0}_n();let Pt=()=>Ft||xt||document.hidden?l.hold():l.release(),In=-1,Yt=[],Kt=0,Qt=()=>bt()-Pn<1e3?Fn:[],rr=w=>t?t.toScreen(w):Wr(he,w),sr=new tn,_t=()=>{if(In===Kt)return Yt;In=Kt;let w=Ct==="portrait",T=Re==="video"&&!w||!(t!=null&&t.smoothedBody)?()=>null:O=>t.smoothedBody(O);return Yt=Ir(Qt(),rr,Y,Se,T,w?{orientation:Ct,hold:sr,t:bt()}:void 0),Yt},gt={x:0,y:0,w:1,h:1},or=()=>(gt.x=he?he.x*Y:0,gt.y=he?he.y*Se:0,gt.w=he?he.w*Y:Y,gt.h=he?he.h*Se:Se,gt),ar=w=>{var X;let T=(X=w.alpha)!=null?X:1,O=w.tags?new Rt(o,w):null;O&&x.add(O);let E=typeof w.tags=="function"?w.tags:j=>String(j);return(j,Fe)=>{var fe,Me,It,kt,te,ee;if(Re==="video")return;let ye=or();for(let ne of Qt()){let re=(Me=(fe=t==null?void 0:t.smoothedBody)==null?void 0:fe.call(t,ne))!=null?Me:ne.body,Pe=(ee=an((te=(kt=(It=t==null?void 0:t.avatarOf)==null?void 0:It.call(t,ne))!=null?kt:ne.avatar)!=null?te:""))!=null?ee:Ht;if(!c.draw(j.r,j.tex,re,Pe,ye,T*Fe,B)||!O)continue;let Nt=E(ne.id);Nt&&O.draw(j.r,j.tex,re,Pe,ye,Nt,Mn(ne.id),T*Fe,B,Y,Se)}}},Zt=new Set,C=new Set,N=new Set,V=!1,J=0,K=0,be=0,je={fps:0,cpuMs:0,drawCalls:0,quads:0,filtersSkipped:0},Oe=0,Jt=0,Ce=bt(),Ge=[],et=0,Ue=()=>({r:n,kernel:U,tex:a}),qe=Ue(),Lt=()=>{if(n.lost)return;let[w,T]=Re==="video"||r.background===void 0?[0,0]:Te(r.background);n.time=be,n.maxBlur=S.maxBlur,n.begin(w,T,B),De(ue.world,null,ue.x,ue.y,ue.rotation,ue.scaleX,ue.scaleY),ss(qe,ue,ue.alpha,ue.tint);let O=n.end();je.drawCalls=O.drawCalls,je.quads=O.quads,je.filtersSkipped=O.filtersSkipped},Ye=w=>{var X;if(!V)return;J=requestAnimationFrame(Ye);let T=Math.min(Math.max((w-K)/1e3,0),.1);K&&Ge.push(w-K),K=w,Kt++;let O=bt(),E=Ft||xt;if(!E){be+=T,i.update(T);for(let j of N)j.destroyed||j.update(T);for(let j of Zt)j(T,be)}for(let j of C)j(T);ue.sweep();for(let j of N)j.destroyed&&N.delete(j);if(n.lost?(et||(et=w),w-et>3e3&&Ot()):(et=0,Lt()),Oe++,Jt+=bt()-O,O-Ce>=1e3&&(je.fps=Math.round(Oe*1e3/(O-Ce)),je.cpuMs=Math.round(Jt/Math.max(Oe,1)*100)/100,(X=t==null?void 0:t.reportStats)==null||X.call(t,{fps:je.fps,renderer:n.kind,tier:A}),Oe=0,Jt=0,Ce=O),Ge.length>=180){let j=Number.isFinite(z)?z:er(Ge);!m&&!E&&Na(Ge,j)&&A!=="low"&&(we(La(A)),H=A,gs(v,R,A,Number.isFinite(z)?z:void 0),console.info("[engine] slow frames: tier ".concat(A))),Ge.length=0}},Ot=()=>{let w=Qn(n.canvas),T=yn(w);if(T){console.warn("[engine] WebGL context lost for good: switching to Canvas 2D"),n.destroy(),n=T;for(let O of s)O.texture=null;for(let O of o.pages)s.add(O.surface);a=Zn(n),qe=Ue(),oe==null||oe.disconnect(),oe==null||oe.observe(w),ke()}},ir=()=>{Pt(),document.hidden||(K=0)};document.addEventListener("visibilitychange",ir);let Nn=()=>{d++;for(let w of x)w.drop()};if((ro=(cr=document.fonts)==null?void 0:cr.addEventListener)==null||ro.call(cr,"loadingdone",Nn),ke(),!I&&r.probe!==!1&&(Number.isFinite(z)||(z=Ia(yield jl(Oa))),!P)){S=mt("high"),ke();let w=yield ql(n,o,()=>a,()=>B,Y,()=>P);if(w.refresh=z,!P){let T=Br(n.kind,w);gs(v,R,T,z),H=T,we(T)}}let lr={stage:ue,get tier(){return S},get renderer(){return n},get canvas(){return n.canvas},get pixelScale(){return B},get backdrop(){return Re},get view(){return he},get orientation(){return Ct},get safeArea(){return Cn},get paused(){return Ft||xt},sound:l,stats:je,get time(){return be},get supports(){let w=n.support;return{filters:w.filters,blur:w.filters&&S.maxBlur>0,shaders:w.shaders,maxBlur:w.filters?S.maxBlur:0,tiers:{high:{maxBlur:mt("high").maxBlur},medium:{maxBlur:mt("medium").maxBlur},low:{maxBlur:mt("low").maxBlur}}}},sprite:(w,T)=>new ze(U,w,T),shape:(w,T)=>new nt(U,w,T),text:(w,T)=>new ot(U,w,T),group:w=>new Vt(U).set(w!=null?w:{}),particles(w,T={}){let O=typeof w=="object"&&"type"in w?U.shape(w).frame:w,E=new hn(U,O,T),Me=T,{max:X,blend:j,gravity:Fe,drag:ye}=Me,fe=en(Me,["max","blend","gravity","drag"]);return E.set(fe),N.add(E),E},tween:(w,T,O,E)=>i.tween(w,T,O,E),bake(w,T,O,E,X){return h.set(w,{w:T,h:O,draw:E,origin:X}),f.delete(w),lr.frame(w)},frame(w){var E,X,j,Fe;let T=f.get(w);if(T&&o.valid(T)&&(T.gen===0||T.scale===B))return T;let O=h.get(w);if(O){let ye=B,fe=o.bake(O.w*ye,O.h*ye,Me=>(Me.scale(ye,ye),O.draw(Me)),ye,(X=(E=O.origin)==null?void 0:E.x)!=null?X:0,(Fe=(j=O.origin)==null?void 0:j.y)!=null?Fe:0);return f.set(w,fe),fe}if(T)return T;throw new Error('[engine] no frame "'.concat(w,'": load it or bake it first'))},load(w){return lt(this,null,function*(){yield Promise.all(Object.entries(w).map(([T,O])=>di(T,O)))})},hands:w=>w===void 0?_t():_t().filter(T=>T.player===w),touched(w,T,O={}){var E;return w.updateWorld(),Nr(w,_t(),T,(E=O.padding)!=null?E:0)},hits(w,T,O,E=0){return w.updateWorld(),Jn(w,T,O,E)},avatars:(w={})=>new tr(U,ar(w)),handMarkers(w={}){var kt,te;let T=(kt=w.radius)!=null?kt:36,O=(te=w.look)!=null?te:"auto",E=new Float64Array(6),X=Math.max(T*.12,3),j={type:"ring",r:T,lw:X,fill:"rgba(251,231,184,0.3)",stroke:"#ffffff"},Fe={type:"ring",r:T,lw:X*1.8,stroke:Xt,shadow:{color:Xt,blur:T*.2}},ye=(ee,ne,re,Pe,Nt,Dt)=>{let ur=ne.w/ne.scale;De(E,null,re-ur/2,Pe-ur/2,0,1,1),ee.r.quad(ee.tex(ne.surface),ne,E,ur,ur,Nt,Dt,"normal")},fe=ee=>{let ne=null,re=!1;return()=>(ne&&o.valid(ne.frame)&&ne.frame.scale===B&&re===S.effects?ne:(re=S.effects,ne=U.shape(ee))).frame},Me=fe(j),It=fe(Fe);return new Ss(U,(ee,ne)=>{let re=O==="video"||O==="auto"&&Re==="video",Pe=Me(),Nt=re?It():null;for(let Dt of _t())Nt&&ye(ee,Nt,Dt.x,Dt.y,16777215,ne),ye(ee,Pe,Dt.x,Dt.y,Te(Dt.color)[0],ne)})},timeline:w=>i.timeline(w),animation(w,T){let O=typeof w=="string"?pi(w):{frames:w},E=new Xe(U,O,T);return N.add(E),E},bitmapFont(w,T){if(!T){let E=b.get(w);if(!E)throw new Error('[engine] no bitmap font "'.concat(w,'": load or make it first'));return E}let O="data"in T?Xs(Sn(T.data),T.pages):Pa(U,T);return b.set(w,O),O},players:()=>Qt(),onFrame(w){return Zt.add(w),()=>{Zt.delete(w)}},onRender(w){return C.add(w),()=>{C.delete(w)}},onBackdrop(w){return qt.add(w),()=>{qt.delete(w)}},get hud(){return Q||(Q=document.createElement("div"),Q.style.cssText="position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;overflow:hidden",document.body.appendChild(Q),ke()),Q},random:(w=0,T=1)=>w+Math.random()*(T-w),start(){V||(V=!0,K=0,J=requestAnimationFrame(Ye))},pause(){xt=!0,Pt()},resume(){xt=!1,Pt()},destroy(){var w,T;V=!1,cancelAnimationFrame(J),On.forEach(O=>O()),removeEventListener("resize",ke),oe==null||oe.disconnect(),document.removeEventListener("visibilitychange",ir),(T=(w=document.fonts)==null?void 0:w.removeEventListener)==null||T.call(w,"loadingdone",Nn),i.clear(),Jo(U),l.destroy(),n.destroy(),Q==null||Q.remove()}};function pi(w){let T=y.get(w);if(T)return T;let O=[...new Set([...f.keys(),...h.keys()])].filter(E=>E.startsWith(w)).sort(ta);if(!O.length)throw new Error('[engine] no animation or frames "'.concat(w,'\u2026"'));return{frames:O}}function di(w,T){return lt(this,null,function*(){var Fe,ye;let O=T.split("?")[0].split(".").pop().toLowerCase();if(["mp3","ogg","wav","m4a","aac","webm"].includes(O))return l.load(w,T);if(["woff","woff2","ttf","otf"].includes(O)){let fe=new FontFace(w,"url(".concat(T,")"));document.fonts.add(yield fe.load()),d++;return}let E=new URL(T,location.href);if(O==="fnt")return js(w,Sn(yield(yield fetch(T)).text()),E);if(O==="json"){let fe=yield(yield fetch(T)).json();if(Array.isArray(fe.chars)&&!fe.frames)return js(w,Sn(fe),E);let Me=yield As(new URL((ye=(Fe=fe.meta)==null?void 0:Fe.image)!=null?ye:T.replace(/\.json$/,".png"),E).href);mi(w,fe,fn(Me));return}let X=yield As(T),j=fn(X);s.add(j),f.set(w,{surface:j,x:0,y:0,w:X.width,h:X.height,scale:1,gen:0,ox:0,oy:0,margin:0})})}function Xs(w,T){return Fa(w,T.map(O=>{let E=fn(O);return s.add(E),E}))}function js(w,T,O){return lt(this,null,function*(){b.set(w,Xs(T,yield Promise.all(T.pages.map(E=>As(new URL(E,O).href)))))})}function mi(w,T,O){var Fe,ye,fe,Me,It,kt;s.add(O);let E=Array.isArray(T.frames)?T.frames:Object.entries(T.frames).map(([te,ee])=>Ie(M({},ee),{filename:te})),X=[],j=[];for(let te of E){let ee=te.frame,ne=te.filename.replace(Va,"");te.rotated&&console.warn("[engine] ".concat(w,"/").concat(ne," is rotated: export without rotation"));let re={surface:O,x:ee.x,y:ee.y,w:ee.w,h:ee.h,scale:1,gen:0,ox:0,oy:0,margin:0};te.trimmed&&te.sourceSize&&te.spriteSourceSize&&(re.sw=te.sourceSize.w,re.sh=te.sourceSize.h,re.tx=te.spriteSourceSize.x,re.ty=te.spriteSourceSize.y);let Pe=te.scale9Borders;Pe&&(re.slice=[Pe.y,((Fe=re.sw)!=null?Fe:ee.w)-Pe.x-Pe.w,((ye=re.sh)!=null?ye:ee.h)-Pe.y-Pe.h,Pe.x]),f.set("".concat(w,"/").concat(ne),re),X.push("".concat(w,"/").concat(ne)),j.push(((fe=te.duration)!=null?fe:0)/1e3)}for(let[te,ee]of Object.entries((Me=T.animations)!=null?Me:{}))y.set("".concat(w,"/").concat(te),{frames:ee.map(ne=>"".concat(w,"/").concat(ne.replace(Va,"")))});for(let te of(kt=(It=T.meta)==null?void 0:It.frameTags)!=null?kt:[]){let ee=[];for(let re=te.from;re<=te.to;re++)ee.push(re);te.direction==="reverse"&&ee.reverse(),te.direction==="pingpong"&&ee.push(...ee.slice(1,-1).reverse());let ne=ee.every(re=>j[re]>0);y.set("".concat(w,"/").concat(te.name),M({frames:ee.map(re=>X[re])},ne?{durations:ee.map(re=>j[re])}:{}))}}return lr})}var Va=/\.(png|webp|jpe?g|gif|bmp)$/i;function As(r){return new Promise((t,e)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>e(new Error("[engine] image did not load: ".concat(r))),n.src=r})}function jl(r){return new Promise(t=>{let e=[],n=0,s=o=>{n&&e.push(o-n),n=o,e.length<r?requestAnimationFrame(s):t(e)};requestAnimationFrame(s)})}function ql(r,t,e,n,s,o=()=>!1){return lt(this,null,function*(){let a=n(),i=xs(t,{type:"star",r:30,fill:"#ffd23f",stroke:"#3a2a10",lw:3},a).frame,l=[],c=[],u=new Float64Array(6),f=.004,h=r.kind==="canvas2d"?r.canvas.getContext("2d"):null,b=bt(),y=0;return yield new Promise(x=>{let d=m=>{y&&m-b>250&&l.push(m-y),y=m;let g=bt();r.begin(0,0,a);let v=e();for(let k=0;k<300;k++){let R=m/1e3+k;De(u,null,k*37%s,k*53%Se,R,1,1),r.quad(v(i.surface),i,u,i.w/a,i.h/a,16777215,f,"normal")}for(let k=0;k<40;k++)r.ellipse(100+k*20,300,20,14,k,16746496,f),r.stroke([100+k*20,400,120+k*20,460,100+k*20,520],3,18,3368703,f,!1);r.end(),h==null||h.getImageData(0,0,1,1),m-b>250&&c.push(bt()-g),m-b<750&&!o()?requestAnimationFrame(d):(r.begin(0,0,a),r.end(),x())};requestAnimationFrame(d)}),{intervals:l,cpu:c}})}var Yl=64,Xa=32,Kl=0,Ql="fabi-cm-".concat(Math.random().toString(36).slice(2,7),"-"),ja=new Set,qa=(r,t)=>{ja.has(r)||(ja.add(r),console.warn(t))},Ya=r=>new Ms(r),Ms=class{constructor(t){p(this,"r",t);p(this,"css","none");p(this,"plans",new mn(Yl));p(this,"buf",new Float64Array(64));p(this,"keys",[]);p(this,"classes",new Map);p(this,"live",new Set);p(this,"svgs",new Map);p(this,"t",0);p(this,"cur",null);p(this,"svgFn",t=>this.svg(t));p(this,"scr",[]);p(this,"flip",0)}chain(t,e){var y,x;let n=this.r,s=this.buf;s[0]=n.scale,s[1]=n.maxBlur;let o=2;for(let d=0;d<e.length;d++){let m=e[d];if(o+22>s.length){let v=new Float64Array(s.length*2);v.set(s),s=this.buf=v}let g=this.classes.get(m.constructor);g===void 0&&this.classes.set(m.constructor,g=this.classes.size),s[o++]=g,s[o++]=m.enabled?1:0,m.params&&(o=m.params(s,o))}let a=(x=(y=this.keys)[o])!=null?x:y[o]=new Float64Array(o);for(let d=0;d<o;d++)a[d]=s[d];let i=Ze(a),l=this.plans.get(a,i);l||this.plans.set(a,l=this.plan(e),i);for(let d=0;d<l.svgs.length;d++){let m=l.svgs[d];m.used<0&&this.attach(m),m.used=this.t}n.skipped+=l.skip;let c=t,u=n.rx0,f=n.ry0,h=n.rx1-u,b=n.ry1-f;for(let d=0;d<l.paints.length;d++)l.parts[d]&&(c=this.bake(c,l.parts[d])),e[l.paints[d]].paint2d(c.getContext("2d"),u,f,h,b);return this.css=l.parts[l.paints.length]||"none",c}tick(){let t=++this.t;if(!(t%Xa||!this.live.size))for(let e of this.live)t-e.used>Xa&&this.detach(e)}destroy(){for(let t of this.live)this.detach(t);this.plans.clear()}svg(t){if(typeof document=="undefined"||!document.body)return null;let e=Array.from({length:20},(s,o)=>{var a;return(a=t[o])!=null?a:0}).join(" "),n=this.svgs.get(e);if(!n){let s="http://www.w3.org/2000/svg",o=document.createElementNS(s,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),o.style.position="absolute";let a=document.createElementNS(s,"filter"),i=Ql+ ++Kl;a.setAttribute("id",i),a.setAttribute("color-interpolation-filters","sRGB");let l=document.createElementNS(s,"feColorMatrix");l.setAttribute("type","matrix"),l.setAttribute("values",e),a.append(l),o.append(a),this.attach(n={key:e,id:i,el:o,used:this.t})}return this.cur.svgs.push(n),"url(#".concat(n.id,")")}attach(t){document.body.append(t.el),this.live.add(t),this.svgs.has(t.key)||this.svgs.set(t.key,t)}detach(t){t.el.remove(),t.used=-1,this.live.delete(t),this.svgs.get(t.key)===t&&this.svgs.delete(t.key)}plan(t){let e=this.r,n=this.cur={parts:[],paints:[],skip:0,svgs:[]},s="";for(let o=0;o<t.length;o++){let a=t[o];if(!a.enabled)continue;if(a.kind===4){n.skip++,qa("shader","[engine] shader() filters are WebGL only: on Canvas 2D they are skipped (check engine.supports.shaders)");continue}let i=e.support.filters&&a.css?a.css(e.scale,e.maxBlur,this.svgFn):null;i!==null?s+=s?" ".concat(i):i:a.paint2d?(n.parts.push(s),n.paints.push(o),s=""):(n.skip++,qa("css","[engine] this browser's Canvas 2D has no ctx.filter: colour filters, blur and shadows are skipped (tint works; check engine.supports.filters)"))}return n.parts.push(s),n}bake(t,e){let n=this.r,s=this.flip^=1,o=this.scr[s];(!o||o.width!==n.canvas.width||o.height!==n.canvas.height)&&(o=this.scr[s]=document.createElement("canvas"),o.width=n.canvas.width,o.height=n.canvas.height);let a=o.getContext("2d"),i=n.rx0,l=n.ry0,c=n.rx1-i,u=n.ry1-l;return a.clearRect(i,l,c,u),a.filter=e,a.drawImage(t,i,l,c,u,i,l,c,u),a.filter="none",o}};var Zl=64,zr=17,Jl=r=>"".concat(_r,"\nuniform sampler2D uTexture;\nuniform mat4 uM[").concat(r,"];\nuniform vec4 uO[").concat(r,"];\nuniform int uK;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvoid main() {\n vec4 c = texture2D(uTexture, vUv);\n if (c.a > 0.0) c.rgb /= c.a;\n for (int i = 0; i < ").concat(r,"; i++) {\n if (i >= uK) break;\n c = clamp(uM[i] * c + uO[i], 0.0, 1.0);\n }\n c.rgb *= c.a;\n gl_FragColor = c * vColor;\n}"),ec=()=>"".concat(_r,"\nuniform sampler2D uTexture;\nuniform vec2 uDir;\nuniform vec2 uOff;\nuniform vec2 uTaps[").concat(zr,"];\nuniform int uN;\nuniform float uMode;\nuniform vec4 uShadow;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvoid main() {\n vec2 p = vUv + uOff;\n vec4 c = texture2D(uTexture, p) * uTaps[0].y;\n for (int i = 1; i < ").concat(zr,"; i++) {\n if (i >= uN) break;\n vec2 d = uDir * uTaps[i].x;\n c += (texture2D(uTexture, p + d) + texture2D(uTexture, p - d)) * uTaps[i].y;\n }\n if (uMode > 0.5) c = uShadow * c.a;\n gl_FragColor = c * vColor;\n}");function tc(r,t,e=new Float32Array(20)){for(let n=0;n<4;n++)for(let s=0;s<5;s++){let o=s===4?t[n*5+4]:0;for(let a=0;a<4;a++)o+=t[n*5+a]*r[a*5+s];e[n*5+s]=o}return r.set(e),r}var Ka=r=>new Cs(r),Cs=class{constructor(t){p(this,"r",t);p(this,"colorProg",null);p(this,"blurProg",null);p(this,"user",new Map);p(this,"uses",0);p(this,"userErr",new Map);p(this,"scratchT",new Map);p(this,"steps",[]);p(this,"mats",[]);p(this,"counts",[]);p(this,"colorN");p(this,"fm",new Float32Array(20));p(this,"fm2",new Float32Array(20));p(this,"fm3",new Float32Array(20));p(this,"m16");p(this,"o4");p(this,"taps",new Float32Array(zr*2));let e=t.gl;this.colorN=Math.max(1,Math.min(8,Math.floor((e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)-4)/5))),this.m16=new Float32Array(16*this.colorN),this.o4=new Float32Array(4*this.colorN)}check(t){var e;return this.r.lost?null:(this.userProg(t,!1),(e=this.userErr.get(t))!=null?e:null)}destroy(){let t=this.r.gl;for(let e of this.scratchT.values())t.deleteTexture(e.gl),t.deleteFramebuffer(e.fb);this.scratchT.clear();for(let e of[this.colorProg,this.blurProg])e&&t.deleteProgram(e.p);for(let e of this.user.values())e.p&&t.deleteProgram(e.p.p);this.user.clear()}userProg(t,e){let n=this.user,s=n.get(t);if(s)return s.t=++this.uses,s.p;if(this.r.lost)return null;if(n.size>=Zl){let a="",i=1/0;for(let[c,u]of n)u.t<i&&(i=u.t,a=c);let l=n.get(a).p;l&&this.r.gl.deleteProgram(l.p),n.delete(a),this.userErr.delete(a)}let o;try{o=this.r.build(t)}catch(a){o=null;let i=a.message;this.userErr.set(t,i),e&&console.error("[engine] a shader filter does not compile: it is skipped.\n".concat(i))}return n.set(t,{p:o,t:++this.uses}),o}scratch(t,e){var l;let n=this.r,s=Math.ceil(n.canvas.width/t),o=Math.ceil(n.canvas.height/t),a=t*8+e,i=(l=this.scratchT.get(a))!=null?l:null;return i&&(i.w!==s||i.h!==o)&&(n.drop(i),i=null),i||(i=n.target(s,o,t,!0),i?this.scratchT.set(a,i):this.scratchT.delete(a)),i}pass(t,e,n,s,o=!1){let a=this.r,i=a.gl;a.flush(),a.mapped=!1,a.bindFb(s),i.viewport(0,0,s.w,s.h),o||(i.disable(i.SCISSOR_TEST),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT)),a.use(t);let l=s.f;i.uniform2f(t.uScale,2/(l*s.w),-2/(l*s.h));let c=Math.floor(a.rx0/l)*l,u=Math.floor(a.ry0/l)*l,f=Math.min(Math.ceil(a.rx1/l),s.w)*l,h=Math.min(Math.ceil(a.ry1/l),s.h)*l,b=1/(n*e.width),y=1/(n*e.height);a.bScis=!1,a.batch.push(c,u,f,u,f,h,c,h,c*b,1-u*y,f*b,1-h*y,4294967295,a.slotOf(e)),a.flush()}post(t){var e,n;return t==="color"?(e=this.colorProg)!=null?e:this.colorProg=this.r.build(Jl(this.colorN)):(n=this.blurProg)!=null?n:this.blurProg=this.r.build(ec())}linear(t,e){var a;let n=this.r,s=n.gl;n.bindTex((a=n.layerTex.get(t))!=null?a:null,0);let o=e?s.LINEAR:s.NEAREST;s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,o)}chain(t,e,n){let s=this.r,o=this.steps,a=s.scale,i=s.maxBlur,l=0;for(let h=0;h<n.length;h++){let b=n[h];if(b.enabled)if(b.kind===1&&b.toMatrix){(!l||o[l-1]!==null)&&(o[l]=null,(!this.mats[l]||this.mats[l].length<20*this.colorN)&&(this.mats[l]=new Float32Array(20*this.colorN)),this.counts[l]=0,l++);let y=this.mats[l-1],x=this.counts[l-1];if(x<this.colorN)b.toMatrix(this.fm),y.set(this.fm,x*20),this.counts[l-1]=x+1;else{let d=(x-1)*20;for(let m=0;m<20;m++)this.fm2[m]=y[d+m];b.toMatrix(this.fm),tc(this.fm2,this.fm,this.fm3),y.set(this.fm2,d)}}else b.kind===4?this.userProg(b.source,!0)?o[l++]=b:s.skipped++:b.kind===2?Math.min(b.radius,i)*a>=.25&&(o[l++]=b):b.kind===3?o[l++]=b:s.skipped++}if(!l)return!1;let c=s.gl,u=t,f=-1;for(let h=0;h<l;h++){let b=h===l-1,y=f===0?1:0,x=b?null:this.scratch(1,y);if(!b&&!x)break;let d=o[h];if(d===null){let m=this.post("color");s.use(m);let g=this.mats[h],v=this.counts[h],k=this.m16,R=this.o4;for(let F=0;F<v;F++)for(let I=0;I<4;I++){for(let A=0;A<4;A++)k[F*16+A*4+I]=g[F*20+I*5+A];R[F*4+I]=g[F*20+I*5+4]}c.uniformMatrix4fv(s.u(m,"uM"),!1,k),c.uniform4fv(s.u(m,"uO"),R),c.uniform1i(s.u(m,"uK"),v),x?this.pass(m,u,1,x):s.final(m,u,1,e)}else if(d.kind===2)this.blur(u,f<0,Math.min(d.radius,i)*a,x,e,null);else if(d.kind===3){let m=d,g=this.scratch(1,2);if(!g)break;this.blur(u,f<0,Math.max(Math.min(m.blur,i),0)*a,g,1,m);let v=x!=null?x:e<1?this.scratch(1,y):null;v?(this.pass(s.main,g.tex,1,v),this.pass(s.main,u,1,v,!0),x||s.final(s.main,v.tex,1,e)):(s.final(s.main,g.tex,1,1),s.final(s.main,u,1,1))}else{let m=d,g=this.userProg(m.source,!0);s.use(g);let v=s.canvas.width,k=s.canvas.height;c.uniform2f(s.u(g,"uResolution"),v,k),c.uniform1f(s.u(g,"uTime"),s.time),c.uniform4f(s.u(g,"uRect"),s.rx0/v,1-s.ry1/k,s.rx1/v,1-s.ry0/k);let R=m.uniforms;for(let F in R){let I=s.u(g,F);if(!I)continue;let A=R[F];typeof A=="number"?c.uniform1f(I,A):A.length===2?c.uniform2fv(I,A):A.length===3?c.uniform3fv(I,A):A.length===4?c.uniform4fv(I,A):A.length===1&&c.uniform1fv(I,A)}x?this.pass(g,u,1,x):s.final(g,u,1,e)}x&&(u=x.tex,f=y)}return s.remap(),!0}blur(t,e,n,s,o,a){let i=this.r,l=i.gl,c=this.post("blur"),u=1;for(;u<16&&n/u>8;)u*=2;e&&this.linear(t,!0);let f=t,h=1,b=Math.sqrt(Math.max(n*n-(u*u-1)/12,0))/u,y=n>=.25?this.tapsFor(b):this.tapsFor(0),x=!0;if(y>1){for(let m=2;m<=u&&x;m*=2){let g=this.scratch(m,0);g?(this.pass(i.main,f,h,g),f=g.tex,h=m):x=!1}let d=x?this.scratch(u,3):null;d&&(i.use(c),l.uniform2fv(i.u(c,"uTaps"),this.taps),l.uniform1i(i.u(c,"uN"),y),l.uniform2f(i.u(c,"uDir"),1/f.width,0),l.uniform2f(i.u(c,"uOff"),0,0),l.uniform1f(i.u(c,"uMode"),0),this.pass(c,f,h,d),f=d.tex)}if(i.use(c),l.uniform2fv(i.u(c,"uTaps"),this.taps),l.uniform1i(i.u(c,"uN"),y),l.uniform2f(i.u(c,"uDir"),0,1/f.height),a){let d=a.opacity,m=a.rgb;l.uniform4f(i.u(c,"uShadow"),(m>>16&255)/255*d,(m>>8&255)/255*d,(m&255)/255*d,d),l.uniform1f(i.u(c,"uMode"),1),l.uniform2f(i.u(c,"uOff"),-a.dx*i.scale/(h*f.width),a.dy*i.scale/(h*f.height))}else l.uniform1f(i.u(c,"uMode"),0),l.uniform2f(i.u(c,"uOff"),0,0);s?this.pass(c,f,h,s):i.final(c,f,h,o),e&&this.linear(t,!1)}tapsFor(t){let e=this.taps;if(e.fill(0),e[1]=1,t<.2)return 1;let n=Math.min(Math.ceil(3*t),(zr-1)*2),s=-1/(2*t*t),o=1,a=1;for(let i=1;i<=n;i+=2){let l=Math.exp(i*i*s),c=i+1<=n?Math.exp((i+1)*(i+1)*s):0,u=l+c;e[a*2]=(i*l+(i+1)*c)/u,e[a*2+1]=u,o+=2*u,a++}for(let i=0;i<a;i++)e[i*2+1]=e[i*2+1]/o;return a}};var yt=r=>Math.min(Math.max(r,0),1),Je=r=>Math.max(r,0),jt=class{constructor(){p(this,"enabled",!0);Be.gl=Ka,Be.c2d=Ya}},it=class extends jt{constructor(e){super();p(this,"amount",e);p(this,"kind",1)}params(e,n){return e[n]=this.amount,n+1}};function Hr(r,t,e){r.fill(0),r[0]=r[6]=r[12]=t,r[4]=r[9]=r[14]=e,r[18]=1}function $r(r,t){r.fill(0);for(let e=0;e<3;e++)for(let n=0;n<3;n++)r[e*5+n]=t[e*3+n];r[18]=1}var W=new Float64Array(9),Ps=class extends it{toMatrix(t){Hr(t,Je(this.amount),0)}css(){return"brightness(".concat(Je(this.amount),")")}},_s=class extends it{toMatrix(t){let e=Je(this.amount);Hr(t,e,.5-.5*e)}css(){return"contrast(".concat(Je(this.amount),")")}},Ls=class extends it{toMatrix(t){let e=yt(this.amount);Hr(t,1-2*e,e)}css(){return"invert(".concat(yt(this.amount),")")}},Os=class extends it{toMatrix(t){let e=Je(this.amount);W[0]=.213+.787*e,W[1]=.715-.715*e,W[2]=.072-.072*e,W[3]=.213-.213*e,W[4]=.715+.285*e,W[5]=.072-.072*e,W[6]=.213-.213*e,W[7]=.715-.715*e,W[8]=.072+.928*e,$r(t,W)}css(){return"saturate(".concat(Je(this.amount),")")}},Is=class extends it{toMatrix(t){let e=1-yt(this.amount);W[0]=.2126+.7874*e,W[1]=.7152-.7152*e,W[2]=.0722-.0722*e,W[3]=.2126-.2126*e,W[4]=.7152+.2848*e,W[5]=.0722-.0722*e,W[6]=.2126-.2126*e,W[7]=.7152-.7152*e,W[8]=.0722+.9278*e,$r(t,W)}css(){return"grayscale(".concat(yt(this.amount),")")}},Ns=class extends it{toMatrix(t){let e=1-yt(this.amount);W[0]=.393+.607*e,W[1]=.769-.769*e,W[2]=.189-.189*e,W[3]=.349-.349*e,W[4]=.686+.314*e,W[5]=.168-.168*e,W[6]=.272-.272*e,W[7]=.534-.534*e,W[8]=.131+.869*e,$r(t,W)}css(){return"sepia(".concat(yt(this.amount),")")}},Ds=class extends it{get angle(){return this.amount}set angle(t){this.amount=t}toMatrix(t){let e=this.amount*Math.PI/180,n=Math.cos(e),s=Math.sin(e);W[0]=.213+n*.787-s*.213,W[1]=.715-n*.715-s*.715,W[2]=.072-n*.072+s*.928,W[3]=.213-n*.213+s*.143,W[4]=.715+n*.285+s*.14,W[5]=.072-n*.072-s*.283,W[6]=.213-n*.213-s*.787,W[7]=.715-n*.715+s*.715,W[8]=.072+n*.928+s*.072,$r(t,W)}css(){return"hue-rotate(".concat(this.amount,"deg)")}},Bs=class extends it{constructor(e,n){super(n);p(this,"c",16777215);p(this,"cs","");this.color=e}get color(){return this.c}set color(e){this.c=Te(e)[0],this.cs=$t(this.c)}params(e,n){return e[n]=this.amount,e[n+1]=this.c,n+2}toMatrix(e){let n=yt(this.amount);Hr(e,1-n,0),e[4]=(this.c>>16&255)/255*n,e[9]=(this.c>>8&255)/255*n,e[14]=(this.c&255)/255*n}css(){return null}paint2d(e,n,s,o,a){let i=yt(this.amount);i<=0||(e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=i,e.globalCompositeOperation="source-atop",e.fillStyle=this.cs,e.fillRect(n,s,o,a),e.restore())}},zs=class extends jt{constructor(e){super();p(this,"kind",1);p(this,"values");if(e.length!==20)throw new Error("colorMatrix: 20 numbers expected (4 rows of 5), got ".concat(e.length));this.values=Array.from(e)}toMatrix(e){var n;for(let s=0;s<20;s++)e[s]=(n=this.values[s])!=null?n:0}params(e,n){var s;for(let o=0;o<20;o++)e[n+o]=(s=this.values[o])!=null?s:0;return n+20}css(e,n,s){return s?s(this.values):null}},Hs=class extends jt{constructor(e){super();p(this,"radius",e);p(this,"kind",2)}params(e,n){return e[n]=this.radius,n+1}pad(e){return 3*Math.min(Je(this.radius),e)}css(e,n){return"blur(".concat(Math.min(Je(this.radius),n)*e,"px)")}},$s=class extends jt{constructor(e,n,s,o){super();p(this,"dx",e);p(this,"dy",n);p(this,"blur",s);p(this,"kind",3);p(this,"rgb",0);p(this,"a",1);this.color=o}get opacity(){return this.a}set opacity(e){this.a=yt(e)}get color(){return this.rgb}set color(e){let[n,s]=Te(e);this.rgb=n,this.a=s}params(e,n){return e[n]=this.dx,e[n+1]=this.dy,e[n+2]=this.blur,e[n+3]=this.rgb,e[n+4]=this.a,n+5}pad(e){return 3*Math.min(Je(this.blur),e)+Math.max(Math.abs(this.dx),Math.abs(this.dy))}css(e,n){return"drop-shadow(".concat(this.dx*e,"px ").concat(this.dy*e,"px ").concat(2*Math.min(Je(this.blur),n)*e,"px ").concat($t(this.rgb,this.opacity),")")}},nc="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uTexture;\nuniform vec2 uResolution;\nuniform float uTime;\nuniform vec4 uRect;\nvarying vec2 vUv;\nvarying vec4 vColor;\n#define main fabiUserMain\n#line 1\n",rc=r=>"".concat(nc).concat(r,"\n#undef main\nvoid main() {\n fabiUserMain();\n gl_FragColor *= vColor.a;\n}\n"),Gs=class extends jt{constructor(e){var n,s;super();p(this,"kind",4);p(this,"source");p(this,"uniforms",{});p(this,"padding");this.source=rc(e.fragment),this.padding=(n=e.padding)!=null?n:0;for(let o in(s=e.uniforms)!=null?s:{}){let a=e.uniforms[o];this.uniforms[o]=typeof a=="number"?a:Float32Array.from(a)}}pad(){return Je(this.padding)}},Qa=(r,t=1)=>new Bs(r,t),Za=r=>new Ps(r),Ja=r=>new _s(r),ei=r=>new Os(r),ti=(r=1)=>new Is(r),ni=(r=1)=>new Ns(r),ri=r=>new Ds(r),si=(r=1)=>new Ls(r),oi=r=>new zs(r),ai=r=>new Hs(r),ii=(r,t,e,n="rgba(0,0,0,0.5)")=>new $s(r,t,e,n);function li(r){var n,s;let t=new Gs(r),e=(s=(n=Be.live)==null?void 0:n.filters())==null?void 0:s.check(t.source);if(e)throw new Error("shader(): the fragment does not compile:\n".concat(e));return t}var Us="x y rotation scaleX scaleY alpha visible blend tint z hitRadius clip mask filters".split(" "),ui="frameName _frame _w _h slice autoAnchor".split(" "),sc="fps loop speed onComplete durations".split(" "),Vs=["anchorX","anchorY"],oc=[...Us,...ui,...sc,...Vs],ac=[...Us,...ui,...Vs],ic=[...Us,...Vs],hi=r=>r instanceof Xe?oc:r instanceof ze?ac:ic;function lc(r){let t={},e=r;for(let n of hi(r))t[n]=e[n];return r instanceof nt&&(t.spec=r.spec),r instanceof ot&&(t.text=r.text,t.style=r.style),r instanceof Xe&&(t.playing=r.playing),t}function ci(r,t){let e=r;r instanceof nt&&r.spec!==t.spec&&(r.spec=t.spec),r instanceof ot&&(r.text=t.text,r.style!==t.style&&(e._style=t.style,e.dirty=!0)),r instanceof Xe&&r.gotoFrame(t.speed<0?r.frameCount-1:0);let n=r instanceof nt||r instanceof ot,s=hi(r);for(let o=0;o<s.length;o++){let a=s[o];(!n||a!=="_frame"&&a!=="frameName")&&(e[a]=t[a])}}var nr=class{constructor(t,e={}){p(this,"factory",t);p(this,"opts",e);p(this,"stats",{live:0,free:0,created:0});p(this,"free",[]);p(this,"states",new Map);p(this,"dead",!1)}get(t){if(this.dead)throw new Error("[engine] nodePool.get() after destroy()");let e=this.free.pop();if(e){this.stats.free--,e._free=!1;let n=this.states.get(e);ci(e,n),e.visible=n.visible,e instanceof Xe&&n.playing&&e.play()}else{if(e=this.factory(),!(e instanceof We))throw new Error("[engine] a nodePool factory must return a node (engine.sprite, engine.shape, \u2026)");if(e._pool)throw new Error("[engine] a nodePool factory returned a node of another pool: make a new node in it");this.states.set(e,lc(e)),e._pool=this,this.stats.created++}return this.stats.live++,t&&e.set(t),e}release(t){var n,s,o;let e=this.states.get(t);if(!(!e||t.destroyed)&&!t._free){if(this.opts.max!==void 0&&this.free.length>=this.opts.max)return t.destroy();(n=t.parent)==null||n.remove(t),t.kernel.tweens.stopAll(t),this.stats.live--,ci(t,e),t instanceof Xe&&t.stop(),t.visible=!1,t._free=!0,(o=(s=this.opts).reset)==null||o.call(s,t),this.free.push(t),this.stats.free++}}forget(t){let e=t;if(this.states.delete(e))if(e._free){let n=this.free.indexOf(e);n>=0&&(this.free[n]=this.free[this.free.length-1],this.free.pop()),this.stats.free--}else this.stats.live--}clear(){for(;this.free.length;)this.free[this.free.length-1].destroy()}destroy(){this.dead=!0;for(let t of[...this.states.keys()])t.destroy()}},fi=(r,t)=>new nr(r,t);window.FabiEngine=Ws;})();
|