@canvasengine/presets 2.0.0-beta.50 → 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 He(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=He(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:T}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(E){T()?E.roundRect(0,0,t(),e(),T()):E.rect(0,0,t(),e()),o&&E.stroke(o),E.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(E){const C=g(),S=T(),F=Math.max(0,Math.min(t()-2*C,i()/s()*(t()-2*C))),M=e()-2*C;T?E.roundRect(C,C,F,M,S):E.rect(C,C,F,M);const N=a();if(N.startsWith("rgba")){const[R,_,v,m]=N.match(/\d+(\.\d+)?/g).map(Number);E.fill({color:Qe(R,_,v),alpha:m})}else E.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 G{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=G.float(-s,s),g=G.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=G.float(-e.angle*.5,e.angle*.5)+i.rotation:s=G.float(0,6.28319)+i.rotation,e.radius>0){let c=G.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=G.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 Et;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(Et||(Et={}));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 _t{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=_t.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=_t.easeInBounce(t*2,0,i,s),c*.5+e):(c=_t.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 Ae(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Dt(new Ae(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 Ae{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=G.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=G.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-G.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=G.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=G.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=_t[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=G.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=G.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=G.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=_t[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=a*(1-e.fadeInDurationFac),this.fadeInDuration=a*e.fadeInDurationFac,this.fadeInEase=_t[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=_t[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=G.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(G.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=G.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(G.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=_t[e.scaleXEase],this.scaleYStart=s.scale.y=G.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(G.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=_t[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=a*(1-e.scaleInDurationFac),this.scaleInDuration=a*e.scaleInDurationFac,this.scaleInEase=_t[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=G.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=G.sign())),e.useTint&&(this.tintEase=_t[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],T=c.getParticleEmitterById(g.id);T.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(T.rotation=s.rotation,T.__adoptRotation=!0),T.__parent=this,this._childEmitters.push(T)}}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 wt{static sanitizeBundle(t){for(let e of t.emitters){const i=wt._presetStructure.emitter;wt.parse(e,i,wt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=wt._presetStructure.sequence;wt.parse(e,i,wt._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"))wt.parse(c,a,i);else for(let o of c)for(let g in i)o[g]==null&&(o[g]=i[g])}}}wt._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(E){try{T(i.next(E))}catch(C){a(C)}}function g(E){try{T(i.throw(E))}catch(C){a(C)}}function T(E){E.done?c(E.value):s(E.value).then(o,g)}T((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 T=yield dt.Assets.loadBundle("rfx_assets");c(this.initBundle(T.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.");wt.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 Te(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 Te(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=Et,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+G.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=G.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=G.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=G.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 Te 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,T;switch(a.componentType){case Et.Sprite:o=c.__getSprite(a.componentId),T=c.__containers[a.containerId]||this.container,T.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.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+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Sprite,o);break;case Et.MovieClip:o=c.__getMovieClip(a.componentId),a.componentParams.loop?(o.animationSpeed=G.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),T=c.__containers[a.containerId]||this.container,T.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.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+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.MovieClip,o);break;case Et.Emitter:o=c.getParticleEmitterById(a.componentId),T=c.__containers[a.containerId]||this.container,o.init(T,!0,G.float(a.scaleMin,a.scaleMax)*G.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(Et.Emitter,o);break;case Et.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 E=e.emitters.map((C,S)=>({...C,id:1e4+S}));g.emitters=[...g.emitters,...E]}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,T=(Math.sin(g)+Math.sin(g*1.3)+Math.sin(g*.7))/3,E=i+(s-i)*(T*.5+.5);e.update(()=>E),requestAnimationFrame(a)};a();const o=g=>{const T=t()*2,E=new D.RadialGradient(T,T,0,T,T,0);E.addColorStop(0,"rgba(255, 255, 0, 1)"),E.addColorStop(.5,"rgba(255, 255, 0, 0.3)"),E.addColorStop(.8,"rgba(255, 255, 0, 0)");const C=T/2;g.rect(-C,-C,T,T).fill(E.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=T=>{const E=D.isSignal(T.propObservables.x)?T.propObservables.x():T.props.x,C=D.isSignal(T.propObservables.y)?T.propObservables.y():T.props.y,S=D.isSignal(T.propObservables.radius)?T.propObservables.radius():T.props.radius;a.circle(E,C,S),a.cut()};for(let T of t){if(D.isObservable(T)){s&&s.unsubscribe(),s=T.subscribe(E=>{for(let C of E.fullElements)g(C)});return}g(T)}};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:M})=>{const R=(typeof s=="function"?s():s)*M/1e3;g.set(g()+R)});const T=M=>{const N=typeof t=="function"?t():t,R=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,v=typeof c=="function"?c():c;typeof a=="function"&&a();const m=typeof o=="function"?o():o,d=g();_&&M.circle(0,0,N).fill(_);const b=360/v,P=N*.4,U=N;for(let k=0;k<v;k++){const y=k*b,V=(d%360+360)%360;let rt=Math.abs(V-y);rt>180&&(rt=360-rt);let W=rt/120;W=Math.min(1,W),W=W*W*W;const lt=m+(1-W)*(1-m),ot=y*(Math.PI/180),ht=b*(Math.PI/180),Y=ot-ht/2,st=ot+ht/2;M.arc(0,0,P,Y,st).arc(0,0,U,st,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 M=t();S.set(M*2),F.set(M*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:T})])}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={},kt={},Ce;function di(){if(Ce)return kt;Ce=1,kt.byteLength=o,kt.toByteArray=T,kt.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 M=F.length;if(M%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=F.indexOf("=");N===-1&&(N=M);var R=N===M?0:4-N%4;return[N,R]}function o(F){var M=a(F),N=M[0],R=M[1];return(N+R)*3/4-R}function g(F,M,N){return(M+N)*3/4-N}function T(F){var M,N=a(F),R=N[0],_=N[1],v=new e(g(F,R,_)),m=0,d=_>0?R-4:R,b;for(b=0;b<d;b+=4)M=t[F.charCodeAt(b)]<<18|t[F.charCodeAt(b+1)]<<12|t[F.charCodeAt(b+2)]<<6|t[F.charCodeAt(b+3)],v[m++]=M>>16&255,v[m++]=M>>8&255,v[m++]=M&255;return _===2&&(M=t[F.charCodeAt(b)]<<2|t[F.charCodeAt(b+1)]>>4,v[m++]=M&255),_===1&&(M=t[F.charCodeAt(b)]<<10|t[F.charCodeAt(b+1)]<<4|t[F.charCodeAt(b+2)]>>2,v[m++]=M>>8&255,v[m++]=M&255),v}function E(F){return h[F>>18&63]+h[F>>12&63]+h[F>>6&63]+h[F&63]}function C(F,M,N){for(var R,_=[],v=M;v<N;v+=3)R=(F[v]<<16&16711680)+(F[v+1]<<8&65280)+(F[v+2]&255),_.push(E(R));return _.join("")}function S(F){for(var M,N=F.length,R=N%3,_=[],v=16383,m=0,d=N-R;m<d;m+=v)_.push(C(F,m,m+v>d?d:m+v));return R===1?(M=F[N-1],_.push(h[M>>2]+h[M<<4&63]+"==")):R===2&&(M=(F[N-2]<<8)+F[N-1],_.push(h[M>>10]+h[M>>4&63]+h[M<<2&63]+"=")),_.join("")}return kt}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,T=g>>1,E=-7,C=e?s-1:0,S=e?-1:1,F=h[t+C];for(C+=S,c=F&(1<<-E)-1,F>>=-E,E+=o;E>0;c=c*256+h[t+C],C+=S,E-=8);for(a=c&(1<<-E)-1,c>>=-E,E+=i;E>0;a=a*256+h[t+C],C+=S,E-=8);if(c===0)c=1-T;else{if(c===g)return a?NaN:(F?-1:1)*(1/0);a=a+Math.pow(2,i),c=c-T}return(F?-1:1)*a*Math.pow(2,c-i)},Wt.write=function(h,t,e,i,s,c){var a,o,g,T=c*8-s-1,E=(1<<T)-1,C=E>>1,S=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=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,a=E):(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>=E?(o=0,a=E):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+=M,o/=256,s-=8);for(a=a<<s|o,T+=s;T>0;h[e+F]=a&255,F+=M,a/=256,T-=8);h[e+F-M]|=N*128}),Wt}var Ie;function Me(){return Ie||(Ie=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 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(mt(u,ArrayBuffer)||u&&mt(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(u,SharedArrayBuffer)||u&&mt(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=R(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 g(u,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function T(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 E(u,r,n){return T(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 E(u,r,n)};function C(u){return T(u),a(u<0?0:_(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=m(u,r)|0;let p=a(n);const x=p.write(u,r);return x!==n&&(p=p.slice(0,x)),p}function F(u){const r=u.length<0?0:_(u.length)|0,n=a(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function M(u){if(mt(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=_(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 _(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(mt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),mt(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 A=0,B=Math.min(p,x);A<B;++A)if(r[A]!==n[A]){p=r[A],x=n[A];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 A=0;for(p=0;p<r.length;++p){let B=r[p];if(mt(B,Uint8Array))A+B.length>x.length?(o.isBuffer(B)||(B=o.from(B)),B.copy(x,A)):Uint8Array.prototype.set.call(x,B,A);else if(o.isBuffer(B))B.copy(x,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=B.length}return x};function m(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||mt(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 it(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qt(u).length;default:if(x)return p?-1:it(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 $(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 st(this,r,n);case"base64":return W(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(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,x,A){if(mt(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),A===void 0&&(A=this.length),n<0||p>r.length||x<0||A>this.length)throw new RangeError("out of range index");if(x>=A&&n>=p)return 0;if(x>=A)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,x>>>=0,A>>>=0,this===r)return 0;let B=A-x,q=p-n;const Z=Math.min(B,q),Q=this.slice(x,A),tt=r.slice(n,p);for(let z=0;z<Z;++z)if(Q[z]!==tt[z]){B=Q[z],q=tt[z];break}return B<q?-1:q<B?1:0};function P(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,we(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 A=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;A=2,B/=2,q/=2,n/=2}function Z(tt,z){return A===1?tt[z]:tt.readUInt16BE(z*A)}let Q;if(x){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*A}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 z=0;z<q;z++)if(Z(u,Q+z)!==Z(r,z)){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 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 A=r.length;p>A/2&&(p=A/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 Mt(it(r,u.length-n),u,n,p)}function V(u,r,n,p){return Mt(yt(r),u,n,p)}function rt(u,r,n,p){return Mt(qt(r),u,n,p)}function K(u,r,n,p){return Mt(Ee(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 A=this.length-n;if((p===void 0||p>A)&&(p=A),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");let B=!1;for(;;)switch(x){case"hex":return k(this,r,n,p);case"utf8":case"utf-8":return y(this,r,n,p);case"ascii":case"latin1":case"binary":return V(this,r,n,p);case"base64":return rt(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,r,n,p);default:if(B)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),B=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(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 x=r;for(;x<n;){const A=u[x];let B=null,q=A>239?4:A>223?3:A>191?2:1;if(x+q<=n){let Z,Q,tt,z;switch(q){case 1:A<128&&(B=A);break;case 2:Z=u[x+1],(Z&192)===128&&(z=(A&31)<<6|Z&63,z>127&&(B=z));break;case 3:Z=u[x+1],Q=u[x+2],(Z&192)===128&&(Q&192)===128&&(z=(A&15)<<12|(Z&63)<<6|Q&63,z>2047&&(z<55296||z>57343)&&(B=z));break;case 4:Z=u[x+1],Q=u[x+2],tt=u[x+3],(Z&192)===128&&(Q&192)===128&&(tt&192)===128&&(z=(A&15)<<18|(Z&63)<<12|(Q&63)<<6|tt&63,z>65535&&z<1114112&&(B=z))}}B===null?(B=65533,q=1):B>65535&&(B-=65536,p.push(B>>>10&1023|55296),B=56320|B&1023),p.push(B),x+=q}return ht(p)}const ot=4096;function ht(u){const r=u.length;if(r<=ot)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=ot));return n}function Y(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 st(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 $(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let x="";for(let A=r;A<n;++A)x+=rr[u[A]];return x}function et(u,r,n){const p=u.slice(r,n);let x="";for(let A=0;A<p.length-1;A+=2)x+=String.fromCharCode(p[A]+p[A+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 L(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||L(r,n,this.length);let x=this[r],A=1,B=0;for(;++B<n&&(A*=256);)x+=this[r+B]*A;return x},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||L(r,n,this.length);let x=this[r+--n],A=1;for(;n>0&&(A*=256);)x+=this[r+--n]*A;return x},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||L(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||L(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||L(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||L(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||L(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,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const x=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,A=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(x)+(BigInt(A)<<BigInt(32))}),o.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const x=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],A=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(x)<<BigInt(32))+BigInt(A)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||L(r,n,this.length);let x=this[r],A=1,B=0;for(;++B<n&&(A*=256);)x+=this[r+B]*A;return A*=128,x>=A&&(x-=Math.pow(2,8*n)),x},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||L(r,n,this.length);let x=n,A=1,B=this[r+--x];for(;x>0&&(A*=256);)B+=this[r+--x]*A;return A*=128,B>=A&&(B-=Math.pow(2,8*n)),B},o.prototype.readInt8=function(r,n){return r=r>>>0,n||L(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||L(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||L(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||L(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||L(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,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(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=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(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||L(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||L(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||L(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||L(r,8,this.length),e.read(this,r,!1,52,8)};function H(u,r,n,p,x,A){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>x||r<A)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 q=Math.pow(2,8*p)-1;H(this,r,n,p,q,0)}let A=1,B=0;for(this[n]=r&255;++B<p&&(A*=256);)this[n+B]=r/A&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 q=Math.pow(2,8*p)-1;H(this,r,n,p,q,0)}let A=p-1,B=1;for(this[n+A]=r&255;--A>=0&&(B*=256);)this[n+A]=r/B&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(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||H(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||H(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||H(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||H(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 Tt(u,r,n,p,x){J(r,p,x,u,n,7);let A=Number(r&BigInt(4294967295));u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A;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 bt(u,r,n,p,x){J(r,p,x,u,n,7);let A=Number(r&BigInt(4294967295));u[n+7]=A,A=A>>8,u[n+6]=A,A=A>>8,u[n+5]=A,A=A>>8,u[n+4]=A;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 Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Ft(function(r,n=0){return bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=0,B=1,q=0;for(this[n]=r&255;++A<p&&(B*=256);)r<0&&q===0&&this[n+A-1]!==0&&(q=1),this[n+A]=(r/B>>0)-q&255;return n+p},o.prototype.writeIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=p-1,B=1,q=0;for(this[n+A]=r&255;--A>=0&&(B*=256);)r<0&&q===0&&this[n+A+1]!==0&&(q=1),this[n+A]=(r/B>>0)-q&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(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||H(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||H(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||H(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||H(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 Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Ft(function(r,n=0){return bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vt(u,r,n,p,x,A){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(u,r,n,p,x){return r=+r,n=n>>>0,x||Vt(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return Ht(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return Ht(this,r,n,!1,p)};function f(u,r,n,p,x){return r=+r,n=n>>>0,x||Vt(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 A=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),A},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 B=r.charCodeAt(0);(x==="utf8"&&B<128||x==="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 A;if(typeof r=="number")for(A=n;A<p;++A)this[A]=r;else{const B=o.isBuffer(r)?r:o.from(r,x),q=B.length;if(q===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(A=0;A<p-n;++A)this[A+n]=B[A%q]}return this};const l={};function I(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(x){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:x,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}I("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),I("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),I("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 j(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&nt(r,u.length-(n+1))}function J(u,r,n,p,x,A){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} ** ${(A+1)*8}${B}`:q=`>= -(2${B} ** ${(A+1)*8-1}${B}) and < 2 ** ${(A+1)*8-1}${B}`,new l.ERR_OUT_OF_RANGE("value",q,u)}j(p,x,A)}function X(u,r){if(typeof u!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",u)}function nt(u,r,n){throw Math.floor(u)!==u?(X(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 It(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 it(u,r){r=r||1/0;let n;const p=u.length;let x=null;const A=[];for(let B=0;B<p;++B){if(n=u.charCodeAt(B),n>55295&&n<57344){if(!x){if(n>56319){(r-=3)>-1&&A.push(239,191,189);continue}else if(B+1===p){(r-=3)>-1&&A.push(239,191,189);continue}x=n;continue}if(n<56320){(r-=3)>-1&&A.push(239,191,189),x=n;continue}n=(x-55296<<10|n-56320)+65536}else x&&(r-=3)>-1&&A.push(239,191,189);if(x=null,n<128){if((r-=1)<0)break;A.push(n)}else if(n<2048){if((r-=2)<0)break;A.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;A.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;A.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return A}function yt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Ee(u,r){let n,p,x;const A=[];for(let B=0;B<u.length&&!((r-=2)<0);++B)n=u.charCodeAt(B),p=n>>8,x=n%256,A.push(x),A.push(p);return A}function qt(u){return t.toByteArray(It(u))}function Mt(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 mt(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 rr=(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 Ft(u){return typeof BigInt>"u"?sr:u}function sr(){throw new Error("BigInt not supported")}})(re)),re}var Fe;function mi(){return Fe||(Fe=1,(function(h,t){var e=Me(),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 T=i(a);return o!==void 0?typeof g=="string"?T.fill(o,g):T.fill(o):T.fill(0),T},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(_){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 v;;)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(v)return;_=(""+_).toLowerCase(),v=!0}}function i(_){var v=e(_);if(typeof v!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return v||_}ie.StringDecoder=s;function s(_){this.encoding=i(_);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=M,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(_){if(_.length===0)return"";var v,m;if(this.lastNeed){if(v=this.fillLast(_),v===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?v?v+this.text(_,m):this.text(_,m):v||""},s.prototype.end=E,s.prototype.text=T,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 a(_,v,m){var d=v.length-1;if(d<m)return 0;var b=c(v[d]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(_.lastNeed=b-2),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,v,m){if((v[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return _.lastNeed=2,"�"}}function g(_){var v=this.lastTotal-this.lastNeed,m=o(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,v,0,_.length),this.lastNeed-=_.length}function T(_,v){var m=a(this,_,v);if(!this.lastNeed)return _.toString("utf8",v);this.lastTotal=m;var d=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,d),_.toString("utf8",v,d)}function E(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+"�":v}function C(_,v){if((_.length-v)%2===0){var m=_.toString("utf16le",v);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",v,_.length-1)}function S(_){var v=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,m)}return v}function F(_,v){var m=(_.length-v)%3;return m===0?_.toString("base64",v):(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",v,_.length-m))}function M(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function N(_){return _.toString(this.encoding)}function R(_){return _&&_.length?this.write(_):""}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=E,t.createStream=T,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 I=this;c(I),I.q=I.c="",I.bufferCheckPosition=t.MAX_BUFFER_LENGTH,I.opt=l||{},I.opt.lowercase=I.opt.lowercase||I.opt.lowercasetags,I.looseCase=I.opt.lowercase?"toLowerCase":"toUpperCase",I.tags=[],I.closed=I.closedRoot=I.sawRoot=!1,I.tag=I.error=null,I.strict=!!f,I.noscript=!!(f||I.opt.noscript),I.state=y.BEGIN,I.strictEntities=I.opt.strictEntities,I.ENTITIES=I.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),I.attribList=[],I.opt.xmlns&&(I.ns=Object.create(N)),I.opt.unquotedAttributeValues===void 0&&(I.opt.unquotedAttributeValues=!f),I.trackPosition=I.opt.position!==!1,I.trackPosition&&(I.position=I.line=I.column=0),rt(I,"onready")}Object.create||(Object.create=function(f){function l(){}l.prototype=f;var I=new l;return I}),Object.keys||(Object.keys=function(f){var l=[];for(var I in f)f.hasOwnProperty(I)&&l.push(I);return l});function s(f){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),I=0,w=0,j=e.length;w<j;w++){var J=f[e[w]].length;if(J>l)switch(e[w]){case"textNode":W(f);break;case"cdata":K(f,"oncdata",f.cdata),f.cdata="";break;case"script":K(f,"onscript",f.script),f.script="";break;default:ot(f,"Max buffer length exceeded: "+e[w])}I=Math.max(I,J)}var X=t.MAX_BUFFER_LENGTH-I;f.bufferCheckPosition=X+f.position}function c(f){for(var l=0,I=e.length;l<I;l++)f[e[l]]=""}function a(f){W(f),f.cdata!==""&&(K(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(K(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ht(this)},write:Ht,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 T(f,l){return new E(f,l)}function E(f,l){if(!(this instanceof E))return new E(f,l);o.apply(this),this._parser=new i(f,l),this.writable=!0,this.readable=!0;var I=this;this._parser.onend=function(){I.emit("end")},this._parser.onerror=function(w){I.emit("error",w),I._parser.error=null},this._decoder=null,g.forEach(function(w){Object.defineProperty(I,"on"+w,{get:function(){return I._parser["on"+w]},set:function(j){if(!j)return I.removeAllListeners(w),I._parser["on"+w]=j,j;I.on(w,j)},enumerable:!0,configurable:!1})})}E.prototype=Object.create(o.prototype,{constructor:{value:E}}),E.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},E.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},E.prototype.on=function(f,l){var I=this;return!I._parser["on"+f]&&g.indexOf(f)!==-1&&(I._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),I.emit.apply(I,w)}),o.prototype.on.call(I,f,l)};var C="[CDATA[",S="DOCTYPE",F="http://www.w3.org/XML/1998/namespace",M="http://www.w3.org/2000/xmlns/",N={xml:F,xmlns:M},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]/,_=/[:_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]/,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===`
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 k(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],I=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[f]=I});for(var V in t.STATE)t.STATE[t.STATE[V]]=V;y=t.STATE;function rt(f,l,I){f[l]&&f[l](I)}function K(f,l,I){f.textNode&&W(f),rt(f,l,I)}function W(f){f.textNode=lt(f.opt,f.textNode),f.textNode&&rt(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 ot(f,l){return W(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,rt(f,"onerror",l),f}function ht(f){return f.sawRoot&&!f.closedRoot&&Y(f,"Unclosed root tag"),f.state!==y.BEGIN&&f.state!==y.BEGIN_WHITESPACE&&f.state!==y.TEXT&&ot(f,"Unexpected end"),W(f),f.c="",f.closed=!0,rt(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&&ot(f,l)}function st(f){f.strict||(f.tagName=f.tagName[f.looseCase]());var l=f.tags[f.tags.length-1]||f,I=f.tag={name:f.tagName,attributes:{}};f.opt.xmlns&&(I.ns=l.ns),f.attribList.length=0,K(f,"onopentagstart",I)}function $(f,l){var I=f.indexOf(":"),w=I<0?["",f]:f.split(":"),j=w[0],J=w[1];return l&&f==="xmlns"&&(j="xmlns",J=""),{prefix:j,local:J}}function et(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=$(f.attribName,!0),I=l.prefix,w=l.local;if(I==="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!==M)Y(f,"xmlns: prefix must be bound to "+M+`
7
- Actual: `+f.attribValue);else{var j=f.tag,J=f.tags[f.tags.length-1]||f;j.ns===J.ns&&(j.ns=Object.create(J.ns)),j.ns[w]=f.attribValue}f.attribList.push([f.attribName,f.attribValue])}else f.tag.attributes[f.attribName]=f.attribValue,K(f,"onattribute",{name:f.attribName,value:f.attribValue});f.attribName=f.attribValue=""}function L(f,l){if(f.opt.xmlns){var I=f.tag,w=$(f.tagName);I.prefix=w.prefix,I.local=w.local,I.uri=I.ns[w.prefix]||"",I.prefix&&!I.uri&&(Y(f,"Unbound namespace prefix: "+JSON.stringify(f.tagName)),I.uri=w.prefix);var j=f.tags[f.tags.length-1]||f;I.ns&&j.ns!==I.ns&&Object.keys(I.ns).forEach(function(mt){K(f,"onopennamespace",{prefix:mt,uri:I.ns[mt]})});for(var J=0,X=f.attribList.length;J<X;J++){var nt=f.attribList[J],ct=nt[0],It=nt[1],it=$(ct,!0),yt=it.prefix,Ee=it.local,qt=yt===""?"":I.ns[yt]||"",Mt={name:ct,value:It,prefix:yt,local:Ee,uri:qt};yt&&yt!=="xmlns"&&!qt&&(Y(f,"Unbound namespace prefix: "+JSON.stringify(yt)),Mt.uri=yt),f.tag.attributes[ct]=Mt,K(f,"onattribute",Mt)}f.attribList.length=0}f.tag.isSelfClosing=!!l,f.sawRoot=!0,f.tags.push(f.tag),K(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 H(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}K(f,"onscript",f.script),f.script=""}var l=f.tags.length,I=f.tagName;f.strict||(I=I[f.looseCase]());for(var w=I;l--;){var j=f.tags[l];if(j.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=I;for(var J=f.tags.length;J-- >l;){var X=f.tag=f.tags.pop();f.tagName=f.tag.name,K(f,"onclosetag",f.tagName);var nt={};for(var ct in X.ns)nt[ct]=X.ns[ct];var It=f.tags[f.tags.length-1]||f;f.opt.xmlns&&X.ns!==It.ns&&Object.keys(X.ns).forEach(function(it){var yt=X.ns[it];K(f,"onclosenamespace",{prefix:it,uri:yt})})}l===0&&(f.closedRoot=!0),f.tagName=f.attribValue=f.attribName="",f.attribList.length=0,f.state=y.TEXT}function Tt(f){var l=f.entity,I=l.toLowerCase(),w,j="";return f.ENTITIES[l]?f.ENTITIES[l]:f.ENTITIES[I]?f.ENTITIES[I]:(l=I,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),w=parseInt(l,16),j=w.toString(16)):(l=l.slice(1),w=parseInt(l,10),j=w.toString(10))),l=l.replace(/^0+/,""),isNaN(w)||j.toLowerCase()!==l?(Y(f,"Invalid character entity"),"&"+f.entity+";"):String.fromCodePoint(w))}function bt(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 Vt(f,l){var I="";return l<f.length&&(I=f.charAt(l)),I}function Ht(f){var l=this;if(this.error)throw this.error;if(l.closed)return ot(l,"Cannot write after close. Assign an onready handler.");if(f===null)return ht(l);typeof f=="object"&&(f=f.toString());for(var I=0,w="";w=Vt(f,I++),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;bt(l,w);continue;case y.BEGIN_WHITESPACE:bt(l,w);continue;case y.TEXT:if(l.sawRoot&&!l.closedRoot){for(var j=I-1;w&&w!=="<"&&w!=="&";)w=Vt(f,I++),w&&l.trackPosition&&(l.position++,w===`
9
- `?(l.line++,l.column=0):l.column++);l.textNode+=f.substring(j,I-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?(K(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===">"?(K(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,K(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&&K(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&&K(l,"oncdata",l.cdata),K(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===">"?(K(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(_,w)?l.tagName+=w:(st(l),w===">"?L(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===">"?(L(l,!0),H(l)):(Y(l,"Forward-slash in opening tag not followed by >"),l.state=y.ATTRIB);continue;case y.ATTRIB:if(d(w))continue;w===">"?L(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,et(l),L(l)):d(w)?l.state=y.ATTRIB_NAME_SAW_WHITE:U(_,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="",K(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?L(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||ot(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}et(l),l.q="",l.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:d(w)?l.state=y.ATTRIB:w===">"?L(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}et(l),w===">"?L(l):l.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(l.tagName)w===">"?H(l):U(_,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;k(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===">"?H(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 X,nt;switch(l.state){case y.TEXT_ENTITY:X=y.TEXT,nt="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:X=y.ATTRIB_VALUE_QUOTED,nt="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:X=y.ATTRIB_VALUE_UNQUOTED,nt="attribValue";break}if(w===";"){var ct=Tt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(ct)?(l.entity="",l.state=X,l.write(ct)):(l[nt]+=ct,l.entity="",l.state=X)}else U(l.entity.length?m:v,w)?l.entity+=w:(Y(l,"Invalid character in entity name"),l[nt]+="&"+l.entity+w,l.entity="",l.state=X);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,I=function(){var w=16384,j=[],J,X,nt=-1,ct=arguments.length;if(!ct)return"";for(var It="";++nt<ct;){var it=Number(arguments[nt]);if(!isFinite(it)||it<0||it>1114111||l(it)!==it)throw RangeError("Invalid code point: "+it);it<=65535?j.push(it):(it-=65536,J=(it>>10)+55296,X=it%1024+56320,j.push(J,X)),(nt+1===ct||j.length>w)&&(It+=f.apply(null,j),j.length=0)}return It};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:I,configurable:!0,writable:!0}):String.fromCodePoint=I})()})(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(_){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 a(_){var v=Number(_);if(!isNaN(v))return v;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,v){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 v=="string"&&(v=i[_+"Fn"](v,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in v)if(v.hasOwnProperty(m))if("instructionFn"in i)v[m]=i.instructionFn(v[m],m,s);else{var d=v[m];delete v[m],v[i.instructionNameFn(m,d,s)]=d}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(v):s[i[_+"Key"]]=v}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in v)if(v.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,v,s):m,i.instructionHasAttributes?(b[i.attributesKey]=v[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(v[m]=i.instructionFn(v[m],m,s)),b[i.instructionKey]=v[m])}else _+"Fn"in i&&(v=i[_+"Fn"](v,s)),b[i[_+"Key"]]=v;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function g(_){if("attributesFn"in i&&_&&(_=i.attributesFn(_,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&_){var v;for(v in _)if(_.hasOwnProperty(v)&&(i.trim&&(_[v]=_[v].trim()),i.nativeTypeAttributes&&(_[v]=a(_[v])),"attributeValueFn"in i&&(_[v]=i.attributeValueFn(_[v],v,s)),"attributeNameFn"in i)){var m=_[v];delete _[v],_[i.attributeNameFn(v,_[v],s)]=m}}return _}function T(_){var v={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,d;(d=m.exec(_.body))!==null;)v[d[1]]=d[2]||d[3]||d[4];v=g(v)}if(_.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&&(_.body=_.body.trim());var b={};i.instructionHasAttributes&&Object.keys(v).length?(b[_.name]={},b[_.name][i.attributesKey]=v):b[_.name]=_.body,o("instruction",b)}}function E(_,v){var m;if(typeof _=="object"&&(v=_.attributes,_=_.name),v=g(v),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&v&&Object.keys(v).length){m[i.attributesKey]={};var d;for(d in v)v.hasOwnProperty(d)&&(m[i.attributesKey][d]=v[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&&v&&Object.keys(v).length&&(m[i.attributesKey]=v),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function C(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=a(_)),i.sanitize&&(_=_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),o("text",_))}function S(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function F(_){var v=s[i.parentKey];i.addParent||delete s[i.parentKey],s=v}function M(_){i.ignoreCdata||(i.trim&&(_=_.trim()),o("cdata",_))}function N(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),o("doctype",_))}function R(_){_.note=_}return le=function(_,v){var m=h.parser(!0,{}),d={};if(s=d,i=c(v),m.opt={strictEntities:!0},m.onopentag=E,m.ontext=C,m.oncomment=S,m.onclosetag=F,m.onerror=R,m.oncdata=M,m.ondoctype=N,m.onprocessinginstruction=T,m.write(_).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,ke;function yi(){if(ke)return ce;ke=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(T,E){return T===g?"_":E},c.spaces):o=JSON.stringify(a,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var ue,Le;function Ye(){if(Le)return ue;Le=1;var h=oe(),t=ne().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?`
10
- `:"")+Array(d+1).join(m.spaces)}function a(m,d,b){if(d.ignoreAttributes)return"";"attributesFn"in d&&(m=d.attributesFn(m,i,e));var P,U,k,y,V=[];for(P in m)m.hasOwnProperty(P)&&m[P]!==null&&m[P]!==void 0&&(y=d.noQuotesForNativeAttributes&&typeof m[P]!="string"?"":'"',U=""+m[P],U=U.replace(/"/g,"&quot;"),k="attributeNameFn"in d?d.attributeNameFn(P,U,i,e):P,V.push(d.spaces&&d.indentAttributes?c(d,b+1,!1):" "),V.push(k+"="+y+("attributeValueFn"in d?d.attributeValueFn(U,P,i,e):U)+y));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"+a(m[d.attributesKey],d,b)+"?>"}function g(m,d,b){if(d.ignoreInstruction)return"";var P;for(P in m)if(m.hasOwnProperty(P))break;var U="instructionNameFn"in d?d.instructionNameFn(P,m[P],i,e):P;if(typeof m[P]=="object")return e=m,i=U,"<?"+U+a(m[P][d.attributesKey],d,b)+"?>";var k=m[P]?m[P]:"";return"instructionFn"in d&&(k=d.instructionFn(k,P,i,e)),"<?"+U+(k?" "+k:"")+"?>"}function T(m,d){return d.ignoreComment?"":"<!--"+("commentFn"in d?d.commentFn(m,i,e):m)+"-->"}function E(m,d){return d.ignoreCdata?"":"<![CDATA["+("cdataFn"in d?d.cdataFn(m,i,e):m.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(m,d){return d.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in d?d.doctypeFn(m,i,e):m)+">"}function S(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 F(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 P=[],U="elementNameFn"in d?d.elementNameFn(m.name,m):m.name;P.push("<"+U),m[d.attributesKey]&&P.push(a(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?(P.push(">"),m[d.elementsKey]&&m[d.elementsKey].length&&(P.push(N(m[d.elementsKey],d,b+1)),e=m,i=m.name),P.push(d.spaces&&F(m,d)?`
11
- `+Array(b+1).join(d.spaces):""),P.push("</"+U+">")):P.push("/>"),P.join("")}function N(m,d,b,P){return m.reduce(function(U,k){var y=c(d,b,P&&!U);switch(k.type){case"element":return U+y+M(k,d,b);case"comment":return U+y+T(k[d.commentKey],d);case"doctype":return U+y+C(k[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?y:"")+E(k[d.cdataKey],d);case"text":return U+(d.indentText?y:"")+S(k[d.textKey],d);case"instruction":var V={};return V[k[d.nameKey]]=k[d.attributesKey]?k:k[d.instructionKey],U+(d.indentInstruction?y:"")+g(V,d,b)}},"")}function R(m,d,b){var P;for(P in m)if(m.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=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 y=[];if(d){if(y.push("<"+k),typeof m!="object")return y.push(">"+S(m,b)+"</"+k+">"),y.join("");m[b.attributesKey]&&y.push(a(m[b.attributesKey],b,P));var V=R(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)y.push(">");else return y.push("/>"),y.join("")}return y.push(v(m,b,P+1,!1)),e=m,i=d,d&&y.push((U?c(b,P,!1):"")+"</"+k+">"),y.join("")}function v(m,d,b,P){var U,k,y,V=[];for(k in m)if(m.hasOwnProperty(k))for(y=t(m[k])?m[k]:[m[k]],U=0;U<y.length;++U){switch(k){case d.declarationKey:V.push(o(y[U],d,b));break;case d.instructionKey:V.push((d.indentInstruction?c(d,b,P):"")+g(y[U],d,b));break;case d.attributesKey:case d.parentKey:break;case d.textKey:V.push((d.indentText?c(d,b,P):"")+S(y[U],d));break;case d.cdataKey:V.push((d.indentCdata?c(d,b,P):"")+E(y[U],d));break;case d.doctypeKey:V.push(c(d,b,P)+C(y[U],d));break;case d.commentKey:V.push(c(d,b,P)+T(y[U],d));break;default:V.push(c(d,b,P)+_(y[U],k,d,b,R(y[U],d)))}P=P&&!V.length}return V.join("")}return ue=function(m,d){d=s(d);var b=[];return e=m,i="_root_",d.compact?b.push(v(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("")},ue}var he,Ge;function xi(){if(Ge)return he;Ge=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,Ve;function Ei(){if(Ve)return fe;Ve=1;var h=Ue(),t=yi(),e=Ye(),i=xi();return fe={xml2js:h,xml2json:t,js2xml:e,json2xml:i},fe}var de=Ei(),wi=Me();const ft=class ft{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,...ft.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"]),...ft.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(a.properties){const g=ft.toArray(a.properties.property),T={};for(let E of g){const C=E._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(E)?.properties??{},_classname:C.propertytype};break;default:S=C.value}T[C.name]=S}a.properties=T}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 T=g.split(",");return{x:+T[0],y:+T[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=ft.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"?ft.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=T=>{const{objectgroup:E,group:C,layer:S,imagelayer:F}=T,M=N=>{N&&ft.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)})};M(E),M(S),M(C),M(F),C&&s(C)};s(t.map);const c=(T,E=[])=>{if(!T)return E;for(let C of T){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 M={...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 M.elements,delete M.layer,M.data&&(M.data=ft.decode(M,M.width*M.height)),E.push(M)}return E},a=c(e.elements[0].elements),o=ft.toArray(i).map(T=>this.transform(T)),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:ft.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=ft.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};ft.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},ft.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let pe=ft;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,Ai=536870912,Ti=268435456;class Lt 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&Ai)}get rotatedHex120(){return!!(this._gid&Ti)}get gid(){return Lt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends Lt{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 Lt{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=Lt.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 T=g.parseMap();return i(T)}else if(e=="tileset"){const T=g.parseTileset();return i(T)}}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=[],T=()=>{E++,E==c.tilesets.length&&!o&&(c.tilesets=g,t(c))};let E=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,T();continue}i&&At.typeOfFile(S.source).isPath&&(S.source=s(S.source)),this._parseFile(S.source,"tileset",(F,M)=>{if(M)return o=!0,t(null,M);g[C]={...F,firstgid:S.firstgid},T()})}}})}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,Ii=(h,t,e)=>t in h?Bi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ct=(h,t,e)=>(Ii(h,typeof t!="symbol"?t+"":t,e),e);const Yt=class Kt 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=Kt.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",Kt.vertSize),Ct(this,"vertPerQuad",Kt.vertPerQuad),Ct(this,"stride",Kt.stride),Ct(this,"buf"),this.buf=e}};Ct(Yt,"vertSize",13),Ct(Yt,"vertPerQuad",4),Ct(Yt,"stride",Yt.vertSize*4);let Mi=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 qe{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 Ke{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 Mi(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(Ke,"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,vt=(h,t,e)=>(Pi(h,typeof t!="symbol"?t+"":t,e),e);class Ot{constructor(t){vt(this,"max_textures"),vt(this,"arr",[]),vt(this,"count",0),vt(this,"dirty",!1),vt(this,"dirty_gpu",!1),vt(this,"bind_group",null),vt(this,"bind_group_resources",{}),vt(this,"tex_sizes",null),vt(this,"null_color",new Float32Array([0,0,0,.5])),vt(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 ki=`
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
- `,Li=`
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 qe{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:ki,fragment:Li.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,Gi=(h,t,e)=>t in h?Yi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Xt=(h,t,e)=>(Gi(h,typeof t!="symbol"?t+"":t,e),e);const Vi=`
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
- `,qi=`
191
+ `,rr=`
111
192
  //include_textures
112
193
 
113
194
  @fragment
@@ -124,18 +205,20 @@ fn mainFrag(
124
205
  var color = sampleMultiTexture(vTextureId, uv, dx, dy);
125
206
  return color * vAlpha;
126
207
  };
127
- `;class ze extends qe{constructor(){super(...arguments),Xt(this,"_shader",null),Xt(this,"max_textures",St.TEXTURES_PER_TILEMAP),Xt(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:Vi,entryPoint:"mainVert"},fragment:{source:qi.replace("//include_textures",Ot.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new O.BindGroup({ut:this.pipe_uniforms})}}Xt(ze,"extension",{type:[O.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Ki=Object.defineProperty,ji=(h,t,e)=>t in h?Ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,at=(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 gt=Object.keys(We).length/2;class Xe extends O.ViewContainer{constructor(t){super({}),at(this,"shadowColor",new Float32Array([0,0,0,.5])),at(this,"state",O.State.for2d()),at(this,"is_valid",!1),at(this,"renderPipeId","tilemap"),at(this,"canBundle",!0),at(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),at(this,"tileAnim",null),at(this,"rects_count",0),at(this,"compositeParent",!1),at(this,"tileset",new Ot(St.TEXTURES_PER_TILEMAP)),at(this,"tilemapBounds",new O.Bounds),at(this,"hasAnimatedTile",!1),at(this,"pointsBuf",[]),at(this,"batched"),at(this,"vbId",0),at(this,"vb",null),at(this,"vbBuffer",null),at(this,"vbArray",null),at(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:T=0,tileWidth:E=c.width,tileHeight:C=c.height,animX:S=0,animY:F=0,rotate:M=0,animCountX:N=1024,animCountY:R=1024,animDivisor:_=1,alpha:v=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||S>0||F>0,m.push(g),m.push(T),m.push(e),m.push(i),m.push(E),m.push(C),m.push(M),m.push(S|0),m.push(F|0),m.push(a),m.push(N),m.push(R),m.push(_),m.push(v),this.tilemapBounds.addFrame(e,i,e+E,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(gt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(gt-7)]=t,i[i.length-(gt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(gt-8)]=t,i[i.length-(gt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(gt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(gt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/gt;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,T=this.vbInts;let E=0,C=0;for(let S=0;S<e.length;S+=gt){this.compositeParent&&(C=e[S+9]);const M=e[S+2],N=e[S+3],R=e[S+4],_=e[S+5],v=e[S+0],m=e[S+1];let d=e[S+6];const b=e[S+7],P=e[S+8],U=e[S+10]||1024,k=e[S+11]||1024,y=b+U*2048,V=P+k*2048,rt=e[S+12],K=e[S+13];let W,lt,ot,ht,Y,st,$,et;if(d===0)W=v,lt=m,ot=v+R,ht=m,Y=v+R,st=m+_,$=v,et=m+_;else{let L=R/2,H=_/2;d%4!==0&&(L=_/2,H=R/2);const Tt=v+L,bt=m+H;d=O.groupD8.add(d,O.groupD8.NW),W=Tt+L*O.groupD8.uX(d),lt=bt+H*O.groupD8.uY(d),d=O.groupD8.add(d,2),ot=Tt+L*O.groupD8.uX(d),ht=bt+H*O.groupD8.uY(d),d=O.groupD8.add(d,2),Y=Tt+L*O.groupD8.uX(d),st=bt+H*O.groupD8.uY(d),d=O.groupD8.add(d,2),$=Tt+L*O.groupD8.uX(d),et=bt+H*O.groupD8.uY(d)}g[E++]=M,g[E++]=N,g[E++]=W,g[E++]=lt,g[E++]=v+.5,g[E++]=m+.5,g[E++]=v+R-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=V,T[E++]=C,g[E++]=rt,g[E++]=K,g[E++]=M+R,g[E++]=N,g[E++]=ot,g[E++]=ht,g[E++]=v+.5,g[E++]=m+.5,g[E++]=v+R-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=V,T[E++]=C,g[E++]=rt,g[E++]=K,g[E++]=M+R,g[E++]=N+_,g[E++]=Y,g[E++]=st,g[E++]=v+.5,g[E++]=m+.5,g[E++]=v+R-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=V,T[E++]=C,g[E++]=rt,g[E++]=K,g[E++]=M,g[E++]=N+_,g[E++]=$,g[E++]=et,g[E++]=v+.5,g[E++]=m+.5,g[E++]=v+R-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=V,T[E++]=C,g[E++]=rt,g[E++]=K}a.data=g}isModified(t){return!!(this.rects_count*gt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/gt}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,T=0,E=0,C=1024,S=1024,F=1,M=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:a,tileHeight:o,animX:g,animY:T,rotate:E,animCountX:C,animCountY:S,animDivisor:F,alpha:M})}}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,Gt=(h,t,e)=>(Wi(h,typeof t!="symbol"?t+"":t,e),e);class Xi extends O.Container{constructor(t){super(),Gt(this,"texturesPerTilemap"),Gt(this,"tileAnim",null),Gt(this,"lastModifiedTilemap",null),Gt(this,"modificationMarker",0),Gt(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 Xe(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],T=g.getTileset().arr;for(let E=0;E<T.length;E++)if(T[E]===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 Xe(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,T){return this.tile(t,e,i,{animX:s,animY:c,animCountX:a,animCountY:o,animDivisor:g,alpha:T})}addRect(t,e,i,s,c,a,o,g,T,E,C,S){const F=t/this.texturesPerTilemap>>0,M=t%this.texturesPerTilemap;return this.children[F]&&this.children[F].getTileset().count>0?(this.lastModifiedTilemap=this.children[F],this.lastModifiedTilemap.addRect(M,e,i,s,c,a,o,g,T,E,C,S)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}O.extensions.add(Ke),O.extensions.add(je),O.extensions.add(ze);class $t extends O.AnimatedSprite{constructor(t,e){super($t.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=$t.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 xe extends D.DisplayObject(Xi){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 T=t+e*g,E=this._layer.getTileByIndex(T);if(!E||E&&E.gid==0)return;const C=xe.findTileSet(E.gid,this.tileSets);if(!C)return;const S=new $t(E,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",xe);function $i(h){return D.createComponent("CompositeTileLayer",h)}class Hi 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 T=a[g];if(T===0)continue;let E;for(let M=t.length-1;M>=0;M--)if(t[M].firstgid&&t[M].firstgid<=T){E=t[M];break}if(!E){c.has(0)||c.set(0,new Array(a.length).fill(0)),c.get(0)[g]=T;continue}const C=T-E.firstgid,S=E.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]=T}const o=Array.from(c.keys()).sort((g,T)=>g-T);for(const g of o){const T=c.get(g);if(T.some(E=>E!==0)){const E={...s,name:`${s.name}_z${g}`,data:T,properties:{...s.properties,z:g}};i.push(E)}}}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(E,C="")=>typeof E!="string"?E:await new At(E,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const E=t();if(E){o=await g(E,e()),a=[];for(let S of o.tilesets)S.tile&&(S.tiles=S.tile),S.tiles||(S.tiles=[]),a.push(await new Hi(S).load(S.image.source));let C=o.layers;i()&&(C=Qi(o.layers,a)),s.set(C)}});const T=(E,C={})=>D.h(D.Container,C,D.loop(E,S=>{switch(S.type){case Rt.Tile:return D.h($i,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...S,tilesets:a});case Rt.Image:const{width:F,height:M,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:M});case Rt.Group:return T(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,T(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
- varying vec2 vUV;
212
+ varying vec2 vUV;
213
+ uniform mat3 translationMatrix;
214
+ uniform mat3 projectionMatrix;
132
215
  void main() {
133
- vUV = aUV;
134
- gl_Position = vec4(aPosition, 0.0, 1.0);
216
+ vUV = aUV;
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;
138
-
139
222
  varying vec2 vUV;
140
223
 
141
224
  uniform float uTime;
@@ -146,139 +229,86 @@ fn mainFrag(
146
229
  uniform float uRainDensity;
147
230
  uniform float uMaxDrops;
148
231
 
149
- // Optimized hash function (single multiply, no sin)
150
- float hash(float n) {
151
- return fract(n * 0.1031);
232
+ float hash(vec2 p) {
233
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
152
234
  }
153
235
 
154
- // Generate a single rain drop with fine realistic streak (highly optimized)
155
- float rainDrop(vec2 uv, float t, float seed, float dropIndex, float maxDrops, float cosA, float sinA) {
156
- // Pre-generate only necessary random values (reduced from 6 to 3)
157
- float rnd0 = hash(seed);
158
- float rnd1 = hash(seed + 1.0);
159
- float rnd2 = hash(seed + 2.0);
160
-
161
- // Simplified X position calculation
162
- float xStructured = mod(dropIndex, 35.0) / 35.0;
163
- float x = mix(rnd0, xStructured, 0.4) * 2.4 - 1.2;
164
-
165
- // Base speed + variation
166
- float speed = (0.4 + rnd1 * 0.6) * uRainSpeed;
167
-
168
- // Simplified Y position calculation
169
- float yStructured = mod(dropIndex, maxDrops) / max(maxDrops, 1.0);
170
- float initialYOffset = mix(rnd2, yStructured, 0.7);
171
- float yProgress = mod(initialYOffset + t * speed, 1.0);
172
- float y = 1.2 - yProgress * 2.4;
173
-
174
- // Aggressive early discard - check vertical bounds first
175
- if (y < -1.3 || y > 1.3) {
176
- return 0.0;
177
- }
178
-
179
- // Simplified wind effect
180
- float windOffset = uWindDirection * uWindStrength * yProgress * 0.5;
181
- x += windOffset;
182
-
183
- // Early discard for horizontal bounds
184
- if (x < -1.5 || x > 1.5) {
185
- return 0.0;
186
- }
187
-
188
- // Fast distance check before expensive calculations
189
- vec2 diff = uv - vec2(x, y);
190
- float distSq = dot(diff, diff);
191
-
192
- // Early discard if too far (major performance boost)
193
- if (distSq > 0.01) { // ~0.1 units distance
194
- return 0.0;
195
- }
196
-
197
- // Only calculate expensive operations if we're close
198
- float dropWidth = 0.0012 + rnd0 * 0.0008;
199
- float dropLength = 0.035 + rnd1 * 0.020;
200
-
201
- // Simplified rotation (only if needed)
202
- float rotX = diff.x * cosA - diff.y * sinA;
203
- float rotY = diff.x * sinA + diff.y * cosA;
204
-
205
- // Fast distance calculation
206
- float distX = abs(rotX) / dropWidth;
207
- float distY = abs(rotY) / dropLength;
208
- float dist = max(distX, distY * 0.6);
209
-
210
- // Final early discard
211
- if (dist > 1.2) {
212
- return 0.0;
213
- }
214
-
215
- // Simplified intensity calculation
216
- float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
217
- intensity *= 0.7 + 0.5 * rnd0;
218
-
219
- // Simplified vertical fade
220
- float verticalFade = smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
221
- intensity *= verticalFade;
222
-
223
- return intensity;
236
+ float rainLayer(
237
+ vec2 uv,
238
+ float t,
239
+ float scale,
240
+ float speed,
241
+ float slant,
242
+ float density,
243
+ float width,
244
+ float length
245
+ ) {
246
+ vec2 dir = normalize(vec2(slant, 1.0));
247
+ vec2 perp = vec2(-dir.y, dir.x);
248
+
249
+ float along = dot(uv, dir) * scale + t * speed;
250
+ float across = dot(uv, perp) * scale;
251
+
252
+ vec2 p = vec2(across, along);
253
+ vec2 cell = floor(p);
254
+ vec2 f = fract(p);
255
+
256
+ float rnd = hash(cell);
257
+ float rnd2 = hash(cell + 13.17);
258
+
259
+ float x = rnd;
260
+ float dropWidth = width * (0.7 + rnd2 * 0.6);
261
+ float dropLength = length * (0.5 + rnd * 0.6);
262
+
263
+ float line = smoothstep(dropWidth, 0.0, abs(f.x - x));
264
+ float segment = smoothstep(0.0, 0.03, f.y)
265
+ * (1.0 - smoothstep(dropLength, dropLength + 0.03, f.y));
266
+
267
+ float visible = step(rnd, density);
268
+ float intensity = line * segment * visible;
269
+ return intensity * (0.6 + 0.4 * rnd2);
224
270
  }
225
271
 
226
272
  void main() {
227
- // Normalized uv coordinates centered (pre-calculated once)
228
- vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy)
229
- / min(uResolution.x, uResolution.y);
230
-
231
- float rain = 0.0;
232
-
233
- // Clamp number of drops - reduced max for better performance
234
- float maxDrops = clamp(uMaxDrops, 10.0, 150.0);
235
-
236
- // Pre-calculate wind angle & trig once per fragment
237
- float windAngle = uWindDirection * uWindStrength * 0.2;
238
- float cosA = cos(windAngle);
239
- float sinA = sin(windAngle);
240
-
241
- // Performance optimization: reduce loop iterations based on resolution
242
- float pixelCount = uResolution.x * uResolution.y;
243
- float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
244
- float effectiveMaxDrops = maxDrops * resolutionFactor;
245
- float loopMax = min(effectiveMaxDrops, 150.0);
246
-
247
- // Optimized loop with early exit optimization
248
- for (float i = 0.0; i < 150.0; i++) {
249
- if (i >= loopMax) break;
250
- // Use larger prime number spacing for better seed distribution
251
- float seed = i * 23.47;
252
- float dropValue = rainDrop(uv, uTime, seed, i, maxDrops, cosA, sinA);
253
- rain += dropValue;
254
-
255
- // Early exit if we've accumulated enough intensity (performance optimization)
256
- if (rain > 2.0) break;
257
- }
258
-
259
- // Scale based on density (optimized calculation)
260
- rain *= uRainDensity * 0.007;
261
-
262
- // Realistic rain color
263
- vec3 rainColor = vec3(0.88, 0.92, 1.0);
264
-
265
- // Alpha calculation - improved visibility
266
- float alpha = rain * 0.9;
267
-
268
- gl_FragColor = vec4(rainColor * rain, alpha);
273
+ vec2 uv = gl_FragCoord.xy / uResolution.xy;
274
+ float aspect = uResolution.x / uResolution.y;
275
+ uv.x *= aspect;
276
+
277
+ float pixelCount = uResolution.x * uResolution.y;
278
+ float resolutionFactor = clamp(pixelCount / 700000.0, 0.6, 1.0);
279
+
280
+ float densityFactor = clamp(uRainDensity / 240.0, 0.2, 1.2);
281
+ float maxDropFactor = clamp(uMaxDrops / 120.0, 0.3, 1.0);
282
+ float density = clamp(densityFactor * maxDropFactor * resolutionFactor, 0.1, 1.0);
283
+
284
+ float slant = uWindDirection * uWindStrength * 0.6;
285
+ float speed = 1.3 * uRainSpeed + 0.4;
286
+
287
+ float rain = 0.0;
288
+ rain += rainLayer(uv, uTime, 24.0, speed * 1.2, slant, density, 0.018, 0.75);
289
+ rain += rainLayer(uv, uTime, 36.0, speed * 1.5, slant * 1.2, density * 0.8, 0.014, 0.6);
290
+ rain += rainLayer(uv, uTime, 52.0, speed * 1.8, slant * 1.4, density * 0.6, 0.012, 0.5);
291
+
292
+ float heightFade = mix(0.65, 1.0, uv.y);
293
+ rain *= heightFade;
294
+
295
+ vec3 rainColor = vec3(0.75, 0.85, 1.0);
296
+ gl_FragColor = vec4(rainColor * rain, clamp(rain, 0.0, 0.9));
269
297
  }
270
- `;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=`
271
299
  precision mediump float;
272
300
  attribute vec2 aPosition;
273
301
  attribute vec2 aUV;
274
- varying vec2 vUV;
302
+ varying vec2 vUV;
303
+ uniform mat3 translationMatrix;
304
+ uniform mat3 projectionMatrix;
275
305
  void main() {
276
306
  vUV = aUV;
277
- 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);
278
309
  }
279
310
  `,t=`
280
311
  precision mediump float;
281
-
282
312
  varying vec2 vUV;
283
313
 
284
314
  uniform float uTime;
@@ -289,136 +319,91 @@ fn mainFrag(
289
319
  uniform float uSnowDensity;
290
320
  uniform float uMaxFlakes;
291
321
 
292
- // Hash function for random number generation
293
- float hash(float n) {
294
- return fract(sin(n) * 43758.5453);
322
+ float hash(vec2 p) {
323
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
295
324
  }
296
325
 
297
- // Generate a single snowflake
298
- float snowFlake(vec2 uv, float t, float seed) {
299
- // Pre-calculate all necessary hash values once
300
- float rnd0 = hash(seed);
301
- float rnd1 = hash(seed + 1.0);
302
- float rnd2 = hash(seed + 2.0);
303
- float rnd3 = hash(seed + 3.0);
304
- float rnd4 = hash(seed + 4.0);
305
-
306
- // Base X position
307
- float x = rnd0 * 2.4 - 1.2;
308
-
309
- // Falling speed (slower than rain)
310
- float baseSpeed = 0.3 + rnd1 * 0.4;
311
- float speed = baseSpeed * uSnowSpeed;
312
-
313
- // Y position falling from top to bottom
314
- float y = 1.2 - fract(t * speed + rnd2) * 2.4;
315
-
316
- // Early exit if flake is too far vertically
317
- if (y < -1.4 || y > 1.4) {
318
- return 0.0;
319
- }
320
-
321
- // Fall progress (0 = top, 1 = bottom)
322
- float fallProgress = (1.2 - y) / 2.4;
323
-
324
- // Optimized oscillation - natural and subtle movement
325
- float oscillationPhase = t * 1.8 + seed * 6.28;
326
- float oscillation = sin(oscillationPhase) * 0.08 + sin(oscillationPhase * 1.4) * 0.04;
327
- oscillation *= (1.0 + fallProgress * 0.3);
328
-
329
- // Wind effect - more pronounced and progressive with fall
330
- float windOffset = uWindDirection * uWindStrength * fallProgress * 0.8;
331
-
332
- // Add horizontal drift due to wind (even at top)
333
- float windDrift = uWindDirection * uWindStrength * 0.2;
334
-
335
- // Final X position with wind and oscillation
336
- x += windOffset + windDrift + oscillation;
337
-
338
- // Early exit if flake is too far horizontally
339
- if (x < -1.4 || x > 1.4) {
340
- return 0.0;
341
- }
342
-
343
- vec2 diff = uv - vec2(x, y);
344
-
345
- // Fast distance check before expensive calculations
346
- float distSq = dot(diff, diff);
347
-
348
- // Early exit if too far (major performance boost)
349
- if (distSq > 0.015) { // ~0.12 units distance
350
- return 0.0;
351
- }
352
-
353
- // Flake size (circular) - only calculate if close
354
- float flakeSize = 0.008 + rnd3 * 0.006;
355
- float sizeSq = flakeSize * flakeSize;
356
-
357
- // Additional early exit check
358
- if (distSq > sizeSq * 1.5) {
326
+ vec2 hash2(vec2 p) {
327
+ return vec2(
328
+ hash(p),
329
+ hash(p + 19.19)
330
+ );
331
+ }
332
+
333
+ float snowLayer(
334
+ vec2 uv,
335
+ float t,
336
+ float scale,
337
+ float speed,
338
+ float wind,
339
+ float density,
340
+ float sizeMin,
341
+ float sizeMax
342
+ ) {
343
+ vec2 p = uv;
344
+ p.x += wind * t;
345
+ p.y += t * speed;
346
+
347
+ p *= scale;
348
+ vec2 cell = floor(p);
349
+ vec2 f = fract(p);
350
+
351
+ float rnd = hash(cell);
352
+ if (rnd > density) {
359
353
  return 0.0;
360
354
  }
361
-
362
- float dist = sqrt(distSq) / flakeSize;
363
-
364
- // Intensity with soft flake shape
365
- float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
366
- intensity *= 0.8 + 0.2 * rnd4;
367
-
368
- // Light twinkle (reduced frequency for performance)
369
- float twinkle = 0.9 + 0.1 * sin(t * 6.0 + seed * 12.56);
370
- intensity *= twinkle;
371
-
372
- // Fade at top and bottom
373
- intensity *= smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
374
-
375
- return intensity;
355
+
356
+ vec2 jitter = hash2(cell + 3.7);
357
+ float wobble = (hash(cell + 9.1) - 0.5) * 0.3;
358
+ vec2 center = jitter;
359
+ center.x += sin(t * 0.7 + jitter.y * 6.283) * 0.15 + wobble;
360
+ center.y += cos(t * 0.5 + jitter.x * 6.283) * 0.12;
361
+
362
+ float size = mix(sizeMin, sizeMax, rnd);
363
+ float dist = length(f - center);
364
+ float alpha = 1.0 - smoothstep(size * 0.4, size, dist);
365
+ float twinkle = 0.7 + 0.3 * sin(t * 1.2 + rnd * 6.283);
366
+ return alpha * twinkle;
376
367
  }
377
368
 
378
369
  void main() {
379
- vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.x, uResolution.y);
380
-
381
- float snow = 0.0;
382
-
383
- // Calculate number of flakes based on density (optimized for performance)
384
- // Density 50-400 corresponds to approximately 40-150 flakes (reduced for performance)
385
- float targetFlakes = 40.0 + (uSnowDensity - 50.0) * (110.0 / 350.0);
386
- float maxFlakes = clamp(max(uMaxFlakes, targetFlakes), 30.0, 120.0);
387
-
388
- // Performance optimization: reduce loop iterations based on resolution
370
+ vec2 uv = gl_FragCoord.xy / uResolution.xy;
371
+ float aspect = uResolution.x / uResolution.y;
372
+ uv.x *= aspect;
373
+
389
374
  float pixelCount = uResolution.x * uResolution.y;
390
- float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
391
- float effectiveMaxFlakes = maxFlakes * resolutionFactor;
392
- float loopMax = min(effectiveMaxFlakes, 120.0);
393
-
394
- // Generate flakes (limited to 120 for performance)
395
- for (float i = 0.0; i < 120.0; i++) {
396
- if (i >= loopMax) break;
397
- float flakeValue = snowFlake(uv, uTime, i * 15.67);
398
- snow += flakeValue;
399
-
400
- // Early exit if we've accumulated enough intensity (performance optimization)
401
- if (snow > 2.5) break;
402
- }
403
-
404
- // Intensity adjustment based on density (normalization)
405
- // Higher density means more visible flakes
406
- float densityFactor = clamp(uSnowDensity / 200.0, 0.3, 2.0);
407
- snow *= densityFactor;
408
-
409
- // White color for snow
410
- vec3 snowColor = vec3(1.0, 1.0, 1.0);
411
-
412
- gl_FragColor = vec4(snowColor * snow, snow * 0.9);
375
+ float resolutionFactor = clamp(pixelCount / 900000.0, 0.5, 1.0);
376
+
377
+ float densityFactor = clamp(uSnowDensity / 220.0, 0.15, 1.2);
378
+ float maxFlakeFactor = clamp(uMaxFlakes / 100.0, 0.3, 1.0);
379
+ float density = clamp(densityFactor * maxFlakeFactor * resolutionFactor, 0.05, 1.0);
380
+
381
+ float wind = uWindDirection * uWindStrength * 0.45;
382
+ float speed = uSnowSpeed * 0.9 + 0.15;
383
+
384
+ float snow = 0.0;
385
+ snow += snowLayer(uv, uTime, 18.0, speed * 0.5, wind * 0.6, density, 0.08, 0.18) * 0.6;
386
+ snow += snowLayer(uv, uTime, 28.0, speed * 0.75, wind * 0.9, density * 0.85, 0.06, 0.14) * 0.75;
387
+ snow += snowLayer(uv, uTime, 40.0, speed, wind, density * 0.7, 0.04, 0.1);
388
+
389
+ float heightFade = mix(0.7, 1.0, uv.y);
390
+ snow *= heightFade;
391
+
392
+ vec3 snowColor = vec3(0.92, 0.95, 1.0);
393
+ float alpha = clamp(snow, 0.0, 0.9);
394
+ gl_FragColor = vec4(snowColor * snow, alpha);
413
395
  }
414
- `;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=`
415
397
  precision mediump float;
416
398
  attribute vec2 aPosition;
417
399
  attribute vec2 aUV;
418
400
  varying vec2 vUV;
401
+ uniform mat3 translationMatrix;
402
+ uniform mat3 projectionMatrix;
419
403
  void main() {
420
- vUV = aUV;
421
- gl_Position = vec4(aPosition, 0.0, 1.0);
404
+ vUV = aUV;
405
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
406
+ gl_Position = vec4(world.xy, 0.0, 1.0);
422
407
  }
423
408
  `,t=`
424
409
  precision mediump float;
@@ -426,97 +411,148 @@ fn mainFrag(
426
411
 
427
412
  uniform float uTime;
428
413
  uniform vec2 uResolution;
429
-
430
- uniform float uSpeed; // movement
431
- uniform float uScale; // detail scale
432
- uniform float uDensity; // opacity
433
-
434
- // ------------------- noise -----------------------------------
414
+ uniform float uSpeed;
415
+ uniform float uScale;
416
+ uniform float uDensity;
417
+ uniform float uHeight;
435
418
 
436
419
  float hash(vec2 p) {
437
- return fract(sin(dot(p, vec2(127.1,311.7))) * 43758.5453);
420
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
438
421
  }
439
422
 
440
423
  float noise(vec2 p) {
441
424
  vec2 i = floor(p);
442
425
  vec2 f = fract(p);
443
- vec2 u = f*f*(3.0 - 2.0*f);
444
- return mix(
445
- mix(hash(i + vec2(0.,0.)), hash(i + vec2(1.,0.)), u.x),
446
- mix(hash(i + vec2(0.,1.)), hash(i + vec2(1.,1.)), u.x),
447
- u.y
448
- );
426
+ float a = hash(i);
427
+ float b = hash(i + vec2(1.0, 0.0));
428
+ float c = hash(i + vec2(0.0, 1.0));
429
+ float d = hash(i + vec2(1.0, 1.0));
430
+ vec2 u = f * f * (3.0 - 2.0 * f);
431
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
449
432
  }
450
433
 
451
- float fbm(vec2 p){
452
- float v = 0.0;
453
- float a = 0.5;
454
- for(int i = 0; i < 5; i++){
455
- v += a * noise(p);
456
- p *= 2.0;
457
- a *= 0.5;
458
- }
459
- return v;
434
+ float fbm(vec2 p) {
435
+ float v = 0.0;
436
+ float a = 0.6;
437
+ v += a * noise(p);
438
+ p *= 2.02;
439
+ a *= 0.5;
440
+ v += a * noise(p + 23.7);
441
+ p *= 2.03;
442
+ a *= 0.5;
443
+ v += a * noise(p + 11.3);
444
+ return v;
460
445
  }
461
446
 
462
- // --------------------------------------------------------------
463
-
464
447
  void main() {
448
+ vec2 uv = vUV;
449
+ float aspect = uResolution.x / uResolution.y;
450
+ uv.x *= aspect;
465
451
 
466
- vec2 uv = gl_FragCoord.xy / uResolution.xy;
467
-
468
- float fog = 0.0;
469
-
470
- // -------- multi-layer fog ----------------------
471
-
472
- for(int i = 0; i < 3; i++){
473
- float layer = float(i);
474
-
475
- vec2 p = uv;
476
-
477
- float scale = uScale * (1.0 + layer * 0.6);
478
- float t = uTime * uSpeed * (0.3 + layer * 0.4);
479
-
480
- // drift
481
- p.x += t * 0.2;
482
- p.y += sin(t + p.x * 2.0) * 0.03;
483
-
484
- // extra wave motion
485
- p.x += cos(p.y * 2.5 + t) * 0.03;
486
-
487
- fog += fbm(p * scale) * (1.0 - layer * 0.25);
452
+ float normalizedDensity = uDensity;
453
+ if (normalizedDensity > 4.0) {
454
+ normalizedDensity = normalizedDensity / 100.0;
488
455
  }
456
+ float density = clamp(normalizedDensity, 0.0, 2.0);
489
457
 
490
- // normalize & threshold
491
- fog = smoothstep(0.25, 0.8, fog);
492
-
493
- // -------------- vertical fade (optional) -----------------
494
-
495
- float height = uv.y;
496
- fog *= (1.0 - height * 0.3);
497
-
498
- // -------------- density handling -------------------------
458
+ float scale = max(uScale, 0.3);
459
+ vec2 drift = vec2(uTime * 0.02 * uSpeed, uTime * 0.015 * uSpeed);
460
+ float fogNoise = fbm(uv * scale + drift);
499
461
 
500
- float density = clamp(uDensity, 0.0, 1.0);
462
+ float softness = smoothstep(0.35, 1.0, fogNoise);
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);
501
468
 
502
- // alpha based on fog intensity (soft)
503
- float alpha = fog * density * 0.8;
469
+ float fog = softness * density * 0.45 * heightFactor;
470
+ float alpha = clamp(fog, 0.0, 0.35);
504
471
 
505
- // -------------- fog color -----------------------
472
+ vec3 fogColor = vec3(1.0);
473
+ gl_FragColor = vec4(fogColor * alpha, alpha);
474
+ }
475
+ `;return new P.GlProgram({vertex:h,fragment:t})}function _r(){const h=`
476
+ precision mediump float;
477
+ attribute vec2 aPosition;
478
+ attribute vec2 aUV;
479
+ varying vec2 vUV;
480
+ uniform mat3 translationMatrix;
481
+ uniform mat3 projectionMatrix;
482
+ void main() {
483
+ vUV = aUV;
484
+ vec3 world = projectionMatrix * translationMatrix * vec3(aPosition, 1.0);
485
+ gl_Position = vec4(world.xy, 0.0, 1.0);
486
+ }
487
+ `,t=`
488
+ precision mediump float;
489
+ varying vec2 vUV;
506
490
 
507
- vec3 baseColor = vec3(0.92, 0.94, 0.96);
491
+ uniform float uTime;
492
+ uniform vec2 uResolution;
493
+ uniform float uSpeed;
494
+ uniform float uScale;
495
+ uniform float uDensity;
496
+ uniform float uHeight;
508
497
 
509
- // slight variation
510
- float v = fbm(uv * 2.0 + uTime * 0.1) * 0.05;
498
+ float hash(vec2 p) {
499
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
500
+ }
511
501
 
512
- vec3 color = baseColor + v;
502
+ float noise(vec2 p) {
503
+ vec2 i = floor(p);
504
+ vec2 f = fract(p);
505
+ float a = hash(i);
506
+ float b = hash(i + vec2(1.0, 0.0));
507
+ float c = hash(i + vec2(0.0, 1.0));
508
+ float d = hash(i + vec2(1.0, 1.0));
509
+ vec2 u = f * f * (3.0 - 2.0 * f);
510
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
511
+ }
513
512
 
514
- // modulate brightness by fog value: bright in high density
515
- color *= (0.6 + fog * 0.4);
513
+ float fbm(vec2 p) {
514
+ float v = 0.0;
515
+ float a = 0.7;
516
+ v += a * noise(p);
517
+ p *= 2.1;
518
+ a *= 0.5;
519
+ v += a * noise(p + 17.0);
520
+ p *= 2.2;
521
+ a *= 0.5;
522
+ v += a * noise(p + 29.0);
523
+ return v;
524
+ }
516
525
 
517
- // ---------- result ---------------------------------
526
+ void main() {
527
+ vec2 uv = vUV;
528
+ float aspect = uResolution.x / uResolution.y;
529
+ uv.x *= aspect;
518
530
 
519
- gl_FragColor = vec4(color, alpha);
531
+ float normalizedDensity = uDensity;
532
+ if (normalizedDensity > 4.0) {
533
+ normalizedDensity = normalizedDensity / 100.0;
534
+ }
535
+ float density = clamp(normalizedDensity, 0.0, 2.0);
536
+
537
+ float scale = max(uScale, 0.2);
538
+ vec2 drift = vec2(uTime * 0.03 * uSpeed, uTime * 0.01 * uSpeed);
539
+ float cloudNoise = fbm(uv * scale + drift);
540
+ float detailNoise = fbm(uv * (scale * 2.4) + drift * 1.7);
541
+
542
+ float shape = smoothstep(0.45, 0.95, cloudNoise);
543
+ float detail = smoothstep(0.4, 0.9, detailNoise);
544
+ float puff = shape * (0.6 + 0.4 * detail);
545
+
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);
551
+ float cloud = puff * density * 0.6 * heightFactor;
552
+ float alpha = clamp(cloud, 0.0, 0.55);
553
+
554
+ vec3 cloudColor = vec3(1.0);
555
+ gl_FragColor = vec4(cloudColor * alpha, alpha);
520
556
  }
521
- `;return new O.GlProgram({vertex:h,fragment:t})}const $e=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(.2),scale:g=D.signal(2),resolution:T}=D.useProps(h),E=D.signal([1e3,1e3]),C=T?typeof T=="function"?T:D.signal(T):E;D.mount(ht=>{const Y=ht.props.context;Y?.canvasSize&&t(()=>{const st=Y.canvasSize();st&&st.width>0&&st.height>0&&E.set([st.width,st.height])})});const S=typeof e=="function"?e:D.signal(e),F=typeof i=="function"?i:D.signal(i),M=typeof s=="function"?s:D.signal(s),N=typeof c=="function"?c:D.signal(c),R=typeof a=="function"?a:D.signal(a),_=typeof o=="function"?o:D.signal(o),v=typeof g=="function"?g:D.signal(g);let m,d;if(t()==="rain")m=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:M(),type:"f32"},uRainDensity:{value:N(),type:"f32"},uMaxDrops:{value:R(),type:"f32"}};else if(t()==="snow")m=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:M(),type:"f32"},uSnowDensity:{value:N(),type:"f32"},uMaxFlakes:{value:R(),type:"f32"}};else if(t()==="fog")m=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"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog`);const b=new O.UniformGroup(d),P=new O.Shader({glProgram:m,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 k=Math.random()*10,y=[...C()],V=F(),rt=M(),K=S(),W=N(),lt=R();_();let ot=v();return D.tick(({deltaTime:ht})=>{k+=ht/600,b.uniforms.uTime=k;const Y=C();(Y[0]!==y[0]||Y[1]!==y[1])&&(b.uniforms.uResolution=Y,y=[...Y]);const st=F();if(st!==V&&(b.uniforms.uWindDirection=st,V=st),t()==="rain"||t()==="snow"){const $=M();$!==rt&&(b.uniforms.uWindStrength=$,rt=$)}if(t()==="rain"){const $=S();$!==K&&(b.uniforms.uRainSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uRainDensity=et,W=et);const L=R();L!==lt&&(b.uniforms.uMaxDrops=L,lt=L)}else if(t()==="snow"){const $=S();$!==K&&(b.uniforms.uSnowSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uSnowDensity=et,W=et);const L=R();L!==lt&&(b.uniforms.uMaxFlakes=L,lt=L)}else if(t()==="fog"){const $=S();$!==K&&(b.uniforms.uSpeed=$,K=$);const et=v();et!==ot&&(b.uniforms.uScale=et,ot=et);const L=N();L!==W&&(b.uniforms.uDensity=L,W=L)}}),D.h(D.Mesh,{geometry:U,shader:P,width:"100%",height:"100%"})},ir=$e;return xt.Bar=Je,xt.LightSpot=li,xt.Loading=ui,xt.NightAmbiant=ci,xt.Particle=oi,xt.TiledMap=Ji,xt.Weather=ir,xt.WeatherEffect=$e,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);
522
558
  //# sourceMappingURL=index.global.js.map