@canvasengine/presets 2.0.0-beta.6 → 2.0.0-beta.60

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.
Files changed (65) hide show
  1. package/dist/Bar.d.ts +14 -0
  2. package/dist/Bar.d.ts.map +1 -0
  3. package/dist/Button.d.ts +1 -0
  4. package/dist/Button.d.ts.map +1 -0
  5. package/dist/FogOfWar.d.ts +38 -0
  6. package/dist/FogOfWar.d.ts.map +1 -0
  7. package/dist/Footprints.d.ts +50 -0
  8. package/dist/Footprints.d.ts.map +1 -0
  9. package/dist/Loading.d.ts +94 -0
  10. package/dist/Loading.d.ts.map +1 -0
  11. package/dist/NightAmbiant.d.ts +141 -0
  12. package/dist/NightAmbiant.d.ts.map +1 -0
  13. package/dist/Particle.d.ts +2 -0
  14. package/dist/Particle.d.ts.map +1 -0
  15. package/dist/SpriteShadows.d.ts +60 -0
  16. package/dist/SpriteShadows.d.ts.map +1 -0
  17. package/dist/Tilemap/Tile.d.ts +23 -0
  18. package/dist/Tilemap/Tile.d.ts.map +1 -0
  19. package/dist/Tilemap/TileGroup.d.ts +62 -0
  20. package/dist/Tilemap/TileGroup.d.ts.map +1 -0
  21. package/dist/Tilemap/TileSet.d.ts +11 -0
  22. package/dist/Tilemap/TileSet.d.ts.map +1 -0
  23. package/dist/Tilemap/index.d.ts +2 -0
  24. package/dist/Tilemap/index.d.ts.map +1 -0
  25. package/dist/Weathers/fog.d.ts +4 -0
  26. package/dist/Weathers/fog.d.ts.map +1 -0
  27. package/dist/Weathers/index.d.ts +382 -0
  28. package/dist/Weathers/index.d.ts.map +1 -0
  29. package/dist/Weathers/rain.d.ts +3 -0
  30. package/dist/Weathers/rain.d.ts.map +1 -0
  31. package/dist/Weathers/snow.d.ts +7 -0
  32. package/dist/Weathers/snow.d.ts.map +1 -0
  33. package/dist/fx/Fx.d.ts +2 -0
  34. package/dist/fx/Fx.d.ts.map +1 -0
  35. package/dist/fx/index.d.ts +5 -0
  36. package/dist/fx/index.d.ts.map +1 -0
  37. package/dist/fx/presets.d.ts +365 -0
  38. package/dist/fx/presets.d.ts.map +1 -0
  39. package/dist/fx/runtime.d.ts +28 -0
  40. package/dist/fx/runtime.d.ts.map +1 -0
  41. package/dist/fx/textures.d.ts +7 -0
  42. package/dist/fx/textures.d.ts.map +1 -0
  43. package/dist/fx/types.d.ts +93 -0
  44. package/dist/fx/types.d.ts.map +1 -0
  45. package/dist/fx/utils.d.ts +10 -0
  46. package/dist/fx/utils.d.ts.map +1 -0
  47. package/dist/index.d.ts +11 -54
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.global.js +579 -0
  50. package/dist/index.global.js.map +1 -0
  51. package/dist/index.js +5356 -764
  52. package/dist/index.js.map +1 -1
  53. package/package.json +35 -16
  54. package/src/Bar.ts +0 -87
  55. package/src/Button.ts +0 -0
  56. package/src/DrawMap/index.ts +0 -60
  57. package/src/Joystick.ts +0 -284
  58. package/src/NightAmbiant.ts +0 -116
  59. package/src/Particle.ts +0 -50
  60. package/src/Tilemap/Tile.ts +0 -79
  61. package/src/Tilemap/TileGroup.ts +0 -207
  62. package/src/Tilemap/TileLayer.ts +0 -162
  63. package/src/Tilemap/TileSet.ts +0 -41
  64. package/src/Tilemap/index.ts +0 -79
  65. package/src/index.ts +0 -6
