@canvasengine/presets 2.0.0-beta.53 → 2.0.0-beta.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Footprints.d.ts +50 -0
- package/dist/Footprints.d.ts.map +1 -0
- package/dist/SpriteShadows.d.ts +60 -0
- package/dist/SpriteShadows.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +41 -20
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3352 -2688
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var CanvasEnginePresets=(function(Et,I,P){"use strict";function _i(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>u[e]})}}return t.default=u,Object.freeze(t)}const At=_i(P);function ae(u){var t=u.toString(16);return t.length==1?"0"+t:t}function yi(u,t,e){return"#"+ae(u)+ae(t)+ae(e)}function gi(u){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:o,border:a,innerMargin:y,borderRadius:C}=I.useProps(u,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return I.h(I.Graphics,{...u,width:t,height:e,draw(S){C()?S.roundRect(0,0,t(),e(),C()):S.rect(0,0,t(),e()),a&&S.stroke(a),S.fill(c())}},I.h(I.Graphics,{width:t,height:e,draw(S){const B=y(),A=C(),D=Math.max(0,Math.min(t()-2*B,i()/s()*(t()-2*B))),F=e()-2*B;C?S.roundRect(B,B,D,F,A):S.rect(B,B,D,F);const R=o();if(R.startsWith("rgba")){const[N,m,x,_]=R.match(/\d+(\.\d+)?/g).map(Number);S.fill({color:yi(N,m,x),alpha:_})}else S.fill(R)}}))}class te{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 Yt{constructor(t){this.data=t}update(t){}dispose(){}}class Oe extends Yt{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 At.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 oe;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip"})(oe||(oe={}));class le{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 H{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 Ht;(function(u){u.Circle="circle",u.Box="box",u.Ring="ring"})(Ht||(Ht={}));class xi extends le{constructor(){super(Ht.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let o=i.rotation;const a=H.float(-s,s),y=H.float(-c,c);o!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+a*Math.cos(o)-y*Math.sin(o),t.component.y=this.__y+this._t*(this.y-this.__y)+a*Math.sin(o)+y*Math.cos(o)):(t.component.x=this.__x+this._t*(this.x-this.__x)+a,t.component.y=this.__y+this._t*(this.y-this.__y)+y),e.radial?(o+=Math.atan2(y,a),t.dx=Math.cos(o),t.dy=Math.sin(o)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=o,this._t+=this._posInterpolationStep}}class wi extends le{constructor(){super(Ht.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=H.float(-e.angle*.5,e.angle*.5)+i.rotation:s=H.float(0,6.28319)+i.rotation,e.radius>0){let c=H.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 le{constructor(){super(Ht.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=H.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 Dt;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip",u[u.Emitter=2]="Emitter",u[u.Trigger=3]="Trigger"})(Dt||(Dt={}));class vi extends At.AnimatedSprite{constructor(t,e,i,s){let c=[],o=e.length;for(let a=0;a<o;a++)c.push(At.Texture.from(e[a]));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 Si{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 Re;(function(u){u.Linear="linear",u.EaseInQuad="easeInQuad",u.EaseOutQuad="easeOutQuad",u.EaseInOutQuad="easeInOutQuad",u.EaseInCubic="easeInCubic",u.EaseOutCubic="easeOutCubic",u.EaseInOutCubic="easeInOutCubic",u.EaseInQuart="easeInQuart",u.EaseOutQuart="easeOutQuart",u.EaseInOutQuart="easeInOutQuart",u.EaseInQuint="easeInQuint",u.EaseOutQuint="easeOutQuint",u.EaseInOutQuint="easeInOutQuint",u.EaseInSine="easeInSine",u.EaseOutSine="easeOutSine",u.EaseInOutSine="easeInOutSine",u.EaseInExpo="easeInExpo",u.EaseOutExpo="easeOutExpo",u.EaseInOutExpo="easeInOutExpo",u.EaseInCirc="easeInCirc",u.EaseOutCirc="easeOutCirc",u.EaseInOutCirc="easeInOutCirc",u.EaseInElastic="easeInElastic",u.EaseOutElastic="easeOutElastic",u.EaseInOutElastic="easeInOutElastic",u.EaseInBack="easeInBack",u.EaseOutBack="easeOutBack",u.EaseInOutBack="easeInOutBack",u.EaseInBounce="easeInBounce",u.EaseOutBounce="easeOutBounce",u.EaseInOutBounce="easeInOutBounce"})(Re||(Re={}));class Mt{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,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s),o||(o=s*.3),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o))+e}static easeOutElastic(t,e,i,s){let c,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s),o||(o=s*.3),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-a)*(2*Math.PI)/o)+i+e}static easeInOutElastic(t,e,i,s){let c,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s/2),o||(o=s*.44999999999999996),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o)*.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=Mt.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=Mt.easeInBounce(t*2,0,i,s),c*.5+e):(c=Mt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class St{constructor(){this.__hasCallback=!1,this._list=new te}add(t,e,i){this._list.add(new Yt(new Pe(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Yt(new Pe(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 o=i.data;o.callRate&&o.calls%o.callRate!=0&&(c=!1),c&&(o.callback.apply(o.scope,t),o.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 Pe{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let Ti=class extends Yt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new St,bounced:new St,updated:new St},this._color=new Si}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const o=this.duration=H.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=H.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-H.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const a=H.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=a*this.dx*i,this.moveSpeedY=a*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const a=this.distance=H.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+a*this.dx-this.startX)*.8,this.deltaY=(s.y+a*this.dy-this.startY)*.8,this.distanceEase=Mt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=H.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=H.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=H.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=Mt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=o*(1-e.fadeInDurationFac),this.fadeInDuration=o*e.fadeInDurationFac,this.fadeInEase=Mt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=Mt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=H.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(H.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=H.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(H.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=Mt[e.scaleXEase],this.scaleYStart=s.scale.y=H.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(H.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=Mt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=o*(1-e.scaleInDurationFac),this.scaleInDuration=o*e.scaleInDurationFac,this.scaleInEase=Mt[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=H.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=H.sign())),e.useTint&&(this.tintEase=Mt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let a=e.childs.length;if(this._hasChildEmitters=a>0,this._childEmitters)for(;--a>-1;){const y=e.childs[a],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 o=t/.0166666;if(s.x+=this.moveSpeedX*o,s.y+=this.moveSpeedY*o,this.moveSpeedY+=this.gravity*o,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 a=this.emitter;a.__on.particleBounced.__hasCallback&&a.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&a.__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 o=this._childEmitters;let a=o.length;for(;--a>-1;){const y=o[a];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 Nt{static sanitizeBundle(t){for(let e of t.emitters){const i=Nt._presetStructure.emitter;Nt.parse(e,i,Nt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Nt._presetStructure.sequence;Nt.parse(e,i,Nt._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 o=e[s];if(!c.hasOwnProperty("length"))Nt.parse(c,o,i);else for(let a of c)for(let y in i)a[y]==null&&(a[y]=i[y])}}}Nt._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 bi extends At.Sprite{constructor(t,e,i,s){super(At.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 Gt(u){if(typeof u!="object"||u===null)return u;const t=Array.isArray(u)?[]:{};for(const e in u){const i=u[e];t[e]=Gt(i)}return t}var Ai=function(u,t,e,i){function s(c){return c instanceof e?c:new e(function(o){o(c)})}return new(e||(e=Promise))(function(c,o){function a(S){try{C(i.next(S))}catch(B){o(B)}}function y(S){try{C(i.throw(S))}catch(B){o(B)}}function C(S){S.done?c(S.value):s(S.value).then(a,y)}C((i=i.apply(u,t||[])).next())})};class Ct{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 te,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,o;for(;c;)o=c.next,c.update(i),c=o;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,o)=>Ai(this,void 0,void 0,function*(){const a={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)a[y]=s[y];At.Assets.addBundle("rfx_assets",a);const C=yield At.Assets.loadBundle("rfx_assets");c(this.initBundle(C.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Ct._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Ct.settingsVersion)throw new Error("Settings version mismatch.");Nt.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 ke(t),s.__fx=this):s=i.pop(),e&&(c=Gt(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,o=this._settingsCache.emitters[t];if(!o)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new ce(t),c.__fx=this):c=s.pop(),i&&(o=Gt(o),o.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(o),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new ce(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 ke(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(At.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 bi(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 vi(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 Ti;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 Ct.__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 At.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Ct._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 o=t;o.values();for(const[a,y]of o)y instanceof At.Texture&&(i[a]=y)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let o in i)if(!(e&&o.indexOf(e)==-1)&&(this.initSprite(o,{texture:o,anchorX:.5,anchorY:.5}),c.sprites.push(o),o.substr(0,3)=="mc_")){const y=o.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(o)}for(let o in s){let a=s[o];c.movieClips.push(o),this.initMovieClip(o,{textures:a,anchorX:.5,anchorY:.5})}return c}}Ct.settingsVersion=0,Ct.version="1.3.4",Ct._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Ct.ComponentType=oe,Ct.EffectSequenceComponentType=Dt,Ct._blendModes=["normal","add","multiply","screen"],Ct.__emitterCores={circle:wi,box:xi,ring:Ei};var Kt;(function(u){u[u.ParticleEmitter=0]="ParticleEmitter",u[u.EffectSequence=1]="EffectSequence"})(Kt||(Kt={}));class ce extends Oe{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new te,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new St,completed:new St,exhausted:new St,particleUpdated:new St,particleSpawned:new St,particleBounced:new St,particleDied:new St}}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],o=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),a=i.__containers[o.settings.containerId]||this.container;o.init(a,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(o.rotation=this._rotation,o.__adoptRotation=!0),o.__parent=this,this._childEmitters.push(o)}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+H.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,o;for(;c;)o=c.next,c.update(t),c=o;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=H.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 o;switch(s.componentType){case 0:c.componentId=s.componentId,o=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,o=e.__getMovieClip(c.componentId),s.componentParams&&(o.loop=!(s.componentParams.loop==null||!s.componentParams.loop),o.animationSpeed=H.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),o.gotoAndPlay(0);break}o.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=o,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=H.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 o,a;switch(c.type){case 0:o=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),a=i.__containers[o.settings.containerId]||this.container,o.init(a,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(o.rotation=t.component.rotation+o.settings.rotation,o.__adoptRotation=!0):o.rotation=o.settings.rotation;break;case 1:o=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),a=i.__containers[o.settings.containerId]||this.container,o.init(a,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(o.rotation=t.component.rotation);break}o.x=t.component.x,o.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 o=i[c];for(const a of o){switch(a.type){case Kt.ParticleEmitter:a.settings=Gt(e.__getEmitterSettings(a.id));break;case Kt.EffectSequence:a.settings=Gt(e.__getSequenceSettings(a.id));break}a.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Kt.ParticleEmitter:c.settings=Gt(e.__getEmitterSettings(c.id));break;case Kt.EffectSequence:c.settings=Gt(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 ke extends Oe{constructor(t){super(t),this._list=[],this._elements=new te,this.__on={started:new St,completed:new St,exhausted:new St,effectSpawned:new St,triggerActivated:new St}}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,o=this._nextEffectSettings;let a,y,C;switch(o.componentType){case Dt.Sprite:a=c.__getSprite(o.componentId),C=c.__containers[o.containerId]||this.container,C.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=H.float(o.alphaMin,o.alphaMax),a.anchor.set(o.componentParams.anchorX,o.componentParams.anchorY),y=new Yt({component:a,endTime:e+o.duration*1e3}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+H.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.Sprite,a);break;case Dt.MovieClip:a=c.__getMovieClip(o.componentId),o.componentParams.loop?(a.animationSpeed=H.float(o.componentParams.animationSpeedMin||1,o.componentParams.animationSpeedMax||1),a.loop=o.componentParams.loop||!1):o.duration,a.anchor.set(o.componentParams.anchorX,o.componentParams.anchorY),a.gotoAndPlay(0),C=c.__containers[o.containerId]||this.container,C.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=H.float(o.alphaMin,o.alphaMax),y=new Yt({component:a,endTime:e+o.duration*1e3}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+H.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.MovieClip,a);break;case Dt.Emitter:a=c.getParticleEmitterById(o.componentId),C=c.__containers[o.containerId]||this.container,a.init(C,!0,H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Yt({component:a,endTime:a.endTime}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+a.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.Emitter,a);break;case Dt.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(o.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 ce?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 Ci(u){const{emit:t,settings:e={}}=u,{name:i}=I.useProps(u),s=new Ct;let c;return At.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),At.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),I.tick(({deltaRatio:o})=>{s.update(o)}),I.mount(async o=>{c=o;let y={...(await At.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const S=e.emitters.map((B,A)=>({...B,id:1e4+A}));y.emitters=[...y.emitters,...S]}s.initBundle(y,!0)}),I.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),I.h(I.Container)}const Mi=`/**
|
|
1
|
+
var CanvasEnginePresets=(function(Ct,D,L){"use strict";function zi(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const Ot=zi(L);function xe(n){var t=n.toString(16);return t.length==1?"0"+t:t}function Gi(n,t,e){return"#"+xe(n)+xe(t)+xe(e)}function ji(n){const{width:t,height:e,value:i,maxValue:r,backgroundColor:l,foregroundColor:c,border:a,innerMargin:g,borderRadius:S}=D.useProps(n,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...n,width:t,height:e,draw(w){S()?w.roundRect(0,0,t(),e(),S()):w.rect(0,0,t(),e()),a&&w.stroke(a),w.fill(l())}},D.h(D.Graphics,{width:t,height:e,draw(w){const C=g(),M=S(),N=Math.max(0,Math.min(t()-2*C,i()/r()*(t()-2*C))),F=e()-2*C;S?w.roundRect(C,C,N,F,M):w.rect(C,C,N,F);const k=c();if(k.startsWith("rgba")){const[R,m,x,y]=k.match(/\d+(\.\d+)?/g).map(Number);w.fill({color:Gi(R,m,x),alpha:y})}else w.fill(k)}}))}class he{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 Xt{constructor(t){this.data=t}update(t){}dispose(){}}class Xe extends Xt{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 Ot.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 we;(function(n){n[n.Sprite=0]="Sprite",n[n.MovieClip=1]="MovieClip"})(we||(we={}));class Ee{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 st{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 re;(function(n){n.Circle="circle",n.Box="box",n.Ring="ring"})(re||(re={}));class Ki extends Ee{constructor(){super(re.Box)}emit(t){const e=this._settings,i=this.emitter,r=e.width*.5*this.__scaleMod,l=e.height*.5*this.__scaleMod;let c=i.rotation;const a=st.float(-r,r),g=st.float(-l,l);c!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+a*Math.cos(c)-g*Math.sin(c),t.component.y=this.__y+this._t*(this.y-this.__y)+a*Math.sin(c)+g*Math.cos(c)):(t.component.x=this.__x+this._t*(this.x-this.__x)+a,t.component.y=this.__y+this._t*(this.y-this.__y)+g),e.radial?(c+=Math.atan2(g,a),t.dx=Math.cos(c),t.dy=Math.sin(c)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=c,this._t+=this._posInterpolationStep}}class qi extends Ee{constructor(){super(re.Circle)}emit(t){const e=this._settings,i=this.emitter;let r;if(e.angle?r=st.float(-e.angle*.5,e.angle*.5)+i.rotation:r=st.float(0,6.28319)+i.rotation,e.radius>0){let l=st.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(r)*l,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(r)*l}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(r),t.dy=Math.sin(r),t.component.rotation=r):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class Wi extends Ee{constructor(){super(re.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 r;e.uniform?(r=this._angle+i.rotation,this._angle+=this._uniformStep):r=st.float(-e.angle*.5,e.angle*.5)+i.rotation;const l=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(r)*l,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(r)*l,e.radial?(t.dx=Math.cos(r),t.dy=Math.sin(r),t.component.rotation=r):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var zt;(function(n){n[n.Sprite=0]="Sprite",n[n.MovieClip=1]="MovieClip",n[n.Emitter=2]="Emitter",n[n.Trigger=3]="Trigger"})(zt||(zt={}));class $i extends Ot.AnimatedSprite{constructor(t,e,i,r){let l=[],c=e.length;for(let a=0;a<c;a++)l.push(Ot.Texture.from(e[a]));super(l),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 Hi{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 Qe;(function(n){n.Linear="linear",n.EaseInQuad="easeInQuad",n.EaseOutQuad="easeOutQuad",n.EaseInOutQuad="easeInOutQuad",n.EaseInCubic="easeInCubic",n.EaseOutCubic="easeOutCubic",n.EaseInOutCubic="easeInOutCubic",n.EaseInQuart="easeInQuart",n.EaseOutQuart="easeOutQuart",n.EaseInOutQuart="easeInOutQuart",n.EaseInQuint="easeInQuint",n.EaseOutQuint="easeOutQuint",n.EaseInOutQuint="easeInOutQuint",n.EaseInSine="easeInSine",n.EaseOutSine="easeOutSine",n.EaseInOutSine="easeInOutSine",n.EaseInExpo="easeInExpo",n.EaseOutExpo="easeOutExpo",n.EaseInOutExpo="easeInOutExpo",n.EaseInCirc="easeInCirc",n.EaseOutCirc="easeOutCirc",n.EaseInOutCirc="easeInOutCirc",n.EaseInElastic="easeInElastic",n.EaseOutElastic="easeOutElastic",n.EaseInOutElastic="easeInOutElastic",n.EaseInBack="easeInBack",n.EaseOutBack="easeOutBack",n.EaseInOutBack="easeInOutBack",n.EaseInBounce="easeInBounce",n.EaseOutBounce="easeOutBounce",n.EaseInOutBounce="easeInOutBounce"})(Qe||(Qe={}));class Pt{static linear(t,e,i,r){return i*t/r+e}static easeInQuad(t,e,i,r){return i*(t/=r)*t+e}static easeOutQuad(t,e,i,r){return-i*(t/=r)*(t-2)+e}static easeInOutQuad(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,r){return i*(t/=r)*t*t+e}static easeOutCubic(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e}static easeInOutCubic(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,r){return i*(t/=r)*t*t*t+e}static easeOutQuart(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,r){return i*(t/=r)*t*t*t*t+e}static easeOutQuint(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,r){return(t/=r/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,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}static easeOutSine(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e}static easeInOutSine(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e}static easeInExpo(t,e,i,r){return t===0?e:i*Math.pow(2,10*(t/r-1))+e}static easeOutExpo(t,e,i,r){return t===r?e+i:i*(-Math.pow(2,-10*t/r)+1)+e}static easeInOutExpo(t,e,i,r){return(t/=r/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,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e}static easeOutCirc(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e}static easeInOutCirc(t,e,i,r){return(t/=r/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,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r),c||(c=r*.3),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),-(l*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c))+e}static easeOutElastic(t,e,i,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r),c||(c=r*.3),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),l*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/c)+i+e}static easeInOutElastic(t,e,i,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r/2),c||(c=r*.44999999999999996),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),t<1?-.5*(l*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c))+e:l*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c)*.5+i+e}static easeInBack(t,e,i,r,l){return l===void 0&&(l=1.70158),i*(t/=r)*t*((l+1)*t-l)+e}static easeOutBack(t,e,i,r,l){return l===void 0&&(l=1.70158),i*((t=t/r-1)*t*((l+1)*t+l)+1)+e}static easeInOutBack(t,e,i,r,l){return l===void 0&&(l=1.70158),(t/=r/2)<1?i/2*(t*t*(((l*=1.525)+1)*t-l))+e:i/2*((t-=2)*t*(((l*=1.525)+1)*t+l)+2)+e}static easeInBounce(t,e,i,r){let l;return l=Pt.easeOutBounce(r-t,0,i,r),i-l+e}static easeOutBounce(t,e,i,r){return(t/=r)<.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,r){let l;return t<r/2?(l=Pt.easeInBounce(t*2,0,i,r),l*.5+e):(l=Pt.easeOutBounce(t*2-r,0,i,r),l*.5+i*.5+e)}}class It{constructor(){this.__hasCallback=!1,this._list=new he}add(t,e,i){this._list.add(new Xt(new Ze(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Xt(new Ze(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,r;for(;i;){r=i.next;let l=!0;const c=i.data;c.callRate&&c.calls%c.callRate!=0&&(l=!1),l&&(c.callback.apply(c.scope,t),c.once&&e.remove(i)),i=r}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,r;for(;i;){if(r=i.next,i.data.callback===t){e.remove(i);return}i=r}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Ze{constructor(t,e,i,r){this.callback=t,this.scope=e,this.once=i,this.callRate=r,this.calls=0}}let Xi=class extends Xt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new It,bounced:new It,updated:new It},this._color=new Hi}init(t,e,i){const r=this.component,l=this.__fx;this.emitter=t,this.settings=e;const c=this.duration=st.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(r):t.container.addChildAt(r,0),r.blendMode=l.__getBlendMode(e.blendMode),this.startX=r.x,this.startY=r.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=st.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-st.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const a=st.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=a*this.dx*i,this.moveSpeedY=a*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const a=this.distance=st.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(r.x+a*this.dx-this.startX)*.8,this.deltaY=(r.y+a*this.dy-this.startY)*.8,this.distanceEase=Pt[e.distanceEase],this.useAlign=!1}else r.x=this.startX,r.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(r.rotation=st.float(0,6.28319)),e.useAlpha&&(this.alphaStart=r.alpha=st.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=st.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=Pt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=c*(1-e.fadeInDurationFac),this.fadeInDuration=c*e.fadeInDurationFac,this.fadeInEase=Pt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=Pt[e.scaleEase],e.uniformScale?(this.scaleStart=r.scale.x=r.scale.y=st.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(st.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=r.scale.x=st.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(st.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=Pt[e.scaleXEase],this.scaleYStart=r.scale.y=st.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(st.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=Pt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=c*(1-e.scaleInDurationFac),this.scaleInDuration=c*e.scaleInDurationFac,this.scaleInEase=Pt[e.scaleInEase||"easeInSine"])):e.uniformScale?(r.scale.x=e.scaleStartMin,r.scale.y=e.scaleStartMin):(r.scale.x=e.scaleXStartMin,r.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=st.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=st.sign())),e.useTint&&(this.tintEase=Pt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let a=e.childs.length;if(this._hasChildEmitters=a>0,this._childEmitters)for(;--a>-1;){const g=e.childs[a],S=l.getParticleEmitterById(g.id);S.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(S.rotation=r.rotation,S.__adoptRotation=!0),S.__parent=this,this._childEmitters.push(S)}}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 r=this.component,l=e*t;if(this.useGravity){const c=t/.0166666;if(r.x+=this.moveSpeedX*c,r.y+=this.moveSpeedY*c,this.moveSpeedY+=this.gravity*c,this.useAlign&&(r.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&r.y>this.floorY){r.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const a=this.emitter;a.__on.particleBounced.__hasCallback&&a.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&a.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(r.x=this.distanceEase(e,this.startX,this.deltaX,i),r.y=this.distanceEase(e,this.startY,this.deltaY,i)):(r.x=this.deltaX*l+this.startX,r.y=this.deltaY*l+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?r.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):r.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?r.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):r.alpha=this.alphaDelta*l+this.alphaStart),this.useRotation&&(r.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?r.scale.x=r.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):r.scale.x=r.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(r.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),r.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):r.scale.x=r.scale.y=this.scaleDelta*l+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(r.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),r.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(r.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),r.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?r.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):r.scale.x=this.scaleXDelta*l+this.scaleXStart,this.scaleYEase?r.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):r.scale.y=this.scaleYDelta*l+this.scaleYStart)),this.useTint&&(r.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 c=this._childEmitters;let a=c.length;for(;--a>-1;){const g=c[a];g.__recycled||(g.x=r.position.x,g.y=r.position.y,g.__adoptRotation&&(g.rotation=r.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 Gt{static sanitizeBundle(t){for(let e of t.emitters){const i=Gt._presetStructure.emitter;Gt.parse(e,i,Gt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Gt._presetStructure.sequence;Gt.parse(e,i,Gt._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let r in e)if(t[r]==null)t[r]=e[r];else{const l=t[r];if(typeof l!="object")continue;const c=e[r];if(!l.hasOwnProperty("length"))Gt.parse(l,c,i);else for(let a of l)for(let g in i)a[g]==null&&(a[g]=i[g])}}}Gt._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 Qi extends Ot.Sprite{constructor(t,e,i,r){super(Ot.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,r||.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 Qt(n){if(typeof n!="object"||n===null)return n;const t=Array.isArray(n)?[]:{};for(const e in n){const i=n[e];t[e]=Qt(i)}return t}var Zi=function(n,t,e,i){function r(l){return l instanceof e?l:new e(function(c){c(l)})}return new(e||(e=Promise))(function(l,c){function a(w){try{S(i.next(w))}catch(C){c(C)}}function g(w){try{S(i.throw(w))}catch(C){c(C)}}function S(w){w.done?l(w.value):r(w.value).then(a,g)}S((i=i.apply(n,t||[])).next())})};class Rt{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 he,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 l=this._effects.first,c;for(;l;)c=l.next,l.update(i),l=c;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="",r=[]){return new Promise((l,c)=>Zi(this,void 0,void 0,function*(){const a={rfx_spritesheet:e,rfx_bundleSettings:t};for(var g in r)a[g]=r[g];Ot.Assets.addBundle("rfx_assets",a);const S=yield Ot.Assets.loadBundle("rfx_assets");l(this.initBundle(S.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Rt._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Rt.settingsVersion)throw new Error("Settings version mismatch.");Gt.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const r=t.emitters[i];this.addParticleEmitter(r.id,r)}for(let i in t.sequences){const r=t.sequences[i];this.addEffectSequence(r.id,r)}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 r,l=this._settingsCache.effectSequences[t];if(!l)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(r=new Je(t),r.__fx=this):r=i.pop(),e&&(l=Qt(l),l.__isClone=!0),r.__applySettings(l),r}getParticleEmitter(t,e=!0,i=!1){const r=this._nameMaps.emitters[t];if(!r)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(r.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const r=this._cache.emitters;let l,c=this._settingsCache.emitters[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return r.length==0?(l=new ve(t),l.__fx=this):l=r.pop(),i&&(c=Qt(c),c.__isClone=!0),l.autoRecycleOnComplete=e,l.__applySettings(c),l}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let r;return i.length==0?(r=new ve(t.id),r.__fx=this):r=i.pop(),r.autoRecycleOnComplete=e,r.__applySettings(t),r}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Je(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(Ot.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 r=this._settingsCache.sprites[t];if(r==null)throw new Error(`Settings not defined for '${t}'`);const l=new Qi(t,r.texture,r.anchorX,r.anchorY);return l.__fx=this,l}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 r=this._settingsCache.mcs[t];if(r==null)throw new Error(`Settings not defined for '${t}'`);const l=new $i(t,r.textures,r.anchorX,r.anchorY);return l.__fx=this,l}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new Xi;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,r=i[t];return r==null&&(r=i[t]=[]),r.length==0?new Rt.__emitterCores[t](t):r.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 Ot.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Rt._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 c=t;c.values();for(const[a,g]of c)g instanceof Ot.Texture&&(i[a]=g)}else i=t;const r={},l={sprites:[],movieClips:[]};for(let c in i)if(!(e&&c.indexOf(e)==-1)&&(this.initSprite(c,{texture:c,anchorX:.5,anchorY:.5}),l.sprites.push(c),c.substr(0,3)=="mc_")){const g=c.split("_")[1];r[g]==null&&(r[g]=[]),r[g].push(c)}for(let c in r){let a=r[c];l.movieClips.push(c),this.initMovieClip(c,{textures:a,anchorX:.5,anchorY:.5})}return l}}Rt.settingsVersion=0,Rt.version="1.3.4",Rt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Rt.ComponentType=we,Rt.EffectSequenceComponentType=zt,Rt._blendModes=["normal","add","multiply","screen"],Rt.__emitterCores={circle:qi,box:Ki,ring:Wi};var te;(function(n){n[n.ParticleEmitter=0]="ParticleEmitter",n[n.EffectSequence=1]="EffectSequence"})(te||(te={}));class ve extends Xe{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new he,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new It,completed:new It,exhausted:new It,particleUpdated:new It,particleSpawned:new It,particleBounced:new It,particleDied:new It}}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 r=e.childs.length;if(this._hasChildEmitters=r>0,this._hasChildEmitters)for(;--r>-1;){const l=e.childs[r],c=this.settings.__isClone?i.createParticleEmitterFrom(l.settings):i.getParticleEmitterById(l.id),a=i.__containers[c.settings.containerId]||this.container;c.init(a,!0,(l.scale||1)*(this._scaleMod||1)),l.adoptRotation&&(c.rotation=this._rotation,c.__adoptRotation=!0),c.__parent=this,this._childEmitters.push(c)}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+st.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let l=this._particles.first,c;for(;l;)c=l.next,l.update(t),l=c;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=st.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 r=t.particleSettings,l=e.__getParticle();let c;switch(r.componentType){case 0:l.componentId=r.componentId,c=e.__getSprite(l.componentId);break;case 1:l.componentId=r.componentId,c=e.__getMovieClip(l.componentId),r.componentParams&&(c.loop=!(r.componentParams.loop==null||!r.componentParams.loop),c.animationSpeed=st.float(r.componentParams.animationSpeedMin||1,r.componentParams.animationSpeedMax||1)),c.gotoAndPlay(0);break}c.anchor.set(r.componentParams.anchorX,r.componentParams.anchorY),l.component=c,this.core.emit(l),l.init(this,r,this._scaleMod),this._particles.add(l),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=st.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 r=this.__on;r.completed.removeAll(),r.started.removeAll(),r.exhausted.removeAll(),r.particleBounced.removeAll(),r.particleDied.removeAll(),r.particleSpawned.removeAll(),r.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 r=e[i];r.__adoptRotation&&(r.rotation=r.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 r=e.length;for(;--r>-1;){const l=e[r];let c,a;switch(l.type){case 0:c=this.settings.__isClone?i.createParticleEmitterFrom(l.settings):i.getParticleEmitterById(l.id),a=i.__containers[c.settings.containerId]||this.container,c.init(a,!0,(l.scale||1)*this._scaleMod),l.adoptRotation?(c.rotation=t.component.rotation+c.settings.rotation,c.__adoptRotation=!0):c.rotation=c.settings.rotation;break;case 1:c=this.settings.__isClone?i.createEffectSequenceEmitterFrom(l.settings):i.getEffectSequenceById(l.id),a=i.__containers[c.settings.containerId]||this.container,c.init(a,0,!0,(l.scale||1)*this._scaleMod),l.adoptRotation&&(c.rotation=t.component.rotation);break}c.x=t.component.x,c.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 l in i){const c=i[l];for(const a of c){switch(a.type){case te.ParticleEmitter:a.settings=Qt(e.__getEmitterSettings(a.id));break;case te.EffectSequence:a.settings=Qt(e.__getSequenceSettings(a.id));break}a.settings.__isClone=!0}}const r=t.childs;for(const l of r){switch(l.type){case te.ParticleEmitter:l.settings=Qt(e.__getEmitterSettings(l.id));break;case te.EffectSequence:l.settings=Qt(e.__getSequenceSettings(l.id));break}l.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 Je extends Xe{constructor(t){super(t),this._list=[],this._elements=new he,this.__on={started:new It,completed:new It,exhausted:new It,effectSpawned:new It,triggerActivated:new It}}init(t,e=0,i=!0,r=1){return this.container=t,this._scaleMod=r,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 l=this.__fx,c=this._nextEffectSettings;let a,g,S;switch(c.componentType){case zt.Sprite:a=l.__getSprite(c.componentId),S=l.__containers[c.containerId]||this.container,S.addChild(a),a.blendMode=l.__getBlendMode(c.blendMode),a.tint=c.tint,a.scale.set(st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=st.float(c.alphaMin,c.alphaMax),a.anchor.set(c.componentParams.anchorX,c.componentParams.anchorY),g=new Xt({component:a,endTime:e+c.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+st.float(c.rotationMin,c.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.Sprite,a);break;case zt.MovieClip:a=l.__getMovieClip(c.componentId),c.componentParams.loop?(a.animationSpeed=st.float(c.componentParams.animationSpeedMin||1,c.componentParams.animationSpeedMax||1),a.loop=c.componentParams.loop||!1):c.duration,a.anchor.set(c.componentParams.anchorX,c.componentParams.anchorY),a.gotoAndPlay(0),S=l.__containers[c.containerId]||this.container,S.addChild(a),a.blendMode=l.__getBlendMode(c.blendMode),a.tint=c.tint,a.scale.set(st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=st.float(c.alphaMin,c.alphaMax),g=new Xt({component:a,endTime:e+c.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+st.float(c.rotationMin,c.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.MovieClip,a);break;case zt.Emitter:a=l.getParticleEmitterById(c.componentId),S=l.__containers[c.containerId]||this.container,a.init(S,!0,st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),g=new Xt({component:a,endTime:a.endTime}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+a.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.Emitter,a);break;case zt.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(c.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 r=i.first;for(;r;){if(r.update(t),e>r.data.endTime){const l=r.data.component;l instanceof ve?l.completed&&i.remove(r):(i.remove(r),l.recycle())}r=r.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 r=this.__on;r.completed.__hasCallback&&r.completed.removeAll(),r.started.__hasCallback&&r.started.removeAll(),r.exhausted.__hasCallback&&r.exhausted.removeAll(),r.effectSpawned.__hasCallback&&r.effectSpawned.removeAll(),r.triggerActivated.__hasCallback&&r.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,r;for(;i;)r=i.next,i.data.rotation=t,i=r}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,r;for(;i;)r=i.next,i.data.x=t,i=r}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,r;for(;i;)r=i.next,i.data.y=t,i=r}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 Ji(n){const{emit:t,settings:e={}}=n,{name:i}=D.useProps(n),r=new Rt;let l;return Ot.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),Ot.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:c})=>{r.update(c)}),D.mount(async c=>{l=c;let g={...(await Ot.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const w=e.emitters.map((C,M)=>({...C,id:1e4+M}));g.emitters=[...g.emitters,...w]}r.initBundle(g,!0)}),D.on(t,()=>{r.getParticleEmitter(i()).init(l.componentInstance)}),D.h(D.Container)}const tr=`/**
|
|
2
2
|
* Night + spot light + fog fragment shader.
|
|
3
3
|
* - Supports multiple circular spots (uSpots) in screen-pixel space.
|
|
4
4
|
* - Each spot is vec4(xPx, yPx, radiusPx, intensity).
|
|
@@ -57,7 +57,7 @@ void main() {
|
|
|
57
57
|
|
|
58
58
|
finalColor = color;
|
|
59
59
|
}
|
|
60
|
-
`,
|
|
60
|
+
`,ti=`/**
|
|
61
61
|
* Default Pixi filter vertex shader.
|
|
62
62
|
* Outputs vTextureCoord (0-1) for sampling the input texture in fragment shader.
|
|
63
63
|
*/
|
|
@@ -83,19 +83,19 @@ void main(void) {
|
|
|
83
83
|
gl_Position = filterVertexPosition();
|
|
84
84
|
vTextureCoord = filterTextureCoord();
|
|
85
85
|
}
|
|
86
|
-
`,ue=24,Bi=180,Ii=.75,Di=.5,Ni=.35,Oi=new Float32Array([.08,.08,.14]),ee=u=>{if(typeof u=="string"){let t=u.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 u=="number")return new Float32Array([(u>>16&255)/255,(u>>8&255)/255,(u&255)/255]);if(Array.isArray(u)&&u.length>=3){const t=u.every(e=>e<=1);return new Float32Array(t?u:u.map(e=>e/255))}return new Float32Array([0,0,0])};function Ue(u,t){const e=new Float32Array(ue*4),i={value:e,type:"vec4<f32>",size:ue},s={value:t?.darkness??Ii,type:"f32"},c={value:t?.fogColor?ee(t.fogColor):Oi,type:"vec3<f32>"},o={value:t?.fogRadius??Di,type:"f32"},a={value:t?.fogSoftness??Ni,type:"f32"},y={value:t?.darkColor?ee(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let C=t?.spots?[...t.spots]:[],S=t?.lightWorldPosition??null;const B=P.Filter.from({gl:{vertex:Fi,fragment:Mi},resources:{nightUniforms:{uSpots:i,uDarkness:s,uDarkColor:y,uFogColor:c,uFogRadius:o,uFogSoftness:a}}}),A=(x,_,f)=>Math.min(Math.max(x,_),f),D=()=>Date.now()/1e3,F=()=>S?[{x:S.x,y:S.y},...C]:C,R=()=>{const x=F(),_=Math.min(x.length,ue),f=u?.getVisibleBounds?.()??t?.getBounds?.(),b=!!f&&f.width>0&&f.height>0,O=u?.toScreen?.bind(u),k=b&&typeof O=="function";let L=0,g=0;if(k){const Y=O(f.x,f.y);_t(Y?.x)&&_t(Y?.y)&&(L=Y.x,g=Y.y)}const q=D();e.fill(0);for(let Y=0;Y<_;Y++){const G=x[Y],st=G.radius??Bi,ft=A(G.intensity??1,0,2),at=G.phase??Y*.7;let ot=ft;if(G.flicker){const W=G.flickerSpeed??12;ot*=.88+.12*Math.sin(q*W+at)}if(G.pulse){const W=G.pulseSpeed??2;ot*=.8+.2*Math.sin(q*W+at)}let K=G.x,gt=G.y,xt=st;if(k){const W=O(G.x,G.y);K=W.x-L,gt=W.y-g}else b&&(K=G.x-f.x,gt=G.y-f.y);const mt=Y*4;e[mt]=K,e[mt+1]=gt,e[mt+2]=xt,e[mt+3]=A(ot,0,2)}i.value=e},N=B.apply.bind(B);B.apply=((...x)=>(R(),N(...x)));const m=B;return m.setLightWorldPosition=x=>{S=x,R()},m.getLightWorldPosition=()=>S,m.setSpots=x=>{C=[...x],R()},m.getSpots=()=>F().map(x=>({...x})),m.syncLightToViewport=R,m.setDarkness=x=>{s.value=x},m.setDarkColor=x=>{y.value=ee(x)},m.setFogColor=x=>{c.value=ee(x)},m.setFogRadius=x=>{o.value=x},m.setFogSoftness=x=>{a.value=x},R(),m}const pt=u=>typeof u=="function"?u():u,_t=u=>typeof u=="number"&&Number.isFinite(u),Ri=u=>{const t=pt(u);if(!t)return null;const e=pt(t.x),i=pt(t.y);if(!_t(e)||!_t(i))return null;const s=pt(t.radius),c=pt(t.intensity),o=pt(t.flickerSpeed),a=pt(t.pulseSpeed),y=pt(t.phase);return{x:e,y:i,radius:_t(s)?s:void 0,intensity:_t(c)?c:void 0,flicker:!!pt(t.flicker),flickerSpeed:_t(o)?o:void 0,pulse:!!pt(t.pulse),pulseSpeed:_t(a)?a:void 0,phase:_t(y)?y:void 0}},Le=u=>{const t=pt(u);return Array.isArray(t)?t.map(Ri).filter(e=>!!e):[]},Pi=u=>{if(!u)return null;if(typeof u.getVisibleBounds=="function"){const t=u.getVisibleBounds();if(t)return t}if(typeof u.getLocalBounds=="function"){const t=u.getLocalBounds();if(t)return t}return _t(u.width)&&_t(u.height)?{x:0,y:0,width:u.width,height:u.height}:null};function ki(u={}){const t=I.useProps(u),e=()=>t.lightSpots??t.spots;return I.mount(i=>{const s=i.props.context,c=s?.viewport,o=c??i.parent?.componentInstance;if(!o)return;const a=s?.canvasSize,y=()=>{if(!c&&typeof a=="function"){const N=a();if(N&&_t(N.width)&&_t(N.height)&&N.width>0&&N.height>0)return{x:0,y:0,width:N.width,height:N.height}}return Pi(o)},C=pt(t.darkness),S=pt(t.darkColor),B=pt(t.fogColor),A=pt(t.fogRadius),D=pt(t.fogSoftness),F=Ue(c,{spots:Le(e()),getBounds:y,darkness:_t(C)?C:void 0,darkColor:S??void 0,fogColor:B??void 0,fogRadius:_t(A)?A:void 0,fogSoftness:_t(D)?D:void 0}),R=Array.isArray(o.filters)?o.filters:[];return R.includes(F)||(o.filters=[...R,F]),I.effect(()=>{F.setSpots(Le(e()))}),I.effect(()=>{const N=pt(t.darkness);_t(N)&&F.setDarkness(N)}),I.effect(()=>{const N=pt(t.darkColor);N!==void 0&&F.setDarkColor(N)}),I.effect(()=>{const N=pt(t.fogColor);N!==void 0&&F.setFogColor(N)}),I.effect(()=>{const N=pt(t.fogRadius);_t(N)&&F.setFogRadius(N)}),I.effect(()=>{const N=pt(t.fogSoftness);_t(N)&&F.setFogSoftness(N)}),()=>{const m=(Array.isArray(o.filters)?o.filters:[]).filter(x=>x!==F);o.filters=m.length>0?m:null}}),I.h(I.Container)}function Ui(u={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:o=3,inactiveAlpha:a=.15}=I.useProps(u,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),y=I.signal(0);I.tick(({deltaTime:F})=>{const N=(typeof s=="function"?s():s)*F/1e3;y.set(y()+N)});const C=F=>{const R=typeof t=="function"?t():t,N=typeof e=="function"?e():e,m=i?typeof i=="function"?i():i:null,x=typeof c=="function"?c():c;typeof o=="function"&&o();const _=typeof a=="function"?a():a,f=y();m&&F.circle(0,0,R).fill(m);const b=360/x,O=R*.4,k=R;for(let L=0;L<x;L++){const g=L*b,q=(f%360+360)%360;let Y=Math.abs(q-g);Y>180&&(Y=360-Y);let st=Y/120;st=Math.min(1,st),st=st*st*st;const ft=_+(1-st)*(1-_),at=g*(Math.PI/180),ot=b*(Math.PI/180),K=at-ot/2,gt=at+ot/2;F.arc(0,0,O,K,gt).arc(0,0,k,gt,K,!0).fill({color:N,alpha:ft})}},B=(typeof t=="function"?t():t)*2,A=I.signal(B),D=I.signal(B);return typeof t=="function"&&I.effect(()=>{const F=t();A.set(F*2),D.set(F*2)}),I.h(I.Container,u,[I.h(I.Graphics,{draw:C})])}var qt=(u=>(u.Tile="tilelayer",u.ObjectGroup="objectgroup",u.Image="imagelayer",u.Group="group",u))(qt||{});function Ve(...u){return u.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function Li(u){if(Object.prototype.hasOwnProperty.call(u,"__esModule"))return u;var t=u.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(u).forEach(function(i){var s=Object.getOwnPropertyDescriptor(u,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return u[i]}})}),e}var he={};const Vi=Li(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var fe={},ie={exports:{}},de={},Xt={},Ye;function Yi(){if(Ye)return Xt;Ye=1,Xt.byteLength=a,Xt.toByteArray=C,Xt.fromByteArray=A;for(var u=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)u[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(D){var F=D.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var R=D.indexOf("=");R===-1&&(R=F);var N=R===F?0:4-R%4;return[R,N]}function a(D){var F=o(D),R=F[0],N=F[1];return(R+N)*3/4-N}function y(D,F,R){return(F+R)*3/4-R}function C(D){var F,R=o(D),N=R[0],m=R[1],x=new e(y(D,N,m)),_=0,f=m>0?N-4:N,b;for(b=0;b<f;b+=4)F=t[D.charCodeAt(b)]<<18|t[D.charCodeAt(b+1)]<<12|t[D.charCodeAt(b+2)]<<6|t[D.charCodeAt(b+3)],x[_++]=F>>16&255,x[_++]=F>>8&255,x[_++]=F&255;return m===2&&(F=t[D.charCodeAt(b)]<<2|t[D.charCodeAt(b+1)]>>4,x[_++]=F&255),m===1&&(F=t[D.charCodeAt(b)]<<10|t[D.charCodeAt(b+1)]<<4|t[D.charCodeAt(b+2)]>>2,x[_++]=F>>8&255,x[_++]=F&255),x}function S(D){return u[D>>18&63]+u[D>>12&63]+u[D>>6&63]+u[D&63]}function B(D,F,R){for(var N,m=[],x=F;x<R;x+=3)N=(D[x]<<16&16711680)+(D[x+1]<<8&65280)+(D[x+2]&255),m.push(S(N));return m.join("")}function A(D){for(var F,R=D.length,N=R%3,m=[],x=16383,_=0,f=R-N;_<f;_+=x)m.push(B(D,_,_+x>f?f:_+x));return N===1?(F=D[R-1],m.push(u[F>>2]+u[F<<4&63]+"==")):N===2&&(F=(D[R-2]<<8)+D[R-1],m.push(u[F>>10]+u[F>>4&63]+u[F<<2&63]+"=")),m.join("")}return Xt}var re={};var Ge;function Gi(){return Ge||(Ge=1,re.read=function(u,t,e,i,s){var c,o,a=s*8-i-1,y=(1<<a)-1,C=y>>1,S=-7,B=e?s-1:0,A=e?-1:1,D=u[t+B];for(B+=A,c=D&(1<<-S)-1,D>>=-S,S+=a;S>0;c=c*256+u[t+B],B+=A,S-=8);for(o=c&(1<<-S)-1,c>>=-S,S+=i;S>0;o=o*256+u[t+B],B+=A,S-=8);if(c===0)c=1-C;else{if(c===y)return o?NaN:(D?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-C}return(D?-1:1)*o*Math.pow(2,c-i)},re.write=function(u,t,e,i,s,c){var o,a,y,C=c*8-s-1,S=(1<<C)-1,B=S>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,D=i?0:c-1,F=i?1:-1,R=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=S):(o=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-o))<1&&(o--,y*=2),o+B>=1?t+=A/y:t+=A*Math.pow(2,1-B),t*y>=2&&(o++,y/=2),o+B>=S?(a=0,o=S):o+B>=1?(a=(t*y-1)*Math.pow(2,s),o=o+B):(a=t*Math.pow(2,B-1)*Math.pow(2,s),o=0));s>=8;u[e+D]=a&255,D+=F,a/=256,s-=8);for(o=o<<s|a,C+=s;C>0;u[e+D]=o&255,D+=F,o/=256,C-=8);u[e+D-F]|=R*128}),re}var ze;function je(){return ze||(ze=1,(function(u){const t=Yi(),e=Gi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;u.Buffer=a,u.SlowBuffer=x,u.INSPECT_MAX_BYTES=50;const s=2147483647;u.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=c(),!a.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 h=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(h,r),h.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(h){if(h>s)throw new RangeError('The value "'+h+'" is invalid for option "size"');const r=new Uint8Array(h);return Object.setPrototypeOf(r,a.prototype),r}function a(h,r,n){if(typeof h=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(h)}return y(h,r,n)}a.poolSize=8192;function y(h,r,n){if(typeof h=="string")return A(h,r);if(ArrayBuffer.isView(h))return F(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(ht(h,ArrayBuffer)||h&&ht(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ht(h,SharedArrayBuffer)||h&&ht(h.buffer,SharedArrayBuffer)))return R(h,r,n);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=h.valueOf&&h.valueOf();if(p!=null&&p!==h)return a.from(p,r,n);const w=N(h);if(w)return w;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return a.from(h[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 h)}a.from=function(h,r,n){return y(h,r,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function C(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function S(h,r,n){return C(h),h<=0?o(h):r!==void 0?typeof n=="string"?o(h).fill(r,n):o(h).fill(r):o(h)}a.alloc=function(h,r,n){return S(h,r,n)};function B(h){return C(h),o(h<0?0:m(h)|0)}a.allocUnsafe=function(h){return B(h)},a.allocUnsafeSlow=function(h){return B(h)};function A(h,r){if((typeof r!="string"||r==="")&&(r="utf8"),!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=_(h,r)|0;let p=o(n);const w=p.write(h,r);return w!==n&&(p=p.slice(0,w)),p}function D(h){const r=h.length<0?0:m(h.length)|0,n=o(r);for(let p=0;p<r;p+=1)n[p]=h[p]&255;return n}function F(h){if(ht(h,Uint8Array)){const r=new Uint8Array(h);return R(r.buffer,r.byteOffset,r.byteLength)}return D(h)}function R(h,r,n){if(r<0||h.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(h.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(h):n===void 0?p=new Uint8Array(h,r):p=new Uint8Array(h,r,n),Object.setPrototypeOf(p,a.prototype),p}function N(h){if(a.isBuffer(h)){const r=m(h.length)|0,n=o(r);return n.length===0||h.copy(n,0,0,r),n}if(h.length!==void 0)return typeof h.length!="number"||Pt(h.length)?o(0):D(h);if(h.type==="Buffer"&&Array.isArray(h.data))return D(h.data)}function m(h){if(h>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return h|0}function x(h){return+h!=h&&(h=0),a.alloc(+h)}a.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==a.prototype},a.compare=function(r,n){if(ht(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),ht(n,Uint8Array)&&(n=a.from(n,n.offset,n.byteLength)),!a.isBuffer(r)||!a.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,w=n.length;for(let v=0,T=Math.min(p,w);v<T;++v)if(r[v]!==n[v]){p=r[v],w=n[v];break}return p<w?-1:w<p?1:0},a.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}},a.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return a.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const w=a.allocUnsafe(n);let v=0;for(p=0;p<r.length;++p){let T=r[p];if(ht(T,Uint8Array))v+T.length>w.length?(a.isBuffer(T)||(T=a.from(T)),T.copy(w,v)):Uint8Array.prototype.set.call(w,T,v);else if(a.isBuffer(T))T.copy(w,v);else throw new TypeError('"list" argument must be an Array of Buffers');v+=T.length}return w};function _(h,r){if(a.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||ht(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const n=h.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let w=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return ut(h).length;default:if(w)return p?-1:j(h).length;r=(""+r).toLowerCase(),w=!0}}a.byteLength=_;function f(h,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(h||(h="utf8");;)switch(h){case"hex":return xt(this,r,n);case"utf8":case"utf-8":return ft(this,r,n);case"ascii":return K(this,r,n);case"latin1":case"binary":return gt(this,r,n);case"base64":return st(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),p=!0}}a.prototype._isBuffer=!0;function b(h,r,n){const p=h[r];h[r]=h[n],h[n]=p}a.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},a.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},a.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},a.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?ft(this,0,r):f.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(r){if(!a.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:a.compare(this,r)===0},a.prototype.inspect=function(){let r="";const n=u.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(r,n,p,w,v){if(ht(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.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),w===void 0&&(w=0),v===void 0&&(v=this.length),n<0||p>r.length||w<0||v>this.length)throw new RangeError("out of range index");if(w>=v&&n>=p)return 0;if(w>=v)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,w>>>=0,v>>>=0,this===r)return 0;let T=v-w,V=p-n;const J=Math.min(T,V),Z=this.slice(w,v),nt=r.slice(n,p);for(let et=0;et<J;++et)if(Z[et]!==nt[et]){T=Z[et],V=nt[et];break}return T<V?-1:V<T?1:0};function O(h,r,n,p,w){if(h.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Pt(n)&&(n=w?0:h.length-1),n<0&&(n=h.length+n),n>=h.length){if(w)return-1;n=h.length-1}else if(n<0)if(w)n=0;else return-1;if(typeof r=="string"&&(r=a.from(r,p)),a.isBuffer(r))return r.length===0?-1:k(h,r,n,p,w);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?w?Uint8Array.prototype.indexOf.call(h,r,n):Uint8Array.prototype.lastIndexOf.call(h,r,n):k(h,[r],n,p,w);throw new TypeError("val must be string, number or Buffer")}function k(h,r,n,p,w){let v=1,T=h.length,V=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(h.length<2||r.length<2)return-1;v=2,T/=2,V/=2,n/=2}function J(nt,et){return v===1?nt[et]:nt.readUInt16BE(et*v)}let Z;if(w){let nt=-1;for(Z=n;Z<T;Z++)if(J(h,Z)===J(r,nt===-1?0:Z-nt)){if(nt===-1&&(nt=Z),Z-nt+1===V)return nt*v}else nt!==-1&&(Z-=Z-nt),nt=-1}else for(n+V>T&&(n=T-V),Z=n;Z>=0;Z--){let nt=!0;for(let et=0;et<V;et++)if(J(h,Z+et)!==J(r,et)){nt=!1;break}if(nt)return Z}return-1}a.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},a.prototype.indexOf=function(r,n,p){return O(this,r,n,p,!0)},a.prototype.lastIndexOf=function(r,n,p){return O(this,r,n,p,!1)};function L(h,r,n,p){n=Number(n)||0;const w=h.length-n;p?(p=Number(p),p>w&&(p=w)):p=w;const v=r.length;p>v/2&&(p=v/2);let T;for(T=0;T<p;++T){const V=parseInt(r.substr(T*2,2),16);if(Pt(V))return T;h[n+T]=V}return T}function g(h,r,n,p){return rt(j(r,h.length-n),h,n,p)}function q(h,r,n,p){return rt($(r),h,n,p)}function Y(h,r,n,p){return rt(ut(r),h,n,p)}function G(h,r,n,p){return rt(ct(r,h.length-n),h,n,p)}a.prototype.write=function(r,n,p,w){if(n===void 0)w="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")w=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,w===void 0&&(w="utf8")):(w=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const v=this.length-n;if((p===void 0||p>v)&&(p=v),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");w||(w="utf8");let T=!1;for(;;)switch(w){case"hex":return L(this,r,n,p);case"utf8":case"utf-8":return g(this,r,n,p);case"ascii":case"latin1":case"binary":return q(this,r,n,p);case"base64":return Y(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,r,n,p);default:if(T)throw new TypeError("Unknown encoding: "+w);w=(""+w).toLowerCase(),T=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function st(h,r,n){return r===0&&n===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(r,n))}function ft(h,r,n){n=Math.min(h.length,n);const p=[];let w=r;for(;w<n;){const v=h[w];let T=null,V=v>239?4:v>223?3:v>191?2:1;if(w+V<=n){let J,Z,nt,et;switch(V){case 1:v<128&&(T=v);break;case 2:J=h[w+1],(J&192)===128&&(et=(v&31)<<6|J&63,et>127&&(T=et));break;case 3:J=h[w+1],Z=h[w+2],(J&192)===128&&(Z&192)===128&&(et=(v&15)<<12|(J&63)<<6|Z&63,et>2047&&(et<55296||et>57343)&&(T=et));break;case 4:J=h[w+1],Z=h[w+2],nt=h[w+3],(J&192)===128&&(Z&192)===128&&(nt&192)===128&&(et=(v&15)<<18|(J&63)<<12|(Z&63)<<6|nt&63,et>65535&&et<1114112&&(T=et))}}T===null?(T=65533,V=1):T>65535&&(T-=65536,p.push(T>>>10&1023|55296),T=56320|T&1023),p.push(T),w+=V}return ot(p)}const at=4096;function ot(h){const r=h.length;if(r<=at)return String.fromCharCode.apply(String,h);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,h.slice(p,p+=at));return n}function K(h,r,n){let p="";n=Math.min(h.length,n);for(let w=r;w<n;++w)p+=String.fromCharCode(h[w]&127);return p}function gt(h,r,n){let p="";n=Math.min(h.length,n);for(let w=r;w<n;++w)p+=String.fromCharCode(h[w]);return p}function xt(h,r,n){const p=h.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let w="";for(let v=r;v<n;++v)w+=jt[h[v]];return w}function mt(h,r,n){const p=h.slice(r,n);let w="";for(let v=0;v<p.length-1;v+=2)w+=String.fromCharCode(p[v]+p[v+1]*256);return w}a.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 w=this.subarray(r,n);return Object.setPrototypeOf(w,a.prototype),w};function W(h,r,n){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+r>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r],v=1,T=0;for(;++T<n&&(v*=256);)w+=this[r+T]*v;return w},a.prototype.readUintBE=a.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r+--n],v=1;for(;n>0&&(v*=256);)w+=this[r+--n]*v;return w},a.prototype.readUint8=a.prototype.readUInt8=function(r,n){return r=r>>>0,n||W(r,1,this.length),this[r]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||W(r,2,this.length),this[r]|this[r+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||W(r,2,this.length),this[r]<<8|this[r+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||W(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},a.prototype.readBigUInt64LE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,v=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(w)+(BigInt(v)<<BigInt(32))}),a.prototype.readBigUInt64BE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],v=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(w)<<BigInt(32))+BigInt(v)}),a.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r],v=1,T=0;for(;++T<n&&(v*=256);)w+=this[r+T]*v;return v*=128,w>=v&&(w-=Math.pow(2,8*n)),w},a.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=n,v=1,T=this[r+--w];for(;w>0&&(v*=256);)T+=this[r+--w]*v;return v*=128,T>=v&&(T-=Math.pow(2,8*n)),T},a.prototype.readInt8=function(r,n){return r=r>>>0,n||W(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},a.prototype.readInt16LE=function(r,n){r=r>>>0,n||W(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(r,n){r=r>>>0,n||W(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},a.prototype.readInt32BE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},a.prototype.readBigInt64LE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(w)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),a.prototype.readBigInt64BE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(w)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),a.prototype.readFloatLE=function(r,n){return r=r>>>0,n||W(r,4,this.length),e.read(this,r,!0,23,4)},a.prototype.readFloatBE=function(r,n){return r=r>>>0,n||W(r,4,this.length),e.read(this,r,!1,23,4)},a.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||W(r,8,this.length),e.read(this,r,!0,52,8)},a.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||W(r,8,this.length),e.read(this,r,!1,52,8)};function tt(h,r,n,p,w,v){if(!a.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>w||r<v)throw new RangeError('"value" argument is out of bounds');if(n+p>h.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(r,n,p,w){if(r=+r,n=n>>>0,p=p>>>0,!w){const V=Math.pow(2,8*p)-1;tt(this,r,n,p,V,0)}let v=1,T=0;for(this[n]=r&255;++T<p&&(v*=256);)this[n+T]=r/v&255;return n+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(r,n,p,w){if(r=+r,n=n>>>0,p=p>>>0,!w){const V=Math.pow(2,8*p)-1;tt(this,r,n,p,V,0)}let v=p-1,T=1;for(this[n+v]=r&255;--v>=0&&(T*=256);)this[n+v]=r/T&255;return n+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,1,255,0),this[n]=r&255,n+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(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(h,r,n,p,w){lt(r,p,w,h,n,7);let v=Number(r&BigInt(4294967295));h[n++]=v,v=v>>8,h[n++]=v,v=v>>8,h[n++]=v,v=v>>8,h[n++]=v;let T=Number(r>>BigInt(32)&BigInt(4294967295));return h[n++]=T,T=T>>8,h[n++]=T,T=T>>8,h[n++]=T,T=T>>8,h[n++]=T,n}function vt(h,r,n,p,w){lt(r,p,w,h,n,7);let v=Number(r&BigInt(4294967295));h[n+7]=v,v=v>>8,h[n+6]=v,v=v>>8,h[n+5]=v,v=v>>8,h[n+4]=v;let T=Number(r>>BigInt(32)&BigInt(4294967295));return h[n+3]=T,T=T>>8,h[n+2]=T,T=T>>8,h[n+1]=T,T=T>>8,h[n]=T,n+8}a.prototype.writeBigUInt64LE=wt(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=wt(function(r,n=0){return vt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(r,n,p,w){if(r=+r,n=n>>>0,!w){const J=Math.pow(2,8*p-1);tt(this,r,n,p,J-1,-J)}let v=0,T=1,V=0;for(this[n]=r&255;++v<p&&(T*=256);)r<0&&V===0&&this[n+v-1]!==0&&(V=1),this[n+v]=(r/T>>0)-V&255;return n+p},a.prototype.writeIntBE=function(r,n,p,w){if(r=+r,n=n>>>0,!w){const J=Math.pow(2,8*p-1);tt(this,r,n,p,J-1,-J)}let v=p-1,T=1,V=0;for(this[n+v]=r&255;--v>=0&&(T*=256);)r<0&&V===0&&this[n+v+1]!==0&&(V=1),this[n+v]=(r/T>>0)-V&255;return n+p},a.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},a.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(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},a.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(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},a.prototype.writeBigInt64LE=wt(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=wt(function(r,n=0){return vt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ft(h,r,n,p,w,v){if(n+p>h.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Rt(h,r,n,p,w){return r=+r,n=n>>>0,w||Ft(h,r,n,4),e.write(h,r,n,p,23,4),n+4}a.prototype.writeFloatLE=function(r,n,p){return Rt(this,r,n,!0,p)},a.prototype.writeFloatBE=function(r,n,p){return Rt(this,r,n,!1,p)};function d(h,r,n,p,w){return r=+r,n=n>>>0,w||Ft(h,r,n,8),e.write(h,r,n,p,52,8),n+8}a.prototype.writeDoubleLE=function(r,n,p){return d(this,r,n,!0,p)},a.prototype.writeDoubleBE=function(r,n,p){return d(this,r,n,!1,p)},a.prototype.copy=function(r,n,p,w){if(!a.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!w&&w!==0&&(w=this.length),n>=r.length&&(n=r.length),n||(n=0),w>0&&w<p&&(w=p),w===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(w<0)throw new RangeError("sourceEnd out of bounds");w>this.length&&(w=this.length),r.length-n<w-p&&(w=r.length-n+p);const v=w-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,w):Uint8Array.prototype.set.call(r,this.subarray(p,w),n),v},a.prototype.fill=function(r,n,p,w){if(typeof r=="string"){if(typeof n=="string"?(w=n,n=0,p=this.length):typeof p=="string"&&(w=p,p=this.length),w!==void 0&&typeof w!="string")throw new TypeError("encoding must be a string");if(typeof w=="string"&&!a.isEncoding(w))throw new TypeError("Unknown encoding: "+w);if(r.length===1){const T=r.charCodeAt(0);(w==="utf8"&&T<128||w==="latin1")&&(r=T)}}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 v;if(typeof r=="number")for(v=n;v<p;++v)this[v]=r;else{const T=a.isBuffer(r)?r:a.from(r,w),V=T.length;if(V===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(v=0;v<p-n;++v)this[v+n]=T[v%V]}return this};const l={};function M(h,r,n){l[h]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(w){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:w,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}M("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(h,r){return`The "${h}" argument must be of type number. Received type ${typeof r}`},TypeError),M("ERR_OUT_OF_RANGE",function(h,r,n){let p=`The value of "${h}" is out of range.`,w=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?w=E(String(n)):typeof n=="bigint"&&(w=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(w=E(w)),w+="n"),p+=` It must be ${r}. Received ${w}`,p},RangeError);function E(h){let r="",n=h.length;const p=h[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${h.slice(n-3,n)}${r}`;return`${h.slice(0,n)}${r}`}function Q(h,r,n){it(r,"offset"),(h[r]===void 0||h[r+n]===void 0)&&U(r,h.length-(n+1))}function lt(h,r,n,p,w,v){if(h>n||h<r){const T=typeof r=="bigint"?"n":"";let V;throw r===0||r===BigInt(0)?V=`>= 0${T} and < 2${T} ** ${(v+1)*8}${T}`:V=`>= -(2${T} ** ${(v+1)*8-1}${T}) and < 2 ** ${(v+1)*8-1}${T}`,new l.ERR_OUT_OF_RANGE("value",V,h)}Q(p,w,v)}function it(h,r){if(typeof h!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",h)}function U(h,r,n){throw Math.floor(h)!==h?(it(h,n),new l.ERR_OUT_OF_RANGE("offset","an integer",h)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,h)}const z=/[^+/0-9A-Za-z-_]/g;function X(h){if(h=h.split("=")[0],h=h.trim().replace(z,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function j(h,r){r=r||1/0;let n;const p=h.length;let w=null;const v=[];for(let T=0;T<p;++T){if(n=h.charCodeAt(T),n>55295&&n<57344){if(!w){if(n>56319){(r-=3)>-1&&v.push(239,191,189);continue}else if(T+1===p){(r-=3)>-1&&v.push(239,191,189);continue}w=n;continue}if(n<56320){(r-=3)>-1&&v.push(239,191,189),w=n;continue}n=(w-55296<<10|n-56320)+65536}else w&&(r-=3)>-1&&v.push(239,191,189);if(w=null,n<128){if((r-=1)<0)break;v.push(n)}else if(n<2048){if((r-=2)<0)break;v.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;v.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;v.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return v}function $(h){const r=[];for(let n=0;n<h.length;++n)r.push(h.charCodeAt(n)&255);return r}function ct(h,r){let n,p,w;const v=[];for(let T=0;T<h.length&&!((r-=2)<0);++T)n=h.charCodeAt(T),p=n>>8,w=n%256,v.push(w),v.push(p);return v}function ut(h){return t.toByteArray(X(h))}function rt(h,r,n,p){let w;for(w=0;w<p&&!(w+n>=r.length||w>=h.length);++w)r[w+n]=h[w];return w}function ht(h,r){return h instanceof r||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===r.name}function Pt(h){return h!==h}const jt=(function(){const h="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let w=0;w<16;++w)r[p+w]=h[n]+h[w]}return r})();function wt(h){return typeof BigInt>"u"?Wt:h}function Wt(){throw new Error("BigInt not supported")}})(de)),de}var Ke;function zi(){return Ke||(Ke=1,(function(u,t){var e=je(),i=e.Buffer;function s(o,a){for(var y in o)a[y]=o[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?u.exports=e:(s(e,t),t.Buffer=c);function c(o,a,y){return i(o,a,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(o,a,y){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,a,y)},c.alloc=function(o,a,y){if(typeof o!="number")throw new TypeError("Argument must be a number");var C=i(o);return a!==void 0?typeof y=="string"?C.fill(a,y):C.fill(a):C.fill(0),C},c.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},c.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(ie,ie.exports)),ie.exports}var qe;function ji(){if(qe)return fe;qe=1;var u=zi().Buffer,t=u.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(m){if(!m)return"utf8";for(var x;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(x)return;m=(""+m).toLowerCase(),x=!0}}function i(m){var x=e(m);if(typeof x!="string"&&(u.isEncoding===t||!t(m)))throw new Error("Unknown encoding: "+m);return x||m}fe.StringDecoder=s;function s(m){this.encoding=i(m);var x;switch(this.encoding){case"utf16le":this.text=B,this.end=A,x=4;break;case"utf8":this.fillLast=y,x=4;break;case"base64":this.text=D,this.end=F,x=3;break;default:this.write=R,this.end=N;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(x)}s.prototype.write=function(m){if(m.length===0)return"";var x,_;if(this.lastNeed){if(x=this.fillLast(m),x===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<m.length?x?x+this.text(m,_):this.text(m,_):x||""},s.prototype.end=S,s.prototype.text=C,s.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function c(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function o(m,x,_){var f=x.length-1;if(f<_)return 0;var b=c(x[f]);return b>=0?(b>0&&(m.lastNeed=b-1),b):--f<_||b===-2?0:(b=c(x[f]),b>=0?(b>0&&(m.lastNeed=b-2),b):--f<_||b===-2?0:(b=c(x[f]),b>=0?(b>0&&(b===2?b=0:m.lastNeed=b-3),b):0))}function a(m,x,_){if((x[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return m.lastNeed=2,"�"}}function y(m){var x=this.lastTotal-this.lastNeed,_=a(this,m);if(_!==void 0)return _;if(this.lastNeed<=m.length)return m.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,x,0,m.length),this.lastNeed-=m.length}function C(m,x){var _=o(this,m,x);if(!this.lastNeed)return m.toString("utf8",x);this.lastTotal=_;var f=m.length-(_-this.lastNeed);return m.copy(this.lastChar,0,f),m.toString("utf8",x,f)}function S(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+"�":x}function B(m,x){if((m.length-x)%2===0){var _=m.toString("utf16le",x);if(_){var f=_.charCodeAt(_.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",x,m.length-1)}function A(m){var x=m&&m.length?this.write(m):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,_)}return x}function D(m,x){var _=(m.length-x)%3;return _===0?m.toString("base64",x):(this.lastNeed=3-_,this.lastTotal=3,_===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",x,m.length-_))}function F(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function R(m){return m.toString(this.encoding)}function N(m){return m&&m.length?this.write(m):""}return fe}var We;function Ki(){return We||(We=1,(function(u){(function(t){t.parser=function(d,l){return new i(d,l)},t.SAXParser=i,t.SAXStream=S,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(d,l){if(!(this instanceof i))return new i(d,l);var M=this;c(M),M.q=M.c="",M.bufferCheckPosition=t.MAX_BUFFER_LENGTH,M.opt=l||{},M.opt.lowercase=M.opt.lowercase||M.opt.lowercasetags,M.looseCase=M.opt.lowercase?"toLowerCase":"toUpperCase",M.tags=[],M.closed=M.closedRoot=M.sawRoot=!1,M.tag=M.error=null,M.strict=!!d,M.noscript=!!(d||M.opt.noscript),M.state=g.BEGIN,M.strictEntities=M.opt.strictEntities,M.ENTITIES=M.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),M.attribList=[],M.opt.xmlns&&(M.ns=Object.create(R)),M.opt.unquotedAttributeValues===void 0&&(M.opt.unquotedAttributeValues=!d),M.trackPosition=M.opt.position!==!1,M.trackPosition&&(M.position=M.line=M.column=0),Y(M,"onready")}Object.create||(Object.create=function(d){function l(){}l.prototype=d;var M=new l;return M}),Object.keys||(Object.keys=function(d){var l=[];for(var M in d)d.hasOwnProperty(M)&&l.push(M);return l});function s(d){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),M=0,E=0,Q=e.length;E<Q;E++){var lt=d[e[E]].length;if(lt>l)switch(e[E]){case"textNode":st(d);break;case"cdata":G(d,"oncdata",d.cdata),d.cdata="";break;case"script":G(d,"onscript",d.script),d.script="";break;default:at(d,"Max buffer length exceeded: "+e[E])}M=Math.max(M,lt)}var it=t.MAX_BUFFER_LENGTH-M;d.bufferCheckPosition=it+d.position}function c(d){for(var l=0,M=e.length;l<M;l++)d[e[l]]=""}function o(d){st(d),d.cdata!==""&&(G(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(G(d,"onscript",d.script),d.script="")}i.prototype={end:function(){ot(this)},write:Rt,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a;try{a=Vi.Stream}catch{a=function(){}}a||(a=function(){});var y=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function C(d,l){return new S(d,l)}function S(d,l){if(!(this instanceof S))return new S(d,l);a.apply(this),this._parser=new i(d,l),this.writable=!0,this.readable=!0;var M=this;this._parser.onend=function(){M.emit("end")},this._parser.onerror=function(E){M.emit("error",E),M._parser.error=null},this._decoder=null,y.forEach(function(E){Object.defineProperty(M,"on"+E,{get:function(){return M._parser["on"+E]},set:function(Q){if(!Q)return M.removeAllListeners(E),M._parser["on"+E]=Q,Q;M.on(E,Q)},enumerable:!0,configurable:!1})})}S.prototype=Object.create(a.prototype,{constructor:{value:S}}),S.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var l=ji().StringDecoder;this._decoder=new l("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},S.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},S.prototype.on=function(d,l){var M=this;return!M._parser["on"+d]&&y.indexOf(d)!==-1&&(M._parser["on"+d]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,d),M.emit.apply(M,E)}),a.prototype.on.call(M,d,l)};var B="[CDATA[",A="DOCTYPE",D="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",R={xml:D,xmlns:F},N=/[:_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-]/,x=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(d){return d===" "||d===`
|
|
87
|
-
`||d==="\r"||d===" "}function
|
|
86
|
+
`,be=24,er=180,ir=.75,rr=.5,nr=.35,sr=new Float32Array([.08,.08,.14]),fe=n=>{if(typeof n=="string"){let t=n.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 n=="number")return new Float32Array([(n>>16&255)/255,(n>>8&255)/255,(n&255)/255]);if(Array.isArray(n)&&n.length>=3){const t=n.every(e=>e<=1);return new Float32Array(t?n:n.map(e=>e/255))}return new Float32Array([0,0,0])};function ei(n,t){const e=new Float32Array(be*4),i={value:e,type:"vec4<f32>",size:be},r={value:t?.darkness??ir,type:"f32"},l={value:t?.fogColor?fe(t.fogColor):sr,type:"vec3<f32>"},c={value:t?.fogRadius??rr,type:"f32"},a={value:t?.fogSoftness??nr,type:"f32"},g={value:t?.darkColor?fe(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let S=t?.spots?[...t.spots]:[],w=t?.lightWorldPosition??null;const C=L.Filter.from({gl:{vertex:ti,fragment:tr},resources:{nightUniforms:{uSpots:i,uDarkness:r,uDarkColor:g,uFogColor:l,uFogRadius:c,uFogSoftness:a}}}),M=(x,y,f)=>Math.min(Math.max(x,y),f),N=()=>Date.now()/1e3,F=()=>w?[{x:w.x,y:w.y},...S]:S,k=()=>{const x=F(),y=Math.min(x.length,be),f=n?.getVisibleBounds?.()??t?.getBounds?.(),A=!!f&&f.width>0&&f.height>0,P=n?.toScreen?.bind(n),I=A&&typeof P=="function";let O=0,_=0;if(I){const V=P(f.x,f.y);Ft(V?.x)&&Ft(V?.y)&&(O=V.x,_=V.y)}const U=N();e.fill(0);for(let V=0;V<y;V++){const z=x[V],K=z.radius??er,et=M(z.intensity??1,0,2),Q=z.phase??V*.7;let W=et;if(z.flicker){const H=z.flickerSpeed??12;W*=.88+.12*Math.sin(U*H+Q)}if(z.pulse){const H=z.pulseSpeed??2;W*=.8+.2*Math.sin(U*H+Q)}let Y=z.x,Z=z.y,yt=K;if(I){const H=P(z.x,z.y);Y=H.x-O,Z=H.y-_}else A&&(Y=z.x-f.x,Z=z.y-f.y);const ct=V*4;e[ct]=Y,e[ct+1]=Z,e[ct+2]=yt,e[ct+3]=M(W,0,2)}i.value=e},R=C.apply.bind(C);C.apply=((...x)=>(k(),R(...x)));const m=C;return m.setLightWorldPosition=x=>{w=x,k()},m.getLightWorldPosition=()=>w,m.setSpots=x=>{S=[...x],k()},m.getSpots=()=>F().map(x=>({...x})),m.syncLightToViewport=k,m.setDarkness=x=>{r.value=x},m.setDarkColor=x=>{g.value=fe(x)},m.setFogColor=x=>{l.value=fe(x)},m.setFogRadius=x=>{c.value=x},m.setFogSoftness=x=>{a.value=x},k(),m}const Tt=n=>typeof n=="function"?n():n,Ft=n=>typeof n=="number"&&Number.isFinite(n),or=n=>{const t=Tt(n);if(!t)return null;const e=Tt(t.x),i=Tt(t.y);if(!Ft(e)||!Ft(i))return null;const r=Tt(t.radius),l=Tt(t.intensity),c=Tt(t.flickerSpeed),a=Tt(t.pulseSpeed),g=Tt(t.phase);return{x:e,y:i,radius:Ft(r)?r:void 0,intensity:Ft(l)?l:void 0,flicker:!!Tt(t.flicker),flickerSpeed:Ft(c)?c:void 0,pulse:!!Tt(t.pulse),pulseSpeed:Ft(a)?a:void 0,phase:Ft(g)?g:void 0}},ii=n=>{const t=Tt(n);return Array.isArray(t)?t.map(or).filter(e=>!!e):[]},ar=n=>{if(!n)return null;if(typeof n.getVisibleBounds=="function"){const t=n.getVisibleBounds();if(t)return t}if(typeof n.getLocalBounds=="function"){const t=n.getLocalBounds();if(t)return t}return Ft(n.width)&&Ft(n.height)?{x:0,y:0,width:n.width,height:n.height}:null};function lr(n={}){const t=D.useProps(n),e=()=>t.lightSpots??t.spots;return D.mount(i=>{const r=i.props.context,l=r?.viewport,c=l??i.parent?.componentInstance;if(!c)return;const a=r?.canvasSize,g=()=>{if(!l&&typeof a=="function"){const R=a();if(R&&Ft(R.width)&&Ft(R.height)&&R.width>0&&R.height>0)return{x:0,y:0,width:R.width,height:R.height}}return ar(c)},S=Tt(t.darkness),w=Tt(t.darkColor),C=Tt(t.fogColor),M=Tt(t.fogRadius),N=Tt(t.fogSoftness),F=ei(l,{spots:ii(e()),getBounds:g,darkness:Ft(S)?S:void 0,darkColor:w??void 0,fogColor:C??void 0,fogRadius:Ft(M)?M:void 0,fogSoftness:Ft(N)?N:void 0}),k=Array.isArray(c.filters)?c.filters:[];return k.includes(F)||(c.filters=[...k,F]),D.effect(()=>{F.setSpots(ii(e()))}),D.effect(()=>{const R=Tt(t.darkness);Ft(R)&&F.setDarkness(R)}),D.effect(()=>{const R=Tt(t.darkColor);R!==void 0&&F.setDarkColor(R)}),D.effect(()=>{const R=Tt(t.fogColor);R!==void 0&&F.setFogColor(R)}),D.effect(()=>{const R=Tt(t.fogRadius);Ft(R)&&F.setFogRadius(R)}),D.effect(()=>{const R=Tt(t.fogSoftness);Ft(R)&&F.setFogSoftness(R)}),()=>{const m=(Array.isArray(c.filters)?c.filters:[]).filter(x=>x!==F);c.filters=m.length>0?m:null}}),D.h(D.Container)}function cr(n={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:r=180,segments:l=8,segmentWidth:c=3,inactiveAlpha:a=.15}=D.useProps(n,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),g=D.signal(0);D.tick(({deltaTime:F})=>{const R=(typeof r=="function"?r():r)*F/1e3;g.set(g()+R)});const S=F=>{const k=typeof t=="function"?t():t,R=typeof e=="function"?e():e,m=i?typeof i=="function"?i():i:null,x=typeof l=="function"?l():l;typeof c=="function"&&c();const y=typeof a=="function"?a():a,f=g();m&&F.circle(0,0,k).fill(m);const A=360/x,P=k*.4,I=k;for(let O=0;O<x;O++){const _=O*A,U=(f%360+360)%360;let V=Math.abs(U-_);V>180&&(V=360-V);let K=V/120;K=Math.min(1,K),K=K*K*K;const et=y+(1-K)*(1-y),Q=_*(Math.PI/180),W=A*(Math.PI/180),Y=Q-W/2,Z=Q+W/2;F.arc(0,0,P,Y,Z).arc(0,0,I,Z,Y,!0).fill({color:R,alpha:et})}},C=(typeof t=="function"?t():t)*2,M=D.signal(C),N=D.signal(C);return typeof t=="function"&&D.effect(()=>{const F=t();M.set(F*2),N.set(F*2)}),D.h(D.Container,n,[D.h(D.Graphics,{draw:S})])}var ee=(n=>(n.Tile="tilelayer",n.ObjectGroup="objectgroup",n.Image="imagelayer",n.Group="group",n))(ee||{});function ri(...n){return n.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function ur(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.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(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),e}var Se={};const hr=ur(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ae={},de={exports:{}},Te={},ne={},ni;function fr(){if(ni)return ne;ni=1,ne.byteLength=a,ne.toByteArray=S,ne.fromByteArray=M;for(var n=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,l=i.length;r<l;++r)n[r]=i[r],t[i.charCodeAt(r)]=r;t[45]=62,t[95]=63;function c(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=N.indexOf("=");k===-1&&(k=F);var R=k===F?0:4-k%4;return[k,R]}function a(N){var F=c(N),k=F[0],R=F[1];return(k+R)*3/4-R}function g(N,F,k){return(F+k)*3/4-k}function S(N){var F,k=c(N),R=k[0],m=k[1],x=new e(g(N,R,m)),y=0,f=m>0?R-4:R,A;for(A=0;A<f;A+=4)F=t[N.charCodeAt(A)]<<18|t[N.charCodeAt(A+1)]<<12|t[N.charCodeAt(A+2)]<<6|t[N.charCodeAt(A+3)],x[y++]=F>>16&255,x[y++]=F>>8&255,x[y++]=F&255;return m===2&&(F=t[N.charCodeAt(A)]<<2|t[N.charCodeAt(A+1)]>>4,x[y++]=F&255),m===1&&(F=t[N.charCodeAt(A)]<<10|t[N.charCodeAt(A+1)]<<4|t[N.charCodeAt(A+2)]>>2,x[y++]=F>>8&255,x[y++]=F&255),x}function w(N){return n[N>>18&63]+n[N>>12&63]+n[N>>6&63]+n[N&63]}function C(N,F,k){for(var R,m=[],x=F;x<k;x+=3)R=(N[x]<<16&16711680)+(N[x+1]<<8&65280)+(N[x+2]&255),m.push(w(R));return m.join("")}function M(N){for(var F,k=N.length,R=k%3,m=[],x=16383,y=0,f=k-R;y<f;y+=x)m.push(C(N,y,y+x>f?f:y+x));return R===1?(F=N[k-1],m.push(n[F>>2]+n[F<<4&63]+"==")):R===2&&(F=(N[k-2]<<8)+N[k-1],m.push(n[F>>10]+n[F>>4&63]+n[F<<2&63]+"=")),m.join("")}return ne}var pe={};var si;function dr(){return si||(si=1,pe.read=function(n,t,e,i,r){var l,c,a=r*8-i-1,g=(1<<a)-1,S=g>>1,w=-7,C=e?r-1:0,M=e?-1:1,N=n[t+C];for(C+=M,l=N&(1<<-w)-1,N>>=-w,w+=a;w>0;l=l*256+n[t+C],C+=M,w-=8);for(c=l&(1<<-w)-1,l>>=-w,w+=i;w>0;c=c*256+n[t+C],C+=M,w-=8);if(l===0)l=1-S;else{if(l===g)return c?NaN:(N?-1:1)*(1/0);c=c+Math.pow(2,i),l=l-S}return(N?-1:1)*c*Math.pow(2,l-i)},pe.write=function(n,t,e,i,r,l){var c,a,g,S=l*8-r-1,w=(1<<S)-1,C=w>>1,M=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=i?0:l-1,F=i?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,c=w):(c=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-c))<1&&(c--,g*=2),c+C>=1?t+=M/g:t+=M*Math.pow(2,1-C),t*g>=2&&(c++,g/=2),c+C>=w?(a=0,c=w):c+C>=1?(a=(t*g-1)*Math.pow(2,r),c=c+C):(a=t*Math.pow(2,C-1)*Math.pow(2,r),c=0));r>=8;n[e+N]=a&255,N+=F,a/=256,r-=8);for(c=c<<r|a,S+=r;S>0;n[e+N]=c&255,N+=F,c/=256,S-=8);n[e+N-F]|=k*128}),pe}var oi;function ai(){return oi||(oi=1,(function(n){const t=fr(),e=dr(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=x,n.INSPECT_MAX_BYTES=50;const r=2147483647;n.kMaxLength=r,a.TYPED_ARRAY_SUPPORT=l(),!a.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 l(){try{const h=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(h,s),h.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(h){if(h>r)throw new RangeError('The value "'+h+'" is invalid for option "size"');const s=new Uint8Array(h);return Object.setPrototypeOf(s,a.prototype),s}function a(h,s,o){if(typeof h=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(h)}return g(h,s,o)}a.poolSize=8192;function g(h,s,o){if(typeof h=="string")return M(h,s);if(ArrayBuffer.isView(h))return F(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Et(h,ArrayBuffer)||h&&Et(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Et(h,SharedArrayBuffer)||h&&Et(h.buffer,SharedArrayBuffer)))return k(h,s,o);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=h.valueOf&&h.valueOf();if(p!=null&&p!==h)return a.from(p,s,o);const v=R(h);if(v)return v;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return a.from(h[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}a.from=function(h,s,o){return g(h,s,o)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function S(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function w(h,s,o){return S(h),h<=0?c(h):s!==void 0?typeof o=="string"?c(h).fill(s,o):c(h).fill(s):c(h)}a.alloc=function(h,s,o){return w(h,s,o)};function C(h){return S(h),c(h<0?0:m(h)|0)}a.allocUnsafe=function(h){return C(h)},a.allocUnsafeSlow=function(h){return C(h)};function M(h,s){if((typeof s!="string"||s==="")&&(s="utf8"),!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=y(h,s)|0;let p=c(o);const v=p.write(h,s);return v!==o&&(p=p.slice(0,v)),p}function N(h){const s=h.length<0?0:m(h.length)|0,o=c(s);for(let p=0;p<s;p+=1)o[p]=h[p]&255;return o}function F(h){if(Et(h,Uint8Array)){const s=new Uint8Array(h);return k(s.buffer,s.byteOffset,s.byteLength)}return N(h)}function k(h,s,o){if(s<0||h.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let p;return s===void 0&&o===void 0?p=new Uint8Array(h):o===void 0?p=new Uint8Array(h,s):p=new Uint8Array(h,s,o),Object.setPrototypeOf(p,a.prototype),p}function R(h){if(a.isBuffer(h)){const s=m(h.length)|0,o=c(s);return o.length===0||h.copy(o,0,0,s),o}if(h.length!==void 0)return typeof h.length!="number"||Kt(h.length)?c(0):N(h);if(h.type==="Buffer"&&Array.isArray(h.data))return N(h.data)}function m(h){if(h>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return h|0}function x(h){return+h!=h&&(h=0),a.alloc(+h)}a.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==a.prototype},a.compare=function(s,o){if(Et(s,Uint8Array)&&(s=a.from(s,s.offset,s.byteLength)),Et(o,Uint8Array)&&(o=a.from(o,o.offset,o.byteLength)),!a.isBuffer(s)||!a.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let p=s.length,v=o.length;for(let b=0,T=Math.min(p,v);b<T;++b)if(s[b]!==o[b]){p=s[b],v=o[b];break}return p<v?-1:v<p?1:0},a.isEncoding=function(s){switch(String(s).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}},a.concat=function(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return a.alloc(0);let p;if(o===void 0)for(o=0,p=0;p<s.length;++p)o+=s[p].length;const v=a.allocUnsafe(o);let b=0;for(p=0;p<s.length;++p){let T=s[p];if(Et(T,Uint8Array))b+T.length>v.length?(a.isBuffer(T)||(T=a.from(T)),T.copy(v,b)):Uint8Array.prototype.set.call(v,T,b);else if(a.isBuffer(T))T.copy(v,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=T.length}return v};function y(h,s){if(a.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||Et(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const o=h.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&o===0)return 0;let v=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return q(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return wt(h).length;default:if(v)return p?-1:q(h).length;s=(""+s).toLowerCase(),v=!0}}a.byteLength=y;function f(h,s,o){let p=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(h||(h="utf8");;)switch(h){case"hex":return yt(this,s,o);case"utf8":case"utf-8":return et(this,s,o);case"ascii":return Y(this,s,o);case"latin1":case"binary":return Z(this,s,o);case"base64":return K(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ct(this,s,o);default:if(p)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),p=!0}}a.prototype._isBuffer=!0;function A(h,s,o){const p=h[s];h[s]=h[o],h[o]=p}a.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)A(this,o,o+1);return this},a.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)A(this,o,o+3),A(this,o+1,o+2);return this},a.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)A(this,o,o+7),A(this,o+1,o+6),A(this,o+2,o+5),A(this,o+3,o+4);return this},a.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?et(this,0,s):f.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(s){if(!a.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:a.compare(this,s)===0},a.prototype.inspect=function(){let s="";const o=n.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(s,o,p,v,b){if(Et(s,Uint8Array)&&(s=a.from(s,s.offset,s.byteLength)),!a.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),p===void 0&&(p=s?s.length:0),v===void 0&&(v=0),b===void 0&&(b=this.length),o<0||p>s.length||v<0||b>this.length)throw new RangeError("out of range index");if(v>=b&&o>=p)return 0;if(v>=b)return-1;if(o>=p)return 1;if(o>>>=0,p>>>=0,v>>>=0,b>>>=0,this===s)return 0;let T=b-v,$=p-o;const at=Math.min(T,$),lt=this.slice(v,b),dt=s.slice(o,p);for(let ht=0;ht<at;++ht)if(lt[ht]!==dt[ht]){T=lt[ht],$=dt[ht];break}return T<$?-1:$<T?1:0};function P(h,s,o,p,v){if(h.length===0)return-1;if(typeof o=="string"?(p=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Kt(o)&&(o=v?0:h.length-1),o<0&&(o=h.length+o),o>=h.length){if(v)return-1;o=h.length-1}else if(o<0)if(v)o=0;else return-1;if(typeof s=="string"&&(s=a.from(s,p)),a.isBuffer(s))return s.length===0?-1:I(h,s,o,p,v);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?v?Uint8Array.prototype.indexOf.call(h,s,o):Uint8Array.prototype.lastIndexOf.call(h,s,o):I(h,[s],o,p,v);throw new TypeError("val must be string, number or Buffer")}function I(h,s,o,p,v){let b=1,T=h.length,$=s.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(h.length<2||s.length<2)return-1;b=2,T/=2,$/=2,o/=2}function at(dt,ht){return b===1?dt[ht]:dt.readUInt16BE(ht*b)}let lt;if(v){let dt=-1;for(lt=o;lt<T;lt++)if(at(h,lt)===at(s,dt===-1?0:lt-dt)){if(dt===-1&&(dt=lt),lt-dt+1===$)return dt*b}else dt!==-1&&(lt-=lt-dt),dt=-1}else for(o+$>T&&(o=T-$),lt=o;lt>=0;lt--){let dt=!0;for(let ht=0;ht<$;ht++)if(at(h,lt+ht)!==at(s,ht)){dt=!1;break}if(dt)return lt}return-1}a.prototype.includes=function(s,o,p){return this.indexOf(s,o,p)!==-1},a.prototype.indexOf=function(s,o,p){return P(this,s,o,p,!0)},a.prototype.lastIndexOf=function(s,o,p){return P(this,s,o,p,!1)};function O(h,s,o,p){o=Number(o)||0;const v=h.length-o;p?(p=Number(p),p>v&&(p=v)):p=v;const b=s.length;p>b/2&&(p=b/2);let T;for(T=0;T<p;++T){const $=parseInt(s.substr(T*2,2),16);if(Kt($))return T;h[o+T]=$}return T}function _(h,s,o,p){return ft(q(s,h.length-o),h,o,p)}function U(h,s,o,p){return ft(ot(s),h,o,p)}function V(h,s,o,p){return ft(wt(s),h,o,p)}function z(h,s,o,p){return ft(xt(s,h.length-o),h,o,p)}a.prototype.write=function(s,o,p,v){if(o===void 0)v="utf8",p=this.length,o=0;else if(p===void 0&&typeof o=="string")v=o,p=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(p)?(p=p>>>0,v===void 0&&(v="utf8")):(v=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-o;if((p===void 0||p>b)&&(p=b),s.length>0&&(p<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");v||(v="utf8");let T=!1;for(;;)switch(v){case"hex":return O(this,s,o,p);case"utf8":case"utf-8":return _(this,s,o,p);case"ascii":case"latin1":case"binary":return U(this,s,o,p);case"base64":return V(this,s,o,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,s,o,p);default:if(T)throw new TypeError("Unknown encoding: "+v);v=(""+v).toLowerCase(),T=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function K(h,s,o){return s===0&&o===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(s,o))}function et(h,s,o){o=Math.min(h.length,o);const p=[];let v=s;for(;v<o;){const b=h[v];let T=null,$=b>239?4:b>223?3:b>191?2:1;if(v+$<=o){let at,lt,dt,ht;switch($){case 1:b<128&&(T=b);break;case 2:at=h[v+1],(at&192)===128&&(ht=(b&31)<<6|at&63,ht>127&&(T=ht));break;case 3:at=h[v+1],lt=h[v+2],(at&192)===128&&(lt&192)===128&&(ht=(b&15)<<12|(at&63)<<6|lt&63,ht>2047&&(ht<55296||ht>57343)&&(T=ht));break;case 4:at=h[v+1],lt=h[v+2],dt=h[v+3],(at&192)===128&&(lt&192)===128&&(dt&192)===128&&(ht=(b&15)<<18|(at&63)<<12|(lt&63)<<6|dt&63,ht>65535&&ht<1114112&&(T=ht))}}T===null?(T=65533,$=1):T>65535&&(T-=65536,p.push(T>>>10&1023|55296),T=56320|T&1023),p.push(T),v+=$}return W(p)}const Q=4096;function W(h){const s=h.length;if(s<=Q)return String.fromCharCode.apply(String,h);let o="",p=0;for(;p<s;)o+=String.fromCharCode.apply(String,h.slice(p,p+=Q));return o}function Y(h,s,o){let p="";o=Math.min(h.length,o);for(let v=s;v<o;++v)p+=String.fromCharCode(h[v]&127);return p}function Z(h,s,o){let p="";o=Math.min(h.length,o);for(let v=s;v<o;++v)p+=String.fromCharCode(h[v]);return p}function yt(h,s,o){const p=h.length;(!s||s<0)&&(s=0),(!o||o<0||o>p)&&(o=p);let v="";for(let b=s;b<o;++b)v+=Jt[h[b]];return v}function ct(h,s,o){const p=h.slice(s,o);let v="";for(let b=0;b<p.length-1;b+=2)v+=String.fromCharCode(p[b]+p[b+1]*256);return v}a.prototype.slice=function(s,o){const p=this.length;s=~~s,o=o===void 0?p:~~o,s<0?(s+=p,s<0&&(s=0)):s>p&&(s=p),o<0?(o+=p,o<0&&(o=0)):o>p&&(o=p),o<s&&(o=s);const v=this.subarray(s,o);return Object.setPrototypeOf(v,a.prototype),v};function H(h,s,o){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+s>o)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s],b=1,T=0;for(;++T<o&&(b*=256);)v+=this[s+T]*b;return v},a.prototype.readUintBE=a.prototype.readUIntBE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s+--o],b=1;for(;o>0&&(b*=256);)v+=this[s+--o]*b;return v},a.prototype.readUint8=a.prototype.readUInt8=function(s,o){return s=s>>>0,o||H(s,1,this.length),this[s]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||H(s,2,this.length),this[s]|this[s+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||H(s,2,this.length),this[s]<<8|this[s+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||H(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},a.prototype.readBigUInt64LE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,b=this[++s]+this[++s]*2**8+this[++s]*2**16+p*2**24;return BigInt(v)+(BigInt(b)<<BigInt(32))}),a.prototype.readBigUInt64BE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],b=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+p;return(BigInt(v)<<BigInt(32))+BigInt(b)}),a.prototype.readIntLE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s],b=1,T=0;for(;++T<o&&(b*=256);)v+=this[s+T]*b;return b*=128,v>=b&&(v-=Math.pow(2,8*o)),v},a.prototype.readIntBE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=o,b=1,T=this[s+--v];for(;v>0&&(b*=256);)T+=this[s+--v]*b;return b*=128,T>=b&&(T-=Math.pow(2,8*o)),T},a.prototype.readInt8=function(s,o){return s=s>>>0,o||H(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},a.prototype.readInt16LE=function(s,o){s=s>>>0,o||H(s,2,this.length);const p=this[s]|this[s+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(s,o){s=s>>>0,o||H(s,2,this.length);const p=this[s+1]|this[s]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},a.prototype.readInt32BE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},a.prototype.readBigInt64LE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(p<<24);return(BigInt(v)<<BigInt(32))+BigInt(o+this[++s]*256+this[++s]*65536+this[++s]*16777216)}),a.prototype.readBigInt64BE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(v)<<BigInt(32))+BigInt(this[++s]*16777216+this[++s]*65536+this[++s]*256+p)}),a.prototype.readFloatLE=function(s,o){return s=s>>>0,o||H(s,4,this.length),e.read(this,s,!0,23,4)},a.prototype.readFloatBE=function(s,o){return s=s>>>0,o||H(s,4,this.length),e.read(this,s,!1,23,4)},a.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||H(s,8,this.length),e.read(this,s,!0,52,8)},a.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||H(s,8,this.length),e.read(this,s,!1,52,8)};function it(h,s,o,p,v,b){if(!a.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>v||s<b)throw new RangeError('"value" argument is out of bounds');if(o+p>h.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(s,o,p,v){if(s=+s,o=o>>>0,p=p>>>0,!v){const $=Math.pow(2,8*p)-1;it(this,s,o,p,$,0)}let b=1,T=0;for(this[o]=s&255;++T<p&&(b*=256);)this[o+T]=s/b&255;return o+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(s,o,p,v){if(s=+s,o=o>>>0,p=p>>>0,!v){const $=Math.pow(2,8*p)-1;it(this,s,o,p,$,0)}let b=p-1,T=1;for(this[o+b]=s&255;--b>=0&&(T*=256);)this[o+b]=s/T&255;return o+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,1,255,0),this[o]=s&255,o+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function vt(h,s,o,p,v){ut(s,p,v,h,o,7);let b=Number(s&BigInt(4294967295));h[o++]=b,b=b>>8,h[o++]=b,b=b>>8,h[o++]=b,b=b>>8,h[o++]=b;let T=Number(s>>BigInt(32)&BigInt(4294967295));return h[o++]=T,T=T>>8,h[o++]=T,T=T>>8,h[o++]=T,T=T>>8,h[o++]=T,o}function j(h,s,o,p,v){ut(s,p,v,h,o,7);let b=Number(s&BigInt(4294967295));h[o+7]=b,b=b>>8,h[o+6]=b,b=b>>8,h[o+5]=b,b=b>>8,h[o+4]=b;let T=Number(s>>BigInt(32)&BigInt(4294967295));return h[o+3]=T,T=T>>8,h[o+2]=T,T=T>>8,h[o+1]=T,T=T>>8,h[o]=T,o+8}a.prototype.writeBigUInt64LE=Nt(function(s,o=0){return vt(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Nt(function(s,o=0){return j(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(s,o,p,v){if(s=+s,o=o>>>0,!v){const at=Math.pow(2,8*p-1);it(this,s,o,p,at-1,-at)}let b=0,T=1,$=0;for(this[o]=s&255;++b<p&&(T*=256);)s<0&&$===0&&this[o+b-1]!==0&&($=1),this[o+b]=(s/T>>0)-$&255;return o+p},a.prototype.writeIntBE=function(s,o,p,v){if(s=+s,o=o>>>0,!v){const at=Math.pow(2,8*p-1);it(this,s,o,p,at-1,-at)}let b=p-1,T=1,$=0;for(this[o+b]=s&255;--b>=0&&(T*=256);)s<0&&$===0&&this[o+b+1]!==0&&($=1),this[o+b]=(s/T>>0)-$&255;return o+p},a.prototype.writeInt8=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},a.prototype.writeInt16LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},a.prototype.writeInt16BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},a.prototype.writeInt32LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},a.prototype.writeInt32BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},a.prototype.writeBigInt64LE=Nt(function(s,o=0){return vt(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Nt(function(s,o=0){return j(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Mt(h,s,o,p,v,b){if(o+p>h.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function bt(h,s,o,p,v){return s=+s,o=o>>>0,v||Mt(h,s,o,4),e.write(h,s,o,p,23,4),o+4}a.prototype.writeFloatLE=function(s,o,p){return bt(this,s,o,!0,p)},a.prototype.writeFloatBE=function(s,o,p){return bt(this,s,o,!1,p)};function d(h,s,o,p,v){return s=+s,o=o>>>0,v||Mt(h,s,o,8),e.write(h,s,o,p,52,8),o+8}a.prototype.writeDoubleLE=function(s,o,p){return d(this,s,o,!0,p)},a.prototype.writeDoubleBE=function(s,o,p){return d(this,s,o,!1,p)},a.prototype.copy=function(s,o,p,v){if(!a.isBuffer(s))throw new TypeError("argument should be a Buffer");if(p||(p=0),!v&&v!==0&&(v=this.length),o>=s.length&&(o=s.length),o||(o=0),v>0&&v<p&&(v=p),v===p||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("sourceEnd out of bounds");v>this.length&&(v=this.length),s.length-o<v-p&&(v=s.length-o+p);const b=v-p;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,p,v):Uint8Array.prototype.set.call(s,this.subarray(p,v),o),b},a.prototype.fill=function(s,o,p,v){if(typeof s=="string"){if(typeof o=="string"?(v=o,o=0,p=this.length):typeof p=="string"&&(v=p,p=this.length),v!==void 0&&typeof v!="string")throw new TypeError("encoding must be a string");if(typeof v=="string"&&!a.isEncoding(v))throw new TypeError("Unknown encoding: "+v);if(s.length===1){const T=s.charCodeAt(0);(v==="utf8"&&T<128||v==="latin1")&&(s=T)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<p)throw new RangeError("Out of range index");if(p<=o)return this;o=o>>>0,p=p===void 0?this.length:p>>>0,s||(s=0);let b;if(typeof s=="number")for(b=o;b<p;++b)this[b]=s;else{const T=a.isBuffer(s)?s:a.from(s,v),$=T.length;if($===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(b=0;b<p-o;++b)this[b+o]=T[b%$]}return this};const u={};function B(h,s,o){u[h]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(v){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:v,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}B("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),B("ERR_INVALID_ARG_TYPE",function(h,s){return`The "${h}" argument must be of type number. Received type ${typeof s}`},TypeError),B("ERR_OUT_OF_RANGE",function(h,s,o){let p=`The value of "${h}" is out of range.`,v=o;return Number.isInteger(o)&&Math.abs(o)>4294967296?v=E(String(o)):typeof o=="bigint"&&(v=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(v=E(v)),v+="n"),p+=` It must be ${s}. Received ${v}`,p},RangeError);function E(h){let s="",o=h.length;const p=h[0]==="-"?1:0;for(;o>=p+4;o-=3)s=`_${h.slice(o-3,o)}${s}`;return`${h.slice(0,o)}${s}`}function J(h,s,o){rt(s,"offset"),(h[s]===void 0||h[s+o]===void 0)&&G(s,h.length-(o+1))}function ut(h,s,o,p,v,b){if(h>o||h<s){const T=typeof s=="bigint"?"n":"";let $;throw s===0||s===BigInt(0)?$=`>= 0${T} and < 2${T} ** ${(b+1)*8}${T}`:$=`>= -(2${T} ** ${(b+1)*8-1}${T}) and < 2 ** ${(b+1)*8-1}${T}`,new u.ERR_OUT_OF_RANGE("value",$,h)}J(p,v,b)}function rt(h,s){if(typeof h!="number")throw new u.ERR_INVALID_ARG_TYPE(s,"number",h)}function G(h,s,o){throw Math.floor(h)!==h?(rt(h,o),new u.ERR_OUT_OF_RANGE("offset","an integer",h)):s<0?new u.ERR_BUFFER_OUT_OF_BOUNDS:new u.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,h)}const X=/[^+/0-9A-Za-z-_]/g;function tt(h){if(h=h.split("=")[0],h=h.trim().replace(X,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function q(h,s){s=s||1/0;let o;const p=h.length;let v=null;const b=[];for(let T=0;T<p;++T){if(o=h.charCodeAt(T),o>55295&&o<57344){if(!v){if(o>56319){(s-=3)>-1&&b.push(239,191,189);continue}else if(T+1===p){(s-=3)>-1&&b.push(239,191,189);continue}v=o;continue}if(o<56320){(s-=3)>-1&&b.push(239,191,189),v=o;continue}o=(v-55296<<10|o-56320)+65536}else v&&(s-=3)>-1&&b.push(239,191,189);if(v=null,o<128){if((s-=1)<0)break;b.push(o)}else if(o<2048){if((s-=2)<0)break;b.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;b.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;b.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return b}function ot(h){const s=[];for(let o=0;o<h.length;++o)s.push(h.charCodeAt(o)&255);return s}function xt(h,s){let o,p,v;const b=[];for(let T=0;T<h.length&&!((s-=2)<0);++T)o=h.charCodeAt(T),p=o>>8,v=o%256,b.push(v),b.push(p);return b}function wt(h){return t.toByteArray(tt(h))}function ft(h,s,o,p){let v;for(v=0;v<p&&!(v+o>=s.length||v>=h.length);++v)s[v+o]=h[v];return v}function Et(h,s){return h instanceof s||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===s.name}function Kt(h){return h!==h}const Jt=(function(){const h="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const p=o*16;for(let v=0;v<16;++v)s[p+v]=h[o]+h[v]}return s})();function Nt(h){return typeof BigInt>"u"?ie:h}function ie(){throw new Error("BigInt not supported")}})(Te)),Te}var li;function pr(){return li||(li=1,(function(n,t){var e=ai(),i=e.Buffer;function r(c,a){for(var g in c)a[g]=c[g]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=e:(r(e,t),t.Buffer=l);function l(c,a,g){return i(c,a,g)}l.prototype=Object.create(i.prototype),r(i,l),l.from=function(c,a,g){if(typeof c=="number")throw new TypeError("Argument must not be a number");return i(c,a,g)},l.alloc=function(c,a,g){if(typeof c!="number")throw new TypeError("Argument must be a number");var S=i(c);return a!==void 0?typeof g=="string"?S.fill(a,g):S.fill(a):S.fill(0),S},l.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return i(c)},l.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(c)}})(de,de.exports)),de.exports}var ci;function mr(){if(ci)return Ae;ci=1;var n=pr().Buffer,t=n.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(m){if(!m)return"utf8";for(var x;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(x)return;m=(""+m).toLowerCase(),x=!0}}function i(m){var x=e(m);if(typeof x!="string"&&(n.isEncoding===t||!t(m)))throw new Error("Unknown encoding: "+m);return x||m}Ae.StringDecoder=r;function r(m){this.encoding=i(m);var x;switch(this.encoding){case"utf16le":this.text=C,this.end=M,x=4;break;case"utf8":this.fillLast=g,x=4;break;case"base64":this.text=N,this.end=F,x=3;break;default:this.write=k,this.end=R;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(x)}r.prototype.write=function(m){if(m.length===0)return"";var x,y;if(this.lastNeed){if(x=this.fillLast(m),x===void 0)return"";y=this.lastNeed,this.lastNeed=0}else y=0;return y<m.length?x?x+this.text(m,y):this.text(m,y):x||""},r.prototype.end=w,r.prototype.text=S,r.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function l(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function c(m,x,y){var f=x.length-1;if(f<y)return 0;var A=l(x[f]);return A>=0?(A>0&&(m.lastNeed=A-1),A):--f<y||A===-2?0:(A=l(x[f]),A>=0?(A>0&&(m.lastNeed=A-2),A):--f<y||A===-2?0:(A=l(x[f]),A>=0?(A>0&&(A===2?A=0:m.lastNeed=A-3),A):0))}function a(m,x,y){if((x[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return m.lastNeed=2,"�"}}function g(m){var x=this.lastTotal-this.lastNeed,y=a(this,m);if(y!==void 0)return y;if(this.lastNeed<=m.length)return m.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,x,0,m.length),this.lastNeed-=m.length}function S(m,x){var y=c(this,m,x);if(!this.lastNeed)return m.toString("utf8",x);this.lastTotal=y;var f=m.length-(y-this.lastNeed);return m.copy(this.lastChar,0,f),m.toString("utf8",x,f)}function w(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+"�":x}function C(m,x){if((m.length-x)%2===0){var y=m.toString("utf16le",x);if(y){var f=y.charCodeAt(y.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],y.slice(0,-1)}return y}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",x,m.length-1)}function M(m){var x=m&&m.length?this.write(m):"";if(this.lastNeed){var y=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,y)}return x}function N(m,x){var y=(m.length-x)%3;return y===0?m.toString("base64",x):(this.lastNeed=3-y,this.lastTotal=3,y===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",x,m.length-y))}function F(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function k(m){return m.toString(this.encoding)}function R(m){return m&&m.length?this.write(m):""}return Ae}var ui;function yr(){return ui||(ui=1,(function(n){(function(t){t.parser=function(d,u){return new i(d,u)},t.SAXParser=i,t.SAXStream=w,t.createStream=S,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(d,u){if(!(this instanceof i))return new i(d,u);var B=this;l(B),B.q=B.c="",B.bufferCheckPosition=t.MAX_BUFFER_LENGTH,B.opt=u||{},B.opt.lowercase=B.opt.lowercase||B.opt.lowercasetags,B.looseCase=B.opt.lowercase?"toLowerCase":"toUpperCase",B.tags=[],B.closed=B.closedRoot=B.sawRoot=!1,B.tag=B.error=null,B.strict=!!d,B.noscript=!!(d||B.opt.noscript),B.state=_.BEGIN,B.strictEntities=B.opt.strictEntities,B.ENTITIES=B.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),B.attribList=[],B.opt.xmlns&&(B.ns=Object.create(k)),B.opt.unquotedAttributeValues===void 0&&(B.opt.unquotedAttributeValues=!d),B.trackPosition=B.opt.position!==!1,B.trackPosition&&(B.position=B.line=B.column=0),V(B,"onready")}Object.create||(Object.create=function(d){function u(){}u.prototype=d;var B=new u;return B}),Object.keys||(Object.keys=function(d){var u=[];for(var B in d)d.hasOwnProperty(B)&&u.push(B);return u});function r(d){for(var u=Math.max(t.MAX_BUFFER_LENGTH,10),B=0,E=0,J=e.length;E<J;E++){var ut=d[e[E]].length;if(ut>u)switch(e[E]){case"textNode":K(d);break;case"cdata":z(d,"oncdata",d.cdata),d.cdata="";break;case"script":z(d,"onscript",d.script),d.script="";break;default:Q(d,"Max buffer length exceeded: "+e[E])}B=Math.max(B,ut)}var rt=t.MAX_BUFFER_LENGTH-B;d.bufferCheckPosition=rt+d.position}function l(d){for(var u=0,B=e.length;u<B;u++)d[e[u]]=""}function c(d){K(d),d.cdata!==""&&(z(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(z(d,"onscript",d.script),d.script="")}i.prototype={end:function(){W(this)},write:bt,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){c(this)}};var a;try{a=hr.Stream}catch{a=function(){}}a||(a=function(){});var g=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function S(d,u){return new w(d,u)}function w(d,u){if(!(this instanceof w))return new w(d,u);a.apply(this),this._parser=new i(d,u),this.writable=!0,this.readable=!0;var B=this;this._parser.onend=function(){B.emit("end")},this._parser.onerror=function(E){B.emit("error",E),B._parser.error=null},this._decoder=null,g.forEach(function(E){Object.defineProperty(B,"on"+E,{get:function(){return B._parser["on"+E]},set:function(J){if(!J)return B.removeAllListeners(E),B._parser["on"+E]=J,J;B.on(E,J)},enumerable:!0,configurable:!1})})}w.prototype=Object.create(a.prototype,{constructor:{value:w}}),w.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var u=mr().StringDecoder;this._decoder=new u("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},w.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},w.prototype.on=function(d,u){var B=this;return!B._parser["on"+d]&&g.indexOf(d)!==-1&&(B._parser["on"+d]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,d),B.emit.apply(B,E)}),a.prototype.on.call(B,d,u)};var C="[CDATA[",M="DOCTYPE",N="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",k={xml:N,xmlns:F},R=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,x=/[#:_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]/,y=/[#:_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 f(d){return d===" "||d===`
|
|
87
|
+
`||d==="\r"||d===" "}function A(d){return d==='"'||d==="'"}function P(d){return d===">"||f(d)}function I(d,u){return d.test(u)}function O(d,u){return!I(d,u)}var _=0;t.STATE={BEGIN:_++,BEGIN_WHITESPACE:_++,TEXT:_++,TEXT_ENTITY:_++,OPEN_WAKA:_++,SGML_DECL:_++,SGML_DECL_QUOTED:_++,DOCTYPE:_++,DOCTYPE_QUOTED:_++,DOCTYPE_DTD:_++,DOCTYPE_DTD_QUOTED:_++,COMMENT_STARTING:_++,COMMENT:_++,COMMENT_ENDING:_++,COMMENT_ENDED:_++,CDATA:_++,CDATA_ENDING:_++,CDATA_ENDING_2:_++,PROC_INST:_++,PROC_INST_BODY:_++,PROC_INST_ENDING:_++,OPEN_TAG:_++,OPEN_TAG_SLASH:_++,ATTRIB:_++,ATTRIB_NAME:_++,ATTRIB_NAME_SAW_WHITE:_++,ATTRIB_VALUE:_++,ATTRIB_VALUE_QUOTED:_++,ATTRIB_VALUE_CLOSED:_++,ATTRIB_VALUE_UNQUOTED:_++,ATTRIB_VALUE_ENTITY_Q:_++,ATTRIB_VALUE_ENTITY_U:_++,CLOSE_TAG:_++,CLOSE_TAG_SAW_WHITE:_++,SCRIPT:_++,SCRIPT_ENDING:_++},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(d){var u=t.ENTITIES[d],B=typeof u=="number"?String.fromCharCode(u):u;t.ENTITIES[d]=B});for(var U in t.STATE)t.STATE[t.STATE[U]]=U;_=t.STATE;function V(d,u,B){d[u]&&d[u](B)}function z(d,u,B){d.textNode&&K(d),V(d,u,B)}function K(d){d.textNode=et(d.opt,d.textNode),d.textNode&&V(d,"ontext",d.textNode),d.textNode=""}function et(d,u){return d.trim&&(u=u.trim()),d.normalize&&(u=u.replace(/\s+/g," ")),u}function Q(d,u){return K(d),d.trackPosition&&(u+=`
|
|
88
88
|
Line: `+d.line+`
|
|
89
89
|
Column: `+d.column+`
|
|
90
|
-
Char: `+d.c),
|
|
91
|
-
Actual: `+d.attribValue);else if(E==="xmlns"&&d.attribValue!==F)
|
|
92
|
-
Actual: `+d.attribValue);else{var
|
|
93
|
-
`?(
|
|
94
|
-
`?(l.line++,l.column=0):l.column++);l.textNode+=d.substring(Q,M-1)}E==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):(!f(E)&&(!l.sawRoot||l.closedRoot)&&K(l,"Text data outside of root node."),E==="&"?l.state=g.TEXT_ENTITY:l.textNode+=E);continue;case g.SCRIPT:E==="<"?l.state=g.SCRIPT_ENDING:l.script+=E;continue;case g.SCRIPT_ENDING:E==="/"?l.state=g.CLOSE_TAG:(l.script+="<"+E,l.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(E==="!")l.state=g.SGML_DECL,l.sgmlDecl="";else if(!f(E))if(k(N,E))l.state=g.OPEN_TAG,l.tagName=E;else if(E==="/")l.state=g.CLOSE_TAG,l.tagName="";else if(E==="?")l.state=g.PROC_INST,l.procInstName=l.procInstBody="";else{if(K(l,"Unencoded <"),l.startTagPosition+1<l.position){var lt=l.position-l.startTagPosition;E=new Array(lt).join(" ")+E}l.textNode+="<"+E,l.state=g.TEXT}continue;case g.SGML_DECL:if(l.sgmlDecl+E==="--"){l.state=g.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=g.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+E,l.sgmlDecl=""):(l.sgmlDecl+E).toUpperCase()===B?(G(l,"onopencdata"),l.state=g.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+E).toUpperCase()===A?(l.state=g.DOCTYPE,(l.doctype||l.sawRoot)&&K(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):E===">"?(G(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=g.TEXT):(b(E)&&(l.state=g.SGML_DECL_QUOTED),l.sgmlDecl+=E);continue;case g.SGML_DECL_QUOTED:E===l.q&&(l.state=g.SGML_DECL,l.q=""),l.sgmlDecl+=E;continue;case g.DOCTYPE:E===">"?(l.state=g.TEXT,G(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=E,E==="["?l.state=g.DOCTYPE_DTD:b(E)&&(l.state=g.DOCTYPE_QUOTED,l.q=E));continue;case g.DOCTYPE_QUOTED:l.doctype+=E,E===l.q&&(l.q="",l.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:E==="]"?(l.doctype+=E,l.state=g.DOCTYPE):E==="<"?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):b(E)?(l.doctype+=E,l.state=g.DOCTYPE_DTD_QUOTED,l.q=E):l.doctype+=E;continue;case g.DOCTYPE_DTD_QUOTED:l.doctype+=E,E===l.q&&(l.state=g.DOCTYPE_DTD,l.q="");continue;case g.COMMENT:E==="-"?l.state=g.COMMENT_ENDING:l.comment+=E;continue;case g.COMMENT_ENDING:E==="-"?(l.state=g.COMMENT_ENDED,l.comment=ft(l.opt,l.comment),l.comment&&G(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+E,l.state=g.COMMENT);continue;case g.COMMENT_ENDED:E!==">"?(K(l,"Malformed comment"),l.comment+="--"+E,l.state=g.COMMENT):l.doctype&&l.doctype!==!0?l.state=g.DOCTYPE_DTD:l.state=g.TEXT;continue;case g.CDATA:E==="]"?l.state=g.CDATA_ENDING:l.cdata+=E;continue;case g.CDATA_ENDING:E==="]"?l.state=g.CDATA_ENDING_2:(l.cdata+="]"+E,l.state=g.CDATA);continue;case g.CDATA_ENDING_2:E===">"?(l.cdata&&G(l,"oncdata",l.cdata),G(l,"onclosecdata"),l.cdata="",l.state=g.TEXT):E==="]"?l.cdata+="]":(l.cdata+="]]"+E,l.state=g.CDATA);continue;case g.PROC_INST:E==="?"?l.state=g.PROC_INST_ENDING:f(E)?l.state=g.PROC_INST_BODY:l.procInstName+=E;continue;case g.PROC_INST_BODY:if(!l.procInstBody&&f(E))continue;E==="?"?l.state=g.PROC_INST_ENDING:l.procInstBody+=E;continue;case g.PROC_INST_ENDING:E===">"?(G(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=g.TEXT):(l.procInstBody+="?"+E,l.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:k(m,E)?l.tagName+=E:(gt(l),E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:(f(E)||K(l,"Invalid character in tag name"),l.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:E===">"?(W(l,!0),tt(l)):(K(l,"Forward-slash in opening tag not followed by >"),l.state=g.ATTRIB);continue;case g.ATTRIB:if(f(E))continue;E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:k(N,E)?(l.attribName=E,l.attribValue="",l.state=g.ATTRIB_NAME):K(l,"Invalid attribute name");continue;case g.ATTRIB_NAME:E==="="?l.state=g.ATTRIB_VALUE:E===">"?(K(l,"Attribute without value"),l.attribValue=l.attribName,mt(l),W(l)):f(E)?l.state=g.ATTRIB_NAME_SAW_WHITE:k(m,E)?l.attribName+=E:K(l,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(E==="=")l.state=g.ATTRIB_VALUE;else{if(f(E))continue;K(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",G(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",E===">"?W(l):k(N,E)?(l.attribName=E,l.state=g.ATTRIB_NAME):(K(l,"Invalid attribute name"),l.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(f(E))continue;b(E)?(l.q=E,l.state=g.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||at(l,"Unquoted attribute value"),l.state=g.ATTRIB_VALUE_UNQUOTED,l.attribValue=E);continue;case g.ATTRIB_VALUE_QUOTED:if(E!==l.q){E==="&"?l.state=g.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=E;continue}mt(l),l.q="",l.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:f(E)?l.state=g.ATTRIB:E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:k(N,E)?(K(l,"No whitespace between attributes"),l.attribName=E,l.attribValue="",l.state=g.ATTRIB_NAME):K(l,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!O(E)){E==="&"?l.state=g.ATTRIB_VALUE_ENTITY_U:l.attribValue+=E;continue}mt(l),E===">"?W(l):l.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(l.tagName)E===">"?tt(l):k(m,E)?l.tagName+=E:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=g.SCRIPT):(f(E)||K(l,"Invalid tagname in closing tag"),l.state=g.CLOSE_TAG_SAW_WHITE);else{if(f(E))continue;L(N,E)?l.script?(l.script+="</"+E,l.state=g.SCRIPT):K(l,"Invalid tagname in closing tag."):l.tagName=E}continue;case g.CLOSE_TAG_SAW_WHITE:if(f(E))continue;E===">"?tt(l):K(l,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var it,U;switch(l.state){case g.TEXT_ENTITY:it=g.TEXT,U="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:it=g.ATTRIB_VALUE_QUOTED,U="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:it=g.ATTRIB_VALUE_UNQUOTED,U="attribValue";break}if(E===";"){var z=Tt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(z)?(l.entity="",l.state=it,l.write(z)):(l[U]+=z,l.entity="",l.state=it)}else k(l.entity.length?_:x,E)?l.entity+=E:(K(l,"Invalid character in entity name"),l[U]+="&"+l.entity+E,l.entity="",l.state=it);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}String.fromCodePoint||(function(){var d=String.fromCharCode,l=Math.floor,M=function(){var E=16384,Q=[],lt,it,U=-1,z=arguments.length;if(!z)return"";for(var X="";++U<z;){var j=Number(arguments[U]);if(!isFinite(j)||j<0||j>1114111||l(j)!==j)throw RangeError("Invalid code point: "+j);j<=65535?Q.push(j):(j-=65536,lt=(j>>10)+55296,it=j%1024+56320,Q.push(lt,it)),(U+1===z||Q.length>E)&&(X+=d.apply(null,Q),Q.length=0)}return X};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:M,configurable:!0,writable:!0}):String.fromCodePoint=M})()})(u)})(he)),he}var pe,He;function me(){return He||(He=1,pe={isArray:function(u){return Array.isArray?Array.isArray(u):Object.prototype.toString.call(u)==="[object Array]"}}),pe}var _e,Xe;function ye(){if(Xe)return _e;Xe=1;var u=me().isArray;return _e={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"&&!u(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}},_e}var ge,$e;function Qe(){if($e)return ge;$e=1;var u=Ki(),t=ye(),e=me().isArray,i,s;function c(m){return i=t.copyOptions(m),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function o(m){var x=Number(m);if(!isNaN(x))return x;var _=m.toLowerCase();return _==="true"?!0:_==="false"?!1:m}function a(m,x){var _;if(i.compact){if(!s[i[m+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[m+"Key"])!==-1:i.alwaysArray)&&(s[i[m+"Key"]]=[]),s[i[m+"Key"]]&&!e(s[i[m+"Key"]])&&(s[i[m+"Key"]]=[s[i[m+"Key"]]]),m+"Fn"in i&&typeof x=="string"&&(x=i[m+"Fn"](x,s)),m==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(_ in x)if(x.hasOwnProperty(_))if("instructionFn"in i)x[_]=i.instructionFn(x[_],_,s);else{var f=x[_];delete x[_],x[i.instructionNameFn(_,f,s)]=f}}e(s[i[m+"Key"]])?s[i[m+"Key"]].push(x):s[i[m+"Key"]]=x}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=m,m==="instruction"){for(_ in x)if(x.hasOwnProperty(_))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(_,x,s):_,i.instructionHasAttributes?(b[i.attributesKey]=x[_][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],_,s))):("instructionFn"in i&&(x[_]=i.instructionFn(x[_],_,s)),b[i.instructionKey]=x[_])}else m+"Fn"in i&&(x=i[m+"Fn"](x,s)),b[i[m+"Key"]]=x;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function y(m){if("attributesFn"in i&&m&&(m=i.attributesFn(m,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&m){var x;for(x in m)if(m.hasOwnProperty(x)&&(i.trim&&(m[x]=m[x].trim()),i.nativeTypeAttributes&&(m[x]=o(m[x])),"attributeValueFn"in i&&(m[x]=i.attributeValueFn(m[x],x,s)),"attributeNameFn"in i)){var _=m[x];delete m[x],m[i.attributeNameFn(x,m[x],s)]=_}}return m}function C(m){var x={};if(m.body&&(m.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var _=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=_.exec(m.body))!==null;)x[f[1]]=f[2]||f[3]||f[4];x=y(x)}if(m.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(x).length&&(s[i.declarationKey][i.attributesKey]=x),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(m.body=m.body.trim());var b={};i.instructionHasAttributes&&Object.keys(x).length?(b[m.name]={},b[m.name][i.attributesKey]=x):b[m.name]=m.body,a("instruction",b)}}function S(m,x){var _;if(typeof m=="object"&&(x=m.attributes,m=m.name),x=y(x),"elementNameFn"in i&&(m=i.elementNameFn(m,s)),i.compact){if(_={},!i.ignoreAttributes&&x&&Object.keys(x).length){_[i.attributesKey]={};var f;for(f in x)x.hasOwnProperty(f)&&(_[i.attributesKey][f]=x[f])}!(m in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(m)!==-1:i.alwaysArray)&&(s[m]=[]),s[m]&&!e(s[m])&&(s[m]=[s[m]]),e(s[m])?s[m].push(_):s[m]=_}else s[i.elementsKey]||(s[i.elementsKey]=[]),_={},_[i.typeKey]="element",_[i.nameKey]=m,!i.ignoreAttributes&&x&&Object.keys(x).length&&(_[i.attributesKey]=x),i.alwaysChildren&&(_[i.elementsKey]=[]),s[i.elementsKey].push(_);_[i.parentKey]=s,s=_}function B(m){i.ignoreText||!m.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(m=m.trim()),i.nativeType&&(m=o(m)),i.sanitize&&(m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),a("text",m))}function A(m){i.ignoreComment||(i.trim&&(m=m.trim()),a("comment",m))}function D(m){var x=s[i.parentKey];i.addParent||delete s[i.parentKey],s=x}function F(m){i.ignoreCdata||(i.trim&&(m=m.trim()),a("cdata",m))}function R(m){i.ignoreDoctype||(m=m.replace(/^ /,""),i.trim&&(m=m.trim()),a("doctype",m))}function N(m){m.note=m}return ge=function(m,x){var _=u.parser(!0,{}),f={};if(s=f,i=c(x),_.opt={strictEntities:!0},_.onopentag=S,_.ontext=B,_.oncomment=A,_.onclosetag=D,_.onerror=N,_.oncdata=F,_.ondoctype=R,_.onprocessinginstruction=C,_.write(m).close(),f[i.elementsKey]){var b=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=b,delete f.text}return f},ge}var xe,Je;function qi(){if(Je)return xe;Je=1;var u=ye(),t=Qe();function e(i){var s=u.copyOptions(i);return u.ensureSpacesExists(s),s}return xe=function(i,s){var c,o,a,y;return c=e(s),o=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?a=JSON.stringify(o,function(C,S){return C===y?"_":S},c.spaces):a=JSON.stringify(o,null,c.spaces),a.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},xe}var we,Ze;function ti(){if(Ze)return we;Ze=1;var u=ye(),t=me().isArray,e,i;function s(_){var f=u.copyOptions(_);return u.ensureFlagExists("ignoreDeclaration",f),u.ensureFlagExists("ignoreInstruction",f),u.ensureFlagExists("ignoreAttributes",f),u.ensureFlagExists("ignoreText",f),u.ensureFlagExists("ignoreComment",f),u.ensureFlagExists("ignoreCdata",f),u.ensureFlagExists("ignoreDoctype",f),u.ensureFlagExists("compact",f),u.ensureFlagExists("indentText",f),u.ensureFlagExists("indentCdata",f),u.ensureFlagExists("indentAttributes",f),u.ensureFlagExists("indentInstruction",f),u.ensureFlagExists("fullTagEmptyElement",f),u.ensureFlagExists("noQuotesForNativeAttributes",f),u.ensureSpacesExists(f),typeof f.spaces=="number"&&(f.spaces=Array(f.spaces+1).join(" ")),u.ensureKeyExists("declaration",f),u.ensureKeyExists("instruction",f),u.ensureKeyExists("attributes",f),u.ensureKeyExists("text",f),u.ensureKeyExists("comment",f),u.ensureKeyExists("cdata",f),u.ensureKeyExists("doctype",f),u.ensureKeyExists("type",f),u.ensureKeyExists("name",f),u.ensureKeyExists("elements",f),u.checkFnExists("doctype",f),u.checkFnExists("instruction",f),u.checkFnExists("cdata",f),u.checkFnExists("comment",f),u.checkFnExists("text",f),u.checkFnExists("instructionName",f),u.checkFnExists("elementName",f),u.checkFnExists("attributeName",f),u.checkFnExists("attributeValue",f),u.checkFnExists("attributes",f),u.checkFnExists("fullTagEmptyElement",f),f}function c(_,f,b){return(!b&&_.spaces?`
|
|
95
|
-
`:"")+Array(f+1).join(
|
|
96
|
-
`+Array(b+1).join(f.spaces):""),O.push("</"+k+">")):O.push("/>"),O.join("")}function R(_,f,b,O){return _.reduce(function(k,L){var g=c(f,b,O&&!k);switch(L.type){case"element":return k+g+F(L,f,b);case"comment":return k+g+C(L[f.commentKey],f);case"doctype":return k+g+B(L[f.doctypeKey],f);case"cdata":return k+(f.indentCdata?g:"")+S(L[f.cdataKey],f);case"text":return k+(f.indentText?g:"")+A(L[f.textKey],f);case"instruction":var q={};return q[L[f.nameKey]]=L[f.attributesKey]?L:L[f.instructionKey],k+(f.indentInstruction?g:"")+y(q,f,b)}},"")}function N(_,f,b){var O;for(O in _)if(_.hasOwnProperty(O))switch(O){case f.parentKey:case f.attributesKey:break;case f.textKey:if(f.indentText||b)return!0;break;case f.cdataKey:if(f.indentCdata||b)return!0;break;case f.instructionKey:if(f.indentInstruction||b)return!0;break;case f.doctypeKey:case f.commentKey:return!0;default:return!0}return!1}function m(_,f,b,O,k){e=_,i=f;var L="elementNameFn"in b?b.elementNameFn(f,_):f;if(typeof _>"u"||_===null||_==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(f,_)||b.fullTagEmptyElement?"<"+L+"></"+L+">":"<"+L+"/>";var g=[];if(f){if(g.push("<"+L),typeof _!="object")return g.push(">"+A(_,b)+"</"+L+">"),g.join("");_[b.attributesKey]&&g.push(o(_[b.attributesKey],b,O));var q=N(_,b,!0)||_[b.attributesKey]&&_[b.attributesKey]["xml:space"]==="preserve";if(q||("fullTagEmptyElementFn"in b?q=b.fullTagEmptyElementFn(f,_):q=b.fullTagEmptyElement),q)g.push(">");else return g.push("/>"),g.join("")}return g.push(x(_,b,O+1,!1)),e=_,i=f,f&&g.push((k?c(b,O,!1):"")+"</"+L+">"),g.join("")}function x(_,f,b,O){var k,L,g,q=[];for(L in _)if(_.hasOwnProperty(L))for(g=t(_[L])?_[L]:[_[L]],k=0;k<g.length;++k){switch(L){case f.declarationKey:q.push(a(g[k],f,b));break;case f.instructionKey:q.push((f.indentInstruction?c(f,b,O):"")+y(g[k],f,b));break;case f.attributesKey:case f.parentKey:break;case f.textKey:q.push((f.indentText?c(f,b,O):"")+A(g[k],f));break;case f.cdataKey:q.push((f.indentCdata?c(f,b,O):"")+S(g[k],f));break;case f.doctypeKey:q.push(c(f,b,O)+B(g[k],f));break;case f.commentKey:q.push(c(f,b,O)+C(g[k],f));break;default:q.push(c(f,b,O)+m(g[k],L,f,b,N(g[k],f)))}O=O&&!q.length}return q.join("")}return we=function(_,f){f=s(f);var b=[];return e=_,i="_root_",f.compact?b.push(x(_,f,0,!0)):(_[f.declarationKey]&&b.push(a(_[f.declarationKey],f,0)),_[f.elementsKey]&&_[f.elementsKey].length&&b.push(R(_[f.elementsKey],f,0,!b.length))),b.join("")},we}var Ee,ei;function Wi(){if(ei)return Ee;ei=1;var u=ti();return Ee=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 u(i,e)},Ee}var ve,ii;function Hi(){if(ii)return ve;ii=1;var u=Qe(),t=qi(),e=ti(),i=Wi();return ve={xml2js:u,xml2json:t,js2xml:e,json2xml:i},ve}var Se=Hi(),Xi=je();const bt=class bt{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 o={...s,...c,...bt.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"]),...bt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(o.properties){const y=bt.toArray(o.properties.property),C={};for(let S of y){const B=S._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(S)?.properties??{},_classname:B.propertytype};break;default:A=B.value}C[B.name]=A}o.properties=C}o.polygon&&(o.polygon=this.transform(o.polygon)),o.polyline&&(o.polyline=this.transform(o.polyline)),o.points&&(o=o.points.split(" ").map(y=>{const C=y.split(",");return{x:+C[0],y:+C[1]}})),o.point&&(o.point=!0),o.ellipse&&(o.ellipse=!0),o.text&&(o.text={text:o.text._text,...this.transform(o.text)},delete o.text._text),o.image&&(o.image=this.transform(o.image)),o.source&&(this.isTilesetSource(o)||(o.source=this.getImagePath(o.source)));const a=o.object||o.objectgroup?.object;return a&&(o.objects=bt.toArray(a).map(y=>this.transform(y))),delete o._attributes,delete o.attributes,delete o.object,delete o.objectgroup,o}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:Ve(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 o=0;o<i;o+=4)c[s]=t.readUInt32LE(o),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?bt.unpackTileBytes(Xi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=Se.xml2js(this.xml,{compact:!0}),e=Se.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=C=>{const{objectgroup:S,group:B,layer:A,imagelayer:D}=C,F=R=>{R&&bt.toArray(R).forEach(N=>{if(this.layers.has(+N._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${N._attributes.id} already exists`);this.layers.set(+N._attributes.id,N)})};F(S),F(A),F(B),F(D),B&&s(B)};s(t.map);const c=(C,S=[])=>{if(!C)return S;for(let B of C){const{name:A}=B;if(!["layer","group","imagelayer","objectgroup"].includes(A))continue;const D=B.elements?.find(R=>R.name=="data");B.layer=this.layers.get(+B.attributes.id);const F={...this.transform(D)??{},...this.transform(B),...this.transform(B.layer),layers:c(B.elements),data:D?D.elements[0].text:void 0,type:A=="layer"?"tilelayer":A};delete F.elements,delete F.layer,F.data&&(F.data=bt.decode(F,F.width*F.height)),S.push(F)}return S},o=c(e.elements[0].elements),a=bt.toArray(i).map(C=>this.transform(C)),y={...this.transform(t.map),layers:o,tilesets:a};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=Se.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:bt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=bt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};bt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},bt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let Te=bt;class be{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 $i=2147483648,Qi=1073741824,Ji=536870912,Zi=268435456;class $t extends be{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&$i)}get verticalFlip(){return!!(this._gid&Qi)}get diagonalFlip(){return!!(this._gid&Ji)}get rotatedHex120(){return!!(this._gid&Zi)}get gid(){return $t.getRealGid(this._gid)}set gid(t){this._gid=t}}let Ae=class extends $t{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 tr extends $t{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class Ce extends be{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=$t.getRealGid(t),c=Ce.findTileSet(s,this.tilesets);if(!c)return;const o=c.getTile(s-c.firstgid);return o?new Ae({...o.tile,gid:t,index:e,layerIndex:i}):new Ae({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 tr(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 er extends be{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 Ae(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class kt{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=a=>kt.typeOfFile(a).isXml,c=a=>{if(!a)return i(null);if(s(a)){const y=new Te(a,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(a))};if(kt.typeOfFile(t).isObject)return i(t);const{isHttp:o}=kt.typeOfFile(t);if(s(t))c(t);else if(o||kt.isBrowser()){let a=o?t:Ve(this.basePath,t);kt.isBrowser()&&window.urlCache&&(a=window.urlCache[t]),fetch(a,{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&&kt.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,o)=>{let a=!1;if(o)return t(null,o);if(c.tilesets){const y=[],C=()=>{S++,S==c.tilesets.length&&!a&&(c.tilesets=y,t(c))};let S=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&&kt.typeOfFile(A.source).isPath&&(A.source=s(A.source)),this._parseFile(A.source,"tileset",(D,F)=>{if(F)return a=!0,t(null,F);y[B]={...D,firstgid:A.firstgid},C()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const Ut={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var ir=Object.defineProperty,rr=(u,t,e)=>t in u?ir(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Lt=(u,t,e)=>(rr(u,typeof t!="symbol"?t+"":t,e),e);const Qt=class Zt 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=Zt.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}}}),Lt(this,"lastTimeAccess",0),Lt(this,"vertSize",Zt.vertSize),Lt(this,"vertPerQuad",Zt.vertPerQuad),Lt(this,"stride",Zt.stride),Lt(this,"buf"),this.buf=e}};Lt(Qt,"vertSize",13),Lt(Qt,"vertPerQuad",4),Lt(Qt,"stride",Qt.vertSize*4);let nr=Qt;var sr=Object.defineProperty,ar=(u,t,e)=>t in u?sr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Vt=(u,t,e)=>(ar(u,typeof t!="symbol"?t+"":t,e),e);class ri{constructor(){Vt(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 ni{constructor(t,e){Vt(this,"renderer"),Vt(this,"tileAnim",[0,0]),Vt(this,"ibLen",0),Vt(this,"indexBuffer",null),Vt(this,"shader"),Vt(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 nr(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=or(t,Ut.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:o}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),o[0]=c[0],o[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Vt(ni,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function or(u,t){const e=u*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 lr=Object.defineProperty,cr=(u,t,e)=>t in u?lr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Ot=(u,t,e)=>(cr(u,typeof t!="symbol"?t+"":t,e),e);class zt{constructor(t){Ot(this,"max_textures"),Ot(this,"arr",[]),Ot(this,"count",0),Ot(this,"dirty",!1),Ot(this,"dirty_gpu",!1),Ot(this,"bind_group",null),Ot(this,"bind_group_resources",{}),Ot(this,"tex_sizes",null),Ot(this,"null_color",new Float32Array([0,0,0,.5])),Ot(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 o=0;o<i;o++){const a=e[o];a&&(t[o*4]=a.pixelWidth,t[o*4+1]=a.pixelHeight,t[o*4+2]=1/a.pixelWidth,t[o*4+3]=1/a.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 o=0;o<e;o++){const a=(o<s?i[o]:null)||P.Texture.EMPTY.source;t[c++]=a.source,t[c++]=a.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(`
|
|
90
|
+
Char: `+d.c),u=new Error(u),d.error=u,V(d,"onerror",u),d}function W(d){return d.sawRoot&&!d.closedRoot&&Y(d,"Unclosed root tag"),d.state!==_.BEGIN&&d.state!==_.BEGIN_WHITESPACE&&d.state!==_.TEXT&&Q(d,"Unexpected end"),K(d),d.c="",d.closed=!0,V(d,"onend"),i.call(d,d.strict,d.opt),d}function Y(d,u){if(typeof d!="object"||!(d instanceof i))throw new Error("bad call to strictFail");d.strict&&Q(d,u)}function Z(d){d.strict||(d.tagName=d.tagName[d.looseCase]());var u=d.tags[d.tags.length-1]||d,B=d.tag={name:d.tagName,attributes:{}};d.opt.xmlns&&(B.ns=u.ns),d.attribList.length=0,z(d,"onopentagstart",B)}function yt(d,u){var B=d.indexOf(":"),E=B<0?["",d]:d.split(":"),J=E[0],ut=E[1];return u&&d==="xmlns"&&(J="xmlns",ut=""),{prefix:J,local:ut}}function ct(d){if(d.strict||(d.attribName=d.attribName[d.looseCase]()),d.attribList.indexOf(d.attribName)!==-1||d.tag.attributes.hasOwnProperty(d.attribName)){d.attribName=d.attribValue="";return}if(d.opt.xmlns){var u=yt(d.attribName,!0),B=u.prefix,E=u.local;if(B==="xmlns")if(E==="xml"&&d.attribValue!==N)Y(d,"xml: prefix must be bound to "+N+`
|
|
91
|
+
Actual: `+d.attribValue);else if(E==="xmlns"&&d.attribValue!==F)Y(d,"xmlns: prefix must be bound to "+F+`
|
|
92
|
+
Actual: `+d.attribValue);else{var J=d.tag,ut=d.tags[d.tags.length-1]||d;J.ns===ut.ns&&(J.ns=Object.create(ut.ns)),J.ns[E]=d.attribValue}d.attribList.push([d.attribName,d.attribValue])}else d.tag.attributes[d.attribName]=d.attribValue,z(d,"onattribute",{name:d.attribName,value:d.attribValue});d.attribName=d.attribValue=""}function H(d,u){if(d.opt.xmlns){var B=d.tag,E=yt(d.tagName);B.prefix=E.prefix,B.local=E.local,B.uri=B.ns[E.prefix]||"",B.prefix&&!B.uri&&(Y(d,"Unbound namespace prefix: "+JSON.stringify(d.tagName)),B.uri=E.prefix);var J=d.tags[d.tags.length-1]||d;B.ns&&J.ns!==B.ns&&Object.keys(B.ns).forEach(function(Et){z(d,"onopennamespace",{prefix:Et,uri:B.ns[Et]})});for(var ut=0,rt=d.attribList.length;ut<rt;ut++){var G=d.attribList[ut],X=G[0],tt=G[1],q=yt(X,!0),ot=q.prefix,xt=q.local,wt=ot===""?"":B.ns[ot]||"",ft={name:X,value:tt,prefix:ot,local:xt,uri:wt};ot&&ot!=="xmlns"&&!wt&&(Y(d,"Unbound namespace prefix: "+JSON.stringify(ot)),ft.uri=ot),d.tag.attributes[X]=ft,z(d,"onattribute",ft)}d.attribList.length=0}d.tag.isSelfClosing=!!u,d.sawRoot=!0,d.tags.push(d.tag),z(d,"onopentag",d.tag),u||(!d.noscript&&d.tagName.toLowerCase()==="script"?d.state=_.SCRIPT:d.state=_.TEXT,d.tag=null,d.tagName=""),d.attribName=d.attribValue="",d.attribList.length=0}function it(d){if(!d.tagName){Y(d,"Weird empty close tag."),d.textNode+="</>",d.state=_.TEXT;return}if(d.script){if(d.tagName!=="script"){d.script+="</"+d.tagName+">",d.tagName="",d.state=_.SCRIPT;return}z(d,"onscript",d.script),d.script=""}var u=d.tags.length,B=d.tagName;d.strict||(B=B[d.looseCase]());for(var E=B;u--;){var J=d.tags[u];if(J.name!==E)Y(d,"Unexpected close tag");else break}if(u<0){Y(d,"Unmatched closing tag: "+d.tagName),d.textNode+="</"+d.tagName+">",d.state=_.TEXT;return}d.tagName=B;for(var ut=d.tags.length;ut-- >u;){var rt=d.tag=d.tags.pop();d.tagName=d.tag.name,z(d,"onclosetag",d.tagName);var G={};for(var X in rt.ns)G[X]=rt.ns[X];var tt=d.tags[d.tags.length-1]||d;d.opt.xmlns&&rt.ns!==tt.ns&&Object.keys(rt.ns).forEach(function(q){var ot=rt.ns[q];z(d,"onclosenamespace",{prefix:q,uri:ot})})}u===0&&(d.closedRoot=!0),d.tagName=d.attribValue=d.attribName="",d.attribList.length=0,d.state=_.TEXT}function vt(d){var u=d.entity,B=u.toLowerCase(),E,J="";return d.ENTITIES[u]?d.ENTITIES[u]:d.ENTITIES[B]?d.ENTITIES[B]:(u=B,u.charAt(0)==="#"&&(u.charAt(1)==="x"?(u=u.slice(2),E=parseInt(u,16),J=E.toString(16)):(u=u.slice(1),E=parseInt(u,10),J=E.toString(10))),u=u.replace(/^0+/,""),isNaN(E)||J.toLowerCase()!==u?(Y(d,"Invalid character entity"),"&"+d.entity+";"):String.fromCodePoint(E))}function j(d,u){u==="<"?(d.state=_.OPEN_WAKA,d.startTagPosition=d.position):f(u)||(Y(d,"Non-whitespace before first tag."),d.textNode=u,d.state=_.TEXT)}function Mt(d,u){var B="";return u<d.length&&(B=d.charAt(u)),B}function bt(d){var u=this;if(this.error)throw this.error;if(u.closed)return Q(u,"Cannot write after close. Assign an onready handler.");if(d===null)return W(u);typeof d=="object"&&(d=d.toString());for(var B=0,E="";E=Mt(d,B++),u.c=E,!!E;)switch(u.trackPosition&&(u.position++,E===`
|
|
93
|
+
`?(u.line++,u.column=0):u.column++),u.state){case _.BEGIN:if(u.state=_.BEGIN_WHITESPACE,E==="\uFEFF")continue;j(u,E);continue;case _.BEGIN_WHITESPACE:j(u,E);continue;case _.TEXT:if(u.sawRoot&&!u.closedRoot){for(var J=B-1;E&&E!=="<"&&E!=="&";)E=Mt(d,B++),E&&u.trackPosition&&(u.position++,E===`
|
|
94
|
+
`?(u.line++,u.column=0):u.column++);u.textNode+=d.substring(J,B-1)}E==="<"&&!(u.sawRoot&&u.closedRoot&&!u.strict)?(u.state=_.OPEN_WAKA,u.startTagPosition=u.position):(!f(E)&&(!u.sawRoot||u.closedRoot)&&Y(u,"Text data outside of root node."),E==="&"?u.state=_.TEXT_ENTITY:u.textNode+=E);continue;case _.SCRIPT:E==="<"?u.state=_.SCRIPT_ENDING:u.script+=E;continue;case _.SCRIPT_ENDING:E==="/"?u.state=_.CLOSE_TAG:(u.script+="<"+E,u.state=_.SCRIPT);continue;case _.OPEN_WAKA:if(E==="!")u.state=_.SGML_DECL,u.sgmlDecl="";else if(!f(E))if(I(R,E))u.state=_.OPEN_TAG,u.tagName=E;else if(E==="/")u.state=_.CLOSE_TAG,u.tagName="";else if(E==="?")u.state=_.PROC_INST,u.procInstName=u.procInstBody="";else{if(Y(u,"Unencoded <"),u.startTagPosition+1<u.position){var ut=u.position-u.startTagPosition;E=new Array(ut).join(" ")+E}u.textNode+="<"+E,u.state=_.TEXT}continue;case _.SGML_DECL:if(u.sgmlDecl+E==="--"){u.state=_.COMMENT,u.comment="",u.sgmlDecl="";continue}u.doctype&&u.doctype!==!0&&u.sgmlDecl?(u.state=_.DOCTYPE_DTD,u.doctype+="<!"+u.sgmlDecl+E,u.sgmlDecl=""):(u.sgmlDecl+E).toUpperCase()===C?(z(u,"onopencdata"),u.state=_.CDATA,u.sgmlDecl="",u.cdata=""):(u.sgmlDecl+E).toUpperCase()===M?(u.state=_.DOCTYPE,(u.doctype||u.sawRoot)&&Y(u,"Inappropriately located doctype declaration"),u.doctype="",u.sgmlDecl=""):E===">"?(z(u,"onsgmldeclaration",u.sgmlDecl),u.sgmlDecl="",u.state=_.TEXT):(A(E)&&(u.state=_.SGML_DECL_QUOTED),u.sgmlDecl+=E);continue;case _.SGML_DECL_QUOTED:E===u.q&&(u.state=_.SGML_DECL,u.q=""),u.sgmlDecl+=E;continue;case _.DOCTYPE:E===">"?(u.state=_.TEXT,z(u,"ondoctype",u.doctype),u.doctype=!0):(u.doctype+=E,E==="["?u.state=_.DOCTYPE_DTD:A(E)&&(u.state=_.DOCTYPE_QUOTED,u.q=E));continue;case _.DOCTYPE_QUOTED:u.doctype+=E,E===u.q&&(u.q="",u.state=_.DOCTYPE);continue;case _.DOCTYPE_DTD:E==="]"?(u.doctype+=E,u.state=_.DOCTYPE):E==="<"?(u.state=_.OPEN_WAKA,u.startTagPosition=u.position):A(E)?(u.doctype+=E,u.state=_.DOCTYPE_DTD_QUOTED,u.q=E):u.doctype+=E;continue;case _.DOCTYPE_DTD_QUOTED:u.doctype+=E,E===u.q&&(u.state=_.DOCTYPE_DTD,u.q="");continue;case _.COMMENT:E==="-"?u.state=_.COMMENT_ENDING:u.comment+=E;continue;case _.COMMENT_ENDING:E==="-"?(u.state=_.COMMENT_ENDED,u.comment=et(u.opt,u.comment),u.comment&&z(u,"oncomment",u.comment),u.comment=""):(u.comment+="-"+E,u.state=_.COMMENT);continue;case _.COMMENT_ENDED:E!==">"?(Y(u,"Malformed comment"),u.comment+="--"+E,u.state=_.COMMENT):u.doctype&&u.doctype!==!0?u.state=_.DOCTYPE_DTD:u.state=_.TEXT;continue;case _.CDATA:E==="]"?u.state=_.CDATA_ENDING:u.cdata+=E;continue;case _.CDATA_ENDING:E==="]"?u.state=_.CDATA_ENDING_2:(u.cdata+="]"+E,u.state=_.CDATA);continue;case _.CDATA_ENDING_2:E===">"?(u.cdata&&z(u,"oncdata",u.cdata),z(u,"onclosecdata"),u.cdata="",u.state=_.TEXT):E==="]"?u.cdata+="]":(u.cdata+="]]"+E,u.state=_.CDATA);continue;case _.PROC_INST:E==="?"?u.state=_.PROC_INST_ENDING:f(E)?u.state=_.PROC_INST_BODY:u.procInstName+=E;continue;case _.PROC_INST_BODY:if(!u.procInstBody&&f(E))continue;E==="?"?u.state=_.PROC_INST_ENDING:u.procInstBody+=E;continue;case _.PROC_INST_ENDING:E===">"?(z(u,"onprocessinginstruction",{name:u.procInstName,body:u.procInstBody}),u.procInstName=u.procInstBody="",u.state=_.TEXT):(u.procInstBody+="?"+E,u.state=_.PROC_INST_BODY);continue;case _.OPEN_TAG:I(m,E)?u.tagName+=E:(Z(u),E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:(f(E)||Y(u,"Invalid character in tag name"),u.state=_.ATTRIB));continue;case _.OPEN_TAG_SLASH:E===">"?(H(u,!0),it(u)):(Y(u,"Forward-slash in opening tag not followed by >"),u.state=_.ATTRIB);continue;case _.ATTRIB:if(f(E))continue;E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:I(R,E)?(u.attribName=E,u.attribValue="",u.state=_.ATTRIB_NAME):Y(u,"Invalid attribute name");continue;case _.ATTRIB_NAME:E==="="?u.state=_.ATTRIB_VALUE:E===">"?(Y(u,"Attribute without value"),u.attribValue=u.attribName,ct(u),H(u)):f(E)?u.state=_.ATTRIB_NAME_SAW_WHITE:I(m,E)?u.attribName+=E:Y(u,"Invalid attribute name");continue;case _.ATTRIB_NAME_SAW_WHITE:if(E==="=")u.state=_.ATTRIB_VALUE;else{if(f(E))continue;Y(u,"Attribute without value"),u.tag.attributes[u.attribName]="",u.attribValue="",z(u,"onattribute",{name:u.attribName,value:""}),u.attribName="",E===">"?H(u):I(R,E)?(u.attribName=E,u.state=_.ATTRIB_NAME):(Y(u,"Invalid attribute name"),u.state=_.ATTRIB)}continue;case _.ATTRIB_VALUE:if(f(E))continue;A(E)?(u.q=E,u.state=_.ATTRIB_VALUE_QUOTED):(u.opt.unquotedAttributeValues||Q(u,"Unquoted attribute value"),u.state=_.ATTRIB_VALUE_UNQUOTED,u.attribValue=E);continue;case _.ATTRIB_VALUE_QUOTED:if(E!==u.q){E==="&"?u.state=_.ATTRIB_VALUE_ENTITY_Q:u.attribValue+=E;continue}ct(u),u.q="",u.state=_.ATTRIB_VALUE_CLOSED;continue;case _.ATTRIB_VALUE_CLOSED:f(E)?u.state=_.ATTRIB:E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:I(R,E)?(Y(u,"No whitespace between attributes"),u.attribName=E,u.attribValue="",u.state=_.ATTRIB_NAME):Y(u,"Invalid attribute name");continue;case _.ATTRIB_VALUE_UNQUOTED:if(!P(E)){E==="&"?u.state=_.ATTRIB_VALUE_ENTITY_U:u.attribValue+=E;continue}ct(u),E===">"?H(u):u.state=_.ATTRIB;continue;case _.CLOSE_TAG:if(u.tagName)E===">"?it(u):I(m,E)?u.tagName+=E:u.script?(u.script+="</"+u.tagName,u.tagName="",u.state=_.SCRIPT):(f(E)||Y(u,"Invalid tagname in closing tag"),u.state=_.CLOSE_TAG_SAW_WHITE);else{if(f(E))continue;O(R,E)?u.script?(u.script+="</"+E,u.state=_.SCRIPT):Y(u,"Invalid tagname in closing tag."):u.tagName=E}continue;case _.CLOSE_TAG_SAW_WHITE:if(f(E))continue;E===">"?it(u):Y(u,"Invalid characters in closing tag");continue;case _.TEXT_ENTITY:case _.ATTRIB_VALUE_ENTITY_Q:case _.ATTRIB_VALUE_ENTITY_U:var rt,G;switch(u.state){case _.TEXT_ENTITY:rt=_.TEXT,G="textNode";break;case _.ATTRIB_VALUE_ENTITY_Q:rt=_.ATTRIB_VALUE_QUOTED,G="attribValue";break;case _.ATTRIB_VALUE_ENTITY_U:rt=_.ATTRIB_VALUE_UNQUOTED,G="attribValue";break}if(E===";"){var X=vt(u);u.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(X)?(u.entity="",u.state=rt,u.write(X)):(u[G]+=X,u.entity="",u.state=rt)}else I(u.entity.length?y:x,E)?u.entity+=E:(Y(u,"Invalid character in entity name"),u[G]+="&"+u.entity+E,u.entity="",u.state=rt);continue;default:throw new Error(u,"Unknown state: "+u.state)}return u.position>=u.bufferCheckPosition&&r(u),u}String.fromCodePoint||(function(){var d=String.fromCharCode,u=Math.floor,B=function(){var E=16384,J=[],ut,rt,G=-1,X=arguments.length;if(!X)return"";for(var tt="";++G<X;){var q=Number(arguments[G]);if(!isFinite(q)||q<0||q>1114111||u(q)!==q)throw RangeError("Invalid code point: "+q);q<=65535?J.push(q):(q-=65536,ut=(q>>10)+55296,rt=q%1024+56320,J.push(ut,rt)),(G+1===X||J.length>E)&&(tt+=d.apply(null,J),J.length=0)}return tt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:B,configurable:!0,writable:!0}):String.fromCodePoint=B})()})(n)})(Se)),Se}var Me,hi;function Ce(){return hi||(hi=1,Me={isArray:function(n){return Array.isArray?Array.isArray(n):Object.prototype.toString.call(n)==="[object Array]"}}),Me}var Fe,fi;function Be(){if(fi)return Fe;fi=1;var n=Ce().isArray;return Fe={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"&&!n(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}},Fe}var Ne,di;function pi(){if(di)return Ne;di=1;var n=yr(),t=Be(),e=Ce().isArray,i,r;function l(m){return i=t.copyOptions(m),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function c(m){var x=Number(m);if(!isNaN(x))return x;var y=m.toLowerCase();return y==="true"?!0:y==="false"?!1:m}function a(m,x){var y;if(i.compact){if(!r[i[m+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[m+"Key"])!==-1:i.alwaysArray)&&(r[i[m+"Key"]]=[]),r[i[m+"Key"]]&&!e(r[i[m+"Key"]])&&(r[i[m+"Key"]]=[r[i[m+"Key"]]]),m+"Fn"in i&&typeof x=="string"&&(x=i[m+"Fn"](x,r)),m==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(y in x)if(x.hasOwnProperty(y))if("instructionFn"in i)x[y]=i.instructionFn(x[y],y,r);else{var f=x[y];delete x[y],x[i.instructionNameFn(y,f,r)]=f}}e(r[i[m+"Key"]])?r[i[m+"Key"]].push(x):r[i[m+"Key"]]=x}else{r[i.elementsKey]||(r[i.elementsKey]=[]);var A={};if(A[i.typeKey]=m,m==="instruction"){for(y in x)if(x.hasOwnProperty(y))break;A[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(y,x,r):y,i.instructionHasAttributes?(A[i.attributesKey]=x[y][i.attributesKey],"instructionFn"in i&&(A[i.attributesKey]=i.instructionFn(A[i.attributesKey],y,r))):("instructionFn"in i&&(x[y]=i.instructionFn(x[y],y,r)),A[i.instructionKey]=x[y])}else m+"Fn"in i&&(x=i[m+"Fn"](x,r)),A[i[m+"Key"]]=x;i.addParent&&(A[i.parentKey]=r),r[i.elementsKey].push(A)}}function g(m){if("attributesFn"in i&&m&&(m=i.attributesFn(m,r)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&m){var x;for(x in m)if(m.hasOwnProperty(x)&&(i.trim&&(m[x]=m[x].trim()),i.nativeTypeAttributes&&(m[x]=c(m[x])),"attributeValueFn"in i&&(m[x]=i.attributeValueFn(m[x],x,r)),"attributeNameFn"in i)){var y=m[x];delete m[x],m[i.attributeNameFn(x,m[x],r)]=y}}return m}function S(m){var x={};if(m.body&&(m.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var y=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=y.exec(m.body))!==null;)x[f[1]]=f[2]||f[3]||f[4];x=g(x)}if(m.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;r[i.declarationKey]={},Object.keys(x).length&&(r[i.declarationKey][i.attributesKey]=x),i.addParent&&(r[i.declarationKey][i.parentKey]=r)}else{if(i.ignoreInstruction)return;i.trim&&(m.body=m.body.trim());var A={};i.instructionHasAttributes&&Object.keys(x).length?(A[m.name]={},A[m.name][i.attributesKey]=x):A[m.name]=m.body,a("instruction",A)}}function w(m,x){var y;if(typeof m=="object"&&(x=m.attributes,m=m.name),x=g(x),"elementNameFn"in i&&(m=i.elementNameFn(m,r)),i.compact){if(y={},!i.ignoreAttributes&&x&&Object.keys(x).length){y[i.attributesKey]={};var f;for(f in x)x.hasOwnProperty(f)&&(y[i.attributesKey][f]=x[f])}!(m in r)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(m)!==-1:i.alwaysArray)&&(r[m]=[]),r[m]&&!e(r[m])&&(r[m]=[r[m]]),e(r[m])?r[m].push(y):r[m]=y}else r[i.elementsKey]||(r[i.elementsKey]=[]),y={},y[i.typeKey]="element",y[i.nameKey]=m,!i.ignoreAttributes&&x&&Object.keys(x).length&&(y[i.attributesKey]=x),i.alwaysChildren&&(y[i.elementsKey]=[]),r[i.elementsKey].push(y);y[i.parentKey]=r,r=y}function C(m){i.ignoreText||!m.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(m=m.trim()),i.nativeType&&(m=c(m)),i.sanitize&&(m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),a("text",m))}function M(m){i.ignoreComment||(i.trim&&(m=m.trim()),a("comment",m))}function N(m){var x=r[i.parentKey];i.addParent||delete r[i.parentKey],r=x}function F(m){i.ignoreCdata||(i.trim&&(m=m.trim()),a("cdata",m))}function k(m){i.ignoreDoctype||(m=m.replace(/^ /,""),i.trim&&(m=m.trim()),a("doctype",m))}function R(m){m.note=m}return Ne=function(m,x){var y=n.parser(!0,{}),f={};if(r=f,i=l(x),y.opt={strictEntities:!0},y.onopentag=w,y.ontext=C,y.oncomment=M,y.onclosetag=N,y.onerror=R,y.oncdata=F,y.ondoctype=k,y.onprocessinginstruction=S,y.write(m).close(),f[i.elementsKey]){var A=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=A,delete f.text}return f},Ne}var Ie,mi;function gr(){if(mi)return Ie;mi=1;var n=Be(),t=pi();function e(i){var r=n.copyOptions(i);return n.ensureSpacesExists(r),r}return Ie=function(i,r){var l,c,a,g;return l=e(r),c=t(i,l),g="compact"in l&&l.compact?"_parent":"parent","addParent"in l&&l.addParent?a=JSON.stringify(c,function(S,w){return S===g?"_":w},l.spaces):a=JSON.stringify(c,null,l.spaces),a.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},Ie}var De,yi;function gi(){if(yi)return De;yi=1;var n=Be(),t=Ce().isArray,e,i;function r(y){var f=n.copyOptions(y);return n.ensureFlagExists("ignoreDeclaration",f),n.ensureFlagExists("ignoreInstruction",f),n.ensureFlagExists("ignoreAttributes",f),n.ensureFlagExists("ignoreText",f),n.ensureFlagExists("ignoreComment",f),n.ensureFlagExists("ignoreCdata",f),n.ensureFlagExists("ignoreDoctype",f),n.ensureFlagExists("compact",f),n.ensureFlagExists("indentText",f),n.ensureFlagExists("indentCdata",f),n.ensureFlagExists("indentAttributes",f),n.ensureFlagExists("indentInstruction",f),n.ensureFlagExists("fullTagEmptyElement",f),n.ensureFlagExists("noQuotesForNativeAttributes",f),n.ensureSpacesExists(f),typeof f.spaces=="number"&&(f.spaces=Array(f.spaces+1).join(" ")),n.ensureKeyExists("declaration",f),n.ensureKeyExists("instruction",f),n.ensureKeyExists("attributes",f),n.ensureKeyExists("text",f),n.ensureKeyExists("comment",f),n.ensureKeyExists("cdata",f),n.ensureKeyExists("doctype",f),n.ensureKeyExists("type",f),n.ensureKeyExists("name",f),n.ensureKeyExists("elements",f),n.checkFnExists("doctype",f),n.checkFnExists("instruction",f),n.checkFnExists("cdata",f),n.checkFnExists("comment",f),n.checkFnExists("text",f),n.checkFnExists("instructionName",f),n.checkFnExists("elementName",f),n.checkFnExists("attributeName",f),n.checkFnExists("attributeValue",f),n.checkFnExists("attributes",f),n.checkFnExists("fullTagEmptyElement",f),f}function l(y,f,A){return(!A&&y.spaces?`
|
|
95
|
+
`:"")+Array(f+1).join(y.spaces)}function c(y,f,A){if(f.ignoreAttributes)return"";"attributesFn"in f&&(y=f.attributesFn(y,i,e));var P,I,O,_,U=[];for(P in y)y.hasOwnProperty(P)&&y[P]!==null&&y[P]!==void 0&&(_=f.noQuotesForNativeAttributes&&typeof y[P]!="string"?"":'"',I=""+y[P],I=I.replace(/"/g,"""),O="attributeNameFn"in f?f.attributeNameFn(P,I,i,e):P,U.push(f.spaces&&f.indentAttributes?l(f,A+1,!1):" "),U.push(O+"="+_+("attributeValueFn"in f?f.attributeValueFn(I,P,i,e):I)+_));return y&&Object.keys(y).length&&f.spaces&&f.indentAttributes&&U.push(l(f,A,!1)),U.join("")}function a(y,f,A){return e=y,i="xml",f.ignoreDeclaration?"":"<?xml"+c(y[f.attributesKey],f,A)+"?>"}function g(y,f,A){if(f.ignoreInstruction)return"";var P;for(P in y)if(y.hasOwnProperty(P))break;var I="instructionNameFn"in f?f.instructionNameFn(P,y[P],i,e):P;if(typeof y[P]=="object")return e=y,i=I,"<?"+I+c(y[P][f.attributesKey],f,A)+"?>";var O=y[P]?y[P]:"";return"instructionFn"in f&&(O=f.instructionFn(O,P,i,e)),"<?"+I+(O?" "+O:"")+"?>"}function S(y,f){return f.ignoreComment?"":"<!--"+("commentFn"in f?f.commentFn(y,i,e):y)+"-->"}function w(y,f){return f.ignoreCdata?"":"<![CDATA["+("cdataFn"in f?f.cdataFn(y,i,e):y.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(y,f){return f.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in f?f.doctypeFn(y,i,e):y)+">"}function M(y,f){return f.ignoreText?"":(y=""+y,y=y.replace(/&/g,"&"),y=y.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in f?f.textFn(y,i,e):y)}function N(y,f){var A;if(y.elements&&y.elements.length)for(A=0;A<y.elements.length;++A)switch(y.elements[A][f.typeKey]){case"text":if(f.indentText)return!0;break;case"cdata":if(f.indentCdata)return!0;break;case"instruction":if(f.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function F(y,f,A){e=y,i=y.name;var P=[],I="elementNameFn"in f?f.elementNameFn(y.name,y):y.name;P.push("<"+I),y[f.attributesKey]&&P.push(c(y[f.attributesKey],f,A));var O=y[f.elementsKey]&&y[f.elementsKey].length||y[f.attributesKey]&&y[f.attributesKey]["xml:space"]==="preserve";return O||("fullTagEmptyElementFn"in f?O=f.fullTagEmptyElementFn(y.name,y):O=f.fullTagEmptyElement),O?(P.push(">"),y[f.elementsKey]&&y[f.elementsKey].length&&(P.push(k(y[f.elementsKey],f,A+1)),e=y,i=y.name),P.push(f.spaces&&N(y,f)?`
|
|
96
|
+
`+Array(A+1).join(f.spaces):""),P.push("</"+I+">")):P.push("/>"),P.join("")}function k(y,f,A,P){return y.reduce(function(I,O){var _=l(f,A,P&&!I);switch(O.type){case"element":return I+_+F(O,f,A);case"comment":return I+_+S(O[f.commentKey],f);case"doctype":return I+_+C(O[f.doctypeKey],f);case"cdata":return I+(f.indentCdata?_:"")+w(O[f.cdataKey],f);case"text":return I+(f.indentText?_:"")+M(O[f.textKey],f);case"instruction":var U={};return U[O[f.nameKey]]=O[f.attributesKey]?O:O[f.instructionKey],I+(f.indentInstruction?_:"")+g(U,f,A)}},"")}function R(y,f,A){var P;for(P in y)if(y.hasOwnProperty(P))switch(P){case f.parentKey:case f.attributesKey:break;case f.textKey:if(f.indentText||A)return!0;break;case f.cdataKey:if(f.indentCdata||A)return!0;break;case f.instructionKey:if(f.indentInstruction||A)return!0;break;case f.doctypeKey:case f.commentKey:return!0;default:return!0}return!1}function m(y,f,A,P,I){e=y,i=f;var O="elementNameFn"in A?A.elementNameFn(f,y):f;if(typeof y>"u"||y===null||y==="")return"fullTagEmptyElementFn"in A&&A.fullTagEmptyElementFn(f,y)||A.fullTagEmptyElement?"<"+O+"></"+O+">":"<"+O+"/>";var _=[];if(f){if(_.push("<"+O),typeof y!="object")return _.push(">"+M(y,A)+"</"+O+">"),_.join("");y[A.attributesKey]&&_.push(c(y[A.attributesKey],A,P));var U=R(y,A,!0)||y[A.attributesKey]&&y[A.attributesKey]["xml:space"]==="preserve";if(U||("fullTagEmptyElementFn"in A?U=A.fullTagEmptyElementFn(f,y):U=A.fullTagEmptyElement),U)_.push(">");else return _.push("/>"),_.join("")}return _.push(x(y,A,P+1,!1)),e=y,i=f,f&&_.push((I?l(A,P,!1):"")+"</"+O+">"),_.join("")}function x(y,f,A,P){var I,O,_,U=[];for(O in y)if(y.hasOwnProperty(O))for(_=t(y[O])?y[O]:[y[O]],I=0;I<_.length;++I){switch(O){case f.declarationKey:U.push(a(_[I],f,A));break;case f.instructionKey:U.push((f.indentInstruction?l(f,A,P):"")+g(_[I],f,A));break;case f.attributesKey:case f.parentKey:break;case f.textKey:U.push((f.indentText?l(f,A,P):"")+M(_[I],f));break;case f.cdataKey:U.push((f.indentCdata?l(f,A,P):"")+w(_[I],f));break;case f.doctypeKey:U.push(l(f,A,P)+C(_[I],f));break;case f.commentKey:U.push(l(f,A,P)+S(_[I],f));break;default:U.push(l(f,A,P)+m(_[I],O,f,A,R(_[I],f)))}P=P&&!U.length}return U.join("")}return De=function(y,f){f=r(f);var A=[];return e=y,i="_root_",f.compact?A.push(x(y,f,0,!0)):(y[f.declarationKey]&&A.push(a(y[f.declarationKey],f,0)),y[f.elementsKey]&&y[f.elementsKey].length&&A.push(k(y[f.elementsKey],f,0,!A.length))),A.join("")},De}var Oe,_i;function _r(){if(_i)return Oe;_i=1;var n=gi();return Oe=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 n(i,e)},Oe}var Re,xi;function xr(){if(xi)return Re;xi=1;var n=pi(),t=gr(),e=gi(),i=_r();return Re={xml2js:n,xml2json:t,js2xml:e,json2xml:i},Re}var Pe=xr(),wr=ai();const Dt=class Dt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=r=>{if(!r)return;const l=r.attributes||r._attributes;if(!l)return r;let c={...r,...l,...Dt.propToNumber(l,["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"]),...Dt.propToBool(l,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(c.properties){const g=Dt.toArray(c.properties.property),S={};for(let w of g){const C=w._attributes;if(!C)continue;let M;switch(C.type){case"file":M=this.getImagePath(C.value);break;case"object":case"float":case"int":M=+C.value;break;case"bool":M=C.value=="true";break;case"class":M={...this.transform(w)?.properties??{},_classname:C.propertytype};break;default:M=C.value}S[C.name]=M}c.properties=S}c.polygon&&(c.polygon=this.transform(c.polygon)),c.polyline&&(c.polyline=this.transform(c.polyline)),c.points&&(c=c.points.split(" ").map(g=>{const S=g.split(",");return{x:+S[0],y:+S[1]}})),c.point&&(c.point=!0),c.ellipse&&(c.ellipse=!0),c.text&&(c.text={text:c.text._text,...this.transform(c.text)},delete c.text._text),c.image&&(c.image=this.transform(c.image)),c.source&&(this.isTilesetSource(c)||(c.source=this.getImagePath(c.source)));const a=c.object||c.objectgroup?.object;return a&&(c.objects=Dt.toArray(a).map(g=>this.transform(g))),delete c._attributes,delete c.attributes,delete c.object,delete c.objectgroup,c}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:ri(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 r=0;const l=[];for(let c=0;c<i;c+=4)l[r]=t.readUInt32LE(c),r++;return l}static decode(t,e){const{encoding:i,data:r}=t;return i=="base64"?Dt.unpackTileBytes(wr.Buffer.from(r.trim(),"base64"),e):i=="csv"?r.trim().split(",").map(l=>+l):r}parseMap(){const t=Pe.xml2js(this.xml,{compact:!0}),e=Pe.xml2js(this.xml),i=t.map.tileset;t.map.group;const r=S=>{const{objectgroup:w,group:C,layer:M,imagelayer:N}=S,F=k=>{k&&Dt.toArray(k).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)})};F(w),F(M),F(C),F(N),C&&r(C)};r(t.map);const l=(S,w=[])=>{if(!S)return w;for(let C of S){const{name:M}=C;if(!["layer","group","imagelayer","objectgroup"].includes(M))continue;const N=C.elements?.find(k=>k.name=="data");C.layer=this.layers.get(+C.attributes.id);const F={...this.transform(N)??{},...this.transform(C),...this.transform(C.layer),layers:l(C.elements),data:N?N.elements[0].text:void 0,type:M=="layer"?"tilelayer":M};delete F.elements,delete F.layer,F.data&&(F.data=Dt.decode(F,F.width*F.height)),w.push(F)}return w},c=l(e.elements[0].elements),a=Dt.toArray(i).map(S=>this.transform(S)),g={...this.transform(t.map),layers:c,tilesets:a};return delete g.layer,delete g.tileset,delete g.group,delete g.imagelayer,g}parseTileset(){const t=Pe.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:Dt.toArray(e.tile).map(r=>{const l=this.transform(r);return r.animation&&(l.animations=Dt.toArray(r.animation.frame).map(this.transform)),delete l.animation,l})};return delete i.tile,i}};Dt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},Dt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let Ue=Dt;class ke{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 Er=2147483648,vr=1073741824,br=536870912,Sr=268435456;class se extends ke{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Er)}get verticalFlip(){return!!(this._gid&vr)}get diagonalFlip(){return!!(this._gid&br)}get rotatedHex120(){return!!(this._gid&Sr)}get gid(){return se.getRealGid(this._gid)}set gid(t){this._gid=t}}let Le=class extends se{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 Ar extends se{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class Ve extends ke{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 r=se.getRealGid(t),l=Ve.findTileSet(r,this.tilesets);if(!l)return;const c=l.getTile(r-l.firstgid);return c?new Le({...c.tile,gid:t,index:e,layerIndex:i}):new Le({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 Ar(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 r=e.length-1;r>=0&&(i=e[r],!(i.firstgid&&i.firstgid<=t));r--);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 Tr extends ke{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 Le(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class qt{constructor(t,{basePath:e="",staticDir:i="",relativePath:r=""}={}){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 r=a=>qt.typeOfFile(a).isXml,l=a=>{if(!a)return i(null);if(r(a)){const g=new Ue(a,t,this.basePath);if(e=="map"){const S=g.parseMap();return i(S)}else if(e=="tileset"){const S=g.parseTileset();return i(S)}}return i(JSON.parse(a))};if(qt.typeOfFile(t).isObject)return i(t);const{isHttp:c}=qt.typeOfFile(t);if(r(t))l(t);else if(c||qt.isBrowser()){let a=c?t:ri(this.basePath,t);qt.isBrowser()&&window.urlCache&&(a=window.urlCache[t]),fetch(a,{headers:{"Content-Type":"application/xml"}}).then(g=>g.text()).then(l).catch(g=>i(null,g))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,r=l=>l.substring(l.lastIndexOf("/")+1);i&&qt.typeOfFile(this.file).isPath&&(this.file=r(this.file)),this._parseFile(this.file,"map",(l,c)=>{let a=!1;if(c)return t(null,c);if(l.tilesets){const g=[],S=()=>{w++,w==l.tilesets.length&&!a&&(l.tilesets=g,t(l))};let w=0;for(let C=0;C<l.tilesets.length;C++){const M=l.tilesets[C];if(!M.source||M.tiles||M.image||M.tile){g[C]=M,S();continue}i&&qt.typeOfFile(M.source).isPath&&(M.source=r(M.source)),this._parseFile(M.source,"tileset",(N,F)=>{if(F)return a=!0,t(null,F);g[C]={...N,firstgid:M.firstgid},S()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((r,l)=>{r?e(r):i(l)},t)})}}const Wt={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var Mr=Object.defineProperty,Cr=(n,t,e)=>t in n?Mr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$t=(n,t,e)=>(Cr(n,typeof t!="symbol"?t+"":t,e),e);const oe=class ue extends L.Geometry{constructor(t){const e=new L.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:L.BufferUsage.VERTEX|L.BufferUsage.COPY_DST,shrinkToFit:!1}),i=ue.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}}}),$t(this,"lastTimeAccess",0),$t(this,"vertSize",ue.vertSize),$t(this,"vertPerQuad",ue.vertPerQuad),$t(this,"stride",ue.stride),$t(this,"buf"),this.buf=e}};$t(oe,"vertSize",13),$t(oe,"vertPerQuad",4),$t(oe,"stride",oe.vertSize*4);let Fr=oe;var Br=Object.defineProperty,Nr=(n,t,e)=>t in n?Br(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ht=(n,t,e)=>(Nr(n,typeof t!="symbol"?t+"":t,e),e);class wi{constructor(){Ht(this,"pipe_uniforms",new L.UniformGroup({u_proj_trans:{value:new L.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class Ei{constructor(t,e){Ht(this,"renderer"),Ht(this,"tileAnim",[0,0]),Ht(this,"ibLen",0),Ht(this,"indexBuffer",null),Ht(this,"shader"),Ht(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new L.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:L.BufferUsage.INDEX|L.BufferUsage.COPY_DST}),this.indexBuffer.destroy=L.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Fr(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=Ir(t,Wt.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,r=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let l=this.tileAnim;const{u_anim_frame:c}=e.uniforms;r.uProjectionMatrix.copyTo(i).append(r.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(l=t.parent.tileAnim||l),c[0]=l[0],c[1]=l[1],e.update(),this.adaptor.execute(this,t)}}Ht(Ei,"extension",{type:[L.ExtensionType.WebGLPipes,L.ExtensionType.WebGPUPipes],name:"tilemap"});function Ir(n,t){const e=n*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,r=0;i<e;i+=6,r+=4)t[i+0]=r+0,t[i+1]=r+1,t[i+2]=r+2,t[i+3]=r+0,t[i+4]=r+2,t[i+5]=r+3;return t}var Dr=Object.defineProperty,Or=(n,t,e)=>t in n?Dr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,jt=(n,t,e)=>(Or(n,typeof t!="symbol"?t+"":t,e),e);class Zt{constructor(t){jt(this,"max_textures"),jt(this,"arr",[]),jt(this,"count",0),jt(this,"dirty",!1),jt(this,"dirty_gpu",!1),jt(this,"bind_group",null),jt(this,"bind_group_resources",{}),jt(this,"tex_sizes",null),jt(this,"null_color",new Float32Array([0,0,0,.5])),jt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new L.Buffer({usage:L.BufferUsage.UNIFORM|L.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:r,null_color:l}=this;for(let c=0;c<i;c++){const a=e[c];a&&(t[c*4]=a.pixelWidth,t[c*4+1]=a.pixelHeight,t[c*4+2]=1/a.pixelWidth,t[c*4+3]=1/a.pixelHeight)}t[r*4]=l[0],t[r*4+1]=l[1],t[r*4+2]=l[2],t[r*4+3]=l[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:r}=this;let l=0;t[l++]=new L.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 c=0;c<e;c++){const a=(c<r?i[c]:null)||L.Texture.EMPTY.source;t[l++]=a.source,t[l++]=a.style}return this.bind_group||(this.bind_group=new L.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(`
|
|
97
97
|
`)}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(`
|
|
98
|
-
`)}static gl_gen_resources(t){const e=[];for(let
|
|
98
|
+
`)}static gl_gen_resources(t){const e=[];for(let r=0;r<t;r++)e[r]=r;const i=[];for(let r=0;r<t;r++)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 Rr=Object.defineProperty,Pr=(n,t,e)=>t in n?Rr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ye=(n,t,e)=>(Pr(n,typeof t!="symbol"?t+"":t,e),e);const Ur=`
|
|
99
99
|
in vec2 aVertexPosition;
|
|
100
100
|
in vec2 aTextureCoord;
|
|
101
101
|
in vec4 aFrame;
|
|
@@ -126,7 +126,7 @@ void main(void)
|
|
|
126
126
|
vTextureId = aTextureId;
|
|
127
127
|
vAlpha = aAlpha;
|
|
128
128
|
}
|
|
129
|
-
`,
|
|
129
|
+
`,kr=`
|
|
130
130
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
131
131
|
precision highp float;
|
|
132
132
|
#else
|
|
@@ -146,7 +146,7 @@ void main(void)
|
|
|
146
146
|
vec4 color = sampleMultiTexture(textureId, textureCoord);
|
|
147
147
|
finalColor = color * vAlpha;
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class vi extends wi{constructor(){super(...arguments),Ye(this,"_shader",null),Ye(this,"max_textures",Wt.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,r=this._shader,l=e.getTileset(),c=r.resources.texture_uniforms;c.uniforms.u_texture_size!==l.tex_sizes&&(c.uniforms.u_texture_size=l.tex_sizes,c.update());for(let a=0;a<l.length;a++)i.texture.bind(l.arr[a],a);i.encoder.draw({geometry:e.vb,shader:r,state:e.state,size:e.rects_count*6})}init(){this._shader=new L.Shader({glProgram:L.GlProgram.from({vertex:Ur,fragment:kr.replace("//include_textures",Zt.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new L.UniformGroup(Zt.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}Ye(vi,"extension",{type:[L.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Lr=Object.defineProperty,Vr=(n,t,e)=>t in n?Lr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,me=(n,t,e)=>(Vr(n,typeof t!="symbol"?t+"":t,e),e);const Yr=`
|
|
150
150
|
struct GlobalUniforms {
|
|
151
151
|
uProjectionMatrix:mat3x3f,
|
|
152
152
|
uWorldTransformMatrix:mat3x3f,
|
|
@@ -192,7 +192,7 @@ fn mainVert(
|
|
|
192
192
|
|
|
193
193
|
return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
|
|
194
194
|
};
|
|
195
|
-
`,
|
|
195
|
+
`,zr=`
|
|
196
196
|
//include_textures
|
|
197
197
|
|
|
198
198
|
@fragment
|
|
@@ -209,7 +209,7 @@ fn mainFrag(
|
|
|
209
209
|
var color = sampleMultiTexture(vTextureId, uv, dx, dy);
|
|
210
210
|
return color * vAlpha;
|
|
211
211
|
};
|
|
212
|
-
`;class ai extends ri{constructor(){super(...arguments),ne(this,"_shader",null),ne(this,"max_textures",Ut.TEXTURES_PER_TILEMAP),ne(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:_r,entryPoint:"mainVert"},fragment:{source:yr.replace("//include_textures",zt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}ne(ai,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var gr=Object.defineProperty,xr=(u,t,e)=>t in u?gr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,yt=(u,t,e)=>(xr(u,typeof t!="symbol"?t+"":t,e),e),oi=(u=>(u[u.U=0]="U",u[u.V=1]="V",u[u.X=2]="X",u[u.Y=3]="Y",u[u.TILE_WIDTH=4]="TILE_WIDTH",u[u.TILE_HEIGHT=5]="TILE_HEIGHT",u[u.ROTATE=6]="ROTATE",u[u.ANIM_X=7]="ANIM_X",u[u.ANIM_Y=8]="ANIM_Y",u[u.TEXTURE_INDEX=9]="TEXTURE_INDEX",u[u.ANIM_COUNT_X=10]="ANIM_COUNT_X",u[u.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",u[u.ANIM_DIVISOR=12]="ANIM_DIVISOR",u[u.ALPHA=13]="ALPHA",u))(oi||{});const Bt=Object.keys(oi).length/2;class li extends P.ViewContainer{constructor(t){super({}),yt(this,"shadowColor",new Float32Array([0,0,0,.5])),yt(this,"state",P.State.for2d()),yt(this,"is_valid",!1),yt(this,"renderPipeId","tilemap"),yt(this,"canBundle",!0),yt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),yt(this,"tileAnim",null),yt(this,"rects_count",0),yt(this,"compositeParent",!1),yt(this,"tileset",new zt(Ut.TEXTURES_PER_TILEMAP)),yt(this,"tilemapBounds",new P.Bounds),yt(this,"hasAnimatedTile",!1),yt(this,"pointsBuf",[]),yt(this,"batched"),yt(this,"vbId",0),yt(this,"vb",null),yt(this,"vbBuffer",null),yt(this,"vbArray",null),yt(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 zt)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 zt(Ut.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 zt(Ut.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,o=-1,a=!1;if(typeof t=="number")o=t,a=!0,c=this.tileset.arr[o];else{let f;typeof t=="string"?f=P.Texture.from(t):f=t;const b=this.tileset;for(let O=0;O<b.count;O++)if(b.arr[O]===f.source){o=O;break}"frame"in f&&(s.u=s.u??f.frame.x,s.v=s.v??f.frame.y,s.tileWidth=s.tileWidth??f.orig.width,s.tileHeight=s.tileHeight??f.orig.height),c=f.source}if(!a&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:y=0,v:C=0,tileWidth:S=c.width,tileHeight:B=c.height,animX:A=0,animY:D=0,rotate:F=0,animCountX:R=1024,animCountY:N=1024,animDivisor:m=1,alpha:x=1}=s,_=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||A>0||D>0,_.push(y),_.push(C),_.push(e),_.push(i),_.push(S),_.push(B),_.push(F),_.push(A|0),_.push(D|0),_.push(o),_.push(R),_.push(N),_.push(m),_.push(x),this.tilemapBounds.addFrame(e,i,e+S,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 o=s.getBuffer("aVertexPosition"),a=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<a){let A=s.stride;for(;A<a;)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 S=0,B=0;for(let A=0;A<e.length;A+=Bt){this.compositeParent&&(B=e[A+9]);const F=e[A+2],R=e[A+3],N=e[A+4],m=e[A+5],x=e[A+0],_=e[A+1];let f=e[A+6];const b=e[A+7],O=e[A+8],k=e[A+10]||1024,L=e[A+11]||1024,g=b+k*2048,q=O+L*2048,Y=e[A+12],G=e[A+13];let st,ft,at,ot,K,gt,xt,mt;if(f===0)st=x,ft=_,at=x+N,ot=_,K=x+N,gt=_+m,xt=x,mt=_+m;else{let W=N/2,tt=m/2;f%4!==0&&(W=m/2,tt=N/2);const Tt=x+W,vt=_+tt;f=P.groupD8.add(f,P.groupD8.NW),st=Tt+W*P.groupD8.uX(f),ft=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),at=Tt+W*P.groupD8.uX(f),ot=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),K=Tt+W*P.groupD8.uX(f),gt=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),xt=Tt+W*P.groupD8.uX(f),mt=vt+tt*P.groupD8.uY(f)}y[S++]=F,y[S++]=R,y[S++]=st,y[S++]=ft,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F+N,y[S++]=R,y[S++]=at,y[S++]=ot,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F+N,y[S++]=R+m,y[S++]=K,y[S++]=gt,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F,y[S++]=R+m,y[S++]=xt,y[S++]=mt,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G}o.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,o,a,y=0,C=0,S=0,B=1024,A=1024,D=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:o,tileHeight:a,animX:y,animY:C,rotate:S,animCountX:B,animCountY:A,animDivisor:D,alpha:F})}}var wr=Object.defineProperty,Er=(u,t,e)=>t in u?wr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Jt=(u,t,e)=>(Er(u,typeof t!="symbol"?t+"":t,e),e);class vr extends P.Container{constructor(t){super(),Jt(this,"texturesPerTilemap"),Jt(this,"tileAnim",null),Jt(this,"lastModifiedTilemap",null),Jt(this,"modificationMarker",0),Jt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Ut.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 o=new li(t.slice(c*e,(c+1)*e));o.compositeParent=!0,this.addChild(o)}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 o=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const a=t/this.texturesPerTilemap>>0;let y=0;if(c=o[a],c)y=t%this.texturesPerTilemap;else{if(c=o[0],!c)return this;y=0}c.tile(y,e,i,s)}else{typeof t=="string"&&(t=P.Texture.from(t));for(let a=0;a<o.length;a++){const y=o[a],C=y.getTileset().arr;for(let S=0;S<C.length;S++)if(C[S]===t.source){c=y;break}if(c)break}if(!c){for(let a=o.length-1;a>=0;a--){const y=o[a];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new li(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,o,a,y,C){return this.tile(t,e,i,{animX:s,animY:c,animCountX:o,animCountY:a,animDivisor:y,alpha:C})}addRect(t,e,i,s,c,o,a,y,C,S,B,A){const D=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[D]&&this.children[D].getTileset().count>0?(this.lastModifiedTilemap=this.children[D],this.lastModifiedTilemap.addRect(F,e,i,s,c,o,a,y,C,S,B,A)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(ni),P.extensions.add(si),P.extensions.add(ai);class se extends P.AnimatedSprite{constructor(t,e){super(se.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=se.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))}}Ut.use32bitIndex=!0;class Fe extends I.DisplayObject(vr){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:o,tileheight:a,width:y}=this._layer;s&&(t=Math.floor(t/o),e=Math.floor(e/a));const C=t+e*y,S=this._layer.getTileByIndex(C);if(!S||S&&S.gid==0)return;const B=Fe.findTileSet(S.gid,this.tileSets);if(!B)return;const A=new se(S,B);if(A.x=t*o,A.y=e*a+(a-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 Ce({...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)}}I.registerComponent("CompositeTileLayer",Fe);function Sr(u){return I.createComponent("CompositeTileLayer",u)}class Tr extends er{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 br(u,t,e){const i=[];for(const s of u){if(s.type!==qt.Tile){i.push(s);continue}const c=new Map;let o;if(Array.isArray(s.data))o=s.data.map(y=>typeof y=="number"?y:parseInt(String(y),10));else{i.push(s);continue}for(let y=0;y<o.length;y++){const C=o[y];if(C===0)continue;let S;for(let F=t.length-1;F>=0;F--)if(t[F].firstgid&&t[F].firstgid<=C){S=t[F];break}if(!S){c.has(0)||c.set(0,new Array(o.length).fill(0)),c.get(0)[y]=C;continue}const B=C-S.firstgid,A=S.tileset.tiles?.[B]?.properties,D=A?.z??0;A?.z,c.has(D)||c.set(D,new Array(o.length).fill(0)),c.get(D)[y]=C}const a=Array.from(c.keys()).sort((y,C)=>y-C);for(const y of a){const C=c.get(y);if(C.some(S=>S!==0)){const S={...s,name:`${s.name}_z${y}`,data:C,properties:{...s.properties,z:y}};i.push(S)}}}return i.sort((s,c)=>{const o=s.properties?.z??.5,a=c.properties?.z??.5;return o-a}),i}function Ar(u){const{map:t,basePath:e,createLayersPerTilesZ:i}=I.useProps(u,{createLayersPerTilesZ:!1,basePath:""}),s=I.signal([]),c=u.objectLayer;let o=[],a={};const y=async(S,B="")=>typeof S!="string"?S:await new kt(S,{basePath:B}).parseFilePromise({getOnlyBasename:!1});I.effect(async()=>{const S=t();if(S){a=await y(S,e()),o=[];for(let A of a.tilesets)A.tile&&(A.tiles=A.tile),A.tiles||(A.tiles=[]),o.push(await new Tr(A).load(A.image.source));let B=a.layers;i()&&(B=br(a.layers,o)),s.set(B)}});const C=(S,B={})=>I.h(I.Container,B,I.loop(S,A=>{switch(A.type){case qt.Tile:return I.h(Sr,{tilewidth:a.tilewidth,tileheight:a.tileheight,width:a.width,height:a.height,...A,tilesets:o});case qt.Image:const{width:D,height:F,source:R}=A.image;return I.h(I.TilingSprite,{image:R,...A,width:A.repeatx?A.width*A.tilewidth:D,height:A.repeaty?A.height*A.tileheight:F});case qt.Group:return C(I.signal(A.layers),A);case qt.ObjectGroup:const N=c?.(A);return I.h(I.Container,A,N);default:return I.h(I.Container)}}));return I.h(I.Container,u,C(s))}function Cr(){const u=`
|
|
212
|
+
`;class bi extends wi{constructor(){super(...arguments),me(this,"_shader",null),me(this,"max_textures",Wt.TEXTURES_PER_TILEMAP),me(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,r=this._shader;r.groups[0]=i.globalUniforms.bindGroup,r.groups[1]=e.getTileset().getBindGroup(),r.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:r,state:e.state,size:e.rects_count*6})}init(){this._shader=new L.Shader({gpuProgram:L.GpuProgram.from({vertex:{source:Yr,entryPoint:"mainVert"},fragment:{source:zr.replace("//include_textures",Zt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new L.BindGroup({ut:this.pipe_uniforms})}}me(bi,"extension",{type:[L.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Gr=Object.defineProperty,jr=(n,t,e)=>t in n?Gr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bt=(n,t,e)=>(jr(n,typeof t!="symbol"?t+"":t,e),e),Si=(n=>(n[n.U=0]="U",n[n.V=1]="V",n[n.X=2]="X",n[n.Y=3]="Y",n[n.TILE_WIDTH=4]="TILE_WIDTH",n[n.TILE_HEIGHT=5]="TILE_HEIGHT",n[n.ROTATE=6]="ROTATE",n[n.ANIM_X=7]="ANIM_X",n[n.ANIM_Y=8]="ANIM_Y",n[n.TEXTURE_INDEX=9]="TEXTURE_INDEX",n[n.ANIM_COUNT_X=10]="ANIM_COUNT_X",n[n.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",n[n.ANIM_DIVISOR=12]="ANIM_DIVISOR",n[n.ALPHA=13]="ALPHA",n))(Si||{});const kt=Object.keys(Si).length/2;class Ai extends L.ViewContainer{constructor(t){super({}),Bt(this,"shadowColor",new Float32Array([0,0,0,.5])),Bt(this,"state",L.State.for2d()),Bt(this,"is_valid",!1),Bt(this,"renderPipeId","tilemap"),Bt(this,"canBundle",!0),Bt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),Bt(this,"tileAnim",null),Bt(this,"rects_count",0),Bt(this,"compositeParent",!1),Bt(this,"tileset",new Zt(Wt.TEXTURES_PER_TILEMAP)),Bt(this,"tilemapBounds",new L.Bounds),Bt(this,"hasAnimatedTile",!1),Bt(this,"pointsBuf",[]),Bt(this,"batched"),Bt(this,"vbId",0),Bt(this,"vb",null),Bt(this,"vbBuffer",null),Bt(this,"vbArray",null),Bt(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 Zt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof L.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Zt(Wt.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let r=0;r<t.length;r++)if(t[r]?.source!==e.arr[r]){i=!1;break}if(i)return this}e=this.tileset=new Zt(Wt.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,r={}){this.didViewUpdate=!0;let l,c=-1,a=!1;if(typeof t=="number")c=t,a=!0,l=this.tileset.arr[c];else{let f;typeof t=="string"?f=L.Texture.from(t):f=t;const A=this.tileset;for(let P=0;P<A.count;P++)if(A.arr[P]===f.source){c=P;break}"frame"in f&&(r.u=r.u??f.frame.x,r.v=r.v??f.frame.y,r.tileWidth=r.tileWidth??f.orig.width,r.tileHeight=r.tileHeight??f.orig.height),l=f.source}if(!a&&!l)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:g=0,v:S=0,tileWidth:w=l.width,tileHeight:C=l.height,animX:M=0,animY:N=0,rotate:F=0,animCountX:k=1024,animCountY:R=1024,animDivisor:m=1,alpha:x=1}=r,y=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||M>0||N>0,y.push(g),y.push(S),y.push(e),y.push(i),y.push(w),y.push(C),y.push(F),y.push(M|0),y.push(N|0),y.push(c),y.push(k),y.push(R),y.push(m),y.push(x),this.tilemapBounds.addFrame(e,i,e+w,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(kt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(kt-7)]=t,i[i.length-(kt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(kt-8)]=t,i[i.length-(kt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(kt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(kt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/kt;let r=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&r)return;this.rects_count=i,r||(r=t.createVb(),this.vb=r,this.vbId=r.id,this.vbBuffer=null);const l=i*r.vertPerQuad;t.checkIndexBuffer(i);const c=r.getBuffer("aVertexPosition"),a=r.stride*l;if(!this.vbBuffer||this.vbBuffer.byteLength<a){let M=r.stride;for(;M<a;)M*=2;this.vbBuffer=new ArrayBuffer(M),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const g=this.vbArray,S=this.vbInts;let w=0,C=0;for(let M=0;M<e.length;M+=kt){this.compositeParent&&(C=e[M+9]);const F=e[M+2],k=e[M+3],R=e[M+4],m=e[M+5],x=e[M+0],y=e[M+1];let f=e[M+6];const A=e[M+7],P=e[M+8],I=e[M+10]||1024,O=e[M+11]||1024,_=A+I*2048,U=P+O*2048,V=e[M+12],z=e[M+13];let K,et,Q,W,Y,Z,yt,ct;if(f===0)K=x,et=y,Q=x+R,W=y,Y=x+R,Z=y+m,yt=x,ct=y+m;else{let H=R/2,it=m/2;f%4!==0&&(H=m/2,it=R/2);const vt=x+H,j=y+it;f=L.groupD8.add(f,L.groupD8.NW),K=vt+H*L.groupD8.uX(f),et=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),Q=vt+H*L.groupD8.uX(f),W=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),Y=vt+H*L.groupD8.uX(f),Z=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),yt=vt+H*L.groupD8.uX(f),ct=j+it*L.groupD8.uY(f)}g[w++]=F,g[w++]=k,g[w++]=K,g[w++]=et,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F+R,g[w++]=k,g[w++]=Q,g[w++]=W,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F+R,g[w++]=k+m,g[w++]=Y,g[w++]=Z,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F,g[w++]=k+m,g[w++]=yt,g[w++]=ct,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z}c.data=g}isModified(t){return!!(this.rects_count*kt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/kt}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,r,l){return this.tile(t,e,i,{animX:r,animY:l}),!0}addRect(t,e,i,r,l,c,a,g=0,S=0,w=0,C=1024,M=1024,N=1,F=1){return this.tile(t,r,l,{u:e,v:i,tileWidth:c,tileHeight:a,animX:g,animY:S,rotate:w,animCountX:C,animCountY:M,animDivisor:N,alpha:F})}}var Kr=Object.defineProperty,qr=(n,t,e)=>t in n?Kr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ae=(n,t,e)=>(qr(n,typeof t!="symbol"?t+"":t,e),e);class Wr extends L.Container{constructor(t){super(),ae(this,"texturesPerTilemap"),ae(this,"tileAnim",null),ae(this,"lastModifiedTilemap",null),ae(this,"modificationMarker",0),ae(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Wt.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,r=Math.ceil(t.length/e);for(let l=0;l<Math.min(i,r);l++)this.children[l].setTileset(t.slice(l*e,(l+1)*e));for(let l=i;l<r;l++){const c=new Ai(t.slice(l*e,(l+1)*e));c.compositeParent=!0,this.addChild(c)}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,r={}){let l=null;const c=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const a=t/this.texturesPerTilemap>>0;let g=0;if(l=c[a],l)g=t%this.texturesPerTilemap;else{if(l=c[0],!l)return this;g=0}l.tile(g,e,i,r)}else{typeof t=="string"&&(t=L.Texture.from(t));for(let a=0;a<c.length;a++){const g=c[a],S=g.getTileset().arr;for(let w=0;w<S.length;w++)if(S[w]===t.source){l=g;break}if(l)break}if(!l){for(let a=c.length-1;a>=0;a--){const g=c[a];if(g.getTileset().count<this.texturesPerTilemap){l=g,g.getTileset().push(t.source);break}}l||(l=new Ai(t.source),l.compositeParent=!0,this.addChild(l))}l.tile(t,e,i,r)}return this.lastModifiedTilemap=l,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,r,l,c,a,g,S){return this.tile(t,e,i,{animX:r,animY:l,animCountX:c,animCountY:a,animDivisor:g,alpha:S})}addRect(t,e,i,r,l,c,a,g,S,w,C,M){const N=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[N]&&this.children[N].getTileset().count>0?(this.lastModifiedTilemap=this.children[N],this.lastModifiedTilemap.addRect(F,e,i,r,l,c,a,g,S,w,C,M)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}L.extensions.add(Ei),L.extensions.add(vi),L.extensions.add(bi);class ye extends L.AnimatedSprite{constructor(t,e){super(ye.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=ye.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(r=>{i.push(e.textures[r.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=r=>{e++,t?t=L.groupD8.add(t,r):t=r};this.tile.horizontalFlip&&i(L.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(L.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(L.groupD8.MAIN_DIAGONAL):i(L.groupD8.REVERSE_DIAGONAL))}}Wt.use32bitIndex=!0;class ze extends D.DisplayObject(Wr){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let r=e.length-1;r>=0&&(i=e[r],!(i.firstgid&&i.firstgid<=t));r--);return i}createTile(t,e,i={}){const{real:r,filter:l}=i,{tilewidth:c,tileheight:a,width:g}=this._layer;r&&(t=Math.floor(t/c),e=Math.floor(e/a));const S=t+e*g,w=this._layer.getTileByIndex(S);if(!w||w&&w.gid==0)return;const C=ze.findTileSet(w.gid,this.tileSets);if(!C)return;const M=new ye(w,C);if(M.x=t*c,M.y=e*a+(a-M.texture.height),M._x=t,M._y=e,C.tileoffset&&(M.x+=C.tileoffset.x??0,M.y+=C.tileoffset.y??0),!(l&&!l(M)))return M}_addFrame(t,e,i){const r=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(r),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new Ve({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:r})=>{r.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 r=this.createTile(i,e);r&&this._addFrame(r,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",ze);function $r(n){return D.createComponent("CompositeTileLayer",n)}class Hr extends Tr{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await L.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let r=this.margin;r<this.image.width;r+=this.tilewidth+this.spacing)this.textures.push(new L.Texture({source:e.source,frame:new L.Rectangle(+r,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Xr(n,t,e){const i=[];for(const r of n){if(r.type!==ee.Tile){i.push(r);continue}const l=new Map;let c;if(Array.isArray(r.data))c=r.data.map(g=>typeof g=="number"?g:parseInt(String(g),10));else{i.push(r);continue}for(let g=0;g<c.length;g++){const S=c[g];if(S===0)continue;let w;for(let F=t.length-1;F>=0;F--)if(t[F].firstgid&&t[F].firstgid<=S){w=t[F];break}if(!w){l.has(0)||l.set(0,new Array(c.length).fill(0)),l.get(0)[g]=S;continue}const C=S-w.firstgid,M=w.tileset.tiles?.[C]?.properties,N=M?.z??0;M?.z,l.has(N)||l.set(N,new Array(c.length).fill(0)),l.get(N)[g]=S}const a=Array.from(l.keys()).sort((g,S)=>g-S);for(const g of a){const S=l.get(g);if(S.some(w=>w!==0)){const w={...r,name:`${r.name}_z${g}`,data:S,properties:{...r.properties,z:g}};i.push(w)}}}return i.sort((r,l)=>{const c=r.properties?.z??.5,a=l.properties?.z??.5;return c-a}),i}function Qr(n){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(n,{createLayersPerTilesZ:!1,basePath:""}),r=D.signal([]),l=n.objectLayer;let c=[],a={};const g=async(w,C="")=>typeof w!="string"?w:await new qt(w,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const w=t();if(w){a=await g(w,e()),c=[];for(let M of a.tilesets)M.tile&&(M.tiles=M.tile),M.tiles||(M.tiles=[]),c.push(await new Hr(M).load(M.image.source));let C=a.layers;i()&&(C=Xr(a.layers,c)),r.set(C)}});const S=(w,C={})=>D.h(D.Container,C,D.loop(w,M=>{switch(M.type){case ee.Tile:return D.h($r,{tilewidth:a.tilewidth,tileheight:a.tileheight,width:a.width,height:a.height,...M,tilesets:c});case ee.Image:const{width:N,height:F,source:k}=M.image;return D.h(D.TilingSprite,{image:k,...M,width:M.repeatx?M.width*M.tilewidth:N,height:M.repeaty?M.height*M.tileheight:F});case ee.Group:return S(D.signal(M.layers),M);case ee.ObjectGroup:const R=l?.(M);return D.h(D.Container,M,R);default:return D.h(D.Container)}}));return D.h(D.Container,n,S(r))}function Zr(){const n=`
|
|
213
213
|
precision mediump float;
|
|
214
214
|
in vec2 aPosition;
|
|
215
215
|
in vec2 aUV;
|
|
@@ -303,7 +303,7 @@ fn mainFrag(
|
|
|
303
303
|
float alpha = clamp(rain * 1.15, 0.0, 0.95);
|
|
304
304
|
finalColor = vec4(rainColor * alpha, alpha);
|
|
305
305
|
}
|
|
306
|
-
`;return new
|
|
306
|
+
`;return new L.GlProgram({vertex:n,fragment:t})}function Jr(){const n=`
|
|
307
307
|
precision mediump float;
|
|
308
308
|
in vec2 aPosition;
|
|
309
309
|
in vec2 aUV;
|
|
@@ -404,7 +404,7 @@ fn mainFrag(
|
|
|
404
404
|
float alpha = clamp(snow * 1.1, 0.0, 0.92);
|
|
405
405
|
finalColor = vec4(snowColor * alpha, alpha);
|
|
406
406
|
}
|
|
407
|
-
`;return new
|
|
407
|
+
`;return new L.GlProgram({vertex:n,fragment:t})}function tn(){const n=`
|
|
408
408
|
precision mediump float;
|
|
409
409
|
in vec2 aPosition;
|
|
410
410
|
in vec2 aUV;
|
|
@@ -512,7 +512,7 @@ fn mainFrag(
|
|
|
512
512
|
vec3 fogColor = mix(baseColor, brightColor, detail * 0.45);
|
|
513
513
|
finalColor = vec4(fogColor * alpha, alpha);
|
|
514
514
|
}
|
|
515
|
-
`;return new
|
|
515
|
+
`;return new L.GlProgram({vertex:n,fragment:t})}function en(){const n=`
|
|
516
516
|
precision mediump float;
|
|
517
517
|
in vec2 aPosition;
|
|
518
518
|
in vec2 aUV;
|
|
@@ -648,5 +648,26 @@ fn mainFrag(
|
|
|
648
648
|
}
|
|
649
649
|
finalColor = vec4(premulColor, alpha);
|
|
650
650
|
}
|
|
651
|
-
`;return new P.GlProgram({vertex:u,fragment:t})}const ci={lightRain:{effect:"rain",speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:"rain",speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:"rain",speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},ui={lightSnow:{effect:"snow",speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:"snow",speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:"snow",speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},hi={rpgMorningMist:{effect:"fog",speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:"fog",speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:"fog",speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:"fog",speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:"fog",speed:.1,density:1.7,height:.72,scale:2.3}},fi={lightClouds:{effect:"cloud",speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:"cloud",speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:"cloud",speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:"cloud",speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:"cloud",speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:"cloud",speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:"cloud",speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:"cloud",speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},Ir={rain:ci,snow:ui,fog:hi,cloud:fi},di=u=>{const{effect:t=I.signal("rain"),speed:e=I.signal(.5),windDirection:i=I.signal(0),windStrength:s=I.signal(.2),density:c=I.signal(120),maxDrops:o=I.signal(80),height:a=I.signal(1),scale:y=I.signal(2),sunIntensity:C=I.signal(.85),sunAngle:S=I.signal(.85),raySpread:B=I.signal(1),rayTwinkle:A=I.signal(.45),rayTwinkleSpeed:D=I.signal(1),resolution:F,...R}=I.useProps(u),N=I.signal([1e3,1e3]),m=I.signal(N()[0]),x=I.signal(N()[1]),_=I.signal(0),f=I.signal(0);let b;const O=typeof t=="function"?t:I.signal(t),k=F?typeof F=="function"?F:I.signal(F):N;I.mount(n=>{const p=n.props.context;let w=n.parent,v=!1;for(;w;){if(w.tag==="Viewport"){v=!0;break}w=w.parent}if(b=v?p?.viewport:void 0,b?.getVisibleBounds){const T=b.getVisibleBounds();T&&T.width>0&&T.height>0&&(N.set([T.width,T.height]),m.set(T.width),x.set(T.height),_.set(T.x),f.set(T.y))}p?.canvasSize&&I.effect(()=>{const T=p.canvasSize();T&&T.width>0&&T.height>0&&(b?.getVisibleBounds||(N.set([T.width,T.height]),m.set(T.width),x.set(T.height),_.set(0),f.set(0)))})});const L=typeof e=="function"?e:I.signal(e),g=typeof i=="function"?i:I.signal(i),q=typeof s=="function"?s:I.signal(s),Y=typeof c=="function"?c:I.signal(c),G=typeof o=="function"?o:I.signal(o),st=typeof a=="function"?a:I.signal(a),ft=typeof y=="function"?y:I.signal(y),at=typeof C=="function"?C:I.signal(C),ot=typeof S=="function"?S:I.signal(S),K=typeof B=="function"?B:I.signal(B),gt=typeof A=="function"?A:I.signal(A),xt=typeof D=="function"?D:I.signal(D),mt=n=>typeof n=="number"&&Number.isFinite(n)?n:1,W=n=>typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):.85,tt=n=>typeof n=="number"&&Number.isFinite(n)?n:.85,Tt=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?n:1,vt=n=>typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):.45,Ft=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?n:1,Rt=n=>[Math.cos(n),Math.sin(n)],d=n=>{if(!Array.isArray(n))return[1,1];const p=typeof n[0]=="number"&&Number.isFinite(n[0])&&n[0]>0?n[0]:1,w=typeof n[1]=="number"&&Number.isFinite(n[1])&&n[1]>0?n[1]:1;return[p,w]};let l,M;if(O()==="rain")l=Cr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uRainSpeed:{value:L(),type:"f32"},uWindDirection:{value:g(),type:"f32"},uWindStrength:{value:q(),type:"f32"},uRainDensity:{value:Y(),type:"f32"},uMaxDrops:{value:G(),type:"f32"}};else if(O()==="snow")l=Mr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSnowSpeed:{value:L(),type:"f32"},uWindDirection:{value:g(),type:"f32"},uWindStrength:{value:q(),type:"f32"},uSnowDensity:{value:Y(),type:"f32"},uMaxFlakes:{value:G(),type:"f32"}};else if(O()==="fog")l=Fr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSpeed:{value:L(),type:"f32"},uScale:{value:ft(),type:"f32"},uDensity:{value:Y(),type:"f32"},uHeight:{value:mt(st()),type:"f32"},uViewportOrigin:{value:[_(),f()],type:"vec2<f32>"}};else if(O()==="cloud"){const n=tt(ot());l=Br(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSpeed:{value:L(),type:"f32"},uScale:{value:ft(),type:"f32"},uDensity:{value:Y(),type:"f32"},uHeight:{value:mt(st()),type:"f32"},uViewportOrigin:{value:[_(),f()],type:"vec2<f32>"},uSunIntensity:{value:W(at()),type:"f32"},uSunDirection:{value:Rt(n),type:"vec2<f32>"},uRaySpread:{value:Tt(K()),type:"f32"},uRayTwinkle:{value:vt(gt()),type:"f32"},uRayTwinkleSpeed:{value:Ft(xt()),type:"f32"}}}else throw new Error(`Unknown weather effect: ${O()}. Supported: rain, snow, fog, cloud`);const E=new P.UniformGroup(M),Q=new P.Shader({glProgram:l,resources:{uniforms:E}}),lt=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 it=Math.random()*10,U=[...d(k())],z=g(),X=q(),j=L(),$=Y(),ct=G(),ut=st(),rt=ft(),ht=W(at()),Pt=tt(ot()),jt=Tt(K()),wt=vt(gt()),Wt=Ft(xt()),h=_(),r=f();return I.tick(({deltaTime:n})=>{if(b?.getVisibleBounds){const v=b.getVisibleBounds();if(v&&v.width>0&&v.height>0){const T=v.width,V=v.height,J=v.x,Z=v.y;T!==m()&&m.set(T),V!==x()&&x.set(V),J!==_()&&_.set(J),Z!==f()&&f.set(Z);const nt=N();(nt[0]!==T||nt[1]!==V)&&N.set([T,V])}}it+=n/600,E.uniforms.uTime=it;const p=d(k());if((p[0]!==U[0]||p[1]!==U[1])&&(E.uniforms.uResolution=p,U=[...p]),O()==="fog"||O()==="cloud"){const v=_(),T=f();(v!==h||T!==r)&&(E.uniforms.uViewportOrigin=[v,T],h=v,r=T)}const w=g();if(w!==z&&(E.uniforms.uWindDirection=w,z=w),O()==="rain"||O()==="snow"){const v=q();v!==X&&(E.uniforms.uWindStrength=v,X=v)}if(O()==="rain"){const v=L();v!==j&&(E.uniforms.uRainSpeed=v,j=v);const T=Y();T!==$&&(E.uniforms.uRainDensity=T,$=T);const V=G();V!==ct&&(E.uniforms.uMaxDrops=V,ct=V)}else if(O()==="snow"){const v=L();v!==j&&(E.uniforms.uSnowSpeed=v,j=v);const T=Y();T!==$&&(E.uniforms.uSnowDensity=T,$=T);const V=G();V!==ct&&(E.uniforms.uMaxFlakes=V,ct=V)}else if(O()==="fog"||O()==="cloud"){const v=L();v!==j&&(E.uniforms.uSpeed=v,j=v);const T=ft();T!==rt&&(E.uniforms.uScale=T,rt=T);const V=Y();V!==$&&(E.uniforms.uDensity=V,$=V);const J=mt(st());if(J!==ut&&(E.uniforms.uHeight=J,ut=J),O()==="cloud"){const Z=W(at());Z!==ht&&(E.uniforms.uSunIntensity=Z,ht=Z);const nt=tt(ot());nt!==Pt&&(E.uniforms.uSunDirection=Rt(nt),Pt=nt);const et=Tt(K());et!==jt&&(E.uniforms.uRaySpread=et,jt=et);const De=vt(gt());De!==wt&&(E.uniforms.uRayTwinkle=De,wt=De);const Ne=Ft(xt());Ne!==Wt&&(E.uniforms.uRayTwinkleSpeed=Ne,Wt=Ne)}}}),I.h(I.Mesh,{...R,geometry:lt,shader:Q,width:m,height:x,x:_,y:f})},Dr=di,Nr=[0,0,0,1],Or=[0,0,0,.55],Be={clarity:0,explored:!1},Ie=()=>Be,pi=new WeakMap,It=(u,t,e)=>Math.max(t,Math.min(e,u)),Rr=(u,t,e)=>{if(t<=u)return e>=t?1:0;const i=It((e-u)/(t-u),0,1);return i*i*(3-2*i)},dt=u=>typeof u=="function"?u():u;function Pr(){const u=I.signal(0);let t=Ie;const e=(s,c)=>(u(),!Number.isFinite(s)||!Number.isFinite(c)?Be:t(s,c)),i={version:()=>u(),clarityAt:(s,c)=>It(e(s,c).clarity,0,1),isVisibleAt:(s,c,o=.65)=>e(s,c).clarity>=It(o,0,1),isExploredAt:(s,c)=>{const o=e(s,c);return o.explored||o.clarity>0},stateAt:(s,c,o=.65)=>{const a=e(s,c);return a.clarity>=It(o,0,1)?"visible":a.explored||a.clarity>0?"explored":"unknown"}};return pi.set(i,{setSampler(s){t=typeof s=="function"?s:Ie},notifyUpdate(){u.update(s=>s+1)}}),i}const mi=(u,t)=>{const e=Array.isArray(u)?u:t,[i,s,c,o]=e,a=(y,C=!1)=>Number.isFinite(y)?y>=0&&y<=1?Math.round(y*255):It(Math.round(y),0,255):C?255:0;return{r:a(i),g:a(s),b:a(c),a:a(o,!0)}},kr=u=>{const t=dt(u);return Array.isArray(t)?t:[]};function Ur(u){const{mapWidth:t,mapHeight:e,tileSize:i=I.signal(32),smooth:s=I.signal(!0),renderScale:c=I.signal(2),edgeSoftness:o=I.signal(22),visionSources:a=I.signal([]),colors:y=I.signal({}),updateHz:C=I.signal(15),initialExplored:S=I.signal(!1),controller:B=void 0,obstacleMap:A=void 0,...D}=I.useProps(u);let F,R=null,N=P.Texture.WHITE,m=null,x=null,_=new Float32Array(0),f=new Uint8Array(0),b=1,O=1,k=1,L=1,g=1,q=1,Y=1,G=1,st=0,ft=!0,at=null,ot=null,K=[];if(F=(()=>{if(typeof document>"u")throw new Error("FogOfWar: document is undefined, canvas cannot be created.");const U=document.createElement("canvas");return U.width=1,U.height=1,U})(),R=F.getContext("2d",{willReadFrequently:!0}),!R)throw new Error("FogOfWar: unable to create 2D context for fog canvas.");N=P.Texture.from(F);const xt=()=>{const z=dt(s)!==!1?2:1,X=Number(dt(c));return Number.isFinite(X)?It(Math.round(X),1,8):z},mt=()=>{if(dt(s)===!1)return 0;const U=Number(dt(o));return Number.isFinite(U)?Math.max(0,U):Math.max(Y*.9,2)},W=()=>{const U=dt(B);return U&&typeof U=="object"?U:void 0},tt=()=>{const U=kr(a),z=[];for(let X=0;X<U.length;X++){const j=U[X];z.push({x:Number(dt(j.x)),y:Number(dt(j.y)),radius:Number(dt(j.radius)),enabled:dt(j.enabled)!==!1})}return z},Tt=U=>{const z=new Array(U.length*4);let X=0;for(let $=0;$<U.length;$++){const ct=U[$];z[X++]=ct.x,z[X++]=ct.y,z[X++]=ct.radius,z[X++]=ct.enabled?1:0}let j=z.length!==K.length;if(!j)for(let $=0;$<z.length;$++){const ct=z[$],ut=K[$];if(Number.isNaN(ct)!==Number.isNaN(ut)||Math.abs(ct-ut)>.01){j=!0;break}}return K=z,j},vt=(U,z)=>{if(!Number.isFinite(U)||!Number.isFinite(z)||k<=0||b<=0||O<=0)return Be;const X=It(U,0,Math.max(0,L-1)),j=It(z,0,Math.max(0,g-1)),$=Math.min(b-1,Math.max(0,Math.floor(X/Y))),ut=Math.min(O-1,Math.max(0,Math.floor(j/Y)))*b+$;return{clarity:It(_[ut]??0,0,1),explored:f[ut]===1}},Ft=U=>{const z=W()??null;z!==at&&(ot&&ot.setSampler(Ie),at=z,ot=at?pi.get(at)??null:null,ot&&ot.setSampler(vt),U=!0),U&&ot&&ot.notifyUpdate()},Rt=()=>{const U=N.source;U&&(U.scaleMode=dt(s)===!1?"nearest":"linear")},d=(U,z,X,j)=>{L=Math.max(1,Math.floor(U)),g=Math.max(1,Math.floor(z)),q=Math.max(1,Math.floor(X)),G=It(j,1,8),Y=Math.max(1,q/G),b=Math.max(1,Math.ceil(L/Y)),O=Math.max(1,Math.ceil(g/Y)),k=b*O,"width"in F&&(F.width=b,F.height=O),_=new Float32Array(k),f=new Uint8Array(k),dt(S)&&f.fill(1),m=R?.createImageData(b,O)??null,x=m?.data??null,Rt(),ft=!0},l=(U,z)=>{if(U.enabled===!1||!Number.isFinite(U.x)||!Number.isFinite(U.y)||!Number.isFinite(U.radius)||U.radius<=0)return;const X=U.x,j=U.y,ct=U.radius/Y,ut=Math.max(0,ct-z),rt=Math.max(ct,ct+z),ht=ut*ut,Pt=rt*rt,jt=Math.max(0,Math.floor(X/Y-rt)),wt=Math.min(b-1,Math.ceil(X/Y+rt)),Wt=Math.max(0,Math.floor(j/Y-rt)),h=Math.min(O-1,Math.ceil(j/Y+rt));for(let r=Wt;r<=h;r++)for(let n=jt;n<=wt;n++){const p=(n+.5)*Y,w=(r+.5)*Y,v=p-X,T=w-j,V=(v*v+T*T)/(Y*Y);if(V>Pt)continue;let J=1;if(rt>ut&&V>ht){const nt=Math.sqrt(V);J=1-Rr(ut,rt,nt)}if(J<=.001)continue;const Z=r*b+n;J>_[Z]&&(_[Z]=J),J>.02&&(f[Z]=1)}},M=U=>{if(!m||!x||!R)return;const z=dt(y)||{},X=mi(z.unknown,Nr),j=mi(z.explored,Or);_.fill(0);const $=U??tt(),ct=mt()/Y;for(let rt=0;rt<$.length;rt++)l($[rt],ct);for(let rt=0;rt<k;rt++){const ht=rt*4,Pt=It(_[rt],0,1),wt=f[rt]===1?j:X;x[ht]=wt.r,x[ht+1]=wt.g,x[ht+2]=wt.b,x[ht+3]=Math.round(wt.a*(1-Pt))}R.putImageData(m,0,0);const ut=N.source;ut&&typeof ut.update=="function"?ut.update():typeof N.update=="function"&&N.update(),Ft(!0)},E=Number(dt(t))||1,Q=Number(dt(e))||1,lt=Number(dt(i))||32,it=xt();return d(E,Q,lt,it),M(),I.tick(({deltaTime:U})=>{if(!R)return;const z=Math.max(1,Number(dt(t))||1),X=Math.max(1,Number(dt(e))||1),j=Math.max(1,Number(dt(i))||32),$=xt();(z!==L||X!==g||j!==q||$!==G)&&d(z,X,j,$),Rt(),Ft(!1);const ct=tt(),ut=Tt(ct);ut&&(ft=!0);const ht=1e3/Math.max(1,Number(dt(C))||15);st+=U,(ft||ut||st>=ht)&&(st=0,ft=!1,M(ct))}),I.h(I.Sprite,{...D,texture:N,x:0,y:0,width:Math.max(1,Number(dt(t))||1),height:Math.max(1,Number(dt(e))||1),roundPixels:!0})}return Et.Bar=gi,Et.CLOUD_PRESETS=fi,Et.FOG_PRESETS=hi,Et.FogOfWar=Ur,Et.Loading=Ui,Et.NightAmbiant=ki,Et.Particle=Ci,Et.RAIN_PRESETS=ci,Et.SNOW_PRESETS=ui,Et.TiledMap=Ar,Et.WEATHER_PRESETS=Ir,Et.Weather=Dr,Et.WeatherEffect=di,Et.createFogOfWarController=Pr,Et.createNightFilter=Ue,Object.defineProperty(Et,Symbol.toStringTag,{value:"Module"}),Et})({},CanvasEngine,PIXI);
|
|
651
|
+
`;return new L.GlProgram({vertex:n,fragment:t})}const Ti={lightRain:{effect:"rain",speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:"rain",speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:"rain",speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},Mi={lightSnow:{effect:"snow",speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:"snow",speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:"snow",speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},Ci={rpgMorningMist:{effect:"fog",speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:"fog",speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:"fog",speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:"fog",speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:"fog",speed:.1,density:1.7,height:.72,scale:2.3}},Fi={lightClouds:{effect:"cloud",speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:"cloud",speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:"cloud",speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:"cloud",speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:"cloud",speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:"cloud",speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:"cloud",speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:"cloud",speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},rn={rain:Ti,snow:Mi,fog:Ci,cloud:Fi},Bi=n=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:r=D.signal(.2),density:l=D.signal(120),maxDrops:c=D.signal(80),height:a=D.signal(1),scale:g=D.signal(2),sunIntensity:S=D.signal(.85),sunAngle:w=D.signal(.85),raySpread:C=D.signal(1),rayTwinkle:M=D.signal(.45),rayTwinkleSpeed:N=D.signal(1),resolution:F,...k}=D.useProps(n),R=D.signal([1e3,1e3]),m=D.signal(R()[0]),x=D.signal(R()[1]),y=D.signal(0),f=D.signal(0);let A;const P=typeof t=="function"?t:D.signal(t),I=F?typeof F=="function"?F:D.signal(F):R;D.mount(o=>{const p=o.props.context;let v=o.parent,b=!1;for(;v;){if(v.tag==="Viewport"){b=!0;break}v=v.parent}if(A=b?p?.viewport:void 0,A?.getVisibleBounds){const T=A.getVisibleBounds();T&&T.width>0&&T.height>0&&(R.set([T.width,T.height]),m.set(T.width),x.set(T.height),y.set(T.x),f.set(T.y))}p?.canvasSize&&D.effect(()=>{const T=p.canvasSize();T&&T.width>0&&T.height>0&&(A?.getVisibleBounds||(R.set([T.width,T.height]),m.set(T.width),x.set(T.height),y.set(0),f.set(0)))})});const O=typeof e=="function"?e:D.signal(e),_=typeof i=="function"?i:D.signal(i),U=typeof r=="function"?r:D.signal(r),V=typeof l=="function"?l:D.signal(l),z=typeof c=="function"?c:D.signal(c),K=typeof a=="function"?a:D.signal(a),et=typeof g=="function"?g:D.signal(g),Q=typeof S=="function"?S:D.signal(S),W=typeof w=="function"?w:D.signal(w),Y=typeof C=="function"?C:D.signal(C),Z=typeof M=="function"?M:D.signal(M),yt=typeof N=="function"?N:D.signal(N),ct=o=>typeof o=="number"&&Number.isFinite(o)?o:1,H=o=>typeof o=="number"&&Number.isFinite(o)?Math.max(0,o):.85,it=o=>typeof o=="number"&&Number.isFinite(o)?o:.85,vt=o=>typeof o=="number"&&Number.isFinite(o)&&o>0?o:1,j=o=>typeof o=="number"&&Number.isFinite(o)?Math.max(0,o):.45,Mt=o=>typeof o=="number"&&Number.isFinite(o)&&o>0?o:1,bt=o=>[Math.cos(o),Math.sin(o)],d=o=>{if(!Array.isArray(o))return[1,1];const p=typeof o[0]=="number"&&Number.isFinite(o[0])&&o[0]>0?o[0]:1,v=typeof o[1]=="number"&&Number.isFinite(o[1])&&o[1]>0?o[1]:1;return[p,v]};let u,B;if(P()==="rain")u=Zr(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uRainSpeed:{value:O(),type:"f32"},uWindDirection:{value:_(),type:"f32"},uWindStrength:{value:U(),type:"f32"},uRainDensity:{value:V(),type:"f32"},uMaxDrops:{value:z(),type:"f32"}};else if(P()==="snow")u=Jr(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSnowSpeed:{value:O(),type:"f32"},uWindDirection:{value:_(),type:"f32"},uWindStrength:{value:U(),type:"f32"},uSnowDensity:{value:V(),type:"f32"},uMaxFlakes:{value:z(),type:"f32"}};else if(P()==="fog")u=tn(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSpeed:{value:O(),type:"f32"},uScale:{value:et(),type:"f32"},uDensity:{value:V(),type:"f32"},uHeight:{value:ct(K()),type:"f32"},uViewportOrigin:{value:[y(),f()],type:"vec2<f32>"}};else if(P()==="cloud"){const o=it(W());u=en(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSpeed:{value:O(),type:"f32"},uScale:{value:et(),type:"f32"},uDensity:{value:V(),type:"f32"},uHeight:{value:ct(K()),type:"f32"},uViewportOrigin:{value:[y(),f()],type:"vec2<f32>"},uSunIntensity:{value:H(Q()),type:"f32"},uSunDirection:{value:bt(o),type:"vec2<f32>"},uRaySpread:{value:vt(Y()),type:"f32"},uRayTwinkle:{value:j(Z()),type:"f32"},uRayTwinkleSpeed:{value:Mt(yt()),type:"f32"}}}else throw new Error(`Unknown weather effect: ${P()}. Supported: rain, snow, fog, cloud`);const E=new L.UniformGroup(B),J=new L.Shader({glProgram:u,resources:{uniforms:E}}),ut=new L.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 rt=Math.random()*10,G=[...d(I())],X=_(),tt=U(),q=O(),ot=V(),xt=z(),wt=K(),ft=et(),Et=H(Q()),Kt=it(W()),Jt=vt(Y()),Nt=j(Z()),ie=Mt(yt()),h=y(),s=f();return D.tick(({deltaTime:o})=>{if(A?.getVisibleBounds){const b=A.getVisibleBounds();if(b&&b.width>0&&b.height>0){const T=b.width,$=b.height,at=b.x,lt=b.y;T!==m()&&m.set(T),$!==x()&&x.set($),at!==y()&&y.set(at),lt!==f()&&f.set(lt);const dt=R();(dt[0]!==T||dt[1]!==$)&&R.set([T,$])}}rt+=o/600,E.uniforms.uTime=rt;const p=d(I());if((p[0]!==G[0]||p[1]!==G[1])&&(E.uniforms.uResolution=p,G=[...p]),P()==="fog"||P()==="cloud"){const b=y(),T=f();(b!==h||T!==s)&&(E.uniforms.uViewportOrigin=[b,T],h=b,s=T)}const v=_();if(v!==X&&(E.uniforms.uWindDirection=v,X=v),P()==="rain"||P()==="snow"){const b=U();b!==tt&&(E.uniforms.uWindStrength=b,tt=b)}if(P()==="rain"){const b=O();b!==q&&(E.uniforms.uRainSpeed=b,q=b);const T=V();T!==ot&&(E.uniforms.uRainDensity=T,ot=T);const $=z();$!==xt&&(E.uniforms.uMaxDrops=$,xt=$)}else if(P()==="snow"){const b=O();b!==q&&(E.uniforms.uSnowSpeed=b,q=b);const T=V();T!==ot&&(E.uniforms.uSnowDensity=T,ot=T);const $=z();$!==xt&&(E.uniforms.uMaxFlakes=$,xt=$)}else if(P()==="fog"||P()==="cloud"){const b=O();b!==q&&(E.uniforms.uSpeed=b,q=b);const T=et();T!==ft&&(E.uniforms.uScale=T,ft=T);const $=V();$!==ot&&(E.uniforms.uDensity=$,ot=$);const at=ct(K());if(at!==wt&&(E.uniforms.uHeight=at,wt=at),P()==="cloud"){const lt=H(Q());lt!==Et&&(E.uniforms.uSunIntensity=lt,Et=lt);const dt=it(W());dt!==Kt&&(E.uniforms.uSunDirection=bt(dt),Kt=dt);const ht=vt(Y());ht!==Jt&&(E.uniforms.uRaySpread=ht,Jt=ht);const $e=j(Z());$e!==Nt&&(E.uniforms.uRayTwinkle=$e,Nt=$e);const He=Mt(yt());He!==ie&&(E.uniforms.uRayTwinkleSpeed=He,ie=He)}}}),D.h(D.Mesh,{...k,geometry:ut,shader:J,width:m,height:x,x:y,y:f})},nn=Bi,sn=[0,0,0,1],on=[0,0,0,.55],Ge={clarity:0,explored:!1},je=()=>Ge,Ni=new WeakMap,Lt=(n,t,e)=>Math.max(t,Math.min(e,n)),an=(n,t,e)=>{if(t<=n)return e>=t?1:0;const i=Lt((e-n)/(t-n),0,1);return i*i*(3-2*i)},St=n=>typeof n=="function"?n():n;function ln(){const n=D.signal(0);let t=je;const e=(r,l)=>(n(),!Number.isFinite(r)||!Number.isFinite(l)?Ge:t(r,l)),i={version:()=>n(),clarityAt:(r,l)=>Lt(e(r,l).clarity,0,1),isVisibleAt:(r,l,c=.65)=>e(r,l).clarity>=Lt(c,0,1),isExploredAt:(r,l)=>{const c=e(r,l);return c.explored||c.clarity>0},stateAt:(r,l,c=.65)=>{const a=e(r,l);return a.clarity>=Lt(c,0,1)?"visible":a.explored||a.clarity>0?"explored":"unknown"}};return Ni.set(i,{setSampler(r){t=typeof r=="function"?r:je},notifyUpdate(){n.update(r=>r+1)}}),i}const Ii=(n,t)=>{const e=Array.isArray(n)?n:t,[i,r,l,c]=e,a=(g,S=!1)=>Number.isFinite(g)?g>=0&&g<=1?Math.round(g*255):Lt(Math.round(g),0,255):S?255:0;return{r:a(i),g:a(r),b:a(l),a:a(c,!0)}},cn=n=>{const t=St(n);return Array.isArray(t)?t:[]};function un(n){const{mapWidth:t,mapHeight:e,tileSize:i=D.signal(32),smooth:r=D.signal(!0),renderScale:l=D.signal(2),edgeSoftness:c=D.signal(22),visionSources:a=D.signal([]),colors:g=D.signal({}),updateHz:S=D.signal(15),initialExplored:w=D.signal(!1),controller:C=void 0,obstacleMap:M=void 0,...N}=D.useProps(n);let F,k=null,R=L.Texture.WHITE,m=null,x=null,y=new Float32Array(0),f=new Uint8Array(0),A=1,P=1,I=1,O=1,_=1,U=1,V=1,z=1,K=0,et=!0,Q=null,W=null,Y=[];if(F=(()=>{if(typeof document>"u")throw new Error("FogOfWar: document is undefined, canvas cannot be created.");const G=document.createElement("canvas");return G.width=1,G.height=1,G})(),k=F.getContext("2d",{willReadFrequently:!0}),!k)throw new Error("FogOfWar: unable to create 2D context for fog canvas.");R=L.Texture.from(F);const yt=()=>{const X=St(r)!==!1?2:1,tt=Number(St(l));return Number.isFinite(tt)?Lt(Math.round(tt),1,8):X},ct=()=>{if(St(r)===!1)return 0;const G=Number(St(c));return Number.isFinite(G)?Math.max(0,G):Math.max(V*.9,2)},H=()=>{const G=St(C);return G&&typeof G=="object"?G:void 0},it=()=>{const G=cn(a),X=[];for(let tt=0;tt<G.length;tt++){const q=G[tt];X.push({x:Number(St(q.x)),y:Number(St(q.y)),radius:Number(St(q.radius)),enabled:St(q.enabled)!==!1})}return X},vt=G=>{const X=new Array(G.length*4);let tt=0;for(let ot=0;ot<G.length;ot++){const xt=G[ot];X[tt++]=xt.x,X[tt++]=xt.y,X[tt++]=xt.radius,X[tt++]=xt.enabled?1:0}let q=X.length!==Y.length;if(!q)for(let ot=0;ot<X.length;ot++){const xt=X[ot],wt=Y[ot];if(Number.isNaN(xt)!==Number.isNaN(wt)||Math.abs(xt-wt)>.01){q=!0;break}}return Y=X,q},j=(G,X)=>{if(!Number.isFinite(G)||!Number.isFinite(X)||I<=0||A<=0||P<=0)return Ge;const tt=Lt(G,0,Math.max(0,O-1)),q=Lt(X,0,Math.max(0,_-1)),ot=Math.min(A-1,Math.max(0,Math.floor(tt/V))),wt=Math.min(P-1,Math.max(0,Math.floor(q/V)))*A+ot;return{clarity:Lt(y[wt]??0,0,1),explored:f[wt]===1}},Mt=G=>{const X=H()??null;X!==Q&&(W&&W.setSampler(je),Q=X,W=Q?Ni.get(Q)??null:null,W&&W.setSampler(j),G=!0),G&&W&&W.notifyUpdate()},bt=()=>{const G=R.source;G&&(G.scaleMode=St(r)===!1?"nearest":"linear")},d=(G,X,tt,q)=>{O=Math.max(1,Math.floor(G)),_=Math.max(1,Math.floor(X)),U=Math.max(1,Math.floor(tt)),z=Lt(q,1,8),V=Math.max(1,U/z),A=Math.max(1,Math.ceil(O/V)),P=Math.max(1,Math.ceil(_/V)),I=A*P,"width"in F&&(F.width=A,F.height=P),y=new Float32Array(I),f=new Uint8Array(I),St(w)&&f.fill(1),m=k?.createImageData(A,P)??null,x=m?.data??null,bt(),et=!0},u=(G,X)=>{if(G.enabled===!1||!Number.isFinite(G.x)||!Number.isFinite(G.y)||!Number.isFinite(G.radius)||G.radius<=0)return;const tt=G.x,q=G.y,xt=G.radius/V,wt=Math.max(0,xt-X),ft=Math.max(xt,xt+X),Et=wt*wt,Kt=ft*ft,Jt=Math.max(0,Math.floor(tt/V-ft)),Nt=Math.min(A-1,Math.ceil(tt/V+ft)),ie=Math.max(0,Math.floor(q/V-ft)),h=Math.min(P-1,Math.ceil(q/V+ft));for(let s=ie;s<=h;s++)for(let o=Jt;o<=Nt;o++){const p=(o+.5)*V,v=(s+.5)*V,b=p-tt,T=v-q,$=(b*b+T*T)/(V*V);if($>Kt)continue;let at=1;if(ft>wt&&$>Et){const dt=Math.sqrt($);at=1-an(wt,ft,dt)}if(at<=.001)continue;const lt=s*A+o;at>y[lt]&&(y[lt]=at),at>.02&&(f[lt]=1)}},B=G=>{if(!m||!x||!k)return;const X=St(g)||{},tt=Ii(X.unknown,sn),q=Ii(X.explored,on);y.fill(0);const ot=G??it(),xt=ct()/V;for(let ft=0;ft<ot.length;ft++)u(ot[ft],xt);for(let ft=0;ft<I;ft++){const Et=ft*4,Kt=Lt(y[ft],0,1),Nt=f[ft]===1?q:tt;x[Et]=Nt.r,x[Et+1]=Nt.g,x[Et+2]=Nt.b,x[Et+3]=Math.round(Nt.a*(1-Kt))}k.putImageData(m,0,0);const wt=R.source;wt&&typeof wt.update=="function"?wt.update():typeof R.update=="function"&&R.update(),Mt(!0)},E=Number(St(t))||1,J=Number(St(e))||1,ut=Number(St(i))||32,rt=yt();return d(E,J,ut,rt),B(),D.tick(({deltaTime:G})=>{if(!k)return;const X=Math.max(1,Number(St(t))||1),tt=Math.max(1,Number(St(e))||1),q=Math.max(1,Number(St(i))||32),ot=yt();(X!==O||tt!==_||q!==U||ot!==z)&&d(X,tt,q,ot),bt(),Mt(!1);const xt=it(),wt=vt(xt);wt&&(et=!0);const Et=1e3/Math.max(1,Number(St(S))||15);K+=G,(et||wt||K>=Et)&&(K=0,et=!1,B(xt))}),D.h(D.Sprite,{...N,texture:R,x:0,y:0,width:Math.max(1,Number(St(t))||1),height:Math.max(1,Number(St(e))||1),roundPixels:!0})}const hn=`/**
|
|
652
|
+
* Gradient alpha for projected sprite shadows.
|
|
653
|
+
* Strong alpha near the caster's feet (vTextureCoord.y ~ 1),
|
|
654
|
+
* softer alpha at the shadow tip (vTextureCoord.y ~ 0).
|
|
655
|
+
*/
|
|
656
|
+
precision highp float;
|
|
657
|
+
precision highp int;
|
|
658
|
+
|
|
659
|
+
in vec2 vTextureCoord;
|
|
660
|
+
out vec4 finalColor;
|
|
661
|
+
|
|
662
|
+
uniform sampler2D uTexture;
|
|
663
|
+
uniform float uPower;
|
|
664
|
+
uniform float uFloor;
|
|
665
|
+
|
|
666
|
+
void main() {
|
|
667
|
+
vec4 color = texture(uTexture, vTextureCoord);
|
|
668
|
+
float gradient = pow(clamp(vTextureCoord.y, 0.0, 1.0), max(0.001, uPower));
|
|
669
|
+
float alphaMul = mix(clamp(uFloor, 0.0, 1.0), 1.0, gradient);
|
|
670
|
+
finalColor = vec4(color.rgb, color.a * alphaMul);
|
|
671
|
+
}
|
|
672
|
+
`,le="__spriteShadowManaged",Di=220,fn=360,dn=1,pn="strongest",mn=30,yn=0,Vt={height:72,footOffset:{x:0,y:0},footAnchor:{x:.5,y:1},alpha:.56,blur:3.5,gradientPower:2,hardness:.42,minLength:10,maxLength:280,contactAlpha:.28,contactScale:.28},gt=(n,t,e)=>Math.max(t,Math.min(e,n)),nt=n=>typeof n=="number"&&Number.isFinite(n),_t=n=>{if(n&&typeof n=="object"&&"value"in n&&Object.keys(n).length<=2)return n.value;if(typeof n=="function")try{return n()}catch{return}return n},gn=n=>{if(typeof n=="number"&&Number.isFinite(n))return Math.max(0,Math.floor(n))&16777215;if(typeof n=="string"){const t=n.trim().replace(/^#/,""),e=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,i=parseInt(e,16);if(Number.isFinite(i))return i&16777215}return yn},Oi=(n,t)=>{const e=_t(n),i=Number(e?.x),r=Number(e?.y);return{x:nt(i)?i:t.x,y:nt(r)?r:t.y}},Ri=(n,t)=>{if(n&&typeof n.toGlobal=="function"){const e=n.toGlobal(t);if(nt(e?.x)&&nt(e?.y))return{x:e.x,y:e.y}}return t},Pi=(n,t)=>{if(n&&typeof n.toLocal=="function"){const e=n.toLocal(t);if(nt(e?.x)&&nt(e?.y))return{x:e.x,y:e.y}}return t},Ui=(n=2,t=.06)=>{const e={value:n,type:"f32"},i={value:t,type:"f32"},r=L.Filter.from({gl:{vertex:ti,fragment:hn},resources:{shadowGradientUniforms:{uPower:e,uFloor:i}}});return r.setGradient=(l,c)=>{e.value=nt(l)?Math.max(.001,l):2,i.value=nt(c)?gt(c,0,1):.06},r},_n=n=>{if(n===!1||n===null||n===void 0)return null;const t=n===!0||typeof n!="object"?{}:n;if(_t(t.enabled)===!1)return null;const i=Number(_t(t.height)),r=Number(_t(t.alpha)),l=Number(_t(t.blur)),c=Number(_t(t.gradientPower)),a=Number(_t(t.hardness)),g=Number(_t(t.minLength)),S=Number(_t(t.maxLength)),w=Number(_t(t.contactAlpha)),C=Number(_t(t.contactScale)),M=Number(_t(t.anchorX));return{height:nt(i)?Math.max(2,i):Vt.height,footOffset:Oi(t.footOffset,Vt.footOffset),footAnchor:Oi(t.footAnchor,Vt.footAnchor),alpha:nt(r)?gt(r,0,1.5):Vt.alpha,blur:nt(l)?Math.max(0,l):Vt.blur,gradientPower:nt(c)?gt(c,.2,8):Vt.gradientPower,hardness:nt(a)?gt(a,0,1):Vt.hardness,minLength:nt(g)?Math.max(0,g):Vt.minLength,maxLength:nt(S)?Math.max(2,S):Vt.maxLength,contactAlpha:nt(w)?gt(w,0,1):Vt.contactAlpha,contactScale:nt(C)?Math.max(.05,C):Vt.contactScale,anchorX:nt(M)?gt(M,0,1):void 0}},xn=n=>{if(!n||n[le])return null;const t=typeof n.getElement=="function"?n.getElement():null,e=_t(n.shadowCaster)??_t(n.fullProps?.shadowCaster)??_t(t?.props?.shadowCaster)??_t(t?.propObservables?.shadowCaster);return e===void 0?null:_n(e)},wn=n=>{const t=[],e=[n];for(;e.length>0;){const i=e.pop(),r=Array.isArray(i?.children)?i.children:[];for(let l=0;l<r.length;l++){const c=r[l];if(!c||c[le])continue;const a=xn(c);a&&c.parent&&t.push({instance:c,caster:a}),Array.isArray(c.children)&&c.children.length>0&&e.push(c)}}return t},En=(n,t)=>{const e=_t(n);if(!Array.isArray(e))return[];const i=[];for(let r=0;r<e.length;r++){const l=e[r];if(_t(l.enabled)===!1)continue;const a=Number(_t(l.x)),g=Number(_t(l.y));if(!nt(a)||!nt(g))continue;const S=Number(_t(l.z)),w=Number(_t(l.radius)),C=Number(_t(l.intensity)),M=Number(_t(l.shadowWeight)),N=Ri(t,{x:a,y:g});i.push({x:a,y:g,globalX:N.x,globalY:N.y,z:nt(S)?Math.max(2,S):Di,radius:nt(w)?Math.max(1,w):fn,intensity:nt(C)?gt(C,0,2):dn,shadowWeight:nt(M)?gt(M,0,4):1})}return i},vn=(n,t)=>{if(n.length===0)return null;if(n.sort((g,S)=>S.influence-g.influence),t==="strongest"||n.length===1)return n[0];const e=n.slice(0,2);let i=0,r=0,l=0,c=0;for(let g=0;g<e.length;g++){const S=e[g],w=Math.max(.001,S.influence);i+=S.dirX*w,r+=S.dirY*w,l+=S.length*w,c+=w}if(c<=0)return null;const a=Math.hypot(i,r);return a<=1e-4?null:{dirX:i/a,dirY:r/a,length:l/c,influence:gt(c/e.length,0,2)}},ce=n=>{n.near.visible=!1,n.far.visible=!1,n.contact.visible=!1},Ke=n=>{n.near.destroy(),n.far.destroy(),n.contact.destroy()},bn=(n,t,e)=>{const i=new L.Sprite,r=new L.Sprite,l=new L.Sprite,c=new L.BlurFilter({strength:2.5,quality:2}),a=new L.BlurFilter({strength:4.2,quality:3}),g=new L.BlurFilter({strength:2.8,quality:2}),S=Ui(2,.08),w=Ui(2.8,.02);return i.filters=[S,c],r.filters=[w,a],l.filters=[g],i.tint=e,r.tint=e,l.tint=e,i.blendMode="multiply",r.blendMode="multiply",l.blendMode="multiply",i.eventMode="none",r.eventMode="none",l.eventMode="none",i.roundPixels=!0,r.roundPixels=!0,l.roundPixels=!0,i.visible=!1,r.visible=!1,l.visible=!1,i.alpha=0,r.alpha=0,i[le]=!0,r[le]=!0,l[le]=!0,t.addChild(l),t.addChild(r),t.addChild(i),{caster:n,parent:t,near:i,far:r,contact:l,nearBlur:c,farBlur:a,contactBlur:g,nearGradient:S,farGradient:w,dirX:0,dirY:1,length:0}},Sn=n=>{const{caster:t,parent:e,near:i,far:r,contact:l}=n;if(!t||t.destroyed||!e)return;const c=nt(t.zIndex)?t.zIndex:0;if(l.zIndex=c-.32,r.zIndex=c-.26,i.zIndex=c-.22,e.sortableChildren||!Array.isArray(e.children)||!e.children.includes(t))return;const a=g=>{if(!g||g.destroyed||!e.children.includes(g))return;const S=e.getChildIndex(t),w=Math.max(0,S-1);e.getChildIndex(g)!==w&&e.setChildIndex(g,w)};a(l),a(r),a(i)},An=(n,t,e,i,r)=>{const l=n.caster,c=n.parent;if(!l||l.destroyed||!c||c.destroyed){ce(n);return}if(l.visible===!1||nt(l.worldAlpha)&&l.worldAlpha<=.001){ce(n);return}const a=typeof l.getBounds=="function"?l.getBounds():null;if(!(!!a&&nt(a.x)&&nt(a.y)&&nt(a.width)&&nt(a.height)&&a.width>0&&a.height>0)){ce(n);return}const S=Math.max(1,Math.abs(Number(l.width))||Math.abs(a.width)),w=Math.max(1,Math.abs(Number(l.height))||Math.abs(a.height)),C=Number(l.anchor?.x),M=Number(l.anchor?.y),N=nt(C)?gt(C,0,1):.5,F=nt(M)?gt(M,0,1):1,k=nt(t.anchorX)?t.anchorX:N,R={x:(t.footAnchor.x-N)*S+t.footOffset.x,y:(t.footAnchor.y-F)*w+t.footOffset.y},m=Ri(l,R),x=Pi(c,m),y=[];for(let Mt=0;Mt<e.length;Mt++){const bt=e[Mt];if(bt.intensity<=.001||bt.radius<=.001)continue;const d=Pi(c,{x:bt.globalX,y:bt.globalY}),u=x.x-d.x,B=x.y-d.y,E=Math.hypot(u,B),J=gt(1-E/bt.radius,0,1),ut=gt(Di/Math.max(12,bt.z),.35,2.4),rt=gt(J*J*bt.intensity*bt.shadowWeight*ut,0,2.2);if(rt<=.001)continue;const G=E>1e-4?E:1,X=u/G,tt=B/G,q=gt(E*t.height/Math.max(14,bt.z),t.minLength,t.maxLength);y.push({dirX:nt(X)?X:0,dirY:nt(tt)?tt:1,influence:rt,length:nt(q)?q:t.minLength})}const f=vn(y,i);if(!f){ce(n);return}const A=l.texture;if(!A){ce(n);return}const P=.34,I=.32,O=n.dirX+(f.dirX-n.dirX)*P,_=n.dirY+(f.dirY-n.dirY)*P,U=Math.hypot(O,_),V=U>1e-4?O/U:f.dirX,z=U>1e-4?_/U:f.dirY,K=n.length+(f.length-n.length)*I;n.dirX=V,n.dirY=z,n.length=K;const et=gt(K/w,.08,6),Q=gt(.62+et*.08,.5,1.2),W=gt(t.hardness,0,1),Y=gt(f.influence,0,1.35),Z=gt(t.alpha*Y,0,1),yt=Math.max(0,t.blur*(1.15-W*.55)),ct=gt(t.gradientPower+(1-W)*.7,.2,8),H=Math.atan2(z,V)+Math.PI/2;n.near.texture=A,n.far.texture=A,n.contact.texture=A,n.near.tint=r,n.far.tint=r,n.contact.tint=r,n.near.anchor.set(k,1),n.far.anchor.set(k,1),n.contact.anchor.set(k,1),n.near.width=S*Q,n.near.height=w*Math.max(.12,et*1.06),n.far.width=n.near.width*1.02,n.far.height=n.near.height*1.22,n.near.position.set(x.x,x.y),n.far.position.set(x.x+V*K*.34,x.y+z*K*.34),n.contact.position.set(x.x+V*Math.min(4,K*.06),x.y+z*Math.min(4,K*.06)),n.near.rotation=H,n.far.rotation=H,n.contact.rotation=H,n.near.alpha=gt(Z*(.74+W*.2),0,1),n.far.alpha=gt(Z*(.3+(1-W)*.2),0,1),n.near.visible=n.near.alpha>.001,n.far.visible=n.far.alpha>.001,n.nearBlur.strength=yt*(.72+(1-Y)*.45),n.farBlur.strength=yt*(1.45+(1-Y)*1.1),n.nearGradient.setGradient(ct,.08),n.farGradient.setGradient(ct+.65,.03);const it=gt(t.contactAlpha*Y*.85,0,1),vt=Math.max(4,S*gt(t.contactScale*1.8,.25,1.3)),j=Math.max(2,w*gt(t.contactScale*.62,.08,.56));n.contact.width=vt*(.92+et*.18),n.contact.height=j,n.contact.alpha=gt(it*(.6+W*.2),0,1),n.contactBlur.strength=yt*(.85+(1-W)*.25),n.contact.visible=n.contact.alpha>.001,Sn(n)};function Tn(n={}){const t=D.useProps(n),e=()=>t.lights??t.sources;return D.mount(i=>{const r=i.props.context,c=r?.viewport??i.parent?.componentInstance;if(!c||typeof c.addChild!="function")return;const a=r?.tick,g=new Map;let S=0,w=!0,C=null;const M=()=>{const N=gn(_t(t.shadowColor)),k=_t(t.mode)==="blend2"?"blend2":pn,R=En(e(),c),m=wn(c),x=new Set;for(let y=0;y<m.length;y++){const{instance:f,caster:A}=m[y];if(!f||!f.parent||f.destroyed)continue;x.add(f);let P=g.get(f);(!P||P.parent!==f.parent)&&(P&&Ke(P),P=bn(f,f.parent,N),g.set(f,P)),An(P,A,R,k,N)}for(const[y,f]of g.entries())(!x.has(y)||!y||y.destroyed)&&(Ke(f),g.delete(y))};return C=a?.observable?.subscribe(N=>{const F=N?.value??N,k=Number(F?.deltaTime),R=nt(k)?k:16.67,m=Number(_t(t.updateHz)),y=1e3/gt(nt(m)?m:mn,1,120);S+=R,(w||S>=y)&&(S=0,w=!1,M())}),M(),()=>{C?.unsubscribe?.();for(const N of g.values())Ke(N);g.clear()}}),D.h(D.Container)}const qe="__footprintManaged",ge="default",Mn=30,Cn=260,Yt={footAnchor:{x:.5,y:1},leftOffset:{x:-10,y:1},rightOffset:{x:10,y:1},minStepDistance:18,minSpeed:36,stepIntervalMs:85,size:1,alpha:1,blur:0,angleOffset:0,jitter:8},Ut={lifetimeMs:1800,startAlpha:.32,endAlpha:0,tint:2959910,blendMode:"multiply",scale:1,blurStart:.45,blurEnd:1.9,erosionStart:.54,depth:.58,rimStrength:.14},Fn={[ge]:Ut,sand:{lifetimeMs:1650,startAlpha:.31,endAlpha:0,tint:9334086,blendMode:"multiply",scale:1,blurStart:.35,blurEnd:1.5,erosionStart:.62,depth:.54,rimStrength:.12},snow:{lifetimeMs:2550,startAlpha:.24,endAlpha:0,tint:8228771,blendMode:"multiply",scale:1.05,blurStart:.6,blurEnd:2.25,erosionStart:.45,depth:.72,rimStrength:.28}},At=(n,t,e)=>Math.max(t,Math.min(e,n)),_e=(n,t,e)=>n+(t-n)*e,ki=(n,t,e)=>{const i=At((e-n)/Math.max(1e-4,t-n),0,1);return i*i*(3-2*i)},mt=n=>typeof n=="number"&&Number.isFinite(n),Bn=n=>n==="left"?"right":"left",Li=n=>n*Math.PI/180,pt=n=>{if(n&&typeof n=="object"&&"value"in n&&Object.keys(n).length<=2)return n.value;if(typeof n=="function")try{return n()}catch{return}return n},Nn=(n,t)=>{if(typeof n=="number"&&Number.isFinite(n))return Math.max(0,Math.floor(n))&16777215;if(typeof n=="string"){const e=n.trim().replace(/^#/,""),i=e.length===3?`${e[0]}${e[0]}${e[1]}${e[1]}${e[2]}${e[2]}`:e,r=parseInt(i,16);if(Number.isFinite(r))return r&16777215}return t},In=(n,t)=>{const e=At(t,0,1),i=Math.round((n>>16&255)*(1-e)),r=Math.round((n>>8&255)*(1-e)),l=Math.round((n&255)*(1-e));return i<<16|r<<8|l},Dn=(n,t)=>{const e=At(t,0,1),i=Math.round((n>>16&255)+(255-(n>>16&255))*e),r=Math.round((n>>8&255)+(255-(n>>8&255))*e),l=Math.round((n&255)+(255-(n&255))*e);return i<<16|r<<8|l},We=(n,t)=>{const e=pt(n),i=Number(e?.x),r=Number(e?.y);return{x:mt(i)?i:t.x,y:mt(r)?r:t.y}},On=(n,t)=>{if(n&&typeof n.toGlobal=="function"){const e=n.toGlobal(t);if(mt(e?.x)&&mt(e?.y))return{x:e.x,y:e.y}}return t},Rn=(n,t)=>{if(n&&typeof n.toLocal=="function"){const e=n.toLocal(t);if(mt(e?.x)&&mt(e?.y))return{x:e.x,y:e.y}}return t},Vi=(n,t)=>{const e=Number(pt(n?.lifetimeMs)),i=Number(pt(n?.startAlpha)),r=Number(pt(n?.endAlpha)),l=Number(pt(n?.scale)),c=Number(pt(n?.blurStart)),a=Number(pt(n?.blurEnd)),g=Number(pt(n?.erosionStart)),S=Number(pt(n?.depth)),w=Number(pt(n?.rimStrength)),C=pt(n?.tint),M=pt(n?.blendMode);return{lifetimeMs:mt(e)?Math.max(120,e):t.lifetimeMs,startAlpha:mt(i)?At(i,0,1.5):t.startAlpha,endAlpha:mt(r)?At(r,0,1.5):t.endAlpha,tint:Nn(C,t.tint),blendMode:M??t.blendMode,scale:mt(l)?Math.max(.05,l):t.scale,blurStart:mt(c)?Math.max(0,c):t.blurStart,blurEnd:mt(a)?Math.max(0,a):t.blurEnd,erosionStart:mt(g)?At(g,.05,.95):t.erosionStart,depth:mt(S)?At(S,0,1):t.depth,rimStrength:mt(w)?At(w,0,1):t.rimStrength}},Pn=n=>{const t=pt(n)??{},e={};for(const[i,r]of Object.entries(Fn))e[i]=Vi(t[i],r);for(const[i,r]of Object.entries(t))e[i]||(e[i]=Vi(r,Ut));return e[ge]||(e[ge]=Ut),e},Un=(n,t)=>{if(n===!1||n===null||n===void 0)return null;const e=n===!0||typeof n!="object"?{}:n;if(pt(e.enabled)===!1)return null;const r=Number(pt(e.minStepDistance)),l=Number(pt(e.minSpeed)),c=Number(pt(e.stepIntervalMs)),a=Number(pt(e.size)),g=Number(pt(e.alpha)),S=Number(pt(e.blur)),w=Number(pt(e.angleOffset)),C=Number(pt(e.jitter)),M=pt(e.surface);return{footAnchor:We(e.footAnchor,Yt.footAnchor),leftOffset:We(e.leftOffset,Yt.leftOffset),rightOffset:We(e.rightOffset,Yt.rightOffset),minStepDistance:mt(r)?Math.max(2,r):Yt.minStepDistance,minSpeed:mt(l)?Math.max(0,l):Yt.minSpeed,stepIntervalMs:mt(c)?Math.max(0,c):Yt.stepIntervalMs,size:mt(a)?Math.max(.1,a):Yt.size,alpha:mt(g)?At(g,0,2):Yt.alpha,blur:mt(S)?Math.max(0,S):Yt.blur,surface:typeof M=="string"&&M.trim().length>0?M.trim():t,angleOffset:mt(w)?w:Yt.angleOffset,jitter:mt(C)?Math.max(0,C):Yt.jitter}},kn=(n,t)=>{if(!n||n[qe])return null;const e=typeof n.getElement=="function"?n.getElement():null,i=pt(n.footprintCaster)??pt(n.fullProps?.footprintCaster)??pt(e?.props?.footprintCaster)??pt(e?.propObservables?.footprintCaster);return i===void 0?null:Un(i,t)},Ln=(n,t)=>{const e=[],i=[n];for(;i.length>0;){const r=i.pop(),l=Array.isArray(r?.children)?r.children:[];for(let c=0;c<l.length;c++){const a=l[c];if(!a||a[qe])continue;const g=kn(a,t);g&&a.parent&&e.push({instance:a,caster:g}),Array.isArray(a.children)&&a.children.length>0&&i.push(a)}}return e},Vn=n=>{const t=n?.app;if(typeof t=="function")try{const i=t();if(i?.renderer&&typeof i.renderer.generateTexture=="function")return i.renderer}catch{}const e=globalThis.__PIXI_RENDERER__;return e&&typeof e.generateTexture=="function"?e:null},Yn=n=>{const t=new L.Graphics;t.ellipse(0,10,8.4,6.1).fill(16777215),t.ellipse(0,-1.4,6.8,9.4).fill(16777215),t.circle(-4.7,-12.8,2).fill(16777215),t.circle(-1.5,-14.6,1.9).fill(16777215),t.circle(1.5,-15.3,1.75).fill(16777215),t.circle(4.5,-14.1,1.45).fill(16777215);const e=n.generateTexture(t);return t.destroy(),e},Yi=(n,t,e)=>{const i=typeof n.getBounds=="function"?n.getBounds():null,r=Math.max(1,Math.abs(Number(n.width))||Math.abs(Number(i?.width))||1),l=Math.max(1,Math.abs(Number(n.height))||Math.abs(Number(i?.height))||1),c=Number(n.anchor?.x),a=Number(n.anchor?.y),g=mt(c)?At(c,0,1):.5,S=mt(a)?At(a,0,1):1,w={x:(e.footAnchor.x-g)*r,y:(e.footAnchor.y-S)*l},C=On(n,w);return Rn(t,C)},zn=(n,t,e)=>{const i=mt(t?.zIndex)?t.zIndex:0;if(n.rimSprite.zIndex=i-.2,n.baseSprite.zIndex=i-.18,n.depthSprite.zIndex=i-.16,e.sortableChildren||!Array.isArray(e.children)||!e.children.includes(t))return;const r=[n.rimSprite,n.baseSprite,n.depthSprite];for(let l=0;l<r.length;l++){const c=r[l];if(!e.children.includes(c))continue;const a=e.getChildIndex(t),g=Math.max(0,a-1);e.getChildIndex(c)!==g&&e.setChildIndex(c,g)}};function Gn(n={}){const t=D.useProps(n);return D.mount(e=>{const i=e.props.context,l=i?.viewport??e.parent?.componentInstance;if(!l||typeof l.addChild!="function")return;const c=i?.tick,a=new Map,g=[],S=[];let w=0,C=0,M=!0,N=null,F=null;const k=()=>{if(F&&!F.destroyed)return F;const I=Vn(i);return I?(F=Yn(I),F):null},R=I=>{const O=[I.baseSprite,I.depthSprite,I.rimSprite];for(let _=0;_<O.length;_++){const U=O[_];U.visible=!1,U.alpha=0,U.parent&&U.parent.removeChild(U)}S.push(I)},m=I=>{const O=[I.baseSprite,I.depthSprite,I.rimSprite];for(let _=0;_<O.length;_++){const U=O[_];U.parent&&U.parent.removeChild(U),U.destroy()}},x=I=>{let O=S.pop();if(O)O.baseSprite.texture=I,O.depthSprite.texture=I,O.rimSprite.texture=I;else{const _=new L.Sprite(I),U=new L.Sprite(I),V=new L.Sprite(I),z=new L.BlurFilter({strength:0,quality:1}),K=new L.BlurFilter({strength:0,quality:1}),et=new L.BlurFilter({strength:0,quality:1}),Q=[_,U,V];for(let W=0;W<Q.length;W++){const Y=Q[W];Y.anchor.set(.5,.84),Y.roundPixels=!0,Y.eventMode="none",Y.visible=!1,Y[qe]=!0}_.filters=[z],U.filters=[K],V.filters=[et],U.blendMode="multiply",V.blendMode="screen",O={baseSprite:_,depthSprite:U,rimSprite:V,baseBlurFilter:z,depthBlurFilter:K,rimBlurFilter:et,bornAt:0,lifetimeMs:Ut.lifetimeMs,startAlpha:Ut.startAlpha,endAlpha:Ut.endAlpha,baseScaleX:1,baseScaleY:1,blurStart:Ut.blurStart,blurEnd:Ut.blurEnd,erosionStart:Ut.erosionStart,depth:Ut.depth,rimStrength:Ut.rimStrength}}return O},y=I=>{for(;g.length>I;){const O=g.shift();if(!O)break;R(O)}},f=I=>{for(let O=g.length-1;O>=0;O--){const _=g[O],U=_.baseSprite,V=_.depthSprite,z=_.rimSprite;if(!U||!V||!z||U.destroyed||V.destroyed||z.destroyed){g.splice(O,1);continue}const K=At((I-_.bornAt)/Math.max(1,_.lifetimeMs),0,1),et=1-ki(0,1,K),Q=K<=_.erosionStart?1:1-ki(_.erosionStart,1,K),W=At(_e(_.startAlpha,_.endAlpha,K)*et*Q,0,1.5);if(K>=1||W<=.001){g.splice(O,1),R(_);continue}const Y=1+K*.08,Z=1+K*.05,yt=1+K*.12,ct=.78-_.depth*.1,H=1.05+_.depth*.12;U.scale.set(_.baseScaleX*Y,_.baseScaleY*Y),V.scale.set(_.baseScaleX*ct*Z,_.baseScaleY*ct*Z),z.scale.set(_.baseScaleX*H*yt,_.baseScaleY*H*yt),U.alpha=W,V.alpha=At(W*(.58+_.depth*.34),0,1.2),z.alpha=At(W*_.rimStrength,0,.65),_.baseBlurFilter.strength=_e(_.blurStart,_.blurEnd,K),_.depthBlurFilter.strength=_e(_.blurStart*(.45+(1-_.depth)*.25),_.blurEnd*(.72+(1-_.depth)*.22),K),_.rimBlurFilter.strength=_e(_.blurStart*.8,_.blurEnd*(1.28+_.depth*.24),K),U.visible=!0,V.visible=!0,z.visible=z.alpha>.001}},A=(I,O,_,U,V,z)=>{const K=k(),et=I.parent;if(!K||!et||et.destroyed)return;const Q=Yi(I,et,O),W=_.nextFoot==="left"?O.leftOffset:O.rightOffset,Y=_.heading,Z=-Math.sin(Y),yt=Math.cos(Y),ct=Math.cos(Y),H=Math.sin(Y),it=Q.x+Z*W.x+ct*W.y,vt=Q.y+yt*W.x+H*W.y,j=x(K),Mt=[j.rimSprite,j.baseSprite,j.depthSprite];for(let tt=0;tt<Mt.length;tt++){const q=Mt[tt];q.parent&&q.parent!==et&&q.parent.removeChild(q),q.parent||et.addChild(q)}const bt=Li(O.jitter),d=(Math.random()*2-1)*bt,u=Li(O.angleOffset),B=Y-Math.PI/2+u+d,E=U.scale*O.size,J=(_.nextFoot==="left"?1:-1)*Math.max(.01,E),ut=Math.max(.01,E),rt=At(U.startAlpha*O.alpha,0,1.5),G=In(U.tint,.38+U.depth*.26),X=Dn(U.tint,.22+U.depth*.38);j.baseSprite.position.set(it,vt),j.depthSprite.position.set(it,vt),j.rimSprite.position.set(it,vt),j.baseSprite.rotation=B,j.depthSprite.rotation=B,j.rimSprite.rotation=B,j.baseSprite.scale.set(J,ut),j.depthSprite.scale.set(J*.82,ut*.82),j.rimSprite.scale.set(J*1.08,ut*1.08),j.baseSprite.tint=U.tint,j.depthSprite.tint=G,j.rimSprite.tint=X,j.baseSprite.blendMode=U.blendMode,j.baseSprite.alpha=rt,j.depthSprite.alpha=At(rt*(.58+U.depth*.34),0,1.2),j.rimSprite.alpha=At(rt*U.rimStrength,0,.65),j.baseSprite.visible=!0,j.depthSprite.visible=!0,j.rimSprite.visible=j.rimSprite.alpha>.001,zn(j,I,et),j.bornAt=V,j.lifetimeMs=U.lifetimeMs,j.startAlpha=rt,j.endAlpha=At(U.endAlpha*O.alpha,0,1.5),j.baseScaleX=J,j.baseScaleY=ut,j.blurStart=Math.max(0,U.blurStart+O.blur),j.blurEnd=Math.max(j.blurStart,U.blurEnd+O.blur),j.depth=U.depth,j.rimStrength=U.rimStrength,j.erosionStart=At(U.erosionStart+(Math.random()*2-1)*.11,.05,.95),j.baseBlurFilter.strength=j.blurStart,j.depthBlurFilter.strength=j.blurStart*(.45+(1-U.depth)*.25),j.rimBlurFilter.strength=j.blurStart*.8,g.push(j),y(z),_.nextFoot=Bn(_.nextFoot),_.lastStepMs=V,_.distanceSinceStep=Math.max(0,_.distanceSinceStep-O.minStepDistance)},P=I=>{const O=pt(t.defaultSurface),_=typeof O=="string"&&O.trim().length>0?O.trim():ge,U=Pn(t.profiles),V=Number(pt(t.maxFootprints)),z=At(mt(V)?V:Cn,10,1200),K=Ln(l,_),et=new Set;for(let Q=0;Q<K.length;Q++){const{instance:W,caster:Y}=K[Q];if(!W||W.destroyed||!W.parent)continue;et.add(W);let Z=a.get(W);Z||(Z={lastPoint:null,lastUpdateMs:I,distanceSinceStep:0,lastStepMs:-1/0,nextFoot:"left",heading:Number(W.rotation)||0},a.set(W,Z));const yt=W.parent,ct=Yi(W,yt,Y);if(!Z.lastPoint){Z.lastPoint=ct,Z.lastUpdateMs=I;continue}const H=Math.max(1,I-Z.lastUpdateMs),it=ct.x-Z.lastPoint.x,vt=ct.y-Z.lastPoint.y,j=Math.hypot(it,vt);j>1e-4&&(Z.heading=Math.atan2(vt,it)),Z.distanceSinceStep+=j;const Mt=j*1e3/H,bt=U[Y.surface]??U[_]??Ut;Mt>=Y.minSpeed&&Z.distanceSinceStep>=Y.minStepDistance&&I-Z.lastStepMs>=Y.stepIntervalMs&&A(W,Y,Z,bt,I,z),Z.lastPoint=ct,Z.lastUpdateMs=I}for(const[Q]of a.entries())(!et.has(Q)||Q?.destroyed)&&a.delete(Q);f(I)};return N=c?.observable?.subscribe(I=>{const O=I?.value??I,_=Number(O?.deltaTime),U=mt(_)?_:16.67;C+=U,w+=U;const V=Number(pt(t.updateHz)),K=1e3/At(mt(V)?V:Mn,1,120);(M||w>=K)&&(w=0,M=!1,P(C))}),P(0),()=>{N?.unsubscribe?.();for(let I=0;I<g.length;I++)m(g[I]);for(let I=0;I<S.length;I++)m(S[I]);g.length=0,S.length=0,a.clear(),F&&!F.destroyed&&F.destroy(!0),F=null}}),D.h(D.Container)}return Ct.Bar=ji,Ct.CLOUD_PRESETS=Fi,Ct.FOG_PRESETS=Ci,Ct.FogOfWar=un,Ct.Footprints=Gn,Ct.Loading=cr,Ct.NightAmbiant=lr,Ct.Particle=Ji,Ct.RAIN_PRESETS=Ti,Ct.SNOW_PRESETS=Mi,Ct.SpriteShadows=Tn,Ct.TiledMap=Qr,Ct.WEATHER_PRESETS=rn,Ct.Weather=nn,Ct.WeatherEffect=Bi,Ct.createFogOfWarController=ln,Ct.createNightFilter=ei,Object.defineProperty(Ct,Symbol.toStringTag,{value:"Module"}),Ct})({},CanvasEngine,PIXI);
|
|
652
673
|
//# sourceMappingURL=index.global.js.map
|