@idosgames/characters 0.3.0 → 0.3.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.
@@ -1,11 +1,11 @@
1
- 'use strict';var D=require('three'),BufferGeometryUtils_js=require('three/examples/jsm/utils/BufferGeometryUtils.js'),RoomEnvironment_js=require('three/examples/jsm/environments/RoomEnvironment.js');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var D__namespace=/*#__PURE__*/_interopNamespace(D);function Zr(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let r=Math.imul(t^t>>>15,1|t);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function It(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}var Vs="en";function ee(e,t){let r=typeof e=="string"?e:e[Vs]??e.en;if(t)for(let[o,a]of Object.entries(t))r=r.split(`{${o}}`).join(String(a));return r}function Pa(e){let t=e.trim(),r=/```(?:json)?\s*([\s\S]*?)(?:```|$)/i.exec(t);r&&r[1]!==void 0&&(t=r[1]);let o=t.indexOf("{");if(o<0)return {ok:false,error:ee({en:"the answer has no JSON object",ru:"\u0432 \u043E\u0442\u0432\u0435\u0442\u0435 \u043D\u0435\u0442 JSON-\u043E\u0431\u044A\u0435\u043A\u0442\u0430"}),truncated:false};let a=0,n=false,s=false,l=-1;for(let i=o;i<t.length;i++){let c=t[i];if(n){s?s=false:c==="\\"?s=true:c==='"'&&(n=false);continue}if(c==='"')n=true;else if(c==="{"||c==="[")a++;else if((c==="}"||c==="]")&&(a--,a===0)){l=i;break}}if(l<0)return {ok:false,error:ee({en:"the JSON is cut off",ru:"JSON \u043E\u0431\u043E\u0440\u0432\u0430\u043D"}),truncated:true};try{return {ok:!0,value:JSON.parse(t.slice(o,l+1))}}catch{return {ok:false,error:ee({en:"invalid JSON",ru:"\u043D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u044B\u0439 JSON"}),truncated:false}}}var za={id:"avatar",label:"\u0410\u0432\u0430\u0442\u0430\u0440",hint:"the iDos Games account avatar: soft blocks with elbows and knees",bones:[{name:"body",role:"body",parent:null,pivot:[0,12.4,0]},{name:"head",role:"head",parent:"body",pivot:[0,22.4,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6.3,21.4,0]},{name:"armR",role:"armR",parent:"body",pivot:[6.3,21.4,0]},{name:"foreArmL",role:"foreArmL",parent:"armL",pivot:[-6.3,17.2,0]},{name:"foreArmR",role:"foreArmR",parent:"armR",pivot:[6.3,17.2,0]},{name:"legL",role:"legL",parent:null,pivot:[-2.1,12.4,0]},{name:"legR",role:"legR",parent:null,pivot:[2.1,12.4,0]},{name:"shinL",role:"shinL",parent:"legL",pivot:[-2.1,6.4,0]},{name:"shinR",role:"shinR",parent:"legR",pivot:[2.1,6.4,0]}],sockets:[{name:"handR",bone:"foreArmR",at:[6.3,11.6,-1]},{name:"handL",bone:"foreArmL",at:[-6.3,11.6,-1]},{name:"headTop",bone:"head",at:[0,30.3,0]},{name:"face",bone:"head",at:[0,26.7,-4]},{name:"back",bone:"body",at:[0,18.5,2.3]},{name:"waist",bone:"body",at:[0,12.8,0]},{name:"shoulders",bone:"body",at:[0,22.4,0]}],hitbox:{w:.6,h:1.9},eye:26.4,height:{min:24,max:40},faceBone:"head",ik:{feet:[{upper:"legL",lower:"shinL",end:"sole",bend:[-2.6,0]},{upper:"legR",lower:"shinR",end:"sole",bend:[-2.6,0]}],hands:{handR:{upper:"armR",lower:"foreArmR",end:"handR",bend:[0,2.6]},handL:{upper:"armL",lower:"foreArmL",end:"handL",bend:[0,2.6]}},look:{head:"head",body:"body",headYaw:1.1,headPitch:.75,bodyYaw:.5}},ragdoll:{torso:"body",joints:[{bone:"head",parent:"body",kind:"ball",swing:.7,twist:.9,up:true},{bone:"armL",parent:"body",kind:"ball",swing:2.2,twist:1.2,tilt:.5},{bone:"armR",parent:"body",kind:"ball",swing:2.2,twist:1.2,tilt:.5},{bone:"foreArmL",parent:"armL",kind:"hinge",bend:[0,2.5]},{bone:"foreArmR",parent:"armR",kind:"hinge",bend:[0,2.5]},{bone:"legL",parent:"body",kind:"ball",swing:1.1,twist:.6,tilt:.6},{bone:"legR",parent:"body",kind:"ball",swing:1.1,twist:.6,tilt:.6},{bone:"shinL",parent:"legL",kind:"hinge",bend:[-2.5,0]},{bone:"shinR",parent:"legR",kind:"hinge",bend:[-2.5,0]}],stand:["legL","legR","shinL","shinR"]},defaultParts:[{bone:"head",size:[8.5,7.5,8],pos:[0,26.5,0],color:"s",name:"head"},{bone:"head",size:[2.9,.8,2.7],pos:[0,22.6,0],color:"s",name:"neck"},{bone:"body",size:[9,6,4.6],pos:[0,19.4,0],color:"t",name:"torso"},{bone:"body",size:[8.5,5.2,4.3],pos:[0,15,0],color:"t",name:"torso"},{bone:"armL",size:[3.6,5,3.6],pos:[-6.3,19.7,0],color:"s",name:"sleeveL"},{bone:"armR",size:[3.6,5,3.6],pos:[6.3,19.7,0],color:"s",name:"sleeveR"},{bone:"foreArmL",size:[3.45,5.4,3.45],pos:[-6.3,15.7,0],color:"s",name:"forearmL"},{bone:"foreArmR",size:[3.45,5.4,3.45],pos:[6.3,15.7,0],color:"s",name:"forearmR"},{bone:"foreArmL",size:[3.3,3,3.3],pos:[-6.3,12.7,0],color:"s",name:"handL"},{bone:"foreArmR",size:[3.3,3,3.3],pos:[6.3,12.7,0],color:"s",name:"handR"},{bone:"legL",size:[4.2,6,4.2],pos:[-2.1,9.4,0],color:"p",name:"legL"},{bone:"legR",size:[4.2,6,4.2],pos:[2.1,9.4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.05,7.2,4.05],pos:[-2.1,4,0],color:"p",name:"legL"},{bone:"shinR",size:[4.05,7.2,4.05],pos:[2.1,4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.2,1.6,5.2],pos:[-2.1,.8,-0.5],color:"p",name:"footL"},{bone:"shinR",size:[4.2,1.6,5.2],pos:[2.1,.8,-0.5],color:"p",name:"footR"}]};var Ia={id:"blob",label:"\u041A\u0430\u043F\u043B\u044F",hint:"slimes, ghosts, spirits, living objects \u2014 one body with a face, moves by hopping",bones:[{name:"body",role:"body",parent:null,pivot:[0,0,0]}],sockets:[{name:"headTop",bone:"body",at:[0,12,0]},{name:"face",bone:"body",at:[0,7,-6]},{name:"back",bone:"body",at:[0,6,6]},{name:"waist",bone:"body",at:[0,3,0]},{name:"shoulders",bone:"body",at:[0,10,0]},{name:"handR",bone:"body",at:[6,5,-2]},{name:"handL",bone:"body",at:[-6,5,-2]}],hitbox:{w:.8,h:.8},eye:8,height:{min:4,max:40},faceBone:"body",defaultParts:[{bone:"body",size:[12,12,12],pos:[0,6,0],color:"t"}]};var Oa={id:"flyer",label:"\u041A\u0440\u044B\u043B\u0430\u0442\u044B\u0439",hint:"birds, bats, dragons, fairies, insects \u2014 creatures whose wings matter",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,11,-3]},{name:"wingL",role:"wingL",parent:"body",pivot:[-3,10,0]},{name:"wingR",role:"wingR",parent:"body",pivot:[3,10,0]},{name:"legL",role:"legL",parent:null,pivot:[-1.5,4,0]},{name:"legR",role:"legR",parent:null,pivot:[1.5,4,0]},{name:"tail",role:"tail",parent:"body",pivot:[0,8,4]}],sockets:[{name:"headTop",bone:"head",at:[0,16,-4]},{name:"face",bone:"head",at:[0,13,-7]},{name:"back",bone:"body",at:[0,11,1]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,10,-2]},{name:"handR",bone:"legR",at:[1.5,0,-1]},{name:"handL",bone:"legL",at:[-1.5,0,-1]}],hitbox:{w:.6,h:.9},eye:14,height:{min:6,max:40},faceBone:"head",ik:{feet:[{upper:"legL",end:"sole"},{upper:"legR",end:"sole"}],look:{head:"head",headYaw:1.2,headPitch:.6,bodyYaw:0}},defaultParts:[{bone:"body",size:[6,6,8],pos:[0,8,0],color:"t"},{bone:"head",size:[5,5,5],pos:[0,13,-4],color:"s"},{bone:"wingL",size:[8,1,6],pos:[-7,10,0],color:"t"},{bone:"wingR",size:[8,1,6],pos:[7,10,0],color:"t"},{bone:"legL",size:[1,4,1],pos:[-1.5,2,0],color:"p"},{bone:"legR",size:[1,4,1],pos:[1.5,2,0],color:"p"},{bone:"tail",size:[4,1,4],pos:[0,8,6],color:"t"}]};var _a={id:"humanoid",label:"\u0427\u0435\u043B\u043E\u0432\u0435\u043A",hint:"people, humanoids, robots, elves, zombies \u2014 anything on two legs with two arms",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,24,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6,22,0]},{name:"armR",role:"armR",parent:"body",pivot:[6,22,0]},{name:"legL",role:"legL",parent:null,pivot:[-2,12,0]},{name:"legR",role:"legR",parent:null,pivot:[2,12,0]}],sockets:[{name:"handR",bone:"armR",at:[6,11,-1]},{name:"handL",bone:"armL",at:[-6,11,-1]},{name:"headTop",bone:"head",at:[0,32,0]},{name:"face",bone:"head",at:[0,28,-4]},{name:"back",bone:"body",at:[0,18,2]},{name:"waist",bone:"body",at:[0,12,0]},{name:"shoulders",bone:"body",at:[0,24,0]}],hitbox:{w:.6,h:1.8},eye:27,height:{min:16,max:48},faceBone:"head",ik:{feet:[{upper:"legL",end:"sole"},{upper:"legR",end:"sole"}],hands:{handR:{upper:"armR",end:"handR"},handL:{upper:"armL",end:"handL"}},look:{head:"head",body:"body",headYaw:1.1,headPitch:.75,bodyYaw:.5}},defaultParts:[{bone:"head",size:[8,8,8],pos:[0,28,0],color:"s"},{bone:"body",size:[8,12,4],pos:[0,18,0],color:"t"},{bone:"armL",size:[4,12,4],pos:[-6,18,0],color:"s"},{bone:"armR",size:[4,12,4],pos:[6,18,0],color:"s"},{bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p"},{bone:"legR",size:[4,12,4],pos:[2,6,0],color:"p"}]};var Va={id:"quadruped",label:"\u0427\u0435\u0442\u0432\u0435\u0440\u043E\u043D\u043E\u0433\u043E\u0435",hint:"dogs, cats, horses, wolves, bears, lizards \u2014 any animal on four legs",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,14,-8]},{name:"legFL",role:"legFL",parent:null,pivot:[-3,8,-6]},{name:"legFR",role:"legFR",parent:null,pivot:[3,8,-6]},{name:"legBL",role:"legBL",parent:null,pivot:[-3,8,6]},{name:"legBR",role:"legBR",parent:null,pivot:[3,8,6]},{name:"tail",role:"tail",parent:"body",pivot:[0,14,8]}],sockets:[{name:"headTop",bone:"head",at:[0,20,-12]},{name:"face",bone:"head",at:[0,16,-16]},{name:"back",bone:"body",at:[0,16,0]},{name:"waist",bone:"body",at:[0,12,4]},{name:"shoulders",bone:"body",at:[0,16,-6]},{name:"handR",bone:"head",at:[2,13,-16]},{name:"handL",bone:"head",at:[-2,13,-16]}],hitbox:{w:.9,h:1},eye:17,height:{min:8,max:40},faceBone:"head",ik:{feet:[{upper:"legFL",end:"sole"},{upper:"legFR",end:"sole"},{upper:"legBL",end:"sole"},{upper:"legBR",end:"sole"}],tilt:{front:["legFL","legFR"],back:["legBL","legBR"],max:.45},look:{head:"head",headYaw:.9,headPitch:.6,bodyYaw:0}},defaultParts:[{bone:"body",size:[8,8,16],pos:[0,12,0],color:"t"},{bone:"head",size:[8,8,8],pos:[0,16,-12],color:"s"},{bone:"legFL",size:[3,8,3],pos:[-3,4,-6],color:"p"},{bone:"legFR",size:[3,8,3],pos:[3,4,-6],color:"p"},{bone:"legBL",size:[3,8,3],pos:[-3,4,6],color:"p"},{bone:"legBR",size:[3,8,3],pos:[3,4,6],color:"p"},{bone:"tail",size:[2,2,8],pos:[0,14,12],color:"t"}]};var Fa={id:"swimmer",label:"\u041F\u043B\u043E\u0432\u0435\u0446",hint:"fish, sharks, dolphins, whales \u2014 creatures that swim with a tail",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,6,-4]},{name:"tail",role:"tail",parent:"body",pivot:[0,6,4]},{name:"finL",role:"ear",parent:"body",pivot:[-3,5,-1]},{name:"finR",role:"ear",parent:"body",pivot:[3,5,-1]}],sockets:[{name:"headTop",bone:"head",at:[0,10,-6]},{name:"face",bone:"head",at:[0,7,-9]},{name:"back",bone:"body",at:[0,10,0]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,9,-3]},{name:"handR",bone:"head",at:[1,4,-9]},{name:"handL",bone:"head",at:[-1,4,-9]}],hitbox:{w:.7,h:.6},eye:8,height:{min:4,max:40},faceBone:"head",ik:{look:{head:"head",headYaw:.4,headPitch:.3,bodyYaw:0}},defaultParts:[{bone:"body",size:[5,7,9],pos:[0,6,0],color:"t"},{bone:"head",size:[5,6,4],pos:[0,6,-6.5],color:"s"},{bone:"tail",size:[1,6,4],pos:[0,6,7],color:"t"},{bone:"finL",size:[3,.6,2],pos:[-4,5,-1],color:"p"},{bone:"finR",size:[3,.6,2],pos:[4,5,-1],color:"p"}]};var Wc=["root","body","head","armL","armR","legL","legR","foreArmL","foreArmR","shinL","shinR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],eo=["tail","wingL","wingR","ear","hair","cape","antenna","static"],$c=["handR","handL","headTop","face","back","waist","shoulders"],gr=["humanoid","quadruped","flyer","blob","swimmer"],Qt="avatar";var Ae={humanoid:_a,quadruped:Va,flyer:Oa,blob:Ia,swimmer:Fa,avatar:za};var Ba=1,dt=["front","back","left","right","top","bottom"],wr=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],Rr=["normal","bouncy","heavy","sneaky","robotic","swagger","skip","ninja","zombie","catwalk"],kr=["calm","fidgety","proud","cool","shy","ready","bored"],Ha={parts:96,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},er=["glass","metal","glow"],c1=["cylinder"],Zt={noise:.5,outline:.4,shade:.25,density:2},J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),xr=e=>Array.isArray(e)?e:[];function Ie(e,t,r,o){let a=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(a)?Math.min(o,Math.max(r,a)):t}function zo(e,t,r){if(typeof e!="string")return r;let o=e.trim();if(t.includes(o))return o;let a=o.toLowerCase().replace(/[\s-]+/g,"_");return t.find(s=>s.toLowerCase()===a)??r}function Ke(e,t,r){return typeof e=="string"?e.trim().slice(0,r):t}function to(e,t,r=null){if(!Array.isArray(e)||e.length<3)return r;let o=e.slice(0,3).map(a=>Ie(a,NaN,-t,t));return o.every(Number.isFinite)?o:r}var Da={black:"#1d1d21",white:"#f0f0f0",gray:"#808080",grey:"#808080",red:"#c0392b",green:"#3c9a3c",blue:"#2f5fd0",yellow:"#f2d33c",orange:"#e8862a",purple:"#8a4fc4",pink:"#f08cb4",brown:"#7a4f2a",cyan:"#2ab0c0",gold:"#d8b030",silver:"#c0c4c8",skin:"#c69c7c"};function ot(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(Da[t])return Da[t];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(a=>a+a).join(""):o)}var ut=new Set(["."," "]),Na=e=>/^[A-Za-z0-9_]{1,24}$/.test(e),Fs={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob",fish:"swimmer",shark:"swimmer",aquatic:"swimmer"};function Bs(e){if(typeof e!="string")return "humanoid";let t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return gr.includes(t)?t:t===Qt?Qt:Fs[t]??"humanoid"}function ja(e,t){let r=/^(.*?)(L|R)$/.exec(e);if(!r)return e;let o=r[1]+(r[2]==="L"?"R":"L");return t(o)?o:e}function Ye(e){if(typeof e=="string"){let f=Pa(e);if(!f.ok)return {ok:false,error:f.error,truncated:f.truncated};e=f.value;}if(!J(e))return {ok:false,error:ee({en:"the character recipe is not an object",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u0436\u0430 \u2014 \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})};if(!("parts"in e)&&!("rig"in e)){let f=e.character??e.spec??e.characterSpec;J(f)&&(e=f);}let t=e,r=Ha,o=[];typeof t.version=="number"&&t.version>Ba&&o.push(ee({en:"recipe version {v} is newer than the game \u2014 read what could be read",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 {v} \u2014 \u043D\u043E\u0432\u0435\u0435 \u0438\u0433\u0440\u044B, \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D\u043E \u0447\u0442\u043E \u043F\u043E\u043D\u044F\u0442\u043D\u043E"},{v:t.version}));let a=Bs(t.rig),n=Ae[a],s={};if(J(t.palette))for(let[f,S]of Object.entries(t.palette)){if(Object.keys(s).length>=r.palette){o.push(ee({en:"the palette is longer than {n} \u2014 the rest was dropped",ru:"\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u0434\u043B\u0438\u043D\u043D\u0435\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0435\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u043E"},{n:r.palette}));break}let T=ot(S);if(f.length!==1||ut.has(f)||!T){o.push(ee({en:"palette colour \xAB{k}\xBB was not understood",ru:"\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u043F\u043E\u043D\u044F\u0442"},{k:f}));continue}s[f]=T;}let l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=(f,S)=>{if(typeof f!="string")return S;if(f.length===1&&s[f])return f;let T=ot(f);if(!T)return S;let C=Object.entries(s).find(([,O])=>O===T);if(C)return C[0];if(Object.keys(s).length>=r.palette)return S;let z=[...l].find(O=>!s[O]);return z?(s[z]=T,z):S},c={},p=0;if(J(t.textures))for(let[f,S]of Object.entries(t.textures)){if(!Na(f)){o.push(ee({en:"texture name \xAB{id}\xBB does not fit",ru:"\u0438\u043C\u044F \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB \u043D\u0435 \u043F\u043E\u0434\u0445\u043E\u0434\u0438\u0442"},{id:f.slice(0,30)}));continue}if(Object.keys(c).length>=r.textures){o.push(ee({en:"more than {n} textures \u2014 the rest were dropped",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.textures}));break}let T=Hs(S,s,o,f);if(T){if(p+T.w*T.h>r.texturePixels){o.push(ee({en:"texture \xAB{id}\xBB did not fit the pixel limit",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB \u043D\u0435 \u0432\u043B\u0435\u0437\u043B\u0430 \u0432 \u043B\u0438\u043C\u0438\u0442 \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439"},{id:f}));continue}p+=T.w*T.h,c[f]=T;}}let h=new Set(n.bones.map(f=>f.name)),m=[];for(let f of xr(t.bones)){if(!J(f))continue;let S=Ke(f.name,"",24);if(!S||!Na(S))continue;let T=to(f.pivot,r.coord);if(!T||m.some(M=>M.name===S))continue;if(m.length>=r.bones){o.push(ee({en:"more than {n} bones \u2014 the rest were dropped",ru:"\u043A\u043E\u0441\u0442\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.bones}));break}let C=h.has(S),z=Ke(f.parent,"",24),O=C?n.bones.find(M=>M.name===S).parent??"":h.has(z)||m.some(M=>M.name===z)?z:n.bones.find(M=>M.role==="body").name;m.push({name:S,parent:O,pivot:T,role:C?"static":zo(f.role,eo,"static")}),h.add(S);}let d=Object.keys(s)[0]??"s",b=[];for(let f of xr(t.parts)){if(b.length>=r.parts){o.push(ee({en:"more than {n} parts \u2014 the rest were dropped",ru:"\u0434\u0435\u0442\u0430\u043B\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.parts}));break}if(!J(f))continue;let S=to(f.size,r.partSide),T=to(f.pos??f.center??f.at,r.coord);if(!S||!T||S.some(V=>V<=0))continue;let C=Ke(f.bone,"",24);h.has(C)||(C&&o.push(ee({en:"bone \xAB{b}\xBB not found \u2014 the part is on the body",ru:"\u043A\u043E\u0441\u0442\u044C \xAB{b}\xBB \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u2014 \u0434\u0435\u0442\u0430\u043B\u044C \u043D\u0430 \u0442\u0435\u043B\u0435"},{b:C})),C=n.bones.find(V=>V.role==="body").name);let z={bone:C,size:S,pos:T,color:i(f.color,d)};if(J(f.faces)){let V={};for(let q of dt){let Y=f.faces[q];if(typeof Y=="string")if(c[Y])V[q]=Y;else {let pe=i(Y,"");pe&&(V[q]=pe);}}Object.keys(V).length&&(z.faces=V);}let O=to(f.rot??f.rotation,180);O&&O.some(V=>V!==0)&&(z.rot=O),(f.mirror===true||f.mirror==="x")&&(z.mirror=true);let M=Ke(f.name,"",24);M&&(z.name=M),f.shape==="cylinder"&&(z.shape="cylinder"),typeof f.mat=="string"&&er.includes(f.mat)&&(z.mat=f.mat),f.wrap===true&&(z.wrap=true),b.push(z);}if(!b.length){for(let[f,S]of Object.entries(Ds))s[f]||(s[f]=S);b.push(...n.defaultParts.map(Ns));}let u=null;if(J(t.face)){let f=t.face,S=h.has(Ke(f.bone,"",24))?Ke(f.bone,"",24):n.faceBone,T=xr(f.rect).map(z=>Math.round(Ie(z,NaN,0,r.partSide)*10)/10),C={};if(J(f.expressions))for(let z of wr){let O=f.expressions[z];typeof O=="string"&&c[O]&&(C[z]=O);}if(!C.neutral){let z=Object.values(C)[0];z&&(C.neutral=z);}if(C.neutral){let z=c[C.neutral];if(u={bone:S,rect:T.length===4&&T.every(Number.isFinite)&&T[2]>0&&T[3]>0?T:[0,0,z.w,z.h],expressions:C},J(f.drawn)){let O=f.drawn;u.drawn={eyes:Ke(O.eyes,"round",16),brows:Ke(O.brows,"none",16),mouth:Ke(O.mouth,"smile",16),eyeColor:ot(O.eyeColor)??"#3b2a20",cheeks:O.cheeks===true};}}else Object.keys(f).length&&o.push(ee({en:"the face has no pictures \u2014 no face is drawn",ru:"\u0443 \u043B\u0438\u0446\u0430 \u043D\u0435\u0442 \u043D\u0438 \u043E\u0434\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438 \u2014 \u043B\u0438\u0446\u043E \u043D\u0435 \u043D\u0430\u0440\u0438\u0441\u043E\u0432\u0430\u043D\u043E"}));}let R=J(t.style)?t.style:{},w=J(t.voice)?t.voice:{},A=J(t.finish)?t.finish:{},k={version:Ba,name:Ke(t.name,ro(),40)||ro(),description:Ke(t.description,"",300),rig:a,scale:Ie(t.scale,1,.25,3),palette:s,textures:c,parts:b,bones:m,face:u,style:{walk:zo(R.walk,Rr,"normal"),idle:zo(R.idle,kr,"calm"),energy:Ie(R.energy,.5,0,1)},voice:{pitch:Ie(w.pitch,1,.5,2)},tags:xr(t.tags).filter(f=>typeof f=="string"&&!!f.trim()).slice(0,8).map(f=>f.trim().slice(0,24)),finish:{noise:Ie(A.noise,Zt.noise,0,1),outline:Ie(A.outline,Zt.outline,0,1),shade:Ie(A.shade,Zt.shade,0,1),density:Math.round(Ie(A.density,Zt.density,1,4))}},x=Ie(A.round,0,0,1);return x>0&&(k.finish.round=x),{ok:true,spec:k,warnings:o}}var Ds={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function Ns(e){return JSON.parse(JSON.stringify(e))}function Hs(e,t,r,o){let a=Array.isArray(e)?{rows:e}:J(e)?e:null;if(!a)return null;let n=Ha.textureSide,s=xr(a.rows??a.pixels).filter(p=>typeof p=="string");if(!s.length)return null;let l=Math.round(Ie(a.h??a.height,s.length,1,n)),i=Math.round(Ie(a.w??a.width,Math.max(...s.map(p=>p.length)),1,n)),c=false;for(s=s.slice(0,l).map(p=>{let h="";for(let m=0;m<i;m++){let d=p[m]??".";ut.has(d)||t[d]?h+=d===" "?".":d:(c=true,h+=".");}return h});s.length<l;)s.push(".".repeat(i));return c&&r.push(ee({en:"texture \xAB{id}\xBB has symbols not in the palette \u2014 they became transparent",ru:"\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \u2014 \u0441\u0442\u0430\u043B\u0438 \u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u044B\u043C\u0438"},{id:o})),{w:i,h:l,rows:s}}function Io(e){return Array.isArray(e)?"["+e.map(Io).join(",")+"]":J(e)?"{"+Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>JSON.stringify(t)+":"+Io(e[t])).join(",")+"}":JSON.stringify(e)}function tr(e){let t=Io(e),r=It(t),o=It("~"+t);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function p1(e){return Ae[e.rig]}function Ga(e){let r=Ae[e.rig].bones.map(o=>{let a=e.bones.find(n=>n.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(a?.pivot??o.pivot).slice()}});for(let o of e.bones)r.some(a=>a.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function ro(){return ee({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var m1=e=>e==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||e==="Character";var qa={front:{tl:[1,1,-1],u:[-1,0,0],d:[0,-1,0],n:[0,0,-1]},back:{tl:[-1,1,1],u:[1,0,0],d:[0,-1,0],n:[0,0,1]},right:{tl:[1,1,1],u:[0,0,-1],d:[0,-1,0],n:[1,0,0]},left:{tl:[-1,1,-1],u:[0,0,1],d:[0,-1,0],n:[-1,0,0]},top:{tl:[1,1,1],u:[-1,0,0],d:[0,0,-1],n:[0,1,0]},bottom:{tl:[-1,-1,1],u:[1,0,0],d:[0,0,-1],n:[0,-1,0]}};function Oo(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}function Ua(e,t,r,o,a,n){let s=((r-1-a)*t+o)*4;e[s]=n[0],e[s+1]=n[1],e[s+2]=n[2],e[s+3]=255;}function js(e,t=0){e.sort((r,o)=>o.h-r.h||o.w-r.w||(r.key<o.key?-1:1));for(let r=16;;r*=2){let o=0,a=0,n=0;for(let l of e)o+l.w+t*2>r&&(o=0,a+=n,n=0),l.x=o+t,l.y=a+t,o+=l.w+t*2,n=Math.max(n,l.h+t*2);let s=a+n;if(s<=r||r>=1024){let l=16;for(;l<s;)l*=2;return {w:r,h:l}}}}function Gs(e,t,r,o,a){let n=(s,l)=>((r-1-o.y-l)*t+o.x+s)*4;for(let s=-a;s<o.h+a;s++)for(let l=-a;l<o.w+a;l++){let i=Math.max(0,Math.min(o.w-1,l)),c=Math.max(0,Math.min(o.h-1,s));if(i===l&&c===s)continue;let p=n(i,c);e.copyWithin(n(l,s),p,p+4);}}function Ka(e,t,r){let o=Math.imul(t,374761393)+Math.imul(r,668265263)+Math.imul(e,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function qs(e,t,r,o,a,n,s,l){let c=1+(.55*Ka(s,t,r)+.45*Ka(s^1540483477,Math.floor(t/3),Math.floor(r/3))-.5)*2*l.noise*.14;return n==="s"?c+=l.shade*.16*(.5-(r+.5)/a):n==="t"?c+=l.shade*.08:c-=l.shade*.2,o>=3&&a>=3&&(t===0||r===0||t===o-1||r===a-1)&&(c*=1-.5*l.outline),[Math.max(0,Math.min(255,e[0]*c)),Math.max(0,Math.min(255,e[1]*c)),Math.max(0,Math.min(255,e[2]*c))]}var rr=Math.PI/180;function or(e,t){if(!t)return e;let[r,o,a]=e,[n,s,l]=[t[0]*rr,t[1]*rr,t[2]*rr],i=Math.cos(l),c=Math.sin(l);return [r,o]=[r*i-o*c,r*c+o*i],i=Math.cos(s),c=Math.sin(s),[r,a]=[r*i+a*c,-r*c+a*i],i=Math.cos(n),c=Math.sin(n),[o,a]=[o*i-a*c,o*c+a*i],[r,o,a]}function Us(e,t){let r=[];for(let o of e.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let a=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;a&&(a.left===void 0&&delete a.left,a.right===void 0&&delete a.right);let n={...o,bone:ja(o.bone,t),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};a?n.faces=a:delete n.faces,o.rot&&(n.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(n);}return r}function $a(e){let t=Ae[e.rig],r=Ga(e),o=v=>r.some(_=>_.name===v),a=Us(e,o),n=e.finish??Zt,s=n.round??0,l=new Map,i=(v,_)=>{let F=v.faces?.[_],H=F!==void 0?e.textures[F]:void 0,he=F!==void 0&&e.palette[F]?F:v.color,[Ce,Ne]=_==="front"||_==="back"?[v.size[0],v.size[1]]:_==="left"||_==="right"?[v.size[2],v.size[1]]:[v.size[0],v.size[2]],Pe=(br,qe)=>Math.max(1,Math.min(64,qe*Math.max(1,Math.round(br*n.density/qe)))),ve=H?Pe(Ce,H.w):Pe(Ce,1),ze=H?Pe(Ne,H.h):Pe(Ne,1),Fe=_==="top"?"t":_==="bottom"?"b":"s",oe=(H?"t:"+F:"c:"+he)+"|"+ve+"x"+ze+Fe,fe=l.get(oe);if(fe)return fe;let $=It(oe),zt=H?null:Oo(e.palette[he]??"#ff00ff");return fe={key:oe,w:ve,h:ze,x:0,y:0,paint:(br,qe,$r,Jr,Xr)=>{for(let ct=0;ct<ze;ct++)for(let pt=0;pt<ve;pt++){let yr=zt;if(H){let Qr=H.rows[Math.floor(ct*H.h/ze)][Math.floor(pt*H.w/ve)];if(ut.has(Qr))continue;let Ue=e.palette[Qr];if(!Ue)continue;yr=Oo(Ue);}Ua(br,qe,$r,Jr+pt,Xr+ct,qs(yr,pt,ct,ve,ze,Fe,$,n));}}},l.set(oe,fe),fe},c=(v,_)=>{let F="e:"+v,H=l.get(F);return H||(H={key:F,w:_.w,h:_.h,x:0,y:0,paint:(he,Ce,Ne,Pe,ve)=>{for(let ze=0;ze<_.h;ze++)for(let Fe=0;Fe<_.w;Fe++){let oe=_.rows[ze][Fe];if(ut.has(oe))continue;let fe=e.palette[oe];fe&&Ua(he,Ce,Ne,Pe+Fe,ve+ze,Oo(fe));}}},l.set(F,H)),H},p=a.map(v=>({p:v,faces:dt.map(_=>({f:_,cell:i(v,_)}))})),h=e.face,m=[];if(h)for(let[v,_]of Object.entries(h.expressions)){let F=e.textures[_];F&&m.push([v,c(_,F)]);}let d=s>0?2:0,{w:b,h:u}=js([...l.values()],d),R=new Uint8Array(b*u*4);for(let v of l.values())v.paint(R,b,u,v.x,v.y),d&&Gs(R,b,u,v,d);let w=.01,A=(v,_=w)=>[(v.x+_)/b,1-(v.y+_)/u,(v.x+v.w-_)/b,1-(v.y+v.h-_)/u],k=new Map;for(let v of r)k.set(v.name,{pos:[],nrm:[],uv:[],idx:[]});let x=new Map,f=v=>{let _=x.get(v);if(_===void 0){_=true;for(let F=0;F<v.h&&_;F++)for(let H=0;H<v.w;H++)if(R[((u-1-v.y-F)*b+v.x+H)*4+3]<128){_=false;break}x.set(v,_);}return _},S=new Map;for(let{p:v}of p)v.shape==="cylinder"&&!S.has(v.bone)&&S.set(v.bone,v);let T=v=>!!v.wrap&&S.has(v.bone),C=new Map;for(let{p:v,faces:_}of p)if(v.shape!=="cylinder"&&v.mat!=="glass"&&_.every(({cell:F})=>f(F))){let F=C.get(v.bone)??[];F.push(v),C.set(v.bone,F);}let z=new Map,O=v=>{if(!v.mat)return k.get(v.bone);let _=v.mat+"|"+v.bone,F=z.get(_);return F||z.set(_,F={bone:v.bone,mat:v.mat,pos:[],nrm:[],uv:[],idx:[]}),F},M=0;for(let{p:v,faces:_}of p){let F=O(v),H=r.find(oe=>oe.name===v.bone).pivot,he=[v.size[0]/2,v.size[1]/2,v.size[2]/2];if(M=Math.max(M,v.pos[1]+he[1]),v.shape==="cylinder"){for(let{f:oe,cell:fe}of _)ei(F,v,he,qa[oe],H,A(fe,.5));continue}let Ce=T(v),Ne=Ce?S.get(v.bone):void 0,Pe=(C.get(v.bone)??[]).filter(oe=>oe!==v&&T(oe)===Ce),ve=Math.min(v.size[0],v.size[1],v.size[2])<Xa?0:s,ze=Math.min(v.size[0],v.size[1],v.size[2])>=$s?Ws:Ys,Fe=(oe,fe)=>{let $=qa[oe],zt=(Ue,mt)=>{let Xt=[he[0]*($.tl[0]+2*($.u[0]*Ue+$.d[0]*mt)),he[1]*($.tl[1]+2*($.u[1]*Ue+$.d[1]*mt)),he[2]*($.tl[2]+2*($.u[2]*Ue+$.d[2]*mt))],ht=or(Xt,v.rot);return [v.pos[0]+ht[0]-H[0],v.pos[1]+ht[1]-H[1],v.pos[2]+ht[2]-H[2]]},br=or($.n,v.rot),qe=F.pos.length/3,[$r,Jr,Xr,ct]=A(fe),[pt,yr]=v.flip?[Xr,$r]:[$r,Xr];if(ve>0||Ce){let[Ue,mt,Xt,ht]=A(fe,.5);Js(F,v,he,$,H,ve,ze,v.flip?[Xt,mt,Ue,ht]:[Ue,mt,Xt,ht],Ce);return}let Qr=[[0,0,pt,Jr],[1,0,yr,Jr],[1,1,yr,ct],[0,1,pt,ct]];for(let[Ue,mt,Xt,ht]of Qr)F.pos.push(...zt(Ue,mt)),F.nrm.push(...br),F.uv.push(Xt,ht);F.idx.push(qe,qe+2,qe+1,qe,qe+3,qe+2);};for(let{f:oe,cell:fe}of _){let $=[F.pos.length,F.nrm.length,F.uv.length,F.idx.length];Fe(oe,fe),Pe.length&&hi(F.pos,$[0],H,Pe,s)?(F.pos.length=$[0],F.nrm.length=$[1],F.uv.length=$[2],F.idx.length=$[3]):Ne&&(ii(F,$[0],H,Ne,ai(v,he,Ne)),si(F.pos,$[0],H,Ne)&&(F.pos.length=$[0],F.nrm.length=$[1],F.uv.length=$[2],F.idx.length=$[3]));}}let V=r.map(v=>{let _=k.get(v.name);return {name:v.name,role:v.role,parent:v.parent,pivot:v.pivot,positions:Float32Array.from(_.pos),normals:Float32Array.from(_.nrm),uvs:Float32Array.from(_.uv),indices:Uint16Array.from(_.idx)}}),q=[...z.values()].map(v=>({bone:v.bone,mat:v.mat,positions:Float32Array.from(v.pos),normals:Float32Array.from(v.nrm),uvs:Float32Array.from(v.uv),indices:Uint16Array.from(v.idx)})),Y=null;if(h&&m.length){let v=e.parts.filter(H=>H.bone===h.bone),_=v.find(H=>H.name===h.bone)??v.sort((H,he)=>he.size[0]*he.size[1]*he.size[2]-H.size[0]*H.size[1]*H.size[2])[0],F=r.find(H=>H.name===h.bone);if(_&&F&&_.shape==="cylinder"){let H={};for(let[he,Ce]of m)H[he]=A(Ce);Y=pi(h.bone,_,h.rect,F.pivot,H);}else if(_&&F){let[H,he,Ce,Ne]=h.rect,Pe=_.pos[0]+_.size[0]/2-H,ve=_.pos[1]+_.size[1]/2-he,ze=_.pos[2]-_.size[2]/2-.05,Fe=F.pivot,oe=($,zt)=>[$-Fe[0],zt-Fe[1],ze-Fe[2]],fe={};for(let[$,zt]of m)fe[$]=A(zt);Y={bone:h.bone,corners:Float32Array.from([...oe(Pe,ve),...oe(Pe-Ce,ve),...oe(Pe-Ce,ve-Ne),...oe(Pe,ve-Ne)]),uv:fe};}}let pe=t.sockets.filter(v=>o(v.bone)).map(v=>{let _=t.bones.find(F=>F.name===v.bone);return {name:v.name,bone:v.bone,at:[v.at[0]-_.pivot[0],v.at[1]-_.pivot[1],v.at[2]-_.pivot[2]]}}),me=Math.max(1,M),ie=me>t.height.max?t.height.max/me:me<t.height.min?t.height.min/me:1;return {hash:tr(e),rig:e.rig,bones:V,mats:q,atlas:{w:b,h:u,data:R},face:Y,sockets:pe,height:me,scale:e.scale*ie,eye:t.eye*me/di(e.rig)}}var Ja=3,Ks=2.5,Ys=1,Ya=0,Ws=2,$s=4.1;function Js(e,t,r,o,a,n,s,l,i=false){let c=Math.min(r[0],r[1],r[2]),p=i?0:Math.min(c,n*Ja),h=Math.min(c,p*Ks),m=[r[0]-p,r[1]-p,r[2]-p],d=[r[0]-h,r[1]-h,r[2]-h],b=C=>Math.abs(C[0])*t.size[0]+Math.abs(C[1])*t.size[1]+Math.abs(C[2])*t.size[2],u=C=>{let z=[];for(let M=0;M<=s;M++)z.push(Math.min(.5,p*M/s/C));if(!i)for(let M=1;M<=Ya;M++)z.push(Math.min(.5,(p+(h-p)*M/Ya)/C));if(i){let M=Math.max(1,Math.min(Qs,Math.ceil(C/Xs)));for(let V=1;V<M;V++)z.push(Vo(V/M));}let O=[...z,...z.map(M=>1-M)].sort((M,V)=>M-V);return O.filter((M,V)=>V===0||M-O[V-1]>1e-6)},R=u(b(o.u)),w=u(b(o.d)),A=e.pos.length/3,[k,x,f,S]=l;for(let C of w)for(let z of R){let O=[0,0,0],M=[0,0,0],V=[0,0,0];for(let _=0;_<3;_++){let F=r[_]*(o.tl[_]+2*(o.u[_]*z+o.d[_]*C)),H=Math.max(-m[_],Math.min(m[_],F));M[_]=F-H,O[_]=H,V[_]=F-Math.max(-d[_],Math.min(d[_],F));}let q=Math.hypot(M[0],M[1],M[2]),Y=q>1e-9?[M[0]/q,M[1]/q,M[2]/q]:[o.n[0],o.n[1],o.n[2]],pe=Math.hypot(V[0],V[1],V[2]),me=pe>1e-9?[V[0]/pe,V[1]/pe,V[2]/pe]:Y,ie=[O[0]+Y[0]*p,O[1]+Y[1]*p,O[2]+Y[2]*p],v=or(ie,t.rot);e.pos.push(t.pos[0]+v[0]-a[0],t.pos[1]+v[1]-a[1],t.pos[2]+v[2]-a[2]),e.nrm.push(...or(me,t.rot)),e.uv.push(k+(f-k)*z,x+(S-x)*C);}let T=R.length;for(let C=0;C+1<w.length;C++)for(let z=0;z+1<T;z++){let O=A+C*T+z;e.idx.push(O,O+T+1,O+1,O,O+T,O+T+1);}}var Xa=.45,Xs=1.5,Qs=5,Zs=10,Wa=.6,Vo=e=>(1-Wa)*e+Wa*(.5+.5*Math.sin(Math.PI*(e-.5))),vr=4,oo=1.12,Qa=.35;function Za(e,t,r){let o=e*e,a=t*t,n=r*r;return [e*Math.sqrt(Math.max(0,1-a/2-n/2+a*n/3)),t*Math.sqrt(Math.max(0,1-n/2-o/2+n*o/3)),r*Math.sqrt(Math.max(0,1-o/2-a/2+o*a/3))]}function en(e){let t=vr,r=Math.pow(Math.pow(e[0]*e[0]+e[2]*e[2],t/2)+Math.pow(Math.abs(e[1]),t),1/t)||1;return [e[0]/r,e[1]/r,e[2]/r]}function Fo(e,t){let r=vr,o=Math.pow(e[0]*e[0]+e[2]*e[2],(r-2)/2),a=[e[0]*o,Math.sign(e[1])*Math.pow(Math.abs(e[1]),r-1),e[2]*o],n=[a[0]/t[0],a[1]/t[1],a[2]/t[2]],s=Math.hypot(n[0],n[1],n[2])||1;return [n[0]/s,n[1]/s,n[2]/s]}function ei(e,t,r,o,a,n){let s=Zs,l=e.pos.length/3,[i,c,p,h]=n;for(let d=0;d<=s;d++)for(let b=0;b<=s;b++){let u=Vo(b/s),R=Vo(d/s),w=[0,0,0];for(let x=0;x<3;x++)w[x]=o.tl[x]+2*(o.u[x]*u+o.d[x]*R);let A=en(Za(w[0],w[1],w[2])),k=or([r[0]*A[0],r[1]*A[1],r[2]*A[2]],t.rot);e.pos.push(t.pos[0]+k[0]-a[0],t.pos[1]+k[1]-a[1],t.pos[2]+k[2]-a[2]),e.nrm.push(...or(Fo(A,r),t.rot)),e.uv.push(i+(p-i)*u,c+(h-c)*R);}let m=s+1;for(let d=0;d<s;d++)for(let b=0;b<s;b++){let u=l+d*m+b;e.idx.push(u,u+m+1,u+1,u,u+m,u+m+1);}}function ti(e,t){let r=[t.size[0]/2,t.size[1]/2,t.size[2]/2],o=[(e[0]-t.pos[0])/r[0],(e[1]-t.pos[1])/r[1],(e[2]-t.pos[2])/r[2]],a=Math.max(Math.abs(o[0]),Math.abs(o[1]),Math.abs(o[2]));if(a<1e-6)return {p:e,w:0,s:[0,1,0]};let n=en(Za(o[0]/a,o[1]/a,o[2]/a)),s=a<=oo?1:Math.max(0,1-(a-oo)/Qa),l=s*s*(3-2*s),i=[t.pos[0]+r[0]*n[0]*a,t.pos[1]+r[1]*n[1]*a,t.pos[2]+r[2]*n[2]*a];return {p:[e[0]+(i[0]-e[0])*l,e[1]+(i[1]-e[1])*l,e[2]+(i[2]-e[2])*l],w:l,s:n}}var ri=1.25,oi=.85;function ai(e,t,r){if(e.rot)return false;let o=(e.pos[1]+t[1]-r.pos[1])/(r.size[1]/2),a=Math.max(t[0]/(r.size[0]/2),t[2]/(r.size[2]/2));return o>ri&&a>=oi}function ni(e,t){let r=t.size[0]/2,o=t.size[2]/2,a=(e[0]-t.pos[0])/r,n=(e[2]-t.pos[2])/o,s=Math.max(Math.abs(a),Math.abs(n));if(s<1e-6)return {p:e,w:0,s:[0,1,0]};let l=a/s,i=n/s,c=l*Math.sqrt(Math.max(0,1-i*i/2)),p=i*Math.sqrt(Math.max(0,1-l*l/2)),h=s<=oo?1:Math.max(0,1-(s-oo)/Qa),m=h*h*(3-2*h),d=t.pos[0]+r*c*s,b=t.pos[2]+o*p*s;return {p:[e[0]+(d-e[0])*m,e[1],e[2]+(b-e[2])*m],w:m,s:[c,0,p]}}function si(e,t,r,o){let a=vr;for(let n=t;n<e.length;n+=3){let s=(e[n]+r[0]-o.pos[0])/(o.size[0]/2),l=(e[n+1]+r[1]-o.pos[1])/(o.size[1]/2),i=(e[n+2]+r[2]-o.pos[2])/(o.size[2]/2);if(Math.pow(Math.pow(s*s+i*i,a/2)+Math.pow(Math.abs(l),a),1/a)>.97)return false}return true}function ii(e,t,r,o,a=false){let n=[o.size[0]/2,o.size[1]/2,o.size[2]/2];for(let s=t;s<e.pos.length;s+=3){let l=[e.pos[s]+r[0],e.pos[s+1]+r[1],e.pos[s+2]+r[2]],{p:i,w:c,s:p}=a?ni(l,o):ti(l,o);if(e.pos[s]=i[0]-r[0],e.pos[s+1]=i[1]-r[1],e.pos[s+2]=i[2]-r[2],c<=0)continue;let h=[e.nrm[s],e.nrm[s+1],e.nrm[s+2]],m=[l[0]-o.pos[0],l[1]-o.pos[1],l[2]-o.pos[2]],d=Math.hypot(m[0],m[1],m[2])||1;if((h[0]*m[0]+h[1]*m[1]+h[2]*m[2])/d<.3||a&&Math.abs(h[1])>.7)continue;let b=Fo(p,n),u=[h[0]+(b[0]-h[0])*c,h[1]+(b[1]-h[1])*c,h[2]+(b[2]-h[2])*c],R=Math.hypot(u[0],u[1],u[2])||1;e.nrm[s]=u[0]/R,e.nrm[s+1]=u[1]/R,e.nrm[s+2]=u[2]/R;}}var _o=.16,li=12,ci=12;function pi(e,t,r,o,a){let n=[t.size[0]/2,t.size[1]/2,t.size[2]/2],[s,l,i,c]=r,p=t.pos[0]+n[0]-s,h=t.pos[1]+n[1]-l,m=li,d=ci,b=new Float32Array((m+1)*(d+1)*3),u=new Float32Array((m+1)*(d+1)*3),R=new Float32Array((m+1)*(d+1)*2),w=0;for(let k=0;k<=d;k++)for(let x=0;x<=m;x++){let f=x/m,S=k/d,T=p-i*f,C=h-c*S,z=(T-t.pos[0])/n[0],O=(C-t.pos[1])/n[1],M=Math.pow(Math.max(0,1-Math.pow(Math.min(1,Math.abs(O)),vr)),1/vr),V=-Math.sqrt(Math.max(.02,M*M-z*z)),q=Fo([z,O,V],n);b[w*3]=T+q[0]*_o-o[0],b[w*3+1]=C+q[1]*_o-o[1],b[w*3+2]=t.pos[2]+n[2]*V+q[2]*_o-o[2],u.set(q,w*3),R[w*2]=f,R[w*2+1]=S,w++;}let A=(k,x)=>[k-o[0],x-o[1],t.pos[2]-n[2]-o[2]];return {bone:e,corners:Float32Array.from([...A(p,h),...A(p-i,h),...A(p-i,h-c),...A(p,h-c)]),uv:a,grid:{cols:m,rows:d,positions:b,normals:u,t:R}}}function mi(e,t){if(!t)return e;let[r,o,a]=e,[n,s,l]=[-t[0]*rr,-t[1]*rr,-t[2]*rr],i=Math.cos(n),c=Math.sin(n);return [o,a]=[o*i-a*c,o*c+a*i],i=Math.cos(s),c=Math.sin(s),[r,a]=[r*i+a*c,-r*c+a*i],i=Math.cos(l),c=Math.sin(l),[r,o]=[r*i-o*c,r*c+o*i],[r,o,a]}function hi(e,t,r,o,a){for(let s of o){let l=[s.size[0]/2,s.size[1]/2,s.size[2]/2],i=Math.min(s.size[0],s.size[1],s.size[2])<Xa?0:a,c=i>0?Math.min(l[0],l[1],l[2],i*Ja):0,p=true;for(let h=t;h<e.length&&p;h+=3){let m=mi([e[h]+r[0]-s.pos[0],e[h+1]+r[1]-s.pos[1],e[h+2]+r[2]-s.pos[2]],s.rot),d=Math.abs(m[0])-(l[0]-c),b=Math.abs(m[1])-(l[1]-c),u=Math.abs(m[2])-(l[2]-c);Math.hypot(Math.max(d,0),Math.max(b,0),Math.max(u,0))+Math.min(Math.max(d,b,u),0)-c>=-0.01&&(p=false);}if(p)return true}return false}function di(e){let t=1;for(let r of Ae[e].defaultParts)t=Math.max(t,r.pos[1]+r.size[1]/2);return t}var Bo=new Map;function ui(e){let t=new Map;for(let i of e.bones){if(!i.indices.length){t.set(i.name,null);continue}let c=new D__namespace.BufferGeometry;c.setAttribute("position",new D__namespace.BufferAttribute(i.positions,3)),c.setAttribute("normal",new D__namespace.BufferAttribute(i.normals,3)),c.setAttribute("uv",new D__namespace.BufferAttribute(i.uvs,2)),c.setIndex(new D__namespace.BufferAttribute(i.indices,1)),c.computeBoundingSphere(),c.userData.shared=true,t.set(i.name,c);}let r=tn(e.bones,e),o=new Map;for(let i of new Set(e.mats.map(c=>c.mat))){let c=e.mats.filter(h=>h.mat===i).map(h=>({...h,pivot:e.bones.find(m=>m.name===h.bone).pivot})),p=tn(c,e);p&&o.set(i,p);}let{w:a,h:n,data:s}=e.atlas,l=new D__namespace.DataTexture(s,a,n,D__namespace.RGBAFormat);return l.magFilter=D__namespace.NearestFilter,l.minFilter=D__namespace.NearestFilter,l.generateMipmaps=false,l.colorSpace=D__namespace.SRGBColorSpace,l.needsUpdate=true,{layout:e,geometries:t,skinned:r,skinnedMats:o,texture:l,refs:0}}function tn(e,t){let r=b=>t.bones.findIndex(u=>u.name===(b.bone??b.name)),o=0,a=0;for(let b of e)o+=b.positions.length/3,a+=b.indices.length;if(!a)return null;let n=new Float32Array(o*3),s=new Float32Array(o*3),l=new Float32Array(o*2),i=new Uint16Array(o*4),c=new Float32Array(o*4),p=o>65535?new Uint32Array(a):new Uint16Array(a),h=0,m=0;e.forEach(b=>{let u=r(b),R=b.positions.length/3;for(let w=0;w<R;w++)n[(h+w)*3]=b.positions[w*3]+b.pivot[0],n[(h+w)*3+1]=b.positions[w*3+1]+b.pivot[1],n[(h+w)*3+2]=b.positions[w*3+2]+b.pivot[2],i[(h+w)*4]=u,c[(h+w)*4]=1;s.set(b.normals,h*3),l.set(b.uvs,h*2);for(let w=0;w<b.indices.length;w++)p[m+w]=b.indices[w]+h;h+=R,m+=b.indices.length;});let d=new D__namespace.BufferGeometry;return d.setAttribute("position",new D__namespace.BufferAttribute(n,3)),d.setAttribute("normal",new D__namespace.BufferAttribute(s,3)),d.setAttribute("uv",new D__namespace.BufferAttribute(l,2)),d.setAttribute("skinIndex",new D__namespace.Uint16BufferAttribute(i,4)),d.setAttribute("skinWeight",new D__namespace.BufferAttribute(c,4)),d.setIndex(new D__namespace.BufferAttribute(p,1)),d.computeBoundingSphere(),d.userData.shared=true,d}function Do(e){let t=Bo.get(tr(e));return t||(t=ui($a(e)),Bo.set(t.layout.hash,t)),t.refs++,t}function ao(e){if(!(--e.refs>0)){Bo.delete(e.layout.hash);for(let t of e.geometries.values())t?.dispose();e.skinned?.dispose();for(let t of e.skinnedMats.values())t.dispose();e.texture.dispose();}}var U=class e{constructor(t,r,o="."){this.w=t;this.h=r;this.g=Array.from({length:r},()=>new Array(t).fill(o));}w;h;g;px(t,r,o){return t>=0&&r>=0&&t<this.w&&r<this.h&&(this.g[r][t]=o),this}rect(t,r,o,a,n){for(let s=r;s<r+a;s++)for(let l=t;l<t+o;l++)this.px(l,s,n);return this}row(t,r,o,a){return this.rect(r,t,o-r+1,1,a)}col(t,r,o,a){return this.rect(t,r,1,o-r+1,a)}where(t,r){for(let o=0;o<this.h;o++)for(let a=0;a<this.w;a++)t(a,o)&&this.px(a,o,r);return this}flipped(){let t=new e(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)t.px(this.w-1-o,r,this.g[r][o]);return t}tex(){return {w:this.w,h:this.h,rows:this.g.map(t=>t.join(""))}}};var fi={s:"#d9a982",S:"#bf8d68",h:"#6b4a2f",H:"#8a6644",k:"#3a2818",w:"#f4f4ef",b:"#3f8f9c",m:"#9a5544",o:"#4a2219",t:"#a7bea9",T:"#c4d6c4",D:"#84a08a",u:"#ece6d2",B:"#6a4e33",g:"#d8c48c",p:"#8c9ca6",P:"#6f808a",z:"#a07a55",Z:"#7c5c3f",l:"#e9e3cf"};function at(e,t){let r=parseInt(e.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(a=>Math.max(0,Math.min(255,Math.round(a*t)))).map(a=>a.toString(16).padStart(2,"0")).join("")}function Ho(e,t){let r={...e};return t.skin&&(r.s=t.skin,r.S=at(t.skin,.86),r.m=at(t.skin,.66)),t.hair&&(r.h=t.hair,r.H=at(t.hair,1.25),r.k=at(t.hair,.6)),t.shirt&&(r.t=t.shirt,r.T=at(t.shirt,1.15),r.D=at(t.shirt,.8)),t.pants&&(r.p=t.pants,r.P=at(t.pants,.8)),t.boots&&(r.z=t.boots,r.Z=at(t.boots,.78)),t.eyes&&(r.b=t.eyes),r}var bi=new U(16,16,"s").rect(0,0,16,3,"h").row(3,0,4,"h").row(3,10,15,"h").row(4,0,1,"h").row(4,13,15,"h").col(0,5,8,"h").col(15,5,8,"h").row(1,3,6,"H").row(1,9,12,"H").row(15,2,13,"S"),rn=new U(16,16,"s").rect(0,0,16,4,"h").rect(7,4,9,7,"h").rect(10,11,6,2,"h").rect(5,7,2,3,"S").row(1,2,13,"H").where((e,t)=>t>4&&t<11&&e>8&&(e+t)%4===0,"k"),yi=rn.flipped(),gi=new U(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>t>8&&(e*3+t)%7===0,"k").rect(4,14,8,2,"s"),xi=new U(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>(3*e+t)%9===0,"k"),wi=new U(18,4,"h").where((e,t)=>(e*7+t*3)%5===0,"H").where((e,t)=>t===3&&e*5%3===0,"k"),Ri=new U(16,24,"t").row(0,6,9,"s").row(1,7,8,"s").row(0,3,5,"T").row(0,10,12,"T").row(1,4,6,"T").row(1,9,11,"T").row(2,5,6,"T").row(2,9,10,"T").col(8,2,19,"D").px(7,5,"u").px(7,9,"u").px(7,13,"u").px(7,17,"u").row(6,2,5,"D").col(2,7,10,"D").col(5,7,10,"D").row(10,2,5,"D").px(4,7,"u").row(6,10,13,"D").col(10,7,10,"D").col(13,7,10,"D").row(10,10,13,"D").px(11,7,"u").row(19,0,15,"D").rect(0,20,16,2,"B").rect(7,20,2,2,"g").rect(0,22,16,2,"p"),ki=new U(16,24,"t").row(5,0,15,"D").col(8,6,19,"D").row(19,0,15,"D").rect(0,20,16,2,"B").rect(0,22,16,2,"p"),vi=new U(8,24,"t").col(4,0,19,"D").row(19,0,7,"D").rect(0,20,8,2,"B").rect(0,22,8,2,"p"),Ai=new U(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),Ei=new U(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),Si=new U(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),Ti=new U(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),Mi=new U(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),Li=new U(8,24,"p").col(3,0,21,"P"),Ci=new U(10,9,"z").row(0,0,9,"Z").row(2,3,6,"l").row(4,3,6,"l").row(6,3,6,"l").col(2,1,6,"Z").col(7,1,6,"Z").rect(0,7,10,2,"Z"),Pi=new U(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function Xe(e){let t=new U(16,10,"."),r=(a,n,s)=>{if(e.brows==="flat")t.row(1,a,a+2,"k");else if(e.brows==="high")t.row(0,a,a+2,"k");else {let l=e.brows==="down"?1:0,i=1-l;t.px(n,l,"k").px(a+1,e.brows==="down"?0:1,"k"),t.px(s,i,"k");}};r(3,5,3),r(10,10,12);let o=a=>{if(e.eyes===0){t.row(3,a,a+2,"k");return}let n=e.eyes===3||e.eyes===2?2:3;for(let s=n;s<n+e.eyes;s++)t.px(a,s,"w").px(a+1,s,"b").px(a+2,s,"w");};switch(o(3),o(10),e.mouth){case "line":t.row(7,6,9,"m");break;case "smile":t.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":t.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":t.rect(6,7,4,2,"o");break;case "small":t.rect(7,7,2,2,"o");break;case "wide":t.row(7,5,10,"m").rect(6,8,4,1,"o");break}return t}var on={f_neutral:Xe({brows:"flat",eyes:2,mouth:"line"}),f_blink:Xe({brows:"flat",eyes:0,mouth:"line"}),f_happy:Xe({brows:"high",eyes:2,mouth:"smile"}),f_sad:Xe({brows:"up",eyes:2,mouth:"frown"}),f_angry:Xe({brows:"down",eyes:1,mouth:"wide"}),f_surprised:Xe({brows:"high",eyes:3,mouth:"small"}),f_scared:Xe({brows:"up",eyes:3,mouth:"open"}),f_tired:Xe({brows:"flat",eyes:1,mouth:"line"}),f_hurt:Xe({brows:"down",eyes:0,mouth:"open"}),f_talk:Xe({brows:"flat",eyes:2,mouth:"open"})},zi=new U(16,24,"t").row(0,5,10,"s").row(1,6,9,"s").px(5,1,"T").px(10,1,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),Ii=new U(16,24,"t").row(0,5,10,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),Oi=new U(8,24,"t").row(7,0,7,"D").row(10,0,7,"D").rect(0,18,8,2,"T").rect(0,20,8,4,"p").row(20,0,7,"P"),_i=new U(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),no=(e,t)=>e.row(t-1,0,e.w-1,"D").where((r,o)=>o>=t&&o<=t+3&&(r+o)%2===0,"T").row(t+4,0,e.w-1,"D"),Vi=no(new U(16,24,"t"),6).row(0,6,9,"s").row(0,4,5,"T").row(0,10,11,"T").row(1,4,11,"T").where((e,t)=>t>=18&&t<=19&&e%2===0,"D").where((e,t)=>t>=18&&t<=19&&e%2===1,"T").rect(0,20,16,4,"p"),Fi=no(new U(16,24,"t"),6).row(0,4,11,"T").where((e,t)=>t>=18&&t<=19,"D").rect(0,20,16,4,"p"),Bi=no(new U(8,24,"t"),6).where((e,t)=>t>=18&&t<=19,"D").rect(0,20,8,4,"p"),Di=no(new U(8,22,"t"),9).where((e,t)=>t>=19&&e%2===0,"D"),an=e=>new U(8,24,"s").rect(0,0,8,12,"p").col(e,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),Ni=an(4),Hi=an(3),ji=new U(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),Gi=new U(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),qi=new U(17,6,"a").rect(0,4,17,2,"A"),Ui=new U(22,22,"a").where((e,t)=>(e*3+t*5)%11===0,"A"),Ki=new U(17,20,"h").where((e,t)=>(e*5+t)%4===0,"H").where((e,t)=>t>10&&(e*3+t*2)%7===0,"k"),X=e=>e.tex(),nn=["shirt","tee","sweater"],sn=["pants","shorts"],ln=["boots","sneakers"],A1=["short","long","curly","none"],Ot=(e,t={})=>({front:e,back:e,left:e,right:e,...t});function jo(e={}){let t=e.top??"shirt",r=e.bottom??"pants",o=e.shoes??"boots",a=e.hair??"short",n=Ho(fi,e.colors??{});n={...n,a:e.colors?.hat??"#d9c9a3"},n.A=at(n.a,.72);let s={head_front:X(bi),head_left:X(rn),head_right:X(yi),head_back:X(gi),hair_top:X(xi),hair_band:X(wi),arm_skin:X(Ei),...Object.fromEntries(Object.entries(on).map(([b,u])=>[b,X(u)]))},l=[{name:"head",bone:"head",size:[8,8,8],pos:[0,28,0],color:"s",faces:{front:"head_front",left:"head_left",right:"head_right",back:"head_back",top:"hair_top"}},{name:"nose",bone:"head",size:[1,1.5,.8],pos:[0,26.9,-4.4],color:"S",faces:{front:"s"}}];if(a!=="none"){if(e.hat||l.push({name:"hair",bone:"head",size:a==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,a==="curly"?32.5:32.2,.15],color:"h",faces:Ot("hair_band",{top:"hair_top"})}),a==="curly"&&!e.hat)for(let[b,u]of [[-2,-1.5],[2,.5],[-0.5,2.5]])l.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[b,33.9,u],color:"h",faces:Ot("hair_band",{top:"hair_top"})});a==="long"?(s.hair_long=X(Ki),l.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:Ot("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:Ot("hair_long",{top:"hair_top"}),mirror:true})):l.push({name:"hairBack",bone:"head",size:[8.6,5,.8],pos:[0,29.6,4.25],color:"h",faces:{back:"head_back",left:"hair_band",right:"hair_band"}});}e.hat&&(s.hat_crown=X(qi),s.hat_brim=X(Ui),l.push({name:"hatBrim",bone:"head",size:[11,.8,11],pos:[0,32.4,0],color:"a",faces:{top:"hat_brim",bottom:"hat_brim"}},{name:"hatCrown",bone:"head",size:[8.4,3,8.4],pos:[0,34.3,0],color:"a",faces:Ot("hat_crown")}));let i={shirt:[Ri,ki,vi],tee:[zi,Ii,Oi],sweater:[Vi,Fi,Bi]},[c,p,h]=i[t];s.top_front=X(c),s.top_back=X(p),s.top_side=X(h),l.push({name:"torso",bone:"body",size:[8,12,4],pos:[0,18,0],color:"t",faces:{front:"top_front",back:"top_back",left:"top_side",right:"top_side",bottom:"p"}}),t==="shirt"&&(s.belt=X(Ai),l.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),l.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:Ot("arm_skin",{top:"t",bottom:"S"}),mirror:true});let m=t==="sweater"?11:t==="tee"?4.5:6.5;s.sleeve=X(t==="sweater"?Di:t==="tee"?_i:Si),l.push({name:"sleeve",bone:"armL",size:[3.6,m,3.6],pos:[-5.5,24-m/2,0],color:"t",faces:Ot("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(s.leg_front=X(Ni),s.leg_side=X(Hi)):(s.leg_front=X(Ti),s.leg_back=X(Mi),s.leg_side=X(Li)),l.push({name:"leg",bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p",faces:{front:"leg_front",back:r==="shorts"?"leg_front":"leg_back",left:"leg_side",right:"leg_side"},mirror:true}),o==="boots"?(s.shoe_front=X(Ci),s.shoe_side=X(Pi)):(s.shoe_front=X(ji),s.shoe_side=X(Gi));let d=o==="boots"?4.5:2.5;return l.push({name:"shoe",bone:"legL",size:[4.6,d,5.2],pos:[-2,d/2,-0.3],color:"z",faces:{front:"shoe_front",back:"shoe_side",left:"shoe_side",right:"shoe_side",bottom:"Z"},mirror:true}),{version:1,name:e.name??ee({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:e.description??ee({en:"A traveler in a shirt with pockets, trousers and laced boots",ru:"\u041F\u0443\u0442\u043D\u0438\u043A \u0432 \u0440\u0443\u0431\u0430\u0448\u043A\u0435 \u0441 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u043C\u0438, \u0431\u0440\u044E\u043A\u0430\u0445 \u0438 \u0448\u043D\u0443\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0431\u043E\u0442\u0438\u043D\u043A\u0430\u0445"}),rig:"humanoid",palette:n,textures:s,parts:l,face:{bone:"head",rect:[0,3,8,5],expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}},style:{walk:"normal",idle:"calm",energy:.5},finish:{noise:.5,outline:.4,shade:.25,density:2},tags:e.tags??["player"]}}function Ar(e,t){return {textures:Object.fromEntries(Object.entries(on).map(([r,o])=>[r,X(o)])),face:{bone:e,rect:t,expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}}}}var Go=jo(),No=null;function _t(){if(!No){let e=Ye(Go);if(!e.ok)throw new Error(e.error);No=e.spec;}return No}function cn(e){let t=document.createElement("canvas");t.width=256,t.height=48;let r=t.getContext("2d");r&&(r.fillStyle="rgba(0,0,0,0.45)",r.fillRect(0,0,256,48),r.font="bold 28px sans-serif",r.fillStyle="#fff",r.textAlign="center",r.textBaseline="middle",r.fillText(e.slice(0,18),128,25));let o=new D__namespace.CanvasTexture(t),a=new D__namespace.Sprite(new D__namespace.SpriteMaterial({map:o,depthTest:false,transparent:true}));return a.scale.set(1.6,.3,1),a.renderOrder=10,a}function qo(e){e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();}var I={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},T1=Object.keys(I),nr=[0,0,0,0,0,0,1,1,1];function ae(e,t){let r=e.get(t);return r||(r=Float64Array.from(nr),e.set(t,r)),r}function de(e,t,r,o){let a=ae(e,t),n=I[r];n>=6?a[n]=a[n]*o:a[n]=a[n]+o;}function y(e,t,r,o){ae(e,t)[I[r]]=o;}function ft(e){for(let t of e.values())t.set(nr);}function pn(e,t,r,o){let a=new Set([...t.keys(),...r.keys()]);for(let n of a){let s=t.get(n)??nr,l=r.get(n)??nr,i=ae(e,n);for(let c=0;c<9;c++)i[c]=s[c]+(l[c]-s[c])*o;}}function Be(e,t){ft(e);for(let[r,o]of t)ae(e,r).set(o);}var M1=["none","block","tool","sword","bow","shield","food","staff","item","pistol","rifle"];function so(){return {speed:0,vy:0,onGround:true,inWater:false,flying:false,gliding:false,sneaking:false,sprinting:false,riding:false,sitting:false,sleeping:false,dead:false,lookYaw:0,lookPitch:0,yawRate:0,held:"none",aiming:false,use:null,talk:false}}var L1=["swing","hurt","place","land","jump","throw","shoot","punch"];var yt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],ue=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Ft=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],bt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Vt=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],He=e=>Math.hypot(e[0],e[1],e[2]),nt=(e,t)=>He(ue(e,t)),Er=(e,t,r)=>[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]+(t[2]-e[2])*r];function sr(e){let t=He(e);return t>1e-12?[e[0]/t,e[1]/t,e[2]/t]:[0,0,0]}var xe=(e,t,r)=>Math.max(t,Math.min(r,e)),Uo=[1,0,0,0,1,0,0,0,1];function De(e,t){return [e[0]*t[0]+e[1]*t[3]+e[2]*t[6],e[0]*t[1]+e[1]*t[4]+e[2]*t[7],e[0]*t[2]+e[1]*t[5]+e[2]*t[8],e[3]*t[0]+e[4]*t[3]+e[5]*t[6],e[3]*t[1]+e[4]*t[4]+e[5]*t[7],e[3]*t[2]+e[4]*t[5]+e[5]*t[8],e[6]*t[0]+e[7]*t[3]+e[8]*t[6],e[6]*t[1]+e[7]*t[4]+e[8]*t[7],e[6]*t[2]+e[7]*t[5]+e[8]*t[8]]}function ne(e,t){return [e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}var gt=e=>[e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]];function Qe(e,t,r){let o=Math.cos(e),a=Math.sin(e),n=Math.cos(t),s=Math.sin(t),l=Math.cos(r),i=Math.sin(r),c=o*l,p=o*i,h=a*l,m=a*i;return [n*l,-n*i,s,p+h*s,c-m*s,-a*n,m-c*s,h+p*s,o*n]}function Bt(e){let t=Math.asin(xe(e[2],-1,1));return Math.abs(e[2])<.9999999?[Math.atan2(-e[5],e[8]),t,Math.atan2(-e[1],e[0])]:[Math.atan2(e[7],e[4]),t,0]}function io(e,t){let[r,o,a]=e,n=Math.cos(t),s=Math.sin(t),l=1-n;return [l*r*r+n,l*r*o-s*a,l*r*a+s*o,l*r*o+s*a,l*o*o+n,l*o*a-s*r,l*r*a-s*o,l*o*a+s*r,l*a*a+n]}function Ko(e,t){let r=sr(e),o=sr(t),a=xe(bt(r,o),-1,1),n=Vt(r,o),s=He(n);if(s<1e-9){if(a>0)return [...Uo];let l=Math.abs(r[0])<.9?Vt(r,[1,0,0]):Vt(r,[0,1,0]);return io(sr(l),Math.PI)}return io(Ft(n,1/s),Math.atan2(s,a))}function mn(e,t,r){return Math.atan2(bt(Vt(e,t),r),bt(e,t))}function Sr(e){let t=Math.PI*2;return e=(e%t+t)%t,e>Math.PI?e-t:e}function lo(e,t,r,o,a){if(a<=0)return e;if(o<=1e-6)return t.v=0,r;let n=2/o,s=n*a,l=1/(1+s+.48*s*s+.235*s*s*s),i=e-r,c=(t.v+n*i)*a;return t.v=(t.v-n*c)*l,r+(i+c)*l}var hn=Float64Array.from([0,0,0,0,0,0,1,1,1]);function We(e,t){let r=new Map(e.map(i=>[i.name,i])),o=new Map,a=t.get("root")??hn,n=Qe(a[I.rx],a[I.ry],a[I.rz]),s={pos:[a[I.px],a[I.py],a[I.pz]],lin:n,rot:n},l=i=>{let c=o.get(i.name);if(c)return c;let p=i.parent?r.get(i.parent):void 0,h=p?l(p):s,m=p?p.pivot:[0,0,0],d=t.get(i.role)??hn,b=[i.pivot[0]-m[0]+d[I.px],i.pivot[1]-m[1]+d[I.py],i.pivot[2]-m[2]+d[I.pz]],u=Qe(d[I.rx],d[I.ry],d[I.rz]),R=[d[I.sx],0,0,0,d[I.sy],0,0,0,d[I.sz]],w={pos:yt(h.pos,ne(h.lin,b)),lin:De(h.lin,De(u,R)),rot:De(h.rot,u),parentRot:h.rot};return o.set(i.name,w),w};for(let i of e)l(i);return o}function Dt(e,t){return yt(e.pos,ne(e.lin,t))}var Yo=.04;function dn(e,t,r,o){let[a,n,s]=Bt(De(gt(r.parentRot),o)),l=ae(e,t);l[I.rx]=a,l[I.ry]=n,l[I.rz]=s;}function Yi(e,t){let r=Yo*t,o=t-r;return e<=o||r<=0?e:o+r*(1-Math.exp(-(e-o)/r))}function Wo(e,t,r){let o=t.upper.node.pos,a=t.lower.node.pos,n=t.end,s=ue(o,a),l=ue(n,a),i=He(s),c=He(l);if(i<1e-9||c<1e-9)return n;let p=sr(ne(t.lower.node.parentRot,[1,0,0])),h=Ft(p,bt(s,p)),m=Ft(p,bt(l,p)),d=ue(s,h),b=ue(l,m),u=He(d),R=He(b),w=nt(o,r),A=nt(o,n),k=w<=A?w:Math.max(A,Yi(w,Math.hypot(He(ue(m,h)),u+R))),x=e.get(t.lower.role)?.[I.rx]??0,f=0;if(u>1e-9&&R>1e-9){let C=mn(d,b,p),z=(i*i+c*c-k*k)/2-bt(h,m),O=xe(z/(u*R),-1,1),M=Math.acos(O),[V,q]=t.bend,Y=v=>{let _=v-x,F=yt(m,yt(Ft(b,Math.cos(_)),Ft(Vt(p,b),Math.sin(_))));return Math.abs(He(ue(F,s))-k)},pe=[Sr(M-C),Sr(-M-C)].flatMap(v=>{let _=x+v;return [_,xe(_,V,q)]}),me=xe(x,V,q),ie=Y(me);for(let v of pe){if(v<V-1e-9||v>q+1e-9)continue;let _=Y(v);(_<ie-1e-6||Math.abs(_-ie)<=1e-6&&Math.abs(v-x)<Math.abs(me-x))&&(me=v,ie=_);}f=me-x;}ae(e,t.lower.role)[I.rx]=x+f;let S=yt(a,ne(io(p,f),l)),T=Ko(ue(S,o),ue(r,o));return dn(e,t.upper.role,t.upper.node,De(T,t.upper.node.rot)),yt(o,ne(T,ue(S,o)))}function un(e,t,r,o,a){let n=r.pos,s=sr(ne(r.parentRot,[1,0,0])),l=ue(o,n),i=Ft(s,bt(l,s)),c=ue(l,i),p=Vt(s,c),h=i[1],m=c[1],d=p[1],b=Math.hypot(m,d);if(b<1e-9)return;let u=Math.atan2(d,m),R=xe((a-n[1]-h)/b,-1,1),w=Math.acos(R),A=Sr(u+w),k=Sr(u-w),x=Math.abs(A)<=Math.abs(k)?A:k;ae(e,t)[I.rx]=(e.get(t)?.[I.rx]??0)+x;}function fn(e,t,r,o,a){let n=Ko(ue(o,r.pos),ue(a,r.pos));dn(e,t,r,De(n,r.rot));}var Wi=.25,bn=.07,$i=.22,Ji=.12,Xi=.28,Qi=.6,co=.45,yn=.03,Zi=.2,e0=.2,t0=.12,Tr=(e,t,r)=>xe(e+(t?r:-r)/Wi,0,1),xt=e=>e*e*(3-2*e),gn=(e,t,r)=>{e[t]=e[t]+r;},Mr=class{ik;bones;feet=[];hands={};out=new Map;thigh;plant=0;wLook=0;lookAt=null;lookV=[{v:0},{v:0},{v:0}];wSeat=0;lastSeat=null;pelvis=0;pelvisV={v:0};wHand={handR:0,handL:0};lastHand={handR:null,handL:null};wLock=0;constructor(t){this.ik=Ae[t.rig].ik??{},this.bones=t.bones.map(l=>({name:l.name,role:l.role,parent:l.parent,pivot:l.pivot}));let r=We(this.bones,new Map),o=l=>t.bones.find(i=>i.role===l),a=l=>{let i=o(l.upper),c=l.lower?o(l.lower):void 0;if(!i||l.lower&&!c)return null;let p=c??i,h=p.name,m;if(l.end==="sole"){let w=0;for(let A=1;A<p.positions.length;A+=3)w=Math.min(w,p.positions[A]);m=[0,w,0];}else {let w=t.sockets.find(A=>A.name===l.end);if(!w)return null;h=w.bone,m=w.at;}let d=r.get(i.name).pos,b=Dt(r.get(h),m),u=c?nt(d,r.get(c.name).pos)+nt(r.get(c.name).pos,b):nt(d,b),R=w=>({name:w.name,role:w.role,parent:w.parent,pivot:w.pivot});return {def:l,upper:R(i),lower:c?R(c):null,endBone:h,endAt:m,length:u}};for(let l of this.ik.feet??[]){let i=a(l);i&&this.feet.push({...i,g:0,gv:{v:0},lock:null,lockYaw:0,step:null});}for(let l of ["handR","handL"]){let i=this.ik.hands?.[l],c=i&&a(i);c&&(this.hands[l]=c);}let n=2,s=this.feet[0]&&t.bones.find(l=>l.name===this.feet[0].upper.name);if(s&&s.positions.length){let l=1/0,i=-1/0;for(let c=0;c<s.positions.length;c+=3)l=Math.min(l,s.positions[c]),i=Math.max(i,s.positions[c]);n=(i-l)/2;}this.thigh=n;}supports(t){return t==="look"?!!this.ik.look:t==="ground"||t==="seat"?this.feet.length>0:!!this.hands[t]}solve(t,r){let o=Math.max(0,Math.min(r.dt,.1)),a=!!r.ground&&this.feet.length>0;if(this.plant=a?xe(this.plant+(r.plant-this.plant)*Math.min(1,o/.12),0,1):Tr(this.plant,false,o),!a&&this.plant===0&&this.resetFeet(),this.wLook=this.ik.look?Tr(this.wLook,!!r.look,o):0,r.look){let m=this.lookAt;this.lookAt=m?[0,1,2].map(d=>lo(m[d],this.lookV[d],r.look[d],t0,o)):[...r.look];}else this.wLook===0&&(this.lookAt=null);this.wSeat=this.feet.length?Tr(this.wSeat,!!r.seat,o):0,r.seat&&(this.lastSeat=r.seat);for(let m of ["handR","handL"])this.wHand[m]=this.hands[m]?Tr(this.wHand[m],!!r[m],o):0,r[m]&&(this.lastHand[m]=r[m]);if(this.plant===0&&this.wLook===0&&this.wSeat===0&&this.wHand.handR===0&&this.wHand.handL===0)return t;let n=this.out;Be(n,t);let s=We(this.bones,n),l=m=>s.get(m),i=this.feet.map(m=>Dt(l(m.endBone),m.endAt)),c=xt(this.wSeat);if(c>0&&this.lastSeat){let m=this.feet.slice(0,2).map(w=>l(w.upper.name).pos),d=m.length===2?Er(m[0],m[1],.5):m[0],b=[d[0],d[1]-this.thigh,d[2]],u=ue(this.lastSeat,b),R=ae(n,"root");R[I.px]=R[I.px]+u[0]*c,R[I.py]=R[I.py]+u[1]*c,R[I.pz]=R[I.pz]+u[2]*c;}let p=xt(this.plant);p>0&&(s=this.ground(n,s,i,r,p,c,o));let h=xt(this.wLook);h>0&&this.lookAt&&this.ik.look&&(s=this.look(n,s,this.lookAt,h));for(let m of ["handR","handL"]){let d=this.hands[m],b=xt(this.wHand[m]),u=this.lastHand[m];if(!d||b===0||!u)continue;s=We(this.bones,n);let R=Dt(s.get(d.endBone),d.endAt),w=Er(R,u,b);d.lower?Wo(n,{upper:{role:d.upper.role,node:s.get(d.upper.name)},lower:{role:d.lower.role,node:s.get(d.lower.name)},end:R,bend:d.def.bend??[-Math.PI,Math.PI]},w):fn(n,d.upper.role,s.get(d.upper.name),R,w);}return n}reset(){this.resetFeet(),this.pelvis=0,this.pelvisV.v=0,this.lookAt=null;for(let t of this.lookV)t.v=0;}resetFeet(){for(let t of this.feet)t.g=0,t.gv.v=0,t.lock=null,t.step=null;this.wLock=0;}ground(t,r,o,a,n,s,l){let i=s===0&&a.standing&&this.feet.every(x=>x.lower);if(this.wLock=Tr(this.wLock,i,l),!i&&this.wLock===0)for(let x of this.feet)x.lock=null,x.step=null;let c=this.feet.some(x=>x.step),p=a.toWorld([0,0,0]),h=a.toWorld([0,0,-1]),m=Math.atan2(h[0]-p[0],h[2]-p[2]),d=[];for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=o[x],T=S[0],C=S[2],z=0;if(i||this.wLock>0){let O=a.toWorld(S),M=xt(this.wLock);if(!f.lock&&!f.step&&(f.lock=O,f.lockYaw=m),f.step){f.step.t=Math.min(1,f.step.t+l/$i);let V=f.step.t,q=a.toModel(Er(f.step.from,O,xt(V)));T+=(q[0]-T)*M,C+=(q[2]-C)*M,z=Math.sin(Math.PI*V)*Ji*f.length*M,V>=1&&(f.lock=O,f.lockYaw=m,f.step=null);}else if(f.lock){let V=a.toModel(f.lock),q=Math.abs(Math.atan2(Math.sin(m-f.lockYaw),Math.cos(m-f.lockYaw)));i&&!c&&(q>Qi||Math.hypot(V[0]-T,V[2]-C)>Xi*f.length)&&(f.step={from:f.lock,t:0},f.lock=null),T+=(V[0]-T)*M,C+=(V[2]-C)*M;}}d.push({x:T,z:C,arc:z});}let b=Math.max(...this.feet.map(x=>x.length));for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=a.ground?a.ground(d[x].x,0,d[x].z):0;S!==null&&S<-co*b&&(S=null),f.g=lo(f.g,f.gv,S??f.g,bn,l);}let u=this.ik.tilt,R=ae(t,"root");if(u){let x=(M,V)=>{let q=this.feet.map((Y,pe)=>M.includes(Y.upper.role)?pe:-1).filter(Y=>Y>=0);return q.length?q.reduce((Y,pe)=>Y+V(this.feet[pe],pe),0)/q.length:0},f=x(u.front,M=>M.g),S=x(u.back,M=>M.g),T=x(u.front,(M,V)=>o[V][2]),C=x(u.back,(M,V)=>o[V][2]),z=Math.max(1,Math.abs(C-T)),O=xe(Math.atan2(f-S,z),-u.max,u.max);R[I.rx]=R[I.rx]+O*n*(1-s),R[I.py]=R[I.py]+(f+S)/2*n*(1-s);}else {let x=this.feet.map(z=>z.g),f=Math.min(...x),S=x.reduce((z,O)=>z+O,0)/x.length,T=this.feet.every(z=>z.lower)?1-xt(this.wLock):0,C=xe(f+(S-f)*T,-co*b,co*b)*(1-s);this.pelvis=lo(this.pelvis,this.pelvisV,C,bn,l),R[I.py]=R[I.py]+this.pelvis*n;}r=We(this.bones,t);let w=x=>this.feet.map((f,S)=>{let T=Math.max(0,o[S][1]),C=T+f.g+d[S].arc,z=Dt(x.get(f.endBone),f.endAt)[1],O=Math.max(z,f.g),M=1-xt(xe((T-yn*f.length)/((Zi-yn)*f.length),0,1)),V=O+(C-O)*M,q=Math.max(f.g,z-e0*f.length);return [d[S].x,V+(q-V)*s,d[S].z]}),A=w(r),k=0;this.feet.forEach((x,f)=>{if(!x.lower)return;let S=r.get(x.upper.name).pos,T=A[f],C=Math.max(nt(S,Dt(r.get(x.endBone),x.endAt)),x.length*(1-Yo)),z=Math.hypot(T[0]-S[0],T[2]-S[2]);z>=C||(k=Math.max(k,S[1]-T[1]-Math.sqrt(C*C-z*z)));}),k>0&&(gn(R,I.py,-Math.min(k,co*b)*n*(1-s)),r=We(this.bones,t),A=w(r));for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=Dt(r.get(f.endBone),f.endAt),T=Er(S,A[x],n);nt(T,S)<1e-6||(f.lower?Wo(t,{upper:{role:f.upper.role,node:r.get(f.upper.name)},lower:{role:f.lower.role,node:r.get(f.lower.name)},end:S,bend:f.def.bend??[-Math.PI,Math.PI]},T):un(t,f.upper.role,r.get(f.upper.name),S,T[1]));}return We(this.bones,t)}look(t,r,o,a){let n=this.ik.look,s=this.bones.find(h=>h.role===n.head);if(!s)return r;let l=h=>{let m=ne(gt(h.parentRot),ue(o,h.pos));return [Math.atan2(-m[0],-m[2]),Math.atan2(m[1],Math.hypot(m[0],m[2]))]};if(He(ue(o,r.get(s.name).pos))<1e-6)return r;let[i,c]=l(r.get(s.name));if(n.body&&n.bodyYaw>0&&this.bones.some(h=>h.role===n.body)){let h=xe(Math.abs(i)-n.headYaw,0,n.bodyYaw)*Math.sign(i);h!==0&&(gn(ae(t,n.body),I.ry,h*a),r=We(this.bones,t),[i,c]=l(r.get(s.name)));}let p=ae(t,n.head);return p[I.ry]=p[I.ry]+(xe(i,-n.headYaw,n.headYaw)-p[I.ry])*a,p[I.rx]=p[I.rx]+(xe(c,-n.headPitch,n.headPitch)-p[I.rx])*a,We(this.bones,t)}};var Ze=(e,t)=>[e[3]*t[0]+e[0]*t[3]+e[1]*t[2]-e[2]*t[1],e[3]*t[1]-e[0]*t[2]+e[1]*t[3]+e[2]*t[0],e[3]*t[2]+e[0]*t[1]-e[1]*t[0]+e[2]*t[3],e[3]*t[3]-e[0]*t[0]-e[1]*t[1]-e[2]*t[2]],it=e=>[-e[0],-e[1],-e[2],e[3]];function Xo(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]);return t>0?[e[0]/t,e[1]/t,e[2]/t,e[3]/t]:[0,0,0,1]}function se(e,t){let[r,o,a,n]=e,s=2*(o*t[2]-a*t[1]),l=2*(a*t[0]-r*t[2]),i=2*(r*t[1]-o*t[0]);return [t[0]+n*s+(o*i-a*l),t[1]+n*l+(a*s-r*i),t[2]+n*i+(r*l-o*s)]}var $o=(e,t)=>se(it(e),t);function Qo(e){let[t,r,o,a]=e;return [1-2*(r*r+o*o),2*(t*r-o*a),2*(t*o+r*a),2*(t*r+o*a),1-2*(t*t+o*o),2*(r*o-t*a),2*(t*o-r*a),2*(r*o+t*a),1-2*(t*t+r*r)]}function ho(e){let t=e[0]+e[4]+e[8],r;if(t>0){let o=Math.sqrt(t+1)*2;r=[(e[7]-e[5])/o,(e[2]-e[6])/o,(e[3]-e[1])/o,.25*o];}else if(e[0]>e[4]&&e[0]>e[8]){let o=Math.sqrt(1+e[0]-e[4]-e[8])*2;r=[.25*o,(e[1]+e[3])/o,(e[2]+e[6])/o,(e[7]-e[5])/o];}else if(e[4]>e[8]){let o=Math.sqrt(1+e[4]-e[0]-e[8])*2;r=[(e[1]+e[3])/o,.25*o,(e[5]+e[7])/o,(e[2]-e[6])/o];}else {let o=Math.sqrt(1+e[8]-e[0]-e[4])*2;r=[(e[2]+e[6])/o,(e[5]+e[7])/o,.25*o,(e[3]-e[1])/o];}return Xo(r)}function vn(e,t,r){let o=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],a=o<0?[-t[0],-t[1],-t[2],-t[3]]:t;if(o=Math.abs(o),o>.9995)return Xo([e[0]+(a[0]-e[0])*r,e[1]+(a[1]-e[1])*r,e[2]+(a[2]-e[2])*r,e[3]+(a[3]-e[3])*r]);let n=Math.acos(o),s=Math.sin((1-r)*n)/Math.sin(n),l=Math.sin(r*n)/Math.sin(n);return [e[0]*s+a[0]*l,e[1]*s+a[1]*l,e[2]*s+a[2]*l,e[3]*s+a[3]*l]}var Oe=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Ee=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],re=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],we=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],st=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Nt=e=>Math.sqrt(we(e,e));function xn(e){let t=Nt(e);return t>1e-12?[e[0]/t,e[1]/t,e[2]/t]:[0,0,0]}function Zo(e,t,r){let o=8*e[0]*e[1]*e[2],a=4*e[0]*e[0],n=4*e[1]*e[1],s=4*e[2]*e[2];return {x:t,q:r,v:[0,0,0],w:[0,0,0],px:t,pq:r,im:1/o,ii:[12/(o*(n+s)),12/(o*(a+s)),12/(o*(a+n))],half:e}}function wt(e,t){let r=$o(e.q,t);return se(e.q,[r[0]*e.ii[0],r[1]*e.ii[1],r[2]*e.ii[2]])}function ir(e,t,r){let[o,a,n]=t,s=e.q,l=Ze([o*.5*r,a*.5*r,n*.5*r,0],s);e.q=Xo([s[0]+l[0],s[1]+l[1],s[2]+l[2],s[3]+l[3]]);}function po(e,t,r,o,a){let n=Nt(a);if(n<1e-9)return 0;let s=re(a,1/n),l=st(t,s),i=e.im+we(l,wt(e,l));if(r){let p=st(o,s);i+=r.im+we(p,wt(r,p));}if(i<=0)return 0;let c=re(s,-n/i);return e.x=Oe(e.x,re(c,e.im)),ir(e,wt(e,st(t,c)),1),r&&(r.x=Ee(r.x,re(c,r.im)),ir(r,wt(r,st(o,c)),-1)),n}function Lr(e,t,r){let o=Nt(r);if(o<1e-9)return;let a=re(r,1/o),n=we(a,wt(e,a));if(t&&(n+=we(a,wt(t,a))),n<=0)return;let s=re(r,1/n);ir(e,wt(e,s),1),t&&ir(t,wt(t,s),-1);}var Jo=[];for(let e of [-1,1])for(let t of [-1,1])for(let r of [-1,1])Jo.push([e,t,r]);var An=[];for(let e of [-1,0,1])for(let t of [-1,0,1])for(let r of [-1,0,1])(e||t||r)&&An.push([e,t,r]);var En=[];for(let e of Jo)for(let t of Jo)e<t&&(e[0]!==t[0]?1:0)+(e[1]!==t[1]?1:0)+(e[2]!==t[2]?1:0)==1&&En.push([e,t]);var wn=2,Rn=30,Sn={gravity:9.8,friction:.7,linDamp:.1,angDamp:.4,tone:8};function Tn(e,t,r,o,a,n){for(let c of e)c.px=c.x,c.pq=c.q,c.v=[c.v[0],c.v[1]-n.gravity*a,c.v[2]],c.x=Oe(c.x,re(c.v,a)),ir(c,c.w,a);let s=Math.min(.5,n.tone*a);for(let c of t)r0(e,c,s);for(let c=0;c<2;c++)for(let p of t)mo(e,p);for(let c of e)kn(c,r,o,n.friction,a);for(let c of t)mo(e,c);for(let c of e)kn(c,r,o,n.friction,a);for(let c of t)mo(e,c);let l=Math.max(0,1-n.linDamp*a),i=Math.max(0,1-n.angDamp*a);for(let c of e){c.v=re(Ee(c.x,c.px),l/a);let p=Nt(c.v);p>Rn&&(c.v=re(c.v,Rn/p));let h=Ze(c.q,it(c.pq));h[3]<0&&(h=[-h[0],-h[1],-h[2],-h[3]]),c.w=[h[0]*2*i/a,h[1]*2*i/a,h[2]*2*i/a];}}function Mn(e,t,r,o,a){let n=o*o*a,s=Math.max(0,1-2*o*a);e.forEach((l,i)=>{let c=r[i];if(l.px=l.x,l.pq=l.q,l.im===0){l.x=c.x,l.q=c.q;return}l.v=Oe(re(l.v,s),re(Ee(c.x,l.x),n));let p=Ze(c.q,it(l.q));p[3]<0&&(p=[-p[0],-p[1],-p[2],-p[3]]),l.w=[l.w[0]*s+2*p[0]*n,l.w[1]*s+2*p[1]*n,l.w[2]*s+2*p[2]*n],l.x=Oe(l.x,re(l.v,a)),ir(l,l.w,a);});for(let l=0;l<3;l++)for(let i of t)mo(e,i);for(let l of e){l.v=re(Ee(l.x,l.px),1/a);let i=Ze(l.q,it(l.pq));i[3]<0&&(i=[-i[0],-i[1],-i[2],-i[3]]),l.w=[i[0]*2/a,i[1]*2/a,i[2]*2/a];}}function r0(e,t,r){let o=e[t.a],a=e[t.b],n=Ze(o.q,Ze(it(o.pq),a.pq)),s=Ze(n,it(a.q));s[3]<0&&(s=[-s[0],-s[1],-s[2],-s[3]]),Lr(o,a,[-2*s[0]*r,-2*s[1]*r,-2*s[2]*r]);}function mo(e,t){let r=e[t.a],o=e[t.b],a=se(r.q,t.ra),n=se(o.q,t.rb);po(r,a,o,n,Ee(Oe(r.x,a),Oe(o.x,n)));let s=t.limit;if(s.kind==="hinge"){let u=se(r.q,s.hinge),R=se(o.q,s.hinge);Lr(r,o,st(u,R));let w=se(r.q,s.hinge),A=se(o.q,s.axis),k=xn(Ee(A,re(w,we(w,A)))),x=se(r.q,s.from),f=se(r.q,s.to);if(we(st(x,k),w)<0||we(st(k,f),w)<0){let S=we(k,x)>we(k,f)?x:f;Lr(r,o,st(S,k));}return}let l=se(r.q,s.center),i=se(o.q,s.axis),c=we(l,i);if(c<s.cosSwing){let u=xn(Ee(i,re(l,c))),R=u[0]===0&&u[1]===0&&u[2]===0?l:Oe(re(l,s.cosSwing),re(u,s.sinSwing));Lr(r,o,st(R,i));}let p=Ze(it(r.q),o.q);p[3]<0&&(p=[-p[0],-p[1],-p[2],-p[3]]);let h=p[0]*s.axis[0]+p[1]*s.axis[1]+p[2]*s.axis[2],m=Math.sqrt(h*h+p[3]*p[3]);if(m<1e-9)return;let d=p[3]/m,b=Math.abs(h)/m;if(d<s.cosHalfTwist){let u=2*(b*s.cosHalfTwist-d*s.sinHalfTwist),R=se(o.q,s.axis);Lr(r,o,re(R,(h>0?1:-1)*u));}}function kn(e,t,r,o,a){for(let n of An){let s=[n[0]*e.half[0],n[1]*e.half[1],n[2]*e.half[2]],l=se(e.q,s),i=Oe(e.x,l),c=null,p=0;if(t!==null&&i[1]<t&&(c=[0,1,0],p=t-i[1]),r.length){let R=Oe(e.px,se(e.pq,s));for(let w of r){if(i[0]<=w.min[0]||i[0]>=w.max[0]||i[1]<=w.min[1]||i[1]>=w.max[1]||i[2]<=w.min[2]||i[2]>=w.max[2])continue;let A=[0,1,0],k=w.max[1]-i[1];if(R[1]<w.max[1]-1e-4){let x=[[[1,0,0],w.max[0]-i[0]],[[-1,0,0],i[0]-w.min[0]],[[0,0,1],w.max[2]-i[2]],[[0,0,-1],i[2]-w.min[2]]];(t===null||w.min[1]>t+.05)&&x.push([[0,-1,0],i[1]-w.min[1]]);for(let[f,S]of x)S<k&&(A=f,k=S);}k>p&&(c=A,p=k);}}if(!c)continue;let h=Oe(e.px,se(e.pq,s));if(p=Math.max(0,Math.min(p,we(Ee(h,i),c)+wn*a)),p<=0)continue;po(e,l,null,[0,0,0],re(c,-p));let m=se(e.q,s),d=Ee(Oe(e.x,m),h),b=Ee(d,re(c,we(d,c))),u=Nt(b);u>1e-9&&po(e,m,null,[0,0,0],re(b,Math.min(1,o*p/u)));}for(let n of r)for(let[s,l]of En){let i=T=>[T[0]<0?n.min[0]:n.max[0],T[1]<0?n.min[1]:n.max[1],T[2]<0?n.min[2]:n.max[2]],c=$o(e.q,Ee(i(s),e.x)),p=$o(e.q,Ee(i(l),e.x)),h=Ee(p,c),m=we(h,h),d=m>0?Math.max(0,Math.min(1,-we(c,h)/m)):0,b=Oe(c,re(h,d)),u=e.half[0]-Math.abs(b[0]),R=e.half[1]-Math.abs(b[1]),w=e.half[2]-Math.abs(b[2]);if(u<=0||R<=0||w<=0)continue;let A=u<R?u<w?0:2:R<w?1:2,k=[0,0,0];k[A]=b[A]>=0?1:-1;let x=A===0?u:A===1?R:w,f=Oe(e.x,se(e.q,b)),S=re(se(e.q,k),-1);x=Math.min(x,we(Ee(Oe(e.px,se(e.pq,b)),f),S)+wn*a),!(x<=0)&&po(e,Ee(f,e.x),null,[0,0,0],re(se(e.q,k),x));}}function Ln(e){let t=Math.max(e.half[0],e.half[1],e.half[2]);return Nt(e.v)+Nt(e.w)*t}var Cn=Math.PI,ea={"root.rx":[[0,Cn/2],[.3,.6],[.6,0],[1,0]],"root.py":[[0,2.3],[.3,-6],[.6,-6],[1,0]],"legL.rx":[[0,0],[.3,1.8],[.6,1.5],[1,0]],"legR.rx":[[0,0],[.3,.2],[.6,-0.1],[1,0]],"shinL.rx":[[0,0],[.3,-2],[.6,-1.5],[1,0]],"shinR.rx":[[0,0],[.3,-1.6],[.6,-1.4],[1,0]],"armL.rx":[[0,0],[.3,-0.6],[.6,.4],[1,0]],"armR.rx":[[0,0],[.3,-0.6],[.6,.2],[1,0]]},Pn={"root.rx":[[0,-Cn/2],[.3,-1.1],[.6,0],[1,0]],"root.py":[[0,2.3],[.3,4.5],[.6,-6],[1,0]],"armL.rx":[[0,1.6],[.3,1.5],[.6,.4],[1,0]],"armR.rx":[[0,1.6],[.3,1.5],[.6,.3],[1,0]],"foreArmL.rx":[[0,1.2],[.3,.1],[.6,.3],[1,0]],"foreArmR.rx":[[0,1.2],[.3,.1],[.6,.3],[1,0]],"legL.rx":[[0,0],[.3,.3],[.6,1.5],[1,0]],"legR.rx":[[0,0],[.3,.2],[.6,-0.1],[1,0]],"shinL.rx":[[0,0],[.3,-0.5],[.6,-1.5],[1,0]],"shinR.rx":[[0,0],[.3,-0.6],[.6,-1.4],[1,0]],"head.rx":[[0,.6],[.3,.3],[.6,0],[1,0]]};function zn(e,t){if(t<=e[0][0])return e[0][1];for(let r=1;r<e.length;r++){let[o,a]=e[r];if(t<=o){let[n,s]=e[r-1],l=(t-n)/Math.max(1e-9,o-n);return s+(a-s)*l*l*(3-2*l)}}return e[e.length-1][1]}var lt=1/240,In=48,o0=.08,a0=.25,n0=6,s0=.6,uo=.35,On=1.8,i0=.3,l0=11,c0=.2,p0=.65,m0=.25,h0=9,d0=14;function _n(e,t){let r=Math.hypot(e[0],e[1],e[2]);return r>t?[e[0]*t/r,e[1]*t/r,e[2]*t/r]:e}var u0=.6,Vn=20,Fn=(e,t)=>{let r=ne(e.rot,[t[0]*e.scale,t[1]*e.scale,t[2]*e.scale]);return [r[0]+e.origin[0],r[1]+e.origin[1],r[2]+e.origin[2]]},Bn=(e,t)=>{let r=ne(gt(e.rot),[t[0]-e.origin[0],t[1]-e.origin[1],t[2]-e.origin[2]]);return [r[0]/e.scale,r[1]/e.scale,r[2]/e.scale]},Cr=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},Dn=e=>Qe(0,e,0),Pr=class{supported;defs=[];fkBones;torso;bodies=[];joints=[];st="none";acc=0;still=0;sleeping=false;out=new Map;world={floor:null};frozen=new Map;riseT=0;keys=ea;yaw0=0;off0=[0,0,0];off1=[0,0,0];driftV=null;flT=0;stand;constructor(t){let r=Ae[t.rig]?.ragdoll;this.fkBones=t.bones.map(n=>({name:n.name,role:n.role,parent:n.parent,pivot:n.pivot})),this.torso=r?.torso??"",this.stand=new Set(r?.stand??[]);let o=new Map(t.bones.map(n=>[n.name,n])),a=r?[r.torso,...r.joints.map(n=>n.bone)]:[];if(this.supported=!!r&&a.every(n=>o.has(n)),!!this.supported)for(let n of a){let s=o.get(n),l=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let p=0;p<s.positions.length;p+=3)for(let h=0;h<3;h++){let m=s.positions[p+h];m<l[h]&&(l[h]=m),m>i[h]&&(i[h]=m);}let c=!Number.isFinite(l[0]);this.defs.push({name:n,role:s.role,pivot:s.pivot,c:c?[0,0,0]:[(l[0]+i[0])/2,(l[1]+i[1])/2,(l[2]+i[2])/2],half:c?[.5,.5,.5]:[Math.max(.3,(i[0]-l[0])/2),Math.max(.3,(i[1]-l[1])/2),Math.max(.3,(i[2]-l[2])/2)],joint:r.joints.find(p=>p.bone===n)??null});}}get state(){return this.st}get resting(){return this.st==="fall"&&this.sleeping}get drift(){return this.driftV}clearDrift(){this.driftV=null;}setWorld(t){this.world=t;}start(t,r,o,a){if(!this.supported)return;let n=r.frame.scale,s=this.place(r.pose,r.frame),l=t&&o>0?this.place(t.pose,t.frame):null;this.bodies=this.defs.map((i,c)=>{let p=s[c],h=Zo([i.half[0]*n,i.half[1]*n,i.half[2]*n],p.x,p.q),m=l?.[c];if(m){h.v=_n([(p.x[0]-m.x[0])/o,(p.x[1]-m.x[1])/o,(p.x[2]-m.x[2])/o],h0);let b=Ze(p.q,it(m.q));b[3]<0&&(b=[-b[0],-b[1],-b[2],-b[3]]),h.w=_n([2*b[0]/o,2*b[1]/o,2*b[2]/o],d0);}let d=Math.max(.15,Math.min(1,p.y/Vn));return h.v=[h.v[0]+a[0]*d,h.v[1]+a[1]*d,h.v[2]+a[2]*d],h}),this.joints=this.makeJoints(n),this.world.floor===null&&!this.world.boxes&&(this.world={floor:r.frame.origin[1]}),this.st="fall",this.acc=0,this.still=0,this.sleeping=false;}place(t,r){let o=We(this.fkBones,t);return this.defs.map(a=>{let n=o.get(a.name),s=De(r.rot,n.rot),l=Fn(r,n.pos),i=ne(s,[a.c[0]*r.scale,a.c[1]*r.scale,a.c[2]*r.scale]);return {x:[l[0]+i[0],l[1]+i[1],l[2]+i[2]],q:ho(s),y:n.pos[1]+ne(n.rot,a.c)[1]}})}makeJoints(t){let r=new Map(this.defs.map((o,a)=>[o.name,a]));return this.defs.flatMap((o,a)=>{let n=o.joint;if(!n)return [];let s=r.get(n.parent);if(s===void 0)return [];let l=this.defs[s],i=[(o.pivot[0]-l.pivot[0]-l.c[0])*t,(o.pivot[1]-l.pivot[1]-l.c[1])*t,(o.pivot[2]-l.pivot[2]-l.c[2])*t],c=[-o.c[0]*t,-o.c[1]*t,-o.c[2]*t],p=[0,-1,0];if(n.kind==="hinge"){let[b,u]=n.bend;return [{a:s,b:a,ra:i,rb:c,limit:{kind:"hinge",hinge:[1,0,0],axis:p,from:[0,-Math.cos(b),-Math.sin(b)],to:[0,-Math.cos(u),-Math.sin(u)]}}]}let h=n.up?[0,1,0]:p,m=n.tilt??0,d=[0,h[1]*Math.cos(m),h[1]*Math.sin(m)];return [{a:s,b:a,ra:i,rb:c,limit:{kind:"ball",center:d,axis:h,cosSwing:Math.cos(n.swing),sinSwing:Math.sin(n.swing),cosHalfTwist:Math.cos(n.twist/2),sinHalfTwist:Math.sin(n.twist/2)}}]})}hit(t,r,o){if(!this.supported||this.st==="rise")return;if(this.st==="fall"){this.push(r);return}let a=t.frame,n=this.place(t.pose,a);this.st!=="flinch"&&(this.bodies=this.defs.map((i,c)=>{let p=Zo([i.half[0]*a.scale,i.half[1]*a.scale,i.half[2]*a.scale],n[c].x,n[c].q);return this.stand.has(i.name)&&(p.im=0,p.ii=[0,0,0]),p}),this.joints=this.makeJoints(a.scale),this.acc=0,this.st="flinch"),this.flT=0;let s=-1;if(typeof o=="string")s=this.defs.findIndex(i=>i.name===o);else if(o){let i=1/0;this.bodies.forEach((c,p)=>{let h=(c.x[0]-o[0])**2+(c.x[1]-o[1])**2+(c.x[2]-o[2])**2;c.im>0&&h<i&&(i=h,s=p);});}let l=new Map;for(let i=s,c=1;i>=0&&c>.05;c*=u0){l.set(i,c);let p=this.defs[i].joint?.parent;i=p?this.defs.findIndex(h=>h.name===p):-1;}this.bodies.forEach((i,c)=>{if(i.im===0)return;let p=s>=0?l.get(c)??0:Math.max(.15,Math.min(1,n[c].y/Vn));i.v=[i.v[0]+r[0]*p,i.v[1]+r[1]*p,i.v[2]+r[2]*p];});}push(t){if(this.st==="fall"){for(let r of this.bodies)r.v=[r.v[0]+t[0],r.v[1]+t[1],r.v[2]+t[2]];this.sleeping=false,this.still=0;}}getUp(t){if(this.st!=="fall")return;let r=this.poseNow(t);Be(this.frozen,r);let o=r.get("root"),a=Qe(o[I.rx],o[I.ry],o[I.rz]),n=this.defs.find(d=>d.name===this.torso),s=ne(a,[0,1,0]),l=ne(a,[0,0,-1])[1]>=0;this.keys=l?ea:Pn,this.yaw0=l?Math.atan2(s[0],s[2]):Math.atan2(-s[0],-s[2]);let i=d=>{let b=d.get("root"),u=Qe(b[I.rx],b[I.ry],b[I.rz]),R=ne(u,n.pivot);return [R[0]+b[I.px],R[1]+b[I.py],R[2]+b[I.pz]]},c=i(r),p=ne(Dn(this.yaw0),i(this.keyPose(0))),h=i(this.keyPose(1)),m=this.groundUnder(t,c);this.off0=[c[0]-p[0],m,c[2]-p[2]],this.off1=[c[0]-h[0],m,c[2]-h[2]],this.driftV=this.off1,this.st="rise",this.riseT=0;}stop(){this.finish(),this.driftV=null;}finish(){this.st="none",this.bodies=[],this.joints=[];}groundUnder(t,r){let o=Fn(t,r),a=this.world.floor,n=this.world.boxes?.([o[0]-.01,-1e9,o[2]-.01],[o[0]+.01,o[1]+.3,o[2]+.01])??[];for(let s of n)o[0]>=s.min[0]&&o[0]<=s.max[0]&&o[2]>=s.min[2]&&o[2]<=s.max[2]&&s.max[1]<=o[1]+.3&&(a=a===null?s.max[1]:Math.max(a,s.max[1]));return a===null?0:Bn(t,[o[0],a,o[2]])[1]}drive(t,r,o){if(this.st==="none")return null;if(this.st==="flinch")return this.flinch(t,r,o);if(this.st==="fall")return this.sleeping||this.simulate(r),this.poseNow(o);this.riseT+=r;let a=this.riseT;if(a<uo)return ta(this.out,this.frozen,this.placed(0,0),Cr(a/uo));let n=(a-uo)/On;if(n<1)return f0(this.out,this.placed(n,Cr(n)));let s=(a-uo-On)/i0;return s>=1?(this.finish(),null):ta(this.out,this.placed(1,1),t,Cr(s))}flinch(t,r,o){let a=this.place(t,o);this.acc=Math.min(this.acc+r,In*lt);let n=this.flT;this.flT+=r;let s=0;for(;this.acc>=lt-1e-9;){this.acc-=lt,s++;let c=l0*Cr((n+s*lt)/c0);Mn(this.bodies,this.joints,a,c,lt);}let l=this.poseNow(o),i=(this.flT-p0)/m0;return i<=0?l:i>=1?(this.finish(),null):ta(this.out,l,t,Cr(i))}simulate(t){this.acc=Math.min(this.acc+t,In*lt);let r=this.nearBoxes();for(;this.acc>=lt-1e-9;)this.acc-=lt,Tn(this.bodies,this.joints,this.world.floor,r,lt,Sn);let o=0;for(let a of this.bodies)o=Math.max(o,Ln(a));if(o<a0){let a=Math.max(0,1-n0*t);for(let n of this.bodies)n.v=[n.v[0]*a,n.v[1]*a,n.v[2]*a],n.w=[n.w[0]*a,n.w[1]*a,n.w[2]*a];}if(this.still=o<o0?this.still+t:0,this.still>=s0){this.sleeping=true;for(let a of this.bodies)a.v=[0,0,0],a.w=[0,0,0];}}nearBoxes(){let t=this.world.boxes;if(!t||!this.bodies.length)return [];let r=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of this.bodies){let n=Math.max(a.half[0],a.half[1],a.half[2])*1.8+.3;for(let s=0;s<3;s++)r[s]=Math.min(r[s],a.x[s]-n),o[s]=Math.max(o[s],a.x[s]+n);}return t(r,o)}poseNow(t){let r=this.out,o=new Map,a=gt(t.rot);this.defs.forEach((w,A)=>o.set(w.name,De(a,Qo(this.bodies[A].q))));let n=this.defs.findIndex(w=>w.name===this.torso),s=this.defs[n],l=this.bodies[n],i=o.get(this.torso),c=l.q,p=se(c,[s.c[0]*t.scale,s.c[1]*t.scale,s.c[2]*t.scale]),h=Bn(t,[l.x[0]-p[0],l.x[1]-p[1],l.x[2]-p[2]]),m=ne(i,s.pivot),d=ae(r,"root"),[b,u,R]=Bt(i);d.set([b,u,R,h[0]-m[0],h[1]-m[1],h[2]-m[2],1,1,1]);for(let w of this.defs){let A=ae(r,w.role);if(w.name===this.torso){A.set([0,0,0,0,0,0,1,1,1]);continue}let k=w.joint?w.joint.parent===this.torso?i:o.get(w.joint.parent):i,[x,f,S]=Bt(De(gt(k),o.get(w.name)));A.set([x,f,S,0,0,0,1,1,1]);}return r}placed(t,r){let o=this.keyPose(t),a=o.get("root"),n=this.yaw0*(1-r),s=Dn(n),l=De(s,Qe(a[I.rx],a[I.ry],a[I.rz])),i=ne(s,[a[I.px],a[I.py],a[I.pz]]),[c,p,h]=Bt(l),m=this.off0,d=this.off1;return a.set([c,p,h,i[0]+m[0]+(d[0]-m[0])*r,i[1]+m[1],i[2]+m[2]+(d[2]-m[2])*r,1,1,1]),o}keyPose(t){let r=new Map;ae(r,"root");for(let o of this.defs)ae(r,o.role);for(let[o,a]of Object.entries(this.keys)){let[n,s]=o.split(".");ae(r,n)[I[s]]=zn(a,t);}return r}};function f0(e,t){return Be(e,t),e}function ta(e,t,r,o){let a=new Set([...t.keys(),...r.keys()]),n=[0,0,0,0,0,0,1,1,1],s=new Map;for(let l of a){let i=t.get(l)??Float64Array.from(n),c=r.get(l)??Float64Array.from(n),p=ho(Qe(i[0],i[1],i[2])),h=ho(Qe(c[0],c[1],c[2])),[m,d,b]=Bt(Qo(vn(p,h,o))),u=new Float64Array(9);u[0]=m,u[1]=d,u[2]=b;for(let R=3;R<9;R++)u[R]=i[R]+(c[R]-i[R])*o;s.set(l,u);}return Be(e,s),e}var Ht=1/16,y0=.68,Nn=.85,g0=1.2,x0=1.03,w0=1.1,R0=.12,k0=.1,v0=.1;function fo(e){let t=r=>r.toFixed(4);e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`{
1
+ 'use strict';var D=require('three'),BufferGeometryUtils_js=require('three/examples/jsm/utils/BufferGeometryUtils.js'),RoomEnvironment_js=require('three/examples/jsm/environments/RoomEnvironment.js');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var D__namespace=/*#__PURE__*/_interopNamespace(D);function to(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let r=Math.imul(t^t>>>15,1|t);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function It(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}var Fs="en";function ee(e,t){let r=typeof e=="string"?e:e[Fs]??e.en;if(t)for(let[o,a]of Object.entries(t))r=r.split(`{${o}}`).join(String(a));return r}function Ia(e){let t=e.trim(),r=/```(?:json)?\s*([\s\S]*?)(?:```|$)/i.exec(t);r&&r[1]!==void 0&&(t=r[1]);let o=t.indexOf("{");if(o<0)return {ok:false,error:ee({en:"the answer has no JSON object",ru:"\u0432 \u043E\u0442\u0432\u0435\u0442\u0435 \u043D\u0435\u0442 JSON-\u043E\u0431\u044A\u0435\u043A\u0442\u0430"}),truncated:false};let a=0,n=false,s=false,l=-1;for(let i=o;i<t.length;i++){let c=t[i];if(n){s?s=false:c==="\\"?s=true:c==='"'&&(n=false);continue}if(c==='"')n=true;else if(c==="{"||c==="[")a++;else if((c==="}"||c==="]")&&(a--,a===0)){l=i;break}}if(l<0)return {ok:false,error:ee({en:"the JSON is cut off",ru:"JSON \u043E\u0431\u043E\u0440\u0432\u0430\u043D"}),truncated:true};try{return {ok:!0,value:JSON.parse(t.slice(o,l+1))}}catch{return {ok:false,error:ee({en:"invalid JSON",ru:"\u043D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u044B\u0439 JSON"}),truncated:false}}}var Oa={id:"avatar",label:"\u0410\u0432\u0430\u0442\u0430\u0440",hint:"the iDos Games account avatar: soft blocks with elbows and knees",bones:[{name:"body",role:"body",parent:null,pivot:[0,12.4,0]},{name:"head",role:"head",parent:"body",pivot:[0,22.4,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6.3,21.4,0]},{name:"armR",role:"armR",parent:"body",pivot:[6.3,21.4,0]},{name:"foreArmL",role:"foreArmL",parent:"armL",pivot:[-6.3,17.2,0]},{name:"foreArmR",role:"foreArmR",parent:"armR",pivot:[6.3,17.2,0]},{name:"legL",role:"legL",parent:null,pivot:[-2.1,12.4,0]},{name:"legR",role:"legR",parent:null,pivot:[2.1,12.4,0]},{name:"shinL",role:"shinL",parent:"legL",pivot:[-2.1,6.4,0]},{name:"shinR",role:"shinR",parent:"legR",pivot:[2.1,6.4,0]}],sockets:[{name:"handR",bone:"foreArmR",at:[6.3,11.6,-1]},{name:"handL",bone:"foreArmL",at:[-6.3,11.6,-1]},{name:"headTop",bone:"head",at:[0,30.3,0]},{name:"face",bone:"head",at:[0,26.7,-4]},{name:"back",bone:"body",at:[0,18.5,2.3]},{name:"waist",bone:"body",at:[0,12.8,0]},{name:"shoulders",bone:"body",at:[0,22.4,0]}],hitbox:{w:.6,h:1.9},eye:26.4,height:{min:24,max:40},faceBone:"head",ik:{feet:[{upper:"legL",lower:"shinL",end:"sole",bend:[-2.6,0]},{upper:"legR",lower:"shinR",end:"sole",bend:[-2.6,0]}],hands:{handR:{upper:"armR",lower:"foreArmR",end:"handR",bend:[0,2.6]},handL:{upper:"armL",lower:"foreArmL",end:"handL",bend:[0,2.6]}},look:{head:"head",body:"body",headYaw:1.1,headPitch:.75,bodyYaw:.5}},ragdoll:{torso:"body",joints:[{bone:"head",parent:"body",kind:"ball",swing:.7,twist:.9,up:true},{bone:"armL",parent:"body",kind:"ball",swing:2.2,twist:1.2,tilt:.5},{bone:"armR",parent:"body",kind:"ball",swing:2.2,twist:1.2,tilt:.5},{bone:"foreArmL",parent:"armL",kind:"hinge",bend:[0,2.5]},{bone:"foreArmR",parent:"armR",kind:"hinge",bend:[0,2.5]},{bone:"legL",parent:"body",kind:"ball",swing:1.1,twist:.6,tilt:.6},{bone:"legR",parent:"body",kind:"ball",swing:1.1,twist:.6,tilt:.6},{bone:"shinL",parent:"legL",kind:"hinge",bend:[-2.5,0]},{bone:"shinR",parent:"legR",kind:"hinge",bend:[-2.5,0]}],stand:["legL","legR","shinL","shinR"]},defaultParts:[{bone:"head",size:[8.5,7.5,8],pos:[0,26.5,0],color:"s",name:"head"},{bone:"head",size:[2.9,.8,2.7],pos:[0,22.6,0],color:"s",name:"neck"},{bone:"body",size:[9,6,4.6],pos:[0,19.4,0],color:"t",name:"torso"},{bone:"body",size:[8.5,5.2,4.3],pos:[0,15,0],color:"t",name:"torso"},{bone:"armL",size:[3.6,5,3.6],pos:[-6.3,19.7,0],color:"s",name:"sleeveL"},{bone:"armR",size:[3.6,5,3.6],pos:[6.3,19.7,0],color:"s",name:"sleeveR"},{bone:"foreArmL",size:[3.45,5.4,3.45],pos:[-6.3,15.7,0],color:"s",name:"forearmL"},{bone:"foreArmR",size:[3.45,5.4,3.45],pos:[6.3,15.7,0],color:"s",name:"forearmR"},{bone:"foreArmL",size:[3.3,3,3.3],pos:[-6.3,12.7,0],color:"s",name:"handL"},{bone:"foreArmR",size:[3.3,3,3.3],pos:[6.3,12.7,0],color:"s",name:"handR"},{bone:"legL",size:[4.2,6,4.2],pos:[-2.1,9.4,0],color:"p",name:"legL"},{bone:"legR",size:[4.2,6,4.2],pos:[2.1,9.4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.05,7.2,4.05],pos:[-2.1,4,0],color:"p",name:"legL"},{bone:"shinR",size:[4.05,7.2,4.05],pos:[2.1,4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.2,1.6,5.2],pos:[-2.1,.8,-0.5],color:"p",name:"footL"},{bone:"shinR",size:[4.2,1.6,5.2],pos:[2.1,.8,-0.5],color:"p",name:"footR"}]};var _a={id:"blob",label:"\u041A\u0430\u043F\u043B\u044F",hint:"slimes, ghosts, spirits, living objects \u2014 one body with a face, moves by hopping",bones:[{name:"body",role:"body",parent:null,pivot:[0,0,0]}],sockets:[{name:"headTop",bone:"body",at:[0,12,0]},{name:"face",bone:"body",at:[0,7,-6]},{name:"back",bone:"body",at:[0,6,6]},{name:"waist",bone:"body",at:[0,3,0]},{name:"shoulders",bone:"body",at:[0,10,0]},{name:"handR",bone:"body",at:[6,5,-2]},{name:"handL",bone:"body",at:[-6,5,-2]}],hitbox:{w:.8,h:.8},eye:8,height:{min:4,max:40},faceBone:"body",defaultParts:[{bone:"body",size:[12,12,12],pos:[0,6,0],color:"t"}]};var Va={id:"flyer",label:"\u041A\u0440\u044B\u043B\u0430\u0442\u044B\u0439",hint:"birds, bats, dragons, fairies, insects \u2014 creatures whose wings matter",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,11,-3]},{name:"wingL",role:"wingL",parent:"body",pivot:[-3,10,0]},{name:"wingR",role:"wingR",parent:"body",pivot:[3,10,0]},{name:"legL",role:"legL",parent:null,pivot:[-1.5,4,0]},{name:"legR",role:"legR",parent:null,pivot:[1.5,4,0]},{name:"tail",role:"tail",parent:"body",pivot:[0,8,4]}],sockets:[{name:"headTop",bone:"head",at:[0,16,-4]},{name:"face",bone:"head",at:[0,13,-7]},{name:"back",bone:"body",at:[0,11,1]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,10,-2]},{name:"handR",bone:"legR",at:[1.5,0,-1]},{name:"handL",bone:"legL",at:[-1.5,0,-1]}],hitbox:{w:.6,h:.9},eye:14,height:{min:6,max:40},faceBone:"head",ik:{feet:[{upper:"legL",end:"sole"},{upper:"legR",end:"sole"}],look:{head:"head",headYaw:1.2,headPitch:.6,bodyYaw:0}},defaultParts:[{bone:"body",size:[6,6,8],pos:[0,8,0],color:"t"},{bone:"head",size:[5,5,5],pos:[0,13,-4],color:"s"},{bone:"wingL",size:[8,1,6],pos:[-7,10,0],color:"t"},{bone:"wingR",size:[8,1,6],pos:[7,10,0],color:"t"},{bone:"legL",size:[1,4,1],pos:[-1.5,2,0],color:"p"},{bone:"legR",size:[1,4,1],pos:[1.5,2,0],color:"p"},{bone:"tail",size:[4,1,4],pos:[0,8,6],color:"t"}]};var Fa={id:"humanoid",label:"\u0427\u0435\u043B\u043E\u0432\u0435\u043A",hint:"people, humanoids, robots, elves, zombies \u2014 anything on two legs with two arms",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,24,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6,22,0]},{name:"armR",role:"armR",parent:"body",pivot:[6,22,0]},{name:"legL",role:"legL",parent:null,pivot:[-2,12,0]},{name:"legR",role:"legR",parent:null,pivot:[2,12,0]}],sockets:[{name:"handR",bone:"armR",at:[6,11,-1]},{name:"handL",bone:"armL",at:[-6,11,-1]},{name:"headTop",bone:"head",at:[0,32,0]},{name:"face",bone:"head",at:[0,28,-4]},{name:"back",bone:"body",at:[0,18,2]},{name:"waist",bone:"body",at:[0,12,0]},{name:"shoulders",bone:"body",at:[0,24,0]}],hitbox:{w:.6,h:1.8},eye:27,height:{min:16,max:48},faceBone:"head",ik:{feet:[{upper:"legL",end:"sole"},{upper:"legR",end:"sole"}],hands:{handR:{upper:"armR",end:"handR"},handL:{upper:"armL",end:"handL"}},look:{head:"head",body:"body",headYaw:1.1,headPitch:.75,bodyYaw:.5}},defaultParts:[{bone:"head",size:[8,8,8],pos:[0,28,0],color:"s"},{bone:"body",size:[8,12,4],pos:[0,18,0],color:"t"},{bone:"armL",size:[4,12,4],pos:[-6,18,0],color:"s"},{bone:"armR",size:[4,12,4],pos:[6,18,0],color:"s"},{bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p"},{bone:"legR",size:[4,12,4],pos:[2,6,0],color:"p"}]};var Ba={id:"quadruped",label:"\u0427\u0435\u0442\u0432\u0435\u0440\u043E\u043D\u043E\u0433\u043E\u0435",hint:"dogs, cats, horses, wolves, bears, lizards \u2014 any animal on four legs",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,14,-8]},{name:"legFL",role:"legFL",parent:null,pivot:[-3,8,-6]},{name:"legFR",role:"legFR",parent:null,pivot:[3,8,-6]},{name:"legBL",role:"legBL",parent:null,pivot:[-3,8,6]},{name:"legBR",role:"legBR",parent:null,pivot:[3,8,6]},{name:"tail",role:"tail",parent:"body",pivot:[0,14,8]}],sockets:[{name:"headTop",bone:"head",at:[0,20,-12]},{name:"face",bone:"head",at:[0,16,-16]},{name:"back",bone:"body",at:[0,16,0]},{name:"waist",bone:"body",at:[0,12,4]},{name:"shoulders",bone:"body",at:[0,16,-6]},{name:"handR",bone:"head",at:[2,13,-16]},{name:"handL",bone:"head",at:[-2,13,-16]}],hitbox:{w:.9,h:1},eye:17,height:{min:8,max:40},faceBone:"head",ik:{feet:[{upper:"legFL",end:"sole"},{upper:"legFR",end:"sole"},{upper:"legBL",end:"sole"},{upper:"legBR",end:"sole"}],tilt:{front:["legFL","legFR"],back:["legBL","legBR"],max:.45},look:{head:"head",headYaw:.9,headPitch:.6,bodyYaw:0}},defaultParts:[{bone:"body",size:[8,8,16],pos:[0,12,0],color:"t"},{bone:"head",size:[8,8,8],pos:[0,16,-12],color:"s"},{bone:"legFL",size:[3,8,3],pos:[-3,4,-6],color:"p"},{bone:"legFR",size:[3,8,3],pos:[3,4,-6],color:"p"},{bone:"legBL",size:[3,8,3],pos:[-3,4,6],color:"p"},{bone:"legBR",size:[3,8,3],pos:[3,4,6],color:"p"},{bone:"tail",size:[2,2,8],pos:[0,14,12],color:"t"}]};var Da={id:"swimmer",label:"\u041F\u043B\u043E\u0432\u0435\u0446",hint:"fish, sharks, dolphins, whales \u2014 creatures that swim with a tail",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,6,-4]},{name:"tail",role:"tail",parent:"body",pivot:[0,6,4]},{name:"finL",role:"ear",parent:"body",pivot:[-3,5,-1]},{name:"finR",role:"ear",parent:"body",pivot:[3,5,-1]}],sockets:[{name:"headTop",bone:"head",at:[0,10,-6]},{name:"face",bone:"head",at:[0,7,-9]},{name:"back",bone:"body",at:[0,10,0]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,9,-3]},{name:"handR",bone:"head",at:[1,4,-9]},{name:"handL",bone:"head",at:[-1,4,-9]}],hitbox:{w:.7,h:.6},eye:8,height:{min:4,max:40},faceBone:"head",ik:{look:{head:"head",headYaw:.4,headPitch:.3,bodyYaw:0}},defaultParts:[{bone:"body",size:[5,7,9],pos:[0,6,0],color:"t"},{bone:"head",size:[5,6,4],pos:[0,6,-6.5],color:"s"},{bone:"tail",size:[1,6,4],pos:[0,6,7],color:"t"},{bone:"finL",size:[3,.6,2],pos:[-4,5,-1],color:"p"},{bone:"finR",size:[3,.6,2],pos:[4,5,-1],color:"p"}]};var $c=["root","body","head","armL","armR","legL","legR","foreArmL","foreArmR","shinL","shinR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],ro=["tail","wingL","wingR","ear","hair","cape","antenna","static"],Jc=["handR","handL","headTop","face","back","waist","shoulders"],wr=["humanoid","quadruped","flyer","blob","swimmer"],Zt="avatar";var Ae={humanoid:Fa,quadruped:Ba,flyer:Va,blob:_a,swimmer:Da,avatar:Oa};var Na=1,ut=["front","back","left","right","top","bottom"],kr=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],vr=["normal","bouncy","heavy","sneaky","robotic","swagger","skip","ninja","zombie","catwalk"],Ar=["calm","fidgety","proud","cool","shy","ready","bored"],Ga={parts:96,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},tr=["glass","metal","glow"],p1=["cylinder"],er={noise:.5,outline:.4,shade:.25,density:2},J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Rr=e=>Array.isArray(e)?e:[];function Ie(e,t,r,o){let a=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(a)?Math.min(o,Math.max(r,a)):t}function Oo(e,t,r){if(typeof e!="string")return r;let o=e.trim();if(t.includes(o))return o;let a=o.toLowerCase().replace(/[\s-]+/g,"_");return t.find(s=>s.toLowerCase()===a)??r}function Ke(e,t,r){return typeof e=="string"?e.trim().slice(0,r):t}function oo(e,t,r=null){if(!Array.isArray(e)||e.length<3)return r;let o=e.slice(0,3).map(a=>Ie(a,NaN,-t,t));return o.every(Number.isFinite)?o:r}var Ha={black:"#1d1d21",white:"#f0f0f0",gray:"#808080",grey:"#808080",red:"#c0392b",green:"#3c9a3c",blue:"#2f5fd0",yellow:"#f2d33c",orange:"#e8862a",purple:"#8a4fc4",pink:"#f08cb4",brown:"#7a4f2a",cyan:"#2ab0c0",gold:"#d8b030",silver:"#c0c4c8",skin:"#c69c7c"};function ot(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(Ha[t])return Ha[t];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(a=>a+a).join(""):o)}var ft=new Set(["."," "]),ja=e=>/^[A-Za-z0-9_]{1,24}$/.test(e),Bs={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob",fish:"swimmer",shark:"swimmer",aquatic:"swimmer"};function Ds(e){if(typeof e!="string")return "humanoid";let t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return wr.includes(t)?t:t===Zt?Zt:Bs[t]??"humanoid"}function qa(e,t){let r=/^(.*?)(L|R)$/.exec(e);if(!r)return e;let o=r[1]+(r[2]==="L"?"R":"L");return t(o)?o:e}function Ye(e){if(typeof e=="string"){let f=Ia(e);if(!f.ok)return {ok:false,error:f.error,truncated:f.truncated};e=f.value;}if(!J(e))return {ok:false,error:ee({en:"the character recipe is not an object",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u0436\u0430 \u2014 \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})};if(!("parts"in e)&&!("rig"in e)){let f=e.character??e.spec??e.characterSpec;J(f)&&(e=f);}let t=e,r=Ga,o=[];typeof t.version=="number"&&t.version>Na&&o.push(ee({en:"recipe version {v} is newer than the game \u2014 read what could be read",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 {v} \u2014 \u043D\u043E\u0432\u0435\u0435 \u0438\u0433\u0440\u044B, \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D\u043E \u0447\u0442\u043E \u043F\u043E\u043D\u044F\u0442\u043D\u043E"},{v:t.version}));let a=Ds(t.rig),n=Ae[a],s={};if(J(t.palette))for(let[f,S]of Object.entries(t.palette)){if(Object.keys(s).length>=r.palette){o.push(ee({en:"the palette is longer than {n} \u2014 the rest was dropped",ru:"\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u0434\u043B\u0438\u043D\u043D\u0435\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0435\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u043E"},{n:r.palette}));break}let T=ot(S);if(f.length!==1||ft.has(f)||!T){o.push(ee({en:"palette colour \xAB{k}\xBB was not understood",ru:"\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u043F\u043E\u043D\u044F\u0442"},{k:f}));continue}s[f]=T;}let l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=(f,S)=>{if(typeof f!="string")return S;if(f.length===1&&s[f])return f;let T=ot(f);if(!T)return S;let C=Object.entries(s).find(([,O])=>O===T);if(C)return C[0];if(Object.keys(s).length>=r.palette)return S;let z=[...l].find(O=>!s[O]);return z?(s[z]=T,z):S},c={},p=0;if(J(t.textures))for(let[f,S]of Object.entries(t.textures)){if(!ja(f)){o.push(ee({en:"texture name \xAB{id}\xBB does not fit",ru:"\u0438\u043C\u044F \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB \u043D\u0435 \u043F\u043E\u0434\u0445\u043E\u0434\u0438\u0442"},{id:f.slice(0,30)}));continue}if(Object.keys(c).length>=r.textures){o.push(ee({en:"more than {n} textures \u2014 the rest were dropped",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.textures}));break}let T=js(S,s,o,f);if(T){if(p+T.w*T.h>r.texturePixels){o.push(ee({en:"texture \xAB{id}\xBB did not fit the pixel limit",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB \u043D\u0435 \u0432\u043B\u0435\u0437\u043B\u0430 \u0432 \u043B\u0438\u043C\u0438\u0442 \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439"},{id:f}));continue}p+=T.w*T.h,c[f]=T;}}let h=new Set(n.bones.map(f=>f.name)),m=[];for(let f of Rr(t.bones)){if(!J(f))continue;let S=Ke(f.name,"",24);if(!S||!ja(S))continue;let T=oo(f.pivot,r.coord);if(!T||m.some(M=>M.name===S))continue;if(m.length>=r.bones){o.push(ee({en:"more than {n} bones \u2014 the rest were dropped",ru:"\u043A\u043E\u0441\u0442\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.bones}));break}let C=h.has(S),z=Ke(f.parent,"",24),O=C?n.bones.find(M=>M.name===S).parent??"":h.has(z)||m.some(M=>M.name===z)?z:n.bones.find(M=>M.role==="body").name;m.push({name:S,parent:O,pivot:T,role:C?"static":Oo(f.role,ro,"static")}),h.add(S);}let d=Object.keys(s)[0]??"s",b=[];for(let f of Rr(t.parts)){if(b.length>=r.parts){o.push(ee({en:"more than {n} parts \u2014 the rest were dropped",ru:"\u0434\u0435\u0442\u0430\u043B\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.parts}));break}if(!J(f))continue;let S=oo(f.size,r.partSide),T=oo(f.pos??f.center??f.at,r.coord);if(!S||!T||S.some(V=>V<=0))continue;let C=Ke(f.bone,"",24);h.has(C)||(C&&o.push(ee({en:"bone \xAB{b}\xBB not found \u2014 the part is on the body",ru:"\u043A\u043E\u0441\u0442\u044C \xAB{b}\xBB \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u2014 \u0434\u0435\u0442\u0430\u043B\u044C \u043D\u0430 \u0442\u0435\u043B\u0435"},{b:C})),C=n.bones.find(V=>V.role==="body").name);let z={bone:C,size:S,pos:T,color:i(f.color,d)};if(J(f.faces)){let V={};for(let q of ut){let Y=f.faces[q];if(typeof Y=="string")if(c[Y])V[q]=Y;else {let pe=i(Y,"");pe&&(V[q]=pe);}}Object.keys(V).length&&(z.faces=V);}let O=oo(f.rot??f.rotation,180);O&&O.some(V=>V!==0)&&(z.rot=O),(f.mirror===true||f.mirror==="x")&&(z.mirror=true);let M=Ke(f.name,"",24);M&&(z.name=M),f.shape==="cylinder"&&(z.shape="cylinder"),typeof f.mat=="string"&&tr.includes(f.mat)&&(z.mat=f.mat),f.wrap===true&&(z.wrap=true),b.push(z);}if(!b.length){for(let[f,S]of Object.entries(Ns))s[f]||(s[f]=S);b.push(...n.defaultParts.map(Hs));}let u=null;if(J(t.face)){let f=t.face,S=h.has(Ke(f.bone,"",24))?Ke(f.bone,"",24):n.faceBone,T=Rr(f.rect).map(z=>Math.round(Ie(z,NaN,0,r.partSide)*10)/10),C={};if(J(f.expressions))for(let z of kr){let O=f.expressions[z];typeof O=="string"&&c[O]&&(C[z]=O);}if(!C.neutral){let z=Object.values(C)[0];z&&(C.neutral=z);}if(C.neutral){let z=c[C.neutral];if(u={bone:S,rect:T.length===4&&T.every(Number.isFinite)&&T[2]>0&&T[3]>0?T:[0,0,z.w,z.h],expressions:C},J(f.drawn)){let O=f.drawn;u.drawn={eyes:Ke(O.eyes,"round",16),brows:Ke(O.brows,"none",16),mouth:Ke(O.mouth,"smile",16),eyeColor:ot(O.eyeColor)??"#3b2a20",cheeks:O.cheeks===true};}}else Object.keys(f).length&&o.push(ee({en:"the face has no pictures \u2014 no face is drawn",ru:"\u0443 \u043B\u0438\u0446\u0430 \u043D\u0435\u0442 \u043D\u0438 \u043E\u0434\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438 \u2014 \u043B\u0438\u0446\u043E \u043D\u0435 \u043D\u0430\u0440\u0438\u0441\u043E\u0432\u0430\u043D\u043E"}));}let R=J(t.style)?t.style:{},w=J(t.voice)?t.voice:{},A=J(t.finish)?t.finish:{},k={version:Na,name:Ke(t.name,ao(),40)||ao(),description:Ke(t.description,"",300),rig:a,scale:Ie(t.scale,1,.25,3),palette:s,textures:c,parts:b,bones:m,face:u,style:{walk:Oo(R.walk,vr,"normal"),idle:Oo(R.idle,Ar,"calm"),energy:Ie(R.energy,.5,0,1)},voice:{pitch:Ie(w.pitch,1,.5,2)},tags:Rr(t.tags).filter(f=>typeof f=="string"&&!!f.trim()).slice(0,8).map(f=>f.trim().slice(0,24)),finish:{noise:Ie(A.noise,er.noise,0,1),outline:Ie(A.outline,er.outline,0,1),shade:Ie(A.shade,er.shade,0,1),density:Math.round(Ie(A.density,er.density,1,4))}},x=Ie(A.round,0,0,1);return x>0&&(k.finish.round=x),{ok:true,spec:k,warnings:o}}var Ns={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function Hs(e){return JSON.parse(JSON.stringify(e))}function js(e,t,r,o){let a=Array.isArray(e)?{rows:e}:J(e)?e:null;if(!a)return null;let n=Ga.textureSide,s=Rr(a.rows??a.pixels).filter(p=>typeof p=="string");if(!s.length)return null;let l=Math.round(Ie(a.h??a.height,s.length,1,n)),i=Math.round(Ie(a.w??a.width,Math.max(...s.map(p=>p.length)),1,n)),c=false;for(s=s.slice(0,l).map(p=>{let h="";for(let m=0;m<i;m++){let d=p[m]??".";ft.has(d)||t[d]?h+=d===" "?".":d:(c=true,h+=".");}return h});s.length<l;)s.push(".".repeat(i));return c&&r.push(ee({en:"texture \xAB{id}\xBB has symbols not in the palette \u2014 they became transparent",ru:"\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \u2014 \u0441\u0442\u0430\u043B\u0438 \u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u044B\u043C\u0438"},{id:o})),{w:i,h:l,rows:s}}function _o(e){return Array.isArray(e)?"["+e.map(_o).join(",")+"]":J(e)?"{"+Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>JSON.stringify(t)+":"+_o(e[t])).join(",")+"}":JSON.stringify(e)}function rr(e){let t=_o(e),r=It(t),o=It("~"+t);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function m1(e){return Ae[e.rig]}function Ua(e){let r=Ae[e.rig].bones.map(o=>{let a=e.bones.find(n=>n.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(a?.pivot??o.pivot).slice()}});for(let o of e.bones)r.some(a=>a.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function ao(){return ee({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var h1=e=>e==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||e==="Character";var Ka={front:{tl:[1,1,-1],u:[-1,0,0],d:[0,-1,0],n:[0,0,-1]},back:{tl:[-1,1,1],u:[1,0,0],d:[0,-1,0],n:[0,0,1]},right:{tl:[1,1,1],u:[0,0,-1],d:[0,-1,0],n:[1,0,0]},left:{tl:[-1,1,-1],u:[0,0,1],d:[0,-1,0],n:[-1,0,0]},top:{tl:[1,1,1],u:[-1,0,0],d:[0,0,-1],n:[0,1,0]},bottom:{tl:[-1,-1,1],u:[1,0,0],d:[0,0,-1],n:[0,-1,0]}};function Vo(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}function Ya(e,t,r,o,a,n){let s=((r-1-a)*t+o)*4;e[s]=n[0],e[s+1]=n[1],e[s+2]=n[2],e[s+3]=255;}function Gs(e,t=0){e.sort((r,o)=>o.h-r.h||o.w-r.w||(r.key<o.key?-1:1));for(let r=16;;r*=2){let o=0,a=0,n=0;for(let l of e)o+l.w+t*2>r&&(o=0,a+=n,n=0),l.x=o+t,l.y=a+t,o+=l.w+t*2,n=Math.max(n,l.h+t*2);let s=a+n;if(s<=r||r>=1024){let l=16;for(;l<s;)l*=2;return {w:r,h:l}}}}function qs(e,t,r,o,a){let n=(s,l)=>((r-1-o.y-l)*t+o.x+s)*4;for(let s=-a;s<o.h+a;s++)for(let l=-a;l<o.w+a;l++){let i=Math.max(0,Math.min(o.w-1,l)),c=Math.max(0,Math.min(o.h-1,s));if(i===l&&c===s)continue;let p=n(i,c);e.copyWithin(n(l,s),p,p+4);}}function Wa(e,t,r){let o=Math.imul(t,374761393)+Math.imul(r,668265263)+Math.imul(e,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function Us(e,t,r,o,a,n,s,l){let c=1+(.55*Wa(s,t,r)+.45*Wa(s^1540483477,Math.floor(t/3),Math.floor(r/3))-.5)*2*l.noise*.14;return n==="s"?c+=l.shade*.16*(.5-(r+.5)/a):n==="t"?c+=l.shade*.08:c-=l.shade*.2,o>=3&&a>=3&&(t===0||r===0||t===o-1||r===a-1)&&(c*=1-.5*l.outline),[Math.max(0,Math.min(255,e[0]*c)),Math.max(0,Math.min(255,e[1]*c)),Math.max(0,Math.min(255,e[2]*c))]}var or=Math.PI/180;function ar(e,t){if(!t)return e;let[r,o,a]=e,[n,s,l]=[t[0]*or,t[1]*or,t[2]*or],i=Math.cos(l),c=Math.sin(l);return [r,o]=[r*i-o*c,r*c+o*i],i=Math.cos(s),c=Math.sin(s),[r,a]=[r*i+a*c,-r*c+a*i],i=Math.cos(n),c=Math.sin(n),[o,a]=[o*i-a*c,o*c+a*i],[r,o,a]}function Ks(e,t){let r=[];for(let o of e.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let a=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;a&&(a.left===void 0&&delete a.left,a.right===void 0&&delete a.right);let n={...o,bone:qa(o.bone,t),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};a?n.faces=a:delete n.faces,o.rot&&(n.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(n);}return r}function Xa(e){let t=Ae[e.rig],r=Ua(e),o=v=>r.some(_=>_.name===v),a=Ks(e,o),n=e.finish??er,s=n.round??0,l=new Map,i=(v,_)=>{let F=v.faces?.[_],H=F!==void 0?e.textures[F]:void 0,he=F!==void 0&&e.palette[F]?F:v.color,[Ce,Ne]=_==="front"||_==="back"?[v.size[0],v.size[1]]:_==="left"||_==="right"?[v.size[2],v.size[1]]:[v.size[0],v.size[2]],Pe=(gr,qe)=>Math.max(1,Math.min(64,qe*Math.max(1,Math.round(gr*n.density/qe)))),ve=H?Pe(Ce,H.w):Pe(Ce,1),ze=H?Pe(Ne,H.h):Pe(Ne,1),Fe=_==="top"?"t":_==="bottom"?"b":"s",oe=(H?"t:"+F:"c:"+he)+"|"+ve+"x"+ze+Fe,fe=l.get(oe);if(fe)return fe;let $=It(oe),zt=H?null:Vo(e.palette[he]??"#ff00ff");return fe={key:oe,w:ve,h:ze,x:0,y:0,paint:(gr,qe,Xr,Qr,Zr)=>{for(let pt=0;pt<ze;pt++)for(let mt=0;mt<ve;mt++){let xr=zt;if(H){let eo=H.rows[Math.floor(pt*H.h/ze)][Math.floor(mt*H.w/ve)];if(ft.has(eo))continue;let Ue=e.palette[eo];if(!Ue)continue;xr=Vo(Ue);}Ya(gr,qe,Xr,Qr+mt,Zr+pt,Us(xr,mt,pt,ve,ze,Fe,$,n));}}},l.set(oe,fe),fe},c=(v,_)=>{let F="e:"+v,H=l.get(F);return H||(H={key:F,w:_.w,h:_.h,x:0,y:0,paint:(he,Ce,Ne,Pe,ve)=>{for(let ze=0;ze<_.h;ze++)for(let Fe=0;Fe<_.w;Fe++){let oe=_.rows[ze][Fe];if(ft.has(oe))continue;let fe=e.palette[oe];fe&&Ya(he,Ce,Ne,Pe+Fe,ve+ze,Vo(fe));}}},l.set(F,H)),H},p=a.map(v=>({p:v,faces:ut.map(_=>({f:_,cell:i(v,_)}))})),h=e.face,m=[];if(h)for(let[v,_]of Object.entries(h.expressions)){let F=e.textures[_];F&&m.push([v,c(_,F)]);}let d=s>0?2:0,{w:b,h:u}=Gs([...l.values()],d),R=new Uint8Array(b*u*4);for(let v of l.values())v.paint(R,b,u,v.x,v.y),d&&qs(R,b,u,v,d);let w=.01,A=(v,_=w)=>[(v.x+_)/b,1-(v.y+_)/u,(v.x+v.w-_)/b,1-(v.y+v.h-_)/u],k=new Map;for(let v of r)k.set(v.name,{pos:[],nrm:[],uv:[],idx:[]});let x=new Map,f=v=>{let _=x.get(v);if(_===void 0){_=true;for(let F=0;F<v.h&&_;F++)for(let H=0;H<v.w;H++)if(R[((u-1-v.y-F)*b+v.x+H)*4+3]<128){_=false;break}x.set(v,_);}return _},S=new Map;for(let{p:v}of p)v.shape==="cylinder"&&!S.has(v.bone)&&S.set(v.bone,v);let T=v=>!!v.wrap&&S.has(v.bone),C=new Map;for(let{p:v,faces:_}of p)if(v.shape!=="cylinder"&&v.mat!=="glass"&&_.every(({cell:F})=>f(F))){let F=C.get(v.bone)??[];F.push(v),C.set(v.bone,F);}let z=new Map,O=v=>{if(!v.mat)return k.get(v.bone);let _=v.mat+"|"+v.bone,F=z.get(_);return F||z.set(_,F={bone:v.bone,mat:v.mat,pos:[],nrm:[],uv:[],idx:[]}),F},M=0;for(let{p:v,faces:_}of p){let F=O(v),H=r.find(oe=>oe.name===v.bone).pivot,he=[v.size[0]/2,v.size[1]/2,v.size[2]/2];if(M=Math.max(M,v.pos[1]+he[1]),v.shape==="cylinder"){for(let{f:oe,cell:fe}of _)ti(F,v,he,Ka[oe],H,A(fe,.5));continue}let Ce=T(v),Ne=Ce?S.get(v.bone):void 0,Pe=(C.get(v.bone)??[]).filter(oe=>oe!==v&&T(oe)===Ce),ve=Math.min(v.size[0],v.size[1],v.size[2])<Za?0:s,ze=Math.min(v.size[0],v.size[1],v.size[2])>=Js?$s:Ws,Fe=(oe,fe)=>{let $=Ka[oe],zt=(Ue,ht)=>{let Qt=[he[0]*($.tl[0]+2*($.u[0]*Ue+$.d[0]*ht)),he[1]*($.tl[1]+2*($.u[1]*Ue+$.d[1]*ht)),he[2]*($.tl[2]+2*($.u[2]*Ue+$.d[2]*ht))],dt=ar(Qt,v.rot);return [v.pos[0]+dt[0]-H[0],v.pos[1]+dt[1]-H[1],v.pos[2]+dt[2]-H[2]]},gr=ar($.n,v.rot),qe=F.pos.length/3,[Xr,Qr,Zr,pt]=A(fe),[mt,xr]=v.flip?[Zr,Xr]:[Xr,Zr];if(ve>0||Ce){let[Ue,ht,Qt,dt]=A(fe,.5);Xs(F,v,he,$,H,ve,ze,v.flip?[Qt,ht,Ue,dt]:[Ue,ht,Qt,dt],Ce);return}let eo=[[0,0,mt,Qr],[1,0,xr,Qr],[1,1,xr,pt],[0,1,mt,pt]];for(let[Ue,ht,Qt,dt]of eo)F.pos.push(...zt(Ue,ht)),F.nrm.push(...gr),F.uv.push(Qt,dt);F.idx.push(qe,qe+2,qe+1,qe,qe+3,qe+2);};for(let{f:oe,cell:fe}of _){let $=[F.pos.length,F.nrm.length,F.uv.length,F.idx.length];Fe(oe,fe),Pe.length&&di(F.pos,$[0],H,Pe,s)?(F.pos.length=$[0],F.nrm.length=$[1],F.uv.length=$[2],F.idx.length=$[3]):Ne&&(li(F,$[0],H,Ne,ni(v,he,Ne)),ii(F.pos,$[0],H,Ne)&&(F.pos.length=$[0],F.nrm.length=$[1],F.uv.length=$[2],F.idx.length=$[3]));}}let V=r.map(v=>{let _=k.get(v.name);return {name:v.name,role:v.role,parent:v.parent,pivot:v.pivot,positions:Float32Array.from(_.pos),normals:Float32Array.from(_.nrm),uvs:Float32Array.from(_.uv),indices:Uint16Array.from(_.idx)}}),q=[...z.values()].map(v=>({bone:v.bone,mat:v.mat,positions:Float32Array.from(v.pos),normals:Float32Array.from(v.nrm),uvs:Float32Array.from(v.uv),indices:Uint16Array.from(v.idx)})),Y=null;if(h&&m.length){let v=e.parts.filter(H=>H.bone===h.bone),_=v.find(H=>H.name===h.bone)??v.sort((H,he)=>he.size[0]*he.size[1]*he.size[2]-H.size[0]*H.size[1]*H.size[2])[0],F=r.find(H=>H.name===h.bone);if(_&&F&&_.shape==="cylinder"){let H={};for(let[he,Ce]of m)H[he]=A(Ce);Y=mi(h.bone,_,h.rect,F.pivot,H);}else if(_&&F){let[H,he,Ce,Ne]=h.rect,Pe=_.pos[0]+_.size[0]/2-H,ve=_.pos[1]+_.size[1]/2-he,ze=_.pos[2]-_.size[2]/2-.05,Fe=F.pivot,oe=($,zt)=>[$-Fe[0],zt-Fe[1],ze-Fe[2]],fe={};for(let[$,zt]of m)fe[$]=A(zt);Y={bone:h.bone,corners:Float32Array.from([...oe(Pe,ve),...oe(Pe-Ce,ve),...oe(Pe-Ce,ve-Ne),...oe(Pe,ve-Ne)]),uv:fe};}}let pe=t.sockets.filter(v=>o(v.bone)).map(v=>{let _=t.bones.find(F=>F.name===v.bone);return {name:v.name,bone:v.bone,at:[v.at[0]-_.pivot[0],v.at[1]-_.pivot[1],v.at[2]-_.pivot[2]]}}),me=Math.max(1,M),ie=me>t.height.max?t.height.max/me:me<t.height.min?t.height.min/me:1;return {hash:rr(e),rig:e.rig,bones:V,mats:q,atlas:{w:b,h:u,data:R},face:Y,sockets:pe,height:me,scale:e.scale*ie,eye:t.eye*me/ui(e.rig)}}var Qa=3,Ys=2.5,Ws=1,$a=0,$s=2,Js=4.1;function Xs(e,t,r,o,a,n,s,l,i=false){let c=Math.min(r[0],r[1],r[2]),p=i?0:Math.min(c,n*Qa),h=Math.min(c,p*Ys),m=[r[0]-p,r[1]-p,r[2]-p],d=[r[0]-h,r[1]-h,r[2]-h],b=C=>Math.abs(C[0])*t.size[0]+Math.abs(C[1])*t.size[1]+Math.abs(C[2])*t.size[2],u=C=>{let z=[];for(let M=0;M<=s;M++)z.push(Math.min(.5,p*M/s/C));if(!i)for(let M=1;M<=$a;M++)z.push(Math.min(.5,(p+(h-p)*M/$a)/C));if(i){let M=Math.max(1,Math.min(Zs,Math.ceil(C/Qs)));for(let V=1;V<M;V++)z.push(Bo(V/M));}let O=[...z,...z.map(M=>1-M)].sort((M,V)=>M-V);return O.filter((M,V)=>V===0||M-O[V-1]>1e-6)},R=u(b(o.u)),w=u(b(o.d)),A=e.pos.length/3,[k,x,f,S]=l;for(let C of w)for(let z of R){let O=[0,0,0],M=[0,0,0],V=[0,0,0];for(let _=0;_<3;_++){let F=r[_]*(o.tl[_]+2*(o.u[_]*z+o.d[_]*C)),H=Math.max(-m[_],Math.min(m[_],F));M[_]=F-H,O[_]=H,V[_]=F-Math.max(-d[_],Math.min(d[_],F));}let q=Math.hypot(M[0],M[1],M[2]),Y=q>1e-9?[M[0]/q,M[1]/q,M[2]/q]:[o.n[0],o.n[1],o.n[2]],pe=Math.hypot(V[0],V[1],V[2]),me=pe>1e-9?[V[0]/pe,V[1]/pe,V[2]/pe]:Y,ie=[O[0]+Y[0]*p,O[1]+Y[1]*p,O[2]+Y[2]*p],v=ar(ie,t.rot);e.pos.push(t.pos[0]+v[0]-a[0],t.pos[1]+v[1]-a[1],t.pos[2]+v[2]-a[2]),e.nrm.push(...ar(me,t.rot)),e.uv.push(k+(f-k)*z,x+(S-x)*C);}let T=R.length;for(let C=0;C+1<w.length;C++)for(let z=0;z+1<T;z++){let O=A+C*T+z;e.idx.push(O,O+T+1,O+1,O,O+T,O+T+1);}}var Za=.45,Qs=1.5,Zs=5,ei=10,Ja=.6,Bo=e=>(1-Ja)*e+Ja*(.5+.5*Math.sin(Math.PI*(e-.5))),Er=4,no=1.12,en=.35;function tn(e,t,r){let o=e*e,a=t*t,n=r*r;return [e*Math.sqrt(Math.max(0,1-a/2-n/2+a*n/3)),t*Math.sqrt(Math.max(0,1-n/2-o/2+n*o/3)),r*Math.sqrt(Math.max(0,1-o/2-a/2+o*a/3))]}function rn(e){let t=Er,r=Math.pow(Math.pow(e[0]*e[0]+e[2]*e[2],t/2)+Math.pow(Math.abs(e[1]),t),1/t)||1;return [e[0]/r,e[1]/r,e[2]/r]}function Do(e,t){let r=Er,o=Math.pow(e[0]*e[0]+e[2]*e[2],(r-2)/2),a=[e[0]*o,Math.sign(e[1])*Math.pow(Math.abs(e[1]),r-1),e[2]*o],n=[a[0]/t[0],a[1]/t[1],a[2]/t[2]],s=Math.hypot(n[0],n[1],n[2])||1;return [n[0]/s,n[1]/s,n[2]/s]}function ti(e,t,r,o,a,n){let s=ei,l=e.pos.length/3,[i,c,p,h]=n;for(let d=0;d<=s;d++)for(let b=0;b<=s;b++){let u=Bo(b/s),R=Bo(d/s),w=[0,0,0];for(let x=0;x<3;x++)w[x]=o.tl[x]+2*(o.u[x]*u+o.d[x]*R);let A=rn(tn(w[0],w[1],w[2])),k=ar([r[0]*A[0],r[1]*A[1],r[2]*A[2]],t.rot);e.pos.push(t.pos[0]+k[0]-a[0],t.pos[1]+k[1]-a[1],t.pos[2]+k[2]-a[2]),e.nrm.push(...ar(Do(A,r),t.rot)),e.uv.push(i+(p-i)*u,c+(h-c)*R);}let m=s+1;for(let d=0;d<s;d++)for(let b=0;b<s;b++){let u=l+d*m+b;e.idx.push(u,u+m+1,u+1,u,u+m,u+m+1);}}function ri(e,t){let r=[t.size[0]/2,t.size[1]/2,t.size[2]/2],o=[(e[0]-t.pos[0])/r[0],(e[1]-t.pos[1])/r[1],(e[2]-t.pos[2])/r[2]],a=Math.max(Math.abs(o[0]),Math.abs(o[1]),Math.abs(o[2]));if(a<1e-6)return {p:e,w:0,s:[0,1,0]};let n=rn(tn(o[0]/a,o[1]/a,o[2]/a)),s=a<=no?1:Math.max(0,1-(a-no)/en),l=s*s*(3-2*s),i=[t.pos[0]+r[0]*n[0]*a,t.pos[1]+r[1]*n[1]*a,t.pos[2]+r[2]*n[2]*a];return {p:[e[0]+(i[0]-e[0])*l,e[1]+(i[1]-e[1])*l,e[2]+(i[2]-e[2])*l],w:l,s:n}}var oi=1.25,ai=.85;function ni(e,t,r){if(e.rot)return false;let o=(e.pos[1]+t[1]-r.pos[1])/(r.size[1]/2),a=Math.max(t[0]/(r.size[0]/2),t[2]/(r.size[2]/2));return o>oi&&a>=ai}function si(e,t){let r=t.size[0]/2,o=t.size[2]/2,a=(e[0]-t.pos[0])/r,n=(e[2]-t.pos[2])/o,s=Math.max(Math.abs(a),Math.abs(n));if(s<1e-6)return {p:e,w:0,s:[0,1,0]};let l=a/s,i=n/s,c=l*Math.sqrt(Math.max(0,1-i*i/2)),p=i*Math.sqrt(Math.max(0,1-l*l/2)),h=s<=no?1:Math.max(0,1-(s-no)/en),m=h*h*(3-2*h),d=t.pos[0]+r*c*s,b=t.pos[2]+o*p*s;return {p:[e[0]+(d-e[0])*m,e[1],e[2]+(b-e[2])*m],w:m,s:[c,0,p]}}function ii(e,t,r,o){let a=Er;for(let n=t;n<e.length;n+=3){let s=(e[n]+r[0]-o.pos[0])/(o.size[0]/2),l=(e[n+1]+r[1]-o.pos[1])/(o.size[1]/2),i=(e[n+2]+r[2]-o.pos[2])/(o.size[2]/2);if(Math.pow(Math.pow(s*s+i*i,a/2)+Math.pow(Math.abs(l),a),1/a)>.97)return false}return true}function li(e,t,r,o,a=false){let n=[o.size[0]/2,o.size[1]/2,o.size[2]/2];for(let s=t;s<e.pos.length;s+=3){let l=[e.pos[s]+r[0],e.pos[s+1]+r[1],e.pos[s+2]+r[2]],{p:i,w:c,s:p}=a?si(l,o):ri(l,o);if(e.pos[s]=i[0]-r[0],e.pos[s+1]=i[1]-r[1],e.pos[s+2]=i[2]-r[2],c<=0)continue;let h=[e.nrm[s],e.nrm[s+1],e.nrm[s+2]],m=[l[0]-o.pos[0],l[1]-o.pos[1],l[2]-o.pos[2]],d=Math.hypot(m[0],m[1],m[2])||1;if((h[0]*m[0]+h[1]*m[1]+h[2]*m[2])/d<.3||a&&Math.abs(h[1])>.7)continue;let b=Do(p,n),u=[h[0]+(b[0]-h[0])*c,h[1]+(b[1]-h[1])*c,h[2]+(b[2]-h[2])*c],R=Math.hypot(u[0],u[1],u[2])||1;e.nrm[s]=u[0]/R,e.nrm[s+1]=u[1]/R,e.nrm[s+2]=u[2]/R;}}var Fo=.16,ci=12,pi=12;function mi(e,t,r,o,a){let n=[t.size[0]/2,t.size[1]/2,t.size[2]/2],[s,l,i,c]=r,p=t.pos[0]+n[0]-s,h=t.pos[1]+n[1]-l,m=ci,d=pi,b=new Float32Array((m+1)*(d+1)*3),u=new Float32Array((m+1)*(d+1)*3),R=new Float32Array((m+1)*(d+1)*2),w=0;for(let k=0;k<=d;k++)for(let x=0;x<=m;x++){let f=x/m,S=k/d,T=p-i*f,C=h-c*S,z=(T-t.pos[0])/n[0],O=(C-t.pos[1])/n[1],M=Math.pow(Math.max(0,1-Math.pow(Math.min(1,Math.abs(O)),Er)),1/Er),V=-Math.sqrt(Math.max(.02,M*M-z*z)),q=Do([z,O,V],n);b[w*3]=T+q[0]*Fo-o[0],b[w*3+1]=C+q[1]*Fo-o[1],b[w*3+2]=t.pos[2]+n[2]*V+q[2]*Fo-o[2],u.set(q,w*3),R[w*2]=f,R[w*2+1]=S,w++;}let A=(k,x)=>[k-o[0],x-o[1],t.pos[2]-n[2]-o[2]];return {bone:e,corners:Float32Array.from([...A(p,h),...A(p-i,h),...A(p-i,h-c),...A(p,h-c)]),uv:a,grid:{cols:m,rows:d,positions:b,normals:u,t:R}}}function hi(e,t){if(!t)return e;let[r,o,a]=e,[n,s,l]=[-t[0]*or,-t[1]*or,-t[2]*or],i=Math.cos(n),c=Math.sin(n);return [o,a]=[o*i-a*c,o*c+a*i],i=Math.cos(s),c=Math.sin(s),[r,a]=[r*i+a*c,-r*c+a*i],i=Math.cos(l),c=Math.sin(l),[r,o]=[r*i-o*c,r*c+o*i],[r,o,a]}function di(e,t,r,o,a){for(let s of o){let l=[s.size[0]/2,s.size[1]/2,s.size[2]/2],i=Math.min(s.size[0],s.size[1],s.size[2])<Za?0:a,c=i>0?Math.min(l[0],l[1],l[2],i*Qa):0,p=true;for(let h=t;h<e.length&&p;h+=3){let m=hi([e[h]+r[0]-s.pos[0],e[h+1]+r[1]-s.pos[1],e[h+2]+r[2]-s.pos[2]],s.rot),d=Math.abs(m[0])-(l[0]-c),b=Math.abs(m[1])-(l[1]-c),u=Math.abs(m[2])-(l[2]-c);Math.hypot(Math.max(d,0),Math.max(b,0),Math.max(u,0))+Math.min(Math.max(d,b,u),0)-c>=-0.01&&(p=false);}if(p)return true}return false}function ui(e){let t=1;for(let r of Ae[e].defaultParts)t=Math.max(t,r.pos[1]+r.size[1]/2);return t}var No=new Map;function fi(e){let t=new Map;for(let i of e.bones){if(!i.indices.length){t.set(i.name,null);continue}let c=new D__namespace.BufferGeometry;c.setAttribute("position",new D__namespace.BufferAttribute(i.positions,3)),c.setAttribute("normal",new D__namespace.BufferAttribute(i.normals,3)),c.setAttribute("uv",new D__namespace.BufferAttribute(i.uvs,2)),c.setIndex(new D__namespace.BufferAttribute(i.indices,1)),c.computeBoundingSphere(),c.userData.shared=true,t.set(i.name,c);}let r=on(e.bones,e),o=new Map;for(let i of new Set(e.mats.map(c=>c.mat))){let c=e.mats.filter(h=>h.mat===i).map(h=>({...h,pivot:e.bones.find(m=>m.name===h.bone).pivot})),p=on(c,e);p&&o.set(i,p);}let{w:a,h:n,data:s}=e.atlas,l=new D__namespace.DataTexture(s,a,n,D__namespace.RGBAFormat);return l.magFilter=D__namespace.NearestFilter,l.minFilter=D__namespace.NearestFilter,l.generateMipmaps=false,l.colorSpace=D__namespace.SRGBColorSpace,l.needsUpdate=true,{layout:e,geometries:t,skinned:r,skinnedMats:o,texture:l,refs:0}}function on(e,t){let r=b=>t.bones.findIndex(u=>u.name===(b.bone??b.name)),o=0,a=0;for(let b of e)o+=b.positions.length/3,a+=b.indices.length;if(!a)return null;let n=new Float32Array(o*3),s=new Float32Array(o*3),l=new Float32Array(o*2),i=new Uint16Array(o*4),c=new Float32Array(o*4),p=o>65535?new Uint32Array(a):new Uint16Array(a),h=0,m=0;e.forEach(b=>{let u=r(b),R=b.positions.length/3;for(let w=0;w<R;w++)n[(h+w)*3]=b.positions[w*3]+b.pivot[0],n[(h+w)*3+1]=b.positions[w*3+1]+b.pivot[1],n[(h+w)*3+2]=b.positions[w*3+2]+b.pivot[2],i[(h+w)*4]=u,c[(h+w)*4]=1;s.set(b.normals,h*3),l.set(b.uvs,h*2);for(let w=0;w<b.indices.length;w++)p[m+w]=b.indices[w]+h;h+=R,m+=b.indices.length;});let d=new D__namespace.BufferGeometry;return d.setAttribute("position",new D__namespace.BufferAttribute(n,3)),d.setAttribute("normal",new D__namespace.BufferAttribute(s,3)),d.setAttribute("uv",new D__namespace.BufferAttribute(l,2)),d.setAttribute("skinIndex",new D__namespace.Uint16BufferAttribute(i,4)),d.setAttribute("skinWeight",new D__namespace.BufferAttribute(c,4)),d.setIndex(new D__namespace.BufferAttribute(p,1)),d.computeBoundingSphere(),d.userData.shared=true,d}function Ho(e){let t=No.get(rr(e));return t||(t=fi(Xa(e)),No.set(t.layout.hash,t)),t.refs++,t}function so(e){if(!(--e.refs>0)){No.delete(e.layout.hash);for(let t of e.geometries.values())t?.dispose();e.skinned?.dispose();for(let t of e.skinnedMats.values())t.dispose();e.texture.dispose();}}var U=class e{constructor(t,r,o="."){this.w=t;this.h=r;this.g=Array.from({length:r},()=>new Array(t).fill(o));}w;h;g;px(t,r,o){return t>=0&&r>=0&&t<this.w&&r<this.h&&(this.g[r][t]=o),this}rect(t,r,o,a,n){for(let s=r;s<r+a;s++)for(let l=t;l<t+o;l++)this.px(l,s,n);return this}row(t,r,o,a){return this.rect(r,t,o-r+1,1,a)}col(t,r,o,a){return this.rect(t,r,1,o-r+1,a)}where(t,r){for(let o=0;o<this.h;o++)for(let a=0;a<this.w;a++)t(a,o)&&this.px(a,o,r);return this}flipped(){let t=new e(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)t.px(this.w-1-o,r,this.g[r][o]);return t}tex(){return {w:this.w,h:this.h,rows:this.g.map(t=>t.join(""))}}};var bi={s:"#d9a982",S:"#bf8d68",h:"#6b4a2f",H:"#8a6644",k:"#3a2818",w:"#f4f4ef",b:"#3f8f9c",m:"#9a5544",o:"#4a2219",t:"#a7bea9",T:"#c4d6c4",D:"#84a08a",u:"#ece6d2",B:"#6a4e33",g:"#d8c48c",p:"#8c9ca6",P:"#6f808a",z:"#a07a55",Z:"#7c5c3f",l:"#e9e3cf"};function at(e,t){let r=parseInt(e.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(a=>Math.max(0,Math.min(255,Math.round(a*t)))).map(a=>a.toString(16).padStart(2,"0")).join("")}function Go(e,t){let r={...e};return t.skin&&(r.s=t.skin,r.S=at(t.skin,.86),r.m=at(t.skin,.66)),t.hair&&(r.h=t.hair,r.H=at(t.hair,1.25),r.k=at(t.hair,.6)),t.shirt&&(r.t=t.shirt,r.T=at(t.shirt,1.15),r.D=at(t.shirt,.8)),t.pants&&(r.p=t.pants,r.P=at(t.pants,.8)),t.boots&&(r.z=t.boots,r.Z=at(t.boots,.78)),t.eyes&&(r.b=t.eyes),r}var yi=new U(16,16,"s").rect(0,0,16,3,"h").row(3,0,4,"h").row(3,10,15,"h").row(4,0,1,"h").row(4,13,15,"h").col(0,5,8,"h").col(15,5,8,"h").row(1,3,6,"H").row(1,9,12,"H").row(15,2,13,"S"),an=new U(16,16,"s").rect(0,0,16,4,"h").rect(7,4,9,7,"h").rect(10,11,6,2,"h").rect(5,7,2,3,"S").row(1,2,13,"H").where((e,t)=>t>4&&t<11&&e>8&&(e+t)%4===0,"k"),gi=an.flipped(),xi=new U(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>t>8&&(e*3+t)%7===0,"k").rect(4,14,8,2,"s"),wi=new U(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>(3*e+t)%9===0,"k"),Ri=new U(18,4,"h").where((e,t)=>(e*7+t*3)%5===0,"H").where((e,t)=>t===3&&e*5%3===0,"k"),ki=new U(16,24,"t").row(0,6,9,"s").row(1,7,8,"s").row(0,3,5,"T").row(0,10,12,"T").row(1,4,6,"T").row(1,9,11,"T").row(2,5,6,"T").row(2,9,10,"T").col(8,2,19,"D").px(7,5,"u").px(7,9,"u").px(7,13,"u").px(7,17,"u").row(6,2,5,"D").col(2,7,10,"D").col(5,7,10,"D").row(10,2,5,"D").px(4,7,"u").row(6,10,13,"D").col(10,7,10,"D").col(13,7,10,"D").row(10,10,13,"D").px(11,7,"u").row(19,0,15,"D").rect(0,20,16,2,"B").rect(7,20,2,2,"g").rect(0,22,16,2,"p"),vi=new U(16,24,"t").row(5,0,15,"D").col(8,6,19,"D").row(19,0,15,"D").rect(0,20,16,2,"B").rect(0,22,16,2,"p"),Ai=new U(8,24,"t").col(4,0,19,"D").row(19,0,7,"D").rect(0,20,8,2,"B").rect(0,22,8,2,"p"),Ei=new U(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),Si=new U(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),Ti=new U(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),Mi=new U(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),Li=new U(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),Ci=new U(8,24,"p").col(3,0,21,"P"),Pi=new U(10,9,"z").row(0,0,9,"Z").row(2,3,6,"l").row(4,3,6,"l").row(6,3,6,"l").col(2,1,6,"Z").col(7,1,6,"Z").rect(0,7,10,2,"Z"),zi=new U(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function Xe(e){let t=new U(16,10,"."),r=(a,n,s)=>{if(e.brows==="flat")t.row(1,a,a+2,"k");else if(e.brows==="high")t.row(0,a,a+2,"k");else {let l=e.brows==="down"?1:0,i=1-l;t.px(n,l,"k").px(a+1,e.brows==="down"?0:1,"k"),t.px(s,i,"k");}};r(3,5,3),r(10,10,12);let o=a=>{if(e.eyes===0){t.row(3,a,a+2,"k");return}let n=e.eyes===3||e.eyes===2?2:3;for(let s=n;s<n+e.eyes;s++)t.px(a,s,"w").px(a+1,s,"b").px(a+2,s,"w");};switch(o(3),o(10),e.mouth){case "line":t.row(7,6,9,"m");break;case "smile":t.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":t.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":t.rect(6,7,4,2,"o");break;case "small":t.rect(7,7,2,2,"o");break;case "wide":t.row(7,5,10,"m").rect(6,8,4,1,"o");break}return t}var nn={f_neutral:Xe({brows:"flat",eyes:2,mouth:"line"}),f_blink:Xe({brows:"flat",eyes:0,mouth:"line"}),f_happy:Xe({brows:"high",eyes:2,mouth:"smile"}),f_sad:Xe({brows:"up",eyes:2,mouth:"frown"}),f_angry:Xe({brows:"down",eyes:1,mouth:"wide"}),f_surprised:Xe({brows:"high",eyes:3,mouth:"small"}),f_scared:Xe({brows:"up",eyes:3,mouth:"open"}),f_tired:Xe({brows:"flat",eyes:1,mouth:"line"}),f_hurt:Xe({brows:"down",eyes:0,mouth:"open"}),f_talk:Xe({brows:"flat",eyes:2,mouth:"open"})},Ii=new U(16,24,"t").row(0,5,10,"s").row(1,6,9,"s").px(5,1,"T").px(10,1,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),Oi=new U(16,24,"t").row(0,5,10,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),_i=new U(8,24,"t").row(7,0,7,"D").row(10,0,7,"D").rect(0,18,8,2,"T").rect(0,20,8,4,"p").row(20,0,7,"P"),Vi=new U(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),io=(e,t)=>e.row(t-1,0,e.w-1,"D").where((r,o)=>o>=t&&o<=t+3&&(r+o)%2===0,"T").row(t+4,0,e.w-1,"D"),Fi=io(new U(16,24,"t"),6).row(0,6,9,"s").row(0,4,5,"T").row(0,10,11,"T").row(1,4,11,"T").where((e,t)=>t>=18&&t<=19&&e%2===0,"D").where((e,t)=>t>=18&&t<=19&&e%2===1,"T").rect(0,20,16,4,"p"),Bi=io(new U(16,24,"t"),6).row(0,4,11,"T").where((e,t)=>t>=18&&t<=19,"D").rect(0,20,16,4,"p"),Di=io(new U(8,24,"t"),6).where((e,t)=>t>=18&&t<=19,"D").rect(0,20,8,4,"p"),Ni=io(new U(8,22,"t"),9).where((e,t)=>t>=19&&e%2===0,"D"),sn=e=>new U(8,24,"s").rect(0,0,8,12,"p").col(e,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),Hi=sn(4),ji=sn(3),Gi=new U(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),qi=new U(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),Ui=new U(17,6,"a").rect(0,4,17,2,"A"),Ki=new U(22,22,"a").where((e,t)=>(e*3+t*5)%11===0,"A"),Yi=new U(17,20,"h").where((e,t)=>(e*5+t)%4===0,"H").where((e,t)=>t>10&&(e*3+t*2)%7===0,"k"),X=e=>e.tex(),ln=["shirt","tee","sweater"],cn=["pants","shorts"],pn=["boots","sneakers"],E1=["short","long","curly","none"],Ot=(e,t={})=>({front:e,back:e,left:e,right:e,...t});function qo(e={}){let t=e.top??"shirt",r=e.bottom??"pants",o=e.shoes??"boots",a=e.hair??"short",n=Go(bi,e.colors??{});n={...n,a:e.colors?.hat??"#d9c9a3"},n.A=at(n.a,.72);let s={head_front:X(yi),head_left:X(an),head_right:X(gi),head_back:X(xi),hair_top:X(wi),hair_band:X(Ri),arm_skin:X(Si),...Object.fromEntries(Object.entries(nn).map(([b,u])=>[b,X(u)]))},l=[{name:"head",bone:"head",size:[8,8,8],pos:[0,28,0],color:"s",faces:{front:"head_front",left:"head_left",right:"head_right",back:"head_back",top:"hair_top"}},{name:"nose",bone:"head",size:[1,1.5,.8],pos:[0,26.9,-4.4],color:"S",faces:{front:"s"}}];if(a!=="none"){if(e.hat||l.push({name:"hair",bone:"head",size:a==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,a==="curly"?32.5:32.2,.15],color:"h",faces:Ot("hair_band",{top:"hair_top"})}),a==="curly"&&!e.hat)for(let[b,u]of [[-2,-1.5],[2,.5],[-0.5,2.5]])l.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[b,33.9,u],color:"h",faces:Ot("hair_band",{top:"hair_top"})});a==="long"?(s.hair_long=X(Yi),l.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:Ot("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:Ot("hair_long",{top:"hair_top"}),mirror:true})):l.push({name:"hairBack",bone:"head",size:[8.6,5,.8],pos:[0,29.6,4.25],color:"h",faces:{back:"head_back",left:"hair_band",right:"hair_band"}});}e.hat&&(s.hat_crown=X(Ui),s.hat_brim=X(Ki),l.push({name:"hatBrim",bone:"head",size:[11,.8,11],pos:[0,32.4,0],color:"a",faces:{top:"hat_brim",bottom:"hat_brim"}},{name:"hatCrown",bone:"head",size:[8.4,3,8.4],pos:[0,34.3,0],color:"a",faces:Ot("hat_crown")}));let i={shirt:[ki,vi,Ai],tee:[Ii,Oi,_i],sweater:[Fi,Bi,Di]},[c,p,h]=i[t];s.top_front=X(c),s.top_back=X(p),s.top_side=X(h),l.push({name:"torso",bone:"body",size:[8,12,4],pos:[0,18,0],color:"t",faces:{front:"top_front",back:"top_back",left:"top_side",right:"top_side",bottom:"p"}}),t==="shirt"&&(s.belt=X(Ei),l.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),l.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:Ot("arm_skin",{top:"t",bottom:"S"}),mirror:true});let m=t==="sweater"?11:t==="tee"?4.5:6.5;s.sleeve=X(t==="sweater"?Ni:t==="tee"?Vi:Ti),l.push({name:"sleeve",bone:"armL",size:[3.6,m,3.6],pos:[-5.5,24-m/2,0],color:"t",faces:Ot("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(s.leg_front=X(Hi),s.leg_side=X(ji)):(s.leg_front=X(Mi),s.leg_back=X(Li),s.leg_side=X(Ci)),l.push({name:"leg",bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p",faces:{front:"leg_front",back:r==="shorts"?"leg_front":"leg_back",left:"leg_side",right:"leg_side"},mirror:true}),o==="boots"?(s.shoe_front=X(Pi),s.shoe_side=X(zi)):(s.shoe_front=X(Gi),s.shoe_side=X(qi));let d=o==="boots"?4.5:2.5;return l.push({name:"shoe",bone:"legL",size:[4.6,d,5.2],pos:[-2,d/2,-0.3],color:"z",faces:{front:"shoe_front",back:"shoe_side",left:"shoe_side",right:"shoe_side",bottom:"Z"},mirror:true}),{version:1,name:e.name??ee({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:e.description??ee({en:"A traveler in a shirt with pockets, trousers and laced boots",ru:"\u041F\u0443\u0442\u043D\u0438\u043A \u0432 \u0440\u0443\u0431\u0430\u0448\u043A\u0435 \u0441 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u043C\u0438, \u0431\u0440\u044E\u043A\u0430\u0445 \u0438 \u0448\u043D\u0443\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0431\u043E\u0442\u0438\u043D\u043A\u0430\u0445"}),rig:"humanoid",palette:n,textures:s,parts:l,face:{bone:"head",rect:[0,3,8,5],expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}},style:{walk:"normal",idle:"calm",energy:.5},finish:{noise:.5,outline:.4,shade:.25,density:2},tags:e.tags??["player"]}}function Sr(e,t){return {textures:Object.fromEntries(Object.entries(nn).map(([r,o])=>[r,X(o)])),face:{bone:e,rect:t,expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}}}}var Uo=qo(),jo=null;function _t(){if(!jo){let e=Ye(Uo);if(!e.ok)throw new Error(e.error);jo=e.spec;}return jo}function mn(e){let t=document.createElement("canvas");t.width=256,t.height=48;let r=t.getContext("2d");r&&(r.fillStyle="rgba(0,0,0,0.45)",r.fillRect(0,0,256,48),r.font="bold 28px sans-serif",r.fillStyle="#fff",r.textAlign="center",r.textBaseline="middle",r.fillText(e.slice(0,18),128,25));let o=new D__namespace.CanvasTexture(t),a=new D__namespace.Sprite(new D__namespace.SpriteMaterial({map:o,depthTest:false,transparent:true}));return a.scale.set(1.6,.3,1),a.renderOrder=10,a}function Ko(e){e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();}var I={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},M1=Object.keys(I),sr=[0,0,0,0,0,0,1,1,1];function ae(e,t){let r=e.get(t);return r||(r=Float64Array.from(sr),e.set(t,r)),r}function de(e,t,r,o){let a=ae(e,t),n=I[r];n>=6?a[n]=a[n]*o:a[n]=a[n]+o;}function y(e,t,r,o){ae(e,t)[I[r]]=o;}function bt(e){for(let t of e.values())t.set(sr);}function hn(e,t,r,o){let a=new Set([...t.keys(),...r.keys()]);for(let n of a){let s=t.get(n)??sr,l=r.get(n)??sr,i=ae(e,n);for(let c=0;c<9;c++)i[c]=s[c]+(l[c]-s[c])*o;}}function Be(e,t){bt(e);for(let[r,o]of t)ae(e,r).set(o);}var L1=["none","block","tool","sword","bow","shield","food","staff","item","pistol","rifle"];function lo(){return {speed:0,vy:0,onGround:true,inWater:false,flying:false,gliding:false,sneaking:false,sprinting:false,riding:false,sitting:false,sleeping:false,dead:false,lookYaw:0,lookPitch:0,yawRate:0,held:"none",aiming:false,use:null,talk:false}}var C1=["swing","hurt","place","land","jump","throw","shoot","punch"];var gt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],ue=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Ft=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],yt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Vt=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],He=e=>Math.hypot(e[0],e[1],e[2]),nt=(e,t)=>He(ue(e,t)),Tr=(e,t,r)=>[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]+(t[2]-e[2])*r];function ir(e){let t=He(e);return t>1e-12?[e[0]/t,e[1]/t,e[2]/t]:[0,0,0]}var xe=(e,t,r)=>Math.max(t,Math.min(r,e)),Yo=[1,0,0,0,1,0,0,0,1];function De(e,t){return [e[0]*t[0]+e[1]*t[3]+e[2]*t[6],e[0]*t[1]+e[1]*t[4]+e[2]*t[7],e[0]*t[2]+e[1]*t[5]+e[2]*t[8],e[3]*t[0]+e[4]*t[3]+e[5]*t[6],e[3]*t[1]+e[4]*t[4]+e[5]*t[7],e[3]*t[2]+e[4]*t[5]+e[5]*t[8],e[6]*t[0]+e[7]*t[3]+e[8]*t[6],e[6]*t[1]+e[7]*t[4]+e[8]*t[7],e[6]*t[2]+e[7]*t[5]+e[8]*t[8]]}function ne(e,t){return [e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}var xt=e=>[e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]];function Qe(e,t,r){let o=Math.cos(e),a=Math.sin(e),n=Math.cos(t),s=Math.sin(t),l=Math.cos(r),i=Math.sin(r),c=o*l,p=o*i,h=a*l,m=a*i;return [n*l,-n*i,s,p+h*s,c-m*s,-a*n,m-c*s,h+p*s,o*n]}function Bt(e){let t=Math.asin(xe(e[2],-1,1));return Math.abs(e[2])<.9999999?[Math.atan2(-e[5],e[8]),t,Math.atan2(-e[1],e[0])]:[Math.atan2(e[7],e[4]),t,0]}function co(e,t){let[r,o,a]=e,n=Math.cos(t),s=Math.sin(t),l=1-n;return [l*r*r+n,l*r*o-s*a,l*r*a+s*o,l*r*o+s*a,l*o*o+n,l*o*a-s*r,l*r*a-s*o,l*o*a+s*r,l*a*a+n]}function Wo(e,t){let r=ir(e),o=ir(t),a=xe(yt(r,o),-1,1),n=Vt(r,o),s=He(n);if(s<1e-9){if(a>0)return [...Yo];let l=Math.abs(r[0])<.9?Vt(r,[1,0,0]):Vt(r,[0,1,0]);return co(ir(l),Math.PI)}return co(Ft(n,1/s),Math.atan2(s,a))}function dn(e,t,r){return Math.atan2(yt(Vt(e,t),r),yt(e,t))}function Mr(e){let t=Math.PI*2;return e=(e%t+t)%t,e>Math.PI?e-t:e}function po(e,t,r,o,a){if(a<=0)return e;if(o<=1e-6)return t.v=0,r;let n=2/o,s=n*a,l=1/(1+s+.48*s*s+.235*s*s*s),i=e-r,c=(t.v+n*i)*a;return t.v=(t.v-n*c)*l,r+(i+c)*l}var un=Float64Array.from([0,0,0,0,0,0,1,1,1]);function We(e,t){let r=new Map(e.map(i=>[i.name,i])),o=new Map,a=t.get("root")??un,n=Qe(a[I.rx],a[I.ry],a[I.rz]),s={pos:[a[I.px],a[I.py],a[I.pz]],lin:n,rot:n},l=i=>{let c=o.get(i.name);if(c)return c;let p=i.parent?r.get(i.parent):void 0,h=p?l(p):s,m=p?p.pivot:[0,0,0],d=t.get(i.role)??un,b=[i.pivot[0]-m[0]+d[I.px],i.pivot[1]-m[1]+d[I.py],i.pivot[2]-m[2]+d[I.pz]],u=Qe(d[I.rx],d[I.ry],d[I.rz]),R=[d[I.sx],0,0,0,d[I.sy],0,0,0,d[I.sz]],w={pos:gt(h.pos,ne(h.lin,b)),lin:De(h.lin,De(u,R)),rot:De(h.rot,u),parentRot:h.rot};return o.set(i.name,w),w};for(let i of e)l(i);return o}function Dt(e,t){return gt(e.pos,ne(e.lin,t))}var $o=.04;function fn(e,t,r,o){let[a,n,s]=Bt(De(xt(r.parentRot),o)),l=ae(e,t);l[I.rx]=a,l[I.ry]=n,l[I.rz]=s;}function Wi(e,t){let r=$o*t,o=t-r;return e<=o||r<=0?e:o+r*(1-Math.exp(-(e-o)/r))}function Jo(e,t,r){let o=t.upper.node.pos,a=t.lower.node.pos,n=t.end,s=ue(o,a),l=ue(n,a),i=He(s),c=He(l);if(i<1e-9||c<1e-9)return n;let p=ir(ne(t.lower.node.parentRot,[1,0,0])),h=Ft(p,yt(s,p)),m=Ft(p,yt(l,p)),d=ue(s,h),b=ue(l,m),u=He(d),R=He(b),w=nt(o,r),A=nt(o,n),k=w<=A?w:Math.max(A,Wi(w,Math.hypot(He(ue(m,h)),u+R))),x=e.get(t.lower.role)?.[I.rx]??0,f=0;if(u>1e-9&&R>1e-9){let C=dn(d,b,p),z=(i*i+c*c-k*k)/2-yt(h,m),O=xe(z/(u*R),-1,1),M=Math.acos(O),[V,q]=t.bend,Y=v=>{let _=v-x,F=gt(m,gt(Ft(b,Math.cos(_)),Ft(Vt(p,b),Math.sin(_))));return Math.abs(He(ue(F,s))-k)},pe=[Mr(M-C),Mr(-M-C)].flatMap(v=>{let _=x+v;return [_,xe(_,V,q)]}),me=xe(x,V,q),ie=Y(me);for(let v of pe){if(v<V-1e-9||v>q+1e-9)continue;let _=Y(v);(_<ie-1e-6||Math.abs(_-ie)<=1e-6&&Math.abs(v-x)<Math.abs(me-x))&&(me=v,ie=_);}f=me-x;}ae(e,t.lower.role)[I.rx]=x+f;let S=gt(a,ne(co(p,f),l)),T=Wo(ue(S,o),ue(r,o));return fn(e,t.upper.role,t.upper.node,De(T,t.upper.node.rot)),gt(o,ne(T,ue(S,o)))}function bn(e,t,r,o,a){let n=r.pos,s=ir(ne(r.parentRot,[1,0,0])),l=ue(o,n),i=Ft(s,yt(l,s)),c=ue(l,i),p=Vt(s,c),h=i[1],m=c[1],d=p[1],b=Math.hypot(m,d);if(b<1e-9)return;let u=Math.atan2(d,m),R=xe((a-n[1]-h)/b,-1,1),w=Math.acos(R),A=Mr(u+w),k=Mr(u-w),x=Math.abs(A)<=Math.abs(k)?A:k;ae(e,t)[I.rx]=(e.get(t)?.[I.rx]??0)+x;}function yn(e,t,r,o,a){let n=Wo(ue(o,r.pos),ue(a,r.pos));fn(e,t,r,De(n,r.rot));}var $i=.25,gn=.07,Ji=.22,Xi=.12,Qi=.28,Zi=.6,mo=.45,xn=.03,e0=.2,t0=.2,r0=.12,Lr=(e,t,r)=>xe(e+(t?r:-r)/$i,0,1),wt=e=>e*e*(3-2*e),wn=(e,t,r)=>{e[t]=e[t]+r;},Cr=class{ik;bones;feet=[];hands={};out=new Map;thigh;plant=0;wLook=0;lookAt=null;lookV=[{v:0},{v:0},{v:0}];wSeat=0;lastSeat=null;pelvis=0;pelvisV={v:0};wHand={handR:0,handL:0};lastHand={handR:null,handL:null};wLock=0;constructor(t){this.ik=Ae[t.rig].ik??{},this.bones=t.bones.map(l=>({name:l.name,role:l.role,parent:l.parent,pivot:l.pivot}));let r=We(this.bones,new Map),o=l=>t.bones.find(i=>i.role===l),a=l=>{let i=o(l.upper),c=l.lower?o(l.lower):void 0;if(!i||l.lower&&!c)return null;let p=c??i,h=p.name,m;if(l.end==="sole"){let w=0;for(let A=1;A<p.positions.length;A+=3)w=Math.min(w,p.positions[A]);m=[0,w,0];}else {let w=t.sockets.find(A=>A.name===l.end);if(!w)return null;h=w.bone,m=w.at;}let d=r.get(i.name).pos,b=Dt(r.get(h),m),u=c?nt(d,r.get(c.name).pos)+nt(r.get(c.name).pos,b):nt(d,b),R=w=>({name:w.name,role:w.role,parent:w.parent,pivot:w.pivot});return {def:l,upper:R(i),lower:c?R(c):null,endBone:h,endAt:m,length:u}};for(let l of this.ik.feet??[]){let i=a(l);i&&this.feet.push({...i,g:0,gv:{v:0},lock:null,lockYaw:0,step:null});}for(let l of ["handR","handL"]){let i=this.ik.hands?.[l],c=i&&a(i);c&&(this.hands[l]=c);}let n=2,s=this.feet[0]&&t.bones.find(l=>l.name===this.feet[0].upper.name);if(s&&s.positions.length){let l=1/0,i=-1/0;for(let c=0;c<s.positions.length;c+=3)l=Math.min(l,s.positions[c]),i=Math.max(i,s.positions[c]);n=(i-l)/2;}this.thigh=n;}supports(t){return t==="look"?!!this.ik.look:t==="ground"||t==="seat"?this.feet.length>0:!!this.hands[t]}solve(t,r){let o=Math.max(0,Math.min(r.dt,.1)),a=!!r.ground&&this.feet.length>0;if(this.plant=a?xe(this.plant+(r.plant-this.plant)*Math.min(1,o/.12),0,1):Lr(this.plant,false,o),!a&&this.plant===0&&this.resetFeet(),this.wLook=this.ik.look?Lr(this.wLook,!!r.look,o):0,r.look){let m=this.lookAt;this.lookAt=m?[0,1,2].map(d=>po(m[d],this.lookV[d],r.look[d],r0,o)):[...r.look];}else this.wLook===0&&(this.lookAt=null);this.wSeat=this.feet.length?Lr(this.wSeat,!!r.seat,o):0,r.seat&&(this.lastSeat=r.seat);for(let m of ["handR","handL"])this.wHand[m]=this.hands[m]?Lr(this.wHand[m],!!r[m],o):0,r[m]&&(this.lastHand[m]=r[m]);if(this.plant===0&&this.wLook===0&&this.wSeat===0&&this.wHand.handR===0&&this.wHand.handL===0)return t;let n=this.out;Be(n,t);let s=We(this.bones,n),l=m=>s.get(m),i=this.feet.map(m=>Dt(l(m.endBone),m.endAt)),c=wt(this.wSeat);if(c>0&&this.lastSeat){let m=this.feet.slice(0,2).map(w=>l(w.upper.name).pos),d=m.length===2?Tr(m[0],m[1],.5):m[0],b=[d[0],d[1]-this.thigh,d[2]],u=ue(this.lastSeat,b),R=ae(n,"root");R[I.px]=R[I.px]+u[0]*c,R[I.py]=R[I.py]+u[1]*c,R[I.pz]=R[I.pz]+u[2]*c;}let p=wt(this.plant);p>0&&(s=this.ground(n,s,i,r,p,c,o));let h=wt(this.wLook);h>0&&this.lookAt&&this.ik.look&&(s=this.look(n,s,this.lookAt,h));for(let m of ["handR","handL"]){let d=this.hands[m],b=wt(this.wHand[m]),u=this.lastHand[m];if(!d||b===0||!u)continue;s=We(this.bones,n);let R=Dt(s.get(d.endBone),d.endAt),w=Tr(R,u,b);d.lower?Jo(n,{upper:{role:d.upper.role,node:s.get(d.upper.name)},lower:{role:d.lower.role,node:s.get(d.lower.name)},end:R,bend:d.def.bend??[-Math.PI,Math.PI]},w):yn(n,d.upper.role,s.get(d.upper.name),R,w);}return n}reset(){this.resetFeet(),this.pelvis=0,this.pelvisV.v=0,this.lookAt=null;for(let t of this.lookV)t.v=0;}resetFeet(){for(let t of this.feet)t.g=0,t.gv.v=0,t.lock=null,t.step=null;this.wLock=0;}ground(t,r,o,a,n,s,l){let i=s===0&&a.standing&&this.feet.every(x=>x.lower);if(this.wLock=Lr(this.wLock,i,l),!i&&this.wLock===0)for(let x of this.feet)x.lock=null,x.step=null;let c=this.feet.some(x=>x.step),p=a.toWorld([0,0,0]),h=a.toWorld([0,0,-1]),m=Math.atan2(h[0]-p[0],h[2]-p[2]),d=[];for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=o[x],T=S[0],C=S[2],z=0;if(i||this.wLock>0){let O=a.toWorld(S),M=wt(this.wLock);if(!f.lock&&!f.step&&(f.lock=O,f.lockYaw=m),f.step){f.step.t=Math.min(1,f.step.t+l/Ji);let V=f.step.t,q=a.toModel(Tr(f.step.from,O,wt(V)));T+=(q[0]-T)*M,C+=(q[2]-C)*M,z=Math.sin(Math.PI*V)*Xi*f.length*M,V>=1&&(f.lock=O,f.lockYaw=m,f.step=null);}else if(f.lock){let V=a.toModel(f.lock),q=Math.abs(Math.atan2(Math.sin(m-f.lockYaw),Math.cos(m-f.lockYaw)));i&&!c&&(q>Zi||Math.hypot(V[0]-T,V[2]-C)>Qi*f.length)&&(f.step={from:f.lock,t:0},f.lock=null),T+=(V[0]-T)*M,C+=(V[2]-C)*M;}}d.push({x:T,z:C,arc:z});}let b=Math.max(...this.feet.map(x=>x.length));for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=a.ground?a.ground(d[x].x,0,d[x].z):0;S!==null&&S<-mo*b&&(S=null),f.g=po(f.g,f.gv,S??f.g,gn,l);}let u=this.ik.tilt,R=ae(t,"root");if(u){let x=(M,V)=>{let q=this.feet.map((Y,pe)=>M.includes(Y.upper.role)?pe:-1).filter(Y=>Y>=0);return q.length?q.reduce((Y,pe)=>Y+V(this.feet[pe],pe),0)/q.length:0},f=x(u.front,M=>M.g),S=x(u.back,M=>M.g),T=x(u.front,(M,V)=>o[V][2]),C=x(u.back,(M,V)=>o[V][2]),z=Math.max(1,Math.abs(C-T)),O=xe(Math.atan2(f-S,z),-u.max,u.max);R[I.rx]=R[I.rx]+O*n*(1-s),R[I.py]=R[I.py]+(f+S)/2*n*(1-s);}else {let x=this.feet.map(z=>z.g),f=Math.min(...x),S=x.reduce((z,O)=>z+O,0)/x.length,T=this.feet.every(z=>z.lower)?1-wt(this.wLock):0,C=xe(f+(S-f)*T,-mo*b,mo*b)*(1-s);this.pelvis=po(this.pelvis,this.pelvisV,C,gn,l),R[I.py]=R[I.py]+this.pelvis*n;}r=We(this.bones,t);let w=x=>this.feet.map((f,S)=>{let T=Math.max(0,o[S][1]),C=T+f.g+d[S].arc,z=Dt(x.get(f.endBone),f.endAt)[1],O=Math.max(z,f.g),M=1-wt(xe((T-xn*f.length)/((e0-xn)*f.length),0,1)),V=O+(C-O)*M,q=Math.max(f.g,z-t0*f.length);return [d[S].x,V+(q-V)*s,d[S].z]}),A=w(r),k=0;this.feet.forEach((x,f)=>{if(!x.lower)return;let S=r.get(x.upper.name).pos,T=A[f],C=Math.max(nt(S,Dt(r.get(x.endBone),x.endAt)),x.length*(1-$o)),z=Math.hypot(T[0]-S[0],T[2]-S[2]);z>=C||(k=Math.max(k,S[1]-T[1]-Math.sqrt(C*C-z*z)));}),k>0&&(wn(R,I.py,-Math.min(k,mo*b)*n*(1-s)),r=We(this.bones,t),A=w(r));for(let x=0;x<this.feet.length;x++){let f=this.feet[x],S=Dt(r.get(f.endBone),f.endAt),T=Tr(S,A[x],n);nt(T,S)<1e-6||(f.lower?Jo(t,{upper:{role:f.upper.role,node:r.get(f.upper.name)},lower:{role:f.lower.role,node:r.get(f.lower.name)},end:S,bend:f.def.bend??[-Math.PI,Math.PI]},T):bn(t,f.upper.role,r.get(f.upper.name),S,T[1]));}return We(this.bones,t)}look(t,r,o,a){let n=this.ik.look,s=this.bones.find(h=>h.role===n.head);if(!s)return r;let l=h=>{let m=ne(xt(h.parentRot),ue(o,h.pos));return [Math.atan2(-m[0],-m[2]),Math.atan2(m[1],Math.hypot(m[0],m[2]))]};if(He(ue(o,r.get(s.name).pos))<1e-6)return r;let[i,c]=l(r.get(s.name));if(n.body&&n.bodyYaw>0&&this.bones.some(h=>h.role===n.body)){let h=xe(Math.abs(i)-n.headYaw,0,n.bodyYaw)*Math.sign(i);h!==0&&(wn(ae(t,n.body),I.ry,h*a),r=We(this.bones,t),[i,c]=l(r.get(s.name)));}let p=ae(t,n.head);return p[I.ry]=p[I.ry]+(xe(i,-n.headYaw,n.headYaw)-p[I.ry])*a,p[I.rx]=p[I.rx]+(xe(c,-n.headPitch,n.headPitch)-p[I.rx])*a,We(this.bones,t)}};var Ze=(e,t)=>[e[3]*t[0]+e[0]*t[3]+e[1]*t[2]-e[2]*t[1],e[3]*t[1]-e[0]*t[2]+e[1]*t[3]+e[2]*t[0],e[3]*t[2]+e[0]*t[1]-e[1]*t[0]+e[2]*t[3],e[3]*t[3]-e[0]*t[0]-e[1]*t[1]-e[2]*t[2]],it=e=>[-e[0],-e[1],-e[2],e[3]];function Zo(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]);return t>0?[e[0]/t,e[1]/t,e[2]/t,e[3]/t]:[0,0,0,1]}function se(e,t){let[r,o,a,n]=e,s=2*(o*t[2]-a*t[1]),l=2*(a*t[0]-r*t[2]),i=2*(r*t[1]-o*t[0]);return [t[0]+n*s+(o*i-a*l),t[1]+n*l+(a*s-r*i),t[2]+n*i+(r*l-o*s)]}var Xo=(e,t)=>se(it(e),t);function ea(e){let[t,r,o,a]=e;return [1-2*(r*r+o*o),2*(t*r-o*a),2*(t*o+r*a),2*(t*r+o*a),1-2*(t*t+o*o),2*(r*o-t*a),2*(t*o-r*a),2*(r*o+t*a),1-2*(t*t+r*r)]}function fo(e){let t=e[0]+e[4]+e[8],r;if(t>0){let o=Math.sqrt(t+1)*2;r=[(e[7]-e[5])/o,(e[2]-e[6])/o,(e[3]-e[1])/o,.25*o];}else if(e[0]>e[4]&&e[0]>e[8]){let o=Math.sqrt(1+e[0]-e[4]-e[8])*2;r=[.25*o,(e[1]+e[3])/o,(e[2]+e[6])/o,(e[7]-e[5])/o];}else if(e[4]>e[8]){let o=Math.sqrt(1+e[4]-e[0]-e[8])*2;r=[(e[1]+e[3])/o,.25*o,(e[5]+e[7])/o,(e[2]-e[6])/o];}else {let o=Math.sqrt(1+e[8]-e[0]-e[4])*2;r=[(e[2]+e[6])/o,(e[5]+e[7])/o,.25*o,(e[3]-e[1])/o];}return Zo(r)}function En(e,t,r){let o=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],a=o<0?[-t[0],-t[1],-t[2],-t[3]]:t;if(o=Math.abs(o),o>.9995)return Zo([e[0]+(a[0]-e[0])*r,e[1]+(a[1]-e[1])*r,e[2]+(a[2]-e[2])*r,e[3]+(a[3]-e[3])*r]);let n=Math.acos(o),s=Math.sin((1-r)*n)/Math.sin(n),l=Math.sin(r*n)/Math.sin(n);return [e[0]*s+a[0]*l,e[1]*s+a[1]*l,e[2]*s+a[2]*l,e[3]*s+a[3]*l]}var Oe=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Ee=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],re=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],we=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],st=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Nt=e=>Math.sqrt(we(e,e));function Rn(e){let t=Nt(e);return t>1e-12?[e[0]/t,e[1]/t,e[2]/t]:[0,0,0]}function ta(e,t,r){let o=8*e[0]*e[1]*e[2],a=4*e[0]*e[0],n=4*e[1]*e[1],s=4*e[2]*e[2];return {x:t,q:r,v:[0,0,0],w:[0,0,0],px:t,pq:r,im:1/o,ii:[12/(o*(n+s)),12/(o*(a+s)),12/(o*(a+n))],half:e}}function Rt(e,t){let r=Xo(e.q,t);return se(e.q,[r[0]*e.ii[0],r[1]*e.ii[1],r[2]*e.ii[2]])}function lr(e,t,r){let[o,a,n]=t,s=e.q,l=Ze([o*.5*r,a*.5*r,n*.5*r,0],s);e.q=Zo([s[0]+l[0],s[1]+l[1],s[2]+l[2],s[3]+l[3]]);}function ho(e,t,r,o,a){let n=Nt(a);if(n<1e-9)return 0;let s=re(a,1/n),l=st(t,s),i=e.im+we(l,Rt(e,l));if(r){let p=st(o,s);i+=r.im+we(p,Rt(r,p));}if(i<=0)return 0;let c=re(s,-n/i);return e.x=Oe(e.x,re(c,e.im)),lr(e,Rt(e,st(t,c)),1),r&&(r.x=Ee(r.x,re(c,r.im)),lr(r,Rt(r,st(o,c)),-1)),n}function Pr(e,t,r){let o=Nt(r);if(o<1e-9)return;let a=re(r,1/o),n=we(a,Rt(e,a));if(t&&(n+=we(a,Rt(t,a))),n<=0)return;let s=re(r,1/n);lr(e,Rt(e,s),1),t&&lr(t,Rt(t,s),-1);}var Qo=[];for(let e of [-1,1])for(let t of [-1,1])for(let r of [-1,1])Qo.push([e,t,r]);var Sn=[];for(let e of [-1,0,1])for(let t of [-1,0,1])for(let r of [-1,0,1])(e||t||r)&&Sn.push([e,t,r]);var Tn=[];for(let e of Qo)for(let t of Qo)e<t&&(e[0]!==t[0]?1:0)+(e[1]!==t[1]?1:0)+(e[2]!==t[2]?1:0)==1&&Tn.push([e,t]);var kn=2,vn=30,Mn={gravity:9.8,friction:.7,linDamp:.1,angDamp:.4,tone:8};function Ln(e,t,r,o,a,n){for(let c of e)c.px=c.x,c.pq=c.q,c.v=[c.v[0],c.v[1]-n.gravity*a,c.v[2]],c.x=Oe(c.x,re(c.v,a)),lr(c,c.w,a);let s=Math.min(.5,n.tone*a);for(let c of t)o0(e,c,s);for(let c=0;c<2;c++)for(let p of t)uo(e,p);for(let c of e)An(c,r,o,n.friction,a);for(let c of t)uo(e,c);for(let c of e)An(c,r,o,n.friction,a);for(let c of t)uo(e,c);let l=Math.max(0,1-n.linDamp*a),i=Math.max(0,1-n.angDamp*a);for(let c of e){c.v=re(Ee(c.x,c.px),l/a);let p=Nt(c.v);p>vn&&(c.v=re(c.v,vn/p));let h=Ze(c.q,it(c.pq));h[3]<0&&(h=[-h[0],-h[1],-h[2],-h[3]]),c.w=[h[0]*2*i/a,h[1]*2*i/a,h[2]*2*i/a];}}function Cn(e,t,r,o,a){let n=o*o*a,s=Math.max(0,1-2*o*a);e.forEach((l,i)=>{let c=r[i];if(l.px=l.x,l.pq=l.q,l.im===0){l.x=c.x,l.q=c.q;return}l.v=Oe(re(l.v,s),re(Ee(c.x,l.x),n));let p=Ze(c.q,it(l.q));p[3]<0&&(p=[-p[0],-p[1],-p[2],-p[3]]),l.w=[l.w[0]*s+2*p[0]*n,l.w[1]*s+2*p[1]*n,l.w[2]*s+2*p[2]*n],l.x=Oe(l.x,re(l.v,a)),lr(l,l.w,a);});for(let l=0;l<3;l++)for(let i of t)uo(e,i);for(let l of e){l.v=re(Ee(l.x,l.px),1/a);let i=Ze(l.q,it(l.pq));i[3]<0&&(i=[-i[0],-i[1],-i[2],-i[3]]),l.w=[i[0]*2/a,i[1]*2/a,i[2]*2/a];}}function o0(e,t,r){let o=e[t.a],a=e[t.b],n=Ze(o.q,Ze(it(o.pq),a.pq)),s=Ze(n,it(a.q));s[3]<0&&(s=[-s[0],-s[1],-s[2],-s[3]]),Pr(o,a,[-2*s[0]*r,-2*s[1]*r,-2*s[2]*r]);}function uo(e,t){let r=e[t.a],o=e[t.b],a=se(r.q,t.ra),n=se(o.q,t.rb);ho(r,a,o,n,Ee(Oe(r.x,a),Oe(o.x,n)));let s=t.limit;if(s.kind==="hinge"){let u=se(r.q,s.hinge),R=se(o.q,s.hinge);Pr(r,o,st(u,R));let w=se(r.q,s.hinge),A=se(o.q,s.axis),k=Rn(Ee(A,re(w,we(w,A)))),x=se(r.q,s.from),f=se(r.q,s.to);if(we(st(x,k),w)<0||we(st(k,f),w)<0){let S=we(k,x)>we(k,f)?x:f;Pr(r,o,st(S,k));}return}let l=se(r.q,s.center),i=se(o.q,s.axis),c=we(l,i);if(c<s.cosSwing){let u=Rn(Ee(i,re(l,c))),R=u[0]===0&&u[1]===0&&u[2]===0?l:Oe(re(l,s.cosSwing),re(u,s.sinSwing));Pr(r,o,st(R,i));}let p=Ze(it(r.q),o.q);p[3]<0&&(p=[-p[0],-p[1],-p[2],-p[3]]);let h=p[0]*s.axis[0]+p[1]*s.axis[1]+p[2]*s.axis[2],m=Math.sqrt(h*h+p[3]*p[3]);if(m<1e-9)return;let d=p[3]/m,b=Math.abs(h)/m;if(d<s.cosHalfTwist){let u=2*(b*s.cosHalfTwist-d*s.sinHalfTwist),R=se(o.q,s.axis);Pr(r,o,re(R,(h>0?1:-1)*u));}}function An(e,t,r,o,a){for(let n of Sn){let s=[n[0]*e.half[0],n[1]*e.half[1],n[2]*e.half[2]],l=se(e.q,s),i=Oe(e.x,l),c=null,p=0;if(t!==null&&i[1]<t&&(c=[0,1,0],p=t-i[1]),r.length){let R=Oe(e.px,se(e.pq,s));for(let w of r){if(i[0]<=w.min[0]||i[0]>=w.max[0]||i[1]<=w.min[1]||i[1]>=w.max[1]||i[2]<=w.min[2]||i[2]>=w.max[2])continue;let A=[0,1,0],k=w.max[1]-i[1];if(R[1]<w.max[1]-1e-4){let x=[[[1,0,0],w.max[0]-i[0]],[[-1,0,0],i[0]-w.min[0]],[[0,0,1],w.max[2]-i[2]],[[0,0,-1],i[2]-w.min[2]]];(t===null||w.min[1]>t+.05)&&x.push([[0,-1,0],i[1]-w.min[1]]);for(let[f,S]of x)S<k&&(A=f,k=S);}k>p&&(c=A,p=k);}}if(!c)continue;let h=Oe(e.px,se(e.pq,s));if(p=Math.max(0,Math.min(p,we(Ee(h,i),c)+kn*a)),p<=0)continue;ho(e,l,null,[0,0,0],re(c,-p));let m=se(e.q,s),d=Ee(Oe(e.x,m),h),b=Ee(d,re(c,we(d,c))),u=Nt(b);u>1e-9&&ho(e,m,null,[0,0,0],re(b,Math.min(1,o*p/u)));}for(let n of r)for(let[s,l]of Tn){let i=T=>[T[0]<0?n.min[0]:n.max[0],T[1]<0?n.min[1]:n.max[1],T[2]<0?n.min[2]:n.max[2]],c=Xo(e.q,Ee(i(s),e.x)),p=Xo(e.q,Ee(i(l),e.x)),h=Ee(p,c),m=we(h,h),d=m>0?Math.max(0,Math.min(1,-we(c,h)/m)):0,b=Oe(c,re(h,d)),u=e.half[0]-Math.abs(b[0]),R=e.half[1]-Math.abs(b[1]),w=e.half[2]-Math.abs(b[2]);if(u<=0||R<=0||w<=0)continue;let A=u<R?u<w?0:2:R<w?1:2,k=[0,0,0];k[A]=b[A]>=0?1:-1;let x=A===0?u:A===1?R:w,f=Oe(e.x,se(e.q,b)),S=re(se(e.q,k),-1);x=Math.min(x,we(Ee(Oe(e.px,se(e.pq,b)),f),S)+kn*a),!(x<=0)&&ho(e,Ee(f,e.x),null,[0,0,0],re(se(e.q,k),x));}}function Pn(e){let t=Math.max(e.half[0],e.half[1],e.half[2]);return Nt(e.v)+Nt(e.w)*t}var zn=Math.PI,ra={"root.rx":[[0,zn/2],[.3,.6],[.6,0],[1,0]],"root.py":[[0,2.3],[.3,-6],[.6,-6],[1,0]],"legL.rx":[[0,0],[.3,1.8],[.6,1.5],[1,0]],"legR.rx":[[0,0],[.3,.2],[.6,-0.1],[1,0]],"shinL.rx":[[0,0],[.3,-2],[.6,-1.5],[1,0]],"shinR.rx":[[0,0],[.3,-1.6],[.6,-1.4],[1,0]],"armL.rx":[[0,0],[.3,-0.6],[.6,.4],[1,0]],"armR.rx":[[0,0],[.3,-0.6],[.6,.2],[1,0]]},In={"root.rx":[[0,-zn/2],[.3,-1.1],[.6,0],[1,0]],"root.py":[[0,2.3],[.3,4.5],[.6,-6],[1,0]],"armL.rx":[[0,1.6],[.3,1.5],[.6,.4],[1,0]],"armR.rx":[[0,1.6],[.3,1.5],[.6,.3],[1,0]],"foreArmL.rx":[[0,1.2],[.3,.1],[.6,.3],[1,0]],"foreArmR.rx":[[0,1.2],[.3,.1],[.6,.3],[1,0]],"legL.rx":[[0,0],[.3,.3],[.6,1.5],[1,0]],"legR.rx":[[0,0],[.3,.2],[.6,-0.1],[1,0]],"shinL.rx":[[0,0],[.3,-0.5],[.6,-1.5],[1,0]],"shinR.rx":[[0,0],[.3,-0.6],[.6,-1.4],[1,0]],"head.rx":[[0,.6],[.3,.3],[.6,0],[1,0]]};function On(e,t){if(t<=e[0][0])return e[0][1];for(let r=1;r<e.length;r++){let[o,a]=e[r];if(t<=o){let[n,s]=e[r-1],l=(t-n)/Math.max(1e-9,o-n);return s+(a-s)*l*l*(3-2*l)}}return e[e.length-1][1]}var lt=1/240,_n=48,a0=.08,n0=.25,s0=6,i0=.6,bo=.35,Vn=1.8,l0=.3,c0=11,p0=.2,m0=.65,h0=.25,d0=9,u0=14;function Fn(e,t){let r=Math.hypot(e[0],e[1],e[2]);return r>t?[e[0]*t/r,e[1]*t/r,e[2]*t/r]:e}var f0=.6,Bn=20,Dn=(e,t)=>{let r=ne(e.rot,[t[0]*e.scale,t[1]*e.scale,t[2]*e.scale]);return [r[0]+e.origin[0],r[1]+e.origin[1],r[2]+e.origin[2]]},Nn=(e,t)=>{let r=ne(xt(e.rot),[t[0]-e.origin[0],t[1]-e.origin[1],t[2]-e.origin[2]]);return [r[0]/e.scale,r[1]/e.scale,r[2]/e.scale]},zr=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},Hn=e=>Qe(0,e,0),Ir=class{supported;defs=[];fkBones;torso;bodies=[];joints=[];st="none";acc=0;still=0;sleeping=false;out=new Map;world={floor:null};frozen=new Map;riseT=0;keys=ra;yaw0=0;off0=[0,0,0];off1=[0,0,0];driftV=null;flT=0;stand;constructor(t){let r=Ae[t.rig]?.ragdoll;this.fkBones=t.bones.map(n=>({name:n.name,role:n.role,parent:n.parent,pivot:n.pivot})),this.torso=r?.torso??"",this.stand=new Set(r?.stand??[]);let o=new Map(t.bones.map(n=>[n.name,n])),a=r?[r.torso,...r.joints.map(n=>n.bone)]:[];if(this.supported=!!r&&a.every(n=>o.has(n)),!!this.supported)for(let n of a){let s=o.get(n),l=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let p=0;p<s.positions.length;p+=3)for(let h=0;h<3;h++){let m=s.positions[p+h];m<l[h]&&(l[h]=m),m>i[h]&&(i[h]=m);}let c=!Number.isFinite(l[0]);this.defs.push({name:n,role:s.role,pivot:s.pivot,c:c?[0,0,0]:[(l[0]+i[0])/2,(l[1]+i[1])/2,(l[2]+i[2])/2],half:c?[.5,.5,.5]:[Math.max(.3,(i[0]-l[0])/2),Math.max(.3,(i[1]-l[1])/2),Math.max(.3,(i[2]-l[2])/2)],joint:r.joints.find(p=>p.bone===n)??null});}}get state(){return this.st}get resting(){return this.st==="fall"&&this.sleeping}get drift(){return this.driftV}clearDrift(){this.driftV=null;}setWorld(t){this.world=t;}start(t,r,o,a){if(!this.supported)return;let n=r.frame.scale,s=this.place(r.pose,r.frame),l=t&&o>0?this.place(t.pose,t.frame):null;this.bodies=this.defs.map((i,c)=>{let p=s[c],h=ta([i.half[0]*n,i.half[1]*n,i.half[2]*n],p.x,p.q),m=l?.[c];if(m){h.v=Fn([(p.x[0]-m.x[0])/o,(p.x[1]-m.x[1])/o,(p.x[2]-m.x[2])/o],d0);let b=Ze(p.q,it(m.q));b[3]<0&&(b=[-b[0],-b[1],-b[2],-b[3]]),h.w=Fn([2*b[0]/o,2*b[1]/o,2*b[2]/o],u0);}let d=Math.max(.15,Math.min(1,p.y/Bn));return h.v=[h.v[0]+a[0]*d,h.v[1]+a[1]*d,h.v[2]+a[2]*d],h}),this.joints=this.makeJoints(n),this.world.floor===null&&!this.world.boxes&&(this.world={floor:r.frame.origin[1]}),this.st="fall",this.acc=0,this.still=0,this.sleeping=false;}place(t,r){let o=We(this.fkBones,t);return this.defs.map(a=>{let n=o.get(a.name),s=De(r.rot,n.rot),l=Dn(r,n.pos),i=ne(s,[a.c[0]*r.scale,a.c[1]*r.scale,a.c[2]*r.scale]);return {x:[l[0]+i[0],l[1]+i[1],l[2]+i[2]],q:fo(s),y:n.pos[1]+ne(n.rot,a.c)[1]}})}makeJoints(t){let r=new Map(this.defs.map((o,a)=>[o.name,a]));return this.defs.flatMap((o,a)=>{let n=o.joint;if(!n)return [];let s=r.get(n.parent);if(s===void 0)return [];let l=this.defs[s],i=[(o.pivot[0]-l.pivot[0]-l.c[0])*t,(o.pivot[1]-l.pivot[1]-l.c[1])*t,(o.pivot[2]-l.pivot[2]-l.c[2])*t],c=[-o.c[0]*t,-o.c[1]*t,-o.c[2]*t],p=[0,-1,0];if(n.kind==="hinge"){let[b,u]=n.bend;return [{a:s,b:a,ra:i,rb:c,limit:{kind:"hinge",hinge:[1,0,0],axis:p,from:[0,-Math.cos(b),-Math.sin(b)],to:[0,-Math.cos(u),-Math.sin(u)]}}]}let h=n.up?[0,1,0]:p,m=n.tilt??0,d=[0,h[1]*Math.cos(m),h[1]*Math.sin(m)];return [{a:s,b:a,ra:i,rb:c,limit:{kind:"ball",center:d,axis:h,cosSwing:Math.cos(n.swing),sinSwing:Math.sin(n.swing),cosHalfTwist:Math.cos(n.twist/2),sinHalfTwist:Math.sin(n.twist/2)}}]})}hit(t,r,o){if(!this.supported||this.st==="rise")return;if(this.st==="fall"){this.push(r);return}let a=t.frame,n=this.place(t.pose,a);this.st!=="flinch"&&(this.bodies=this.defs.map((i,c)=>{let p=ta([i.half[0]*a.scale,i.half[1]*a.scale,i.half[2]*a.scale],n[c].x,n[c].q);return this.stand.has(i.name)&&(p.im=0,p.ii=[0,0,0]),p}),this.joints=this.makeJoints(a.scale),this.acc=0,this.st="flinch"),this.flT=0;let s=-1;if(typeof o=="string")s=this.defs.findIndex(i=>i.name===o);else if(o){let i=1/0;this.bodies.forEach((c,p)=>{let h=(c.x[0]-o[0])**2+(c.x[1]-o[1])**2+(c.x[2]-o[2])**2;c.im>0&&h<i&&(i=h,s=p);});}let l=new Map;for(let i=s,c=1;i>=0&&c>.05;c*=f0){l.set(i,c);let p=this.defs[i].joint?.parent;i=p?this.defs.findIndex(h=>h.name===p):-1;}this.bodies.forEach((i,c)=>{if(i.im===0)return;let p=s>=0?l.get(c)??0:Math.max(.15,Math.min(1,n[c].y/Bn));i.v=[i.v[0]+r[0]*p,i.v[1]+r[1]*p,i.v[2]+r[2]*p];});}push(t){if(this.st==="fall"){for(let r of this.bodies)r.v=[r.v[0]+t[0],r.v[1]+t[1],r.v[2]+t[2]];this.sleeping=false,this.still=0;}}getUp(t){if(this.st!=="fall")return;let r=this.poseNow(t);Be(this.frozen,r);let o=r.get("root"),a=Qe(o[I.rx],o[I.ry],o[I.rz]),n=this.defs.find(d=>d.name===this.torso),s=ne(a,[0,1,0]),l=ne(a,[0,0,-1])[1]>=0;this.keys=l?ra:In,this.yaw0=l?Math.atan2(s[0],s[2]):Math.atan2(-s[0],-s[2]);let i=d=>{let b=d.get("root"),u=Qe(b[I.rx],b[I.ry],b[I.rz]),R=ne(u,n.pivot);return [R[0]+b[I.px],R[1]+b[I.py],R[2]+b[I.pz]]},c=i(r),p=ne(Hn(this.yaw0),i(this.keyPose(0))),h=i(this.keyPose(1)),m=this.groundUnder(t,c);this.off0=[c[0]-p[0],m,c[2]-p[2]],this.off1=[c[0]-h[0],m,c[2]-h[2]],this.driftV=this.off1,this.st="rise",this.riseT=0;}stop(){this.finish(),this.driftV=null;}finish(){this.st="none",this.bodies=[],this.joints=[];}groundUnder(t,r){let o=Dn(t,r),a=this.world.floor,n=this.world.boxes?.([o[0]-.01,-1e9,o[2]-.01],[o[0]+.01,o[1]+.3,o[2]+.01])??[];for(let s of n)o[0]>=s.min[0]&&o[0]<=s.max[0]&&o[2]>=s.min[2]&&o[2]<=s.max[2]&&s.max[1]<=o[1]+.3&&(a=a===null?s.max[1]:Math.max(a,s.max[1]));return a===null?0:Nn(t,[o[0],a,o[2]])[1]}drive(t,r,o){if(this.st==="none")return null;if(this.st==="flinch")return this.flinch(t,r,o);if(this.st==="fall")return this.sleeping||this.simulate(r),this.poseNow(o);this.riseT+=r;let a=this.riseT;if(a<bo)return oa(this.out,this.frozen,this.placed(0,0),zr(a/bo));let n=(a-bo)/Vn;if(n<1)return b0(this.out,this.placed(n,zr(n)));let s=(a-bo-Vn)/l0;return s>=1?(this.finish(),null):oa(this.out,this.placed(1,1),t,zr(s))}flinch(t,r,o){let a=this.place(t,o);this.acc=Math.min(this.acc+r,_n*lt);let n=this.flT;this.flT+=r;let s=0;for(;this.acc>=lt-1e-9;){this.acc-=lt,s++;let c=c0*zr((n+s*lt)/p0);Cn(this.bodies,this.joints,a,c,lt);}let l=this.poseNow(o),i=(this.flT-m0)/h0;return i<=0?l:i>=1?(this.finish(),null):oa(this.out,l,t,zr(i))}simulate(t){this.acc=Math.min(this.acc+t,_n*lt);let r=this.nearBoxes();for(;this.acc>=lt-1e-9;)this.acc-=lt,Ln(this.bodies,this.joints,this.world.floor,r,lt,Mn);let o=0;for(let a of this.bodies)o=Math.max(o,Pn(a));if(o<n0){let a=Math.max(0,1-s0*t);for(let n of this.bodies)n.v=[n.v[0]*a,n.v[1]*a,n.v[2]*a],n.w=[n.w[0]*a,n.w[1]*a,n.w[2]*a];}if(this.still=o<a0?this.still+t:0,this.still>=i0){this.sleeping=true;for(let a of this.bodies)a.v=[0,0,0],a.w=[0,0,0];}}nearBoxes(){let t=this.world.boxes;if(!t||!this.bodies.length)return [];let r=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of this.bodies){let n=Math.max(a.half[0],a.half[1],a.half[2])*1.8+.3;for(let s=0;s<3;s++)r[s]=Math.min(r[s],a.x[s]-n),o[s]=Math.max(o[s],a.x[s]+n);}return t(r,o)}poseNow(t){let r=this.out,o=new Map,a=xt(t.rot);this.defs.forEach((w,A)=>o.set(w.name,De(a,ea(this.bodies[A].q))));let n=this.defs.findIndex(w=>w.name===this.torso),s=this.defs[n],l=this.bodies[n],i=o.get(this.torso),c=l.q,p=se(c,[s.c[0]*t.scale,s.c[1]*t.scale,s.c[2]*t.scale]),h=Nn(t,[l.x[0]-p[0],l.x[1]-p[1],l.x[2]-p[2]]),m=ne(i,s.pivot),d=ae(r,"root"),[b,u,R]=Bt(i);d.set([b,u,R,h[0]-m[0],h[1]-m[1],h[2]-m[2],1,1,1]);for(let w of this.defs){let A=ae(r,w.role);if(w.name===this.torso){A.set([0,0,0,0,0,0,1,1,1]);continue}let k=w.joint?w.joint.parent===this.torso?i:o.get(w.joint.parent):i,[x,f,S]=Bt(De(xt(k),o.get(w.name)));A.set([x,f,S,0,0,0,1,1,1]);}return r}placed(t,r){let o=this.keyPose(t),a=o.get("root"),n=this.yaw0*(1-r),s=Hn(n),l=De(s,Qe(a[I.rx],a[I.ry],a[I.rz])),i=ne(s,[a[I.px],a[I.py],a[I.pz]]),[c,p,h]=Bt(l),m=this.off0,d=this.off1;return a.set([c,p,h,i[0]+m[0]+(d[0]-m[0])*r,i[1]+m[1],i[2]+m[2]+(d[2]-m[2])*r,1,1,1]),o}keyPose(t){let r=new Map;ae(r,"root");for(let o of this.defs)ae(r,o.role);for(let[o,a]of Object.entries(this.keys)){let[n,s]=o.split(".");ae(r,n)[I[s]]=On(a,t);}return r}};function b0(e,t){return Be(e,t),e}function oa(e,t,r,o){let a=new Set([...t.keys(),...r.keys()]),n=[0,0,0,0,0,0,1,1,1],s=new Map;for(let l of a){let i=t.get(l)??Float64Array.from(n),c=r.get(l)??Float64Array.from(n),p=fo(Qe(i[0],i[1],i[2])),h=fo(Qe(c[0],c[1],c[2])),[m,d,b]=Bt(ea(En(p,h,o))),u=new Float64Array(9);u[0]=m,u[1]=d,u[2]=b;for(let R=3;R<9;R++)u[R]=i[R]+(c[R]-i[R])*o;s.set(l,u);}return Be(e,s),e}var Ht=1/16,g0=.68,jn=.85,x0=1.2,w0=1.03,R0=1.1,k0=.12,v0=.1,A0=.1;function yo(e){let t=r=>r.toFixed(4);e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`{
2
2
  vec3 c = gl_FragColor.rgb;
3
3
  float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
4
- c = mix(vec3(l), c, ${t(g0)});
4
+ c = mix(vec3(l), c, ${t(x0)});
5
5
  #ifdef TONE_MAPPING
6
- c = (c - 0.5) * ${t(x0)} + 0.5;
7
- #else
8
6
  c = (c - 0.5) * ${t(w0)} + 0.5;
7
+ #else
8
+ c = (c - 0.5) * ${t(R0)} + 0.5;
9
9
  #endif
10
10
  gl_FragColor.rgb = clamp(c, 0.0, 1.0);
11
11
  }
@@ -14,29 +14,29 @@
14
14
  {
15
15
  vec3 c = gl_FragColor.rgb;
16
16
  float avg = (c.r + c.g + c.b) / 3.0;
17
- c += (avg - c) * (1.0 - 1.0 / (1.001 - ${t(R0)}));
17
+ c += (avg - c) * (1.0 - 1.0 / (1.001 - ${t(k0)}));
18
18
  c = min(c, 1.0);
19
- c = clamp((c - 0.5) / (1.0 - ${t(k0)}) + 0.5, 0.0, 1.0);
19
+ c = clamp((c - 0.5) / (1.0 - ${t(v0)}) + 0.5, 0.0, 1.0);
20
20
  float lu = dot(c, vec3(0.2126, 0.7152, 0.0722));
21
- c += ${t(v0)} * lu * lu;
21
+ c += ${t(A0)} * lu * lu;
22
22
  gl_FragColor.rgb = clamp(c, 0.0, 1.0);
23
23
  }
24
- #endif`);}function ra(e,t,r){if(!e)return new D__namespace.MeshLambertMaterial(r);let o=new D__namespace.MeshStandardMaterial({...r,roughness:t,metalness:0});return o.onBeforeCompile=fo,o}function A0(e,t){if(e==="glass"){if(!t)return new D__namespace.MeshLambertMaterial({transparent:true,opacity:.5,depthWrite:false});let o=new D__namespace.MeshStandardMaterial({transparent:true,opacity:.42,depthWrite:false,roughness:.08,metalness:.2});return o.onBeforeCompile=fo,o}if(e==="glow"){let o={emissive:16777215,emissiveIntensity:.85};return t?new D__namespace.MeshStandardMaterial({...o,roughness:.6}):new D__namespace.MeshLambertMaterial(o)}if(!t)return new D__namespace.MeshLambertMaterial({alphaTest:.5});let r=new D__namespace.MeshStandardMaterial({alphaTest:.5,roughness:.28,metalness:.85});return r.onBeforeCompile=fo,r}var Hn=5921370;function jn(e){let t=(r,o)=>r.replace(`#include <${o}>`,D__namespace.ShaderChunk[o].replace("varying vec2 vMapUv","centroid varying vec2 vMapUv"));e.vertexShader=t(e.vertexShader,"uv_pars_vertex"),e.fragmentShader=t(e.fragmentShader,"uv_pars_fragment");}function E0(e){jn(e),fo(e);}var bo=class{group=new D__namespace.Group;root=new D__namespace.Group;asset;spec;bones=new Map;byRole=new Map;meshes=[];material;decalMat;gloss;decal=null;expression=null;sockets=new Map;attached=new Map;label=null;shadows;layer;brightness=1;painter;prints=[];printMeshes=[];printMats=new Map;partMats=new Map;emotion;ik=null;ikGoals={ground:null,look:null,handR:null,handL:null,seat:null};toWorldM=new D__namespace.Matrix4;toModelM=new D__namespace.Matrix4;tmpV=new D__namespace.Vector3;ragdoll=null;ragWorld=null;ragPush=null;ragHit=null;ragRise=false;ragOn=false;drifted=new Map;snaps=[null,null];snapDt=0;constructor(t=_t(),r={}){this.spec=t,this.shadows=r.shadows??true,this.layer=r.layer??0,this.painter=r.facePainter??null,this.gloss=r.gloss??false,this.material=ra(this.gloss,y0,{alphaTest:.5}),this.material.onBeforeCompile=this.gloss?E0:jn,this.decalMat=ra(this.gloss,Nn,{alphaTest:.5,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.group.add(this.root),this.asset=Do(t),this.build(),r.name&&this.setName(r.name);}get height(){let t=this.asset.layout;return t.height*t.scale*Ht}get eye(){let t=this.asset.layout;return t.eye*t.scale*Ht}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(t){let r=Do(t);if(r===this.asset){ao(r);return}this.clear(),ao(this.asset),this.asset=r,this.spec=t,this.build();}build(){let{layout:t,skinned:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.useFaceMap(),this.root.scale.setScalar(t.scale*Ht);let a=new Map(t.bones.map(p=>[p.name,p.pivot])),n=[],s=[];for(let p of t.bones){let h=new D__namespace.Bone;n.push(h),s.push(new D__namespace.Matrix4().makeTranslation(-p.pivot[0],-p.pivot[1],-p.pivot[2]));let m=p.parent?a.get(p.parent)??[0,0,0]:[0,0,0],d=[p.pivot[0]-m[0],p.pivot[1]-m[1],p.pivot[2]-m[2]];h.position.set(...d);let b={name:p.name,role:p.role,group:h,rest:d};this.bones.set(p.name,b);let u=this.byRole.get(p.role)??[];u.push(b),this.byRole.set(p.role,u);}for(let p of t.bones){let h=this.bones.get(p.name);((p.parent?this.bones.get(p.parent):void 0)?.group??this.root).add(h.group);}let l=new D__namespace.Skeleton(n,s),i=(p,h,m)=>{let d=new D__namespace.SkinnedMesh(p,h);d.bind(l,new D__namespace.Matrix4);let b=(r??p).boundingSphere;b&&(d.boundingSphere=new D__namespace.Sphere(b.center.clone(),b.radius*1.6)),d.castShadow=m&&this.shadows,d.receiveShadow=this.shadows,d.layers.set(this.layer),this.meshes.push(d),this.root.add(d);};r&&i(r,this.material,true);for(let[p,h]of this.asset.skinnedMats){let m=this.partMats.get(p);m||this.partMats.set(p,m=A0(p,this.gloss)),m.map=this.asset.texture,p==="glow"&&(m.emissiveMap=this.asset.texture),m.needsUpdate=true,i(h,m,p!=="glass");}let c=t.face;if(c){let p=new D__namespace.BufferGeometry,h=c.grid;if(h){p.setAttribute("position",new D__namespace.BufferAttribute(h.positions,3)),p.setAttribute("normal",new D__namespace.BufferAttribute(h.normals,3)),p.setAttribute("uv",new D__namespace.BufferAttribute(new Float32Array(h.t.length),2));let m=[],d=h.cols+1;for(let b=0;b<h.rows;b++)for(let u=0;u<h.cols;u++){let R=b*d+u;m.push(R,R+d+1,R+1,R,R+d,R+d+1);}p.setIndex(m);}else {p.setAttribute("position",new D__namespace.BufferAttribute(c.corners,3));let m=new Float32Array(12);for(let d=0;d<4;d++)m[d*3+2]=-1;p.setAttribute("normal",new D__namespace.BufferAttribute(m,3)),p.setAttribute("uv",new D__namespace.BufferAttribute(new Float32Array(8),2)),p.setIndex([0,2,1,0,3,2]);}this.decal=new D__namespace.Mesh(p,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(c.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let p of t.sockets){let h=new D__namespace.Object3D;h.position.set(...p.at),h.scale.setScalar(1/(t.scale*Ht)),this.bones.get(p.bone)?.group.add(h),this.sockets.set(p.name,h);let m=this.attached.get(p.name);m&&h.add(m);}this.buildPrints(),this.placeLabel(),this.ik=new Mr(t),this.ragdoll=new Pr(t),this.ragWorld&&this.ragdoll.setWorld(this.ragWorld),this.ragOn=false,this.snaps=[null,null],this.setBrightness(this.brightness);}setPrints(t){this.prints=t??[],this.buildPrints(),this.setBrightness(this.brightness);}buildPrints(){for(let o of this.printMeshes)o.removeFromParent(),o.geometry.dispose();this.printMeshes=[];let t=new Set,r=new Map;for(let o of this.prints){let a=this.bones.get(o.bone),n=this.asset.layout.bones.find(p=>p.name===o.bone);if(!a||!n)continue;let s=this.printMats.get(o.texture);s||(s=ra(this.gloss,Nn,{map:o.texture,emissiveMap:o.texture,emissive:Hn,transparent:true,alphaTest:.02,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.printMats.set(o.texture,s)),t.add(o.texture);let l=new D__namespace.PlaneGeometry(o.w,o.h);o.facing==="front"&&l.rotateY(Math.PI),l.translate(o.center[0]-n.pivot[0],o.center[1]-n.pivot[1],o.center[2]-n.pivot[2]);let i=`${o.bone}|${o.texture.uuid}`,c=r.get(i)??{node:a,mat:s,geos:[]};c.geos.push(l),r.set(i,c);}for(let{node:o,mat:a,geos:n}of r.values()){let s=n.length===1?n[0]:BufferGeometryUtils_js.mergeGeometries(n)??n[0];if(s!==n[0])for(let i of n)i.dispose();let l=new D__namespace.Mesh(s,a);l.layers.set(this.layer),o.group.add(l),this.printMeshes.push(l);}for(let[o,a]of this.printMats)t.has(o)||(a.dispose(),this.printMats.delete(o));}clear(){for(let t of this.sockets.values())for(let r of [...t.children])t.remove(r);this.root.clear();for(let t of this.printMeshes)t.geometry.dispose();this.printMeshes=[],this.decal?.geometry.dispose(),this.decal=null;for(let t of this.meshes)t instanceof D__namespace.SkinnedMesh&&t.skeleton.dispose();this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(t,r){let o=this.ragdoll?.drift;if(o){Be(this.drifted,t);let i=ae(this.drifted,"root");for(let c=0;c<3;c++)i[I.px+c]=i[I.px+c]+o[c];t=this.drifted;}let a=this.ragdoll?.supported?this.ragdoll:null,n=false;a&&(this.ragHit||a.state==="flinch")&&r&&this.ik&&(t=this.solveIK(t,r),n=true);let s=a?this.driveRagdoll(t,r?.dt??0):null;s?t=s:(!n&&r&&this.ik&&(t=this.solveIK(t,r)),this.remember(t,r?.dt??0));let l=t.get("root");if(l){this.root.rotation.set(l[I.rx],l[I.ry],l[I.rz]);let i=this.asset.layout.scale*Ht;this.root.position.set(l[I.px]*i,l[I.py]*i,l[I.pz]*i);}else this.root.rotation.set(0,0,0),this.root.position.set(0,0,0);for(let[i,c]of this.byRole){let p=t.get(i);for(let h of c){let m=h.group;if(!p){m.rotation.set(0,0,0),m.position.set(...h.rest),m.scale.set(1,1,1);continue}m.rotation.set(p[I.rx],p[I.ry],p[I.rz]),m.position.set(h.rest[0]+p[I.px],h.rest[1]+p[I.py],h.rest[2]+p[I.pz]),m.scale.set(p[I.sx],p[I.sy],p[I.sz]);}}}fall(t=[0,0,0]){if(!this.ragdoll?.supported)return false;let r=Array.isArray(t)?[t[0],t[1],t[2]]:[t.x,t.y,t.z];return this.ragdoll.state==="fall"?this.ragdoll.push(r):this.ragPush=r,this.ragRise=false,true}hit(t,r=null){if(!this.ragdoll?.supported)return false;let o=Array.isArray(t)?[t[0],t[1],t[2]]:[t.x,t.y,t.z],a=r===null||typeof r=="string"?r:Array.isArray(r)?[r[0],r[1],r[2]]:[r.x,r.y,r.z];return this.ragdoll.state==="fall"||this.ragPush?this.fall(o):(this.ragHit={push:o,at:a},true)}getUp(){(this.ragdoll?.state==="fall"||this.ragPush)&&(this.ragRise=true);}stopRagdoll(){this.ragdoll?.stop(),this.ragPush=null,this.ragHit=null,this.ragRise=false;}takeRagdollDrift(){let t=this.ragdoll;if(!t||t.state!=="none")return null;let r=this.ragdollDrift;return r?(t.clearDrift(),this.ik?.reset(),this.snaps=[null,null],r):null}get ragdollDrift(){let t=this.ragdoll?.drift;if(!t)return null;let r=this.ragFrame();return ne(r.rot,[t[0]*r.scale,t[1]*r.scale,t[2]*r.scale])}get ragdollState(){return this.ragPush?"fall":this.ragHit?"flinch":this.ragdoll?.state??"none"}get ragdollResting(){return !!this.ragdoll?.resting}supportsRagdoll(){return !!this.ragdoll?.supported}setColliders(t){this.ragWorld=t,this.ragdoll&&this.ragdoll.setWorld(t??{floor:null});}ragFrame(){let t=this.asset.layout.scale*Ht;this.group.updateWorldMatrix(true,false);let r=new D__namespace.Vector3,o=new D__namespace.Quaternion,a=new D__namespace.Vector3;this.group.matrixWorld.decompose(r,o,a);let n=new D__namespace.Matrix4().makeRotationFromQuaternion(o).elements;return {rot:[n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]],scale:t*a.x,origin:[r.x,r.y,r.z]}}remember(t,r){if(!this.ragdoll?.supported)return;let a=this.snaps[0]??{pose:new Map,frame:this.ragFrame()};Be(a.pose,t),a.frame=this.ragFrame(),this.snaps=[this.snaps[1]??null,a],this.snapDt=r;}driveRagdoll(t,r){let o=this.ragdoll,a=this.ragFrame();if(this.ragPush){let l=this.snaps[1]??{pose:t,frame:a};o.start(this.snaps[1]?this.snaps[0]??null:null,l,this.snapDt,this.ragPush),this.ragPush=null;}this.ragHit&&(o.hit({pose:t,frame:a},this.ragHit.push,this.ragHit.at),this.ragHit=null),this.ragRise&&o.state==="fall"&&(o.getUp(a),this.ragRise=false);let n=o.state==="flinch",s=o.drive(t,r,a);return n||(s?this.ragOn=true:this.ragOn&&(this.ragOn=false,this.ik?.reset(),this.snaps=[null,null])),s}setGround(t){this.ikGoals.ground=t;}lookAt(t){this.ikGoals.look=t;}reach(t,r){this.ikGoals[t]=r;}seat(t){this.ikGoals.seat=t;}supportsIK(t){return !!this.ik?.supports(t)}resetIK(){this.ik?.reset();}solveIK(t,r){let o=this.ikGoals,a=this.asset.layout.scale*Ht;this.group.updateWorldMatrix(true,false),this.toWorldM.copy(this.group.matrixWorld).scale(this.tmpV.set(a,a,a)),this.toModelM.copy(this.toWorldM).invert();let n=this.tmpV,s=h=>(n.set(h[0],h[1],h[2]).applyMatrix4(this.toWorldM),[n.x,n.y,n.z]),l=h=>(n.set(h[0],h[1],h[2]).applyMatrix4(this.toModelM),[n.x,n.y,n.z]),i=h=>{if(!h)return null;let m;return h instanceof D__namespace.Vector3?m=h:h instanceof D__namespace.Object3D?m=h.getWorldPosition(new D__namespace.Vector3):m=h(),m?l([m.x,m.y,m.z]):null},c=o.ground,p=c?(h,m,d)=>{let[b,u,R]=s([h,m,d]),w=c(b,R,u);return w===null?null:l([b,w,R])[1]}:null;return this.ik.solve(t,{dt:r.dt,plant:r.plant,standing:r.standing,ground:p,look:i(o.look),handR:i(o.handR),handL:i(o.handL),seat:i(o.seat),toWorld:s,toModel:l})}setFacePainter(t){if(t===this.painter)return;this.painter=t,this.useFaceMap();let r=this.expression??"neutral";this.expression=null,this.setExpression(r);}useFaceMap(){let t=this.painter;this.decalMat.map=t?t.texture:this.asset.texture,this.decalMat.transparent=!!t,this.decalMat.alphaTest=t?.02:.5,this.decalMat.needsUpdate=true;}setExpression(t,r){if(t===this.expression&&(!this.painter||r===this.emotion)||!this.decal)return;let o=this.asset.layout.face?.uv,a=this.painter?[0,1,1,0]:o?.[t]??o?.neutral;if(!a)return;this.expression=t,this.emotion=r,this.painter?.paint(t,r);let[n,s,l,i]=a,c=this.decal.geometry.getAttribute("uv"),p=this.asset.layout.face?.grid;if(p)for(let h=0;h<c.count;h++)c.setXY(h,n+(l-n)*p.t[h*2],s+(i-s)*p.t[h*2+1]);else c.setXY(0,n,s),c.setXY(1,l,s),c.setXY(2,l,i),c.setXY(3,n,i);c.needsUpdate=true;}materials(){return [this.material,this.decalMat,...this.partMats.values()]}setBrightness(t){this.brightness=t,this.material.color.setScalar(t),this.decalMat.color.setScalar(t);for(let r of this.printMats.values())r.color.setScalar(t);for(let r of this.partMats.values())r.color.setScalar(t);}setEmissive(t){if(this.material.emissive.getHex()!==t){this.material.emissive.setHex(t),this.decalMat.emissive.setHex(t);for(let r of this.printMats.values())r.emissive.setHex(t||Hn);for(let[r,o]of this.partMats)r!=="glow"&&o.emissive.setHex(t);}}setShadows(t){if(t!==this.shadows){this.shadows=t;for(let r of this.meshes)r.castShadow=t&&!r.material.transparent;}}attach(t,r){let o=this.attached.get(t);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(t);return}this.attached.set(t,r),this.sockets.get(t)?.add(r);}}attachedAt(t){return this.attached.get(t)??null}setName(t){this.label&&qo(this.label),this.label=t?cn(t):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(t){this.label&&(this.label.visible=t);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(t){for(let r of this.meshes)t(r);this.decal&&t(this.decal);for(let r of this.printMeshes)t(r);}dispose(){this.group.removeFromParent();for(let t of this.attached.values())t.removeFromParent();this.attached.clear(),this.clear(),this.label&&qo(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose();for(let t of this.printMats.values())t.dispose();this.printMats.clear();for(let t of this.partMats.values())t.dispose();this.partMats.clear(),ao(this.asset);}};var yo=new Map,oa=new Set;function cp(e){let t=tr(e);if(!yo.has(t)){yo.set(t,e);for(let r of oa)r(t);}return t}function pp(e){return typeof e=="string"?yo.get(e):void 0}function mp(e){let t={};for(let r of e){let o=yo.get(r);o&&(t[r]=o);}return t}function hp(e){return oa.add(e),()=>oa.delete(e)}var S0=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],T0=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],M0=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],L0=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],C0=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],P0=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function yp(e,t="",r=""){let o=Zr(It("npc:"+e+"|"+t)),a=l=>l[Math.floor(o()*l.length)],n=jo({top:a(nn),bottom:a(sn),shoes:a(ln),hair:a(["short","short","long","curly"]),hat:o()<.2,colors:{skin:a(T0),hair:a(M0),shirt:a(L0),pants:a(C0),boots:a(S0),hat:a(P0)}});n.name=e.slice(0,40),n.description=[t,r].filter(Boolean).join(" \u2014 ").slice(0,300),n.style={walk:a(["normal","normal","bouncy","heavy","sneaky"]),idle:a(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},n.tags=["npc",...t?[t.slice(0,24)]:[]];let s=Ye(n);return s.ok?s.spec:_t()}var Rt=([e,t,r])=>"#"+[e,t,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function z0(e){if(!e.length)return null;let t=r=>{let o=e.map(a=>a[r]).sort((a,n)=>a-n);return o[o.length>>1]};return [t(0),t(1),t(2)]}function I0(e,t){let{width:r,height:o,data:a}=e,n=(w,A)=>{let k=(A*r+w)*4;return [a[k],a[k+1],a[k+2]]},s=[n(0,0),n(r-1,0),n(0,o-1),n(r-1,o-1)],l=[0,1,2].map(w=>s.reduce((A,k)=>A+k[w],0)/4),i=w=>Math.abs(w[0]-l[0])+Math.abs(w[1]-l[1])+Math.abs(w[2]-l[2])>60,c=r,p=-1,h=o,m=-1;for(let w=0;w<o;w+=2)for(let A=0;A<r;A+=2)i(n(A,w))&&(c=Math.min(c,A),p=Math.max(p,A),h=Math.min(h,w),m=Math.max(m,w));p<0&&(c=0,p=r-1,h=0,m=o-1);let d=m-h+1,b=p-c+1,u=c+Math.floor(b*.3),R=c+Math.ceil(b*.7);return t.map(([w,A])=>{let k=[];for(let x=h+Math.floor(d*w);x<h+Math.ceil(d*A);x++)for(let f=u;f<R;f++){if(x<0||x>=o||f<0||f>=r)continue;let S=n(f,x);i(S)&&k.push(S);}return z0(k)})}var O0=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function kp(e,t="humanoid",r=ro()){let[o,a,n,s,l]=I0(e,O0);if(t==="humanoid"){let c=JSON.parse(JSON.stringify(Go));c.palette=Ho(c.palette,{...o?{hair:Rt(o)}:{},...a?{skin:Rt(a)}:{},...n?{shirt:Rt(n)}:{},...s?{pants:Rt(s)}:{},...l?{boots:Rt(l)}:{}}),c.name=r,c.tags=[];let p=Ye(c);return p.ok?p.spec:_t()}let i=Ye({name:r,rig:t,palette:{s:Rt(a??o??[198,156,124]),t:Rt(n??[58,143,214]),p:Rt(s??l??[44,62,107]),w:"#f4f4f4",b:"#1d1d21"},textures:{f_neutral:{w:4,h:2,rows:["wbbw","...."]},f_blink:{w:4,h:2,rows:["bbbb","...."]}},face:{rect:t==="blob"?[4,4,4,2]:t==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return i.ok?i.spec:_t()}var _0={normal:{},bouncy:{amp:.9,arm:.8,bob:1.6,tempo:1.1,sway:.04},heavy:{amp:.6,arm:.4,bob:.6,tempo:.8,sway:.12},sneaky:{amp:.5,arm:.3,tempo:1.2},robotic:{amp:.7,arm:.7,quant:true},swagger:{amp:.7,arm:.5,bob:.8,tempo:.85,sway:.1,swagger:.22},skip:{amp:.9,arm:.9,bob:1.2,tempo:1.05,skip:1},ninja:{amp:.6,arm:.2,tempo:1.25,crouch:2.2},zombie:{amp:.45,arm:.05,tempo:.6,sway:.14,reach:1.45},catwalk:{amp:.7,arm:.45,tempo:.95,sway:.08,cross:.12}},V0={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8},cool:{pose:"hips",chest:.04,breath:.8},shy:{pose:"shy",breath:1.1},ready:{pose:"ready",breath:1.4},bored:{pose:"bored",breath:.7,fidget:.4}};function aa(e){let t={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,reach:0,crouch:0,skip:0,cross:0,swagger:0,pose:"none",..._0[e.walk],...V0[e.idle]};return t.tempo*=.8+.4*e.energy,t.amp*=.85+.3*e.energy,t}function jt(e,t=0){let r=Math.sin(e.phase+t);return e.style.quant?Math.max(-1,Math.min(1,r*3)):r}function na(e,t,r){let o=jt(t)*r;y(e,"legL","rx",o),y(e,"legR","rx",-o),y(e,"legFL","rx",o),y(e,"legBR","rx",o),y(e,"legFR","rx",-o),y(e,"legBL","rx",-o);}function sa(e,t,r){let o=jt(t)*r;y(e,"armL","rx",-o),y(e,"armR","rx",o);}function ia(e,t,r,o){let a=jt(t),n=Math.max(0,Math.cos(t.phase))*Math.max(0,-a+.3),s=Math.max(0,-Math.cos(t.phase))*Math.max(0,a+.3);y(e,"shinL","rx",-r*(.15+n)),y(e,"shinR","rx",-r*(.15+s)),y(e,"foreArmL","rx",o*(.6+.4*Math.max(0,-a))),y(e,"foreArmR","rx",o*(.6+.4*Math.max(0,a)));}var F0=(e,t)=>{let r=Math.sin(t.clock*2)*t.style.breath;y(e,"armL","rz",-0.04-.03*r),y(e,"armR","rz",.04+.03*r),y(e,"foreArmL","rx",.12+.02*r),y(e,"foreArmR","rx",.12+.02*r),y(e,"head","rx",.03*Math.sin(t.clock*1.7)+t.style.chest),y(e,"body","rx",t.style.chest*-0.5),t.style.fidget&&(y(e,"head","ry",.35*Math.sin(t.clock*.7)*Math.sin(t.clock*.31)),y(e,"root","ry",.05*Math.sin(t.clock*.9))),y(e,"body","sy",1+.04*Math.sin(t.clock*3)),B0(e,t);};function B0(e,t){let r=Math.sin(t.clock*2);switch(t.style.pose){case "hips":y(e,"armL","rz",-0.75),y(e,"armR","rz",.75),y(e,"foreArmL","rx",.2),y(e,"foreArmR","rx",.2),y(e,"foreArmL","rz",1.5),y(e,"foreArmR","rz",-1.5),y(e,"legL","rz",-0.06),y(e,"legR","rz",.06);break;case "shy":y(e,"armL","rx",-0.35),y(e,"armR","rx",-0.35),y(e,"foreArmL","rx",.5),y(e,"foreArmR","rx",.5),y(e,"head","rx",-0.15+.03*r),y(e,"legR","rx",.15+.08*Math.sin(t.clock*1.3)),y(e,"shinR","rx",-0.3);break;case "ready":y(e,"legL","rz",-0.16),y(e,"legR","rz",.16),y(e,"legL","rx",.25),y(e,"legR","rx",-0.15),y(e,"shinL","rx",-0.35),y(e,"shinR","rx",-0.25),y(e,"armL","rx",.9),y(e,"armR","rx",.7),y(e,"foreArmL","rx",1.4),y(e,"foreArmR","rx",1.5),y(e,"root","py",-0.6+.3*Math.abs(Math.sin(t.clock*3.2)));break;case "bored":y(e,"root","rz",.04),y(e,"legL","rz",-0.04),y(e,"shinR","rx",-0.25),y(e,"legR","rx",.12),y(e,"head","rz",.12+.03*r),y(e,"body","rx",-0.06);break;}}var D0=(e,t)=>{na(e,t,t.style.amp),sa(e,t,t.style.arm),ia(e,t,t.style.amp*1.1,.35);let r=t.style.bob*Math.abs(Math.cos(t.phase));y(e,"root","py",r),y(e,"body","rz",t.style.sway*jt(t)),N0(e,t);};function N0(e,t){let r=t.style;if(r.reach&&(y(e,"armL","rx",r.reach+.05*Math.sin(t.phase)),y(e,"armR","rx",r.reach-.05*Math.sin(t.phase)),y(e,"foreArmL","rx",.1),y(e,"foreArmR","rx",.1),y(e,"head","rz",.15*Math.sin(t.phase*.5))),r.crouch&&(y(e,"root","py",-r.crouch),y(e,"body","rx",-0.3),y(e,"head","rx",.25),de(e,"shinL","rx",-0.5),de(e,"shinR","rx",-0.5),de(e,"legL","rx",.35),de(e,"legR","rx",.35),y(e,"armL","rx",-0.9),y(e,"armR","rx",-0.9)),r.skip){let o=Math.max(0,Math.sin(t.phase));de(e,"root","py",2.2*r.skip*o*o),de(e,"armL","rz",-0.3*o),de(e,"armR","rz",.3*o);}r.cross&&(y(e,"legL","rz",r.cross),y(e,"legR","rz",-r.cross),y(e,"root","ry",.12*jt(t))),r.swagger&&(y(e,"body","ry",r.swagger*jt(t)),y(e,"head","rz",-0.5*r.swagger*jt(t)),y(e,"armL","rz",-0.2),y(e,"armR","rz",.2));}var H0=(e,t)=>{na(e,t,t.style.amp*1.3),sa(e,t,t.style.arm*1.6),ia(e,t,t.style.amp*1.6,1.1),y(e,"body","rx",-0.18),y(e,"head","rx",.18),y(e,"root","py",(.8+t.style.bob)*Math.abs(Math.cos(t.phase)));},j0=(e,t)=>{na(e,t,t.style.amp*.5*Math.min(1,t.input.speed)),sa(e,t,t.style.arm*.4*Math.min(1,t.input.speed)),y(e,"body","rx",-0.45),y(e,"head","rx",.45),de(e,"armL","rx",.25),de(e,"armR","rx",.25),ia(e,t,.9,.6),y(e,"root","py",-1.5);},G0=(e,t)=>{y(e,"root","rx",-1.3),y(e,"head","rx",1),y(e,"armL","rx",Math.PI-.5+.5*Math.sin(t.t*3)),y(e,"armR","rx",Math.PI-.5+.5*Math.sin(t.t*3+Math.PI)),y(e,"legL","rx",.3*Math.sin(t.t*8)),y(e,"legR","rx",-0.3*Math.sin(t.t*8));},q0=(e,t)=>{y(e,"legL","rx",.15),y(e,"legR","rx",.1),y(e,"armL","rz",-0.15),y(e,"armR","rz",.15),y(e,"root","py",.6*Math.sin(t.t*2));},U0=e=>{y(e,"root","rx",-1.35),y(e,"head","rx",1.1),y(e,"armL","rz",-1.3),y(e,"armR","rz",1.3);},K0=(e,t)=>{let r=.15*Math.sin(t.t*10);y(e,"armL","rz",-0.6-r),y(e,"armR","rz",.6+r),y(e,"legL","rx",.25),y(e,"legR","rx",-0.25),y(e,"shinL","rx",-0.5),y(e,"shinR","rx",-0.3),y(e,"foreArmL","rx",.4),y(e,"foreArmR","rx",.4);},Y0=e=>{y(e,"legL","rx",1.45),y(e,"legR","rx",1.45),y(e,"legL","ry",.1),y(e,"legR","ry",-0.1),y(e,"shinL","rx",-1.45),y(e,"shinR","rx",-1.45),y(e,"root","py",-10),y(e,"body","rx",.4),y(e,"legBL","rx",1.2),y(e,"legBR","rx",1.2);},W0=e=>{y(e,"legL","rx",1.4),y(e,"legR","rx",1.4),y(e,"legL","rz",-0.3),y(e,"legR","rz",.3),y(e,"armL","rx",.45),y(e,"armR","rx",.45),y(e,"shinL","rx",-1.2),y(e,"shinR","rx",-1.2),y(e,"foreArmL","rx",.5),y(e,"foreArmR","rx",.5);},$0=e=>{y(e,"root","rx",Math.PI/2),y(e,"root","py",2);},J0=e=>{y(e,"root","rz",Math.PI/2),y(e,"root","py",2);},X0=(e,t)=>{let r=Math.sin(t.phase*.5);y(e,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;y(e,"body","sy",1-o+.1*Math.max(0,r)),y(e,"body","sx",1+o*.6),y(e,"body","sz",1+o*.6);},Q0=(e,t)=>{let r=Math.min(t.input.speed,8),o=Math.sin(t.clock*(3+r*1.2)),a=.25+r*.04;y(e,"tail","ry",a*1.6*o),y(e,"body","ry",-a*.35*o),y(e,"root","py",.4*Math.sin(t.clock*1.6));},Z0=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"armR","rx",1.9*r),y(e,"armR","ry",.3*r),y(e,"body","ry",-0.3*r),y(e,"foreArmR","rx",.6*r);},el=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"armR","rx",.9*r);},tl=(e,t)=>{let r=t.k<.4?-1.5*(t.k/.4):-1.5+3.5*((t.k-.4)/.6);y(e,"armR","rx",t.k>.9?r*(1-t.k)*10:r);},rl=(e,t)=>{let r=Math.sin(Math.PI*t.k)*(1-t.k);y(e,"armR","rx",.35*r),y(e,"foreArmR","rx",.5*r),y(e,"armL","rx",.2*r),y(e,"body","rx",-0.05*r);},ol=(e,t)=>{let r=t.k<.35?t.k/.35:Math.max(0,1-(t.k-.35)/.65);y(e,"armR","rx",1.55*r),y(e,"armR","ry",-0.15*r),y(e,"foreArmR","rx",.2*(1-r)),y(e,"body","ry",.35*r),y(e,"armL","rx",.6),y(e,"foreArmL","rx",1.2);},al=e=>{y(e,"armR","rx",1.5),y(e,"foreArmR","rx",.05),y(e,"armL","rx",1.3),y(e,"armL","ry",-0.45),y(e,"foreArmL","rx",.3);},nl=e=>{y(e,"armR","rx",1.25),y(e,"armR","ry",.25),y(e,"foreArmR","rx",.9),y(e,"armL","rx",1.45),y(e,"armL","ry",-0.35),y(e,"foreArmL","rx",.25),y(e,"body","ry",.25),y(e,"head","ry",-0.2);},sl=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"body","rx",.15*r),y(e,"head","rx",.2*r),y(e,"root","rz",.05*r);},il=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"root","py",-1.5*r),y(e,"legL","rx",.2*r),y(e,"legR","rx",.2*r),y(e,"shinL","rx",-0.5*r),y(e,"shinR","rx",-0.5*r),y(e,"body","sy",1-.2*r),y(e,"body","sx",1+.12*r),y(e,"body","sz",1+.12*r);},ll=(e,t)=>{y(e,"armR","rx",1.3+.1*Math.sin(t.t*16)),y(e,"armR","ry",-0.5),y(e,"head","rx",-0.1+.08*Math.sin(t.t*16));},cl=e=>{y(e,"armR","rx",2),y(e,"armR","ry",-0.4),y(e,"head","rx",.35);},pl=e=>{y(e,"armR","rx",1.57),y(e,"armR","ry",-0.1),y(e,"armL","rx",1.57),y(e,"armL","ry",.35);},ml=e=>{y(e,"armL","rx",.9),y(e,"armL","ry",-0.6);},zr={idle:F0,walk:D0,run:H0,sneak:j0,swim:G0,fly:q0,glide:U0,fall:K0,sit:Y0,ride:W0,sleep:$0,dead:J0,hop:X0,swing:Z0,place:el,throw:tl,shoot:rl,punch:ol,aimPistol:al,aimRifle:nl,hurt:sl,land:il,eat:ll,drink:cl,draw:pl,block:ml,fin:Q0},Gn={blob:{walk:"hop",run:"hop",sneak:"hop"},swimmer:{idle:"fin",walk:"fin",run:"fin",sneak:"fin",swim:"fin",fall:"fin"}},qn={swing:.3,place:.2,throw:.45,shoot:.16,punch:.28,hurt:.3,land:.22};function le(e,t,r=.3){let o={};for(let[a,n]of Object.entries(t))o[a]=[[0,0],[r,n],[Math.max(r,e-r),n],[e,0]];return o}function N(e,t){let r={};for(let[o,a]of Object.entries(t))r[o]=[[0,a],[e,a]];return r}function E(e,t,r,o,a,n=0,s=false){let l=Math.max(8,Math.round(a*8)),i=[];for(let c=0;c<=l;c++){let p=c/l,h=s?Math.min(1,p/.15,(1-p)/.15):1;i.push([e*p,(r+o*Math.sin(Math.PI*2*a*p+n))*h]);}return {[t]:i}}function kt(e,t){return [[0,t],[e,t]]}function P(e,t){return t.map(([r,o])=>[e*r,o])}function B(...e){return Object.assign({},...e)}var Un={"legL.rx":1.5,"legR.rx":1.5,"shinL.rx":-1.5,"shinR.rx":-1.5,"root.py":-6.2},hl=4.1,Kn={"legL.rx":1.45,"legR.rx":1.45,"legL.ry":.75,"legR.ry":-0.75,"shinL.rx":-2.5,"shinR.rx":-2.5,"shinL.ry":-0.6,"shinR.ry":.6,"root.py":-10.2},Ir={"root.rx":Math.PI/2,"root.py":2.3,"root.pz":0};var be=Math.PI,$n={"armR.rx":.55,"foreArmR.rx":1.35,"armR.rz":-0.15},Or={"armL.rx":.55,"foreArmL.rx":1.35,"armL.rz":.15},Yn={...$n,...Or},Wn={"armL.rx":.75,"armR.rx":.75,"foreArmL.rx":.85,"foreArmR.rx":.85,"head.rx":-0.2},Se=(e,t)=>N(e,{...Un,...t}),go=(e,t,r,o)=>B(E(e,"legL.rx",0,r,t),E(e,"legR.rx",0,r,t,be),E(e,"shinL.rx",-o,o,t,-be/2),E(e,"shinR.rx",-o,o,t,be/2)),la={tiptoe:{label:"\u041D\u0430 \u0446\u044B\u043F\u043E\u0447\u043A\u0430\u0445",en:"Tiptoe",duration:1.6,loop:true,tracks:B(go(1.6,2,.35,.35),N(1.6,{"root.py":.6,"body.rx":-0.12,"armL.rx":.6,"armR.rx":.6,"foreArmL.rx":1.4,"foreArmR.rx":1.4}),E(1.6,"head.ry",0,.25,1))},limp:{label:"\u041A\u043E\u0432\u044B\u043B\u044F\u0442\u044C",en:"Limp",duration:1.6,loop:true,emotion:"hurt",tracks:{"legL.rx":P(1.6,[[0,.4],[.5,-0.3],[1,.4]]),"legR.rx":P(1.6,[[0,-0.15],[.5,.15],[1,-0.15]]),"shinL.rx":P(1.6,[[0,-0.2],[.25,-0.9],[.5,-0.1],[1,-0.2]]),"root.py":P(1.6,[[0,0],[.5,-1],[1,0]]),"body.rz":P(1.6,[[0,.04],[.5,-0.1],[1,.04]]),"armR.rz":kt(1.6,.2)}},crawl:{label:"\u041F\u043E\u043B\u0437\u0442\u0438",en:"Crawl",duration:1.6,loop:true,tracks:B(N(1.6,{"root.rx":-1.35,"root.py":3.2,"head.rx":1.1,"legL.rx":1.3,"legR.rx":1.3,"shinL.rx":-1.4,"shinR.rx":-1.4}),E(1.6,"armL.rx",2,.4,2),E(1.6,"armR.rx",2,.4,2,be),E(1.6,"legL.ry",0,.15,2,be),E(1.6,"legR.ry",0,.15,2))},climb:{label:"\u041B\u0435\u0437\u0442\u044C \u043F\u043E \u043B\u0435\u0441\u0442\u043D\u0438\u0446\u0435",en:"Climb",duration:1.6,loop:true,tracks:B(E(1.6,"armL.rx",2.6,.4,1),E(1.6,"armR.rx",2.6,.4,1,be),E(1.6,"legL.rx",.7,.6,1,be),E(1.6,"legR.rx",.7,.6,1),E(1.6,"shinL.rx",-1,.6,1,be),E(1.6,"shinR.rx",-1,.6,1),N(1.6,{"head.rx":.4,"foreArmL.rx":.5,"foreArmR.rx":.5}))},jog:{label:"\u0411\u0435\u0433 \u0442\u0440\u0443\u0441\u0446\u043E\u0439",en:"Jog",duration:.9,loop:true,tracks:B(go(.9,1,.6,.6),E(.9,"armL.rx",0,.6,1,be),E(.9,"armR.rx",0,.6,1),N(.9,{"foreArmL.rx":1.4,"foreArmR.rx":1.4,"body.rx":-0.1}),E(.9,"root.py",.8,.8,2))},carry:{label:"\u041D\u0435\u0441\u0442\u0438 \u043A\u043E\u0440\u043E\u0431\u043A\u0443",en:"Carry",duration:1,loop:true,layer:"upper",tracks:N(1,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.7,"foreArmR.rx":.7,"armL.rz":-0.25,"armR.rz":.25,"body.rx":.08})},push:{label:"\u0422\u043E\u043B\u043A\u0430\u0442\u044C",en:"Push",duration:1.4,loop:true,emotion:"determined",tracks:B(go(1.4,1,.3,.5),N(1.4,{"body.rx":-0.45,"head.rx":.4,"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":.5,"foreArmR.rx":.5,"root.py":-0.8}))},pull:{label:"\u0422\u044F\u043D\u0443\u0442\u044C",en:"Pull",duration:1.4,loop:true,emotion:"determined",tracks:B(go(1.4,1,.25,.4),N(1.4,{"body.rx":.25,"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":.3,"foreArmR.rx":.3,"root.py":-0.6}))},sitChair:{label:"\u0421\u0438\u0434\u0435\u0442\u044C \u043D\u0430 \u0441\u0442\u0443\u043B\u0435",en:"Sit on a chair",seat:true,duration:2,loop:true,tracks:B(Se(2,{"armL.rx":.4,"armR.rx":.4,"foreArmL.rx":.5,"foreArmR.rx":.5}),E(2,"head.rz",0,.04,1))},sitFloor:{label:"\u041F\u043E-\u0442\u0443\u0440\u0435\u0446\u043A\u0438",en:"Sit cross-legged",duration:2,loop:true,tracks:N(2,{...Kn,"armL.rx":.5,"armR.rx":.5,"foreArmL.rx":.6,"foreArmR.rx":.6})},sitKneel:{label:"\u041D\u0430 \u043A\u043E\u043B\u0435\u043D\u044F\u0445",en:"Kneel",duration:2,loop:true,tracks:N(2,{"shinL.rx":-1.5,"shinR.rx":-1.5,"root.py":-6.1,"armL.rx":.2,"armR.rx":.2})},sitEdge:{label:"\u041D\u0430 \u043A\u0440\u0430\u044E",en:"Sit on the edge",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rz":-0.3,"armR.rz":.3,"armL.rx":-0.2,"armR.rx":-0.2}),E(2.4,"shinL.rx",-1.2,.3,2),E(2.4,"shinR.rx",-1.2,.3,2,be))},sitLounge:{label:"\u0420\u0430\u0437\u0432\u0430\u043B\u0438\u0432\u0448\u0438\u0441\u044C",en:"Lounge",seat:true,duration:2,loop:true,emotion:"cool",tracks:Se(2,{"body.rx":.35,"head.rx":-0.2,"legL.rx":1.2,"shinL.rx":-0.6,"armL.rz":-2.6,"armR.rz":2.6,"foreArmL.rz":1.8,"foreArmR.rz":-1.8,"root.py":-6.8})},sitHug:{label:"\u041E\u0431\u0445\u0432\u0430\u0442\u0438\u0432 \u043A\u043E\u043B\u0435\u043D\u0438",en:"Hug knees",duration:2,loop:true,emotion:"sad",tracks:N(2,{"legL.rx":2.4,"legR.rx":2.4,"shinL.rx":-2.6,"shinR.rx":-2.6,"root.py":-10.2,"armL.rx":1,"armR.rx":1,"foreArmL.rx":.9,"foreArmR.rx":.9,"head.rx":-0.15,"body.rx":-0.15})},squat:{label:"\u041D\u0430 \u043A\u043E\u0440\u0442\u043E\u0447\u043A\u0430\u0445",en:"Squat",duration:2,loop:true,tracks:N(2,{"legL.rx":2,"legR.rx":2,"legL.rz":-0.2,"legR.rz":.2,"shinL.rx":-2.5,"shinR.rx":-2.5,"root.py":-7,"body.rx":-0.35,"head.rx":.3,"armL.rx":.7,"armR.rx":.7,"foreArmL.rx":.6,"foreArmR.rx":.6})},sitEat:{label:"\u0415\u0441\u0442\u044C \u0441\u0438\u0434\u044F",en:"Eat (seated)",seat:true,duration:1.2,loop:true,tracks:B(Se(1.2,{...Or,"armR.rx":.9}),E(1.2,"foreArmR.rx",1.5,.45,1),E(1.2,"head.rx",-0.1,.06,2))},sitDrink:{label:"\u041F\u0438\u0442\u044C \u0441\u0438\u0434\u044F",en:"Drink (seated)",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{}),{"armR.rx":P(2.4,[[0,.6],[.3,1.2],[.6,1.2],[1,.6]]),"foreArmR.rx":P(2.4,[[0,1.3],[.3,2],[.6,2],[1,1.3]]),"head.rx":P(2.4,[[0,0],[.3,.3],[.6,.3],[1,0]])})},sitRead:{label:"\u0427\u0438\u0442\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Read (seated)",seat:true,duration:3,loop:true,tracks:B(Se(3,{...Yn,"head.rx":-0.3}),E(3,"head.ry",0,.08,1))},sitLaptop:{label:"\u0417\u0430 \u043D\u043E\u0443\u0442\u0431\u0443\u043A\u043E\u043C",en:"Laptop",seat:true,duration:1.2,loop:true,tracks:B(Se(1.2,Wn),E(1.2,"foreArmL.rx",.85,.08,4),E(1.2,"foreArmR.rx",.85,.08,4,be))},sitWrite:{label:"\u041F\u0438\u0441\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Write (seated)",seat:true,duration:1.6,loop:true,tracks:B(Se(1.6,{...Wn,"armL.rx":.6}),E(1.6,"foreArmR.rz",0,.15,3),E(1.6,"head.rz",0,.05,1))},sitTalk:{label:"\u0413\u043E\u0432\u043E\u0440\u0438\u0442\u044C \u0441\u0438\u0434\u044F",en:"Talk (seated)",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rx":.6,"foreArmL.rx":1}),E(2.4,"armR.rx",.8,.3,2),E(2.4,"foreArmR.rx",1.2,.4,3),E(2.4,"head.rz",0,.08,2))},sitLaugh:{label:"\u0421\u043C\u0435\u044F\u0442\u044C\u0441\u044F \u0441\u0438\u0434\u044F",en:"Laugh (seated)",seat:true,duration:1.6,loop:true,emotion:"happy",tracks:B(Se(1.6,{"armL.rx":.5,"armR.rx":.5,"foreArmL.rx":1,"foreArmR.rx":1}),E(1.6,"body.rx",.12,.1,4),E(1.6,"head.rx",.2,.1,4))},sitCry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Cry (seated)",seat:true,duration:2.4,loop:true,emotion:"crying",tracks:B(Se(2.4,{"armL.rx":2.2,"armR.rx":2.2,"foreArmL.rx":1.5,"foreArmR.rx":1.5,"head.rx":-0.45,"body.rx":-0.25}),E(2.4,"body.sy",1,.02,4))},sitDoze:{label:"\u041A\u043B\u0435\u0432\u0430\u0442\u044C \u043D\u043E\u0441\u043E\u043C",en:"Doze",seat:true,duration:3,loop:true,emotion:"sleepy",tracks:B(Se(3,{"armL.rx":.3,"armR.rx":.3}),{"head.rx":P(3,[[0,-0.15],[.6,-0.6],[.7,-0.1],[1,-0.15]])})},sitDrive:{label:"\u0420\u0443\u043B\u0438\u0442\u044C",en:"Drive",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":.5,"foreArmR.rx":.5}),E(2.4,"armL.rz",.2,.2,1),E(2.4,"armR.rz",-0.2,.2,1),E(2.4,"body.rz",0,.05,1,be))},sitGamepad:{label:"\u0418\u0433\u0440\u0430\u0442\u044C \u0441 \u0433\u0435\u0439\u043C\u043F\u0430\u0434\u043E\u043C",en:"Gamepad",seat:true,duration:1.2,loop:true,emotion:"determined",tracks:B(Se(1.2,{"armL.rx":.8,"armR.rx":.8,"foreArmL.rx":1.2,"foreArmR.rx":1.2,"armL.rz":.25,"armR.rz":-0.25,"body.rx":-0.15,"head.rx":-0.05}),E(1.2,"foreArmL.rz",0,.08,4),E(1.2,"body.rz",0,.05,1))},sitClap:{label:"\u0425\u043B\u043E\u043F\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Clap (seated)",seat:true,duration:1.2,loop:true,emotion:"happy",tracks:B(Se(1.2,{"armL.rx":1.1,"armR.rx":1.1,"foreArmL.rx":.6,"foreArmR.rx":.6}),E(1.2,"foreArmL.rz",.55,.35,4),E(1.2,"foreArmR.rz",-0.55,-0.35,4))},lieBack:{label:"\u041B\u0435\u0436\u0430\u0442\u044C \u043D\u0430 \u0441\u043F\u0438\u043D\u0435",en:"Lie on the back",duration:3,loop:true,tracks:B(N(3,{...Ir,"armL.rz":-2.6,"armR.rz":2.6,"foreArmL.rz":1.6,"foreArmR.rz":-1.6,"legL.rx":.1}),E(3,"body.sy",1,.02,1))},lieSide:{label:"\u0421\u043F\u0430\u0442\u044C \u043D\u0430 \u0431\u043E\u043A\u0443",en:"Sleep on the side",duration:3,loop:true,emotion:"sleepy",tracks:B(N(3,{"root.rz":be/2,"root.py":4.6,"legL.rx":.7,"legR.rx":.4,"shinL.rx":-0.9,"shinR.rx":-0.6,"armL.rx":1.2,"armR.rx":.9,"foreArmL.rx":1.2,"head.rz":-0.2}),E(3,"body.sy",1,.02,1))},lieFront:{label:"\u041D\u0430 \u0436\u0438\u0432\u043E\u0442\u0435",en:"Lie on the front",duration:2.4,loop:true,tracks:B(N(2.4,{"root.rx":-be/2,"root.py":2.3,"head.rx":.9,"armL.rx":2.6,"armR.rx":2.6,"foreArmL.rx":1.6,"foreArmR.rx":1.6,"shinR.rx":-1.4}),E(2.4,"shinL.rx",-1.2,.5,1))},getUp:{label:"\u0412\u0441\u0442\u0430\u0442\u044C \u0441 \u043F\u043E\u043B\u0430",en:"Get up",duration:1.8,tracks:{"root.rx":P(1.8,[[0,be/2],[.3,.6],[.6,0],[1,0]]),"root.py":P(1.8,[[0,2.3],[.3,-6],[.6,-6],[1,0]]),"legL.rx":P(1.8,[[0,0],[.3,1.8],[.6,1.5],[1,0]]),"legR.rx":P(1.8,[[0,0],[.3,.2],[.6,-0.1],[1,0]]),"shinL.rx":P(1.8,[[0,0],[.3,-2],[.6,-1.5],[1,0]]),"shinR.rx":P(1.8,[[0,0],[.3,-1.6],[.6,-1.4],[1,0]]),"armL.rx":P(1.8,[[0,0],[.3,-0.6],[.6,.4],[1,0]])}},phone:{label:"\u0413\u043E\u0432\u043E\u0440\u0438\u0442\u044C \u043F\u043E \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0443",en:"Phone call",duration:2.4,loop:true,layer:"upper",tracks:B(N(2.4,{"armR.rx":2.1,"armR.rz":-0.08,"head.rz":-0.15}),E(2.4,"head.rx",0,.05,2),E(2.4,"armL.rz",-0.15,.15,2))},phoneScroll:{label:"\u041B\u0438\u0441\u0442\u0430\u0442\u044C \u0442\u0435\u043B\u0435\u0444\u043E\u043D",en:"Scroll phone",duration:1.6,loop:true,layer:"upper",tracks:B(N(1.6,{...$n,"armL.rx":.5,"foreArmL.rx":1.4,"armL.rz":.3,"head.rx":-0.4}),E(1.6,"foreArmL.rz",.1,.06,2))},selfie:{label:"\u0421\u0435\u043B\u0444\u0438",en:"Selfie",duration:2,loop:true,emotion:"happy",layer:"upper",tracks:B(N(2,{"armR.rx":1.8,"armR.rz":.6,"foreArmR.rx":.2,"head.rz":-0.15,"armL.rz":-1.4,"foreArmL.rz":1.2}),E(2,"head.ry",.2,.05,1))},photo:{label:"\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0440\u043E\u0432\u0430\u0442\u044C",en:"Take a photo",duration:2,loop:true,layer:"upper",tracks:N(2,{"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":1.2,"foreArmR.rx":1.2,"armL.rz":.35,"armR.rz":-0.35,"head.rx":.05})},drinkCup:{label:"\u041F\u0438\u0442\u044C \u0438\u0437 \u043A\u0440\u0443\u0436\u043A\u0438",en:"Drink from a cup",duration:2.4,loop:true,layer:"upper",tracks:{"armR.rx":P(2.4,[[0,.55],[.3,1.2],[.6,1.2],[1,.55]]),"foreArmR.rx":P(2.4,[[0,1.35],[.3,2.1],[.6,2.1],[1,1.35]]),"head.rx":P(2.4,[[0,0],[.3,.3],[.6,.3],[1,0]])}},eat:{label:"\u0415\u0441\u0442\u044C",en:"Eat",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{...Or,"armR.rx":.9}),E(1.2,"foreArmR.rx",1.5,.45,1),E(1.2,"head.rx",-0.1,.06,2))},read:{label:"\u0427\u0438\u0442\u0430\u0442\u044C",en:"Read",duration:3,loop:true,layer:"upper",tracks:B(N(3,{...Yn,"head.rx":-0.35}),E(3,"head.ry",0,.08,1))},board:{label:"\u041F\u0438\u0441\u0430\u0442\u044C \u043D\u0430 \u0434\u043E\u0441\u043A\u0435",en:"Write on a board",duration:2,loop:true,tracks:B(N(2,{"armR.rx":2,"foreArmR.rx":.4,"body.ry":.15,"head.rx":.2}),E(2,"armR.rz",0,.25,2),E(2,"foreArmR.rz",0,.2,4))},cook:{label:"\u0413\u043E\u0442\u043E\u0432\u0438\u0442\u044C",en:"Cook",duration:1.6,loop:true,layer:"upper",tracks:B(N(1.6,{...Or,"armR.rx":.9,"foreArmR.rx":.9,"head.rx":-0.3}),E(1.6,"armR.rz",0,.2,2),E(1.6,"armR.ry",0,.3,2,be/2))},dishes:{label:"\u041C\u044B\u0442\u044C \u043F\u043E\u0441\u0443\u0434\u0443",en:"Wash dishes",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.6,"foreArmR.rx":.6,"head.rx":-0.35,"body.rx":-0.1}),E(1.6,"armR.rz",0,.15,3),E(1.6,"armL.rz",0,.12,3,be))},sweep:{label:"\u041F\u043E\u0434\u043C\u0435\u0442\u0430\u0442\u044C",en:"Sweep",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":.6,"armR.rx":.4,"foreArmL.rx":.9,"foreArmR.rx":.5,"body.rx":-0.15,"head.rx":-0.2}),E(1.6,"body.ry",0,.3,2),E(1.6,"armL.rz",0,.25,2))},water:{label:"\u041F\u043E\u043B\u0438\u0432\u0430\u0442\u044C \u0446\u0432\u0435\u0442\u044B",en:"Water plants",duration:2.4,loop:true,tracks:B(N(2.4,{"armR.rx":.9,"foreArmR.rx":.5,"body.rx":-0.1,"head.rx":-0.3}),E(2.4,"armR.rz",-0.1,.25,1))},dig:{label:"\u041A\u043E\u043F\u0430\u0442\u044C",en:"Dig",duration:1.6,loop:true,emotion:"determined",tracks:{"body.rx":P(1.6,[[0,-0.1],[.4,-0.6],[.7,0],[1,-0.1]]),"armL.rx":P(1.6,[[0,.6],[.4,1.4],[.7,.5],[1,.6]]),"armR.rx":P(1.6,[[0,.4],[.4,.9],[.7,.2],[1,.4]]),"foreArmL.rx":kt(1.6,.8),"foreArmR.rx":kt(1.6,.6),"shinL.rx":P(1.6,[[0,0],[.4,-0.5],[.7,0],[1,0]]),"shinR.rx":P(1.6,[[0,0],[.4,-0.5],[.7,0],[1,0]]),"root.py":P(1.6,[[0,0],[.4,-1],[.7,0],[1,0]])}},fish:{label:"\u0420\u044B\u0431\u0430\u0447\u0438\u0442\u044C",en:"Fish",duration:3,loop:true,tracks:B(N(3,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.9,"foreArmR.rx":.7,"head.rx":.05}),E(3,"armR.rx",.9,.08,2))},paint:{label:"\u0420\u0438\u0441\u043E\u0432\u0430\u0442\u044C \u043D\u0430 \u043C\u043E\u043B\u044C\u0431\u0435\u0440\u0442\u0435",en:"Paint",duration:2,loop:true,layer:"upper",tracks:B(N(2,{"armR.rx":1.4,"foreArmR.rx":.6,...Or,"head.rz":.1}),E(2,"armR.rz",0,.2,2),E(2,"foreArmR.rx",.6,.25,3))},brushTeeth:{label:"\u0427\u0438\u0441\u0442\u0438\u0442\u044C \u0437\u0443\u0431\u044B",en:"Brush teeth",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{"armR.rx":1,"foreArmR.rx":2,"armR.rz":-0.2,"head.rx":.05}),E(1.2,"armR.ry",0,.2,6))},washFace:{label:"\u0423\u043C\u044B\u0432\u0430\u0442\u044C\u0441\u044F",en:"Wash face",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":1.9,"foreArmR.rx":1.9,"body.rx":-0.45,"head.rx":-0.3}),E(1.6,"foreArmL.rx",1.9,.25,3),E(1.6,"foreArmR.rx",1.9,.25,3))},openDoor:{label:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0434\u0432\u0435\u0440\u044C",en:"Open a door",duration:1.6,layer:"upper",tracks:{"armR.rx":P(1.6,[[0,0],[.3,1.3],[.6,1.3],[.9,.6],[1,0]]),"foreArmR.rx":P(1.6,[[0,0],[.3,.4],[.6,.4],[1,0]]),"armR.ry":P(1.6,[[0,0],[.3,0],[.45,-0.5],[.9,-0.6],[1,0]]),"body.ry":P(1.6,[[0,0],[.6,-0.2],[1,0]])}},knock:{label:"\u041F\u043E\u0441\u0442\u0443\u0447\u0430\u0442\u044C",en:"Knock",duration:1.4,layer:"upper",tracks:B({"armR.rx":P(1.4,[[0,0],[.2,1.3],[.85,1.3],[1,0]])},E(1.4,"foreArmR.rx",1.4,.35,3,0,true),{"head.rz":P(1.4,[[0,0],[.3,.1],[1,0]])})},checkWatch:{label:"\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u043D\u0430 \u0447\u0430\u0441\u044B",en:"Check the time",duration:1.6,layer:"upper",tracks:{"armL.rx":P(1.6,[[0,0],[.25,.9],[.8,.9],[1,0]]),"foreArmL.rx":P(1.6,[[0,0],[.25,1.4],[.8,1.4],[1,0]]),"armL.rz":P(1.6,[[0,0],[.25,.4],[.8,.4],[1,0]]),"head.rx":P(1.6,[[0,0],[.3,-0.4],[.8,-0.4],[1,0]]),"head.ry":P(1.6,[[0,0],[.3,-0.25],[.8,-0.25],[1,0]])}},wait:{label:"\u0416\u0434\u0430\u0442\u044C",en:"Wait",duration:1.2,loop:true,emotion:"tired",tracks:B(N(1.2,{"armL.rz":-0.8,"armR.rz":.8,"foreArmL.rz":1.5,"foreArmR.rz":-1.5}),{"legR.rx":P(1.2,[[0,.15],[.25,.15],[.5,.15],[1,.15]]),"shinR.rx":P(1.2,[[0,-0.2],[.2,-0.45],[.4,-0.2],[.6,-0.45],[.8,-0.2],[1,-0.2]])})},pockets:{label:"\u0420\u0443\u043A\u0438 \u0432 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u0445",en:"Hands in pockets",duration:2,loop:true,emotion:"cool",layer:"upper",tracks:N(2,{"armL.rx":-0.25,"armR.rx":-0.25,"armL.rz":-0.12,"armR.rz":.12,"foreArmL.rx":.5,"foreArmR.rx":.5,"head.rx":.05})},armsCrossed:{label:"\u0420\u0443\u043A\u0438 \u0441\u043A\u0440\u0435\u0449\u0435\u043D\u044B",en:"Arms crossed",duration:2,loop:true,layer:"upper",tracks:N(2,{"armL.rx":.6,"armR.rx":.6,"armL.rz":.35,"armR.rz":-0.35,"foreArmL.rx":1.6,"foreArmR.rx":1.6,"foreArmL.ry":-0.7,"foreArmR.ry":.7,"head.rx":.08})},lean:{label:"\u041E\u0431\u043B\u043E\u043A\u043E\u0442\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u0441\u0442\u0435\u043D\u0443",en:"Lean on a wall",duration:2,loop:true,emotion:"cool",tracks:N(2,{"root.rz":-0.12,"root.px":-1,"legL.rx":.15,"legL.ry":.2,"shinL.rx":-0.4,"armR.rz":1.5,"foreArmR.rz":-1.4,"armL.rx":-0.2,"foreArmL.rx":.4,"head.rz":.06})},shiver:{label:"\u0414\u0440\u043E\u0436\u0430\u0442\u044C \u043E\u0442 \u0445\u043E\u043B\u043E\u0434\u0430",en:"Shiver",duration:1.2,loop:true,emotion:"scared",layer:"upper",tracks:B(N(1.2,{"armL.rx":.8,"armR.rx":.8,"armL.rz":.5,"armR.rz":-0.5,"foreArmL.rx":1.4,"foreArmR.rx":1.4,"head.rx":-0.15}),E(1.2,"body.rz",0,.03,10),E(1.2,"head.rz",0,.04,9))},fan:{label:"\u041E\u0431\u043C\u0430\u0445\u0438\u0432\u0430\u0442\u044C\u0441\u044F",en:"Fan yourself",duration:1.2,loop:true,emotion:"tired",layer:"upper",tracks:B(N(1.2,{"armR.rx":.9,"foreArmR.rx":1.7,"head.rx":.15}),E(1.2,"foreArmR.rz",0,.4,4))},sneeze:{label:"\u0427\u0438\u0445\u043D\u0443\u0442\u044C",en:"Sneeze",duration:1.4,tracks:{"head.rx":P(1.4,[[0,0],[.45,.4],[.55,-0.4],[.8,-0.2],[1,0]]),"body.rx":P(1.4,[[0,0],[.45,.1],[.55,-0.35],[.8,-0.1],[1,0]]),"armR.rx":P(1.4,[[0,0],[.4,1.3],[.8,1.3],[1,0]]),"foreArmR.rx":P(1.4,[[0,0],[.4,1.9],[.8,1.9],[1,0]])}},cough:{label:"\u041A\u0430\u0448\u043B\u044F\u0442\u044C",en:"Cough",duration:1.4,layer:"upper",tracks:B({"armR.rx":P(1.4,[[0,0],[.2,1.2],[.85,1.2],[1,0]]),"foreArmR.rx":P(1.4,[[0,0],[.2,2],[.85,2],[1,0]])},E(1.4,"body.rx",-0.1,.1,3,0,true),E(1.4,"head.rx",-0.1,.12,3,0,true))},hug:{label:"\u041E\u0431\u043D\u044F\u0442\u044C",en:"Hug",duration:2,loop:true,emotion:"love",layer:"upper",tracks:N(2,{"armL.rx":1.3,"armR.rx":1.3,"armL.rz":-0.4,"armR.rz":.4,"foreArmL.rz":1,"foreArmR.rz":-1,"foreArmL.rx":.4,"foreArmR.rx":.4,"head.rz":.1})},handshake:{label:"\u0420\u0443\u043A\u043E\u043F\u043E\u0436\u0430\u0442\u0438\u0435",en:"Handshake",duration:1.6,loop:true,emotion:"happy",layer:"upper",tracks:B(N(1.6,{"armR.rx":.9,"foreArmR.rx":.5}),E(1.6,"foreArmR.rx",.5,.15,3))},highFive:{label:"\u0414\u0430\u0442\u044C \u043F\u044F\u0442\u044C",en:"High five",duration:1.2,emotion:"excited",layer:"upper",tracks:{"armR.rz":P(1.2,[[0,0],[.3,.35],[1,0]]),"armR.rx":P(1.2,[[0,0],[.3,2.8],[.45,2.5],[.8,2.5],[1,0]]),"body.ry":P(1.2,[[0,0],[.4,-0.15],[1,0]])}},throw:{label:"\u0411\u0440\u043E\u0441\u0438\u0442\u044C",en:"Throw",duration:1.2,layer:"upper",tracks:{"armR.rx":P(1.2,[[0,0],[.35,-0.6],[.5,2.2],[.7,1.2],[1,0]]),"armR.rz":P(1.2,[[0,0],[.35,.8],[.5,.2],[1,0]]),"body.ry":P(1.2,[[0,0],[.35,.35],[.55,-0.3],[1,0]]),"armL.rx":P(1.2,[[0,0],[.35,1],[.55,.2],[1,0]])}},catch:{label:"\u041F\u043E\u0439\u043C\u0430\u0442\u044C",en:"Catch",duration:1.2,emotion:"surprised",layer:"upper",tracks:{"armL.rx":P(1.2,[[0,0],[.3,1.6],[.5,1.4],[.8,.9],[1,0]]),"armR.rx":P(1.2,[[0,0],[.3,1.6],[.5,1.4],[.8,.9],[1,0]]),"foreArmL.rx":P(1.2,[[0,0],[.5,.4],[.8,1.2],[1,0]]),"foreArmR.rx":P(1.2,[[0,0],[.5,.4],[.8,1.2],[1,0]]),"body.rx":P(1.2,[[0,0],[.5,.08],[1,0]])}},juggle:{label:"\u041F\u043E\u0434\u043A\u0438\u0434\u044B\u0432\u0430\u0442\u044C \u043C\u044F\u0447",en:"Juggle",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{"armL.rx":.7,"armR.rx":.7,"head.rx":.35}),E(1.2,"foreArmL.rx",1.2,.35,2),E(1.2,"foreArmR.rx",1.2,.35,2,be))}};var Gt=Math.PI,ca={clap:{label:"\u0425\u043B\u043E\u043F\u0430\u0442\u044C",en:"Clap",duration:1.8,emotion:"happy",layer:"upper",tracks:B(le(1.8,{"armL.rx":1.2,"armR.rx":1.2,"armL.rz":.25,"armR.rz":-0.25},.2),E(1.8,"foreArmL.rz",.55,.35,5,0,true),E(1.8,"foreArmR.rz",-0.55,-0.35,5,0,true),le(1.8,{"foreArmL.rx":.6,"foreArmR.rx":.6},.2))},salute:{label:"\u041E\u0442\u0434\u0430\u0442\u044C \u0447\u0435\u0441\u0442\u044C",en:"Salute",duration:1.6,layer:"upper",tracks:le(1.6,{"armR.rx":2.6,"armR.rz":-0.12,"head.rx":.08},.25)},thumbsUp:{label:"\u041A\u043B\u0430\u0441\u0441",en:"Thumbs up",duration:1.4,emotion:"happy",layer:"upper",tracks:le(1.4,{"armR.rx":1,"armR.rz":.3,"foreArmR.rx":1.2,"head.rz":-0.1},.2)},heartHands:{label:"\u0421\u0435\u0440\u0434\u0446\u0435 \u0440\u0443\u043A\u0430\u043C\u0438",en:"Heart hands",duration:2,emotion:"love",layer:"upper",tracks:le(2,{"armL.rz":-2.3,"armR.rz":2.3,"armL.rx":.4,"armR.rx":.4,"foreArmL.rz":1.3,"foreArmR.rz":-1.3,"head.rz":.12})},think:{label:"\u0414\u0443\u043C\u0430\u0442\u044C",en:"Think",duration:2.4,emotion:"confused",layer:"upper",tracks:B(le(2.4,{"armR.rx":.9,"armR.rz":-0.2,"foreArmR.rx":2.1,"armL.rx":.5,"foreArmL.rx":1.4,"armL.rz":.3}),E(2.4,"head.rz",.12,.05,2,0,true),le(2.4,{"head.rx":.15}))},nod:{label:"\u0414\u0430",en:"Yes",duration:1.2,layer:"upper",tracks:E(1.2,"head.rx",-0.1,.22,3,0,true)},headShake:{label:"\u041D\u0435\u0442",en:"No",duration:1.2,layer:"upper",tracks:E(1.2,"head.ry",0,.4,3,0,true)},beckon:{label:"\u0418\u0434\u0438 \u0441\u044E\u0434\u0430",en:"Come here",duration:1.8,layer:"upper",tracks:B(le(1.8,{"armR.rx":1.3,"armR.rz":.2}),E(1.8,"foreArmR.rx",1,.6,3,0,true),le(1.8,{"head.rz":.1}))},stop:{label:"\u0421\u0442\u043E\u043F",en:"Stop",duration:1.4,emotion:"determined",layer:"upper",tracks:le(1.4,{"armR.rx":1.55,"foreArmR.rx":1.2,"body.rx":.06},.15)},yawn:{label:"\u0417\u0435\u0432\u043D\u0443\u0442\u044C",en:"Yawn",duration:2.4,emotion:"sleepy",layer:"upper",tracks:le(2.4,{"armR.rx":1.4,"foreArmR.rx":1.9,"armR.rz":-0.25,"armL.rz":-0.35,"armL.rx":-0.15,"head.rx":.35,"body.rx":.08},.5)},stretch:{label:"\u041F\u043E\u0442\u044F\u043D\u0443\u0442\u044C\u0441\u044F",en:"Stretch",duration:2.6,emotion:"sleepy",tracks:B(le(2.6,{"armL.rz":-2.9,"armR.rz":2.9,"head.rx":.3,"body.rx":.12},.6),{"root.py":P(2.6,[[0,0],[.3,.8],[.7,.8],[1,0]])})},flex:{label:"\u0421\u0438\u043B\u0430",en:"Flex",duration:1.8,emotion:"determined",layer:"upper",tracks:B(le(1.8,{"armL.rz":-1.5,"armR.rz":1.5,"foreArmL.rz":-1.6,"foreArmR.rz":1.6,"body.rx":.08},.25),E(1.8,"body.ry",0,.15,2,0,true))},jumpJoy:{label:"\u041F\u0440\u044B\u0436\u043E\u043A \u0440\u0430\u0434\u043E\u0441\u0442\u0438",en:"Jump for joy",duration:1.4,emotion:"excited",tracks:{"root.py":P(1.4,[[0,0],[.15,-1.5],[.4,6],[.6,6],[.8,0],[.9,-1],[1,0]]),"armL.rz":P(1.4,[[0,0],[.4,-2.8],[.7,-2.8],[1,0]]),"armR.rz":P(1.4,[[0,0],[.4,2.8],[.7,2.8],[1,0]]),"shinL.rx":P(1.4,[[0,0],[.15,-0.6],[.45,-1.4],[.7,-1.2],[.85,-0.4],[1,0]]),"shinR.rx":P(1.4,[[0,0],[.15,-0.6],[.45,-1.4],[.7,-1.2],[.85,-0.4],[1,0]])}},spin:{label:"\u041A\u0440\u0443\u0436\u0438\u0442\u044C\u0441\u044F",en:"Spin",duration:1.6,emotion:"happy",tracks:{"root.ry":P(1.6,[[0,0],[1,Gt*2]]),"armL.rz":P(1.6,[[0,0],[.2,-1.5],[.8,-1.5],[1,0]]),"armR.rz":P(1.6,[[0,0],[.2,1.5],[.8,1.5],[1,0]])}},victory:{label:"\u041F\u043E\u0431\u0435\u0434\u0430",en:"Victory",duration:2,emotion:"excited",tracks:B(le(2,{"armR.rz":2.9,"armL.rz":-0.4,"foreArmL.rx":1.3,"armL.rx":.3,"head.rx":.2,"body.rx":.08}),{"root.py":P(2,[[0,0],[.2,3],[.35,0],[1,0]])})},airGuitar:{label:"\u0413\u0438\u0442\u0430\u0440\u0430",en:"Air guitar",duration:2.4,loop:true,emotion:"excited",tracks:B(N(2.4,{"armL.rx":1.2,"armL.rz":-0.5,"foreArmL.rz":.7,"armR.rx":.5,"foreArmR.rx":1.2,"legL.rx":.3,"shinL.rx":-0.4}),E(2.4,"foreArmR.rz",-0.2,.35,8),E(2.4,"head.rx",-0.1,.18,4),E(2.4,"body.rx",-0.05,.06,4))},drum:{label:"\u0411\u0430\u0440\u0430\u0431\u0430\u043D",en:"Drum",duration:1.6,loop:true,emotion:"excited",tracks:B(N(1.6,{"armL.rx":.7,"armR.rx":.7}),E(1.6,"foreArmL.rx",1,.5,4),E(1.6,"foreArmR.rx",1,.5,4,Gt),E(1.6,"head.rx",0,.12,4))},pushups:{label:"\u041E\u0442\u0436\u0438\u043C\u0430\u043D\u0438\u044F",en:"Push-ups",duration:2,loop:true,emotion:"determined",tracks:B(N(2,{"root.rx":-1.35,"armL.rx":1.45,"armR.rx":1.45,"head.rx":1.1}),E(2,"root.py",3.4,1.2,2),E(2,"foreArmL.rx",-0.5,.5,2),E(2,"foreArmR.rx",-0.5,.5,2))},kneel:{label:"\u041D\u0430 \u043A\u043E\u043B\u0435\u043D\u043E",en:"Kneel",duration:2.4,tracks:le(2.4,{"legR.rx":-0.15,"shinR.rx":-1.4,"legL.rx":1.5,"shinL.rx":-1.5,"root.py":-6,"armR.rx":.9,"foreArmR.rx":1.4,"head.rx":-0.15},.5)},curtsy:{label:"\u0420\u0435\u0432\u0435\u0440\u0430\u043D\u0441",en:"Curtsy",duration:1.6,tracks:le(1.6,{"legR.rx":-0.4,"shinL.rx":-0.6,"shinR.rx":-0.6,"root.py":-1.4,"armL.rz":-0.5,"armR.rz":.5,"body.rx":-0.15,"head.rx":-0.2},.4)},scratchHead:{label:"\u041F\u043E\u0447\u0435\u0441\u0430\u0442\u044C \u0437\u0430\u0442\u044B\u043B\u043E\u043A",en:"Scratch head",duration:1.8,emotion:"confused",layer:"upper",tracks:B(le(1.8,{"armR.rx":3.05,"armR.rz":-0.35,"head.rz":.15,"head.rx":.2}),E(1.8,"foreArmR.rx",.35,.25,5,0,true))},hide:{label:"\u0421\u043F\u0440\u044F\u0442\u0430\u0442\u044C\u0441\u044F",en:"Hide",duration:2,emotion:"scared",tracks:le(2,{"armL.rx":2.4,"armR.rx":2.4,"foreArmL.rx":1.4,"foreArmR.rx":1.4,"body.rx":-0.35,"head.rx":-0.4,"shinL.rx":-0.5,"shinR.rx":-0.5,"root.py":-1.5},.2)},stomp:{label:"\u0422\u043E\u043F\u043D\u0443\u0442\u044C",en:"Stomp",duration:1.2,emotion:"angry",tracks:B(le(1.2,{"armL.rz":-0.35,"armR.rz":.35,"body.rx":-0.1},.15),{"legR.rx":P(1.2,[[0,0],[.3,.8],[.45,0],[.65,.8],[.8,0],[1,0]]),"shinR.rx":P(1.2,[[0,0],[.3,-1],[.45,0],[.65,-1],[.8,0],[1,0]])})},slump:{label:"\u041F\u043E\u043D\u0438\u043A",en:"Slump",duration:2.4,emotion:"sad",tracks:le(2.4,{"body.rx":-0.35,"head.rx":-0.45,"armL.rz":.05,"armR.rz":-0.05,"shinL.rx":-0.15,"shinR.rx":-0.15},.6)},rollLaugh:{label:"\u0412\u0430\u043B\u044F\u0442\u044C\u0441\u044F \u043E\u0442 \u0441\u043C\u0435\u0445\u0430",en:"Rolling with laughter",duration:2.4,loop:true,emotion:"happy",tracks:B(N(2.4,{...Ir,"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":1.2,"foreArmR.rx":1.2}),E(2.4,"root.rz",0,.35,2),E(2.4,"legL.rx",1,.5,4),E(2.4,"legR.rx",1,.5,4,Gt),E(2.4,"head.rx",.2,.15,6))},blowKiss:{label:"\u0412\u043E\u0437\u0434\u0443\u0448\u043D\u044B\u0439 \u043F\u043E\u0446\u0435\u043B\u0443\u0439",en:"Blow a kiss",duration:1.6,emotion:"love",layer:"upper",tracks:{"armR.rx":P(1.6,[[0,0],[.3,1.2],[.55,1.2],[.75,1.6],[1,0]]),"foreArmR.rx":P(1.6,[[0,0],[.3,2],[.55,2],[.75,.3],[1,0]]),"armR.rz":P(1.6,[[0,0],[.3,-0.2],[.75,.4],[1,0]]),"head.rz":P(1.6,[[0,0],[.3,.12],[.9,.12],[1,0]])}},phew:{label:"\u0424\u0443\u0445",en:"Phew",duration:1.6,emotion:"tired",layer:"upper",tracks:{"armR.rz":P(1.6,[[0,0],[.3,1.7],[.7,2.1],[1,0]]),"foreArmR.rz":P(1.6,[[0,0],[.3,-1.4],[.7,-1.6],[1,0]]),"head.rx":P(1.6,[[0,0],[.3,.2],[.7,-0.2],[1,0]]),"body.rx":P(1.6,[[0,0],[.6,-0.08],[1,0]])}},lookAround:{label:"\u041E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C\u0441\u044F",en:"Look around",duration:2.6,layer:"upper",tracks:{"head.ry":P(2.6,[[0,0],[.2,.9],[.45,.9],[.65,-0.9],[.85,-0.9],[1,0]]),"body.ry":P(2.6,[[0,0],[.2,.25],[.45,.25],[.65,-0.25],[.85,-0.25],[1,0]]),"armR.rx":P(2.6,[[0,0],[.2,2.6],[.85,2.6],[1,0]]),"foreArmR.rx":P(2.6,[[0,0],[.2,.9],[.85,.9],[1,0]])}},karate:{label:"\u041A\u0430\u0440\u0430\u0442\u044D",en:"Karate",duration:1.8,emotion:"determined",tracks:{"armR.rx":P(1.8,[[0,.6],[.2,.6],[.3,1.57],[.45,.6],[1,0]]),"foreArmR.rx":P(1.8,[[0,1.6],[.2,1.6],[.3,0],[.45,1.6],[1,0]]),"armL.rx":P(1.8,[[0,.6],[.45,.6],[.55,1.57],[.7,.6],[1,0]]),"foreArmL.rx":P(1.8,[[0,1.6],[.45,1.6],[.55,0],[.7,1.6],[1,0]]),"legR.rx":P(1.8,[[0,0],[.7,0],[.8,1.4],[.9,0],[1,0]]),"body.ry":P(1.8,[[0,0],[.3,-0.3],[.55,.3],[.8,0],[1,0]]),"root.py":P(1.8,[[0,-1],[.9,-1],[1,0]])}},nap:{label:"\u0423\u0441\u043D\u0443\u0442\u044C",en:"Nap",duration:3,loop:true,emotion:"sleepy",tracks:B(N(3,{...Ir,"armL.rz":-0.3,"armR.rz":2.4,"foreArmR.rz":-1.4,"legL.rx":.15}),E(3,"body.sy",1,.03,1))},danceRobot:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0420\u043E\u0431\u043E\u0442\xBB",en:"Robot dance",duration:2,loop:true,emotion:"cool",tracks:{"armL.rx":P(2,[[0,1.57],[.25,1.57],[.26,0],[.5,0],[.51,1.57],[.75,1.57],[.76,0],[1,1.57]]),"foreArmL.rx":P(2,[[0,0],[.25,0],[.26,1.57],[.5,1.57],[.51,0],[1,0]]),"armR.rx":P(2,[[0,0],[.25,0],[.26,1.57],[.5,1.57],[.51,0],[.75,0],[.76,1.57],[1,0]]),"foreArmR.rx":P(2,[[0,1.57],[.25,1.57],[.26,0],[.75,0],[.76,1.57],[1,1.57]]),"head.ry":P(2,[[0,.4],[.25,.4],[.26,-0.4],[.75,-0.4],[.76,.4],[1,.4]]),"root.py":P(2,[[0,0],[.25,-0.8],[.5,0],[.75,-0.8],[1,0]])}},danceHop:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u041F\u0440\u044B\u0433-\u0441\u043A\u043E\u043A\xBB",en:"Hop dance",duration:1.6,loop:true,emotion:"excited",tracks:B(E(1.6,"root.py",1.2,1.2,4),E(1.6,"legL.rx",.25,.35,2),E(1.6,"legR.rx",.25,.35,2,Gt),E(1.6,"shinL.rx",-0.5,.3,2),E(1.6,"shinR.rx",-0.5,.3,2,Gt),E(1.6,"armL.rz",-1.6,.9,2),E(1.6,"armR.rz",1.6,.9,2))},danceSway:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u041F\u043E\u043A\u0430\u0447\u0438\u0432\u0430\u043D\u0438\u0435\xBB",en:"Sway dance",duration:2.4,loop:true,emotion:"happy",tracks:B(E(2.4,"body.rz",0,.12,2),E(2.4,"head.rz",0,.16,2,Gt),E(2.4,"root.px",0,1.2,2),E(2.4,"armL.rz",-0.6,.4,2),E(2.4,"armR.rz",.6,.4,2),N(2.4,{"foreArmL.rx":1.1,"foreArmR.rx":1.1}),E(2.4,"shinL.rx",-0.2,.2,2),E(2.4,"shinR.rx",-0.2,.2,2,Gt))},danceDisco:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0414\u0438\u0441\u043A\u043E\xBB",en:"Disco dance",duration:2,loop:true,emotion:"cool",tracks:{"armR.rz":P(2,[[0,2.6],[.25,.2],[.5,2.6],[.75,.2],[1,2.6]]),"armR.rx":P(2,[[0,.6],[.25,.9],[.5,.6],[.75,.9],[1,.6]]),"armL.rz":kt(2,-0.3),"armL.rx":kt(2,.4),"foreArmL.rx":kt(2,1.3),"body.ry":P(2,[[0,.3],[.25,-0.2],[.5,.3],[.75,-0.2],[1,.3]]),"root.py":P(2,[[0,0],[.125,-0.8],[.25,0],[.375,-0.8],[.5,0],[.625,-0.8],[.75,0],[.875,-0.8],[1,0]]),"legL.rz":P(2,[[0,0],[.25,-0.2],[.5,0],[.75,-0.2],[1,0]])}},danceWave:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0412\u043E\u043B\u043D\u0430\xBB",en:"Wave dance",duration:2,loop:true,emotion:"happy",tracks:B(E(2,"armL.rz",-1.57,.35,2,0),E(2,"foreArmL.rz",0,.6,2,.8),E(2,"armR.rz",1.57,-0.35,2,1.6),E(2,"foreArmR.rz",0,-0.6,2,2.4),E(2,"body.rz",0,.08,2,1.2),E(2,"head.rz",0,.12,2,2),E(2,"root.py",-0.4,.4,4))}};var xo=Math.PI,Jn={wave:{label:"\u041F\u043E\u043C\u0430\u0445\u0430\u0442\u044C",duration:2,emotion:"happy",tracks:{"armR.rz":[[0,0],[.25,2.7],[.5,2.3],[.75,2.8],[1,2.3],[1.25,2.8],[1.5,2.4],[2,0]],"armR.rx":[[0,0],[.25,.2],[1.75,.2],[2,0]],"head.rz":[[0,0],[.5,.1],[1.5,.1],[2,0]]}},cheer:{label:"\u0423\u0440\u0430!",duration:1.6,emotion:"happy",tracks:{"armL.rz":[[0,0],[.25,-2.8],[1.35,-2.8],[1.6,0]],"armR.rz":[[0,0],[.25,2.8],[1.35,2.8],[1.6,0]],"root.py":[[0,0],[.3,3],[.55,0],[.8,3],[1.05,0]]}},dance:{label:"\u0422\u0430\u043D\u0435\u0446",duration:2,loop:true,emotion:"happy",tracks:{"root.ry":[[0,.3],[.5,-0.3],[1,.3],[1.5,-0.3],[2,.3]],"armL.rz":[[0,-0.4],[.5,-2.4],[1,-0.4],[1.5,-2.4],[2,-0.4]],"armR.rz":[[0,2.4],[.5,.4],[1,2.4],[1.5,.4],[2,2.4]],"legL.rx":[[0,0],[.5,.5],[1,0],[2,0]],"legR.rx":[[0,0],[1,0],[1.5,.5],[2,0]],"root.py":[[0,0],[.25,1.5],[.5,0],[.75,1.5],[1,0],[1.25,1.5],[1.5,0],[1.75,1.5],[2,0]],"tail.ry":[[0,.6],[.5,-0.6],[1,.6],[1.5,-0.6],[2,.6]]}},point:{label:"\u0423\u043A\u0430\u0437\u0430\u0442\u044C",duration:1.6,tracks:{"armR.rx":[[0,0],[.2,1.55],[1.4,1.55],[1.6,0]]}},laugh:{label:"\u0421\u043C\u0435\u0445",duration:1.6,emotion:"happy",tracks:{"body.rx":[[0,0],[.2,.15],[.4,.05],[.6,.15],[.8,.05],[1,.15],[1.2,.05],[1.6,0]],"head.rx":[[0,0],[.2,.3],[1.4,.3],[1.6,0]],"armL.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]],"armR.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]]}},cry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C",duration:2.4,emotion:"sad",tracks:{"head.rx":[[0,0],[.3,-0.4],[2.1,-0.4],[2.4,0]],"head.rz":[[0,0],[.6,.08],[.9,-0.08],[1.2,.08],[1.5,-0.08],[2.4,0]],"armR.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armR.ry":[[0,0],[.3,-0.6],[2.1,-0.6],[2.4,0]],"armL.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armL.ry":[[0,0],[.3,.6],[2.1,.6],[2.4,0]]}},bow:{label:"\u041F\u043E\u043A\u043B\u043E\u043D",duration:1.4,tracks:{"body.rx":[[0,0],[.4,-0.7],[1,-0.7],[1.4,0]],"armR.rx":[[0,0],[.4,.5],[1,.5],[1.4,0]]}},shrug:{label:"\u041F\u043E\u0436\u0430\u0442\u044C \u043F\u043B\u0435\u0447\u0430\u043C\u0438",duration:1.2,tracks:{"armL.rz":[[0,0],[.3,-0.5],[.9,-0.5],[1.2,0]],"armR.rz":[[0,0],[.3,.5],[.9,.5],[1.2,0]],"armL.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"armR.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"head.rz":[[0,0],[.3,.25],[.9,.25],[1.2,0]]}},facepalm:{label:"\u0420\u0443\u043A\u0430-\u043B\u0438\u0446\u043E",duration:1.6,emotion:"tired",tracks:{"armR.rx":[[0,0],[.3,2.5],[1.3,2.5],[1.6,0]],"armR.rz":[[0,0],[.3,-0.4],[1.3,-0.4],[1.6,0]],"head.rx":[[0,0],[.3,-0.35],[1.3,-0.35],[1.6,0]]}},sit:{label:"\u0421\u0435\u0441\u0442\u044C",duration:1,loop:true,tracks:{"legL.rx":[[0,xo*.46],[1,xo*.46]],"legR.rx":[[0,xo*.46],[1,xo*.46]],"root.py":[[0,-10],[1,-10]]}}},$e={...Jn,...ca,...la},Op=[...Object.keys(Jn),...Object.keys(ca)],_p=Object.keys(la),Vp=Object.keys($e);function pa(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call($e,e)}function Fp(e){return pa(e)&&$e[e].seat===true}function Bp(e,t){let r=$e[e];return t?r.label:r.en??e}function dl(e,t){let r=e[0];if(t<=r[0])return r[1];for(let o=1;o<e.length;o++){let a=e[o];if(t<=a[0]){let n=e[o-1],s=(t-n[0])/Math.max(1e-6,a[0]-n[0]),l=s*s*(3-2*s);return n[1]+(a[1]-n[1])*l}}return e[e.length-1][1]}function Xn(e,t,r){let o=t.loop?r%t.duration:Math.min(r,t.duration);for(let[a,n]of Object.entries(t.tracks)){let s=a.lastIndexOf("."),l=a.slice(0,s),i=a.slice(s+1);i in I&&y(e,l,i,dl(n,o));}}var ul=["neutral","happy","sad","angry","surprised","scared","tired","hurt"],vt=[...ul,"love","excited","smug","confused","embarrassed","silly","cool","disgusted","determined","crying","dizzy","sleepy","wink"];function fl(e){return typeof e=="string"&&vt.includes(e)}var Qn={neutral:"neutral",happy:"happy",sad:"sad",angry:"angry",surprised:"surprised",scared:"scared",tired:"tired",hurt:"hurt",love:"happy",excited:"happy",smug:"happy",confused:"surprised",embarrassed:"happy",silly:"happy",cool:"neutral",disgusted:"angry",determined:"angry",crying:"sad",dizzy:"hurt",sleepy:"tired",wink:"happy"};var _r={move:["idle","talk","walk","run","jump","fall","tiptoe","limp","crawl","climb","jog","carry","push","pull"],sit:["sit","sitChair","sitFloor","sitKneel","sitEdge","sitLounge","sitHug","squat","sitEat","sitDrink","sitRead","sitLaptop","sitWrite","sitTalk","sitLaugh","sitCry","sitDoze","sitDrive","sitGamepad","sitClap"],lie:["lieBack","lieSide","lieFront","getUp"],home:["phone","phoneScroll","selfie","photo","drinkCup","eat","read","board","cook","dishes","sweep","water","dig","fish","paint","brushTeeth","washFace","openDoor","knock","checkWatch","wait","pockets","armsCrossed","lean","shiver","fan","sneeze","cough"],social:["wave","point","surprised","dance","hug","handshake","highFive","throw","catch","juggle"]},Zn=[..._r.move,..._r.sit,..._r.lie,..._r.home,..._r.social];var lr={neutral:["neutral"],happy:["happy","neutral"],sad:["sad","tired","neutral"],angry:["angry","neutral"],surprised:["surprised","scared","neutral"],scared:["scared","surprised","sad","neutral"],tired:["tired","sad","neutral"],hurt:["hurt","angry","sad","neutral"],love:["happy","neutral"],excited:["happy","surprised","neutral"],smug:["happy","neutral"],confused:["surprised","neutral"],embarrassed:["happy","sad","neutral"],silly:["happy","neutral"],cool:["neutral"],disgusted:["angry","sad","neutral"],determined:["angry","neutral"],crying:["sad","tired","neutral"],dizzy:["hurt","tired","neutral"],sleepy:["tired","blink","neutral"],wink:["happy","neutral"]},ma={neutral:{add:{},tempo:1},happy:{add:{"head.rx":.08},tempo:1.1},sad:{add:{"head.rx":-0.3,"body.rx":-0.08,"tail.rx":.5},tempo:.8},angry:{add:{"body.rx":-0.12,"head.rx":.1,"armL.rz":-0.1,"armR.rz":.1},tempo:1.1},surprised:{add:{"head.rx":.15,"body.rx":.05},tempo:1},scared:{add:{"body.rx":-0.1,"head.rx":-0.1,"armL.rx":.3,"armR.rx":.3,"tail.rx":.6},tempo:1.3},tired:{add:{"head.rx":-0.35,"body.rx":-0.12},tempo:.7},hurt:{add:{"body.rx":-0.1},tempo:1},love:{add:{"head.rz":.12,"head.rx":.06},tempo:.9},excited:{add:{"head.rx":.12,"body.rx":.04},tempo:1.3},smug:{add:{"head.rx":.14,"head.rz":-0.08},tempo:.9},confused:{add:{"head.rz":.22},tempo:.9},embarrassed:{add:{"head.rx":-0.2,"head.ry":.25,"armL.rx":.15,"armR.rx":.15},tempo:.9},silly:{add:{"head.rz":-0.18},tempo:1.2},cool:{add:{"head.rx":.06,"body.rx":.04},tempo:.85},disgusted:{add:{"head.rx":.1,"head.ry":-0.3,"body.rx":.06},tempo:1},determined:{add:{"body.rx":-0.06,"armL.rz":-0.08,"armR.rz":.08},tempo:1.15},crying:{add:{"head.rx":-0.35,"body.rx":-0.1,"tail.rx":.5},tempo:.75},dizzy:{add:{"head.rz":.15,"body.rz":-0.05},tempo:.8},sleepy:{add:{"head.rx":-0.4,"head.rz":.1,"body.rx":-0.1},tempo:.6},wink:{add:{"head.rz":.1},tempo:1.05}};function es(e,t,r){if(!(r<=0))for(let[o,a]of Object.entries(ma[t].add)){let n=o.lastIndexOf(".");de(e,o.slice(0,n),o.slice(n+1),(a??0)*r);}}var qp={damaged:{emotion:"hurt",seconds:.8},lowHealth:{emotion:"tired"},nearDeath:{emotion:"scared"},achievement:{emotion:"happy",seconds:3},bossKilled:{emotion:"happy",seconds:5},tamed:{emotion:"happy",seconds:3},traded:{emotion:"happy",seconds:2},petDied:{emotion:"sad",seconds:6},explosion:{emotion:"surprised",seconds:1.5}};function Up(e){let t=[[/(😍|🥰|😘|❤|💕)/u,"love"],[/(🤩|🥳)/u,"excited"],[/(😏)/u,"smug"],[/(😕|🤔|😵‍💫)/u,"confused"],[/(😳|☺)/u,"embarrassed"],[/(😜|😝|😛|:P|:p)/u,"silly"],[/(😎)/u,"cool"],[/(🤢|🤮)/u,"disgusted"],[/(😤|💪)/u,"determined"],[/(😭)/u,"crying"],[/(😵)/u,"dizzy"],[/(😴|💤)/u,"sleepy"],[/(😉|;\))/u,"wink"],[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of t)if(r.test(e))return o;return null}var bl=[{state:"dead",when:e=>e.dead,clip:"dead",blend:.25},{state:"sleep",when:e=>e.sleeping,clip:"sleep",blend:.3},{state:"ride",when:e=>e.riding,clip:"ride",blend:.2},{state:"sit",when:e=>e.sitting,clip:"sit",blend:.3},{state:"swim",when:e=>e.inWater&&!e.onGround&&!e.flying,clip:"swim",blend:.3},{state:"glide",when:e=>e.gliding,clip:"glide",blend:.25},{state:"fly",when:e=>e.flying,clip:"fly",blend:.25},{state:"fall",when:(e,t)=>t.airTime>.35&&e.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:e=>e.sneaking,clip:"sneak",blend:.15},{state:"run",when:e=>e.sprinting&&e.speed>3||e.speed>6.5,clip:"run",blend:.15},{state:"walk",when:e=>e.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],yl=new Set(["idle","walk","run","sneak","sit"]),gl=new Set(["hurt","land","shoot"]),xl={eat:"eat",drink:"drink",draw:"draw",block:"block"},wl={tail:(e,t)=>[["ry",-e.yawRate*.25+.12*Math.sin(t*2)],["rx",-(.1+Math.min(e.speed,8)*.06)]],cape:(e,t)=>[["rx",-(.05+Math.min(e.speed,8)*.12)-(e.speed>1?.06*Math.sin(t*9):0)-(e.vy<-3?.4:0)]],hair:e=>[["rx",-Math.min(e.speed,8)*.03]],ear:(e,t)=>[["rz",.08*Math.sin(t*1.3)+Math.min(e.speed,6)*.02]],antenna:(e,t)=>[["rx",.1*Math.sin(t*3)-e.vy*.02]],wingL:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?-0.05:-0.7*Math.sin(t*12)]]:[["rz",1.1+.05*Math.sin(t*1.5)]],wingR:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?.05:.7*Math.sin(t*12)]]:[["rz",-1.1-.05*Math.sin(t*1.5)]]},wo=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},Ro=class{rig;style;faces;pose=new Map;expression="neutral";state="idle";stateT=0;clock=0;phase=0;airTime=0;wasOnGround=true;loco=new Map;from=new Map;lastLoco=new Map;blendT=1;blendDur=.2;tmp=new Map;upperPose=new Map;upperDef=null;actions=[];useClip=null;useW=0;emote=null;mood="neutral";moodOverGestures=false;flash=null;postureW=new Map;blinkT=3;blinking=0;talkT=0;springs=new Map;constructor(t,r,o=[]){this.rig=t,this.style=aa(r),this.faces=new Set(o);}setRandom(t){this.random=t;}random=Math.random;setStyle(t){this.style=aa(t);}setEmotion(t,r){r&&r>0?this.flash={emotion:t,left:r}:this.mood=t;}get emotion(){return this.emote?.def.emotion&&!this.moodOverGestures?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}get plant(){return yl.has(this.state)&&this.airTime<.12?1:0}get standing(){return this.state==="idle"&&!this.emote&&this.stateT>.2}playEmote(t){this.emote={id:t,def:$e[t],t:0};}stopEmote(){this.emote=null;}trigger(t){switch(t){case "swing":case "place":case "throw":case "shoot":case "punch":case "hurt":case "land":{let r=t;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:qn[r]??.3}),t==="hurt"&&this.setEmotion("hurt",.8);break}}}update(t,r=so()){t=Math.min(t,.1),this.clock+=t;let o=this.emotion,a=ma[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=t:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*t*3.5*a;let n=bl.find(c=>c.when(r,this));n.state!==this.state&&(Be(this.from,this.lastLoco),this.state=n.state,this.stateT=0,this.blendT=0,this.blendDur=n.blend),this.stateT+=t,ft(this.loco);let s=Gn[this.rig]?.[n.clip]??n.clip,l={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*a};if(zr[s](this.loco,l),ft(this.pose),this.blendT<this.blendDur?(this.blendT+=t,pn(this.pose,this.from,this.loco,wo(this.blendT/this.blendDur))):Be(this.pose,this.loco),Be(this.lastLoco,this.pose),this.emote){let c=this.emote;c.t+=t;let p=c.def.layer==="upper";if((p?!(this.state==="idle"||this.state==="walk"||this.state==="run"||this.state==="sneak"):r.speed>1||this.state!=="idle")||!c.def.loop&&c.t>=c.def.duration)this.emote=null;else {let d=c.def.loop?wo(c.t/.15):wo(Math.min(c.t/.15,(c.def.duration-c.t)/.15)),b=p?this.upperPose:this.tmp;p&&this.upperDef!==c.def&&(b.clear(),this.upperDef=c.def),ft(b),Xn(b,c.def,c.t),this.overlay(b,d,false);}}let i=r.use?xl[r.use]:null;i&&(this.useClip=i),this.useW=Math.max(0,Math.min(1,this.useW+(i?t:-t)*8)),this.useClip&&this.useW>0?(ft(this.tmp),zr[this.useClip](this.tmp,{...l,t:this.clock}),this.overlay(this.tmp,wo(this.useW),false)):r.aiming&&(r.held==="pistol"||r.held==="rifle")?(ft(this.tmp),zr[r.held==="rifle"?"aimRifle":"aimPistol"](this.tmp,l),this.overlay(this.tmp,1,false),de(this.pose,"armR","rx",Math.max(-0.8,Math.min(.8,r.lookPitch))),de(this.pose,"armL","rx",Math.max(-0.8,Math.min(.8,r.lookPitch)))):r.held!=="none"&&!this.emote&&de(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let c of this.actions){c.t+=t;let p=Math.min(1,c.t/c.dur);ft(this.tmp),zr[c.clip](this.tmp,{...l,t:c.t,k:p}),this.overlay(this.tmp,1,gl.has(c.clip));}this.actions=this.actions.filter(c=>c.t<c.dur),this.state!=="dead"&&this.state!=="sleep"&&(de(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),de(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=t)<=0&&(this.flash=null);for(let c of vt){let p=this.postureW.get(c)??0,h=p+((c===o?1:0)-p)*Math.min(1,t*6);this.postureW.set(c,h),this.state!=="dead"&&es(this.pose,c,h);}for(let[c,p]of Object.entries(wl))for(let[h,m]of p(r,this.clock)){let d=c+"."+h,b=this.springs.get(d);b||this.springs.set(d,b={x:m,v:0});let u=60,R=9;b.v+=(u*(m-b.x)-R*b.v)*t,b.x+=b.v*t,de(this.pose,c,h,b.x);}return this.expression=this.face(r,t,o),this.pose}overlay(t,r,o){for(let[a,n]of t){let s=ae(this.pose,a);for(let l=0;l<9;l++)o?l>=I.sx?s[l]=s[l]*(1+(n[l]-1)*r):s[l]=s[l]+(n[l]-nr[l])*r:s[l]=s[l]+(n[l]-s[l])*r;}}face(t,r,o){let a=s=>s.find(l=>this.faces.has(l))??"neutral";if(t.dead||this.state==="dead"||t.sleeping)return a(["blink","hurt","neutral"]);let n=a(lr[o]);return t.viseme!==void 0?(this.talkT=0,t.viseme!=="rest"&&t.viseme!=="MBP"?a(["talk",n]):n):t.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?a(["talk",n]):n):(this.talkT=0,this.blinking>0?(this.blinking-=r,a(["blink",n])):(this.blinkT-=r,this.blinkT<=0&&(this.blinkT=2.5+this.random()*3,o!=="surprised"&&o!=="scared"&&o!=="hurt"&&(this.blinking=.13)),n))}};var je="voxel-v1",Ut=1,Kt=["hair","top","bottom","shoes","hands","waist","back","neck","faceAcc","hat"],ua=["head","torso","sleeveL","sleeveR","forearmL","forearmR","handL","handR","legL","legR","footL","footR"],fa={sleeves:["sleeveL","sleeveR"],forearms:["forearmL","forearmR"],arms:["sleeveL","sleeveR","forearmL","forearmR"],hands:["handL","handR"],legs:["legL","legR"],feet:["footL","footR"]},qt="@skin",ba={hair:{bones:["head"],paint:["head"],paintFaces:["top","back","left","right"],parts:8,box:{min:[-6,22,-6],max:[6,35.5,6]}},hat:{bones:["head"],paint:[],parts:8,box:{min:[-7,21,-8],max:[7,38,7]}},top:{bones:["body","armL","armR","foreArmL","foreArmR"],paint:["torso","sleeveL","sleeveR","forearmL","forearmR"],parts:6,box:{min:[-10,9.5,-6],max:[10,26,6]}},bottom:{bones:["body","legL","legR","shinL","shinR"],paint:["legL","legR"],parts:4,box:{min:[-6.5,.5,-4.5],max:[6.5,17,4.5]}},shoes:{bones:["legL","legR","shinL","shinR"],paint:["footL","footR"],parts:4,box:{min:[-5.5,-0.5,-4.5],max:[5.5,7,4]}},hands:{bones:["armL","armR","foreArmL","foreArmR"],paint:["handL","handR"],parts:2,box:{min:[-10,9.5,-4],max:[10,16,4]}},waist:{bones:["body"],paint:[],parts:4,box:{min:[-7,9.5,-4],max:[7,16.5,4]}},back:{bones:["body"],paint:[],parts:8,box:{min:[-13.5,6,1.5],max:[13.5,36.5,13]}},faceAcc:{bones:["head"],paint:[],parts:8,box:{min:[-6,21,-6.5],max:[6,30.5,5]}},neck:{bones:["body"],paint:[],parts:6,box:{min:[-6,15,-4.5],max:[6,24.5,4.5]}}},Yt={palette:5,textures:4,textureSide:32,texturePixels:2048,id:40,textureId:12,name:40},Fr=["round","sparkle","wide","cat","sleepy","dot","anime","almond","button","narrow","starry","glam"],Br=["soft","thick","arched","none","straight","angled","bushy","thin"],Dr=["smile","grin","cat","small","smirk","open","teeth","fang","tongue","pout"],Nr=["none","freckles","mole","scar","plaster","whiskers","star"],Hr=["block","round"],ya="round",ga=Rr,xa=kr,Et={walk:"bouncy",idle:"calm"},St=[.5,1.8,7.5,5.4],Rl={eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,marks:"none",emotion:"neutral"},Vr={min:.9,max:1.1},At=(e,t,r)=>typeof e=="string"&&t.includes(e)?e:r,da=e=>typeof e=="string"&&Kt.includes(e);function cr(e){let t=J(e)?e:{},r=J(t.body)?t.body:{},o=J(t.face)?t.face:{},a=J(t.anim)?t.anim:{},n=Rl,s={};if(J(t.wear))for(let[i,c]of Object.entries(t.wear))da(i)&&typeof c=="string"&&c.trim()&&(s[i]=c.trim().slice(0,Yt.id));let l={};if(J(t.tint))for(let[i,c]of Object.entries(t.tint)){let p=ot(c);da(i)&&p&&(l[i]=p);}return {version:Ut,style:je,body:{skin:ot(r.skin)??"#f2c9a0",height:Math.round(Ie(r.height,1,Vr.min,Vr.max)*1e3)/1e3,head:At(r.head,Hr,ya)},face:{eyes:At(o.eyes,Fr,n.eyes),eyeColor:ot(o.eyeColor)??n.eyeColor,brows:At(o.brows,Br,n.brows),browColor:ot(o.browColor)??n.browColor,mouth:At(o.mouth,Dr,n.mouth),cheeks:typeof o.cheeks=="boolean"?o.cheeks:n.cheeks,marks:At(o.marks,Nr,"none"),emotion:At(o.emotion,vt,n.emotion)},anim:{walk:At(a.walk,ga,Et.walk),idle:At(a.idle,xa,Et.idle)},wear:s,tint:l}}var kl=/^[a-z0-9][a-z0-9_.-]*$/,vl=/^[A-Za-z0-9]+$/;function ha(e){return !Array.isArray(e)||e.length!==3?null:e.every(t=>typeof t=="number"&&Number.isFinite(t))?e:null}function Al(e,t){if(!t||t.every(o=>o===0))return [e[0]/2,e[1]/2,e[2]/2];let r=Math.hypot(e[0],e[1],e[2])/2;return [r,r,r]}function pr(e){let t=[],r=(A,k,x)=>t.push(ee({en:A,ru:k},x));if(!J(e))return {ok:false,errors:[ee({en:"the item is not an object",ru:"\u0432\u0435\u0449\u044C: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})]};let o=e,a=Yt;o.style!==void 0&&o.style!==je&&r("style \xAB{s}\xBB is not {need}","\u0441\u0442\u0438\u043B\u044C \xAB{s}\xBB: \u043D\u0435 {need}",{s:String(o.style),need:je});let n=typeof o.id=="string"?o.id.trim():"";if((!n||n.length>a.id||!kl.test(n))&&r("id must be 1, {n} characters: a-z, 0-9, _ . -","id: 1, {n} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432: a-z, 0-9, _ . -",{n:a.id}),!da(o.slot))return r("unknown slot \xAB{s}\xBB","\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0441\u043B\u043E\u0442 \xAB{s}\xBB",{s:String(o.slot)}),{ok:false,errors:t};let s=o.slot,l=ba[s],i=typeof o.name=="string"&&o.name.trim()?o.name.trim().slice(0,a.name):n,c={};if(!J(o.palette)||!Object.keys(o.palette).length)r("the palette is empty","\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u043F\u0443\u0441\u0442\u0430");else {let A=Object.entries(o.palette);A.length>a.palette&&r("more than {n} colours in the palette","\u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u0446\u0432\u0435\u0442\u043E\u0432",{n:a.palette});for(let[k,x]of A){let f=x===qt?qt:ot(x);k.length!==1||ut.has(k)||!f?r("palette colour \xAB{k}\xBB is not valid","\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F",{k}):c[k]=f;}}let p=typeof o.tint=="string"&&o.tint?o.tint:null;p!==null&&(!c[p]||c[p]===qt)&&r("tint \xAB{k}\xBB is not a colour of the palette","\u043F\u0435\u0440\u0435\u043A\u0440\u0430\u0441\u043A\u0430 \xAB{k}\xBB: \u043D\u0435 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{k:p});let h={},m=0;if(o.textures!==void 0)if(!J(o.textures))r("textures is not an object","textures: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442");else {let A=Object.entries(o.textures);A.length>a.textures&&r("more than {n} textures","\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n}",{n:a.textures});for(let[k,x]of A){if(k.length>a.textureId||!vl.test(k)){r("texture id \xAB{id}\xBB must be 1, {n} letters or digits","id \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB: 1, {n} \u0431\u0443\u043A\u0432 \u0438\u043B\u0438 \u0446\u0438\u0444\u0440",{id:k.slice(0,20),n:a.textureId});continue}let f=J(x)?x:null,S=f&&Array.isArray(f.rows)?f.rows:null,T=f?f.w:void 0,C=f?f.h:void 0;if(!S||typeof T!="number"||typeof C!="number"||!Number.isInteger(T)||!Number.isInteger(C)||T<1||C<1||T>a.textureSide||C>a.textureSide||S.length!==C||S.some(O=>typeof O!="string"||O.length!==T)){r("texture \xAB{id}\xBB must be w\xD7h \u2264 {n} with exactly h rows of w symbols","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB: w\xD7h \u2264 {n}, \u0440\u043E\u0432\u043D\u043E h \u0441\u0442\u0440\u043E\u043A \u043F\u043E w \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",{id:k,n:a.textureSide});continue}S.some(O=>[...O].some(M=>!ut.has(M)&&!c[M]))&&r("texture \xAB{id}\xBB uses symbols outside the palette","\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{id:k}),m+=T*C,h[k]={w:T,h:C,rows:S.map(O=>O.replace(/ /g,"."))};}m>a.texturePixels&&r("textures take {p} pixels, the limit is {n}","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \u0437\u0430\u043D\u0438\u043C\u0430\u044E\u0442 {p} \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439, \u043F\u0440\u0435\u0434\u0435\u043B {n}",{p:m,n:a.texturePixels});}let d=(A,k)=>typeof A!="string"?null:h[A]||c[A]?A:(r("{w}: \xAB{v}\xBB is neither a texture nor a palette colour","{w}: \xAB{v}\xBB: \u043D\u0438 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430, \u043D\u0438 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{w:k,v:A}),null),b=(A,k,x=dt)=>{if(A===void 0)return;if(!J(A)){r("{w}: faces is not an object","{w}: faces: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:k});return}let f={};for(let[S,T]of Object.entries(A)){if(!dt.includes(S)){r("{w}: unknown face \xAB{f}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:k,f:S});continue}if(!x.includes(S)){r("{w}: the {slot} slot may not paint the \xAB{f}\xBB face","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:k,slot:s,f:S});continue}let C=d(T,k);C&&(f[S]=C);}return Object.keys(f).length?f:void 0},u=[];o.paint!==void 0&&!Array.isArray(o.paint)&&r("paint is not a list","paint: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");for(let[A,k]of (Array.isArray(o.paint)?o.paint:[]).entries()){let x=`paint[${A}]`;if(!J(k)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:x});continue}let f=typeof k.region=="string"?k.region:"",S=fa[f]??(ua.includes(f)?[f]:[]);if(!S.length){r("{w}: unknown region \xAB{r}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0431\u043B\u0430\u0441\u0442\u044C \xAB{r}\xBB",{w:x,r:f});continue}let T=S.filter(O=>!l.paint.includes(O));if(T.length){r("{w}: the {slot} slot may not paint \xAB{r}\xBB","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \xAB{r}\xBB",{w:x,slot:s,r:T.join(", ")});continue}let C=typeof k.color=="string"&&c[k.color]?k.color:null;C||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:x});let z=b(k.faces,x,l.paintFaces);if(C)for(let O of S){let M={region:O,color:C};z&&(M.faces={...z}),u.push(M);}}let R=[];o.parts!==void 0&&!Array.isArray(o.parts)&&r("parts is not a list","parts: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");let w=Array.isArray(o.parts)?o.parts:[];w.length>l.parts&&r("the {slot} slot allows {n} boxes, the item has {m}","\u0441\u043B\u043E\u0442\u0443 {slot} \u043C\u043E\u0436\u043D\u043E {n} \u043A\u043E\u0440\u043E\u0431\u043E\u043A, \u0443 \u0432\u0435\u0449\u0438 {m}",{slot:s,n:l.parts,m:w.length});for(let[A,k]of w.entries()){let x=`parts[${A}]`;if(!J(k)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:x});continue}let f=typeof k.bone=="string"?k.bone:"";if(!l.bones.includes(f)){r("{w}: the {slot} slot puts boxes only on {b}","{w}: \u0441\u043B\u043E\u0442 {slot} \u0441\u0442\u0430\u0432\u0438\u0442 \u043A\u043E\u0440\u043E\u0431\u043A\u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 {b}",{w:x,slot:s,b:l.bones.join(", ")});continue}let S=ha(k.size),T=ha(k.pos);if(!S||!T||S.some(ie=>ie<=0)){r("{w}: size and pos must be [x, y, z]","{w}: size \u0438 pos: [x, y, z]",{w:x});continue}let C=k.rot===void 0?void 0:ha(k.rot);k.rot!==void 0&&!C&&r("{w}: rot must be [x, y, z]","{w}: rot: [x, y, z]",{w:x});let z=k.mirror===true,O=Al(S,C??void 0),V=(z?[T[0],-T[0]]:[T[0]]).some(ie=>ie-O[0]<l.box.min[0]-1e-6||ie+O[0]>l.box.max[0]+1e-6)||[1,2].some(ie=>T[ie]-O[ie]<l.box.min[ie]-1e-6||T[ie]+O[ie]>l.box.max[ie]+1e-6);V&&r("{w}: the box leaves the {slot} slot frame","{w}: \u043A\u043E\u0440\u043E\u0431\u043A\u0430 \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043C\u043A\u0443 \u0441\u043B\u043E\u0442\u0430 {slot}",{w:x,slot:s});let q=typeof k.color=="string"&&c[k.color]?k.color:null;q||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:x});let Y=b(k.faces,x),pe;if(k.mat!==void 0&&(typeof k.mat=="string"&&er.includes(k.mat)?pe=k.mat:r("{w}: material \xAB{m}\xBB is not {list}","{w}: \u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B \xAB{m}\xBB: \u043D\u0435 {list}",{w:x,m:String(k.mat),list:er.join(", ")})),!q||V)continue;let me={bone:f,size:[...S],pos:[...T],color:q};Y&&(me.faces=Y),C&&C.some(ie=>ie!==0)&&(me.rot=[...C]),z&&(me.mirror=true),typeof k.name=="string"&&k.name.trim()&&(me.name=k.name.trim().slice(0,24)),pe&&(me.mat=pe),R.push(me);}return !w.length&&!(Array.isArray(o.paint)&&o.paint.length)&&r("the item neither paints nor adds anything","\u0432\u0435\u0449\u044C \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0438 \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442"),t.length?{ok:false,errors:t}:{ok:true,item:{version:Ut,style:je,id:n,slot:s,name:i,palette:c,tint:p,textures:h,paint:u,parts:R}}}var _e="#2b2140",et="#7a2e2e",Wt="#e8707a",El={neutral:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:0,tear:false},happy:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false},sad:{eye:"open",iris:1,white:1,lidOuter:.38,lidInner:.12,browUp:0,browInner:.09,tear:true},angry:{eye:"open",iris:.9,white:.95,lidOuter:.1,lidInner:.42,browUp:-0.02,browInner:-0.1,tear:false},surprised:{eye:"open",iris:.55,white:1.15,lidOuter:0,lidInner:0,browUp:.1,browInner:0,tear:false},scared:{eye:"open",iris:.42,white:1.08,lidOuter:0,lidInner:0,browUp:.08,browInner:.07,tear:false},tired:{eye:"open",iris:1,white:1,lidOuter:.5,lidInner:.5,browUp:-0.02,browInner:-0.02,tear:false},hurt:{eye:"hurt",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:-0.07,tear:false},love:{eye:"heart",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.05,browInner:.03,tear:false,blush:.6},excited:{eye:"star",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.09,browInner:0,tear:false},smug:{eye:"open",iris:.95,white:1,lidOuter:.42,lidInner:.36,browUp:0,browInner:-0.03,tear:false,look:.25,browTilt:.06},confused:{eye:"open",iris:.8,white:1.05,lidOuter:0,lidInner:0,browUp:.03,browInner:.04,tear:false,browTilt:.1,sweat:true},embarrassed:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.02,browInner:.08,tear:false,blush:1,sweat:true},silly:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.06,browInner:0,tear:false,wink:true},cool:{eye:"open",iris:.9,white:1,lidOuter:.38,lidInner:.38,browUp:-0.01,browInner:-0.02,tear:false},disgusted:{eye:"open",iris:.85,white:.95,lidOuter:.3,lidInner:.45,browUp:-0.02,browInner:-0.08,tear:false,look:-0.3},determined:{eye:"open",iris:1,white:1,lidOuter:.15,lidInner:.34,browUp:-0.01,browInner:-0.12,tear:false},crying:{eye:"closed",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.02,browInner:.12,tear:false,stream:true},dizzy:{eye:"spiral",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:.05,tear:false},sleepy:{eye:"closed",iris:1,white:1,lidOuter:0,lidInner:0,browUp:-0.02,browInner:0,tear:false,zzz:true},wink:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false,wink:true}};function wa(e,t,r,o,a,n="neutral"){let s=a==="blink"||a==="talk"?n==="blink"||n==="talk"?"neutral":n:a,l=El[s];e.clearRect(0,0,t,r),e.lineCap="round",e.lineJoin="round";let i=r*.5,c=t*.105,p=r*.2,h=a==="blink"?"closed":l.eye;if(o.cheeks&&s!=="scared"&&(e.fillStyle=s==="happy"?"rgba(236,110,140,0.5)":"rgba(236,120,140,0.32)",j(e,t*.12,r*.8,t*.07,r*.075),e.fill(),j(e,t*.88,r*.8,t*.07,r*.075),e.fill()),l.blush){e.fillStyle=`rgba(236,90,120,${.35*l.blush})`,j(e,t*.13,r*.8,t*.085,r*.09),e.fill(),j(e,t*.87,r*.8,t*.085,r*.09),e.fill(),e.strokeStyle=`rgba(200,60,90,${.7*l.blush})`,e.lineWidth=t*.008;for(let m of [t*.13,t*.87])for(let d=-1;d<=1;d++)e.beginPath(),e.moveTo(m+d*t*.025-t*.01,r*.84),e.lineTo(m+d*t*.025+t*.01,r*.76),e.stroke();}Sl(e,t,r,o);for(let m of [-1,1]){let d=t*(.5+m*.22),b=l.wink&&m===1&&h!=="closed"?"happy":h;Ml(e,d,i,c,p,m,o,b,l);let u=(l.browTilt??0)*(m===1?1:-0.4);Ll(e,d,i-p-r*.07-r*u,t,r,m,o,l);}if(l.stream&&a!=="blink"){e.fillStyle="rgba(133,183,235,0.85)";for(let m of [-1,1]){let d=t*(.5+m*.22);e.beginPath(),e.moveTo(d-t*.03,i+p*.35),e.quadraticCurveTo(d-t*.045,r*.8,d-t*.025,r),e.lineTo(d+t*.025,r),e.quadraticCurveTo(d+t*.04,r*.8,d+t*.03,i+p*.35),e.closePath(),e.fill();}}if(l.sweat){e.fillStyle="#9fd3f5";let m=t*.95,d=r*.2;e.beginPath(),e.moveTo(m,d-r*.09),e.quadraticCurveTo(m+t*.035,d+r*.02,m,d+r*.05),e.quadraticCurveTo(m-t*.035,d+r*.02,m,d-r*.09),e.fill();}if(l.zzz){e.strokeStyle=_e,e.lineWidth=t*.012;let m=(d,b,u)=>{e.beginPath(),e.moveTo(d,b),e.lineTo(d+u,b),e.lineTo(d,b+u),e.lineTo(d+u,b+u),e.stroke();};m(t*.8,r*.12,t*.05),m(t*.88,r*.02,t*.035);}if(l.tear&&h==="open"){e.fillStyle="#85b7eb";let m=t*.5-t*.22-c*.6,d=i+p*1.05;e.beginPath(),e.moveTo(m,d-r*.07),e.quadraticCurveTo(m+t*.03,d,m,d+r*.04),e.quadraticCurveTo(m-t*.03,d,m,d-r*.07),e.fill();}Cl(e,t*.5,r*.86,t,r,o,a==="talk"?"talk":s);}function Sl(e,t,r,o){let a=o.marks;if(!(!a||a==="none"))switch(a){case "freckles":{e.fillStyle="rgba(150,90,50,0.55)";let n=[[.08,.7],[.13,.66],[.18,.71],[.11,.76],[.16,.78],[.92,.7],[.87,.66],[.82,.71],[.89,.76],[.84,.78]];for(let[s,l]of n)j(e,t*s,r*l,t*.009,t*.009),e.fill();return}case "mole":e.fillStyle="#4a2e22",j(e,t*.64,r*.82,t*.011,t*.011),e.fill();return;case "scar":{e.strokeStyle="rgba(150,60,60,0.75)",e.lineWidth=t*.012,e.beginPath(),e.moveTo(t*.2,r*.12),e.lineTo(t*.32,r*.78),e.stroke(),e.lineWidth=t*.007;for(let n=1;n<=4;n++){let s=n/5,l=t*(.2+.12*s),i=r*(.12+.66*s);e.beginPath(),e.moveTo(l-t*.025,i+r*.005),e.lineTo(l+t*.025,i-r*.005),e.stroke();}return}case "plaster":{e.save(),e.translate(t*.84,r*.74),e.rotate(-0.5),e.fillStyle="#f1d3a8",e.fillRect(-t*.07,-r*.04,t*.14,r*.08),e.fillStyle="#e3b98a",e.fillRect(-t*.025,-r*.04,t*.05,r*.08),e.restore();return}case "whiskers":{e.strokeStyle=_e,e.lineWidth=t*.008;for(let n of [-1,1])for(let s of [-0.04,0,.04])e.beginPath(),e.moveTo(t*(.5+n*.24),r*(.78+s)),e.lineTo(t*(.5+n*.42),r*(.75+s*1.8)),e.stroke();return}case "star":ko(e,t*.84,r*.74,t*.045),e.fillStyle="#f2c14e",e.fill();return}}function Tl(e,t,r,o){e.beginPath(),e.moveTo(t,r+o*.9),e.bezierCurveTo(t-o*1.4,r-o*.1,t-o*.7,r-o*1.1,t,r-o*.4),e.bezierCurveTo(t+o*.7,r-o*1.1,t+o*1.4,r-o*.1,t,r+o*.9),e.closePath();}function j(e,t,r,o,a){e.beginPath(),e.ellipse(t,r,Math.max(.1,o),Math.max(.1,a),0,0,Math.PI*2);}function Ml(e,t,r,o,a,n,s,l,i){let c=o*.26;if(e.strokeStyle=_e,e.lineWidth=c,l==="closed"){e.beginPath(),e.moveTo(t-o,r+a*.1),e.quadraticCurveTo(t,r+a*.55,t+o,r+a*.1),e.stroke(),s.eyes==="wide"&&ts(e,t,r+a*.15,o,a*.3,n,c);return}if(l==="happy"){e.lineWidth=c*1.2,e.beginPath(),e.moveTo(t-o,r+a*.35),e.quadraticCurveTo(t,r-a*.75,t+o,r+a*.35),e.stroke();return}if(l==="heart"){Tl(e,t,r,o*1.05),e.fillStyle="#e8436b",e.fill(),e.fillStyle="rgba(255,255,255,0.8)",j(e,t-o*.38,r-a*.25,o*.2,o*.16),e.fill();return}if(l==="star"){ko(e,t,r,Math.min(o,a)*1.15),e.fillStyle="#f2c14e",e.fill(),e.lineWidth=c*.6,e.stroke();return}if(l==="spiral"){e.lineWidth=c*.9,e.beginPath();for(let O=0;O<=36;O++){let M=O/36*Math.PI*4*n,V=O/36*Math.min(o,a)*.95,q=t+Math.cos(M)*V,Y=r+Math.sin(M)*V;O?e.lineTo(q,Y):e.moveTo(q,Y);}e.stroke();return}if(l==="hurt"){let O=t-n*o*.6,M=t+n*o*.8;e.lineWidth=c*1.2,e.beginPath(),e.moveTo(M,r-a*.55),e.lineTo(O,r),e.lineTo(M,r+a*.55),e.stroke();return}let p=s.eyes==="anime"?1.12:s.eyes==="narrow"?1.15:1,h=s.eyes==="anime"?1.25:s.eyes==="narrow"?.55:1,m=o*i.white*p,d=a*i.white*h,b=s.eyes==="sleepy"?.32:0,u=Math.max(i.lidOuter,b),R=Math.max(i.lidInner,b),w=r-d,A=t+n*(m+c),k=t-n*(m+c),x=w+2*d*u,f=w+2*d*R,S=u>0||R>0;e.save(),S&&(e.beginPath(),e.moveTo(A,x),e.lineTo(k,f),e.lineTo(k,r+d*2),e.lineTo(A,r+d*2),e.closePath(),e.clip());let T=Math.min(m,d)*.8*i.iris*(s.eyes==="narrow"?1.5:1),C=r+d*.12,z=(i.look??0)*m*.45;switch(s.eyes){case "button":{e.fillStyle=_e,j(e,t+z,r+d*.05,m*.72,d*.8),e.fill(),e.fillStyle="#ffffff",j(e,t+z-m*.28,r-d*.25,m*.2,m*.2),e.fill(),j(e,t+z+m*.25,r+d*.3,m*.09,m*.09),e.fill();break}case "almond":{e.fillStyle="#ffffff",mr(e,t,r,m*1.05,d*.8,n),e.fill(),e.save(),mr(e,t,r,m*1.05,d*.8,n),e.clip(),e.fillStyle=s.eyeColor,j(e,t+z,C,T*1.05,T*1.05),e.fill(),e.fillStyle=_e,j(e,t+z,C,T*.5,T*.5),e.fill(),e.fillStyle="#ffffff",j(e,t+z-T*.38,C-T*.4,T*.28,T*.28),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=c*1.1,mr(e,t,r,m*1.05,d*.8,n),e.stroke();break}case "anime":case "starry":case "glam":case "narrow":{e.fillStyle="#ffffff",j(e,t,r,m,d),e.fill(),e.save(),j(e,t,r,m,d),e.clip();let O=s.eyes==="anime"?1.3:s.eyes==="narrow"?1:1.12,M=T*O,V=t+z;e.fillStyle=s.eyeColor,j(e,V,C,M*.95,M*(s.eyes==="anime"?1.25:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.22)",j(e,V,C+M*.5,M*.7,M*.45),e.fill(),s.eyes==="starry"?(ko(e,V,C,M*.62),e.fillStyle="#fff3b0",e.fill()):(e.fillStyle=_e,j(e,V,C,M*.46,M*(s.eyes==="anime"?.62:.5)),e.fill()),e.fillStyle="#ffffff",j(e,V-M*.38,C-M*.45,M*(s.eyes==="anime"?.38:.3),M*.3),e.fill(),j(e,V+M*.4,C+M*.4,M*.16,M*.16),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=s.eyes==="anime"||s.eyes==="glam"?c*1.6:c,e.beginPath(),e.ellipse(t,r,m,d,0,Math.PI*1.05,Math.PI*1.95),e.stroke(),s.eyes==="glam"&&(e.beginPath(),e.moveTo(t+n*m*.85,r-d*.45),e.lineTo(t+n*m*1.45,r-d*.95),e.stroke());break}case "dot":{e.fillStyle=_e,j(e,t+z,r+d*.1,m*.55,d*.72),e.fill(),e.fillStyle="#ffffff",j(e,t+z-m*.18,r-d*.18,m*.17,m*.17),e.fill();break}case "cat":{e.fillStyle="#ffffff",mr(e,t,r,m*1.08,d*.85,n),e.fill(),e.save(),mr(e,t,r,m*1.08,d*.85,n),e.clip(),e.fillStyle=s.eyeColor,j(e,t,C,T*1.05,T*1.2),e.fill(),e.fillStyle=_e,j(e,t,C,T*.22*(i.iris<1?1.5:1),T*.95),e.fill(),e.fillStyle="#ffffff",j(e,t-T*.4,C-T*.45,T*.25,T*.25),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=c,mr(e,t,r,m*1.08,d*.85,n),e.stroke();break}default:{let O=s.eyes==="sparkle"||s.eyes==="wide";e.fillStyle="#ffffff",j(e,t,r,m,d),e.fill(),e.save(),j(e,t,r,m,d),e.clip();let M=O?T*1.18:T;e.fillStyle=s.eyeColor,j(e,t+z,C,M*.95,M*(s.eyes==="sparkle"?1.15:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.18)",j(e,t+z,C+M*.45,M*.7,M*.45),e.fill(),e.fillStyle=_e,j(e,t+z,C,M*.48,M*.52),e.fill(),e.fillStyle="#ffffff",j(e,t+z-M*.38,C-M*.42,M*.32,M*.32),e.fill(),j(e,t+z+M*.38,C+M*.38,M*.14,M*.14),e.fill(),s.eyes==="sparkle"&&(ko(e,t+z+M*.3,C-M*.55,M*.22),e.fill()),e.restore(),e.strokeStyle=_e,e.lineWidth=c,e.beginPath(),e.ellipse(t,r,m,d,0,Math.PI*1.08,Math.PI*1.92),e.stroke();break}}if(e.restore(),S){e.strokeStyle=_e,e.lineWidth=c;let O=Y=>(Y-A)/(k-A),M=Y=>x+(f-x)*O(Y),V=t-m*.95,q=t+m*.95;e.beginPath(),e.moveTo(V,M(V)),e.lineTo(q,M(q)),e.stroke();}(s.eyes==="wide"||s.eyes==="glam")&&ts(e,t,r-d*.55,m,d*.45,n,c);}function mr(e,t,r,o,a,n){let s=t+n*o,l=t-n*o;e.beginPath(),e.moveTo(l,r+a*.15),e.quadraticCurveTo(t,r-a*1.5,s,r-a*.35),e.quadraticCurveTo(t,r+a*1.4,l,r+a*.15),e.closePath();}function ts(e,t,r,o,a,n,s){e.lineWidth=s*.8;let l=t+n*o;for(let i=0;i<2;i++){let c=r+i*a*.6;e.beginPath(),e.moveTo(l-n*o*.1,c),e.lineTo(l+n*o*.35,c-a*(.7-i*.2)),e.stroke();}}function ko(e,t,r,o){e.beginPath();for(let a=0;a<8;a++){let n=a%2?o*.35:o,s=a*Math.PI/4-Math.PI/2,l=t+Math.cos(s)*n,i=r+Math.sin(s)*n;a?e.lineTo(l,i):e.moveTo(l,i);}e.closePath(),e.fillStyle="#ffffff";}function Ll(e,t,r,o,a,n,s,l){if(s.brows==="none")return;let i=o*.095,c=r-a*l.browUp,p=t-n*i,h=t+n*i,m=c-a*l.browInner,d=c+a*l.browInner*.3;if(e.strokeStyle=s.browColor,e.fillStyle=s.browColor,s.brows==="bushy"){let u=a*.085;e.beginPath(),e.moveTo(h+n*o*.01,d+u*.2),e.quadraticCurveTo(t,Math.min(d,m)-u*.9,p,m-u*.1),e.lineTo(p,m+u*.8);for(let R=1;R<=4;R++){let w=p+(h-p)*R/4;e.lineTo(w-n*o*.01,m+(d-m)*(R/4)+u*(R%2?.5:.85));}e.closePath(),e.fill();return}if(s.brows==="straight"||s.brows==="thin"){e.lineWidth=o*(s.brows==="thin"?.014:.03),e.beginPath(),e.moveTo(h,d),e.lineTo(p,m),e.stroke();return}if(s.brows==="angled"){e.lineWidth=o*.028;let u=t+n*i*.3;e.beginPath(),e.moveTo(p,m),e.lineTo(u,Math.min(d,m)-a*.06),e.lineTo(h,d+a*.02),e.stroke();return}if(s.brows==="thick"){let u=a*.06;e.beginPath(),e.moveTo(h,d),e.quadraticCurveTo(t,Math.min(d,m)-u*.6,p,m),e.lineTo(p,m+u),e.quadraticCurveTo(t,Math.min(d,m)+u*.5,h,d+u*.6),e.closePath(),e.fill();return}e.lineWidth=o*(s.brows==="arched"?.026:.032),e.beginPath(),e.moveTo(h,d);let b=s.brows==="arched"?a*.09:a*.035;e.quadraticCurveTo(t+n*i*.2,Math.min(d,m)-b,p,m),e.stroke();}function Cl(e,t,r,o,a,n,s){let l=o*.026;e.strokeStyle=et,e.lineWidth=l;let i=o*(n.mouth==="small"||n.mouth==="pout"?.06:n.mouth==="grin"?.12:.09),c=(p,h=4)=>{e.beginPath();for(let m=0;m<=h;m++){let d=t-i+2*i*m/h,b=r+(m%2?-1:1)*a*p;m?e.lineTo(d,b):e.moveTo(d,b);}e.stroke();};switch(s){case "love":case "wink":case "embarrassed":if(s==="embarrassed"){c(.025,4);return}e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r+a*.09,t+i,r-a*.04),e.stroke();return;case "excited":case "silly":{let p=Math.max(i,o*.11);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r-a*.07),e.quadraticCurveTo(t,r-a*.03,t+p,r-a*.07),e.quadraticCurveTo(t,r+a*.22,t-p,r-a*.07),e.closePath(),e.fill(),s==="silly"?(e.fillStyle=Wt,j(e,t+p*.25,r+a*.11,p*.4,a*.08),e.fill(),e.strokeStyle="#c4505c",e.lineWidth=l*.5,e.beginPath(),e.moveTo(t+p*.25,r+a*.06),e.lineTo(t+p*.25,r+a*.14),e.stroke()):(e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.12,p*.55,a*.06),e.fill(),e.restore());return}case "smug":case "cool":e.beginPath(),e.moveTo(t-i,r+a*.01),e.quadraticCurveTo(t+i*.3,r+a*.03,t+i*1.05,r-a*.06),e.stroke();return;case "confused":case "dizzy":c(s==="dizzy"?.035:.02,s==="dizzy"?6:4);return;case "disgusted":{e.beginPath(),e.moveTo(t-i,r+a*.05),e.lineTo(t-i*.3,r-a*.02),e.lineTo(t+i*.4,r+a*.03),e.lineTo(t+i,r-a*.01),e.stroke(),e.fillStyle=Wt,j(e,t-i*.1,r+a*.045,i*.3,a*.03),e.fill();return}case "determined":{e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.035,i*2,a*.07),e.strokeStyle=et,e.lineWidth=l*.7,e.strokeRect(t-i,r-a*.035,i*2,a*.07),e.beginPath(),e.moveTo(t-i,r),e.lineTo(t+i,r),e.stroke();return}case "crying":{let p=Math.max(i,o*.1);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r+a*.09),e.quadraticCurveTo(t,r-a*.14,t+p,r+a*.09),e.closePath(),e.fill();return}case "sleepy":e.fillStyle=et,j(e,t,r+a*.01,o*.025,a*.035),e.fill();return;case "happy":{let p=Math.max(i,o*.1);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r-a*.06),e.quadraticCurveTo(t,r-a*.02,t+p,r-a*.06),e.quadraticCurveTo(t,r+a*.2,t-p,r-a*.06),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.1,p*.55,a*.06),e.fill(),n.mouth==="grin"&&(e.fillStyle="#ffffff",e.fillRect(t-p,r-a*.08,p*2,a*.045)),e.restore();return}case "surprised":e.fillStyle=et,j(e,t,r,o*.045,a*.085),e.fill();return;case "talk":e.fillStyle=et,j(e,t,r,Math.max(i*.7,o*.06),a*.07),e.fill(),e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.06,o*.045,a*.035),e.fill(),e.restore();return;case "sad":e.beginPath(),e.moveTo(t-i,r+a*.04),e.quadraticCurveTo(t,r-a*.07,t+i,r+a*.04),e.stroke();return;case "angry":e.beginPath(),e.moveTo(t-i,r+a*.01),e.quadraticCurveTo(t,r-a*.03,t+i,r+a*.01),e.stroke();return;case "scared":{e.beginPath();let p=4;for(let h=0;h<=p;h++){let m=t-i+2*i*h/p,d=r+(h%2?-1:1)*a*.022;h?e.lineTo(m,d):e.moveTo(m,d);}e.stroke();return}case "tired":e.beginPath(),e.moveTo(t-i*.6,r),e.lineTo(t+i*.6,r),e.stroke();return;case "hurt":{e.beginPath();let p=4;for(let h=0;h<=p;h++){let m=t-i+2*i*h/p,d=r+(h%2?-1:1)*a*.04;h?e.lineTo(m,d):e.moveTo(m,d);}e.stroke();return}}if(n.mouth==="smirk"){e.beginPath(),e.moveTo(t-i,r),e.quadraticCurveTo(t+i*.3,r+a*.03,t+i,r-a*.06),e.stroke();return}if(n.mouth==="pout"){e.lineWidth=l*.9,e.beginPath(),e.moveTo(t-i*.15,r-a*.05),e.quadraticCurveTo(t+i*.9,r-a*.03,t-i*.05,r),e.quadraticCurveTo(t+i*.9,r+a*.03,t-i*.15,r+a*.05),e.stroke();return}if(n.mouth==="open"||n.mouth==="teeth"||n.mouth==="fang"||n.mouth==="tongue"){e.fillStyle=et,e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r-a*.02,t+i,r-a*.04),e.quadraticCurveTo(t,r+a*.13,t-i,r-a*.04),e.closePath(),e.fill(),e.save(),e.clip(),n.mouth==="teeth"?(e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.06,i*2,a*.045)):n.mouth!=="fang"&&(e.fillStyle=Wt,j(e,t,r+a*.07,i*.55,a*.05),e.fill()),e.restore(),n.mouth==="fang"&&(e.fillStyle="#ffffff",e.beginPath(),e.moveTo(t+i*.35,r-a*.035),e.lineTo(t+i*.6,r-a*.035),e.lineTo(t+i*.47,r+a*.03),e.closePath(),e.fill()),n.mouth==="tongue"&&(e.fillStyle=Wt,j(e,t+i*.3,r+a*.07,i*.32,a*.05),e.fill());return}if(n.mouth==="cat"){e.beginPath(),e.moveTo(t-i,r-a*.03),e.quadraticCurveTo(t-i*.5,r+a*.06,t,r-a*.01),e.quadraticCurveTo(t+i*.5,r+a*.06,t+i,r-a*.03),e.stroke();return}if(n.mouth==="grin"){e.fillStyle=et,e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r-a*.01,t+i,r-a*.04),e.quadraticCurveTo(t,r+a*.12,t-i,r-a*.04),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.06,i*2,a*.04),e.restore();return}e.beginPath(),e.moveTo(t-i,r-a*.03),e.quadraticCurveTo(t,r+a*.06,t+i,r-a*.03),e.stroke();}var rs=16;function Pl(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}var hr=class{texture;g;w;h;face;current="neutral";base="neutral";constructor(t,r=St){this.face=t,this.w=Math.round(r[2]*rs),this.h=Math.round(r[3]*rs);let o=Pl(this.w,this.h),a=o.getContext("2d");if(!a)throw new Error("DrawnFace: no 2D canvas");this.g=a,this.texture=new D__namespace.CanvasTexture(o),this.texture.colorSpace=D__namespace.SRGBColorSpace,this.texture.anisotropy=4,this.paint("neutral");}paint(t,r){let o=r&&t!=="blink"&&t!=="talk"&&lr[r].includes(t)?r:t;o!=="blink"&&o!=="talk"?this.base=o:r&&(this.base=r),this.current=o,wa(this.g,this.w,this.h,this.face,o,this.base),this.texture.needsUpdate=true;}setFace(t){this.face=t,wa(this.g,this.w,this.h,this.face,this.current,this.base),this.texture.needsUpdate=true;}dispose(){this.texture.dispose();}};var zl={idle:{},talk:{},walk:{speed:1.6},run:{speed:5.2},surprised:{emote:"shrug"},point:{emote:"point"},sit:{sitting:true},wave:{emote:"wave"},jump:{air:true},fall:{emote:"facepalm"},dance:{emote:"dance"},carry:{speed:1.4,emote:"carry"},jog:{speed:3.4}},Il=Object.fromEntries(Zn.map(e=>[e,zl[e]??(pa(e)?{emote:e}:{})])),Ol={handR:"handR",handL:"handL",head:"headTop"},Ao=class{view;animator;input=so();seed;ownFace;drawn=null;pose="idle";jumpT=-1;constructor(t,r={}){this.ownFace=!r.facePainter,this.ownFace&&(this.drawn=os(t)),this.view=new bo(t,{shadows:false,gloss:!!t?.face?.drawn,...r,facePainter:r.facePainter??this.drawn}),this.seed=r.seed??1,this.animator=this.newAnimator();}get group(){return this.view.group}get height(){return this.view.height}setSpec(t){let r=this.view.hash;if(this.view.setSpec(t),this.view.hash!==r&&(this.animator=this.newAnimator(),this.ownFace)){let o=this.drawn;this.drawn=os(t),this.view.setFacePainter(this.drawn),o?.dispose();}}setEmotion(t){this.animator.setEmotion(t);}setViseme(t){this.input.viseme=t;}setPose(t){if(t===this.pose)return;this.pose=t;let r=Il[t];if(this.input.speed=r.speed??0,this.input.sitting=!!r.sitting,r.emote)this.animator.playEmote(r.emote);else {let o=this.animator.emoting;o&&"loop"in $e[o]&&$e[o].loop&&this.animator.stopEmote();}r.air&&(this.jumpT=0,this.animator.trigger("jump"));}playEmote(t){this.animator.playEmote(t);}stopEmote(){this.animator.stopEmote();}trigger(t){if(t==="jump"){this.jumpT=0,this.animator.trigger("jump");return}this.animator.trigger(t);}setGround(t){this.view.setGround(t);}lookAt(t){this.view.lookAt(t);}reach(t,r){this.view.reach(t,r);}seat(t){this.view.seat(t);}fall(t){return this.view.fall(t)}hit(t,r){return this.view.hit(t,r??null)}getUp(){this.view.getUp();}stopRagdoll(){this.view.stopRagdoll();}takeRagdollDrift(){return this.view.takeRagdollDrift()}get ragdollDrift(){return this.view.ragdollDrift}get ragdoll(){return this.view.ragdollState}setColliders(t){this.view.setColliders(t);}attach(t,r){this.view.attach(Ol[t],r);}update(t){let r=this.input;this.jumpT>=0&&(this.jumpT+=t,r.onGround=this.jumpT>.6,r.vy=this.jumpT<.3?4:-4,r.onGround&&(this.jumpT=-1,r.vy=0,this.animator.trigger("land")));let o=this.animator.update(t,r);this.view.applyPose(o,{dt:t,plant:this.animator.plant,standing:this.animator.standing}),this.view.setExpression(this.animator.expression,this.animator.emotion);}dispose(){this.view.dispose(),this.drawn?.dispose();}newAnimator(){let t=this.view.spec,r=new Ro(t.rig,t.style,this.view.expressions);return r.setRandom(Zr(this.seed)),r}};function os(e){let t=e?.face?.drawn;if(!t)return null;try{let{face:r}=cr({face:{...t,brows:t.brows,browColor:"#2a1c14"}});return new hr({...r,emotion:"neutral"},e.face.rect)}catch{return null}}var _l=gr.map(e=>{let t=Ae[e],r=t.bones.map(a=>`${a.name}@[${a.pivot.join(",")}]`).join(" "),o=t.defaultParts.map(a=>`${a.bone} ${a.size.join("x")} at [${a.pos.join(",")}]`).join("; ");return `- "${e}" \u2014 ${t.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
25
- `),gm=`You design blocky voxel characters for a Minecraft-like game. Reply with ONE JSON object \u2014 a CharacterSpec \u2014 and nothing else: no markdown, no comments, no explanations.
24
+ #endif`);}function aa(e,t,r){if(!e)return new D__namespace.MeshLambertMaterial(r);let o=new D__namespace.MeshStandardMaterial({...r,roughness:t,metalness:0});return o.onBeforeCompile=yo,o}function E0(e,t){if(e==="glass"){if(!t)return new D__namespace.MeshLambertMaterial({transparent:true,opacity:.5,depthWrite:false});let o=new D__namespace.MeshStandardMaterial({transparent:true,opacity:.42,depthWrite:false,roughness:.08,metalness:.2});return o.onBeforeCompile=yo,o}if(e==="glow"){let o={emissive:16777215,emissiveIntensity:.85};return t?new D__namespace.MeshStandardMaterial({...o,roughness:.6}):new D__namespace.MeshLambertMaterial(o)}if(!t)return new D__namespace.MeshLambertMaterial({alphaTest:.5});let r=new D__namespace.MeshStandardMaterial({alphaTest:.5,roughness:.28,metalness:.85});return r.onBeforeCompile=yo,r}var Gn=5921370;function qn(e){let t=(r,o)=>r.replace(`#include <${o}>`,D__namespace.ShaderChunk[o].replace("varying vec2 vMapUv","centroid varying vec2 vMapUv"));e.vertexShader=t(e.vertexShader,"uv_pars_vertex"),e.fragmentShader=t(e.fragmentShader,"uv_pars_fragment");}function S0(e){qn(e),yo(e);}var go=class{group=new D__namespace.Group;root=new D__namespace.Group;asset;spec;bones=new Map;byRole=new Map;meshes=[];material;decalMat;gloss;decal=null;expression=null;sockets=new Map;attached=new Map;label=null;shadows;layer;brightness=1;painter;prints=[];printMeshes=[];printMats=new Map;partMats=new Map;emotion;ik=null;ikGoals={ground:null,look:null,handR:null,handL:null,seat:null};toWorldM=new D__namespace.Matrix4;toModelM=new D__namespace.Matrix4;tmpV=new D__namespace.Vector3;ragdoll=null;ragWorld=null;ragPush=null;ragHit=null;ragRise=false;ragOn=false;drifted=new Map;snaps=[null,null];snapDt=0;constructor(t=_t(),r={}){this.spec=t,this.shadows=r.shadows??true,this.layer=r.layer??0,this.painter=r.facePainter??null,this.gloss=r.gloss??false,this.material=aa(this.gloss,g0,{alphaTest:.5}),this.material.onBeforeCompile=this.gloss?S0:qn,this.decalMat=aa(this.gloss,jn,{alphaTest:.5,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.group.add(this.root),this.asset=Ho(t),this.build(),r.name&&this.setName(r.name);}get height(){let t=this.asset.layout;return t.height*t.scale*Ht}get eye(){let t=this.asset.layout;return t.eye*t.scale*Ht}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(t){let r=Ho(t);if(r===this.asset){so(r);return}this.clear(),so(this.asset),this.asset=r,this.spec=t,this.build();}build(){let{layout:t,skinned:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.useFaceMap(),this.root.scale.setScalar(t.scale*Ht);let a=new Map(t.bones.map(p=>[p.name,p.pivot])),n=[],s=[];for(let p of t.bones){let h=new D__namespace.Bone;n.push(h),s.push(new D__namespace.Matrix4().makeTranslation(-p.pivot[0],-p.pivot[1],-p.pivot[2]));let m=p.parent?a.get(p.parent)??[0,0,0]:[0,0,0],d=[p.pivot[0]-m[0],p.pivot[1]-m[1],p.pivot[2]-m[2]];h.position.set(...d);let b={name:p.name,role:p.role,group:h,rest:d};this.bones.set(p.name,b);let u=this.byRole.get(p.role)??[];u.push(b),this.byRole.set(p.role,u);}for(let p of t.bones){let h=this.bones.get(p.name);((p.parent?this.bones.get(p.parent):void 0)?.group??this.root).add(h.group);}let l=new D__namespace.Skeleton(n,s),i=(p,h,m)=>{let d=new D__namespace.SkinnedMesh(p,h);d.bind(l,new D__namespace.Matrix4);let b=(r??p).boundingSphere;b&&(d.boundingSphere=new D__namespace.Sphere(b.center.clone(),b.radius*1.6)),d.castShadow=m&&this.shadows,d.receiveShadow=this.shadows,d.layers.set(this.layer),this.meshes.push(d),this.root.add(d);};r&&i(r,this.material,true);for(let[p,h]of this.asset.skinnedMats){let m=this.partMats.get(p);m||this.partMats.set(p,m=E0(p,this.gloss)),m.map=this.asset.texture,p==="glow"&&(m.emissiveMap=this.asset.texture),m.needsUpdate=true,i(h,m,p!=="glass");}let c=t.face;if(c){let p=new D__namespace.BufferGeometry,h=c.grid;if(h){p.setAttribute("position",new D__namespace.BufferAttribute(h.positions,3)),p.setAttribute("normal",new D__namespace.BufferAttribute(h.normals,3)),p.setAttribute("uv",new D__namespace.BufferAttribute(new Float32Array(h.t.length),2));let m=[],d=h.cols+1;for(let b=0;b<h.rows;b++)for(let u=0;u<h.cols;u++){let R=b*d+u;m.push(R,R+d+1,R+1,R,R+d,R+d+1);}p.setIndex(m);}else {p.setAttribute("position",new D__namespace.BufferAttribute(c.corners,3));let m=new Float32Array(12);for(let d=0;d<4;d++)m[d*3+2]=-1;p.setAttribute("normal",new D__namespace.BufferAttribute(m,3)),p.setAttribute("uv",new D__namespace.BufferAttribute(new Float32Array(8),2)),p.setIndex([0,2,1,0,3,2]);}this.decal=new D__namespace.Mesh(p,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(c.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let p of t.sockets){let h=new D__namespace.Object3D;h.position.set(...p.at),h.scale.setScalar(1/(t.scale*Ht)),this.bones.get(p.bone)?.group.add(h),this.sockets.set(p.name,h);let m=this.attached.get(p.name);m&&h.add(m);}this.buildPrints(),this.placeLabel(),this.ik=new Cr(t),this.ragdoll=new Ir(t),this.ragWorld&&this.ragdoll.setWorld(this.ragWorld),this.ragOn=false,this.snaps=[null,null],this.setBrightness(this.brightness);}setPrints(t){this.prints=t??[],this.buildPrints(),this.setBrightness(this.brightness);}buildPrints(){for(let o of this.printMeshes)o.removeFromParent(),o.geometry.dispose();this.printMeshes=[];let t=new Set,r=new Map;for(let o of this.prints){let a=this.bones.get(o.bone),n=this.asset.layout.bones.find(p=>p.name===o.bone);if(!a||!n)continue;let s=this.printMats.get(o.texture);s||(s=aa(this.gloss,jn,{map:o.texture,emissiveMap:o.texture,emissive:Gn,transparent:true,alphaTest:.02,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.printMats.set(o.texture,s)),t.add(o.texture);let l=new D__namespace.PlaneGeometry(o.w,o.h);o.facing==="front"&&l.rotateY(Math.PI),l.translate(o.center[0]-n.pivot[0],o.center[1]-n.pivot[1],o.center[2]-n.pivot[2]);let i=`${o.bone}|${o.texture.uuid}`,c=r.get(i)??{node:a,mat:s,geos:[]};c.geos.push(l),r.set(i,c);}for(let{node:o,mat:a,geos:n}of r.values()){let s=n.length===1?n[0]:BufferGeometryUtils_js.mergeGeometries(n)??n[0];if(s!==n[0])for(let i of n)i.dispose();let l=new D__namespace.Mesh(s,a);l.layers.set(this.layer),o.group.add(l),this.printMeshes.push(l);}for(let[o,a]of this.printMats)t.has(o)||(a.dispose(),this.printMats.delete(o));}clear(){for(let t of this.sockets.values())for(let r of [...t.children])t.remove(r);this.root.clear();for(let t of this.printMeshes)t.geometry.dispose();this.printMeshes=[],this.decal?.geometry.dispose(),this.decal=null;for(let t of this.meshes)t instanceof D__namespace.SkinnedMesh&&t.skeleton.dispose();this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(t,r){let o=this.ragdoll?.drift;if(o){Be(this.drifted,t);let i=ae(this.drifted,"root");for(let c=0;c<3;c++)i[I.px+c]=i[I.px+c]+o[c];t=this.drifted;}let a=this.ragdoll?.supported?this.ragdoll:null,n=false;a&&(this.ragHit||a.state==="flinch")&&r&&this.ik&&(t=this.solveIK(t,r),n=true);let s=a?this.driveRagdoll(t,r?.dt??0):null;s?t=s:(!n&&r&&this.ik&&(t=this.solveIK(t,r)),this.remember(t,r?.dt??0));let l=t.get("root");if(l){this.root.rotation.set(l[I.rx],l[I.ry],l[I.rz]);let i=this.asset.layout.scale*Ht;this.root.position.set(l[I.px]*i,l[I.py]*i,l[I.pz]*i);}else this.root.rotation.set(0,0,0),this.root.position.set(0,0,0);for(let[i,c]of this.byRole){let p=t.get(i);for(let h of c){let m=h.group;if(!p){m.rotation.set(0,0,0),m.position.set(...h.rest),m.scale.set(1,1,1);continue}m.rotation.set(p[I.rx],p[I.ry],p[I.rz]),m.position.set(h.rest[0]+p[I.px],h.rest[1]+p[I.py],h.rest[2]+p[I.pz]),m.scale.set(p[I.sx],p[I.sy],p[I.sz]);}}}fall(t=[0,0,0]){if(!this.ragdoll?.supported)return false;let r=Array.isArray(t)?[t[0],t[1],t[2]]:[t.x,t.y,t.z];return this.ragdoll.state==="fall"?this.ragdoll.push(r):this.ragPush=r,this.ragRise=false,true}hit(t,r=null){if(!this.ragdoll?.supported)return false;let o=Array.isArray(t)?[t[0],t[1],t[2]]:[t.x,t.y,t.z],a=r===null||typeof r=="string"?r:Array.isArray(r)?[r[0],r[1],r[2]]:[r.x,r.y,r.z];return this.ragdoll.state==="fall"||this.ragPush?this.fall(o):(this.ragHit={push:o,at:a},true)}getUp(){(this.ragdoll?.state==="fall"||this.ragPush)&&(this.ragRise=true);}stopRagdoll(){this.ragdoll?.stop(),this.ragPush=null,this.ragHit=null,this.ragRise=false;}takeRagdollDrift(){let t=this.ragdoll;if(!t||t.state!=="none")return null;let r=this.ragdollDrift;return r?(t.clearDrift(),this.ik?.reset(),this.snaps=[null,null],r):null}get ragdollDrift(){let t=this.ragdoll?.drift;if(!t)return null;let r=this.ragFrame();return ne(r.rot,[t[0]*r.scale,t[1]*r.scale,t[2]*r.scale])}get ragdollState(){return this.ragPush?"fall":this.ragHit?"flinch":this.ragdoll?.state??"none"}get ragdollResting(){return !!this.ragdoll?.resting}supportsRagdoll(){return !!this.ragdoll?.supported}setColliders(t){this.ragWorld=t,this.ragdoll&&this.ragdoll.setWorld(t??{floor:null});}ragFrame(){let t=this.asset.layout.scale*Ht;this.group.updateWorldMatrix(true,false);let r=new D__namespace.Vector3,o=new D__namespace.Quaternion,a=new D__namespace.Vector3;this.group.matrixWorld.decompose(r,o,a);let n=new D__namespace.Matrix4().makeRotationFromQuaternion(o).elements;return {rot:[n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]],scale:t*a.x,origin:[r.x,r.y,r.z]}}remember(t,r){if(!this.ragdoll?.supported)return;let a=this.snaps[0]??{pose:new Map,frame:this.ragFrame()};Be(a.pose,t),a.frame=this.ragFrame(),this.snaps=[this.snaps[1]??null,a],this.snapDt=r;}driveRagdoll(t,r){let o=this.ragdoll,a=this.ragFrame();if(this.ragPush){let l=this.snaps[1]??{pose:t,frame:a};o.start(this.snaps[1]?this.snaps[0]??null:null,l,this.snapDt,this.ragPush),this.ragPush=null;}this.ragHit&&(o.hit({pose:t,frame:a},this.ragHit.push,this.ragHit.at),this.ragHit=null),this.ragRise&&o.state==="fall"&&(o.getUp(a),this.ragRise=false);let n=o.state==="flinch",s=o.drive(t,r,a);return n||(s?this.ragOn=true:this.ragOn&&(this.ragOn=false,this.ik?.reset(),this.snaps=[null,null])),s}setGround(t){this.ikGoals.ground=t;}lookAt(t){this.ikGoals.look=t;}reach(t,r){this.ikGoals[t]=r;}seat(t){this.ikGoals.seat=t;}supportsIK(t){return !!this.ik?.supports(t)}resetIK(){this.ik?.reset();}solveIK(t,r){let o=this.ikGoals,a=this.asset.layout.scale*Ht;this.group.updateWorldMatrix(true,false),this.toWorldM.copy(this.group.matrixWorld).scale(this.tmpV.set(a,a,a)),this.toModelM.copy(this.toWorldM).invert();let n=this.tmpV,s=h=>(n.set(h[0],h[1],h[2]).applyMatrix4(this.toWorldM),[n.x,n.y,n.z]),l=h=>(n.set(h[0],h[1],h[2]).applyMatrix4(this.toModelM),[n.x,n.y,n.z]),i=h=>{if(!h)return null;let m;return h instanceof D__namespace.Vector3?m=h:h instanceof D__namespace.Object3D?m=h.getWorldPosition(new D__namespace.Vector3):m=h(),m?l([m.x,m.y,m.z]):null},c=o.ground,p=c?(h,m,d)=>{let[b,u,R]=s([h,m,d]),w=c(b,R,u);return w===null?null:l([b,w,R])[1]}:null;return this.ik.solve(t,{dt:r.dt,plant:r.plant,standing:r.standing,ground:p,look:i(o.look),handR:i(o.handR),handL:i(o.handL),seat:i(o.seat),toWorld:s,toModel:l})}setFacePainter(t){if(t===this.painter)return;this.painter=t,this.useFaceMap();let r=this.expression??"neutral";this.expression=null,this.setExpression(r);}useFaceMap(){let t=this.painter;this.decalMat.map=t?t.texture:this.asset.texture,this.decalMat.transparent=!!t,this.decalMat.alphaTest=t?.02:.5,this.decalMat.needsUpdate=true;}setExpression(t,r){if(t===this.expression&&(!this.painter||r===this.emotion)||!this.decal)return;let o=this.asset.layout.face?.uv,a=this.painter?[0,1,1,0]:o?.[t]??o?.neutral;if(!a)return;this.expression=t,this.emotion=r,this.painter?.paint(t,r);let[n,s,l,i]=a,c=this.decal.geometry.getAttribute("uv"),p=this.asset.layout.face?.grid;if(p)for(let h=0;h<c.count;h++)c.setXY(h,n+(l-n)*p.t[h*2],s+(i-s)*p.t[h*2+1]);else c.setXY(0,n,s),c.setXY(1,l,s),c.setXY(2,l,i),c.setXY(3,n,i);c.needsUpdate=true;}materials(){return [this.material,this.decalMat,...this.partMats.values()]}setBrightness(t){this.brightness=t,this.material.color.setScalar(t),this.decalMat.color.setScalar(t);for(let r of this.printMats.values())r.color.setScalar(t);for(let r of this.partMats.values())r.color.setScalar(t);}setEmissive(t){if(this.material.emissive.getHex()!==t){this.material.emissive.setHex(t),this.decalMat.emissive.setHex(t);for(let r of this.printMats.values())r.emissive.setHex(t||Gn);for(let[r,o]of this.partMats)r!=="glow"&&o.emissive.setHex(t);}}setShadows(t){if(t!==this.shadows){this.shadows=t;for(let r of this.meshes)r.castShadow=t&&!r.material.transparent;}}attach(t,r){let o=this.attached.get(t);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(t);return}this.attached.set(t,r),this.sockets.get(t)?.add(r);}}attachedAt(t){return this.attached.get(t)??null}setName(t){this.label&&Ko(this.label),this.label=t?mn(t):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(t){this.label&&(this.label.visible=t);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(t){for(let r of this.meshes)t(r);this.decal&&t(this.decal);for(let r of this.printMeshes)t(r);}dispose(){this.group.removeFromParent();for(let t of this.attached.values())t.removeFromParent();this.attached.clear(),this.clear(),this.label&&Ko(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose();for(let t of this.printMats.values())t.dispose();this.printMats.clear();for(let t of this.partMats.values())t.dispose();this.partMats.clear(),so(this.asset);}};var xo=new Map,na=new Set;function pp(e){let t=rr(e);if(!xo.has(t)){xo.set(t,e);for(let r of na)r(t);}return t}function mp(e){return typeof e=="string"?xo.get(e):void 0}function hp(e){let t={};for(let r of e){let o=xo.get(r);o&&(t[r]=o);}return t}function dp(e){return na.add(e),()=>na.delete(e)}var T0=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],M0=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],L0=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],C0=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],P0=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],z0=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function gp(e,t="",r=""){let o=to(It("npc:"+e+"|"+t)),a=l=>l[Math.floor(o()*l.length)],n=qo({top:a(ln),bottom:a(cn),shoes:a(pn),hair:a(["short","short","long","curly"]),hat:o()<.2,colors:{skin:a(M0),hair:a(L0),shirt:a(C0),pants:a(P0),boots:a(T0),hat:a(z0)}});n.name=e.slice(0,40),n.description=[t,r].filter(Boolean).join(" \u2014 ").slice(0,300),n.style={walk:a(["normal","normal","bouncy","heavy","sneaky"]),idle:a(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},n.tags=["npc",...t?[t.slice(0,24)]:[]];let s=Ye(n);return s.ok?s.spec:_t()}var kt=([e,t,r])=>"#"+[e,t,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function I0(e){if(!e.length)return null;let t=r=>{let o=e.map(a=>a[r]).sort((a,n)=>a-n);return o[o.length>>1]};return [t(0),t(1),t(2)]}function O0(e,t){let{width:r,height:o,data:a}=e,n=(w,A)=>{let k=(A*r+w)*4;return [a[k],a[k+1],a[k+2]]},s=[n(0,0),n(r-1,0),n(0,o-1),n(r-1,o-1)],l=[0,1,2].map(w=>s.reduce((A,k)=>A+k[w],0)/4),i=w=>Math.abs(w[0]-l[0])+Math.abs(w[1]-l[1])+Math.abs(w[2]-l[2])>60,c=r,p=-1,h=o,m=-1;for(let w=0;w<o;w+=2)for(let A=0;A<r;A+=2)i(n(A,w))&&(c=Math.min(c,A),p=Math.max(p,A),h=Math.min(h,w),m=Math.max(m,w));p<0&&(c=0,p=r-1,h=0,m=o-1);let d=m-h+1,b=p-c+1,u=c+Math.floor(b*.3),R=c+Math.ceil(b*.7);return t.map(([w,A])=>{let k=[];for(let x=h+Math.floor(d*w);x<h+Math.ceil(d*A);x++)for(let f=u;f<R;f++){if(x<0||x>=o||f<0||f>=r)continue;let S=n(f,x);i(S)&&k.push(S);}return I0(k)})}var _0=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function vp(e,t="humanoid",r=ao()){let[o,a,n,s,l]=O0(e,_0);if(t==="humanoid"){let c=JSON.parse(JSON.stringify(Uo));c.palette=Go(c.palette,{...o?{hair:kt(o)}:{},...a?{skin:kt(a)}:{},...n?{shirt:kt(n)}:{},...s?{pants:kt(s)}:{},...l?{boots:kt(l)}:{}}),c.name=r,c.tags=[];let p=Ye(c);return p.ok?p.spec:_t()}let i=Ye({name:r,rig:t,palette:{s:kt(a??o??[198,156,124]),t:kt(n??[58,143,214]),p:kt(s??l??[44,62,107]),w:"#f4f4f4",b:"#1d1d21"},textures:{f_neutral:{w:4,h:2,rows:["wbbw","...."]},f_blink:{w:4,h:2,rows:["bbbb","...."]}},face:{rect:t==="blob"?[4,4,4,2]:t==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return i.ok?i.spec:_t()}var V0={normal:{},bouncy:{amp:.9,arm:.8,bob:1.6,tempo:1.1,sway:.04},heavy:{amp:.6,arm:.4,bob:.6,tempo:.8,sway:.12},sneaky:{amp:.5,arm:.3,tempo:1.2},robotic:{amp:.7,arm:.7,quant:true},swagger:{amp:.7,arm:.5,bob:.8,tempo:.85,sway:.1,swagger:.22},skip:{amp:.9,arm:.9,bob:1.2,tempo:1.05,skip:1},ninja:{amp:.6,arm:.2,tempo:1.25,crouch:2.2},zombie:{amp:.45,arm:.05,tempo:.6,sway:.14,reach:1.45},catwalk:{amp:.7,arm:.45,tempo:.95,sway:.08,cross:.12}},F0={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8},cool:{pose:"hips",chest:.04,breath:.8},shy:{pose:"shy",breath:1.1},ready:{pose:"ready",breath:1.4},bored:{pose:"bored",breath:.7,fidget:.4}};function sa(e){let t={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,reach:0,crouch:0,skip:0,cross:0,swagger:0,pose:"none",...V0[e.walk],...F0[e.idle]};return t.tempo*=.8+.4*e.energy,t.amp*=.85+.3*e.energy,t}function jt(e,t=0){let r=Math.sin(e.phase+t);return e.style.quant?Math.max(-1,Math.min(1,r*3)):r}function ia(e,t,r){let o=jt(t)*r;y(e,"legL","rx",o),y(e,"legR","rx",-o),y(e,"legFL","rx",o),y(e,"legBR","rx",o),y(e,"legFR","rx",-o),y(e,"legBL","rx",-o);}function la(e,t,r){let o=jt(t)*r;y(e,"armL","rx",-o),y(e,"armR","rx",o);}function ca(e,t,r,o){let a=jt(t),n=Math.max(0,Math.cos(t.phase))*Math.max(0,-a+.3),s=Math.max(0,-Math.cos(t.phase))*Math.max(0,a+.3);y(e,"shinL","rx",-r*(.15+n)),y(e,"shinR","rx",-r*(.15+s)),y(e,"foreArmL","rx",o*(.6+.4*Math.max(0,-a))),y(e,"foreArmR","rx",o*(.6+.4*Math.max(0,a)));}var B0=(e,t)=>{let r=Math.sin(t.clock*2)*t.style.breath;y(e,"armL","rz",-0.04-.03*r),y(e,"armR","rz",.04+.03*r),y(e,"foreArmL","rx",.12+.02*r),y(e,"foreArmR","rx",.12+.02*r),y(e,"head","rx",.03*Math.sin(t.clock*1.7)+t.style.chest),y(e,"body","rx",t.style.chest*-0.5),t.style.fidget&&(y(e,"head","ry",.35*Math.sin(t.clock*.7)*Math.sin(t.clock*.31)),y(e,"root","ry",.05*Math.sin(t.clock*.9))),y(e,"body","sy",1+.04*Math.sin(t.clock*3)),D0(e,t);};function D0(e,t){let r=Math.sin(t.clock*2);switch(t.style.pose){case "hips":y(e,"armL","rz",-0.75),y(e,"armR","rz",.75),y(e,"foreArmL","rx",.2),y(e,"foreArmR","rx",.2),y(e,"foreArmL","rz",1.5),y(e,"foreArmR","rz",-1.5),y(e,"legL","rz",-0.06),y(e,"legR","rz",.06);break;case "shy":y(e,"armL","rx",-0.35),y(e,"armR","rx",-0.35),y(e,"foreArmL","rx",.5),y(e,"foreArmR","rx",.5),y(e,"head","rx",-0.15+.03*r),y(e,"legR","rx",.15+.08*Math.sin(t.clock*1.3)),y(e,"shinR","rx",-0.3);break;case "ready":y(e,"legL","rz",-0.16),y(e,"legR","rz",.16),y(e,"legL","rx",.25),y(e,"legR","rx",-0.15),y(e,"shinL","rx",-0.35),y(e,"shinR","rx",-0.25),y(e,"armL","rx",.9),y(e,"armR","rx",.7),y(e,"foreArmL","rx",1.4),y(e,"foreArmR","rx",1.5),y(e,"root","py",-0.6+.3*Math.abs(Math.sin(t.clock*3.2)));break;case "bored":y(e,"root","rz",.04),y(e,"legL","rz",-0.04),y(e,"shinR","rx",-0.25),y(e,"legR","rx",.12),y(e,"head","rz",.12+.03*r),y(e,"body","rx",-0.06);break;}}var N0=(e,t)=>{ia(e,t,t.style.amp),la(e,t,t.style.arm),ca(e,t,t.style.amp*1.1,.35);let r=t.style.bob*Math.abs(Math.cos(t.phase));y(e,"root","py",r),y(e,"body","rz",t.style.sway*jt(t)),H0(e,t);};function H0(e,t){let r=t.style;if(r.reach&&(y(e,"armL","rx",r.reach+.05*Math.sin(t.phase)),y(e,"armR","rx",r.reach-.05*Math.sin(t.phase)),y(e,"foreArmL","rx",.1),y(e,"foreArmR","rx",.1),y(e,"head","rz",.15*Math.sin(t.phase*.5))),r.crouch&&(y(e,"root","py",-r.crouch),y(e,"body","rx",-0.3),y(e,"head","rx",.25),de(e,"shinL","rx",-0.5),de(e,"shinR","rx",-0.5),de(e,"legL","rx",.35),de(e,"legR","rx",.35),y(e,"armL","rx",-0.9),y(e,"armR","rx",-0.9)),r.skip){let o=Math.max(0,Math.sin(t.phase));de(e,"root","py",2.2*r.skip*o*o),de(e,"armL","rz",-0.3*o),de(e,"armR","rz",.3*o);}r.cross&&(y(e,"legL","rz",r.cross),y(e,"legR","rz",-r.cross),y(e,"root","ry",.12*jt(t))),r.swagger&&(y(e,"body","ry",r.swagger*jt(t)),y(e,"head","rz",-0.5*r.swagger*jt(t)),y(e,"armL","rz",-0.2),y(e,"armR","rz",.2));}var j0=(e,t)=>{ia(e,t,t.style.amp*1.3),la(e,t,t.style.arm*1.6),ca(e,t,t.style.amp*1.6,1.1),y(e,"body","rx",-0.18),y(e,"head","rx",.18),y(e,"root","py",(.8+t.style.bob)*Math.abs(Math.cos(t.phase)));},G0=(e,t)=>{ia(e,t,t.style.amp*.5*Math.min(1,t.input.speed)),la(e,t,t.style.arm*.4*Math.min(1,t.input.speed)),y(e,"body","rx",-0.45),y(e,"head","rx",.45),de(e,"armL","rx",.25),de(e,"armR","rx",.25),ca(e,t,.9,.6),y(e,"root","py",-1.5);},q0=(e,t)=>{y(e,"root","rx",-1.3),y(e,"head","rx",1),y(e,"armL","rx",Math.PI-.5+.5*Math.sin(t.t*3)),y(e,"armR","rx",Math.PI-.5+.5*Math.sin(t.t*3+Math.PI)),y(e,"legL","rx",.3*Math.sin(t.t*8)),y(e,"legR","rx",-0.3*Math.sin(t.t*8));},U0=(e,t)=>{y(e,"legL","rx",.15),y(e,"legR","rx",.1),y(e,"armL","rz",-0.15),y(e,"armR","rz",.15),y(e,"root","py",.6*Math.sin(t.t*2));},K0=e=>{y(e,"root","rx",-1.35),y(e,"head","rx",1.1),y(e,"armL","rz",-1.3),y(e,"armR","rz",1.3);},Y0=(e,t)=>{let r=.15*Math.sin(t.t*10);y(e,"armL","rz",-0.6-r),y(e,"armR","rz",.6+r),y(e,"legL","rx",.25),y(e,"legR","rx",-0.25),y(e,"shinL","rx",-0.5),y(e,"shinR","rx",-0.3),y(e,"foreArmL","rx",.4),y(e,"foreArmR","rx",.4);},W0=e=>{y(e,"legL","rx",1.45),y(e,"legR","rx",1.45),y(e,"legL","ry",.1),y(e,"legR","ry",-0.1),y(e,"shinL","rx",-1.45),y(e,"shinR","rx",-1.45),y(e,"root","py",-10),y(e,"body","rx",.4),y(e,"legBL","rx",1.2),y(e,"legBR","rx",1.2);},$0=e=>{y(e,"legL","rx",1.4),y(e,"legR","rx",1.4),y(e,"legL","rz",-0.3),y(e,"legR","rz",.3),y(e,"armL","rx",.45),y(e,"armR","rx",.45),y(e,"shinL","rx",-1.2),y(e,"shinR","rx",-1.2),y(e,"foreArmL","rx",.5),y(e,"foreArmR","rx",.5);},J0=e=>{y(e,"root","rx",Math.PI/2),y(e,"root","py",2);},X0=e=>{y(e,"root","rz",Math.PI/2),y(e,"root","py",2);},Q0=(e,t)=>{let r=Math.sin(t.phase*.5);y(e,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;y(e,"body","sy",1-o+.1*Math.max(0,r)),y(e,"body","sx",1+o*.6),y(e,"body","sz",1+o*.6);},Z0=(e,t)=>{let r=Math.min(t.input.speed,8),o=Math.sin(t.clock*(3+r*1.2)),a=.25+r*.04;y(e,"tail","ry",a*1.6*o),y(e,"body","ry",-a*.35*o),y(e,"root","py",.4*Math.sin(t.clock*1.6));},el=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"armR","rx",1.9*r),y(e,"armR","ry",.3*r),y(e,"body","ry",-0.3*r),y(e,"foreArmR","rx",.6*r);},tl=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"armR","rx",.9*r);},rl=(e,t)=>{let r=t.k<.4?-1.5*(t.k/.4):-1.5+3.5*((t.k-.4)/.6);y(e,"armR","rx",t.k>.9?r*(1-t.k)*10:r);},ol=(e,t)=>{let r=Math.sin(Math.PI*t.k)*(1-t.k);y(e,"armR","rx",.35*r),y(e,"foreArmR","rx",.5*r),y(e,"armL","rx",.2*r),y(e,"body","rx",-0.05*r);},al=(e,t)=>{let r=t.k<.35?t.k/.35:Math.max(0,1-(t.k-.35)/.65);y(e,"armR","rx",1.55*r),y(e,"armR","ry",-0.15*r),y(e,"foreArmR","rx",.2*(1-r)),y(e,"body","ry",.35*r),y(e,"armL","rx",.6),y(e,"foreArmL","rx",1.2);},nl=e=>{y(e,"armR","rx",1.5),y(e,"foreArmR","rx",.05),y(e,"armL","rx",1.3),y(e,"armL","ry",-0.45),y(e,"foreArmL","rx",.3);},sl=e=>{y(e,"armR","rx",1.25),y(e,"armR","ry",.25),y(e,"foreArmR","rx",.9),y(e,"armL","rx",1.45),y(e,"armL","ry",-0.35),y(e,"foreArmL","rx",.25),y(e,"body","ry",.25),y(e,"head","ry",-0.2);},il=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"body","rx",.15*r),y(e,"head","rx",.2*r),y(e,"root","rz",.05*r);},ll=(e,t)=>{let r=Math.sin(Math.PI*t.k);y(e,"root","py",-1.5*r),y(e,"legL","rx",.2*r),y(e,"legR","rx",.2*r),y(e,"shinL","rx",-0.5*r),y(e,"shinR","rx",-0.5*r),y(e,"body","sy",1-.2*r),y(e,"body","sx",1+.12*r),y(e,"body","sz",1+.12*r);},cl=(e,t)=>{y(e,"armR","rx",1.3+.1*Math.sin(t.t*16)),y(e,"armR","ry",-0.5),y(e,"head","rx",-0.1+.08*Math.sin(t.t*16));},pl=e=>{y(e,"armR","rx",2),y(e,"armR","ry",-0.4),y(e,"head","rx",.35);},ml=e=>{y(e,"armR","rx",1.57),y(e,"armR","ry",-0.1),y(e,"armL","rx",1.57),y(e,"armL","ry",.35);},hl=e=>{y(e,"armL","rx",.9),y(e,"armL","ry",-0.6);},Or={idle:B0,walk:N0,run:j0,sneak:G0,swim:q0,fly:U0,glide:K0,fall:Y0,sit:W0,ride:$0,sleep:J0,dead:X0,hop:Q0,swing:el,place:tl,throw:rl,shoot:ol,punch:al,aimPistol:nl,aimRifle:sl,hurt:il,land:ll,eat:cl,drink:pl,draw:ml,block:hl,fin:Z0},Un={blob:{walk:"hop",run:"hop",sneak:"hop"},swimmer:{idle:"fin",walk:"fin",run:"fin",sneak:"fin",swim:"fin",fall:"fin"}},Kn={swing:.3,place:.2,throw:.45,shoot:.16,punch:.28,hurt:.3,land:.22};function le(e,t,r=.3){let o={};for(let[a,n]of Object.entries(t))o[a]=[[0,0],[r,n],[Math.max(r,e-r),n],[e,0]];return o}function N(e,t){let r={};for(let[o,a]of Object.entries(t))r[o]=[[0,a],[e,a]];return r}function E(e,t,r,o,a,n=0,s=false){let l=Math.max(8,Math.round(a*8)),i=[];for(let c=0;c<=l;c++){let p=c/l,h=s?Math.min(1,p/.15,(1-p)/.15):1;i.push([e*p,(r+o*Math.sin(Math.PI*2*a*p+n))*h]);}return {[t]:i}}function vt(e,t){return [[0,t],[e,t]]}function P(e,t){return t.map(([r,o])=>[e*r,o])}function B(...e){return Object.assign({},...e)}var Yn={"legL.rx":1.5,"legR.rx":1.5,"shinL.rx":-1.5,"shinR.rx":-1.5,"root.py":-6.2},dl=4.1,Wn={"legL.rx":1.45,"legR.rx":1.45,"legL.ry":.75,"legR.ry":-0.75,"shinL.rx":-2.5,"shinR.rx":-2.5,"shinL.ry":-0.6,"shinR.ry":.6,"root.py":-10.2},_r={"root.rx":Math.PI/2,"root.py":2.3,"root.pz":0};var be=Math.PI,Xn={"armR.rx":.55,"foreArmR.rx":1.35,"armR.rz":-0.15},Vr={"armL.rx":.55,"foreArmL.rx":1.35,"armL.rz":.15},$n={...Xn,...Vr},Jn={"armL.rx":.75,"armR.rx":.75,"foreArmL.rx":.85,"foreArmR.rx":.85,"head.rx":-0.2},Se=(e,t)=>N(e,{...Yn,...t}),wo=(e,t,r,o)=>B(E(e,"legL.rx",0,r,t),E(e,"legR.rx",0,r,t,be),E(e,"shinL.rx",-o,o,t,-be/2),E(e,"shinR.rx",-o,o,t,be/2)),pa={tiptoe:{label:"\u041D\u0430 \u0446\u044B\u043F\u043E\u0447\u043A\u0430\u0445",en:"Tiptoe",duration:1.6,loop:true,tracks:B(wo(1.6,2,.35,.35),N(1.6,{"root.py":.6,"body.rx":-0.12,"armL.rx":.6,"armR.rx":.6,"foreArmL.rx":1.4,"foreArmR.rx":1.4}),E(1.6,"head.ry",0,.25,1))},limp:{label:"\u041A\u043E\u0432\u044B\u043B\u044F\u0442\u044C",en:"Limp",duration:1.6,loop:true,emotion:"hurt",tracks:{"legL.rx":P(1.6,[[0,.4],[.5,-0.3],[1,.4]]),"legR.rx":P(1.6,[[0,-0.15],[.5,.15],[1,-0.15]]),"shinL.rx":P(1.6,[[0,-0.2],[.25,-0.9],[.5,-0.1],[1,-0.2]]),"root.py":P(1.6,[[0,0],[.5,-1],[1,0]]),"body.rz":P(1.6,[[0,.04],[.5,-0.1],[1,.04]]),"armR.rz":vt(1.6,.2)}},crawl:{label:"\u041F\u043E\u043B\u0437\u0442\u0438",en:"Crawl",duration:1.6,loop:true,tracks:B(N(1.6,{"root.rx":-1.35,"root.py":3.2,"head.rx":1.1,"legL.rx":1.3,"legR.rx":1.3,"shinL.rx":-1.4,"shinR.rx":-1.4}),E(1.6,"armL.rx",2,.4,2),E(1.6,"armR.rx",2,.4,2,be),E(1.6,"legL.ry",0,.15,2,be),E(1.6,"legR.ry",0,.15,2))},climb:{label:"\u041B\u0435\u0437\u0442\u044C \u043F\u043E \u043B\u0435\u0441\u0442\u043D\u0438\u0446\u0435",en:"Climb",duration:1.6,loop:true,tracks:B(E(1.6,"armL.rx",2.6,.4,1),E(1.6,"armR.rx",2.6,.4,1,be),E(1.6,"legL.rx",.7,.6,1,be),E(1.6,"legR.rx",.7,.6,1),E(1.6,"shinL.rx",-1,.6,1,be),E(1.6,"shinR.rx",-1,.6,1),N(1.6,{"head.rx":.4,"foreArmL.rx":.5,"foreArmR.rx":.5}))},jog:{label:"\u0411\u0435\u0433 \u0442\u0440\u0443\u0441\u0446\u043E\u0439",en:"Jog",duration:.9,loop:true,tracks:B(wo(.9,1,.6,.6),E(.9,"armL.rx",0,.6,1,be),E(.9,"armR.rx",0,.6,1),N(.9,{"foreArmL.rx":1.4,"foreArmR.rx":1.4,"body.rx":-0.1}),E(.9,"root.py",.8,.8,2))},carry:{label:"\u041D\u0435\u0441\u0442\u0438 \u043A\u043E\u0440\u043E\u0431\u043A\u0443",en:"Carry",duration:1,loop:true,layer:"upper",tracks:N(1,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.7,"foreArmR.rx":.7,"armL.rz":-0.25,"armR.rz":.25,"body.rx":.08})},push:{label:"\u0422\u043E\u043B\u043A\u0430\u0442\u044C",en:"Push",duration:1.4,loop:true,emotion:"determined",tracks:B(wo(1.4,1,.3,.5),N(1.4,{"body.rx":-0.45,"head.rx":.4,"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":.5,"foreArmR.rx":.5,"root.py":-0.8}))},pull:{label:"\u0422\u044F\u043D\u0443\u0442\u044C",en:"Pull",duration:1.4,loop:true,emotion:"determined",tracks:B(wo(1.4,1,.25,.4),N(1.4,{"body.rx":.25,"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":.3,"foreArmR.rx":.3,"root.py":-0.6}))},sitChair:{label:"\u0421\u0438\u0434\u0435\u0442\u044C \u043D\u0430 \u0441\u0442\u0443\u043B\u0435",en:"Sit on a chair",seat:true,duration:2,loop:true,tracks:B(Se(2,{"armL.rx":.4,"armR.rx":.4,"foreArmL.rx":.5,"foreArmR.rx":.5}),E(2,"head.rz",0,.04,1))},sitFloor:{label:"\u041F\u043E-\u0442\u0443\u0440\u0435\u0446\u043A\u0438",en:"Sit cross-legged",duration:2,loop:true,tracks:N(2,{...Wn,"armL.rx":.5,"armR.rx":.5,"foreArmL.rx":.6,"foreArmR.rx":.6})},sitKneel:{label:"\u041D\u0430 \u043A\u043E\u043B\u0435\u043D\u044F\u0445",en:"Kneel",duration:2,loop:true,tracks:N(2,{"shinL.rx":-1.5,"shinR.rx":-1.5,"root.py":-6.1,"armL.rx":.2,"armR.rx":.2})},sitEdge:{label:"\u041D\u0430 \u043A\u0440\u0430\u044E",en:"Sit on the edge",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rz":-0.3,"armR.rz":.3,"armL.rx":-0.2,"armR.rx":-0.2}),E(2.4,"shinL.rx",-1.2,.3,2),E(2.4,"shinR.rx",-1.2,.3,2,be))},sitLounge:{label:"\u0420\u0430\u0437\u0432\u0430\u043B\u0438\u0432\u0448\u0438\u0441\u044C",en:"Lounge",seat:true,duration:2,loop:true,emotion:"cool",tracks:Se(2,{"body.rx":.35,"head.rx":-0.2,"legL.rx":1.2,"shinL.rx":-0.6,"armL.rz":-2.6,"armR.rz":2.6,"foreArmL.rz":1.8,"foreArmR.rz":-1.8,"root.py":-6.8})},sitHug:{label:"\u041E\u0431\u0445\u0432\u0430\u0442\u0438\u0432 \u043A\u043E\u043B\u0435\u043D\u0438",en:"Hug knees",duration:2,loop:true,emotion:"sad",tracks:N(2,{"legL.rx":2.4,"legR.rx":2.4,"shinL.rx":-2.6,"shinR.rx":-2.6,"root.py":-10.2,"armL.rx":1,"armR.rx":1,"foreArmL.rx":.9,"foreArmR.rx":.9,"head.rx":-0.15,"body.rx":-0.15})},squat:{label:"\u041D\u0430 \u043A\u043E\u0440\u0442\u043E\u0447\u043A\u0430\u0445",en:"Squat",duration:2,loop:true,tracks:N(2,{"legL.rx":2,"legR.rx":2,"legL.rz":-0.2,"legR.rz":.2,"shinL.rx":-2.5,"shinR.rx":-2.5,"root.py":-7,"body.rx":-0.35,"head.rx":.3,"armL.rx":.7,"armR.rx":.7,"foreArmL.rx":.6,"foreArmR.rx":.6})},sitEat:{label:"\u0415\u0441\u0442\u044C \u0441\u0438\u0434\u044F",en:"Eat (seated)",seat:true,duration:1.2,loop:true,tracks:B(Se(1.2,{...Vr,"armR.rx":.9}),E(1.2,"foreArmR.rx",1.5,.45,1),E(1.2,"head.rx",-0.1,.06,2))},sitDrink:{label:"\u041F\u0438\u0442\u044C \u0441\u0438\u0434\u044F",en:"Drink (seated)",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{}),{"armR.rx":P(2.4,[[0,.6],[.3,1.2],[.6,1.2],[1,.6]]),"foreArmR.rx":P(2.4,[[0,1.3],[.3,2],[.6,2],[1,1.3]]),"head.rx":P(2.4,[[0,0],[.3,.3],[.6,.3],[1,0]])})},sitRead:{label:"\u0427\u0438\u0442\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Read (seated)",seat:true,duration:3,loop:true,tracks:B(Se(3,{...$n,"head.rx":-0.3}),E(3,"head.ry",0,.08,1))},sitLaptop:{label:"\u0417\u0430 \u043D\u043E\u0443\u0442\u0431\u0443\u043A\u043E\u043C",en:"Laptop",seat:true,duration:1.2,loop:true,tracks:B(Se(1.2,Jn),E(1.2,"foreArmL.rx",.85,.08,4),E(1.2,"foreArmR.rx",.85,.08,4,be))},sitWrite:{label:"\u041F\u0438\u0441\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Write (seated)",seat:true,duration:1.6,loop:true,tracks:B(Se(1.6,{...Jn,"armL.rx":.6}),E(1.6,"foreArmR.rz",0,.15,3),E(1.6,"head.rz",0,.05,1))},sitTalk:{label:"\u0413\u043E\u0432\u043E\u0440\u0438\u0442\u044C \u0441\u0438\u0434\u044F",en:"Talk (seated)",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rx":.6,"foreArmL.rx":1}),E(2.4,"armR.rx",.8,.3,2),E(2.4,"foreArmR.rx",1.2,.4,3),E(2.4,"head.rz",0,.08,2))},sitLaugh:{label:"\u0421\u043C\u0435\u044F\u0442\u044C\u0441\u044F \u0441\u0438\u0434\u044F",en:"Laugh (seated)",seat:true,duration:1.6,loop:true,emotion:"happy",tracks:B(Se(1.6,{"armL.rx":.5,"armR.rx":.5,"foreArmL.rx":1,"foreArmR.rx":1}),E(1.6,"body.rx",.12,.1,4),E(1.6,"head.rx",.2,.1,4))},sitCry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Cry (seated)",seat:true,duration:2.4,loop:true,emotion:"crying",tracks:B(Se(2.4,{"armL.rx":2.2,"armR.rx":2.2,"foreArmL.rx":1.5,"foreArmR.rx":1.5,"head.rx":-0.45,"body.rx":-0.25}),E(2.4,"body.sy",1,.02,4))},sitDoze:{label:"\u041A\u043B\u0435\u0432\u0430\u0442\u044C \u043D\u043E\u0441\u043E\u043C",en:"Doze",seat:true,duration:3,loop:true,emotion:"sleepy",tracks:B(Se(3,{"armL.rx":.3,"armR.rx":.3}),{"head.rx":P(3,[[0,-0.15],[.6,-0.6],[.7,-0.1],[1,-0.15]])})},sitDrive:{label:"\u0420\u0443\u043B\u0438\u0442\u044C",en:"Drive",seat:true,duration:2.4,loop:true,tracks:B(Se(2.4,{"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":.5,"foreArmR.rx":.5}),E(2.4,"armL.rz",.2,.2,1),E(2.4,"armR.rz",-0.2,.2,1),E(2.4,"body.rz",0,.05,1,be))},sitGamepad:{label:"\u0418\u0433\u0440\u0430\u0442\u044C \u0441 \u0433\u0435\u0439\u043C\u043F\u0430\u0434\u043E\u043C",en:"Gamepad",seat:true,duration:1.2,loop:true,emotion:"determined",tracks:B(Se(1.2,{"armL.rx":.8,"armR.rx":.8,"foreArmL.rx":1.2,"foreArmR.rx":1.2,"armL.rz":.25,"armR.rz":-0.25,"body.rx":-0.15,"head.rx":-0.05}),E(1.2,"foreArmL.rz",0,.08,4),E(1.2,"body.rz",0,.05,1))},sitClap:{label:"\u0425\u043B\u043E\u043F\u0430\u0442\u044C \u0441\u0438\u0434\u044F",en:"Clap (seated)",seat:true,duration:1.2,loop:true,emotion:"happy",tracks:B(Se(1.2,{"armL.rx":1.1,"armR.rx":1.1,"foreArmL.rx":.6,"foreArmR.rx":.6}),E(1.2,"foreArmL.rz",.55,.35,4),E(1.2,"foreArmR.rz",-0.55,-0.35,4))},lieBack:{label:"\u041B\u0435\u0436\u0430\u0442\u044C \u043D\u0430 \u0441\u043F\u0438\u043D\u0435",en:"Lie on the back",duration:3,loop:true,tracks:B(N(3,{..._r,"armL.rz":-2.6,"armR.rz":2.6,"foreArmL.rz":1.6,"foreArmR.rz":-1.6,"legL.rx":.1}),E(3,"body.sy",1,.02,1))},lieSide:{label:"\u0421\u043F\u0430\u0442\u044C \u043D\u0430 \u0431\u043E\u043A\u0443",en:"Sleep on the side",duration:3,loop:true,emotion:"sleepy",tracks:B(N(3,{"root.rz":be/2,"root.py":4.6,"legL.rx":.7,"legR.rx":.4,"shinL.rx":-0.9,"shinR.rx":-0.6,"armL.rx":1.2,"armR.rx":.9,"foreArmL.rx":1.2,"head.rz":-0.2}),E(3,"body.sy",1,.02,1))},lieFront:{label:"\u041D\u0430 \u0436\u0438\u0432\u043E\u0442\u0435",en:"Lie on the front",duration:2.4,loop:true,tracks:B(N(2.4,{"root.rx":-be/2,"root.py":2.3,"head.rx":.9,"armL.rx":2.6,"armR.rx":2.6,"foreArmL.rx":1.6,"foreArmR.rx":1.6,"shinR.rx":-1.4}),E(2.4,"shinL.rx",-1.2,.5,1))},getUp:{label:"\u0412\u0441\u0442\u0430\u0442\u044C \u0441 \u043F\u043E\u043B\u0430",en:"Get up",duration:1.8,tracks:{"root.rx":P(1.8,[[0,be/2],[.3,.6],[.6,0],[1,0]]),"root.py":P(1.8,[[0,2.3],[.3,-6],[.6,-6],[1,0]]),"legL.rx":P(1.8,[[0,0],[.3,1.8],[.6,1.5],[1,0]]),"legR.rx":P(1.8,[[0,0],[.3,.2],[.6,-0.1],[1,0]]),"shinL.rx":P(1.8,[[0,0],[.3,-2],[.6,-1.5],[1,0]]),"shinR.rx":P(1.8,[[0,0],[.3,-1.6],[.6,-1.4],[1,0]]),"armL.rx":P(1.8,[[0,0],[.3,-0.6],[.6,.4],[1,0]])}},phone:{label:"\u0413\u043E\u0432\u043E\u0440\u0438\u0442\u044C \u043F\u043E \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0443",en:"Phone call",duration:2.4,loop:true,layer:"upper",tracks:B(N(2.4,{"armR.rx":2.1,"armR.rz":-0.08,"head.rz":-0.15}),E(2.4,"head.rx",0,.05,2),E(2.4,"armL.rz",-0.15,.15,2))},phoneScroll:{label:"\u041B\u0438\u0441\u0442\u0430\u0442\u044C \u0442\u0435\u043B\u0435\u0444\u043E\u043D",en:"Scroll phone",duration:1.6,loop:true,layer:"upper",tracks:B(N(1.6,{...Xn,"armL.rx":.5,"foreArmL.rx":1.4,"armL.rz":.3,"head.rx":-0.4}),E(1.6,"foreArmL.rz",.1,.06,2))},selfie:{label:"\u0421\u0435\u043B\u0444\u0438",en:"Selfie",duration:2,loop:true,emotion:"happy",layer:"upper",tracks:B(N(2,{"armR.rx":1.8,"armR.rz":.6,"foreArmR.rx":.2,"head.rz":-0.15,"armL.rz":-1.4,"foreArmL.rz":1.2}),E(2,"head.ry",.2,.05,1))},photo:{label:"\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0440\u043E\u0432\u0430\u0442\u044C",en:"Take a photo",duration:2,loop:true,layer:"upper",tracks:N(2,{"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":1.2,"foreArmR.rx":1.2,"armL.rz":.35,"armR.rz":-0.35,"head.rx":.05})},drinkCup:{label:"\u041F\u0438\u0442\u044C \u0438\u0437 \u043A\u0440\u0443\u0436\u043A\u0438",en:"Drink from a cup",duration:2.4,loop:true,layer:"upper",tracks:{"armR.rx":P(2.4,[[0,.55],[.3,1.2],[.6,1.2],[1,.55]]),"foreArmR.rx":P(2.4,[[0,1.35],[.3,2.1],[.6,2.1],[1,1.35]]),"head.rx":P(2.4,[[0,0],[.3,.3],[.6,.3],[1,0]])}},eat:{label:"\u0415\u0441\u0442\u044C",en:"Eat",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{...Vr,"armR.rx":.9}),E(1.2,"foreArmR.rx",1.5,.45,1),E(1.2,"head.rx",-0.1,.06,2))},read:{label:"\u0427\u0438\u0442\u0430\u0442\u044C",en:"Read",duration:3,loop:true,layer:"upper",tracks:B(N(3,{...$n,"head.rx":-0.35}),E(3,"head.ry",0,.08,1))},board:{label:"\u041F\u0438\u0441\u0430\u0442\u044C \u043D\u0430 \u0434\u043E\u0441\u043A\u0435",en:"Write on a board",duration:2,loop:true,tracks:B(N(2,{"armR.rx":2,"foreArmR.rx":.4,"body.ry":.15,"head.rx":.2}),E(2,"armR.rz",0,.25,2),E(2,"foreArmR.rz",0,.2,4))},cook:{label:"\u0413\u043E\u0442\u043E\u0432\u0438\u0442\u044C",en:"Cook",duration:1.6,loop:true,layer:"upper",tracks:B(N(1.6,{...Vr,"armR.rx":.9,"foreArmR.rx":.9,"head.rx":-0.3}),E(1.6,"armR.rz",0,.2,2),E(1.6,"armR.ry",0,.3,2,be/2))},dishes:{label:"\u041C\u044B\u0442\u044C \u043F\u043E\u0441\u0443\u0434\u0443",en:"Wash dishes",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.6,"foreArmR.rx":.6,"head.rx":-0.35,"body.rx":-0.1}),E(1.6,"armR.rz",0,.15,3),E(1.6,"armL.rz",0,.12,3,be))},sweep:{label:"\u041F\u043E\u0434\u043C\u0435\u0442\u0430\u0442\u044C",en:"Sweep",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":.6,"armR.rx":.4,"foreArmL.rx":.9,"foreArmR.rx":.5,"body.rx":-0.15,"head.rx":-0.2}),E(1.6,"body.ry",0,.3,2),E(1.6,"armL.rz",0,.25,2))},water:{label:"\u041F\u043E\u043B\u0438\u0432\u0430\u0442\u044C \u0446\u0432\u0435\u0442\u044B",en:"Water plants",duration:2.4,loop:true,tracks:B(N(2.4,{"armR.rx":.9,"foreArmR.rx":.5,"body.rx":-0.1,"head.rx":-0.3}),E(2.4,"armR.rz",-0.1,.25,1))},dig:{label:"\u041A\u043E\u043F\u0430\u0442\u044C",en:"Dig",duration:1.6,loop:true,emotion:"determined",tracks:{"body.rx":P(1.6,[[0,-0.1],[.4,-0.6],[.7,0],[1,-0.1]]),"armL.rx":P(1.6,[[0,.6],[.4,1.4],[.7,.5],[1,.6]]),"armR.rx":P(1.6,[[0,.4],[.4,.9],[.7,.2],[1,.4]]),"foreArmL.rx":vt(1.6,.8),"foreArmR.rx":vt(1.6,.6),"shinL.rx":P(1.6,[[0,0],[.4,-0.5],[.7,0],[1,0]]),"shinR.rx":P(1.6,[[0,0],[.4,-0.5],[.7,0],[1,0]]),"root.py":P(1.6,[[0,0],[.4,-1],[.7,0],[1,0]])}},fish:{label:"\u0420\u044B\u0431\u0430\u0447\u0438\u0442\u044C",en:"Fish",duration:3,loop:true,tracks:B(N(3,{"armL.rx":.9,"armR.rx":.9,"foreArmL.rx":.9,"foreArmR.rx":.7,"head.rx":.05}),E(3,"armR.rx",.9,.08,2))},paint:{label:"\u0420\u0438\u0441\u043E\u0432\u0430\u0442\u044C \u043D\u0430 \u043C\u043E\u043B\u044C\u0431\u0435\u0440\u0442\u0435",en:"Paint",duration:2,loop:true,layer:"upper",tracks:B(N(2,{"armR.rx":1.4,"foreArmR.rx":.6,...Vr,"head.rz":.1}),E(2,"armR.rz",0,.2,2),E(2,"foreArmR.rx",.6,.25,3))},brushTeeth:{label:"\u0427\u0438\u0441\u0442\u0438\u0442\u044C \u0437\u0443\u0431\u044B",en:"Brush teeth",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{"armR.rx":1,"foreArmR.rx":2,"armR.rz":-0.2,"head.rx":.05}),E(1.2,"armR.ry",0,.2,6))},washFace:{label:"\u0423\u043C\u044B\u0432\u0430\u0442\u044C\u0441\u044F",en:"Wash face",duration:1.6,loop:true,tracks:B(N(1.6,{"armL.rx":1.4,"armR.rx":1.4,"foreArmL.rx":1.9,"foreArmR.rx":1.9,"body.rx":-0.45,"head.rx":-0.3}),E(1.6,"foreArmL.rx",1.9,.25,3),E(1.6,"foreArmR.rx",1.9,.25,3))},openDoor:{label:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0434\u0432\u0435\u0440\u044C",en:"Open a door",duration:1.6,layer:"upper",tracks:{"armR.rx":P(1.6,[[0,0],[.3,1.3],[.6,1.3],[.9,.6],[1,0]]),"foreArmR.rx":P(1.6,[[0,0],[.3,.4],[.6,.4],[1,0]]),"armR.ry":P(1.6,[[0,0],[.3,0],[.45,-0.5],[.9,-0.6],[1,0]]),"body.ry":P(1.6,[[0,0],[.6,-0.2],[1,0]])}},knock:{label:"\u041F\u043E\u0441\u0442\u0443\u0447\u0430\u0442\u044C",en:"Knock",duration:1.4,layer:"upper",tracks:B({"armR.rx":P(1.4,[[0,0],[.2,1.3],[.85,1.3],[1,0]])},E(1.4,"foreArmR.rx",1.4,.35,3,0,true),{"head.rz":P(1.4,[[0,0],[.3,.1],[1,0]])})},checkWatch:{label:"\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u043D\u0430 \u0447\u0430\u0441\u044B",en:"Check the time",duration:1.6,layer:"upper",tracks:{"armL.rx":P(1.6,[[0,0],[.25,.9],[.8,.9],[1,0]]),"foreArmL.rx":P(1.6,[[0,0],[.25,1.4],[.8,1.4],[1,0]]),"armL.rz":P(1.6,[[0,0],[.25,.4],[.8,.4],[1,0]]),"head.rx":P(1.6,[[0,0],[.3,-0.4],[.8,-0.4],[1,0]]),"head.ry":P(1.6,[[0,0],[.3,-0.25],[.8,-0.25],[1,0]])}},wait:{label:"\u0416\u0434\u0430\u0442\u044C",en:"Wait",duration:1.2,loop:true,emotion:"tired",tracks:B(N(1.2,{"armL.rz":-0.8,"armR.rz":.8,"foreArmL.rz":1.5,"foreArmR.rz":-1.5}),{"legR.rx":P(1.2,[[0,.15],[.25,.15],[.5,.15],[1,.15]]),"shinR.rx":P(1.2,[[0,-0.2],[.2,-0.45],[.4,-0.2],[.6,-0.45],[.8,-0.2],[1,-0.2]])})},pockets:{label:"\u0420\u0443\u043A\u0438 \u0432 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u0445",en:"Hands in pockets",duration:2,loop:true,emotion:"cool",layer:"upper",tracks:N(2,{"armL.rx":-0.25,"armR.rx":-0.25,"armL.rz":-0.12,"armR.rz":.12,"foreArmL.rx":.5,"foreArmR.rx":.5,"head.rx":.05})},armsCrossed:{label:"\u0420\u0443\u043A\u0438 \u0441\u043A\u0440\u0435\u0449\u0435\u043D\u044B",en:"Arms crossed",duration:2,loop:true,layer:"upper",tracks:N(2,{"armL.rx":.6,"armR.rx":.6,"armL.rz":.35,"armR.rz":-0.35,"foreArmL.rx":1.6,"foreArmR.rx":1.6,"foreArmL.ry":-0.7,"foreArmR.ry":.7,"head.rx":.08})},lean:{label:"\u041E\u0431\u043B\u043E\u043A\u043E\u0442\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u0441\u0442\u0435\u043D\u0443",en:"Lean on a wall",duration:2,loop:true,emotion:"cool",tracks:N(2,{"root.rz":-0.12,"root.px":-1,"legL.rx":.15,"legL.ry":.2,"shinL.rx":-0.4,"armR.rz":1.5,"foreArmR.rz":-1.4,"armL.rx":-0.2,"foreArmL.rx":.4,"head.rz":.06})},shiver:{label:"\u0414\u0440\u043E\u0436\u0430\u0442\u044C \u043E\u0442 \u0445\u043E\u043B\u043E\u0434\u0430",en:"Shiver",duration:1.2,loop:true,emotion:"scared",layer:"upper",tracks:B(N(1.2,{"armL.rx":.8,"armR.rx":.8,"armL.rz":.5,"armR.rz":-0.5,"foreArmL.rx":1.4,"foreArmR.rx":1.4,"head.rx":-0.15}),E(1.2,"body.rz",0,.03,10),E(1.2,"head.rz",0,.04,9))},fan:{label:"\u041E\u0431\u043C\u0430\u0445\u0438\u0432\u0430\u0442\u044C\u0441\u044F",en:"Fan yourself",duration:1.2,loop:true,emotion:"tired",layer:"upper",tracks:B(N(1.2,{"armR.rx":.9,"foreArmR.rx":1.7,"head.rx":.15}),E(1.2,"foreArmR.rz",0,.4,4))},sneeze:{label:"\u0427\u0438\u0445\u043D\u0443\u0442\u044C",en:"Sneeze",duration:1.4,tracks:{"head.rx":P(1.4,[[0,0],[.45,.4],[.55,-0.4],[.8,-0.2],[1,0]]),"body.rx":P(1.4,[[0,0],[.45,.1],[.55,-0.35],[.8,-0.1],[1,0]]),"armR.rx":P(1.4,[[0,0],[.4,1.3],[.8,1.3],[1,0]]),"foreArmR.rx":P(1.4,[[0,0],[.4,1.9],[.8,1.9],[1,0]])}},cough:{label:"\u041A\u0430\u0448\u043B\u044F\u0442\u044C",en:"Cough",duration:1.4,layer:"upper",tracks:B({"armR.rx":P(1.4,[[0,0],[.2,1.2],[.85,1.2],[1,0]]),"foreArmR.rx":P(1.4,[[0,0],[.2,2],[.85,2],[1,0]])},E(1.4,"body.rx",-0.1,.1,3,0,true),E(1.4,"head.rx",-0.1,.12,3,0,true))},hug:{label:"\u041E\u0431\u043D\u044F\u0442\u044C",en:"Hug",duration:2,loop:true,emotion:"love",layer:"upper",tracks:N(2,{"armL.rx":1.3,"armR.rx":1.3,"armL.rz":-0.4,"armR.rz":.4,"foreArmL.rz":1,"foreArmR.rz":-1,"foreArmL.rx":.4,"foreArmR.rx":.4,"head.rz":.1})},handshake:{label:"\u0420\u0443\u043A\u043E\u043F\u043E\u0436\u0430\u0442\u0438\u0435",en:"Handshake",duration:1.6,loop:true,emotion:"happy",layer:"upper",tracks:B(N(1.6,{"armR.rx":.9,"foreArmR.rx":.5}),E(1.6,"foreArmR.rx",.5,.15,3))},highFive:{label:"\u0414\u0430\u0442\u044C \u043F\u044F\u0442\u044C",en:"High five",duration:1.2,emotion:"excited",layer:"upper",tracks:{"armR.rz":P(1.2,[[0,0],[.3,.35],[1,0]]),"armR.rx":P(1.2,[[0,0],[.3,2.8],[.45,2.5],[.8,2.5],[1,0]]),"body.ry":P(1.2,[[0,0],[.4,-0.15],[1,0]])}},throw:{label:"\u0411\u0440\u043E\u0441\u0438\u0442\u044C",en:"Throw",duration:1.2,layer:"upper",tracks:{"armR.rx":P(1.2,[[0,0],[.35,-0.6],[.5,2.2],[.7,1.2],[1,0]]),"armR.rz":P(1.2,[[0,0],[.35,.8],[.5,.2],[1,0]]),"body.ry":P(1.2,[[0,0],[.35,.35],[.55,-0.3],[1,0]]),"armL.rx":P(1.2,[[0,0],[.35,1],[.55,.2],[1,0]])}},catch:{label:"\u041F\u043E\u0439\u043C\u0430\u0442\u044C",en:"Catch",duration:1.2,emotion:"surprised",layer:"upper",tracks:{"armL.rx":P(1.2,[[0,0],[.3,1.6],[.5,1.4],[.8,.9],[1,0]]),"armR.rx":P(1.2,[[0,0],[.3,1.6],[.5,1.4],[.8,.9],[1,0]]),"foreArmL.rx":P(1.2,[[0,0],[.5,.4],[.8,1.2],[1,0]]),"foreArmR.rx":P(1.2,[[0,0],[.5,.4],[.8,1.2],[1,0]]),"body.rx":P(1.2,[[0,0],[.5,.08],[1,0]])}},juggle:{label:"\u041F\u043E\u0434\u043A\u0438\u0434\u044B\u0432\u0430\u0442\u044C \u043C\u044F\u0447",en:"Juggle",duration:1.2,loop:true,layer:"upper",tracks:B(N(1.2,{"armL.rx":.7,"armR.rx":.7,"head.rx":.35}),E(1.2,"foreArmL.rx",1.2,.35,2),E(1.2,"foreArmR.rx",1.2,.35,2,be))}};var Gt=Math.PI,ma={clap:{label:"\u0425\u043B\u043E\u043F\u0430\u0442\u044C",en:"Clap",duration:1.8,emotion:"happy",layer:"upper",tracks:B(le(1.8,{"armL.rx":1.2,"armR.rx":1.2,"armL.rz":.25,"armR.rz":-0.25},.2),E(1.8,"foreArmL.rz",.55,.35,5,0,true),E(1.8,"foreArmR.rz",-0.55,-0.35,5,0,true),le(1.8,{"foreArmL.rx":.6,"foreArmR.rx":.6},.2))},salute:{label:"\u041E\u0442\u0434\u0430\u0442\u044C \u0447\u0435\u0441\u0442\u044C",en:"Salute",duration:1.6,layer:"upper",tracks:le(1.6,{"armR.rx":2.6,"armR.rz":-0.12,"head.rx":.08},.25)},thumbsUp:{label:"\u041A\u043B\u0430\u0441\u0441",en:"Thumbs up",duration:1.4,emotion:"happy",layer:"upper",tracks:le(1.4,{"armR.rx":1,"armR.rz":.3,"foreArmR.rx":1.2,"head.rz":-0.1},.2)},heartHands:{label:"\u0421\u0435\u0440\u0434\u0446\u0435 \u0440\u0443\u043A\u0430\u043C\u0438",en:"Heart hands",duration:2,emotion:"love",layer:"upper",tracks:le(2,{"armL.rz":-2.3,"armR.rz":2.3,"armL.rx":.4,"armR.rx":.4,"foreArmL.rz":1.3,"foreArmR.rz":-1.3,"head.rz":.12})},think:{label:"\u0414\u0443\u043C\u0430\u0442\u044C",en:"Think",duration:2.4,emotion:"confused",layer:"upper",tracks:B(le(2.4,{"armR.rx":.9,"armR.rz":-0.2,"foreArmR.rx":2.1,"armL.rx":.5,"foreArmL.rx":1.4,"armL.rz":.3}),E(2.4,"head.rz",.12,.05,2,0,true),le(2.4,{"head.rx":.15}))},nod:{label:"\u0414\u0430",en:"Yes",duration:1.2,layer:"upper",tracks:E(1.2,"head.rx",-0.1,.22,3,0,true)},headShake:{label:"\u041D\u0435\u0442",en:"No",duration:1.2,layer:"upper",tracks:E(1.2,"head.ry",0,.4,3,0,true)},beckon:{label:"\u0418\u0434\u0438 \u0441\u044E\u0434\u0430",en:"Come here",duration:1.8,layer:"upper",tracks:B(le(1.8,{"armR.rx":1.3,"armR.rz":.2}),E(1.8,"foreArmR.rx",1,.6,3,0,true),le(1.8,{"head.rz":.1}))},stop:{label:"\u0421\u0442\u043E\u043F",en:"Stop",duration:1.4,emotion:"determined",layer:"upper",tracks:le(1.4,{"armR.rx":1.55,"foreArmR.rx":1.2,"body.rx":.06},.15)},yawn:{label:"\u0417\u0435\u0432\u043D\u0443\u0442\u044C",en:"Yawn",duration:2.4,emotion:"sleepy",layer:"upper",tracks:le(2.4,{"armR.rx":1.4,"foreArmR.rx":1.9,"armR.rz":-0.25,"armL.rz":-0.35,"armL.rx":-0.15,"head.rx":.35,"body.rx":.08},.5)},stretch:{label:"\u041F\u043E\u0442\u044F\u043D\u0443\u0442\u044C\u0441\u044F",en:"Stretch",duration:2.6,emotion:"sleepy",tracks:B(le(2.6,{"armL.rz":-2.9,"armR.rz":2.9,"head.rx":.3,"body.rx":.12},.6),{"root.py":P(2.6,[[0,0],[.3,.8],[.7,.8],[1,0]])})},flex:{label:"\u0421\u0438\u043B\u0430",en:"Flex",duration:1.8,emotion:"determined",layer:"upper",tracks:B(le(1.8,{"armL.rz":-1.5,"armR.rz":1.5,"foreArmL.rz":-1.6,"foreArmR.rz":1.6,"body.rx":.08},.25),E(1.8,"body.ry",0,.15,2,0,true))},jumpJoy:{label:"\u041F\u0440\u044B\u0436\u043E\u043A \u0440\u0430\u0434\u043E\u0441\u0442\u0438",en:"Jump for joy",duration:1.4,emotion:"excited",tracks:{"root.py":P(1.4,[[0,0],[.15,-1.5],[.4,6],[.6,6],[.8,0],[.9,-1],[1,0]]),"armL.rz":P(1.4,[[0,0],[.4,-2.8],[.7,-2.8],[1,0]]),"armR.rz":P(1.4,[[0,0],[.4,2.8],[.7,2.8],[1,0]]),"shinL.rx":P(1.4,[[0,0],[.15,-0.6],[.45,-1.4],[.7,-1.2],[.85,-0.4],[1,0]]),"shinR.rx":P(1.4,[[0,0],[.15,-0.6],[.45,-1.4],[.7,-1.2],[.85,-0.4],[1,0]])}},spin:{label:"\u041A\u0440\u0443\u0436\u0438\u0442\u044C\u0441\u044F",en:"Spin",duration:1.6,emotion:"happy",tracks:{"root.ry":P(1.6,[[0,0],[1,Gt*2]]),"armL.rz":P(1.6,[[0,0],[.2,-1.5],[.8,-1.5],[1,0]]),"armR.rz":P(1.6,[[0,0],[.2,1.5],[.8,1.5],[1,0]])}},victory:{label:"\u041F\u043E\u0431\u0435\u0434\u0430",en:"Victory",duration:2,emotion:"excited",tracks:B(le(2,{"armR.rz":2.9,"armL.rz":-0.4,"foreArmL.rx":1.3,"armL.rx":.3,"head.rx":.2,"body.rx":.08}),{"root.py":P(2,[[0,0],[.2,3],[.35,0],[1,0]])})},airGuitar:{label:"\u0413\u0438\u0442\u0430\u0440\u0430",en:"Air guitar",duration:2.4,loop:true,emotion:"excited",tracks:B(N(2.4,{"armL.rx":1.2,"armL.rz":-0.5,"foreArmL.rz":.7,"armR.rx":.5,"foreArmR.rx":1.2,"legL.rx":.3,"shinL.rx":-0.4}),E(2.4,"foreArmR.rz",-0.2,.35,8),E(2.4,"head.rx",-0.1,.18,4),E(2.4,"body.rx",-0.05,.06,4))},drum:{label:"\u0411\u0430\u0440\u0430\u0431\u0430\u043D",en:"Drum",duration:1.6,loop:true,emotion:"excited",tracks:B(N(1.6,{"armL.rx":.7,"armR.rx":.7}),E(1.6,"foreArmL.rx",1,.5,4),E(1.6,"foreArmR.rx",1,.5,4,Gt),E(1.6,"head.rx",0,.12,4))},pushups:{label:"\u041E\u0442\u0436\u0438\u043C\u0430\u043D\u0438\u044F",en:"Push-ups",duration:2,loop:true,emotion:"determined",tracks:B(N(2,{"root.rx":-1.35,"armL.rx":1.45,"armR.rx":1.45,"head.rx":1.1}),E(2,"root.py",3.4,1.2,2),E(2,"foreArmL.rx",-0.5,.5,2),E(2,"foreArmR.rx",-0.5,.5,2))},kneel:{label:"\u041D\u0430 \u043A\u043E\u043B\u0435\u043D\u043E",en:"Kneel",duration:2.4,tracks:le(2.4,{"legR.rx":-0.15,"shinR.rx":-1.4,"legL.rx":1.5,"shinL.rx":-1.5,"root.py":-6,"armR.rx":.9,"foreArmR.rx":1.4,"head.rx":-0.15},.5)},curtsy:{label:"\u0420\u0435\u0432\u0435\u0440\u0430\u043D\u0441",en:"Curtsy",duration:1.6,tracks:le(1.6,{"legR.rx":-0.4,"shinL.rx":-0.6,"shinR.rx":-0.6,"root.py":-1.4,"armL.rz":-0.5,"armR.rz":.5,"body.rx":-0.15,"head.rx":-0.2},.4)},scratchHead:{label:"\u041F\u043E\u0447\u0435\u0441\u0430\u0442\u044C \u0437\u0430\u0442\u044B\u043B\u043E\u043A",en:"Scratch head",duration:1.8,emotion:"confused",layer:"upper",tracks:B(le(1.8,{"armR.rx":3.05,"armR.rz":-0.35,"head.rz":.15,"head.rx":.2}),E(1.8,"foreArmR.rx",.35,.25,5,0,true))},hide:{label:"\u0421\u043F\u0440\u044F\u0442\u0430\u0442\u044C\u0441\u044F",en:"Hide",duration:2,emotion:"scared",tracks:le(2,{"armL.rx":2.4,"armR.rx":2.4,"foreArmL.rx":1.4,"foreArmR.rx":1.4,"body.rx":-0.35,"head.rx":-0.4,"shinL.rx":-0.5,"shinR.rx":-0.5,"root.py":-1.5},.2)},stomp:{label:"\u0422\u043E\u043F\u043D\u0443\u0442\u044C",en:"Stomp",duration:1.2,emotion:"angry",tracks:B(le(1.2,{"armL.rz":-0.35,"armR.rz":.35,"body.rx":-0.1},.15),{"legR.rx":P(1.2,[[0,0],[.3,.8],[.45,0],[.65,.8],[.8,0],[1,0]]),"shinR.rx":P(1.2,[[0,0],[.3,-1],[.45,0],[.65,-1],[.8,0],[1,0]])})},slump:{label:"\u041F\u043E\u043D\u0438\u043A",en:"Slump",duration:2.4,emotion:"sad",tracks:le(2.4,{"body.rx":-0.35,"head.rx":-0.45,"armL.rz":.05,"armR.rz":-0.05,"shinL.rx":-0.15,"shinR.rx":-0.15},.6)},rollLaugh:{label:"\u0412\u0430\u043B\u044F\u0442\u044C\u0441\u044F \u043E\u0442 \u0441\u043C\u0435\u0445\u0430",en:"Rolling with laughter",duration:2.4,loop:true,emotion:"happy",tracks:B(N(2.4,{..._r,"armL.rx":1.2,"armR.rx":1.2,"foreArmL.rx":1.2,"foreArmR.rx":1.2}),E(2.4,"root.rz",0,.35,2),E(2.4,"legL.rx",1,.5,4),E(2.4,"legR.rx",1,.5,4,Gt),E(2.4,"head.rx",.2,.15,6))},blowKiss:{label:"\u0412\u043E\u0437\u0434\u0443\u0448\u043D\u044B\u0439 \u043F\u043E\u0446\u0435\u043B\u0443\u0439",en:"Blow a kiss",duration:1.6,emotion:"love",layer:"upper",tracks:{"armR.rx":P(1.6,[[0,0],[.3,1.2],[.55,1.2],[.75,1.6],[1,0]]),"foreArmR.rx":P(1.6,[[0,0],[.3,2],[.55,2],[.75,.3],[1,0]]),"armR.rz":P(1.6,[[0,0],[.3,-0.2],[.75,.4],[1,0]]),"head.rz":P(1.6,[[0,0],[.3,.12],[.9,.12],[1,0]])}},phew:{label:"\u0424\u0443\u0445",en:"Phew",duration:1.6,emotion:"tired",layer:"upper",tracks:{"armR.rz":P(1.6,[[0,0],[.3,1.7],[.7,2.1],[1,0]]),"foreArmR.rz":P(1.6,[[0,0],[.3,-1.4],[.7,-1.6],[1,0]]),"head.rx":P(1.6,[[0,0],[.3,.2],[.7,-0.2],[1,0]]),"body.rx":P(1.6,[[0,0],[.6,-0.08],[1,0]])}},lookAround:{label:"\u041E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C\u0441\u044F",en:"Look around",duration:2.6,layer:"upper",tracks:{"head.ry":P(2.6,[[0,0],[.2,.9],[.45,.9],[.65,-0.9],[.85,-0.9],[1,0]]),"body.ry":P(2.6,[[0,0],[.2,.25],[.45,.25],[.65,-0.25],[.85,-0.25],[1,0]]),"armR.rx":P(2.6,[[0,0],[.2,2.6],[.85,2.6],[1,0]]),"foreArmR.rx":P(2.6,[[0,0],[.2,.9],[.85,.9],[1,0]])}},karate:{label:"\u041A\u0430\u0440\u0430\u0442\u044D",en:"Karate",duration:1.8,emotion:"determined",tracks:{"armR.rx":P(1.8,[[0,.6],[.2,.6],[.3,1.57],[.45,.6],[1,0]]),"foreArmR.rx":P(1.8,[[0,1.6],[.2,1.6],[.3,0],[.45,1.6],[1,0]]),"armL.rx":P(1.8,[[0,.6],[.45,.6],[.55,1.57],[.7,.6],[1,0]]),"foreArmL.rx":P(1.8,[[0,1.6],[.45,1.6],[.55,0],[.7,1.6],[1,0]]),"legR.rx":P(1.8,[[0,0],[.7,0],[.8,1.4],[.9,0],[1,0]]),"body.ry":P(1.8,[[0,0],[.3,-0.3],[.55,.3],[.8,0],[1,0]]),"root.py":P(1.8,[[0,-1],[.9,-1],[1,0]])}},nap:{label:"\u0423\u0441\u043D\u0443\u0442\u044C",en:"Nap",duration:3,loop:true,emotion:"sleepy",tracks:B(N(3,{..._r,"armL.rz":-0.3,"armR.rz":2.4,"foreArmR.rz":-1.4,"legL.rx":.15}),E(3,"body.sy",1,.03,1))},danceRobot:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0420\u043E\u0431\u043E\u0442\xBB",en:"Robot dance",duration:2,loop:true,emotion:"cool",tracks:{"armL.rx":P(2,[[0,1.57],[.25,1.57],[.26,0],[.5,0],[.51,1.57],[.75,1.57],[.76,0],[1,1.57]]),"foreArmL.rx":P(2,[[0,0],[.25,0],[.26,1.57],[.5,1.57],[.51,0],[1,0]]),"armR.rx":P(2,[[0,0],[.25,0],[.26,1.57],[.5,1.57],[.51,0],[.75,0],[.76,1.57],[1,0]]),"foreArmR.rx":P(2,[[0,1.57],[.25,1.57],[.26,0],[.75,0],[.76,1.57],[1,1.57]]),"head.ry":P(2,[[0,.4],[.25,.4],[.26,-0.4],[.75,-0.4],[.76,.4],[1,.4]]),"root.py":P(2,[[0,0],[.25,-0.8],[.5,0],[.75,-0.8],[1,0]])}},danceHop:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u041F\u0440\u044B\u0433-\u0441\u043A\u043E\u043A\xBB",en:"Hop dance",duration:1.6,loop:true,emotion:"excited",tracks:B(E(1.6,"root.py",1.2,1.2,4),E(1.6,"legL.rx",.25,.35,2),E(1.6,"legR.rx",.25,.35,2,Gt),E(1.6,"shinL.rx",-0.5,.3,2),E(1.6,"shinR.rx",-0.5,.3,2,Gt),E(1.6,"armL.rz",-1.6,.9,2),E(1.6,"armR.rz",1.6,.9,2))},danceSway:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u041F\u043E\u043A\u0430\u0447\u0438\u0432\u0430\u043D\u0438\u0435\xBB",en:"Sway dance",duration:2.4,loop:true,emotion:"happy",tracks:B(E(2.4,"body.rz",0,.12,2),E(2.4,"head.rz",0,.16,2,Gt),E(2.4,"root.px",0,1.2,2),E(2.4,"armL.rz",-0.6,.4,2),E(2.4,"armR.rz",.6,.4,2),N(2.4,{"foreArmL.rx":1.1,"foreArmR.rx":1.1}),E(2.4,"shinL.rx",-0.2,.2,2),E(2.4,"shinR.rx",-0.2,.2,2,Gt))},danceDisco:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0414\u0438\u0441\u043A\u043E\xBB",en:"Disco dance",duration:2,loop:true,emotion:"cool",tracks:{"armR.rz":P(2,[[0,2.6],[.25,.2],[.5,2.6],[.75,.2],[1,2.6]]),"armR.rx":P(2,[[0,.6],[.25,.9],[.5,.6],[.75,.9],[1,.6]]),"armL.rz":vt(2,-0.3),"armL.rx":vt(2,.4),"foreArmL.rx":vt(2,1.3),"body.ry":P(2,[[0,.3],[.25,-0.2],[.5,.3],[.75,-0.2],[1,.3]]),"root.py":P(2,[[0,0],[.125,-0.8],[.25,0],[.375,-0.8],[.5,0],[.625,-0.8],[.75,0],[.875,-0.8],[1,0]]),"legL.rz":P(2,[[0,0],[.25,-0.2],[.5,0],[.75,-0.2],[1,0]])}},danceWave:{label:"\u0422\u0430\u043D\u0435\u0446 \xAB\u0412\u043E\u043B\u043D\u0430\xBB",en:"Wave dance",duration:2,loop:true,emotion:"happy",tracks:B(E(2,"armL.rz",-1.57,.35,2,0),E(2,"foreArmL.rz",0,.6,2,.8),E(2,"armR.rz",1.57,-0.35,2,1.6),E(2,"foreArmR.rz",0,-0.6,2,2.4),E(2,"body.rz",0,.08,2,1.2),E(2,"head.rz",0,.12,2,2),E(2,"root.py",-0.4,.4,4))}};var Ro=Math.PI,Qn={wave:{label:"\u041F\u043E\u043C\u0430\u0445\u0430\u0442\u044C",duration:2,emotion:"happy",tracks:{"armR.rz":[[0,0],[.25,2.7],[.5,2.3],[.75,2.8],[1,2.3],[1.25,2.8],[1.5,2.4],[2,0]],"armR.rx":[[0,0],[.25,.2],[1.75,.2],[2,0]],"head.rz":[[0,0],[.5,.1],[1.5,.1],[2,0]]}},cheer:{label:"\u0423\u0440\u0430!",duration:1.6,emotion:"happy",tracks:{"armL.rz":[[0,0],[.25,-2.8],[1.35,-2.8],[1.6,0]],"armR.rz":[[0,0],[.25,2.8],[1.35,2.8],[1.6,0]],"root.py":[[0,0],[.3,3],[.55,0],[.8,3],[1.05,0]]}},dance:{label:"\u0422\u0430\u043D\u0435\u0446",duration:2,loop:true,emotion:"happy",tracks:{"root.ry":[[0,.3],[.5,-0.3],[1,.3],[1.5,-0.3],[2,.3]],"armL.rz":[[0,-0.4],[.5,-2.4],[1,-0.4],[1.5,-2.4],[2,-0.4]],"armR.rz":[[0,2.4],[.5,.4],[1,2.4],[1.5,.4],[2,2.4]],"legL.rx":[[0,0],[.5,.5],[1,0],[2,0]],"legR.rx":[[0,0],[1,0],[1.5,.5],[2,0]],"root.py":[[0,0],[.25,1.5],[.5,0],[.75,1.5],[1,0],[1.25,1.5],[1.5,0],[1.75,1.5],[2,0]],"tail.ry":[[0,.6],[.5,-0.6],[1,.6],[1.5,-0.6],[2,.6]]}},point:{label:"\u0423\u043A\u0430\u0437\u0430\u0442\u044C",duration:1.6,tracks:{"armR.rx":[[0,0],[.2,1.55],[1.4,1.55],[1.6,0]]}},laugh:{label:"\u0421\u043C\u0435\u0445",duration:1.6,emotion:"happy",tracks:{"body.rx":[[0,0],[.2,.15],[.4,.05],[.6,.15],[.8,.05],[1,.15],[1.2,.05],[1.6,0]],"head.rx":[[0,0],[.2,.3],[1.4,.3],[1.6,0]],"armL.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]],"armR.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]]}},cry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C",duration:2.4,emotion:"sad",tracks:{"head.rx":[[0,0],[.3,-0.4],[2.1,-0.4],[2.4,0]],"head.rz":[[0,0],[.6,.08],[.9,-0.08],[1.2,.08],[1.5,-0.08],[2.4,0]],"armR.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armR.ry":[[0,0],[.3,-0.6],[2.1,-0.6],[2.4,0]],"armL.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armL.ry":[[0,0],[.3,.6],[2.1,.6],[2.4,0]]}},bow:{label:"\u041F\u043E\u043A\u043B\u043E\u043D",duration:1.4,tracks:{"body.rx":[[0,0],[.4,-0.7],[1,-0.7],[1.4,0]],"armR.rx":[[0,0],[.4,.5],[1,.5],[1.4,0]]}},shrug:{label:"\u041F\u043E\u0436\u0430\u0442\u044C \u043F\u043B\u0435\u0447\u0430\u043C\u0438",duration:1.2,tracks:{"armL.rz":[[0,0],[.3,-0.5],[.9,-0.5],[1.2,0]],"armR.rz":[[0,0],[.3,.5],[.9,.5],[1.2,0]],"armL.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"armR.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"head.rz":[[0,0],[.3,.25],[.9,.25],[1.2,0]]}},facepalm:{label:"\u0420\u0443\u043A\u0430-\u043B\u0438\u0446\u043E",duration:1.6,emotion:"tired",tracks:{"armR.rx":[[0,0],[.3,2.5],[1.3,2.5],[1.6,0]],"armR.rz":[[0,0],[.3,-0.4],[1.3,-0.4],[1.6,0]],"head.rx":[[0,0],[.3,-0.35],[1.3,-0.35],[1.6,0]]}},sit:{label:"\u0421\u0435\u0441\u0442\u044C",duration:1,loop:true,tracks:{"legL.rx":[[0,Ro*.46],[1,Ro*.46]],"legR.rx":[[0,Ro*.46],[1,Ro*.46]],"root.py":[[0,-10],[1,-10]]}}},$e={...Qn,...ma,...pa},_p=[...Object.keys(Qn),...Object.keys(ma)],Vp=Object.keys(pa),Fp=Object.keys($e);function ha(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call($e,e)}function Bp(e){return ha(e)&&$e[e].seat===true}function Dp(e,t){let r=$e[e];return t?r.label:r.en??e}function ul(e,t){let r=e[0];if(t<=r[0])return r[1];for(let o=1;o<e.length;o++){let a=e[o];if(t<=a[0]){let n=e[o-1],s=(t-n[0])/Math.max(1e-6,a[0]-n[0]),l=s*s*(3-2*s);return n[1]+(a[1]-n[1])*l}}return e[e.length-1][1]}function Zn(e,t,r){let o=t.loop?r%t.duration:Math.min(r,t.duration);for(let[a,n]of Object.entries(t.tracks)){let s=a.lastIndexOf("."),l=a.slice(0,s),i=a.slice(s+1);i in I&&y(e,l,i,ul(n,o));}}var fl=["neutral","happy","sad","angry","surprised","scared","tired","hurt"],At=[...fl,"love","excited","smug","confused","embarrassed","silly","cool","disgusted","determined","crying","dizzy","sleepy","wink"];function bl(e){return typeof e=="string"&&At.includes(e)}var es={neutral:"neutral",happy:"happy",sad:"sad",angry:"angry",surprised:"surprised",scared:"scared",tired:"tired",hurt:"hurt",love:"happy",excited:"happy",smug:"happy",confused:"surprised",embarrassed:"happy",silly:"happy",cool:"neutral",disgusted:"angry",determined:"angry",crying:"sad",dizzy:"hurt",sleepy:"tired",wink:"happy"};var Fr={move:["idle","talk","walk","run","jump","fall","tiptoe","limp","crawl","climb","jog","carry","push","pull"],sit:["sit","sitChair","sitFloor","sitKneel","sitEdge","sitLounge","sitHug","squat","sitEat","sitDrink","sitRead","sitLaptop","sitWrite","sitTalk","sitLaugh","sitCry","sitDoze","sitDrive","sitGamepad","sitClap"],lie:["lieBack","lieSide","lieFront","getUp"],home:["phone","phoneScroll","selfie","photo","drinkCup","eat","read","board","cook","dishes","sweep","water","dig","fish","paint","brushTeeth","washFace","openDoor","knock","checkWatch","wait","pockets","armsCrossed","lean","shiver","fan","sneeze","cough"],social:["wave","point","surprised","dance","hug","handshake","highFive","throw","catch","juggle"]},ts=[...Fr.move,...Fr.sit,...Fr.lie,...Fr.home,...Fr.social];var cr={neutral:["neutral"],happy:["happy","neutral"],sad:["sad","tired","neutral"],angry:["angry","neutral"],surprised:["surprised","scared","neutral"],scared:["scared","surprised","sad","neutral"],tired:["tired","sad","neutral"],hurt:["hurt","angry","sad","neutral"],love:["happy","neutral"],excited:["happy","surprised","neutral"],smug:["happy","neutral"],confused:["surprised","neutral"],embarrassed:["happy","sad","neutral"],silly:["happy","neutral"],cool:["neutral"],disgusted:["angry","sad","neutral"],determined:["angry","neutral"],crying:["sad","tired","neutral"],dizzy:["hurt","tired","neutral"],sleepy:["tired","blink","neutral"],wink:["happy","neutral"]},da={neutral:{add:{},tempo:1},happy:{add:{"head.rx":.08},tempo:1.1},sad:{add:{"head.rx":-0.3,"body.rx":-0.08,"tail.rx":.5},tempo:.8},angry:{add:{"body.rx":-0.12,"head.rx":.1,"armL.rz":-0.1,"armR.rz":.1},tempo:1.1},surprised:{add:{"head.rx":.15,"body.rx":.05},tempo:1},scared:{add:{"body.rx":-0.1,"head.rx":-0.1,"armL.rx":.3,"armR.rx":.3,"tail.rx":.6},tempo:1.3},tired:{add:{"head.rx":-0.35,"body.rx":-0.12},tempo:.7},hurt:{add:{"body.rx":-0.1},tempo:1},love:{add:{"head.rz":.12,"head.rx":.06},tempo:.9},excited:{add:{"head.rx":.12,"body.rx":.04},tempo:1.3},smug:{add:{"head.rx":.14,"head.rz":-0.08},tempo:.9},confused:{add:{"head.rz":.22},tempo:.9},embarrassed:{add:{"head.rx":-0.2,"head.ry":.25,"armL.rx":.15,"armR.rx":.15},tempo:.9},silly:{add:{"head.rz":-0.18},tempo:1.2},cool:{add:{"head.rx":.06,"body.rx":.04},tempo:.85},disgusted:{add:{"head.rx":.1,"head.ry":-0.3,"body.rx":.06},tempo:1},determined:{add:{"body.rx":-0.06,"armL.rz":-0.08,"armR.rz":.08},tempo:1.15},crying:{add:{"head.rx":-0.35,"body.rx":-0.1,"tail.rx":.5},tempo:.75},dizzy:{add:{"head.rz":.15,"body.rz":-0.05},tempo:.8},sleepy:{add:{"head.rx":-0.4,"head.rz":.1,"body.rx":-0.1},tempo:.6},wink:{add:{"head.rz":.1},tempo:1.05}};function rs(e,t,r){if(!(r<=0))for(let[o,a]of Object.entries(da[t].add)){let n=o.lastIndexOf(".");de(e,o.slice(0,n),o.slice(n+1),(a??0)*r);}}var Up={damaged:{emotion:"hurt",seconds:.8},lowHealth:{emotion:"tired"},nearDeath:{emotion:"scared"},achievement:{emotion:"happy",seconds:3},bossKilled:{emotion:"happy",seconds:5},tamed:{emotion:"happy",seconds:3},traded:{emotion:"happy",seconds:2},petDied:{emotion:"sad",seconds:6},explosion:{emotion:"surprised",seconds:1.5}};function Kp(e){let t=[[/(😍|🥰|😘|❤|💕)/u,"love"],[/(🤩|🥳)/u,"excited"],[/(😏)/u,"smug"],[/(😕|🤔|😵‍💫)/u,"confused"],[/(😳|☺)/u,"embarrassed"],[/(😜|😝|😛|:P|:p)/u,"silly"],[/(😎)/u,"cool"],[/(🤢|🤮)/u,"disgusted"],[/(😤|💪)/u,"determined"],[/(😭)/u,"crying"],[/(😵)/u,"dizzy"],[/(😴|💤)/u,"sleepy"],[/(😉|;\))/u,"wink"],[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of t)if(r.test(e))return o;return null}var yl=[{state:"dead",when:e=>e.dead,clip:"dead",blend:.25},{state:"sleep",when:e=>e.sleeping,clip:"sleep",blend:.3},{state:"ride",when:e=>e.riding,clip:"ride",blend:.2},{state:"sit",when:e=>e.sitting,clip:"sit",blend:.3},{state:"swim",when:e=>e.inWater&&!e.onGround&&!e.flying,clip:"swim",blend:.3},{state:"glide",when:e=>e.gliding,clip:"glide",blend:.25},{state:"fly",when:e=>e.flying,clip:"fly",blend:.25},{state:"fall",when:(e,t)=>t.airTime>.35&&e.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:e=>e.sneaking,clip:"sneak",blend:.15},{state:"run",when:e=>e.sprinting&&e.speed>3||e.speed>6.5,clip:"run",blend:.15},{state:"walk",when:e=>e.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],gl=new Set(["idle","walk","run","sneak","sit"]),xl=new Set(["hurt","land","shoot"]),wl={eat:"eat",drink:"drink",draw:"draw",block:"block"},Rl={tail:(e,t)=>[["ry",-e.yawRate*.25+.12*Math.sin(t*2)],["rx",-(.1+Math.min(e.speed,8)*.06)]],cape:(e,t)=>[["rx",-(.05+Math.min(e.speed,8)*.12)-(e.speed>1?.06*Math.sin(t*9):0)-(e.vy<-3?.4:0)]],hair:e=>[["rx",-Math.min(e.speed,8)*.03]],ear:(e,t)=>[["rz",.08*Math.sin(t*1.3)+Math.min(e.speed,6)*.02]],antenna:(e,t)=>[["rx",.1*Math.sin(t*3)-e.vy*.02]],wingL:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?-0.05:-0.7*Math.sin(t*12)]]:[["rz",1.1+.05*Math.sin(t*1.5)]],wingR:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?.05:.7*Math.sin(t*12)]]:[["rz",-1.1-.05*Math.sin(t*1.5)]]},ko=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},vo=class{rig;style;faces;pose=new Map;expression="neutral";state="idle";stateT=0;clock=0;phase=0;airTime=0;wasOnGround=true;loco=new Map;from=new Map;lastLoco=new Map;blendT=1;blendDur=.2;tmp=new Map;upperPose=new Map;upperDef=null;actions=[];useClip=null;useW=0;emote=null;mood="neutral";moodOverGestures=false;flash=null;postureW=new Map;blinkT=3;blinking=0;talkT=0;springs=new Map;constructor(t,r,o=[]){this.rig=t,this.style=sa(r),this.faces=new Set(o);}setRandom(t){this.random=t;}random=Math.random;setStyle(t){this.style=sa(t);}setEmotion(t,r){r&&r>0?this.flash={emotion:t,left:r}:this.mood=t;}get emotion(){return this.emote?.def.emotion&&!this.moodOverGestures?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}get plant(){return gl.has(this.state)&&this.airTime<.12?1:0}get standing(){return this.state==="idle"&&!this.emote&&this.stateT>.2}playEmote(t){this.emote={id:t,def:$e[t],t:0};}stopEmote(){this.emote=null;}trigger(t){switch(t){case "swing":case "place":case "throw":case "shoot":case "punch":case "hurt":case "land":{let r=t;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:Kn[r]??.3}),t==="hurt"&&this.setEmotion("hurt",.8);break}}}update(t,r=lo()){t=Math.min(t,.1),this.clock+=t;let o=this.emotion,a=da[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=t:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*t*3.5*a;let n=yl.find(c=>c.when(r,this));n.state!==this.state&&(Be(this.from,this.lastLoco),this.state=n.state,this.stateT=0,this.blendT=0,this.blendDur=n.blend),this.stateT+=t,bt(this.loco);let s=Un[this.rig]?.[n.clip]??n.clip,l={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*a};if(Or[s](this.loco,l),bt(this.pose),this.blendT<this.blendDur?(this.blendT+=t,hn(this.pose,this.from,this.loco,ko(this.blendT/this.blendDur))):Be(this.pose,this.loco),Be(this.lastLoco,this.pose),this.emote){let c=this.emote;c.t+=t;let p=c.def.layer==="upper";if((p?!(this.state==="idle"||this.state==="walk"||this.state==="run"||this.state==="sneak"):r.speed>1||this.state!=="idle")||!c.def.loop&&c.t>=c.def.duration)this.emote=null;else {let d=c.def.loop?ko(c.t/.15):ko(Math.min(c.t/.15,(c.def.duration-c.t)/.15)),b=p?this.upperPose:this.tmp;p&&this.upperDef!==c.def&&(b.clear(),this.upperDef=c.def),bt(b),Zn(b,c.def,c.t),this.overlay(b,d,false);}}let i=r.use?wl[r.use]:null;i&&(this.useClip=i),this.useW=Math.max(0,Math.min(1,this.useW+(i?t:-t)*8)),this.useClip&&this.useW>0?(bt(this.tmp),Or[this.useClip](this.tmp,{...l,t:this.clock}),this.overlay(this.tmp,ko(this.useW),false)):r.aiming&&(r.held==="pistol"||r.held==="rifle")?(bt(this.tmp),Or[r.held==="rifle"?"aimRifle":"aimPistol"](this.tmp,l),this.overlay(this.tmp,1,false),de(this.pose,"armR","rx",Math.max(-0.8,Math.min(.8,r.lookPitch))),de(this.pose,"armL","rx",Math.max(-0.8,Math.min(.8,r.lookPitch)))):r.held!=="none"&&!this.emote&&de(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let c of this.actions){c.t+=t;let p=Math.min(1,c.t/c.dur);bt(this.tmp),Or[c.clip](this.tmp,{...l,t:c.t,k:p}),this.overlay(this.tmp,1,xl.has(c.clip));}this.actions=this.actions.filter(c=>c.t<c.dur),this.state!=="dead"&&this.state!=="sleep"&&(de(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),de(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=t)<=0&&(this.flash=null);for(let c of At){let p=this.postureW.get(c)??0,h=p+((c===o?1:0)-p)*Math.min(1,t*6);this.postureW.set(c,h),this.state!=="dead"&&rs(this.pose,c,h);}for(let[c,p]of Object.entries(Rl))for(let[h,m]of p(r,this.clock)){let d=c+"."+h,b=this.springs.get(d);b||this.springs.set(d,b={x:m,v:0});let u=60,R=9;b.v+=(u*(m-b.x)-R*b.v)*t,b.x+=b.v*t,de(this.pose,c,h,b.x);}return this.expression=this.face(r,t,o),this.pose}overlay(t,r,o){for(let[a,n]of t){let s=ae(this.pose,a);for(let l=0;l<9;l++)o?l>=I.sx?s[l]=s[l]*(1+(n[l]-1)*r):s[l]=s[l]+(n[l]-sr[l])*r:s[l]=s[l]+(n[l]-s[l])*r;}}face(t,r,o){let a=s=>s.find(l=>this.faces.has(l))??"neutral";if(t.dead||this.state==="dead"||t.sleeping)return a(["blink","hurt","neutral"]);let n=a(cr[o]);return t.viseme!==void 0?(this.talkT=0,t.viseme!=="rest"&&t.viseme!=="MBP"?a(["talk",n]):n):t.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?a(["talk",n]):n):(this.talkT=0,this.blinking>0?(this.blinking-=r,a(["blink",n])):(this.blinkT-=r,this.blinkT<=0&&(this.blinkT=2.5+this.random()*3,o!=="surprised"&&o!=="scared"&&o!=="hurt"&&(this.blinking=.13)),n))}};var je="voxel-v1",Ut=1,Kt=["hair","top","bottom","shoes","hands","waist","back","neck","faceAcc","hat"],ba=["head","torso","sleeveL","sleeveR","forearmL","forearmR","handL","handR","legL","legR","footL","footR"],ya={sleeves:["sleeveL","sleeveR"],forearms:["forearmL","forearmR"],arms:["sleeveL","sleeveR","forearmL","forearmR"],hands:["handL","handR"],legs:["legL","legR"],feet:["footL","footR"]},qt="@skin",ga={hair:{bones:["head"],paint:["head"],paintFaces:["top","back","left","right"],parts:8,box:{min:[-6,22,-6],max:[6,35.5,6]}},hat:{bones:["head"],paint:[],parts:8,box:{min:[-7,21,-8],max:[7,38,7]}},top:{bones:["body","armL","armR","foreArmL","foreArmR"],paint:["torso","sleeveL","sleeveR","forearmL","forearmR"],parts:6,box:{min:[-10,9.5,-6],max:[10,26,6]}},bottom:{bones:["body","legL","legR","shinL","shinR"],paint:["legL","legR"],parts:4,box:{min:[-6.5,.5,-4.5],max:[6.5,17,4.5]}},shoes:{bones:["legL","legR","shinL","shinR"],paint:["footL","footR"],parts:4,box:{min:[-5.5,-0.5,-4.5],max:[5.5,7,4]}},hands:{bones:["armL","armR","foreArmL","foreArmR"],paint:["handL","handR"],parts:2,box:{min:[-10,9.5,-4],max:[10,16,4]}},waist:{bones:["body"],paint:[],parts:4,box:{min:[-7,9.5,-4],max:[7,16.5,4]}},back:{bones:["body"],paint:[],parts:8,box:{min:[-13.5,6,1.5],max:[13.5,36.5,13]}},faceAcc:{bones:["head"],paint:[],parts:8,box:{min:[-6,21,-6.5],max:[6,30.5,5]}},neck:{bones:["body"],paint:[],parts:6,box:{min:[-6,15,-4.5],max:[6,24.5,4.5]}}},Yt={palette:5,textures:4,textureSide:32,texturePixels:2048,id:40,textureId:12,name:40},Dr=["round","sparkle","wide","cat","sleepy","dot","anime","almond","button","narrow","starry","glam"],Nr=["soft","thick","arched","none","straight","angled","bushy","thin"],Hr=["smile","grin","cat","small","smirk","open","teeth","fang","tongue","pout"],jr=["none","freckles","mole","scar","plaster","whiskers","star"],Gr=["block","round"],xa="round",wa=vr,Ra=Ar,ct={walk:"bouncy",idle:"calm"},St=[.5,1.8,7.5,5.4],kl={eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,marks:"none",emotion:"neutral"},Br={min:.9,max:1.1},Et=(e,t,r)=>typeof e=="string"&&t.includes(e)?e:r,fa=e=>typeof e=="string"&&Kt.includes(e);function pr(e){let t=J(e)?e:{},r=J(t.body)?t.body:{},o=J(t.face)?t.face:{},a=J(t.anim)?t.anim:{},n=kl,s={};if(J(t.wear))for(let[i,c]of Object.entries(t.wear))fa(i)&&typeof c=="string"&&c.trim()&&(s[i]=c.trim().slice(0,Yt.id));let l={};if(J(t.tint))for(let[i,c]of Object.entries(t.tint)){let p=ot(c);fa(i)&&p&&(l[i]=p);}return {version:Ut,style:je,body:{skin:ot(r.skin)??"#f2c9a0",height:Math.round(Ie(r.height,1,Br.min,Br.max)*1e3)/1e3,head:Et(r.head,Gr,xa)},face:{eyes:Et(o.eyes,Dr,n.eyes),eyeColor:ot(o.eyeColor)??n.eyeColor,brows:Et(o.brows,Nr,n.brows),browColor:ot(o.browColor)??n.browColor,mouth:Et(o.mouth,Hr,n.mouth),cheeks:typeof o.cheeks=="boolean"?o.cheeks:n.cheeks,marks:Et(o.marks,jr,"none"),emotion:Et(o.emotion,At,n.emotion)},anim:{walk:Et(a.walk,wa,ct.walk),idle:Et(a.idle,Ra,ct.idle)},wear:s,tint:l}}var vl=/^[a-z0-9][a-z0-9_.-]*$/,Al=/^[A-Za-z0-9]+$/;function ua(e){return !Array.isArray(e)||e.length!==3?null:e.every(t=>typeof t=="number"&&Number.isFinite(t))?e:null}function El(e,t){if(!t||t.every(o=>o===0))return [e[0]/2,e[1]/2,e[2]/2];let r=Math.hypot(e[0],e[1],e[2])/2;return [r,r,r]}function mr(e){let t=[],r=(A,k,x)=>t.push(ee({en:A,ru:k},x));if(!J(e))return {ok:false,errors:[ee({en:"the item is not an object",ru:"\u0432\u0435\u0449\u044C: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})]};let o=e,a=Yt;o.style!==void 0&&o.style!==je&&r("style \xAB{s}\xBB is not {need}","\u0441\u0442\u0438\u043B\u044C \xAB{s}\xBB: \u043D\u0435 {need}",{s:String(o.style),need:je});let n=typeof o.id=="string"?o.id.trim():"";if((!n||n.length>a.id||!vl.test(n))&&r("id must be 1, {n} characters: a-z, 0-9, _ . -","id: 1, {n} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432: a-z, 0-9, _ . -",{n:a.id}),!fa(o.slot))return r("unknown slot \xAB{s}\xBB","\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0441\u043B\u043E\u0442 \xAB{s}\xBB",{s:String(o.slot)}),{ok:false,errors:t};let s=o.slot,l=ga[s],i=typeof o.name=="string"&&o.name.trim()?o.name.trim().slice(0,a.name):n,c={};if(!J(o.palette)||!Object.keys(o.palette).length)r("the palette is empty","\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u043F\u0443\u0441\u0442\u0430");else {let A=Object.entries(o.palette);A.length>a.palette&&r("more than {n} colours in the palette","\u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u0446\u0432\u0435\u0442\u043E\u0432",{n:a.palette});for(let[k,x]of A){let f=x===qt?qt:ot(x);k.length!==1||ft.has(k)||!f?r("palette colour \xAB{k}\xBB is not valid","\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F",{k}):c[k]=f;}}let p=typeof o.tint=="string"&&o.tint?o.tint:null;p!==null&&(!c[p]||c[p]===qt)&&r("tint \xAB{k}\xBB is not a colour of the palette","\u043F\u0435\u0440\u0435\u043A\u0440\u0430\u0441\u043A\u0430 \xAB{k}\xBB: \u043D\u0435 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{k:p});let h={},m=0;if(o.textures!==void 0)if(!J(o.textures))r("textures is not an object","textures: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442");else {let A=Object.entries(o.textures);A.length>a.textures&&r("more than {n} textures","\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n}",{n:a.textures});for(let[k,x]of A){if(k.length>a.textureId||!Al.test(k)){r("texture id \xAB{id}\xBB must be 1, {n} letters or digits","id \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB: 1, {n} \u0431\u0443\u043A\u0432 \u0438\u043B\u0438 \u0446\u0438\u0444\u0440",{id:k.slice(0,20),n:a.textureId});continue}let f=J(x)?x:null,S=f&&Array.isArray(f.rows)?f.rows:null,T=f?f.w:void 0,C=f?f.h:void 0;if(!S||typeof T!="number"||typeof C!="number"||!Number.isInteger(T)||!Number.isInteger(C)||T<1||C<1||T>a.textureSide||C>a.textureSide||S.length!==C||S.some(O=>typeof O!="string"||O.length!==T)){r("texture \xAB{id}\xBB must be w\xD7h \u2264 {n} with exactly h rows of w symbols","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB: w\xD7h \u2264 {n}, \u0440\u043E\u0432\u043D\u043E h \u0441\u0442\u0440\u043E\u043A \u043F\u043E w \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",{id:k,n:a.textureSide});continue}S.some(O=>[...O].some(M=>!ft.has(M)&&!c[M]))&&r("texture \xAB{id}\xBB uses symbols outside the palette","\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{id:k}),m+=T*C,h[k]={w:T,h:C,rows:S.map(O=>O.replace(/ /g,"."))};}m>a.texturePixels&&r("textures take {p} pixels, the limit is {n}","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \u0437\u0430\u043D\u0438\u043C\u0430\u044E\u0442 {p} \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439, \u043F\u0440\u0435\u0434\u0435\u043B {n}",{p:m,n:a.texturePixels});}let d=(A,k)=>typeof A!="string"?null:h[A]||c[A]?A:(r("{w}: \xAB{v}\xBB is neither a texture nor a palette colour","{w}: \xAB{v}\xBB: \u043D\u0438 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430, \u043D\u0438 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{w:k,v:A}),null),b=(A,k,x=ut)=>{if(A===void 0)return;if(!J(A)){r("{w}: faces is not an object","{w}: faces: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:k});return}let f={};for(let[S,T]of Object.entries(A)){if(!ut.includes(S)){r("{w}: unknown face \xAB{f}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:k,f:S});continue}if(!x.includes(S)){r("{w}: the {slot} slot may not paint the \xAB{f}\xBB face","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:k,slot:s,f:S});continue}let C=d(T,k);C&&(f[S]=C);}return Object.keys(f).length?f:void 0},u=[];o.paint!==void 0&&!Array.isArray(o.paint)&&r("paint is not a list","paint: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");for(let[A,k]of (Array.isArray(o.paint)?o.paint:[]).entries()){let x=`paint[${A}]`;if(!J(k)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:x});continue}let f=typeof k.region=="string"?k.region:"",S=ya[f]??(ba.includes(f)?[f]:[]);if(!S.length){r("{w}: unknown region \xAB{r}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0431\u043B\u0430\u0441\u0442\u044C \xAB{r}\xBB",{w:x,r:f});continue}let T=S.filter(O=>!l.paint.includes(O));if(T.length){r("{w}: the {slot} slot may not paint \xAB{r}\xBB","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \xAB{r}\xBB",{w:x,slot:s,r:T.join(", ")});continue}let C=typeof k.color=="string"&&c[k.color]?k.color:null;C||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:x});let z=b(k.faces,x,l.paintFaces);if(C)for(let O of S){let M={region:O,color:C};z&&(M.faces={...z}),u.push(M);}}let R=[];o.parts!==void 0&&!Array.isArray(o.parts)&&r("parts is not a list","parts: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");let w=Array.isArray(o.parts)?o.parts:[];w.length>l.parts&&r("the {slot} slot allows {n} boxes, the item has {m}","\u0441\u043B\u043E\u0442\u0443 {slot} \u043C\u043E\u0436\u043D\u043E {n} \u043A\u043E\u0440\u043E\u0431\u043E\u043A, \u0443 \u0432\u0435\u0449\u0438 {m}",{slot:s,n:l.parts,m:w.length});for(let[A,k]of w.entries()){let x=`parts[${A}]`;if(!J(k)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:x});continue}let f=typeof k.bone=="string"?k.bone:"";if(!l.bones.includes(f)){r("{w}: the {slot} slot puts boxes only on {b}","{w}: \u0441\u043B\u043E\u0442 {slot} \u0441\u0442\u0430\u0432\u0438\u0442 \u043A\u043E\u0440\u043E\u0431\u043A\u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 {b}",{w:x,slot:s,b:l.bones.join(", ")});continue}let S=ua(k.size),T=ua(k.pos);if(!S||!T||S.some(ie=>ie<=0)){r("{w}: size and pos must be [x, y, z]","{w}: size \u0438 pos: [x, y, z]",{w:x});continue}let C=k.rot===void 0?void 0:ua(k.rot);k.rot!==void 0&&!C&&r("{w}: rot must be [x, y, z]","{w}: rot: [x, y, z]",{w:x});let z=k.mirror===true,O=El(S,C??void 0),V=(z?[T[0],-T[0]]:[T[0]]).some(ie=>ie-O[0]<l.box.min[0]-1e-6||ie+O[0]>l.box.max[0]+1e-6)||[1,2].some(ie=>T[ie]-O[ie]<l.box.min[ie]-1e-6||T[ie]+O[ie]>l.box.max[ie]+1e-6);V&&r("{w}: the box leaves the {slot} slot frame","{w}: \u043A\u043E\u0440\u043E\u0431\u043A\u0430 \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043C\u043A\u0443 \u0441\u043B\u043E\u0442\u0430 {slot}",{w:x,slot:s});let q=typeof k.color=="string"&&c[k.color]?k.color:null;q||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:x});let Y=b(k.faces,x),pe;if(k.mat!==void 0&&(typeof k.mat=="string"&&tr.includes(k.mat)?pe=k.mat:r("{w}: material \xAB{m}\xBB is not {list}","{w}: \u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B \xAB{m}\xBB: \u043D\u0435 {list}",{w:x,m:String(k.mat),list:tr.join(", ")})),!q||V)continue;let me={bone:f,size:[...S],pos:[...T],color:q};Y&&(me.faces=Y),C&&C.some(ie=>ie!==0)&&(me.rot=[...C]),z&&(me.mirror=true),typeof k.name=="string"&&k.name.trim()&&(me.name=k.name.trim().slice(0,24)),pe&&(me.mat=pe),R.push(me);}return !w.length&&!(Array.isArray(o.paint)&&o.paint.length)&&r("the item neither paints nor adds anything","\u0432\u0435\u0449\u044C \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0438 \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442"),t.length?{ok:false,errors:t}:{ok:true,item:{version:Ut,style:je,id:n,slot:s,name:i,palette:c,tint:p,textures:h,paint:u,parts:R}}}var _e="#2b2140",et="#7a2e2e",Wt="#e8707a",Sl={neutral:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:0,tear:false},happy:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false},sad:{eye:"open",iris:1,white:1,lidOuter:.38,lidInner:.12,browUp:0,browInner:.09,tear:true},angry:{eye:"open",iris:.9,white:.95,lidOuter:.1,lidInner:.42,browUp:-0.02,browInner:-0.1,tear:false},surprised:{eye:"open",iris:.55,white:1.15,lidOuter:0,lidInner:0,browUp:.1,browInner:0,tear:false},scared:{eye:"open",iris:.42,white:1.08,lidOuter:0,lidInner:0,browUp:.08,browInner:.07,tear:false},tired:{eye:"open",iris:1,white:1,lidOuter:.5,lidInner:.5,browUp:-0.02,browInner:-0.02,tear:false},hurt:{eye:"hurt",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:-0.07,tear:false},love:{eye:"heart",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.05,browInner:.03,tear:false,blush:.6},excited:{eye:"star",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.09,browInner:0,tear:false},smug:{eye:"open",iris:.95,white:1,lidOuter:.42,lidInner:.36,browUp:0,browInner:-0.03,tear:false,look:.25,browTilt:.06},confused:{eye:"open",iris:.8,white:1.05,lidOuter:0,lidInner:0,browUp:.03,browInner:.04,tear:false,browTilt:.1,sweat:true},embarrassed:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.02,browInner:.08,tear:false,blush:1,sweat:true},silly:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.06,browInner:0,tear:false,wink:true},cool:{eye:"open",iris:.9,white:1,lidOuter:.38,lidInner:.38,browUp:-0.01,browInner:-0.02,tear:false},disgusted:{eye:"open",iris:.85,white:.95,lidOuter:.3,lidInner:.45,browUp:-0.02,browInner:-0.08,tear:false,look:-0.3},determined:{eye:"open",iris:1,white:1,lidOuter:.15,lidInner:.34,browUp:-0.01,browInner:-0.12,tear:false},crying:{eye:"closed",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.02,browInner:.12,tear:false,stream:true},dizzy:{eye:"spiral",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:.05,tear:false},sleepy:{eye:"closed",iris:1,white:1,lidOuter:0,lidInner:0,browUp:-0.02,browInner:0,tear:false,zzz:true},wink:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false,wink:true}};function ka(e,t,r,o,a,n="neutral"){let s=a==="blink"||a==="talk"?n==="blink"||n==="talk"?"neutral":n:a,l=Sl[s];e.clearRect(0,0,t,r),e.lineCap="round",e.lineJoin="round";let i=r*.5,c=t*.105,p=r*.2,h=a==="blink"?"closed":l.eye;if(o.cheeks&&s!=="scared"&&(e.fillStyle=s==="happy"?"rgba(236,110,140,0.5)":"rgba(236,120,140,0.32)",j(e,t*.12,r*.8,t*.07,r*.075),e.fill(),j(e,t*.88,r*.8,t*.07,r*.075),e.fill()),l.blush){e.fillStyle=`rgba(236,90,120,${.35*l.blush})`,j(e,t*.13,r*.8,t*.085,r*.09),e.fill(),j(e,t*.87,r*.8,t*.085,r*.09),e.fill(),e.strokeStyle=`rgba(200,60,90,${.7*l.blush})`,e.lineWidth=t*.008;for(let m of [t*.13,t*.87])for(let d=-1;d<=1;d++)e.beginPath(),e.moveTo(m+d*t*.025-t*.01,r*.84),e.lineTo(m+d*t*.025+t*.01,r*.76),e.stroke();}Tl(e,t,r,o);for(let m of [-1,1]){let d=t*(.5+m*.22),b=l.wink&&m===1&&h!=="closed"?"happy":h;Ll(e,d,i,c,p,m,o,b,l);let u=(l.browTilt??0)*(m===1?1:-0.4);Cl(e,d,i-p-r*.07-r*u,t,r,m,o,l);}if(l.stream&&a!=="blink"){e.fillStyle="rgba(133,183,235,0.85)";for(let m of [-1,1]){let d=t*(.5+m*.22);e.beginPath(),e.moveTo(d-t*.03,i+p*.35),e.quadraticCurveTo(d-t*.045,r*.8,d-t*.025,r),e.lineTo(d+t*.025,r),e.quadraticCurveTo(d+t*.04,r*.8,d+t*.03,i+p*.35),e.closePath(),e.fill();}}if(l.sweat){e.fillStyle="#9fd3f5";let m=t*.95,d=r*.2;e.beginPath(),e.moveTo(m,d-r*.09),e.quadraticCurveTo(m+t*.035,d+r*.02,m,d+r*.05),e.quadraticCurveTo(m-t*.035,d+r*.02,m,d-r*.09),e.fill();}if(l.zzz){e.strokeStyle=_e,e.lineWidth=t*.012;let m=(d,b,u)=>{e.beginPath(),e.moveTo(d,b),e.lineTo(d+u,b),e.lineTo(d,b+u),e.lineTo(d+u,b+u),e.stroke();};m(t*.8,r*.12,t*.05),m(t*.88,r*.02,t*.035);}if(l.tear&&h==="open"){e.fillStyle="#85b7eb";let m=t*.5-t*.22-c*.6,d=i+p*1.05;e.beginPath(),e.moveTo(m,d-r*.07),e.quadraticCurveTo(m+t*.03,d,m,d+r*.04),e.quadraticCurveTo(m-t*.03,d,m,d-r*.07),e.fill();}Pl(e,t*.5,r*.86,t,r,o,a==="talk"?"talk":s);}function Tl(e,t,r,o){let a=o.marks;if(!(!a||a==="none"))switch(a){case "freckles":{e.fillStyle="rgba(150,90,50,0.55)";let n=[[.08,.7],[.13,.66],[.18,.71],[.11,.76],[.16,.78],[.92,.7],[.87,.66],[.82,.71],[.89,.76],[.84,.78]];for(let[s,l]of n)j(e,t*s,r*l,t*.009,t*.009),e.fill();return}case "mole":e.fillStyle="#4a2e22",j(e,t*.64,r*.82,t*.011,t*.011),e.fill();return;case "scar":{e.strokeStyle="rgba(150,60,60,0.75)",e.lineWidth=t*.012,e.beginPath(),e.moveTo(t*.2,r*.12),e.lineTo(t*.32,r*.78),e.stroke(),e.lineWidth=t*.007;for(let n=1;n<=4;n++){let s=n/5,l=t*(.2+.12*s),i=r*(.12+.66*s);e.beginPath(),e.moveTo(l-t*.025,i+r*.005),e.lineTo(l+t*.025,i-r*.005),e.stroke();}return}case "plaster":{e.save(),e.translate(t*.84,r*.74),e.rotate(-0.5),e.fillStyle="#f1d3a8",e.fillRect(-t*.07,-r*.04,t*.14,r*.08),e.fillStyle="#e3b98a",e.fillRect(-t*.025,-r*.04,t*.05,r*.08),e.restore();return}case "whiskers":{e.strokeStyle=_e,e.lineWidth=t*.008;for(let n of [-1,1])for(let s of [-0.04,0,.04])e.beginPath(),e.moveTo(t*(.5+n*.24),r*(.78+s)),e.lineTo(t*(.5+n*.42),r*(.75+s*1.8)),e.stroke();return}case "star":Ao(e,t*.84,r*.74,t*.045),e.fillStyle="#f2c14e",e.fill();return}}function Ml(e,t,r,o){e.beginPath(),e.moveTo(t,r+o*.9),e.bezierCurveTo(t-o*1.4,r-o*.1,t-o*.7,r-o*1.1,t,r-o*.4),e.bezierCurveTo(t+o*.7,r-o*1.1,t+o*1.4,r-o*.1,t,r+o*.9),e.closePath();}function j(e,t,r,o,a){e.beginPath(),e.ellipse(t,r,Math.max(.1,o),Math.max(.1,a),0,0,Math.PI*2);}function Ll(e,t,r,o,a,n,s,l,i){let c=o*.26;if(e.strokeStyle=_e,e.lineWidth=c,l==="closed"){e.beginPath(),e.moveTo(t-o,r+a*.1),e.quadraticCurveTo(t,r+a*.55,t+o,r+a*.1),e.stroke(),s.eyes==="wide"&&os(e,t,r+a*.15,o,a*.3,n,c);return}if(l==="happy"){e.lineWidth=c*1.2,e.beginPath(),e.moveTo(t-o,r+a*.35),e.quadraticCurveTo(t,r-a*.75,t+o,r+a*.35),e.stroke();return}if(l==="heart"){Ml(e,t,r,o*1.05),e.fillStyle="#e8436b",e.fill(),e.fillStyle="rgba(255,255,255,0.8)",j(e,t-o*.38,r-a*.25,o*.2,o*.16),e.fill();return}if(l==="star"){Ao(e,t,r,Math.min(o,a)*1.15),e.fillStyle="#f2c14e",e.fill(),e.lineWidth=c*.6,e.stroke();return}if(l==="spiral"){e.lineWidth=c*.9,e.beginPath();for(let O=0;O<=36;O++){let M=O/36*Math.PI*4*n,V=O/36*Math.min(o,a)*.95,q=t+Math.cos(M)*V,Y=r+Math.sin(M)*V;O?e.lineTo(q,Y):e.moveTo(q,Y);}e.stroke();return}if(l==="hurt"){let O=t-n*o*.6,M=t+n*o*.8;e.lineWidth=c*1.2,e.beginPath(),e.moveTo(M,r-a*.55),e.lineTo(O,r),e.lineTo(M,r+a*.55),e.stroke();return}let p=s.eyes==="anime"?1.12:s.eyes==="narrow"?1.15:1,h=s.eyes==="anime"?1.25:s.eyes==="narrow"?.55:1,m=o*i.white*p,d=a*i.white*h,b=s.eyes==="sleepy"?.32:0,u=Math.max(i.lidOuter,b),R=Math.max(i.lidInner,b),w=r-d,A=t+n*(m+c),k=t-n*(m+c),x=w+2*d*u,f=w+2*d*R,S=u>0||R>0;e.save(),S&&(e.beginPath(),e.moveTo(A,x),e.lineTo(k,f),e.lineTo(k,r+d*2),e.lineTo(A,r+d*2),e.closePath(),e.clip());let T=Math.min(m,d)*.8*i.iris*(s.eyes==="narrow"?1.5:1),C=r+d*.12,z=(i.look??0)*m*.45;switch(s.eyes){case "button":{e.fillStyle=_e,j(e,t+z,r+d*.05,m*.72,d*.8),e.fill(),e.fillStyle="#ffffff",j(e,t+z-m*.28,r-d*.25,m*.2,m*.2),e.fill(),j(e,t+z+m*.25,r+d*.3,m*.09,m*.09),e.fill();break}case "almond":{e.fillStyle="#ffffff",hr(e,t,r,m*1.05,d*.8,n),e.fill(),e.save(),hr(e,t,r,m*1.05,d*.8,n),e.clip(),e.fillStyle=s.eyeColor,j(e,t+z,C,T*1.05,T*1.05),e.fill(),e.fillStyle=_e,j(e,t+z,C,T*.5,T*.5),e.fill(),e.fillStyle="#ffffff",j(e,t+z-T*.38,C-T*.4,T*.28,T*.28),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=c*1.1,hr(e,t,r,m*1.05,d*.8,n),e.stroke();break}case "anime":case "starry":case "glam":case "narrow":{e.fillStyle="#ffffff",j(e,t,r,m,d),e.fill(),e.save(),j(e,t,r,m,d),e.clip();let O=s.eyes==="anime"?1.3:s.eyes==="narrow"?1:1.12,M=T*O,V=t+z;e.fillStyle=s.eyeColor,j(e,V,C,M*.95,M*(s.eyes==="anime"?1.25:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.22)",j(e,V,C+M*.5,M*.7,M*.45),e.fill(),s.eyes==="starry"?(Ao(e,V,C,M*.62),e.fillStyle="#fff3b0",e.fill()):(e.fillStyle=_e,j(e,V,C,M*.46,M*(s.eyes==="anime"?.62:.5)),e.fill()),e.fillStyle="#ffffff",j(e,V-M*.38,C-M*.45,M*(s.eyes==="anime"?.38:.3),M*.3),e.fill(),j(e,V+M*.4,C+M*.4,M*.16,M*.16),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=s.eyes==="anime"||s.eyes==="glam"?c*1.6:c,e.beginPath(),e.ellipse(t,r,m,d,0,Math.PI*1.05,Math.PI*1.95),e.stroke(),s.eyes==="glam"&&(e.beginPath(),e.moveTo(t+n*m*.85,r-d*.45),e.lineTo(t+n*m*1.45,r-d*.95),e.stroke());break}case "dot":{e.fillStyle=_e,j(e,t+z,r+d*.1,m*.55,d*.72),e.fill(),e.fillStyle="#ffffff",j(e,t+z-m*.18,r-d*.18,m*.17,m*.17),e.fill();break}case "cat":{e.fillStyle="#ffffff",hr(e,t,r,m*1.08,d*.85,n),e.fill(),e.save(),hr(e,t,r,m*1.08,d*.85,n),e.clip(),e.fillStyle=s.eyeColor,j(e,t,C,T*1.05,T*1.2),e.fill(),e.fillStyle=_e,j(e,t,C,T*.22*(i.iris<1?1.5:1),T*.95),e.fill(),e.fillStyle="#ffffff",j(e,t-T*.4,C-T*.45,T*.25,T*.25),e.fill(),e.restore(),e.strokeStyle=_e,e.lineWidth=c,hr(e,t,r,m*1.08,d*.85,n),e.stroke();break}default:{let O=s.eyes==="sparkle"||s.eyes==="wide";e.fillStyle="#ffffff",j(e,t,r,m,d),e.fill(),e.save(),j(e,t,r,m,d),e.clip();let M=O?T*1.18:T;e.fillStyle=s.eyeColor,j(e,t+z,C,M*.95,M*(s.eyes==="sparkle"?1.15:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.18)",j(e,t+z,C+M*.45,M*.7,M*.45),e.fill(),e.fillStyle=_e,j(e,t+z,C,M*.48,M*.52),e.fill(),e.fillStyle="#ffffff",j(e,t+z-M*.38,C-M*.42,M*.32,M*.32),e.fill(),j(e,t+z+M*.38,C+M*.38,M*.14,M*.14),e.fill(),s.eyes==="sparkle"&&(Ao(e,t+z+M*.3,C-M*.55,M*.22),e.fill()),e.restore(),e.strokeStyle=_e,e.lineWidth=c,e.beginPath(),e.ellipse(t,r,m,d,0,Math.PI*1.08,Math.PI*1.92),e.stroke();break}}if(e.restore(),S){e.strokeStyle=_e,e.lineWidth=c;let O=Y=>(Y-A)/(k-A),M=Y=>x+(f-x)*O(Y),V=t-m*.95,q=t+m*.95;e.beginPath(),e.moveTo(V,M(V)),e.lineTo(q,M(q)),e.stroke();}(s.eyes==="wide"||s.eyes==="glam")&&os(e,t,r-d*.55,m,d*.45,n,c);}function hr(e,t,r,o,a,n){let s=t+n*o,l=t-n*o;e.beginPath(),e.moveTo(l,r+a*.15),e.quadraticCurveTo(t,r-a*1.5,s,r-a*.35),e.quadraticCurveTo(t,r+a*1.4,l,r+a*.15),e.closePath();}function os(e,t,r,o,a,n,s){e.lineWidth=s*.8;let l=t+n*o;for(let i=0;i<2;i++){let c=r+i*a*.6;e.beginPath(),e.moveTo(l-n*o*.1,c),e.lineTo(l+n*o*.35,c-a*(.7-i*.2)),e.stroke();}}function Ao(e,t,r,o){e.beginPath();for(let a=0;a<8;a++){let n=a%2?o*.35:o,s=a*Math.PI/4-Math.PI/2,l=t+Math.cos(s)*n,i=r+Math.sin(s)*n;a?e.lineTo(l,i):e.moveTo(l,i);}e.closePath(),e.fillStyle="#ffffff";}function Cl(e,t,r,o,a,n,s,l){if(s.brows==="none")return;let i=o*.095,c=r-a*l.browUp,p=t-n*i,h=t+n*i,m=c-a*l.browInner,d=c+a*l.browInner*.3;if(e.strokeStyle=s.browColor,e.fillStyle=s.browColor,s.brows==="bushy"){let u=a*.085;e.beginPath(),e.moveTo(h+n*o*.01,d+u*.2),e.quadraticCurveTo(t,Math.min(d,m)-u*.9,p,m-u*.1),e.lineTo(p,m+u*.8);for(let R=1;R<=4;R++){let w=p+(h-p)*R/4;e.lineTo(w-n*o*.01,m+(d-m)*(R/4)+u*(R%2?.5:.85));}e.closePath(),e.fill();return}if(s.brows==="straight"||s.brows==="thin"){e.lineWidth=o*(s.brows==="thin"?.014:.03),e.beginPath(),e.moveTo(h,d),e.lineTo(p,m),e.stroke();return}if(s.brows==="angled"){e.lineWidth=o*.028;let u=t+n*i*.3;e.beginPath(),e.moveTo(p,m),e.lineTo(u,Math.min(d,m)-a*.06),e.lineTo(h,d+a*.02),e.stroke();return}if(s.brows==="thick"){let u=a*.06;e.beginPath(),e.moveTo(h,d),e.quadraticCurveTo(t,Math.min(d,m)-u*.6,p,m),e.lineTo(p,m+u),e.quadraticCurveTo(t,Math.min(d,m)+u*.5,h,d+u*.6),e.closePath(),e.fill();return}e.lineWidth=o*(s.brows==="arched"?.026:.032),e.beginPath(),e.moveTo(h,d);let b=s.brows==="arched"?a*.09:a*.035;e.quadraticCurveTo(t+n*i*.2,Math.min(d,m)-b,p,m),e.stroke();}function Pl(e,t,r,o,a,n,s){let l=o*.026;e.strokeStyle=et,e.lineWidth=l;let i=o*(n.mouth==="small"||n.mouth==="pout"?.06:n.mouth==="grin"?.12:.09),c=(p,h=4)=>{e.beginPath();for(let m=0;m<=h;m++){let d=t-i+2*i*m/h,b=r+(m%2?-1:1)*a*p;m?e.lineTo(d,b):e.moveTo(d,b);}e.stroke();};switch(s){case "love":case "wink":case "embarrassed":if(s==="embarrassed"){c(.025,4);return}e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r+a*.09,t+i,r-a*.04),e.stroke();return;case "excited":case "silly":{let p=Math.max(i,o*.11);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r-a*.07),e.quadraticCurveTo(t,r-a*.03,t+p,r-a*.07),e.quadraticCurveTo(t,r+a*.22,t-p,r-a*.07),e.closePath(),e.fill(),s==="silly"?(e.fillStyle=Wt,j(e,t+p*.25,r+a*.11,p*.4,a*.08),e.fill(),e.strokeStyle="#c4505c",e.lineWidth=l*.5,e.beginPath(),e.moveTo(t+p*.25,r+a*.06),e.lineTo(t+p*.25,r+a*.14),e.stroke()):(e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.12,p*.55,a*.06),e.fill(),e.restore());return}case "smug":case "cool":e.beginPath(),e.moveTo(t-i,r+a*.01),e.quadraticCurveTo(t+i*.3,r+a*.03,t+i*1.05,r-a*.06),e.stroke();return;case "confused":case "dizzy":c(s==="dizzy"?.035:.02,s==="dizzy"?6:4);return;case "disgusted":{e.beginPath(),e.moveTo(t-i,r+a*.05),e.lineTo(t-i*.3,r-a*.02),e.lineTo(t+i*.4,r+a*.03),e.lineTo(t+i,r-a*.01),e.stroke(),e.fillStyle=Wt,j(e,t-i*.1,r+a*.045,i*.3,a*.03),e.fill();return}case "determined":{e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.035,i*2,a*.07),e.strokeStyle=et,e.lineWidth=l*.7,e.strokeRect(t-i,r-a*.035,i*2,a*.07),e.beginPath(),e.moveTo(t-i,r),e.lineTo(t+i,r),e.stroke();return}case "crying":{let p=Math.max(i,o*.1);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r+a*.09),e.quadraticCurveTo(t,r-a*.14,t+p,r+a*.09),e.closePath(),e.fill();return}case "sleepy":e.fillStyle=et,j(e,t,r+a*.01,o*.025,a*.035),e.fill();return;case "happy":{let p=Math.max(i,o*.1);e.fillStyle=et,e.beginPath(),e.moveTo(t-p,r-a*.06),e.quadraticCurveTo(t,r-a*.02,t+p,r-a*.06),e.quadraticCurveTo(t,r+a*.2,t-p,r-a*.06),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.1,p*.55,a*.06),e.fill(),n.mouth==="grin"&&(e.fillStyle="#ffffff",e.fillRect(t-p,r-a*.08,p*2,a*.045)),e.restore();return}case "surprised":e.fillStyle=et,j(e,t,r,o*.045,a*.085),e.fill();return;case "talk":e.fillStyle=et,j(e,t,r,Math.max(i*.7,o*.06),a*.07),e.fill(),e.save(),e.clip(),e.fillStyle=Wt,j(e,t,r+a*.06,o*.045,a*.035),e.fill(),e.restore();return;case "sad":e.beginPath(),e.moveTo(t-i,r+a*.04),e.quadraticCurveTo(t,r-a*.07,t+i,r+a*.04),e.stroke();return;case "angry":e.beginPath(),e.moveTo(t-i,r+a*.01),e.quadraticCurveTo(t,r-a*.03,t+i,r+a*.01),e.stroke();return;case "scared":{e.beginPath();let p=4;for(let h=0;h<=p;h++){let m=t-i+2*i*h/p,d=r+(h%2?-1:1)*a*.022;h?e.lineTo(m,d):e.moveTo(m,d);}e.stroke();return}case "tired":e.beginPath(),e.moveTo(t-i*.6,r),e.lineTo(t+i*.6,r),e.stroke();return;case "hurt":{e.beginPath();let p=4;for(let h=0;h<=p;h++){let m=t-i+2*i*h/p,d=r+(h%2?-1:1)*a*.04;h?e.lineTo(m,d):e.moveTo(m,d);}e.stroke();return}}if(n.mouth==="smirk"){e.beginPath(),e.moveTo(t-i,r),e.quadraticCurveTo(t+i*.3,r+a*.03,t+i,r-a*.06),e.stroke();return}if(n.mouth==="pout"){e.lineWidth=l*.9,e.beginPath(),e.moveTo(t-i*.15,r-a*.05),e.quadraticCurveTo(t+i*.9,r-a*.03,t-i*.05,r),e.quadraticCurveTo(t+i*.9,r+a*.03,t-i*.15,r+a*.05),e.stroke();return}if(n.mouth==="open"||n.mouth==="teeth"||n.mouth==="fang"||n.mouth==="tongue"){e.fillStyle=et,e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r-a*.02,t+i,r-a*.04),e.quadraticCurveTo(t,r+a*.13,t-i,r-a*.04),e.closePath(),e.fill(),e.save(),e.clip(),n.mouth==="teeth"?(e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.06,i*2,a*.045)):n.mouth!=="fang"&&(e.fillStyle=Wt,j(e,t,r+a*.07,i*.55,a*.05),e.fill()),e.restore(),n.mouth==="fang"&&(e.fillStyle="#ffffff",e.beginPath(),e.moveTo(t+i*.35,r-a*.035),e.lineTo(t+i*.6,r-a*.035),e.lineTo(t+i*.47,r+a*.03),e.closePath(),e.fill()),n.mouth==="tongue"&&(e.fillStyle=Wt,j(e,t+i*.3,r+a*.07,i*.32,a*.05),e.fill());return}if(n.mouth==="cat"){e.beginPath(),e.moveTo(t-i,r-a*.03),e.quadraticCurveTo(t-i*.5,r+a*.06,t,r-a*.01),e.quadraticCurveTo(t+i*.5,r+a*.06,t+i,r-a*.03),e.stroke();return}if(n.mouth==="grin"){e.fillStyle=et,e.beginPath(),e.moveTo(t-i,r-a*.04),e.quadraticCurveTo(t,r-a*.01,t+i,r-a*.04),e.quadraticCurveTo(t,r+a*.12,t-i,r-a*.04),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle="#ffffff",e.fillRect(t-i,r-a*.06,i*2,a*.04),e.restore();return}e.beginPath(),e.moveTo(t-i,r-a*.03),e.quadraticCurveTo(t,r+a*.06,t+i,r-a*.03),e.stroke();}var as=16;function zl(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}var dr=class{texture;g;w;h;face;current="neutral";base="neutral";constructor(t,r=St){this.face=t,this.w=Math.round(r[2]*as),this.h=Math.round(r[3]*as);let o=zl(this.w,this.h),a=o.getContext("2d");if(!a)throw new Error("DrawnFace: no 2D canvas");this.g=a,this.texture=new D__namespace.CanvasTexture(o),this.texture.colorSpace=D__namespace.SRGBColorSpace,this.texture.anisotropy=4,this.paint("neutral");}paint(t,r){let o=r&&t!=="blink"&&t!=="talk"&&cr[r].includes(t)?r:t;o!=="blink"&&o!=="talk"?this.base=o:r&&(this.base=r),this.current=o,ka(this.g,this.w,this.h,this.face,o,this.base),this.texture.needsUpdate=true;}setFace(t){this.face=t,ka(this.g,this.w,this.h,this.face,this.current,this.base),this.texture.needsUpdate=true;}dispose(){this.texture.dispose();}};var Il={idle:{},talk:{},walk:{speed:1.6},run:{speed:5.2},surprised:{emote:"shrug"},point:{emote:"point"},sit:{sitting:true},wave:{emote:"wave"},jump:{air:true},fall:{emote:"facepalm"},dance:{emote:"dance"},carry:{speed:1.4,emote:"carry"},jog:{speed:3.4}},Ol=Object.fromEntries(ts.map(e=>[e,Il[e]??(ha(e)?{emote:e}:{})])),_l={handR:"handR",handL:"handL",head:"headTop"},So=class{view;animator;input=lo();seed;ownFace;drawn=null;pose="idle";jumpT=-1;constructor(t,r={}){this.ownFace=!r.facePainter,this.ownFace&&(this.drawn=ns(t)),this.view=new go(t,{shadows:false,gloss:!!t?.face?.drawn,...r,facePainter:r.facePainter??this.drawn}),this.seed=r.seed??1,this.animator=this.newAnimator();}get group(){return this.view.group}get height(){return this.view.height}setSpec(t){let r=this.view.hash;if(this.view.setSpec(t),this.view.hash!==r&&(this.animator=this.newAnimator(),this.ownFace)){let o=this.drawn;this.drawn=ns(t),this.view.setFacePainter(this.drawn),o?.dispose();}}setEmotion(t){this.animator.setEmotion(t);}setViseme(t){this.input.viseme=t;}setPose(t){if(t===this.pose)return;this.pose=t;let r=Ol[t];if(this.input.speed=r.speed??0,this.input.sitting=!!r.sitting,r.emote)this.animator.playEmote(r.emote);else {let o=this.animator.emoting;o&&"loop"in $e[o]&&$e[o].loop&&this.animator.stopEmote();}r.air&&(this.jumpT=0,this.animator.trigger("jump"));}playEmote(t){this.animator.playEmote(t);}stopEmote(){this.animator.stopEmote();}trigger(t){if(t==="jump"){this.jumpT=0,this.animator.trigger("jump");return}this.animator.trigger(t);}setGround(t){this.view.setGround(t);}lookAt(t){this.view.lookAt(t);}reach(t,r){this.view.reach(t,r);}seat(t){this.view.seat(t);}fall(t){return this.view.fall(t)}hit(t,r){return this.view.hit(t,r??null)}getUp(){this.view.getUp();}stopRagdoll(){this.view.stopRagdoll();}takeRagdollDrift(){return this.view.takeRagdollDrift()}get ragdollDrift(){return this.view.ragdollDrift}get ragdoll(){return this.view.ragdollState}setColliders(t){this.view.setColliders(t);}attach(t,r){this.view.attach(_l[t],r);}update(t){let r=this.input;this.jumpT>=0&&(this.jumpT+=t,r.onGround=this.jumpT>.6,r.vy=this.jumpT<.3?4:-4,r.onGround&&(this.jumpT=-1,r.vy=0,this.animator.trigger("land")));let o=this.animator.update(t,r);this.view.applyPose(o,{dt:t,plant:this.animator.plant,standing:this.animator.standing}),this.view.setExpression(this.animator.expression,this.animator.emotion);}dispose(){this.view.dispose(),this.drawn?.dispose();}newAnimator(){let t=this.view.spec,r=new vo(t.rig,t.style,this.view.expressions);return r.setRandom(to(this.seed)),r}};function ns(e){let t=e?.face?.drawn;if(!t)return null;try{let{face:r}=pr({face:{...t,brows:t.brows,browColor:"#2a1c14"}});return new dr({...r,emotion:"neutral"},e.face.rect)}catch{return null}}var Vl=wr.map(e=>{let t=Ae[e],r=t.bones.map(a=>`${a.name}@[${a.pivot.join(",")}]`).join(" "),o=t.defaultParts.map(a=>`${a.bone} ${a.size.join("x")} at [${a.pos.join(",")}]`).join("; ");return `- "${e}" \u2014 ${t.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
25
+ `),xm=`You design blocky voxel characters for a Minecraft-like game. Reply with ONE JSON object \u2014 a CharacterSpec \u2014 and nothing else: no markdown, no comments, no explanations.
26
26
 
27
27
  The game builds and animates the character from your recipe. You give the SHAPE (boxes on a skeleton), the COLOURS (a palette) and small PIXEL-ART pictures for faces and clothes. Animations (walk, run, sneak, swim, fly, emotes, emotions) come from the skeleton \u2014 you never animate.
28
28
 
29
29
  COORDINATES are in model PIXELS (16 px = 1 block): x to the character's RIGHT hand, y UP (y = 0 is the soles of the feet), z BACKWARDS \u2014 the character LOOKS TOWARD -z (its face is on the -z side). A normal person is 32 px tall.
30
30
 
31
31
  SKELETONS ("rig"):
32
- ${_l}
32
+ ${Vl}
33
33
 
34
34
  CharacterSpec:
35
35
  {
36
36
  "version": 1,
37
37
  "name": string (<= 40 chars, in the player's language),
38
38
  "description": string (<= 200 chars),
39
- "rig": ${gr.map(e=>`"${e}"`).join(" | ")},
39
+ "rig": ${wr.map(e=>`"${e}"`).join(" | ")},
40
40
  "scale": 0.25..3 (overall size; 1 = normal),
41
41
  "palette": { "<one character>": "#rrggbb", ... } (<= 32 colours; "." and " " are transparent),
42
42
  "textures": { "<id>": { "w": 1..32, "h": 1..32, "rows": [ "<w palette characters>", ... h rows, top row first ] } },
@@ -48,11 +48,11 @@ CharacterSpec:
48
48
  "mirror": true (also adds the mirrored copy on the paired bone: armL -> armR, legFL -> legFR),
49
49
  "name": string } ],
50
50
  "bones": [ <= 16 EXTRA bones for tails, ears, wings, capes, hair, antennas:
51
- { "name": string, "parent": "<bone>", "pivot": [x, y, z], "role": ${eo.map(e=>`"${e}"`).join(" | ")} } ]
51
+ { "name": string, "parent": "<bone>", "pivot": [x, y, z], "role": ${ro.map(e=>`"${e}"`).join(" | ")} } ]
52
52
  (a role makes the bone move by itself: a tail sways, ears twitch, a cape flutters when running, wings flap in flight; "static" \u2014 no motion),
53
53
  "face": { "bone": "head", "rect": [x, y, w, h] (where the face sits on the FRONT face of the head box, px from its top-left corner as seen by a viewer),
54
- "expressions": { ${wr.map(e=>`"${e}"`).join(", ")}: "<texture id of size w x h>" } } \u2014 eyes and mouth, drawn over the head; "neutral" is required, draw as many others as you can (at least blink, happy, sad, angry, surprised),
55
- "style": { "walk": ${Rr.map(e=>`"${e}"`).join(" | ")}, "idle": ${kr.map(e=>`"${e}"`).join(" | ")}, "energy": 0..1 },
54
+ "expressions": { ${kr.map(e=>`"${e}"`).join(", ")}: "<texture id of size w x h>" } } \u2014 eyes and mouth, drawn over the head; "neutral" is required, draw as many others as you can (at least blink, happy, sad, angry, surprised),
55
+ "style": { "walk": ${vr.map(e=>`"${e}"`).join(" | ")}, "idle": ${Ar.map(e=>`"${e}"`).join(" | ")}, "energy": 0..1 },
56
56
  "voice": { "pitch": 0.5..2 },
57
57
  "tags": [ <= 8 short words ],
58
58
  "finish": { "noise": 0..1, "outline": 0..1, "shade": 0..1, "density": 1..4 } (optional; defaults 0.5 / 0.4 / 0.25 / 2 \u2014 the game adds fabric noise, a dark outline on the edge of every box face and top-to-bottom shading by itself; set 0 for a clean flat look)
@@ -74,4 +74,4 @@ HOW TO BUILD A GOOD, DETAILED CHARACTER (the game's style: blocky people with fi
74
74
  - Clothes in the textures: a shirt front with a collar, a button placket and pockets; a striped t-shirt; a knitted sweater with a pattern band and a ribbed hem; trousers with a crease; shorts with skin below and socks; the belt with a buckle.
75
75
  - The head front texture: hair on the top rows and the sides, skin elsewhere, a slightly darker chin row; the eyes, brows and mouth go into "face" (e.g. rect [0, 3, 8, 5] with 16x10 pictures): white eyes 3 texels wide with a coloured iris in the middle, brows above them, a 4-texel mouth \u2014 one picture per expression, the same size, transparent where the skin shows through.
76
76
  - Add detail with extra boxes: hair fringe, a hood, armour plates, a crown, horns, a tail (an extra bone with role "tail").
77
- - When the player sends pictures (possibly of ONE character from different angles: front, side, back) study EVERY picture: get the silhouette, proportions, colours, clothes and the face right. Pictures can be photos, drawings or 3D renders \u2014 turn them into a clean blocky version.`;var as=["wolf","lion","tiger","panda","pig","cow","sheep","horse","deer","mouse","raccoon","elephant","hedgehog","turtle","frog","duck","chicken","owl","penguin","bat","bee","eagle","fish","shark"],Eo={h:"#efe6cf",n:"#f2a0a8",r:"#d8342c",y:"#f2a630",d:"#2a2a30",g:"#e8f6ff"},K={mirror:true},Vl=["legFL","legFR","legBL","legBR"];function Te(e,t={}){let r=t.body??[8,8,16],o=t.bodyY??12;e("body","body",r,[0,o,0],"t"),t.belly!==false&&e("belly","body",[r[0]-2,1,r[2]-4],[0,o-r[1]/2,0],"l"),e("head","head",[8,8,8],[0,16,-12],t.head??"s");let a=t.leg??[3,8];for(let n of Vl){let s=n.endsWith("L")?-3:3,l=n.startsWith("legF")?-6:6;e(n,n,[a[0],a[1],a[0]],[s,a[1]/2,l],t.legColor??"t"),t.paw!==null&&e(`${n}Paw`,n,[a[0]+.2,1.5,a[0]+.2],[s,.75,l],t.paw??"a");}}var jr=(e,t="a",r=[4,3,3])=>{e("snout","head",r,[0,14.5,-16-r[2]/2+.5],"l"),e("nose","head",[1.4,1,.6],[0,15.6,-16-r[2]+.4],t);};function $t(e,t={}){let r=t.body??[6,6,8];e("body","body",r,[0,8,0],"t"),e("belly","body",[r[0]-1.4,r[1]-2,1],[0,7.5,-r[2]/2-.2],"l"),e("head","head",[5,5,5],[0,13,-4],t.head??"s");let o=t.wing??[8,1,6];e("wing","wingL",o,[-3-o[0]/2,10,0],t.wingColor??"a",K),e("leg","legL",[1,4,1],[-1.5,2,0],t.legColor??"a",K);}var Fl={bone:"head",rect:[0,1,5,3]};function ns(e,t){let r=(a,n,s)=>({rig:"quadruped",style:{walk:a,idle:n,energy:s},palette:Eo}),o=(a,n,s)=>({rig:"flyer",style:{walk:a,idle:n,energy:s},face:Fl,palette:Eo});switch(e){case "wolf":return Te(t),t("ear","head",[2.4,3.4,1],[-2.5,21.5,-10.5],"t",K),jr(t,"d"),t("ruff","body",[9,6,3],[0,13,-6.5],"l"),t("tail","tail",[3,3,10],[0,13,13],"t",{rot:[25,0,0]}),t("tailTip","tail",[3.1,3.1,2],[0,14.6,17.5],"l",{rot:[25,0,0]}),r("sneaky","proud",.6);case "lion":return Te(t),t("mane","head",[12,12,3],[0,16,-9.5],"a"),t("maneTop","head",[10,2,6],[0,21,-11.5],"a"),t("ear","head",[2,2,1],[-3,21.4,-12],"s",K),jr(t,"d",[4,2.6,2]),t("tail","tail",[1.4,1.4,10],[0,13,13],"t",{rot:[30,0,0]}),t("tuft","tail",[2.6,2.6,2.6],[0,15.2,18],"a",{rot:[30,0,0]}),r("heavy","proud",.5);case "tiger":Te(t);for(let a of [-5,-1.5,2,5.5])t(`stripe${a}`,"body",[8.3,1,1.1],[0,12.6,a],"d");return t("stripeHead","head",[8.3,1,3],[0,19.8,-11],"d"),t("ear","head",[2,2,1],[-3,21,-10.5],"t",K),jr(t,"n",[4,2.6,2]),t("tail","tail",[1.8,1.8,10],[0,14,13],"t",{rot:[20,0,0]}),t("tailRing","tail",[2,2,1],[0,15,15],"d",{rot:[20,0,0]}),r("sneaky","proud",.6);case "panda":return Te(t,{body:[9,9,15],legColor:"a",paw:"a"}),t("band","body",[9.2,9.2,4],[0,12,-4.5],"a"),t("ear","head",[2.4,2.4,1.2],[-3,21,-11],"a",K),t("nose","head",[1.6,1,.6],[0,15,-16.3],"a"),t("tail","tail",[2,2,2],[0,14,8.5],"l"),r("heavy","calm",.4);case "pig":return Te(t,{leg:[3,6],paw:"a"}),t("snout","head",[3.6,2.6,1.2],[0,14.6,-16.6],"n"),t("nostril","head",[.6,.8,.2],[-0.8,14.6,-17.3],"a",K),t("ear","head",[2.4,2,1],[-2.6,20.6,-10.5],"n",{mirror:true,rot:[-30,0,0]}),t("tail","tail",[1,1,2.6],[0,15,9],"n",{rot:[-40,0,0]}),r("bouncy","fidgety",.7);case "cow":return Te(t,{body:[9,9,16],paw:"d"}),t("spot","body",[9.2,3.6,4],[0,14,-2],"a"),t("spot2","body",[9.2,3,3],[0,11,5],"a"),t("muzzle","head",[6,3,1.6],[0,13.6,-16.6],"n"),t("horn","head",[1,2.4,1],[-2.8,21.2,-11],"h",K),t("ear","head",[2.6,1.2,1],[-5,18.6,-11],"t",K),t("tail","tail",[1,8,1],[0,11,9],"t"),t("tailTip","tail",[1.6,2,1.6],[0,6.6,9],"a"),r("heavy","calm",.3);case "sheep":return Te(t,{body:[10,9,16],leg:[2.6,7],legColor:"a",paw:"d",head:"a",belly:false}),t("woolTop","body",[9,2,13],[0,17,0],"t"),t("woolHead","head",[8.6,2.4,6],[0,20.4,-11.6],"t"),t("ear","head",[2.6,1,1.6],[-5,18,-11],"a",K),t("tail","tail",[2.6,2.6,2],[0,14,9],"t"),r("bouncy","calm",.5);case "horse":return Te(t,{body:[8,8,17],paw:"d"}),t("muzzle","head",[5,4.6,4],[0,13.8,-17.6],"s"),t("nose","head",[5.2,1.6,1],[0,12.6,-19.6],"l"),t("mane","head",[1.6,3,8],[0,21.4,-9],"a"),t("maneNeck","body",[1.6,3,5],[0,17,-5.5],"a"),t("ear","head",[1.4,2.4,1],[-2.4,21.2,-13.4],"s",K),t("tail","tail",[2.2,10,2.2],[0,10,9.4],"a"),r("normal","proud",.7);case "deer":Te(t,{body:[7,8,15]}),jr(t,"d",[3.6,2.8,2.4]),t("ear","head",[2.6,1.4,1],[-5,19.6,-10.5],"t",K),t("antler","head",[.8,4,.8],[-2.4,22,-10.5],"h",K),t("antlerTine","head",[2.6,.8,.8],[-3.4,23.2,-10.5],"h",K),t("antlerTop","head",[.8,2,.8],[-4.3,24.4,-10.5],"h",K);for(let a of [-3,1,4])t(`spot${a}`,"body",[1.4,.4,1.4],[-1.6,16.1,a],"l",K);return t("tail","tail",[2,2.4,1.4],[0,14.6,8.4],"l"),r("bouncy","calm",.6);case "mouse":return Te(t,{body:[7,6,12],bodyY:11,leg:[2.4,8],paw:"n"}),t("ear","head",[3.4,3.4,.8],[-3.6,21.4,-10.6],"t",K),t("earIn","head",[2.2,2.2,.3],[-3.6,21.4,-11.1],"n",K),t("nose","head",[1.2,1,.6],[0,15,-16.3],"n"),t("tail","tail",[.8,.8,11],[0,12,13],"n",{rot:[15,0,0]}),r("sneaky","fidgety",.9);case "raccoon":Te(t,{paw:"d"}),t("mask","head",[8.3,1.4,8.3],[0,17,-12],"d",{shape:"cylinder"}),jr(t,"d",[3.4,2.4,2]),t("ear","head",[2.2,2.4,1],[-2.8,21.2,-10.5],"a",K),t("tail","tail",[3,3,10],[0,14,13],"t",{rot:[20,0,0]});for(let a of [10,13.4,16.8])t(`ring${a}`,"tail",[3.2,3.2,1.4],[0,14+(a-13)*.36,a],"d",{rot:[20,0,0]});return r("sneaky","fidgety",.7);case "elephant":return Te(t,{body:[10,10,16],leg:[4,8],paw:"l"}),t("ear","head",[1,7,6],[-5,16.4,-10.6],"a",K),t("trunk","head",[2.6,4,2.4],[0,12.6,-17.2],"s"),t("trunk2","head",[2.2,4,2.2],[0,9,-17.6],"s"),t("trunkTip","head",[2,1.6,2.6],[0,6.6,-18],"s"),t("tusk","head",[.8,.8,3],[-2.2,12.6,-17.2],"h",K),t("tail","tail",[.8,6,.8],[0,12,8.4],"t"),r("heavy","calm",.3);case "hedgehog":Te(t,{body:[8,6,12],bodyY:10,leg:[2.4,8],paw:"l"}),t("spines","body",[9.4,5,12],[0,13.6,1],"a");for(let a of [-3,1,5])t(`spike${a}`,"body",[1,1.6,1],[-2.4,16.8,a],"a",K);return t("spikeTop","body",[1,1.8,1],[0,16.9,-1],"a"),t("nose","head",[1.4,1.2,1.4],[0,14.6,-16.6],"d"),t("ear","head",[1.4,1.4,.8],[-3,20.6,-10.6],"l",K),r("sneaky","fidgety",.8);case "turtle":return Te(t,{body:[8,5,12],bodyY:9,leg:[3,8],paw:null}),t("shell","body",[11,6,15],[0,13,.6],"a"),t("shellTop","body",[8,1.6,11],[0,16.6,.6],"a"),t("shellRim","body",[11.4,1,15.4],[0,10.4,.6],"l"),t("tail","tail",[1.4,1.4,2.6],[0,11,9],"t"),r("heavy","calm",.2);case "frog":return Te(t,{body:[9,6,12],bodyY:10,leg:[3,8],paw:"a"}),t("eyeBump","head",[2.6,2.4,2.6],[-2.4,21.2,-13],"t",K),t("eyeBall","head",[1.6,1.6,.4],[-2.4,21.4,-14.5],"w",K),t("pupil","head",[.8,.8,.2],[-2.4,21.4,-14.8],"k",K),t("backLeg","legBL",[3.6,3,5],[-3.4,3.5,7.4],"t",K),r("bouncy","calm",.8);case "duck":return $t(t,{wingColor:"t",legColor:"y"}),t("bill","head",[3,.9,2.6],[0,12,-7.6],"y"),t("tail","tail",[3,1,2.4],[0,9.6,5],"t",{rot:[-25,0,0]}),o("bouncy","fidgety",.6);case "chicken":return $t(t,{wing:[3,4,6],wingColor:"t",legColor:"y"}),t("comb","head",[1,2,3.6],[0,16.4,-4],"r"),t("beak","head",[1.4,1,1.6],[0,12.8,-7.2],"y"),t("wattle","head",[.8,1.4,.6],[0,11.2,-6.8],"r"),t("tail","tail",[3,4,3],[0,11,5],"t",{rot:[20,0,0]}),o("bouncy","fidgety",.9);case "owl":return $t(t,{body:[7,7,7],wingColor:"a"}),t("tuft","head",[1,2,1],[-2,16.4,-4],"a",K),t("beak","head",[1,1.2,1],[0,12.4,-7],"y"),t("tail","tail",[3,1,3],[0,6,5],"a"),o("normal","calm",.3);case "penguin":return $t(t,{body:[7,9,6],wing:[3,6,2],wingColor:"t",legColor:"y"}),t("belly2","body",[5,7,.6],[0,7.6,-3.3],"l"),t("beak","head",[1.4,1,1.8],[0,12.6,-7.2],"y"),t("feet","legL",[2,.6,2.4],[-1.5,.3,-0.8],"y",K),o("heavy","fidgety",.6);case "bat":return $t(t,{body:[5,5,5],wing:[9,.6,5],wingColor:"a",legColor:"d"}),t("ear","head",[1.4,2.6,.8],[-1.6,16.6,-4],"t",K),t("fang","head",[.5,.8,.3],[-0.8,11.2,-6.6],"w",K),o("sneaky","fidgety",.8);case "bee":return $t(t,{body:[6,6,8],wing:[5,.4,4],wingColor:"g",legColor:"d"}),t("stripe","body",[6.2,6.2,1.2],[0,8,0],"d"),t("stripe2","body",[6.2,6.2,1.2],[0,8,2.8],"d"),t("stinger","body",[.8,.8,1.6],[0,7.4,4.6],"d"),t("antenna","head",[.4,2.4,.4],[-1.2,16.4,-4.6],"d",K),t("antennaTip","head",[.8,.8,.8],[-1.2,17.8,-4.6],"d",K),o("bouncy","fidgety",1);case "eagle":return $t(t,{body:[6,7,8],wing:[10,1,6],wingColor:"t",legColor:"y",head:"l"}),t("beak","head",[1.6,1.4,2],[0,12.6,-7.4],"y"),t("beakTip","head",[1,1,.8],[0,11.6,-8],"y"),t("tail","tail",[4,1,4],[0,7.4,6],"l"),o("heavy","proud",.6);case "fish":return t("body","body",[5,7,9],[0,6,0],"t"),t("belly","body",[4,1,7],[0,2.4,0],"l"),t("head","head",[5,6,4],[0,6,-6.5],"s"),t("tailFin","tail",[.8,6,4],[0,6,7],"a"),t("dorsal","body",[.8,2.4,4],[0,10.6,0],"a"),t("fin","finL",[3,.6,2],[-4,5,-1],"a",K),{rig:"swimmer",style:{walk:"normal",idle:"calm",energy:.7},face:{bone:"head",rect:[0,1,5,3]},palette:Eo};case "shark":return t("body","body",[7,7,16],[0,6,1],"t"),t("belly","body",[5.6,1,13],[0,2.4,1],"l"),t("head","head",[7,6,6],[0,6,-9],"s"),t("jaw","head",[6,1.4,5],[0,3.4,-9],"l"),t("dorsal","body",[1,5,4],[0,11.6,0],"t"),t("tailFin","tail",[1,9,5],[0,7,11.4],"t"),t("fin","finL",[4,.8,3],[-5,4,-1],"t",K),{rig:"swimmer",style:{walk:"heavy",idle:"proud",energy:.6},face:{bone:"head",rect:[0,1,7,3]},palette:Eo}}throw new Error(`unknown creature kind: ${e}`)}var Am=["cat","dog","fox","bear","rabbit","bird","dragon","slime","ghost","robot",...as],Bl=e=>({k:"#2a1c14",w:"#f4f4ef",b:e,m:"#7a3a30",o:"#3a1a14"});function Dl(e){let t=e.light??e.body,r=e.accent??e.body,o={t:e.body,s:e.body,l:t,a:r,p:r,...Bl(e.eyes??"#3f6f3a")},a=[],n="quadruped",s=Ar("head",[0,3,8,5]),l={walk:"normal",idle:"calm",energy:.6},i=(u,R,w,A,k,x={})=>a.push({name:u,bone:R,size:w,pos:A,color:k,...x});switch(e.kind){case "cat":case "fox":case "dog":case "bear":case "rabbit":{let u=e.kind;i("body","body",[8,8,16],[0,12,0],"t"),i("belly","body",[6,1,12],[0,8,0],"l"),i("head","head",[8,8,8],[0,16,-12],"s");for(let R of ["legFL","legFR","legBL","legBR"]){let w=R.endsWith("L")?-3:3,A=R.startsWith("legF")?-6:6;i(R,R,[3,8,3],[w,4,A],"t"),i(`${R}Paw`,R,[3.2,1.5,3.2],[w,.75,A],"a");}u==="cat"?(i("ear","head",[2,2.5,1],[-2.5,21,-11],"a",{mirror:true}),i("tail","tail",[1.6,1.6,10],[0,15,13],"t",{rot:[20,0,0]}),l={walk:"sneaky",idle:"calm",energy:.5}):u==="fox"?(i("ear","head",[2.4,3.2,1],[-2.5,21.4,-11],"t",{mirror:true}),i("snout","head",[4,3,3],[0,14.5,-17],"l"),i("nose","head",[1.2,1,.6],[0,15.6,-18.6],"a"),i("tail","tail",[3.5,3.5,10],[0,14,13],"t",{rot:[15,0,0]}),i("tailTip","tail",[3.6,3.6,2.5],[0,15.2,18],"l"),l={walk:"bouncy",idle:"fidgety",energy:.7}):u==="dog"?(i("ear","head",[1.5,4,3],[-4.6,17.5,-11.5],"a",{mirror:true}),i("snout","head",[4,3,3],[0,14.5,-17],"l"),i("nose","head",[1.6,1.2,.6],[0,15.8,-18.6],"a"),i("tail","tail",[2,2,7],[0,16,11],"t",{rot:[40,0,0]}),l={walk:"bouncy",idle:"fidgety",energy:.9}):u==="bear"?(i("ear","head",[2,2,1],[-3,20.6,-10.5],"a",{mirror:true}),i("snout","head",[4,3,2.5],[0,14.5,-16.8],"l"),i("nose","head",[1.6,1.2,.6],[0,15.8,-18.2],"a"),i("tail","tail",[2,2,2],[0,14,9],"t"),l={walk:"heavy",idle:"proud",energy:.4}):(i("ear","head",[1.6,7,1],[-1.8,23.5,-11],"t",{mirror:true}),i("earInner","head",[.8,5.5,.4],[-1.8,23.5,-11.6],"l",{mirror:true}),i("tail","tail",[3,3,3],[0,14,9.5],"l"),l={walk:"bouncy",idle:"fidgety",energy:.8});break}case "bird":case "dragon":{n="flyer",s=Ar("head",[0,1,5,3]);let u=e.kind==="dragon";i("body","body",[6,6,8],[0,8,0],"t"),i("belly","body",[4.6,4,1],[0,7.5,-4.2],"l"),i("head","head",[5,5,5],[0,13,-4],"s"),i("wing","wingL",[8,1,6],[-7,10,0],"a",{mirror:true}),i("leg","legL",[1,4,1],[-1.5,2,0],"a",{mirror:true}),u?(i("horn","head",[.8,2,.8],[-1.4,16.4,-3],"l",{mirror:true}),i("snout","head",[3,2,2.4],[0,12.2,-7.4],"s"),i("tail","tail",[2,2,8],[0,7,7],"t"),i("spike","body",[1,1.5,6],[0,11.6,0],"a"),l={walk:"heavy",idle:"proud",energy:.6}):(i("beak","head",[1.6,1.2,2],[0,12.4,-7.2],"a"),i("tail","tail",[4,1,4],[0,8,6],"a"),i("crest","head",[1,2,2],[0,16.2,-3.6],"a"),l={walk:"bouncy",idle:"fidgety",energy:.8});break}case "slime":case "ghost":case "robot":{n="blob",s=Ar("body",[2,3,8,5]),e.kind==="slime"?(i("body","body",[12,10,12],[0,5,0],"t"),l={walk:"bouncy",idle:"fidgety",energy:.9}):e.kind==="ghost"?(i("body","body",[10,12,10],[0,7,0],"t"),i("hem","body",[10.4,2,10.4],[0,1,0],"l",{shape:"cylinder"}),l={walk:"sneaky",idle:"calm",energy:.4}):(i("body","body",[11,11,10],[0,5.5,0],"t"),i("antenna","body",[.8,3,.8],[0,12.5,0],"a"),i("bulb","body",[1.6,1.6,1.6],[0,14.6,0],"l"),i("screen","body",[9,6,.4],[0,6.5,-4.82],"l"),l={walk:"robotic",idle:"calm",energy:.5});break}default:{let u=ns(e.kind,i);n=u.rig,l=u.style,u.face&&(s=Ar(u.face.bone,u.face.rect)),Object.assign(o,u.palette);}}Hl(a);let c=e.kind==="slime"||e.kind==="ghost"?"body":"head";for(let u of a)u.name===c&&u.bone===s.face.bone&&(u.shape="cylinder");let[p,h,m,d]=s.face.rect,b=[p+m*ss,h,m*(1-2*ss),d];return {version:1,name:e.name,description:e.description??"",rig:n,palette:o,textures:s.textures,parts:a,face:{...s.face,rect:b,drawn:{...Gl(e.kind),eyeColor:e.eyes??jl}},style:l,finish:Nl,tags:e.tags??[e.kind]}}var Nl={noise:0,outline:0,shade:.12,density:4,round:.35},dr=1.5;function Hl(e){let t=e,r=p=>p.size[0]*p.size[1]*p.size[2],o=p=>t.filter(h=>h.bone===p).sort((h,m)=>r(m)-r(h))[0],a=o("body");if(!a)return;let n=(p,h)=>p.pos[h]-p.size[h]/2,s=(p,h)=>p.pos[h]+p.size[h]/2;for(let p of ["legFL","legFR","legBL","legBR","legL","legR"]){let h=o(p);if(!h||s(h,1)>n(a,1)+dr||s(h,1)<n(a,1)-3)continue;let m=n(h,1),d=n(a,1)+dr;h.size[1]=d-m,h.pos[1]=(d+m)/2;}let l=(p,h,m)=>{for(let d of t)d.bone===p&&(d.pos[h]=d.pos[h]+m);},i=o("head");if(i&&i.pos[2]<n(a,2)){let p=n(a,2)+dr-s(i,2);p>0&&l("head",2,p);}let c=o("tail");if(c&&c.pos[2]>s(a,2)){let p=n(c,2)-(s(a,2)-dr);p>0&&l("tail",2,-p);}for(let p of [o("wingL"),o("finL")]){if(!p)continue;let h=n(a,0)+dr,m=s(p,0);m<h&&(p.size[0]=p.size[0]+(h-m),p.pos[0]=p.pos[0]+(h-m)/2);}if(i)for(let p of t){if(p.bone!=="head"||p===i)continue;let h=n(p,1)-(s(i,1)-dr/2);h>0&&n(p,1)<s(i,1)+.6&&(p.pos[1]=p.pos[1]-h);}}var jl="#2a1c14",ss=.07;function Gl(e){let t=(r,o,a=true)=>({eyes:r,brows:"none",mouth:o,cheeks:a});switch(e){case "cat":case "fox":case "lion":case "tiger":return t("cat","cat");case "dog":case "wolf":case "rabbit":case "mouse":case "raccoon":case "hedgehog":return t("round","cat");case "dragon":return t("almond","fang",false);case "slime":return t("sparkle","smile");case "ghost":return t("round","open",false);case "robot":return t("button","smile",false);case "owl":case "frog":return t("wide","smile");case "shark":return t("narrow","teeth",false);case "fish":return t("round","pout",false);case "bat":return t("round","fang");case "bee":case "turtle":return t("button","smile");default:return t("round","small")}}function Em(e){let t=Ye(Dl(e));if(!t.ok)throw new Error(`${e.kind}: ${t.error}`);return t.spec}var is={torso:"#d9d3c5",legs:"#5f6b7a"},ql="#2b2140",Ul="#7a2e2e",Kl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Yl=32,Wl=[10,7],Gr=1,$l={noise:0,outline:0,shade:.12,density:4,round:.35},Jl=["front","back","left","right"];function ls(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}var Ra=class{map={};next=0;key(t){let r=Object.entries(this.map).find(([,i])=>i===t);if(r)return r[0];if(this.next<Yl){let i=Kl[this.next++];return this.map[i]=t,i}let[o,a,n]=ls(t),s=Object.keys(this.map)[0],l=1/0;for(let[i,c]of Object.entries(this.map)){let[p,h,m]=ls(c),d=(o-p)**2+(a-h)**2+(n-m)**2;d<l&&(l=d,s=i);}return s}};function Xl(e,t){return (typeof e=="function"?e(t):e[t])??null}function Ql(e){let[t,r]=Wl,o=new U(t,r),a=n=>{n(1),n(6);};switch(e){case "blink":case "tired":a(n=>o.row(3,n,n+2,"k"));break;case "happy":a(n=>o.px(n,3,"k").px(n+1,2,"k").px(n+2,3,"k"));break;case "hurt":o.px(1,2,"k").px(2,3,"k").px(1,4,"k"),o.px(8,2,"k").px(7,3,"k").px(8,4,"k");break;case "surprised":case "scared":a(n=>o.rect(n,2,3,3,"w").px(n+1,3,"k"));break;default:a(n=>o.rect(n,2,3,3,"w").rect(n+1,3,2,2,"e").px(n+1,3,"k"));}switch(e==="angry"&&o.px(1,1,"k").px(2,1,"k").px(3,2,"k").px(8,1,"k").px(7,1,"k").px(6,2,"k"),e==="sad"&&o.px(3,1,"k").px(2,1,"k").px(6,1,"k").px(7,1,"k"),e){case "happy":case "talk":o.rect(4,5,2,2,"m");break;case "surprised":o.rect(4,5,2,2,"m");break;case "sad":o.px(3,6,"m").row(5,4,5,"m").px(6,6,"m");break;case "angry":case "tired":case "scared":case "hurt":o.row(6,4,5,"m");break;default:o.px(3,5,"m").row(6,4,5,"m").px(6,5,"m");}return o.tex()}function ka(e,t){let r=Ae[Qt],o=new Ra,a=o.key(e.body.skin),n=r.defaultParts.map(d=>({...d,size:[...d.size],pos:[...d.pos],color:d.name==="torso"?o.key(is.torso):d.name?.startsWith("leg")||d.name?.startsWith("foot")?o.key(is.legs):a})),s=new Map;for(let d of n){let b=s.get(d.name)??[];b.push(d),s.set(d.name,b);}for(let d of s.values())d.sort((b,u)=>u.pos[1]+u.size[1]/2-(b.pos[1]+b.size[1]/2));let l=(e.body.head??ya)==="round";if(l)for(let d of n)d.name==="head"?(d.shape="cylinder",d.size=[d.size[0],d.size[1]+Gr,d.size[2]],d.pos=[d.pos[0],d.pos[1]+Gr/2,d.pos[2]]):d.name==="neck"&&(d.size=[2.6,1.8,2.4],d.pos=[0,23.1,0]);let i={},c={k:o.key(ql),w:o.key("#ffffff"),e:o.key(e.face.eyeColor),m:o.key(Ul)},p={};for(let d of wr){let b=Ql(d),u="face_"+d;i[u]={...b,rows:b.rows.map(R=>[...R].map(w=>c[w]??w).join(""))},p[d]=u;}p.neutral=p[Qn[e.face.emotion]]??p.neutral;for(let d of Kt){let b=e.wear[d];if(!b)continue;let u=Xl(t,b);if(!u||u.slot!==d||u.style!==je)continue;let R={};for(let[x,f]of Object.entries(u.palette))R[x]=f===qt?a:o.key(x===u.tint&&e.tint[d]?e.tint[d]:f);let w={};for(let[x,f]of Object.entries(u.textures)){let S=`${d}_${x}`;w[x]=S,i[S]={w:f.w,h:f.h,rows:f.rows.map(T=>[...T].map(C=>R[C]??C).join(""))};}let A=x=>{if(!x)return;let f={};for(let[S,T]of Object.entries(x)){let C=w[T]??R[T];C&&(f[S]=C);}return Object.keys(f).length?f:void 0};for(let x of u.paint){let f=s.get(x.region);if(!f)continue;let S=R[x.color],T=A(x.faces);f.forEach((C,z)=>{S&&(C.color=S);let O=T&&Zl(T,f,z,i);O?C.faces=O:delete C.faces;});}let k=d==="hair"||d==="hat"||d==="faceAcc"&&!u.parts.some(x=>x.mat);for(let x of u.parts){let f={bone:x.bone,size:[...x.size],pos:[...x.pos],color:R[x.color]??a},S=A(x.faces);if(S&&(f.faces=S),x.rot&&(f.rot=[...x.rot]),x.mirror&&(f.mirror=true),x.name&&(f.name=x.name),x.mat&&(f.mat=x.mat),l&&x.bone===r.faceBone){let T=d==="hair"||d==="hat"?Gr:Gr/2;f.pos=[f.pos[0],f.pos[1]+T,f.pos[2]],k&&(f.wrap=true);}n.push(f);}}let h={version:1,name:"Avatar",description:"",rig:Qt,scale:e.body.height,palette:o.map,textures:i,parts:n,bones:[],face:{bone:r.faceBone,rect:l?[St[0],St[1]+Gr/2,St[2],St[3]]:[...St],expressions:p},style:{walk:e.anim?.walk??Et.walk,idle:e.anim?.idle??Et.idle,energy:.6},voice:{pitch:1},tags:["avatar",je],finish:{...$l}},m=Ye(h);if(!m.ok)throw new Error("composeAvatar: "+m.error);return m.spec}function Zl(e,t,r,o){if(t.length===1)return {...e};let a=t[0].pos[1]+t[0].size[1]/2,n=Math.min(...t.map(c=>c.pos[1]-c.size[1]/2)),s=Math.max(1e-6,a-n),l=c=>c<=0?0:c>=t.length?1:(a-(t[c-1].pos[1]-t[c-1].size[1]/2))/s,i={};for(let[c,p]of Object.entries(e)){let h=o[p];if(!h){i[c]=p;continue}if(c==="top"){r===0&&(i[c]=p);continue}if(c==="bottom"){r===t.length-1&&(i[c]=p);continue}if(!Jl.includes(c))continue;let m=Math.min(h.h-1,Math.round(l(r)*h.h)),d=Math.max(m+1,Math.round(l(r+1)*h.h)),b=`${p}_${r}`;o[b]||(o[b]={w:h.w,h:d-m,rows:h.rows.slice(m,d)}),i[c]=b;}return Object.keys(i).length?i:void 0}var ec={paths:[{x:243,y:-2,d:"M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"},{x:243,y:-2,d:"M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"},{x:243,y:-2,d:"M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"},{x:-460,y:467,d:"M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"},{x:-106,y:244,d:"M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"}]},tc={helmet:{paths:[0,1,2],box:[258,10,353,447]},wordmark:{paths:[3,4],box:[12,499,837,182]}},rc={"top.idos":{color:"#f8f8fc",faces:["front","back"],layers:[{art:"helmet",y:19.4,z:2.3,height:3.9},{art:"wordmark",y:14.85,z:2.15,width:6.2}]}},cs=512,ms=.02,ps=new Map;function oc(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}function ac(e,t,r){let o=`${e}:${r}`,a=ps.get(o);if(a)return a;if(typeof Path2D>"u")return null;let[n,s,l,i]=t.box,c=i*ms,p=cs/(i+2*c),h=oc(Math.round((l+2*c)*p),cs),m=h.getContext("2d");if(!m)return null;m.clearRect(0,0,h.width,h.height),m.fillStyle=r;for(let b of t.paths){let u=ec.paths[b];m.setTransform(p,0,0,p,(u.x-n+c)*p,(u.y-s+c)*p),m.fill(new Path2D(u.d));}let d=new D__namespace.CanvasTexture(h);return d.colorSpace=D__namespace.SRGBColorSpace,d.anisotropy=4,ps.set(o,d),d}function va(e){let t=[];for(let r of Kt){let o=e.wear[r],a=o?rc[o]:void 0;if(a)for(let n of a.layers){let s=tc[n.art],l=ac(n.art,s,a.color);if(!l)continue;let[,,i,c]=s.box,p=i/c,h=n.height??(n.width??1)/p,m=n.width??h*p,d=2*ms*h;for(let b of a.faces){let u=(b==="front"?-1:1)*(n.z+.03),R=[0,n.y,u];t.push({bone:"body",center:R,w:m+d,h:h+d,facing:b,texture:l});}}}return t}var To=class extends Ao{face;rest;mood="neutral";constructor(t,r,o={}){let a=new hr(t.face);super(ka(t,r),{gloss:true,shadows:true,...o,facePainter:a}),this.face=a,this.rest=t.face.emotion,this.view.setPrints(va(t)),this.applyMood();}setEmotion(t){this.mood=t,this.applyMood();}setAvatar(t,r){this.face.setFace(t.face),this.rest=t.face.emotion,this.setSpec(ka(t,r)),this.view.setPrints(va(t)),this.applyMood();}applyMood(){super.setEmotion(this.mood==="neutral"?this.rest:this.mood),this.animator.moodOverGestures=this.rest!=="neutral";}dispose(){super.dispose(),this.face.dispose();}};var sc=1.12,ic=.25,hs=1.6;function ds(e){e.outputColorSpace=D__namespace.SRGBColorSpace,e.toneMapping=D__namespace.NeutralToneMapping,e.toneMappingExposure=sc,e.shadowMap.enabled=true,e.shadowMap.type=D__namespace.PCFShadowMap;let t=new D__namespace.PMREMGenerator(e),r=new RoomEnvironment_js.RoomEnvironment,o=t.fromScene(r,.04).texture;return r.dispose(),t.dispose(),{light(a){a.environment=o,a.environmentIntensity=ic,a.add(new D__namespace.HemisphereLight(14543103,8019024,.6));let n=new D__namespace.DirectionalLight(16772829,3.4);n.position.set(4,4.4,-2.2),n.castShadow=true;let s=n.shadow.camera;s.left=s.bottom=-hs,s.right=s.top=hs,s.near=.5,s.far=12,n.shadow.mapSize.set(1024,1024),n.shadow.bias=-5e-4,n.shadow.normalBias=.02,n.shadow.radius=4,n.shadow.intensity=.55,n.target.position.set(0,1,0),a.add(n,n.target);let l=new D__namespace.DirectionalLight(13623551,.45);l.position.set(-3,.8,-3),a.add(l);let i=new D__namespace.DirectionalLight(14478591,2.6);i.position.set(-3.2,2.6,2.6),a.add(i);},dispose(){o.dispose();}}}function lc(e){if(e==="walk")return .3;if(e==="idle")return 1.2;let t=$e[e];return t.loop?1:t.duration*.4}var Ym=["#a99cff","#5b4bd6"];function cc(e,t){switch(t){case "full":return {center:new D__namespace.Vector3(0,e*.5,0),size:e*1.12,lift:.04};case "torso":return {center:new D__namespace.Vector3(0,e*.57,0),size:e*.5,lift:.06};case "legs":return {center:new D__namespace.Vector3(0,e*.2,0),size:e*.5,lift:.1};case "feet":return {center:new D__namespace.Vector3(0,e*.08,0),size:e*.32,lift:.3};case "face":return {center:new D__namespace.Vector3(0,e*.86,0),size:e*.34,lift:.04};case "head":return {center:new D__namespace.Vector3(0,e*.88,0),size:e*.5,lift:.08};default:return {center:new D__namespace.Vector3(0,e*.8,0),size:e*.56,lift:.08}}}function pc(e){let t=e.view.spec.parts,r=t.find(a=>a.name==="head"),o=0;for(let a of t)o=Math.max(o,a.pos[1]+a.size[1]/2);return !r||o<=0?e.height:Math.min(e.height,e.height*(r.pos[1]+r.size[1]/2)*mc/o)}var mc=1.022;function hc(e){return typeof e=="number"?e:e==="side"?Math.PI/2:e==="back"?Math.PI:.18}function us(e,t,r,o,a,n,s){let l=s.frame??"portrait",i={...a,face:{...a.face,emotion:"neutral"}},c=new To(i,n,{seed:7});try{e.setClearColor(0,0);let p=new D__namespace.Scene;t.light(p),c.group.rotation.y=hc(s.view),p.add(c.group);for(let f=0;f<20;f++)c.update(1/30);let h=s.motion;if(h){h==="walk"?c.setPose("walk"):h!=="idle"&&c.playEmote(h);let f=Math.round(Math.max(0,s.at??lc(h))*30);for(let S=0;S<f;S++)c.update(1/30);}if(!h||h==="walk"||h==="idle"||s.expression){let f=s.expression??a.face.emotion;c.view.setExpression(lr[f][0],f);}let{center:m,size:d,lift:b}=cc(l==="full"||l==="head"?c.height:pc(c),l),u=28,R=new D__namespace.PerspectiveCamera(u,1,.05,50),w=d/2/Math.tan(D__namespace.MathUtils.degToRad(u/2));R.position.set(m.x,m.y+d*b,m.z-w),R.lookAt(m),e.render(p,R);let A=document.createElement("canvas");A.width=o,A.height=o;let k=A.getContext("2d");if(!k)return r;let x=s.background;if(typeof x=="string")k.fillStyle=x,k.fillRect(0,0,o,o);else if(x){let f=k.createRadialGradient(o*.5,o*.38,o*.05,o*.5,o*.5,o*.72);f.addColorStop(0,x[0]),f.addColorStop(1,x[1]),k.fillStyle=f,k.fillRect(0,0,o,o);}return k.imageSmoothingEnabled=!s.pixelated,k.drawImage(r,0,0),A}finally{c.dispose();}}function fs(e,t){let r=document.createElement("canvas");r.width=e,r.height=e;let o=new D__namespace.WebGLRenderer({canvas:r,antialias:!t,alpha:true,preserveDrawingBuffer:true});return o.setPixelRatio(1),o.setSize(e,e,false),{renderer:o,lighting:ds(o),gl:r}}function bs(e){e.lighting.dispose(),e.renderer.dispose(),e.renderer.forceContextLoss();}function dc(e,t,r={}){let o=Math.max(16,Math.round(r.size??256)),a=fs(o,!!r.pixelated);try{return us(a.renderer,a.lighting,a.gl,o,e,t,r)}finally{bs(a);}}function ys(e={}){let t=Math.max(16,Math.round(e.size??256)),r=fs(t,!!e.pixelated);return {render(o,a,n={}){if(!r)throw new Error("snapshotter disposed");return us(r.renderer,r.lighting,r.gl,t,o,a,{...n,pixelated:e.pixelated})},dispose(){r&&(bs(r),r=null);}}}function Wm(e,t,r={}){let o=dc(e,t,r);return new Promise(a=>o.toBlob(n=>a(n),"image/png"))}function $m(e){if(!e?.spec)return null;let t={};for(let r of e.items??[])r&&typeof r.id=="string"&&(t[r.id]=r);return {spec:cr(e.spec),items:t}}function Me(e,t){let r=pr(e);if(!r.ok)throw new Error(`avatar set: ${String(e.id)}: ${r.errors.join("; ")}`);return t===void 0?{item:r.item}:{item:r.item,price:t}}var Z=e=>({w:e[0].length,h:e.length,rows:e}),g=(e,t,r,o={})=>({bone:"head",size:e,pos:t,color:r,...o}),L=(e,t,r,o={})=>({bone:"body",size:e,pos:t,color:r,...o}),W=(e,t,r,o,a={})=>({bone:e,size:t,pos:r,color:o,mirror:true,...a});var tt=(e,t,r,o,a,n)=>Me({id:`back.${e}`,slot:"back",name:t,palette:r,tint:o,parts:a},n),Tt=(e,t,r,o,a,n)=>Me({id:`neck.${e}`,slot:"neck",name:t,palette:r,tint:o,parts:a},n),ce={mirror:true},gs=[L([2.25,7.5,1.47],[1.69,21.15,3.04],"b",ce),L([10.13,3.13,.74],[7.31,26.15,3.86],"a",ce),L([10.13,3.13,.74],[7.88,23.03,4.05],"b",ce),L([9,3.13,.74],[8.44,19.9,4.23],"a",ce),L([6.75,3.13,.74],[9,16.77,4.42],"b",ce),L([4.5,3.13,.74],[9.56,13.65,4.6],"a",ce)],xs=[tt("shield","Round shield",{a:"#a32d2d",b:"#d8b030",c:"#5a3a22"},"a",[L([8,8,.8],[0,17.5,3.4],"a"),L([8.6,.8,1],[0,21.6,3.4],"c"),L([8.6,.8,1],[0,13.4,3.4],"c"),L([2.2,2.2,.8],[0,17.5,4.2],"b",{mat:"metal"})]),tt("skateboard","Skateboard",{a:"#2ab0c0",b:"#1d1d21",c:"#f4f1ea"},"a",[L([3,11,.5],[0,18,3.4],"a"),L([1,1,1],[1,13.4,3.9],"c",ce),L([1,1,1],[1,22.6,3.9],"c",ce)]),tt("rocketpack","Rocket pack",{a:"#c8ccd2",b:"#2b2140",f:"#ff8a2a"},null,[L([2.6,7,2.6],[1.6,17.5,3.8],"a",{mirror:true,mat:"metal"}),L([1.8,.8,1.8],[1.6,13.6,3.8],"b",ce),L([1.4,3,1.4],[1.6,11.6,3.8],"f",{mirror:true,mat:"glow"}),L([2.8,.8,2.8],[1.6,21.4,3.8],"b",ce)],250),tt("guitar","Guitar",{a:"#c0612b",b:"#3a2414",c:"#1d1d21"},"a",[L([5,5,1.4],[0,12.5,3.6],"a"),L([1,9,.8],[0,19.5,3.6],"b"),L([1.6,1.8,.9],[0,24.9,3.6],"b"),L([1.4,1.4,.2],[0,12.8,4.35],"c")],150),tt("batwings","Bat wings",{a:"#3c2f5a",b:"#241a3a"},"a",gs,200),tt("dragonwings","Dragon wings",{a:"#3c9a3c",b:"#2a6a2a",c:"#e8d27a"},"a",[...gs.slice(0,5),L([1,1.6,1],[12.2,28.3,3.86],"c",ce)],250),tt("butterfly","Butterfly wings",{a:"#f2a03a",b:"#2b2140"},"a",[L([6,7,.4],[4.2,21,3.2],"a",ce),L([4.6,5,.4],[3.6,15,3.2],"a",ce),L([1.4,1.4,.3],[5,22.4,3.5],"b",ce),L([1,1,.3],[3.8,15,3.5],"b",ce)],180),tt("fairy","Fairy wings",{a:"#c8f0ff",b:"#f6c8ff"},"a",[L([4.6,7,.3],[3.5,22,3],"a",{mirror:true,mat:"glass"}),L([3.4,4.6,.3],[3,16,3],"b",{mirror:true,mat:"glass"})],200),tt("quiver","Quiver",{a:"#7a4f2a",b:"#c8ccd2",c:"#f4f1ea"},"a",[L([2.4,8,2.4],[1.8,20,3.8],"a"),L([.4,3,.4],[1.2,25.5,3.6],"b"),L([.4,3,.4],[2.4,25.8,4],"b"),L([.8,.8,.3],[1.2,27.2,3.6],"c"),L([.8,.8,.3],[2.4,27.5,4],"c")],120),tt("shell","Turtle shell",{a:"#4c8a3a",b:"#2f5a24",c:"#c8b070"},"a",[L([8.6,9,2.8],[0,17.5,3.6],"a"),L([9.2,.9,3],[0,13,3.6],"c"),L([4,4,.4],[0,18,5.15],"b")],150)],ws=[Tt("scarf","Scarf",{a:"#c0392b",b:"#f4f1ea"},"a",[L([6,1.8,5.4],[0,22.5,0],"a"),L([1.6,4.5,.6],[1.2,19.4,-2.7],"a"),L([1.6,3.4,.6],[-0.6,19.9,-2.95],"b")]),Tt("bowtie","Bow tie",{a:"#c0392b"},"a",[L([.6,.7,.6],[0,21.9,-2.6],"a"),L([1.2,1.2,.4],[.85,21.9,-2.55],"a",ce)]),Tt("bandana","Neck scarf",{a:"#2f5fd0"},"a",[L([6,1.4,5],[0,22.4,0],"a"),L([4,1.6,.6],[0,21,-2.6],"a"),L([2.4,1.2,.6],[0,19.8,-2.6],"a"),L([1,.8,.6],[0,19,-2.6],"a")]),Tt("chain","Gold chain",{a:"#e8b730"},null,[L([5.4,.5,4.8],[0,22.3,0],"a",{mat:"metal"}),L([.5,2.2,.4],[0,21,-2.55],"a",{mat:"metal"}),L([1.2,1.2,.4],[0,19.6,-2.6],"a",{mat:"metal"})],150),Tt("medal","Medal",{a:"#e8b730",b:"#2f5fd0"},"b",[L([5.4,.5,4.8],[0,22.3,0],"b"),L([1.2,3.4,.3],[0,20.4,-2.5],"b"),L([1.6,1.6,.4],[0,18.3,-2.6],"a",{mat:"metal"})],120),Tt("heart","Heart pendant",{a:"#e8436b",b:"#c8ccd2"},"a",[L([5.4,.4,4.8],[0,22.3,0],"b",{mat:"metal"}),L([.3,2.4,.3],[0,20.9,-2.5],"b",{mat:"metal"}),L([1.4,1.2,.4],[0,19.3,-2.6],"a"),L([.7,.5,.4],[.35,20,-2.6],"a",ce)],100),Tt("lei","Flower lei",{a:"#4c9a4a",b:"#f08cb4",c:"#f2d33c",d:"#f4f1ea",e:"#ef9f27"},null,[L([6,1,5.4],[0,22.4,0],"a"),L([1.3,1.3,1.3],[2.4,21.4,-2.6],"b",ce),L([1.3,1.3,1.3],[0,20.9,-2.8],"c"),L([1.3,1.3,1.3],[3,22,0],"d",ce),L([1.3,1.3,1.3],[2,21.8,2.6],"e",ce)],120),Tt("headphones","Headphones on the neck",{a:"#2b2140",b:"#4be0c8"},"b",[L([1.4,2,2.2],[3.6,22.2,-0.2],"a",ce),L([.3,1.4,1.6],[4.35,22.2,-0.2],"b",{mirror:true,mat:"glow"}),L([6,.7,.8],[0,21.6,2.2],"a")],150)];var Aa=e=>({front:e,back:e,left:e,right:e}),rt=(e,t,r,o,a,n)=>Me({id:`bottom.${e}`,slot:"bottom",name:t,palette:r,tint:o,textures:a.textures??{},paint:a.paint,parts:a.parts??[]},n),Rs=[rt("sweatpants","Sweatpants",{a:"#8a8f98",b:"#6a6f78"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[4.4,1,4.4],[2.1,1.4,0],"b")]}),rt("leggings","Leggings",{a:"#1d1d21",w:"#f4f1ea"},"a",{textures:{st:Z(["aawa","aawa","aawa","aawa"])},paint:[{region:"legs",color:"a",faces:{left:"st",right:"st"}}]}),rt("pleated","Pleated skirt",{a:"#2b2140",b:"#3c3450",s:"@skin"},"a",{textures:{pl:Z(["abababab","abababab","abababab","abababab"])},paint:[{region:"legs",color:"s"}],parts:[L([10.4,4.8,5.6],[0,11.3,0],"a",{faces:Aa("pl")})]}),rt("joggers","Joggers",{a:"#2f5fd0",b:"#1d3f90"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[4.3,1.2,4.3],[2.1,1.3,0],"b")]}),rt("plaidskirt","Plaid skirt",{a:"#a32d2d",b:"#2b2140",s:"@skin"},"a",{textures:{pl:Z(["abaabaab","bbbbbbbb","abaabaab","abaabaab","bbbbbbbb","abaabaab"])},paint:[{region:"legs",color:"s"}],parts:[L([10.13,4.38,5.52],[0,11.46,0],"a",{faces:Aa("pl")})]},100),rt("denimshorts","Denim shorts",{a:"#3f6fd8",b:"#6a8fe8",s:"@skin"},"a",{paint:[{region:"legs",color:"s"}],parts:[W("legR",[4.62,5.4,4.62],[2.1,9.7,0],"a"),W("legR",[4.8,.8,4.8],[2.1,7.3,0],"b")]},80),rt("ripped","Ripped jeans",{a:"#2f5fd0",s:"@skin"},"a",{textures:{rp:Z(["aaaa","asaa","aaaa","aaaa","assa","aaaa"])},paint:[{region:"legs",color:"a",faces:{front:"rp"}}]},100),rt("camo","Camo pants",{a:"#5a6b3a",b:"#3a4a28",c:"#8a8a5a"},"a",{textures:{cm:Z(["aabbac","abbaac","caabba","ccaaba","abccaa","aabcca"])},paint:[{region:"legs",color:"a",faces:Aa("cm")}]},120),rt("tutu","Tutu",{a:"#f08cb4",b:"#ffc0d8",c:"#f4d8e4"},"a",{paint:[{region:"legs",color:"c"}],parts:[L([12,1.6,8],[0,12.5,0],"a"),L([11,1.2,7.2],[0,11.4,0],"b")]},150),rt("flares","Flared pants",{a:"#c87f17",b:"#a8670f"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[5.2,3,5.2],[2.1,2.3,0],"a")]},100)];var G=-4.75,Jt=(e,t="a",r)=>[g([1.7,.3,.3],[3.6,e,G],t,{mirror:true,...r?{mat:r}:{}}),g([.3,.3,4.4],[4.45,e,-2.55],t,{mirror:true,...r?{mat:r}:{}})],Le=(e,t,r,o,a,n)=>Me({id:`face.${e}`,slot:"faceAcc",name:t,palette:r,tint:o,parts:a},n),ur={"face.glasses":Le("glasses","Round glasses",{a:"#2b2140",g:"#cfe8ff"},"a",[g([2.6,.3,.3],[1.6,27.1,G],"a",{mirror:true}),g([2.6,.3,.3],[1.6,24.5,G],"a",{mirror:true}),g([.3,2.9,.3],[2.9,25.8,G],"a",{mirror:true}),g([.3,2.9,.3],[.3,25.8,G],"a",{mirror:true}),g([2.3,2.3,.15],[1.6,25.8,G],"g",{mirror:true,mat:"glass"}),...Jt(26.6)]).item,"face.shades":Le("shades","Sunglasses",{a:"#1d1d21",g:"#2a2a30"},"a",[g([2.8,2.1,.3],[1.6,25.85,G],"g",{mirror:true,mat:"glass"}),g([6.8,.42,.36],[0,26.95,G],"a"),g([.36,1.6,.36],[3.05,26.1,G],"a",{mirror:true}),...Jt(26.75)]).item,"face.visor":Le("visor","Cyber visor",{a:"#33e0ff",b:"#1d1d21"},"a",[g([8.6,1.8,.35],[0,25.9,-4.6],"a",{mat:"glow"}),g([.4,1.2,2.4],[4.35,26,-3.4],"b",{mirror:true}),g([.3,.6,7.6],[4.45,26.2,.4],"b",{mirror:true}),g([8.9,.6,.3],[0,26.2,4.45],"b")]).item},ks=[Le("mask","Face mask",{a:"#9ad0f0",b:"#f4f1ea"},"a",[g([6.4,2.8,.6],[0,23.6,-4.15],"a"),g([.4,2.4,1.6],[3.35,23.7,-3.35],"a",{mirror:true}),g([.25,.25,3],[4.35,24.9,-1.9],"b",{mirror:true})]),Le("clownnose","Clown nose",{a:"#e0302a",b:"#ffffff"},"a",[g([1.4,1.3,1.2],[0,24.9,-4.55],"a"),g([.4,.4,.2],[-0.3,25.25,-5.2],"b")]),Le("mustache","Mustache",{a:"#3b2a20"},"a",[g([3.4,.7,.5],[0,24.45,-4.25],"a"),g([.9,.9,.5],[1.95,24.3,-4.25],"a",{mirror:true})]),Le("beard","Beard",{a:"#3b2a20"},"a",[g([6.4,1.4,1.4],[0,22.2,-3.5],"a"),g([1.3,3.4,5.2],[3.75,23.6,-1.4],"a",{mirror:true}),g([2.4,.8,.5],[0,23.05,-4.25],"a"),g([3.6,.7,.5],[0,24.45,-4.25],"a")],120),Le("aviators","Aviators",{a:"#d8b030",g:"#c8843a"},"g",[g([2.6,1.6,.2],[1.6,26,G],"g",{mirror:true,mat:"glass"}),g([2,.8,.2],[1.6,24.85,G],"g",{mirror:true,mat:"glass"}),g([6.8,.25,.3],[0,26.85,G],"a",{mat:"metal"}),g([1,.25,.3],[0,26.35,G],"a",{mat:"metal"}),g([.25,2,.3],[2.95,25.8,G],"a",{mirror:true,mat:"metal"}),...Jt(26.7,"a","metal")],150),Le("square","Square glasses",{a:"#1d1d21",g:"#e0f0ff"},"a",[g([2.8,.45,.4],[1.6,27,G],"a",{mirror:true}),g([2.8,.45,.4],[1.6,24.6,G],"a",{mirror:true}),g([.45,2.4,.4],[3,25.8,G],"a",{mirror:true}),g([.45,2.4,.4],[.2,25.8,G],"a",{mirror:true}),g([2.2,2,.15],[1.6,25.8,G],"g",{mirror:true,mat:"glass"}),...Jt(26.7),g([.6,.3,.3],[0,26.3,G],"a")],100),Le("hearts","Heart glasses",{a:"#e8436b",b:"#ff8fb0"},"a",[g([2.6,1.3,.3],[1.6,26.1,G],"b",{mirror:true,mat:"glass"}),g([1.7,.8,.3],[1.6,25.1,G],"b",{mirror:true,mat:"glass"}),g([.8,.6,.3],[1.6,24.5,G],"b",{mirror:true,mat:"glass"}),g([1.1,.7,.32],[1,26.9,G],"a",{mirror:true}),g([1.1,.7,.32],[2.2,26.9,G],"a",{mirror:true}),g([.8,.3,.3],[0,26.3,G],"a"),...Jt(26.6)],120),Le("stars","Star glasses",{a:"#d8b030",b:"#ffe27a"},"a",[g([2.8,.9,.3],[1.6,26,G],"b",{mirror:true,mat:"glass"}),g([1.2,2.6,.3],[1.6,25.8,G],"b",{mirror:true,mat:"glass"}),g([.6,.7,.32],[1.6,27.3,G],"a",{mirror:true}),g([.8,.3,.3],[0,26.3,G],"a"),...Jt(26.6)],120),Le("goggles","Ski goggles",{a:"#2f5fd0",g:"#ff9a3c"},"a",[g([7.6,2.4,.4],[0,25.9,-4.8],"g",{mat:"glass"}),g([8.2,.5,.6],[0,27.35,-4.6],"a"),g([8.2,.5,.6],[0,24.45,-4.6],"a"),g([.5,1.4,8.6],[4.5,25.9,0],"a",{mirror:true}),g([9.4,1.4,.5],[0,25.9,4.5],"a")],150),Le("monocle","Monocle",{a:"#d8b030",g:"#e0f0ff"},null,[g([2.4,.25,.25],[-1.6,27,G],"a",{mat:"metal"}),g([2.4,.25,.25],[-1.6,24.6,G],"a",{mat:"metal"}),g([.25,2.4,.25],[-2.8,25.8,G],"a",{mat:"metal"}),g([.25,2.4,.25],[-0.4,25.8,G],"a",{mat:"metal"}),g([2.2,2.2,.12],[-1.6,25.8,G],"g",{mat:"glass"}),g([.2,3.2,.2],[-2.9,22.9,-4.7],"a",{mat:"metal"})],150),Le("3d","3D glasses",{a:"#f4f1ea",r:"#e0302a",c:"#2f8fe0"},null,[g([6.9,.5,.35],[0,27,G],"a"),g([6.9,.5,.35],[0,24.6,G],"a"),g([.5,2.9,.35],[3.2,25.8,G],"a",{mirror:true}),g([.8,2.9,.35],[0,25.8,G],"a"),g([2.3,1.9,.15],[1.6,25.8,G],"r",{mat:"glass"}),g([2.3,1.9,.15],[-1.6,25.8,G],"c",{mat:"glass"}),...Jt(26.6)],100),Le("eyepatch","Eye patch",{a:"#1d1d21"},null,[g([2.6,2.4,.4],[1.6,25.9,-4.3],"a"),g([5,.4,.3],[-1,27.3,-4.3],"a"),g([.3,.5,8.6],[4.4,27.3,0],"a",{mirror:true}),g([8.9,.5,.3],[0,27.3,4.4],"a")],100)];var Sa=(e,t)=>(r,o,a,n,s,l)=>Me({id:`${t}.${r}`,slot:e,name:o,palette:a,tint:n,textures:s.textures??{},paint:s.paint??[],parts:s.parts??[]},l),Mt=Sa("shoes","shoes"),Mo=Sa("hands","hands"),Lo=Sa("waist","waist"),Ea=(e="a")=>L([9.45,1.25,4.97],[0,13.15,0],e),vs=[Mt("bunny","Bunny slippers",{a:"#f4f1ea",b:"#f08cb4"},"b",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[.6,1.6,.4],[1.3,2.2,-2.4],"a"),W("shinR",[.6,1.6,.4],[2.9,2.2,-2.4],"a"),W("shinR",[.9,.7,.5],[2.1,1.1,-3.3],"b")]}),Mt("rainboots","Rain boots",{a:"#f2c14e",b:"#2b2140"},"a",{paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[W("shinR",[4.6,5,4.6],[2.1,3.5,0],"a")]}),Mt("runners","Running shoes",{a:"#2ab0c0",b:"#f4f1ea",c:"#e8436b"},"a",{textures:{sd:Z(["aaaaa","acaca","bbbbb"])},paint:[{region:"feet",color:"a",faces:{left:"sd",right:"sd",bottom:"b"}}],parts:[W("shinR",[4.4,.5,5.5],[2.1,.25,-0.5],"b")]}),Mt("rollers","Roller skates",{a:"#e8436b",b:"#f4f1ea",c:"#2b2140"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.5,3,4.6],[2.1,2.6,0],"a"),W("shinR",[3.4,.4,5],[2.1,.2,-0.5],"b"),W("shinR",[3.6,.9,.9],[2.1,-0.05,-2.4],"c"),W("shinR",[3.6,.9,.9],[2.1,-0.05,1.4],"c")]},150),Mt("iceskates","Ice skates",{a:"#f4f1ea",b:"#c8ccd2"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.5,3.2,4.6],[2.1,2.7,0],"a"),W("shinR",[.35,.6,5.8],[2.1,-0.2,-0.5],"b",{mat:"metal"})]},150),Mt("cowboy","Cowboy boots",{a:"#7a4f2a",b:"#4a2e1a"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.7,4.6,4.7],[2.1,3.6,0],"a"),W("shinR",[3,.6,1.4],[2.1,.3,1.6],"b")]},120),Mt("space","Space boots",{a:"#f4f1ea",b:"#9aa4ae"},null,{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[5,4.6,5],[2.1,3.3,0],"a"),W("shinR",[4.6,.6,5.8],[2.1,.3,-0.5],"b")]},150),Mt("platform","Platform sneakers",{a:"#1d1d21",w:"#f4f1ea"},"a",{textures:{toe:Z(["aaaa","wwww"]),side:Z(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[W("shinR",[4.5,1.2,5.6],[2.1,.6,-0.5],"w")]},100)],As=[Mo("mittens","Mittens",{a:"#c0392b",b:"#f4f1ea"},"a",{paint:[{region:"hands",color:"a"}],parts:[W("foreArmR",[3.7,.9,3.7],[6.3,14.3,0],"b")]}),Mo("fingerless","Fingerless gloves",{a:"#2b2140",s:"@skin"},"a",{textures:{fl:Z(["sss","aaa","aaa"])},paint:[{region:"hands",color:"a",faces:{front:"fl",back:"fl",left:"fl",right:"fl",bottom:"s"}}]}),Mo("wristbands","Wristbands",{a:"#e8436b"},"a",{parts:[W("foreArmR",[3.8,1.2,3.8],[6.3,14.7,0],"a")]}),Mo("boxing","Boxing gloves",{a:"#c0392b",b:"#f4f1ea"},"a",{paint:[{region:"hands",color:"a"}],parts:[W("foreArmR",[4.2,3.6,4.2],[6.3,12.5,-0.2],"a"),W("foreArmR",[3.8,1,3.8],[6.3,14.6,0],"b")]},100)],Es=[Lo("fannypack","Fanny pack",{a:"#2b2140",b:"#534ab7",m:"#c8ccd2"},"b",{parts:[L([9.45,.8,4.97],[0,13.6,0],"a"),L([4,2,1.6],[0,13.6,-3.1],"b"),L([3.2,.2,.15],[0,14.3,-3.92],"m",{mat:"metal"})]}),Lo("tools","Tool belt",{a:"#5a3a22",b:"#8a5a32",m:"#9aa4ae",h:"#c0612b"},"a",{parts:[Ea(),L([2.2,2.2,1.3],[3.2,12,-2.8],"b",{mirror:true}),L([.5,2.6,.5],[-1.4,11.8,-3.1],"h"),L([1.6,.7,.7],[-1.4,13.2,-3.1],"m",{mat:"metal"})]},80),Lo("sheath","Sword sheath",{a:"#3a2a22",b:"#5a3a22",m:"#c8ccd2"},"a",{parts:[Ea(),L([.9,4.8,1.2],[4.9,12.1,0],"b"),L([1.6,.4,.8],[4.9,14.7,0],"m",{mat:"metal"}),L([.6,1.4,.6],[4.9,15.6,0],"a")]},120),Lo("pouches","Double pouches",{a:"#3a2a22",b:"#6b6b4a"},"b",{parts:[Ea("a"),L([2.4,2.4,1.3],[2.6,11.8,-2.9],"b",{mirror:true})]},60)];var Je=g([9.21,2.05,8.73],[0,29.91,0],"a"),Lt=g([9.21,1.7,.73],[0,28.72,-4.36],"a"),qr=g([.71,1.7,2.8],[4.5,28.72,-2.9],"a",{mirror:true}),Ct=(e,t)=>g([.71,e,7.58],[4.6,t,.51],"a",{mirror:true}),Pt=(e,t)=>g([9.21,e,.73],[0,t,4.36],"a"),ke=(e,t,r,o,a={a:"#3b2a20"})=>Me({id:`hair.${e}`,slot:"hair",name:t,palette:a,tint:"a",parts:r},o),Ss=[ke("afro","Afro",[g([11.4,4.4,10.2],[0,31.3,.6],"a"),g([10.6,2.2,8.2],[0,27.2,1.5],"a"),g([1.2,4.2,7.4],[5,26.4,1.2],"a",{mirror:true}),g([9.6,4.4,1.3],[0,26.2,4.9],"a"),g([8.6,1.9,.8],[0,28.95,-4.5],"a")]),ke("buzz","Buzz cut",[g([8.9,.6,8.4],[0,30.45,0],"a"),g([.4,2.6,7.6],[4.42,28.9,.2],"a",{mirror:true}),g([8.9,3.6,.4],[0,28.4,4.2],"a"),g([8.9,.8,.4],[0,29.75,-4.2],"a")]),ke("sidepart","Side part",[Je,g([5.5,2.4,.9],[-1.85,28.6,-4.4],"a"),g([3.7,1.3,.73],[2.75,29.1,-4.36],"a"),Ct(3.41,27.86),Pt(4.77,27.18),g([3.2,1,3.4],[-1.6,31.3,-1.4],"a")]),ke("pigtails","Pigtails",[Je,Lt,qr,Ct(3.41,27.86),Pt(4.77,27.18),g([1.9,4.6,1.9],[4.9,26,1.6],"a",{mirror:true}),g([2.1,.8,2.1],[4.9,28.4,1.6],"b",{mirror:true})],void 0,{a:"#3b2a20",b:"#d4537e"}),ke("braids","Braids",[Je,Lt,Ct(3.41,27.86),Pt(4.77,27.18),g([1.6,5.6,1.6],[3.4,25,3.9],"a",{mirror:true}),g([1.9,.6,1.9],[3.4,22.5,3.9],"b",{mirror:true})],void 0,{a:"#3b2a20",b:"#f2c14e"}),ke("bowl","Bowl cut",[g([9.9,3.2,9.4],[0,29,0],"a"),g([9.4,1,8.9],[0,30.9,0],"a"),g([9.6,3.6,.9],[0,27,4.5],"a")]),ke("dreads","Dreadlocks",[Je,Lt,g([1.3,5,1.3],[4.75,25.6,-1.6],"a",{mirror:true}),g([1.3,5.6,1.3],[4.75,25.3,1.7],"a",{mirror:true}),g([1.3,6,1.3],[2.4,25,4.75],"a",{mirror:true}),g([1.3,6.2,1.3],[0,25.2,4.8],"a"),Pt(3.2,28.3)],120),ke("longwavy","Long waves",[Je,Lt,qr,g([1.06,6.82,7.88],[4.78,26.16,.66],"a",{mirror:true}),g([9.21,7.5,1.09],[0,26.16,4.55],"a"),g([1.3,2,8],[5.1,23.4,.9],"a",{mirror:true}),g([9.8,2,1.4],[0,23.2,4.85],"a")],120),ke("topknot","Top knot",[Je,Lt,qr,Ct(2.73,28.2),Pt(4.09,27.52),g([3.2,2.8,3.2],[0,32.3,0],"a"),g([3.5,.6,3.5],[0,31.1,0],"b")],100,{a:"#3b2a20",b:"#1d1d21"}),ke("spacebuns","Space buns",[Je,Lt,qr,Ct(3.41,27.86),Pt(4.77,27.18),g([3,3,3],[3,31.8,.5],"a",{mirror:true})],120),ke("emo","Swept fringe",[Je,g([6.5,3.8,.9],[-1.3,27.6,-4.45],"a"),g([2.7,1.3,.73],[3.25,29.1,-4.36],"a"),Ct(4.5,27.3),Pt(5.4,26.9)],100),ke("quiff","Quiff",[Je,g([8,2.4,3.2],[0,31.4,-2.6],"a"),g([8.6,1.2,1.2],[0,30.6,-4.4],"a"),Ct(2.73,28.2),Pt(4.09,27.52)],100),ke("mullet","Mullet",[Je,Lt,qr,Ct(2.73,28.2),g([9.21,7,1.09],[0,25.8,4.55],"a"),g([8,2,1.6],[0,23.2,4.9],"a")],80),ke("wavybob","Wavy bob",[Je,Lt,g([1.06,6.13,8.6],[4.78,26.84,.3],"a",{mirror:true}),g([9.21,6.14,1.09],[0,26.5,4.55],"a"),g([1.5,1.2,8.8],[5.1,24.1,.3],"a",{mirror:true}),g([9.6,1.2,1.5],[0,24.1,4.8],"a")],100),ke("curls","Shoulder curls",[g([9.92,2.39,9.45],[0,30.08,0],"a"),g([9.21,1.36,.73],[0,28.89,-4.8],"a"),g([2.83,2.73,2.91],[3.54,28.89,-2.55],"a",{mirror:true}),g([2.83,2.73,2.91],[3.54,28.89,1.82],"a",{mirror:true}),g([5.67,2.05,5.82],[0,31.61,0],"a"),g([4.25,4.27,2.18],[2.13,27.27,4],"a",{mirror:true}),g([2.6,4,2.6],[4.4,24.4,2.4],"a",{mirror:true})],150),ke("undercut","Undercut",[g([9.21,2.6,8.73],[0,30.2,0],"a"),g([9.21,1.7,2],[0,29.9,-4.3],"a"),g([.4,2.6,7.6],[4.42,28.2,.2],"b",{mirror:true}),g([8.9,3.4,.4],[0,27.6,4.2],"b")],120,{a:"#3b2a20",b:"#2a1d16"})];var ye=(e,t,r,o,a,n)=>Me({id:`hat.${e}`,slot:"hat",name:t,palette:r,tint:o,parts:a},n),Ta=g([9.4,.7,1.2],[0,30.6,0],"c"),Ts=[ye("tophat","Top hat",{a:"#1d1d21",b:"#a32d2d"},"a",[g([11.4,.55,11],[0,30.6,0],"a"),g([8.6,6,8.2],[0,33.9,0],"a"),g([8.8,.9,8.4],[0,31.4,0],"b")],150),ye("cowboy","Cowboy hat",{a:"#9a6a3a",b:"#4a2e1a"},"a",[g([13,.6,12],[0,30.4,0],"a"),g([.8,1.2,11],[6.1,31,0],"a",{mirror:true}),g([8.4,3.5,8],[0,32.4,0],"a"),g([8.6,.7,8.2],[0,31.1,0],"b")],150),ye("tricorn","Tricorn",{a:"#2c2420",b:"#d8b030"},"a",[g([10.4,2.4,10],[0,31.2,0],"a"),g([.8,2.6,8],[5.2,31.6,0],"a",{mirror:true}),g([9,2.6,.8],[0,31.6,4.8],"a"),g([3,2.2,.8],[0,31.4,-5],"a"),g([8,.4,.6],[0,30.2,-5.2],"b",{mat:"metal"})],180),ye("chef","Chef hat",{a:"#f6f4ee",b:"#e2ded2"},null,[g([9.8,2,9.4],[0,30.7,0],"b"),g([10.6,4.5,10.2],[0,33.9,0],"a")],100),ye("beret","Beret",{a:"#a32d2d"},"a",[g([10,1.6,9.6],[-0.4,31,0],"a"),g([.8,.8,.8],[0,32,0],"a")]),ye("hardhat","Hard hat",{a:"#f2c14e",b:"#d8a030"},"a",[g([9.8,3,9.4],[0,31.3,0],"a"),g([9.8,.5,2.5],[0,30,-5.5],"a"),g([1,.8,9.6],[0,33,0],"b")],80),ye("viking","Viking helmet",{a:"#9aa4ae",b:"#6a5a3a",c:"#f0e6d0"},"a",[g([9.8,3.2,9.4],[0,31.2,0],"a",{mat:"metal"}),g([10.2,1,9.8],[0,29.9,0],"b"),g([1.4,1.4,1.4],[5.5,31.6,0],"c",{mirror:true}),g([1.1,2.4,1.1],[6.2,33.2,0],"c",{mirror:true}),g([.8,2.2,.5],[0,28.6,-5.05],"a",{mat:"metal"})],200),ye("space","Space helmet",{a:"#bfe6ff",b:"#d8dde4",c:"#ff5a3c"},null,[g([11,10.4,10.8],[0,27,0],"a",{mat:"glass"}),g([10,1,9.6],[0,22.3,0],"b",{mat:"metal"}),g([1.2,1.2,.6],[0,32.4,-1.6],"c",{mat:"glow"})],250),ye("catears","Cat ears",{a:"#2b2140",b:"#f08cb4",c:"#2b2140"},"a",[Ta,g([2,2.2,1],[2.9,32,0],"a",{mirror:true}),g([1.1,1.3,.4],[2.9,31.8,-0.65],"b",{mirror:true})]),ye("bunnyears","Bunny ears",{a:"#f4f1ea",b:"#f08cb4",c:"#f4f1ea"},"a",[Ta,g([1.5,5.4,.9],[1.9,33.6,0],"a",{mirror:true}),g([.8,4.2,.3],[1.9,33.4,-0.55],"b",{mirror:true})],80),ye("foxears","Fox ears",{a:"#e8862a",b:"#2a1c14",c:"#2a1c14"},"a",[Ta,g([2.4,2.8,1],[2.8,32.2,0],"a",{mirror:true}),g([2.4,.9,1.05],[2.8,33.55,0],"b",{mirror:true})],80),ye("halo","Halo",{a:"#ffe27a"},"a",[g([6,.5,1],[0,33.4,-2.5],"a",{mat:"glow"}),g([6,.5,1],[0,33.4,2.5],"a",{mat:"glow"}),g([1,.5,4],[2.5,33.4,0],"a",{mat:"glow",mirror:true})],250),ye("horns","Little horns",{a:"#c0392b",b:"#7a1d1d"},"a",[g([1.4,1.8,1.4],[2.6,31.1,-0.6],"a",{mirror:true}),g([.9,1.2,.9],[2.9,32.5,-0.6],"b",{mirror:true})],120),ye("party","Party hat",{a:"#7f77dd",b:"#f2c14e"},"a",[g([6,1.6,6],[0,31.1,0],"a"),g([4.4,1.8,4.4],[0,32.8,0],"b"),g([2.8,1.8,2.8],[0,34.6,0],"a"),g([1.4,1.6,1.4],[0,36.3,0],"b"),g([1.6,1.2,1.6],[0,37.3,0],"a")]),ye("flowers","Flower wreath",{a:"#4c9a4a",b:"#f08cb4",c:"#f2d33c",d:"#f4f1ea"},null,[g([9.6,.9,9.2],[0,30.4,0],"a"),g([1.4,1.2,1.4],[3,30.9,-4.4],"b",{mirror:true}),g([1.4,1.2,1.4],[0,31,-4.6],"c"),g([1.4,1.2,1.4],[4.7,30.9,.5],"d",{mirror:true}),g([1.4,1.2,1.4],[2.6,30.9,4.5],"c",{mirror:true})],120),ye("bandana","Bandana",{a:"#c0392b"},"a",[g([9.6,2.4,9.2],[0,30.1,0],"a"),g([2,1.6,1.6],[0,29.4,5],"a"),g([1,2.6,.6],[.7,27.6,5.2],"a",{mirror:true})]),ye("ninja","Ninja headband",{a:"#2b2140",b:"#c8ccd2"},"a",[g([9.4,1.3,9],[0,28.8,0],"a"),g([3,1.1,.4],[0,28.8,-4.7],"b",{mat:"metal"}),g([.9,3,.5],[.7,27,4.9],"a",{mirror:true})],100),ye("propeller","Propeller cap",{a:"#2f5fd0",b:"#f2d33c",c:"#c0392b"},"a",[g([9.63,2.73,9.16],[0,30.8,.15],"a"),g([7.79,.55,3.64],[0,29.57,-5.96],"a"),g([.6,1.2,.6],[0,32.7,0],"b"),g([7,.3,1.2],[0,33.4,0],"c"),g([1.2,.3,7],[0,33.4,0],"b")],150)];var Co=e=>({front:e,back:e,left:e,right:e}),ge=(e,t,r,o,a,n)=>Me({id:`top.${e}`,slot:"top",name:t,palette:r,tint:o,textures:a.textures??{},paint:a.paint,parts:a.parts??[]},n),uc=Z(["abaabaab","bbbbbbbb","abaabaab","abaabaab","bbbbbbbb","abaabaab","abaabaab","abaabaab"]),Ms=[ge("flannel","Flannel shirt",{a:"#c0392b",b:"#2b2140"},"a",{textures:{pl:uc},paint:[{region:"torso",color:"a",faces:Co("pl")},{region:"arms",color:"a",faces:Co("pl")}],parts:[L([5.6,.8,.5],[0,22.2,-2.4],"b")]}),ge("polo","Polo shirt",{a:"#1d9e75",w:"#f4f1ea"},"a",{textures:{pk:Z(["aaawaaaa","aaawaaaa","aaawaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"pk"}},{region:"sleeves",color:"a"}],parts:[L([4.6,.9,.6],[0,22.4,-2.3],"a")]}),ge("heart","Heart sweater",{a:"#d4537e",b:"#f4f1ea"},"a",{textures:{h:Z(["aaaaaaaa","aabaabaa","abbbbbba","abbbbbba","aabbbbaa","aaabbaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"h"}},{region:"arms",color:"a"}]}),ge("gamer","Gamepad tee",{a:"#2b2140",b:"#9aa4ae",c:"#33e0ff",d:"#e8436b"},"a",{textures:{g:Z(["aaaaaaaa","aaaaaaaa","abbbbbba","bcbbbdbb","bbbbbbbb","abbaabba","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"g"}},{region:"sleeves",color:"a"}]}),ge("jersey","Sports jersey",{a:"#2f5fd0",w:"#f4f1ea"},"a",{textures:{n:Z(["aaaaaaaa","aawwwwaa","aaaaawaa","aaaawaaa","aaawaaaa","aaawaaaa","aaaaaaaa","aaaaaaaa"]),sl:Z(["aaa","www","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"n",back:"n"}},{region:"sleeves",color:"a",faces:Co("sl")}]}),ge("dress","Dress",{a:"#7f77dd",b:"#f4f1ea"},"a",{paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}],parts:[L([10.2,5,5.6],[0,12.1,0],"a"),L([9,.8,4.6],[0,14.9,0],"b")]}),ge("bomber","Varsity jacket",{a:"#a32d2d",b:"#f4f1ea",c:"#2b2140"},"a",{textures:{fr:Z(["aaabbaaa","aaabbaaa","abaabaaa","abaabaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa"]),cf:Z(["bbb","bbb","bbb","bbb","ccc"])},paint:[{region:"torso",color:"a",faces:{front:"fr"}},{region:"arms",color:"b",faces:Co("cf")}],parts:[L([8.8,.9,4.6],[0,12.9,0],"c")]},120),ge("puffer","Puffer jacket",{a:"#ef9f27",b:"#c87f17"},"a",{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([9.6,3.2,5.2],[0,20.6,0],"a"),L([9.4,3,5],[0,17.4,0],"b"),L([9,3,4.8],[0,14.3,0],"a"),W("armR",[4,2.2,4],[6.3,20.4,0],"a")]},150),ge("overalls","Overalls",{a:"#2f5fd0",b:"#f4f1ea",g:"#d8b030"},"a",{paint:[{region:"torso",color:"b"},{region:"sleeves",color:"b"}],parts:[L([6,5,.5],[0,17.8,-2.4],"a"),L([1.2,4,.5],[2.4,20.6,-2.4],"a",{mirror:true}),L([.6,.6,.3],[2.4,21.7,-2.75],"g",{mirror:true,mat:"metal"}),L([1.2,9,.5],[2.4,17.5,2.4],"a",{mirror:true}),L([8.8,4.4,4.6],[0,14.8,0],"a")]},100),ge("labcoat","Lab coat",{a:"#f4f1ea",b:"#9ad0f0"},null,{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([9,4.5,4.8],[0,11.8,0],"a"),L([1.6,4,.4],[1.6,19.8,-2.45],"a",{mirror:true}),L([1.6,1.4,.3],[-2.6,17,-2.4],"b")]},120),ge("ninja","Ninja suit",{a:"#2b2140",r:"#c0392b",g:"#3c3450"},"a",{textures:{wr:Z(["agaaaaaa","aagaaaaa","aaagaaaa","aaaagaaa","aaaaagaa","aaaaaaga","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"wr"}},{region:"arms",color:"a"}],parts:[L([9.2,1,4.8],[0,14.3,0],"r")]},150),ge("space","Space suit",{a:"#f4f1ea",b:"#9aa4ae",c:"#33e0ff",d:"#e8436b"},null,{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([5,3.6,.6],[0,19,-2.5],"b"),L([.6,.6,.3],[-1.2,19.6,-2.9],"c",{mat:"glow"}),L([.6,.6,.3],[1.2,19.6,-2.9],"d",{mat:"glow"}),W("armR",[4.2,1,4.2],[6.3,22.4,0],"b"),L([7,.8,5],[0,22.6,0],"b",{mat:"metal"})]},250),ge("pirate","Pirate shirt",{a:"#f4f1ea",b:"#5a3a22",r:"#a32d2d"},null,{textures:{v:Z(["aabbbbaa","aaabbaaa","aabaabaa","aaabbaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"v"}},{region:"arms",color:"a"}],parts:[W("foreArmR",[4.2,3,4.2],[6.3,15.6,0],"a"),L([9.2,1.4,4.8],[0,13.6,0],"r")]},120),ge("raincoat","Raincoat",{a:"#f2c14e",b:"#d8a030"},"a",{textures:{bt:Z(["aaaaaaaa","aaabaaaa","aaaaaaaa","aaabaaaa","aaaaaaaa","aaabaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"bt"}},{region:"arms",color:"a"}],parts:[L([7,3.6,2],[0,21.5,2.9],"a"),L([9,4,4.8],[0,12,0],"a")]},100),ge("vest","Vest and shirt",{a:"#5a3a22",b:"#f4f1ea"},"a",{paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[L([4.2,7,.5],[2.2,17.5,-2.4],"a",{mirror:true}),L([9,9,.5],[0,17.4,2.4],"a")]},80),ge("chef","Chef jacket",{a:"#f6f4ee",b:"#2b2140"},null,{textures:{db:Z(["aaaaaaaa","aabaabaa","aaaaaaaa","aabaabaa","aaaaaaaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"db"}},{region:"arms",color:"a"}],parts:[L([5,.8,.5],[0,22.3,-2.4],"a")]},80),ge("tuxedo","Tuxedo",{a:"#1d1d21",w:"#f4f1ea"},null,{textures:{tx:Z(["aawwwwaa","aaawwaaa","aaawwaaa","aaawwaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"tx"}},{region:"arms",color:"a"}],parts:[L([2,1,.4],[0,21.7,-2.6],"a"),L([8.6,4,.6],[0,11.6,2.4],"a")]},200),ge("leather","Leather jacket",{a:"#2a2420",b:"#c8ccd2"},"a",{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([2.6,1.6,.6],[2.5,22.1,-2.25],"a",{mirror:true}),L([.4,8,.3],[-0.8,16.8,-2.45],"b",{mat:"metal"})]},180)];var Ur=[...Ss,...Ms,...Rs,...vs,...As,...Es,...xs,...ws,...ks,...Ts];function Ge(e){let t=pr(e);if(!t.ok)throw new Error(`avatar shop: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var Ma=e=>({w:e[0].length,h:e.length,rows:e}),fc={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},bc={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},Ls=[{price:250,item:Ge({id:"hat.crown",slot:"hat",name:"Crown",palette:{a:"#e8b730",g:"#d23c4a"},tint:"a",parts:[{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,-4.36],color:"a"},{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,4.36],color:"a"},{bone:"head",size:[.71,1.7,8.73],pos:[4.6,30.93,0],color:"a",mirror:true},{bone:"head",size:[1.13,1.36,.73],pos:[2.98,32.47,-4.36],color:"a",mirror:true},{bone:"head",size:[1.13,1.77,.73],pos:[0,32.67,-4.36],color:"a"},{bone:"head",size:[.99,.95,.29],pos:[0,30.93,-4.87],color:"g"}]})},{price:250,item:Ge({id:"back.wings",slot:"back",name:"Angel wings",palette:{a:"#f7f5ff",b:"#d9d4f2"},tint:"a",parts:[{bone:"body",size:[2.25,7.5,1.47],pos:[1.69,21.15,3.04],color:"b",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.31,26.15,3.86],color:"a",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.88,23.03,4.05],color:"b",mirror:true},{bone:"body",size:[9,3.13,.74],pos:[8.44,19.9,4.23],color:"a",mirror:true},{bone:"body",size:[6.75,3.13,.74],pos:[9,16.77,4.42],color:"b",mirror:true},{bone:"body",size:[4.5,3.13,.74],pos:[9.56,13.65,4.6],color:"a",mirror:true},{bone:"body",size:[3.38,1.88,.74],pos:[11.25,28.65,3.86],color:"a",mirror:true}]})},{price:200,item:Ge({id:"hat.wizard",slot:"hat",name:"Wizard hat",palette:{a:"#3c2f8f",s:"#f2c14e"},tint:"a",parts:[{bone:"head",size:[10.63,.55,10.18],pos:[0,30.39,0],color:"a"},{bone:"head",size:[8.5,1.77,8],pos:[0,31.55,0],color:"a"},{bone:"head",size:[6.38,1.77,5.82],pos:[0,33.32,.36],color:"a"},{bone:"head",size:[4.25,1.77,4],pos:[0,35.09,.73],color:"a"},{bone:"head",size:[2.13,1.64,2.18],pos:[0,36.8,1.09],color:"a"},{bone:"head",size:[1.13,1.09,.29],pos:[0,31.61,-4.15],color:"s"}]})},{price:200,item:Ge({id:"top.armor",slot:"top",name:"Knight armor",palette:{a:"#b8c2cc",b:"#5b6672",g:"#e8b730"},tint:"a",paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[{bone:"body",size:[9.67,7.5,.74],pos:[0,18.65,-2.67],color:"a"},{bone:"armR",size:[4.32,2.94,4.32],pos:[6.3,22.38,0],color:"a",mirror:true},{bone:"body",size:[2.25,2.5,.37],pos:[0,19.27,-3.22],color:"g"}]})},{price:200,item:Ge({id:"back.sword",slot:"back",name:"Sword",palette:{a:"#d8dde4",g:"#e8b730",h:"#5a3a22"},tint:"g",parts:[{bone:"body",size:[1.35,12.5,.55],pos:[2.81,17.4,3.04],color:"a"},{bone:"body",size:[4.5,1.13,.92],pos:[2.81,24.21,3.04],color:"g"},{bone:"body",size:[1.01,3.75,.83],pos:[2.81,26.65,3.04],color:"h"},{bone:"body",size:[1.58,1.5,1.1],pos:[2.81,29.28,3.04],color:"g"}]})},{price:150,item:Ge({id:"hat.headphones",slot:"hat",name:"Headphones",palette:{a:"#2b2140",b:"#4be0c8"},tint:"b",parts:[{bone:"head",size:[9.63,.82,1.45],pos:[0,31.07,0],color:"a"},{bone:"head",size:[.57,3.41,.87],pos:[4.89,29.57,0],color:"a",mirror:true},{bone:"head",size:[1.13,2.45,2.62],pos:[4.96,27.39,0],color:"a",mirror:true},{bone:"head",size:[.28,1.64,1.75],pos:[5.6,27.39,0],color:"b",mirror:true}]})},{price:150,item:Ge({id:"hair.mohawk",slot:"hair",name:"Mohawk",palette:{a:"#d4537e"},tint:"a",parts:[{bone:"head",size:[1.84,3.07,8],pos:[0,31.78,0],color:"a"},{bone:"head",size:[1.84,2.05,1.45],pos:[0,31.27,-4.73],color:"a"},{bone:"head",size:[2.13,4.09,.73],pos:[0,28.2,4.36],color:"a"}]})},{price:150,item:Ge({id:"top.suit",slot:"top",name:"Suit and tie",palette:{a:"#2c2f3a",w:"#f4f1ea",r:"#c0392b"},tint:"a",textures:{front:Ma(["awwrrwwa","aawrrwaa","aaarraaa","aaarraaa","aaarraaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"front"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[1.35,1,.28],pos:[-2.92,19.9,-2.44],color:"w"}]})},{price:120,item:Ge({id:"hair.ponytail",slot:"hair",name:"Ponytail",palette:{a:"#3b2a20",b:"#d4537e"},tint:"a",parts:[fc,bc,{bone:"head",size:[.71,3.41,7.27],pos:[4.6,27.86,.36],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"},{bone:"head",size:[2.27,1.02,1.75],pos:[0,28.55,4.95],color:"b"},{bone:"head",size:[1.84,5.45,1.45],pos:[0,25.82,5.09],color:"a"}]})},{price:120,item:ur["face.visor"]},{price:100,item:Ge({id:"shoes.hightops",slot:"shoes",name:"High-tops",palette:{a:"#7f77dd",w:"#f4f1ea",b:"#2b2140"},tint:"a",textures:{toe:Ma(["aaaa","wwww"]),side:Ma(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[{bone:"shinR",size:[4.62,4.32,4.62],pos:[2.1,3.76,0],color:"b",mirror:true}]})},{price:50,item:Ge({id:"hands.gauntlets",slot:"hands",name:"Golden gauntlets",palette:{a:"#e8b730",b:"#b8862a"},tint:"a",paint:[{region:"hands",color:"a"}],parts:[{bone:"foreArmR",size:[4.32,1.75,4.32],pos:[6.3,13.78,0],color:"b",mirror:true}]})},{price:50,item:Ge({id:"waist.pouch",slot:"waist",name:"Belt pouch",palette:{a:"#3a2a22",b:"#7a5233"},tint:"b",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[2.7,2.5,1.29],pos:[2.93,11.9,-3.04],color:"b"}]})}],Cs=Ur.filter(e=>e.price!==void 0),Ps=[...Ls,...Cs].map(e=>e.item),La=Object.fromEntries([...Ls,...Cs].map(e=>[e.item.id,e.price])),zs=e=>Object.prototype.hasOwnProperty.call(La,e);function Q(e){let t=pr(e);if(!t.ok)throw new Error(`avatar catalog: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var fr=e=>({w:e[0].length,h:e.length,rows:e}),Kr={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},Ca={bone:"head",size:[.71,1.7,2.8],pos:[4.5,28.72,-2.9],color:"a",mirror:true},Yr={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},yc=[Q({id:"hair.short",slot:"hair",name:"Short",palette:{a:"#3b2a20"},tint:"a",parts:[Kr,Yr,Ca,{bone:"head",size:[.71,3.41,7.58],pos:[4.6,27.86,.51],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"}]}),Q({id:"hair.bob",slot:"hair",name:"Bob",palette:{a:"#3b2a20"},tint:"a",parts:[Kr,Yr,{bone:"head",size:[1.06,6.13,8.6],pos:[4.78,26.84,.3],color:"a",mirror:true},{bone:"head",size:[9.21,6.14,1.09],pos:[0,26.5,4.55],color:"a"}]}),Q({id:"hair.spiky",slot:"hair",name:"Spiky",palette:{a:"#3b2a20"},tint:"a",parts:[Kr,Yr,{bone:"head",size:[.71,2.73,8.6],pos:[4.6,28.2,0],color:"a",mirror:true},{bone:"head",size:[9.21,2.73,.73],pos:[0,28.2,4.36],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[2.83,31.61,-0.73],color:"a",mirror:true},{bone:"head",size:[2.13,2.73,2.18],pos:[0,31.95,-0.73],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[-1.42,31.61,2.18],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[1.77,31.75,1.82],color:"a"}]}),Q({id:"hair.long",slot:"hair",name:"Long",palette:{a:"#3b2a20"},tint:"a",parts:[Kr,Yr,Ca,{bone:"head",size:[1.06,6.82,7.88],pos:[4.78,26.16,.66],color:"a",mirror:true},{bone:"head",size:[9.21,7.5,1.09],pos:[0,26.16,4.55],color:"a"}]}),Q({id:"hair.bun",slot:"hair",name:"Bun",palette:{a:"#3b2a20"},tint:"a",parts:[Kr,Yr,Ca,{bone:"head",size:[.71,2.73,6.48],pos:[4.6,28.2,1.06],color:"a",mirror:true},{bone:"head",size:[9.21,4.09,.73],pos:[0,27.52,4.36],color:"a"},{bone:"head",size:[4.25,3.41,3.64],pos:[0,32.64,1.82],color:"a"}]}),Q({id:"hair.curly",slot:"hair",name:"Curly",palette:{a:"#3b2a20"},tint:"a",parts:[{bone:"head",size:[9.92,2.39,9.45],pos:[0,30.08,0],color:"a"},{bone:"head",size:[9.21,1.36,.73],pos:[0,28.89,-4.8],color:"a"},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,-2.55],color:"a",mirror:true},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,1.82],color:"a",mirror:true},{bone:"head",size:[5.67,2.05,5.82],pos:[0,31.61,0],color:"a"},{bone:"head",size:[4.25,4.27,2.18],pos:[2.13,27.27,4],color:"a",mirror:true}]})],gc=[Q({id:"top.idos",slot:"top",name:"iDos Games tee",palette:{a:"#1565ff"},tint:null,paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}]}),Q({id:"top.tee",slot:"top",name:"Star tee",palette:{a:"#1d9e75",b:"#f4f1ea"},tint:"a",textures:{print:fr(["aaaaaaaa","aaabbaaa","aabbbbaa","abbbbbba","aabbbbaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"print"}},{region:"sleeves",color:"a"}]}),Q({id:"top.hoodie",slot:"top",name:"Hoodie",palette:{a:"#378add",b:"#24578f",w:"#f0f0f0"},tint:"a",paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[{bone:"body",size:[7.88,4.38,1.84],pos:[0,21.78,3.04],color:"a"},{bone:"body",size:[5.63,2.5,.46],pos:[0,15.52,-2.53],color:"b"},{bone:"body",size:[.56,2.75,.37],pos:[1.24,19.65,-2.48],color:"w",mirror:true}]}),Q({id:"top.stripes",slot:"top",name:"Striped sweater",palette:{a:"#d4537e",b:"#f4f1ea"},tint:"a",textures:{st:fr(["aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa"]),sl:fr(["aaa","bbb","aaa","bbb","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"st",back:"st",left:"st",right:"st"}},{region:"arms",color:"a",faces:{front:"sl",back:"sl",left:"sl",right:"sl"}}]}),Q({id:"top.jacket",slot:"top",name:"Jacket",palette:{a:"#444441",b:"#f4f1ea",c:"#c8c2b4"},tint:"a",textures:{open:fr(["aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aacbbcaa","aaabbaaa","aaabbaaa"])},paint:[{region:"torso",color:"a",faces:{front:"open"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[3.38,1.5,.92],pos:[2.48,22.53,-2.21],color:"a",mirror:true}]}),Q({id:"top.tank",slot:"top",name:"Tank top",palette:{a:"#ef9f27"},tint:"a",paint:[{region:"torso",color:"a"}]})],xc=[Q({id:"bottom.jeans",slot:"bottom",name:"Jeans",palette:{a:"#2f5fd0"},tint:"a",paint:[{region:"legs",color:"a"}]}),Q({id:"bottom.shorts",slot:"bottom",name:"Shorts",palette:{a:"#5f6b7a",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"legR",size:[4.62,5.4,4.62],pos:[2.1,9.7,0],color:"a",mirror:true}]}),Q({id:"bottom.skirt",slot:"bottom",name:"Skirt",palette:{a:"#7f77dd",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"body",size:[10.13,4.38,5.52],pos:[0,11.46,0],color:"a"}]}),Q({id:"bottom.cargo",slot:"bottom",name:"Cargo pants",palette:{a:"#6b6b4a",b:"#55553a"},tint:"a",paint:[{region:"legs",color:"a"}],parts:[{bone:"legR",size:[.84,4.32,2.52],pos:[4.62,7,0],color:"b",mirror:true}]})],wc=[Q({id:"shoes.sneakers",slot:"shoes",name:"Sneakers",palette:{a:"#d84a30",w:"#f4f1ea"},tint:"a",textures:{toe:fr(["aaaa","wwww"]),side:fr(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}]}),Q({id:"shoes.boots",slot:"shoes",name:"Boots",palette:{a:"#5a3a22",b:"#3a2414"},tint:"a",paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[{bone:"shinR",size:[4.83,4.32,4.83],pos:[2.1,3.76,0],color:"a",mirror:true}]}),Q({id:"shoes.sandals",slot:"shoes",name:"Sandals",palette:{a:"#b0773a",s:"@skin"},tint:"a",paint:[{region:"feet",color:"s"}],parts:[{bone:"shinR",size:[4.51,.48,5.57],pos:[2.1,.24,-0.53],color:"a",mirror:true},{bone:"shinR",size:[4.51,.4,1.05],pos:[2.1,1.12,-1.89],color:"a",mirror:true}]})],Rc=[Q({id:"hands.gloves",slot:"hands",name:"Gloves",palette:{a:"#2b2140"},tint:"a",paint:[{region:"hands",color:"a"}]})],kc=[Q({id:"waist.belt",slot:"waist",name:"Belt",palette:{a:"#5a3a22",g:"#d8b030"},tint:"a",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[1.8,1.5,.37],pos:[0,13.15,-2.67],color:"g"}]})],vc=[Q({id:"back.backpack",slot:"back",name:"Backpack",palette:{a:"#c0612b",b:"#8a3f18"},tint:"a",parts:[{bone:"body",size:[6.75,8.75,2.76],pos:[0,17.4,3.68],color:"a"},{bone:"body",size:[4.5,3.75,.55],pos:[0,14.9,5.34],color:"b"}]}),Q({id:"back.cape",slot:"back",name:"Cape",palette:{a:"#a32d2d"},tint:"a",parts:[{bone:"body",size:[10.13,12.5,.55],pos:[0,16.15,2.67],color:"a"}]})],Ac=[ur["face.glasses"],ur["face.shades"]],Ec=[Q({id:"hat.beanie",slot:"hat",name:"Beanie",palette:{a:"#534ab7",w:"#f4f1ea"},tint:"a",parts:[{bone:"head",size:[9.92,3.07,9.45],pos:[0,30.76,0],color:"a"},{bone:"head",size:[10.34,1.36,9.89],pos:[0,29.3,0],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[0,33.18,0],color:"w"}]}),Q({id:"hat.cap",slot:"hat",name:"Cap",palette:{a:"#c0392b"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,30.8,.15],color:"a"},{bone:"head",size:[7.79,.55,3.64],pos:[0,29.57,-5.96],color:"a"}]}),Q({id:"hat.bucket",slot:"hat",name:"Bucket hat",palette:{a:"#c8b88a"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,31.61,0],color:"a"},{bone:"head",size:[11.33,.55,10.91],pos:[0,30.39,0],color:"a"}]})],Po=[...yc,...gc,...xc,...wc,...Rc,...kc,...vc,...Ac,...Ec,...Ps.filter(e=>!Ur.some(t=>t.item.id===e.id)),...Ur.map(e=>e.item)],Mh=Object.fromEntries(Po.map(e=>[e.id,e]));function Sc(e){return Po.filter(t=>t.slot===e)}function Is(e){return Sc(e).filter(t=>!zs(t.id))}var Tc=["#f9e0cf","#f2c9a0","#e2ad80","#c88d62","#9c6844","#6e4a32"],Mc=["#3b2a20","#1d1d21","#f2c14e","#c0612b","#ece6da","#7f77dd","#d4537e","#2ab0a0"],Lc=["#3b2a20","#2f5fd0","#1d9e75","#7f77dd","#c0392b","#d8b030"],Cc=["#1d9e75","#378add","#d4537e","#444441","#ef9f27","#534ab7","#c0392b","#e8e4da"],_s={version:Ut,style:je,body:{skin:"#f2c9a0",height:1,head:"round"},face:{eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,marks:"none",emotion:"neutral"},anim:{...Et},wear:{hair:"hair.short",top:"top.idos",bottom:"bottom.jeans",shoes:"shoes.sneakers"},tint:{}},Os={hair:.92,top:1,bottom:1,shoes:1,hands:.1,waist:.2,back:.2,neck:.15,faceAcc:.25,hat:.35};function zh(e=Math.random){let t=n=>n[Math.floor(e()*n.length)],r=t(Mc),o={},a={};for(let n of Object.keys(Os)){if(e()>=Os[n])continue;let s=Is(n);s.length&&(o[n]=t(s).id,a[n]=n==="hair"?r:t(Cc));}return {version:Ut,style:je,body:{skin:t(Tc),height:.95+e()*.1,head:t(Hr)},face:{eyes:t(Fr),eyeColor:t(Lc),brows:t(Br),browColor:r==="#ece6da"||r==="#f2c14e"?"#8a6a3a":r,mouth:t(Dr),cheeks:e()<.6,marks:e()<.3?t(Nr):"none",emotion:"neutral"},anim:{...Et},wear:o,tint:a}}var Pc={hair:{frame:"portrait",view:.5},hat:{frame:"head",view:.35},faceAcc:{frame:"portrait",view:.2},neck:{frame:"portrait",view:.3},top:{frame:"torso",view:.3},waist:{frame:"torso",view:.3},hands:{frame:"torso",view:.55},bottom:{frame:"legs",view:.3},shoes:{frame:"feet",view:.6},back:{frame:"full",view:Math.PI-.6}},zc=["hair","top","bottom","shoes"];function Ic(e,t){let r=cr(JSON.parse(JSON.stringify(_s)));for(let o of Object.keys(r.wear))zc.includes(o)||delete r.wear[o];return r.tint={},r.wear[e]=t,r}function Fh(e,t){return {key:`item:${e.id}`,make:()=>({spec:Ic(e.slot,e.id),items:{...t,[e.id]:e},opts:Pc[e.slot]})}}function Bh(e={}){let t=e.size??224,r=e.limit??800,o=e.budgetMs??14,a=new Map,n=new Map,s=[],l=null,i=false,c=(m,d)=>{for(a.delete(m),a.set(m,d);a.size>r;){let b=a.keys().next().value;URL.revokeObjectURL(a.get(b)),a.delete(b);}},p=()=>{if(i)return;i=true;let m=globalThis.requestIdleCallback;m?m(h,{timeout:120}):setTimeout(h,16);};function h(){i=false;let m=performance.now();for(;s.length&&performance.now()-m<o;){let d=s.shift(),b=n.get(d);if(b&&(n.delete(d),b.listeners.size!==0))try{l??=ys({size:t});let{spec:u,items:R,opts:w}=b.make(),A=l.render(u,R,w),k=[...b.listeners];A.toBlob(x=>{if(!x)return;let f=URL.createObjectURL(x);c(d,f);for(let S of k)S(f);},"image/png");}catch{l?.dispose(),l=null;}}s.length&&p();}return {peek:m=>a.get(m)??null,request(m,d){let b=a.get(m.key);if(b)return c(m.key,b),d(b),()=>{};let u=n.get(m.key);u||(u={make:m.make,listeners:new Set},n.set(m.key,u),s.push(m.key)),u.listeners.add(d),p();let R=u;return ()=>R.listeners.delete(d)},release(){l?.dispose(),l=null;}}}var Oc="voxel-avatar-v1";function Uh(){return {standard:Oc,style:je,version:Ut,slots:[...Kt],eyes:[...Fr],brows:[...Br],mouths:[...Dr],emotions:[...vt],heads:[...Hr],marks:[...Nr],walks:[...ga],idles:[...xa],height:{min:Vr.min,max:Vr.max},items:[...Po],shop:{...La},rules:{slots:{...ba},limits:{...Yt},regions:[...ua],regionPairs:Object.fromEntries(Object.entries(fa).map(([e,t])=>[e,[...t]])),faces:[...dt],skinColor:qt,materials:[...er]}}}var _c=(e,t,r)=>"#"+[e,t,r].map(o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0")).join("");function Vc(e,t,r){let o=[];for(let a=0;a<r;a++)for(let n=0;n<t;n++){let s=Math.floor(n*e.width/t),l=Math.max(s+1,Math.floor((n+1)*e.width/t)),i=Math.floor(a*e.height/r),c=Math.max(i+1,Math.floor((a+1)*e.height/r)),p=0,h=0,m=0,d=0,b=0;for(let u=i;u<c;u++)for(let R=s;R<l;R++){let w=(u*e.width+R)*4;b++,!((e.data[w+3]??0)<128)&&(p+=e.data[w]??0,h+=e.data[w+1]??0,m+=e.data[w+2]??0,d++);}o.push(d*2<b?null:[p/d,h/d,m/d]);}return o}var Wr=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2;function Wh(e,t){let r=Yt.textureSide,a=Math.min(1,16/Math.max(e.width,e.height,1)),n=Math.max(1,Math.min(r,Math.round(t.w??e.width*a))),s=Math.max(1,Math.min(r,Math.round(t.h??e.height*a))),l=[...new Set(t.symbols)].slice(0,Yt.palette);if(!l.length)throw new Error("pixelTextureFromImage: no palette symbols to use");let i=Vc(e,n,s),c=i.filter(u=>!!u),p=new Map;for(let u of c){let R=u.map(A=>Math.round(A/8)).join(","),w=p.get(R);w?w.n++:p.set(R,{n:1,c:u});}let h=[...p.values()].sort((u,R)=>R.n-u.n||(u.c.join()<R.c.join()?-1:1)),m=[];for(let u of h){if(m.length>=l.length)break;m.every(R=>Wr(R,u.c)>576)&&m.push([...u.c]);}!m.length&&h[0]&&(m=[[...h[0].c]]);for(let u=0;u<8&&m.length;u++){let R=m.map(()=>[0,0,0,0]);for(let w of c){let A=0;for(let x=1;x<m.length;x++)Wr(w,m[x])<Wr(w,m[A])&&(A=x);let k=R[A];k[0]+=w[0],k[1]+=w[1],k[2]+=w[2],k[3]+=1;}m=m.map((w,A)=>{let k=R[A];return k[3]?[k[0]/k[3],k[1]/k[3],k[2]/k[3]]:w});}let d={};m.forEach((u,R)=>d[l[R]]=_c(u[0],u[1],u[2]));let b=[];for(let u=0;u<s;u++){let R="";for(let w=0;w<n;w++){let A=i[u*n+w];if(!A||!m.length){R+=".";continue}let k=0;for(let x=1;x<m.length;x++)Wr(A,m[x])<Wr(A,m[k])&&(k=x);R+=l[k];}b.push(R);}return {texture:{w:n,h:s,rows:b},palette:d}}var Fc="ugc.",$h=e=>e.startsWith(Fc);exports.ACTION_TIME=qn;exports.ANIM_EVENTS=L1;exports.AVATAR_AUTHOR_ITEM_PREFIX=Fc;exports.AVATAR_BASE_COLORS=is;exports.AVATAR_FACE_RECT=St;exports.AVATAR_HEADS=Hr;exports.AVATAR_HEIGHT=Vr;exports.AVATAR_IDLES=xa;exports.AVATAR_ITEMS=Mh;exports.AVATAR_ITEM_LIMITS=Yt;exports.AVATAR_ITEM_LIST=Po;exports.AVATAR_ITEM_PRINTS=rc;exports.AVATAR_ITEM_SHOTS=Pc;exports.AVATAR_PORTRAIT_BACKGROUND=Ym;exports.AVATAR_RIG_ID=Qt;exports.AVATAR_SHOP_DEFAULT_PRICES=La;exports.AVATAR_SHOP_ITEM_LIST=Ps;exports.AVATAR_SLOTS=Kt;exports.AVATAR_SPEC_VERSION=Ut;exports.AVATAR_STANDARD_ID=Oc;exports.AVATAR_STYLE=je;exports.AVATAR_WALKS=ga;exports.Animator=Ro;exports.Art=U;exports.AvatarActor=To;exports.BODY_REGIONS=ua;exports.BONE_ROLES=Wc;exports.BROW_STYLES=Br;exports.CH=I;exports.CHANNELS=T1;exports.CHARACTER_LIMITS=Ha;exports.CHARACTER_SPEC_VERSION=Ba;exports.CLEAR=ut;exports.CLIPS=zr;exports.CLOTH_COLORS=Cc;exports.CREATURE_KINDS=Am;exports.CharacterView=bo;exports.DEFAULT_AVATAR=_s;exports.DEFAULT_AVATAR_ANIM=Et;exports.DEFAULT_AVATAR_FACE=Rl;exports.DEFAULT_AVATAR_HEAD=ya;exports.DEFAULT_CHARACTER_SOURCE=Go;exports.DEFAULT_COLORS=Ds;exports.DEFAULT_FINISH=Zt;exports.DrawnFace=hr;exports.EMOTES=$e;exports.EMOTE_IDS=Vp;exports.EMOTIONS=vt;exports.EMOTION_EVENTS=qp;exports.EVERYDAY_IDS=_p;exports.EXPRESSIONS=wr;exports.EXPRESSION_CHAIN=lr;exports.EXTRA_BONE_ROLES=eo;exports.EYE_COLORS=Lc;exports.EYE_STYLES=Fr;exports.FACE_NAMES=dt;exports.FACE_TEXELS=rs;exports.GESTURE_IDS=Op;exports.HAIR_COLORS=Mc;exports.HELD_KINDS=M1;exports.HUMAN_BOTTOMS=sn;exports.HUMAN_HAIR=A1;exports.HUMAN_SHOES=ln;exports.HUMAN_TOPS=nn;exports.IDLE_STYLES=kr;exports.IKSolver=Mr;exports.LOCOMOTION=bl;exports.MARK_STYLES=Nr;exports.MOUTH_STYLES=Dr;exports.PART_MATERIALS=er;exports.PART_SHAPES=c1;exports.POSTURE=ma;exports.REGION_PAIRS=fa;exports.REST=nr;exports.RIGS=Ae;exports.RIG_CLIPS=Gn;exports.RIG_IDS=gr;exports.Ragdoll=Pr;exports.SEAT_HEIGHT_PX=hl;exports.SKIN_COLOR=qt;exports.SKIN_TONES=Tc;exports.SLOT_RULES=ba;exports.SOCKETS=$c;exports.VOXEL_CHARACTER_SYSTEM_PROMPT=gm;exports.VoxelActor=Ao;exports.WALK_STYLES=Rr;exports.acquireCharacter=Do;exports.add=de;exports.applyPosture=es;exports.avatarCatalogExport=Uh;exports.avatarFromServer=$m;exports.avatarItemShot=Fh;exports.avatarItemsForSlot=Sc;exports.avatarMannequinWith=Ic;exports.avatarPrints=va;exports.bandColors=I0;exports.bone=ae;exports.bonesOf=Ga;exports.characterFromImage=kp;exports.characterOf=pp;exports.characterSpecs=mp;exports.clearPose=ft;exports.composeAvatar=ka;exports.copyPose=Be;exports.createAvatarLighting=ds;exports.createAvatarSnapshotter=ys;exports.createAvatarThumbQueue=Bh;exports.creatureCharacter=Em;exports.creatureSource=Dl;exports.defaultCharacter=_t;exports.defaultCharacterName=ro;exports.disposeNameplate=qo;exports.drawAvatarFace=wa;exports.emoteLabelOf=Bp;exports.emotionFromText=Up;exports.freeAvatarItemsForSlot=Is;exports.humanSource=jo;exports.isAuthorAvatarItem=$h;exports.isAvatarShopItem=zs;exports.isChairEmote=Fp;exports.isDefaultCharacterName=m1;exports.isEmote=pa;exports.isEmotion=fl;exports.isObj=J;exports.layoutCharacter=$a;exports.lerpPose=pn;exports.mirrorBone=ja;exports.nameplate=cn;exports.newAnimInput=so;exports.normColor=ot;exports.npcCharacter=yp;exports.num=Ie;exports.onCharacterKnown=hp;exports.parseAvatarSpec=cr;exports.parseCharacterSpec=Ye;exports.pick=zo;exports.pixelTextureFromImage=Wh;exports.randomAvatar=zh;exports.recolor=Ho;exports.registerCharacter=cp;exports.releaseCharacter=ao;exports.renderAvatarCanvas=dc;exports.renderAvatarImage=Wm;exports.rigOfSpec=p1;exports.sampleEmote=Xn;exports.sampleTrack=dl;exports.setCh=y;exports.specHash=tr;exports.stableStringify=Io;exports.standardFace=Ar;exports.styleParams=aa;exports.validateAvatarItem=pr;exports.vec3=to;
77
+ - When the player sends pictures (possibly of ONE character from different angles: front, side, back) study EVERY picture: get the silhouette, proportions, colours, clothes and the face right. Pictures can be photos, drawings or 3D renders \u2014 turn them into a clean blocky version.`;var ss=["wolf","lion","tiger","panda","pig","cow","sheep","horse","deer","mouse","raccoon","elephant","hedgehog","turtle","frog","duck","chicken","owl","penguin","bat","bee","eagle","fish","shark"],To={h:"#efe6cf",n:"#f2a0a8",r:"#d8342c",y:"#f2a630",d:"#2a2a30",g:"#e8f6ff"},K={mirror:true},Fl=["legFL","legFR","legBL","legBR"];function Te(e,t={}){let r=t.body??[8,8,16],o=t.bodyY??12;e("body","body",r,[0,o,0],"t"),t.belly!==false&&e("belly","body",[r[0]-2,1,r[2]-4],[0,o-r[1]/2,0],"l"),e("head","head",[8,8,8],[0,16,-12],t.head??"s");let a=t.leg??[3,8];for(let n of Fl){let s=n.endsWith("L")?-3:3,l=n.startsWith("legF")?-6:6;e(n,n,[a[0],a[1],a[0]],[s,a[1]/2,l],t.legColor??"t"),t.paw!==null&&e(`${n}Paw`,n,[a[0]+.2,1.5,a[0]+.2],[s,.75,l],t.paw??"a");}}var qr=(e,t="a",r=[4,3,3])=>{e("snout","head",r,[0,14.5,-16-r[2]/2+.5],"l"),e("nose","head",[1.4,1,.6],[0,15.6,-16-r[2]+.4],t);};function $t(e,t={}){let r=t.body??[6,6,8];e("body","body",r,[0,8,0],"t"),e("belly","body",[r[0]-1.4,r[1]-2,1],[0,7.5,-r[2]/2-.2],"l"),e("head","head",[5,5,5],[0,13,-4],t.head??"s");let o=t.wing??[8,1,6];e("wing","wingL",o,[-3-o[0]/2,10,0],t.wingColor??"a",K),e("leg","legL",[1,4,1],[-1.5,2,0],t.legColor??"a",K);}var Bl={bone:"head",rect:[0,1,5,3]};function is(e,t){let r=(a,n,s)=>({rig:"quadruped",style:{walk:a,idle:n,energy:s},palette:To}),o=(a,n,s)=>({rig:"flyer",style:{walk:a,idle:n,energy:s},face:Bl,palette:To});switch(e){case "wolf":return Te(t),t("ear","head",[2.4,3.4,1],[-2.5,21.5,-10.5],"t",K),qr(t,"d"),t("ruff","body",[9,6,3],[0,13,-6.5],"l"),t("tail","tail",[3,3,10],[0,13,13],"t",{rot:[25,0,0]}),t("tailTip","tail",[3.1,3.1,2],[0,14.6,17.5],"l",{rot:[25,0,0]}),r("sneaky","proud",.6);case "lion":return Te(t),t("mane","head",[12,12,3],[0,16,-9.5],"a"),t("maneTop","head",[10,2,6],[0,21,-11.5],"a"),t("ear","head",[2,2,1],[-3,21.4,-12],"s",K),qr(t,"d",[4,2.6,2]),t("tail","tail",[1.4,1.4,10],[0,13,13],"t",{rot:[30,0,0]}),t("tuft","tail",[2.6,2.6,2.6],[0,15.2,18],"a",{rot:[30,0,0]}),r("heavy","proud",.5);case "tiger":Te(t);for(let a of [-5,-1.5,2,5.5])t(`stripe${a}`,"body",[8.3,1,1.1],[0,12.6,a],"d");return t("stripeHead","head",[8.3,1,3],[0,19.8,-11],"d"),t("ear","head",[2,2,1],[-3,21,-10.5],"t",K),qr(t,"n",[4,2.6,2]),t("tail","tail",[1.8,1.8,10],[0,14,13],"t",{rot:[20,0,0]}),t("tailRing","tail",[2,2,1],[0,15,15],"d",{rot:[20,0,0]}),r("sneaky","proud",.6);case "panda":return Te(t,{body:[9,9,15],legColor:"a",paw:"a"}),t("band","body",[9.2,9.2,4],[0,12,-4.5],"a"),t("ear","head",[2.4,2.4,1.2],[-3,21,-11],"a",K),t("nose","head",[1.6,1,.6],[0,15,-16.3],"a"),t("tail","tail",[2,2,2],[0,14,8.5],"l"),r("heavy","calm",.4);case "pig":return Te(t,{leg:[3,6],paw:"a"}),t("snout","head",[3.6,2.6,1.2],[0,14.6,-16.6],"n"),t("nostril","head",[.6,.8,.2],[-0.8,14.6,-17.3],"a",K),t("ear","head",[2.4,2,1],[-2.6,20.6,-10.5],"n",{mirror:true,rot:[-30,0,0]}),t("tail","tail",[1,1,2.6],[0,15,9],"n",{rot:[-40,0,0]}),r("bouncy","fidgety",.7);case "cow":return Te(t,{body:[9,9,16],paw:"d"}),t("spot","body",[9.2,3.6,4],[0,14,-2],"a"),t("spot2","body",[9.2,3,3],[0,11,5],"a"),t("muzzle","head",[6,3,1.6],[0,13.6,-16.6],"n"),t("horn","head",[1,2.4,1],[-2.8,21.2,-11],"h",K),t("ear","head",[2.6,1.2,1],[-5,18.6,-11],"t",K),t("tail","tail",[1,8,1],[0,11,9],"t"),t("tailTip","tail",[1.6,2,1.6],[0,6.6,9],"a"),r("heavy","calm",.3);case "sheep":return Te(t,{body:[10,9,16],leg:[2.6,7],legColor:"a",paw:"d",head:"a",belly:false}),t("woolTop","body",[9,2,13],[0,17,0],"t"),t("woolHead","head",[8.6,2.4,6],[0,20.4,-11.6],"t"),t("ear","head",[2.6,1,1.6],[-5,18,-11],"a",K),t("tail","tail",[2.6,2.6,2],[0,14,9],"t"),r("bouncy","calm",.5);case "horse":return Te(t,{body:[8,8,17],paw:"d"}),t("muzzle","head",[5,4.6,4],[0,13.8,-17.6],"s"),t("nose","head",[5.2,1.6,1],[0,12.6,-19.6],"l"),t("mane","head",[1.6,3,8],[0,21.4,-9],"a"),t("maneNeck","body",[1.6,3,5],[0,17,-5.5],"a"),t("ear","head",[1.4,2.4,1],[-2.4,21.2,-13.4],"s",K),t("tail","tail",[2.2,10,2.2],[0,10,9.4],"a"),r("normal","proud",.7);case "deer":Te(t,{body:[7,8,15]}),qr(t,"d",[3.6,2.8,2.4]),t("ear","head",[2.6,1.4,1],[-5,19.6,-10.5],"t",K),t("antler","head",[.8,4,.8],[-2.4,22,-10.5],"h",K),t("antlerTine","head",[2.6,.8,.8],[-3.4,23.2,-10.5],"h",K),t("antlerTop","head",[.8,2,.8],[-4.3,24.4,-10.5],"h",K);for(let a of [-3,1,4])t(`spot${a}`,"body",[1.4,.4,1.4],[-1.6,16.1,a],"l",K);return t("tail","tail",[2,2.4,1.4],[0,14.6,8.4],"l"),r("bouncy","calm",.6);case "mouse":return Te(t,{body:[7,6,12],bodyY:11,leg:[2.4,8],paw:"n"}),t("ear","head",[3.4,3.4,.8],[-3.6,21.4,-10.6],"t",K),t("earIn","head",[2.2,2.2,.3],[-3.6,21.4,-11.1],"n",K),t("nose","head",[1.2,1,.6],[0,15,-16.3],"n"),t("tail","tail",[.8,.8,11],[0,12,13],"n",{rot:[15,0,0]}),r("sneaky","fidgety",.9);case "raccoon":Te(t,{paw:"d"}),t("mask","head",[8.3,1.4,8.3],[0,17,-12],"d",{shape:"cylinder"}),qr(t,"d",[3.4,2.4,2]),t("ear","head",[2.2,2.4,1],[-2.8,21.2,-10.5],"a",K),t("tail","tail",[3,3,10],[0,14,13],"t",{rot:[20,0,0]});for(let a of [10,13.4,16.8])t(`ring${a}`,"tail",[3.2,3.2,1.4],[0,14+(a-13)*.36,a],"d",{rot:[20,0,0]});return r("sneaky","fidgety",.7);case "elephant":return Te(t,{body:[10,10,16],leg:[4,8],paw:"l"}),t("ear","head",[1,7,6],[-5,16.4,-10.6],"a",K),t("trunk","head",[2.6,4,2.4],[0,12.6,-17.2],"s"),t("trunk2","head",[2.2,4,2.2],[0,9,-17.6],"s"),t("trunkTip","head",[2,1.6,2.6],[0,6.6,-18],"s"),t("tusk","head",[.8,.8,3],[-2.2,12.6,-17.2],"h",K),t("tail","tail",[.8,6,.8],[0,12,8.4],"t"),r("heavy","calm",.3);case "hedgehog":Te(t,{body:[8,6,12],bodyY:10,leg:[2.4,8],paw:"l"}),t("spines","body",[9.4,5,12],[0,13.6,1],"a");for(let a of [-3,1,5])t(`spike${a}`,"body",[1,1.6,1],[-2.4,16.8,a],"a",K);return t("spikeTop","body",[1,1.8,1],[0,16.9,-1],"a"),t("nose","head",[1.4,1.2,1.4],[0,14.6,-16.6],"d"),t("ear","head",[1.4,1.4,.8],[-3,20.6,-10.6],"l",K),r("sneaky","fidgety",.8);case "turtle":return Te(t,{body:[8,5,12],bodyY:9,leg:[3,8],paw:null}),t("shell","body",[11,6,15],[0,13,.6],"a"),t("shellTop","body",[8,1.6,11],[0,16.6,.6],"a"),t("shellRim","body",[11.4,1,15.4],[0,10.4,.6],"l"),t("tail","tail",[1.4,1.4,2.6],[0,11,9],"t"),r("heavy","calm",.2);case "frog":return Te(t,{body:[9,6,12],bodyY:10,leg:[3,8],paw:"a"}),t("eyeBump","head",[2.6,2.4,2.6],[-2.4,21.2,-13],"t",K),t("eyeBall","head",[1.6,1.6,.4],[-2.4,21.4,-14.5],"w",K),t("pupil","head",[.8,.8,.2],[-2.4,21.4,-14.8],"k",K),t("backLeg","legBL",[3.6,3,5],[-3.4,3.5,7.4],"t",K),r("bouncy","calm",.8);case "duck":return $t(t,{wingColor:"t",legColor:"y"}),t("bill","head",[3,.9,2.6],[0,12,-7.6],"y"),t("tail","tail",[3,1,2.4],[0,9.6,5],"t",{rot:[-25,0,0]}),o("bouncy","fidgety",.6);case "chicken":return $t(t,{wing:[3,4,6],wingColor:"t",legColor:"y"}),t("comb","head",[1,2,3.6],[0,16.4,-4],"r"),t("beak","head",[1.4,1,1.6],[0,12.8,-7.2],"y"),t("wattle","head",[.8,1.4,.6],[0,11.2,-6.8],"r"),t("tail","tail",[3,4,3],[0,11,5],"t",{rot:[20,0,0]}),o("bouncy","fidgety",.9);case "owl":return $t(t,{body:[7,7,7],wingColor:"a"}),t("tuft","head",[1,2,1],[-2,16.4,-4],"a",K),t("beak","head",[1,1.2,1],[0,12.4,-7],"y"),t("tail","tail",[3,1,3],[0,6,5],"a"),o("normal","calm",.3);case "penguin":return $t(t,{body:[7,9,6],wing:[3,6,2],wingColor:"t",legColor:"y"}),t("belly2","body",[5,7,.6],[0,7.6,-3.3],"l"),t("beak","head",[1.4,1,1.8],[0,12.6,-7.2],"y"),t("feet","legL",[2,.6,2.4],[-1.5,.3,-0.8],"y",K),o("heavy","fidgety",.6);case "bat":return $t(t,{body:[5,5,5],wing:[9,.6,5],wingColor:"a",legColor:"d"}),t("ear","head",[1.4,2.6,.8],[-1.6,16.6,-4],"t",K),t("fang","head",[.5,.8,.3],[-0.8,11.2,-6.6],"w",K),o("sneaky","fidgety",.8);case "bee":return $t(t,{body:[6,6,8],wing:[5,.4,4],wingColor:"g",legColor:"d"}),t("stripe","body",[6.2,6.2,1.2],[0,8,0],"d"),t("stripe2","body",[6.2,6.2,1.2],[0,8,2.8],"d"),t("stinger","body",[.8,.8,1.6],[0,7.4,4.6],"d"),t("antenna","head",[.4,2.4,.4],[-1.2,16.4,-4.6],"d",K),t("antennaTip","head",[.8,.8,.8],[-1.2,17.8,-4.6],"d",K),o("bouncy","fidgety",1);case "eagle":return $t(t,{body:[6,7,8],wing:[10,1,6],wingColor:"t",legColor:"y",head:"l"}),t("beak","head",[1.6,1.4,2],[0,12.6,-7.4],"y"),t("beakTip","head",[1,1,.8],[0,11.6,-8],"y"),t("tail","tail",[4,1,4],[0,7.4,6],"l"),o("heavy","proud",.6);case "fish":return t("body","body",[5,7,9],[0,6,0],"t"),t("belly","body",[4,1,7],[0,2.4,0],"l"),t("head","head",[5,6,4],[0,6,-6.5],"s"),t("tailFin","tail",[.8,6,4],[0,6,7],"a"),t("dorsal","body",[.8,2.4,4],[0,10.6,0],"a"),t("fin","finL",[3,.6,2],[-4,5,-1],"a",K),{rig:"swimmer",style:{walk:"normal",idle:"calm",energy:.7},face:{bone:"head",rect:[0,1,5,3]},palette:To};case "shark":return t("body","body",[7,7,16],[0,6,1],"t"),t("belly","body",[5.6,1,13],[0,2.4,1],"l"),t("head","head",[7,6,6],[0,6,-9],"s"),t("jaw","head",[6,1.4,5],[0,3.4,-9],"l"),t("dorsal","body",[1,5,4],[0,11.6,0],"t"),t("tailFin","tail",[1,9,5],[0,7,11.4],"t"),t("fin","finL",[4,.8,3],[-5,4,-1],"t",K),{rig:"swimmer",style:{walk:"heavy",idle:"proud",energy:.6},face:{bone:"head",rect:[0,1,7,3]},palette:To}}throw new Error(`unknown creature kind: ${e}`)}var Em=["cat","dog","fox","bear","rabbit","bird","dragon","slime","ghost","robot",...ss],Dl=e=>({k:"#2a1c14",w:"#f4f4ef",b:e,m:"#7a3a30",o:"#3a1a14"});function Nl(e){let t=e.light??e.body,r=e.accent??e.body,o={t:e.body,s:e.body,l:t,a:r,p:r,...Dl(e.eyes??"#3f6f3a")},a=[],n="quadruped",s=Sr("head",[0,3,8,5]),l={walk:"normal",idle:"calm",energy:.6},i=(u,R,w,A,k,x={})=>a.push({name:u,bone:R,size:w,pos:A,color:k,...x});switch(e.kind){case "cat":case "fox":case "dog":case "bear":case "rabbit":{let u=e.kind;i("body","body",[8,8,16],[0,12,0],"t"),i("belly","body",[6,1,12],[0,8,0],"l"),i("head","head",[8,8,8],[0,16,-12],"s");for(let R of ["legFL","legFR","legBL","legBR"]){let w=R.endsWith("L")?-3:3,A=R.startsWith("legF")?-6:6;i(R,R,[3,8,3],[w,4,A],"t"),i(`${R}Paw`,R,[3.2,1.5,3.2],[w,.75,A],"a");}u==="cat"?(i("ear","head",[2,2.5,1],[-2.5,21,-11],"a",{mirror:true}),i("tail","tail",[1.6,1.6,10],[0,15,13],"t",{rot:[20,0,0]}),l={walk:"sneaky",idle:"calm",energy:.5}):u==="fox"?(i("ear","head",[2.4,3.2,1],[-2.5,21.4,-11],"t",{mirror:true}),i("snout","head",[4,3,3],[0,14.5,-17],"l"),i("nose","head",[1.2,1,.6],[0,15.6,-18.6],"a"),i("tail","tail",[3.5,3.5,10],[0,14,13],"t",{rot:[15,0,0]}),i("tailTip","tail",[3.6,3.6,2.5],[0,15.2,18],"l"),l={walk:"bouncy",idle:"fidgety",energy:.7}):u==="dog"?(i("ear","head",[1.5,4,3],[-4.6,17.5,-11.5],"a",{mirror:true}),i("snout","head",[4,3,3],[0,14.5,-17],"l"),i("nose","head",[1.6,1.2,.6],[0,15.8,-18.6],"a"),i("tail","tail",[2,2,7],[0,16,11],"t",{rot:[40,0,0]}),l={walk:"bouncy",idle:"fidgety",energy:.9}):u==="bear"?(i("ear","head",[2,2,1],[-3,20.6,-10.5],"a",{mirror:true}),i("snout","head",[4,3,2.5],[0,14.5,-16.8],"l"),i("nose","head",[1.6,1.2,.6],[0,15.8,-18.2],"a"),i("tail","tail",[2,2,2],[0,14,9],"t"),l={walk:"heavy",idle:"proud",energy:.4}):(i("ear","head",[1.6,7,1],[-1.8,23.5,-11],"t",{mirror:true}),i("earInner","head",[.8,5.5,.4],[-1.8,23.5,-11.6],"l",{mirror:true}),i("tail","tail",[3,3,3],[0,14,9.5],"l"),l={walk:"bouncy",idle:"fidgety",energy:.8});break}case "bird":case "dragon":{n="flyer",s=Sr("head",[0,1,5,3]);let u=e.kind==="dragon";i("body","body",[6,6,8],[0,8,0],"t"),i("belly","body",[4.6,4,1],[0,7.5,-4.2],"l"),i("head","head",[5,5,5],[0,13,-4],"s"),i("wing","wingL",[8,1,6],[-7,10,0],"a",{mirror:true}),i("leg","legL",[1,4,1],[-1.5,2,0],"a",{mirror:true}),u?(i("horn","head",[.8,2,.8],[-1.4,16.4,-3],"l",{mirror:true}),i("snout","head",[3,2,2.4],[0,12.2,-7.4],"s"),i("tail","tail",[2,2,8],[0,7,7],"t"),i("spike","body",[1,1.5,6],[0,11.6,0],"a"),l={walk:"heavy",idle:"proud",energy:.6}):(i("beak","head",[1.6,1.2,2],[0,12.4,-7.2],"a"),i("tail","tail",[4,1,4],[0,8,6],"a"),i("crest","head",[1,2,2],[0,16.2,-3.6],"a"),l={walk:"bouncy",idle:"fidgety",energy:.8});break}case "slime":case "ghost":case "robot":{n="blob",s=Sr("body",[2,3,8,5]),e.kind==="slime"?(i("body","body",[12,10,12],[0,5,0],"t"),l={walk:"bouncy",idle:"fidgety",energy:.9}):e.kind==="ghost"?(i("body","body",[10,12,10],[0,7,0],"t"),i("hem","body",[10.4,2,10.4],[0,1,0],"l",{shape:"cylinder"}),l={walk:"sneaky",idle:"calm",energy:.4}):(i("body","body",[11,11,10],[0,5.5,0],"t"),i("antenna","body",[.8,3,.8],[0,12.5,0],"a"),i("bulb","body",[1.6,1.6,1.6],[0,14.6,0],"l"),i("screen","body",[9,6,.4],[0,6.5,-4.82],"l"),l={walk:"robotic",idle:"calm",energy:.5});break}default:{let u=is(e.kind,i);n=u.rig,l=u.style,u.face&&(s=Sr(u.face.bone,u.face.rect)),Object.assign(o,u.palette);}}jl(a);let c=e.kind==="slime"||e.kind==="ghost"?"body":"head";for(let u of a)u.name===c&&u.bone===s.face.bone&&(u.shape="cylinder");let[p,h,m,d]=s.face.rect,b=[p+m*ls,h,m*(1-2*ls),d];return {version:1,name:e.name,description:e.description??"",rig:n,palette:o,textures:s.textures,parts:a,face:{...s.face,rect:b,drawn:{...ql(e.kind),eyeColor:e.eyes??Gl}},style:l,finish:Hl,tags:e.tags??[e.kind]}}var Hl={noise:0,outline:0,shade:.12,density:4,round:.35},ur=1.5;function jl(e){let t=e,r=p=>p.size[0]*p.size[1]*p.size[2],o=p=>t.filter(h=>h.bone===p).sort((h,m)=>r(m)-r(h))[0],a=o("body");if(!a)return;let n=(p,h)=>p.pos[h]-p.size[h]/2,s=(p,h)=>p.pos[h]+p.size[h]/2;for(let p of ["legFL","legFR","legBL","legBR","legL","legR"]){let h=o(p);if(!h||s(h,1)>n(a,1)+ur||s(h,1)<n(a,1)-3)continue;let m=n(h,1),d=n(a,1)+ur;h.size[1]=d-m,h.pos[1]=(d+m)/2;}let l=(p,h,m)=>{for(let d of t)d.bone===p&&(d.pos[h]=d.pos[h]+m);},i=o("head");if(i&&i.pos[2]<n(a,2)){let p=n(a,2)+ur-s(i,2);p>0&&l("head",2,p);}let c=o("tail");if(c&&c.pos[2]>s(a,2)){let p=n(c,2)-(s(a,2)-ur);p>0&&l("tail",2,-p);}for(let p of [o("wingL"),o("finL")]){if(!p)continue;let h=n(a,0)+ur,m=s(p,0);m<h&&(p.size[0]=p.size[0]+(h-m),p.pos[0]=p.pos[0]+(h-m)/2);}if(i)for(let p of t){if(p.bone!=="head"||p===i)continue;let h=n(p,1)-(s(i,1)-ur/2);h>0&&n(p,1)<s(i,1)+.6&&(p.pos[1]=p.pos[1]-h);}}var Gl="#2a1c14",ls=.07;function ql(e){let t=(r,o,a=true)=>({eyes:r,brows:"none",mouth:o,cheeks:a});switch(e){case "cat":case "fox":case "lion":case "tiger":return t("cat","cat");case "dog":case "wolf":case "rabbit":case "mouse":case "raccoon":case "hedgehog":return t("round","cat");case "dragon":return t("almond","fang",false);case "slime":return t("sparkle","smile");case "ghost":return t("round","open",false);case "robot":return t("button","smile",false);case "owl":case "frog":return t("wide","smile");case "shark":return t("narrow","teeth",false);case "fish":return t("round","pout",false);case "bat":return t("round","fang");case "bee":case "turtle":return t("button","smile");default:return t("round","small")}}function Sm(e){let t=Ye(Nl(e));if(!t.ok)throw new Error(`${e.kind}: ${t.error}`);return t.spec}var cs={torso:"#d9d3c5",legs:"#5f6b7a"},Ul="#2b2140",Kl="#7a2e2e",Yl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Wl=32,$l=[10,7],Ur=1,Jl={noise:0,outline:0,shade:.12,density:4,round:.35},Xl=["front","back","left","right"];function ps(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}var va=class{map={};next=0;key(t){let r=Object.entries(this.map).find(([,i])=>i===t);if(r)return r[0];if(this.next<Wl){let i=Yl[this.next++];return this.map[i]=t,i}let[o,a,n]=ps(t),s=Object.keys(this.map)[0],l=1/0;for(let[i,c]of Object.entries(this.map)){let[p,h,m]=ps(c),d=(o-p)**2+(a-h)**2+(n-m)**2;d<l&&(l=d,s=i);}return s}};function Ql(e,t){return (typeof e=="function"?e(t):e[t])??null}function Zl(e){let[t,r]=$l,o=new U(t,r),a=n=>{n(1),n(6);};switch(e){case "blink":case "tired":a(n=>o.row(3,n,n+2,"k"));break;case "happy":a(n=>o.px(n,3,"k").px(n+1,2,"k").px(n+2,3,"k"));break;case "hurt":o.px(1,2,"k").px(2,3,"k").px(1,4,"k"),o.px(8,2,"k").px(7,3,"k").px(8,4,"k");break;case "surprised":case "scared":a(n=>o.rect(n,2,3,3,"w").px(n+1,3,"k"));break;default:a(n=>o.rect(n,2,3,3,"w").rect(n+1,3,2,2,"e").px(n+1,3,"k"));}switch(e==="angry"&&o.px(1,1,"k").px(2,1,"k").px(3,2,"k").px(8,1,"k").px(7,1,"k").px(6,2,"k"),e==="sad"&&o.px(3,1,"k").px(2,1,"k").px(6,1,"k").px(7,1,"k"),e){case "happy":case "talk":o.rect(4,5,2,2,"m");break;case "surprised":o.rect(4,5,2,2,"m");break;case "sad":o.px(3,6,"m").row(5,4,5,"m").px(6,6,"m");break;case "angry":case "tired":case "scared":case "hurt":o.row(6,4,5,"m");break;default:o.px(3,5,"m").row(6,4,5,"m").px(6,5,"m");}return o.tex()}function Aa(e,t){let r=Ae[Zt],o=new va,a=o.key(e.body.skin),n=r.defaultParts.map(d=>({...d,size:[...d.size],pos:[...d.pos],color:d.name==="torso"?o.key(cs.torso):d.name?.startsWith("leg")||d.name?.startsWith("foot")?o.key(cs.legs):a})),s=new Map;for(let d of n){let b=s.get(d.name)??[];b.push(d),s.set(d.name,b);}for(let d of s.values())d.sort((b,u)=>u.pos[1]+u.size[1]/2-(b.pos[1]+b.size[1]/2));let l=(e.body.head??xa)==="round";if(l)for(let d of n)d.name==="head"?(d.shape="cylinder",d.size=[d.size[0],d.size[1]+Ur,d.size[2]],d.pos=[d.pos[0],d.pos[1]+Ur/2,d.pos[2]]):d.name==="neck"&&(d.size=[2.6,1.8,2.4],d.pos=[0,23.1,0]);let i={},c={k:o.key(Ul),w:o.key("#ffffff"),e:o.key(e.face.eyeColor),m:o.key(Kl)},p={};for(let d of kr){let b=Zl(d),u="face_"+d;i[u]={...b,rows:b.rows.map(R=>[...R].map(w=>c[w]??w).join(""))},p[d]=u;}p.neutral=p[es[e.face.emotion]]??p.neutral;for(let d of Kt){let b=e.wear[d];if(!b)continue;let u=Ql(t,b);if(!u||u.slot!==d||u.style!==je)continue;let R={};for(let[x,f]of Object.entries(u.palette))R[x]=f===qt?a:o.key(x===u.tint&&e.tint[d]?e.tint[d]:f);let w={};for(let[x,f]of Object.entries(u.textures)){let S=`${d}_${x}`;w[x]=S,i[S]={w:f.w,h:f.h,rows:f.rows.map(T=>[...T].map(C=>R[C]??C).join(""))};}let A=x=>{if(!x)return;let f={};for(let[S,T]of Object.entries(x)){let C=w[T]??R[T];C&&(f[S]=C);}return Object.keys(f).length?f:void 0};for(let x of u.paint){let f=s.get(x.region);if(!f)continue;let S=R[x.color],T=A(x.faces);f.forEach((C,z)=>{S&&(C.color=S);let O=T&&ec(T,f,z,i);O?C.faces=O:delete C.faces;});}let k=d==="hair"||d==="hat"||d==="faceAcc"&&!u.parts.some(x=>x.mat);for(let x of u.parts){let f={bone:x.bone,size:[...x.size],pos:[...x.pos],color:R[x.color]??a},S=A(x.faces);if(S&&(f.faces=S),x.rot&&(f.rot=[...x.rot]),x.mirror&&(f.mirror=true),x.name&&(f.name=x.name),x.mat&&(f.mat=x.mat),l&&x.bone===r.faceBone){let T=d==="hair"||d==="hat"?Ur:Ur/2;f.pos=[f.pos[0],f.pos[1]+T,f.pos[2]],k&&(f.wrap=true);}n.push(f);}}let h={version:1,name:"Avatar",description:"",rig:Zt,scale:e.body.height,palette:o.map,textures:i,parts:n,bones:[],face:{bone:r.faceBone,rect:l?[St[0],St[1]+Ur/2,St[2],St[3]]:[...St],expressions:p},style:{walk:e.anim?.walk??ct.walk,idle:e.anim?.idle??ct.idle,energy:.6},voice:{pitch:1},tags:["avatar",je],finish:{...Jl}},m=Ye(h);if(!m.ok)throw new Error("composeAvatar: "+m.error);return m.spec}function ec(e,t,r,o){if(t.length===1)return {...e};let a=t[0].pos[1]+t[0].size[1]/2,n=Math.min(...t.map(c=>c.pos[1]-c.size[1]/2)),s=Math.max(1e-6,a-n),l=c=>c<=0?0:c>=t.length?1:(a-(t[c-1].pos[1]-t[c-1].size[1]/2))/s,i={};for(let[c,p]of Object.entries(e)){let h=o[p];if(!h){i[c]=p;continue}if(c==="top"){r===0&&(i[c]=p);continue}if(c==="bottom"){r===t.length-1&&(i[c]=p);continue}if(!Xl.includes(c))continue;let m=Math.min(h.h-1,Math.round(l(r)*h.h)),d=Math.max(m+1,Math.round(l(r+1)*h.h)),b=`${p}_${r}`;o[b]||(o[b]={w:h.w,h:d-m,rows:h.rows.slice(m,d)}),i[c]=b;}return Object.keys(i).length?i:void 0}var tc={paths:[{x:243,y:-2,d:"M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"},{x:243,y:-2,d:"M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"},{x:243,y:-2,d:"M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"},{x:-460,y:467,d:"M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"},{x:-106,y:244,d:"M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"}]},rc={helmet:{paths:[0,1,2],box:[258,10,353,447]},wordmark:{paths:[3,4],box:[12,499,837,182]}},oc={"top.idos":{color:"#f8f8fc",faces:["front","back"],layers:[{art:"helmet",y:19.4,z:2.3,height:3.9},{art:"wordmark",y:14.85,z:2.15,width:6.2}]}},ms=512,ds=.02,hs=new Map;function ac(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}function nc(e,t,r){let o=`${e}:${r}`,a=hs.get(o);if(a)return a;if(typeof Path2D>"u")return null;let[n,s,l,i]=t.box,c=i*ds,p=ms/(i+2*c),h=ac(Math.round((l+2*c)*p),ms),m=h.getContext("2d");if(!m)return null;m.clearRect(0,0,h.width,h.height),m.fillStyle=r;for(let b of t.paths){let u=tc.paths[b];m.setTransform(p,0,0,p,(u.x-n+c)*p,(u.y-s+c)*p),m.fill(new Path2D(u.d));}let d=new D__namespace.CanvasTexture(h);return d.colorSpace=D__namespace.SRGBColorSpace,d.anisotropy=4,hs.set(o,d),d}function Ea(e){let t=[];for(let r of Kt){let o=e.wear[r],a=o?oc[o]:void 0;if(a)for(let n of a.layers){let s=rc[n.art],l=nc(n.art,s,a.color);if(!l)continue;let[,,i,c]=s.box,p=i/c,h=n.height??(n.width??1)/p,m=n.width??h*p,d=2*ds*h;for(let b of a.faces){let u=(b==="front"?-1:1)*(n.z+.03),R=[0,n.y,u];t.push({bone:"body",center:R,w:m+d,h:h+d,facing:b,texture:l});}}}return t}var Lo=class extends So{face;rest;mood="neutral";constructor(t,r,o={}){let a=new dr(t.face);super(Aa(t,r),{gloss:true,shadows:true,...o,facePainter:a}),this.face=a,this.rest=t.face.emotion,this.view.setPrints(Ea(t)),this.applyMood();}setEmotion(t){this.mood=t,this.applyMood();}setAvatar(t,r){this.face.setFace(t.face),this.rest=t.face.emotion,this.setSpec(Aa(t,r)),this.view.setPrints(Ea(t)),this.applyMood();}applyMood(){super.setEmotion(this.mood==="neutral"?this.rest:this.mood),this.animator.moodOverGestures=this.rest!=="neutral";}dispose(){super.dispose(),this.face.dispose();}};var ic=1.12,lc=.25,us=1.6;function fs(e){e.outputColorSpace=D__namespace.SRGBColorSpace,e.toneMapping=D__namespace.NeutralToneMapping,e.toneMappingExposure=ic,e.shadowMap.enabled=true,e.shadowMap.type=D__namespace.PCFShadowMap;let t=new D__namespace.PMREMGenerator(e),r=new RoomEnvironment_js.RoomEnvironment,o=t.fromScene(r,.04).texture;return r.dispose(),t.dispose(),{light(a){a.environment=o,a.environmentIntensity=lc,a.add(new D__namespace.HemisphereLight(14543103,8019024,.6));let n=new D__namespace.DirectionalLight(16772829,3.4);n.position.set(4,4.4,-2.2),n.castShadow=true;let s=n.shadow.camera;s.left=s.bottom=-us,s.right=s.top=us,s.near=.5,s.far=12,n.shadow.mapSize.set(1024,1024),n.shadow.bias=-5e-4,n.shadow.normalBias=.02,n.shadow.radius=4,n.shadow.intensity=.55,n.target.position.set(0,1,0),a.add(n,n.target);let l=new D__namespace.DirectionalLight(13623551,.45);l.position.set(-3,.8,-3),a.add(l);let i=new D__namespace.DirectionalLight(14478591,2.6);i.position.set(-3.2,2.6,2.6),a.add(i);},dispose(){o.dispose();}}}function cc(e){if(e==="walk")return .3;if(e==="idle")return 1.2;let t=$e[e];return t.loop?1:t.duration*.4}var Wm=["#a99cff","#5b4bd6"];function pc(e,t){switch(t){case "full":return {center:new D__namespace.Vector3(0,e*.5,0),size:e*1.12,lift:.04};case "torso":return {center:new D__namespace.Vector3(0,e*.57,0),size:e*.5,lift:.06};case "legs":return {center:new D__namespace.Vector3(0,e*.2,0),size:e*.5,lift:.1};case "feet":return {center:new D__namespace.Vector3(0,e*.08,0),size:e*.32,lift:.3};case "face":return {center:new D__namespace.Vector3(0,e*.86,0),size:e*.34,lift:.04};case "head":return {center:new D__namespace.Vector3(0,e*.88,0),size:e*.5,lift:.08};default:return {center:new D__namespace.Vector3(0,e*.8,0),size:e*.56,lift:.08}}}function mc(e){let t=e.view.spec.parts,r=t.find(a=>a.name==="head"),o=0;for(let a of t)o=Math.max(o,a.pos[1]+a.size[1]/2);return !r||o<=0?e.height:Math.min(e.height,e.height*(r.pos[1]+r.size[1]/2)*hc/o)}var hc=1.022;function dc(e){return typeof e=="number"?e:e==="side"?Math.PI/2:e==="back"?Math.PI:.18}function bs(e,t,r,o,a,n,s){let l=s.frame??"portrait",i={...a,face:{...a.face,emotion:"neutral"}},c=new Lo(i,n,{seed:7});try{e.setClearColor(0,0);let p=new D__namespace.Scene;t.light(p),c.group.rotation.y=dc(s.view),p.add(c.group);for(let f=0;f<20;f++)c.update(1/30);let h=s.motion;if(h){h==="walk"?c.setPose("walk"):h!=="idle"&&c.playEmote(h);let f=Math.round(Math.max(0,s.at??cc(h))*30);for(let S=0;S<f;S++)c.update(1/30);}if(!h||h==="walk"||h==="idle"||s.expression){let f=s.expression??a.face.emotion;c.view.setExpression(cr[f][0],f);}let{center:m,size:d,lift:b}=pc(l==="full"||l==="head"?c.height:mc(c),l),u=28,R=new D__namespace.PerspectiveCamera(u,1,.05,50),w=d/2/Math.tan(D__namespace.MathUtils.degToRad(u/2));R.position.set(m.x,m.y+d*b,m.z-w),R.lookAt(m),e.render(p,R);let A=document.createElement("canvas");A.width=o,A.height=o;let k=A.getContext("2d");if(!k)return r;let x=s.background;if(typeof x=="string")k.fillStyle=x,k.fillRect(0,0,o,o);else if(x){let f=k.createRadialGradient(o*.5,o*.38,o*.05,o*.5,o*.5,o*.72);f.addColorStop(0,x[0]),f.addColorStop(1,x[1]),k.fillStyle=f,k.fillRect(0,0,o,o);}return k.imageSmoothingEnabled=!s.pixelated,k.drawImage(r,0,0),A}finally{c.dispose();}}function ys(e,t){let r=document.createElement("canvas");r.width=e,r.height=e;let o=new D__namespace.WebGLRenderer({canvas:r,antialias:!t,alpha:true,preserveDrawingBuffer:true});return o.setPixelRatio(1),o.setSize(e,e,false),{renderer:o,lighting:fs(o),gl:r}}function gs(e){e.lighting.dispose(),e.renderer.dispose(),e.renderer.forceContextLoss();}function uc(e,t,r={}){let o=Math.max(16,Math.round(r.size??256)),a=ys(o,!!r.pixelated);try{return bs(a.renderer,a.lighting,a.gl,o,e,t,r)}finally{gs(a);}}function xs(e={}){let t=Math.max(16,Math.round(e.size??256)),r=ys(t,!!e.pixelated);return {render(o,a,n={}){if(!r)throw new Error("snapshotter disposed");return bs(r.renderer,r.lighting,r.gl,t,o,a,{...n,pixelated:e.pixelated})},dispose(){r&&(gs(r),r=null);}}}function $m(e,t,r={}){let o=uc(e,t,r);return new Promise(a=>o.toBlob(n=>a(n),"image/png"))}function Jm(e){if(!e?.spec)return null;let t={};for(let r of e.items??[])r&&typeof r.id=="string"&&(t[r.id]=r);return {spec:pr(e.spec),items:t}}function Me(e,t){let r=mr(e);if(!r.ok)throw new Error(`avatar set: ${String(e.id)}: ${r.errors.join("; ")}`);return t===void 0?{item:r.item}:{item:r.item,price:t}}var Z=e=>({w:e[0].length,h:e.length,rows:e}),g=(e,t,r,o={})=>({bone:"head",size:e,pos:t,color:r,...o}),L=(e,t,r,o={})=>({bone:"body",size:e,pos:t,color:r,...o}),W=(e,t,r,o,a={})=>({bone:e,size:t,pos:r,color:o,mirror:true,...a});var tt=(e,t,r,o,a,n)=>Me({id:`back.${e}`,slot:"back",name:t,palette:r,tint:o,parts:a},n),Tt=(e,t,r,o,a,n)=>Me({id:`neck.${e}`,slot:"neck",name:t,palette:r,tint:o,parts:a},n),ce={mirror:true},ws=[L([2.25,7.5,1.47],[1.69,21.15,3.04],"b",ce),L([10.13,3.13,.74],[7.31,26.15,3.86],"a",ce),L([10.13,3.13,.74],[7.88,23.03,4.05],"b",ce),L([9,3.13,.74],[8.44,19.9,4.23],"a",ce),L([6.75,3.13,.74],[9,16.77,4.42],"b",ce),L([4.5,3.13,.74],[9.56,13.65,4.6],"a",ce)],Rs=[tt("shield","Round shield",{a:"#a32d2d",b:"#d8b030",c:"#5a3a22"},"a",[L([8,8,.8],[0,17.5,3.4],"a"),L([8.6,.8,1],[0,21.6,3.4],"c"),L([8.6,.8,1],[0,13.4,3.4],"c"),L([2.2,2.2,.8],[0,17.5,4.2],"b",{mat:"metal"})]),tt("skateboard","Skateboard",{a:"#2ab0c0",b:"#1d1d21",c:"#f4f1ea"},"a",[L([3,11,.5],[0,18,3.4],"a"),L([1,1,1],[1,13.4,3.9],"c",ce),L([1,1,1],[1,22.6,3.9],"c",ce)]),tt("rocketpack","Rocket pack",{a:"#c8ccd2",b:"#2b2140",f:"#ff8a2a"},null,[L([2.6,7,2.6],[1.6,17.5,3.8],"a",{mirror:true,mat:"metal"}),L([1.8,.8,1.8],[1.6,13.6,3.8],"b",ce),L([1.4,3,1.4],[1.6,11.6,3.8],"f",{mirror:true,mat:"glow"}),L([2.8,.8,2.8],[1.6,21.4,3.8],"b",ce)],250),tt("guitar","Guitar",{a:"#c0612b",b:"#3a2414",c:"#1d1d21"},"a",[L([5,5,1.4],[0,12.5,3.6],"a"),L([1,9,.8],[0,19.5,3.6],"b"),L([1.6,1.8,.9],[0,24.9,3.6],"b"),L([1.4,1.4,.2],[0,12.8,4.35],"c")],150),tt("batwings","Bat wings",{a:"#3c2f5a",b:"#241a3a"},"a",ws,200),tt("dragonwings","Dragon wings",{a:"#3c9a3c",b:"#2a6a2a",c:"#e8d27a"},"a",[...ws.slice(0,5),L([1,1.6,1],[12.2,28.3,3.86],"c",ce)],250),tt("butterfly","Butterfly wings",{a:"#f2a03a",b:"#2b2140"},"a",[L([6,7,.4],[4.2,21,3.2],"a",ce),L([4.6,5,.4],[3.6,15,3.2],"a",ce),L([1.4,1.4,.3],[5,22.4,3.5],"b",ce),L([1,1,.3],[3.8,15,3.5],"b",ce)],180),tt("fairy","Fairy wings",{a:"#c8f0ff",b:"#f6c8ff"},"a",[L([4.6,7,.3],[3.5,22,3],"a",{mirror:true,mat:"glass"}),L([3.4,4.6,.3],[3,16,3],"b",{mirror:true,mat:"glass"})],200),tt("quiver","Quiver",{a:"#7a4f2a",b:"#c8ccd2",c:"#f4f1ea"},"a",[L([2.4,8,2.4],[1.8,20,3.8],"a"),L([.4,3,.4],[1.2,25.5,3.6],"b"),L([.4,3,.4],[2.4,25.8,4],"b"),L([.8,.8,.3],[1.2,27.2,3.6],"c"),L([.8,.8,.3],[2.4,27.5,4],"c")],120),tt("shell","Turtle shell",{a:"#4c8a3a",b:"#2f5a24",c:"#c8b070"},"a",[L([8.6,9,2.8],[0,17.5,3.6],"a"),L([9.2,.9,3],[0,13,3.6],"c"),L([4,4,.4],[0,18,5.15],"b")],150)],ks=[Tt("scarf","Scarf",{a:"#c0392b",b:"#f4f1ea"},"a",[L([6,1.8,5.4],[0,22.5,0],"a"),L([1.6,4.5,.6],[1.2,19.4,-2.7],"a"),L([1.6,3.4,.6],[-0.6,19.9,-2.95],"b")]),Tt("bowtie","Bow tie",{a:"#c0392b"},"a",[L([.6,.7,.6],[0,21.9,-2.6],"a"),L([1.2,1.2,.4],[.85,21.9,-2.55],"a",ce)]),Tt("bandana","Neck scarf",{a:"#2f5fd0"},"a",[L([6,1.4,5],[0,22.4,0],"a"),L([4,1.6,.6],[0,21,-2.6],"a"),L([2.4,1.2,.6],[0,19.8,-2.6],"a"),L([1,.8,.6],[0,19,-2.6],"a")]),Tt("chain","Gold chain",{a:"#e8b730"},null,[L([5.4,.5,4.8],[0,22.3,0],"a",{mat:"metal"}),L([.5,2.2,.4],[0,21,-2.55],"a",{mat:"metal"}),L([1.2,1.2,.4],[0,19.6,-2.6],"a",{mat:"metal"})],150),Tt("medal","Medal",{a:"#e8b730",b:"#2f5fd0"},"b",[L([5.4,.5,4.8],[0,22.3,0],"b"),L([1.2,3.4,.3],[0,20.4,-2.5],"b"),L([1.6,1.6,.4],[0,18.3,-2.6],"a",{mat:"metal"})],120),Tt("heart","Heart pendant",{a:"#e8436b",b:"#c8ccd2"},"a",[L([5.4,.4,4.8],[0,22.3,0],"b",{mat:"metal"}),L([.3,2.4,.3],[0,20.9,-2.5],"b",{mat:"metal"}),L([1.4,1.2,.4],[0,19.3,-2.6],"a"),L([.7,.5,.4],[.35,20,-2.6],"a",ce)],100),Tt("lei","Flower lei",{a:"#4c9a4a",b:"#f08cb4",c:"#f2d33c",d:"#f4f1ea",e:"#ef9f27"},null,[L([6,1,5.4],[0,22.4,0],"a"),L([1.3,1.3,1.3],[2.4,21.4,-2.6],"b",ce),L([1.3,1.3,1.3],[0,20.9,-2.8],"c"),L([1.3,1.3,1.3],[3,22,0],"d",ce),L([1.3,1.3,1.3],[2,21.8,2.6],"e",ce)],120),Tt("headphones","Headphones on the neck",{a:"#2b2140",b:"#4be0c8"},"b",[L([1.4,2,2.2],[3.6,22.2,-0.2],"a",ce),L([.3,1.4,1.6],[4.35,22.2,-0.2],"b",{mirror:true,mat:"glow"}),L([6,.7,.8],[0,21.6,2.2],"a")],150)];var Sa=e=>({front:e,back:e,left:e,right:e}),rt=(e,t,r,o,a,n)=>Me({id:`bottom.${e}`,slot:"bottom",name:t,palette:r,tint:o,textures:a.textures??{},paint:a.paint,parts:a.parts??[]},n),vs=[rt("sweatpants","Sweatpants",{a:"#8a8f98",b:"#6a6f78"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[4.4,1,4.4],[2.1,1.4,0],"b")]}),rt("leggings","Leggings",{a:"#1d1d21",w:"#f4f1ea"},"a",{textures:{st:Z(["aawa","aawa","aawa","aawa"])},paint:[{region:"legs",color:"a",faces:{left:"st",right:"st"}}]}),rt("pleated","Pleated skirt",{a:"#2b2140",b:"#3c3450",s:"@skin"},"a",{textures:{pl:Z(["abababab","abababab","abababab","abababab"])},paint:[{region:"legs",color:"s"}],parts:[L([10.4,4.8,5.6],[0,11.3,0],"a",{faces:Sa("pl")})]}),rt("joggers","Joggers",{a:"#2f5fd0",b:"#1d3f90"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[4.3,1.2,4.3],[2.1,1.3,0],"b")]}),rt("plaidskirt","Plaid skirt",{a:"#a32d2d",b:"#2b2140",s:"@skin"},"a",{textures:{pl:Z(["abaabaab","bbbbbbbb","abaabaab","abaabaab","bbbbbbbb","abaabaab"])},paint:[{region:"legs",color:"s"}],parts:[L([10.13,4.38,5.52],[0,11.46,0],"a",{faces:Sa("pl")})]},100),rt("denimshorts","Denim shorts",{a:"#3f6fd8",b:"#6a8fe8",s:"@skin"},"a",{paint:[{region:"legs",color:"s"}],parts:[W("legR",[4.62,5.4,4.62],[2.1,9.7,0],"a"),W("legR",[4.8,.8,4.8],[2.1,7.3,0],"b")]},80),rt("ripped","Ripped jeans",{a:"#2f5fd0",s:"@skin"},"a",{textures:{rp:Z(["aaaa","asaa","aaaa","aaaa","assa","aaaa"])},paint:[{region:"legs",color:"a",faces:{front:"rp"}}]},100),rt("camo","Camo pants",{a:"#5a6b3a",b:"#3a4a28",c:"#8a8a5a"},"a",{textures:{cm:Z(["aabbac","abbaac","caabba","ccaaba","abccaa","aabcca"])},paint:[{region:"legs",color:"a",faces:Sa("cm")}]},120),rt("tutu","Tutu",{a:"#f08cb4",b:"#ffc0d8",c:"#f4d8e4"},"a",{paint:[{region:"legs",color:"c"}],parts:[L([12,1.6,8],[0,12.5,0],"a"),L([11,1.2,7.2],[0,11.4,0],"b")]},150),rt("flares","Flared pants",{a:"#c87f17",b:"#a8670f"},"a",{paint:[{region:"legs",color:"a"}],parts:[W("shinR",[5.2,3,5.2],[2.1,2.3,0],"a")]},100)];var G=-4.75,Jt=(e,t="a",r)=>[g([1.7,.3,.3],[3.6,e,G],t,{mirror:true,...r?{mat:r}:{}}),g([.3,.3,4.4],[4.45,e,-2.55],t,{mirror:true,...r?{mat:r}:{}})],Le=(e,t,r,o,a,n)=>Me({id:`face.${e}`,slot:"faceAcc",name:t,palette:r,tint:o,parts:a},n),fr={"face.glasses":Le("glasses","Round glasses",{a:"#2b2140",g:"#cfe8ff"},"a",[g([2.6,.3,.3],[1.6,27.1,G],"a",{mirror:true}),g([2.6,.3,.3],[1.6,24.5,G],"a",{mirror:true}),g([.3,2.9,.3],[2.9,25.8,G],"a",{mirror:true}),g([.3,2.9,.3],[.3,25.8,G],"a",{mirror:true}),g([2.3,2.3,.15],[1.6,25.8,G],"g",{mirror:true,mat:"glass"}),...Jt(26.6)]).item,"face.shades":Le("shades","Sunglasses",{a:"#1d1d21",g:"#2a2a30"},"a",[g([2.8,2.1,.3],[1.6,25.85,G],"g",{mirror:true,mat:"glass"}),g([6.8,.42,.36],[0,26.95,G],"a"),g([.36,1.6,.36],[3.05,26.1,G],"a",{mirror:true}),...Jt(26.75)]).item,"face.visor":Le("visor","Cyber visor",{a:"#33e0ff",b:"#1d1d21"},"a",[g([8.6,1.8,.35],[0,25.9,-4.6],"a",{mat:"glow"}),g([.4,1.2,2.4],[4.35,26,-3.4],"b",{mirror:true}),g([.3,.6,7.6],[4.45,26.2,.4],"b",{mirror:true}),g([8.9,.6,.3],[0,26.2,4.45],"b")]).item},As=[Le("mask","Face mask",{a:"#9ad0f0",b:"#f4f1ea"},"a",[g([6.4,2.8,.6],[0,23.6,-4.15],"a"),g([.4,2.4,1.6],[3.35,23.7,-3.35],"a",{mirror:true}),g([.25,.25,3],[4.35,24.9,-1.9],"b",{mirror:true})]),Le("clownnose","Clown nose",{a:"#e0302a",b:"#ffffff"},"a",[g([1.4,1.3,1.2],[0,24.9,-4.55],"a"),g([.4,.4,.2],[-0.3,25.25,-5.2],"b")]),Le("mustache","Mustache",{a:"#3b2a20"},"a",[g([3.4,.7,.5],[0,24.45,-4.25],"a"),g([.9,.9,.5],[1.95,24.3,-4.25],"a",{mirror:true})]),Le("beard","Beard",{a:"#3b2a20"},"a",[g([6.4,1.4,1.4],[0,22.2,-3.5],"a"),g([1.3,3.4,5.2],[3.75,23.6,-1.4],"a",{mirror:true}),g([2.4,.8,.5],[0,23.05,-4.25],"a"),g([3.6,.7,.5],[0,24.45,-4.25],"a")],120),Le("aviators","Aviators",{a:"#d8b030",g:"#c8843a"},"g",[g([2.6,1.6,.2],[1.6,26,G],"g",{mirror:true,mat:"glass"}),g([2,.8,.2],[1.6,24.85,G],"g",{mirror:true,mat:"glass"}),g([6.8,.25,.3],[0,26.85,G],"a",{mat:"metal"}),g([1,.25,.3],[0,26.35,G],"a",{mat:"metal"}),g([.25,2,.3],[2.95,25.8,G],"a",{mirror:true,mat:"metal"}),...Jt(26.7,"a","metal")],150),Le("square","Square glasses",{a:"#1d1d21",g:"#e0f0ff"},"a",[g([2.8,.45,.4],[1.6,27,G],"a",{mirror:true}),g([2.8,.45,.4],[1.6,24.6,G],"a",{mirror:true}),g([.45,2.4,.4],[3,25.8,G],"a",{mirror:true}),g([.45,2.4,.4],[.2,25.8,G],"a",{mirror:true}),g([2.2,2,.15],[1.6,25.8,G],"g",{mirror:true,mat:"glass"}),...Jt(26.7),g([.6,.3,.3],[0,26.3,G],"a")],100),Le("hearts","Heart glasses",{a:"#e8436b",b:"#ff8fb0"},"a",[g([2.6,1.3,.3],[1.6,26.1,G],"b",{mirror:true,mat:"glass"}),g([1.7,.8,.3],[1.6,25.1,G],"b",{mirror:true,mat:"glass"}),g([.8,.6,.3],[1.6,24.5,G],"b",{mirror:true,mat:"glass"}),g([1.1,.7,.32],[1,26.9,G],"a",{mirror:true}),g([1.1,.7,.32],[2.2,26.9,G],"a",{mirror:true}),g([.8,.3,.3],[0,26.3,G],"a"),...Jt(26.6)],120),Le("stars","Star glasses",{a:"#d8b030",b:"#ffe27a"},"a",[g([2.8,.9,.3],[1.6,26,G],"b",{mirror:true,mat:"glass"}),g([1.2,2.6,.3],[1.6,25.8,G],"b",{mirror:true,mat:"glass"}),g([.6,.7,.32],[1.6,27.3,G],"a",{mirror:true}),g([.8,.3,.3],[0,26.3,G],"a"),...Jt(26.6)],120),Le("goggles","Ski goggles",{a:"#2f5fd0",g:"#ff9a3c"},"a",[g([7.6,2.4,.4],[0,25.9,-4.8],"g",{mat:"glass"}),g([8.2,.5,.6],[0,27.35,-4.6],"a"),g([8.2,.5,.6],[0,24.45,-4.6],"a"),g([.5,1.4,8.6],[4.5,25.9,0],"a",{mirror:true}),g([9.4,1.4,.5],[0,25.9,4.5],"a")],150),Le("monocle","Monocle",{a:"#d8b030",g:"#e0f0ff"},null,[g([2.4,.25,.25],[-1.6,27,G],"a",{mat:"metal"}),g([2.4,.25,.25],[-1.6,24.6,G],"a",{mat:"metal"}),g([.25,2.4,.25],[-2.8,25.8,G],"a",{mat:"metal"}),g([.25,2.4,.25],[-0.4,25.8,G],"a",{mat:"metal"}),g([2.2,2.2,.12],[-1.6,25.8,G],"g",{mat:"glass"}),g([.2,3.2,.2],[-2.9,22.9,-4.7],"a",{mat:"metal"})],150),Le("3d","3D glasses",{a:"#f4f1ea",r:"#e0302a",c:"#2f8fe0"},null,[g([6.9,.5,.35],[0,27,G],"a"),g([6.9,.5,.35],[0,24.6,G],"a"),g([.5,2.9,.35],[3.2,25.8,G],"a",{mirror:true}),g([.8,2.9,.35],[0,25.8,G],"a"),g([2.3,1.9,.15],[1.6,25.8,G],"r",{mat:"glass"}),g([2.3,1.9,.15],[-1.6,25.8,G],"c",{mat:"glass"}),...Jt(26.6)],100),Le("eyepatch","Eye patch",{a:"#1d1d21"},null,[g([2.6,2.4,.4],[1.6,25.9,-4.3],"a"),g([5,.4,.3],[-1,27.3,-4.3],"a"),g([.3,.5,8.6],[4.4,27.3,0],"a",{mirror:true}),g([8.9,.5,.3],[0,27.3,4.4],"a")],100)];var Ma=(e,t)=>(r,o,a,n,s,l)=>Me({id:`${t}.${r}`,slot:e,name:o,palette:a,tint:n,textures:s.textures??{},paint:s.paint??[],parts:s.parts??[]},l),Mt=Ma("shoes","shoes"),Co=Ma("hands","hands"),Po=Ma("waist","waist"),Ta=(e="a")=>L([9.45,1.25,4.97],[0,13.15,0],e),Es=[Mt("bunny","Bunny slippers",{a:"#f4f1ea",b:"#f08cb4"},"b",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[.6,1.6,.4],[1.3,2.2,-2.4],"a"),W("shinR",[.6,1.6,.4],[2.9,2.2,-2.4],"a"),W("shinR",[.9,.7,.5],[2.1,1.1,-3.3],"b")]}),Mt("rainboots","Rain boots",{a:"#f2c14e",b:"#2b2140"},"a",{paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[W("shinR",[4.6,5,4.6],[2.1,3.5,0],"a")]}),Mt("runners","Running shoes",{a:"#2ab0c0",b:"#f4f1ea",c:"#e8436b"},"a",{textures:{sd:Z(["aaaaa","acaca","bbbbb"])},paint:[{region:"feet",color:"a",faces:{left:"sd",right:"sd",bottom:"b"}}],parts:[W("shinR",[4.4,.5,5.5],[2.1,.25,-0.5],"b")]}),Mt("rollers","Roller skates",{a:"#e8436b",b:"#f4f1ea",c:"#2b2140"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.5,3,4.6],[2.1,2.6,0],"a"),W("shinR",[3.4,.4,5],[2.1,.2,-0.5],"b"),W("shinR",[3.6,.9,.9],[2.1,-0.05,-2.4],"c"),W("shinR",[3.6,.9,.9],[2.1,-0.05,1.4],"c")]},150),Mt("iceskates","Ice skates",{a:"#f4f1ea",b:"#c8ccd2"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.5,3.2,4.6],[2.1,2.7,0],"a"),W("shinR",[.35,.6,5.8],[2.1,-0.2,-0.5],"b",{mat:"metal"})]},150),Mt("cowboy","Cowboy boots",{a:"#7a4f2a",b:"#4a2e1a"},"a",{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[4.7,4.6,4.7],[2.1,3.6,0],"a"),W("shinR",[3,.6,1.4],[2.1,.3,1.6],"b")]},120),Mt("space","Space boots",{a:"#f4f1ea",b:"#9aa4ae"},null,{paint:[{region:"feet",color:"a"}],parts:[W("shinR",[5,4.6,5],[2.1,3.3,0],"a"),W("shinR",[4.6,.6,5.8],[2.1,.3,-0.5],"b")]},150),Mt("platform","Platform sneakers",{a:"#1d1d21",w:"#f4f1ea"},"a",{textures:{toe:Z(["aaaa","wwww"]),side:Z(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[W("shinR",[4.5,1.2,5.6],[2.1,.6,-0.5],"w")]},100)],Ss=[Co("mittens","Mittens",{a:"#c0392b",b:"#f4f1ea"},"a",{paint:[{region:"hands",color:"a"}],parts:[W("foreArmR",[3.7,.9,3.7],[6.3,14.3,0],"b")]}),Co("fingerless","Fingerless gloves",{a:"#2b2140",s:"@skin"},"a",{textures:{fl:Z(["sss","aaa","aaa"])},paint:[{region:"hands",color:"a",faces:{front:"fl",back:"fl",left:"fl",right:"fl",bottom:"s"}}]}),Co("wristbands","Wristbands",{a:"#e8436b"},"a",{parts:[W("foreArmR",[3.8,1.2,3.8],[6.3,14.7,0],"a")]}),Co("boxing","Boxing gloves",{a:"#c0392b",b:"#f4f1ea"},"a",{paint:[{region:"hands",color:"a"}],parts:[W("foreArmR",[4.2,3.6,4.2],[6.3,12.5,-0.2],"a"),W("foreArmR",[3.8,1,3.8],[6.3,14.6,0],"b")]},100)],Ts=[Po("fannypack","Fanny pack",{a:"#2b2140",b:"#534ab7",m:"#c8ccd2"},"b",{parts:[L([9.45,.8,4.97],[0,13.6,0],"a"),L([4,2,1.6],[0,13.6,-3.1],"b"),L([3.2,.2,.15],[0,14.3,-3.92],"m",{mat:"metal"})]}),Po("tools","Tool belt",{a:"#5a3a22",b:"#8a5a32",m:"#9aa4ae",h:"#c0612b"},"a",{parts:[Ta(),L([2.2,2.2,1.3],[3.2,12,-2.8],"b",{mirror:true}),L([.5,2.6,.5],[-1.4,11.8,-3.1],"h"),L([1.6,.7,.7],[-1.4,13.2,-3.1],"m",{mat:"metal"})]},80),Po("sheath","Sword sheath",{a:"#3a2a22",b:"#5a3a22",m:"#c8ccd2"},"a",{parts:[Ta(),L([.9,4.8,1.2],[4.9,12.1,0],"b"),L([1.6,.4,.8],[4.9,14.7,0],"m",{mat:"metal"}),L([.6,1.4,.6],[4.9,15.6,0],"a")]},120),Po("pouches","Double pouches",{a:"#3a2a22",b:"#6b6b4a"},"b",{parts:[Ta("a"),L([2.4,2.4,1.3],[2.6,11.8,-2.9],"b",{mirror:true})]},60)];var Je=g([9.21,2.05,8.73],[0,29.91,0],"a"),Lt=g([9.21,1.7,.73],[0,28.72,-4.36],"a"),Kr=g([.71,1.7,2.8],[4.5,28.72,-2.9],"a",{mirror:true}),Ct=(e,t)=>g([.71,e,7.58],[4.6,t,.51],"a",{mirror:true}),Pt=(e,t)=>g([9.21,e,.73],[0,t,4.36],"a"),ke=(e,t,r,o,a={a:"#3b2a20"})=>Me({id:`hair.${e}`,slot:"hair",name:t,palette:a,tint:"a",parts:r},o),Ms=[ke("afro","Afro",[g([11.4,4.4,10.2],[0,31.3,.6],"a"),g([10.6,2.2,8.2],[0,27.2,1.5],"a"),g([1.2,4.2,7.4],[5,26.4,1.2],"a",{mirror:true}),g([9.6,4.4,1.3],[0,26.2,4.9],"a"),g([8.6,1.9,.8],[0,28.95,-4.5],"a")]),ke("buzz","Buzz cut",[g([8.9,.6,8.4],[0,30.45,0],"a"),g([.4,2.6,7.6],[4.42,28.9,.2],"a",{mirror:true}),g([8.9,3.6,.4],[0,28.4,4.2],"a"),g([8.9,.8,.4],[0,29.75,-4.2],"a")]),ke("sidepart","Side part",[Je,g([5.5,2.4,.9],[-1.85,28.6,-4.4],"a"),g([3.7,1.3,.73],[2.75,29.1,-4.36],"a"),Ct(3.41,27.86),Pt(4.77,27.18),g([3.2,1,3.4],[-1.6,31.3,-1.4],"a")]),ke("pigtails","Pigtails",[Je,Lt,Kr,Ct(3.41,27.86),Pt(4.77,27.18),g([1.9,4.6,1.9],[4.9,26,1.6],"a",{mirror:true}),g([2.1,.8,2.1],[4.9,28.4,1.6],"b",{mirror:true})],void 0,{a:"#3b2a20",b:"#d4537e"}),ke("braids","Braids",[Je,Lt,Ct(3.41,27.86),Pt(4.77,27.18),g([1.6,5.6,1.6],[3.4,25,3.9],"a",{mirror:true}),g([1.9,.6,1.9],[3.4,22.5,3.9],"b",{mirror:true})],void 0,{a:"#3b2a20",b:"#f2c14e"}),ke("bowl","Bowl cut",[g([9.9,3.2,9.4],[0,29,0],"a"),g([9.4,1,8.9],[0,30.9,0],"a"),g([9.6,3.6,.9],[0,27,4.5],"a")]),ke("dreads","Dreadlocks",[Je,Lt,g([1.3,5,1.3],[4.75,25.6,-1.6],"a",{mirror:true}),g([1.3,5.6,1.3],[4.75,25.3,1.7],"a",{mirror:true}),g([1.3,6,1.3],[2.4,25,4.75],"a",{mirror:true}),g([1.3,6.2,1.3],[0,25.2,4.8],"a"),Pt(3.2,28.3)],120),ke("longwavy","Long waves",[Je,Lt,Kr,g([1.06,6.82,7.88],[4.78,26.16,.66],"a",{mirror:true}),g([9.21,7.5,1.09],[0,26.16,4.55],"a"),g([1.3,2,8],[5.1,23.4,.9],"a",{mirror:true}),g([9.8,2,1.4],[0,23.2,4.85],"a")],120),ke("topknot","Top knot",[Je,Lt,Kr,Ct(2.73,28.2),Pt(4.09,27.52),g([3.2,2.8,3.2],[0,32.3,0],"a"),g([3.5,.6,3.5],[0,31.1,0],"b")],100,{a:"#3b2a20",b:"#1d1d21"}),ke("spacebuns","Space buns",[Je,Lt,Kr,Ct(3.41,27.86),Pt(4.77,27.18),g([3,3,3],[3,31.8,.5],"a",{mirror:true})],120),ke("emo","Swept fringe",[Je,g([6.5,3.8,.9],[-1.3,27.6,-4.45],"a"),g([2.7,1.3,.73],[3.25,29.1,-4.36],"a"),Ct(4.5,27.3),Pt(5.4,26.9)],100),ke("quiff","Quiff",[Je,g([8,2.4,3.2],[0,31.4,-2.6],"a"),g([8.6,1.2,1.2],[0,30.6,-4.4],"a"),Ct(2.73,28.2),Pt(4.09,27.52)],100),ke("mullet","Mullet",[Je,Lt,Kr,Ct(2.73,28.2),g([9.21,7,1.09],[0,25.8,4.55],"a"),g([8,2,1.6],[0,23.2,4.9],"a")],80),ke("wavybob","Wavy bob",[Je,Lt,g([1.06,6.13,8.6],[4.78,26.84,.3],"a",{mirror:true}),g([9.21,6.14,1.09],[0,26.5,4.55],"a"),g([1.5,1.2,8.8],[5.1,24.1,.3],"a",{mirror:true}),g([9.6,1.2,1.5],[0,24.1,4.8],"a")],100),ke("curls","Shoulder curls",[g([9.92,2.39,9.45],[0,30.08,0],"a"),g([9.21,1.36,.73],[0,28.89,-4.8],"a"),g([2.83,2.73,2.91],[3.54,28.89,-2.55],"a",{mirror:true}),g([2.83,2.73,2.91],[3.54,28.89,1.82],"a",{mirror:true}),g([5.67,2.05,5.82],[0,31.61,0],"a"),g([4.25,4.27,2.18],[2.13,27.27,4],"a",{mirror:true}),g([2.6,4,2.6],[4.4,24.4,2.4],"a",{mirror:true})],150),ke("undercut","Undercut",[g([9.21,2.6,8.73],[0,30.2,0],"a"),g([9.21,1.7,2],[0,29.9,-4.3],"a"),g([.4,2.6,7.6],[4.42,28.2,.2],"b",{mirror:true}),g([8.9,3.4,.4],[0,27.6,4.2],"b")],120,{a:"#3b2a20",b:"#2a1d16"})];var ye=(e,t,r,o,a,n)=>Me({id:`hat.${e}`,slot:"hat",name:t,palette:r,tint:o,parts:a},n),La=g([9.4,.7,1.2],[0,30.6,0],"c"),Ls=[ye("tophat","Top hat",{a:"#1d1d21",b:"#a32d2d"},"a",[g([11.4,.55,11],[0,30.6,0],"a"),g([8.6,6,8.2],[0,33.9,0],"a"),g([8.8,.9,8.4],[0,31.4,0],"b")],150),ye("cowboy","Cowboy hat",{a:"#9a6a3a",b:"#4a2e1a"},"a",[g([13,.6,12],[0,30.4,0],"a"),g([.8,1.2,11],[6.1,31,0],"a",{mirror:true}),g([8.4,3.5,8],[0,32.4,0],"a"),g([8.6,.7,8.2],[0,31.1,0],"b")],150),ye("tricorn","Tricorn",{a:"#2c2420",b:"#d8b030"},"a",[g([10.4,2.4,10],[0,31.2,0],"a"),g([.8,2.6,8],[5.2,31.6,0],"a",{mirror:true}),g([9,2.6,.8],[0,31.6,4.8],"a"),g([3,2.2,.8],[0,31.4,-5],"a"),g([8,.4,.6],[0,30.2,-5.2],"b",{mat:"metal"})],180),ye("chef","Chef hat",{a:"#f6f4ee",b:"#e2ded2"},null,[g([9.8,2,9.4],[0,30.7,0],"b"),g([10.6,4.5,10.2],[0,33.9,0],"a")],100),ye("beret","Beret",{a:"#a32d2d"},"a",[g([10,1.6,9.6],[-0.4,31,0],"a"),g([.8,.8,.8],[0,32,0],"a")]),ye("hardhat","Hard hat",{a:"#f2c14e",b:"#d8a030"},"a",[g([9.8,3,9.4],[0,31.3,0],"a"),g([9.8,.5,2.5],[0,30,-5.5],"a"),g([1,.8,9.6],[0,33,0],"b")],80),ye("viking","Viking helmet",{a:"#9aa4ae",b:"#6a5a3a",c:"#f0e6d0"},"a",[g([9.8,3.2,9.4],[0,31.2,0],"a",{mat:"metal"}),g([10.2,1,9.8],[0,29.9,0],"b"),g([1.4,1.4,1.4],[5.5,31.6,0],"c",{mirror:true}),g([1.1,2.4,1.1],[6.2,33.2,0],"c",{mirror:true}),g([.8,2.2,.5],[0,28.6,-5.05],"a",{mat:"metal"})],200),ye("space","Space helmet",{a:"#bfe6ff",b:"#d8dde4",c:"#ff5a3c"},null,[g([11,10.4,10.8],[0,27,0],"a",{mat:"glass"}),g([10,1,9.6],[0,22.3,0],"b",{mat:"metal"}),g([1.2,1.2,.6],[0,32.4,-1.6],"c",{mat:"glow"})],250),ye("catears","Cat ears",{a:"#2b2140",b:"#f08cb4",c:"#2b2140"},"a",[La,g([2,2.2,1],[2.9,32,0],"a",{mirror:true}),g([1.1,1.3,.4],[2.9,31.8,-0.65],"b",{mirror:true})]),ye("bunnyears","Bunny ears",{a:"#f4f1ea",b:"#f08cb4",c:"#f4f1ea"},"a",[La,g([1.5,5.4,.9],[1.9,33.6,0],"a",{mirror:true}),g([.8,4.2,.3],[1.9,33.4,-0.55],"b",{mirror:true})],80),ye("foxears","Fox ears",{a:"#e8862a",b:"#2a1c14",c:"#2a1c14"},"a",[La,g([2.4,2.8,1],[2.8,32.2,0],"a",{mirror:true}),g([2.4,.9,1.05],[2.8,33.55,0],"b",{mirror:true})],80),ye("halo","Halo",{a:"#ffe27a"},"a",[g([6,.5,1],[0,33.4,-2.5],"a",{mat:"glow"}),g([6,.5,1],[0,33.4,2.5],"a",{mat:"glow"}),g([1,.5,4],[2.5,33.4,0],"a",{mat:"glow",mirror:true})],250),ye("horns","Little horns",{a:"#c0392b",b:"#7a1d1d"},"a",[g([1.4,1.8,1.4],[2.6,31.1,-0.6],"a",{mirror:true}),g([.9,1.2,.9],[2.9,32.5,-0.6],"b",{mirror:true})],120),ye("party","Party hat",{a:"#7f77dd",b:"#f2c14e"},"a",[g([6,1.6,6],[0,31.1,0],"a"),g([4.4,1.8,4.4],[0,32.8,0],"b"),g([2.8,1.8,2.8],[0,34.6,0],"a"),g([1.4,1.6,1.4],[0,36.3,0],"b"),g([1.6,1.2,1.6],[0,37.3,0],"a")]),ye("flowers","Flower wreath",{a:"#4c9a4a",b:"#f08cb4",c:"#f2d33c",d:"#f4f1ea"},null,[g([9.6,.9,9.2],[0,30.4,0],"a"),g([1.4,1.2,1.4],[3,30.9,-4.4],"b",{mirror:true}),g([1.4,1.2,1.4],[0,31,-4.6],"c"),g([1.4,1.2,1.4],[4.7,30.9,.5],"d",{mirror:true}),g([1.4,1.2,1.4],[2.6,30.9,4.5],"c",{mirror:true})],120),ye("bandana","Bandana",{a:"#c0392b"},"a",[g([9.6,2.4,9.2],[0,30.1,0],"a"),g([2,1.6,1.6],[0,29.4,5],"a"),g([1,2.6,.6],[.7,27.6,5.2],"a",{mirror:true})]),ye("ninja","Ninja headband",{a:"#2b2140",b:"#c8ccd2"},"a",[g([9.4,1.3,9],[0,28.8,0],"a"),g([3,1.1,.4],[0,28.8,-4.7],"b",{mat:"metal"}),g([.9,3,.5],[.7,27,4.9],"a",{mirror:true})],100),ye("propeller","Propeller cap",{a:"#2f5fd0",b:"#f2d33c",c:"#c0392b"},"a",[g([9.63,2.73,9.16],[0,30.8,.15],"a"),g([7.79,.55,3.64],[0,29.57,-5.96],"a"),g([.6,1.2,.6],[0,32.7,0],"b"),g([7,.3,1.2],[0,33.4,0],"c"),g([1.2,.3,7],[0,33.4,0],"b")],150)];var zo=e=>({front:e,back:e,left:e,right:e}),ge=(e,t,r,o,a,n)=>Me({id:`top.${e}`,slot:"top",name:t,palette:r,tint:o,textures:a.textures??{},paint:a.paint,parts:a.parts??[]},n),fc=Z(["abaabaab","bbbbbbbb","abaabaab","abaabaab","bbbbbbbb","abaabaab","abaabaab","abaabaab"]),Cs=[ge("flannel","Flannel shirt",{a:"#c0392b",b:"#2b2140"},"a",{textures:{pl:fc},paint:[{region:"torso",color:"a",faces:zo("pl")},{region:"arms",color:"a",faces:zo("pl")}],parts:[L([5.6,.8,.5],[0,22.2,-2.4],"b")]}),ge("polo","Polo shirt",{a:"#1d9e75",w:"#f4f1ea"},"a",{textures:{pk:Z(["aaawaaaa","aaawaaaa","aaawaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"pk"}},{region:"sleeves",color:"a"}],parts:[L([4.6,.9,.6],[0,22.4,-2.3],"a")]}),ge("heart","Heart sweater",{a:"#d4537e",b:"#f4f1ea"},"a",{textures:{h:Z(["aaaaaaaa","aabaabaa","abbbbbba","abbbbbba","aabbbbaa","aaabbaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"h"}},{region:"arms",color:"a"}]}),ge("gamer","Gamepad tee",{a:"#2b2140",b:"#9aa4ae",c:"#33e0ff",d:"#e8436b"},"a",{textures:{g:Z(["aaaaaaaa","aaaaaaaa","abbbbbba","bcbbbdbb","bbbbbbbb","abbaabba","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"g"}},{region:"sleeves",color:"a"}]}),ge("jersey","Sports jersey",{a:"#2f5fd0",w:"#f4f1ea"},"a",{textures:{n:Z(["aaaaaaaa","aawwwwaa","aaaaawaa","aaaawaaa","aaawaaaa","aaawaaaa","aaaaaaaa","aaaaaaaa"]),sl:Z(["aaa","www","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"n",back:"n"}},{region:"sleeves",color:"a",faces:zo("sl")}]}),ge("dress","Dress",{a:"#7f77dd",b:"#f4f1ea"},"a",{paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}],parts:[L([10.2,5,5.6],[0,12.1,0],"a"),L([9,.8,4.6],[0,14.9,0],"b")]}),ge("bomber","Varsity jacket",{a:"#a32d2d",b:"#f4f1ea",c:"#2b2140"},"a",{textures:{fr:Z(["aaabbaaa","aaabbaaa","abaabaaa","abaabaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa"]),cf:Z(["bbb","bbb","bbb","bbb","ccc"])},paint:[{region:"torso",color:"a",faces:{front:"fr"}},{region:"arms",color:"b",faces:zo("cf")}],parts:[L([8.8,.9,4.6],[0,12.9,0],"c")]},120),ge("puffer","Puffer jacket",{a:"#ef9f27",b:"#c87f17"},"a",{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([9.6,3.2,5.2],[0,20.6,0],"a"),L([9.4,3,5],[0,17.4,0],"b"),L([9,3,4.8],[0,14.3,0],"a"),W("armR",[4,2.2,4],[6.3,20.4,0],"a")]},150),ge("overalls","Overalls",{a:"#2f5fd0",b:"#f4f1ea",g:"#d8b030"},"a",{paint:[{region:"torso",color:"b"},{region:"sleeves",color:"b"}],parts:[L([6,5,.5],[0,17.8,-2.4],"a"),L([1.2,4,.5],[2.4,20.6,-2.4],"a",{mirror:true}),L([.6,.6,.3],[2.4,21.7,-2.75],"g",{mirror:true,mat:"metal"}),L([1.2,9,.5],[2.4,17.5,2.4],"a",{mirror:true}),L([8.8,4.4,4.6],[0,14.8,0],"a")]},100),ge("labcoat","Lab coat",{a:"#f4f1ea",b:"#9ad0f0"},null,{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([9,4.5,4.8],[0,11.8,0],"a"),L([1.6,4,.4],[1.6,19.8,-2.45],"a",{mirror:true}),L([1.6,1.4,.3],[-2.6,17,-2.4],"b")]},120),ge("ninja","Ninja suit",{a:"#2b2140",r:"#c0392b",g:"#3c3450"},"a",{textures:{wr:Z(["agaaaaaa","aagaaaaa","aaagaaaa","aaaagaaa","aaaaagaa","aaaaaaga","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"wr"}},{region:"arms",color:"a"}],parts:[L([9.2,1,4.8],[0,14.3,0],"r")]},150),ge("space","Space suit",{a:"#f4f1ea",b:"#9aa4ae",c:"#33e0ff",d:"#e8436b"},null,{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([5,3.6,.6],[0,19,-2.5],"b"),L([.6,.6,.3],[-1.2,19.6,-2.9],"c",{mat:"glow"}),L([.6,.6,.3],[1.2,19.6,-2.9],"d",{mat:"glow"}),W("armR",[4.2,1,4.2],[6.3,22.4,0],"b"),L([7,.8,5],[0,22.6,0],"b",{mat:"metal"})]},250),ge("pirate","Pirate shirt",{a:"#f4f1ea",b:"#5a3a22",r:"#a32d2d"},null,{textures:{v:Z(["aabbbbaa","aaabbaaa","aabaabaa","aaabbaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"v"}},{region:"arms",color:"a"}],parts:[W("foreArmR",[4.2,3,4.2],[6.3,15.6,0],"a"),L([9.2,1.4,4.8],[0,13.6,0],"r")]},120),ge("raincoat","Raincoat",{a:"#f2c14e",b:"#d8a030"},"a",{textures:{bt:Z(["aaaaaaaa","aaabaaaa","aaaaaaaa","aaabaaaa","aaaaaaaa","aaabaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"bt"}},{region:"arms",color:"a"}],parts:[L([7,3.6,2],[0,21.5,2.9],"a"),L([9,4,4.8],[0,12,0],"a")]},100),ge("vest","Vest and shirt",{a:"#5a3a22",b:"#f4f1ea"},"a",{paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[L([4.2,7,.5],[2.2,17.5,-2.4],"a",{mirror:true}),L([9,9,.5],[0,17.4,2.4],"a")]},80),ge("chef","Chef jacket",{a:"#f6f4ee",b:"#2b2140"},null,{textures:{db:Z(["aaaaaaaa","aabaabaa","aaaaaaaa","aabaabaa","aaaaaaaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"db"}},{region:"arms",color:"a"}],parts:[L([5,.8,.5],[0,22.3,-2.4],"a")]},80),ge("tuxedo","Tuxedo",{a:"#1d1d21",w:"#f4f1ea"},null,{textures:{tx:Z(["aawwwwaa","aaawwaaa","aaawwaaa","aaawwaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"tx"}},{region:"arms",color:"a"}],parts:[L([2,1,.4],[0,21.7,-2.6],"a"),L([8.6,4,.6],[0,11.6,2.4],"a")]},200),ge("leather","Leather jacket",{a:"#2a2420",b:"#c8ccd2"},"a",{paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[L([2.6,1.6,.6],[2.5,22.1,-2.25],"a",{mirror:true}),L([.4,8,.3],[-0.8,16.8,-2.45],"b",{mat:"metal"})]},180)];var Yr=[...Ms,...Cs,...vs,...Es,...Ss,...Ts,...Rs,...ks,...As,...Ls];function Ge(e){let t=mr(e);if(!t.ok)throw new Error(`avatar shop: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var Ca=e=>({w:e[0].length,h:e.length,rows:e}),bc={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},yc={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},Ps=[{price:250,item:Ge({id:"hat.crown",slot:"hat",name:"Crown",palette:{a:"#e8b730",g:"#d23c4a"},tint:"a",parts:[{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,-4.36],color:"a"},{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,4.36],color:"a"},{bone:"head",size:[.71,1.7,8.73],pos:[4.6,30.93,0],color:"a",mirror:true},{bone:"head",size:[1.13,1.36,.73],pos:[2.98,32.47,-4.36],color:"a",mirror:true},{bone:"head",size:[1.13,1.77,.73],pos:[0,32.67,-4.36],color:"a"},{bone:"head",size:[.99,.95,.29],pos:[0,30.93,-4.87],color:"g"}]})},{price:250,item:Ge({id:"back.wings",slot:"back",name:"Angel wings",palette:{a:"#f7f5ff",b:"#d9d4f2"},tint:"a",parts:[{bone:"body",size:[2.25,7.5,1.47],pos:[1.69,21.15,3.04],color:"b",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.31,26.15,3.86],color:"a",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.88,23.03,4.05],color:"b",mirror:true},{bone:"body",size:[9,3.13,.74],pos:[8.44,19.9,4.23],color:"a",mirror:true},{bone:"body",size:[6.75,3.13,.74],pos:[9,16.77,4.42],color:"b",mirror:true},{bone:"body",size:[4.5,3.13,.74],pos:[9.56,13.65,4.6],color:"a",mirror:true},{bone:"body",size:[3.38,1.88,.74],pos:[11.25,28.65,3.86],color:"a",mirror:true}]})},{price:200,item:Ge({id:"hat.wizard",slot:"hat",name:"Wizard hat",palette:{a:"#3c2f8f",s:"#f2c14e"},tint:"a",parts:[{bone:"head",size:[10.63,.55,10.18],pos:[0,30.39,0],color:"a"},{bone:"head",size:[8.5,1.77,8],pos:[0,31.55,0],color:"a"},{bone:"head",size:[6.38,1.77,5.82],pos:[0,33.32,.36],color:"a"},{bone:"head",size:[4.25,1.77,4],pos:[0,35.09,.73],color:"a"},{bone:"head",size:[2.13,1.64,2.18],pos:[0,36.8,1.09],color:"a"},{bone:"head",size:[1.13,1.09,.29],pos:[0,31.61,-4.15],color:"s"}]})},{price:200,item:Ge({id:"top.armor",slot:"top",name:"Knight armor",palette:{a:"#b8c2cc",b:"#5b6672",g:"#e8b730"},tint:"a",paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[{bone:"body",size:[9.67,7.5,.74],pos:[0,18.65,-2.67],color:"a"},{bone:"armR",size:[4.32,2.94,4.32],pos:[6.3,22.38,0],color:"a",mirror:true},{bone:"body",size:[2.25,2.5,.37],pos:[0,19.27,-3.22],color:"g"}]})},{price:200,item:Ge({id:"back.sword",slot:"back",name:"Sword",palette:{a:"#d8dde4",g:"#e8b730",h:"#5a3a22"},tint:"g",parts:[{bone:"body",size:[1.35,12.5,.55],pos:[2.81,17.4,3.04],color:"a"},{bone:"body",size:[4.5,1.13,.92],pos:[2.81,24.21,3.04],color:"g"},{bone:"body",size:[1.01,3.75,.83],pos:[2.81,26.65,3.04],color:"h"},{bone:"body",size:[1.58,1.5,1.1],pos:[2.81,29.28,3.04],color:"g"}]})},{price:150,item:Ge({id:"hat.headphones",slot:"hat",name:"Headphones",palette:{a:"#2b2140",b:"#4be0c8"},tint:"b",parts:[{bone:"head",size:[9.63,.82,1.45],pos:[0,31.07,0],color:"a"},{bone:"head",size:[.57,3.41,.87],pos:[4.89,29.57,0],color:"a",mirror:true},{bone:"head",size:[1.13,2.45,2.62],pos:[4.96,27.39,0],color:"a",mirror:true},{bone:"head",size:[.28,1.64,1.75],pos:[5.6,27.39,0],color:"b",mirror:true}]})},{price:150,item:Ge({id:"hair.mohawk",slot:"hair",name:"Mohawk",palette:{a:"#d4537e"},tint:"a",parts:[{bone:"head",size:[1.84,3.07,8],pos:[0,31.78,0],color:"a"},{bone:"head",size:[1.84,2.05,1.45],pos:[0,31.27,-4.73],color:"a"},{bone:"head",size:[2.13,4.09,.73],pos:[0,28.2,4.36],color:"a"}]})},{price:150,item:Ge({id:"top.suit",slot:"top",name:"Suit and tie",palette:{a:"#2c2f3a",w:"#f4f1ea",r:"#c0392b"},tint:"a",textures:{front:Ca(["awwrrwwa","aawrrwaa","aaarraaa","aaarraaa","aaarraaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"front"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[1.35,1,.28],pos:[-2.92,19.9,-2.44],color:"w"}]})},{price:120,item:Ge({id:"hair.ponytail",slot:"hair",name:"Ponytail",palette:{a:"#3b2a20",b:"#d4537e"},tint:"a",parts:[bc,yc,{bone:"head",size:[.71,3.41,7.27],pos:[4.6,27.86,.36],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"},{bone:"head",size:[2.27,1.02,1.75],pos:[0,28.55,4.95],color:"b"},{bone:"head",size:[1.84,5.45,1.45],pos:[0,25.82,5.09],color:"a"}]})},{price:120,item:fr["face.visor"]},{price:100,item:Ge({id:"shoes.hightops",slot:"shoes",name:"High-tops",palette:{a:"#7f77dd",w:"#f4f1ea",b:"#2b2140"},tint:"a",textures:{toe:Ca(["aaaa","wwww"]),side:Ca(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[{bone:"shinR",size:[4.62,4.32,4.62],pos:[2.1,3.76,0],color:"b",mirror:true}]})},{price:50,item:Ge({id:"hands.gauntlets",slot:"hands",name:"Golden gauntlets",palette:{a:"#e8b730",b:"#b8862a"},tint:"a",paint:[{region:"hands",color:"a"}],parts:[{bone:"foreArmR",size:[4.32,1.75,4.32],pos:[6.3,13.78,0],color:"b",mirror:true}]})},{price:50,item:Ge({id:"waist.pouch",slot:"waist",name:"Belt pouch",palette:{a:"#3a2a22",b:"#7a5233"},tint:"b",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[2.7,2.5,1.29],pos:[2.93,11.9,-3.04],color:"b"}]})}],zs=Yr.filter(e=>e.price!==void 0),Is=[...Ps,...zs].map(e=>e.item),Pa=Object.fromEntries([...Ps,...zs].map(e=>[e.item.id,e.price])),Os=e=>Object.prototype.hasOwnProperty.call(Pa,e);function Q(e){let t=mr(e);if(!t.ok)throw new Error(`avatar catalog: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var br=e=>({w:e[0].length,h:e.length,rows:e}),Wr={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},za={bone:"head",size:[.71,1.7,2.8],pos:[4.5,28.72,-2.9],color:"a",mirror:true},$r={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},gc=[Q({id:"hair.short",slot:"hair",name:"Short",palette:{a:"#3b2a20"},tint:"a",parts:[Wr,$r,za,{bone:"head",size:[.71,3.41,7.58],pos:[4.6,27.86,.51],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"}]}),Q({id:"hair.bob",slot:"hair",name:"Bob",palette:{a:"#3b2a20"},tint:"a",parts:[Wr,$r,{bone:"head",size:[1.06,6.13,8.6],pos:[4.78,26.84,.3],color:"a",mirror:true},{bone:"head",size:[9.21,6.14,1.09],pos:[0,26.5,4.55],color:"a"}]}),Q({id:"hair.spiky",slot:"hair",name:"Spiky",palette:{a:"#3b2a20"},tint:"a",parts:[Wr,$r,{bone:"head",size:[.71,2.73,8.6],pos:[4.6,28.2,0],color:"a",mirror:true},{bone:"head",size:[9.21,2.73,.73],pos:[0,28.2,4.36],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[2.83,31.61,-0.73],color:"a",mirror:true},{bone:"head",size:[2.13,2.73,2.18],pos:[0,31.95,-0.73],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[-1.42,31.61,2.18],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[1.77,31.75,1.82],color:"a"}]}),Q({id:"hair.long",slot:"hair",name:"Long",palette:{a:"#3b2a20"},tint:"a",parts:[Wr,$r,za,{bone:"head",size:[1.06,6.82,7.88],pos:[4.78,26.16,.66],color:"a",mirror:true},{bone:"head",size:[9.21,7.5,1.09],pos:[0,26.16,4.55],color:"a"}]}),Q({id:"hair.bun",slot:"hair",name:"Bun",palette:{a:"#3b2a20"},tint:"a",parts:[Wr,$r,za,{bone:"head",size:[.71,2.73,6.48],pos:[4.6,28.2,1.06],color:"a",mirror:true},{bone:"head",size:[9.21,4.09,.73],pos:[0,27.52,4.36],color:"a"},{bone:"head",size:[4.25,3.41,3.64],pos:[0,32.64,1.82],color:"a"}]}),Q({id:"hair.curly",slot:"hair",name:"Curly",palette:{a:"#3b2a20"},tint:"a",parts:[{bone:"head",size:[9.92,2.39,9.45],pos:[0,30.08,0],color:"a"},{bone:"head",size:[9.21,1.36,.73],pos:[0,28.89,-4.8],color:"a"},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,-2.55],color:"a",mirror:true},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,1.82],color:"a",mirror:true},{bone:"head",size:[5.67,2.05,5.82],pos:[0,31.61,0],color:"a"},{bone:"head",size:[4.25,4.27,2.18],pos:[2.13,27.27,4],color:"a",mirror:true}]})],xc=[Q({id:"top.idos",slot:"top",name:"iDos Games tee",palette:{a:"#1565ff"},tint:null,paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}]}),Q({id:"top.tee",slot:"top",name:"Star tee",palette:{a:"#1d9e75",b:"#f4f1ea"},tint:"a",textures:{print:br(["aaaaaaaa","aaabbaaa","aabbbbaa","abbbbbba","aabbbbaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"print"}},{region:"sleeves",color:"a"}]}),Q({id:"top.hoodie",slot:"top",name:"Hoodie",palette:{a:"#378add",b:"#24578f",w:"#f0f0f0"},tint:"a",paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[{bone:"body",size:[7.88,4.38,1.84],pos:[0,21.78,3.04],color:"a"},{bone:"body",size:[5.63,2.5,.46],pos:[0,15.52,-2.53],color:"b"},{bone:"body",size:[.56,2.75,.37],pos:[1.24,19.65,-2.48],color:"w",mirror:true}]}),Q({id:"top.stripes",slot:"top",name:"Striped sweater",palette:{a:"#d4537e",b:"#f4f1ea"},tint:"a",textures:{st:br(["aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa"]),sl:br(["aaa","bbb","aaa","bbb","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"st",back:"st",left:"st",right:"st"}},{region:"arms",color:"a",faces:{front:"sl",back:"sl",left:"sl",right:"sl"}}]}),Q({id:"top.jacket",slot:"top",name:"Jacket",palette:{a:"#444441",b:"#f4f1ea",c:"#c8c2b4"},tint:"a",textures:{open:br(["aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aacbbcaa","aaabbaaa","aaabbaaa"])},paint:[{region:"torso",color:"a",faces:{front:"open"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[3.38,1.5,.92],pos:[2.48,22.53,-2.21],color:"a",mirror:true}]}),Q({id:"top.tank",slot:"top",name:"Tank top",palette:{a:"#ef9f27"},tint:"a",paint:[{region:"torso",color:"a"}]})],wc=[Q({id:"bottom.jeans",slot:"bottom",name:"Jeans",palette:{a:"#2f5fd0"},tint:"a",paint:[{region:"legs",color:"a"}]}),Q({id:"bottom.shorts",slot:"bottom",name:"Shorts",palette:{a:"#5f6b7a",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"legR",size:[4.62,5.4,4.62],pos:[2.1,9.7,0],color:"a",mirror:true}]}),Q({id:"bottom.skirt",slot:"bottom",name:"Skirt",palette:{a:"#7f77dd",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"body",size:[10.13,4.38,5.52],pos:[0,11.46,0],color:"a"}]}),Q({id:"bottom.cargo",slot:"bottom",name:"Cargo pants",palette:{a:"#6b6b4a",b:"#55553a"},tint:"a",paint:[{region:"legs",color:"a"}],parts:[{bone:"legR",size:[.84,4.32,2.52],pos:[4.62,7,0],color:"b",mirror:true}]})],Rc=[Q({id:"shoes.sneakers",slot:"shoes",name:"Sneakers",palette:{a:"#d84a30",w:"#f4f1ea"},tint:"a",textures:{toe:br(["aaaa","wwww"]),side:br(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}]}),Q({id:"shoes.boots",slot:"shoes",name:"Boots",palette:{a:"#5a3a22",b:"#3a2414"},tint:"a",paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[{bone:"shinR",size:[4.83,4.32,4.83],pos:[2.1,3.76,0],color:"a",mirror:true}]}),Q({id:"shoes.sandals",slot:"shoes",name:"Sandals",palette:{a:"#b0773a",s:"@skin"},tint:"a",paint:[{region:"feet",color:"s"}],parts:[{bone:"shinR",size:[4.51,.48,5.57],pos:[2.1,.24,-0.53],color:"a",mirror:true},{bone:"shinR",size:[4.51,.4,1.05],pos:[2.1,1.12,-1.89],color:"a",mirror:true}]})],kc=[Q({id:"hands.gloves",slot:"hands",name:"Gloves",palette:{a:"#2b2140"},tint:"a",paint:[{region:"hands",color:"a"}]})],vc=[Q({id:"waist.belt",slot:"waist",name:"Belt",palette:{a:"#5a3a22",g:"#d8b030"},tint:"a",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[1.8,1.5,.37],pos:[0,13.15,-2.67],color:"g"}]})],Ac=[Q({id:"back.backpack",slot:"back",name:"Backpack",palette:{a:"#c0612b",b:"#8a3f18"},tint:"a",parts:[{bone:"body",size:[6.75,8.75,2.76],pos:[0,17.4,3.68],color:"a"},{bone:"body",size:[4.5,3.75,.55],pos:[0,14.9,5.34],color:"b"}]}),Q({id:"back.cape",slot:"back",name:"Cape",palette:{a:"#a32d2d"},tint:"a",parts:[{bone:"body",size:[10.13,12.5,.55],pos:[0,16.15,2.67],color:"a"}]})],Ec=[fr["face.glasses"],fr["face.shades"]],Sc=[Q({id:"hat.beanie",slot:"hat",name:"Beanie",palette:{a:"#534ab7",w:"#f4f1ea"},tint:"a",parts:[{bone:"head",size:[9.92,3.07,9.45],pos:[0,30.76,0],color:"a"},{bone:"head",size:[10.34,1.36,9.89],pos:[0,29.3,0],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[0,33.18,0],color:"w"}]}),Q({id:"hat.cap",slot:"hat",name:"Cap",palette:{a:"#c0392b"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,30.8,.15],color:"a"},{bone:"head",size:[7.79,.55,3.64],pos:[0,29.57,-5.96],color:"a"}]}),Q({id:"hat.bucket",slot:"hat",name:"Bucket hat",palette:{a:"#c8b88a"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,31.61,0],color:"a"},{bone:"head",size:[11.33,.55,10.91],pos:[0,30.39,0],color:"a"}]})],Io=[...gc,...xc,...wc,...Rc,...kc,...vc,...Ac,...Ec,...Sc,...Is.filter(e=>!Yr.some(t=>t.item.id===e.id)),...Yr.map(e=>e.item)],Lh=Object.fromEntries(Io.map(e=>[e.id,e]));function Tc(e){return Io.filter(t=>t.slot===e)}function _s(e){return Tc(e).filter(t=>!Os(t.id))}var Mc=["#f9e0cf","#f2c9a0","#e2ad80","#c88d62","#9c6844","#6e4a32"],Lc=["#3b2a20","#1d1d21","#f2c14e","#c0612b","#ece6da","#7f77dd","#d4537e","#2ab0a0"],Cc=["#3b2a20","#2f5fd0","#1d9e75","#7f77dd","#c0392b","#d8b030"],Pc=["#1d9e75","#378add","#d4537e","#444441","#ef9f27","#534ab7","#c0392b","#e8e4da"],yr={version:Ut,style:je,body:{skin:"#f2c9a0",height:1,head:"round"},face:{eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,marks:"none",emotion:"neutral"},anim:{...ct},wear:{hair:"hair.short",top:"top.idos",bottom:"bottom.jeans",shoes:"shoes.sneakers"},tint:{}},Vs={hair:.92,top:1,bottom:1,shoes:1,hands:.1,waist:.2,back:.2,neck:.15,faceAcc:.25,hat:.35};function Ih(e=Math.random){let t=n=>n[Math.floor(e()*n.length)],r=t(Lc),o={},a={};for(let n of Object.keys(Vs)){if(e()>=Vs[n])continue;let s=_s(n);s.length&&(o[n]=t(s).id,a[n]=n==="hair"?r:t(Pc));}return {version:Ut,style:je,body:{skin:t(Mc),height:.95+e()*.1,head:t(Gr)},face:{eyes:t(Dr),eyeColor:t(Cc),brows:t(Nr),browColor:r==="#ece6da"||r==="#f2c14e"?"#8a6a3a":r,mouth:t(Hr),cheeks:e()<.6,marks:e()<.3?t(jr):"none",emotion:"neutral"},anim:{...ct},wear:o,tint:a}}function Xt(e,t,r,o={}){return {...yr,body:{...yr.body,skin:e},face:{...yr.face,...t},anim:{...ct},wear:r,tint:o}}var Oh=[yr,Xt("#e2ad80",{eyes:"sparkle",mouth:"grin"},{hair:"hair.bun",top:"top.hoodie",bottom:"bottom.leggings",shoes:"shoes.runners"},{hair:"#3b2a20",top:"#d4537e",bottom:"#444441",shoes:"#e8e4da"}),Xt("#6e4a32",{eyes:"wide",mouth:"grin",browColor:"#1d1d21"},{hair:"hair.afro",top:"top.jersey",bottom:"bottom.shorts",shoes:"shoes.sneakers",hands:"hands.wristbands"},{hair:"#1d1d21",top:"#ef9f27",bottom:"#444441",shoes:"#e8e4da",hands:"#c0392b"}),Xt("#f9e0cf",{eyes:"anime",mouth:"open",browColor:"#534ab7"},{hair:"hair.spiky",top:"top.gamer",bottom:"bottom.cargo",shoes:"shoes.sneakers",faceAcc:"face.shades"},{hair:"#7f77dd",top:"#534ab7",bottom:"#444441",shoes:"#e8e4da",faceAcc:"#1d1d21"}),Xt("#c88d62",{eyes:"almond",mouth:"smile",browColor:"#8a4a2a"},{hair:"hair.long",top:"top.dress",bottom:"bottom.leggings",shoes:"shoes.sandals"},{hair:"#c0612b",top:"#1d9e75",bottom:"#444441",shoes:"#e8e4da"}),Xt("#9c6844",{eyes:"round",mouth:"smirk",browColor:"#1d1d21"},{hair:"hair.buzz",hat:"hat.cap",top:"top.tee",bottom:"bottom.joggers",shoes:"shoes.sneakers",back:"back.skateboard"},{hair:"#1d1d21",hat:"#c0392b",top:"#378add",bottom:"#444441",shoes:"#e8e4da",back:"#ef9f27"}),Xt("#f2c9a0",{eyes:"starry",mouth:"cat",marks:"freckles",browColor:"#8a6a3a"},{hair:"hair.pigtails",top:"top.heart",bottom:"bottom.pleated",shoes:"shoes.rainboots"},{hair:"#f2c14e",top:"#d4537e",bottom:"#534ab7",shoes:"#ef9f27"}),Xt("#e2ad80",{eyes:"narrow",brows:"thick",mouth:"smirk"},{hair:"hair.sidepart",top:"top.jacket",bottom:"bottom.jeans",shoes:"shoes.boots",back:"back.cape",neck:"neck.scarf"},{hair:"#3b2a20",top:"#444441",bottom:"#378add",shoes:"#3b2a20",back:"#c0392b",neck:"#ef9f27"})];var zc={hair:{frame:"portrait",view:.5},hat:{frame:"head",view:.35},faceAcc:{frame:"portrait",view:.2},neck:{frame:"portrait",view:.3},top:{frame:"torso",view:.3},waist:{frame:"torso",view:.3},hands:{frame:"torso",view:.55},bottom:{frame:"legs",view:.3},shoes:{frame:"feet",view:.6},back:{frame:"full",view:Math.PI-.6}},Ic=["hair","top","bottom","shoes"];function Oc(e,t){let r=pr(JSON.parse(JSON.stringify(yr)));for(let o of Object.keys(r.wear))Ic.includes(o)||delete r.wear[o];return r.tint={},r.wear[e]=t,r}function Dh(e,t){return {key:`item:${e.id}`,make:()=>({spec:Oc(e.slot,e.id),items:{...t,[e.id]:e},opts:zc[e.slot]})}}function Nh(e={}){let t=e.size??224,r=e.limit??800,o=e.budgetMs??14,a=new Map,n=new Map,s=[],l=null,i=false,c=(m,d)=>{for(a.delete(m),a.set(m,d);a.size>r;){let b=a.keys().next().value;URL.revokeObjectURL(a.get(b)),a.delete(b);}},p=()=>{if(i)return;i=true;let m=globalThis.requestIdleCallback;m?m(h,{timeout:120}):setTimeout(h,16);};function h(){i=false;let m=performance.now();for(;s.length&&performance.now()-m<o;){let d=s.shift(),b=n.get(d);if(b&&(n.delete(d),b.listeners.size!==0))try{l??=xs({size:t});let{spec:u,items:R,opts:w}=b.make(),A=l.render(u,R,w),k=[...b.listeners];A.toBlob(x=>{if(!x)return;let f=URL.createObjectURL(x);c(d,f);for(let S of k)S(f);},"image/png");}catch{l?.dispose(),l=null;}}s.length&&p();}return {peek:m=>a.get(m)??null,request(m,d){let b=a.get(m.key);if(b)return c(m.key,b),d(b),()=>{};let u=n.get(m.key);u||(u={make:m.make,listeners:new Set},n.set(m.key,u),s.push(m.key)),u.listeners.add(d),p();let R=u;return ()=>R.listeners.delete(d)},release(){l?.dispose(),l=null;}}}var _c="voxel-avatar-v1";function Yh(){return {standard:_c,style:je,version:Ut,slots:[...Kt],eyes:[...Dr],brows:[...Nr],mouths:[...Hr],emotions:[...At],heads:[...Gr],marks:[...jr],walks:[...wa],idles:[...Ra],height:{min:Br.min,max:Br.max},items:[...Io],shop:{...Pa},rules:{slots:{...ga},limits:{...Yt},regions:[...ba],regionPairs:Object.fromEntries(Object.entries(ya).map(([e,t])=>[e,[...t]])),faces:[...ut],skinColor:qt,materials:[...tr]}}}var Vc=(e,t,r)=>"#"+[e,t,r].map(o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0")).join("");function Fc(e,t,r){let o=[];for(let a=0;a<r;a++)for(let n=0;n<t;n++){let s=Math.floor(n*e.width/t),l=Math.max(s+1,Math.floor((n+1)*e.width/t)),i=Math.floor(a*e.height/r),c=Math.max(i+1,Math.floor((a+1)*e.height/r)),p=0,h=0,m=0,d=0,b=0;for(let u=i;u<c;u++)for(let R=s;R<l;R++){let w=(u*e.width+R)*4;b++,!((e.data[w+3]??0)<128)&&(p+=e.data[w]??0,h+=e.data[w+1]??0,m+=e.data[w+2]??0,d++);}o.push(d*2<b?null:[p/d,h/d,m/d]);}return o}var Jr=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2;function Jh(e,t){let r=Yt.textureSide,a=Math.min(1,16/Math.max(e.width,e.height,1)),n=Math.max(1,Math.min(r,Math.round(t.w??e.width*a))),s=Math.max(1,Math.min(r,Math.round(t.h??e.height*a))),l=[...new Set(t.symbols)].slice(0,Yt.palette);if(!l.length)throw new Error("pixelTextureFromImage: no palette symbols to use");let i=Fc(e,n,s),c=i.filter(u=>!!u),p=new Map;for(let u of c){let R=u.map(A=>Math.round(A/8)).join(","),w=p.get(R);w?w.n++:p.set(R,{n:1,c:u});}let h=[...p.values()].sort((u,R)=>R.n-u.n||(u.c.join()<R.c.join()?-1:1)),m=[];for(let u of h){if(m.length>=l.length)break;m.every(R=>Jr(R,u.c)>576)&&m.push([...u.c]);}!m.length&&h[0]&&(m=[[...h[0].c]]);for(let u=0;u<8&&m.length;u++){let R=m.map(()=>[0,0,0,0]);for(let w of c){let A=0;for(let x=1;x<m.length;x++)Jr(w,m[x])<Jr(w,m[A])&&(A=x);let k=R[A];k[0]+=w[0],k[1]+=w[1],k[2]+=w[2],k[3]+=1;}m=m.map((w,A)=>{let k=R[A];return k[3]?[k[0]/k[3],k[1]/k[3],k[2]/k[3]]:w});}let d={};m.forEach((u,R)=>d[l[R]]=Vc(u[0],u[1],u[2]));let b=[];for(let u=0;u<s;u++){let R="";for(let w=0;w<n;w++){let A=i[u*n+w];if(!A||!m.length){R+=".";continue}let k=0;for(let x=1;x<m.length;x++)Jr(A,m[x])<Jr(A,m[k])&&(k=x);R+=l[k];}b.push(R);}return {texture:{w:n,h:s,rows:b},palette:d}}var Bc="ugc.",Xh=e=>e.startsWith(Bc);exports.ACTION_TIME=Kn;exports.ANIM_EVENTS=C1;exports.AVATAR_AUTHOR_ITEM_PREFIX=Bc;exports.AVATAR_BASE_COLORS=cs;exports.AVATAR_FACE_RECT=St;exports.AVATAR_HEADS=Gr;exports.AVATAR_HEIGHT=Br;exports.AVATAR_IDLES=Ra;exports.AVATAR_ITEMS=Lh;exports.AVATAR_ITEM_LIMITS=Yt;exports.AVATAR_ITEM_LIST=Io;exports.AVATAR_ITEM_PRINTS=oc;exports.AVATAR_ITEM_SHOTS=zc;exports.AVATAR_PORTRAIT_BACKGROUND=Wm;exports.AVATAR_RIG_ID=Zt;exports.AVATAR_SHOP_DEFAULT_PRICES=Pa;exports.AVATAR_SHOP_ITEM_LIST=Is;exports.AVATAR_SLOTS=Kt;exports.AVATAR_SPEC_VERSION=Ut;exports.AVATAR_STANDARD_ID=_c;exports.AVATAR_STYLE=je;exports.AVATAR_WALKS=wa;exports.Animator=vo;exports.Art=U;exports.AvatarActor=Lo;exports.BODY_REGIONS=ba;exports.BONE_ROLES=$c;exports.BROW_STYLES=Nr;exports.CH=I;exports.CHANNELS=M1;exports.CHARACTER_LIMITS=Ga;exports.CHARACTER_SPEC_VERSION=Na;exports.CLEAR=ft;exports.CLIPS=Or;exports.CLOTH_COLORS=Pc;exports.CREATURE_KINDS=Em;exports.CharacterView=go;exports.DEFAULT_AVATAR=yr;exports.DEFAULT_AVATAR_ANIM=ct;exports.DEFAULT_AVATAR_FACE=kl;exports.DEFAULT_AVATAR_HEAD=xa;exports.DEFAULT_CHARACTER_SOURCE=Uo;exports.DEFAULT_COLORS=Ns;exports.DEFAULT_FINISH=er;exports.DrawnFace=dr;exports.EMOTES=$e;exports.EMOTE_IDS=Fp;exports.EMOTIONS=At;exports.EMOTION_EVENTS=Up;exports.EVERYDAY_IDS=Vp;exports.EXPRESSIONS=kr;exports.EXPRESSION_CHAIN=cr;exports.EXTRA_BONE_ROLES=ro;exports.EYE_COLORS=Cc;exports.EYE_STYLES=Dr;exports.FACE_NAMES=ut;exports.FACE_TEXELS=as;exports.GESTURE_IDS=_p;exports.HAIR_COLORS=Lc;exports.HELD_KINDS=L1;exports.HUMAN_BOTTOMS=cn;exports.HUMAN_HAIR=E1;exports.HUMAN_SHOES=pn;exports.HUMAN_TOPS=ln;exports.IDLE_STYLES=Ar;exports.IKSolver=Cr;exports.LOCOMOTION=yl;exports.MARK_STYLES=jr;exports.MOUTH_STYLES=Hr;exports.PART_MATERIALS=tr;exports.PART_SHAPES=p1;exports.POSTURE=da;exports.REGION_PAIRS=ya;exports.REST=sr;exports.RIGS=Ae;exports.RIG_CLIPS=Un;exports.RIG_IDS=wr;exports.Ragdoll=Ir;exports.SEAT_HEIGHT_PX=dl;exports.SKIN_COLOR=qt;exports.SKIN_TONES=Mc;exports.SLOT_RULES=ga;exports.SOCKETS=Jc;exports.STARTER_LOOKS=Oh;exports.VOXEL_CHARACTER_SYSTEM_PROMPT=xm;exports.VoxelActor=So;exports.WALK_STYLES=vr;exports.acquireCharacter=Ho;exports.add=de;exports.applyPosture=rs;exports.avatarCatalogExport=Yh;exports.avatarFromServer=Jm;exports.avatarItemShot=Dh;exports.avatarItemsForSlot=Tc;exports.avatarMannequinWith=Oc;exports.avatarPrints=Ea;exports.bandColors=O0;exports.bone=ae;exports.bonesOf=Ua;exports.characterFromImage=vp;exports.characterOf=mp;exports.characterSpecs=hp;exports.clearPose=bt;exports.composeAvatar=Aa;exports.copyPose=Be;exports.createAvatarLighting=fs;exports.createAvatarSnapshotter=xs;exports.createAvatarThumbQueue=Nh;exports.creatureCharacter=Sm;exports.creatureSource=Nl;exports.defaultCharacter=_t;exports.defaultCharacterName=ao;exports.disposeNameplate=Ko;exports.drawAvatarFace=ka;exports.emoteLabelOf=Dp;exports.emotionFromText=Kp;exports.freeAvatarItemsForSlot=_s;exports.humanSource=qo;exports.isAuthorAvatarItem=Xh;exports.isAvatarShopItem=Os;exports.isChairEmote=Bp;exports.isDefaultCharacterName=h1;exports.isEmote=ha;exports.isEmotion=bl;exports.isObj=J;exports.layoutCharacter=Xa;exports.lerpPose=hn;exports.mirrorBone=qa;exports.nameplate=mn;exports.newAnimInput=lo;exports.normColor=ot;exports.npcCharacter=gp;exports.num=Ie;exports.onCharacterKnown=dp;exports.parseAvatarSpec=pr;exports.parseCharacterSpec=Ye;exports.pick=Oo;exports.pixelTextureFromImage=Jh;exports.randomAvatar=Ih;exports.recolor=Go;exports.registerCharacter=pp;exports.releaseCharacter=so;exports.renderAvatarCanvas=uc;exports.renderAvatarImage=$m;exports.rigOfSpec=m1;exports.sampleEmote=Zn;exports.sampleTrack=ul;exports.setCh=y;exports.specHash=rr;exports.stableStringify=_o;exports.standardFace=Sr;exports.styleParams=sa;exports.validateAvatarItem=mr;exports.vec3=oo;