@canvasengine/presets 2.0.0-beta.51 → 2.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,97 @@
1
- var CanvasEnginePresets=(function(xt,D,O){"use strict";function Xe(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const e in h)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>h[e]})}}return t.default=h,Object.freeze(t)}const dt=Xe(O);function Qt(h){var t=h.toString(16);return t.length==1?"0"+t:t}function Qe(h,t,e){return"#"+Qt(h)+Qt(t)+Qt(e)}function Je(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:a,border:o,innerMargin:g,borderRadius:A}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(x){A()?x.roundRect(0,0,t(),e(),A()):x.rect(0,0,t(),e()),o&&x.stroke(o),x.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(x){const C=g(),S=A(),F=Math.max(0,Math.min(t()-2*C,i()/s()*(t()-2*C))),I=e()-2*C;A?x.roundRect(C,C,F,I,S):x.rect(C,C,F,I);const N=a();if(N.startsWith("rgba")){const[R,m,v,_]=N.match(/\d+(\.\d+)?/g).map(Number);x.fill({color:Qe(R,m,v),alpha:_})}else x.fill(N)}}))}class jt{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Dt{constructor(t){this.data=t}update(t){}dispose(){}}class ve extends Dt{constructor(t){super(),this.componentId=t,this.exhausted=!1,this.completed=!1,this.name="",this.endTime=0,this._x=0,this._y=0,this._rotation=0,this._alpha=0,this._scale=new dt.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var Jt;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(Jt||(Jt={}));class Zt{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class V{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Ut;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Ut||(Ut={}));class Ze extends Zt{constructor(){super(Ut.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let a=i.rotation;const o=V.float(-s,s),g=V.float(-c,c);a!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(a)-g*Math.sin(a),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(a)+g*Math.cos(a)):(t.component.x=this.__x+this._t*(this.x-this.__x)+o,t.component.y=this.__y+this._t*(this.y-this.__y)+g),e.radial?(a+=Math.atan2(g,o),t.dx=Math.cos(a),t.dy=Math.sin(a)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=a,this._t+=this._posInterpolationStep}}class ti extends Zt{constructor(){super(Ut.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=V.float(-e.angle*.5,e.angle*.5)+i.rotation:s=V.float(0,6.28319)+i.rotation,e.radius>0){let c=V.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c}else t.component.x=this.__x+this._t*(this.x-this.__x),t.component.y=this.__y+this._t*(this.y-this.__y);e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class ei extends Zt{constructor(){super(Ut.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=V.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var wt;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(wt||(wt={}));class ii extends dt.AnimatedSprite{constructor(t,e,i,s){let c=[],a=e.length;for(let o=0;o<a;o++)c.push(dt.Texture.from(e[o]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class ri{constructor(){}setRgb(t,e){this.startRgb=this.rgb=t,this.r=this.sR=t>>16&255,this.g=this.sG=t>>8&255,this.b=this.sB=t&255,this.targetRgb=e,this.dR=(e>>16&255)-this.r,this.dG=(e>>8&255)-this.g,this.dB=(e&255)-this.b}tween(t,e,i){return t?(this.r=t(e,this.sR,this.dR,i),this.g=t(e,this.sG,this.dG,i),this.b=t(e,this.sB,this.dB,i)):(e/=i,this.r=this.dR*e+this.sR,this.g=this.dG*e+this.sG,this.b=this.dB*e+this.sB),this.rgb=this.r<<16|this.g<<8|this.b,this.rgb}}var be;(function(h){h.Linear="linear",h.EaseInQuad="easeInQuad",h.EaseOutQuad="easeOutQuad",h.EaseInOutQuad="easeInOutQuad",h.EaseInCubic="easeInCubic",h.EaseOutCubic="easeOutCubic",h.EaseInOutCubic="easeInOutCubic",h.EaseInQuart="easeInQuart",h.EaseOutQuart="easeOutQuart",h.EaseInOutQuart="easeInOutQuart",h.EaseInQuint="easeInQuint",h.EaseOutQuint="easeOutQuint",h.EaseInOutQuint="easeInOutQuint",h.EaseInSine="easeInSine",h.EaseOutSine="easeOutSine",h.EaseInOutSine="easeInOutSine",h.EaseInExpo="easeInExpo",h.EaseOutExpo="easeOutExpo",h.EaseInOutExpo="easeInOutExpo",h.EaseInCirc="easeInCirc",h.EaseOutCirc="easeOutCirc",h.EaseInOutCirc="easeInOutCirc",h.EaseInElastic="easeInElastic",h.EaseOutElastic="easeOutElastic",h.EaseInOutElastic="easeInOutElastic",h.EaseInBack="easeInBack",h.EaseOutBack="easeOutBack",h.EaseInOutBack="easeInOutBack",h.EaseInBounce="easeInBounce",h.EaseOutBounce="easeOutBounce",h.EaseInOutBounce="easeInOutBounce"})(be||(be={}));class gt{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e}static easeOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/a)+i+e}static easeInOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s/2),a||(a=s*.44999999999999996),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=gt.easeOutBounce(s-t,0,i,s),i-c+e}static easeOutBounce(t,e,i,s){return(t/=s)<.36363636363636365?i*(7.5625*t*t)+e:t<.7272727272727273?i*(7.5625*(t-=.5454545454545454)*t+.75)+e:t<.9090909090909091?i*(7.5625*(t-=.8181818181818182)*t+.9375)+e:i*(7.5625*(t-=.9545454545454546)*t+.984375)+e}static easeInOutBounce(t,e,i,s){let c;return t<s/2?(c=gt.easeInBounce(t*2,0,i,s),c*.5+e):(c=gt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class ut{constructor(){this.__hasCallback=!1,this._list=new jt}add(t,e,i){this._list.add(new Dt(new Te(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Dt(new Te(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const a=i.data;a.callRate&&a.calls%a.callRate!=0&&(c=!1),c&&(a.callback.apply(a.scope,t),a.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Te{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let si=class extends Dt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new ut,bounced:new ut,updated:new ut},this._color=new ri}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const a=this.duration=V.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(s):t.container.addChildAt(s,0),s.blendMode=c.__getBlendMode(e.blendMode),this.startX=s.x,this.startY=s.y,this.useGravity=t.settings.useGravity,this.useScale=e.useScale,this.useRotation=e.useRotation,this.useAlpha=e.useAlpha,this.useTint=e.useTint,this.useSpawns=e.useSpawns,this.useChilds=e.useChilds,this.useMotion=e.useMotion,this.useGravity)if(this.gravity=t.settings.gravity,this.useFloor=t.settings.useFloor,this.floorY=t.settings.floorY,this.bounceFac=V.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-V.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=V.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=o*this.dx*i,this.moveSpeedY=o*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const o=this.distance=V.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+o*this.dx-this.startX)*.8,this.deltaY=(s.y+o*this.dy-this.startY)*.8,this.distanceEase=gt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=V.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=V.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=V.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=gt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=a*(1-e.fadeInDurationFac),this.fadeInDuration=a*e.fadeInDurationFac,this.fadeInEase=gt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=gt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=V.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(V.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=V.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(V.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=gt[e.scaleXEase],this.scaleYStart=s.scale.y=V.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(V.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=gt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=a*(1-e.scaleInDurationFac),this.scaleInDuration=a*e.scaleInDurationFac,this.scaleInEase=gt[e.scaleInEase||"easeInSine"])):e.uniformScale?(s.scale.x=e.scaleStartMin,s.scale.y=e.scaleStartMin):(s.scale.x=e.scaleXStartMin,s.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=V.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=V.sign())),e.useTint&&(this.tintEase=gt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let o=e.childs.length;if(this._hasChildEmitters=o>0,this._childEmitters)for(;--o>-1;){const g=e.childs[o],A=c.getParticleEmitterById(g.id);A.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(A.rotation=s.rotation,A.__adoptRotation=!0),A.__parent=this,this._childEmitters.push(A)}}return e.useSpawns&&(e.spawn.onStart.length>0&&t.__subSpawn(this,e.spawn.onStart),this._spawnOnHalfway=e.spawn.onHalfway.length>0),t.__on.particleSpawned.__hasCallback&&t.__on.particleSpawned.dispatch(this),this}update(t){const e=this.time+=t,i=this.duration;if(e>=i){this.emitter.__removeParticle(this);return}const s=this.component,c=e*t;if(this.useGravity){const a=t/.0166666;if(s.x+=this.moveSpeedX*a,s.y+=this.moveSpeedY*a,this.moveSpeedY+=this.gravity*a,this.useAlign&&(s.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&s.y>this.floorY){s.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const o=this.emitter;o.__on.particleBounced.__hasCallback&&o.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&o.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(s.x=this.distanceEase(e,this.startX,this.deltaX,i),s.y=this.distanceEase(e,this.startY,this.deltaY,i)):(s.x=this.deltaX*c+this.startX,s.y=this.deltaY*c+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?s.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):s.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?s.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):s.alpha=this.alphaDelta*c+this.alphaStart),this.useRotation&&(s.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?s.scale.x=s.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):s.scale.x=s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(s.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),s.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):s.scale.x=s.scale.y=this.scaleDelta*c+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(s.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),s.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(s.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?s.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):s.scale.x=this.scaleXDelta*c+this.scaleXStart,this.scaleYEase?s.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):s.scale.y=this.scaleYDelta*c+this.scaleYStart)),this.useTint&&(s.tint=this._color.tween(this.tintEase,e,i)),this._spawnOnHalfway&&e>=.5&&(this._spawnOnHalfway=!1,this.emitter.__subSpawn(this,this.settings.spawn.onHalfway)),this.useChilds&&this._hasChildEmitters){const a=this._childEmitters;let o=a.length;for(;--o>-1;){const g=a[o];g.__recycled||(g.x=s.position.x,g.y=s.position.y,g.__adoptRotation&&(g.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class vt{static sanitizeBundle(t){for(let e of t.emitters){const i=vt._presetStructure.emitter;vt.parse(e,i,vt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=vt._presetStructure.sequence;vt.parse(e,i,vt._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let s in e)if(t[s]==null)t[s]=e[s];else{const c=t[s];if(typeof c!="object")continue;const a=e[s];if(!c.hasOwnProperty("length"))vt.parse(c,a,i);else for(let o of c)for(let g in i)o[g]==null&&(o[g]=i[g])}}}vt._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class ni extends dt.Sprite{constructor(t,e,i,s){super(dt.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Nt(h){if(typeof h!="object"||h===null)return h;const t=Array.isArray(h)?[]:{};for(const e in h){const i=h[e];t[e]=Nt(i)}return t}var ai=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(a){a(c)})}return new(e||(e=Promise))(function(c,a){function o(x){try{A(i.next(x))}catch(C){a(C)}}function g(x){try{A(i.throw(x))}catch(C){a(C)}}function A(x){x.done?c(x.value):s(x.value).then(o,g)}A((i=i.apply(h,t||[])).next())})};class pt{constructor(){this.useBlendModes=!0,this.particleCount=0,this.emitterCount=0,this.effectSequenceCount=0,this.maxParticles=5e3,this.particleFac=1,this._active=!1,this._effects=new jt,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,a;for(;c;)a=c.next,c.update(i),c=a;this._timeElapsed=e}clearCache(){this._cache={particles:[],mcs:[],sprites:[],effectSequences:[],emitters:[],cores:{}},this._settingsCache={mcs:{},sprites:{},emitters:{},effectSequences:{}},this._nameMaps={emitters:{},effectSequences:{}}}setFloorY(t){const e=this._settingsCache.emitters;for(let i in e)e[i].floorY=t}dispose(){let t=this._effects,e=t.first;for(;e;)e.dispose(),e=e.next;t.clear(),this.clearCache()}loadBundleFiles(t,e,i="",s=[]){return new Promise((c,a)=>ai(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var g in s)o[g]=s[g];dt.Assets.addBundle("rfx_assets",o);const A=yield dt.Assets.loadBundle("rfx_assets");c(this.initBundle(A.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==pt._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=pt.settingsVersion)throw new Error("Settings version mismatch.");vt.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const s=t.emitters[i];this.addParticleEmitter(s.id,s)}for(let i in t.sequences){const s=t.sequences[i];this.addEffectSequence(s.id,s)}return this.useBlendModes=t.useBlendModes,this.maxParticles=t.maxParticles,this.parseTextureCache(t.spritesheetFilter)}addParticleEmitter(t,e){if(this._settingsCache.emitters[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.emitters[t]=e,this._nameMaps.emitters[e.name]=e,this}addEffectSequence(t,e){if(this._settingsCache.effectSequences[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.effectSequences[t]=e,this._nameMaps.effectSequences[e.name]=e,this}initSprite(t,e){if(this._settingsCache.sprites[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.sprites[t]=e,this}initMovieClip(t,e){if(this._settingsCache.mcs[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.mcs[t]=e,this}getMovieClips(){return this._settingsCache.mcs}getSprites(){return this._settingsCache.sprites}addContainer(t,e){this.__containers[t]=e}getEffectSequence(t,e=!1){const i=this._nameMaps.effectSequences[t];if(!i)throw new Error(`Settings not defined for '${t}'`);return this.getEffectSequenceById(i.id,e)}getEffectSequenceById(t,e=!1){const i=this._cache.effectSequences;let s,c=this._settingsCache.effectSequences[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(s=new Ae(t),s.__fx=this):s=i.pop(),e&&(c=Nt(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,a=this._settingsCache.emitters[t];if(!a)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new te(t),c.__fx=this):c=s.pop(),i&&(a=Nt(a),a.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(a),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new te(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Ae(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(dt.Cache._cache,t)}get active(){return this._active}__addActiveEffect(t){this._effects.add(t)}__removeActiveEffect(t){this._effects.remove(t)}__getSprite(t){const e=this._cache.sprites;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){const s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new ni(t,s.texture,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getMovieClip(t){const e=this._cache.mcs;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){let s=this._settingsCache.mcs[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new ii(t,s.textures,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new si;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new pt.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return dt.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?pt._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const a=t;a.values();for(const[o,g]of a)g instanceof dt.Texture&&(i[o]=g)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let a in i)if(!(e&&a.indexOf(e)==-1)&&(this.initSprite(a,{texture:a,anchorX:.5,anchorY:.5}),c.sprites.push(a),a.substr(0,3)=="mc_")){const g=a.split("_")[1];s[g]==null&&(s[g]=[]),s[g].push(a)}for(let a in s){let o=s[a];c.movieClips.push(a),this.initMovieClip(a,{textures:o,anchorX:.5,anchorY:.5})}return c}}pt.settingsVersion=0,pt.version="1.3.4",pt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",pt.ComponentType=Jt,pt.EffectSequenceComponentType=wt,pt._blendModes=["normal","add","multiply","screen"],pt.__emitterCores={circle:ti,box:Ze,ring:ei};var Pt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Pt||(Pt={}));class te extends ve{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new jt,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new ut,completed:new ut,exhausted:new ut,particleUpdated:new ut,particleSpawned:new ut,particleBounced:new ut,particleDied:new ut}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container;a.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(a.rotation=this._rotation,a.__adoptRotation=!0),a.__parent=this,this._childEmitters.push(a)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+V.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,a;for(;c;)a=c.next,c.update(t),c=a;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=V.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let a;switch(s.componentType){case 0:c.componentId=s.componentId,a=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,a=e.__getMovieClip(c.componentId),s.componentParams&&(a.loop=!(s.componentParams.loop==null||!s.componentParams.loop),a.animationSpeed=V.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),a.gotoAndPlay(0);break}a.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=a,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=V.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let a,o;switch(c.type){case 0:a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(a.rotation=t.component.rotation+a.settings.rotation,a.__adoptRotation=!0):a.rotation=a.settings.rotation;break;case 1:a=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(a.rotation=t.component.rotation);break}a.x=t.component.x,a.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const a=i[c];for(const o of a){switch(o.type){case Pt.ParticleEmitter:o.settings=Nt(e.__getEmitterSettings(o.id));break;case Pt.EffectSequence:o.settings=Nt(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Pt.ParticleEmitter:c.settings=Nt(e.__getEmitterSettings(c.id));break;case Pt.EffectSequence:c.settings=Nt(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class Ae extends ve{constructor(t){super(t),this._list=[],this._elements=new jt,this.__on={started:new ut,completed:new ut,exhausted:new ut,effectSpawned:new ut,triggerActivated:new ut}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,a=this._nextEffectSettings;let o,g,A;switch(a.componentType){case wt.Sprite:o=c.__getSprite(a.componentId),A=c.__containers[a.containerId]||this.container,A.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(V.float(a.scaleMin,a.scaleMax)*V.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=V.float(a.alphaMin,a.alphaMax),o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),g=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+V.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(wt.Sprite,o);break;case wt.MovieClip:o=c.__getMovieClip(a.componentId),a.componentParams.loop?(o.animationSpeed=V.float(a.componentParams.animationSpeedMin||1,a.componentParams.animationSpeedMax||1),o.loop=a.componentParams.loop||!1):a.duration,o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),o.gotoAndPlay(0),A=c.__containers[a.containerId]||this.container,A.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(V.float(a.scaleMin,a.scaleMax)*V.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=V.float(a.alphaMin,a.alphaMax),g=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+V.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(wt.MovieClip,o);break;case wt.Emitter:o=c.getParticleEmitterById(a.componentId),A=c.__containers[a.containerId]||this.container,o.init(A,!0,V.float(a.scaleMin,a.scaleMax)*V.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),g=new Dt({component:o,endTime:o.endTime}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+o.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(wt.Emitter,o);break;case wt.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(a.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof te?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function oi(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new pt;let c;return dt.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),dt.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:a})=>{s.update(a)}),D.mount(async a=>{c=a;let g={...(await dt.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const x=e.emitters.map((C,S)=>({...C,id:1e4+S}));g.emitters=[...g.emitters,...x]}s.initBundle(g,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}function li(h){const{radius:t}=D.useProps(h),e=D.animatedSignal(1),i=1,s=2,c=.001,a=()=>{const g=Date.now()*c,A=(Math.sin(g)+Math.sin(g*1.3)+Math.sin(g*.7))/3,x=i+(s-i)*(A*.5+.5);e.update(()=>x),requestAnimationFrame(a)};a();const o=g=>{const A=t()*2,x=new D.RadialGradient(A,A,0,A,A,0);x.addColorStop(0,"rgba(255, 255, 0, 1)"),x.addColorStop(.5,"rgba(255, 255, 0, 0.3)"),x.addColorStop(.8,"rgba(255, 255, 0, 0)");const C=A/2;g.rect(-C,-C,A,A).fill(x.render({translate:{x:C,y:C}}))};return D.h(D.Graphics,{draw:o,...h,scale:e})}function ci(h){const{children:t}=h,e=D.signal(0),i=D.signal(0);let s;const c=a=>{a.rect(-80,-80,e()+160,i()+160),a.fill(0);const g=A=>{const x=D.isSignal(A.propObservables.x)?A.propObservables.x():A.props.x,C=D.isSignal(A.propObservables.y)?A.propObservables.y():A.props.y,S=D.isSignal(A.propObservables.radius)?A.propObservables.radius():A.props.radius;a.circle(x,C,S),a.cut()};for(let A of t){if(D.isObservable(A)){s&&s.unsubscribe(),s=A.subscribe(x=>{for(let C of x.fullElements)g(C)});return}g(A)}};return D.mount(a=>{a.componentInstance.on("layout",o=>{e.update(()=>a.componentInstance.getWidth()),i.update(()=>a.componentInstance.getHeight())})}),D.h(D.Container,{width:"100%",height:"100%",...h},D.h(D.Graphics,{draw:c,alpha:.8,blur:80}),...t)}function ui(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:a=3,inactiveAlpha:o=.15}=D.useProps(h,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),g=D.signal(0);D.tick(({deltaTime:I})=>{const R=(typeof s=="function"?s():s)*I/1e3;g.set(g()+R)});const A=I=>{const N=typeof t=="function"?t():t,R=typeof e=="function"?e():e,m=i?typeof i=="function"?i():i:null,v=typeof c=="function"?c():c;typeof a=="function"&&a();const _=typeof o=="function"?o():o,d=g();m&&I.circle(0,0,N).fill(m);const b=360/v,P=N*.4,U=N;for(let L=0;L<v;L++){const y=L*b,G=(d%360+360)%360;let it=Math.abs(G-y);it>180&&(it=360-it);let $=it/120;$=Math.min(1,$),$=$*$*$;const lt=_+(1-$)*(1-_),at=y*(Math.PI/180),ft=b*(Math.PI/180),Y=at-ft/2,ot=at+ft/2;I.arc(0,0,P,Y,ot).arc(0,0,U,ot,Y,!0).fill({color:R,alpha:lt})}},C=(typeof t=="function"?t():t)*2,S=D.signal(C),F=D.signal(C);return typeof t=="function"&&D.effect(()=>{const I=t();S.set(I*2),F.set(I*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:A})])}var Rt=(h=>(h.Tile="tilelayer",h.ObjectGroup="objectgroup",h.Image="imagelayer",h.Group="group",h))(Rt||{});function Se(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function hi(h){if(Object.prototype.hasOwnProperty.call(h,"__esModule"))return h;var t=h.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(h).forEach(function(i){var s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return h[i]}})}),e}var ee={};const fi=hi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ie={},zt={exports:{}},re={},Lt={},Ce;function di(){if(Ce)return Lt;Ce=1,Lt.byteLength=o,Lt.toByteArray=A,Lt.fromByteArray=S;for(var h=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)h[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function a(F){var I=F.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=F.indexOf("=");N===-1&&(N=I);var R=N===I?0:4-N%4;return[N,R]}function o(F){var I=a(F),N=I[0],R=I[1];return(N+R)*3/4-R}function g(F,I,N){return(I+N)*3/4-N}function A(F){var I,N=a(F),R=N[0],m=N[1],v=new e(g(F,R,m)),_=0,d=m>0?R-4:R,b;for(b=0;b<d;b+=4)I=t[F.charCodeAt(b)]<<18|t[F.charCodeAt(b+1)]<<12|t[F.charCodeAt(b+2)]<<6|t[F.charCodeAt(b+3)],v[_++]=I>>16&255,v[_++]=I>>8&255,v[_++]=I&255;return m===2&&(I=t[F.charCodeAt(b)]<<2|t[F.charCodeAt(b+1)]>>4,v[_++]=I&255),m===1&&(I=t[F.charCodeAt(b)]<<10|t[F.charCodeAt(b+1)]<<4|t[F.charCodeAt(b+2)]>>2,v[_++]=I>>8&255,v[_++]=I&255),v}function x(F){return h[F>>18&63]+h[F>>12&63]+h[F>>6&63]+h[F&63]}function C(F,I,N){for(var R,m=[],v=I;v<N;v+=3)R=(F[v]<<16&16711680)+(F[v+1]<<8&65280)+(F[v+2]&255),m.push(x(R));return m.join("")}function S(F){for(var I,N=F.length,R=N%3,m=[],v=16383,_=0,d=N-R;_<d;_+=v)m.push(C(F,_,_+v>d?d:_+v));return R===1?(I=F[N-1],m.push(h[I>>2]+h[I<<4&63]+"==")):R===2&&(I=(F[N-2]<<8)+F[N-1],m.push(h[I>>10]+h[I>>4&63]+h[I<<2&63]+"=")),m.join("")}return Lt}var Wt={};var Be;function pi(){return Be||(Be=1,Wt.read=function(h,t,e,i,s){var c,a,o=s*8-i-1,g=(1<<o)-1,A=g>>1,x=-7,C=e?s-1:0,S=e?-1:1,F=h[t+C];for(C+=S,c=F&(1<<-x)-1,F>>=-x,x+=o;x>0;c=c*256+h[t+C],C+=S,x-=8);for(a=c&(1<<-x)-1,c>>=-x,x+=i;x>0;a=a*256+h[t+C],C+=S,x-=8);if(c===0)c=1-A;else{if(c===g)return a?NaN:(F?-1:1)*(1/0);a=a+Math.pow(2,i),c=c-A}return(F?-1:1)*a*Math.pow(2,c-i)},Wt.write=function(h,t,e,i,s,c){var a,o,g,A=c*8-s-1,x=(1<<A)-1,C=x>>1,S=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=i?0:c-1,I=i?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=x):(a=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-a))<1&&(a--,g*=2),a+C>=1?t+=S/g:t+=S*Math.pow(2,1-C),t*g>=2&&(a++,g/=2),a+C>=x?(o=0,a=x):a+C>=1?(o=(t*g-1)*Math.pow(2,s),a=a+C):(o=t*Math.pow(2,C-1)*Math.pow(2,s),a=0));s>=8;h[e+F]=o&255,F+=I,o/=256,s-=8);for(a=a<<s|o,A+=s;A>0;h[e+F]=a&255,F+=I,a/=256,A-=8);h[e+F-I]|=N*128}),Wt}var Me;function Ie(){return Me||(Me=1,(function(h){const t=di(),e=pi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=v,h.INSPECT_MAX_BYTES=50;const s=2147483647;h.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=c(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const u=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(u,r),u.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function a(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const r=new Uint8Array(u);return Object.setPrototypeOf(r,o.prototype),r}function o(u,r,n){if(typeof u=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(u)}return g(u,r,n)}o.poolSize=8192;function g(u,r,n){if(typeof u=="string")return S(u,r);if(ArrayBuffer.isView(u))return I(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(_t(u,ArrayBuffer)||u&&_t(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(_t(u,SharedArrayBuffer)||u&&_t(u.buffer,SharedArrayBuffer)))return N(u,r,n);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=u.valueOf&&u.valueOf();if(p!=null&&p!==u)return o.from(p,r,n);const E=R(u);if(E)return E;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return o.from(u[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}o.from=function(u,r,n){return g(u,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function A(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function x(u,r,n){return A(u),u<=0?a(u):r!==void 0?typeof n=="string"?a(u).fill(r,n):a(u).fill(r):a(u)}o.alloc=function(u,r,n){return x(u,r,n)};function C(u){return A(u),a(u<0?0:m(u)|0)}o.allocUnsafe=function(u){return C(u)},o.allocUnsafeSlow=function(u){return C(u)};function S(u,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=_(u,r)|0;let p=a(n);const E=p.write(u,r);return E!==n&&(p=p.slice(0,E)),p}function F(u){const r=u.length<0?0:m(u.length)|0,n=a(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function I(u){if(_t(u,Uint8Array)){const r=new Uint8Array(u);return N(r.buffer,r.byteOffset,r.byteLength)}return F(u)}function N(u,r,n){if(r<0||u.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(u):n===void 0?p=new Uint8Array(u,r):p=new Uint8Array(u,r,n),Object.setPrototypeOf(p,o.prototype),p}function R(u){if(o.isBuffer(u)){const r=m(u.length)|0,n=a(r);return n.length===0||u.copy(n,0,0,r),n}if(u.length!==void 0)return typeof u.length!="number"||we(u.length)?a(0):F(u);if(u.type==="Buffer"&&Array.isArray(u.data))return F(u.data)}function m(u){if(u>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return u|0}function v(u){return+u!=u&&(u=0),o.alloc(+u)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(_t(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),_t(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let p=r.length,E=n.length;for(let T=0,B=Math.min(p,E);T<B;++T)if(r[T]!==n[T]){p=r[T],E=n[T];break}return p<E?-1:E<p?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const E=o.allocUnsafe(n);let T=0;for(p=0;p<r.length;++p){let B=r[p];if(_t(B,Uint8Array))T+B.length>E.length?(o.isBuffer(B)||(B=o.from(B)),B.copy(E,T)):Uint8Array.prototype.set.call(E,B,T);else if(o.isBuffer(B))B.copy(E,T);else throw new TypeError('"list" argument must be an Array of Buffers');T+=B.length}return E};function _(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||_t(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);const n=u.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let E=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return et(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Kt(u).length;default:if(E)return p?-1:et(u).length;r=(""+r).toLowerCase(),E=!0}}o.byteLength=_;function d(u,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(u||(u="utf8");;)switch(u){case"hex":return nt(this,r,n);case"utf8":case"utf-8":return lt(this,r,n);case"ascii":return Y(this,r,n);case"latin1":case"binary":return ot(this,r,n);case"base64":return $(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return X(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),p=!0}}o.prototype._isBuffer=!0;function b(u,r,n){const p=u[r];u[r]=u[n],u[n]=p}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?lt(this,0,r):d.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const n=h.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(r,n,p,E,T){if(_t(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),E===void 0&&(E=0),T===void 0&&(T=this.length),n<0||p>r.length||E<0||T>this.length)throw new RangeError("out of range index");if(E>=T&&n>=p)return 0;if(E>=T)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,E>>>=0,T>>>=0,this===r)return 0;let B=T-E,q=p-n;const Z=Math.min(B,q),Q=this.slice(E,T),tt=r.slice(n,p);for(let W=0;W<Z;++W)if(Q[W]!==tt[W]){B=Q[W],q=tt[W];break}return B<q?-1:q<B?1:0};function P(u,r,n,p,E){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=E?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(E)return-1;n=u.length-1}else if(n<0)if(E)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,p)),o.isBuffer(r))return r.length===0?-1:U(u,r,n,p,E);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?E?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):U(u,[r],n,p,E);throw new TypeError("val must be string, number or Buffer")}function U(u,r,n,p,E){let T=1,B=u.length,q=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(u.length<2||r.length<2)return-1;T=2,B/=2,q/=2,n/=2}function Z(tt,W){return T===1?tt[W]:tt.readUInt16BE(W*T)}let Q;if(E){let tt=-1;for(Q=n;Q<B;Q++)if(Z(u,Q)===Z(r,tt===-1?0:Q-tt)){if(tt===-1&&(tt=Q),Q-tt+1===q)return tt*T}else tt!==-1&&(Q-=Q-tt),tt=-1}else for(n+q>B&&(n=B-q),Q=n;Q>=0;Q--){let tt=!0;for(let W=0;W<q;W++)if(Z(u,Q+W)!==Z(r,W)){tt=!1;break}if(tt)return Q}return-1}o.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},o.prototype.indexOf=function(r,n,p){return P(this,r,n,p,!0)},o.prototype.lastIndexOf=function(r,n,p){return P(this,r,n,p,!1)};function L(u,r,n,p){n=Number(n)||0;const E=u.length-n;p?(p=Number(p),p>E&&(p=E)):p=E;const T=r.length;p>T/2&&(p=T/2);let B;for(B=0;B<p;++B){const q=parseInt(r.substr(B*2,2),16);if(we(q))return B;u[n+B]=q}return B}function y(u,r,n,p){return It(et(r,u.length-n),u,n,p)}function G(u,r,n,p){return It(Et(r),u,n,p)}function it(u,r,n,p){return It(Kt(r),u,n,p)}function j(u,r,n,p){return It(xe(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,E){if(n===void 0)E="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")E=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,E===void 0&&(E="utf8")):(E=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const T=this.length-n;if((p===void 0||p>T)&&(p=T),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");E||(E="utf8");let B=!1;for(;;)switch(E){case"hex":return L(this,r,n,p);case"utf8":case"utf-8":return y(this,r,n,p);case"ascii":case"latin1":case"binary":return G(this,r,n,p);case"base64":return it(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,r,n,p);default:if(B)throw new TypeError("Unknown encoding: "+E);E=(""+E).toLowerCase(),B=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function lt(u,r,n){n=Math.min(u.length,n);const p=[];let E=r;for(;E<n;){const T=u[E];let B=null,q=T>239?4:T>223?3:T>191?2:1;if(E+q<=n){let Z,Q,tt,W;switch(q){case 1:T<128&&(B=T);break;case 2:Z=u[E+1],(Z&192)===128&&(W=(T&31)<<6|Z&63,W>127&&(B=W));break;case 3:Z=u[E+1],Q=u[E+2],(Z&192)===128&&(Q&192)===128&&(W=(T&15)<<12|(Z&63)<<6|Q&63,W>2047&&(W<55296||W>57343)&&(B=W));break;case 4:Z=u[E+1],Q=u[E+2],tt=u[E+3],(Z&192)===128&&(Q&192)===128&&(tt&192)===128&&(W=(T&15)<<18|(Z&63)<<12|(Q&63)<<6|tt&63,W>65535&&W<1114112&&(B=W))}}B===null?(B=65533,q=1):B>65535&&(B-=65536,p.push(B>>>10&1023|55296),B=56320|B&1023),p.push(B),E+=q}return ft(p)}const at=4096;function ft(u){const r=u.length;if(r<=at)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=at));return n}function Y(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]&127);return p}function ot(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]);return p}function nt(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let E="";for(let T=r;T<n;++T)E+=sr[u[T]];return E}function X(u,r,n){const p=u.slice(r,n);let E="";for(let T=0;T<p.length-1;T+=2)E+=String.fromCharCode(p[T]+p[T+1]*256);return E}o.prototype.slice=function(r,n){const p=this.length;r=~~r,n=n===void 0?p:~~n,r<0?(r+=p,r<0&&(r=0)):r>p&&(r=p),n<0?(n+=p,n<0&&(n=0)):n>p&&(n=p),n<r&&(n=r);const E=this.subarray(r,n);return Object.setPrototypeOf(E,o.prototype),E};function k(u,r,n){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||k(r,n,this.length);let E=this[r],T=1,B=0;for(;++B<n&&(T*=256);)E+=this[r+B]*T;return E},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||k(r,n,this.length);let E=this[r+--n],T=1;for(;n>0&&(T*=256);)E+=this[r+--n]*T;return E},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||k(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||k(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||k(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,H(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&rt(r,this.length-8);const E=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,T=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(E)+(BigInt(T)<<BigInt(32))}),o.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,H(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&rt(r,this.length-8);const E=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],T=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(E)<<BigInt(32))+BigInt(T)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||k(r,n,this.length);let E=this[r],T=1,B=0;for(;++B<n&&(T*=256);)E+=this[r+B]*T;return T*=128,E>=T&&(E-=Math.pow(2,8*n)),E},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||k(r,n,this.length);let E=n,T=1,B=this[r+--E];for(;E>0&&(T*=256);)B+=this[r+--E]*T;return T*=128,B>=T&&(B-=Math.pow(2,8*n)),B},o.prototype.readInt8=function(r,n){return r=r>>>0,n||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||k(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||k(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,H(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&rt(r,this.length-8);const E=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(E)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),o.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,H(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&rt(r,this.length-8);const E=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(E)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||k(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||k(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||k(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||k(r,8,this.length),e.read(this,r,!1,52,8)};function K(u,r,n,p,E,T){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>E||r<T)throw new RangeError('"value" argument is out of bounds');if(n+p>u.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;K(this,r,n,p,q,0)}let T=1,B=0;for(this[n]=r&255;++B<p&&(T*=256);)this[n+B]=r/T&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;K(this,r,n,p,q,0)}let T=p-1,B=1;for(this[n+T]=r&255;--T>=0&&(B*=256);)this[n+T]=r/B&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function mt(u,r,n,p,E){J(r,p,E,u,n,7);let T=Number(r&BigInt(4294967295));u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T;let B=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=B,B=B>>8,u[n++]=B,B=B>>8,u[n++]=B,B=B>>8,u[n++]=B,n}function Tt(u,r,n,p,E){J(r,p,E,u,n,7);let T=Number(r&BigInt(4294967295));u[n+7]=T,T=T>>8,u[n+6]=T,T=T>>8,u[n+5]=T,T=T>>8,u[n+4]=T;let B=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=B,B=B>>8,u[n+2]=B,B=B>>8,u[n+1]=B,B=B>>8,u[n]=B,n+8}o.prototype.writeBigUInt64LE=Ft(function(r,n=0){return mt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Ft(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);K(this,r,n,p,Z-1,-Z)}let T=0,B=1,q=0;for(this[n]=r&255;++T<p&&(B*=256);)r<0&&q===0&&this[n+T-1]!==0&&(q=1),this[n+T]=(r/B>>0)-q&255;return n+p},o.prototype.writeIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);K(this,r,n,p,Z-1,-Z)}let T=p-1,B=1,q=0;for(this[n+T]=r&255;--T>=0&&(B*=256);)r<0&&q===0&&this[n+T+1]!==0&&(q=1),this[n+T]=(r/B>>0)-q&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||K(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=Ft(function(r,n=0){return mt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Ft(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Gt(u,r,n,p,E,T){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Xt(u,r,n,p,E){return r=+r,n=n>>>0,E||Gt(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return Xt(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return Xt(this,r,n,!1,p)};function f(u,r,n,p,E){return r=+r,n=n>>>0,E||Gt(u,r,n,8),e.write(u,r,n,p,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,p){return f(this,r,n,!0,p)},o.prototype.writeDoubleBE=function(r,n,p){return f(this,r,n,!1,p)},o.prototype.copy=function(r,n,p,E){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!E&&E!==0&&(E=this.length),n>=r.length&&(n=r.length),n||(n=0),E>0&&E<p&&(E=p),E===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("sourceEnd out of bounds");E>this.length&&(E=this.length),r.length-n<E-p&&(E=r.length-n+p);const T=E-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,E):Uint8Array.prototype.set.call(r,this.subarray(p,E),n),T},o.prototype.fill=function(r,n,p,E){if(typeof r=="string"){if(typeof n=="string"?(E=n,n=0,p=this.length):typeof p=="string"&&(E=p,p=this.length),E!==void 0&&typeof E!="string")throw new TypeError("encoding must be a string");if(typeof E=="string"&&!o.isEncoding(E))throw new TypeError("Unknown encoding: "+E);if(r.length===1){const B=r.charCodeAt(0);(E==="utf8"&&B<128||E==="latin1")&&(r=B)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let T;if(typeof r=="number")for(T=n;T<p;++T)this[T]=r;else{const B=o.isBuffer(r)?r:o.from(r,E),q=B.length;if(q===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(T=0;T<p-n;++T)this[T+n]=B[T%q]}return this};const l={};function M(u,r,n){l[u]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${u}]`,this.stack,delete this.name}get code(){return u}set code(E){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:E,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}M("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),M("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,E=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?E=w(String(n)):typeof n=="bigint"&&(E=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(E=w(E)),E+="n"),p+=` It must be ${r}. Received ${E}`,p},RangeError);function w(u){let r="",n=u.length;const p=u[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${u.slice(n-3,n)}${r}`;return`${u.slice(0,n)}${r}`}function z(u,r,n){H(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&rt(r,u.length-(n+1))}function J(u,r,n,p,E,T){if(u>n||u<r){const B=typeof r=="bigint"?"n":"";let q;throw r===0||r===BigInt(0)?q=`>= 0${B} and < 2${B} ** ${(T+1)*8}${B}`:q=`>= -(2${B} ** ${(T+1)*8-1}${B}) and < 2 ** ${(T+1)*8-1}${B}`,new l.ERR_OUT_OF_RANGE("value",q,u)}z(p,E,T)}function H(u,r){if(typeof u!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",u)}function rt(u,r,n){throw Math.floor(u)!==u?(H(u,n),new l.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const ct=/[^+/0-9A-Za-z-_]/g;function Mt(u){if(u=u.split("=")[0],u=u.trim().replace(ct,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function et(u,r){r=r||1/0;let n;const p=u.length;let E=null;const T=[];for(let B=0;B<p;++B){if(n=u.charCodeAt(B),n>55295&&n<57344){if(!E){if(n>56319){(r-=3)>-1&&T.push(239,191,189);continue}else if(B+1===p){(r-=3)>-1&&T.push(239,191,189);continue}E=n;continue}if(n<56320){(r-=3)>-1&&T.push(239,191,189),E=n;continue}n=(E-55296<<10|n-56320)+65536}else E&&(r-=3)>-1&&T.push(239,191,189);if(E=null,n<128){if((r-=1)<0)break;T.push(n)}else if(n<2048){if((r-=2)<0)break;T.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;T.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;T.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return T}function Et(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function xe(u,r){let n,p,E;const T=[];for(let B=0;B<u.length&&!((r-=2)<0);++B)n=u.charCodeAt(B),p=n>>8,E=n%256,T.push(E),T.push(p);return T}function Kt(u){return t.toByteArray(Mt(u))}function It(u,r,n,p){let E;for(E=0;E<p&&!(E+n>=r.length||E>=u.length);++E)r[E+n]=u[E];return E}function _t(u,r){return u instanceof r||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===r.name}function we(u){return u!==u}const sr=(function(){const u="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let E=0;E<16;++E)r[p+E]=u[n]+u[E]}return r})();function Ft(u){return typeof BigInt>"u"?nr:u}function nr(){throw new Error("BigInt not supported")}})(re)),re}var Fe;function mi(){return Fe||(Fe=1,(function(h,t){var e=Ie(),i=e.Buffer;function s(a,o){for(var g in a)o[g]=a[g]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(a,o,g){return i(a,o,g)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(a,o,g){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,g)},c.alloc=function(a,o,g){if(typeof a!="number")throw new TypeError("Argument must be a number");var A=i(a);return o!==void 0?typeof g=="string"?A.fill(o,g):A.fill(o):A.fill(0),A},c.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i(a)},c.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(a)}})(zt,zt.exports)),zt.exports}var De;function _i(){if(De)return ie;De=1;var h=mi().Buffer,t=h.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(m){if(!m)return"utf8";for(var v;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(v)return;m=(""+m).toLowerCase(),v=!0}}function i(m){var v=e(m);if(typeof v!="string"&&(h.isEncoding===t||!t(m)))throw new Error("Unknown encoding: "+m);return v||m}ie.StringDecoder=s;function s(m){this.encoding=i(m);var v;switch(this.encoding){case"utf16le":this.text=C,this.end=S,v=4;break;case"utf8":this.fillLast=g,v=4;break;case"base64":this.text=F,this.end=I,v=3;break;default:this.write=N,this.end=R;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(v)}s.prototype.write=function(m){if(m.length===0)return"";var v,_;if(this.lastNeed){if(v=this.fillLast(m),v===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<m.length?v?v+this.text(m,_):this.text(m,_):v||""},s.prototype.end=x,s.prototype.text=A,s.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function c(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function a(m,v,_){var d=v.length-1;if(d<_)return 0;var b=c(v[d]);return b>=0?(b>0&&(m.lastNeed=b-1),b):--d<_||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(m.lastNeed=b-2),b):--d<_||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(b===2?b=0:m.lastNeed=b-3),b):0))}function o(m,v,_){if((v[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return m.lastNeed=2,"�"}}function g(m){var v=this.lastTotal-this.lastNeed,_=o(this,m);if(_!==void 0)return _;if(this.lastNeed<=m.length)return m.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,v,0,m.length),this.lastNeed-=m.length}function A(m,v){var _=a(this,m,v);if(!this.lastNeed)return m.toString("utf8",v);this.lastTotal=_;var d=m.length-(_-this.lastNeed);return m.copy(this.lastChar,0,d),m.toString("utf8",v,d)}function x(m){var v=m&&m.length?this.write(m):"";return this.lastNeed?v+"�":v}function C(m,v){if((m.length-v)%2===0){var _=m.toString("utf16le",v);if(_){var d=_.charCodeAt(_.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",v,m.length-1)}function S(m){var v=m&&m.length?this.write(m):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,_)}return v}function F(m,v){var _=(m.length-v)%3;return _===0?m.toString("base64",v):(this.lastNeed=3-_,this.lastTotal=3,_===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",v,m.length-_))}function I(m){var v=m&&m.length?this.write(m):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function N(m){return m.toString(this.encoding)}function R(m){return m&&m.length?this.write(m):""}return ie}var Ne;function gi(){return Ne||(Ne=1,(function(h){(function(t){t.parser=function(f,l){return new i(f,l)},t.SAXParser=i,t.SAXStream=x,t.createStream=A,t.MAX_BUFFER_LENGTH=65536;var e=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function i(f,l){if(!(this instanceof i))return new i(f,l);var M=this;c(M),M.q=M.c="",M.bufferCheckPosition=t.MAX_BUFFER_LENGTH,M.opt=l||{},M.opt.lowercase=M.opt.lowercase||M.opt.lowercasetags,M.looseCase=M.opt.lowercase?"toLowerCase":"toUpperCase",M.tags=[],M.closed=M.closedRoot=M.sawRoot=!1,M.tag=M.error=null,M.strict=!!f,M.noscript=!!(f||M.opt.noscript),M.state=y.BEGIN,M.strictEntities=M.opt.strictEntities,M.ENTITIES=M.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),M.attribList=[],M.opt.xmlns&&(M.ns=Object.create(N)),M.opt.unquotedAttributeValues===void 0&&(M.opt.unquotedAttributeValues=!f),M.trackPosition=M.opt.position!==!1,M.trackPosition&&(M.position=M.line=M.column=0),it(M,"onready")}Object.create||(Object.create=function(f){function l(){}l.prototype=f;var M=new l;return M}),Object.keys||(Object.keys=function(f){var l=[];for(var M in f)f.hasOwnProperty(M)&&l.push(M);return l});function s(f){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),M=0,w=0,z=e.length;w<z;w++){var J=f[e[w]].length;if(J>l)switch(e[w]){case"textNode":$(f);break;case"cdata":j(f,"oncdata",f.cdata),f.cdata="";break;case"script":j(f,"onscript",f.script),f.script="";break;default:at(f,"Max buffer length exceeded: "+e[w])}M=Math.max(M,J)}var H=t.MAX_BUFFER_LENGTH-M;f.bufferCheckPosition=H+f.position}function c(f){for(var l=0,M=e.length;l<M;l++)f[e[l]]=""}function a(f){$(f),f.cdata!==""&&(j(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(j(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ft(this)},write:Xt,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=fi.Stream}catch{o=function(){}}o||(o=function(){});var g=t.EVENTS.filter(function(f){return f!=="error"&&f!=="end"});function A(f,l){return new x(f,l)}function x(f,l){if(!(this instanceof x))return new x(f,l);o.apply(this),this._parser=new i(f,l),this.writable=!0,this.readable=!0;var M=this;this._parser.onend=function(){M.emit("end")},this._parser.onerror=function(w){M.emit("error",w),M._parser.error=null},this._decoder=null,g.forEach(function(w){Object.defineProperty(M,"on"+w,{get:function(){return M._parser["on"+w]},set:function(z){if(!z)return M.removeAllListeners(w),M._parser["on"+w]=z,z;M.on(w,z)},enumerable:!0,configurable:!1})})}x.prototype=Object.create(o.prototype,{constructor:{value:x}}),x.prototype.write=function(f){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(f)){if(!this._decoder){var l=_i().StringDecoder;this._decoder=new l("utf8")}f=this._decoder.write(f)}return this._parser.write(f.toString()),this.emit("data",f),!0},x.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},x.prototype.on=function(f,l){var M=this;return!M._parser["on"+f]&&g.indexOf(f)!==-1&&(M._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),M.emit.apply(M,w)}),o.prototype.on.call(M,f,l)};var C="[CDATA[",S="DOCTYPE",F="http://www.w3.org/XML/1998/namespace",I="http://www.w3.org/2000/xmlns/",N={xml:F,xmlns:I},R=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,v=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function d(f){return f===" "||f===`
2
- `||f==="\r"||f===" "}function b(f){return f==='"'||f==="'"}function P(f){return f===">"||d(f)}function U(f,l){return f.test(l)}function L(f,l){return!U(f,l)}var y=0;t.STATE={BEGIN:y++,BEGIN_WHITESPACE:y++,TEXT:y++,TEXT_ENTITY:y++,OPEN_WAKA:y++,SGML_DECL:y++,SGML_DECL_QUOTED:y++,DOCTYPE:y++,DOCTYPE_QUOTED:y++,DOCTYPE_DTD:y++,DOCTYPE_DTD_QUOTED:y++,COMMENT_STARTING:y++,COMMENT:y++,COMMENT_ENDING:y++,COMMENT_ENDED:y++,CDATA:y++,CDATA_ENDING:y++,CDATA_ENDING_2:y++,PROC_INST:y++,PROC_INST_BODY:y++,PROC_INST_ENDING:y++,OPEN_TAG:y++,OPEN_TAG_SLASH:y++,ATTRIB:y++,ATTRIB_NAME:y++,ATTRIB_NAME_SAW_WHITE:y++,ATTRIB_VALUE:y++,ATTRIB_VALUE_QUOTED:y++,ATTRIB_VALUE_CLOSED:y++,ATTRIB_VALUE_UNQUOTED:y++,ATTRIB_VALUE_ENTITY_Q:y++,ATTRIB_VALUE_ENTITY_U:y++,CLOSE_TAG:y++,CLOSE_TAG_SAW_WHITE:y++,SCRIPT:y++,SCRIPT_ENDING:y++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(f){var l=t.ENTITIES[f],M=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[f]=M});for(var G in t.STATE)t.STATE[t.STATE[G]]=G;y=t.STATE;function it(f,l,M){f[l]&&f[l](M)}function j(f,l,M){f.textNode&&$(f),it(f,l,M)}function $(f){f.textNode=lt(f.opt,f.textNode),f.textNode&&it(f,"ontext",f.textNode),f.textNode=""}function lt(f,l){return f.trim&&(l=l.trim()),f.normalize&&(l=l.replace(/\s+/g," ")),l}function at(f,l){return $(f),f.trackPosition&&(l+=`
1
+ var CanvasEnginePresets=(function(At,D,P){"use strict";function ii(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const e in h)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>h[e]})}}return t.default=h,Object.freeze(t)}const xt=ii(P);function te(h){var t=h.toString(16);return t.length==1?"0"+t:t}function ri(h,t,e){return"#"+te(h)+te(t)+te(e)}function si(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:l,border:o,innerMargin:y,borderRadius:C}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(v){C()?v.roundRect(0,0,t(),e(),C()):v.rect(0,0,t(),e()),o&&v.stroke(o),v.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(v){const B=y(),A=C(),I=Math.max(0,Math.min(t()-2*B,i()/s()*(t()-2*B))),M=e()-2*B;C?v.roundRect(B,B,I,M,A):v.rect(B,B,I,M);const N=l();if(N.startsWith("rgba")){const[O,_,E,m]=N.match(/\d+(\.\d+)?/g).map(Number);v.fill({color:ri(O,_,E),alpha:m})}else v.fill(N)}}))}class Ht{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Pt{constructor(t){this.data=t}update(t){}dispose(){}}class Se extends Pt{constructor(t){super(),this.componentId=t,this.exhausted=!1,this.completed=!1,this.name="",this.endTime=0,this._x=0,this._y=0,this._rotation=0,this._alpha=0,this._scale=new xt.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var ee;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(ee||(ee={}));class ie{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class Y{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Yt;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Yt||(Yt={}));class ni extends ie{constructor(){super(Yt.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let l=i.rotation;const o=Y.float(-s,s),y=Y.float(-c,c);l!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(l)-y*Math.sin(l),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(l)+y*Math.cos(l)):(t.component.x=this.__x+this._t*(this.x-this.__x)+o,t.component.y=this.__y+this._t*(this.y-this.__y)+y),e.radial?(l+=Math.atan2(y,o),t.dx=Math.cos(l),t.dy=Math.sin(l)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=l,this._t+=this._posInterpolationStep}}class ai extends ie{constructor(){super(Yt.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=Y.float(-e.angle*.5,e.angle*.5)+i.rotation:s=Y.float(0,6.28319)+i.rotation,e.radius>0){let c=Y.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c}else t.component.x=this.__x+this._t*(this.x-this.__x),t.component.y=this.__y+this._t*(this.y-this.__y);e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class oi extends ie{constructor(){super(Yt.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=Y.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var St;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(St||(St={}));class li extends xt.AnimatedSprite{constructor(t,e,i,s){let c=[],l=e.length;for(let o=0;o<l;o++)c.push(xt.Texture.from(e[o]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class ci{constructor(){}setRgb(t,e){this.startRgb=this.rgb=t,this.r=this.sR=t>>16&255,this.g=this.sG=t>>8&255,this.b=this.sB=t&255,this.targetRgb=e,this.dR=(e>>16&255)-this.r,this.dG=(e>>8&255)-this.g,this.dB=(e&255)-this.b}tween(t,e,i){return t?(this.r=t(e,this.sR,this.dR,i),this.g=t(e,this.sG,this.dG,i),this.b=t(e,this.sB,this.dB,i)):(e/=i,this.r=this.dR*e+this.sR,this.g=this.dG*e+this.sG,this.b=this.dB*e+this.sB),this.rgb=this.r<<16|this.g<<8|this.b,this.rgb}}var Ce;(function(h){h.Linear="linear",h.EaseInQuad="easeInQuad",h.EaseOutQuad="easeOutQuad",h.EaseInOutQuad="easeInOutQuad",h.EaseInCubic="easeInCubic",h.EaseOutCubic="easeOutCubic",h.EaseInOutCubic="easeInOutCubic",h.EaseInQuart="easeInQuart",h.EaseOutQuart="easeOutQuart",h.EaseInOutQuart="easeInOutQuart",h.EaseInQuint="easeInQuint",h.EaseOutQuint="easeOutQuint",h.EaseInOutQuint="easeInOutQuint",h.EaseInSine="easeInSine",h.EaseOutSine="easeOutSine",h.EaseInOutSine="easeInOutSine",h.EaseInExpo="easeInExpo",h.EaseOutExpo="easeOutExpo",h.EaseInOutExpo="easeInOutExpo",h.EaseInCirc="easeInCirc",h.EaseOutCirc="easeOutCirc",h.EaseInOutCirc="easeInOutCirc",h.EaseInElastic="easeInElastic",h.EaseOutElastic="easeOutElastic",h.EaseInOutElastic="easeInOutElastic",h.EaseInBack="easeInBack",h.EaseOutBack="easeOutBack",h.EaseInOutBack="easeInOutBack",h.EaseInBounce="easeInBounce",h.EaseOutBounce="easeOutBounce",h.EaseInOutBounce="easeInOutBounce"})(Ce||(Ce={}));class vt{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s),l||(l=s*.3),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l))+e}static easeOutElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s),l||(l=s*.3),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/l)+i+e}static easeInOutElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s/2),l||(l=s*.44999999999999996),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=vt.easeOutBounce(s-t,0,i,s),i-c+e}static easeOutBounce(t,e,i,s){return(t/=s)<.36363636363636365?i*(7.5625*t*t)+e:t<.7272727272727273?i*(7.5625*(t-=.5454545454545454)*t+.75)+e:t<.9090909090909091?i*(7.5625*(t-=.8181818181818182)*t+.9375)+e:i*(7.5625*(t-=.9545454545454546)*t+.984375)+e}static easeInOutBounce(t,e,i,s){let c;return t<s/2?(c=vt.easeInBounce(t*2,0,i,s),c*.5+e):(c=vt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class mt{constructor(){this.__hasCallback=!1,this._list=new Ht}add(t,e,i){this._list.add(new Pt(new Be(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Pt(new Be(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const l=i.data;l.callRate&&l.calls%l.callRate!=0&&(c=!1),c&&(l.callback.apply(l.scope,t),l.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Be{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let ui=class extends Pt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new mt,bounced:new mt,updated:new mt},this._color=new ci}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const l=this.duration=Y.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(s):t.container.addChildAt(s,0),s.blendMode=c.__getBlendMode(e.blendMode),this.startX=s.x,this.startY=s.y,this.useGravity=t.settings.useGravity,this.useScale=e.useScale,this.useRotation=e.useRotation,this.useAlpha=e.useAlpha,this.useTint=e.useTint,this.useSpawns=e.useSpawns,this.useChilds=e.useChilds,this.useMotion=e.useMotion,this.useGravity)if(this.gravity=t.settings.gravity,this.useFloor=t.settings.useFloor,this.floorY=t.settings.floorY,this.bounceFac=Y.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-Y.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=Y.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=o*this.dx*i,this.moveSpeedY=o*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const o=this.distance=Y.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+o*this.dx-this.startX)*.8,this.deltaY=(s.y+o*this.dy-this.startY)*.8,this.distanceEase=vt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=Y.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=Y.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=Y.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=vt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=l*(1-e.fadeInDurationFac),this.fadeInDuration=l*e.fadeInDurationFac,this.fadeInEase=vt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=vt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=Y.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(Y.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=Y.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(Y.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=vt[e.scaleXEase],this.scaleYStart=s.scale.y=Y.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(Y.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=vt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=l*(1-e.scaleInDurationFac),this.scaleInDuration=l*e.scaleInDurationFac,this.scaleInEase=vt[e.scaleInEase||"easeInSine"])):e.uniformScale?(s.scale.x=e.scaleStartMin,s.scale.y=e.scaleStartMin):(s.scale.x=e.scaleXStartMin,s.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=Y.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=Y.sign())),e.useTint&&(this.tintEase=vt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let o=e.childs.length;if(this._hasChildEmitters=o>0,this._childEmitters)for(;--o>-1;){const y=e.childs[o],C=c.getParticleEmitterById(y.id);C.init(t.container,!0,(y.scale||1)*(i||1)),y.adoptRotation&&(C.rotation=s.rotation,C.__adoptRotation=!0),C.__parent=this,this._childEmitters.push(C)}}return e.useSpawns&&(e.spawn.onStart.length>0&&t.__subSpawn(this,e.spawn.onStart),this._spawnOnHalfway=e.spawn.onHalfway.length>0),t.__on.particleSpawned.__hasCallback&&t.__on.particleSpawned.dispatch(this),this}update(t){const e=this.time+=t,i=this.duration;if(e>=i){this.emitter.__removeParticle(this);return}const s=this.component,c=e*t;if(this.useGravity){const l=t/.0166666;if(s.x+=this.moveSpeedX*l,s.y+=this.moveSpeedY*l,this.moveSpeedY+=this.gravity*l,this.useAlign&&(s.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&s.y>this.floorY){s.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const o=this.emitter;o.__on.particleBounced.__hasCallback&&o.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&o.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(s.x=this.distanceEase(e,this.startX,this.deltaX,i),s.y=this.distanceEase(e,this.startY,this.deltaY,i)):(s.x=this.deltaX*c+this.startX,s.y=this.deltaY*c+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?s.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):s.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?s.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):s.alpha=this.alphaDelta*c+this.alphaStart),this.useRotation&&(s.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?s.scale.x=s.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):s.scale.x=s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(s.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),s.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):s.scale.x=s.scale.y=this.scaleDelta*c+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(s.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),s.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(s.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?s.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):s.scale.x=this.scaleXDelta*c+this.scaleXStart,this.scaleYEase?s.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):s.scale.y=this.scaleYDelta*c+this.scaleYStart)),this.useTint&&(s.tint=this._color.tween(this.tintEase,e,i)),this._spawnOnHalfway&&e>=.5&&(this._spawnOnHalfway=!1,this.emitter.__subSpawn(this,this.settings.spawn.onHalfway)),this.useChilds&&this._hasChildEmitters){const l=this._childEmitters;let o=l.length;for(;--o>-1;){const y=l[o];y.__recycled||(y.x=s.position.x,y.y=s.position.y,y.__adoptRotation&&(y.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class Ct{static sanitizeBundle(t){for(let e of t.emitters){const i=Ct._presetStructure.emitter;Ct.parse(e,i,Ct._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Ct._presetStructure.sequence;Ct.parse(e,i,Ct._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let s in e)if(t[s]==null)t[s]=e[s];else{const c=t[s];if(typeof c!="object")continue;const l=e[s];if(!c.hasOwnProperty("length"))Ct.parse(c,l,i);else for(let o of c)for(let y in i)o[y]==null&&(o[y]=i[y])}}}Ct._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class hi extends xt.Sprite{constructor(t,e,i,s){super(xt.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Ut(h){if(typeof h!="object"||h===null)return h;const t=Array.isArray(h)?[]:{};for(const e in h){const i=h[e];t[e]=Ut(i)}return t}var fi=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(l){l(c)})}return new(e||(e=Promise))(function(c,l){function o(v){try{C(i.next(v))}catch(B){l(B)}}function y(v){try{C(i.throw(v))}catch(B){l(B)}}function C(v){v.done?c(v.value):s(v.value).then(o,y)}C((i=i.apply(h,t||[])).next())})};class Et{constructor(){this.useBlendModes=!0,this.particleCount=0,this.emitterCount=0,this.effectSequenceCount=0,this.maxParticles=5e3,this.particleFac=1,this._active=!1,this._effects=new Ht,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,l;for(;c;)l=c.next,c.update(i),c=l;this._timeElapsed=e}clearCache(){this._cache={particles:[],mcs:[],sprites:[],effectSequences:[],emitters:[],cores:{}},this._settingsCache={mcs:{},sprites:{},emitters:{},effectSequences:{}},this._nameMaps={emitters:{},effectSequences:{}}}setFloorY(t){const e=this._settingsCache.emitters;for(let i in e)e[i].floorY=t}dispose(){let t=this._effects,e=t.first;for(;e;)e.dispose(),e=e.next;t.clear(),this.clearCache()}loadBundleFiles(t,e,i="",s=[]){return new Promise((c,l)=>fi(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)o[y]=s[y];xt.Assets.addBundle("rfx_assets",o);const C=yield xt.Assets.loadBundle("rfx_assets");c(this.initBundle(C.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Et._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Et.settingsVersion)throw new Error("Settings version mismatch.");Ct.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const s=t.emitters[i];this.addParticleEmitter(s.id,s)}for(let i in t.sequences){const s=t.sequences[i];this.addEffectSequence(s.id,s)}return this.useBlendModes=t.useBlendModes,this.maxParticles=t.maxParticles,this.parseTextureCache(t.spritesheetFilter)}addParticleEmitter(t,e){if(this._settingsCache.emitters[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.emitters[t]=e,this._nameMaps.emitters[e.name]=e,this}addEffectSequence(t,e){if(this._settingsCache.effectSequences[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.effectSequences[t]=e,this._nameMaps.effectSequences[e.name]=e,this}initSprite(t,e){if(this._settingsCache.sprites[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.sprites[t]=e,this}initMovieClip(t,e){if(this._settingsCache.mcs[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.mcs[t]=e,this}getMovieClips(){return this._settingsCache.mcs}getSprites(){return this._settingsCache.sprites}addContainer(t,e){this.__containers[t]=e}getEffectSequence(t,e=!1){const i=this._nameMaps.effectSequences[t];if(!i)throw new Error(`Settings not defined for '${t}'`);return this.getEffectSequenceById(i.id,e)}getEffectSequenceById(t,e=!1){const i=this._cache.effectSequences;let s,c=this._settingsCache.effectSequences[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(s=new Me(t),s.__fx=this):s=i.pop(),e&&(c=Ut(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,l=this._settingsCache.emitters[t];if(!l)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new re(t),c.__fx=this):c=s.pop(),i&&(l=Ut(l),l.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(l),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new re(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Me(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(xt.Cache._cache,t)}get active(){return this._active}__addActiveEffect(t){this._effects.add(t)}__removeActiveEffect(t){this._effects.remove(t)}__getSprite(t){const e=this._cache.sprites;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){const s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new hi(t,s.texture,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getMovieClip(t){const e=this._cache.mcs;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){let s=this._settingsCache.mcs[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new li(t,s.textures,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new ui;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new Et.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return xt.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Et._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const l=t;l.values();for(const[o,y]of l)y instanceof xt.Texture&&(i[o]=y)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let l in i)if(!(e&&l.indexOf(e)==-1)&&(this.initSprite(l,{texture:l,anchorX:.5,anchorY:.5}),c.sprites.push(l),l.substr(0,3)=="mc_")){const y=l.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(l)}for(let l in s){let o=s[l];c.movieClips.push(l),this.initMovieClip(l,{textures:o,anchorX:.5,anchorY:.5})}return c}}Et.settingsVersion=0,Et.version="1.3.4",Et._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Et.ComponentType=ee,Et.EffectSequenceComponentType=St,Et._blendModes=["normal","add","multiply","screen"],Et.__emitterCores={circle:ai,box:ni,ring:oi};var Lt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Lt||(Lt={}));class re extends Se{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new Ht,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new mt,completed:new mt,exhausted:new mt,particleUpdated:new mt,particleSpawned:new mt,particleBounced:new mt,particleDied:new mt}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],l=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[l.settings.containerId]||this.container;l.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(l.rotation=this._rotation,l.__adoptRotation=!0),l.__parent=this,this._childEmitters.push(l)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+Y.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,l;for(;c;)l=c.next,c.update(t),c=l;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=Y.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let l;switch(s.componentType){case 0:c.componentId=s.componentId,l=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,l=e.__getMovieClip(c.componentId),s.componentParams&&(l.loop=!(s.componentParams.loop==null||!s.componentParams.loop),l.animationSpeed=Y.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),l.gotoAndPlay(0);break}l.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=l,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=Y.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let l,o;switch(c.type){case 0:l=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[l.settings.containerId]||this.container,l.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(l.rotation=t.component.rotation+l.settings.rotation,l.__adoptRotation=!0):l.rotation=l.settings.rotation;break;case 1:l=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[l.settings.containerId]||this.container,l.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(l.rotation=t.component.rotation);break}l.x=t.component.x,l.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const l=i[c];for(const o of l){switch(o.type){case Lt.ParticleEmitter:o.settings=Ut(e.__getEmitterSettings(o.id));break;case Lt.EffectSequence:o.settings=Ut(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Lt.ParticleEmitter:c.settings=Ut(e.__getEmitterSettings(c.id));break;case Lt.EffectSequence:c.settings=Ut(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class Me extends Se{constructor(t){super(t),this._list=[],this._elements=new Ht,this.__on={started:new mt,completed:new mt,exhausted:new mt,effectSpawned:new mt,triggerActivated:new mt}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,l=this._nextEffectSettings;let o,y,C;switch(l.componentType){case St.Sprite:o=c.__getSprite(l.componentId),C=c.__containers[l.containerId]||this.container,C.addChild(o),o.blendMode=c.__getBlendMode(l.blendMode),o.tint=l.tint,o.scale.set(Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=Y.float(l.alphaMin,l.alphaMax),o.anchor.set(l.componentParams.anchorX,l.componentParams.anchorY),y=new Pt({component:o,endTime:e+l.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+Y.float(l.rotationMin,l.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.Sprite,o);break;case St.MovieClip:o=c.__getMovieClip(l.componentId),l.componentParams.loop?(o.animationSpeed=Y.float(l.componentParams.animationSpeedMin||1,l.componentParams.animationSpeedMax||1),o.loop=l.componentParams.loop||!1):l.duration,o.anchor.set(l.componentParams.anchorX,l.componentParams.anchorY),o.gotoAndPlay(0),C=c.__containers[l.containerId]||this.container,C.addChild(o),o.blendMode=c.__getBlendMode(l.blendMode),o.tint=l.tint,o.scale.set(Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=Y.float(l.alphaMin,l.alphaMax),y=new Pt({component:o,endTime:e+l.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+Y.float(l.rotationMin,l.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.MovieClip,o);break;case St.Emitter:o=c.getParticleEmitterById(l.componentId),C=c.__containers[l.containerId]||this.container,o.init(C,!0,Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Pt({component:o,endTime:o.endTime}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+o.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.Emitter,o);break;case St.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(l.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof re?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function di(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new Et;let c;return xt.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),xt.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:l})=>{s.update(l)}),D.mount(async l=>{c=l;let y={...(await xt.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const v=e.emitters.map((B,A)=>({...B,id:1e4+A}));y.emitters=[...y.emitters,...v]}s.initBundle(y,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}const pi=`/**
2
+ * Night + spot light + fog fragment shader.
3
+ * - Supports multiple circular spots (uSpots) in normalized screen space.
4
+ * - Each spot is vec4(x, y, radius, intensity) in normalized coordinates.
5
+ * - Fog is based on the nearest light source so illuminated areas stay readable.
6
+ * - Dark zones are tinted with uDarkColor for colored night effects.
7
+ */
8
+ in vec2 vTextureCoord;
9
+
10
+ out vec4 finalColor;
11
+
12
+ uniform sampler2D uTexture;
13
+ uniform vec4 uSpots[24];
14
+ uniform float uAspect;
15
+ uniform float uDarkness;
16
+ uniform vec3 uDarkColor;
17
+ uniform vec3 uFogColor;
18
+ uniform float uFogRadius;
19
+ uniform float uFogSoftness;
20
+
21
+ void main() {
22
+ vec4 color = texture(uTexture, vTextureCoord);
23
+ float light = 0.0;
24
+ float nearestDist = 1.0;
25
+
26
+ for (int i = 0; i < 24; i++) {
27
+ vec4 spotData = uSpots[i];
28
+ vec2 lightPos = spotData.xy;
29
+ float radius = max(spotData.z, 0.0001);
30
+ float intensity = max(spotData.w, 0.0);
31
+ if (intensity <= 0.0001) continue;
32
+
33
+ vec2 delta = vTextureCoord - lightPos;
34
+ delta.x *= uAspect;
35
+ float dist = length(delta);
36
+ float spot = (1.0 - smoothstep(0.0, radius, dist)) * intensity;
37
+ light = clamp(light + spot, 0.0, 1.0);
38
+ nearestDist = min(nearestDist, dist);
39
+ }
40
+
41
+ // Night: full brightness where light is strong, darker elsewhere.
42
+ // Apply dark color tint in unlit areas.
43
+ float factor = mix(1.0 - uDarkness, 1.0, light);
44
+ vec3 darkened = color.rgb * factor;
45
+ // Blend towards dark color in unlit areas (when factor < 1)
46
+ float darkTint = (1.0 - factor) * uDarkness;
47
+ color.rgb = mix(darkened, uDarkColor, darkTint);
48
+
49
+ // Fog fades in with distance to nearest light, but less inside lit areas.
50
+ float fogFactor = smoothstep(uFogRadius, uFogRadius + uFogSoftness, nearestDist);
51
+ fogFactor *= (1.0 - light * 0.7);
52
+ color.rgb = mix(color.rgb, uFogColor, clamp(fogFactor, 0.0, 1.0));
53
+
54
+ finalColor = color;
55
+ }
56
+ `,mi=`/**
57
+ * Default Pixi filter vertex shader.
58
+ * Outputs vTextureCoord (0-1) for sampling the input texture in fragment shader.
59
+ */
60
+ in vec2 aPosition;
61
+ out vec2 vTextureCoord;
62
+
63
+ uniform vec4 uInputSize;
64
+ uniform vec4 uOutputFrame;
65
+ uniform vec4 uOutputTexture;
66
+
67
+ vec4 filterVertexPosition(void) {
68
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
69
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
70
+ position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
71
+ return vec4(position, 0.0, 1.0);
72
+ }
73
+
74
+ vec2 filterTextureCoord(void) {
75
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
76
+ }
77
+
78
+ void main(void) {
79
+ gl_Position = filterVertexPosition();
80
+ vTextureCoord = filterTextureCoord();
81
+ }
82
+ `,se=24,_i=180,gi=.75,yi=.5,xi=.35,Ei=new Float32Array([.08,.08,.14]),$t=h=>{if(typeof h=="string"){let t=h.replace(/^#/,"");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);const e=parseInt(t,16);return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255])}if(typeof h=="number")return new Float32Array([(h>>16&255)/255,(h>>8&255)/255,(h&255)/255]);if(Array.isArray(h)&&h.length>=3){const t=h.every(e=>e<=1);return new Float32Array(t?h:h.map(e=>e/255))}return new Float32Array([0,0,0])};function Fe(h,t){const e=new Float32Array(se*4),i={value:e,type:"vec4<f32>",size:se},s={value:1,type:"f32"},c={value:t?.darkness??gi,type:"f32"},l={value:t?.fogColor?$t(t.fogColor):Ei,type:"vec3<f32>"},o={value:t?.fogRadius??yi,type:"f32"},y={value:t?.fogSoftness??xi,type:"f32"},C={value:t?.darkColor?$t(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let v=t?.spots?[...t.spots]:[],B=t?.lightWorldPosition??null;const A=P.Filter.from({gl:{vertex:mi,fragment:pi},resources:{nightUniforms:{uSpots:i,uAspect:s,uDarkness:c,uDarkColor:C,uFogColor:l,uFogRadius:o,uFogSoftness:y}}}),I=(m,d,b)=>Math.min(Math.max(m,d),b),M=()=>Date.now()/1e3,N=()=>B?[{x:B.x,y:B.y},...v]:v,O=()=>{const m=N(),d=Math.min(m.length,se),b=h?.getVisibleBounds?.()??t?.getBounds?.(),R=!!b&&b.width>0&&b.height>0,U=M();R&&(s.value=b.width/b.height),e.fill(0);for(let k=0;k<d;k++){const g=m[k],V=g.radius??_i,j=I(g.intensity??1,0,2),z=g.phase??k*.7;let Q=j;if(g.flicker){const nt=g.flickerSpeed??12;Q*=.88+.12*Math.sin(U*nt+z)}if(g.pulse){const nt=g.pulseSpeed??2;Q*=.8+.2*Math.sin(U*nt+z)}let ut=g.x,tt=g.y,ht=.15;R&&(ut=(g.x-b.x)/b.width,tt=(g.y-b.y)/b.height,ht=V/b.height);const L=k*4;e[L]=ut,e[L+1]=tt,e[L+2]=ht,e[L+3]=I(Q,0,2)}i.value=e},_=A.apply.bind(A);A.apply=((...m)=>(O(),_(...m)));const E=A;return E.setLightWorldPosition=m=>{B=m,O()},E.getLightWorldPosition=()=>B,E.setSpots=m=>{v=[...m],O()},E.getSpots=()=>N().map(m=>({...m})),E.syncLightToViewport=O,E.setDarkness=m=>{c.value=m},E.setDarkColor=m=>{C.value=$t(m)},E.setFogColor=m=>{l.value=$t(m)},E.setFogRadius=m=>{o.value=m},E.setFogSoftness=m=>{y.value=m},O(),E}const st=h=>typeof h=="function"?h():h,_t=h=>typeof h=="number"&&Number.isFinite(h),wi=h=>{const t=st(h);if(!t)return null;const e=st(t.x),i=st(t.y);if(!_t(e)||!_t(i))return null;const s=st(t.radius),c=st(t.intensity),l=st(t.flickerSpeed),o=st(t.pulseSpeed),y=st(t.phase);return{x:e,y:i,radius:_t(s)?s:void 0,intensity:_t(c)?c:void 0,flicker:!!st(t.flicker),flickerSpeed:_t(l)?l:void 0,pulse:!!st(t.pulse),pulseSpeed:_t(o)?o:void 0,phase:_t(y)?y:void 0}},Ie=h=>{const t=st(h);return Array.isArray(t)?t.map(wi).filter(e=>!!e):[]},vi=h=>{if(!h)return null;if(typeof h.getVisibleBounds=="function"){const t=h.getVisibleBounds();if(t)return t}if(typeof h.getLocalBounds=="function"){const t=h.getLocalBounds();if(t)return t}return _t(h.width)&&_t(h.height)?{x:0,y:0,width:h.width,height:h.height}:null};function bi(h={}){const t=D.useProps(h),e=()=>t.lightSpots??t.spots;return D.mount(i=>{const c=i.props.context?.viewport,l=c??i.parent?.componentInstance;if(!l)return;const o=st(t.darkness),y=st(t.darkColor),C=st(t.fogColor),v=st(t.fogRadius),B=st(t.fogSoftness),A=Fe(c,{spots:Ie(e()),getBounds:()=>vi(l),darkness:_t(o)?o:void 0,darkColor:y??void 0,fogColor:C??void 0,fogRadius:_t(v)?v:void 0,fogSoftness:_t(B)?B:void 0}),I=Array.isArray(l.filters)?l.filters:[];return I.includes(A)||(l.filters=[...I,A]),D.effect(()=>{A.setSpots(Ie(e()))}),D.effect(()=>{const M=st(t.darkness);_t(M)&&A.setDarkness(M)}),D.effect(()=>{const M=st(t.darkColor);M!==void 0&&A.setDarkColor(M)}),D.effect(()=>{const M=st(t.fogColor);M!==void 0&&A.setFogColor(M)}),D.effect(()=>{const M=st(t.fogRadius);_t(M)&&A.setFogRadius(M)}),D.effect(()=>{const M=st(t.fogSoftness);_t(M)&&A.setFogSoftness(M)}),()=>{const N=(Array.isArray(l.filters)?l.filters:[]).filter(O=>O!==A);l.filters=N.length>0?N:null}}),D.h(D.Container)}function Ti(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:l=3,inactiveAlpha:o=.15}=D.useProps(h,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),y=D.signal(0);D.tick(({deltaTime:M})=>{const O=(typeof s=="function"?s():s)*M/1e3;y.set(y()+O)});const C=M=>{const N=typeof t=="function"?t():t,O=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,E=typeof c=="function"?c():c;typeof l=="function"&&l();const m=typeof o=="function"?o():o,d=y();_&&M.circle(0,0,N).fill(_);const b=360/E,R=N*.4,U=N;for(let k=0;k<E;k++){const g=k*b,V=(d%360+360)%360;let j=Math.abs(V-g);j>180&&(j=360-j);let Q=j/120;Q=Math.min(1,Q),Q=Q*Q*Q;const ut=m+(1-Q)*(1-m),tt=g*(Math.PI/180),ht=b*(Math.PI/180),L=tt-ht/2,nt=tt+ht/2;M.arc(0,0,R,L,nt).arc(0,0,U,nt,L,!0).fill({color:O,alpha:ut})}},B=(typeof t=="function"?t():t)*2,A=D.signal(B),I=D.signal(B);return typeof t=="function"&&D.effect(()=>{const M=t();A.set(M*2),I.set(M*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:C})])}var Vt=(h=>(h.Tile="tilelayer",h.ObjectGroup="objectgroup",h.Image="imagelayer",h.Group="group",h))(Vt||{});function De(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function Ai(h){if(Object.prototype.hasOwnProperty.call(h,"__esModule"))return h;var t=h.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(h).forEach(function(i){var s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return h[i]}})}),e}var ne={};const Si=Ai(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ae={},Xt={exports:{}},oe={},Gt={},Ne;function Ci(){if(Ne)return Gt;Ne=1,Gt.byteLength=o,Gt.toByteArray=C,Gt.fromByteArray=A;for(var h=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)h[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function l(I){var M=I.length;if(M%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=I.indexOf("=");N===-1&&(N=M);var O=N===M?0:4-N%4;return[N,O]}function o(I){var M=l(I),N=M[0],O=M[1];return(N+O)*3/4-O}function y(I,M,N){return(M+N)*3/4-N}function C(I){var M,N=l(I),O=N[0],_=N[1],E=new e(y(I,O,_)),m=0,d=_>0?O-4:O,b;for(b=0;b<d;b+=4)M=t[I.charCodeAt(b)]<<18|t[I.charCodeAt(b+1)]<<12|t[I.charCodeAt(b+2)]<<6|t[I.charCodeAt(b+3)],E[m++]=M>>16&255,E[m++]=M>>8&255,E[m++]=M&255;return _===2&&(M=t[I.charCodeAt(b)]<<2|t[I.charCodeAt(b+1)]>>4,E[m++]=M&255),_===1&&(M=t[I.charCodeAt(b)]<<10|t[I.charCodeAt(b+1)]<<4|t[I.charCodeAt(b+2)]>>2,E[m++]=M>>8&255,E[m++]=M&255),E}function v(I){return h[I>>18&63]+h[I>>12&63]+h[I>>6&63]+h[I&63]}function B(I,M,N){for(var O,_=[],E=M;E<N;E+=3)O=(I[E]<<16&16711680)+(I[E+1]<<8&65280)+(I[E+2]&255),_.push(v(O));return _.join("")}function A(I){for(var M,N=I.length,O=N%3,_=[],E=16383,m=0,d=N-O;m<d;m+=E)_.push(B(I,m,m+E>d?d:m+E));return O===1?(M=I[N-1],_.push(h[M>>2]+h[M<<4&63]+"==")):O===2&&(M=(I[N-2]<<8)+I[N-1],_.push(h[M>>10]+h[M>>4&63]+h[M<<2&63]+"=")),_.join("")}return Gt}var Qt={};var Oe;function Bi(){return Oe||(Oe=1,Qt.read=function(h,t,e,i,s){var c,l,o=s*8-i-1,y=(1<<o)-1,C=y>>1,v=-7,B=e?s-1:0,A=e?-1:1,I=h[t+B];for(B+=A,c=I&(1<<-v)-1,I>>=-v,v+=o;v>0;c=c*256+h[t+B],B+=A,v-=8);for(l=c&(1<<-v)-1,c>>=-v,v+=i;v>0;l=l*256+h[t+B],B+=A,v-=8);if(c===0)c=1-C;else{if(c===y)return l?NaN:(I?-1:1)*(1/0);l=l+Math.pow(2,i),c=c-C}return(I?-1:1)*l*Math.pow(2,c-i)},Qt.write=function(h,t,e,i,s,c){var l,o,y,C=c*8-s-1,v=(1<<C)-1,B=v>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=i?0:c-1,M=i?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,l=v):(l=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-l))<1&&(l--,y*=2),l+B>=1?t+=A/y:t+=A*Math.pow(2,1-B),t*y>=2&&(l++,y/=2),l+B>=v?(o=0,l=v):l+B>=1?(o=(t*y-1)*Math.pow(2,s),l=l+B):(o=t*Math.pow(2,B-1)*Math.pow(2,s),l=0));s>=8;h[e+I]=o&255,I+=M,o/=256,s-=8);for(l=l<<s|o,C+=s;C>0;h[e+I]=l&255,I+=M,l/=256,C-=8);h[e+I-M]|=N*128}),Qt}var Re;function Pe(){return Re||(Re=1,(function(h){const t=Ci(),e=Bi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=E,h.INSPECT_MAX_BYTES=50;const s=2147483647;h.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=c(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const u=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(u,r),u.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function l(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const r=new Uint8Array(u);return Object.setPrototypeOf(r,o.prototype),r}function o(u,r,n){if(typeof u=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(u)}return y(u,r,n)}o.poolSize=8192;function y(u,r,n){if(typeof u=="string")return A(u,r);if(ArrayBuffer.isView(u))return M(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(wt(u,ArrayBuffer)||u&&wt(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(wt(u,SharedArrayBuffer)||u&&wt(u.buffer,SharedArrayBuffer)))return N(u,r,n);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=u.valueOf&&u.valueOf();if(p!=null&&p!==u)return o.from(p,r,n);const x=O(u);if(x)return x;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return o.from(u[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}o.from=function(u,r,n){return y(u,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function C(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function v(u,r,n){return C(u),u<=0?l(u):r!==void 0?typeof n=="string"?l(u).fill(r,n):l(u).fill(r):l(u)}o.alloc=function(u,r,n){return v(u,r,n)};function B(u){return C(u),l(u<0?0:_(u)|0)}o.allocUnsafe=function(u){return B(u)},o.allocUnsafeSlow=function(u){return B(u)};function A(u,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=m(u,r)|0;let p=l(n);const x=p.write(u,r);return x!==n&&(p=p.slice(0,x)),p}function I(u){const r=u.length<0?0:_(u.length)|0,n=l(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function M(u){if(wt(u,Uint8Array)){const r=new Uint8Array(u);return N(r.buffer,r.byteOffset,r.byteLength)}return I(u)}function N(u,r,n){if(r<0||u.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(u):n===void 0?p=new Uint8Array(u,r):p=new Uint8Array(u,r,n),Object.setPrototypeOf(p,o.prototype),p}function O(u){if(o.isBuffer(u)){const r=_(u.length)|0,n=l(r);return n.length===0||u.copy(n,0,0,r),n}if(u.length!==void 0)return typeof u.length!="number"||Ae(u.length)?l(0):I(u);if(u.type==="Buffer"&&Array.isArray(u.data))return I(u.data)}function _(u){if(u>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return u|0}function E(u){return+u!=u&&(u=0),o.alloc(+u)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(wt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),wt(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let p=r.length,x=n.length;for(let T=0,F=Math.min(p,x);T<F;++T)if(r[T]!==n[T]){p=r[T],x=n[T];break}return p<x?-1:x<p?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const x=o.allocUnsafe(n);let T=0;for(p=0;p<r.length;++p){let F=r[p];if(wt(F,Uint8Array))T+F.length>x.length?(o.isBuffer(F)||(F=o.from(F)),F.copy(x,T)):Uint8Array.prototype.set.call(x,F,T);else if(o.isBuffer(F))F.copy(x,T);else throw new TypeError('"list" argument must be an Array of Buffers');T+=F.length}return x};function m(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||wt(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);const n=u.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let x=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return at(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return zt(u).length;default:if(x)return p?-1:at(u).length;r=(""+r).toLowerCase(),x=!0}}o.byteLength=m;function d(u,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(u||(u="utf8");;)switch(u){case"hex":return dt(this,r,n);case"utf8":case"utf-8":return ut(this,r,n);case"ascii":return L(this,r,n);case"latin1":case"binary":return nt(this,r,n);case"base64":return Q(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),p=!0}}o.prototype._isBuffer=!0;function b(u,r,n){const p=u[r];u[r]=u[n],u[n]=p}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?ut(this,0,r):d.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const n=h.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(r,n,p,x,T){if(wt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),x===void 0&&(x=0),T===void 0&&(T=this.length),n<0||p>r.length||x<0||T>this.length)throw new RangeError("out of range index");if(x>=T&&n>=p)return 0;if(x>=T)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,x>>>=0,T>>>=0,this===r)return 0;let F=T-x,G=p-n;const it=Math.min(F,G),Z=this.slice(x,T),rt=r.slice(n,p);for(let H=0;H<it;++H)if(Z[H]!==rt[H]){F=Z[H],G=rt[H];break}return F<G?-1:G<F?1:0};function R(u,r,n,p,x){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ae(n)&&(n=x?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(x)return-1;n=u.length-1}else if(n<0)if(x)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,p)),o.isBuffer(r))return r.length===0?-1:U(u,r,n,p,x);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?x?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):U(u,[r],n,p,x);throw new TypeError("val must be string, number or Buffer")}function U(u,r,n,p,x){let T=1,F=u.length,G=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(u.length<2||r.length<2)return-1;T=2,F/=2,G/=2,n/=2}function it(rt,H){return T===1?rt[H]:rt.readUInt16BE(H*T)}let Z;if(x){let rt=-1;for(Z=n;Z<F;Z++)if(it(u,Z)===it(r,rt===-1?0:Z-rt)){if(rt===-1&&(rt=Z),Z-rt+1===G)return rt*T}else rt!==-1&&(Z-=Z-rt),rt=-1}else for(n+G>F&&(n=F-G),Z=n;Z>=0;Z--){let rt=!0;for(let H=0;H<G;H++)if(it(u,Z+H)!==it(r,H)){rt=!1;break}if(rt)return Z}return-1}o.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},o.prototype.indexOf=function(r,n,p){return R(this,r,n,p,!0)},o.prototype.lastIndexOf=function(r,n,p){return R(this,r,n,p,!1)};function k(u,r,n,p){n=Number(n)||0;const x=u.length-n;p?(p=Number(p),p>x&&(p=x)):p=x;const T=r.length;p>T/2&&(p=T/2);let F;for(F=0;F<p;++F){const G=parseInt(r.substr(F*2,2),16);if(Ae(G))return F;u[n+F]=G}return F}function g(u,r,n,p){return Ot(at(r,u.length-n),u,n,p)}function V(u,r,n,p){return Ot(Tt(r),u,n,p)}function j(u,r,n,p){return Ot(zt(r),u,n,p)}function z(u,r,n,p){return Ot(Te(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,x){if(n===void 0)x="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")x=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,x===void 0&&(x="utf8")):(x=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const T=this.length-n;if((p===void 0||p>T)&&(p=T),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");let F=!1;for(;;)switch(x){case"hex":return k(this,r,n,p);case"utf8":case"utf-8":return g(this,r,n,p);case"ascii":case"latin1":case"binary":return V(this,r,n,p);case"base64":return j(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,r,n,p);default:if(F)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),F=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function ut(u,r,n){n=Math.min(u.length,n);const p=[];let x=r;for(;x<n;){const T=u[x];let F=null,G=T>239?4:T>223?3:T>191?2:1;if(x+G<=n){let it,Z,rt,H;switch(G){case 1:T<128&&(F=T);break;case 2:it=u[x+1],(it&192)===128&&(H=(T&31)<<6|it&63,H>127&&(F=H));break;case 3:it=u[x+1],Z=u[x+2],(it&192)===128&&(Z&192)===128&&(H=(T&15)<<12|(it&63)<<6|Z&63,H>2047&&(H<55296||H>57343)&&(F=H));break;case 4:it=u[x+1],Z=u[x+2],rt=u[x+3],(it&192)===128&&(Z&192)===128&&(rt&192)===128&&(H=(T&15)<<18|(it&63)<<12|(Z&63)<<6|rt&63,H>65535&&H<1114112&&(F=H))}}F===null?(F=65533,G=1):F>65535&&(F-=65536,p.push(F>>>10&1023|55296),F=56320|F&1023),p.push(F),x+=G}return ht(p)}const tt=4096;function ht(u){const r=u.length;if(r<=tt)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=tt));return n}function L(u,r,n){let p="";n=Math.min(u.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(u[x]&127);return p}function nt(u,r,n){let p="";n=Math.min(u.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(u[x]);return p}function dt(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let x="";for(let T=r;T<n;++T)x+=yr[u[T]];return x}function yt(u,r,n){const p=u.slice(r,n);let x="";for(let T=0;T<p.length-1;T+=2)x+=String.fromCharCode(p[T]+p[T+1]*256);return x}o.prototype.slice=function(r,n){const p=this.length;r=~~r,n=n===void 0?p:~~n,r<0?(r+=p,r<0&&(r=0)):r>p&&(r=p),n<0?(n+=p,n<0&&(n=0)):n>p&&(n=p),n<r&&(n=r);const x=this.subarray(r,n);return Object.setPrototypeOf(x,o.prototype),x};function K(u,r,n){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r],T=1,F=0;for(;++F<n&&(T*=256);)x+=this[r+F]*T;return x},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r+--n],T=1;for(;n>0&&(T*=256);)x+=this[r+--n]*T;return x},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||K(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||K(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||K(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||K(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,T=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(x)+(BigInt(T)<<BigInt(32))}),o.prototype.readBigUInt64BE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],T=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(x)<<BigInt(32))+BigInt(T)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r],T=1,F=0;for(;++F<n&&(T*=256);)x+=this[r+F]*T;return T*=128,x>=T&&(x-=Math.pow(2,8*n)),x},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=n,T=1,F=this[r+--x];for(;x>0&&(T*=256);)F+=this[r+--x]*T;return T*=128,F>=T&&(F-=Math.pow(2,8*n)),F},o.prototype.readInt8=function(r,n){return r=r>>>0,n||K(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||K(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||K(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(x)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),o.prototype.readBigInt64BE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(x)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||K(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||K(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||K(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||K(r,8,this.length),e.read(this,r,!1,52,8)};function W(u,r,n,p,x,T){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>x||r<T)throw new RangeError('"value" argument is out of bounds');if(n+p>u.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const G=Math.pow(2,8*p)-1;W(this,r,n,p,G,0)}let T=1,F=0;for(this[n]=r&255;++F<p&&(T*=256);)this[n+F]=r/T&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const G=Math.pow(2,8*p)-1;W(this,r,n,p,G,0)}let T=p-1,F=1;for(this[n+T]=r&255;--T>=0&&(F*=256);)this[n+T]=r/F&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function ft(u,r,n,p,x){et(r,p,x,u,n,7);let T=Number(r&BigInt(4294967295));u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T;let F=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=F,F=F>>8,u[n++]=F,F=F>>8,u[n++]=F,F=F>>8,u[n++]=F,n}function ct(u,r,n,p,x){et(r,p,x,u,n,7);let T=Number(r&BigInt(4294967295));u[n+7]=T,T=T>>8,u[n+6]=T,T=T>>8,u[n+5]=T,T=T>>8,u[n+4]=T;let F=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=F,F=F>>8,u[n+2]=F,F=F>>8,u[n+1]=F,F=F>>8,u[n]=F,n+8}o.prototype.writeBigUInt64LE=Rt(function(r,n=0){return ft(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Rt(function(r,n=0){return ct(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const it=Math.pow(2,8*p-1);W(this,r,n,p,it-1,-it)}let T=0,F=1,G=0;for(this[n]=r&255;++T<p&&(F*=256);)r<0&&G===0&&this[n+T-1]!==0&&(G=1),this[n+T]=(r/F>>0)-G&255;return n+p},o.prototype.writeIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const it=Math.pow(2,8*p-1);W(this,r,n,p,it-1,-it)}let T=p-1,F=1,G=0;for(this[n+T]=r&255;--T>=0&&(F*=256);)r<0&&G===0&&this[n+T+1]!==0&&(G=1),this[n+T]=(r/F>>0)-G&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=Rt(function(r,n=0){return ft(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Rt(function(r,n=0){return ct(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(u,r,n,p,x,T){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function $(u,r,n,p,x){return r=+r,n=n>>>0,x||J(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return $(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return $(this,r,n,!1,p)};function f(u,r,n,p,x){return r=+r,n=n>>>0,x||J(u,r,n,8),e.write(u,r,n,p,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,p){return f(this,r,n,!0,p)},o.prototype.writeDoubleBE=function(r,n,p){return f(this,r,n,!1,p)},o.prototype.copy=function(r,n,p,x){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!x&&x!==0&&(x=this.length),n>=r.length&&(n=r.length),n||(n=0),x>0&&x<p&&(x=p),x===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(x<0)throw new RangeError("sourceEnd out of bounds");x>this.length&&(x=this.length),r.length-n<x-p&&(x=r.length-n+p);const T=x-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,x):Uint8Array.prototype.set.call(r,this.subarray(p,x),n),T},o.prototype.fill=function(r,n,p,x){if(typeof r=="string"){if(typeof n=="string"?(x=n,n=0,p=this.length):typeof p=="string"&&(x=p,p=this.length),x!==void 0&&typeof x!="string")throw new TypeError("encoding must be a string");if(typeof x=="string"&&!o.isEncoding(x))throw new TypeError("Unknown encoding: "+x);if(r.length===1){const F=r.charCodeAt(0);(x==="utf8"&&F<128||x==="latin1")&&(r=F)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let T;if(typeof r=="number")for(T=n;T<p;++T)this[T]=r;else{const F=o.isBuffer(r)?r:o.from(r,x),G=F.length;if(G===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(T=0;T<p-n;++T)this[T+n]=F[T%G]}return this};const a={};function S(u,r,n){a[u]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${u}]`,this.stack,delete this.name}get code(){return u}set code(x){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:x,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}S("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),S("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),S("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,x=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?x=w(String(n)):typeof n=="bigint"&&(x=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(x=w(x)),x+="n"),p+=` It must be ${r}. Received ${x}`,p},RangeError);function w(u){let r="",n=u.length;const p=u[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${u.slice(n-3,n)}${r}`;return`${u.slice(0,n)}${r}`}function q(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&ot(r,u.length-(n+1))}function et(u,r,n,p,x,T){if(u>n||u<r){const F=typeof r=="bigint"?"n":"";let G;throw r===0||r===BigInt(0)?G=`>= 0${F} and < 2${F} ** ${(T+1)*8}${F}`:G=`>= -(2${F} ** ${(T+1)*8-1}${F}) and < 2 ** ${(T+1)*8-1}${F}`,new a.ERR_OUT_OF_RANGE("value",G,u)}q(p,x,T)}function X(u,r){if(typeof u!="number")throw new a.ERR_INVALID_ARG_TYPE(r,"number",u)}function ot(u,r,n){throw Math.floor(u)!==u?(X(u,n),new a.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new a.ERR_BUFFER_OUT_OF_BOUNDS:new a.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const pt=/[^+/0-9A-Za-z-_]/g;function Nt(u){if(u=u.split("=")[0],u=u.trim().replace(pt,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function at(u,r){r=r||1/0;let n;const p=u.length;let x=null;const T=[];for(let F=0;F<p;++F){if(n=u.charCodeAt(F),n>55295&&n<57344){if(!x){if(n>56319){(r-=3)>-1&&T.push(239,191,189);continue}else if(F+1===p){(r-=3)>-1&&T.push(239,191,189);continue}x=n;continue}if(n<56320){(r-=3)>-1&&T.push(239,191,189),x=n;continue}n=(x-55296<<10|n-56320)+65536}else x&&(r-=3)>-1&&T.push(239,191,189);if(x=null,n<128){if((r-=1)<0)break;T.push(n)}else if(n<2048){if((r-=2)<0)break;T.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;T.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;T.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return T}function Tt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Te(u,r){let n,p,x;const T=[];for(let F=0;F<u.length&&!((r-=2)<0);++F)n=u.charCodeAt(F),p=n>>8,x=n%256,T.push(x),T.push(p);return T}function zt(u){return t.toByteArray(Nt(u))}function Ot(u,r,n,p){let x;for(x=0;x<p&&!(x+n>=r.length||x>=u.length);++x)r[x+n]=u[x];return x}function wt(u,r){return u instanceof r||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===r.name}function Ae(u){return u!==u}const yr=(function(){const u="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let x=0;x<16;++x)r[p+x]=u[n]+u[x]}return r})();function Rt(u){return typeof BigInt>"u"?xr:u}function xr(){throw new Error("BigInt not supported")}})(oe)),oe}var Ue;function Mi(){return Ue||(Ue=1,(function(h,t){var e=Pe(),i=e.Buffer;function s(l,o){for(var y in l)o[y]=l[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(l,o,y){return i(l,o,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(l,o,y){if(typeof l=="number")throw new TypeError("Argument must not be a number");return i(l,o,y)},c.alloc=function(l,o,y){if(typeof l!="number")throw new TypeError("Argument must be a number");var C=i(l);return o!==void 0?typeof y=="string"?C.fill(o,y):C.fill(o):C.fill(0),C},c.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return i(l)},c.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(l)}})(Xt,Xt.exports)),Xt.exports}var ke;function Fi(){if(ke)return ae;ke=1;var h=Mi().Buffer,t=h.isEncoding||function(_){switch(_=""+_,_&&_.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(_){if(!_)return"utf8";for(var E;;)switch(_){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return _;default:if(E)return;_=(""+_).toLowerCase(),E=!0}}function i(_){var E=e(_);if(typeof E!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return E||_}ae.StringDecoder=s;function s(_){this.encoding=i(_);var E;switch(this.encoding){case"utf16le":this.text=B,this.end=A,E=4;break;case"utf8":this.fillLast=y,E=4;break;case"base64":this.text=I,this.end=M,E=3;break;default:this.write=N,this.end=O;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(E)}s.prototype.write=function(_){if(_.length===0)return"";var E,m;if(this.lastNeed){if(E=this.fillLast(_),E===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?E?E+this.text(_,m):this.text(_,m):E||""},s.prototype.end=v,s.prototype.text=C,s.prototype.fillLast=function(_){if(this.lastNeed<=_.length)return _.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,this.lastTotal-this.lastNeed,0,_.length),this.lastNeed-=_.length};function c(_){return _<=127?0:_>>5===6?2:_>>4===14?3:_>>3===30?4:_>>6===2?-1:-2}function l(_,E,m){var d=E.length-1;if(d<m)return 0;var b=c(E[d]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--d<m||b===-2?0:(b=c(E[d]),b>=0?(b>0&&(_.lastNeed=b-2),b):--d<m||b===-2?0:(b=c(E[d]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,E,m){if((E[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&E.length>1){if((E[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&E.length>2&&(E[2]&192)!==128)return _.lastNeed=2,"�"}}function y(_){var E=this.lastTotal-this.lastNeed,m=o(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,E,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,E,0,_.length),this.lastNeed-=_.length}function C(_,E){var m=l(this,_,E);if(!this.lastNeed)return _.toString("utf8",E);this.lastTotal=m;var d=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,d),_.toString("utf8",E,d)}function v(_){var E=_&&_.length?this.write(_):"";return this.lastNeed?E+"�":E}function B(_,E){if((_.length-E)%2===0){var m=_.toString("utf16le",E);if(m){var d=m.charCodeAt(m.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=_[_.length-1],_.toString("utf16le",E,_.length-1)}function A(_){var E=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return E+this.lastChar.toString("utf16le",0,m)}return E}function I(_,E){var m=(_.length-E)%3;return m===0?_.toString("base64",E):(this.lastNeed=3-m,this.lastTotal=3,m===1?this.lastChar[0]=_[_.length-1]:(this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1]),_.toString("base64",E,_.length-m))}function M(_){var E=_&&_.length?this.write(_):"";return this.lastNeed?E+this.lastChar.toString("base64",0,3-this.lastNeed):E}function N(_){return _.toString(this.encoding)}function O(_){return _&&_.length?this.write(_):""}return ae}var Le;function Ii(){return Le||(Le=1,(function(h){(function(t){t.parser=function(f,a){return new i(f,a)},t.SAXParser=i,t.SAXStream=v,t.createStream=C,t.MAX_BUFFER_LENGTH=65536;var e=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function i(f,a){if(!(this instanceof i))return new i(f,a);var S=this;c(S),S.q=S.c="",S.bufferCheckPosition=t.MAX_BUFFER_LENGTH,S.opt=a||{},S.opt.lowercase=S.opt.lowercase||S.opt.lowercasetags,S.looseCase=S.opt.lowercase?"toLowerCase":"toUpperCase",S.tags=[],S.closed=S.closedRoot=S.sawRoot=!1,S.tag=S.error=null,S.strict=!!f,S.noscript=!!(f||S.opt.noscript),S.state=g.BEGIN,S.strictEntities=S.opt.strictEntities,S.ENTITIES=S.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),S.attribList=[],S.opt.xmlns&&(S.ns=Object.create(N)),S.opt.unquotedAttributeValues===void 0&&(S.opt.unquotedAttributeValues=!f),S.trackPosition=S.opt.position!==!1,S.trackPosition&&(S.position=S.line=S.column=0),j(S,"onready")}Object.create||(Object.create=function(f){function a(){}a.prototype=f;var S=new a;return S}),Object.keys||(Object.keys=function(f){var a=[];for(var S in f)f.hasOwnProperty(S)&&a.push(S);return a});function s(f){for(var a=Math.max(t.MAX_BUFFER_LENGTH,10),S=0,w=0,q=e.length;w<q;w++){var et=f[e[w]].length;if(et>a)switch(e[w]){case"textNode":Q(f);break;case"cdata":z(f,"oncdata",f.cdata),f.cdata="";break;case"script":z(f,"onscript",f.script),f.script="";break;default:tt(f,"Max buffer length exceeded: "+e[w])}S=Math.max(S,et)}var X=t.MAX_BUFFER_LENGTH-S;f.bufferCheckPosition=X+f.position}function c(f){for(var a=0,S=e.length;a<S;a++)f[e[a]]=""}function l(f){Q(f),f.cdata!==""&&(z(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(z(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ht(this)},write:$,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){l(this)}};var o;try{o=Si.Stream}catch{o=function(){}}o||(o=function(){});var y=t.EVENTS.filter(function(f){return f!=="error"&&f!=="end"});function C(f,a){return new v(f,a)}function v(f,a){if(!(this instanceof v))return new v(f,a);o.apply(this),this._parser=new i(f,a),this.writable=!0,this.readable=!0;var S=this;this._parser.onend=function(){S.emit("end")},this._parser.onerror=function(w){S.emit("error",w),S._parser.error=null},this._decoder=null,y.forEach(function(w){Object.defineProperty(S,"on"+w,{get:function(){return S._parser["on"+w]},set:function(q){if(!q)return S.removeAllListeners(w),S._parser["on"+w]=q,q;S.on(w,q)},enumerable:!0,configurable:!1})})}v.prototype=Object.create(o.prototype,{constructor:{value:v}}),v.prototype.write=function(f){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(f)){if(!this._decoder){var a=Fi().StringDecoder;this._decoder=new a("utf8")}f=this._decoder.write(f)}return this._parser.write(f.toString()),this.emit("data",f),!0},v.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},v.prototype.on=function(f,a){var S=this;return!S._parser["on"+f]&&y.indexOf(f)!==-1&&(S._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),S.emit.apply(S,w)}),o.prototype.on.call(S,f,a)};var B="[CDATA[",A="DOCTYPE",I="http://www.w3.org/XML/1998/namespace",M="http://www.w3.org/2000/xmlns/",N={xml:I,xmlns:M},O=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,E=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function d(f){return f===" "||f===`
83
+ `||f==="\r"||f===" "}function b(f){return f==='"'||f==="'"}function R(f){return f===">"||d(f)}function U(f,a){return f.test(a)}function k(f,a){return!U(f,a)}var g=0;t.STATE={BEGIN:g++,BEGIN_WHITESPACE:g++,TEXT:g++,TEXT_ENTITY:g++,OPEN_WAKA:g++,SGML_DECL:g++,SGML_DECL_QUOTED:g++,DOCTYPE:g++,DOCTYPE_QUOTED:g++,DOCTYPE_DTD:g++,DOCTYPE_DTD_QUOTED:g++,COMMENT_STARTING:g++,COMMENT:g++,COMMENT_ENDING:g++,COMMENT_ENDED:g++,CDATA:g++,CDATA_ENDING:g++,CDATA_ENDING_2:g++,PROC_INST:g++,PROC_INST_BODY:g++,PROC_INST_ENDING:g++,OPEN_TAG:g++,OPEN_TAG_SLASH:g++,ATTRIB:g++,ATTRIB_NAME:g++,ATTRIB_NAME_SAW_WHITE:g++,ATTRIB_VALUE:g++,ATTRIB_VALUE_QUOTED:g++,ATTRIB_VALUE_CLOSED:g++,ATTRIB_VALUE_UNQUOTED:g++,ATTRIB_VALUE_ENTITY_Q:g++,ATTRIB_VALUE_ENTITY_U:g++,CLOSE_TAG:g++,CLOSE_TAG_SAW_WHITE:g++,SCRIPT:g++,SCRIPT_ENDING:g++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(f){var a=t.ENTITIES[f],S=typeof a=="number"?String.fromCharCode(a):a;t.ENTITIES[f]=S});for(var V in t.STATE)t.STATE[t.STATE[V]]=V;g=t.STATE;function j(f,a,S){f[a]&&f[a](S)}function z(f,a,S){f.textNode&&Q(f),j(f,a,S)}function Q(f){f.textNode=ut(f.opt,f.textNode),f.textNode&&j(f,"ontext",f.textNode),f.textNode=""}function ut(f,a){return f.trim&&(a=a.trim()),f.normalize&&(a=a.replace(/\s+/g," ")),a}function tt(f,a){return Q(f),f.trackPosition&&(a+=`
3
84
  Line: `+f.line+`
4
85
  Column: `+f.column+`
5
- Char: `+f.c),l=new Error(l),f.error=l,it(f,"onerror",l),f}function ft(f){return f.sawRoot&&!f.closedRoot&&Y(f,"Unclosed root tag"),f.state!==y.BEGIN&&f.state!==y.BEGIN_WHITESPACE&&f.state!==y.TEXT&&at(f,"Unexpected end"),$(f),f.c="",f.closed=!0,it(f,"onend"),i.call(f,f.strict,f.opt),f}function Y(f,l){if(typeof f!="object"||!(f instanceof i))throw new Error("bad call to strictFail");f.strict&&at(f,l)}function ot(f){f.strict||(f.tagName=f.tagName[f.looseCase]());var l=f.tags[f.tags.length-1]||f,M=f.tag={name:f.tagName,attributes:{}};f.opt.xmlns&&(M.ns=l.ns),f.attribList.length=0,j(f,"onopentagstart",M)}function nt(f,l){var M=f.indexOf(":"),w=M<0?["",f]:f.split(":"),z=w[0],J=w[1];return l&&f==="xmlns"&&(z="xmlns",J=""),{prefix:z,local:J}}function X(f){if(f.strict||(f.attribName=f.attribName[f.looseCase]()),f.attribList.indexOf(f.attribName)!==-1||f.tag.attributes.hasOwnProperty(f.attribName)){f.attribName=f.attribValue="";return}if(f.opt.xmlns){var l=nt(f.attribName,!0),M=l.prefix,w=l.local;if(M==="xmlns")if(w==="xml"&&f.attribValue!==F)Y(f,"xml: prefix must be bound to "+F+`
6
- Actual: `+f.attribValue);else if(w==="xmlns"&&f.attribValue!==I)Y(f,"xmlns: prefix must be bound to "+I+`
7
- Actual: `+f.attribValue);else{var z=f.tag,J=f.tags[f.tags.length-1]||f;z.ns===J.ns&&(z.ns=Object.create(J.ns)),z.ns[w]=f.attribValue}f.attribList.push([f.attribName,f.attribValue])}else f.tag.attributes[f.attribName]=f.attribValue,j(f,"onattribute",{name:f.attribName,value:f.attribValue});f.attribName=f.attribValue=""}function k(f,l){if(f.opt.xmlns){var M=f.tag,w=nt(f.tagName);M.prefix=w.prefix,M.local=w.local,M.uri=M.ns[w.prefix]||"",M.prefix&&!M.uri&&(Y(f,"Unbound namespace prefix: "+JSON.stringify(f.tagName)),M.uri=w.prefix);var z=f.tags[f.tags.length-1]||f;M.ns&&z.ns!==M.ns&&Object.keys(M.ns).forEach(function(_t){j(f,"onopennamespace",{prefix:_t,uri:M.ns[_t]})});for(var J=0,H=f.attribList.length;J<H;J++){var rt=f.attribList[J],ct=rt[0],Mt=rt[1],et=nt(ct,!0),Et=et.prefix,xe=et.local,Kt=Et===""?"":M.ns[Et]||"",It={name:ct,value:Mt,prefix:Et,local:xe,uri:Kt};Et&&Et!=="xmlns"&&!Kt&&(Y(f,"Unbound namespace prefix: "+JSON.stringify(Et)),It.uri=Et),f.tag.attributes[ct]=It,j(f,"onattribute",It)}f.attribList.length=0}f.tag.isSelfClosing=!!l,f.sawRoot=!0,f.tags.push(f.tag),j(f,"onopentag",f.tag),l||(!f.noscript&&f.tagName.toLowerCase()==="script"?f.state=y.SCRIPT:f.state=y.TEXT,f.tag=null,f.tagName=""),f.attribName=f.attribValue="",f.attribList.length=0}function K(f){if(!f.tagName){Y(f,"Weird empty close tag."),f.textNode+="</>",f.state=y.TEXT;return}if(f.script){if(f.tagName!=="script"){f.script+="</"+f.tagName+">",f.tagName="",f.state=y.SCRIPT;return}j(f,"onscript",f.script),f.script=""}var l=f.tags.length,M=f.tagName;f.strict||(M=M[f.looseCase]());for(var w=M;l--;){var z=f.tags[l];if(z.name!==w)Y(f,"Unexpected close tag");else break}if(l<0){Y(f,"Unmatched closing tag: "+f.tagName),f.textNode+="</"+f.tagName+">",f.state=y.TEXT;return}f.tagName=M;for(var J=f.tags.length;J-- >l;){var H=f.tag=f.tags.pop();f.tagName=f.tag.name,j(f,"onclosetag",f.tagName);var rt={};for(var ct in H.ns)rt[ct]=H.ns[ct];var Mt=f.tags[f.tags.length-1]||f;f.opt.xmlns&&H.ns!==Mt.ns&&Object.keys(H.ns).forEach(function(et){var Et=H.ns[et];j(f,"onclosenamespace",{prefix:et,uri:Et})})}l===0&&(f.closedRoot=!0),f.tagName=f.attribValue=f.attribName="",f.attribList.length=0,f.state=y.TEXT}function mt(f){var l=f.entity,M=l.toLowerCase(),w,z="";return f.ENTITIES[l]?f.ENTITIES[l]:f.ENTITIES[M]?f.ENTITIES[M]:(l=M,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),w=parseInt(l,16),z=w.toString(16)):(l=l.slice(1),w=parseInt(l,10),z=w.toString(10))),l=l.replace(/^0+/,""),isNaN(w)||z.toLowerCase()!==l?(Y(f,"Invalid character entity"),"&"+f.entity+";"):String.fromCodePoint(w))}function Tt(f,l){l==="<"?(f.state=y.OPEN_WAKA,f.startTagPosition=f.position):d(l)||(Y(f,"Non-whitespace before first tag."),f.textNode=l,f.state=y.TEXT)}function Gt(f,l){var M="";return l<f.length&&(M=f.charAt(l)),M}function Xt(f){var l=this;if(this.error)throw this.error;if(l.closed)return at(l,"Cannot write after close. Assign an onready handler.");if(f===null)return ft(l);typeof f=="object"&&(f=f.toString());for(var M=0,w="";w=Gt(f,M++),l.c=w,!!w;)switch(l.trackPosition&&(l.position++,w===`
8
- `?(l.line++,l.column=0):l.column++),l.state){case y.BEGIN:if(l.state=y.BEGIN_WHITESPACE,w==="\uFEFF")continue;Tt(l,w);continue;case y.BEGIN_WHITESPACE:Tt(l,w);continue;case y.TEXT:if(l.sawRoot&&!l.closedRoot){for(var z=M-1;w&&w!=="<"&&w!=="&";)w=Gt(f,M++),w&&l.trackPosition&&(l.position++,w===`
9
- `?(l.line++,l.column=0):l.column++);l.textNode+=f.substring(z,M-1)}w==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):(!d(w)&&(!l.sawRoot||l.closedRoot)&&Y(l,"Text data outside of root node."),w==="&"?l.state=y.TEXT_ENTITY:l.textNode+=w);continue;case y.SCRIPT:w==="<"?l.state=y.SCRIPT_ENDING:l.script+=w;continue;case y.SCRIPT_ENDING:w==="/"?l.state=y.CLOSE_TAG:(l.script+="<"+w,l.state=y.SCRIPT);continue;case y.OPEN_WAKA:if(w==="!")l.state=y.SGML_DECL,l.sgmlDecl="";else if(!d(w))if(U(R,w))l.state=y.OPEN_TAG,l.tagName=w;else if(w==="/")l.state=y.CLOSE_TAG,l.tagName="";else if(w==="?")l.state=y.PROC_INST,l.procInstName=l.procInstBody="";else{if(Y(l,"Unencoded <"),l.startTagPosition+1<l.position){var J=l.position-l.startTagPosition;w=new Array(J).join(" ")+w}l.textNode+="<"+w,l.state=y.TEXT}continue;case y.SGML_DECL:if(l.sgmlDecl+w==="--"){l.state=y.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=y.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+w,l.sgmlDecl=""):(l.sgmlDecl+w).toUpperCase()===C?(j(l,"onopencdata"),l.state=y.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+w).toUpperCase()===S?(l.state=y.DOCTYPE,(l.doctype||l.sawRoot)&&Y(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):w===">"?(j(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=y.TEXT):(b(w)&&(l.state=y.SGML_DECL_QUOTED),l.sgmlDecl+=w);continue;case y.SGML_DECL_QUOTED:w===l.q&&(l.state=y.SGML_DECL,l.q=""),l.sgmlDecl+=w;continue;case y.DOCTYPE:w===">"?(l.state=y.TEXT,j(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=w,w==="["?l.state=y.DOCTYPE_DTD:b(w)&&(l.state=y.DOCTYPE_QUOTED,l.q=w));continue;case y.DOCTYPE_QUOTED:l.doctype+=w,w===l.q&&(l.q="",l.state=y.DOCTYPE);continue;case y.DOCTYPE_DTD:w==="]"?(l.doctype+=w,l.state=y.DOCTYPE):w==="<"?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):b(w)?(l.doctype+=w,l.state=y.DOCTYPE_DTD_QUOTED,l.q=w):l.doctype+=w;continue;case y.DOCTYPE_DTD_QUOTED:l.doctype+=w,w===l.q&&(l.state=y.DOCTYPE_DTD,l.q="");continue;case y.COMMENT:w==="-"?l.state=y.COMMENT_ENDING:l.comment+=w;continue;case y.COMMENT_ENDING:w==="-"?(l.state=y.COMMENT_ENDED,l.comment=lt(l.opt,l.comment),l.comment&&j(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+w,l.state=y.COMMENT);continue;case y.COMMENT_ENDED:w!==">"?(Y(l,"Malformed comment"),l.comment+="--"+w,l.state=y.COMMENT):l.doctype&&l.doctype!==!0?l.state=y.DOCTYPE_DTD:l.state=y.TEXT;continue;case y.CDATA:w==="]"?l.state=y.CDATA_ENDING:l.cdata+=w;continue;case y.CDATA_ENDING:w==="]"?l.state=y.CDATA_ENDING_2:(l.cdata+="]"+w,l.state=y.CDATA);continue;case y.CDATA_ENDING_2:w===">"?(l.cdata&&j(l,"oncdata",l.cdata),j(l,"onclosecdata"),l.cdata="",l.state=y.TEXT):w==="]"?l.cdata+="]":(l.cdata+="]]"+w,l.state=y.CDATA);continue;case y.PROC_INST:w==="?"?l.state=y.PROC_INST_ENDING:d(w)?l.state=y.PROC_INST_BODY:l.procInstName+=w;continue;case y.PROC_INST_BODY:if(!l.procInstBody&&d(w))continue;w==="?"?l.state=y.PROC_INST_ENDING:l.procInstBody+=w;continue;case y.PROC_INST_ENDING:w===">"?(j(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=y.TEXT):(l.procInstBody+="?"+w,l.state=y.PROC_INST_BODY);continue;case y.OPEN_TAG:U(m,w)?l.tagName+=w:(ot(l),w===">"?k(l):w==="/"?l.state=y.OPEN_TAG_SLASH:(d(w)||Y(l,"Invalid character in tag name"),l.state=y.ATTRIB));continue;case y.OPEN_TAG_SLASH:w===">"?(k(l,!0),K(l)):(Y(l,"Forward-slash in opening tag not followed by >"),l.state=y.ATTRIB);continue;case y.ATTRIB:if(d(w))continue;w===">"?k(l):w==="/"?l.state=y.OPEN_TAG_SLASH:U(R,w)?(l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):Y(l,"Invalid attribute name");continue;case y.ATTRIB_NAME:w==="="?l.state=y.ATTRIB_VALUE:w===">"?(Y(l,"Attribute without value"),l.attribValue=l.attribName,X(l),k(l)):d(w)?l.state=y.ATTRIB_NAME_SAW_WHITE:U(m,w)?l.attribName+=w:Y(l,"Invalid attribute name");continue;case y.ATTRIB_NAME_SAW_WHITE:if(w==="=")l.state=y.ATTRIB_VALUE;else{if(d(w))continue;Y(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",j(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?k(l):U(R,w)?(l.attribName=w,l.state=y.ATTRIB_NAME):(Y(l,"Invalid attribute name"),l.state=y.ATTRIB)}continue;case y.ATTRIB_VALUE:if(d(w))continue;b(w)?(l.q=w,l.state=y.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||at(l,"Unquoted attribute value"),l.state=y.ATTRIB_VALUE_UNQUOTED,l.attribValue=w);continue;case y.ATTRIB_VALUE_QUOTED:if(w!==l.q){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=w;continue}X(l),l.q="",l.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:d(w)?l.state=y.ATTRIB:w===">"?k(l):w==="/"?l.state=y.OPEN_TAG_SLASH:U(R,w)?(Y(l,"No whitespace between attributes"),l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):Y(l,"Invalid attribute name");continue;case y.ATTRIB_VALUE_UNQUOTED:if(!P(w)){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_U:l.attribValue+=w;continue}X(l),w===">"?k(l):l.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(l.tagName)w===">"?K(l):U(m,w)?l.tagName+=w:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=y.SCRIPT):(d(w)||Y(l,"Invalid tagname in closing tag"),l.state=y.CLOSE_TAG_SAW_WHITE);else{if(d(w))continue;L(R,w)?l.script?(l.script+="</"+w,l.state=y.SCRIPT):Y(l,"Invalid tagname in closing tag."):l.tagName=w}continue;case y.CLOSE_TAG_SAW_WHITE:if(d(w))continue;w===">"?K(l):Y(l,"Invalid characters in closing tag");continue;case y.TEXT_ENTITY:case y.ATTRIB_VALUE_ENTITY_Q:case y.ATTRIB_VALUE_ENTITY_U:var H,rt;switch(l.state){case y.TEXT_ENTITY:H=y.TEXT,rt="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:H=y.ATTRIB_VALUE_QUOTED,rt="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:H=y.ATTRIB_VALUE_UNQUOTED,rt="attribValue";break}if(w===";"){var ct=mt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(ct)?(l.entity="",l.state=H,l.write(ct)):(l[rt]+=ct,l.entity="",l.state=H)}else U(l.entity.length?_:v,w)?l.entity+=w:(Y(l,"Invalid character in entity name"),l[rt]+="&"+l.entity+w,l.entity="",l.state=H);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}String.fromCodePoint||(function(){var f=String.fromCharCode,l=Math.floor,M=function(){var w=16384,z=[],J,H,rt=-1,ct=arguments.length;if(!ct)return"";for(var Mt="";++rt<ct;){var et=Number(arguments[rt]);if(!isFinite(et)||et<0||et>1114111||l(et)!==et)throw RangeError("Invalid code point: "+et);et<=65535?z.push(et):(et-=65536,J=(et>>10)+55296,H=et%1024+56320,z.push(J,H)),(rt+1===ct||z.length>w)&&(Mt+=f.apply(null,z),z.length=0)}return Mt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:M,configurable:!0,writable:!0}):String.fromCodePoint=M})()})(h)})(ee)),ee}var se,Oe;function ne(){return Oe||(Oe=1,se={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),se}var ae,Pe;function oe(){if(Pe)return ae;Pe=1;var h=ne().isArray;return ae={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!h(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},ae}var le,Re;function Ue(){if(Re)return le;Re=1;var h=gi(),t=oe(),e=ne().isArray,i,s;function c(m){return i=t.copyOptions(m),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function a(m){var v=Number(m);if(!isNaN(v))return v;var _=m.toLowerCase();return _==="true"?!0:_==="false"?!1:m}function o(m,v){var _;if(i.compact){if(!s[i[m+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[m+"Key"])!==-1:i.alwaysArray)&&(s[i[m+"Key"]]=[]),s[i[m+"Key"]]&&!e(s[i[m+"Key"]])&&(s[i[m+"Key"]]=[s[i[m+"Key"]]]),m+"Fn"in i&&typeof v=="string"&&(v=i[m+"Fn"](v,s)),m==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(_ in v)if(v.hasOwnProperty(_))if("instructionFn"in i)v[_]=i.instructionFn(v[_],_,s);else{var d=v[_];delete v[_],v[i.instructionNameFn(_,d,s)]=d}}e(s[i[m+"Key"]])?s[i[m+"Key"]].push(v):s[i[m+"Key"]]=v}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=m,m==="instruction"){for(_ in v)if(v.hasOwnProperty(_))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(_,v,s):_,i.instructionHasAttributes?(b[i.attributesKey]=v[_][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],_,s))):("instructionFn"in i&&(v[_]=i.instructionFn(v[_],_,s)),b[i.instructionKey]=v[_])}else m+"Fn"in i&&(v=i[m+"Fn"](v,s)),b[i[m+"Key"]]=v;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function g(m){if("attributesFn"in i&&m&&(m=i.attributesFn(m,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&m){var v;for(v in m)if(m.hasOwnProperty(v)&&(i.trim&&(m[v]=m[v].trim()),i.nativeTypeAttributes&&(m[v]=a(m[v])),"attributeValueFn"in i&&(m[v]=i.attributeValueFn(m[v],v,s)),"attributeNameFn"in i)){var _=m[v];delete m[v],m[i.attributeNameFn(v,m[v],s)]=_}}return m}function A(m){var v={};if(m.body&&(m.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var _=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,d;(d=_.exec(m.body))!==null;)v[d[1]]=d[2]||d[3]||d[4];v=g(v)}if(m.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(v).length&&(s[i.declarationKey][i.attributesKey]=v),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(m.body=m.body.trim());var b={};i.instructionHasAttributes&&Object.keys(v).length?(b[m.name]={},b[m.name][i.attributesKey]=v):b[m.name]=m.body,o("instruction",b)}}function x(m,v){var _;if(typeof m=="object"&&(v=m.attributes,m=m.name),v=g(v),"elementNameFn"in i&&(m=i.elementNameFn(m,s)),i.compact){if(_={},!i.ignoreAttributes&&v&&Object.keys(v).length){_[i.attributesKey]={};var d;for(d in v)v.hasOwnProperty(d)&&(_[i.attributesKey][d]=v[d])}!(m in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(m)!==-1:i.alwaysArray)&&(s[m]=[]),s[m]&&!e(s[m])&&(s[m]=[s[m]]),e(s[m])?s[m].push(_):s[m]=_}else s[i.elementsKey]||(s[i.elementsKey]=[]),_={},_[i.typeKey]="element",_[i.nameKey]=m,!i.ignoreAttributes&&v&&Object.keys(v).length&&(_[i.attributesKey]=v),i.alwaysChildren&&(_[i.elementsKey]=[]),s[i.elementsKey].push(_);_[i.parentKey]=s,s=_}function C(m){i.ignoreText||!m.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(m=m.trim()),i.nativeType&&(m=a(m)),i.sanitize&&(m=m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),o("text",m))}function S(m){i.ignoreComment||(i.trim&&(m=m.trim()),o("comment",m))}function F(m){var v=s[i.parentKey];i.addParent||delete s[i.parentKey],s=v}function I(m){i.ignoreCdata||(i.trim&&(m=m.trim()),o("cdata",m))}function N(m){i.ignoreDoctype||(m=m.replace(/^ /,""),i.trim&&(m=m.trim()),o("doctype",m))}function R(m){m.note=m}return le=function(m,v){var _=h.parser(!0,{}),d={};if(s=d,i=c(v),_.opt={strictEntities:!0},_.onopentag=x,_.ontext=C,_.oncomment=S,_.onclosetag=F,_.onerror=R,_.oncdata=I,_.ondoctype=N,_.onprocessinginstruction=A,_.write(m).close(),d[i.elementsKey]){var b=d[i.elementsKey];delete d[i.elementsKey],d[i.elementsKey]=b,delete d.text}return d},le}var ce,Le;function yi(){if(Le)return ce;Le=1;var h=oe(),t=Ue();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return ce=function(i,s){var c,a,o,g;return c=e(s),a=t(i,c),g="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(a,function(A,x){return A===g?"_":x},c.spaces):o=JSON.stringify(a,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var ue,ke;function Ye(){if(ke)return ue;ke=1;var h=oe(),t=ne().isArray,e,i;function s(_){var d=h.copyOptions(_);return h.ensureFlagExists("ignoreDeclaration",d),h.ensureFlagExists("ignoreInstruction",d),h.ensureFlagExists("ignoreAttributes",d),h.ensureFlagExists("ignoreText",d),h.ensureFlagExists("ignoreComment",d),h.ensureFlagExists("ignoreCdata",d),h.ensureFlagExists("ignoreDoctype",d),h.ensureFlagExists("compact",d),h.ensureFlagExists("indentText",d),h.ensureFlagExists("indentCdata",d),h.ensureFlagExists("indentAttributes",d),h.ensureFlagExists("indentInstruction",d),h.ensureFlagExists("fullTagEmptyElement",d),h.ensureFlagExists("noQuotesForNativeAttributes",d),h.ensureSpacesExists(d),typeof d.spaces=="number"&&(d.spaces=Array(d.spaces+1).join(" ")),h.ensureKeyExists("declaration",d),h.ensureKeyExists("instruction",d),h.ensureKeyExists("attributes",d),h.ensureKeyExists("text",d),h.ensureKeyExists("comment",d),h.ensureKeyExists("cdata",d),h.ensureKeyExists("doctype",d),h.ensureKeyExists("type",d),h.ensureKeyExists("name",d),h.ensureKeyExists("elements",d),h.checkFnExists("doctype",d),h.checkFnExists("instruction",d),h.checkFnExists("cdata",d),h.checkFnExists("comment",d),h.checkFnExists("text",d),h.checkFnExists("instructionName",d),h.checkFnExists("elementName",d),h.checkFnExists("attributeName",d),h.checkFnExists("attributeValue",d),h.checkFnExists("attributes",d),h.checkFnExists("fullTagEmptyElement",d),d}function c(_,d,b){return(!b&&_.spaces?`
10
- `:"")+Array(d+1).join(_.spaces)}function a(_,d,b){if(d.ignoreAttributes)return"";"attributesFn"in d&&(_=d.attributesFn(_,i,e));var P,U,L,y,G=[];for(P in _)_.hasOwnProperty(P)&&_[P]!==null&&_[P]!==void 0&&(y=d.noQuotesForNativeAttributes&&typeof _[P]!="string"?"":'"',U=""+_[P],U=U.replace(/"/g,"&quot;"),L="attributeNameFn"in d?d.attributeNameFn(P,U,i,e):P,G.push(d.spaces&&d.indentAttributes?c(d,b+1,!1):" "),G.push(L+"="+y+("attributeValueFn"in d?d.attributeValueFn(U,P,i,e):U)+y));return _&&Object.keys(_).length&&d.spaces&&d.indentAttributes&&G.push(c(d,b,!1)),G.join("")}function o(_,d,b){return e=_,i="xml",d.ignoreDeclaration?"":"<?xml"+a(_[d.attributesKey],d,b)+"?>"}function g(_,d,b){if(d.ignoreInstruction)return"";var P;for(P in _)if(_.hasOwnProperty(P))break;var U="instructionNameFn"in d?d.instructionNameFn(P,_[P],i,e):P;if(typeof _[P]=="object")return e=_,i=U,"<?"+U+a(_[P][d.attributesKey],d,b)+"?>";var L=_[P]?_[P]:"";return"instructionFn"in d&&(L=d.instructionFn(L,P,i,e)),"<?"+U+(L?" "+L:"")+"?>"}function A(_,d){return d.ignoreComment?"":"<!--"+("commentFn"in d?d.commentFn(_,i,e):_)+"-->"}function x(_,d){return d.ignoreCdata?"":"<![CDATA["+("cdataFn"in d?d.cdataFn(_,i,e):_.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(_,d){return d.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in d?d.doctypeFn(_,i,e):_)+">"}function S(_,d){return d.ignoreText?"":(_=""+_,_=_.replace(/&amp;/g,"&"),_=_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in d?d.textFn(_,i,e):_)}function F(_,d){var b;if(_.elements&&_.elements.length)for(b=0;b<_.elements.length;++b)switch(_.elements[b][d.typeKey]){case"text":if(d.indentText)return!0;break;case"cdata":if(d.indentCdata)return!0;break;case"instruction":if(d.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function I(_,d,b){e=_,i=_.name;var P=[],U="elementNameFn"in d?d.elementNameFn(_.name,_):_.name;P.push("<"+U),_[d.attributesKey]&&P.push(a(_[d.attributesKey],d,b));var L=_[d.elementsKey]&&_[d.elementsKey].length||_[d.attributesKey]&&_[d.attributesKey]["xml:space"]==="preserve";return L||("fullTagEmptyElementFn"in d?L=d.fullTagEmptyElementFn(_.name,_):L=d.fullTagEmptyElement),L?(P.push(">"),_[d.elementsKey]&&_[d.elementsKey].length&&(P.push(N(_[d.elementsKey],d,b+1)),e=_,i=_.name),P.push(d.spaces&&F(_,d)?`
11
- `+Array(b+1).join(d.spaces):""),P.push("</"+U+">")):P.push("/>"),P.join("")}function N(_,d,b,P){return _.reduce(function(U,L){var y=c(d,b,P&&!U);switch(L.type){case"element":return U+y+I(L,d,b);case"comment":return U+y+A(L[d.commentKey],d);case"doctype":return U+y+C(L[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?y:"")+x(L[d.cdataKey],d);case"text":return U+(d.indentText?y:"")+S(L[d.textKey],d);case"instruction":var G={};return G[L[d.nameKey]]=L[d.attributesKey]?L:L[d.instructionKey],U+(d.indentInstruction?y:"")+g(G,d,b)}},"")}function R(_,d,b){var P;for(P in _)if(_.hasOwnProperty(P))switch(P){case d.parentKey:case d.attributesKey:break;case d.textKey:if(d.indentText||b)return!0;break;case d.cdataKey:if(d.indentCdata||b)return!0;break;case d.instructionKey:if(d.indentInstruction||b)return!0;break;case d.doctypeKey:case d.commentKey:return!0;default:return!0}return!1}function m(_,d,b,P,U){e=_,i=d;var L="elementNameFn"in b?b.elementNameFn(d,_):d;if(typeof _>"u"||_===null||_==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(d,_)||b.fullTagEmptyElement?"<"+L+"></"+L+">":"<"+L+"/>";var y=[];if(d){if(y.push("<"+L),typeof _!="object")return y.push(">"+S(_,b)+"</"+L+">"),y.join("");_[b.attributesKey]&&y.push(a(_[b.attributesKey],b,P));var G=R(_,b,!0)||_[b.attributesKey]&&_[b.attributesKey]["xml:space"]==="preserve";if(G||("fullTagEmptyElementFn"in b?G=b.fullTagEmptyElementFn(d,_):G=b.fullTagEmptyElement),G)y.push(">");else return y.push("/>"),y.join("")}return y.push(v(_,b,P+1,!1)),e=_,i=d,d&&y.push((U?c(b,P,!1):"")+"</"+L+">"),y.join("")}function v(_,d,b,P){var U,L,y,G=[];for(L in _)if(_.hasOwnProperty(L))for(y=t(_[L])?_[L]:[_[L]],U=0;U<y.length;++U){switch(L){case d.declarationKey:G.push(o(y[U],d,b));break;case d.instructionKey:G.push((d.indentInstruction?c(d,b,P):"")+g(y[U],d,b));break;case d.attributesKey:case d.parentKey:break;case d.textKey:G.push((d.indentText?c(d,b,P):"")+S(y[U],d));break;case d.cdataKey:G.push((d.indentCdata?c(d,b,P):"")+x(y[U],d));break;case d.doctypeKey:G.push(c(d,b,P)+C(y[U],d));break;case d.commentKey:G.push(c(d,b,P)+A(y[U],d));break;default:G.push(c(d,b,P)+m(y[U],L,d,b,R(y[U],d)))}P=P&&!G.length}return G.join("")}return ue=function(_,d){d=s(d);var b=[];return e=_,i="_root_",d.compact?b.push(v(_,d,0,!0)):(_[d.declarationKey]&&b.push(o(_[d.declarationKey],d,0)),_[d.elementsKey]&&_[d.elementsKey].length&&b.push(N(_[d.elementsKey],d,0,!b.length))),b.join("")},ue}var he,Ve;function Ei(){if(Ve)return he;Ve=1;var h=Ye();return he=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return h(i,e)},he}var fe,Ge;function xi(){if(Ge)return fe;Ge=1;var h=Ue(),t=yi(),e=Ye(),i=Ei();return fe={xml2js:h,xml2json:t,js2xml:e,json2xml:i},fe}var de=xi(),wi=Ie();const ht=class ht{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let a={...s,...c,...ht.propToNumber(c,["version","width","height","tilewidth","tileheight","nextlayerid","nextobjectid","hexsidelength","opacity","x","y","offsetx","offsety","startx","starty","id","firstgid","imageheight","imagewidth","margin","columns","rows","tilecount","rotation","gid","tileid","duration","parallaxx","parallaxy","repeatx","repeaty","pixelsize"]),...ht.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(a.properties){const g=ht.toArray(a.properties.property),A={};for(let x of g){const C=x._attributes;if(!C)continue;let S;switch(C.type){case"file":S=this.getImagePath(C.value);break;case"object":case"float":case"int":S=+C.value;break;case"bool":S=C.value=="true";break;case"class":S={...this.transform(x)?.properties??{},_classname:C.propertytype};break;default:S=C.value}A[C.name]=S}a.properties=A}a.polygon&&(a.polygon=this.transform(a.polygon)),a.polyline&&(a.polyline=this.transform(a.polyline)),a.points&&(a=a.points.split(" ").map(g=>{const A=g.split(",");return{x:+A[0],y:+A[1]}})),a.point&&(a.point=!0),a.ellipse&&(a.ellipse=!0),a.text&&(a.text={text:a.text._text,...this.transform(a.text)},delete a.text._text),a.image&&(a.image=this.transform(a.image)),a.source&&(this.isTilesetSource(a)||(a.source=this.getImagePath(a.source)));const o=a.object||a.objectgroup?.object;return o&&(a.objects=ht.toArray(o).map(g=>this.transform(g))),delete a._attributes,delete a.attributes,delete a.object,delete a.objectgroup,a}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:Se(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let a=0;a<i;a+=4)c[s]=t.readUInt32LE(a),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?ht.unpackTileBytes(wi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=de.xml2js(this.xml,{compact:!0}),e=de.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=A=>{const{objectgroup:x,group:C,layer:S,imagelayer:F}=A,I=N=>{N&&ht.toArray(N).forEach(R=>{if(this.layers.has(+R._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${R._attributes.id} already exists`);this.layers.set(+R._attributes.id,R)})};I(x),I(S),I(C),I(F),C&&s(C)};s(t.map);const c=(A,x=[])=>{if(!A)return x;for(let C of A){const{name:S}=C;if(!["layer","group","imagelayer","objectgroup"].includes(S))continue;const F=C.elements?.find(N=>N.name=="data");C.layer=this.layers.get(+C.attributes.id);const I={...this.transform(F)??{},...this.transform(C),...this.transform(C.layer),layers:c(C.elements),data:F?F.elements[0].text:void 0,type:S=="layer"?"tilelayer":S};delete I.elements,delete I.layer,I.data&&(I.data=ht.decode(I,I.width*I.height)),x.push(I)}return x},a=c(e.elements[0].elements),o=ht.toArray(i).map(A=>this.transform(A)),g={...this.transform(t.map),layers:a,tilesets:o};return delete g.layer,delete g.tileset,delete g.group,delete g.imagelayer,g}parseTileset(){const t=de.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:ht.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=ht.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};ht.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},ht.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let pe=ht;class me{constructor(t){this.properties={},this.properties=t?.properties??{}}getProperty(t,e){const i=this.properties[t];return i===void 0?e:i}hasProperty(t){return!!this.properties[t]}setProperty(t,e){this.properties[t]=e}getType(){return this.class||this.type}}const vi=2147483648,bi=1073741824,Ti=536870912,Ai=268435456;class kt extends me{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&vi)}get verticalFlip(){return!!(this._gid&bi)}get diagonalFlip(){return!!(this._gid&Ti)}get rotatedHex120(){return!!(this._gid&Ai)}get gid(){return kt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends kt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Si extends kt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class ge extends me{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=kt.getRealGid(t),c=ge.findTileSet(s,this.tilesets);if(!c)return;const a=c.getTile(s-c.firstgid);return a?new _e({...a.tile,gid:t,index:e,layerIndex:i}):new _e({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Si(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class Ci extends me{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new _e(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class At{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=o=>At.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const g=new pe(o,t,this.basePath);if(e=="map"){const A=g.parseMap();return i(A)}else if(e=="tileset"){const A=g.parseTileset();return i(A)}}return i(JSON.parse(o))};if(At.typeOfFile(t).isObject)return i(t);const{isHttp:a}=At.typeOfFile(t);if(s(t))c(t);else if(a||At.isBrowser()){let o=a?t:Se(this.basePath,t);At.isBrowser()&&window.urlCache&&(o=window.urlCache[t]),fetch(o,{headers:{"Content-Type":"application/xml"}}).then(g=>g.text()).then(c).catch(g=>i(null,g))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&At.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,a)=>{let o=!1;if(a)return t(null,a);if(c.tilesets){const g=[],A=()=>{x++,x==c.tilesets.length&&!o&&(c.tilesets=g,t(c))};let x=0;for(let C=0;C<c.tilesets.length;C++){const S=c.tilesets[C];if(!S.source||S.tiles||S.image||S.tile){g[C]=S,A();continue}i&&At.typeOfFile(S.source).isPath&&(S.source=s(S.source)),this._parseFile(S.source,"tileset",(F,I)=>{if(I)return o=!0,t(null,I);g[C]={...F,firstgid:S.firstgid},A()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const St={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var Bi=Object.defineProperty,Mi=(h,t,e)=>t in h?Bi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ct=(h,t,e)=>(Mi(h,typeof t!="symbol"?t+"":t,e),e);const Yt=class qt extends O.Geometry{constructor(t){const e=new O.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:O.BufferUsage.VERTEX|O.BufferUsage.COPY_DST,shrinkToFit:!1}),i=qt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:8},aFrame:{buffer:e,format:"float32x4",stride:i,offset:16},aAnim:{buffer:e,format:"float32x2",stride:i,offset:32},aTextureId:{buffer:e,format:"sint32",stride:i,offset:40},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:44},aAlpha:{buffer:e,format:"float32",stride:i,offset:48}}}),Ct(this,"lastTimeAccess",0),Ct(this,"vertSize",qt.vertSize),Ct(this,"vertPerQuad",qt.vertPerQuad),Ct(this,"stride",qt.stride),Ct(this,"buf"),this.buf=e}};Ct(Yt,"vertSize",13),Ct(Yt,"vertPerQuad",4),Ct(Yt,"stride",Yt.vertSize*4);let Ii=Yt;var Fi=Object.defineProperty,Di=(h,t,e)=>t in h?Fi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Bt=(h,t,e)=>(Di(h,typeof t!="symbol"?t+"":t,e),e);class Ke{constructor(){Bt(this,"pipe_uniforms",new O.UniformGroup({u_proj_trans:{value:new O.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class qe{constructor(t,e){Bt(this,"renderer"),Bt(this,"tileAnim",[0,0]),Bt(this,"ibLen",0),Bt(this,"indexBuffer",null),Bt(this,"shader"),Bt(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new O.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:O.BufferUsage.INDEX|O.BufferUsage.COPY_DST}),this.indexBuffer.destroy=O.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Ii(this.indexBuffer);return t.lastTimeAccess=Date.now(),t}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(t){const e=t*6;e<=this.ibLen||(this.ibLen=e,this.indexBuffer.data=Ni(t,St.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:a}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),a[0]=c[0],a[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Bt(qe,"extension",{type:[O.ExtensionType.WebGLPipes,O.ExtensionType.WebGPUPipes],name:"tilemap"});function Ni(h,t){const e=h*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var Oi=Object.defineProperty,Pi=(h,t,e)=>t in h?Oi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,bt=(h,t,e)=>(Pi(h,typeof t!="symbol"?t+"":t,e),e);class Ot{constructor(t){bt(this,"max_textures"),bt(this,"arr",[]),bt(this,"count",0),bt(this,"dirty",!1),bt(this,"dirty_gpu",!1),bt(this,"bind_group",null),bt(this,"bind_group_resources",{}),bt(this,"tex_sizes",null),bt(this,"null_color",new Float32Array([0,0,0,.5])),bt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new O.Buffer({usage:O.BufferUsage.UNIFORM|O.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let a=0;a<i;a++){const o=e[a];o&&(t[a*4]=o.pixelWidth,t[a*4+1]=o.pixelHeight,t[a*4+2]=1/o.pixelWidth,t[a*4+3]=1/o.pixelHeight)}t[s*4]=c[0],t[s*4+1]=c[1],t[s*4+2]=c[2],t[s*4+3]=c[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:t,max_textures:e,arr:i,count:s}=this;let c=0;t[c++]=new O.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let a=0;a<e;a++){const o=(a<s?i[a]:null)||O.Texture.EMPTY.source;t[c++]=o.source,t[c++]=o.style}return this.bind_group||(this.bind_group=new O.BindGroup(t)),this.bind_group}static generate_gpu_textures(t){const e=[];e.push("struct TextureArrayFields {"),e.push(` u_texture_size: array<vec4f, ${t}>,`),e.push(" u_null_color: vec4f"),e.push("}"),e.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let i=0;i<t;i++)e.push(`@group(1) @binding(${i*2+1}) var u_texture_${i}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i*2+2}) var u_sampler_${i}: sampler;`);e.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),e.push("switch texture_id {");for(let i=0;i<t;i++)e.push(` case ${i}: { return textureSampleGrad(u_texture_${i}, u_sampler_${i}, uv, dx, dy); }`);return e.push(" default: { return taf.u_null_color; }"),e.push("} }"),e.join(`
86
+ Char: `+f.c),a=new Error(a),f.error=a,j(f,"onerror",a),f}function ht(f){return f.sawRoot&&!f.closedRoot&&L(f,"Unclosed root tag"),f.state!==g.BEGIN&&f.state!==g.BEGIN_WHITESPACE&&f.state!==g.TEXT&&tt(f,"Unexpected end"),Q(f),f.c="",f.closed=!0,j(f,"onend"),i.call(f,f.strict,f.opt),f}function L(f,a){if(typeof f!="object"||!(f instanceof i))throw new Error("bad call to strictFail");f.strict&&tt(f,a)}function nt(f){f.strict||(f.tagName=f.tagName[f.looseCase]());var a=f.tags[f.tags.length-1]||f,S=f.tag={name:f.tagName,attributes:{}};f.opt.xmlns&&(S.ns=a.ns),f.attribList.length=0,z(f,"onopentagstart",S)}function dt(f,a){var S=f.indexOf(":"),w=S<0?["",f]:f.split(":"),q=w[0],et=w[1];return a&&f==="xmlns"&&(q="xmlns",et=""),{prefix:q,local:et}}function yt(f){if(f.strict||(f.attribName=f.attribName[f.looseCase]()),f.attribList.indexOf(f.attribName)!==-1||f.tag.attributes.hasOwnProperty(f.attribName)){f.attribName=f.attribValue="";return}if(f.opt.xmlns){var a=dt(f.attribName,!0),S=a.prefix,w=a.local;if(S==="xmlns")if(w==="xml"&&f.attribValue!==I)L(f,"xml: prefix must be bound to "+I+`
87
+ Actual: `+f.attribValue);else if(w==="xmlns"&&f.attribValue!==M)L(f,"xmlns: prefix must be bound to "+M+`
88
+ Actual: `+f.attribValue);else{var q=f.tag,et=f.tags[f.tags.length-1]||f;q.ns===et.ns&&(q.ns=Object.create(et.ns)),q.ns[w]=f.attribValue}f.attribList.push([f.attribName,f.attribValue])}else f.tag.attributes[f.attribName]=f.attribValue,z(f,"onattribute",{name:f.attribName,value:f.attribValue});f.attribName=f.attribValue=""}function K(f,a){if(f.opt.xmlns){var S=f.tag,w=dt(f.tagName);S.prefix=w.prefix,S.local=w.local,S.uri=S.ns[w.prefix]||"",S.prefix&&!S.uri&&(L(f,"Unbound namespace prefix: "+JSON.stringify(f.tagName)),S.uri=w.prefix);var q=f.tags[f.tags.length-1]||f;S.ns&&q.ns!==S.ns&&Object.keys(S.ns).forEach(function(wt){z(f,"onopennamespace",{prefix:wt,uri:S.ns[wt]})});for(var et=0,X=f.attribList.length;et<X;et++){var ot=f.attribList[et],pt=ot[0],Nt=ot[1],at=dt(pt,!0),Tt=at.prefix,Te=at.local,zt=Tt===""?"":S.ns[Tt]||"",Ot={name:pt,value:Nt,prefix:Tt,local:Te,uri:zt};Tt&&Tt!=="xmlns"&&!zt&&(L(f,"Unbound namespace prefix: "+JSON.stringify(Tt)),Ot.uri=Tt),f.tag.attributes[pt]=Ot,z(f,"onattribute",Ot)}f.attribList.length=0}f.tag.isSelfClosing=!!a,f.sawRoot=!0,f.tags.push(f.tag),z(f,"onopentag",f.tag),a||(!f.noscript&&f.tagName.toLowerCase()==="script"?f.state=g.SCRIPT:f.state=g.TEXT,f.tag=null,f.tagName=""),f.attribName=f.attribValue="",f.attribList.length=0}function W(f){if(!f.tagName){L(f,"Weird empty close tag."),f.textNode+="</>",f.state=g.TEXT;return}if(f.script){if(f.tagName!=="script"){f.script+="</"+f.tagName+">",f.tagName="",f.state=g.SCRIPT;return}z(f,"onscript",f.script),f.script=""}var a=f.tags.length,S=f.tagName;f.strict||(S=S[f.looseCase]());for(var w=S;a--;){var q=f.tags[a];if(q.name!==w)L(f,"Unexpected close tag");else break}if(a<0){L(f,"Unmatched closing tag: "+f.tagName),f.textNode+="</"+f.tagName+">",f.state=g.TEXT;return}f.tagName=S;for(var et=f.tags.length;et-- >a;){var X=f.tag=f.tags.pop();f.tagName=f.tag.name,z(f,"onclosetag",f.tagName);var ot={};for(var pt in X.ns)ot[pt]=X.ns[pt];var Nt=f.tags[f.tags.length-1]||f;f.opt.xmlns&&X.ns!==Nt.ns&&Object.keys(X.ns).forEach(function(at){var Tt=X.ns[at];z(f,"onclosenamespace",{prefix:at,uri:Tt})})}a===0&&(f.closedRoot=!0),f.tagName=f.attribValue=f.attribName="",f.attribList.length=0,f.state=g.TEXT}function ft(f){var a=f.entity,S=a.toLowerCase(),w,q="";return f.ENTITIES[a]?f.ENTITIES[a]:f.ENTITIES[S]?f.ENTITIES[S]:(a=S,a.charAt(0)==="#"&&(a.charAt(1)==="x"?(a=a.slice(2),w=parseInt(a,16),q=w.toString(16)):(a=a.slice(1),w=parseInt(a,10),q=w.toString(10))),a=a.replace(/^0+/,""),isNaN(w)||q.toLowerCase()!==a?(L(f,"Invalid character entity"),"&"+f.entity+";"):String.fromCodePoint(w))}function ct(f,a){a==="<"?(f.state=g.OPEN_WAKA,f.startTagPosition=f.position):d(a)||(L(f,"Non-whitespace before first tag."),f.textNode=a,f.state=g.TEXT)}function J(f,a){var S="";return a<f.length&&(S=f.charAt(a)),S}function $(f){var a=this;if(this.error)throw this.error;if(a.closed)return tt(a,"Cannot write after close. Assign an onready handler.");if(f===null)return ht(a);typeof f=="object"&&(f=f.toString());for(var S=0,w="";w=J(f,S++),a.c=w,!!w;)switch(a.trackPosition&&(a.position++,w===`
89
+ `?(a.line++,a.column=0):a.column++),a.state){case g.BEGIN:if(a.state=g.BEGIN_WHITESPACE,w==="\uFEFF")continue;ct(a,w);continue;case g.BEGIN_WHITESPACE:ct(a,w);continue;case g.TEXT:if(a.sawRoot&&!a.closedRoot){for(var q=S-1;w&&w!=="<"&&w!=="&";)w=J(f,S++),w&&a.trackPosition&&(a.position++,w===`
90
+ `?(a.line++,a.column=0):a.column++);a.textNode+=f.substring(q,S-1)}w==="<"&&!(a.sawRoot&&a.closedRoot&&!a.strict)?(a.state=g.OPEN_WAKA,a.startTagPosition=a.position):(!d(w)&&(!a.sawRoot||a.closedRoot)&&L(a,"Text data outside of root node."),w==="&"?a.state=g.TEXT_ENTITY:a.textNode+=w);continue;case g.SCRIPT:w==="<"?a.state=g.SCRIPT_ENDING:a.script+=w;continue;case g.SCRIPT_ENDING:w==="/"?a.state=g.CLOSE_TAG:(a.script+="<"+w,a.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(w==="!")a.state=g.SGML_DECL,a.sgmlDecl="";else if(!d(w))if(U(O,w))a.state=g.OPEN_TAG,a.tagName=w;else if(w==="/")a.state=g.CLOSE_TAG,a.tagName="";else if(w==="?")a.state=g.PROC_INST,a.procInstName=a.procInstBody="";else{if(L(a,"Unencoded <"),a.startTagPosition+1<a.position){var et=a.position-a.startTagPosition;w=new Array(et).join(" ")+w}a.textNode+="<"+w,a.state=g.TEXT}continue;case g.SGML_DECL:if(a.sgmlDecl+w==="--"){a.state=g.COMMENT,a.comment="",a.sgmlDecl="";continue}a.doctype&&a.doctype!==!0&&a.sgmlDecl?(a.state=g.DOCTYPE_DTD,a.doctype+="<!"+a.sgmlDecl+w,a.sgmlDecl=""):(a.sgmlDecl+w).toUpperCase()===B?(z(a,"onopencdata"),a.state=g.CDATA,a.sgmlDecl="",a.cdata=""):(a.sgmlDecl+w).toUpperCase()===A?(a.state=g.DOCTYPE,(a.doctype||a.sawRoot)&&L(a,"Inappropriately located doctype declaration"),a.doctype="",a.sgmlDecl=""):w===">"?(z(a,"onsgmldeclaration",a.sgmlDecl),a.sgmlDecl="",a.state=g.TEXT):(b(w)&&(a.state=g.SGML_DECL_QUOTED),a.sgmlDecl+=w);continue;case g.SGML_DECL_QUOTED:w===a.q&&(a.state=g.SGML_DECL,a.q=""),a.sgmlDecl+=w;continue;case g.DOCTYPE:w===">"?(a.state=g.TEXT,z(a,"ondoctype",a.doctype),a.doctype=!0):(a.doctype+=w,w==="["?a.state=g.DOCTYPE_DTD:b(w)&&(a.state=g.DOCTYPE_QUOTED,a.q=w));continue;case g.DOCTYPE_QUOTED:a.doctype+=w,w===a.q&&(a.q="",a.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:w==="]"?(a.doctype+=w,a.state=g.DOCTYPE):w==="<"?(a.state=g.OPEN_WAKA,a.startTagPosition=a.position):b(w)?(a.doctype+=w,a.state=g.DOCTYPE_DTD_QUOTED,a.q=w):a.doctype+=w;continue;case g.DOCTYPE_DTD_QUOTED:a.doctype+=w,w===a.q&&(a.state=g.DOCTYPE_DTD,a.q="");continue;case g.COMMENT:w==="-"?a.state=g.COMMENT_ENDING:a.comment+=w;continue;case g.COMMENT_ENDING:w==="-"?(a.state=g.COMMENT_ENDED,a.comment=ut(a.opt,a.comment),a.comment&&z(a,"oncomment",a.comment),a.comment=""):(a.comment+="-"+w,a.state=g.COMMENT);continue;case g.COMMENT_ENDED:w!==">"?(L(a,"Malformed comment"),a.comment+="--"+w,a.state=g.COMMENT):a.doctype&&a.doctype!==!0?a.state=g.DOCTYPE_DTD:a.state=g.TEXT;continue;case g.CDATA:w==="]"?a.state=g.CDATA_ENDING:a.cdata+=w;continue;case g.CDATA_ENDING:w==="]"?a.state=g.CDATA_ENDING_2:(a.cdata+="]"+w,a.state=g.CDATA);continue;case g.CDATA_ENDING_2:w===">"?(a.cdata&&z(a,"oncdata",a.cdata),z(a,"onclosecdata"),a.cdata="",a.state=g.TEXT):w==="]"?a.cdata+="]":(a.cdata+="]]"+w,a.state=g.CDATA);continue;case g.PROC_INST:w==="?"?a.state=g.PROC_INST_ENDING:d(w)?a.state=g.PROC_INST_BODY:a.procInstName+=w;continue;case g.PROC_INST_BODY:if(!a.procInstBody&&d(w))continue;w==="?"?a.state=g.PROC_INST_ENDING:a.procInstBody+=w;continue;case g.PROC_INST_ENDING:w===">"?(z(a,"onprocessinginstruction",{name:a.procInstName,body:a.procInstBody}),a.procInstName=a.procInstBody="",a.state=g.TEXT):(a.procInstBody+="?"+w,a.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:U(_,w)?a.tagName+=w:(nt(a),w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:(d(w)||L(a,"Invalid character in tag name"),a.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:w===">"?(K(a,!0),W(a)):(L(a,"Forward-slash in opening tag not followed by >"),a.state=g.ATTRIB);continue;case g.ATTRIB:if(d(w))continue;w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:U(O,w)?(a.attribName=w,a.attribValue="",a.state=g.ATTRIB_NAME):L(a,"Invalid attribute name");continue;case g.ATTRIB_NAME:w==="="?a.state=g.ATTRIB_VALUE:w===">"?(L(a,"Attribute without value"),a.attribValue=a.attribName,yt(a),K(a)):d(w)?a.state=g.ATTRIB_NAME_SAW_WHITE:U(_,w)?a.attribName+=w:L(a,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(w==="=")a.state=g.ATTRIB_VALUE;else{if(d(w))continue;L(a,"Attribute without value"),a.tag.attributes[a.attribName]="",a.attribValue="",z(a,"onattribute",{name:a.attribName,value:""}),a.attribName="",w===">"?K(a):U(O,w)?(a.attribName=w,a.state=g.ATTRIB_NAME):(L(a,"Invalid attribute name"),a.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(d(w))continue;b(w)?(a.q=w,a.state=g.ATTRIB_VALUE_QUOTED):(a.opt.unquotedAttributeValues||tt(a,"Unquoted attribute value"),a.state=g.ATTRIB_VALUE_UNQUOTED,a.attribValue=w);continue;case g.ATTRIB_VALUE_QUOTED:if(w!==a.q){w==="&"?a.state=g.ATTRIB_VALUE_ENTITY_Q:a.attribValue+=w;continue}yt(a),a.q="",a.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:d(w)?a.state=g.ATTRIB:w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:U(O,w)?(L(a,"No whitespace between attributes"),a.attribName=w,a.attribValue="",a.state=g.ATTRIB_NAME):L(a,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!R(w)){w==="&"?a.state=g.ATTRIB_VALUE_ENTITY_U:a.attribValue+=w;continue}yt(a),w===">"?K(a):a.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(a.tagName)w===">"?W(a):U(_,w)?a.tagName+=w:a.script?(a.script+="</"+a.tagName,a.tagName="",a.state=g.SCRIPT):(d(w)||L(a,"Invalid tagname in closing tag"),a.state=g.CLOSE_TAG_SAW_WHITE);else{if(d(w))continue;k(O,w)?a.script?(a.script+="</"+w,a.state=g.SCRIPT):L(a,"Invalid tagname in closing tag."):a.tagName=w}continue;case g.CLOSE_TAG_SAW_WHITE:if(d(w))continue;w===">"?W(a):L(a,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var X,ot;switch(a.state){case g.TEXT_ENTITY:X=g.TEXT,ot="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:X=g.ATTRIB_VALUE_QUOTED,ot="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:X=g.ATTRIB_VALUE_UNQUOTED,ot="attribValue";break}if(w===";"){var pt=ft(a);a.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(pt)?(a.entity="",a.state=X,a.write(pt)):(a[ot]+=pt,a.entity="",a.state=X)}else U(a.entity.length?m:E,w)?a.entity+=w:(L(a,"Invalid character in entity name"),a[ot]+="&"+a.entity+w,a.entity="",a.state=X);continue;default:throw new Error(a,"Unknown state: "+a.state)}return a.position>=a.bufferCheckPosition&&s(a),a}String.fromCodePoint||(function(){var f=String.fromCharCode,a=Math.floor,S=function(){var w=16384,q=[],et,X,ot=-1,pt=arguments.length;if(!pt)return"";for(var Nt="";++ot<pt;){var at=Number(arguments[ot]);if(!isFinite(at)||at<0||at>1114111||a(at)!==at)throw RangeError("Invalid code point: "+at);at<=65535?q.push(at):(at-=65536,et=(at>>10)+55296,X=at%1024+56320,q.push(et,X)),(ot+1===pt||q.length>w)&&(Nt+=f.apply(null,q),q.length=0)}return Nt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S})()})(h)})(ne)),ne}var le,Ve;function ce(){return Ve||(Ve=1,le={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),le}var ue,Ye;function he(){if(Ye)return ue;Ye=1;var h=ce().isArray;return ue={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!h(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},ue}var fe,Ge;function Ke(){if(Ge)return fe;Ge=1;var h=Ii(),t=he(),e=ce().isArray,i,s;function c(_){return i=t.copyOptions(_),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function l(_){var E=Number(_);if(!isNaN(E))return E;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,E){var m;if(i.compact){if(!s[i[_+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[_+"Key"])!==-1:i.alwaysArray)&&(s[i[_+"Key"]]=[]),s[i[_+"Key"]]&&!e(s[i[_+"Key"]])&&(s[i[_+"Key"]]=[s[i[_+"Key"]]]),_+"Fn"in i&&typeof E=="string"&&(E=i[_+"Fn"](E,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in E)if(E.hasOwnProperty(m))if("instructionFn"in i)E[m]=i.instructionFn(E[m],m,s);else{var d=E[m];delete E[m],E[i.instructionNameFn(m,d,s)]=d}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(E):s[i[_+"Key"]]=E}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in E)if(E.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,E,s):m,i.instructionHasAttributes?(b[i.attributesKey]=E[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(E[m]=i.instructionFn(E[m],m,s)),b[i.instructionKey]=E[m])}else _+"Fn"in i&&(E=i[_+"Fn"](E,s)),b[i[_+"Key"]]=E;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function y(_){if("attributesFn"in i&&_&&(_=i.attributesFn(_,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&_){var E;for(E in _)if(_.hasOwnProperty(E)&&(i.trim&&(_[E]=_[E].trim()),i.nativeTypeAttributes&&(_[E]=l(_[E])),"attributeValueFn"in i&&(_[E]=i.attributeValueFn(_[E],E,s)),"attributeNameFn"in i)){var m=_[E];delete _[E],_[i.attributeNameFn(E,_[E],s)]=m}}return _}function C(_){var E={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,d;(d=m.exec(_.body))!==null;)E[d[1]]=d[2]||d[3]||d[4];E=y(E)}if(_.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(E).length&&(s[i.declarationKey][i.attributesKey]=E),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(_.body=_.body.trim());var b={};i.instructionHasAttributes&&Object.keys(E).length?(b[_.name]={},b[_.name][i.attributesKey]=E):b[_.name]=_.body,o("instruction",b)}}function v(_,E){var m;if(typeof _=="object"&&(E=_.attributes,_=_.name),E=y(E),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&E&&Object.keys(E).length){m[i.attributesKey]={};var d;for(d in E)E.hasOwnProperty(d)&&(m[i.attributesKey][d]=E[d])}!(_ in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(_)!==-1:i.alwaysArray)&&(s[_]=[]),s[_]&&!e(s[_])&&(s[_]=[s[_]]),e(s[_])?s[_].push(m):s[_]=m}else s[i.elementsKey]||(s[i.elementsKey]=[]),m={},m[i.typeKey]="element",m[i.nameKey]=_,!i.ignoreAttributes&&E&&Object.keys(E).length&&(m[i.attributesKey]=E),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function B(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=l(_)),i.sanitize&&(_=_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),o("text",_))}function A(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function I(_){var E=s[i.parentKey];i.addParent||delete s[i.parentKey],s=E}function M(_){i.ignoreCdata||(i.trim&&(_=_.trim()),o("cdata",_))}function N(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),o("doctype",_))}function O(_){_.note=_}return fe=function(_,E){var m=h.parser(!0,{}),d={};if(s=d,i=c(E),m.opt={strictEntities:!0},m.onopentag=v,m.ontext=B,m.oncomment=A,m.onclosetag=I,m.onerror=O,m.oncdata=M,m.ondoctype=N,m.onprocessinginstruction=C,m.write(_).close(),d[i.elementsKey]){var b=d[i.elementsKey];delete d[i.elementsKey],d[i.elementsKey]=b,delete d.text}return d},fe}var de,je;function Di(){if(je)return de;je=1;var h=he(),t=Ke();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return de=function(i,s){var c,l,o,y;return c=e(s),l=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(l,function(C,v){return C===y?"_":v},c.spaces):o=JSON.stringify(l,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},de}var pe,qe;function ze(){if(qe)return pe;qe=1;var h=he(),t=ce().isArray,e,i;function s(m){var d=h.copyOptions(m);return h.ensureFlagExists("ignoreDeclaration",d),h.ensureFlagExists("ignoreInstruction",d),h.ensureFlagExists("ignoreAttributes",d),h.ensureFlagExists("ignoreText",d),h.ensureFlagExists("ignoreComment",d),h.ensureFlagExists("ignoreCdata",d),h.ensureFlagExists("ignoreDoctype",d),h.ensureFlagExists("compact",d),h.ensureFlagExists("indentText",d),h.ensureFlagExists("indentCdata",d),h.ensureFlagExists("indentAttributes",d),h.ensureFlagExists("indentInstruction",d),h.ensureFlagExists("fullTagEmptyElement",d),h.ensureFlagExists("noQuotesForNativeAttributes",d),h.ensureSpacesExists(d),typeof d.spaces=="number"&&(d.spaces=Array(d.spaces+1).join(" ")),h.ensureKeyExists("declaration",d),h.ensureKeyExists("instruction",d),h.ensureKeyExists("attributes",d),h.ensureKeyExists("text",d),h.ensureKeyExists("comment",d),h.ensureKeyExists("cdata",d),h.ensureKeyExists("doctype",d),h.ensureKeyExists("type",d),h.ensureKeyExists("name",d),h.ensureKeyExists("elements",d),h.checkFnExists("doctype",d),h.checkFnExists("instruction",d),h.checkFnExists("cdata",d),h.checkFnExists("comment",d),h.checkFnExists("text",d),h.checkFnExists("instructionName",d),h.checkFnExists("elementName",d),h.checkFnExists("attributeName",d),h.checkFnExists("attributeValue",d),h.checkFnExists("attributes",d),h.checkFnExists("fullTagEmptyElement",d),d}function c(m,d,b){return(!b&&m.spaces?`
91
+ `:"")+Array(d+1).join(m.spaces)}function l(m,d,b){if(d.ignoreAttributes)return"";"attributesFn"in d&&(m=d.attributesFn(m,i,e));var R,U,k,g,V=[];for(R in m)m.hasOwnProperty(R)&&m[R]!==null&&m[R]!==void 0&&(g=d.noQuotesForNativeAttributes&&typeof m[R]!="string"?"":'"',U=""+m[R],U=U.replace(/"/g,"&quot;"),k="attributeNameFn"in d?d.attributeNameFn(R,U,i,e):R,V.push(d.spaces&&d.indentAttributes?c(d,b+1,!1):" "),V.push(k+"="+g+("attributeValueFn"in d?d.attributeValueFn(U,R,i,e):U)+g));return m&&Object.keys(m).length&&d.spaces&&d.indentAttributes&&V.push(c(d,b,!1)),V.join("")}function o(m,d,b){return e=m,i="xml",d.ignoreDeclaration?"":"<?xml"+l(m[d.attributesKey],d,b)+"?>"}function y(m,d,b){if(d.ignoreInstruction)return"";var R;for(R in m)if(m.hasOwnProperty(R))break;var U="instructionNameFn"in d?d.instructionNameFn(R,m[R],i,e):R;if(typeof m[R]=="object")return e=m,i=U,"<?"+U+l(m[R][d.attributesKey],d,b)+"?>";var k=m[R]?m[R]:"";return"instructionFn"in d&&(k=d.instructionFn(k,R,i,e)),"<?"+U+(k?" "+k:"")+"?>"}function C(m,d){return d.ignoreComment?"":"<!--"+("commentFn"in d?d.commentFn(m,i,e):m)+"-->"}function v(m,d){return d.ignoreCdata?"":"<![CDATA["+("cdataFn"in d?d.cdataFn(m,i,e):m.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function B(m,d){return d.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in d?d.doctypeFn(m,i,e):m)+">"}function A(m,d){return d.ignoreText?"":(m=""+m,m=m.replace(/&amp;/g,"&"),m=m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in d?d.textFn(m,i,e):m)}function I(m,d){var b;if(m.elements&&m.elements.length)for(b=0;b<m.elements.length;++b)switch(m.elements[b][d.typeKey]){case"text":if(d.indentText)return!0;break;case"cdata":if(d.indentCdata)return!0;break;case"instruction":if(d.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function M(m,d,b){e=m,i=m.name;var R=[],U="elementNameFn"in d?d.elementNameFn(m.name,m):m.name;R.push("<"+U),m[d.attributesKey]&&R.push(l(m[d.attributesKey],d,b));var k=m[d.elementsKey]&&m[d.elementsKey].length||m[d.attributesKey]&&m[d.attributesKey]["xml:space"]==="preserve";return k||("fullTagEmptyElementFn"in d?k=d.fullTagEmptyElementFn(m.name,m):k=d.fullTagEmptyElement),k?(R.push(">"),m[d.elementsKey]&&m[d.elementsKey].length&&(R.push(N(m[d.elementsKey],d,b+1)),e=m,i=m.name),R.push(d.spaces&&I(m,d)?`
92
+ `+Array(b+1).join(d.spaces):""),R.push("</"+U+">")):R.push("/>"),R.join("")}function N(m,d,b,R){return m.reduce(function(U,k){var g=c(d,b,R&&!U);switch(k.type){case"element":return U+g+M(k,d,b);case"comment":return U+g+C(k[d.commentKey],d);case"doctype":return U+g+B(k[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?g:"")+v(k[d.cdataKey],d);case"text":return U+(d.indentText?g:"")+A(k[d.textKey],d);case"instruction":var V={};return V[k[d.nameKey]]=k[d.attributesKey]?k:k[d.instructionKey],U+(d.indentInstruction?g:"")+y(V,d,b)}},"")}function O(m,d,b){var R;for(R in m)if(m.hasOwnProperty(R))switch(R){case d.parentKey:case d.attributesKey:break;case d.textKey:if(d.indentText||b)return!0;break;case d.cdataKey:if(d.indentCdata||b)return!0;break;case d.instructionKey:if(d.indentInstruction||b)return!0;break;case d.doctypeKey:case d.commentKey:return!0;default:return!0}return!1}function _(m,d,b,R,U){e=m,i=d;var k="elementNameFn"in b?b.elementNameFn(d,m):d;if(typeof m>"u"||m===null||m==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(d,m)||b.fullTagEmptyElement?"<"+k+"></"+k+">":"<"+k+"/>";var g=[];if(d){if(g.push("<"+k),typeof m!="object")return g.push(">"+A(m,b)+"</"+k+">"),g.join("");m[b.attributesKey]&&g.push(l(m[b.attributesKey],b,R));var V=O(m,b,!0)||m[b.attributesKey]&&m[b.attributesKey]["xml:space"]==="preserve";if(V||("fullTagEmptyElementFn"in b?V=b.fullTagEmptyElementFn(d,m):V=b.fullTagEmptyElement),V)g.push(">");else return g.push("/>"),g.join("")}return g.push(E(m,b,R+1,!1)),e=m,i=d,d&&g.push((U?c(b,R,!1):"")+"</"+k+">"),g.join("")}function E(m,d,b,R){var U,k,g,V=[];for(k in m)if(m.hasOwnProperty(k))for(g=t(m[k])?m[k]:[m[k]],U=0;U<g.length;++U){switch(k){case d.declarationKey:V.push(o(g[U],d,b));break;case d.instructionKey:V.push((d.indentInstruction?c(d,b,R):"")+y(g[U],d,b));break;case d.attributesKey:case d.parentKey:break;case d.textKey:V.push((d.indentText?c(d,b,R):"")+A(g[U],d));break;case d.cdataKey:V.push((d.indentCdata?c(d,b,R):"")+v(g[U],d));break;case d.doctypeKey:V.push(c(d,b,R)+B(g[U],d));break;case d.commentKey:V.push(c(d,b,R)+C(g[U],d));break;default:V.push(c(d,b,R)+_(g[U],k,d,b,O(g[U],d)))}R=R&&!V.length}return V.join("")}return pe=function(m,d){d=s(d);var b=[];return e=m,i="_root_",d.compact?b.push(E(m,d,0,!0)):(m[d.declarationKey]&&b.push(o(m[d.declarationKey],d,0)),m[d.elementsKey]&&m[d.elementsKey].length&&b.push(N(m[d.elementsKey],d,0,!b.length))),b.join("")},pe}var me,We;function Ni(){if(We)return me;We=1;var h=ze();return me=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return h(i,e)},me}var _e,He;function Oi(){if(He)return _e;He=1;var h=Ke(),t=Di(),e=ze(),i=Ni();return _e={xml2js:h,xml2json:t,js2xml:e,json2xml:i},_e}var ge=Oi(),Ri=Pe();const gt=class gt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let l={...s,...c,...gt.propToNumber(c,["version","width","height","tilewidth","tileheight","nextlayerid","nextobjectid","hexsidelength","opacity","x","y","offsetx","offsety","startx","starty","id","firstgid","imageheight","imagewidth","margin","columns","rows","tilecount","rotation","gid","tileid","duration","parallaxx","parallaxy","repeatx","repeaty","pixelsize"]),...gt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(l.properties){const y=gt.toArray(l.properties.property),C={};for(let v of y){const B=v._attributes;if(!B)continue;let A;switch(B.type){case"file":A=this.getImagePath(B.value);break;case"object":case"float":case"int":A=+B.value;break;case"bool":A=B.value=="true";break;case"class":A={...this.transform(v)?.properties??{},_classname:B.propertytype};break;default:A=B.value}C[B.name]=A}l.properties=C}l.polygon&&(l.polygon=this.transform(l.polygon)),l.polyline&&(l.polyline=this.transform(l.polyline)),l.points&&(l=l.points.split(" ").map(y=>{const C=y.split(",");return{x:+C[0],y:+C[1]}})),l.point&&(l.point=!0),l.ellipse&&(l.ellipse=!0),l.text&&(l.text={text:l.text._text,...this.transform(l.text)},delete l.text._text),l.image&&(l.image=this.transform(l.image)),l.source&&(this.isTilesetSource(l)||(l.source=this.getImagePath(l.source)));const o=l.object||l.objectgroup?.object;return o&&(l.objects=gt.toArray(o).map(y=>this.transform(y))),delete l._attributes,delete l.attributes,delete l.object,delete l.objectgroup,l}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:De(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let l=0;l<i;l+=4)c[s]=t.readUInt32LE(l),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?gt.unpackTileBytes(Ri.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=ge.xml2js(this.xml,{compact:!0}),e=ge.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=C=>{const{objectgroup:v,group:B,layer:A,imagelayer:I}=C,M=N=>{N&&gt.toArray(N).forEach(O=>{if(this.layers.has(+O._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${O._attributes.id} already exists`);this.layers.set(+O._attributes.id,O)})};M(v),M(A),M(B),M(I),B&&s(B)};s(t.map);const c=(C,v=[])=>{if(!C)return v;for(let B of C){const{name:A}=B;if(!["layer","group","imagelayer","objectgroup"].includes(A))continue;const I=B.elements?.find(N=>N.name=="data");B.layer=this.layers.get(+B.attributes.id);const M={...this.transform(I)??{},...this.transform(B),...this.transform(B.layer),layers:c(B.elements),data:I?I.elements[0].text:void 0,type:A=="layer"?"tilelayer":A};delete M.elements,delete M.layer,M.data&&(M.data=gt.decode(M,M.width*M.height)),v.push(M)}return v},l=c(e.elements[0].elements),o=gt.toArray(i).map(C=>this.transform(C)),y={...this.transform(t.map),layers:l,tilesets:o};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=ge.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:gt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=gt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};gt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},gt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let ye=gt;class xe{constructor(t){this.properties={},this.properties=t?.properties??{}}getProperty(t,e){const i=this.properties[t];return i===void 0?e:i}hasProperty(t){return!!this.properties[t]}setProperty(t,e){this.properties[t]=e}getType(){return this.class||this.type}}const Pi=2147483648,Ui=1073741824,ki=536870912,Li=268435456;class Kt extends xe{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Pi)}get verticalFlip(){return!!(this._gid&Ui)}get diagonalFlip(){return!!(this._gid&ki)}get rotatedHex120(){return!!(this._gid&Li)}get gid(){return Kt.getRealGid(this._gid)}set gid(t){this._gid=t}}let Ee=class extends Kt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Vi extends Kt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class we extends xe{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=Kt.getRealGid(t),c=we.findTileSet(s,this.tilesets);if(!c)return;const l=c.getTile(s-c.firstgid);return l?new Ee({...l.tile,gid:t,index:e,layerIndex:i}):new Ee({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Vi(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class Yi extends xe{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new Ee(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class Mt{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=o=>Mt.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const y=new ye(o,t,this.basePath);if(e=="map"){const C=y.parseMap();return i(C)}else if(e=="tileset"){const C=y.parseTileset();return i(C)}}return i(JSON.parse(o))};if(Mt.typeOfFile(t).isObject)return i(t);const{isHttp:l}=Mt.typeOfFile(t);if(s(t))c(t);else if(l||Mt.isBrowser()){let o=l?t:De(this.basePath,t);Mt.isBrowser()&&window.urlCache&&(o=window.urlCache[t]),fetch(o,{headers:{"Content-Type":"application/xml"}}).then(y=>y.text()).then(c).catch(y=>i(null,y))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&Mt.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,l)=>{let o=!1;if(l)return t(null,l);if(c.tilesets){const y=[],C=()=>{v++,v==c.tilesets.length&&!o&&(c.tilesets=y,t(c))};let v=0;for(let B=0;B<c.tilesets.length;B++){const A=c.tilesets[B];if(!A.source||A.tiles||A.image||A.tile){y[B]=A,C();continue}i&&Mt.typeOfFile(A.source).isPath&&(A.source=s(A.source)),this._parseFile(A.source,"tileset",(I,M)=>{if(M)return o=!0,t(null,M);y[B]={...I,firstgid:A.firstgid},C()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const Ft={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var Gi=Object.defineProperty,Ki=(h,t,e)=>t in h?Gi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,It=(h,t,e)=>(Ki(h,typeof t!="symbol"?t+"":t,e),e);const jt=class Wt extends P.Geometry{constructor(t){const e=new P.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:P.BufferUsage.VERTEX|P.BufferUsage.COPY_DST,shrinkToFit:!1}),i=Wt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:8},aFrame:{buffer:e,format:"float32x4",stride:i,offset:16},aAnim:{buffer:e,format:"float32x2",stride:i,offset:32},aTextureId:{buffer:e,format:"sint32",stride:i,offset:40},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:44},aAlpha:{buffer:e,format:"float32",stride:i,offset:48}}}),It(this,"lastTimeAccess",0),It(this,"vertSize",Wt.vertSize),It(this,"vertPerQuad",Wt.vertPerQuad),It(this,"stride",Wt.stride),It(this,"buf"),this.buf=e}};It(jt,"vertSize",13),It(jt,"vertPerQuad",4),It(jt,"stride",jt.vertSize*4);let ji=jt;var qi=Object.defineProperty,zi=(h,t,e)=>t in h?qi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Dt=(h,t,e)=>(zi(h,typeof t!="symbol"?t+"":t,e),e);class $e{constructor(){Dt(this,"pipe_uniforms",new P.UniformGroup({u_proj_trans:{value:new P.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class Xe{constructor(t,e){Dt(this,"renderer"),Dt(this,"tileAnim",[0,0]),Dt(this,"ibLen",0),Dt(this,"indexBuffer",null),Dt(this,"shader"),Dt(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new P.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:P.BufferUsage.INDEX|P.BufferUsage.COPY_DST}),this.indexBuffer.destroy=P.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new ji(this.indexBuffer);return t.lastTimeAccess=Date.now(),t}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(t){const e=t*6;e<=this.ibLen||(this.ibLen=e,this.indexBuffer.data=Wi(t,Ft.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:l}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),l[0]=c[0],l[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Dt(Xe,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function Wi(h,t){const e=h*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var Hi=Object.defineProperty,$i=(h,t,e)=>t in h?Hi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Bt=(h,t,e)=>($i(h,typeof t!="symbol"?t+"":t,e),e);class kt{constructor(t){Bt(this,"max_textures"),Bt(this,"arr",[]),Bt(this,"count",0),Bt(this,"dirty",!1),Bt(this,"dirty_gpu",!1),Bt(this,"bind_group",null),Bt(this,"bind_group_resources",{}),Bt(this,"tex_sizes",null),Bt(this,"null_color",new Float32Array([0,0,0,.5])),Bt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new P.Buffer({usage:P.BufferUsage.UNIFORM|P.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let l=0;l<i;l++){const o=e[l];o&&(t[l*4]=o.pixelWidth,t[l*4+1]=o.pixelHeight,t[l*4+2]=1/o.pixelWidth,t[l*4+3]=1/o.pixelHeight)}t[s*4]=c[0],t[s*4+1]=c[1],t[s*4+2]=c[2],t[s*4+3]=c[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:t,max_textures:e,arr:i,count:s}=this;let c=0;t[c++]=new P.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let l=0;l<e;l++){const o=(l<s?i[l]:null)||P.Texture.EMPTY.source;t[c++]=o.source,t[c++]=o.style}return this.bind_group||(this.bind_group=new P.BindGroup(t)),this.bind_group}static generate_gpu_textures(t){const e=[];e.push("struct TextureArrayFields {"),e.push(` u_texture_size: array<vec4f, ${t}>,`),e.push(" u_null_color: vec4f"),e.push("}"),e.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let i=0;i<t;i++)e.push(`@group(1) @binding(${i*2+1}) var u_texture_${i}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i*2+2}) var u_sampler_${i}: sampler;`);e.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),e.push("switch texture_id {");for(let i=0;i<t;i++)e.push(` case ${i}: { return textureSampleGrad(u_texture_${i}, u_sampler_${i}, uv, dx, dy); }`);return e.push(" default: { return taf.u_null_color; }"),e.push("} }"),e.join(`
12
93
  `)}static generate_gl_textures(t){const e=[];e.push(`uniform vec4 u_texture_size[${t+1}];`),e.push(`uniform sampler2D u_textures[${t}];`),e.push("uniform vec4 u_null_color;"),e.push("vec4 sampleMultiTexture(float texture_id, vec2 uv) {"),e.push(`if(texture_id < -0.5) return u_texture_size[${t}];`);for(let i=0;i<t;i++)e.push(`if(texture_id < ${i}.5) return texture(u_textures[${i}], uv * u_texture_size[${i}].zw);`);return e.push(`return u_texture_size[${t}];`),e.push("}"),e.join(`
13
- `)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var Ri=Object.defineProperty,Ui=(h,t,e)=>t in h?Ri(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ye=(h,t,e)=>(Ui(h,typeof t!="symbol"?t+"":t,e),e);const Li=`
94
+ `)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var Xi=Object.defineProperty,Qi=(h,t,e)=>t in h?Xi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ve=(h,t,e)=>(Qi(h,typeof t!="symbol"?t+"":t,e),e);const Ji=`
14
95
  in vec2 aVertexPosition;
15
96
  in vec2 aTextureCoord;
16
97
  in vec4 aFrame;
@@ -41,7 +122,7 @@ void main(void)
41
122
  vTextureId = aTextureId;
42
123
  vAlpha = aAlpha;
43
124
  }
44
- `,ki=`
125
+ `,Zi=`
45
126
  #ifdef GL_FRAGMENT_PRECISION_HIGH
46
127
  precision highp float;
47
128
  #else
@@ -61,7 +142,7 @@ void main(void)
61
142
  vec4 color = sampleMultiTexture(textureId, textureCoord);
62
143
  finalColor = color * vAlpha;
63
144
  }
64
- `;class je extends Ke{constructor(){super(...arguments),ye(this,"_shader",null),ye(this,"max_textures",St.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),a=s.resources.texture_uniforms;a.uniforms.u_texture_size!==c.tex_sizes&&(a.uniforms.u_texture_size=c.tex_sizes,a.update());for(let o=0;o<c.length;o++)i.texture.bind(c.arr[o],o);i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new O.Shader({glProgram:O.GlProgram.from({vertex:Li,fragment:ki.replace("//include_textures",Ot.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new O.UniformGroup(Ot.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}ye(je,"extension",{type:[O.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Yi=Object.defineProperty,Vi=(h,t,e)=>t in h?Yi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,$t=(h,t,e)=>(Vi(h,typeof t!="symbol"?t+"":t,e),e);const Gi=`
145
+ `;class Qe extends $e{constructor(){super(...arguments),ve(this,"_shader",null),ve(this,"max_textures",Ft.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),l=s.resources.texture_uniforms;l.uniforms.u_texture_size!==c.tex_sizes&&(l.uniforms.u_texture_size=c.tex_sizes,l.update());for(let o=0;o<c.length;o++)i.texture.bind(c.arr[o],o);i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({glProgram:P.GlProgram.from({vertex:Ji,fragment:Zi.replace("//include_textures",kt.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new P.UniformGroup(kt.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}ve(Qe,"extension",{type:[P.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var tr=Object.defineProperty,er=(h,t,e)=>t in h?tr(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Jt=(h,t,e)=>(er(h,typeof t!="symbol"?t+"":t,e),e);const ir=`
65
146
  struct GlobalUniforms {
66
147
  uProjectionMatrix:mat3x3f,
67
148
  uWorldTransformMatrix:mat3x3f,
@@ -107,7 +188,7 @@ fn mainVert(
107
188
 
108
189
  return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
109
190
  };
110
- `,Ki=`
191
+ `,rr=`
111
192
  //include_textures
112
193
 
113
194
  @fragment
@@ -124,14 +205,17 @@ fn mainFrag(
124
205
  var color = sampleMultiTexture(vTextureId, uv, dx, dy);
125
206
  return color * vAlpha;
126
207
  };
127
- `;class ze extends Ke{constructor(){super(...arguments),$t(this,"_shader",null),$t(this,"max_textures",St.TEXTURES_PER_TILEMAP),$t(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new O.Shader({gpuProgram:O.GpuProgram.from({vertex:{source:Gi,entryPoint:"mainVert"},fragment:{source:Ki.replace("//include_textures",Ot.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new O.BindGroup({ut:this.pipe_uniforms})}}$t(ze,"extension",{type:[O.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var qi=Object.defineProperty,ji=(h,t,e)=>t in h?qi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,st=(h,t,e)=>(ji(h,typeof t!="symbol"?t+"":t,e),e),We=(h=>(h[h.U=0]="U",h[h.V=1]="V",h[h.X=2]="X",h[h.Y=3]="Y",h[h.TILE_WIDTH=4]="TILE_WIDTH",h[h.TILE_HEIGHT=5]="TILE_HEIGHT",h[h.ROTATE=6]="ROTATE",h[h.ANIM_X=7]="ANIM_X",h[h.ANIM_Y=8]="ANIM_Y",h[h.TEXTURE_INDEX=9]="TEXTURE_INDEX",h[h.ANIM_COUNT_X=10]="ANIM_COUNT_X",h[h.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",h[h.ANIM_DIVISOR=12]="ANIM_DIVISOR",h[h.ALPHA=13]="ALPHA",h))(We||{});const yt=Object.keys(We).length/2;class $e extends O.ViewContainer{constructor(t){super({}),st(this,"shadowColor",new Float32Array([0,0,0,.5])),st(this,"state",O.State.for2d()),st(this,"is_valid",!1),st(this,"renderPipeId","tilemap"),st(this,"canBundle",!0),st(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),st(this,"tileAnim",null),st(this,"rects_count",0),st(this,"compositeParent",!1),st(this,"tileset",new Ot(St.TEXTURES_PER_TILEMAP)),st(this,"tilemapBounds",new O.Bounds),st(this,"hasAnimatedTile",!1),st(this,"pointsBuf",[]),st(this,"batched"),st(this,"vbId",0),st(this,"vb",null),st(this,"vbBuffer",null),st(this,"vbArray",null),st(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){let e=this.tileset;if(t instanceof Ot)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof O.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Ot(St.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let s=0;s<t.length;s++)if(t[s]?.source!==e.arr[s]){i=!1;break}if(i)return this}e=this.tileset=new Ot(St.TEXTURES_PER_TILEMAP);for(let i=0;i<t.length;i++)e.push(t[i]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,s={}){this.didViewUpdate=!0;let c,a=-1,o=!1;if(typeof t=="number")a=t,o=!0,c=this.tileset.arr[a];else{let d;typeof t=="string"?d=O.Texture.from(t):d=t;const b=this.tileset;for(let P=0;P<b.count;P++)if(b.arr[P]===d.source){a=P;break}"frame"in d&&(s.u=s.u??d.frame.x,s.v=s.v??d.frame.y,s.tileWidth=s.tileWidth??d.orig.width,s.tileHeight=s.tileHeight??d.orig.height),c=d.source}if(!o&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:g=0,v:A=0,tileWidth:x=c.width,tileHeight:C=c.height,animX:S=0,animY:F=0,rotate:I=0,animCountX:N=1024,animCountY:R=1024,animDivisor:m=1,alpha:v=1}=s,_=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||S>0||F>0,_.push(g),_.push(A),_.push(e),_.push(i),_.push(x),_.push(C),_.push(I),_.push(S|0),_.push(F|0),_.push(a),_.push(N),_.push(R),_.push(m),_.push(v),this.tilemapBounds.addFrame(e,i,e+x,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(yt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(yt-7)]=t,i[i.length-(yt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(yt-8)]=t,i[i.length-(yt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(yt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(yt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/yt;let s=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&s)return;this.rects_count=i,s||(s=t.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const c=i*s.vertPerQuad;t.checkIndexBuffer(i);const a=s.getBuffer("aVertexPosition"),o=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<o){let S=s.stride;for(;S<o;)S*=2;this.vbBuffer=new ArrayBuffer(S),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const g=this.vbArray,A=this.vbInts;let x=0,C=0;for(let S=0;S<e.length;S+=yt){this.compositeParent&&(C=e[S+9]);const I=e[S+2],N=e[S+3],R=e[S+4],m=e[S+5],v=e[S+0],_=e[S+1];let d=e[S+6];const b=e[S+7],P=e[S+8],U=e[S+10]||1024,L=e[S+11]||1024,y=b+U*2048,G=P+L*2048,it=e[S+12],j=e[S+13];let $,lt,at,ft,Y,ot,nt,X;if(d===0)$=v,lt=_,at=v+R,ft=_,Y=v+R,ot=_+m,nt=v,X=_+m;else{let k=R/2,K=m/2;d%4!==0&&(k=m/2,K=R/2);const mt=v+k,Tt=_+K;d=O.groupD8.add(d,O.groupD8.NW),$=mt+k*O.groupD8.uX(d),lt=Tt+K*O.groupD8.uY(d),d=O.groupD8.add(d,2),at=mt+k*O.groupD8.uX(d),ft=Tt+K*O.groupD8.uY(d),d=O.groupD8.add(d,2),Y=mt+k*O.groupD8.uX(d),ot=Tt+K*O.groupD8.uY(d),d=O.groupD8.add(d,2),nt=mt+k*O.groupD8.uX(d),X=Tt+K*O.groupD8.uY(d)}g[x++]=I,g[x++]=N,g[x++]=$,g[x++]=lt,g[x++]=v+.5,g[x++]=_+.5,g[x++]=v+R-.5,g[x++]=_+m-.5,g[x++]=y,g[x++]=G,A[x++]=C,g[x++]=it,g[x++]=j,g[x++]=I+R,g[x++]=N,g[x++]=at,g[x++]=ft,g[x++]=v+.5,g[x++]=_+.5,g[x++]=v+R-.5,g[x++]=_+m-.5,g[x++]=y,g[x++]=G,A[x++]=C,g[x++]=it,g[x++]=j,g[x++]=I+R,g[x++]=N+m,g[x++]=Y,g[x++]=ot,g[x++]=v+.5,g[x++]=_+.5,g[x++]=v+R-.5,g[x++]=_+m-.5,g[x++]=y,g[x++]=G,A[x++]=C,g[x++]=it,g[x++]=j,g[x++]=I,g[x++]=N+m,g[x++]=nt,g[x++]=X,g[x++]=v+.5,g[x++]=_+.5,g[x++]=v+R-.5,g[x++]=_+m-.5,g[x++]=y,g[x++]=G,A[x++]=C,g[x++]=it,g[x++]=j}a.data=g}isModified(t){return!!(this.rects_count*yt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/yt}addBounds(t){const e=this.tilemapBounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}get bounds(){return this.tilemapBounds}destroy(t){super.destroy(t),this.destroyVb()}addFrame(t,e,i,s,c){return this.tile(t,e,i,{animX:s,animY:c}),!0}addRect(t,e,i,s,c,a,o,g=0,A=0,x=0,C=1024,S=1024,F=1,I=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:a,tileHeight:o,animX:g,animY:A,rotate:x,animCountX:C,animCountY:S,animDivisor:F,alpha:I})}}var zi=Object.defineProperty,Wi=(h,t,e)=>t in h?zi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Vt=(h,t,e)=>(Wi(h,typeof t!="symbol"?t+"":t,e),e);class $i extends O.Container{constructor(t){super(),Vt(this,"texturesPerTilemap"),Vt(this,"tileAnim",null),Vt(this,"lastModifiedTilemap",null),Vt(this,"modificationMarker",0),Vt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=St.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const a=new $e(t.slice(c*e,(c+1)*e));a.compositeParent=!0,this.addChild(a)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const a=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let g=0;if(c=a[o],c)g=t%this.texturesPerTilemap;else{if(c=a[0],!c)return this;g=0}c.tile(g,e,i,s)}else{typeof t=="string"&&(t=O.Texture.from(t));for(let o=0;o<a.length;o++){const g=a[o],A=g.getTileset().arr;for(let x=0;x<A.length;x++)if(A[x]===t.source){c=g;break}if(c)break}if(!c){for(let o=a.length-1;o>=0;o--){const g=a[o];if(g.getTileset().count<this.texturesPerTilemap){c=g,g.getTileset().push(t.source);break}}c||(c=new $e(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,a,o,g,A){return this.tile(t,e,i,{animX:s,animY:c,animCountX:a,animCountY:o,animDivisor:g,alpha:A})}addRect(t,e,i,s,c,a,o,g,A,x,C,S){const F=t/this.texturesPerTilemap>>0,I=t%this.texturesPerTilemap;return this.children[F]&&this.children[F].getTileset().count>0?(this.lastModifiedTilemap=this.children[F],this.lastModifiedTilemap.addRect(I,e,i,s,c,a,o,g,A,x,C,S)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}O.extensions.add(qe),O.extensions.add(je),O.extensions.add(ze);class Ht extends O.AnimatedSprite{constructor(t,e){super(Ht.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=Ht.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=O.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(O.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(O.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(O.groupD8.MAIN_DIAGONAL):i(O.groupD8.REVERSE_DIAGONAL))}}St.use32bitIndex=!0;class Ee extends D.DisplayObject($i){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:a,tileheight:o,width:g}=this._layer;s&&(t=Math.floor(t/a),e=Math.floor(e/o));const A=t+e*g,x=this._layer.getTileByIndex(A);if(!x||x&&x.gid==0)return;const C=Ee.findTileSet(x.gid,this.tileSets);if(!C)return;const S=new Ht(x,C);if(S.x=t*a,S.y=e*o+(o-S.texture.height),S._x=t,S._y=e,C.tileoffset&&(S.x+=C.tileoffset.x??0,S.y+=C.tileoffset.y??0),!(c&&!c(S)))return S}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new ge({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",Ee);function Hi(h){return D.createComponent("CompositeTileLayer",h)}class Xi extends Ci{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await O.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let s=this.margin;s<this.image.width;s+=this.tilewidth+this.spacing)this.textures.push(new O.Texture({source:e.source,frame:new O.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Qi(h,t,e){const i=[];for(const s of h){if(s.type!==Rt.Tile){i.push(s);continue}const c=new Map;let a;if(Array.isArray(s.data))a=s.data.map(g=>typeof g=="number"?g:parseInt(String(g),10));else{i.push(s);continue}for(let g=0;g<a.length;g++){const A=a[g];if(A===0)continue;let x;for(let I=t.length-1;I>=0;I--)if(t[I].firstgid&&t[I].firstgid<=A){x=t[I];break}if(!x){c.has(0)||c.set(0,new Array(a.length).fill(0)),c.get(0)[g]=A;continue}const C=A-x.firstgid,S=x.tileset.tiles?.[C]?.properties,F=S?.z??0;S?.z,c.has(F)||c.set(F,new Array(a.length).fill(0)),c.get(F)[g]=A}const o=Array.from(c.keys()).sort((g,A)=>g-A);for(const g of o){const A=c.get(g);if(A.some(x=>x!==0)){const x={...s,name:`${s.name}_z${g}`,data:A,properties:{...s.properties,z:g}};i.push(x)}}}return i.sort((s,c)=>{const a=s.properties?.z??.5,o=c.properties?.z??.5;return a-o}),i}function Ji(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let a=[],o={};const g=async(x,C="")=>typeof x!="string"?x:await new At(x,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const x=t();if(x){o=await g(x,e()),a=[];for(let S of o.tilesets)S.tile&&(S.tiles=S.tile),S.tiles||(S.tiles=[]),a.push(await new Xi(S).load(S.image.source));let C=o.layers;i()&&(C=Qi(o.layers,a)),s.set(C)}});const A=(x,C={})=>D.h(D.Container,C,D.loop(x,S=>{switch(S.type){case Rt.Tile:return D.h(Hi,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...S,tilesets:a});case Rt.Image:const{width:F,height:I,source:N}=S.image;return D.h(D.TilingSprite,{image:N,...S,width:S.repeatx?S.width*S.tilewidth:F,height:S.repeaty?S.height*S.tileheight:I});case Rt.Group:return A(D.signal(S.layers),S);case Rt.ObjectGroup:const R=c?.(S);return D.h(D.Container,S,R);default:return D.h(D.Container)}}));return D.h(D.Container,h,A(s))}function Zi(){const h=`
208
+ `;class Je extends $e{constructor(){super(...arguments),Jt(this,"_shader",null),Jt(this,"max_textures",Ft.TEXTURES_PER_TILEMAP),Jt(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({gpuProgram:P.GpuProgram.from({vertex:{source:ir,entryPoint:"mainVert"},fragment:{source:rr.replace("//include_textures",kt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}Jt(Je,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var sr=Object.defineProperty,nr=(h,t,e)=>t in h?sr(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,lt=(h,t,e)=>(nr(h,typeof t!="symbol"?t+"":t,e),e),Ze=(h=>(h[h.U=0]="U",h[h.V=1]="V",h[h.X=2]="X",h[h.Y=3]="Y",h[h.TILE_WIDTH=4]="TILE_WIDTH",h[h.TILE_HEIGHT=5]="TILE_HEIGHT",h[h.ROTATE=6]="ROTATE",h[h.ANIM_X=7]="ANIM_X",h[h.ANIM_Y=8]="ANIM_Y",h[h.TEXTURE_INDEX=9]="TEXTURE_INDEX",h[h.ANIM_COUNT_X=10]="ANIM_COUNT_X",h[h.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",h[h.ANIM_DIVISOR=12]="ANIM_DIVISOR",h[h.ALPHA=13]="ALPHA",h))(Ze||{});const bt=Object.keys(Ze).length/2;class ti extends P.ViewContainer{constructor(t){super({}),lt(this,"shadowColor",new Float32Array([0,0,0,.5])),lt(this,"state",P.State.for2d()),lt(this,"is_valid",!1),lt(this,"renderPipeId","tilemap"),lt(this,"canBundle",!0),lt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),lt(this,"tileAnim",null),lt(this,"rects_count",0),lt(this,"compositeParent",!1),lt(this,"tileset",new kt(Ft.TEXTURES_PER_TILEMAP)),lt(this,"tilemapBounds",new P.Bounds),lt(this,"hasAnimatedTile",!1),lt(this,"pointsBuf",[]),lt(this,"batched"),lt(this,"vbId",0),lt(this,"vb",null),lt(this,"vbBuffer",null),lt(this,"vbArray",null),lt(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){let e=this.tileset;if(t instanceof kt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof P.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new kt(Ft.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let s=0;s<t.length;s++)if(t[s]?.source!==e.arr[s]){i=!1;break}if(i)return this}e=this.tileset=new kt(Ft.TEXTURES_PER_TILEMAP);for(let i=0;i<t.length;i++)e.push(t[i]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,s={}){this.didViewUpdate=!0;let c,l=-1,o=!1;if(typeof t=="number")l=t,o=!0,c=this.tileset.arr[l];else{let d;typeof t=="string"?d=P.Texture.from(t):d=t;const b=this.tileset;for(let R=0;R<b.count;R++)if(b.arr[R]===d.source){l=R;break}"frame"in d&&(s.u=s.u??d.frame.x,s.v=s.v??d.frame.y,s.tileWidth=s.tileWidth??d.orig.width,s.tileHeight=s.tileHeight??d.orig.height),c=d.source}if(!o&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:y=0,v:C=0,tileWidth:v=c.width,tileHeight:B=c.height,animX:A=0,animY:I=0,rotate:M=0,animCountX:N=1024,animCountY:O=1024,animDivisor:_=1,alpha:E=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||A>0||I>0,m.push(y),m.push(C),m.push(e),m.push(i),m.push(v),m.push(B),m.push(M),m.push(A|0),m.push(I|0),m.push(l),m.push(N),m.push(O),m.push(_),m.push(E),this.tilemapBounds.addFrame(e,i,e+v,i+B),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(bt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(bt-7)]=t,i[i.length-(bt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(bt-8)]=t,i[i.length-(bt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(bt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(bt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/bt;let s=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&s)return;this.rects_count=i,s||(s=t.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const c=i*s.vertPerQuad;t.checkIndexBuffer(i);const l=s.getBuffer("aVertexPosition"),o=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<o){let A=s.stride;for(;A<o;)A*=2;this.vbBuffer=new ArrayBuffer(A),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const y=this.vbArray,C=this.vbInts;let v=0,B=0;for(let A=0;A<e.length;A+=bt){this.compositeParent&&(B=e[A+9]);const M=e[A+2],N=e[A+3],O=e[A+4],_=e[A+5],E=e[A+0],m=e[A+1];let d=e[A+6];const b=e[A+7],R=e[A+8],U=e[A+10]||1024,k=e[A+11]||1024,g=b+U*2048,V=R+k*2048,j=e[A+12],z=e[A+13];let Q,ut,tt,ht,L,nt,dt,yt;if(d===0)Q=E,ut=m,tt=E+O,ht=m,L=E+O,nt=m+_,dt=E,yt=m+_;else{let K=O/2,W=_/2;d%4!==0&&(K=_/2,W=O/2);const ft=E+K,ct=m+W;d=P.groupD8.add(d,P.groupD8.NW),Q=ft+K*P.groupD8.uX(d),ut=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),tt=ft+K*P.groupD8.uX(d),ht=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),L=ft+K*P.groupD8.uX(d),nt=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),dt=ft+K*P.groupD8.uX(d),yt=ct+W*P.groupD8.uY(d)}y[v++]=M,y[v++]=N,y[v++]=Q,y[v++]=ut,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M+O,y[v++]=N,y[v++]=tt,y[v++]=ht,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M+O,y[v++]=N+_,y[v++]=L,y[v++]=nt,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M,y[v++]=N+_,y[v++]=dt,y[v++]=yt,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z}l.data=y}isModified(t){return!!(this.rects_count*bt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/bt}addBounds(t){const e=this.tilemapBounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}get bounds(){return this.tilemapBounds}destroy(t){super.destroy(t),this.destroyVb()}addFrame(t,e,i,s,c){return this.tile(t,e,i,{animX:s,animY:c}),!0}addRect(t,e,i,s,c,l,o,y=0,C=0,v=0,B=1024,A=1024,I=1,M=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:l,tileHeight:o,animX:y,animY:C,rotate:v,animCountX:B,animCountY:A,animDivisor:I,alpha:M})}}var ar=Object.defineProperty,or=(h,t,e)=>t in h?ar(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,qt=(h,t,e)=>(or(h,typeof t!="symbol"?t+"":t,e),e);class lr extends P.Container{constructor(t){super(),qt(this,"texturesPerTilemap"),qt(this,"tileAnim",null),qt(this,"lastModifiedTilemap",null),qt(this,"modificationMarker",0),qt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Ft.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const l=new ti(t.slice(c*e,(c+1)*e));l.compositeParent=!0,this.addChild(l)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const l=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let y=0;if(c=l[o],c)y=t%this.texturesPerTilemap;else{if(c=l[0],!c)return this;y=0}c.tile(y,e,i,s)}else{typeof t=="string"&&(t=P.Texture.from(t));for(let o=0;o<l.length;o++){const y=l[o],C=y.getTileset().arr;for(let v=0;v<C.length;v++)if(C[v]===t.source){c=y;break}if(c)break}if(!c){for(let o=l.length-1;o>=0;o--){const y=l[o];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new ti(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,l,o,y,C){return this.tile(t,e,i,{animX:s,animY:c,animCountX:l,animCountY:o,animDivisor:y,alpha:C})}addRect(t,e,i,s,c,l,o,y,C,v,B,A){const I=t/this.texturesPerTilemap>>0,M=t%this.texturesPerTilemap;return this.children[I]&&this.children[I].getTileset().count>0?(this.lastModifiedTilemap=this.children[I],this.lastModifiedTilemap.addRect(M,e,i,s,c,l,o,y,C,v,B,A)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(Xe),P.extensions.add(Qe),P.extensions.add(Je);class Zt extends P.AnimatedSprite{constructor(t,e){super(Zt.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=Zt.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=P.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(P.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(P.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(P.groupD8.MAIN_DIAGONAL):i(P.groupD8.REVERSE_DIAGONAL))}}Ft.use32bitIndex=!0;class be extends D.DisplayObject(lr){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:l,tileheight:o,width:y}=this._layer;s&&(t=Math.floor(t/l),e=Math.floor(e/o));const C=t+e*y,v=this._layer.getTileByIndex(C);if(!v||v&&v.gid==0)return;const B=be.findTileSet(v.gid,this.tileSets);if(!B)return;const A=new Zt(v,B);if(A.x=t*l,A.y=e*o+(o-A.texture.height),A._x=t,A._y=e,B.tileoffset&&(A.x+=B.tileoffset.x??0,A.y+=B.tileoffset.y??0),!(c&&!c(A)))return A}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new we({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",be);function cr(h){return D.createComponent("CompositeTileLayer",h)}class ur extends Yi{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await P.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let s=this.margin;s<this.image.width;s+=this.tilewidth+this.spacing)this.textures.push(new P.Texture({source:e.source,frame:new P.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function hr(h,t,e){const i=[];for(const s of h){if(s.type!==Vt.Tile){i.push(s);continue}const c=new Map;let l;if(Array.isArray(s.data))l=s.data.map(y=>typeof y=="number"?y:parseInt(String(y),10));else{i.push(s);continue}for(let y=0;y<l.length;y++){const C=l[y];if(C===0)continue;let v;for(let M=t.length-1;M>=0;M--)if(t[M].firstgid&&t[M].firstgid<=C){v=t[M];break}if(!v){c.has(0)||c.set(0,new Array(l.length).fill(0)),c.get(0)[y]=C;continue}const B=C-v.firstgid,A=v.tileset.tiles?.[B]?.properties,I=A?.z??0;A?.z,c.has(I)||c.set(I,new Array(l.length).fill(0)),c.get(I)[y]=C}const o=Array.from(c.keys()).sort((y,C)=>y-C);for(const y of o){const C=c.get(y);if(C.some(v=>v!==0)){const v={...s,name:`${s.name}_z${y}`,data:C,properties:{...s.properties,z:y}};i.push(v)}}}return i.sort((s,c)=>{const l=s.properties?.z??.5,o=c.properties?.z??.5;return l-o}),i}function fr(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let l=[],o={};const y=async(v,B="")=>typeof v!="string"?v:await new Mt(v,{basePath:B}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const v=t();if(v){o=await y(v,e()),l=[];for(let A of o.tilesets)A.tile&&(A.tiles=A.tile),A.tiles||(A.tiles=[]),l.push(await new ur(A).load(A.image.source));let B=o.layers;i()&&(B=hr(o.layers,l)),s.set(B)}});const C=(v,B={})=>D.h(D.Container,B,D.loop(v,A=>{switch(A.type){case Vt.Tile:return D.h(cr,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...A,tilesets:l});case Vt.Image:const{width:I,height:M,source:N}=A.image;return D.h(D.TilingSprite,{image:N,...A,width:A.repeatx?A.width*A.tilewidth:I,height:A.repeaty?A.height*A.tileheight:M});case Vt.Group:return C(D.signal(A.layers),A);case Vt.ObjectGroup:const O=c?.(A);return D.h(D.Container,A,O);default:return D.h(D.Container)}}));return D.h(D.Container,h,C(s))}function dr(){const h=`
128
209
  precision mediump float;
129
210
  attribute vec2 aPosition;
130
211
  attribute vec2 aUV;
131
212
  varying vec2 vUV;
213
+ uniform mat3 translationMatrix;
214
+ uniform mat3 projectionMatrix;
132
215
  void main() {
133
216
  vUV = aUV;
134
- gl_Position = vec4(aPosition, 0.0, 1.0);
217
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
218
+ gl_Position = vec4(world.xy, 0.0, 1.0);
135
219
  }
136
220
  `,t=`
137
221
  precision mediump float;
@@ -211,14 +295,17 @@ fn mainFrag(
211
295
  vec3 rainColor = vec3(0.75, 0.85, 1.0);
212
296
  gl_FragColor = vec4(rainColor * rain, clamp(rain, 0.0, 0.9));
213
297
  }
214
- `;return new O.GlProgram({vertex:h,fragment:t})}function tr(){const h=`
298
+ `;return new P.GlProgram({vertex:h,fragment:t})}function pr(){const h=`
215
299
  precision mediump float;
216
300
  attribute vec2 aPosition;
217
301
  attribute vec2 aUV;
218
302
  varying vec2 vUV;
303
+ uniform mat3 translationMatrix;
304
+ uniform mat3 projectionMatrix;
219
305
  void main() {
220
306
  vUV = aUV;
221
- gl_Position = vec4(aPosition, 0.0, 1.0);
307
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
308
+ gl_Position = vec4(world.xy, 0.0, 1.0);
222
309
  }
223
310
  `,t=`
224
311
  precision mediump float;
@@ -306,14 +393,17 @@ fn mainFrag(
306
393
  float alpha = clamp(snow, 0.0, 0.9);
307
394
  gl_FragColor = vec4(snowColor * snow, alpha);
308
395
  }
309
- `;return new O.GlProgram({vertex:h,fragment:t})}function er(){const h=`
396
+ `;return new P.GlProgram({vertex:h,fragment:t})}function mr(){const h=`
310
397
  precision mediump float;
311
398
  attribute vec2 aPosition;
312
399
  attribute vec2 aUV;
313
400
  varying vec2 vUV;
401
+ uniform mat3 translationMatrix;
402
+ uniform mat3 projectionMatrix;
314
403
  void main() {
315
404
  vUV = aUV;
316
- gl_Position = vec4(aPosition, 0.0, 1.0);
405
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
406
+ gl_Position = vec4(world.xy, 0.0, 1.0);
317
407
  }
318
408
  `,t=`
319
409
  precision mediump float;
@@ -370,8 +460,11 @@ fn mainFrag(
370
460
  float fogNoise = fbm(uv * scale + drift);
371
461
 
372
462
  float softness = smoothstep(0.35, 1.0, fogNoise);
373
- float baseHeight = 0.6 + 0.4 * (1.0 - uv.y);
374
- float heightFactor = mix(baseHeight, 1.0, clamp(uHeight, 0.0, 1.0));
463
+ float heightControl = clamp(uHeight, 0.0, 1.0);
464
+ float fullScreen = step(0.99, heightControl);
465
+ float baseHeight = 0.6 + 0.4 * uv.y;
466
+ float heightFactor = mix(baseHeight, 1.0, heightControl);
467
+ heightFactor = mix(heightFactor, 1.0, fullScreen);
375
468
 
376
469
  float fog = softness * density * 0.45 * heightFactor;
377
470
  float alpha = clamp(fog, 0.0, 0.35);
@@ -379,14 +472,17 @@ fn mainFrag(
379
472
  vec3 fogColor = vec3(1.0);
380
473
  gl_FragColor = vec4(fogColor * alpha, alpha);
381
474
  }
382
- `;return new O.GlProgram({vertex:h,fragment:t})}function ir(){const h=`
475
+ `;return new P.GlProgram({vertex:h,fragment:t})}function _r(){const h=`
383
476
  precision mediump float;
384
477
  attribute vec2 aPosition;
385
478
  attribute vec2 aUV;
386
479
  varying vec2 vUV;
480
+ uniform mat3 translationMatrix;
481
+ uniform mat3 projectionMatrix;
387
482
  void main() {
388
483
  vUV = aUV;
389
- gl_Position = vec4(aPosition, 0.0, 1.0);
484
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
485
+ gl_Position = vec4(world.xy, 0.0, 1.0);
390
486
  }
391
487
  `,t=`
392
488
  precision mediump float;
@@ -447,12 +543,16 @@ fn mainFrag(
447
543
  float detail = smoothstep(0.4, 0.9, detailNoise);
448
544
  float puff = shape * (0.6 + 0.4 * detail);
449
545
 
450
- float heightFactor = mix(0.6 + 0.4 * uv.y, 1.0, clamp(uHeight, 0.0, 1.0));
546
+ float heightControl = clamp(uHeight, 0.0, 1.0);
547
+ float fullScreen = step(0.99, heightControl);
548
+ float baseHeight = 0.6 + 0.4 * uv.y;
549
+ float heightFactor = mix(baseHeight, 1.0, heightControl);
550
+ heightFactor = mix(heightFactor, 1.0, fullScreen);
451
551
  float cloud = puff * density * 0.6 * heightFactor;
452
552
  float alpha = clamp(cloud, 0.0, 0.55);
453
553
 
454
554
  vec3 cloudColor = vec3(1.0);
455
555
  gl_FragColor = vec4(cloudColor * alpha, alpha);
456
556
  }
457
- `;return new O.GlProgram({vertex:h,fragment:t})}const He=h=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:s=D.signal(.2),density:c=D.signal(120),maxDrops:a=D.signal(80),height:o=D.signal(1),scale:g=D.signal(2),resolution:A}=D.useProps(h),x=D.signal([1e3,1e3]),C=A?typeof A=="function"?A:D.signal(A):x;D.mount(Y=>{const ot=Y.props.context;ot?.canvasSize&&t(()=>{const nt=ot.canvasSize();nt&&nt.width>0&&nt.height>0&&x.set([nt.width,nt.height])})});const S=typeof e=="function"?e:D.signal(e),F=typeof i=="function"?i:D.signal(i),I=typeof s=="function"?s:D.signal(s),N=typeof c=="function"?c:D.signal(c),R=typeof a=="function"?a:D.signal(a),m=typeof o=="function"?o:D.signal(o),v=typeof g=="function"?g:D.signal(g);let _,d;if(t()==="rain")_=Zi(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uRainSpeed:{value:S(),type:"f32"},uWindDirection:{value:F(),type:"f32"},uWindStrength:{value:I(),type:"f32"},uRainDensity:{value:N(),type:"f32"},uMaxDrops:{value:R(),type:"f32"}};else if(t()==="snow")_=tr(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSnowSpeed:{value:S(),type:"f32"},uWindDirection:{value:F(),type:"f32"},uWindStrength:{value:I(),type:"f32"},uSnowDensity:{value:N(),type:"f32"},uMaxFlakes:{value:R(),type:"f32"}};else if(t()==="fog")_=er(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSpeed:{value:S(),type:"f32"},uScale:{value:v(),type:"f32"},uDensity:{value:N(),type:"f32"},uHeight:{value:m(),type:"f32"}};else if(t()==="cloud")_=ir(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSpeed:{value:S(),type:"f32"},uScale:{value:v(),type:"f32"},uDensity:{value:N(),type:"f32"},uHeight:{value:m(),type:"f32"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog, cloud`);const b=new O.UniformGroup(d),P=new O.Shader({glProgram:_,resources:{uniforms:b}}),U=new O.Geometry({attributes:{aPosition:[-1,-1,1,-1,1,1,-1,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let L=Math.random()*10,y=[...C()],G=F(),it=I(),j=S(),$=N(),lt=R(),at=m(),ft=v();return D.tick(({deltaTime:Y})=>{L+=Y/600,b.uniforms.uTime=L;const ot=C();(ot[0]!==y[0]||ot[1]!==y[1])&&(b.uniforms.uResolution=ot,y=[...ot]);const nt=F();if(nt!==G&&(b.uniforms.uWindDirection=nt,G=nt),t()==="rain"||t()==="snow"){const X=I();X!==it&&(b.uniforms.uWindStrength=X,it=X)}if(t()==="rain"){const X=S();X!==j&&(b.uniforms.uRainSpeed=X,j=X);const k=N();k!==$&&(b.uniforms.uRainDensity=k,$=k);const K=R();K!==lt&&(b.uniforms.uMaxDrops=K,lt=K)}else if(t()==="snow"){const X=S();X!==j&&(b.uniforms.uSnowSpeed=X,j=X);const k=N();k!==$&&(b.uniforms.uSnowDensity=k,$=k);const K=R();K!==lt&&(b.uniforms.uMaxFlakes=K,lt=K)}else if(t()==="fog"||t()==="cloud"){const X=S();X!==j&&(b.uniforms.uSpeed=X,j=X);const k=v();k!==ft&&(b.uniforms.uScale=k,ft=k);const K=N();K!==$&&(b.uniforms.uDensity=K,$=K);const mt=m();mt!==at&&(b.uniforms.uHeight=mt,at=mt)}}),D.h(D.Mesh,{geometry:U,shader:P,width:"100%",height:"100%"})},rr=He;return xt.Bar=Je,xt.LightSpot=li,xt.Loading=ui,xt.NightAmbiant=ci,xt.Particle=oi,xt.TiledMap=Ji,xt.Weather=rr,xt.WeatherEffect=He,Object.defineProperty(xt,Symbol.toStringTag,{value:"Module"}),xt})({},CanvasEngine,PIXI);
557
+ `;return new P.GlProgram({vertex:h,fragment:t})}const ei=h=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:s=D.signal(.2),density:c=D.signal(120),maxDrops:l=D.signal(80),height:o=D.signal(1),scale:y=D.signal(2),resolution:C}=D.useProps(h),v=D.signal([1e3,1e3]),B=D.signal(0),A=D.signal(0),I=D.signal(0),M=D.signal(0);let N;const O=C?typeof C=="function"?C:D.signal(C):v;D.mount(ft=>{const ct=ft.props.context;if(N=ct?.viewport,N?.getVisibleBounds){const J=N.getVisibleBounds();J&&(v.set([J.width,J.height]),B.set(J.width),A.set(J.height),I.set(J.x),M.set(J.y))}ct?.canvasSize&&t(()=>{const J=ct.canvasSize();J&&J.width>0&&J.height>0&&(N?.getVisibleBounds||(v.set([J.width,J.height]),B.set(J.width),A.set(J.height),I.set(0),M.set(0)))})});const _=typeof e=="function"?e:D.signal(e),E=typeof i=="function"?i:D.signal(i),m=typeof s=="function"?s:D.signal(s),d=typeof c=="function"?c:D.signal(c),b=typeof l=="function"?l:D.signal(l),R=typeof o=="function"?o:D.signal(o),U=typeof y=="function"?y:D.signal(y),k=ft=>typeof ft=="number"&&Number.isFinite(ft)?ft:1;let g,V;if(t()==="rain")g=dr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uRainSpeed:{value:_(),type:"f32"},uWindDirection:{value:E(),type:"f32"},uWindStrength:{value:m(),type:"f32"},uRainDensity:{value:d(),type:"f32"},uMaxDrops:{value:b(),type:"f32"}};else if(t()==="snow")g=pr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSnowSpeed:{value:_(),type:"f32"},uWindDirection:{value:E(),type:"f32"},uWindStrength:{value:m(),type:"f32"},uSnowDensity:{value:d(),type:"f32"},uMaxFlakes:{value:b(),type:"f32"}};else if(t()==="fog")g=mr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSpeed:{value:_(),type:"f32"},uScale:{value:U(),type:"f32"},uDensity:{value:d(),type:"f32"},uHeight:{value:k(R()),type:"f32"}};else if(t()==="cloud")g=_r(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSpeed:{value:_(),type:"f32"},uScale:{value:U(),type:"f32"},uDensity:{value:d(),type:"f32"},uHeight:{value:k(R()),type:"f32"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog, cloud`);const j=new P.UniformGroup(V),z=new P.Shader({glProgram:g,resources:{uniforms:j}}),Q=new P.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let ut=Math.random()*10,tt=[...O()],ht=E(),L=m(),nt=_(),dt=d(),yt=b(),K=R(),W=U();return D.tick(({deltaTime:ft})=>{if(N?.getVisibleBounds){const $=N.getVisibleBounds();if($){const f=$.width,a=$.height,S=$.x,w=$.y;f!==B()&&B.set(f),a!==A()&&A.set(a),S!==I()&&I.set(S),w!==M()&&M.set(w);const q=v();(q[0]!==f||q[1]!==a)&&v.set([f,a])}}ut+=ft/600,j.uniforms.uTime=ut;const ct=O();(ct[0]!==tt[0]||ct[1]!==tt[1])&&(j.uniforms.uResolution=ct,tt=[...ct]);const J=E();if(J!==ht&&(j.uniforms.uWindDirection=J,ht=J),t()==="rain"||t()==="snow"){const $=m();$!==L&&(j.uniforms.uWindStrength=$,L=$)}if(t()==="rain"){const $=_();$!==nt&&(j.uniforms.uRainSpeed=$,nt=$);const f=d();f!==dt&&(j.uniforms.uRainDensity=f,dt=f);const a=b();a!==yt&&(j.uniforms.uMaxDrops=a,yt=a)}else if(t()==="snow"){const $=_();$!==nt&&(j.uniforms.uSnowSpeed=$,nt=$);const f=d();f!==dt&&(j.uniforms.uSnowDensity=f,dt=f);const a=b();a!==yt&&(j.uniforms.uMaxFlakes=a,yt=a)}else if(t()==="fog"||t()==="cloud"){const $=_();$!==nt&&(j.uniforms.uSpeed=$,nt=$);const f=U();f!==W&&(j.uniforms.uScale=f,W=f);const a=d();a!==dt&&(j.uniforms.uDensity=a,dt=a);const S=k(R());S!==K&&(j.uniforms.uHeight=S,K=S)}}),D.h(D.Mesh,{geometry:Q,shader:z,width:B,height:A,x:I,y:M})},gr=ei;return At.Bar=si,At.Loading=Ti,At.NightAmbiant=bi,At.Particle=di,At.TiledMap=fr,At.Weather=gr,At.WeatherEffect=ei,At.createNightFilter=Fe,Object.defineProperty(At,Symbol.toStringTag,{value:"Module"}),At})({},CanvasEngine,PIXI);
458
558
  //# sourceMappingURL=index.global.js.map