@galacean/engine-spine 4.2.0-beta.1 → 4.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/loader/SpineResource.d.ts +32 -0
- package/types/spine-core/Animation.d.ts +378 -0
- package/types/spine-core/AnimationState.d.ts +365 -0
- package/types/spine-core/AnimationStateData.d.ts +23 -0
- package/types/spine-core/AssetManager.d.ts +36 -0
- package/types/spine-core/AtlasAttachmentLoader.d.ts +23 -0
- package/types/spine-core/BlendMode.d.ts +7 -0
- package/types/spine-core/Bone.d.ts +110 -0
- package/types/spine-core/BoneData.d.ts +44 -0
- package/types/spine-core/ConstraintData.d.ts +7 -0
- package/types/spine-core/Event.d.ts +16 -0
- package/types/spine-core/EventData.d.ts +13 -0
- package/types/spine-core/IkConstraint.d.ts +38 -0
- package/types/spine-core/IkConstraintData.d.ts +26 -0
- package/types/spine-core/PathConstraint.d.ts +46 -0
- package/types/spine-core/PathConstraintData.d.ts +52 -0
- package/types/spine-core/SharedAssetManager.d.ts +19 -0
- package/types/spine-core/Skeleton.d.ts +134 -0
- package/types/spine-core/SkeletonBinary.d.ts +49 -0
- package/types/spine-core/SkeletonBounds.d.ts +48 -0
- package/types/spine-core/SkeletonClipping.d.ts +22 -0
- package/types/spine-core/SkeletonData.d.ts +89 -0
- package/types/spine-core/SkeletonJson.d.ts +34 -0
- package/types/spine-core/Skin.d.ts +43 -0
- package/types/spine-core/Slot.d.ts +42 -0
- package/types/spine-core/SlotData.d.ts +23 -0
- package/types/spine-core/Texture.d.ts +43 -0
- package/types/spine-core/TextureAtlas.d.ts +30 -0
- package/types/spine-core/TransformConstraint.d.ts +36 -0
- package/types/spine-core/TransformConstraintData.d.ts +34 -0
- package/types/spine-core/Triangulator.d.ts +14 -0
- package/types/spine-core/Updatable.d.ts +9 -0
- package/types/spine-core/Utils.d.ts +124 -0
- package/types/spine-core/VertexEffect.d.ts +7 -0
- package/types/spine-core/attachments/Attachment.d.ts +43 -0
- package/types/spine-core/attachments/AttachmentLoader.d.ts +25 -0
- package/types/spine-core/attachments/AttachmentType.d.ts +9 -0
- package/types/spine-core/attachments/BoundingBoxAttachment.d.ts +12 -0
- package/types/spine-core/attachments/ClippingAttachment.d.ts +14 -0
- package/types/spine-core/attachments/MeshAttachment.d.ts +46 -0
- package/types/spine-core/attachments/PathAttachment.d.ts +19 -0
- package/types/spine-core/attachments/PointAttachment.d.ts +20 -0
- package/types/spine-core/attachments/RegionAttachment.d.ts +88 -0
- package/types/spine-core/index.d.ts +45 -0
- package/types/spine-core/polyfills.d.ts +1 -0
- package/types/spine-core/vertexeffects/JitterEffect.d.ts +11 -0
- package/types/spine-core/vertexeffects/SwirlEffect.d.ts +16 -0
- package/types/util/AttachmentTools.d.ts +3 -0
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.Spine={}),t.Galacean)}(this,(function(t,e){"use strict";function s(t,e,s,i){var n,a=arguments.length,r=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(r=(a<3?n(r):a>3?n(e,s,r):n(e,s))||r);return a>3&&r&&Object.defineProperty(e,s,r),r}"function"==typeof SuppressedError&&SuppressedError;class i{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,!e&&(this.size++,!0)}addAll(t){let e=this.size;for(var s=0,i=t.length;s<i;s++)this.add(t[s]);return e!=this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}}class n{r;g;b;a;static WHITE=new n(1,1,1,1);static RED=new n(1,0,0,1);static GREEN=new n(0,1,0,1);static BLUE=new n(0,0,1,1);static MAGENTA=new n(1,0,1,1);constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=8!=t.length?1:parseInt(t.substr(6,2),16)/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,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(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255}static rgb888ToColor(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255}toRgb888(){const t=t=>("0"+(255*t).toString(16)).slice(-2);return Number("0x"+t(this.r)+t(this.g)+t(this.b))}static fromString(t){return(new n).setFromString(t)}}class a{static PI=3.1415927;static PI2=2*a.PI;static invPI2=1/a.PI2;static radiansToDegrees=180/a.PI;static radDeg=a.radiansToDegrees;static degreesToRadians=a.PI/180;static degRad=a.degreesToRadians;static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(t){return Math.cos(t*a.degRad)}static sinDeg(t){return Math.sin(t*a.degRad)}static atan2Deg(t,e){return Math.atan2(t,e)*a.degRad}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){let e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(t,e){return a.randomTriangularWith(t,e,.5*(t+e))}static randomTriangularWith(t,e,s){let i=Math.random(),n=e-t;return i<=(s-t)/n?t+Math.sqrt(i*n*(s-t)):e-Math.sqrt((1-i)*n*(e-s))}static isPowerOfTwo(t){return t&&!(t&t-1)}}class r{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class o extends r{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1}}class l{static SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array;static arrayCopy(t,e,s,i,n){for(let a=e,r=i;a<e+n;a++,r++)s[r]=t[a]}static arrayFill(t,e,s,i){for(let n=e;n<s;n++)t[n]=i}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let n=i;n<e;n++)t[n]=s;return t}static ensureArrayCapacity(t,e,s=0){return t.length>=e?t:l.setArraySize(t,e,s)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static newShortArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static toFloatArray(t){return l.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return l.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t,e){}static contains(t,e,s=!0){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1}static enumValue(t,e){return t[e[0].toUpperCase()+e.slice(1)]}}class h{items=new Array;instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&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}}class c{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class d{name;constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}}class u extends d{static nextID=0;id=u.nextID++;bones=null;vertices=[];worldVerticesLength=0;timelineAttachment=this;constructor(t){super(t)}computeWorldVertices(t,e,s,i,n,a){s=n+(s>>1)*a;let r=t.bone.skeleton,o=t.deform,l=this.vertices,h=this.bones;if(!h){o.length>0&&(l=o);let r=t.bone,h=r.worldX,c=r.worldY,d=r.a,u=r.b,m=r.c,f=r.d;for(let t=e,r=n;r<s;t+=2,r+=a){let e=l[t],s=l[t+1];i[r]=e*d+s*u+h,i[r+1]=e*m+s*f+c}return}let c=0,d=0;for(let t=0;t<e;t+=2){let t=h[c];c+=t+1,d+=t}let u=r.bones;if(0==o.length)for(let t=n,e=3*d;t<s;t+=a){let s=0,n=0,a=h[c++];for(a+=c;c<a;c++,e+=3){let t=u[h[c]],i=l[e],a=l[e+1],r=l[e+2];s+=(i*t.a+a*t.b+t.worldX)*r,n+=(i*t.c+a*t.d+t.worldY)*r}i[t]=s,i[t+1]=n}else{let t=o;for(let e=n,r=3*d,o=d<<1;e<s;e+=a){let s=0,n=0,a=h[c++];for(a+=c;c<a;c++,r+=3,o+=2){let e=u[h[c]],i=l[r]+t[o],a=l[r+1]+t[o+1],d=l[r+2];s+=(i*e.a+a*e.b+e.worldX)*d,n+=(i*e.c+a*e.d+e.worldY)*d}i[e]=s,i[e+1]=n}}}copyTo(t){this.bones?(t.bones=new Array(this.bones.length),l.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=l.newFloatArray(this.vertices.length),l.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment}}class m{static _nextID=0;id=m.nextID();regions;start=0;digits=0;setupIndex=0;constructor(t){this.regions=new Array(t)}copy(){let t=new m(this.regions.length);return l.arrayCopy(this.regions,0,t.regions,0,this.regions.length),t.start=this.start,t.digits=this.digits,t.setupIndex=this.setupIndex,t}apply(t,e){let s=t.sequenceIndex;-1==s&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1);let i=this.regions[s];e.region!=i&&(e.region=i,e.updateRegion())}getPath(t,e){let s=t,i=(this.start+e).toString();for(let t=this.digits-i.length;t>0;t--)s+="0";return s+=i,s}static nextID(){return m._nextID++}}var f;!function(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"}(f||(f={}));const p=[f.hold,f.once,f.loop,f.pingpong,f.onceReverse,f.loopReverse,f.pingpongReverse];class g{name;timelines=[];timelineIds=new i;duration;constructor(t,e,s){if(!t)throw new Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=s}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e<t.length;e++)this.timelineIds.addAll(t[e].getPropertyIds())}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,i,n,a,r,o){if(!t)throw new Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let i=0,h=l.length;i<h;i++)l[i].apply(t,e,s,n,a,r,o)}}var x,w;t.MixBlend=void 0,(x=t.MixBlend||(t.MixBlend={}))[x.setup=0]="setup",x[x.first=1]="first",x[x.replace=2]="replace",x[x.add=3]="add",t.MixDirection=void 0,(w=t.MixDirection||(t.MixDirection={}))[w.mixIn=0]="mixIn",w[w.mixOut=1]="mixOut";const b={rotate:0,x:1,y:2,scaleX:3,scaleY:4,shearX:5,shearY:6,inherit:7,rgb:8,alpha:9,rgb2:10,attachment:11,deform:12,event:13,drawOrder:14,ikConstraint:15,transformConstraint:16,pathConstraintPosition:17,pathConstraintSpacing:18,pathConstraintMix:19,physicsConstraintInertia:20,physicsConstraintStrength:21,physicsConstraintDamping:22,physicsConstraintMass:23,physicsConstraintWind:24,physicsConstraintGravity:25,physicsConstraintMix:26,physicsConstraintReset:27,sequence:28};class y{propertyIds;frames;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 search1(t,e){let s=t.length;for(let i=1;i<s;i++)if(t[i]>e)return i-1;return s-1}static search(t,e,s){let i=t.length;for(let n=s;n<i;n+=s)if(t[n]>e)return n-s;return i-s}}class M extends y{curves;constructor(t,e,s){super(t,s),this.curves=l.newFloatArray(t+18*e),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){let e=this.getFrameCount()+18*t;if(this.curves.length>e){let t=l.newFloatArray(e);l.arrayCopy(this.curves,0,t,0,e),this.curves=t}}setBezier(t,e,s,i,n,a,r,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*a+o),f=.03*(n-2*r+l),p=.006*(3*(a-o)-i+h),g=.006*(3*(r-l)-n+c),x=2*m+p,w=2*f+g,b=.3*(a-i)+m+.16666667*p,y=.3*(r-n)+f+.16666667*g,M=i+b,S=n+y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getBezierValue(t,e,s,i){let n=this.curves;if(n[i]>t){let a=this.frames[e],r=this.frames[e+s];return r+(t-a)/(n[i]-a)*(n[i+1]-r)}let a=i+18;for(i+=2;i<a;i+=2)if(n[i]>=t){let e=n[i-2],s=n[i-1];return s+(t-e)/(n[i]-e)*(n[i+1]-s)}e+=this.getFrameEntries();let r=n[a-2],o=n[a-1];return o+(t-r)/(this.frames[e]-r)*(this.frames[e+s]-o)}}class S extends M{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){let e=this.frames,s=e.length-2;for(let i=2;i<=s;i+=2)if(e[i]>t){s=i-2;break}let i=this.curves[s>>1];switch(i){case 0:let i=e[s],n=e[s+1];return n+(t-i)/(e[s+2]-i)*(e[s+2+1]-n);case 1:return e[s+1]}return this.getBezierValue(t,s,1,i-2)}getRelativeValue(e,s,i,n,a){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}let r=this.getCurveValue(e);switch(i){case t.MixBlend.setup:return a+r*s;case t.MixBlend.first:case t.MixBlend.replace:r+=a-n}return n+r*s}getAbsoluteValue(e,s,i,n,a){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}let r=this.getCurveValue(e);return i==t.MixBlend.setup?a+(r-a)*s:n+(r-n)*s}getAbsoluteValue2(e,s,i,n,a,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}return i==t.MixBlend.setup?a+(r-a)*s:n+(r-n)*s}getScaleValue(e,s,i,n,r,o){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return o;case t.MixBlend.first:return r+(o-r)*s}return r}let l=this.getCurveValue(e)*o;if(1==s)return i==t.MixBlend.add?r+l-o:l;if(n==t.MixDirection.mixOut)switch(i){case t.MixBlend.setup:return o+(Math.abs(l)*a.signum(o)-o)*s;case t.MixBlend.first:case t.MixBlend.replace:return r+(Math.abs(l)*a.signum(r)-r)*s}else{let e=0;switch(i){case t.MixBlend.setup:return e=Math.abs(o)*a.signum(l),e+(l-e)*s;case t.MixBlend.first:case t.MixBlend.replace:return e=Math.abs(r)*a.signum(l),e+(l-e)*s}}return r+(l-o)*s}}class v extends M{constructor(t,e,s,i){super(t,e,[s,i])}getFrameEntries(){return 3}setFrame(t,e,s,i){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i}}class k extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.rotate+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.rotation=this.getRelativeValue(s,n,a,o.rotation,o.data.rotation))}}class I extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s,b.y+"|"+s),this.boneIndex=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.x=l.data.x,void(l.y=l.data.y);case t.MixBlend.first:l.x+=(l.data.x-l.x)*a,l.y+=(l.data.y-l.y)*a}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(r){case t.MixBlend.setup:l.x=l.data.x+c*a,l.y=l.data.y+d*a;break;case t.MixBlend.first:case t.MixBlend.replace:l.x+=(l.data.x+c-l.x)*a,l.y+=(l.data.y+d-l.y)*a;break;case t.MixBlend.add:l.x+=c*a,l.y+=d*a}}}class A extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.x=this.getRelativeValue(s,n,a,o.x,o.data.x))}}class T extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.y+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.y=this.getRelativeValue(s,n,a,o.y,o.data.y))}}class B extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s,b.scaleY+"|"+s),this.boneIndex=s}apply(e,s,i,n,r,o,l){let h=e.bones[this.boneIndex];if(!h.active)return;let c,d,u=this.frames;if(i<u[0]){switch(o){case t.MixBlend.setup:return h.scaleX=h.data.scaleX,void(h.scaleY=h.data.scaleY);case t.MixBlend.first:h.scaleX+=(h.data.scaleX-h.scaleX)*r,h.scaleY+=(h.data.scaleY-h.scaleY)*r}return}let m=y.search(u,i,3),f=this.curves[m/3];switch(f){case 0:let t=u[m];c=u[m+1],d=u[m+2];let e=(i-t)/(u[m+3]-t);c+=(u[m+3+1]-c)*e,d+=(u[m+3+2]-d)*e;break;case 1:c=u[m+1],d=u[m+2];break;default:c=this.getBezierValue(i,m,1,f-2),d=this.getBezierValue(i,m,2,f+18-2)}if(c*=h.data.scaleX,d*=h.data.scaleY,1==r)o==t.MixBlend.add?(h.scaleX+=c-h.data.scaleX,h.scaleY+=d-h.data.scaleY):(h.scaleX=c,h.scaleY=d);else{let e=0,s=0;if(l==t.MixDirection.mixOut)switch(o){case t.MixBlend.setup:e=h.data.scaleX,s=h.data.scaleY,h.scaleX=e+(Math.abs(c)*a.signum(e)-e)*r,h.scaleY=s+(Math.abs(d)*a.signum(s)-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=h.scaleX,s=h.scaleY,h.scaleX=e+(Math.abs(c)*a.signum(e)-e)*r,h.scaleY=s+(Math.abs(d)*a.signum(s)-s)*r;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*r,h.scaleY+=(d-h.data.scaleY)*r}else switch(o){case t.MixBlend.setup:e=Math.abs(h.data.scaleX)*a.signum(c),s=Math.abs(h.data.scaleY)*a.signum(d),h.scaleX=e+(c-e)*r,h.scaleY=s+(d-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=Math.abs(h.scaleX)*a.signum(c),s=Math.abs(h.scaleY)*a.signum(d),h.scaleX=e+(c-e)*r,h.scaleY=s+(d-s)*r;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*r,h.scaleY+=(d-h.data.scaleY)*r}}}}class C extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.scaleX=this.getScaleValue(s,n,a,r,o.scaleX,o.data.scaleX))}}class F extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.scaleY=this.getScaleValue(s,n,a,r,o.scaleY,o.data.scaleY))}}class E extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s,b.shearY+"|"+s),this.boneIndex=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case t.MixBlend.first:l.shearX+=(l.data.shearX-l.shearX)*a,l.shearY+=(l.data.shearY-l.shearY)*a}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(r){case t.MixBlend.setup:l.shearX=l.data.shearX+c*a,l.shearY=l.data.shearY+d*a;break;case t.MixBlend.first:case t.MixBlend.replace:l.shearX+=(l.data.shearX+c-l.shearX)*a,l.shearY+=(l.data.shearY+d-l.shearY)*a;break;case t.MixBlend.add:l.shearX+=c*a,l.shearY+=d*a}}}class R extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.shearX=this.getRelativeValue(s,n,a,o.shearX,o.data.shearX))}}class Y extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.shearY=this.getRelativeValue(s,n,a,o.shearY,o.data.shearY))}}class P extends y{boneIndex=0;constructor(t,e){super(t,[b.inherit+"|"+e]),this.boneIndex=e}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;i<h[0]?r!=t.MixBlend.setup&&r!=t.MixBlend.first||(l.inherit=l.data.inherit):l.inherit=this.frames[y.search(h,i,2)+1]}}class X extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s]),this.slotIndex=s}getFrameEntries(){return 5}setFrame(t,e,s,i,n,a){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return void c.setFromColor(e);case t.MixBlend.first:c.add((e.r-c.r)*a,(e.g-c.g)*a,(e.b-c.b)*a,(e.a-c.a)*a)}return}let d=0,u=0,m=0,f=0,p=y.search(h,i,5),g=this.curves[p/5];switch(g){case 0:let t=h[p];d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];let e=(i-t)/(h[p+5]-t);d+=(h[p+5+1]-d)*e,u+=(h[p+5+2]-u)*e,m+=(h[p+5+3]-m)*e,f+=(h[p+5+4]-f)*e;break;case 1:d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];break;default:d=this.getBezierValue(i,p,1,g-2),u=this.getBezierValue(i,p,2,g+18-2),m=this.getBezierValue(i,p,3,g+36-2),f=this.getBezierValue(i,p,4,g+54-2)}1==a?c.set(d,u,m,f):(r==t.MixBlend.setup&&c.setFromColor(l.data.color),c.add((d-c.r)*a,(u-c.g)*a,(m-c.b)*a,(f-c.a)*a))}}class _ extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s]),this.slotIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,void(c.b=e.b);case t.MixBlend.first:c.r+=(e.r-c.r)*a,c.g+=(e.g-c.g)*a,c.b+=(e.b-c.b)*a}return}let d=0,u=0,m=0,f=y.search(h,i,4),p=this.curves[f>>2];switch(p){case 0:let t=h[f];d=h[f+1],u=h[f+2],m=h[f+3];let e=(i-t)/(h[f+4]-t);d+=(h[f+4+1]-d)*e,u+=(h[f+4+2]-u)*e,m+=(h[f+4+3]-m)*e;break;case 1:d=h[f+1],u=h[f+2],m=h[f+3];break;default:d=this.getBezierValue(i,f,1,p-2),u=this.getBezierValue(i,f,2,p+18-2),m=this.getBezierValue(i,f,3,p+36-2)}if(1==a)c.r=d,c.g=u,c.b=m;else{if(r==t.MixBlend.setup){let t=l.data.color;c.r=t.r,c.g=t.g,c.b=t.b}c.r+=(d-c.r)*a,c.g+=(u-c.g)*a,c.b+=(m-c.b)*a}}}class V extends S{slotIndex=0;constructor(t,e,s){super(t,e,b.alpha+"|"+s),this.slotIndex=s}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.color;if(i<this.frames[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return void(h.a=e.a);case t.MixBlend.first:h.a+=(e.a-h.a)*a}return}let c=this.getCurveValue(i);1==a?h.a=c:(r==t.MixBlend.setup&&(h.a=l.data.color.a),h.a+=(c-h.a)*a)}}class D extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 8}setFrame(t,e,s,i,n,a,r,o,l){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a,this.frames[t+5]=r,this.frames[t+6]=o,this.frames[t+7]=l}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(r){case t.MixBlend.setup:return c.setFromColor(e),d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.add((e.r-c.r)*a,(e.g-c.g)*a,(e.b-c.b)*a,(e.a-c.a)*a),d.r+=(s.r-d.r)*a,d.g+=(s.g-d.g)*a,d.b+=(s.b-d.b)*a}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=0,b=y.search(h,i,8),M=this.curves[b>>3];switch(M){case 0:let t=h[b];u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];let e=(i-t)/(h[b+8]-t);u+=(h[b+8+1]-u)*e,m+=(h[b+8+2]-m)*e,f+=(h[b+8+3]-f)*e,p+=(h[b+8+4]-p)*e,g+=(h[b+8+5]-g)*e,x+=(h[b+8+6]-x)*e,w+=(h[b+8+7]-w)*e;break;case 1:u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];break;default:u=this.getBezierValue(i,b,1,M-2),m=this.getBezierValue(i,b,2,M+18-2),f=this.getBezierValue(i,b,3,M+36-2),p=this.getBezierValue(i,b,4,M+54-2),g=this.getBezierValue(i,b,5,M+72-2),x=this.getBezierValue(i,b,6,M+90-2),w=this.getBezierValue(i,b,7,M+108-2)}if(1==a)c.set(u,m,f,p),d.r=g,d.g=x,d.b=w;else{if(r==t.MixBlend.setup){c.setFromColor(l.data.color);let t=l.data.darkColor;d.r=t.r,d.g=t.g,d.b=t.b}c.add((u-c.r)*a,(m-c.g)*a,(f-c.b)*a,(p-c.a)*a),d.r+=(g-d.r)*a,d.g+=(x-d.g)*a,d.b+=(w-d.b)*a}}}class O extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,a,r,o){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a,this.frames[t+5]=r,this.frames[t+6]=o}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(r){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,c.b=e.b,d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.r+=(e.r-c.r)*a,c.g+=(e.g-c.g)*a,c.b+=(e.b-c.b)*a,d.r+=(s.r-d.r)*a,d.g+=(s.g-d.g)*a,d.b+=(s.b-d.b)*a}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=y.search(h,i,7),b=this.curves[w/7];switch(b){case 0:let t=h[w];u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];let e=(i-t)/(h[w+7]-t);u+=(h[w+7+1]-u)*e,m+=(h[w+7+2]-m)*e,f+=(h[w+7+3]-f)*e,p+=(h[w+7+4]-p)*e,g+=(h[w+7+5]-g)*e,x+=(h[w+7+6]-x)*e;break;case 1:u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];break;default:u=this.getBezierValue(i,w,1,b-2),m=this.getBezierValue(i,w,2,b+18-2),f=this.getBezierValue(i,w,3,b+36-2),p=this.getBezierValue(i,w,4,b+54-2),g=this.getBezierValue(i,w,5,b+72-2),x=this.getBezierValue(i,w,6,b+90-2)}if(1==a)c.r=u,c.g=m,c.b=f,d.r=p,d.g=g,d.b=x;else{if(r==t.MixBlend.setup){let t=l.data.color,e=l.data.darkColor;c.r=t.r,c.g=t.g,c.b=t.b,d.r=e.r,d.g=e.g,d.b=e.b}c.r+=(u-c.r)*a,c.g+=(m-c.g)*a,c.b+=(f-c.b)*a,d.r+=(p-d.r)*a,d.g+=(g-d.g)*a,d.b+=(x-d.b)*a}}}class N extends y{slotIndex=0;attachmentNames;constructor(t,e){super(t,[b.attachment+"|"+e]),this.slotIndex=e,this.attachmentNames=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];l.bone.active&&(o!=t.MixDirection.mixOut?i<this.frames[0]?r!=t.MixBlend.setup&&r!=t.MixBlend.first||this.setAttachment(e,l,l.data.attachmentName):this.setAttachment(e,l,this.attachmentNames[y.search1(this.frames,i)]):r==t.MixBlend.setup&&this.setAttachment(e,l,l.data.attachmentName))}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}}class L extends M{slotIndex=0;attachment;vertices;constructor(t,e,s,i){super(t,e,[b.deform+"|"+s+"|"+i.id]),this.slotIndex=s,this.attachment=i,this.vertices=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,i,n,a,r,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*a+o),f=.03*l-.06*r,p=.006*(3*(a-o)-i+h),g=.018*(r-l+.33333333),x=2*m+p,w=2*f+g,b=.3*(a-i)+m+.16666667*p,y=.3*r+f+.16666667*g,M=i+b,S=y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getCurvePercent(t,e){let s=this.curves,i=s[e];switch(i){case 0:let s=this.frames[e];return(t-s)/(this.frames[e+this.getFrameEntries()]-s);case 1:return 0}if(i-=2,s[i]>t){let n=this.frames[e];return s[i+1]*(t-n)/(s[i]-n)}let n=i+18;for(i+=2;i<n;i+=2)if(s[i]>=t){let e=s[i-2],n=s[i-1];return n+(t-e)/(s[i]-e)*(s[i+1]-n)}let a=s[n-2],r=s[n-1];return r+(1-r)*(t-a)/(this.frames[e+this.getFrameEntries()]-a)}apply(e,s,i,n,a,r,o){let h=e.slots[this.slotIndex];if(!h.bone.active)return;let c=h.getAttachment();if(!c)return;if(!(c instanceof u)||c.timelineAttachment!=this.attachment)return;let d=h.deform;0==d.length&&(r=t.MixBlend.setup);let m=this.vertices,f=m[0].length,p=this.frames;if(i<p[0]){switch(r){case t.MixBlend.setup:return void(d.length=0);case t.MixBlend.first:if(1==a)return void(d.length=0);d.length=f;let e=c;if(e.bones){a=1-a;for(g=0;g<f;g++)d[g]*=a}else{let t=e.vertices;for(var g=0;g<f;g++)d[g]+=(t[g]-d[g])*a}}return}if(d.length=f,i>=p[p.length-1]){let e=m[p.length-1];if(1==a)if(r==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]+=e[t];else{let s=t.vertices;for(let t=0;t<f;t++)d[t]+=e[t]-s[t]}}else l.arrayCopy(e,0,d,0,f);else switch(r){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]=e[t]*a;else{let s=t.vertices;for(let t=0;t<f;t++){let i=s[t];d[t]=i+(e[t]-i)*a}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++)d[t]+=(e[t]-d[t])*a;break;case t.MixBlend.add:let s=c;if(s.bones)for(let t=0;t<f;t++)d[t]+=e[t]*a;else{let t=s.vertices;for(let s=0;s<f;s++)d[s]+=(e[s]-t[s])*a}}return}let x=y.search1(p,i),w=this.getCurvePercent(i,x),b=m[x],M=m[x+1];if(1==a)if(r==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=e+(M[t]-e)*w}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t];d[t]+=s+(M[t]-s)*w-e[t]}}}else for(let t=0;t<f;t++){let e=b[t];d[t]=e+(M[t]-e)*w}else switch(r){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]=(e+(M[t]-e)*w)*a}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t],i=e[t];d[t]=i+(s+(M[t]-s)*w-i)*a}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w-d[t])*a}break;case t.MixBlend.add:let e=c;if(e.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w)*a}else{let t=e.vertices;for(let e=0;e<f;e++){let s=b[e];d[e]+=(s+(M[e]-s)*w-t[e])*a}}}}}class q extends y{static propertyIds=[""+b.event];events;constructor(t){super(t,q.propertyIds),this.events=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,n,a,r){if(!i)return;let o=this.frames,l=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,n,a,r),e=-1;else if(e>=o[l-1])return;if(s<o[0])return;let h=0;if(e<o[0])h=0;else{h=y.search1(o,e)+1;let t=o[h];for(;h>0&&o[h-1]==t;)h--}for(;h<l&&s>=o[h];h++)i.push(this.events[h])}}class U extends y{static propertyIds=[""+b.drawOrder];drawOrders;constructor(t){super(t,U.propertyIds),this.drawOrders=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(e,s,i,n,a,r,o){if(o==t.MixDirection.mixOut)return void(r==t.MixBlend.setup&&l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));if(i<this.frames[0])return void(r!=t.MixBlend.setup&&r!=t.MixBlend.first||l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));let h=y.search1(this.frames,i),c=this.drawOrders[h];if(c){let t=e.drawOrder,s=e.slots;for(let e=0,i=c.length;e<i;e++)t[e]=s[c[e]]}else l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length)}}class W extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.ikConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,i,n,a,r){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a?1:0,this.frames[t+5]=r?1:0}apply(e,s,i,n,a,r,o){let l=e.ikConstraints[this.constraintIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.mix=l.data.mix,l.softness=l.data.softness,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,void(l.stretch=l.data.stretch);case t.MixBlend.first:l.mix+=(l.data.mix-l.mix)*a,l.softness+=(l.data.softness-l.softness)*a,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch}return}let c=0,d=0,u=y.search(h,i,6),m=this.curves[u/6];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+6]-t);c+=(h[u+6+1]-c)*e,d+=(h[u+6+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}r==t.MixBlend.setup?(l.mix=l.data.mix+(c-l.data.mix)*a,l.softness=l.data.softness+(d-l.data.softness)*a,o==t.MixDirection.mixOut?(l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch):(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5])):(l.mix+=(c-l.mix)*a,l.softness+=(d-l.softness)*a,o==t.MixDirection.mixIn&&(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5]))}}class z extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.transformConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,a,r,o){let l=this.frames;l[t*=7]=e,l[t+1]=s,l[t+2]=i,l[t+3]=n,l[t+4]=a,l[t+5]=r,l[t+6]=o}apply(e,s,i,n,a,r,o){let l=e.transformConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u,m,f,p=this.frames;if(i<p[0]){let e=l.data;switch(r){case t.MixBlend.setup:return l.mixRotate=e.mixRotate,l.mixX=e.mixX,l.mixY=e.mixY,l.mixScaleX=e.mixScaleX,l.mixScaleY=e.mixScaleY,void(l.mixShearY=e.mixShearY);case t.MixBlend.first:l.mixRotate+=(e.mixRotate-l.mixRotate)*a,l.mixX+=(e.mixX-l.mixX)*a,l.mixY+=(e.mixY-l.mixY)*a,l.mixScaleX+=(e.mixScaleX-l.mixScaleX)*a,l.mixScaleY+=(e.mixScaleY-l.mixScaleY)*a,l.mixShearY+=(e.mixShearY-l.mixShearY)*a}return}let g=y.search(p,i,7),x=this.curves[g/7];switch(x){case 0:let t=p[g];h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];let e=(i-t)/(p[g+7]-t);h+=(p[g+7+1]-h)*e,c+=(p[g+7+2]-c)*e,d+=(p[g+7+3]-d)*e,u+=(p[g+7+4]-u)*e,m+=(p[g+7+5]-m)*e,f+=(p[g+7+6]-f)*e;break;case 1:h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];break;default:h=this.getBezierValue(i,g,1,x-2),c=this.getBezierValue(i,g,2,x+18-2),d=this.getBezierValue(i,g,3,x+36-2),u=this.getBezierValue(i,g,4,x+54-2),m=this.getBezierValue(i,g,5,x+72-2),f=this.getBezierValue(i,g,6,x+90-2)}if(r==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*a,l.mixX=t.mixX+(c-t.mixX)*a,l.mixY=t.mixY+(d-t.mixY)*a,l.mixScaleX=t.mixScaleX+(u-t.mixScaleX)*a,l.mixScaleY=t.mixScaleY+(m-t.mixScaleY)*a,l.mixShearY=t.mixShearY+(f-t.mixShearY)*a}else l.mixRotate+=(h-l.mixRotate)*a,l.mixX+=(c-l.mixX)*a,l.mixY+=(d-l.mixY)*a,l.mixScaleX+=(u-l.mixScaleX)*a,l.mixScaleY+=(m-l.mixScaleY)*a,l.mixShearY+=(f-l.mixShearY)*a}}class G extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintPosition+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.position=this.getAbsoluteValue(s,n,a,o.position,o.data.position))}}class $ extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintSpacing+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.spacing=this.getAbsoluteValue(s,n,a,o.spacing,o.data.spacing))}}class j extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.pathConstraintMix+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){let a=this.frames;a[t<<=2]=e,a[t+1]=s,a[t+2]=i,a[t+3]=n}apply(e,s,i,n,a,r,o){let l=e.pathConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u=this.frames;if(i<u[0]){switch(r){case t.MixBlend.setup:return l.mixRotate=l.data.mixRotate,l.mixX=l.data.mixX,void(l.mixY=l.data.mixY);case t.MixBlend.first:l.mixRotate+=(l.data.mixRotate-l.mixRotate)*a,l.mixX+=(l.data.mixX-l.mixX)*a,l.mixY+=(l.data.mixY-l.mixY)*a}return}let m=y.search(u,i,4),f=this.curves[m>>2];switch(f){case 0:let t=u[m];h=u[m+1],c=u[m+2],d=u[m+3];let e=(i-t)/(u[m+4]-t);h+=(u[m+4+1]-h)*e,c+=(u[m+4+2]-c)*e,d+=(u[m+4+3]-d)*e;break;case 1:h=u[m+1],c=u[m+2],d=u[m+3];break;default:h=this.getBezierValue(i,m,1,f-2),c=this.getBezierValue(i,m,2,f+18-2),d=this.getBezierValue(i,m,3,f+36-2)}if(r==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*a,l.mixX=t.mixX+(c-t.mixX)*a,l.mixY=t.mixY+(d-t.mixY)*a}else l.mixRotate+=(h-l.mixRotate)*a,l.mixX+=(c-l.mixX)*a,l.mixY+=(d-l.mixY)*a}}class H extends S{constraintIndex=0;constructor(t,e,s,i){super(t,e,i+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o;if(-1==this.constraintIndex){const e=s>=this.frames[0]?this.getCurveValue(s):0;for(const i of t.physicsConstraints)i.active&&this.global(i.data)&&this.set(i,this.getAbsoluteValue2(s,n,a,this.get(i),this.setup(i),e))}else o=t.physicsConstraints[this.constraintIndex],o.active&&this.set(o,this.getAbsoluteValue(s,n,a,this.get(o),this.setup(o)))}}class J extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintInertia)}setup(t){return t.data.inertia}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}}class K extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintStrength)}setup(t){return t.data.strength}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}}class Q extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintDamping)}setup(t){return t.data.damping}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}}class Z extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMass)}setup(t){return 1/t.data.massInverse}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}}class tt extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintWind)}setup(t){return t.data.wind}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}}class et extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintGravity)}setup(t){return t.data.gravity}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}}class st extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMix)}setup(t){return t.data.mix}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}}class it extends y{static propertyIds=[b.physicsConstraintReset.toString()];constraintIndex;constructor(t,e){super(t,it.propertyIds),this.constraintIndex=e}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e}apply(t,e,s,i,n,a,r){let o;if(-1!=this.constraintIndex&&(o=t.physicsConstraints[this.constraintIndex],!o.active))return;const l=this.frames;if(e>s)this.apply(t,e,Number.MAX_VALUE,[],n,a,r),e=-1;else if(e>=l[l.length-1])return;if(!(s<l[0])&&(e<l[0]||s>=l[y.search1(l,e)+1]))if(null!=o)o.reset();else for(const e of t.physicsConstraints)e.active&&e.reset()}}class nt extends y{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(t,e,s){super(t,[b.sequence+"|"+e+"|"+s.sequence.id]),this.slotIndex=e,this.attachment=s}getFrameEntries(){return nt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(t,e,s,i,n){let a=this.frames;a[t*=nt.ENTRIES]=e,a[t+nt.MODE]=s|i<<4,a[t+nt.DELAY]=n}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.attachment,c=this.attachment;if(!(h==c||h instanceof u&&h.timelineAttachment==c))return;let d=this.frames;if(i<d[0])return void(r!=t.MixBlend.setup&&r!=t.MixBlend.first||(l.sequenceIndex=-1));let m=y.search(d,i,nt.ENTRIES),g=d[m],x=d[m+nt.MODE],w=d[m+nt.DELAY];if(!this.attachment.sequence)return;let b=x>>4,M=this.attachment.sequence.regions.length,S=p[15&x];if(S!=f.hold)switch(b+=(i-g)/w+1e-5|0,S){case f.once:b=Math.min(M-1,b);break;case f.loop:b%=M;break;case f.pingpong:{let t=(M<<1)-2;b=0==t?0:b%t,b>=M&&(b=t-b);break}case f.onceReverse:b=Math.max(M-1-b,0);break;case f.loopReverse:b=M-1-b%M;break;case f.pingpongReverse:{let t=(M<<1)-2;b=0==t?0:(b+M-1)%t,b>=M&&(b=t-b)}}l.sequenceIndex=b}}class at{static _emptyAnimation=new g("<empty>",[],0);static emptyAnimation(){return at._emptyAnimation}data;tracks=new Array;timeScale=1;unkeyedState=0;events=new Array;listeners=new Array;queue=new ot(this);propertyIDs=new i;animationsChanged=!1;trackEntryPool=new h((()=>new rt));constructor(t){this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(!i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let n=t*i.timeScale;if(i.delay>0){if(i.delay-=n,i.delay>0)continue;n=-i.delay,i.delay=0}let a=i.next;if(a){let e=i.trackLast-a.delay;if(e>=0){for(a.delay=0,a.trackTime+=0==i.timeScale?0:(e/i.timeScale+t)*a.timeScale,i.trackTime+=n,this.setCurrent(s,a,!0);a.mixingFrom;)a.mixTime+=t,a=a.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&!i.mixingFrom){e[s]=null,this.queue.end(i),this.clearNext(i);continue}if(i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null,t&&(t.mixingTo=null);t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(!s)return!0;let i=this.updateMixingFrom(s,e);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,s.mixingFrom&&(s.mixingFrom.mixingTo=t),t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e,!1)}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,o=i.length;r<o;r++){let o=i[r];if(!o||o.delay>0)continue;n=!0;let h=0==r?t.MixBlend.first:o.mixBlend,c=o.alpha;o.mixingFrom?c*=this.applyMixingFrom(o,e,h):o.trackTime>=o.trackEnd&&!o.next&&(c=0);let d=c>=o.alphaAttachmentThreshold,u=o.animationLast,m=o.getAnimationTime(),f=m,p=s;o.reverse&&(f=o.animation.duration-f,p=null);let g=o.animation.timelines,x=g.length;if(0==r&&1==c||h==t.MixBlend.add){0==r&&(d=!0);for(let s=0;s<x;s++){l.webkit602BugfixHelper(c,h);var a=g[s];a instanceof N?this.applyAttachmentTimeline(a,e,f,h,d):a.apply(e,u,f,p,c,h,t.MixDirection.mixIn)}}else{let s=o.timelineMode,i=o.shortestRotation,n=!i&&o.timelinesRotation.length!=x<<1;n&&(o.timelinesRotation.length=x<<1);for(let a=0;a<x;a++){let r=g[a],m=s[a]==ht?h:t.MixBlend.setup;!i&&r instanceof k?this.applyRotateTimeline(r,e,f,c,m,o.timelinesRotation,a<<1,n):r instanceof N?this.applyAttachmentTimeline(r,e,f,h,d):(l.webkit602BugfixHelper(c,h),r.apply(e,u,f,p,c,m,t.MixDirection.mixIn))}}this.queueEvents(o,m),s.length=0,o.nextAnimationLast=m,o.nextTrackLast=o.trackTime}for(var r=this.unkeyedState+ft,o=e.slots,h=0,c=e.slots.length;h<c;h++){var d=o[h];if(d.attachmentState==r){var u=d.data.attachmentName;d.setAttachment(u?e.getAttachment(d.data.index,u):null)}}return this.unkeyedState+=2,this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;n.mixingFrom&&this.applyMixingFrom(n,s,i);let a=0;0==e.mixDuration?(a=1,i==t.MixBlend.first&&(i=t.MixBlend.setup)):(a=e.mixTime/e.mixDuration,a>1&&(a=1),i!=t.MixBlend.first&&(i=n.mixBlend));let r=a<n.mixAttachmentThreshold,o=a<n.mixDrawOrderThreshold,h=n.animation.timelines,c=h.length,d=n.alpha*e.interruptAlpha,u=d*(1-a),m=n.animationLast,f=n.getAnimationTime(),p=f,g=null;if(n.reverse?p=n.animation.duration-p:a<n.eventThreshold&&(g=this.events),i==t.MixBlend.add)for(let e=0;e<c;e++)h[e].apply(s,m,p,g,u,i,t.MixDirection.mixOut);else{let e=n.timelineMode,a=n.timelineHoldMix,f=n.shortestRotation,x=!f&&n.timelinesRotation.length!=c<<1;x&&(n.timelinesRotation.length=c<<1),n.totalAlpha=0;for(let w=0;w<c;w++){let c,b=h[w],y=t.MixDirection.mixOut,M=0;switch(e[w]){case ht:if(!o&&b instanceof U)continue;c=i,M=u;break;case ct:c=t.MixBlend.setup,M=u;break;case dt:c=i,M=d;break;case ut:c=t.MixBlend.setup,M=d;break;default:c=t.MixBlend.setup;let e=a[w];M=d*Math.max(0,1-e.mixTime/e.mixDuration)}n.totalAlpha+=M,!f&&b instanceof k?this.applyRotateTimeline(b,s,p,M,c,n.timelinesRotation,w<<1,x):b instanceof N?this.applyAttachmentTimeline(b,s,p,c,r&&M>=n.alphaAttachmentThreshold):(l.webkit602BugfixHelper(M,i),o&&b instanceof U&&c==t.MixBlend.setup&&(y=t.MixDirection.mixIn),b.apply(s,m,p,g,M,c,y))}}return e.mixDuration>0&&this.queueEvents(n,f),this.events.length=0,n.nextAnimationLast=f,n.nextTrackLast=n.trackTime,a}applyAttachmentTimeline(e,s,i,n,a){var r=s.slots[e.slotIndex];r.bone.active&&(i<e.frames[0]?n!=t.MixBlend.setup&&n!=t.MixBlend.first||this.setAttachment(s,r,r.data.attachmentName,a):this.setAttachment(s,r,e.attachmentNames[y.search1(e.frames,i)],a),r.attachmentState<=this.unkeyedState&&(r.attachmentState=this.unkeyedState+ft))}setAttachment(t,e,s,i){e.setAttachment(s?t.getAttachment(e.data.index,s):null),i&&(e.attachmentState=this.unkeyedState+pt)}applyRotateTimeline(e,s,i,n,r,o,l,h){if(h&&(o[l]=0),1==n)return void e.apply(s,0,i,null,1,r,t.MixDirection.mixIn);let c=s.bones[e.boneIndex];if(!c.active)return;let d=0,u=0;if(i<e.frames[0])switch(r){case t.MixBlend.setup:c.rotation=c.data.rotation;default:return;case t.MixBlend.first:d=c.rotation,u=c.data.rotation}else d=r==t.MixBlend.setup?c.data.rotation:c.rotation,u=c.data.rotation+e.getCurveValue(i);let m=0,f=u-d;if(f-=360*Math.ceil(f/360-.5),0==f)m=o[l];else{let t=0,e=0;h?(t=0,e=f):(t=o[l],e=o[l+1]);let s=t-t%360;m=f+s;let i=f>=0,n=t>=0;Math.abs(e)<=90&&a.signum(e)!=a.signum(f)&&(Math.abs(t-s)>180?(m+=360*a.signum(t),n=i):0!=s?m-=360*a.signum(t):n=i),n!=i&&(m+=360*a.signum(t)),o[l]=m}o[l+1]=f,c.rotation=d+m*n}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,n=i-s,a=t.trackLast%n,r=this.events,o=0,l=r.length;for(;o<l;o++){let e=r[o];if(e.time<a)break;e.time>i||this.queue.event(t,e)}let h=!1;if(t.loop)if(0==n)h=!0;else{const e=Math.floor(t.trackTime/n);h=e>0&&e>Math.floor(t.trackLast/n)}else h=e>=i&&t.animationLast<i;for(h&&this.queue.complete(t);o<l;o++){let e=r[o];e.time<s||this.queue.event(t,e)}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(!e)return;this.queue.end(e),this.clearNext(e);let s=e;for(;;){let t=s.mixingFrom;if(!t)break;this.queue.end(t),s.mixingFrom=null,s.mixingTo=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,e.previous=null,i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,i.mixingTo=e,e.mixTime=0,i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s=!1){let i=this.data.skeletonData.findAnimation(e);if(!i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s=!1){if(!e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.clearNext(n),n=n.mixingFrom,i=!1):this.clearNext(n));let a=this.trackEntry(t,e,s,n);return this.setCurrent(t,a,i),this.queue.drain(),a}addAnimation(t,e,s=!1,i=0){let n=this.data.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s=!1,i=0){if(!e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(n)for(;n.next;)n=n.next;let a=this.trackEntry(t,e,s,n);return n?(n.next=a,a.previous=n,i<=0&&(i+=n.getTrackComplete()-a.mixDuration)):(this.setCurrent(t,a,!0),this.queue.drain()),a.delay=i,a}setEmptyAnimation(t,e=0){let s=this.setAnimationWith(t,at.emptyAnimation(),!1);return s.mixDuration=e,s.trackEnd=e,s}addEmptyAnimation(t,e=0,s=0){let i=this.addAnimationWith(t,at.emptyAnimation(),!1,s);return s<=0&&(i.delay+=i.mixDuration-e),i.mixDuration=e,i.trackEnd=e,i}setEmptyAnimations(t=0){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(l.ensureArrayCapacity(this.tracks,t+1,null),this.tracks.length=t+1,null)}trackEntry(e,s,i,n){let a=this.trackEntryPool.obtain();return a.reset(),a.trackIndex=e,a.animation=s,a.loop=i,a.holdPrevious=!1,a.reverse=!1,a.shortestRotation=!1,a.eventThreshold=0,a.alphaAttachmentThreshold=0,a.mixAttachmentThreshold=0,a.mixDrawOrderThreshold=0,a.animationStart=0,a.animationEnd=s.duration,a.animationLast=-1,a.nextAnimationLast=-1,a.delay=0,a.trackTime=0,a.trackLast=-1,a.nextTrackLast=-1,a.trackEnd=Number.MAX_VALUE,a.timeScale=1,a.alpha=1,a.mixTime=0,a.mixDuration=n?this.data.getMix(n.animation,s):0,a.interruptAlpha=1,a.totalAlpha=0,a.mixBlend=t.MixBlend.replace,a}clearNext(t){let e=t.next;for(;e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1,this.propertyIDs.clear();let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do{i.mixingTo&&i.mixBlend==t.MixBlend.add||this.computeHold(i),i=i.mixingTo}while(i)}}}computeHold(t){let e=t.mixingTo,s=t.animation.timelines,i=t.animation.timelines.length,n=t.timelineMode;n.length=i;let a=t.timelineHoldMix;a.length=0;let r=this.propertyIDs;if(e&&e.holdPrevious)for(let t=0;t<i;t++)n[t]=r.addAll(s[t].getPropertyIds())?ut:dt;else t:for(let o=0;o<i;o++){let i=s[o],l=i.getPropertyIds();if(r.addAll(l))if(!e||i instanceof N||i instanceof U||i instanceof q||!e.animation.hasTimeline(l))n[o]=ct;else{for(let s=e.mixingTo;s;s=s.mixingTo)if(!s.animation.hasTimeline(l)){if(t.mixDuration>0){n[o]=mt,a[o]=s;continue t}break}n[o]=ut}else n[o]=ht}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(!t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}}class rt{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;holdPrevious=!1;reverse=!1;shortestRotation=!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;interruptAlpha=0;totalAlpha=0;get mixDuration(){return this._mixDuration}set mixDuration(t){this._mixDuration=t}setMixDurationWithDelay(t,e){this._mixDuration=t,null!=this.previous&&e<=0&&(e+=this.previous.getTrackComplete()-t),this.delay=e}mixBlend=t.MixBlend.replace;timelineMode=new Array;timelineHoldMix=new Array;timelinesRotation=new Array;reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){let t=this.animationEnd-this.animationStart;if(0!=t){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return-1!=this.nextTrackLast}isNextReady(){return null!=this.next&&this.nextTrackLast-this.next.delay>=0}}class ot{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(e){this.objects.push(t.EventType.start),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(t.EventType.interrupt),this.objects.push(e)}end(e){this.objects.push(t.EventType.end),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(t.EventType.dispose),this.objects.push(e)}complete(e){this.objects.push(t.EventType.complete),this.objects.push(e)}event(e,s){this.objects.push(t.EventType.event),this.objects.push(e),this.objects.push(s)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let e=this.objects,s=this.animState.listeners;for(let i=0;i<e.length;i+=2){let n=e[i],a=e[i+1];switch(n){case t.EventType.start:a.listener&&a.listener.start&&a.listener.start(a);for(let t=0;t<s.length;t++){let e=s[t];e.start&&e.start(a)}break;case t.EventType.interrupt:a.listener&&a.listener.interrupt&&a.listener.interrupt(a);for(let t=0;t<s.length;t++){let e=s[t];e.interrupt&&e.interrupt(a)}break;case t.EventType.end:a.listener&&a.listener.end&&a.listener.end(a);for(let t=0;t<s.length;t++){let e=s[t];e.end&&e.end(a)}case t.EventType.dispose:a.listener&&a.listener.dispose&&a.listener.dispose(a);for(let t=0;t<s.length;t++){let e=s[t];e.dispose&&e.dispose(a)}this.animState.trackEntryPool.free(a);break;case t.EventType.complete:a.listener&&a.listener.complete&&a.listener.complete(a);for(let t=0;t<s.length;t++){let e=s[t];e.complete&&e.complete(a)}break;case t.EventType.event:let n=e[2+i++];a.listener&&a.listener.event&&a.listener.event(a,n);for(let t=0;t<s.length;t++){let e=s[t];e.event&&e.event(a,n)}}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var lt;t.EventType=void 0,(lt=t.EventType||(t.EventType={}))[lt.start=0]="start",lt[lt.interrupt=1]="interrupt",lt[lt.end=2]="end",lt[lt.dispose=3]="dispose",lt[lt.complete=4]="complete",lt[lt.event=5]="event";const ht=0,ct=1,dt=2,ut=3,mt=4,ft=1,pt=2;class gt{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(!i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class xt extends u{color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new xt(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t}}class wt extends u{endSlot=null;color=new n(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){let t=new wt(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t}}class bt{_image;constructor(t){this._image=t}getImage(){return this._image}}var yt,Mt,St,vt,kt,It,At,Tt,Bt;t.TextureFilter=void 0,(yt=t.TextureFilter||(t.TextureFilter={}))[yt.Nearest=9728]="Nearest",yt[yt.Linear=9729]="Linear",yt[yt.MipMap=9987]="MipMap",yt[yt.MipMapNearestNearest=9984]="MipMapNearestNearest",yt[yt.MipMapLinearNearest=9985]="MipMapLinearNearest",yt[yt.MipMapNearestLinear=9986]="MipMapNearestLinear",yt[yt.MipMapLinearLinear=9987]="MipMapLinearLinear",t.TextureWrap=void 0,(Mt=t.TextureWrap||(t.TextureWrap={}))[Mt.MirroredRepeat=33648]="MirroredRepeat",Mt[Mt.ClampToEdge=33071]="ClampToEdge",Mt[Mt.Repeat=10497]="Repeat";class Ct{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0}class Ft{pages=new Array;regions=new Array;constructor(e){let s=new Et(e),i=new Array(4),n={size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},format:()=>{},filter:e=>{e.minFilter=l.enumValue(t.TextureFilter,i[1]),e.magFilter=l.enumValue(t.TextureFilter,i[2])},repeat:e=>{-1!=i[1].indexOf("x")&&(e.uWrap=t.TextureWrap.Repeat),-1!=i[1].indexOf("y")&&(e.vWrap=t.TextureWrap.Repeat)},pma:t=>{t.pma="true"==i[1]}};var a={xy:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2])},size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},bounds:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2]),t.width=parseInt(i[3]),t.height=parseInt(i[4])},offset:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2])},orig:t=>{t.originalWidth=parseInt(i[1]),t.originalHeight=parseInt(i[2])},offsets:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2]),t.originalWidth=parseInt(i[3]),t.originalHeight=parseInt(i[4])},rotate:t=>{let e=i[1];"true"==e?t.degrees=90:"false"!=e&&(t.degrees=parseInt(e))},index:t=>{t.index=parseInt(i[1])}};let r=s.readLine();for(;r&&0==r.trim().length;)r=s.readLine();for(;r&&0!=r.trim().length&&0!=s.readEntry(i,r);)r=s.readLine();let o=null,h=null,c=null;for(;null!==r;)if(0==r.trim().length)o=null,r=s.readLine();else if(o){let t=new Yt(o,r);for(;;){let e=s.readEntry(i,r=s.readLine());if(0==e)break;let n=a[i[0]];if(n)n(t);else{h||(h=[]),c||(c=[]),h.push(i[0]);let t=[];for(let s=0;s<e;s++)t.push(parseInt(i[s+1]));c.push(t)}}0==t.originalWidth&&0==t.originalHeight&&(t.originalWidth=t.width,t.originalHeight=t.height),h&&h.length>0&&c&&c.length>0&&(t.names=h,t.values=c,h=null,c=null),t.u=t.x/o.width,t.v=t.y/o.height,90==t.degrees?(t.u2=(t.x+t.height)/o.width,t.v2=(t.y+t.width)/o.height):(t.u2=(t.x+t.width)/o.width,t.v2=(t.y+t.height)/o.height),this.regions.push(t)}else{for(o=new Rt(r.trim());0!=s.readEntry(i,r=s.readLine());){let t=n[i[0]];t&&t(o)}this.pages.push(o)}}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(let 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()}}class Et{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)return 0;if(0==(e=e.trim()).length)return 0;let s=e.indexOf(":");if(-1==s)return 0;t[0]=e.substr(0,s).trim();for(let i=1,n=s+1;;i++){let s=e.indexOf(",",n);if(-1==s)return t[i]=e.substr(n).trim(),i;if(t[i]=e.substr(n,s-n).trim(),n=s+1,4==i)return 4}}}class Rt{name;minFilter=t.TextureFilter.Nearest;magFilter=t.TextureFilter.Nearest;uWrap=t.TextureWrap.ClampToEdge;vWrap=t.TextureWrap.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=new Array;constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(let e of this.regions)e.texture=t}}class Yt extends Ct{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)}}class Pt extends u{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new n(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new n(0,0,0,0);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.regionUVs;this.uvs&&this.uvs.length==t.length||(this.uvs=l.newFloatArray(t.length));let e=this.uvs,s=this.uvs.length,i=this.region.u,n=this.region.v,a=0,r=0;if(this.region instanceof Yt){let o=this.region,l=o.page,h=l.width,c=l.height;switch(o.degrees){case 90:i-=(o.originalHeight-o.offsetY-o.height)/h,n-=(o.originalWidth-o.offsetX-o.width)/c,a=o.originalHeight/h,r=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+t[o+1]*a,e[o+1]=n+(1-t[o])*r;return;case 180:i-=(o.originalWidth-o.offsetX-o.width)/h,n-=o.offsetY/c,a=o.originalWidth/h,r=o.originalHeight/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o])*a,e[o+1]=n+(1-t[o+1])*r;return;case 270:i-=o.offsetY/h,n-=o.offsetX/c,a=o.originalHeight/h,r=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o+1])*a,e[o+1]=n+t[o]*r;return}i-=o.offsetX/h,n-=(o.originalHeight-o.offsetY-o.height)/c,a=o.originalWidth/h,r=o.originalHeight/c}else this.region?(a=this.region.u2-i,r=this.region.v2-n):(i=n=0,a=r=1);for(let o=0;o<s;o+=2)e[o]=i+t[o]*a,e[o+1]=n+t[o+1]*r}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}copy(){if(this.parentMesh)return this.newLinkedMesh();let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=new Array(this.regionUVs.length),l.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.uvs=new Array(this.uvs.length),l.arrayCopy(this.uvs,0,t.uvs,0,this.uvs.length),t.triangles=new Array(this.triangles.length),l.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,t.sequence=null!=this.sequence?this.sequence.copy():null,this.edges&&(t.edges=new Array(this.edges.length),l.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}computeWorldVertices(t,e,s,i,n,a){null!=this.sequence&&this.sequence.apply(t,this),super.computeWorldVertices(t,e,s,i,n,a)}newLinkedMesh(){let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),t.timelineAttachment=this.timelineAttachment,t.setParentMesh(this.parentMesh?this.parentMesh:this),null!=t.region&&t.updateRegion(),t}}class Xt extends u{lengths=[];closed=!1;constantSpeed=!1;color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new Xt(this.name);return this.copyTo(t),t.lengths=new Array(this.lengths.length),l.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}}class _t extends u{x=0;y=0;rotation=0;color=new n(.38,.94,0,1);constructor(t){super(t)}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){const e=this.rotation*a.degRad,s=Math.cos(e),i=Math.sin(e),n=s*t.a+i*t.b,r=s*t.c+i*t.d;return a.atan2Deg(r,n)}copy(){let t=new _t(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t}}class Vt extends d{x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;color=new n(1,1,1,1);path;region=null;sequence=null;offset=l.newFloatArray(8);uvs=l.newFloatArray(8);tempColor=new n(1,1,1,1);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.region,e=this.uvs;if(null==t)return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=1,e[5]=1,e[6]=1,void(e[7]=0);let s=this.width/this.region.originalWidth*this.scaleX,i=this.height/this.region.originalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.region.offsetX*s,r=-this.height/2*this.scaleY+this.region.offsetY*i,o=n+this.region.width*s,l=r+this.region.height*i,h=this.rotation*a.degRad,c=Math.cos(h),d=Math.sin(h),u=this.x,m=this.y,f=n*c+u,p=n*d,g=r*c+m,x=r*d,w=o*c+u,b=o*d,y=l*c+m,M=l*d,S=this.offset;S[0]=f-x,S[1]=g+p,S[2]=f-M,S[3]=y+p,S[4]=w-M,S[5]=y+b,S[6]=w-x,S[7]=g+b,90==t.degrees?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(t,e,s,i){null!=this.sequence&&this.sequence.apply(t,this);let n=t.bone,a=this.offset,r=n.worldX,o=n.worldY,l=n.a,h=n.b,c=n.c,d=n.d,u=0,m=0;u=a[0],m=a[1],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[2],m=a[3],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[4],m=a[5],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[6],m=a[7],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o}copy(){let t=new Vt(this.name,this.path);return t.region=this.region,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,l.arrayCopy(this.uvs,0,t.uvs,0,8),l.arrayCopy(this.offset,0,t.offset,0,8),t.color.setFromColor(this.color),t.sequence=null!=this.sequence?this.sequence.copy():null,t}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}class Dt{atlas;constructor(t){this.atlas=t}loadSequence(t,e,s){let i=s.regions;for(let n=0,a=i.length;n<a;n++){let a=s.getPath(e,n),r=this.atlas.findRegion(a);if(null==r)throw new Error("Region not found in atlas: "+a+" (sequence: "+t+")");i[n]=r}}newRegionAttachment(t,e,s,i){let n=new Vt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");n.region=t}return n}newMeshAttachment(t,e,s,i){let n=new Pt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");n.region=t}return n}newBoundingBoxAttachment(t,e){return new xt(e)}newPathAttachment(t,e){return new Xt(e)}newPointAttachment(t,e){return new _t(e)}newClippingAttachment(t,e){return new wt(e)}}class Ot{index=0;name;parent=null;length=0;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;inherit=t.Inherit.Normal;skinRequired=!1;color=new n;icon;visible=!1;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}t.Inherit=void 0,(St=t.Inherit||(t.Inherit={}))[St.Normal=0]="Normal",St[St.OnlyTranslation=1]="OnlyTranslation",St[St.NoRotationOrReflection=2]="NoRotationOrReflection",St[St.NoScale=3]="NoScale",St[St.NoScaleOrReflection=4]="NoScaleOrReflection";class Nt{data;skeleton;parent=null;children=new Array;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=t.Inherit.Normal;sorted=!1;active=!1;constructor(t,e,s){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(e,s,i,n,r,o,l){this.ax=e,this.ay=s,this.arotation=i,this.ascaleX=n,this.ascaleY=r,this.ashearX=o,this.ashearY=l;let h=this.parent;if(!h){let t=this.skeleton;const h=t.scaleX,c=t.scaleY,d=(i+o)*a.degRad,u=(i+90+l)*a.degRad;return this.a=Math.cos(d)*n*h,this.b=Math.cos(u)*r*h,this.c=Math.sin(d)*n*c,this.d=Math.sin(u)*r*c,this.worldX=e*h+t.x,void(this.worldY=s*c+t.y)}let c=h.a,d=h.b,u=h.c,m=h.d;switch(this.worldX=c*e+d*s+h.worldX,this.worldY=u*e+m*s+h.worldY,this.inherit){case t.Inherit.Normal:{const t=(i+o)*a.degRad,e=(i+90+l)*a.degRad,s=Math.cos(t)*n,h=Math.cos(e)*r,f=Math.sin(t)*n,p=Math.sin(e)*r;return this.a=c*s+d*f,this.b=c*h+d*p,this.c=u*s+m*f,void(this.d=u*h+m*p)}case t.Inherit.OnlyTranslation:{const t=(i+o)*a.degRad,e=(i+90+l)*a.degRad;this.a=Math.cos(t)*n,this.b=Math.cos(e)*r,this.c=Math.sin(t)*n,this.d=Math.sin(e)*r;break}case t.Inherit.NoRotationOrReflection:{let t=c*c+u*u,e=0;t>1e-4?(t=Math.abs(c*m-d*u)/t,c/=this.skeleton.scaleX,u/=this.skeleton.scaleY,d=u*t,m=c*t,e=Math.atan2(u,c)*a.radDeg):(c=0,u=0,e=90-Math.atan2(m,d)*a.radDeg);const s=(i+o-e)*a.degRad,h=(i+l-e+90)*a.degRad,f=Math.cos(s)*n,p=Math.cos(h)*r,g=Math.sin(s)*n,x=Math.sin(h)*r;this.a=c*f-d*g,this.b=c*p-d*x,this.c=u*f+m*g,this.d=u*p+m*x;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:{i*=a.degRad;const e=Math.cos(i),s=Math.sin(i);let h=(c*e+d*s)/this.skeleton.scaleX,f=(u*e+m*s)/this.skeleton.scaleY,p=Math.sqrt(h*h+f*f);p>1e-5&&(p=1/p),h*=p,f*=p,p=Math.sqrt(h*h+f*f),this.inherit==t.Inherit.NoScale&&c*m-d*u<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p),i=Math.PI/2+Math.atan2(f,h);const g=Math.cos(i)*p,x=Math.sin(i)*p;o*=a.degRad,l=(90+l)*a.degRad;const w=Math.cos(o)*n,b=Math.cos(l)*r,y=Math.sin(o)*n,M=Math.sin(l)*r;this.a=h*w+g*y,this.b=h*b+g*M,this.c=f*w+x*y,this.d=f*b+x*M;break}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;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}updateAppliedTransform(){let e=this.parent;if(!e)return this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,this.arotation=Math.atan2(this.c,this.a)*a.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*a.radDeg);let s,i,n,r,o=e.a,l=e.b,h=e.c,c=e.d,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d,g=this.worldX-e.worldX,x=this.worldY-e.worldY;if(this.ax=g*u-x*m,this.ay=x*p-g*f,this.inherit==t.Inherit.OnlyTranslation)s=this.a,i=this.b,n=this.c,r=this.d;else{switch(this.inherit){case t.Inherit.NoRotationOrReflection:{let t=Math.abs(o*c-l*h)/(o*o+h*h),e=o/this.skeleton.scaleX;l=-(h/this.skeleton.scaleY)*t*this.skeleton.scaleX,c=e*t*this.skeleton.scaleY,d=1/(o*c-l*h),u=c*d,m=l*d;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:let e=a.cosDeg(this.rotation),s=a.sinDeg(this.rotation);o=(o*e+l*s)/this.skeleton.scaleX,h=(h*e+c*s)/this.skeleton.scaleY;let i=Math.sqrt(o*o+h*h);i>1e-5&&(i=1/i),o*=i,h*=i,i=Math.sqrt(o*o+h*h),this.inherit==t.Inherit.NoScale&&d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(i=-i);let n=a.PI/2+Math.atan2(h,o);l=Math.cos(n)*i,c=Math.sin(n)*i,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d}s=u*this.a-m*this.c,i=u*this.b-m*this.d,n=p*this.c-f*this.a,r=p*this.d-f*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(s*s+n*n),this.ascaleX>1e-4){let t=s*r-i*n;this.ascaleY=t/this.ascaleX,this.ashearY=-Math.atan2(s*i+n*r,t)*a.radDeg,this.arotation=Math.atan2(n,s)*a.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(i*i+r*r),this.ashearY=0,this.arotation=90-Math.atan2(r,i)*a.radDeg}getWorldRotationX(){return Math.atan2(this.c,this.a)*a.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*a.radDeg}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){let e=1/(this.a*this.d-this.b*this.c),s=t.x-this.worldX,i=t.y-this.worldY;return t.x=s*this.d*e-i*this.b*e,t.y=i*this.a*e-s*this.c*e,t}localToWorld(t){let 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(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.worldToLocal(t)}parentToWorld(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=a.sinDeg(t),s=a.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*a.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=a.sinDeg(t),s=a.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*a.radDeg}rotateWorld(t){t*=a.degRad;const e=Math.sin(t),s=Math.cos(t),i=this.a,n=this.b;this.a=s*i-e*this.c,this.b=s*n-e*this.d,this.c=e*i+s*this.c,this.d=e*n+s*this.d}}class Lt{name;order;skinRequired;constructor(t,e,s){this.name=t,this.order=e,this.skinRequired=s}}class qt{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return-1!=e?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){for(var e=window.atob(t),s=e.length,i=new Uint8Array(s),n=0;n<s;n++)i[n]=e.charCodeAt(n);return i}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(-1==e)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;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToString(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",t,!0);let n=()=>{this.finish(t,i.status,i.responseText)};i.onload=n,i.onerror=n,i.send()}downloadJson(t,e,s){this.downloadText(t,(t=>{e(JSON.parse(t))}),s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToUint8Array(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";let n=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{200==i.status||0==i.status?this.finish(t,200,new Uint8Array(i.response)):n()},i.onerror=n,i.send()}start(t,e,s){let i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,s)}}finish(t,e,s){let i=this.callbacks[t];delete this.callbacks[t];let n=200==e||0==e?[s]:[e,s];for(let t=n.length-1,e=i.length;t<e;t+=2)i[t].apply(null,n)}}class Ut{data;intValue=0;floatValue=0;stringValue=null;time=0;volume=0;balance=0;constructor(t,e){if(!e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class Wt{name;intValue=0;floatValue=0;stringValue=null;audioPath=null;volume=0;balance=0;constructor(t){this.name=t}}class zt{data;bones;target;bendDirection=0;compress=!1;stretch=!1;mix=1;softness=0;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find bone ${t.target.name}`);this.target=s,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}update(t){if(0==this.mix)return;let e=this.target,s=this.bones;switch(s.length){case 1:this.apply1(s[0],e.worldX,e.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(s[0],s[1],e.worldX,e.worldY,this.bendDirection,this.stretch,this.data.uniform,this.softness,this.mix)}}apply1(e,s,i,n,r,o,l){let h=e.parent;if(!h)throw new Error("IK bone must have parent.");let c=h.a,d=h.b,u=h.c,m=h.d,f=-e.ashearX-e.arotation,p=0,g=0;switch(e.inherit){case t.Inherit.OnlyTranslation:p=(s-e.worldX)*a.signum(e.skeleton.scaleX),g=(i-e.worldY)*a.signum(e.skeleton.scaleY);break;case t.Inherit.NoRotationOrReflection:let n=Math.abs(c*m-d*u)/Math.max(1e-4,c*c+u*u),r=c/e.skeleton.scaleX,o=u/e.skeleton.scaleY;d=-o*n*e.skeleton.scaleX,m=r*n*e.skeleton.scaleY,f+=Math.atan2(o,r)*a.radDeg;default:let l=s-h.worldX,x=i-h.worldY,w=c*m-d*u;Math.abs(w)<=1e-4?(p=0,g=0):(p=(l*m-x*d)/w-e.ax,g=(x*c-l*u)/w-e.ay)}f+=Math.atan2(g,p)*a.radDeg,e.ascaleX<0&&(f+=180),f>180?f-=360:f<-180&&(f+=360);let x=e.ascaleX,w=e.ascaleY;if(n||r){switch(e.inherit){case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:p=s-e.worldX,g=i-e.worldY}const a=e.data.length*x;if(a>1e-4){const t=p*p+g*g;if(n&&t<a*a||r&&t>a*a){const e=(Math.sqrt(t)/a-1)*l+1;x*=e,o&&(w*=e)}}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+f*l,x,w,e.ashearX,e.ashearY)}apply2(e,s,i,n,r,o,l,h,c){if(e.inherit!=t.Inherit.Normal||s.inherit!=t.Inherit.Normal)return;let d=e.ax,u=e.ay,m=e.ascaleX,f=e.ascaleY,p=m,g=f,x=s.ascaleX,w=0,b=0,y=0;m<0?(m=-m,w=180,y=-1):(w=0,y=1),f<0&&(f=-f,y=-y),x<0?(x=-x,b=180):b=0;let M=s.ax,S=0,v=0,k=0,I=e.a,A=e.b,T=e.c,B=e.d,C=Math.abs(m-f)<=1e-4;!C||o?(S=0,v=I*M+e.worldX,k=T*M+e.worldY):(S=s.ay,v=I*M+A*S+e.worldX,k=T*M+B*S+e.worldY);let F=e.parent;if(!F)throw new Error("IK parent must itself have a parent.");I=F.a,A=F.b,T=F.c,B=F.d;let E=I*B-A*T,R=v-F.worldX,Y=k-F.worldY;E=Math.abs(E)<=1e-4?0:1/E;let P,X,_=(R*B-Y*A)*E-d,V=(Y*I-R*T)*E-u,D=Math.sqrt(_*_+V*V),O=s.data.length*x;if(D<1e-4)return this.apply1(e,i,n,!1,o,!1,c),void s.updateWorldTransformWith(M,S,0,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY);R=i-F.worldX,Y=n-F.worldY;let N=(R*B-Y*A)*E-d,L=(Y*I-R*T)*E-u,q=N*N+L*L;if(0!=h){h*=m*(x+1)*.5;let t=Math.sqrt(q),e=t-D-O*m+h;if(e>0){let s=Math.min(1,e/(2*h))-1;s=(e-h*(1-s*s))/t,N-=s*N,L-=s*L,q=N*N+L*L}}t:if(C){O*=m;let t=(q-D*D-O*O)/(2*D*O);t<-1?(t=-1,X=Math.PI*r):t>1?(t=1,X=0,o&&(I=(Math.sqrt(q)/(D+O)-1)*c+1,p*=I,l&&(g*=I))):X=Math.acos(t)*r,I=D+O*t,A=O*Math.sin(X),P=Math.atan2(L*I-N*A,N*I+L*A)}else{I=m*O,A=f*O;let t=I*I,e=A*A,s=Math.atan2(L,N);T=e*D*D+t*q-t*e;let i=-2*e*D,n=e-t;if(B=i*i-4*n*T,B>=0){let t=Math.sqrt(B);i<0&&(t=-t),t=.5*-(i+t);let e=t/n,a=T/t,o=Math.abs(e)<Math.abs(a)?e:a;if(o*o<=q){Y=Math.sqrt(q-o*o)*r,P=s-Math.atan2(Y,o),X=Math.atan2(Y/f,(o-D)/m);break t}}let o=a.PI,l=D-I,h=l*l,c=0,d=0,u=D+I,p=u*u,g=0;T=-I*D/(t-e),T>=-1&&T<=1&&(T=Math.acos(T),R=I*Math.cos(T)+D,Y=A*Math.sin(T),B=R*R+Y*Y,B<h&&(o=T,h=B,l=R,c=Y),B>p&&(d=T,p=B,u=R,g=Y)),q<=.5*(h+p)?(P=s-Math.atan2(c*r,l),X=o*r):(P=s-Math.atan2(g*r,u),X=d*r)}let U=Math.atan2(S,M)*y,W=e.arotation;P=(P-U)*a.radDeg+w-W,P>180?P-=360:P<-180&&(P+=360),e.updateWorldTransformWith(d,u,W+P*c,p,g,0,0),W=s.arotation,X=((X+U)*a.radDeg-s.ashearX)*y+b-W,X>180?X-=360:X<-180&&(X+=360),s.updateWorldTransformWith(M,S,W+X*c,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY)}}class Gt extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}bendDirection=0;compress=!1;stretch=!1;uniform=!1;mix=0;softness=0;constructor(t){super(t,0,!1)}}class $t extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("SlotData not set.")}positionMode=t.PositionMode.Fixed;spacingMode=t.SpacingMode.Fixed;rotateMode=t.RotateMode.Chain;offsetRotation=0;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;constructor(t){super(t,0,!1)}}t.PositionMode=void 0,(vt=t.PositionMode||(t.PositionMode={}))[vt.Fixed=0]="Fixed",vt[vt.Percent=1]="Percent",t.SpacingMode=void 0,(kt=t.SpacingMode||(t.SpacingMode={}))[kt.Length=0]="Length",kt[kt.Fixed=1]="Fixed",kt[kt.Percent=2]="Percent",kt[kt.Proportional=3]="Proportional",t.RotateMode=void 0,(It=t.RotateMode||(t.RotateMode={}))[It.Tangent=0]="Tangent",It[It.Chain=1]="Chain",It[It.ChainScale=2]="ChainScale";class jt{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=new Array;positions=new Array;world=new Array;curves=new Array;lengths=new Array;segments=new Array;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0,i=t.bones.length;s<i;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findSlot(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}`);this.target=s,this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}update(e){let s=this.target.getAttachment();if(!(s instanceof Xt))return;let i=this.mixRotate,n=this.mixX,r=this.mixY;if(0==i&&0==n&&0==r)return;let o=this.data,h=o.rotateMode==t.RotateMode.Tangent,c=o.rotateMode==t.RotateMode.ChainScale,d=this.bones,u=d.length,m=h?u:u+1,f=l.setArraySize(this.spaces,m),p=c?this.lengths=l.setArraySize(this.lengths,u):[],g=this.spacing;switch(o.spacingMode){case t.SpacingMode.Percent:if(c)for(let t=0,e=m-1;t<e;t++){let e=d[t],s=e.data.length,i=s*e.a,n=s*e.c;p[t]=Math.sqrt(i*i+n*n)}l.arrayFill(f,1,m,g);break;case t.SpacingMode.Proportional:let e=0;for(let t=0,s=m-1;t<s;){let s=d[t],i=s.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*s.a,a=i*s.c,r=Math.sqrt(n*n+a*a);c&&(p[t]=r),f[++t]=r,e+=r}}if(e>0){e=m/e*g;for(let t=1;t<m;t++)f[t]*=e}break;default:let s=o.spacingMode==t.SpacingMode.Length;for(let t=0,e=m-1;t<e;){let e=d[t],i=e.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*e.a,a=i*e.c,r=Math.sqrt(n*n+a*a);c&&(p[t]=r),f[++t]=(s?i+g:g)*r/i}}}let x=this.computeWorldPositions(s,m,h),w=x[0],b=x[1],y=o.offsetRotation,M=!1;if(0==y)M=o.rotateMode==t.RotateMode.Chain;else{M=!1;let t=this.target.bone;y*=t.a*t.d-t.b*t.c>0?a.degRad:-a.degRad}for(let t=0,e=3;t<u;t++,e+=3){let s=d[t];s.worldX+=(w-s.worldX)*n,s.worldY+=(b-s.worldY)*r;let o=x[e],l=x[e+1],u=o-w,m=l-b;if(c){let e=p[t];if(0!=e){let t=(Math.sqrt(u*u+m*m)/e-1)*i+1;s.a*=t,s.c*=t}}if(w=o,b=l,i>0){let n=s.a,r=s.b,o=s.c,l=s.d,c=0,d=0,p=0;if(c=h?x[e-1]:0==f[t+1]?x[e+2]:Math.atan2(m,u),c-=Math.atan2(o,n),M){d=Math.cos(c),p=Math.sin(c);let t=s.data.length;w+=(t*(d*n-p*o)-u)*i,b+=(t*(p*n+d*o)-m)*i}else c+=y;c>a.PI?c-=a.PI2:c<-a.PI&&(c+=a.PI2),c*=i,d=Math.cos(c),p=Math.sin(c),s.a=d*n-p*o,s.b=d*r-p*l,s.c=p*n+d*o,s.d=p*r+d*l}s.updateAppliedTransform()}}computeWorldPositions(e,s,i){let n=this.target,a=this.position,r=this.spaces,o=l.setArraySize(this.positions,3*s+2),h=this.world,c=e.closed,d=e.worldVerticesLength,u=d/6,m=jt.NONE;if(!e.constantSpeed){let f=e.lengths;u-=c?1:2;let p,g=f[u];switch(this.data.positionMode==t.PositionMode.Percent&&(a*=g),this.data.spacingMode){case t.SpacingMode.Percent:p=g;break;case t.SpacingMode.Proportional:p=g/s;break;default:p=1}h=l.setArraySize(this.world,8);for(let t=0,l=0,x=0;t<s;t++,l+=3){let s=r[t]*p;a+=s;let w=a;if(c)w%=g,w<0&&(w+=g),x=0;else{if(w<0){m!=jt.BEFORE&&(m=jt.BEFORE,e.computeWorldVertices(n,2,4,h,0,2)),this.addBeforePosition(w,h,0,o,l);continue}if(w>g){m!=jt.AFTER&&(m=jt.AFTER,e.computeWorldVertices(n,d-6,4,h,0,2)),this.addAfterPosition(w-g,h,0,o,l);continue}}for(;;x++){let t=f[x];if(!(w>t)){if(0==x)w/=t;else{let e=f[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,c&&x==u?(e.computeWorldVertices(n,d-4,4,h,0,2),e.computeWorldVertices(n,0,4,h,4,2)):e.computeWorldVertices(n,6*x+2,8,h,0,2)),this.addCurvePosition(w,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],o,l,i||t>0&&0==s)}return o}c?(d+=2,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d-4,h,0,2),e.computeWorldVertices(n,0,2,h,d-4,2),h[d-2]=h[0],h[d-1]=h[1]):(u--,d-=4,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d,h,0,2));let f,p=l.setArraySize(this.curves,u),g=0,x=h[0],w=h[1],b=0,y=0,M=0,S=0,v=0,k=0,I=0,A=0,T=0,B=0,C=0,F=0,E=0,R=0;for(let t=0,e=2;t<u;t++,e+=6)b=h[e],y=h[e+1],M=h[e+2],S=h[e+3],v=h[e+4],k=h[e+5],I=.1875*(x-2*b+M),A=.1875*(w-2*y+S),T=.09375*(3*(b-M)-x+v),B=.09375*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.75*(b-x)+I+.16666667*T,R=.75*(y-w)+A+.16666667*B,g+=Math.sqrt(E*E+R*R),E+=C,R+=F,C+=T,F+=B,g+=Math.sqrt(E*E+R*R),E+=C,R+=F,g+=Math.sqrt(E*E+R*R),E+=C+T,R+=F+B,g+=Math.sqrt(E*E+R*R),p[t]=g,x=v,w=k;switch(this.data.positionMode==t.PositionMode.Percent&&(a*=g),this.data.spacingMode){case t.SpacingMode.Percent:f=g;break;case t.SpacingMode.Proportional:f=g/s;break;default:f=1}let Y=this.segments,P=0;for(let t=0,e=0,n=0,l=0;t<s;t++,e+=3){let s=r[t]*f;a+=s;let u=a;if(c)u%=g,u<0&&(u+=g),n=0;else{if(u<0){this.addBeforePosition(u,h,0,o,e);continue}if(u>g){this.addAfterPosition(u-g,h,d-4,o,e);continue}}for(;;n++){let t=p[n];if(!(u>t)){if(0==n)u/=t;else{let e=p[n-1];u=(u-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=h[t],w=h[t+1],b=h[t+2],y=h[t+3],M=h[t+4],S=h[t+5],v=h[t+6],k=h[t+7],I=.03*(x-2*b+M),A=.03*(w-2*y+S),T=.006*(3*(b-M)-x+v),B=.006*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.3*(b-x)+I+.16666667*T,R=.3*(y-w)+A+.16666667*B,P=Math.sqrt(E*E+R*R),Y[0]=P,t=1;t<8;t++)E+=C,R+=F,C+=T,F+=B,P+=Math.sqrt(E*E+R*R),Y[t]=P;E+=C,R+=F,P+=Math.sqrt(E*E+R*R),Y[8]=P,E+=C+T,R+=F+B,P+=Math.sqrt(E*E+R*R),Y[9]=P,l=0}for(u*=P;;l++){let t=Y[l];if(!(u>t)){if(0==l)u/=t;else{let e=Y[l-1];u=l+(u-e)/(t-e)}break}}this.addCurvePosition(.1*u,x,w,b,y,M,S,v,k,o,e,i||t>0&&0==s)}return o}addBeforePosition(t,e,s,i,n){let a=e[s],r=e[s+1],o=e[s+2]-a,l=e[s+3]-r,h=Math.atan2(l,o);i[n]=a+t*Math.cos(h),i[n+1]=r+t*Math.sin(h),i[n+2]=h}addAfterPosition(t,e,s,i,n){let a=e[s+2],r=e[s+3],o=a-e[s],l=r-e[s+1],h=Math.atan2(l,o);i[n]=a+t*Math.cos(h),i[n+1]=r+t*Math.sin(h),i[n+2]=h}addCurvePosition(t,e,s,i,n,a,r,o,l,h,c,d){if(0==t||isNaN(t))return h[c]=e,h[c+1]=s,void(h[c+2]=Math.atan2(n-s,i-e));let u=t*t,m=u*t,f=1-t,p=f*f,g=p*f,x=f*t,w=3*x,b=f*w,y=w*t,M=e*g+i*b+a*y+o*m,S=s*g+n*b+r*y+l*m;h[c]=M,h[c+1]=S,d&&(h[c+2]=t<.001?Math.atan2(n-s,i-e):Math.atan2(S-(s*p+n*x*2+r*u),M-(e*p+i*x*2+a*u)))}}class Ht{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],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}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){const t=this.data;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}isActive(){return this.active}update(e){const s=this.mix;if(0==s)return;const i=this.data.x>0,n=this.data.y>0,r=this.data.rotate>0||this.data.shearX>0,o=this.data.scaleX>0,l=this.bone,h=l.data.length;switch(e){case t.Physics.none:return;case t.Physics.reset:this.reset();case t.Physics.update:const e=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=e,this.lastTime=this.skeleton.time;const c=l.worldX,d=l.worldY;if(this._reset)this._reset=!1,this.ux=c,this.uy=d;else{let t=this.remaining,u=this.inertia,m=this.data.limit*e,f=this.data.step,p=this.skeleton.data.referenceScale,g=-1;if(i||n){if(i){const t=(this.ux-c)*u;this.xOffset+=t>m?m:t<-m?-m:t,this.ux=c}if(n){const t=(this.uy-d)*u;this.yOffset+=t>m?m:t<-m?-m:t,this.uy=d}if(t>=f){g=Math.pow(this.damping,60*f);const e=this.massInverse*f,s=this.strength,a=this.wind*p,r=(Qt.yDown?-this.gravity:this.gravity)*p;do{i&&(this.xVelocity+=(a-this.xOffset*s)*e,this.xOffset+=this.xVelocity*f,this.xVelocity*=g),n&&(this.yVelocity-=(r+this.yOffset*s)*e,this.yOffset+=this.yVelocity*f,this.yVelocity*=g),t-=f}while(t>=f)}i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(r||o){let e=Math.atan2(l.c,l.a),i=0,n=0,c=0,d=this.cx-l.worldX,x=this.cy-l.worldY;if(d>m?d=m:d<-m&&(d=-m),x>m?x=m:x<-m&&(x=-m),r){c=(this.data.rotate+this.data.shearX)*s;let t=Math.atan2(x+this.ty,d+this.tx)-e-this.rotateOffset*c;this.rotateOffset+=(t-Math.ceil(t*a.invPI2-.5)*a.PI2)*u,t=this.rotateOffset*c+e,i=Math.cos(t),n=Math.sin(t),o&&(t=h*l.getWorldScaleX(),t>0&&(this.scaleOffset+=(d*i+x*n)*u/t))}else{i=Math.cos(e),n=Math.sin(e);const t=h*l.getWorldScaleX();t>0&&(this.scaleOffset+=(d*i+x*n)*u/t)}if(t=this.remaining,t>=f){-1==g&&(g=Math.pow(this.damping,60*f));const s=this.massInverse*f,a=this.strength,l=this.wind,d=Qt.yDown?-this.gravity:this.gravity,u=h/p;for(;;)if(t-=f,o&&(this.scaleVelocity+=(l*i-d*n-this.scaleOffset*a)*s,this.scaleOffset+=this.scaleVelocity*f,this.scaleVelocity*=g),r){if(this.rotateVelocity-=((l*n+d*i)*u+this.rotateOffset*a)*s,this.rotateOffset+=this.rotateVelocity*f,this.rotateVelocity*=g,t<f)break;const r=this.rotateOffset*c+e;i=Math.cos(r),n=Math.sin(r)}else if(t<f)break}}this.remaining=t}this.cx=l.worldX,this.cy=l.worldY;break;case t.Physics.pose:i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(r){let t=this.rotateOffset*s,e=0,i=0,n=0;if(this.data.shearX>0){let s=0;this.data.rotate>0&&(s=t*this.data.rotate,e=Math.sin(s),i=Math.cos(s),n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d),s+=t*this.data.shearX,e=Math.sin(s),i=Math.cos(s),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c}else t*=this.data.rotate,e=Math.sin(t),i=Math.cos(t),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c,n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d}if(o){const t=1+this.scaleOffset*s*this.data.scaleX;l.a*=t,l.c*=t}e!=t.Physics.pose&&(this.tx=h*l.a,this.ty=h*l.c),l.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,s){const i=s*a.degRad,n=Math.cos(i),r=Math.sin(i),o=this.cx-t,l=this.cy-e;this.translate(o*n-l*r-o,o*r+l*n-l)}}class Jt{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=new Array;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new n,this.darkColor=t.darkColor?new n:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(t instanceof u&&this.attachment instanceof u&&t.timelineAttachment==this.attachment.timelineAttachment||(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}}class Kt{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new c;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}.`);this.target=s,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}update(t){0==this.mixRotate&&0==this.mixX&&0==this.mixY&&0==this.mixScaleX&&0==this.mixScaleY&&0==this.mixShearY||(this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld())}applyAbsoluteWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?a.degRad:-a.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,r=Math.atan2(d,h)-Math.atan2(i,e)+f;r>a.PI?r-=a.PI2:r<-a.PI&&(r+=a.PI2),r*=t;let o=Math.cos(r),l=Math.sin(r);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=(t.x-x.worldX)*e,x.worldY+=(t.y-x.worldY)*s}if(0!=i){let t=Math.sqrt(x.a*x.a+x.c*x.c);0!=t&&(t=(t+(Math.sqrt(h*h+d*d)-t+this.data.offsetScaleX)*i)/t),x.a*=t,x.c*=t}if(0!=n){let t=Math.sqrt(x.b*x.b+x.d*x.d);0!=t&&(t=(t+(Math.sqrt(c*c+u*u)-t+this.data.offsetScaleY)*n)/t),x.b*=t,x.d*=t}if(r>0){let t=x.b,e=x.d,s=Math.atan2(e,t),i=Math.atan2(u,c)-Math.atan2(d,h)-(s-Math.atan2(x.c,x.a));i>a.PI?i-=a.PI2:i<-a.PI&&(i+=a.PI2),i=s+(i+p)*r;let n=Math.sqrt(t*t+e*e);x.b=Math.cos(i)*n,x.d=Math.sin(i)*n}x.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?a.degRad:-a.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,r=Math.atan2(d,h)+f;r>a.PI?r-=a.PI2:r<-a.PI&&(r+=a.PI2),r*=t;let o=Math.cos(r),l=Math.sin(r);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=t.x*e,x.worldY+=t.y*s}if(0!=i){let t=(Math.sqrt(h*h+d*d)-1+this.data.offsetScaleX)*i+1;x.a*=t,x.c*=t}if(0!=n){let t=(Math.sqrt(c*c+u*u)-1+this.data.offsetScaleY)*n+1;x.b*=t,x.d*=t}if(r>0){let t=Math.atan2(u,c)-Math.atan2(d,h);t>a.PI?t-=a.PI2:t<-a.PI&&(t+=a.PI2);let e=x.b,s=x.d;t=Math.atan2(s,e)+(t-a.PI/2+p)*r;let i=Math.sqrt(e*e+s*s);x.b=Math.cos(t)*i,x.d=Math.sin(t)*i}x.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,r=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation;0!=t&&(c+=(r.arotation-c+this.data.offsetRotation)*t);let d=h.ax,u=h.ay;d+=(r.ax-d+this.data.offsetX)*e,u+=(r.ay-u+this.data.offsetY)*s;let m=h.ascaleX,f=h.ascaleY;0!=i&&0!=m&&(m=(m+(r.ascaleX-m+this.data.offsetScaleX)*i)/m),0!=n&&0!=f&&(f=(f+(r.ascaleY-f+this.data.offsetScaleY)*n)/f);let p=h.ashearY;0!=a&&(p+=(r.ashearY-p+this.data.offsetShearY)*a),h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}applyRelativeLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,r=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation+(r.arotation+this.data.offsetRotation)*t,d=h.ax+(r.ax+this.data.offsetX)*e,u=h.ay+(r.ay+this.data.offsetY)*s,m=h.ascaleX*((r.ascaleX-1+this.data.offsetScaleX)*i+1),f=h.ascaleY*((r.ascaleY-1+this.data.offsetScaleY)*n+1),p=h.ashearY+(r.ashearY+this.data.offsetShearY)*a;h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}}class Qt{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;data;bones;slots;drawOrder;ikConstraints;transformConstraints;pathConstraints;physicsConstraints;_updateCache=new Array;skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return Qt.yDown?-this._scaleY:this._scaleY}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;constructor(t){if(!t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(i.parent){let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}else s=new Nt(i,this,null);this.bones.push(s)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],n=new Jt(s,i);this.slots.push(n),this.drawOrder.push(n)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new zt(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new Kt(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new jt(s,this))}this.physicsConstraints=new Array;for(let e=0;e<t.physicsConstraints.length;e++){let s=t.physicsConstraints[e];this.physicsConstraints.push(new Ht(s,this))}this.color=new n(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted=s.data.skinRequired,s.active=!s.sorted}if(this.skin){let t=this.skin.bones;for(let e=0,s=this.skin.bones.length;e<s;e++){let s=this.bones[t[e].index];do{s.sorted=!1,s.active=!0,s=s.parent}while(s)}}let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=this.physicsConstraints,a=e.length,r=s.length,o=i.length,l=this.physicsConstraints.length,h=a+r+o+l;t:for(let t=0;t<h;t++){for(let s=0;s<a;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<o;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}for(let e=0;e<l;e++){const s=n[e];if(s.data.order==t){this.sortPhysicsConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),1==s.length)this._updateCache.push(t),this.sortReset(i.children);else{let e=s[s.length-1];this.sortBone(e),this._updateCache.push(t),this.sortReset(i.children),e.sorted=!0}}sortPathConstraint(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target,s=e.data.index,i=e.bone;this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let n=e.getAttachment();n instanceof Xt&&this.sortPathConstraintAttachmentWith(n,i);let a=t.bones,r=a.length;for(let t=0;t<r;t++)this.sortBone(a[t]);this._updateCache.push(t);for(let t=0;t<r;t++)this.sortReset(a[t].children);for(let t=0;t<r;t++)a[t].sorted=!0}sortTransformConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this.sortBone(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof Xt))return;let s=t.bones;if(s){let t=this.bones;for(let e=0,i=s.length;e<i;){let i=s[e++];for(i+=e;e<i;)this.sortBone(t[s[e++]])}}else this.sortBone(e)}sortPhysicsConstraint(t){const e=t.bone;t.active=e.active&&(!t.data.skinRequired||null!=this.skin&&l.contains(this.skin.constraints,t.data,!0)),t.active&&(this.sortBone(e),this._updateCache.push(t),this.sortReset(e.children),e.sorted=!0)}sortBone(t){if(!t)return;if(t.sorted)return;let e=t.parent;e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.active&&(s.sorted&&this.sortReset(s.children),s.sorted=!1)}}updateWorldTransform(t){if(null==t)throw new Error("physics is undefined");let e=this.bones;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY}let s=this._updateCache;for(let e=0,i=s.length;e<i;e++)s[e].update(t)}updateWorldTransformWith(t,e){let s=this.getRootBone();if(!s)throw new Error("Root bone must not be null.");let i=e.a,n=e.b,r=e.c,o=e.d;s.worldX=i*this.x+n*this.y+e.worldX,s.worldY=r*this.x+o*this.y+e.worldY;const l=(s.rotation+s.shearX)*a.degRad,h=(s.rotation+90+s.shearY)*a.degRad,c=Math.cos(l)*s.scaleX,d=Math.cos(h)*s.scaleY,u=Math.sin(l)*s.scaleX,m=Math.sin(h)*s.scaleY;s.a=(i*c+n*u)*this.scaleX,s.b=(i*d+n*m)*this.scaleX,s.c=(r*c+o*u)*this.scaleY,s.d=(r*d+o*m)*this.scaleY;let f=this._updateCache;for(let e=0,i=f.length;e<i;e++){let i=f[e];i!=s&&i.update(t)}}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){for(const t of this.bones)t.setToSetupPose();for(const t of this.ikConstraints)t.setToSetupPose();for(const t of this.transformConstraints)t.setToSetupPose();for(const t of this.pathConstraints)t.setToSetupPose();for(const t of this.physicsConstraints)t.setToSetupPose()}setSlotsToSetupPose(){let t=this.slots;l.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}setSkinByName(t){let e=this.data.findSkin(t);if(!e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(t!=this.skin){if(t)if(this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],n=i.data.attachmentName;if(n){let e=t.getAttachment(s,n);e&&i.setAttachment(e)}}}this.skin=t,this.updateCache()}}getAttachmentByName(t,e){let s=this.data.findSlot(t);if(!s)throw new Error(`Can't find slot with name ${t}`);return this.getAttachment(s.index,e)}getAttachment(t,e){if(!e)throw new Error("attachmentName cannot be null.");if(this.skin){let s=this.skin.getAttachment(t,e);if(s)return s}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(!t)throw new Error("slotName cannot be null.");let s=this.slots;for(let i=0,n=s.length;i<n;i++){let n=s[i];if(n.data.name==t){let s=null;if(e&&(s=this.getAttachment(i,e),!s))throw new Error("Attachment not found: "+e+", for slot: "+t);return void n.setAttachment(s)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.ikConstraints.find((e=>e.data.name==t))??null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.transformConstraints.find((e=>e.data.name==t))??null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.pathConstraints.find((e=>e.data.name==t))??null}findPhysicsConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");return this.physicsConstraints.find((e=>e.data.name==t))??null}getBoundsRect(){let t=new c,e=new c;return this.getBounds(t,e),{x:t.x,y:t.y,width:e.x,height:e.y}}getBounds(t,e,s=new Array(2),i=null){if(!t)throw new Error("offset cannot be null.");if(!e)throw new Error("size cannot be null.");let n=this.drawOrder,a=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let t=0,e=n.length;t<e;t++){let e=n[t];if(!e.bone.active)continue;let c=0,d=null,u=null,m=e.getAttachment();if(m instanceof Vt)c=8,d=l.setArraySize(s,c,0),m.computeWorldVertices(e,d,0,2),u=Qt.quadTriangles;else if(m instanceof Pt){let t=m;c=t.worldVerticesLength,d=l.setArraySize(s,c,0),t.computeWorldVertices(e,0,c,d,0,2),u=t.triangles}else if(m instanceof wt&&null!=i){i.clipStart(e,m);continue}if(d&&u){null!=i&&i.isClipping()&&(i.clipTriangles(d,u,u.length),d=i.clippedVertices,c=i.clippedVertices.length);for(let t=0,e=d.length;t<e;t+=2){let e=d[t],s=d[t+1];a=Math.min(a,e),r=Math.min(r,s),o=Math.max(o,e),h=Math.max(h,s)}}null!=i&&i.clipEndWithSlot(e)}null!=i&&i.clipEnd(),t.set(a,r),e.set(o-a,h-r)}update(t){this.time+=t}physicsTranslate(t,e){const s=this.physicsConstraints;for(let i=0,n=s.length;i<n;i++)s[i].translate(t,e)}physicsRotate(t,e,s){const i=this.physicsConstraints;for(let n=0,a=i.length;n<a;n++)i[n].rotate(t,e,s)}}t.Physics=void 0,(At=t.Physics||(t.Physics={}))[At.none=0]="none",At[At.reset=1]="reset",At[At.update=2]="update",At[At.pose=3]="pose";class Zt extends Lt{_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;constructor(t){super(t,0,!1)}}class te{name=null;bones=new Array;slots=new Array;skins=new Array;defaultSkin=null;events=new Array;animations=new Array;ikConstraints=new Array;transformConstraints=new Array;pathConstraints=new Array;physicsConstraints=new Array;x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=0;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSkin(t){if(!t)throw new Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(!t)throw new Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(!t)throw new Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPhysicsConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.physicsConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}}class ee{slotIndex;name;attachment;constructor(t=0,e,s){this.slotIndex=t,this.name=e,this.attachment=s}}class se{name;attachments=new Array;bones=Array();constraints=new Array;color=new n(.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.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}addSkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];this.setAttachment(s.slotIndex,s.name,s.attachment)}}copySkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];s.attachment&&(s.attachment instanceof Pt?(s.attachment=s.attachment.newLinkedMesh(),this.setAttachment(s.slotIndex,s.name,s.attachment)):(s.attachment=s.attachment.copy(),this.setAttachment(s.slotIndex,s.name,s.attachment)))}}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){let s=this.attachments[t];s&&delete s[e]}getAttachments(){let t=new Array;for(var e=0;e<this.attachments.length;e++){let s=this.attachments[e];if(s)for(let i in s){let n=s[i];n&&t.push(new ee(e,i,n))}}return t}getAttachmentsForSlot(t,e){let s=this.attachments[t];if(s)for(let i in s){let n=s[i];n&&e.push(new ee(t,i,n))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let n=t.slots[i],a=n.getAttachment();if(a&&s<e.attachments.length){let t=e.attachments[s];for(let e in t){if(a==t[e]){let t=this.getAttachment(s,e);t&&n.setAttachment(t);break}}}s++}}}class ie{index=0;name;boneData;color=new n(1,1,1,1);darkColor=null;attachmentName=null;blendMode=t.BlendMode.Normal;visible=!0;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}t.BlendMode=void 0,(Tt=t.BlendMode||(t.BlendMode={}))[Tt.Normal=0]="Normal",Tt[Tt.Additive=1]="Additive",Tt[Tt.Multiply=2]="Multiply",Tt[Tt.Screen=3]="Screen";class ne extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;offsetRotation=0;offsetX=0;offsetY=0;offsetScaleX=0;offsetScaleY=0;offsetShearY=0;relative=!1;local=!1;constructor(t){super(t,0,!1)}}class ae{scale=1;attachmentLoader;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te;i.name="";let a=new re(e),r=a.readInt32(),o=a.readInt32();i.hash=0==o&&0==r?null:o.toString(16)+r.toString(16),i.version=a.readString(),i.x=a.readFloat(),i.y=a.readFloat(),i.width=a.readFloat(),i.height=a.readFloat(),i.referenceScale=a.readFloat()*s;let h=a.readBoolean();h&&(i.fps=a.readFloat(),i.imagesPath=a.readString(),i.audioPath=a.readString());let c=0;c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("String in string table must not be null.");a.strings.push(t)}c=a.readInt(!0);for(let t=0;t<c;t++){let e=a.readString();if(!e)throw new Error("Bone name must not be null.");let r=0==t?null:i.bones[a.readInt(!0)],o=new Ot(t,e,r);o.rotation=a.readFloat(),o.x=a.readFloat()*s,o.y=a.readFloat()*s,o.scaleX=a.readFloat(),o.scaleY=a.readFloat(),o.shearX=a.readFloat(),o.shearY=a.readFloat(),o.length=a.readFloat()*s,o.inherit=a.readByte(),o.skinRequired=a.readBoolean(),h&&(n.rgba8888ToColor(o.color,a.readInt32()),o.icon=a.readString()??void 0,o.visible=a.readBoolean()),i.bones.push(o)}c=a.readInt(!0);for(let t=0;t<c;t++){let e=a.readString();if(!e)throw new Error("Slot name must not be null.");let s=i.bones[a.readInt(!0)],r=new ie(t,e,s);n.rgba8888ToColor(r.color,a.readInt32());let o=a.readInt32();-1!=o&&n.rgb888ToColor(r.darkColor=new n,o),r.attachmentName=a.readStringRef(),r.blendMode=a.readInt(!0),h&&(r.visible=a.readBoolean()),i.slots.push(r)}c=a.readInt(!0);for(let t,e=0;e<c;e++){let e=a.readString();if(!e)throw new Error("IK constraint data name must not be null.");let n=new Gt(e);n.order=a.readInt(!0),t=a.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[a.readInt(!0)]);n.target=i.bones[a.readInt(!0)];let r=a.readByte();n.skinRequired=!!(1&r),n.bendDirection=2&r?1:-1,n.compress=!!(4&r),n.stretch=!!(8&r),n.uniform=!!(16&r),32&r&&(n.mix=64&r?a.readFloat():1),128&r&&(n.softness=a.readFloat()*s),i.ikConstraints.push(n)}c=a.readInt(!0);for(let t,e=0;e<c;e++){let e=a.readString();if(!e)throw new Error("Transform constraint data name must not be null.");let n=new ne(e);n.order=a.readInt(!0),t=a.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[a.readInt(!0)]);n.target=i.bones[a.readInt(!0)];let r=a.readByte();n.skinRequired=!!(1&r),n.local=!!(2&r),n.relative=!!(4&r),8&r&&(n.offsetRotation=a.readFloat()),16&r&&(n.offsetX=a.readFloat()*s),32&r&&(n.offsetY=a.readFloat()*s),64&r&&(n.offsetScaleX=a.readFloat()),128&r&&(n.offsetScaleY=a.readFloat()),r=a.readByte(),1&r&&(n.offsetShearY=a.readFloat()),2&r&&(n.mixRotate=a.readFloat()),4&r&&(n.mixX=a.readFloat()),8&r&&(n.mixY=a.readFloat()),16&r&&(n.mixScaleX=a.readFloat()),32&r&&(n.mixScaleY=a.readFloat()),64&r&&(n.mixShearY=a.readFloat()),i.transformConstraints.push(n)}c=a.readInt(!0);for(let e,n=0;n<c;n++){let n=a.readString();if(!n)throw new Error("Path constraint data name must not be null.");let r=new $t(n);r.order=a.readInt(!0),r.skinRequired=a.readBoolean(),e=a.readInt(!0);for(let t=0;t<e;t++)r.bones.push(i.bones[a.readInt(!0)]);r.target=i.slots[a.readInt(!0)];const o=a.readByte();r.positionMode=1&o,r.spacingMode=o>>1&3,r.rotateMode=o>>3&3,128&o&&(r.offsetRotation=a.readFloat()),r.position=a.readFloat(),r.positionMode==t.PositionMode.Fixed&&(r.position*=s),r.spacing=a.readFloat(),r.spacingMode!=t.SpacingMode.Length&&r.spacingMode!=t.SpacingMode.Fixed||(r.spacing*=s),r.mixRotate=a.readFloat(),r.mixX=a.readFloat(),r.mixY=a.readFloat(),i.pathConstraints.push(r)}c=a.readInt(!0);for(let t=0;t<c;t++){const t=a.readString();if(!t)throw new Error("Physics constraint data name must not be null.");const e=new Zt(t);e.order=a.readInt(!0),e.bone=i.bones[a.readInt(!0)];let n=a.readByte();e.skinRequired=!!(1&n),2&n&&(e.x=a.readFloat()),4&n&&(e.y=a.readFloat()),8&n&&(e.rotate=a.readFloat()),16&n&&(e.scaleX=a.readFloat()),32&n&&(e.shearX=a.readFloat()),e.limit=(64&n?a.readFloat():5e3)*s,e.step=1/a.readUnsignedByte(),e.inertia=a.readFloat(),e.strength=a.readFloat(),e.damping=a.readFloat(),e.massInverse=128&n?a.readFloat():1,e.wind=a.readFloat(),e.gravity=a.readFloat(),n=a.readByte(),1&n&&(e.inertiaGlobal=!0),2&n&&(e.strengthGlobal=!0),4&n&&(e.dampingGlobal=!0),8&n&&(e.massGlobal=!0),16&n&&(e.windGlobal=!0),32&n&&(e.gravityGlobal=!0),64&n&&(e.mixGlobal=!0),e.mix=128&n?a.readFloat():1,i.physicsConstraints.push(e)}let d=this.readSkin(a,i,!0,h);d&&(i.defaultSkin=d,i.skins.push(d));{let t=i.skins.length;for(l.setArraySize(i.skins,c=t+a.readInt(!0));t<c;t++){let e=this.readSkin(a,i,!1,h);if(!e)throw new Error("readSkin() should not have returned null.");i.skins[t]=e}}c=this.linkedMeshes.length;for(let t=0;t<c;t++){let e=this.linkedMeshes[t];const s=i.skins[e.skinIndex];if(!e.parent)throw new Error("Linked mesh parent must not be null");let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}this.linkedMeshes.length=0,c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("Event data name must not be null");let e=new Wt(t);e.intValue=a.readInt(!1),e.floatValue=a.readFloat(),e.stringValue=a.readString(),e.audioPath=a.readString(),e.audioPath&&(e.volume=a.readFloat(),e.balance=a.readFloat()),i.events.push(e)}c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("Animatio name must not be null.");i.animations.push(this.readAnimation(a,t,i))}return i}readSkin(t,e,s,i){let a=null,r=0;if(s){if(r=t.readInt(!0),0==r)return null;a=new se("default")}else{let s=t.readString();if(!s)throw new Error("Skin name must not be null.");a=new se(s),i&&n.rgba8888ToColor(a.color,t.readInt32()),a.bones.length=t.readInt(!0);for(let s=0,i=a.bones.length;s<i;s++)a.bones[s]=e.bones[t.readInt(!0)];for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.ikConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.transformConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.pathConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.physicsConstraints[t.readInt(!0)]);r=t.readInt(!0)}for(let s=0;s<r;s++){let s=t.readInt(!0);for(let n=0,r=t.readInt(!0);n<r;n++){let n=t.readStringRef();if(!n)throw new Error("Attachment name must not be null");let r=this.readAttachment(t,e,a,s,n,i);r&&a.setAttachment(s,n,r)}}return a}readAttachment(t,e,s,i,a,r){let o=this.scale,h=t.readByte();const c=8&h?t.readStringRef():a;if(!c)throw new Error("Attachment name must not be null");switch(7&h){case Bt.Region:{let e=16&h?t.readStringRef():null;const i=32&h?t.readInt32():4294967295,a=64&h?this.readSequence(t):null;let r=128&h?t.readFloat():0,l=t.readFloat(),d=t.readFloat(),u=t.readFloat(),m=t.readFloat(),f=t.readFloat(),p=t.readFloat();e||(e=c);let g=this.attachmentLoader.newRegionAttachment(s,c,e,a);return g?(g.path=e,g.x=l*o,g.y=d*o,g.scaleX=u,g.scaleY=m,g.rotation=r,g.width=f*o,g.height=p*o,n.rgba8888ToColor(g.color,i),g.sequence=a,null==a&&g.updateRegion(),g):null}case Bt.BoundingBox:{let e=this.readVertices(t,!!(16&h)),i=r?t.readInt32():0,a=this.attachmentLoader.newBoundingBoxAttachment(s,c);return a?(a.worldVerticesLength=e.length,a.vertices=e.vertices,a.bones=e.bones,r&&n.rgba8888ToColor(a.color,i),a):null}case Bt.Mesh:{let e=16&h?t.readStringRef():c;const i=32&h?t.readInt32():4294967295,a=64&h?this.readSequence(t):null,l=t.readInt(!0),d=this.readVertices(t,!!(128&h)),u=this.readFloatArray(t,d.length,1),m=this.readShortArray(t,3*(d.length-l-2));let f=[],p=0,g=0;r&&(f=this.readShortArray(t,t.readInt(!0)),p=t.readFloat(),g=t.readFloat()),e||(e=c);let x=this.attachmentLoader.newMeshAttachment(s,c,e,a);return x?(x.path=e,n.rgba8888ToColor(x.color,i),x.bones=d.bones,x.vertices=d.vertices,x.worldVerticesLength=d.length,x.triangles=m,x.regionUVs=u,null==a&&x.updateRegion(),x.hullLength=l<<1,x.sequence=a,r&&(x.edges=f,x.width=p*o,x.height=g*o),x):null}case Bt.LinkedMesh:{const e=16&h?t.readStringRef():c;if(null==e)throw new Error("Path of linked mesh must not be null");const a=32&h?t.readInt32():4294967295,l=64&h?this.readSequence(t):null,d=!!(128&h),u=t.readInt(!0),m=t.readStringRef();let f=0,p=0;r&&(f=t.readFloat(),p=t.readFloat());let g=this.attachmentLoader.newMeshAttachment(s,c,e,l);return g?(g.path=e,n.rgba8888ToColor(g.color,a),g.sequence=l,r&&(g.width=f*o,g.height=p*o),this.linkedMeshes.push(new oe(g,u,i,m,d)),g):null}case Bt.Path:{const e=!!(16&h),i=!!(32&h),a=this.readVertices(t,!!(64&h)),d=l.newArray(a.length/6,0);for(let e=0,s=d.length;e<s;e++)d[e]=t.readFloat()*o;const u=r?t.readInt32():0,m=this.attachmentLoader.newPathAttachment(s,c);return m?(m.closed=e,m.constantSpeed=i,m.worldVerticesLength=a.length,m.vertices=a.vertices,m.bones=a.bones,m.lengths=d,r&&n.rgba8888ToColor(m.color,u),m):null}case Bt.Point:{const e=t.readFloat(),i=t.readFloat(),a=t.readFloat(),l=r?t.readInt32():0,h=this.attachmentLoader.newPointAttachment(s,c);return h?(h.x=i*o,h.y=a*o,h.rotation=e,r&&n.rgba8888ToColor(h.color,l),h):null}case Bt.Clipping:{const i=t.readInt(!0),a=this.readVertices(t,!!(16&h));let o=r?t.readInt32():0,l=this.attachmentLoader.newClippingAttachment(s,c);return l?(l.endSlot=e.slots[i],l.worldVerticesLength=a.length,l.vertices=a.vertices,l.bones=a.bones,r&&n.rgba8888ToColor(l.color,o),l):null}}return null}readSequence(t){let e=new m(t.readInt(!0));return e.start=t.readInt(!0),e.digits=t.readInt(!0),e.setupIndex=t.readInt(!0),e}readVertices(t,e){const s=this.scale,i=t.readInt(!0),n=new le;if(n.length=i<<1,!e)return n.vertices=this.readFloatArray(t,n.length,s),n;let a=new Array,r=new Array;for(let e=0;e<i;e++){let e=t.readInt(!0);r.push(e);for(let i=0;i<e;i++)r.push(t.readInt(!0)),a.push(t.readFloat()*s),a.push(t.readFloat()*s),a.push(t.readFloat())}return n.vertices=l.toFloatArray(a),n.bones=r,n}readFloatArray(t,e,s){let i=new Array(e);if(1==s)for(let s=0;s<e;s++)i[s]=t.readFloat();else for(let n=0;n<e;n++)i[n]=t.readFloat()*s;return i}readShortArray(t,e){let s=new Array(e);for(let i=0;i<e;i++)s[i]=t.readInt(!0);return s}readAnimation(e,s,i){e.readInt(!0);let n=new Array,a=this.scale;for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0),a=i-1;switch(s){case ve:{let s=new N(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readStringRef());n.push(s);break}case ke:{let s=e.readInt(!0),r=new X(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,u,1),de(e,r,s++,t,3,o,i,d,m,1)}o=i,l=n,h=a,c=u,d=m}n.push(r);break}case Ie:{let s=e.readInt(!0),r=new _(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,d,1)}o=i,l=n,h=a,c=d}n.push(r);break}case Ae:{let s=e.readInt(!0),r=new D(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d,u,m,f),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255,w=e.readUnsignedByte()/255,b=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,p,1),de(e,r,s++,t,3,o,i,d,g,1),de(e,r,s++,t,4,o,i,u,x,1),de(e,r,s++,t,5,o,i,m,w,1),de(e,r,s++,t,6,o,i,f,b,1)}o=i,l=n,h=a,c=p,d=g,u=x,m=w,f=b}n.push(r);break}case Te:{let s=e.readInt(!0),r=new O(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d,u,m),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,f,1),de(e,r,s++,t,3,o,i,d,p,1),de(e,r,s++,t,4,o,i,u,g,1),de(e,r,s++,t,5,o,i,m,x,1)}o=i,l=n,h=a,c=f,d=p,u=g,m=x}n.push(r);break}case Be:{let s=new V(i,e.readInt(!0),t),r=e.readFloat(),o=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,r,o),t!=a;t++){let n=e.readFloat(),a=e.readUnsignedByte()/255;switch(e.readByte()){case qe:s.setStepped(t);break;case Ue:de(e,s,i++,t,0,r,n,o,a,1)}r=n,o=a}n.push(s)}}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0);if(s==Se){let s=new P(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readByte());n.push(s);continue}let r=e.readInt(!0);switch(s){case ue:n.push(he(e,new k(i,r,t),1));break;case me:n.push(ce(e,new I(i,r,t),a));break;case fe:n.push(he(e,new A(i,r,t),a));break;case pe:n.push(he(e,new T(i,r,t),a));break;case ge:n.push(ce(e,new B(i,r,t),1));break;case xe:n.push(he(e,new C(i,r,t),1));break;case we:n.push(he(e,new F(i,r,t),1));break;case be:n.push(ce(e,new E(i,r,t),1));break;case ye:n.push(he(e,new R(i,r,t),1));break;case Me:n.push(he(e,new Y(i,r,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,r=new W(s,e.readInt(!0),t),o=e.readByte(),l=e.readFloat(),h=1&o?2&o?e.readFloat():1:0,c=4&o?e.readFloat()*a:0;for(let t=0,s=0;r.setFrame(t,l,h,c,8&o?1:-1,!!(16&o),!!(32&o)),t!=i;t++){o=e.readByte();const i=e.readFloat(),n=1&o?2&o?e.readFloat():1:0,d=4&o?e.readFloat()*a:0;64&o?r.setStepped(t):128&o&&(de(e,r,s++,t,0,l,i,h,n,1),de(e,r,s++,t,1,l,i,c,d,a)),l=i,h=n,c=d}n.push(r)}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,a=new z(s,e.readInt(!0),t),r=e.readFloat(),o=e.readFloat(),l=e.readFloat(),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0;a.setFrame(t,r,o,l,h,c,d,u),t!=i;t++){let i=e.readFloat(),n=e.readFloat(),m=e.readFloat(),f=e.readFloat(),p=e.readFloat(),g=e.readFloat(),x=e.readFloat();switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,r,i,o,n,1),de(e,a,s++,t,1,r,i,l,m,1),de(e,a,s++,t,2,r,i,h,f,1),de(e,a,s++,t,3,r,i,c,p,1),de(e,a,s++,t,4,r,i,d,g,1),de(e,a,s++,t,5,r,i,u,x,1)}r=i,o=n,l=m,h=f,c=p,d=g,u=x}n.push(a)}for(let s=0,r=e.readInt(!0);s<r;s++){let s=e.readInt(!0),r=i.pathConstraints[s];for(let i=0,o=e.readInt(!0);i<o;i++){const i=e.readByte(),o=e.readInt(!0),l=e.readInt(!0);switch(i){case Ee:n.push(he(e,new G(o,l,s),r.positionMode==t.PositionMode.Fixed?a:1));break;case Re:n.push(he(e,new $(o,l,s),r.spacingMode==t.SpacingMode.Length||r.spacingMode==t.SpacingMode.Fixed?a:1));break;case Ye:let i=new j(o,l,s),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0,n=i.getFrameCount()-1;i.setFrame(t,h,c,d,u),t!=n;t++){let n=e.readFloat(),a=e.readFloat(),r=e.readFloat(),o=e.readFloat();switch(e.readByte()){case qe:i.setStepped(t);break;case Ue:de(e,i,s++,t,0,h,n,c,a,1),de(e,i,s++,t,1,h,n,d,r,1),de(e,i,s++,t,2,h,n,u,o,1)}h=n,c=a,d=r,u=o}n.push(i)}}}for(let t=0,s=e.readInt(!0);t<s;t++){const t=e.readInt(!0)-1;for(let s=0,i=e.readInt(!0);s<i;s++){const s=e.readByte(),i=e.readInt(!0);if(s==Le){const s=new it(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat());n.push(s);continue}const a=e.readInt(!0);switch(s){case Pe:n.push(he(e,new J(i,a,t),1));break;case Xe:n.push(he(e,new K(i,a,t),1));break;case _e:n.push(he(e,new Q(i,a,t),1));break;case Ve:n.push(he(e,new Z(i,a,t),1));break;case De:n.push(he(e,new tt(i,a,t),1));break;case Oe:n.push(he(e,new et(i,a,t),1));break;case Ne:n.push(he(e,new st(i,a,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=i.skins[e.readInt(!0)];for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readInt(!0);for(let i=0,r=e.readInt(!0);i<r;i++){let i=e.readStringRef();if(!i)throw new Error("attachmentName must not be null.");let r=t.getAttachment(s,i),o=e.readByte(),h=e.readInt(!0),c=h-1;switch(o){case Ce:{let t=r,i=t.bones,o=t.vertices,d=i?o.length/3*2:o.length,u=e.readInt(!0),m=new L(h,u,s,t),f=e.readFloat();for(let t=0,s=0;;t++){let n,r=e.readInt(!0);if(0==r)n=i?l.newFloatArray(d):o;else{n=l.newFloatArray(d);let t=e.readInt(!0);if(r+=t,1==a)for(let s=t;s<r;s++)n[s]=e.readFloat();else for(let s=t;s<r;s++)n[s]=e.readFloat()*a;if(!i)for(let t=0,e=n.length;t<e;t++)n[t]+=o[t]}if(m.setFrame(t,f,n),t==c)break;let h=e.readFloat();switch(e.readByte()){case qe:m.setStepped(t);break;case Ue:de(e,m,s++,t,0,f,h,0,1,1)}f=h}n.push(m);break}case Fe:{let t=new nt(h,s,r);for(let s=0;s<h;s++){let i=e.readFloat(),n=e.readInt32();t.setFrame(s,i,p[15&n],n>>4,e.readFloat())}n.push(t);break}}}}}let r=e.readInt(!0);if(r>0){let t=new U(r),s=i.slots.length;for(let i=0;i<r;i++){let n=e.readFloat(),a=e.readInt(!0),r=l.newArray(s,0);for(let t=s-1;t>=0;t--)r[t]=-1;let o=l.newArray(s-a,0),h=0,c=0;for(let t=0;t<a;t++){let t=e.readInt(!0);for(;h!=t;)o[c++]=h++;r[h+e.readInt(!0)]=h++}for(;h<s;)o[c++]=h++;for(let t=s-1;t>=0;t--)-1==r[t]&&(r[t]=o[--c]);t.setFrame(i,n,r)}n.push(t)}let o=e.readInt(!0);if(o>0){let t=new q(o);for(let s=0;s<o;s++){let n=e.readFloat(),a=i.events[e.readInt(!0)],r=new Ut(n,a);r.intValue=e.readInt(!1),r.floatValue=e.readFloat(),r.stringValue=e.readString(),null==r.stringValue&&(r.stringValue=a.stringValue),r.data.audioPath&&(r.volume=e.readFloat(),r.balance=e.readFloat()),t.setFrame(s,r)}n.push(t)}let h=0;for(let t=0,e=n.length;t<e;t++)h=Math.max(h,n[t].getDuration());return new g(s,n,h)}}class re{strings;index;buffer;constructor(t,e=new Array,s=0,i=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=i}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){let t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){let t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=127&e;return 128&e&&(e=this.readByte(),s|=(127&e)<<7,128&e&&(e=this.readByte(),s|=(127&e)<<14,128&e&&(e=this.readByte(),s|=(127&e)<<21,128&e&&(e=this.readByte(),s|=(127&e)<<28)))),t?s:s>>>1^-(1&s)}readStringRef(){let t=this.readInt(!0);return 0==t?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;){let t=this.readUnsignedByte();switch(t>>4){case 12:case 13:e+=String.fromCharCode((31&t)<<6|63&this.readByte()),s+=2;break;case 14:e+=String.fromCharCode((15&t)<<12|(63&this.readByte())<<6|63&this.readByte()),s+=3;break;default:e+=String.fromCharCode(t),s++}}return e}readFloat(){let t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return 0!=this.readByte()}}class oe{parent;skinIndex;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}class le{bones;vertices;length;constructor(t=null,e=null,s=0){this.bones=t,this.vertices=e,this.length=s}}function he(t,e,s){let i=t.readFloat(),n=t.readFloat()*s;for(let a=0,r=0,o=e.getFrameCount()-1;e.setFrame(a,i,n),a!=o;a++){let o=t.readFloat(),l=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(a);break;case Ue:de(t,e,r++,a,0,i,o,n,l,s)}i=o,n=l}return e}function ce(t,e,s){let i=t.readFloat(),n=t.readFloat()*s,a=t.readFloat()*s;for(let r=0,o=0,l=e.getFrameCount()-1;e.setFrame(r,i,n,a),r!=l;r++){let l=t.readFloat(),h=t.readFloat()*s,c=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(r);break;case Ue:de(t,e,o++,r,0,i,l,n,h,s),de(t,e,o++,r,1,i,l,a,c,s)}i=l,n=h,a=c}return e}function de(t,e,s,i,n,a,r,o,l,h){e.setBezier(s,i,n,a,o,t.readFloat(),t.readFloat()*h,t.readFloat(),t.readFloat()*h,r,l)}!function(t){t[t.Region=0]="Region",t[t.BoundingBox=1]="BoundingBox",t[t.Mesh=2]="Mesh",t[t.LinkedMesh=3]="LinkedMesh",t[t.Path=4]="Path",t[t.Point=5]="Point",t[t.Clipping=6]="Clipping"}(Bt||(Bt={}));const ue=0,me=1,fe=2,pe=3,ge=4,xe=5,we=6,be=7,ye=8,Me=9,Se=10,ve=0,ke=1,Ie=2,Ae=3,Te=4,Be=5,Ce=0,Fe=1,Ee=0,Re=1,Ye=2,Pe=0,Xe=1,_e=2,Ve=4,De=5,Oe=6,Ne=7,Le=8,qe=1,Ue=2;class We{convexPolygons=new Array;convexPolygonsIndices=new Array;indicesArray=new Array;isConcaveArray=new Array;triangles=new Array;polygonPool=new h((()=>new Array));polygonIndicesPool=new h((()=>new Array));triangulate(t){let e=t,s=t.length>>1,i=this.indicesArray;i.length=0;for(let t=0;t<s;t++)i[t]=t;let n=this.isConcaveArray;n.length=0;for(let t=0,a=s;t<a;++t)n[t]=We.isConcave(t,s,e,i);let a=this.triangles;for(a.length=0;s>3;){let t=s-1,r=0,o=1;for(;;){t:if(!n[r]){let a=i[t]<<1,l=i[r]<<1,h=i[o]<<1,c=e[a],d=e[a+1],u=e[l],m=e[l+1],f=e[h],p=e[h+1];for(let a=(o+1)%s;a!=t;a=(a+1)%s){if(!n[a])continue;let t=i[a]<<1,s=e[t],r=e[t+1];if(We.positiveArea(f,p,c,d,s,r)&&We.positiveArea(c,d,u,m,s,r)&&We.positiveArea(u,m,f,p,s,r))break t}break}if(0==o){do{if(!n[r])break;r--}while(r>0);break}t=r,r=o,o=(o+1)%s}a.push(i[(s+r-1)%s]),a.push(i[r]),a.push(i[(r+1)%s]),i.splice(r,1),n.splice(r,1),s--;let l=(s+r-1)%s,h=r==s?0:r;n[l]=We.isConcave(l,s,e,i),n[h]=We.isConcave(h,s,e,i)}return 3==s&&(a.push(i[2]),a.push(i[0]),a.push(i[1])),a}decompose(t,e){let s=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;let n=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(n),n.length=0;let a=this.polygonIndicesPool.obtain();a.length=0;let r=this.polygonPool.obtain();r.length=0;let o=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,c=e[t+1]<<1,d=e[t+2]<<1,u=s[h],m=s[h+1],f=s[c],p=s[c+1],g=s[d],x=s[d+1],w=!1;if(o==h){let t=r.length-4,e=We.winding(r[t],r[t+1],r[t+2],r[t+3],g,x),s=We.winding(g,x,r[0],r[1],r[2],r[3]);e==l&&s==l&&(r.push(g),r.push(x),a.push(d),w=!0)}w||(r.length>0?(i.push(r),n.push(a)):(this.polygonPool.free(r),this.polygonIndicesPool.free(a)),r=this.polygonPool.obtain(),r.length=0,r.push(u),r.push(m),r.push(f),r.push(p),r.push(g),r.push(x),a=this.polygonIndicesPool.obtain(),a.length=0,a.push(h),a.push(c),a.push(d),l=We.winding(u,m,f,p,g,x),o=h)}r.length>0&&(i.push(r),n.push(a));for(let t=0,e=i.length;t<e;t++){if(a=n[t],0==a.length)continue;let s=a[0],o=a[a.length-1];r=i[t];let l=r.length-4,h=r[l],c=r[l+1],d=r[l+2],u=r[l+3],m=r[0],f=r[1],p=r[2],g=r[3],x=We.winding(h,c,d,u,m,f);for(let l=0;l<e;l++){if(l==t)continue;let e=n[l];if(3!=e.length)continue;let w=e[0],b=e[1],y=e[2],M=i[l],S=M[M.length-2],v=M[M.length-1];if(w!=s||b!=o)continue;let k=We.winding(h,c,d,u,S,v),I=We.winding(S,v,m,f,p,g);k==x&&I==x&&(M.length=0,e.length=0,r.push(S),r.push(v),a.push(y),h=d,c=u,d=S,u=v,l=0)}}for(let t=i.length-1;t>=0;t--)r=i[t],0==r.length&&(i.splice(t,1),this.polygonPool.free(r),a=n[t],n.splice(t,1),this.polygonIndicesPool.free(a));return i}static isConcave(t,e,s,i){let n=i[(e+t-1)%e]<<1,a=i[t]<<1,r=i[(t+1)%e]<<1;return!this.positiveArea(s[n],s[n+1],s[a],s[a+1],s[r],s[r+1])}static positiveArea(t,e,s,i,n,a){return t*(a-i)+s*(e-a)+n*(i-e)>=0}static winding(t,e,s,i,n,a){let r=s-t,o=i-e;return n*o-a*r+r*e-t*o>=0?1:-1}}class ze{triangulator=new We;clippingPolygon=new Array;clipOutput=new Array;clippedVertices=new Array;clippedUVs=new Array;clippedTriangles=new Array;scratch=new Array;clipAttachment=null;clippingPolygons=null;clipStart(t,e){if(this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=l.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ze.makeClockwise(n);let a=this.clippingPolygons=this.triangulator.decompose(n,this.triangulator.triangulate(n));for(let t=0,e=a.length;t<e;t++){let e=a[t];ze.makeClockwise(e),e.push(e[0]),e.push(e[1])}return a.length}clipEndWithSlot(t){this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,n,a,r){i&&n&&a&&"boolean"==typeof r?this.clipTrianglesRender(t,e,s,i,n,a,r):this.clipTrianglesNoRender(t,e,s)}clipTrianglesNoRender(t,e,s){let i=this.clipOutput,n=this.clippedVertices,a=this.clippedTriangles,r=this.clippingPolygons,o=r.length,h=0;n.length=0,a.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,d=t[s],u=t[s+1];s=e[c+1]<<1;let m=t[s],f=t[s+1];s=e[c+2]<<1;let p=t[s],g=t[s+1];for(let t=0;t<o;t++){let e=n.length;if(!this.clip(d,u,m,f,p,g,r[t],i)){let t=l.setArraySize(n,e+6);t[e]=d,t[e+1]=u,t[e+2]=m,t[e+3]=f,t[e+4]=p,t[e+5]=g,e=a.length;let s=l.setArraySize(a,e+3);s[e]=h,s[e+1]=h+1,s[e+2]=h+2,h+=3;break}{let t=i.length;if(0==t)continue;let s=t>>1,r=this.clipOutput,o=l.setArraySize(n,e+2*s);for(let s=0;s<t;s+=2,e+=2){let t=r[s],i=r[s+1];o[e]=t,o[e+1]=i}e=a.length;let c=l.setArraySize(a,e+3*(s-2));s--;for(let t=1;t<s;t++,e+=3)c[e]=h,c[e+1]=h+t,c[e+2]=h+t+1;h+=s+1}}}}clipTrianglesRender(t,e,s,i,n,a,r){let o=this.clipOutput,h=this.clippedVertices,c=this.clippedTriangles,d=this.clippingPolygons,u=d.length,m=r?12:8,f=0;h.length=0,c.length=0;for(let p=0;p<s;p+=3){let s=e[p]<<1,g=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[p+1]<<1;let y=t[s],M=t[s+1],S=i[s],v=i[s+1];s=e[p+2]<<1;let k=t[s],I=t[s+1],A=i[s],T=i[s+1];for(let t=0;t<u;t++){let e=h.length;if(!this.clip(g,x,y,M,k,I,d[t],o)){let t=l.setArraySize(h,e+3*m);t[e]=g,t[e+1]=x,t[e+2]=n.r,t[e+3]=n.g,t[e+4]=n.b,t[e+5]=n.a,r?(t[e+6]=w,t[e+7]=b,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=y,t[e+13]=M,t[e+14]=n.r,t[e+15]=n.g,t[e+16]=n.b,t[e+17]=n.a,t[e+18]=S,t[e+19]=v,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=k,t[e+25]=I,t[e+26]=n.r,t[e+27]=n.g,t[e+28]=n.b,t[e+29]=n.a,t[e+30]=A,t[e+31]=T,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=w,t[e+7]=b,t[e+8]=y,t[e+9]=M,t[e+10]=n.r,t[e+11]=n.g,t[e+12]=n.b,t[e+13]=n.a,t[e+14]=S,t[e+15]=v,t[e+16]=k,t[e+17]=I,t[e+18]=n.r,t[e+19]=n.g,t[e+20]=n.b,t[e+21]=n.a,t[e+22]=A,t[e+23]=T),e=c.length;let s=l.setArraySize(c,e+3);s[e]=f,s[e+1]=f+1,s[e+2]=f+2,f+=3;break}{let t=o.length;if(0==t)continue;let s=M-I,i=k-y,d=g-k,u=I-x,p=1/(s*d+i*(x-I)),B=t>>1,C=this.clipOutput,F=l.setArraySize(h,e+B*m);for(let o=0;o<t;o+=2,e+=m){let t=C[o],l=C[o+1];F[e]=t,F[e+1]=l,F[e+2]=n.r,F[e+3]=n.g,F[e+4]=n.b,F[e+5]=n.a;let h=t-k,c=l-I,m=(s*h+i*c)*p,f=(u*h+d*c)*p,g=1-m-f;F[e+6]=w*m+S*f+A*g,F[e+7]=b*m+v*f+T*g,r&&(F[e+8]=a.r,F[e+9]=a.g,F[e+10]=a.b,F[e+11]=a.a)}e=c.length;let E=l.setArraySize(c,e+3*(B-2));B--;for(let t=1;t<B;t++,e+=3)E[e]=f,E[e+1]=f+t,E[e+2]=f+t+1;f+=B+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,a=this.clippedVertices,r=this.clippedUVs,o=this.clippedTriangles,h=this.clippingPolygons,c=h.length,d=0;a.length=0,r.length=0,o.length=0;for(let u=0;u<s;u+=3){let s=e[u]<<1,m=t[s],f=t[s+1],p=i[s],g=i[s+1];s=e[u+1]<<1;let x=t[s],w=t[s+1],b=i[s],y=i[s+1];s=e[u+2]<<1;let M=t[s],S=t[s+1],v=i[s],k=i[s+1];for(let t=0;t<c;t++){let e=a.length;if(!this.clip(m,f,x,w,M,S,h[t],n)){let t=l.setArraySize(a,e+6);t[e]=m,t[e+1]=f,t[e+2]=x,t[e+3]=w,t[e+4]=M,t[e+5]=S;let s=l.setArraySize(r,e+6);s[e]=p,s[e+1]=g,s[e+2]=b,s[e+3]=y,s[e+4]=v,s[e+5]=k,e=o.length;let i=l.setArraySize(o,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}{let t=n.length;if(0==t)continue;let s=w-S,i=M-x,h=m-M,c=S-f,u=1/(s*h+i*(f-S)),I=t>>1,A=this.clipOutput,T=l.setArraySize(a,e+2*I),B=l.setArraySize(r,e+2*I);for(let n=0;n<t;n+=2,e+=2){let t=A[n],a=A[n+1];T[e]=t,T[e+1]=a;let r=t-M,o=a-S,l=(s*r+i*o)*u,d=(c*r+h*o)*u,m=1-l-d;B[e]=p*l+b*d+v*m,B[e+1]=g*l+y*d+k*m}e=o.length;let C=l.setArraySize(o,e+3*(I-2));I--;for(let t=1;t<I;t++,e+=3)C[e]=d,C[e+1]=d+t,C[e+2]=d+t+1;d+=I+1}}}}clip(t,e,s,i,n,a,r,o){let l,h=o,c=!1;r.length%4>=2?(l=o,o=this.scratch):l=this.scratch,l.length=0,l.push(t),l.push(e),l.push(s),l.push(i),l.push(n),l.push(a),l.push(t),l.push(e),o.length=0;let d=r.length-4,u=r;for(let t=0;;t+=2){let e=u[t],s=u[t+1],i=e-u[t+2],n=s-u[t+3],a=o.length,r=l;for(let t=0,a=l.length-2;t<a;){let a=r[t],l=r[t+1];t+=2;let h=r[t],d=r[t+1],u=n*(e-h)>i*(s-d),m=n*(e-a)-i*(s-l);if(m>0){if(u){o.push(h),o.push(d);continue}let t=h-a,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(a+t*s),o.push(l+e*s)}else if(u){let t=h-a,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(a+t*s),o.push(l+e*s),o.push(h),o.push(d)}c=!0}if(a==o.length)return h.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==d)break;let m=o;(o=l).length=0,l=m}if(h!=o){h.length=0;for(let t=0,e=o.length-2;t<e;t++)h[t]=o[t]}else h.length=h.length-2;return c}static makeClockwise(t){let e=t,s=t.length,i=e[s-2]*e[1]-e[0]*e[s-1],n=0,a=0,r=0,o=0;for(let t=0,l=s-3;t<l;t+=2)n=e[t],a=e[t+1],r=e[t+2],o=e[t+3],i+=n*o-r*a;if(!(i<0))for(let t=0,i=s-2,n=s>>1;t<n;t+=2){let s=e[t],n=e[t+1],a=i-t;e[t]=e[a],e[t+1]=e[a+1],e[a]=s,e[a+1]=n}}}class Ge{attachmentLoader;scale=1;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te,a="string"==typeof e?JSON.parse(e):e,r=a.skeleton;if(r&&(i.hash=r.hash,i.version=r.spine,i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height,i.referenceScale=Ke(r,"referenceScale",100)*s,i.fps=r.fps,i.imagesPath=r.images??null,i.audioPath=r.audio??null),a.bones)for(let e=0;e<a.bones.length;e++){let n=a.bones[e],r=null,o=Ke(n,"parent",null);o&&(r=i.findBone(o));let h=new Ot(i.bones.length,n.name,r);h.length=Ke(n,"length",0)*s,h.x=Ke(n,"x",0)*s,h.y=Ke(n,"y",0)*s,h.rotation=Ke(n,"rotation",0),h.scaleX=Ke(n,"scaleX",1),h.scaleY=Ke(n,"scaleY",1),h.shearX=Ke(n,"shearX",0),h.shearY=Ke(n,"shearY",0),h.inherit=l.enumValue(t.Inherit,Ke(n,"inherit","Normal")),h.skinRequired=Ke(n,"skin",!1);let c=Ke(n,"color",null);c&&h.color.setFromString(c),i.bones.push(h)}if(a.slots)for(let e=0;e<a.slots.length;e++){let s=a.slots[e],r=s.name,o=i.findBone(s.bone);if(!o)throw new Error(`Couldn't find bone ${s.bone} for slot ${r}`);let h=new ie(i.slots.length,r,o),c=Ke(s,"color",null);c&&h.color.setFromString(c);let d=Ke(s,"dark",null);d&&(h.darkColor=n.fromString(d)),h.attachmentName=Ke(s,"attachment",null),h.blendMode=l.enumValue(t.BlendMode,Ke(s,"blend","normal")),h.visible=Ke(s,"visible",!0),i.slots.push(h)}if(a.ik)for(let t=0;t<a.ik.length;t++){let e=a.ik[t],n=new Gt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=i.findBone(e.bones[t]);if(!s)throw new Error(`Couldn't find bone ${e.bones[t]} for IK constraint ${e.name}.`);n.bones.push(s)}let r=i.findBone(e.target);if(!r)throw new Error(`Couldn't find target bone ${e.target} for IK constraint ${e.name}.`);n.target=r,n.mix=Ke(e,"mix",1),n.softness=Ke(e,"softness",0)*s,n.bendDirection=Ke(e,"bendPositive",!0)?1:-1,n.compress=Ke(e,"compress",!1),n.stretch=Ke(e,"stretch",!1),n.uniform=Ke(e,"uniform",!1),i.ikConstraints.push(n)}if(a.transform)for(let t=0;t<a.transform.length;t++){let e=a.transform[t],n=new ne(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=e.bones[t],a=i.findBone(s);if(!a)throw new Error(`Couldn't find bone ${s} for transform constraint ${e.name}.`);n.bones.push(a)}let r=e.target,o=i.findBone(r);if(!o)throw new Error(`Couldn't find target bone ${r} for transform constraint ${e.name}.`);n.target=o,n.local=Ke(e,"local",!1),n.relative=Ke(e,"relative",!1),n.offsetRotation=Ke(e,"rotation",0),n.offsetX=Ke(e,"x",0)*s,n.offsetY=Ke(e,"y",0)*s,n.offsetScaleX=Ke(e,"scaleX",0),n.offsetScaleY=Ke(e,"scaleY",0),n.offsetShearY=Ke(e,"shearY",0),n.mixRotate=Ke(e,"mixRotate",1),n.mixX=Ke(e,"mixX",1),n.mixY=Ke(e,"mixY",n.mixX),n.mixScaleX=Ke(e,"mixScaleX",1),n.mixScaleY=Ke(e,"mixScaleY",n.mixScaleX),n.mixShearY=Ke(e,"mixShearY",1),i.transformConstraints.push(n)}if(a.path)for(let e=0;e<a.path.length;e++){let n=a.path[e],r=new $t(n.name);r.order=Ke(n,"order",0),r.skinRequired=Ke(n,"skin",!1);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],s=i.findBone(e);if(!s)throw new Error(`Couldn't find bone ${e} for path constraint ${n.name}.`);r.bones.push(s)}let o=n.target,h=i.findSlot(o);if(!h)throw new Error(`Couldn't find target slot ${o} for path constraint ${n.name}.`);r.target=h,r.positionMode=l.enumValue(t.PositionMode,Ke(n,"positionMode","Percent")),r.spacingMode=l.enumValue(t.SpacingMode,Ke(n,"spacingMode","Length")),r.rotateMode=l.enumValue(t.RotateMode,Ke(n,"rotateMode","Tangent")),r.offsetRotation=Ke(n,"rotation",0),r.position=Ke(n,"position",0),r.positionMode==t.PositionMode.Fixed&&(r.position*=s),r.spacing=Ke(n,"spacing",0),r.spacingMode!=t.SpacingMode.Length&&r.spacingMode!=t.SpacingMode.Fixed||(r.spacing*=s),r.mixRotate=Ke(n,"mixRotate",1),r.mixX=Ke(n,"mixX",1),r.mixY=Ke(n,"mixY",r.mixX),i.pathConstraints.push(r)}if(a.physics)for(let t=0;t<a.physics.length;t++){const e=a.physics[t],n=new Zt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);const r=e.bone,o=i.findBone(r);if(null==o)throw new Error("Physics bone not found: "+r);n.bone=o,n.x=Ke(e,"x",0),n.y=Ke(e,"y",0),n.rotate=Ke(e,"rotate",0),n.scaleX=Ke(e,"scaleX",0),n.shearX=Ke(e,"shearX",0),n.limit=Ke(e,"limit",5e3)*s,n.step=1/Ke(e,"fps",60),n.inertia=Ke(e,"inertia",1),n.strength=Ke(e,"strength",100),n.damping=Ke(e,"damping",1),n.massInverse=1/Ke(e,"mass",1),n.wind=Ke(e,"wind",0),n.gravity=Ke(e,"gravity",0),n.mix=Ke(e,"mix",1),n.inertiaGlobal=Ke(e,"inertiaGlobal",!1),n.strengthGlobal=Ke(e,"strengthGlobal",!1),n.dampingGlobal=Ke(e,"dampingGlobal",!1),n.massGlobal=Ke(e,"massGlobal",!1),n.windGlobal=Ke(e,"windGlobal",!1),n.gravityGlobal=Ke(e,"gravityGlobal",!1),n.mixGlobal=Ke(e,"mixGlobal",!1),i.physicsConstraints.push(n)}if(a.skins)for(let t=0;t<a.skins.length;t++){let e=a.skins[t],s=new se(e.name);if(e.bones)for(let t=0;t<e.bones.length;t++){let n=e.bones[t],a=i.findBone(n);if(!a)throw new Error(`Couldn't find bone ${n} for skin ${e.name}.`);s.bones.push(a)}if(e.ik)for(let t=0;t<e.ik.length;t++){let n=e.ik[t],a=i.findIkConstraint(n);if(!a)throw new Error(`Couldn't find IK constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.transform)for(let t=0;t<e.transform.length;t++){let n=e.transform[t],a=i.findTransformConstraint(n);if(!a)throw new Error(`Couldn't find transform constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.path)for(let t=0;t<e.path.length;t++){let n=e.path[t],a=i.findPathConstraint(n);if(!a)throw new Error(`Couldn't find path constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.physics)for(let t=0;t<e.physics.length;t++){let n=e.physics[t],a=i.findPhysicsConstraint(n);if(!a)throw new Error(`Couldn't find physics constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}for(let t in e.attachments){let n=i.findSlot(t);if(!n)throw new Error(`Couldn't find slot ${t} for skin ${e.name}.`);let a=e.attachments[t];for(let t in a){let e=this.readAttachment(a[t],s,n.index,t,i);e&&s.setAttachment(n.index,t,e)}}i.skins.push(s),"default"==s.name&&(i.defaultSkin=s)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],s=e.skin?i.findSkin(e.skin):i.defaultSkin;if(!s)throw new Error(`Skin not found: ${e.skin}`);let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}if(this.linkedMeshes.length=0,a.events)for(let t in a.events){let e=a.events[t],s=new Wt(t);s.intValue=Ke(e,"int",0),s.floatValue=Ke(e,"float",0),s.stringValue=Ke(e,"string",""),s.audioPath=Ke(e,"audio",null),s.audioPath&&(s.volume=Ke(e,"volume",1),s.balance=Ke(e,"balance",0)),i.events.push(s)}if(a.animations)for(let t in a.animations){let e=a.animations[t];this.readAnimation(e,t,i)}return i}readAttachment(t,e,s,i,n){let a=this.scale;switch(i=Ke(t,"name",i),Ke(t,"type","region")){case"region":{let s=Ke(t,"path",i),n=this.readSequence(Ke(t,"sequence",null)),r=this.attachmentLoader.newRegionAttachment(e,i,s,n);if(!r)return null;r.path=s,r.x=Ke(t,"x",0)*a,r.y=Ke(t,"y",0)*a,r.scaleX=Ke(t,"scaleX",1),r.scaleY=Ke(t,"scaleY",1),r.rotation=Ke(t,"rotation",0),r.width=t.width*a,r.height=t.height*a,r.sequence=n;let o=Ke(t,"color",null);return o&&r.color.setFromString(o),null!=r.region&&r.updateRegion(),r}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(!s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=Ke(t,"path",i),r=this.readSequence(Ke(t,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(e,i,n,r);if(!o)return null;o.path=n;let l=Ke(t,"color",null);l&&o.color.setFromString(l),o.width=Ke(t,"width",0)*a,o.height=Ke(t,"height",0)*a,o.sequence=r;let h=Ke(t,"parent",null);if(h)return this.linkedMeshes.push(new $e(o,Ke(t,"skin",null),s,h,Ke(t,"timelines",!0))),o;let c=t.uvs;return this.readVertices(t,o,c.length),o.triangles=t.triangles,o.regionUVs=c,null!=o.region&&o.updateRegion(),o.edges=Ke(t,"edges",null),o.hullLength=2*Ke(t,"hull",0),o}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(!s)return null;s.closed=Ke(t,"closed",!1),s.constantSpeed=Ke(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let r=l.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)r[e]=t.lengths[e]*a;s.lengths=r;let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(!s)return null;s.x=Ke(t,"x",0)*a,s.y=Ke(t,"y",0)*a,s.rotation=Ke(t,"rotation",0);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(!s)return null;let a=Ke(t,"end",null);a&&(s.endSlot=n.findSlot(a));let r=t.vertexCount;this.readVertices(t,s,r<<1);let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}}return null}readSequence(t){if(null==t)return null;let e=new m(Ke(t,"count",0));return e.start=Ke(t,"start",1),e.digits=Ke(t,"digits",0),e.setupIndex=Ke(t,"setup",0),e}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=l.toFloatArray(n);if(1!=i)for(let e=0,s=n.length;e<s;e++)t[e]*=i;return void(e.vertices=t)}let a=new Array,r=new Array;for(let t=0,e=n.length;t<e;){let e=n[t++];r.push(e);for(let s=t+4*e;t<s;t+=4)r.push(n[t]),a.push(n[t+1]*i),a.push(n[t+2]*i),a.push(n[t+3])}e.bones=r,e.vertices=l.toFloatArray(a)}readAnimation(e,s,i){let a=this.scale,r=new Array;if(e.slots)for(let t in e.slots){let s=e.slots[t],a=i.findSlot(t);if(!a)throw new Error("Slot not found: "+t);let o=a.index;for(let t in s){let e=s[t];if(!e)continue;let i=e.length;if("attachment"==t){let t=new N(i,o);for(let s=0;s<i;s++){let i=e[s];t.setFrame(s,Ke(i,"time",0),Ke(i,"name",null))}r.push(t)}else if("rgba"==t){let t=new X(i,i<<2,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a);let o=e[i+1];if(!o){t.shrink(r);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(r=Je(d,t,r,i,0,a,h,l.r,c.r,1),r=Je(d,t,r,i,1,a,h,l.g,c.g,1),r=Je(d,t,r,i,2,a,h,l.b,c.b,1),r=Je(d,t,r,i,3,a,h,l.a,c.a,1)),a=h,l=c,s=o}r.push(t)}else if("rgb"==t){let t=new _(i,3*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b);let o=e[i+1];if(!o){t.shrink(r);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(r=Je(d,t,r,i,0,a,h,l.r,c.r,1),r=Je(d,t,r,i,1,a,h,l.g,c.g,1),r=Je(d,t,r,i,2,a,h,l.b,c.b,1)),a=h,l=c,s=o}r.push(t)}else if("alpha"==t)r.push(je(e,new V(i,i,o),0,1));else if("rgba2"==t){let t=new D(i,7*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(r);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(r=Je(m,t,r,i,0,a,c,l.r,d.r,1),r=Je(m,t,r,i,1,a,c,l.g,d.g,1),r=Je(m,t,r,i,2,a,c,l.b,d.b,1),r=Je(m,t,r,i,3,a,c,l.a,d.a,1),r=Je(m,t,r,i,4,a,c,h.r,u.r,1),r=Je(m,t,r,i,5,a,c,h.g,u.g,1),r=Je(m,t,r,i,6,a,c,h.b,u.b,1)),a=c,l=d,h=u,s=o}r.push(t)}else if("rgb2"==t){let t=new O(i,6*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(r);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(r=Je(m,t,r,i,0,a,c,l.r,d.r,1),r=Je(m,t,r,i,1,a,c,l.g,d.g,1),r=Je(m,t,r,i,2,a,c,l.b,d.b,1),r=Je(m,t,r,i,3,a,c,h.r,u.r,1),r=Je(m,t,r,i,4,a,c,h.g,u.g,1),r=Je(m,t,r,i,5,a,c,h.b,u.b,1)),a=c,l=d,h=u,s=o}r.push(t)}}}if(e.bones)for(let s in e.bones){let n=e.bones[s],o=i.findBone(s);if(!o)throw new Error("Bone not found: "+s);let h=o.index;for(let e in n){let s=n[e],i=s.length;if(0!=i)if("rotate"===e)r.push(je(s,new k(i,i,h),0,1));else if("translate"===e){let t=new I(i,i<<1,h);r.push(He(s,t,"x","y",0,a))}else if("translatex"===e){let t=new A(i,i,h);r.push(je(s,t,0,a))}else if("translatey"===e){let t=new T(i,i,h);r.push(je(s,t,0,a))}else if("scale"===e){let t=new B(i,i<<1,h);r.push(He(s,t,"x","y",1,1))}else if("scalex"===e){let t=new C(i,i,h);r.push(je(s,t,1,1))}else if("scaley"===e){let t=new F(i,i,h);r.push(je(s,t,1,1))}else if("shear"===e){let t=new E(i,i<<1,h);r.push(He(s,t,"x","y",0,1))}else if("shearx"===e){let t=new R(i,i,h);r.push(je(s,t,0,1))}else if("sheary"===e){let t=new Y(i,i,h);r.push(je(s,t,0,1))}else if("inherit"===e){let e=new P(i,o.index);for(let i=0;i<s.length;i++){let n=s[i];e.setFrame(i,Ke(n,"time",0),l.enumValue(t.Inherit,Ke(n,"inherit","Normal")))}r.push(e)}}}if(e.ik)for(let t in e.ik){let s=e.ik[t],n=s[0];if(!n)continue;let o=i.findIkConstraint(t);if(!o)throw new Error("IK Constraint not found: "+t);let l=i.ikConstraints.indexOf(o),h=new W(s.length,s.length<<1,l),c=Ke(n,"time",0),d=Ke(n,"mix",1),u=Ke(n,"softness",0)*a;for(let t=0,e=0;;t++){h.setFrame(t,c,d,u,Ke(n,"bendPositive",!0)?1:-1,Ke(n,"compress",!1),Ke(n,"stretch",!1));let i=s[t+1];if(!i){h.shrink(e);break}let r=Ke(i,"time",0),o=Ke(i,"mix",1),l=Ke(i,"softness",0)*a,m=n.curve;m&&(e=Je(m,h,e,t,0,c,r,d,o,1),e=Je(m,h,e,t,1,c,r,u,l,a)),c=r,d=o,u=l,n=i}r.push(h)}if(e.transform)for(let t in e.transform){let s=e.transform[t],n=s[0];if(!n)continue;let a=i.findTransformConstraint(t);if(!a)throw new Error("Transform constraint not found: "+t);let o=i.transformConstraints.indexOf(a),l=new z(s.length,6*s.length,o),h=Ke(n,"time",0),c=Ke(n,"mixRotate",1),d=Ke(n,"mixX",1),u=Ke(n,"mixY",d),m=Ke(n,"mixScaleX",1),f=Ke(n,"mixScaleY",m),p=Ke(n,"mixShearY",1);for(let t=0,e=0;;t++){l.setFrame(t,h,c,d,u,m,f,p);let i=s[t+1];if(!i){l.shrink(e);break}let a=Ke(i,"time",0),r=Ke(i,"mixRotate",1),o=Ke(i,"mixX",1),g=Ke(i,"mixY",o),x=Ke(i,"mixScaleX",1),w=Ke(i,"mixScaleY",x),b=Ke(i,"mixShearY",1),y=n.curve;y&&(e=Je(y,l,e,t,0,h,a,c,r,1),e=Je(y,l,e,t,1,h,a,d,o,1),e=Je(y,l,e,t,2,h,a,u,g,1),e=Je(y,l,e,t,3,h,a,m,x,1),e=Je(y,l,e,t,4,h,a,f,w,1),e=Je(y,l,e,t,5,h,a,p,b,1)),h=a,c=r,d=o,u=g,m=x,f=w,m=x,n=i}r.push(l)}if(e.path)for(let s in e.path){let n=e.path[s],o=i.findPathConstraint(s);if(!o)throw new Error("Path constraint not found: "+s);let l=i.pathConstraints.indexOf(o);for(let e in n){let s=n[e],i=s[0];if(!i)continue;let h=s.length;if("position"===e){let e=new G(h,h,l);r.push(je(s,e,0,o.positionMode==t.PositionMode.Fixed?a:1))}else if("spacing"===e){let e=new $(h,h,l);r.push(je(s,e,0,o.spacingMode==t.SpacingMode.Length||o.spacingMode==t.SpacingMode.Fixed?a:1))}else if("mix"===e){let t=new j(h,3*h,l),e=Ke(i,"time",0),n=Ke(i,"mixRotate",1),a=Ke(i,"mixX",1),o=Ke(i,"mixY",a);for(let r=0,l=0;;r++){t.setFrame(r,e,n,a,o);let h=s[r+1];if(!h){t.shrink(l);break}let c=Ke(h,"time",0),d=Ke(h,"mixRotate",1),u=Ke(h,"mixX",1),m=Ke(h,"mixY",u),f=i.curve;f&&(l=Je(f,t,l,r,0,e,c,n,d,1),l=Je(f,t,l,r,1,e,c,a,u,1),l=Je(f,t,l,r,2,e,c,o,m,1)),e=c,n=d,a=u,o=m,i=h}r.push(t)}}}if(e.physics)for(let t in e.physics){let s=e.physics[t],n=-1;if(t.length>0){let e=i.findPhysicsConstraint(t);if(!e)throw new Error("Physics constraint not found: "+t);n=i.physicsConstraints.indexOf(e)}for(let t in s){let e=s[t],i=e[0];if(!i)continue;let a,o=e.length;if("reset"!=t){if("inertia"==t)a=new J(o,o,n);else if("strength"==t)a=new K(o,o,n);else if("damping"==t)a=new Q(o,o,n);else if("mass"==t)a=new Z(o,o,n);else if("wind"==t)a=new tt(o,o,n);else if("gravity"==t)a=new et(o,o,n);else{if("mix"!=t)continue;a=new st(o,o,n)}r.push(je(e,a,0,1))}else{const t=new it(o,n);for(let s=0;null!=i;i=e[s+1],s++)t.setFrame(s,Ke(i,"time",0));r.push(t)}}}if(e.attachments)for(let t in e.attachments){let s=e.attachments[t],n=i.findSkin(t);if(!n)throw new Error("Skin not found: "+t);for(let t in s){let e=s[t],o=i.findSlot(t);if(!o)throw new Error("Slot not found: "+t);let h=o.index;for(let t in e){let s=e[t],i=n.getAttachment(h,t);for(let t in s){let e=s[t],n=e[0];if(n)if("deform"==t){let t=i.bones,s=i.vertices,o=t?s.length/3*2:s.length,c=new L(e.length,e.length,h,i),d=Ke(n,"time",0);for(let i=0,r=0;;i++){let h,u=Ke(n,"vertices",null);if(u){h=l.newFloatArray(o);let e=Ke(n,"offset",0);if(l.arrayCopy(u,0,h,e,u.length),1!=a)for(let t=e,s=t+u.length;t<s;t++)h[t]*=a;if(!t)for(let t=0;t<o;t++)h[t]+=s[t]}else h=t?l.newFloatArray(o):s;c.setFrame(i,d,h);let m=e[i+1];if(!m){c.shrink(r);break}let f=Ke(m,"time",0),p=n.curve;p&&(r=Je(p,c,r,i,0,d,f,0,1,1)),d=f,n=m}r.push(c)}else if("sequence"==t){let t=new nt(e.length,h,i),s=0;for(let i=0;i<e.length;i++){let a=Ke(n,"delay",s),r=Ke(n,"time",0),o=f[Ke(n,"mode","hold")],l=Ke(n,"index",0);t.setFrame(i,r,o,l,a),s=a,n=e[i+1]}r.push(t)}}}}}if(e.drawOrder){let t=new U(e.drawOrder.length),s=i.slots.length,n=0;for(let a=0;a<e.drawOrder.length;a++,n++){let r=e.drawOrder[a],o=null,h=Ke(r,"offsets",null);if(h){o=l.newArray(s,-1);let t=l.newArray(s-h.length,0),e=0,n=0;for(let s=0;s<h.length;s++){let a=h[s],r=i.findSlot(a.slot);if(!r)throw new Error("Slot not found: "+r);let l=r.index;for(;e!=l;)t[n++]=e++;o[e+a.offset]=e++}for(;e<s;)t[n++]=e++;for(let e=s-1;e>=0;e--)-1==o[e]&&(o[e]=t[--n])}t.setFrame(n,Ke(r,"time",0),o)}r.push(t)}if(e.events){let t=new q(e.events.length),s=0;for(let n=0;n<e.events.length;n++,s++){let a=e.events[n],r=i.findEvent(a.name);if(!r)throw new Error("Event not found: "+a.name);let o=new Ut(l.toSinglePrecision(Ke(a,"time",0)),r);o.intValue=Ke(a,"int",r.intValue),o.floatValue=Ke(a,"float",r.floatValue),o.stringValue=Ke(a,"string",r.stringValue),o.data.audioPath&&(o.volume=Ke(a,"volume",1),o.balance=Ke(a,"balance",0)),t.setFrame(s,o)}r.push(t)}let o=0;for(let t=0,e=r.length;t<e;t++)o=Math.max(o,r[t].getDuration());i.animations.push(new g(s,r,o))}}class $e{parent;skin;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}function je(t,e,s,i){let n=t[0],a=Ke(n,"time",0),r=Ke(n,"value",s)*i,o=0;for(let l=0;;l++){e.setFrame(l,a,r);let h=t[l+1];if(!h)return e.shrink(o),e;let c=Ke(h,"time",0),d=Ke(h,"value",s)*i;n.curve&&(o=Je(n.curve,e,o,l,0,a,c,r,d,i)),a=c,r=d,n=h}}function He(t,e,s,i,n,a){let r=t[0],o=Ke(r,"time",0),l=Ke(r,s,n)*a,h=Ke(r,i,n)*a,c=0;for(let d=0;;d++){e.setFrame(d,o,l,h);let u=t[d+1];if(!u)return e.shrink(c),e;let m=Ke(u,"time",0),f=Ke(u,s,n)*a,p=Ke(u,i,n)*a,g=r.curve;g&&(c=Je(g,e,c,d,0,o,m,l,f,a),c=Je(g,e,c,d,1,o,m,h,p,a)),o=m,l=f,h=p,r=u}}function Je(t,e,s,i,n,a,r,o,l,h){if("stepped"==t)return e.setStepped(i),s;let c=n<<2,d=t[c],u=t[c+1]*h,m=t[c+2],f=t[c+3]*h;return e.setBezier(s,i,n,a,o,d,u,m,f,r,l),s+1}function Ke(t,e,s){return void 0!==t[e]?t[e]:s}var Qe;function Ze(t,e,s){const i=new Dt(t);return"json"===s?new Ge(i).readSkeletonData(e):new ae(i).readSkeletonData(new Uint8Array(e))}async function ts(t,s,i){let n;const a=t.map(((t,n)=>{const a=s[n];let r=e.AssetType.Texture2D;return"ktx"===a?r=e.AssetType.KTX:"ktx2"===a&&(r=e.AssetType.KTX2),is(t,i,r)}));try{n=await Promise.all(a)}catch(t){throw t}return n}async function es(t,s){const i=function(t){const e=new URL(t),s=e.origin+e.pathname;return s.endsWith("/")?s:s.substring(0,s.lastIndexOf("/")+1)}(t);let n,a;try{n=await e.request(t,{type:"text"})}catch(e){throw new Error(`Spine Atlas: ${t} load error: ${e}`)}let r=new Ft(n);const o=[];for(let t of r.pages){const e=i+t.name;o.push(is(e,s))}try{a=await Promise.all(o)}catch(t){throw new Error(`Spine Texture: load error: ${t}`)}return r=ss(n,a),r}function ss(t,e){const s=new Ft(t);return s.pages.forEach(((t,s)=>{const i=function(t){return new ns(new Image,t)}(e.find((e=>e.name===t.name))||e[s]);t.setTexture(i)})),s}function is(t,s,i=e.AssetType.Texture2D){return s.resourceManager.load({url:t,type:i})}void 0===Math.fround&&(Math.fround=(Qe=new Float32Array(1),function(t){return Qe[0]=t,Qe[0]}));class ns extends bt{constructor(t,e){super(t),this.texture=e,this.texture.generateMipmaps()}getImage(){return this.texture}setFilters(s,i){s===t.TextureFilter.Nearest?this.texture.filterMode=e.TextureFilterMode.Point:i===t.TextureFilter.MipMapLinearLinear?this.texture.filterMode=e.TextureFilterMode.Trilinear:this.texture.filterMode=e.TextureFilterMode.Bilinear}setWraps(t,e){this.texture.wrapModeU=this._convertWrapMode(t),this.texture.wrapModeV=this._convertWrapMode(e)}dispose(){}_convertWrapMode(s){switch(s){case t.TextureWrap.ClampToEdge:return e.TextureWrapMode.Clamp;case t.TextureWrap.Repeat:return e.TextureWrapMode.Repeat;case t.TextureWrap.MirroredRepeat:return e.TextureWrapMode.Mirror;default:throw new Error("Unsupported texture wrap mode.")}}}class as{constructor(t,e=1){this._type=t,this._lastElementIndex=e-1;const s=this._elements=new Array(e);for(let i=0;i<e;++i)s[i]=new t}get(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]}return(t){this._elements[++this._lastElementIndex]=t}}class rs{constructor(t){this._usedElementCount=0,this._type=t,this._elements=[]}get(){const{_usedElementCount:t,_elements:e}=this;if(this._usedElementCount++,e.length===t){const t=new this._type;return e.push(t),t}return e[t]}clear(){this._usedElementCount=0}}const{SourceAlpha:os,One:ls,DestinationColor:hs,Zero:cs,OneMinusSourceColor:ds,OneMinusSourceAlpha:us}=e.BlendFactor,{Add:ms}=e.BlendOperation;function fs(e,s){const i=e.renderState.blendState.targetBlendState;switch(s){case t.BlendMode.Additive:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=ls,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ls,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Multiply:i.sourceColorBlendFactor=hs,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Screen:i.sourceColorBlendFactor=ls,i.destinationColorBlendFactor=ds,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ds,i.colorBlendOperation=i.alphaBlendOperation=ms;break;default:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms}}class ps{}const gs=1/0,xs=-1/0;class ws{static{this.QUAD_TRIANGLES=[0,1,2,2,3,0]}static{this.VERTEX_SIZE=8}static{this.VERTEX_STRIDE=9}static{this.tempDark=new n}static{this.tempColor=new n}static{this.tempVerts=new Array(8)}static{this.tempBlendMode=null}static{this.tempTexture=null}static{this.subPrimitivePool=new as(e.SubPrimitive)}static{this.subRenderItemPool=new rs(ps)}static{this.bounds=new e.BoundingBox(new e.Vector3(gs,gs,gs),new e.Vector3(xs,xs,xs))}getMaxVertexCount(t){const e=new Set,{skins:s}=t,i=s.length;for(let t=0;t<i;t++){const i=s[t];this._collectUniqueAttachments(i,e)}return this._calculateTotalVertexCount(e)}buildPrimitive(e,s){const{useClipping:i=!0,zSpacing:n=.01}=s.setting,{_clipper:a,_separateSlots:r,_subRenderItems:o,_separateSlotTextureMap:l}=this,{bounds:h}=ws;h.min.set(gs,gs,gs),h.max.set(xs,xs,xs);let c=0,d=0;const u=e.drawOrder,m=u.length,{engine:f,_indices:p,_vertices:g,_subPrimitives:x}=s;let{tempVerts:w,tempTexture:b,tempBlendMode:y,subRenderItemPool:M,subPrimitivePool:S}=ws;o.length=0,M.clear();let v,k,I=s._vertices,A=0,T=0,B=t.BlendMode.Normal,C=null,F=0;ws.tempBlendMode=null,ws.tempTexture=null;for(let t=0;t<m;++t){const e=u[t];if(!e.bone.active){a.clipEndWithSlot(e);continue}const s=e.getAttachment();let h=null;const m=n*t;let f=0;const E=a.isClipping();let R=E?2:ws.VERTEX_SIZE;if(s){switch(s.constructor){case Vt:const t=s;h=t.color,f=4*R,t.computeWorldVertices(e,w,0,R),v=ws.QUAD_TRIANGLES,k=t.uvs,C=t.region.texture;break;case Pt:const n=s;h=n.color,f=(n.worldVerticesLength>>1)*R,f>I.length&&(ws.tempVerts=new Array(f)),n.computeWorldVertices(e,0,n.worldVerticesLength,w,0,R),v=n.triangles,k=n.uvs,C=n.region.texture;break;case wt:if(i){let t=s;a.clipStart(e,t)}continue;default:i&&a.clipEndWithSlot(e);continue}if(null!=C){let t,s,i,n,u=e.bone.skeleton.color,I=e.color,Y=u.a*I.a*h.a,P=ws.tempColor,X=ws.tempDark;if(P.set(u.r*I.r*h.r,u.g*I.g*h.g,u.b*I.b*h.b,Y),E)a.clipTriangles(w,v,v.length,k,P,X,!1),t=a.clippedVertices,s=t.length,i=a.clippedTriangles,n=i.length;else{let e=w;const{r:a,g:r,b:o,a:l}=P;for(let t=2,s=0,i=f;t<i;t+=R,s+=2)e[t]=a,e[t+1]=r,e[t+2]=o,e[t+3]=l,e[t+4]=k[s],e[t+5]=k[s+1];t=w,s=f,i=v,n=v.length}if(0==s||0==n){a.clipEndWithSlot(e);continue}let _=c/ws.VERTEX_STRIDE,V=g,D=c,O=0;for(;O<s;){let e=t[O++],s=t[O++];V[D++]=e,V[D++]=s,V[D++]=m,V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],this._expandByPoint(e,s,m)}c=D;let N=p;for(D=d,O=0;O<n;D++,O++)N[D]=i[O]+_;d+=n;const L=e.data,q=L.name;B=L.blendMode;const U=null!==y&&y!==L.blendMode,W=null!==b&&b!==C,z=r.get(q);if(z||U||W){if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.subPrimitive=e,s.texture=b,s.blendMode=y,o.push(s),A+=T,T=0}if(z){const t=l.get(q);if(t){const e=C.texture;t.filterMode=e.filterMode,t.wrapModeU=e.wrapModeU,t.wrapModeV=e.wrapModeV}const e=x[F];e&&F++;const s=e||S.get();s.start=A,s.count=n;const i=M.get();i.blendMode=B,i.subPrimitive=s,i.texture=C,i.slotName=q,o.push(i),A+=n,T=0}else T+=n}else T+=n;b=C,y=B}a.clipEndWithSlot(e)}else i&&a.clipEndWithSlot(e)}if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.blendMode=B,s.subPrimitive=e,s.texture=C,o.push(s),T=0}a.clipEnd();const E=x.length,R=o.length;if(R<E)for(let t=R;t<E;t++){const e=x[t];S.return(e)}s._clearSubPrimitives();for(let t=0,e=R;t<e;++t){const e=o[t],{slotName:i,blendMode:n,texture:a}=e;s._addSubPrimitive(e.subPrimitive);let r=a.texture;l.has(i)&&(r=l.get(i));const h=`${r.instanceId}_${n}`;let c=ys._materialCache.get(h);c||(c=this._createMaterialForTexture(r,f,n),ys._materialCache.set(h,c)),s.setMaterial(t,c)}s._vertexBuffer.setData(g),s._indexBuffer.setData(p)}addSeparateSlot(t){this._separateSlots.set(t,t)}addSeparateSlotTexture(t,e){this._separateSlotTextureMap.set(t,e)}_createMaterialForTexture(t,e,s){const i=ys._getDefaultMaterial(e);return i.shaderData.setTexture("material_SpineTexture",t),fs(i,s),i}_expandByPoint(t,e,s){const{bounds:{min:i,max:n}}=ws,a=Math.min(i.x,t),r=Math.min(i.y,e),o=Math.min(i.z,s),l=Math.max(n.x,t),h=Math.max(n.y,e),c=Math.max(n.z,s);i.set(a,r,o),n.set(l,h,c)}_collectUniqueAttachments(t,e){const{attachments:s}=t;for(let t=0,i=s.length;t<i;t++){const i=s[t];for(let t in i){const s=i[t];s&&!e.has(s)&&e.add(s)}}}_calculateTotalVertexCount(t){let e=0;const s=ws.QUAD_TRIANGLES.length;return t.forEach((t=>{t instanceof Vt?e+=s:t instanceof Pt&&(e+=t.triangles.length)})),e}constructor(){this._clipper=new ze,this._subRenderItems=[],this._separateSlots=new Map,this._separateSlotTextureMap=new Map}}class bs extends e.Material{static{this._spineVS="\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 COLOR_0;\n \n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n }\n "}static{this._spineFS="\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n vec4 baseColor = texture2D(material_SpineTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n }\n "}constructor(s){super(s,e.Shader.find("galacean-spine-shader")||e.Shader.create("galacean-spine-shader",bs._spineVS,bs._spineFS));const i=this.renderState;i.blendState.targetBlendState.enabled=!0,fs(this,t.BlendMode.Normal),i.depthState.writeEnabled=!1,i.rasterState.cullMode=e.CullMode.Off,i.renderQueueType=e.RenderQueueType.Transparent}}class ys extends e.Renderer{static{this._spineGenerator=new ws}static{this._positionVertexElement=new e.VertexElement("POSITION",0,e.VertexElementFormat.Vector3,0)}static{this._colorVertexElement=new e.VertexElement("COLOR_0",12,e.VertexElementFormat.Vector4,0)}static{this._uvVertexElement=new e.VertexElement("TEXCOORD_0",28,e.VertexElementFormat.Vector2,0)}static{this._materialCache=new Map}static{this._animationDataCache=new Map}static _getDefaultMaterial(t){let e=this._defaultMaterial;if(e){if(e.engine===t)return e.clone();e.destroy(!0),e=null}return e=new bs(t),e.isGCIgnored=!0,this._defaultMaterial=e,e.clone()}get resource(){return this._resource}set resource(t){if(!t)return this._state=null,this._skeleton=null,void(this._resource=null);this._resource=t,this._addResourceReferCount(t,1);const{skeletonData:e}=t;this._skeleton=new Qt(e);let s=ys._animationDataCache.get(e);s||(s=new gt(e),ys._animationDataCache.set(e,s)),this._state=new at(s);const i=ys._spineGenerator.getMaxVertexCount(e);this._createBuffer(i),this._initializeDefaultState(),this._dirtyUpdateFlag|=4,this._state.addListener({start:()=>{this._onAnimationStart()},complete:t=>{this._onAnimationComplete(t)}})}get state(){return this._state}get skeleton(){return this._skeleton}constructor(t){super(t),this.setting=new vs,this.defaultState=new ks,this._subPrimitives=[],this._needResizeBuffer=!1,this._vertexCount=0;const s=new e.Primitive(this._engine);this._primitive=s,s.addVertexElement(ys._positionVertexElement),s.addVertexElement(ys._colorVertexElement),s.addVertexElement(ys._uvVertexElement)}addSeparateSlot(t){this._skeleton||console.error("Skeleton not found!");this._skeleton.findSlot(t)?ys._spineGenerator.addSeparateSlot(t):console.warn(`Slot: ${t} not find.`)}_onEnable(){this._initializeDefaultState()}update(e){const{_state:s,_skeleton:i}=this;s&&i&&(s.update(e),s.apply(i),i.update(e),i.updateWorldTransform(t.Physics.update),ys._spineGenerator.buildPrimitive(this._skeleton,this),this._isContainDirtyFlag(4)&&(this._onWorldVolumeChanged(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(2)&&this._calculateGeneratorBounds(this.bounds))}_render(t){const{_primitive:e,_subPrimitives:s}=this,{_materials:i,_engine:n}=this,a=n._renderElementPool.get();a.set(this.priority,this._distanceForSort);const r=n._subRenderElementPool;if(s){for(let t=0,n=s.length;t<n;t++){let n=i[t];if(!n)continue;(n.destroyed||n.shader.destroyed)&&(n=this.engine._meshMagentaMaterial);const o=r.get();o.set(this,n,e,s[t]),a.addSubRenderElement(o)}t.camera._renderPipeline.pushRenderElement(t,a)}}_updateBounds(t){this._calculateGeneratorBounds(t)}_calculateGeneratorBounds(t){const{bounds:s}=ws;e.BoundingBox.transform(s,this.entity.transform.worldMatrix,t)}_cloneTo(t){t.resource=this._resource}_onDestroy(){const{_primitive:t,_subPrimitives:e,_resource:s}=this;e.length=0,t&&t.destroy(),s&&this._addResourceReferCount(s,-1),this._clearMaterialCache(),this._primitive=null,this._resource=null,this._skeleton=null,this._state=null,this.setting=null,super._onDestroy()}_createBuffer(t){const{_engine:s,_primitive:i}=this;this._vertices=new Float32Array(t*ws.VERTEX_STRIDE),this._indices=new Uint16Array(t);const n=4*ws.VERTEX_STRIDE,a=new e.Buffer(s,e.BufferBindFlag.VertexBuffer,this._vertices,e.BufferUsage.Dynamic),r=new e.Buffer(s,e.BufferBindFlag.IndexBuffer,this._indices,e.BufferUsage.Dynamic);this._indexBuffer=r,this._vertexBuffer=a;const o=new e.VertexBufferBinding(a,n);this._primitive.setVertexBufferBinding(0,o);const l=new e.IndexBufferBinding(r,e.IndexFormat.UInt16);i.setIndexBufferBinding(l)}_addSubPrimitive(t){this._subPrimitives.push(t)}_clearSubPrimitives(){this._subPrimitives.length=0}_isContainDirtyFlag(t){return!!(this._dirtyUpdateFlag&t)}_setDirtyFlagFalse(t){this._dirtyUpdateFlag&=~t}_onWorldVolumeChanged(){this._dirtyUpdateFlag|=1}_onAnimationStart(){this._dirtyUpdateFlag|=2}_onAnimationComplete(t){t.loop||this._setDirtyFlagFalse(2)}_clearMaterialCache(){this._materials.forEach((e=>{const s=e.shaderData.getTexture("material_SpineTexture"),i=function(e){const s=e.renderState.blendState.targetBlendState;return s.sourceColorBlendFactor===os&&s.destinationColorBlendFactor===ls&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ls&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Additive:s.sourceColorBlendFactor===hs&&s.destinationColorBlendFactor===cs&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===cs&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Multiply:s.sourceColorBlendFactor===ls&&s.destinationColorBlendFactor===ds&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ds&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Screen:t.BlendMode.Normal}(e),n=`${s.instanceId}_${i}`;ys._materialCache.delete(n)}))}_initializeDefaultState(){const{skeleton:t,state:e}=this;if(t&&e){const{animationName:s,skinName:i,loop:n,scale:a}=this.defaultState;t.scaleX=a,t.scaleY=a,"default"!==i&&(t.setSkinByName(i),t.setToSetupPose()),s&&e.setAnimation(0,s,n)}}}var Ms,Ss;s([e.deepClone],ys.prototype,"setting",void 0),s([e.deepClone],ys.prototype,"defaultState",void 0),s([e.ignoreClone],ys.prototype,"_primitive",void 0),s([e.ignoreClone],ys.prototype,"_subPrimitives",void 0),s([e.ignoreClone],ys.prototype,"_indexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertices",void 0),s([e.ignoreClone],ys.prototype,"_indices",void 0),s([e.ignoreClone],ys.prototype,"_needResizeBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexCount",void 0),s([e.ignoreClone],ys.prototype,"_resource",void 0),s([e.ignoreClone],ys.prototype,"_skeleton",void 0),s([e.ignoreClone],ys.prototype,"_state",void 0),function(t){t[t.TransformVolume=1]="TransformVolume",t[t.AnimationVolume=2]="AnimationVolume",t[t.InitialVolume=4]="InitialVolume"}(Ms||(Ms={})),function(t){t[t.WorldVolume=1]="WorldVolume"}(Ss||(Ss={}));class vs{constructor(t=.01,e=!0){this.zSpacing=t,this.useClipping=e}}class ks{constructor(t=1,e=!0,s=null,i="default"){this.scale=t,this.loop=e,this.animationName=s,this.skinName=i}}class Is extends e.ReferResource{get skeletonData(){return this._skeletonData}constructor(t,e){super(t),this.textures=[],this._skeletonData=e,this._associationTextureInSkeletonData(e)}_onDestroy(){super._onDestroy();const{textures:t,_skeletonData:e}=this;t&&this._disassociationSuperResource(t),this._clearAttachmentTextures(e),ys._animationDataCache.delete(e),this._skeletonData=null}_disassociationSuperResource(t){for(let e=0,s=t.length;e<s;e++)t[e]._disassociationSuperResource(this)}_associationTextureInSkeletonData(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0],s=e?.region?.texture.texture;s&&!this.textures.find((t=>t.instanceId===s.instanceId))&&(this.textures.push(s),s._associationSuperResource(this))}))}))}_clearAttachmentTextures(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0];e?.region?.texture&&(e.region.texture.texture=null)}))}))}}class As{constructor(t,e=0,s){this.data=t,this._dataView=new DataView(t.buffer,t.byteOffset+e,s??t.byteLength-e),this._position=0}nextUint16(){const t=this._dataView.getUint16(this._position,!0);return this._position+=2,t}nextStr(){const t=this.nextUint16(),e=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,t);return this._position+=t,this.decodeText(e)}nextImageData(){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)}decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let s=0,i=t.length;s<i;s++)e+=String.fromCharCode(t[s]);return decodeURIComponent(encodeURIComponent(e))}}class Ts extends e.Loader{static{this.imageExtensions=["png","jpg","webp","jpeg","ktx","ktx2"]}static{this.skeletonExtensions=["skel","json","bin"]}static parseAndAssignSpineAsset(t,e,s){const{imageExtensions:i,skeletonExtensions:n}=Ts,a=Ts.getUrlExtension(t,e);a&&(n.includes(a)&&(s.skeletonPath=t,s.skeletonExtension=a),"atlas"===a&&(s.atlasPath=t),i.includes(a)&&(s.imagePaths.push(t),s.imageExtensions.push(a)))}static deriveAndAssignSpineAsset(t,e,s){const i=Ts.getUrlExtension(t,e);if(!i)return;s.skeletonPath=t,s.skeletonExtension=i;const n=/(\.(json|bin|skel))$/;let a;if(n.test(t)&&(a=t.replace(n,"")),a){const t=a+".atlas";s.atlasPath=t}}static verifyFileExtensions(t,e){return t?e&&!Array.isArray(t)?(console.error("Expect fileExtensions to be an array."),[]):e||"string"==typeof t?t:(console.error("Expect fileExtensions to be a string."),null):null}static getUrlExtension(t,e){if(e)return e;const s=t.match(/\/([^\/?#]+)\.([a-zA-Z0-9]+)(\?|#|$)|\?[^#]*\.([a-zA-Z0-9]+)(\?|#|$)/);return s?s[2]||s[4]:null}load(t,s){return new e.AssetPromise((async e=>{let i;if(t.urls)i=await this._handleOriginAsset(t,s);else{const e=await this.request(t.url,{type:"arraybuffer"}),n=new As(new Uint8Array(e)),a=n.nextStr();i=a.startsWith("spine")?await this._handleEditorAsset(e,n,a,s):await this._handleOriginAsset(t,s,e)}e(i)}))}async _handleEditorAsset(t,e,s,i){let n,a;const r=s.startsWith("spine:skel")?"skel":"json",{engine:o}=i;if("skel"===r)a=e.nextStr(),n=e.nextImageData();else{const e=new TextDecoder("utf-8").decode(new Uint8Array(t)),{data:s,atlas:i}=JSON.parse(e);a=i.refId,n=s}const l=Ze(await i.getResourceByRef({refId:a}),n,r);return new Is(o,l)}async _handleOriginAsset(t,e,s){let{fileExtensions:i}=t.params||{},n={skeletonPath:"",skeletonExtension:"",atlasPath:"",imagePaths:[],imageExtensions:[]};const{engine:a}=e;if(s){const e=Ts.verifyFileExtensions(i,!1);Ts.deriveAndAssignSpineAsset(t.url,e,n);const{skeletonPath:r,atlasPath:o}=n;if(!r||!o)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");const l=await es(o,a),{data:h,type:c}=this._determineSkeletonDataType(s),d=Ze(l,h,c);return new Is(a,d)}{i=Ts.verifyFileExtensions(i,!0);for(let e=0;e<t.urls.length;e+=1){const s=t.urls[e],a=i&&i[e]||null;Ts.parseAndAssignSpineAsset(s,a,n)}const{skeletonPath:e,atlasPath:s,imagePaths:r,skeletonExtension:o,imageExtensions:l}=n;if(!e||!s)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");const h="json"===o?"json":"skel";let c,d,u=["json"===o?this.request(e,{type:"text"}):this.request(e,{type:"arraybuffer"})];if(r.length>0){let t,e;u=u.concat([this.request(s,{type:"text"}),ts(r,l,a)]),[d,t,e]=await Promise.all(u),c=ss(t,e)}else u.push(es(s,a)),[d,c]=await Promise.all(u);const m=Ze(c,d,h);return new Is(a,m)}}_determineSkeletonDataType(t){let e,s;try{const i=new TextDecoder("utf-8").decode(t);JSON.parse(i),e=i,s="json"}catch(i){e=t,s="skel"}return{data:e,type:s}}}Ts=s([e.resourceLoader("spine",["json","bin","skel"])],Ts);class Bs extends e.Loader{load(t,s){return new e.AssetPromise((async e=>{const i=await this.request(t.url,{type:"text"}),{data:n,textures:a}=JSON.parse(i),r=a.map((t=>s.getResourceByRef({refId:t.refId})));e(ss(n,await Promise.all(r)))}))}}Bs=s([e.resourceLoader("EditorSpineAtlas",["atlas"])],Bs);const Cs="4.2.0-beta.1";e.Loader.registerClass("SpineAnimationRenderer",ys),console.log(`Galacean spine version: ${Cs}`),t.AlphaTimeline=V,t.Animation=g,t.AnimationState=at,t.AnimationStateAdapter=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},t.AnimationStateData=gt,t.AssetManagerBase=class{pathPrefix="";textureLoader;downloader;assets={};errors={};toLoad=0;loaded=0;constructor(t,e="",s=new qt){this.textureLoader=t,this.pathPrefix=e,this.downloader=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.assets[e]=s,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise(((t,e)=>{let s=()=>{this.isLoadingComplete()?this.hasErrors()?e(this.errors):t(this):requestAnimationFrame(s)};requestAnimationFrame(s)}))}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadBinary(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load binary ${t}: status ${e}, ${i}`)}))}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${e}, ${i}`)}))}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadJson(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load JSON ${t}: status ${e}, ${i}`)}))}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),!!("undefined"==typeof window||"undefined"==typeof navigator||!window.document))fetch(t,{mode:"cors"}).then((e=>e.ok?e.blob():(this.error(s,t,`Couldn't load image: ${t}`),null))).then((t=>t?createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null)).then((s=>{s&&this.success(e,t,this.textureLoader(s))}));else{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this.success(e,t,this.textureLoader(i))},i.onerror=()=>{this.error(s,t,`Couldn't load image: ${t}`)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),i.src=t}}loadTextureAtlas(t,e=()=>{},s=()=>{},i){let n=t.lastIndexOf("/"),a=n>=0?t.substring(0,n+1):"";t=this.start(t),this.downloader.downloadText(t,(n=>{try{let r=new Ft(n),o=r.pages.length,l=!1;for(let n of r.pages)this.loadTexture(i?i[n.name]:a+n.name,((s,i)=>{l||(n.setTexture(i),0==--o&&this.success(e,t,r))}),((e,i)=>{l||this.error(s,t,`Couldn't load texture atlas ${t} page image: ${e}`),l=!0}))}catch(e){this.error(s,t,`Couldn't parse texture atlas ${t}: ${e.message}`)}}),((e,i)=>{this.error(s,t,`Couldn't load texture atlas ${t}: status ${e}, ${i}`)}))}get(t){return this.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;let e=this.assets[t];if(e)return e;let s=this.errors[t];throw Error("Asset not found: "+t+(s?"\n"+s:""))}remove(t){t=this.pathPrefix+t;let e=this.assets[t];return e.dispose&&e.dispose(),delete this.assets[t],e}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},t.AtlasAttachmentLoader=Dt,t.Attachment=d,t.AttachmentTimeline=N,t.BinaryInput=re,t.Bone=Nt,t.BoneData=Ot,t.BoundingBoxAttachment=xt,t.CURRENT=pt,t.ClippingAttachment=wt,t.Color=n,t.ConstraintData=Lt,t.CurveTimeline=M,t.CurveTimeline1=S,t.CurveTimeline2=v,t.DebugUtils=class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},t.DeformTimeline=L,t.Downloader=qt,t.DrawOrderTimeline=U,t.Event=Ut,t.EventData=Wt,t.EventQueue=ot,t.EventTimeline=q,t.FIRST=ct,t.FakeTexture=class extends bt{setFilters(t,e){}setWraps(t,e){}dispose(){}},t.HOLD_FIRST=ut,t.HOLD_MIX=mt,t.HOLD_SUBSEQUENT=dt,t.IkConstraint=zt,t.IkConstraintData=Gt,t.IkConstraintTimeline=W,t.InheritTimeline=P,t.IntSet=class{array=new Array;add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return null!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}},t.Interpolation=r,t.MathUtils=a,t.MeshAttachment=Pt,t.PathAttachment=Xt,t.PathConstraint=jt,t.PathConstraintData=$t,t.PathConstraintMixTimeline=j,t.PathConstraintPositionTimeline=G,t.PathConstraintSpacingTimeline=$,t.PhysicsConstraintDampingTimeline=Q,t.PhysicsConstraintGravityTimeline=et,t.PhysicsConstraintInertiaTimeline=J,t.PhysicsConstraintMassTimeline=Z,t.PhysicsConstraintMixTimeline=st,t.PhysicsConstraintResetTimeline=it,t.PhysicsConstraintStrengthTimeline=K,t.PhysicsConstraintTimeline=H,t.PhysicsConstraintWindTimeline=tt,t.PointAttachment=_t,t.Pool=h,t.Pow=o,t.PowOut=class extends o{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}},t.RGB2Timeline=O,t.RGBA2Timeline=D,t.RGBATimeline=X,t.RGBTimeline=_,t.RegionAttachment=Vt,t.RotateTimeline=k,t.SETUP=ft,t.SUBSEQUENT=ht,t.ScaleTimeline=B,t.ScaleXTimeline=C,t.ScaleYTimeline=F,t.SequenceTimeline=nt,t.ShearTimeline=E,t.ShearXTimeline=R,t.ShearYTimeline=Y,t.Skeleton=Qt,t.SkeletonBinary=ae,t.SkeletonBounds=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=new Array;polygons=new Array;polygonPool=new h((()=>l.newFloatArray(16)));update(t,e){if(!t)throw new Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,n=this.polygonPool,a=t.slots,r=a.length;s.length=0,n.freeAll(i),i.length=0;for(let t=0;t<r;t++){let e=a[t];if(!e.bone.active)continue;let r=e.getAttachment();if(r instanceof xt){let t=r;s.push(t);let a=n.obtain();a.length!=t.worldVerticesLength&&(a=l.newFloatArray(t.worldVerticesLength)),i.push(a),t.computeWorldVertices(e,0,t.worldVerticesLength,a,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,i=Number.NEGATIVE_INFINITY,n=this.polygons;for(let a=0,r=n.length;a<r;a++){let r=n[a],o=r;for(let n=0,a=r.length;n<a;n+=2){let a=o[n],r=o[n+1];t=Math.min(t,a),e=Math.min(e,r),s=Math.max(s,a),i=Math.max(i,r)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let n=this.minX,a=this.minY,r=this.maxX,o=this.maxY;if(t<=n&&s<=n||e<=a&&i<=a||t>=r&&s>=r||e>=o&&i>=o)return!1;let l=(i-e)/(s-t),h=l*(n-t)+e;if(h>a&&h<o)return!0;if(h=l*(r-t)+e,h>a&&h<o)return!0;let c=(a-e)/l+t;return c>n&&c<r||(c=(o-e)/l+t,c>n&&c<r)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,n=s.length;i<n;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t,n=t.length,a=n-2,r=!1;for(let t=0;t<n;t+=2){let n=i[t+1],o=i[a+1];if(n<s&&o>=s||o<s&&n>=s){let l=i[t];l+(s-n)/(o-n)*(i[a]-l)<e&&(r=!r)}a=t}return r}intersectsSegment(t,e,s,i){let n=this.polygons;for(let a=0,r=n.length;a<r;a++)if(this.intersectsSegmentPolygon(n[a],t,e,s,i))return this.boundingBoxes[a];return null}intersectsSegmentPolygon(t,e,s,i,n){let a=t,r=t.length,o=e-i,l=s-n,h=e*n-s*i,c=a[r-2],d=a[r-1];for(let t=0;t<r;t+=2){let r=a[t],u=a[t+1],m=c*u-d*r,f=c-r,p=d-u,g=o*p-l*f,x=(h*f-o*m)/g;if((x>=c&&x<=r||x>=r&&x<=c)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*p-l*m)/g;if((t>=d&&t<=u||t>=u&&t<=d)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}c=r,d=u}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},t.SkeletonClipping=ze,t.SkeletonData=te,t.SkeletonDataResource=Is,t.SkeletonJson=Ge,t.Skin=se,t.SkinEntry=ee,t.Slot=Jt,t.SlotData=ie,t.SpineAnimationRenderer=ys,t.StringSet=i,t.Texture=bt,t.TextureAtlas=Ft,t.TextureAtlasPage=Rt,t.TextureAtlasRegion=Yt,t.TextureRegion=Ct,t.TimeKeeper=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){let 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)}},t.Timeline=y,t.TrackEntry=rt,t.TransformConstraint=Kt,t.TransformConstraintData=ne,t.TransformConstraintTimeline=z,t.TranslateTimeline=I,t.TranslateXTimeline=A,t.TranslateYTimeline=T,t.Triangulator=We,t.Utils=l,t.Vector2=c,t.VertexAttachment=u,t.WindowedMean=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}},t.createTextureAtlas=ss,t.version=Cs,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.Spine={}),t.Galacean)}(this,(function(t,e){"use strict";function s(t,e,s,i){var n,a=arguments.length,r=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(r=(a<3?n(r):a>3?n(e,s,r):n(e,s))||r);return a>3&&r&&Object.defineProperty(e,s,r),r}"function"==typeof SuppressedError&&SuppressedError;class i{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,!e&&(this.size++,!0)}addAll(t){let e=this.size;for(var s=0,i=t.length;s<i;s++)this.add(t[s]);return e!=this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}}class n{r;g;b;a;static WHITE=new n(1,1,1,1);static RED=new n(1,0,0,1);static GREEN=new n(0,1,0,1);static BLUE=new n(0,0,1,1);static MAGENTA=new n(1,0,1,1);constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=8!=t.length?1:parseInt(t.substr(6,2),16)/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,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(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255}static rgb888ToColor(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255}toRgb888(){const t=t=>("0"+(255*t).toString(16)).slice(-2);return Number("0x"+t(this.r)+t(this.g)+t(this.b))}static fromString(t){return(new n).setFromString(t)}}class a{static PI=3.1415927;static PI2=2*a.PI;static invPI2=1/a.PI2;static radiansToDegrees=180/a.PI;static radDeg=a.radiansToDegrees;static degreesToRadians=a.PI/180;static degRad=a.degreesToRadians;static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(t){return Math.cos(t*a.degRad)}static sinDeg(t){return Math.sin(t*a.degRad)}static atan2Deg(t,e){return Math.atan2(t,e)*a.degRad}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){let e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(t,e){return a.randomTriangularWith(t,e,.5*(t+e))}static randomTriangularWith(t,e,s){let i=Math.random(),n=e-t;return i<=(s-t)/n?t+Math.sqrt(i*n*(s-t)):e-Math.sqrt((1-i)*n*(e-s))}static isPowerOfTwo(t){return t&&!(t&t-1)}}class r{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class o extends r{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1}}class l{static SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array;static arrayCopy(t,e,s,i,n){for(let a=e,r=i;a<e+n;a++,r++)s[r]=t[a]}static arrayFill(t,e,s,i){for(let n=e;n<s;n++)t[n]=i}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let n=i;n<e;n++)t[n]=s;return t}static ensureArrayCapacity(t,e,s=0){return t.length>=e?t:l.setArraySize(t,e,s)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static newShortArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static toFloatArray(t){return l.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return l.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t,e){}static contains(t,e,s=!0){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1}static enumValue(t,e){return t[e[0].toUpperCase()+e.slice(1)]}}class h{items=new Array;instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&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}}class c{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class d{name;constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}}class u extends d{static nextID=0;id=u.nextID++;bones=null;vertices=[];worldVerticesLength=0;timelineAttachment=this;constructor(t){super(t)}computeWorldVertices(t,e,s,i,n,a){s=n+(s>>1)*a;let r=t.bone.skeleton,o=t.deform,l=this.vertices,h=this.bones;if(!h){o.length>0&&(l=o);let r=t.bone,h=r.worldX,c=r.worldY,d=r.a,u=r.b,m=r.c,f=r.d;for(let t=e,r=n;r<s;t+=2,r+=a){let e=l[t],s=l[t+1];i[r]=e*d+s*u+h,i[r+1]=e*m+s*f+c}return}let c=0,d=0;for(let t=0;t<e;t+=2){let t=h[c];c+=t+1,d+=t}let u=r.bones;if(0==o.length)for(let t=n,e=3*d;t<s;t+=a){let s=0,n=0,a=h[c++];for(a+=c;c<a;c++,e+=3){let t=u[h[c]],i=l[e],a=l[e+1],r=l[e+2];s+=(i*t.a+a*t.b+t.worldX)*r,n+=(i*t.c+a*t.d+t.worldY)*r}i[t]=s,i[t+1]=n}else{let t=o;for(let e=n,r=3*d,o=d<<1;e<s;e+=a){let s=0,n=0,a=h[c++];for(a+=c;c<a;c++,r+=3,o+=2){let e=u[h[c]],i=l[r]+t[o],a=l[r+1]+t[o+1],d=l[r+2];s+=(i*e.a+a*e.b+e.worldX)*d,n+=(i*e.c+a*e.d+e.worldY)*d}i[e]=s,i[e+1]=n}}}copyTo(t){this.bones?(t.bones=new Array(this.bones.length),l.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=l.newFloatArray(this.vertices.length),l.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment}}class m{static _nextID=0;id=m.nextID();regions;start=0;digits=0;setupIndex=0;constructor(t){this.regions=new Array(t)}copy(){let t=new m(this.regions.length);return l.arrayCopy(this.regions,0,t.regions,0,this.regions.length),t.start=this.start,t.digits=this.digits,t.setupIndex=this.setupIndex,t}apply(t,e){let s=t.sequenceIndex;-1==s&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1);let i=this.regions[s];e.region!=i&&(e.region=i,e.updateRegion())}getPath(t,e){let s=t,i=(this.start+e).toString();for(let t=this.digits-i.length;t>0;t--)s+="0";return s+=i,s}static nextID(){return m._nextID++}}var f;!function(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"}(f||(f={}));const p=[f.hold,f.once,f.loop,f.pingpong,f.onceReverse,f.loopReverse,f.pingpongReverse];class g{name;timelines=[];timelineIds=new i;duration;constructor(t,e,s){if(!t)throw new Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=s}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e<t.length;e++)this.timelineIds.addAll(t[e].getPropertyIds())}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,i,n,a,r,o){if(!t)throw new Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let i=0,h=l.length;i<h;i++)l[i].apply(t,e,s,n,a,r,o)}}var x,w;t.MixBlend=void 0,(x=t.MixBlend||(t.MixBlend={}))[x.setup=0]="setup",x[x.first=1]="first",x[x.replace=2]="replace",x[x.add=3]="add",t.MixDirection=void 0,(w=t.MixDirection||(t.MixDirection={}))[w.mixIn=0]="mixIn",w[w.mixOut=1]="mixOut";const b={rotate:0,x:1,y:2,scaleX:3,scaleY:4,shearX:5,shearY:6,inherit:7,rgb:8,alpha:9,rgb2:10,attachment:11,deform:12,event:13,drawOrder:14,ikConstraint:15,transformConstraint:16,pathConstraintPosition:17,pathConstraintSpacing:18,pathConstraintMix:19,physicsConstraintInertia:20,physicsConstraintStrength:21,physicsConstraintDamping:22,physicsConstraintMass:23,physicsConstraintWind:24,physicsConstraintGravity:25,physicsConstraintMix:26,physicsConstraintReset:27,sequence:28};class y{propertyIds;frames;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 search1(t,e){let s=t.length;for(let i=1;i<s;i++)if(t[i]>e)return i-1;return s-1}static search(t,e,s){let i=t.length;for(let n=s;n<i;n+=s)if(t[n]>e)return n-s;return i-s}}class M extends y{curves;constructor(t,e,s){super(t,s),this.curves=l.newFloatArray(t+18*e),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){let e=this.getFrameCount()+18*t;if(this.curves.length>e){let t=l.newFloatArray(e);l.arrayCopy(this.curves,0,t,0,e),this.curves=t}}setBezier(t,e,s,i,n,a,r,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*a+o),f=.03*(n-2*r+l),p=.006*(3*(a-o)-i+h),g=.006*(3*(r-l)-n+c),x=2*m+p,w=2*f+g,b=.3*(a-i)+m+.16666667*p,y=.3*(r-n)+f+.16666667*g,M=i+b,S=n+y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getBezierValue(t,e,s,i){let n=this.curves;if(n[i]>t){let a=this.frames[e],r=this.frames[e+s];return r+(t-a)/(n[i]-a)*(n[i+1]-r)}let a=i+18;for(i+=2;i<a;i+=2)if(n[i]>=t){let e=n[i-2],s=n[i-1];return s+(t-e)/(n[i]-e)*(n[i+1]-s)}e+=this.getFrameEntries();let r=n[a-2],o=n[a-1];return o+(t-r)/(this.frames[e]-r)*(this.frames[e+s]-o)}}class S extends M{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){let e=this.frames,s=e.length-2;for(let i=2;i<=s;i+=2)if(e[i]>t){s=i-2;break}let i=this.curves[s>>1];switch(i){case 0:let i=e[s],n=e[s+1];return n+(t-i)/(e[s+2]-i)*(e[s+2+1]-n);case 1:return e[s+1]}return this.getBezierValue(t,s,1,i-2)}getRelativeValue(e,s,i,n,a){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}let r=this.getCurveValue(e);switch(i){case t.MixBlend.setup:return a+r*s;case t.MixBlend.first:case t.MixBlend.replace:r+=a-n}return n+r*s}getAbsoluteValue(e,s,i,n,a){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}let r=this.getCurveValue(e);return i==t.MixBlend.setup?a+(r-a)*s:n+(r-n)*s}getAbsoluteValue2(e,s,i,n,a,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return a;case t.MixBlend.first:return n+(a-n)*s}return n}return i==t.MixBlend.setup?a+(r-a)*s:n+(r-n)*s}getScaleValue(e,s,i,n,r,o){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return o;case t.MixBlend.first:return r+(o-r)*s}return r}let l=this.getCurveValue(e)*o;if(1==s)return i==t.MixBlend.add?r+l-o:l;if(n==t.MixDirection.mixOut)switch(i){case t.MixBlend.setup:return o+(Math.abs(l)*a.signum(o)-o)*s;case t.MixBlend.first:case t.MixBlend.replace:return r+(Math.abs(l)*a.signum(r)-r)*s}else{let e=0;switch(i){case t.MixBlend.setup:return e=Math.abs(o)*a.signum(l),e+(l-e)*s;case t.MixBlend.first:case t.MixBlend.replace:return e=Math.abs(r)*a.signum(l),e+(l-e)*s}}return r+(l-o)*s}}class v extends M{constructor(t,e,s,i){super(t,e,[s,i])}getFrameEntries(){return 3}setFrame(t,e,s,i){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i}}class k extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.rotate+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.rotation=this.getRelativeValue(s,n,a,o.rotation,o.data.rotation))}}class I extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s,b.y+"|"+s),this.boneIndex=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.x=l.data.x,void(l.y=l.data.y);case t.MixBlend.first:l.x+=(l.data.x-l.x)*a,l.y+=(l.data.y-l.y)*a}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(r){case t.MixBlend.setup:l.x=l.data.x+c*a,l.y=l.data.y+d*a;break;case t.MixBlend.first:case t.MixBlend.replace:l.x+=(l.data.x+c-l.x)*a,l.y+=(l.data.y+d-l.y)*a;break;case t.MixBlend.add:l.x+=c*a,l.y+=d*a}}}class A extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.x=this.getRelativeValue(s,n,a,o.x,o.data.x))}}class T extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.y+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.y=this.getRelativeValue(s,n,a,o.y,o.data.y))}}class B extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s,b.scaleY+"|"+s),this.boneIndex=s}apply(e,s,i,n,r,o,l){let h=e.bones[this.boneIndex];if(!h.active)return;let c,d,u=this.frames;if(i<u[0]){switch(o){case t.MixBlend.setup:return h.scaleX=h.data.scaleX,void(h.scaleY=h.data.scaleY);case t.MixBlend.first:h.scaleX+=(h.data.scaleX-h.scaleX)*r,h.scaleY+=(h.data.scaleY-h.scaleY)*r}return}let m=y.search(u,i,3),f=this.curves[m/3];switch(f){case 0:let t=u[m];c=u[m+1],d=u[m+2];let e=(i-t)/(u[m+3]-t);c+=(u[m+3+1]-c)*e,d+=(u[m+3+2]-d)*e;break;case 1:c=u[m+1],d=u[m+2];break;default:c=this.getBezierValue(i,m,1,f-2),d=this.getBezierValue(i,m,2,f+18-2)}if(c*=h.data.scaleX,d*=h.data.scaleY,1==r)o==t.MixBlend.add?(h.scaleX+=c-h.data.scaleX,h.scaleY+=d-h.data.scaleY):(h.scaleX=c,h.scaleY=d);else{let e=0,s=0;if(l==t.MixDirection.mixOut)switch(o){case t.MixBlend.setup:e=h.data.scaleX,s=h.data.scaleY,h.scaleX=e+(Math.abs(c)*a.signum(e)-e)*r,h.scaleY=s+(Math.abs(d)*a.signum(s)-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=h.scaleX,s=h.scaleY,h.scaleX=e+(Math.abs(c)*a.signum(e)-e)*r,h.scaleY=s+(Math.abs(d)*a.signum(s)-s)*r;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*r,h.scaleY+=(d-h.data.scaleY)*r}else switch(o){case t.MixBlend.setup:e=Math.abs(h.data.scaleX)*a.signum(c),s=Math.abs(h.data.scaleY)*a.signum(d),h.scaleX=e+(c-e)*r,h.scaleY=s+(d-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=Math.abs(h.scaleX)*a.signum(c),s=Math.abs(h.scaleY)*a.signum(d),h.scaleX=e+(c-e)*r,h.scaleY=s+(d-s)*r;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*r,h.scaleY+=(d-h.data.scaleY)*r}}}}class C extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.scaleX=this.getScaleValue(s,n,a,r,o.scaleX,o.data.scaleX))}}class F extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.scaleY=this.getScaleValue(s,n,a,r,o.scaleY,o.data.scaleY))}}class E extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s,b.shearY+"|"+s),this.boneIndex=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case t.MixBlend.first:l.shearX+=(l.data.shearX-l.shearX)*a,l.shearY+=(l.data.shearY-l.shearY)*a}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(r){case t.MixBlend.setup:l.shearX=l.data.shearX+c*a,l.shearY=l.data.shearY+d*a;break;case t.MixBlend.first:case t.MixBlend.replace:l.shearX+=(l.data.shearX+c-l.shearX)*a,l.shearY+=(l.data.shearY+d-l.shearY)*a;break;case t.MixBlend.add:l.shearX+=c*a,l.shearY+=d*a}}}class Y extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.shearX=this.getRelativeValue(s,n,a,o.shearX,o.data.shearX))}}class R extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,a,r){let o=t.bones[this.boneIndex];o.active&&(o.shearY=this.getRelativeValue(s,n,a,o.shearY,o.data.shearY))}}class P extends y{boneIndex=0;constructor(t,e){super(t,[b.inherit+"|"+e]),this.boneIndex=e}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(e,s,i,n,a,r,o){let l=e.bones[this.boneIndex];if(!l.active)return;if(o==t.MixDirection.mixOut)return void(r==t.MixBlend.setup&&(l.inherit=l.data.inherit));let h=this.frames;i<h[0]?r!=t.MixBlend.setup&&r!=t.MixBlend.first||(l.inherit=l.data.inherit):l.inherit=this.frames[y.search(h,i,2)+1]}}class X extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s]),this.slotIndex=s}getFrameEntries(){return 5}setFrame(t,e,s,i,n,a){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return void c.setFromColor(e);case t.MixBlend.first:c.add((e.r-c.r)*a,(e.g-c.g)*a,(e.b-c.b)*a,(e.a-c.a)*a)}return}let d=0,u=0,m=0,f=0,p=y.search(h,i,5),g=this.curves[p/5];switch(g){case 0:let t=h[p];d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];let e=(i-t)/(h[p+5]-t);d+=(h[p+5+1]-d)*e,u+=(h[p+5+2]-u)*e,m+=(h[p+5+3]-m)*e,f+=(h[p+5+4]-f)*e;break;case 1:d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];break;default:d=this.getBezierValue(i,p,1,g-2),u=this.getBezierValue(i,p,2,g+18-2),m=this.getBezierValue(i,p,3,g+36-2),f=this.getBezierValue(i,p,4,g+54-2)}1==a?c.set(d,u,m,f):(r==t.MixBlend.setup&&c.setFromColor(l.data.color),c.add((d-c.r)*a,(u-c.g)*a,(m-c.b)*a,(f-c.a)*a))}}class _ extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s]),this.slotIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,void(c.b=e.b);case t.MixBlend.first:c.r+=(e.r-c.r)*a,c.g+=(e.g-c.g)*a,c.b+=(e.b-c.b)*a}return}let d=0,u=0,m=0,f=y.search(h,i,4),p=this.curves[f>>2];switch(p){case 0:let t=h[f];d=h[f+1],u=h[f+2],m=h[f+3];let e=(i-t)/(h[f+4]-t);d+=(h[f+4+1]-d)*e,u+=(h[f+4+2]-u)*e,m+=(h[f+4+3]-m)*e;break;case 1:d=h[f+1],u=h[f+2],m=h[f+3];break;default:d=this.getBezierValue(i,f,1,p-2),u=this.getBezierValue(i,f,2,p+18-2),m=this.getBezierValue(i,f,3,p+36-2)}if(1==a)c.r=d,c.g=u,c.b=m;else{if(r==t.MixBlend.setup){let t=l.data.color;c.r=t.r,c.g=t.g,c.b=t.b}c.r+=(d-c.r)*a,c.g+=(u-c.g)*a,c.b+=(m-c.b)*a}}}class V extends S{slotIndex=0;constructor(t,e,s){super(t,e,b.alpha+"|"+s),this.slotIndex=s}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.color;if(i<this.frames[0]){let e=l.data.color;switch(r){case t.MixBlend.setup:return void(h.a=e.a);case t.MixBlend.first:h.a+=(e.a-h.a)*a}return}let c=this.getCurveValue(i);1==a?h.a=c:(r==t.MixBlend.setup&&(h.a=l.data.color.a),h.a+=(c-h.a)*a)}}class D extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 8}setFrame(t,e,s,i,n,a,r,o,l){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a,this.frames[t+5]=r,this.frames[t+6]=o,this.frames[t+7]=l}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(r){case t.MixBlend.setup:return c.setFromColor(e),d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.add((e.r-c.r)*a,(e.g-c.g)*a,(e.b-c.b)*a,(e.a-c.a)*a),d.r+=(s.r-d.r)*a,d.g+=(s.g-d.g)*a,d.b+=(s.b-d.b)*a}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=0,b=y.search(h,i,8),M=this.curves[b>>3];switch(M){case 0:let t=h[b];u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];let e=(i-t)/(h[b+8]-t);u+=(h[b+8+1]-u)*e,m+=(h[b+8+2]-m)*e,f+=(h[b+8+3]-f)*e,p+=(h[b+8+4]-p)*e,g+=(h[b+8+5]-g)*e,x+=(h[b+8+6]-x)*e,w+=(h[b+8+7]-w)*e;break;case 1:u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];break;default:u=this.getBezierValue(i,b,1,M-2),m=this.getBezierValue(i,b,2,M+18-2),f=this.getBezierValue(i,b,3,M+36-2),p=this.getBezierValue(i,b,4,M+54-2),g=this.getBezierValue(i,b,5,M+72-2),x=this.getBezierValue(i,b,6,M+90-2),w=this.getBezierValue(i,b,7,M+108-2)}if(1==a)c.set(u,m,f,p),d.r=g,d.g=x,d.b=w;else{if(r==t.MixBlend.setup){c.setFromColor(l.data.color);let t=l.data.darkColor;d.r=t.r,d.g=t.g,d.b=t.b}c.add((u-c.r)*a,(m-c.g)*a,(f-c.b)*a,(p-c.a)*a),d.r+=(g-d.r)*a,d.g+=(x-d.g)*a,d.b+=(w-d.b)*a}}}class O extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,a,r,o){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a,this.frames[t+5]=r,this.frames[t+6]=o}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(r){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,c.b=e.b,d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.r+=(e.r-c.r)*a,c.g+=(e.g-c.g)*a,c.b+=(e.b-c.b)*a,d.r+=(s.r-d.r)*a,d.g+=(s.g-d.g)*a,d.b+=(s.b-d.b)*a}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=y.search(h,i,7),b=this.curves[w/7];switch(b){case 0:let t=h[w];u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];let e=(i-t)/(h[w+7]-t);u+=(h[w+7+1]-u)*e,m+=(h[w+7+2]-m)*e,f+=(h[w+7+3]-f)*e,p+=(h[w+7+4]-p)*e,g+=(h[w+7+5]-g)*e,x+=(h[w+7+6]-x)*e;break;case 1:u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];break;default:u=this.getBezierValue(i,w,1,b-2),m=this.getBezierValue(i,w,2,b+18-2),f=this.getBezierValue(i,w,3,b+36-2),p=this.getBezierValue(i,w,4,b+54-2),g=this.getBezierValue(i,w,5,b+72-2),x=this.getBezierValue(i,w,6,b+90-2)}if(1==a)c.r=u,c.g=m,c.b=f,d.r=p,d.g=g,d.b=x;else{if(r==t.MixBlend.setup){let t=l.data.color,e=l.data.darkColor;c.r=t.r,c.g=t.g,c.b=t.b,d.r=e.r,d.g=e.g,d.b=e.b}c.r+=(u-c.r)*a,c.g+=(m-c.g)*a,c.b+=(f-c.b)*a,d.r+=(p-d.r)*a,d.g+=(g-d.g)*a,d.b+=(x-d.b)*a}}}class N extends y{slotIndex=0;attachmentNames;constructor(t,e){super(t,[b.attachment+"|"+e]),this.slotIndex=e,this.attachmentNames=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];l.bone.active&&(o!=t.MixDirection.mixOut?i<this.frames[0]?r!=t.MixBlend.setup&&r!=t.MixBlend.first||this.setAttachment(e,l,l.data.attachmentName):this.setAttachment(e,l,this.attachmentNames[y.search1(this.frames,i)]):r==t.MixBlend.setup&&this.setAttachment(e,l,l.data.attachmentName))}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}}class L extends M{slotIndex=0;attachment;vertices;constructor(t,e,s,i){super(t,e,[b.deform+"|"+s+"|"+i.id]),this.slotIndex=s,this.attachment=i,this.vertices=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,i,n,a,r,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*a+o),f=.03*l-.06*r,p=.006*(3*(a-o)-i+h),g=.018*(r-l+.33333333),x=2*m+p,w=2*f+g,b=.3*(a-i)+m+.16666667*p,y=.3*r+f+.16666667*g,M=i+b,S=y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getCurvePercent(t,e){let s=this.curves,i=s[e];switch(i){case 0:let s=this.frames[e];return(t-s)/(this.frames[e+this.getFrameEntries()]-s);case 1:return 0}if(i-=2,s[i]>t){let n=this.frames[e];return s[i+1]*(t-n)/(s[i]-n)}let n=i+18;for(i+=2;i<n;i+=2)if(s[i]>=t){let e=s[i-2],n=s[i-1];return n+(t-e)/(s[i]-e)*(s[i+1]-n)}let a=s[n-2],r=s[n-1];return r+(1-r)*(t-a)/(this.frames[e+this.getFrameEntries()]-a)}apply(e,s,i,n,a,r,o){let h=e.slots[this.slotIndex];if(!h.bone.active)return;let c=h.getAttachment();if(!c)return;if(!(c instanceof u)||c.timelineAttachment!=this.attachment)return;let d=h.deform;0==d.length&&(r=t.MixBlend.setup);let m=this.vertices,f=m[0].length,p=this.frames;if(i<p[0]){switch(r){case t.MixBlend.setup:return void(d.length=0);case t.MixBlend.first:if(1==a)return void(d.length=0);d.length=f;let e=c;if(e.bones){a=1-a;for(g=0;g<f;g++)d[g]*=a}else{let t=e.vertices;for(var g=0;g<f;g++)d[g]+=(t[g]-d[g])*a}}return}if(d.length=f,i>=p[p.length-1]){let e=m[p.length-1];if(1==a)if(r==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]+=e[t];else{let s=t.vertices;for(let t=0;t<f;t++)d[t]+=e[t]-s[t]}}else l.arrayCopy(e,0,d,0,f);else switch(r){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]=e[t]*a;else{let s=t.vertices;for(let t=0;t<f;t++){let i=s[t];d[t]=i+(e[t]-i)*a}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++)d[t]+=(e[t]-d[t])*a;break;case t.MixBlend.add:let s=c;if(s.bones)for(let t=0;t<f;t++)d[t]+=e[t]*a;else{let t=s.vertices;for(let s=0;s<f;s++)d[s]+=(e[s]-t[s])*a}}return}let x=y.search1(p,i),w=this.getCurvePercent(i,x),b=m[x],M=m[x+1];if(1==a)if(r==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=e+(M[t]-e)*w}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t];d[t]+=s+(M[t]-s)*w-e[t]}}}else for(let t=0;t<f;t++){let e=b[t];d[t]=e+(M[t]-e)*w}else switch(r){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]=(e+(M[t]-e)*w)*a}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t],i=e[t];d[t]=i+(s+(M[t]-s)*w-i)*a}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w-d[t])*a}break;case t.MixBlend.add:let e=c;if(e.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w)*a}else{let t=e.vertices;for(let e=0;e<f;e++){let s=b[e];d[e]+=(s+(M[e]-s)*w-t[e])*a}}}}}class q extends y{static propertyIds=[""+b.event];events;constructor(t){super(t,q.propertyIds),this.events=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,n,a,r){if(!i)return;let o=this.frames,l=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,n,a,r),e=-1;else if(e>=o[l-1])return;if(s<o[0])return;let h=0;if(e<o[0])h=0;else{h=y.search1(o,e)+1;let t=o[h];for(;h>0&&o[h-1]==t;)h--}for(;h<l&&s>=o[h];h++)i.push(this.events[h])}}class U extends y{static propertyIds=[""+b.drawOrder];drawOrders;constructor(t){super(t,U.propertyIds),this.drawOrders=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(e,s,i,n,a,r,o){if(o==t.MixDirection.mixOut)return void(r==t.MixBlend.setup&&l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));if(i<this.frames[0])return void(r!=t.MixBlend.setup&&r!=t.MixBlend.first||l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));let h=y.search1(this.frames,i),c=this.drawOrders[h];if(c){let t=e.drawOrder,s=e.slots;for(let e=0,i=c.length;e<i;e++)t[e]=s[c[e]]}else l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length)}}class W extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.ikConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,i,n,a,r){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=a?1:0,this.frames[t+5]=r?1:0}apply(e,s,i,n,a,r,o){let l=e.ikConstraints[this.constraintIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(r){case t.MixBlend.setup:return l.mix=l.data.mix,l.softness=l.data.softness,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,void(l.stretch=l.data.stretch);case t.MixBlend.first:l.mix+=(l.data.mix-l.mix)*a,l.softness+=(l.data.softness-l.softness)*a,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch}return}let c=0,d=0,u=y.search(h,i,6),m=this.curves[u/6];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+6]-t);c+=(h[u+6+1]-c)*e,d+=(h[u+6+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}r==t.MixBlend.setup?(l.mix=l.data.mix+(c-l.data.mix)*a,l.softness=l.data.softness+(d-l.data.softness)*a,o==t.MixDirection.mixOut?(l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch):(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5])):(l.mix+=(c-l.mix)*a,l.softness+=(d-l.softness)*a,o==t.MixDirection.mixIn&&(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5]))}}class z extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.transformConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,a,r,o){let l=this.frames;l[t*=7]=e,l[t+1]=s,l[t+2]=i,l[t+3]=n,l[t+4]=a,l[t+5]=r,l[t+6]=o}apply(e,s,i,n,a,r,o){let l=e.transformConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u,m,f,p=this.frames;if(i<p[0]){let e=l.data;switch(r){case t.MixBlend.setup:return l.mixRotate=e.mixRotate,l.mixX=e.mixX,l.mixY=e.mixY,l.mixScaleX=e.mixScaleX,l.mixScaleY=e.mixScaleY,void(l.mixShearY=e.mixShearY);case t.MixBlend.first:l.mixRotate+=(e.mixRotate-l.mixRotate)*a,l.mixX+=(e.mixX-l.mixX)*a,l.mixY+=(e.mixY-l.mixY)*a,l.mixScaleX+=(e.mixScaleX-l.mixScaleX)*a,l.mixScaleY+=(e.mixScaleY-l.mixScaleY)*a,l.mixShearY+=(e.mixShearY-l.mixShearY)*a}return}let g=y.search(p,i,7),x=this.curves[g/7];switch(x){case 0:let t=p[g];h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];let e=(i-t)/(p[g+7]-t);h+=(p[g+7+1]-h)*e,c+=(p[g+7+2]-c)*e,d+=(p[g+7+3]-d)*e,u+=(p[g+7+4]-u)*e,m+=(p[g+7+5]-m)*e,f+=(p[g+7+6]-f)*e;break;case 1:h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];break;default:h=this.getBezierValue(i,g,1,x-2),c=this.getBezierValue(i,g,2,x+18-2),d=this.getBezierValue(i,g,3,x+36-2),u=this.getBezierValue(i,g,4,x+54-2),m=this.getBezierValue(i,g,5,x+72-2),f=this.getBezierValue(i,g,6,x+90-2)}if(r==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*a,l.mixX=t.mixX+(c-t.mixX)*a,l.mixY=t.mixY+(d-t.mixY)*a,l.mixScaleX=t.mixScaleX+(u-t.mixScaleX)*a,l.mixScaleY=t.mixScaleY+(m-t.mixScaleY)*a,l.mixShearY=t.mixShearY+(f-t.mixShearY)*a}else l.mixRotate+=(h-l.mixRotate)*a,l.mixX+=(c-l.mixX)*a,l.mixY+=(d-l.mixY)*a,l.mixScaleX+=(u-l.mixScaleX)*a,l.mixScaleY+=(m-l.mixScaleY)*a,l.mixShearY+=(f-l.mixShearY)*a}}class G extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintPosition+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.position=this.getAbsoluteValue(s,n,a,o.position,o.data.position))}}class $ extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintSpacing+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.spacing=this.getAbsoluteValue(s,n,a,o.spacing,o.data.spacing))}}class j extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.pathConstraintMix+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){let a=this.frames;a[t<<=2]=e,a[t+1]=s,a[t+2]=i,a[t+3]=n}apply(e,s,i,n,a,r,o){let l=e.pathConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u=this.frames;if(i<u[0]){switch(r){case t.MixBlend.setup:return l.mixRotate=l.data.mixRotate,l.mixX=l.data.mixX,void(l.mixY=l.data.mixY);case t.MixBlend.first:l.mixRotate+=(l.data.mixRotate-l.mixRotate)*a,l.mixX+=(l.data.mixX-l.mixX)*a,l.mixY+=(l.data.mixY-l.mixY)*a}return}let m=y.search(u,i,4),f=this.curves[m>>2];switch(f){case 0:let t=u[m];h=u[m+1],c=u[m+2],d=u[m+3];let e=(i-t)/(u[m+4]-t);h+=(u[m+4+1]-h)*e,c+=(u[m+4+2]-c)*e,d+=(u[m+4+3]-d)*e;break;case 1:h=u[m+1],c=u[m+2],d=u[m+3];break;default:h=this.getBezierValue(i,m,1,f-2),c=this.getBezierValue(i,m,2,f+18-2),d=this.getBezierValue(i,m,3,f+36-2)}if(r==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*a,l.mixX=t.mixX+(c-t.mixX)*a,l.mixY=t.mixY+(d-t.mixY)*a}else l.mixRotate+=(h-l.mixRotate)*a,l.mixX+=(c-l.mixX)*a,l.mixY+=(d-l.mixY)*a}}class H extends S{constraintIndex=0;constructor(t,e,s,i){super(t,e,i+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,a,r){let o;if(-1==this.constraintIndex){const e=s>=this.frames[0]?this.getCurveValue(s):0;for(const i of t.physicsConstraints)i.active&&this.global(i.data)&&this.set(i,this.getAbsoluteValue2(s,n,a,this.get(i),this.setup(i),e))}else o=t.physicsConstraints[this.constraintIndex],o.active&&this.set(o,this.getAbsoluteValue(s,n,a,this.get(o),this.setup(o)))}}class J extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintInertia)}setup(t){return t.data.inertia}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}}class K extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintStrength)}setup(t){return t.data.strength}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}}class Q extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintDamping)}setup(t){return t.data.damping}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}}class Z extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMass)}setup(t){return 1/t.data.massInverse}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}}class tt extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintWind)}setup(t){return t.data.wind}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}}class et extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintGravity)}setup(t){return t.data.gravity}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}}class st extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMix)}setup(t){return t.data.mix}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}}class it extends y{static propertyIds=[b.physicsConstraintReset.toString()];constraintIndex;constructor(t,e){super(t,it.propertyIds),this.constraintIndex=e}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e}apply(t,e,s,i,n,a,r){let o;if(-1!=this.constraintIndex&&(o=t.physicsConstraints[this.constraintIndex],!o.active))return;const l=this.frames;if(e>s)this.apply(t,e,Number.MAX_VALUE,[],n,a,r),e=-1;else if(e>=l[l.length-1])return;if(!(s<l[0])&&(e<l[0]||s>=l[y.search1(l,e)+1]))if(null!=o)o.reset();else for(const e of t.physicsConstraints)e.active&&e.reset()}}class nt extends y{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(t,e,s){super(t,[b.sequence+"|"+e+"|"+s.sequence.id]),this.slotIndex=e,this.attachment=s}getFrameEntries(){return nt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(t,e,s,i,n){let a=this.frames;a[t*=nt.ENTRIES]=e,a[t+nt.MODE]=s|i<<4,a[t+nt.DELAY]=n}apply(e,s,i,n,a,r,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.attachment,c=this.attachment;if(!(h==c||h instanceof u&&h.timelineAttachment==c))return;if(o==t.MixDirection.mixOut)return void(r==t.MixBlend.setup&&(l.sequenceIndex=-1));let d=this.frames;if(i<d[0])return void(r!=t.MixBlend.setup&&r!=t.MixBlend.first||(l.sequenceIndex=-1));let m=y.search(d,i,nt.ENTRIES),g=d[m],x=d[m+nt.MODE],w=d[m+nt.DELAY];if(!this.attachment.sequence)return;let b=x>>4,M=this.attachment.sequence.regions.length,S=p[15&x];if(S!=f.hold)switch(b+=(i-g)/w+1e-5|0,S){case f.once:b=Math.min(M-1,b);break;case f.loop:b%=M;break;case f.pingpong:{let t=(M<<1)-2;b=0==t?0:b%t,b>=M&&(b=t-b);break}case f.onceReverse:b=Math.max(M-1-b,0);break;case f.loopReverse:b=M-1-b%M;break;case f.pingpongReverse:{let t=(M<<1)-2;b=0==t?0:(b+M-1)%t,b>=M&&(b=t-b)}}l.sequenceIndex=b}}class at{static _emptyAnimation=new g("<empty>",[],0);static emptyAnimation(){return at._emptyAnimation}data;tracks=new Array;timeScale=1;unkeyedState=0;events=new Array;listeners=new Array;queue=new ot(this);propertyIDs=new i;animationsChanged=!1;trackEntryPool=new h((()=>new rt));constructor(t){this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(!i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let n=t*i.timeScale;if(i.delay>0){if(i.delay-=n,i.delay>0)continue;n=-i.delay,i.delay=0}let a=i.next;if(a){let e=i.trackLast-a.delay;if(e>=0){for(a.delay=0,a.trackTime+=0==i.timeScale?0:(e/i.timeScale+t)*a.timeScale,i.trackTime+=n,this.setCurrent(s,a,!0);a.mixingFrom;)a.mixTime+=t,a=a.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&!i.mixingFrom){e[s]=null,this.queue.end(i),this.clearNext(i);continue}if(i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null,t&&(t.mixingTo=null);t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(!s)return!0;let i=this.updateMixingFrom(s,e);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,s.mixingFrom&&(s.mixingFrom.mixingTo=t),t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e,!1)}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,o=i.length;r<o;r++){let o=i[r];if(!o||o.delay>0)continue;n=!0;let h=0==r?t.MixBlend.first:o.mixBlend,c=o.alpha;o.mixingFrom?c*=this.applyMixingFrom(o,e,h):o.trackTime>=o.trackEnd&&!o.next&&(c=0);let d=c>=o.alphaAttachmentThreshold,u=o.animationLast,m=o.getAnimationTime(),f=m,p=s;o.reverse&&(f=o.animation.duration-f,p=null);let g=o.animation.timelines,x=g.length;if(0==r&&1==c||h==t.MixBlend.add){0==r&&(d=!0);for(let s=0;s<x;s++){l.webkit602BugfixHelper(c,h);var a=g[s];a instanceof N?this.applyAttachmentTimeline(a,e,f,h,d):a.apply(e,u,f,p,c,h,t.MixDirection.mixIn)}}else{let s=o.timelineMode,i=o.shortestRotation,n=!i&&o.timelinesRotation.length!=x<<1;n&&(o.timelinesRotation.length=x<<1);for(let a=0;a<x;a++){let r=g[a],m=s[a]==ht?h:t.MixBlend.setup;!i&&r instanceof k?this.applyRotateTimeline(r,e,f,c,m,o.timelinesRotation,a<<1,n):r instanceof N?this.applyAttachmentTimeline(r,e,f,h,d):(l.webkit602BugfixHelper(c,h),r.apply(e,u,f,p,c,m,t.MixDirection.mixIn))}}this.queueEvents(o,m),s.length=0,o.nextAnimationLast=m,o.nextTrackLast=o.trackTime}for(var r=this.unkeyedState+ft,o=e.slots,h=0,c=e.slots.length;h<c;h++){var d=o[h];if(d.attachmentState==r){var u=d.data.attachmentName;d.setAttachment(u?e.getAttachment(d.data.index,u):null)}}return this.unkeyedState+=2,this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;n.mixingFrom&&this.applyMixingFrom(n,s,i);let a=0;0==e.mixDuration?(a=1,i==t.MixBlend.first&&(i=t.MixBlend.setup)):(a=e.mixTime/e.mixDuration,a>1&&(a=1),i!=t.MixBlend.first&&(i=n.mixBlend));let r=a<n.mixAttachmentThreshold,o=a<n.mixDrawOrderThreshold,h=n.animation.timelines,c=h.length,d=n.alpha*e.interruptAlpha,u=d*(1-a),m=n.animationLast,f=n.getAnimationTime(),p=f,g=null;if(n.reverse?p=n.animation.duration-p:a<n.eventThreshold&&(g=this.events),i==t.MixBlend.add)for(let e=0;e<c;e++)h[e].apply(s,m,p,g,u,i,t.MixDirection.mixOut);else{let e=n.timelineMode,a=n.timelineHoldMix,f=n.shortestRotation,x=!f&&n.timelinesRotation.length!=c<<1;x&&(n.timelinesRotation.length=c<<1),n.totalAlpha=0;for(let w=0;w<c;w++){let c,b=h[w],y=t.MixDirection.mixOut,M=0;switch(e[w]){case ht:if(!o&&b instanceof U)continue;c=i,M=u;break;case ct:c=t.MixBlend.setup,M=u;break;case dt:c=i,M=d;break;case ut:c=t.MixBlend.setup,M=d;break;default:c=t.MixBlend.setup;let e=a[w];M=d*Math.max(0,1-e.mixTime/e.mixDuration)}n.totalAlpha+=M,!f&&b instanceof k?this.applyRotateTimeline(b,s,p,M,c,n.timelinesRotation,w<<1,x):b instanceof N?this.applyAttachmentTimeline(b,s,p,c,r&&M>=n.alphaAttachmentThreshold):(l.webkit602BugfixHelper(M,i),o&&b instanceof U&&c==t.MixBlend.setup&&(y=t.MixDirection.mixIn),b.apply(s,m,p,g,M,c,y))}}return e.mixDuration>0&&this.queueEvents(n,f),this.events.length=0,n.nextAnimationLast=f,n.nextTrackLast=n.trackTime,a}applyAttachmentTimeline(e,s,i,n,a){var r=s.slots[e.slotIndex];r.bone.active&&(i<e.frames[0]?n!=t.MixBlend.setup&&n!=t.MixBlend.first||this.setAttachment(s,r,r.data.attachmentName,a):this.setAttachment(s,r,e.attachmentNames[y.search1(e.frames,i)],a),r.attachmentState<=this.unkeyedState&&(r.attachmentState=this.unkeyedState+ft))}setAttachment(t,e,s,i){e.setAttachment(s?t.getAttachment(e.data.index,s):null),i&&(e.attachmentState=this.unkeyedState+pt)}applyRotateTimeline(e,s,i,n,r,o,l,h){if(h&&(o[l]=0),1==n)return void e.apply(s,0,i,null,1,r,t.MixDirection.mixIn);let c=s.bones[e.boneIndex];if(!c.active)return;let d=0,u=0;if(i<e.frames[0])switch(r){case t.MixBlend.setup:c.rotation=c.data.rotation;default:return;case t.MixBlend.first:d=c.rotation,u=c.data.rotation}else d=r==t.MixBlend.setup?c.data.rotation:c.rotation,u=c.data.rotation+e.getCurveValue(i);let m=0,f=u-d;if(f-=360*Math.ceil(f/360-.5),0==f)m=o[l];else{let t=0,e=0;h?(t=0,e=f):(t=o[l],e=o[l+1]);let s=t-t%360;m=f+s;let i=f>=0,n=t>=0;Math.abs(e)<=90&&a.signum(e)!=a.signum(f)&&(Math.abs(t-s)>180?(m+=360*a.signum(t),n=i):0!=s?m-=360*a.signum(t):n=i),n!=i&&(m+=360*a.signum(t)),o[l]=m}o[l+1]=f,c.rotation=d+m*n}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,n=i-s,a=t.trackLast%n,r=this.events,o=0,l=r.length;for(;o<l;o++){let e=r[o];if(e.time<a)break;e.time>i||this.queue.event(t,e)}let h=!1;if(t.loop)if(0==n)h=!0;else{const e=Math.floor(t.trackTime/n);h=e>0&&e>Math.floor(t.trackLast/n)}else h=e>=i&&t.animationLast<i;for(h&&this.queue.complete(t);o<l;o++){let e=r[o];e.time<s||this.queue.event(t,e)}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(!e)return;this.queue.end(e),this.clearNext(e);let s=e;for(;;){let t=s.mixingFrom;if(!t)break;this.queue.end(t),s.mixingFrom=null,s.mixingTo=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,e.previous=null,i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,i.mixingTo=e,e.mixTime=0,i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s=!1){let i=this.data.skeletonData.findAnimation(e);if(!i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s=!1){if(!e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.clearNext(n),n=n.mixingFrom,i=!1):this.clearNext(n));let a=this.trackEntry(t,e,s,n);return this.setCurrent(t,a,i),this.queue.drain(),a}addAnimation(t,e,s=!1,i=0){let n=this.data.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s=!1,i=0){if(!e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(n)for(;n.next;)n=n.next;let a=this.trackEntry(t,e,s,n);return n?(n.next=a,a.previous=n,i<=0&&(i+=n.getTrackComplete()-a.mixDuration)):(this.setCurrent(t,a,!0),this.queue.drain()),a.delay=i,a}setEmptyAnimation(t,e=0){let s=this.setAnimationWith(t,at.emptyAnimation(),!1);return s.mixDuration=e,s.trackEnd=e,s}addEmptyAnimation(t,e=0,s=0){let i=this.addAnimationWith(t,at.emptyAnimation(),!1,s);return s<=0&&(i.delay+=i.mixDuration-e),i.mixDuration=e,i.trackEnd=e,i}setEmptyAnimations(t=0){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(l.ensureArrayCapacity(this.tracks,t+1,null),this.tracks.length=t+1,null)}trackEntry(e,s,i,n){let a=this.trackEntryPool.obtain();return a.reset(),a.trackIndex=e,a.animation=s,a.loop=i,a.holdPrevious=!1,a.reverse=!1,a.shortestRotation=!1,a.eventThreshold=0,a.alphaAttachmentThreshold=0,a.mixAttachmentThreshold=0,a.mixDrawOrderThreshold=0,a.animationStart=0,a.animationEnd=s.duration,a.animationLast=-1,a.nextAnimationLast=-1,a.delay=0,a.trackTime=0,a.trackLast=-1,a.nextTrackLast=-1,a.trackEnd=Number.MAX_VALUE,a.timeScale=1,a.alpha=1,a.mixTime=0,a.mixDuration=n?this.data.getMix(n.animation,s):0,a.interruptAlpha=1,a.totalAlpha=0,a.mixBlend=t.MixBlend.replace,a}clearNext(t){let e=t.next;for(;e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1,this.propertyIDs.clear();let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do{i.mixingTo&&i.mixBlend==t.MixBlend.add||this.computeHold(i),i=i.mixingTo}while(i)}}}computeHold(t){let e=t.mixingTo,s=t.animation.timelines,i=t.animation.timelines.length,n=t.timelineMode;n.length=i;let a=t.timelineHoldMix;a.length=0;let r=this.propertyIDs;if(e&&e.holdPrevious)for(let t=0;t<i;t++)n[t]=r.addAll(s[t].getPropertyIds())?ut:dt;else t:for(let o=0;o<i;o++){let i=s[o],l=i.getPropertyIds();if(r.addAll(l))if(!e||i instanceof N||i instanceof U||i instanceof q||!e.animation.hasTimeline(l))n[o]=ct;else{for(let s=e.mixingTo;s;s=s.mixingTo)if(!s.animation.hasTimeline(l)){if(t.mixDuration>0){n[o]=mt,a[o]=s;continue t}break}n[o]=ut}else n[o]=ht}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(!t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}}class rt{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;holdPrevious=!1;reverse=!1;shortestRotation=!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;interruptAlpha=0;totalAlpha=0;get mixDuration(){return this._mixDuration}set mixDuration(t){this._mixDuration=t}setMixDurationWithDelay(t,e){this._mixDuration=t,null!=this.previous&&e<=0&&(e+=this.previous.getTrackComplete()-t),this.delay=e}mixBlend=t.MixBlend.replace;timelineMode=new Array;timelineHoldMix=new Array;timelinesRotation=new Array;reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){let t=this.animationEnd-this.animationStart;if(0!=t){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return-1!=this.nextTrackLast}isNextReady(){return null!=this.next&&this.nextTrackLast-this.next.delay>=0}}class ot{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(e){this.objects.push(t.EventType.start),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(t.EventType.interrupt),this.objects.push(e)}end(e){this.objects.push(t.EventType.end),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(t.EventType.dispose),this.objects.push(e)}complete(e){this.objects.push(t.EventType.complete),this.objects.push(e)}event(e,s){this.objects.push(t.EventType.event),this.objects.push(e),this.objects.push(s)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let e=this.objects,s=this.animState.listeners;for(let i=0;i<e.length;i+=2){let n=e[i],a=e[i+1];switch(n){case t.EventType.start:a.listener&&a.listener.start&&a.listener.start(a);for(let t=0;t<s.length;t++){let e=s[t];e.start&&e.start(a)}break;case t.EventType.interrupt:a.listener&&a.listener.interrupt&&a.listener.interrupt(a);for(let t=0;t<s.length;t++){let e=s[t];e.interrupt&&e.interrupt(a)}break;case t.EventType.end:a.listener&&a.listener.end&&a.listener.end(a);for(let t=0;t<s.length;t++){let e=s[t];e.end&&e.end(a)}case t.EventType.dispose:a.listener&&a.listener.dispose&&a.listener.dispose(a);for(let t=0;t<s.length;t++){let e=s[t];e.dispose&&e.dispose(a)}this.animState.trackEntryPool.free(a);break;case t.EventType.complete:a.listener&&a.listener.complete&&a.listener.complete(a);for(let t=0;t<s.length;t++){let e=s[t];e.complete&&e.complete(a)}break;case t.EventType.event:let n=e[2+i++];a.listener&&a.listener.event&&a.listener.event(a,n);for(let t=0;t<s.length;t++){let e=s[t];e.event&&e.event(a,n)}}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var lt;t.EventType=void 0,(lt=t.EventType||(t.EventType={}))[lt.start=0]="start",lt[lt.interrupt=1]="interrupt",lt[lt.end=2]="end",lt[lt.dispose=3]="dispose",lt[lt.complete=4]="complete",lt[lt.event=5]="event";const ht=0,ct=1,dt=2,ut=3,mt=4,ft=1,pt=2;class gt{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(!i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class xt extends u{color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new xt(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t}}class wt extends u{endSlot=null;color=new n(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){let t=new wt(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t}}class bt{_image;constructor(t){this._image=t}getImage(){return this._image}}var yt,Mt,St,vt,kt,It,At,Tt,Bt;t.TextureFilter=void 0,(yt=t.TextureFilter||(t.TextureFilter={}))[yt.Nearest=9728]="Nearest",yt[yt.Linear=9729]="Linear",yt[yt.MipMap=9987]="MipMap",yt[yt.MipMapNearestNearest=9984]="MipMapNearestNearest",yt[yt.MipMapLinearNearest=9985]="MipMapLinearNearest",yt[yt.MipMapNearestLinear=9986]="MipMapNearestLinear",yt[yt.MipMapLinearLinear=9987]="MipMapLinearLinear",t.TextureWrap=void 0,(Mt=t.TextureWrap||(t.TextureWrap={}))[Mt.MirroredRepeat=33648]="MirroredRepeat",Mt[Mt.ClampToEdge=33071]="ClampToEdge",Mt[Mt.Repeat=10497]="Repeat";class Ct{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0}class Ft{pages=new Array;regions=new Array;constructor(e){let s=new Et(e),i=new Array(4),n={size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},format:()=>{},filter:e=>{e.minFilter=l.enumValue(t.TextureFilter,i[1]),e.magFilter=l.enumValue(t.TextureFilter,i[2])},repeat:e=>{-1!=i[1].indexOf("x")&&(e.uWrap=t.TextureWrap.Repeat),-1!=i[1].indexOf("y")&&(e.vWrap=t.TextureWrap.Repeat)},pma:t=>{t.pma="true"==i[1]}};var a={xy:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2])},size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},bounds:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2]),t.width=parseInt(i[3]),t.height=parseInt(i[4])},offset:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2])},orig:t=>{t.originalWidth=parseInt(i[1]),t.originalHeight=parseInt(i[2])},offsets:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2]),t.originalWidth=parseInt(i[3]),t.originalHeight=parseInt(i[4])},rotate:t=>{let e=i[1];"true"==e?t.degrees=90:"false"!=e&&(t.degrees=parseInt(e))},index:t=>{t.index=parseInt(i[1])}};let r=s.readLine();for(;r&&0==r.trim().length;)r=s.readLine();for(;r&&0!=r.trim().length&&0!=s.readEntry(i,r);)r=s.readLine();let o=null,h=null,c=null;for(;null!==r;)if(0==r.trim().length)o=null,r=s.readLine();else if(o){let t=new Rt(o,r);for(;;){let e=s.readEntry(i,r=s.readLine());if(0==e)break;let n=a[i[0]];if(n)n(t);else{h||(h=[]),c||(c=[]),h.push(i[0]);let t=[];for(let s=0;s<e;s++)t.push(parseInt(i[s+1]));c.push(t)}}0==t.originalWidth&&0==t.originalHeight&&(t.originalWidth=t.width,t.originalHeight=t.height),h&&h.length>0&&c&&c.length>0&&(t.names=h,t.values=c,h=null,c=null),t.u=t.x/o.width,t.v=t.y/o.height,90==t.degrees?(t.u2=(t.x+t.height)/o.width,t.v2=(t.y+t.width)/o.height):(t.u2=(t.x+t.width)/o.width,t.v2=(t.y+t.height)/o.height),this.regions.push(t)}else{for(o=new Yt(r.trim());0!=s.readEntry(i,r=s.readLine());){let t=n[i[0]];t&&t(o)}this.pages.push(o)}}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(let 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()}}class Et{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)return 0;if(0==(e=e.trim()).length)return 0;let s=e.indexOf(":");if(-1==s)return 0;t[0]=e.substr(0,s).trim();for(let i=1,n=s+1;;i++){let s=e.indexOf(",",n);if(-1==s)return t[i]=e.substr(n).trim(),i;if(t[i]=e.substr(n,s-n).trim(),n=s+1,4==i)return 4}}}class Yt{name;minFilter=t.TextureFilter.Nearest;magFilter=t.TextureFilter.Nearest;uWrap=t.TextureWrap.ClampToEdge;vWrap=t.TextureWrap.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=new Array;constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(let e of this.regions)e.texture=t}}class Rt extends Ct{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)}}class Pt extends u{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new n(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new n(0,0,0,0);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.regionUVs;this.uvs&&this.uvs.length==t.length||(this.uvs=l.newFloatArray(t.length));let e=this.uvs,s=this.uvs.length,i=this.region.u,n=this.region.v,a=0,r=0;if(this.region instanceof Rt){let o=this.region,l=o.page,h=l.width,c=l.height;switch(o.degrees){case 90:i-=(o.originalHeight-o.offsetY-o.height)/h,n-=(o.originalWidth-o.offsetX-o.width)/c,a=o.originalHeight/h,r=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+t[o+1]*a,e[o+1]=n+(1-t[o])*r;return;case 180:i-=(o.originalWidth-o.offsetX-o.width)/h,n-=o.offsetY/c,a=o.originalWidth/h,r=o.originalHeight/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o])*a,e[o+1]=n+(1-t[o+1])*r;return;case 270:i-=o.offsetY/h,n-=o.offsetX/c,a=o.originalHeight/h,r=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o+1])*a,e[o+1]=n+t[o]*r;return}i-=o.offsetX/h,n-=(o.originalHeight-o.offsetY-o.height)/c,a=o.originalWidth/h,r=o.originalHeight/c}else this.region?(a=this.region.u2-i,r=this.region.v2-n):(i=n=0,a=r=1);for(let o=0;o<s;o+=2)e[o]=i+t[o]*a,e[o+1]=n+t[o+1]*r}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}copy(){if(this.parentMesh)return this.newLinkedMesh();let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=new Array(this.regionUVs.length),l.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.uvs=new Array(this.uvs.length),l.arrayCopy(this.uvs,0,t.uvs,0,this.uvs.length),t.triangles=new Array(this.triangles.length),l.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,t.sequence=null!=this.sequence?this.sequence.copy():null,this.edges&&(t.edges=new Array(this.edges.length),l.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}computeWorldVertices(t,e,s,i,n,a){null!=this.sequence&&this.sequence.apply(t,this),super.computeWorldVertices(t,e,s,i,n,a)}newLinkedMesh(){let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),t.timelineAttachment=this.timelineAttachment,t.setParentMesh(this.parentMesh?this.parentMesh:this),null!=t.region&&t.updateRegion(),t}}class Xt extends u{lengths=[];closed=!1;constantSpeed=!1;color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new Xt(this.name);return this.copyTo(t),t.lengths=new Array(this.lengths.length),l.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}}class _t extends u{x=0;y=0;rotation=0;color=new n(.38,.94,0,1);constructor(t){super(t)}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){const e=this.rotation*a.degRad,s=Math.cos(e),i=Math.sin(e),n=s*t.a+i*t.b,r=s*t.c+i*t.d;return a.atan2Deg(r,n)}copy(){let t=new _t(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t}}class Vt extends d{x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;color=new n(1,1,1,1);path;region=null;sequence=null;offset=l.newFloatArray(8);uvs=l.newFloatArray(8);tempColor=new n(1,1,1,1);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.region,e=this.uvs;if(null==t)return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=1,e[5]=1,e[6]=1,void(e[7]=0);let s=this.width/this.region.originalWidth*this.scaleX,i=this.height/this.region.originalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.region.offsetX*s,r=-this.height/2*this.scaleY+this.region.offsetY*i,o=n+this.region.width*s,l=r+this.region.height*i,h=this.rotation*a.degRad,c=Math.cos(h),d=Math.sin(h),u=this.x,m=this.y,f=n*c+u,p=n*d,g=r*c+m,x=r*d,w=o*c+u,b=o*d,y=l*c+m,M=l*d,S=this.offset;S[0]=f-x,S[1]=g+p,S[2]=f-M,S[3]=y+p,S[4]=w-M,S[5]=y+b,S[6]=w-x,S[7]=g+b,90==t.degrees?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(t,e,s,i){null!=this.sequence&&this.sequence.apply(t,this);let n=t.bone,a=this.offset,r=n.worldX,o=n.worldY,l=n.a,h=n.b,c=n.c,d=n.d,u=0,m=0;u=a[0],m=a[1],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[2],m=a[3],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[4],m=a[5],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o,s+=i,u=a[6],m=a[7],e[s]=u*l+m*h+r,e[s+1]=u*c+m*d+o}copy(){let t=new Vt(this.name,this.path);return t.region=this.region,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,l.arrayCopy(this.uvs,0,t.uvs,0,8),l.arrayCopy(this.offset,0,t.offset,0,8),t.color.setFromColor(this.color),t.sequence=null!=this.sequence?this.sequence.copy():null,t}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}class Dt{atlas;constructor(t){this.atlas=t}loadSequence(t,e,s){let i=s.regions;for(let n=0,a=i.length;n<a;n++){let a=s.getPath(e,n),r=this.atlas.findRegion(a);if(null==r)throw new Error("Region not found in atlas: "+a+" (sequence: "+t+")");i[n]=r}}newRegionAttachment(t,e,s,i){let n=new Vt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");n.region=t}return n}newMeshAttachment(t,e,s,i){let n=new Pt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");n.region=t}return n}newBoundingBoxAttachment(t,e){return new xt(e)}newPathAttachment(t,e){return new Xt(e)}newPointAttachment(t,e){return new _t(e)}newClippingAttachment(t,e){return new wt(e)}}class Ot{index=0;name;parent=null;length=0;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;inherit=t.Inherit.Normal;skinRequired=!1;color=new n;icon;visible=!1;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}t.Inherit=void 0,(St=t.Inherit||(t.Inherit={}))[St.Normal=0]="Normal",St[St.OnlyTranslation=1]="OnlyTranslation",St[St.NoRotationOrReflection=2]="NoRotationOrReflection",St[St.NoScale=3]="NoScale",St[St.NoScaleOrReflection=4]="NoScaleOrReflection";class Nt{data;skeleton;parent=null;children=new Array;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=t.Inherit.Normal;sorted=!1;active=!1;constructor(t,e,s){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(e,s,i,n,r,o,l){this.ax=e,this.ay=s,this.arotation=i,this.ascaleX=n,this.ascaleY=r,this.ashearX=o,this.ashearY=l;let h=this.parent;if(!h){let t=this.skeleton;const h=t.scaleX,c=t.scaleY,d=(i+o)*a.degRad,u=(i+90+l)*a.degRad;return this.a=Math.cos(d)*n*h,this.b=Math.cos(u)*r*h,this.c=Math.sin(d)*n*c,this.d=Math.sin(u)*r*c,this.worldX=e*h+t.x,void(this.worldY=s*c+t.y)}let c=h.a,d=h.b,u=h.c,m=h.d;switch(this.worldX=c*e+d*s+h.worldX,this.worldY=u*e+m*s+h.worldY,this.inherit){case t.Inherit.Normal:{const t=(i+o)*a.degRad,e=(i+90+l)*a.degRad,s=Math.cos(t)*n,h=Math.cos(e)*r,f=Math.sin(t)*n,p=Math.sin(e)*r;return this.a=c*s+d*f,this.b=c*h+d*p,this.c=u*s+m*f,void(this.d=u*h+m*p)}case t.Inherit.OnlyTranslation:{const t=(i+o)*a.degRad,e=(i+90+l)*a.degRad;this.a=Math.cos(t)*n,this.b=Math.cos(e)*r,this.c=Math.sin(t)*n,this.d=Math.sin(e)*r;break}case t.Inherit.NoRotationOrReflection:{let t=1/this.skeleton.scaleX,e=1/this.skeleton.scaleY;c*=t,u*=e;let s=c*c+u*u,h=0;s>1e-4?(s=Math.abs(c*m*e-d*t*u)/s,d=u*s,m=c*s,h=Math.atan2(u,c)*a.radDeg):(c=0,u=0,h=90-Math.atan2(m,d)*a.radDeg);const f=(i+o-h)*a.degRad,p=(i+l-h+90)*a.degRad,g=Math.cos(f)*n,x=Math.cos(p)*r,w=Math.sin(f)*n,b=Math.sin(p)*r;this.a=c*g-d*w,this.b=c*x-d*b,this.c=u*g+m*w,this.d=u*x+m*b;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:{i*=a.degRad;const e=Math.cos(i),s=Math.sin(i);let h=(c*e+d*s)/this.skeleton.scaleX,f=(u*e+m*s)/this.skeleton.scaleY,p=Math.sqrt(h*h+f*f);p>1e-5&&(p=1/p),h*=p,f*=p,p=Math.sqrt(h*h+f*f),this.inherit==t.Inherit.NoScale&&c*m-d*u<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p),i=Math.PI/2+Math.atan2(f,h);const g=Math.cos(i)*p,x=Math.sin(i)*p;o*=a.degRad,l=(90+l)*a.degRad;const w=Math.cos(o)*n,b=Math.cos(l)*r,y=Math.sin(o)*n,M=Math.sin(l)*r;this.a=h*w+g*y,this.b=h*b+g*M,this.c=f*w+x*y,this.d=f*b+x*M;break}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;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}updateAppliedTransform(){let e=this.parent;if(!e)return this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,this.arotation=Math.atan2(this.c,this.a)*a.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*a.radDeg);let s,i,n,r,o=e.a,l=e.b,h=e.c,c=e.d,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d,g=this.worldX-e.worldX,x=this.worldY-e.worldY;if(this.ax=g*u-x*m,this.ay=x*p-g*f,this.inherit==t.Inherit.OnlyTranslation)s=this.a,i=this.b,n=this.c,r=this.d;else{switch(this.inherit){case t.Inherit.NoRotationOrReflection:{let t=Math.abs(o*c-l*h)/(o*o+h*h);l=-h*this.skeleton.scaleX*t/this.skeleton.scaleY,c=o*this.skeleton.scaleY*t/this.skeleton.scaleX,d=1/(o*c-l*h),u=c*d,m=l*d;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:let e=a.cosDeg(this.rotation),s=a.sinDeg(this.rotation);o=(o*e+l*s)/this.skeleton.scaleX,h=(h*e+c*s)/this.skeleton.scaleY;let i=Math.sqrt(o*o+h*h);i>1e-5&&(i=1/i),o*=i,h*=i,i=Math.sqrt(o*o+h*h),this.inherit==t.Inherit.NoScale&&d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(i=-i);let n=a.PI/2+Math.atan2(h,o);l=Math.cos(n)*i,c=Math.sin(n)*i,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d}s=u*this.a-m*this.c,i=u*this.b-m*this.d,n=p*this.c-f*this.a,r=p*this.d-f*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(s*s+n*n),this.ascaleX>1e-4){let t=s*r-i*n;this.ascaleY=t/this.ascaleX,this.ashearY=-Math.atan2(s*i+n*r,t)*a.radDeg,this.arotation=Math.atan2(n,s)*a.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(i*i+r*r),this.ashearY=0,this.arotation=90-Math.atan2(r,i)*a.radDeg}getWorldRotationX(){return Math.atan2(this.c,this.a)*a.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*a.radDeg}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){let e=1/(this.a*this.d-this.b*this.c),s=t.x-this.worldX,i=t.y-this.worldY;return t.x=s*this.d*e-i*this.b*e,t.y=i*this.a*e-s*this.c*e,t}localToWorld(t){let 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(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.worldToLocal(t)}parentToWorld(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=a.sinDeg(t),s=a.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*a.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=a.sinDeg(t),s=a.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*a.radDeg}rotateWorld(t){t*=a.degRad;const e=Math.sin(t),s=Math.cos(t),i=this.a,n=this.b;this.a=s*i-e*this.c,this.b=s*n-e*this.d,this.c=e*i+s*this.c,this.d=e*n+s*this.d}}class Lt{name;order;skinRequired;constructor(t,e,s){this.name=t,this.order=e,this.skinRequired=s}}class qt{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return-1!=e?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){for(var e=window.atob(t),s=e.length,i=new Uint8Array(s),n=0;n<s;n++)i[n]=e.charCodeAt(n);return i}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(-1==e)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;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToString(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",t,!0);let n=()=>{this.finish(t,i.status,i.responseText)};i.onload=n,i.onerror=n,i.send()}downloadJson(t,e,s){this.downloadText(t,(t=>{e(JSON.parse(t))}),s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToUint8Array(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";let n=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{200==i.status||0==i.status?this.finish(t,200,new Uint8Array(i.response)):n()},i.onerror=n,i.send()}start(t,e,s){let i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,s)}}finish(t,e,s){let i=this.callbacks[t];delete this.callbacks[t];let n=200==e||0==e?[s]:[e,s];for(let t=n.length-1,e=i.length;t<e;t+=2)i[t].apply(null,n)}}class Ut{data;intValue=0;floatValue=0;stringValue=null;time=0;volume=0;balance=0;constructor(t,e){if(!e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class Wt{name;intValue=0;floatValue=0;stringValue=null;audioPath=null;volume=0;balance=0;constructor(t){this.name=t}}class zt{data;bones;target;bendDirection=0;compress=!1;stretch=!1;mix=1;softness=0;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find bone ${t.target.name}`);this.target=s,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}update(t){if(0==this.mix)return;let e=this.target,s=this.bones;switch(s.length){case 1:this.apply1(s[0],e.worldX,e.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(s[0],s[1],e.worldX,e.worldY,this.bendDirection,this.stretch,this.data.uniform,this.softness,this.mix)}}apply1(e,s,i,n,r,o,l){let h=e.parent;if(!h)throw new Error("IK bone must have parent.");let c=h.a,d=h.b,u=h.c,m=h.d,f=-e.ashearX-e.arotation,p=0,g=0;switch(e.inherit){case t.Inherit.OnlyTranslation:p=(s-e.worldX)*a.signum(e.skeleton.scaleX),g=(i-e.worldY)*a.signum(e.skeleton.scaleY);break;case t.Inherit.NoRotationOrReflection:let n=Math.abs(c*m-d*u)/Math.max(1e-4,c*c+u*u),r=c/e.skeleton.scaleX,o=u/e.skeleton.scaleY;d=-o*n*e.skeleton.scaleX,m=r*n*e.skeleton.scaleY,f+=Math.atan2(o,r)*a.radDeg;default:let l=s-h.worldX,x=i-h.worldY,w=c*m-d*u;Math.abs(w)<=1e-4?(p=0,g=0):(p=(l*m-x*d)/w-e.ax,g=(x*c-l*u)/w-e.ay)}f+=Math.atan2(g,p)*a.radDeg,e.ascaleX<0&&(f+=180),f>180?f-=360:f<-180&&(f+=360);let x=e.ascaleX,w=e.ascaleY;if(n||r){switch(e.inherit){case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:p=s-e.worldX,g=i-e.worldY}const a=e.data.length*x;if(a>1e-4){const t=p*p+g*g;if(n&&t<a*a||r&&t>a*a){const e=(Math.sqrt(t)/a-1)*l+1;x*=e,o&&(w*=e)}}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+f*l,x,w,e.ashearX,e.ashearY)}apply2(e,s,i,n,r,o,l,h,c){if(e.inherit!=t.Inherit.Normal||s.inherit!=t.Inherit.Normal)return;let d=e.ax,u=e.ay,m=e.ascaleX,f=e.ascaleY,p=m,g=f,x=s.ascaleX,w=0,b=0,y=0;m<0?(m=-m,w=180,y=-1):(w=0,y=1),f<0&&(f=-f,y=-y),x<0?(x=-x,b=180):b=0;let M=s.ax,S=0,v=0,k=0,I=e.a,A=e.b,T=e.c,B=e.d,C=Math.abs(m-f)<=1e-4;!C||o?(S=0,v=I*M+e.worldX,k=T*M+e.worldY):(S=s.ay,v=I*M+A*S+e.worldX,k=T*M+B*S+e.worldY);let F=e.parent;if(!F)throw new Error("IK parent must itself have a parent.");I=F.a,A=F.b,T=F.c,B=F.d;let E=I*B-A*T,Y=v-F.worldX,R=k-F.worldY;E=Math.abs(E)<=1e-4?0:1/E;let P,X,_=(Y*B-R*A)*E-d,V=(R*I-Y*T)*E-u,D=Math.sqrt(_*_+V*V),O=s.data.length*x;if(D<1e-4)return this.apply1(e,i,n,!1,o,!1,c),void s.updateWorldTransformWith(M,S,0,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY);Y=i-F.worldX,R=n-F.worldY;let N=(Y*B-R*A)*E-d,L=(R*I-Y*T)*E-u,q=N*N+L*L;if(0!=h){h*=m*(x+1)*.5;let t=Math.sqrt(q),e=t-D-O*m+h;if(e>0){let s=Math.min(1,e/(2*h))-1;s=(e-h*(1-s*s))/t,N-=s*N,L-=s*L,q=N*N+L*L}}t:if(C){O*=m;let t=(q-D*D-O*O)/(2*D*O);t<-1?(t=-1,X=Math.PI*r):t>1?(t=1,X=0,o&&(I=(Math.sqrt(q)/(D+O)-1)*c+1,p*=I,l&&(g*=I))):X=Math.acos(t)*r,I=D+O*t,A=O*Math.sin(X),P=Math.atan2(L*I-N*A,N*I+L*A)}else{I=m*O,A=f*O;let t=I*I,e=A*A,s=Math.atan2(L,N);T=e*D*D+t*q-t*e;let i=-2*e*D,n=e-t;if(B=i*i-4*n*T,B>=0){let t=Math.sqrt(B);i<0&&(t=-t),t=.5*-(i+t);let e=t/n,a=T/t,o=Math.abs(e)<Math.abs(a)?e:a;if(e=q-o*o,e>=0){R=Math.sqrt(e)*r,P=s-Math.atan2(R,o),X=Math.atan2(R/f,(o-D)/m);break t}}let o=a.PI,l=D-I,h=l*l,c=0,d=0,u=D+I,p=u*u,g=0;T=-I*D/(t-e),T>=-1&&T<=1&&(T=Math.acos(T),Y=I*Math.cos(T)+D,R=A*Math.sin(T),B=Y*Y+R*R,B<h&&(o=T,h=B,l=Y,c=R),B>p&&(d=T,p=B,u=Y,g=R)),q<=.5*(h+p)?(P=s-Math.atan2(c*r,l),X=o*r):(P=s-Math.atan2(g*r,u),X=d*r)}let U=Math.atan2(S,M)*y,W=e.arotation;P=(P-U)*a.radDeg+w-W,P>180?P-=360:P<-180&&(P+=360),e.updateWorldTransformWith(d,u,W+P*c,p,g,0,0),W=s.arotation,X=((X+U)*a.radDeg-s.ashearX)*y+b-W,X>180?X-=360:X<-180&&(X+=360),s.updateWorldTransformWith(M,S,W+X*c,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY)}}class Gt extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}bendDirection=0;compress=!1;stretch=!1;uniform=!1;mix=0;softness=0;constructor(t){super(t,0,!1)}}class $t extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("SlotData not set.")}positionMode=t.PositionMode.Fixed;spacingMode=t.SpacingMode.Fixed;rotateMode=t.RotateMode.Chain;offsetRotation=0;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;constructor(t){super(t,0,!1)}}t.PositionMode=void 0,(vt=t.PositionMode||(t.PositionMode={}))[vt.Fixed=0]="Fixed",vt[vt.Percent=1]="Percent",t.SpacingMode=void 0,(kt=t.SpacingMode||(t.SpacingMode={}))[kt.Length=0]="Length",kt[kt.Fixed=1]="Fixed",kt[kt.Percent=2]="Percent",kt[kt.Proportional=3]="Proportional",t.RotateMode=void 0,(It=t.RotateMode||(t.RotateMode={}))[It.Tangent=0]="Tangent",It[It.Chain=1]="Chain",It[It.ChainScale=2]="ChainScale";class jt{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=new Array;positions=new Array;world=new Array;curves=new Array;lengths=new Array;segments=new Array;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0,i=t.bones.length;s<i;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findSlot(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}`);this.target=s,this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}update(e){let s=this.target.getAttachment();if(!(s instanceof Xt))return;let i=this.mixRotate,n=this.mixX,r=this.mixY;if(0==i&&0==n&&0==r)return;let o=this.data,h=o.rotateMode==t.RotateMode.Tangent,c=o.rotateMode==t.RotateMode.ChainScale,d=this.bones,u=d.length,m=h?u:u+1,f=l.setArraySize(this.spaces,m),p=c?this.lengths=l.setArraySize(this.lengths,u):[],g=this.spacing;switch(o.spacingMode){case t.SpacingMode.Percent:if(c)for(let t=0,e=m-1;t<e;t++){let e=d[t],s=e.data.length,i=s*e.a,n=s*e.c;p[t]=Math.sqrt(i*i+n*n)}l.arrayFill(f,1,m,g);break;case t.SpacingMode.Proportional:let e=0;for(let t=0,s=m-1;t<s;){let s=d[t],i=s.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*s.a,a=i*s.c,r=Math.sqrt(n*n+a*a);c&&(p[t]=r),f[++t]=r,e+=r}}if(e>0){e=m/e*g;for(let t=1;t<m;t++)f[t]*=e}break;default:let s=o.spacingMode==t.SpacingMode.Length;for(let t=0,e=m-1;t<e;){let e=d[t],i=e.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*e.a,a=i*e.c,r=Math.sqrt(n*n+a*a);c&&(p[t]=r),f[++t]=(s?i+g:g)*r/i}}}let x=this.computeWorldPositions(s,m,h),w=x[0],b=x[1],y=o.offsetRotation,M=!1;if(0==y)M=o.rotateMode==t.RotateMode.Chain;else{M=!1;let t=this.target.bone;y*=t.a*t.d-t.b*t.c>0?a.degRad:-a.degRad}for(let t=0,e=3;t<u;t++,e+=3){let s=d[t];s.worldX+=(w-s.worldX)*n,s.worldY+=(b-s.worldY)*r;let o=x[e],l=x[e+1],u=o-w,m=l-b;if(c){let e=p[t];if(0!=e){let t=(Math.sqrt(u*u+m*m)/e-1)*i+1;s.a*=t,s.c*=t}}if(w=o,b=l,i>0){let n=s.a,r=s.b,o=s.c,l=s.d,c=0,d=0,p=0;if(c=h?x[e-1]:0==f[t+1]?x[e+2]:Math.atan2(m,u),c-=Math.atan2(o,n),M){d=Math.cos(c),p=Math.sin(c);let t=s.data.length;w+=(t*(d*n-p*o)-u)*i,b+=(t*(p*n+d*o)-m)*i}else c+=y;c>a.PI?c-=a.PI2:c<-a.PI&&(c+=a.PI2),c*=i,d=Math.cos(c),p=Math.sin(c),s.a=d*n-p*o,s.b=d*r-p*l,s.c=p*n+d*o,s.d=p*r+d*l}s.updateAppliedTransform()}}computeWorldPositions(e,s,i){let n=this.target,a=this.position,r=this.spaces,o=l.setArraySize(this.positions,3*s+2),h=this.world,c=e.closed,d=e.worldVerticesLength,u=d/6,m=jt.NONE;if(!e.constantSpeed){let f=e.lengths;u-=c?1:2;let p,g=f[u];switch(this.data.positionMode==t.PositionMode.Percent&&(a*=g),this.data.spacingMode){case t.SpacingMode.Percent:p=g;break;case t.SpacingMode.Proportional:p=g/s;break;default:p=1}h=l.setArraySize(this.world,8);for(let t=0,l=0,x=0;t<s;t++,l+=3){let s=r[t]*p;a+=s;let w=a;if(c)w%=g,w<0&&(w+=g),x=0;else{if(w<0){m!=jt.BEFORE&&(m=jt.BEFORE,e.computeWorldVertices(n,2,4,h,0,2)),this.addBeforePosition(w,h,0,o,l);continue}if(w>g){m!=jt.AFTER&&(m=jt.AFTER,e.computeWorldVertices(n,d-6,4,h,0,2)),this.addAfterPosition(w-g,h,0,o,l);continue}}for(;;x++){let t=f[x];if(!(w>t)){if(0==x)w/=t;else{let e=f[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,c&&x==u?(e.computeWorldVertices(n,d-4,4,h,0,2),e.computeWorldVertices(n,0,4,h,4,2)):e.computeWorldVertices(n,6*x+2,8,h,0,2)),this.addCurvePosition(w,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],o,l,i||t>0&&0==s)}return o}c?(d+=2,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d-4,h,0,2),e.computeWorldVertices(n,0,2,h,d-4,2),h[d-2]=h[0],h[d-1]=h[1]):(u--,d-=4,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d,h,0,2));let f,p=l.setArraySize(this.curves,u),g=0,x=h[0],w=h[1],b=0,y=0,M=0,S=0,v=0,k=0,I=0,A=0,T=0,B=0,C=0,F=0,E=0,Y=0;for(let t=0,e=2;t<u;t++,e+=6)b=h[e],y=h[e+1],M=h[e+2],S=h[e+3],v=h[e+4],k=h[e+5],I=.1875*(x-2*b+M),A=.1875*(w-2*y+S),T=.09375*(3*(b-M)-x+v),B=.09375*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.75*(b-x)+I+.16666667*T,Y=.75*(y-w)+A+.16666667*B,g+=Math.sqrt(E*E+Y*Y),E+=C,Y+=F,C+=T,F+=B,g+=Math.sqrt(E*E+Y*Y),E+=C,Y+=F,g+=Math.sqrt(E*E+Y*Y),E+=C+T,Y+=F+B,g+=Math.sqrt(E*E+Y*Y),p[t]=g,x=v,w=k;switch(this.data.positionMode==t.PositionMode.Percent&&(a*=g),this.data.spacingMode){case t.SpacingMode.Percent:f=g;break;case t.SpacingMode.Proportional:f=g/s;break;default:f=1}let R=this.segments,P=0;for(let t=0,e=0,n=0,l=0;t<s;t++,e+=3){let s=r[t]*f;a+=s;let u=a;if(c)u%=g,u<0&&(u+=g),n=0;else{if(u<0){this.addBeforePosition(u,h,0,o,e);continue}if(u>g){this.addAfterPosition(u-g,h,d-4,o,e);continue}}for(;;n++){let t=p[n];if(!(u>t)){if(0==n)u/=t;else{let e=p[n-1];u=(u-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=h[t],w=h[t+1],b=h[t+2],y=h[t+3],M=h[t+4],S=h[t+5],v=h[t+6],k=h[t+7],I=.03*(x-2*b+M),A=.03*(w-2*y+S),T=.006*(3*(b-M)-x+v),B=.006*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.3*(b-x)+I+.16666667*T,Y=.3*(y-w)+A+.16666667*B,P=Math.sqrt(E*E+Y*Y),R[0]=P,t=1;t<8;t++)E+=C,Y+=F,C+=T,F+=B,P+=Math.sqrt(E*E+Y*Y),R[t]=P;E+=C,Y+=F,P+=Math.sqrt(E*E+Y*Y),R[8]=P,E+=C+T,Y+=F+B,P+=Math.sqrt(E*E+Y*Y),R[9]=P,l=0}for(u*=P;;l++){let t=R[l];if(!(u>t)){if(0==l)u/=t;else{let e=R[l-1];u=l+(u-e)/(t-e)}break}}this.addCurvePosition(.1*u,x,w,b,y,M,S,v,k,o,e,i||t>0&&0==s)}return o}addBeforePosition(t,e,s,i,n){let a=e[s],r=e[s+1],o=e[s+2]-a,l=e[s+3]-r,h=Math.atan2(l,o);i[n]=a+t*Math.cos(h),i[n+1]=r+t*Math.sin(h),i[n+2]=h}addAfterPosition(t,e,s,i,n){let a=e[s+2],r=e[s+3],o=a-e[s],l=r-e[s+1],h=Math.atan2(l,o);i[n]=a+t*Math.cos(h),i[n+1]=r+t*Math.sin(h),i[n+2]=h}addCurvePosition(t,e,s,i,n,a,r,o,l,h,c,d){if(0==t||isNaN(t))return h[c]=e,h[c+1]=s,void(h[c+2]=Math.atan2(n-s,i-e));let u=t*t,m=u*t,f=1-t,p=f*f,g=p*f,x=f*t,w=3*x,b=f*w,y=w*t,M=e*g+i*b+a*y+o*m,S=s*g+n*b+r*y+l*m;h[c]=M,h[c+1]=S,d&&(h[c+2]=t<.001?Math.atan2(n-s,i-e):Math.atan2(S-(s*p+n*x*2+r*u),M-(e*p+i*x*2+a*u)))}}class Ht{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],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}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){const t=this.data;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}isActive(){return this.active}update(e){const s=this.mix;if(0==s)return;const i=this.data.x>0,n=this.data.y>0,r=this.data.rotate>0||this.data.shearX>0,o=this.data.scaleX>0,l=this.bone,h=l.data.length;switch(e){case t.Physics.none:return;case t.Physics.reset:this.reset();case t.Physics.update:const e=this.skeleton,c=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=c,this.lastTime=e.time;const d=l.worldX,u=l.worldY;if(this._reset)this._reset=!1,this.ux=d,this.uy=u;else{let t=this.remaining,m=this.inertia,f=this.data.step,p=this.skeleton.data.referenceScale,g=-1,x=this.data.limit*c,w=x*Math.abs(e.scaleY);if(x*=Math.abs(e.scaleX),i||n){if(i){const t=(this.ux-d)*m;this.xOffset+=t>x?x:t<-x?-x:t,this.ux=d}if(n){const t=(this.uy-u)*m;this.yOffset+=t>w?w:t<-w?-w:t,this.uy=u}if(t>=f){g=Math.pow(this.damping,60*f);const e=this.massInverse*f,s=this.strength,a=this.wind*p,r=(Qt.yDown?-this.gravity:this.gravity)*p;do{i&&(this.xVelocity+=(a-this.xOffset*s)*e,this.xOffset+=this.xVelocity*f,this.xVelocity*=g),n&&(this.yVelocity-=(r+this.yOffset*s)*e,this.yOffset+=this.yVelocity*f,this.yVelocity*=g),t-=f}while(t>=f)}i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(r||o){let e=Math.atan2(l.c,l.a),i=0,n=0,c=0,d=this.cx-l.worldX,u=this.cy-l.worldY;if(d>x?d=x:d<-x&&(d=-x),u>w?u=w:u<-w&&(u=-w),r){c=(this.data.rotate+this.data.shearX)*s;let t=Math.atan2(u+this.ty,d+this.tx)-e-this.rotateOffset*c;this.rotateOffset+=(t-Math.ceil(t*a.invPI2-.5)*a.PI2)*m,t=this.rotateOffset*c+e,i=Math.cos(t),n=Math.sin(t),o&&(t=h*l.getWorldScaleX(),t>0&&(this.scaleOffset+=(d*i+u*n)*m/t))}else{i=Math.cos(e),n=Math.sin(e);const t=h*l.getWorldScaleX();t>0&&(this.scaleOffset+=(d*i+u*n)*m/t)}if(t=this.remaining,t>=f){-1==g&&(g=Math.pow(this.damping,60*f));const s=this.massInverse*f,a=this.strength,l=this.wind,d=Qt.yDown?-this.gravity:this.gravity,u=h/p;for(;;)if(t-=f,o&&(this.scaleVelocity+=(l*i-d*n-this.scaleOffset*a)*s,this.scaleOffset+=this.scaleVelocity*f,this.scaleVelocity*=g),r){if(this.rotateVelocity-=((l*n+d*i)*u+this.rotateOffset*a)*s,this.rotateOffset+=this.rotateVelocity*f,this.rotateVelocity*=g,t<f)break;const r=this.rotateOffset*c+e;i=Math.cos(r),n=Math.sin(r)}else if(t<f)break}}this.remaining=t}this.cx=l.worldX,this.cy=l.worldY;break;case t.Physics.pose:i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(r){let t=this.rotateOffset*s,e=0,i=0,n=0;if(this.data.shearX>0){let s=0;this.data.rotate>0&&(s=t*this.data.rotate,e=Math.sin(s),i=Math.cos(s),n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d),s+=t*this.data.shearX,e=Math.sin(s),i=Math.cos(s),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c}else t*=this.data.rotate,e=Math.sin(t),i=Math.cos(t),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c,n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d}if(o){const t=1+this.scaleOffset*s*this.data.scaleX;l.a*=t,l.c*=t}e!=t.Physics.pose&&(this.tx=h*l.a,this.ty=h*l.c),l.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,s){const i=s*a.degRad,n=Math.cos(i),r=Math.sin(i),o=this.cx-t,l=this.cy-e;this.translate(o*n-l*r-o,o*r+l*n-l)}}class Jt{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=new Array;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new n,this.darkColor=t.darkColor?new n:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(t instanceof u&&this.attachment instanceof u&&t.timelineAttachment==this.attachment.timelineAttachment||(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}}class Kt{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new c;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}.`);this.target=s,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}update(t){0==this.mixRotate&&0==this.mixX&&0==this.mixY&&0==this.mixScaleX&&0==this.mixScaleY&&0==this.mixShearY||(this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld())}applyAbsoluteWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?a.degRad:-a.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,r=Math.atan2(d,h)-Math.atan2(i,e)+f;r>a.PI?r-=a.PI2:r<-a.PI&&(r+=a.PI2),r*=t;let o=Math.cos(r),l=Math.sin(r);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=(t.x-x.worldX)*e,x.worldY+=(t.y-x.worldY)*s}if(0!=i){let t=Math.sqrt(x.a*x.a+x.c*x.c);0!=t&&(t=(t+(Math.sqrt(h*h+d*d)-t+this.data.offsetScaleX)*i)/t),x.a*=t,x.c*=t}if(0!=n){let t=Math.sqrt(x.b*x.b+x.d*x.d);0!=t&&(t=(t+(Math.sqrt(c*c+u*u)-t+this.data.offsetScaleY)*n)/t),x.b*=t,x.d*=t}if(r>0){let t=x.b,e=x.d,s=Math.atan2(e,t),i=Math.atan2(u,c)-Math.atan2(d,h)-(s-Math.atan2(x.c,x.a));i>a.PI?i-=a.PI2:i<-a.PI&&(i+=a.PI2),i=s+(i+p)*r;let n=Math.sqrt(t*t+e*e);x.b=Math.cos(i)*n,x.d=Math.sin(i)*n}x.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?a.degRad:-a.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,r=Math.atan2(d,h)+f;r>a.PI?r-=a.PI2:r<-a.PI&&(r+=a.PI2),r*=t;let o=Math.cos(r),l=Math.sin(r);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=t.x*e,x.worldY+=t.y*s}if(0!=i){let t=(Math.sqrt(h*h+d*d)-1+this.data.offsetScaleX)*i+1;x.a*=t,x.c*=t}if(0!=n){let t=(Math.sqrt(c*c+u*u)-1+this.data.offsetScaleY)*n+1;x.b*=t,x.d*=t}if(r>0){let t=Math.atan2(u,c)-Math.atan2(d,h);t>a.PI?t-=a.PI2:t<-a.PI&&(t+=a.PI2);let e=x.b,s=x.d;t=Math.atan2(s,e)+(t-a.PI/2+p)*r;let i=Math.sqrt(e*e+s*s);x.b=Math.cos(t)*i,x.d=Math.sin(t)*i}x.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,r=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation;0!=t&&(c+=(r.arotation-c+this.data.offsetRotation)*t);let d=h.ax,u=h.ay;d+=(r.ax-d+this.data.offsetX)*e,u+=(r.ay-u+this.data.offsetY)*s;let m=h.ascaleX,f=h.ascaleY;0!=i&&0!=m&&(m=(m+(r.ascaleX-m+this.data.offsetScaleX)*i)/m),0!=n&&0!=f&&(f=(f+(r.ascaleY-f+this.data.offsetScaleY)*n)/f);let p=h.ashearY;0!=a&&(p+=(r.ashearY-p+this.data.offsetShearY)*a),h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}applyRelativeLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,r=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation+(r.arotation+this.data.offsetRotation)*t,d=h.ax+(r.ax+this.data.offsetX)*e,u=h.ay+(r.ay+this.data.offsetY)*s,m=h.ascaleX*((r.ascaleX-1+this.data.offsetScaleX)*i+1),f=h.ascaleY*((r.ascaleY-1+this.data.offsetScaleY)*n+1),p=h.ashearY+(r.ashearY+this.data.offsetShearY)*a;h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}}class Qt{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;data;bones;slots;drawOrder;ikConstraints;transformConstraints;pathConstraints;physicsConstraints;_updateCache=new Array;skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return Qt.yDown?-this._scaleY:this._scaleY}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;constructor(t){if(!t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(i.parent){let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}else s=new Nt(i,this,null);this.bones.push(s)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],n=new Jt(s,i);this.slots.push(n),this.drawOrder.push(n)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new zt(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new Kt(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new jt(s,this))}this.physicsConstraints=new Array;for(let e=0;e<t.physicsConstraints.length;e++){let s=t.physicsConstraints[e];this.physicsConstraints.push(new Ht(s,this))}this.color=new n(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted=s.data.skinRequired,s.active=!s.sorted}if(this.skin){let t=this.skin.bones;for(let e=0,s=this.skin.bones.length;e<s;e++){let s=this.bones[t[e].index];do{s.sorted=!1,s.active=!0,s=s.parent}while(s)}}let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=this.physicsConstraints,a=e.length,r=s.length,o=i.length,l=this.physicsConstraints.length,h=a+r+o+l;t:for(let t=0;t<h;t++){for(let s=0;s<a;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<o;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}for(let e=0;e<l;e++){const s=n[e];if(s.data.order==t){this.sortPhysicsConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),1==s.length)this._updateCache.push(t),this.sortReset(i.children);else{let e=s[s.length-1];this.sortBone(e),this._updateCache.push(t),this.sortReset(i.children),e.sorted=!0}}sortPathConstraint(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target,s=e.data.index,i=e.bone;this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let n=e.getAttachment();n instanceof Xt&&this.sortPathConstraintAttachmentWith(n,i);let a=t.bones,r=a.length;for(let t=0;t<r;t++)this.sortBone(a[t]);this._updateCache.push(t);for(let t=0;t<r;t++)this.sortReset(a[t].children);for(let t=0;t<r;t++)a[t].sorted=!0}sortTransformConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this.sortBone(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof Xt))return;let s=t.bones;if(s){let t=this.bones;for(let e=0,i=s.length;e<i;){let i=s[e++];for(i+=e;e<i;)this.sortBone(t[s[e++]])}}else this.sortBone(e)}sortPhysicsConstraint(t){const e=t.bone;t.active=e.active&&(!t.data.skinRequired||null!=this.skin&&l.contains(this.skin.constraints,t.data,!0)),t.active&&(this.sortBone(e),this._updateCache.push(t),this.sortReset(e.children),e.sorted=!0)}sortBone(t){if(!t)return;if(t.sorted)return;let e=t.parent;e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.active&&(s.sorted&&this.sortReset(s.children),s.sorted=!1)}}updateWorldTransform(t){if(null==t)throw new Error("physics is undefined");let e=this.bones;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY}let s=this._updateCache;for(let e=0,i=s.length;e<i;e++)s[e].update(t)}updateWorldTransformWith(t,e){let s=this.getRootBone();if(!s)throw new Error("Root bone must not be null.");let i=e.a,n=e.b,r=e.c,o=e.d;s.worldX=i*this.x+n*this.y+e.worldX,s.worldY=r*this.x+o*this.y+e.worldY;const l=(s.rotation+s.shearX)*a.degRad,h=(s.rotation+90+s.shearY)*a.degRad,c=Math.cos(l)*s.scaleX,d=Math.cos(h)*s.scaleY,u=Math.sin(l)*s.scaleX,m=Math.sin(h)*s.scaleY;s.a=(i*c+n*u)*this.scaleX,s.b=(i*d+n*m)*this.scaleX,s.c=(r*c+o*u)*this.scaleY,s.d=(r*d+o*m)*this.scaleY;let f=this._updateCache;for(let e=0,i=f.length;e<i;e++){let i=f[e];i!=s&&i.update(t)}}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){for(const t of this.bones)t.setToSetupPose();for(const t of this.ikConstraints)t.setToSetupPose();for(const t of this.transformConstraints)t.setToSetupPose();for(const t of this.pathConstraints)t.setToSetupPose();for(const t of this.physicsConstraints)t.setToSetupPose()}setSlotsToSetupPose(){let t=this.slots;l.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}setSkinByName(t){let e=this.data.findSkin(t);if(!e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(t!=this.skin){if(t)if(this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],n=i.data.attachmentName;if(n){let e=t.getAttachment(s,n);e&&i.setAttachment(e)}}}this.skin=t,this.updateCache()}}getAttachmentByName(t,e){let s=this.data.findSlot(t);if(!s)throw new Error(`Can't find slot with name ${t}`);return this.getAttachment(s.index,e)}getAttachment(t,e){if(!e)throw new Error("attachmentName cannot be null.");if(this.skin){let s=this.skin.getAttachment(t,e);if(s)return s}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(!t)throw new Error("slotName cannot be null.");let s=this.slots;for(let i=0,n=s.length;i<n;i++){let n=s[i];if(n.data.name==t){let s=null;if(e&&(s=this.getAttachment(i,e),!s))throw new Error("Attachment not found: "+e+", for slot: "+t);return void n.setAttachment(s)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.ikConstraints.find((e=>e.data.name==t))??null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.transformConstraints.find((e=>e.data.name==t))??null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.pathConstraints.find((e=>e.data.name==t))??null}findPhysicsConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");return this.physicsConstraints.find((e=>e.data.name==t))??null}getBoundsRect(){let t=new c,e=new c;return this.getBounds(t,e),{x:t.x,y:t.y,width:e.x,height:e.y}}getBounds(t,e,s=new Array(2),i=null){if(!t)throw new Error("offset cannot be null.");if(!e)throw new Error("size cannot be null.");let n=this.drawOrder,a=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let t=0,e=n.length;t<e;t++){let e=n[t];if(!e.bone.active)continue;let c=0,d=null,u=null,m=e.getAttachment();if(m instanceof Vt)c=8,d=l.setArraySize(s,c,0),m.computeWorldVertices(e,d,0,2),u=Qt.quadTriangles;else if(m instanceof Pt){let t=m;c=t.worldVerticesLength,d=l.setArraySize(s,c,0),t.computeWorldVertices(e,0,c,d,0,2),u=t.triangles}else if(m instanceof wt&&null!=i){i.clipStart(e,m);continue}if(d&&u){null!=i&&i.isClipping()&&(i.clipTriangles(d,u,u.length),d=i.clippedVertices,c=i.clippedVertices.length);for(let t=0,e=d.length;t<e;t+=2){let e=d[t],s=d[t+1];a=Math.min(a,e),r=Math.min(r,s),o=Math.max(o,e),h=Math.max(h,s)}}null!=i&&i.clipEndWithSlot(e)}null!=i&&i.clipEnd(),t.set(a,r),e.set(o-a,h-r)}update(t){this.time+=t}physicsTranslate(t,e){const s=this.physicsConstraints;for(let i=0,n=s.length;i<n;i++)s[i].translate(t,e)}physicsRotate(t,e,s){const i=this.physicsConstraints;for(let n=0,a=i.length;n<a;n++)i[n].rotate(t,e,s)}}t.Physics=void 0,(At=t.Physics||(t.Physics={}))[At.none=0]="none",At[At.reset=1]="reset",At[At.update=2]="update",At[At.pose=3]="pose";class Zt extends Lt{_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;constructor(t){super(t,0,!1)}}class te{name=null;bones=new Array;slots=new Array;skins=new Array;defaultSkin=null;events=new Array;animations=new Array;ikConstraints=new Array;transformConstraints=new Array;pathConstraints=new Array;physicsConstraints=new Array;x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=0;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSkin(t){if(!t)throw new Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(!t)throw new Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(!t)throw new Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPhysicsConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.physicsConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}}class ee{slotIndex;name;attachment;constructor(t=0,e,s){this.slotIndex=t,this.name=e,this.attachment=s}}class se{name;attachments=new Array;bones=Array();constraints=new Array;color=new n(.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.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}addSkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];this.setAttachment(s.slotIndex,s.name,s.attachment)}}copySkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];s.attachment&&(s.attachment instanceof Pt?(s.attachment=s.attachment.newLinkedMesh(),this.setAttachment(s.slotIndex,s.name,s.attachment)):(s.attachment=s.attachment.copy(),this.setAttachment(s.slotIndex,s.name,s.attachment)))}}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){let s=this.attachments[t];s&&delete s[e]}getAttachments(){let t=new Array;for(var e=0;e<this.attachments.length;e++){let s=this.attachments[e];if(s)for(let i in s){let n=s[i];n&&t.push(new ee(e,i,n))}}return t}getAttachmentsForSlot(t,e){let s=this.attachments[t];if(s)for(let i in s){let n=s[i];n&&e.push(new ee(t,i,n))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let n=t.slots[i],a=n.getAttachment();if(a&&s<e.attachments.length){let t=e.attachments[s];for(let e in t){if(a==t[e]){let t=this.getAttachment(s,e);t&&n.setAttachment(t);break}}}s++}}}class ie{index=0;name;boneData;color=new n(1,1,1,1);darkColor=null;attachmentName=null;blendMode=t.BlendMode.Normal;visible=!0;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}t.BlendMode=void 0,(Tt=t.BlendMode||(t.BlendMode={}))[Tt.Normal=0]="Normal",Tt[Tt.Additive=1]="Additive",Tt[Tt.Multiply=2]="Multiply",Tt[Tt.Screen=3]="Screen";class ne extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;offsetRotation=0;offsetX=0;offsetY=0;offsetScaleX=0;offsetScaleY=0;offsetShearY=0;relative=!1;local=!1;constructor(t){super(t,0,!1)}}class ae{scale=1;attachmentLoader;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te;i.name="";let a=new re(e),r=a.readInt32(),o=a.readInt32();i.hash=0==o&&0==r?null:o.toString(16)+r.toString(16),i.version=a.readString(),i.x=a.readFloat(),i.y=a.readFloat(),i.width=a.readFloat(),i.height=a.readFloat(),i.referenceScale=a.readFloat()*s;let h=a.readBoolean();h&&(i.fps=a.readFloat(),i.imagesPath=a.readString(),i.audioPath=a.readString());let c=0;c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("String in string table must not be null.");a.strings.push(t)}c=a.readInt(!0);for(let t=0;t<c;t++){let e=a.readString();if(!e)throw new Error("Bone name must not be null.");let r=0==t?null:i.bones[a.readInt(!0)],o=new Ot(t,e,r);o.rotation=a.readFloat(),o.x=a.readFloat()*s,o.y=a.readFloat()*s,o.scaleX=a.readFloat(),o.scaleY=a.readFloat(),o.shearX=a.readFloat(),o.shearY=a.readFloat(),o.length=a.readFloat()*s,o.inherit=a.readByte(),o.skinRequired=a.readBoolean(),h&&(n.rgba8888ToColor(o.color,a.readInt32()),o.icon=a.readString()??void 0,o.visible=a.readBoolean()),i.bones.push(o)}c=a.readInt(!0);for(let t=0;t<c;t++){let e=a.readString();if(!e)throw new Error("Slot name must not be null.");let s=i.bones[a.readInt(!0)],r=new ie(t,e,s);n.rgba8888ToColor(r.color,a.readInt32());let o=a.readInt32();-1!=o&&n.rgb888ToColor(r.darkColor=new n,o),r.attachmentName=a.readStringRef(),r.blendMode=a.readInt(!0),h&&(r.visible=a.readBoolean()),i.slots.push(r)}c=a.readInt(!0);for(let t,e=0;e<c;e++){let e=a.readString();if(!e)throw new Error("IK constraint data name must not be null.");let n=new Gt(e);n.order=a.readInt(!0),t=a.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[a.readInt(!0)]);n.target=i.bones[a.readInt(!0)];let r=a.readByte();n.skinRequired=!!(1&r),n.bendDirection=2&r?1:-1,n.compress=!!(4&r),n.stretch=!!(8&r),n.uniform=!!(16&r),32&r&&(n.mix=64&r?a.readFloat():1),128&r&&(n.softness=a.readFloat()*s),i.ikConstraints.push(n)}c=a.readInt(!0);for(let t,e=0;e<c;e++){let e=a.readString();if(!e)throw new Error("Transform constraint data name must not be null.");let n=new ne(e);n.order=a.readInt(!0),t=a.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[a.readInt(!0)]);n.target=i.bones[a.readInt(!0)];let r=a.readByte();n.skinRequired=!!(1&r),n.local=!!(2&r),n.relative=!!(4&r),8&r&&(n.offsetRotation=a.readFloat()),16&r&&(n.offsetX=a.readFloat()*s),32&r&&(n.offsetY=a.readFloat()*s),64&r&&(n.offsetScaleX=a.readFloat()),128&r&&(n.offsetScaleY=a.readFloat()),r=a.readByte(),1&r&&(n.offsetShearY=a.readFloat()),2&r&&(n.mixRotate=a.readFloat()),4&r&&(n.mixX=a.readFloat()),8&r&&(n.mixY=a.readFloat()),16&r&&(n.mixScaleX=a.readFloat()),32&r&&(n.mixScaleY=a.readFloat()),64&r&&(n.mixShearY=a.readFloat()),i.transformConstraints.push(n)}c=a.readInt(!0);for(let e,n=0;n<c;n++){let n=a.readString();if(!n)throw new Error("Path constraint data name must not be null.");let r=new $t(n);r.order=a.readInt(!0),r.skinRequired=a.readBoolean(),e=a.readInt(!0);for(let t=0;t<e;t++)r.bones.push(i.bones[a.readInt(!0)]);r.target=i.slots[a.readInt(!0)];const o=a.readByte();r.positionMode=1&o,r.spacingMode=o>>1&3,r.rotateMode=o>>3&3,128&o&&(r.offsetRotation=a.readFloat()),r.position=a.readFloat(),r.positionMode==t.PositionMode.Fixed&&(r.position*=s),r.spacing=a.readFloat(),r.spacingMode!=t.SpacingMode.Length&&r.spacingMode!=t.SpacingMode.Fixed||(r.spacing*=s),r.mixRotate=a.readFloat(),r.mixX=a.readFloat(),r.mixY=a.readFloat(),i.pathConstraints.push(r)}c=a.readInt(!0);for(let t=0;t<c;t++){const t=a.readString();if(!t)throw new Error("Physics constraint data name must not be null.");const e=new Zt(t);e.order=a.readInt(!0),e.bone=i.bones[a.readInt(!0)];let n=a.readByte();e.skinRequired=!!(1&n),2&n&&(e.x=a.readFloat()),4&n&&(e.y=a.readFloat()),8&n&&(e.rotate=a.readFloat()),16&n&&(e.scaleX=a.readFloat()),32&n&&(e.shearX=a.readFloat()),e.limit=(64&n?a.readFloat():5e3)*s,e.step=1/a.readUnsignedByte(),e.inertia=a.readFloat(),e.strength=a.readFloat(),e.damping=a.readFloat(),e.massInverse=128&n?a.readFloat():1,e.wind=a.readFloat(),e.gravity=a.readFloat(),n=a.readByte(),1&n&&(e.inertiaGlobal=!0),2&n&&(e.strengthGlobal=!0),4&n&&(e.dampingGlobal=!0),8&n&&(e.massGlobal=!0),16&n&&(e.windGlobal=!0),32&n&&(e.gravityGlobal=!0),64&n&&(e.mixGlobal=!0),e.mix=128&n?a.readFloat():1,i.physicsConstraints.push(e)}let d=this.readSkin(a,i,!0,h);d&&(i.defaultSkin=d,i.skins.push(d));{let t=i.skins.length;for(l.setArraySize(i.skins,c=t+a.readInt(!0));t<c;t++){let e=this.readSkin(a,i,!1,h);if(!e)throw new Error("readSkin() should not have returned null.");i.skins[t]=e}}c=this.linkedMeshes.length;for(let t=0;t<c;t++){let e=this.linkedMeshes[t];const s=i.skins[e.skinIndex];if(!e.parent)throw new Error("Linked mesh parent must not be null");let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}this.linkedMeshes.length=0,c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("Event data name must not be null");let e=new Wt(t);e.intValue=a.readInt(!1),e.floatValue=a.readFloat(),e.stringValue=a.readString(),e.audioPath=a.readString(),e.audioPath&&(e.volume=a.readFloat(),e.balance=a.readFloat()),i.events.push(e)}c=a.readInt(!0);for(let t=0;t<c;t++){let t=a.readString();if(!t)throw new Error("Animatio name must not be null.");i.animations.push(this.readAnimation(a,t,i))}return i}readSkin(t,e,s,i){let a=null,r=0;if(s){if(r=t.readInt(!0),0==r)return null;a=new se("default")}else{let s=t.readString();if(!s)throw new Error("Skin name must not be null.");a=new se(s),i&&n.rgba8888ToColor(a.color,t.readInt32()),a.bones.length=t.readInt(!0);for(let s=0,i=a.bones.length;s<i;s++)a.bones[s]=e.bones[t.readInt(!0)];for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.ikConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.transformConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.pathConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.physicsConstraints[t.readInt(!0)]);r=t.readInt(!0)}for(let s=0;s<r;s++){let s=t.readInt(!0);for(let n=0,r=t.readInt(!0);n<r;n++){let n=t.readStringRef();if(!n)throw new Error("Attachment name must not be null");let r=this.readAttachment(t,e,a,s,n,i);r&&a.setAttachment(s,n,r)}}return a}readAttachment(t,e,s,i,a,r){let o=this.scale,h=t.readByte();const c=8&h?t.readStringRef():a;if(!c)throw new Error("Attachment name must not be null");switch(7&h){case Bt.Region:{let e=16&h?t.readStringRef():null;const i=32&h?t.readInt32():4294967295,a=64&h?this.readSequence(t):null;let r=128&h?t.readFloat():0,l=t.readFloat(),d=t.readFloat(),u=t.readFloat(),m=t.readFloat(),f=t.readFloat(),p=t.readFloat();e||(e=c);let g=this.attachmentLoader.newRegionAttachment(s,c,e,a);return g?(g.path=e,g.x=l*o,g.y=d*o,g.scaleX=u,g.scaleY=m,g.rotation=r,g.width=f*o,g.height=p*o,n.rgba8888ToColor(g.color,i),g.sequence=a,null==a&&g.updateRegion(),g):null}case Bt.BoundingBox:{let e=this.readVertices(t,!!(16&h)),i=r?t.readInt32():0,a=this.attachmentLoader.newBoundingBoxAttachment(s,c);return a?(a.worldVerticesLength=e.length,a.vertices=e.vertices,a.bones=e.bones,r&&n.rgba8888ToColor(a.color,i),a):null}case Bt.Mesh:{let e=16&h?t.readStringRef():c;const i=32&h?t.readInt32():4294967295,a=64&h?this.readSequence(t):null,l=t.readInt(!0),d=this.readVertices(t,!!(128&h)),u=this.readFloatArray(t,d.length,1),m=this.readShortArray(t,3*(d.length-l-2));let f=[],p=0,g=0;r&&(f=this.readShortArray(t,t.readInt(!0)),p=t.readFloat(),g=t.readFloat()),e||(e=c);let x=this.attachmentLoader.newMeshAttachment(s,c,e,a);return x?(x.path=e,n.rgba8888ToColor(x.color,i),x.bones=d.bones,x.vertices=d.vertices,x.worldVerticesLength=d.length,x.triangles=m,x.regionUVs=u,null==a&&x.updateRegion(),x.hullLength=l<<1,x.sequence=a,r&&(x.edges=f,x.width=p*o,x.height=g*o),x):null}case Bt.LinkedMesh:{const e=16&h?t.readStringRef():c;if(null==e)throw new Error("Path of linked mesh must not be null");const a=32&h?t.readInt32():4294967295,l=64&h?this.readSequence(t):null,d=!!(128&h),u=t.readInt(!0),m=t.readStringRef();let f=0,p=0;r&&(f=t.readFloat(),p=t.readFloat());let g=this.attachmentLoader.newMeshAttachment(s,c,e,l);return g?(g.path=e,n.rgba8888ToColor(g.color,a),g.sequence=l,r&&(g.width=f*o,g.height=p*o),this.linkedMeshes.push(new oe(g,u,i,m,d)),g):null}case Bt.Path:{const e=!!(16&h),i=!!(32&h),a=this.readVertices(t,!!(64&h)),d=l.newArray(a.length/6,0);for(let e=0,s=d.length;e<s;e++)d[e]=t.readFloat()*o;const u=r?t.readInt32():0,m=this.attachmentLoader.newPathAttachment(s,c);return m?(m.closed=e,m.constantSpeed=i,m.worldVerticesLength=a.length,m.vertices=a.vertices,m.bones=a.bones,m.lengths=d,r&&n.rgba8888ToColor(m.color,u),m):null}case Bt.Point:{const e=t.readFloat(),i=t.readFloat(),a=t.readFloat(),l=r?t.readInt32():0,h=this.attachmentLoader.newPointAttachment(s,c);return h?(h.x=i*o,h.y=a*o,h.rotation=e,r&&n.rgba8888ToColor(h.color,l),h):null}case Bt.Clipping:{const i=t.readInt(!0),a=this.readVertices(t,!!(16&h));let o=r?t.readInt32():0,l=this.attachmentLoader.newClippingAttachment(s,c);return l?(l.endSlot=e.slots[i],l.worldVerticesLength=a.length,l.vertices=a.vertices,l.bones=a.bones,r&&n.rgba8888ToColor(l.color,o),l):null}}return null}readSequence(t){let e=new m(t.readInt(!0));return e.start=t.readInt(!0),e.digits=t.readInt(!0),e.setupIndex=t.readInt(!0),e}readVertices(t,e){const s=this.scale,i=t.readInt(!0),n=new le;if(n.length=i<<1,!e)return n.vertices=this.readFloatArray(t,n.length,s),n;let a=new Array,r=new Array;for(let e=0;e<i;e++){let e=t.readInt(!0);r.push(e);for(let i=0;i<e;i++)r.push(t.readInt(!0)),a.push(t.readFloat()*s),a.push(t.readFloat()*s),a.push(t.readFloat())}return n.vertices=l.toFloatArray(a),n.bones=r,n}readFloatArray(t,e,s){let i=new Array(e);if(1==s)for(let s=0;s<e;s++)i[s]=t.readFloat();else for(let n=0;n<e;n++)i[n]=t.readFloat()*s;return i}readShortArray(t,e){let s=new Array(e);for(let i=0;i<e;i++)s[i]=t.readInt(!0);return s}readAnimation(e,s,i){e.readInt(!0);let n=new Array,a=this.scale;for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0),a=i-1;switch(s){case ve:{let s=new N(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readStringRef());n.push(s);break}case ke:{let s=e.readInt(!0),r=new X(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,u,1),de(e,r,s++,t,3,o,i,d,m,1)}o=i,l=n,h=a,c=u,d=m}n.push(r);break}case Ie:{let s=e.readInt(!0),r=new _(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,d,1)}o=i,l=n,h=a,c=d}n.push(r);break}case Ae:{let s=e.readInt(!0),r=new D(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d,u,m,f),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255,w=e.readUnsignedByte()/255,b=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,p,1),de(e,r,s++,t,3,o,i,d,g,1),de(e,r,s++,t,4,o,i,u,x,1),de(e,r,s++,t,5,o,i,m,w,1),de(e,r,s++,t,6,o,i,f,b,1)}o=i,l=n,h=a,c=p,d=g,u=x,m=w,f=b}n.push(r);break}case Te:{let s=e.readInt(!0),r=new O(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;for(let t=0,s=0;r.setFrame(t,o,l,h,c,d,u,m),t!=a;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,a=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255;switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,o,i,l,n,1),de(e,r,s++,t,1,o,i,h,a,1),de(e,r,s++,t,2,o,i,c,f,1),de(e,r,s++,t,3,o,i,d,p,1),de(e,r,s++,t,4,o,i,u,g,1),de(e,r,s++,t,5,o,i,m,x,1)}o=i,l=n,h=a,c=f,d=p,u=g,m=x}n.push(r);break}case Be:{let s=new V(i,e.readInt(!0),t),r=e.readFloat(),o=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,r,o),t!=a;t++){let n=e.readFloat(),a=e.readUnsignedByte()/255;switch(e.readByte()){case qe:s.setStepped(t);break;case Ue:de(e,s,i++,t,0,r,n,o,a,1)}r=n,o=a}n.push(s)}}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0);if(s==Se){let s=new P(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readByte());n.push(s);continue}let r=e.readInt(!0);switch(s){case ue:n.push(he(e,new k(i,r,t),1));break;case me:n.push(ce(e,new I(i,r,t),a));break;case fe:n.push(he(e,new A(i,r,t),a));break;case pe:n.push(he(e,new T(i,r,t),a));break;case ge:n.push(ce(e,new B(i,r,t),1));break;case xe:n.push(he(e,new C(i,r,t),1));break;case we:n.push(he(e,new F(i,r,t),1));break;case be:n.push(ce(e,new E(i,r,t),1));break;case ye:n.push(he(e,new Y(i,r,t),1));break;case Me:n.push(he(e,new R(i,r,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,r=new W(s,e.readInt(!0),t),o=e.readByte(),l=e.readFloat(),h=1&o?2&o?e.readFloat():1:0,c=4&o?e.readFloat()*a:0;for(let t=0,s=0;r.setFrame(t,l,h,c,8&o?1:-1,!!(16&o),!!(32&o)),t!=i;t++){o=e.readByte();const i=e.readFloat(),n=1&o?2&o?e.readFloat():1:0,d=4&o?e.readFloat()*a:0;64&o?r.setStepped(t):128&o&&(de(e,r,s++,t,0,l,i,h,n,1),de(e,r,s++,t,1,l,i,c,d,a)),l=i,h=n,c=d}n.push(r)}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,a=new z(s,e.readInt(!0),t),r=e.readFloat(),o=e.readFloat(),l=e.readFloat(),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0;a.setFrame(t,r,o,l,h,c,d,u),t!=i;t++){let i=e.readFloat(),n=e.readFloat(),m=e.readFloat(),f=e.readFloat(),p=e.readFloat(),g=e.readFloat(),x=e.readFloat();switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,r,i,o,n,1),de(e,a,s++,t,1,r,i,l,m,1),de(e,a,s++,t,2,r,i,h,f,1),de(e,a,s++,t,3,r,i,c,p,1),de(e,a,s++,t,4,r,i,d,g,1),de(e,a,s++,t,5,r,i,u,x,1)}r=i,o=n,l=m,h=f,c=p,d=g,u=x}n.push(a)}for(let s=0,r=e.readInt(!0);s<r;s++){let s=e.readInt(!0),r=i.pathConstraints[s];for(let i=0,o=e.readInt(!0);i<o;i++){const i=e.readByte(),o=e.readInt(!0),l=e.readInt(!0);switch(i){case Ee:n.push(he(e,new G(o,l,s),r.positionMode==t.PositionMode.Fixed?a:1));break;case Ye:n.push(he(e,new $(o,l,s),r.spacingMode==t.SpacingMode.Length||r.spacingMode==t.SpacingMode.Fixed?a:1));break;case Re:let i=new j(o,l,s),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0,n=i.getFrameCount()-1;i.setFrame(t,h,c,d,u),t!=n;t++){let n=e.readFloat(),a=e.readFloat(),r=e.readFloat(),o=e.readFloat();switch(e.readByte()){case qe:i.setStepped(t);break;case Ue:de(e,i,s++,t,0,h,n,c,a,1),de(e,i,s++,t,1,h,n,d,r,1),de(e,i,s++,t,2,h,n,u,o,1)}h=n,c=a,d=r,u=o}n.push(i)}}}for(let t=0,s=e.readInt(!0);t<s;t++){const t=e.readInt(!0)-1;for(let s=0,i=e.readInt(!0);s<i;s++){const s=e.readByte(),i=e.readInt(!0);if(s==Le){const s=new it(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat());n.push(s);continue}const a=e.readInt(!0);switch(s){case Pe:n.push(he(e,new J(i,a,t),1));break;case Xe:n.push(he(e,new K(i,a,t),1));break;case _e:n.push(he(e,new Q(i,a,t),1));break;case Ve:n.push(he(e,new Z(i,a,t),1));break;case De:n.push(he(e,new tt(i,a,t),1));break;case Oe:n.push(he(e,new et(i,a,t),1));break;case Ne:n.push(he(e,new st(i,a,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=i.skins[e.readInt(!0)];for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readInt(!0);for(let i=0,r=e.readInt(!0);i<r;i++){let i=e.readStringRef();if(!i)throw new Error("attachmentName must not be null.");let r=t.getAttachment(s,i),o=e.readByte(),h=e.readInt(!0),c=h-1;switch(o){case Ce:{let t=r,i=t.bones,o=t.vertices,d=i?o.length/3*2:o.length,u=e.readInt(!0),m=new L(h,u,s,t),f=e.readFloat();for(let t=0,s=0;;t++){let n,r=e.readInt(!0);if(0==r)n=i?l.newFloatArray(d):o;else{n=l.newFloatArray(d);let t=e.readInt(!0);if(r+=t,1==a)for(let s=t;s<r;s++)n[s]=e.readFloat();else for(let s=t;s<r;s++)n[s]=e.readFloat()*a;if(!i)for(let t=0,e=n.length;t<e;t++)n[t]+=o[t]}if(m.setFrame(t,f,n),t==c)break;let h=e.readFloat();switch(e.readByte()){case qe:m.setStepped(t);break;case Ue:de(e,m,s++,t,0,f,h,0,1,1)}f=h}n.push(m);break}case Fe:{let t=new nt(h,s,r);for(let s=0;s<h;s++){let i=e.readFloat(),n=e.readInt32();t.setFrame(s,i,p[15&n],n>>4,e.readFloat())}n.push(t);break}}}}}let r=e.readInt(!0);if(r>0){let t=new U(r),s=i.slots.length;for(let i=0;i<r;i++){let n=e.readFloat(),a=e.readInt(!0),r=l.newArray(s,0);for(let t=s-1;t>=0;t--)r[t]=-1;let o=l.newArray(s-a,0),h=0,c=0;for(let t=0;t<a;t++){let t=e.readInt(!0);for(;h!=t;)o[c++]=h++;r[h+e.readInt(!0)]=h++}for(;h<s;)o[c++]=h++;for(let t=s-1;t>=0;t--)-1==r[t]&&(r[t]=o[--c]);t.setFrame(i,n,r)}n.push(t)}let o=e.readInt(!0);if(o>0){let t=new q(o);for(let s=0;s<o;s++){let n=e.readFloat(),a=i.events[e.readInt(!0)],r=new Ut(n,a);r.intValue=e.readInt(!1),r.floatValue=e.readFloat(),r.stringValue=e.readString(),null==r.stringValue&&(r.stringValue=a.stringValue),r.data.audioPath&&(r.volume=e.readFloat(),r.balance=e.readFloat()),t.setFrame(s,r)}n.push(t)}let h=0;for(let t=0,e=n.length;t<e;t++)h=Math.max(h,n[t].getDuration());return new g(s,n,h)}}class re{strings;index;buffer;constructor(t,e=new Array,s=0,i=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=i}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){let t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){let t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=127&e;return 128&e&&(e=this.readByte(),s|=(127&e)<<7,128&e&&(e=this.readByte(),s|=(127&e)<<14,128&e&&(e=this.readByte(),s|=(127&e)<<21,128&e&&(e=this.readByte(),s|=(127&e)<<28)))),t?s:s>>>1^-(1&s)}readStringRef(){let t=this.readInt(!0);return 0==t?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;){let t=this.readUnsignedByte();switch(t>>4){case 12:case 13:e+=String.fromCharCode((31&t)<<6|63&this.readByte()),s+=2;break;case 14:e+=String.fromCharCode((15&t)<<12|(63&this.readByte())<<6|63&this.readByte()),s+=3;break;default:e+=String.fromCharCode(t),s++}}return e}readFloat(){let t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return 0!=this.readByte()}}class oe{parent;skinIndex;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}class le{bones;vertices;length;constructor(t=null,e=null,s=0){this.bones=t,this.vertices=e,this.length=s}}function he(t,e,s){let i=t.readFloat(),n=t.readFloat()*s;for(let a=0,r=0,o=e.getFrameCount()-1;e.setFrame(a,i,n),a!=o;a++){let o=t.readFloat(),l=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(a);break;case Ue:de(t,e,r++,a,0,i,o,n,l,s)}i=o,n=l}return e}function ce(t,e,s){let i=t.readFloat(),n=t.readFloat()*s,a=t.readFloat()*s;for(let r=0,o=0,l=e.getFrameCount()-1;e.setFrame(r,i,n,a),r!=l;r++){let l=t.readFloat(),h=t.readFloat()*s,c=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(r);break;case Ue:de(t,e,o++,r,0,i,l,n,h,s),de(t,e,o++,r,1,i,l,a,c,s)}i=l,n=h,a=c}return e}function de(t,e,s,i,n,a,r,o,l,h){e.setBezier(s,i,n,a,o,t.readFloat(),t.readFloat()*h,t.readFloat(),t.readFloat()*h,r,l)}!function(t){t[t.Region=0]="Region",t[t.BoundingBox=1]="BoundingBox",t[t.Mesh=2]="Mesh",t[t.LinkedMesh=3]="LinkedMesh",t[t.Path=4]="Path",t[t.Point=5]="Point",t[t.Clipping=6]="Clipping"}(Bt||(Bt={}));const ue=0,me=1,fe=2,pe=3,ge=4,xe=5,we=6,be=7,ye=8,Me=9,Se=10,ve=0,ke=1,Ie=2,Ae=3,Te=4,Be=5,Ce=0,Fe=1,Ee=0,Ye=1,Re=2,Pe=0,Xe=1,_e=2,Ve=4,De=5,Oe=6,Ne=7,Le=8,qe=1,Ue=2;class We{convexPolygons=new Array;convexPolygonsIndices=new Array;indicesArray=new Array;isConcaveArray=new Array;triangles=new Array;polygonPool=new h((()=>new Array));polygonIndicesPool=new h((()=>new Array));triangulate(t){let e=t,s=t.length>>1,i=this.indicesArray;i.length=0;for(let t=0;t<s;t++)i[t]=t;let n=this.isConcaveArray;n.length=0;for(let t=0,a=s;t<a;++t)n[t]=We.isConcave(t,s,e,i);let a=this.triangles;for(a.length=0;s>3;){let t=s-1,r=0,o=1;for(;;){t:if(!n[r]){let a=i[t]<<1,l=i[r]<<1,h=i[o]<<1,c=e[a],d=e[a+1],u=e[l],m=e[l+1],f=e[h],p=e[h+1];for(let a=(o+1)%s;a!=t;a=(a+1)%s){if(!n[a])continue;let t=i[a]<<1,s=e[t],r=e[t+1];if(We.positiveArea(f,p,c,d,s,r)&&We.positiveArea(c,d,u,m,s,r)&&We.positiveArea(u,m,f,p,s,r))break t}break}if(0==o){do{if(!n[r])break;r--}while(r>0);break}t=r,r=o,o=(o+1)%s}a.push(i[(s+r-1)%s]),a.push(i[r]),a.push(i[(r+1)%s]),i.splice(r,1),n.splice(r,1),s--;let l=(s+r-1)%s,h=r==s?0:r;n[l]=We.isConcave(l,s,e,i),n[h]=We.isConcave(h,s,e,i)}return 3==s&&(a.push(i[2]),a.push(i[0]),a.push(i[1])),a}decompose(t,e){let s=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;let n=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(n),n.length=0;let a=this.polygonIndicesPool.obtain();a.length=0;let r=this.polygonPool.obtain();r.length=0;let o=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,c=e[t+1]<<1,d=e[t+2]<<1,u=s[h],m=s[h+1],f=s[c],p=s[c+1],g=s[d],x=s[d+1],w=!1;if(o==h){let t=r.length-4,e=We.winding(r[t],r[t+1],r[t+2],r[t+3],g,x),s=We.winding(g,x,r[0],r[1],r[2],r[3]);e==l&&s==l&&(r.push(g),r.push(x),a.push(d),w=!0)}w||(r.length>0?(i.push(r),n.push(a)):(this.polygonPool.free(r),this.polygonIndicesPool.free(a)),r=this.polygonPool.obtain(),r.length=0,r.push(u),r.push(m),r.push(f),r.push(p),r.push(g),r.push(x),a=this.polygonIndicesPool.obtain(),a.length=0,a.push(h),a.push(c),a.push(d),l=We.winding(u,m,f,p,g,x),o=h)}r.length>0&&(i.push(r),n.push(a));for(let t=0,e=i.length;t<e;t++){if(a=n[t],0==a.length)continue;let s=a[0],o=a[a.length-1];r=i[t];let l=r.length-4,h=r[l],c=r[l+1],d=r[l+2],u=r[l+3],m=r[0],f=r[1],p=r[2],g=r[3],x=We.winding(h,c,d,u,m,f);for(let l=0;l<e;l++){if(l==t)continue;let e=n[l];if(3!=e.length)continue;let w=e[0],b=e[1],y=e[2],M=i[l],S=M[M.length-2],v=M[M.length-1];if(w!=s||b!=o)continue;let k=We.winding(h,c,d,u,S,v),I=We.winding(S,v,m,f,p,g);k==x&&I==x&&(M.length=0,e.length=0,r.push(S),r.push(v),a.push(y),h=d,c=u,d=S,u=v,l=0)}}for(let t=i.length-1;t>=0;t--)r=i[t],0==r.length&&(i.splice(t,1),this.polygonPool.free(r),a=n[t],n.splice(t,1),this.polygonIndicesPool.free(a));return i}static isConcave(t,e,s,i){let n=i[(e+t-1)%e]<<1,a=i[t]<<1,r=i[(t+1)%e]<<1;return!this.positiveArea(s[n],s[n+1],s[a],s[a+1],s[r],s[r+1])}static positiveArea(t,e,s,i,n,a){return t*(a-i)+s*(e-a)+n*(i-e)>=0}static winding(t,e,s,i,n,a){let r=s-t,o=i-e;return n*o-a*r+r*e-t*o>=0?1:-1}}class ze{triangulator=new We;clippingPolygon=new Array;clipOutput=new Array;clippedVertices=new Array;clippedUVs=new Array;clippedTriangles=new Array;scratch=new Array;clipAttachment=null;clippingPolygons=null;clipStart(t,e){if(this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=l.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ze.makeClockwise(n);let a=this.clippingPolygons=this.triangulator.decompose(n,this.triangulator.triangulate(n));for(let t=0,e=a.length;t<e;t++){let e=a[t];ze.makeClockwise(e),e.push(e[0]),e.push(e[1])}return a.length}clipEndWithSlot(t){this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,n,a,r,o){let l,h,c,d,u,m;"number"==typeof e?(l=s,h=i,c=n,d=a,u=r,m=o):(l=e,h=s,c=i,d=n,u=a,m=r),c&&d&&u&&"boolean"==typeof m?this.clipTrianglesRender(t,l,h,c,d,u,m):this.clipTrianglesNoRender(t,l,h)}clipTrianglesNoRender(t,e,s){let i=this.clipOutput,n=this.clippedVertices,a=this.clippedTriangles,r=this.clippingPolygons,o=r.length,h=0;n.length=0,a.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,d=t[s],u=t[s+1];s=e[c+1]<<1;let m=t[s],f=t[s+1];s=e[c+2]<<1;let p=t[s],g=t[s+1];for(let t=0;t<o;t++){let e=n.length;if(!this.clip(d,u,m,f,p,g,r[t],i)){let t=l.setArraySize(n,e+6);t[e]=d,t[e+1]=u,t[e+2]=m,t[e+3]=f,t[e+4]=p,t[e+5]=g,e=a.length;let s=l.setArraySize(a,e+3);s[e]=h,s[e+1]=h+1,s[e+2]=h+2,h+=3;break}{let t=i.length;if(0==t)continue;let s=t>>1,r=this.clipOutput,o=l.setArraySize(n,e+2*s);for(let s=0;s<t;s+=2,e+=2){let t=r[s],i=r[s+1];o[e]=t,o[e+1]=i}e=a.length;let c=l.setArraySize(a,e+3*(s-2));s--;for(let t=1;t<s;t++,e+=3)c[e]=h,c[e+1]=h+t,c[e+2]=h+t+1;h+=s+1}}}}clipTrianglesRender(t,e,s,i,n,a,r){let o=this.clipOutput,h=this.clippedVertices,c=this.clippedTriangles,d=this.clippingPolygons,u=d.length,m=r?12:8,f=0;h.length=0,c.length=0;for(let p=0;p<s;p+=3){let s=e[p]<<1,g=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[p+1]<<1;let y=t[s],M=t[s+1],S=i[s],v=i[s+1];s=e[p+2]<<1;let k=t[s],I=t[s+1],A=i[s],T=i[s+1];for(let t=0;t<u;t++){let e=h.length;if(!this.clip(g,x,y,M,k,I,d[t],o)){let t=l.setArraySize(h,e+3*m);t[e]=g,t[e+1]=x,t[e+2]=n.r,t[e+3]=n.g,t[e+4]=n.b,t[e+5]=n.a,r?(t[e+6]=w,t[e+7]=b,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=y,t[e+13]=M,t[e+14]=n.r,t[e+15]=n.g,t[e+16]=n.b,t[e+17]=n.a,t[e+18]=S,t[e+19]=v,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=k,t[e+25]=I,t[e+26]=n.r,t[e+27]=n.g,t[e+28]=n.b,t[e+29]=n.a,t[e+30]=A,t[e+31]=T,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=w,t[e+7]=b,t[e+8]=y,t[e+9]=M,t[e+10]=n.r,t[e+11]=n.g,t[e+12]=n.b,t[e+13]=n.a,t[e+14]=S,t[e+15]=v,t[e+16]=k,t[e+17]=I,t[e+18]=n.r,t[e+19]=n.g,t[e+20]=n.b,t[e+21]=n.a,t[e+22]=A,t[e+23]=T),e=c.length;let s=l.setArraySize(c,e+3);s[e]=f,s[e+1]=f+1,s[e+2]=f+2,f+=3;break}{let t=o.length;if(0==t)continue;let s=M-I,i=k-y,d=g-k,u=I-x,p=1/(s*d+i*(x-I)),B=t>>1,C=this.clipOutput,F=l.setArraySize(h,e+B*m);for(let o=0;o<t;o+=2,e+=m){let t=C[o],l=C[o+1];F[e]=t,F[e+1]=l,F[e+2]=n.r,F[e+3]=n.g,F[e+4]=n.b,F[e+5]=n.a;let h=t-k,c=l-I,m=(s*h+i*c)*p,f=(u*h+d*c)*p,g=1-m-f;F[e+6]=w*m+S*f+A*g,F[e+7]=b*m+v*f+T*g,r&&(F[e+8]=a.r,F[e+9]=a.g,F[e+10]=a.b,F[e+11]=a.a)}e=c.length;let E=l.setArraySize(c,e+3*(B-2));B--;for(let t=1;t<B;t++,e+=3)E[e]=f,E[e+1]=f+t,E[e+2]=f+t+1;f+=B+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,a=this.clippedVertices,r=this.clippedUVs,o=this.clippedTriangles,h=this.clippingPolygons,c=h.length,d=0;a.length=0,r.length=0,o.length=0;for(let u=0;u<s;u+=3){let s=e[u]<<1,m=t[s],f=t[s+1],p=i[s],g=i[s+1];s=e[u+1]<<1;let x=t[s],w=t[s+1],b=i[s],y=i[s+1];s=e[u+2]<<1;let M=t[s],S=t[s+1],v=i[s],k=i[s+1];for(let t=0;t<c;t++){let e=a.length;if(!this.clip(m,f,x,w,M,S,h[t],n)){let t=l.setArraySize(a,e+6);t[e]=m,t[e+1]=f,t[e+2]=x,t[e+3]=w,t[e+4]=M,t[e+5]=S;let s=l.setArraySize(r,e+6);s[e]=p,s[e+1]=g,s[e+2]=b,s[e+3]=y,s[e+4]=v,s[e+5]=k,e=o.length;let i=l.setArraySize(o,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}{let t=n.length;if(0==t)continue;let s=w-S,i=M-x,h=m-M,c=S-f,u=1/(s*h+i*(f-S)),I=t>>1,A=this.clipOutput,T=l.setArraySize(a,e+2*I),B=l.setArraySize(r,e+2*I);for(let n=0;n<t;n+=2,e+=2){let t=A[n],a=A[n+1];T[e]=t,T[e+1]=a;let r=t-M,o=a-S,l=(s*r+i*o)*u,d=(c*r+h*o)*u,m=1-l-d;B[e]=p*l+b*d+v*m,B[e+1]=g*l+y*d+k*m}e=o.length;let C=l.setArraySize(o,e+3*(I-2));I--;for(let t=1;t<I;t++,e+=3)C[e]=d,C[e+1]=d+t,C[e+2]=d+t+1;d+=I+1}}}}clip(t,e,s,i,n,a,r,o){let l,h=o,c=!1;r.length%4>=2?(l=o,o=this.scratch):l=this.scratch,l.length=0,l.push(t),l.push(e),l.push(s),l.push(i),l.push(n),l.push(a),l.push(t),l.push(e),o.length=0;let d=r.length-4,u=r;for(let t=0;;t+=2){let e=u[t],s=u[t+1],i=e-u[t+2],n=s-u[t+3],a=o.length,r=l;for(let t=0,a=l.length-2;t<a;){let a=r[t],l=r[t+1];t+=2;let h=r[t],d=r[t+1],u=n*(e-h)>i*(s-d),m=n*(e-a)-i*(s-l);if(m>0){if(u){o.push(h),o.push(d);continue}let t=h-a,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(a+t*s),o.push(l+e*s)}else if(u){let t=h-a,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(a+t*s),o.push(l+e*s),o.push(h),o.push(d)}c=!0}if(a==o.length)return h.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==d)break;let m=o;(o=l).length=0,l=m}if(h!=o){h.length=0;for(let t=0,e=o.length-2;t<e;t++)h[t]=o[t]}else h.length=h.length-2;return c}static makeClockwise(t){let e=t,s=t.length,i=e[s-2]*e[1]-e[0]*e[s-1],n=0,a=0,r=0,o=0;for(let t=0,l=s-3;t<l;t+=2)n=e[t],a=e[t+1],r=e[t+2],o=e[t+3],i+=n*o-r*a;if(!(i<0))for(let t=0,i=s-2,n=s>>1;t<n;t+=2){let s=e[t],n=e[t+1],a=i-t;e[t]=e[a],e[t+1]=e[a+1],e[a]=s,e[a+1]=n}}}class Ge{attachmentLoader;scale=1;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te,a="string"==typeof e?JSON.parse(e):e,r=a.skeleton;if(r&&(i.hash=r.hash,i.version=r.spine,i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height,i.referenceScale=Ke(r,"referenceScale",100)*s,i.fps=r.fps,i.imagesPath=r.images??null,i.audioPath=r.audio??null),a.bones)for(let e=0;e<a.bones.length;e++){let n=a.bones[e],r=null,o=Ke(n,"parent",null);o&&(r=i.findBone(o));let h=new Ot(i.bones.length,n.name,r);h.length=Ke(n,"length",0)*s,h.x=Ke(n,"x",0)*s,h.y=Ke(n,"y",0)*s,h.rotation=Ke(n,"rotation",0),h.scaleX=Ke(n,"scaleX",1),h.scaleY=Ke(n,"scaleY",1),h.shearX=Ke(n,"shearX",0),h.shearY=Ke(n,"shearY",0),h.inherit=l.enumValue(t.Inherit,Ke(n,"inherit","Normal")),h.skinRequired=Ke(n,"skin",!1);let c=Ke(n,"color",null);c&&h.color.setFromString(c),i.bones.push(h)}if(a.slots)for(let e=0;e<a.slots.length;e++){let s=a.slots[e],r=s.name,o=i.findBone(s.bone);if(!o)throw new Error(`Couldn't find bone ${s.bone} for slot ${r}`);let h=new ie(i.slots.length,r,o),c=Ke(s,"color",null);c&&h.color.setFromString(c);let d=Ke(s,"dark",null);d&&(h.darkColor=n.fromString(d)),h.attachmentName=Ke(s,"attachment",null),h.blendMode=l.enumValue(t.BlendMode,Ke(s,"blend","normal")),h.visible=Ke(s,"visible",!0),i.slots.push(h)}if(a.ik)for(let t=0;t<a.ik.length;t++){let e=a.ik[t],n=new Gt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=i.findBone(e.bones[t]);if(!s)throw new Error(`Couldn't find bone ${e.bones[t]} for IK constraint ${e.name}.`);n.bones.push(s)}let r=i.findBone(e.target);if(!r)throw new Error(`Couldn't find target bone ${e.target} for IK constraint ${e.name}.`);n.target=r,n.mix=Ke(e,"mix",1),n.softness=Ke(e,"softness",0)*s,n.bendDirection=Ke(e,"bendPositive",!0)?1:-1,n.compress=Ke(e,"compress",!1),n.stretch=Ke(e,"stretch",!1),n.uniform=Ke(e,"uniform",!1),i.ikConstraints.push(n)}if(a.transform)for(let t=0;t<a.transform.length;t++){let e=a.transform[t],n=new ne(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=e.bones[t],a=i.findBone(s);if(!a)throw new Error(`Couldn't find bone ${s} for transform constraint ${e.name}.`);n.bones.push(a)}let r=e.target,o=i.findBone(r);if(!o)throw new Error(`Couldn't find target bone ${r} for transform constraint ${e.name}.`);n.target=o,n.local=Ke(e,"local",!1),n.relative=Ke(e,"relative",!1),n.offsetRotation=Ke(e,"rotation",0),n.offsetX=Ke(e,"x",0)*s,n.offsetY=Ke(e,"y",0)*s,n.offsetScaleX=Ke(e,"scaleX",0),n.offsetScaleY=Ke(e,"scaleY",0),n.offsetShearY=Ke(e,"shearY",0),n.mixRotate=Ke(e,"mixRotate",1),n.mixX=Ke(e,"mixX",1),n.mixY=Ke(e,"mixY",n.mixX),n.mixScaleX=Ke(e,"mixScaleX",1),n.mixScaleY=Ke(e,"mixScaleY",n.mixScaleX),n.mixShearY=Ke(e,"mixShearY",1),i.transformConstraints.push(n)}if(a.path)for(let e=0;e<a.path.length;e++){let n=a.path[e],r=new $t(n.name);r.order=Ke(n,"order",0),r.skinRequired=Ke(n,"skin",!1);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],s=i.findBone(e);if(!s)throw new Error(`Couldn't find bone ${e} for path constraint ${n.name}.`);r.bones.push(s)}let o=n.target,h=i.findSlot(o);if(!h)throw new Error(`Couldn't find target slot ${o} for path constraint ${n.name}.`);r.target=h,r.positionMode=l.enumValue(t.PositionMode,Ke(n,"positionMode","Percent")),r.spacingMode=l.enumValue(t.SpacingMode,Ke(n,"spacingMode","Length")),r.rotateMode=l.enumValue(t.RotateMode,Ke(n,"rotateMode","Tangent")),r.offsetRotation=Ke(n,"rotation",0),r.position=Ke(n,"position",0),r.positionMode==t.PositionMode.Fixed&&(r.position*=s),r.spacing=Ke(n,"spacing",0),r.spacingMode!=t.SpacingMode.Length&&r.spacingMode!=t.SpacingMode.Fixed||(r.spacing*=s),r.mixRotate=Ke(n,"mixRotate",1),r.mixX=Ke(n,"mixX",1),r.mixY=Ke(n,"mixY",r.mixX),i.pathConstraints.push(r)}if(a.physics)for(let t=0;t<a.physics.length;t++){const e=a.physics[t],n=new Zt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);const r=e.bone,o=i.findBone(r);if(null==o)throw new Error("Physics bone not found: "+r);n.bone=o,n.x=Ke(e,"x",0),n.y=Ke(e,"y",0),n.rotate=Ke(e,"rotate",0),n.scaleX=Ke(e,"scaleX",0),n.shearX=Ke(e,"shearX",0),n.limit=Ke(e,"limit",5e3)*s,n.step=1/Ke(e,"fps",60),n.inertia=Ke(e,"inertia",1),n.strength=Ke(e,"strength",100),n.damping=Ke(e,"damping",1),n.massInverse=1/Ke(e,"mass",1),n.wind=Ke(e,"wind",0),n.gravity=Ke(e,"gravity",0),n.mix=Ke(e,"mix",1),n.inertiaGlobal=Ke(e,"inertiaGlobal",!1),n.strengthGlobal=Ke(e,"strengthGlobal",!1),n.dampingGlobal=Ke(e,"dampingGlobal",!1),n.massGlobal=Ke(e,"massGlobal",!1),n.windGlobal=Ke(e,"windGlobal",!1),n.gravityGlobal=Ke(e,"gravityGlobal",!1),n.mixGlobal=Ke(e,"mixGlobal",!1),i.physicsConstraints.push(n)}if(a.skins)for(let t=0;t<a.skins.length;t++){let e=a.skins[t],s=new se(e.name);if(e.bones)for(let t=0;t<e.bones.length;t++){let n=e.bones[t],a=i.findBone(n);if(!a)throw new Error(`Couldn't find bone ${n} for skin ${e.name}.`);s.bones.push(a)}if(e.ik)for(let t=0;t<e.ik.length;t++){let n=e.ik[t],a=i.findIkConstraint(n);if(!a)throw new Error(`Couldn't find IK constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.transform)for(let t=0;t<e.transform.length;t++){let n=e.transform[t],a=i.findTransformConstraint(n);if(!a)throw new Error(`Couldn't find transform constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.path)for(let t=0;t<e.path.length;t++){let n=e.path[t],a=i.findPathConstraint(n);if(!a)throw new Error(`Couldn't find path constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}if(e.physics)for(let t=0;t<e.physics.length;t++){let n=e.physics[t],a=i.findPhysicsConstraint(n);if(!a)throw new Error(`Couldn't find physics constraint ${n} for skin ${e.name}.`);s.constraints.push(a)}for(let t in e.attachments){let n=i.findSlot(t);if(!n)throw new Error(`Couldn't find slot ${t} for skin ${e.name}.`);let a=e.attachments[t];for(let t in a){let e=this.readAttachment(a[t],s,n.index,t,i);e&&s.setAttachment(n.index,t,e)}}i.skins.push(s),"default"==s.name&&(i.defaultSkin=s)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],s=e.skin?i.findSkin(e.skin):i.defaultSkin;if(!s)throw new Error(`Skin not found: ${e.skin}`);let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}if(this.linkedMeshes.length=0,a.events)for(let t in a.events){let e=a.events[t],s=new Wt(t);s.intValue=Ke(e,"int",0),s.floatValue=Ke(e,"float",0),s.stringValue=Ke(e,"string",""),s.audioPath=Ke(e,"audio",null),s.audioPath&&(s.volume=Ke(e,"volume",1),s.balance=Ke(e,"balance",0)),i.events.push(s)}if(a.animations)for(let t in a.animations){let e=a.animations[t];this.readAnimation(e,t,i)}return i}readAttachment(t,e,s,i,n){let a=this.scale;switch(i=Ke(t,"name",i),Ke(t,"type","region")){case"region":{let s=Ke(t,"path",i),n=this.readSequence(Ke(t,"sequence",null)),r=this.attachmentLoader.newRegionAttachment(e,i,s,n);if(!r)return null;r.path=s,r.x=Ke(t,"x",0)*a,r.y=Ke(t,"y",0)*a,r.scaleX=Ke(t,"scaleX",1),r.scaleY=Ke(t,"scaleY",1),r.rotation=Ke(t,"rotation",0),r.width=t.width*a,r.height=t.height*a,r.sequence=n;let o=Ke(t,"color",null);return o&&r.color.setFromString(o),null!=r.region&&r.updateRegion(),r}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(!s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=Ke(t,"path",i),r=this.readSequence(Ke(t,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(e,i,n,r);if(!o)return null;o.path=n;let l=Ke(t,"color",null);l&&o.color.setFromString(l),o.width=Ke(t,"width",0)*a,o.height=Ke(t,"height",0)*a,o.sequence=r;let h=Ke(t,"parent",null);if(h)return this.linkedMeshes.push(new $e(o,Ke(t,"skin",null),s,h,Ke(t,"timelines",!0))),o;let c=t.uvs;return this.readVertices(t,o,c.length),o.triangles=t.triangles,o.regionUVs=c,null!=o.region&&o.updateRegion(),o.edges=Ke(t,"edges",null),o.hullLength=2*Ke(t,"hull",0),o}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(!s)return null;s.closed=Ke(t,"closed",!1),s.constantSpeed=Ke(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let r=l.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)r[e]=t.lengths[e]*a;s.lengths=r;let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(!s)return null;s.x=Ke(t,"x",0)*a,s.y=Ke(t,"y",0)*a,s.rotation=Ke(t,"rotation",0);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(!s)return null;let a=Ke(t,"end",null);a&&(s.endSlot=n.findSlot(a));let r=t.vertexCount;this.readVertices(t,s,r<<1);let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}}return null}readSequence(t){if(null==t)return null;let e=new m(Ke(t,"count",0));return e.start=Ke(t,"start",1),e.digits=Ke(t,"digits",0),e.setupIndex=Ke(t,"setup",0),e}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=l.toFloatArray(n);if(1!=i)for(let e=0,s=n.length;e<s;e++)t[e]*=i;return void(e.vertices=t)}let a=new Array,r=new Array;for(let t=0,e=n.length;t<e;){let e=n[t++];r.push(e);for(let s=t+4*e;t<s;t+=4)r.push(n[t]),a.push(n[t+1]*i),a.push(n[t+2]*i),a.push(n[t+3])}e.bones=r,e.vertices=l.toFloatArray(a)}readAnimation(e,s,i){let a=this.scale,r=new Array;if(e.slots)for(let t in e.slots){let s=e.slots[t],a=i.findSlot(t);if(!a)throw new Error("Slot not found: "+t);let o=a.index;for(let t in s){let e=s[t];if(!e)continue;let i=e.length;if("attachment"==t){let t=new N(i,o);for(let s=0;s<i;s++){let i=e[s];t.setFrame(s,Ke(i,"time",0),Ke(i,"name",null))}r.push(t)}else if("rgba"==t){let t=new X(i,i<<2,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a);let o=e[i+1];if(!o){t.shrink(r);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(r=Je(d,t,r,i,0,a,h,l.r,c.r,1),r=Je(d,t,r,i,1,a,h,l.g,c.g,1),r=Je(d,t,r,i,2,a,h,l.b,c.b,1),r=Je(d,t,r,i,3,a,h,l.a,c.a,1)),a=h,l=c,s=o}r.push(t)}else if("rgb"==t){let t=new _(i,3*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b);let o=e[i+1];if(!o){t.shrink(r);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(r=Je(d,t,r,i,0,a,h,l.r,c.r,1),r=Je(d,t,r,i,1,a,h,l.g,c.g,1),r=Je(d,t,r,i,2,a,h,l.b,c.b,1)),a=h,l=c,s=o}r.push(t)}else if("alpha"==t)r.push(je(e,new V(i,i,o),0,1));else if("rgba2"==t){let t=new D(i,7*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(r);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(r=Je(m,t,r,i,0,a,c,l.r,d.r,1),r=Je(m,t,r,i,1,a,c,l.g,d.g,1),r=Je(m,t,r,i,2,a,c,l.b,d.b,1),r=Je(m,t,r,i,3,a,c,l.a,d.a,1),r=Je(m,t,r,i,4,a,c,h.r,u.r,1),r=Je(m,t,r,i,5,a,c,h.g,u.g,1),r=Je(m,t,r,i,6,a,c,h.b,u.b,1)),a=c,l=d,h=u,s=o}r.push(t)}else if("rgb2"==t){let t=new O(i,6*i,o),s=e[0],a=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(r);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(r=Je(m,t,r,i,0,a,c,l.r,d.r,1),r=Je(m,t,r,i,1,a,c,l.g,d.g,1),r=Je(m,t,r,i,2,a,c,l.b,d.b,1),r=Je(m,t,r,i,3,a,c,h.r,u.r,1),r=Je(m,t,r,i,4,a,c,h.g,u.g,1),r=Je(m,t,r,i,5,a,c,h.b,u.b,1)),a=c,l=d,h=u,s=o}r.push(t)}}}if(e.bones)for(let s in e.bones){let n=e.bones[s],o=i.findBone(s);if(!o)throw new Error("Bone not found: "+s);let h=o.index;for(let e in n){let s=n[e],i=s.length;if(0!=i)if("rotate"===e)r.push(je(s,new k(i,i,h),0,1));else if("translate"===e){let t=new I(i,i<<1,h);r.push(He(s,t,"x","y",0,a))}else if("translatex"===e){let t=new A(i,i,h);r.push(je(s,t,0,a))}else if("translatey"===e){let t=new T(i,i,h);r.push(je(s,t,0,a))}else if("scale"===e){let t=new B(i,i<<1,h);r.push(He(s,t,"x","y",1,1))}else if("scalex"===e){let t=new C(i,i,h);r.push(je(s,t,1,1))}else if("scaley"===e){let t=new F(i,i,h);r.push(je(s,t,1,1))}else if("shear"===e){let t=new E(i,i<<1,h);r.push(He(s,t,"x","y",0,1))}else if("shearx"===e){let t=new Y(i,i,h);r.push(je(s,t,0,1))}else if("sheary"===e){let t=new R(i,i,h);r.push(je(s,t,0,1))}else if("inherit"===e){let e=new P(i,o.index);for(let i=0;i<s.length;i++){let n=s[i];e.setFrame(i,Ke(n,"time",0),l.enumValue(t.Inherit,Ke(n,"inherit","Normal")))}r.push(e)}}}if(e.ik)for(let t in e.ik){let s=e.ik[t],n=s[0];if(!n)continue;let o=i.findIkConstraint(t);if(!o)throw new Error("IK Constraint not found: "+t);let l=i.ikConstraints.indexOf(o),h=new W(s.length,s.length<<1,l),c=Ke(n,"time",0),d=Ke(n,"mix",1),u=Ke(n,"softness",0)*a;for(let t=0,e=0;;t++){h.setFrame(t,c,d,u,Ke(n,"bendPositive",!0)?1:-1,Ke(n,"compress",!1),Ke(n,"stretch",!1));let i=s[t+1];if(!i){h.shrink(e);break}let r=Ke(i,"time",0),o=Ke(i,"mix",1),l=Ke(i,"softness",0)*a,m=n.curve;m&&(e=Je(m,h,e,t,0,c,r,d,o,1),e=Je(m,h,e,t,1,c,r,u,l,a)),c=r,d=o,u=l,n=i}r.push(h)}if(e.transform)for(let t in e.transform){let s=e.transform[t],n=s[0];if(!n)continue;let a=i.findTransformConstraint(t);if(!a)throw new Error("Transform constraint not found: "+t);let o=i.transformConstraints.indexOf(a),l=new z(s.length,6*s.length,o),h=Ke(n,"time",0),c=Ke(n,"mixRotate",1),d=Ke(n,"mixX",1),u=Ke(n,"mixY",d),m=Ke(n,"mixScaleX",1),f=Ke(n,"mixScaleY",m),p=Ke(n,"mixShearY",1);for(let t=0,e=0;;t++){l.setFrame(t,h,c,d,u,m,f,p);let i=s[t+1];if(!i){l.shrink(e);break}let a=Ke(i,"time",0),r=Ke(i,"mixRotate",1),o=Ke(i,"mixX",1),g=Ke(i,"mixY",o),x=Ke(i,"mixScaleX",1),w=Ke(i,"mixScaleY",x),b=Ke(i,"mixShearY",1),y=n.curve;y&&(e=Je(y,l,e,t,0,h,a,c,r,1),e=Je(y,l,e,t,1,h,a,d,o,1),e=Je(y,l,e,t,2,h,a,u,g,1),e=Je(y,l,e,t,3,h,a,m,x,1),e=Je(y,l,e,t,4,h,a,f,w,1),e=Je(y,l,e,t,5,h,a,p,b,1)),h=a,c=r,d=o,u=g,m=x,f=w,m=x,n=i}r.push(l)}if(e.path)for(let s in e.path){let n=e.path[s],o=i.findPathConstraint(s);if(!o)throw new Error("Path constraint not found: "+s);let l=i.pathConstraints.indexOf(o);for(let e in n){let s=n[e],i=s[0];if(!i)continue;let h=s.length;if("position"===e){let e=new G(h,h,l);r.push(je(s,e,0,o.positionMode==t.PositionMode.Fixed?a:1))}else if("spacing"===e){let e=new $(h,h,l);r.push(je(s,e,0,o.spacingMode==t.SpacingMode.Length||o.spacingMode==t.SpacingMode.Fixed?a:1))}else if("mix"===e){let t=new j(h,3*h,l),e=Ke(i,"time",0),n=Ke(i,"mixRotate",1),a=Ke(i,"mixX",1),o=Ke(i,"mixY",a);for(let r=0,l=0;;r++){t.setFrame(r,e,n,a,o);let h=s[r+1];if(!h){t.shrink(l);break}let c=Ke(h,"time",0),d=Ke(h,"mixRotate",1),u=Ke(h,"mixX",1),m=Ke(h,"mixY",u),f=i.curve;f&&(l=Je(f,t,l,r,0,e,c,n,d,1),l=Je(f,t,l,r,1,e,c,a,u,1),l=Je(f,t,l,r,2,e,c,o,m,1)),e=c,n=d,a=u,o=m,i=h}r.push(t)}}}if(e.physics)for(let t in e.physics){let s=e.physics[t],n=-1;if(t.length>0){let e=i.findPhysicsConstraint(t);if(!e)throw new Error("Physics constraint not found: "+t);n=i.physicsConstraints.indexOf(e)}for(let t in s){let e=s[t],i=e[0];if(!i)continue;let a,o=e.length;if("reset"!=t){if("inertia"==t)a=new J(o,o,n);else if("strength"==t)a=new K(o,o,n);else if("damping"==t)a=new Q(o,o,n);else if("mass"==t)a=new Z(o,o,n);else if("wind"==t)a=new tt(o,o,n);else if("gravity"==t)a=new et(o,o,n);else{if("mix"!=t)continue;a=new st(o,o,n)}r.push(je(e,a,0,1))}else{const t=new it(o,n);for(let s=0;null!=i;i=e[s+1],s++)t.setFrame(s,Ke(i,"time",0));r.push(t)}}}if(e.attachments)for(let t in e.attachments){let s=e.attachments[t],n=i.findSkin(t);if(!n)throw new Error("Skin not found: "+t);for(let t in s){let e=s[t],o=i.findSlot(t);if(!o)throw new Error("Slot not found: "+t);let h=o.index;for(let t in e){let s=e[t],i=n.getAttachment(h,t);for(let t in s){let e=s[t],n=e[0];if(n)if("deform"==t){let t=i.bones,s=i.vertices,o=t?s.length/3*2:s.length,c=new L(e.length,e.length,h,i),d=Ke(n,"time",0);for(let i=0,r=0;;i++){let h,u=Ke(n,"vertices",null);if(u){h=l.newFloatArray(o);let e=Ke(n,"offset",0);if(l.arrayCopy(u,0,h,e,u.length),1!=a)for(let t=e,s=t+u.length;t<s;t++)h[t]*=a;if(!t)for(let t=0;t<o;t++)h[t]+=s[t]}else h=t?l.newFloatArray(o):s;c.setFrame(i,d,h);let m=e[i+1];if(!m){c.shrink(r);break}let f=Ke(m,"time",0),p=n.curve;p&&(r=Je(p,c,r,i,0,d,f,0,1,1)),d=f,n=m}r.push(c)}else if("sequence"==t){let t=new nt(e.length,h,i),s=0;for(let i=0;i<e.length;i++){let a=Ke(n,"delay",s),r=Ke(n,"time",0),o=f[Ke(n,"mode","hold")],l=Ke(n,"index",0);t.setFrame(i,r,o,l,a),s=a,n=e[i+1]}r.push(t)}}}}}if(e.drawOrder){let t=new U(e.drawOrder.length),s=i.slots.length,n=0;for(let a=0;a<e.drawOrder.length;a++,n++){let r=e.drawOrder[a],o=null,h=Ke(r,"offsets",null);if(h){o=l.newArray(s,-1);let t=l.newArray(s-h.length,0),e=0,n=0;for(let s=0;s<h.length;s++){let a=h[s],r=i.findSlot(a.slot);if(!r)throw new Error("Slot not found: "+r);let l=r.index;for(;e!=l;)t[n++]=e++;o[e+a.offset]=e++}for(;e<s;)t[n++]=e++;for(let e=s-1;e>=0;e--)-1==o[e]&&(o[e]=t[--n])}t.setFrame(n,Ke(r,"time",0),o)}r.push(t)}if(e.events){let t=new q(e.events.length),s=0;for(let n=0;n<e.events.length;n++,s++){let a=e.events[n],r=i.findEvent(a.name);if(!r)throw new Error("Event not found: "+a.name);let o=new Ut(l.toSinglePrecision(Ke(a,"time",0)),r);o.intValue=Ke(a,"int",r.intValue),o.floatValue=Ke(a,"float",r.floatValue),o.stringValue=Ke(a,"string",r.stringValue),o.data.audioPath&&(o.volume=Ke(a,"volume",1),o.balance=Ke(a,"balance",0)),t.setFrame(s,o)}r.push(t)}let o=0;for(let t=0,e=r.length;t<e;t++)o=Math.max(o,r[t].getDuration());i.animations.push(new g(s,r,o))}}class $e{parent;skin;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}function je(t,e,s,i){let n=t[0],a=Ke(n,"time",0),r=Ke(n,"value",s)*i,o=0;for(let l=0;;l++){e.setFrame(l,a,r);let h=t[l+1];if(!h)return e.shrink(o),e;let c=Ke(h,"time",0),d=Ke(h,"value",s)*i;n.curve&&(o=Je(n.curve,e,o,l,0,a,c,r,d,i)),a=c,r=d,n=h}}function He(t,e,s,i,n,a){let r=t[0],o=Ke(r,"time",0),l=Ke(r,s,n)*a,h=Ke(r,i,n)*a,c=0;for(let d=0;;d++){e.setFrame(d,o,l,h);let u=t[d+1];if(!u)return e.shrink(c),e;let m=Ke(u,"time",0),f=Ke(u,s,n)*a,p=Ke(u,i,n)*a,g=r.curve;g&&(c=Je(g,e,c,d,0,o,m,l,f,a),c=Je(g,e,c,d,1,o,m,h,p,a)),o=m,l=f,h=p,r=u}}function Je(t,e,s,i,n,a,r,o,l,h){if("stepped"==t)return e.setStepped(i),s;let c=n<<2,d=t[c],u=t[c+1]*h,m=t[c+2],f=t[c+3]*h;return e.setBezier(s,i,n,a,o,d,u,m,f,r,l),s+1}function Ke(t,e,s){return void 0!==t[e]?t[e]:s}var Qe;function Ze(t,e,s){const i=new Dt(t);return"json"===s?new Ge(i).readSkeletonData(e):new ae(i).readSkeletonData(new Uint8Array(e))}async function ts(t,s,i){let n;const a=t.map(((t,n)=>{const a=s[n];let r=e.AssetType.Texture2D;return"ktx"===a?r=e.AssetType.KTX:"ktx2"===a&&(r=e.AssetType.KTX2),is(t,i,r)}));try{n=await Promise.all(a)}catch(t){throw t}return n}async function es(t,s){const i=function(t){const e=new URL(t),s=e.origin+e.pathname;return s.endsWith("/")?s:s.substring(0,s.lastIndexOf("/")+1)}(t);let n,a;try{n=await e.request(t,{type:"text"})}catch(e){throw new Error(`Spine Atlas: ${t} load error: ${e}`)}let r=new Ft(n);const o=[];for(let t of r.pages){const e=i+t.name;o.push(is(e,s))}try{a=await Promise.all(o)}catch(t){throw new Error(`Spine Texture: load error: ${t}`)}return r=ss(n,a),r}function ss(t,e){const s=new Ft(t);return s.pages.forEach(((t,s)=>{const i=function(t){return new ns(new Image,t)}(e.find((e=>e.name===t.name))||e[s]);t.setTexture(i)})),s}function is(t,s,i=e.AssetType.Texture2D){return s.resourceManager.load({url:t,type:i})}void 0===Math.fround&&(Math.fround=(Qe=new Float32Array(1),function(t){return Qe[0]=t,Qe[0]}));class ns extends bt{constructor(t,e){super(t),this.texture=e,this.texture.generateMipmaps()}getImage(){return this.texture}setFilters(s,i){s===t.TextureFilter.Nearest?this.texture.filterMode=e.TextureFilterMode.Point:i===t.TextureFilter.MipMapLinearLinear?this.texture.filterMode=e.TextureFilterMode.Trilinear:this.texture.filterMode=e.TextureFilterMode.Bilinear}setWraps(t,e){this.texture.wrapModeU=this._convertWrapMode(t),this.texture.wrapModeV=this._convertWrapMode(e)}dispose(){}_convertWrapMode(s){switch(s){case t.TextureWrap.ClampToEdge:return e.TextureWrapMode.Clamp;case t.TextureWrap.Repeat:return e.TextureWrapMode.Repeat;case t.TextureWrap.MirroredRepeat:return e.TextureWrapMode.Mirror;default:throw new Error("Unsupported texture wrap mode.")}}}class as{constructor(t,e=1){this._type=t,this._lastElementIndex=e-1;const s=this._elements=new Array(e);for(let i=0;i<e;++i)s[i]=new t}get(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]}return(t){this._elements[++this._lastElementIndex]=t}}class rs{constructor(t){this._usedElementCount=0,this._type=t,this._elements=[]}get(){const{_usedElementCount:t,_elements:e}=this;if(this._usedElementCount++,e.length===t){const t=new this._type;return e.push(t),t}return e[t]}clear(){this._usedElementCount=0}}const{SourceAlpha:os,One:ls,DestinationColor:hs,Zero:cs,OneMinusSourceColor:ds,OneMinusSourceAlpha:us}=e.BlendFactor,{Add:ms}=e.BlendOperation;function fs(e,s){const i=e.renderState.blendState.targetBlendState;switch(s){case t.BlendMode.Additive:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=ls,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ls,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Multiply:i.sourceColorBlendFactor=hs,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Screen:i.sourceColorBlendFactor=ls,i.destinationColorBlendFactor=ds,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ds,i.colorBlendOperation=i.alphaBlendOperation=ms;break;default:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms}}class ps{}const gs=1/0,xs=-1/0;class ws{static{this.QUAD_TRIANGLES=[0,1,2,2,3,0]}static{this.VERTEX_SIZE=8}static{this.VERTEX_STRIDE=9}static{this.tempDark=new n}static{this.tempColor=new n}static{this.tempVerts=new Array(8)}static{this.tempBlendMode=null}static{this.tempTexture=null}static{this.subPrimitivePool=new as(e.SubPrimitive)}static{this.subRenderItemPool=new rs(ps)}static{this.bounds=new e.BoundingBox(new e.Vector3(gs,gs,gs),new e.Vector3(xs,xs,xs))}getMaxVertexCount(t){const e=new Set,{skins:s}=t,i=s.length;for(let t=0;t<i;t++){const i=s[t];this._collectUniqueAttachments(i,e)}return this._calculateTotalVertexCount(e)}buildPrimitive(e,s){const{useClipping:i=!0,zSpacing:n=.01}=s.setting,{_clipper:a,_separateSlots:r,_subRenderItems:o,_separateSlotTextureMap:l}=this,{bounds:h}=ws;h.min.set(gs,gs,gs),h.max.set(xs,xs,xs);let c=0,d=0;const u=e.drawOrder,m=u.length,{engine:f,_indices:p,_vertices:g,_subPrimitives:x}=s;let{tempVerts:w,tempTexture:b,tempBlendMode:y,subRenderItemPool:M,subPrimitivePool:S}=ws;o.length=0,M.clear();let v,k,I=s._vertices,A=0,T=0,B=t.BlendMode.Normal,C=null,F=0;ws.tempBlendMode=null,ws.tempTexture=null;for(let t=0;t<m;++t){const e=u[t];if(!e.bone.active){a.clipEndWithSlot(e);continue}const s=e.getAttachment();let h=null;const m=n*t;let f=0;const E=a.isClipping();let Y=E?2:ws.VERTEX_SIZE;if(s){switch(s.constructor){case Vt:const t=s;h=t.color,f=4*Y,t.computeWorldVertices(e,w,0,Y),v=ws.QUAD_TRIANGLES,k=t.uvs,C=t.region.texture;break;case Pt:const n=s;h=n.color,f=(n.worldVerticesLength>>1)*Y,f>I.length&&(ws.tempVerts=new Array(f)),n.computeWorldVertices(e,0,n.worldVerticesLength,w,0,Y),v=n.triangles,k=n.uvs,C=n.region.texture;break;case wt:if(i){let t=s;a.clipStart(e,t)}continue;default:i&&a.clipEndWithSlot(e);continue}if(null!=C){let t,s,i,n,u=e.bone.skeleton.color,I=e.color,R=u.a*I.a*h.a,P=ws.tempColor,X=ws.tempDark;if(P.set(u.r*I.r*h.r,u.g*I.g*h.g,u.b*I.b*h.b,R),E)a.clipTriangles(w,v,v.length,k,P,X,!1),t=a.clippedVertices,s=t.length,i=a.clippedTriangles,n=i.length;else{let e=w;const{r:a,g:r,b:o,a:l}=P;for(let t=2,s=0,i=f;t<i;t+=Y,s+=2)e[t]=a,e[t+1]=r,e[t+2]=o,e[t+3]=l,e[t+4]=k[s],e[t+5]=k[s+1];t=w,s=f,i=v,n=v.length}if(0==s||0==n){a.clipEndWithSlot(e);continue}let _=c/ws.VERTEX_STRIDE,V=g,D=c,O=0;for(;O<s;){let e=t[O++],s=t[O++];V[D++]=e,V[D++]=s,V[D++]=m,V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],this._expandByPoint(e,s,m)}c=D;let N=p;for(D=d,O=0;O<n;D++,O++)N[D]=i[O]+_;d+=n;const L=e.data,q=L.name;B=L.blendMode;const U=null!==y&&y!==L.blendMode,W=null!==b&&b!==C,z=r.get(q);if(z||U||W){if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.subPrimitive=e,s.texture=b,s.blendMode=y,o.push(s),A+=T,T=0}if(z){const t=l.get(q);if(t){const e=C.texture;t.filterMode=e.filterMode,t.wrapModeU=e.wrapModeU,t.wrapModeV=e.wrapModeV}const e=x[F];e&&F++;const s=e||S.get();s.start=A,s.count=n;const i=M.get();i.blendMode=B,i.subPrimitive=s,i.texture=C,i.slotName=q,o.push(i),A+=n,T=0}else T+=n}else T+=n;b=C,y=B}a.clipEndWithSlot(e)}else i&&a.clipEndWithSlot(e)}if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.blendMode=B,s.subPrimitive=e,s.texture=C,o.push(s),T=0}a.clipEnd();const E=x.length,Y=o.length;if(Y<E)for(let t=Y;t<E;t++){const e=x[t];S.return(e)}s._clearSubPrimitives();for(let t=0,e=Y;t<e;++t){const e=o[t],{slotName:i,blendMode:n,texture:a}=e;s._addSubPrimitive(e.subPrimitive);let r=a.texture;l.has(i)&&(r=l.get(i));const h=`${r.instanceId}_${n}`;let c=ys._materialCache.get(h);c||(c=this._createMaterialForTexture(r,f,n),ys._materialCache.set(h,c)),s.setMaterial(t,c)}s._vertexBuffer.setData(g),s._indexBuffer.setData(p)}addSeparateSlot(t){this._separateSlots.set(t,t)}addSeparateSlotTexture(t,e){this._separateSlotTextureMap.set(t,e)}_createMaterialForTexture(t,e,s){const i=ys._getDefaultMaterial(e);return i.shaderData.setTexture("material_SpineTexture",t),fs(i,s),i}_expandByPoint(t,e,s){const{bounds:{min:i,max:n}}=ws,a=Math.min(i.x,t),r=Math.min(i.y,e),o=Math.min(i.z,s),l=Math.max(n.x,t),h=Math.max(n.y,e),c=Math.max(n.z,s);i.set(a,r,o),n.set(l,h,c)}_collectUniqueAttachments(t,e){const{attachments:s}=t;for(let t=0,i=s.length;t<i;t++){const i=s[t];for(let t in i){const s=i[t];s&&!e.has(s)&&e.add(s)}}}_calculateTotalVertexCount(t){let e=0;const s=ws.QUAD_TRIANGLES.length;return t.forEach((t=>{t instanceof Vt?e+=s:t instanceof Pt&&(e+=t.triangles.length)})),e}constructor(){this._clipper=new ze,this._subRenderItems=[],this._separateSlots=new Map,this._separateSlotTextureMap=new Map}}class bs extends e.Material{static{this._spineVS="\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 COLOR_0;\n \n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n }\n "}static{this._spineFS="\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n vec4 baseColor = texture2D(material_SpineTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n }\n "}constructor(s){super(s,e.Shader.find("galacean-spine-shader")||e.Shader.create("galacean-spine-shader",bs._spineVS,bs._spineFS));const i=this.renderState;i.blendState.targetBlendState.enabled=!0,fs(this,t.BlendMode.Normal),i.depthState.writeEnabled=!1,i.rasterState.cullMode=e.CullMode.Off,i.renderQueueType=e.RenderQueueType.Transparent}}class ys extends e.Renderer{static{this._spineGenerator=new ws}static{this._positionVertexElement=new e.VertexElement("POSITION",0,e.VertexElementFormat.Vector3,0)}static{this._colorVertexElement=new e.VertexElement("COLOR_0",12,e.VertexElementFormat.Vector4,0)}static{this._uvVertexElement=new e.VertexElement("TEXCOORD_0",28,e.VertexElementFormat.Vector2,0)}static{this._materialCache=new Map}static{this._animationDataCache=new Map}static _getDefaultMaterial(t){let e=this._defaultMaterial;if(e){if(e.engine===t)return e.clone();e.destroy(!0),e=null}return e=new bs(t),e.isGCIgnored=!0,this._defaultMaterial=e,e.clone()}get resource(){return this._resource}set resource(t){if(!t)return this._state=null,this._skeleton=null,void(this._resource=null);this._resource=t,this._addResourceReferCount(t,1);const{skeletonData:e}=t;this._skeleton=new Qt(e);let s=ys._animationDataCache.get(e);s||(s=new gt(e),ys._animationDataCache.set(e,s)),this._state=new at(s);const i=ys._spineGenerator.getMaxVertexCount(e);this._createBuffer(i),this._initializeDefaultState(),this._dirtyUpdateFlag|=4,this._state.addListener({start:()=>{this._onAnimationStart()},complete:t=>{this._onAnimationComplete(t)}})}get state(){return this._state}get skeleton(){return this._skeleton}constructor(t){super(t),this.setting=new Ms,this.defaultState=new Ss,this._subPrimitives=[],this._needResizeBuffer=!1,this._vertexCount=0;const s=new e.Primitive(this._engine);this._primitive=s,s.addVertexElement(ys._positionVertexElement),s.addVertexElement(ys._colorVertexElement),s.addVertexElement(ys._uvVertexElement)}addSeparateSlot(t){this._skeleton||console.error("Skeleton not found!");this._skeleton.findSlot(t)?ys._spineGenerator.addSeparateSlot(t):console.warn(`Slot: ${t} not find.`)}_onEnable(){this._initializeDefaultState()}update(e){const{_state:s,_skeleton:i}=this;s&&i&&(s.update(e),s.apply(i),i.update(e),i.updateWorldTransform(t.Physics.update),ys._spineGenerator.buildPrimitive(this._skeleton,this),this._isContainDirtyFlag(4)&&(this._onWorldVolumeChanged(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(2)&&this._calculateGeneratorBounds(this.bounds))}_render(t){const{_primitive:e,_subPrimitives:s}=this,{_materials:i,_engine:n}=this,a=n._renderElementPool.get();a.set(this.priority,this._distanceForSort);const r=n._subRenderElementPool;if(s){for(let t=0,n=s.length;t<n;t++){let n=i[t];if(!n)continue;(n.destroyed||n.shader.destroyed)&&(n=this.engine._meshMagentaMaterial);const o=r.get();o.set(this,n,e,s[t]),a.addSubRenderElement(o)}t.camera._renderPipeline.pushRenderElement(t,a)}}_updateBounds(t){this._calculateGeneratorBounds(t)}_calculateGeneratorBounds(t){const{bounds:s}=ws;e.BoundingBox.transform(s,this.entity.transform.worldMatrix,t)}_cloneTo(t){t.resource=this._resource}_onDestroy(){const{_primitive:t,_subPrimitives:e,_resource:s}=this;e.length=0,t&&t.destroy(),s&&this._addResourceReferCount(s,-1),this._clearMaterialCache(),this._primitive=null,this._resource=null,this._skeleton=null,this._state=null,this.setting=null,super._onDestroy()}_createBuffer(t){const{_engine:s,_primitive:i}=this;this._vertices=new Float32Array(t*ws.VERTEX_STRIDE),this._indices=new Uint16Array(t);const n=4*ws.VERTEX_STRIDE,a=new e.Buffer(s,e.BufferBindFlag.VertexBuffer,this._vertices,e.BufferUsage.Dynamic),r=new e.Buffer(s,e.BufferBindFlag.IndexBuffer,this._indices,e.BufferUsage.Dynamic);this._indexBuffer=r,this._vertexBuffer=a;const o=new e.VertexBufferBinding(a,n);this._primitive.setVertexBufferBinding(0,o);const l=new e.IndexBufferBinding(r,e.IndexFormat.UInt16);i.setIndexBufferBinding(l)}_addSubPrimitive(t){this._subPrimitives.push(t)}_clearSubPrimitives(){this._subPrimitives.length=0}_isContainDirtyFlag(t){return!!(this._dirtyUpdateFlag&t)}_setDirtyFlagFalse(t){this._dirtyUpdateFlag&=~t}_onWorldVolumeChanged(){this._dirtyUpdateFlag|=1}_onAnimationStart(){this._dirtyUpdateFlag|=2}_onAnimationComplete(t){t.loop||this._setDirtyFlagFalse(2)}_clearMaterialCache(){this._materials.forEach((e=>{const s=e.shaderData.getTexture("material_SpineTexture"),i=function(e){const s=e.renderState.blendState.targetBlendState;return s.sourceColorBlendFactor===os&&s.destinationColorBlendFactor===ls&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ls&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Additive:s.sourceColorBlendFactor===hs&&s.destinationColorBlendFactor===cs&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===cs&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Multiply:s.sourceColorBlendFactor===ls&&s.destinationColorBlendFactor===ds&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ds&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Screen:t.BlendMode.Normal}(e),n=`${s.instanceId}_${i}`;ys._materialCache.delete(n)}))}_initializeDefaultState(){const{skeleton:t,state:e}=this;if(t&&e){const{animationName:s,skinName:i,loop:n,scale:a}=this.defaultState;t.scaleX=a,t.scaleY=a,"default"!==i&&(t.setSkinByName(i),t.setToSetupPose()),s&&e.setAnimation(0,s,n)}}}s([e.deepClone],ys.prototype,"setting",void 0),s([e.deepClone],ys.prototype,"defaultState",void 0),s([e.ignoreClone],ys.prototype,"_primitive",void 0),s([e.ignoreClone],ys.prototype,"_subPrimitives",void 0),s([e.ignoreClone],ys.prototype,"_indexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertices",void 0),s([e.ignoreClone],ys.prototype,"_indices",void 0),s([e.ignoreClone],ys.prototype,"_needResizeBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexCount",void 0),s([e.ignoreClone],ys.prototype,"_resource",void 0),s([e.ignoreClone],ys.prototype,"_skeleton",void 0),s([e.ignoreClone],ys.prototype,"_state",void 0);class Ms{constructor(t=.01,e=!0){this.zSpacing=t,this.useClipping=e}}class Ss{constructor(t=1,e=!0,s=null,i="default"){this.scale=t,this.loop=e,this.animationName=s,this.skinName=i}}class vs extends e.ReferResource{get skeletonData(){return this._skeletonData}constructor(t,e){super(t),this.textures=[],this._skeletonData=e,this._associationTextureInSkeletonData(e)}_onDestroy(){super._onDestroy();const{textures:t,_skeletonData:e}=this;t&&this._disassociationSuperResource(t),this._clearAttachmentTextures(e),ys._animationDataCache.delete(e),this._skeletonData=null}_disassociationSuperResource(t){for(let e=0,s=t.length;e<s;e++)t[e]._disassociationSuperResource(this)}_associationTextureInSkeletonData(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0],s=e?.region?.texture.texture;s&&!this.textures.find((t=>t.instanceId===s.instanceId))&&(this.textures.push(s),s._associationSuperResource(this))}))}))}_clearAttachmentTextures(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0];e?.region?.texture&&(e.region.texture.texture=null)}))}))}}class ks{constructor(t,e=0,s){this.data=t,this._dataView=new DataView(t.buffer,t.byteOffset+e,s??t.byteLength-e),this._position=0}nextUint16(){const t=this._dataView.getUint16(this._position,!0);return this._position+=2,t}nextStr(){const t=this.nextUint16(),e=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,t);return this._position+=t,this.decodeText(e)}nextImageData(){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)}decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let s=0,i=t.length;s<i;s++)e+=String.fromCharCode(t[s]);return decodeURIComponent(encodeURIComponent(e))}}class Is extends e.Loader{static{this.imageExtensions=["png","jpg","webp","jpeg","ktx","ktx2"]}static{this.skeletonExtensions=["skel","json","bin"]}static parseAndAssignSpineAsset(t,e,s){const{imageExtensions:i,skeletonExtensions:n}=Is,a=Is.getUrlExtension(t,e);a&&(n.includes(a)&&(s.skeletonPath=t,s.skeletonExtension=a),"atlas"===a&&(s.atlasPath=t),i.includes(a)&&(s.imagePaths.push(t),s.imageExtensions.push(a)))}static deriveAndAssignSpineAsset(t,e,s){const i=Is.getUrlExtension(t,e);if(!i)return;s.skeletonPath=t,s.skeletonExtension=i;const n=/(\.(json|bin|skel))$/;let a;if(n.test(t)&&(a=t.replace(n,"")),a){const t=a+".atlas";s.atlasPath=t}}static verifyFileExtensions(t,e){return t?e&&!Array.isArray(t)?(console.error("Expect fileExtensions to be an array."),[]):e||"string"==typeof t?t:(console.error("Expect fileExtensions to be a string."),null):null}static getUrlExtension(t,e){if(e)return e;const s=t.match(/\/([^\/?#]+)\.([a-zA-Z0-9]+)(\?|#|$)|\?[^#]*\.([a-zA-Z0-9]+)(\?|#|$)/);return s?s[2]||s[4]:null}load(t,s){return new e.AssetPromise((async e=>{let i;if(t.urls)i=await this._handleOriginAsset(t,s);else{const e=await s._request(t.url,{type:"arraybuffer"}),n=new ks(new Uint8Array(e)),a=n.nextStr();i=a.startsWith("spine")?await this._handleEditorAsset(e,n,a,s):await this._handleOriginAsset(t,s,e)}e(i)}))}async _handleEditorAsset(t,e,s,i){let n,a;const r=s.startsWith("spine:skel")?"skel":"json",{engine:o}=i;if("skel"===r)a=e.nextStr(),n=e.nextImageData();else{const e=new TextDecoder("utf-8").decode(new Uint8Array(t)),{data:s,atlas:i}=JSON.parse(e);a=i.refId,n=s}const l=Ze(await i.getResourceByRef({refId:a}),n,r);return new vs(o,l)}async _handleOriginAsset(t,e,s){let{fileExtensions:i}=t.params||{},n={skeletonPath:"",skeletonExtension:"",atlasPath:"",imagePaths:[],imageExtensions:[]};const{engine:a}=e;if(s){const e=Is.verifyFileExtensions(i,!1);Is.deriveAndAssignSpineAsset(t.url,e,n);const{skeletonPath:r,atlasPath:o}=n;if(!r||!o)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");const l=await es(o,a),{data:h,type:c}=this._determineSkeletonDataType(s),d=Ze(l,h,c);return new vs(a,d)}{i=Is.verifyFileExtensions(i,!0);for(let e=0;e<t.urls.length;e+=1){const s=t.urls[e],a=i&&i[e]||null;Is.parseAndAssignSpineAsset(s,a,n)}const{skeletonPath:s,atlasPath:r,imagePaths:o,skeletonExtension:l,imageExtensions:h}=n;if(!s||!r)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");const c="json"===l?"json":"skel";let d,u,m=["json"===l?e._request(s,{type:"text"}):e._request(s,{type:"arraybuffer"})];if(o.length>0){let t,s;m=m.concat([e._request(r,{type:"text"}),ts(o,h,a)]),[u,t,s]=await Promise.all(m),d=ss(t,s)}else m.push(es(r,a)),[u,d]=await Promise.all(m);const f=Ze(d,u,c);return new vs(a,f)}}_determineSkeletonDataType(t){let e,s;try{const i=new TextDecoder("utf-8").decode(t);JSON.parse(i),e=i,s="json"}catch(i){e=t,s="skel"}return{data:e,type:s}}}Is=s([e.resourceLoader("spine",["json","bin","skel"])],Is);class As extends e.Loader{load(t,s){return new e.AssetPromise((async e=>{const i=await s._request(t.url,{type:"text"}),{data:n,textures:a}=JSON.parse(i),r=a.map((t=>s.getResourceByRef({refId:t.refId})));e(ss(n,await Promise.all(r)))}))}}As=s([e.resourceLoader("EditorSpineAtlas",["atlas"])],As);const Ts="4.2.0-beta.2";e.Loader.registerClass("SpineAnimationRenderer",ys),console.log(`Galacean spine version: ${Ts}`),t.AlphaTimeline=V,t.Animation=g,t.AnimationState=at,t.AnimationStateAdapter=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},t.AnimationStateData=gt,t.AssetManagerBase=class{pathPrefix="";textureLoader;downloader;assets={};errors={};toLoad=0;loaded=0;constructor(t,e="",s=new qt){this.textureLoader=t,this.pathPrefix=e,this.downloader=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.assets[e]=s,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise(((t,e)=>{let s=()=>{this.isLoadingComplete()?this.hasErrors()?e(this.errors):t(this):requestAnimationFrame(s)};requestAnimationFrame(s)}))}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadBinary(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load binary ${t}: status ${e}, ${i}`)}))}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${e}, ${i}`)}))}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadJson(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load JSON ${t}: status ${e}, ${i}`)}))}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),!!("undefined"==typeof window||"undefined"==typeof navigator||!window.document))fetch(t,{mode:"cors"}).then((e=>e.ok?e.blob():(this.error(s,t,`Couldn't load image: ${t}`),null))).then((t=>t?createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null)).then((s=>{s&&this.success(e,t,this.textureLoader(s))}));else{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this.success(e,t,this.textureLoader(i))},i.onerror=()=>{this.error(s,t,`Couldn't load image: ${t}`)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),i.src=t}}loadTextureAtlas(t,e=()=>{},s=()=>{},i){let n=t.lastIndexOf("/"),a=n>=0?t.substring(0,n+1):"";t=this.start(t),this.downloader.downloadText(t,(n=>{try{let r=new Ft(n),o=r.pages.length,l=!1;for(let n of r.pages)this.loadTexture(i?i[n.name]:a+n.name,((s,i)=>{l||(n.setTexture(i),0==--o&&this.success(e,t,r))}),((e,i)=>{l||this.error(s,t,`Couldn't load texture atlas ${t} page image: ${e}`),l=!0}))}catch(e){this.error(s,t,`Couldn't parse texture atlas ${t}: ${e.message}`)}}),((e,i)=>{this.error(s,t,`Couldn't load texture atlas ${t}: status ${e}, ${i}`)}))}get(t){return this.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;let e=this.assets[t];if(e)return e;let s=this.errors[t];throw Error("Asset not found: "+t+(s?"\n"+s:""))}remove(t){t=this.pathPrefix+t;let e=this.assets[t];return e.dispose&&e.dispose(),delete this.assets[t],e}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},t.AtlasAttachmentLoader=Dt,t.Attachment=d,t.AttachmentTimeline=N,t.BinaryInput=re,t.Bone=Nt,t.BoneData=Ot,t.BoundingBoxAttachment=xt,t.CURRENT=pt,t.ClippingAttachment=wt,t.Color=n,t.ConstraintData=Lt,t.CurveTimeline=M,t.CurveTimeline1=S,t.CurveTimeline2=v,t.DebugUtils=class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},t.DeformTimeline=L,t.Downloader=qt,t.DrawOrderTimeline=U,t.Event=Ut,t.EventData=Wt,t.EventQueue=ot,t.EventTimeline=q,t.FIRST=ct,t.FakeTexture=class extends bt{setFilters(t,e){}setWraps(t,e){}dispose(){}},t.HOLD_FIRST=ut,t.HOLD_MIX=mt,t.HOLD_SUBSEQUENT=dt,t.IkConstraint=zt,t.IkConstraintData=Gt,t.IkConstraintTimeline=W,t.InheritTimeline=P,t.IntSet=class{array=new Array;add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return null!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}},t.Interpolation=r,t.MathUtils=a,t.MeshAttachment=Pt,t.PathAttachment=Xt,t.PathConstraint=jt,t.PathConstraintData=$t,t.PathConstraintMixTimeline=j,t.PathConstraintPositionTimeline=G,t.PathConstraintSpacingTimeline=$,t.PhysicsConstraintDampingTimeline=Q,t.PhysicsConstraintGravityTimeline=et,t.PhysicsConstraintInertiaTimeline=J,t.PhysicsConstraintMassTimeline=Z,t.PhysicsConstraintMixTimeline=st,t.PhysicsConstraintResetTimeline=it,t.PhysicsConstraintStrengthTimeline=K,t.PhysicsConstraintTimeline=H,t.PhysicsConstraintWindTimeline=tt,t.PointAttachment=_t,t.Pool=h,t.Pow=o,t.PowOut=class extends o{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}},t.RGB2Timeline=O,t.RGBA2Timeline=D,t.RGBATimeline=X,t.RGBTimeline=_,t.RegionAttachment=Vt,t.RotateTimeline=k,t.SETUP=ft,t.SUBSEQUENT=ht,t.ScaleTimeline=B,t.ScaleXTimeline=C,t.ScaleYTimeline=F,t.SequenceTimeline=nt,t.ShearTimeline=E,t.ShearXTimeline=Y,t.ShearYTimeline=R,t.Skeleton=Qt,t.SkeletonBinary=ae,t.SkeletonBounds=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=new Array;polygons=new Array;polygonPool=new h((()=>l.newFloatArray(16)));update(t,e){if(!t)throw new Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,n=this.polygonPool,a=t.slots,r=a.length;s.length=0,n.freeAll(i),i.length=0;for(let t=0;t<r;t++){let e=a[t];if(!e.bone.active)continue;let r=e.getAttachment();if(r instanceof xt){let t=r;s.push(t);let a=n.obtain();a.length!=t.worldVerticesLength&&(a=l.newFloatArray(t.worldVerticesLength)),i.push(a),t.computeWorldVertices(e,0,t.worldVerticesLength,a,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,i=Number.NEGATIVE_INFINITY,n=this.polygons;for(let a=0,r=n.length;a<r;a++){let r=n[a],o=r;for(let n=0,a=r.length;n<a;n+=2){let a=o[n],r=o[n+1];t=Math.min(t,a),e=Math.min(e,r),s=Math.max(s,a),i=Math.max(i,r)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let n=this.minX,a=this.minY,r=this.maxX,o=this.maxY;if(t<=n&&s<=n||e<=a&&i<=a||t>=r&&s>=r||e>=o&&i>=o)return!1;let l=(i-e)/(s-t),h=l*(n-t)+e;if(h>a&&h<o)return!0;if(h=l*(r-t)+e,h>a&&h<o)return!0;let c=(a-e)/l+t;return c>n&&c<r||(c=(o-e)/l+t,c>n&&c<r)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,n=s.length;i<n;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t,n=t.length,a=n-2,r=!1;for(let t=0;t<n;t+=2){let n=i[t+1],o=i[a+1];if(n<s&&o>=s||o<s&&n>=s){let l=i[t];l+(s-n)/(o-n)*(i[a]-l)<e&&(r=!r)}a=t}return r}intersectsSegment(t,e,s,i){let n=this.polygons;for(let a=0,r=n.length;a<r;a++)if(this.intersectsSegmentPolygon(n[a],t,e,s,i))return this.boundingBoxes[a];return null}intersectsSegmentPolygon(t,e,s,i,n){let a=t,r=t.length,o=e-i,l=s-n,h=e*n-s*i,c=a[r-2],d=a[r-1];for(let t=0;t<r;t+=2){let r=a[t],u=a[t+1],m=c*u-d*r,f=c-r,p=d-u,g=o*p-l*f,x=(h*f-o*m)/g;if((x>=c&&x<=r||x>=r&&x<=c)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*p-l*m)/g;if((t>=d&&t<=u||t>=u&&t<=d)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}c=r,d=u}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},t.SkeletonClipping=ze,t.SkeletonData=te,t.SkeletonDataResource=vs,t.SkeletonJson=Ge,t.Skin=se,t.SkinEntry=ee,t.Slot=Jt,t.SlotData=ie,t.SpineAnimationRenderer=ys,t.StringSet=i,t.Texture=bt,t.TextureAtlas=Ft,t.TextureAtlasPage=Yt,t.TextureAtlasRegion=Rt,t.TextureRegion=Ct,t.TimeKeeper=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){let 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)}},t.Timeline=y,t.TrackEntry=rt,t.TransformConstraint=Kt,t.TransformConstraintData=ne,t.TransformConstraintTimeline=z,t.TranslateTimeline=I,t.TranslateXTimeline=A,t.TranslateYTimeline=T,t.Triangulator=We,t.Utils=l,t.Vector2=c,t.VertexAttachment=u,t.WindowedMean=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}},t.createTextureAtlas=ss,t.version=Ts,Object.defineProperty(t,"__esModule",{value:!0})}));
|