@canvasengine/presets 2.0.0-beta.38 → 2.0.0-beta.39
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/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +20 -20
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1413 -1511
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/Joystick.d.ts +0 -34
- package/dist/Joystick.d.ts.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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}/*!
|
|
1
|
+
var CanvasEnginePresets=function(xt,D,P){"use strict";function He(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const e in h)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>h[e]})}}return t.default=h,Object.freeze(t)}const dt=He(P);function Qt(h){var t=h.toString(16);return t.length==1?"0"+t:t}function Qe(h,t,e){return"#"+Qt(h)+Qt(t)+Qt(e)}function Je(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:a,border:o,innerMargin:y,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=y(),T=S(),M=Math.max(0,Math.min(t()-2*C,i()/s()*(t()-2*C))),F=e()-2*C;S?x.roundRect(C,C,M,F,T):x.rect(C,C,M,F);const N=a();if(N.startsWith("rgba")){const[O,_,v,m]=N.match(/\d+(\.\d+)?/g).map(Number);x.fill({color:Qe(O,_,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 dt.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var Jt;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(Jt||(Jt={}));class Zt{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class G{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Ut;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Ut||(Ut={}));class Ze extends Zt{constructor(){super(Ut.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let a=i.rotation;const o=G.float(-s,s),y=G.float(-c,c);a!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(a)-y*Math.sin(a),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(a)+y*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)+y),e.radial?(a+=Math.atan2(y,o),t.dx=Math.cos(a),t.dy=Math.sin(a)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=a,this._t+=this._posInterpolationStep}}class ti extends Zt{constructor(){super(Ut.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=G.float(-e.angle*.5,e.angle*.5)+i.rotation:s=G.float(0,6.28319)+i.rotation,e.radius>0){let c=G.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c}else t.component.x=this.__x+this._t*(this.x-this.__x),t.component.y=this.__y+this._t*(this.y-this.__y);e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class ei extends Zt{constructor(){super(Ut.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=G.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var Et;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(Et||(Et={}));class ii extends dt.AnimatedSprite{constructor(t,e,i,s){let c=[],a=e.length;for(let o=0;o<a;o++)c.push(dt.Texture.from(e[o]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class ri{constructor(){}setRgb(t,e){this.startRgb=this.rgb=t,this.r=this.sR=t>>16&255,this.g=this.sG=t>>8&255,this.b=this.sB=t&255,this.targetRgb=e,this.dR=(e>>16&255)-this.r,this.dG=(e>>8&255)-this.g,this.dB=(e&255)-this.b}tween(t,e,i){return t?(this.r=t(e,this.sR,this.dR,i),this.g=t(e,this.sG,this.dG,i),this.b=t(e,this.sB,this.dB,i)):(e/=i,this.r=this.dR*e+this.sR,this.g=this.dG*e+this.sG,this.b=this.dB*e+this.sB),this.rgb=this.r<<16|this.g<<8|this.b,this.rgb}}var be;(function(h){h.Linear="linear",h.EaseInQuad="easeInQuad",h.EaseOutQuad="easeOutQuad",h.EaseInOutQuad="easeInOutQuad",h.EaseInCubic="easeInCubic",h.EaseOutCubic="easeOutCubic",h.EaseInOutCubic="easeInOutCubic",h.EaseInQuart="easeInQuart",h.EaseOutQuart="easeOutQuart",h.EaseInOutQuart="easeInOutQuart",h.EaseInQuint="easeInQuint",h.EaseOutQuint="easeOutQuint",h.EaseInOutQuint="easeInOutQuint",h.EaseInSine="easeInSine",h.EaseOutSine="easeOutSine",h.EaseInOutSine="easeInOutSine",h.EaseInExpo="easeInExpo",h.EaseOutExpo="easeOutExpo",h.EaseInOutExpo="easeInOutExpo",h.EaseInCirc="easeInCirc",h.EaseOutCirc="easeOutCirc",h.EaseInOutCirc="easeInOutCirc",h.EaseInElastic="easeInElastic",h.EaseOutElastic="easeOutElastic",h.EaseInOutElastic="easeInOutElastic",h.EaseInBack="easeInBack",h.EaseOutBack="easeOutBack",h.EaseInOutBack="easeInOutBack",h.EaseInBounce="easeInBounce",h.EaseOutBounce="easeOutBounce",h.EaseInOutBounce="easeInOutBounce"})(be||(be={}));class _t{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e}static easeOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/a)+i+e}static easeInOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s/2),a||(a=s*.44999999999999996),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=_t.easeOutBounce(s-t,0,i,s),i-c+e}static easeOutBounce(t,e,i,s){return(t/=s)<.36363636363636365?i*(7.5625*t*t)+e:t<.7272727272727273?i*(7.5625*(t-=.5454545454545454)*t+.75)+e:t<.9090909090909091?i*(7.5625*(t-=.8181818181818182)*t+.9375)+e:i*(7.5625*(t-=.9545454545454546)*t+.984375)+e}static easeInOutBounce(t,e,i,s){let c;return t<s/2?(c=_t.easeInBounce(t*2,0,i,s),c*.5+e):(c=_t.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class ut{constructor(){this.__hasCallback=!1,this._list=new zt}add(t,e,i){this._list.add(new Dt(new Ae(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Dt(new Ae(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const a=i.data;a.callRate&&a.calls%a.callRate!=0&&(c=!1),c&&(a.callback.apply(a.scope,t),a.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Ae{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let si=class extends Dt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new ut,bounced:new ut,updated:new ut},this._color=new ri}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const a=this.duration=G.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(s):t.container.addChildAt(s,0),s.blendMode=c.__getBlendMode(e.blendMode),this.startX=s.x,this.startY=s.y,this.useGravity=t.settings.useGravity,this.useScale=e.useScale,this.useRotation=e.useRotation,this.useAlpha=e.useAlpha,this.useTint=e.useTint,this.useSpawns=e.useSpawns,this.useChilds=e.useChilds,this.useMotion=e.useMotion,this.useGravity)if(this.gravity=t.settings.gravity,this.useFloor=t.settings.useFloor,this.floorY=t.settings.floorY,this.bounceFac=G.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-G.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=G.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=o*this.dx*i,this.moveSpeedY=o*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const o=this.distance=G.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+o*this.dx-this.startX)*.8,this.deltaY=(s.y+o*this.dy-this.startY)*.8,this.distanceEase=_t[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=G.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=G.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=G.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=_t[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=a*(1-e.fadeInDurationFac),this.fadeInDuration=a*e.fadeInDurationFac,this.fadeInEase=_t[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=_t[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=G.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(G.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=G.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(G.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=_t[e.scaleXEase],this.scaleYStart=s.scale.y=G.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(G.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=_t[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=a*(1-e.scaleInDurationFac),this.scaleInDuration=a*e.scaleInDurationFac,this.scaleInEase=_t[e.scaleInEase||"easeInSine"])):e.uniformScale?(s.scale.x=e.scaleStartMin,s.scale.y=e.scaleStartMin):(s.scale.x=e.scaleXStartMin,s.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=G.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=G.sign())),e.useTint&&(this.tintEase=_t[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let o=e.childs.length;if(this._hasChildEmitters=o>0,this._childEmitters)for(;--o>-1;){const y=e.childs[o],S=c.getParticleEmitterById(y.id);S.init(t.container,!0,(y.scale||1)*(i||1)),y.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 y=a[o];y.__recycled||(y.x=s.position.x,y.y=s.position.y,y.__adoptRotation&&(y.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class 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 y in i)o[y]==null&&(o[y]=i[y])}}}wt._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class ni extends dt.Sprite{constructor(t,e,i,s){super(dt.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Nt(h){if(typeof h!="object"||h===null)return h;const t=Array.isArray(h)?[]:{};for(const e in h){const i=h[e];t[e]=Nt(i)}return t}var ai=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(a){a(c)})}return new(e||(e=Promise))(function(c,a){function o(x){try{S(i.next(x))}catch(C){a(C)}}function y(x){try{S(i.throw(x))}catch(C){a(C)}}function S(x){x.done?c(x.value):s(x.value).then(o,y)}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)=>ai(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)o[y]=s[y];dt.Assets.addBundle("rfx_assets",o);const S=yield dt.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 Te(t),s.__fx=this):s=i.pop(),e&&(c=Nt(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,a=this._settingsCache.emitters[t];if(!a)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new te(t),c.__fx=this):c=s.pop(),i&&(a=Nt(a),a.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(a),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new te(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Te(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(dt.Cache._cache,t)}get active(){return this._active}__addActiveEffect(t){this._effects.add(t)}__removeActiveEffect(t){this._effects.remove(t)}__getSprite(t){const e=this._cache.sprites;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){const s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new ni(t,s.texture,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getMovieClip(t){const e=this._cache.mcs;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){let s=this._settingsCache.mcs[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new ii(t,s.textures,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new si;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new pt.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return dt.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?pt._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const a=t;a.values();for(const[o,y]of a)y instanceof dt.Texture&&(i[o]=y)}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 y=a.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(a)}for(let a in s){let o=s[a];c.movieClips.push(a),this.initMovieClip(a,{textures:o,anchorX:.5,anchorY:.5})}return c}}pt.settingsVersion=0,pt.version="1.3.4",pt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",pt.ComponentType=Jt,pt.EffectSequenceComponentType=Et,pt._blendModes=["normal","add","multiply","screen"],pt.__emitterCores={circle:ti,box:Ze,ring:ei};var Pt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Pt||(Pt={}));class te extends ve{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new zt,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new ut,completed:new ut,exhausted:new ut,particleUpdated:new ut,particleSpawned:new ut,particleBounced:new ut,particleDied:new ut}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container;a.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(a.rotation=this._rotation,a.__adoptRotation=!0),a.__parent=this,this._childEmitters.push(a)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+G.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,a;for(;c;)a=c.next,c.update(t),c=a;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=G.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let a;switch(s.componentType){case 0:c.componentId=s.componentId,a=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,a=e.__getMovieClip(c.componentId),s.componentParams&&(a.loop=!(s.componentParams.loop==null||!s.componentParams.loop),a.animationSpeed=G.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),a.gotoAndPlay(0);break}a.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=a,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=G.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let a,o;switch(c.type){case 0:a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(a.rotation=t.component.rotation+a.settings.rotation,a.__adoptRotation=!0):a.rotation=a.settings.rotation;break;case 1:a=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(a.rotation=t.component.rotation);break}a.x=t.component.x,a.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const a=i[c];for(const o of a){switch(o.type){case Pt.ParticleEmitter:o.settings=Nt(e.__getEmitterSettings(o.id));break;case Pt.EffectSequence:o.settings=Nt(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Pt.ParticleEmitter:c.settings=Nt(e.__getEmitterSettings(c.id));break;case Pt.EffectSequence:c.settings=Nt(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class Te extends ve{constructor(t){super(t),this._list=[],this._elements=new zt,this.__on={started:new ut,completed:new ut,exhausted:new ut,effectSpawned:new ut,triggerActivated:new ut}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,a=this._nextEffectSettings;let o,y,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(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.float(a.alphaMin,a.alphaMax),o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),y=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Sprite,o);break;case Et.MovieClip:o=c.__getMovieClip(a.componentId),a.componentParams.loop?(o.animationSpeed=G.float(a.componentParams.animationSpeedMin||1,a.componentParams.animationSpeedMax||1),o.loop=a.componentParams.loop||!1):a.duration,o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),o.gotoAndPlay(0),S=c.__containers[a.containerId]||this.container,S.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.float(a.alphaMin,a.alphaMax),y=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.MovieClip,o);break;case Et.Emitter:o=c.getParticleEmitterById(a.componentId),S=c.__containers[a.containerId]||this.container,o.init(S,!0,G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Dt({component:o,endTime:o.endTime}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+o.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Emitter,o);break;case Et.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(a.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof te?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function oi(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new pt;let c;return dt.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),dt.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:a})=>{s.update(a)}),D.mount(async a=>{c=a;let y={...(await dt.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const x=e.emitters.map((C,T)=>({...C,id:1e4+T}));y.emitters=[...y.emitters,...x]}s.initBundle(y,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}function li(h){const{radius:t}=D.useProps(h),e=D.animatedSignal(1),i=1,s=2,c=.001,a=()=>{const y=Date.now()*c,S=(Math.sin(y)+Math.sin(y*1.3)+Math.sin(y*.7))/3,x=i+(s-i)*(S*.5+.5);e.update(()=>x),requestAnimationFrame(a)};a();const o=y=>{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;y.rect(-C,-C,S,S).fill(x.render({translate:{x:C,y:C}}))};return D.h(D.Graphics,{draw:o,...h,scale:e})}function ci(h){const{children:t}=h,e=D.signal(0),i=D.signal(0);let s;const c=a=>{a.rect(-80,-80,e()+80*2,i()+80*2),a.fill(0);const y=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,T=D.isSignal(S.propObservables.radius)?S.propObservables.radius():S.props.radius;a.circle(x,C,T),a.cut()};for(let S of t){if(D.isObservable(S)){s&&s.unsubscribe(),s=S.subscribe(x=>{for(let C of x.fullElements)y(C)});return}y(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)}function ui(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:a=3,inactiveAlpha:o=.15}=D.useProps(h,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),y=D.signal(0);D.tick(({deltaTime:F})=>{const O=(typeof s=="function"?s():s)*F/1e3;y.set(y()+O)});const S=F=>{const N=typeof t=="function"?t():t,O=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,v=typeof c=="function"?c():c;typeof a=="function"&&a();const m=typeof o=="function"?o():o,d=y();_&&F.circle(0,0,N).fill(_);const b=360/v,R=N*.4,U=N;for(let k=0;k<v;k++){const g=k*b,V=(d%360+360)%360;let rt=Math.abs(V-g);rt>180&&(rt=360-rt);let W=rt/120;W=Math.min(1,W),W=W*W*W;const lt=m+(1-W)*(1-m),ot=g*(Math.PI/180),ht=b*(Math.PI/180),L=ot-ht/2,st=ot+ht/2;F.arc(0,0,R,L,st).arc(0,0,U,st,L,!0).fill({color:O,alpha:lt})}},C=(typeof t=="function"?t():t)*2,T=D.signal(C),M=D.signal(C);return typeof t=="function"&&D.effect(()=>{const F=t();T.set(F*2),M.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 Se(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function hi(h){if(Object.prototype.hasOwnProperty.call(h,"__esModule"))return h;var t=h.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(h).forEach(function(i){var s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return h[i]}})}),e}var ee={};const fi=hi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ie={},jt={exports:{}},re={},kt={},Ce;function di(){if(Ce)return kt;Ce=1,kt.byteLength=o,kt.toByteArray=S,kt.fromByteArray=T;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(M){var F=M.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=M.indexOf("=");N===-1&&(N=F);var O=N===F?0:4-N%4;return[N,O]}function o(M){var F=a(M),N=F[0],O=F[1];return(N+O)*3/4-O}function y(M,F,N){return(F+N)*3/4-N}function S(M){var F,N=a(M),O=N[0],_=N[1],v=new e(y(M,O,_)),m=0,d=_>0?O-4:O,b;for(b=0;b<d;b+=4)F=t[M.charCodeAt(b)]<<18|t[M.charCodeAt(b+1)]<<12|t[M.charCodeAt(b+2)]<<6|t[M.charCodeAt(b+3)],v[m++]=F>>16&255,v[m++]=F>>8&255,v[m++]=F&255;return _===2&&(F=t[M.charCodeAt(b)]<<2|t[M.charCodeAt(b+1)]>>4,v[m++]=F&255),_===1&&(F=t[M.charCodeAt(b)]<<10|t[M.charCodeAt(b+1)]<<4|t[M.charCodeAt(b+2)]>>2,v[m++]=F>>8&255,v[m++]=F&255),v}function x(M){return h[M>>18&63]+h[M>>12&63]+h[M>>6&63]+h[M&63]}function C(M,F,N){for(var O,_=[],v=F;v<N;v+=3)O=(M[v]<<16&16711680)+(M[v+1]<<8&65280)+(M[v+2]&255),_.push(x(O));return _.join("")}function T(M){for(var F,N=M.length,O=N%3,_=[],v=16383,m=0,d=N-O;m<d;m+=v)_.push(C(M,m,m+v>d?d:m+v));return O===1?(F=M[N-1],_.push(h[F>>2]+h[F<<4&63]+"==")):O===2&&(F=(M[N-2]<<8)+M[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 pi(){return Ie||(Ie=1,Wt.read=function(h,t,e,i,s){var c,a,o=s*8-i-1,y=(1<<o)-1,S=y>>1,x=-7,C=e?s-1:0,T=e?-1:1,M=h[t+C];for(C+=T,c=M&(1<<-x)-1,M>>=-x,x+=o;x>0;c=c*256+h[t+C],C+=T,x-=8);for(a=c&(1<<-x)-1,c>>=-x,x+=i;x>0;a=a*256+h[t+C],C+=T,x-=8);if(c===0)c=1-S;else{if(c===y)return a?NaN:(M?-1:1)*(1/0);a=a+Math.pow(2,i),c=c-S}return(M?-1:1)*a*Math.pow(2,c-i)},Wt.write=function(h,t,e,i,s,c){var a,o,y,S=c*8-s-1,x=(1<<S)-1,C=x>>1,T=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=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*(y=Math.pow(2,-a))<1&&(a--,y*=2),a+C>=1?t+=T/y:t+=T*Math.pow(2,1-C),t*y>=2&&(a++,y/=2),a+C>=x?(o=0,a=x):a+C>=1?(o=(t*y-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+M]=o&255,M+=F,o/=256,s-=8);for(a=a<<s|o,S+=s;S>0;h[e+M]=a&255,M+=F,a/=256,S-=8);h[e+M-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(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
|
-
`||
|
|
8
|
-
Line: `+
|
|
9
|
-
Column: `+
|
|
10
|
-
Char: `+
|
|
11
|
-
Actual: `+
|
|
12
|
-
Actual: `+
|
|
13
|
-
`?(l.line++,l.column=0):l.column++),l.state){case
|
|
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(
|
|
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(`
|
|
6
|
+
*/var Be;function Me(){return Be||(Be=1,function(h){const t=di(),e=pi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=v,h.INSPECT_MAX_BYTES=50;const s=2147483647;h.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=c(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const u=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(u,r),u.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function a(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const r=new Uint8Array(u);return Object.setPrototypeOf(r,o.prototype),r}function o(u,r,n){if(typeof u=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(u)}return y(u,r,n)}o.poolSize=8192;function y(u,r,n){if(typeof u=="string")return T(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=O(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 y(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 T(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 M(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 M(u)}function N(u,r,n){if(r<0||u.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(u):n===void 0?p=new Uint8Array(u,r):p=new Uint8Array(u,r,n),Object.setPrototypeOf(p,o.prototype),p}function O(u){if(o.isBuffer(u)){const r=_(u.length)|0,n=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):M(u);if(u.type==="Buffer"&&Array.isArray(u.data))return M(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 A=0,I=Math.min(p,E);A<I;++A)if(r[A]!==n[A]){p=r[A],E=n[A];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 A=0;for(p=0;p<r.length;++p){let I=r[p];if(mt(I,Uint8Array))A+I.length>E.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(E,A)):Uint8Array.prototype.set.call(E,I,A);else if(o.isBuffer(I))I.copy(E,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=I.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 it(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qt(u).length;default:if(E)return p?-1:it(u).length;r=(""+r).toLowerCase(),E=!0}}o.byteLength=m;function d(u,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(u||(u="utf8");;)switch(u){case"hex":return $(this,r,n);case"utf8":case"utf-8":return lt(this,r,n);case"ascii":return L(this,r,n);case"latin1":case"binary":return st(this,r,n);case"base64":return W(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),p=!0}}o.prototype._isBuffer=!0;function b(u,r,n){const p=u[r];u[r]=u[n],u[n]=p}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?lt(this,0,r):d.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const n=h.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(r,n,p,E,A){if(mt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),E===void 0&&(E=0),A===void 0&&(A=this.length),n<0||p>r.length||E<0||A>this.length)throw new RangeError("out of range index");if(E>=A&&n>=p)return 0;if(E>=A)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,E>>>=0,A>>>=0,this===r)return 0;let I=A-E,q=p-n;const Z=Math.min(I,q),Q=this.slice(E,A),tt=r.slice(n,p);for(let j=0;j<Z;++j)if(Q[j]!==tt[j]){I=Q[j],q=tt[j];break}return I<q?-1:q<I?1:0};function R(u,r,n,p,E){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=E?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(E)return-1;n=u.length-1}else if(n<0)if(E)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,p)),o.isBuffer(r))return r.length===0?-1:U(u,r,n,p,E);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?E?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):U(u,[r],n,p,E);throw new TypeError("val must be string, number or Buffer")}function U(u,r,n,p,E){let A=1,I=u.length,q=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(u.length<2||r.length<2)return-1;A=2,I/=2,q/=2,n/=2}function Z(tt,j){return A===1?tt[j]:tt.readUInt16BE(j*A)}let Q;if(E){let tt=-1;for(Q=n;Q<I;Q++)if(Z(u,Q)===Z(r,tt===-1?0:Q-tt)){if(tt===-1&&(tt=Q),Q-tt+1===q)return tt*A}else tt!==-1&&(Q-=Q-tt),tt=-1}else for(n+q>I&&(n=I-q),Q=n;Q>=0;Q--){let tt=!0;for(let j=0;j<q;j++)if(Z(u,Q+j)!==Z(r,j)){tt=!1;break}if(tt)return Q}return-1}o.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},o.prototype.indexOf=function(r,n,p){return R(this,r,n,p,!0)},o.prototype.lastIndexOf=function(r,n,p){return R(this,r,n,p,!1)};function k(u,r,n,p){n=Number(n)||0;const E=u.length-n;p?(p=Number(p),p>E&&(p=E)):p=E;const A=r.length;p>A/2&&(p=A/2);let I;for(I=0;I<p;++I){const q=parseInt(r.substr(I*2,2),16);if(we(q))return I;u[n+I]=q}return I}function g(u,r,n,p){return Mt(it(r,u.length-n),u,n,p)}function V(u,r,n,p){return Mt(yt(r),u,n,p)}function rt(u,r,n,p){return Mt(qt(r),u,n,p)}function K(u,r,n,p){return Mt(Ee(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,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 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");E||(E="utf8");let I=!1;for(;;)switch(E){case"hex":return k(this,r,n,p);case"utf8":case"utf-8":return g(this,r,n,p);case"ascii":case"latin1":case"binary":return V(this,r,n,p);case"base64":return 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: "+E);E=(""+E).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function lt(u,r,n){n=Math.min(u.length,n);const p=[];let E=r;for(;E<n;){const A=u[E];let I=null,q=A>239?4:A>223?3:A>191?2:1;if(E+q<=n){let Z,Q,tt,j;switch(q){case 1:A<128&&(I=A);break;case 2:Z=u[E+1],(Z&192)===128&&(j=(A&31)<<6|Z&63,j>127&&(I=j));break;case 3:Z=u[E+1],Q=u[E+2],(Z&192)===128&&(Q&192)===128&&(j=(A&15)<<12|(Z&63)<<6|Q&63,j>2047&&(j<55296||j>57343)&&(I=j));break;case 4:Z=u[E+1],Q=u[E+2],tt=u[E+3],(Z&192)===128&&(Q&192)===128&&(tt&192)===128&&(j=(A&15)<<18|(Z&63)<<12|(Q&63)<<6|tt&63,j>65535&&j<1114112&&(I=j))}}I===null?(I=65533,q=1):I>65535&&(I-=65536,p.push(I>>>10&1023|55296),I=56320|I&1023),p.push(I),E+=q}return ht(p)}const ot=4096;function ht(u){const r=u.length;if(r<=ot)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=ot));return n}function 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 st(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 A=r;A<n;++A)E+=rr[u[A]];return E}function et(u,r,n){const p=u.slice(r,n);let E="";for(let A=0;A<p.length-1;A+=2)E+=String.fromCharCode(p[A]+p[A+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],A=1,I=0;for(;++I<n&&(A*=256);)E+=this[r+I]*A;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],A=1;for(;n>0&&(A*=256);)E+=this[r+--n]*A;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)&&nt(r,this.length-8);const E=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(E)+(BigInt(A)<<BigInt(32))}),o.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const E=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(E)<<BigInt(32))+BigInt(A)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r],A=1,I=0;for(;++I<n&&(A*=256);)E+=this[r+I]*A;return A*=128,E>=A&&(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,A=1,I=this[r+--E];for(;E>0&&(A*=256);)I+=this[r+--E]*A;return A*=128,I>=A&&(I-=Math.pow(2,8*n)),I},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)&&nt(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)&&nt(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,A){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>E||r<A)throw new RangeError('"value" argument is out of bounds');if(n+p>u.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;H(this,r,n,p,q,0)}let A=1,I=0;for(this[n]=r&255;++I<p&&(A*=256);)this[n+I]=r/A&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;H(this,r,n,p,q,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},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function Tt(u,r,n,p,E){J(r,p,E,u,n,7);let A=Number(r&BigInt(4294967295));u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=I,I=I>>8,u[n++]=I,I=I>>8,u[n++]=I,I=I>>8,u[n++]=I,n}function bt(u,r,n,p,E){J(r,p,E,u,n,7);let A=Number(r&BigInt(4294967295));u[n+7]=A,A=A>>8,u[n+6]=A,A=A>>8,u[n+5]=A,A=A>>8,u[n+4]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=I,I=I>>8,u[n+2]=I,I=I>>8,u[n+1]=I,I=I>>8,u[n]=I,n+8}o.prototype.writeBigUInt64LE=Ft(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Ft(function(r,n=0){return bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=0,I=1,q=0;for(this[n]=r&255;++A<p&&(I*=256);)r<0&&q===0&&this[n+A-1]!==0&&(q=1),this[n+A]=(r/I>>0)-q&255;return n+p},o.prototype.writeIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=p-1,I=1,q=0;for(this[n+A]=r&255;--A>=0&&(I*=256);)r<0&&q===0&&this[n+A+1]!==0&&(q=1),this[n+A]=(r/I>>0)-q&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||H(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=Ft(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Ft(function(r,n=0){return bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vt(u,r,n,p,E,A){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(u,r,n,p,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 f(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 f(this,r,n,!0,p)},o.prototype.writeDoubleBE=function(r,n,p){return f(this,r,n,!1,p)},o.prototype.copy=function(r,n,p,E){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!E&&E!==0&&(E=this.length),n>=r.length&&(n=r.length),n||(n=0),E>0&&E<p&&(E=p),E===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("sourceEnd out of bounds");E>this.length&&(E=this.length),r.length-n<E-p&&(E=r.length-n+p);const A=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),A},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 I=r.charCodeAt(0);(E==="utf8"&&I<128||E==="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=o.isBuffer(r)?r:o.from(r,E),q=I.length;if(q===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(A=0;A<p-n;++A)this[A+n]=I[A%q]}return this};const l={};function B(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}`}}}B("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),B("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),B("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,E=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?E=w(String(n)):typeof n=="bigint"&&(E=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(E=w(E)),E+="n"),p+=` It must be ${r}. Received ${E}`,p},RangeError);function w(u){let r="",n=u.length;const p=u[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${u.slice(n-3,n)}${r}`;return`${u.slice(0,n)}${r}`}function z(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&nt(r,u.length-(n+1))}function J(u,r,n,p,E,A){if(u>n||u<r){const I=typeof r=="bigint"?"n":"";let q;throw r===0||r===BigInt(0)?q=`>= 0${I} and < 2${I} ** ${(A+1)*8}${I}`:q=`>= -(2${I} ** ${(A+1)*8-1}${I}) and < 2 ** ${(A+1)*8-1}${I}`,new l.ERR_OUT_OF_RANGE("value",q,u)}z(p,E,A)}function X(u,r){if(typeof u!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",u)}function nt(u,r,n){throw Math.floor(u)!==u?(X(u,n),new l.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const ct=/[^+/0-9A-Za-z-_]/g;function Bt(u){if(u=u.split("=")[0],u=u.trim().replace(ct,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function it(u,r){r=r||1/0;let n;const p=u.length;let E=null;const A=[];for(let I=0;I<p;++I){if(n=u.charCodeAt(I),n>55295&&n<57344){if(!E){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}E=n;continue}if(n<56320){(r-=3)>-1&&A.push(239,191,189),E=n;continue}n=(E-55296<<10|n-56320)+65536}else E&&(r-=3)>-1&&A.push(239,191,189);if(E=null,n<128){if((r-=1)<0)break;A.push(n)}else if(n<2048){if((r-=2)<0)break;A.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;A.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;A.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return A}function yt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Ee(u,r){let n,p,E;const A=[];for(let I=0;I<u.length&&!((r-=2)<0);++I)n=u.charCodeAt(I),p=n>>8,E=n%256,A.push(E),A.push(p);return A}function qt(u){return t.toByteArray(Bt(u))}function Mt(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 rr=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"?sr:u}function sr(){throw new Error("BigInt not supported")}}(re)),re}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Fe;function mi(){return Fe||(Fe=1,function(h,t){var e=Me(),i=e.Buffer;function s(a,o){for(var y in a)o[y]=a[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(a,o,y){return i(a,o,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(a,o,y){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,y)},c.alloc=function(a,o,y){if(typeof a!="number")throw new TypeError("Argument must be a number");var S=i(a);return o!==void 0?typeof y=="string"?S.fill(o,y):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 De;function _i(){if(De)return ie;De=1;var h=mi().Buffer,t=h.isEncoding||function(_){switch(_=""+_,_&&_.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(_){if(!_)return"utf8";for(var v;;)switch(_){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return _;default:if(v)return;_=(""+_).toLowerCase(),v=!0}}function i(_){var v=e(_);if(typeof v!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return v||_}ie.StringDecoder=s;function s(_){this.encoding=i(_);var v;switch(this.encoding){case"utf16le":this.text=C,this.end=T,v=4;break;case"utf8":this.fillLast=y,v=4;break;case"base64":this.text=M,this.end=F,v=3;break;default:this.write=N,this.end=O;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 d=v.length-1;if(d<m)return 0;var b=c(v[d]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(_.lastNeed=b-2),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,v,m){if((v[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return _.lastNeed=2,"�"}}function y(_){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 d=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,d),_.toString("utf8",v,d)}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 d=m.charCodeAt(m.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=_[_.length-1],_.toString("utf16le",v,_.length-1)}function T(_){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 M(_,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 O(_){return _&&_.length?this.write(_):""}return ie}var Ne;function gi(){return Ne||(Ne=1,function(h){(function(t){t.parser=function(f,l){return new i(f,l)},t.SAXParser=i,t.SAXStream=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(f,l){if(!(this instanceof i))return new i(f,l);var B=this;c(B),B.q=B.c="",B.bufferCheckPosition=t.MAX_BUFFER_LENGTH,B.opt=l||{},B.opt.lowercase=B.opt.lowercase||B.opt.lowercasetags,B.looseCase=B.opt.lowercase?"toLowerCase":"toUpperCase",B.tags=[],B.closed=B.closedRoot=B.sawRoot=!1,B.tag=B.error=null,B.strict=!!f,B.noscript=!!(f||B.opt.noscript),B.state=g.BEGIN,B.strictEntities=B.opt.strictEntities,B.ENTITIES=B.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),B.attribList=[],B.opt.xmlns&&(B.ns=Object.create(N)),B.opt.unquotedAttributeValues===void 0&&(B.opt.unquotedAttributeValues=!f),B.trackPosition=B.opt.position!==!1,B.trackPosition&&(B.position=B.line=B.column=0),rt(B,"onready")}Object.create||(Object.create=function(f){function l(){}l.prototype=f;var B=new l;return B}),Object.keys||(Object.keys=function(f){var l=[];for(var B in f)f.hasOwnProperty(B)&&l.push(B);return l});function s(f){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),B=0,w=0,z=e.length;w<z;w++){var J=f[e[w]].length;if(J>l)switch(e[w]){case"textNode":W(f);break;case"cdata":K(f,"oncdata",f.cdata),f.cdata="";break;case"script":K(f,"onscript",f.script),f.script="";break;default:ot(f,"Max buffer length exceeded: "+e[w])}B=Math.max(B,J)}var X=t.MAX_BUFFER_LENGTH-B;f.bufferCheckPosition=X+f.position}function c(f){for(var l=0,B=e.length;l<B;l++)f[e[l]]=""}function a(f){W(f),f.cdata!==""&&(K(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(K(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ht(this)},write:Ht,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=fi.Stream}catch{o=function(){}}o||(o=function(){});var y=t.EVENTS.filter(function(f){return f!=="error"&&f!=="end"});function S(f,l){return new x(f,l)}function x(f,l){if(!(this instanceof x))return new x(f,l);o.apply(this),this._parser=new i(f,l),this.writable=!0,this.readable=!0;var B=this;this._parser.onend=function(){B.emit("end")},this._parser.onerror=function(w){B.emit("error",w),B._parser.error=null},this._decoder=null,y.forEach(function(w){Object.defineProperty(B,"on"+w,{get:function(){return B._parser["on"+w]},set:function(z){if(!z)return B.removeAllListeners(w),B._parser["on"+w]=z,z;B.on(w,z)},enumerable:!0,configurable:!1})})}x.prototype=Object.create(o.prototype,{constructor:{value:x}}),x.prototype.write=function(f){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(f)){if(!this._decoder){var l=_i().StringDecoder;this._decoder=new l("utf8")}f=this._decoder.write(f)}return this._parser.write(f.toString()),this.emit("data",f),!0},x.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},x.prototype.on=function(f,l){var B=this;return!B._parser["on"+f]&&y.indexOf(f)!==-1&&(B._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),B.emit.apply(B,w)}),o.prototype.on.call(B,f,l)};var C="[CDATA[",T="DOCTYPE",M="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",N={xml:M,xmlns:F},O=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,v=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function d(f){return f===" "||f===`
|
|
7
|
+
`||f==="\r"||f===" "}function b(f){return f==='"'||f==="'"}function R(f){return f===">"||d(f)}function U(f,l){return f.test(l)}function k(f,l){return!U(f,l)}var g=0;t.STATE={BEGIN:g++,BEGIN_WHITESPACE:g++,TEXT:g++,TEXT_ENTITY:g++,OPEN_WAKA:g++,SGML_DECL:g++,SGML_DECL_QUOTED:g++,DOCTYPE:g++,DOCTYPE_QUOTED:g++,DOCTYPE_DTD:g++,DOCTYPE_DTD_QUOTED:g++,COMMENT_STARTING:g++,COMMENT:g++,COMMENT_ENDING:g++,COMMENT_ENDED:g++,CDATA:g++,CDATA_ENDING:g++,CDATA_ENDING_2:g++,PROC_INST:g++,PROC_INST_BODY:g++,PROC_INST_ENDING:g++,OPEN_TAG:g++,OPEN_TAG_SLASH:g++,ATTRIB:g++,ATTRIB_NAME:g++,ATTRIB_NAME_SAW_WHITE:g++,ATTRIB_VALUE:g++,ATTRIB_VALUE_QUOTED:g++,ATTRIB_VALUE_CLOSED:g++,ATTRIB_VALUE_UNQUOTED:g++,ATTRIB_VALUE_ENTITY_Q:g++,ATTRIB_VALUE_ENTITY_U:g++,CLOSE_TAG:g++,CLOSE_TAG_SAW_WHITE:g++,SCRIPT:g++,SCRIPT_ENDING:g++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(f){var l=t.ENTITIES[f],B=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[f]=B});for(var V in t.STATE)t.STATE[t.STATE[V]]=V;g=t.STATE;function rt(f,l,B){f[l]&&f[l](B)}function K(f,l,B){f.textNode&&W(f),rt(f,l,B)}function W(f){f.textNode=lt(f.opt,f.textNode),f.textNode&&rt(f,"ontext",f.textNode),f.textNode=""}function lt(f,l){return f.trim&&(l=l.trim()),f.normalize&&(l=l.replace(/\s+/g," ")),l}function ot(f,l){return W(f),f.trackPosition&&(l+=`
|
|
8
|
+
Line: `+f.line+`
|
|
9
|
+
Column: `+f.column+`
|
|
10
|
+
Char: `+f.c),l=new Error(l),f.error=l,rt(f,"onerror",l),f}function ht(f){return f.sawRoot&&!f.closedRoot&&L(f,"Unclosed root tag"),f.state!==g.BEGIN&&f.state!==g.BEGIN_WHITESPACE&&f.state!==g.TEXT&&ot(f,"Unexpected end"),W(f),f.c="",f.closed=!0,rt(f,"onend"),i.call(f,f.strict,f.opt),f}function L(f,l){if(typeof f!="object"||!(f instanceof i))throw new Error("bad call to strictFail");f.strict&&ot(f,l)}function st(f){f.strict||(f.tagName=f.tagName[f.looseCase]());var l=f.tags[f.tags.length-1]||f,B=f.tag={name:f.tagName,attributes:{}};f.opt.xmlns&&(B.ns=l.ns),f.attribList.length=0,K(f,"onopentagstart",B)}function $(f,l){var B=f.indexOf(":"),w=B<0?["",f]:f.split(":"),z=w[0],J=w[1];return l&&f==="xmlns"&&(z="xmlns",J=""),{prefix:z,local:J}}function et(f){if(f.strict||(f.attribName=f.attribName[f.looseCase]()),f.attribList.indexOf(f.attribName)!==-1||f.tag.attributes.hasOwnProperty(f.attribName)){f.attribName=f.attribValue="";return}if(f.opt.xmlns){var l=$(f.attribName,!0),B=l.prefix,w=l.local;if(B==="xmlns")if(w==="xml"&&f.attribValue!==M)L(f,"xml: prefix must be bound to "+M+`
|
|
11
|
+
Actual: `+f.attribValue);else if(w==="xmlns"&&f.attribValue!==F)L(f,"xmlns: prefix must be bound to "+F+`
|
|
12
|
+
Actual: `+f.attribValue);else{var z=f.tag,J=f.tags[f.tags.length-1]||f;z.ns===J.ns&&(z.ns=Object.create(J.ns)),z.ns[w]=f.attribValue}f.attribList.push([f.attribName,f.attribValue])}else f.tag.attributes[f.attribName]=f.attribValue,K(f,"onattribute",{name:f.attribName,value:f.attribValue});f.attribName=f.attribValue=""}function Y(f,l){if(f.opt.xmlns){var B=f.tag,w=$(f.tagName);B.prefix=w.prefix,B.local=w.local,B.uri=B.ns[w.prefix]||"",B.prefix&&!B.uri&&(L(f,"Unbound namespace prefix: "+JSON.stringify(f.tagName)),B.uri=w.prefix);var z=f.tags[f.tags.length-1]||f;B.ns&&z.ns!==B.ns&&Object.keys(B.ns).forEach(function(mt){K(f,"onopennamespace",{prefix:mt,uri:B.ns[mt]})});for(var J=0,X=f.attribList.length;J<X;J++){var nt=f.attribList[J],ct=nt[0],Bt=nt[1],it=$(ct,!0),yt=it.prefix,Ee=it.local,qt=yt===""?"":B.ns[yt]||"",Mt={name:ct,value:Bt,prefix:yt,local:Ee,uri:qt};yt&&yt!=="xmlns"&&!qt&&(L(f,"Unbound namespace prefix: "+JSON.stringify(yt)),Mt.uri=yt),f.tag.attributes[ct]=Mt,K(f,"onattribute",Mt)}f.attribList.length=0}f.tag.isSelfClosing=!!l,f.sawRoot=!0,f.tags.push(f.tag),K(f,"onopentag",f.tag),l||(!f.noscript&&f.tagName.toLowerCase()==="script"?f.state=g.SCRIPT:f.state=g.TEXT,f.tag=null,f.tagName=""),f.attribName=f.attribValue="",f.attribList.length=0}function H(f){if(!f.tagName){L(f,"Weird empty close tag."),f.textNode+="</>",f.state=g.TEXT;return}if(f.script){if(f.tagName!=="script"){f.script+="</"+f.tagName+">",f.tagName="",f.state=g.SCRIPT;return}K(f,"onscript",f.script),f.script=""}var l=f.tags.length,B=f.tagName;f.strict||(B=B[f.looseCase]());for(var w=B;l--;){var z=f.tags[l];if(z.name!==w)L(f,"Unexpected close tag");else break}if(l<0){L(f,"Unmatched closing tag: "+f.tagName),f.textNode+="</"+f.tagName+">",f.state=g.TEXT;return}f.tagName=B;for(var J=f.tags.length;J-- >l;){var X=f.tag=f.tags.pop();f.tagName=f.tag.name,K(f,"onclosetag",f.tagName);var nt={};for(var ct in X.ns)nt[ct]=X.ns[ct];var Bt=f.tags[f.tags.length-1]||f;f.opt.xmlns&&X.ns!==Bt.ns&&Object.keys(X.ns).forEach(function(it){var yt=X.ns[it];K(f,"onclosenamespace",{prefix:it,uri:yt})})}l===0&&(f.closedRoot=!0),f.tagName=f.attribValue=f.attribName="",f.attribList.length=0,f.state=g.TEXT}function Tt(f){var l=f.entity,B=l.toLowerCase(),w,z="";return f.ENTITIES[l]?f.ENTITIES[l]:f.ENTITIES[B]?f.ENTITIES[B]:(l=B,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),w=parseInt(l,16),z=w.toString(16)):(l=l.slice(1),w=parseInt(l,10),z=w.toString(10))),l=l.replace(/^0+/,""),isNaN(w)||z.toLowerCase()!==l?(L(f,"Invalid character entity"),"&"+f.entity+";"):String.fromCodePoint(w))}function bt(f,l){l==="<"?(f.state=g.OPEN_WAKA,f.startTagPosition=f.position):d(l)||(L(f,"Non-whitespace before first tag."),f.textNode=l,f.state=g.TEXT)}function Vt(f,l){var B="";return l<f.length&&(B=f.charAt(l)),B}function Ht(f){var l=this;if(this.error)throw this.error;if(l.closed)return ot(l,"Cannot write after close. Assign an onready handler.");if(f===null)return ht(l);typeof f=="object"&&(f=f.toString());for(var B=0,w="";w=Vt(f,B++),l.c=w,!!w;)switch(l.trackPosition&&(l.position++,w===`
|
|
13
|
+
`?(l.line++,l.column=0):l.column++),l.state){case g.BEGIN:if(l.state=g.BEGIN_WHITESPACE,w==="\uFEFF")continue;bt(l,w);continue;case g.BEGIN_WHITESPACE:bt(l,w);continue;case g.TEXT:if(l.sawRoot&&!l.closedRoot){for(var z=B-1;w&&w!=="<"&&w!=="&";)w=Vt(f,B++),w&&l.trackPosition&&(l.position++,w===`
|
|
14
|
+
`?(l.line++,l.column=0):l.column++);l.textNode+=f.substring(z,B-1)}w==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):(!d(w)&&(!l.sawRoot||l.closedRoot)&&L(l,"Text data outside of root node."),w==="&"?l.state=g.TEXT_ENTITY:l.textNode+=w);continue;case g.SCRIPT:w==="<"?l.state=g.SCRIPT_ENDING:l.script+=w;continue;case g.SCRIPT_ENDING:w==="/"?l.state=g.CLOSE_TAG:(l.script+="<"+w,l.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(w==="!")l.state=g.SGML_DECL,l.sgmlDecl="";else if(!d(w))if(U(O,w))l.state=g.OPEN_TAG,l.tagName=w;else if(w==="/")l.state=g.CLOSE_TAG,l.tagName="";else if(w==="?")l.state=g.PROC_INST,l.procInstName=l.procInstBody="";else{if(L(l,"Unencoded <"),l.startTagPosition+1<l.position){var J=l.position-l.startTagPosition;w=new Array(J).join(" ")+w}l.textNode+="<"+w,l.state=g.TEXT}continue;case g.SGML_DECL:if(l.sgmlDecl+w==="--"){l.state=g.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=g.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+w,l.sgmlDecl=""):(l.sgmlDecl+w).toUpperCase()===C?(K(l,"onopencdata"),l.state=g.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+w).toUpperCase()===T?(l.state=g.DOCTYPE,(l.doctype||l.sawRoot)&&L(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):w===">"?(K(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=g.TEXT):(b(w)&&(l.state=g.SGML_DECL_QUOTED),l.sgmlDecl+=w);continue;case g.SGML_DECL_QUOTED:w===l.q&&(l.state=g.SGML_DECL,l.q=""),l.sgmlDecl+=w;continue;case g.DOCTYPE:w===">"?(l.state=g.TEXT,K(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=w,w==="["?l.state=g.DOCTYPE_DTD:b(w)&&(l.state=g.DOCTYPE_QUOTED,l.q=w));continue;case g.DOCTYPE_QUOTED:l.doctype+=w,w===l.q&&(l.q="",l.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:w==="]"?(l.doctype+=w,l.state=g.DOCTYPE):w==="<"?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):b(w)?(l.doctype+=w,l.state=g.DOCTYPE_DTD_QUOTED,l.q=w):l.doctype+=w;continue;case g.DOCTYPE_DTD_QUOTED:l.doctype+=w,w===l.q&&(l.state=g.DOCTYPE_DTD,l.q="");continue;case g.COMMENT:w==="-"?l.state=g.COMMENT_ENDING:l.comment+=w;continue;case g.COMMENT_ENDING:w==="-"?(l.state=g.COMMENT_ENDED,l.comment=lt(l.opt,l.comment),l.comment&&K(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+w,l.state=g.COMMENT);continue;case g.COMMENT_ENDED:w!==">"?(L(l,"Malformed comment"),l.comment+="--"+w,l.state=g.COMMENT):l.doctype&&l.doctype!==!0?l.state=g.DOCTYPE_DTD:l.state=g.TEXT;continue;case g.CDATA:w==="]"?l.state=g.CDATA_ENDING:l.cdata+=w;continue;case g.CDATA_ENDING:w==="]"?l.state=g.CDATA_ENDING_2:(l.cdata+="]"+w,l.state=g.CDATA);continue;case g.CDATA_ENDING_2:w===">"?(l.cdata&&K(l,"oncdata",l.cdata),K(l,"onclosecdata"),l.cdata="",l.state=g.TEXT):w==="]"?l.cdata+="]":(l.cdata+="]]"+w,l.state=g.CDATA);continue;case g.PROC_INST:w==="?"?l.state=g.PROC_INST_ENDING:d(w)?l.state=g.PROC_INST_BODY:l.procInstName+=w;continue;case g.PROC_INST_BODY:if(!l.procInstBody&&d(w))continue;w==="?"?l.state=g.PROC_INST_ENDING:l.procInstBody+=w;continue;case g.PROC_INST_ENDING:w===">"?(K(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=g.TEXT):(l.procInstBody+="?"+w,l.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:U(_,w)?l.tagName+=w:(st(l),w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:(d(w)||L(l,"Invalid character in tag name"),l.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:w===">"?(Y(l,!0),H(l)):(L(l,"Forward-slash in opening tag not followed by >"),l.state=g.ATTRIB);continue;case g.ATTRIB:if(d(w))continue;w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:U(O,w)?(l.attribName=w,l.attribValue="",l.state=g.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case g.ATTRIB_NAME:w==="="?l.state=g.ATTRIB_VALUE:w===">"?(L(l,"Attribute without value"),l.attribValue=l.attribName,et(l),Y(l)):d(w)?l.state=g.ATTRIB_NAME_SAW_WHITE:U(_,w)?l.attribName+=w:L(l,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(w==="=")l.state=g.ATTRIB_VALUE;else{if(d(w))continue;L(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",K(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?Y(l):U(O,w)?(l.attribName=w,l.state=g.ATTRIB_NAME):(L(l,"Invalid attribute name"),l.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(d(w))continue;b(w)?(l.q=w,l.state=g.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||ot(l,"Unquoted attribute value"),l.state=g.ATTRIB_VALUE_UNQUOTED,l.attribValue=w);continue;case g.ATTRIB_VALUE_QUOTED:if(w!==l.q){w==="&"?l.state=g.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=w;continue}et(l),l.q="",l.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:d(w)?l.state=g.ATTRIB:w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:U(O,w)?(L(l,"No whitespace between attributes"),l.attribName=w,l.attribValue="",l.state=g.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!R(w)){w==="&"?l.state=g.ATTRIB_VALUE_ENTITY_U:l.attribValue+=w;continue}et(l),w===">"?Y(l):l.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(l.tagName)w===">"?H(l):U(_,w)?l.tagName+=w:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=g.SCRIPT):(d(w)||L(l,"Invalid tagname in closing tag"),l.state=g.CLOSE_TAG_SAW_WHITE);else{if(d(w))continue;k(O,w)?l.script?(l.script+="</"+w,l.state=g.SCRIPT):L(l,"Invalid tagname in closing tag."):l.tagName=w}continue;case g.CLOSE_TAG_SAW_WHITE:if(d(w))continue;w===">"?H(l):L(l,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var X,nt;switch(l.state){case g.TEXT_ENTITY:X=g.TEXT,nt="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:X=g.ATTRIB_VALUE_QUOTED,nt="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:X=g.ATTRIB_VALUE_UNQUOTED,nt="attribValue";break}if(w===";"){var ct=Tt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(ct)?(l.entity="",l.state=X,l.write(ct)):(l[nt]+=ct,l.entity="",l.state=X)}else U(l.entity.length?m:v,w)?l.entity+=w:(L(l,"Invalid character in entity name"),l[nt]+="&"+l.entity+w,l.entity="",l.state=X);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var f=String.fromCharCode,l=Math.floor,B=function(){var w=16384,z=[],J,X,nt=-1,ct=arguments.length;if(!ct)return"";for(var Bt="";++nt<ct;){var it=Number(arguments[nt]);if(!isFinite(it)||it<0||it>1114111||l(it)!==it)throw RangeError("Invalid code point: "+it);it<=65535?z.push(it):(it-=65536,J=(it>>10)+55296,X=it%1024+56320,z.push(J,X)),(nt+1===ct||z.length>w)&&(Bt+=f.apply(null,z),z.length=0)}return Bt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:B,configurable:!0,writable:!0}):String.fromCodePoint=B}()})(h)}(ee)),ee}var se,Oe;function ne(){return Oe||(Oe=1,se={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),se}var ae,Pe;function oe(){if(Pe)return ae;Pe=1;var h=ne().isArray;return ae={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!h(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},ae}var le,Re;function Ue(){if(Re)return le;Re=1;var h=gi(),t=oe(),e=ne().isArray,i,s;function c(_){return i=t.copyOptions(_),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function a(_){var v=Number(_);if(!isNaN(v))return v;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,v){var m;if(i.compact){if(!s[i[_+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[_+"Key"])!==-1:i.alwaysArray)&&(s[i[_+"Key"]]=[]),s[i[_+"Key"]]&&!e(s[i[_+"Key"]])&&(s[i[_+"Key"]]=[s[i[_+"Key"]]]),_+"Fn"in i&&typeof v=="string"&&(v=i[_+"Fn"](v,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in v)if(v.hasOwnProperty(m))if("instructionFn"in i)v[m]=i.instructionFn(v[m],m,s);else{var d=v[m];delete v[m],v[i.instructionNameFn(m,d,s)]=d}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(v):s[i[_+"Key"]]=v}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in v)if(v.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,v,s):m,i.instructionHasAttributes?(b[i.attributesKey]=v[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(v[m]=i.instructionFn(v[m],m,s)),b[i.instructionKey]=v[m])}else _+"Fn"in i&&(v=i[_+"Fn"](v,s)),b[i[_+"Key"]]=v;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function y(_){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,d;(d=m.exec(_.body))!==null;)v[d[1]]=d[2]||d[3]||d[4];v=y(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=y(v),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&v&&Object.keys(v).length){m[i.attributesKey]={};var d;for(d in v)v.hasOwnProperty(d)&&(m[i.attributesKey][d]=v[d])}!(_ in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(_)!==-1:i.alwaysArray)&&(s[_]=[]),s[_]&&!e(s[_])&&(s[_]=[s[_]]),e(s[_])?s[_].push(m):s[_]=m}else s[i.elementsKey]||(s[i.elementsKey]=[]),m={},m[i.typeKey]="element",m[i.nameKey]=_,!i.ignoreAttributes&&v&&Object.keys(v).length&&(m[i.attributesKey]=v),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function C(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=a(_)),i.sanitize&&(_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),o("text",_))}function T(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function M(_){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 O(_){_.note=_}return le=function(_,v){var m=h.parser(!0,{}),d={};if(s=d,i=c(v),m.opt={strictEntities:!0},m.onopentag=x,m.ontext=C,m.oncomment=T,m.onclosetag=M,m.onerror=O,m.oncdata=F,m.ondoctype=N,m.onprocessinginstruction=S,m.write(_).close(),d[i.elementsKey]){var b=d[i.elementsKey];delete d[i.elementsKey],d[i.elementsKey]=b,delete d.text}return d},le}var ce,ke;function yi(){if(ke)return ce;ke=1;var h=oe(),t=Ue();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return ce=function(i,s){var c,a,o,y;return c=e(s),a=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(a,function(S,x){return S===y?"_":x},c.spaces):o=JSON.stringify(a,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var ue,Le;function Ye(){if(Le)return ue;Le=1;var h=oe(),t=ne().isArray,e,i;function s(m){var d=h.copyOptions(m);return h.ensureFlagExists("ignoreDeclaration",d),h.ensureFlagExists("ignoreInstruction",d),h.ensureFlagExists("ignoreAttributes",d),h.ensureFlagExists("ignoreText",d),h.ensureFlagExists("ignoreComment",d),h.ensureFlagExists("ignoreCdata",d),h.ensureFlagExists("ignoreDoctype",d),h.ensureFlagExists("compact",d),h.ensureFlagExists("indentText",d),h.ensureFlagExists("indentCdata",d),h.ensureFlagExists("indentAttributes",d),h.ensureFlagExists("indentInstruction",d),h.ensureFlagExists("fullTagEmptyElement",d),h.ensureFlagExists("noQuotesForNativeAttributes",d),h.ensureSpacesExists(d),typeof d.spaces=="number"&&(d.spaces=Array(d.spaces+1).join(" ")),h.ensureKeyExists("declaration",d),h.ensureKeyExists("instruction",d),h.ensureKeyExists("attributes",d),h.ensureKeyExists("text",d),h.ensureKeyExists("comment",d),h.ensureKeyExists("cdata",d),h.ensureKeyExists("doctype",d),h.ensureKeyExists("type",d),h.ensureKeyExists("name",d),h.ensureKeyExists("elements",d),h.checkFnExists("doctype",d),h.checkFnExists("instruction",d),h.checkFnExists("cdata",d),h.checkFnExists("comment",d),h.checkFnExists("text",d),h.checkFnExists("instructionName",d),h.checkFnExists("elementName",d),h.checkFnExists("attributeName",d),h.checkFnExists("attributeValue",d),h.checkFnExists("attributes",d),h.checkFnExists("fullTagEmptyElement",d),d}function c(m,d,b){return(!b&&m.spaces?`
|
|
15
|
+
`:"")+Array(d+1).join(m.spaces)}function a(m,d,b){if(d.ignoreAttributes)return"";"attributesFn"in d&&(m=d.attributesFn(m,i,e));var R,U,k,g,V=[];for(R in m)m.hasOwnProperty(R)&&m[R]!==null&&m[R]!==void 0&&(g=d.noQuotesForNativeAttributes&&typeof m[R]!="string"?"":'"',U=""+m[R],U=U.replace(/"/g,"""),k="attributeNameFn"in d?d.attributeNameFn(R,U,i,e):R,V.push(d.spaces&&d.indentAttributes?c(d,b+1,!1):" "),V.push(k+"="+g+("attributeValueFn"in d?d.attributeValueFn(U,R,i,e):U)+g));return m&&Object.keys(m).length&&d.spaces&&d.indentAttributes&&V.push(c(d,b,!1)),V.join("")}function o(m,d,b){return e=m,i="xml",d.ignoreDeclaration?"":"<?xml"+a(m[d.attributesKey],d,b)+"?>"}function y(m,d,b){if(d.ignoreInstruction)return"";var R;for(R in m)if(m.hasOwnProperty(R))break;var U="instructionNameFn"in d?d.instructionNameFn(R,m[R],i,e):R;if(typeof m[R]=="object")return e=m,i=U,"<?"+U+a(m[R][d.attributesKey],d,b)+"?>";var k=m[R]?m[R]:"";return"instructionFn"in d&&(k=d.instructionFn(k,R,i,e)),"<?"+U+(k?" "+k:"")+"?>"}function S(m,d){return d.ignoreComment?"":"<!--"+("commentFn"in d?d.commentFn(m,i,e):m)+"-->"}function x(m,d){return d.ignoreCdata?"":"<![CDATA["+("cdataFn"in d?d.cdataFn(m,i,e):m.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(m,d){return d.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in d?d.doctypeFn(m,i,e):m)+">"}function T(m,d){return d.ignoreText?"":(m=""+m,m=m.replace(/&/g,"&"),m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in d?d.textFn(m,i,e):m)}function M(m,d){var b;if(m.elements&&m.elements.length)for(b=0;b<m.elements.length;++b)switch(m.elements[b][d.typeKey]){case"text":if(d.indentText)return!0;break;case"cdata":if(d.indentCdata)return!0;break;case"instruction":if(d.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function F(m,d,b){e=m,i=m.name;var R=[],U="elementNameFn"in d?d.elementNameFn(m.name,m):m.name;R.push("<"+U),m[d.attributesKey]&&R.push(a(m[d.attributesKey],d,b));var k=m[d.elementsKey]&&m[d.elementsKey].length||m[d.attributesKey]&&m[d.attributesKey]["xml:space"]==="preserve";return k||("fullTagEmptyElementFn"in d?k=d.fullTagEmptyElementFn(m.name,m):k=d.fullTagEmptyElement),k?(R.push(">"),m[d.elementsKey]&&m[d.elementsKey].length&&(R.push(N(m[d.elementsKey],d,b+1)),e=m,i=m.name),R.push(d.spaces&&M(m,d)?`
|
|
16
|
+
`+Array(b+1).join(d.spaces):""),R.push("</"+U+">")):R.push("/>"),R.join("")}function N(m,d,b,R){return m.reduce(function(U,k){var g=c(d,b,R&&!U);switch(k.type){case"element":return U+g+F(k,d,b);case"comment":return U+g+S(k[d.commentKey],d);case"doctype":return U+g+C(k[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?g:"")+x(k[d.cdataKey],d);case"text":return U+(d.indentText?g:"")+T(k[d.textKey],d);case"instruction":var V={};return V[k[d.nameKey]]=k[d.attributesKey]?k:k[d.instructionKey],U+(d.indentInstruction?g:"")+y(V,d,b)}},"")}function O(m,d,b){var R;for(R in m)if(m.hasOwnProperty(R))switch(R){case d.parentKey:case d.attributesKey:break;case d.textKey:if(d.indentText||b)return!0;break;case d.cdataKey:if(d.indentCdata||b)return!0;break;case d.instructionKey:if(d.indentInstruction||b)return!0;break;case d.doctypeKey:case d.commentKey:return!0;default:return!0}return!1}function _(m,d,b,R,U){e=m,i=d;var k="elementNameFn"in b?b.elementNameFn(d,m):d;if(typeof m>"u"||m===null||m==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(d,m)||b.fullTagEmptyElement?"<"+k+"></"+k+">":"<"+k+"/>";var g=[];if(d){if(g.push("<"+k),typeof m!="object")return g.push(">"+T(m,b)+"</"+k+">"),g.join("");m[b.attributesKey]&&g.push(a(m[b.attributesKey],b,R));var V=O(m,b,!0)||m[b.attributesKey]&&m[b.attributesKey]["xml:space"]==="preserve";if(V||("fullTagEmptyElementFn"in b?V=b.fullTagEmptyElementFn(d,m):V=b.fullTagEmptyElement),V)g.push(">");else return g.push("/>"),g.join("")}return g.push(v(m,b,R+1,!1)),e=m,i=d,d&&g.push((U?c(b,R,!1):"")+"</"+k+">"),g.join("")}function v(m,d,b,R){var U,k,g,V=[];for(k in m)if(m.hasOwnProperty(k))for(g=t(m[k])?m[k]:[m[k]],U=0;U<g.length;++U){switch(k){case d.declarationKey:V.push(o(g[U],d,b));break;case d.instructionKey:V.push((d.indentInstruction?c(d,b,R):"")+y(g[U],d,b));break;case d.attributesKey:case d.parentKey:break;case d.textKey:V.push((d.indentText?c(d,b,R):"")+T(g[U],d));break;case d.cdataKey:V.push((d.indentCdata?c(d,b,R):"")+x(g[U],d));break;case d.doctypeKey:V.push(c(d,b,R)+C(g[U],d));break;case d.commentKey:V.push(c(d,b,R)+S(g[U],d));break;default:V.push(c(d,b,R)+_(g[U],k,d,b,O(g[U],d)))}R=R&&!V.length}return V.join("")}return ue=function(m,d){d=s(d);var b=[];return e=m,i="_root_",d.compact?b.push(v(m,d,0,!0)):(m[d.declarationKey]&&b.push(o(m[d.declarationKey],d,0)),m[d.elementsKey]&&m[d.elementsKey].length&&b.push(N(m[d.elementsKey],d,0,!b.length))),b.join("")},ue}var he,Ge;function xi(){if(Ge)return he;Ge=1;var h=Ye();return he=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return h(i,e)},he}var fe,Ve;function Ei(){if(Ve)return fe;Ve=1;var h=Ue(),t=yi(),e=Ye(),i=xi();return fe={xml2js:h,xml2json:t,js2xml:e,json2xml:i},fe}var de=Ei(),wi=Me();const ft=class ft{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{var y,S;if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let a={...s,...c,...ft.propToNumber(c,["version","width","height","tilewidth","tileheight","nextlayerid","nextobjectid","hexsidelength","opacity","x","y","offsetx","offsety","startx","starty","id","firstgid","imageheight","imagewidth","margin","columns","rows","tilecount","rotation","gid","tileid","duration","parallaxx","parallaxy","repeatx","repeaty","pixelsize"]),...ft.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(a.properties){const x=ft.toArray(a.properties.property),C={};for(let T of x){const M=T._attributes;if(!M)continue;let F;switch(M.type){case"file":F=this.getImagePath(M.value);break;case"object":case"float":case"int":F=+M.value;break;case"bool":F=M.value=="true";break;case"class":F={...((y=this.transform(T))==null?void 0:y.properties)??{},_classname:M.propertytype};break;default:F=M.value}C[M.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=ft.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:Se(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let a=0;a<i;a+=4)c[s]=t.readUInt32LE(a),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?ft.unpackTileBytes(wi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=de.xml2js(this.xml,{compact:!0}),e=de.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=S=>{const{objectgroup:x,group:C,layer:T,imagelayer:M}=S,F=N=>{N&&ft.toArray(N).forEach(O=>{if(this.layers.has(+O._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${O._attributes.id} already exists`);this.layers.set(+O._attributes.id,O)})};F(x),F(T),F(C),F(M),C&&s(C)};s(t.map);const c=(S,x=[])=>{var C;if(!S)return x;for(let T of S){const{name:M}=T;if(!["layer","group","imagelayer","objectgroup"].includes(M))continue;const F=(C=T.elements)==null?void 0:C.find(O=>O.name=="data");T.layer=this.layers.get(+T.attributes.id);const N={...this.transform(F)??{},...this.transform(T),...this.transform(T.layer),layers:c(T.elements),data:F?F.elements[0].text:void 0,type:M=="layer"?"tilelayer":M};delete N.elements,delete N.layer,N.data&&(N.data=ft.decode(N,N.width*N.height)),x.push(N)}return x},a=c(e.elements[0].elements),o=ft.toArray(i).map(S=>this.transform(S)),y={...this.transform(t.map),layers:a,tilesets:o};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=de.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:ft.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=ft.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};ft.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},ft.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let pe=ft;class me{constructor(t){this.properties={},this.properties=(t==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 vi=2147483648,bi=1073741824,Ai=536870912,Ti=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&vi)}get verticalFlip(){return!!(this._gid&bi)}get diagonalFlip(){return!!(this._gid&Ai)}get rotatedHex120(){return!!(this._gid&Ti)}get gid(){return Lt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends Lt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Si extends Lt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t!=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=Lt.getRealGid(t),c=ge.findTileSet(s,this.tilesets);if(!c)return;const a=c.getTile(s-c.firstgid);return a?new _e({...a.tile,gid:t,index:e,layerIndex:i}):new _e({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Si(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class Ci extends me{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new _e(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class At{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=o=>At.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const y=new pe(o,t,this.basePath);if(e=="map"){const S=y.parseMap();return i(S)}else if(e=="tileset"){const S=y.parseTileset();return i(S)}}return i(JSON.parse(o))};if(At.typeOfFile(t).isObject)return i(t);const{isHttp:a}=At.typeOfFile(t);if(s(t))c(t);else if(a||At.isBrowser()){let o=a?t:Se(this.basePath,t);At.isBrowser()&&window.urlCache&&(o=window.urlCache[t]),fetch(o,{headers:{"Content-Type":"application/xml"}}).then(y=>y.text()).then(c).catch(y=>i(null,y))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&At.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,a)=>{let o=!1;if(a)return t(null,a);if(c.tilesets){const y=[],S=()=>{x++,x==c.tilesets.length&&!o&&(c.tilesets=y,t(c))};let x=0;for(let C=0;C<c.tilesets.length;C++){const T=c.tilesets[C];if(!T.source||T.tiles||T.image||T.tile){y[C]=T,S();continue}i&&At.typeOfFile(T.source).isPath&&(T.source=s(T.source)),this._parseFile(T.source,"tileset",(M,F)=>{if(F)return o=!0,t(null,F);y[C]={...M,firstgid:T.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 Ii=Object.defineProperty,Bi=(h,t,e)=>t in h?Ii(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ct=(h,t,e)=>(Bi(h,typeof t!="symbol"?t+"":t,e),e);const Yt=class Kt extends P.Geometry{constructor(t){const e=new P.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:P.BufferUsage.VERTEX|P.BufferUsage.COPY_DST,shrinkToFit:!1}),i=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 Mi=Yt;var Fi=Object.defineProperty,Di=(h,t,e)=>t in h?Fi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,It=(h,t,e)=>(Di(h,typeof t!="symbol"?t+"":t,e),e);class qe{constructor(){It(this,"pipe_uniforms",new P.UniformGroup({u_proj_trans:{value:new P.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class Ke{constructor(t,e){It(this,"renderer"),It(this,"tileAnim",[0,0]),It(this,"ibLen",0),It(this,"indexBuffer",null),It(this,"shader"),It(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new P.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:P.BufferUsage.INDEX|P.BufferUsage.COPY_DST}),this.indexBuffer.destroy=P.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Mi(this.indexBuffer);return t.lastTimeAccess=Date.now(),t}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(t){const e=t*6;e<=this.ibLen||(this.ibLen=e,this.indexBuffer.data=Ni(t,St.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:a}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),a[0]=c[0],a[1]=c[1],e.update(),this.adaptor.execute(this,t)}}It(Ke,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function Ni(h,t){const e=h*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var Oi=Object.defineProperty,Pi=(h,t,e)=>t in h?Oi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vt=(h,t,e)=>(Pi(h,typeof t!="symbol"?t+"":t,e),e);class Ot{constructor(t){vt(this,"max_textures"),vt(this,"arr",[]),vt(this,"count",0),vt(this,"dirty",!1),vt(this,"dirty_gpu",!1),vt(this,"bind_group",null),vt(this,"bind_group_resources",{}),vt(this,"tex_sizes",null),vt(this,"null_color",new Float32Array([0,0,0,.5])),vt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new P.Buffer({usage:P.BufferUsage.UNIFORM|P.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let 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 P.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let a=0;a<e;a++){const o=(a<s?i[a]:null)||P.Texture.EMPTY.source;t[c++]=o.source,t[c++]=o.style}return this.bind_group||(this.bind_group=new P.BindGroup(t)),this.bind_group}static generate_gpu_textures(t){const e=[];e.push("struct TextureArrayFields {"),e.push(` u_texture_size: array<vec4f, ${t}>,`),e.push(" u_null_color: vec4f"),e.push("}"),e.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let i=0;i<t;i++)e.push(`@group(1) @binding(${i*2+1}) var u_texture_${i}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i*2+2}) var u_sampler_${i}: sampler;`);e.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),e.push("switch texture_id {");for(let i=0;i<t;i++)e.push(` case ${i}: { return textureSampleGrad(u_texture_${i}, u_sampler_${i}, uv, dx, dy); }`);return e.push(" default: { return taf.u_null_color; }"),e.push("} }"),e.join(`
|
|
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 Ri=Object.defineProperty,Ui=(h,t,e)=>t in h?Ri(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ye=(h,t,e)=>(Ui(h,typeof t!="symbol"?t+"":t,e),e);const ki=`
|
|
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
|
+
`,Li=`
|
|
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 ze extends qe{constructor(){super(...arguments),ye(this,"_shader",null),ye(this,"max_textures",St.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),a=s.resources.texture_uniforms;a.uniforms.u_texture_size!==c.tex_sizes&&(a.uniforms.u_texture_size=c.tex_sizes,a.update());for(let o=0;o<c.length;o++)i.texture.bind(c.arr[o],o);i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({glProgram:P.GlProgram.from({vertex:ki,fragment:Li.replace("//include_textures",Ot.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new P.UniformGroup(Ot.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}ye(ze,"extension",{type:[P.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Yi=Object.defineProperty,Gi=(h,t,e)=>t in h?Yi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Xt=(h,t,e)=>(Gi(h,typeof t!="symbol"?t+"":t,e),e);const Vi=`
|
|
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
|
+
`,qi=`
|
|
116
116
|
//include_textures
|
|
117
117
|
|
|
118
118
|
@fragment
|
|
@@ -129,7 +129,7 @@ fn mainFrag(
|
|
|
129
129
|
var color = sampleMultiTexture(vTextureId, uv, dx, dy);
|
|
130
130
|
return color * vAlpha;
|
|
131
131
|
};
|
|
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=`
|
|
132
|
+
`;class je extends qe{constructor(){super(...arguments),Xt(this,"_shader",null),Xt(this,"max_textures",St.TEXTURES_PER_TILEMAP),Xt(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({gpuProgram:P.GpuProgram.from({vertex:{source:Vi,entryPoint:"mainVert"},fragment:{source:qi.replace("//include_textures",Ot.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}Xt(je,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Ki=Object.defineProperty,zi=(h,t,e)=>t in h?Ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,at=(h,t,e)=>(zi(h,typeof t!="symbol"?t+"":t,e),e),We=(h=>(h[h.U=0]="U",h[h.V=1]="V",h[h.X=2]="X",h[h.Y=3]="Y",h[h.TILE_WIDTH=4]="TILE_WIDTH",h[h.TILE_HEIGHT=5]="TILE_HEIGHT",h[h.ROTATE=6]="ROTATE",h[h.ANIM_X=7]="ANIM_X",h[h.ANIM_Y=8]="ANIM_Y",h[h.TEXTURE_INDEX=9]="TEXTURE_INDEX",h[h.ANIM_COUNT_X=10]="ANIM_COUNT_X",h[h.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",h[h.ANIM_DIVISOR=12]="ANIM_DIVISOR",h[h.ALPHA=13]="ALPHA",h))(We||{});const gt=Object.keys(We).length/2;class Xe extends P.ViewContainer{constructor(t){super({}),at(this,"shadowColor",new Float32Array([0,0,0,.5])),at(this,"state",P.State.for2d()),at(this,"is_valid",!1),at(this,"renderPipeId","tilemap"),at(this,"canBundle",!0),at(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),at(this,"tileAnim",null),at(this,"rects_count",0),at(this,"compositeParent",!1),at(this,"tileset",new Ot(St.TEXTURES_PER_TILEMAP)),at(this,"tilemapBounds",new P.Bounds),at(this,"hasAnimatedTile",!1),at(this,"pointsBuf",[]),at(this,"batched"),at(this,"vbId",0),at(this,"vb",null),at(this,"vbBuffer",null),at(this,"vbArray",null),at(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){var i,s;let e=this.tileset;if(t instanceof Ot)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof P.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Ot(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 Ot(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 d;typeof t=="string"?d=P.Texture.from(t):d=t;const b=this.tileset;for(let R=0;R<b.count;R++)if(b.arr[R]===d.source){a=R;break}"frame"in d&&(s.u=s.u??d.frame.x,s.v=s.v??d.frame.y,s.tileWidth=s.tileWidth??d.orig.width,s.tileHeight=s.tileHeight??d.orig.height),c=d.source}if(!o&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:y=0,v:S=0,tileWidth:x=c.width,tileHeight:C=c.height,animX:T=0,animY:M=0,rotate:F=0,animCountX:N=1024,animCountY:O=1024,animDivisor:_=1,alpha:v=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||T>0||M>0,m.push(y),m.push(S),m.push(e),m.push(i),m.push(x),m.push(C),m.push(F),m.push(T|0),m.push(M|0),m.push(a),m.push(N),m.push(O),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 T=s.stride;for(;T<o;)T*=2;this.vbBuffer=new ArrayBuffer(T),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const y=this.vbArray,S=this.vbInts;let x=0,C=0;for(let T=0;T<e.length;T+=gt){this.compositeParent&&(C=e[T+9]);const F=e[T+2],N=e[T+3],O=e[T+4],_=e[T+5],v=e[T+0],m=e[T+1];let d=e[T+6];const b=e[T+7],R=e[T+8],U=e[T+10]||1024,k=e[T+11]||1024,g=b+U*2048,V=R+k*2048,rt=e[T+12],K=e[T+13];let W,lt,ot,ht,L,st,$,et;if(d===0)W=v,lt=m,ot=v+O,ht=m,L=v+O,st=m+_,$=v,et=m+_;else{let Y=O/2,H=_/2;d%4!==0&&(Y=_/2,H=O/2);const Tt=v+Y,bt=m+H;d=P.groupD8.add(d,P.groupD8.NW),W=Tt+Y*P.groupD8.uX(d),lt=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),ot=Tt+Y*P.groupD8.uX(d),ht=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),L=Tt+Y*P.groupD8.uX(d),st=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),$=Tt+Y*P.groupD8.uX(d),et=bt+H*P.groupD8.uY(d)}y[x++]=F,y[x++]=N,y[x++]=W,y[x++]=lt,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F+O,y[x++]=N,y[x++]=ot,y[x++]=ht,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F+O,y[x++]=N+_,y[x++]=L,y[x++]=st,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F,y[x++]=N+_,y[x++]=$,y[x++]=et,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K}a.data=y}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,y=0,S=0,x=0,C=1024,T=1024,M=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:a,tileHeight:o,animX:y,animY:S,rotate:x,animCountX:C,animCountY:T,animDivisor:M,alpha:F})}}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,Gt=(h,t,e)=>(Wi(h,typeof t!="symbol"?t+"":t,e),e);class Xi extends P.Container{constructor(t){super(),Gt(this,"texturesPerTilemap"),Gt(this,"tileAnim",null),Gt(this,"lastModifiedTilemap",null),Gt(this,"modificationMarker",0),Gt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=St.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const a=new Xe(t.slice(c*e,(c+1)*e));a.compositeParent=!0,this.addChild(a)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const a=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let y=0;if(c=a[o],c)y=t%this.texturesPerTilemap;else{if(c=a[0],!c)return this;y=0}c.tile(y,e,i,s)}else{typeof t=="string"&&(t=P.Texture.from(t));for(let o=0;o<a.length;o++){const y=a[o],S=y.getTileset().arr;for(let x=0;x<S.length;x++)if(S[x]===t.source){c=y;break}if(c)break}if(!c){for(let o=a.length-1;o>=0;o--){const y=a[o];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new Xe(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,a,o,y,S){return this.tile(t,e,i,{animX:s,animY:c,animCountX:a,animCountY:o,animDivisor:y,alpha:S})}addRect(t,e,i,s,c,a,o,y,S,x,C,T){const M=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[M]&&this.children[M].getTileset().count>0?(this.lastModifiedTilemap=this.children[M],this.lastModifiedTilemap.addRect(F,e,i,s,c,a,o,y,S,x,C,T)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(Ke),P.extensions.add(ze),P.extensions.add(je);class $t extends P.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=P.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(P.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(P.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(P.groupD8.MAIN_DIAGONAL):i(P.groupD8.REVERSE_DIAGONAL))}}St.use32bitIndex=!0;class xe extends D.DisplayObject(Xi){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:a,tileheight:o,width:y}=this._layer;s&&(t=Math.floor(t/a),e=Math.floor(e/o));const S=t+e*y,x=this._layer.getTileByIndex(S);if(!x||x&&x.gid==0)return;const C=xe.findTileSet(x.gid,this.tileSets);if(!C)return;const T=new $t(x,C);if(T.x=t*a,T.y=e*o+(o-T.texture.height),T._x=t,T._y=e,C.tileoffset&&(T.x+=C.tileoffset.x??0,T.y+=C.tileoffset.y??0),!(c&&!c(T)))return T}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new ge({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",xe);function $i(h){return D.createComponent("CompositeTileLayer",h)}class Hi extends Ci{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await P.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let s=this.margin;s<this.image.width;s+=this.tilewidth+this.spacing)this.textures.push(new P.Texture({source:e.source,frame:new P.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Qi(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 y;if(Array.isArray(a.data))y=a.data.map(x=>typeof x=="number"?x:parseInt(String(x),10));else{i.push(a);continue}for(let x=0;x<y.length;x++){const C=y[x];if(C===0)continue;let T;for(let O=t.length-1;O>=0;O--)if(t[O].firstgid&&t[O].firstgid<=C){T=t[O];break}if(!T){o.has(0)||o.set(0,new Array(y.length).fill(0)),o.get(0)[x]=C;continue}const M=C-T.firstgid,F=(c=(s=T.tileset.tiles)==null?void 0:s[M])==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(y.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(T=>T!==0)){const T={...a,name:`${a.name}_z${x}`,data:C,properties:{...a.properties,z:x}};i.push(T)}}}return i.sort((a,o)=>{var x,C;const y=((x=a.properties)==null?void 0:x.z)??.5,S=((C=o.properties)==null?void 0:C.z)??.5;return y-S}),i}function Ji(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let a=[],o={};const y=async(x,C="")=>typeof x!="string"?x:await new At(x,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const x=t();if(x){o=await y(x,e()),a=[];for(let T of o.tilesets)T.tile&&(T.tiles=T.tile),T.tiles||(T.tiles=[]),a.push(await new Hi(T).load(T.image.source));let C=o.layers;i()&&(C=Qi(o.layers,a)),s.set(C)}});const S=(x,C={})=>D.h(D.Container,C,D.loop(x,T=>{switch(T.type){case Rt.Tile:return D.h($i,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...T,tilesets:a});case Rt.Image:const{width:M,height:F,source:N}=T.image;return D.h(D.TilingSprite,{image:N,...T,width:T.repeatx?T.width*T.tilewidth:M,height:T.repeaty?T.height*T.tileheight:F});case Rt.Group:return S(D.signal(T.layers),T);case Rt.ObjectGroup:const O=c==null?void 0:c(T);return D.h(D.Container,T,O);default:return D.h(D.Container)}}));return D.h(D.Container,h,S(s))}function Zi(){const h=`
|
|
133
133
|
precision mediump float;
|
|
134
134
|
attribute vec2 aPosition;
|
|
135
135
|
attribute vec2 aUV;
|
|
@@ -272,7 +272,7 @@ fn mainFrag(
|
|
|
272
272
|
|
|
273
273
|
gl_FragColor = vec4(rainColor * rain, alpha);
|
|
274
274
|
}
|
|
275
|
-
`;return new
|
|
275
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}function tr(){const h=`
|
|
276
276
|
precision mediump float;
|
|
277
277
|
attribute vec2 aPosition;
|
|
278
278
|
attribute vec2 aUV;
|
|
@@ -416,7 +416,7 @@ fn mainFrag(
|
|
|
416
416
|
|
|
417
417
|
gl_FragColor = vec4(snowColor * snow, snow * 0.9);
|
|
418
418
|
}
|
|
419
|
-
`;return new
|
|
419
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}function er(){const h=`
|
|
420
420
|
precision mediump float;
|
|
421
421
|
attribute vec2 aPosition;
|
|
422
422
|
attribute vec2 aUV;
|
|
@@ -523,5 +523,5 @@ fn mainFrag(
|
|
|
523
523
|
|
|
524
524
|
gl_FragColor = vec4(color, alpha);
|
|
525
525
|
}
|
|
526
|
-
`;return new
|
|
526
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}const $e=h=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:s=D.signal(.2),density:c=D.signal(120),maxDrops:a=D.signal(80),height:o=D.signal(.2),scale:y=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(ht=>{const L=ht.props.context;L!=null&&L.canvasSize&&t(()=>{const st=L.canvasSize();st&&st.width>0&&st.height>0&&x.set([st.width,st.height])})});const T=typeof e=="function"?e:D.signal(e),M=typeof i=="function"?i:D.signal(i),F=typeof s=="function"?s:D.signal(s),N=typeof c=="function"?c:D.signal(c),O=typeof a=="function"?a:D.signal(a),_=typeof o=="function"?o:D.signal(o),v=typeof y=="function"?y:D.signal(y);let m,d;if(t()==="rain")m=Zi(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uRainSpeed:{value:T(),type:"f32"},uWindDirection:{value:M(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uRainDensity:{value:N(),type:"f32"},uMaxDrops:{value:O(),type:"f32"}};else if(t()==="snow")m=tr(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSnowSpeed:{value:T(),type:"f32"},uWindDirection:{value:M(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uSnowDensity:{value:N(),type:"f32"},uMaxFlakes:{value:O(),type:"f32"}};else if(t()==="fog")m=er(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSpeed:{value:T(),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 P.UniformGroup(d),R=new P.Shader({glProgram:m,resources:{uniforms:b}}),U=new P.Geometry({attributes:{aPosition:[-1,-1,1,-1,1,1,-1,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let k=Math.random()*10,g=[...C()],V=M(),rt=F(),K=T(),W=N(),lt=O();_();let ot=v();return D.tick(({deltaTime:ht})=>{k+=ht/600,b.uniforms.uTime=k;const L=C();(L[0]!==g[0]||L[1]!==g[1])&&(b.uniforms.uResolution=L,g=[...L]);const st=M();if(st!==V&&(b.uniforms.uWindDirection=st,V=st),t()==="rain"||t()==="snow"){const $=F();$!==rt&&(b.uniforms.uWindStrength=$,rt=$)}if(t()==="rain"){const $=T();$!==K&&(b.uniforms.uRainSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uRainDensity=et,W=et);const Y=O();Y!==lt&&(b.uniforms.uMaxDrops=Y,lt=Y)}else if(t()==="snow"){const $=T();$!==K&&(b.uniforms.uSnowSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uSnowDensity=et,W=et);const Y=O();Y!==lt&&(b.uniforms.uMaxFlakes=Y,lt=Y)}else if(t()==="fog"){const $=T();$!==K&&(b.uniforms.uSpeed=$,K=$);const et=v();et!==ot&&(b.uniforms.uScale=et,ot=et);const Y=N();Y!==W&&(b.uniforms.uDensity=Y,W=Y)}}),D.h(D.Mesh,{geometry:U,shader:R,width:"100%",height:"100%"})},ir=$e;return xt.Bar=Je,xt.LightSpot=li,xt.Loading=ui,xt.NightAmbiant=ci,xt.Particle=oi,xt.TiledMap=Ji,xt.Weather=ir,xt.WeatherEffect=$e,Object.defineProperty(xt,Symbol.toStringTag,{value:"Module"}),xt}({},CanvasEngine,PIXI);
|
|
527
527
|
//# sourceMappingURL=index.global.js.map
|