@canvasengine/presets 2.0.0-beta.35 → 2.0.0-beta.36
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/Loading.d.ts +94 -0
- package/dist/Loading.d.ts.map +1 -0
- package/dist/NightAmbiant.d.ts.map +1 -1
- package/dist/Tilemap/TileLayer.d.ts +4 -0
- package/dist/Tilemap/TileLayer.d.ts.map +1 -1
- package/dist/Weathers/fog.d.ts +3 -0
- package/dist/Weathers/fog.d.ts.map +1 -0
- package/dist/Weathers/index.d.ts +1 -52
- package/dist/Weathers/index.d.ts.map +1 -1
- package/dist/Weathers/rain.d.ts +20 -0
- package/dist/Weathers/rain.d.ts.map +1 -0
- package/dist/Weathers/snow.d.ts +12 -0
- package/dist/Weathers/snow.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +408 -103
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2359 -1910
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var CanvasEnginePresets=function(dt,O,U){"use strict";function Qe(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 ot=Qe(U);function Qt(u){var t=u.toString(16);return t.length==1?"0"+t:t}function Je(u,t,e){return"#"+Qt(u)+Qt(t)+Qt(e)}function Ze(u){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:o,border:a,innerMargin:g,borderRadius:v}=O.useProps(u,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return O.h(O.Graphics,{...u,width:t,height:e,draw(E){v()?E.roundRect(0,0,t(),e(),v()):E.rect(0,0,t(),e()),a&&E.stroke(a),E.fill(c())}},O.h(O.Graphics,{width:t,height:e,draw(E){const S=g(),C=v(),B=Math.max(0,Math.min(t()-2*S,i()/s()*(t()-2*S))),F=e()-2*S;v?E.roundRect(S,S,B,F,C):E.rect(S,S,B,F);const D=o();if(D.startsWith("rgba")){const[P,_,b,m]=D.match(/\d+(\.\d+)?/g).map(Number);E.fill({color:Je(P,_,b),alpha:m})}else E.fill(D)}}))}class jt{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Ft{constructor(t){this.data=t}update(t){}dispose(){}}class be extends Ft{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 Jt;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip"})(Jt||(Jt={}));class Zt{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class k{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Ut;(function(u){u.Circle="circle",u.Box="box",u.Ring="ring"})(Ut||(Ut={}));class ti extends Zt{constructor(){super(Ut.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let o=i.rotation;const a=k.float(-s,s),g=k.float(-c,c);o!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+a*Math.cos(o)-g*Math.sin(o),t.component.y=this.__y+this._t*(this.y-this.__y)+a*Math.sin(o)+g*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)+g),e.radial?(o+=Math.atan2(g,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 ei extends Zt{constructor(){super(Ut.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=k.float(-e.angle*.5,e.angle*.5)+i.rotation:s=k.float(0,6.28319)+i.rotation,e.radius>0){let c=k.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 ii extends Zt{constructor(){super(Ut.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=k.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 gt;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip",u[u.Emitter=2]="Emitter",u[u.Trigger=3]="Trigger"})(gt||(gt={}));class ri extends ot.AnimatedSprite{constructor(t,e,i,s){let c=[],o=e.length;for(let a=0;a<o;a++)c.push(ot.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 Te;(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"})(Te||(Te={}));class ut{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=ut.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=ut.easeInBounce(t*2,0,i,s),c*.5+e):(c=ut.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class nt{constructor(){this.__hasCallback=!1,this._list=new jt}add(t,e,i){this._list.add(new Ft(new Ae(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Ft(new Ae(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const 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 Ae{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let ni=class extends Ft{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new nt,bounced:new nt,updated:new nt},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=k.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=k.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-k.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const a=k.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=k.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=ut[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=k.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=k.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=k.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=ut[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=o*(1-e.fadeInDurationFac),this.fadeInDuration=o*e.fadeInDurationFac,this.fadeInEase=ut[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=ut[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=k.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(k.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=k.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(k.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=ut[e.scaleXEase],this.scaleYStart=s.scale.y=k.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(k.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=ut[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=o*(1-e.scaleInDurationFac),this.scaleInDuration=o*e.scaleInDurationFac,this.scaleInEase=ut[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=k.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=k.sign())),e.useTint&&(this.tintEase=ut[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],v=c.getParticleEmitterById(g.id);v.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(v.rotation=s.rotation,v.__adoptRotation=!0),v.__parent=this,this._childEmitters.push(v)}}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 g=o[a];g.__recycled||(g.x=s.position.x,g.y=s.position.y,g.__adoptRotation&&(g.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class yt{static sanitizeBundle(t){for(let e of t.emitters){const i=yt._presetStructure.emitter;yt.parse(e,i,yt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=yt._presetStructure.sequence;yt.parse(e,i,yt._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"))yt.parse(c,o,i);else for(let a of c)for(let g in i)a[g]==null&&(a[g]=i[g])}}}yt._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 ai extends ot.Sprite{constructor(t,e,i,s){super(ot.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Nt(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]=Nt(i)}return t}var oi=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(E){try{v(i.next(E))}catch(S){o(S)}}function g(E){try{v(i.throw(E))}catch(S){o(S)}}function v(E){E.done?c(E.value):s(E.value).then(a,g)}v((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 jt,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,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)=>oi(this,void 0,void 0,function*(){const a={rfx_spritesheet:e,rfx_bundleSettings:t};for(var g in s)a[g]=s[g];ot.Assets.addBundle("rfx_assets",a);const v=yield ot.Assets.loadBundle("rfx_assets");c(this.initBundle(v.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.");yt.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 ve(t),s.__fx=this):s=i.pop(),e&&(c=Nt(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,o=this._settingsCache.emitters[t];if(!o)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new te(t),c.__fx=this):c=s.pop(),i&&(o=Nt(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 te(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new ve(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 s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new ai(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 ri(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 ni;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 ot.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,g]of o)g instanceof ot.Texture&&(i[a]=g)}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 g=o.split("_")[1];s[g]==null&&(s[g]=[]),s[g].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=Jt,ct.EffectSequenceComponentType=gt,ct._blendModes=["normal","add","multiply","screen"],ct.__emitterCores={circle:ei,box:ti,ring:ii};var Pt;(function(u){u[u.ParticleEmitter=0]="ParticleEmitter",u[u.EffectSequence=1]="EffectSequence"})(Pt||(Pt={}));class te extends be{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new jt,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new nt,completed:new nt,exhausted:new nt,particleUpdated:new nt,particleSpawned:new nt,particleBounced:new nt,particleDied:new nt}}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+k.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=k.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=k.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=k.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 Pt.ParticleEmitter:a.settings=Nt(e.__getEmitterSettings(a.id));break;case Pt.EffectSequence:a.settings=Nt(e.__getSequenceSettings(a.id));break}a.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Pt.ParticleEmitter:c.settings=Nt(e.__getEmitterSettings(c.id));break;case Pt.EffectSequence:c.settings=Nt(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class ve extends be{constructor(t){super(t),this._list=[],this._elements=new jt,this.__on={started:new nt,completed:new nt,exhausted:new nt,effectSpawned:new nt,triggerActivated:new nt}}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,g,v;switch(o.componentType){case gt.Sprite:a=c.__getSprite(o.componentId),v=c.__containers[o.containerId]||this.container,v.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(k.float(o.scaleMin,o.scaleMax)*k.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=k.float(o.alphaMin,o.alphaMax),a.anchor.set(o.componentParams.anchorX,o.componentParams.anchorY),g=new Ft({component:a,endTime:e+o.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+k.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(gt.Sprite,a);break;case gt.MovieClip:a=c.__getMovieClip(o.componentId),o.componentParams.loop?(a.animationSpeed=k.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),v=c.__containers[o.containerId]||this.container,v.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(k.float(o.scaleMin,o.scaleMax)*k.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=k.float(o.alphaMin,o.alphaMax),g=new Ft({component:a,endTime:e+o.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+k.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(gt.MovieClip,a);break;case gt.Emitter:a=c.getParticleEmitterById(o.componentId),v=c.__containers[o.containerId]||this.container,a.init(v,!0,k.float(o.scaleMin,o.scaleMax)*k.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),g=new Ft({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(gt.Emitter,a);break;case gt.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 te?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function li(u){const{emit:t,settings:e={}}=u,{name:i}=O.useProps(u),s=new ct;let c;return ot.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),ot.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),O.tick(({deltaRatio:o})=>{s.update(o)}),O.mount(async o=>{c=o;let g={...(await ot.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const E=e.emitters.map((S,C)=>({...S,id:1e4+C}));g.emitters=[...g.emitters,...E]}s.initBundle(g,!0)}),O.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),O.h(O.Container)}function ci(u){const{radius:t}=O.useProps(u),e=O.animatedSignal(1),i=1,s=2,c=.001,o=()=>{const g=Date.now()*c,v=(Math.sin(g)+Math.sin(g*1.3)+Math.sin(g*.7))/3,E=i+(s-i)*(v*.5+.5);e.update(()=>E),requestAnimationFrame(o)};o();const a=g=>{const v=t()*2,E=new O.RadialGradient(v,v,0,v,v,0);E.addColorStop(0,"rgba(255, 255, 0, 1)"),E.addColorStop(.5,"rgba(255, 255, 0, 0.3)"),E.addColorStop(.8,"rgba(255, 255, 0, 0)");const S=v/2;g.rect(-S,-S,v,v).fill(E.render({translate:{x:S,y:S}}))};return O.h(O.Graphics,{draw:a,...u,scale:e})}function hi(u){const{children:t}=u,e=O.signal(0),i=O.signal(0);let s;const c=o=>{o.rect(-80,-80,e()+80*2,i()+80*2),o.fill(0);const g=v=>{const E=O.isSignal(v.propObservables.x)?v.propObservables.x():v.props.x,S=O.isSignal(v.propObservables.y)?v.propObservables.y():v.props.y,C=O.isSignal(v.propObservables.radius)?v.propObservables.radius():v.props.radius;o.circle(E,S,C),o.cut()};for(let v of t){if(O.isObservable(v)){s&&s.unsubscribe(),s=v.subscribe(E=>{for(let S of E.fullElements)g(S)});return}g(v)}};return O.mount(o=>{O.effect(()=>{const{displayWidth:a,displayHeight:g}=o.componentInstance,v=+a(),E=+g();setTimeout(()=>{e.update(()=>v),i.update(()=>E)},0)})}),O.h(O.Container,{width:"100%",height:"100%",...u},O.h(O.Graphics,{draw:c,alpha:.8,blur:80}),...t)}var Ce=(u=>(u.LEFT="left",u.TOP="top",u.BOTTOM="bottom",u.RIGHT="right",u.TOP_LEFT="top_left",u.TOP_RIGHT="top_right",u.BOTTOM_LEFT="bottom_left",u.BOTTOM_RIGHT="bottom_right",u))(Ce||{});function ui(u={}){const t=Object.assign({outerScale:{x:1,y:1},innerScale:{x:1,y:1},innerColor:"black",outerColor:"black"},u);let e=70,i=10;const s=.5;let c=!1,o=null,a=0;const g=O.signal(0),v=O.signal(0),E=O.signal(s);function S(m){const f=m.x-0,T=m.y-0;return Math.min(1,Math.sqrt(f*f+T*T)/e)}function C(m){let f=Math.atan2(m.y,m.x);return f>=-Math.PI/8&&f<0||f>=0&&f<Math.PI/8?"right":f>=Math.PI/8&&f<3*Math.PI/8?"bottom_right":f>=3*Math.PI/8&&f<5*Math.PI/8?"bottom":f>=5*Math.PI/8&&f<7*Math.PI/8?"bottom_left":f>=7*Math.PI/8&&f<Math.PI||f>=-Math.PI&&f<-7*Math.PI/8?"left":f>=-7*Math.PI/8&&f<-5*Math.PI/8?"top_left":f>=-5*Math.PI/8&&f<-3*Math.PI/8?"top":"top_right"}function B(m){var f;o=m.getLocalPosition(this),c=!0,E.set(1),(f=t.onStart)==null||f.call(t)}function F(){var m;c&&(g.set(0),v.set(0),c=!1,E.set(s),(m=t.onEnd)==null||m.call(t))}function D(m){var ft,at,mt;if(c==!1)return;let f=m.getLocalPosition(this),T=f.x-((o==null?void 0:o.x)??0),N=f.y-((o==null?void 0:o.y)??0),R=new ot.Point(0,0),L=0;if(T==0&&N==0)return;let y="left";if(T==0){N>0?(R.set(0,N>e?e:N),L=270,y="bottom"):(R.set(0,-(Math.abs(N)>e?e:Math.abs(N))),L=90,y="top"),g.set(R.x),v.set(R.y),a=S(R),(ft=t.onChange)==null||ft.call(t,{angle:L,direction:y,power:a});return}if(N==0){T>0?(R.set(Math.abs(T)>e?e:Math.abs(T),0),L=0,y="left"):(R.set(-(Math.abs(T)>e?e:Math.abs(T)),0),L=180,y="right"),g.set(R.x),v.set(R.y),a=S(R),(at=t.onChange)==null||at.call(t,{angle:L,direction:y,power:a});return}let G=Math.abs(N/T),rt=Math.atan(G);L=rt*180/Math.PI;let K=0,it=0;T*T+N*N>=e*e?(K=e*Math.cos(rt),it=e*Math.sin(rt)):(K=Math.abs(T)>e?e:Math.abs(T),it=Math.abs(N)>e?e:Math.abs(N)),N<0&&(it=-Math.abs(it)),T<0&&(K=-Math.abs(K)),T>0&&N<0||(T<0&&N<0?L=180-L:T<0&&N>0?L=L+180:T>0&&N>0&&(L=360-L)),R.set(K,it),a=S(R),y=C(R),g.set(R.x),v.set(R.y),(mt=t.onChange)==null||mt.call(t,{angle:L,direction:y,power:a})}let P,_;t.outer?_=O.h(O.Sprite,{image:t.outer,anchor:{x:.5,y:.5},scale:t.outerScale}):_=O.h(O.Graphics,{draw:m=>{m.circle(0,0,e).fill(t.outerColor)},alpha:.5});const b={scale:t.innerScale,x:g,y:v,alpha:E};return t.inner?P=t.inner:P=O.h(O.Graphics,{draw:m=>{m.circle(0,0,i*2.5).fill(t.innerColor)},...b}),O.h(O.Container,{...u,pointerdown:B,pointerup:F,pointerupoutside:F,pointermove:D},_,P)}var Rt=(u=>(u.Tile="tilelayer",u.ObjectGroup="objectgroup",u.Image="imagelayer",u.Group="group",u))(Rt||{});function Se(...u){return u.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function fi(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 ee={};const di=fi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ie={},Xt={exports:{}},re={},Lt={},Ie;function pi(){if(Ie)return Lt;Ie=1,Lt.byteLength=a,Lt.toByteArray=v,Lt.fromByteArray=C;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(B){var F=B.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var D=B.indexOf("=");D===-1&&(D=F);var P=D===F?0:4-D%4;return[D,P]}function a(B){var F=o(B),D=F[0],P=F[1];return(D+P)*3/4-P}function g(B,F,D){return(F+D)*3/4-D}function v(B){var F,D=o(B),P=D[0],_=D[1],b=new e(g(B,P,_)),m=0,f=_>0?P-4:P,T;for(T=0;T<f;T+=4)F=t[B.charCodeAt(T)]<<18|t[B.charCodeAt(T+1)]<<12|t[B.charCodeAt(T+2)]<<6|t[B.charCodeAt(T+3)],b[m++]=F>>16&255,b[m++]=F>>8&255,b[m++]=F&255;return _===2&&(F=t[B.charCodeAt(T)]<<2|t[B.charCodeAt(T+1)]>>4,b[m++]=F&255),_===1&&(F=t[B.charCodeAt(T)]<<10|t[B.charCodeAt(T+1)]<<4|t[B.charCodeAt(T+2)]>>2,b[m++]=F>>8&255,b[m++]=F&255),b}function E(B){return u[B>>18&63]+u[B>>12&63]+u[B>>6&63]+u[B&63]}function S(B,F,D){for(var P,_=[],b=F;b<D;b+=3)P=(B[b]<<16&16711680)+(B[b+1]<<8&65280)+(B[b+2]&255),_.push(E(P));return _.join("")}function C(B){for(var F,D=B.length,P=D%3,_=[],b=16383,m=0,f=D-P;m<f;m+=b)_.push(S(B,m,m+b>f?f:m+b));return P===1?(F=B[D-1],_.push(u[F>>2]+u[F<<4&63]+"==")):P===2&&(F=(B[D-2]<<8)+B[D-1],_.push(u[F>>10]+u[F>>4&63]+u[F<<2&63]+"=")),_.join("")}return Lt}var $t={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Me;function mi(){return Me||(Me=1,$t.read=function(u,t,e,i,s){var c,o,a=s*8-i-1,g=(1<<a)-1,v=g>>1,E=-7,S=e?s-1:0,C=e?-1:1,B=u[t+S];for(S+=C,c=B&(1<<-E)-1,B>>=-E,E+=a;E>0;c=c*256+u[t+S],S+=C,E-=8);for(o=c&(1<<-E)-1,c>>=-E,E+=i;E>0;o=o*256+u[t+S],S+=C,E-=8);if(c===0)c=1-v;else{if(c===g)return o?NaN:(B?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-v}return(B?-1:1)*o*Math.pow(2,c-i)},$t.write=function(u,t,e,i,s,c){var o,a,g,v=c*8-s-1,E=(1<<v)-1,S=E>>1,C=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=i?0:c-1,F=i?1:-1,D=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=E):(o=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-o))<1&&(o--,g*=2),o+S>=1?t+=C/g:t+=C*Math.pow(2,1-S),t*g>=2&&(o++,g/=2),o+S>=E?(a=0,o=E):o+S>=1?(a=(t*g-1)*Math.pow(2,s),o=o+S):(a=t*Math.pow(2,S-1)*Math.pow(2,s),o=0));s>=8;u[e+B]=a&255,B+=F,a/=256,s-=8);for(o=o<<s|a,v+=s;v>0;u[e+B]=o&255,B+=F,o/=256,v-=8);u[e+B-F]|=D*128}),$t}/*!
|
|
1
|
+
var CanvasEnginePresets=function(_t,D,k){"use strict";function Qe(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const e in h)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>h[e]})}}return t.default=h,Object.freeze(t)}const ft=Qe(k);function Qt(h){var t=h.toString(16);return t.length==1?"0"+t:t}function Je(h,t,e){return"#"+Qt(h)+Qt(t)+Qt(e)}function Ze(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:a,border:o,innerMargin:g,borderRadius:S}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(x){S()?x.roundRect(0,0,t(),e(),S()):x.rect(0,0,t(),e()),o&&x.stroke(o),x.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(x){const C=g(),A=S(),B=Math.max(0,Math.min(t()-2*C,i()/s()*(t()-2*C))),F=e()-2*C;S?x.roundRect(C,C,B,F,A):x.rect(C,C,B,F);const N=a();if(N.startsWith("rgba")){const[P,_,v,m]=N.match(/\d+(\.\d+)?/g).map(Number);x.fill({color:Je(P,_,v),alpha:m})}else x.fill(N)}}))}class zt{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Dt{constructor(t){this.data=t}update(t){}dispose(){}}class ve extends Dt{constructor(t){super(),this.componentId=t,this.exhausted=!1,this.completed=!1,this.name="",this.endTime=0,this._x=0,this._y=0,this._rotation=0,this._alpha=0,this._scale=new ft.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var Jt;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(Jt||(Jt={}));class Zt{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class q{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Ut;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Ut||(Ut={}));class ti extends Zt{constructor(){super(Ut.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let a=i.rotation;const o=q.float(-s,s),g=q.float(-c,c);a!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(a)-g*Math.sin(a),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(a)+g*Math.cos(a)):(t.component.x=this.__x+this._t*(this.x-this.__x)+o,t.component.y=this.__y+this._t*(this.y-this.__y)+g),e.radial?(a+=Math.atan2(g,o),t.dx=Math.cos(a),t.dy=Math.sin(a)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=a,this._t+=this._posInterpolationStep}}class ei extends Zt{constructor(){super(Ut.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=q.float(-e.angle*.5,e.angle*.5)+i.rotation:s=q.float(0,6.28319)+i.rotation,e.radius>0){let c=q.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 ii extends Zt{constructor(){super(Ut.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=q.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var Et;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(Et||(Et={}));class ri extends ft.AnimatedSprite{constructor(t,e,i,s){let c=[],a=e.length;for(let o=0;o<a;o++)c.push(ft.Texture.from(e[o]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class 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 be;(function(h){h.Linear="linear",h.EaseInQuad="easeInQuad",h.EaseOutQuad="easeOutQuad",h.EaseInOutQuad="easeInOutQuad",h.EaseInCubic="easeInCubic",h.EaseOutCubic="easeOutCubic",h.EaseInOutCubic="easeInOutCubic",h.EaseInQuart="easeInQuart",h.EaseOutQuart="easeOutQuart",h.EaseInOutQuart="easeInOutQuart",h.EaseInQuint="easeInQuint",h.EaseOutQuint="easeOutQuint",h.EaseInOutQuint="easeInOutQuint",h.EaseInSine="easeInSine",h.EaseOutSine="easeOutSine",h.EaseInOutSine="easeInOutSine",h.EaseInExpo="easeInExpo",h.EaseOutExpo="easeOutExpo",h.EaseInOutExpo="easeInOutExpo",h.EaseInCirc="easeInCirc",h.EaseOutCirc="easeOutCirc",h.EaseInOutCirc="easeInOutCirc",h.EaseInElastic="easeInElastic",h.EaseOutElastic="easeOutElastic",h.EaseInOutElastic="easeInOutElastic",h.EaseInBack="easeInBack",h.EaseOutBack="easeOutBack",h.EaseInOutBack="easeInOutBack",h.EaseInBounce="easeInBounce",h.EaseOutBounce="easeOutBounce",h.EaseInOutBounce="easeInOutBounce"})(be||(be={}));class yt{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e}static easeOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/a)+i+e}static easeInOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s/2),a||(a=s*.44999999999999996),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=yt.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=yt.easeInBounce(t*2,0,i,s),c*.5+e):(c=yt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class ht{constructor(){this.__hasCallback=!1,this._list=new zt}add(t,e,i){this._list.add(new Dt(new Te(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Dt(new Te(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const a=i.data;a.callRate&&a.calls%a.callRate!=0&&(c=!1),c&&(a.callback.apply(a.scope,t),a.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Te{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let ni=class extends Dt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new ht,bounced:new ht,updated:new ht},this._color=new si}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const a=this.duration=q.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=q.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-q.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=q.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=o*this.dx*i,this.moveSpeedY=o*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const o=this.distance=q.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+o*this.dx-this.startX)*.8,this.deltaY=(s.y+o*this.dy-this.startY)*.8,this.distanceEase=yt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=q.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=q.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=q.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=yt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=a*(1-e.fadeInDurationFac),this.fadeInDuration=a*e.fadeInDurationFac,this.fadeInEase=yt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=yt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=q.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(q.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=q.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(q.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=yt[e.scaleXEase],this.scaleYStart=s.scale.y=q.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(q.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=yt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=a*(1-e.scaleInDurationFac),this.scaleInDuration=a*e.scaleInDurationFac,this.scaleInEase=yt[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=q.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=q.sign())),e.useTint&&(this.tintEase=yt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let o=e.childs.length;if(this._hasChildEmitters=o>0,this._childEmitters)for(;--o>-1;){const g=e.childs[o],S=c.getParticleEmitterById(g.id);S.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(S.rotation=s.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 s=this.component,c=e*t;if(this.useGravity){const a=t/.0166666;if(s.x+=this.moveSpeedX*a,s.y+=this.moveSpeedY*a,this.moveSpeedY+=this.gravity*a,this.useAlign&&(s.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&s.y>this.floorY){s.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const o=this.emitter;o.__on.particleBounced.__hasCallback&&o.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&o.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(s.x=this.distanceEase(e,this.startX,this.deltaX,i),s.y=this.distanceEase(e,this.startY,this.deltaY,i)):(s.x=this.deltaX*c+this.startX,s.y=this.deltaY*c+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?s.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):s.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?s.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):s.alpha=this.alphaDelta*c+this.alphaStart),this.useRotation&&(s.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?s.scale.x=s.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):s.scale.x=s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(s.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),s.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):s.scale.x=s.scale.y=this.scaleDelta*c+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(s.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),s.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(s.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?s.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):s.scale.x=this.scaleXDelta*c+this.scaleXStart,this.scaleYEase?s.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):s.scale.y=this.scaleYDelta*c+this.scaleYStart)),this.useTint&&(s.tint=this._color.tween(this.tintEase,e,i)),this._spawnOnHalfway&&e>=.5&&(this._spawnOnHalfway=!1,this.emitter.__subSpawn(this,this.settings.spawn.onHalfway)),this.useChilds&&this._hasChildEmitters){const a=this._childEmitters;let o=a.length;for(;--o>-1;){const g=a[o];g.__recycled||(g.x=s.position.x,g.y=s.position.y,g.__adoptRotation&&(g.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class wt{static sanitizeBundle(t){for(let e of t.emitters){const i=wt._presetStructure.emitter;wt.parse(e,i,wt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=wt._presetStructure.sequence;wt.parse(e,i,wt._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let s in e)if(t[s]==null)t[s]=e[s];else{const c=t[s];if(typeof c!="object")continue;const a=e[s];if(!c.hasOwnProperty("length"))wt.parse(c,a,i);else for(let o of c)for(let g in i)o[g]==null&&(o[g]=i[g])}}}wt._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class ai extends ft.Sprite{constructor(t,e,i,s){super(ft.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 Ot(h){if(typeof h!="object"||h===null)return h;const t=Array.isArray(h)?[]:{};for(const e in h){const i=h[e];t[e]=Ot(i)}return t}var oi=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(a){a(c)})}return new(e||(e=Promise))(function(c,a){function o(x){try{S(i.next(x))}catch(C){a(C)}}function g(x){try{S(i.throw(x))}catch(C){a(C)}}function S(x){x.done?c(x.value):s(x.value).then(o,g)}S((i=i.apply(h,t||[])).next())})};class pt{constructor(){this.useBlendModes=!0,this.particleCount=0,this.emitterCount=0,this.effectSequenceCount=0,this.maxParticles=5e3,this.particleFac=1,this._active=!1,this._effects=new zt,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,a;for(;c;)a=c.next,c.update(i),c=a;this._timeElapsed=e}clearCache(){this._cache={particles:[],mcs:[],sprites:[],effectSequences:[],emitters:[],cores:{}},this._settingsCache={mcs:{},sprites:{},emitters:{},effectSequences:{}},this._nameMaps={emitters:{},effectSequences:{}}}setFloorY(t){const e=this._settingsCache.emitters;for(let i in e)e[i].floorY=t}dispose(){let t=this._effects,e=t.first;for(;e;)e.dispose(),e=e.next;t.clear(),this.clearCache()}loadBundleFiles(t,e,i="",s=[]){return new Promise((c,a)=>oi(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var g in s)o[g]=s[g];ft.Assets.addBundle("rfx_assets",o);const S=yield ft.Assets.loadBundle("rfx_assets");c(this.initBundle(S.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==pt._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=pt.settingsVersion)throw new Error("Settings version mismatch.");wt.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const s=t.emitters[i];this.addParticleEmitter(s.id,s)}for(let i in t.sequences){const s=t.sequences[i];this.addEffectSequence(s.id,s)}return this.useBlendModes=t.useBlendModes,this.maxParticles=t.maxParticles,this.parseTextureCache(t.spritesheetFilter)}addParticleEmitter(t,e){if(this._settingsCache.emitters[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.emitters[t]=e,this._nameMaps.emitters[e.name]=e,this}addEffectSequence(t,e){if(this._settingsCache.effectSequences[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.effectSequences[t]=e,this._nameMaps.effectSequences[e.name]=e,this}initSprite(t,e){if(this._settingsCache.sprites[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.sprites[t]=e,this}initMovieClip(t,e){if(this._settingsCache.mcs[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.mcs[t]=e,this}getMovieClips(){return this._settingsCache.mcs}getSprites(){return this._settingsCache.sprites}addContainer(t,e){this.__containers[t]=e}getEffectSequence(t,e=!1){const i=this._nameMaps.effectSequences[t];if(!i)throw new Error(`Settings not defined for '${t}'`);return this.getEffectSequenceById(i.id,e)}getEffectSequenceById(t,e=!1){const i=this._cache.effectSequences;let s,c=this._settingsCache.effectSequences[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(s=new Ae(t),s.__fx=this):s=i.pop(),e&&(c=Ot(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,a=this._settingsCache.emitters[t];if(!a)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new te(t),c.__fx=this):c=s.pop(),i&&(a=Ot(a),a.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(a),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new te(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Ae(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(ft.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 ai(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 ri(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 ni;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new pt.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return ft.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?pt._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const a=t;a.values();for(const[o,g]of a)g instanceof ft.Texture&&(i[o]=g)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let a in i)if(!(e&&a.indexOf(e)==-1)&&(this.initSprite(a,{texture:a,anchorX:.5,anchorY:.5}),c.sprites.push(a),a.substr(0,3)=="mc_")){const g=a.split("_")[1];s[g]==null&&(s[g]=[]),s[g].push(a)}for(let a in s){let o=s[a];c.movieClips.push(a),this.initMovieClip(a,{textures:o,anchorX:.5,anchorY:.5})}return c}}pt.settingsVersion=0,pt.version="1.3.4",pt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",pt.ComponentType=Jt,pt.EffectSequenceComponentType=Et,pt._blendModes=["normal","add","multiply","screen"],pt.__emitterCores={circle:ei,box:ti,ring:ii};var Pt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Pt||(Pt={}));class te extends ve{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new zt,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new ht,completed:new ht,exhausted:new ht,particleUpdated:new ht,particleSpawned:new ht,particleBounced:new ht,particleDied:new ht}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container;a.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(a.rotation=this._rotation,a.__adoptRotation=!0),a.__parent=this,this._childEmitters.push(a)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+q.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,a;for(;c;)a=c.next,c.update(t),c=a;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=q.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let a;switch(s.componentType){case 0:c.componentId=s.componentId,a=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,a=e.__getMovieClip(c.componentId),s.componentParams&&(a.loop=!(s.componentParams.loop==null||!s.componentParams.loop),a.animationSpeed=q.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),a.gotoAndPlay(0);break}a.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=a,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=q.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let a,o;switch(c.type){case 0:a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(a.rotation=t.component.rotation+a.settings.rotation,a.__adoptRotation=!0):a.rotation=a.settings.rotation;break;case 1:a=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(a.rotation=t.component.rotation);break}a.x=t.component.x,a.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const a=i[c];for(const o of a){switch(o.type){case Pt.ParticleEmitter:o.settings=Ot(e.__getEmitterSettings(o.id));break;case Pt.EffectSequence:o.settings=Ot(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Pt.ParticleEmitter:c.settings=Ot(e.__getEmitterSettings(c.id));break;case Pt.EffectSequence:c.settings=Ot(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class Ae extends ve{constructor(t){super(t),this._list=[],this._elements=new zt,this.__on={started:new ht,completed:new ht,exhausted:new ht,effectSpawned:new ht,triggerActivated:new ht}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,a=this._nextEffectSettings;let o,g,S;switch(a.componentType){case Et.Sprite:o=c.__getSprite(a.componentId),S=c.__containers[a.containerId]||this.container,S.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(q.float(a.scaleMin,a.scaleMax)*q.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=q.float(a.alphaMin,a.alphaMax),o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),g=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+q.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Sprite,o);break;case Et.MovieClip:o=c.__getMovieClip(a.componentId),a.componentParams.loop?(o.animationSpeed=q.float(a.componentParams.animationSpeedMin||1,a.componentParams.animationSpeedMax||1),o.loop=a.componentParams.loop||!1):a.duration,o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),o.gotoAndPlay(0),S=c.__containers[a.containerId]||this.container,S.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(q.float(a.scaleMin,a.scaleMax)*q.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=q.float(a.alphaMin,a.alphaMax),g=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+q.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.MovieClip,o);break;case Et.Emitter:o=c.getParticleEmitterById(a.componentId),S=c.__containers[a.containerId]||this.container,o.init(S,!0,q.float(a.scaleMin,a.scaleMax)*q.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),g=new Dt({component:o,endTime:o.endTime}),this._elements.add(g),o.x=this._x,o.y=this._y,o.rotation=this._rotation+o.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Emitter,o);break;case Et.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(a.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof te?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function li(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new pt;let c;return ft.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),ft.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:a})=>{s.update(a)}),D.mount(async a=>{c=a;let g={...(await ft.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const x=e.emitters.map((C,A)=>({...C,id:1e4+A}));g.emitters=[...g.emitters,...x]}s.initBundle(g,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}function ci(h){const{radius:t}=D.useProps(h),e=D.animatedSignal(1),i=1,s=2,c=.001,a=()=>{const g=Date.now()*c,S=(Math.sin(g)+Math.sin(g*1.3)+Math.sin(g*.7))/3,x=i+(s-i)*(S*.5+.5);e.update(()=>x),requestAnimationFrame(a)};a();const o=g=>{const S=t()*2,x=new D.RadialGradient(S,S,0,S,S,0);x.addColorStop(0,"rgba(255, 255, 0, 1)"),x.addColorStop(.5,"rgba(255, 255, 0, 0.3)"),x.addColorStop(.8,"rgba(255, 255, 0, 0)");const C=S/2;g.rect(-C,-C,S,S).fill(x.render({translate:{x:C,y:C}}))};return D.h(D.Graphics,{draw:o,...h,scale:e})}function ui(h){const{children:t}=h,e=D.signal(0),i=D.signal(0);let s;const c=a=>{a.rect(-80,-80,e()+80*2,i()+80*2),a.fill(0);const g=S=>{const x=D.isSignal(S.propObservables.x)?S.propObservables.x():S.props.x,C=D.isSignal(S.propObservables.y)?S.propObservables.y():S.props.y,A=D.isSignal(S.propObservables.radius)?S.propObservables.radius():S.props.radius;a.circle(x,C,A),a.cut()};for(let S of t){if(D.isObservable(S)){s&&s.unsubscribe(),s=S.subscribe(x=>{for(let C of x.fullElements)g(C)});return}g(S)}};return D.mount(a=>{a.componentInstance.on("layout",o=>{e.update(()=>a.componentInstance.getWidth()),i.update(()=>a.componentInstance.getHeight())})}),D.h(D.Container,{width:"100%",height:"100%",...h},D.h(D.Graphics,{draw:c,alpha:.8,blur:80}),...t)}var Se=(h=>(h.LEFT="left",h.TOP="top",h.BOTTOM="bottom",h.RIGHT="right",h.TOP_LEFT="top_left",h.TOP_RIGHT="top_right",h.BOTTOM_LEFT="bottom_left",h.BOTTOM_RIGHT="bottom_right",h))(Se||{});function hi(h={}){const t=Object.assign({outerScale:{x:1,y:1},innerScale:{x:1,y:1},innerColor:"black",outerColor:"black"},h);let e=70,i=10;const s=.5;let c=!1,a=null,o=0;const g=D.signal(0),S=D.signal(0),x=D.signal(s);function C(m){const f=m.x-0,b=m.y-0;return Math.min(1,Math.sqrt(f*f+b*b)/e)}function A(m){let f=Math.atan2(m.y,m.x);return f>=-Math.PI/8&&f<0||f>=0&&f<Math.PI/8?"right":f>=Math.PI/8&&f<3*Math.PI/8?"bottom_right":f>=3*Math.PI/8&&f<5*Math.PI/8?"bottom":f>=5*Math.PI/8&&f<7*Math.PI/8?"bottom_left":f>=7*Math.PI/8&&f<Math.PI||f>=-Math.PI&&f<-7*Math.PI/8?"left":f>=-7*Math.PI/8&&f<-5*Math.PI/8?"top_left":f>=-5*Math.PI/8&&f<-3*Math.PI/8?"top":"top_right"}function B(m){var f;a=m.getLocalPosition(this),c=!0,x.set(1),(f=t.onStart)==null||f.call(t)}function F(){var m;c&&(g.set(0),S.set(0),c=!1,x.set(s),(m=t.onEnd)==null||m.call(t))}function N(m){var lt,it,ct;if(c==!1)return;let f=m.getLocalPosition(this),b=f.x-((a==null?void 0:a.x)??0),O=f.y-((a==null?void 0:a.y)??0),R=new ft.Point(0,0),U=0;if(b==0&&O==0)return;let y="left";if(b==0){O>0?(R.set(0,O>e?e:O),U=270,y="bottom"):(R.set(0,-(Math.abs(O)>e?e:Math.abs(O))),U=90,y="top"),g.set(R.x),S.set(R.y),o=C(R),(lt=t.onChange)==null||lt.call(t,{angle:U,direction:y,power:o});return}if(O==0){b>0?(R.set(Math.abs(b)>e?e:Math.abs(b),0),U=0,y="left"):(R.set(-(Math.abs(b)>e?e:Math.abs(b)),0),U=180,y="right"),g.set(R.x),S.set(R.y),o=C(R),(it=t.onChange)==null||it.call(t,{angle:U,direction:y,power:o});return}let V=Math.abs(O/b),Q=Math.atan(V);U=Q*180/Math.PI;let G=0,z=0;b*b+O*O>=e*e?(G=e*Math.cos(Q),z=e*Math.sin(Q)):(G=Math.abs(b)>e?e:Math.abs(b),z=Math.abs(O)>e?e:Math.abs(O)),O<0&&(z=-Math.abs(z)),b<0&&(G=-Math.abs(G)),b>0&&O<0||(b<0&&O<0?U=180-U:b<0&&O>0?U=U+180:b>0&&O>0&&(U=360-U)),R.set(G,z),o=C(R),y=A(R),g.set(R.x),S.set(R.y),(ct=t.onChange)==null||ct.call(t,{angle:U,direction:y,power:o})}let P,_;t.outer?_=D.h(D.Sprite,{image:t.outer,anchor:{x:.5,y:.5},scale:t.outerScale}):_=D.h(D.Graphics,{draw:m=>{m.circle(0,0,e).fill(t.outerColor)},alpha:.5});const v={scale:t.innerScale,x:g,y:S,alpha:x};return t.inner?P=t.inner:P=D.h(D.Graphics,{draw:m=>{m.circle(0,0,i*2.5).fill(t.innerColor)},...v}),D.h(D.Container,{...h,pointerdown:B,pointerup:F,pointerupoutside:F,pointermove:N},_,P)}function fi(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:a=3,inactiveAlpha:o=.15}=D.useProps(h,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),g=D.signal(0);D.tick(({deltaTime:F})=>{const P=(typeof s=="function"?s():s)*F/1e3;g.set(g()+P)});const S=F=>{const N=typeof t=="function"?t():t,P=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,v=typeof c=="function"?c():c;typeof a=="function"&&a();const m=typeof o=="function"?o():o,f=g();_&&F.circle(0,0,N).fill(_);const b=360/v,O=N*.4,R=N;for(let U=0;U<v;U++){const y=U*b,V=(f%360+360)%360;let Q=Math.abs(V-y);Q>180&&(Q=360-Q);let z=Q/120;z=Math.min(1,z),z=z*z*z;const lt=m+(1-z)*(1-m),it=y*(Math.PI/180),ct=b*(Math.PI/180),L=it-ct/2,nt=it+ct/2;F.arc(0,0,O,L,nt).arc(0,0,R,nt,L,!0).fill({color:P,alpha:lt})}},C=(typeof t=="function"?t():t)*2,A=D.signal(C),B=D.signal(C);return typeof t=="function"&&D.effect(()=>{const F=t();A.set(F*2),B.set(F*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:S})])}var Rt=(h=>(h.Tile="tilelayer",h.ObjectGroup="objectgroup",h.Image="imagelayer",h.Group="group",h))(Rt||{});function Ce(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function di(h){if(Object.prototype.hasOwnProperty.call(h,"__esModule"))return h;var t=h.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(h).forEach(function(i){var s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return h[i]}})}),e}var ee={};const pi=di(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ie={},jt={exports:{}},re={},kt={},Me;function mi(){if(Me)return kt;Me=1,kt.byteLength=o,kt.toByteArray=S,kt.fromByteArray=A;for(var h=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)h[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function a(B){var F=B.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=B.indexOf("=");N===-1&&(N=F);var P=N===F?0:4-N%4;return[N,P]}function o(B){var F=a(B),N=F[0],P=F[1];return(N+P)*3/4-P}function g(B,F,N){return(F+N)*3/4-N}function S(B){var F,N=a(B),P=N[0],_=N[1],v=new e(g(B,P,_)),m=0,f=_>0?P-4:P,b;for(b=0;b<f;b+=4)F=t[B.charCodeAt(b)]<<18|t[B.charCodeAt(b+1)]<<12|t[B.charCodeAt(b+2)]<<6|t[B.charCodeAt(b+3)],v[m++]=F>>16&255,v[m++]=F>>8&255,v[m++]=F&255;return _===2&&(F=t[B.charCodeAt(b)]<<2|t[B.charCodeAt(b+1)]>>4,v[m++]=F&255),_===1&&(F=t[B.charCodeAt(b)]<<10|t[B.charCodeAt(b+1)]<<4|t[B.charCodeAt(b+2)]>>2,v[m++]=F>>8&255,v[m++]=F&255),v}function x(B){return h[B>>18&63]+h[B>>12&63]+h[B>>6&63]+h[B&63]}function C(B,F,N){for(var P,_=[],v=F;v<N;v+=3)P=(B[v]<<16&16711680)+(B[v+1]<<8&65280)+(B[v+2]&255),_.push(x(P));return _.join("")}function A(B){for(var F,N=B.length,P=N%3,_=[],v=16383,m=0,f=N-P;m<f;m+=v)_.push(C(B,m,m+v>f?f:m+v));return P===1?(F=B[N-1],_.push(h[F>>2]+h[F<<4&63]+"==")):P===2&&(F=(B[N-2]<<8)+B[N-1],_.push(h[F>>10]+h[F>>4&63]+h[F<<2&63]+"=")),_.join("")}return kt}var Wt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ie;function _i(){return Ie||(Ie=1,Wt.read=function(h,t,e,i,s){var c,a,o=s*8-i-1,g=(1<<o)-1,S=g>>1,x=-7,C=e?s-1:0,A=e?-1:1,B=h[t+C];for(C+=A,c=B&(1<<-x)-1,B>>=-x,x+=o;x>0;c=c*256+h[t+C],C+=A,x-=8);for(a=c&(1<<-x)-1,c>>=-x,x+=i;x>0;a=a*256+h[t+C],C+=A,x-=8);if(c===0)c=1-S;else{if(c===g)return a?NaN:(B?-1:1)*(1/0);a=a+Math.pow(2,i),c=c-S}return(B?-1:1)*a*Math.pow(2,c-i)},Wt.write=function(h,t,e,i,s,c){var a,o,g,S=c*8-s-1,x=(1<<S)-1,C=x>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=i?0:c-1,F=i?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=x):(a=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-a))<1&&(a--,g*=2),a+C>=1?t+=A/g:t+=A*Math.pow(2,1-C),t*g>=2&&(a++,g/=2),a+C>=x?(o=0,a=x):a+C>=1?(o=(t*g-1)*Math.pow(2,s),a=a+C):(o=t*Math.pow(2,C-1)*Math.pow(2,s),a=0));s>=8;h[e+B]=o&255,B+=F,o/=256,s-=8);for(a=a<<s|o,S+=s;S>0;h[e+B]=a&255,B+=F,a/=256,S-=8);h[e+B-F]|=N*128}),Wt}/*!
|
|
2
2
|
* The buffer module from node.js, for the browser.
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/var Be;function Fe(){return Be||(Be=1,function(u){const t=pi(),e=mi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;u.Buffer=a,u.SlowBuffer=b,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 S(h)}return g(h,r,n)}a.poolSize=8192;function g(h,r,n){if(typeof h=="string")return C(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 D(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 x=P(h);if(x)return x;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 g(h,r,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function v(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 E(h,r,n){return v(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 E(h,r,n)};function S(h){return v(h),o(h<0?0:_(h)|0)}a.allocUnsafe=function(h){return S(h)},a.allocUnsafeSlow=function(h){return S(h)};function C(h,r){if((typeof r!="string"||r==="")&&(r="utf8"),!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=m(h,r)|0;let p=o(n);const x=p.write(h,r);return x!==n&&(p=p.slice(0,x)),p}function B(h){const r=h.length<0?0:_(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 D(r.buffer,r.byteOffset,r.byteLength)}return B(h)}function D(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 P(h){if(a.isBuffer(h)){const r=_(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"||we(h.length)?o(0):B(h);if(h.type==="Buffer"&&Array.isArray(h.data))return B(h.data)}function _(h){if(h>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return h|0}function b(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,x=n.length;for(let A=0,I=Math.min(p,x);A<I;++A)if(r[A]!==n[A]){p=r[A],x=n[A];break}return p<x?-1:x<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 x=a.allocUnsafe(n);let A=0;for(p=0;p<r.length;++p){let I=r[p];if(ht(I,Uint8Array))A+I.length>x.length?(a.isBuffer(I)||(I=a.from(I)),I.copy(x,A)):Uint8Array.prototype.set.call(x,I,A);else if(a.isBuffer(I))I.copy(x,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=I.length}return x};function m(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 x=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Z(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qt(h).length;default:if(x)return p?-1:Z(h).length;r=(""+r).toLowerCase(),x=!0}}a.byteLength=m;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 bt(this,r,n);case"utf8":case"utf-8":return ft(this,r,n);case"ascii":return q(this,r,n);case"latin1":case"binary":return Dt(this,r,n);case"base64":return it(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),p=!0}}a.prototype._isBuffer=!0;function T(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)T(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)T(this,n,n+3),T(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)T(this,n,n+7),T(this,n+1,n+6),T(this,n+2,n+5),T(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,x,A){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),x===void 0&&(x=0),A===void 0&&(A=this.length),n<0||p>r.length||x<0||A>this.length)throw new RangeError("out of range index");if(x>=A&&n>=p)return 0;if(x>=A)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,x>>>=0,A>>>=0,this===r)return 0;let I=A-x,Y=p-n;const Q=Math.min(I,Y),z=this.slice(x,A),J=r.slice(n,p);for(let X=0;X<Q;++X)if(z[X]!==J[X]){I=z[X],Y=J[X];break}return I<Y?-1:Y<I?1:0};function N(h,r,n,p,x){if(h.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=x?0:h.length-1),n<0&&(n=h.length+n),n>=h.length){if(x)return-1;n=h.length-1}else if(n<0)if(x)n=0;else return-1;if(typeof r=="string"&&(r=a.from(r,p)),a.isBuffer(r))return r.length===0?-1:R(h,r,n,p,x);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?x?Uint8Array.prototype.indexOf.call(h,r,n):Uint8Array.prototype.lastIndexOf.call(h,r,n):R(h,[r],n,p,x);throw new TypeError("val must be string, number or Buffer")}function R(h,r,n,p,x){let A=1,I=h.length,Y=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;A=2,I/=2,Y/=2,n/=2}function Q(J,X){return A===1?J[X]:J.readUInt16BE(X*A)}let z;if(x){let J=-1;for(z=n;z<I;z++)if(Q(h,z)===Q(r,J===-1?0:z-J)){if(J===-1&&(J=z),z-J+1===Y)return J*A}else J!==-1&&(z-=z-J),J=-1}else for(n+Y>I&&(n=I-Y),z=n;z>=0;z--){let J=!0;for(let X=0;X<Y;X++)if(Q(h,z+X)!==Q(r,X)){J=!1;break}if(J)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 N(this,r,n,p,!0)},a.prototype.lastIndexOf=function(r,n,p){return N(this,r,n,p,!1)};function L(h,r,n,p){n=Number(n)||0;const x=h.length-n;p?(p=Number(p),p>x&&(p=x)):p=x;const A=r.length;p>A/2&&(p=A/2);let I;for(I=0;I<p;++I){const Y=parseInt(r.substr(I*2,2),16);if(we(Y))return I;h[n+I]=Y}return I}function y(h,r,n,p){return Mt(Z(r,h.length-n),h,n,p)}function G(h,r,n,p){return Mt(_t(r),h,n,p)}function rt(h,r,n,p){return Mt(qt(r),h,n,p)}function K(h,r,n,p){return Mt(xe(r,h.length-n),h,n,p)}a.prototype.write=function(r,n,p,x){if(n===void 0)x="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")x=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,x===void 0&&(x="utf8")):(x=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const A=this.length-n;if((p===void 0||p>A)&&(p=A),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");let I=!1;for(;;)switch(x){case"hex":return L(this,r,n,p);case"utf8":case"utf-8":return y(this,r,n,p);case"ascii":case"latin1":case"binary":return G(this,r,n,p);case"base64":return rt(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,r,n,p);default:if(I)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function it(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 x=r;for(;x<n;){const A=h[x];let I=null,Y=A>239?4:A>223?3:A>191?2:1;if(x+Y<=n){let Q,z,J,X;switch(Y){case 1:A<128&&(I=A);break;case 2:Q=h[x+1],(Q&192)===128&&(X=(A&31)<<6|Q&63,X>127&&(I=X));break;case 3:Q=h[x+1],z=h[x+2],(Q&192)===128&&(z&192)===128&&(X=(A&15)<<12|(Q&63)<<6|z&63,X>2047&&(X<55296||X>57343)&&(I=X));break;case 4:Q=h[x+1],z=h[x+2],J=h[x+3],(Q&192)===128&&(z&192)===128&&(J&192)===128&&(X=(A&15)<<18|(Q&63)<<12|(z&63)<<6|J&63,X>65535&&X<1114112&&(I=X))}}I===null?(I=65533,Y=1):I>65535&&(I-=65536,p.push(I>>>10&1023|55296),I=56320|I&1023),p.push(I),x+=Y}return mt(p)}const at=4096;function mt(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 q(h,r,n){let p="";n=Math.min(h.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(h[x]&127);return p}function Dt(h,r,n){let p="";n=Math.min(h.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(h[x]);return p}function bt(h,r,n){const p=h.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let x="";for(let A=r;A<n;++A)x+=er[h[A]];return x}function Tt(h,r,n){const p=h.slice(r,n);let x="";for(let A=0;A<p.length-1;A+=2)x+=String.fromCharCode(p[A]+p[A+1]*256);return x}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 x=this.subarray(r,n);return Object.setPrototypeOf(x,a.prototype),x};function V(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||V(r,n,this.length);let x=this[r],A=1,I=0;for(;++I<n&&(A*=256);)x+=this[r+I]*A;return x},a.prototype.readUintBE=a.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||V(r,n,this.length);let x=this[r+--n],A=1;for(;n>0&&(A*=256);)x+=this[r+--n]*A;return x},a.prototype.readUint8=a.prototype.readUInt8=function(r,n){return r=r>>>0,n||V(r,1,this.length),this[r]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||V(r,2,this.length),this[r]|this[r+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||V(r,2,this.length),this[r]<<8|this[r+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||V(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||V(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},a.prototype.readBigUInt64LE=Bt(function(r){r=r>>>0,$(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&tt(r,this.length-8);const x=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,A=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(x)+(BigInt(A)<<BigInt(32))}),a.prototype.readBigUInt64BE=Bt(function(r){r=r>>>0,$(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&tt(r,this.length-8);const x=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],A=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(x)<<BigInt(32))+BigInt(A)}),a.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||V(r,n,this.length);let x=this[r],A=1,I=0;for(;++I<n&&(A*=256);)x+=this[r+I]*A;return A*=128,x>=A&&(x-=Math.pow(2,8*n)),x},a.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||V(r,n,this.length);let x=n,A=1,I=this[r+--x];for(;x>0&&(A*=256);)I+=this[r+--x]*A;return A*=128,I>=A&&(I-=Math.pow(2,8*n)),I},a.prototype.readInt8=function(r,n){return r=r>>>0,n||V(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},a.prototype.readInt16LE=function(r,n){r=r>>>0,n||V(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||V(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||V(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||V(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},a.prototype.readBigInt64LE=Bt(function(r){r=r>>>0,$(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&tt(r,this.length-8);const x=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(x)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),a.prototype.readBigInt64BE=Bt(function(r){r=r>>>0,$(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&tt(r,this.length-8);const x=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(x)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),a.prototype.readFloatLE=function(r,n){return r=r>>>0,n||V(r,4,this.length),e.read(this,r,!0,23,4)},a.prototype.readFloatBE=function(r,n){return r=r>>>0,n||V(r,4,this.length),e.read(this,r,!1,23,4)},a.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||V(r,8,this.length),e.read(this,r,!0,52,8)},a.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||V(r,8,this.length),e.read(this,r,!1,52,8)};function W(h,r,n,p,x,A){if(!a.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>x||r<A)throw new RangeError('"value" argument is out of bounds');if(n+p>h.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const Y=Math.pow(2,8*p)-1;W(this,r,n,p,Y,0)}let A=1,I=0;for(this[n]=r&255;++I<p&&(A*=256);)this[n+I]=r/A&255;return n+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const Y=Math.pow(2,8*p)-1;W(this,r,n,p,Y,0)}let A=p-1,I=1;for(this[n+A]=r&255;--A>=0&&(I*=256);)this[n+A]=r/I&255;return n+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,255,0),this[n]=r&255,n+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function At(h,r,n,p,x){H(r,p,x,h,n,7);let A=Number(r&BigInt(4294967295));h[n++]=A,A=A>>8,h[n++]=A,A=A>>8,h[n++]=A,A=A>>8,h[n++]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return h[n++]=I,I=I>>8,h[n++]=I,I=I>>8,h[n++]=I,I=I>>8,h[n++]=I,n}function xt(h,r,n,p,x){H(r,p,x,h,n,7);let A=Number(r&BigInt(4294967295));h[n+7]=A,A=A>>8,h[n+6]=A,A=A>>8,h[n+5]=A,A=A>>8,h[n+4]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return h[n+3]=I,I=I>>8,h[n+2]=I,I=I>>8,h[n+1]=I,I=I>>8,h[n]=I,n+8}a.prototype.writeBigUInt64LE=Bt(function(r,n=0){return At(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Bt(function(r,n=0){return xt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const Q=Math.pow(2,8*p-1);W(this,r,n,p,Q-1,-Q)}let A=0,I=1,Y=0;for(this[n]=r&255;++A<p&&(I*=256);)r<0&&Y===0&&this[n+A-1]!==0&&(Y=1),this[n+A]=(r/I>>0)-Y&255;return n+p},a.prototype.writeIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const Q=Math.pow(2,8*p-1);W(this,r,n,p,Q-1,-Q)}let A=p-1,I=1,Y=0;for(this[n+A]=r&255;--A>=0&&(I*=256);)r<0&&Y===0&&this[n+A+1]!==0&&(Y=1),this[n+A]=(r/I>>0)-Y&255;return n+p},a.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},a.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},a.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},a.prototype.writeBigInt64LE=Bt(function(r,n=0){return At(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Bt(function(r,n=0){return xt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Kt(h,r,n,p,x,A){if(n+p>h.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(h,r,n,p,x){return r=+r,n=n>>>0,x||Kt(h,r,n,4),e.write(h,r,n,p,23,4),n+4}a.prototype.writeFloatLE=function(r,n,p){return Ht(this,r,n,!0,p)},a.prototype.writeFloatBE=function(r,n,p){return Ht(this,r,n,!1,p)};function d(h,r,n,p,x){return r=+r,n=n>>>0,x||Kt(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,x){if(!a.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!x&&x!==0&&(x=this.length),n>=r.length&&(n=r.length),n||(n=0),x>0&&x<p&&(x=p),x===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(x<0)throw new RangeError("sourceEnd out of bounds");x>this.length&&(x=this.length),r.length-n<x-p&&(x=r.length-n+p);const A=x-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,x):Uint8Array.prototype.set.call(r,this.subarray(p,x),n),A},a.prototype.fill=function(r,n,p,x){if(typeof r=="string"){if(typeof n=="string"?(x=n,n=0,p=this.length):typeof p=="string"&&(x=p,p=this.length),x!==void 0&&typeof x!="string")throw new TypeError("encoding must be a string");if(typeof x=="string"&&!a.isEncoding(x))throw new TypeError("Unknown encoding: "+x);if(r.length===1){const I=r.charCodeAt(0);(x==="utf8"&&I<128||x==="latin1")&&(r=I)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let A;if(typeof r=="number")for(A=n;A<p;++A)this[A]=r;else{const I=a.isBuffer(r)?r:a.from(r,x),Y=I.length;if(Y===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(A=0;A<p-n;++A)this[A+n]=I[A%Y]}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(x){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:x,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.`,x=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?x=w(String(n)):typeof n=="bigint"&&(x=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(x=w(x)),x+="n"),p+=` It must be ${r}. Received ${x}`,p},RangeError);function w(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 j(h,r,n){$(r,"offset"),(h[r]===void 0||h[r+n]===void 0)&&tt(r,h.length-(n+1))}function H(h,r,n,p,x,A){if(h>n||h<r){const I=typeof r=="bigint"?"n":"";let Y;throw r===0||r===BigInt(0)?Y=`>= 0${I} and < 2${I} ** ${(A+1)*8}${I}`:Y=`>= -(2${I} ** ${(A+1)*8-1}${I}) and < 2 ** ${(A+1)*8-1}${I}`,new l.ERR_OUT_OF_RANGE("value",Y,h)}j(p,x,A)}function $(h,r){if(typeof h!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",h)}function tt(h,r,n){throw Math.floor(h)!==h?($(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 st=/[^+/0-9A-Za-z-_]/g;function It(h){if(h=h.split("=")[0],h=h.trim().replace(st,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function Z(h,r){r=r||1/0;let n;const p=h.length;let x=null;const A=[];for(let I=0;I<p;++I){if(n=h.charCodeAt(I),n>55295&&n<57344){if(!x){if(n>56319){(r-=3)>-1&&A.push(239,191,189);continue}else if(I+1===p){(r-=3)>-1&&A.push(239,191,189);continue}x=n;continue}if(n<56320){(r-=3)>-1&&A.push(239,191,189),x=n;continue}n=(x-55296<<10|n-56320)+65536}else x&&(r-=3)>-1&&A.push(239,191,189);if(x=null,n<128){if((r-=1)<0)break;A.push(n)}else if(n<2048){if((r-=2)<0)break;A.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;A.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;A.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return A}function _t(h){const r=[];for(let n=0;n<h.length;++n)r.push(h.charCodeAt(n)&255);return r}function xe(h,r){let n,p,x;const A=[];for(let I=0;I<h.length&&!((r-=2)<0);++I)n=h.charCodeAt(I),p=n>>8,x=n%256,A.push(x),A.push(p);return A}function qt(h){return t.toByteArray(It(h))}function Mt(h,r,n,p){let x;for(x=0;x<p&&!(x+n>=r.length||x>=h.length);++x)r[x+n]=h[x];return x}function ht(h,r){return h instanceof r||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===r.name}function we(h){return h!==h}const er=function(){const h="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let x=0;x<16;++x)r[p+x]=h[n]+h[x]}return r}();function Bt(h){return typeof BigInt>"u"?ir:h}function ir(){throw new Error("BigInt not supported")}}(re)),re}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ne;function _i(){return Ne||(Ne=1,function(u,t){var e=Fe(),i=e.Buffer;function s(o,a){for(var g in o)a[g]=o[g]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?u.exports=e:(s(e,t),t.Buffer=c);function c(o,a,g){return i(o,a,g)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(o,a,g){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,a,g)},c.alloc=function(o,a,g){if(typeof o!="number")throw new TypeError("Argument must be a number");var v=i(o);return a!==void 0?typeof g=="string"?v.fill(a,g):v.fill(a):v.fill(0),v},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)}}(Xt,Xt.exports)),Xt.exports}var Oe;function gi(){if(Oe)return ie;Oe=1;var u=_i().Buffer,t=u.isEncoding||function(_){switch(_=""+_,_&&_.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(_){if(!_)return"utf8";for(var b;;)switch(_){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return _;default:if(b)return;_=(""+_).toLowerCase(),b=!0}}function i(_){var b=e(_);if(typeof b!="string"&&(u.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return b||_}ie.StringDecoder=s;function s(_){this.encoding=i(_);var b;switch(this.encoding){case"utf16le":this.text=S,this.end=C,b=4;break;case"utf8":this.fillLast=g,b=4;break;case"base64":this.text=B,this.end=F,b=3;break;default:this.write=D,this.end=P;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(b)}s.prototype.write=function(_){if(_.length===0)return"";var b,m;if(this.lastNeed){if(b=this.fillLast(_),b===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?b?b+this.text(_,m):this.text(_,m):b||""},s.prototype.end=E,s.prototype.text=v,s.prototype.fillLast=function(_){if(this.lastNeed<=_.length)return _.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,this.lastTotal-this.lastNeed,0,_.length),this.lastNeed-=_.length};function c(_){return _<=127?0:_>>5===6?2:_>>4===14?3:_>>3===30?4:_>>6===2?-1:-2}function o(_,b,m){var f=b.length-1;if(f<m)return 0;var T=c(b[f]);return T>=0?(T>0&&(_.lastNeed=T-1),T):--f<m||T===-2?0:(T=c(b[f]),T>=0?(T>0&&(_.lastNeed=T-2),T):--f<m||T===-2?0:(T=c(b[f]),T>=0?(T>0&&(T===2?T=0:_.lastNeed=T-3),T):0))}function a(_,b,m){if((b[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&b.length>1){if((b[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&b.length>2&&(b[2]&192)!==128)return _.lastNeed=2,"�"}}function g(_){var b=this.lastTotal-this.lastNeed,m=a(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,b,0,_.length),this.lastNeed-=_.length}function v(_,b){var m=o(this,_,b);if(!this.lastNeed)return _.toString("utf8",b);this.lastTotal=m;var f=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,f),_.toString("utf8",b,f)}function E(_){var b=_&&_.length?this.write(_):"";return this.lastNeed?b+"�":b}function S(_,b){if((_.length-b)%2===0){var m=_.toString("utf16le",b);if(m){var f=m.charCodeAt(m.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=_[_.length-1],_.toString("utf16le",b,_.length-1)}function C(_){var b=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,m)}return b}function B(_,b){var m=(_.length-b)%3;return m===0?_.toString("base64",b):(this.lastNeed=3-m,this.lastTotal=3,m===1?this.lastChar[0]=_[_.length-1]:(this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1]),_.toString("base64",b,_.length-m))}function F(_){var b=_&&_.length?this.write(_):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function D(_){return _.toString(this.encoding)}function P(_){return _&&_.length?this.write(_):""}return ie}var De;function yi(){return De||(De=1,function(u){(function(t){t.parser=function(d,l){return new i(d,l)},t.SAXParser=i,t.SAXStream=E,t.createStream=v,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=y.BEGIN,M.strictEntities=M.opt.strictEntities,M.ENTITIES=M.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),M.attribList=[],M.opt.xmlns&&(M.ns=Object.create(D)),M.opt.unquotedAttributeValues===void 0&&(M.opt.unquotedAttributeValues=!d),M.trackPosition=M.opt.position!==!1,M.trackPosition&&(M.position=M.line=M.column=0),rt(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,w=0,j=e.length;w<j;w++){var H=d[e[w]].length;if(H>l)switch(e[w]){case"textNode":it(d);break;case"cdata":K(d,"oncdata",d.cdata),d.cdata="";break;case"script":K(d,"onscript",d.script),d.script="";break;default:at(d,"Max buffer length exceeded: "+e[w])}M=Math.max(M,H)}var $=t.MAX_BUFFER_LENGTH-M;d.bufferCheckPosition=$+d.position}function c(d){for(var l=0,M=e.length;l<M;l++)d[e[l]]=""}function o(d){it(d),d.cdata!==""&&(K(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(K(d,"onscript",d.script),d.script="")}i.prototype={end:function(){mt(this)},write:Ht,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a;try{a=di.Stream}catch{a=function(){}}a||(a=function(){});var g=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function v(d,l){return new E(d,l)}function E(d,l){if(!(this instanceof E))return new E(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(w){M.emit("error",w),M._parser.error=null},this._decoder=null,g.forEach(function(w){Object.defineProperty(M,"on"+w,{get:function(){return M._parser["on"+w]},set:function(j){if(!j)return M.removeAllListeners(w),M._parser["on"+w]=j,j;M.on(w,j)},enumerable:!0,configurable:!1})})}E.prototype=Object.create(a.prototype,{constructor:{value:E}}),E.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var l=gi().StringDecoder;this._decoder=new l("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},E.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},E.prototype.on=function(d,l){var M=this;return!M._parser["on"+d]&&g.indexOf(d)!==-1&&(M._parser["on"+d]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,d),M.emit.apply(M,w)}),a.prototype.on.call(M,d,l)};var S="[CDATA[",C="DOCTYPE",B="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",D={xml:B,xmlns:F},P=/[:_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-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(d){return d===" "||d===`
|
|
7
|
-
`||d==="\r"||d===" "}function
|
|
6
|
+
*/var Be;function Fe(){return Be||(Be=1,function(h){const t=mi(),e=_i(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=v,h.INSPECT_MAX_BYTES=50;const s=2147483647;h.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=c(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const u=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(u,r),u.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function a(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const r=new Uint8Array(u);return Object.setPrototypeOf(r,o.prototype),r}function o(u,r,n){if(typeof u=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(u)}return g(u,r,n)}o.poolSize=8192;function g(u,r,n){if(typeof u=="string")return A(u,r);if(ArrayBuffer.isView(u))return F(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(mt(u,ArrayBuffer)||u&&mt(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(u,SharedArrayBuffer)||u&&mt(u.buffer,SharedArrayBuffer)))return N(u,r,n);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=u.valueOf&&u.valueOf();if(p!=null&&p!==u)return o.from(p,r,n);const E=P(u);if(E)return E;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return o.from(u[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}o.from=function(u,r,n){return g(u,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function S(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function x(u,r,n){return S(u),u<=0?a(u):r!==void 0?typeof n=="string"?a(u).fill(r,n):a(u).fill(r):a(u)}o.alloc=function(u,r,n){return x(u,r,n)};function C(u){return S(u),a(u<0?0:_(u)|0)}o.allocUnsafe=function(u){return C(u)},o.allocUnsafeSlow=function(u){return C(u)};function A(u,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=m(u,r)|0;let p=a(n);const E=p.write(u,r);return E!==n&&(p=p.slice(0,E)),p}function B(u){const r=u.length<0?0:_(u.length)|0,n=a(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function F(u){if(mt(u,Uint8Array)){const r=new Uint8Array(u);return N(r.buffer,r.byteOffset,r.byteLength)}return B(u)}function N(u,r,n){if(r<0||u.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(u):n===void 0?p=new Uint8Array(u,r):p=new Uint8Array(u,r,n),Object.setPrototypeOf(p,o.prototype),p}function P(u){if(o.isBuffer(u)){const r=_(u.length)|0,n=a(r);return n.length===0||u.copy(n,0,0,r),n}if(u.length!==void 0)return typeof u.length!="number"||we(u.length)?a(0):B(u);if(u.type==="Buffer"&&Array.isArray(u.data))return B(u.data)}function _(u){if(u>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return u|0}function v(u){return+u!=u&&(u=0),o.alloc(+u)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(mt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),mt(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let p=r.length,E=n.length;for(let T=0,M=Math.min(p,E);T<M;++T)if(r[T]!==n[T]){p=r[T],E=n[T];break}return p<E?-1:E<p?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const E=o.allocUnsafe(n);let T=0;for(p=0;p<r.length;++p){let M=r[p];if(mt(M,Uint8Array))T+M.length>E.length?(o.isBuffer(M)||(M=o.from(M)),M.copy(E,T)):Uint8Array.prototype.set.call(E,M,T);else if(o.isBuffer(M))M.copy(E,T);else throw new TypeError('"list" argument must be an Array of Buffers');T+=M.length}return E};function m(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||mt(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);const n=u.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let E=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return st(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qt(u).length;default:if(E)return p?-1:st(u).length;r=(""+r).toLowerCase(),E=!0}}o.byteLength=m;function f(u,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(u||(u="utf8");;)switch(u){case"hex":return $(this,r,n);case"utf8":case"utf-8":return lt(this,r,n);case"ascii":return L(this,r,n);case"latin1":case"binary":return nt(this,r,n);case"base64":return z(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),p=!0}}o.prototype._isBuffer=!0;function b(u,r,n){const p=u[r];u[r]=u[n],u[n]=p}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?lt(this,0,r):f.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const n=h.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(r,n,p,E,T){if(mt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),E===void 0&&(E=0),T===void 0&&(T=this.length),n<0||p>r.length||E<0||T>this.length)throw new RangeError("out of range index");if(E>=T&&n>=p)return 0;if(E>=T)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,E>>>=0,T>>>=0,this===r)return 0;let M=T-E,K=p-n;const tt=Math.min(M,K),J=this.slice(E,T),et=r.slice(n,p);for(let W=0;W<tt;++W)if(J[W]!==et[W]){M=J[W],K=et[W];break}return M<K?-1:K<M?1:0};function O(u,r,n,p,E){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=E?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(E)return-1;n=u.length-1}else if(n<0)if(E)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,p)),o.isBuffer(r))return r.length===0?-1:R(u,r,n,p,E);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?E?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):R(u,[r],n,p,E);throw new TypeError("val must be string, number or Buffer")}function R(u,r,n,p,E){let T=1,M=u.length,K=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(u.length<2||r.length<2)return-1;T=2,M/=2,K/=2,n/=2}function tt(et,W){return T===1?et[W]:et.readUInt16BE(W*T)}let J;if(E){let et=-1;for(J=n;J<M;J++)if(tt(u,J)===tt(r,et===-1?0:J-et)){if(et===-1&&(et=J),J-et+1===K)return et*T}else et!==-1&&(J-=J-et),et=-1}else for(n+K>M&&(n=M-K),J=n;J>=0;J--){let et=!0;for(let W=0;W<K;W++)if(tt(u,J+W)!==tt(r,W)){et=!1;break}if(et)return J}return-1}o.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},o.prototype.indexOf=function(r,n,p){return O(this,r,n,p,!0)},o.prototype.lastIndexOf=function(r,n,p){return O(this,r,n,p,!1)};function U(u,r,n,p){n=Number(n)||0;const E=u.length-n;p?(p=Number(p),p>E&&(p=E)):p=E;const T=r.length;p>T/2&&(p=T/2);let M;for(M=0;M<p;++M){const K=parseInt(r.substr(M*2,2),16);if(we(K))return M;u[n+M]=K}return M}function y(u,r,n,p){return Bt(st(r,u.length-n),u,n,p)}function V(u,r,n,p){return Bt(xt(r),u,n,p)}function Q(u,r,n,p){return Bt(qt(r),u,n,p)}function G(u,r,n,p){return Bt(Ee(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,E){if(n===void 0)E="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")E=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,E===void 0&&(E="utf8")):(E=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const T=this.length-n;if((p===void 0||p>T)&&(p=T),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");E||(E="utf8");let M=!1;for(;;)switch(E){case"hex":return U(this,r,n,p);case"utf8":case"utf-8":return y(this,r,n,p);case"ascii":case"latin1":case"binary":return V(this,r,n,p);case"base64":return Q(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,r,n,p);default:if(M)throw new TypeError("Unknown encoding: "+E);E=(""+E).toLowerCase(),M=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function z(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function lt(u,r,n){n=Math.min(u.length,n);const p=[];let E=r;for(;E<n;){const T=u[E];let M=null,K=T>239?4:T>223?3:T>191?2:1;if(E+K<=n){let tt,J,et,W;switch(K){case 1:T<128&&(M=T);break;case 2:tt=u[E+1],(tt&192)===128&&(W=(T&31)<<6|tt&63,W>127&&(M=W));break;case 3:tt=u[E+1],J=u[E+2],(tt&192)===128&&(J&192)===128&&(W=(T&15)<<12|(tt&63)<<6|J&63,W>2047&&(W<55296||W>57343)&&(M=W));break;case 4:tt=u[E+1],J=u[E+2],et=u[E+3],(tt&192)===128&&(J&192)===128&&(et&192)===128&&(W=(T&15)<<18|(tt&63)<<12|(J&63)<<6|et&63,W>65535&&W<1114112&&(M=W))}}M===null?(M=65533,K=1):M>65535&&(M-=65536,p.push(M>>>10&1023|55296),M=56320|M&1023),p.push(M),E+=K}return ct(p)}const it=4096;function ct(u){const r=u.length;if(r<=it)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=it));return n}function L(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]&127);return p}function nt(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]);return p}function $(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let E="";for(let T=r;T<n;++T)E+=nr[u[T]];return E}function rt(u,r,n){const p=u.slice(r,n);let E="";for(let T=0;T<p.length-1;T+=2)E+=String.fromCharCode(p[T]+p[T+1]*256);return E}o.prototype.slice=function(r,n){const p=this.length;r=~~r,n=n===void 0?p:~~n,r<0?(r+=p,r<0&&(r=0)):r>p&&(r=p),n<0?(n+=p,n<0&&(n=0)):n>p&&(n=p),n<r&&(n=r);const E=this.subarray(r,n);return Object.setPrototypeOf(E,o.prototype),E};function Y(u,r,n){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r],T=1,M=0;for(;++M<n&&(T*=256);)E+=this[r+M]*T;return E},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r+--n],T=1;for(;n>0&&(T*=256);)E+=this[r+--n]*T;return E},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||Y(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||Y(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||Y(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&at(r,this.length-8);const E=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,T=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(E)+(BigInt(T)<<BigInt(32))}),o.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&at(r,this.length-8);const E=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],T=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(E)<<BigInt(32))+BigInt(T)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r],T=1,M=0;for(;++M<n&&(T*=256);)E+=this[r+M]*T;return T*=128,E>=T&&(E-=Math.pow(2,8*n)),E},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=n,T=1,M=this[r+--E];for(;E>0&&(T*=256);)M+=this[r+--E]*T;return T*=128,M>=T&&(M-=Math.pow(2,8*n)),M},o.prototype.readInt8=function(r,n){return r=r>>>0,n||Y(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||Y(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||Y(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&at(r,this.length-8);const E=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(E)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),o.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&at(r,this.length-8);const E=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(E)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||Y(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||Y(r,8,this.length),e.read(this,r,!1,52,8)};function H(u,r,n,p,E,T){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>E||r<T)throw new RangeError('"value" argument is out of bounds');if(n+p>u.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const K=Math.pow(2,8*p)-1;H(this,r,n,p,K,0)}let T=1,M=0;for(this[n]=r&255;++M<p&&(T*=256);)this[n+M]=r/T&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const K=Math.pow(2,8*p)-1;H(this,r,n,p,K,0)}let T=p-1,M=1;for(this[n+T]=r&255;--T>=0&&(M*=256);)this[n+T]=r/M&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function At(u,r,n,p,E){Z(r,p,E,u,n,7);let T=Number(r&BigInt(4294967295));u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T;let M=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=M,M=M>>8,u[n++]=M,M=M>>8,u[n++]=M,M=M>>8,u[n++]=M,n}function bt(u,r,n,p,E){Z(r,p,E,u,n,7);let T=Number(r&BigInt(4294967295));u[n+7]=T,T=T>>8,u[n+6]=T,T=T>>8,u[n+5]=T,T=T>>8,u[n+4]=T;let M=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=M,M=M>>8,u[n+2]=M,M=M>>8,u[n+1]=M,M=M>>8,u[n]=M,n+8}o.prototype.writeBigUInt64LE=Ft(function(r,n=0){return At(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Ft(function(r,n=0){return bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const tt=Math.pow(2,8*p-1);H(this,r,n,p,tt-1,-tt)}let T=0,M=1,K=0;for(this[n]=r&255;++T<p&&(M*=256);)r<0&&K===0&&this[n+T-1]!==0&&(K=1),this[n+T]=(r/M>>0)-K&255;return n+p},o.prototype.writeIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const tt=Math.pow(2,8*p-1);H(this,r,n,p,tt-1,-tt)}let T=p-1,M=1,K=0;for(this[n+T]=r&255;--T>=0&&(M*=256);)r<0&&K===0&&this[n+T+1]!==0&&(K=1),this[n+T]=(r/M>>0)-K&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=Ft(function(r,n=0){return At(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Ft(function(r,n=0){return bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vt(u,r,n,p,E,T){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(u,r,n,p,E){return r=+r,n=n>>>0,E||Vt(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return Ht(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return Ht(this,r,n,!1,p)};function d(u,r,n,p,E){return r=+r,n=n>>>0,E||Vt(u,r,n,8),e.write(u,r,n,p,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,p){return d(this,r,n,!0,p)},o.prototype.writeDoubleBE=function(r,n,p){return d(this,r,n,!1,p)},o.prototype.copy=function(r,n,p,E){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!E&&E!==0&&(E=this.length),n>=r.length&&(n=r.length),n||(n=0),E>0&&E<p&&(E=p),E===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("sourceEnd out of bounds");E>this.length&&(E=this.length),r.length-n<E-p&&(E=r.length-n+p);const T=E-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,E):Uint8Array.prototype.set.call(r,this.subarray(p,E),n),T},o.prototype.fill=function(r,n,p,E){if(typeof r=="string"){if(typeof n=="string"?(E=n,n=0,p=this.length):typeof p=="string"&&(E=p,p=this.length),E!==void 0&&typeof E!="string")throw new TypeError("encoding must be a string");if(typeof E=="string"&&!o.isEncoding(E))throw new TypeError("Unknown encoding: "+E);if(r.length===1){const M=r.charCodeAt(0);(E==="utf8"&&M<128||E==="latin1")&&(r=M)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let T;if(typeof r=="number")for(T=n;T<p;++T)this[T]=r;else{const M=o.isBuffer(r)?r:o.from(r,E),K=M.length;if(K===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(T=0;T<p-n;++T)this[T+n]=M[T%K]}return this};const l={};function I(u,r,n){l[u]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${u}]`,this.stack,delete this.name}get code(){return u}set code(E){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:E,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}I("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),I("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),I("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,E=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?E=w(String(n)):typeof n=="bigint"&&(E=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(E=w(E)),E+="n"),p+=` It must be ${r}. Received ${E}`,p},RangeError);function w(u){let r="",n=u.length;const p=u[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${u.slice(n-3,n)}${r}`;return`${u.slice(0,n)}${r}`}function j(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&at(r,u.length-(n+1))}function Z(u,r,n,p,E,T){if(u>n||u<r){const M=typeof r=="bigint"?"n":"";let K;throw r===0||r===BigInt(0)?K=`>= 0${M} and < 2${M} ** ${(T+1)*8}${M}`:K=`>= -(2${M} ** ${(T+1)*8-1}${M}) and < 2 ** ${(T+1)*8-1}${M}`,new l.ERR_OUT_OF_RANGE("value",K,u)}j(p,E,T)}function X(u,r){if(typeof u!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",u)}function at(u,r,n){throw Math.floor(u)!==u?(X(u,n),new l.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const ut=/[^+/0-9A-Za-z-_]/g;function It(u){if(u=u.split("=")[0],u=u.trim().replace(ut,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function st(u,r){r=r||1/0;let n;const p=u.length;let E=null;const T=[];for(let M=0;M<p;++M){if(n=u.charCodeAt(M),n>55295&&n<57344){if(!E){if(n>56319){(r-=3)>-1&&T.push(239,191,189);continue}else if(M+1===p){(r-=3)>-1&&T.push(239,191,189);continue}E=n;continue}if(n<56320){(r-=3)>-1&&T.push(239,191,189),E=n;continue}n=(E-55296<<10|n-56320)+65536}else E&&(r-=3)>-1&&T.push(239,191,189);if(E=null,n<128){if((r-=1)<0)break;T.push(n)}else if(n<2048){if((r-=2)<0)break;T.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;T.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;T.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return T}function xt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Ee(u,r){let n,p,E;const T=[];for(let M=0;M<u.length&&!((r-=2)<0);++M)n=u.charCodeAt(M),p=n>>8,E=n%256,T.push(E),T.push(p);return T}function qt(u){return t.toByteArray(It(u))}function Bt(u,r,n,p){let E;for(E=0;E<p&&!(E+n>=r.length||E>=u.length);++E)r[E+n]=u[E];return E}function mt(u,r){return u instanceof r||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===r.name}function we(u){return u!==u}const nr=function(){const u="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let E=0;E<16;++E)r[p+E]=u[n]+u[E]}return r}();function Ft(u){return typeof BigInt>"u"?ar:u}function ar(){throw new Error("BigInt not supported")}}(re)),re}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var De;function yi(){return De||(De=1,function(h,t){var e=Fe(),i=e.Buffer;function s(a,o){for(var g in a)o[g]=a[g]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(a,o,g){return i(a,o,g)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(a,o,g){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,g)},c.alloc=function(a,o,g){if(typeof a!="number")throw new TypeError("Argument must be a number");var S=i(a);return o!==void 0?typeof g=="string"?S.fill(o,g):S.fill(o):S.fill(0),S},c.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i(a)},c.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(a)}}(jt,jt.exports)),jt.exports}var Oe;function gi(){if(Oe)return ie;Oe=1;var h=yi().Buffer,t=h.isEncoding||function(_){switch(_=""+_,_&&_.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(_){if(!_)return"utf8";for(var v;;)switch(_){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return _;default:if(v)return;_=(""+_).toLowerCase(),v=!0}}function i(_){var v=e(_);if(typeof v!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return v||_}ie.StringDecoder=s;function s(_){this.encoding=i(_);var v;switch(this.encoding){case"utf16le":this.text=C,this.end=A,v=4;break;case"utf8":this.fillLast=g,v=4;break;case"base64":this.text=B,this.end=F,v=3;break;default:this.write=N,this.end=P;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(v)}s.prototype.write=function(_){if(_.length===0)return"";var v,m;if(this.lastNeed){if(v=this.fillLast(_),v===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?v?v+this.text(_,m):this.text(_,m):v||""},s.prototype.end=x,s.prototype.text=S,s.prototype.fillLast=function(_){if(this.lastNeed<=_.length)return _.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,this.lastTotal-this.lastNeed,0,_.length),this.lastNeed-=_.length};function c(_){return _<=127?0:_>>5===6?2:_>>4===14?3:_>>3===30?4:_>>6===2?-1:-2}function a(_,v,m){var f=v.length-1;if(f<m)return 0;var b=c(v[f]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--f<m||b===-2?0:(b=c(v[f]),b>=0?(b>0&&(_.lastNeed=b-2),b):--f<m||b===-2?0:(b=c(v[f]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,v,m){if((v[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return _.lastNeed=2,"�"}}function g(_){var v=this.lastTotal-this.lastNeed,m=o(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,v,0,_.length),this.lastNeed-=_.length}function S(_,v){var m=a(this,_,v);if(!this.lastNeed)return _.toString("utf8",v);this.lastTotal=m;var f=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,f),_.toString("utf8",v,f)}function x(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+"�":v}function C(_,v){if((_.length-v)%2===0){var m=_.toString("utf16le",v);if(m){var f=m.charCodeAt(m.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=_[_.length-1],_.toString("utf16le",v,_.length-1)}function A(_){var v=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,m)}return v}function B(_,v){var m=(_.length-v)%3;return m===0?_.toString("base64",v):(this.lastNeed=3-m,this.lastTotal=3,m===1?this.lastChar[0]=_[_.length-1]:(this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1]),_.toString("base64",v,_.length-m))}function F(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function N(_){return _.toString(this.encoding)}function P(_){return _&&_.length?this.write(_):""}return ie}var Ne;function xi(){return Ne||(Ne=1,function(h){(function(t){t.parser=function(d,l){return new i(d,l)},t.SAXParser=i,t.SAXStream=x,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,l){if(!(this instanceof i))return new i(d,l);var I=this;c(I),I.q=I.c="",I.bufferCheckPosition=t.MAX_BUFFER_LENGTH,I.opt=l||{},I.opt.lowercase=I.opt.lowercase||I.opt.lowercasetags,I.looseCase=I.opt.lowercase?"toLowerCase":"toUpperCase",I.tags=[],I.closed=I.closedRoot=I.sawRoot=!1,I.tag=I.error=null,I.strict=!!d,I.noscript=!!(d||I.opt.noscript),I.state=y.BEGIN,I.strictEntities=I.opt.strictEntities,I.ENTITIES=I.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),I.attribList=[],I.opt.xmlns&&(I.ns=Object.create(N)),I.opt.unquotedAttributeValues===void 0&&(I.opt.unquotedAttributeValues=!d),I.trackPosition=I.opt.position!==!1,I.trackPosition&&(I.position=I.line=I.column=0),Q(I,"onready")}Object.create||(Object.create=function(d){function l(){}l.prototype=d;var I=new l;return I}),Object.keys||(Object.keys=function(d){var l=[];for(var I in d)d.hasOwnProperty(I)&&l.push(I);return l});function s(d){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),I=0,w=0,j=e.length;w<j;w++){var Z=d[e[w]].length;if(Z>l)switch(e[w]){case"textNode":z(d);break;case"cdata":G(d,"oncdata",d.cdata),d.cdata="";break;case"script":G(d,"onscript",d.script),d.script="";break;default:it(d,"Max buffer length exceeded: "+e[w])}I=Math.max(I,Z)}var X=t.MAX_BUFFER_LENGTH-I;d.bufferCheckPosition=X+d.position}function c(d){for(var l=0,I=e.length;l<I;l++)d[e[l]]=""}function a(d){z(d),d.cdata!==""&&(G(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(G(d,"onscript",d.script),d.script="")}i.prototype={end:function(){ct(this)},write:Ht,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=pi.Stream}catch{o=function(){}}o||(o=function(){});var g=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function S(d,l){return new x(d,l)}function x(d,l){if(!(this instanceof x))return new x(d,l);o.apply(this),this._parser=new i(d,l),this.writable=!0,this.readable=!0;var I=this;this._parser.onend=function(){I.emit("end")},this._parser.onerror=function(w){I.emit("error",w),I._parser.error=null},this._decoder=null,g.forEach(function(w){Object.defineProperty(I,"on"+w,{get:function(){return I._parser["on"+w]},set:function(j){if(!j)return I.removeAllListeners(w),I._parser["on"+w]=j,j;I.on(w,j)},enumerable:!0,configurable:!1})})}x.prototype=Object.create(o.prototype,{constructor:{value:x}}),x.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var l=gi().StringDecoder;this._decoder=new l("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},x.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},x.prototype.on=function(d,l){var I=this;return!I._parser["on"+d]&&g.indexOf(d)!==-1&&(I._parser["on"+d]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,d),I.emit.apply(I,w)}),o.prototype.on.call(I,d,l)};var C="[CDATA[",A="DOCTYPE",B="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",N={xml:B,xmlns:F},P=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,v=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(d){return d===" "||d===`
|
|
7
|
+
`||d==="\r"||d===" "}function b(d){return d==='"'||d==="'"}function O(d){return d===">"||f(d)}function R(d,l){return d.test(l)}function U(d,l){return!R(d,l)}var y=0;t.STATE={BEGIN:y++,BEGIN_WHITESPACE:y++,TEXT:y++,TEXT_ENTITY:y++,OPEN_WAKA:y++,SGML_DECL:y++,SGML_DECL_QUOTED:y++,DOCTYPE:y++,DOCTYPE_QUOTED:y++,DOCTYPE_DTD:y++,DOCTYPE_DTD_QUOTED:y++,COMMENT_STARTING:y++,COMMENT:y++,COMMENT_ENDING:y++,COMMENT_ENDED:y++,CDATA:y++,CDATA_ENDING:y++,CDATA_ENDING_2:y++,PROC_INST:y++,PROC_INST_BODY:y++,PROC_INST_ENDING:y++,OPEN_TAG:y++,OPEN_TAG_SLASH:y++,ATTRIB:y++,ATTRIB_NAME:y++,ATTRIB_NAME_SAW_WHITE:y++,ATTRIB_VALUE:y++,ATTRIB_VALUE_QUOTED:y++,ATTRIB_VALUE_CLOSED:y++,ATTRIB_VALUE_UNQUOTED:y++,ATTRIB_VALUE_ENTITY_Q:y++,ATTRIB_VALUE_ENTITY_U:y++,CLOSE_TAG:y++,CLOSE_TAG_SAW_WHITE:y++,SCRIPT:y++,SCRIPT_ENDING:y++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(d){var l=t.ENTITIES[d],I=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[d]=I});for(var V in t.STATE)t.STATE[t.STATE[V]]=V;y=t.STATE;function Q(d,l,I){d[l]&&d[l](I)}function G(d,l,I){d.textNode&&z(d),Q(d,l,I)}function z(d){d.textNode=lt(d.opt,d.textNode),d.textNode&&Q(d,"ontext",d.textNode),d.textNode=""}function lt(d,l){return d.trim&&(l=l.trim()),d.normalize&&(l=l.replace(/\s+/g," ")),l}function it(d,l){return z(d),d.trackPosition&&(l+=`
|
|
8
8
|
Line: `+d.line+`
|
|
9
9
|
Column: `+d.column+`
|
|
10
|
-
Char: `+d.c),l=new Error(l),d.error=l,
|
|
11
|
-
Actual: `+d.attribValue);else if(w==="xmlns"&&d.attribValue!==F)
|
|
12
|
-
Actual: `+d.attribValue);else{var j=d.tag,
|
|
13
|
-
`?(l.line++,l.column=0):l.column++),l.state){case y.BEGIN:if(l.state=y.BEGIN_WHITESPACE,w==="\uFEFF")continue;
|
|
14
|
-
`?(l.line++,l.column=0):l.column++);l.textNode+=d.substring(j,M-1)}w==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):(!f(w)&&(!l.sawRoot||l.closedRoot)&&q(l,"Text data outside of root node."),w==="&"?l.state=y.TEXT_ENTITY:l.textNode+=w);continue;case y.SCRIPT:w==="<"?l.state=y.SCRIPT_ENDING:l.script+=w;continue;case y.SCRIPT_ENDING:w==="/"?l.state=y.CLOSE_TAG:(l.script+="<"+w,l.state=y.SCRIPT);continue;case y.OPEN_WAKA:if(w==="!")l.state=y.SGML_DECL,l.sgmlDecl="";else if(!f(w))if(R(P,w))l.state=y.OPEN_TAG,l.tagName=w;else if(w==="/")l.state=y.CLOSE_TAG,l.tagName="";else if(w==="?")l.state=y.PROC_INST,l.procInstName=l.procInstBody="";else{if(q(l,"Unencoded <"),l.startTagPosition+1<l.position){var H=l.position-l.startTagPosition;w=new Array(H).join(" ")+w}l.textNode+="<"+w,l.state=y.TEXT}continue;case y.SGML_DECL:if(l.sgmlDecl+w==="--"){l.state=y.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=y.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+w,l.sgmlDecl=""):(l.sgmlDecl+w).toUpperCase()===S?(K(l,"onopencdata"),l.state=y.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+w).toUpperCase()===C?(l.state=y.DOCTYPE,(l.doctype||l.sawRoot)&&q(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):w===">"?(K(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=y.TEXT):(T(w)&&(l.state=y.SGML_DECL_QUOTED),l.sgmlDecl+=w);continue;case y.SGML_DECL_QUOTED:w===l.q&&(l.state=y.SGML_DECL,l.q=""),l.sgmlDecl+=w;continue;case y.DOCTYPE:w===">"?(l.state=y.TEXT,K(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=w,w==="["?l.state=y.DOCTYPE_DTD:T(w)&&(l.state=y.DOCTYPE_QUOTED,l.q=w));continue;case y.DOCTYPE_QUOTED:l.doctype+=w,w===l.q&&(l.q="",l.state=y.DOCTYPE);continue;case y.DOCTYPE_DTD:w==="]"?(l.doctype+=w,l.state=y.DOCTYPE):w==="<"?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):T(w)?(l.doctype+=w,l.state=y.DOCTYPE_DTD_QUOTED,l.q=w):l.doctype+=w;continue;case y.DOCTYPE_DTD_QUOTED:l.doctype+=w,w===l.q&&(l.state=y.DOCTYPE_DTD,l.q="");continue;case y.COMMENT:w==="-"?l.state=y.COMMENT_ENDING:l.comment+=w;continue;case y.COMMENT_ENDING:w==="-"?(l.state=y.COMMENT_ENDED,l.comment=ft(l.opt,l.comment),l.comment&&K(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+w,l.state=y.COMMENT);continue;case y.COMMENT_ENDED:w!==">"?(q(l,"Malformed comment"),l.comment+="--"+w,l.state=y.COMMENT):l.doctype&&l.doctype!==!0?l.state=y.DOCTYPE_DTD:l.state=y.TEXT;continue;case y.CDATA:w==="]"?l.state=y.CDATA_ENDING:l.cdata+=w;continue;case y.CDATA_ENDING:w==="]"?l.state=y.CDATA_ENDING_2:(l.cdata+="]"+w,l.state=y.CDATA);continue;case y.CDATA_ENDING_2:w===">"?(l.cdata&&K(l,"oncdata",l.cdata),K(l,"onclosecdata"),l.cdata="",l.state=y.TEXT):w==="]"?l.cdata+="]":(l.cdata+="]]"+w,l.state=y.CDATA);continue;case y.PROC_INST:w==="?"?l.state=y.PROC_INST_ENDING:f(w)?l.state=y.PROC_INST_BODY:l.procInstName+=w;continue;case y.PROC_INST_BODY:if(!l.procInstBody&&f(w))continue;w==="?"?l.state=y.PROC_INST_ENDING:l.procInstBody+=w;continue;case y.PROC_INST_ENDING:w===">"?(K(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=y.TEXT):(l.procInstBody+="?"+w,l.state=y.PROC_INST_BODY);continue;case y.OPEN_TAG:R(_,w)?l.tagName+=w:(Dt(l),w===">"?V(l):w==="/"?l.state=y.OPEN_TAG_SLASH:(f(w)||q(l,"Invalid character in tag name"),l.state=y.ATTRIB));continue;case y.OPEN_TAG_SLASH:w===">"?(V(l,!0),W(l)):(q(l,"Forward-slash in opening tag not followed by >"),l.state=y.ATTRIB);continue;case y.ATTRIB:if(f(w))continue;w===">"?V(l):w==="/"?l.state=y.OPEN_TAG_SLASH:R(P,w)?(l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):q(l,"Invalid attribute name");continue;case y.ATTRIB_NAME:w==="="?l.state=y.ATTRIB_VALUE:w===">"?(q(l,"Attribute without value"),l.attribValue=l.attribName,Tt(l),V(l)):f(w)?l.state=y.ATTRIB_NAME_SAW_WHITE:R(_,w)?l.attribName+=w:q(l,"Invalid attribute name");continue;case y.ATTRIB_NAME_SAW_WHITE:if(w==="=")l.state=y.ATTRIB_VALUE;else{if(f(w))continue;q(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",K(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?V(l):R(P,w)?(l.attribName=w,l.state=y.ATTRIB_NAME):(q(l,"Invalid attribute name"),l.state=y.ATTRIB)}continue;case y.ATTRIB_VALUE:if(f(w))continue;T(w)?(l.q=w,l.state=y.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||at(l,"Unquoted attribute value"),l.state=y.ATTRIB_VALUE_UNQUOTED,l.attribValue=w);continue;case y.ATTRIB_VALUE_QUOTED:if(w!==l.q){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=w;continue}Tt(l),l.q="",l.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:f(w)?l.state=y.ATTRIB:w===">"?V(l):w==="/"?l.state=y.OPEN_TAG_SLASH:R(P,w)?(q(l,"No whitespace between attributes"),l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):q(l,"Invalid attribute name");continue;case y.ATTRIB_VALUE_UNQUOTED:if(!N(w)){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_U:l.attribValue+=w;continue}Tt(l),w===">"?V(l):l.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(l.tagName)w===">"?W(l):R(_,w)?l.tagName+=w:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=y.SCRIPT):(f(w)||q(l,"Invalid tagname in closing tag"),l.state=y.CLOSE_TAG_SAW_WHITE);else{if(f(w))continue;L(P,w)?l.script?(l.script+="</"+w,l.state=y.SCRIPT):q(l,"Invalid tagname in closing tag."):l.tagName=w}continue;case y.CLOSE_TAG_SAW_WHITE:if(f(w))continue;w===">"?W(l):q(l,"Invalid characters in closing tag");continue;case y.TEXT_ENTITY:case y.ATTRIB_VALUE_ENTITY_Q:case y.ATTRIB_VALUE_ENTITY_U:var $,tt;switch(l.state){case y.TEXT_ENTITY:$=y.TEXT,tt="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:$=y.ATTRIB_VALUE_QUOTED,tt="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:$=y.ATTRIB_VALUE_UNQUOTED,tt="attribValue";break}if(w===";"){var st=At(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(st)?(l.entity="",l.state=$,l.write(st)):(l[tt]+=st,l.entity="",l.state=$)}else R(l.entity.length?m:b,w)?l.entity+=w:(q(l,"Invalid character in entity name"),l[tt]+="&"+l.entity+w,l.entity="",l.state=$);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var d=String.fromCharCode,l=Math.floor,M=function(){var w=16384,j=[],H,$,tt=-1,st=arguments.length;if(!st)return"";for(var It="";++tt<st;){var Z=Number(arguments[tt]);if(!isFinite(Z)||Z<0||Z>1114111||l(Z)!==Z)throw RangeError("Invalid code point: "+Z);Z<=65535?j.push(Z):(Z-=65536,H=(Z>>10)+55296,$=Z%1024+56320,j.push(H,$)),(tt+1===st||j.length>w)&&(It+=d.apply(null,j),j.length=0)}return It};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:M,configurable:!0,writable:!0}):String.fromCodePoint=M}()})(u)}(ee)),ee}var se,Pe;function ne(){return Pe||(Pe=1,se={isArray:function(u){return Array.isArray?Array.isArray(u):Object.prototype.toString.call(u)==="[object Array]"}}),se}var ae,Re;function oe(){if(Re)return ae;Re=1;var u=ne().isArray;return ae={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!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}},ae}var le,Ue;function Le(){if(Ue)return le;Ue=1;var u=yi(),t=oe(),e=ne().isArray,i,s;function c(_){return i=t.copyOptions(_),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function o(_){var b=Number(_);if(!isNaN(b))return b;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function a(_,b){var m;if(i.compact){if(!s[i[_+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[_+"Key"])!==-1:i.alwaysArray)&&(s[i[_+"Key"]]=[]),s[i[_+"Key"]]&&!e(s[i[_+"Key"]])&&(s[i[_+"Key"]]=[s[i[_+"Key"]]]),_+"Fn"in i&&typeof b=="string"&&(b=i[_+"Fn"](b,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in b)if(b.hasOwnProperty(m))if("instructionFn"in i)b[m]=i.instructionFn(b[m],m,s);else{var f=b[m];delete b[m],b[i.instructionNameFn(m,f,s)]=f}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(b):s[i[_+"Key"]]=b}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var T={};if(T[i.typeKey]=_,_==="instruction"){for(m in b)if(b.hasOwnProperty(m))break;T[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,b,s):m,i.instructionHasAttributes?(T[i.attributesKey]=b[m][i.attributesKey],"instructionFn"in i&&(T[i.attributesKey]=i.instructionFn(T[i.attributesKey],m,s))):("instructionFn"in i&&(b[m]=i.instructionFn(b[m],m,s)),T[i.instructionKey]=b[m])}else _+"Fn"in i&&(b=i[_+"Fn"](b,s)),T[i[_+"Key"]]=b;i.addParent&&(T[i.parentKey]=s),s[i.elementsKey].push(T)}}function g(_){if("attributesFn"in i&&_&&(_=i.attributesFn(_,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&_){var b;for(b in _)if(_.hasOwnProperty(b)&&(i.trim&&(_[b]=_[b].trim()),i.nativeTypeAttributes&&(_[b]=o(_[b])),"attributeValueFn"in i&&(_[b]=i.attributeValueFn(_[b],b,s)),"attributeNameFn"in i)){var m=_[b];delete _[b],_[i.attributeNameFn(b,_[b],s)]=m}}return _}function v(_){var b={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=m.exec(_.body))!==null;)b[f[1]]=f[2]||f[3]||f[4];b=g(b)}if(_.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(b).length&&(s[i.declarationKey][i.attributesKey]=b),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(_.body=_.body.trim());var T={};i.instructionHasAttributes&&Object.keys(b).length?(T[_.name]={},T[_.name][i.attributesKey]=b):T[_.name]=_.body,a("instruction",T)}}function E(_,b){var m;if(typeof _=="object"&&(b=_.attributes,_=_.name),b=g(b),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&b&&Object.keys(b).length){m[i.attributesKey]={};var f;for(f in b)b.hasOwnProperty(f)&&(m[i.attributesKey][f]=b[f])}!(_ in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(_)!==-1:i.alwaysArray)&&(s[_]=[]),s[_]&&!e(s[_])&&(s[_]=[s[_]]),e(s[_])?s[_].push(m):s[_]=m}else s[i.elementsKey]||(s[i.elementsKey]=[]),m={},m[i.typeKey]="element",m[i.nameKey]=_,!i.ignoreAttributes&&b&&Object.keys(b).length&&(m[i.attributesKey]=b),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function S(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=o(_)),i.sanitize&&(_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),a("text",_))}function C(_){i.ignoreComment||(i.trim&&(_=_.trim()),a("comment",_))}function B(_){var b=s[i.parentKey];i.addParent||delete s[i.parentKey],s=b}function F(_){i.ignoreCdata||(i.trim&&(_=_.trim()),a("cdata",_))}function D(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),a("doctype",_))}function P(_){_.note=_}return le=function(_,b){var m=u.parser(!0,{}),f={};if(s=f,i=c(b),m.opt={strictEntities:!0},m.onopentag=E,m.ontext=S,m.oncomment=C,m.onclosetag=B,m.onerror=P,m.oncdata=F,m.ondoctype=D,m.onprocessinginstruction=v,m.write(_).close(),f[i.elementsKey]){var T=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=T,delete f.text}return f},le}var ce,ke;function Ei(){if(ke)return ce;ke=1;var u=oe(),t=Le();function e(i){var s=u.copyOptions(i);return u.ensureSpacesExists(s),s}return ce=function(i,s){var c,o,a,g;return c=e(s),o=t(i,c),g="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?a=JSON.stringify(o,function(v,E){return v===g?"_":E},c.spaces):a=JSON.stringify(o,null,c.spaces),a.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var he,Ye;function Ge(){if(Ye)return he;Ye=1;var u=oe(),t=ne().isArray,e,i;function s(m){var f=u.copyOptions(m);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(m,f,T){return(!T&&m.spaces?`
|
|
15
|
-
`:"")+Array(f+1).join(m.spaces)}function
|
|
16
|
-
`+Array(T+1).join(f.spaces):""),N.push("</"+R+">")):N.push("/>"),N.join("")}function D(m,f,T,N){return m.reduce(function(R,L){var y=c(f,T,N&&!R);switch(L.type){case"element":return R+y+F(L,f,T);case"comment":return R+y+v(L[f.commentKey],f);case"doctype":return R+y+S(L[f.doctypeKey],f);case"cdata":return R+(f.indentCdata?y:"")+E(L[f.cdataKey],f);case"text":return R+(f.indentText?y:"")+C(L[f.textKey],f);case"instruction":var G={};return G[L[f.nameKey]]=L[f.attributesKey]?L:L[f.instructionKey],R+(f.indentInstruction?y:"")+g(G,f,T)}},"")}function P(m,f,T){var N;for(N in m)if(m.hasOwnProperty(N))switch(N){case f.parentKey:case f.attributesKey:break;case f.textKey:if(f.indentText||T)return!0;break;case f.cdataKey:if(f.indentCdata||T)return!0;break;case f.instructionKey:if(f.indentInstruction||T)return!0;break;case f.doctypeKey:case f.commentKey:return!0;default:return!0}return!1}function _(m,f,T,N,R){e=m,i=f;var L="elementNameFn"in T?T.elementNameFn(f,m):f;if(typeof m>"u"||m===null||m==="")return"fullTagEmptyElementFn"in T&&T.fullTagEmptyElementFn(f,m)||T.fullTagEmptyElement?"<"+L+"></"+L+">":"<"+L+"/>";var y=[];if(f){if(y.push("<"+L),typeof m!="object")return y.push(">"+C(m,T)+"</"+L+">"),y.join("");m[T.attributesKey]&&y.push(o(m[T.attributesKey],T,N));var G=P(m,T,!0)||m[T.attributesKey]&&m[T.attributesKey]["xml:space"]==="preserve";if(G||("fullTagEmptyElementFn"in T?G=T.fullTagEmptyElementFn(f,m):G=T.fullTagEmptyElement),G)y.push(">");else return y.push("/>"),y.join("")}return y.push(b(m,T,N+1,!1)),e=m,i=f,f&&y.push((R?c(T,N,!1):"")+"</"+L+">"),y.join("")}function b(m,f,T,N){var R,L,y,G=[];for(L in m)if(m.hasOwnProperty(L))for(y=t(m[L])?m[L]:[m[L]],R=0;R<y.length;++R){switch(L){case f.declarationKey:G.push(a(y[R],f,T));break;case f.instructionKey:G.push((f.indentInstruction?c(f,T,N):"")+g(y[R],f,T));break;case f.attributesKey:case f.parentKey:break;case f.textKey:G.push((f.indentText?c(f,T,N):"")+C(y[R],f));break;case f.cdataKey:G.push((f.indentCdata?c(f,T,N):"")+E(y[R],f));break;case f.doctypeKey:G.push(c(f,T,N)+S(y[R],f));break;case f.commentKey:G.push(c(f,T,N)+v(y[R],f));break;default:G.push(c(f,T,N)+_(y[R],L,f,T,P(y[R],f)))}N=N&&!G.length}return G.join("")}return he=function(m,f){f=s(f);var T=[];return e=m,i="_root_",f.compact?T.push(b(m,f,0,!0)):(m[f.declarationKey]&&T.push(a(m[f.declarationKey],f,0)),m[f.elementsKey]&&m[f.elementsKey].length&&T.push(D(m[f.elementsKey],f,0,!T.length))),T.join("")},he}var ue,Ke;function xi(){if(Ke)return ue;Ke=1;var u=Ge();return ue=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)},ue}var fe,qe;function wi(){if(qe)return fe;qe=1;var u=Le(),t=Ei(),e=Ge(),i=xi();return fe={xml2js:u,xml2json:t,js2xml:e,json2xml:i},fe}var de=wi(),bi=Fe();const lt=class lt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{var g,v;if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let o={...s,...c,...lt.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"]),...lt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(o.properties){const E=lt.toArray(o.properties.property),S={};for(let C of E){const B=C._attributes;if(!B)continue;let F;switch(B.type){case"file":F=this.getImagePath(B.value);break;case"object":case"float":case"int":F=+B.value;break;case"bool":F=B.value=="true";break;case"class":F={...((g=this.transform(C))==null?void 0:g.properties)??{},_classname:B.propertytype};break;default:F=B.value}S[B.name]=F}o.properties=S}o.polygon&&(o.polygon=this.transform(o.polygon)),o.polyline&&(o.polyline=this.transform(o.polyline)),o.points&&(o=o.points.split(" ").map(E=>{const S=E.split(",");return{x:+S[0],y:+S[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||((v=o.objectgroup)==null?void 0:v.object);return a&&(o.objects=lt.toArray(a).map(E=>this.transform(E))),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:Se(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let 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"?lt.unpackTileBytes(bi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=de.xml2js(this.xml,{compact:!0}),e=de.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=v=>{const{objectgroup:E,group:S,layer:C,imagelayer:B}=v,F=D=>{D&<.toArray(D).forEach(P=>{if(this.layers.has(+P._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${P._attributes.id} already exists`);this.layers.set(+P._attributes.id,P)})};F(E),F(C),F(S),F(B),S&&s(S)};s(t.map);const c=(v,E=[])=>{var S;if(!v)return E;for(let C of v){const{name:B}=C;if(!["layer","group","imagelayer","objectgroup"].includes(B))continue;const F=(S=C.elements)==null?void 0:S.find(P=>P.name=="data");C.layer=this.layers.get(+C.attributes.id);const D={...this.transform(F)??{},...this.transform(C),...this.transform(C.layer),layers:c(C.elements),data:F?F.elements[0].text:void 0,type:B=="layer"?"tilelayer":B};delete D.elements,delete D.layer,D.data&&(D.data=lt.decode(D,D.width*D.height)),E.push(D)}return E},o=c(e.elements[0].elements),a=lt.toArray(i).map(v=>this.transform(v)),g={...this.transform(t.map),layers:o,tilesets:a};return delete g.layer,delete g.tileset,delete g.group,delete g.imagelayer,g}parseTileset(){const t=de.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:lt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=lt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};lt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},lt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let pe=lt;class me{constructor(t){this.properties={},this.properties=(t==null?void 0: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 Ti=2147483648,Ai=1073741824,vi=536870912,Ci=268435456;class kt extends me{constructor(t){super(t),this.obj=t,this._gid=t==null?void 0:t.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Ti)}get verticalFlip(){return!!(this._gid&Ai)}get diagonalFlip(){return!!(this._gid&vi)}get rotatedHex120(){return!!(this._gid&Ci)}get gid(){return kt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends kt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Si extends kt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t!=null&&t.gid&&(this.y-=this.height)}}class ge extends me{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=kt.getRealGid(t),c=ge.findTileSet(s,this.tilesets);if(!c)return;const o=c.getTile(s-c.firstgid);return o?new _e({...o.tile,gid:t,index:e,layerIndex:i}):new _e({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Si(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class Ii extends me{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new _e(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class wt{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=>wt.typeOfFile(a).isXml,c=a=>{if(!a)return i(null);if(s(a)){const g=new pe(a,t,this.basePath);if(e=="map"){const v=g.parseMap();return i(v)}else if(e=="tileset"){const v=g.parseTileset();return i(v)}}return i(JSON.parse(a))};if(wt.typeOfFile(t).isObject)return i(t);const{isHttp:o}=wt.typeOfFile(t);if(s(t))c(t);else if(o||wt.isBrowser()){let a=o?t:Se(this.basePath,t);wt.isBrowser()&&window.urlCache&&(a=window.urlCache[t]),fetch(a,{headers:{"Content-Type":"application/xml"}}).then(g=>g.text()).then(c).catch(g=>i(null,g))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&wt.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 g=[],v=()=>{E++,E==c.tilesets.length&&!a&&(c.tilesets=g,t(c))};let E=0;for(let S=0;S<c.tilesets.length;S++){const C=c.tilesets[S];if(!C.source||C.tiles||C.image||C.tile){g[S]=C,v();continue}i&&wt.typeOfFile(C.source).isPath&&(C.source=s(C.source)),this._parseFile(C.source,"tileset",(B,F)=>{if(F)return a=!0,t(null,F);g[S]={...B,firstgid:C.firstgid},v()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const vt={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:"linear",use32bitIndex:!1};var Mi=Object.defineProperty,Bi=(u,t,e)=>t in u?Mi(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Ct=(u,t,e)=>(Bi(u,typeof t!="symbol"?t+"":t,e),e);const Yt=class Vt extends U.Geometry{constructor(t){const e=new U.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:U.BufferUsage.VERTEX|U.BufferUsage.COPY_DST,shrinkToFit:!1}),i=Vt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:2*4},aFrame:{buffer:e,format:"float32x4",stride:i,offset:4*4},aAnim:{buffer:e,format:"float32x2",stride:i,offset:8*4},aTextureId:{buffer:e,format:"sint32",stride:i,offset:10*4},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:11*4},aAlpha:{buffer:e,format:"float32",stride:i,offset:12*4}}}),Ct(this,"lastTimeAccess",0),Ct(this,"vertSize",Vt.vertSize),Ct(this,"vertPerQuad",Vt.vertPerQuad),Ct(this,"stride",Vt.stride),Ct(this,"buf"),this.buf=e}};Ct(Yt,"vertSize",13),Ct(Yt,"vertPerQuad",4),Ct(Yt,"stride",Yt.vertSize*4);let Fi=Yt;var Ni=Object.defineProperty,Oi=(u,t,e)=>t in u?Ni(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,St=(u,t,e)=>(Oi(u,typeof t!="symbol"?t+"":t,e),e);class Ve{constructor(){St(this,"pipe_uniforms",new U.UniformGroup({u_proj_trans:{value:new U.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class je{constructor(t,e){St(this,"renderer"),St(this,"tileAnim",[0,0]),St(this,"ibLen",0),St(this,"indexBuffer",null),St(this,"shader"),St(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new U.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:U.BufferUsage.INDEX|U.BufferUsage.COPY_DST}),this.indexBuffer.destroy=U.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Fi(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=Di(t,vt.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)}}St(je,"extension",{type:[U.ExtensionType.WebGLPipes,U.ExtensionType.WebGPUPipes],name:"tilemap"});function Di(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 Pi=Object.defineProperty,Ri=(u,t,e)=>t in u?Pi(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Et=(u,t,e)=>(Ri(u,typeof t!="symbol"?t+"":t,e),e);class Ot{constructor(t){Et(this,"max_textures"),Et(this,"arr",[]),Et(this,"count",0),Et(this,"dirty",!1),Et(this,"dirty_gpu",!1),Et(this,"bind_group",null),Et(this,"bind_group_resources",{}),Et(this,"tex_sizes",null),Et(this,"null_color",new Float32Array([0,0,0,.5])),Et(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new U.Buffer({usage:U.BufferUsage.UNIFORM|U.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 U.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)||U.Texture.EMPTY.source;t[c++]=a.source,t[c++]=a.style}return this.bind_group||(this.bind_group=new U.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(`
|
|
10
|
+
Char: `+d.c),l=new Error(l),d.error=l,Q(d,"onerror",l),d}function ct(d){return d.sawRoot&&!d.closedRoot&&L(d,"Unclosed root tag"),d.state!==y.BEGIN&&d.state!==y.BEGIN_WHITESPACE&&d.state!==y.TEXT&&it(d,"Unexpected end"),z(d),d.c="",d.closed=!0,Q(d,"onend"),i.call(d,d.strict,d.opt),d}function L(d,l){if(typeof d!="object"||!(d instanceof i))throw new Error("bad call to strictFail");d.strict&&it(d,l)}function nt(d){d.strict||(d.tagName=d.tagName[d.looseCase]());var l=d.tags[d.tags.length-1]||d,I=d.tag={name:d.tagName,attributes:{}};d.opt.xmlns&&(I.ns=l.ns),d.attribList.length=0,G(d,"onopentagstart",I)}function $(d,l){var I=d.indexOf(":"),w=I<0?["",d]:d.split(":"),j=w[0],Z=w[1];return l&&d==="xmlns"&&(j="xmlns",Z=""),{prefix:j,local:Z}}function rt(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 l=$(d.attribName,!0),I=l.prefix,w=l.local;if(I==="xmlns")if(w==="xml"&&d.attribValue!==B)L(d,"xml: prefix must be bound to "+B+`
|
|
11
|
+
Actual: `+d.attribValue);else if(w==="xmlns"&&d.attribValue!==F)L(d,"xmlns: prefix must be bound to "+F+`
|
|
12
|
+
Actual: `+d.attribValue);else{var j=d.tag,Z=d.tags[d.tags.length-1]||d;j.ns===Z.ns&&(j.ns=Object.create(Z.ns)),j.ns[w]=d.attribValue}d.attribList.push([d.attribName,d.attribValue])}else d.tag.attributes[d.attribName]=d.attribValue,G(d,"onattribute",{name:d.attribName,value:d.attribValue});d.attribName=d.attribValue=""}function Y(d,l){if(d.opt.xmlns){var I=d.tag,w=$(d.tagName);I.prefix=w.prefix,I.local=w.local,I.uri=I.ns[w.prefix]||"",I.prefix&&!I.uri&&(L(d,"Unbound namespace prefix: "+JSON.stringify(d.tagName)),I.uri=w.prefix);var j=d.tags[d.tags.length-1]||d;I.ns&&j.ns!==I.ns&&Object.keys(I.ns).forEach(function(mt){G(d,"onopennamespace",{prefix:mt,uri:I.ns[mt]})});for(var Z=0,X=d.attribList.length;Z<X;Z++){var at=d.attribList[Z],ut=at[0],It=at[1],st=$(ut,!0),xt=st.prefix,Ee=st.local,qt=xt===""?"":I.ns[xt]||"",Bt={name:ut,value:It,prefix:xt,local:Ee,uri:qt};xt&&xt!=="xmlns"&&!qt&&(L(d,"Unbound namespace prefix: "+JSON.stringify(xt)),Bt.uri=xt),d.tag.attributes[ut]=Bt,G(d,"onattribute",Bt)}d.attribList.length=0}d.tag.isSelfClosing=!!l,d.sawRoot=!0,d.tags.push(d.tag),G(d,"onopentag",d.tag),l||(!d.noscript&&d.tagName.toLowerCase()==="script"?d.state=y.SCRIPT:d.state=y.TEXT,d.tag=null,d.tagName=""),d.attribName=d.attribValue="",d.attribList.length=0}function H(d){if(!d.tagName){L(d,"Weird empty close tag."),d.textNode+="</>",d.state=y.TEXT;return}if(d.script){if(d.tagName!=="script"){d.script+="</"+d.tagName+">",d.tagName="",d.state=y.SCRIPT;return}G(d,"onscript",d.script),d.script=""}var l=d.tags.length,I=d.tagName;d.strict||(I=I[d.looseCase]());for(var w=I;l--;){var j=d.tags[l];if(j.name!==w)L(d,"Unexpected close tag");else break}if(l<0){L(d,"Unmatched closing tag: "+d.tagName),d.textNode+="</"+d.tagName+">",d.state=y.TEXT;return}d.tagName=I;for(var Z=d.tags.length;Z-- >l;){var X=d.tag=d.tags.pop();d.tagName=d.tag.name,G(d,"onclosetag",d.tagName);var at={};for(var ut in X.ns)at[ut]=X.ns[ut];var It=d.tags[d.tags.length-1]||d;d.opt.xmlns&&X.ns!==It.ns&&Object.keys(X.ns).forEach(function(st){var xt=X.ns[st];G(d,"onclosenamespace",{prefix:st,uri:xt})})}l===0&&(d.closedRoot=!0),d.tagName=d.attribValue=d.attribName="",d.attribList.length=0,d.state=y.TEXT}function At(d){var l=d.entity,I=l.toLowerCase(),w,j="";return d.ENTITIES[l]?d.ENTITIES[l]:d.ENTITIES[I]?d.ENTITIES[I]:(l=I,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),w=parseInt(l,16),j=w.toString(16)):(l=l.slice(1),w=parseInt(l,10),j=w.toString(10))),l=l.replace(/^0+/,""),isNaN(w)||j.toLowerCase()!==l?(L(d,"Invalid character entity"),"&"+d.entity+";"):String.fromCodePoint(w))}function bt(d,l){l==="<"?(d.state=y.OPEN_WAKA,d.startTagPosition=d.position):f(l)||(L(d,"Non-whitespace before first tag."),d.textNode=l,d.state=y.TEXT)}function Vt(d,l){var I="";return l<d.length&&(I=d.charAt(l)),I}function Ht(d){var l=this;if(this.error)throw this.error;if(l.closed)return it(l,"Cannot write after close. Assign an onready handler.");if(d===null)return ct(l);typeof d=="object"&&(d=d.toString());for(var I=0,w="";w=Vt(d,I++),l.c=w,!!w;)switch(l.trackPosition&&(l.position++,w===`
|
|
13
|
+
`?(l.line++,l.column=0):l.column++),l.state){case y.BEGIN:if(l.state=y.BEGIN_WHITESPACE,w==="\uFEFF")continue;bt(l,w);continue;case y.BEGIN_WHITESPACE:bt(l,w);continue;case y.TEXT:if(l.sawRoot&&!l.closedRoot){for(var j=I-1;w&&w!=="<"&&w!=="&";)w=Vt(d,I++),w&&l.trackPosition&&(l.position++,w===`
|
|
14
|
+
`?(l.line++,l.column=0):l.column++);l.textNode+=d.substring(j,I-1)}w==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):(!f(w)&&(!l.sawRoot||l.closedRoot)&&L(l,"Text data outside of root node."),w==="&"?l.state=y.TEXT_ENTITY:l.textNode+=w);continue;case y.SCRIPT:w==="<"?l.state=y.SCRIPT_ENDING:l.script+=w;continue;case y.SCRIPT_ENDING:w==="/"?l.state=y.CLOSE_TAG:(l.script+="<"+w,l.state=y.SCRIPT);continue;case y.OPEN_WAKA:if(w==="!")l.state=y.SGML_DECL,l.sgmlDecl="";else if(!f(w))if(R(P,w))l.state=y.OPEN_TAG,l.tagName=w;else if(w==="/")l.state=y.CLOSE_TAG,l.tagName="";else if(w==="?")l.state=y.PROC_INST,l.procInstName=l.procInstBody="";else{if(L(l,"Unencoded <"),l.startTagPosition+1<l.position){var Z=l.position-l.startTagPosition;w=new Array(Z).join(" ")+w}l.textNode+="<"+w,l.state=y.TEXT}continue;case y.SGML_DECL:if(l.sgmlDecl+w==="--"){l.state=y.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=y.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+w,l.sgmlDecl=""):(l.sgmlDecl+w).toUpperCase()===C?(G(l,"onopencdata"),l.state=y.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+w).toUpperCase()===A?(l.state=y.DOCTYPE,(l.doctype||l.sawRoot)&&L(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):w===">"?(G(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=y.TEXT):(b(w)&&(l.state=y.SGML_DECL_QUOTED),l.sgmlDecl+=w);continue;case y.SGML_DECL_QUOTED:w===l.q&&(l.state=y.SGML_DECL,l.q=""),l.sgmlDecl+=w;continue;case y.DOCTYPE:w===">"?(l.state=y.TEXT,G(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=w,w==="["?l.state=y.DOCTYPE_DTD:b(w)&&(l.state=y.DOCTYPE_QUOTED,l.q=w));continue;case y.DOCTYPE_QUOTED:l.doctype+=w,w===l.q&&(l.q="",l.state=y.DOCTYPE);continue;case y.DOCTYPE_DTD:w==="]"?(l.doctype+=w,l.state=y.DOCTYPE):w==="<"?(l.state=y.OPEN_WAKA,l.startTagPosition=l.position):b(w)?(l.doctype+=w,l.state=y.DOCTYPE_DTD_QUOTED,l.q=w):l.doctype+=w;continue;case y.DOCTYPE_DTD_QUOTED:l.doctype+=w,w===l.q&&(l.state=y.DOCTYPE_DTD,l.q="");continue;case y.COMMENT:w==="-"?l.state=y.COMMENT_ENDING:l.comment+=w;continue;case y.COMMENT_ENDING:w==="-"?(l.state=y.COMMENT_ENDED,l.comment=lt(l.opt,l.comment),l.comment&&G(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+w,l.state=y.COMMENT);continue;case y.COMMENT_ENDED:w!==">"?(L(l,"Malformed comment"),l.comment+="--"+w,l.state=y.COMMENT):l.doctype&&l.doctype!==!0?l.state=y.DOCTYPE_DTD:l.state=y.TEXT;continue;case y.CDATA:w==="]"?l.state=y.CDATA_ENDING:l.cdata+=w;continue;case y.CDATA_ENDING:w==="]"?l.state=y.CDATA_ENDING_2:(l.cdata+="]"+w,l.state=y.CDATA);continue;case y.CDATA_ENDING_2:w===">"?(l.cdata&&G(l,"oncdata",l.cdata),G(l,"onclosecdata"),l.cdata="",l.state=y.TEXT):w==="]"?l.cdata+="]":(l.cdata+="]]"+w,l.state=y.CDATA);continue;case y.PROC_INST:w==="?"?l.state=y.PROC_INST_ENDING:f(w)?l.state=y.PROC_INST_BODY:l.procInstName+=w;continue;case y.PROC_INST_BODY:if(!l.procInstBody&&f(w))continue;w==="?"?l.state=y.PROC_INST_ENDING:l.procInstBody+=w;continue;case y.PROC_INST_ENDING:w===">"?(G(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=y.TEXT):(l.procInstBody+="?"+w,l.state=y.PROC_INST_BODY);continue;case y.OPEN_TAG:R(_,w)?l.tagName+=w:(nt(l),w===">"?Y(l):w==="/"?l.state=y.OPEN_TAG_SLASH:(f(w)||L(l,"Invalid character in tag name"),l.state=y.ATTRIB));continue;case y.OPEN_TAG_SLASH:w===">"?(Y(l,!0),H(l)):(L(l,"Forward-slash in opening tag not followed by >"),l.state=y.ATTRIB);continue;case y.ATTRIB:if(f(w))continue;w===">"?Y(l):w==="/"?l.state=y.OPEN_TAG_SLASH:R(P,w)?(l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case y.ATTRIB_NAME:w==="="?l.state=y.ATTRIB_VALUE:w===">"?(L(l,"Attribute without value"),l.attribValue=l.attribName,rt(l),Y(l)):f(w)?l.state=y.ATTRIB_NAME_SAW_WHITE:R(_,w)?l.attribName+=w:L(l,"Invalid attribute name");continue;case y.ATTRIB_NAME_SAW_WHITE:if(w==="=")l.state=y.ATTRIB_VALUE;else{if(f(w))continue;L(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",G(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?Y(l):R(P,w)?(l.attribName=w,l.state=y.ATTRIB_NAME):(L(l,"Invalid attribute name"),l.state=y.ATTRIB)}continue;case y.ATTRIB_VALUE:if(f(w))continue;b(w)?(l.q=w,l.state=y.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||it(l,"Unquoted attribute value"),l.state=y.ATTRIB_VALUE_UNQUOTED,l.attribValue=w);continue;case y.ATTRIB_VALUE_QUOTED:if(w!==l.q){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=w;continue}rt(l),l.q="",l.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:f(w)?l.state=y.ATTRIB:w===">"?Y(l):w==="/"?l.state=y.OPEN_TAG_SLASH:R(P,w)?(L(l,"No whitespace between attributes"),l.attribName=w,l.attribValue="",l.state=y.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case y.ATTRIB_VALUE_UNQUOTED:if(!O(w)){w==="&"?l.state=y.ATTRIB_VALUE_ENTITY_U:l.attribValue+=w;continue}rt(l),w===">"?Y(l):l.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(l.tagName)w===">"?H(l):R(_,w)?l.tagName+=w:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=y.SCRIPT):(f(w)||L(l,"Invalid tagname in closing tag"),l.state=y.CLOSE_TAG_SAW_WHITE);else{if(f(w))continue;U(P,w)?l.script?(l.script+="</"+w,l.state=y.SCRIPT):L(l,"Invalid tagname in closing tag."):l.tagName=w}continue;case y.CLOSE_TAG_SAW_WHITE:if(f(w))continue;w===">"?H(l):L(l,"Invalid characters in closing tag");continue;case y.TEXT_ENTITY:case y.ATTRIB_VALUE_ENTITY_Q:case y.ATTRIB_VALUE_ENTITY_U:var X,at;switch(l.state){case y.TEXT_ENTITY:X=y.TEXT,at="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:X=y.ATTRIB_VALUE_QUOTED,at="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:X=y.ATTRIB_VALUE_UNQUOTED,at="attribValue";break}if(w===";"){var ut=At(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(ut)?(l.entity="",l.state=X,l.write(ut)):(l[at]+=ut,l.entity="",l.state=X)}else R(l.entity.length?m:v,w)?l.entity+=w:(L(l,"Invalid character in entity name"),l[at]+="&"+l.entity+w,l.entity="",l.state=X);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var d=String.fromCharCode,l=Math.floor,I=function(){var w=16384,j=[],Z,X,at=-1,ut=arguments.length;if(!ut)return"";for(var It="";++at<ut;){var st=Number(arguments[at]);if(!isFinite(st)||st<0||st>1114111||l(st)!==st)throw RangeError("Invalid code point: "+st);st<=65535?j.push(st):(st-=65536,Z=(st>>10)+55296,X=st%1024+56320,j.push(Z,X)),(at+1===ut||j.length>w)&&(It+=d.apply(null,j),j.length=0)}return It};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:I,configurable:!0,writable:!0}):String.fromCodePoint=I}()})(h)}(ee)),ee}var se,Pe;function ne(){return Pe||(Pe=1,se={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),se}var ae,Re;function oe(){if(Re)return ae;Re=1;var h=ne().isArray;return ae={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!h(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},ae}var le,Ue;function ke(){if(Ue)return le;Ue=1;var h=xi(),t=oe(),e=ne().isArray,i,s;function c(_){return i=t.copyOptions(_),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function a(_){var v=Number(_);if(!isNaN(v))return v;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,v){var m;if(i.compact){if(!s[i[_+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[_+"Key"])!==-1:i.alwaysArray)&&(s[i[_+"Key"]]=[]),s[i[_+"Key"]]&&!e(s[i[_+"Key"]])&&(s[i[_+"Key"]]=[s[i[_+"Key"]]]),_+"Fn"in i&&typeof v=="string"&&(v=i[_+"Fn"](v,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in v)if(v.hasOwnProperty(m))if("instructionFn"in i)v[m]=i.instructionFn(v[m],m,s);else{var f=v[m];delete v[m],v[i.instructionNameFn(m,f,s)]=f}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(v):s[i[_+"Key"]]=v}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in v)if(v.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,v,s):m,i.instructionHasAttributes?(b[i.attributesKey]=v[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(v[m]=i.instructionFn(v[m],m,s)),b[i.instructionKey]=v[m])}else _+"Fn"in i&&(v=i[_+"Fn"](v,s)),b[i[_+"Key"]]=v;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function g(_){if("attributesFn"in i&&_&&(_=i.attributesFn(_,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&_){var v;for(v in _)if(_.hasOwnProperty(v)&&(i.trim&&(_[v]=_[v].trim()),i.nativeTypeAttributes&&(_[v]=a(_[v])),"attributeValueFn"in i&&(_[v]=i.attributeValueFn(_[v],v,s)),"attributeNameFn"in i)){var m=_[v];delete _[v],_[i.attributeNameFn(v,_[v],s)]=m}}return _}function S(_){var v={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=m.exec(_.body))!==null;)v[f[1]]=f[2]||f[3]||f[4];v=g(v)}if(_.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(v).length&&(s[i.declarationKey][i.attributesKey]=v),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(_.body=_.body.trim());var b={};i.instructionHasAttributes&&Object.keys(v).length?(b[_.name]={},b[_.name][i.attributesKey]=v):b[_.name]=_.body,o("instruction",b)}}function x(_,v){var m;if(typeof _=="object"&&(v=_.attributes,_=_.name),v=g(v),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&v&&Object.keys(v).length){m[i.attributesKey]={};var f;for(f in v)v.hasOwnProperty(f)&&(m[i.attributesKey][f]=v[f])}!(_ in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(_)!==-1:i.alwaysArray)&&(s[_]=[]),s[_]&&!e(s[_])&&(s[_]=[s[_]]),e(s[_])?s[_].push(m):s[_]=m}else s[i.elementsKey]||(s[i.elementsKey]=[]),m={},m[i.typeKey]="element",m[i.nameKey]=_,!i.ignoreAttributes&&v&&Object.keys(v).length&&(m[i.attributesKey]=v),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function C(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=a(_)),i.sanitize&&(_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),o("text",_))}function A(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function B(_){var v=s[i.parentKey];i.addParent||delete s[i.parentKey],s=v}function F(_){i.ignoreCdata||(i.trim&&(_=_.trim()),o("cdata",_))}function N(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),o("doctype",_))}function P(_){_.note=_}return le=function(_,v){var m=h.parser(!0,{}),f={};if(s=f,i=c(v),m.opt={strictEntities:!0},m.onopentag=x,m.ontext=C,m.oncomment=A,m.onclosetag=B,m.onerror=P,m.oncdata=F,m.ondoctype=N,m.onprocessinginstruction=S,m.write(_).close(),f[i.elementsKey]){var b=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=b,delete f.text}return f},le}var ce,Le;function Ei(){if(Le)return ce;Le=1;var h=oe(),t=ke();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return ce=function(i,s){var c,a,o,g;return c=e(s),a=t(i,c),g="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(a,function(S,x){return S===g?"_":x},c.spaces):o=JSON.stringify(a,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var ue,Ye;function Ge(){if(Ye)return ue;Ye=1;var h=oe(),t=ne().isArray,e,i;function s(m){var f=h.copyOptions(m);return h.ensureFlagExists("ignoreDeclaration",f),h.ensureFlagExists("ignoreInstruction",f),h.ensureFlagExists("ignoreAttributes",f),h.ensureFlagExists("ignoreText",f),h.ensureFlagExists("ignoreComment",f),h.ensureFlagExists("ignoreCdata",f),h.ensureFlagExists("ignoreDoctype",f),h.ensureFlagExists("compact",f),h.ensureFlagExists("indentText",f),h.ensureFlagExists("indentCdata",f),h.ensureFlagExists("indentAttributes",f),h.ensureFlagExists("indentInstruction",f),h.ensureFlagExists("fullTagEmptyElement",f),h.ensureFlagExists("noQuotesForNativeAttributes",f),h.ensureSpacesExists(f),typeof f.spaces=="number"&&(f.spaces=Array(f.spaces+1).join(" ")),h.ensureKeyExists("declaration",f),h.ensureKeyExists("instruction",f),h.ensureKeyExists("attributes",f),h.ensureKeyExists("text",f),h.ensureKeyExists("comment",f),h.ensureKeyExists("cdata",f),h.ensureKeyExists("doctype",f),h.ensureKeyExists("type",f),h.ensureKeyExists("name",f),h.ensureKeyExists("elements",f),h.checkFnExists("doctype",f),h.checkFnExists("instruction",f),h.checkFnExists("cdata",f),h.checkFnExists("comment",f),h.checkFnExists("text",f),h.checkFnExists("instructionName",f),h.checkFnExists("elementName",f),h.checkFnExists("attributeName",f),h.checkFnExists("attributeValue",f),h.checkFnExists("attributes",f),h.checkFnExists("fullTagEmptyElement",f),f}function c(m,f,b){return(!b&&m.spaces?`
|
|
15
|
+
`:"")+Array(f+1).join(m.spaces)}function a(m,f,b){if(f.ignoreAttributes)return"";"attributesFn"in f&&(m=f.attributesFn(m,i,e));var O,R,U,y,V=[];for(O in m)m.hasOwnProperty(O)&&m[O]!==null&&m[O]!==void 0&&(y=f.noQuotesForNativeAttributes&&typeof m[O]!="string"?"":'"',R=""+m[O],R=R.replace(/"/g,"""),U="attributeNameFn"in f?f.attributeNameFn(O,R,i,e):O,V.push(f.spaces&&f.indentAttributes?c(f,b+1,!1):" "),V.push(U+"="+y+("attributeValueFn"in f?f.attributeValueFn(R,O,i,e):R)+y));return m&&Object.keys(m).length&&f.spaces&&f.indentAttributes&&V.push(c(f,b,!1)),V.join("")}function o(m,f,b){return e=m,i="xml",f.ignoreDeclaration?"":"<?xml"+a(m[f.attributesKey],f,b)+"?>"}function g(m,f,b){if(f.ignoreInstruction)return"";var O;for(O in m)if(m.hasOwnProperty(O))break;var R="instructionNameFn"in f?f.instructionNameFn(O,m[O],i,e):O;if(typeof m[O]=="object")return e=m,i=R,"<?"+R+a(m[O][f.attributesKey],f,b)+"?>";var U=m[O]?m[O]:"";return"instructionFn"in f&&(U=f.instructionFn(U,O,i,e)),"<?"+R+(U?" "+U:"")+"?>"}function S(m,f){return f.ignoreComment?"":"<!--"+("commentFn"in f?f.commentFn(m,i,e):m)+"-->"}function x(m,f){return f.ignoreCdata?"":"<![CDATA["+("cdataFn"in f?f.cdataFn(m,i,e):m.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(m,f){return f.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in f?f.doctypeFn(m,i,e):m)+">"}function A(m,f){return f.ignoreText?"":(m=""+m,m=m.replace(/&/g,"&"),m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in f?f.textFn(m,i,e):m)}function B(m,f){var b;if(m.elements&&m.elements.length)for(b=0;b<m.elements.length;++b)switch(m.elements[b][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(m,f,b){e=m,i=m.name;var O=[],R="elementNameFn"in f?f.elementNameFn(m.name,m):m.name;O.push("<"+R),m[f.attributesKey]&&O.push(a(m[f.attributesKey],f,b));var U=m[f.elementsKey]&&m[f.elementsKey].length||m[f.attributesKey]&&m[f.attributesKey]["xml:space"]==="preserve";return U||("fullTagEmptyElementFn"in f?U=f.fullTagEmptyElementFn(m.name,m):U=f.fullTagEmptyElement),U?(O.push(">"),m[f.elementsKey]&&m[f.elementsKey].length&&(O.push(N(m[f.elementsKey],f,b+1)),e=m,i=m.name),O.push(f.spaces&&B(m,f)?`
|
|
16
|
+
`+Array(b+1).join(f.spaces):""),O.push("</"+R+">")):O.push("/>"),O.join("")}function N(m,f,b,O){return m.reduce(function(R,U){var y=c(f,b,O&&!R);switch(U.type){case"element":return R+y+F(U,f,b);case"comment":return R+y+S(U[f.commentKey],f);case"doctype":return R+y+C(U[f.doctypeKey],f);case"cdata":return R+(f.indentCdata?y:"")+x(U[f.cdataKey],f);case"text":return R+(f.indentText?y:"")+A(U[f.textKey],f);case"instruction":var V={};return V[U[f.nameKey]]=U[f.attributesKey]?U:U[f.instructionKey],R+(f.indentInstruction?y:"")+g(V,f,b)}},"")}function P(m,f,b){var O;for(O in m)if(m.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,R){e=m,i=f;var U="elementNameFn"in b?b.elementNameFn(f,m):f;if(typeof m>"u"||m===null||m==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(f,m)||b.fullTagEmptyElement?"<"+U+"></"+U+">":"<"+U+"/>";var y=[];if(f){if(y.push("<"+U),typeof m!="object")return y.push(">"+A(m,b)+"</"+U+">"),y.join("");m[b.attributesKey]&&y.push(a(m[b.attributesKey],b,O));var V=P(m,b,!0)||m[b.attributesKey]&&m[b.attributesKey]["xml:space"]==="preserve";if(V||("fullTagEmptyElementFn"in b?V=b.fullTagEmptyElementFn(f,m):V=b.fullTagEmptyElement),V)y.push(">");else return y.push("/>"),y.join("")}return y.push(v(m,b,O+1,!1)),e=m,i=f,f&&y.push((R?c(b,O,!1):"")+"</"+U+">"),y.join("")}function v(m,f,b,O){var R,U,y,V=[];for(U in m)if(m.hasOwnProperty(U))for(y=t(m[U])?m[U]:[m[U]],R=0;R<y.length;++R){switch(U){case f.declarationKey:V.push(o(y[R],f,b));break;case f.instructionKey:V.push((f.indentInstruction?c(f,b,O):"")+g(y[R],f,b));break;case f.attributesKey:case f.parentKey:break;case f.textKey:V.push((f.indentText?c(f,b,O):"")+A(y[R],f));break;case f.cdataKey:V.push((f.indentCdata?c(f,b,O):"")+x(y[R],f));break;case f.doctypeKey:V.push(c(f,b,O)+C(y[R],f));break;case f.commentKey:V.push(c(f,b,O)+S(y[R],f));break;default:V.push(c(f,b,O)+_(y[R],U,f,b,P(y[R],f)))}O=O&&!V.length}return V.join("")}return ue=function(m,f){f=s(f);var b=[];return e=m,i="_root_",f.compact?b.push(v(m,f,0,!0)):(m[f.declarationKey]&&b.push(o(m[f.declarationKey],f,0)),m[f.elementsKey]&&m[f.elementsKey].length&&b.push(N(m[f.elementsKey],f,0,!b.length))),b.join("")},ue}var he,Ve;function wi(){if(Ve)return he;Ve=1;var h=Ge();return he=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return h(i,e)},he}var fe,qe;function vi(){if(qe)return fe;qe=1;var h=ke(),t=Ei(),e=Ge(),i=wi();return fe={xml2js:h,xml2json:t,js2xml:e,json2xml:i},fe}var de=vi(),bi=Fe();const dt=class dt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{var g,S;if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let a={...s,...c,...dt.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"]),...dt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(a.properties){const x=dt.toArray(a.properties.property),C={};for(let A of x){const B=A._attributes;if(!B)continue;let F;switch(B.type){case"file":F=this.getImagePath(B.value);break;case"object":case"float":case"int":F=+B.value;break;case"bool":F=B.value=="true";break;case"class":F={...((g=this.transform(A))==null?void 0:g.properties)??{},_classname:B.propertytype};break;default:F=B.value}C[B.name]=F}a.properties=C}a.polygon&&(a.polygon=this.transform(a.polygon)),a.polyline&&(a.polyline=this.transform(a.polyline)),a.points&&(a=a.points.split(" ").map(x=>{const C=x.split(",");return{x:+C[0],y:+C[1]}})),a.point&&(a.point=!0),a.ellipse&&(a.ellipse=!0),a.text&&(a.text={text:a.text._text,...this.transform(a.text)},delete a.text._text),a.image&&(a.image=this.transform(a.image)),a.source&&(this.isTilesetSource(a)||(a.source=this.getImagePath(a.source)));const o=a.object||((S=a.objectgroup)==null?void 0:S.object);return o&&(a.objects=dt.toArray(o).map(x=>this.transform(x))),delete a._attributes,delete a.attributes,delete a.object,delete a.objectgroup,a}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:Ce(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let a=0;a<i;a+=4)c[s]=t.readUInt32LE(a),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?dt.unpackTileBytes(bi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=de.xml2js(this.xml,{compact:!0}),e=de.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=S=>{const{objectgroup:x,group:C,layer:A,imagelayer:B}=S,F=N=>{N&&dt.toArray(N).forEach(P=>{if(this.layers.has(+P._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${P._attributes.id} already exists`);this.layers.set(+P._attributes.id,P)})};F(x),F(A),F(C),F(B),C&&s(C)};s(t.map);const c=(S,x=[])=>{var C;if(!S)return x;for(let A of S){const{name:B}=A;if(!["layer","group","imagelayer","objectgroup"].includes(B))continue;const F=(C=A.elements)==null?void 0:C.find(P=>P.name=="data");A.layer=this.layers.get(+A.attributes.id);const N={...this.transform(F)??{},...this.transform(A),...this.transform(A.layer),layers:c(A.elements),data:F?F.elements[0].text:void 0,type:B=="layer"?"tilelayer":B};delete N.elements,delete N.layer,N.data&&(N.data=dt.decode(N,N.width*N.height)),x.push(N)}return x},a=c(e.elements[0].elements),o=dt.toArray(i).map(S=>this.transform(S)),g={...this.transform(t.map),layers:a,tilesets:o};return delete g.layer,delete g.tileset,delete g.group,delete g.imagelayer,g}parseTileset(){const t=de.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:dt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=dt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};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 pe=dt;class me{constructor(t){this.properties={},this.properties=(t==null?void 0: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 Ti=2147483648,Ai=1073741824,Si=536870912,Ci=268435456;class Lt extends me{constructor(t){super(t),this.obj=t,this._gid=t==null?void 0:t.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Ti)}get verticalFlip(){return!!(this._gid&Ai)}get diagonalFlip(){return!!(this._gid&Si)}get rotatedHex120(){return!!(this._gid&Ci)}get gid(){return Lt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends Lt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Mi extends Lt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t!=null&&t.gid&&(this.y-=this.height)}}class ye extends me{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=Lt.getRealGid(t),c=ye.findTileSet(s,this.tilesets);if(!c)return;const a=c.getTile(s-c.firstgid);return a?new _e({...a.tile,gid:t,index:e,layerIndex:i}):new _e({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Mi(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 Ii extends me{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new _e(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class Tt{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=o=>Tt.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const g=new pe(o,t,this.basePath);if(e=="map"){const S=g.parseMap();return i(S)}else if(e=="tileset"){const S=g.parseTileset();return i(S)}}return i(JSON.parse(o))};if(Tt.typeOfFile(t).isObject)return i(t);const{isHttp:a}=Tt.typeOfFile(t);if(s(t))c(t);else if(a||Tt.isBrowser()){let o=a?t:Ce(this.basePath,t);Tt.isBrowser()&&window.urlCache&&(o=window.urlCache[t]),fetch(o,{headers:{"Content-Type":"application/xml"}}).then(g=>g.text()).then(c).catch(g=>i(null,g))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&Tt.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,a)=>{let o=!1;if(a)return t(null,a);if(c.tilesets){const g=[],S=()=>{x++,x==c.tilesets.length&&!o&&(c.tilesets=g,t(c))};let x=0;for(let C=0;C<c.tilesets.length;C++){const A=c.tilesets[C];if(!A.source||A.tiles||A.image||A.tile){g[C]=A,S();continue}i&&Tt.typeOfFile(A.source).isPath&&(A.source=s(A.source)),this._parseFile(A.source,"tileset",(B,F)=>{if(F)return o=!0,t(null,F);g[C]={...B,firstgid:A.firstgid},S()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const St={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:"linear",use32bitIndex:!1};var Bi=Object.defineProperty,Fi=(h,t,e)=>t in h?Bi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ct=(h,t,e)=>(Fi(h,typeof t!="symbol"?t+"":t,e),e);const Yt=class Kt extends k.Geometry{constructor(t){const e=new k.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:k.BufferUsage.VERTEX|k.BufferUsage.COPY_DST,shrinkToFit:!1}),i=Kt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:2*4},aFrame:{buffer:e,format:"float32x4",stride:i,offset:4*4},aAnim:{buffer:e,format:"float32x2",stride:i,offset:8*4},aTextureId:{buffer:e,format:"sint32",stride:i,offset:10*4},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:11*4},aAlpha:{buffer:e,format:"float32",stride:i,offset:12*4}}}),Ct(this,"lastTimeAccess",0),Ct(this,"vertSize",Kt.vertSize),Ct(this,"vertPerQuad",Kt.vertPerQuad),Ct(this,"stride",Kt.stride),Ct(this,"buf"),this.buf=e}};Ct(Yt,"vertSize",13),Ct(Yt,"vertPerQuad",4),Ct(Yt,"stride",Yt.vertSize*4);let Di=Yt;var Oi=Object.defineProperty,Ni=(h,t,e)=>t in h?Oi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Mt=(h,t,e)=>(Ni(h,typeof t!="symbol"?t+"":t,e),e);class Ke{constructor(){Mt(this,"pipe_uniforms",new k.UniformGroup({u_proj_trans:{value:new k.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class ze{constructor(t,e){Mt(this,"renderer"),Mt(this,"tileAnim",[0,0]),Mt(this,"ibLen",0),Mt(this,"indexBuffer",null),Mt(this,"shader"),Mt(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new k.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:k.BufferUsage.INDEX|k.BufferUsage.COPY_DST}),this.indexBuffer.destroy=k.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Di(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=Pi(t,St.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:a}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),a[0]=c[0],a[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Mt(ze,"extension",{type:[k.ExtensionType.WebGLPipes,k.ExtensionType.WebGPUPipes],name:"tilemap"});function Pi(h,t){const e=h*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var Ri=Object.defineProperty,Ui=(h,t,e)=>t in h?Ri(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vt=(h,t,e)=>(Ui(h,typeof t!="symbol"?t+"":t,e),e);class Nt{constructor(t){vt(this,"max_textures"),vt(this,"arr",[]),vt(this,"count",0),vt(this,"dirty",!1),vt(this,"dirty_gpu",!1),vt(this,"bind_group",null),vt(this,"bind_group_resources",{}),vt(this,"tex_sizes",null),vt(this,"null_color",new Float32Array([0,0,0,.5])),vt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new k.Buffer({usage:k.BufferUsage.UNIFORM|k.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let a=0;a<i;a++){const o=e[a];o&&(t[a*4]=o.pixelWidth,t[a*4+1]=o.pixelHeight,t[a*4+2]=1/o.pixelWidth,t[a*4+3]=1/o.pixelHeight)}t[s*4]=c[0],t[s*4+1]=c[1],t[s*4+2]=c[2],t[s*4+3]=c[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:t,max_textures:e,arr:i,count:s}=this;let c=0;t[c++]=new k.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let a=0;a<e;a++){const o=(a<s?i[a]:null)||k.Texture.EMPTY.source;t[c++]=o.source,t[c++]=o.style}return this.bind_group||(this.bind_group=new k.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(`
|
|
17
17
|
`)}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(`
|
|
18
|
-
`)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var
|
|
18
|
+
`)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var ki=Object.defineProperty,Li=(h,t,e)=>t in h?ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ge=(h,t,e)=>(Li(h,typeof t!="symbol"?t+"":t,e),e);const Yi=`
|
|
19
19
|
in vec2 aVertexPosition;
|
|
20
20
|
in vec2 aTextureCoord;
|
|
21
21
|
in vec4 aFrame;
|
|
@@ -46,7 +46,7 @@ void main(void)
|
|
|
46
46
|
vTextureId = aTextureId;
|
|
47
47
|
vAlpha = aAlpha;
|
|
48
48
|
}
|
|
49
|
-
`,
|
|
49
|
+
`,Gi=`
|
|
50
50
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
51
51
|
precision highp float;
|
|
52
52
|
#else
|
|
@@ -66,7 +66,7 @@ void main(void)
|
|
|
66
66
|
vec4 color = sampleMultiTexture(textureId, textureCoord);
|
|
67
67
|
finalColor = color * vAlpha;
|
|
68
68
|
}
|
|
69
|
-
`;class
|
|
69
|
+
`;class je extends Ke{constructor(){super(...arguments),ge(this,"_shader",null),ge(this,"max_textures",St.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),a=s.resources.texture_uniforms;a.uniforms.u_texture_size!==c.tex_sizes&&(a.uniforms.u_texture_size=c.tex_sizes,a.update());for(let o=0;o<c.length;o++)i.texture.bind(c.arr[o],o);i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new k.Shader({glProgram:k.GlProgram.from({vertex:Yi,fragment:Gi.replace("//include_textures",Nt.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new k.UniformGroup(Nt.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}ge(je,"extension",{type:[k.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Vi=Object.defineProperty,qi=(h,t,e)=>t in h?Vi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Xt=(h,t,e)=>(qi(h,typeof t!="symbol"?t+"":t,e),e);const Ki=`
|
|
70
70
|
struct GlobalUniforms {
|
|
71
71
|
uProjectionMatrix:mat3x3f,
|
|
72
72
|
uWorldTransformMatrix:mat3x3f,
|
|
@@ -112,7 +112,7 @@ fn mainVert(
|
|
|
112
112
|
|
|
113
113
|
return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
|
|
114
114
|
};
|
|
115
|
-
`,
|
|
115
|
+
`,zi=`
|
|
116
116
|
//include_textures
|
|
117
117
|
|
|
118
118
|
@fragment
|
|
@@ -129,94 +129,399 @@ fn mainFrag(
|
|
|
129
129
|
var color = sampleMultiTexture(vTextureId, uv, dx, dy);
|
|
130
130
|
return color * vAlpha;
|
|
131
131
|
};
|
|
132
|
-
`;class $e extends Ve{constructor(){super(...arguments),Wt(this,"_shader",null),Wt(this,"max_textures",vt.TEXTURES_PER_TILEMAP),Wt(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 U.Shader({gpuProgram:U.GpuProgram.from({vertex:{source:qi,entryPoint:"mainVert"},fragment:{source:Vi.replace("//include_textures",Ot.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new U.BindGroup({ut:this.pipe_uniforms})}}Wt($e,"extension",{type:[U.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var ji=Object.defineProperty,Xi=(u,t,e)=>t in u?ji(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,et=(u,t,e)=>(Xi(u,typeof t!="symbol"?t+"":t,e),e),We=(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))(We||{});const pt=Object.keys(We).length/2;class ze extends U.ViewContainer{constructor(t){super({}),et(this,"shadowColor",new Float32Array([0,0,0,.5])),et(this,"state",U.State.for2d()),et(this,"is_valid",!1),et(this,"renderPipeId","tilemap"),et(this,"canBundle",!0),et(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),et(this,"tileAnim",null),et(this,"rects_count",0),et(this,"compositeParent",!1),et(this,"tileset",new Ot(vt.TEXTURES_PER_TILEMAP)),et(this,"tilemapBounds",new U.Bounds),et(this,"hasAnimatedTile",!1),et(this,"pointsBuf",[]),et(this,"batched"),et(this,"vbId",0),et(this,"vb",null),et(this,"vbBuffer",null),et(this,"vbArray",null),et(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=[]){var i,s;let e=this.tileset;if(t instanceof Ot)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof U.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Ot(vt.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let c=!0;for(let o=0;o<t.length;o++)if(((i=t[o])==null?void 0:i.source)!==e.arr[o]){c=!1;break}if(c)return this}e=this.tileset=new Ot(vt.TEXTURES_PER_TILEMAP);for(let c=0;c<t.length;c++)e.push((s=t[c])==null?void 0:s.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=U.Texture.from(t):f=t;const T=this.tileset;for(let N=0;N<T.count;N++)if(T.arr[N]===f.source){o=N;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:g=0,v=0,tileWidth:E=c.width,tileHeight:S=c.height,animX:C=0,animY:B=0,rotate:F=0,animCountX:D=1024,animCountY:P=1024,animDivisor:_=1,alpha:b=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||C>0||B>0,m.push(g),m.push(v),m.push(e),m.push(i),m.push(E),m.push(S),m.push(F),m.push(C|0),m.push(B|0),m.push(o),m.push(D),m.push(P),m.push(_),m.push(b),this.tilemapBounds.addFrame(e,i,e+E,i+S),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(pt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(pt-7)]=t,i[i.length-(pt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(pt-8)]=t,i[i.length-(pt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(pt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(pt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/pt;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 C=s.stride;for(;C<a;)C*=2;this.vbBuffer=new ArrayBuffer(C),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const g=this.vbArray,v=this.vbInts;let E=0,S=0;for(let C=0;C<e.length;C+=pt){this.compositeParent&&(S=e[C+9]);const F=e[C+2],D=e[C+3],P=e[C+4],_=e[C+5],b=e[C+0],m=e[C+1];let f=e[C+6];const T=e[C+7],N=e[C+8],R=e[C+10]||1024,L=e[C+11]||1024,y=T+R*2048,G=N+L*2048,rt=e[C+12],K=e[C+13];let it,ft,at,mt,q,Dt,bt,Tt;if(f===0)it=b,ft=m,at=b+P,mt=m,q=b+P,Dt=m+_,bt=b,Tt=m+_;else{let V=P/2,W=_/2;f%4!==0&&(V=_/2,W=P/2);const At=b+V,xt=m+W;f=U.groupD8.add(f,U.groupD8.NW),it=At+V*U.groupD8.uX(f),ft=xt+W*U.groupD8.uY(f),f=U.groupD8.add(f,2),at=At+V*U.groupD8.uX(f),mt=xt+W*U.groupD8.uY(f),f=U.groupD8.add(f,2),q=At+V*U.groupD8.uX(f),Dt=xt+W*U.groupD8.uY(f),f=U.groupD8.add(f,2),bt=At+V*U.groupD8.uX(f),Tt=xt+W*U.groupD8.uY(f)}g[E++]=F,g[E++]=D,g[E++]=it,g[E++]=ft,g[E++]=b+.5,g[E++]=m+.5,g[E++]=b+P-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=G,v[E++]=S,g[E++]=rt,g[E++]=K,g[E++]=F+P,g[E++]=D,g[E++]=at,g[E++]=mt,g[E++]=b+.5,g[E++]=m+.5,g[E++]=b+P-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=G,v[E++]=S,g[E++]=rt,g[E++]=K,g[E++]=F+P,g[E++]=D+_,g[E++]=q,g[E++]=Dt,g[E++]=b+.5,g[E++]=m+.5,g[E++]=b+P-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=G,v[E++]=S,g[E++]=rt,g[E++]=K,g[E++]=F,g[E++]=D+_,g[E++]=bt,g[E++]=Tt,g[E++]=b+.5,g[E++]=m+.5,g[E++]=b+P-.5,g[E++]=m+_-.5,g[E++]=y,g[E++]=G,v[E++]=S,g[E++]=rt,g[E++]=K}o.data=g}isModified(t){return!!(this.rects_count*pt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/pt}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,g=0,v=0,E=0,S=1024,C=1024,B=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:o,tileHeight:a,animX:g,animY:v,rotate:E,animCountX:S,animCountY:C,animDivisor:B,alpha:F})}}var $i=Object.defineProperty,Wi=(u,t,e)=>t in u?$i(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Gt=(u,t,e)=>(Wi(u,typeof t!="symbol"?t+"":t,e),e);class zi extends U.Container{constructor(t){super(),Gt(this,"texturesPerTilemap"),Gt(this,"tileAnim",null),Gt(this,"lastModifiedTilemap",null),Gt(this,"modificationMarker",0),Gt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=vt.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 ze(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 g=0;if(c=o[a],c)g=t%this.texturesPerTilemap;else{if(c=o[0],!c)return this;g=0}c.tile(g,e,i,s)}else{typeof t=="string"&&(t=U.Texture.from(t));for(let a=0;a<o.length;a++){const g=o[a],v=g.getTileset().arr;for(let E=0;E<v.length;E++)if(v[E]===t.source){c=g;break}if(c)break}if(!c){for(let a=o.length-1;a>=0;a--){const g=o[a];if(g.getTileset().count<this.texturesPerTilemap){c=g,g.getTileset().push(t.source);break}}c||(c=new ze(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,g,v){return this.tile(t,e,i,{animX:s,animY:c,animCountX:o,animCountY:a,animDivisor:g,alpha:v})}addRect(t,e,i,s,c,o,a,g,v,E,S,C){const B=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[B]&&this.children[B].getTileset().count>0?(this.lastModifiedTilemap=this.children[B],this.lastModifiedTilemap.addRect(F,e,i,s,c,o,a,g,v,E,S,C)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}U.extensions.add(je),U.extensions.add(Xe),U.extensions.add($e);class zt extends U.AnimatedSprite{constructor(t,e){super(zt.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=zt.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=U.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(U.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(U.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(U.groupD8.MAIN_DIAGONAL):i(U.groupD8.REVERSE_DIAGONAL))}}vt.use32bitIndex=!0;class Ee extends O.DisplayObject(zi){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:g}=this._layer;s&&(t=Math.floor(t/o),e=Math.floor(e/a));const v=t+e*g,E=this._layer.getTileByIndex(v);if(!E||E&&E.gid==0)return;const S=Ee.findTileSet(E.gid,this.tileSets);if(!S)return;const C=new zt(E,S);if(C.x=t*o,C.y=e*a+(a-C.texture.height),C._x=t,C._y=e,S.tileoffset&&(C.x+=S.tileoffset.x??0,C.y+=S.tileoffset.y??0),!(c&&!c(C)))return C}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new ge({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}O.registerComponent("CompositeTileLayer",Ee);function Hi(u){return O.createComponent("CompositeTileLayer",u)}class Qi extends Ii{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await U.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 U.Texture({source:e.source,frame:new U.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Ji(u,t,e){var s,c;const i=[];for(const o of u){if(o.type!==Rt.Tile){i.push(o);continue}const a=new Map;let g;if(Array.isArray(o.data))g=o.data.map(E=>typeof E=="number"?E:parseInt(String(E),10));else{i.push(o);continue}for(let E=0;E<g.length;E++){const S=g[E];if(S===0)continue;let C;for(let P=t.length-1;P>=0;P--)if(t[P].firstgid&&t[P].firstgid<=S){C=t[P];break}if(!C){a.has(0)||a.set(0,new Array(g.length).fill(0)),a.get(0)[E]=S;continue}const B=S-C.firstgid,F=(c=(s=C.tileset.tiles)==null?void 0:s[B])==null?void 0:c.properties,D=(F==null?void 0:F.z)??0;F==null||F.z,a.has(D)||a.set(D,new Array(g.length).fill(0)),a.get(D)[E]=S}const v=Array.from(a.keys()).sort((E,S)=>E-S);for(const E of v){const S=a.get(E);if(S.some(C=>C!==0)){const C={...o,name:`${o.name}_z${E}`,data:S,properties:{...o.properties,z:E}};i.push(C)}}}return i.sort((o,a)=>{var E,S;const g=((E=o.properties)==null?void 0:E.z)??.5,v=((S=a.properties)==null?void 0:S.z)??.5;return g-v}),i}function Zi(u){const{map:t,basePath:e,createLayersPerTilesZ:i}=O.useProps(u,{createLayersPerTilesZ:!1,basePath:""}),s=O.signal([]),c=u.objectLayer;let o=[],a={};const g=async(E,S="")=>typeof E!="string"?E:await new wt(E,{basePath:S}).parseFilePromise({getOnlyBasename:!1});O.effect(async()=>{const E=t();if(E){a=await g(E,e()),o=[];for(let C of a.tilesets)C.tile&&(C.tiles=C.tile),C.tiles||(C.tiles=[]),o.push(await new Qi(C).load(C.image.source));let S=a.layers;i()&&(S=Ji(a.layers,o)),s.set(S)}});const v=(E,S={})=>O.h(O.Container,S,O.loop(E,C=>{switch(C.type){case Rt.Tile:return O.h(Hi,{tilewidth:a.tilewidth,tileheight:a.tileheight,width:a.width,height:a.height,...C,tilesets:o});case Rt.Image:const{width:B,height:F,source:D}=C.image;return O.h(O.TilingSprite,{image:D,...C,width:C.repeatx?C.width*C.tilewidth:B,height:C.repeaty?C.height*C.tileheight:F});case Rt.Group:return v(O.signal(C.layers),C);case Rt.ObjectGroup:const P=c==null?void 0:c(C);return O.h(O.Container,C,P);default:return O.h(O.Container)}}));return O.h(O.Container,u,v(s))}const He=u=>{const{speed:t=O.signal(.5),windDirection:e=O.signal(0),windStrength:i=O.signal(.2),density:s=O.signal(180),resolution:c=O.signal([1e3,1e3])}=O.useProps(u),o=typeof t=="function"?t:O.signal(t),a=typeof e=="function"?e:O.signal(e),g=typeof i=="function"?i:O.signal(i),v=typeof s=="function"?s:O.signal(s),E=typeof c=="function"?c:O.signal(c),S=`
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
132
|
+
`;class We extends Ke{constructor(){super(...arguments),Xt(this,"_shader",null),Xt(this,"max_textures",St.TEXTURES_PER_TILEMAP),Xt(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new k.Shader({gpuProgram:k.GpuProgram.from({vertex:{source:Ki,entryPoint:"mainVert"},fragment:{source:zi.replace("//include_textures",Nt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new k.BindGroup({ut:this.pipe_uniforms})}}Xt(We,"extension",{type:[k.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var ji=Object.defineProperty,Wi=(h,t,e)=>t in h?ji(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ot=(h,t,e)=>(Wi(h,typeof t!="symbol"?t+"":t,e),e),Xe=(h=>(h[h.U=0]="U",h[h.V=1]="V",h[h.X=2]="X",h[h.Y=3]="Y",h[h.TILE_WIDTH=4]="TILE_WIDTH",h[h.TILE_HEIGHT=5]="TILE_HEIGHT",h[h.ROTATE=6]="ROTATE",h[h.ANIM_X=7]="ANIM_X",h[h.ANIM_Y=8]="ANIM_Y",h[h.TEXTURE_INDEX=9]="TEXTURE_INDEX",h[h.ANIM_COUNT_X=10]="ANIM_COUNT_X",h[h.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",h[h.ANIM_DIVISOR=12]="ANIM_DIVISOR",h[h.ALPHA=13]="ALPHA",h))(Xe||{});const gt=Object.keys(Xe).length/2;class $e extends k.ViewContainer{constructor(t){super({}),ot(this,"shadowColor",new Float32Array([0,0,0,.5])),ot(this,"state",k.State.for2d()),ot(this,"is_valid",!1),ot(this,"renderPipeId","tilemap"),ot(this,"canBundle",!0),ot(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),ot(this,"tileAnim",null),ot(this,"rects_count",0),ot(this,"compositeParent",!1),ot(this,"tileset",new Nt(St.TEXTURES_PER_TILEMAP)),ot(this,"tilemapBounds",new k.Bounds),ot(this,"hasAnimatedTile",!1),ot(this,"pointsBuf",[]),ot(this,"batched"),ot(this,"vbId",0),ot(this,"vb",null),ot(this,"vbBuffer",null),ot(this,"vbArray",null),ot(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=[]){var i,s;let e=this.tileset;if(t instanceof Nt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof k.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Nt(St.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let c=!0;for(let a=0;a<t.length;a++)if(((i=t[a])==null?void 0:i.source)!==e.arr[a]){c=!1;break}if(c)return this}e=this.tileset=new Nt(St.TEXTURES_PER_TILEMAP);for(let c=0;c<t.length;c++)e.push((s=t[c])==null?void 0:s.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,s={}){this.didViewUpdate=!0;let c,a=-1,o=!1;if(typeof t=="number")a=t,o=!0,c=this.tileset.arr[a];else{let f;typeof t=="string"?f=k.Texture.from(t):f=t;const b=this.tileset;for(let O=0;O<b.count;O++)if(b.arr[O]===f.source){a=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(!o&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:g=0,v:S=0,tileWidth:x=c.width,tileHeight:C=c.height,animX:A=0,animY:B=0,rotate:F=0,animCountX:N=1024,animCountY:P=1024,animDivisor:_=1,alpha:v=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||A>0||B>0,m.push(g),m.push(S),m.push(e),m.push(i),m.push(x),m.push(C),m.push(F),m.push(A|0),m.push(B|0),m.push(a),m.push(N),m.push(P),m.push(_),m.push(v),this.tilemapBounds.addFrame(e,i,e+x,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(gt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(gt-7)]=t,i[i.length-(gt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(gt-8)]=t,i[i.length-(gt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(gt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(gt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/gt;let s=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&s)return;this.rects_count=i,s||(s=t.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const c=i*s.vertPerQuad;t.checkIndexBuffer(i);const a=s.getBuffer("aVertexPosition"),o=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<o){let A=s.stride;for(;A<o;)A*=2;this.vbBuffer=new ArrayBuffer(A),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const g=this.vbArray,S=this.vbInts;let x=0,C=0;for(let A=0;A<e.length;A+=gt){this.compositeParent&&(C=e[A+9]);const F=e[A+2],N=e[A+3],P=e[A+4],_=e[A+5],v=e[A+0],m=e[A+1];let f=e[A+6];const b=e[A+7],O=e[A+8],R=e[A+10]||1024,U=e[A+11]||1024,y=b+R*2048,V=O+U*2048,Q=e[A+12],G=e[A+13];let z,lt,it,ct,L,nt,$,rt;if(f===0)z=v,lt=m,it=v+P,ct=m,L=v+P,nt=m+_,$=v,rt=m+_;else{let Y=P/2,H=_/2;f%4!==0&&(Y=_/2,H=P/2);const At=v+Y,bt=m+H;f=k.groupD8.add(f,k.groupD8.NW),z=At+Y*k.groupD8.uX(f),lt=bt+H*k.groupD8.uY(f),f=k.groupD8.add(f,2),it=At+Y*k.groupD8.uX(f),ct=bt+H*k.groupD8.uY(f),f=k.groupD8.add(f,2),L=At+Y*k.groupD8.uX(f),nt=bt+H*k.groupD8.uY(f),f=k.groupD8.add(f,2),$=At+Y*k.groupD8.uX(f),rt=bt+H*k.groupD8.uY(f)}g[x++]=F,g[x++]=N,g[x++]=z,g[x++]=lt,g[x++]=v+.5,g[x++]=m+.5,g[x++]=v+P-.5,g[x++]=m+_-.5,g[x++]=y,g[x++]=V,S[x++]=C,g[x++]=Q,g[x++]=G,g[x++]=F+P,g[x++]=N,g[x++]=it,g[x++]=ct,g[x++]=v+.5,g[x++]=m+.5,g[x++]=v+P-.5,g[x++]=m+_-.5,g[x++]=y,g[x++]=V,S[x++]=C,g[x++]=Q,g[x++]=G,g[x++]=F+P,g[x++]=N+_,g[x++]=L,g[x++]=nt,g[x++]=v+.5,g[x++]=m+.5,g[x++]=v+P-.5,g[x++]=m+_-.5,g[x++]=y,g[x++]=V,S[x++]=C,g[x++]=Q,g[x++]=G,g[x++]=F,g[x++]=N+_,g[x++]=$,g[x++]=rt,g[x++]=v+.5,g[x++]=m+.5,g[x++]=v+P-.5,g[x++]=m+_-.5,g[x++]=y,g[x++]=V,S[x++]=C,g[x++]=Q,g[x++]=G}a.data=g}isModified(t){return!!(this.rects_count*gt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/gt}addBounds(t){const e=this.tilemapBounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}get bounds(){return this.tilemapBounds}destroy(t){super.destroy(t),this.destroyVb()}addFrame(t,e,i,s,c){return this.tile(t,e,i,{animX:s,animY:c}),!0}addRect(t,e,i,s,c,a,o,g=0,S=0,x=0,C=1024,A=1024,B=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:a,tileHeight:o,animX:g,animY:S,rotate:x,animCountX:C,animCountY:A,animDivisor:B,alpha:F})}}var Xi=Object.defineProperty,$i=(h,t,e)=>t in h?Xi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Gt=(h,t,e)=>($i(h,typeof t!="symbol"?t+"":t,e),e);class Hi extends k.Container{constructor(t){super(),Gt(this,"texturesPerTilemap"),Gt(this,"tileAnim",null),Gt(this,"lastModifiedTilemap",null),Gt(this,"modificationMarker",0),Gt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=St.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const a=new $e(t.slice(c*e,(c+1)*e));a.compositeParent=!0,this.addChild(a)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const a=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let g=0;if(c=a[o],c)g=t%this.texturesPerTilemap;else{if(c=a[0],!c)return this;g=0}c.tile(g,e,i,s)}else{typeof t=="string"&&(t=k.Texture.from(t));for(let o=0;o<a.length;o++){const g=a[o],S=g.getTileset().arr;for(let x=0;x<S.length;x++)if(S[x]===t.source){c=g;break}if(c)break}if(!c){for(let o=a.length-1;o>=0;o--){const g=a[o];if(g.getTileset().count<this.texturesPerTilemap){c=g,g.getTileset().push(t.source);break}}c||(c=new $e(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,a,o,g,S){return this.tile(t,e,i,{animX:s,animY:c,animCountX:a,animCountY:o,animDivisor:g,alpha:S})}addRect(t,e,i,s,c,a,o,g,S,x,C,A){const B=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[B]&&this.children[B].getTileset().count>0?(this.lastModifiedTilemap=this.children[B],this.lastModifiedTilemap.addRect(F,e,i,s,c,a,o,g,S,x,C,A)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}k.extensions.add(ze),k.extensions.add(je),k.extensions.add(We);class $t extends k.AnimatedSprite{constructor(t,e){super($t.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=$t.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=k.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(k.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(k.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(k.groupD8.MAIN_DIAGONAL):i(k.groupD8.REVERSE_DIAGONAL))}}St.use32bitIndex=!0;class xe extends D.DisplayObject(Hi){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:a,tileheight:o,width:g}=this._layer;s&&(t=Math.floor(t/a),e=Math.floor(e/o));const S=t+e*g,x=this._layer.getTileByIndex(S);if(!x||x&&x.gid==0)return;const C=xe.findTileSet(x.gid,this.tileSets);if(!C)return;const A=new $t(x,C);if(A.x=t*a,A.y=e*o+(o-A.texture.height),A._x=t,A._y=e,C.tileoffset&&(A.x+=C.tileoffset.x??0,A.y+=C.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 ye({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",xe);function Qi(h){return D.createComponent("CompositeTileLayer",h)}class Ji extends Ii{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await k.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 k.Texture({source:e.source,frame:new k.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Zi(h,t,e){var s,c;const i=[];for(const a of h){if(a.type!==Rt.Tile){i.push(a);continue}const o=new Map;let g;if(Array.isArray(a.data))g=a.data.map(x=>typeof x=="number"?x:parseInt(String(x),10));else{i.push(a);continue}for(let x=0;x<g.length;x++){const C=g[x];if(C===0)continue;let A;for(let P=t.length-1;P>=0;P--)if(t[P].firstgid&&t[P].firstgid<=C){A=t[P];break}if(!A){o.has(0)||o.set(0,new Array(g.length).fill(0)),o.get(0)[x]=C;continue}const B=C-A.firstgid,F=(c=(s=A.tileset.tiles)==null?void 0:s[B])==null?void 0:c.properties,N=(F==null?void 0:F.z)??0;F==null||F.z,o.has(N)||o.set(N,new Array(g.length).fill(0)),o.get(N)[x]=C}const S=Array.from(o.keys()).sort((x,C)=>x-C);for(const x of S){const C=o.get(x);if(C.some(A=>A!==0)){const A={...a,name:`${a.name}_z${x}`,data:C,properties:{...a.properties,z:x}};i.push(A)}}}return i.sort((a,o)=>{var x,C;const g=((x=a.properties)==null?void 0:x.z)??.5,S=((C=o.properties)==null?void 0:C.z)??.5;return g-S}),i}function tr(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let a=[],o={};const g=async(x,C="")=>typeof x!="string"?x:await new Tt(x,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const x=t();if(x){o=await g(x,e()),a=[];for(let A of o.tilesets)A.tile&&(A.tiles=A.tile),A.tiles||(A.tiles=[]),a.push(await new Ji(A).load(A.image.source));let C=o.layers;i()&&(C=Zi(o.layers,a)),s.set(C)}});const S=(x,C={})=>D.h(D.Container,C,D.loop(x,A=>{switch(A.type){case Rt.Tile:return D.h(Qi,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...A,tilesets:a});case Rt.Image:const{width:B,height:F,source:N}=A.image;return D.h(D.TilingSprite,{image:N,...A,width:A.repeatx?A.width*A.tilewidth:B,height:A.repeaty?A.height*A.tileheight:F});case Rt.Group:return S(D.signal(A.layers),A);case Rt.ObjectGroup:const P=c==null?void 0:c(A);return D.h(D.Container,A,P);default:return D.h(D.Container)}}));return D.h(D.Container,h,S(s))}function er(){const h=`
|
|
133
|
+
precision mediump float;
|
|
134
|
+
attribute vec2 aPosition;
|
|
135
|
+
attribute vec2 aUV;
|
|
136
|
+
varying vec2 vUV;
|
|
137
|
+
void main() {
|
|
138
|
+
vUV = aUV;
|
|
139
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
140
|
+
}
|
|
141
|
+
`,t=`
|
|
142
|
+
precision mediump float;
|
|
143
|
+
|
|
144
|
+
varying vec2 vUV;
|
|
145
|
+
|
|
146
|
+
uniform float uTime;
|
|
147
|
+
uniform vec2 uResolution;
|
|
148
|
+
uniform float uRainSpeed;
|
|
149
|
+
uniform float uWindDirection;
|
|
150
|
+
uniform float uWindStrength;
|
|
151
|
+
uniform float uRainDensity;
|
|
152
|
+
uniform float uMaxDrops;
|
|
153
|
+
|
|
154
|
+
// Optimized hash function (single multiply, no sin)
|
|
155
|
+
float hash(float n) {
|
|
156
|
+
return fract(n * 0.1031);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Generate a single rain drop with fine realistic streak (highly optimized)
|
|
160
|
+
float rainDrop(vec2 uv, float t, float seed, float dropIndex, float maxDrops, float cosA, float sinA) {
|
|
161
|
+
// Pre-generate only necessary random values (reduced from 6 to 3)
|
|
162
|
+
float rnd0 = hash(seed);
|
|
163
|
+
float rnd1 = hash(seed + 1.0);
|
|
164
|
+
float rnd2 = hash(seed + 2.0);
|
|
165
|
+
|
|
166
|
+
// Simplified X position calculation
|
|
167
|
+
float xStructured = mod(dropIndex, 35.0) / 35.0;
|
|
168
|
+
float x = mix(rnd0, xStructured, 0.4) * 2.4 - 1.2;
|
|
169
|
+
|
|
170
|
+
// Base speed + variation
|
|
171
|
+
float speed = (0.4 + rnd1 * 0.6) * uRainSpeed;
|
|
172
|
+
|
|
173
|
+
// Simplified Y position calculation
|
|
174
|
+
float yStructured = mod(dropIndex, maxDrops) / max(maxDrops, 1.0);
|
|
175
|
+
float initialYOffset = mix(rnd2, yStructured, 0.7);
|
|
176
|
+
float yProgress = mod(initialYOffset + t * speed, 1.0);
|
|
177
|
+
float y = 1.2 - yProgress * 2.4;
|
|
178
|
+
|
|
179
|
+
// Aggressive early discard - check vertical bounds first
|
|
180
|
+
if (y < -1.3 || y > 1.3) {
|
|
181
|
+
return 0.0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Simplified wind effect
|
|
185
|
+
float windOffset = uWindDirection * uWindStrength * yProgress * 0.5;
|
|
186
|
+
x += windOffset;
|
|
187
|
+
|
|
188
|
+
// Early discard for horizontal bounds
|
|
189
|
+
if (x < -1.5 || x > 1.5) {
|
|
190
|
+
return 0.0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Fast distance check before expensive calculations
|
|
194
|
+
vec2 diff = uv - vec2(x, y);
|
|
195
|
+
float distSq = dot(diff, diff);
|
|
196
|
+
|
|
197
|
+
// Early discard if too far (major performance boost)
|
|
198
|
+
if (distSq > 0.01) { // ~0.1 units distance
|
|
199
|
+
return 0.0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Only calculate expensive operations if we're close
|
|
203
|
+
float dropWidth = 0.0012 + rnd0 * 0.0008;
|
|
204
|
+
float dropLength = 0.035 + rnd1 * 0.020;
|
|
205
|
+
|
|
206
|
+
// Simplified rotation (only if needed)
|
|
207
|
+
float rotX = diff.x * cosA - diff.y * sinA;
|
|
208
|
+
float rotY = diff.x * sinA + diff.y * cosA;
|
|
209
|
+
|
|
210
|
+
// Fast distance calculation
|
|
211
|
+
float distX = abs(rotX) / dropWidth;
|
|
212
|
+
float distY = abs(rotY) / dropLength;
|
|
213
|
+
float dist = max(distX, distY * 0.6);
|
|
214
|
+
|
|
215
|
+
// Final early discard
|
|
216
|
+
if (dist > 1.2) {
|
|
217
|
+
return 0.0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Simplified intensity calculation
|
|
221
|
+
float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
|
|
222
|
+
intensity *= 0.7 + 0.5 * rnd0;
|
|
223
|
+
|
|
224
|
+
// Simplified vertical fade
|
|
225
|
+
float verticalFade = smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
|
|
226
|
+
intensity *= verticalFade;
|
|
227
|
+
|
|
228
|
+
return intensity;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void main() {
|
|
232
|
+
// Normalized uv coordinates centered (pre-calculated once)
|
|
233
|
+
vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy)
|
|
234
|
+
/ min(uResolution.x, uResolution.y);
|
|
235
|
+
|
|
236
|
+
float rain = 0.0;
|
|
237
|
+
|
|
238
|
+
// Clamp number of drops - reduced max for better performance
|
|
239
|
+
float maxDrops = clamp(uMaxDrops, 10.0, 150.0);
|
|
240
|
+
|
|
241
|
+
// Pre-calculate wind angle & trig once per fragment
|
|
242
|
+
float windAngle = uWindDirection * uWindStrength * 0.2;
|
|
243
|
+
float cosA = cos(windAngle);
|
|
244
|
+
float sinA = sin(windAngle);
|
|
245
|
+
|
|
246
|
+
// Performance optimization: reduce loop iterations based on resolution
|
|
247
|
+
float pixelCount = uResolution.x * uResolution.y;
|
|
248
|
+
float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
|
|
249
|
+
float effectiveMaxDrops = maxDrops * resolutionFactor;
|
|
250
|
+
float loopMax = min(effectiveMaxDrops, 150.0);
|
|
251
|
+
|
|
252
|
+
// Optimized loop with early exit optimization
|
|
253
|
+
for (float i = 0.0; i < 150.0; i++) {
|
|
254
|
+
if (i >= loopMax) break;
|
|
255
|
+
// Use larger prime number spacing for better seed distribution
|
|
256
|
+
float seed = i * 23.47;
|
|
257
|
+
float dropValue = rainDrop(uv, uTime, seed, i, maxDrops, cosA, sinA);
|
|
258
|
+
rain += dropValue;
|
|
259
|
+
|
|
260
|
+
// Early exit if we've accumulated enough intensity (performance optimization)
|
|
261
|
+
if (rain > 2.0) break;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Scale based on density (optimized calculation)
|
|
265
|
+
rain *= uRainDensity * 0.007;
|
|
266
|
+
|
|
267
|
+
// Realistic rain color
|
|
268
|
+
vec3 rainColor = vec3(0.88, 0.92, 1.0);
|
|
269
|
+
|
|
270
|
+
// Alpha calculation - improved visibility
|
|
271
|
+
float alpha = rain * 0.9;
|
|
272
|
+
|
|
273
|
+
gl_FragColor = vec4(rainColor * rain, alpha);
|
|
274
|
+
}
|
|
275
|
+
`;return new k.GlProgram({vertex:h,fragment:t})}function ir(){const h=`
|
|
276
|
+
precision mediump float;
|
|
277
|
+
attribute vec2 aPosition;
|
|
278
|
+
attribute vec2 aUV;
|
|
279
|
+
varying vec2 vUV;
|
|
280
|
+
void main() {
|
|
281
|
+
vUV = aUV;
|
|
282
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
283
|
+
}
|
|
284
|
+
`,t=`
|
|
285
|
+
precision mediump float;
|
|
286
|
+
|
|
287
|
+
varying vec2 vUV;
|
|
288
|
+
|
|
289
|
+
uniform float uTime;
|
|
290
|
+
uniform vec2 uResolution;
|
|
291
|
+
uniform float uSnowSpeed;
|
|
292
|
+
uniform float uWindDirection;
|
|
293
|
+
uniform float uWindStrength;
|
|
294
|
+
uniform float uSnowDensity;
|
|
295
|
+
uniform float uMaxFlakes;
|
|
296
|
+
|
|
297
|
+
// Hash function for random number generation
|
|
298
|
+
float hash(float n) {
|
|
299
|
+
return fract(sin(n) * 43758.5453);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Generate a single snowflake
|
|
303
|
+
float snowFlake(vec2 uv, float t, float seed) {
|
|
304
|
+
// Pre-calculate all necessary hash values once
|
|
305
|
+
float rnd0 = hash(seed);
|
|
306
|
+
float rnd1 = hash(seed + 1.0);
|
|
307
|
+
float rnd2 = hash(seed + 2.0);
|
|
308
|
+
float rnd3 = hash(seed + 3.0);
|
|
309
|
+
float rnd4 = hash(seed + 4.0);
|
|
310
|
+
|
|
311
|
+
// Base X position
|
|
312
|
+
float x = rnd0 * 2.4 - 1.2;
|
|
313
|
+
|
|
314
|
+
// Falling speed (slower than rain)
|
|
315
|
+
float baseSpeed = 0.3 + rnd1 * 0.4;
|
|
316
|
+
float speed = baseSpeed * uSnowSpeed;
|
|
317
|
+
|
|
318
|
+
// Y position falling from top to bottom
|
|
319
|
+
float y = 1.2 - fract(t * speed + rnd2) * 2.4;
|
|
320
|
+
|
|
321
|
+
// Early exit if flake is too far vertically
|
|
322
|
+
if (y < -1.4 || y > 1.4) {
|
|
323
|
+
return 0.0;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Fall progress (0 = top, 1 = bottom)
|
|
327
|
+
float fallProgress = (1.2 - y) / 2.4;
|
|
328
|
+
|
|
329
|
+
// Optimized oscillation - natural and subtle movement
|
|
330
|
+
float oscillationPhase = t * 1.8 + seed * 6.28;
|
|
331
|
+
float oscillation = sin(oscillationPhase) * 0.08 + sin(oscillationPhase * 1.4) * 0.04;
|
|
332
|
+
oscillation *= (1.0 + fallProgress * 0.3);
|
|
333
|
+
|
|
334
|
+
// Wind effect - more pronounced and progressive with fall
|
|
335
|
+
float windOffset = uWindDirection * uWindStrength * fallProgress * 0.8;
|
|
336
|
+
|
|
337
|
+
// Add horizontal drift due to wind (even at top)
|
|
338
|
+
float windDrift = uWindDirection * uWindStrength * 0.2;
|
|
339
|
+
|
|
340
|
+
// Final X position with wind and oscillation
|
|
341
|
+
x += windOffset + windDrift + oscillation;
|
|
342
|
+
|
|
343
|
+
// Early exit if flake is too far horizontally
|
|
344
|
+
if (x < -1.4 || x > 1.4) {
|
|
345
|
+
return 0.0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
vec2 diff = uv - vec2(x, y);
|
|
349
|
+
|
|
350
|
+
// Fast distance check before expensive calculations
|
|
351
|
+
float distSq = dot(diff, diff);
|
|
352
|
+
|
|
353
|
+
// Early exit if too far (major performance boost)
|
|
354
|
+
if (distSq > 0.015) { // ~0.12 units distance
|
|
355
|
+
return 0.0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Flake size (circular) - only calculate if close
|
|
359
|
+
float flakeSize = 0.008 + rnd3 * 0.006;
|
|
360
|
+
float sizeSq = flakeSize * flakeSize;
|
|
361
|
+
|
|
362
|
+
// Additional early exit check
|
|
363
|
+
if (distSq > sizeSq * 1.5) {
|
|
364
|
+
return 0.0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
float dist = sqrt(distSq) / flakeSize;
|
|
368
|
+
|
|
369
|
+
// Intensity with soft flake shape
|
|
370
|
+
float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
|
|
371
|
+
intensity *= 0.8 + 0.2 * rnd4;
|
|
372
|
+
|
|
373
|
+
// Light twinkle (reduced frequency for performance)
|
|
374
|
+
float twinkle = 0.9 + 0.1 * sin(t * 6.0 + seed * 12.56);
|
|
375
|
+
intensity *= twinkle;
|
|
376
|
+
|
|
377
|
+
// Fade at top and bottom
|
|
378
|
+
intensity *= smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
|
|
379
|
+
|
|
380
|
+
return intensity;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
void main() {
|
|
384
|
+
vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.x, uResolution.y);
|
|
385
|
+
|
|
386
|
+
float snow = 0.0;
|
|
387
|
+
|
|
388
|
+
// Calculate number of flakes based on density (optimized for performance)
|
|
389
|
+
// Density 50-400 corresponds to approximately 40-150 flakes (reduced for performance)
|
|
390
|
+
float targetFlakes = 40.0 + (uSnowDensity - 50.0) * (110.0 / 350.0);
|
|
391
|
+
float maxFlakes = clamp(max(uMaxFlakes, targetFlakes), 30.0, 120.0);
|
|
392
|
+
|
|
393
|
+
// Performance optimization: reduce loop iterations based on resolution
|
|
394
|
+
float pixelCount = uResolution.x * uResolution.y;
|
|
395
|
+
float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
|
|
396
|
+
float effectiveMaxFlakes = maxFlakes * resolutionFactor;
|
|
397
|
+
float loopMax = min(effectiveMaxFlakes, 120.0);
|
|
398
|
+
|
|
399
|
+
// Generate flakes (limited to 120 for performance)
|
|
400
|
+
for (float i = 0.0; i < 120.0; i++) {
|
|
401
|
+
if (i >= loopMax) break;
|
|
402
|
+
float flakeValue = snowFlake(uv, uTime, i * 15.67);
|
|
403
|
+
snow += flakeValue;
|
|
404
|
+
|
|
405
|
+
// Early exit if we've accumulated enough intensity (performance optimization)
|
|
406
|
+
if (snow > 2.5) break;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Intensity adjustment based on density (normalization)
|
|
410
|
+
// Higher density means more visible flakes
|
|
411
|
+
float densityFactor = clamp(uSnowDensity / 200.0, 0.3, 2.0);
|
|
412
|
+
snow *= densityFactor;
|
|
413
|
+
|
|
414
|
+
// White color for snow
|
|
415
|
+
vec3 snowColor = vec3(1.0, 1.0, 1.0);
|
|
416
|
+
|
|
417
|
+
gl_FragColor = vec4(snowColor * snow, snow * 0.9);
|
|
418
|
+
}
|
|
419
|
+
`;return new k.GlProgram({vertex:h,fragment:t})}function rr(){const h=`
|
|
420
|
+
precision mediump float;
|
|
421
|
+
attribute vec2 aPosition;
|
|
422
|
+
attribute vec2 aUV;
|
|
423
|
+
varying vec2 vUV;
|
|
424
|
+
void main() {
|
|
425
|
+
vUV = aUV;
|
|
426
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
427
|
+
}
|
|
428
|
+
`,t=`
|
|
429
|
+
precision mediump float;
|
|
430
|
+
varying vec2 vUV;
|
|
431
|
+
|
|
432
|
+
uniform float uTime;
|
|
433
|
+
uniform vec2 uResolution;
|
|
201
434
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
435
|
+
uniform float uSpeed; // movement
|
|
436
|
+
uniform float uScale; // detail scale
|
|
437
|
+
uniform float uDensity; // opacity
|
|
438
|
+
|
|
439
|
+
// ------------------- noise -----------------------------------
|
|
440
|
+
|
|
441
|
+
float hash(vec2 p) {
|
|
442
|
+
return fract(sin(dot(p, vec2(127.1,311.7))) * 43758.5453);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
float noise(vec2 p) {
|
|
446
|
+
vec2 i = floor(p);
|
|
447
|
+
vec2 f = fract(p);
|
|
448
|
+
vec2 u = f*f*(3.0 - 2.0*f);
|
|
449
|
+
return mix(
|
|
450
|
+
mix(hash(i + vec2(0.,0.)), hash(i + vec2(1.,0.)), u.x),
|
|
451
|
+
mix(hash(i + vec2(0.,1.)), hash(i + vec2(1.,1.)), u.x),
|
|
452
|
+
u.y
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
float fbm(vec2 p){
|
|
457
|
+
float v = 0.0;
|
|
458
|
+
float a = 0.5;
|
|
459
|
+
for(int i = 0; i < 5; i++){
|
|
460
|
+
v += a * noise(p);
|
|
461
|
+
p *= 2.0;
|
|
462
|
+
a *= 0.5;
|
|
463
|
+
}
|
|
464
|
+
return v;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// --------------------------------------------------------------
|
|
468
|
+
|
|
469
|
+
void main() {
|
|
470
|
+
|
|
471
|
+
vec2 uv = gl_FragCoord.xy / uResolution.xy;
|
|
472
|
+
|
|
473
|
+
float fog = 0.0;
|
|
474
|
+
|
|
475
|
+
// -------- multi-layer fog ----------------------
|
|
476
|
+
|
|
477
|
+
for(int i = 0; i < 3; i++){
|
|
478
|
+
float layer = float(i);
|
|
479
|
+
|
|
480
|
+
vec2 p = uv;
|
|
481
|
+
|
|
482
|
+
float scale = uScale * (1.0 + layer * 0.6);
|
|
483
|
+
float t = uTime * uSpeed * (0.3 + layer * 0.4);
|
|
484
|
+
|
|
485
|
+
// drift
|
|
486
|
+
p.x += t * 0.2;
|
|
487
|
+
p.y += sin(t + p.x * 2.0) * 0.03;
|
|
488
|
+
|
|
489
|
+
// extra wave motion
|
|
490
|
+
p.x += cos(p.y * 2.5 + t) * 0.03;
|
|
491
|
+
|
|
492
|
+
fog += fbm(p * scale) * (1.0 - layer * 0.25);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// normalize & threshold
|
|
496
|
+
fog = smoothstep(0.25, 0.8, fog);
|
|
497
|
+
|
|
498
|
+
// -------------- vertical fade (optional) -----------------
|
|
499
|
+
|
|
500
|
+
float height = uv.y;
|
|
501
|
+
fog *= (1.0 - height * 0.3);
|
|
502
|
+
|
|
503
|
+
// -------------- density handling -------------------------
|
|
504
|
+
|
|
505
|
+
float density = clamp(uDensity, 0.0, 1.0);
|
|
506
|
+
|
|
507
|
+
// alpha based on fog intensity (soft)
|
|
508
|
+
float alpha = fog * density * 0.8;
|
|
509
|
+
|
|
510
|
+
// -------------- fog color -----------------------
|
|
511
|
+
|
|
512
|
+
vec3 baseColor = vec3(0.92, 0.94, 0.96);
|
|
513
|
+
|
|
514
|
+
// slight variation
|
|
515
|
+
float v = fbm(uv * 2.0 + uTime * 0.1) * 0.05;
|
|
516
|
+
|
|
517
|
+
vec3 color = baseColor + v;
|
|
518
|
+
|
|
519
|
+
// modulate brightness by fog value: bright in high density
|
|
520
|
+
color *= (0.6 + fog * 0.4);
|
|
521
|
+
|
|
522
|
+
// ---------- result ---------------------------------
|
|
523
|
+
|
|
524
|
+
gl_FragColor = vec4(color, alpha);
|
|
525
|
+
}
|
|
526
|
+
`;return new k.GlProgram({vertex:h,fragment:t})}const He=h=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:s=D.signal(.2),density:c=D.signal(120),maxDrops:a=D.signal(80),height:o=D.signal(.2),scale:g=D.signal(2),resolution:S}=D.useProps(h),x=D.signal([1e3,1e3]),C=S?typeof S=="function"?S:D.signal(S):x;D.mount(ct=>{const L=ct.props.context;L!=null&&L.canvasSize&&t(()=>{const nt=L.canvasSize();nt&&nt.width>0&&nt.height>0&&x.set([nt.width,nt.height])})});const A=typeof e=="function"?e:D.signal(e),B=typeof i=="function"?i:D.signal(i),F=typeof s=="function"?s:D.signal(s),N=typeof c=="function"?c:D.signal(c),P=typeof a=="function"?a:D.signal(a),_=typeof o=="function"?o:D.signal(o),v=typeof g=="function"?g:D.signal(g);let m,f;if(t()==="rain")m=er(),f={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uRainSpeed:{value:A(),type:"f32"},uWindDirection:{value:B(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uRainDensity:{value:N(),type:"f32"},uMaxDrops:{value:P(),type:"f32"}};else if(t()==="snow")m=ir(),f={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSnowSpeed:{value:A(),type:"f32"},uWindDirection:{value:B(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uSnowDensity:{value:N(),type:"f32"},uMaxFlakes:{value:P(),type:"f32"}};else if(t()==="fog")m=rr(),f={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSpeed:{value:A(),type:"f32"},uScale:{value:v(),type:"f32"},uDensity:{value:N(),type:"f32"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog`);const b=new k.UniformGroup(f),O=new k.Shader({glProgram:m,resources:{uniforms:b}}),R=new k.Geometry({attributes:{aPosition:[-1,-1,1,-1,1,1,-1,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let U=Math.random()*10,y=[...C()],V=B(),Q=F(),G=A(),z=N(),lt=P();_();let it=v();return D.tick(({deltaTime:ct})=>{U+=ct/600,b.uniforms.uTime=U;const L=C();(L[0]!==y[0]||L[1]!==y[1])&&(b.uniforms.uResolution=L,y=[...L]);const nt=B();if(nt!==V&&(b.uniforms.uWindDirection=nt,V=nt),t()==="rain"||t()==="snow"){const $=F();$!==Q&&(b.uniforms.uWindStrength=$,Q=$)}if(t()==="rain"){const $=A();$!==G&&(b.uniforms.uRainSpeed=$,G=$);const rt=N();rt!==z&&(b.uniforms.uRainDensity=rt,z=rt);const Y=P();Y!==lt&&(b.uniforms.uMaxDrops=Y,lt=Y)}else if(t()==="snow"){const $=A();$!==G&&(b.uniforms.uSnowSpeed=$,G=$);const rt=N();rt!==z&&(b.uniforms.uSnowDensity=rt,z=rt);const Y=P();Y!==lt&&(b.uniforms.uMaxFlakes=Y,lt=Y)}else if(t()==="fog"){const $=A();$!==G&&(b.uniforms.uSpeed=$,G=$);const rt=v();rt!==it&&(b.uniforms.uScale=rt,it=rt);const Y=N();Y!==z&&(b.uniforms.uDensity=Y,z=Y)}}),D.h(D.Mesh,{geometry:R,shader:O,width:"100%",height:"100%"})},sr=He;return _t.Bar=Ze,_t.Direction=Se,_t.Joystick=hi,_t.LightSpot=ci,_t.Loading=fi,_t.NightAmbiant=ui,_t.Particle=li,_t.TiledMap=tr,_t.Weather=sr,_t.WeatherEffect=He,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"}),_t}({},CanvasEngine,PIXI);
|
|
222
527
|
//# sourceMappingURL=index.global.js.map
|