@@ -0,0 +1,579 @@
1
+ var CanvasEnginePresets=(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e){var t=e.toString(16);return t.length==1?`0`+t:t}function i(e,t,n){return`#`+r(e)+r(t)+r(n)}function a(e){let{width:n,height:r,value:a,maxValue:o,backgroundColor:s,foregroundColor:c,border:l,innerMargin:u,borderRadius:d}=(0,t.useProps)(e,{backgroundColor:`#000000`,foregroundColor:`#FFFFFF`,innerMargin:0,borderRadius:0});return(0,t.h)(t.Graphics,{...e,width:n,height:r,draw(e){d()?e.roundRect(0,0,n(),r(),d()):e.rect(0,0,n(),r()),l&&e.stroke(l),e.fill(s())}},(0,t.h)(t.Graphics,{width:n,height:r,draw(e){let t=u(),s=d(),l=Math.max(0,Math.min(n()-2*t,a()/o()*(n()-2*t))),f=r()-2*t;d?e.roundRect(t,t,l,f,s):e.rect(t,t,l,f);let p=c();if(p.startsWith(`rgba`)){let[t,n,r,a]=p.match(/\d+(\.\d+)?/g).map(Number);e.fill({color:i(t,n,r),alpha:a})}else e.fill(p)}}))}var o={hitSpark:{duration:180,emitters:[{burst:18,angle:[0,360],speed:[120,340],particle:{shape:`spark`,lifetime:[160,340],color:[`#fff4a8`,`#ff7a2f`],alpha:[1,0],scale:[.18,0],rotationSpeed:[-480,480],blendMode:`add`,ease:`outCubic`}}]},slashSpark:{duration:160,emitters:[{burst:22,angle:[-12,12],speed:[180,430],spreadX:10,spreadY:3,particle:{shape:`spark`,lifetime:[110,260],color:[`#ffffff`,`#ffcf5a`],alpha:[1,0],scale:[.16,0],rotation:[-8,8],rotationSpeed:[-260,260],blendMode:`add`,ease:`outCubic`}},{burst:8,angle:[150,210],speed:[60,160],particle:{shape:`star`,lifetime:[140,320],color:[`#fff8cc`,`#ff8f3d`],alpha:[.85,0],scale:[.12,.4],blendMode:`add`,ease:`outQuad`}}]},impactBurst:{duration:260,emitters:[{burst:24,angle:[0,360],speed:[130,280],particle:{shape:`spark`,lifetime:[180,420],color:[`#fff3ba`,`#d64d27`],alpha:[1,0],scale:[.2,0],rotationSpeed:[-360,360],blendMode:`add`,ease:`outCubic`}},{burst:10,angle:[0,360],speed:[30,90],particle:{shape:`softCircle`,lifetime:[220,520],color:[`#ffd18a`,`#6d3a2a`],alpha:[.38,0],scale:[.28,1.15],ease:`outQuad`}}]},smokePuff:{duration:260,emitters:[{burst:16,angle:[-130,-50],speed:[12,58],spreadX:10,spreadY:6,gravity:-10,particle:{shape:`softCircle`,lifetime:[520,940],color:[`#8f8f8f`,`#4f4f4f`],alpha:[.38,0],scale:[.45,1.85],rotationSpeed:[-40,40],ease:`outQuad`}}]},dustStep:{duration:160,emitters:[{burst:10,angle:[-170,-10],speed:[18,86],spreadX:8,spreadY:3,particle:{shape:`softCircle`,lifetime:[260,520],color:`#b99a6a`,alpha:[.26,0],scale:[.22,.9],ease:`outQuad`}}]},dashDust:{duration:220,emitters:[{burst:22,angle:[155,205],speed:[70,190],spreadX:18,spreadY:5,particle:{shape:`softCircle`,lifetime:[300,640],color:[`#cfb07c`,`#8f744f`],alpha:[.34,0],scale:[.28,1.2],ease:`outCubic`}},{burst:9,angle:[168,192],speed:[150,330],spreadX:10,particle:{shape:`spark`,lifetime:[120,280],color:`#d9c08a`,alpha:[.42,0],scale:[.12,0],ease:`outCubic`}}]},magicBurst:{duration:360,emitters:[{burst:32,angle:[0,360],speed:[70,220],particle:{shape:`star`,lifetime:[420,840],color:[`#77e5ff`,`#b970ff`],alpha:[.95,0],scale:[.18,.75],rotationSpeed:[-220,220],blendMode:`add`,ease:`outCubic`}}]},healPulse:{duration:520,emitters:[{burst:18,angle:[-120,-60],speed:[28,86],spreadX:20,spreadY:10,gravity:-16,particle:{shape:`star`,lifetime:[520,980],color:[`#d9ffe6`,`#55e68a`],alpha:[.85,0],scale:[.18,.62],rotationSpeed:[-120,120],blendMode:`add`,ease:`outQuad`}},{burst:10,angle:[-105,-75],speed:[12,42],spreadX:16,particle:{shape:`softCircle`,lifetime:[620,1100],color:[`#9fffc5`,`#3edc7c`],alpha:[.3,0],scale:[.3,1],blendMode:`add`,ease:`outQuad`}}]},campfire:{duration:1e3,emitters:[{loop:!0,rate:38,angle:[-110,-70],speed:[16,54],spreadX:8,spreadY:3,particle:{shape:`softCircle`,lifetime:[360,720],color:[`#ffd36d`,`#ff4b1f`],alpha:[.8,0],scale:[.25,1.05],blendMode:`add`,ease:`outQuad`}},{loop:!0,rate:12,angle:[-115,-65],speed:[10,30],particle:{shape:`softCircle`,lifetime:[620,1100],color:`#555555`,alpha:[.18,0],scale:[.35,1.4],ease:`outQuad`}}]},torchFire:{duration:1e3,emitters:[{loop:!0,rate:24,angle:[-104,-76],speed:[12,42],spreadX:4,spreadY:2,particle:{shape:`softCircle`,lifetime:[280,560],color:[`#fff09a`,`#ff5a22`],alpha:[.75,0],scale:[.16,.72],blendMode:`add`,ease:`outQuad`}},{loop:!0,rate:7,angle:[-112,-68],speed:[8,26],particle:{shape:`softCircle`,lifetime:[520,960],color:`#4f4f4f`,alpha:[.13,0],scale:[.22,.9],ease:`outQuad`}}]},pickup:{duration:320,emitters:[{burst:14,angle:[210,330],speed:[70,170],particle:{shape:`star`,lifetime:[260,620],color:[`#ffffff`,`#ffe66d`],alpha:[1,0],scale:[.2,.65],blendMode:`add`,ease:`outCubic`}}]},levelUp:{duration:820,emitters:[{burst:30,angle:[-105,-75],speed:[80,210],spreadX:34,spreadY:10,gravity:-24,particle:{shape:`star`,lifetime:[620,1180],color:[`#ffffff`,`#ffe870`],alpha:[1,0],scale:[.16,.8],rotationSpeed:[-180,180],blendMode:`add`,ease:`outCubic`}},{duration:420,rate:36,angle:[-98,-82],speed:[90,180],spreadX:26,particle:{shape:`spark`,lifetime:[420,840],color:[`#fff8c8`,`#66d9ff`],alpha:[.75,0],scale:[.12,0],blendMode:`add`,ease:`outCubic`}}]},explosionSmall:{duration:280,emitters:[{burst:28,angle:[0,360],speed:[120,300],particle:{shape:`softCircle`,lifetime:[300,720],color:[`#fff1a6`,`#d34b24`],alpha:[1,0],scale:[.25,1.15],blendMode:`add`,ease:`outCubic`}}]}},s=new Map,c=new Map;function l(e=`softCircle`){return s.has(e)||s.set(e,u(e)),s.get(e)}function u(e){if(typeof document>`u`)return n.Texture.WHITE;let t=document.createElement(`canvas`);t.width=e===`spark`?64:48,t.height=e===`spark`?16:48;let r=t.getContext(`2d`);if(!r)return n.Texture.WHITE;if(r.clearRect(0,0,t.width,t.height),r.fillStyle=`#ffffff`,r.strokeStyle=`#ffffff`,e===`spark`){let e=r.createLinearGradient(0,0,t.width,0);e.addColorStop(0,`rgba(255,255,255,0)`),e.addColorStop(.22,`rgba(255,255,255,1)`),e.addColorStop(1,`rgba(255,255,255,0)`),r.strokeStyle=e,r.lineWidth=4,r.lineCap=`round`,r.beginPath(),r.moveTo(3,t.height/2),r.lineTo(t.width-3,t.height/2),r.stroke()}else if(e===`square`)r.fillRect(8,8,32,32);else if(e===`star`)d(r,24,24,5,20,8);else if(e===`circle`)r.beginPath(),r.arc(24,24,18,0,Math.PI*2),r.fill();else{let e=r.createRadialGradient(24,24,2,24,24,22);e.addColorStop(0,`rgba(255,255,255,1)`),e.addColorStop(.45,`rgba(255,255,255,0.72)`),e.addColorStop(1,`rgba(255,255,255,0)`),r.fillStyle=e,r.fillRect(0,0,t.width,t.height)}return n.Texture.from(t)}function d(e,t,n,r,i,a){e.beginPath();for(let o=0;o<r*2;o++){let s=o%2==0?i:a,c=o*Math.PI/r-Math.PI/2,l=t+Math.cos(c)*s,u=n+Math.sin(c)*s;o===0?e.moveTo(l,u):e.lineTo(l,u)}e.closePath(),e.fill()}async function f(e={}){let t=[];if(e.image&&!c.has(e.image)){let r=n.Assets.load(e.image);c.set(e.image,r),t.push(r.then(t=>{c.set(e.image,t)}))}e.spritesheet&&t.push(Promise.resolve(n.Assets.load(e.spritesheet))),await Promise.all(t)}async function p(e){await Promise.all((e?.emitters??[]).map(e=>f(e.particle)))}function m(e={},t=Math.random){if(e.texture)return[e.texture];if(e.frames?.length){let r=e.frames.map(e=>n.Texture.from(e));return e.frameMode===`random`?[r[Math.floor(t()*r.length)]??r[0]]:r}if(e.frame)return[n.Texture.from(e.frame)];if(e.image){let t=c.get(e.image);return t&&!(t instanceof Promise)?[t]:[]}return[l(e.shape)]}function h(e=Date.now()){let t=e>>>0;return()=>(t=t*1664525+1013904223>>>0,t/4294967296)}function g(e,t,n){return e===void 0?n:Array.isArray(e)?e[0]+(e[1]-e[0])*t():e}function _(e,t){return g(e,t,0)*Math.PI/180}function v(e,t=16777215){if(e===void 0)return t;if(typeof e==`number`)return e;let n=e.trim().replace(`#`,``);return n.length===3?parseInt(n.split(``).map(e=>e+e).join(``),16):parseInt(n,16)}function y(e,t,n){return e+(t-e)*n}function b(e,t,n){let r=e>>16&255,i=e>>8&255,a=e&255,o=t>>16&255,s=t>>8&255,c=t&255,l=Math.round(y(r,o,n)),u=Math.round(y(i,s,n)),d=Math.round(y(a,c,n));return(l<<16)+(u<<8)+d}function x(e,t){let n=Math.max(0,Math.min(1,t));return e===`outQuad`?1-(1-n)*(1-n):e===`outCubic`?1-(1-n)**3:e===`inQuad`?n*n:n}var S=class{constructor(e={}){this.instances=new Set,this.pool=[],this.activeCount=0,this.random=h(e.seed),this.maxParticles=e.maxParticles??600}async preload(e){await p(e)}spawn(e,t,n={}){let r={container:e,preset:t,elapsed:0,loop:!!n.loop,complete:!1,activeParticles:0,emitters:t.emitters.map(e=>({...e,elapsed:0,emittedBurst:!1,carry:0,particles:[]})),options:n,stop:()=>{r.loop=!1,r.complete=!0,r.emitters.forEach(e=>{e.duration=0,e.loop=!1})}};return this.instances.add(r),n.onStart?.(r),r}update(e){let t=Number.isFinite(e)?Math.max(0,e):0;for(let e of Array.from(this.instances))this.updateInstance(e,t)}clear(){for(let e of Array.from(this.instances))this.recycleInstance(e);this.instances.clear()}get activeInstances(){return this.instances.size}updateInstance(e,t){e.elapsed+=t;let n=e.preset.delay??0;if(e.elapsed<n)return;let r=!1,i=!1;for(let n of e.emitters)this.updateEmitter(e,n,t),r||=n.particles.length>0,i||=this.isEmitterActive(e,n);e.activeParticles=e.emitters.reduce((e,t)=>e+t.particles.length,0),!i&&!r&&(e.complete=!0),e.complete&&!r&&(this.instances.delete(e),e.options.onComplete?.(e))}updateEmitter(e,t,n){t.elapsed+=n;let r=t.delay??0;if(t.elapsed>=r&&this.isEmitterActive(e,t)){if(t.burst&&!t.emittedBurst){for(let n=0;n<t.burst;n++)this.spawnParticle(e,t);t.emittedBurst=!0}if(t.rate){t.carry+=t.rate*n/1e3;let r=Math.floor(t.carry);t.carry-=r;for(let n=0;n<r;n++)this.spawnParticle(e,t)}}for(let r=t.particles.length-1;r>=0;r--){let i=t.particles[r];i.age+=n,i.age>=i.lifetime?(this.recycleParticle(e.container,i),t.particles.splice(r,1)):this.updateParticle(i,n)}}isEmitterActive(e,t){if(e.complete)return!1;let n=t.delay??0,r=t.elapsed-n;return r<0?!1:t.burst&&!t.emittedBurst||e.loop||t.loop?!0:r<=(t.duration??e.preset.duration??0)}spawnParticle(e,t){let r=t.maxParticles??e.options.maxParticles??this.maxParticles;if(this.activeCount>=r||t.particles.length>=r)return;let i=t.particle??{},a=m(i,this.random);if(!a.length){if(e.options.missingTexture===`skip`)return;if(e.options.missingTexture===`error`)throw Error(`Fx particle texture is not loaded`);a.push(l(i.shape))}let o=this.pool.pop()??new n.Sprite(n.Texture.WHITE);o.texture=a[0],o.visible=!0,o.anchor.set(i.anchor?.x??.5,i.anchor?.y??.5),o.x=(t.x??0)+g([-(t.spreadX??0),t.spreadX??0],this.random,0),o.y=(t.y??0)+g([-(t.spreadY??0),t.spreadY??0],this.random,0),o.rotation=g(i.rotation,this.random,0)*Math.PI/180,o.blendMode=i.blendMode??`normal`;let s=_(t.angle,this.random),c=g(t.speed,this.random,0),u=i.alpha??[1,0],d=i.scale??[1,0],f=i.tint??i.color??16777215,p=v(Array.isArray(f)?f[0]:f),h=v(Array.isArray(f)?f[1]:f,p),y=g(Array.isArray(d)?d[0]:d,this.random,1),b=Array.isArray(d)?g(d[1],this.random,0):y,x=g(Array.isArray(u)?u[0]:u,this.random,1),S=Array.isArray(u)?g(u[1],this.random,0):x;o.alpha=x,o.tint=p,o.scale.set(y),e.container.addChild(o);let C={sprite:o,age:0,lifetime:g(i.lifetime,this.random,600),vx:Math.cos(s)*c,vy:Math.sin(s)*c,ax:t.accelerationX??0,ay:t.accelerationY??0,gravity:t.gravity??0,startAlpha:x,endAlpha:S,startScale:y,endScale:b,startTint:p,endTint:h,rotationSpeed:g(i.rotationSpeed,this.random,0)*Math.PI/180,frameRate:i.frameRate??12,frames:a,ease:i.ease??`linear`};t.particles.push(C),this.activeCount++,e.options.onParticleSpawn?.(C)}updateParticle(e,t){let n=t/1e3,r=e.age/e.lifetime,i=x(e.ease,r);if(e.vx+=e.ax*n,e.vy+=(e.ay+e.gravity)*n,e.sprite.x+=e.vx*n,e.sprite.y+=e.vy*n,e.sprite.rotation+=e.rotationSpeed*n,e.sprite.alpha=y(e.startAlpha,e.endAlpha,i),e.sprite.scale.set(y(e.startScale,e.endScale,i)),e.sprite.tint=b(e.startTint,e.endTint,i),e.frames.length>1){let t=Math.min(e.frames.length-1,Math.floor(e.age/1e3*e.frameRate)%e.frames.length);e.sprite.texture=e.frames[t]}}recycleParticle(e,t){e.removeChild(t.sprite),t.sprite.visible=!1,t.sprite.alpha=1,t.sprite.tint=16777215,t.sprite.scale.set(1),this.pool.push(t.sprite),this.activeCount=Math.max(0,this.activeCount-1)}recycleInstance(e){for(let t of e.emitters){for(let n of t.particles)this.recycleParticle(e.container,n);t.particles=[]}}},C=e=>typeof e==`function`?e():e;function w(e,t){let n=C(t);if(n)return n;let r=C(e),i=o[r];if(!i)throw Error(`Unknown Fx preset: ${r}`);return i}function T(e){let{name:n,preset:r,trigger:i,autostart:a,loop:o,enabled:s,x:c,y:l,rotation:u,scale:d,alpha:f,seed:p,maxParticles:m,timeScale:h,preload:g,missingTexture:_,onStart:v,onComplete:y,onParticleSpawn:b,...x}=(0,t.useProps)(e,{name:`hitSpark`,autostart:!1,loop:!1,enabled:!0,x:0,y:0,rotation:0,scale:1,alpha:1,timeScale:1,preload:!0,missingTexture:`shape`}),T,E=new S({seed:C(p),maxParticles:C(m)}),D=async(e={})=>{if(!T||!C(s))return;let t=w(n,r);return C(g)&&await E.preload(t),E.spawn(T,t,{loop:C(o),seed:C(p),maxParticles:C(m),missingTexture:C(_),onStart:v,onComplete:y,onParticleSpawn:b,...e})};return(0,t.mount)(e=>(T=e.componentInstance,(C(a)||C(o))&&D(),()=>{E.clear()})),i?.listen&&(0,t.on)(i,async e=>{await D(e)}),(0,t.tick)(({deltaTime:e})=>{E.update((e??16.67)*C(h))}),(0,t.h)(t.Container,{...x,x:c,y:l,rotation:u,scale:d,alpha:f})}function E(e){let{emit:t,...n}=e;return T({...n,trigger:n.trigger??t})}var D=`/**
2
+ * Night + spot light + fog fragment shader.
3
+ * - Supports multiple circular spots (uSpots) in screen-pixel space.
4
+ * - Each spot is vec4(xPx, yPx, radiusPx, intensity).
5
+ * - Fog is based on the nearest light source so illuminated areas stay readable.
6
+ * - Dark zones are tinted with uDarkColor for colored night effects.
7
+ */
8
+ precision highp float;
9
+ precision highp int;
10
+
11
+ in vec2 vTextureCoord;
12
+
13
+ out vec4 finalColor;
14
+
15
+ uniform sampler2D uTexture;
16
+ uniform highp vec4 uInputSize;
17
+ uniform vec4 uSpots[24];
18
+ uniform float uDarkness;
19
+ uniform vec3 uDarkColor;
20
+ uniform vec3 uFogColor;
21
+ uniform float uFogRadius;
22
+ uniform float uFogSoftness;
23
+
24
+ void main() {
25
+ vec4 color = texture(uTexture, vTextureCoord);
26
+ float light = 0.0;
27
+ float nearestDist = 1.0;
28
+ vec2 fragPx = vTextureCoord * uInputSize.xy;
29
+ float minInputDim = max(min(uInputSize.x, uInputSize.y), 1.0);
30
+
31
+ for (int i = 0; i < 24; i++) {
32
+ vec4 spotData = uSpots[i];
33
+ vec2 lightPosPx = spotData.xy;
34
+ float radiusPx = max(spotData.z, 0.0001);
35
+ float intensity = max(spotData.w, 0.0);
36
+ if (intensity <= 0.0001) continue;
37
+
38
+ vec2 deltaPx = fragPx - lightPosPx;
39
+ float distPx = length(deltaPx);
40
+ float spot = (1.0 - smoothstep(0.0, radiusPx, distPx)) * intensity;
41
+ light = clamp(light + spot, 0.0, 1.0);
42
+ nearestDist = min(nearestDist, distPx / minInputDim);
43
+ }
44
+
45
+ // Night: full brightness where light is strong, darker elsewhere.
46
+ // Apply dark color tint in unlit areas.
47
+ float factor = mix(1.0 - uDarkness, 1.0, light);
48
+ vec3 darkened = color.rgb * factor;
49
+ // Blend towards dark color in unlit areas (when factor < 1)
50
+ float darkTint = (1.0 - factor) * uDarkness;
51
+ color.rgb = mix(darkened, uDarkColor, darkTint);
52
+
53
+ // Fog fades in with distance to nearest light, but less inside lit areas.
54
+ float fogFactor = smoothstep(uFogRadius, uFogRadius + uFogSoftness, nearestDist);
55
+ fogFactor *= (1.0 - light * 0.7);
56
+ color.rgb = mix(color.rgb, uFogColor, clamp(fogFactor, 0.0, 1.0));
57
+
58
+ finalColor = color;
59
+ }
60
+ `,O=`/**
61
+ * Default Pixi filter vertex shader.
62
+ * Outputs vTextureCoord (0-1) for sampling the input texture in fragment shader.
63
+ */
64
+ in vec2 aPosition;
65
+ out vec2 vTextureCoord;
66
+
67
+ uniform highp vec4 uInputSize;
68
+ uniform vec4 uOutputFrame;
69
+ uniform vec4 uOutputTexture;
70
+
71
+ vec4 filterVertexPosition(void) {
72
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
73
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
74
+ position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
75
+ return vec4(position, 0.0, 1.0);
76
+ }
77
+
78
+ vec2 filterTextureCoord(void) {
79
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
80
+ }
81
+
82
+ void main(void) {
83
+ gl_Position = filterVertexPosition();
84
+ vTextureCoord = filterTextureCoord();
85
+ }
86
+ `,k=24,A=180,j=.75,M=.5,N=.35,P=new Float32Array([.08,.08,.14]),F=(e,t,n)=>Math.min(Math.max(e,t),n),I=e=>F(e,0,1),L=e=>{if(typeof e==`string`){let t=e.replace(/^#/,``);t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);let n=parseInt(t,16);return new Float32Array([(n>>16&255)/255,(n>>8&255)/255,(n&255)/255])}if(typeof e==`number`)return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]);if(Array.isArray(e)&&e.length>=3){let t=e.every(e=>e<=1);return new Float32Array(t?e:e.map(e=>e/255))}return new Float32Array([0,0,0])};function R(e,t){let r=new Float32Array(k*4),i={value:r,type:`vec4<f32>`,size:k},a={value:I(t?.darkness??j),type:`f32`},o={value:t?.fogColor?L(t.fogColor):P,type:`vec3<f32>`},s={value:t?.fogRadius??M,type:`f32`},c={value:t?.fogSoftness??N,type:`f32`},l={value:t?.darkColor?L(t.darkColor):new Float32Array([0,0,0]),type:`vec3<f32>`},u=t?.spots?[...t.spots]:[],d=t?.lightWorldPosition??null,f=n.Filter.from({gl:{vertex:O,fragment:D},resources:{nightUniforms:{uSpots:i,uDarkness:a,uDarkColor:l,uFogColor:o,uFogRadius:s,uFogSoftness:c}}}),p=f.resources.nightUniforms.uniforms,m=()=>Date.now()/1e3,h=(e,t)=>{let n=p[e];n instanceof Float32Array&&n.length>=t.length?n.set(t):p[e]=t},g=()=>d?[{x:d.x,y:d.y},...u]:u,_=()=>{let n=g(),i=Math.min(n.length,k),a=e?.getVisibleBounds?.()??t?.getBounds?.(),o=!!a&&a.width>0&&a.height>0,s=e?.toScreen?.bind(e),c=o&&typeof s==`function`,l=0,u=0;if(c){let e=s(a.x,a.y);B(e?.x)&&B(e?.y)&&(l=e.x,u=e.y)}let d=m();r.fill(0);for(let e=0;e<i;e++){let t=n[e],i=t.radius??A,f=F(t.intensity??1,0,2),p=t.phase??e*.7,m=f;if(t.flicker){let e=t.flickerSpeed??12;m*=.88+.12*Math.sin(d*e+p)}if(t.pulse){let e=t.pulseSpeed??2;m*=.8+.2*Math.sin(d*e+p)}let h=t.x,g=t.y,_=i;if(c){let e=s(t.x,t.y);h=e.x-l,g=e.y-u}else o&&(h=t.x-a.x,g=t.y-a.y);let v=e*4;r[v]=h,r[v+1]=g,r[v+2]=_,r[v+3]=F(m,0,2)}p.uSpots=r},v=f.apply.bind(f);f.apply=((...e)=>(_(),v(...e)));let y=f;return y.setLightWorldPosition=e=>{d=e,_()},y.getLightWorldPosition=()=>d,y.setSpots=e=>{u=[...e],_()},y.getSpots=()=>g().map(e=>({...e})),y.syncLightToViewport=_,y.setDarkness=e=>{p.uDarkness=I(e)},y.setDarkColor=e=>{h(`uDarkColor`,L(e))},y.setFogColor=e=>{h(`uFogColor`,L(e))},y.setFogRadius=e=>{p.uFogRadius=e},y.setFogSoftness=e=>{p.uFogSoftness=e},_(),y}var z=e=>typeof e==`function`?e():e,B=e=>typeof e==`number`&&Number.isFinite(e),ee=e=>{let t=z(e);if(!t)return null;let n=z(t.x),r=z(t.y);if(!B(n)||!B(r))return null;let i=z(t.radius),a=z(t.intensity),o=z(t.flickerSpeed),s=z(t.pulseSpeed),c=z(t.phase);return{x:n,y:r,radius:B(i)?i:void 0,intensity:B(a)?a:void 0,flicker:!!z(t.flicker),flickerSpeed:B(o)?o:void 0,pulse:!!z(t.pulse),pulseSpeed:B(s)?s:void 0,phase:B(c)?c:void 0}},te=e=>{let t=z(e);return Array.isArray(t)?t.map(ee).filter(e=>!!e):[]},ne=e=>{if(!e)return null;if(typeof e.getVisibleBounds==`function`){let t=e.getVisibleBounds();if(t)return t}if(typeof e.getLocalBounds==`function`){let t=e.getLocalBounds();if(t)return t}return B(e.width)&&B(e.height)?{x:0,y:0,width:e.width,height:e.height}:null};function V(e={}){let n=(0,t.useProps)(e),r=()=>n.lightSpots??n.spots;return(0,t.mount)(e=>{let i=e.props.context,a=i?.viewport,o=a??e.parent?.componentInstance;if(!o)return;let s=i?.canvasSize,c=()=>{if(!a&&typeof s==`function`){let e=s();if(e&&B(e.width)&&B(e.height)&&e.width>0&&e.height>0)return{x:0,y:0,width:e.width,height:e.height}}return ne(o)},l=z(n.darkness),u=z(n.darkColor),d=z(n.fogColor),f=z(n.fogRadius),p=z(n.fogSoftness),m=R(a,{spots:te(r()),getBounds:c,darkness:B(l)?l:void 0,darkColor:u??void 0,fogColor:d??void 0,fogRadius:B(f)?f:void 0,fogSoftness:B(p)?p:void 0}),h=Array.isArray(o.filters)?o.filters:[];return h.includes(m)||(o.filters=[...h,m]),(0,t.effect)(()=>{m.setSpots(te(r()))}),(0,t.effect)(()=>{let e=z(n.darkness);B(e)&&m.setDarkness(e)}),(0,t.effect)(()=>{let e=z(n.darkColor);e!==void 0&&m.setDarkColor(e)}),(0,t.effect)(()=>{let e=z(n.fogColor);e!==void 0&&m.setFogColor(e)}),(0,t.effect)(()=>{let e=z(n.fogRadius);B(e)&&m.setFogRadius(e)}),(0,t.effect)(()=>{let e=z(n.fogSoftness);B(e)&&m.setFogSoftness(e)}),()=>{let e=(Array.isArray(o.filters)?o.filters:[]).filter(e=>e!==m);o.filters=e.length>0?e:null}}),(0,t.h)(t.Container)}function re(e={}){let{size:n=30,color:r=`#3498db`,backgroundColor:i,speed:a=180,segments:o=8,segmentWidth:s=3,inactiveAlpha:c=.15}=(0,t.useProps)(e,{size:30,color:`#3498db`,speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),l=(0,t.signal)(0);(0,t.tick)(({deltaTime:e})=>{let t=(typeof a==`function`?a():a)*e/1e3;l.set(l()+t)});let u=e=>{let t=typeof n==`function`?n():n,a=typeof r==`function`?r():r,u=i?typeof i==`function`?i():i:null,d=typeof o==`function`?o():o;typeof s==`function`&&s();let f=typeof c==`function`?c():c,p=l();u&&e.circle(0,0,t).fill(u);let m=360/d,h=t*.4,g=t;for(let t=0;t<d;t++){let n=t*m,r=(p%360+360)%360,i=Math.abs(r-n);i>180&&(i=360-i);let o=i/120;o=Math.min(1,o),o=o*o*o;let s=f+(1-o)*(1-f),c=Math.PI/180*n,l=Math.PI/180*m,u=c-l/2,d=c+l/2;e.arc(0,0,h,u,d).arc(0,0,g,d,u,!0).fill({color:a,alpha:s})}},d=(typeof n==`function`?n():n)*2,f=(0,t.signal)(d),p=(0,t.signal)(d);return typeof n==`function`&&(0,t.effect)(()=>{let e=n();f.set(e*2),p.set(e*2)}),(0,t.h)(t.Container,e,[(0,t.h)(t.Graphics,{draw:u})])}var H=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ie=function(e){return e.Tile=`tilelayer`,e.ObjectGroup=`objectgroup`,e.Image=`imagelayer`,e.Group=`group`,e}({});function ae(...e){return e.filter(e=>e&&e.length>0).join(`/`).replace(/\/+/g,`/`)}var oe=H(((e,t)=>{t.exports={}})),se=H((e=>{(function(e){e.parser=function(e,t){return new n(e,t)},e.SAXParser=n,e.SAXStream=l,e.createStream=c,e.MAX_BUFFER_LENGTH=64*1024;var t=[`comment`,`sgmlDecl`,`textNode`,`tagName`,`doctype`,`procInstName`,`procInstBody`,`entity`,`attribName`,`attribValue`,`cdata`,`script`];e.EVENTS=[`text`,`processinginstruction`,`sgmldeclaration`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`opencdata`,`cdata`,`closecdata`,`error`,`end`,`ready`,`script`,`opennamespace`,`closenamespace`];function n(t,r){if(!(this instanceof n))return new n(t,r);var a=this;i(a),a.q=a.c=``,a.bufferCheckPosition=e.MAX_BUFFER_LENGTH,a.opt=r||{},a.opt.lowercase=a.opt.lowercase||a.opt.lowercasetags,a.looseCase=a.opt.lowercase?`toLowerCase`:`toUpperCase`,a.tags=[],a.closed=a.closedRoot=a.sawRoot=!1,a.tag=a.error=null,a.strict=!!t,a.noscript=!!(t||a.opt.noscript),a.state=w.BEGIN,a.strictEntities=a.opt.strictEntities,a.ENTITIES=a.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),a.attribList=[],a.opt.xmlns&&(a.ns=Object.create(m)),a.opt.unquotedAttributeValues===void 0&&(a.opt.unquotedAttributeValues=!t),a.trackPosition=a.opt.position!==!1,a.trackPosition&&(a.position=a.line=a.column=0),E(a,`onready`)}Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t});function r(n){for(var r=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,a=0,o=t.length;a<o;a++){var s=n[t[a]].length;if(s>r)switch(t[a]){case`textNode`:O(n);break;case`cdata`:D(n,`oncdata`,n.cdata),n.cdata=``;break;case`script`:D(n,`onscript`,n.script),n.script=``;break;default:A(n,`Max buffer length exceeded: `+t[a])}i=Math.max(i,s)}n.bufferCheckPosition=e.MAX_BUFFER_LENGTH-i+n.position}function i(e){for(var n=0,r=t.length;n<r;n++)e[t[n]]=``}function a(e){O(e),e.cdata!==``&&(D(e,`oncdata`,e.cdata),e.cdata=``),e.script!==``&&(D(e,`onscript`,e.script),e.script=``)}n.prototype={end:function(){j(this)},write:ee,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=oe().Stream}catch{o=function(){}}o||=function(){};var s=e.EVENTS.filter(function(e){return e!==`error`&&e!==`end`});function c(e,t){return new l(e,t)}function l(e,t){if(!(this instanceof l))return new l(e,t);o.apply(this),this._parser=new n(e,t),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit(`end`)},this._parser.onerror=function(e){r.emit(`error`,e),r._parser.error=null},this._decoder=null,s.forEach(function(e){Object.defineProperty(r,`on`+e,{get:function(){return r._parser[`on`+e]},set:function(t){if(!t)return r.removeAllListeners(e),r._parser[`on`+e]=t,t;r.on(e,t)},enumerable:!0,configurable:!1})})}l.prototype=Object.create(o.prototype,{constructor:{value:l}}),l.prototype.write=function(e){if(typeof Buffer==`function`&&typeof Buffer.isBuffer==`function`&&Buffer.isBuffer(e)){if(!this._decoder){var t=oe().StringDecoder;this._decoder=new t(`utf8`)}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit(`data`,e),!0},l.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},l.prototype.on=function(e,t){var n=this;return!n._parser[`on`+e]&&s.indexOf(e)!==-1&&(n._parser[`on`+e]=function(){var t=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),o.prototype.on.call(n,e,t)};var u=`[CDATA[`,d=`DOCTYPE`,f=`http://www.w3.org/XML/1998/namespace`,p=`http://www.w3.org/2000/xmlns/`,m={xml:f,xmlns:p},h=/[:_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]/,g=/[:_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-]/,_=/[#:_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]/,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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function y(e){return e===` `||e===`
87
+ `||e===`\r`||e===` `}function b(e){return e===`"`||e===`'`}function x(e){return e===`>`||y(e)}function S(e,t){return e.test(t)}function C(e,t){return!S(e,t)}var w=0;for(var T in e.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},e.XML_ENTITIES={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`},e.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(e.ENTITIES).forEach(function(t){var n=e.ENTITIES[t],r=typeof n==`number`?String.fromCharCode(n):n;e.ENTITIES[t]=r}),e.STATE)e.STATE[e.STATE[T]]=T;w=e.STATE;function E(e,t,n){e[t]&&e[t](n)}function D(e,t,n){e.textNode&&O(e),E(e,t,n)}function O(e){e.textNode=k(e.opt,e.textNode),e.textNode&&E(e,`ontext`,e.textNode),e.textNode=``}function k(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g,` `)),t}function A(e,t){return O(e),e.trackPosition&&(t+=`
88
+ Line: `+e.line+`
89
+ Column: `+e.column+`
90
+ Char: `+e.c),t=Error(t),e.error=t,E(e,`onerror`,t),e}function j(e){return e.sawRoot&&!e.closedRoot&&M(e,`Unclosed root tag`),e.state!==w.BEGIN&&e.state!==w.BEGIN_WHITESPACE&&e.state!==w.TEXT&&A(e,`Unexpected end`),O(e),e.c=``,e.closed=!0,E(e,`onend`),n.call(e,e.strict,e.opt),e}function M(e,t){if(typeof e!=`object`||!(e instanceof n))throw Error(`bad call to strictFail`);e.strict&&A(e,t)}function N(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,n=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(n.ns=t.ns),e.attribList.length=0,D(e,`onopentagstart`,n)}function P(e,t){var n=e.indexOf(`:`)<0?[``,e]:e.split(`:`),r=n[0],i=n[1];return t&&e===`xmlns`&&(r=`xmlns`,i=``),{prefix:r,local:i}}function F(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),e.attribList.indexOf(e.attribName)!==-1||e.tag.attributes.hasOwnProperty(e.attribName)){e.attribName=e.attribValue=``;return}if(e.opt.xmlns){var t=P(e.attribName,!0),n=t.prefix,r=t.local;if(n===`xmlns`)if(r===`xml`&&e.attribValue!==f)M(e,`xml: prefix must be bound to `+f+`
91
+ Actual: `+e.attribValue);else if(r===`xmlns`&&e.attribValue!==p)M(e,`xmlns: prefix must be bound to `+p+`
92
+ Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.ns&&(i.ns=Object.create(a.ns)),i.ns[r]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,D(e,`onattribute`,{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=``}function I(e,t){if(e.opt.xmlns){var n=e.tag,r=P(e.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||``,n.prefix&&!n.uri&&(M(e,`Unbound namespace prefix: `+JSON.stringify(e.tagName)),n.uri=r.prefix);var i=e.tags[e.tags.length-1]||e;n.ns&&i.ns!==n.ns&&Object.keys(n.ns).forEach(function(t){D(e,`onopennamespace`,{prefix:t,uri:n.ns[t]})});for(var a=0,o=e.attribList.length;a<o;a++){var s=e.attribList[a],c=s[0],l=s[1],u=P(c,!0),d=u.prefix,f=u.local,p=d===``?``:n.ns[d]||``,m={name:c,value:l,prefix:d,local:f,uri:p};d&&d!==`xmlns`&&!p&&(M(e,`Unbound namespace prefix: `+JSON.stringify(d)),m.uri=d),e.tag.attributes[c]=m,D(e,`onattribute`,m)}e.attribList.length=0}e.tag.isSelfClosing=!!t,e.sawRoot=!0,e.tags.push(e.tag),D(e,`onopentag`,e.tag),t||(!e.noscript&&e.tagName.toLowerCase()===`script`?e.state=w.SCRIPT:e.state=w.TEXT,e.tag=null,e.tagName=``),e.attribName=e.attribValue=``,e.attribList.length=0}function L(e){if(!e.tagName){M(e,`Weird empty close tag.`),e.textNode+=`</>`,e.state=w.TEXT;return}if(e.script){if(e.tagName!==`script`){e.script+=`</`+e.tagName+`>`,e.tagName=``,e.state=w.SCRIPT;return}D(e,`onscript`,e.script),e.script=``}var t=e.tags.length,n=e.tagName;e.strict||(n=n[e.looseCase]());for(var r=n;t--&&e.tags[t].name!==r;)M(e,`Unexpected close tag`);if(t<0){M(e,`Unmatched closing tag: `+e.tagName),e.textNode+=`</`+e.tagName+`>`,e.state=w.TEXT;return}e.tagName=n;for(var i=e.tags.length;i-- >t;){var a=e.tag=e.tags.pop();e.tagName=e.tag.name,D(e,`onclosetag`,e.tagName);var o={};for(var s in a.ns)o[s]=a.ns[s];var c=e.tags[e.tags.length-1]||e;e.opt.xmlns&&a.ns!==c.ns&&Object.keys(a.ns).forEach(function(t){var n=a.ns[t];D(e,`onclosenamespace`,{prefix:t,uri:n})})}t===0&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName=``,e.attribList.length=0,e.state=w.TEXT}function R(e){var t=e.entity,n=t.toLowerCase(),r,i=``;return e.ENTITIES[t]?e.ENTITIES[t]:e.ENTITIES[n]?e.ENTITIES[n]:(t=n,t.charAt(0)===`#`&&(t.charAt(1)===`x`?(t=t.slice(2),r=parseInt(t,16),i=r.toString(16)):(t=t.slice(1),r=parseInt(t,10),i=r.toString(10))),t=t.replace(/^0+/,``),isNaN(r)||i.toLowerCase()!==t?(M(e,`Invalid character entity`),`&`+e.entity+`;`):String.fromCodePoint(r))}function z(e,t){t===`<`?(e.state=w.OPEN_WAKA,e.startTagPosition=e.position):y(t)||(M(e,`Non-whitespace before first tag.`),e.textNode=t,e.state=w.TEXT)}function B(e,t){var n=``;return t<e.length&&(n=e.charAt(t)),n}function ee(t){var n=this;if(this.error)throw this.error;if(n.closed)return A(n,`Cannot write after close. Assign an onready handler.`);if(t===null)return j(n);typeof t==`object`&&(t=t.toString());for(var i=0,a=``;a=B(t,i++),n.c=a,a;)switch(n.trackPosition&&(n.position++,a===`
93
+ `?(n.line++,n.column=0):n.column++),n.state){case w.BEGIN:if(n.state=w.BEGIN_WHITESPACE,a===``)continue;z(n,a);continue;case w.BEGIN_WHITESPACE:z(n,a);continue;case w.TEXT:if(n.sawRoot&&!n.closedRoot){for(var o=i-1;a&&a!==`<`&&a!==`&`;)a=B(t,i++),a&&n.trackPosition&&(n.position++,a===`
94
+ `?(n.line++,n.column=0):n.column++);n.textNode+=t.substring(o,i-1)}a===`<`&&!(n.sawRoot&&n.closedRoot&&!n.strict)?(n.state=w.OPEN_WAKA,n.startTagPosition=n.position):(!y(a)&&(!n.sawRoot||n.closedRoot)&&M(n,`Text data outside of root node.`),a===`&`?n.state=w.TEXT_ENTITY:n.textNode+=a);continue;case w.SCRIPT:a===`<`?n.state=w.SCRIPT_ENDING:n.script+=a;continue;case w.SCRIPT_ENDING:a===`/`?n.state=w.CLOSE_TAG:(n.script+=`<`+a,n.state=w.SCRIPT);continue;case w.OPEN_WAKA:if(a===`!`)n.state=w.SGML_DECL,n.sgmlDecl=``;else if(!y(a))if(S(h,a))n.state=w.OPEN_TAG,n.tagName=a;else if(a===`/`)n.state=w.CLOSE_TAG,n.tagName=``;else if(a===`?`)n.state=w.PROC_INST,n.procInstName=n.procInstBody=``;else{if(M(n,`Unencoded <`),n.startTagPosition+1<n.position){var s=n.position-n.startTagPosition;a=Array(s).join(` `)+a}n.textNode+=`<`+a,n.state=w.TEXT}continue;case w.SGML_DECL:if(n.sgmlDecl+a===`--`){n.state=w.COMMENT,n.comment=``,n.sgmlDecl=``;continue}n.doctype&&n.doctype!==!0&&n.sgmlDecl?(n.state=w.DOCTYPE_DTD,n.doctype+=`<!`+n.sgmlDecl+a,n.sgmlDecl=``):(n.sgmlDecl+a).toUpperCase()===u?(D(n,`onopencdata`),n.state=w.CDATA,n.sgmlDecl=``,n.cdata=``):(n.sgmlDecl+a).toUpperCase()===d?(n.state=w.DOCTYPE,(n.doctype||n.sawRoot)&&M(n,`Inappropriately located doctype declaration`),n.doctype=``,n.sgmlDecl=``):a===`>`?(D(n,`onsgmldeclaration`,n.sgmlDecl),n.sgmlDecl=``,n.state=w.TEXT):(b(a)&&(n.state=w.SGML_DECL_QUOTED),n.sgmlDecl+=a);continue;case w.SGML_DECL_QUOTED:a===n.q&&(n.state=w.SGML_DECL,n.q=``),n.sgmlDecl+=a;continue;case w.DOCTYPE:a===`>`?(n.state=w.TEXT,D(n,`ondoctype`,n.doctype),n.doctype=!0):(n.doctype+=a,a===`[`?n.state=w.DOCTYPE_DTD:b(a)&&(n.state=w.DOCTYPE_QUOTED,n.q=a));continue;case w.DOCTYPE_QUOTED:n.doctype+=a,a===n.q&&(n.q=``,n.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:a===`]`?(n.doctype+=a,n.state=w.DOCTYPE):a===`<`?(n.state=w.OPEN_WAKA,n.startTagPosition=n.position):b(a)?(n.doctype+=a,n.state=w.DOCTYPE_DTD_QUOTED,n.q=a):n.doctype+=a;continue;case w.DOCTYPE_DTD_QUOTED:n.doctype+=a,a===n.q&&(n.state=w.DOCTYPE_DTD,n.q=``);continue;case w.COMMENT:a===`-`?n.state=w.COMMENT_ENDING:n.comment+=a;continue;case w.COMMENT_ENDING:a===`-`?(n.state=w.COMMENT_ENDED,n.comment=k(n.opt,n.comment),n.comment&&D(n,`oncomment`,n.comment),n.comment=``):(n.comment+=`-`+a,n.state=w.COMMENT);continue;case w.COMMENT_ENDED:a===`>`?n.doctype&&n.doctype!==!0?n.state=w.DOCTYPE_DTD:n.state=w.TEXT:(M(n,`Malformed comment`),n.comment+=`--`+a,n.state=w.COMMENT);continue;case w.CDATA:a===`]`?n.state=w.CDATA_ENDING:n.cdata+=a;continue;case w.CDATA_ENDING:a===`]`?n.state=w.CDATA_ENDING_2:(n.cdata+=`]`+a,n.state=w.CDATA);continue;case w.CDATA_ENDING_2:a===`>`?(n.cdata&&D(n,`oncdata`,n.cdata),D(n,`onclosecdata`),n.cdata=``,n.state=w.TEXT):a===`]`?n.cdata+=`]`:(n.cdata+=`]]`+a,n.state=w.CDATA);continue;case w.PROC_INST:a===`?`?n.state=w.PROC_INST_ENDING:y(a)?n.state=w.PROC_INST_BODY:n.procInstName+=a;continue;case w.PROC_INST_BODY:if(!n.procInstBody&&y(a))continue;a===`?`?n.state=w.PROC_INST_ENDING:n.procInstBody+=a;continue;case w.PROC_INST_ENDING:a===`>`?(D(n,`onprocessinginstruction`,{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody=``,n.state=w.TEXT):(n.procInstBody+=`?`+a,n.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:S(g,a)?n.tagName+=a:(N(n),a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:(y(a)||M(n,`Invalid character in tag name`),n.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:a===`>`?(I(n,!0),L(n)):(M(n,`Forward-slash in opening tag not followed by >`),n.state=w.ATTRIB);continue;case w.ATTRIB:if(y(a))continue;a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:S(h,a)?(n.attribName=a,n.attribValue=``,n.state=w.ATTRIB_NAME):M(n,`Invalid attribute name`);continue;case w.ATTRIB_NAME:a===`=`?n.state=w.ATTRIB_VALUE:a===`>`?(M(n,`Attribute without value`),n.attribValue=n.attribName,F(n),I(n)):y(a)?n.state=w.ATTRIB_NAME_SAW_WHITE:S(g,a)?n.attribName+=a:M(n,`Invalid attribute name`);continue;case w.ATTRIB_NAME_SAW_WHITE:if(a===`=`)n.state=w.ATTRIB_VALUE;else if(y(a))continue;else M(n,`Attribute without value`),n.tag.attributes[n.attribName]=``,n.attribValue=``,D(n,`onattribute`,{name:n.attribName,value:``}),n.attribName=``,a===`>`?I(n):S(h,a)?(n.attribName=a,n.state=w.ATTRIB_NAME):(M(n,`Invalid attribute name`),n.state=w.ATTRIB);continue;case w.ATTRIB_VALUE:if(y(a))continue;b(a)?(n.q=a,n.state=w.ATTRIB_VALUE_QUOTED):(n.opt.unquotedAttributeValues||A(n,`Unquoted attribute value`),n.state=w.ATTRIB_VALUE_UNQUOTED,n.attribValue=a);continue;case w.ATTRIB_VALUE_QUOTED:if(a!==n.q){a===`&`?n.state=w.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=a;continue}F(n),n.q=``,n.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:y(a)?n.state=w.ATTRIB:a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:S(h,a)?(M(n,`No whitespace between attributes`),n.attribName=a,n.attribValue=``,n.state=w.ATTRIB_NAME):M(n,`Invalid attribute name`);continue;case w.ATTRIB_VALUE_UNQUOTED:if(!x(a)){a===`&`?n.state=w.ATTRIB_VALUE_ENTITY_U:n.attribValue+=a;continue}F(n),a===`>`?I(n):n.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(n.tagName)a===`>`?L(n):S(g,a)?n.tagName+=a:n.script?(n.script+=`</`+n.tagName,n.tagName=``,n.state=w.SCRIPT):(y(a)||M(n,`Invalid tagname in closing tag`),n.state=w.CLOSE_TAG_SAW_WHITE);else{if(y(a))continue;C(h,a)?n.script?(n.script+=`</`+a,n.state=w.SCRIPT):M(n,`Invalid tagname in closing tag.`):n.tagName=a}continue;case w.CLOSE_TAG_SAW_WHITE:if(y(a))continue;a===`>`?L(n):M(n,`Invalid characters in closing tag`);continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var c,l;switch(n.state){case w.TEXT_ENTITY:c=w.TEXT,l=`textNode`;break;case w.ATTRIB_VALUE_ENTITY_Q:c=w.ATTRIB_VALUE_QUOTED,l=`attribValue`;break;case w.ATTRIB_VALUE_ENTITY_U:c=w.ATTRIB_VALUE_UNQUOTED,l=`attribValue`;break}if(a===`;`){var f=R(n);n.opt.unparsedEntities&&!Object.values(e.XML_ENTITIES).includes(f)?(n.entity=``,n.state=c,n.write(f)):(n[l]+=f,n.entity=``,n.state=c)}else S(n.entity.length?v:_,a)?n.entity+=a:(M(n,`Invalid character in entity name`),n[l]+=`&`+n.entity+a,n.entity=``,n.state=c);continue;default:throw Error(n,`Unknown state: `+n.state)}return n.position>=n.bufferCheckPosition&&r(n),n}String.fromCodePoint||(function(){var e=String.fromCharCode,t=Math.floor,n=function(){var n=16384,r=[],i,a,o=-1,s=arguments.length;if(!s)return``;for(var c=``;++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l)throw RangeError(`Invalid code point: `+l);l<=65535?r.push(l):(l-=65536,i=(l>>10)+55296,a=l%1024+56320,r.push(i,a)),(o+1===s||r.length>n)&&(c+=e.apply(null,r),r.length=0)}return c};Object.defineProperty?Object.defineProperty(String,`fromCodePoint`,{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n})()})(e===void 0?e.sax={}:e)})),U=H(((e,t)=>{t.exports={isArray:function(e){return Array.isArray?Array.isArray(e):Object.prototype.toString.call(e)===`[object Array]`}}})),ce=H(((e,t)=>{var n=U().isArray;t.exports={copyOptions:function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n},ensureFlagExists:function(e,t){(!(e in t)||typeof t[e]!=`boolean`)&&(t[e]=!1)},ensureSpacesExists:function(e){(!(`spaces`in e)||typeof e.spaces!=`number`&&typeof e.spaces!=`string`)&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){(!(`alwaysArray`in e)||typeof e.alwaysArray!=`boolean`&&!n(e.alwaysArray))&&(e.alwaysArray=!1)},ensureKeyExists:function(e,t){(!(e+`Key`in t)||typeof t[e+`Key`]!=`string`)&&(t[e+`Key`]=t.compact?`_`+e:e)},checkFnExists:function(e,t){return e+`Fn`in t}}})),le=H(((e,t)=>{var n=se(),r={on:function(){},parse:function(){}},i=ce(),a=U().isArray,o,s=!0,c;function l(e){return o=i.copyOptions(e),i.ensureFlagExists(`ignoreDeclaration`,o),i.ensureFlagExists(`ignoreInstruction`,o),i.ensureFlagExists(`ignoreAttributes`,o),i.ensureFlagExists(`ignoreText`,o),i.ensureFlagExists(`ignoreComment`,o),i.ensureFlagExists(`ignoreCdata`,o),i.ensureFlagExists(`ignoreDoctype`,o),i.ensureFlagExists(`compact`,o),i.ensureFlagExists(`alwaysChildren`,o),i.ensureFlagExists(`addParent`,o),i.ensureFlagExists(`trim`,o),i.ensureFlagExists(`nativeType`,o),i.ensureFlagExists(`nativeTypeAttributes`,o),i.ensureFlagExists(`sanitize`,o),i.ensureFlagExists(`instructionHasAttributes`,o),i.ensureFlagExists(`captureSpacesBetweenElements`,o),i.ensureAlwaysArrayExists(o),i.ensureKeyExists(`declaration`,o),i.ensureKeyExists(`instruction`,o),i.ensureKeyExists(`attributes`,o),i.ensureKeyExists(`text`,o),i.ensureKeyExists(`comment`,o),i.ensureKeyExists(`cdata`,o),i.ensureKeyExists(`doctype`,o),i.ensureKeyExists(`type`,o),i.ensureKeyExists(`name`,o),i.ensureKeyExists(`elements`,o),i.ensureKeyExists(`parent`,o),i.checkFnExists(`doctype`,o),i.checkFnExists(`instruction`,o),i.checkFnExists(`cdata`,o),i.checkFnExists(`comment`,o),i.checkFnExists(`text`,o),i.checkFnExists(`instructionName`,o),i.checkFnExists(`elementName`,o),i.checkFnExists(`attributeName`,o),i.checkFnExists(`attributeValue`,o),i.checkFnExists(`attributes`,o),o}function u(e){var t=Number(e);if(!isNaN(t))return t;var n=e.toLowerCase();return n===`true`?!0:n===`false`?!1:e}function d(e,t){var n;if(o.compact){if(!c[o[e+`Key`]]&&(a(o.alwaysArray)?o.alwaysArray.indexOf(o[e+`Key`])!==-1:o.alwaysArray)&&(c[o[e+`Key`]]=[]),c[o[e+`Key`]]&&!a(c[o[e+`Key`]])&&(c[o[e+`Key`]]=[c[o[e+`Key`]]]),e+`Fn`in o&&typeof t==`string`&&(t=o[e+`Fn`](t,c)),e===`instruction`&&(`instructionFn`in o||`instructionNameFn`in o)){for(n in t)if(t.hasOwnProperty(n))if(`instructionFn`in o)t[n]=o.instructionFn(t[n],n,c);else{var r=t[n];delete t[n],t[o.instructionNameFn(n,r,c)]=r}}a(c[o[e+`Key`]])?c[o[e+`Key`]].push(t):c[o[e+`Key`]]=t}else{c[o.elementsKey]||(c[o.elementsKey]=[]);var i={};if(i[o.typeKey]=e,e===`instruction`){for(n in t)if(t.hasOwnProperty(n))break;i[o.nameKey]=`instructionNameFn`in o?o.instructionNameFn(n,t,c):n,o.instructionHasAttributes?(i[o.attributesKey]=t[n][o.attributesKey],`instructionFn`in o&&(i[o.attributesKey]=o.instructionFn(i[o.attributesKey],n,c))):(`instructionFn`in o&&(t[n]=o.instructionFn(t[n],n,c)),i[o.instructionKey]=t[n])}else e+`Fn`in o&&(t=o[e+`Fn`](t,c)),i[o[e+`Key`]]=t;o.addParent&&(i[o.parentKey]=c),c[o.elementsKey].push(i)}}function f(e){if(`attributesFn`in o&&e&&(e=o.attributesFn(e,c)),(o.trim||`attributeValueFn`in o||`attributeNameFn`in o||o.nativeTypeAttributes)&&e){for(var t in e)if(e.hasOwnProperty(t)&&(o.trim&&(e[t]=e[t].trim()),o.nativeTypeAttributes&&(e[t]=u(e[t])),`attributeValueFn`in o&&(e[t]=o.attributeValueFn(e[t],t,c)),`attributeNameFn`in o)){var n=e[t];delete e[t],e[o.attributeNameFn(t,e[t],c)]=n}}return e}function p(e){var t={};if(e.body&&(e.name.toLowerCase()===`xml`||o.instructionHasAttributes)){for(var n=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,r;(r=n.exec(e.body))!==null;)t[r[1]]=r[2]||r[3]||r[4];t=f(t)}if(e.name.toLowerCase()===`xml`){if(o.ignoreDeclaration)return;c[o.declarationKey]={},Object.keys(t).length&&(c[o.declarationKey][o.attributesKey]=t),o.addParent&&(c[o.declarationKey][o.parentKey]=c)}else{if(o.ignoreInstruction)return;o.trim&&(e.body=e.body.trim());var i={};o.instructionHasAttributes&&Object.keys(t).length?(i[e.name]={},i[e.name][o.attributesKey]=t):i[e.name]=e.body,d(`instruction`,i)}}function m(e,t){var n;if(typeof e==`object`&&(t=e.attributes,e=e.name),t=f(t),`elementNameFn`in o&&(e=o.elementNameFn(e,c)),o.compact){if(n={},!o.ignoreAttributes&&t&&Object.keys(t).length)for(var r in n[o.attributesKey]={},t)t.hasOwnProperty(r)&&(n[o.attributesKey][r]=t[r]);!(e in c)&&(a(o.alwaysArray)?o.alwaysArray.indexOf(e)!==-1:o.alwaysArray)&&(c[e]=[]),c[e]&&!a(c[e])&&(c[e]=[c[e]]),a(c[e])?c[e].push(n):c[e]=n}else c[o.elementsKey]||(c[o.elementsKey]=[]),n={},n[o.typeKey]=`element`,n[o.nameKey]=e,!o.ignoreAttributes&&t&&Object.keys(t).length&&(n[o.attributesKey]=t),o.alwaysChildren&&(n[o.elementsKey]=[]),c[o.elementsKey].push(n);n[o.parentKey]=c,c=n}function h(e){o.ignoreText||!e.trim()&&!o.captureSpacesBetweenElements||(o.trim&&(e=e.trim()),o.nativeType&&(e=u(e)),o.sanitize&&(e=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)),d(`text`,e))}function g(e){o.ignoreComment||(o.trim&&(e=e.trim()),d(`comment`,e))}function _(e){var t=c[o.parentKey];o.addParent||delete c[o.parentKey],c=t}function v(e){o.ignoreCdata||(o.trim&&(e=e.trim()),d(`cdata`,e))}function y(e){o.ignoreDoctype||(e=e.replace(/^ /,``),o.trim&&(e=e.trim()),d(`doctype`,e))}function b(e){e.note=e}t.exports=function(e,t){var i=s?n.parser(!0,{}):i=new r.Parser(`UTF-8`),a={};if(c=a,o=l(t),s?(i.opt={strictEntities:!0},i.onopentag=m,i.ontext=h,i.oncomment=g,i.onclosetag=_,i.onerror=b,i.oncdata=v,i.ondoctype=y,i.onprocessinginstruction=p):(i.on(`startElement`,m),i.on(`text`,h),i.on(`comment`,g),i.on(`endElement`,_),i.on(`error`,b)),s)i.write(e).close();else if(!i.parse(e))throw Error(`XML parsing error: `+i.getError());if(a[o.elementsKey]){var u=a[o.elementsKey];delete a[o.elementsKey],a[o.elementsKey]=u,delete a.text}return a}})),ue=H(((e,t)=>{var n=ce(),r=le();function i(e){var t=n.copyOptions(e);return n.ensureSpacesExists(t),t}t.exports=function(e,t){var n=i(t),a=r(e,n),o,s=`compact`in n&&n.compact?`_parent`:`parent`;return o=`addParent`in n&&n.addParent?JSON.stringify(a,function(e,t){return e===s?`_`:t},n.spaces):JSON.stringify(a,null,n.spaces),o.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}})),de=H(((e,t)=>{var n=ce(),r=U().isArray,i,a;function o(e){var t=n.copyOptions(e);return n.ensureFlagExists(`ignoreDeclaration`,t),n.ensureFlagExists(`ignoreInstruction`,t),n.ensureFlagExists(`ignoreAttributes`,t),n.ensureFlagExists(`ignoreText`,t),n.ensureFlagExists(`ignoreComment`,t),n.ensureFlagExists(`ignoreCdata`,t),n.ensureFlagExists(`ignoreDoctype`,t),n.ensureFlagExists(`compact`,t),n.ensureFlagExists(`indentText`,t),n.ensureFlagExists(`indentCdata`,t),n.ensureFlagExists(`indentAttributes`,t),n.ensureFlagExists(`indentInstruction`,t),n.ensureFlagExists(`fullTagEmptyElement`,t),n.ensureFlagExists(`noQuotesForNativeAttributes`,t),n.ensureSpacesExists(t),typeof t.spaces==`number`&&(t.spaces=Array(t.spaces+1).join(` `)),n.ensureKeyExists(`declaration`,t),n.ensureKeyExists(`instruction`,t),n.ensureKeyExists(`attributes`,t),n.ensureKeyExists(`text`,t),n.ensureKeyExists(`comment`,t),n.ensureKeyExists(`cdata`,t),n.ensureKeyExists(`doctype`,t),n.ensureKeyExists(`type`,t),n.ensureKeyExists(`name`,t),n.ensureKeyExists(`elements`,t),n.checkFnExists(`doctype`,t),n.checkFnExists(`instruction`,t),n.checkFnExists(`cdata`,t),n.checkFnExists(`comment`,t),n.checkFnExists(`text`,t),n.checkFnExists(`instructionName`,t),n.checkFnExists(`elementName`,t),n.checkFnExists(`attributeName`,t),n.checkFnExists(`attributeValue`,t),n.checkFnExists(`attributes`,t),n.checkFnExists(`fullTagEmptyElement`,t),t}function s(e,t,n){return(!n&&e.spaces?`
95
+ `:``)+Array(t+1).join(e.spaces)}function c(e,t,n){if(t.ignoreAttributes)return``;`attributesFn`in t&&(e=t.attributesFn(e,a,i));var r,o,c,l,u=[];for(r in e)e.hasOwnProperty(r)&&e[r]!==null&&e[r]!==void 0&&(l=t.noQuotesForNativeAttributes&&typeof e[r]!=`string`?``:`"`,o=``+e[r],o=o.replace(/"/g,`&quot;`),c=`attributeNameFn`in t?t.attributeNameFn(r,o,a,i):r,u.push(t.spaces&&t.indentAttributes?s(t,n+1,!1):` `),u.push(c+`=`+l+(`attributeValueFn`in t?t.attributeValueFn(o,r,a,i):o)+l));return e&&Object.keys(e).length&&t.spaces&&t.indentAttributes&&u.push(s(t,n,!1)),u.join(``)}function l(e,t,n){return i=e,a=`xml`,t.ignoreDeclaration?``:`<?xml`+c(e[t.attributesKey],t,n)+`?>`}function u(e,t,n){if(t.ignoreInstruction)return``;for(var r in e)if(e.hasOwnProperty(r))break;var o=`instructionNameFn`in t?t.instructionNameFn(r,e[r],a,i):r;if(typeof e[r]==`object`)return i=e,a=o,`<?`+o+c(e[r][t.attributesKey],t,n)+`?>`;var s=e[r]?e[r]:``;return`instructionFn`in t&&(s=t.instructionFn(s,r,a,i)),`<?`+o+(s?` `+s:``)+`?>`}function d(e,t){return t.ignoreComment?``:`<!--`+(`commentFn`in t?t.commentFn(e,a,i):e)+`-->`}function f(e,t){return t.ignoreCdata?``:`<![CDATA[`+(`cdataFn`in t?t.cdataFn(e,a,i):e.replace(`]]>`,`]]]]><![CDATA[>`))+`]]>`}function p(e,t){return t.ignoreDoctype?``:`<!DOCTYPE `+(`doctypeFn`in t?t.doctypeFn(e,a,i):e)+`>`}function m(e,t){return t.ignoreText?``:(e=``+e,e=e.replace(/&amp;/g,`&`),e=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),`textFn`in t?t.textFn(e,a,i):e)}function h(e,t){var n;if(e.elements&&e.elements.length)for(n=0;n<e.elements.length;++n)switch(e.elements[n][t.typeKey]){case`text`:if(t.indentText)return!0;break;case`cdata`:if(t.indentCdata)return!0;break;case`instruction`:if(t.indentInstruction)return!0;break;case`doctype`:case`comment`:case`element`:return!0;default:return!0}return!1}function g(e,t,n){i=e,a=e.name;var r=[],o=`elementNameFn`in t?t.elementNameFn(e.name,e):e.name;r.push(`<`+o),e[t.attributesKey]&&r.push(c(e[t.attributesKey],t,n));var s=e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&e[t.attributesKey][`xml:space`]===`preserve`;return s||=`fullTagEmptyElementFn`in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement,s?(r.push(`>`),e[t.elementsKey]&&e[t.elementsKey].length&&(r.push(_(e[t.elementsKey],t,n+1)),i=e,a=e.name),r.push(t.spaces&&h(e,t)?`
96
+ `+Array(n+1).join(t.spaces):``),r.push(`</`+o+`>`)):r.push(`/>`),r.join(``)}function _(e,t,n,r){return e.reduce(function(e,i){var a=s(t,n,r&&!e);switch(i.type){case`element`:return e+a+g(i,t,n);case`comment`:return e+a+d(i[t.commentKey],t);case`doctype`:return e+a+p(i[t.doctypeKey],t);case`cdata`:return e+(t.indentCdata?a:``)+f(i[t.cdataKey],t);case`text`:return e+(t.indentText?a:``)+m(i[t.textKey],t);case`instruction`:var o={};return o[i[t.nameKey]]=i[t.attributesKey]?i:i[t.instructionKey],e+(t.indentInstruction?a:``)+u(o,t,n)}},``)}function v(e,t,n){for(var r in e)if(e.hasOwnProperty(r))switch(r){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||n)return!0;break;case t.cdataKey:if(t.indentCdata||n)return!0;break;case t.instructionKey:if(t.indentInstruction||n)return!0;break;case t.doctypeKey:case t.commentKey:return!0;default:return!0}return!1}function y(e,t,n,r,o){i=e,a=t;var l=`elementNameFn`in n?n.elementNameFn(t,e):t;if(e==null||e===``)return`fullTagEmptyElementFn`in n&&n.fullTagEmptyElementFn(t,e)||n.fullTagEmptyElement?`<`+l+`></`+l+`>`:`<`+l+`/>`;var u=[];if(t){if(u.push(`<`+l),typeof e!=`object`)return u.push(`>`+m(e,n)+`</`+l+`>`),u.join(``);e[n.attributesKey]&&u.push(c(e[n.attributesKey],n,r));var d=v(e,n,!0)||e[n.attributesKey]&&e[n.attributesKey][`xml:space`]===`preserve`;if(d||=`fullTagEmptyElementFn`in n?n.fullTagEmptyElementFn(t,e):n.fullTagEmptyElement,d)u.push(`>`);else return u.push(`/>`),u.join(``)}return u.push(b(e,n,r+1,!1)),i=e,a=t,t&&u.push((o?s(n,r,!1):``)+`</`+l+`>`),u.join(``)}function b(e,t,n,i){var a,o,c,h=[];for(o in e)if(e.hasOwnProperty(o))for(c=r(e[o])?e[o]:[e[o]],a=0;a<c.length;++a){switch(o){case t.declarationKey:h.push(l(c[a],t,n));break;case t.instructionKey:h.push((t.indentInstruction?s(t,n,i):``)+u(c[a],t,n));break;case t.attributesKey:case t.parentKey:break;case t.textKey:h.push((t.indentText?s(t,n,i):``)+m(c[a],t));break;case t.cdataKey:h.push((t.indentCdata?s(t,n,i):``)+f(c[a],t));break;case t.doctypeKey:h.push(s(t,n,i)+p(c[a],t));break;case t.commentKey:h.push(s(t,n,i)+d(c[a],t));break;default:h.push(s(t,n,i)+y(c[a],o,t,n,v(c[a],t)))}i&&=!h.length}return h.join(``)}t.exports=function(e,t){t=o(t);var n=[];return i=e,a=`_root_`,t.compact?n.push(b(e,t,0,!0)):(e[t.declarationKey]&&n.push(l(e[t.declarationKey],t,0)),e[t.elementsKey]&&e[t.elementsKey].length&&n.push(_(e[t.elementsKey],t,0,!n.length))),n.join(``)}})),fe=H(((e,t)=>{var n=de();t.exports=function(e,t){e instanceof Buffer&&(e=e.toString());var r=null;if(typeof e==`string`)try{r=JSON.parse(e)}catch{throw Error(`The JSON structure is invalid`)}else r=e;return n(r,t)}})),pe=H(((e,t)=>{t.exports={xml2js:le(),xml2json:ue(),js2xml:de(),json2xml:fe()}})),me=H((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),he=H((e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),W=H((e=>{var t=me(),n=he(),r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=s,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.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 a(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,`parent`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,`offset`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return d(e)}return c(e,t,n)}s.poolSize=8192;function c(e,t,n){if(typeof e==`string`)return f(e,t);if(ArrayBuffer.isView(e))return m(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<`u`&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return h(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return s.from(r,t,n);let i=g(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return s.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}s.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function u(e,t,n){return l(e),e<=0||t===void 0?o(e):typeof n==`string`?o(e).fill(t,n):o(e).fill(t)}s.alloc=function(e,t,n){return u(e,t,n)};function d(e){return l(e),o(e<0?0:_(e)|0)}s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)};function f(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!s.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=y(e,t)|0,r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function p(e){let t=e.length<0?0:_(e.length)|0,n=o(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function m(e){if(W(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}function h(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new Uint8Array(e):n===void 0?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,s.prototype),r}function g(e){if(s.isBuffer(e)){let t=_(e.length)|0,n=o(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||ge(e.length)?o(0):p(e);if(e.type===`Buffer`&&Array.isArray(e.data))return p(e.data)}function _(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function v(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),W(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(W(t,Uint8Array))i+t.length>r.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else if(s.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function y(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(e,ArrayBuffer))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return le(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return fe(e).length;default:if(i)return r?-1:le(e).length;t=(``+t).toLowerCase(),i=!0}}s.byteLength=y;function b(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return F(this,t,n);case`utf8`:case`utf-8`:return A(this,t,n);case`ascii`:return N(this,t,n);case`latin1`:case`binary`:return P(this,t,n);case`base64`:return k(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return I(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}s.prototype._isBuffer=!0;function x(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)x(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)x(this,t,t+7),x(this,t+1,t+6),x(this,t+2,t+5),x(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?A(this,0,e):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(e,t,n,r,i){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,o=n-t,c=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],o=u[e];break}return a<o?-1:+(o<a)};function S(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,ge(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=s.from(t,r)),s.isBuffer(t))return t.length===0?-1:C(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function C(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return S(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return S(this,e,t,n,!1)};function w(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(ge(r))return o;e[n+o]=r}return o}function T(e,t,n,r){return pe(le(t,e.length-n),e,n,r)}function E(e,t,n,r){return pe(ue(t),e,n,r)}function D(e,t,n,r){return pe(fe(t),e,n,r)}function O(e,t,n,r){return pe(de(t,e.length-n),e,n,r)}s.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return w(this,e,t,n);case`utf8`:case`utf-8`:return T(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return E(this,e,t,n);case`base64`:return D(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return O(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function k(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function A(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return M(r)}var j=4096;function M(e){let t=e.length;if(t<=j)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=j));return n}function N(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function P(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function F(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=_e[e[r]];return i}function I(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,s.prototype),r};function L(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||L(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||L(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||L(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||L(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||L(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||L(e,8,this.length),n.read(this,e,!1,52,8)};function R(e,t,n,r,i,a){if(!s.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;R(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;R(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function z(e,t,n,r,i){ae(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function B(e,t,n,r,i){ae(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}s.prototype.writeBigUInt64LE=ve(function(e,t=0){return z(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeBigUInt64BE=ve(function(e,t=0){return B(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);R(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);R(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=ve(function(e,t=0){return z(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),s.prototype.writeBigInt64BE=ve(function(e,t=0){return B(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ee(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function te(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,i,23,4),r+4}s.prototype.writeFloatLE=function(e,t,n){return te(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return te(this,e,t,!1,n)};function ne(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,i,52,8),r+8}s.prototype.writeDoubleLE=function(e,t,n){return ne(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return ne(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof Uint8Array.prototype.copyWithin==`function`?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},s.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!s.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=s.isBuffer(e)?e:s.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var V={};function re(e,t,n){V[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}re(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),re(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),re(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=H(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function H(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function ie(e,t,n){oe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&se(t,e.length-(n+1))}function ae(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new V.ERR_OUT_OF_RANGE(`value`,i,e)}ie(r,i,a)}function oe(e,t){if(typeof e!=`number`)throw new V.ERR_INVALID_ARG_TYPE(t,`number`,e)}function se(e,t,n){throw Math.floor(e)===e?t<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(oe(e,n),new V.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}var U=/[^+/0-9A-Za-z-_]/g;function ce(e){if(e=e.split(`=`)[0],e=e.trim().replace(U,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function le(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ue(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function de(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function fe(e){return t.toByteArray(ce(e))}function pe(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function W(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function ge(e){return e!==e}var _e=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function ve(e){return typeof BigInt>`u`?ye:e}function ye(){throw Error(`BigInt not supported`)}})),ge=pe(),_e=W(),ve=class e{constructor(t,n=``,r=``){this.xml=t,this.filePath=n,this.basePath=r,this.layers=new Map,this.transform=t=>{if(!t)return;let n=t.attributes||t._attributes;if(!n)return t;let r={...t,...n,...e.propToNumber(n,`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`.split(`.`)),...e.propToBool(n,[`visible`,`infinite`,`locked`,`bold`,`italic`,`kerning`,`strikeout`,`underline`,`wrap`])};if(r.properties){let t=e.toArray(r.properties.property),n={};for(let e of t){let t=e._attributes;if(!t)continue;let r;switch(t.type){case`file`:r=this.getImagePath(t.value);break;case`object`:case`float`:case`int`:r=+t.value;break;case`bool`:r=t.value==`true`;break;case`class`:r={...this.transform(e)?.properties??{},_classname:t.propertytype};break;default:r=t.value}n[t.name]=r}r.properties=n}r.polygon&&=this.transform(r.polygon),r.polyline&&=this.transform(r.polyline),r.points&&(r=r.points.split(` `).map(e=>{let t=e.split(`,`);return{x:+t[0],y:+t[1]}})),r.point&&=!0,r.ellipse&&=!0,r.text&&(r.text={text:r.text._text,...this.transform(r.text)},delete r.text._text),r.image&&=this.transform(r.image),r.source&&(this.isTilesetSource(r)||(r.source=this.getImagePath(r.source)));let i=r.object||r.objectgroup?.object;return i&&(r.objects=e.toArray(i).map(e=>this.transform(e))),delete r._attributes,delete r.attributes,delete r.object,delete r.objectgroup,r}}static{this.propToNumber=(e,t)=>{for(let n of t)e[n]!==void 0&&(e[n]=+e[n]);return e}}static{this.propToBool=(e,t)=>{for(let n of t)e[n]!==void 0&&(e[n]=e[n]==`true`||e[n]==`1`);return e}}static toArray(e){return e?Array.isArray(e)?e:[e]:[]}getImagePath(e){return this.filePath.startsWith(`http`)?new URL(e,this.filePath).href:ae(this.basePath,e)}isTilesetSource(e){return e.firstgid!==void 0||e.tilewidth!==void 0||e.tileheight!==void 0||e.tilecount!==void 0||e.columns!==void 0}static unpackTileBytes(e,t){let n=t*4;if(e.length!==n)throw Error(`Expected `+n+` bytes of tile data; received `+e.length);let r=0,i=[];for(let t=0;t<n;t+=4)i[r]=e.readUInt32LE(t),r++;return i}static decode(t,n){let{encoding:r,data:i}=t;return r==`base64`?e.unpackTileBytes(_e.Buffer.from(i.trim(),`base64`),n):r==`csv`?i.trim().split(`,`).map(e=>+e):i}parseMap(){let t=(0,ge.xml2js)(this.xml,{compact:!0}),n=(0,ge.xml2js)(this.xml),r=t.map.tileset;t.map.group;let i=t=>{let{objectgroup:n,group:r,layer:a,imagelayer:o}=t,s=t=>{t&&e.toArray(t).forEach(e=>{if(this.layers.has(+e._attributes.id))throw Error(`Tiled Parser Error: Layer with id ${e._attributes.id} already exists`);this.layers.set(+e._attributes.id,e)})};s(n),s(a),s(r),s(o),r&&i(r)};i(t.map);let a=(t,n=[])=>{if(!t)return n;for(let r of t){let{name:t}=r;if(![`layer`,`group`,`imagelayer`,`objectgroup`].includes(t))continue;let i=r.elements?.find(e=>e.name==`data`);r.layer=this.layers.get(+r.attributes.id);let o={...this.transform(i)??{},...this.transform(r),...this.transform(r.layer),layers:a(r.elements),data:i?i.elements[0].text:void 0,type:t==`layer`?`tilelayer`:t};delete o.elements,delete o.layer,o.data&&=e.decode(o,o.width*o.height),n.push(o)}return n},o=a(n.elements[0].elements),s=e.toArray(r).map(e=>this.transform(e)),c={...this.transform(t.map),layers:o,tilesets:s};return delete c.layer,delete c.tileset,delete c.group,delete c.imagelayer,c}parseTileset(){let{tileset:t}=(0,ge.xml2js)(this.xml,{compact:!0}),n={...this.transform(t),image:this.transform(t.image),tiles:e.toArray(t.tile).map(t=>{let n=this.transform(t);return t.animation&&(n.animations=e.toArray(t.animation.frame).map(this.transform)),delete n.animation,n})};return delete n.tile,n}},ye=class{constructor(e){this.properties={},this.properties=e?.properties??{}}getProperty(e,t){let n=this.properties[e];return n===void 0?t:n}hasProperty(e){return!!this.properties[e]}setProperty(e,t){this.properties[e]=t}getType(){return this.class||this.type}},be=2147483648,xe=1073741824,Se=536870912,Ce=268435456,we=class e extends ye{constructor(e){super(e),this.obj=e,this._gid=e?.gid}static getRealGid(e){return e&268435455}get horizontalFlip(){return!!(this._gid&be)}get verticalFlip(){return!!(this._gid&xe)}get diagonalFlip(){return!!(this._gid&Se)}get rotatedHex120(){return!!(this._gid&Ce)}get gid(){return e.getRealGid(this._gid)}set gid(e){this._gid=e}},Te=class extends we{constructor(e){super(e),this.tile=e;let t=this.properties;Reflect.deleteProperty(e,`gid`),Object.assign(this,e),t&&Object.keys(t).length>0&&(this.properties={...t,...this.properties})}},Ee=class extends we{constructor(e){super(e),this.layerName=``,Object.assign(this,e),e?.gid&&(this.y-=this.height)}},De=class e extends ye{get size(){return this.data.length}constructor(e,t,n){super(e),this.tilesets=t,this.parent=n,this.cacheTiles=!1,this.tiles=[],Object.assign(this,e),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty(`cache-tiles`,!1),this.cacheTiles&&this.propertiesTiles()}createTile(t,n,r){if(t==0)return;let i=we.getRealGid(t),a=e.findTileSet(i,this.tilesets);if(!a)return;let o=a.getTile(i-a.firstgid);return o?new Te({...o.tile,gid:t,index:n,layerIndex:r}):new Te({gid:t,index:n,layerIndex:r})}mergePropertiesWithParent(){let e=this.getLayerParent();if(this.properties||={},e){for(let t in e.properties){let n=e.properties[t];if(this.properties[t]===void 0)this.properties[t]=n;else if(t==`z`)this.properties[t]+=n;else continue}this.opacity=Math.round((e.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(e.offsetx??0)+(this.offsetx??0),this.offsety=(e.offsety??0)+(this.offsety??0),this.locked=e.locked??!1}}propertiesTiles(){if(!this.data)return;let e=this.data;for(let t=0;t<e.length;t++){let n=e[t];this.tiles.push(this.createTile(n,t))}}mapObjects(){this.objects&&=this.objects.map(e=>{let t=new Ee(e);return t.layerName=this.name,t})}getTileByIndex(e){return this.cacheTiles?this.tiles[e]:this.createTile(this.data[e],e)}static findTileSet(e,t){let n;for(let r=t.length-1;r>=0&&(n=t[r],!(n.firstgid&&n.firstgid<=e));r--);return n}getLayerParent(){return this.parent}tilesForEach(e){for(let t=0;t<this.data.length;t++){if(this.cacheTiles){e(this.tiles[t],t);continue}e(this.createTile(this.data[t],t),t)}}setData(e,t){this.data[e]=t}},Oe=class extends ye{constructor(e){super(e),this.tileset=e,this.cacheTileId=new Map,Object.assign(this,e),this.margin=this.margin??0,this.spacing=this.spacing??0;let t=e.tiles||e.tile||[];for(let e of t)this.addTile(e);Reflect.deleteProperty(this,`tiles`),Reflect.deleteProperty(this,`tile`)}addTile(e){let t=new Te(e);return this.cacheTileId.set(t.id,t),t}getTile(e){return this.cacheTileId.get(+e)}},ke=class e{constructor(e,{basePath:t=``,staticDir:n=``,relativePath:r=``}={}){this.file=e,this.basePath=t}static isBrowser(){return typeof window<`u`&&!window.useFileSystem}static typeOfFile(e){e=e.trim();let t=typeof e==`string`,n={isXml:t&&e.startsWith(`<?xml`),isObject:!!e.version,isHttp:t&&e.startsWith(`http`)};return{...n,isPath:!n.isXml&&!n.isObject&&!n.isHttp}}_parseFile(t,n,r){let i=t=>e.typeOfFile(t).isXml,a=e=>{if(!e)return r(null);if(i(e)){let i=new ve(e,t,this.basePath);if(n==`map`)return r(i.parseMap());if(n==`tileset`)return r(i.parseTileset())}return r(JSON.parse(e))};if(e.typeOfFile(t).isObject)return r(t);let{isHttp:o}=e.typeOfFile(t);if(i(t))a(t);else if(o||e.isBrowser()){let n=o?t:ae(this.basePath,t);e.isBrowser()&&window.urlCache&&(n=window.urlCache[t]),fetch(n,{headers:{"Content-Type":`application/xml`}}).then(e=>e.text()).then(a).catch(e=>r(null,e))}}parseFile(t,n={}){let{getOnlyBasename:r}=n,i=e=>e.substring(e.lastIndexOf(`/`)+1);r&&e.typeOfFile(this.file).isPath&&(this.file=i(this.file)),this._parseFile(this.file,`map`,(n,a)=>{let o=!1;if(a)return t(null,a);if(n.tilesets){let a=[],s=()=>{c++,c==n.tilesets.length&&!o&&(n.tilesets=a,t(n))},c=0;for(let c=0;c<n.tilesets.length;c++){let l=n.tilesets[c];if(!l.source||l.tiles||l.image||l.tile){a[c]=l,s();continue}r&&e.typeOfFile(l.source).isPath&&(l.source=i(l.source)),this._parseFile(l.source,`tileset`,(e,n)=>{if(n)return o=!0,t(null,n);a[c]={...e,firstgid:l.firstgid},s()})}}})}parseFilePromise(e={}){return new Promise((t,n)=>{this.parseFile((e,r)=>{e?t(e):n(r)},e)})}},Ae={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:`linear`,use32bitIndex:!1},je=Object.defineProperty,Me=(e,t,n)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ne=(e,t,n)=>(Me(e,typeof t==`symbol`?t:t+``,n),n),Pe=class e extends n.Geometry{constructor(t){let r=new n.Buffer({data:new Float32Array(2),label:`tilemap-buffer`,usage:n.BufferUsage.VERTEX|n.BufferUsage.COPY_DST,shrinkToFit:!1}),i=e.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:r,format:`float32x2`,stride:i,offset:0},aTextureCoord:{buffer:r,format:`float32x2`,stride:i,offset:8},aFrame:{buffer:r,format:`float32x4`,stride:i,offset:16},aAnim:{buffer:r,format:`float32x2`,stride:i,offset:32},aTextureId:{buffer:r,format:`sint32`,stride:i,offset:40},aAnimDivisor:{buffer:r,format:`float32`,stride:i,offset:44},aAlpha:{buffer:r,format:`float32`,stride:i,offset:48}}}),Ne(this,`lastTimeAccess`,0),Ne(this,`vertSize`,e.vertSize),Ne(this,`vertPerQuad`,e.vertPerQuad),Ne(this,`stride`,e.stride),Ne(this,`buf`),this.buf=r}};Ne(Pe,`vertSize`,13),Ne(Pe,`vertPerQuad`,4),Ne(Pe,`stride`,Pe.vertSize*4);var Fe=Pe,Ie=Object.defineProperty,Le=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Re=(e,t,n)=>(Le(e,typeof t==`symbol`?t:t+``,n),n),ze=class{constructor(){Re(this,`pipe_uniforms`,new n.UniformGroup({u_proj_trans:{value:new n.Matrix,type:`mat3x3<f32>`},u_anim_frame:{value:new Float32Array(2),type:`vec2<f32>`}}))}},Be=class{constructor(e,t){Re(this,`renderer`),Re(this,`tileAnim`,[0,0]),Re(this,`ibLen`,0),Re(this,`indexBuffer`,null),Re(this,`shader`),Re(this,`adaptor`),this.renderer=e,this.adaptor=t,this.adaptor.init(),this.indexBuffer=new n.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:`index-tilemap-buffer`,usage:n.BufferUsage.INDEX|n.BufferUsage.COPY_DST}),this.indexBuffer.destroy=n.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){let e=new Fe(this.indexBuffer);return e.lastTimeAccess=Date.now(),e}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(e){let t=e*6;t<=this.ibLen||(this.ibLen=t,this.indexBuffer.data=Ve(e,Ae.use32bitIndex?new Uint32Array(t):new Uint16Array(t)))}destroyRenderable(e){e.vb.destroy(!0),e.vb=null}addRenderable(e,t){let n=this.renderer.renderPipes.batch;e.updateBuffer(this),e.checkValid(),e.getTileset().update(),e.is_valid&&(n.break(t),t.add(e._instruction))}updateRenderable(e,t){e.updateBuffer(this),e.getTileset().update()}validateRenderable(e){return e.checkValid()}execute({tilemap:e}){if(!e.isRenderable)return;e.state.blendMode=e.groupBlendMode;let{pipe_uniforms:t}=this.adaptor,n=t.uniforms.u_proj_trans,r=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms,i=this.tileAnim,{u_anim_frame:a}=t.uniforms;r.uProjectionMatrix.copyTo(n).append(r.uWorldTransformMatrix).append(e.worldTransform),e.compositeParent&&(i=e.parent.tileAnim||i),a[0]=i[0],a[1]=i[1],t.update(),this.adaptor.execute(this,e)}};Re(Be,`extension`,{type:[n.ExtensionType.WebGLPipes,n.ExtensionType.WebGPUPipes],name:`tilemap`});function Ve(e,t){let n=e*6;if(t.length!==n)throw Error(`Out buffer length is incorrect, got ${t.length} and expected ${n}`);for(let e=0,r=0;e<n;e+=6,r+=4)t[e+0]=r+0,t[e+1]=r+1,t[e+2]=r+2,t[e+3]=r+0,t[e+4]=r+2,t[e+5]=r+3;return t}var He=Object.defineProperty,Ue=(e,t,n)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,We=(e,t,n)=>(Ue(e,typeof t==`symbol`?t:t+``,n),n),Ge=class{constructor(e){We(this,`max_textures`),We(this,`arr`,[]),We(this,`count`,0),We(this,`dirty`,!1),We(this,`dirty_gpu`,!1),We(this,`bind_group`,null),We(this,`bind_group_resources`,{}),We(this,`tex_sizes`,null),We(this,`null_color`,new Float32Array([0,0,0,.5])),We(this,`tex_buf`,null),this.max_textures=e,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new n.Buffer({usage:n.BufferUsage.UNIFORM|n.BufferUsage.COPY_DST})}get length(){return this.count}push(e){this.arr[this.count++]=e,this.dirty=!0}at(e){return this.arr[e]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;let{tex_sizes:e,arr:t,count:n,max_textures:r,null_color:i}=this;for(let r=0;r<n;r++){let n=t[r];n&&(e[r*4]=n.pixelWidth,e[r*4+1]=n.pixelHeight,e[r*4+2]=1/n.pixelWidth,e[r*4+3]=1/n.pixelHeight)}e[r*4]=i[0],e[r*4+1]=i[1],e[r*4+2]=i[2],e[r*4+3]=i[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;let{bind_group_resources:e,max_textures:t,arr:r,count:i}=this,a=0;e[a++]=new n.UniformGroup({u_texture_size:{value:this.tex_sizes,type:`vec4<f32>`,size:t},u_null_color:{value:this.null_color,type:`vec4<f32>`}});for(let o=0;o<t;o++){let t=(o<i?r[o]:null)||n.Texture.EMPTY.source;e[a++]=t.source,e[a++]=t.style}return this.bind_group||=new n.BindGroup(e),this.bind_group}static generate_gpu_textures(e){let t=[];t.push(`struct TextureArrayFields {`),t.push(` u_texture_size: array<vec4f, ${e}>,`),t.push(` u_null_color: vec4f`),t.push(`}`),t.push(`@group(1) @binding(0) var<uniform> taf: TextureArrayFields;`);for(let n=0;n<e;n++)t.push(`@group(1) @binding(${n*2+1}) var u_texture_${n}: texture_2d<f32>;`),t.push(`@group(1) @binding(${n*2+2}) var u_sampler_${n}: sampler;`);t.push(`fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {`),t.push(`switch texture_id {`);for(let n=0;n<e;n++)t.push(` case ${n}: { return textureSampleGrad(u_texture_${n}, u_sampler_${n}, uv, dx, dy); }`);return t.push(` default: { return taf.u_null_color; }`),t.push(`} }`),t.join(`
97
+ `)}static generate_gl_textures(e){let t=[];t.push(`uniform vec4 u_texture_size[${e+1}];`),t.push(`uniform sampler2D u_textures[${e}];`),t.push(`uniform vec4 u_null_color;`),t.push(`vec4 sampleMultiTexture(float texture_id, vec2 uv) {`),t.push(`if(texture_id < -0.5) return u_texture_size[${e}];`);for(let n=0;n<e;n++)t.push(`if(texture_id < ${n}.5) return texture(u_textures[${n}], uv * u_texture_size[${n}].zw);`);return t.push(`return u_texture_size[${e}];`),t.push(`}`),t.join(`
98
+ `)}static gl_gen_resources(e){let t=[];for(let n=0;n<e;n++)t[n]=n;let n=[];for(let t=0;t<e;t++)n.push(2048),n.push(2048),n.push(1/2048),n.push(1/2048);return{u_textures:{value:t,type:`i32`,size:e},u_texture_size:{value:n,type:`vec4<f32>`,size:e}}}},Ke=Object.defineProperty,qe=(e,t,n)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Je=(e,t,n)=>(qe(e,typeof t==`symbol`?t:t+``,n),n),Ye=`
99
+ in vec2 aVertexPosition;
100
+ in vec2 aTextureCoord;
101
+ in vec4 aFrame;
102
+ in vec2 aAnim;
103
+ in float aAnimDivisor;
104
+ in float aTextureId;
105
+ in float aAlpha;
106
+
107
+ uniform mat3 u_proj_trans;
108
+ uniform vec2 u_anim_frame;
109
+
110
+ out vec2 vTextureCoord;
111
+ out float vTextureId;
112
+ out vec4 vFrame;
113
+ out float vAlpha;
114
+
115
+ void main(void)
116
+ {
117
+ gl_Position = vec4((u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
118
+ vec2 animCount = floor((aAnim + 0.5) / 2048.0);
119
+ vec2 animFrameOffset = aAnim - animCount * 2048.0;
120
+ vec2 currentFrame = floor(u_anim_frame / aAnimDivisor);
121
+ vec2 loop_num = floor((currentFrame + 0.5) / animCount);
122
+ vec2 animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
123
+
124
+ vTextureCoord = aTextureCoord + animOffset;
125
+ vFrame = aFrame + vec4(animOffset, animOffset);
126
+ vTextureId = aTextureId;
127
+ vAlpha = aAlpha;
128
+ }
129
+ `,Xe=`
130
+ #ifdef GL_FRAGMENT_PRECISION_HIGH
131
+ precision highp float;
132
+ #else
133
+ precision mediump float;
134
+ #endif
135
+ in vec2 vTextureCoord;
136
+ in vec4 vFrame;
137
+ in float vTextureId;
138
+ in float vAlpha;
139
+
140
+ //include_textures
141
+
142
+ void main(void)
143
+ {
144
+ float textureId = floor(vTextureId + 0.5);
145
+ vec2 textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
146
+ vec4 color = sampleMultiTexture(textureId, textureCoord);
147
+ finalColor = color * vAlpha;
148
+ }
149
+ `,Ze=class extends ze{constructor(){super(...arguments),Je(this,`_shader`,null),Je(this,`max_textures`,Ae.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){let n=e.renderer,r=this._shader,i=t.getTileset(),a=r.resources.texture_uniforms;a.uniforms.u_texture_size!==i.tex_sizes&&(a.uniforms.u_texture_size=i.tex_sizes,a.update());for(let e=0;e<i.length;e++)n.texture.bind(i.arr[e],e);n.encoder.draw({geometry:t.vb,shader:r,state:t.state,size:t.rects_count*6})}init(){this._shader=new n.Shader({glProgram:n.GlProgram.from({vertex:Ye,fragment:Xe.replace(`//include_textures`,Ge.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new n.UniformGroup(Ge.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}};Je(Ze,`extension`,{type:[n.ExtensionType.WebGLPipesAdaptor],name:`tilemap`});var Qe=Object.defineProperty,$e=(e,t,n)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,et=(e,t,n)=>($e(e,typeof t==`symbol`?t:t+``,n),n),tt=`
150
+ struct GlobalUniforms {
151
+ uProjectionMatrix:mat3x3f,
152
+ uWorldTransformMatrix:mat3x3f,
153
+ uWorldColorAlpha: vec4f,
154
+ uResolution: vec2f,
155
+ }
156
+
157
+ struct TilemapUniforms {
158
+ u_proj_trans:mat3x3f,
159
+ u_anim_frame:vec2f
160
+ }
161
+
162
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
163
+ @group(2) @binding(0) var<uniform> loc: TilemapUniforms;
164
+
165
+ struct VSOutput {
166
+ @builtin(position) vPosition: vec4f,
167
+ @location(0) @interpolate(flat) vTextureId : i32,
168
+ @location(1) vTextureCoord : vec2f,
169
+ @location(2) @interpolate(flat) vFrame : vec4f,
170
+ @location(3) vAlpha : f32
171
+ };
172
+
173
+ @vertex
174
+ fn mainVert(
175
+ @location(6) aVertexPosition: vec2f,
176
+ @location(4) aTextureCoord: vec2f,
177
+ @location(3) aFrame: vec4f,
178
+ @location(1) aAnim: vec2f,
179
+ @location(2) aAnimDivisor: f32,
180
+ @location(5) aTextureId: i32,
181
+ @location(0) aAlpha: f32,
182
+ ) -> VSOutput {
183
+
184
+ var vPosition = vec4((loc.u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
185
+ var animCount = floor((aAnim + 0.5) / 2048.0);
186
+ var animFrameOffset = aAnim - animCount * 2048.0;
187
+ var currentFrame = floor(loc.u_anim_frame / aAnimDivisor);
188
+ var loop_num = floor((currentFrame + 0.5) / animCount);
189
+ var animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
190
+ var vTextureCoord = aTextureCoord + animOffset;
191
+ var vFrame = aFrame + vec4(animOffset, animOffset);
192
+
193
+ return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
194
+ };
195
+ `,nt=`
196
+ //include_textures
197
+
198
+ @fragment
199
+ fn mainFrag(
200
+ @location(0) @interpolate(flat) vTextureId : i32,
201
+ @location(1) vTextureCoord : vec2f,
202
+ @location(2) @interpolate(flat) vFrame : vec4f,
203
+ @location(3) vAlpha : f32,
204
+ ) -> @location(0) vec4f {
205
+ var textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
206
+ var uv = textureCoord * taf.u_texture_size[vTextureId].zw;
207
+ var dx = dpdx(uv);
208
+ var dy = dpdy(uv);
209
+ var color = sampleMultiTexture(vTextureId, uv, dx, dy);
210
+ return color * vAlpha;
211
+ };
212
+ `,rt=class extends ze{constructor(){super(...arguments),et(this,`_shader`,null),et(this,`max_textures`,Ae.TEXTURES_PER_TILEMAP),et(this,`bind_group`,null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){let n=e.renderer,r=this._shader;r.groups[0]=n.globalUniforms.bindGroup,r.groups[1]=t.getTileset().getBindGroup(),r.groups[2]=this.bind_group,n.encoder.draw({geometry:t.vb,shader:r,state:t.state,size:t.rects_count*6})}init(){this._shader=new n.Shader({gpuProgram:n.GpuProgram.from({vertex:{source:tt,entryPoint:`mainVert`},fragment:{source:nt.replace(`//include_textures`,Ge.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new n.BindGroup({ut:this.pipe_uniforms})}};et(rt,`extension`,{type:[n.ExtensionType.WebGPUPipesAdaptor],name:`tilemap`});var it=Object.defineProperty,at=(e,t,n)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G=(e,t,n)=>(at(e,typeof t==`symbol`?t:t+``,n),n),ot=(e=>(e[e.U=0]=`U`,e[e.V=1]=`V`,e[e.X=2]=`X`,e[e.Y=3]=`Y`,e[e.TILE_WIDTH=4]=`TILE_WIDTH`,e[e.TILE_HEIGHT=5]=`TILE_HEIGHT`,e[e.ROTATE=6]=`ROTATE`,e[e.ANIM_X=7]=`ANIM_X`,e[e.ANIM_Y=8]=`ANIM_Y`,e[e.TEXTURE_INDEX=9]=`TEXTURE_INDEX`,e[e.ANIM_COUNT_X=10]=`ANIM_COUNT_X`,e[e.ANIM_COUNT_Y=11]=`ANIM_COUNT_Y`,e[e.ANIM_DIVISOR=12]=`ANIM_DIVISOR`,e[e.ALPHA=13]=`ALPHA`,e))(ot||{}),st=Object.keys(ot).length/2,ct=class extends n.ViewContainer{constructor(e){super({}),G(this,`shadowColor`,new Float32Array([0,0,0,.5])),G(this,`state`,n.State.for2d()),G(this,`is_valid`,!1),G(this,`renderPipeId`,`tilemap`),G(this,`canBundle`,!0),G(this,`_instruction`,{renderPipeId:`tilemap`,tilemap:this}),G(this,`tileAnim`,null),G(this,`rects_count`,0),G(this,`compositeParent`,!1),G(this,`tileset`,new Ge(Ae.TEXTURES_PER_TILEMAP)),G(this,`tilemapBounds`,new n.Bounds),G(this,`hasAnimatedTile`,!1),G(this,`pointsBuf`,[]),G(this,`batched`),G(this,`vbId`,0),G(this,`vb`,null),G(this,`vbBuffer`,null),G(this,`vbArray`,null),G(this,`vbInts`,null),this.setTileset(e)}checkValid(){let e=this.tileset.count>0&&this.pointsBuf.length>0,t=this.is_valid!==e;return this.is_valid=e,t!==e}updateBounds(){let e=this.tilemapBounds;this._bounds.minX=e.minX,this._bounds.maxX=e.maxX,this._bounds.minY=e.minY,this._bounds.maxY=e.maxY}getTileset(){return this.tileset}setTileset(e=[]){let t=this.tileset;if(e instanceof Ge)this.tileset=e,this.didViewUpdate=!0;else if(e instanceof n.TextureSource){if(t.count===1&&t.arr[0]===e)return this;t=this.tileset=new Ge(Ae.TEXTURES_PER_TILEMAP),t.push(e),this.didViewUpdate=!0}else{if(e.length===t.count){let n=!0;for(let r=0;r<e.length;r++)if(e[r]?.source!==t.arr[r]){n=!1;break}if(n)return this}t=this.tileset=new Ge(Ae.TEXTURES_PER_TILEMAP);for(let n=0;n<e.length;n++)t.push(e[n]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(e,t,r,i={}){this.didViewUpdate=!0;let a,o=-1,s=!1;if(typeof e==`number`)o=e,s=!0,a=this.tileset.arr[o];else{let t;t=typeof e==`string`?n.Texture.from(e):e;let r=this.tileset;for(let e=0;e<r.count;e++)if(r.arr[e]===t.source){o=e;break}`frame`in t&&(i.u=i.u??t.frame.x,i.v=i.v??t.frame.y,i.tileWidth=i.tileWidth??t.orig.width,i.tileHeight=i.tileHeight??t.orig.height),a=t.source}if(!s&&!a)return console.error(`The tile texture was not found in the tilemap tileset.`),this;let{u:c=0,v:l=0,tileWidth:u=a.width,tileHeight:d=a.height,animX:f=0,animY:p=0,rotate:m=0,animCountX:h=1024,animCountY:g=1024,animDivisor:_=1,alpha:v=1}=i,y=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||f>0||p>0,y.push(c),y.push(l),y.push(t),y.push(r),y.push(u),y.push(d),y.push(m),y.push(f|0),y.push(p|0),y.push(o),y.push(h),y.push(g),y.push(_),y.push(v),this.tilemapBounds.addFrame(t,r,t+u,r+d),this}tileRotate(e){let t=this.pointsBuf;t[t.length-(st-9)]=e}tileAnimX(e,t){let n=this.pointsBuf;n[n.length-(st-7)]=e,n[n.length-(st-10)]=t}tileAnimY(e,t){let n=this.pointsBuf;n[n.length-(st-8)]=e,n[n.length-(st-11)]=t}tileAnimDivisor(e){let t=this.pointsBuf;t[t.length-(st-12)]=e}tileAlpha(e){let t=this.pointsBuf;t[t.length-(st-13)]=e}destroyVb(){this.vb&&=(this.vb.destroy(),null)}updateBuffer(e){let t=this.pointsBuf,r=t.length/st,i=this.vb;if(this.tileset.count===0||r===0||this.rects_count===r&&i)return;this.rects_count=r,i||(i=e.createVb(),this.vb=i,this.vbId=i.id,this.vbBuffer=null);let a=r*i.vertPerQuad;e.checkIndexBuffer(r);let o=i.getBuffer(`aVertexPosition`),s=i.stride*a;if(!this.vbBuffer||this.vbBuffer.byteLength<s){let e=i.stride;for(;e<s;)e*=2;this.vbBuffer=new ArrayBuffer(e),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}let c=this.vbArray,l=this.vbInts,u=0,d=0;for(let e=0;e<t.length;e+=st){let r=.5;this.compositeParent&&(d=t[e+9]);let i=t[e+2],a=t[e+3],o=t[e+4],s=t[e+5],f=t[e+0],p=t[e+1],m=t[e+6],h=t[e+7],g=t[e+8],_=t[e+10]||1024,v=t[e+11]||1024,y=h+_*2048,b=g+v*2048,x=t[e+12],S=t[e+13],C,w,T,E,D,O,k,A;if(m===0)C=f,w=p,T=f+o,E=p,D=f+o,O=p+s,k=f,A=p+s;else{let e=o/2,t=s/2;m%4!=0&&(e=s/2,t=o/2);let r=f+e,i=p+t;m=n.groupD8.add(m,n.groupD8.NW),C=r+e*n.groupD8.uX(m),w=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),T=r+e*n.groupD8.uX(m),E=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),D=r+e*n.groupD8.uX(m),O=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),k=r+e*n.groupD8.uX(m),A=i+t*n.groupD8.uY(m)}c[u++]=i,c[u++]=a,c[u++]=C,c[u++]=w,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i+o,c[u++]=a,c[u++]=T,c[u++]=E,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i+o,c[u++]=a+s,c[u++]=D,c[u++]=O,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i,c[u++]=a+s,c[u++]=k,c[u++]=A,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S}o.data=c}isModified(e){return!!(this.rects_count*st!==this.pointsBuf.length||e&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/st}addBounds(e){let t=this.tilemapBounds;e.addFrame(t.minX,t.minY,t.maxX,t.maxY)}get bounds(){return this.tilemapBounds}destroy(e){super.destroy(e),this.destroyVb()}addFrame(e,t,n,r,i){return this.tile(e,t,n,{animX:r,animY:i}),!0}addRect(e,t,n,r,i,a,o,s=0,c=0,l=0,u=1024,d=1024,f=1,p=1){return this.tile(e,r,i,{u:t,v:n,tileWidth:a,tileHeight:o,animX:s,animY:c,rotate:l,animCountX:u,animCountY:d,animDivisor:f,alpha:p})}},lt=Object.defineProperty,ut=(e,t,n)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t,n)=>(ut(e,typeof t==`symbol`?t:t+``,n),n),ft=class extends n.Container{constructor(e){super(),dt(this,`texturesPerTilemap`),dt(this,`tileAnim`,null),dt(this,`lastModifiedTilemap`,null),dt(this,`modificationMarker`,0),dt(this,`setBitmaps`,this.tileset),this.texturesPerTilemap=Ae.TEXTURES_PER_TILEMAP,this.tileset(e)}tileset(e){e||=[];let t=this.texturesPerTilemap,n=this.children.length,r=Math.ceil(e.length/t);for(let i=0;i<Math.min(n,r);i++)this.children[i].setTileset(e.slice(i*t,(i+1)*t));for(let i=n;i<r;i++){let n=new ct(e.slice(i*t,(i+1)*t));n.compositeParent=!0,this.addChild(n)}return this}clear(){for(let e=0;e<this.children.length;e++)this.children[e].clear();return this.modificationMarker=0,this}tileRotate(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(e),this}tileAnimX(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(e,t),this}tileAnimY(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(e,t),this}tileAnimDivisor(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(e),this}tile(e,t,r,i={}){let a=null,o=this.children;if(this.lastModifiedTilemap=null,typeof e==`number`){let n=e/this.texturesPerTilemap>>0,s=0;if(a=o[n],a)s=e%this.texturesPerTilemap;else{if(a=o[0],!a)return this;s=0}a.tile(s,t,r,i)}else{typeof e==`string`&&(e=n.Texture.from(e));for(let t=0;t<o.length;t++){let n=o[t],r=n.getTileset().arr;for(let t=0;t<r.length;t++)if(r[t]===e.source){a=n;break}if(a)break}if(!a){for(let t=o.length-1;t>=0;t--){let n=o[t];if(n.getTileset().count<this.texturesPerTilemap){a=n,n.getTileset().push(e.source);break}}a||(a=new ct(e.source),a.compositeParent=!0,this.addChild(a))}a.tile(e,t,r,i)}return this.lastModifiedTilemap=a,this}isModified(e){let t=this.children;if(this.modificationMarker!==t.length)return!0;for(let n=0;n<t.length;n++)if(t[n].isModified(e))return!0;return!1}clearModify(){let e=this.children;this.modificationMarker=e.length;for(let t=0;t<e.length;t++)e[t].clearModify()}addFrame(e,t,n,r,i,a,o,s,c){return this.tile(e,t,n,{animX:r,animY:i,animCountX:a,animCountY:o,animDivisor:s,alpha:c})}addRect(e,t,n,r,i,a,o,s,c,l,u,d){let f=e/this.texturesPerTilemap>>0,p=e%this.texturesPerTilemap;return this.children[f]&&this.children[f].getTileset().count>0?(this.lastModifiedTilemap=this.children[f],this.lastModifiedTilemap.addRect(p,t,n,r,i,a,o,s,c,l,u,d)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}};n.extensions.add(Be),n.extensions.add(Ze),n.extensions.add(rt);var pt=class e extends n.AnimatedSprite{static getTextures(e,t){let n=[];return e.animations&&e.animations.length?e.animations.forEach(e=>{n.push(t.textures[e.tileid])}):n.push(t.textures[e.gid-t.firstgid]),n}constructor(t,n){super(e.getTextures(t,n)),this.tile=t,this.tileSet=n,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=e.getTextures(t,n),this.texture=this.textures[0],this.flip()}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(e){let t=this.animations.length;if(t>1){let n=(this.animations[1].tileid-this.animations[0].tileid)*this.width;e.tileAnimX(n,t)}}flip(){let e,t=0,r=r=>{t++,e=e?n.groupD8.add(e,r):r};this.tile.horizontalFlip&&r(n.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&r(n.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(t%2==0?r(n.groupD8.MAIN_DIAGONAL):r(n.groupD8.REVERSE_DIAGONAL))}};Ae.use32bitIndex=!0;var mt=class e extends (0,t.DisplayObject)(ft){constructor(...e){super(...e),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(e,t){let n;for(let r=t.length-1;r>=0&&(n=t[r],!(n.firstgid&&n.firstgid<=e));r--);return n}createTile(t,n,r={}){let{real:i,filter:a}=r,{tilewidth:o,tileheight:s,width:c}=this._layer;i&&(t=Math.floor(t/o),n=Math.floor(n/s));let l=t+n*c,u=this._layer.getTileByIndex(l);if(!u||u&&u.gid==0)return;let d=e.findTileSet(u.gid,this.tileSets);if(!d)return;let f=new pt(u,d);if(f.x=t*o,f.y=n*s+(s-f.texture.height),f._x=t,f._y=n,d.tileoffset&&(f.x+=d.tileoffset.x??0,f.y+=d.tileoffset.y??0),!(a&&!a(f)))return f}_addFrame(e,t,n){let r=this.tile(e.texture,e.x,e.y,{rotate:e.texture.rotate});e.setAnimation(r),this._tiles[t+`;`+n]=e}async onMount(e){let{props:t}=e;this.tileSets=t.tilesets,this._layer=new De({...t},this.tileSets);let n=t.context.tick;this.subscriptionTick=n.observable.subscribe(({value:e})=>{e.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(e)}onUpdate(e){if(super.onUpdate(e),this.isMounted){e.tileheight&&(this._layer.tileheight=e.tileheight),e.tilewidth&&(this._layer.tilewidth=e.tilewidth),e.width&&(this._layer.width=e.width),e.height&&(this._layer.height=e.height),e.parallaxX&&(this._layer.parallaxX=e.parallaxx),e.parallaxY&&(this._layer.parallaxY=e.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let t=0;t<this._layer.width;t++){let n=this.createTile(t,e);n&&this._addFrame(n,t,e)}}}async onDestroy(e){this.subscriptionTick.unsubscribe(),await super.onDestroy(e)}};(0,t.registerComponent)(`CompositeTileLayer`,mt);function ht(e){return(0,t.createComponent)(`CompositeTileLayer`,e)}var gt=class extends Oe{constructor(e){super(e),this.textures=[],this.tileGroups={}}loadGroup(){}async load(e){let t=await n.Assets.load(e);for(let e=this.margin;e<this.image.height;e+=this.tileheight+this.spacing)for(let r=this.margin;r<this.image.width;r+=this.tilewidth+this.spacing)this.textures.push(new n.Texture({source:t.source,frame:new n.Rectangle(+r,+e,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}};function _t(e,t,n){let r=[];for(let n of e){if(n.type!==ie.Tile){r.push(n);continue}let e=new Map,i;if(Array.isArray(n.data))i=n.data.map(e=>typeof e==`number`?e:parseInt(String(e),10));else{r.push(n);continue}let a=0,o=0;for(let n=0;n<i.length;n++){let r=i[n];if(r===0)continue;a++;let s;for(let e=t.length-1;e>=0;e--)if(t[e].firstgid&&t[e].firstgid<=r){s=t[e];break}if(!s){e.has(0)||e.set(0,Array(i.length).fill(0)),e.get(0)[n]=r;continue}let c=r-s.firstgid,l=s.tileset.tiles?.[c]?.properties,u=l?.z??0;l?.z!==void 0&&o++,e.has(u)||e.set(u,Array(i.length).fill(0)),e.get(u)[n]=r}let s=Array.from(e.keys()).sort((e,t)=>e-t);for(let t of s){let i=e.get(t);if(i.some(e=>e!==0)){let e={...n,name:`${n.name}_z${t}`,data:i,properties:{...n.properties,z:t}};r.push(e)}}}return r.sort((e,t)=>(e.properties?.z??.5)-(t.properties?.z??.5)),r}function vt(e){let{map:n,basePath:r,createLayersPerTilesZ:i}=(0,t.useProps)(e,{createLayersPerTilesZ:!1,basePath:``}),a=(0,t.signal)([]),o=e.objectLayer,s=[],c={},l=async(e,t=``)=>typeof e==`string`?await new ke(e,{basePath:t}).parseFilePromise({getOnlyBasename:!1}):e;(0,t.effect)(async()=>{let e=n();if(e){c=await l(e,r()),s=[];for(let e of c.tilesets)e.tile&&(e.tiles=e.tile),e.tiles||=[],s.push(await new gt(e).load(e.image.source));let t=c.layers;i()&&(t=_t(c.layers,s,c)),a.set(t)}});let u=(e,n={})=>(0,t.h)(t.Container,n,(0,t.loop)(e,e=>{switch(e.type){case ie.Tile:return(0,t.h)(ht,{tilewidth:c.tilewidth,tileheight:c.tileheight,width:c.width,height:c.height,...e,tilesets:s});case ie.Image:let{width:n,height:r,source:i}=e.image;return(0,t.h)(t.TilingSprite,{image:i,...e,width:e.repeatx?e.width*e.tilewidth:n,height:e.repeaty?e.height*e.tileheight:r});case ie.Group:return u((0,t.signal)(e.layers),e);case ie.ObjectGroup:let a=o?.(e);return(0,t.h)(t.Container,e,a);default:return(0,t.h)(t.Container)}}));return(0,t.h)(t.Container,e,u(a))}function yt(){return new n.GlProgram({vertex:`
213
+ precision mediump float;
214
+ in vec2 aPosition;
215
+ in vec2 aUV;
216
+ out vec2 vUV;
217
+ uniform mat3 uProjectionMatrix;
218
+ uniform mat3 uWorldTransformMatrix;
219
+ uniform mat3 uTransformMatrix;
220
+ void main(void) {
221
+ vUV = aUV;
222
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
223
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
224
+ }
225
+ `,fragment:`
226
+ precision mediump float;
227
+ in vec2 vUV;
228
+ out vec4 finalColor;
229
+
230
+ uniform float uTime;
231
+ uniform vec2 uResolution;
232
+ uniform float uSnowSpeed;
233
+ uniform float uWindDirection;
234
+ uniform float uWindStrength;
235
+ uniform float uSnowDensity;
236
+ uniform float uMaxFlakes;
237
+
238
+ float hash(vec2 p) {
239
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
240
+ }
241
+
242
+ vec2 hash2(vec2 p) {
243
+ return vec2(
244
+ hash(p),
245
+ hash(p + 19.19)
246
+ );
247
+ }
248
+
249
+ float snowLayer(
250
+ vec2 uv,
251
+ float t,
252
+ float scale,
253
+ float speed,
254
+ float wind,
255
+ float density,
256
+ float sizeMin,
257
+ float sizeMax
258
+ ) {
259
+ vec2 p = uv;
260
+ p.x -= wind * t;
261
+ p.y -= t * speed;
262
+
263
+ p *= scale;
264
+ vec2 cell = floor(p);
265
+ vec2 f = fract(p);
266
+
267
+ float rnd = hash(cell);
268
+ if (rnd > density) {
269
+ return 0.0;
270
+ }
271
+
272
+ vec2 jitter = hash2(cell + 3.7);
273
+ float wobble = (hash(cell + 9.1) - 0.5) * 0.3;
274
+ vec2 center = jitter;
275
+ center.x += sin(t * 0.7 + jitter.y * 6.283) * 0.15 + wobble;
276
+ center.y += cos(t * 0.5 + jitter.x * 6.283) * 0.12;
277
+
278
+ float size = mix(sizeMin, sizeMax, rnd);
279
+ float dist = length(f - center);
280
+ float alpha = 1.0 - smoothstep(size * 0.4, size, dist);
281
+ float twinkle = 0.7 + 0.3 * sin(t * 1.2 + rnd * 6.283);
282
+ return alpha * twinkle;
283
+ }
284
+
285
+ void main() {
286
+ vec2 safeResolution = max(uResolution, vec2(1.0));
287
+ vec2 uv = vUV;
288
+ float aspect = safeResolution.x / safeResolution.y;
289
+ uv.x *= aspect;
290
+
291
+ float pixelCount = safeResolution.x * safeResolution.y;
292
+ float resolutionFactor = clamp(pixelCount / 900000.0, 0.6, 1.1);
293
+
294
+ float densityFactor = clamp(uSnowDensity / 180.0, 0.25, 1.3);
295
+ float maxFlakeFactor = clamp(uMaxFlakes / 90.0, 0.4, 1.1);
296
+ float density = clamp(densityFactor * maxFlakeFactor * resolutionFactor, 0.08, 1.0);
297
+
298
+ float wind = uWindDirection * uWindStrength * 0.45;
299
+ float speed = uSnowSpeed * 0.9 + 0.15;
300
+
301
+ float snow = 0.0;
302
+ snow += snowLayer(uv, uTime, 18.0, speed * 0.5, wind * 0.6, density, 0.1, 0.22) * 0.65;
303
+ snow += snowLayer(uv, uTime, 28.0, speed * 0.75, wind * 0.9, density * 0.9, 0.075, 0.16) * 0.8;
304
+ snow += snowLayer(uv, uTime, 40.0, speed, wind, density * 0.75, 0.05, 0.12);
305
+
306
+ float heightFade = mix(0.7, 1.0, uv.y);
307
+ snow *= heightFade;
308
+
309
+ vec3 snowColor = vec3(0.92, 0.95, 1.0);
310
+ float alpha = clamp(snow * 1.1, 0.0, 0.92);
311
+ finalColor = vec4(snowColor * alpha, alpha);
312
+ }
313
+ `})}function bt(){return new n.GlProgram({vertex:`
314
+ precision mediump float;
315
+ in vec2 aPosition;
316
+ in vec2 aUV;
317
+ out vec2 vUV;
318
+ uniform mat3 uProjectionMatrix;
319
+ uniform mat3 uWorldTransformMatrix;
320
+ uniform mat3 uTransformMatrix;
321
+ void main(void) {
322
+ vUV = aUV;
323
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
324
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
325
+ }
326
+ `,fragment:`
327
+ precision mediump float;
328
+ in vec2 vUV;
329
+ out vec4 finalColor;
330
+
331
+ uniform float uTime;
332
+ uniform vec2 uResolution;
333
+ uniform float uSpeed;
334
+ uniform float uScale;
335
+ uniform float uDensity;
336
+ uniform float uHeight;
337
+ uniform vec2 uViewportOrigin;
338
+
339
+ float hash(vec2 p) {
340
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
341
+ }
342
+
343
+ float noise(vec2 p) {
344
+ vec2 i = floor(p);
345
+ vec2 f = fract(p);
346
+ float a = hash(i);
347
+ float b = hash(i + vec2(1.0, 0.0));
348
+ float c = hash(i + vec2(0.0, 1.0));
349
+ float d = hash(i + vec2(1.0, 1.0));
350
+ vec2 u = f * f * (3.0 - 2.0 * f);
351
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
352
+ }
353
+
354
+ float fbm(vec2 p) {
355
+ float value = 0.0;
356
+ float amp = 0.5;
357
+ value += amp * noise(p);
358
+ p = p * 2.03 + vec2(17.13, 9.37);
359
+ amp *= 0.55;
360
+ value += amp * noise(p);
361
+ p = p * 2.01 + vec2(31.71, 4.23);
362
+ amp *= 0.55;
363
+ value += amp * noise(p);
364
+ p = p * 2.02 + vec2(15.41, 27.19);
365
+ amp *= 0.55;
366
+ value += amp * noise(p);
367
+ return value;
368
+ }
369
+
370
+ void main() {
371
+ vec2 safeResolution = max(uResolution, vec2(1.0));
372
+ vec2 rawUv = vUV;
373
+ vec2 uv = rawUv;
374
+ float aspect = safeResolution.x / safeResolution.y;
375
+ uv.x *= aspect;
376
+ vec2 viewportShift = vec2(
377
+ (uViewportOrigin.x / safeResolution.x) * aspect,
378
+ uViewportOrigin.y / safeResolution.y
379
+ );
380
+ vec2 worldUv = uv + viewportShift;
381
+
382
+ float normalizedDensity = uDensity;
383
+ if (normalizedDensity > 4.0) {
384
+ normalizedDensity = normalizedDensity / 120.0;
385
+ }
386
+ float density = clamp(normalizedDensity, 0.0, 2.4);
387
+ float scale = clamp(uScale, 0.25, 4.0);
388
+ float speed = max(uSpeed * 8.0, 0.18);
389
+
390
+ vec2 driftA = vec2(uTime * 0.06 * speed, uTime * 0.02 * speed);
391
+ vec2 driftB = vec2(-uTime * 0.042 * speed, uTime * 0.016 * speed);
392
+ vec2 wobble = vec2(
393
+ sin(uTime * 0.23 * speed + worldUv.y * 4.0) * 0.03,
394
+ cos(uTime * 0.17 * speed + worldUv.x * 3.2) * 0.018
395
+ );
396
+ vec2 flowUv = worldUv + wobble;
397
+
398
+ float layerA = fbm(flowUv * scale + driftA);
399
+ float layerB = fbm(flowUv * (scale * 1.7) + driftB);
400
+ float layerC = fbm(vec2(flowUv.x * 0.75, flowUv.y * 1.35) * (scale * 1.2) + vec2(driftA.x * 0.6, -driftA.y * 0.8));
401
+
402
+ float wisps = smoothstep(0.2, 0.82, layerA);
403
+ float detail = smoothstep(0.28, 0.9, layerB);
404
+ float fogPattern = clamp(wisps * 0.55 + detail * 0.3 + layerC * 0.35, 0.0, 1.2);
405
+
406
+ float heightControl = clamp(uHeight, 0.0, 1.0);
407
+ float fullScreen = step(0.99, heightControl);
408
+ float groundFog = pow(clamp(rawUv.y, 0.0, 1.0), 0.42);
409
+ float heightFactor = mix(groundFog, 1.0, heightControl);
410
+ heightFactor = mix(heightFactor, 1.0, fullScreen);
411
+
412
+ float breathing = 0.9 + 0.1 * sin(uTime * 0.25 * speed);
413
+ float fog = fogPattern * density * heightFactor * breathing;
414
+ float alpha = clamp(fog * 0.82, 0.0, 0.82);
415
+
416
+ vec3 baseColor = vec3(0.84, 0.88, 0.94);
417
+ vec3 brightColor = vec3(0.95, 0.97, 1.0);
418
+ vec3 fogColor = mix(baseColor, brightColor, detail * 0.45);
419
+ finalColor = vec4(fogColor * alpha, alpha);
420
+ }
421
+ `})}function xt(){return new n.GlProgram({vertex:`
422
+ precision mediump float;
423
+ in vec2 aPosition;
424
+ in vec2 aUV;
425
+ out vec2 vUV;
426
+ uniform mat3 uProjectionMatrix;
427
+ uniform mat3 uWorldTransformMatrix;
428
+ uniform mat3 uTransformMatrix;
429
+ void main(void) {
430
+ vUV = aUV;
431
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
432
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
433
+ }
434
+ `,fragment:`
435
+ precision mediump float;
436
+ in vec2 vUV;
437
+ out vec4 finalColor;
438
+
439
+ uniform float uTime;
440
+ uniform vec2 uResolution;
441
+ uniform float uSpeed;
442
+ uniform float uScale;
443
+ uniform float uDensity;
444
+ uniform float uHeight;
445
+ uniform vec2 uViewportOrigin;
446
+ uniform float uSunIntensity;
447
+ uniform vec2 uSunDirection;
448
+ uniform float uRaySpread;
449
+ uniform float uRayTwinkle;
450
+ uniform float uRayTwinkleSpeed;
451
+
452
+ float hash(vec2 p) {
453
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
454
+ }
455
+
456
+ float noise(vec2 p) {
457
+ vec2 i = floor(p);
458
+ vec2 f = fract(p);
459
+ float a = hash(i);
460
+ float b = hash(i + vec2(1.0, 0.0));
461
+ float c = hash(i + vec2(0.0, 1.0));
462
+ float d = hash(i + vec2(1.0, 1.0));
463
+ vec2 u = f * f * (3.0 - 2.0 * f);
464
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
465
+ }
466
+
467
+ float fbm(vec2 p) {
468
+ float v = 0.0;
469
+ float a = 0.7;
470
+ v += a * noise(p);
471
+ p *= 2.1;
472
+ a *= 0.5;
473
+ v += a * noise(p + 17.0);
474
+ p *= 2.2;
475
+ a *= 0.5;
476
+ v += a * noise(p + 29.0);
477
+ return v;
478
+ }
479
+
480
+ void main() {
481
+ vec2 safeResolution = max(uResolution, vec2(1.0));
482
+ vec2 uv = vUV;
483
+ float aspect = safeResolution.x / safeResolution.y;
484
+ uv.x *= aspect;
485
+ vec2 viewportShift = vec2(
486
+ (uViewportOrigin.x / safeResolution.x) * aspect,
487
+ uViewportOrigin.y / safeResolution.y
488
+ );
489
+ vec2 worldUv = uv + viewportShift;
490
+
491
+ float normalizedDensity = uDensity;
492
+ if (normalizedDensity > 4.0) {
493
+ normalizedDensity = normalizedDensity / 100.0;
494
+ }
495
+ float density = clamp(normalizedDensity, 0.0, 2.0);
496
+ float scale = clamp(uScale, 0.2, 4.0);
497
+ float speed = max(uSpeed * 6.0, 0.12);
498
+ vec2 driftMain = vec2(uTime * 0.04 * speed, uTime * 0.012 * speed);
499
+ vec2 driftDetail = vec2(-uTime * 0.028 * speed, uTime * 0.01 * speed);
500
+ vec2 wobble = vec2(
501
+ sin(uTime * 0.18 * speed + worldUv.y * 4.8) * 0.035,
502
+ cos(uTime * 0.16 * speed + worldUv.x * 3.7) * 0.02
503
+ );
504
+ vec2 flowUv = worldUv + wobble;
505
+
506
+ float cloudNoise = fbm(flowUv * scale + driftMain);
507
+ float detailNoise = fbm(flowUv * (scale * 2.4) + driftDetail);
508
+
509
+ float shape = smoothstep(0.4, 0.93, cloudNoise);
510
+ float detail = smoothstep(0.36, 0.9, detailNoise);
511
+ float puff = shape * (0.55 + 0.45 * detail);
512
+
513
+ float heightControl = clamp(uHeight, 0.0, 1.0);
514
+ float fullScreen = step(0.99, heightControl);
515
+ float skyHeight = pow(clamp(1.0 - vUV.y, 0.0, 1.0), 0.68);
516
+ float heightFactor = mix(skyHeight, 1.0, heightControl);
517
+ heightFactor = mix(heightFactor, 1.0, fullScreen);
518
+ float cloud = puff * density * 0.72 * heightFactor;
519
+ float cloudAlpha = clamp(cloud, 0.0, 0.68);
520
+
521
+ vec2 sunDir = uSunDirection;
522
+ if (length(sunDir) < 0.0001) {
523
+ sunDir = vec2(0.55, 1.0);
524
+ }
525
+ sunDir = normalize(sunDir);
526
+ vec2 rayUv = worldUv;
527
+ float spread = clamp(uRaySpread, 0.35, 2.5);
528
+ float rayCoord = dot(rayUv, sunDir) * (6.5 / spread);
529
+ float rayNoise = fbm(vec2(rayCoord, rayUv.y * 0.55));
530
+ float shafts = smoothstep(0.5, 0.9, rayNoise);
531
+ float skyFade = pow(clamp(1.0 - vUV.y, 0.0, 1.0), 1.25);
532
+ float cloudGap = clamp(1.0 - cloudAlpha * 1.05, 0.0, 1.0);
533
+ float twinkleAmount = clamp(uRayTwinkle, 0.0, 1.5);
534
+ float twinkleSpeed = max(uRayTwinkleSpeed, 0.01);
535
+ float twinklePulse = 0.5 + 0.5 * sin(uTime * 1.9 * twinkleSpeed + rayCoord * 1.8);
536
+ float twinkleNoise = fbm(vec2(rayCoord * 1.35 + 13.7, uTime * 0.1 * twinkleSpeed));
537
+ float twinkle = mix(
538
+ 1.0,
539
+ clamp(0.7 + 0.35 * twinklePulse + 0.25 * twinkleNoise, 0.35, 1.55),
540
+ twinkleAmount
541
+ );
542
+ float rayAlpha = shafts * skyFade * cloudGap * clamp(uSunIntensity, 0.0, 2.0) * twinkle * 0.58;
543
+
544
+ vec3 cloudDark = vec3(0.82, 0.87, 0.94);
545
+ vec3 cloudBright = vec3(0.98, 0.99, 1.0);
546
+ vec3 cloudColor = mix(cloudDark, cloudBright, detail * 0.55);
547
+ vec3 rayColor = vec3(1.0, 0.95, 0.8);
548
+
549
+ float totalAlpha = cloudAlpha + rayAlpha;
550
+ float alpha = clamp(totalAlpha, 0.0, 0.86);
551
+ vec3 premulColor = cloudColor * cloudAlpha + rayColor * rayAlpha;
552
+ if (totalAlpha > 0.0001) {
553
+ premulColor *= (alpha / totalAlpha);
554
+ }
555
+ finalColor = vec4(premulColor, alpha);
556
+ }
557
+ `})}var St=new Map,K=e=>typeof e==`function`?e():e;function Ct(e){let t=e*9301+49297;return()=>(t=(t*9301+49297)%233280,t/233280)}function wt(e=1){if(St.has(e))return St.get(e);if(typeof document>`u`)return n.Texture.WHITE;let t=Ct(e),r=document.createElement(`canvas`);r.width=192,r.height=192;let i=r.getContext(`2d`);if(!i)return n.Texture.WHITE;i.clearRect(0,0,r.width,r.height),i.lineCap=`round`;for(let e=0;e<62;e++){let e=t()*r.width,n=t()*r.height,a=18+t()*24,o=4+t()*8,s=.2+t()*.22,c=t()>.76?1.9:1.15,l=i.createLinearGradient(e,n,e+o,n+a);l.addColorStop(0,`rgba(220,235,255,0)`),l.addColorStop(.28,`rgba(220,235,255,${s})`),l.addColorStop(.72,`rgba(235,245,255,${s*.86})`),l.addColorStop(1,`rgba(220,235,255,0)`),i.strokeStyle=l,i.lineWidth=c,i.beginPath(),i.moveTo(e,n),i.lineTo(e+o,n+a),i.stroke()}let a=n.Texture.from(r);return St.set(e,a),a}var Tt=class extends (0,t.DisplayObject)(n.TilingSprite){constructor(...e){super(...e),this.widthInput=1e3,this.heightInput=1e3,this.speedInput=1,this.windInput=0,this.windStrengthInput=0,this.fallScaleInput=1,this.densityInput=120,this.maxDropsInput=80,this.topDownInput=!0,this.topDownTileScale={x:1,y:1},this.sideTileScale={x:1,y:1},this.topDownAlpha=.5,this.sideAlpha=.4,this.offsetX=0,this.offsetY=0}onUpdate(e){super.onUpdate(e),e.texture&&(this.texture=e.texture),e.topDownTileScale&&(this.topDownTileScale=e.topDownTileScale),e.sideTileScale&&(this.sideTileScale=e.sideTileScale),e.topDownAlpha!==void 0&&(this.topDownAlpha=e.topDownAlpha),e.sideAlpha!==void 0&&(this.sideAlpha=e.sideAlpha),e.startX!==void 0&&(this.offsetX=e.startX),e.startY!==void 0&&(this.offsetY=e.startY),e.speed!==void 0&&(this.speedInput=e.speed),e.windDirection!==void 0&&(this.windInput=e.windDirection),e.windStrength!==void 0&&(this.windStrengthInput=e.windStrength),e.fallScale!==void 0&&(this.fallScaleInput=e.fallScale),e.density!==void 0&&(this.densityInput=e.density),e.maxDrops!==void 0&&(this.maxDropsInput=e.maxDrops),e.topDown!==void 0&&(this.topDownInput=e.topDown),e.width!==void 0&&(this.widthInput=e.width,this.width=Number(K(e.width))||this.width),e.height!==void 0&&(this.heightInput=e.height,this.height=Number(K(e.height))||this.height)}async onMount(e,t){await super.onMount(e,t),this.widthInput=e.propObservables?.width??e.props.width??this.widthInput,this.heightInput=e.propObservables?.height??e.props.height??this.heightInput,this.speedInput=e.propObservables?.speed??e.props.speed??this.speedInput,this.windInput=e.propObservables?.windDirection??e.props.windDirection??this.windInput,this.windStrengthInput=e.propObservables?.windStrength??e.props.windStrength??this.windStrengthInput,this.densityInput=e.propObservables?.density??e.props.density??this.densityInput,this.maxDropsInput=e.propObservables?.maxDrops??e.props.maxDrops??this.maxDropsInput,this.topDownInput=e.propObservables?.topDown??e.props.topDown??this.topDownInput,this.tickSubscription=e.props.context?.tick?.observable?.subscribe(({value:e})=>{let t=Math.min(e?.deltaTime??16.67,50)/16.67,n=Number(K(this.speedInput))||0,r=Number(K(this.windInput))||0,i=Number(K(this.windStrengthInput))||0,a=Number(K(this.fallScaleInput))||1,o=Number(K(this.densityInput))||120,s=Number(K(this.maxDropsInput))||80,c=K(this.topDownInput)!==!1&&K(this.topDownInput)!==0,l=Number(K(this.widthInput))||this.width,u=Number(K(this.heightInput))||this.height,d=Math.min(Math.max(s/100,.45),1.65),f=Math.min(Math.max(o/180*d,.35),1.55),p=c?this.topDownTileScale:this.sideTileScale,m=(7.2+n*4.8)*a*t,h=r*i*3.8*t;this.width=l,this.height=u,this.alpha=(c?this.topDownAlpha:this.sideAlpha)*f,this.tileScale.set(p.x,p.y),this.offsetX+=h+m*.12,this.offsetY+=m,this.tilePosition.set(this.offsetX,this.offsetY)})}async onDestroy(e,t){this.tickSubscription?.unsubscribe?.(),await super.onDestroy(e,t)}};(0,t.registerComponent)(`RainTextureLayer`,Tt);var Et=e=>(0,t.createComponent)(`RainTextureLayer`,e),Dt=class extends (0,t.DisplayObject)(n.Container){constructor(...e){super(...e),this.graphics=new n.Graphics,this.widthInput=1e3,this.heightInput=1e3,this.speedInput=1,this.densityInput=120,this.maxDropsInput=80,this.topDownInput=!0,this.windInput=0,this.windStrengthInput=0,this.lastTopDown=null,this.splashes=[]}onUpdate(e){super.onUpdate(e),e.width!==void 0&&(this.widthInput=e.width,this.width=Number(K(e.width))||this.width),e.height!==void 0&&(this.heightInput=e.height,this.height=Number(K(e.height))||this.height),e.speed!==void 0&&(this.speedInput=e.speed),e.density!==void 0&&(this.densityInput=e.density),e.maxDrops!==void 0&&(this.maxDropsInput=e.maxDrops),e.topDown!==void 0&&(this.topDownInput=e.topDown),e.windDirection!==void 0&&(this.windInput=e.windDirection),e.windStrength!==void 0&&(this.windStrengthInput=e.windStrength)}async onMount(e,t){await super.onMount(e,t),this.addChild(this.graphics),this.widthInput=e.propObservables?.width??e.props.width??this.widthInput,this.heightInput=e.propObservables?.height??e.props.height??this.heightInput,this.speedInput=e.propObservables?.speed??e.props.speed??this.speedInput,this.densityInput=e.propObservables?.density??e.props.density??this.densityInput,this.maxDropsInput=e.propObservables?.maxDrops??e.props.maxDrops??this.maxDropsInput,this.topDownInput=e.propObservables?.topDown??e.props.topDown??this.topDownInput,this.windInput=e.propObservables?.windDirection??e.props.windDirection??this.windInput,this.windStrengthInput=e.propObservables?.windStrength??e.props.windStrength??this.windStrengthInput,this.tickSubscription=e.props.context?.tick?.observable?.subscribe(({value:e})=>{let t=Math.min(e?.deltaTime??16.67,50)/16.67;this.drawImpacts(t)})}numberValue(e,t){let n=Number(K(e));return Number.isFinite(n)&&n>0?n:t}booleanValue(e){let t=K(e);return t!==!1&&t!==0}resetSplash(e,t,n,r,i=!1){e.x=Math.random()*t,e.y=r?n*(.12+Math.random()*.78):n*(.78+Math.random()*.12),e.life=.24+Math.random()*.22,e.radius=r?2.2+Math.random()*3.2:3.4+Math.random()*4.4,e.delay=.12+Math.random()*.55,e.age=i?Math.random()*e.life:-Math.random()*e.delay}ensureSplashCount(e,t,n,r){for(;this.splashes.length<e;){let e={x:0,y:0,age:0,life:.35,radius:3,delay:.25};this.resetSplash(e,t,n,r,!0),this.splashes.push(e)}this.splashes.length>e&&(this.splashes.length=e)}drawImpacts(e){let t=this.numberValue(this.widthInput,1e3),n=this.numberValue(this.heightInput,1e3),r=this.numberValue(this.speedInput,1),i=this.numberValue(this.densityInput,120),a=this.numberValue(this.maxDropsInput,80),o=this.booleanValue(this.topDownInput),s=Number(K(this.windInput))||0,c=Number(K(this.windStrengthInput))||0,l=Math.min(Math.max(i/180,.45),1.55),u=Math.min(Math.round(a),Math.round((o?54:34)*l)),d=this.graphics;this.lastTopDown!==o&&(this.splashes.length=0,this.lastTopDown=o),this.alpha=o?.9:.82,this.ensureSplashCount(u,t,n,o),d.clear();for(let i of this.splashes){if(i.age+=(.045+r*.018)*e,i.age>i.life){this.resetSplash(i,t,n,o);continue}if(i.age<0)continue;let a=i.age/i.life,u=(1-a)**1.7*l,f=i.radius*(.65+a*2.6),p=o?a*.8:a*1.6,m=s*c*7*a,h=i.x+m,g=i.y-p,_=Math.min(.62,.44*u);d.ellipse(h,g,f,i.radius*(.18+a*.16)).stroke({color:13625855,alpha:_,width:o?1.15:1.35}),d.moveTo(h-f*1.15,g-.4).lineTo(h-f*.35,g-i.radius*.24).stroke({color:15070975,alpha:_*.78,width:1}),d.moveTo(h+f*.35,g-i.radius*.24).lineTo(h+f*1.15,g-.4).stroke({color:15070975,alpha:_*.78,width:1})}}async onDestroy(e,t){this.tickSubscription?.unsubscribe?.(),await super.onDestroy(e,t)}};(0,t.registerComponent)(`RainImpactLayer`,Dt);var Ot=e=>(0,t.createComponent)(`RainImpactLayer`,e),kt={lightRain:{effect:`rain`,speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:`rain`,speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:`rain`,speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},At={lightSnow:{effect:`snow`,speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:`snow`,speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:`snow`,speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},jt={rpgMorningMist:{effect:`fog`,speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:`fog`,speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:`fog`,speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:`fog`,speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:`fog`,speed:.1,density:1.7,height:.72,scale:2.3}},Mt={lightClouds:{effect:`cloud`,speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:`cloud`,speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:`cloud`,speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:`cloud`,speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:`cloud`,speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:`cloud`,speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:`cloud`,speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:`cloud`,speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},Nt={rain:kt,snow:At,fog:jt,cloud:Mt},Pt=e=>{let{effect:r=(0,t.signal)(`rain`),speed:i=(0,t.signal)(.5),windDirection:a=(0,t.signal)(0),windStrength:o=(0,t.signal)(.2),density:s=(0,t.signal)(120),maxDrops:c=(0,t.signal)(80),topDown:l=(0,t.signal)(!0),height:u=(0,t.signal)(1),scale:d=(0,t.signal)(2),sunIntensity:f=(0,t.signal)(.85),sunAngle:p=(0,t.signal)(.85),raySpread:m=(0,t.signal)(1),rayTwinkle:h=(0,t.signal)(.45),rayTwinkleSpeed:g=(0,t.signal)(1),resolution:_,...v}=(0,t.useProps)(e),y=(0,t.signal)([1e3,1e3]),b=(0,t.signal)(y()[0]),x=(0,t.signal)(y()[1]),S=(0,t.signal)(0),C=(0,t.signal)(0),w,T=typeof r==`function`?r:(0,t.signal)(r),E=_?typeof _==`function`?_:(0,t.signal)(_):y;(0,t.mount)(e=>{let n=e.props.context,r=e.parent,i=!1;for(;r;){if(r.tag===`Viewport`){i=!0;break}r=r.parent}if(w=i?n?.viewport:void 0,w?.getVisibleBounds){let e=w.getVisibleBounds();e&&e.width>0&&e.height>0&&(y.set([e.width,e.height]),b.set(e.width),x.set(e.height),S.set(e.x),C.set(e.y))}n?.canvasSize&&(0,t.effect)(()=>{let e=n.canvasSize();e&&e.width>0&&e.height>0&&(w?.getVisibleBounds||(y.set([e.width,e.height]),b.set(e.width),x.set(e.height),S.set(0),C.set(0)))})});let D=typeof i==`function`?i:(0,t.signal)(i),O=typeof a==`function`?a:(0,t.signal)(a),k=typeof o==`function`?o:(0,t.signal)(o),A=typeof s==`function`?s:(0,t.signal)(s),j=typeof c==`function`?c:(0,t.signal)(c),M=typeof l==`function`?l:(0,t.signal)(l),N=typeof u==`function`?u:(0,t.signal)(u),P=typeof d==`function`?d:(0,t.signal)(d),F=typeof f==`function`?f:(0,t.signal)(f),I=typeof p==`function`?p:(0,t.signal)(p),L=typeof m==`function`?m:(0,t.signal)(m),R=typeof h==`function`?h:(0,t.signal)(h),z=typeof g==`function`?g:(0,t.signal)(g),B=e=>typeof e==`number`&&Number.isFinite(e)?e:1,ee=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,e):.85,te=e=>typeof e==`number`&&Number.isFinite(e)?e:.85,ne=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:1,V=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,e):.45,re=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:1,H=e=>e===!1||e===0?0:1,ie=e=>[Math.cos(e),Math.sin(e)],ae=e=>Array.isArray(e)?[typeof e[0]==`number`&&Number.isFinite(e[0])&&e[0]>0?e[0]:1,typeof e[1]==`number`&&Number.isFinite(e[1])&&e[1]>0?e[1]:1]:[1,1];if(T()===`rain`)return(0,t.h)(t.Container,{...v,width:b,height:x,x:S,y:C},(0,t.h)(Et,{texture:wt(11),width:b,height:x,speed:D,windDirection:O,windStrength:k,density:A,maxDrops:j,topDown:M,fallScale:1.08,topDownTileScale:{x:.92,y:.92},sideTileScale:{x:1.08,y:1.18},topDownAlpha:.58,sideAlpha:.48,blendMode:`screen`,startX:0,startY:0}),(0,t.h)(Et,{texture:wt(29),width:b,height:x,speed:D,windDirection:O,windStrength:k,density:A,maxDrops:j,topDown:M,fallScale:.82,topDownTileScale:{x:1.25,y:1.25},sideTileScale:{x:1.42,y:1.55},topDownAlpha:.38,sideAlpha:.3,blendMode:`screen`,startX:53,startY:37}),(0,t.h)(Et,{texture:wt(47),width:b,height:x,speed:D,windDirection:O,windStrength:k,density:A,maxDrops:j,topDown:M,fallScale:.64,topDownTileScale:{x:1.7,y:1.7},sideTileScale:{x:1.9,y:2.1},topDownAlpha:.24,sideAlpha:.18,blendMode:`screen`,startX:101,startY:73}),(0,t.h)(Ot,{width:b,height:x,speed:D,density:A,maxDrops:j,topDown:M,windDirection:O,windStrength:k,blendMode:`screen`}));let oe,se;if(T()===`snow`)oe=yt(),se={uTime:{value:0,type:`f32`},uResolution:{value:ae(E()),type:`vec2<f32>`},uSnowSpeed:{value:D(),type:`f32`},uWindDirection:{value:O(),type:`f32`},uWindStrength:{value:k(),type:`f32`},uSnowDensity:{value:A(),type:`f32`},uMaxFlakes:{value:j(),type:`f32`}};else if(T()===`fog`)oe=bt(),se={uTime:{value:0,type:`f32`},uResolution:{value:ae(E()),type:`vec2<f32>`},uSpeed:{value:D(),type:`f32`},uScale:{value:P(),type:`f32`},uDensity:{value:A(),type:`f32`},uHeight:{value:B(N()),type:`f32`},uViewportOrigin:{value:[S(),C()],type:`vec2<f32>`}};else if(T()===`cloud`){let e=te(I());oe=xt(),se={uTime:{value:0,type:`f32`},uResolution:{value:ae(E()),type:`vec2<f32>`},uSpeed:{value:D(),type:`f32`},uScale:{value:P(),type:`f32`},uDensity:{value:A(),type:`f32`},uHeight:{value:B(N()),type:`f32`},uViewportOrigin:{value:[S(),C()],type:`vec2<f32>`},uSunIntensity:{value:ee(F()),type:`f32`},uSunDirection:{value:ie(e),type:`vec2<f32>`},uRaySpread:{value:ne(L()),type:`f32`},uRayTwinkle:{value:V(R()),type:`f32`},uRayTwinkleSpeed:{value:re(z()),type:`f32`}}}else throw Error(`Unknown weather effect: ${T()}. Supported: rain, snow, fog, cloud`);let U=new n.UniformGroup(se),ce=new n.Shader({glProgram:oe,resources:{uniforms:U}}),le=new n.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]}),ue=Math.random()*10,de=[...ae(E())],fe=O(),pe=k(),me=D(),he=A(),W=j(),ge=H(M()),_e=N(),ve=P(),ye=ee(F()),be=te(I()),xe=ne(L()),Se=V(R()),Ce=re(z()),we=S(),Te=C();return(0,t.tick)(({deltaTime:e})=>{if(w?.getVisibleBounds){let e=w.getVisibleBounds();if(e&&e.width>0&&e.height>0){let t=e.width,n=e.height,r=e.x,i=e.y;t!==b()&&b.set(t),n!==x()&&x.set(n),r!==S()&&S.set(r),i!==C()&&C.set(i);let a=y();(a[0]!==t||a[1]!==n)&&y.set([t,n])}}ue+=e/600,U.uniforms.uTime=ue;let t=ae(E());if((t[0]!==de[0]||t[1]!==de[1])&&(U.uniforms.uResolution=t,de=[...t]),T()===`fog`||T()===`cloud`){let e=S(),t=C();(e!==we||t!==Te)&&(U.uniforms.uViewportOrigin=[e,t],we=e,Te=t)}let n=O();if(n!==fe&&(U.uniforms.uWindDirection=n,fe=n),T()===`rain`||T()===`snow`){let e=k();e!==pe&&(U.uniforms.uWindStrength=e,pe=e)}if(T()===`rain`){let e=D();e!==me&&(U.uniforms.uRainSpeed=e,me=e);let t=A();t!==he&&(U.uniforms.uRainDensity=t,he=t);let n=j();n!==W&&(U.uniforms.uMaxDrops=n,W=n);let r=H(M());r!==ge&&(U.uniforms.uRainTopDown=r,ge=r)}else if(T()===`snow`){let e=D();e!==me&&(U.uniforms.uSnowSpeed=e,me=e);let t=A();t!==he&&(U.uniforms.uSnowDensity=t,he=t);let n=j();n!==W&&(U.uniforms.uMaxFlakes=n,W=n)}else if(T()===`fog`||T()===`cloud`){let e=D();e!==me&&(U.uniforms.uSpeed=e,me=e);let t=P();t!==ve&&(U.uniforms.uScale=t,ve=t);let n=A();n!==he&&(U.uniforms.uDensity=n,he=n);let r=B(N());if(r!==_e&&(U.uniforms.uHeight=r,_e=r),T()===`cloud`){let e=ee(F());e!==ye&&(U.uniforms.uSunIntensity=e,ye=e);let t=te(I());t!==be&&(U.uniforms.uSunDirection=ie(t),be=t);let n=ne(L());n!==xe&&(U.uniforms.uRaySpread=n,xe=n);let r=V(R());r!==Se&&(U.uniforms.uRayTwinkle=r,Se=r);let i=re(z());i!==Ce&&(U.uniforms.uRayTwinkleSpeed=i,Ce=i)}}}),(0,t.h)(t.Mesh,{...v,geometry:le,shader:ce,width:b,height:x,x:S,y:C})},Ft=Pt,It=[0,0,0,1],Lt=[0,0,0,.55],Rt={clarity:0,explored:!1},zt=()=>Rt,Bt=new WeakMap,Vt=(e,t,n)=>Math.max(t,Math.min(n,e)),Ht=(e,t,n)=>{if(t<=e)return+(n>=t);let r=Vt((n-e)/(t-e),0,1);return r*r*(3-2*r)},q=e=>typeof e==`function`?e():e;function Ut(){let e=(0,t.signal)(0),n=zt,r=(t,r)=>(e(),!Number.isFinite(t)||!Number.isFinite(r)?Rt:n(t,r)),i={version:()=>e(),clarityAt:(e,t)=>Vt(r(e,t).clarity,0,1),isVisibleAt:(e,t,n=.65)=>r(e,t).clarity>=Vt(n,0,1),isExploredAt:(e,t)=>{let n=r(e,t);return n.explored||n.clarity>0},stateAt:(e,t,n=.65)=>{let i=r(e,t);return i.clarity>=Vt(n,0,1)?`visible`:i.explored||i.clarity>0?`explored`:`unknown`}};return Bt.set(i,{setSampler(e){n=typeof e==`function`?e:zt},notifyUpdate(){e.update(e=>e+1)}}),i}var Wt=(e,t)=>{let[n,r,i,a]=Array.isArray(e)?e:t,o=(e,t=!1)=>Number.isFinite(e)?e>=0&&e<=1?Math.round(e*255):Vt(Math.round(e),0,255):t?255:0;return{r:o(n),g:o(r),b:o(i),a:o(a,!0)}},Gt=e=>{let t=q(e);return Array.isArray(t)?t:[]};function Kt(e){let{mapWidth:r,mapHeight:i,tileSize:a=(0,t.signal)(32),smooth:o=(0,t.signal)(!0),renderScale:s=(0,t.signal)(2),edgeSoftness:c=(0,t.signal)(22),visionSources:l=(0,t.signal)([]),colors:u=(0,t.signal)({}),updateHz:d=(0,t.signal)(15),initialExplored:f=(0,t.signal)(!1),controller:p=void 0,obstacleMap:m=void 0,...h}=(0,t.useProps)(e),g,_=null,v=n.Texture.WHITE,y=null,b=null,x=new Float32Array,S=new Uint8Array,C=1,w=1,T=1,E=1,D=1,O=1,k=1,A=1,j=0,M=!0,N=null,P=null,F=[];if(g=(()=>{if(typeof document>`u`)throw Error(`FogOfWar: document is undefined, canvas cannot be created.`);let e=document.createElement(`canvas`);return e.width=1,e.height=1,e})(),_=g.getContext(`2d`,{willReadFrequently:!0}),!_)throw Error(`FogOfWar: unable to create 2D context for fog canvas.`);v=n.Texture.from(g);let I=()=>{let e=q(o)===!1?1:2,t=Number(q(s));return Number.isFinite(t)?Vt(Math.round(t),1,8):e},L=()=>{if(q(o)===!1)return 0;let e=Number(q(c));return Number.isFinite(e)?Math.max(0,e):Math.max(k*.9,2)},R=()=>{let e=q(p);return e&&typeof e==`object`?e:void 0},z=()=>{let e=Gt(l),t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push({x:Number(q(r.x)),y:Number(q(r.y)),radius:Number(q(r.radius)),enabled:q(r.enabled)!==!1})}return t},B=e=>{let t=Array(e.length*4),n=0;for(let r=0;r<e.length;r++){let i=e[r];t[n++]=i.x,t[n++]=i.y,t[n++]=i.radius,t[n++]=+!!i.enabled}let r=t.length!==F.length;if(!r)for(let e=0;e<t.length;e++){let n=t[e],i=F[e];if(Number.isNaN(n)!==Number.isNaN(i)||Math.abs(n-i)>.01){r=!0;break}}return F=t,r},ee=(e,t)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||T<=0||C<=0||w<=0)return Rt;let n=Vt(e,0,Math.max(0,E-1)),r=Vt(t,0,Math.max(0,D-1)),i=Math.min(C-1,Math.max(0,Math.floor(n/k))),a=Math.min(w-1,Math.max(0,Math.floor(r/k)))*C+i;return{clarity:Vt(x[a]??0,0,1),explored:S[a]===1}},te=e=>{let t=R()??null;t!==N&&(P&&P.setSampler(zt),N=t,P=N?Bt.get(N)??null:null,P&&P.setSampler(ee),e=!0),e&&P&&P.notifyUpdate()},ne=()=>{let e=v.source;e&&(e.scaleMode=q(o)===!1?`nearest`:`linear`)},V=(e,t,n,r)=>{E=Math.max(1,Math.floor(e)),D=Math.max(1,Math.floor(t)),O=Math.max(1,Math.floor(n)),A=Vt(r,1,8),k=Math.max(1,O/A),C=Math.max(1,Math.ceil(E/k)),w=Math.max(1,Math.ceil(D/k)),T=C*w,`width`in g&&(g.width=C,g.height=w),x=new Float32Array(T),S=new Uint8Array(T),q(f)&&S.fill(1),y=_?.createImageData(C,w)??null,b=y?.data??null,ne(),M=!0},re=(e,t)=>{if(e.enabled===!1||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.radius)||e.radius<=0)return;let n=e.x,r=e.y,i=e.radius/k,a=Math.max(0,i-t),o=Math.max(i,i+t),s=a*a,c=o*o,l=Math.max(0,Math.floor(n/k-o)),u=Math.min(C-1,Math.ceil(n/k+o)),d=Math.max(0,Math.floor(r/k-o)),f=Math.min(w-1,Math.ceil(r/k+o));for(let e=d;e<=f;e++)for(let t=l;t<=u;t++){let i=(t+.5)*k,l=(e+.5)*k,u=i-n,d=l-r,f=(u*u+d*d)/(k*k);if(f>c)continue;let p=1;if(o>a&&f>s&&(p=1-Ht(a,o,Math.sqrt(f))),p<=.001)continue;let m=e*C+t;p>x[m]&&(x[m]=p),p>.02&&(S[m]=1)}},H=e=>{if(!y||!b||!_)return;let t=q(u)||{},n=Wt(t.unknown,It),r=Wt(t.explored,Lt);x.fill(0);let i=e??z(),a=L()/k;for(let e=0;e<i.length;e++)re(i[e],a);for(let e=0;e<T;e++){let t=e*4,i=Vt(x[e],0,1),a=S[e]===1?r:n;b[t]=a.r,b[t+1]=a.g,b[t+2]=a.b,b[t+3]=Math.round(a.a*(1-i))}_.putImageData(y,0,0);let o=v.source;o&&typeof o.update==`function`?o.update():typeof v.update==`function`&&v.update(),te(!0)};return V(Number(q(r))||1,Number(q(i))||1,Number(q(a))||32,I()),H(),(0,t.tick)(({deltaTime:e})=>{if(!_)return;let t=Math.max(1,Number(q(r))||1),n=Math.max(1,Number(q(i))||1),o=Math.max(1,Number(q(a))||32),s=I();(t!==E||n!==D||o!==O||s!==A)&&V(t,n,o,s),ne(),te(!1);let c=z(),l=B(c);l&&(M=!0);let u=1e3/Math.max(1,Number(q(d))||15);j+=e,(M||l||j>=u)&&(j=0,M=!1,H(c))}),(0,t.h)(t.Sprite,{...h,texture:v,x:0,y:0,width:Math.max(1,Number(q(r))||1),height:Math.max(1,Number(q(i))||1),roundPixels:!0})}var qt=`/**
558
+ * Gradient alpha for projected sprite shadows.
559
+ * Strong alpha near the caster's feet (vTextureCoord.y ~ 1),
560
+ * softer alpha at the shadow tip (vTextureCoord.y ~ 0).
561
+ */
562
+ precision highp float;
563
+ precision highp int;
564
+
565
+ in vec2 vTextureCoord;
566
+ out vec4 finalColor;
567
+
568
+ uniform sampler2D uTexture;
569
+ uniform float uPower;
570
+ uniform float uFloor;
571
+
572
+ void main() {
573
+ vec4 color = texture(uTexture, vTextureCoord);
574
+ float gradient = pow(clamp(vTextureCoord.y, 0.0, 1.0), max(0.001, uPower));
575
+ float alphaMul = mix(clamp(uFloor, 0.0, 1.0), 1.0, gradient);
576
+ finalColor = vec4(color.rgb, color.a * alphaMul);
577
+ }
578
+ `,Jt=`__spriteShadowManaged`,Yt=220,Xt=360,Zt=1,Qt=`strongest`,$t=30,en=0,tn={height:72,footOffset:{x:0,y:0},footAnchor:{x:.5,y:1},alpha:.56,blur:3.5,gradientPower:2,hardness:.42,minLength:10,maxLength:280,contactAlpha:.28,contactScale:.28},J=(e,t,n)=>Math.max(t,Math.min(n,e)),Y=e=>typeof e==`number`&&Number.isFinite(e),X=e=>{if(e&&typeof e==`object`&&`value`in e&&Object.keys(e).length<=2)return e.value;if(typeof e==`function`)try{return e()}catch{return}return e},nn=e=>{if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,Math.floor(e))&16777215;if(typeof e==`string`){let t=e.trim().replace(/^#/,``),n=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,r=parseInt(n,16);if(Number.isFinite(r))return r&16777215}return en},rn=(e,t)=>{let n=X(e),r=Number(n?.x),i=Number(n?.y);return{x:Y(r)?r:t.x,y:Y(i)?i:t.y}},an=(e,t)=>{if(e&&typeof e.toGlobal==`function`){let n=e.toGlobal(t);if(Y(n?.x)&&Y(n?.y))return{x:n.x,y:n.y}}return t},on=(e,t)=>{if(e&&typeof e.toLocal==`function`){let n=e.toLocal(t);if(Y(n?.x)&&Y(n?.y))return{x:n.x,y:n.y}}return t},sn=(e=2,t=.06)=>{let r={value:e,type:`f32`},i={value:t,type:`f32`},a=n.Filter.from({gl:{vertex:O,fragment:qt},resources:{shadowGradientUniforms:{uPower:r,uFloor:i}}});return a.setGradient=(e,t)=>{r.value=Y(e)?Math.max(.001,e):2,i.value=Y(t)?J(t,0,1):.06},a},cn=e=>{if(e===!1||e==null)return null;let t=e===!0||typeof e!=`object`?{}:e;if(X(t.enabled)===!1)return null;let n=Number(X(t.height)),r=Number(X(t.alpha)),i=Number(X(t.blur)),a=Number(X(t.gradientPower)),o=Number(X(t.hardness)),s=Number(X(t.minLength)),c=Number(X(t.maxLength)),l=Number(X(t.contactAlpha)),u=Number(X(t.contactScale)),d=Number(X(t.anchorX));return{height:Y(n)?Math.max(2,n):tn.height,footOffset:rn(t.footOffset,tn.footOffset),footAnchor:rn(t.footAnchor,tn.footAnchor),alpha:Y(r)?J(r,0,1.5):tn.alpha,blur:Y(i)?Math.max(0,i):tn.blur,gradientPower:Y(a)?J(a,.2,8):tn.gradientPower,hardness:Y(o)?J(o,0,1):tn.hardness,minLength:Y(s)?Math.max(0,s):tn.minLength,maxLength:Y(c)?Math.max(2,c):tn.maxLength,contactAlpha:Y(l)?J(l,0,1):tn.contactAlpha,contactScale:Y(u)?Math.max(.05,u):tn.contactScale,anchorX:Y(d)?J(d,0,1):void 0}},ln=e=>{if(!e||e[Jt])return null;let t=typeof e.getElement==`function`?e.getElement():null,n=X(e.shadowCaster)??X(e.fullProps?.shadowCaster)??X(t?.props?.shadowCaster)??X(t?.propObservables?.shadowCaster);return n===void 0?null:cn(n)},un=e=>{let t=[],n=[e];for(;n.length>0;){let e=n.pop(),r=Array.isArray(e?.children)?e.children:[];for(let e=0;e<r.length;e++){let i=r[e];if(!i||i[Jt])continue;let a=ln(i);a&&i.parent&&t.push({instance:i,caster:a}),Array.isArray(i.children)&&i.children.length>0&&n.push(i)}}return t},dn=(e,t)=>{let n=X(e);if(!Array.isArray(n))return[];let r=[];for(let e=0;e<n.length;e++){let i=n[e];if(X(i.enabled)===!1)continue;let a=Number(X(i.x)),o=Number(X(i.y));if(!Y(a)||!Y(o))continue;let s=Number(X(i.z)),c=Number(X(i.radius)),l=Number(X(i.intensity)),u=Number(X(i.shadowWeight)),d=an(t,{x:a,y:o});r.push({x:a,y:o,globalX:d.x,globalY:d.y,z:Y(s)?Math.max(2,s):Yt,radius:Y(c)?Math.max(1,c):Xt,intensity:Y(l)?J(l,0,2):Zt,shadowWeight:Y(u)?J(u,0,4):1})}return r},fn=(e,t)=>{if(e.length===0)return null;if(e.sort((e,t)=>t.influence-e.influence),t===`strongest`||e.length===1)return e[0];let n=e.slice(0,2),r=0,i=0,a=0,o=0;for(let e=0;e<n.length;e++){let t=n[e],s=Math.max(.001,t.influence);r+=t.dirX*s,i+=t.dirY*s,a+=t.length*s,o+=s}if(o<=0)return null;let s=Math.hypot(r,i);return s<=1e-4?null:{dirX:r/s,dirY:i/s,length:a/o,influence:J(o/n.length,0,2)}},pn=e=>{e.near.visible=!1,e.far.visible=!1,e.contact.visible=!1},mn=e=>{e.near.destroy(),e.far.destroy(),e.contact.destroy()},hn=(e,t,r)=>{let i=new n.Sprite,a=new n.Sprite,o=new n.Sprite,s=new n.BlurFilter({strength:2.5,quality:2}),c=new n.BlurFilter({strength:4.2,quality:3}),l=new n.BlurFilter({strength:2.8,quality:2}),u=sn(2,.08),d=sn(2.8,.02);return i.filters=[u,s],a.filters=[d,c],o.filters=[l],i.tint=r,a.tint=r,o.tint=r,i.blendMode=`multiply`,a.blendMode=`multiply`,o.blendMode=`multiply`,i.eventMode=`none`,a.eventMode=`none`,o.eventMode=`none`,i.roundPixels=!0,a.roundPixels=!0,o.roundPixels=!0,i.visible=!1,a.visible=!1,o.visible=!1,i.alpha=0,a.alpha=0,i[Jt]=!0,a[Jt]=!0,o[Jt]=!0,t.addChild(o),t.addChild(a),t.addChild(i),{caster:e,parent:t,near:i,far:a,contact:o,nearBlur:s,farBlur:c,contactBlur:l,nearGradient:u,farGradient:d,dirX:0,dirY:1,length:0}},gn=e=>{let{caster:t,parent:n,near:r,far:i,contact:a}=e;if(!t||t.destroyed||!n)return;let o=Y(t.zIndex)?t.zIndex:0;if(a.zIndex=o-.32,i.zIndex=o-.26,r.zIndex=o-.22,n.sortableChildren||!Array.isArray(n.children)||!n.children.includes(t))return;let s=e=>{if(!e||e.destroyed||!n.children.includes(e))return;let r=n.getChildIndex(t),i=Math.max(0,r-1);n.getChildIndex(e)!==i&&n.setChildIndex(e,i)};s(a),s(i),s(r)},_n=(e,t,n,r,i)=>{let a=e.caster,o=e.parent;if(!a||a.destroyed||!o||o.destroyed){pn(e);return}if(a.visible===!1||Y(a.worldAlpha)&&a.worldAlpha<=.001){pn(e);return}let s=typeof a.getBounds==`function`?a.getBounds():null;if(!(s&&Y(s.x)&&Y(s.y)&&Y(s.width)&&Y(s.height)&&s.width>0&&s.height>0)){pn(e);return}let c=Math.max(1,Math.abs(Number(a.width))||Math.abs(s.width)),l=Math.max(1,Math.abs(Number(a.height))||Math.abs(s.height)),u=Number(a.anchor?.x),d=Number(a.anchor?.y),f=Y(u)?J(u,0,1):.5,p=Y(d)?J(d,0,1):1,m=Y(t.anchorX)?t.anchorX:f,h=on(o,an(a,{x:(t.footAnchor.x-f)*c+t.footOffset.x,y:(t.footAnchor.y-p)*l+t.footOffset.y})),g=[];for(let e=0;e<n.length;e++){let r=n[e];if(r.intensity<=.001||r.radius<=.001)continue;let i=on(o,{x:r.globalX,y:r.globalY}),a=h.x-i.x,s=h.y-i.y,c=Math.hypot(a,s),l=J(1-c/r.radius,0,1),u=J(Yt/Math.max(12,r.z),.35,2.4),d=J(l*l*r.intensity*r.shadowWeight*u,0,2.2);if(d<=.001)continue;let f=c>1e-4?c:1,p=a/f,m=s/f,_=J(c*t.height/Math.max(14,r.z),t.minLength,t.maxLength);g.push({dirX:Y(p)?p:0,dirY:Y(m)?m:1,influence:d,length:Y(_)?_:t.minLength})}let _=fn(g,r);if(!_){pn(e);return}let v=a.texture;if(!v){pn(e);return}let y=.34,b=e.dirX+(_.dirX-e.dirX)*y,x=e.dirY+(_.dirY-e.dirY)*y,S=Math.hypot(b,x),C=S>1e-4?b/S:_.dirX,w=S>1e-4?x/S:_.dirY,T=e.length+(_.length-e.length)*.32;e.dirX=C,e.dirY=w,e.length=T;let E=J(T/l,.08,6),D=J(.62+E*.08,.5,1.2),O=J(t.hardness,0,1),k=J(_.influence,0,1.35),A=J(t.alpha*k,0,1),j=Math.max(0,t.blur*(1.15-O*.55)),M=J(t.gradientPower+(1-O)*.7,.2,8),N=Math.atan2(w,C)+Math.PI/2;e.near.texture=v,e.far.texture=v,e.contact.texture=v,e.near.tint=i,e.far.tint=i,e.contact.tint=i,e.near.anchor.set(m,1),e.far.anchor.set(m,1),e.contact.anchor.set(m,1),e.near.width=c*D,e.near.height=l*Math.max(.12,E*1.06),e.far.width=e.near.width*1.02,e.far.height=e.near.height*1.22,e.near.position.set(h.x,h.y),e.far.position.set(h.x+C*T*.34,h.y+w*T*.34),e.contact.position.set(h.x+C*Math.min(4,T*.06),h.y+w*Math.min(4,T*.06)),e.near.rotation=N,e.far.rotation=N,e.contact.rotation=N,e.near.alpha=J(A*(.74+O*.2),0,1),e.far.alpha=J(A*(.3+(1-O)*.2),0,1),e.near.visible=e.near.alpha>.001,e.far.visible=e.far.alpha>.001,e.nearBlur.strength=j*(.72+(1-k)*.45),e.farBlur.strength=j*(1.45+(1-k)*1.1),e.nearGradient.setGradient(M,.08),e.farGradient.setGradient(M+.65,.03);let P=J(t.contactAlpha*k*.85,0,1),F=Math.max(4,c*J(t.contactScale*1.8,.25,1.3)),I=Math.max(2,l*J(t.contactScale*.62,.08,.56));e.contact.width=F*(.92+E*.18),e.contact.height=I,e.contact.alpha=J(P*(.6+O*.2),0,1),e.contactBlur.strength=j*(.85+(1-O)*.25),e.contact.visible=e.contact.alpha>.001,gn(e)};function vn(e={}){let n=(0,t.useProps)(e),r=()=>n.lights??n.sources;return(0,t.mount)(e=>{let t=e.props.context,i=t?.viewport??e.parent?.componentInstance;if(!i||typeof i.addChild!=`function`)return;let a=t?.tick,o=new Map,s=0,c=!0,l=null,u=()=>{let e=nn(X(n.shadowColor)),t=X(n.mode)===`blend2`?`blend2`:Qt,a=dn(r(),i),s=un(i),c=new Set;for(let n=0;n<s.length;n++){let{instance:r,caster:i}=s[n];if(!r||!r.parent||r.destroyed)continue;c.add(r);let l=o.get(r);(!l||l.parent!==r.parent)&&(l&&mn(l),l=hn(r,r.parent,e),o.set(r,l)),_n(l,i,a,t,e)}for(let[e,t]of o.entries())(!c.has(e)||!e||e.destroyed)&&(mn(t),o.delete(e))};return l=a?.observable?.subscribe(e=>{let t=e?.value??e,r=Number(t?.deltaTime),i=Y(r)?r:16.67,a=Number(X(n.updateHz)),o=1e3/J(Y(a)?a:$t,1,120);s+=i,(c||s>=o)&&(s=0,c=!1,u())}),u(),()=>{l?.unsubscribe?.();for(let e of o.values())mn(e);o.clear()}}),(0,t.h)(t.Container)}var yn=`__footprintManaged`,bn=`default`,xn=30,Sn=260,Cn={footAnchor:{x:.5,y:1},leftOffset:{x:-10,y:1},rightOffset:{x:10,y:1},minStepDistance:18,minSpeed:36,stepIntervalMs:85,size:1,alpha:1,blur:0,surface:bn,angleOffset:0,jitter:8},wn={lifetimeMs:1800,startAlpha:.32,endAlpha:0,tint:2959910,blendMode:`multiply`,scale:1,blurStart:.45,blurEnd:1.9,erosionStart:.54,depth:.58,rimStrength:.14},Tn={[bn]:wn,sand:{lifetimeMs:1650,startAlpha:.31,endAlpha:0,tint:9334086,blendMode:`multiply`,scale:1,blurStart:.35,blurEnd:1.5,erosionStart:.62,depth:.54,rimStrength:.12},snow:{lifetimeMs:2550,startAlpha:.24,endAlpha:0,tint:8228771,blendMode:`multiply`,scale:1.05,blurStart:.6,blurEnd:2.25,erosionStart:.45,depth:.72,rimStrength:.28}},Z=(e,t,n)=>Math.max(t,Math.min(n,e)),En=(e,t,n)=>e+(t-e)*n,Dn=(e,t,n)=>{let r=Z((n-e)/Math.max(1e-4,t-e),0,1);return r*r*(3-2*r)},Q=e=>typeof e==`number`&&Number.isFinite(e),On=e=>e===`left`?`right`:`left`,kn=e=>e*Math.PI/180,$=e=>{if(e&&typeof e==`object`&&`value`in e&&Object.keys(e).length<=2)return e.value;if(typeof e==`function`)try{return e()}catch{return}return e},An=(e,t)=>{if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,Math.floor(e))&16777215;if(typeof e==`string`){let t=e.trim().replace(/^#/,``),n=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,r=parseInt(n,16);if(Number.isFinite(r))return r&16777215}return t},jn=(e,t)=>{let n=Z(t,0,1),r=Math.round((e>>16&255)*(1-n)),i=Math.round((e>>8&255)*(1-n)),a=Math.round((e&255)*(1-n));return r<<16|i<<8|a},Mn=(e,t)=>{let n=Z(t,0,1),r=Math.round((e>>16&255)+(255-(e>>16&255))*n),i=Math.round((e>>8&255)+(255-(e>>8&255))*n),a=Math.round((e&255)+(255-(e&255))*n);return r<<16|i<<8|a},Nn=(e,t)=>{let n=$(e),r=Number(n?.x),i=Number(n?.y);return{x:Q(r)?r:t.x,y:Q(i)?i:t.y}},Pn=(e,t)=>{if(e&&typeof e.toGlobal==`function`){let n=e.toGlobal(t);if(Q(n?.x)&&Q(n?.y))return{x:n.x,y:n.y}}return t},Fn=(e,t)=>{if(e&&typeof e.toLocal==`function`){let n=e.toLocal(t);if(Q(n?.x)&&Q(n?.y))return{x:n.x,y:n.y}}return t},In=(e,t)=>{let n=Number($(e?.lifetimeMs)),r=Number($(e?.startAlpha)),i=Number($(e?.endAlpha)),a=Number($(e?.scale)),o=Number($(e?.blurStart)),s=Number($(e?.blurEnd)),c=Number($(e?.erosionStart)),l=Number($(e?.depth)),u=Number($(e?.rimStrength)),d=$(e?.tint),f=$(e?.blendMode);return{lifetimeMs:Q(n)?Math.max(120,n):t.lifetimeMs,startAlpha:Q(r)?Z(r,0,1.5):t.startAlpha,endAlpha:Q(i)?Z(i,0,1.5):t.endAlpha,tint:An(d,t.tint),blendMode:f??t.blendMode,scale:Q(a)?Math.max(.05,a):t.scale,blurStart:Q(o)?Math.max(0,o):t.blurStart,blurEnd:Q(s)?Math.max(0,s):t.blurEnd,erosionStart:Q(c)?Z(c,.05,.95):t.erosionStart,depth:Q(l)?Z(l,0,1):t.depth,rimStrength:Q(u)?Z(u,0,1):t.rimStrength}},Ln=e=>{let t=$(e)??{},n={};for(let[e,r]of Object.entries(Tn))n[e]=In(t[e],r);for(let[e,r]of Object.entries(t))n[e]||(n[e]=In(r,wn));return n[bn]||(n[bn]=wn),n},Rn=(e,t)=>{if(e===!1||e==null)return null;let n=e===!0||typeof e!=`object`?{}:e;if($(n.enabled)===!1)return null;let r=Number($(n.minStepDistance)),i=Number($(n.minSpeed)),a=Number($(n.stepIntervalMs)),o=Number($(n.size)),s=Number($(n.alpha)),c=Number($(n.blur)),l=Number($(n.angleOffset)),u=Number($(n.jitter)),d=$(n.surface);return{footAnchor:Nn(n.footAnchor,Cn.footAnchor),leftOffset:Nn(n.leftOffset,Cn.leftOffset),rightOffset:Nn(n.rightOffset,Cn.rightOffset),minStepDistance:Q(r)?Math.max(2,r):Cn.minStepDistance,minSpeed:Q(i)?Math.max(0,i):Cn.minSpeed,stepIntervalMs:Q(a)?Math.max(0,a):Cn.stepIntervalMs,size:Q(o)?Math.max(.1,o):Cn.size,alpha:Q(s)?Z(s,0,2):Cn.alpha,blur:Q(c)?Math.max(0,c):Cn.blur,surface:typeof d==`string`&&d.trim().length>0?d.trim():t,angleOffset:Q(l)?l:Cn.angleOffset,jitter:Q(u)?Math.max(0,u):Cn.jitter}},zn=(e,t)=>{if(!e||e[yn])return null;let n=typeof e.getElement==`function`?e.getElement():null,r=$(e.footprintCaster)??$(e.fullProps?.footprintCaster)??$(n?.props?.footprintCaster)??$(n?.propObservables?.footprintCaster);return r===void 0?null:Rn(r,t)},Bn=(e,t)=>{let n=[],r=[e];for(;r.length>0;){let e=r.pop(),i=Array.isArray(e?.children)?e.children:[];for(let e=0;e<i.length;e++){let a=i[e];if(!a||a[yn])continue;let o=zn(a,t);o&&a.parent&&n.push({instance:a,caster:o}),Array.isArray(a.children)&&a.children.length>0&&r.push(a)}}return n},Vn=e=>{let t=e?.app;if(typeof t==`function`)try{let e=t();if(e?.renderer&&typeof e.renderer.generateTexture==`function`)return e.renderer}catch{}let n=globalThis.__PIXI_RENDERER__;return n&&typeof n.generateTexture==`function`?n:null},Hn=e=>{let t=new n.Graphics;t.ellipse(0,10,8.4,6.1).fill(16777215),t.ellipse(0,-1.4,6.8,9.4).fill(16777215),t.circle(-4.7,-12.8,2).fill(16777215),t.circle(-1.5,-14.6,1.9).fill(16777215),t.circle(1.5,-15.3,1.75).fill(16777215),t.circle(4.5,-14.1,1.45).fill(16777215);let r=e.generateTexture(t);return t.destroy(),r},Un=(e,t,n)=>{let r=typeof e.getBounds==`function`?e.getBounds():null,i=Math.max(1,Math.abs(Number(e.width))||Math.abs(Number(r?.width))||1),a=Math.max(1,Math.abs(Number(e.height))||Math.abs(Number(r?.height))||1),o=Number(e.anchor?.x),s=Number(e.anchor?.y),c=Q(o)?Z(o,0,1):.5,l=Q(s)?Z(s,0,1):1;return Fn(t,Pn(e,{x:(n.footAnchor.x-c)*i,y:(n.footAnchor.y-l)*a}))},Wn=(e,t,n)=>{let r=Q(t?.zIndex)?t.zIndex:0;if(e.rimSprite.zIndex=r-.2,e.baseSprite.zIndex=r-.18,e.depthSprite.zIndex=r-.16,n.sortableChildren||!Array.isArray(n.children)||!n.children.includes(t))return;let i=[e.rimSprite,e.baseSprite,e.depthSprite];for(let e=0;e<i.length;e++){let r=i[e];if(!n.children.includes(r))continue;let a=n.getChildIndex(t),o=Math.max(0,a-1);n.getChildIndex(r)!==o&&n.setChildIndex(r,o)}};function Gn(e={}){let r=(0,t.useProps)(e);return(0,t.mount)(e=>{let t=e.props.context,i=t?.viewport??e.parent?.componentInstance;if(!i||typeof i.addChild!=`function`)return;let a=t?.tick,o=new Map,s=[],c=[],l=0,u=0,d=!0,f=null,p=null,m=()=>{if(p&&!p.destroyed)return p;let e=Vn(t);return e?(p=Hn(e),p):null},h=e=>{let t=[e.baseSprite,e.depthSprite,e.rimSprite];for(let e=0;e<t.length;e++){let n=t[e];n.visible=!1,n.alpha=0,n.parent&&n.parent.removeChild(n)}c.push(e)},g=e=>{let t=[e.baseSprite,e.depthSprite,e.rimSprite];for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.removeChild(n),n.destroy()}},_=e=>{let t=c.pop();if(t)t.baseSprite.texture=e,t.depthSprite.texture=e,t.rimSprite.texture=e;else{let r=new n.Sprite(e),i=new n.Sprite(e),a=new n.Sprite(e),o=new n.BlurFilter({strength:0,quality:1}),s=new n.BlurFilter({strength:0,quality:1}),c=new n.BlurFilter({strength:0,quality:1}),l=[r,i,a];for(let e=0;e<l.length;e++){let t=l[e];t.anchor.set(.5,.84),t.roundPixels=!0,t.eventMode=`none`,t.visible=!1,t[yn]=!0}r.filters=[o],i.filters=[s],a.filters=[c],i.blendMode=`multiply`,a.blendMode=`screen`,t={baseSprite:r,depthSprite:i,rimSprite:a,baseBlurFilter:o,depthBlurFilter:s,rimBlurFilter:c,bornAt:0,lifetimeMs:wn.lifetimeMs,startAlpha:wn.startAlpha,endAlpha:wn.endAlpha,baseScaleX:1,baseScaleY:1,blurStart:wn.blurStart,blurEnd:wn.blurEnd,erosionStart:wn.erosionStart,depth:wn.depth,rimStrength:wn.rimStrength}}return t},v=e=>{for(;s.length>e;){let e=s.shift();if(!e)break;h(e)}},y=e=>{for(let t=s.length-1;t>=0;t--){let n=s[t],r=n.baseSprite,i=n.depthSprite,a=n.rimSprite;if(!r||!i||!a||r.destroyed||i.destroyed||a.destroyed){s.splice(t,1);continue}let o=Z((e-n.bornAt)/Math.max(1,n.lifetimeMs),0,1),c=1-Dn(0,1,o),l=o<=n.erosionStart?1:1-Dn(n.erosionStart,1,o),u=Z(En(n.startAlpha,n.endAlpha,o)*c*l,0,1.5);if(o>=1||u<=.001){s.splice(t,1),h(n);continue}let d=1+o*.08,f=1+o*.05,p=1+o*.12,m=.78-n.depth*.1,g=1.05+n.depth*.12;r.scale.set(n.baseScaleX*d,n.baseScaleY*d),i.scale.set(n.baseScaleX*m*f,n.baseScaleY*m*f),a.scale.set(n.baseScaleX*g*p,n.baseScaleY*g*p),r.alpha=u,i.alpha=Z(u*(.58+n.depth*.34),0,1.2),a.alpha=Z(u*n.rimStrength,0,.65),n.baseBlurFilter.strength=En(n.blurStart,n.blurEnd,o),n.depthBlurFilter.strength=En(n.blurStart*(.45+(1-n.depth)*.25),n.blurEnd*(.72+(1-n.depth)*.22),o),n.rimBlurFilter.strength=En(n.blurStart*.8,n.blurEnd*(1.28+n.depth*.24),o),r.visible=!0,i.visible=!0,a.visible=a.alpha>.001}},b=(e,t,n,r,i,a)=>{let o=m(),c=e.parent;if(!o||!c||c.destroyed)return;let l=Un(e,c,t),u=n.nextFoot===`left`?t.leftOffset:t.rightOffset,d=n.heading,f=-Math.sin(d),p=Math.cos(d),h=Math.cos(d),g=Math.sin(d),y=l.x+f*u.x+h*u.y,b=l.y+p*u.x+g*u.y,x=_(o),S=[x.rimSprite,x.baseSprite,x.depthSprite];for(let e=0;e<S.length;e++){let t=S[e];t.parent&&t.parent!==c&&t.parent.removeChild(t),t.parent||c.addChild(t)}let C=kn(t.jitter),w=(Math.random()*2-1)*C,T=kn(t.angleOffset),E=d-Math.PI/2+T+w,D=r.scale*t.size,O=(n.nextFoot===`left`?1:-1)*Math.max(.01,D),k=Math.max(.01,D),A=Z(r.startAlpha*t.alpha,0,1.5),j=jn(r.tint,.38+r.depth*.26),M=Mn(r.tint,.22+r.depth*.38);x.baseSprite.position.set(y,b),x.depthSprite.position.set(y,b),x.rimSprite.position.set(y,b),x.baseSprite.rotation=E,x.depthSprite.rotation=E,x.rimSprite.rotation=E,x.baseSprite.scale.set(O,k),x.depthSprite.scale.set(O*.82,k*.82),x.rimSprite.scale.set(O*1.08,k*1.08),x.baseSprite.tint=r.tint,x.depthSprite.tint=j,x.rimSprite.tint=M,x.baseSprite.blendMode=r.blendMode,x.baseSprite.alpha=A,x.depthSprite.alpha=Z(A*(.58+r.depth*.34),0,1.2),x.rimSprite.alpha=Z(A*r.rimStrength,0,.65),x.baseSprite.visible=!0,x.depthSprite.visible=!0,x.rimSprite.visible=x.rimSprite.alpha>.001,Wn(x,e,c),x.bornAt=i,x.lifetimeMs=r.lifetimeMs,x.startAlpha=A,x.endAlpha=Z(r.endAlpha*t.alpha,0,1.5),x.baseScaleX=O,x.baseScaleY=k,x.blurStart=Math.max(0,r.blurStart+t.blur),x.blurEnd=Math.max(x.blurStart,r.blurEnd+t.blur),x.depth=r.depth,x.rimStrength=r.rimStrength,x.erosionStart=Z(r.erosionStart+(Math.random()*2-1)*.11,.05,.95),x.baseBlurFilter.strength=x.blurStart,x.depthBlurFilter.strength=x.blurStart*(.45+(1-r.depth)*.25),x.rimBlurFilter.strength=x.blurStart*.8,s.push(x),v(a),n.nextFoot=On(n.nextFoot),n.lastStepMs=i,n.distanceSinceStep=Math.max(0,n.distanceSinceStep-t.minStepDistance)},x=e=>{let t=$(r.defaultSurface),n=typeof t==`string`&&t.trim().length>0?t.trim():bn,a=Ln(r.profiles),s=Number($(r.maxFootprints)),c=Z(Q(s)?s:Sn,10,1200),l=Bn(i,n),u=new Set;for(let t=0;t<l.length;t++){let{instance:r,caster:i}=l[t];if(!r||r.destroyed||!r.parent)continue;u.add(r);let s=o.get(r);s||(s={lastPoint:null,lastUpdateMs:e,distanceSinceStep:0,lastStepMs:-1/0,nextFoot:`left`,heading:Number(r.rotation)||0},o.set(r,s));let d=r.parent,f=Un(r,d,i);if(!s.lastPoint){s.lastPoint=f,s.lastUpdateMs=e;continue}let p=Math.max(1,e-s.lastUpdateMs),m=f.x-s.lastPoint.x,h=f.y-s.lastPoint.y,g=Math.hypot(m,h);g>1e-4&&(s.heading=Math.atan2(h,m)),s.distanceSinceStep+=g;let _=g*1e3/p,v=a[i.surface]??a[n]??wn;_>=i.minSpeed&&s.distanceSinceStep>=i.minStepDistance&&e-s.lastStepMs>=i.stepIntervalMs&&b(r,i,s,v,e,c),s.lastPoint=f,s.lastUpdateMs=e}for(let[e]of o.entries())(!u.has(e)||e?.destroyed)&&o.delete(e);y(e)};return f=a?.observable?.subscribe(e=>{let t=e?.value??e,n=Number(t?.deltaTime),i=Q(n)?n:16.67;u+=i,l+=i;let a=Number($(r.updateHz)),o=1e3/Z(Q(a)?a:xn,1,120);(d||l>=o)&&(l=0,d=!1,x(u))}),x(0),()=>{f?.unsubscribe?.();for(let e=0;e<s.length;e++)g(s[e]);for(let e=0;e<c.length;e++)g(c[e]);s.length=0,c.length=0,o.clear(),p&&!p.destroyed&&p.destroy(!0),p=null}}),(0,t.h)(t.Container)}return e.Bar=a,e.CLOUD_PRESETS=Mt,e.FOG_PRESETS=jt,e.FX_PRESETS=o,e.FogOfWar=Kt,e.Footprints=Gn,e.Fx=T,e.FxRuntime=S,e.Loading=re,e.NightAmbiant=V,e.Particle=E,e.RAIN_PRESETS=kt,e.SNOW_PRESETS=At,e.SpriteShadows=vn,e.TiledMap=vt,e.WEATHER_PRESETS=Nt,e.Weather=Ft,e.WeatherEffect=Pt,e.createFogOfWarController=Ut,e.createNightFilter=R,e})({},CanvasEngine,PIXI);
579
+ //# sourceMappingURL=index.global.js.map