@esotericsoftware/spine-canvas 4.3.5 → 4.3.7

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 spine=(()=>{var Ce=Object.defineProperty,Xn=Object.getOwnPropertyDescriptor,Vn=Object.getOwnPropertyNames,Rn=Object.prototype.hasOwnProperty,Ln=(t,e)=>{for(var s in e)Ce(t,s,{get:e[s],enumerable:!0})},Bn=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vn(e))!Rn.call(t,i)&&i!==s&&Ce(t,i,{get:()=>e[i],enumerable:!(n=Xn(e,i))||n.enumerable});return t},On=t=>Bn(Ce({},"__esModule",{value:!0}),t),Ds={};Ln(Ds,{AlphaTimeline:()=>Ge,Animation:()=>Kt,AnimationState:()=>Wn,AnimationStateAdapter:()=>Gn,AnimationStateData:()=>Hn,AssetCache:()=>tn,AssetManager:()=>qi,AssetManagerBase:()=>Zs,AtlasAttachmentLoader:()=>jn,Attachment:()=>Ee,AttachmentTimeline:()=>Ft,BinaryInput:()=>dn,BlendMode:()=>Ps,Bone:()=>re,BoneData:()=>bs,BonePose:()=>ie,BoneTimeline1:()=>vt,BoneTimeline2:()=>Qt,BoundingBoxAttachment:()=>ps,CanvasTexture:()=>bn,ClippingAttachment:()=>zt,Color:()=>z,Constraint:()=>Et,ConstraintData:()=>Xt,ConstraintTimeline1:()=>kt,CurveTimeline:()=>yt,CurveTimeline1:()=>Nt,DebugUtils:()=>Un,DeformTimeline:()=>Je,Downloader:()=>gs,DrawOrder:()=>sn,DrawOrderFolderTimeline:()=>qt,DrawOrderTimeline:()=>At,Event:()=>oe,EventData:()=>ys,EventQueue:()=>Js,EventTimeline:()=>Zt,EventType:()=>Ks,FIRST:()=>$t,FakeTexture:()=>_n,FromProperty:()=>It,FromRotate:()=>ge,FromScaleX:()=>xe,FromScaleY:()=>we,FromShearY:()=>ye,FromX:()=>pe,FromY:()=>be,HOLD:()=>_t,HOLD_FIRST:()=>Qs,IkConstraint:()=>nn,IkConstraintData:()=>Wt,IkConstraintPose:()=>le,IkConstraintTimeline:()=>Qe,Inherit:()=>ne,InheritTimeline:()=>_e,IntSet:()=>Nn,Interpolation:()=>Lt,MathUtils:()=>R,MeshAttachment:()=>wt,PathAttachment:()=>ee,PathConstraint:()=>rn,PathConstraintData:()=>Gt,PathConstraintMixTimeline:()=>ss,PathConstraintPose:()=>ce,PathConstraintPositionTimeline:()=>ts,PathConstraintSpacingTimeline:()=>es,Physics:()=>an,PhysicsConstraint:()=>As,PhysicsConstraintDampingTimeline:()=>rs,PhysicsConstraintData:()=>Ht,PhysicsConstraintGravityTimeline:()=>ls,PhysicsConstraintInertiaTimeline:()=>ns,PhysicsConstraintMassTimeline:()=>as,PhysicsConstraintMixTimeline:()=>cs,PhysicsConstraintPose:()=>he,PhysicsConstraintResetTimeline:()=>hs,PhysicsConstraintStrengthTimeline:()=>is,PhysicsConstraintTimeline:()=>pt,PhysicsConstraintWindTimeline:()=>os,PointAttachment:()=>en,Pool:()=>Bt,Posed:()=>xs,PosedActive:()=>ws,PosedData:()=>se,PositionMode:()=>vs,Pow:()=>Us,PowOut:()=>Dn,Property:()=>zs,RETAIN:()=>ms,RGB2Timeline:()=>je,RGBA2Timeline:()=>He,RGBATimeline:()=>ze,RGBTimeline:()=>We,RegionAttachment:()=>j,RotateMode:()=>Ss,RotateTimeline:()=>Dt,SETUP:()=>us,SUBSEQUENT:()=>te,ScaleTimeline:()=>Oe,ScaleXTimeline:()=>Ne,ScaleYMode:()=>ae,ScaleYTimeline:()=>De,Sequence:()=>Ot,SequenceMode:()=>Xe,SequenceModeValues:()=>Ve,SequenceTimeline:()=>Ke,ShearTimeline:()=>Ue,ShearXTimeline:()=>qe,ShearYTimeline:()=>$e,Skeleton:()=>ln,SkeletonBinary:()=>Jn,SkeletonBounds:()=>Bi,SkeletonClipping:()=>gn,SkeletonData:()=>Is,SkeletonJson:()=>Oi,SkeletonRenderer:()=>_i,SkeletonRendererCore:()=>Di,Skin:()=>ue,SkinEntry:()=>Cs,Slider:()=>cn,SliderData:()=>Tt,SliderMixTimeline:()=>fs,SliderPose:()=>fe,SliderTimeline:()=>ds,Slot:()=>on,SlotCurveTimeline:()=>Ut,SlotData:()=>Ms,SlotPose:()=>de,SpacingMode:()=>Ts,StringSet:()=>Me,Texture:()=>Ye,TextureAtlas:()=>Fe,TextureAtlasPage:()=>_s,TextureAtlasRegion:()=>ke,TextureFilter:()=>Jt,TextureRegion:()=>$s,TextureWrap:()=>qs,TimeKeeper:()=>qn,Timeline:()=>Z,ToProperty:()=>Ct,ToRotate:()=>Ys,ToScaleX:()=>Es,ToScaleY:()=>Xs,ToShearY:()=>Vs,ToX:()=>Fs,ToY:()=>ks,TrackEntry:()=>js,TransformConstraint:()=>hn,TransformConstraintData:()=>J,TransformConstraintPose:()=>me,TransformConstraintTimeline:()=>Ze,TranslateTimeline:()=>Re,TranslateXTimeline:()=>Le,TranslateYTimeline:()=>Be,Triangulator:()=>mn,Utils:()=>L,Vector2:()=>Pe,VertexAttachment:()=>xt,WindowedMean:()=>$n,isBoneTimeline:()=>Gs,isConstraintTimeline:()=>Hs,isSlotTimeline:()=>Ws});var Nn=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}},Me=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 ct{static epsilon=1e-5;static epsilon2=ct.epsilon*ct.epsilon;static PI=3.1415927;static PI2=ct.PI*2;static invPI2=1/ct.PI2;static radiansToDegrees=180/ct.PI;static radDeg=ct.radiansToDegrees;static degreesToRadians=ct.PI/180;static degRad=ct.degreesToRadians;static clamp(e,s,n){return e<s?s:e>n?n:e}static cosDeg(e){return Math.cos(e*ct.degRad)}static sinDeg(e){return Math.sin(e*ct.degRad)}static atan2Deg(e,s){return Math.atan2(e,s)*ct.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 ct.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}},Lt=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)}},Us=class extends Lt{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}},Dn=class extends Us{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 c=s,l=i;c<s+r;c++,l++)n[l]=e[c]}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)]}},Un=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}`)}}},Bt=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}},Pe=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}},qn=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)}},$n=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}},Ye=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},_n=class extends Ye{setFilters(t,e){}setWraps(t,e){}dispose(){}},Fe=class{pages=[];regions=[];constructor(t){const e=new zn(t),s=new Array(4),n={};n.size=a=>{a.width=parseInt(s[1]),a.height=parseInt(s[2])},n.format=()=>{},n.filter=a=>{a.minFilter=L.enumValue(Jt,s[1]),a.magFilter=L.enumValue(Jt,s[2])},n.repeat=a=>{s[1].indexOf("x")!==-1&&(a.uWrap=10497),s[1].indexOf("y")!==-1&&(a.vWrap=10497)},n.pma=a=>{a.pma=s[1]==="true"};var i={};i.xy=a=>{a.x=parseInt(s[1]),a.y=parseInt(s[2])},i.size=a=>{a.width=parseInt(s[1]),a.height=parseInt(s[2])},i.bounds=a=>{a.x=parseInt(s[1]),a.y=parseInt(s[2]),a.width=parseInt(s[3]),a.height=parseInt(s[4])},i.offset=a=>{a.offsetX=parseInt(s[1]),a.offsetY=parseInt(s[2])},i.orig=a=>{a.originalWidth=parseInt(s[1]),a.originalHeight=parseInt(s[2])},i.offsets=a=>{a.offsetX=parseInt(s[1]),a.offsetY=parseInt(s[2]),a.originalWidth=parseInt(s[3]),a.originalHeight=parseInt(s[4])},i.rotate=a=>{const h=s[1];h==="true"?a.degrees=90:h!=="false"&&(a.degrees=parseInt(h))},i.index=a=>{a.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 c=null,l=null,o=null;for(;r!==null;)if(r.trim().length===0)c=null,r=e.readLine();else if(c){const a=new ke(c,r);for(;;){const h=e.readEntry(s,r=e.readLine());if(h===0)break;const d=i[s[0]];if(d)d(a);else{l||(l=[]),o||(o=[]),l.push(s[0]);const f=[];for(let u=0;u<h;u++)f.push(parseInt(s[u+1]));o.push(f)}}a.originalWidth===0&&a.originalHeight===0&&(a.originalWidth=a.width,a.originalHeight=a.height),l&&l.length>0&&o&&o.length>0&&(a.names=l,a.values=o,l=null,o=null),a.u=a.x/c.width,a.v=a.y/c.height,a.degrees===90?(a.u2=(a.x+a.height)/c.width,a.v2=(a.y+a.width)/c.height):(a.u2=(a.x+a.width)/c.width,a.v2=(a.y+a.height)/c.height),this.regions.push(a)}else{for(c=new _s(r.trim());e.readEntry(s,r=e.readLine())!==0;){const a=n[s[0]];a&&a(c)}this.pages.push(c)}}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()}},zn=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}}},_s=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}},ke=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)}},Ee=class xn{static empty=[];name;timelineAttachment;timelineSlots=xn.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,c=this.timelineSlots.length;r<c;r++){if(i=e[this.timelineSlots[r]],!i.bone.isActive())continue;const l=(n?i.getAppliedPose():i.getPose()).getAttachment();if(l!=null&&l.timelineAttachment===this)return!0}return!1}},xt=class wn extends Ee{static nextID=0;id=wn.nextID++;bones=null;vertices=[];worldVerticesLength=0;constructor(e){super(e)}computeWorldVertices(e,s,n,i,r,c,l){i=c+(i>>1)*l;const o=s.appliedPose.deform;let a=this.vertices;const h=this.bones;if(!h){o.length>0&&(a=o);const m=s.bone.appliedPose,p=m.worldX,g=m.worldY,b=m.a,x=m.b,w=m.c,T=m.d;for(let y=n,v=c;v<i;y+=2,v+=l){const S=a[y],A=a[y+1];r[v]=S*b+A*x+p,r[v+1]=S*w+A*T+g}return}let d=0,f=0;for(let m=0;m<n;m+=2){const p=h[d];d+=p+1,f+=p}const u=e.bones;if(o.length===0)for(let m=c,p=f*3;m<i;m+=l){let g=0,b=0,x=h[d++];for(x+=d;d<x;d++,p+=3){const w=u[h[d]].appliedPose,T=a[p],y=a[p+1],v=a[p+2];g+=(T*w.a+y*w.b+w.worldX)*v,b+=(T*w.c+y*w.d+w.worldY)*v}r[m]=g,r[m+1]=b}else{const m=o;for(let p=c,g=f*3,b=f<<1;p<i;p+=l){let x=0,w=0,T=h[d++];for(T+=d;d<T;d++,g+=3,b+=2){const y=u[h[d]].appliedPose,v=a[g]+m[b],S=a[g+1]+m[b+1],A=a[g+2];x+=(v*y.a+S*y.b+y.worldX)*A,w+=(v*y.c+S*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,c=e.v,l=0,o=0;if(e instanceof ke){const a=e.page,h=a.width,d=a.height;switch(e.degrees){case 90:r-=(e.originalHeight-e.offsetY-e.height)/h,c-=(e.originalWidth-e.offsetX-e.width)/d,l=e.originalHeight/h,o=e.originalWidth/d;for(let f=0;f<i;f+=2)n[f]=r+s[f+1]*l,n[f+1]=c+(1-s[f])*o;return;case 180:r-=(e.originalWidth-e.offsetX-e.width)/h,c-=e.offsetY/d,l=e.originalWidth/h,o=e.originalHeight/d;for(let f=0;f<i;f+=2)n[f]=r+(1-s[f])*l,n[f+1]=c+(1-s[f+1])*o;return;case 270:r-=e.offsetY/h,c-=e.offsetX/d,l=e.originalHeight/h,o=e.originalWidth/d;for(let f=0;f<i;f+=2)n[f]=r+(1-s[f+1])*l,n[f+1]=c+s[f]*o;return;default:r-=e.offsetX/h,c-=(e.originalHeight-e.offsetY-e.height)/d,l=e.originalWidth/h,o=e.originalHeight/d}}else e?(l=e.u2-r,o=e.v2-c):(r=c=0,l=o=1);for(let a=0;a<i;a+=2)n[a]=r+s[a]*l,n[a+1]=c+s[a+1]*o}},j=class yn extends Ee{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 yn(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 c=e.bone.appliedPose,l=c.worldX,o=c.worldY,a=c.a,h=c.b,d=c.c,f=c.d;let u=s[0],m=s[1];n[i]=u*a+m*h+l,n[i+1]=u*d+m*f+o,i+=r,u=s[2],m=s[3],n[i]=u*a+m*h+l,n[i+1]=u*d+m*f+o,i+=r,u=s[4],m=s[5],n[i]=u*a+m*h+l,n[i+1]=u*d+m*f+o,i+=r,u=s[6],m=s[7],n[i]=u*a+m*h+l,n[i+1]=u*d+m*f+o}getOffsets(e){return this.sequence.offsets[this.sequence.resolveIndex(e)]}updateSequence(){this.sequence.update(this)}static computeUVs(e,s,n,i,r,c,l,o,a,h){if(!e)throw new Error("Region not set.");const d=l/e.originalWidth*i,f=o/e.originalHeight*r,u=-l/2*i+e.offsetX*d,m=-o/2*r+e.offsetY*f,p=u+e.width*d,g=m+e.height*f,b=c*R.degRad,x=Math.cos(b),w=Math.sin(b),T=u*x+s,y=u*w,v=m*x+n,S=m*w,A=p*x+s,I=p*w,M=g*x+n,P=g*w;a[0]=T-S,a[1]=v+y,a[2]=T-P,a[3]=M+y,a[4]=A-P,a[5]=M+I,a[6]=A-S,a[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},Ot=class Te{static _nextID=0;id=Te.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 Te(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 Te._nextID++}},Xe=(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))(Xe||{}),Ve=[0,1,2,3,4,5,6],Kt=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 Me,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),Gs(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,c,l,o,a){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,f=h.length;d<f;d++)h[d].apply(t,e,s,i,r,c,l,o,a)}},zs=(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.ikConstraint=15]="ikConstraint",t[t.transformConstraint=16]="transformConstraint",t[t.pathConstraintPosition=17]="pathConstraintPosition",t[t.pathConstraintSpacing=18]="pathConstraintSpacing",t[t.pathConstraintMix=19]="pathConstraintMix",t[t.physicsConstraintInertia=20]="physicsConstraintInertia",t[t.physicsConstraintStrength=21]="physicsConstraintStrength",t[t.physicsConstraintDamping=22]="physicsConstraintDamping",t[t.physicsConstraintMass=23]="physicsConstraintMass",t[t.physicsConstraintWind=24]="physicsConstraintWind",t[t.physicsConstraintGravity=25]="physicsConstraintGravity",t[t.physicsConstraintMix=26]="physicsConstraintMix",t[t.physicsConstraintReset=27]="physicsConstraintReset",t[t.sequence=28]="sequence",t[t.sliderTime=29]="sliderTime",t[t.sliderMix=30]="sliderMix",t))(zs||{}),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 Ws(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,c,l,o,a,h){const d=this.curves;let f=this.getFrameCount()+t*18;s===0&&(d[e]=2+f);const u=(n-r*2+l)*.03,m=(i-c*2+o)*.03,p=((r-l)*3-n+a)*.006,g=((c-o)*3-i+h)*.006;let b=u*2+p,x=m*2+g,w=(r-n)*.3+u+p*.16666667,T=(c-i)*.3+m+g*.16666667,y=n+w,v=i+T;for(let S=f+18;f<S;f+=2)d[f]=y,d[f+1]=v,w+=b,T+=x,b+=p,x+=g,y+=w,v+=T}getBezierValue(t,e,s,n){const i=this.curves;if(i[n]>t){const o=this.frames[e],a=this.frames[e+s];return a+(t-o)/(i[n]-o)*(i[n+1]-a)}const r=n+18;for(n+=2;n<r;n+=2)if(i[n]>=t){const o=i[n-2],a=i[n-1];return a+(t-o)/(i[n]-o)*(i[n+1]-a)}e+=this.getFrameEntries();const c=i[r-2],l=i[r-1];return l+(t-c)/(this.frames[e]-c)*(this.frames[e+s]-l)}},Nt=class extends yt{constructor(t,e,s){super(t,e,s)}getFrameEntries(){return 2}setFrame(t,e,s){t<<=1,this.frames[t]=e,this.frames[t+1]=s}getCurveValue(t){const e=this.frames;let s=e.length-2;for(let i=2;i<=s;i+=2)if(e[i]>t){s=i-2;break}const n=this.curves[s>>1];switch(n){case 0:{const i=e[s],r=e[s+1];return r+(t-i)/(e[s+2]-i)*(e[s+2+1]-r)}case 1:return e[s+1]}return this.getBezierValue(t,s,1,n-2)}getRelativeValue(t,e,s,n,i,r){if(t<this.frames[0])return s?r:i;const c=this.getCurveValue(t);return s?r+c*e:i+(n?c:c+r-i)*e}getAbsoluteValue(t,e,s,n,i,r,c){return c===void 0?this.getAbsoluteValue1(t,e,s,n,i,r):this.getAbsoluteValue2(t,e,s,n,i,r,c)}getAbsoluteValue1(t,e,s,n,i,r){if(t<this.frames[0])return s?r:i;const c=this.getCurveValue(t);return s?r+(n?c:c-r)*e:i+(n?c:c-i)*e}getAbsoluteValue2(t,e,s,n,i,r,c){return t<this.frames[0]?s?r:i:s?r+(n?c:c-r)*e:i+(n?c:c-i)*e}getScaleValue(t,e,s,n,i,r,c){if(t<this.frames[0])return s?c:r;const l=this.getCurveValue(t)*c;if(e===1&&!n)return l;let o=s?c:r;return n?o+(l-c)*e:i?o+(Math.abs(l)*Math.sign(o)-o)*e:(o=Math.abs(o)*Math.sign(l),o+(l-o)*e)}};function Gs(t){return typeof t=="object"&&t!==null&&typeof t.boneIndex=="number"}var vt=class extends Nt{boneIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.boneIndex=s,this.additive=!0}apply(t,e,s,n,i,r,c,l,o){const a=t.bones[this.boneIndex];a.active&&this.apply1(o?a.appliedPose:a.pose,a.data.setupPose,s,i,r,c,l)}},Qt=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,c,l,o){const a=t.bones[this.boneIndex];a.active&&this.apply1(o?a.appliedPose:a.pose,a.data.setupPose,s,i,r,c,l)}},Dt=class extends vt{constructor(t,e,s){super(t,e,s,0)}apply1(t,e,s,n,i,r,c){t.rotation=this.getRelativeValue(s,n,i,r,t.rotation,e.rotation)}},Re=class extends Qt{constructor(t,e,s){super(t,e,s,1,2)}apply1(t,e,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(t.x=e.x,t.y=e.y);return}let o=0,a=0;const h=Z.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];o=l[h+1],a=l[h+2];const u=(s-f)/(l[h+3]-f);o+=(l[h+3+1]-o)*u,a+=(l[h+3+2]-a)*u;break}case 1:o=l[h+1],a=l[h+2];break;default:o=this.getBezierValue(s,h,1,d-2),a=this.getBezierValue(s,h,2,d+18-2)}i?(t.x=e.x+o*n,t.y=e.y+a*n):r?(t.x+=o*n,t.y+=a*n):(t.x+=(e.x+o-t.x)*n,t.y+=(e.y+a-t.y)*n)}},Le=class extends vt{constructor(t,e,s){super(t,e,s,1)}apply1(t,e,s,n,i,r,c){t.x=this.getRelativeValue(s,n,i,r,t.x,e.x)}},Be=class extends vt{constructor(t,e,s){super(t,e,s,2)}apply1(t,e,s,n,i,r,c){t.y=this.getRelativeValue(s,n,i,r,t.y,e.y)}},Oe=class extends Qt{constructor(t,e,s){super(t,e,s,3,4)}apply1(t,e,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(t.scaleX=e.scaleX,t.scaleY=e.scaleY);return}let o,a;const h=Z.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];o=l[h+1],a=l[h+2];const u=(s-f)/(l[h+3]-f);o+=(l[h+3+1]-o)*u,a+=(l[h+3+2]-a)*u;break}case 1:o=l[h+1],a=l[h+2];break;default:o=this.getBezierValue(s,h,1,d-2),a=this.getBezierValue(s,h,2,d+18-2)}if(o*=e.scaleX,a*=e.scaleY,n===1&&!r)t.scaleX=o,t.scaleY=a;else{let f=0,u=0;i?(f=e.scaleX,u=e.scaleY):(f=t.scaleX,u=t.scaleY),r?(t.scaleX=f+(o-e.scaleX)*n,t.scaleY=u+(a-e.scaleY)*n):c?(t.scaleX=f+(Math.abs(o)*Math.sign(f)-f)*n,t.scaleY=u+(Math.abs(a)*Math.sign(u)-u)*n):(f=Math.abs(f)*Math.sign(o),u=Math.abs(u)*Math.sign(a),t.scaleX=f+(o-f)*n,t.scaleY=u+(a-u)*n)}}},Ne=class extends vt{constructor(t,e,s){super(t,e,s,3)}apply1(t,e,s,n,i,r,c){t.scaleX=this.getScaleValue(s,n,i,r,c,t.scaleX,e.scaleX)}},De=class extends vt{constructor(t,e,s){super(t,e,s,4)}apply1(t,e,s,n,i,r,c){t.scaleY=this.getScaleValue(s,n,i,r,c,t.scaleY,e.scaleY)}},Ue=class extends Qt{constructor(t,e,s){super(t,e,s,5,6)}apply1(t,e,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(t.shearX=e.shearX,t.shearY=e.shearY);return}let o=0,a=0;const h=Z.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];o=l[h+1],a=l[h+2];const u=(s-f)/(l[h+3]-f);o+=(l[h+3+1]-o)*u,a+=(l[h+3+2]-a)*u;break}case 1:o=l[h+1],a=l[h+2];break;default:o=this.getBezierValue(s,h,1,d-2),a=this.getBezierValue(s,h,2,d+18-2)}i?(t.shearX=e.shearX+o*n,t.shearY=e.shearY+a*n):r?(t.shearX+=o*n,t.shearY+=a*n):(t.shearX+=(e.shearX+o-t.shearX)*n,t.shearY+=(e.shearY+a-t.shearY)*n)}},qe=class extends vt{constructor(t,e,s){super(t,e,s,5)}apply1(t,e,s,n,i,r,c){t.shearX=this.getRelativeValue(s,n,i,r,t.shearX,e.shearX)}},$e=class extends vt{constructor(t,e,s){super(t,e,s,6)}apply1(t,e,s,n,i,r,c){t.shearY=this.getRelativeValue(s,n,i,r,t.shearY,e.shearY)}},_e=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,c,l,o){const a=t.bones[this.boneIndex];if(!a.active)return;const h=o?a.appliedPose:a.pose;if(l)r&&(h.inherit=a.data.setupPose.inherit);else{const d=this.frames;s<d[0]?r&&(h.inherit=a.data.setupPose.inherit):h.inherit=this.frames[Z.search(d,s,2)+1]}}},Ut=class extends yt{slotIndex;constructor(t,e,s,...n){super(t,e,...n),this.slotIndex=s}apply(t,e,s,n,i,r,c,l,o){const a=t.slots[this.slotIndex];a.bone.active&&this.apply1(a,o?a.appliedPose:a.pose,s,i,r,c)}},ze=class extends Ut{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 c=e.color,l=this.frames;if(s<l[0]){i&&c.setFromColor(t.data.setupPose.color);return}let o=0,a=0,h=0,d=0;const f=Z.search(l,s,5),u=this.curves[f/5];switch(u){case 0:{const m=l[f];o=l[f+1],a=l[f+2],h=l[f+3],d=l[f+4];const p=(s-m)/(l[f+5]-m);o+=(l[f+5+1]-o)*p,a+=(l[f+5+2]-a)*p,h+=(l[f+5+3]-h)*p,d+=(l[f+5+4]-d)*p;break}case 1:o=l[f+1],a=l[f+2],h=l[f+3],d=l[f+4];break;default:o=this.getBezierValue(s,f,1,u-2),a=this.getBezierValue(s,f,2,u+18-2),h=this.getBezierValue(s,f,3,u+18*2-2),d=this.getBezierValue(s,f,4,u+18*3-2)}if(n===1)c.set(o,a,h,d);else if(i){const m=t.data.setupPose.color;c.set(m.r+(o-m.r)*n,m.g+(a-m.g)*n,m.b+(h-m.b)*n,m.a+(d-m.a)*n)}else c.add((o-c.r)*n,(a-c.g)*n,(h-c.b)*n,(d-c.a)*n)}},We=class extends Ut{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 c=e.color;let l=0,o=0,a=0;const h=this.frames;if(s<h[0]){if(i){const u=t.data.setupPose.color;c.r=u.r,c.g=u.g,c.b=u.b}return}const d=Z.search(h,s,4),f=this.curves[d>>2];switch(f){case 0:{const u=h[d];l=h[d+1],o=h[d+2],a=h[d+3];const m=(s-u)/(h[d+4]-u);l+=(h[d+4+1]-l)*m,o+=(h[d+4+2]-o)*m,a+=(h[d+4+3]-a)*m;break}case 1:l=h[d+1],o=h[d+2],a=h[d+3];break;default:l=this.getBezierValue(s,d,1,f-2),o=this.getBezierValue(s,d,2,f+18-2),a=this.getBezierValue(s,d,3,f+18*2-2)}if(n!==1)if(i){const u=t.data.setupPose.color;l=u.r+(l-u.r)*n,o=u.g+(o-u.g)*n,a=u.b+(a-u.b)*n}else l=c.r+(l-c.r)*n,o=c.g+(o-c.g)*n,a=c.b+(a-c.b)*n;c.r=l<0?0:l>1?1:l,c.g=o<0?0:o>1?1:o,c.b=a<0?0:a>1?1:a}},Ge=class extends Nt{slotIndex=0;constructor(t,e,s){super(t,e,`9|${s}`),this.slotIndex=s}apply(t,e,s,n,i,r,c,l,o){const a=t.slots[this.slotIndex];if(!a.bone.active)return;const h=(o?a.appliedPose:a.pose).color;let d=0;const f=this.frames;if(s<f[0]){r&&(h.a=a.data.setupPose.color.a);return}if(d=this.getCurveValue(s),i!==1)if(r){const u=a.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}},He=class extends Ut{constructor(t,e,s){super(t,e,s,`8|${s}`,`9|${s}`,`10|${s}`)}getFrameEntries(){return 8}setFrame(t,e,s,n,i,r,c,l,o){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]=c,this.frames[t+6]=l,this.frames[t+7]=o}apply1(t,e,s,n,i,r){const c=e.color,l=e.darkColor;let o=0,a=0,h=0;const d=this.frames;if(s<d[0]){if(i){const x=t.data.setupPose;c.setFromColor(x.color);const w=x.darkColor;l.r=w.r,l.g=w.g,l.b=w.b}return}let f=0,u=0,m=0,p=0;const g=Z.search(d,s,8),b=this.curves[g>>3];switch(b){case 0:{const x=d[g];f=d[g+1],u=d[g+2],m=d[g+3],p=d[g+4],o=d[g+5],a=d[g+6],h=d[g+7];const w=(s-x)/(d[g+8]-x);f+=(d[g+8+1]-f)*w,u+=(d[g+8+2]-u)*w,m+=(d[g+8+3]-m)*w,p+=(d[g+8+4]-p)*w,o+=(d[g+8+5]-o)*w,a+=(d[g+8+6]-a)*w,h+=(d[g+8+7]-h)*w;break}case 1:f=d[g+1],u=d[g+2],m=d[g+3],p=d[g+4],o=d[g+5],a=d[g+6],h=d[g+7];break;default:f=this.getBezierValue(s,g,1,b-2),u=this.getBezierValue(s,g,2,b+18-2),m=this.getBezierValue(s,g,3,b+18*2-2),p=this.getBezierValue(s,g,4,b+18*3-2),o=this.getBezierValue(s,g,5,b+18*4-2),a=this.getBezierValue(s,g,6,b+18*5-2),h=this.getBezierValue(s,g,7,b+18*6-2)}if(n===1)c.set(f,u,m,p);else if(i){const x=t.data.setupPose;let w=x.color;c.set(w.r+(f-w.r)*n,w.g+(u-w.g)*n,w.b+(m-w.b)*n,w.a+(p-w.a)*n),w=x.darkColor,o=w.r+(o-w.r)*n,a=w.g+(a-w.g)*n,h=w.b+(h-w.b)*n}else c.add((f-c.r)*n,(u-c.g)*n,(m-c.b)*n,(p-c.a)*n),o=l.r+(o-l.r)*n,a=l.g+(a-l.g)*n,h=l.b+(h-l.b)*n;l.r=o<0?0:o>1?1:o,l.g=a<0?0:a>1?1:a,l.b=h<0?0:h>1?1:h}},je=class extends Ut{constructor(t,e,s){super(t,e,s,`8|${s}`,`10|${s}`)}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,c,l){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]=c,this.frames[t+6]=l}apply1(t,e,s,n,i,r){const c=e.color,l=e.darkColor;let o=0,a=0,h=0,d=0,f=0,u=0;const m=this.frames;if(s<m[0]){if(i){const b=t.data.setupPose,x=b.color,w=b.darkColor;c.r=x.r,c.g=x.g,c.b=x.b,l.r=w.r,l.g=w.g,l.b=w.b}return}const p=Z.search(m,s,7),g=this.curves[p/7];switch(g){case 0:{const b=m[p];o=m[p+1],a=m[p+2],h=m[p+3],d=m[p+4],f=m[p+5],u=m[p+6];const x=(s-b)/(m[p+7]-b);o+=(m[p+7+1]-o)*x,a+=(m[p+7+2]-a)*x,h+=(m[p+7+3]-h)*x,d+=(m[p+7+4]-d)*x,f+=(m[p+7+5]-f)*x,u+=(m[p+7+6]-u)*x;break}case 1:o=m[p+1],a=m[p+2],h=m[p+3],d=m[p+4],f=m[p+5],u=m[p+6];break;default:o=this.getBezierValue(s,p,1,g-2),a=this.getBezierValue(s,p,2,g+18-2),h=this.getBezierValue(s,p,3,g+18*2-2),d=this.getBezierValue(s,p,4,g+18*3-2),f=this.getBezierValue(s,p,5,g+18*4-2),u=this.getBezierValue(s,p,6,g+18*5-2)}if(n!==1)if(i){const b=t.data.setupPose;let x=b.color;o=x.r+(o-x.r)*n,a=x.g+(a-x.g)*n,h=x.b+(h-x.b)*n,x=b.darkColor,d=x.r+(d-x.r)*n,f=x.g+(f-x.g)*n,u=x.b+(u-x.b)*n}else o=c.r+(o-c.r)*n,a=c.g+(a-c.g)*n,h=c.b+(h-c.b)*n,d=l.r+(d-l.r)*n,f=l.g+(f-l.g)*n,u=l.b+(u-l.b)*n;c.r=o<0?0:o>1?1:o,c.g=a<0?0:a>1?1:a,c.b=h<0?0:h>1?1:h,l.r=d<0?0:d>1?1:d,l.g=f<0?0:f>1?1:f,l.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,c,l,o){const a=t.slots[this.slotIndex];if(!a.bone.active)return;const h=o?a.appliedPose:a.pose;l||s<this.frames[0]?r&&this.setAttachment(t,h,a.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)}},Je=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,c,l,o,a,h){const d=this.curves;let f=this.getFrameCount()+t*18;s===0&&(d[e]=2+f);const u=(n-r*2+l)*.03,m=o*.03-c*.06,p=((r-l)*3-n+a)*.006,g=(c-o+.33333333)*.018;let b=u*2+p,x=m*2+g,w=(r-n)*.3+u+p*.16666667,T=c*.3+m+g*.16666667,y=n+w,v=T;for(let S=f+18;f<S;f+=2)d[f]=y,d[f+1]=v,w+=b,T+=x,b+=p,x+=g,y+=w,v+=T}getCurvePercent(t,e){const s=this.curves;let n=s[e];switch(n){case 0:{const l=this.frames[e];return(t-l)/(this.frames[e+this.getFrameEntries()]-l)}case 1:return 0}if(n-=2,s[n]>t){const l=this.frames[e];return s[n+1]*(t-l)/(s[n]-l)}const i=n+18;for(n+=2;n<i;n+=2)if(s[n]>=t){const l=s[n-2],o=s[n-1];return o+(t-l)/(s[n]-l)*(s[n+1]-o)}const r=s[i-2],c=s[i-1];return c+(1-c)*(t-r)/(this.frames[e+this.getFrameEntries()]-r)}apply(t,e,s,n,i,r,c,l,o){const a=t.slots;if(!this.attachment.isTimelineActive(a,this.slotIndex,o))return;const h=this.attachment.timelineSlots,d=this.frames;if(s<d[0]){this.applyBeforeFirst(a[this.slotIndex],o,r);for(const g of h)this.applyBeforeFirst(a[g],o,r);return}let f,u,m;if(s>=d[d.length-1])m=0,f=this.vertices[d.length-1],u=null;else{const g=Z.search(d,s);m=this.getCurvePercent(s,g),f=this.vertices[g],u=this.vertices[g+1]}const p=this.vertices[0].length;this.applyToSlot(a[this.slotIndex],o,f,u,m,p,i,r,c);for(const g of h)this.applyToSlot(a[g],o,f,u,m,p,i,r,c)}applyToSlot(t,e,s,n,i,r,c,l,o){if(!t.bone.active)return;const a=e?t.appliedPose:t.pose;if(a.attachment===null||a.attachment.timelineAttachment!==this.attachment)return;const h=a.attachment,d=a.deform;if(d.length===0&&(l=!0),d.length=r,n===null)if(c===1)if(o&&!l)if(h.bones)for(let f=0;f<r;f++)d[f]+=s[f];else{const f=h.vertices;for(let u=0;u<r;u++)d[u]+=s[u]-f[u]}else L.arrayCopy(s,0,d,0,r);else if(l)if(h.bones)for(let f=0;f<r;f++)d[f]=s[f]*c;else{const f=h.vertices;for(let u=0;u<r;u++){const m=f[u];d[u]=m+(s[u]-m)*c}}else if(o)if(h.bones)for(let f=0;f<r;f++)d[f]+=s[f]*c;else{const f=h.vertices;for(let u=0;u<r;u++)d[u]+=(s[u]-f[u])*c}else for(let f=0;f<r;f++)d[f]+=(s[f]-d[f])*c;else if(c===1)if(o&&!l)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]+=u+(n[f]-u)*i}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u];d[u]+=m+(n[u]-m)*i-f[u]}}else if(i===0)L.arrayCopy(s,0,d,0,r);else for(let f=0;f<r;f++){const u=s[f];d[f]=u+(n[f]-u)*i}else if(l)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]=(u+(n[f]-u)*i)*c}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u],p=f[u];d[u]=p+(m+(n[u]-m)*i-p)*c}}else if(o)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]+=(u+(n[f]-u)*i)*c}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u];d[u]+=(m+(n[u]-m)*i-f[u])*c}}else for(let f=0;f<r;f++){const u=s[f];d[f]+=(u+(n[f]-u)*i-d[f])*c}}applyBeforeFirst(t,e,s){if(!t.bone.active)return;const n=e?t.appliedPose:t.pose;n.attachment==null||n.attachment.timelineAttachment!==this.attachment||(n.deform.length===0&&(s=!0),s&&(n.deform.length=0))}},Ke=class St extends Z{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(e,s,n){super(e,`28|${s}|${n.sequence.id}`),this.slotIndex=s,this.attachment=n,this.instant=!0}getFrameEntries(){return St.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(e,s,n,i,r){const c=this.frames;e*=St.ENTRIES,c[e]=s,c[e+St.MODE]=n|i<<4,c[e+St.DELAY]=r}apply(e,s,n,i,r,c,l,o,a){const h=e.slots;if(!this.attachment.isTimelineActive(h,this.slotIndex,a))return;const d=this.attachment.timelineSlots,f=this.frames;if(o||n<f[0]){if(c){this.setupPose(h[this.slotIndex],a);for(const b of d)this.setupPose(h[b],a)}return}const u=Z.search(f,n,St.ENTRIES),m=f[u],p=f[u+St.MODE],g=f[u+St.DELAY];this.applyToSlot(h[this.slotIndex],a,n,m,p,g);for(const b of d)this.applyToSlot(h[b],a,n,m,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,c){if(!e.bone.active)return;const l=s?e.appliedPose:e.pose;if(l.attachment===null||l.attachment.timelineAttachment!==this.attachment)return;let o=r>>4,a=l.attachment.sequence.regions.length;const h=Ve[r&15];if(h!==0)switch(o+=(n-i)/c+1e-5|0,h){case 1:o=Math.min(a-1,o);break;case 2:o%=a;break;case 3:{const d=(a<<1)-2;o=d===0?0:o%d,o>=a&&(o=d-o);break}case 4:o=Math.max(a-1-o,0);break;case 5:o=a-1-o%a;break;case 6:{const d=(a<<1)-2;o=d===0?0:(o+a-1)%d,o>=a&&(o=d-o)}}l.sequenceIndex=o}},Zt=class vn extends Z{static propertyIds=["13"];events;constructor(e){super(e,...vn.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,c,l,o,a){if(!i)return;const h=this.frames,d=this.frames.length;if(s>n)this.apply(null,s,Number.MAX_VALUE,i,0,!1,!1,!1,!1),s=-1;else if(s>=h[d-1])return;if(n<h[0])return;let f=0;if(s<h[0])f=0;else{f=Z.search(h,s)+1;const u=h[f];for(;f>0&&h[f-1]===u;)f--}for(;f<d&&n>=h[f];f++)i.push(this.events[f])}},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,c,l,o,a){const h=a?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(o||n<this.frames[0]){c&&L.arrayCopy(d,0,h,0,e.slots.length);return}const f=this.drawOrders[Z.search(this.frames,n)];if(!f)L.arrayCopy(d,0,h,0,e.slots.length);else for(let u=0,m=f.length;u<m;u++)h[u]=d[f[u]]}},qt=class Tn extends Z{slots;inFolder;drawOrders;constructor(e,s,n){super(e,...Tn.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]=`d${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,c,l,o,a){const h=a?e.drawOrder.appliedPose:e.drawOrder.pose,d=e.slots;if(o||n<this.frames[0])c&&this.setup(h,d);else{const f=this.drawOrders[Z.search(this.frames,n)];if(!f)this.setup(h,d);else{const u=this.inFolder,m=this.slots;for(let p=0,g=0,b=m.length;!(u[h[p].data.index]&&(h[p]=d[m[f[g]]],++g===b));p++);}}}setup(e,s){const{inFolder:n,slots:i}=this;for(let r=0,c=0,l=i.length;!(n[e[r].data.index]&&(e[r]=s[i[c]],++c===l));r++);}};function Hs(t){return typeof t=="object"&&t!==null&&typeof t.constraintIndex=="number"}var Qe=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`15|${s}`),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,n,i,r,c){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]=c?1:0}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(!a.active)return;const h=o?a.appliedPose:a.pose,d=this.frames;if(s<d[0]){if(r){const b=a.data.setupPose;h.mix=b.mix,h.softness=b.softness,h.bendDirection=b.bendDirection,h.compress=b.compress,h.stretch=b.stretch}return}let f=0,u=0;const m=Z.search(d,s,6),p=this.curves[m/6];switch(p){case 0:{const b=d[m];f=d[m+1],u=d[m+2];const x=(s-b)/(d[m+6]-b);f+=(d[m+6+1]-f)*x,u+=(d[m+6+2]-u)*x;break}case 1:f=d[m+1],u=d[m+2];break;default:f=this.getBezierValue(s,m,1,p-2),u=this.getBezierValue(s,m,2,p+18-2)}const g=r?a.data.setupPose:h;h.mix=g.mix+(f-g.mix)*i,h.softness=g.softness+(u-g.softness)*i,l?r&&(h.bendDirection=g.bendDirection,h.compress=g.compress,h.stretch=g.stretch):(h.bendDirection=d[m+3],h.compress=d[m+4]!==0,h.stretch=d[m+5]!==0)}},Ze=class extends yt{constraintIndex=0;constructor(t,e,s){super(t,e,`16|${s}`),this.constraintIndex=s,this.additive=!0}getFrameEntries(){return 7}setFrame(t,e,s,n,i,r,c,l){const o=this.frames;t*=7,o[t]=e,o[t+1]=s,o[t+2]=n,o[t+3]=i,o[t+4]=r,o[t+5]=c,o[t+6]=l}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(!a.active)return;const h=o?a.appliedPose:a.pose,d=this.frames;if(s<d[0]){if(r){const y=a.data.setupPose;h.mixRotate=y.mixRotate,h.mixX=y.mixX,h.mixY=y.mixY,h.mixScaleX=y.mixScaleX,h.mixScaleY=y.mixScaleY,h.mixShearY=y.mixShearY}return}let f,u,m,p,g,b;const x=Z.search(d,s,7),w=this.curves[x/7];switch(w){case 0:{const y=d[x];f=d[x+1],u=d[x+2],m=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];const v=(s-y)/(d[x+7]-y);f+=(d[x+7+1]-f)*v,u+=(d[x+7+2]-u)*v,m+=(d[x+7+3]-m)*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:f=d[x+1],u=d[x+2],m=d[x+3],p=d[x+4],g=d[x+5],b=d[x+6];break;default:f=this.getBezierValue(s,x,1,w-2),u=this.getBezierValue(s,x,2,w+18-2),m=this.getBezierValue(s,x,3,w+18*2-2),p=this.getBezierValue(s,x,4,w+18*3-2),g=this.getBezierValue(s,x,5,w+18*4-2),b=this.getBezierValue(s,x,6,w+18*5-2)}const T=r?a.data.setupPose:h;c?(h.mixRotate=T.mixRotate+f*i,h.mixX=T.mixX+u*i,h.mixY=T.mixY+m*i,h.mixScaleX=T.mixScaleX+p*i,h.mixScaleY=T.mixScaleY+g*i,h.mixShearY=T.mixShearY+b*i):(h.mixRotate=T.mixRotate+(f-T.mixRotate)*i,h.mixX=T.mixX+(u-T.mixX)*i,h.mixY=T.mixY+(m-T.mixY)*i,h.mixScaleX=T.mixScaleX+(p-T.mixScaleX)*i,h.mixScaleY=T.mixScaleY+(g-T.mixScaleY)*i,h.mixShearY=T.mixShearY+(b-T.mixShearY)*i)}},kt=class extends Nt{constraintIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.constraintIndex=s}},ts=class extends kt{constructor(t,e,s){super(t,e,s,17),this.additive=!0}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(a.active){const h=o?a.appliedPose:a.pose;h.position=this.getAbsoluteValue(s,i,r,c,h.position,a.data.setupPose.position)}}},es=class extends kt{constructor(t,e,s){super(t,e,s,18)}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(a.active){const h=o?a.appliedPose:a.pose;h.spacing=this.getAbsoluteValue(s,i,r,!1,h.spacing,a.data.setupPose.spacing)}}},ss=class extends yt{constraintIndex;constructor(t,e,s){super(t,e,`19|${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,c,l,o){const a=t.constraints[this.constraintIndex];if(!a.active)return;const h=o?a.appliedPose:a.pose,d=this.frames;if(s<d[0]){if(r){const x=a.data.setupPose;h.mixRotate=x.mixRotate,h.mixX=x.mixX,h.mixY=x.mixY}return}let f,u,m;const p=Z.search(d,s,4),g=this.curves[p>>2];switch(g){case 0:{const x=d[p];f=d[p+1],u=d[p+2],m=d[p+3];const w=(s-x)/(d[p+4]-x);f+=(d[p+4+1]-f)*w,u+=(d[p+4+2]-u)*w,m+=(d[p+4+3]-m)*w;break}case 1:f=d[p+1],u=d[p+2],m=d[p+3];break;default:f=this.getBezierValue(s,p,1,g-2),u=this.getBezierValue(s,p,2,g+18-2),m=this.getBezierValue(s,p,3,g+18*2-2)}const b=r?a.data.setupPose:h;c?(h.mixRotate=b.mixRotate+f*i,h.mixX=b.mixX+u*i,h.mixY=b.mixY+m*i):(h.mixRotate=b.mixRotate+(f-b.mixRotate)*i,h.mixX=b.mixX+(u-b.mixX)*i,h.mixY=b.mixY+(m-b.mixY)*i)}},pt=class extends kt{constructor(t,e,s,n){super(t,e,s,n)}apply(t,e,s,n,i,r,c,l,o){if(c&&!this.additive&&(c=!1),this.constraintIndex===-1){const a=s>=this.frames[0]?this.getCurveValue(s):0,h=t.physics;for(const d of h)if(d.active&&this.global(d.data)){const f=o?d.appliedPose:d.pose;this.set(f,this.getAbsoluteValue(s,i,r,c,this.get(f),this.get(d.data.setupPose),a))}}else{const a=t.constraints[this.constraintIndex];if(a.active){const h=o?a.appliedPose:a.pose;this.set(h,this.getAbsoluteValue(s,i,r,c,this.get(h),this.get(a.data.setupPose)))}}}},ns=class extends pt{constructor(t,e,s){super(t,e,s,20)}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}},is=class extends pt{constructor(t,e,s){super(t,e,s,21)}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}},rs=class extends pt{constructor(t,e,s){super(t,e,s,22)}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}},as=class extends pt{constructor(t,e,s){super(t,e,s,23)}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}},os=class extends pt{constructor(t,e,s){super(t,e,s,24),this.additive=!0}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}},ls=class extends pt{constructor(t,e,s){super(t,e,s,25),this.additive=!0}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}},cs=class extends pt{constructor(t,e,s){super(t,e,s,26)}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}},hs=class Sn extends Z{static propertyIds=["27"];constraintIndex;constructor(e,s){super(e,...Sn.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,c,l,o,a){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,!1,!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 f of e.physics)f.active&&f.reset(e)}},ds=class extends kt{constructor(t,e,s){super(t,e,s,29)}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(a.active){const h=o?a.appliedPose:a.pose;h.time=this.getAbsoluteValue(s,i,r,c,h.time,a.data.setupPose.time)}}},fs=class extends kt{constructor(t,e,s){super(t,e,s,30),this.additive=!0}apply(t,e,s,n,i,r,c,l,o){const a=t.constraints[this.constraintIndex];if(a.active){const h=o?a.appliedPose:a.pose;h.mix=this.getAbsoluteValue(s,i,r,c,h.mix,a.data.setupPose.mix)}}},Wn=class Os{static emptyAnimation=new Kt("<empty>",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new Js(this);propertyIds=new Me;animationsChanged=!1;trackEntryPool=new Bt(()=>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 c=e*r.timeScale;if(r.delay>0){if(r.delay-=c,r.delay>0)continue;c=-r.delay,r.delay=0}let l=r.next;if(l){const o=r.trackLast-l.delay;if(o>=0){for(l.delay=0,l.trackTime+=r.timeScale===0?0:(o/r.timeScale+e)*l.timeScale,r.trackTime+=c,this.setTrack(n,l,!0);l.mixingFrom;)l.mixTime+=e,l=l.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 o=r.mixingFrom;for(r.mixingFrom=null,o&&(o.mixingTo=null);o;)this.queue.end(o),o=o.mixingFrom}r.trackTime+=c}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 l=0,o=n.length;l<o;l++){const a=n[l];if(!a||a.delay>0)continue;i=!0;let h=a.alpha;a.mixingFrom?h*=this.applyMixingFrom(a,e):a.trackTime>=a.trackEnd&&!a.next&&(h=0);let d=a.animationLast,f=a.getAnimationTime(),u=f,m=s;a.reverse&&(u=a.animation.duration-u,m=null);const p=a.animation.timelines,g=p.length;if(l===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,!0,!0):x.apply(e,d,u,m,h,!0,!1,!1,!1)}else{const b=a.timelineMode,x=h>=a.alphaAttachmentThreshold,w=a.additive,T=w||a.shortestRotation,y=!T&&a.timelinesRotation.length!==g<<1;y&&(a.timelinesRotation.length=g<<1);for(let v=0;v<g;v++){const S=p[v],A=(b[v]&$t)!==0;!T&&S instanceof Dt?this.applyRotateTimeline(S,e,u,h,A,a.timelinesRotation,v<<1,y):S instanceof Ft?this.applyAttachmentTimeline(S,e,u,A,x):(L.webkit602BugfixHelper(h),S.apply(e,d,u,m,h,A,w,!1,!1))}}a.reverse&&this.eventsReverse(a,d,f),this.queueEvents(a,f),s.length=0,a.nextAnimationLast=f,a.nextTrackLast=a.trackTime}const r=this.unkeyedState+us,c=e.slots;for(let l=0,o=e.slots.length;l<o;l++){const a=c[l];if(a.attachmentState===r){const h=a.data.attachmentName;a.pose.setAttachment(h?e.getAttachment(a.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(),c=n.alpha*i,l=1-r*e.alpha,o=c*(1-r),a=l>0?o/l:c,h=n.animation.timelines,d=h.length,f=n.timelineMode,u=n.timelineHoldMix,m=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 T=n.animationLast,y=n.getAnimationTime(),v=y,S=null;n.reverse?v=n.animation.duration-v:r<n.eventThreshold&&(S=this.events),n.totalAlpha=0;for(let A=0;A<d;A++){const I=h[A],M=f[A],P=(M&$t)!==0;let k=0;if((M&_t)!==0){const E=u[A];k=E==null?a:a*(1-E.mix())}else{if(!p&&I instanceof At&&!P)continue;k=o}if(n.totalAlpha+=k,!b&&I instanceof Dt)this.applyRotateTimeline(I,s,v,k,P,w,A<<1,x);else if(I instanceof Ft)this.applyAttachmentTimeline(I,s,v,P,m&&k>=n.alphaAttachmentThreshold);else{const E=!p||!(I instanceof At)||!P;I.apply(s,T,v,S,k,P,g,E,!1)}}return n.reverse&&r<n.eventThreshold&&this.eventsReverse(n,T,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 c=s.slots[e.slotIndex];if(!c.bone.active||!r&&c.attachmentState===this.unkeyedState+ms)return;let l=n<e.frames[0],o=null;if(l||(o=e.attachmentNames[Z.search(e.frames,n)],l=!r&&o==null),l){if(!i)return;o=c.data.attachmentName}c.pose.setAttachment(o==null?null:s.getAttachment(c.data.index,o)),r?c.attachmentState=this.unkeyedState+ms:l||(c.attachmentState=this.unkeyedState+us)}applyRotateTimeline(e,s,n,i,r,c,l,o){if(o&&(c[l]=0),i===1){e.apply(s,0,n,null,1,r,!1,!1,!1);return}const a=s.bones[e.boneIndex];if(!a.active)return;const h=a.pose,d=a.data.setupPose,f=e.frames;if(n<f[0]){r&&(h.rotation=d.rotation);return}const u=r?d.rotation:h.rotation,m=d.rotation+e.getCurveValue(n);let p=0,g=m-u;if(g-=Math.ceil(g/360-.5)*360,g===0)p=c[l];else{let b=0,x=0;o?(b=0,x=g):(b=c[l],x=c[l+1]);const w=b-b%360;p=g+w;let T=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=T):w!==0?p-=360*R.signum(b):y=T),y!==T&&(p+=360*R.signum(b)),c[l]=p}c[l+1]=g,h.rotation=u+p*i}queueEvents(e,s){const n=e.animationStart,i=e.animationEnd,r=i-n,c=e.reverse;let l=e.trackLast%r;c&&(l=r-l);const o=this.events;let a=0,h=o.length;for(;a<h;a++){const f=o[a];if(f.time<l!==c)break;f.time>=n&&f.time<=i&&this.queue.event(e,f)}let d=!1;if(e.loop)if(r===0)d=!0;else{const f=Math.floor(e.trackTime/r);d=f>0&&f>Math.floor(e.trackLast/r)}else d=s>=i&&e.animationLast<i;for(d&&this.queue.complete(e);a<h;a++){const f=o[a];f.time>=n&&f.time<=i&&this.queue.event(e,f)}}eventsReverse(e,s,n){const i=e.animation.duration,r=i-s,c=i-n,l=e.animation.timelines;for(let o=0,a=e.animation.timelines.length;o<a;o++){const h=l[o];if(!(h instanceof Zt))continue;const d=h.events,f=h.frames,u=f.length;if(r>=c){for(let m=0;m<u;m++)if(!(f[m]<c)){if(f[m]>=r)break;this.events.push(d[m])}}else{for(let p=0;p<u&&!(f[p]>=r);p++)this.events.push(d[p]);let m=0;for(;m<u&&!(f[m]>=c);m++);for(;m<u;m++)this.events.push(d[m])}}}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 c=this.trackEntry(e,s,n,r);return this.setTrack(e,c,i),this.queue.drain(),c}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 c=this.trackEntry(e,s,n,r);return r?(r.next=c,c.previous=r,i<=0&&(i=Math.max(i+r.getTrackComplete()-c.mixDuration,0))):(this.setTrack(e,c,!0),this.queue.drain(),i<0&&(i=0)),c.delay=i,c}setEmptyAnimation(e,s=0){const n=this.setAnimation(e,Os.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(e,s=0,n=0){const i=this.addAnimation(e,Os.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++){let i=e[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do this.computeHold(i),i=i.mixingTo;while(i)}}this.propertyIds.clear()}computeHold(e){const s=e.animation.timelines,n=e.animation.timelines.length,i=e.timelineMode;i.length=n;const r=e.timelineHoldMix;r.length=0;const c=this.propertyIds,l=e.additive,o=e.keepHold,a=e.mixingTo;t:for(let h=0;h<n;h++){const d=s[h],f=d.propertyIds,u=c.addAll(f)&&!(d instanceof qt&&c.contains(At.propertyID));if(l&&d.additive){i[h]=u?$t:te;continue}for(let p=e.mixingFrom;p!=null;p=p.mixingFrom)if(p.animation.hasTimeline(f)){i[h]=te;continue t}let m;if(a===null||d.instant||a.additive&&d.additive||!a.animation?.hasTimeline(f))m=u?$t:te;else{m=u?Qs:_t;for(let p=a.mixingTo;p!=null;p=p.mixingTo)if(p.additive&&d.additive||!p.animation?.hasTimeline(f)){p.mixDuration>0&&(r[h]=p);break}}o&&(m=m&~_t|i[h]&_t),i[h]=m}}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=Lt.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===Lt.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=Lt.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}},Js=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 c=i[r];c.start&&c.start(n)}break;case 1:n.listener?.interrupt&&n.listener.interrupt(n);for(let r=0;r<i.length;r++){const c=i[r];c.interrupt&&c.interrupt(n)}break;case 2:n.listener?.end&&n.listener.end(n);for(let r=0;r<i.length;r++){const c=i[r];c.end&&c.end(n)}case 3:n.listener?.dispose&&n.listener.dispose(n);for(let r=0;r<i.length;r++){const c=i[r];c.dispose&&c.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 c=i[r];c.complete&&c.complete(n)}break;case 5:{const r=e[t+++2];n.listener?.event&&n.listener.event(n,r);for(let c=0;c<i.length;c++){const l=i[c];l.event&&l.event(n,r)}break}}}this.clear(),this.drainDisabled=!1}}clear(){this.objects.length=0}},Ks=(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))(Ks||{}),Gn=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},te=0,$t=1,_t=2,Qs=3,us=1,ms=2,Hn=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}},Zs=class{constructor(t,e="",s=new gs,n=new tn){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,c)=>{const l=`Couldn't load binary ${t}: status ${r}, ${c}`;this.error(s,t,l),i(l)})}))}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,c)=>{const l=`Couldn't load JSON ${t}: status ${r}, ${c}`;this.error(s,t,l),i(l)})}))}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(o=>{if(o.ok)return o.blob();const a=`Couldn't load image: ${t}`;this.error(s,t,`Couldn't load image: ${t}`),r(a)}).then(o=>o?createImageBitmap(o,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(o=>{if(o){const a=this.createTexture(t,n,o);this.success(e,t,a),i(a)}});else{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{const a=this.createTexture(t,n,o);this.success(e,t,a),i(a)},o.onerror=()=>{const a=`Couldn't load image: ${t}`;this.error(s,t,a),r(a)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),o.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((c,l)=>{this.downloader.downloadText(t,o=>{try{const a=this.createTextureAtlas(o,r,t,n);let h=a.pages.length,d=!1;if(h===0){this.success(e,t,a),c(a);return}for(const f of a.pages)this.loadTexture(this.texturePath(r,f.name,n),(u,m)=>{d||(f.setTexture(m),--h===0&&(this.success(e,t,a),c(a)))},(u,m)=>{if(!d){const p=`Couldn't load texture ${t} page image: ${u}`;this.error(s,t,p),l(p)}d=!0})}catch(a){const h=`Couldn't parse texture atlas ${t}: ${a.message}`;this.error(s,t,h),l(h)}},(o,a)=>{const h=`Couldn't load texture atlas ${t}: status ${o}, ${a}`;this.error(s,t,h),l(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,c)=>{this.downloader.downloadText(t,l=>{try{const o=this.createTextureAtlas(l,i,t);this.success(e,t,o),r(o)}catch(o){const a=`Couldn't parse texture atlas ${t}: ${o.message}`;this.error(s,t,a),c(a)}},(l,o)=>{const a=`Couldn't load texture atlas ${t}: status ${l}, ${o}`;this.error(s,t,a),c(a)})}))}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 Fe){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 Fe(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 c=this.texturePath(e,r.name,n);this.texturePmaInfo[this.pathPrefix+c]=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}},tn=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(c){this.finish(t,400,JSON.stringify(c))}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(c){this.finish(t,400,JSON.stringify(c))}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 An extends xt{color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new An(this.name);return this.copyTo(e),e.color.setFromColor(this.color),e}},zt=class In extends xt{endSlot=null;convex=!1;inverse=!1;color=new z(.2275,.2275,.8078,1);constructor(e){super(e)}copy(){const e=new In(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 Cn extends xt{lengths=[];closed=!1;constantSpeed=!1;color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new Cn(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}},en=class Mn 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,c=n*e.c+i*e.d;return R.atan2Deg(c,r)}copy(){const e=new Mn(this.name);return e.x=this.x,e.y=this.y,e.rotation=this.rotation,e.color.setFromColor(this.color),e}},jn=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 en(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 Pn 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 Pn(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,f=t.scaleY,u=(e+i)*R.degRad,m=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(m)*n*d,this.c=Math.sin(u)*s*f,this.d=Math.sin(m)*n*f,this.worldX=this.x*d+t.x,this.worldY=this.y*f+t.y;return}const c=this.bone.parent.appliedPose;let l=c.a,o=c.b,a=c.c,h=c.d;switch(this.worldX=l*this.x+o*this.y+c.worldX,this.worldY=a*this.x+h*this.y+c.worldY,this.inherit){case 0:{const d=(e+i)*R.degRad,f=(e+90+r)*R.degRad,u=Math.cos(d)*s,m=Math.cos(f)*n,p=Math.sin(d)*s,g=Math.sin(f)*n;this.a=l*u+o*p,this.b=l*m+o*g,this.c=a*u+h*p,this.d=a*m+h*g;return}case 1:{const d=t.scaleX,f=t.scaleY,u=(e+i)*R.degRad,m=(e+90+r)*R.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(m)*n*d,this.c=Math.sin(u)*s*f,this.d=Math.sin(m)*n*f;break}case 2:{const d=t.scaleX,f=t.scaleY,u=1/d,m=1/f;l*=u,a*=m;let p=l*l+a*a,g=0;p>R.epsilon2?(p=Math.abs(l*h*m-o*u*a)/p,o=a*p,h=l*p,g=e-R.atan2Deg(a,l)):(l=0,a=0,g=e-90+R.atan2Deg(h,o));const b=(g+i)*R.degRad,x=(g+r+90)*R.degRad,w=Math.cos(b)*s,T=Math.cos(x)*n,y=Math.sin(b)*s,v=Math.sin(x)*n;this.a=(l*w-o*y)*d,this.b=(l*T-o*v)*d,this.c=(a*w+h*y)*f,this.d=(a*T+h*v)*f;break}case 3:case 4:{const d=t.scaleX,f=t.scaleY,u=1/d,m=1/f,p=e*R.degRad,g=Math.cos(p),b=Math.sin(p);let x=(l*g+o*b)*u,w=(a*g+h*b)*m;const T=1/Math.sqrt(x*x+w*w);x*=T,w*=T;let y=-w,v=x;this.inherit===3&&l*h-o*a<0!=(d<0!=f<0)&&(y=-y,v=-v);const S=i*R.degRad,A=(90+r)*R.degRad,I=Math.cos(S)*s,M=Math.cos(A)*n,P=Math.sin(S)*s,k=Math.sin(A)*n;this.a=(x*I+y*P)*d,this.b=(x*M+y*k)*d,this.c=(w*I+v*P)*f,this.d=(w*M+v*k)*f;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,c=n.c,l=n.d;const o=i*l-r*c,a=1/(i*l-r*c),h=l*a,d=r*a,f=c*a,u=i*a,m=this.worldX-n.worldX,p=this.worldY-n.worldY;switch(this.x=m*h-p*d,this.y=p*u-m*f,this.inherit){case 0:this.set5(h*this.a-d*this.c,h*this.b-d*this.d,u*this.c-f*this.a,u*this.d-f*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,c*=b;const x=this.a*g,w=this.b*g,T=this.c*b,y=this.d*b,v=1/(i*i+c*c),S=1/Math.abs(o*g*b);this.set5((i*x+c*T)*v,(i*w+c*y)*v,(i*T-c*x)*S,(i*y-c*w)*S,R.atan2Deg(c,i));break}case 3:case 4:{const g=1/e,b=1/s,x=this.a*g,w=this.b*g,T=this.c*b,y=this.d*b;let v=l*this.a-r*this.c,S=i*this.c-c*this.a;o<0&&(v=-v,S=-S);let A=R.atan2Deg(S,v);this.rotation=A,A*=R.degRad;const I=Math.cos(A),M=Math.sin(A);let P=(i*I+r*M)*g,k=(c*I+l*M)*b;const E=1/Math.sqrt(P*P+k*k);P*=E,k*=E;const X=this.inherit===3&&o<0!=(e<0!=s<0)?-1:1;this.set4(P*x+k*T,P*w+k*y,(P*T-k*x)*X,(P*y-k*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,c=e*e+n*n;if(r>R.epsilon2){const l=R.atan2Deg(s,t);this.rotation=l+i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(c),c>R.epsilon2?(this.shearY=R.atan2Deg(n,e),t*n-e*s<0?(this.scaleY=-this.scaleY,this.shearY+=90-l):this.shearY-=90+l,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}else this.scaleX=0,this.scaleY=Math.sqrt(c),this.shearY=0,this.rotation=c>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 Yn 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 Yn(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}},sn=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)}},ae=(t=>(t[t.None=0]="None",t[t.Uniform=1]="Uniform",t[t.Volume=2]="Volume",t))(ae||{}),oe=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 oe(-1,this);constructor(t){this.name=t}},le=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}},nn=class Pt extends Et{bones;target;constructor(e,s){if(super(e,new le,new le),!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 Pt(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:Pt.apply(e,r[0],i.worldX,i.worldY,n.compress,n.stretch,this.data.scaleYMode,n.mix);break;case 2:Pt.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,c,l,o,a,h){typeof n=="number"?Pt.apply1(e,s,n,i,r,c,l,o):Pt.apply2(e,s,n,i,r,c,l,o,a,h)}static apply1(e,s,n,i,r,c,l,o){s.modifyLocal(e);const a=s.bone.parent.appliedPose;let h=a.a,d=a.b,f=a.c,u=a.d,m=-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*f)/Math.max(R.epsilon,h*h+f*f),x=h/e.scaleX,w=f/e.scaleY;d=-w*b*e.scaleX,u=x*b*e.scaleY,m+=R.atan2Deg(w,x)}default:{const b=n-a.worldX,x=i-a.worldY,w=h*u-d*f;Math.abs(w)<=R.epsilon?(p=0,g=0):(p=(b*u-x*d)/w-s.x,g=(x*h-b*f)/w-s.y)}}if(m+=R.atan2Deg(g,p),s.scaleX<0&&(m+=180),m>180?m-=360:m<=-180&&(m+=360),s.rotation+=m*o,r||c){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||c&&x>b*b){const w=(Math.sqrt(x)/b-1)*o+1;switch(s.scaleX*=w,l){case 1:s.scaleY*=w;break;case 2:s.scaleY/=w<.7?.25+.642857*w:w}}}}}static apply2(e,s,n,i,r,c,l,o,a,h){if(s.inherit!==0||n.inherit!==0)return;s.modifyLocal(e),n.modifyLocal(e);let d=s.x,f=s.y,u=s.scaleX,m=s.scaleY,p=n.scaleX,g=0,b=0,x=0;u<0?(u=-u,g=180,x=-1):(g=0,x=1),m<0&&(m=-m,x=-x),p<0?(p=-p,b=180):b=0;let w=0,T=0,y=s.a,v=s.b,S=s.c,A=s.d;const I=Math.abs(u-m)<=R.epsilon;!I||l?(n.y=0,w=y*n.x+s.worldX,T=S*n.x+s.worldY):(w=y*n.x+v*n.y+s.worldX,T=S*n.x+A*n.y+s.worldY);const M=s.bone.parent.appliedPose;y=M.a,v=M.b,S=M.c,A=M.d;let P=y*A-v*S,k=w-M.worldX,E=T-M.worldY;P=Math.abs(P)<=R.epsilon?0:1/P;const X=(k*A-E*v)*P-d,V=(E*y-k*S)*P-f;let N=Math.sqrt(X*X+V*V),$=n.bone.data.length*p,O,F;if(N<R.epsilon){Pt.apply(e,s,i,r,!1,l,0,h),n.rotation=0;return}k=i-M.worldX,E=r-M.worldY;let Y=(k*A-E*v)*P-d,U=(E*y-k*S)*P-f,D=Y*Y+U*U;if(a!==0){a*=u*(p+1)*.5;const B=Math.sqrt(D),_=B-N-$*u+a;if(_>0){let q=Math.min(1,_/(a*2))-1;q=(_-a*(1-q*q))/B,Y-=q*Y,U-=q*U,D=Y*Y+U*U}}t:if(I){$*=u;let B=(D-N*N-$*$)/(2*N*$);if(B<-1)B=-1,F=Math.PI*c;else if(B>1){if(B=1,F=0,l)switch(y=(Math.sqrt(D)/(N+$)-1)*h+1,s.scaleX*=y,o){case 1:s.scaleY*=y;break;case 2:s.scaleY/=y<.7?.25+.642857*y:y}}else F=Math.acos(B)*c;y=N+$*B,v=$*Math.sin(F),O=Math.atan2(U*y-Y*v,Y*y+U*v)}else{y=u*$,v=m*$;const B=y*y,_=v*v,q=Math.atan2(U,Y);S=_*N*N+B*D-B*_;const K=-2*_*N,et=_-B;if(A=K*K-4*et*S,A>=0){let gt=Math.sqrt(A);K<0&&(gt=-gt),gt=-(K+gt)*.5;let bt=gt/et,jt=S/gt;const ve=Math.abs(bt)<Math.abs(jt)?bt:jt;if(bt=D-ve*ve,bt>=0){E=Math.sqrt(bt)*c,O=q-Math.atan2(E,ve),F=Math.atan2(E/m,(ve-N)/u);break t}}let Q=R.PI,st=N-y,it=st*st,nt=0,dt=0,rt=N+y,at=rt*rt,ft=0;S=-y*N/(B-_),S>=-1&&S<=1&&(S=Math.acos(S),k=y*Math.cos(S)+N,E=v*Math.sin(S),A=k*k+E*E,A<it&&(Q=S,it=A,st=k,nt=E),A>at&&(dt=S,at=A,rt=k,ft=E)),D<=(it+at)*.5?(O=q-Math.atan2(nt*c,st),F=Q*c):(O=q-Math.atan2(ft*c,rt),F=dt*c)}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 le)}create(t){return new nn(this,t)}},ce=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}},Gt=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 ce)}create(t){return new rn(this,t)}},vs=(t=>(t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent",t))(vs||{}),Ts=(t=>(t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional",t))(Ts||{}),Ss=(t=>(t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale",t))(Ss||{}),rn=class Yt 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 ce,new ce),!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 Yt(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,c=i.mixX,l=i.mixY;if(r===0&&c===0&&l===0)return;const o=this.data,a=o.rotateMode===0,h=o.rotateMode===2,d=this.bones,f=d.length,u=a?f:f+1,m=L.setArraySize(this.spaces,u),p=h?this.lengths=L.setArraySize(this.lengths,f):[],g=i.spacing;switch(o.spacingMode){case 2:if(h)for(let v=0,S=u-1;v<S;v++){const A=d[v],I=A.bone.data.length,M=I*A.a,P=I*A.c;p[v]=Math.sqrt(M*M+P*P)}L.arrayFill(m,1,u,g);break;case 3:{let v=0;for(let S=0,A=u-1;S<A;){const I=d[S],M=I.bone.data.length;if(M<R.epsilon)h&&(p[S]=0),m[++S]=g;else{const P=M*I.a,k=M*I.c,E=Math.sqrt(P*P+k*k);h&&(p[S]=E),m[++S]=E,v+=E}}if(v>0){v=u/v*g;for(let S=1;S<u;S++)m[S]*=v}break}default:{const v=o.spacingMode===0;for(let S=0,A=u-1;S<A;){const I=d[S],M=I.bone.data.length;if(M<R.epsilon)h&&(p[S]=0),m[++S]=g;else{const P=M*I.a,k=M*I.c,E=Math.sqrt(P*P+k*k);h&&(p[S]=E),m[++S]=(v?Math.max(0,M+g):g)*E/M}}}}const b=this.computeWorldPositions(e,n,u,a);let x=b[0],w=b[1],T=o.offsetRotation,y=!1;if(T===0)y=o.rotateMode===1;else{y=!1;const v=this.slot.bone.appliedPose;T*=v.a*v.d-v.b*v.c>0?R.degRad:-R.degRad}for(let v=0,S=3,A=e._update;v<f;v++,S+=3){const I=d[v];I.worldX+=(x-I.worldX)*c,I.worldY+=(w-I.worldY)*l;const M=b[S],P=b[S+1],k=M-x,E=P-w;if(h){const X=p[v];if(X!==0){const V=(Math.sqrt(k*k+E*E)/X-1)*r+1;I.a*=V,I.c*=V}}if(x=M,w=P,r>0){let X=I.a,V=I.b,N=I.c,$=I.d,O=0,F=0,Y=0;if(a?O=b[S-1]:m[v+1]===0?O=b[S+2]:O=Math.atan2(E,k),O-=Math.atan2(N,X),y){F=Math.cos(O),Y=Math.sin(O);const U=I.bone.data.length;x+=(U*(F*X-Y*N)-k)*r,w+=(U*(Y*X+F*N)-E)*r}else O+=T;O>R.PI?O-=R.PI2:O<-R.PI&&(O+=R.PI2),O*=r,F=Math.cos(O),Y=Math.sin(O),I.a=F*X-Y*N,I.b=F*V-Y*$,I.c=Y*X+F*N,I.d=Y*V+F*$}I.modifyWorld(A)}}computeWorldPositions(e,s,n,i){const r=this.slot;let c=this.appliedPose.position,l=this.spaces,o=L.setArraySize(this.positions,n*3+2),a=this.world;const h=s.closed;let d=s.worldVerticesLength,f=d/6,u=Yt.NONE;if(!s.constantSpeed){const F=s.lengths;f-=h?1:2;const Y=F[f];this.data.positionMode===1&&(c*=Y);let U;switch(this.data.spacingMode){case 2:U=Y;break;case 3:U=Y/n;break;default:U=1}a=L.setArraySize(this.world,8);for(let D=0,W=0,B=0;D<n;D++,W+=3){const _=l[D]*U;c+=_;let q=c;if(h)q%=Y,q<0&&(q+=Y),B=0;else if(q<0){u!==Yt.BEFORE&&(u=Yt.BEFORE,s.computeWorldVertices(e,r,2,4,a,0,2)),this.addBeforePosition(q,a,0,o,W);continue}else if(q>Y){u!==Yt.AFTER&&(u=Yt.AFTER,s.computeWorldVertices(e,r,d-6,4,a,0,2)),this.addAfterPosition(q-Y,a,0,o,W);continue}for(;;B++){const K=F[B];if(!(q>K)){if(B===0)q/=K;else{const et=F[B-1];q=(q-et)/(K-et)}break}}B!==u&&(u=B,h&&B===f?(s.computeWorldVertices(e,r,d-4,4,a,0,2),s.computeWorldVertices(e,r,0,4,a,4,2)):s.computeWorldVertices(e,r,B*6+2,8,a,0,2)),this.addCurvePosition(q,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],o,W,i||D>0&&_===0)}return o}h?(d+=2,a=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d-4,a,0,2),s.computeWorldVertices(e,r,0,2,a,d-4,2),a[d-2]=a[0],a[d-1]=a[1]):(f--,d-=4,a=L.setArraySize(this.world,d),s.computeWorldVertices(e,r,2,d,a,0,2));const m=L.setArraySize(this.curves,f);let p=0,g=a[0],b=a[1],x=0,w=0,T=0,y=0,v=0,S=0,A=0,I=0,M=0,P=0,k=0,E=0,X=0,V=0;for(let F=0,Y=2;F<f;F++,Y+=6)x=a[Y],w=a[Y+1],T=a[Y+2],y=a[Y+3],v=a[Y+4],S=a[Y+5],A=(g-x*2+T)*.1875,I=(b-w*2+y)*.1875,M=((x-T)*3-g+v)*.09375,P=((w-y)*3-b+S)*.09375,k=A*2+M,E=I*2+P,X=(x-g)*.75+A+M*.16666667,V=(w-b)*.75+I+P*.16666667,p+=Math.sqrt(X*X+V*V),X+=k,V+=E,k+=M,E+=P,p+=Math.sqrt(X*X+V*V),X+=k,V+=E,p+=Math.sqrt(X*X+V*V),X+=k+M,V+=E+P,p+=Math.sqrt(X*X+V*V),m[F]=p,g=v,b=S;this.data.positionMode===1&&(c*=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 O=0;for(let F=0,Y=0,U=0,D=0;F<n;F++,Y+=3){const W=l[F]*N;c+=W;let B=c;if(h)B%=p,B<0&&(B+=p),U=0,D=0;else if(B<0){this.addBeforePosition(B,a,0,o,Y);continue}else if(B>p){this.addAfterPosition(B-p,a,d-4,o,Y);continue}for(;;U++){const _=m[U];if(!(B>_)){if(U===0)B/=_;else{const q=m[U-1];B=(B-q)/(_-q)}break}}if(U!==u){u=U;let _=U*6;for(g=a[_],b=a[_+1],x=a[_+2],w=a[_+3],T=a[_+4],y=a[_+5],v=a[_+6],S=a[_+7],A=(g-x*2+T)*.03,I=(b-w*2+y)*.03,M=((x-T)*3-g+v)*.006,P=((w-y)*3-b+S)*.006,k=A*2+M,E=I*2+P,X=(x-g)*.3+A+M*.16666667,V=(w-b)*.3+I+P*.16666667,O=Math.sqrt(X*X+V*V),$[0]=O,_=1;_<8;_++)X+=k,V+=E,k+=M,E+=P,O+=Math.sqrt(X*X+V*V),$[_]=O;X+=k,V+=E,O+=Math.sqrt(X*X+V*V),$[8]=O,X+=k+M,V+=E+P,O+=Math.sqrt(X*X+V*V),$[9]=O,D=0}for(B*=O;;D++){const _=$[D];if(!(B>_)){if(D===0)B/=_;else{const q=$[D-1];B=D+(B-q)/(_-q)}break}}this.addCurvePosition(B*.1,g,b,x,w,T,y,v,S,o,Y,i||F>0&&W===0)}return o}addBeforePosition(e,s,n,i,r){const c=s[n],l=s[n+1],o=s[n+2]-c,a=s[n+3]-l,h=Math.atan2(a,o);i[r]=c+e*Math.cos(h),i[r+1]=l+e*Math.sin(h),i[r+2]=h}addAfterPosition(e,s,n,i,r){const c=s[n+2],l=s[n+3],o=c-s[n],a=l-s[n+1],h=Math.atan2(a,o);i[r]=c+e*Math.cos(h),i[r+1]=l+e*Math.sin(h),i[r+2]=h}addCurvePosition(e,s,n,i,r,c,l,o,a,h,d,f){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,m=u*e,p=1-e,g=p*p,b=g*p,x=p*e,w=x*3,T=p*w,y=w*e,v=s*b+i*T+c*y+o*m,S=n*b+r*T+l*y+a*m;h[d]=v,h[d+1]=S,f&&(e<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(S-(n*g+r*x*2+l*u),v-(s*g+i*x*2+c*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 c=0;c<r;c++){const l=i[c].bone;e.sortBone(l),e.constrained(l)}e._updateCache.push(this);for(let c=0;c<r;c++)e.sortReset(i[c].bone.children);for(let c=0;c<r;c++)i[c].bone.sorted=!0}sortPathSlot(e,s,n,i){const r=s.getAttachments();for(let c=0,l=r.length;c<l;c++){const o=r[c];o.slotIndex===n&&this.sortPath(e,o.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 c=0,l=i.length;c<l;){let o=i[c++];for(o+=c;c<o;)e.sortBone(r[i[c++]])}}}isSourceActive(){return this.slot.bone.active}},an=(t=>(t[t.none=0]="none",t[t.reset=1]="reset",t[t.update=2]="update",t[t.pose=3]="pose",t))(an||{}),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)}},on=class Fn 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 Fn(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)}},ln=class Ae{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Ae.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Ae.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 on(s,this));this.drawOrder=new sn(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 c=0,l=e.length;c<l;c++)e[c].unconstrained();const s=this.bones,n=s.length;for(let c=0,l=n;c<l;c++){const o=s[c];o.sorted=o.data.skinRequired,o.active=!o.sorted,o.unconstrained()}if(this.skin){const c=this.skin.bones;for(let l=0,o=this.skin.bones.length;l<o;l++){let a=this.bones[c[l].index];do a.sorted=!1,a.active=!0,a=a.parent;while(a)}}const i=this.constraints;let r=this.constraints.length;for(let c=0;c<r;c++)i[c].unconstrained();for(let c=0;c<r;c++){const l=i[c];l.active=l.isSourceActive()&&(!l.data.skinRequired||this.skin!=null&&this.skin.constraints.includes(l.data)),l.active&&l.sort(this)}for(let c=0;c<n;c++)this.sortBone(s[c]);r=this._updateCache.length;for(let c=0;c<r;c++){const l=this._updateCache[c];l instanceof re&&(this._updateCache[c]=l.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],c=r.data.attachmentName;if(c){const l=e.getAttachment(n,c);l&&r.pose.setAttachment(l)}}}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 c=n[i];if(c instanceof s&&c.data.name===e)return c}return null}getBoundsRect(e){const s=new Pe,n=new Pe;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,c=r;let l=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let d=0,f=r.length;d<f;d++){const u=c[d];if(!u.bone.active)continue;let m=0,p=null,g=null;const b=u.appliedPose.attachment;if(b){if(b instanceof j)m=8,p=L.setArraySize(n,m,0),b.computeWorldVertices(u,b.getOffsets(u.appliedPose),p,0,2),g=Ae.quadTriangles;else if(b instanceof wt)m=b.worldVerticesLength,p=L.setArraySize(n,m,0),b.computeWorldVertices(this,u,0,m,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,m=i.clippedVertices.length);for(let x=0,w=p.length;x<w;x+=2){const T=p[x],y=p[x+1];l=Math.min(l,T),o=Math.min(o,y),a=Math.max(a,T),h=Math.max(h,y)}}}i&&i.clipEnd(u)}i&&i.clipEnd(),e.set(l,o),s.set(a-l,h-o)}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,c=i.length;r<c;r++)i[r].rotate(e,s,n)}},As=class kn 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 kn(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),c=Math.sin(i),l=this.cx-e,o=this.cy-s;this.translate(l*r-o*c-l,l*c+o*r-o)}update(e,s){const n=this.appliedPose,i=n.mix;if(i===0)return;const r=this.data.x>0,c=this.data.y>0,l=this.data.rotate>0||this.data.shearX>0,o=this.data.scaleX>0,a=this.bone;let h=a.bone.data.length,d=this.data.step,f=0;switch(s){case 0:return;case 1:this.reset(e);case 2:{const u=Math.max(e.time-this.lastTime,0),m=this.remaining;this.remaining+=u,this.lastTime=e.time;const p=a.worldX,g=a.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,T=-1,y=0,v=0,S=this.data.limit*u,A=S*Math.abs(e.scaleY);if(S*=Math.abs(e.scaleX),r||c){if(r){const I=(this.ux-p)*x;this.xOffset+=I>S?S:I<-S?-S:I,this.ux=p}if(c){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;T=n.damping**(60*d),y=d*n.massInverse,v=n.strength;const P=w*n.wind,k=w*n.gravity,E=(P*e.windX+k*e.gravityX)*e.scaleX,X=(P*e.windY+k*e.gravityY)*e.scaleY;do r&&(this.xVelocity+=(E-this.xOffset*v)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=T),c&&(this.yVelocity-=(X+this.yOffset*v)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=T),b-=d;while(b>=d);this.xLag=this.xOffset-I,this.yLag=this.yOffset-M}f=Math.max(0,1-b/d),r&&(a.worldX+=(this.xOffset-this.xLag*f)*i*this.data.x),c&&(a.worldY+=(this.yOffset-this.yLag*f)*i*this.data.y)}if(l||o){let I=Math.atan2(a.c,a.a),M=0,P=0,k=0,E=this.cx-a.worldX,X=this.cy-a.worldY;if(E>S?E=S:E<-S&&(E=-S),X>A?X=A:X<-A&&(X=-A),b=this.remaining,l){k=(this.data.rotate+this.data.shearX)*i,f=this.rotateLag*Math.max(0,1-m/d);let V=Math.atan2(X+this.ty,E+this.tx)-I-(this.rotateOffset-f)*k;this.rotateOffset+=(V-Math.ceil(V*R.invPI2-.5)*R.PI2)*x,V=(this.rotateOffset-f)*k+I,M=Math.cos(V),P=Math.sin(V),o&&(V=h*a.getWorldScaleX(),V>0&&(this.scaleOffset+=(E*M+X*P)*x/V))}else{M=Math.cos(I),P=Math.sin(I);const V=h*a.getWorldScaleX()-this.scaleLag*Math.max(0,1-m/d);V>0&&(this.scaleOffset+=(E*M+X*P)*x/V)}if(b>=d){T===-1&&(T=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)*ln.yDir,$=this.rotateOffset,O=this.scaleOffset,F=h/w;for(;;)if(b-=d,o&&(this.scaleVelocity+=(V*M-N*P-this.scaleOffset*v)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=T),l){if(this.rotateVelocity-=((V*P+N*M)*F+this.rotateOffset*v)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=T,b<d)break;const Y=this.rotateOffset*k+I;M=Math.cos(Y),P=Math.sin(Y)}else if(b<d)break;this.rotateLag=this.rotateOffset-$,this.scaleLag=this.scaleOffset-O}f=Math.max(0,1-b/d)}this.remaining=b}this.cx=a.worldX,this.cy=a.worldY;break}case 3:f=Math.max(0,1-this.remaining/d),r&&(a.worldX+=(this.xOffset-this.xLag*f)*i*this.data.x),c&&(a.worldY+=(this.yOffset-this.yLag*f)*i*this.data.y)}if(l){let u=(this.rotateOffset-this.rotateLag*f)*i,m=0,p=0,g=0;if(this.data.shearX>0){let b=0;this.data.rotate>0&&(b=u*this.data.rotate,m=Math.sin(b),p=Math.cos(b),g=a.b,a.b=p*g-m*a.d,a.d=m*g+p*a.d),b+=u*this.data.shearX,m=Math.sin(b),p=Math.cos(b),g=a.a,a.a=p*g-m*a.c,a.c=m*g+p*a.c}else u*=this.data.rotate,m=Math.sin(u),p=Math.cos(u),g=a.a,a.a=p*g-m*a.c,a.c=m*g+p*a.c,g=a.b,a.b=p*g-m*a.d,a.d=m*g+p*a.d}if(o){let u=1+(this.scaleOffset-this.scaleLag*f)*i*this.data.scaleX;switch(a.a*=u,a.c*=u,this.data.scaleYMode){case 1:a.b*=u,a.d*=u;break;case 2:u=Math.abs(u),u=u>=.7?1/u:4-3.67347*u,a.b*=u,a.d*=u}}s!==3&&(this.tx=h*a.a,this.ty=h*a.c),a.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}},Ht=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}},cn=class Ns 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 Ns(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,c=this.bone;if(c!==null){if(!c.active)return;i.local&&c.appliedPose.validateLocalTransform(e),n.time=i.offset+(i.property.value(e,c.appliedPose,i.local,Ns.offsets)-i.property.offset)*i.scale,i.loop?n.time=r.duration+n.time%r.duration:n.time=Math.max(0,n.time)}const l=e.bones,o=r.bones;for(let a=0,h=r.bones.length;a<h;a++)l[o[a]].appliedPose.modifyLocal(e);r.apply(e,n.time,n.time,i.loop,null,n.mix,!1,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,f=n.animation.bones.length;d<f;d++){const u=i[r[d]];u.sorted=!1,e.sortReset(u.children),e.constrained(u)}const c=n.animation.timelines,l=e.slots,o=e.constraints,a=e.physics,h=e.physics.length;for(let d=0,f=n.animation.timelines.length;d<f;d++){const u=c[d];if(Ws(u))e.constrained(l[u.slotIndex]);else if(u instanceof At||u instanceof qt)e.drawOrder.constrained();else if(u instanceof pt)if(u.constraintIndex===-1)for(let m=0;m<h;m++)e.constrained(a[m]);else e.constrained(o[u.constraintIndex]);else if(Hs(u)){const m=u.constraintIndex;m!==-1&&e.constrained(o[m])}}}},Tt=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 cn(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 Tt&&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 c=e.attachments[s];for(const l in c){const o=c[l];if(r===o){const a=this.getAttachment(s,l);a&&i.pose.setAttachment(a);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}},Ps=(t=>(t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen",t))(Ps||{}),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}},hn=class En 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 En(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,c=i.localTarget,l=i.additive,o=i.clamp,a=i.offsets,h=this.source.appliedPose;r&&h.validateLocalTransform(e);const d=i.properties,f=i.properties.length,u=e._update,m=this.bones;for(let p=0,g=this.bones.length;p<g;p++){const b=m[p];c?b.modifyLocal(e):b.modifyWorld(u);for(let x=0;x<f;x++){const w=d[x],T=w.value(e,h,r,a)-w.offset,y=w.to;for(let v=0,S=w.to.length;v<S;v++){const A=y[v];if(A.mix(n)!==0){let I=A.offset+T*A.scale;o&&(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,c,l)}}}}}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 c=s[r].bone;e.sortReset(c.children),e.constrained(c)}for(let r=0;r<n;r++)s[r].bone.sorted=i}isSourceActive(){return this.source.active}},J=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 hn(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[J.ROTATION];const i=t.scaleX,r=t.scaleY;let c=Math.atan2(e.c/r,e.a/i)*R.radDeg+((e.a*e.d-e.b*e.c)*i*r>0?n[J.ROTATION]:-n[J.ROTATION]);return c<0&&(c+=360),c}},Ys=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 c=t.scaleX,l=t.scaleY,o=1/c,a=1/l,h=s.a*o,d=s.b*o,f=s.c*a,u=s.d*a;n*=R.degRad,r||(n-=Math.atan2(f,h)),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2),n*=e.mixRotate;const m=Math.cos(n),p=Math.sin(n);s.a=(m*h-p*f)*c,s.b=(m*d-p*u)*c,s.c=(p*h+m*f)*l,s.d=(p*d+m*u)*l}}},pe=class extends It{value(t,e,s,n){return s?e.x+n[J.X]:(n[J.X]*e.a+n[J.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[J.Y]:(n[J.X]*e.c+n[J.Y]*e.d+e.worldY)/t.scaleY}},ks=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[J.SCALEX];const i=e.a/t.scaleX,r=e.c/t.scaleY;return Math.sqrt(i*i+r*r)+n[J.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 c=1+(n-1)*e.mixScaleX;s.a*=c,s.c*=c}else{let c=s.a/t.scaleX,l=s.c/t.scaleY,o=Math.sqrt(c*c+l*l);o!==0&&(o=1+(n-o)*e.mixScaleX/o,s.a*=o,s.c*=o)}}},we=class extends It{value(t,e,s,n){if(s)return e.scaleY+n[J.SCALEY];const i=e.b/t.scaleX,r=e.d/t.scaleY;return Math.sqrt(i*i+r*r)+n[J.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 c=1+(n-1)*e.mixScaleY;s.b*=c,s.d*=c}else{let c=s.b/t.scaleX,l=s.d/t.scaleY,o=Math.sqrt(c*c+l*l);o!==0&&(o=1+(n-o)*e.mixScaleY/o,s.b*=o,s.d*=o)}}},ye=class extends It{value(t,e,s,n){if(s)return e.shearY+n[J.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[J.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 c=t.scaleX,l=t.scaleY,o=s.b/c,a=s.d/l,h=Math.atan2(a,o);n=(n+90)*R.degRad,r?n-=R.PI/2:(n-=h-Math.atan2(s.c/l,s.a/c),n>R.PI?n-=R.PI2:n<-R.PI&&(n+=R.PI2)),n=h+n*e.mixShearY;const d=Math.sqrt(o*o+a*a);s.b=Math.cos(n)*d*c,s.d=Math.sin(n)*d*l}}},Jn=class{scale=1;attachmentLoader;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Is;s.name="";const n=new dn(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 c=n.readBoolean();c&&(s.fps=n.readFloat(),s.imagesPath=n.readString(),s.audioPath=n.readString());let l=0;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("String in string table must not be null.");n.strings.push(m)}const o=s.bones;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Bone name must not be null.");const p=u===0?null:o[n.readInt(!0)],g=new bs(u,m,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(),c&&(z.rgba8888ToColor(g.color,n.readInt32()),g.icon=n.readString()??void 0,g.iconSize=n.readFloat(),g.iconRotation=n.readFloat(),g.visible=n.readBoolean()),o.push(g)}l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Slot name must not be null.");const p=o[n.readInt(!0)],g=new Ms(u,m,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),c&&(g.visible=n.readBoolean()),s.slots.push(g)}const a=s.constraints,h=n.readInt(!0);for(let u=0;u<h;u++){const m=n.readString();if(!m)throw new Error("Constraint data name must not be null.");let p;switch(n.readByte()){case bi:{const g=new Wt(m);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(o[n.readInt(!0)]);g.target=o[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),a.push(g);break}case wi:{const g=new J(m);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(o[n.readInt(!0)]);g.source=o[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,T;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,T=n.readByte();for(let S=0;S<T;S++){let A=1,I;switch(n.readByte()){case 0:I=new Ys;break;case 1:{A=e,I=new Fs;break}case 2:{A=e,I=new ks;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[S]=I)}g.properties[w]=v}}b=n.readByte(),(b&1)!==0&&(g.offsets[J.ROTATION]=n.readFloat()),(b&2)!==0&&(g.offsets[J.X]=n.readFloat()*e),(b&4)!==0&&(g.offsets[J.Y]=n.readFloat()*e),(b&8)!==0&&(g.offsets[J.SCALEX]=n.readFloat()),(b&16)!==0&&(g.offsets[J.SCALEY]=n.readFloat()),(b&32)!==0&&(g.offsets[J.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()),a.push(g);break}case xi:{const g=new Gt(m);p=n.readInt(!0);for(let w=0;w<p;w++)g.bones.push(o[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(),a.push(g);break}case yi:{const g=new Ht(m);g.bone=o[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,a.push(g);break}case vi:{const g=new Tt(m),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();c&&(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=o[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}a.push(g);break}}}const d=this.readSkin(n,s,!0,c);d&&(s.defaultSkin=d,s.skins.push(d));{let u=s.skins.length;for(L.setArraySize(s.skins,l=u+n.readInt(!0));u<l;u++){const m=this.readSkin(n,s,!1,c);if(!m)throw new Error("readSkin() should not have returned null.");s.skins[u]=m}}l=this.linkedMeshes.length;for(let u=0;u<l;u++){const m=this.linkedMeshes[u],p=s.skins[m.skinIndex];if(!m.source)throw new Error("Linked mesh parent must not be null");const g=p.getAttachment(m.sourceIndex,m.source);if(!g)throw new Error(`Source mesh not found: ${m.source}`);m.mesh.timelineAttachment=m.inheritTimelines?g:m.mesh,m.mesh.setSourceMesh(g),m.mesh.updateSequence()}this.linkedMeshes.length=0,l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Event data name must not be null");const p=new ys(m),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 f=s.animations;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Animation name must not be null.");f.push(this.readAnimation(n,m,s,c))}for(let u=0;u<h;u++){const m=a[u];m instanceof Tt&&(m.animation=f[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 c=t.readString();if(!c)throw new Error("Skin name must not be null.");i=new ue(c),n&&z.rgba8888ToColor(i.color,t.readInt32());let l=t.readInt(!0),o=e.bones,a=i.bones;for(let h=0;h<l;h++)a[h]=o[t.readInt(!0)];l=t.readInt(!0),o=e.constraints,a=i.constraints;for(let h=0;h<l;h++)a[h]=o[t.readInt(!0)];r=t.readInt(!0)}for(let c=0;c<r;c++){const l=t.readInt(!0);for(let o=0,a=t.readInt(!0);o<a;o++){const h=t.readStringRef();if(!h)throw new Error("Attachment name must not be null");const d=this.readAttachment(t,e,i,l,h,n);d&&i.setAttachment(l,h,d)}}return i}readAttachment(t,e,s,n,i,r){const c=this.scale,l=t.readByte(),o=(l&8)!==0?t.readStringRef():i;if(!o)throw new Error("Attachment name must not be null");switch(l&7){case 0:{let a=(l&16)!==0?t.readStringRef():null;const h=(l&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(l&64)!==0),f=(l&128)!==0?t.readFloat():0,u=t.readFloat(),m=t.readFloat(),p=t.readFloat(),g=t.readFloat(),b=t.readFloat(),x=t.readFloat();a||(a=o);const w=this.attachmentLoader.newRegionAttachment(s,i,o,a,d);return w?(w.path=a,w.x=u*c,w.y=m*c,w.scaleX=p,w.scaleY=g,w.rotation=f,w.width=b*c,w.height=x*c,z.rgba8888ToColor(w.color,h),w.updateSequence(),w):null}case 1:{const a=this.readVertices(t,(l&16)!==0),h=r?t.readInt32():0,d=this.attachmentLoader.newBoundingBoxAttachment(s,i,o);return d?(d.worldVerticesLength=a.length,d.vertices=a.vertices,d.bones=a.bones,r&&z.rgba8888ToColor(d.color,h),d):null}case 2:{let a=(l&16)!==0?t.readStringRef():o;const h=(l&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(l&64)!==0),f=t.readInt(!0),u=this.readVertices(t,(l&128)!==0),m=this.readFloatArray(t,u.length,1),p=this.readShortArray(t,(u.length-f-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,T=0;r&&(x=this.readShortArray(t,t.readInt(!0)),w=t.readFloat(),T=t.readFloat()),a||(a=o);const y=this.attachmentLoader.newMeshAttachment(s,i,o,a,d);return y?(y.path=a,z.rgba8888ToColor(y.color,h),y.hullLength=f<<1,y.bones=u.bones,y.vertices=u.vertices,y.worldVerticesLength=u.length,y.regionUVs=m,y.triangles=p,b&&(y.timelineSlots=b),r&&(y.edges=x,y.width=w*c,y.height=T*c),y.updateSequence(),y):null}case 3:{const a=(l&16)!==0?t.readStringRef():o;if(a==null)throw new Error("Path of linked mesh must not be null");const h=(l&32)!==0?t.readInt32():4294967295,d=this.readSequence(t,(l&64)!==0),f=(l&128)!==0,u=t.readInt(!0),m=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,o,a,d);return x?(x.path=a,z.rgba8888ToColor(x.color,h),r&&(x.width=g*c,x.height=b*c),this.linkedMeshes.push(new Kn(x,m,n,u,p,f)),x):null}case 4:{const a=(l&16)!==0,h=(l&32)!==0,d=this.readVertices(t,(l&64)!==0),f=this.readFloatArray(t,d.length/6,c),u=r?t.readInt32():0,m=this.attachmentLoader.newPathAttachment(s,i,o);return m?(m.closed=a,m.constantSpeed=h,m.worldVerticesLength=d.length,m.vertices=d.vertices,m.bones=d.bones,m.lengths=f,r&&z.rgba8888ToColor(m.color,u),m):null}case 5:{const a=t.readFloat(),h=t.readFloat(),d=t.readFloat(),f=r?t.readInt32():0,u=this.attachmentLoader.newPointAttachment(s,i,o);return u?(u.x=h*c,u.y=d*c,u.rotation=a,r&&z.rgba8888ToColor(u.color,f),u):null}case 6:{const a=t.readInt(!0),h=this.readVertices(t,(l&16)!==0),d=r?t.readInt32():0,f=this.attachmentLoader.newClippingAttachment(s,i,o);return f?(f.endSlot=e.slots[a],f.convex=(l&32)!==0,f.inverse=(l&64)!==0,f.worldVerticesLength=h.length,f.vertices=h.vertices,f.bones=h.bones,r&&z.rgba8888ToColor(f.color,d),f):null}}}readSequence(t,e){if(!e)return new Ot(1,!1);const s=new Ot(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 fn(null,this.readFloatArray(t,i,s),i);const r=t.readInt(!0),c=[],l=[];for(let o=0,a=0;o<r;){const h=t.readInt(!0);c[o++]=h;for(let d=0;d<h;d++,a+=3)c[o++]=t.readInt(!0),l[a]=t.readFloat()*s,l[a+1]=t.readFloat()*s,l[a+2]=t.readFloat()}return new fn(c,L.toFloatArray(l),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 f=0,u=t.readInt(!0);f<u;f++){const m=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 di:{const T=new Ft(x,m);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat(),t.readStringRef());i.push(T);break}case fi:{const T=t.readInt(!0),y=new ze(x,T,m);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255;for(let P=0,k=0;y.setFrame(P,v,S,A,I,M),P!==w;P++){const E=t.readFloat(),X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255,N=t.readUnsignedByte()/255,$=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(P);break;case mt:G(t,y,k++,P,0,v,E,S,X,1),G(t,y,k++,P,1,v,E,A,V,1),G(t,y,k++,P,2,v,E,I,N,1),G(t,y,k++,P,3,v,E,M,$,1)}v=E,S=X,A=V,I=N,M=$}i.push(y);break}case ui:{const T=t.readInt(!0),y=new We(x,T,m);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255;for(let M=0,P=0;y.setFrame(M,v,S,A,I),M!==w;M++){const k=t.readFloat(),E=t.readUnsignedByte()/255,X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(M);break;case mt:G(t,y,P++,M,0,v,k,S,E,1),G(t,y,P++,M,1,v,k,A,X,1),G(t,y,P++,M,2,v,k,I,V,1)}v=k,S=E,A=X,I=V}i.push(y);break}case mi:{const T=t.readInt(!0),y=new He(x,T,m);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,E=t.readUnsignedByte()/255;for(let X=0,V=0;y.setFrame(X,v,S,A,I,M,P,k,E),X!==w;X++){const N=t.readFloat(),$=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255,W=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(X);break;case mt:G(t,y,V++,X,0,v,N,S,$,1),G(t,y,V++,X,1,v,N,A,O,1),G(t,y,V++,X,2,v,N,I,F,1),G(t,y,V++,X,3,v,N,M,Y,1),G(t,y,V++,X,4,v,N,P,U,1),G(t,y,V++,X,5,v,N,k,D,1),G(t,y,V++,X,6,v,N,E,W,1)}v=N,S=$,A=O,I=F,M=Y,P=U,k=D,E=W}i.push(y);break}case gi:{const T=t.readInt(!0),y=new je(x,T,m);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255;for(let E=0,X=0;y.setFrame(E,v,S,A,I,M,P,k),E!==w;E++){const V=t.readFloat(),N=t.readUnsignedByte()/255,$=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(E);break;case mt:G(t,y,X++,E,0,v,V,S,N,1),G(t,y,X++,E,1,v,V,A,$,1),G(t,y,X++,E,2,v,V,I,O,1),G(t,y,X++,E,3,v,V,M,F,1),G(t,y,X++,E,4,v,V,P,Y,1),G(t,y,X++,E,5,v,V,k,U,1)}v=V,S=N,A=$,I=O,M=F,P=Y,k=U}i.push(y);break}case pi:{const T=new Ge(x,t.readInt(!0),m);let y=t.readFloat(),v=t.readUnsignedByte()/255;for(let S=0,A=0;T.setFrame(S,y,v),S!==w;S++){const I=t.readFloat(),M=t.readUnsignedByte()/255;switch(t.readByte()){case ut:T.setStepped(S);break;case mt:G(t,T,A++,S,0,y,I,v,M,1)}y=I,v=M}i.push(T)}}}}for(let f=0,u=t.readInt(!0);f<u;f++){const m=t.readInt(!0);for(let p=0,g=t.readInt(!0);p<g;p++){const b=t.readByte(),x=t.readInt(!0);if(b===hi){const T=new _e(x,m);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat(),t.readByte());i.push(T);continue}const w=t.readInt(!0);switch(b){case ti:tt(t,i,new Dt(x,w,m),1);break;case ei:tt(t,i,new Re(x,w,m),r);break;case si:tt(t,i,new Le(x,w,m),r);break;case ni:tt(t,i,new Be(x,w,m),r);break;case ii:tt(t,i,new Oe(x,w,m),1);break;case ri:tt(t,i,new Ne(x,w,m),1);break;case ai:tt(t,i,new De(x,w,m),1);break;case oi:tt(t,i,new Ue(x,w,m),1);break;case li:tt(t,i,new qe(x,w,m),1);break;case ci:tt(t,i,new $e(x,w,m),1);break}}}for(let f=0,u=t.readInt(!0);f<u;f++){const m=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new Qe(p,t.readInt(!0),m);let x=t.readByte(),w=t.readFloat(),T=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,y=(x&4)!==0?t.readFloat()*r:0;for(let v=0,S=0;b.setFrame(v,w,T,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&&(G(t,b,S++,v,0,w,A,T,I,1),G(t,b,S++,v,1,w,A,y,M,r)),w=A,T=I,y=M}i.push(b)}for(let f=0,u=t.readInt(!0);f<u;f++){const m=t.readInt(!0),p=t.readInt(!0),g=p-1,b=new Ze(p,t.readInt(!0),m);let x=t.readFloat(),w=t.readFloat(),T=t.readFloat(),y=t.readFloat(),v=t.readFloat(),S=t.readFloat(),A=t.readFloat();for(let I=0,M=0;b.setFrame(I,x,w,T,y,v,S,A),I!==g;I++){const P=t.readFloat(),k=t.readFloat(),E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat(),$=t.readFloat();switch(t.readByte()){case ut:b.setStepped(I);break;case mt:G(t,b,M++,I,0,x,P,w,k,1),G(t,b,M++,I,1,x,P,T,E,1),G(t,b,M++,I,2,x,P,y,X,1),G(t,b,M++,I,3,x,P,v,V,1),G(t,b,M++,I,4,x,P,S,N,1),G(t,b,M++,I,5,x,P,A,$,1)}x=P,w=k,T=E,y=X,v=V,S=N,A=$}i.push(b)}for(let f=0,u=t.readInt(!0);f<u;f++){const m=t.readInt(!0),p=s.constraints[m];for(let g=0,b=t.readInt(!0);g<b;g++){const x=t.readByte(),w=t.readInt(!0),T=t.readInt(!0);switch(x){case Ai:tt(t,i,new ts(w,T,m),p.positionMode===0?r:1);break;case Ii:tt(t,i,new es(w,T,m),p.spacingMode===0||p.spacingMode===1?r:1);break;case Ci:{const y=new ss(w,T,m);let v=t.readFloat(),S=t.readFloat(),A=t.readFloat(),I=t.readFloat();for(let M=0,P=0,k=y.getFrameCount()-1;y.setFrame(M,v,S,A,I),M!==k;M++){const E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat();switch(t.readByte()){case ut:y.setStepped(M);break;case mt:G(t,y,P++,M,0,v,E,S,X,1),G(t,y,P++,M,1,v,E,A,V,1),G(t,y,P++,M,2,v,E,I,N,1)}v=E,S=X,A=V,I=N}i.push(y)}}}}for(let f=0,u=t.readInt(!0);f<u;f++){const m=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===Vi){const T=new hs(x,m);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat());i.push(T);continue}const w=t.readInt(!0);switch(b){case Mi:tt(t,i,new ns(x,w,m),1);break;case Pi:tt(t,i,new is(x,w,m),1);break;case Yi:tt(t,i,new rs(x,w,m),1);break;case Fi:tt(t,i,new as(x,w,m),1);break;case ki:tt(t,i,new os(x,w,m),1);break;case Ei:tt(t,i,new ls(x,w,m),1);break;case Xi:tt(t,i,new cs(x,w,m),1);break;default:throw new Error("Unknown physics timeline type.")}}}for(let f=0,u=t.readInt(!0);f<u;f++){const m=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 Ri:tt(t,i,new ds(x,w,m),1);break;case Li:tt(t,i,new fs(x,w,m),1);break;default:throw new Error(`Uknown slider type: ${b}`)}}}for(let f=0,u=t.readInt(!0);f<u;f++){const m=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 T=t.readStringRef();if(!T)throw new Error("attachmentName must not be null.");const y=m.getAttachment(b,T),v=t.readByte(),S=t.readInt(!0),A=S-1;switch(v){case Ti:{const I=y,M=I.bones,P=I.vertices,k=M?P.length/3*2:P.length,E=t.readInt(!0),X=new Je(S,E,b,I);let V=t.readFloat();for(let N=0,$=0;;N++){let O,F=t.readInt(!0);if(F===0)O=M?L.newFloatArray(k):P;else{O=L.newFloatArray(k);const U=t.readInt(!0);if(F+=U,r===1)for(let D=U;D<F;D++)O[D]=t.readFloat();else for(let D=U;D<F;D++)O[D]=t.readFloat()*r;if(!M)for(let D=0,W=O.length;D<W;D++)O[D]+=P[D]}if(X.setFrame(N,V,O),N===A)break;const Y=t.readFloat();switch(t.readByte()){case ut:X.setStepped(N);break;case mt:G(t,X,$++,N,0,V,Y,0,1,1)}V=Y}i.push(X);break}case Si:{const I=new Ke(S,b,y);for(let M=0;M<S;M++){const P=t.readFloat(),k=t.readInt32();I.setFrame(M,P,Ve[k&15],k>>4,t.readFloat())}i.push(I);break}}}}}const c=s.slots.length,l=t.readInt(!0);if(l>0){const f=new At(l);for(let u=0;u<l;u++)f.setFrame(u,t.readFloat(),un(t,c));i.push(f)}const o=t.readInt(!0);for(let f=0;f<o;f++){const u=t.readInt(!0),m=new Array(u);for(let b=0;b<u;b++)m[b]=t.readInt(!0);const p=t.readInt(!0),g=new qt(p,m,c);for(let b=0;b<p;b++)g.setFrame(b,t.readFloat(),un(t,u));i.push(g)}const a=t.readInt(!0);if(a>0){const f=new Zt(a);for(let u=0;u<a;u++){const m=t.readFloat(),p=s.events[t.readInt(!0)],g=new oe(m,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()),f.setFrame(u,g)}i.push(f)}let h=0;for(let f=0,u=i.length;f<u;f++)h=Math.max(h,i[f].getDuration());const d=new Kt(e,i,h);return n&&z.rgba8888ToColor(d.color,t.readInt32()),d}},dn=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}},Kn=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}},fn=class{constructor(t=null,e,s=0){this.bones=t,this.vertices=e,this.length=s}};function tt(t,e,s,n){s instanceof Nt?Qn(t,e,s,n):Zn(t,e,s,n)}function Qn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n;for(let c=0,l=0,o=s.getFrameCount()-1;s.setFrame(c,i,r),c!==o;c++){const a=t.readFloat(),h=t.readFloat()*n;switch(t.readByte()){case ut:s.setStepped(c);break;case mt:G(t,s,l++,c,0,i,a,r,h,n)}i=a,r=h}e.push(s)}function Zn(t,e,s,n){let i=t.readFloat(),r=t.readFloat()*n,c=t.readFloat()*n;for(let l=0,o=0,a=s.getFrameCount()-1;s.setFrame(l,i,r,c),l!==a;l++){const h=t.readFloat(),d=t.readFloat()*n,f=t.readFloat()*n;switch(t.readByte()){case ut:s.setStepped(l);break;case mt:G(t,s,o++,l,0,i,h,r,d,n),G(t,s,o++,l,1,i,h,c,f,n)}i=h,r=d,c=f}e.push(s)}function un(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,c=0;for(let l=0;l<s;l++){const o=t.readInt(!0);for(;r!==o;)i[c++]=r++;n[r+t.readInt(!0)]=r++}for(;r<e;)i[c++]=r++;for(let l=e-1;l>=0;l--)n[l]===-1&&(n[l]=i[--c]);return n}function G(t,e,s,n,i,r,c,l,o,a){e.setBezier(s,n,i,r,l,t.readFloat(),t.readFloat()*a,t.readFloat(),t.readFloat()*a,c,o)}var ti=0,ei=1,si=2,ni=3,ii=4,ri=5,ai=6,oi=7,li=8,ci=9,hi=10,di=0,fi=1,ui=2,mi=3,gi=4,pi=5,bi=0,xi=1,wi=2,yi=3,vi=4,Ti=0,Si=1,Ai=0,Ii=1,Ci=2,Mi=0,Pi=1,Yi=2,Fi=4,ki=5,Ei=6,Xi=7,Vi=8,Ri=0,Li=1,ut=1,mt=2,Bi=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new Bt(()=>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,c=r.length;s.length=0,i.freeAll(n),n.length=0;for(let l=0;l<c;l++){const o=r[l];if(!o.bone.active)continue;const a=o.appliedPose.attachment;if(a instanceof ps){s.push(a);let h=i.obtain();h.length!==a.worldVerticesLength&&(h=L.newFloatArray(a.worldVerticesLength)),n.push(h),a.computeWorldVertices(t,o,0,a.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,c=i.length;r<c;r++){const l=i[r],o=l;for(let a=0,h=l.length;a<h;a+=2){const d=o[a],f=o[a+1];t=Math.min(t,d),e=Math.min(e,f),s=Math.max(s,d),n=Math.max(n,f)}}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,c=this.maxX,l=this.maxY;if(t<=i&&s<=i||e<=r&&n<=r||t>=c&&s>=c||e>=l&&n>=l)return!1;const o=(n-e)/(s-t);let a=o*(i-t)+e;if(a>r&&a<l||(a=o*(c-t)+e,a>r&&a<l))return!0;let h=(r-e)/o+t;return h>i&&h<c||(h=(l-e)/o+t,h>i&&h<c)}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,c=!1;for(let l=0;l<i;l+=2){const o=n[l+1],a=n[r+1];if(o<s&&a>=s||a<s&&o>=s){const h=n[l];h+(s-o)/(a-o)*(n[r]-h)<e&&(c=!c)}r=l}return c}intersectsSegment(t,e,s,n){const i=this.polygons;for(let r=0,c=i.length;r<c;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,c=t.length,l=e-n,o=s-i,a=e*i-s*n;let h=r[c-2],d=r[c-1];for(let f=0;f<c;f+=2){const u=r[f],m=r[f+1],p=h*m-d*u,g=h-u,b=d-m,x=l*b-o*g,w=(a*g-l*p)/x;if((w>=h&&w<=u||w>=u&&w<=h)&&(w>=e&&w<=n||w>=n&&w<=e)){const T=(a*b-o*p)/x;if((T>=d&&T<=m||T>=m&&T<=d)&&(T>=s&&T<=i||T>=i&&T<=s))return!0}h=u,d=m}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}},mn=class ot{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new Bt(()=>[]);polygonIndicesPool=new Bt(()=>[]);triangulate(e){const s=e;let n=e.length>>1;const i=this.indicesArray;i.length=0;for(let l=0;l<n;l++)i[l]=l;const r=this.isConcaveArray;r.length=0;for(let l=0;l<n;l++)r[l]=ot.isConcave(l,n,s,i);const c=this.triangles;for(c.length=0;n>3;){let l=n-1,o=0,a=1;for(;;){t:if(!r[o]){const f=i[l]<<1,u=i[o]<<1,m=i[a]<<1,p=s[f],g=s[f+1],b=s[u],x=s[u+1],w=s[m],T=s[m+1];for(let y=a+1<n?a+1:0;y!==l;){if(r[y]){const v=i[y]<<1,S=s[v],A=s[v+1];if(ot.positiveArea(w,T,p,g,S,A)&&ot.positiveArea(p,g,b,x,S,A)&&ot.positiveArea(b,x,w,T,S,A))break t}++y===n&&(y=0)}break}if(a===0){do{if(!r[o])break;o--}while(o>0);l=o>0?o-1:n-1,a=o+1<n?o+1:0;break}l=o,o=a,++a===n&&(a=0)}c.push(i[l],i[o],i[a]),i.splice(o,1),r.splice(o,1),n--;const h=o>0?o-1:n-1,d=o<n?o:0;r[h]=ot.isConcave(h,n,s,i),r[d]=ot.isConcave(d,n,s,i)}return n===3&&c.push(i[2],i[0],i[1]),c}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 c=this.polygonIndicesPool.obtain();c.length=0;let l=this.polygonPool.obtain();l.length=0;let o=-1,a=0;for(let h=0,d=s.length;h<d;h+=3){const f=s[h]<<1,u=s[h+1]<<1,m=s[h+2]<<1,p=n[f],g=n[f+1],b=n[u],x=n[u+1],w=n[m],T=n[m+1];if(o===f){const y=l.length-4;if(ot.winding(l[y],l[y+1],l[y+2],l[y+3],w,T)===a&&ot.winding(w,T,l[0],l[1],l[2],l[3])===a){l.push(w,T),c.push(m);continue}}l.length>0&&(i.push(l),r.push(c),l=this.polygonPool.obtain(),c=this.polygonIndicesPool.obtain()),l.length=0,l.push(p,g,b,x),l.push(w,T),c.length=0,c.push(f,u,m),a=ot.winding(p,g,b,x,w,T),o=f}l.length>0&&(i.push(l),r.push(c));for(let h=0,d=i.length;h<d;h++){if(c=r[h],c.length===0)continue;const f=c[0];let u=c[c.length-1];l=i[h];const m=l.length-4;let p=l[m],g=l[m+1],b=l[m+2],x=l[m+3];const w=l[0],T=l[1],y=l[2],v=l[3],S=ot.winding(p,g,b,x,w,T);for(let A=0;A<d;A++){if(A===h)continue;const I=r[A];if(I.length!==3)continue;const M=I[0],P=I[1],k=I[2],E=i[A],X=E[E.length-2],V=E[E.length-1];M!==f||P!==u||ot.winding(p,g,b,x,X,V)===S&&ot.winding(X,V,w,T,y,v)===S&&(E.length=0,I.length=0,l.push(X,V),c.push(k),u=k,p=b,g=x,b=X,x=V,A=-1)}}for(let h=i.length-1;h>=0;h--)l=i[h],l.length===0?(i.splice(h,1),this.polygonPool.free(l),c=r[h],r.splice(h,1),this.polygonIndicesPool.free(c)):l.push(l[0],l[1]);return i}static isConcave(e,s,n,i){const r=i[e>0?e-1:s-1]<<1,c=i[e]<<1,l=i[e+1<s?e+1:0]<<1;return!ot.positiveArea(n[r],n[r+1],n[c],n[c+1],n[l],n[l+1])}static positiveArea(e,s,n,i,r,c){return e*(c-i)+n*(s-c)+r*(i-s)>=0}static winding(e,s,n,i,r,c){return e*(c-i)+n*(s-c)+r*(i-s)>=0?1:-1}},gn=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,c=this.makeClockwise(r);c||this.inverse||s.convex?(c||this.makeConvex(r),this.clippingPolygon.push(r[0],r[1]),this.clippingPolygons.push(r)):(this.triangulator===null&&(this.triangulator=new mn),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,c,l){return n&&i&&r&&typeof c=="boolean"&&typeof l=="number"?this.clipTrianglesRender(t,e,s,n,i,r,c,l):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 f=e[d]<<1;const u=t[f],m=t[f+1];f=e[d+1]<<1;const p=t[f],g=t[f+1];f=e[d+2]<<1;const b=t[f],x=t[f+1];this.clipInverse(u,m,p,g,b,x,h);const w=this.inverseVertices;for(let T=0,y=this.inverseVertices.length;T<y;){const v=w[T++];let S=v>>1,A=n.length;const I=L.setArraySize(n,A+v);L.arrayCopy(w,T,I,A,v),A=i.length;const M=L.setArraySize(i,A+3*(S-2));for(let P=1;P<S-1;P++,A+=3)M[A]=r,M[A+1]=r+P,M[A+2]=r+P+1;r+=S,T+=v}}return!0}const c=this.clipOutput,l=this.clippingPolygons,o=l.length;let a=null;for(let h=0;h<s;h+=3){let d=e[h]<<1;const f=t[d],u=t[d+1];d=e[h+1]<<1;const m=t[d],p=t[d+1];d=e[h+2]<<1;const g=t[d],b=t[d+1];for(let x=0;x<o;x++){let w=n.length;if(this.clip(f,u,m,p,g,b,l[x])){a=this.clipOutput;const T=c.length;if(T===0)continue;let y=T>>1;const v=L.setArraySize(n,w+T);L.arrayCopy(a,0,v,w,T),w=i.length;const S=L.setArraySize(i,w+3*(y-2));y--;for(let A=1;A<y;A++,w+=3)S[w]=r,S[w+1]=r+A,S[w+2]=r+A+1;r+=y}else{const T=L.setArraySize(n,w+6);T[w]=f,T[w+1]=u,T[w+2]=m,T[w+3]=p,T[w+4]=g,T[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 a!=null}clipTrianglesRender(t,e,s,n,i,r,c,l){const o=this.clippedVertices;o.length=0;const a=this.clippedTriangles;a.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 T=t[b*l],y=t[b*l+1],v=t[x*l],S=t[x*l+1],A=t[w*l],I=t[w*l+1];this.clipInverse(T,y,v,S,A,I,p);const M=this.inverseVertices.length;if(M===0)continue;const P=n[b<<=1],k=n[b+1],E=n[x<<=1],X=n[x+1],V=n[w<<=1],N=n[w+1],$=S-I,O=A-v,F=T-A,Y=I-y,U=1/($*F+O*(y-I)),D=this.inverseVertices;for(let W=0;W<M;){const B=D[W++],_=B>>1;let q=o.length;const K=L.setArraySize(o,q+_*l);for(let Q=0;Q<B;Q+=2,q+=l){const st=D[W+Q],it=D[W+Q+1];K[q]=st,K[q+1]=it,K[q+2]=i.r,K[q+3]=i.g,K[q+4]=i.b,K[q+5]=i.a;const nt=st-A,dt=it-I,rt=($*nt+O*dt)*U,at=(Y*nt+F*dt)*U,ft=1-rt-at;K[q+6]=P*rt+E*at+V*ft,K[q+7]=k*rt+X*at+N*ft,c&&(K[q+8]=r.r,K[q+9]=r.g,K[q+10]=r.b,K[q+11]=r.a)}q=a.length;const et=L.setArraySize(a,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,f=this.clippingPolygons,u=this.clippingPolygons.length;let m=null;for(let p=0;p<s;p+=3){let g=e[p];const b=t[g*l],x=t[g*l+1],w=n[g<<1],T=n[(g<<1)+1];g=e[p+1];const y=t[g*l],v=t[g*l+1],S=n[g<<1],A=n[(g<<1)+1];g=e[p+2];const I=t[g*l],M=t[g*l+1],P=n[g<<1],k=n[(g<<1)+1],E=v-M,X=I-y,V=b-I,N=M-x,$=1/(E*V+X*(x-M));for(let O=0;O<u;O++){let F=o.length;if(this.clip(b,x,y,v,I,M,f[O])){m=this.clipOutput;const Y=d.length;if(Y===0)continue;let U=Y>>1;const D=L.setArraySize(o,F+U*l);for(let B=0;B<Y;B+=2,F+=l){const _=m[B],q=m[B+1];D[F]=_,D[F+1]=q,D[F+2]=i.r,D[F+3]=i.g,D[F+4]=i.b,D[F+5]=i.a;const K=_-I,et=q-M,Q=(E*K+X*et)*$,st=(N*K+V*et)*$,it=1-Q-st;D[F+6]=w*Q+S*st+P*it,D[F+7]=T*Q+A*st+k*it,c&&(D[F+8]=r.r,D[F+9]=r.g,D[F+10]=r.b,D[F+11]=r.a)}F=a.length;const W=L.setArraySize(a,F+3*(U-2));U--;for(let B=1;B<U;B++,F+=3)W[F]=h,W[F+1]=h+B,W[F+2]=h+B+1;h+=U+1}else{const Y=L.setArraySize(o,F+3*l);Y[F]=b,Y[F+1]=x,Y[F+2]=i.r,Y[F+3]=i.g,Y[F+4]=i.b,Y[F+5]=i.a,c?(Y[F+6]=w,Y[F+7]=T,Y[F+8]=r.r,Y[F+9]=r.g,Y[F+10]=r.b,Y[F+11]=r.a,Y[F+12]=y,Y[F+13]=v,Y[F+14]=i.r,Y[F+15]=i.g,Y[F+16]=i.b,Y[F+17]=i.a,Y[F+18]=S,Y[F+19]=A,Y[F+20]=r.r,Y[F+21]=r.g,Y[F+22]=r.b,Y[F+23]=r.a,Y[F+24]=I,Y[F+25]=M,Y[F+26]=i.r,Y[F+27]=i.g,Y[F+28]=i.b,Y[F+29]=i.a,Y[F+30]=P,Y[F+31]=k,Y[F+32]=r.r,Y[F+33]=r.g,Y[F+34]=r.b,Y[F+35]=r.a):(Y[F+6]=w,Y[F+7]=T,Y[F+8]=y,Y[F+9]=v,Y[F+10]=i.r,Y[F+11]=i.g,Y[F+12]=i.b,Y[F+13]=i.a,Y[F+14]=S,Y[F+15]=A,Y[F+16]=I,Y[F+17]=M,Y[F+18]=i.r,Y[F+19]=i.g,Y[F+20]=i.b,Y[F+21]=i.a,Y[F+22]=P,Y[F+23]=k),F=a.length;const U=L.setArraySize(a,F+3);U[F]=h,U[F+1]=h+1,U[F+2]=h+2,h+=3;break}}}return m!=null}clipTrianglesUnpacked(t,e,s,n,i,r=2){let c=this._clippedVerticesTyped,l=this._clippedUVsTyped,o=this._clippedTrianglesTyped,a=0;if(this.clippedVerticesLength=0,this.clippedUVsLength=0,this.clippedTrianglesLength=0,this.inverse){const m=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 T=i[w],y=i[w+1];g=s[p+1]*r;const v=t[e+g],S=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],P=t[e+g+1];w=s[p+2]<<1;const k=i[w],E=i[w+1];this.clipInverse(b,x,v,S,M,P,m);const X=this.inverseVertices.length;if(X===0)continue;const V=S-P,N=M-v,$=b-M,O=P-x,F=1/(V*$+N*(x-P)),Y=this.inverseVertices;for(let U=0;U<X;){const D=Y[U++],W=D>>1;let B=this.clippedVerticesLength;const _=B+W*r,q=this.clippedUVsLength+W*2;c.length<_&&(this._clippedVerticesTyped=new Float32Array(_*2),this._clippedVerticesTyped.set(c.subarray(0,B)),c=this._clippedVerticesTyped),l.length<q&&(this._clippedUVsTyped=new Float32Array(q*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped),this.clippedVerticesLength=_,this.clippedUVsLength=q;const K=this._clippedVerticesTyped,et=this._clippedUVsTyped;let Q=q-W*2;for(let nt=0;nt<D;nt+=2,B+=r,Q+=2){const dt=Y[U+nt],rt=Y[U+nt+1];K[B]=dt,K[B+1]=rt;const at=dt-M,ft=rt-P,gt=(V*at+N*ft)*F,bt=(O*at+$*ft)*F,jt=1-gt-bt;et[Q]=T*gt+A*bt+k*jt,et[Q+1]=y*gt+I*bt+E*jt}B=this.clippedTrianglesLength;const st=B+3*(W-2);o.length<st&&(this._clippedTrianglesTyped=new Uint16Array(st*2),this._clippedTrianglesTyped.set(o.subarray(0,B)),o=this._clippedTrianglesTyped),this.clippedTrianglesLength=st;const it=o;for(let nt=1;nt<W-1;nt++,B+=3)it[B]=a,it[B+1]=a+nt,it[B+2]=a+nt+1;a+=W,U+=D}}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,f=this.clippingPolygons.length;let u=null;for(let m=0;m<n;m+=3){let p=s[m],g=p*r;const b=t[e+g],x=t[e+g+1];let w=p<<1;const T=i[w],y=i[w+1];p=s[m+1],g=p*r;const v=t[e+g],S=t[e+g+1];w=p<<1;const A=i[w],I=i[w+1];p=s[m+2],g=p*r;const M=t[e+g],P=t[e+g+1];w=p<<1;const k=i[w],E=i[w+1],X=S-P,V=M-v,N=b-M,$=P-x,O=1/(X*N+V*(x-P));for(let F=0;F<f;F++){let Y=this.clippedVerticesLength;if(this.clip(b,x,v,S,M,P,d[F])){u=h;const U=h.length;if(U===0)continue;let D=U>>1;const W=Y+D*r;c.length<W&&(this._clippedVerticesTyped=new Float32Array(W*2),this._clippedVerticesTyped.set(c.subarray(0,Y)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+D*2)*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),c=this._clippedVerticesTyped,l=this._clippedUVsTyped);const B=c,_=l;this.clippedVerticesLength=W;let q=this.clippedUVsLength;this.clippedUVsLength=q+D*2;for(let Q=0;Q<U;Q+=2,Y+=r,q+=2){const st=u[Q],it=u[Q+1];B[Y]=st,B[Y+1]=it;const nt=st-M,dt=it-P,rt=(X*nt+V*dt)*O,at=($*nt+N*dt)*O,ft=1-rt-at;_[q]=T*rt+A*at+k*ft,_[q+1]=y*rt+I*at+E*ft}Y=this.clippedTrianglesLength;const K=Y+3*(D-2);o.length<K&&(this._clippedTrianglesTyped=new Uint16Array(K*2),this._clippedTrianglesTyped.set(o.subarray(0,Y)),o=this._clippedTrianglesTyped),this.clippedTrianglesLength=K;const et=o;D--;for(let Q=1;Q<D;Q++,Y+=3)et[Y]=a,et[Y+1]=a+Q,et[Y+2]=a+Q+1;a+=D+1}else{let U=Y+3*r;c.length<U&&(this._clippedVerticesTyped=new Float32Array(U*2),this._clippedVerticesTyped.set(c.subarray(0,Y)),c=this._clippedVerticesTyped),c[Y]=b,c[Y+1]=x,c[Y+r]=v,c[Y+r+1]=S,c[Y+r*2]=M,c[Y+r*2+1]=P;const D=this.clippedUVsLength+3*2;l.length<D&&(this._clippedUVsTyped=new Float32Array(D*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped);const W=this.clippedUVsLength;l[W]=T,l[W+1]=y,l[W+2]=A,l[W+3]=I,l[W+4]=k,l[W+5]=E,this.clippedVerticesLength=U,this.clippedUVsLength=D,Y=this.clippedTrianglesLength,U=Y+3,o.length<U&&(this._clippedTrianglesTyped=new Uint16Array(U*2),this._clippedTrianglesTyped.set(o.subarray(0,Y)),o=this._clippedTrianglesTyped);const B=o;B[Y]=a,B[Y+1]=a+1,B[Y+2]=a+2,a+=3,this.clippedTrianglesLength=U;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,c){const l=this.clipOutput;let o=!1,a,h;c.length%4>=2?(a=this.clipOutput,h=this.scratch):(a=this.scratch,h=this.clipOutput);const d=c;a.length=8;const f=a;f[0]=t,f[1]=e,f[2]=s,f[3]=n,f[4]=i,f[5]=r,f[6]=t,f[7]=e,h.length=0;const u=c.length-4;for(let m=0;;m+=2){const p=d[m],g=d[m+1],b=p-d[m+2],x=g-d[m+3],w=h.length,T=a;for(let v=0,S=a.length-2;v<S;){t=T[v],e=T[v+1],v+=2,s=T[v],n=T[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,P=n-e,k=I/(M*x-P*b);k>=0&&k<=1?(h.push(t+M*k,e+P*k),o=!0):h.push(s,n)}else if(A){const M=s-t,P=n-e,k=I/(M*x-P*b);k>=0&&k<=1?(h.push(t+M*k,e+P*k,s,n),o=!0):h.push(s,n)}else o=!0}if(w===h.length)return l.length=0,!0;if(h.push(h[0],h[1]),m===u)break;const y=h;h=a,h.length=0,a=y}if(l!==h){l.length=0;for(let m=0,p=h.length-2;m<p;m++)l[m]=h[m]}else l.length=l.length-2;return o}clipInverse(t,e,s,n,i,r,c){this.inverseVertices.length=0;const l=c.length-4;let o,a;c.length%4>=2?(o=this.clipOutput,a=this.scratch):(o=this.scratch,a=this.clipOutput),o.length=8;let h=c,d=o;d[0]=t,d[1]=e,d[2]=s,d[3]=n,d[4]=i,d[5]=r,d[6]=t,d[7]=e,a.length=0;for(let f=0;;f+=2){const u=h[f],m=h[f+1],p=u-h[f+2],g=m-h[f+3],b=a.length,x=this.inverseVertices.length;this.inverseVertices.push(0),d=o;for(let y=0,v=o.length-2;y<v;){t=d[y],e=d[y+1],y+=2,s=d[y],n=d[y+1];const S=g*(u-s)>p*(m-n),A=g*(u-t)-p*(m-e);if(A>0)if(S)a.push(s,n);else{const I=s-t,M=n-e,P=A/(I*g-M*p);if(P>=0&&P<=1){const k=t+I*P,E=e+M*P;a.push(k,E),this.inverseVertices.push(k,E,s,n)}else a.push(s,n)}else if(S){const I=s-t,M=n-e,P=A/(I*g-M*p);if(P>=0&&P<=1){const k=t+I*P,E=e+M*P;this.inverseVertices.push(k,E),a.push(k,E,s,n)}else a.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===a.length||(a.push(a[0],a[1]),f===l))break;const T=a;a=o,a.length=0,o=T}}makeClockwise(t){const e=t,s=t.length;let n=!0,i=!0,r=0,c=e[s-2],l=e[s-1],o=e[0],a=e[1];for(let d=2;d<s;d+=2){const f=e[d],u=e[d+1];r+=o*u-f*a;const m=(o-c)*(u-a)-(a-l)*(f-o);i=i&&m<=0,n=n&&m>=0,c=o,l=a,o=f,a=u}r+=o*e[1]-e[0]*a;const h=(o-c)*(e[1]-a)-(a-l)*(e[0]-o);if(i=i&&h<=0,n=n&&h>=0,r>=0){for(let d=0,f=s-2,u=s>>1;d<u;d+=2){const m=e[d],p=e[d+1],g=f-d;e[d]=e[g],e[d+1]=e[g+1],e[g]=m,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 c=2;c<e;c+=2){const l=s[c],o=s[c+1];let a=c-2;for(;a>=0&&(n[a]>l||n[a]===l&&n[a+1]>o);a-=2)n[a+2]=n[a],n[a+3]=n[a+1];n[a+2]=l,n[a+3]=o}s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3];let i=4;for(let c=4;c<e;c+=2,i+=2){const l=n[c],o=n[c+1];for(;(s[i-2]-s[i-4])*(o-s[i-3])-(s[i-1]-s[i-3])*(l-s[i-4])>=0&&(i-=2,i!==2););s[i]=l,s[i+1]=o}s[i]=n[e-4],s[i+1]=n[e-3];const r=i;i+=2;for(let c=e-6;c>=0;c-=2,i+=2){const l=n[c],o=n[c+1];for(;(s[i-2]-s[i-4])*(o-s[i-3])-(s[i-1]-s[i-3])*(l-s[i-4])>=0&&(i-=2,i!==r););s[i]=l,s[i+1]=o}t.length=i-2}},Oi=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 c=n.bones[r];let l=null;const o=C(c,"parent",null);o&&(l=s.findBone(o));const a=new bs(s.bones.length,c.name,l);a.length=C(c,"length",0)*e;const h=a.setupPose;h.x=C(c,"x",0)*e,h.y=C(c,"y",0)*e,h.rotation=C(c,"rotation",0),h.scaleX=C(c,"scaleX",1),h.scaleY=C(c,"scaleY",1),h.shearX=C(c,"shearX",0),h.shearY=C(c,"shearY",0),h.inherit=L.enumValue(ne,C(c,"inherit","Normal")),a.skinRequired=C(c,"skin",!1);const d=C(c,"color",null);d&&a.color.setFromString(d),a.icon=C(c,"icon",void 0),a.iconSize=C(c,"iconSize",1),a.iconRotation=C(c,"iconRotation",0),s.bones.push(a)}if(n.slots)for(let r=0;r<n.slots.length;r++){const c=n.slots[r],l=c.name,o=s.findBone(c.bone);if(!o)throw new Error(`Couldn't find bone ${c.bone} for slot ${l}`);const a=new Ms(s.slots.length,l,o),h=C(c,"color",null);h&&a.setupPose.color.setFromString(h);const d=C(c,"dark",null);d&&(a.setupPose.darkColor=z.fromString(d)),a.attachmentName=C(c,"attachment",null),a.blendMode=L.enumValue(Ps,C(c,"blend","normal")),a.visible=C(c,"visible",!0),s.slots.push(a)}if(n.constraints)for(const r of n.constraints){const c=r.name,l=C(r,"skin",!1);switch(C(r,"type",!1)){case"ik":{const o=new Wt(c);o.skinRequired=l;for(let u=0;u<r.bones.length;u++){const m=s.findBone(r.bones[u]);if(!m)throw new Error(`Couldn't find bone ${r.bones[u]} for IK constraint ${c}.`);o.bones.push(m)}const a=r.target,h=s.findBone(a);if(!h)throw new Error(`Couldn't find target bone ${a} for IK constraint ${c}.`);o.target=h;const d=C(r,"scaleY",null);d!=null&&(o.scaleYMode=L.enumValue(ae,d));const f=o.setupPose;f.mix=C(r,"mix",1),f.softness=C(r,"softness",0)*e,f.bendDirection=C(r,"bendPositive",!0)?1:-1,f.compress=C(r,"compress",!1),f.stretch=C(r,"stretch",!1),s.constraints.push(o);break}case"transform":{const o=new J(c);o.skinRequired=l;for(let w=0;w<r.bones.length;w++){const T=r.bones[w],y=s.findBone(T);if(!y)throw new Error(`Couldn't find bone ${T} for transform constraint ${r.name}.`);o.bones.push(y)}const a=r.source,h=s.findBone(a);if(!h)throw new Error(`Couldn't find source bone ${a} for transform constraint ${r.name}.`);o.source=h,o.localSource=C(r,"localSource",!1),o.localTarget=C(r,"localTarget",!1),o.additive=C(r,"additive",!1),o.clamp=C(r,"clamp",!1);let d=!1,f=!1,u=!1,m=!1,p=!1,g=!1;const b=Object.entries(C(r,"properties",{}));for(const[w,T]of b){const y=this.fromProperty(w),v=this.propertyScale(w,e);y.offset=C(T,"offset",0)*v;const S=Object.entries(C(T,"to",{}));for(const[A,I]of S){let M=1,P;switch(A){case"rotate":{d=!0,P=new Ys;break}case"x":{f=!0,P=new Fs,M=e;break}case"y":{u=!0,P=new ks,M=e;break}case"scaleX":{m=!0,P=new Es;break}case"scaleY":{p=!0,P=new Xs;break}case"shearY":{g=!0,P=new Vs;break}default:throw new Error(`Invalid transform constraint to property: ${A}`)}P.offset=C(I,"offset",0)*M,P.max=C(I,"max",1)*M,P.scale=C(I,"scale",1)*M/v,y.to.push(P)}y.to.length>0&&o.properties.push(y)}o.offsets[J.ROTATION]=C(r,"rotation",0),o.offsets[J.X]=C(r,"x",0)*e,o.offsets[J.Y]=C(r,"y",0)*e,o.offsets[J.SCALEX]=C(r,"scaleX",0),o.offsets[J.SCALEY]=C(r,"scaleY",0),o.offsets[J.SHEARY]=C(r,"shearY",0);const x=o.setupPose;d&&(x.mixRotate=C(r,"mixRotate",1)),f&&(x.mixX=C(r,"mixX",1)),u&&(x.mixY=C(r,"mixY",x.mixX)),m&&(x.mixScaleX=C(r,"mixScaleX",1)),p&&(x.mixScaleY=C(r,"mixScaleY",x.mixScaleX)),g&&(x.mixShearY=C(r,"mixShearY",1)),s.constraints.push(o);break}case"path":{const o=new Gt(c);o.skinRequired=l;for(let f=0;f<r.bones.length;f++){const u=r.bones[f],m=s.findBone(u);if(!m)throw new Error(`Couldn't find bone ${u} for path constraint ${r.name}.`);o.bones.push(m)}const a=r.slot,h=s.findSlot(a);if(!h)throw new Error(`Couldn't find slot ${a} for path constraint ${r.name}.`);o.slot=h,o.positionMode=L.enumValue(vs,C(r,"positionMode","Percent")),o.spacingMode=L.enumValue(Ts,C(r,"spacingMode","Length")),o.rotateMode=L.enumValue(Ss,C(r,"rotateMode","Tangent")),o.offsetRotation=C(r,"rotation",0);const d=o.setupPose;d.position=C(r,"position",0),o.positionMode===0&&(d.position*=e),d.spacing=C(r,"spacing",0),(o.spacingMode===0||o.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(o);break}case"physics":{const o=new Ht(c);o.skinRequired=l;const a=r.bone,h=s.findBone(a);if(h==null)throw new Error(`Physics bone not found: ${a}`);o.bone=h,o.x=C(r,"x",0),o.y=C(r,"y",0),o.rotate=C(r,"rotate",0),o.scaleX=C(r,"scaleX",0);const d=C(r,"scaleY",null);d!=null&&(o.scaleYMode=L.enumValue(ae,d)),o.shearX=C(r,"shearX",0),o.limit=C(r,"limit",5e3)*e,o.step=1/C(r,"fps",60);const f=o.setupPose;f.inertia=C(r,"inertia",.5),f.strength=C(r,"strength",100),f.damping=C(r,"damping",.85),f.massInverse=1/C(r,"mass",1),f.wind=C(r,"wind",0),f.gravity=C(r,"gravity",0),f.mix=C(r,"mix",1),o.inertiaGlobal=C(r,"inertiaGlobal",!1),o.strengthGlobal=C(r,"strengthGlobal",!1),o.dampingGlobal=C(r,"dampingGlobal",!1),o.massGlobal=C(r,"massGlobal",!1),o.windGlobal=C(r,"windGlobal",!1),o.gravityGlobal=C(r,"gravityGlobal",!1),o.mixGlobal=C(r,"mixGlobal",!1),s.constraints.push(o);break}case"slider":{const o=new Tt(c);o.skinRequired=l,o.additive=C(r,"additive",!1),o.loop=C(r,"loop",!1),o.setupPose.mix=C(r,"mix",1);const a=r.bone;if(a){if(o.bone=s.findBone(a),!o.bone)throw new Error(`Slider bone not found: ${a}`);const h=r.property;o.property=this.fromProperty(h);const d=this.propertyScale(h,e);o.property.offset=C(r,"from",0)*d,o.offset=C(r,"to",0),o.scale=C(r,"scale",1)/d,o.max=C(r,"max",0),o.local=C(r,"local",!1)}else o.setupPose.time=C(r,"time",0);s.constraints.push(o);break}}}if(n.skins)for(let r=0;r<n.skins.length;r++){const c=n.skins[r],l=new ue(c.name);if(c.bones)for(let o=0;o<c.bones.length;o++){const a=c.bones[o],h=s.findBone(a);if(!h)throw new Error(`Couldn't find bone ${a} for skin ${c.name}.`);l.bones.push(h)}if(c.ik)for(let o=0;o<c.ik.length;o++){const a=c.ik[o],h=s.findConstraint(a,Wt);if(!h)throw new Error(`Couldn't find IK constraint ${a} for skin ${c.name}.`);l.constraints.push(h)}if(c.transform)for(let o=0;o<c.transform.length;o++){const a=c.transform[o],h=s.findConstraint(a,J);if(!h)throw new Error(`Couldn't find transform constraint ${a} for skin ${c.name}.`);l.constraints.push(h)}if(c.path)for(let o=0;o<c.path.length;o++){const a=c.path[o],h=s.findConstraint(a,Gt);if(!h)throw new Error(`Couldn't find path constraint ${a} for skin ${c.name}.`);l.constraints.push(h)}if(c.physics)for(let o=0;o<c.physics.length;o++){const a=c.physics[o],h=s.findConstraint(a,Ht);if(!h)throw new Error(`Couldn't find physics constraint ${a} for skin ${c.name}.`);l.constraints.push(h)}if(c.slider)for(let o=0;o<c.slider.length;o++){const a=c.slider[o],h=s.findConstraint(a,Tt);if(!h)throw new Error(`Couldn't find slider constraint ${a} for skin ${c.name}.`);l.constraints.push(h)}for(const o in c.attachments){const a=s.findSlot(o);if(!a)throw new Error(`Couldn't find skin slot ${o} for skin ${c.name}.`);const h=c.attachments[o];for(const d in h){const f=this.readAttachment(h[d],l,a.index,d,s);f&&l.setAttachment(a.index,d,f)}}s.skins.push(l),l.name==="default"&&(s.defaultSkin=l)}for(let r=0,c=this.linkedMeshes.length;r<c;r++){const l=this.linkedMeshes[r],o=l.skin?s.findSkin(l.skin):s.defaultSkin;if(!o)throw new Error(`Skin not found: ${l.skin}`);const a=o.getAttachment(l.sourceIndex,l.source);if(!a)throw new Error(`Source mesh not found: ${l.source}`);l.mesh.timelineAttachment=l.inheritTimelines?a:l.mesh,l.mesh.setSourceMesh(a),l.mesh.updateSequence();t:if(l.inheritTimelines&&l.slotIndex!==l.sourceIndex){const h=a.timelineSlots;for(const f of h)if(f===l.slotIndex)break t;const d=[...h];d[h.length]=l.slotIndex,a.timelineSlots=d}}if(this.linkedMeshes.length=0,n.events)for(const r in n.events){const c=n.events[r],l=new ys(r),o=l.setupPose;o.intValue=C(c,"int",0),o.floatValue=C(c,"float",0),o.stringValue=C(c,"string",""),l._audioPath=C(c,"audio",null),l.audioPath&&(o.volume=C(c,"volume",o.volume),o.balance=C(c,"balance",o.balance)),s.events.push(l)}if(n.animations)for(const r in n.animations){const c=n.animations[r];this.readAnimation(c,r,s)}if(n.constraints)for(const r in n.constraints){const c=n.constraints[r];if(c.type==="slider"){const l=s.findConstraint(c.name,Tt),o=c.animation,a=s.findAnimation(o);if(!a)throw new Error(`Slider animation not found: ${o}`);l.animation=a}}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,c=C(t,"name",n);switch(C(t,"type","region")){case"region":{const l=C(t,"path",c),o=this.readSequence(C(t,"sequence",null)),a=this.attachmentLoader.newRegionAttachment(e,n,c,l,o);if(!a)return null;a.path=l,a.x=C(t,"x",0)*r,a.y=C(t,"y",0)*r,a.scaleX=C(t,"scaleX",1),a.scaleY=C(t,"scaleY",1),a.rotation=C(t,"rotation",0),a.width=t.width*r,a.height=t.height*r;const h=C(t,"color",null);return h&&a.color.setFromString(h),a.updateSequence(),a}case"boundingbox":{const l=this.attachmentLoader.newBoundingBoxAttachment(e,n,c);if(!l)return null;this.readVertices(t,l,t.vertexCount<<1);const o=C(t,"color",null);return o&&l.color.setFromString(o),l}case"mesh":case"linkedmesh":{const l=C(t,"path",c),o=this.readSequence(C(t,"sequence",null)),a=this.attachmentLoader.newMeshAttachment(e,n,c,l,o);if(!a)return null;a.path=l;const h=C(t,"color",null);h&&a.color.setFromString(h),a.width=C(t,"width",0)*r,a.height=C(t,"height",0)*r;const d=C(t,"source",null);if(d){let u=s;const m=C(t,"slot",null);if(m){const p=i.findSlot(m);if(!p)throw new Error(`Source mesh slot not found: ${m}`);u=p.index}return this.linkedMeshes.push(new Ni(a,C(t,"skin",null),s,u,d,C(t,"timelines",!0))),a}const f=t.uvs;return this.readVertices(t,a,f.length),a.triangles=t.triangles,a.regionUVs=f,a.edges=C(t,"edges",null),a.hullLength=C(t,"hull",0)*2,a.updateSequence(),a}case"path":{const l=this.attachmentLoader.newPathAttachment(e,n,c);if(!l)return null;l.closed=C(t,"closed",!1),l.constantSpeed=C(t,"constantSpeed",!0);const o=t.vertexCount;this.readVertices(t,l,o<<1);const a=L.newArray(o/3,0);for(let d=0;d<t.lengths.length;d++)a[d]=t.lengths[d]*r;l.lengths=a;const h=C(t,"color",null);return h&&l.color.setFromString(h),l}case"point":{const l=this.attachmentLoader.newPointAttachment(e,n,c);if(!l)return null;l.x=C(t,"x",0)*r,l.y=C(t,"y",0)*r,l.rotation=C(t,"rotation",0);const o=C(t,"color",null);return o&&l.color.setFromString(o),l}case"clipping":{const l=this.attachmentLoader.newClippingAttachment(e,n,c);if(!l)return null;const o=C(t,"end",null);o&&(l.endSlot=i.findSlot(o)),l.convex=C(t,"convex",!1),l.inverse=C(t,"inverse",!1);const a=t.vertexCount;this.readVertices(t,l,a<<1);const h=C(t,"color",null);return h&&l.color.setFromString(h),l}}return null}readSequence(t){if(t==null)return new Ot(1,!1);const e=new Ot(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 l=L.toFloatArray(i);if(n!==1)for(let o=0,a=i.length;o<a;o++)l[o]*=n;e.vertices=l;return}const r=[],c=[];for(let l=0,o=i.length;l<o;){const a=i[l++];c.push(a);for(let h=l+a*4;l<h;l+=4)c.push(i[l]),r.push(i[l+1]*n),r.push(i[l+2]*n),r.push(i[l+3])}e.bones=c,e.vertices=L.toFloatArray(r)}readAnimation(t,e,s){const n=this.scale,i=[];if(t.slots)for(const o in t.slots){const a=t.slots[o],h=s.findSlot(o);if(!h)throw new Error(`Slot not found: ${o}`);const d=h.index;for(const f in a){const u=a[f];if(!u)continue;const m=u.length;switch(f){case"attachment":{const p=new Ft(m,d);for(let g=0;g<m;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 ze(m,m<<2,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.color);for(let w=0,T=0;;w++){p.setFrame(w,b,x.r,x.g,x.b,x.a);const y=u[w+1];if(!y){p.shrink(T);break}const v=C(y,"time",0),S=z.fromString(y.color),A=g.curve;A&&(T=H(A,p,T,w,0,b,v,x.r,S.r,1),T=H(A,p,T,w,1,b,v,x.g,S.g,1),T=H(A,p,T,w,2,b,v,x.b,S.b,1),T=H(A,p,T,w,3,b,v,x.a,S.a,1)),b=v,x=S,g=y}i.push(p);break}case"rgb":{const p=new We(m,m*3,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.color);for(let w=0,T=0;;w++){p.setFrame(w,b,x.r,x.g,x.b);const y=u[w+1];if(!y){p.shrink(T);break}const v=C(y,"time",0),S=z.fromString(y.color),A=g.curve;A&&(T=H(A,p,T,w,0,b,v,x.r,S.r,1),T=H(A,p,T,w,1,b,v,x.g,S.g,1),T=H(A,p,T,w,2,b,v,x.b,S.b,1)),b=v,x=S,g=y}i.push(p);break}case"alpha":{lt(i,u,new Ge(m,m,d),0,1);break}case"rgba2":{const p=new He(m,m*7,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let T=0,y=0;;T++){p.setFrame(T,b,x.r,x.g,x.b,x.a,w.r,w.g,w.b);const v=u[T+1];if(!v){p.shrink(y);break}const S=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=H(M,p,y,T,0,b,S,x.r,A.r,1),y=H(M,p,y,T,1,b,S,x.g,A.g,1),y=H(M,p,y,T,2,b,S,x.b,A.b,1),y=H(M,p,y,T,3,b,S,x.a,A.a,1),y=H(M,p,y,T,4,b,S,w.r,I.r,1),y=H(M,p,y,T,5,b,S,w.g,I.g,1),y=H(M,p,y,T,6,b,S,w.b,I.b,1)),b=S,x=A,w=I,g=v}i.push(p);break}case"rgb2":{const p=new je(m,m*6,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.light),w=z.fromString(g.dark);for(let T=0,y=0;;T++){p.setFrame(T,b,x.r,x.g,x.b,w.r,w.g,w.b);const v=u[T+1];if(!v){p.shrink(y);break}const S=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=H(M,p,y,T,0,b,S,x.r,A.r,1),y=H(M,p,y,T,1,b,S,x.g,A.g,1),y=H(M,p,y,T,2,b,S,x.b,A.b,1),y=H(M,p,y,T,3,b,S,w.r,I.r,1),y=H(M,p,y,T,4,b,S,w.g,I.g,1),y=H(M,p,y,T,5,b,S,w.b,I.b,1)),b=S,x=A,w=I,g=v}i.push(p);break}default:throw new Error(`Invalid timeline type for a slot: ${u.name} (${a.name})`)}}}if(t.bones)for(const o in t.bones){const a=t.bones[o],h=s.findBone(o);if(!h)throw new Error(`Bone not found: ${o}`);const d=h.index;for(const f in a){const u=a[f],m=u.length;if(m!==0)switch(f){case"rotate":lt(i,u,new Dt(m,m,d),0,1);break;case"translate":Rs(i,u,new Re(m,m<<1,d),"x","y",0,n);break;case"translatex":lt(i,u,new Le(m,m,d),0,n);break;case"translatey":lt(i,u,new Be(m,m,d),0,n);break;case"scale":Rs(i,u,new Oe(m,m<<1,d),"x","y",1,1);break;case"scalex":lt(i,u,new Ne(m,m,d),1,1);break;case"scaley":lt(i,u,new De(m,m,d),1,1);break;case"shear":Rs(i,u,new Ue(m,m<<1,d),"x","y",0,1);break;case"shearx":lt(i,u,new qe(m,m,d),0,1);break;case"sheary":lt(i,u,new $e(m,m,d),0,1);break;case"inherit":{const p=new _e(m,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} (${a.name})`)}}}if(t.ik)for(const o in t.ik){const a=t.ik[o];let h=a[0];if(!h)continue;const d=s.findConstraint(o,Wt);if(!d)throw new Error(`IK Constraint not found: ${o}`);const f=new Qe(a.length,a.length<<1,s.constraints.indexOf(d));let u=C(h,"time",0),m=C(h,"mix",1),p=C(h,"softness",0)*n;for(let g=0,b=0;;g++){f.setFrame(g,u,m,p,C(h,"bendPositive",!0)?1:-1,C(h,"compress",!1),C(h,"stretch",!1));const x=a[g+1];if(!x){f.shrink(b);break}const w=C(x,"time",0),T=C(x,"mix",1),y=C(x,"softness",0)*n,v=h.curve;v&&(b=H(v,f,b,g,0,u,w,m,T,1),b=H(v,f,b,g,1,u,w,p,y,n)),u=w,m=T,p=y,h=x}i.push(f)}if(t.transform)for(const o in t.transform){const a=t.transform[o];let h=a[0];if(!h)continue;const d=s.findConstraint(o,J);if(!d)throw new Error(`Transform constraint not found: ${o}`);const f=new Ze(a.length,a.length*6,s.constraints.indexOf(d));let u=C(h,"time",0),m=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 T=0,y=0;;T++){f.setFrame(T,u,m,p,g,b,x,w);const v=a[T+1];if(!v){f.shrink(y);break}const S=C(v,"time",0),A=C(v,"mixRotate",1),I=C(v,"mixX",1),M=C(v,"mixY",I),P=C(v,"mixScaleX",1),k=C(v,"mixScaleY",1),E=C(v,"mixShearY",1),X=h.curve;X&&(y=H(X,f,y,T,0,u,S,m,A,1),y=H(X,f,y,T,1,u,S,p,I,1),y=H(X,f,y,T,2,u,S,g,M,1),y=H(X,f,y,T,3,u,S,b,P,1),y=H(X,f,y,T,4,u,S,x,k,1),y=H(X,f,y,T,5,u,S,w,E,1)),u=S,m=A,p=I,g=M,b=P,x=k,w=E,h=v}i.push(f)}if(t.path)for(const o in t.path){const a=t.path[o],h=s.findConstraint(o,Gt);if(!h)throw new Error(`Path constraint not found: ${o}`);const d=s.constraints.indexOf(h);for(const f in a){const u=a[f];let m=u[0];if(!m)continue;const p=u.length;switch(f){case"position":{const g=new ts(p,p,d);lt(i,u,g,0,h.positionMode===0?n:1);break}case"spacing":{const g=new es(p,p,d);lt(i,u,g,0,h.spacingMode===0||h.spacingMode===1?n:1);break}case"mix":{const g=new ss(p,p*3,d);let b=C(m,"time",0),x=C(m,"mixRotate",1),w=C(m,"mixX",1),T=C(m,"mixY",w);for(let y=0,v=0;;y++){g.setFrame(y,b,x,w,T);const S=u[y+1];if(!S){g.shrink(v);break}const A=C(S,"time",0),I=C(S,"mixRotate",1),M=C(S,"mixX",1),P=C(S,"mixY",M),k=m.curve;k&&(v=H(k,g,v,y,0,b,A,x,I,1),v=H(k,g,v,y,1,b,A,w,M,1),v=H(k,g,v,y,2,b,A,T,P,1)),b=A,x=I,w=M,T=P,m=S}i.push(g);break}}}}if(t.physics)for(const o in t.physics){const a=t.physics[o];let h=-1;if(o.length>0){const d=s.findConstraint(o,Ht);if(!d)throw new Error(`Physics constraint not found: ${o}`);h=s.constraints.indexOf(d)}for(const d in a){const f=a[d];let u=f[0];if(!u)continue;const m=f.length;let p,g=0;if(d==="reset"){const b=new hs(m,h);for(let x=0;u!=null;u=f[x+1],x++)b.setFrame(x,C(u,"time",0));i.push(b);continue}switch(d){case"inertia":p=new ns(m,m,h);break;case"strength":p=new is(m,m,h);break;case"damping":p=new rs(m,m,h);break;case"mass":p=new as(m,m,h);break;case"wind":p=new os(m,m,h);break;case"gravity":p=new ls(m,m,h);break;case"mix":{g=1,p=new cs(m,m,h);break}default:continue}lt(i,f,p,g,1)}}if(t.slider)for(const o in t.slider){const a=t.slider[o],h=s.findConstraint(o,Tt);if(!h)throw new Error(`Slider not found: ${o}`);const d=s.constraints.indexOf(h);for(const f in a){const u=a[f];if(!u[0])continue;const p=u.length;switch(f){case"time":lt(i,u,new ds(p,p,d),1,1);break;case"mix":lt(i,u,new fs(p,p,d),1,1);break}}}if(t.attachments)for(const o in t.attachments){const a=t.attachments[o],h=s.findSkin(o);if(!h)throw new Error(`Skin not found: ${o}`);for(const d in a){const f=a[d],u=s.findSlot(d);if(!u)throw new Error(`Attachment slot not found: ${d}`);const m=u.index;for(const p in f){const g=f[p],b=h.getAttachment(m,p);if(!b)throw new Error(`Timeline attachment not found: ${p}`);for(const x in g){const w=g[x];let T=w[0];if(T){if(x==="deform"){const y=b.bones,v=b.vertices,S=y?v.length/3*2:v.length,A=new Je(w.length,w.length,m,b);let I=C(T,"time",0);for(let M=0,P=0;;M++){let k;const E=C(T,"vertices",null);if(!E)k=y?L.newFloatArray(S):v;else{k=L.newFloatArray(S);const $=C(T,"offset",0);if(L.arrayCopy(E,0,k,$,E.length),n!==1)for(let O=$,F=O+E.length;O<F;O++)k[O]*=n;if(!y)for(let O=0;O<S;O++)k[O]+=v[O]}A.setFrame(M,I,k);const X=w[M+1];if(!X){A.shrink(P);break}const V=C(X,"time",0),N=T.curve;N&&(P=H(N,A,P,M,0,I,V,0,1,1)),I=V,T=X}i.push(A)}else if(x==="sequence"){const y=new Ke(w.length,m,b);let v=0;for(let S=0;S<w.length;S++){const A=C(T,"delay",v),I=C(T,"time",0),M=Xe[C(T,"mode","hold")],P=C(T,"index",0);y.setFrame(S,I,M,P,A),v=A,T=w[S+1]}i.push(y)}}}}}}if(t.drawOrder){const o=new At(t.drawOrder.length),a=s.slots.length;let h=0;for(const d of t.drawOrder)o.setFrame(h++,C(d,"time",0),pn(s,d,a,null));i.push(o)}if(t.drawOrderFolder)for(const o of t.drawOrderFolder){const a=C(o,"slots",[]),h=new Array(a.length);let d=0;for(const p of a){const g=s.findSlot(p);if(!g)throw new Error(`Draw order folder slot not found: ${p}`);h[d++]=g.index}const f=C(o,"keys",[]),u=new qt(f.length,h,s.slots.length);let m=0;for(const p of f)u.setFrame(m++,C(p,"time",0),pn(s,p,h.length,h));i.push(u)}if(t.events){const o=new Zt(t.events.length);let a=0;for(let h=0;h<t.events.length;h++,a++){const d=t.events[h],f=s.findEvent(d.name);if(!f)throw new Error(`Event not found: ${d.name}`);const u=f.setupPose,m=new oe(L.toSinglePrecision(C(d,"time",0)),f);m.intValue=C(d,"int",u.intValue),m.floatValue=C(d,"float",u.floatValue),m.stringValue=C(d,"string",u.stringValue),m.data.audioPath&&(m.volume=C(d,"volume",u.volume),m.balance=C(d,"balance",u.volume)),o.setFrame(a,m)}i.push(o)}let r=0;for(let o=0,a=i.length;o<a;o++)r=Math.max(r,i[o].getDuration());const c=new Kt(e,i,r),l=C(t,"color",null);l!==null&&c.color.setFromString(l),s.animations.push(c)}},Ni=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 lt(t,e,s,n,i){let r=e[0],c=r.time??0,l=(r.value??n)*i,o=0;for(let a=0;;a++){s.setFrame(a,c,l);const h=e[a+1];if(!h){s.shrink(o),t.push(s);return}const d=h.time??0,f=(h.value??n)*i;r.curve&&(o=H(r.curve,s,o,a,0,c,d,l,f,i)),c=d,l=f,r=h}}function Rs(t,e,s,n,i,r,c){let l=e[0],o=l.time??0,a=(l[n]??r)*c,h=(l[i]??r)*c,d=0;for(let f=0;;f++){s.setFrame(f,o,a,h);const u=e[f+1];if(!u){s.shrink(d),t.push(s);return}const m=u.time??0,p=(u[n]??r)*c,g=(u[i]??r)*c,b=l.curve;b&&(d=H(b,s,d,f,0,o,m,a,p,c),d=H(b,s,d,f,1,o,m,h,g,c)),o=m,a=p,h=g,l=u}}function pn(t,e,s,n){const i=e.offsets;if(!i)return null;const r=new Array(s).fill(-1),c=new Array(s-i.length);let l=0,o=0;for(const a of i){const h=t.findSlot(a.slot);if(h==null)throw new Error(`Draw order slot not found: ${a.slot}`);let d=0;if(!n)d=h.index;else{d=-1;for(let f=0;f<s;f++)if(n[f]===h.index){d=f;break}if(d===-1)throw new Error(`Slot not in folder: ${a.slot}`)}for(;l!==d;)c[o++]=l++;r[l+a.offset]=l++}for(;l<s;)c[o++]=l++;for(let a=s-1;a>=0;a--)r[a]===-1&&(r[a]=c[--o]);return r}function H(t,e,s,n,i,r,c,l,o,a){if(t==="stepped")return e.setStepped(n),s;const h=i<<2,d=t[h],f=t[h+1]*a,u=t[h+2],m=t[h+3]*a;return e.setBezier(s,n,i,r,l,d,f,u,m,c,o),s+1}function C(t,e,s){return t[e]!==void 0?t[e]:s}var Di=class{commandPool=new Ui;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new gn;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 c=0;c<t.slots.length;c++){const l=r[c],o=l.appliedPose.attachment;if(!o){i.clipEnd(l);continue}const a=l.appliedPose,h=a.color;if((h.a===0||!l.bone.active)&&!(o instanceof zt)){i.clipEnd(l);continue}let f,u,m,p,g,b,x;if(o instanceof j){if(b=o.color,b.a===0){i.clipEnd(l);continue}const S=o.sequence,A=S.resolveIndex(a);o.computeWorldVertices(l,o.getOffsets(a),this.worldVertices,0,n),f=this.worldVertices,u=4,m=S.getUVs(A),p=this.quadIndices,g=6,x=S.regions[A]?.texture}else if(o instanceof wt){if(b=o.color,b.a===0){i.clipEnd(l);continue}this.worldVertices.length<o.worldVerticesLength&&(this.worldVertices=new Float32Array(o.worldVerticesLength)),o.computeWorldVertices(t,l,0,o.worldVerticesLength,this.worldVertices,0,n),f=this.worldVertices,u=o.worldVerticesLength>>1;const S=o.sequence,A=S.resolveIndex(a);m=S.getUVs(A),p=o.triangles,g=p.length,x=S.regions[A]?.texture}else if(o instanceof zt){i.clipStart(t,l,o);continue}else continue;const w=t.color;let T,y;if(e){let S;if(s){S=Math.floor(s[3]*w.a*h.a*b.a*255);const A=Math.floor(S*s[0]*w.r*h.r*b.r),I=Math.floor(S*s[1]*w.g*h.g*b.g),M=Math.floor(S*s[2]*w.b*h.b*b.b);T=S<<24|A<<16|I<<8|M}else{S=Math.floor(w.a*h.a*b.a*255);const A=Math.floor(S*w.r*h.r*b.r),I=Math.floor(S*w.g*h.g*b.g),M=Math.floor(S*w.b*h.b*b.b);T=S<<24|A<<16|I<<8|M}if(y=4278190080,a.darkColor){const{r:A,g:I,b:M}=a.darkColor;y=4278190080|Math.floor(A*S)<<16|Math.floor(I*S)<<8|Math.floor(M*S)}}else{if(s){const S=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);T=S<<24|A<<16|I<<8|M}else{const S=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);T=S<<24|A<<16|I<<8|M}if(y=0,a.darkColor){const{r:S,g:A,b:I}=a.darkColor;y=Math.floor(S*255)<<16|Math.floor(A*255)<<8|Math.floor(I*255)}}i.isClipping()&&(i.clipTrianglesUnpacked(f,0,p,g,m,n),f=i.clippedVerticesTyped,u=i.clippedVerticesLength/n,m=i.clippedUVsTyped,p=i.clippedTrianglesTyped,g=i.clippedTrianglesLength);const v=this.commandPool.getCommand(u,g,n);v.blendMode=l.data.blendMode,v.texture=x,v.positions.set(f.subarray(0,u*n)),v.uvs.set(m.subarray(0,u<<1));for(let S=0;S<u;S++)v.colors[S]=T,v.darkColors[S]=y;p instanceof Uint16Array?v.indices.set(p.subarray(0,g)):v.indices.set(p.slice(0,g)),this.renderCommands.push(v),i.clipEnd(l)}return i.clipEnd(),this.batchCommands(n)}batchSubCommands(t,e,s,n,i,r){const c=t[e],l=this.commandPool.getCommand(n,i,r);l.blendMode=c.blendMode,l.texture=c.texture;let o=0,a=0,h=0,d=0,f=0;for(let u=e;u<=s;u++){const m=t[u];l.positions.set(m.positions,o),o+=m.numVertices*r,l.uvs.set(m.uvs,a),a+=m.numVertices<<1,l.colors.set(m.colors,h),l.darkColors.set(m.darkColors,h),h+=m.numVertices;for(let p=0;p<m.numIndices;p++)l.indices[d+p]=m.indices[p]+f;d+=m.numIndices,f+=m.numVertices}return l}batchCommands(t){if(this.renderCommands.length===0)return;let e,s,n=this.renderCommands[0],i=0,r=1,c=n.numVertices,l=n.numIndices;for(;r<=this.renderCommands.length;){const o=r<this.renderCommands.length?this.renderCommands[r]:null;if(o&&o.numVertices===0&&o.numIndices===0){r++;continue}if(o!==null&&o.texture===n.texture&&o.blendMode===n.blendMode&&o.colors[0]===n.colors[0]&&o.darkColors[0]===n.darkColors[0]&&l+o.numIndices<65535)c+=o.numVertices,l+=o.numIndices;else{const h=this.batchSubCommands(this.renderCommands,i,r-1,c,l,t);if(s?(s.next=h,s=h):e=s=h,r===this.renderCommands.length)break;n=this.renderCommands[r],i=r,c=n.numVertices,l=n.numIndices}r++}return e}},Ui=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),c=new Uint32Array(t),l=new Uint32Array(t),o=new Uint16Array(e);n={positions:i,uvs:r,colors:c,darkColors:l,indices:o,_positions:i,_uvs:r,_colors:c,_darkColors:l,_indices:o,numVertices:t,numIndices:e,blendMode:0,texture:null}}return this.inUse.push(n),n}reset(){this.pool.push(...this.inUse),this.inUse.length=0}},bn=class extends Ye{constructor(t){super(t)}setFilters(t,e){}setWraps(t,e){}dispose(){}},qi=class extends Zs{constructor(t="",e=new gs){super(s=>new bn(s),t,e)}},$i=L.newFloatArray(8),_i=class Ie{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 c=0,l=r.length;c<l;c++){const o=r[c],a=o.bone;if(!a.active)continue;const h=o.appliedPose,d=h.attachment;if(!(d instanceof j))continue;const f=d.sequence,u=f.resolveIndex(h);d.computeWorldVertices(o,d.getOffsets(h),$i,0,2);const m=f.regions[u],p=m.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=a.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 T=d.width/m.originalWidth;s.scale(T*d.scaleX,T*d.scaleY);let y=m.width,v=m.height;if(s.translate(y/2,v/2),m.degrees===90){const S=y;y=v,v=S,s.rotate(-Math.PI/2)}s.scale(1,-1),s.translate(-y/2,-v/2),s.globalAlpha=n.a,s.drawImage(p,p.width*m.u,p.height*m.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 c=null,l=this.vertices,o=null;for(let a=0,h=r.length;a<h;a++){const d=r[a],f=d.appliedPose,u=f.attachment;let m;if(u instanceof j){const p=u.sequence,g=p.resolveIndex(f),b=p.getUVs(g),x=u.getOffsets(f);l=this.computeRegionVertices(d,u,x,b,!1),o=Ie.QUAD_TRIANGLES,m=(p.regions[g]?.texture).getImage()}else if(u instanceof wt){const p=u.sequence,g=p.resolveIndex(f),b=p.getUVs(g);l=this.computeMeshVertices(d,u,b,!1),o=u.triangles,m=(p.regions[g]?.texture).getImage()}else continue;if(m){d.data.blendMode!==c&&(c=d.data.blendMode);const p=f.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<o.length;b+=3){const x=o[b]*8,w=o[b+1]*8,T=o[b+2]*8,y=l[x],v=l[x+1],S=l[x+6],A=l[x+7],I=l[w],M=l[w+1],P=l[w+6],k=l[w+7],E=l[T],X=l[T+1],V=l[T+6],N=l[T+7];this.drawTriangle(m,y,v,S,A,I,M,P,k,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,c,l,o,a,h,d,f,u){const m=this.ctx,p=e.width-1,g=e.height-1;i*=p,r*=g,o*=p,a*=g,f*=p,u*=g,m.beginPath(),m.moveTo(s,n),m.lineTo(c,l),m.lineTo(h,d),m.closePath(),c-=s,l-=n,h-=s,d-=n,o-=i,a-=r,f-=i,u-=r;let b=o*u-f*a;if(b===0)return;b=1/b;const x=(u*c-a*h)*b,w=(u*l-a*d)*b,T=(o*h-f*c)*b,y=(o*d-f*l)*b,v=s-x*i-T*r,S=n-w*i-y*r;m.save(),m.transform(x,w,T,y,v,S),m.clip(),m.drawImage(e,0,0),m.restore()}computeRegionVertices(e,s,n,i,r){const c=e.skeleton.color,l=e.appliedPose.color,o=s.color,a=c.a*l.a*o.a,h=r?a:1,d=this.tempColor;d.set(c.r*l.r*o.r*h,c.g*l.g*o.g*h,c.b*l.b*o.b*h,a),s.computeWorldVertices(e,n,this.vertices,0,Ie.VERTEX_SIZE);const f=this.vertices;return f[j.C1R]=d.r,f[j.C1G]=d.g,f[j.C1B]=d.b,f[j.C1A]=d.a,f[j.U1]=i[0],f[j.V1]=i[1],f[j.C2R]=d.r,f[j.C2G]=d.g,f[j.C2B]=d.b,f[j.C2A]=d.a,f[j.U2]=i[2],f[j.V2]=i[3],f[j.C3R]=d.r,f[j.C3G]=d.g,f[j.C3B]=d.b,f[j.C3A]=d.a,f[j.U3]=i[4],f[j.V3]=i[5],f[j.C4R]=d.r,f[j.C4G]=d.g,f[j.C4B]=d.b,f[j.C4A]=d.a,f[j.U4]=i[6],f[j.V4]=i[7],f}computeMeshVertices(e,s,n,i){const r=e.skeleton,c=r.color,l=e.appliedPose.color,o=s.color,a=c.a*l.a*o.a,h=i?a:1,d=this.tempColor;d.set(c.r*l.r*o.r*h,c.g*l.g*o.g*h,c.b*l.b*o.b*h,a);const f=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,Ie.VERTEX_SIZE);for(let m=0,p=0,g=2;m<f;m++)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}};return On(Ds)})();
1
+ "use strict";var spine=(()=>{var Ie=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Bn=Object.getOwnPropertyNames,On=Object.prototype.hasOwnProperty,Nn=(t,e)=>{for(var s in e)Ie(t,s,{get:e[s],enumerable:!0})},Dn=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Bn(e))!On.call(t,i)&&i!==s&&Ie(t,i,{get:()=>e[i],enumerable:!(n=Ln(e,i))||n.enumerable});return t},Un=t=>Dn(Ie({},"__esModule",{value:!0}),t),qs={};Nn(qs,{ATTACH_RETAIN:()=>gs,ATTACH_SETUP:()=>ms,AlphaTimeline:()=>ze,Animation:()=>Kt,AnimationState:()=>jn,AnimationStateAdapter:()=>Jn,AnimationStateData:()=>Kn,AssetCache:()=>rn,AssetManager:()=>zi,AssetManagerBase:()=>nn,AtlasAttachmentLoader:()=>Qn,Attachment:()=>ke,AttachmentTimeline:()=>kt,BinaryInput:()=>gn,BlendMode:()=>Ps,Bone:()=>ie,BoneData:()=>xs,BonePose:()=>ne,BoneTimeline1:()=>vt,BoneTimeline2:()=>Qt,BoundingBoxAttachment:()=>bs,CURRENT:()=>ds,CanvasTexture:()=>vn,ClippingAttachment:()=>_t,Color:()=>z,Constraint:()=>Et,ConstraintData:()=>Xt,ConstraintTimeline1:()=>Ft,CurveTimeline:()=>yt,CurveTimeline1:()=>Nt,DebugUtils:()=>_n,DeformTimeline:()=>He,Downloader:()=>ps,DrawOrder:()=>an,DrawOrderFolderTimeline:()=>qt,DrawOrderTimeline:()=>At,Event:()=>oe,EventData:()=>vs,EventQueue:()=>tn,EventTimeline:()=>Zt,EventType:()=>en,FIRST:()=>fs,FakeTexture:()=>Gn,FromProperty:()=>It,FromRotate:()=>me,FromScaleX:()=>be,FromScaleY:()=>xe,FromShearY:()=>we,FromX:()=>ge,FromY:()=>pe,HOLD:()=>$t,IkConstraint:()=>cn,IkConstraintData:()=>zt,IkConstraintPose:()=>ae,IkConstraintTimeline:()=>Je,Inherit:()=>se,InheritTimeline:()=>qe,IntSet:()=>qn,Interpolation:()=>Lt,MODE:()=>us,MathUtils:()=>R,MeshAttachment:()=>wt,MixFrom:()=>Hs,PathAttachment:()=>te,PathConstraint:()=>ln,PathConstraintData:()=>Wt,PathConstraintMixTimeline:()=>ts,PathConstraintPose:()=>ce,PathConstraintPositionTimeline:()=>Qe,PathConstraintSpacingTimeline:()=>Ze,Physics:()=>hn,PhysicsConstraint:()=>Is,PhysicsConstraintDampingTimeline:()=>ns,PhysicsConstraintData:()=>Gt,PhysicsConstraintGravityTimeline:()=>os,PhysicsConstraintInertiaTimeline:()=>es,PhysicsConstraintMassTimeline:()=>is,PhysicsConstraintMixTimeline:()=>as,PhysicsConstraintPose:()=>le,PhysicsConstraintResetTimeline:()=>cs,PhysicsConstraintStrengthTimeline:()=>ss,PhysicsConstraintTimeline:()=>pt,PhysicsConstraintWindTimeline:()=>rs,PointAttachment:()=>on,Pool:()=>Bt,Posed:()=>ws,PosedActive:()=>ys,PosedData:()=>ee,PositionMode:()=>Ts,Pow:()=>_s,PowOut:()=>$n,Property:()=>js,RGB2Timeline:()=>Ge,RGBA2Timeline:()=>We,RGBATimeline:()=>$e,RGBTimeline:()=>_e,RegionAttachment:()=>j,RotateMode:()=>As,RotateTimeline:()=>Dt,SETUP:()=>sn,ScaleTimeline:()=>Le,ScaleXTimeline:()=>Be,ScaleYMode:()=>re,ScaleYTimeline:()=>Oe,Sequence:()=>Ot,SequenceMode:()=>Fe,SequenceModeValues:()=>Ee,SequenceTimeline:()=>je,ShearTimeline:()=>Ne,ShearXTimeline:()=>De,ShearYTimeline:()=>Ue,Skeleton:()=>fn,SkeletonBinary:()=>Zn,SkeletonBounds:()=>Di,SkeletonClipping:()=>wn,SkeletonData:()=>Cs,SkeletonJson:()=>Ui,SkeletonRenderer:()=>Gi,SkeletonRendererCore:()=>$i,Skin:()=>fe,SkinEntry:()=>Ms,Slider:()=>un,SliderData:()=>Tt,SliderMixTimeline:()=>hs,SliderPose:()=>de,SliderTimeline:()=>ls,Slot:()=>dn,SlotCurveTimeline:()=>Ut,SlotData:()=>Ys,SlotPose:()=>he,SpacingMode:()=>Ss,StringSet:()=>$s,Texture:()=>Me,TextureAtlas:()=>Ye,TextureAtlasPage:()=>Gs,TextureAtlasRegion:()=>Pe,TextureFilter:()=>Jt,TextureRegion:()=>Ws,TextureWrap:()=>zs,TimeKeeper:()=>zn,Timeline:()=>Z,ToProperty:()=>Ct,ToRotate:()=>ks,ToScaleX:()=>Xs,ToScaleY:()=>Vs,ToShearY:()=>Rs,ToX:()=>Fs,ToY:()=>Es,TrackEntry:()=>Zs,TransformConstraint:()=>mn,TransformConstraintData:()=>J,TransformConstraintPose:()=>ue,TransformConstraintTimeline:()=>Ke,TranslateTimeline:()=>Xe,TranslateXTimeline:()=>Ve,TranslateYTimeline:()=>Re,Triangulator:()=>xn,Utils:()=>L,Vector2:()=>Ce,VertexAttachment:()=>xt,WindowedMean:()=>Wn,isBoneTimeline:()=>Ks,isConstraintTimeline:()=>Qs,isSlotTimeline:()=>Js});var qn=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}},$s=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}},Lt=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 Lt{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}},$n=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)]}},_n=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}`)}}},Bt=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}},Ce=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}},zn=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)}},Wn=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}},Me=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||{}),zs=(t=>(t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat",t))(zs||{}),Ws=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},Gn=class extends Me{setFilters(t,e){}setWraps(t,e){}dispose(){}},Ye=class{pages=[];regions=[];constructor(t){const e=new Hn(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 Pe(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 Gs(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()}},Hn=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}}},Gs=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}},Pe=class extends Ws{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 Tn{static empty=[];name;timelineAttachment;timelineSlots=Tn.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 Sn extends ke{static nextID=0;id=Sn.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,T=f.d;for(let y=n,v=a;v<i;y+=2,v+=c){const S=o[y],A=o[y+1];r[v]=S*b+A*x+p,r[v+1]=S*w+A*T+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,T=o[p],y=o[p+1],v=o[p+2];g+=(T*w.a+y*w.b+w.worldX)*v,b+=(T*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,T=h[d++];for(T+=d;d<T;d++,g+=3,b+=2){const y=u[h[d]].appliedPose,v=o[g]+f[b],S=o[g+1]+f[b+1],A=o[g+2];x+=(v*y.a+S*y.b+y.worldX)*A,w+=(v*y.c+S*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 Bs 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 Bs(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 Bs(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 Pe){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 An 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 An(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),T=u*x+s,y=u*w,v=f*x+n,S=f*w,A=p*x+s,I=p*w,M=g*x+n,Y=g*w;o[0]=T-S,o[1]=v+y,o[2]=T-Y,o[3]=M+y,o[4]=A-Y,o[5]=M+I,o[6]=A-S,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},Ot=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||{}),Ee=[0,1,2,3,4,5,6],Kt=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 $s,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),Ks(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)}},Hs=(t=>(t[t.current=0]="current",t[t.setup=1]="setup",t[t.first=2]="first",t))(Hs||{}),js=(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))(js||{}),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 Js(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,T=(a-i)*.3+f+g*.16666667,y=n+w,v=i+T;for(let S=m+18;m<S;m+=2)d[m]=y,d[m+1]=v,w+=b,T+=x,b+=p,x+=g,y+=w,v+=T}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)}},Nt=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 Ks(t){return typeof t=="object"&&t!==null&&typeof t.boneIndex=="number"}var vt=class extends Nt{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)}},Qt=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)}},Xe=class extends Qt{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)}},Ve=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)}},Re=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)}},Le=class extends Qt{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)}}},Be=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)}},Oe=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)}},Ne=class extends Qt{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)}},De=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)}},qe=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]}}},Ut=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 Ut{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+18*2-2),d=this.getBezierValue(s,m,4,u+18*3-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)}},_e=class extends Ut{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+18*2-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}},ze=class extends Nt{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}},We=class extends Ut{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,T=x.darkColor;switch(i){case 1:{a.setFromColor(w),c.r=T.r,c.g=T.g,c.b=T.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+=(T.r-c.r)*n,c.g+=(T.g-c.g)*n,c.b+=(T.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+18*2-2),p=this.getBezierValue(s,g,4,b+18*3-2),l=this.getBezierValue(s,g,5,b+18*4-2),o=this.getBezierValue(s,g,6,b+18*5-2),h=this.getBezierValue(s,g,7,b+18*6-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}},Ge=class extends Ut{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+18*2-2),d=this.getBezierValue(s,p,4,g+18*3-2),m=this.getBezierValue(s,p,5,g+18*4-2),u=this.getBezierValue(s,p,6,g+18*5-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,T=a*.3+f+g*.16666667,y=n+w,v=T;for(let S=m+18;m<S;m+=2)d[m]=y,d[m+1]=v,w+=b,T+=x,b+=p,x+=g,y+=w,v+=T}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}}},je=class St 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 St.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(e,s,n,i,r){const a=this.frames;e*=St.ENTRIES,a[e]=s,a[e+St.MODE]=n|i<<4,a[e+St.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,St.ENTRIES),f=m[u],p=m[u+St.MODE],g=m[u+St.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=Ee[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}},Zt=class In extends Z{static propertyIds=["13"];events;constructor(e){super(e,...In.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 Os extends Z{static propertyID="14";static propertyIds=[Os.propertyID];drawOrders;constructor(e){super(e,...Os.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 Ns extends Z{static propertyID="15";slots;inFolder;drawOrders;constructor(e,s,n){super(e,...Ns.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]=`${Ns.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 Qs(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+18*2-2),p=this.getBezierValue(s,x,4,w+18*3-2),g=this.getBezierValue(s,x,5,w+18*4-2),b=this.getBezierValue(s,x,6,w+18*5-2)}const T=r===1?o.data.setupPose:h;a?(h.mixRotate=T.mixRotate+m*i,h.mixX=T.mixX+u*i,h.mixY=T.mixY+f*i,h.mixScaleX=T.mixScaleX+p*i,h.mixScaleY=T.mixScaleY+g*i,h.mixShearY=T.mixShearY+b*i):(h.mixRotate=T.mixRotate+(m-T.mixRotate)*i,h.mixX=T.mixX+(u-T.mixX)*i,h.mixY=T.mixY+(f-T.mixY)*i,h.mixScaleX=T.mixScaleX+(p-T.mixScaleX)*i,h.mixScaleY=T.mixScaleY+(g-T.mixScaleY)*i,h.mixShearY=T.mixShearY+(b-T.mixShearY)*i)}},Ft=class extends Nt{constraintIndex;constructor(t,e,s,n){super(t,e,`${n}|${s}`),this.constraintIndex=s}},Qe=class extends Ft{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)}}},Ze=class extends Ft{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)}}},ts=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+18*2-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)}},pt=class extends Ft{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)))}}}},es=class extends pt{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}},ss=class extends pt{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}},ns=class extends pt{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}},is=class extends pt{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}},rs=class extends pt{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}},os=class extends pt{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}},as=class extends pt{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}},cs=class Cn extends Z{static propertyIds=["28"];constraintIndex;constructor(e,s){super(e,...Cn.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)}},ls=class extends Ft{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)}}},hs=class extends Ft{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)}}},jn=class Ds{static emptyAnimation=new Kt("<empty>",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new tn(this);propertyIds=new Map;animationsChanged=!1;trackEntryPool=new Bt(()=>new Zs);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,T=w||o.shortestRotation,y=!T&&o.timelinesRotation.length!==g<<1;y&&(o.timelinesRotation.length=g<<1);for(let v=0;v<g;v++){const S=p[v],A=b[v]&us;!T&&S instanceof Dt?this.applyRotateTimeline(S,e,u,h,A,o.timelinesRotation,v<<1,y):S instanceof kt?this.applyAttachmentTimeline(S,e,u,A,x):(L.webkit602BugfixHelper(h),S.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+ms,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 T=n.animationLast,y=n.getAnimationTime(),v=y,S=null;n.reverse?v=n.animation.duration-v:r<n.eventThreshold&&(S=this.events),n.totalAlpha=0;for(let A=0;A<d;A++){const I=h[A],M=m[A],Y=M&us;let F=0;if((M&$t)!==0){const E=u[A];F=E==null?o:o*(1-E.mix())}else{if(!p&&I instanceof At&&Y===0)continue;F=l}if(n.totalAlpha+=F,!b&&I instanceof Dt)this.applyRotateTimeline(I,s,v,F,Y,w,A<<1,x);else if(I instanceof kt)this.applyAttachmentTimeline(I,s,v,Y,f&&F>=n.alphaAttachmentThreshold);else{const E=!p||!(I instanceof At)||Y===0;I.apply(s,T,v,S,F,Y,g,E,!1)}}return n.reverse&&r<n.eventThreshold&&this.eventsReverse(n,T,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+gs)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+gs:c||(a.attachmentState=this.unkeyedState+ms)}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 T=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=T):w!==0?p-=360*R.signum(b):y=T),y!==T&&(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 Zt))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,Ds.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(e,s=0,n=0){const i=this.addAnimation(e,Ds.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=sn;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 ds}r=fs}}if(s instanceof qt){const a=i.get(At.propertyID);if(a!=null)return a!==e?ds:fs}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()}},Zs=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=Lt.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===Lt.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=Lt.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}},tn=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}},en=(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))(en||{}),Jn=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},ds=0,sn=1,fs=2,us=3,$t=4,ms=1,gs=2,Kn=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}},nn=class{constructor(t,e="",s=new ps,n=new rn){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 Ye){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 Ye(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}},rn=class Te{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(e){const s=Te.AVAILABLE_CACHES.get(e);if(s)return s;const n=new Te;return Te.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]}},ps=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)}},bs=class Mn extends xt{color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new Mn(this.name);return this.copyTo(e),e.color.setFromColor(this.color),e}},_t=class Yn extends xt{endSlot=null;convex=!1;inverse=!1;color=new z(.2275,.2275,.8078,1);constructor(e){super(e)}copy(){const e=new Yn(this.name);return this.copyTo(e),e.endSlot=this.endSlot,e.convex=this.convex,e.inverse=this.inverse,e.color.setFromColor(this.color),e}},te=class Pn extends xt{lengths=[];closed=!1;constantSpeed=!1;color=new z(1,1,1,1);constructor(e){super(e)}copy(){const e=new Pn(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}},on=class kn 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 kn(this.name);return e.x=this.x,e.y=this.y,e.rotation=this.rotation,e.color.setFromColor(this.color),e}},Qn=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 bs(s)}newPathAttachment(t,e,s){return new te(s)}newPointAttachment(t,e,s){return new on(s)}newClippingAttachment(t,e,s){return new _t(s)}},ee=class{name;setupPose;skinRequired=!1;constructor(t,e){if(t==null)throw new Error("name cannot be null.");this.name=t,this.setupPose=e}},xs=class Fn extends ee{index=0;parent=null;length=0;color=new z;icon;iconSize=1;iconRotation=0;visible=!1;constructor(e,s,n){if(super(s,new ne),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}},se=(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))(se||{}),ne=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,T=Math.cos(x)*n,y=Math.sin(b)*s,v=Math.sin(x)*n;this.a=(c*w-l*y)*d,this.b=(c*T-l*v)*d,this.c=(o*w+h*y)*m,this.d=(o*T+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 T=1/Math.sqrt(x*x+w*w);x*=T,w*=T;let y=-w,v=x;this.inherit===3&&c*h-l*o<0!=(d<0!=m<0)&&(y=-y,v=-v);const S=i*R.degRad,A=(90+r)*R.degRad,I=Math.cos(S)*s,M=Math.cos(A)*n,Y=Math.sin(S)*s,F=Math.sin(A)*n;this.a=(x*I+y*Y)*d,this.b=(x*M+y*F)*d,this.c=(w*I+v*Y)*m,this.d=(w*M+v*F)*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,T=this.c*b,y=this.d*b,v=1/(i*i+a*a),S=1/Math.abs(l*g*b);this.set5((i*x+a*T)*v,(i*w+a*y)*v,(i*T-a*x)*S,(i*y-a*w)*S,R.atan2Deg(a,i));break}case 3:case 4:{const g=1/e,b=1/s,x=this.a*g,w=this.b*g,T=this.c*b,y=this.d*b;let v=c*this.a-r*this.c,S=i*this.c-a*this.a;l<0&&(v=-v,S=-S);let A=R.atan2Deg(S,v);this.rotation=A,A*=R.degRad;const I=Math.cos(A),M=Math.sin(A);let Y=(i*I+r*M)*g,F=(a*I+c*M)*b;const E=1/Math.sqrt(Y*Y+F*F);Y*=E,F*=E;const X=this.inherit===3&&l<0!=(e<0!=s<0)?-1:1;this.set4(Y*x+F*T,Y*w+F*y,(Y*T-F*x)*X,(Y*y-F*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}},ws=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)}},ys=class extends ws{active=!1;constructor(t,e,s){super(t,e,s),this.setupPose()}isActive(){return this.active}},ie=class En extends ys{parent=null;children=[];sorted=!1;constructor(e,s){super(e,new ne,new ne),this.parent=s,this.appliedPose.bone=this,this.constrainedPose.bone=this}copy(e){const s=new En(this.data,e);return s.pose.set(this.pose),s}},Et=class extends ys{constructor(t,e,s){super(t,e,s)}isSourceActive(){return!0}},an=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 ee{constructor(t,e){super(t,e)}},re=(t=>(t[t.None=0]="None",t[t.Uniform=1]="Uniform",t[t.Volume=2]="Volume",t))(re||{}),oe=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}},vs=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 oe(-1,this);constructor(t){this.name=t}},ae=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}},cn=class Yt extends Et{bones;target;constructor(e,s){if(super(e,new ae,new ae),!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,T=0,y=s.a,v=s.b,S=s.c,A=s.d;const I=Math.abs(u-f)<=R.epsilon;!I||c?(n.y=0,w=y*n.x+s.worldX,T=S*n.x+s.worldY):(w=y*n.x+v*n.y+s.worldX,T=S*n.x+A*n.y+s.worldY);const M=s.bone.parent.appliedPose;y=M.a,v=M.b,S=M.c,A=M.d;let Y=y*A-v*S,F=w-M.worldX,E=T-M.worldY;Y=Math.abs(Y)<=R.epsilon?0:1/Y;const X=(F*A-E*v)*Y-d,V=(E*y-F*S)*Y-m;let N=Math.sqrt(X*X+V*V),$=n.bone.data.length*p,O,k;if(N<R.epsilon){Yt.apply(e,s,i,r,!1,c,0,h),n.rotation=0;return}F=i-M.worldX,E=r-M.worldY;let P=(F*A-E*v)*Y-d,U=(E*y-F*S)*Y-m,D=P*P+U*U;if(o!==0){o*=u*(p+1)*.5;const B=Math.sqrt(D),_=B-N-$*u+o;if(_>0){let q=Math.min(1,_/(o*2))-1;q=(_-o*(1-q*q))/B,P-=q*P,U-=q*U,D=P*P+U*U}}t:if(I){$*=u;let B=(D-N*N-$*$)/(2*N*$);if(B<-1)B=-1,k=Math.PI*a;else if(B>1){if(B=1,k=0,c)switch(y=(Math.sqrt(D)/(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 k=Math.acos(B)*a;y=N+$*B,v=$*Math.sin(k),O=Math.atan2(U*y-P*v,P*y+U*v)}else{y=u*$,v=f*$;const B=y*y,_=v*v,q=Math.atan2(U,P);S=_*N*N+B*D-B*_;const K=-2*_*N,et=_-B;if(A=K*K-4*et*S,A>=0){let gt=Math.sqrt(A);K<0&&(gt=-gt),gt=-(K+gt)*.5;let bt=gt/et,Ht=S/gt;const ye=Math.abs(bt)<Math.abs(Ht)?bt:Ht;if(bt=D-ye*ye,bt>=0){E=Math.sqrt(bt)*a,O=q-Math.atan2(E,ye),k=Math.atan2(E/f,(ye-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;S=-y*N/(B-_),S>=-1&&S<=1&&(S=Math.acos(S),F=y*Math.cos(S)+N,E=v*Math.sin(S),A=F*F+E*E,A<it&&(Q=S,it=A,st=F,nt=E),A>ot&&(dt=S,ot=A,rt=F,ft=E)),D<=(it+ot)*.5?(O=q-Math.atan2(nt*a,st),k=Q*a):(O=q-Math.atan2(ft*a,rt),k=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,k=((k+W)*R.radDeg-n.shearX)*x+b-n.rotation,k>180?k-=360:k<=-180&&(k+=360),n.rotation+=k*h}},zt=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 ae)}create(t){return new cn(this,t)}},ce=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}},Wt=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 ce)}create(t){return new ln(this,t)}},Ts=(t=>(t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent",t))(Ts||{}),Ss=(t=>(t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional",t))(Ss||{}),As=(t=>(t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale",t))(As||{}),ln=class Pt 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 ce,new ce),!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 Pt(this.data,e);return s.pose.set(this.pose),s}update(e,s){const n=this.slot.appliedPose.attachment;if(!(n instanceof te))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,S=u-1;v<S;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 S=0,A=u-1;S<A;){const I=d[S],M=I.bone.data.length;if(M<R.epsilon)h&&(p[S]=0),f[++S]=g;else{const Y=M*I.a,F=M*I.c,E=Math.sqrt(Y*Y+F*F);h&&(p[S]=E),f[++S]=E,v+=E}}if(v>0){v=u/v*g;for(let S=1;S<u;S++)f[S]*=v}break}default:{const v=l.spacingMode===0;for(let S=0,A=u-1;S<A;){const I=d[S],M=I.bone.data.length;if(M<R.epsilon)h&&(p[S]=0),f[++S]=g;else{const Y=M*I.a,F=M*I.c,E=Math.sqrt(Y*Y+F*F);h&&(p[S]=E),f[++S]=(v?Math.max(0,M+g):g)*E/M}}}}const b=this.computeWorldPositions(e,n,u,o);let x=b[0],w=b[1],T=l.offsetRotation,y=!1;if(T===0)y=l.rotateMode===1;else{y=!1;const v=this.slot.bone.appliedPose;T*=v.a*v.d-v.b*v.c>0?R.degRad:-R.degRad}for(let v=0,S=3,A=e._update;v<m;v++,S+=3){const I=d[v];I.worldX+=(x-I.worldX)*a,I.worldY+=(w-I.worldY)*c;const M=b[S],Y=b[S+1],F=M-x,E=Y-w;if(h){const X=p[v];if(X!==0){const V=(Math.sqrt(F*F+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,$=I.d,O=0,k=0,P=0;if(o?O=b[S-1]:f[v+1]===0?O=b[S+2]:O=Math.atan2(E,F),O-=Math.atan2(N,X),y){k=Math.cos(O),P=Math.sin(O);const U=I.bone.data.length;x+=(U*(k*X-P*N)-F)*r,w+=(U*(P*X+k*N)-E)*r}else O+=T;O>R.PI?O-=R.PI2:O<-R.PI&&(O+=R.PI2),O*=r,k=Math.cos(O),P=Math.sin(O),I.a=k*X-P*N,I.b=k*V-P*$,I.c=P*X+k*N,I.d=P*V+k*$}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=Pt.NONE;if(!s.constantSpeed){const k=s.lengths;m-=h?1:2;const P=k[m];this.data.positionMode===1&&(a*=P);let U;switch(this.data.spacingMode){case 2:U=P;break;case 3:U=P/n;break;default:U=1}o=L.setArraySize(this.world,8);for(let D=0,W=0,B=0;D<n;D++,W+=3){const _=c[D]*U;a+=_;let q=a;if(h)q%=P,q<0&&(q+=P),B=0;else if(q<0){u!==Pt.BEFORE&&(u=Pt.BEFORE,s.computeWorldVertices(e,r,2,4,o,0,2)),this.addBeforePosition(q,o,0,l,W);continue}else if(q>P){u!==Pt.AFTER&&(u=Pt.AFTER,s.computeWorldVertices(e,r,d-6,4,o,0,2)),this.addAfterPosition(q-P,o,0,l,W);continue}for(;;B++){const K=k[B];if(!(q>K)){if(B===0)q/=K;else{const et=k[B-1];q=(q-et)/(K-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||D>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,T=0,y=0,v=0,S=0,A=0,I=0,M=0,Y=0,F=0,E=0,X=0,V=0;for(let k=0,P=2;k<m;k++,P+=6)x=o[P],w=o[P+1],T=o[P+2],y=o[P+3],v=o[P+4],S=o[P+5],A=(g-x*2+T)*.1875,I=(b-w*2+y)*.1875,M=((x-T)*3-g+v)*.09375,Y=((w-y)*3-b+S)*.09375,F=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+=F,V+=E,F+=M,E+=Y,p+=Math.sqrt(X*X+V*V),X+=F,V+=E,p+=Math.sqrt(X*X+V*V),X+=F+M,V+=E+Y,p+=Math.sqrt(X*X+V*V),f[k]=p,g=v,b=S;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 O=0;for(let k=0,P=0,U=0,D=0;k<n;k++,P+=3){const W=c[k]*N;a+=W;let B=a;if(h)B%=p,B<0&&(B+=p),U=0,D=0;else if(B<0){this.addBeforePosition(B,o,0,l,P);continue}else if(B>p){this.addAfterPosition(B-p,o,d-4,l,P);continue}for(;;U++){const _=f[U];if(!(B>_)){if(U===0)B/=_;else{const q=f[U-1];B=(B-q)/(_-q)}break}}if(U!==u){u=U;let _=U*6;for(g=o[_],b=o[_+1],x=o[_+2],w=o[_+3],T=o[_+4],y=o[_+5],v=o[_+6],S=o[_+7],A=(g-x*2+T)*.03,I=(b-w*2+y)*.03,M=((x-T)*3-g+v)*.006,Y=((w-y)*3-b+S)*.006,F=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),$[0]=O,_=1;_<8;_++)X+=F,V+=E,F+=M,E+=Y,O+=Math.sqrt(X*X+V*V),$[_]=O;X+=F,V+=E,O+=Math.sqrt(X*X+V*V),$[8]=O,X+=F+M,V+=E+Y,O+=Math.sqrt(X*X+V*V),$[9]=O,D=0}for(B*=O;;D++){const _=$[D];if(!(B>_)){if(D===0)B/=_;else{const q=$[D-1];B=D+(B-q)/(_-q)}break}}this.addCurvePosition(B*.1,g,b,x,w,T,y,v,S,l,P,i||k>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,T=p*w,y=w*e,v=s*b+i*T+a*y+l*f,S=n*b+r*T+c*y+o*f;h[d]=v,h[d+1]=S,m&&(e<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(S-(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 te))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}},hn=(t=>(t[t.none=0]="none",t[t.reset=1]="reset",t[t.update=2]="update",t[t.pose=3]="pose",t))(hn||{}),le=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}},he=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)}},dn=class Xn extends ws{skeleton;bone;attachmentState=0;constructor(e,s){if(super(e,new he,new he),!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 Xn(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)}},fn=class Se{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Se.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Se.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 ie(n,null);else{const r=this.bones[n.parent.index];i=new ie(n,r),r.children.push(i)}this.bones.push(i)}this.slots=[];for(const s of this.data.slots)this.slots.push(new dn(s,this));this.drawOrder=new an(this.slots),this.physics=[],this.constraints=[];for(const s of this.data.constraints){const n=s.create(this);n instanceof Is&&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 ie&&(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 Ce,n=new Ce;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=Se.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 _t&&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 T=p[x],y=p[x+1];c=Math.min(c,T),l=Math.min(l,y),o=Math.max(o,T),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)}},Is=class Vn 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 le,new le),s==null)throw new Error("skeleton cannot be null.");this.bone=s.bones[e.bone.index].constrainedPose}copy(e){var s=new Vn(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,T=-1,y=0,v=0,S=this.data.limit*u,A=S*Math.abs(e.scaleY);if(S*=Math.abs(e.scaleX),r||a){if(r){const I=(this.ux-p)*x;this.xOffset+=I>S?S:I<-S?-S: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;T=n.damping**(60*d),y=d*n.massInverse,v=n.strength;const Y=w*n.wind,F=w*n.gravity,E=(Y*e.windX+F*e.gravityX)*e.scaleX,X=(Y*e.windY+F*e.gravityY)*e.scaleY;do r&&(this.xVelocity+=(E-this.xOffset*v)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=T),a&&(this.yVelocity-=(X+this.yOffset*v)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=T),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,F=0,E=this.cx-o.worldX,X=this.cy-o.worldY;if(E>S?E=S:E<-S&&(E=-S),X>A?X=A:X<-A&&(X=-A),b=this.remaining,c){F=(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)*F;this.rotateOffset+=(V-Math.ceil(V*R.invPI2-.5)*R.PI2)*x,V=(this.rotateOffset-m)*F+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){T===-1&&(T=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)*fn.yDir,$=this.rotateOffset,O=this.scaleOffset,k=h/w;for(;;)if(b-=d,l&&(this.scaleVelocity+=(V*M-N*Y-this.scaleOffset*v)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=T),c){if(this.rotateVelocity-=((V*Y+N*M)*k+this.rotateOffset*v)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=T,b<d)break;const P=this.rotateOffset*F+I;M=Math.cos(P),Y=Math.sin(P)}else if(b<d)break;this.rotateLag=this.rotateOffset-$,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 le)}create(t){return new Is(this,t)}};typeof Math.fround>"u"&&(Math.fround=(t=>e=>(t[0]=e,t[0]))(new Float32Array(1)));var de=class{time=0;mix=0;set(t){this.time=t.time,this.mix=t.mix}},un=class Us extends Et{static offsets=[0,0,0,0,0,0];bone=null;constructor(e,s){if(super(e,new de,new de),!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(Js(u))e.constrained(c[u.slotIndex]);else if(u instanceof At||u instanceof qt)e.drawOrder.constrained();else if(u instanceof pt)if(u.constraintIndex===-1)for(let f=0;f<h;f++)e.constrained(o[f]);else e.constrained(l[u.constraintIndex]);else if(Qs(u)){const f=u.constraintIndex;f!==-1&&e.constrained(l[f])}}}},Tt=class extends Xt{animation;additive=!1;loop=!1;bone=null;property;scale=0;offset=0;local=!1;max=0;constructor(t){super(t,new de)}create(t){return new un(this,t)}},Cs=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 Tt&&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}},Ms=class{slotIndex=0;placeholder;attachment;constructor(t=0,e,s){this.slotIndex=t,this.placeholder=e,this.attachment=s}},fe=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 Ms(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 Ms(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++}}},Ys=class extends ee{index=0;boneData;attachmentName=null;blendMode=0;visible=!0;constructor(t,e,s){if(super(e,new he),t<0)throw new Error("index must be >= 0.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.boneData=s}},Ps=(t=>(t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen",t))(Ps||{}),ue=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}},mn=class Rn extends Et{bones;source;constructor(e,s){if(super(e,new ue,new ue),!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 Rn(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],T=w.value(e,h,r,o)-w.offset,y=w.to;for(let v=0,S=w.to.length;v<S;v++){const A=y[v];if(A.mix(n)!==0){let I=A.offset+T*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}},J=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 ue)}create(e){return new mn(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},me=class extends It{value(t,e,s,n){if(s)return e.rotation+n[J.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[J.ROTATION]:-n[J.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}}},ge=class extends It{value(t,e,s,n){return s?e.x+n[J.X]:(n[J.X]*e.a+n[J.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)}},pe=class extends It{value(t,e,s,n){return s?e.y+n[J.Y]:(n[J.X]*e.c+n[J.Y]*e.d+e.worldY)/t.scaleY}},Es=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)}},be=class extends It{value(t,e,s,n){if(s)return e.scaleX+n[J.SCALEX];const i=e.a/t.scaleX,r=e.c/t.scaleY;return Math.sqrt(i*i+r*r)+n[J.SCALEX]}},Xs=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)}}},xe=class extends It{value(t,e,s,n){if(s)return e.scaleY+n[J.SCALEY];const i=e.b/t.scaleX,r=e.d/t.scaleY;return Math.sqrt(i*i+r*r)+n[J.SCALEY]}},Vs=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)}}},we=class extends It{value(t,e,s,n){if(s)return e.shearY+n[J.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[J.SHEARY]}},Rs=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 Cs;s.name="";const n=new gn(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 xs(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 Ys(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 yi:{const g=new zt(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 Ti:{const g=new J(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,T;w<p;w++){let y=1,v;switch(n.readByte()){case 0:v=new me;break;case 1:{y=e,v=new ge;break}case 2:{y=e,v=new pe;break}case 3:v=new be;break;case 4:v=new xe;break;case 5:v=new we;break;default:v=null}if(v){v.offset=n.readFloat()*y,T=n.readByte();for(let S=0;S<T;S++){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 Es;break}case 3:I=new Xs;break;case 4:I=new Vs;break;case 5:I=new Rs;break;default:I=null}I&&(I.offset=n.readFloat()*A,I.max=n.readFloat()*A,I.scale=n.readFloat()*A/y,v.to[S]=I)}g.properties[w]=v}}b=n.readByte(),(b&1)!==0&&(g.offsets[J.ROTATION]=n.readFloat()),(b&2)!==0&&(g.offsets[J.X]=n.readFloat()*e),(b&4)!==0&&(g.offsets[J.Y]=n.readFloat()*e),(b&8)!==0&&(g.offsets[J.SCALEX]=n.readFloat()),(b&16)!==0&&(g.offsets[J.SCALEY]=n.readFloat()),(b&32)!==0&&(g.offsets[J.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 vi:{const g=new Wt(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 Si:{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 Ai:{const g=new Tt(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 me;break;case 1:{w=e,g.property=new ge;break}case 2:{w=e,g.property=new pe;break}case 3:g.property=new be;break;case 4:g.property=new xe;break;case 5:g.property=new we;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 vs(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 Tt&&(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 fe("default")}else{const a=t.readString();if(!a)throw new Error("Skin name must not be null.");i=new fe(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,T=0;r&&(x=this.readShortArray(t,t.readInt(!0)),w=t.readFloat(),T=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=T*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 ti(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 Ot(1,!1);const s=new Ot(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 pn(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 pn(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 mi:{const T=new kt(x,f);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat(),t.readStringRef());i.push(T);break}case gi:{const T=t.readInt(!0),y=new $e(x,T,f);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255;for(let Y=0,F=0;y.setFrame(Y,v,S,A,I,M),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 ut:y.setStepped(Y);break;case mt:G(t,y,F++,Y,0,v,E,S,X,1),G(t,y,F++,Y,1,v,E,A,V,1),G(t,y,F++,Y,2,v,E,I,N,1),G(t,y,F++,Y,3,v,E,M,$,1)}v=E,S=X,A=V,I=N,M=$}i.push(y);break}case pi:{const T=t.readInt(!0),y=new _e(x,T,f);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255;for(let M=0,Y=0;y.setFrame(M,v,S,A,I),M!==w;M++){const F=t.readFloat(),E=t.readUnsignedByte()/255,X=t.readUnsignedByte()/255,V=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(M);break;case mt:G(t,y,Y++,M,0,v,F,S,E,1),G(t,y,Y++,M,1,v,F,A,X,1),G(t,y,Y++,M,2,v,F,I,V,1)}v=F,S=E,A=X,I=V}i.push(y);break}case bi:{const T=t.readInt(!0),y=new We(x,T,f);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255,E=t.readUnsignedByte()/255;for(let X=0,V=0;y.setFrame(X,v,S,A,I,M,Y,F,E),X!==w;X++){const N=t.readFloat(),$=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255,D=t.readUnsignedByte()/255,W=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(X);break;case mt:G(t,y,V++,X,0,v,N,S,$,1),G(t,y,V++,X,1,v,N,A,O,1),G(t,y,V++,X,2,v,N,I,k,1),G(t,y,V++,X,3,v,N,M,P,1),G(t,y,V++,X,4,v,N,Y,U,1),G(t,y,V++,X,5,v,N,F,D,1),G(t,y,V++,X,6,v,N,E,W,1)}v=N,S=$,A=O,I=k,M=P,Y=U,F=D,E=W}i.push(y);break}case xi:{const T=t.readInt(!0),y=new Ge(x,T,f);let v=t.readFloat(),S=t.readUnsignedByte()/255,A=t.readUnsignedByte()/255,I=t.readUnsignedByte()/255,M=t.readUnsignedByte()/255,Y=t.readUnsignedByte()/255,F=t.readUnsignedByte()/255;for(let E=0,X=0;y.setFrame(E,v,S,A,I,M,Y,F),E!==w;E++){const V=t.readFloat(),N=t.readUnsignedByte()/255,$=t.readUnsignedByte()/255,O=t.readUnsignedByte()/255,k=t.readUnsignedByte()/255,P=t.readUnsignedByte()/255,U=t.readUnsignedByte()/255;switch(t.readByte()){case ut:y.setStepped(E);break;case mt:G(t,y,X++,E,0,v,V,S,N,1),G(t,y,X++,E,1,v,V,A,$,1),G(t,y,X++,E,2,v,V,I,O,1),G(t,y,X++,E,3,v,V,M,k,1),G(t,y,X++,E,4,v,V,Y,P,1),G(t,y,X++,E,5,v,V,F,U,1)}v=V,S=N,A=$,I=O,M=k,Y=P,F=U}i.push(y);break}case wi:{const T=new ze(x,t.readInt(!0),f);let y=t.readFloat(),v=t.readUnsignedByte()/255;for(let S=0,A=0;T.setFrame(S,y,v),S!==w;S++){const I=t.readFloat(),M=t.readUnsignedByte()/255;switch(t.readByte()){case ut:T.setStepped(S);break;case mt:G(t,T,A++,S,0,y,I,v,M,1)}y=I,v=M}i.push(T)}}}}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===ui){const T=new qe(x,f);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat(),t.readByte());i.push(T);continue}const w=t.readInt(!0);switch(b){case ni:tt(t,i,new Dt(x,w,f),1);break;case ii:tt(t,i,new Xe(x,w,f),r);break;case ri:tt(t,i,new Ve(x,w,f),r);break;case oi:tt(t,i,new Re(x,w,f),r);break;case ai:tt(t,i,new Le(x,w,f),1);break;case ci:tt(t,i,new Be(x,w,f),1);break;case li:tt(t,i,new Oe(x,w,f),1);break;case hi:tt(t,i,new Ne(x,w,f),1);break;case di:tt(t,i,new De(x,w,f),1);break;case fi: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(),T=(x&1)!==0?(x&2)!==0?t.readFloat():1:0,y=(x&4)!==0?t.readFloat()*r:0;for(let v=0,S=0;b.setFrame(v,w,T,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&&(G(t,b,S++,v,0,w,A,T,I,1),G(t,b,S++,v,1,w,A,y,M,r)),w=A,T=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(),T=t.readFloat(),y=t.readFloat(),v=t.readFloat(),S=t.readFloat(),A=t.readFloat();for(let I=0,M=0;b.setFrame(I,x,w,T,y,v,S,A),I!==g;I++){const Y=t.readFloat(),F=t.readFloat(),E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat(),$=t.readFloat();switch(t.readByte()){case ut:b.setStepped(I);break;case mt:G(t,b,M++,I,0,x,Y,w,F,1),G(t,b,M++,I,1,x,Y,T,E,1),G(t,b,M++,I,2,x,Y,y,X,1),G(t,b,M++,I,3,x,Y,v,V,1),G(t,b,M++,I,4,x,Y,S,N,1),G(t,b,M++,I,5,x,Y,A,$,1)}x=Y,w=F,T=E,y=X,v=V,S=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),T=t.readInt(!0);switch(x){case Mi:tt(t,i,new Qe(w,T,f),p.positionMode===0?r:1);break;case Yi:tt(t,i,new Ze(w,T,f),p.spacingMode===0||p.spacingMode===1?r:1);break;case Pi:{const y=new ts(w,T,f);let v=t.readFloat(),S=t.readFloat(),A=t.readFloat(),I=t.readFloat();for(let M=0,Y=0,F=y.getFrameCount()-1;y.setFrame(M,v,S,A,I),M!==F;M++){const E=t.readFloat(),X=t.readFloat(),V=t.readFloat(),N=t.readFloat();switch(t.readByte()){case ut:y.setStepped(M);break;case mt:G(t,y,Y++,M,0,v,E,S,X,1),G(t,y,Y++,M,1,v,E,A,V,1),G(t,y,Y++,M,2,v,E,I,N,1)}v=E,S=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===Bi){const T=new cs(x,f);for(let y=0;y<x;y++)T.setFrame(y,t.readFloat());i.push(T);continue}const w=t.readInt(!0);switch(b){case ki:tt(t,i,new es(x,w,f),1);break;case Fi:tt(t,i,new ss(x,w,f),1);break;case Ei:tt(t,i,new ns(x,w,f),1);break;case Xi:tt(t,i,new is(x,w,f),1);break;case Vi:tt(t,i,new rs(x,w,f),1);break;case Ri:tt(t,i,new os(x,w,f),1);break;case Li:tt(t,i,new as(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 Oi:tt(t,i,new ls(x,w,f),1);break;case Ni:tt(t,i,new hs(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 T=t.readStringRef();if(!T)throw new Error("attachmentName must not be null.");const y=f.getAttachment(b,T),v=t.readByte(),S=t.readInt(!0),A=S-1;switch(v){case Ii:{const I=y,M=I.bones,Y=I.vertices,F=M?Y.length/3*2:Y.length,E=t.readInt(!0),X=new He(S,E,b,I);let V=t.readFloat();for(let N=0,$=0;;N++){let O,k=t.readInt(!0);if(k===0)O=M?L.newFloatArray(F):Y;else{O=L.newFloatArray(F);const U=t.readInt(!0);if(k+=U,r===1)for(let D=U;D<k;D++)O[D]=t.readFloat();else for(let D=U;D<k;D++)O[D]=t.readFloat()*r;if(!M)for(let D=0,W=O.length;D<W;D++)O[D]+=Y[D]}if(X.setFrame(N,V,O),N===A)break;const P=t.readFloat();switch(t.readByte()){case ut:X.setStepped(N);break;case mt:G(t,X,$++,N,0,V,P,0,1,1)}V=P}i.push(X);break}case Ci:{const I=new je(S,b,y);for(let M=0;M<S;M++){const Y=t.readFloat(),F=t.readInt32();I.setFrame(M,Y,Ee[F&15],F>>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(),bn(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(),bn(t,u));i.push(g)}const o=t.readInt(!0);if(o>0){const m=new Zt(o);for(let u=0;u<o;u++){const f=t.readFloat(),p=s.events[t.readInt(!0)],g=new oe(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 Kt(e,i,h);return n&&z.rgba8888ToColor(d.color,t.readInt32()),d}},gn=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}},ti=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}},pn=class{constructor(t=null,e,s=0){this.bones=t,this.vertices=e,this.length=s}};function tt(t,e,s,n){s instanceof Nt?ei(t,e,s,n):si(t,e,s,n)}function ei(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 ut:s.setStepped(a);break;case mt:G(t,s,c++,a,0,i,o,r,h,n)}i=o,r=h}e.push(s)}function si(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 ut:s.setStepped(c);break;case mt:G(t,s,l++,c,0,i,h,r,d,n),G(t,s,l++,c,1,i,h,a,m,n)}i=h,r=d,a=m}e.push(s)}function bn(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 G(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 ni=0,ii=1,ri=2,oi=3,ai=4,ci=5,li=6,hi=7,di=8,fi=9,ui=10,mi=0,gi=1,pi=2,bi=3,xi=4,wi=5,yi=0,vi=1,Ti=2,Si=3,Ai=4,Ii=0,Ci=1,Mi=0,Yi=1,Pi=2,ki=0,Fi=1,Ei=2,Xi=4,Vi=5,Ri=6,Li=7,Bi=8,Oi=0,Ni=1,ut=1,mt=2,Di=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new Bt(()=>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 bs){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 T=(o*b-l*p)/x;if((T>=d&&T<=f||T>=f&&T<=d)&&(T>=s&&T<=i||T>=i&&T<=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}},xn=class at{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new Bt(()=>[]);polygonIndicesPool=new Bt(()=>[]);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],T=s[f+1];for(let y=o+1<n?o+1:0;y!==c;){if(r[y]){const v=i[y]<<1,S=s[v],A=s[v+1];if(at.positiveArea(w,T,p,g,S,A)&&at.positiveArea(p,g,b,x,S,A)&&at.positiveArea(b,x,w,T,S,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],T=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,T)===o&&at.winding(w,T,c[0],c[1],c[2],c[3])===o){c.push(w,T),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,T),a.length=0,a.push(m,u,f),o=at.winding(p,g,b,x,w,T),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],T=c[1],y=c[2],v=c[3],S=at.winding(p,g,b,x,w,T);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],F=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)===S&&at.winding(X,V,w,T,y,v)===S&&(E.length=0,I.length=0,c.push(X,V),a.push(F),u=F,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}},wn=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 xn),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 T=0,y=this.inverseVertices.length;T<y;){const v=w[T++];let S=v>>1,A=n.length;const I=L.setArraySize(n,A+v);L.arrayCopy(w,T,I,A,v),A=i.length;const M=L.setArraySize(i,A+3*(S-2));for(let Y=1;Y<S-1;Y++,A+=3)M[A]=r,M[A+1]=r+Y,M[A+2]=r+Y+1;r+=S,T+=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 T=a.length;if(T===0)continue;let y=T>>1;const v=L.setArraySize(n,w+T);L.arrayCopy(o,0,v,w,T),w=i.length;const S=L.setArraySize(i,w+3*(y-2));y--;for(let A=1;A<y;A++,w+=3)S[w]=r,S[w+1]=r+A,S[w+2]=r+A+1;r+=y}else{const T=L.setArraySize(n,w+6);T[w]=m,T[w+1]=u,T[w+2]=f,T[w+3]=p,T[w+4]=g,T[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 T=t[b*c],y=t[b*c+1],v=t[x*c],S=t[x*c+1],A=t[w*c],I=t[w*c+1];this.clipInverse(T,y,v,S,A,I,p);const M=this.inverseVertices.length;if(M===0)continue;const Y=n[b<<=1],F=n[b+1],E=n[x<<=1],X=n[x+1],V=n[w<<=1],N=n[w+1],$=S-I,O=A-v,k=T-A,P=I-y,U=1/($*k+O*(y-I)),D=this.inverseVertices;for(let W=0;W<M;){const B=D[W++],_=B>>1;let q=l.length;const K=L.setArraySize(l,q+_*c);for(let Q=0;Q<B;Q+=2,q+=c){const st=D[W+Q],it=D[W+Q+1];K[q]=st,K[q+1]=it,K[q+2]=i.r,K[q+3]=i.g,K[q+4]=i.b,K[q+5]=i.a;const nt=st-A,dt=it-I,rt=($*nt+O*dt)*U,ot=(P*nt+k*dt)*U,ft=1-rt-ot;K[q+6]=Y*rt+E*ot+V*ft,K[q+7]=F*rt+X*ot+N*ft,a&&(K[q+8]=r.r,K[q+9]=r.g,K[q+10]=r.b,K[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],T=n[(g<<1)+1];g=e[p+1];const y=t[g*c],v=t[g*c+1],S=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],F=n[(g<<1)+1],E=v-M,X=I-y,V=b-I,N=M-x,$=1/(E*V+X*(x-M));for(let O=0;O<u;O++){let k=l.length;if(this.clip(b,x,y,v,I,M,m[O])){f=this.clipOutput;const P=d.length;if(P===0)continue;let U=P>>1;const D=L.setArraySize(l,k+U*c);for(let B=0;B<P;B+=2,k+=c){const _=f[B],q=f[B+1];D[k]=_,D[k+1]=q,D[k+2]=i.r,D[k+3]=i.g,D[k+4]=i.b,D[k+5]=i.a;const K=_-I,et=q-M,Q=(E*K+X*et)*$,st=(N*K+V*et)*$,it=1-Q-st;D[k+6]=w*Q+S*st+Y*it,D[k+7]=T*Q+A*st+F*it,a&&(D[k+8]=r.r,D[k+9]=r.g,D[k+10]=r.b,D[k+11]=r.a)}k=o.length;const W=L.setArraySize(o,k+3*(U-2));U--;for(let B=1;B<U;B++,k+=3)W[k]=h,W[k+1]=h+B,W[k+2]=h+B+1;h+=U+1}else{const P=L.setArraySize(l,k+3*c);P[k]=b,P[k+1]=x,P[k+2]=i.r,P[k+3]=i.g,P[k+4]=i.b,P[k+5]=i.a,a?(P[k+6]=w,P[k+7]=T,P[k+8]=r.r,P[k+9]=r.g,P[k+10]=r.b,P[k+11]=r.a,P[k+12]=y,P[k+13]=v,P[k+14]=i.r,P[k+15]=i.g,P[k+16]=i.b,P[k+17]=i.a,P[k+18]=S,P[k+19]=A,P[k+20]=r.r,P[k+21]=r.g,P[k+22]=r.b,P[k+23]=r.a,P[k+24]=I,P[k+25]=M,P[k+26]=i.r,P[k+27]=i.g,P[k+28]=i.b,P[k+29]=i.a,P[k+30]=Y,P[k+31]=F,P[k+32]=r.r,P[k+33]=r.g,P[k+34]=r.b,P[k+35]=r.a):(P[k+6]=w,P[k+7]=T,P[k+8]=y,P[k+9]=v,P[k+10]=i.r,P[k+11]=i.g,P[k+12]=i.b,P[k+13]=i.a,P[k+14]=S,P[k+15]=A,P[k+16]=I,P[k+17]=M,P[k+18]=i.r,P[k+19]=i.g,P[k+20]=i.b,P[k+21]=i.a,P[k+22]=Y,P[k+23]=F),k=o.length;const U=L.setArraySize(o,k+3);U[k]=h,U[k+1]=h+1,U[k+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 T=i[w],y=i[w+1];g=s[p+1]*r;const v=t[e+g],S=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 F=i[w],E=i[w+1];this.clipInverse(b,x,v,S,M,Y,f);const X=this.inverseVertices.length;if(X===0)continue;const V=S-Y,N=M-v,$=b-M,O=Y-x,k=1/(V*$+N*(x-Y)),P=this.inverseVertices;for(let U=0;U<X;){const D=P[U++],W=D>>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 K=this._clippedVerticesTyped,et=this._clippedUVsTyped;let Q=q-W*2;for(let nt=0;nt<D;nt+=2,B+=r,Q+=2){const dt=P[U+nt],rt=P[U+nt+1];K[B]=dt,K[B+1]=rt;const ot=dt-M,ft=rt-Y,gt=(V*ot+N*ft)*k,bt=(O*ot+$*ft)*k,Ht=1-gt-bt;et[Q]=T*gt+A*bt+F*Ht,et[Q+1]=y*gt+I*bt+E*Ht}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,U+=D}}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 T=i[w],y=i[w+1];p=s[f+1],g=p*r;const v=t[e+g],S=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 F=i[w],E=i[w+1],X=S-Y,V=M-v,N=b-M,$=Y-x,O=1/(X*N+V*(x-Y));for(let k=0;k<m;k++){let P=this.clippedVerticesLength;if(this.clip(b,x,v,S,M,Y,d[k])){u=h;const U=h.length;if(U===0)continue;let D=U>>1;const W=P+D*r;a.length<W&&(this._clippedVerticesTyped=new Float32Array(W*2),this._clippedVerticesTyped.set(a.subarray(0,P)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+D*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+D*2;for(let Q=0;Q<U;Q+=2,P+=r,q+=2){const st=u[Q],it=u[Q+1];B[P]=st,B[P+1]=it;const nt=st-M,dt=it-Y,rt=(X*nt+V*dt)*O,ot=($*nt+N*dt)*O,ft=1-rt-ot;_[q]=T*rt+A*ot+F*ft,_[q+1]=y*rt+I*ot+E*ft}P=this.clippedTrianglesLength;const K=P+3*(D-2);l.length<K&&(this._clippedTrianglesTyped=new Uint16Array(K*2),this._clippedTrianglesTyped.set(l.subarray(0,P)),l=this._clippedTrianglesTyped),this.clippedTrianglesLength=K;const et=l;D--;for(let Q=1;Q<D;Q++,P+=3)et[P]=o,et[P+1]=o+Q,et[P+2]=o+Q+1;o+=D+1}else{let U=P+3*r;a.length<U&&(this._clippedVerticesTyped=new Float32Array(U*2),this._clippedVerticesTyped.set(a.subarray(0,P)),a=this._clippedVerticesTyped),a[P]=b,a[P+1]=x,a[P+r]=v,a[P+r+1]=S,a[P+r*2]=M,a[P+r*2+1]=Y;const D=this.clippedUVsLength+3*2;c.length<D&&(this._clippedUVsTyped=new Float32Array(D*2),this._clippedUVsTyped.set(c.subarray(0,this.clippedUVsLength)),c=this._clippedUVsTyped);const W=this.clippedUVsLength;c[W]=T,c[W+1]=y,c[W+2]=A,c[W+3]=I,c[W+4]=F,c[W+5]=E,this.clippedVerticesLength=U,this.clippedUVsLength=D,P=this.clippedTrianglesLength,U=P+3,l.length<U&&(this._clippedTrianglesTyped=new Uint16Array(U*2),this._clippedTrianglesTyped.set(l.subarray(0,P)),l=this._clippedTrianglesTyped);const B=l;B[P]=o,B[P+1]=o+1,B[P+2]=o+2,o+=3,this.clippedTrianglesLength=U;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,T=o;for(let v=0,S=o.length-2;v<S;){t=T[v],e=T[v+1],v+=2,s=T[v],n=T[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,F=I/(M*x-Y*b);F>=0&&F<=1?(h.push(t+M*F,e+Y*F),l=!0):h.push(s,n)}else if(A){const M=s-t,Y=n-e,F=I/(M*x-Y*b);F>=0&&F<=1?(h.push(t+M*F,e+Y*F,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 S=g*(u-s)>p*(f-n),A=g*(u-t)-p*(f-e);if(A>0)if(S)o.push(s,n);else{const I=s-t,M=n-e,Y=A/(I*g-M*p);if(Y>=0&&Y<=1){const F=t+I*Y,E=e+M*Y;o.push(F,E),this.inverseVertices.push(F,E,s,n)}else o.push(s,n)}else if(S){const I=s-t,M=n-e,Y=A/(I*g-M*p);if(Y>=0&&Y<=1){const F=t+I*Y,E=e+M*Y;this.inverseVertices.push(F,E),o.push(F,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 T=o;o=l,o.length=0,l=T}}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}},Ui=class{attachmentLoader;scale=1;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(t){const e=this.scale,s=new Cs,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 xs(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(se,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 Ys(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(Ps,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 zt(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(re,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 J(a);l.skinRequired=c;for(let w=0;w<r.bones.length;w++){const T=r.bones[w],y=s.findBone(T);if(!y)throw new Error(`Couldn't find bone ${T} 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,T]of b){const y=this.fromProperty(w),v=this.propertyScale(w,e);y.offset=C(T,"offset",0)*v;const S=Object.entries(C(T,"to",{}));for(const[A,I]of S){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 Es,M=e;break}case"scaleX":{f=!0,Y=new Xs;break}case"scaleY":{p=!0,Y=new Vs;break}case"shearY":{g=!0,Y=new Rs;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[J.ROTATION]=C(r,"rotation",0),l.offsets[J.X]=C(r,"x",0)*e,l.offsets[J.Y]=C(r,"y",0)*e,l.offsets[J.SCALEX]=C(r,"scaleX",0),l.offsets[J.SCALEY]=C(r,"scaleY",0),l.offsets[J.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 Wt(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(Ts,C(r,"positionMode","Percent")),l.spacingMode=L.enumValue(Ss,C(r,"spacingMode","Length")),l.rotateMode=L.enumValue(As,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(re,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 Tt(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 fe(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,zt);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,J);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,Wt);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,Tt);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 vs(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,Tt),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 me;break;case"x":e=new ge;break;case"y":e=new pe;break;case"scaleX":e=new be;break;case"scaleY":e=new xe;break;case"shearY":e=new we;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 qi(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 Ot(1,!1);const e=new Ot(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 kt(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,T=0;;w++){p.setFrame(w,b,x.r,x.g,x.b,x.a);const y=u[w+1];if(!y){p.shrink(T);break}const v=C(y,"time",0),S=z.fromString(y.color),A=g.curve;A&&(T=H(A,p,T,w,0,b,v,x.r,S.r,1),T=H(A,p,T,w,1,b,v,x.g,S.g,1),T=H(A,p,T,w,2,b,v,x.b,S.b,1),T=H(A,p,T,w,3,b,v,x.a,S.a,1)),b=v,x=S,g=y}i.push(p);break}case"rgb":{const p=new _e(f,f*3,d);let g=u[0],b=C(g,"time",0),x=z.fromString(g.color);for(let w=0,T=0;;w++){p.setFrame(w,b,x.r,x.g,x.b);const y=u[w+1];if(!y){p.shrink(T);break}const v=C(y,"time",0),S=z.fromString(y.color),A=g.curve;A&&(T=H(A,p,T,w,0,b,v,x.r,S.r,1),T=H(A,p,T,w,1,b,v,x.g,S.g,1),T=H(A,p,T,w,2,b,v,x.b,S.b,1)),b=v,x=S,g=y}i.push(p);break}case"alpha":{ct(i,u,new ze(f,f,d),0,1);break}case"rgba2":{const p=new We(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 T=0,y=0;;T++){p.setFrame(T,b,x.r,x.g,x.b,x.a,w.r,w.g,w.b);const v=u[T+1];if(!v){p.shrink(y);break}const S=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=H(M,p,y,T,0,b,S,x.r,A.r,1),y=H(M,p,y,T,1,b,S,x.g,A.g,1),y=H(M,p,y,T,2,b,S,x.b,A.b,1),y=H(M,p,y,T,3,b,S,x.a,A.a,1),y=H(M,p,y,T,4,b,S,w.r,I.r,1),y=H(M,p,y,T,5,b,S,w.g,I.g,1),y=H(M,p,y,T,6,b,S,w.b,I.b,1)),b=S,x=A,w=I,g=v}i.push(p);break}case"rgb2":{const p=new Ge(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 T=0,y=0;;T++){p.setFrame(T,b,x.r,x.g,x.b,w.r,w.g,w.b);const v=u[T+1];if(!v){p.shrink(y);break}const S=C(v,"time",0),A=z.fromString(v.light),I=z.fromString(v.dark),M=g.curve;M&&(y=H(M,p,y,T,0,b,S,x.r,A.r,1),y=H(M,p,y,T,1,b,S,x.g,A.g,1),y=H(M,p,y,T,2,b,S,x.b,A.b,1),y=H(M,p,y,T,3,b,S,w.r,I.r,1),y=H(M,p,y,T,4,b,S,w.g,I.g,1),y=H(M,p,y,T,5,b,S,w.b,I.b,1)),b=S,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":Ls(i,u,new Xe(f,f<<1,d),"x","y",0,n);break;case"translatex":ct(i,u,new Ve(f,f,d),0,n);break;case"translatey":ct(i,u,new Re(f,f,d),0,n);break;case"scale":Ls(i,u,new Le(f,f<<1,d),"x","y",1,1);break;case"scalex":ct(i,u,new Be(f,f,d),1,1);break;case"scaley":ct(i,u,new Oe(f,f,d),1,1);break;case"shear":Ls(i,u,new Ne(f,f<<1,d),"x","y",0,1);break;case"shearx":ct(i,u,new De(f,f,d),0,1);break;case"sheary":ct(i,u,new Ue(f,f,d),0,1);break;case"inherit":{const p=new qe(f,h.index);for(let g=0;g<u.length;g++){const b=u[g];p.setFrame(g,C(b,"time",0),L.enumValue(se,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,zt);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),T=C(x,"mix",1),y=C(x,"softness",0)*n,v=h.curve;v&&(b=H(v,m,b,g,0,u,w,f,T,1),b=H(v,m,b,g,1,u,w,p,y,n)),u=w,f=T,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,J);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 T=0,y=0;;T++){m.setFrame(T,u,f,p,g,b,x,w);const v=o[T+1];if(!v){m.shrink(y);break}const S=C(v,"time",0),A=C(v,"mixRotate",1),I=C(v,"mixX",1),M=C(v,"mixY",I),Y=C(v,"mixScaleX",1),F=C(v,"mixScaleY",1),E=C(v,"mixShearY",1),X=h.curve;X&&(y=H(X,m,y,T,0,u,S,f,A,1),y=H(X,m,y,T,1,u,S,p,I,1),y=H(X,m,y,T,2,u,S,g,M,1),y=H(X,m,y,T,3,u,S,b,Y,1),y=H(X,m,y,T,4,u,S,x,F,1),y=H(X,m,y,T,5,u,S,w,E,1)),u=S,f=A,p=I,g=M,b=Y,x=F,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,Wt);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 Qe(p,p,d);ct(i,u,g,0,h.positionMode===0?n:1);break}case"spacing":{const g=new Ze(p,p,d);ct(i,u,g,0,h.spacingMode===0||h.spacingMode===1?n:1);break}case"mix":{const g=new ts(p,p*3,d);let b=C(f,"time",0),x=C(f,"mixRotate",1),w=C(f,"mixX",1),T=C(f,"mixY",w);for(let y=0,v=0;;y++){g.setFrame(y,b,x,w,T);const S=u[y+1];if(!S){g.shrink(v);break}const A=C(S,"time",0),I=C(S,"mixRotate",1),M=C(S,"mixX",1),Y=C(S,"mixY",M),F=f.curve;F&&(v=H(F,g,v,y,0,b,A,x,I,1),v=H(F,g,v,y,1,b,A,w,M,1),v=H(F,g,v,y,2,b,A,T,Y,1)),b=A,x=I,w=M,T=Y,f=S}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 cs(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 es(f,f,h);break;case"strength":p=new ss(f,f,h);break;case"damping":p=new ns(f,f,h);break;case"mass":p=new is(f,f,h);break;case"wind":p=new rs(f,f,h);break;case"gravity":p=new os(f,f,h);break;case"mix":{g=1,p=new as(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,Tt);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 ls(p,p,d),1,1);break;case"mix":ct(i,u,new hs(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 T=w[0];if(T){if(x==="deform"){const y=b.bones,v=b.vertices,S=y?v.length/3*2:v.length,A=new He(w.length,w.length,f,b);let I=C(T,"time",0);for(let M=0,Y=0;;M++){let F;const E=C(T,"vertices",null);if(!E)F=y?L.newFloatArray(S):v;else{F=L.newFloatArray(S);const $=C(T,"offset",0);if(L.arrayCopy(E,0,F,$,E.length),n!==1)for(let O=$,k=O+E.length;O<k;O++)F[O]*=n;if(!y)for(let O=0;O<S;O++)F[O]+=v[O]}A.setFrame(M,I,F);const X=w[M+1];if(!X){A.shrink(Y);break}const V=C(X,"time",0),N=T.curve;N&&(Y=H(N,A,Y,M,0,I,V,0,1,1)),I=V,T=X}i.push(A)}else if(x==="sequence"){const y=new je(w.length,f,b);let v=0;for(let S=0;S<w.length;S++){const A=C(T,"delay",v),I=C(T,"time",0),M=Fe[C(T,"mode","hold")],Y=C(T,"index",0);y.setFrame(S,I,M,Y,A),v=A,T=w[S+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),yn(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),yn(s,p,h.length,h));i.push(u)}if(t.events){const l=new Zt(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 oe(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 Kt(e,i,r),c=C(t,"color",null);c!==null&&a.color.setFromString(c),s.animations.push(a)}},qi=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=H(r.curve,s,l,o,0,a,d,c,m,i)),a=d,c=m,r=h}}function Ls(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=H(b,s,d,m,0,l,f,o,p,a),d=H(b,s,d,m,1,l,f,h,g,a)),l=f,o=p,h=g,c=u}}function yn(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 H(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 $i=class{commandPool=new _i;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new wn;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 _t)){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 S=l.sequence,A=S.resolveIndex(o);l.computeWorldVertices(c,l.getOffsets(o),this.worldVertices,0,n),m=this.worldVertices,u=4,f=S.getUVs(A),p=this.quadIndices,g=6,x=S.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 S=l.sequence,A=S.resolveIndex(o);f=S.getUVs(A),p=l.triangles,g=p.length,x=S.regions[A]?.texture}else if(l instanceof _t){i.clipStart(t,c,l);continue}else continue;const w=t.color;let T,y;if(e){let S;if(s){S=Math.floor(s[3]*w.a*h.a*b.a*255);const A=Math.floor(S*s[0]*w.r*h.r*b.r),I=Math.floor(S*s[1]*w.g*h.g*b.g),M=Math.floor(S*s[2]*w.b*h.b*b.b);T=S<<24|A<<16|I<<8|M}else{S=Math.floor(w.a*h.a*b.a*255);const A=Math.floor(S*w.r*h.r*b.r),I=Math.floor(S*w.g*h.g*b.g),M=Math.floor(S*w.b*h.b*b.b);T=S<<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*S)<<16|Math.floor(I*S)<<8|Math.floor(M*S)}}else{if(s){const S=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);T=S<<24|A<<16|I<<8|M}else{const S=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);T=S<<24|A<<16|I<<8|M}if(y=0,o.darkColor){const{r:S,g:A,b:I}=o.darkColor;y=Math.floor(S*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 S=0;S<u;S++)v.colors[S]=T,v.darkColors[S]=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}},_i=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}},vn=class extends Me{constructor(t){super(t)}setFilters(t,e){}setWraps(t,e){}dispose(){}},zi=class extends nn{constructor(t="",e=new ps){super(s=>new vn(s),t,e)}},Wi=L.newFloatArray(8),Gi=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),Wi,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 T=d.width/f.originalWidth;s.scale(T*d.scaleX,T*d.scaleY);let y=f.width,v=f.height;if(s.translate(y/2,v/2),f.degrees===90){const S=y;y=v,v=S,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,T=l[b+2]*8,y=c[x],v=c[x+1],S=c[x+6],A=c[x+7],I=c[w],M=c[w+1],Y=c[w+6],F=c[w+7],E=c[T],X=c[T+1],V=c[T+6],N=c[T+7];this.drawTriangle(f,y,v,S,A,I,M,Y,F,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,T=(l*h-m*a)*b,y=(l*d-m*c)*b,v=s-x*i-T*r,S=n-w*i-y*r;f.save(),f.transform(x,w,T,y,v,S),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}};return Un(qs)})();