@esotericsoftware/spine-canvas 4.3.8 → 4.3.9

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,2 +1,2 @@
1
- "use strict";var Vn=class{array=[];add(t){const e=this.contains(t);return this.array[t|0]=t|0,!e}contains(t){return this.array[t|0]!==void 0}remove(t){this.array[t|0]=void 0}clear(){this.array.length=0}},Ds=class{entries={};size=0;add(t){const e=this.entries[t];return this.entries[t]=!0,e?!1:(this.size++,!0)}addAll(t){const e=this.size;for(let s=0,n=t.length;s<n;s++)this.add(t[s]);return e!==this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}},z=class Mt{constructor(e=0,s=0,n=0,i=0){this.r=e,this.g=s,this.b=n,this.a=i}static WHITE=new Mt(1,1,1,1);static RED=new Mt(1,0,0,1);static GREEN=new Mt(0,1,0,1);static BLUE=new Mt(0,0,1,1);static MAGENTA=new Mt(1,0,1,1);set(e,s,n,i){return this.r=e,this.g=s,this.b=n,this.a=i,this.clamp()}setFromColor(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}setFromString(e){return e=e.charAt(0)==="#"?e.substr(1):e,this.r=parseInt(e.substr(0,2),16)/255,this.g=parseInt(e.substr(2,2),16)/255,this.b=parseInt(e.substr(4,2),16)/255,this.a=e.length!==8?1:parseInt(e.substr(6,2),16)/255,this}add(e,s,n,i){return this.r+=e,this.g+=s,this.b+=n,this.a+=i,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(e,s){e.r=((s&4278190080)>>>24)/255,e.g=((s&16711680)>>>16)/255,e.b=((s&65280)>>>8)/255,e.a=(s&255)/255}static rgb888ToColor(e,s){e.r=((s&16711680)>>>16)/255,e.g=((s&65280)>>>8)/255,e.b=(s&255)/255}toRgb888(){const e=s=>`0${(s*255).toString(16)}`.slice(-2);return+`0x${e(this.r)}${e(this.g)}${e(this.b)}`}static fromString(e,s=new Mt){return s.setFromString(e)}},R=class lt{static epsilon=1e-5;static epsilon2=lt.epsilon*lt.epsilon;static PI=3.1415927;static PI2=lt.PI*2;static invPI2=1/lt.PI2;static radiansToDegrees=180/lt.PI;static radDeg=lt.radiansToDegrees;static degreesToRadians=lt.PI/180;static degRad=lt.degreesToRadians;static clamp(e,s,n){return e<s?s:e>n?n:e}static cosDeg(e){return Math.cos(e*lt.degRad)}static sinDeg(e){return Math.sin(e*lt.degRad)}static atan2Deg(e,s){return Math.atan2(e,s)*lt.radDeg}static signum(e){return e>0?1:e<0?-1:0}static toInt(e){return e>0?Math.floor(e):Math.ceil(e)}static cbrt(e){const s=Math.pow(Math.abs(e),.3333333333333333);return e<0?-s:s}static randomTriangular(e,s){return lt.randomTriangularWith(e,s,(e+s)*.5)}static randomTriangularWith(e,s,n){const i=Math.random(),r=s-e;return i<=(n-e)/r?e+Math.sqrt(i*r*(n-e)):s-Math.sqrt((1-i)*r*(s-n))}static isPowerOfTwo(e){return e&&(e&e-1)===0}},Bt=class Vt{static linear=new class extends Vt{applyInternal(e){return e}};static smooth=new class extends Vt{applyInternal(e){return e*e*(3-2*e)}};static slowFast=new class extends Vt{applyInternal(e){return e*e}};static fastSlow=new class extends Vt{applyInternal(e){return(e-1)*(e-1)*-1+1}};static circle=new class extends Vt{applyInternal(e){return e<=.5?(e*=2,(1-Math.sqrt(1-e*e))/2):(e--,e*=2,(Math.sqrt(1-e*e)+1)/2)}};apply(e,s,n){return s===void 0||n===void 0?this.applyInternal(e):e+(s-e)*this.applyInternal(n)}},$s=class extends Bt{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(t*2,this.power)/2:Math.pow((t-1)*2,this.power)/(this.power%2===0?-2:2)+1}},Rn=class extends $s{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2===0?-1:1)+1}},L=class Rt{static SUPPORTS_TYPED_ARRAYS=typeof Float32Array<"u";static arrayCopy(e,s,n,i,r){for(let a=s,c=i;a<s+r;a++,c++)n[c]=e[a]}static arrayFill(e,s,n,i){for(let r=s;r<n;r++)e[r]=i}static setArraySize(e,s,n=0){const i=e.length;if(i===s)return e;if(e.length=s,i<s)for(let r=i;r<s;r++)e[r]=n;return e}static ensureArrayCapacity(e,s,n=0){return e.length>=s?e:Rt.setArraySize(e,s,n)}static newArray(e,s){const n=[];for(let i=0;i<e;i++)n[i]=s;return n}static newFloatArray(e){if(Rt.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static newShortArray(e){if(Rt.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static toFloatArray(e){return Rt.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return Rt.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(e){}static contains(e,s,n=!0){for(let i=0;i<e.length;i++)if(e[i]===s)return!0;return!1}static enumValue(e,s){return e[s[0].toUpperCase()+s.slice(1)]}},Ln=class{static logBones(t){for(let e=0;e<t.bones.length;e++){const s=t.bones[e].appliedPose;console.log(`${s.bone.data.name}, ${s.a}, ${s.b}, ${s.c}, ${s.d}, ${s.worldX}, ${s.worldY}`)}}},Ot=class{items=[];instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset?.(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)this.free(t[e])}clear(){this.items.length=0}},Ie=class{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){const t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){const t=this.length();return t!==0&&(this.x/=t,this.y/=t),this}},Bn=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){const t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},On=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(t=32){this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}},Ce=class{_image;constructor(t){this._image=t}getImage(){return this._image}},Jt=(t=>(t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear",t))(Jt||{}),qs=(t=>(t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat",t))(qs||{}),_s=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},Nn=class extends Ce{setFilters(t,e){}setWraps(t,e){}dispose(){}},Me=class{pages=[];regions=[];constructor(t){const e=new Un(t),s=new Array(4),n={};n.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},n.format=()=>{},n.filter=o=>{o.minFilter=L.enumValue(Jt,s[1]),o.magFilter=L.enumValue(Jt,s[2])},n.repeat=o=>{s[1].indexOf("x")!==-1&&(o.uWrap=10497),s[1].indexOf("y")!==-1&&(o.vWrap=10497)},n.pma=o=>{o.pma=s[1]==="true"};var i={};i.xy=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2])},i.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},i.bounds=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2]),o.width=parseInt(s[3]),o.height=parseInt(s[4])},i.offset=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2])},i.orig=o=>{o.originalWidth=parseInt(s[1]),o.originalHeight=parseInt(s[2])},i.offsets=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2]),o.originalWidth=parseInt(s[3]),o.originalHeight=parseInt(s[4])},i.rotate=o=>{const h=s[1];h==="true"?o.degrees=90:h!=="false"&&(o.degrees=parseInt(h))},i.index=o=>{o.index=parseInt(s[1])};let r=e.readLine();for(;r&&r.trim().length===0;)r=e.readLine();for(;!(!r||r.trim().length===0||e.readEntry(s,r)===0);)r=e.readLine();let a=null,c=null,l=null;for(;r!==null;)if(r.trim().length===0)a=null,r=e.readLine();else if(a){const o=new Ye(a,r);for(;;){const h=e.readEntry(s,r=e.readLine());if(h===0)break;const d=i[s[0]];if(d)d(o);else{c||(c=[]),l||(l=[]),c.push(s[0]);const m=[];for(let u=0;u<h;u++)m.push(parseInt(s[u+1]));l.push(m)}}o.originalWidth===0&&o.originalHeight===0&&(o.originalWidth=o.width,o.originalHeight=o.height),c&&c.length>0&&l&&l.length>0&&(o.names=c,o.values=l,c=null,l=null),o.u=o.x/a.width,o.v=o.y/a.height,o.degrees===90?(o.u2=(o.x+o.height)/a.width,o.v2=(o.y+o.width)/a.height):(o.u2=(o.x+o.width)/a.width,o.v2=(o.y+o.height)/a.height),this.regions.push(o)}else{for(a=new zs(r.trim());e.readEntry(s,r=e.readLine())!==0;){const o=n[s[0]];o&&o(a)}this.pages.push(a)}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name===t)return this.regions[e];return null}setTextures(t,e=""){for(const s of this.pages)s.setTexture(t.get(e+s.name))}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture?.dispose()}},Un=class{lines;index=0;constructor(t){this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e||(e=e.trim(),e.length===0))return 0;const s=e.indexOf(":");if(s===-1)return 0;t[0]=e.substr(0,s).trim();for(let n=1,i=s+1;;n++){const r=e.indexOf(",",i);if(r===-1)return t[n]=e.substr(i).trim(),n;if(t[n]=e.substr(i,r-i).trim(),i=r+1,n===4)return 4}}},zs=class{name;minFilter=9728;magFilter=9728;uWrap=33071;vWrap=33071;texture=null;width=0;height=0;pma=!1;regions=[];constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(const e of this.regions)e.texture=t}},Ye=class extends _s{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}},ke=class yn{static empty=[];name;timelineAttachment;timelineSlots=yn.empty;constructor(e){if(!e)throw new Error("name cannot be null.");this.name=e,this.timelineAttachment=this}isTimelineActive(e,s,n){let i=e[s];if(i.bone.isActive()){const r=(n?i.getAppliedPose():i.getPose()).getAttachment();if(r!=null&&r.timelineAttachment===this)return!0}for(let r=0,a=this.timelineSlots.length;r<a;r++){if(i=e[this.timelineSlots[r]],!i.bone.isActive())continue;const c=(n?i.getAppliedPose():i.getPose()).getAttachment();if(c!=null&&c.timelineAttachment===this)return!0}return!1}},xt=class vn extends ke{static nextID=0;id=vn.nextID++;bones=null;vertices=[];worldVerticesLength=0;constructor(e){super(e)}computeWorldVertices(e,s,n,i,r,a,c){i=a+(i>>1)*c;const l=s.appliedPose.deform;let o=this.vertices;const h=this.bones;if(!h){l.length>0&&(o=l);const f=s.bone.appliedPose,p=f.worldX,g=f.worldY,b=f.a,x=f.b,w=f.c,S=f.d;for(let y=n,v=a;v<i;y+=2,v+=c){const T=o[y],A=o[y+1];r[v]=T*b+A*x+p,r[v+1]=T*w+A*S+g}return}let d=0,m=0;for(let f=0;f<n;f+=2){const p=h[d];d+=p+1,m+=p}const u=e.bones;if(l.length===0)for(let f=a,p=m*3;f<i;f+=c){let g=0,b=0,x=h[d++];for(x+=d;d<x;d++,p+=3){const w=u[h[d]].appliedPose,S=o[p],y=o[p+1],v=o[p+2];g+=(S*w.a+y*w.b+w.worldX)*v,b+=(S*w.c+y*w.d+w.worldY)*v}r[f]=g,r[f+1]=b}else{const f=l;for(let p=a,g=m*3,b=m<<1;p<i;p+=c){let x=0,w=0,S=h[d++];for(S+=d;d<S;d++,g+=3,b+=2){const y=u[h[d]].appliedPose,v=o[g]+f[b],T=o[g+1]+f[b+1],A=o[g+2];x+=(v*y.a+T*y.b+y.worldX)*A,w+=(v*y.c+T*y.d+y.worldY)*A}r[p]=x,r[p+1]=w}}}copyTo(e){this.bones?(e.bones=[],L.arrayCopy(this.bones,0,e.bones,0,this.bones.length)):e.bones=null,this.vertices&&(e.vertices=L.newFloatArray(this.vertices.length),L.arrayCopy(this.vertices,0,e.vertices,0,this.vertices.length)),e.worldVerticesLength=this.worldVerticesLength,e.timelineAttachment=this.timelineAttachment,e.timelineSlots=this.timelineSlots}},wt=class Ls extends xt{sequence;regionUVs=[];triangles=[];hullLength=0;path;color=new z(1,1,1,1);sourceMesh=null;edges=[];width=0;height=0;tempColor=new z(0,0,0,0);constructor(e,s){super(e),this.sequence=s}copy(){if(this.sourceMesh)return this.newLinkedMesh();const e=new Ls(this.name,this.sequence.copy());return e.path=this.path,e.color.setFromColor(this.color),this.copyTo(e),e.regionUVs=[],L.arrayCopy(this.regionUVs,0,e.regionUVs,0,this.regionUVs.length),e.triangles=[],L.arrayCopy(this.triangles,0,e.triangles,0,this.triangles.length),e.hullLength=this.hullLength,this.edges&&(e.edges=[],L.arrayCopy(this.edges,0,e.edges,0,this.edges.length)),e.width=this.width,e.height=this.height,e}updateSequence(){this.sequence.update(this)}getSourceMesh(){return this.sourceMesh}setSourceMesh(e){this.sourceMesh=e,e&&(this.bones=e.bones,this.vertices=e.vertices,this.worldVerticesLength=e.worldVerticesLength,this.regionUVs=e.regionUVs,this.triangles=e.triangles,this.hullLength=e.hullLength,this.worldVerticesLength=e.worldVerticesLength,this.edges=e.edges,this.width=e.width,this.height=e.height)}newLinkedMesh(){const e=new Ls(this.name,this.sequence.copy());return e.timelineAttachment=this.timelineAttachment,e.path=this.path,e.color.setFromColor(this.color),e.setSourceMesh(this.sourceMesh?this.sourceMesh:this),e.updateSequence(),e}static computeUVs(e,s,n){if(!e)throw new Error("Region not set.");const i=n.length;let r=e.u,a=e.v,c=0,l=0;if(e instanceof Ye){const o=e.page,h=o.width,d=o.height;switch(e.degrees){case 90:r-=(e.originalHeight-e.offsetY-e.height)/h,a-=(e.originalWidth-e.offsetX-e.width)/d,c=e.originalHeight/h,l=e.originalWidth/d;for(let m=0;m<i;m+=2)n[m]=r+s[m+1]*c,n[m+1]=a+(1-s[m])*l;return;case 180:r-=(e.originalWidth-e.offsetX-e.width)/h,a-=e.offsetY/d,c=e.originalWidth/h,l=e.originalHeight/d;for(let m=0;m<i;m+=2)n[m]=r+(1-s[m])*c,n[m+1]=a+(1-s[m+1])*l;return;case 270:r-=e.offsetY/h,a-=e.offsetX/d,c=e.originalHeight/h,l=e.originalWidth/d;for(let m=0;m<i;m+=2)n[m]=r+(1-s[m+1])*c,n[m+1]=a+s[m]*l;return;default:r-=e.offsetX/h,a-=(e.originalHeight-e.offsetY-e.height)/d,c=e.originalWidth/h,l=e.originalHeight/d}}else e?(c=e.u2-r,l=e.v2-a):(r=a=0,c=l=1);for(let o=0;o<i;o+=2)n[o]=r+s[o]*c,n[o+1]=a+s[o+1]*l}},j=class Sn extends ke{sequence;x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;path;color=new z(1,1,1,1);tempColor=new z(1,1,1,1);constructor(e,s){super(e),this.sequence=s}copy(){const e=new Sn(this.name,this.sequence.copy());return e.path=this.path,e.x=this.x,e.y=this.y,e.scaleX=this.scaleX,e.scaleY=this.scaleY,e.rotation=this.rotation,e.width=this.width,e.height=this.height,e.color.setFromColor(this.color),e}computeWorldVertices(e,s,n,i,r){const a=e.bone.appliedPose,c=a.worldX,l=a.worldY,o=a.a,h=a.b,d=a.c,m=a.d;let u=s[0],f=s[1];n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[2],f=s[3],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[4],f=s[5],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[6],f=s[7],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l}getOffsets(e){return this.sequence.offsets[this.sequence.resolveIndex(e)]}updateSequence(){this.sequence.update(this)}static computeUVs(e,s,n,i,r,a,c,l,o,h){if(!e)throw new Error("Region not set.");const d=c/e.originalWidth*i,m=l/e.originalHeight*r,u=-c/2*i+e.offsetX*d,f=-l/2*r+e.offsetY*m,p=u+e.width*d,g=f+e.height*m,b=a*R.degRad,x=Math.cos(b),w=Math.sin(b),S=u*x+s,y=u*w,v=f*x+n,T=f*w,A=p*x+s,I=p*w,M=g*x+n,Y=g*w;o[0]=S-T,o[1]=v+y,o[2]=S-Y,o[3]=M+y,o[4]=A-Y,o[5]=M+I,o[6]=A-T,o[7]=v+I,e==null?(h[0]=0,h[1]=0,h[2]=0,h[3]=1,h[4]=1,h[5]=1,h[6]=1,h[7]=0):(h[1]=e.v2,h[2]=e.u,h[5]=e.v,h[6]=e.u2,e.degrees===90?(h[0]=e.u2,h[3]=e.v2,h[4]=e.u,h[7]=e.v):(h[0]=e.u,h[3]=e.v,h[4]=e.u2,h[7]=e.v2))}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31},Nt=class ve{static _nextID=0;id=ve.nextID();regions;pathSuffix;uvs;offsets;start=0;digits=0;setupIndex=0;constructor(e,s){this.regions=new Array(e),this.pathSuffix=s}copy(){const e=this.regions.length,s=new ve(e,this.pathSuffix);if(L.arrayCopy(this.regions,0,s.regions,0,e),s.start=this.start,s.digits=this.digits,s.setupIndex=this.setupIndex,this.uvs!=null){const n=this.uvs[0].length;s.uvs=[];for(let i=0;i<e;i++)s.uvs[i]=L.newFloatArray(n),L.arrayCopy(this.uvs[i],0,s.uvs[i],0,n)}if(this.offsets!=null){s.offsets=[];for(let n=0;n<e;n++)s.offsets[n]=[],L.arrayCopy(this.offsets[n],0,s.offsets[n],0,8)}return s}update(e){const s=this.regions.length;if(e instanceof j){this.uvs=[],this.offsets=[];for(let n=0;n<s;n++)this.uvs[n]=L.newFloatArray(8),this.offsets[n]=[],j.computeUVs(this.regions[n],e.x,e.y,e.scaleX,e.scaleY,e.rotation,e.width,e.height,this.offsets[n],this.uvs[n])}else if(e instanceof wt){const n=e.regionUVs;this.uvs=[],this.offsets=void 0;for(let i=0;i<s;i++)this.uvs[i]=L.newFloatArray(n.length),wt.computeUVs(this.regions[i],n,this.uvs[i])}}resolveIndex(e){let s=e.sequenceIndex;return s===-1&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1),s}getUVs(e){return this.uvs[e]}hasPathSuffix(){return this.pathSuffix}getPath(e,s){if(!this.pathSuffix)return e;let n=e;const i=(this.start+s).toString();for(let r=this.digits-i.length;r>0;r--)n+="0";return n+=i,n}static nextID(){return ve._nextID++}},Fe=(t=>(t[t.hold=0]="hold",t[t.once=1]="once",t[t.loop=2]="loop",t[t.pingpong=3]="pingpong",t[t.onceReverse=4]="onceReverse",t[t.loopReverse=5]="loopReverse",t[t.pingpongReverse=6]="pingpongReverse",t))(Fe||{}),Pe=[0,1,2,3,4,5,6],Qt=class{name;timelines=[];timelineIds;bones;color=new z(1,1,1,1);duration;constructor(t,e,s){if(!t)throw new Error("name cannot be null.");this.name=t,this.duration=s,this.timelineIds=new Ds,this.bones=[],this.setTimelines(e)}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t;const e=t.length;this.timelineIds.clear(),this.bones.length=0;const s=new Set,n=t;for(let i=0;i<e;i++){const r=n[i];this.timelineIds.addAll(r.propertyIds),js(r)&&s.add(r.boneIndex)&&this.bones.push(r.boneIndex)}}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,n,i,r,a,c,l,o){if(!t)throw new Error("skeleton cannot be null.");n&&this.duration!==0&&(s%=this.duration,e>0&&(e%=this.duration));const h=this.timelines;for(let d=0,m=h.length;d<m;d++)h[d].apply(t,e,s,i,r,a,c,l,o)}},Ws=(t=>(t[t.current=0]="current",t[t.setup=1]="setup",t[t.first=2]="first",t))(Ws||{}),Hs=(t=>(t[t.rotate=0]="rotate",t[t.x=1]="x",t[t.y=2]="y",t[t.scaleX=3]="scaleX",t[t.scaleY=4]="scaleY",t[t.shearX=5]="shearX",t[t.shearY=6]="shearY",t[t.inherit=7]="inherit",t[t.rgb=8]="rgb",t[t.alpha=9]="alpha",t[t.rgb2=10]="rgb2",t[t.attachment=11]="attachment",t[t.deform=12]="deform",t[t.event=13]="event",t[t.drawOrder=14]="drawOrder",t[t.drawOrderFolder=15]="drawOrderFolder",t[t.ikConstraint=16]="ikConstraint",t[t.transformConstraint=17]="transformConstraint",t[t.pathConstraintPosition=18]="pathConstraintPosition",t[t.pathConstraintSpacing=19]="pathConstraintSpacing",t[t.pathConstraintMix=20]="pathConstraintMix",t[t.physicsConstraintInertia=21]="physicsConstraintInertia",t[t.physicsConstraintStrength=22]="physicsConstraintStrength",t[t.physicsConstraintDamping=23]="physicsConstraintDamping",t[t.physicsConstraintMass=24]="physicsConstraintMass",t[t.physicsConstraintWind=25]="physicsConstraintWind",t[t.physicsConstraintGravity=26]="physicsConstraintGravity",t[t.physicsConstraintMix=27]="physicsConstraintMix",t[t.physicsConstraintReset=28]="physicsConstraintReset",t[t.sequence=29]="sequence",t[t.sliderTime=30]="sliderTime",t[t.sliderMix=31]="sliderMix",t))(Hs||{}),Z=class{propertyIds;frames;additive=!1;instant=!1;constructor(t,...e){this.propertyIds=e,this.frames=L.newFloatArray(t*this.getFrameEntries())}getPropertyIds(){return this.propertyIds}getFrameEntries(){return 1}getFrameCount(){return this.frames.length/this.getFrameEntries()}getDuration(){return this.frames[this.frames.length-this.getFrameEntries()]}static search(t,e,s=1){const n=t.length;for(let i=s;i<n;i+=s)if(t[i]>e)return i-s;return n-s}};function Gs(t){return typeof t=="object"&&t!==null&&typeof t.slotIndex=="number"}var yt=class extends Z{curves;constructor(t,e,...s){super(t,...s),this.curves=L.newFloatArray(t+e*18),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){const e=this.getFrameCount()+t*18;if(this.curves.length>e){const s=L.newFloatArray(e);L.arrayCopy(this.curves,0,s,0,e),this.curves=s}}setBezier(t,e,s,n,i,r,a,c,l,o,h){const d=this.curves;let m=this.getFrameCount()+t*18;s===0&&(d[e]=2+m);const u=(n-r*2+c)*.03,f=(i-a*2+l)*.03,p=((r-c)*3-n+o)*.006,g=((a-l)*3-i+h)*.006;let b=u*2+p,x=f*2+g,w=(r-n)*.3+u+p*.16666667,S=(a-i)*.3+f+g*.16666667,y=n+w,v=i+S;for(let T=m+18;m<T;m+=2)d[m]=y,d[m+1]=v,w+=b,S+=x,b+=p,x+=g,y+=w,v+=S}getBezierValue(t,e,s,n){const i=this.curves;if(i[n]>t){const l=this.frames[e],o=this.frames[e+s];return o+(t-l)/(i[n]-l)*(i[n+1]-o)}const r=n+18;for(n+=2;n<r;n+=2)if(i[n]>=t){const l=i[n-2],o=i[n-1];return o+(t-l)/(i[n]-l)*(i[n+1]-o)}e+=this.getFrameEntries();const a=i[r-2],c=i[r-1];return c+(t-a)/(this.frames[e]-a)*(this.frames[e+s]-c)}},Ut=class jt extends yt{constructor(e,s,n){super(e,s,n)}getFrameEntries(){return 2}setFrame(e,s,n){e<<=1,this.frames[e]=s,this.frames[e+1]=n}getCurveValue(e){const s=this.frames;let n=s.length-2;for(let r=2;r<=n;r+=2)if(s[r]>e){n=r-2;break}const i=this.curves[n>>1];switch(i){case 0:{const r=s[n],a=s[n+1];return a+(e-r)/(s[n+2]-r)*(s[n+2+1]-a)}case 1:return s[n+1]}return this.getBezierValue(e,n,1,i-2)}getRelativeValue(e,s,n,i,r,a){if(e<this.frames[0])return jt.beforeFirstKey(n,s,r,a);const c=this.getCurveValue(e);return n===1?a+c*s:r+(i?c:c+a-r)*s}getAbsoluteValue(e,s,n,i,r,a,c){return c===void 0?this.getAbsoluteValue1(e,s,n,i,r,a):this.getAbsoluteValue2(e,s,n,i,r,a,c)}getAbsoluteValue1(e,s,n,i,r,a){if(e<this.frames[0])return jt.beforeFirstKey(n,s,r,a);const c=this.getCurveValue(e);return n===1?a+(i?c:c-a)*s:r+(i?c:c-r)*s}getAbsoluteValue2(e,s,n,i,r,a,c){return e<this.frames[0]?jt.beforeFirstKey(n,s,r,a):n===1?a+(i?c:c-a)*s:r+(i?c:c-r)*s}getScaleValue(e,s,n,i,r,a,c){if(e<this.frames[0])return jt.beforeFirstKey(n,s,a,c);const l=this.getCurveValue(e)*c;if(s===1&&!i)return l;let o=n===1?c:a;return i?o+(l-c)*s:r?o+(Math.abs(l)*Math.sign(o)-o)*s:(o=Math.abs(o)*Math.sign(l),o+(l-o)*s)}static beforeFirstKey(e,s,n,i){switch(e){case 1:return i;case 2:return n+(i-n)*s;case 0:return n}}};function js(t){return typeof t=="object"&&t!==null&&typeof t.boneIndex=="number"}var vt=class extends Ut{boneIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.boneIndex=s,this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];o.active&&this.apply1(l?o.appliedPose:o.pose,o.data.setupPose,s,i,r,a,c)}},Zt=class extends yt{boneIndex;constructor(t,e,s,n,i){super(t,e,`${n}|${s}`,`${i}|${s}`),this.boneIndex=s,this.additive=!0}getFrameEntries(){return 3}setFrame(t,e,s,n){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];o.active&&this.apply1(l?o.appliedPose:o.pose,o.data.setupPose,s,i,r,a,c)}},Dt=class extends vt{constructor(t,e,s){super(t,e,s,0)}apply1(t,e,s,n,i,r,a){t.rotation=this.getRelativeValue(s,n,i,r,t.rotation,e.rotation)}},Ee=class extends Zt{constructor(t,e,s){super(t,e,s,1,2)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.x=e.x,t.y=e.y;break;case 2:t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n;break}return}let l=0,o=0;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i===1?(t.x=e.x+l*n,t.y=e.y+o*n):r?(t.x+=l*n,t.y+=o*n):(t.x+=(e.x+l-t.x)*n,t.y+=(e.y+o-t.y)*n)}},Xe=class extends vt{constructor(t,e,s){super(t,e,s,1)}apply1(t,e,s,n,i,r,a){t.x=this.getRelativeValue(s,n,i,r,t.x,e.x)}},Ve=class extends vt{constructor(t,e,s){super(t,e,s,2)}apply1(t,e,s,n,i,r,a){t.y=this.getRelativeValue(s,n,i,r,t.y,e.y)}},Re=class extends Zt{constructor(t,e,s){super(t,e,s,3,4)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.scaleX=e.scaleX,t.scaleY=e.scaleY;break;case 2:t.scaleX+=(e.scaleX-t.scaleX)*n,t.scaleY+=(e.scaleY-t.scaleY)*n;break}return}let l,o;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}if(l*=e.scaleX,o*=e.scaleY,n===1&&!r)t.scaleX=l,t.scaleY=o;else{let m=0,u=0;i===1?(m=e.scaleX,u=e.scaleY):(m=t.scaleX,u=t.scaleY),r?(t.scaleX=m+(l-e.scaleX)*n,t.scaleY=u+(o-e.scaleY)*n):a?(t.scaleX=m+(Math.abs(l)*Math.sign(m)-m)*n,t.scaleY=u+(Math.abs(o)*Math.sign(u)-u)*n):(m=Math.abs(m)*Math.sign(l),u=Math.abs(u)*Math.sign(o),t.scaleX=m+(l-m)*n,t.scaleY=u+(o-u)*n)}}},Le=class extends vt{constructor(t,e,s){super(t,e,s,3)}apply1(t,e,s,n,i,r,a){t.scaleX=this.getScaleValue(s,n,i,r,a,t.scaleX,e.scaleX)}},Be=class extends vt{constructor(t,e,s){super(t,e,s,4)}apply1(t,e,s,n,i,r,a){t.scaleY=this.getScaleValue(s,n,i,r,a,t.scaleY,e.scaleY)}},Oe=class extends Zt{constructor(t,e,s){super(t,e,s,5,6)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.shearX=e.shearX,t.shearY=e.shearY;break;case 2:t.shearX+=(e.shearX-t.shearX)*n,t.shearY+=(e.shearY-t.shearY)*n;break}return}let l=0,o=0;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i===1?(t.shearX=e.shearX+l*n,t.shearY=e.shearY+o*n):r?(t.shearX+=l*n,t.shearY+=o*n):(t.shearX+=(e.shearX+l-t.shearX)*n,t.shearY+=(e.shearY+o-t.shearY)*n)}},Ne=class extends vt{constructor(t,e,s){super(t,e,s,5)}apply1(t,e,s,n,i,r,a){t.shearX=this.getRelativeValue(s,n,i,r,t.shearX,e.shearX)}},Ue=class extends vt{constructor(t,e,s){super(t,e,s,6)}apply1(t,e,s,n,i,r,a){t.shearY=this.getRelativeValue(s,n,i,r,t.shearY,e.shearY)}},De=class extends Z{boneIndex;constructor(t,e){super(t,`7|${e}`),this.boneIndex=e,this.instant=!0}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose;if(c)r!==0&&(h.inherit=o.data.setupPose.inherit);else{const d=this.frames;s<d[0]?r!==0&&(h.inherit=o.data.setupPose.inherit):h.inherit=this.frames[Z.search(d,s,2)+1]}}},$t=class extends yt{slotIndex;constructor(t,e,s,...n){super(t,e,...n),this.slotIndex=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];o.bone.active&&this.apply1(o,l?o.appliedPose:o.pose,s,i,r,a)}},$e=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`9|${s}`)}getFrameEntries(){return 5}setFrame(t,e,s,n,i,r){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r}apply1(t,e,s,n,i,r){const a=e.color,c=this.frames;if(s<c[0]){const f=t.data.setupPose.color;switch(i){case 1:a.setFromColor(f);break;case 2:a.add((f.r-a.r)*n,(f.g-a.g)*n,(f.b-a.b)*n,(f.a-a.a)*n);break}return}let l=0,o=0,h=0,d=0;const m=Z.search(c,s,5),u=this.curves[m/5];switch(u){case 0:{const f=c[m];l=c[m+1],o=c[m+2],h=c[m+3],d=c[m+4];const p=(s-f)/(c[m+5]-f);l+=(c[m+5+1]-l)*p,o+=(c[m+5+2]-o)*p,h+=(c[m+5+3]-h)*p,d+=(c[m+5+4]-d)*p;break}case 1:l=c[m+1],o=c[m+2],h=c[m+3],d=c[m+4];break;default:l=this.getBezierValue(s,m,1,u-2),o=this.getBezierValue(s,m,2,u+18-2),h=this.getBezierValue(s,m,3,u+36-2),d=this.getBezierValue(s,m,4,u+54-2)}if(n===1)a.set(l,o,h,d);else if(i===1){const f=t.data.setupPose.color;a.set(f.r+(l-f.r)*n,f.g+(o-f.g)*n,f.b+(h-f.b)*n,f.a+(d-f.a)*n)}else a.add((l-a.r)*n,(o-a.g)*n,(h-a.b)*n,(d-a.a)*n)}},qe=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`)}getFrameEntries(){return 4}setFrame(t,e,s,n,i){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i}apply1(t,e,s,n,i,r){const a=e.color;let c=0,l=0,o=0;const h=this.frames;if(s<h[0]){const u=t.data.setupPose.color;switch(i){case 1:{a.r=u.r,a.g=u.g,a.b=u.b;break}case 2:{a.r+=(u.r-a.r)*n,a.g+=(u.g-a.g)*n,a.b+=(u.b-a.b)*n;break}}return}const d=Z.search(h,s,4),m=this.curves[d>>2];switch(m){case 0:{const u=h[d];c=h[d+1],l=h[d+2],o=h[d+3];const f=(s-u)/(h[d+4]-u);c+=(h[d+4+1]-c)*f,l+=(h[d+4+2]-l)*f,o+=(h[d+4+3]-o)*f;break}case 1:c=h[d+1],l=h[d+2],o=h[d+3];break;default:c=this.getBezierValue(s,d,1,m-2),l=this.getBezierValue(s,d,2,m+18-2),o=this.getBezierValue(s,d,3,m+36-2)}if(n!==1)if(i===1){const u=t.data.setupPose.color;c=u.r+(c-u.r)*n,l=u.g+(l-u.g)*n,o=u.b+(o-u.b)*n}else c=a.r+(c-a.r)*n,l=a.g+(l-a.g)*n,o=a.b+(o-a.b)*n;a.r=c<0?0:c>1?1:c,a.g=l<0?0:l>1?1:l,a.b=o<0?0:o>1?1:o}},_e=class extends Ut{slotIndex=0;constructor(t,e,s){super(t,e,`9|${s}`),this.slotIndex=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];if(!o.bone.active)return;const h=(l?o.appliedPose:o.pose).color;let d=0;const m=this.frames;if(s<m[0]){const u=o.data.setupPose.color.a;switch(r){case 1:h.a=u;break;case 2:h.a+=(u-h.a)*i;break}return}if(d=this.getCurveValue(s),i!==1)if(r===1){const u=o.data.setupPose.color;d=u.a+(d-u.a)*i}else d=h.a+(d-h.a)*i;h.a=d<0?0:d>1?1:d}},ze=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`9|${s}`,`10|${s}`)}getFrameEntries(){return 8}setFrame(t,e,s,n,i,r,a,c,l){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=c,this.frames[t+7]=l}apply1(t,e,s,n,i,r){const a=e.color,c=e.darkColor;let l=0,o=0,h=0;const d=this.frames;if(s<d[0]){const x=t.data.setupPose,w=x.color,S=x.darkColor;switch(i){case 1:{a.setFromColor(w),c.r=S.r,c.g=S.g,c.b=S.b;break}case 2:{a.add((w.r-a.r)*n,(w.g-a.g)*n,(w.b-a.b)*n,(w.a-a.a)*n),c.r+=(S.r-c.r)*n,c.g+=(S.g-c.g)*n,c.b+=(S.b-c.b)*n;break}}return}let m=0,u=0,f=0,p=0;const g=Z.search(d,s,8),b=this.curves[g>>3];switch(b){case 0:{const x=d[g];m=d[g+1],u=d[g+2],f=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];const w=(s-x)/(d[g+8]-x);m+=(d[g+8+1]-m)*w,u+=(d[g+8+2]-u)*w,f+=(d[g+8+3]-f)*w,p+=(d[g+8+4]-p)*w,l+=(d[g+8+5]-l)*w,o+=(d[g+8+6]-o)*w,h+=(d[g+8+7]-h)*w;break}case 1:m=d[g+1],u=d[g+2],f=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];break;default:m=this.getBezierValue(s,g,1,b-2),u=this.getBezierValue(s,g,2,b+18-2),f=this.getBezierValue(s,g,3,b+36-2),p=this.getBezierValue(s,g,4,b+54-2),l=this.getBezierValue(s,g,5,b+72-2),o=this.getBezierValue(s,g,6,b+90-2),h=this.getBezierValue(s,g,7,b+108-2)}if(n===1)a.set(m,u,f,p);else if(i===1){const x=t.data.setupPose;let w=x.color;a.set(w.r+(m-w.r)*n,w.g+(u-w.g)*n,w.b+(f-w.b)*n,w.a+(p-w.a)*n),w=x.darkColor,l=w.r+(l-w.r)*n,o=w.g+(o-w.g)*n,h=w.b+(h-w.b)*n}else a.add((m-a.r)*n,(u-a.g)*n,(f-a.b)*n,(p-a.a)*n),l=c.r+(l-c.r)*n,o=c.g+(o-c.g)*n,h=c.b+(h-c.b)*n;c.r=l<0?0:l>1?1:l,c.g=o<0?0:o>1?1:o,c.b=h<0?0:h>1?1:h}},We=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`10|${s}`)}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,a,c){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=c}apply1(t,e,s,n,i,r){const a=e.color,c=e.darkColor;let l=0,o=0,h=0,d=0,m=0,u=0;const f=this.frames;if(s<f[0]){const b=t.data.setupPose,x=b.color,w=b.darkColor;switch(i){case 1:a.r=x.r,a.g=x.g,a.b=x.b,c.r=w.r,c.g=w.g,c.b=w.b;break;case 2:a.r+=(x.r-a.r)*n,a.g+=(x.g-a.g)*n,a.b+=(x.b-a.b)*n,c.r+=(w.r-c.r)*n,c.g+=(w.g-c.g)*n,c.b+=(w.b-c.b)*n;break}return}const p=Z.search(f,s,7),g=this.curves[p/7];switch(g){case 0:{const b=f[p];l=f[p+1],o=f[p+2],h=f[p+3],d=f[p+4],m=f[p+5],u=f[p+6];const x=(s-b)/(f[p+7]-b);l+=(f[p+7+1]-l)*x,o+=(f[p+7+2]-o)*x,h+=(f[p+7+3]-h)*x,d+=(f[p+7+4]-d)*x,m+=(f[p+7+5]-m)*x,u+=(f[p+7+6]-u)*x;break}case 1:l=f[p+1],o=f[p+2],h=f[p+3],d=f[p+4],m=f[p+5],u=f[p+6];break;default:l=this.getBezierValue(s,p,1,g-2),o=this.getBezierValue(s,p,2,g+18-2),h=this.getBezierValue(s,p,3,g+36-2),d=this.getBezierValue(s,p,4,g+54-2),m=this.getBezierValue(s,p,5,g+72-2),u=this.getBezierValue(s,p,6,g+90-2)}if(n!==1)if(i===1){const b=t.data.setupPose;let x=b.color;l=x.r+(l-x.r)*n,o=x.g+(o-x.g)*n,h=x.b+(h-x.b)*n,x=b.darkColor,d=x.r+(d-x.r)*n,m=x.g+(m-x.g)*n,u=x.b+(u-x.b)*n}else l=a.r+(l-a.r)*n,o=a.g+(o-a.g)*n,h=a.b+(h-a.b)*n,d=c.r+(d-c.r)*n,m=c.g+(m-c.g)*n,u=c.b+(u-c.b)*n;a.r=l<0?0:l>1?1:l,a.g=o<0?0:o>1?1:o,a.b=h<0?0:h>1?1:h,c.r=d<0?0:d>1?1:d,c.g=m<0?0:m>1?1:m,c.b=u<0?0:u>1?1:u}},Ft=class extends Z{slotIndex=0;attachmentNames;constructor(t,e){super(t,`11|${e}`),this.slotIndex=e,this.attachmentNames=new Array(t),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];if(!o.bone.active)return;const h=l?o.appliedPose:o.pose;c||s<this.frames[0]?r!==0&&this.setAttachment(t,h,o.data.attachmentName):this.setAttachment(t,h,this.attachmentNames[Z.search(this.frames,s)])}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}},He=class extends yt{slotIndex;attachment;vertices;constructor(t,e,s,n){super(t,e,`12|${s}|${n.id}`),this.slotIndex=s,this.attachment=n,this.vertices=new Array(t),this.additive=!0}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,n,i,r,a,c,l,o,h){const d=this.curves;let m=this.getFrameCount()+t*18;s===0&&(d[e]=2+m);const u=(n-r*2+c)*.03,f=l*.03-a*.06,p=((r-c)*3-n+o)*.006,g=(a-l+.33333333)*.018;let b=u*2+p,x=f*2+g,w=(r-n)*.3+u+p*.16666667,S=a*.3+f+g*.16666667,y=n+w,v=S;for(let T=m+18;m<T;m+=2)d[m]=y,d[m+1]=v,w+=b,S+=x,b+=p,x+=g,y+=w,v+=S}getCurvePercent(t,e){const s=this.curves;let n=s[e];switch(n){case 0:{const c=this.frames[e];return(t-c)/(this.frames[e+this.getFrameEntries()]-c)}case 1:return 0}if(n-=2,s[n]>t){const c=this.frames[e];return s[n+1]*(t-c)/(s[n]-c)}const i=n+18;for(n+=2;n<i;n+=2)if(s[n]>=t){const c=s[n-2],l=s[n-1];return l+(t-c)/(s[n]-c)*(s[n+1]-l)}const r=s[i-2],a=s[i-1];return a+(1-a)*(t-r)/(this.frames[e+this.getFrameEntries()]-r)}apply(t,e,s,n,i,r,a,c,l){const o=t.slots;if(!this.attachment.isTimelineActive(o,this.slotIndex,l))return;const h=this.attachment.timelineSlots,d=this.frames;if(s<d[0]){this.applyBeforeFirst(o[this.slotIndex],l,i,r);for(const g of h)this.applyBeforeFirst(o[g],l,i,r);return}let m,u,f;if(s>=d[d.length-1])f=0,m=this.vertices[d.length-1],u=null;else{const g=Z.search(d,s);f=this.getCurvePercent(s,g),m=this.vertices[g],u=this.vertices[g+1]}const p=this.vertices[0].length;this.applyToSlot(o[this.slotIndex],l,m,u,f,p,i,r,a);for(const g of h)this.applyToSlot(o[g],l,m,u,f,p,i,r,a)}applyBeforeFirst(t,e,s,n){if(!t.bone.active)return;const i=e?t.appliedPose:t.pose;if(i.attachment==null||i.attachment.timelineAttachment!==this.attachment)return;const r=i.deform;switch(r.length===0&&(n=1),n){case 1:r.length=0;break;case 2:{if(s===1){r.length=0;return}const a=this.vertices[0].length;r.length=a;const c=r,l=i.attachment;if(l.bones===null){const o=l.vertices;for(let h=0;h<a;h++)c[h]+=(o[h]-c[h])*s}else{s=1-s;for(let o=0;o<a;o++)c[o]*=s}}}}applyToSlot(t,e,s,n,i,r,a,c,l){if(!t.bone.active)return;const o=e?t.appliedPose:t.pose;if(o.attachment===null||o.attachment.timelineAttachment!==this.attachment)return;const h=o.attachment,d=o.deform;d.length===0&&(c=1);const m=c===1;if(d.length=r,n===null)if(a===1)if(l&&!m)if(h.bones)for(let u=0;u<r;u++)d[u]+=s[u];else{const u=h.vertices;for(let f=0;f<r;f++)d[f]+=s[f]-u[f]}else L.arrayCopy(s,0,d,0,r);else if(m)if(h.bones)for(let u=0;u<r;u++)d[u]=s[u]*a;else{const u=h.vertices;for(let f=0;f<r;f++){const p=u[f];d[f]=p+(s[f]-p)*a}}else if(l)if(h.bones)for(let u=0;u<r;u++)d[u]+=s[u]*a;else{const u=h.vertices;for(let f=0;f<r;f++)d[f]+=(s[f]-u[f])*a}else for(let u=0;u<r;u++)d[u]+=(s[u]-d[u])*a;else if(a===1)if(l&&!m)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]+=f+(n[u]-f)*i}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f];d[f]+=p+(n[f]-p)*i-u[f]}}else if(i===0)L.arrayCopy(s,0,d,0,r);else for(let u=0;u<r;u++){const f=s[u];d[u]=f+(n[u]-f)*i}else if(m)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]=(f+(n[u]-f)*i)*a}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f],g=u[f];d[f]=g+(p+(n[f]-p)*i-g)*a}}else if(l)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]+=(f+(n[u]-f)*i)*a}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f];d[f]+=(p+(n[f]-p)*i-u[f])*a}}else for(let u=0;u<r;u++){const f=s[u];d[u]+=(f+(n[u]-f)*i-d[u])*a}}},Ge=class Tt extends Z{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(e,s,n){super(e,`29|${s}|${n.sequence.id}`),this.slotIndex=s,this.attachment=n,this.instant=!0}getFrameEntries(){return Tt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(e,s,n,i,r){const a=this.frames;e*=Tt.ENTRIES,a[e]=s,a[e+Tt.MODE]=n|i<<4,a[e+Tt.DELAY]=r}apply(e,s,n,i,r,a,c,l,o){const h=e.slots;if(!this.attachment.isTimelineActive(h,this.slotIndex,o))return;const d=this.attachment.timelineSlots,m=this.frames;if(l||n<m[0]){if(a!==0){this.setupPose(h[this.slotIndex],o);for(const b of d)this.setupPose(h[b],o)}return}const u=Z.search(m,n,Tt.ENTRIES),f=m[u],p=m[u+Tt.MODE],g=m[u+Tt.DELAY];this.applyToSlot(h[this.slotIndex],o,n,f,p,g);for(const b of d)this.applyToSlot(h[b],o,n,f,p,g)}setupPose(e,s){if(!e.bone.active)return;const n=s?e.appliedPose:e.pose;n.attachment===null||n.attachment.timelineAttachment!==this.attachment||(n.sequenceIndex=-1)}applyToSlot(e,s,n,i,r,a){if(!e.bone.active)return;const c=s?e.appliedPose:e.pose;if(c.attachment===null||c.attachment.timelineAttachment!==this.attachment)return;let l=r>>4,o=c.attachment.sequence.regions.length;const h=Pe[r&15];if(h!==0)switch(l+=(n-i)/a+1e-5|0,h){case 1:l=Math.min(o-1,l);break;case 2:l%=o;break;case 3:{const d=(o<<1)-2;l=d===0?0:l%d,l>=o&&(l=d-l);break}case 4:l=Math.max(o-1-l,0);break;case 5:l=o-1-l%o;break;case 6:{const d=(o<<1)-2;l=d===0?0:(l+o-1)%d,l>=o&&(l=d-l)}}c.sequenceIndex=l}},te=class Tn extends Z{static propertyIds=["13"];events;constructor(e){super(e,...Tn.propertyIds),this.events=new Array(e),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s){this.frames[e]=s.time,this.events[e]=s}apply(e,s,n,i,r,a,c,l,o){if(!i)return;const h=this.frames,d=this.frames.length;if(s>n)this.apply(null,s,Number.MAX_VALUE,i,0,a,!1,!1,!1),s=-1;else if(s>=h[d-1])return;if(n<h[0])return;let m=0;if(s<h[0])m=0;else{m=Z.search(h,s)+1;const u=h[m];for(;m>0&&h[m-1]===u;)m--}for(;m<d&&n>=h[m];m++)i.push(this.events[m])}},At=class Bs extends Z{static propertyID="14";static propertyIds=[Bs.propertyID];drawOrders;constructor(e){super(e,...Bs.propertyIds),this.drawOrders=new Array(e),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s,n){this.frames[e]=s,this.drawOrders[e]=n}apply(e,s,n,i,r,a,c,l,o){const h=o?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(l||n<this.frames[0]){a!==0&&L.arrayCopy(d,0,h,0,e.slots.length);return}const m=this.drawOrders[Z.search(this.frames,n)];if(!m)L.arrayCopy(d,0,h,0,e.slots.length);else for(let u=0,f=m.length;u<f;u++)h[u]=d[m[u]]}},qt=class Os extends Z{static propertyID="15";slots;inFolder;drawOrders;constructor(e,s,n){super(e,...Os.propertyIds(s)),this.slots=s,this.drawOrders=new Array(e),this.inFolder=new Array(n);for(const i of s)this.inFolder[i]=!0;this.instant=!0}static propertyIds(e){const s=e.length,n=new Array(s);for(let i=0;i<s;i++)n[i]=`${Os.propertyID}|${e[i]}`;return n}getFrameCount(){return this.frames.length}getSlots(){return this.slots}getDrawOrders(){return this.drawOrders}setFrame(e,s,n){this.frames[e]=s,this.drawOrders[e]=n}apply(e,s,n,i,r,a,c,l,o){const h=o?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(l||n<this.frames[0])a!==0&&this.setup(h,d);else{const m=this.drawOrders[Z.search(this.frames,n)];if(!m)this.setup(h,d);else{const u=this.inFolder,f=this.slots;for(let p=0,g=0,b=f.length;!(u[h[p].data.index]&&(h[p]=d[f[m[g]]],++g===b));p++);}}}setup(e,s){const{inFolder:n,slots:i}=this;for(let r=0,a=0,c=i.length;!(n[e[r].data.index]&&(e[r]=s[i[a]],++a===c));r++);}};function Ks(t){return typeof t=="object"&&t!==null&&typeof t.constraintIndex=="number"}var je=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`16|${s}`),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,n,i,r,a){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r?1:0,this.frames[t+5]=a?1:0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const b=o.data.setupPose;switch(r){case 1:{h.mix=b.mix,h.softness=b.softness,h.bendDirection=b.bendDirection,h.compress=b.compress,h.stretch=b.stretch;break}case 2:{h.mix+=(b.mix-h.mix)*i,h.softness+=(b.softness-h.softness)*i,h.bendDirection=b.bendDirection,h.compress=b.compress,h.stretch=b.stretch;break}}return}let m=0,u=0;const f=Z.search(d,s,6),p=this.curves[f/6];switch(p){case 0:{const b=d[f];m=d[f+1],u=d[f+2];const x=(s-b)/(d[f+6]-b);m+=(d[f+6+1]-m)*x,u+=(d[f+6+2]-u)*x;break}case 1:m=d[f+1],u=d[f+2];break;default:m=this.getBezierValue(s,f,1,p-2),u=this.getBezierValue(s,f,2,p+18-2)}const g=r===1?o.data.setupPose:h;h.mix=g.mix+(m-g.mix)*i,h.softness=g.softness+(u-g.softness)*i,c?r===1&&(h.bendDirection=g.bendDirection,h.compress=g.compress,h.stretch=g.stretch):(h.bendDirection=d[f+3],h.compress=d[f+4]!==0,h.stretch=d[f+5]!==0)}},Ke=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`17|${s}`),this.constraintIndex=s,this.additive=!0}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,a,c){const l=this.frames;t*=7,l[t]=e,l[t+1]=s,l[t+2]=n,l[t+3]=i,l[t+4]=r,l[t+5]=a,l[t+6]=c}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const y=o.data.setupPose;switch(r){case 1:{h.mixRotate=y.mixRotate,h.mixX=y.mixX,h.mixY=y.mixY,h.mixScaleX=y.mixScaleX,h.mixScaleY=y.mixScaleY,h.mixShearY=y.mixShearY;break}case 2:{h.mixRotate+=(y.mixRotate-h.mixRotate)*i,h.mixX+=(y.mixX-h.mixX)*i,h.mixY+=(y.mixY-h.mixY)*i,h.mixScaleX+=(y.mixScaleX-h.mixScaleX)*i,h.mixScaleY+=(y.mixScaleY-h.mixScaleY)*i,h.mixShearY+=(y.mixShearY-h.mixShearY)*i;break}}return}let m,u,f,p,g,b;const x=Z.search(d,s,7),w=this.curves[x/7];switch(w){case 0:{const y=d[x];m=d[x+1],u=d[x+2],f=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];const v=(s-y)/(d[x+7]-y);m+=(d[x+7+1]-m)*v,u+=(d[x+7+2]-u)*v,f+=(d[x+7+3]-f)*v,p+=(d[x+7+4]-p)*v,g+=(d[x+7+5]-g)*v,b+=(d[x+7+6]-b)*v;break}case 1:m=d[x+1],u=d[x+2],f=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];break;default:m=this.getBezierValue(s,x,1,w-2),u=this.getBezierValue(s,x,2,w+18-2),f=this.getBezierValue(s,x,3,w+36-2),p=this.getBezierValue(s,x,4,w+54-2),g=this.getBezierValue(s,x,5,w+72-2),b=this.getBezierValue(s,x,6,w+90-2)}const S=r===1?o.data.setupPose:h;a?(h.mixRotate=S.mixRotate+m*i,h.mixX=S.mixX+u*i,h.mixY=S.mixY+f*i,h.mixScaleX=S.mixScaleX+p*i,h.mixScaleY=S.mixScaleY+g*i,h.mixShearY=S.mixShearY+b*i):(h.mixRotate=S.mixRotate+(m-S.mixRotate)*i,h.mixX=S.mixX+(u-S.mixX)*i,h.mixY=S.mixY+(f-S.mixY)*i,h.mixScaleX=S.mixScaleX+(p-S.mixScaleX)*i,h.mixScaleY=S.mixScaleY+(g-S.mixScaleY)*i,h.mixShearY=S.mixShearY+(b-S.mixShearY)*i)}},Pt=class extends Ut{constraintIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.constraintIndex=s}},Je=class extends Pt{constructor(t,e,s){super(t,e,s,18),this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.position=this.getAbsoluteValue(s,i,r,a,h.position,o.data.setupPose.position)}}},Qe=class extends Pt{constructor(t,e,s){super(t,e,s,19)}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.spacing=this.getAbsoluteValue(s,i,r,!1,h.spacing,o.data.setupPose.spacing)}}},Ze=class extends yt{constraintIndex;constructor(t,e,s){super(t,e,`20|${s}`),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,n,i){const r=this.frames;t<<=2,r[t]=e,r[t+1]=s,r[t+2]=n,r[t+3]=i}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const x=o.data.setupPose;switch(r){case 1:{h.mixRotate=x.mixRotate,h.mixX=x.mixX,h.mixY=x.mixY;break}case 2:{h.mixRotate+=(x.mixRotate-h.mixRotate)*i,h.mixX+=(x.mixX-h.mixX)*i,h.mixY+=(x.mixY-h.mixY)*i;break}}return}let m,u,f;const p=Z.search(d,s,4),g=this.curves[p>>2];switch(g){case 0:{const x=d[p];m=d[p+1],u=d[p+2],f=d[p+3];const w=(s-x)/(d[p+4]-x);m+=(d[p+4+1]-m)*w,u+=(d[p+4+2]-u)*w,f+=(d[p+4+3]-f)*w;break}case 1:m=d[p+1],u=d[p+2],f=d[p+3];break;default:m=this.getBezierValue(s,p,1,g-2),u=this.getBezierValue(s,p,2,g+18-2),f=this.getBezierValue(s,p,3,g+36-2)}const b=r===1?o.data.setupPose:h;a?(h.mixRotate=b.mixRotate+m*i,h.mixX=b.mixX+u*i,h.mixY=b.mixY+f*i):(h.mixRotate=b.mixRotate+(m-b.mixRotate)*i,h.mixX=b.mixX+(u-b.mixX)*i,h.mixY=b.mixY+(f-b.mixY)*i)}},bt=class extends Pt{constructor(t,e,s,n){super(t,e,s,n)}apply(t,e,s,n,i,r,a,c,l){if(a&&!this.additive&&(a=!1),this.constraintIndex===-1){const o=s>=this.frames[0]?this.getCurveValue(s):0,h=t.physics;for(const d of h)if(d.active&&this.global(d.data)){const m=l?d.appliedPose:d.pose;this.set(m,this.getAbsoluteValue(s,i,r,a,this.get(m),this.get(d.data.setupPose),o))}}else{const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;this.set(h,this.getAbsoluteValue(s,i,r,a,this.get(h),this.get(o.data.setupPose)))}}}},ts=class extends bt{constructor(t,e,s){super(t,e,s,21)}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}},es=class extends bt{constructor(t,e,s){super(t,e,s,22)}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}},ss=class extends bt{constructor(t,e,s){super(t,e,s,23)}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}},ns=class extends bt{constructor(t,e,s){super(t,e,s,24)}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}},is=class extends bt{constructor(t,e,s){super(t,e,s,25),this.additive=!0}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}},rs=class extends bt{constructor(t,e,s){super(t,e,s,26),this.additive=!0}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}},os=class extends bt{constructor(t,e,s){super(t,e,s,27)}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}},as=class An extends Z{static propertyIds=["28"];constraintIndex;constructor(e,s){super(e,...An.propertyIds),this.constraintIndex=s,this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s){this.frames[e]=s}apply(e,s,n,i,r,a,c,l,o){let h;if(this.constraintIndex!==-1&&(h=e.constraints[this.constraintIndex],!h.active))return;const d=this.frames;if(s>n)this.apply(e,s,Number.MAX_VALUE,[],r,a,!1,!1,!1),s=-1;else if(s>=d[d.length-1])return;if(!(n<d[0])&&(s<d[0]||n>=d[Z.search(d,s)+1]))if(h!=null)h.reset(e);else for(const m of e.physics)m.active&&m.reset(e)}},cs=class extends Pt{constructor(t,e,s){super(t,e,s,30)}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.time=this.getAbsoluteValue(s,i,r,a,h.time,o.data.setupPose.time)}}},ls=class extends Pt{constructor(t,e,s){super(t,e,s,31),this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.mix=this.getAbsoluteValue(s,i,r,a,h.mix,o.data.setupPose.mix)}}},Dn=class Ns{static emptyAnimation=new Qt("<empty>",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new Qs(this);propertyIds=new Map;animationsChanged=!1;trackEntryPool=new Ot(()=>new Js);constructor(e){this.data=e}update(e){e*=this.timeScale;const s=this.tracks;for(let n=0,i=s.length;n<i;n++){const r=s[n];if(!r)continue;r.animationLast=r.nextAnimationLast,r.trackLast=r.nextTrackLast;let a=e*r.timeScale;if(r.delay>0){if(r.delay-=a,r.delay>0)continue;a=-r.delay,r.delay=0}let c=r.next;if(c){const l=r.trackLast-c.delay;if(l>=0){for(c.delay=0,c.trackTime+=r.timeScale===0?0:(l/r.timeScale+e)*c.timeScale,r.trackTime+=a,this.setTrack(n,c,!0);c.mixingFrom;)c.mixTime+=e,c=c.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&!r.mixingFrom){s[n]=null,this.queue.end(r),this.clearNext(r);continue}if(r.mixingFrom&&this.updateMixingFrom(r,e)){let l=r.mixingFrom;for(r.mixingFrom=null,l&&(l.mixingTo=null);l;)this.queue.end(l),l=l.mixingFrom}r.trackTime+=a}this.queue.drain()}updateMixingFrom(e,s){const n=e.mixingFrom;if(!n)return!0;const i=this.updateMixingFrom(n,s);if(n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,e.nextTrackLast!==-1&&e.mixTime>=e.mixDuration){if(n.totalAlpha===0||e.mixDuration===0){if(e.mixingFrom=n.mixingFrom,n.mixingFrom!=null&&(n.mixingFrom.mixingTo=e),n.totalAlpha===0)for(let r=e;r.mixingTo!=null;r=r.mixingTo)r.keepHold=!0;this.queue.end(n)}return i}return n.trackTime+=s*n.timeScale,e.mixTime+=s,!1}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();const s=this.events,n=this.tracks;let i=!1;for(let c=0,l=n.length;c<l;c++){const o=n[c];if(!o||o.delay>0)continue;i=!0;let h=o.alpha;o.mixingFrom?h*=this.applyMixingFrom(o,e):o.trackTime>=o.trackEnd&&!o.next&&(h=0);let d=o.animationLast,m=o.getAnimationTime(),u=m,f=s;o.reverse&&(u=o.animation.duration-u,f=null);const p=o.animation.timelines,g=p.length;if(c===0&&h===1)for(let b=0;b<g;b++){L.webkit602BugfixHelper(h);const x=p[b];x instanceof Ft?this.applyAttachmentTimeline(x,e,u,1,!0):x.apply(e,d,u,f,h,1,!1,!1,!1)}else{const b=o.timelineMode,x=h>=o.alphaAttachmentThreshold,w=o.additive,S=w||o.shortestRotation,y=!S&&o.timelinesRotation.length!==g<<1;y&&(o.timelinesRotation.length=g<<1);for(let v=0;v<g;v++){const T=p[v],A=b[v]&fs;!S&&T instanceof Dt?this.applyRotateTimeline(T,e,u,h,A,o.timelinesRotation,v<<1,y):T instanceof Ft?this.applyAttachmentTimeline(T,e,u,A,x):(L.webkit602BugfixHelper(h),T.apply(e,d,u,f,h,A,w,!1,!1))}}o.reverse&&this.eventsReverse(o,d,m),this.queueEvents(o,m),s.length=0,o.nextAnimationLast=m,o.nextTrackLast=o.trackTime}const r=this.unkeyedState+us,a=e.slots;for(let c=0,l=e.slots.length;c<l;c++){const o=a[c];if(o.attachmentState===r){const h=o.data.attachmentName;o.pose.setAttachment(h?e.getAttachment(o.data.index,h):null)}}return this.unkeyedState+=2,this.queue.drain(),i}applyMixingFrom(e,s){const n=e.mixingFrom,i=n.mixingFrom!==null?this.applyMixingFrom(n,s):1,r=e.mix(),a=n.alpha*i,c=1-r*e.alpha,l=a*(1-r),o=c>0?l/c:a,h=n.animation.timelines,d=h.length,m=n.timelineMode,u=n.timelineHoldMix,f=r<n.mixAttachmentThreshold,p=r<n.mixDrawOrderThreshold,g=n.additive,b=g||n.shortestRotation,x=!b&&n.timelinesRotation.length!==d<<1;x&&(n.timelinesRotation.length=d<<1);const w=n.timelinesRotation;let S=n.animationLast,y=n.getAnimationTime(),v=y,T=null;n.reverse?v=n.animation.duration-v:r<n.eventThreshold&&(T=this.events),n.totalAlpha=0;for(let A=0;A<d;A++){const I=h[A],M=m[A],Y=M&fs;let P=0;if((M&_t)!==0){const E=u[A];P=E==null?o:o*(1-E.mix())}else{if(!p&&I instanceof At&&Y===0)continue;P=l}if(n.totalAlpha+=P,!b&&I instanceof Dt)this.applyRotateTimeline(I,s,v,P,Y,w,A<<1,x);else if(I instanceof Ft)this.applyAttachmentTimeline(I,s,v,Y,f&&P>=n.alphaAttachmentThreshold);else{const E=!p||!(I instanceof At)||Y===0;I.apply(s,S,v,T,P,Y,g,E,!1)}}return n.reverse&&r<n.eventThreshold&&this.eventsReverse(n,S,y),e.mixDuration>0&&this.queueEvents(n,y),this.events.length=0,n.nextAnimationLast=y,n.nextTrackLast=n.trackTime,r}applyAttachmentTimeline(e,s,n,i,r){const a=s.slots[e.slotIndex];if(!a.bone.active||!r&&a.attachmentState===this.unkeyedState+ms)return;let c=n<e.frames[0],l=null;if(c||(l=e.attachmentNames[Z.search(e.frames,n)],c=!r&&l==null),c){if(i===0)return;l=a.data.attachmentName}a.pose.setAttachment(l==null?null:s.getAttachment(a.data.index,l)),r?a.attachmentState=this.unkeyedState+ms:c||(a.attachmentState=this.unkeyedState+us)}applyRotateTimeline(e,s,n,i,r,a,c,l){if(l&&(a[c]=0),i===1){e.apply(s,0,n,null,1,r,!1,!1,!1);return}const o=s.bones[e.boneIndex];if(!o.active)return;const h=o.pose,d=o.data.setupPose,m=e.frames;let u,f;if(n<m[0]){switch(r){case 1:{h.rotation=d.rotation;return}case 0:return}u=h.rotation,f=d.rotation}else u=r===1?d.rotation:h.rotation,f=d.rotation+e.getCurveValue(n);let p=0,g=f-u;if(g-=Math.ceil(g/360-.5)*360,g===0)p=a[c];else{let b=0,x=0;l?(b=0,x=g):(b=a[c],x=a[c+1]);const w=b-b%360;p=g+w;let S=g>=0,y=b>=0;Math.abs(x)<=90&&R.signum(x)!==R.signum(g)&&(Math.abs(b-w)>180?(p+=360*R.signum(b),y=S):w!==0?p-=360*R.signum(b):y=S),y!==S&&(p+=360*R.signum(b)),a[c]=p}a[c+1]=g,h.rotation=u+p*i}queueEvents(e,s){const n=e.animationStart,i=e.animationEnd,r=i-n,a=e.reverse;let c=e.trackLast%r;a&&(c=r-c);const l=this.events;let o=0,h=l.length;for(;o<h;o++){const m=l[o];if(m.time<c!==a)break;m.time>=n&&m.time<=i&&this.queue.event(e,m)}let d=!1;if(e.loop)if(r===0)d=!0;else{const m=Math.floor(e.trackTime/r);d=m>0&&m>Math.floor(e.trackLast/r)}else d=s>=i&&e.animationLast<i;for(d&&this.queue.complete(e);o<h;o++){const m=l[o];m.time>=n&&m.time<=i&&this.queue.event(e,m)}}eventsReverse(e,s,n){const i=e.animation.duration,r=i-s,a=i-n,c=e.animation.timelines;for(let l=0,o=e.animation.timelines.length;l<o;l++){const h=c[l];if(!(h instanceof te))continue;const d=h.events,m=h.frames,u=m.length;if(r>=a){for(let f=0;f<u;f++)if(!(m[f]<a)){if(m[f]>=r)break;this.events.push(d[f])}}else{for(let p=0;p<u&&!(m[p]>=r);p++)this.events.push(d[p]);let f=0;for(;f<u&&!(m[f]>=a);f++);for(;f<u;f++)this.events.push(d[f])}}}clearTracks(){const e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let s=0,n=this.tracks.length;s<n;s++)this.clearTrack(s);this.tracks.length=0,this.queue.drainDisabled=e,this.queue.drain()}clearTrack(e){if(e<0)throw new Error("trackIndex must be >= 0.");if(e>=this.tracks.length)return;const s=this.tracks[e];if(!s)return;this.queue.end(s),this.clearNext(s);let n=s;for(;;){const i=n.mixingFrom;if(!i)break;this.queue.end(i),n.mixingFrom=null,n.mixingTo=null,n=i}this.tracks[s.trackIndex]=null,this.queue.drain()}setTrack(e,s,n){const i=this.expandToIndex(e);this.tracks[e]=s,s.previous=null,i&&(i.next=null,n&&this.queue.interrupt(i),s.mixingFrom=i,i.mixingTo=s,s.mixTime=0,i.timelinesRotation.length=0),this.queue.start(s)}setAnimation(e,s,n=!1){return typeof s=="string"?this.setAnimation1(e,s,n):this.setAnimation2(e,s,n)}setAnimation1(e,s,n=!1){const i=this.data.skeletonData.findAnimation(s);if(!i)throw new Error(`Animation not found: ${s}`);return this.setAnimation2(e,i,n)}setAnimation2(e,s,n=!1){if(e<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let i=!0,r=this.expandToIndex(e);r&&(r.nextTrackLast===-1&&r.animation===s?(this.tracks[e]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.clearNext(r),r=r.mixingFrom,i=!1):this.clearNext(r));const a=this.trackEntry(e,s,n,r);return this.setTrack(e,a,i),this.queue.drain(),a}addAnimation(e,s,n=!1,i=0){return typeof s=="string"?this.addAnimation1(e,s,n,i):this.addAnimation2(e,s,n,i)}addAnimation1(e,s,n=!1,i=0){const r=this.data.skeletonData.findAnimation(s);if(!r)throw new Error(`Animation not found: ${s}`);return this.addAnimation2(e,r,n,i)}addAnimation2(e,s,n=!1,i=0){if(e<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let r=this.expandToIndex(e);if(r)for(;r.next;)r=r.next;const a=this.trackEntry(e,s,n,r);return r?(r.next=a,a.previous=r,i<=0&&(i=Math.max(i+r.getTrackComplete()-a.mixDuration,0))):(this.setTrack(e,a,!0),this.queue.drain(),i<0&&(i=0)),a.delay=i,a}setEmptyAnimation(e,s=0){const n=this.setAnimation(e,Ns.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(e,s=0,n=0){const i=this.addAnimation(e,Ns.emptyAnimation,!1,n);return n<=0&&(i.delay=Math.max(i.delay+i.mixDuration-s,0)),i.mixDuration=s,i.trackEnd=s,i}setEmptyAnimations(e=0){const s=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let n=0,i=this.tracks.length;n<i;n++){const r=this.tracks[n];r&&this.setEmptyAnimation(r.trackIndex,e)}this.queue.drainDisabled=s,this.queue.drain()}expandToIndex(e){return e<this.tracks.length?this.tracks[e]:(L.ensureArrayCapacity(this.tracks,e+1,null),this.tracks.length=e+1,null)}trackEntry(e,s,n,i){const r=this.trackEntryPool.obtain();return r.reset(),r.trackIndex=e,r.animation=s,r.loop=n,r.additive=!1,r.reverse=!1,r.shortestRotation=!1,r.eventThreshold=0,r.alphaAttachmentThreshold=0,r.mixAttachmentThreshold=0,r.mixDrawOrderThreshold=0,r.animationStart=0,r.animationEnd=s.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixTime=0,r.mixDuration=i?this.data.getMix(i.animation,s):0,r.totalAlpha=0,r.keepHold=!1,r}clearNext(e){let s=e.next;for(;s;)this.queue.dispose(s),s=s.next;e.next=null}_animationsChanged(){this.animationsChanged=!1;const e=this.tracks;for(let s=0,n=e.length;s<n;s++){const i=e[s];if(!i)continue;let r=i;for(;r.mixingFrom;)r=r.mixingFrom;do this.computeHold(r,i),r=r.mixingTo;while(r)}this.propertyIds.clear()}computeHold(e,s){const n=e.animation.timelines,i=e.animation.timelines.length,r=e.timelineMode;r.length=i;const a=e.timelineHoldMix;a.length=0;const c=e.additive,l=e.keepHold,o=e.mixingTo;for(let h=0;h<i;h++){const d=n[h],m=d.propertyIds,u=this.from(s,d,m);if(c&&d.additive){r[h]=u;continue}let f;if(o===null||d.instant||o.additive&&d.additive||!o.animation?.hasTimeline(m))f=u;else{f=u|_t;for(let p=o.mixingTo;p!=null;p=p.mixingTo)if(p.additive&&d.additive||!p.animation?.hasTimeline(m)){p.mixDuration>0&&(a[h]=p);break}}l&&(f=f&~_t|r[h]&_t),r[h]=f}}from(e,s,n){const i=this.propertyIds;let r=tn;for(let a=0,c=n.length;a<c;a++){const l=i.get(n[a]);if(l===void 0)i.set(n[a],e);else{if(l!==e){for(;++a<c;)i.has(n[a])||i.set(n[a],e);return hs}r=ds}}if(s instanceof qt){const a=i.get(At.propertyID);if(a!=null)return a!==e?hs:ds}return r}getTrack(e){if(e<0)throw new Error("trackIndex must be >= 0.");return e>=this.tracks.length?null:this.tracks[e]}addListener(e){if(!e)throw new Error("listener cannot be null.");this.listeners.push(e)}removeListener(e){const s=this.listeners.indexOf(e);s>=0&&this.listeners.splice(s,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}},Js=class{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;additive=!1;reverse=!1;shortestRotation=!1;keepHold=!1;eventThreshold=0;mixAttachmentThreshold=0;alphaAttachmentThreshold=0;mixDrawOrderThreshold=0;animationStart=0;animationEnd=0;animationLast=0;nextAnimationLast=0;delay=0;trackTime=0;trackLast=0;nextTrackLast=0;trackEnd=0;timeScale=0;alpha=0;mixTime=0;mixDuration=0;totalAlpha=0;mixInterpolation=Bt.linear;setMixDuration(t,e){this.mixDuration=t,e!==void 0&&(e<=0&&(e=this.previous==null?0:Math.max(e+this.previous.getTrackComplete()-t,0)),this.delay=e)}setMixInterpolation(t){if(!t)throw new Error("mixInterpolation cannot be null.");this.mixInterpolation=t}mix(){if(this.mixDuration===0)return 1;let t=this.mixTime/this.mixDuration;return t>=1?1:this.mixInterpolation===Bt.linear?t:(t=this.mixInterpolation.apply(t),t<0?0:t>1?1:t)}timelineMode=[];timelineHoldMix=[];timelinesRotation=[];reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.mixInterpolation=Bt.linear,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(!this.loop)return Math.min(this.trackTime+this.animationStart,this.animationEnd);const t=this.animationEnd-this.animationStart;return t===0?this.animationStart:this.trackTime%t+this.animationStart}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){const t=this.animationEnd-this.animationStart;if(t!==0){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return this.nextTrackLast!==-1}isNextReady(){return this.next!=null&&this.nextTrackLast-this.next.delay>=0}},Qs=class{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(!this.drainDisabled){this.drainDisabled=!0;for(let t=0;t<this.objects.length;t+=2){const e=this.objects,s=e[t],n=e[t+1],i=this.animState.listeners.slice();switch(s){case 0:n.listener?.start&&n.listener.start(n);for(let r=0;r<i.length;r++){const a=i[r];a.start&&a.start(n)}break;case 1:n.listener?.interrupt&&n.listener.interrupt(n);for(let r=0;r<i.length;r++){const a=i[r];a.interrupt&&a.interrupt(n)}break;case 2:n.listener?.end&&n.listener.end(n);for(let r=0;r<i.length;r++){const a=i[r];a.end&&a.end(n)}case 3:n.listener?.dispose&&n.listener.dispose(n);for(let r=0;r<i.length;r++){const a=i[r];a.dispose&&a.dispose(n)}this.animState.trackEntryPool.free(n);break;case 4:n.listener?.complete&&n.listener.complete(n);for(let r=0;r<i.length;r++){const a=i[r];a.complete&&a.complete(n)}break;case 5:{const r=e[t+++2];n.listener?.event&&n.listener.event(n,r);for(let a=0;a<i.length;a++){const c=i[a];c.event&&c.event(n,r)}break}}}this.clear(),this.drainDisabled=!1}}clear(){this.objects.length=0}},Zs=(t=>(t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event",t))(Zs||{}),$n=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},hs=0,tn=1,ds=2,fs=3,_t=4,us=1,ms=2,qn=class{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){return typeof t=="string"?this.setMix1(t,e,s):this.setMix2(t,e,s)}setMix1(t,e,s){const n=this.skeletonData.findAnimation(t);if(!n)throw new Error(`Animation not found: ${t}`);const i=this.skeletonData.findAnimation(e);if(!i)throw new Error(`Animation not found: ${e}`);this.setMix2(n,i,s)}setMix2(t,e,s){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");const n=`${t.name}.${e.name}`;this.animationToMixTime[n]=s}getMix(t,e){const s=`${t.name}.${e.name}`,n=this.animationToMixTime[s];return n===void 0?this.defaultMix:n}},en=class{constructor(t,e="",s=new gs,n=new sn){this.textureLoader=t,this.pathPrefix=e,this.downloader=s,this.cache=n}errors={};toLoad=0;loaded=0;texturePmaInfo={};start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.cache.assets[e]=s,this.cache.assetsRefCount[e]=(this.cache.assetsRefCount[e]||0)+1,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise((e,s)=>{const n=()=>{if(this.isLoadingComplete()){this.hasErrors()?s(this.errors):e(this);return}requestAnimationFrame(n)};requestAnimationFrame(n)})}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((n,i)=>{this.downloader.downloadBinary(t,r=>{this.success(e,t,r),n(r)},(r,a)=>{const c=`Couldn't load binary ${t}: status ${r}, ${a}`;this.error(s,t,c),i(c)})}))}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,n=>{this.success(e,t,n)},(n,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${n}, ${i}`)})}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((n,i)=>{this.downloader.downloadJson(t,r=>{this.success(e,t,r),n(r)},(r,a)=>{const c=`Couldn't load JSON ${t}: status ${r}, ${a}`;this.error(s,t,c),i(c)})}))}reuseAssets(t,e=()=>{},s=()=>{}){const n=this.cache.getAsset(t),i=n!==void 0;return i&&(this.cache.assetsLoaded[t]=n.then(r=>(r=r instanceof Image||r instanceof ImageBitmap?this.textureLoader(r):r,this.success(e,t,r),r)).catch(r=>{this.error(s,t,r)})),i}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),this.reuseAssets(t,e,s))return;const n=this.texturePmaInfo[t];this.cache.assetsLoaded[t]=new Promise((i,r)=>{if(!!!(typeof window<"u"&&typeof navigator<"u"&&window.document))fetch(t,{mode:"cors"}).then(l=>{if(l.ok)return l.blob();const o=`Couldn't load image: ${t}`;this.error(s,t,`Couldn't load image: ${t}`),r(o)}).then(l=>l?createImageBitmap(l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(l=>{if(l){const o=this.createTexture(t,n,l);this.success(e,t,o),i(o)}});else{const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const o=this.createTexture(t,n,l);this.success(e,t,o),i(o)},l.onerror=()=>{const o=`Couldn't load image: ${t}`;this.error(s,t,o),r(o)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),l.src=t}})}loadTextureAtlas(t,e=()=>{},s=()=>{},n){const i=t.lastIndexOf("/"),r=i>=0?t.substring(0,i+1):"";t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((a,c)=>{this.downloader.downloadText(t,l=>{try{const o=this.createTextureAtlas(l,r,t,n);let h=o.pages.length,d=!1;if(h===0){this.success(e,t,o),a(o);return}for(const m of o.pages)this.loadTexture(this.texturePath(r,m.name,n),(u,f)=>{d||(m.setTexture(f),--h===0&&(this.success(e,t,o),a(o)))},(u,f)=>{if(!d){const p=`Couldn't load texture ${t} page image: ${u}`;this.error(s,t,p),c(p)}d=!0})}catch(o){const h=`Couldn't parse texture atlas ${t}: ${o.message}`;this.error(s,t,h),c(h)}},(l,o)=>{const h=`Couldn't load texture atlas ${t}: status ${l}, ${o}`;this.error(s,t,h),c(h)})}))}loadTextureAtlasButNoTextures(t,e=()=>{},s=()=>{}){const n=t.lastIndexOf("/"),i=n>=0?t.substring(0,n+1):"";t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((r,a)=>{this.downloader.downloadText(t,c=>{try{const l=this.createTextureAtlas(c,i,t);this.success(e,t,l),r(l)}catch(l){const o=`Couldn't parse texture atlas ${t}: ${l.message}`;this.error(s,t,o),a(o)}},(c,l)=>{const o=`Couldn't load texture atlas ${t}: status ${c}, ${l}`;this.error(s,t,o),a(o)})}))}async loadBinaryAsync(t){return new Promise((e,s)=>{this.loadBinary(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadJsonAsync(t){return new Promise((e,s)=>{this.loadJson(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAsync(t){return new Promise((e,s)=>{this.loadTexture(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAtlasAsync(t){return new Promise((e,s)=>{this.loadTextureAtlas(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAtlasButNoTexturesAsync(t){return new Promise((e,s)=>{this.loadTextureAtlasButNoTextures(t,(n,i)=>e(i),(n,i)=>s(i))})}setCache(t){this.cache=t}get(t){return this.cache.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;const e=this.cache.assets[t];if(e)return e;const s=this.errors[t];throw Error(`Asset not found: ${t}${s?`
2
- ${s}`:""}`)}remove(t){t=this.pathPrefix+t;const e=this.cache.assets[t];return e.dispose&&e.dispose(),delete this.cache.assets[t],delete this.cache.assetsRefCount[t],delete this.cache.assetsLoaded[t],e}removeAll(){for(const t in this.cache.assets){const e=this.cache.assets[t];e.dispose&&e.dispose()}this.cache.assets={},this.cache.assetsLoaded={},this.cache.assetsRefCount={}}isLoadingComplete(){return this.toLoad===0}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}disposeAsset(t){const e=this.cache.assets[t];if(e instanceof Me){e.dispose();return}this.disposeAssetInternal(t)}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}disposeAssetInternal(t){if(this.cache.assetsRefCount[t]>0&&--this.cache.assetsRefCount[t]===0)return this.remove(t)}createTextureAtlas(t,e,s,n){const i=new Me(t);i.dispose=()=>{if(!(this.cache.assetsRefCount[s]<=0)){this.disposeAssetInternal(s);for(const r of i.pages)r.texture?.dispose()}};for(const r of i.pages){const a=this.texturePath(e,r.name,n);this.texturePmaInfo[this.pathPrefix+a]=r.pma}return i}createTexture(t,e,s){const n=this.textureLoader(s,e),i=n.dispose.bind(n);return n.dispose=()=>{this.disposeAssetInternal(t)&&i()},n}texturePath(t,e,s){return s?s[e]:t+e}},sn=class Se{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(e){const s=Se.AVAILABLE_CACHES.get(e);if(s)return s;const n=new Se;return Se.AVAILABLE_CACHES.set(e,n),n}async addAsset(e,s){return this.assetsLoaded[e]=Promise.resolve(s),this.assets[e]=s,s}getAsset(e){return this.assetsLoaded[e]}},gs=class{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return e!==-1?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){var e=window.atob(t),s=e.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=e.charCodeAt(i);return n}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(e===-1)throw new Error("Not a binary data URI.");return e+=7,this.base64ToUint8Array(t.substr(e))}downloadText(t,e,s){if(this.start(t,e,s))return;const n=this.rawDataUris[t];if(n&&!n.includes(".")){try{this.finish(t,200,this.dataUriToString(n))}catch(a){this.finish(t,400,JSON.stringify(a))}return}const i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",n||t,!0);const r=()=>{this.finish(t,i.status,i.responseText)};i.onload=r,i.onerror=r,i.send()}downloadJson(t,e,s){this.downloadText(t,n=>{e(JSON.parse(n))},s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;const n=this.rawDataUris[t];if(n&&!n.includes(".")){try{this.finish(t,200,this.dataUriToUint8Array(n))}catch(a){this.finish(t,400,JSON.stringify(a))}return}const i=new XMLHttpRequest;i.open("GET",n||t,!0),i.responseType="arraybuffer";const r=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{i.status===200||i.status===0?this.finish(t,200,new Uint8Array(i.response)):r()},i.onerror=r,i.send()}start(t,e,s){let n=this.callbacks[t];try{if(n)return!0;this.callbacks[t]=n=[]}finally{n.push(e,s)}}finish(t,e,s){const n=this.callbacks[t];if(delete this.callbacks[t],e===200||e===0)for(let i=0,r=n.length;i<r;i+=2)n[i](s);else for(let i=1,r=n.length;i<r;i+=2)n[i](e,s)}},ps=class In extends xt{color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new In(this.name);return this.copyTo(e),e.color.setFromColor(this.color),e}},zt=class Cn extends xt{endSlot=null;convex=!1;inverse=!1;color=new z(.2275,.2275,.8078,1);constructor(e){super(e)}copy(){const e=new Cn(this.name);return this.copyTo(e),e.endSlot=this.endSlot,e.convex=this.convex,e.inverse=this.inverse,e.color.setFromColor(this.color),e}},ee=class Mn extends xt{lengths=[];closed=!1;constantSpeed=!1;color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new Mn(this.name);return this.copyTo(e),e.lengths=[],L.arrayCopy(this.lengths,0,e.lengths,0,this.lengths.length),e.closed=this.closed,e.constantSpeed=this.constantSpeed,e.color.setFromColor(this.color),e}},nn=class Yn extends xt{x=0;y=0;rotation=0;color=new z(.38,.94,0,1);constructor(e){super(e)}computeWorldPosition(e,s){return s.x=this.x*e.a+this.y*e.b+e.worldX,s.y=this.x*e.c+this.y*e.d+e.worldY,s}computeWorldRotation(e){const s=this.rotation*R.degRad,n=Math.cos(s),i=Math.sin(s),r=n*e.a+i*e.b,a=n*e.c+i*e.d;return R.atan2Deg(a,r)}copy(){const e=new Yn(this.name);return e.x=this.x,e.y=this.y,e.rotation=this.rotation,e.color.setFromColor(this.color),e}},_n=class{atlas;allowMissingRegions;constructor(t,e=!1){this.atlas=t,this.allowMissingRegions=e}findRegions(t,e,s){const n=s.regions;for(let i=0,r=n.length;i<r;i++)n[i]=this.findRegion(t,s.getPath(e,i))}findRegion(t,e){const s=this.atlas.findRegion(e);if(!s&&!this.allowMissingRegions)throw new Error(`Region not found in atlas: ${e} (attachment: ${t})`);return s}newRegionAttachment(t,e,s,n,i){return this.findRegions(s,n,i),new j(s,i)}newMeshAttachment(t,e,s,n,i){return this.findRegions(s,n,i),new wt(s,i)}newBoundingBoxAttachment(t,e,s){return new ps(s)}newPathAttachment(t,e,s){return new ee(s)}newPointAttachment(t,e,s){return new nn(s)}newClippingAttachment(t,e,s){return new zt(s)}},se=class{name;setupPose;skinRequired=!1;constructor(t,e){if(t==null)throw new Error("name cannot be null.");this.name=t,this.setupPose=e}},bs=class kn extends se{index=0;parent=null;length=0;color=new z;icon;iconSize=1;iconRotation=0;visible=!1;constructor(e,s,n){if(super(s,new ie),e<0)throw new Error("index must be >= 0.");if(!s)throw new Error("name cannot be null.");this.index=e,this.parent=n}copy(e){const s=new kn(this.index,this.name,e);return s.length=this.length,s.setupPose.set(this.setupPose),s}},ne=(t=>(t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection",t))(ne||{}),ie=class{bone;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;inherit=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;world=0;local=0;set(t){if(t==null)throw new Error("pose cannot be null.");this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}setPosition(t,e){this.x=t,this.y=e}setScale(t,e){this.scaleX=t,this.scaleY=e===void 0?t:e}getInherit(){return this.inherit}setInherit(t){if(t==null)throw new Error("inherit cannot be null.");this.inherit=t}update(t,e){this.world!==t._update&&this.updateWorldTransform(t)}updateWorldTransform(t){this.local===t._update?this.updateLocalTransform(t):this.world=t._update;const e=this.rotation,s=this.scaleX,n=this.scaleY,i=this.shearX,r=this.shearY;if(!this.bone.parent){const d=t.scaleX,m=t.scaleY,u=(e+i)*R.degRad,f=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(f)*n*d,this.c=Math.sin(u)*s*m,this.d=Math.sin(f)*n*m,this.worldX=this.x*d+t.x,this.worldY=this.y*m+t.y;return}const a=this.bone.parent.appliedPose;let c=a.a,l=a.b,o=a.c,h=a.d;switch(this.worldX=c*this.x+l*this.y+a.worldX,this.worldY=o*this.x+h*this.y+a.worldY,this.inherit){case 0:{const d=(e+i)*R.degRad,m=(e+90+r)*R.degRad,u=Math.cos(d)*s,f=Math.cos(m)*n,p=Math.sin(d)*s,g=Math.sin(m)*n;this.a=c*u+l*p,this.b=c*f+l*g,this.c=o*u+h*p,this.d=o*f+h*g;return}case 1:{const d=t.scaleX,m=t.scaleY,u=(e+i)*R.degRad,f=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(f)*n*d,this.c=Math.sin(u)*s*m,this.d=Math.sin(f)*n*m;break}case 2:{const d=t.scaleX,m=t.scaleY,u=1/d,f=1/m;c*=u,o*=f;let p=c*c+o*o,g=0;p>R.epsilon2?(p=Math.abs(c*h*f-l*u*o)/p,l=o*p,h=c*p,g=e-R.atan2Deg(o,c)):(c=0,o=0,g=e-90+R.atan2Deg(h,l));const b=(g+i)*R.degRad,x=(g+r+90)*R.degRad,w=Math.cos(b)*s,S=Math.cos(x)*n,y=Math.sin(b)*s,v=Math.sin(x)*n;this.a=(c*w-l*y)*d,this.b=(c*S-l*v)*d,this.c=(o*w+h*y)*m,this.d=(o*S+h*v)*m;break}case 3:case 4:{const d=t.scaleX,m=t.scaleY,u=1/d,f=1/m,p=e*R.degRad,g=Math.cos(p),b=Math.sin(p);let x=(c*g+l*b)*u,w=(o*g+h*b)*f;const S=1/Math.sqrt(x*x+w*w);x*=S,w*=S;let y=-w,v=x;this.inherit===3&&c*h-l*o<0!=(d<0!=m<0)&&(y=-y,v=-v);const T=i*R.degRad,A=(90+r)*R.degRad,I=Math.cos(T)*s,M=Math.cos(A)*n,Y=Math.sin(T)*s,P=Math.sin(A)*n;this.a=(x*I+y*Y)*d,this.b=(x*M+y*P)*d,this.c=(w*I+v*Y)*m,this.d=(w*M+v*P)*m;break}}}updateLocalTransform(t){this.local=0,this.world=t._update;const e=t.scaleX,s=t.scaleY;if(!this.bone.parent){const g=1/e,b=1/s;this.x=(this.worldX-t.x)*g,this.y=(this.worldY-t.y)*b,this.set5(this.a*g,this.b*g,this.c*b,this.d*b,0);return}const n=this.bone.parent.appliedPose;let i=n.a,r=n.b,a=n.c,c=n.d;const l=i*c-r*a,o=1/(i*c-r*a),h=c*o,d=r*o,m=a*o,u=i*o,f=this.worldX-n.worldX,p=this.worldY-n.worldY;switch(this.x=f*h-p*d,this.y=p*u-f*m,this.inherit){case 0:this.set5(h*this.a-d*this.c,h*this.b-d*this.d,u*this.c-m*this.a,u*this.d-m*this.b,0);break;case 1:{const g=1/e,b=1/s;this.set5(this.a*g,this.b*g,this.c*b,this.d*b,0);break}case 2:{const g=1/e,b=1/s;i*=g,a*=b;const x=this.a*g,w=this.b*g,S=this.c*b,y=this.d*b,v=1/(i*i+a*a),T=1/Math.abs(l*g*b);this.set5((i*x+a*S)*v,(i*w+a*y)*v,(i*S-a*x)*T,(i*y-a*w)*T,R.atan2Deg(a,i));break}case 3:case 4:{const g=1/e,b=1/s,x=this.a*g,w=this.b*g,S=this.c*b,y=this.d*b;let v=c*this.a-r*this.c,T=i*this.c-a*this.a;l<0&&(v=-v,T=-T);let A=R.atan2Deg(T,v);this.rotation=A,A*=R.degRad;const I=Math.cos(A),M=Math.sin(A);let Y=(i*I+r*M)*g,P=(a*I+c*M)*b;const E=1/Math.sqrt(Y*Y+P*P);Y*=E,P*=E;const X=this.inherit===3&&l<0!=(e<0!=s<0)?-1:1;this.set4(Y*x+P*S,Y*w+P*y,(Y*S-P*x)*X,(Y*y-P*w)*X)}}}set4(t,e,s,n){const i=t*t+s*s,r=e*e+n*n;i>R.epsilon2?(this.shearX=R.atan2Deg(s,t),this.scaleX=Math.sqrt(i)):(this.shearX=0,this.scaleX=0),this.scaleY=Math.sqrt(r),r>R.epsilon2?(this.shearY=R.atan2Deg(n,e),t*n-e*s<0?(this.scaleY=-this.scaleY,this.shearY+=90):this.shearY-=90,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}set5(t,e,s,n,i){this.shearX=0;const r=t*t+s*s,a=e*e+n*n;if(r>R.epsilon2){const c=R.atan2Deg(s,t);this.rotation=c+i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(a),a>R.epsilon2?(this.shearY=R.atan2Deg(n,e),t*n-e*s<0?(this.scaleY=-this.scaleY,this.shearY+=90-c):this.shearY-=90+c,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}else this.scaleX=0,this.scaleY=Math.sqrt(a),this.shearY=0,this.rotation=a>R.epsilon2?R.atan2Deg(n,e)-90+i:i}validateLocalTransform(t){this.local===t._update&&this.updateLocalTransform(t)}modifyLocal(t){this.local===t._update&&this.updateLocalTransform(t),this.world=0,this.resetWorld(t._update)}modifyWorld(t){this.local=t,this.world=t,this.resetWorld(t)}resetWorld(t){const e=this.bone.children;for(let s=0,n=e.length;s<n;s++){const i=e[s].appliedPose;i.world===t&&(i.world=0,i.local=0,i.resetWorld(t))}}getWorldRotationX(){return R.atan2Deg(this.c,this.a)}getWorldRotationY(){return R.atan2Deg(this.d,this.b)}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}worldToLocal(t){if(t==null)throw new Error("world cannot be null.");const e=this.a*this.d-this.b*this.c,s=t.x-this.worldX,n=t.y-this.worldY;return t.x=(s*this.d-n*this.b)/e,t.y=(n*this.a-s*this.c)/e,t}localToWorld(t){if(t==null)throw new Error("local cannot be null.");const e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToParent(t){if(t==null)throw new Error("world cannot be null.");return this.bone.parent==null?t:this.bone.parent.appliedPose.worldToLocal(t)}parentToWorld(t){if(t==null)throw new Error("world cannot be null.");return this.bone.parent==null?t:this.bone.parent.appliedPose.localToWorld(t)}worldToLocalRotation(t){t*=R.degRad;const e=Math.sin(t),s=Math.cos(t);return R.atan2Deg(this.a*e-this.c*s,this.d*s-this.b*e)+this.rotation-this.shearX}localToWorldRotation(t){t=(t-this.rotation-this.shearX)*R.degRad;const e=Math.sin(t),s=Math.cos(t);return R.atan2Deg(s*this.c+e*this.d,s*this.a+e*this.b)}rotateWorld(t){t*=R.degRad;const e=Math.sin(t),s=Math.cos(t),n=this.a,i=this.b;this.a=s*n-e*this.c,this.b=s*i-e*this.d,this.c=e*n+s*this.c,this.d=e*i+s*this.d}},xs=class{data;pose;constrainedPose;appliedPose;constructor(t,e,s){if(t==null)throw new Error("data cannot be null.");this.data=t,this.pose=e,this.constrainedPose=s,this.appliedPose=e}setupPose(){this.pose.set(this.data.setupPose)}getData(){return this.data}getPose(){return this.pose}getAppliedPose(){return this.appliedPose}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.set(this.pose)}},ws=class extends xs{active=!1;constructor(t,e,s){super(t,e,s),this.setupPose()}isActive(){return this.active}},re=class Fn extends ws{parent=null;children=[];sorted=!1;constructor(e,s){super(e,new ie,new ie),this.parent=s,this.appliedPose.bone=this,this.constrainedPose.bone=this}copy(e){const s=new Fn(this.data,e);return s.pose.set(this.pose),s}},Et=class extends ws{constructor(t,e,s){super(t,e,s)}isSourceActive(){return!0}},rn=class{_setupPose;pose;constrainedPose;appliedPose;constructor(t){this._setupPose=t,this.pose=[...t],this.constrainedPose=[],this.appliedPose=this.pose}setupPose(){this.pose.length=this._setupPose.length,L.arrayCopy(this._setupPose,0,this.pose,0,this._setupPose.length)}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.length=this.pose.length,L.arrayCopy(this.pose,0,this.constrainedPose,0,this.pose.length)}},Xt=class extends se{constructor(t,e){super(t,e)}},oe=(t=>(t[t.None=0]="None",t[t.Uniform=1]="Uniform",t[t.Volume=2]="Volume",t))(oe||{}),ae=class{time=0;data;intValue=0;floatValue=0;stringValue=null;volume=0;balance=0;constructor(t,e){if(!e)throw new Error("data cannot be null.");this.time=t,this.data=e}},ys=class{name;_audioPath=null;get audioPath(){return this._audioPath}set audioPath(t){if(t==null)throw new Error("audioPath cannot be null.");this._audioPath=t}setupPose=new ae(-1,this);constructor(t){this.name=t}},ce=class{bendDirection=0;compress=!1;stretch=!1;mix=0;softness=0;set(t){this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}},on=class Yt extends Et{bones;target;constructor(e,s){if(super(e,new ce,new ce),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const n of e.bones)this.bones.push(s.bones[n.index].constrainedPose);this.target=s.bones[e.target.index]}copy(e){var s=new Yt(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.target.appliedPose,r=this.bones;switch(r.length){case 1:Yt.apply(e,r[0],i.worldX,i.worldY,n.compress,n.stretch,this.data.scaleYMode,n.mix);break;case 2:Yt.apply(e,r[0],r[1],i.worldX,i.worldY,n.bendDirection,n.stretch,this.data.scaleYMode,n.softness,n.mix);break}}sort(e){e.sortBone(this.target);const s=this.bones[0].bone;e.sortBone(s),e._updateCache.push(this),s.sorted=!1,e.sortReset(s.children),e.constrained(s),this.bones.length>1&&e.constrained(this.bones[1].bone)}isSourceActive(){return this.target.active}static apply(e,s,n,i,r,a,c,l,o,h){typeof n=="number"?Yt.apply1(e,s,n,i,r,a,c,l):Yt.apply2(e,s,n,i,r,a,c,l,o,h)}static apply1(e,s,n,i,r,a,c,l){s.modifyLocal(e);const o=s.bone.parent.appliedPose;let h=o.a,d=o.b,m=o.c,u=o.d,f=-s.shearX-s.rotation,p=0,g=0;switch(s.inherit){case 1:p=(n-s.worldX)*R.signum(e.scaleX),g=(i-s.worldY)*R.signum(e.scaleY);break;case 2:{const b=Math.abs(h*u-d*m)/Math.max(R.epsilon,h*h+m*m),x=h/e.scaleX,w=m/e.scaleY;d=-w*b*e.scaleX,u=x*b*e.scaleY,f+=R.atan2Deg(w,x)}default:{const b=n-o.worldX,x=i-o.worldY,w=h*u-d*m;Math.abs(w)<=R.epsilon?(p=0,g=0):(p=(b*u-x*d)/w-s.x,g=(x*h-b*m)/w-s.y)}}if(f+=R.atan2Deg(g,p),s.scaleX<0&&(f+=180),f>180?f-=360:f<=-180&&(f+=360),s.rotation+=f*l,r||a){switch(s.inherit){case 3:case 4:p=n-s.worldX,g=i-s.worldY}const b=s.bone.data.length*s.scaleX;if(b>R.epsilon){const x=p*p+g*g;if(r&&x<b*b||a&&x>b*b){const w=(Math.sqrt(x)/b-1)*l+1;switch(s.scaleX*=w,c){case 1:s.scaleY*=w;break;case 2:s.scaleY/=w<.7?.25+.642857*w:w}}}}}static apply2(e,s,n,i,r,a,c,l,o,h){if(s.inherit!==0||n.inherit!==0)return;s.modifyLocal(e),n.modifyLocal(e);let d=s.x,m=s.y,u=s.scaleX,f=s.scaleY,p=n.scaleX,g=0,b=0,x=0;u<0?(u=-u,g=180,x=-1):(g=0,x=1),f<0&&(f=-f,x=-x),p<0?(p=-p,b=180):b=0;let w=0,S=0,y=s.a,v=s.b,T=s.c,A=s.d;const I=Math.abs(u-f)<=R.epsilon;!I||c?(n.y=0,w=y*n.x+s.worldX,S=T*n.x+s.worldY):(w=y*n.x+v*n.y+s.worldX,S=T*n.x+A*n.y+s.worldY);const M=s.bone.parent.appliedPose;y=M.a,v=M.b,T=M.c,A=M.d;let Y=y*A-v*T,P=w-M.worldX,E=S-M.worldY;Y=Math.abs(Y)<=R.epsilon?0:1/Y;const X=(P*A-E*v)*Y-d,V=(E*y-P*T)*Y-m;let N=Math.sqrt(X*X+V*V),q=n.bone.data.length*p,O,F;if(N<R.epsilon){Yt.apply(e,s,i,r,!1,c,0,h),n.rotation=0;return}P=i-M.worldX,E=r-M.worldY;let k=(P*A-E*v)*Y-d,D=(E*y-P*T)*Y-m,U=k*k+D*D;if(o!==0){o*=u*(p+1)*.5;const B=Math.sqrt(U),_=B-N-q*u+o;if(_>0){let $=Math.min(1,_/(o*2))-1;$=(_-o*(1-$*$))/B,k-=$*k,D-=$*D,U=k*k+D*D}}t:if(I){q*=u;let B=(U-N*N-q*q)/(2*N*q);if(B<-1)B=-1,F=Math.PI*a;else if(B>1){if(B=1,F=0,c)switch(y=(Math.sqrt(U)/(N+q)-1)*h+1,s.scaleX*=y,l){case 1:s.scaleY*=y;break;case 2:s.scaleY/=y<.7?.25+.642857*y:y}}else F=Math.acos(B)*a;y=N+q*B,v=q*Math.sin(F),O=Math.atan2(D*y-k*v,k*y+D*v)}else{y=u*q,v=f*q;const B=y*y,_=v*v,$=Math.atan2(D,k);T=_*N*N+B*U-B*_;const J=-2*_*N,et=_-B;if(A=J*J-4*et*T,A>=0){let ut=Math.sqrt(A);J<0&&(ut=-ut),ut=-(J+ut)*.5;let pt=ut/et,Lt=T/ut;const Kt=Math.abs(pt)<Math.abs(Lt)?pt:Lt;if(pt=U-Kt*Kt,pt>=0){E=Math.sqrt(pt)*a,O=$-Math.atan2(E,Kt),F=Math.atan2(E/f,(Kt-N)/u);break t}}let Q=R.PI,st=N-y,it=st*st,nt=0,dt=0,rt=N+y,ot=rt*rt,ft=0;T=-y*N/(B-_),T>=-1&&T<=1&&(T=Math.acos(T),P=y*Math.cos(T)+N,E=v*Math.sin(T),A=P*P+E*E,A<it&&(Q=T,it=A,st=P,nt=E),A>ot&&(dt=T,ot=A,rt=P,ft=E)),U<=(it+ot)*.5?(O=$-Math.atan2(nt*a,st),F=Q*a):(O=$-Math.atan2(ft*a,rt),F=dt*a)}const W=Math.atan2(n.y,n.x)*x;O=(O-W)*R.radDeg+g-s.rotation,O>180?O-=360:O<=-180&&(O+=360),s.rotation+=O*h,F=((F+W)*R.radDeg-n.shearX)*x+b-n.rotation,F>180?F-=360:F<=-180&&(F+=360),n.rotation+=F*h}},Wt=class extends Xt{bones=[];_target=null;set target(t){this._target=t}get target(){if(!this._target)throw new Error("target cannot be null.");return this._target}_scaleYMode=0;set scaleYMode(t){this._scaleYMode=t}get scaleYMode(){if(this._scaleYMode==null)throw new Error("scaleYMode cannot be null.");return this._scaleYMode}constructor(t){super(t,new ce)}create(t){return new on(this,t)}},le=class{position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;set(t){this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}},Ht=class extends Xt{bones=[];set slot(t){this._slot=t}get slot(){if(this._slot)return this._slot;throw new Error("SlotData not set.")}_slot=null;positionMode=0;spacingMode=1;rotateMode=1;offsetRotation=0;constructor(t){super(t,new le)}create(t){return new an(this,t)}},vs=(t=>(t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent",t))(vs||{}),Ss=(t=>(t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional",t))(Ss||{}),Ts=(t=>(t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale",t))(Ts||{}),an=class kt extends Et{static NONE=-1;static BEFORE=-2;static AFTER=-3;data;bones;slot;spaces=[];positions=[];world=[];curves=[];lengths=[];segments=[];constructor(e,s){if(super(e,new le,new le),!s)throw new Error("skeleton cannot be null.");this.data=e,this.bones=[];for(const n of this.data.bones)this.bones.push(s.bones[n.index].constrainedPose);this.slot=s.slots[e.slot.index]}copy(e){var s=new kt(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.slot.appliedPose.attachment;if(!(n instanceof ee))return;const i=this.appliedPose,r=i.mixRotate,a=i.mixX,c=i.mixY;if(r===0&&a===0&&c===0)return;const l=this.data,o=l.rotateMode===0,h=l.rotateMode===2,d=this.bones,m=d.length,u=o?m:m+1,f=L.setArraySize(this.spaces,u),p=h?this.lengths=L.setArraySize(this.lengths,m):[],g=i.spacing;switch(l.spacingMode){case 2:if(h)for(let v=0,T=u-1;v<T;v++){const A=d[v],I=A.bone.data.length,M=I*A.a,Y=I*A.c;p[v]=Math.sqrt(M*M+Y*Y)}L.arrayFill(f,1,u,g);break;case 3:{let v=0;for(let T=0,A=u-1;T<A;){const I=d[T],M=I.bone.data.length;if(M<R.epsilon)h&&(p[T]=0),f[++T]=g;else{const Y=M*I.a,P=M*I.c,E=Math.sqrt(Y*Y+P*P);h&&(p[T]=E),f[++T]=E,v+=E}}if(v>0){v=u/v*g;for(let T=1;T<u;T++)f[T]*=v}break}default:{const v=l.spacingMode===0;for(let T=0,A=u-1;T<A;){const I=d[T],M=I.bone.data.length;if(M<R.epsilon)h&&(p[T]=0),f[++T]=g;else{const Y=M*I.a,P=M*I.c,E=Math.sqrt(Y*Y+P*P);h&&(p[T]=E),f[++T]=(v?Math.max(0,M+g):g)*E/M}}}}const b=this.computeWorldPositions(e,n,u,o);let x=b[0],w=b[1],S=l.offsetRotation,y=!1;if(S===0)y=l.rotateMode===1;else{y=!1;const v=this.slot.bone.appliedPose;S*=v.a*v.d-v.b*v.c>0?R.degRad:-R.degRad}for(let v=0,T=3,A=e._update;v<m;v++,T+=3){const I=d[v];I.worldX+=(x-I.worldX)*a,I.worldY+=(w-I.worldY)*c;const M=b[T],Y=b[T+1],P=M-x,E=Y-w;if(h){const X=p[v];if(X!==0){const V=(Math.sqrt(P*P+E*E)/X-1)*r+1;I.a*=V,I.c*=V}}if(x=M,w=Y,r>0){let X=I.a,V=I.b,N=I.c,q=I.d,O=0,F=0,k=0;if(o?O=b[T-1]:f[v+1]===0?O=b[T+2]:O=Math.atan2(E,P),O-=Math.atan2(N,X),y){F=Math.cos(O),k=Math.sin(O);const D=I.bone.data.length;x+=(D*(F*X-k*N)-P)*r,w+=(D*(k*X+F*N)-E)*r}else O+=S;O>R.PI?O-=R.PI2:O<-R.PI&&(O+=R.PI2),O*=r,F=Math.cos(O),k=Math.sin(O),I.a=F*X-k*N,I.b=F*V-k*q,I.c=k*X+F*N,I.d=k*V+F*q}I.modifyWorld(A)}}computeWorldPositions(e,s,n,i){const r=this.slot;let a=this.appliedPose.position,c=this.spaces,l=L.setArraySize(this.positions,n*3+2),o=this.world;const h=s.closed;let d=s.worldVerticesLength,m=d/6,u=kt.NONE;if(!s.constantSpeed){const F=s.lengths;m-=h?1:2;const k=F[m];this.data.positionMode===1&&(a*=k);let D;switch(this.data.spacingMode){case 2:D=k;break;case 3:D=k/n;break;default:D=1}o=L.setArraySize(this.world,8);for(let U=0,W=0,B=0;U<n;U++,W+=3){const _=c[U]*D;a+=_;let $=a;if(h)$%=k,$<0&&($+=k),B=0;else if($<0){u!==kt.BEFORE&&(u=kt.BEFORE,s.computeWorldVertices(e,r,2,4,o,0,2)),this.addBeforePosition($,o,0,l,W);continue}else if($>k){u!==kt.AFTER&&(u=kt.AFTER,s.computeWorldVertices(e,r,d-6,4,o,0,2)),this.addAfterPosition($-k,o,0,l,W);continue}for(;;B++){const J=F[B];if(!($>J)){if(B===0)$/=J;else{const et=F[B-1];$=($-et)/(J-et)}break}}B!==u&&(u=B,h&&B===m?(s.computeWorldVertices(e,r,d-4,4,o,0,2),s.computeWorldVertices(e,r,0,4,o,4,2)):s.computeWorldVertices(e,r,B*6+2,8,o,0,2)),this.addCurvePosition($,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],l,W,i||U>0&&_===0)}return l}h?(d+=2,o=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d-4,o,0,2),s.computeWorldVertices(e,r,0,2,o,d-4,2),o[d-2]=o[0],o[d-1]=o[1]):(m--,d-=4,o=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d,o,0,2));const f=L.setArraySize(this.curves,m);let p=0,g=o[0],b=o[1],x=0,w=0,S=0,y=0,v=0,T=0,A=0,I=0,M=0,Y=0,P=0,E=0,X=0,V=0;for(let F=0,k=2;F<m;F++,k+=6)x=o[k],w=o[k+1],S=o[k+2],y=o[k+3],v=o[k+4],T=o[k+5],A=(g-x*2+S)*.1875,I=(b-w*2+y)*.1875,M=((x-S)*3-g+v)*.09375,Y=((w-y)*3-b+T)*.09375,P=A*2+M,E=I*2+Y,X=(x-g)*.75+A+M*.16666667,V=(w-b)*.75+I+Y*.16666667,p+=Math.sqrt(X*X+V*V),X+=P,V+=E,P+=M,E+=Y,p+=Math.sqrt(X*X+V*V),X+=P,V+=E,p+=Math.sqrt(X*X+V*V),X+=P+M,V+=E+Y,p+=Math.sqrt(X*X+V*V),f[F]=p,g=v,b=T;this.data.positionMode===1&&(a*=p);let N;switch(this.data.spacingMode){case 2:N=p;break;case 3:N=p/n;break;default:N=1}const q=this.segments;let O=0;for(let F=0,k=0,D=0,U=0;F<n;F++,k+=3){const W=c[F]*N;a+=W;let B=a;if(h)B%=p,B<0&&(B+=p),D=0,U=0;else if(B<0){this.addBeforePosition(B,o,0,l,k);continue}else if(B>p){this.addAfterPosition(B-p,o,d-4,l,k);continue}for(;;D++){const _=f[D];if(!(B>_)){if(D===0)B/=_;else{const $=f[D-1];B=(B-$)/(_-$)}break}}if(D!==u){u=D;let _=D*6;for(g=o[_],b=o[_+1],x=o[_+2],w=o[_+3],S=o[_+4],y=o[_+5],v=o[_+6],T=o[_+7],A=(g-x*2+S)*.03,I=(b-w*2+y)*.03,M=((x-S)*3-g+v)*.006,Y=((w-y)*3-b+T)*.006,P=A*2+M,E=I*2+Y,X=(x-g)*.3+A+M*.16666667,V=(w-b)*.3+I+Y*.16666667,O=Math.sqrt(X*X+V*V),q[0]=O,_=1;_<8;_++)X+=P,V+=E,P+=M,E+=Y,O+=Math.sqrt(X*X+V*V),q[_]=O;X+=P,V+=E,O+=Math.sqrt(X*X+V*V),q[8]=O,X+=P+M,V+=E+Y,O+=Math.sqrt(X*X+V*V),q[9]=O,U=0}for(B*=O;;U++){const _=q[U];if(!(B>_)){if(U===0)B/=_;else{const $=q[U-1];B=U+(B-$)/(_-$)}break}}this.addCurvePosition(B*.1,g,b,x,w,S,y,v,T,l,k,i||F>0&&W===0)}return l}addBeforePosition(e,s,n,i,r){const a=s[n],c=s[n+1],l=s[n+2]-a,o=s[n+3]-c,h=Math.atan2(o,l);i[r]=a+e*Math.cos(h),i[r+1]=c+e*Math.sin(h),i[r+2]=h}addAfterPosition(e,s,n,i,r){const a=s[n+2],c=s[n+3],l=a-s[n],o=c-s[n+1],h=Math.atan2(o,l);i[r]=a+e*Math.cos(h),i[r+1]=c+e*Math.sin(h),i[r+2]=h}addCurvePosition(e,s,n,i,r,a,c,l,o,h,d,m){if(e===0||Number.isNaN(e)){h[d]=s,h[d+1]=n,h[d+2]=Math.atan2(r-n,i-s);return}const u=e*e,f=u*e,p=1-e,g=p*p,b=g*p,x=p*e,w=x*3,S=p*w,y=w*e,v=s*b+i*S+a*y+l*f,T=n*b+r*S+c*y+o*f;h[d]=v,h[d+1]=T,m&&(e<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(T-(n*g+r*x*2+c*u),v-(s*g+i*x*2+a*u)))}sort(e){const s=this.slot.data.index,n=this.slot.bone;e.skin!=null&&this.sortPathSlot(e,e.skin,s,n),e.data.defaultSkin!=null&&e.data.defaultSkin!==e.skin&&this.sortPathSlot(e,e.data.defaultSkin,s,n),this.sortPath(e,this.slot.pose.attachment,n);const i=this.bones,r=this.bones.length;for(let a=0;a<r;a++){const c=i[a].bone;e.sortBone(c),e.constrained(c)}e._updateCache.push(this);for(let a=0;a<r;a++)e.sortReset(i[a].bone.children);for(let a=0;a<r;a++)i[a].bone.sorted=!0}sortPathSlot(e,s,n,i){const r=s.getAttachments();for(let a=0,c=r.length;a<c;a++){const l=r[a];l.slotIndex===n&&this.sortPath(e,l.attachment,i)}}sortPath(e,s,n){if(!(s instanceof ee))return;const i=s.bones;if(i==null)e.sortBone(n);else{const r=e.bones;for(let a=0,c=i.length;a<c;){let l=i[a++];for(l+=a;a<l;)e.sortBone(r[i[a++]])}}}isSourceActive(){return this.slot.bone.active}},cn=(t=>(t[t.none=0]="none",t[t.reset=1]="reset",t[t.update=2]="update",t[t.pose=3]="pose",t))(cn||{}),he=class{inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;set(t){this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}},de=class{color=new z(1,1,1,1);darkColor=null;attachment=null;sequenceIndex=0;deform=[];SlotPose(){}set(t){if(t==null)throw new Error("pose cannot be null.");this.color.setFromColor(t.color),this.darkColor!=null&&t.darkColor!=null&&this.darkColor.setFromColor(t.darkColor),this.attachment=t.attachment,this.sequenceIndex=t.sequenceIndex,this.deform.length=0,this.deform.push(...t.deform)}getAttachment(){return this.attachment}setAttachment(t){this.attachment!==t&&((!(t instanceof xt)||!(this.attachment instanceof xt)||t.timelineAttachment!==this.attachment.timelineAttachment)&&(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}},ln=class Pn extends xs{skeleton;bone;attachmentState=0;constructor(e,s){if(super(e,new de,new de),!s)throw new Error("skeleton cannot be null.");this.skeleton=s,this.bone=s.bones[e.boneData.index],e.setupPose.darkColor!=null&&(this.pose.darkColor=new z,this.constrainedPose.darkColor=new z),this.setupPose()}copy(e,s,n){const i=new Pn(e.data,this.skeleton);return this.data.setupPose.darkColor!=null&&(i.pose.darkColor=new z,i.constrainedPose.darkColor=new z),i.pose.set(e.pose),i}setupPose(){this.pose.color.setFromColor(this.data.setupPose.color),this.pose.darkColor&&this.pose.darkColor.setFromColor(this.data.setupPose.darkColor),this.pose.sequenceIndex=this.data.setupPose.sequenceIndex,this.data.attachmentName?(this.pose.attachment=null,this.pose.setAttachment(this.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.pose.setAttachment(null)}},hn=class Te{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Te.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Te.yDir}set scaleY(e){this._scaleY=e}x=0;y=0;time=0;windX=1;windY=0;gravityX=0;gravityY=1;_update=0;constructor(e){if(!e)throw new Error("data cannot be null.");this.data=e,this.bones=[];for(let s=0;s<e.bones.length;s++){const n=e.bones[s];let i;if(!n.parent)i=new re(n,null);else{const r=this.bones[n.parent.index];i=new re(n,r),r.children.push(i)}this.bones.push(i)}this.slots=[];for(const s of this.data.slots)this.slots.push(new ln(s,this));this.drawOrder=new rn(this.slots),this.physics=[],this.constraints=[];for(const s of this.data.constraints){const n=s.create(this);n instanceof As&&this.physics.push(n),this.constraints.push(n)}this.color=new z(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.resetCache.length=0,this.drawOrder.unconstrained();const e=this.slots;for(let a=0,c=e.length;a<c;a++)e[a].unconstrained();const s=this.bones,n=s.length;for(let a=0,c=n;a<c;a++){const l=s[a];l.sorted=l.data.skinRequired,l.active=!l.sorted,l.unconstrained()}if(this.skin){const a=this.skin.bones;for(let c=0,l=this.skin.bones.length;c<l;c++){let o=this.bones[a[c].index];do o.sorted=!1,o.active=!0,o=o.parent;while(o)}}const i=this.constraints;let r=this.constraints.length;for(let a=0;a<r;a++)i[a].unconstrained();for(let a=0;a<r;a++){const c=i[a];c.active=c.isSourceActive()&&(!c.data.skinRequired||this.skin!=null&&this.skin.constraints.includes(c.data)),c.active&&c.sort(this)}for(let a=0;a<n;a++)this.sortBone(s[a]);r=this._updateCache.length;for(let a=0;a<r;a++){const c=this._updateCache[a];c instanceof re&&(this._updateCache[a]=c.appliedPose)}}constrained(e){e.pose===e.appliedPose&&(e.constrained(),this.resetCache.push(e))}sortBone(e){if(e.sorted||!e.active)return;const s=e.parent;s&&this.sortBone(s),e.sorted=!0,this._updateCache.push(e)}sortReset(e){for(let s=0,n=e.length;s<n;s++){const i=e[s];i.active&&(i.sorted&&this.sortReset(i.children),i.sorted=!1)}}updateWorldTransform(e){this._update++,this.drawOrder.appliedPose===this.drawOrder.constrainedPose&&this.drawOrder.resetConstrained();const s=this.resetCache;for(let i=0,r=this.resetCache.length;i<r;i++)s[i].resetConstrained();const n=this._updateCache;for(let i=0,r=this._updateCache.length;i<r;i++)n[i].update(this,e)}setupPose(){this.setupPoseBones(),this.setupPoseSlots()}setupPoseBones(){const e=this.bones;for(let n=0,i=e.length;n<i;n++)e[n].setupPose();const s=this.constraints;for(let n=0,i=s.length;n<i;n++)s[n].setupPose()}setupPoseSlots(){this.drawOrder.setupPose();const e=this.slots;for(let s=0,n=e.length;s<n;s++)e[s].setupPose()}getRootBone(){return this.bones.length===0?null:this.bones[0]}findBone(e){if(!e)throw new Error("boneName cannot be null.");const s=this.bones;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===e)return s[n];return null}findSlot(e){if(!e)throw new Error("slotName cannot be null.");const s=this.slots;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===e)return s[n];return null}setSkin(e){typeof e=="string"?this.setSkinByName(e):this.setSkinBySkin(e)}setSkinByName(e){const s=this.data.findSkin(e);if(!s)throw new Error(`Skin not found: ${e}`);this.setSkin(s)}setSkinBySkin(e){if(e!==this.skin){if(e)if(this.skin)e.attachAll(this,this.skin);else{const s=this.slots;for(let n=0,i=s.length;n<i;n++){const r=s[n],a=r.data.attachmentName;if(a){const c=e.getAttachment(n,a);c&&r.pose.setAttachment(c)}}}this.skin=e,this.updateCache()}}getAttachment(e,s){return typeof e=="string"?this.getAttachmentByName(e,s):this.getAttachmentByIndex(e,s)}getAttachmentByName(e,s){const n=this.data.findSlot(e);if(!n)throw new Error(`Can't find slot with name ${e}`);return this.getAttachment(n.index,s)}getAttachmentByIndex(e,s){if(!s)throw new Error("placeholder cannot be null.");if(this.skin){const n=this.skin.getAttachment(e,s);if(n)return n}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(e,s):null}setAttachment(e,s){if(!e)throw new Error("slotName cannot be null.");const n=this.findSlot(e);if(!n)throw new Error(`Slot not found: ${e}`);let i=null;if(s&&(i=this.getAttachment(n.data.index,s),!i))throw new Error(`Attachment not found: ${s}, for slot: ${e}`);n.pose.setAttachment(i)}findConstraint(e,s){if(e==null)throw new Error("constraintName cannot be null.");if(s==null)throw new Error("type cannot be null.");const n=this.constraints;for(let i=0,r=n.length;i<r;i++){const a=n[i];if(a instanceof s&&a.data.name===e)return a}return null}getBoundsRect(e){const s=new Ie,n=new Ie;return this.getBounds(s,n,void 0,e),{x:s.x,y:s.y,width:n.x,height:n.y}}getBounds(e,s,n=new Array(2),i=null){if(!e)throw new Error("offset cannot be null.");if(!s)throw new Error("size cannot be null.");const r=this.drawOrder.appliedPose,a=r;let c=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let d=0,m=r.length;d<m;d++){const u=a[d];if(!u.bone.active)continue;let f=0,p=null,g=null;const b=u.appliedPose.attachment;if(b){if(b instanceof j)f=8,p=L.setArraySize(n,f,0),b.computeWorldVertices(u,b.getOffsets(u.appliedPose),p,0,2),g=Te.quadTriangles;else if(b instanceof wt)f=b.worldVerticesLength,p=L.setArraySize(n,f,0),b.computeWorldVertices(this,u,0,f,p,0,2),g=b.triangles;else if(b instanceof zt&&i){i.clipEnd(u),i.clipStart(this,u,b);continue}if(p&&g){i?.isClipping()&&i.clipTriangles(p,g,g.length)&&(p=i.clippedVertices,f=i.clippedVertices.length);for(let x=0,w=p.length;x<w;x+=2){const S=p[x],y=p[x+1];c=Math.min(c,S),l=Math.min(l,y),o=Math.max(o,S),h=Math.max(h,y)}}}i&&i.clipEnd(u)}i&&i.clipEnd(),e.set(c,l),s.set(o-c,h-l)}setScale(e,s){this.scaleX=e,this.scaleY=s}setPosition(e,s){this.x=e,this.y=s}update(e){this.time+=e}physicsTranslate(e,s){const n=this.physics;for(let i=0,r=n.length;i<r;i++)n[i].translate(e,s)}physicsRotate(e,s,n){const i=this.physics;for(let r=0,a=i.length;r<a;r++)i[r].rotate(e,s,n)}},As=class En extends Et{bone;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xLag=0;xVelocity=0;yOffset=0;yLag=0;yVelocity=0;rotateOffset=0;rotateLag=0;rotateVelocity=0;scaleOffset=0;scaleLag=0;scaleVelocity=0;remaining=0;lastTime=0;constructor(e,s){if(super(e,new he,new he),s==null)throw new Error("skeleton cannot be null.");this.bone=s.bones[e.bone.index].constrainedPose}copy(e){var s=new En(this.data,e);return s.pose.set(this.pose),s}reset(e){this.remaining=0,this.lastTime=e.time,this._reset=!0,this.xOffset=0,this.xLag=0,this.xVelocity=0,this.yOffset=0,this.yLag=0,this.yVelocity=0,this.rotateOffset=0,this.rotateLag=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleLag=0,this.scaleVelocity=0}translate(e,s){this.ux-=e,this.uy-=s,this.cx-=e,this.cy-=s}rotate(e,s,n){const i=n*R.degRad,r=Math.cos(i),a=Math.sin(i),c=this.cx-e,l=this.cy-s;this.translate(c*r-l*a-c,c*a+l*r-l)}update(e,s){const n=this.appliedPose,i=n.mix;if(i===0)return;const r=this.data.x>0,a=this.data.y>0,c=this.data.rotate>0||this.data.shearX>0,l=this.data.scaleX>0,o=this.bone;let h=o.bone.data.length,d=this.data.step,m=0;switch(s){case 0:return;case 1:this.reset(e);case 2:{const u=Math.max(e.time-this.lastTime,0),f=this.remaining;this.remaining+=u,this.lastTime=e.time;const p=o.worldX,g=o.worldY;if(this._reset)this._reset=!1,this.ux=p,this.uy=g;else{let b=this.remaining,x=n.inertia,w=e.data.referenceScale,S=-1,y=0,v=0,T=this.data.limit*u,A=T*Math.abs(e.scaleY);if(T*=Math.abs(e.scaleX),r||a){if(r){const I=(this.ux-p)*x;this.xOffset+=I>T?T:I<-T?-T:I,this.ux=p}if(a){const I=(this.uy-g)*x;this.yOffset+=I>A?A:I<-A?-A:I,this.uy=g}if(b>=d){const I=this.xOffset,M=this.yOffset;S=n.damping**(60*d),y=d*n.massInverse,v=n.strength;const Y=w*n.wind,P=w*n.gravity,E=(Y*e.windX+P*e.gravityX)*e.scaleX,X=(Y*e.windY+P*e.gravityY)*e.scaleY;do r&&(this.xVelocity+=(E-this.xOffset*v)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=S),a&&(this.yVelocity-=(X+this.yOffset*v)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=S),b-=d;while(b>=d);this.xLag=this.xOffset-I,this.yLag=this.yOffset-M}m=Math.max(0,1-b/d),r&&(o.worldX+=(this.xOffset-this.xLag*m)*i*this.data.x),a&&(o.worldY+=(this.yOffset-this.yLag*m)*i*this.data.y)}if(c||l){let I=Math.atan2(o.c,o.a),M=0,Y=0,P=0,E=this.cx-o.worldX,X=this.cy-o.worldY;if(E>T?E=T:E<-T&&(E=-T),X>A?X=A:X<-A&&(X=-A),b=this.remaining,c){P=(this.data.rotate+this.data.shearX)*i,m=this.rotateLag*Math.max(0,1-f/d);let V=Math.atan2(X+this.ty,E+this.tx)-I-(this.rotateOffset-m)*P;this.rotateOffset+=(V-Math.ceil(V*R.invPI2-.5)*R.PI2)*x,V=(this.rotateOffset-m)*P+I,M=Math.cos(V),Y=Math.sin(V),l&&(V=h*o.getWorldScaleX(),V>0&&(this.scaleOffset+=(E*M+X*Y)*x/V))}else{M=Math.cos(I),Y=Math.sin(I);const V=h*o.getWorldScaleX()-this.scaleLag*Math.max(0,1-f/d);V>0&&(this.scaleOffset+=(E*M+X*Y)*x/V)}if(b>=d){S===-1&&(S=n.damping**(60*d),y=d*n.massInverse,v=n.strength);const V=n.wind*e.windX+n.gravity*e.gravityX,N=(n.wind*e.windY+n.gravity*e.gravityY)*hn.yDir,q=this.rotateOffset,O=this.scaleOffset,F=h/w;for(;;)if(b-=d,l&&(this.scaleVelocity+=(V*M-N*Y-this.scaleOffset*v)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=S),c){if(this.rotateVelocity-=((V*Y+N*M)*F+this.rotateOffset*v)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=S,b<d)break;const k=this.rotateOffset*P+I;M=Math.cos(k),Y=Math.sin(k)}else if(b<d)break;this.rotateLag=this.rotateOffset-q,this.scaleLag=this.scaleOffset-O}m=Math.max(0,1-b/d)}this.remaining=b}this.cx=o.worldX,this.cy=o.worldY;break}case 3:m=Math.max(0,1-this.remaining/d),r&&(o.worldX+=(this.xOffset-this.xLag*m)*i*this.data.x),a&&(o.worldY+=(this.yOffset-this.yLag*m)*i*this.data.y)}if(c){let u=(this.rotateOffset-this.rotateLag*m)*i,f=0,p=0,g=0;if(this.data.shearX>0){let b=0;this.data.rotate>0&&(b=u*this.data.rotate,f=Math.sin(b),p=Math.cos(b),g=o.b,o.b=p*g-f*o.d,o.d=f*g+p*o.d),b+=u*this.data.shearX,f=Math.sin(b),p=Math.cos(b),g=o.a,o.a=p*g-f*o.c,o.c=f*g+p*o.c}else u*=this.data.rotate,f=Math.sin(u),p=Math.cos(u),g=o.a,o.a=p*g-f*o.c,o.c=f*g+p*o.c,g=o.b,o.b=p*g-f*o.d,o.d=f*g+p*o.d}if(l){let u=1+(this.scaleOffset-this.scaleLag*m)*i*this.data.scaleX;switch(o.a*=u,o.c*=u,this.data.scaleYMode){case 1:o.b*=u,o.d*=u;break;case 2:u=Math.abs(u),u=u>=.7?1/u:4-3.67347*u,o.b*=u,o.d*=u}}s!==3&&(this.tx=h*o.a,this.ty=h*o.c),o.modifyWorld(e._update)}sort(e){const s=this.bone.bone;e.sortBone(s),e._updateCache.push(this),e.sortReset(s.children),e.constrained(s)}isSourceActive(){return this.bone.bone.active}},Gt=class extends Xt{set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}_bone=null;x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;_scaleYMode=0;get scaleYMode(){return this._scaleYMode}set scaleYMode(t){if(t==null)throw new Error("scaleYMode cannot be null.");this._scaleYMode=t}constructor(t){super(t,new he)}create(t){return new As(this,t)}};typeof Math.fround>"u"&&(Math.fround=(t=>e=>(t[0]=e,t[0]))(new Float32Array(1)));var fe=class{time=0;mix=0;set(t){this.time=t.time,this.mix=t.mix}},dn=class Us extends Et{static offsets=[0,0,0,0,0,0];bone=null;constructor(e,s){if(super(e,new fe,new fe),!s)throw new Error("skeleton cannot be null.");e.bone!=null&&(this.bone=s.bones[e.bone.index])}copy(e){var s=new Us(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.data,r=i.animation,a=this.bone;if(a!==null){if(!a.active)return;i.local&&a.appliedPose.validateLocalTransform(e),n.time=i.offset+(i.property.value(e,a.appliedPose,i.local,Us.offsets)-i.property.offset)*i.scale,i.loop?n.time=r.duration+n.time%r.duration:n.time=Math.max(0,n.time)}const c=e.bones,l=r.bones;for(let o=0,h=r.bones.length;o<h;o++)c[l[o]].appliedPose.modifyLocal(e);r.apply(e,n.time,n.time,i.loop,null,n.mix,0,i.additive,!1,!0)}sort(e){const s=this.bone,n=this.data;s&&!n.local&&e.sortBone(s),e._updateCache.push(this);const i=e.bones,r=n.animation.bones;for(let d=0,m=n.animation.bones.length;d<m;d++){const u=i[r[d]];u.sorted=!1,e.sortReset(u.children),e.constrained(u)}const a=n.animation.timelines,c=e.slots,l=e.constraints,o=e.physics,h=e.physics.length;for(let d=0,m=n.animation.timelines.length;d<m;d++){const u=a[d];if(Gs(u))e.constrained(c[u.slotIndex]);else if(u instanceof At||u instanceof qt)e.drawOrder.constrained();else if(u instanceof bt)if(u.constraintIndex===-1)for(let f=0;f<h;f++)e.constrained(o[f]);else e.constrained(l[u.constraintIndex]);else if(Ks(u)){const f=u.constraintIndex;f!==-1&&e.constrained(l[f])}}}},St=class extends Xt{animation;additive=!1;loop=!1;bone=null;property;scale=0;offset=0;local=!1;max=0;constructor(t){super(t,new fe)}create(t){return new dn(this,t)}},Is=class{name=null;bones=[];slots=[];skins=[];defaultSkin=null;events=[];animations=[];constraints=[];x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=30;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");const e=this.bones;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");const e=this.slots;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSkin(t){if(!t)throw new Error("skinName cannot be null.");const e=this.skins;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findEvent(t){if(!t)throw new Error("eventDataName cannot be null.");const e=this.events;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSliderAnimations(t){const e=this.constraints;for(let s=0,n=this.constraints.length;s<n;s++){const i=e[s];i instanceof St&&i.animation!=null&&t.push(i.animation)}return t}findAnimation(t){if(!t)throw new Error("animationName cannot be null.");const e=this.animations;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findConstraint(t,e){if(!t)throw new Error("constraintName cannot be null.");if(e==null)throw new Error("type cannot be null.");const s=this.constraints;for(let n=0,i=this.constraints.length;n<i;n++){const r=s[n];if(r instanceof e&&r.name===t)return r}return null}},Cs=class{slotIndex=0;placeholder;attachment;constructor(t=0,e,s){this.slotIndex=t,this.placeholder=e,this.attachment=s}},ue=class{name;attachments=[];bones=[];constraints=[];color=new z(.99607843,.61960787,.30980393,1);constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}setAttachment(t,e,s){if(!s)throw new Error("attachment cannot be null.");const n=this.attachments;t>=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=s}addSkin(t){for(let s=0;s<t.bones.length;s++){const n=t.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<t.constraints.length;s++){const n=t.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const e=t.getAttachments();for(let s=0;s<e.length;s++){const n=e[s];this.setAttachment(n.slotIndex,n.placeholder,n.attachment)}}copySkin(t){for(let s=0;s<t.bones.length;s++){const n=t.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<t.constraints.length;s++){const n=t.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const e=t.getAttachments();for(let s=0;s<e.length;s++){const n=e[s];n.attachment&&(n.attachment instanceof wt?(n.attachment=n.attachment.newLinkedMesh(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)):(n.attachment=n.attachment.copy(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)))}}getAttachment(t,e){const s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){const s=this.attachments[t];s&&delete s[e]}getAttachments(){const t=[];for(let e=0;e<this.attachments.length;e++){const s=this.attachments[e];if(s)for(const n in s){const i=s[n];i&&t.push(new Cs(e,n,i))}}return t}getAttachmentsForSlot(t,e){const s=this.attachments[t];if(s)for(const n in s){const i=s[n];i&&e.push(new Cs(t,n,i))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let n=0;n<t.slots.length;n++){const i=t.slots[n],r=i.pose.getAttachment();if(r&&s<e.attachments.length){const a=e.attachments[s];for(const c in a){const l=a[c];if(r===l){const o=this.getAttachment(s,c);o&&i.pose.setAttachment(o);break}}}s++}}},Ms=class extends se{index=0;boneData;attachmentName=null;blendMode=0;visible=!0;constructor(t,e,s){if(super(e,new de),t<0)throw new Error("index must be >= 0.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.boneData=s}},Ys=(t=>(t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen",t))(Ys||{}),me=class{mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;set(t){this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}},fn=class Xn extends Et{bones;source;constructor(e,s){if(super(e,new me,new me),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const i of e.bones)this.bones.push(s.bones[i.index].constrainedPose);const n=s.bones[e.source.index];if(n==null)throw new Error("source cannot be null.");this.source=n}copy(e){var s=new Xn(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mixRotate===0&&n.mixX===0&&n.mixY===0&&n.mixScaleX===0&&n.mixScaleY===0&&n.mixShearY===0)return;const i=this.data,r=i.localSource,a=i.localTarget,c=i.additive,l=i.clamp,o=i.offsets,h=this.source.appliedPose;r&&h.validateLocalTransform(e);const d=i.properties,m=i.properties.length,u=e._update,f=this.bones;for(let p=0,g=this.bones.length;p<g;p++){const b=f[p];a?b.modifyLocal(e):b.modifyWorld(u);for(let x=0;x<m;x++){const w=d[x],S=w.value(e,h,r,o)-w.offset,y=w.to;for(let v=0,T=w.to.length;v<T;v++){const A=y[v];if(A.mix(n)!==0){let I=A.offset+S*A.scale;l&&(A.offset<A.max?I=R.clamp(I,A.offset,A.max):I=R.clamp(I,A.max,A.offset)),A.apply(e,n,b,I,a,c)}}}}}sort(e){this.data.localSource||e.sortBone(this.source);const s=this.bones,n=this.bones.length,i=!this.data.localTarget;if(i)for(let r=0;r<n;r++)e.sortBone(s[r].bone);e._updateCache.push(this);for(let r=0;r<n;r++){const a=s[r].bone;e.sortReset(a.children),e.constrained(a)}for(let r=0;r<n;r++)s[r].bone.sorted=i}isSourceActive(){return this.source.active}},K=class ht extends Xt{static ROTATION=0;static X=1;static Y=2;static SCALEX=3;static SCALEY=4;static SHEARY=5;bones=[];set source(e){this._source=e}get source(){if(this._source)return this._source;throw new Error("BoneData not set.")}_source=null;offsets=[0,0,0,0,0,0];offsetX=0;offsetY=0;localSource=!1;localTarget=!1;additive=!1;clamp=!1;properties=[];constructor(e){super(e,new me)}create(e){return new fn(this,e)}getOffsetRotation(){return this.offsets[ht.ROTATION]}setOffsetRotation(e){this.offsets[ht.ROTATION]=e}getOffsetX(){return this.offsets[ht.X]}setOffsetX(e){this.offsets[ht.X]=e}getOffsetY(){return this.offsets[ht.Y]}setOffsetY(e){this.offsets[ht.Y]=e}getOffsetScaleX(){return this.offsets[ht.SCALEX]}setOffsetScaleX(e){this.offsets[ht.SCALEX]=e}getOffsetScaleY(){return this.offsets[ht.SCALEY]}setOffsetScaleY(e){this.offsets[ht.SCALEY]=e}getOffsetShearY(){return this.offsets[ht.SHEARY]}setOffsetShearY(e){this.offsets[ht.SHEARY]=e}},It=class{offset=0;to=[]},Ct=class{offset=0;max=0;scale=0},ge=class extends It{value(t,e,s,n){if(s)return e.rotation+n[K.ROTATION];const i=t.scaleX,r=t.scaleY;let a=Math.atan2(e.c/r,e.a/i)*R.radDeg+((e.a*e.d-e.b*e.c)*i*r>0?n[K.ROTATION]:-n[K.ROTATION]);return a<0&&(a+=360),a}},ks=class extends Ct{mix(t){return t.mixRotate}apply(t,e,s,n,i,r){if(i)s.rotation+=(r?n:n-s.rotation)*e.mixRotate;else{const a=t.scaleX,c=t.scaleY,l=1/a,o=1/c,h=s.a*l,d=s.b*l,m=s.c*o,u=s.d*o;n*=R.degRad,r||(n-=Math.atan2(m,h)),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2),n*=e.mixRotate;const f=Math.cos(n),p=Math.sin(n);s.a=(f*h-p*m)*a,s.b=(f*d-p*u)*a,s.c=(p*h+f*m)*c,s.d=(p*d+f*u)*c}}},pe=class extends It{value(t,e,s,n){return s?e.x+n[K.X]:(n[K.X]*e.a+n[K.Y]*e.b+e.worldX)/t.scaleX}},Fs=class extends Ct{mix(t){return t.mixX}apply(t,e,s,n,i,r){i?s.x+=(r?n:n-s.x)*e.mixX:(r||(n-=s.worldX/t.scaleX),s.worldX+=n*e.mixX*t.scaleX)}},be=class extends It{value(t,e,s,n){return s?e.y+n[K.Y]:(n[K.X]*e.c+n[K.Y]*e.d+e.worldY)/t.scaleY}},Ps=class extends Ct{mix(t){return t.mixY}apply(t,e,s,n,i,r){i?s.y+=(r?n:n-s.y)*e.mixY:(r||(n-=s.worldY/t.scaleY),s.worldY+=n*e.mixY*t.scaleY)}},xe=class extends It{value(t,e,s,n){if(s)return e.scaleX+n[K.SCALEX];const i=e.a/t.scaleX,r=e.c/t.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEX]}},Es=class extends Ct{mix(t){return t.mixScaleX}apply(t,e,s,n,i,r){if(i)r?s.scaleX*=1+(n-1)*e.mixScaleX:s.scaleX!==0&&(s.scaleX+=(n-s.scaleX)*e.mixScaleX);else if(r){const a=1+(n-1)*e.mixScaleX;s.a*=a,s.c*=a}else{let a=s.a/t.scaleX,c=s.c/t.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*e.mixScaleX/l,s.a*=l,s.c*=l)}}},we=class extends It{value(t,e,s,n){if(s)return e.scaleY+n[K.SCALEY];const i=e.b/t.scaleX,r=e.d/t.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEY]}},Xs=class extends Ct{mix(t){return t.mixScaleY}apply(t,e,s,n,i,r){if(i)r?s.scaleY*=1+(n-1)*e.mixScaleY:s.scaleY!==0&&(s.scaleY+=(n-s.scaleY)*e.mixScaleY);else if(r){const a=1+(n-1)*e.mixScaleY;s.b*=a,s.d*=a}else{let a=s.b/t.scaleX,c=s.d/t.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*e.mixScaleY/l,s.b*=l,s.d*=l)}}},ye=class extends It{value(t,e,s,n){if(s)return e.shearY+n[K.SHEARY];const i=1/t.scaleX,r=1/t.scaleY;return(Math.atan2(e.d*r,e.b*i)-Math.atan2(e.c*r,e.a*i))*R.radDeg-90+n[K.SHEARY]}},Vs=class extends Ct{mix(t){return t.mixShearY}apply(t,e,s,n,i,r){if(i)r||(n-=s.shearY),s.shearY+=n*e.mixShearY;else{const a=t.scaleX,c=t.scaleY,l=s.b/a,o=s.d/c,h=Math.atan2(o,l);n=(n+90)*R.degRad,r?n-=R.PI/2:(n-=h-Math.atan2(s.c/c,s.a/a),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2)),n=h+n*e.mixShearY;const d=Math.sqrt(l*l+o*o);s.b=Math.cos(n)*d*a,s.d=Math.sin(n)*d*c}}},zn=class{scale=1;attachmentLoader;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Is;s.name="";const n=new un(t),i=n.readInt32(),r=n.readInt32();s.hash=r===0&&i===0?null:r.toString(16)+i.toString(16),s.version=n.readString(),s.x=n.readFloat(),s.y=n.readFloat(),s.width=n.readFloat(),s.height=n.readFloat(),s.referenceScale=n.readFloat()*e;const a=n.readBoolean();a&&(s.fps=n.readFloat(),s.imagesPath=n.readString(),s.audioPath=n.readString());let c=0;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("String in string table must not be null.");n.strings.push(f)}const l=s.bones;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Bone name must not be null.");const p=u===0?null:l[n.readInt(!0)],g=new bs(u,f,p),b=g.setupPose;b.rotation=n.readFloat(),b.x=n.readFloat()*e,b.y=n.readFloat()*e,b.scaleX=n.readFloat(),b.scaleY=n.readFloat(),b.shearX=n.readFloat(),b.shearY=n.readFloat(),b.inherit=n.readByte(),g.length=n.readFloat()*e,g.skinRequired=n.readBoolean(),a&&(z.rgba8888ToColor(g.color,n.readInt32()),g.icon=n.readString()??void 0,g.iconSize=n.readFloat(),g.iconRotation=n.readFloat(),g.visible=n.readBoolean()),l.push(g)}c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Slot name must not be null.");const p=l[n.readInt(!0)],g=new Ms(u,f,p);z.rgba8888ToColor(g.setupPose.color,n.readInt32());const b=n.readInt32();b!==-1&&z.rgb888ToColor(g.setupPose.darkColor=new z,b),g.attachmentName=n.readStringRef(),g.blendMode=n.readInt(!0),a&&(g.visible=n.readBoolean()),s.slots.push(g)}const o=s.constraints,h=n.readInt(!0);for(let u=0;u<h;u++){const f=n.readString();if(!f)throw new Error("Constraint data name must not be null.");let p;switch(n.readByte()){case fi:{const g=new Wt(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.target=l[n.readInt(!0)];const b=n.readByte();g.skinRequired=(b&1)!==0,(b&2)!==0&&(g.scaleYMode=n.readUnsignedByte());const x=g.setupPose;x.bendDirection=(b&4)!==0?-1:1,x.compress=(b&8)!==0,x.stretch=(b&16)!==0,(b&32)!==0&&(x.mix=(b&64)!==0?n.readFloat():1),(b&128)!==0&&(x.softness=n.readFloat()*e),o.push(g);break}case mi:{const g=new K(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.source=l[n.readInt(!0)];let b=n.readUnsignedByte();g.skinRequired=(b&1)!==0,g.localSource=(b&2)!==0,g.localTarget=(b&4)!==0,g.additive=(b&8)!==0,g.clamp=(b&16)!==0,p=b>>5;for(let w=0,S;w<p;w++){let y=1,v;switch(n.readByte()){case 0:v=new ge;break;case 1:{y=e,v=new pe;break}case 2:{y=e,v=new be;break}case 3:v=new xe;break;case 4:v=new we;break;case 5:v=new ye;break;default:v=null}if(v){v.offset=n.readFloat()*y,S=n.readByte();for(let T=0;T<S;T++){let A=1,I;switch(n.readByte()){case 0:I=new ks;break;case 1:{A=e,I=new Fs;break}case 2:{A=e,I=new Ps;break}case 3:I=new Es;break;case 4:I=new Xs;break;case 5:I=new Vs;break;default:I=null}I&&(I.offset=n.readFloat()*A,I.max=n.readFloat()*A,I.scale=n.readFloat()*A/y,v.to[T]=I)}g.properties[w]=v}}b=n.readByte(),(b&1)!==0&&(g.offsets[K.ROTATION]=n.readFloat()),(b&2)!==0&&(g.offsets[K.X]=n.readFloat()*e),(b&4)!==0&&(g.offsets[K.Y]=n.readFloat()*e),(b&8)!==0&&(g.offsets[K.SCALEX]=n.readFloat()),(b&16)!==0&&(g.offsets[K.SCALEY]=n.readFloat()),(b&32)!==0&&(g.offsets[K.SHEARY]=n.readFloat()),b=n.readByte();const x=g.setupPose;(b&1)!==0&&(x.mixRotate=n.readFloat()),(b&2)!==0&&(x.mixX=n.readFloat()),(b&4)!==0&&(x.mixY=n.readFloat()),(b&8)!==0&&(x.mixScaleX=n.readFloat()),(b&16)!==0&&(x.mixScaleY=n.readFloat()),(b&32)!==0&&(x.mixShearY=n.readFloat()),o.push(g);break}case ui:{const g=new Ht(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.slot=s.slots[n.readInt(!0)];const b=n.readByte();g.skinRequired=(b&1)!==0,g.positionMode=b>>1&1,g.spacingMode=b>>2&3,g.rotateMode=b>>4&3,(b&128)!==0&&(g.offsetRotation=n.readFloat());const x=g.setupPose;x.position=n.readFloat(),g.positionMode===0&&(x.position*=e),x.spacing=n.readFloat(),(g.spacingMode===0||g.spacingMode===1)&&(x.spacing*=e),x.mixRotate=n.readFloat(),x.mixX=n.readFloat(),x.mixY=n.readFloat(),o.push(g);break}case gi:{const g=new Gt(f);g.bone=l[n.readInt(!0)];let b=n.readByte();if(g.skinRequired=(b&1)!==0,(b&2)!==0&&(g.x=n.readFloat()),(b&4)!==0&&(g.y=n.readFloat()),(b&8)!==0&&(g.rotate=n.readFloat()),(b&16)!==0){let w=n.readFloat();w<-2?(g.scaleYMode=2,w=-2-w):w<0&&(g.scaleYMode=1,w=-1-w),g.scaleX=w}(b&32)!==0&&(g.shearX=n.readFloat()),g.limit=((b&64)!==0?n.readFloat():5e3)*e,g.step=1/n.readUnsignedByte();const x=g.setupPose;x.inertia=n.readFloat(),x.strength=n.readFloat(),x.damping=n.readFloat(),x.massInverse=(b&128)!==0?n.readFloat():1,x.wind=n.readFloat(),x.gravity=n.readFloat(),b=n.readByte(),(b&1)!==0&&(g.inertiaGlobal=!0),(b&2)!==0&&(g.strengthGlobal=!0),(b&4)!==0&&(g.dampingGlobal=!0),(b&8)!==0&&(g.massGlobal=!0),(b&16)!==0&&(g.windGlobal=!0),(b&32)!==0&&(g.gravityGlobal=!0),(b&64)!==0&&(g.mixGlobal=!0),x.mix=(b&128)!==0?n.readFloat():1,o.push(g);break}case pi:{const g=new St(f),b=n.readByte();if(g.skinRequired=(b&1)!==0,g.loop=(b&2)!==0,g.additive=(b&4)!==0,(b&8)!==0){const x=n.readFloat();a&&(b&64)!==0?g.max=x:g.setupPose.time=x}if((b&16)!==0&&(g.setupPose.mix=(b&32)!==0?n.readFloat():1),(b&64)!==0){g.local=(b&128)!==0,g.bone=l[n.readInt(!0)];const x=n.readFloat();let w=1;switch(n.readByte()){case 0:g.property=new ge;break;case 1:{w=e,g.property=new pe;break}case 2:{w=e,g.property=new be;break}case 3:g.property=new xe;break;case 4:g.property=new we;break;case 5:g.property=new ye;break;default:continue}g.property.offset=x*w,g.offset=n.readFloat(),g.scale=n.readFloat()/w}o.push(g);break}}}const d=this.readSkin(n,s,!0,a);d&&(s.defaultSkin=d,s.skins.push(d));{let u=s.skins.length;for(L.setArraySize(s.skins,c=u+n.readInt(!0));u<c;u++){const f=this.readSkin(n,s,!1,a);if(!f)throw new Error("readSkin() should not have returned null.");s.skins[u]=f}}c=this.linkedMeshes.length;for(let u=0;u<c;u++){const f=this.linkedMeshes[u],p=s.skins[f.skinIndex];if(!f.source)throw new Error("Linked mesh parent must not be null");const g=p.getAttachment(f.sourceIndex,f.source);if(!g)throw new Error(`Source mesh not found: ${f.source}`);f.mesh.timelineAttachment=f.inheritTimelines?g:f.mesh,f.mesh.setSourceMesh(g),f.mesh.updateSequence()}this.linkedMeshes.length=0,c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Event data name must not be null");const p=new ys(f),g=p.setupPose;g.intValue=n.readInt(!1),g.floatValue=n.readFloat(),g.stringValue=n.readString(),p._audioPath=n.readString(),p.audioPath&&(g.volume=n.readFloat(),g.balance=n.readFloat()),s.events.push(p)}const m=s.animations;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Animation name must not be null.");m.push(this.readAnimation(n,f,s,a))}for(let u=0;u<h;u++){const f=o[u];f instanceof St&&(f.animation=m[n.readInt(!0)])}return s}readSkin(t,e,s,n){let i=null,r=0;if(s){if(r=t.readInt(!0),r===0)return null;i=new ue("default")}else{const a=t.readString();if(!a)throw new Error("Skin name must not be null.");i=new ue(a),n&&z.rgba8888ToColor(i.color,t.readInt32());let c=t.readInt(!0),l=e.bones,o=i.bones;for(let h=0;h<c;h++)o[h]=l[t.readInt(!0)];c=t.readInt(!0),l=e.constraints,o=i.constraints;for(let h=0;h<c;h++)o[h]=l[t.readInt(!0)];r=t.readInt(!0)}for(let a=0;a<r;a++){const c=t.readInt(!0);for(let l=0,o=t.readInt(!0);l<o;l++){const h=t.readStringRef();if(!h)throw new Error("Attachment name must not be null");const d=this.readAttachment(t,e,i,c,h,n);d&&i.setAttachment(c,h,d)}}return i}readAttachment(t,e,s,n,i,r){const a=this.scale,c=t.readByte(),l=(c&8)!==0?t.readStringRef():i;if(!l)throw new Error("Attachment name must not be null");switch(c&7){case 0:{let o=(c&16)!==0?t.readStringRef():null;const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=(c&128)!==0?t.readFloat():0,u=t.readFloat(),f=t.readFloat(),p=t.readFloat(),g=t.readFloat(),b=t.readFloat(),x=t.readFloat();o||(o=l);const w=this.attachmentLoader.newRegionAttachment(s,i,l,o,d);return w?(w.path=o,w.x=u*a,w.y=f*a,w.scaleX=p,w.scaleY=g,w.rotation=m,w.width=b*a,w.height=x*a,z.rgba8888ToColor(w.color,h),w.updateSequence(),w):null}case 1:{const o=this.readVertices(t,(c&16)!==0),h=r?t.readInt32():0,d=this.attachmentLoader.newBoundingBoxAttachment(s,i,l);return d?(d.worldVerticesLength=o.length,d.vertices=o.vertices,d.bones=o.bones,r&&z.rgba8888ToColor(d.color,h),d):null}case 2:{let o=(c&16)!==0?t.readStringRef():l;const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=t.readInt(!0),u=this.readVertices(t,(c&128)!==0),f=this.readFloatArray(t,u.length,1),p=this.readShortArray(t,(u.length-m-2)*3),g=t.readInt(!0);let b=null;if(g>0){b=[];for(let v=0;v<g;v++)b[v]=t.readInt(!0)}let x=[],w=0,S=0;r&&(x=this.readShortArray(t,t.readInt(!0)),w=t.readFloat(),S=t.readFloat()),o||(o=l);const y=this.attachmentLoader.newMeshAttachment(s,i,l,o,d);return y?(y.path=o,z.rgba8888ToColor(y.color,h),y.hullLength=m<<1,y.bones=u.bones,y.vertices=u.vertices,y.worldVerticesLength=u.length,y.regionUVs=f,y.triangles=p,b&&(y.timelineSlots=b),r&&(y.edges=x,y.width=w*a,y.height=S*a),y.updateSequence(),y):null}case 3:{const o=(c&16)!==0?t.readStringRef():l;if(o==null)throw new Error("Path of linked mesh must not be null");const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=(c&128)!==0,u=t.readInt(!0),f=t.readInt(!0),p=t.readStringRef();let g=0,b=0;r&&(g=t.readFloat(),b=t.readFloat());const x=this.attachmentLoader.newMeshAttachment(s,i,l,o,d);return x?(x.path=o,z.rgba8888ToColor(x.color,h),r&&(x.width=g*a,x.height=b*a),this.linkedMeshes.push(new Wn(x,f,n,u,p,m)),x):null}case 4:{const o=(c&16)!==0,h=(c&32)!==0,d=this.readVertices(t,(c&64)!==0),m=this.readFloatArray(t,d.length/6,a),u=r?t.readInt32():0,f=this.attachmentLoader.newPathAttachment(s,i,l);return f?(f.closed=o,f.constantSpeed=h,f.worldVerticesLength=d.length,f.vertices=d.vertices,f.bones=d.bones,f.lengths=m,r&&z.rgba8888ToColor(f.color,u),f):null}case 5:{const o=t.readFloat(),h=t.readFloat(),d=t.readFloat(),m=r?t.readInt32():0,u=this.attachmentLoader.newPointAttachment(s,i,l);return u?(u.x=h*a,u.y=d*a,u.rotation=o,r&&z.rgba8888ToColor(u.color,m),u):null}case 6:{const o=t.readInt(!0),h=this.readVertices(t,(c&16)!==0),d=r?t.readInt32():0,m=this.attachmentLoader.newClippingAttachment(s,i,l);return m?(m.endSlot=e.slots[o],m.convex=(c&32)!==0,m.inverse=(c&64)!==0,m.worldVerticesLength=h.length,m.vertices=h.vertices,m.bones=h.bones,r&&z.rgba8888ToColor(m.color,d),m):null}}}readSequence(t,e){if(!e)return new Nt(1,!1);const s=new Nt(t.readInt(!0),!0);return s.start=t.readInt(!0),s.digits=t.readInt(!0),s.setupIndex=t.readInt(!0),s}readVertices(t,e){const s=this.scale,i=t.readInt(!0)<<1;if(!e)return new mn(null,this.readFloatArray(t,i,s),i);const r=t.readInt(!0),a=[],c=[];for(let l=0,o=0;l<r;){const h=t.readInt(!0);a[l++]=h;for(let d=0;d<h;d++,o+=3)a[l++]=t.readInt(!0),c[o]=t.readFloat()*s,c[o+1]=t.readFloat()*s,c[o+2]=t.readFloat()}return new mn(a,L.toFloatArray(c),i)}readFloatArray(t,e,s){const n=[];if(s===1)for(let i=0;i<e;i++)n[i]=t.readFloat();else for(let i=0;i<e;i++)n[i]=t.readFloat()*s;return n}readShortArray(t,e){const s=[];for(let n=0;n<e;n++)s[n]=t.readInt(!0);return s}readAnimation(t,e,s,n){t.readInt(!0);const i=[],r=this.scale;for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0),w=x-1;switch(b){case oi:{const S=new Ft(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat(),t.readStringRef());i.push(S);break}case ai:{const S=t.readInt(!0),y=new $e(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255;for(let Y=0,P=0;y.setFrame(Y,v,T,A,I,M),Y!==w;Y++){const E=t.readFloat(),X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255,N=t.readUnsignedByte()/255,q=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(Y);break;case gt:H(t,y,P++,Y,0,v,E,T,X,1),H(t,y,P++,Y,1,v,E,A,V,1),H(t,y,P++,Y,2,v,E,I,N,1),H(t,y,P++,Y,3,v,E,M,q,1)}v=E,T=X,A=V,I=N,M=q}i.push(y);break}case ci:{const S=t.readInt(!0),y=new qe(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255;for(let M=0,Y=0;y.setFrame(M,v,T,A,I),M!==w;M++){const P=t.readFloat(),E=t.readUnsignedByte()/255,X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(M);break;case gt:H(t,y,Y++,M,0,v,P,T,E,1),H(t,y,Y++,M,1,v,P,A,X,1),H(t,y,Y++,M,2,v,P,I,V,1)}v=P,T=E,A=X,I=V}i.push(y);break}case li:{const S=t.readInt(!0),y=new ze(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,E=t.readUnsignedByte()/255;for(let X=0,V=0;y.setFrame(X,v,T,A,I,M,Y,P,E),X!==w;X++){const N=t.readFloat(),q=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255,W=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(X);break;case gt:H(t,y,V++,X,0,v,N,T,q,1),H(t,y,V++,X,1,v,N,A,O,1),H(t,y,V++,X,2,v,N,I,F,1),H(t,y,V++,X,3,v,N,M,k,1),H(t,y,V++,X,4,v,N,Y,D,1),H(t,y,V++,X,5,v,N,P,U,1),H(t,y,V++,X,6,v,N,E,W,1)}v=N,T=q,A=O,I=F,M=k,Y=D,P=U,E=W}i.push(y);break}case hi:{const S=t.readInt(!0),y=new We(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255;for(let E=0,X=0;y.setFrame(E,v,T,A,I,M,Y,P),E!==w;E++){const V=t.readFloat(),N=t.readUnsignedByte()/255,q=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(E);break;case gt:H(t,y,X++,E,0,v,V,T,N,1),H(t,y,X++,E,1,v,V,A,q,1),H(t,y,X++,E,2,v,V,I,O,1),H(t,y,X++,E,3,v,V,M,F,1),H(t,y,X++,E,4,v,V,Y,k,1),H(t,y,X++,E,5,v,V,P,D,1)}v=V,T=N,A=q,I=O,M=F,Y=k,P=D}i.push(y);break}case di:{const S=new _e(x,t.readInt(!0),f);let y=t.readFloat(),v=t.readUnsignedByte()/255;for(let T=0,A=0;S.setFrame(T,y,v),T!==w;T++){const I=t.readFloat(),M=t.readUnsignedByte()/255;switch(t.readByte()){case mt:S.setStepped(T);break;case gt:H(t,S,A++,T,0,y,I,v,M,1)}y=I,v=M}i.push(S)}}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0);if(b===ri){const S=new De(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat(),t.readByte());i.push(S);continue}const w=t.readInt(!0);switch(b){case jn:tt(t,i,new Dt(x,w,f),1);break;case Kn:tt(t,i,new Ee(x,w,f),r);break;case Jn:tt(t,i,new Xe(x,w,f),r);break;case Qn:tt(t,i,new Ve(x,w,f),r);break;case Zn:tt(t,i,new Re(x,w,f),1);break;case ti:tt(t,i,new Le(x,w,f),1);break;case ei:tt(t,i,new Be(x,w,f),1);break;case si:tt(t,i,new Oe(x,w,f),1);break;case ni:tt(t,i,new Ne(x,w,f),1);break;case ii:tt(t,i,new Ue(x,w,f),1);break}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new je(p,t.readInt(!0),f);let x=t.readByte(),w=t.readFloat(),S=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,y=(x&4)!==0?t.readFloat()*r:0;for(let v=0,T=0;b.setFrame(v,w,S,y,(x&8)!==0?1:-1,(x&16)!==0,(x&32)!==0),v!==g;v++){x=t.readByte();const A=t.readFloat(),I=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,M=(x&4)!==0?t.readFloat()*r:0;(x&64)!==0?b.setStepped(v):(x&128)!==0&&(H(t,b,T++,v,0,w,A,S,I,1),H(t,b,T++,v,1,w,A,y,M,r)),w=A,S=I,y=M}i.push(b)}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new Ke(p,t.readInt(!0),f);let x=t.readFloat(),w=t.readFloat(),S=t.readFloat(),y=t.readFloat(),v=t.readFloat(),T=t.readFloat(),A=t.readFloat();for(let I=0,M=0;b.setFrame(I,x,w,S,y,v,T,A),I!==g;I++){const Y=t.readFloat(),P=t.readFloat(),E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat(),q=t.readFloat();switch(t.readByte()){case mt:b.setStepped(I);break;case gt:H(t,b,M++,I,0,x,Y,w,P,1),H(t,b,M++,I,1,x,Y,S,E,1),H(t,b,M++,I,2,x,Y,y,X,1),H(t,b,M++,I,3,x,Y,v,V,1),H(t,b,M++,I,4,x,Y,T,N,1),H(t,b,M++,I,5,x,Y,A,q,1)}x=Y,w=P,S=E,y=X,v=V,T=N,A=q}i.push(b)}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=s.constraints[f];for(let g=0,b=t.readInt(!0);g<b;g++){const x=t.readByte(),w=t.readInt(!0),S=t.readInt(!0);switch(x){case wi:tt(t,i,new Je(w,S,f),p.positionMode===0?r:1);break;case yi:tt(t,i,new Qe(w,S,f),p.spacingMode===0||p.spacingMode===1?r:1);break;case vi:{const y=new Ze(w,S,f);let v=t.readFloat(),T=t.readFloat(),A=t.readFloat(),I=t.readFloat();for(let M=0,Y=0,P=y.getFrameCount()-1;y.setFrame(M,v,T,A,I),M!==P;M++){const E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat();switch(t.readByte()){case mt:y.setStepped(M);break;case gt:H(t,y,Y++,M,0,v,E,T,X,1),H(t,y,Y++,M,1,v,E,A,V,1),H(t,y,Y++,M,2,v,E,I,N,1)}v=E,T=X,A=V,I=N}i.push(y)}}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0)-1;for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0);if(b===ki){const S=new as(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat());i.push(S);continue}const w=t.readInt(!0);switch(b){case Si:tt(t,i,new ts(x,w,f),1);break;case Ti:tt(t,i,new es(x,w,f),1);break;case Ai:tt(t,i,new ss(x,w,f),1);break;case Ii:tt(t,i,new ns(x,w,f),1);break;case Ci:tt(t,i,new is(x,w,f),1);break;case Mi:tt(t,i,new rs(x,w,f),1);break;case Yi:tt(t,i,new os(x,w,f),1);break;default:throw new Error("Unknown physics timeline type.")}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0),w=t.readInt(!0);switch(b){case Fi:tt(t,i,new cs(x,w,f),1);break;case Pi:tt(t,i,new ls(x,w,f),1);break;default:throw new Error(`Uknown slider type: ${b}`)}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=s.skins[t.readInt(!0)];for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readInt(!0);for(let x=0,w=t.readInt(!0);x<w;x++){const S=t.readStringRef();if(!S)throw new Error("attachmentName must not be null.");const y=f.getAttachment(b,S),v=t.readByte(),T=t.readInt(!0),A=T-1;switch(v){case bi:{const I=y,M=I.bones,Y=I.vertices,P=M?Y.length/3*2:Y.length,E=t.readInt(!0),X=new He(T,E,b,I);let V=t.readFloat();for(let N=0,q=0;;N++){let O,F=t.readInt(!0);if(F===0)O=M?L.newFloatArray(P):Y;else{O=L.newFloatArray(P);const D=t.readInt(!0);if(F+=D,r===1)for(let U=D;U<F;U++)O[U]=t.readFloat();else for(let U=D;U<F;U++)O[U]=t.readFloat()*r;if(!M)for(let U=0,W=O.length;U<W;U++)O[U]+=Y[U]}if(X.setFrame(N,V,O),N===A)break;const k=t.readFloat();switch(t.readByte()){case mt:X.setStepped(N);break;case gt:H(t,X,q++,N,0,V,k,0,1,1)}V=k}i.push(X);break}case xi:{const I=new Ge(T,b,y);for(let M=0;M<T;M++){const Y=t.readFloat(),P=t.readInt32();I.setFrame(M,Y,Pe[P&15],P>>4,t.readFloat())}i.push(I);break}}}}}const a=s.slots.length,c=t.readInt(!0);if(c>0){const m=new At(c);for(let u=0;u<c;u++)m.setFrame(u,t.readFloat(),gn(t,a));i.push(m)}const l=t.readInt(!0);for(let m=0;m<l;m++){const u=t.readInt(!0),f=new Array(u);for(let b=0;b<u;b++)f[b]=t.readInt(!0);const p=t.readInt(!0),g=new qt(p,f,a);for(let b=0;b<p;b++)g.setFrame(b,t.readFloat(),gn(t,u));i.push(g)}const o=t.readInt(!0);if(o>0){const m=new te(o);for(let u=0;u<o;u++){const f=t.readFloat(),p=s.events[t.readInt(!0)],g=new ae(f,p);g.intValue=t.readInt(!1),g.floatValue=t.readFloat(),g.stringValue=t.readString(),g.stringValue==null&&(g.stringValue=p.setupPose.stringValue),g.data.audioPath&&(g.volume=t.readFloat(),g.balance=t.readFloat()),m.setFrame(u,g)}i.push(m)}let h=0;for(let m=0,u=i.length;m<u;m++)h=Math.max(h,i[m].getDuration());const d=new Qt(e,i,h);return n&&z.rgba8888ToColor(d.color,t.readInt32()),d}},un=class{constructor(t,e=[],s=0,n=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=n}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){const t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){const t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=e&127;return(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<7,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<14,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<21,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<28)))),t?s:s>>>1^-(s&1)}readStringRef(){const t=this.readInt(!0);return t===0?null:this.strings[t-1]}readString(){let t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;let e="";for(let s=0;s<t;){const n=this.readUnsignedByte();switch(n>>4){case 12:case 13:e+=String.fromCharCode((n&31)<<6|this.readByte()&63),s+=2;break;case 14:e+=String.fromCharCode((n&15)<<12|(this.readByte()&63)<<6|this.readByte()&63),s+=3;break;default:e+=String.fromCharCode(n),s++}}return e}readFloat(){const t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return this.readByte()!==0}},Wn=class{source;skinIndex;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(t,e,s,n,i,r){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}},mn=class{constructor(t=null,e,s=0){this.bones=t,this.vertices=e,this.length=s}};function tt(t,e,s,n){s instanceof Ut?Hn(t,e,s,n):Gn(t,e,s,n)}function Hn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n;for(let a=0,c=0,l=s.getFrameCount()-1;s.setFrame(a,i,r),a!==l;a++){const o=t.readFloat(),h=t.readFloat()*n;switch(t.readByte()){case mt:s.setStepped(a);break;case gt:H(t,s,c++,a,0,i,o,r,h,n)}i=o,r=h}e.push(s)}function Gn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n,a=t.readFloat()*n;for(let c=0,l=0,o=s.getFrameCount()-1;s.setFrame(c,i,r,a),c!==o;c++){const h=t.readFloat(),d=t.readFloat()*n,m=t.readFloat()*n;switch(t.readByte()){case mt:s.setStepped(c);break;case gt:H(t,s,l++,c,0,i,h,r,d,n),H(t,s,l++,c,1,i,h,a,m,n)}i=h,r=d,a=m}e.push(s)}function gn(t,e){const s=t.readInt(!0);if(s===0)return null;const n=new Array(e).fill(-1),i=new Array(e-s);let r=0,a=0;for(let c=0;c<s;c++){const l=t.readInt(!0);for(;r!==l;)i[a++]=r++;n[r+t.readInt(!0)]=r++}for(;r<e;)i[a++]=r++;for(let c=e-1;c>=0;c--)n[c]===-1&&(n[c]=i[--a]);return n}function H(t,e,s,n,i,r,a,c,l,o){e.setBezier(s,n,i,r,c,t.readFloat(),t.readFloat()*o,t.readFloat(),t.readFloat()*o,a,l)}var jn=0,Kn=1,Jn=2,Qn=3,Zn=4,ti=5,ei=6,si=7,ni=8,ii=9,ri=10,oi=0,ai=1,ci=2,li=3,hi=4,di=5,fi=0,ui=1,mi=2,gi=3,pi=4,bi=0,xi=1,wi=0,yi=1,vi=2,Si=0,Ti=1,Ai=2,Ii=4,Ci=5,Mi=6,Yi=7,ki=8,Fi=0,Pi=1,mt=1,gt=2,Ei=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new Ot(()=>L.newFloatArray(16));update(t,e){if(!t)throw new Error("skeleton cannot be null.");const s=this.boundingBoxes,n=this.polygons,i=this.polygonPool,r=t.slots,a=r.length;s.length=0,i.freeAll(n),n.length=0;for(let c=0;c<a;c++){const l=r[c];if(!l.bone.active)continue;const o=l.appliedPose.attachment;if(o instanceof ps){s.push(o);let h=i.obtain();h.length!==o.worldVerticesLength&&(h=L.newFloatArray(o.worldVerticesLength)),n.push(h),o.computeWorldVertices(t,l,0,o.worldVerticesLength,h,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;const i=this.polygons;for(let r=0,a=i.length;r<a;r++){const c=i[r],l=c;for(let o=0,h=c.length;o<h;o+=2){const d=l[o],m=l[o+1];t=Math.min(t,d),e=Math.min(e,m),s=Math.max(s,d),n=Math.max(n,m)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,n){const i=this.minX,r=this.minY,a=this.maxX,c=this.maxY;if(t<=i&&s<=i||e<=r&&n<=r||t>=a&&s>=a||e>=c&&n>=c)return!1;const l=(n-e)/(s-t);let o=l*(i-t)+e;if(o>r&&o<c||(o=l*(a-t)+e,o>r&&o<c))return!0;let h=(r-e)/l+t;return h>i&&h<a||(h=(c-e)/l+t,h>i&&h<a)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){const s=this.polygons;for(let n=0,i=s.length;n<i;n++)if(this.containsPointPolygon(s[n],t,e))return this.boundingBoxes[n];return null}containsPointPolygon(t,e,s){const n=t,i=t.length;let r=i-2,a=!1;for(let c=0;c<i;c+=2){const l=n[c+1],o=n[r+1];if(l<s&&o>=s||o<s&&l>=s){const h=n[c];h+(s-l)/(o-l)*(n[r]-h)<e&&(a=!a)}r=c}return a}intersectsSegment(t,e,s,n){const i=this.polygons;for(let r=0,a=i.length;r<a;r++)if(this.intersectsSegmentPolygon(i[r],t,e,s,n))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,n,i){const r=t,a=t.length,c=e-n,l=s-i,o=e*i-s*n;let h=r[a-2],d=r[a-1];for(let m=0;m<a;m+=2){const u=r[m],f=r[m+1],p=h*f-d*u,g=h-u,b=d-f,x=c*b-l*g,w=(o*g-c*p)/x;if((w>=h&&w<=u||w>=u&&w<=h)&&(w>=e&&w<=n||w>=n&&w<=e)){const S=(o*b-l*p)/x;if((S>=d&&S<=f||S>=f&&S<=d)&&(S>=s&&S<=i||S>=i&&S<=s))return!0}h=u,d=f}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");const e=this.boundingBoxes.indexOf(t);return e===-1?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},pn=class at{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new Ot(()=>[]);polygonIndicesPool=new Ot(()=>[]);triangulate(e){const s=e;let n=e.length>>1;const i=this.indicesArray;i.length=0;for(let c=0;c<n;c++)i[c]=c;const r=this.isConcaveArray;r.length=0;for(let c=0;c<n;c++)r[c]=at.isConcave(c,n,s,i);const a=this.triangles;for(a.length=0;n>3;){let c=n-1,l=0,o=1;for(;;){t:if(!r[l]){const m=i[c]<<1,u=i[l]<<1,f=i[o]<<1,p=s[m],g=s[m+1],b=s[u],x=s[u+1],w=s[f],S=s[f+1];for(let y=o+1<n?o+1:0;y!==c;){if(r[y]){const v=i[y]<<1,T=s[v],A=s[v+1];if(at.positiveArea(w,S,p,g,T,A)&&at.positiveArea(p,g,b,x,T,A)&&at.positiveArea(b,x,w,S,T,A))break t}++y===n&&(y=0)}break}if(o===0){do{if(!r[l])break;l--}while(l>0);c=l>0?l-1:n-1,o=l+1<n?l+1:0;break}c=l,l=o,++o===n&&(o=0)}a.push(i[c],i[l],i[o]),i.splice(l,1),r.splice(l,1),n--;const h=l>0?l-1:n-1,d=l<n?l:0;r[h]=at.isConcave(h,n,s,i),r[d]=at.isConcave(d,n,s,i)}return n===3&&a.push(i[2],i[0],i[1]),a}decompose(e,s){const n=e,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;const r=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(r),r.length=0;let a=this.polygonIndicesPool.obtain();a.length=0;let c=this.polygonPool.obtain();c.length=0;let l=-1,o=0;for(let h=0,d=s.length;h<d;h+=3){const m=s[h]<<1,u=s[h+1]<<1,f=s[h+2]<<1,p=n[m],g=n[m+1],b=n[u],x=n[u+1],w=n[f],S=n[f+1];if(l===m){const y=c.length-4;if(at.winding(c[y],c[y+1],c[y+2],c[y+3],w,S)===o&&at.winding(w,S,c[0],c[1],c[2],c[3])===o){c.push(w,S),a.push(f);continue}}c.length>0&&(i.push(c),r.push(a),c=this.polygonPool.obtain(),a=this.polygonIndicesPool.obtain()),c.length=0,c.push(p,g,b,x),c.push(w,S),a.length=0,a.push(m,u,f),o=at.winding(p,g,b,x,w,S),l=m}c.length>0&&(i.push(c),r.push(a));for(let h=0,d=i.length;h<d;h++){if(a=r[h],a.length===0)continue;const m=a[0];let u=a[a.length-1];c=i[h];const f=c.length-4;let p=c[f],g=c[f+1],b=c[f+2],x=c[f+3];const w=c[0],S=c[1],y=c[2],v=c[3],T=at.winding(p,g,b,x,w,S);for(let A=0;A<d;A++){if(A===h)continue;const I=r[A];if(I.length!==3)continue;const M=I[0],Y=I[1],P=I[2],E=i[A],X=E[E.length-2],V=E[E.length-1];M!==m||Y!==u||at.winding(p,g,b,x,X,V)===T&&at.winding(X,V,w,S,y,v)===T&&(E.length=0,I.length=0,c.push(X,V),a.push(P),u=P,p=b,g=x,b=X,x=V,A=-1)}}for(let h=i.length-1;h>=0;h--)c=i[h],c.length===0?(i.splice(h,1),this.polygonPool.free(c),a=r[h],r.splice(h,1),this.polygonIndicesPool.free(a)):c.push(c[0],c[1]);return i}static isConcave(e,s,n,i){const r=i[e>0?e-1:s-1]<<1,a=i[e]<<1,c=i[e+1<s?e+1:0]<<1;return!at.positiveArea(n[r],n[r+1],n[a],n[a+1],n[c],n[c+1])}static positiveArea(e,s,n,i,r,a){return e*(a-i)+n*(s-a)+r*(i-s)>=0}static winding(e,s,n,i,r,a){return e*(a-i)+n*(s-a)+r*(i-s)>=0?1:-1}},bn=class{triangulator=null;clippingPolygon=[];clippingPolygons=[];clipOutput=[];clippedVertices=[];clippedUVs=[];clippedTriangles=[];inverseVertices=[];_clippedVerticesTyped=new Float32Array(1024);_clippedUVsTyped=new Float32Array(1024);_clippedTrianglesTyped=new Uint16Array(1024);clippedVerticesTyped=new Float32Array(0);clippedUVsTyped=new Float32Array(0);clippedTrianglesTyped=new Uint16Array(0);clippedVerticesLength=0;clippedUVsLength=0;clippedTrianglesLength=0;scratch=[];inverse=!1;clipAttachment=null;clipStart(t,e,s){if(this.clipAttachment)return;const n=s.worldVerticesLength;this.clipAttachment=s,this.inverse=s.inverse;const i=L.setArraySize(this.clippingPolygon,n);s.computeWorldVertices(t,e,0,n,i,0,2);const r=this.clippingPolygon,a=this.makeClockwise(r);a||this.inverse||s.convex?(a||this.makeConvex(r),this.clippingPolygon.push(r[0],r[1]),this.clippingPolygons.push(r)):(this.triangulator===null&&(this.triangulator=new pn),this.clippingPolygons.push(...this.triangulator.decompose(r,this.triangulator.triangulate(r))))}clipEnd(t){this.clipAttachment&&(t&&this.clipAttachment.endSlot!==t.data||(this.clipAttachment=null,this.clippingPolygons.length=0))}isClipping(){return this.clipAttachment!=null}clipTriangles(t,e,s,n,i,r,a,c){return n&&i&&r&&typeof a=="boolean"&&typeof c=="number"?this.clipTrianglesRender(t,e,s,n,i,r,a,c):this.clipTrianglesNoRender(t,e,s)}clipTrianglesNoRender(t,e,s){const n=this.clippedVertices;n.length=0;const i=this.clippedTriangles;i.length=0;let r=0;if(this.inverse){const h=this.clippingPolygons[0];for(let d=0;d<s;d+=3){let m=e[d]<<1;const u=t[m],f=t[m+1];m=e[d+1]<<1;const p=t[m],g=t[m+1];m=e[d+2]<<1;const b=t[m],x=t[m+1];this.clipInverse(u,f,p,g,b,x,h);const w=this.inverseVertices;for(let S=0,y=this.inverseVertices.length;S<y;){const v=w[S++];let T=v>>1,A=n.length;const I=L.setArraySize(n,A+v);L.arrayCopy(w,S,I,A,v),A=i.length;const M=L.setArraySize(i,A+3*(T-2));for(let Y=1;Y<T-1;Y++,A+=3)M[A]=r,M[A+1]=r+Y,M[A+2]=r+Y+1;r+=T,S+=v}}return!0}const a=this.clipOutput,c=this.clippingPolygons,l=c.length;let o=null;for(let h=0;h<s;h+=3){let d=e[h]<<1;const m=t[d],u=t[d+1];d=e[h+1]<<1;const f=t[d],p=t[d+1];d=e[h+2]<<1;const g=t[d],b=t[d+1];for(let x=0;x<l;x++){let w=n.length;if(this.clip(m,u,f,p,g,b,c[x])){o=this.clipOutput;const S=a.length;if(S===0)continue;let y=S>>1;const v=L.setArraySize(n,w+S);L.arrayCopy(o,0,v,w,S),w=i.length;const T=L.setArraySize(i,w+3*(y-2));y--;for(let A=1;A<y;A++,w+=3)T[w]=r,T[w+1]=r+A,T[w+2]=r+A+1;r+=y}else{const S=L.setArraySize(n,w+6);S[w]=m,S[w+1]=u,S[w+2]=f,S[w+3]=p,S[w+4]=g,S[w+5]=b,w=i.length;const y=L.setArraySize(i,w+3);y[w]=r,y[w+1]=r+1,y[w+2]=r+2,r+=3;break}}}return o!=null}clipTrianglesRender(t,e,s,n,i,r,a,c){const l=this.clippedVertices;l.length=0;const o=this.clippedTriangles;o.length=0;let h=0;if(this.inverse){const p=this.clippingPolygons[0];for(let g=0;g<s;g+=3){let b=e[g],x=e[g+1],w=e[g+2];const S=t[b*c],y=t[b*c+1],v=t[x*c],T=t[x*c+1],A=t[w*c],I=t[w*c+1];this.clipInverse(S,y,v,T,A,I,p);const M=this.inverseVertices.length;if(M===0)continue;const Y=n[b<<=1],P=n[b+1],E=n[x<<=1],X=n[x+1],V=n[w<<=1],N=n[w+1],q=T-I,O=A-v,F=S-A,k=I-y,D=1/(q*F+O*(y-I)),U=this.inverseVertices;for(let W=0;W<M;){const B=U[W++],_=B>>1;let $=l.length;const J=L.setArraySize(l,$+_*c);for(let Q=0;Q<B;Q+=2,$+=c){const st=U[W+Q],it=U[W+Q+1];J[$]=st,J[$+1]=it,J[$+2]=i.r,J[$+3]=i.g,J[$+4]=i.b,J[$+5]=i.a;const nt=st-A,dt=it-I,rt=(q*nt+O*dt)*D,ot=(k*nt+F*dt)*D,ft=1-rt-ot;J[$+6]=Y*rt+E*ot+V*ft,J[$+7]=P*rt+X*ot+N*ft,a&&(J[$+8]=r.r,J[$+9]=r.g,J[$+10]=r.b,J[$+11]=r.a)}$=o.length;const et=L.setArraySize(o,$+3*(_-2));for(let Q=1;Q<_-1;Q++,$+=3)et[$]=h,et[$+1]=h+Q,et[$+2]=h+Q+1;h+=_,W+=B}}return!0}const d=this.clipOutput,m=this.clippingPolygons,u=this.clippingPolygons.length;let f=null;for(let p=0;p<s;p+=3){let g=e[p];const b=t[g*c],x=t[g*c+1],w=n[g<<1],S=n[(g<<1)+1];g=e[p+1];const y=t[g*c],v=t[g*c+1],T=n[g<<1],A=n[(g<<1)+1];g=e[p+2];const I=t[g*c],M=t[g*c+1],Y=n[g<<1],P=n[(g<<1)+1],E=v-M,X=I-y,V=b-I,N=M-x,q=1/(E*V+X*(x-M));for(let O=0;O<u;O++){let F=l.length;if(this.clip(b,x,y,v,I,M,m[O])){f=this.clipOutput;const k=d.length;if(k===0)continue;let D=k>>1;const U=L.setArraySize(l,F+D*c);for(let B=0;B<k;B+=2,F+=c){const _=f[B],$=f[B+1];U[F]=_,U[F+1]=$,U[F+2]=i.r,U[F+3]=i.g,U[F+4]=i.b,U[F+5]=i.a;const J=_-I,et=$-M,Q=(E*J+X*et)*q,st=(N*J+V*et)*q,it=1-Q-st;U[F+6]=w*Q+T*st+Y*it,U[F+7]=S*Q+A*st+P*it,a&&(U[F+8]=r.r,U[F+9]=r.g,U[F+10]=r.b,U[F+11]=r.a)}F=o.length;const W=L.setArraySize(o,F+3*(D-2));D--;for(let B=1;B<D;B++,F+=3)W[F]=h,W[F+1]=h+B,W[F+2]=h+B+1;h+=D+1}else{const k=L.setArraySize(l,F+3*c);k[F]=b,k[F+1]=x,k[F+2]=i.r,k[F+3]=i.g,k[F+4]=i.b,k[F+5]=i.a,a?(k[F+6]=w,k[F+7]=S,k[F+8]=r.r,k[F+9]=r.g,k[F+10]=r.b,k[F+11]=r.a,k[F+12]=y,k[F+13]=v,k[F+14]=i.r,k[F+15]=i.g,k[F+16]=i.b,k[F+17]=i.a,k[F+18]=T,k[F+19]=A,k[F+20]=r.r,k[F+21]=r.g,k[F+22]=r.b,k[F+23]=r.a,k[F+24]=I,k[F+25]=M,k[F+26]=i.r,k[F+27]=i.g,k[F+28]=i.b,k[F+29]=i.a,k[F+30]=Y,k[F+31]=P,k[F+32]=r.r,k[F+33]=r.g,k[F+34]=r.b,k[F+35]=r.a):(k[F+6]=w,k[F+7]=S,k[F+8]=y,k[F+9]=v,k[F+10]=i.r,k[F+11]=i.g,k[F+12]=i.b,k[F+13]=i.a,k[F+14]=T,k[F+15]=A,k[F+16]=I,k[F+17]=M,k[F+18]=i.r,k[F+19]=i.g,k[F+20]=i.b,k[F+21]=i.a,k[F+22]=Y,k[F+23]=P),F=o.length;const D=L.setArraySize(o,F+3);D[F]=h,D[F+1]=h+1,D[F+2]=h+2,h+=3;break}}}return f!=null}clipTrianglesUnpacked(t,e,s,n,i,r=2){let a=this._clippedVerticesTyped,c=this._clippedUVsTyped,l=this._clippedTrianglesTyped,o=0;if(this.clippedVerticesLength=0,this.clippedUVsLength=0,this.clippedTrianglesLength=0,this.inverse){const f=this.clippingPolygons[0];for(let p=0;p<n;p+=3){let g=s[p]*r;const b=t[e+g],x=t[e+g+1];let w=s[p]<<1;const S=i[w],y=i[w+1];g=s[p+1]*r;const v=t[e+g],T=t[e+g+1];w=s[p+1]<<1;const A=i[w],I=i[w+1];g=s[p+2]*r;const M=t[e+g],Y=t[e+g+1];w=s[p+2]<<1;const P=i[w],E=i[w+1];this.clipInverse(b,x,v,T,M,Y,f);const X=this.inverseVertices.length;if(X===0)continue;const V=T-Y,N=M-v,q=b-M,O=Y-x,F=1/(V*q+N*(x-Y)),k=this.inverseVertices;for(let D=0;D<X;){const U=k[D++],W=U>>1;let B=this.clippedVerticesLength;const _=B+W*r,$=this.clippedUVsLength+W*2;a.length<_&&(this._clippedVerticesTyped=new Float32Array(_*2),this._clippedVerticesTyped.set(a.subarray(0,B)),a=this._clippedVerticesTyped),c.length<$&&(this._clippedUVsTyped=new Float32Array($*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),c=this._clippedUVsTyped),this.clippedVerticesLength=_,this.clippedUVsLength=$;const J=this._clippedVerticesTyped,et=this._clippedUVsTyped;let Q=$-W*2;for(let nt=0;nt<U;nt+=2,B+=r,Q+=2){const dt=k[D+nt],rt=k[D+nt+1];J[B]=dt,J[B+1]=rt;const ot=dt-M,ft=rt-Y,ut=(V*ot+N*ft)*F,pt=(O*ot+q*ft)*F,Lt=1-ut-pt;et[Q]=S*ut+A*pt+P*Lt,et[Q+1]=y*ut+I*pt+E*Lt}B=this.clippedTrianglesLength;const st=B+3*(W-2);l.length<st&&(this._clippedTrianglesTyped=new Uint16Array(st*2),this._clippedTrianglesTyped.set(l.subarray(0,B)),l=this._clippedTrianglesTyped),this.clippedTrianglesLength=st;const it=l;for(let nt=1;nt<W-1;nt++,B+=3)it[B]=o,it[B+1]=o+nt,it[B+2]=o+nt+1;o+=W,D+=U}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),!0}const h=this.clipOutput,d=this.clippingPolygons,m=this.clippingPolygons.length;let u=null;for(let f=0;f<n;f+=3){let p=s[f],g=p*r;const b=t[e+g],x=t[e+g+1];let w=p<<1;const S=i[w],y=i[w+1];p=s[f+1],g=p*r;const v=t[e+g],T=t[e+g+1];w=p<<1;const A=i[w],I=i[w+1];p=s[f+2],g=p*r;const M=t[e+g],Y=t[e+g+1];w=p<<1;const P=i[w],E=i[w+1],X=T-Y,V=M-v,N=b-M,q=Y-x,O=1/(X*N+V*(x-Y));for(let F=0;F<m;F++){let k=this.clippedVerticesLength;if(this.clip(b,x,v,T,M,Y,d[F])){u=h;const D=h.length;if(D===0)continue;let U=D>>1;const W=k+U*r;a.length<W&&(this._clippedVerticesTyped=new Float32Array(W*2),this._clippedVerticesTyped.set(a.subarray(0,k)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+U*2)*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),a=this._clippedVerticesTyped,c=this._clippedUVsTyped);const B=a,_=c;this.clippedVerticesLength=W;let $=this.clippedUVsLength;this.clippedUVsLength=$+U*2;for(let Q=0;Q<D;Q+=2,k+=r,$+=2){const st=u[Q],it=u[Q+1];B[k]=st,B[k+1]=it;const nt=st-M,dt=it-Y,rt=(X*nt+V*dt)*O,ot=(q*nt+N*dt)*O,ft=1-rt-ot;_[$]=S*rt+A*ot+P*ft,_[$+1]=y*rt+I*ot+E*ft}k=this.clippedTrianglesLength;const J=k+3*(U-2);l.length<J&&(this._clippedTrianglesTyped=new Uint16Array(J*2),this._clippedTrianglesTyped.set(l.subarray(0,k)),l=this._clippedTrianglesTyped),this.clippedTrianglesLength=J;const et=l;U--;for(let Q=1;Q<U;Q++,k+=3)et[k]=o,et[k+1]=o+Q,et[k+2]=o+Q+1;o+=U+1}else{let D=k+3*r;a.length<D&&(this._clippedVerticesTyped=new Float32Array(D*2),this._clippedVerticesTyped.set(a.subarray(0,k)),a=this._clippedVerticesTyped),a[k]=b,a[k+1]=x,a[k+r]=v,a[k+r+1]=T,a[k+r*2]=M,a[k+r*2+1]=Y;const U=this.clippedUVsLength+6;c.length<U&&(this._clippedUVsTyped=new Float32Array(U*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),c=this._clippedUVsTyped);const W=this.clippedUVsLength;c[W]=S,c[W+1]=y,c[W+2]=A,c[W+3]=I,c[W+4]=P,c[W+5]=E,this.clippedVerticesLength=D,this.clippedUVsLength=U,k=this.clippedTrianglesLength,D=k+3,l.length<D&&(this._clippedTrianglesTyped=new Uint16Array(D*2),this._clippedTrianglesTyped.set(l.subarray(0,k)),l=this._clippedTrianglesTyped);const B=l;B[k]=o,B[k+1]=o+1,B[k+2]=o+2,o+=3,this.clippedTrianglesLength=D;break}}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),u!==null}clip(t,e,s,n,i,r,a){const c=this.clipOutput;let l=!1,o,h;a.length%4>=2?(o=this.clipOutput,h=this.scratch):(o=this.scratch,h=this.clipOutput);const d=a;o.length=8;const m=o;m[0]=t,m[1]=e,m[2]=s,m[3]=n,m[4]=i,m[5]=r,m[6]=t,m[7]=e,h.length=0;const u=a.length-4;for(let f=0;;f+=2){const p=d[f],g=d[f+1],b=p-d[f+2],x=g-d[f+3],w=h.length,S=o;for(let v=0,T=o.length-2;v<T;){t=S[v],e=S[v+1],v+=2,s=S[v],n=S[v+1];const A=x*(p-s)>b*(g-n),I=x*(p-t)-b*(g-e);if(I>0)if(A)h.push(s,n);else{const M=s-t,Y=n-e,P=I/(M*x-Y*b);P>=0&&P<=1?(h.push(t+M*P,e+Y*P),l=!0):h.push(s,n)}else if(A){const M=s-t,Y=n-e,P=I/(M*x-Y*b);P>=0&&P<=1?(h.push(t+M*P,e+Y*P,s,n),l=!0):h.push(s,n)}else l=!0}if(w===h.length)return c.length=0,!0;if(h.push(h[0],h[1]),f===u)break;const y=h;h=o,h.length=0,o=y}if(c!==h){c.length=0;for(let f=0,p=h.length-2;f<p;f++)c[f]=h[f]}else c.length=c.length-2;return l}clipInverse(t,e,s,n,i,r,a){this.inverseVertices.length=0;const c=a.length-4;let l,o;a.length%4>=2?(l=this.clipOutput,o=this.scratch):(l=this.scratch,o=this.clipOutput),l.length=8;let h=a,d=l;d[0]=t,d[1]=e,d[2]=s,d[3]=n,d[4]=i,d[5]=r,d[6]=t,d[7]=e,o.length=0;for(let m=0;;m+=2){const u=h[m],f=h[m+1],p=u-h[m+2],g=f-h[m+3],b=o.length,x=this.inverseVertices.length;this.inverseVertices.push(0),d=l;for(let y=0,v=l.length-2;y<v;){t=d[y],e=d[y+1],y+=2,s=d[y],n=d[y+1];const T=g*(u-s)>p*(f-n),A=g*(u-t)-p*(f-e);if(A>0)if(T)o.push(s,n);else{const I=s-t,M=n-e,Y=A/(I*g-M*p);if(Y>=0&&Y<=1){const P=t+I*Y,E=e+M*Y;o.push(P,E),this.inverseVertices.push(P,E,s,n)}else o.push(s,n)}else if(T){const I=s-t,M=n-e,Y=A/(I*g-M*p);if(Y>=0&&Y<=1){const P=t+I*Y,E=e+M*Y;this.inverseVertices.push(P,E),o.push(P,E,s,n)}else o.push(s,n)}else this.inverseVertices.push(s,n)}const w=this.inverseVertices.length-x-1;if(w>=6?this.inverseVertices[x]=w:this.inverseVertices.length=x,b===o.length||(o.push(o[0],o[1]),m===c))break;const S=o;o=l,o.length=0,l=S}}makeClockwise(t){const e=t,s=t.length;let n=!0,i=!0,r=0,a=e[s-2],c=e[s-1],l=e[0],o=e[1];for(let d=2;d<s;d+=2){const m=e[d],u=e[d+1];r+=l*u-m*o;const f=(l-a)*(u-o)-(o-c)*(m-l);i=i&&f<=0,n=n&&f>=0,a=l,c=o,l=m,o=u}r+=l*e[1]-e[0]*o;const h=(l-a)*(e[1]-o)-(o-c)*(e[0]-l);if(i=i&&h<=0,n=n&&h>=0,r>=0){for(let d=0,m=s-2,u=s>>1;d<u;d+=2){const f=e[d],p=e[d+1],g=m-d;e[d]=e[g],e[d+1]=e[g+1],e[g]=f,e[g+1]=p}return n}return i}makeConvex(t){const e=t.length,s=t;this.clipOutput.length=e;const n=this.clipOutput;n[0]=s[0],n[1]=s[1];for(let a=2;a<e;a+=2){const c=s[a],l=s[a+1];let o=a-2;for(;o>=0&&(n[o]>c||n[o]===c&&n[o+1]>l);o-=2)n[o+2]=n[o],n[o+3]=n[o+1];n[o+2]=c,n[o+3]=l}s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3];let i=4;for(let a=4;a<e;a+=2,i+=2){const c=n[a],l=n[a+1];for(;(s[i-2]-s[i-4])*(l-s[i-3])-(s[i-1]-s[i-3])*(c-s[i-4])>=0&&(i-=2,i!==2););s[i]=c,s[i+1]=l}s[i]=n[e-4],s[i+1]=n[e-3];const r=i;i+=2;for(let a=e-6;a>=0;a-=2,i+=2){const c=n[a],l=n[a+1];for(;(s[i-2]-s[i-4])*(l-s[i-3])-(s[i-1]-s[i-3])*(c-s[i-4])>=0&&(i-=2,i!==r););s[i]=c,s[i+1]=l}t.length=i-2}},Xi=class{attachmentLoader;scale=1;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Is,n=typeof t=="string"?JSON.parse(t):t,i=n.skeleton;if(i&&(s.hash=i.hash,s.version=i.spine,s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height,s.referenceScale=C(i,"referenceScale",100)*e,s.fps=i.fps,s.imagesPath=i.images??null,s.audioPath=i.audio??null),n.bones)for(let r=0;r<n.bones.length;r++){const a=n.bones[r];let c=null;const l=C(a,"parent",null);l&&(c=s.findBone(l));const o=new bs(s.bones.length,a.name,c);o.length=C(a,"length",0)*e;const h=o.setupPose;h.x=C(a,"x",0)*e,h.y=C(a,"y",0)*e,h.rotation=C(a,"rotation",0),h.scaleX=C(a,"scaleX",1),h.scaleY=C(a,"scaleY",1),h.shearX=C(a,"shearX",0),h.shearY=C(a,"shearY",0),h.inherit=L.enumValue(ne,C(a,"inherit","Normal")),o.skinRequired=C(a,"skin",!1);const d=C(a,"color",null);d&&o.color.setFromString(d),o.icon=C(a,"icon",void 0),o.iconSize=C(a,"iconSize",1),o.iconRotation=C(a,"iconRotation",0),s.bones.push(o)}if(n.slots)for(let r=0;r<n.slots.length;r++){const a=n.slots[r],c=a.name,l=s.findBone(a.bone);if(!l)throw new Error(`Couldn't find bone ${a.bone} for slot ${c}`);const o=new Ms(s.slots.length,c,l),h=C(a,"color",null);h&&o.setupPose.color.setFromString(h);const d=C(a,"dark",null);d&&(o.setupPose.darkColor=z.fromString(d)),o.attachmentName=C(a,"attachment",null),o.blendMode=L.enumValue(Ys,C(a,"blend","normal")),o.visible=C(a,"visible",!0),s.slots.push(o)}if(n.constraints)for(const r of n.constraints){const a=r.name,c=C(r,"skin",!1);switch(C(r,"type",!1)){case"ik":{const l=new Wt(a);l.skinRequired=c;for(let u=0;u<r.bones.length;u++){const f=s.findBone(r.bones[u]);if(!f)throw new Error(`Couldn't find bone ${r.bones[u]} for IK constraint ${a}.`);l.bones.push(f)}const o=r.target,h=s.findBone(o);if(!h)throw new Error(`Couldn't find target bone ${o} for IK constraint ${a}.`);l.target=h;const d=C(r,"scaleY",null);d!=null&&(l.scaleYMode=L.enumValue(oe,d));const m=l.setupPose;m.mix=C(r,"mix",1),m.softness=C(r,"softness",0)*e,m.bendDirection=C(r,"bendPositive",!0)?1:-1,m.compress=C(r,"compress",!1),m.stretch=C(r,"stretch",!1),s.constraints.push(l);break}case"transform":{const l=new K(a);l.skinRequired=c;for(let w=0;w<r.bones.length;w++){const S=r.bones[w],y=s.findBone(S);if(!y)throw new Error(`Couldn't find bone ${S} for transform constraint ${r.name}.`);l.bones.push(y)}const o=r.source,h=s.findBone(o);if(!h)throw new Error(`Couldn't find source bone ${o} for transform constraint ${r.name}.`);l.source=h,l.localSource=C(r,"localSource",!1),l.localTarget=C(r,"localTarget",!1),l.additive=C(r,"additive",!1),l.clamp=C(r,"clamp",!1);let d=!1,m=!1,u=!1,f=!1,p=!1,g=!1;const b=Object.entries(C(r,"properties",{}));for(const[w,S]of b){const y=this.fromProperty(w),v=this.propertyScale(w,e);y.offset=C(S,"offset",0)*v;const T=Object.entries(C(S,"to",{}));for(const[A,I]of T){let M=1,Y;switch(A){case"rotate":{d=!0,Y=new ks;break}case"x":{m=!0,Y=new Fs,M=e;break}case"y":{u=!0,Y=new Ps,M=e;break}case"scaleX":{f=!0,Y=new Es;break}case"scaleY":{p=!0,Y=new Xs;break}case"shearY":{g=!0,Y=new Vs;break}default:throw new Error(`Invalid transform constraint to property: ${A}`)}Y.offset=C(I,"offset",0)*M,Y.max=C(I,"max",1)*M,Y.scale=C(I,"scale",1)*M/v,y.to.push(Y)}y.to.length>0&&l.properties.push(y)}l.offsets[K.ROTATION]=C(r,"rotation",0),l.offsets[K.X]=C(r,"x",0)*e,l.offsets[K.Y]=C(r,"y",0)*e,l.offsets[K.SCALEX]=C(r,"scaleX",0),l.offsets[K.SCALEY]=C(r,"scaleY",0),l.offsets[K.SHEARY]=C(r,"shearY",0);const x=l.setupPose;d&&(x.mixRotate=C(r,"mixRotate",1)),m&&(x.mixX=C(r,"mixX",1)),u&&(x.mixY=C(r,"mixY",x.mixX)),f&&(x.mixScaleX=C(r,"mixScaleX",1)),p&&(x.mixScaleY=C(r,"mixScaleY",x.mixScaleX)),g&&(x.mixShearY=C(r,"mixShearY",1)),s.constraints.push(l);break}case"path":{const l=new Ht(a);l.skinRequired=c;for(let m=0;m<r.bones.length;m++){const u=r.bones[m],f=s.findBone(u);if(!f)throw new Error(`Couldn't find bone ${u} for path constraint ${r.name}.`);l.bones.push(f)}const o=r.slot,h=s.findSlot(o);if(!h)throw new Error(`Couldn't find slot ${o} for path constraint ${r.name}.`);l.slot=h,l.positionMode=L.enumValue(vs,C(r,"positionMode","Percent")),l.spacingMode=L.enumValue(Ss,C(r,"spacingMode","Length")),l.rotateMode=L.enumValue(Ts,C(r,"rotateMode","Tangent")),l.offsetRotation=C(r,"rotation",0);const d=l.setupPose;d.position=C(r,"position",0),l.positionMode===0&&(d.position*=e),d.spacing=C(r,"spacing",0),(l.spacingMode===0||l.spacingMode===1)&&(d.spacing*=e),d.mixRotate=C(r,"mixRotate",1),d.mixX=C(r,"mixX",1),d.mixY=C(r,"mixY",d.mixX),s.constraints.push(l);break}case"physics":{const l=new Gt(a);l.skinRequired=c;const o=r.bone,h=s.findBone(o);if(h==null)throw new Error(`Physics bone not found: ${o}`);l.bone=h,l.x=C(r,"x",0),l.y=C(r,"y",0),l.rotate=C(r,"rotate",0),l.scaleX=C(r,"scaleX",0);const d=C(r,"scaleY",null);d!=null&&(l.scaleYMode=L.enumValue(oe,d)),l.shearX=C(r,"shearX",0),l.limit=C(r,"limit",5e3)*e,l.step=1/C(r,"fps",60);const m=l.setupPose;m.inertia=C(r,"inertia",.5),m.strength=C(r,"strength",100),m.damping=C(r,"damping",.85),m.massInverse=1/C(r,"mass",1),m.wind=C(r,"wind",0),m.gravity=C(r,"gravity",0),m.mix=C(r,"mix",1),l.inertiaGlobal=C(r,"inertiaGlobal",!1),l.strengthGlobal=C(r,"strengthGlobal",!1),l.dampingGlobal=C(r,"dampingGlobal",!1),l.massGlobal=C(r,"massGlobal",!1),l.windGlobal=C(r,"windGlobal",!1),l.gravityGlobal=C(r,"gravityGlobal",!1),l.mixGlobal=C(r,"mixGlobal",!1),s.constraints.push(l);break}case"slider":{const l=new St(a);l.skinRequired=c,l.additive=C(r,"additive",!1),l.loop=C(r,"loop",!1),l.setupPose.mix=C(r,"mix",1);const o=r.bone;if(o){if(l.bone=s.findBone(o),!l.bone)throw new Error(`Slider bone not found: ${o}`);const h=r.property;l.property=this.fromProperty(h);const d=this.propertyScale(h,e);l.property.offset=C(r,"from",0)*d,l.offset=C(r,"to",0),l.scale=C(r,"scale",1)/d,l.max=C(r,"max",0),l.local=C(r,"local",!1)}else l.setupPose.time=C(r,"time",0);s.constraints.push(l);break}}}if(n.skins)for(let r=0;r<n.skins.length;r++){const a=n.skins[r],c=new ue(a.name);if(a.bones)for(let l=0;l<a.bones.length;l++){const o=a.bones[l],h=s.findBone(o);if(!h)throw new Error(`Couldn't find bone ${o} for skin ${a.name}.`);c.bones.push(h)}if(a.ik)for(let l=0;l<a.ik.length;l++){const o=a.ik[l],h=s.findConstraint(o,Wt);if(!h)throw new Error(`Couldn't find IK constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.transform)for(let l=0;l<a.transform.length;l++){const o=a.transform[l],h=s.findConstraint(o,K);if(!h)throw new Error(`Couldn't find transform constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.path)for(let l=0;l<a.path.length;l++){const o=a.path[l],h=s.findConstraint(o,Ht);if(!h)throw new Error(`Couldn't find path constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.physics)for(let l=0;l<a.physics.length;l++){const o=a.physics[l],h=s.findConstraint(o,Gt);if(!h)throw new Error(`Couldn't find physics constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.slider)for(let l=0;l<a.slider.length;l++){const o=a.slider[l],h=s.findConstraint(o,St);if(!h)throw new Error(`Couldn't find slider constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}for(const l in a.attachments){const o=s.findSlot(l);if(!o)throw new Error(`Couldn't find skin slot ${l} for skin ${a.name}.`);const h=a.attachments[l];for(const d in h){const m=this.readAttachment(h[d],c,o.index,d,s);m&&c.setAttachment(o.index,d,m)}}s.skins.push(c),c.name==="default"&&(s.defaultSkin=c)}for(let r=0,a=this.linkedMeshes.length;r<a;r++){const c=this.linkedMeshes[r],l=c.skin?s.findSkin(c.skin):s.defaultSkin;if(!l)throw new Error(`Skin not found: ${c.skin}`);const o=l.getAttachment(c.sourceIndex,c.source);if(!o)throw new Error(`Source mesh not found: ${c.source}`);c.mesh.timelineAttachment=c.inheritTimelines?o:c.mesh,c.mesh.setSourceMesh(o),c.mesh.updateSequence();t:if(c.inheritTimelines&&c.slotIndex!==c.sourceIndex){const h=o.timelineSlots;for(const m of h)if(m===c.slotIndex)break t;const d=[...h];d[h.length]=c.slotIndex,o.timelineSlots=d}}if(this.linkedMeshes.length=0,n.events)for(const r in n.events){const a=n.events[r],c=new ys(r),l=c.setupPose;l.intValue=C(a,"int",0),l.floatValue=C(a,"float",0),l.stringValue=C(a,"string",""),c._audioPath=C(a,"audio",null),c.audioPath&&(l.volume=C(a,"volume",l.volume),l.balance=C(a,"balance",l.balance)),s.events.push(c)}if(n.animations)for(const r in n.animations){const a=n.animations[r];this.readAnimation(a,r,s)}if(n.constraints)for(const r in n.constraints){const a=n.constraints[r];if(a.type==="slider"){const c=s.findConstraint(a.name,St),l=a.animation,o=s.findAnimation(l);if(!o)throw new Error(`Slider animation not found: ${l}`);c.animation=o}}return s}fromProperty(t){let e;switch(t){case"rotate":e=new ge;break;case"x":e=new pe;break;case"y":e=new be;break;case"scaleX":e=new xe;break;case"scaleY":e=new we;break;case"shearY":e=new ye;break;default:throw new Error(`Invalid transform constraint from property: ${t}`)}return e}propertyScale(t,e){switch(t){case"x":case"y":return e;default:return 1}}readAttachment(t,e,s,n,i){const r=this.scale,a=C(t,"name",n);switch(C(t,"type","region")){case"region":{const c=C(t,"path",a),l=this.readSequence(C(t,"sequence",null)),o=this.attachmentLoader.newRegionAttachment(e,n,a,c,l);if(!o)return null;o.path=c,o.x=C(t,"x",0)*r,o.y=C(t,"y",0)*r,o.scaleX=C(t,"scaleX",1),o.scaleY=C(t,"scaleY",1),o.rotation=C(t,"rotation",0),o.width=t.width*r,o.height=t.height*r;const h=C(t,"color",null);return h&&o.color.setFromString(h),o.updateSequence(),o}case"boundingbox":{const c=this.attachmentLoader.newBoundingBoxAttachment(e,n,a);if(!c)return null;this.readVertices(t,c,t.vertexCount<<1);const l=C(t,"color",null);return l&&c.color.setFromString(l),c}case"mesh":case"linkedmesh":{const c=C(t,"path",a),l=this.readSequence(C(t,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(e,n,a,c,l);if(!o)return null;o.path=c;const h=C(t,"color",null);h&&o.color.setFromString(h),o.width=C(t,"width",0)*r,o.height=C(t,"height",0)*r;const d=C(t,"source",null);if(d){let u=s;const f=C(t,"slot",null);if(f){const p=i.findSlot(f);if(!p)throw new Error(`Source mesh slot not found: ${f}`);u=p.index}return this.linkedMeshes.push(new Vi(o,C(t,"skin",null),s,u,d,C(t,"timelines",!0))),o}const m=t.uvs;return this.readVertices(t,o,m.length),o.triangles=t.triangles,o.regionUVs=m,o.edges=C(t,"edges",null),o.hullLength=C(t,"hull",0)*2,o.updateSequence(),o}case"path":{const c=this.attachmentLoader.newPathAttachment(e,n,a);if(!c)return null;c.closed=C(t,"closed",!1),c.constantSpeed=C(t,"constantSpeed",!0);const l=t.vertexCount;this.readVertices(t,c,l<<1);const o=L.newArray(l/3,0);for(let d=0;d<t.lengths.length;d++)o[d]=t.lengths[d]*r;c.lengths=o;const h=C(t,"color",null);return h&&c.color.setFromString(h),c}case"point":{const c=this.attachmentLoader.newPointAttachment(e,n,a);if(!c)return null;c.x=C(t,"x",0)*r,c.y=C(t,"y",0)*r,c.rotation=C(t,"rotation",0);const l=C(t,"color",null);return l&&c.color.setFromString(l),c}case"clipping":{const c=this.attachmentLoader.newClippingAttachment(e,n,a);if(!c)return null;const l=C(t,"end",null);l&&(c.endSlot=i.findSlot(l)),c.convex=C(t,"convex",!1),c.inverse=C(t,"inverse",!1);const o=t.vertexCount;this.readVertices(t,c,o<<1);const h=C(t,"color",null);return h&&c.color.setFromString(h),c}}return null}readSequence(t){if(t==null)return new Nt(1,!1);const e=new Nt(C(t,"count",0),!0);return e.start=C(t,"start",1),e.digits=C(t,"digits",0),e.setupIndex=C(t,"setup",0),e}readVertices(t,e,s){const n=this.scale;e.worldVerticesLength=s;const i=t.vertices;if(s===i.length){const c=L.toFloatArray(i);if(n!==1)for(let l=0,o=i.length;l<o;l++)c[l]*=n;e.vertices=c;return}const r=[],a=[];for(let c=0,l=i.length;c<l;){const o=i[c++];a.push(o);for(let h=c+o*4;c<h;c+=4)a.push(i[c]),r.push(i[c+1]*n),r.push(i[c+2]*n),r.push(i[c+3])}e.bones=a,e.vertices=L.toFloatArray(r)}readAnimation(t,e,s){const n=this.scale,i=[];if(t.slots)for(const l in t.slots){const o=t.slots[l],h=s.findSlot(l);if(!h)throw new Error(`Slot not found: ${l}`);const d=h.index;for(const m in o){const u=o[m];if(!u)continue;const f=u.length;switch(m){case"attachment":{const p=new Ft(f,d);for(let g=0;g<f;g++){const b=u[g];p.setFrame(g,C(b,"time",0),C(b,"name",null))}i.push(p);break}case"rgba":{const p=new $e(f,f<<2,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.color);for(let w=0,S=0;;w++){p.setFrame(w,b,x.r,x.g,x.b,x.a);const y=u[w+1];if(!y){p.shrink(S);break}const v=C(y,"time",0),T=z.fromString(y.color),A=g.curve;A&&(S=G(A,p,S,w,0,b,v,x.r,T.r,1),S=G(A,p,S,w,1,b,v,x.g,T.g,1),S=G(A,p,S,w,2,b,v,x.b,T.b,1),S=G(A,p,S,w,3,b,v,x.a,T.a,1)),b=v,x=T,g=y}i.push(p);break}case"rgb":{const p=new qe(f,f*3,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.color);for(let w=0,S=0;;w++){p.setFrame(w,b,x.r,x.g,x.b);const y=u[w+1];if(!y){p.shrink(S);break}const v=C(y,"time",0),T=z.fromString(y.color),A=g.curve;A&&(S=G(A,p,S,w,0,b,v,x.r,T.r,1),S=G(A,p,S,w,1,b,v,x.g,T.g,1),S=G(A,p,S,w,2,b,v,x.b,T.b,1)),b=v,x=T,g=y}i.push(p);break}case"alpha":{ct(i,u,new _e(f,f,d),0,1);break}case"rgba2":{const p=new ze(f,f*7,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let S=0,y=0;;S++){p.setFrame(S,b,x.r,x.g,x.b,x.a,w.r,w.g,w.b);const v=u[S+1];if(!v){p.shrink(y);break}const T=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=G(M,p,y,S,0,b,T,x.r,A.r,1),y=G(M,p,y,S,1,b,T,x.g,A.g,1),y=G(M,p,y,S,2,b,T,x.b,A.b,1),y=G(M,p,y,S,3,b,T,x.a,A.a,1),y=G(M,p,y,S,4,b,T,w.r,I.r,1),y=G(M,p,y,S,5,b,T,w.g,I.g,1),y=G(M,p,y,S,6,b,T,w.b,I.b,1)),b=T,x=A,w=I,g=v}i.push(p);break}case"rgb2":{const p=new We(f,f*6,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let S=0,y=0;;S++){p.setFrame(S,b,x.r,x.g,x.b,w.r,w.g,w.b);const v=u[S+1];if(!v){p.shrink(y);break}const T=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=G(M,p,y,S,0,b,T,x.r,A.r,1),y=G(M,p,y,S,1,b,T,x.g,A.g,1),y=G(M,p,y,S,2,b,T,x.b,A.b,1),y=G(M,p,y,S,3,b,T,w.r,I.r,1),y=G(M,p,y,S,4,b,T,w.g,I.g,1),y=G(M,p,y,S,5,b,T,w.b,I.b,1)),b=T,x=A,w=I,g=v}i.push(p);break}default:throw new Error(`Invalid timeline type for a slot: ${u.name} (${o.name})`)}}}if(t.bones)for(const l in t.bones){const o=t.bones[l],h=s.findBone(l);if(!h)throw new Error(`Bone not found: ${l}`);const d=h.index;for(const m in o){const u=o[m],f=u.length;if(f!==0)switch(m){case"rotate":ct(i,u,new Dt(f,f,d),0,1);break;case"translate":Rs(i,u,new Ee(f,f<<1,d),"x","y",0,n);break;case"translatex":ct(i,u,new Xe(f,f,d),0,n);break;case"translatey":ct(i,u,new Ve(f,f,d),0,n);break;case"scale":Rs(i,u,new Re(f,f<<1,d),"x","y",1,1);break;case"scalex":ct(i,u,new Le(f,f,d),1,1);break;case"scaley":ct(i,u,new Be(f,f,d),1,1);break;case"shear":Rs(i,u,new Oe(f,f<<1,d),"x","y",0,1);break;case"shearx":ct(i,u,new Ne(f,f,d),0,1);break;case"sheary":ct(i,u,new Ue(f,f,d),0,1);break;case"inherit":{const p=new De(f,h.index);for(let g=0;g<u.length;g++){const b=u[g];p.setFrame(g,C(b,"time",0),L.enumValue(ne,C(b,"inherit","Normal")))}i.push(p);break}default:throw new Error(`Invalid timeline type for a bone: ${u.name} (${o.name})`)}}}if(t.ik)for(const l in t.ik){const o=t.ik[l];let h=o[0];if(!h)continue;const d=s.findConstraint(l,Wt);if(!d)throw new Error(`IK Constraint not found: ${l}`);const m=new je(o.length,o.length<<1,s.constraints.indexOf(d));let u=C(h,"time",0),f=C(h,"mix",1),p=C(h,"softness",0)*n;for(let g=0,b=0;;g++){m.setFrame(g,u,f,p,C(h,"bendPositive",!0)?1:-1,C(h,"compress",!1),C(h,"stretch",!1));const x=o[g+1];if(!x){m.shrink(b);break}const w=C(x,"time",0),S=C(x,"mix",1),y=C(x,"softness",0)*n,v=h.curve;v&&(b=G(v,m,b,g,0,u,w,f,S,1),b=G(v,m,b,g,1,u,w,p,y,n)),u=w,f=S,p=y,h=x}i.push(m)}if(t.transform)for(const l in t.transform){const o=t.transform[l];let h=o[0];if(!h)continue;const d=s.findConstraint(l,K);if(!d)throw new Error(`Transform constraint not found: ${l}`);const m=new Ke(o.length,o.length*6,s.constraints.indexOf(d));let u=C(h,"time",0),f=C(h,"mixRotate",1),p=C(h,"mixX",1),g=C(h,"mixY",p),b=C(h,"mixScaleX",1),x=C(h,"mixScaleY",1),w=C(h,"mixShearY",1);for(let S=0,y=0;;S++){m.setFrame(S,u,f,p,g,b,x,w);const v=o[S+1];if(!v){m.shrink(y);break}const T=C(v,"time",0),A=C(v,"mixRotate",1),I=C(v,"mixX",1),M=C(v,"mixY",I),Y=C(v,"mixScaleX",1),P=C(v,"mixScaleY",1),E=C(v,"mixShearY",1),X=h.curve;X&&(y=G(X,m,y,S,0,u,T,f,A,1),y=G(X,m,y,S,1,u,T,p,I,1),y=G(X,m,y,S,2,u,T,g,M,1),y=G(X,m,y,S,3,u,T,b,Y,1),y=G(X,m,y,S,4,u,T,x,P,1),y=G(X,m,y,S,5,u,T,w,E,1)),u=T,f=A,p=I,g=M,b=Y,x=P,w=E,h=v}i.push(m)}if(t.path)for(const l in t.path){const o=t.path[l],h=s.findConstraint(l,Ht);if(!h)throw new Error(`Path constraint not found: ${l}`);const d=s.constraints.indexOf(h);for(const m in o){const u=o[m];let f=u[0];if(!f)continue;const p=u.length;switch(m){case"position":{const g=new Je(p,p,d);ct(i,u,g,0,h.positionMode===0?n:1);break}case"spacing":{const g=new Qe(p,p,d);ct(i,u,g,0,h.spacingMode===0||h.spacingMode===1?n:1);break}case"mix":{const g=new Ze(p,p*3,d);let b=C(f,"time",0),x=C(f,"mixRotate",1),w=C(f,"mixX",1),S=C(f,"mixY",w);for(let y=0,v=0;;y++){g.setFrame(y,b,x,w,S);const T=u[y+1];if(!T){g.shrink(v);break}const A=C(T,"time",0),I=C(T,"mixRotate",1),M=C(T,"mixX",1),Y=C(T,"mixY",M),P=f.curve;P&&(v=G(P,g,v,y,0,b,A,x,I,1),v=G(P,g,v,y,1,b,A,w,M,1),v=G(P,g,v,y,2,b,A,S,Y,1)),b=A,x=I,w=M,S=Y,f=T}i.push(g);break}}}}if(t.physics)for(const l in t.physics){const o=t.physics[l];let h=-1;if(l.length>0){const d=s.findConstraint(l,Gt);if(!d)throw new Error(`Physics constraint not found: ${l}`);h=s.constraints.indexOf(d)}for(const d in o){const m=o[d];let u=m[0];if(!u)continue;const f=m.length;let p,g=0;if(d==="reset"){const b=new as(f,h);for(let x=0;u!=null;u=m[x+1],x++)b.setFrame(x,C(u,"time",0));i.push(b);continue}switch(d){case"inertia":p=new ts(f,f,h);break;case"strength":p=new es(f,f,h);break;case"damping":p=new ss(f,f,h);break;case"mass":p=new ns(f,f,h);break;case"wind":p=new is(f,f,h);break;case"gravity":p=new rs(f,f,h);break;case"mix":{g=1,p=new os(f,f,h);break}default:continue}ct(i,m,p,g,1)}}if(t.slider)for(const l in t.slider){const o=t.slider[l],h=s.findConstraint(l,St);if(!h)throw new Error(`Slider not found: ${l}`);const d=s.constraints.indexOf(h);for(const m in o){const u=o[m];if(!u[0])continue;const p=u.length;switch(m){case"time":ct(i,u,new cs(p,p,d),1,1);break;case"mix":ct(i,u,new ls(p,p,d),1,1);break}}}if(t.attachments)for(const l in t.attachments){const o=t.attachments[l],h=s.findSkin(l);if(!h)throw new Error(`Skin not found: ${l}`);for(const d in o){const m=o[d],u=s.findSlot(d);if(!u)throw new Error(`Attachment slot not found: ${d}`);const f=u.index;for(const p in m){const g=m[p],b=h.getAttachment(f,p);if(!b)throw new Error(`Timeline attachment not found: ${p}`);for(const x in g){const w=g[x];let S=w[0];if(S){if(x==="deform"){const y=b.bones,v=b.vertices,T=y?v.length/3*2:v.length,A=new He(w.length,w.length,f,b);let I=C(S,"time",0);for(let M=0,Y=0;;M++){let P;const E=C(S,"vertices",null);if(!E)P=y?L.newFloatArray(T):v;else{P=L.newFloatArray(T);const q=C(S,"offset",0);if(L.arrayCopy(E,0,P,q,E.length),n!==1)for(let O=q,F=O+E.length;O<F;O++)P[O]*=n;if(!y)for(let O=0;O<T;O++)P[O]+=v[O]}A.setFrame(M,I,P);const X=w[M+1];if(!X){A.shrink(Y);break}const V=C(X,"time",0),N=S.curve;N&&(Y=G(N,A,Y,M,0,I,V,0,1,1)),I=V,S=X}i.push(A)}else if(x==="sequence"){const y=new Ge(w.length,f,b);let v=0;for(let T=0;T<w.length;T++){const A=C(S,"delay",v),I=C(S,"time",0),M=Fe[C(S,"mode","hold")],Y=C(S,"index",0);y.setFrame(T,I,M,Y,A),v=A,S=w[T+1]}i.push(y)}}}}}}if(t.drawOrder){const l=new At(t.drawOrder.length),o=s.slots.length;let h=0;for(const d of t.drawOrder)l.setFrame(h++,C(d,"time",0),xn(s,d,o,null));i.push(l)}if(t.drawOrderFolder)for(const l of t.drawOrderFolder){const o=C(l,"slots",[]),h=new Array(o.length);let d=0;for(const p of o){const g=s.findSlot(p);if(!g)throw new Error(`Draw order folder slot not found: ${p}`);h[d++]=g.index}const m=C(l,"keys",[]),u=new qt(m.length,h,s.slots.length);let f=0;for(const p of m)u.setFrame(f++,C(p,"time",0),xn(s,p,h.length,h));i.push(u)}if(t.events){const l=new te(t.events.length);let o=0;for(let h=0;h<t.events.length;h++,o++){const d=t.events[h],m=s.findEvent(d.name);if(!m)throw new Error(`Event not found: ${d.name}`);const u=m.setupPose,f=new ae(L.toSinglePrecision(C(d,"time",0)),m);f.intValue=C(d,"int",u.intValue),f.floatValue=C(d,"float",u.floatValue),f.stringValue=C(d,"string",u.stringValue),f.data.audioPath&&(f.volume=C(d,"volume",u.volume),f.balance=C(d,"balance",u.volume)),l.setFrame(o,f)}i.push(l)}let r=0;for(let l=0,o=i.length;l<o;l++)r=Math.max(r,i[l].getDuration());const a=new Qt(e,i,r),c=C(t,"color",null);c!==null&&a.color.setFromString(c),s.animations.push(a)}},Vi=class{source;skin;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(t,e,s,n,i,r){this.mesh=t,this.skin=e,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}};function ct(t,e,s,n,i){let r=e[0],a=r.time??0,c=(r.value??n)*i,l=0;for(let o=0;;o++){s.setFrame(o,a,c);const h=e[o+1];if(!h){s.shrink(l),t.push(s);return}const d=h.time??0,m=(h.value??n)*i;r.curve&&(l=G(r.curve,s,l,o,0,a,d,c,m,i)),a=d,c=m,r=h}}function Rs(t,e,s,n,i,r,a){let c=e[0],l=c.time??0,o=(c[n]??r)*a,h=(c[i]??r)*a,d=0;for(let m=0;;m++){s.setFrame(m,l,o,h);const u=e[m+1];if(!u){s.shrink(d),t.push(s);return}const f=u.time??0,p=(u[n]??r)*a,g=(u[i]??r)*a,b=c.curve;b&&(d=G(b,s,d,m,0,l,f,o,p,a),d=G(b,s,d,m,1,l,f,h,g,a)),l=f,o=p,h=g,c=u}}function xn(t,e,s,n){const i=e.offsets;if(!i)return null;const r=new Array(s).fill(-1),a=new Array(s-i.length);let c=0,l=0;for(const o of i){const h=t.findSlot(o.slot);if(h==null)throw new Error(`Draw order slot not found: ${o.slot}`);let d=0;if(!n)d=h.index;else{d=-1;for(let m=0;m<s;m++)if(n[m]===h.index){d=m;break}if(d===-1)throw new Error(`Slot not in folder: ${o.slot}`)}for(;c!==d;)a[l++]=c++;r[c+o.offset]=c++}for(;c<s;)a[l++]=c++;for(let o=s-1;o>=0;o--)r[o]===-1&&(r[o]=a[--l]);return r}function G(t,e,s,n,i,r,a,c,l,o){if(t==="stepped")return e.setStepped(n),s;const h=i<<2,d=t[h],m=t[h+1]*o,u=t[h+2],f=t[h+3]*o;return e.setBezier(s,n,i,r,c,d,m,u,f,a,l),s+1}function C(t,e,s){return t[e]!==void 0?t[e]:s}var Ri=class{commandPool=new Li;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new bn;renderCommands=[];render(t,e=!1,s,n=2){this.commandPool.reset(),this.renderCommands.length=0;const i=this.clipping,r=t.drawOrder.appliedPose;for(let a=0;a<t.slots.length;a++){const c=r[a],l=c.appliedPose.attachment;if(!l){i.clipEnd(c);continue}const o=c.appliedPose,h=o.color;if((h.a===0||!c.bone.active)&&!(l instanceof zt)){i.clipEnd(c);continue}let m,u,f,p,g,b,x;if(l instanceof j){if(b=l.color,b.a===0){i.clipEnd(c);continue}const T=l.sequence,A=T.resolveIndex(o);l.computeWorldVertices(c,l.getOffsets(o),this.worldVertices,0,n),m=this.worldVertices,u=4,f=T.getUVs(A),p=this.quadIndices,g=6,x=T.regions[A]?.texture}else if(l instanceof wt){if(b=l.color,b.a===0){i.clipEnd(c);continue}this.worldVertices.length<l.worldVerticesLength&&(this.worldVertices=new Float32Array(l.worldVerticesLength)),l.computeWorldVertices(t,c,0,l.worldVerticesLength,this.worldVertices,0,n),m=this.worldVertices,u=l.worldVerticesLength>>1;const T=l.sequence,A=T.resolveIndex(o);f=T.getUVs(A),p=l.triangles,g=p.length,x=T.regions[A]?.texture}else if(l instanceof zt){i.clipStart(t,c,l);continue}else continue;const w=t.color;let S,y;if(e){let T;if(s){T=Math.floor(s[3]*w.a*h.a*b.a*255);const A=Math.floor(T*s[0]*w.r*h.r*b.r),I=Math.floor(T*s[1]*w.g*h.g*b.g),M=Math.floor(T*s[2]*w.b*h.b*b.b);S=T<<24|A<<16|I<<8|M}else{T=Math.floor(w.a*h.a*b.a*255);const A=Math.floor(T*w.r*h.r*b.r),I=Math.floor(T*w.g*h.g*b.g),M=Math.floor(T*w.b*h.b*b.b);S=T<<24|A<<16|I<<8|M}if(y=4278190080,o.darkColor){const{r:A,g:I,b:M}=o.darkColor;y=4278190080|Math.floor(A*T)<<16|Math.floor(I*T)<<8|Math.floor(M*T)}}else{if(s){const T=Math.floor(s[3]*w.a*h.a*b.a*255),A=Math.floor(s[0]*w.r*h.r*b.r*255),I=Math.floor(s[1]*w.g*h.g*b.g*255),M=Math.floor(s[2]*w.b*h.b*b.b*255);S=T<<24|A<<16|I<<8|M}else{const T=Math.floor(w.a*h.a*b.a*255),A=Math.floor(w.r*h.r*b.r*255),I=Math.floor(w.g*h.g*b.g*255),M=Math.floor(w.b*h.b*b.b*255);S=T<<24|A<<16|I<<8|M}if(y=0,o.darkColor){const{r:T,g:A,b:I}=o.darkColor;y=Math.floor(T*255)<<16|Math.floor(A*255)<<8|Math.floor(I*255)}}i.isClipping()&&(i.clipTrianglesUnpacked(m,0,p,g,f,n),m=i.clippedVerticesTyped,u=i.clippedVerticesLength/n,f=i.clippedUVsTyped,p=i.clippedTrianglesTyped,g=i.clippedTrianglesLength);const v=this.commandPool.getCommand(u,g,n);v.blendMode=c.data.blendMode,v.texture=x,v.positions.set(m.subarray(0,u*n)),v.uvs.set(f.subarray(0,u<<1));for(let T=0;T<u;T++)v.colors[T]=S,v.darkColors[T]=y;p instanceof Uint16Array?v.indices.set(p.subarray(0,g)):v.indices.set(p.slice(0,g)),this.renderCommands.push(v),i.clipEnd(c)}return i.clipEnd(),this.batchCommands(n)}batchSubCommands(t,e,s,n,i,r){const a=t[e],c=this.commandPool.getCommand(n,i,r);c.blendMode=a.blendMode,c.texture=a.texture;let l=0,o=0,h=0,d=0,m=0;for(let u=e;u<=s;u++){const f=t[u];c.positions.set(f.positions,l),l+=f.numVertices*r,c.uvs.set(f.uvs,o),o+=f.numVertices<<1,c.colors.set(f.colors,h),c.darkColors.set(f.darkColors,h),h+=f.numVertices;for(let p=0;p<f.numIndices;p++)c.indices[d+p]=f.indices[p]+m;d+=f.numIndices,m+=f.numVertices}return c}batchCommands(t){if(this.renderCommands.length===0)return;let e,s,n=this.renderCommands[0],i=0,r=1,a=n.numVertices,c=n.numIndices;for(;r<=this.renderCommands.length;){const l=r<this.renderCommands.length?this.renderCommands[r]:null;if(l&&l.numVertices===0&&l.numIndices===0){r++;continue}if(l!==null&&l.texture===n.texture&&l.blendMode===n.blendMode&&l.colors[0]===n.colors[0]&&l.darkColors[0]===n.darkColors[0]&&c+l.numIndices<65535)a+=l.numVertices,c+=l.numIndices;else{const h=this.batchSubCommands(this.renderCommands,i,r-1,a,c,t);if(s?(s.next=h,s=h):e=s=h,r===this.renderCommands.length)break;n=this.renderCommands[r],i=r,a=n.numVertices,c=n.numIndices}r++}return e}},Li=class{pool=[];inUse=[];getCommand(t,e,s){let n;for(const i of this.pool)if(i._positions.length>=t*s&&i._indices.length>=e){n=i;break}if(n)this.pool.splice(this.pool.indexOf(n),1),n.next=void 0,n.numVertices=t,n.numIndices=e,n.positions=n._positions.subarray(0,t*s),n.uvs=n._uvs.subarray(0,t<<1),n.colors=n._colors.subarray(0,t),n.darkColors=n._darkColors.subarray(0,t),n.indices=n._indices.subarray(0,e);else{const i=new Float32Array(t*s),r=new Float32Array(t<<1),a=new Uint32Array(t),c=new Uint32Array(t),l=new Uint16Array(e);n={positions:i,uvs:r,colors:a,darkColors:c,indices:l,_positions:i,_uvs:r,_colors:a,_darkColors:c,_indices:l,numVertices:t,numIndices:e,blendMode:0,texture:null}}return this.inUse.push(n),n}reset(){this.pool.push(...this.inUse),this.inUse.length=0}},wn=class extends Ce{constructor(t){super(t)}setFilters(t,e){}setWraps(t,e){}dispose(){}},Bi=class extends en{constructor(t="",e=new gs){super(s=>new wn(s),t,e)}},Oi=L.newFloatArray(8),Ni=class Ae{static QUAD_TRIANGLES=[0,1,2,2,3,0];static VERTEX_SIZE=8;ctx;triangleRendering=!1;debugRendering=!1;vertices=L.newFloatArray(8*1024);tempColor=new z;constructor(e){this.ctx=e}draw(e){this.triangleRendering?this.drawTriangles(e):this.drawImages(e)}drawImages(e){const s=this.ctx,n=this.tempColor,i=e.color,r=e.drawOrder.appliedPose;this.debugRendering&&(s.strokeStyle="green");for(let a=0,c=r.length;a<c;a++){const l=r[a],o=l.bone;if(!o.active)continue;const h=l.appliedPose,d=h.attachment;if(!(d instanceof j))continue;const m=d.sequence,u=m.resolveIndex(h);d.computeWorldVertices(l,d.getOffsets(h),Oi,0,2);const f=m.regions[u],p=f.texture.getImage(),g=h.color,b=d.color;n.set(i.r*g.r*b.r,i.g*g.g*b.g,i.b*g.b*b.b,i.a*g.a*b.a),s.save();const x=o.appliedPose;s.transform(x.a,x.c,x.b,x.d,x.worldX,x.worldY);const w=d.getOffsets(h);s.translate(w[0],w[1]),s.rotate(d.rotation*Math.PI/180);const S=d.width/f.originalWidth;s.scale(S*d.scaleX,S*d.scaleY);let y=f.width,v=f.height;if(s.translate(y/2,v/2),f.degrees===90){const T=y;y=v,v=T,s.rotate(-Math.PI/2)}s.scale(1,-1),s.translate(-y/2,-v/2),s.globalAlpha=n.a,s.drawImage(p,p.width*f.u,p.height*f.v,y,v,0,0,y,v),this.debugRendering&&s.strokeRect(0,0,y,v),s.restore()}}drawTriangles(e){const s=this.ctx,n=this.tempColor,i=e.color,r=e.drawOrder.appliedPose;let a=null,c=this.vertices,l=null;for(let o=0,h=r.length;o<h;o++){const d=r[o],m=d.appliedPose,u=m.attachment;let f;if(u instanceof j){const p=u.sequence,g=p.resolveIndex(m),b=p.getUVs(g),x=u.getOffsets(m);c=this.computeRegionVertices(d,u,x,b,!1),l=Ae.QUAD_TRIANGLES,f=(p.regions[g]?.texture).getImage()}else if(u instanceof wt){const p=u.sequence,g=p.resolveIndex(m),b=p.getUVs(g);c=this.computeMeshVertices(d,u,b,!1),l=u.triangles,f=(p.regions[g]?.texture).getImage()}else continue;if(f){d.data.blendMode!==a&&(a=d.data.blendMode);const p=m.color,g=u.color;n.set(i.r*p.r*g.r,i.g*p.g*g.g,i.b*p.b*g.b,i.a*p.a*g.a),s.globalAlpha=n.a;for(let b=0;b<l.length;b+=3){const x=l[b]*8,w=l[b+1]*8,S=l[b+2]*8,y=c[x],v=c[x+1],T=c[x+6],A=c[x+7],I=c[w],M=c[w+1],Y=c[w+6],P=c[w+7],E=c[S],X=c[S+1],V=c[S+6],N=c[S+7];this.drawTriangle(f,y,v,T,A,I,M,Y,P,E,X,V,N),this.debugRendering&&(s.strokeStyle="green",s.beginPath(),s.moveTo(y,v),s.lineTo(I,M),s.lineTo(E,X),s.lineTo(y,v),s.stroke())}}}this.ctx.globalAlpha=1}drawTriangle(e,s,n,i,r,a,c,l,o,h,d,m,u){const f=this.ctx,p=e.width-1,g=e.height-1;i*=p,r*=g,l*=p,o*=g,m*=p,u*=g,f.beginPath(),f.moveTo(s,n),f.lineTo(a,c),f.lineTo(h,d),f.closePath(),a-=s,c-=n,h-=s,d-=n,l-=i,o-=r,m-=i,u-=r;let b=l*u-m*o;if(b===0)return;b=1/b;const x=(u*a-o*h)*b,w=(u*c-o*d)*b,S=(l*h-m*a)*b,y=(l*d-m*c)*b,v=s-x*i-S*r,T=n-w*i-y*r;f.save(),f.transform(x,w,S,y,v,T),f.clip(),f.drawImage(e,0,0),f.restore()}computeRegionVertices(e,s,n,i,r){const a=e.skeleton.color,c=e.appliedPose.color,l=s.color,o=a.a*c.a*l.a,h=r?o:1,d=this.tempColor;d.set(a.r*c.r*l.r*h,a.g*c.g*l.g*h,a.b*c.b*l.b*h,o),s.computeWorldVertices(e,n,this.vertices,0,Ae.VERTEX_SIZE);const m=this.vertices;return m[j.C1R]=d.r,m[j.C1G]=d.g,m[j.C1B]=d.b,m[j.C1A]=d.a,m[j.U1]=i[0],m[j.V1]=i[1],m[j.C2R]=d.r,m[j.C2G]=d.g,m[j.C2B]=d.b,m[j.C2A]=d.a,m[j.U2]=i[2],m[j.V2]=i[3],m[j.C3R]=d.r,m[j.C3G]=d.g,m[j.C3B]=d.b,m[j.C3A]=d.a,m[j.U3]=i[4],m[j.V3]=i[5],m[j.C4R]=d.r,m[j.C4G]=d.g,m[j.C4B]=d.b,m[j.C4A]=d.a,m[j.U4]=i[6],m[j.V4]=i[7],m}computeMeshVertices(e,s,n,i){const r=e.skeleton,a=r.color,c=e.appliedPose.color,l=s.color,o=a.a*c.a*l.a,h=i?o:1,d=this.tempColor;d.set(a.r*c.r*l.r*h,a.g*c.g*l.g*h,a.b*c.b*l.b*h,o);const m=s.worldVerticesLength/2;let u=this.vertices;u.length<s.worldVerticesLength&&(this.vertices=u=L.newFloatArray(s.worldVerticesLength)),s.computeWorldVertices(r,e,0,s.worldVerticesLength,u,0,Ae.VERTEX_SIZE);for(let f=0,p=0,g=2;f<m;f++)u[g++]=d.r,u[g++]=d.g,u[g++]=d.b,u[g++]=d.a,u[g++]=n[p++],u[g++]=n[p++],g+=2;return u}};export{ms as ATTACH_RETAIN,us as ATTACH_SETUP,_e as AlphaTimeline,Qt as Animation,Dn as AnimationState,$n as AnimationStateAdapter,qn as AnimationStateData,sn as AssetCache,Bi as AssetManager,en as AssetManagerBase,_n as AtlasAttachmentLoader,ke as Attachment,Ft as AttachmentTimeline,un as BinaryInput,Ys as BlendMode,re as Bone,bs as BoneData,ie as BonePose,vt as BoneTimeline1,Zt as BoneTimeline2,ps as BoundingBoxAttachment,hs as CURRENT,wn as CanvasTexture,zt as ClippingAttachment,z as Color,Et as Constraint,Xt as ConstraintData,Pt as ConstraintTimeline1,yt as CurveTimeline,Ut as CurveTimeline1,Ln as DebugUtils,He as DeformTimeline,gs as Downloader,rn as DrawOrder,qt as DrawOrderFolderTimeline,At as DrawOrderTimeline,ae as Event,ys as EventData,Qs as EventQueue,te as EventTimeline,Zs as EventType,ds as FIRST,Nn as FakeTexture,It as FromProperty,ge as FromRotate,xe as FromScaleX,we as FromScaleY,ye as FromShearY,pe as FromX,be as FromY,_t as HOLD,on as IkConstraint,Wt as IkConstraintData,ce as IkConstraintPose,je as IkConstraintTimeline,ne as Inherit,De as InheritTimeline,Vn as IntSet,Bt as Interpolation,fs as MODE,R as MathUtils,wt as MeshAttachment,Ws as MixFrom,ee as PathAttachment,an as PathConstraint,Ht as PathConstraintData,Ze as PathConstraintMixTimeline,le as PathConstraintPose,Je as PathConstraintPositionTimeline,Qe as PathConstraintSpacingTimeline,cn as Physics,As as PhysicsConstraint,ss as PhysicsConstraintDampingTimeline,Gt as PhysicsConstraintData,rs as PhysicsConstraintGravityTimeline,ts as PhysicsConstraintInertiaTimeline,ns as PhysicsConstraintMassTimeline,os as PhysicsConstraintMixTimeline,he as PhysicsConstraintPose,as as PhysicsConstraintResetTimeline,es as PhysicsConstraintStrengthTimeline,bt as PhysicsConstraintTimeline,is as PhysicsConstraintWindTimeline,nn as PointAttachment,Ot as Pool,xs as Posed,ws as PosedActive,se as PosedData,vs as PositionMode,$s as Pow,Rn as PowOut,Hs as Property,We as RGB2Timeline,ze as RGBA2Timeline,$e as RGBATimeline,qe as RGBTimeline,j as RegionAttachment,Ts as RotateMode,Dt as RotateTimeline,tn as SETUP,Re as ScaleTimeline,Le as ScaleXTimeline,oe as ScaleYMode,Be as ScaleYTimeline,Nt as Sequence,Fe as SequenceMode,Pe as SequenceModeValues,Ge as SequenceTimeline,Oe as ShearTimeline,Ne as ShearXTimeline,Ue as ShearYTimeline,hn as Skeleton,zn as SkeletonBinary,Ei as SkeletonBounds,bn as SkeletonClipping,Is as SkeletonData,Xi as SkeletonJson,Ni as SkeletonRenderer,Ri as SkeletonRendererCore,ue as Skin,Cs as SkinEntry,dn as Slider,St as SliderData,ls as SliderMixTimeline,fe as SliderPose,cs as SliderTimeline,ln as Slot,$t as SlotCurveTimeline,Ms as SlotData,de as SlotPose,Ss as SpacingMode,Ds as StringSet,Ce as Texture,Me as TextureAtlas,zs as TextureAtlasPage,Ye as TextureAtlasRegion,Jt as TextureFilter,_s as TextureRegion,qs as TextureWrap,Bn as TimeKeeper,Z as Timeline,Ct as ToProperty,ks as ToRotate,Es as ToScaleX,Xs as ToScaleY,Vs as ToShearY,Fs as ToX,Ps as ToY,Js as TrackEntry,fn as TransformConstraint,K as TransformConstraintData,me as TransformConstraintPose,Ke as TransformConstraintTimeline,Ee as TranslateTimeline,Xe as TranslateXTimeline,Ve as TranslateYTimeline,pn as Triangulator,L as Utils,Ie as Vector2,xt as VertexAttachment,On as WindowedMean,js as isBoneTimeline,Ks as isConstraintTimeline,Gs as isSlotTimeline};
1
+ "use strict";var Vn=class{array=[];add(t){const e=this.contains(t);return this.array[t|0]=t|0,!e}contains(t){return this.array[t|0]!==void 0}remove(t){this.array[t|0]=void 0}clear(){this.array.length=0}},Ds=class{entries={};size=0;add(t){const e=this.entries[t];return this.entries[t]=!0,e?!1:(this.size++,!0)}addAll(t){const e=this.size;for(let s=0,n=t.length;s<n;s++)this.add(t[s]);return e!==this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}},z=class Mt{constructor(e=0,s=0,n=0,i=0){this.r=e,this.g=s,this.b=n,this.a=i}static WHITE=new Mt(1,1,1,1);static RED=new Mt(1,0,0,1);static GREEN=new Mt(0,1,0,1);static BLUE=new Mt(0,0,1,1);static MAGENTA=new Mt(1,0,1,1);set(e,s,n,i){return this.r=e,this.g=s,this.b=n,this.a=i,this.clamp()}setFromColor(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}setFromString(e){return e=e.charAt(0)==="#"?e.substr(1):e,this.r=parseInt(e.substr(0,2),16)/255,this.g=parseInt(e.substr(2,2),16)/255,this.b=parseInt(e.substr(4,2),16)/255,this.a=e.length!==8?1:parseInt(e.substr(6,2),16)/255,this}add(e,s,n,i){return this.r+=e,this.g+=s,this.b+=n,this.a+=i,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(e,s){e.r=((s&4278190080)>>>24)/255,e.g=((s&16711680)>>>16)/255,e.b=((s&65280)>>>8)/255,e.a=(s&255)/255}static rgb888ToColor(e,s){e.r=((s&16711680)>>>16)/255,e.g=((s&65280)>>>8)/255,e.b=(s&255)/255}toRgb888(){const e=s=>`0${(s*255).toString(16)}`.slice(-2);return+`0x${e(this.r)}${e(this.g)}${e(this.b)}`}static fromString(e,s=new Mt){return s.setFromString(e)}},R=class lt{static epsilon=1e-5;static epsilon2=lt.epsilon*lt.epsilon;static PI=3.1415927;static PI2=lt.PI*2;static invPI2=1/lt.PI2;static radiansToDegrees=180/lt.PI;static radDeg=lt.radiansToDegrees;static degreesToRadians=lt.PI/180;static degRad=lt.degreesToRadians;static clamp(e,s,n){return e<s?s:e>n?n:e}static cosDeg(e){return Math.cos(e*lt.degRad)}static sinDeg(e){return Math.sin(e*lt.degRad)}static atan2Deg(e,s){return Math.atan2(e,s)*lt.radDeg}static signum(e){return e>0?1:e<0?-1:0}static toInt(e){return e>0?Math.floor(e):Math.ceil(e)}static cbrt(e){const s=Math.pow(Math.abs(e),.3333333333333333);return e<0?-s:s}static randomTriangular(e,s){return lt.randomTriangularWith(e,s,(e+s)*.5)}static randomTriangularWith(e,s,n){const i=Math.random(),r=s-e;return i<=(n-e)/r?e+Math.sqrt(i*r*(n-e)):s-Math.sqrt((1-i)*r*(s-n))}static isPowerOfTwo(e){return e&&(e&e-1)===0}},Bt=class Vt{static linear=new class extends Vt{applyInternal(e){return e}};static smooth=new class extends Vt{applyInternal(e){return e*e*(3-2*e)}};static slowFast=new class extends Vt{applyInternal(e){return e*e}};static fastSlow=new class extends Vt{applyInternal(e){return(e-1)*(e-1)*-1+1}};static circle=new class extends Vt{applyInternal(e){return e<=.5?(e*=2,(1-Math.sqrt(1-e*e))/2):(e--,e*=2,(Math.sqrt(1-e*e)+1)/2)}};apply(e,s,n){return s===void 0||n===void 0?this.applyInternal(e):e+(s-e)*this.applyInternal(n)}},$s=class extends Bt{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(t*2,this.power)/2:Math.pow((t-1)*2,this.power)/(this.power%2===0?-2:2)+1}},Rn=class extends $s{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2===0?-1:1)+1}},L=class Rt{static SUPPORTS_TYPED_ARRAYS=typeof Float32Array<"u";static arrayCopy(e,s,n,i,r){for(let a=s,c=i;a<s+r;a++,c++)n[c]=e[a]}static arrayFill(e,s,n,i){for(let r=s;r<n;r++)e[r]=i}static setArraySize(e,s,n=0){const i=e.length;if(i===s)return e;if(e.length=s,i<s)for(let r=i;r<s;r++)e[r]=n;return e}static ensureArrayCapacity(e,s,n=0){return e.length>=s?e:Rt.setArraySize(e,s,n)}static newArray(e,s){const n=[];for(let i=0;i<e;i++)n[i]=s;return n}static newFloatArray(e){if(Rt.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static newShortArray(e){if(Rt.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static toFloatArray(e){return Rt.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return Rt.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(e){}static contains(e,s,n=!0){for(let i=0;i<e.length;i++)if(e[i]===s)return!0;return!1}static enumValue(e,s){return e[s[0].toUpperCase()+s.slice(1)]}},Ln=class{static logBones(t){for(let e=0;e<t.bones.length;e++){const s=t.bones[e].appliedPose;console.log(`${s.bone.data.name}, ${s.a}, ${s.b}, ${s.c}, ${s.d}, ${s.worldX}, ${s.worldY}`)}}},Ot=class{items=[];instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset?.(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)this.free(t[e])}clear(){this.items.length=0}},Ie=class{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){const t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){const t=this.length();return t!==0&&(this.x/=t,this.y/=t),this}},Bn=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){const t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},On=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(t=32){this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}},Ce=class{_image;constructor(t){this._image=t}getImage(){return this._image}},Jt=(t=>(t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear",t))(Jt||{}),qs=(t=>(t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat",t))(qs||{}),_s=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},Nn=class extends Ce{setFilters(t,e){}setWraps(t,e){}dispose(){}},Me=class{pages=[];regions=[];constructor(t){const e=new Un(t),s=new Array(4),n={};n.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},n.format=()=>{},n.filter=o=>{o.minFilter=L.enumValue(Jt,s[1]),o.magFilter=L.enumValue(Jt,s[2])},n.repeat=o=>{s[1].indexOf("x")!==-1&&(o.uWrap=10497),s[1].indexOf("y")!==-1&&(o.vWrap=10497)},n.pma=o=>{o.pma=s[1]==="true"};var i={};i.xy=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2])},i.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},i.bounds=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2]),o.width=parseInt(s[3]),o.height=parseInt(s[4])},i.offset=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2])},i.orig=o=>{o.originalWidth=parseInt(s[1]),o.originalHeight=parseInt(s[2])},i.offsets=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2]),o.originalWidth=parseInt(s[3]),o.originalHeight=parseInt(s[4])},i.rotate=o=>{const h=s[1];h==="true"?o.degrees=90:h!=="false"&&(o.degrees=parseInt(h))},i.index=o=>{o.index=parseInt(s[1])};let r=e.readLine();for(;r&&r.trim().length===0;)r=e.readLine();for(;!(!r||r.trim().length===0||e.readEntry(s,r)===0);)r=e.readLine();let a=null,c=null,l=null;for(;r!==null;)if(r.trim().length===0)a=null,r=e.readLine();else if(a){const o=new Ye(a,r);for(;;){const h=e.readEntry(s,r=e.readLine());if(h===0)break;const d=i[s[0]];if(d)d(o);else{c||(c=[]),l||(l=[]),c.push(s[0]);const m=[];for(let u=0;u<h;u++)m.push(parseInt(s[u+1]));l.push(m)}}o.originalWidth===0&&o.originalHeight===0&&(o.originalWidth=o.width,o.originalHeight=o.height),c&&c.length>0&&l&&l.length>0&&(o.names=c,o.values=l,c=null,l=null),o.u=o.x/a.width,o.v=o.y/a.height,o.degrees===90?(o.u2=(o.x+o.height)/a.width,o.v2=(o.y+o.width)/a.height):(o.u2=(o.x+o.width)/a.width,o.v2=(o.y+o.height)/a.height),this.regions.push(o)}else{for(a=new zs(r.trim());e.readEntry(s,r=e.readLine())!==0;){const o=n[s[0]];o&&o(a)}this.pages.push(a)}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name===t)return this.regions[e];return null}setTextures(t,e=""){for(const s of this.pages)s.setTexture(t.get(e+s.name))}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture?.dispose()}},Un=class{lines;index=0;constructor(t){this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e||(e=e.trim(),e.length===0))return 0;const s=e.indexOf(":");if(s===-1)return 0;t[0]=e.substr(0,s).trim();for(let n=1,i=s+1;;n++){const r=e.indexOf(",",i);if(r===-1)return t[n]=e.substr(i).trim(),n;if(t[n]=e.substr(i,r-i).trim(),i=r+1,n===4)return 4}}},zs=class{name;minFilter=9728;magFilter=9728;uWrap=33071;vWrap=33071;texture=null;width=0;height=0;pma=!1;regions=[];constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(const e of this.regions)e.texture=t}},Ye=class extends _s{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}},Fe=class yn{static empty=[];name;timelineAttachment;timelineSlots=yn.empty;constructor(e){if(!e)throw new Error("name cannot be null.");this.name=e,this.timelineAttachment=this}isTimelineActive(e,s,n){let i=e[s];if(i.bone.isActive()){const r=(n?i.getAppliedPose():i.getPose()).getAttachment();if(r!=null&&r.timelineAttachment===this)return!0}for(let r=0,a=this.timelineSlots.length;r<a;r++){if(i=e[this.timelineSlots[r]],!i.bone.isActive())continue;const c=(n?i.getAppliedPose():i.getPose()).getAttachment();if(c!=null&&c.timelineAttachment===this)return!0}return!1}},xt=class vn extends Fe{static nextID=0;id=vn.nextID++;bones=null;vertices=[];worldVerticesLength=0;constructor(e){super(e)}computeWorldVertices(e,s,n,i,r,a,c){i=a+(i>>1)*c;const l=s.appliedPose.deform;let o=this.vertices;const h=this.bones;if(!h){l.length>0&&(o=l);const f=s.bone.appliedPose,p=f.worldX,g=f.worldY,b=f.a,x=f.b,w=f.c,S=f.d;for(let y=n,v=a;v<i;y+=2,v+=c){const T=o[y],A=o[y+1];r[v]=T*b+A*x+p,r[v+1]=T*w+A*S+g}return}let d=0,m=0;for(let f=0;f<n;f+=2){const p=h[d];d+=p+1,m+=p}const u=e.bones;if(l.length===0)for(let f=a,p=m*3;f<i;f+=c){let g=0,b=0,x=h[d++];for(x+=d;d<x;d++,p+=3){const w=u[h[d]].appliedPose,S=o[p],y=o[p+1],v=o[p+2];g+=(S*w.a+y*w.b+w.worldX)*v,b+=(S*w.c+y*w.d+w.worldY)*v}r[f]=g,r[f+1]=b}else{const f=l;for(let p=a,g=m*3,b=m<<1;p<i;p+=c){let x=0,w=0,S=h[d++];for(S+=d;d<S;d++,g+=3,b+=2){const y=u[h[d]].appliedPose,v=o[g]+f[b],T=o[g+1]+f[b+1],A=o[g+2];x+=(v*y.a+T*y.b+y.worldX)*A,w+=(v*y.c+T*y.d+y.worldY)*A}r[p]=x,r[p+1]=w}}}copyTo(e){this.bones?(e.bones=[],L.arrayCopy(this.bones,0,e.bones,0,this.bones.length)):e.bones=null,this.vertices&&(e.vertices=L.newFloatArray(this.vertices.length),L.arrayCopy(this.vertices,0,e.vertices,0,this.vertices.length)),e.worldVerticesLength=this.worldVerticesLength,e.timelineAttachment=this.timelineAttachment,e.timelineSlots=this.timelineSlots}},wt=class Ls extends xt{sequence;regionUVs=[];triangles=[];hullLength=0;path;color=new z(1,1,1,1);sourceMesh=null;edges=[];width=0;height=0;tempColor=new z(0,0,0,0);constructor(e,s){super(e),this.sequence=s}copy(){if(this.sourceMesh)return this.newLinkedMesh();const e=new Ls(this.name,this.sequence.copy());return e.path=this.path,e.color.setFromColor(this.color),this.copyTo(e),e.regionUVs=[],L.arrayCopy(this.regionUVs,0,e.regionUVs,0,this.regionUVs.length),e.triangles=[],L.arrayCopy(this.triangles,0,e.triangles,0,this.triangles.length),e.hullLength=this.hullLength,this.edges&&(e.edges=[],L.arrayCopy(this.edges,0,e.edges,0,this.edges.length)),e.width=this.width,e.height=this.height,e}updateSequence(){this.sequence.update(this)}getSourceMesh(){return this.sourceMesh}setSourceMesh(e){this.sourceMesh=e,e&&(this.bones=e.bones,this.vertices=e.vertices,this.worldVerticesLength=e.worldVerticesLength,this.regionUVs=e.regionUVs,this.triangles=e.triangles,this.hullLength=e.hullLength,this.worldVerticesLength=e.worldVerticesLength,this.edges=e.edges,this.width=e.width,this.height=e.height)}newLinkedMesh(){const e=new Ls(this.name,this.sequence.copy());return e.timelineAttachment=this.timelineAttachment,e.path=this.path,e.color.setFromColor(this.color),e.setSourceMesh(this.sourceMesh?this.sourceMesh:this),e.updateSequence(),e}static computeUVs(e,s,n){if(!e)throw new Error("Region not set.");const i=n.length;let r=e.u,a=e.v,c=0,l=0;if(e instanceof Ye){const o=e.page,h=o.width,d=o.height;switch(e.degrees){case 90:r-=(e.originalHeight-e.offsetY-e.height)/h,a-=(e.originalWidth-e.offsetX-e.width)/d,c=e.originalHeight/h,l=e.originalWidth/d;for(let m=0;m<i;m+=2)n[m]=r+s[m+1]*c,n[m+1]=a+(1-s[m])*l;return;case 180:r-=(e.originalWidth-e.offsetX-e.width)/h,a-=e.offsetY/d,c=e.originalWidth/h,l=e.originalHeight/d;for(let m=0;m<i;m+=2)n[m]=r+(1-s[m])*c,n[m+1]=a+(1-s[m+1])*l;return;case 270:r-=e.offsetY/h,a-=e.offsetX/d,c=e.originalHeight/h,l=e.originalWidth/d;for(let m=0;m<i;m+=2)n[m]=r+(1-s[m+1])*c,n[m+1]=a+s[m]*l;return;default:r-=e.offsetX/h,a-=(e.originalHeight-e.offsetY-e.height)/d,c=e.originalWidth/h,l=e.originalHeight/d}}else e?(c=e.u2-r,l=e.v2-a):(r=a=0,c=l=1);for(let o=0;o<i;o+=2)n[o]=r+s[o]*c,n[o+1]=a+s[o+1]*l}},j=class Sn extends Fe{sequence;x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;path;color=new z(1,1,1,1);tempColor=new z(1,1,1,1);constructor(e,s){super(e),this.sequence=s}copy(){const e=new Sn(this.name,this.sequence.copy());return e.path=this.path,e.x=this.x,e.y=this.y,e.scaleX=this.scaleX,e.scaleY=this.scaleY,e.rotation=this.rotation,e.width=this.width,e.height=this.height,e.color.setFromColor(this.color),e}computeWorldVertices(e,s,n,i,r){const a=e.bone.appliedPose,c=a.worldX,l=a.worldY,o=a.a,h=a.b,d=a.c,m=a.d;let u=s[0],f=s[1];n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[2],f=s[3],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[4],f=s[5],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l,i+=r,u=s[6],f=s[7],n[i]=u*o+f*h+c,n[i+1]=u*d+f*m+l}getOffsets(e){return this.sequence.offsets[this.sequence.resolveIndex(e)]}updateSequence(){this.sequence.update(this)}static computeUVs(e,s,n,i,r,a,c,l,o,h){if(!e)throw new Error("Region not set.");const d=c/e.originalWidth*i,m=l/e.originalHeight*r,u=-c/2*i+e.offsetX*d,f=-l/2*r+e.offsetY*m,p=u+e.width*d,g=f+e.height*m,b=a*R.degRad,x=Math.cos(b),w=Math.sin(b),S=u*x+s,y=u*w,v=f*x+n,T=f*w,A=p*x+s,M=p*w,C=g*x+n,Y=g*w;o[0]=S-T,o[1]=v+y,o[2]=S-Y,o[3]=C+y,o[4]=A-Y,o[5]=C+M,o[6]=A-T,o[7]=v+M,e==null?(h[0]=0,h[1]=0,h[2]=0,h[3]=1,h[4]=1,h[5]=1,h[6]=1,h[7]=0):(h[1]=e.v2,h[2]=e.u,h[5]=e.v,h[6]=e.u2,e.degrees===90?(h[0]=e.u2,h[3]=e.v2,h[4]=e.u,h[7]=e.v):(h[0]=e.u,h[3]=e.v,h[4]=e.u2,h[7]=e.v2))}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31},Nt=class ve{static _nextID=0;id=ve.nextID();regions;pathSuffix;uvs;offsets;start=0;digits=0;setupIndex=0;constructor(e,s){this.regions=new Array(e),this.pathSuffix=s}copy(){const e=this.regions.length,s=new ve(e,this.pathSuffix);if(L.arrayCopy(this.regions,0,s.regions,0,e),s.start=this.start,s.digits=this.digits,s.setupIndex=this.setupIndex,this.uvs!=null){const n=this.uvs[0].length;s.uvs=[];for(let i=0;i<e;i++)s.uvs[i]=L.newFloatArray(n),L.arrayCopy(this.uvs[i],0,s.uvs[i],0,n)}if(this.offsets!=null){s.offsets=[];for(let n=0;n<e;n++)s.offsets[n]=[],L.arrayCopy(this.offsets[n],0,s.offsets[n],0,8)}return s}update(e){const s=this.regions.length;if(e instanceof j){this.uvs=[],this.offsets=[];for(let n=0;n<s;n++)this.uvs[n]=L.newFloatArray(8),this.offsets[n]=[],j.computeUVs(this.regions[n],e.x,e.y,e.scaleX,e.scaleY,e.rotation,e.width,e.height,this.offsets[n],this.uvs[n])}else if(e instanceof wt){const n=e.regionUVs;this.uvs=[],this.offsets=void 0;for(let i=0;i<s;i++)this.uvs[i]=L.newFloatArray(n.length),wt.computeUVs(this.regions[i],n,this.uvs[i])}}resolveIndex(e){let s=e.sequenceIndex;return s===-1&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1),s}getUVs(e){return this.uvs[e]}hasPathSuffix(){return this.pathSuffix}getPath(e,s){if(!this.pathSuffix)return e;let n=e;const i=(this.start+s).toString();for(let r=this.digits-i.length;r>0;r--)n+="0";return n+=i,n}static nextID(){return ve._nextID++}},ke=(t=>(t[t.hold=0]="hold",t[t.once=1]="once",t[t.loop=2]="loop",t[t.pingpong=3]="pingpong",t[t.onceReverse=4]="onceReverse",t[t.loopReverse=5]="loopReverse",t[t.pingpongReverse=6]="pingpongReverse",t))(ke||{}),Pe=[0,1,2,3,4,5,6],Qt=class{name;timelines=[];timelineIds;bones;color=new z(1,1,1,1);duration;constructor(t,e,s){if(!t)throw new Error("name cannot be null.");this.name=t,this.duration=s,this.timelineIds=new Ds,this.bones=[],this.setTimelines(e)}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t;const e=t.length;this.timelineIds.clear(),this.bones.length=0;const s=new Set,n=t;for(let i=0;i<e;i++){const r=n[i];this.timelineIds.addAll(r.propertyIds),js(r)&&s.add(r.boneIndex)&&this.bones.push(r.boneIndex)}}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,n,i,r,a,c,l,o){if(!t)throw new Error("skeleton cannot be null.");n&&this.duration!==0&&(s%=this.duration,e>0&&(e%=this.duration));const h=this.timelines;for(let d=0,m=h.length;d<m;d++)h[d].apply(t,e,s,i,r,a,c,l,o)}},Ws=(t=>(t[t.current=0]="current",t[t.setup=1]="setup",t[t.first=2]="first",t))(Ws||{}),Hs=(t=>(t[t.rotate=0]="rotate",t[t.x=1]="x",t[t.y=2]="y",t[t.scaleX=3]="scaleX",t[t.scaleY=4]="scaleY",t[t.shearX=5]="shearX",t[t.shearY=6]="shearY",t[t.inherit=7]="inherit",t[t.rgb=8]="rgb",t[t.alpha=9]="alpha",t[t.rgb2=10]="rgb2",t[t.attachment=11]="attachment",t[t.deform=12]="deform",t[t.event=13]="event",t[t.drawOrder=14]="drawOrder",t[t.drawOrderFolder=15]="drawOrderFolder",t[t.ikConstraint=16]="ikConstraint",t[t.transformConstraint=17]="transformConstraint",t[t.pathConstraintPosition=18]="pathConstraintPosition",t[t.pathConstraintSpacing=19]="pathConstraintSpacing",t[t.pathConstraintMix=20]="pathConstraintMix",t[t.physicsConstraintInertia=21]="physicsConstraintInertia",t[t.physicsConstraintStrength=22]="physicsConstraintStrength",t[t.physicsConstraintDamping=23]="physicsConstraintDamping",t[t.physicsConstraintMass=24]="physicsConstraintMass",t[t.physicsConstraintWind=25]="physicsConstraintWind",t[t.physicsConstraintGravity=26]="physicsConstraintGravity",t[t.physicsConstraintMix=27]="physicsConstraintMix",t[t.physicsConstraintReset=28]="physicsConstraintReset",t[t.sequence=29]="sequence",t[t.sliderTime=30]="sliderTime",t[t.sliderMix=31]="sliderMix",t))(Hs||{}),Z=class{propertyIds;frames;additive=!1;instant=!1;constructor(t,...e){this.propertyIds=e,this.frames=L.newFloatArray(t*this.getFrameEntries())}getPropertyIds(){return this.propertyIds}getFrameEntries(){return 1}getFrameCount(){return this.frames.length/this.getFrameEntries()}getDuration(){return this.frames[this.frames.length-this.getFrameEntries()]}static search(t,e,s=1){const n=t.length;for(let i=s;i<n;i+=s)if(t[i]>e)return i-s;return n-s}};function Gs(t){return typeof t=="object"&&t!==null&&typeof t.slotIndex=="number"}var yt=class extends Z{curves;constructor(t,e,...s){super(t,...s),this.curves=L.newFloatArray(t+e*18),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){const e=this.getFrameCount()+t*18;if(this.curves.length>e){const s=L.newFloatArray(e);L.arrayCopy(this.curves,0,s,0,e),this.curves=s}}setBezier(t,e,s,n,i,r,a,c,l,o,h){const d=this.curves;let m=this.getFrameCount()+t*18;s===0&&(d[e]=2+m);const u=(n-r*2+c)*.03,f=(i-a*2+l)*.03,p=((r-c)*3-n+o)*.006,g=((a-l)*3-i+h)*.006;let b=u*2+p,x=f*2+g,w=(r-n)*.3+u+p*.16666667,S=(a-i)*.3+f+g*.16666667,y=n+w,v=i+S;for(let T=m+18;m<T;m+=2)d[m]=y,d[m+1]=v,w+=b,S+=x,b+=p,x+=g,y+=w,v+=S}getBezierValue(t,e,s,n){const i=this.curves;if(i[n]>t){const l=this.frames[e],o=this.frames[e+s];return o+(t-l)/(i[n]-l)*(i[n+1]-o)}const r=n+18;for(n+=2;n<r;n+=2)if(i[n]>=t){const l=i[n-2],o=i[n-1];return o+(t-l)/(i[n]-l)*(i[n+1]-o)}e+=this.getFrameEntries();const a=i[r-2],c=i[r-1];return c+(t-a)/(this.frames[e]-a)*(this.frames[e+s]-c)}},Ut=class jt extends yt{constructor(e,s,n){super(e,s,n)}getFrameEntries(){return 2}setFrame(e,s,n){e<<=1,this.frames[e]=s,this.frames[e+1]=n}getCurveValue(e){const s=this.frames;let n=s.length-2;for(let r=2;r<=n;r+=2)if(s[r]>e){n=r-2;break}const i=this.curves[n>>1];switch(i){case 0:{const r=s[n],a=s[n+1];return a+(e-r)/(s[n+2]-r)*(s[n+2+1]-a)}case 1:return s[n+1]}return this.getBezierValue(e,n,1,i-2)}getRelativeValue(e,s,n,i,r,a){if(e<this.frames[0])return jt.beforeFirstKey(n,s,r,a);const c=this.getCurveValue(e);return n===1?a+c*s:r+(i?c:c+a-r)*s}getAbsoluteValue(e,s,n,i,r,a,c){return c===void 0?this.getAbsoluteValue1(e,s,n,i,r,a):this.getAbsoluteValue2(e,s,n,i,r,a,c)}getAbsoluteValue1(e,s,n,i,r,a){if(e<this.frames[0])return jt.beforeFirstKey(n,s,r,a);const c=this.getCurveValue(e);return n===1?a+(i?c:c-a)*s:r+(i?c:c-r)*s}getAbsoluteValue2(e,s,n,i,r,a,c){return e<this.frames[0]?jt.beforeFirstKey(n,s,r,a):n===1?a+(i?c:c-a)*s:r+(i?c:c-r)*s}getScaleValue(e,s,n,i,r,a,c){if(e<this.frames[0])return jt.beforeFirstKey(n,s,a,c);const l=this.getCurveValue(e)*c;if(s===1&&!i)return l;let o=n===1?c:a;return i?o+(l-c)*s:r?o+(Math.abs(l)*Math.sign(o)-o)*s:(o=Math.abs(o)*Math.sign(l),o+(l-o)*s)}static beforeFirstKey(e,s,n,i){switch(e){case 1:return i;case 2:return n+(i-n)*s;case 0:return n}}};function js(t){return typeof t=="object"&&t!==null&&typeof t.boneIndex=="number"}var vt=class extends Ut{boneIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.boneIndex=s,this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];o.active&&this.apply1(l?o.appliedPose:o.pose,o.data.setupPose,s,i,r,a,c)}},Zt=class extends yt{boneIndex;constructor(t,e,s,n,i){super(t,e,`${n}|${s}`,`${i}|${s}`),this.boneIndex=s,this.additive=!0}getFrameEntries(){return 3}setFrame(t,e,s,n){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];o.active&&this.apply1(l?o.appliedPose:o.pose,o.data.setupPose,s,i,r,a,c)}},Dt=class extends vt{constructor(t,e,s){super(t,e,s,0)}apply1(t,e,s,n,i,r,a){t.rotation=this.getRelativeValue(s,n,i,r,t.rotation,e.rotation)}},Ee=class extends Zt{constructor(t,e,s){super(t,e,s,1,2)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.x=e.x,t.y=e.y;break;case 2:t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n;break}return}let l=0,o=0;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i===1?(t.x=e.x+l*n,t.y=e.y+o*n):r?(t.x+=l*n,t.y+=o*n):(t.x+=(e.x+l-t.x)*n,t.y+=(e.y+o-t.y)*n)}},Xe=class extends vt{constructor(t,e,s){super(t,e,s,1)}apply1(t,e,s,n,i,r,a){t.x=this.getRelativeValue(s,n,i,r,t.x,e.x)}},Ve=class extends vt{constructor(t,e,s){super(t,e,s,2)}apply1(t,e,s,n,i,r,a){t.y=this.getRelativeValue(s,n,i,r,t.y,e.y)}},Re=class extends Zt{constructor(t,e,s){super(t,e,s,3,4)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.scaleX=e.scaleX,t.scaleY=e.scaleY;break;case 2:t.scaleX+=(e.scaleX-t.scaleX)*n,t.scaleY+=(e.scaleY-t.scaleY)*n;break}return}let l,o;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}if(l*=e.scaleX,o*=e.scaleY,n===1&&!r)t.scaleX=l,t.scaleY=o;else{let m=0,u=0;i===1?(m=e.scaleX,u=e.scaleY):(m=t.scaleX,u=t.scaleY),r?(t.scaleX=m+(l-e.scaleX)*n,t.scaleY=u+(o-e.scaleY)*n):a?(t.scaleX=m+(Math.abs(l)*Math.sign(m)-m)*n,t.scaleY=u+(Math.abs(o)*Math.sign(u)-u)*n):(m=Math.abs(m)*Math.sign(l),u=Math.abs(u)*Math.sign(o),t.scaleX=m+(l-m)*n,t.scaleY=u+(o-u)*n)}}},Le=class extends vt{constructor(t,e,s){super(t,e,s,3)}apply1(t,e,s,n,i,r,a){t.scaleX=this.getScaleValue(s,n,i,r,a,t.scaleX,e.scaleX)}},Be=class extends vt{constructor(t,e,s){super(t,e,s,4)}apply1(t,e,s,n,i,r,a){t.scaleY=this.getScaleValue(s,n,i,r,a,t.scaleY,e.scaleY)}},Oe=class extends Zt{constructor(t,e,s){super(t,e,s,5,6)}apply1(t,e,s,n,i,r,a){const c=this.frames;if(s<c[0]){switch(i){case 1:t.shearX=e.shearX,t.shearY=e.shearY;break;case 2:t.shearX+=(e.shearX-t.shearX)*n,t.shearY+=(e.shearY-t.shearY)*n;break}return}let l=0,o=0;const h=Z.search(c,s,3),d=this.curves[h/3];switch(d){case 0:{const m=c[h];l=c[h+1],o=c[h+2];const u=(s-m)/(c[h+3]-m);l+=(c[h+3+1]-l)*u,o+=(c[h+3+2]-o)*u;break}case 1:l=c[h+1],o=c[h+2];break;default:l=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i===1?(t.shearX=e.shearX+l*n,t.shearY=e.shearY+o*n):r?(t.shearX+=l*n,t.shearY+=o*n):(t.shearX+=(e.shearX+l-t.shearX)*n,t.shearY+=(e.shearY+o-t.shearY)*n)}},Ne=class extends vt{constructor(t,e,s){super(t,e,s,5)}apply1(t,e,s,n,i,r,a){t.shearX=this.getRelativeValue(s,n,i,r,t.shearX,e.shearX)}},Ue=class extends vt{constructor(t,e,s){super(t,e,s,6)}apply1(t,e,s,n,i,r,a){t.shearY=this.getRelativeValue(s,n,i,r,t.shearY,e.shearY)}},De=class extends Z{boneIndex;constructor(t,e){super(t,`7|${e}`),this.boneIndex=e,this.instant=!0}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(t,e,s,n,i,r,a,c,l){const o=t.bones[this.boneIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose;if(c)r!==0&&(h.inherit=o.data.setupPose.inherit);else{const d=this.frames;s<d[0]?r!==0&&(h.inherit=o.data.setupPose.inherit):h.inherit=this.frames[Z.search(d,s,2)+1]}}},$t=class extends yt{slotIndex;constructor(t,e,s,...n){super(t,e,...n),this.slotIndex=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];o.bone.active&&this.apply1(o,l?o.appliedPose:o.pose,s,i,r,a)}},$e=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`9|${s}`)}getFrameEntries(){return 5}setFrame(t,e,s,n,i,r){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r}apply1(t,e,s,n,i,r){const a=e.color,c=this.frames;if(s<c[0]){const f=t.data.setupPose.color;switch(i){case 1:a.setFromColor(f);break;case 2:a.add((f.r-a.r)*n,(f.g-a.g)*n,(f.b-a.b)*n,(f.a-a.a)*n);break}return}let l=0,o=0,h=0,d=0;const m=Z.search(c,s,5),u=this.curves[m/5];switch(u){case 0:{const f=c[m];l=c[m+1],o=c[m+2],h=c[m+3],d=c[m+4];const p=(s-f)/(c[m+5]-f);l+=(c[m+5+1]-l)*p,o+=(c[m+5+2]-o)*p,h+=(c[m+5+3]-h)*p,d+=(c[m+5+4]-d)*p;break}case 1:l=c[m+1],o=c[m+2],h=c[m+3],d=c[m+4];break;default:l=this.getBezierValue(s,m,1,u-2),o=this.getBezierValue(s,m,2,u+18-2),h=this.getBezierValue(s,m,3,u+36-2),d=this.getBezierValue(s,m,4,u+54-2)}if(n===1)a.set(l,o,h,d);else if(i===1){const f=t.data.setupPose.color;a.set(f.r+(l-f.r)*n,f.g+(o-f.g)*n,f.b+(h-f.b)*n,f.a+(d-f.a)*n)}else a.add((l-a.r)*n,(o-a.g)*n,(h-a.b)*n,(d-a.a)*n)}},qe=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`)}getFrameEntries(){return 4}setFrame(t,e,s,n,i){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i}apply1(t,e,s,n,i,r){const a=e.color;let c=0,l=0,o=0;const h=this.frames;if(s<h[0]){const u=t.data.setupPose.color;switch(i){case 1:{a.r=u.r,a.g=u.g,a.b=u.b;break}case 2:{a.r+=(u.r-a.r)*n,a.g+=(u.g-a.g)*n,a.b+=(u.b-a.b)*n;break}}return}const d=Z.search(h,s,4),m=this.curves[d>>2];switch(m){case 0:{const u=h[d];c=h[d+1],l=h[d+2],o=h[d+3];const f=(s-u)/(h[d+4]-u);c+=(h[d+4+1]-c)*f,l+=(h[d+4+2]-l)*f,o+=(h[d+4+3]-o)*f;break}case 1:c=h[d+1],l=h[d+2],o=h[d+3];break;default:c=this.getBezierValue(s,d,1,m-2),l=this.getBezierValue(s,d,2,m+18-2),o=this.getBezierValue(s,d,3,m+36-2)}if(n!==1)if(i===1){const u=t.data.setupPose.color;c=u.r+(c-u.r)*n,l=u.g+(l-u.g)*n,o=u.b+(o-u.b)*n}else c=a.r+(c-a.r)*n,l=a.g+(l-a.g)*n,o=a.b+(o-a.b)*n;a.r=c<0?0:c>1?1:c,a.g=l<0?0:l>1?1:l,a.b=o<0?0:o>1?1:o}},_e=class extends Ut{slotIndex=0;constructor(t,e,s){super(t,e,`9|${s}`),this.slotIndex=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];if(!o.bone.active)return;const h=(l?o.appliedPose:o.pose).color;let d=0;const m=this.frames;if(s<m[0]){const u=o.data.setupPose.color.a;switch(r){case 1:h.a=u;break;case 2:h.a+=(u-h.a)*i;break}return}if(d=this.getCurveValue(s),i!==1)if(r===1){const u=o.data.setupPose.color;d=u.a+(d-u.a)*i}else d=h.a+(d-h.a)*i;h.a=d<0?0:d>1?1:d}},ze=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`9|${s}`,`10|${s}`)}getFrameEntries(){return 8}setFrame(t,e,s,n,i,r,a,c,l){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=c,this.frames[t+7]=l}apply1(t,e,s,n,i,r){const a=e.color,c=e.darkColor;let l=0,o=0,h=0;const d=this.frames;if(s<d[0]){const x=t.data.setupPose,w=x.color,S=x.darkColor;switch(i){case 1:{a.setFromColor(w),c.r=S.r,c.g=S.g,c.b=S.b;break}case 2:{a.add((w.r-a.r)*n,(w.g-a.g)*n,(w.b-a.b)*n,(w.a-a.a)*n),c.r+=(S.r-c.r)*n,c.g+=(S.g-c.g)*n,c.b+=(S.b-c.b)*n;break}}return}let m=0,u=0,f=0,p=0;const g=Z.search(d,s,8),b=this.curves[g>>3];switch(b){case 0:{const x=d[g];m=d[g+1],u=d[g+2],f=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];const w=(s-x)/(d[g+8]-x);m+=(d[g+8+1]-m)*w,u+=(d[g+8+2]-u)*w,f+=(d[g+8+3]-f)*w,p+=(d[g+8+4]-p)*w,l+=(d[g+8+5]-l)*w,o+=(d[g+8+6]-o)*w,h+=(d[g+8+7]-h)*w;break}case 1:m=d[g+1],u=d[g+2],f=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];break;default:m=this.getBezierValue(s,g,1,b-2),u=this.getBezierValue(s,g,2,b+18-2),f=this.getBezierValue(s,g,3,b+36-2),p=this.getBezierValue(s,g,4,b+54-2),l=this.getBezierValue(s,g,5,b+72-2),o=this.getBezierValue(s,g,6,b+90-2),h=this.getBezierValue(s,g,7,b+108-2)}if(n===1)a.set(m,u,f,p);else if(i===1){const x=t.data.setupPose;let w=x.color;a.set(w.r+(m-w.r)*n,w.g+(u-w.g)*n,w.b+(f-w.b)*n,w.a+(p-w.a)*n),w=x.darkColor,l=w.r+(l-w.r)*n,o=w.g+(o-w.g)*n,h=w.b+(h-w.b)*n}else a.add((m-a.r)*n,(u-a.g)*n,(f-a.b)*n,(p-a.a)*n),l=c.r+(l-c.r)*n,o=c.g+(o-c.g)*n,h=c.b+(h-c.b)*n;c.r=l<0?0:l>1?1:l,c.g=o<0?0:o>1?1:o,c.b=h<0?0:h>1?1:h}},We=class extends $t{constructor(t,e,s){super(t,e,s,`8|${s}`,`10|${s}`)}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,a,c){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=c}apply1(t,e,s,n,i,r){const a=e.color,c=e.darkColor;let l=0,o=0,h=0,d=0,m=0,u=0;const f=this.frames;if(s<f[0]){const b=t.data.setupPose,x=b.color,w=b.darkColor;switch(i){case 1:a.r=x.r,a.g=x.g,a.b=x.b,c.r=w.r,c.g=w.g,c.b=w.b;break;case 2:a.r+=(x.r-a.r)*n,a.g+=(x.g-a.g)*n,a.b+=(x.b-a.b)*n,c.r+=(w.r-c.r)*n,c.g+=(w.g-c.g)*n,c.b+=(w.b-c.b)*n;break}return}const p=Z.search(f,s,7),g=this.curves[p/7];switch(g){case 0:{const b=f[p];l=f[p+1],o=f[p+2],h=f[p+3],d=f[p+4],m=f[p+5],u=f[p+6];const x=(s-b)/(f[p+7]-b);l+=(f[p+7+1]-l)*x,o+=(f[p+7+2]-o)*x,h+=(f[p+7+3]-h)*x,d+=(f[p+7+4]-d)*x,m+=(f[p+7+5]-m)*x,u+=(f[p+7+6]-u)*x;break}case 1:l=f[p+1],o=f[p+2],h=f[p+3],d=f[p+4],m=f[p+5],u=f[p+6];break;default:l=this.getBezierValue(s,p,1,g-2),o=this.getBezierValue(s,p,2,g+18-2),h=this.getBezierValue(s,p,3,g+36-2),d=this.getBezierValue(s,p,4,g+54-2),m=this.getBezierValue(s,p,5,g+72-2),u=this.getBezierValue(s,p,6,g+90-2)}if(n!==1)if(i===1){const b=t.data.setupPose;let x=b.color;l=x.r+(l-x.r)*n,o=x.g+(o-x.g)*n,h=x.b+(h-x.b)*n,x=b.darkColor,d=x.r+(d-x.r)*n,m=x.g+(m-x.g)*n,u=x.b+(u-x.b)*n}else l=a.r+(l-a.r)*n,o=a.g+(o-a.g)*n,h=a.b+(h-a.b)*n,d=c.r+(d-c.r)*n,m=c.g+(m-c.g)*n,u=c.b+(u-c.b)*n;a.r=l<0?0:l>1?1:l,a.g=o<0?0:o>1?1:o,a.b=h<0?0:h>1?1:h,c.r=d<0?0:d>1?1:d,c.g=m<0?0:m>1?1:m,c.b=u<0?0:u>1?1:u}},kt=class extends Z{slotIndex=0;attachmentNames;constructor(t,e){super(t,`11|${e}`),this.slotIndex=e,this.attachmentNames=new Array(t),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,n,i,r,a,c,l){const o=t.slots[this.slotIndex];if(!o.bone.active)return;const h=l?o.appliedPose:o.pose;c||s<this.frames[0]?r!==0&&this.setAttachment(t,h,o.data.attachmentName):this.setAttachment(t,h,this.attachmentNames[Z.search(this.frames,s)])}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}},He=class extends yt{slotIndex;attachment;vertices;constructor(t,e,s,n){super(t,e,`12|${s}|${n.id}`),this.slotIndex=s,this.attachment=n,this.vertices=new Array(t),this.additive=!0}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,n,i,r,a,c,l,o,h){const d=this.curves;let m=this.getFrameCount()+t*18;s===0&&(d[e]=2+m);const u=(n-r*2+c)*.03,f=l*.03-a*.06,p=((r-c)*3-n+o)*.006,g=(a-l+.33333333)*.018;let b=u*2+p,x=f*2+g,w=(r-n)*.3+u+p*.16666667,S=a*.3+f+g*.16666667,y=n+w,v=S;for(let T=m+18;m<T;m+=2)d[m]=y,d[m+1]=v,w+=b,S+=x,b+=p,x+=g,y+=w,v+=S}getCurvePercent(t,e){const s=this.curves;let n=s[e];switch(n){case 0:{const c=this.frames[e];return(t-c)/(this.frames[e+this.getFrameEntries()]-c)}case 1:return 0}if(n-=2,s[n]>t){const c=this.frames[e];return s[n+1]*(t-c)/(s[n]-c)}const i=n+18;for(n+=2;n<i;n+=2)if(s[n]>=t){const c=s[n-2],l=s[n-1];return l+(t-c)/(s[n]-c)*(s[n+1]-l)}const r=s[i-2],a=s[i-1];return a+(1-a)*(t-r)/(this.frames[e+this.getFrameEntries()]-r)}apply(t,e,s,n,i,r,a,c,l){const o=t.slots;if(!this.attachment.isTimelineActive(o,this.slotIndex,l))return;const h=this.attachment.timelineSlots,d=this.frames;if(s<d[0]){this.applyBeforeFirst(o[this.slotIndex],l,i,r);for(const g of h)this.applyBeforeFirst(o[g],l,i,r);return}let m,u,f;if(s>=d[d.length-1])f=0,m=this.vertices[d.length-1],u=null;else{const g=Z.search(d,s);f=this.getCurvePercent(s,g),m=this.vertices[g],u=this.vertices[g+1]}const p=this.vertices[0].length;this.applyToSlot(o[this.slotIndex],l,m,u,f,p,i,r,a);for(const g of h)this.applyToSlot(o[g],l,m,u,f,p,i,r,a)}applyBeforeFirst(t,e,s,n){if(!t.bone.active)return;const i=e?t.appliedPose:t.pose;if(i.attachment==null||i.attachment.timelineAttachment!==this.attachment)return;const r=i.deform;switch(r.length===0&&(n=1),n){case 1:r.length=0;break;case 2:{if(s===1){r.length=0;return}const a=this.vertices[0].length;r.length=a;const c=r,l=i.attachment;if(l.bones===null){const o=l.vertices;for(let h=0;h<a;h++)c[h]+=(o[h]-c[h])*s}else{s=1-s;for(let o=0;o<a;o++)c[o]*=s}}}}applyToSlot(t,e,s,n,i,r,a,c,l){if(!t.bone.active)return;const o=e?t.appliedPose:t.pose;if(o.attachment===null||o.attachment.timelineAttachment!==this.attachment)return;const h=o.attachment,d=o.deform;d.length===0&&(c=1);const m=c===1;if(d.length=r,n===null)if(a===1)if(l&&!m)if(h.bones)for(let u=0;u<r;u++)d[u]+=s[u];else{const u=h.vertices;for(let f=0;f<r;f++)d[f]+=s[f]-u[f]}else L.arrayCopy(s,0,d,0,r);else if(m)if(h.bones)for(let u=0;u<r;u++)d[u]=s[u]*a;else{const u=h.vertices;for(let f=0;f<r;f++){const p=u[f];d[f]=p+(s[f]-p)*a}}else if(l)if(h.bones)for(let u=0;u<r;u++)d[u]+=s[u]*a;else{const u=h.vertices;for(let f=0;f<r;f++)d[f]+=(s[f]-u[f])*a}else for(let u=0;u<r;u++)d[u]+=(s[u]-d[u])*a;else if(a===1)if(l&&!m)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]+=f+(n[u]-f)*i}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f];d[f]+=p+(n[f]-p)*i-u[f]}}else if(i===0)L.arrayCopy(s,0,d,0,r);else for(let u=0;u<r;u++){const f=s[u];d[u]=f+(n[u]-f)*i}else if(m)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]=(f+(n[u]-f)*i)*a}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f],g=u[f];d[f]=g+(p+(n[f]-p)*i-g)*a}}else if(l)if(h.bones)for(let u=0;u<r;u++){const f=s[u];d[u]+=(f+(n[u]-f)*i)*a}else{const u=h.vertices;for(let f=0;f<r;f++){const p=s[f];d[f]+=(p+(n[f]-p)*i-u[f])*a}}else for(let u=0;u<r;u++){const f=s[u];d[u]+=(f+(n[u]-f)*i-d[u])*a}}},Ge=class Tt extends Z{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(e,s,n){super(e,`29|${s}|${n.sequence.id}`),this.slotIndex=s,this.attachment=n,this.instant=!0}getFrameEntries(){return Tt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(e,s,n,i,r){const a=this.frames;e*=Tt.ENTRIES,a[e]=s,a[e+Tt.MODE]=n|i<<4,a[e+Tt.DELAY]=r}apply(e,s,n,i,r,a,c,l,o){const h=e.slots;if(!this.attachment.isTimelineActive(h,this.slotIndex,o))return;const d=this.attachment.timelineSlots,m=this.frames;if(l||n<m[0]){if(a!==0){this.setupPose(h[this.slotIndex],o);for(const b of d)this.setupPose(h[b],o)}return}const u=Z.search(m,n,Tt.ENTRIES),f=m[u],p=m[u+Tt.MODE],g=m[u+Tt.DELAY];this.applyToSlot(h[this.slotIndex],o,n,f,p,g);for(const b of d)this.applyToSlot(h[b],o,n,f,p,g)}setupPose(e,s){if(!e.bone.active)return;const n=s?e.appliedPose:e.pose;n.attachment===null||n.attachment.timelineAttachment!==this.attachment||(n.sequenceIndex=-1)}applyToSlot(e,s,n,i,r,a){if(!e.bone.active)return;const c=s?e.appliedPose:e.pose;if(c.attachment===null||c.attachment.timelineAttachment!==this.attachment)return;let l=r>>4,o=c.attachment.sequence.regions.length;const h=Pe[r&15];if(h!==0)switch(l+=(n-i)/a+1e-5|0,h){case 1:l=Math.min(o-1,l);break;case 2:l%=o;break;case 3:{const d=(o<<1)-2;l=d===0?0:l%d,l>=o&&(l=d-l);break}case 4:l=Math.max(o-1-l,0);break;case 5:l=o-1-l%o;break;case 6:{const d=(o<<1)-2;l=d===0?0:(l+o-1)%d,l>=o&&(l=d-l)}}c.sequenceIndex=l}},te=class Tn extends Z{static propertyIds=["13"];events;constructor(e){super(e,...Tn.propertyIds),this.events=new Array(e),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s){this.frames[e]=s.time,this.events[e]=s}apply(e,s,n,i,r,a,c,l,o){if(!i)return;const h=this.frames,d=this.frames.length;if(s>n)this.apply(null,s,Number.MAX_VALUE,i,0,a,!1,!1,!1),s=-1;else if(s>=h[d-1])return;if(n<h[0])return;let m=0;if(s<h[0])m=0;else{m=Z.search(h,s)+1;const u=h[m];for(;m>0&&h[m-1]===u;)m--}for(;m<d&&n>=h[m];m++)i.push(this.events[m])}},At=class Bs extends Z{static propertyID="14";static propertyIds=[Bs.propertyID];drawOrders;constructor(e){super(e,...Bs.propertyIds),this.drawOrders=new Array(e),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s,n){this.frames[e]=s,this.drawOrders[e]=n}apply(e,s,n,i,r,a,c,l,o){const h=o?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(l||n<this.frames[0]){a!==0&&L.arrayCopy(d,0,h,0,e.slots.length);return}const m=this.drawOrders[Z.search(this.frames,n)];if(!m)L.arrayCopy(d,0,h,0,e.slots.length);else for(let u=0,f=m.length;u<f;u++)h[u]=d[m[u]]}},qt=class Os extends Z{static propertyID="15";slots;inFolder;drawOrders;constructor(e,s,n){super(e,...Os.propertyIds(s)),this.slots=s,this.drawOrders=new Array(e),this.inFolder=new Array(n);for(const i of s)this.inFolder[i]=!0;this.instant=!0}static propertyIds(e){const s=e.length,n=new Array(s);for(let i=0;i<s;i++)n[i]=`${Os.propertyID}|${e[i]}`;return n}getFrameCount(){return this.frames.length}getSlots(){return this.slots}getDrawOrders(){return this.drawOrders}setFrame(e,s,n){this.frames[e]=s,this.drawOrders[e]=n}apply(e,s,n,i,r,a,c,l,o){const h=o?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(l||n<this.frames[0])a!==0&&this.setup(h,d);else{const m=this.drawOrders[Z.search(this.frames,n)];if(!m)this.setup(h,d);else{const u=this.inFolder,f=this.slots;for(let p=0,g=0,b=f.length;!(u[h[p].data.index]&&(h[p]=d[f[m[g]]],++g===b));p++);}}}setup(e,s){const{inFolder:n,slots:i}=this;for(let r=0,a=0,c=i.length;!(n[e[r].data.index]&&(e[r]=s[i[a]],++a===c));r++);}};function Ks(t){return typeof t=="object"&&t!==null&&typeof t.constraintIndex=="number"}var je=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`16|${s}`),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,n,i,r,a){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=n,this.frames[t+3]=i,this.frames[t+4]=r?1:0,this.frames[t+5]=a?1:0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const b=o.data.setupPose;switch(r){case 1:{h.mix=b.mix,h.softness=b.softness,h.bendDirection=b.bendDirection,h.compress=b.compress,h.stretch=b.stretch;break}case 2:{h.mix+=(b.mix-h.mix)*i,h.softness+=(b.softness-h.softness)*i,h.bendDirection=b.bendDirection,h.compress=b.compress,h.stretch=b.stretch;break}}return}let m=0,u=0;const f=Z.search(d,s,6),p=this.curves[f/6];switch(p){case 0:{const b=d[f];m=d[f+1],u=d[f+2];const x=(s-b)/(d[f+6]-b);m+=(d[f+6+1]-m)*x,u+=(d[f+6+2]-u)*x;break}case 1:m=d[f+1],u=d[f+2];break;default:m=this.getBezierValue(s,f,1,p-2),u=this.getBezierValue(s,f,2,p+18-2)}const g=r===1?o.data.setupPose:h;h.mix=g.mix+(m-g.mix)*i,h.softness=g.softness+(u-g.softness)*i,c?r===1&&(h.bendDirection=g.bendDirection,h.compress=g.compress,h.stretch=g.stretch):(h.bendDirection=d[f+3],h.compress=d[f+4]!==0,h.stretch=d[f+5]!==0)}},Ke=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`17|${s}`),this.constraintIndex=s,this.additive=!0}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,a,c){const l=this.frames;t*=7,l[t]=e,l[t+1]=s,l[t+2]=n,l[t+3]=i,l[t+4]=r,l[t+5]=a,l[t+6]=c}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const y=o.data.setupPose;switch(r){case 1:{h.mixRotate=y.mixRotate,h.mixX=y.mixX,h.mixY=y.mixY,h.mixScaleX=y.mixScaleX,h.mixScaleY=y.mixScaleY,h.mixShearY=y.mixShearY;break}case 2:{h.mixRotate+=(y.mixRotate-h.mixRotate)*i,h.mixX+=(y.mixX-h.mixX)*i,h.mixY+=(y.mixY-h.mixY)*i,h.mixScaleX+=(y.mixScaleX-h.mixScaleX)*i,h.mixScaleY+=(y.mixScaleY-h.mixScaleY)*i,h.mixShearY+=(y.mixShearY-h.mixShearY)*i;break}}return}let m,u,f,p,g,b;const x=Z.search(d,s,7),w=this.curves[x/7];switch(w){case 0:{const y=d[x];m=d[x+1],u=d[x+2],f=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];const v=(s-y)/(d[x+7]-y);m+=(d[x+7+1]-m)*v,u+=(d[x+7+2]-u)*v,f+=(d[x+7+3]-f)*v,p+=(d[x+7+4]-p)*v,g+=(d[x+7+5]-g)*v,b+=(d[x+7+6]-b)*v;break}case 1:m=d[x+1],u=d[x+2],f=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];break;default:m=this.getBezierValue(s,x,1,w-2),u=this.getBezierValue(s,x,2,w+18-2),f=this.getBezierValue(s,x,3,w+36-2),p=this.getBezierValue(s,x,4,w+54-2),g=this.getBezierValue(s,x,5,w+72-2),b=this.getBezierValue(s,x,6,w+90-2)}const S=r===1?o.data.setupPose:h;a?(h.mixRotate=S.mixRotate+m*i,h.mixX=S.mixX+u*i,h.mixY=S.mixY+f*i,h.mixScaleX=S.mixScaleX+p*i,h.mixScaleY=S.mixScaleY+g*i,h.mixShearY=S.mixShearY+b*i):(h.mixRotate=S.mixRotate+(m-S.mixRotate)*i,h.mixX=S.mixX+(u-S.mixX)*i,h.mixY=S.mixY+(f-S.mixY)*i,h.mixScaleX=S.mixScaleX+(p-S.mixScaleX)*i,h.mixScaleY=S.mixScaleY+(g-S.mixScaleY)*i,h.mixShearY=S.mixShearY+(b-S.mixShearY)*i)}},Pt=class extends Ut{constraintIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.constraintIndex=s}},Je=class extends Pt{constructor(t,e,s){super(t,e,s,18),this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.position=this.getAbsoluteValue(s,i,r,a,h.position,o.data.setupPose.position)}}},Qe=class extends Pt{constructor(t,e,s){super(t,e,s,19)}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.spacing=this.getAbsoluteValue(s,i,r,!1,h.spacing,o.data.setupPose.spacing)}}},Ze=class extends yt{constraintIndex;constructor(t,e,s){super(t,e,`20|${s}`),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,n,i){const r=this.frames;t<<=2,r[t]=e,r[t+1]=s,r[t+2]=n,r[t+3]=i}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(!o.active)return;const h=l?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){const x=o.data.setupPose;switch(r){case 1:{h.mixRotate=x.mixRotate,h.mixX=x.mixX,h.mixY=x.mixY;break}case 2:{h.mixRotate+=(x.mixRotate-h.mixRotate)*i,h.mixX+=(x.mixX-h.mixX)*i,h.mixY+=(x.mixY-h.mixY)*i;break}}return}let m,u,f;const p=Z.search(d,s,4),g=this.curves[p>>2];switch(g){case 0:{const x=d[p];m=d[p+1],u=d[p+2],f=d[p+3];const w=(s-x)/(d[p+4]-x);m+=(d[p+4+1]-m)*w,u+=(d[p+4+2]-u)*w,f+=(d[p+4+3]-f)*w;break}case 1:m=d[p+1],u=d[p+2],f=d[p+3];break;default:m=this.getBezierValue(s,p,1,g-2),u=this.getBezierValue(s,p,2,g+18-2),f=this.getBezierValue(s,p,3,g+36-2)}const b=r===1?o.data.setupPose:h;a?(h.mixRotate=b.mixRotate+m*i,h.mixX=b.mixX+u*i,h.mixY=b.mixY+f*i):(h.mixRotate=b.mixRotate+(m-b.mixRotate)*i,h.mixX=b.mixX+(u-b.mixX)*i,h.mixY=b.mixY+(f-b.mixY)*i)}},bt=class extends Pt{constructor(t,e,s,n){super(t,e,s,n)}apply(t,e,s,n,i,r,a,c,l){if(a&&!this.additive&&(a=!1),this.constraintIndex===-1){const o=s>=this.frames[0]?this.getCurveValue(s):0,h=t.physics;for(const d of h)if(d.active&&this.global(d.data)){const m=l?d.appliedPose:d.pose;this.set(m,this.getAbsoluteValue(s,i,r,a,this.get(m),this.get(d.data.setupPose),o))}}else{const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;this.set(h,this.getAbsoluteValue(s,i,r,a,this.get(h),this.get(o.data.setupPose)))}}}},ts=class extends bt{constructor(t,e,s){super(t,e,s,21)}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}},es=class extends bt{constructor(t,e,s){super(t,e,s,22)}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}},ss=class extends bt{constructor(t,e,s){super(t,e,s,23)}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}},ns=class extends bt{constructor(t,e,s){super(t,e,s,24)}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}},is=class extends bt{constructor(t,e,s){super(t,e,s,25),this.additive=!0}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}},rs=class extends bt{constructor(t,e,s){super(t,e,s,26),this.additive=!0}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}},os=class extends bt{constructor(t,e,s){super(t,e,s,27)}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}},as=class An extends Z{static propertyIds=["28"];constraintIndex;constructor(e,s){super(e,...An.propertyIds),this.constraintIndex=s,this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,s){this.frames[e]=s}apply(e,s,n,i,r,a,c,l,o){let h;if(this.constraintIndex!==-1&&(h=e.constraints[this.constraintIndex],!h.active))return;const d=this.frames;if(s>n)this.apply(e,s,Number.MAX_VALUE,[],r,a,!1,!1,!1),s=-1;else if(s>=d[d.length-1])return;if(!(n<d[0])&&(s<d[0]||n>=d[Z.search(d,s)+1]))if(h!=null)h.reset(e);else for(const m of e.physics)m.active&&m.reset(e)}},cs=class extends Pt{constructor(t,e,s){super(t,e,s,30)}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.time=this.getAbsoluteValue(s,i,r,a,h.time,o.data.setupPose.time)}}},ls=class extends Pt{constructor(t,e,s){super(t,e,s,31),this.additive=!0}apply(t,e,s,n,i,r,a,c,l){const o=t.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.mix=this.getAbsoluteValue(s,i,r,a,h.mix,o.data.setupPose.mix)}}},Dn=class Ns{static emptyAnimation=new Qt("<empty>",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new Qs(this);propertyIds=new Map;animationsChanged=!1;trackEntryPool=new Ot(()=>new Js);constructor(e){this.data=e}update(e){e*=this.timeScale;const s=this.tracks;for(let n=0,i=s.length;n<i;n++){const r=s[n];if(!r)continue;r.animationLast=r.nextAnimationLast,r.trackLast=r.nextTrackLast;let a=e*r.timeScale;if(r.delay>0){if(r.delay-=a,r.delay>0)continue;a=-r.delay,r.delay=0}let c=r.next;if(c){const l=r.trackLast-c.delay;if(l>=0){for(c.delay=0,c.trackTime+=r.timeScale===0?0:(l/r.timeScale+e)*c.timeScale,r.trackTime+=a,this.setTrack(n,c,!0);c.mixingFrom;)c.mixTime+=e,c=c.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&!r.mixingFrom){s[n]=null,this.queue.end(r),this.clearNext(r);continue}if(r.mixingFrom&&this.updateMixingFrom(r,e)){let l=r.mixingFrom;for(r.mixingFrom=null,l&&(l.mixingTo=null);l;)this.queue.end(l),l=l.mixingFrom}r.trackTime+=a}this.queue.drain()}updateMixingFrom(e,s){const n=e.mixingFrom;if(!n)return!0;const i=this.updateMixingFrom(n,s);if(n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,e.nextTrackLast!==-1&&e.mixTime>=e.mixDuration){if(n.totalAlpha===0||e.mixDuration===0){if(e.mixingFrom=n.mixingFrom,n.mixingFrom!=null&&(n.mixingFrom.mixingTo=e),n.totalAlpha===0)for(let r=e;r.mixingTo!=null;r=r.mixingTo)r.keepHold=!0;this.queue.end(n)}return i}return n.trackTime+=s*n.timeScale,e.mixTime+=s,!1}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();const s=this.events,n=this.tracks;let i=!1;for(let c=0,l=n.length;c<l;c++){const o=n[c];if(!o||o.delay>0)continue;i=!0;let h=o.alpha;o.mixingFrom?h*=this.applyMixingFrom(o,e):o.trackTime>=o.trackEnd&&!o.next&&(h=0);let d=o.animationLast,m=o.getAnimationTime(),u=m,f=s;o.reverse&&(u=o.animation.duration-u,f=null);const p=o.animation.timelines,g=p.length;if(c===0&&h===1)for(let b=0;b<g;b++){L.webkit602BugfixHelper(h);const x=p[b];x instanceof kt?this.applyAttachmentTimeline(x,e,u,1,!0):x.apply(e,d,u,f,h,1,!1,!1,!1)}else{const b=o.timelineMode,x=h>=o.alphaAttachmentThreshold,w=o.additive,S=w||o.shortestRotation,y=!S&&o.timelinesRotation.length!==g<<1;y&&(o.timelinesRotation.length=g<<1);for(let v=0;v<g;v++){const T=p[v],A=b[v]&fs;!S&&T instanceof Dt?this.applyRotateTimeline(T,e,u,h,A,o.timelinesRotation,v<<1,y):T instanceof kt?this.applyAttachmentTimeline(T,e,u,A,x):(L.webkit602BugfixHelper(h),T.apply(e,d,u,f,h,A,w,!1,!1))}}o.reverse&&this.eventsReverse(o,d,m),this.queueEvents(o,m),s.length=0,o.nextAnimationLast=m,o.nextTrackLast=o.trackTime}const r=this.unkeyedState+us,a=e.slots;for(let c=0,l=e.slots.length;c<l;c++){const o=a[c];if(o.attachmentState===r){const h=o.data.attachmentName;o.pose.setAttachment(h?e.getAttachment(o.data.index,h):null)}}return this.unkeyedState+=2,this.queue.drain(),i}applyMixingFrom(e,s){const n=e.mixingFrom,i=n.mixingFrom!==null?this.applyMixingFrom(n,s):1,r=e.mix(),a=n.alpha*i,c=1-r*e.alpha,l=a*(1-r),o=c>0?l/c:a,h=n.animation.timelines,d=h.length,m=n.timelineMode,u=n.timelineHoldMix,f=r<n.mixAttachmentThreshold,p=r<n.mixDrawOrderThreshold,g=n.additive,b=g||n.shortestRotation,x=!b&&n.timelinesRotation.length!==d<<1;x&&(n.timelinesRotation.length=d<<1);const w=n.timelinesRotation;let S=n.animationLast,y=n.getAnimationTime(),v=y,T=null;n.reverse?v=n.animation.duration-v:r<n.eventThreshold&&(T=this.events),n.totalAlpha=0;for(let A=0;A<d;A++){const M=h[A],C=m[A],Y=C&fs;let P=0;if((C&_t)!==0){const E=u[A];P=E==null?o:o*(1-E.mix())}else{if(!p&&M instanceof At&&Y===0)continue;P=l}if(n.totalAlpha+=P,!b&&M instanceof Dt)this.applyRotateTimeline(M,s,v,P,Y,w,A<<1,x);else if(M instanceof kt)this.applyAttachmentTimeline(M,s,v,Y,f&&P>=n.alphaAttachmentThreshold);else{const E=!p||!(M instanceof At)||Y===0;M.apply(s,S,v,T,P,Y,g,E,!1)}}return n.reverse&&r<n.eventThreshold&&this.eventsReverse(n,S,y),e.mixDuration>0&&this.queueEvents(n,y),this.events.length=0,n.nextAnimationLast=y,n.nextTrackLast=n.trackTime,r}applyAttachmentTimeline(e,s,n,i,r){const a=s.slots[e.slotIndex];if(!a.bone.active||!r&&a.attachmentState===this.unkeyedState+ms)return;let c=n<e.frames[0],l=null;if(c||(l=e.attachmentNames[Z.search(e.frames,n)],c=!r&&l==null),c){if(i===0)return;l=a.data.attachmentName}a.pose.setAttachment(l==null?null:s.getAttachment(a.data.index,l)),r?a.attachmentState=this.unkeyedState+ms:c||(a.attachmentState=this.unkeyedState+us)}applyRotateTimeline(e,s,n,i,r,a,c,l){if(l&&(a[c]=0),i===1){e.apply(s,0,n,null,1,r,!1,!1,!1);return}const o=s.bones[e.boneIndex];if(!o.active)return;const h=o.pose,d=o.data.setupPose,m=e.frames;let u,f;if(n<m[0]){switch(r){case 1:{h.rotation=d.rotation;return}case 0:return}u=h.rotation,f=d.rotation}else u=r===1?d.rotation:h.rotation,f=d.rotation+e.getCurveValue(n);let p=0,g=f-u;if(g-=Math.ceil(g/360-.5)*360,g===0)p=a[c];else{let b=0,x=0;l?(b=0,x=g):(b=a[c],x=a[c+1]);const w=b-b%360;p=g+w;let S=g>=0,y=b>=0;Math.abs(x)<=90&&R.signum(x)!==R.signum(g)&&(Math.abs(b-w)>180?(p+=360*R.signum(b),y=S):w!==0?p-=360*R.signum(b):y=S),y!==S&&(p+=360*R.signum(b)),a[c]=p}a[c+1]=g,h.rotation=u+p*i}queueEvents(e,s){const n=e.animationStart,i=e.animationEnd,r=i-n,a=e.reverse;let c=e.trackLast%r;a&&(c=r-c);const l=this.events;let o=0,h=l.length;for(;o<h;o++){const m=l[o];if(m.time<c!==a)break;m.time>=n&&m.time<=i&&this.queue.event(e,m)}let d=!1;if(e.loop)if(r===0)d=!0;else{const m=Math.floor(e.trackTime/r);d=m>0&&m>Math.floor(e.trackLast/r)}else d=s>=i&&e.animationLast<i;for(d&&this.queue.complete(e);o<h;o++){const m=l[o];m.time>=n&&m.time<=i&&this.queue.event(e,m)}}eventsReverse(e,s,n){const i=e.animation.duration,r=i-s,a=i-n,c=e.animation.timelines;for(let l=0,o=e.animation.timelines.length;l<o;l++){const h=c[l];if(!(h instanceof te))continue;const d=h.events,m=h.frames,u=m.length;if(r>=a){for(let f=0;f<u;f++)if(!(m[f]<a)){if(m[f]>=r)break;this.events.push(d[f])}}else{for(let p=0;p<u&&!(m[p]>=r);p++)this.events.push(d[p]);let f=0;for(;f<u&&!(m[f]>=a);f++);for(;f<u;f++)this.events.push(d[f])}}}clearTracks(){const e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let s=0,n=this.tracks.length;s<n;s++)this.clearTrack(s);this.tracks.length=0,this.queue.drainDisabled=e,this.queue.drain()}clearTrack(e){if(e<0)throw new Error("trackIndex must be >= 0.");if(e>=this.tracks.length)return;const s=this.tracks[e];if(!s)return;this.queue.end(s),this.clearNext(s);let n=s;for(;;){const i=n.mixingFrom;if(!i)break;this.queue.end(i),n.mixingFrom=null,n.mixingTo=null,n=i}this.tracks[s.trackIndex]=null,this.queue.drain()}setTrack(e,s,n){const i=this.expandToIndex(e);this.tracks[e]=s,s.previous=null,i&&(i.next=null,n&&this.queue.interrupt(i),s.mixingFrom=i,i.mixingTo=s,s.mixTime=0,i.timelinesRotation.length=0),this.queue.start(s)}setAnimation(e,s,n=!1){return typeof s=="string"?this.setAnimation1(e,s,n):this.setAnimation2(e,s,n)}setAnimation1(e,s,n=!1){const i=this.data.skeletonData.findAnimation(s);if(!i)throw new Error(`Animation not found: ${s}`);return this.setAnimation2(e,i,n)}setAnimation2(e,s,n=!1){if(e<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let i=!0,r=this.expandToIndex(e);r&&(r.nextTrackLast===-1&&r.animation===s?(this.tracks[e]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.clearNext(r),r=r.mixingFrom,i=!1):this.clearNext(r));const a=this.trackEntry(e,s,n,r);return this.setTrack(e,a,i),this.queue.drain(),a}addAnimation(e,s,n=!1,i=0){return typeof s=="string"?this.addAnimation1(e,s,n,i):this.addAnimation2(e,s,n,i)}addAnimation1(e,s,n=!1,i=0){const r=this.data.skeletonData.findAnimation(s);if(!r)throw new Error(`Animation not found: ${s}`);return this.addAnimation2(e,r,n,i)}addAnimation2(e,s,n=!1,i=0){if(e<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let r=this.expandToIndex(e);if(r)for(;r.next;)r=r.next;const a=this.trackEntry(e,s,n,r);return r?(r.next=a,a.previous=r,i<=0&&(i=Math.max(i+r.getTrackComplete()-a.mixDuration,0))):(this.setTrack(e,a,!0),this.queue.drain(),i<0&&(i=0)),a.delay=i,a}setEmptyAnimation(e,s=0){const n=this.setAnimation(e,Ns.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(e,s=0,n=0){const i=this.addAnimation(e,Ns.emptyAnimation,!1,n);return n<=0&&(i.delay=Math.max(i.delay+i.mixDuration-s,0)),i.mixDuration=s,i.trackEnd=s,i}setEmptyAnimations(e=0){const s=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let n=0,i=this.tracks.length;n<i;n++){const r=this.tracks[n];r&&this.setEmptyAnimation(r.trackIndex,e)}this.queue.drainDisabled=s,this.queue.drain()}expandToIndex(e){return e<this.tracks.length?this.tracks[e]:(L.ensureArrayCapacity(this.tracks,e+1,null),this.tracks.length=e+1,null)}trackEntry(e,s,n,i){const r=this.trackEntryPool.obtain();return r.reset(),r.trackIndex=e,r.animation=s,r.loop=n,r.additive=!1,r.reverse=!1,r.shortestRotation=!1,r.eventThreshold=0,r.alphaAttachmentThreshold=0,r.mixAttachmentThreshold=0,r.mixDrawOrderThreshold=0,r.animationStart=0,r.animationEnd=s.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixTime=0,r.mixDuration=i?this.data.getMix(i.animation,s):0,r.totalAlpha=0,r.keepHold=!1,r}clearNext(e){let s=e.next;for(;s;)this.queue.dispose(s),s=s.next;e.next=null}_animationsChanged(){this.animationsChanged=!1;const e=this.tracks;for(let s=0,n=e.length;s<n;s++){const i=e[s];if(!i)continue;let r=i;for(;r.mixingFrom;)r=r.mixingFrom;do this.computeHold(r,i),r=r.mixingTo;while(r)}this.propertyIds.clear()}computeHold(e,s){const n=e.animation.timelines,i=e.animation.timelines.length,r=e.timelineMode;r.length=i;const a=e.timelineHoldMix;a.length=0;const c=e.additive,l=e.keepHold,o=e.mixingTo;for(let h=0;h<i;h++){const d=n[h],m=d.propertyIds,u=this.from(s,d,m);if(c&&d.additive){r[h]=u;continue}let f;if(o===null||d.instant||o.additive&&d.additive||!o.animation?.hasTimeline(m))f=u;else{f=u|_t;for(let p=o.mixingTo;p!=null;p=p.mixingTo)if(p.additive&&d.additive||!p.animation?.hasTimeline(m)){p.mixDuration>0&&(a[h]=p);break}}l&&(f=f&~_t|r[h]&_t),r[h]=f}}from(e,s,n){const i=this.propertyIds;let r=tn;for(let a=0,c=n.length;a<c;a++){const l=i.get(n[a]);if(l===void 0)i.set(n[a],e);else{if(l!==e){for(;++a<c;)i.has(n[a])||i.set(n[a],e);return hs}r=ds}}if(s instanceof qt){const a=i.get(At.propertyID);if(a!=null)return a!==e?hs:ds}return r}getTrack(e){if(e<0)throw new Error("trackIndex must be >= 0.");return e>=this.tracks.length?null:this.tracks[e]}addListener(e){if(!e)throw new Error("listener cannot be null.");this.listeners.push(e)}removeListener(e){const s=this.listeners.indexOf(e);s>=0&&this.listeners.splice(s,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}},Js=class{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;additive=!1;reverse=!1;shortestRotation=!1;keepHold=!1;eventThreshold=0;mixAttachmentThreshold=0;alphaAttachmentThreshold=0;mixDrawOrderThreshold=0;animationStart=0;animationEnd=0;animationLast=0;nextAnimationLast=0;delay=0;trackTime=0;trackLast=0;nextTrackLast=0;trackEnd=0;timeScale=0;alpha=0;mixTime=0;mixDuration=0;totalAlpha=0;mixInterpolation=Bt.linear;setMixDuration(t,e){this.mixDuration=t,e!==void 0&&(e<=0&&(e=this.previous==null?0:Math.max(e+this.previous.getTrackComplete()-t,0)),this.delay=e)}setMixInterpolation(t){if(!t)throw new Error("mixInterpolation cannot be null.");this.mixInterpolation=t}mix(){if(this.mixDuration===0)return 1;let t=this.mixTime/this.mixDuration;return t>=1?1:this.mixInterpolation===Bt.linear?t:(t=this.mixInterpolation.apply(t),t<0?0:t>1?1:t)}timelineMode=[];timelineHoldMix=[];timelinesRotation=[];reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.mixInterpolation=Bt.linear,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(!this.loop)return Math.min(this.trackTime+this.animationStart,this.animationEnd);const t=this.animationEnd-this.animationStart;return t===0?this.animationStart:this.trackTime%t+this.animationStart}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){const t=this.animationEnd-this.animationStart;if(t!==0){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return this.nextTrackLast!==-1}isNextReady(){return this.next!=null&&this.nextTrackLast-this.next.delay>=0}},Qs=class{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(!this.drainDisabled){this.drainDisabled=!0;for(let t=0;t<this.objects.length;t+=2){const e=this.objects,s=e[t],n=e[t+1],i=this.animState.listeners.slice();switch(s){case 0:n.listener?.start&&n.listener.start(n);for(let r=0;r<i.length;r++){const a=i[r];a.start&&a.start(n)}break;case 1:n.listener?.interrupt&&n.listener.interrupt(n);for(let r=0;r<i.length;r++){const a=i[r];a.interrupt&&a.interrupt(n)}break;case 2:n.listener?.end&&n.listener.end(n);for(let r=0;r<i.length;r++){const a=i[r];a.end&&a.end(n)}case 3:n.listener?.dispose&&n.listener.dispose(n);for(let r=0;r<i.length;r++){const a=i[r];a.dispose&&a.dispose(n)}this.animState.trackEntryPool.free(n);break;case 4:n.listener?.complete&&n.listener.complete(n);for(let r=0;r<i.length;r++){const a=i[r];a.complete&&a.complete(n)}break;case 5:{const r=e[t+++2];n.listener?.event&&n.listener.event(n,r);for(let a=0;a<i.length;a++){const c=i[a];c.event&&c.event(n,r)}break}}}this.clear(),this.drainDisabled=!1}}clear(){this.objects.length=0}},Zs=(t=>(t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event",t))(Zs||{}),$n=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},hs=0,tn=1,ds=2,fs=3,_t=4,us=1,ms=2,qn=class{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){return typeof t=="string"?this.setMix1(t,e,s):this.setMix2(t,e,s)}setMix1(t,e,s){const n=this.skeletonData.findAnimation(t);if(!n)throw new Error(`Animation not found: ${t}`);const i=this.skeletonData.findAnimation(e);if(!i)throw new Error(`Animation not found: ${e}`);this.setMix2(n,i,s)}setMix2(t,e,s){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");const n=`${t.name}.${e.name}`;this.animationToMixTime[n]=s}getMix(t,e){const s=`${t.name}.${e.name}`,n=this.animationToMixTime[s];return n===void 0?this.defaultMix:n}},en=class{constructor(t,e="",s=new gs,n=new sn){this.textureLoader=t,this.pathPrefix=e,this.downloader=s,this.cache=n}errors={};toLoad=0;loaded=0;texturePmaInfo={};start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.cache.assets[e]=s,this.cache.assetsRefCount[e]=(this.cache.assetsRefCount[e]||0)+1,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise((e,s)=>{const n=()=>{if(this.isLoadingComplete()){this.hasErrors()?s(this.errors):e(this);return}requestAnimationFrame(n)};requestAnimationFrame(n)})}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((n,i)=>{this.downloader.downloadBinary(t,r=>{this.success(e,t,r),n(r)},(r,a)=>{const c=`Couldn't load binary ${t}: status ${r}, ${a}`;this.error(s,t,c),i(c)})}))}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,n=>{this.success(e,t,n)},(n,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${n}, ${i}`)})}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((n,i)=>{this.downloader.downloadJson(t,r=>{this.success(e,t,r),n(r)},(r,a)=>{const c=`Couldn't load JSON ${t}: status ${r}, ${a}`;this.error(s,t,c),i(c)})}))}reuseAssets(t,e=()=>{},s=()=>{}){const n=this.cache.getAsset(t),i=n!==void 0;return i&&(this.cache.assetsLoaded[t]=n.then(r=>(r=r instanceof Image||r instanceof ImageBitmap?this.textureLoader(r):r,this.success(e,t,r),r)).catch(r=>{this.error(s,t,r)})),i}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),this.reuseAssets(t,e,s))return;const n=this.texturePmaInfo[t];this.cache.assetsLoaded[t]=new Promise((i,r)=>{if(!!!(typeof window<"u"&&typeof navigator<"u"&&window.document))fetch(t,{mode:"cors"}).then(l=>{if(l.ok)return l.blob();const o=`Couldn't load image: ${t}`;this.error(s,t,`Couldn't load image: ${t}`),r(o)}).then(l=>l?createImageBitmap(l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(l=>{if(l){const o=this.createTexture(t,n,l);this.success(e,t,o),i(o)}});else{const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const o=this.createTexture(t,n,l);this.success(e,t,o),i(o)},l.onerror=()=>{const o=`Couldn't load image: ${t}`;this.error(s,t,o),r(o)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),l.src=t}})}loadTextureAtlas(t,e=()=>{},s=()=>{},n){const i=t.lastIndexOf("/"),r=i>=0?t.substring(0,i+1):"";t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((a,c)=>{this.downloader.downloadText(t,l=>{try{const o=this.createTextureAtlas(l,r,t,n);let h=o.pages.length,d=!1;if(h===0){this.success(e,t,o),a(o);return}for(const m of o.pages)this.loadTexture(this.texturePath(r,m.name,n),(u,f)=>{d||(m.setTexture(f),--h===0&&(this.success(e,t,o),a(o)))},(u,f)=>{if(!d){const p=`Couldn't load texture ${t} page image: ${u}`;this.error(s,t,p),c(p)}d=!0})}catch(o){const h=`Couldn't parse texture atlas ${t}: ${o.message}`;this.error(s,t,h),c(h)}},(l,o)=>{const h=`Couldn't load texture atlas ${t}: status ${l}, ${o}`;this.error(s,t,h),c(h)})}))}loadTextureAtlasButNoTextures(t,e=()=>{},s=()=>{}){const n=t.lastIndexOf("/"),i=n>=0?t.substring(0,n+1):"";t=this.start(t),!this.reuseAssets(t,e,s)&&(this.cache.assetsLoaded[t]=new Promise((r,a)=>{this.downloader.downloadText(t,c=>{try{const l=this.createTextureAtlas(c,i,t);this.success(e,t,l),r(l)}catch(l){const o=`Couldn't parse texture atlas ${t}: ${l.message}`;this.error(s,t,o),a(o)}},(c,l)=>{const o=`Couldn't load texture atlas ${t}: status ${c}, ${l}`;this.error(s,t,o),a(o)})}))}async loadBinaryAsync(t){return new Promise((e,s)=>{this.loadBinary(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadJsonAsync(t){return new Promise((e,s)=>{this.loadJson(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAsync(t){return new Promise((e,s)=>{this.loadTexture(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAtlasAsync(t){return new Promise((e,s)=>{this.loadTextureAtlas(t,(n,i)=>e(i),(n,i)=>s(i))})}async loadTextureAtlasButNoTexturesAsync(t){return new Promise((e,s)=>{this.loadTextureAtlasButNoTextures(t,(n,i)=>e(i),(n,i)=>s(i))})}setCache(t){this.cache=t}get(t){return this.cache.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;const e=this.cache.assets[t];if(e)return e;const s=this.errors[t];throw Error(`Asset not found: ${t}${s?`
2
+ ${s}`:""}`)}remove(t){t=this.pathPrefix+t;const e=this.cache.assets[t];return e.dispose&&e.dispose(),delete this.cache.assets[t],delete this.cache.assetsRefCount[t],delete this.cache.assetsLoaded[t],e}removeAll(){for(const t in this.cache.assets){const e=this.cache.assets[t];e.dispose&&e.dispose()}this.cache.assets={},this.cache.assetsLoaded={},this.cache.assetsRefCount={}}isLoadingComplete(){return this.toLoad===0}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}disposeAsset(t){const e=this.cache.assets[t];if(e instanceof Me){e.dispose();return}this.disposeAssetInternal(t)}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}disposeAssetInternal(t){if(this.cache.assetsRefCount[t]>0&&--this.cache.assetsRefCount[t]===0)return this.remove(t)}createTextureAtlas(t,e,s,n){const i=new Me(t);i.dispose=()=>{if(!(this.cache.assetsRefCount[s]<=0)){this.disposeAssetInternal(s);for(const r of i.pages)r.texture?.dispose()}};for(const r of i.pages){const a=this.texturePath(e,r.name,n);this.texturePmaInfo[this.pathPrefix+a]=r.pma}return i}createTexture(t,e,s){const n=this.textureLoader(s,e),i=n.dispose.bind(n);return n.dispose=()=>{this.disposeAssetInternal(t)&&i()},n}texturePath(t,e,s){return s?s[e]:t+e}},sn=class Se{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(e){const s=Se.AVAILABLE_CACHES.get(e);if(s)return s;const n=new Se;return Se.AVAILABLE_CACHES.set(e,n),n}async addAsset(e,s){return this.assetsLoaded[e]=Promise.resolve(s),this.assets[e]=s,s}getAsset(e){return this.assetsLoaded[e]}},gs=class{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return e!==-1?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){var e=window.atob(t),s=e.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=e.charCodeAt(i);return n}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(e===-1)throw new Error("Not a binary data URI.");return e+=7,this.base64ToUint8Array(t.substr(e))}downloadText(t,e,s){if(this.start(t,e,s))return;const n=this.rawDataUris[t];if(n&&!n.includes(".")){try{this.finish(t,200,this.dataUriToString(n))}catch(a){this.finish(t,400,JSON.stringify(a))}return}const i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",n||t,!0);const r=()=>{this.finish(t,i.status,i.responseText)};i.onload=r,i.onerror=r,i.send()}downloadJson(t,e,s){this.downloadText(t,n=>{e(JSON.parse(n))},s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;const n=this.rawDataUris[t];if(n&&!n.includes(".")){try{this.finish(t,200,this.dataUriToUint8Array(n))}catch(a){this.finish(t,400,JSON.stringify(a))}return}const i=new XMLHttpRequest;i.open("GET",n||t,!0),i.responseType="arraybuffer";const r=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{i.status===200||i.status===0?this.finish(t,200,new Uint8Array(i.response)):r()},i.onerror=r,i.send()}start(t,e,s){let n=this.callbacks[t];try{if(n)return!0;this.callbacks[t]=n=[]}finally{n.push(e,s)}}finish(t,e,s){const n=this.callbacks[t];if(delete this.callbacks[t],e===200||e===0)for(let i=0,r=n.length;i<r;i+=2)n[i](s);else for(let i=1,r=n.length;i<r;i+=2)n[i](e,s)}},ps=class In extends xt{color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new In(this.name);return this.copyTo(e),e.color.setFromColor(this.color),e}},zt=class Cn extends xt{endSlot=null;convex=!1;inverse=!1;color=new z(.2275,.2275,.8078,1);constructor(e){super(e)}copy(){const e=new Cn(this.name);return this.copyTo(e),e.endSlot=this.endSlot,e.convex=this.convex,e.inverse=this.inverse,e.color.setFromColor(this.color),e}},ee=class Mn extends xt{lengths=[];closed=!1;constantSpeed=!1;color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new Mn(this.name);return this.copyTo(e),e.lengths=[],L.arrayCopy(this.lengths,0,e.lengths,0,this.lengths.length),e.closed=this.closed,e.constantSpeed=this.constantSpeed,e.color.setFromColor(this.color),e}},nn=class Yn extends xt{x=0;y=0;rotation=0;color=new z(.38,.94,0,1);constructor(e){super(e)}computeWorldPosition(e,s){return s.x=this.x*e.a+this.y*e.b+e.worldX,s.y=this.x*e.c+this.y*e.d+e.worldY,s}computeWorldRotation(e){const s=this.rotation*R.degRad,n=Math.cos(s),i=Math.sin(s),r=n*e.a+i*e.b,a=n*e.c+i*e.d;return R.atan2Deg(a,r)}copy(){const e=new Yn(this.name);return e.x=this.x,e.y=this.y,e.rotation=this.rotation,e.color.setFromColor(this.color),e}},_n=class{atlas;allowMissingRegions;constructor(t,e=!1){this.atlas=t,this.allowMissingRegions=e}findRegions(t,e,s){const n=s.regions;for(let i=0,r=n.length;i<r;i++)n[i]=this.findRegion(t,s.getPath(e,i))}findRegion(t,e){const s=this.atlas.findRegion(e);if(!s&&!this.allowMissingRegions)throw new Error(`Region not found in atlas: ${e} (attachment: ${t})`);return s}newRegionAttachment(t,e,s,n,i){return this.findRegions(s,n,i),new j(s,i)}newMeshAttachment(t,e,s,n,i){return this.findRegions(s,n,i),new wt(s,i)}newBoundingBoxAttachment(t,e,s){return new ps(s)}newPathAttachment(t,e,s){return new ee(s)}newPointAttachment(t,e,s){return new nn(s)}newClippingAttachment(t,e,s){return new zt(s)}},se=class{name;setupPose;skinRequired=!1;constructor(t,e){if(t==null)throw new Error("name cannot be null.");this.name=t,this.setupPose=e}},bs=class Fn extends se{index=0;parent=null;length=0;color=new z;icon;iconSize=1;iconRotation=0;visible=!1;constructor(e,s,n){if(super(s,new ie),e<0)throw new Error("index must be >= 0.");if(!s)throw new Error("name cannot be null.");this.index=e,this.parent=n}copy(e){const s=new Fn(this.index,this.name,e);return s.length=this.length,s.setupPose.set(this.setupPose),s}},ne=(t=>(t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection",t))(ne||{}),ie=class{bone;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;inherit=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;world=0;local=0;set(t){if(t==null)throw new Error("pose cannot be null.");this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}setPosition(t,e){this.x=t,this.y=e}setScale(t,e){this.scaleX=t,this.scaleY=e===void 0?t:e}getInherit(){return this.inherit}setInherit(t){if(t==null)throw new Error("inherit cannot be null.");this.inherit=t}update(t,e){this.world!==t._update&&this.updateWorldTransform(t)}updateWorldTransform(t){this.local===t._update?this.updateLocalTransform(t):this.world=t._update;const e=this.rotation,s=this.scaleX,n=this.scaleY,i=this.shearX,r=this.shearY;if(!this.bone.parent){const d=t.scaleX,m=t.scaleY,u=(e+i)*R.degRad,f=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(f)*n*d,this.c=Math.sin(u)*s*m,this.d=Math.sin(f)*n*m,this.worldX=this.x*d+t.x,this.worldY=this.y*m+t.y;return}const a=this.bone.parent.appliedPose;let c=a.a,l=a.b,o=a.c,h=a.d;switch(this.worldX=c*this.x+l*this.y+a.worldX,this.worldY=o*this.x+h*this.y+a.worldY,this.inherit){case 0:{const d=(e+i)*R.degRad,m=(e+90+r)*R.degRad,u=Math.cos(d)*s,f=Math.cos(m)*n,p=Math.sin(d)*s,g=Math.sin(m)*n;this.a=c*u+l*p,this.b=c*f+l*g,this.c=o*u+h*p,this.d=o*f+h*g;return}case 1:{const d=t.scaleX,m=t.scaleY,u=(e+i)*R.degRad,f=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(f)*n*d,this.c=Math.sin(u)*s*m,this.d=Math.sin(f)*n*m;break}case 2:{const d=t.scaleX,m=t.scaleY,u=1/d,f=1/m;c*=u,o*=f;let p=c*c+o*o,g=0;p>R.epsilon2?(p=Math.abs(c*h*f-l*u*o)/p,l=o*p,h=c*p,g=e-R.atan2Deg(o,c)):(c=0,o=0,g=e-90+R.atan2Deg(h,l));const b=(g+i)*R.degRad,x=(g+r+90)*R.degRad,w=Math.cos(b)*s,S=Math.cos(x)*n,y=Math.sin(b)*s,v=Math.sin(x)*n;this.a=(c*w-l*y)*d,this.b=(c*S-l*v)*d,this.c=(o*w+h*y)*m,this.d=(o*S+h*v)*m;break}case 3:case 4:{const d=t.scaleX,m=t.scaleY,u=1/d,f=1/m,p=e*R.degRad,g=Math.cos(p),b=Math.sin(p);let x=(c*g+l*b)*u,w=(o*g+h*b)*f;const S=1/Math.sqrt(x*x+w*w);x*=S,w*=S;let y=-w,v=x;this.inherit===3&&c*h-l*o<0!=(d<0!=m<0)&&(y=-y,v=-v);const T=i*R.degRad,A=(90+r)*R.degRad,M=Math.cos(T)*s,C=Math.cos(A)*n,Y=Math.sin(T)*s,P=Math.sin(A)*n;this.a=(x*M+y*Y)*d,this.b=(x*C+y*P)*d,this.c=(w*M+v*Y)*m,this.d=(w*C+v*P)*m;break}}}updateLocalTransform(t){this.local=0,this.world=t._update;const e=t.scaleX,s=t.scaleY;if(!this.bone.parent){const g=1/e,b=1/s;this.x=(this.worldX-t.x)*g,this.y=(this.worldY-t.y)*b,this.set5(this.a*g,this.b*g,this.c*b,this.d*b,0);return}const n=this.bone.parent.appliedPose;let i=n.a,r=n.b,a=n.c,c=n.d;const l=i*c-r*a,o=1/(i*c-r*a),h=c*o,d=r*o,m=a*o,u=i*o,f=this.worldX-n.worldX,p=this.worldY-n.worldY;switch(this.x=f*h-p*d,this.y=p*u-f*m,this.inherit){case 0:this.set5(h*this.a-d*this.c,h*this.b-d*this.d,u*this.c-m*this.a,u*this.d-m*this.b,0);break;case 1:{const g=1/e,b=1/s;this.set5(this.a*g,this.b*g,this.c*b,this.d*b,0);break}case 2:{const g=1/e,b=1/s;i*=g,a*=b;const x=this.a*g,w=this.b*g,S=this.c*b,y=this.d*b,v=1/(i*i+a*a),T=1/Math.abs(l*g*b);this.set5((i*x+a*S)*v,(i*w+a*y)*v,(i*S-a*x)*T,(i*y-a*w)*T,R.atan2Deg(a,i));break}case 3:case 4:{const g=1/e,b=1/s,x=this.a*g,w=this.b*g,S=this.c*b,y=this.d*b;let v=c*this.a-r*this.c,T=i*this.c-a*this.a;l<0&&(v=-v,T=-T);let A=R.atan2Deg(T,v);this.rotation=A,A*=R.degRad;const M=Math.cos(A),C=Math.sin(A);let Y=(i*M+r*C)*g,P=(a*M+c*C)*b;const E=1/Math.sqrt(Y*Y+P*P);Y*=E,P*=E;const X=this.inherit===3&&l<0!=(e<0!=s<0)?-1:1;this.set4(Y*x+P*S,Y*w+P*y,(Y*S-P*x)*X,(Y*y-P*w)*X)}}}set4(t,e,s,n){const i=t*t+s*s,r=e*e+n*n;i>R.epsilon2?(this.shearX=R.atan2Deg(s,t),this.scaleX=Math.sqrt(i)):(this.shearX=0,this.scaleX=0),this.scaleY=Math.sqrt(r),r>R.epsilon2?(this.shearY=R.atan2Deg(n,e),t*n-e*s<0?(this.scaleY=-this.scaleY,this.shearY+=90):this.shearY-=90,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}set5(t,e,s,n,i){this.shearX=0;const r=t*t+s*s,a=e*e+n*n;if(r>R.epsilon2){const c=R.atan2Deg(s,t);this.rotation=c+i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(a),a>R.epsilon2?(this.shearY=R.atan2Deg(n,e),t*n-e*s<0?(this.scaleY=-this.scaleY,this.shearY+=90-c):this.shearY-=90+c,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}else this.scaleX=0,this.scaleY=Math.sqrt(a),this.shearY=0,this.rotation=a>R.epsilon2?R.atan2Deg(n,e)-90+i:i}validateLocalTransform(t){this.local===t._update&&this.updateLocalTransform(t)}modifyLocal(t){this.local===t._update&&this.updateLocalTransform(t),this.world=0,this.resetWorld(t,t._update)}modifyWorld(t){const e=t._update;this.local=e,this.world=e,this.resetWorld(t,e)}resetWorld(t,e){const s=this.bone.children;for(let n=0,i=s.length;n<i;n++){const r=s[n].appliedPose;r.world===e&&(r.local===e&&r.updateLocalTransform(t),r.world=0,r.resetWorld(t,e))}}getWorldRotationX(){return R.atan2Deg(this.c,this.a)}getWorldRotationY(){return R.atan2Deg(this.d,this.b)}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}worldToLocal(t){if(t==null)throw new Error("world cannot be null.");const e=this.a*this.d-this.b*this.c,s=t.x-this.worldX,n=t.y-this.worldY;return t.x=(s*this.d-n*this.b)/e,t.y=(n*this.a-s*this.c)/e,t}localToWorld(t){if(t==null)throw new Error("local cannot be null.");const e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToParent(t){if(t==null)throw new Error("world cannot be null.");return this.bone.parent==null?t:this.bone.parent.appliedPose.worldToLocal(t)}parentToWorld(t){if(t==null)throw new Error("world cannot be null.");return this.bone.parent==null?t:this.bone.parent.appliedPose.localToWorld(t)}worldToLocalRotation(t){t*=R.degRad;const e=Math.sin(t),s=Math.cos(t);return R.atan2Deg(this.a*e-this.c*s,this.d*s-this.b*e)+this.rotation-this.shearX}localToWorldRotation(t){t=(t-this.rotation-this.shearX)*R.degRad;const e=Math.sin(t),s=Math.cos(t);return R.atan2Deg(s*this.c+e*this.d,s*this.a+e*this.b)}rotateWorld(t){t*=R.degRad;const e=Math.sin(t),s=Math.cos(t),n=this.a,i=this.b;this.a=s*n-e*this.c,this.b=s*i-e*this.d,this.c=e*n+s*this.c,this.d=e*i+s*this.d}},xs=class{data;pose;constrainedPose;appliedPose;constructor(t,e,s){if(t==null)throw new Error("data cannot be null.");this.data=t,this.pose=e,this.constrainedPose=s,this.appliedPose=e}setupPose(){this.pose.set(this.data.setupPose)}getData(){return this.data}getPose(){return this.pose}getAppliedPose(){return this.appliedPose}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.set(this.pose)}},ws=class extends xs{active=!1;constructor(t,e,s){super(t,e,s),this.setupPose()}isActive(){return this.active}},re=class kn extends ws{parent=null;children=[];sorted=!1;constructor(e,s){super(e,new ie,new ie),this.parent=s,this.appliedPose.bone=this,this.constrainedPose.bone=this}copy(e){const s=new kn(this.data,e);return s.pose.set(this.pose),s}},Et=class extends ws{constructor(t,e,s){super(t,e,s)}isSourceActive(){return!0}},rn=class{_setupPose;pose;constrainedPose;appliedPose;constructor(t){this._setupPose=t,this.pose=[...t],this.constrainedPose=[],this.appliedPose=this.pose}setupPose(){this.pose.length=this._setupPose.length,L.arrayCopy(this._setupPose,0,this.pose,0,this._setupPose.length)}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.length=this.pose.length,L.arrayCopy(this.pose,0,this.constrainedPose,0,this.pose.length)}},Xt=class extends se{constructor(t,e){super(t,e)}},oe=(t=>(t[t.None=0]="None",t[t.Uniform=1]="Uniform",t[t.Volume=2]="Volume",t))(oe||{}),ae=class{time=0;data;intValue=0;floatValue=0;stringValue=null;volume=0;balance=0;constructor(t,e){if(!e)throw new Error("data cannot be null.");this.time=t,this.data=e}},ys=class{name;_audioPath=null;get audioPath(){return this._audioPath}set audioPath(t){if(t==null)throw new Error("audioPath cannot be null.");this._audioPath=t}setupPose=new ae(-1,this);constructor(t){this.name=t}},ce=class{bendDirection=0;compress=!1;stretch=!1;mix=0;softness=0;set(t){this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}},on=class Yt extends Et{bones;target;constructor(e,s){if(super(e,new ce,new ce),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const n of e.bones)this.bones.push(s.bones[n.index].constrainedPose);this.target=s.bones[e.target.index]}copy(e){var s=new Yt(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.target.appliedPose,r=this.bones;switch(r.length){case 1:Yt.apply(e,r[0],i.worldX,i.worldY,n.compress,n.stretch,this.data.scaleYMode,n.mix);break;case 2:Yt.apply(e,r[0],r[1],i.worldX,i.worldY,n.bendDirection,n.stretch,this.data.scaleYMode,n.softness,n.mix);break}}sort(e){e.sortBone(this.target);const s=this.bones[0].bone;e.sortBone(s),e._updateCache.push(this),s.sorted=!1,e.sortReset(s.children),e.constrained(s),this.bones.length>1&&e.constrained(this.bones[1].bone)}isSourceActive(){return this.target.active}static apply(e,s,n,i,r,a,c,l,o,h){typeof n=="number"?Yt.apply1(e,s,n,i,r,a,c,l):Yt.apply2(e,s,n,i,r,a,c,l,o,h)}static apply1(e,s,n,i,r,a,c,l){s.modifyLocal(e);const o=s.bone.parent.appliedPose;let h=o.a,d=o.b,m=o.c,u=o.d,f=-s.shearX-s.rotation,p=0,g=0;switch(s.inherit){case 1:p=(n-s.worldX)*R.signum(e.scaleX),g=(i-s.worldY)*R.signum(e.scaleY);break;case 2:{const b=Math.abs(h*u-d*m)/Math.max(R.epsilon,h*h+m*m),x=h/e.scaleX,w=m/e.scaleY;d=-w*b*e.scaleX,u=x*b*e.scaleY,f+=R.atan2Deg(w,x)}default:{const b=n-o.worldX,x=i-o.worldY,w=h*u-d*m;Math.abs(w)<=R.epsilon?(p=0,g=0):(p=(b*u-x*d)/w-s.x,g=(x*h-b*m)/w-s.y)}}if(f+=R.atan2Deg(g,p),s.scaleX<0&&(f+=180),f>180?f-=360:f<=-180&&(f+=360),s.rotation+=f*l,r||a){switch(s.inherit){case 3:case 4:p=n-s.worldX,g=i-s.worldY}const b=s.bone.data.length*s.scaleX;if(b>R.epsilon){const x=p*p+g*g;if(r&&x<b*b||a&&x>b*b){const w=(Math.sqrt(x)/b-1)*l+1;switch(s.scaleX*=w,c){case 1:s.scaleY*=w;break;case 2:s.scaleY/=w<.7?.25+.642857*w:w}}}}}static apply2(e,s,n,i,r,a,c,l,o,h){if(s.inherit!==0||n.inherit!==0)return;s.modifyLocal(e),n.modifyLocal(e);let d=s.x,m=s.y,u=s.scaleX,f=s.scaleY,p=n.scaleX,g=0,b=0,x=0;u<0?(u=-u,g=180,x=-1):(g=0,x=1),f<0&&(f=-f,x=-x),p<0?(p=-p,b=180):b=0;let w=0,S=0,y=s.a,v=s.b,T=s.c,A=s.d;const M=Math.abs(u-f)<=R.epsilon;!M||c?(n.y=0,w=y*n.x+s.worldX,S=T*n.x+s.worldY):(w=y*n.x+v*n.y+s.worldX,S=T*n.x+A*n.y+s.worldY);const C=s.bone.parent.appliedPose;y=C.a,v=C.b,T=C.c,A=C.d;let Y=y*A-v*T,P=w-C.worldX,E=S-C.worldY;Y=Math.abs(Y)<=R.epsilon?0:1/Y;const X=(P*A-E*v)*Y-d,V=(E*y-P*T)*Y-m;let N=Math.sqrt(X*X+V*V),$=n.bone.data.length*p,U,F;if(N<R.epsilon){Yt.apply(e,s,i,r,!1,c,0,h),n.rotation=0;return}P=i-C.worldX,E=r-C.worldY;let k=(P*A-E*v)*Y-d,D=(E*y-P*T)*Y-m,O=k*k+D*D;if(o!==0){o*=u*(p+1)*.5;const B=Math.sqrt(O),_=B-N-$*u+o;if(_>0){let q=Math.min(1,_/(o*2))-1;q=(_-o*(1-q*q))/B,k-=q*k,D-=q*D,O=k*k+D*D}}t:if(M){$*=u;let B=(O-N*N-$*$)/(2*N*$);if(B<-1)B=-1,F=Math.PI*a;else if(B>1){if(B=1,F=0,c)switch(y=(Math.sqrt(O)/(N+$)-1)*h+1,s.scaleX*=y,l){case 1:s.scaleY*=y;break;case 2:s.scaleY/=y<.7?.25+.642857*y:y}}else F=Math.acos(B)*a;y=N+$*B,v=$*Math.sin(F),U=Math.atan2(D*y-k*v,k*y+D*v)}else{y=u*$,v=f*$;const B=y*y,_=v*v,q=Math.atan2(D,k);T=_*N*N+B*O-B*_;const J=-2*_*N,et=_-B;if(A=J*J-4*et*T,A>=0){let ut=Math.sqrt(A);J<0&&(ut=-ut),ut=-(J+ut)*.5;let pt=ut/et,Lt=T/ut;const Kt=Math.abs(pt)<Math.abs(Lt)?pt:Lt;if(pt=O-Kt*Kt,pt>=0){E=Math.sqrt(pt)*a,U=q-Math.atan2(E,Kt),F=Math.atan2(E/f,(Kt-N)/u);break t}}let Q=R.PI,st=N-y,it=st*st,nt=0,dt=0,rt=N+y,ot=rt*rt,ft=0;T=-y*N/(B-_),T>=-1&&T<=1&&(T=Math.acos(T),P=y*Math.cos(T)+N,E=v*Math.sin(T),A=P*P+E*E,A<it&&(Q=T,it=A,st=P,nt=E),A>ot&&(dt=T,ot=A,rt=P,ft=E)),O<=(it+ot)*.5?(U=q-Math.atan2(nt*a,st),F=Q*a):(U=q-Math.atan2(ft*a,rt),F=dt*a)}const W=Math.atan2(n.y,n.x)*x;U=(U-W)*R.radDeg+g-s.rotation,U>180?U-=360:U<=-180&&(U+=360),s.rotation+=U*h,F=((F+W)*R.radDeg-n.shearX)*x+b-n.rotation,F>180?F-=360:F<=-180&&(F+=360),n.rotation+=F*h}},Wt=class extends Xt{bones=[];_target=null;set target(t){this._target=t}get target(){if(!this._target)throw new Error("target cannot be null.");return this._target}_scaleYMode=0;set scaleYMode(t){this._scaleYMode=t}get scaleYMode(){if(this._scaleYMode==null)throw new Error("scaleYMode cannot be null.");return this._scaleYMode}constructor(t){super(t,new ce)}create(t){return new on(this,t)}},le=class{position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;set(t){this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}},Ht=class extends Xt{bones=[];set slot(t){this._slot=t}get slot(){if(this._slot)return this._slot;throw new Error("SlotData not set.")}_slot=null;positionMode=0;spacingMode=1;rotateMode=1;offsetRotation=0;constructor(t){super(t,new le)}create(t){return new an(this,t)}},vs=(t=>(t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent",t))(vs||{}),Ss=(t=>(t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional",t))(Ss||{}),Ts=(t=>(t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale",t))(Ts||{}),an=class Ft extends Et{static NONE=-1;static BEFORE=-2;static AFTER=-3;data;bones;slot;spaces=[];positions=[];world=[];curves=[];lengths=[];segments=[];constructor(e,s){if(super(e,new le,new le),!s)throw new Error("skeleton cannot be null.");this.data=e,this.bones=[];for(const n of this.data.bones)this.bones.push(s.bones[n.index].constrainedPose);this.slot=s.slots[e.slot.index]}copy(e){var s=new Ft(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.slot.appliedPose.attachment;if(!(n instanceof ee))return;const i=this.appliedPose,r=i.mixRotate,a=i.mixX,c=i.mixY;if(r===0&&a===0&&c===0)return;const l=this.data,o=l.rotateMode===0,h=l.rotateMode===2,d=this.bones,m=d.length,u=o?m:m+1,f=L.setArraySize(this.spaces,u),p=h?this.lengths=L.setArraySize(this.lengths,m):[],g=i.spacing;switch(l.spacingMode){case 2:if(h)for(let v=0,T=u-1;v<T;v++){const A=d[v],M=A.bone.data.length,C=M*A.a,Y=M*A.c;p[v]=Math.sqrt(C*C+Y*Y)}L.arrayFill(f,1,u,g);break;case 3:{let v=0;for(let T=0,A=u-1;T<A;){const M=d[T],C=M.bone.data.length;if(C<R.epsilon)h&&(p[T]=0),f[++T]=g;else{const Y=C*M.a,P=C*M.c,E=Math.sqrt(Y*Y+P*P);h&&(p[T]=E),f[++T]=E,v+=E}}if(v>0){v=u/v*g;for(let T=1;T<u;T++)f[T]*=v}break}default:{const v=l.spacingMode===0;for(let T=0,A=u-1;T<A;){const M=d[T],C=M.bone.data.length;if(C<R.epsilon)h&&(p[T]=0),f[++T]=g;else{const Y=C*M.a,P=C*M.c,E=Math.sqrt(Y*Y+P*P);h&&(p[T]=E),f[++T]=(v?Math.max(0,C+g):g)*E/C}}}}const b=this.computeWorldPositions(e,n,u,o);let x=b[0],w=b[1],S=l.offsetRotation,y=!1;if(S===0)y=l.rotateMode===1;else{y=!1;const v=this.slot.bone.appliedPose;S*=v.a*v.d-v.b*v.c>0?R.degRad:-R.degRad}for(let v=0,T=3;v<m;v++,T+=3){const A=d[v];A.modifyWorld(e),A.worldX+=(x-A.worldX)*a,A.worldY+=(w-A.worldY)*c;const M=b[T],C=b[T+1],Y=M-x,P=C-w;if(h){const E=p[v];if(E!==0){const X=(Math.sqrt(Y*Y+P*P)/E-1)*r+1;A.a*=X,A.c*=X}}if(x=M,w=C,r>0){let E=A.a,X=A.b,V=A.c,N=A.d,$=0,U=0,F=0;if(o?$=b[T-1]:f[v+1]===0?$=b[T+2]:$=Math.atan2(P,Y),$-=Math.atan2(V,E),y){U=Math.cos($),F=Math.sin($);const k=A.bone.data.length;x+=(k*(U*E-F*V)-Y)*r,w+=(k*(F*E+U*V)-P)*r}else $+=S;$>R.PI?$-=R.PI2:$<-R.PI&&($+=R.PI2),$*=r,U=Math.cos($),F=Math.sin($),A.a=U*E-F*V,A.b=U*X-F*N,A.c=F*E+U*V,A.d=F*X+U*N}}}computeWorldPositions(e,s,n,i){const r=this.slot;let a=this.appliedPose.position,c=this.spaces,l=L.setArraySize(this.positions,n*3+2),o=this.world;const h=s.closed;let d=s.worldVerticesLength,m=d/6,u=Ft.NONE;if(!s.constantSpeed){const F=s.lengths;m-=h?1:2;const k=F[m];this.data.positionMode===1&&(a*=k);let D;switch(this.data.spacingMode){case 2:D=k;break;case 3:D=k/n;break;default:D=1}o=L.setArraySize(this.world,8);for(let O=0,W=0,B=0;O<n;O++,W+=3){const _=c[O]*D;a+=_;let q=a;if(h)q%=k,q<0&&(q+=k),B=0;else if(q<0){u!==Ft.BEFORE&&(u=Ft.BEFORE,s.computeWorldVertices(e,r,2,4,o,0,2)),this.addBeforePosition(q,o,0,l,W);continue}else if(q>k){u!==Ft.AFTER&&(u=Ft.AFTER,s.computeWorldVertices(e,r,d-6,4,o,0,2)),this.addAfterPosition(q-k,o,0,l,W);continue}for(;;B++){const J=F[B];if(!(q>J)){if(B===0)q/=J;else{const et=F[B-1];q=(q-et)/(J-et)}break}}B!==u&&(u=B,h&&B===m?(s.computeWorldVertices(e,r,d-4,4,o,0,2),s.computeWorldVertices(e,r,0,4,o,4,2)):s.computeWorldVertices(e,r,B*6+2,8,o,0,2)),this.addCurvePosition(q,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],l,W,i||O>0&&_===0)}return l}h?(d+=2,o=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d-4,o,0,2),s.computeWorldVertices(e,r,0,2,o,d-4,2),o[d-2]=o[0],o[d-1]=o[1]):(m--,d-=4,o=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d,o,0,2));const f=L.setArraySize(this.curves,m);let p=0,g=o[0],b=o[1],x=0,w=0,S=0,y=0,v=0,T=0,A=0,M=0,C=0,Y=0,P=0,E=0,X=0,V=0;for(let F=0,k=2;F<m;F++,k+=6)x=o[k],w=o[k+1],S=o[k+2],y=o[k+3],v=o[k+4],T=o[k+5],A=(g-x*2+S)*.1875,M=(b-w*2+y)*.1875,C=((x-S)*3-g+v)*.09375,Y=((w-y)*3-b+T)*.09375,P=A*2+C,E=M*2+Y,X=(x-g)*.75+A+C*.16666667,V=(w-b)*.75+M+Y*.16666667,p+=Math.sqrt(X*X+V*V),X+=P,V+=E,P+=C,E+=Y,p+=Math.sqrt(X*X+V*V),X+=P,V+=E,p+=Math.sqrt(X*X+V*V),X+=P+C,V+=E+Y,p+=Math.sqrt(X*X+V*V),f[F]=p,g=v,b=T;this.data.positionMode===1&&(a*=p);let N;switch(this.data.spacingMode){case 2:N=p;break;case 3:N=p/n;break;default:N=1}const $=this.segments;let U=0;for(let F=0,k=0,D=0,O=0;F<n;F++,k+=3){const W=c[F]*N;a+=W;let B=a;if(h)B%=p,B<0&&(B+=p),D=0,O=0;else if(B<0){this.addBeforePosition(B,o,0,l,k);continue}else if(B>p){this.addAfterPosition(B-p,o,d-4,l,k);continue}for(;;D++){const _=f[D];if(!(B>_)){if(D===0)B/=_;else{const q=f[D-1];B=(B-q)/(_-q)}break}}if(D!==u){u=D;let _=D*6;for(g=o[_],b=o[_+1],x=o[_+2],w=o[_+3],S=o[_+4],y=o[_+5],v=o[_+6],T=o[_+7],A=(g-x*2+S)*.03,M=(b-w*2+y)*.03,C=((x-S)*3-g+v)*.006,Y=((w-y)*3-b+T)*.006,P=A*2+C,E=M*2+Y,X=(x-g)*.3+A+C*.16666667,V=(w-b)*.3+M+Y*.16666667,U=Math.sqrt(X*X+V*V),$[0]=U,_=1;_<8;_++)X+=P,V+=E,P+=C,E+=Y,U+=Math.sqrt(X*X+V*V),$[_]=U;X+=P,V+=E,U+=Math.sqrt(X*X+V*V),$[8]=U,X+=P+C,V+=E+Y,U+=Math.sqrt(X*X+V*V),$[9]=U,O=0}for(B*=U;;O++){const _=$[O];if(!(B>_)){if(O===0)B/=_;else{const q=$[O-1];B=O+(B-q)/(_-q)}break}}this.addCurvePosition(B*.1,g,b,x,w,S,y,v,T,l,k,i||F>0&&W===0)}return l}addBeforePosition(e,s,n,i,r){const a=s[n],c=s[n+1],l=s[n+2]-a,o=s[n+3]-c,h=Math.atan2(o,l);i[r]=a+e*Math.cos(h),i[r+1]=c+e*Math.sin(h),i[r+2]=h}addAfterPosition(e,s,n,i,r){const a=s[n+2],c=s[n+3],l=a-s[n],o=c-s[n+1],h=Math.atan2(o,l);i[r]=a+e*Math.cos(h),i[r+1]=c+e*Math.sin(h),i[r+2]=h}addCurvePosition(e,s,n,i,r,a,c,l,o,h,d,m){if(e===0||Number.isNaN(e)){h[d]=s,h[d+1]=n,h[d+2]=Math.atan2(r-n,i-s);return}const u=e*e,f=u*e,p=1-e,g=p*p,b=g*p,x=p*e,w=x*3,S=p*w,y=w*e,v=s*b+i*S+a*y+l*f,T=n*b+r*S+c*y+o*f;h[d]=v,h[d+1]=T,m&&(e<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(T-(n*g+r*x*2+c*u),v-(s*g+i*x*2+a*u)))}sort(e){const s=this.slot.data.index,n=this.slot.bone;e.skin!=null&&this.sortPathSlot(e,e.skin,s,n),e.data.defaultSkin!=null&&e.data.defaultSkin!==e.skin&&this.sortPathSlot(e,e.data.defaultSkin,s,n),this.sortPath(e,this.slot.pose.attachment,n);const i=this.bones,r=this.bones.length;for(let a=0;a<r;a++){const c=i[a].bone;e.sortBone(c),e.constrained(c)}e._updateCache.push(this);for(let a=0;a<r;a++)e.sortReset(i[a].bone.children);for(let a=0;a<r;a++)i[a].bone.sorted=!0}sortPathSlot(e,s,n,i){const r=s.getAttachments();for(let a=0,c=r.length;a<c;a++){const l=r[a];l.slotIndex===n&&this.sortPath(e,l.attachment,i)}}sortPath(e,s,n){if(!(s instanceof ee))return;const i=s.bones;if(i==null)e.sortBone(n);else{const r=e.bones;for(let a=0,c=i.length;a<c;){let l=i[a++];for(l+=a;a<l;)e.sortBone(r[i[a++]])}}}isSourceActive(){return this.slot.bone.active}},cn=(t=>(t[t.none=0]="none",t[t.reset=1]="reset",t[t.update=2]="update",t[t.pose=3]="pose",t))(cn||{}),he=class{inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;set(t){this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}},de=class{color=new z(1,1,1,1);darkColor=null;attachment=null;sequenceIndex=0;deform=[];SlotPose(){}set(t){if(t==null)throw new Error("pose cannot be null.");this.color.setFromColor(t.color),this.darkColor!=null&&t.darkColor!=null&&this.darkColor.setFromColor(t.darkColor),this.attachment=t.attachment,this.sequenceIndex=t.sequenceIndex,this.deform.length=0,this.deform.push(...t.deform)}getAttachment(){return this.attachment}setAttachment(t){this.attachment!==t&&((!(t instanceof xt)||!(this.attachment instanceof xt)||t.timelineAttachment!==this.attachment.timelineAttachment)&&(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}},ln=class Pn extends xs{skeleton;bone;attachmentState=0;constructor(e,s){if(super(e,new de,new de),!s)throw new Error("skeleton cannot be null.");this.skeleton=s,this.bone=s.bones[e.boneData.index],e.setupPose.darkColor!=null&&(this.pose.darkColor=new z,this.constrainedPose.darkColor=new z),this.setupPose()}copy(e,s,n){const i=new Pn(e.data,this.skeleton);return this.data.setupPose.darkColor!=null&&(i.pose.darkColor=new z,i.constrainedPose.darkColor=new z),i.pose.set(e.pose),i}setupPose(){this.pose.color.setFromColor(this.data.setupPose.color),this.pose.darkColor&&this.pose.darkColor.setFromColor(this.data.setupPose.darkColor),this.pose.sequenceIndex=this.data.setupPose.sequenceIndex,this.data.attachmentName?(this.pose.attachment=null,this.pose.setAttachment(this.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.pose.setAttachment(null)}},hn=class Te{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Te.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Te.yDir}set scaleY(e){this._scaleY=e}x=0;y=0;time=0;windX=1;windY=0;gravityX=0;gravityY=1;_update=0;constructor(e){if(!e)throw new Error("data cannot be null.");this.data=e,this.bones=[];for(let s=0;s<e.bones.length;s++){const n=e.bones[s];let i;if(!n.parent)i=new re(n,null);else{const r=this.bones[n.parent.index];i=new re(n,r),r.children.push(i)}this.bones.push(i)}this.slots=[];for(const s of this.data.slots)this.slots.push(new ln(s,this));this.drawOrder=new rn(this.slots),this.physics=[],this.constraints=[];for(const s of this.data.constraints){const n=s.create(this);n instanceof As&&this.physics.push(n),this.constraints.push(n)}this.color=new z(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.resetCache.length=0,this.drawOrder.unconstrained();const e=this.slots;for(let a=0,c=e.length;a<c;a++)e[a].unconstrained();const s=this.bones,n=s.length;for(let a=0,c=n;a<c;a++){const l=s[a];l.sorted=l.data.skinRequired,l.active=!l.sorted,l.unconstrained()}if(this.skin){const a=this.skin.bones;for(let c=0,l=this.skin.bones.length;c<l;c++){let o=this.bones[a[c].index];do o.sorted=!1,o.active=!0,o=o.parent;while(o)}}const i=this.constraints;let r=this.constraints.length;for(let a=0;a<r;a++)i[a].unconstrained();for(let a=0;a<r;a++){const c=i[a];c.active=c.isSourceActive()&&(!c.data.skinRequired||this.skin!=null&&this.skin.constraints.includes(c.data)),c.active&&c.sort(this)}for(let a=0;a<n;a++)this.sortBone(s[a]);r=this._updateCache.length;for(let a=0;a<r;a++){const c=this._updateCache[a];c instanceof re&&(this._updateCache[a]=c.appliedPose)}}constrained(e){e.pose===e.appliedPose&&(e.constrained(),this.resetCache.push(e))}sortBone(e){if(e.sorted||!e.active)return;const s=e.parent;s&&this.sortBone(s),e.sorted=!0,this._updateCache.push(e)}sortReset(e){for(let s=0,n=e.length;s<n;s++){const i=e[s];i.active&&(i.sorted&&this.sortReset(i.children),i.sorted=!1)}}updateWorldTransform(e){this._update++,this.drawOrder.appliedPose===this.drawOrder.constrainedPose&&this.drawOrder.resetConstrained();const s=this.resetCache;for(let i=0,r=this.resetCache.length;i<r;i++)s[i].resetConstrained();const n=this._updateCache;for(let i=0,r=this._updateCache.length;i<r;i++)n[i].update(this,e)}setupPose(){this.setupPoseBones(),this.setupPoseSlots()}setupPoseBones(){const e=this.bones;for(let n=0,i=e.length;n<i;n++)e[n].setupPose();const s=this.constraints;for(let n=0,i=s.length;n<i;n++)s[n].setupPose()}setupPoseSlots(){this.drawOrder.setupPose();const e=this.slots;for(let s=0,n=e.length;s<n;s++)e[s].setupPose()}getRootBone(){return this.bones.length===0?null:this.bones[0]}findBone(e){if(!e)throw new Error("boneName cannot be null.");const s=this.bones;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===e)return s[n];return null}findSlot(e){if(!e)throw new Error("slotName cannot be null.");const s=this.slots;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===e)return s[n];return null}setSkin(e){typeof e=="string"?this.setSkinByName(e):this.setSkinBySkin(e)}setSkinByName(e){const s=this.data.findSkin(e);if(!s)throw new Error(`Skin not found: ${e}`);this.setSkin(s)}setSkinBySkin(e){if(e!==this.skin){if(e)if(this.skin)e.attachAll(this,this.skin);else{const s=this.slots;for(let n=0,i=s.length;n<i;n++){const r=s[n],a=r.data.attachmentName;if(a){const c=e.getAttachment(n,a);c&&r.pose.setAttachment(c)}}}this.skin=e,this.updateCache()}}getAttachment(e,s){return typeof e=="string"?this.getAttachmentByName(e,s):this.getAttachmentByIndex(e,s)}getAttachmentByName(e,s){const n=this.data.findSlot(e);if(!n)throw new Error(`Can't find slot with name ${e}`);return this.getAttachment(n.index,s)}getAttachmentByIndex(e,s){if(!s)throw new Error("placeholder cannot be null.");if(this.skin){const n=this.skin.getAttachment(e,s);if(n)return n}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(e,s):null}setAttachment(e,s){if(!e)throw new Error("slotName cannot be null.");const n=this.findSlot(e);if(!n)throw new Error(`Slot not found: ${e}`);let i=null;if(s&&(i=this.getAttachment(n.data.index,s),!i))throw new Error(`Attachment not found: ${s}, for slot: ${e}`);n.pose.setAttachment(i)}findConstraint(e,s){if(e==null)throw new Error("constraintName cannot be null.");if(s==null)throw new Error("type cannot be null.");const n=this.constraints;for(let i=0,r=n.length;i<r;i++){const a=n[i];if(a instanceof s&&a.data.name===e)return a}return null}getBoundsRect(e){const s=new Ie,n=new Ie;return this.getBounds(s,n,void 0,e),{x:s.x,y:s.y,width:n.x,height:n.y}}getBounds(e,s,n=new Array(2),i=null){if(!e)throw new Error("offset cannot be null.");if(!s)throw new Error("size cannot be null.");const r=this.drawOrder.appliedPose,a=r;let c=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let d=0,m=r.length;d<m;d++){const u=a[d];if(!u.bone.active)continue;let f=0,p=null,g=null;const b=u.appliedPose.attachment;if(b){if(b instanceof j)f=8,p=L.setArraySize(n,f,0),b.computeWorldVertices(u,b.getOffsets(u.appliedPose),p,0,2),g=Te.quadTriangles;else if(b instanceof wt)f=b.worldVerticesLength,p=L.setArraySize(n,f,0),b.computeWorldVertices(this,u,0,f,p,0,2),g=b.triangles;else if(b instanceof zt&&i){i.clipEnd(u),i.clipStart(this,u,b);continue}if(p&&g){i?.isClipping()&&i.clipTriangles(p,g,g.length)&&(p=i.clippedVertices,f=i.clippedVertices.length);for(let x=0,w=p.length;x<w;x+=2){const S=p[x],y=p[x+1];c=Math.min(c,S),l=Math.min(l,y),o=Math.max(o,S),h=Math.max(h,y)}}}i&&i.clipEnd(u)}i&&i.clipEnd(),e.set(c,l),s.set(o-c,h-l)}setScale(e,s){this.scaleX=e,this.scaleY=s}setPosition(e,s){this.x=e,this.y=s}update(e){this.time+=e}physicsTranslate(e,s){const n=this.physics;for(let i=0,r=n.length;i<r;i++)n[i].translate(e,s)}physicsRotate(e,s,n){const i=this.physics;for(let r=0,a=i.length;r<a;r++)i[r].rotate(e,s,n)}},As=class En extends Et{bone;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xLag=0;xVelocity=0;yOffset=0;yLag=0;yVelocity=0;rotateOffset=0;rotateLag=0;rotateVelocity=0;scaleOffset=0;scaleLag=0;scaleVelocity=0;remaining=0;lastTime=0;constructor(e,s){if(super(e,new he,new he),s==null)throw new Error("skeleton cannot be null.");this.bone=s.bones[e.bone.index].constrainedPose}copy(e){var s=new En(this.data,e);return s.pose.set(this.pose),s}reset(e){this.remaining=0,this.lastTime=e.time,this._reset=!0,this.xOffset=0,this.xLag=0,this.xVelocity=0,this.yOffset=0,this.yLag=0,this.yVelocity=0,this.rotateOffset=0,this.rotateLag=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleLag=0,this.scaleVelocity=0}translate(e,s){this.ux-=e,this.uy-=s,this.cx-=e,this.cy-=s}rotate(e,s,n){const i=n*R.degRad,r=Math.cos(i),a=Math.sin(i),c=this.cx-e,l=this.cy-s;this.translate(c*r-l*a-c,c*a+l*r-l)}update(e,s){const n=this.appliedPose,i=n.mix;if(i===0)return;const r=this.data.x>0,a=this.data.y>0,c=this.data.rotate>0||this.data.shearX>0,l=this.data.scaleX>0,o=this.bone;let h=o.bone.data.length,d=this.data.step,m=0;if(s!==0){switch(o.modifyWorld(e),s){case 1:this.reset(e);case 2:{const u=Math.max(e.time-this.lastTime,0),f=this.remaining;this.remaining+=u,this.lastTime=e.time;const p=o.worldX,g=o.worldY;if(this._reset)this._reset=!1,this.ux=p,this.uy=g;else{let b=this.remaining,x=n.inertia,w=e.data.referenceScale,S=-1,y=0,v=0,T=this.data.limit*u,A=T*Math.abs(e.scaleY);if(T*=Math.abs(e.scaleX),r||a){if(r){const M=(this.ux-p)*x;this.xOffset+=M>T?T:M<-T?-T:M,this.ux=p}if(a){const M=(this.uy-g)*x;this.yOffset+=M>A?A:M<-A?-A:M,this.uy=g}if(b>=d){const M=this.xOffset,C=this.yOffset;S=n.damping**(60*d),y=d*n.massInverse,v=n.strength;const Y=w*n.wind,P=w*n.gravity,E=(Y*e.windX+P*e.gravityX)*e.scaleX,X=(Y*e.windY+P*e.gravityY)*e.scaleY;do r&&(this.xVelocity+=(E-this.xOffset*v)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=S),a&&(this.yVelocity-=(X+this.yOffset*v)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=S),b-=d;while(b>=d);this.xLag=this.xOffset-M,this.yLag=this.yOffset-C}m=Math.max(0,1-b/d),r&&(o.worldX+=(this.xOffset-this.xLag*m)*i*this.data.x),a&&(o.worldY+=(this.yOffset-this.yLag*m)*i*this.data.y)}if(c||l){let M=Math.atan2(o.c,o.a),C=0,Y=0,P=0,E=this.cx-o.worldX,X=this.cy-o.worldY;if(E>T?E=T:E<-T&&(E=-T),X>A?X=A:X<-A&&(X=-A),b=this.remaining,c){P=(this.data.rotate+this.data.shearX)*i,m=this.rotateLag*Math.max(0,1-f/d);let V=Math.atan2(X+this.ty,E+this.tx)-M-(this.rotateOffset-m)*P;this.rotateOffset+=(V-Math.ceil(V*R.invPI2-.5)*R.PI2)*x,V=(this.rotateOffset-m)*P+M,C=Math.cos(V),Y=Math.sin(V),l&&(V=h*o.getWorldScaleX(),V>0&&(this.scaleOffset+=(E*C+X*Y)*x/V))}else{C=Math.cos(M),Y=Math.sin(M);const V=h*o.getWorldScaleX()-this.scaleLag*Math.max(0,1-f/d);V>0&&(this.scaleOffset+=(E*C+X*Y)*x/V)}if(b>=d){S===-1&&(S=n.damping**(60*d),y=d*n.massInverse,v=n.strength);const V=n.wind*e.windX+n.gravity*e.gravityX,N=(n.wind*e.windY+n.gravity*e.gravityY)*hn.yDir,$=this.rotateOffset,U=this.scaleOffset,F=h/w;for(;;)if(b-=d,l&&(this.scaleVelocity+=(V*C-N*Y-this.scaleOffset*v)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=S),c){if(this.rotateVelocity-=((V*Y+N*C)*F+this.rotateOffset*v)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=S,b<d)break;const k=this.rotateOffset*P+M;C=Math.cos(k),Y=Math.sin(k)}else if(b<d)break;this.rotateLag=this.rotateOffset-$,this.scaleLag=this.scaleOffset-U}m=Math.max(0,1-b/d)}this.remaining=b}this.cx=o.worldX,this.cy=o.worldY;break}case 3:m=Math.max(0,1-this.remaining/d),r&&(o.worldX+=(this.xOffset-this.xLag*m)*i*this.data.x),a&&(o.worldY+=(this.yOffset-this.yLag*m)*i*this.data.y)}if(c){let u=(this.rotateOffset-this.rotateLag*m)*i,f=0,p=0,g=0;if(this.data.shearX>0){let b=0;this.data.rotate>0&&(b=u*this.data.rotate,f=Math.sin(b),p=Math.cos(b),g=o.b,o.b=p*g-f*o.d,o.d=f*g+p*o.d),b+=u*this.data.shearX,f=Math.sin(b),p=Math.cos(b),g=o.a,o.a=p*g-f*o.c,o.c=f*g+p*o.c}else u*=this.data.rotate,f=Math.sin(u),p=Math.cos(u),g=o.a,o.a=p*g-f*o.c,o.c=f*g+p*o.c,g=o.b,o.b=p*g-f*o.d,o.d=f*g+p*o.d}if(l){let u=1+(this.scaleOffset-this.scaleLag*m)*i*this.data.scaleX;switch(o.a*=u,o.c*=u,this.data.scaleYMode){case 1:o.b*=u,o.d*=u;break;case 2:u=Math.abs(u),u=u>=.7?1/u:4-3.67347*u,o.b*=u,o.d*=u}}s!==3&&(this.tx=h*o.a,this.ty=h*o.c)}}sort(e){const s=this.bone.bone;e.sortBone(s),e._updateCache.push(this),e.sortReset(s.children),e.constrained(s)}isSourceActive(){return this.bone.bone.active}},Gt=class extends Xt{set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}_bone=null;x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;_scaleYMode=0;get scaleYMode(){return this._scaleYMode}set scaleYMode(t){if(t==null)throw new Error("scaleYMode cannot be null.");this._scaleYMode=t}constructor(t){super(t,new he)}create(t){return new As(this,t)}};typeof Math.fround>"u"&&(Math.fround=(t=>e=>(t[0]=e,t[0]))(new Float32Array(1)));var fe=class{time=0;mix=0;set(t){this.time=t.time,this.mix=t.mix}},dn=class Us extends Et{static offsets=[0,0,0,0,0,0];bone=null;constructor(e,s){if(super(e,new fe,new fe),!s)throw new Error("skeleton cannot be null.");e.bone!=null&&(this.bone=s.bones[e.bone.index])}copy(e){var s=new Us(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.data,r=i.animation,a=this.bone;if(a!==null){if(!a.active)return;i.local&&a.appliedPose.validateLocalTransform(e),n.time=i.offset+(i.property.value(e,a.appliedPose,i.local,Us.offsets)-i.property.offset)*i.scale,i.loop?n.time=r.duration+n.time%r.duration:n.time=Math.max(0,n.time)}const c=e.bones,l=r.bones;for(let o=0,h=r.bones.length;o<h;o++)c[l[o]].appliedPose.modifyLocal(e);r.apply(e,n.time,n.time,i.loop,null,n.mix,0,i.additive,!1,!0)}sort(e){const s=this.bone,n=this.data;s&&!n.local&&e.sortBone(s),e._updateCache.push(this);const i=e.bones,r=n.animation.bones;for(let d=0,m=n.animation.bones.length;d<m;d++){const u=i[r[d]];u.sorted=!1,e.sortReset(u.children),e.constrained(u)}const a=n.animation.timelines,c=e.slots,l=e.constraints,o=e.physics,h=e.physics.length;for(let d=0,m=n.animation.timelines.length;d<m;d++){const u=a[d];if(Gs(u))e.constrained(c[u.slotIndex]);else if(u instanceof At||u instanceof qt)e.drawOrder.constrained();else if(u instanceof bt)if(u.constraintIndex===-1)for(let f=0;f<h;f++)e.constrained(o[f]);else e.constrained(l[u.constraintIndex]);else if(Ks(u)){const f=u.constraintIndex;f!==-1&&e.constrained(l[f])}}}},St=class extends Xt{animation;additive=!1;loop=!1;bone=null;property;scale=0;offset=0;local=!1;max=0;constructor(t){super(t,new fe)}create(t){return new dn(this,t)}},Is=class{name=null;bones=[];slots=[];skins=[];defaultSkin=null;events=[];animations=[];constraints=[];x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=30;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");const e=this.bones;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");const e=this.slots;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSkin(t){if(!t)throw new Error("skinName cannot be null.");const e=this.skins;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findEvent(t){if(!t)throw new Error("eventDataName cannot be null.");const e=this.events;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findSliderAnimations(t){const e=this.constraints;for(let s=0,n=this.constraints.length;s<n;s++){const i=e[s];i instanceof St&&i.animation!=null&&t.push(i.animation)}return t}findAnimation(t){if(!t)throw new Error("animationName cannot be null.");const e=this.animations;for(let s=0,n=e.length;s<n;s++)if(e[s].name===t)return e[s];return null}findConstraint(t,e){if(!t)throw new Error("constraintName cannot be null.");if(e==null)throw new Error("type cannot be null.");const s=this.constraints;for(let n=0,i=this.constraints.length;n<i;n++){const r=s[n];if(r instanceof e&&r.name===t)return r}return null}},Cs=class{slotIndex=0;placeholder;attachment;constructor(t=0,e,s){this.slotIndex=t,this.placeholder=e,this.attachment=s}},ue=class{name;attachments=[];bones=[];constraints=[];color=new z(.99607843,.61960787,.30980393,1);constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}setAttachment(t,e,s){if(!s)throw new Error("attachment cannot be null.");const n=this.attachments;t>=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=s}addSkin(t){for(let s=0;s<t.bones.length;s++){const n=t.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<t.constraints.length;s++){const n=t.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const e=t.getAttachments();for(let s=0;s<e.length;s++){const n=e[s];this.setAttachment(n.slotIndex,n.placeholder,n.attachment)}}copySkin(t){for(let s=0;s<t.bones.length;s++){const n=t.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<t.constraints.length;s++){const n=t.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const e=t.getAttachments();for(let s=0;s<e.length;s++){const n=e[s];n.attachment&&(n.attachment instanceof wt?(n.attachment=n.attachment.newLinkedMesh(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)):(n.attachment=n.attachment.copy(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)))}}getAttachment(t,e){const s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){const s=this.attachments[t];s&&delete s[e]}getAttachments(){const t=[];for(let e=0;e<this.attachments.length;e++){const s=this.attachments[e];if(s)for(const n in s){const i=s[n];i&&t.push(new Cs(e,n,i))}}return t}getAttachmentsForSlot(t,e){const s=this.attachments[t];if(s)for(const n in s){const i=s[n];i&&e.push(new Cs(t,n,i))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let n=0;n<t.slots.length;n++){const i=t.slots[n],r=i.pose.getAttachment();if(r&&s<e.attachments.length){const a=e.attachments[s];for(const c in a){const l=a[c];if(r===l){const o=this.getAttachment(s,c);o&&i.pose.setAttachment(o);break}}}s++}}},Ms=class extends se{index=0;boneData;attachmentName=null;blendMode=0;visible=!0;constructor(t,e,s){if(super(e,new de),t<0)throw new Error("index must be >= 0.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.boneData=s}},Ys=(t=>(t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen",t))(Ys||{}),me=class{mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;set(t){this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}},fn=class Xn extends Et{bones;source;constructor(e,s){if(super(e,new me,new me),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const i of e.bones)this.bones.push(s.bones[i.index].constrainedPose);const n=s.bones[e.source.index];if(n==null)throw new Error("source cannot be null.");this.source=n}copy(e){var s=new Xn(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.appliedPose;if(n.mixRotate===0&&n.mixX===0&&n.mixY===0&&n.mixScaleX===0&&n.mixScaleY===0&&n.mixShearY===0)return;const i=this.data,r=i.localSource,a=i.localTarget,c=i.additive,l=i.clamp,o=i.offsets,h=this.source.appliedPose;r&&h.validateLocalTransform(e);const d=i.properties,m=i.properties.length,u=this.bones;for(let f=0,p=this.bones.length;f<p;f++){const g=u[f];a?g.modifyLocal(e):g.modifyWorld(e);for(let b=0;b<m;b++){const x=d[b],w=x.value(e,h,r,o)-x.offset,S=x.to;for(let y=0,v=x.to.length;y<v;y++){const T=S[y];if(T.mix(n)!==0){let A=T.offset+w*T.scale;l&&(T.offset<T.max?A=R.clamp(A,T.offset,T.max):A=R.clamp(A,T.max,T.offset)),T.apply(e,n,g,A,a,c)}}}}}sort(e){this.data.localSource||e.sortBone(this.source);const s=this.bones,n=this.bones.length,i=!this.data.localTarget;if(i)for(let r=0;r<n;r++)e.sortBone(s[r].bone);e._updateCache.push(this);for(let r=0;r<n;r++){const a=s[r].bone;e.sortReset(a.children),e.constrained(a)}for(let r=0;r<n;r++)s[r].bone.sorted=i}isSourceActive(){return this.source.active}},K=class ht extends Xt{static ROTATION=0;static X=1;static Y=2;static SCALEX=3;static SCALEY=4;static SHEARY=5;bones=[];set source(e){this._source=e}get source(){if(this._source)return this._source;throw new Error("BoneData not set.")}_source=null;offsets=[0,0,0,0,0,0];offsetX=0;offsetY=0;localSource=!1;localTarget=!1;additive=!1;clamp=!1;properties=[];constructor(e){super(e,new me)}create(e){return new fn(this,e)}getOffsetRotation(){return this.offsets[ht.ROTATION]}setOffsetRotation(e){this.offsets[ht.ROTATION]=e}getOffsetX(){return this.offsets[ht.X]}setOffsetX(e){this.offsets[ht.X]=e}getOffsetY(){return this.offsets[ht.Y]}setOffsetY(e){this.offsets[ht.Y]=e}getOffsetScaleX(){return this.offsets[ht.SCALEX]}setOffsetScaleX(e){this.offsets[ht.SCALEX]=e}getOffsetScaleY(){return this.offsets[ht.SCALEY]}setOffsetScaleY(e){this.offsets[ht.SCALEY]=e}getOffsetShearY(){return this.offsets[ht.SHEARY]}setOffsetShearY(e){this.offsets[ht.SHEARY]=e}},It=class{offset=0;to=[]},Ct=class{offset=0;max=0;scale=0},ge=class extends It{value(t,e,s,n){if(s)return e.rotation+n[K.ROTATION];const i=t.scaleX,r=t.scaleY;let a=Math.atan2(e.c/r,e.a/i)*R.radDeg+((e.a*e.d-e.b*e.c)*i*r>0?n[K.ROTATION]:-n[K.ROTATION]);return a<0&&(a+=360),a}},Fs=class extends Ct{mix(t){return t.mixRotate}apply(t,e,s,n,i,r){if(i)s.rotation+=(r?n:n-s.rotation)*e.mixRotate;else{const a=t.scaleX,c=t.scaleY,l=1/a,o=1/c,h=s.a*l,d=s.b*l,m=s.c*o,u=s.d*o;n*=R.degRad,r||(n-=Math.atan2(m,h)),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2),n*=e.mixRotate;const f=Math.cos(n),p=Math.sin(n);s.a=(f*h-p*m)*a,s.b=(f*d-p*u)*a,s.c=(p*h+f*m)*c,s.d=(p*d+f*u)*c}}},pe=class extends It{value(t,e,s,n){return s?e.x+n[K.X]:(n[K.X]*e.a+n[K.Y]*e.b+e.worldX)/t.scaleX}},ks=class extends Ct{mix(t){return t.mixX}apply(t,e,s,n,i,r){i?s.x+=(r?n:n-s.x)*e.mixX:(r||(n-=s.worldX/t.scaleX),s.worldX+=n*e.mixX*t.scaleX)}},be=class extends It{value(t,e,s,n){return s?e.y+n[K.Y]:(n[K.X]*e.c+n[K.Y]*e.d+e.worldY)/t.scaleY}},Ps=class extends Ct{mix(t){return t.mixY}apply(t,e,s,n,i,r){i?s.y+=(r?n:n-s.y)*e.mixY:(r||(n-=s.worldY/t.scaleY),s.worldY+=n*e.mixY*t.scaleY)}},xe=class extends It{value(t,e,s,n){if(s)return e.scaleX+n[K.SCALEX];const i=e.a/t.scaleX,r=e.c/t.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEX]}},Es=class extends Ct{mix(t){return t.mixScaleX}apply(t,e,s,n,i,r){if(i)r?s.scaleX*=1+(n-1)*e.mixScaleX:s.scaleX!==0&&(s.scaleX+=(n-s.scaleX)*e.mixScaleX);else if(r){const a=1+(n-1)*e.mixScaleX;s.a*=a,s.c*=a}else{let a=s.a/t.scaleX,c=s.c/t.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*e.mixScaleX/l,s.a*=l,s.c*=l)}}},we=class extends It{value(t,e,s,n){if(s)return e.scaleY+n[K.SCALEY];const i=e.b/t.scaleX,r=e.d/t.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEY]}},Xs=class extends Ct{mix(t){return t.mixScaleY}apply(t,e,s,n,i,r){if(i)r?s.scaleY*=1+(n-1)*e.mixScaleY:s.scaleY!==0&&(s.scaleY+=(n-s.scaleY)*e.mixScaleY);else if(r){const a=1+(n-1)*e.mixScaleY;s.b*=a,s.d*=a}else{let a=s.b/t.scaleX,c=s.d/t.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*e.mixScaleY/l,s.b*=l,s.d*=l)}}},ye=class extends It{value(t,e,s,n){if(s)return e.shearY+n[K.SHEARY];const i=1/t.scaleX,r=1/t.scaleY;return(Math.atan2(e.d*r,e.b*i)-Math.atan2(e.c*r,e.a*i))*R.radDeg-90+n[K.SHEARY]}},Vs=class extends Ct{mix(t){return t.mixShearY}apply(t,e,s,n,i,r){if(i)r||(n-=s.shearY),s.shearY+=n*e.mixShearY;else{const a=t.scaleX,c=t.scaleY,l=s.b/a,o=s.d/c,h=Math.atan2(o,l);n=(n+90)*R.degRad,r?n-=R.PI/2:(n-=h-Math.atan2(s.c/c,s.a/a),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2)),n=h+n*e.mixShearY;const d=Math.sqrt(l*l+o*o);s.b=Math.cos(n)*d*a,s.d=Math.sin(n)*d*c}}},zn=class{scale=1;attachmentLoader;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Is;s.name="";const n=new un(t),i=n.readInt32(),r=n.readInt32();s.hash=r===0&&i===0?null:r.toString(16)+i.toString(16),s.version=n.readString(),s.x=n.readFloat(),s.y=n.readFloat(),s.width=n.readFloat(),s.height=n.readFloat(),s.referenceScale=n.readFloat()*e;const a=n.readBoolean();a&&(s.fps=n.readFloat(),s.imagesPath=n.readString(),s.audioPath=n.readString());let c=0;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("String in string table must not be null.");n.strings.push(f)}const l=s.bones;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Bone name must not be null.");const p=u===0?null:l[n.readInt(!0)],g=new bs(u,f,p),b=g.setupPose;b.rotation=n.readFloat(),b.x=n.readFloat()*e,b.y=n.readFloat()*e,b.scaleX=n.readFloat(),b.scaleY=n.readFloat(),b.shearX=n.readFloat(),b.shearY=n.readFloat(),b.inherit=n.readByte(),g.length=n.readFloat()*e,g.skinRequired=n.readBoolean(),a&&(z.rgba8888ToColor(g.color,n.readInt32()),g.icon=n.readString()??void 0,g.iconSize=n.readFloat(),g.iconRotation=n.readFloat(),g.visible=n.readBoolean()),l.push(g)}c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Slot name must not be null.");const p=l[n.readInt(!0)],g=new Ms(u,f,p);z.rgba8888ToColor(g.setupPose.color,n.readInt32());const b=n.readInt32();b!==-1&&z.rgb888ToColor(g.setupPose.darkColor=new z,b),g.attachmentName=n.readStringRef(),g.blendMode=n.readInt(!0),a&&(g.visible=n.readBoolean()),s.slots.push(g)}const o=s.constraints,h=n.readInt(!0);for(let u=0;u<h;u++){const f=n.readString();if(!f)throw new Error("Constraint data name must not be null.");let p;switch(n.readByte()){case fi:{const g=new Wt(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.target=l[n.readInt(!0)];const b=n.readByte();g.skinRequired=(b&1)!==0,(b&2)!==0&&(g.scaleYMode=n.readUnsignedByte());const x=g.setupPose;x.bendDirection=(b&4)!==0?-1:1,x.compress=(b&8)!==0,x.stretch=(b&16)!==0,(b&32)!==0&&(x.mix=(b&64)!==0?n.readFloat():1),(b&128)!==0&&(x.softness=n.readFloat()*e),o.push(g);break}case mi:{const g=new K(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.source=l[n.readInt(!0)];let b=n.readUnsignedByte();g.skinRequired=(b&1)!==0,g.localSource=(b&2)!==0,g.localTarget=(b&4)!==0,g.additive=(b&8)!==0,g.clamp=(b&16)!==0,p=b>>5;for(let w=0,S;w<p;w++){let y=1,v;switch(n.readByte()){case 0:v=new ge;break;case 1:{y=e,v=new pe;break}case 2:{y=e,v=new be;break}case 3:v=new xe;break;case 4:v=new we;break;case 5:v=new ye;break;default:v=null}if(v){v.offset=n.readFloat()*y,S=n.readByte();for(let T=0;T<S;T++){let A=1,M;switch(n.readByte()){case 0:M=new Fs;break;case 1:{A=e,M=new ks;break}case 2:{A=e,M=new Ps;break}case 3:M=new Es;break;case 4:M=new Xs;break;case 5:M=new Vs;break;default:M=null}M&&(M.offset=n.readFloat()*A,M.max=n.readFloat()*A,M.scale=n.readFloat()*A/y,v.to[T]=M)}g.properties[w]=v}}b=n.readByte(),(b&1)!==0&&(g.offsets[K.ROTATION]=n.readFloat()),(b&2)!==0&&(g.offsets[K.X]=n.readFloat()*e),(b&4)!==0&&(g.offsets[K.Y]=n.readFloat()*e),(b&8)!==0&&(g.offsets[K.SCALEX]=n.readFloat()),(b&16)!==0&&(g.offsets[K.SCALEY]=n.readFloat()),(b&32)!==0&&(g.offsets[K.SHEARY]=n.readFloat()),b=n.readByte();const x=g.setupPose;(b&1)!==0&&(x.mixRotate=n.readFloat()),(b&2)!==0&&(x.mixX=n.readFloat()),(b&4)!==0&&(x.mixY=n.readFloat()),(b&8)!==0&&(x.mixScaleX=n.readFloat()),(b&16)!==0&&(x.mixScaleY=n.readFloat()),(b&32)!==0&&(x.mixShearY=n.readFloat()),o.push(g);break}case ui:{const g=new Ht(f);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(l[n.readInt(!0)]);g.slot=s.slots[n.readInt(!0)];const b=n.readByte();g.skinRequired=(b&1)!==0,g.positionMode=b>>1&1,g.spacingMode=b>>2&3,g.rotateMode=b>>4&3,(b&128)!==0&&(g.offsetRotation=n.readFloat());const x=g.setupPose;x.position=n.readFloat(),g.positionMode===0&&(x.position*=e),x.spacing=n.readFloat(),(g.spacingMode===0||g.spacingMode===1)&&(x.spacing*=e),x.mixRotate=n.readFloat(),x.mixX=n.readFloat(),x.mixY=n.readFloat(),o.push(g);break}case gi:{const g=new Gt(f);g.bone=l[n.readInt(!0)];let b=n.readByte();if(g.skinRequired=(b&1)!==0,(b&2)!==0&&(g.x=n.readFloat()),(b&4)!==0&&(g.y=n.readFloat()),(b&8)!==0&&(g.rotate=n.readFloat()),(b&16)!==0){let w=n.readFloat();w<-2?(g.scaleYMode=2,w=-2-w):w<0&&(g.scaleYMode=1,w=-1-w),g.scaleX=w}(b&32)!==0&&(g.shearX=n.readFloat()),g.limit=((b&64)!==0?n.readFloat():5e3)*e,g.step=1/n.readUnsignedByte();const x=g.setupPose;x.inertia=n.readFloat(),x.strength=n.readFloat(),x.damping=n.readFloat(),x.massInverse=(b&128)!==0?n.readFloat():1,x.wind=n.readFloat(),x.gravity=n.readFloat(),b=n.readByte(),(b&1)!==0&&(g.inertiaGlobal=!0),(b&2)!==0&&(g.strengthGlobal=!0),(b&4)!==0&&(g.dampingGlobal=!0),(b&8)!==0&&(g.massGlobal=!0),(b&16)!==0&&(g.windGlobal=!0),(b&32)!==0&&(g.gravityGlobal=!0),(b&64)!==0&&(g.mixGlobal=!0),x.mix=(b&128)!==0?n.readFloat():1,o.push(g);break}case pi:{const g=new St(f),b=n.readByte();if(g.skinRequired=(b&1)!==0,g.loop=(b&2)!==0,g.additive=(b&4)!==0,(b&8)!==0){const x=n.readFloat();a&&(b&64)!==0?g.max=x:g.setupPose.time=x}if((b&16)!==0&&(g.setupPose.mix=(b&32)!==0?n.readFloat():1),(b&64)!==0){g.local=(b&128)!==0,g.bone=l[n.readInt(!0)];const x=n.readFloat();let w=1;switch(n.readByte()){case 0:g.property=new ge;break;case 1:{w=e,g.property=new pe;break}case 2:{w=e,g.property=new be;break}case 3:g.property=new xe;break;case 4:g.property=new we;break;case 5:g.property=new ye;break;default:continue}g.property.offset=x*w,g.offset=n.readFloat(),g.scale=n.readFloat()/w}o.push(g);break}}}const d=this.readSkin(n,s,!0,a);d&&(s.defaultSkin=d,s.skins.push(d));{let u=s.skins.length;for(L.setArraySize(s.skins,c=u+n.readInt(!0));u<c;u++){const f=this.readSkin(n,s,!1,a);if(!f)throw new Error("readSkin() should not have returned null.");s.skins[u]=f}}c=this.linkedMeshes.length;for(let u=0;u<c;u++){const f=this.linkedMeshes[u],p=s.skins[f.skinIndex];if(!f.source)throw new Error("Linked mesh parent must not be null");const g=p.getAttachment(f.sourceIndex,f.source);if(!g)throw new Error(`Source mesh not found: ${f.source}`);f.mesh.timelineAttachment=f.inheritTimelines?g:f.mesh,f.mesh.setSourceMesh(g),f.mesh.updateSequence()}this.linkedMeshes.length=0,c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Event data name must not be null");const p=new ys(f),g=p.setupPose;g.intValue=n.readInt(!1),g.floatValue=n.readFloat(),g.stringValue=n.readString(),p._audioPath=n.readString(),p.audioPath&&(g.volume=n.readFloat(),g.balance=n.readFloat()),s.events.push(p)}const m=s.animations;c=n.readInt(!0);for(let u=0;u<c;u++){const f=n.readString();if(!f)throw new Error("Animation name must not be null.");m.push(this.readAnimation(n,f,s,a))}for(let u=0;u<h;u++){const f=o[u];f instanceof St&&(f.animation=m[n.readInt(!0)])}return s}readSkin(t,e,s,n){let i=null,r=0;if(s){if(r=t.readInt(!0),r===0)return null;i=new ue("default")}else{const a=t.readString();if(!a)throw new Error("Skin name must not be null.");i=new ue(a),n&&z.rgba8888ToColor(i.color,t.readInt32());let c=t.readInt(!0),l=e.bones,o=i.bones;for(let h=0;h<c;h++)o[h]=l[t.readInt(!0)];c=t.readInt(!0),l=e.constraints,o=i.constraints;for(let h=0;h<c;h++)o[h]=l[t.readInt(!0)];r=t.readInt(!0)}for(let a=0;a<r;a++){const c=t.readInt(!0);for(let l=0,o=t.readInt(!0);l<o;l++){const h=t.readStringRef();if(!h)throw new Error("Attachment name must not be null");const d=this.readAttachment(t,e,i,c,h,n);d&&i.setAttachment(c,h,d)}}return i}readAttachment(t,e,s,n,i,r){const a=this.scale,c=t.readByte(),l=(c&8)!==0?t.readStringRef():i;if(!l)throw new Error("Attachment name must not be null");switch(c&7){case 0:{let o=(c&16)!==0?t.readStringRef():null;const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=(c&128)!==0?t.readFloat():0,u=t.readFloat(),f=t.readFloat(),p=t.readFloat(),g=t.readFloat(),b=t.readFloat(),x=t.readFloat();o||(o=l);const w=this.attachmentLoader.newRegionAttachment(s,i,l,o,d);return w?(w.path=o,w.x=u*a,w.y=f*a,w.scaleX=p,w.scaleY=g,w.rotation=m,w.width=b*a,w.height=x*a,z.rgba8888ToColor(w.color,h),w.updateSequence(),w):null}case 1:{const o=this.readVertices(t,(c&16)!==0),h=r?t.readInt32():0,d=this.attachmentLoader.newBoundingBoxAttachment(s,i,l);return d?(d.worldVerticesLength=o.length,d.vertices=o.vertices,d.bones=o.bones,r&&z.rgba8888ToColor(d.color,h),d):null}case 2:{let o=(c&16)!==0?t.readStringRef():l;const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=t.readInt(!0),u=this.readVertices(t,(c&128)!==0),f=this.readFloatArray(t,u.length,1),p=this.readShortArray(t,(u.length-m-2)*3),g=t.readInt(!0);let b=null;if(g>0){b=[];for(let v=0;v<g;v++)b[v]=t.readInt(!0)}let x=[],w=0,S=0;r&&(x=this.readShortArray(t,t.readInt(!0)),w=t.readFloat(),S=t.readFloat()),o||(o=l);const y=this.attachmentLoader.newMeshAttachment(s,i,l,o,d);return y?(y.path=o,z.rgba8888ToColor(y.color,h),y.hullLength=m<<1,y.bones=u.bones,y.vertices=u.vertices,y.worldVerticesLength=u.length,y.regionUVs=f,y.triangles=p,b&&(y.timelineSlots=b),r&&(y.edges=x,y.width=w*a,y.height=S*a),y.updateSequence(),y):null}case 3:{const o=(c&16)!==0?t.readStringRef():l;if(o==null)throw new Error("Path of linked mesh must not be null");const h=(c&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(c&64)!==0),m=(c&128)!==0,u=t.readInt(!0),f=t.readInt(!0),p=t.readStringRef();let g=0,b=0;r&&(g=t.readFloat(),b=t.readFloat());const x=this.attachmentLoader.newMeshAttachment(s,i,l,o,d);return x?(x.path=o,z.rgba8888ToColor(x.color,h),r&&(x.width=g*a,x.height=b*a),this.linkedMeshes.push(new Wn(x,f,n,u,p,m)),x):null}case 4:{const o=(c&16)!==0,h=(c&32)!==0,d=this.readVertices(t,(c&64)!==0),m=this.readFloatArray(t,d.length/6,a),u=r?t.readInt32():0,f=this.attachmentLoader.newPathAttachment(s,i,l);return f?(f.closed=o,f.constantSpeed=h,f.worldVerticesLength=d.length,f.vertices=d.vertices,f.bones=d.bones,f.lengths=m,r&&z.rgba8888ToColor(f.color,u),f):null}case 5:{const o=t.readFloat(),h=t.readFloat(),d=t.readFloat(),m=r?t.readInt32():0,u=this.attachmentLoader.newPointAttachment(s,i,l);return u?(u.x=h*a,u.y=d*a,u.rotation=o,r&&z.rgba8888ToColor(u.color,m),u):null}case 6:{const o=t.readInt(!0),h=this.readVertices(t,(c&16)!==0),d=r?t.readInt32():0,m=this.attachmentLoader.newClippingAttachment(s,i,l);return m?(m.endSlot=e.slots[o],m.convex=(c&32)!==0,m.inverse=(c&64)!==0,m.worldVerticesLength=h.length,m.vertices=h.vertices,m.bones=h.bones,r&&z.rgba8888ToColor(m.color,d),m):null}}}readSequence(t,e){if(!e)return new Nt(1,!1);const s=new Nt(t.readInt(!0),!0);return s.start=t.readInt(!0),s.digits=t.readInt(!0),s.setupIndex=t.readInt(!0),s}readVertices(t,e){const s=this.scale,i=t.readInt(!0)<<1;if(!e)return new mn(null,this.readFloatArray(t,i,s),i);const r=t.readInt(!0),a=[],c=[];for(let l=0,o=0;l<r;){const h=t.readInt(!0);a[l++]=h;for(let d=0;d<h;d++,o+=3)a[l++]=t.readInt(!0),c[o]=t.readFloat()*s,c[o+1]=t.readFloat()*s,c[o+2]=t.readFloat()}return new mn(a,L.toFloatArray(c),i)}readFloatArray(t,e,s){const n=[];if(s===1)for(let i=0;i<e;i++)n[i]=t.readFloat();else for(let i=0;i<e;i++)n[i]=t.readFloat()*s;return n}readShortArray(t,e){const s=[];for(let n=0;n<e;n++)s[n]=t.readInt(!0);return s}readAnimation(t,e,s,n){t.readInt(!0);const i=[],r=this.scale;for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0),w=x-1;switch(b){case oi:{const S=new kt(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat(),t.readStringRef());i.push(S);break}case ai:{const S=t.readInt(!0),y=new $e(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,C=t.readUnsignedByte()/255;for(let Y=0,P=0;y.setFrame(Y,v,T,A,M,C),Y!==w;Y++){const E=t.readFloat(),X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255,N=t.readUnsignedByte()/255,$=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(Y);break;case gt:H(t,y,P++,Y,0,v,E,T,X,1),H(t,y,P++,Y,1,v,E,A,V,1),H(t,y,P++,Y,2,v,E,M,N,1),H(t,y,P++,Y,3,v,E,C,$,1)}v=E,T=X,A=V,M=N,C=$}i.push(y);break}case ci:{const S=t.readInt(!0),y=new qe(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255;for(let C=0,Y=0;y.setFrame(C,v,T,A,M),C!==w;C++){const P=t.readFloat(),E=t.readUnsignedByte()/255,X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(C);break;case gt:H(t,y,Y++,C,0,v,P,T,E,1),H(t,y,Y++,C,1,v,P,A,X,1),H(t,y,Y++,C,2,v,P,M,V,1)}v=P,T=E,A=X,M=V}i.push(y);break}case li:{const S=t.readInt(!0),y=new ze(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,C=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,E=t.readUnsignedByte()/255;for(let X=0,V=0;y.setFrame(X,v,T,A,M,C,Y,P,E),X!==w;X++){const N=t.readFloat(),$=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,W=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(X);break;case gt:H(t,y,V++,X,0,v,N,T,$,1),H(t,y,V++,X,1,v,N,A,U,1),H(t,y,V++,X,2,v,N,M,F,1),H(t,y,V++,X,3,v,N,C,k,1),H(t,y,V++,X,4,v,N,Y,D,1),H(t,y,V++,X,5,v,N,P,O,1),H(t,y,V++,X,6,v,N,E,W,1)}v=N,T=$,A=U,M=F,C=k,Y=D,P=O,E=W}i.push(y);break}case hi:{const S=t.readInt(!0),y=new We(x,S,f);let v=t.readFloat(),T=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,C=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255;for(let E=0,X=0;y.setFrame(E,v,T,A,M,C,Y,P),E!==w;E++){const V=t.readFloat(),N=t.readUnsignedByte()/255,$=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255;switch(t.readByte()){case mt:y.setStepped(E);break;case gt:H(t,y,X++,E,0,v,V,T,N,1),H(t,y,X++,E,1,v,V,A,$,1),H(t,y,X++,E,2,v,V,M,U,1),H(t,y,X++,E,3,v,V,C,F,1),H(t,y,X++,E,4,v,V,Y,k,1),H(t,y,X++,E,5,v,V,P,D,1)}v=V,T=N,A=$,M=U,C=F,Y=k,P=D}i.push(y);break}case di:{const S=new _e(x,t.readInt(!0),f);let y=t.readFloat(),v=t.readUnsignedByte()/255;for(let T=0,A=0;S.setFrame(T,y,v),T!==w;T++){const M=t.readFloat(),C=t.readUnsignedByte()/255;switch(t.readByte()){case mt:S.setStepped(T);break;case gt:H(t,S,A++,T,0,y,M,v,C,1)}y=M,v=C}i.push(S)}}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0);if(b===ri){const S=new De(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat(),t.readByte());i.push(S);continue}const w=t.readInt(!0);switch(b){case jn:tt(t,i,new Dt(x,w,f),1);break;case Kn:tt(t,i,new Ee(x,w,f),r);break;case Jn:tt(t,i,new Xe(x,w,f),r);break;case Qn:tt(t,i,new Ve(x,w,f),r);break;case Zn:tt(t,i,new Re(x,w,f),1);break;case ti:tt(t,i,new Le(x,w,f),1);break;case ei:tt(t,i,new Be(x,w,f),1);break;case si:tt(t,i,new Oe(x,w,f),1);break;case ni:tt(t,i,new Ne(x,w,f),1);break;case ii:tt(t,i,new Ue(x,w,f),1);break}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new je(p,t.readInt(!0),f);let x=t.readByte(),w=t.readFloat(),S=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,y=(x&4)!==0?t.readFloat()*r:0;for(let v=0,T=0;b.setFrame(v,w,S,y,(x&8)!==0?1:-1,(x&16)!==0,(x&32)!==0),v!==g;v++){x=t.readByte();const A=t.readFloat(),M=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,C=(x&4)!==0?t.readFloat()*r:0;(x&64)!==0?b.setStepped(v):(x&128)!==0&&(H(t,b,T++,v,0,w,A,S,M,1),H(t,b,T++,v,1,w,A,y,C,r)),w=A,S=M,y=C}i.push(b)}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new Ke(p,t.readInt(!0),f);let x=t.readFloat(),w=t.readFloat(),S=t.readFloat(),y=t.readFloat(),v=t.readFloat(),T=t.readFloat(),A=t.readFloat();for(let M=0,C=0;b.setFrame(M,x,w,S,y,v,T,A),M!==g;M++){const Y=t.readFloat(),P=t.readFloat(),E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat(),$=t.readFloat();switch(t.readByte()){case mt:b.setStepped(M);break;case gt:H(t,b,C++,M,0,x,Y,w,P,1),H(t,b,C++,M,1,x,Y,S,E,1),H(t,b,C++,M,2,x,Y,y,X,1),H(t,b,C++,M,3,x,Y,v,V,1),H(t,b,C++,M,4,x,Y,T,N,1),H(t,b,C++,M,5,x,Y,A,$,1)}x=Y,w=P,S=E,y=X,v=V,T=N,A=$}i.push(b)}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0),p=s.constraints[f];for(let g=0,b=t.readInt(!0);g<b;g++){const x=t.readByte(),w=t.readInt(!0),S=t.readInt(!0);switch(x){case wi:tt(t,i,new Je(w,S,f),p.positionMode===0?r:1);break;case yi:tt(t,i,new Qe(w,S,f),p.spacingMode===0||p.spacingMode===1?r:1);break;case vi:{const y=new Ze(w,S,f);let v=t.readFloat(),T=t.readFloat(),A=t.readFloat(),M=t.readFloat();for(let C=0,Y=0,P=y.getFrameCount()-1;y.setFrame(C,v,T,A,M),C!==P;C++){const E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat();switch(t.readByte()){case mt:y.setStepped(C);break;case gt:H(t,y,Y++,C,0,v,E,T,X,1),H(t,y,Y++,C,1,v,E,A,V,1),H(t,y,Y++,C,2,v,E,M,N,1)}v=E,T=X,A=V,M=N}i.push(y)}}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0)-1;for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0);if(b===Fi){const S=new as(x,f);for(let y=0;y<x;y++)S.setFrame(y,t.readFloat());i.push(S);continue}const w=t.readInt(!0);switch(b){case Si:tt(t,i,new ts(x,w,f),1);break;case Ti:tt(t,i,new es(x,w,f),1);break;case Ai:tt(t,i,new ss(x,w,f),1);break;case Ii:tt(t,i,new ns(x,w,f),1);break;case Ci:tt(t,i,new is(x,w,f),1);break;case Mi:tt(t,i,new rs(x,w,f),1);break;case Yi:tt(t,i,new os(x,w,f),1);break;default:throw new Error("Unknown physics timeline type.")}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0),w=t.readInt(!0);switch(b){case ki:tt(t,i,new cs(x,w,f),1);break;case Pi:tt(t,i,new ls(x,w,f),1);break;default:throw new Error(`Uknown slider type: ${b}`)}}}for(let m=0,u=t.readInt(!0);m<u;m++){const f=s.skins[t.readInt(!0)];for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readInt(!0);for(let x=0,w=t.readInt(!0);x<w;x++){const S=t.readStringRef();if(!S)throw new Error("attachmentName must not be null.");const y=f.getAttachment(b,S),v=t.readByte(),T=t.readInt(!0),A=T-1;switch(v){case bi:{const M=y,C=M.bones,Y=M.vertices,P=C?Y.length/3*2:Y.length,E=t.readInt(!0),X=new He(T,E,b,M);let V=t.readFloat();for(let N=0,$=0;;N++){let U,F=t.readInt(!0);if(F===0)U=C?L.newFloatArray(P):Y;else{U=L.newFloatArray(P);const D=t.readInt(!0);if(F+=D,r===1)for(let O=D;O<F;O++)U[O]=t.readFloat();else for(let O=D;O<F;O++)U[O]=t.readFloat()*r;if(!C)for(let O=0,W=U.length;O<W;O++)U[O]+=Y[O]}if(X.setFrame(N,V,U),N===A)break;const k=t.readFloat();switch(t.readByte()){case mt:X.setStepped(N);break;case gt:H(t,X,$++,N,0,V,k,0,1,1)}V=k}i.push(X);break}case xi:{const M=new Ge(T,b,y);for(let C=0;C<T;C++){const Y=t.readFloat(),P=t.readInt32();M.setFrame(C,Y,Pe[P&15],P>>4,t.readFloat())}i.push(M);break}}}}}const a=s.slots.length,c=t.readInt(!0);if(c>0){const m=new At(c);for(let u=0;u<c;u++)m.setFrame(u,t.readFloat(),gn(t,a));i.push(m)}const l=t.readInt(!0);for(let m=0;m<l;m++){const u=t.readInt(!0),f=new Array(u);for(let b=0;b<u;b++)f[b]=t.readInt(!0);const p=t.readInt(!0),g=new qt(p,f,a);for(let b=0;b<p;b++)g.setFrame(b,t.readFloat(),gn(t,u));i.push(g)}const o=t.readInt(!0);if(o>0){const m=new te(o);for(let u=0;u<o;u++){const f=t.readFloat(),p=s.events[t.readInt(!0)],g=new ae(f,p);g.intValue=t.readInt(!1),g.floatValue=t.readFloat(),g.stringValue=t.readString(),g.stringValue==null&&(g.stringValue=p.setupPose.stringValue),g.data.audioPath&&(g.volume=t.readFloat(),g.balance=t.readFloat()),m.setFrame(u,g)}i.push(m)}let h=0;for(let m=0,u=i.length;m<u;m++)h=Math.max(h,i[m].getDuration());const d=new Qt(e,i,h);return n&&z.rgba8888ToColor(d.color,t.readInt32()),d}},un=class{constructor(t,e=[],s=0,n=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=n}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){const t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){const t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=e&127;return(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<7,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<14,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<21,(e&128)!==0&&(e=this.readByte(),s|=(e&127)<<28)))),t?s:s>>>1^-(s&1)}readStringRef(){const t=this.readInt(!0);return t===0?null:this.strings[t-1]}readString(){let t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;let e="";for(let s=0;s<t;){const n=this.readUnsignedByte();switch(n>>4){case 12:case 13:e+=String.fromCharCode((n&31)<<6|this.readByte()&63),s+=2;break;case 14:e+=String.fromCharCode((n&15)<<12|(this.readByte()&63)<<6|this.readByte()&63),s+=3;break;default:e+=String.fromCharCode(n),s++}}return e}readFloat(){const t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return this.readByte()!==0}},Wn=class{source;skinIndex;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(t,e,s,n,i,r){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}},mn=class{constructor(t=null,e,s=0){this.bones=t,this.vertices=e,this.length=s}};function tt(t,e,s,n){s instanceof Ut?Hn(t,e,s,n):Gn(t,e,s,n)}function Hn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n;for(let a=0,c=0,l=s.getFrameCount()-1;s.setFrame(a,i,r),a!==l;a++){const o=t.readFloat(),h=t.readFloat()*n;switch(t.readByte()){case mt:s.setStepped(a);break;case gt:H(t,s,c++,a,0,i,o,r,h,n)}i=o,r=h}e.push(s)}function Gn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n,a=t.readFloat()*n;for(let c=0,l=0,o=s.getFrameCount()-1;s.setFrame(c,i,r,a),c!==o;c++){const h=t.readFloat(),d=t.readFloat()*n,m=t.readFloat()*n;switch(t.readByte()){case mt:s.setStepped(c);break;case gt:H(t,s,l++,c,0,i,h,r,d,n),H(t,s,l++,c,1,i,h,a,m,n)}i=h,r=d,a=m}e.push(s)}function gn(t,e){const s=t.readInt(!0);if(s===0)return null;const n=new Array(e).fill(-1),i=new Array(e-s);let r=0,a=0;for(let c=0;c<s;c++){const l=t.readInt(!0);for(;r!==l;)i[a++]=r++;n[r+t.readInt(!0)]=r++}for(;r<e;)i[a++]=r++;for(let c=e-1;c>=0;c--)n[c]===-1&&(n[c]=i[--a]);return n}function H(t,e,s,n,i,r,a,c,l,o){e.setBezier(s,n,i,r,c,t.readFloat(),t.readFloat()*o,t.readFloat(),t.readFloat()*o,a,l)}var jn=0,Kn=1,Jn=2,Qn=3,Zn=4,ti=5,ei=6,si=7,ni=8,ii=9,ri=10,oi=0,ai=1,ci=2,li=3,hi=4,di=5,fi=0,ui=1,mi=2,gi=3,pi=4,bi=0,xi=1,wi=0,yi=1,vi=2,Si=0,Ti=1,Ai=2,Ii=4,Ci=5,Mi=6,Yi=7,Fi=8,ki=0,Pi=1,mt=1,gt=2,Ei=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new Ot(()=>L.newFloatArray(16));update(t,e){if(!t)throw new Error("skeleton cannot be null.");const s=this.boundingBoxes,n=this.polygons,i=this.polygonPool,r=t.slots,a=r.length;s.length=0,i.freeAll(n),n.length=0;for(let c=0;c<a;c++){const l=r[c];if(!l.bone.active)continue;const o=l.appliedPose.attachment;if(o instanceof ps){s.push(o);let h=i.obtain();h.length!==o.worldVerticesLength&&(h=L.newFloatArray(o.worldVerticesLength)),n.push(h),o.computeWorldVertices(t,l,0,o.worldVerticesLength,h,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;const i=this.polygons;for(let r=0,a=i.length;r<a;r++){const c=i[r],l=c;for(let o=0,h=c.length;o<h;o+=2){const d=l[o],m=l[o+1];t=Math.min(t,d),e=Math.min(e,m),s=Math.max(s,d),n=Math.max(n,m)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,n){const i=this.minX,r=this.minY,a=this.maxX,c=this.maxY;if(t<=i&&s<=i||e<=r&&n<=r||t>=a&&s>=a||e>=c&&n>=c)return!1;const l=(n-e)/(s-t);let o=l*(i-t)+e;if(o>r&&o<c||(o=l*(a-t)+e,o>r&&o<c))return!0;let h=(r-e)/l+t;return h>i&&h<a||(h=(c-e)/l+t,h>i&&h<a)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){const s=this.polygons;for(let n=0,i=s.length;n<i;n++)if(this.containsPointPolygon(s[n],t,e))return this.boundingBoxes[n];return null}containsPointPolygon(t,e,s){const n=t,i=t.length;let r=i-2,a=!1;for(let c=0;c<i;c+=2){const l=n[c+1],o=n[r+1];if(l<s&&o>=s||o<s&&l>=s){const h=n[c];h+(s-l)/(o-l)*(n[r]-h)<e&&(a=!a)}r=c}return a}intersectsSegment(t,e,s,n){const i=this.polygons;for(let r=0,a=i.length;r<a;r++)if(this.intersectsSegmentPolygon(i[r],t,e,s,n))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,n,i){const r=t,a=t.length,c=e-n,l=s-i,o=e*i-s*n;let h=r[a-2],d=r[a-1];for(let m=0;m<a;m+=2){const u=r[m],f=r[m+1],p=h*f-d*u,g=h-u,b=d-f,x=c*b-l*g,w=(o*g-c*p)/x;if((w>=h&&w<=u||w>=u&&w<=h)&&(w>=e&&w<=n||w>=n&&w<=e)){const S=(o*b-l*p)/x;if((S>=d&&S<=f||S>=f&&S<=d)&&(S>=s&&S<=i||S>=i&&S<=s))return!0}h=u,d=f}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");const e=this.boundingBoxes.indexOf(t);return e===-1?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},pn=class at{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new Ot(()=>[]);polygonIndicesPool=new Ot(()=>[]);triangulate(e){const s=e;let n=e.length>>1;const i=this.indicesArray;i.length=0;for(let c=0;c<n;c++)i[c]=c;const r=this.isConcaveArray;r.length=0;for(let c=0;c<n;c++)r[c]=at.isConcave(c,n,s,i);const a=this.triangles;for(a.length=0;n>3;){let c=n-1,l=0,o=1;for(;;){t:if(!r[l]){const m=i[c]<<1,u=i[l]<<1,f=i[o]<<1,p=s[m],g=s[m+1],b=s[u],x=s[u+1],w=s[f],S=s[f+1];for(let y=o+1<n?o+1:0;y!==c;){if(r[y]){const v=i[y]<<1,T=s[v],A=s[v+1];if(at.positiveArea(w,S,p,g,T,A)&&at.positiveArea(p,g,b,x,T,A)&&at.positiveArea(b,x,w,S,T,A))break t}++y===n&&(y=0)}break}if(o===0){do{if(!r[l])break;l--}while(l>0);c=l>0?l-1:n-1,o=l+1<n?l+1:0;break}c=l,l=o,++o===n&&(o=0)}a.push(i[c],i[l],i[o]),i.splice(l,1),r.splice(l,1),n--;const h=l>0?l-1:n-1,d=l<n?l:0;r[h]=at.isConcave(h,n,s,i),r[d]=at.isConcave(d,n,s,i)}return n===3&&a.push(i[2],i[0],i[1]),a}decompose(e,s){const n=e,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;const r=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(r),r.length=0;let a=this.polygonIndicesPool.obtain();a.length=0;let c=this.polygonPool.obtain();c.length=0;let l=-1,o=0;for(let h=0,d=s.length;h<d;h+=3){const m=s[h]<<1,u=s[h+1]<<1,f=s[h+2]<<1,p=n[m],g=n[m+1],b=n[u],x=n[u+1],w=n[f],S=n[f+1];if(l===m){const y=c.length-4;if(at.winding(c[y],c[y+1],c[y+2],c[y+3],w,S)===o&&at.winding(w,S,c[0],c[1],c[2],c[3])===o){c.push(w,S),a.push(f);continue}}c.length>0&&(i.push(c),r.push(a),c=this.polygonPool.obtain(),a=this.polygonIndicesPool.obtain()),c.length=0,c.push(p,g,b,x),c.push(w,S),a.length=0,a.push(m,u,f),o=at.winding(p,g,b,x,w,S),l=m}c.length>0&&(i.push(c),r.push(a));for(let h=0,d=i.length;h<d;h++){if(a=r[h],a.length===0)continue;const m=a[0];let u=a[a.length-1];c=i[h];const f=c.length-4;let p=c[f],g=c[f+1],b=c[f+2],x=c[f+3];const w=c[0],S=c[1],y=c[2],v=c[3],T=at.winding(p,g,b,x,w,S);for(let A=0;A<d;A++){if(A===h)continue;const M=r[A];if(M.length!==3)continue;const C=M[0],Y=M[1],P=M[2],E=i[A],X=E[E.length-2],V=E[E.length-1];C!==m||Y!==u||at.winding(p,g,b,x,X,V)===T&&at.winding(X,V,w,S,y,v)===T&&(E.length=0,M.length=0,c.push(X,V),a.push(P),u=P,p=b,g=x,b=X,x=V,A=-1)}}for(let h=i.length-1;h>=0;h--)c=i[h],c.length===0?(i.splice(h,1),this.polygonPool.free(c),a=r[h],r.splice(h,1),this.polygonIndicesPool.free(a)):c.push(c[0],c[1]);return i}static isConcave(e,s,n,i){const r=i[e>0?e-1:s-1]<<1,a=i[e]<<1,c=i[e+1<s?e+1:0]<<1;return!at.positiveArea(n[r],n[r+1],n[a],n[a+1],n[c],n[c+1])}static positiveArea(e,s,n,i,r,a){return e*(a-i)+n*(s-a)+r*(i-s)>=0}static winding(e,s,n,i,r,a){return e*(a-i)+n*(s-a)+r*(i-s)>=0?1:-1}},bn=class{triangulator=null;clippingPolygon=[];clippingPolygons=[];clipOutput=[];clippedVertices=[];clippedUVs=[];clippedTriangles=[];inverseVertices=[];_clippedVerticesTyped=new Float32Array(1024);_clippedUVsTyped=new Float32Array(1024);_clippedTrianglesTyped=new Uint16Array(1024);clippedVerticesTyped=new Float32Array(0);clippedUVsTyped=new Float32Array(0);clippedTrianglesTyped=new Uint16Array(0);clippedVerticesLength=0;clippedUVsLength=0;clippedTrianglesLength=0;scratch=[];inverse=!1;clipAttachment=null;clipStart(t,e,s){if(this.clipAttachment)return;const n=s.worldVerticesLength;this.clipAttachment=s,this.inverse=s.inverse;const i=L.setArraySize(this.clippingPolygon,n);s.computeWorldVertices(t,e,0,n,i,0,2);const r=this.clippingPolygon,a=this.makeClockwise(r);a||this.inverse||s.convex?(a||this.makeConvex(r),this.clippingPolygon.push(r[0],r[1]),this.clippingPolygons.push(r)):(this.triangulator===null&&(this.triangulator=new pn),this.clippingPolygons.push(...this.triangulator.decompose(r,this.triangulator.triangulate(r))))}clipEnd(t){this.clipAttachment&&(t&&this.clipAttachment.endSlot!==t.data||(this.clipAttachment=null,this.clippingPolygons.length=0))}isClipping(){return this.clipAttachment!=null}clipTriangles(t,e,s,n,i,r,a,c){return n&&i&&r&&typeof a=="boolean"&&typeof c=="number"?this.clipTrianglesRender(t,e,s,n,i,r,a,c):this.clipTrianglesNoRender(t,e,s)}clipTrianglesNoRender(t,e,s){const n=this.clippedVertices;n.length=0;const i=this.clippedTriangles;i.length=0;let r=0;if(this.inverse){const h=this.clippingPolygons[0];for(let d=0;d<s;d+=3){let m=e[d]<<1;const u=t[m],f=t[m+1];m=e[d+1]<<1;const p=t[m],g=t[m+1];m=e[d+2]<<1;const b=t[m],x=t[m+1];this.clipInverse(u,f,p,g,b,x,h);const w=this.inverseVertices;for(let S=0,y=this.inverseVertices.length;S<y;){const v=w[S++];let T=v>>1,A=n.length;const M=L.setArraySize(n,A+v);L.arrayCopy(w,S,M,A,v),A=i.length;const C=L.setArraySize(i,A+3*(T-2));for(let Y=1;Y<T-1;Y++,A+=3)C[A]=r,C[A+1]=r+Y,C[A+2]=r+Y+1;r+=T,S+=v}}return!0}const a=this.clipOutput,c=this.clippingPolygons,l=c.length;let o=null;for(let h=0;h<s;h+=3){let d=e[h]<<1;const m=t[d],u=t[d+1];d=e[h+1]<<1;const f=t[d],p=t[d+1];d=e[h+2]<<1;const g=t[d],b=t[d+1];for(let x=0;x<l;x++){let w=n.length;if(this.clip(m,u,f,p,g,b,c[x])){o=this.clipOutput;const S=a.length;if(S===0)continue;let y=S>>1;const v=L.setArraySize(n,w+S);L.arrayCopy(o,0,v,w,S),w=i.length;const T=L.setArraySize(i,w+3*(y-2));y--;for(let A=1;A<y;A++,w+=3)T[w]=r,T[w+1]=r+A,T[w+2]=r+A+1;r+=y}else{const S=L.setArraySize(n,w+6);S[w]=m,S[w+1]=u,S[w+2]=f,S[w+3]=p,S[w+4]=g,S[w+5]=b,w=i.length;const y=L.setArraySize(i,w+3);y[w]=r,y[w+1]=r+1,y[w+2]=r+2,r+=3;break}}}return o!=null}clipTrianglesRender(t,e,s,n,i,r,a,c){const l=this.clippedVertices;l.length=0;const o=this.clippedTriangles;o.length=0;let h=0;if(this.inverse){const p=this.clippingPolygons[0];for(let g=0;g<s;g+=3){let b=e[g],x=e[g+1],w=e[g+2];const S=t[b*c],y=t[b*c+1],v=t[x*c],T=t[x*c+1],A=t[w*c],M=t[w*c+1];this.clipInverse(S,y,v,T,A,M,p);const C=this.inverseVertices.length;if(C===0)continue;const Y=n[b<<=1],P=n[b+1],E=n[x<<=1],X=n[x+1],V=n[w<<=1],N=n[w+1],$=T-M,U=A-v,F=S-A,k=M-y,D=1/($*F+U*(y-M)),O=this.inverseVertices;for(let W=0;W<C;){const B=O[W++],_=B>>1;let q=l.length;const J=L.setArraySize(l,q+_*c);for(let Q=0;Q<B;Q+=2,q+=c){const st=O[W+Q],it=O[W+Q+1];J[q]=st,J[q+1]=it,J[q+2]=i.r,J[q+3]=i.g,J[q+4]=i.b,J[q+5]=i.a;const nt=st-A,dt=it-M,rt=($*nt+U*dt)*D,ot=(k*nt+F*dt)*D,ft=1-rt-ot;J[q+6]=Y*rt+E*ot+V*ft,J[q+7]=P*rt+X*ot+N*ft,a&&(J[q+8]=r.r,J[q+9]=r.g,J[q+10]=r.b,J[q+11]=r.a)}q=o.length;const et=L.setArraySize(o,q+3*(_-2));for(let Q=1;Q<_-1;Q++,q+=3)et[q]=h,et[q+1]=h+Q,et[q+2]=h+Q+1;h+=_,W+=B}}return!0}const d=this.clipOutput,m=this.clippingPolygons,u=this.clippingPolygons.length;let f=null;for(let p=0;p<s;p+=3){let g=e[p];const b=t[g*c],x=t[g*c+1],w=n[g<<1],S=n[(g<<1)+1];g=e[p+1];const y=t[g*c],v=t[g*c+1],T=n[g<<1],A=n[(g<<1)+1];g=e[p+2];const M=t[g*c],C=t[g*c+1],Y=n[g<<1],P=n[(g<<1)+1],E=v-C,X=M-y,V=b-M,N=C-x,$=1/(E*V+X*(x-C));for(let U=0;U<u;U++){let F=l.length;if(this.clip(b,x,y,v,M,C,m[U])){f=this.clipOutput;const k=d.length;if(k===0)continue;let D=k>>1;const O=L.setArraySize(l,F+D*c);for(let B=0;B<k;B+=2,F+=c){const _=f[B],q=f[B+1];O[F]=_,O[F+1]=q,O[F+2]=i.r,O[F+3]=i.g,O[F+4]=i.b,O[F+5]=i.a;const J=_-M,et=q-C,Q=(E*J+X*et)*$,st=(N*J+V*et)*$,it=1-Q-st;O[F+6]=w*Q+T*st+Y*it,O[F+7]=S*Q+A*st+P*it,a&&(O[F+8]=r.r,O[F+9]=r.g,O[F+10]=r.b,O[F+11]=r.a)}F=o.length;const W=L.setArraySize(o,F+3*(D-2));D--;for(let B=1;B<D;B++,F+=3)W[F]=h,W[F+1]=h+B,W[F+2]=h+B+1;h+=D+1}else{const k=L.setArraySize(l,F+3*c);k[F]=b,k[F+1]=x,k[F+2]=i.r,k[F+3]=i.g,k[F+4]=i.b,k[F+5]=i.a,a?(k[F+6]=w,k[F+7]=S,k[F+8]=r.r,k[F+9]=r.g,k[F+10]=r.b,k[F+11]=r.a,k[F+12]=y,k[F+13]=v,k[F+14]=i.r,k[F+15]=i.g,k[F+16]=i.b,k[F+17]=i.a,k[F+18]=T,k[F+19]=A,k[F+20]=r.r,k[F+21]=r.g,k[F+22]=r.b,k[F+23]=r.a,k[F+24]=M,k[F+25]=C,k[F+26]=i.r,k[F+27]=i.g,k[F+28]=i.b,k[F+29]=i.a,k[F+30]=Y,k[F+31]=P,k[F+32]=r.r,k[F+33]=r.g,k[F+34]=r.b,k[F+35]=r.a):(k[F+6]=w,k[F+7]=S,k[F+8]=y,k[F+9]=v,k[F+10]=i.r,k[F+11]=i.g,k[F+12]=i.b,k[F+13]=i.a,k[F+14]=T,k[F+15]=A,k[F+16]=M,k[F+17]=C,k[F+18]=i.r,k[F+19]=i.g,k[F+20]=i.b,k[F+21]=i.a,k[F+22]=Y,k[F+23]=P),F=o.length;const D=L.setArraySize(o,F+3);D[F]=h,D[F+1]=h+1,D[F+2]=h+2,h+=3;break}}}return f!=null}clipTrianglesUnpacked(t,e,s,n,i,r=2){let a=this._clippedVerticesTyped,c=this._clippedUVsTyped,l=this._clippedTrianglesTyped,o=0;if(this.clippedVerticesLength=0,this.clippedUVsLength=0,this.clippedTrianglesLength=0,this.inverse){const f=this.clippingPolygons[0];for(let p=0;p<n;p+=3){let g=s[p]*r;const b=t[e+g],x=t[e+g+1];let w=s[p]<<1;const S=i[w],y=i[w+1];g=s[p+1]*r;const v=t[e+g],T=t[e+g+1];w=s[p+1]<<1;const A=i[w],M=i[w+1];g=s[p+2]*r;const C=t[e+g],Y=t[e+g+1];w=s[p+2]<<1;const P=i[w],E=i[w+1];this.clipInverse(b,x,v,T,C,Y,f);const X=this.inverseVertices.length;if(X===0)continue;const V=T-Y,N=C-v,$=b-C,U=Y-x,F=1/(V*$+N*(x-Y)),k=this.inverseVertices;for(let D=0;D<X;){const O=k[D++],W=O>>1;let B=this.clippedVerticesLength;const _=B+W*r,q=this.clippedUVsLength+W*2;a.length<_&&(this._clippedVerticesTyped=new Float32Array(_*2),this._clippedVerticesTyped.set(a.subarray(0,B)),a=this._clippedVerticesTyped),c.length<q&&(this._clippedUVsTyped=new Float32Array(q*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),c=this._clippedUVsTyped),this.clippedVerticesLength=_,this.clippedUVsLength=q;const J=this._clippedVerticesTyped,et=this._clippedUVsTyped;let Q=q-W*2;for(let nt=0;nt<O;nt+=2,B+=r,Q+=2){const dt=k[D+nt],rt=k[D+nt+1];J[B]=dt,J[B+1]=rt;const ot=dt-C,ft=rt-Y,ut=(V*ot+N*ft)*F,pt=(U*ot+$*ft)*F,Lt=1-ut-pt;et[Q]=S*ut+A*pt+P*Lt,et[Q+1]=y*ut+M*pt+E*Lt}B=this.clippedTrianglesLength;const st=B+3*(W-2);l.length<st&&(this._clippedTrianglesTyped=new Uint16Array(st*2),this._clippedTrianglesTyped.set(l.subarray(0,B)),l=this._clippedTrianglesTyped),this.clippedTrianglesLength=st;const it=l;for(let nt=1;nt<W-1;nt++,B+=3)it[B]=o,it[B+1]=o+nt,it[B+2]=o+nt+1;o+=W,D+=O}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),!0}const h=this.clipOutput,d=this.clippingPolygons,m=this.clippingPolygons.length;let u=null;for(let f=0;f<n;f+=3){let p=s[f],g=p*r;const b=t[e+g],x=t[e+g+1];let w=p<<1;const S=i[w],y=i[w+1];p=s[f+1],g=p*r;const v=t[e+g],T=t[e+g+1];w=p<<1;const A=i[w],M=i[w+1];p=s[f+2],g=p*r;const C=t[e+g],Y=t[e+g+1];w=p<<1;const P=i[w],E=i[w+1],X=T-Y,V=C-v,N=b-C,$=Y-x,U=1/(X*N+V*(x-Y));for(let F=0;F<m;F++){let k=this.clippedVerticesLength;if(this.clip(b,x,v,T,C,Y,d[F])){u=h;const D=h.length;if(D===0)continue;let O=D>>1;const W=k+O*r;a.length<W&&(this._clippedVerticesTyped=new Float32Array(W*2),this._clippedVerticesTyped.set(a.subarray(0,k)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+O*2)*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),a=this._clippedVerticesTyped,c=this._clippedUVsTyped);const B=a,_=c;this.clippedVerticesLength=W;let q=this.clippedUVsLength;this.clippedUVsLength=q+O*2;for(let Q=0;Q<D;Q+=2,k+=r,q+=2){const st=u[Q],it=u[Q+1];B[k]=st,B[k+1]=it;const nt=st-C,dt=it-Y,rt=(X*nt+V*dt)*U,ot=($*nt+N*dt)*U,ft=1-rt-ot;_[q]=S*rt+A*ot+P*ft,_[q+1]=y*rt+M*ot+E*ft}k=this.clippedTrianglesLength;const J=k+3*(O-2);l.length<J&&(this._clippedTrianglesTyped=new Uint16Array(J*2),this._clippedTrianglesTyped.set(l.subarray(0,k)),l=this._clippedTrianglesTyped),this.clippedTrianglesLength=J;const et=l;O--;for(let Q=1;Q<O;Q++,k+=3)et[k]=o,et[k+1]=o+Q,et[k+2]=o+Q+1;o+=O+1}else{let D=k+3*r;a.length<D&&(this._clippedVerticesTyped=new Float32Array(D*2),this._clippedVerticesTyped.set(a.subarray(0,k)),a=this._clippedVerticesTyped),a[k]=b,a[k+1]=x,a[k+r]=v,a[k+r+1]=T,a[k+r*2]=C,a[k+r*2+1]=Y;const O=this.clippedUVsLength+6;c.length<O&&(this._clippedUVsTyped=new Float32Array(O*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),c=this._clippedUVsTyped);const W=this.clippedUVsLength;c[W]=S,c[W+1]=y,c[W+2]=A,c[W+3]=M,c[W+4]=P,c[W+5]=E,this.clippedVerticesLength=D,this.clippedUVsLength=O,k=this.clippedTrianglesLength,D=k+3,l.length<D&&(this._clippedTrianglesTyped=new Uint16Array(D*2),this._clippedTrianglesTyped.set(l.subarray(0,k)),l=this._clippedTrianglesTyped);const B=l;B[k]=o,B[k+1]=o+1,B[k+2]=o+2,o+=3,this.clippedTrianglesLength=D;break}}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),u!==null}clip(t,e,s,n,i,r,a){const c=this.clipOutput;let l=!1,o,h;a.length%4>=2?(o=this.clipOutput,h=this.scratch):(o=this.scratch,h=this.clipOutput);const d=a;o.length=8;const m=o;m[0]=t,m[1]=e,m[2]=s,m[3]=n,m[4]=i,m[5]=r,m[6]=t,m[7]=e,h.length=0;const u=a.length-4;for(let f=0;;f+=2){const p=d[f],g=d[f+1],b=p-d[f+2],x=g-d[f+3],w=h.length,S=o;for(let v=0,T=o.length-2;v<T;){t=S[v],e=S[v+1],v+=2,s=S[v],n=S[v+1];const A=x*(p-s)>b*(g-n),M=x*(p-t)-b*(g-e);if(M>0)if(A)h.push(s,n);else{const C=s-t,Y=n-e,P=M/(C*x-Y*b);P>=0&&P<=1?(h.push(t+C*P,e+Y*P),l=!0):h.push(s,n)}else if(A){const C=s-t,Y=n-e,P=M/(C*x-Y*b);P>=0&&P<=1?(h.push(t+C*P,e+Y*P,s,n),l=!0):h.push(s,n)}else l=!0}if(w===h.length)return c.length=0,!0;if(h.push(h[0],h[1]),f===u)break;const y=h;h=o,h.length=0,o=y}if(c!==h){c.length=0;for(let f=0,p=h.length-2;f<p;f++)c[f]=h[f]}else c.length=c.length-2;return l}clipInverse(t,e,s,n,i,r,a){this.inverseVertices.length=0;const c=a.length-4;let l,o;a.length%4>=2?(l=this.clipOutput,o=this.scratch):(l=this.scratch,o=this.clipOutput),l.length=8;let h=a,d=l;d[0]=t,d[1]=e,d[2]=s,d[3]=n,d[4]=i,d[5]=r,d[6]=t,d[7]=e,o.length=0;for(let m=0;;m+=2){const u=h[m],f=h[m+1],p=u-h[m+2],g=f-h[m+3],b=o.length,x=this.inverseVertices.length;this.inverseVertices.push(0),d=l;for(let y=0,v=l.length-2;y<v;){t=d[y],e=d[y+1],y+=2,s=d[y],n=d[y+1];const T=g*(u-s)>p*(f-n),A=g*(u-t)-p*(f-e);if(A>0)if(T)o.push(s,n);else{const M=s-t,C=n-e,Y=A/(M*g-C*p);if(Y>=0&&Y<=1){const P=t+M*Y,E=e+C*Y;o.push(P,E),this.inverseVertices.push(P,E,s,n)}else o.push(s,n)}else if(T){const M=s-t,C=n-e,Y=A/(M*g-C*p);if(Y>=0&&Y<=1){const P=t+M*Y,E=e+C*Y;this.inverseVertices.push(P,E),o.push(P,E,s,n)}else o.push(s,n)}else this.inverseVertices.push(s,n)}const w=this.inverseVertices.length-x-1;if(w>=6?this.inverseVertices[x]=w:this.inverseVertices.length=x,b===o.length||(o.push(o[0],o[1]),m===c))break;const S=o;o=l,o.length=0,l=S}}makeClockwise(t){const e=t,s=t.length;let n=!0,i=!0,r=0,a=e[s-2],c=e[s-1],l=e[0],o=e[1];for(let d=2;d<s;d+=2){const m=e[d],u=e[d+1];r+=l*u-m*o;const f=(l-a)*(u-o)-(o-c)*(m-l);i=i&&f<=0,n=n&&f>=0,a=l,c=o,l=m,o=u}r+=l*e[1]-e[0]*o;const h=(l-a)*(e[1]-o)-(o-c)*(e[0]-l);if(i=i&&h<=0,n=n&&h>=0,r>=0){for(let d=0,m=s-2,u=s>>1;d<u;d+=2){const f=e[d],p=e[d+1],g=m-d;e[d]=e[g],e[d+1]=e[g+1],e[g]=f,e[g+1]=p}return n}return i}makeConvex(t){const e=t.length,s=t;this.clipOutput.length=e;const n=this.clipOutput;n[0]=s[0],n[1]=s[1];for(let a=2;a<e;a+=2){const c=s[a],l=s[a+1];let o=a-2;for(;o>=0&&(n[o]>c||n[o]===c&&n[o+1]>l);o-=2)n[o+2]=n[o],n[o+3]=n[o+1];n[o+2]=c,n[o+3]=l}s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3];let i=4;for(let a=4;a<e;a+=2,i+=2){const c=n[a],l=n[a+1];for(;(s[i-2]-s[i-4])*(l-s[i-3])-(s[i-1]-s[i-3])*(c-s[i-4])>=0&&(i-=2,i!==2););s[i]=c,s[i+1]=l}s[i]=n[e-4],s[i+1]=n[e-3];const r=i;i+=2;for(let a=e-6;a>=0;a-=2,i+=2){const c=n[a],l=n[a+1];for(;(s[i-2]-s[i-4])*(l-s[i-3])-(s[i-1]-s[i-3])*(c-s[i-4])>=0&&(i-=2,i!==r););s[i]=c,s[i+1]=l}t.length=i-2}},Xi=class{attachmentLoader;scale=1;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Is,n=typeof t=="string"?JSON.parse(t):t,i=n.skeleton;if(i&&(s.hash=i.hash,s.version=i.spine,s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height,s.referenceScale=I(i,"referenceScale",100)*e,s.fps=i.fps,s.imagesPath=i.images??null,s.audioPath=i.audio??null),n.bones)for(let r=0;r<n.bones.length;r++){const a=n.bones[r];let c=null;const l=I(a,"parent",null);l&&(c=s.findBone(l));const o=new bs(s.bones.length,a.name,c);o.length=I(a,"length",0)*e;const h=o.setupPose;h.x=I(a,"x",0)*e,h.y=I(a,"y",0)*e,h.rotation=I(a,"rotation",0),h.scaleX=I(a,"scaleX",1),h.scaleY=I(a,"scaleY",1),h.shearX=I(a,"shearX",0),h.shearY=I(a,"shearY",0),h.inherit=L.enumValue(ne,I(a,"inherit","Normal")),o.skinRequired=I(a,"skin",!1);const d=I(a,"color",null);d&&o.color.setFromString(d),o.icon=I(a,"icon",void 0),o.iconSize=I(a,"iconSize",1),o.iconRotation=I(a,"iconRotation",0),s.bones.push(o)}if(n.slots)for(let r=0;r<n.slots.length;r++){const a=n.slots[r],c=a.name,l=s.findBone(a.bone);if(!l)throw new Error(`Couldn't find bone ${a.bone} for slot ${c}`);const o=new Ms(s.slots.length,c,l),h=I(a,"color",null);h&&o.setupPose.color.setFromString(h);const d=I(a,"dark",null);d&&(o.setupPose.darkColor=z.fromString(d)),o.attachmentName=I(a,"attachment",null),o.blendMode=L.enumValue(Ys,I(a,"blend","normal")),o.visible=I(a,"visible",!0),s.slots.push(o)}if(n.constraints)for(const r of n.constraints){const a=r.name,c=I(r,"skin",!1);switch(I(r,"type",!1)){case"ik":{const l=new Wt(a);l.skinRequired=c;for(let u=0;u<r.bones.length;u++){const f=s.findBone(r.bones[u]);if(!f)throw new Error(`Couldn't find bone ${r.bones[u]} for IK constraint ${a}.`);l.bones.push(f)}const o=r.target,h=s.findBone(o);if(!h)throw new Error(`Couldn't find target bone ${o} for IK constraint ${a}.`);l.target=h;const d=I(r,"scaleY",null);d!=null&&(l.scaleYMode=L.enumValue(oe,d));const m=l.setupPose;m.mix=I(r,"mix",1),m.softness=I(r,"softness",0)*e,m.bendDirection=I(r,"bendPositive",!0)?1:-1,m.compress=I(r,"compress",!1),m.stretch=I(r,"stretch",!1),s.constraints.push(l);break}case"transform":{const l=new K(a);l.skinRequired=c;for(let w=0;w<r.bones.length;w++){const S=r.bones[w],y=s.findBone(S);if(!y)throw new Error(`Couldn't find bone ${S} for transform constraint ${r.name}.`);l.bones.push(y)}const o=r.source,h=s.findBone(o);if(!h)throw new Error(`Couldn't find source bone ${o} for transform constraint ${r.name}.`);l.source=h,l.localSource=I(r,"localSource",!1),l.localTarget=I(r,"localTarget",!1),l.additive=I(r,"additive",!1),l.clamp=I(r,"clamp",!1);let d=!1,m=!1,u=!1,f=!1,p=!1,g=!1;const b=Object.entries(I(r,"properties",{}));for(const[w,S]of b){const y=this.fromProperty(w),v=this.propertyScale(w,e);y.offset=I(S,"offset",0)*v;const T=Object.entries(I(S,"to",{}));for(const[A,M]of T){let C=1,Y;switch(A){case"rotate":{d=!0,Y=new Fs;break}case"x":{m=!0,Y=new ks,C=e;break}case"y":{u=!0,Y=new Ps,C=e;break}case"scaleX":{f=!0,Y=new Es;break}case"scaleY":{p=!0,Y=new Xs;break}case"shearY":{g=!0,Y=new Vs;break}default:throw new Error(`Invalid transform constraint to property: ${A}`)}Y.offset=I(M,"offset",0)*C,Y.max=I(M,"max",1)*C,Y.scale=I(M,"scale",1)*C/v,y.to.push(Y)}y.to.length>0&&l.properties.push(y)}l.offsets[K.ROTATION]=I(r,"rotation",0),l.offsets[K.X]=I(r,"x",0)*e,l.offsets[K.Y]=I(r,"y",0)*e,l.offsets[K.SCALEX]=I(r,"scaleX",0),l.offsets[K.SCALEY]=I(r,"scaleY",0),l.offsets[K.SHEARY]=I(r,"shearY",0);const x=l.setupPose;d&&(x.mixRotate=I(r,"mixRotate",1)),m&&(x.mixX=I(r,"mixX",1)),u&&(x.mixY=I(r,"mixY",x.mixX)),f&&(x.mixScaleX=I(r,"mixScaleX",1)),p&&(x.mixScaleY=I(r,"mixScaleY",x.mixScaleX)),g&&(x.mixShearY=I(r,"mixShearY",1)),s.constraints.push(l);break}case"path":{const l=new Ht(a);l.skinRequired=c;for(let m=0;m<r.bones.length;m++){const u=r.bones[m],f=s.findBone(u);if(!f)throw new Error(`Couldn't find bone ${u} for path constraint ${r.name}.`);l.bones.push(f)}const o=r.slot,h=s.findSlot(o);if(!h)throw new Error(`Couldn't find slot ${o} for path constraint ${r.name}.`);l.slot=h,l.positionMode=L.enumValue(vs,I(r,"positionMode","Percent")),l.spacingMode=L.enumValue(Ss,I(r,"spacingMode","Length")),l.rotateMode=L.enumValue(Ts,I(r,"rotateMode","Tangent")),l.offsetRotation=I(r,"rotation",0);const d=l.setupPose;d.position=I(r,"position",0),l.positionMode===0&&(d.position*=e),d.spacing=I(r,"spacing",0),(l.spacingMode===0||l.spacingMode===1)&&(d.spacing*=e),d.mixRotate=I(r,"mixRotate",1),d.mixX=I(r,"mixX",1),d.mixY=I(r,"mixY",d.mixX),s.constraints.push(l);break}case"physics":{const l=new Gt(a);l.skinRequired=c;const o=r.bone,h=s.findBone(o);if(h==null)throw new Error(`Physics bone not found: ${o}`);l.bone=h,l.x=I(r,"x",0),l.y=I(r,"y",0),l.rotate=I(r,"rotate",0),l.scaleX=I(r,"scaleX",0);const d=I(r,"scaleY",null);d!=null&&(l.scaleYMode=L.enumValue(oe,d)),l.shearX=I(r,"shearX",0),l.limit=I(r,"limit",5e3)*e,l.step=1/I(r,"fps",60);const m=l.setupPose;m.inertia=I(r,"inertia",.5),m.strength=I(r,"strength",100),m.damping=I(r,"damping",.85),m.massInverse=1/I(r,"mass",1),m.wind=I(r,"wind",0),m.gravity=I(r,"gravity",0),m.mix=I(r,"mix",1),l.inertiaGlobal=I(r,"inertiaGlobal",!1),l.strengthGlobal=I(r,"strengthGlobal",!1),l.dampingGlobal=I(r,"dampingGlobal",!1),l.massGlobal=I(r,"massGlobal",!1),l.windGlobal=I(r,"windGlobal",!1),l.gravityGlobal=I(r,"gravityGlobal",!1),l.mixGlobal=I(r,"mixGlobal",!1),s.constraints.push(l);break}case"slider":{const l=new St(a);l.skinRequired=c,l.additive=I(r,"additive",!1),l.loop=I(r,"loop",!1),l.setupPose.mix=I(r,"mix",1);const o=r.bone;if(o){if(l.bone=s.findBone(o),!l.bone)throw new Error(`Slider bone not found: ${o}`);const h=r.property;l.property=this.fromProperty(h);const d=this.propertyScale(h,e);l.property.offset=I(r,"from",0)*d,l.offset=I(r,"to",0),l.scale=I(r,"scale",1)/d,l.max=I(r,"max",0),l.local=I(r,"local",!1)}else l.setupPose.time=I(r,"time",0);s.constraints.push(l);break}}}if(n.skins)for(let r=0;r<n.skins.length;r++){const a=n.skins[r],c=new ue(a.name);if(a.bones)for(let l=0;l<a.bones.length;l++){const o=a.bones[l],h=s.findBone(o);if(!h)throw new Error(`Couldn't find bone ${o} for skin ${a.name}.`);c.bones.push(h)}if(a.ik)for(let l=0;l<a.ik.length;l++){const o=a.ik[l],h=s.findConstraint(o,Wt);if(!h)throw new Error(`Couldn't find IK constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.transform)for(let l=0;l<a.transform.length;l++){const o=a.transform[l],h=s.findConstraint(o,K);if(!h)throw new Error(`Couldn't find transform constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.path)for(let l=0;l<a.path.length;l++){const o=a.path[l],h=s.findConstraint(o,Ht);if(!h)throw new Error(`Couldn't find path constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.physics)for(let l=0;l<a.physics.length;l++){const o=a.physics[l],h=s.findConstraint(o,Gt);if(!h)throw new Error(`Couldn't find physics constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}if(a.slider)for(let l=0;l<a.slider.length;l++){const o=a.slider[l],h=s.findConstraint(o,St);if(!h)throw new Error(`Couldn't find slider constraint ${o} for skin ${a.name}.`);c.constraints.push(h)}for(const l in a.attachments){const o=s.findSlot(l);if(!o)throw new Error(`Couldn't find skin slot ${l} for skin ${a.name}.`);const h=a.attachments[l];for(const d in h){const m=this.readAttachment(h[d],c,o.index,d,s);m&&c.setAttachment(o.index,d,m)}}s.skins.push(c),c.name==="default"&&(s.defaultSkin=c)}for(let r=0,a=this.linkedMeshes.length;r<a;r++){const c=this.linkedMeshes[r],l=c.skin?s.findSkin(c.skin):s.defaultSkin;if(!l)throw new Error(`Skin not found: ${c.skin}`);const o=l.getAttachment(c.sourceIndex,c.source);if(!o)throw new Error(`Source mesh not found: ${c.source}`);c.mesh.timelineAttachment=c.inheritTimelines?o:c.mesh,c.mesh.setSourceMesh(o),c.mesh.updateSequence();t:if(c.inheritTimelines&&c.slotIndex!==c.sourceIndex){const h=o.timelineSlots;for(const m of h)if(m===c.slotIndex)break t;const d=[...h];d[h.length]=c.slotIndex,o.timelineSlots=d}}if(this.linkedMeshes.length=0,n.events)for(const r in n.events){const a=n.events[r],c=new ys(r),l=c.setupPose;l.intValue=I(a,"int",0),l.floatValue=I(a,"float",0),l.stringValue=I(a,"string",""),c._audioPath=I(a,"audio",null),c.audioPath&&(l.volume=I(a,"volume",l.volume),l.balance=I(a,"balance",l.balance)),s.events.push(c)}if(n.animations)for(const r in n.animations){const a=n.animations[r];this.readAnimation(a,r,s)}if(n.constraints)for(const r in n.constraints){const a=n.constraints[r];if(a.type==="slider"){const c=s.findConstraint(a.name,St),l=a.animation,o=s.findAnimation(l);if(!o)throw new Error(`Slider animation not found: ${l}`);c.animation=o}}return s}fromProperty(t){let e;switch(t){case"rotate":e=new ge;break;case"x":e=new pe;break;case"y":e=new be;break;case"scaleX":e=new xe;break;case"scaleY":e=new we;break;case"shearY":e=new ye;break;default:throw new Error(`Invalid transform constraint from property: ${t}`)}return e}propertyScale(t,e){switch(t){case"x":case"y":return e;default:return 1}}readAttachment(t,e,s,n,i){const r=this.scale,a=I(t,"name",n);switch(I(t,"type","region")){case"region":{const c=I(t,"path",a),l=this.readSequence(I(t,"sequence",null)),o=this.attachmentLoader.newRegionAttachment(e,n,a,c,l);if(!o)return null;o.path=c,o.x=I(t,"x",0)*r,o.y=I(t,"y",0)*r,o.scaleX=I(t,"scaleX",1),o.scaleY=I(t,"scaleY",1),o.rotation=I(t,"rotation",0),o.width=t.width*r,o.height=t.height*r;const h=I(t,"color",null);return h&&o.color.setFromString(h),o.updateSequence(),o}case"boundingbox":{const c=this.attachmentLoader.newBoundingBoxAttachment(e,n,a);if(!c)return null;this.readVertices(t,c,t.vertexCount<<1);const l=I(t,"color",null);return l&&c.color.setFromString(l),c}case"mesh":case"linkedmesh":{const c=I(t,"path",a),l=this.readSequence(I(t,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(e,n,a,c,l);if(!o)return null;o.path=c;const h=I(t,"color",null);h&&o.color.setFromString(h),o.width=I(t,"width",0)*r,o.height=I(t,"height",0)*r;const d=I(t,"source",null);if(d){let u=s;const f=I(t,"slot",null);if(f){const p=i.findSlot(f);if(!p)throw new Error(`Source mesh slot not found: ${f}`);u=p.index}return this.linkedMeshes.push(new Vi(o,I(t,"skin",null),s,u,d,I(t,"timelines",!0))),o}const m=t.uvs;return this.readVertices(t,o,m.length),o.triangles=t.triangles,o.regionUVs=m,o.edges=I(t,"edges",null),o.hullLength=I(t,"hull",0)*2,o.updateSequence(),o}case"path":{const c=this.attachmentLoader.newPathAttachment(e,n,a);if(!c)return null;c.closed=I(t,"closed",!1),c.constantSpeed=I(t,"constantSpeed",!0);const l=t.vertexCount;this.readVertices(t,c,l<<1);const o=L.newArray(l/3,0);for(let d=0;d<t.lengths.length;d++)o[d]=t.lengths[d]*r;c.lengths=o;const h=I(t,"color",null);return h&&c.color.setFromString(h),c}case"point":{const c=this.attachmentLoader.newPointAttachment(e,n,a);if(!c)return null;c.x=I(t,"x",0)*r,c.y=I(t,"y",0)*r,c.rotation=I(t,"rotation",0);const l=I(t,"color",null);return l&&c.color.setFromString(l),c}case"clipping":{const c=this.attachmentLoader.newClippingAttachment(e,n,a);if(!c)return null;const l=I(t,"end",null);l&&(c.endSlot=i.findSlot(l)),c.convex=I(t,"convex",!1),c.inverse=I(t,"inverse",!1);const o=t.vertexCount;this.readVertices(t,c,o<<1);const h=I(t,"color",null);return h&&c.color.setFromString(h),c}}return null}readSequence(t){if(t==null)return new Nt(1,!1);const e=new Nt(I(t,"count",0),!0);return e.start=I(t,"start",1),e.digits=I(t,"digits",0),e.setupIndex=I(t,"setup",0),e}readVertices(t,e,s){const n=this.scale;e.worldVerticesLength=s;const i=t.vertices;if(s===i.length){const c=L.toFloatArray(i);if(n!==1)for(let l=0,o=i.length;l<o;l++)c[l]*=n;e.vertices=c;return}const r=[],a=[];for(let c=0,l=i.length;c<l;){const o=i[c++];a.push(o);for(let h=c+o*4;c<h;c+=4)a.push(i[c]),r.push(i[c+1]*n),r.push(i[c+2]*n),r.push(i[c+3])}e.bones=a,e.vertices=L.toFloatArray(r)}readAnimation(t,e,s){const n=this.scale,i=[];if(t.slots)for(const l in t.slots){const o=t.slots[l],h=s.findSlot(l);if(!h)throw new Error(`Slot not found: ${l}`);const d=h.index;for(const m in o){const u=o[m];if(!u)continue;const f=u.length;switch(m){case"attachment":{const p=new kt(f,d);for(let g=0;g<f;g++){const b=u[g];p.setFrame(g,I(b,"time",0),I(b,"name",null))}i.push(p);break}case"rgba":{const p=new $e(f,f<<2,d);let g=u[0],b=I(g,"time",0),x=z.fromString(g.color);for(let w=0,S=0;;w++){p.setFrame(w,b,x.r,x.g,x.b,x.a);const y=u[w+1];if(!y){p.shrink(S);break}const v=I(y,"time",0),T=z.fromString(y.color),A=g.curve;A&&(S=G(A,p,S,w,0,b,v,x.r,T.r,1),S=G(A,p,S,w,1,b,v,x.g,T.g,1),S=G(A,p,S,w,2,b,v,x.b,T.b,1),S=G(A,p,S,w,3,b,v,x.a,T.a,1)),b=v,x=T,g=y}i.push(p);break}case"rgb":{const p=new qe(f,f*3,d);let g=u[0],b=I(g,"time",0),x=z.fromString(g.color);for(let w=0,S=0;;w++){p.setFrame(w,b,x.r,x.g,x.b);const y=u[w+1];if(!y){p.shrink(S);break}const v=I(y,"time",0),T=z.fromString(y.color),A=g.curve;A&&(S=G(A,p,S,w,0,b,v,x.r,T.r,1),S=G(A,p,S,w,1,b,v,x.g,T.g,1),S=G(A,p,S,w,2,b,v,x.b,T.b,1)),b=v,x=T,g=y}i.push(p);break}case"alpha":{ct(i,u,new _e(f,f,d),0,1);break}case"rgba2":{const p=new ze(f,f*7,d);let g=u[0],b=I(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let S=0,y=0;;S++){p.setFrame(S,b,x.r,x.g,x.b,x.a,w.r,w.g,w.b);const v=u[S+1];if(!v){p.shrink(y);break}const T=I(v,"time",0),A=z.fromString(v.light),M=z.fromString(v.dark),C=g.curve;C&&(y=G(C,p,y,S,0,b,T,x.r,A.r,1),y=G(C,p,y,S,1,b,T,x.g,A.g,1),y=G(C,p,y,S,2,b,T,x.b,A.b,1),y=G(C,p,y,S,3,b,T,x.a,A.a,1),y=G(C,p,y,S,4,b,T,w.r,M.r,1),y=G(C,p,y,S,5,b,T,w.g,M.g,1),y=G(C,p,y,S,6,b,T,w.b,M.b,1)),b=T,x=A,w=M,g=v}i.push(p);break}case"rgb2":{const p=new We(f,f*6,d);let g=u[0],b=I(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let S=0,y=0;;S++){p.setFrame(S,b,x.r,x.g,x.b,w.r,w.g,w.b);const v=u[S+1];if(!v){p.shrink(y);break}const T=I(v,"time",0),A=z.fromString(v.light),M=z.fromString(v.dark),C=g.curve;C&&(y=G(C,p,y,S,0,b,T,x.r,A.r,1),y=G(C,p,y,S,1,b,T,x.g,A.g,1),y=G(C,p,y,S,2,b,T,x.b,A.b,1),y=G(C,p,y,S,3,b,T,w.r,M.r,1),y=G(C,p,y,S,4,b,T,w.g,M.g,1),y=G(C,p,y,S,5,b,T,w.b,M.b,1)),b=T,x=A,w=M,g=v}i.push(p);break}default:throw new Error(`Invalid timeline type for a slot: ${u.name} (${o.name})`)}}}if(t.bones)for(const l in t.bones){const o=t.bones[l],h=s.findBone(l);if(!h)throw new Error(`Bone not found: ${l}`);const d=h.index;for(const m in o){const u=o[m],f=u.length;if(f!==0)switch(m){case"rotate":ct(i,u,new Dt(f,f,d),0,1);break;case"translate":Rs(i,u,new Ee(f,f<<1,d),"x","y",0,n);break;case"translatex":ct(i,u,new Xe(f,f,d),0,n);break;case"translatey":ct(i,u,new Ve(f,f,d),0,n);break;case"scale":Rs(i,u,new Re(f,f<<1,d),"x","y",1,1);break;case"scalex":ct(i,u,new Le(f,f,d),1,1);break;case"scaley":ct(i,u,new Be(f,f,d),1,1);break;case"shear":Rs(i,u,new Oe(f,f<<1,d),"x","y",0,1);break;case"shearx":ct(i,u,new Ne(f,f,d),0,1);break;case"sheary":ct(i,u,new Ue(f,f,d),0,1);break;case"inherit":{const p=new De(f,h.index);for(let g=0;g<u.length;g++){const b=u[g];p.setFrame(g,I(b,"time",0),L.enumValue(ne,I(b,"inherit","Normal")))}i.push(p);break}default:throw new Error(`Invalid timeline type for a bone: ${u.name} (${o.name})`)}}}if(t.ik)for(const l in t.ik){const o=t.ik[l];let h=o[0];if(!h)continue;const d=s.findConstraint(l,Wt);if(!d)throw new Error(`IK Constraint not found: ${l}`);const m=new je(o.length,o.length<<1,s.constraints.indexOf(d));let u=I(h,"time",0),f=I(h,"mix",1),p=I(h,"softness",0)*n;for(let g=0,b=0;;g++){m.setFrame(g,u,f,p,I(h,"bendPositive",!0)?1:-1,I(h,"compress",!1),I(h,"stretch",!1));const x=o[g+1];if(!x){m.shrink(b);break}const w=I(x,"time",0),S=I(x,"mix",1),y=I(x,"softness",0)*n,v=h.curve;v&&(b=G(v,m,b,g,0,u,w,f,S,1),b=G(v,m,b,g,1,u,w,p,y,n)),u=w,f=S,p=y,h=x}i.push(m)}if(t.transform)for(const l in t.transform){const o=t.transform[l];let h=o[0];if(!h)continue;const d=s.findConstraint(l,K);if(!d)throw new Error(`Transform constraint not found: ${l}`);const m=new Ke(o.length,o.length*6,s.constraints.indexOf(d));let u=I(h,"time",0),f=I(h,"mixRotate",1),p=I(h,"mixX",1),g=I(h,"mixY",p),b=I(h,"mixScaleX",1),x=I(h,"mixScaleY",1),w=I(h,"mixShearY",1);for(let S=0,y=0;;S++){m.setFrame(S,u,f,p,g,b,x,w);const v=o[S+1];if(!v){m.shrink(y);break}const T=I(v,"time",0),A=I(v,"mixRotate",1),M=I(v,"mixX",1),C=I(v,"mixY",M),Y=I(v,"mixScaleX",1),P=I(v,"mixScaleY",1),E=I(v,"mixShearY",1),X=h.curve;X&&(y=G(X,m,y,S,0,u,T,f,A,1),y=G(X,m,y,S,1,u,T,p,M,1),y=G(X,m,y,S,2,u,T,g,C,1),y=G(X,m,y,S,3,u,T,b,Y,1),y=G(X,m,y,S,4,u,T,x,P,1),y=G(X,m,y,S,5,u,T,w,E,1)),u=T,f=A,p=M,g=C,b=Y,x=P,w=E,h=v}i.push(m)}if(t.path)for(const l in t.path){const o=t.path[l],h=s.findConstraint(l,Ht);if(!h)throw new Error(`Path constraint not found: ${l}`);const d=s.constraints.indexOf(h);for(const m in o){const u=o[m];let f=u[0];if(!f)continue;const p=u.length;switch(m){case"position":{const g=new Je(p,p,d);ct(i,u,g,0,h.positionMode===0?n:1);break}case"spacing":{const g=new Qe(p,p,d);ct(i,u,g,0,h.spacingMode===0||h.spacingMode===1?n:1);break}case"mix":{const g=new Ze(p,p*3,d);let b=I(f,"time",0),x=I(f,"mixRotate",1),w=I(f,"mixX",1),S=I(f,"mixY",w);for(let y=0,v=0;;y++){g.setFrame(y,b,x,w,S);const T=u[y+1];if(!T){g.shrink(v);break}const A=I(T,"time",0),M=I(T,"mixRotate",1),C=I(T,"mixX",1),Y=I(T,"mixY",C),P=f.curve;P&&(v=G(P,g,v,y,0,b,A,x,M,1),v=G(P,g,v,y,1,b,A,w,C,1),v=G(P,g,v,y,2,b,A,S,Y,1)),b=A,x=M,w=C,S=Y,f=T}i.push(g);break}}}}if(t.physics)for(const l in t.physics){const o=t.physics[l];let h=-1;if(l.length>0){const d=s.findConstraint(l,Gt);if(!d)throw new Error(`Physics constraint not found: ${l}`);h=s.constraints.indexOf(d)}for(const d in o){const m=o[d];let u=m[0];if(!u)continue;const f=m.length;let p,g=0;if(d==="reset"){const b=new as(f,h);for(let x=0;u!=null;u=m[x+1],x++)b.setFrame(x,I(u,"time",0));i.push(b);continue}switch(d){case"inertia":p=new ts(f,f,h);break;case"strength":p=new es(f,f,h);break;case"damping":p=new ss(f,f,h);break;case"mass":p=new ns(f,f,h);break;case"wind":p=new is(f,f,h);break;case"gravity":p=new rs(f,f,h);break;case"mix":{g=1,p=new os(f,f,h);break}default:continue}ct(i,m,p,g,1)}}if(t.slider)for(const l in t.slider){const o=t.slider[l],h=s.findConstraint(l,St);if(!h)throw new Error(`Slider not found: ${l}`);const d=s.constraints.indexOf(h);for(const m in o){const u=o[m];if(!u[0])continue;const p=u.length;switch(m){case"time":ct(i,u,new cs(p,p,d),1,1);break;case"mix":ct(i,u,new ls(p,p,d),1,1);break}}}if(t.attachments)for(const l in t.attachments){const o=t.attachments[l],h=s.findSkin(l);if(!h)throw new Error(`Skin not found: ${l}`);for(const d in o){const m=o[d],u=s.findSlot(d);if(!u)throw new Error(`Attachment slot not found: ${d}`);const f=u.index;for(const p in m){const g=m[p],b=h.getAttachment(f,p);if(!b)throw new Error(`Timeline attachment not found: ${p}`);for(const x in g){const w=g[x];let S=w[0];if(S){if(x==="deform"){const y=b.bones,v=b.vertices,T=y?v.length/3*2:v.length,A=new He(w.length,w.length,f,b);let M=I(S,"time",0);for(let C=0,Y=0;;C++){let P;const E=I(S,"vertices",null);if(!E)P=y?L.newFloatArray(T):v;else{P=L.newFloatArray(T);const $=I(S,"offset",0);if(L.arrayCopy(E,0,P,$,E.length),n!==1)for(let U=$,F=U+E.length;U<F;U++)P[U]*=n;if(!y)for(let U=0;U<T;U++)P[U]+=v[U]}A.setFrame(C,M,P);const X=w[C+1];if(!X){A.shrink(Y);break}const V=I(X,"time",0),N=S.curve;N&&(Y=G(N,A,Y,C,0,M,V,0,1,1)),M=V,S=X}i.push(A)}else if(x==="sequence"){const y=new Ge(w.length,f,b);let v=0;for(let T=0;T<w.length;T++){const A=I(S,"delay",v),M=I(S,"time",0),C=ke[I(S,"mode","hold")],Y=I(S,"index",0);y.setFrame(T,M,C,Y,A),v=A,S=w[T+1]}i.push(y)}}}}}}if(t.drawOrder){const l=new At(t.drawOrder.length),o=s.slots.length;let h=0;for(const d of t.drawOrder)l.setFrame(h++,I(d,"time",0),xn(s,d,o,null));i.push(l)}if(t.drawOrderFolder)for(const l of t.drawOrderFolder){const o=I(l,"slots",[]),h=new Array(o.length);let d=0;for(const p of o){const g=s.findSlot(p);if(!g)throw new Error(`Draw order folder slot not found: ${p}`);h[d++]=g.index}const m=I(l,"keys",[]),u=new qt(m.length,h,s.slots.length);let f=0;for(const p of m)u.setFrame(f++,I(p,"time",0),xn(s,p,h.length,h));i.push(u)}if(t.events){const l=new te(t.events.length);let o=0;for(let h=0;h<t.events.length;h++,o++){const d=t.events[h],m=s.findEvent(d.name);if(!m)throw new Error(`Event not found: ${d.name}`);const u=m.setupPose,f=new ae(L.toSinglePrecision(I(d,"time",0)),m);f.intValue=I(d,"int",u.intValue),f.floatValue=I(d,"float",u.floatValue),f.stringValue=I(d,"string",u.stringValue),f.data.audioPath&&(f.volume=I(d,"volume",u.volume),f.balance=I(d,"balance",u.volume)),l.setFrame(o,f)}i.push(l)}let r=0;for(let l=0,o=i.length;l<o;l++)r=Math.max(r,i[l].getDuration());const a=new Qt(e,i,r),c=I(t,"color",null);c!==null&&a.color.setFromString(c),s.animations.push(a)}},Vi=class{source;skin;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(t,e,s,n,i,r){this.mesh=t,this.skin=e,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}};function ct(t,e,s,n,i){let r=e[0],a=r.time??0,c=(r.value??n)*i,l=0;for(let o=0;;o++){s.setFrame(o,a,c);const h=e[o+1];if(!h){s.shrink(l),t.push(s);return}const d=h.time??0,m=(h.value??n)*i;r.curve&&(l=G(r.curve,s,l,o,0,a,d,c,m,i)),a=d,c=m,r=h}}function Rs(t,e,s,n,i,r,a){let c=e[0],l=c.time??0,o=(c[n]??r)*a,h=(c[i]??r)*a,d=0;for(let m=0;;m++){s.setFrame(m,l,o,h);const u=e[m+1];if(!u){s.shrink(d),t.push(s);return}const f=u.time??0,p=(u[n]??r)*a,g=(u[i]??r)*a,b=c.curve;b&&(d=G(b,s,d,m,0,l,f,o,p,a),d=G(b,s,d,m,1,l,f,h,g,a)),l=f,o=p,h=g,c=u}}function xn(t,e,s,n){const i=e.offsets;if(!i)return null;const r=new Array(s).fill(-1),a=new Array(s-i.length);let c=0,l=0;for(const o of i){const h=t.findSlot(o.slot);if(h==null)throw new Error(`Draw order slot not found: ${o.slot}`);let d=0;if(!n)d=h.index;else{d=-1;for(let m=0;m<s;m++)if(n[m]===h.index){d=m;break}if(d===-1)throw new Error(`Slot not in folder: ${o.slot}`)}for(;c!==d;)a[l++]=c++;r[c+o.offset]=c++}for(;c<s;)a[l++]=c++;for(let o=s-1;o>=0;o--)r[o]===-1&&(r[o]=a[--l]);return r}function G(t,e,s,n,i,r,a,c,l,o){if(t==="stepped")return e.setStepped(n),s;const h=i<<2,d=t[h],m=t[h+1]*o,u=t[h+2],f=t[h+3]*o;return e.setBezier(s,n,i,r,c,d,m,u,f,a,l),s+1}function I(t,e,s){return t[e]!==void 0?t[e]:s}var Ri=class{commandPool=new Li;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new bn;renderCommands=[];render(t,e=!1,s,n=2){this.commandPool.reset(),this.renderCommands.length=0;const i=this.clipping,r=t.drawOrder.appliedPose;for(let a=0;a<t.slots.length;a++){const c=r[a],l=c.appliedPose.attachment;if(!l){i.clipEnd(c);continue}const o=c.appliedPose,h=o.color;if((h.a===0||!c.bone.active)&&!(l instanceof zt)){i.clipEnd(c);continue}let m,u,f,p,g,b,x;if(l instanceof j){if(b=l.color,b.a===0){i.clipEnd(c);continue}const T=l.sequence,A=T.resolveIndex(o);l.computeWorldVertices(c,l.getOffsets(o),this.worldVertices,0,n),m=this.worldVertices,u=4,f=T.getUVs(A),p=this.quadIndices,g=6,x=T.regions[A]?.texture}else if(l instanceof wt){if(b=l.color,b.a===0){i.clipEnd(c);continue}this.worldVertices.length<l.worldVerticesLength&&(this.worldVertices=new Float32Array(l.worldVerticesLength)),l.computeWorldVertices(t,c,0,l.worldVerticesLength,this.worldVertices,0,n),m=this.worldVertices,u=l.worldVerticesLength>>1;const T=l.sequence,A=T.resolveIndex(o);f=T.getUVs(A),p=l.triangles,g=p.length,x=T.regions[A]?.texture}else if(l instanceof zt){i.clipStart(t,c,l);continue}else continue;const w=t.color;let S,y;if(e){let T;if(s){T=Math.floor(s[3]*w.a*h.a*b.a*255);const A=Math.floor(T*s[0]*w.r*h.r*b.r),M=Math.floor(T*s[1]*w.g*h.g*b.g),C=Math.floor(T*s[2]*w.b*h.b*b.b);S=T<<24|A<<16|M<<8|C}else{T=Math.floor(w.a*h.a*b.a*255);const A=Math.floor(T*w.r*h.r*b.r),M=Math.floor(T*w.g*h.g*b.g),C=Math.floor(T*w.b*h.b*b.b);S=T<<24|A<<16|M<<8|C}if(y=4278190080,o.darkColor){const{r:A,g:M,b:C}=o.darkColor;y=4278190080|Math.floor(A*T)<<16|Math.floor(M*T)<<8|Math.floor(C*T)}}else{if(s){const T=Math.floor(s[3]*w.a*h.a*b.a*255),A=Math.floor(s[0]*w.r*h.r*b.r*255),M=Math.floor(s[1]*w.g*h.g*b.g*255),C=Math.floor(s[2]*w.b*h.b*b.b*255);S=T<<24|A<<16|M<<8|C}else{const T=Math.floor(w.a*h.a*b.a*255),A=Math.floor(w.r*h.r*b.r*255),M=Math.floor(w.g*h.g*b.g*255),C=Math.floor(w.b*h.b*b.b*255);S=T<<24|A<<16|M<<8|C}if(y=0,o.darkColor){const{r:T,g:A,b:M}=o.darkColor;y=Math.floor(T*255)<<16|Math.floor(A*255)<<8|Math.floor(M*255)}}i.isClipping()&&(i.clipTrianglesUnpacked(m,0,p,g,f,n),m=i.clippedVerticesTyped,u=i.clippedVerticesLength/n,f=i.clippedUVsTyped,p=i.clippedTrianglesTyped,g=i.clippedTrianglesLength);const v=this.commandPool.getCommand(u,g,n);v.blendMode=c.data.blendMode,v.texture=x,v.positions.set(m.subarray(0,u*n)),v.uvs.set(f.subarray(0,u<<1));for(let T=0;T<u;T++)v.colors[T]=S,v.darkColors[T]=y;p instanceof Uint16Array?v.indices.set(p.subarray(0,g)):v.indices.set(p.slice(0,g)),this.renderCommands.push(v),i.clipEnd(c)}return i.clipEnd(),this.batchCommands(n)}batchSubCommands(t,e,s,n,i,r){const a=t[e],c=this.commandPool.getCommand(n,i,r);c.blendMode=a.blendMode,c.texture=a.texture;let l=0,o=0,h=0,d=0,m=0;for(let u=e;u<=s;u++){const f=t[u];c.positions.set(f.positions,l),l+=f.numVertices*r,c.uvs.set(f.uvs,o),o+=f.numVertices<<1,c.colors.set(f.colors,h),c.darkColors.set(f.darkColors,h),h+=f.numVertices;for(let p=0;p<f.numIndices;p++)c.indices[d+p]=f.indices[p]+m;d+=f.numIndices,m+=f.numVertices}return c}batchCommands(t){if(this.renderCommands.length===0)return;let e,s,n=this.renderCommands[0],i=0,r=1,a=n.numVertices,c=n.numIndices;for(;r<=this.renderCommands.length;){const l=r<this.renderCommands.length?this.renderCommands[r]:null;if(l&&l.numVertices===0&&l.numIndices===0){r++;continue}if(l!==null&&l.texture===n.texture&&l.blendMode===n.blendMode&&l.colors[0]===n.colors[0]&&l.darkColors[0]===n.darkColors[0]&&c+l.numIndices<65535)a+=l.numVertices,c+=l.numIndices;else{const h=this.batchSubCommands(this.renderCommands,i,r-1,a,c,t);if(s?(s.next=h,s=h):e=s=h,r===this.renderCommands.length)break;n=this.renderCommands[r],i=r,a=n.numVertices,c=n.numIndices}r++}return e}},Li=class{pool=[];inUse=[];getCommand(t,e,s){let n;for(const i of this.pool)if(i._positions.length>=t*s&&i._indices.length>=e){n=i;break}if(n)this.pool.splice(this.pool.indexOf(n),1),n.next=void 0,n.numVertices=t,n.numIndices=e,n.positions=n._positions.subarray(0,t*s),n.uvs=n._uvs.subarray(0,t<<1),n.colors=n._colors.subarray(0,t),n.darkColors=n._darkColors.subarray(0,t),n.indices=n._indices.subarray(0,e);else{const i=new Float32Array(t*s),r=new Float32Array(t<<1),a=new Uint32Array(t),c=new Uint32Array(t),l=new Uint16Array(e);n={positions:i,uvs:r,colors:a,darkColors:c,indices:l,_positions:i,_uvs:r,_colors:a,_darkColors:c,_indices:l,numVertices:t,numIndices:e,blendMode:0,texture:null}}return this.inUse.push(n),n}reset(){this.pool.push(...this.inUse),this.inUse.length=0}},wn=class extends Ce{constructor(t){super(t)}setFilters(t,e){}setWraps(t,e){}dispose(){}},Bi=class extends en{constructor(t="",e=new gs){super(s=>new wn(s),t,e)}},Oi=L.newFloatArray(8),Ni=class Ae{static QUAD_TRIANGLES=[0,1,2,2,3,0];static VERTEX_SIZE=8;ctx;triangleRendering=!1;debugRendering=!1;vertices=L.newFloatArray(8*1024);tempColor=new z;constructor(e){this.ctx=e}draw(e){this.triangleRendering?this.drawTriangles(e):this.drawImages(e)}drawImages(e){const s=this.ctx,n=this.tempColor,i=e.color,r=e.drawOrder.appliedPose;this.debugRendering&&(s.strokeStyle="green");for(let a=0,c=r.length;a<c;a++){const l=r[a],o=l.bone;if(!o.active)continue;const h=l.appliedPose,d=h.attachment;if(!(d instanceof j))continue;const m=d.sequence,u=m.resolveIndex(h);d.computeWorldVertices(l,d.getOffsets(h),Oi,0,2);const f=m.regions[u],p=f.texture.getImage(),g=h.color,b=d.color;n.set(i.r*g.r*b.r,i.g*g.g*b.g,i.b*g.b*b.b,i.a*g.a*b.a),s.save();const x=o.appliedPose;s.transform(x.a,x.c,x.b,x.d,x.worldX,x.worldY);const w=d.getOffsets(h);s.translate(w[0],w[1]),s.rotate(d.rotation*Math.PI/180);const S=d.width/f.originalWidth;s.scale(S*d.scaleX,S*d.scaleY);let y=f.width,v=f.height;if(s.translate(y/2,v/2),f.degrees===90){const T=y;y=v,v=T,s.rotate(-Math.PI/2)}s.scale(1,-1),s.translate(-y/2,-v/2),s.globalAlpha=n.a,s.drawImage(p,p.width*f.u,p.height*f.v,y,v,0,0,y,v),this.debugRendering&&s.strokeRect(0,0,y,v),s.restore()}}drawTriangles(e){const s=this.ctx,n=this.tempColor,i=e.color,r=e.drawOrder.appliedPose;let a=null,c=this.vertices,l=null;for(let o=0,h=r.length;o<h;o++){const d=r[o],m=d.appliedPose,u=m.attachment;let f;if(u instanceof j){const p=u.sequence,g=p.resolveIndex(m),b=p.getUVs(g),x=u.getOffsets(m);c=this.computeRegionVertices(d,u,x,b,!1),l=Ae.QUAD_TRIANGLES,f=(p.regions[g]?.texture).getImage()}else if(u instanceof wt){const p=u.sequence,g=p.resolveIndex(m),b=p.getUVs(g);c=this.computeMeshVertices(d,u,b,!1),l=u.triangles,f=(p.regions[g]?.texture).getImage()}else continue;if(f){d.data.blendMode!==a&&(a=d.data.blendMode);const p=m.color,g=u.color;n.set(i.r*p.r*g.r,i.g*p.g*g.g,i.b*p.b*g.b,i.a*p.a*g.a),s.globalAlpha=n.a;for(let b=0;b<l.length;b+=3){const x=l[b]*8,w=l[b+1]*8,S=l[b+2]*8,y=c[x],v=c[x+1],T=c[x+6],A=c[x+7],M=c[w],C=c[w+1],Y=c[w+6],P=c[w+7],E=c[S],X=c[S+1],V=c[S+6],N=c[S+7];this.drawTriangle(f,y,v,T,A,M,C,Y,P,E,X,V,N),this.debugRendering&&(s.strokeStyle="green",s.beginPath(),s.moveTo(y,v),s.lineTo(M,C),s.lineTo(E,X),s.lineTo(y,v),s.stroke())}}}this.ctx.globalAlpha=1}drawTriangle(e,s,n,i,r,a,c,l,o,h,d,m,u){const f=this.ctx,p=e.width-1,g=e.height-1;i*=p,r*=g,l*=p,o*=g,m*=p,u*=g,f.beginPath(),f.moveTo(s,n),f.lineTo(a,c),f.lineTo(h,d),f.closePath(),a-=s,c-=n,h-=s,d-=n,l-=i,o-=r,m-=i,u-=r;let b=l*u-m*o;if(b===0)return;b=1/b;const x=(u*a-o*h)*b,w=(u*c-o*d)*b,S=(l*h-m*a)*b,y=(l*d-m*c)*b,v=s-x*i-S*r,T=n-w*i-y*r;f.save(),f.transform(x,w,S,y,v,T),f.clip(),f.drawImage(e,0,0),f.restore()}computeRegionVertices(e,s,n,i,r){const a=e.skeleton.color,c=e.appliedPose.color,l=s.color,o=a.a*c.a*l.a,h=r?o:1,d=this.tempColor;d.set(a.r*c.r*l.r*h,a.g*c.g*l.g*h,a.b*c.b*l.b*h,o),s.computeWorldVertices(e,n,this.vertices,0,Ae.VERTEX_SIZE);const m=this.vertices;return m[j.C1R]=d.r,m[j.C1G]=d.g,m[j.C1B]=d.b,m[j.C1A]=d.a,m[j.U1]=i[0],m[j.V1]=i[1],m[j.C2R]=d.r,m[j.C2G]=d.g,m[j.C2B]=d.b,m[j.C2A]=d.a,m[j.U2]=i[2],m[j.V2]=i[3],m[j.C3R]=d.r,m[j.C3G]=d.g,m[j.C3B]=d.b,m[j.C3A]=d.a,m[j.U3]=i[4],m[j.V3]=i[5],m[j.C4R]=d.r,m[j.C4G]=d.g,m[j.C4B]=d.b,m[j.C4A]=d.a,m[j.U4]=i[6],m[j.V4]=i[7],m}computeMeshVertices(e,s,n,i){const r=e.skeleton,a=r.color,c=e.appliedPose.color,l=s.color,o=a.a*c.a*l.a,h=i?o:1,d=this.tempColor;d.set(a.r*c.r*l.r*h,a.g*c.g*l.g*h,a.b*c.b*l.b*h,o);const m=s.worldVerticesLength/2;let u=this.vertices;u.length<s.worldVerticesLength&&(this.vertices=u=L.newFloatArray(s.worldVerticesLength)),s.computeWorldVertices(r,e,0,s.worldVerticesLength,u,0,Ae.VERTEX_SIZE);for(let f=0,p=0,g=2;f<m;f++)u[g++]=d.r,u[g++]=d.g,u[g++]=d.b,u[g++]=d.a,u[g++]=n[p++],u[g++]=n[p++],g+=2;return u}};export{ms as ATTACH_RETAIN,us as ATTACH_SETUP,_e as AlphaTimeline,Qt as Animation,Dn as AnimationState,$n as AnimationStateAdapter,qn as AnimationStateData,sn as AssetCache,Bi as AssetManager,en as AssetManagerBase,_n as AtlasAttachmentLoader,Fe as Attachment,kt as AttachmentTimeline,un as BinaryInput,Ys as BlendMode,re as Bone,bs as BoneData,ie as BonePose,vt as BoneTimeline1,Zt as BoneTimeline2,ps as BoundingBoxAttachment,hs as CURRENT,wn as CanvasTexture,zt as ClippingAttachment,z as Color,Et as Constraint,Xt as ConstraintData,Pt as ConstraintTimeline1,yt as CurveTimeline,Ut as CurveTimeline1,Ln as DebugUtils,He as DeformTimeline,gs as Downloader,rn as DrawOrder,qt as DrawOrderFolderTimeline,At as DrawOrderTimeline,ae as Event,ys as EventData,Qs as EventQueue,te as EventTimeline,Zs as EventType,ds as FIRST,Nn as FakeTexture,It as FromProperty,ge as FromRotate,xe as FromScaleX,we as FromScaleY,ye as FromShearY,pe as FromX,be as FromY,_t as HOLD,on as IkConstraint,Wt as IkConstraintData,ce as IkConstraintPose,je as IkConstraintTimeline,ne as Inherit,De as InheritTimeline,Vn as IntSet,Bt as Interpolation,fs as MODE,R as MathUtils,wt as MeshAttachment,Ws as MixFrom,ee as PathAttachment,an as PathConstraint,Ht as PathConstraintData,Ze as PathConstraintMixTimeline,le as PathConstraintPose,Je as PathConstraintPositionTimeline,Qe as PathConstraintSpacingTimeline,cn as Physics,As as PhysicsConstraint,ss as PhysicsConstraintDampingTimeline,Gt as PhysicsConstraintData,rs as PhysicsConstraintGravityTimeline,ts as PhysicsConstraintInertiaTimeline,ns as PhysicsConstraintMassTimeline,os as PhysicsConstraintMixTimeline,he as PhysicsConstraintPose,as as PhysicsConstraintResetTimeline,es as PhysicsConstraintStrengthTimeline,bt as PhysicsConstraintTimeline,is as PhysicsConstraintWindTimeline,nn as PointAttachment,Ot as Pool,xs as Posed,ws as PosedActive,se as PosedData,vs as PositionMode,$s as Pow,Rn as PowOut,Hs as Property,We as RGB2Timeline,ze as RGBA2Timeline,$e as RGBATimeline,qe as RGBTimeline,j as RegionAttachment,Ts as RotateMode,Dt as RotateTimeline,tn as SETUP,Re as ScaleTimeline,Le as ScaleXTimeline,oe as ScaleYMode,Be as ScaleYTimeline,Nt as Sequence,ke as SequenceMode,Pe as SequenceModeValues,Ge as SequenceTimeline,Oe as ShearTimeline,Ne as ShearXTimeline,Ue as ShearYTimeline,hn as Skeleton,zn as SkeletonBinary,Ei as SkeletonBounds,bn as SkeletonClipping,Is as SkeletonData,Xi as SkeletonJson,Ni as SkeletonRenderer,Ri as SkeletonRendererCore,ue as Skin,Cs as SkinEntry,dn as Slider,St as SliderData,ls as SliderMixTimeline,fe as SliderPose,cs as SliderTimeline,ln as Slot,$t as SlotCurveTimeline,Ms as SlotData,de as SlotPose,Ss as SpacingMode,Ds as StringSet,Ce as Texture,Me as TextureAtlas,zs as TextureAtlasPage,Ye as TextureAtlasRegion,Jt as TextureFilter,_s as TextureRegion,qs as TextureWrap,Bn as TimeKeeper,Z as Timeline,Ct as ToProperty,Fs as ToRotate,Es as ToScaleX,Xs as ToScaleY,Vs as ToShearY,ks as ToX,Ps as ToY,Js as TrackEntry,fn as TransformConstraint,K as TransformConstraintData,me as TransformConstraintPose,Ke as TransformConstraintTimeline,Ee as TranslateTimeline,Xe as TranslateXTimeline,Ve as TranslateYTimeline,pn as Triangulator,L as Utils,Ie as Vector2,xt as VertexAttachment,On as WindowedMean,js as isBoneTimeline,Ks as isConstraintTimeline,Gs as isSlotTimeline};