@datamoc/mw_games 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@ of their own; improvements to `mwg`'s own files are shared back.
9
9
  **[Live examples and API docs](https://datamoc.github.io/mwg/)**: every example below,
10
10
  playable in the browser with no download, plus the generated API reference.
11
11
 
12
- > **Status: early release (v0.2.0).** Every module in the shared floor below, plus optional
12
+ > **Status: early release (v0.2.1).** Every module in the shared floor below, plus optional
13
13
  > 3D, mobile (Capacitor) and desktop (WebView2) packaging, is built and tested - see
14
14
  > [ROADMAP.md](ROADMAP.md) for the full, numbered history. Still `0.y.z`: the "public API"
15
15
  > can still change between minor versions, and the wider genre-specific modules keep growing.
@@ -1 +1 @@
1
- {"version":3,"file":"Music.d.ts","sourceRoot":"","sources":["../../src/audio/Music.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAW3D,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;CACpC;AAED;;;;GAIG;AACH,qBAAa,KAAK;IACjB,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAA6B;IAC3C,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,OAAO,GAAE,YAAiB,EAGrC;IAED,4EAA4E;IAC5E,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,SAAI,GAAG,IAAI,CA4BzC;IAED,IAAI,CAAC,YAAY,SAAI,GAAG,IAAI,CAU3B;IAED,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAevB;CACD"}
1
+ {"version":3,"file":"Music.d.ts","sourceRoot":"","sources":["../../src/audio/Music.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAW3D,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;CACpC;AAED;;;;GAIG;AACH,qBAAa,KAAK;IACjB,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAA6B;IAC3C,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,OAAO,GAAE,YAAiB,EAGrC;IAED,4EAA4E;IAC5E,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,SAAI,GAAG,IAAI,CA+BzC;IAED,IAAI,CAAC,YAAY,SAAI,GAAG,IAAI,CAU3B;IAED,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAevB;CACD"}
@@ -19,12 +19,15 @@ export class Music {
19
19
  this.current = incoming;
20
20
  if (fadeDuration <= 0) {
21
21
  incoming.volume = this.volume;
22
- void incoming.play();
22
+ // a rejection here means the switch itself (or the previous.pause() right below)
23
+ // interrupted this play()'s own in-flight load - expected during a track switch,
24
+ // so swallow it the standard way rather than let it surface as unhandled.
25
+ void Promise.resolve(incoming.play()).catch(() => { });
23
26
  previous?.pause();
24
27
  return;
25
28
  }
26
29
  incoming.volume = 0;
27
- void incoming.play();
30
+ void Promise.resolve(incoming.play()).catch(() => { });
28
31
  this.fades.push({ audio: incoming, elapsed: 0, duration: fadeDuration, from: 0, to: this.volume, stopAtEnd: false });
29
32
  if (previous) {
30
33
  this.fades.push({
@@ -1 +1 @@
1
- {"version":3,"file":"Music.js","sourceRoot":"","sources":["../../src/audio/Music.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAgB3D;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAMjB,YAAY,OAAO,GAAiB,EA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AI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE1D,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/C,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;oBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;oBACnB,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"Sound.d.ts","sourceRoot":"","sources":["../../src/audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,YAAY;IAC5B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAEpC,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,KAAK;IACjB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAMnD;IAED,IAAI,IAAI,IAAI,CASX;IAED,OAAO,IAAI,IAAI,CAKd;CACD"}
1
+ {"version":3,"file":"Sound.d.ts","sourceRoot":"","sources":["../../src/audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,YAAY;IAC5B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAEpC,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,KAAK;IACjB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAMnD;IAED,IAAI,IAAI,IAAI,CAYX;IAED,OAAO,IAAI,IAAI,CAKd;CACD"}
@@ -20,7 +20,10 @@ export class Sound {
20
20
  this.next = (this.next + 1) % this.pool.length;
21
21
  audio.volume = this.volume;
22
22
  audio.currentTime = 0;
23
- void audio.play();
23
+ // play() can return a Promise that rejects if this reuse interrupts its own prior,
24
+ // still-loading play() (a real browser, not the fakes tests supply) - swallow it the
25
+ // standard way, since restarting a pooled clip mid-load is expected here, not an error.
26
+ void Promise.resolve(audio.play()).catch(() => { });
24
27
  if (this.caption)
25
28
  onCaption.dispatch({ text: this.caption });
26
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAc1C;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IAMjB,YAAY,IAAY,EAAE,OAAO,GAAiB,EAAE;QAJ5C,SAAI,GAAG,CA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,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"Synth.d.ts","sourceRoot":"","sources":["../../src/audio/Synth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,WAAgB,GAAG,MAAM,CAsBhE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,WAAgB,EAAE,MAAM,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,QAAkC,GAAG,QAAQ,CAI7H"}
1
+ {"version":3,"file":"Synth.d.ts","sourceRoot":"","sources":["../../src/audio/Synth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,WAAgB,GAAG,MAAM,CAsBhE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,WAAgB,EAAE,MAAM,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,QAAkC,GAAG,QAAQ,CAM7H"}
@@ -34,7 +34,9 @@ export function synthesizeTone(options = {}) {
34
34
  */
35
35
  export function playTone(options = {}, create = (uri) => new Audio(uri)) {
36
36
  const playable = create(synthesizeTone(options));
37
- void playable.play();
37
+ // same rejection-swallowing as Sound.play()/Music.play(): an interrupted play() here is
38
+ // expected, not an error, and must not escape as an unhandled rejection.
39
+ void Promise.resolve(playable.play()).catch(() => { });
38
40
  return playable;
39
41
  }
40
42
  function waveSample(waveform, phase, seed, index) {
@@ -1 +1 @@
1
- {"version":3,"file":"Synth.js","sourceRoot":"","sources":["../../src/audio/Synth.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAO,GAAgB,EAAE;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;IAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC;IACrC,MAAM,KAA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G,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACnF,MAAM,IAAI,CAAC,CAAC;IACb,CAAC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,yBAAyB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,UAAU,CAAC,IAAc,EAAE,MAAc,EAAE,IAAY;IAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -1,4 +1,4 @@
1
- var mw_games=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=`0.2.0`,p,m,h,g,_=s((()=>{p=(e=>(e.Application=`application`,e.WebGLPipes=`webgl-pipes`,e.WebGLPipesAdaptor=`webgl-pipes-adaptor`,e.WebGLSystem=`webgl-system`,e.WebGPUPipes=`webgpu-pipes`,e.WebGPUPipesAdaptor=`webgpu-pipes-adaptor`,e.WebGPUSystem=`webgpu-system`,e.CanvasSystem=`canvas-system`,e.CanvasPipesAdaptor=`canvas-pipes-adaptor`,e.CanvasPipes=`canvas-pipes`,e.Asset=`asset`,e.LoadParser=`load-parser`,e.ResolveParser=`resolve-parser`,e.CacheParser=`cache-parser`,e.DetectionParser=`detection-parser`,e.MaskEffect=`mask-effect`,e.BlendMode=`blend-mode`,e.TextureSource=`texture-source`,e.TextureUploaderWebGL=`texture-uploader-webgl`,e.TextureUploaderWebGPU=`texture-uploader-webgpu`,e.Environment=`environment`,e.ShapeBuilder=`shape-builder`,e.Batcher=`batcher`,e))(p||{}),m=e=>{if(typeof e==`function`||typeof e==`object`&&e.extension){if(!e.extension)throw Error(`Extension class must have an extension object`);e={...typeof e.extension==`object`?e.extension:{type:e.extension},ref:e}}if(typeof e==`object`)e={...e};else throw Error(`Invalid extension type`);return typeof e.type==`string`&&(e.type=[e.type]),e},h=(e,t)=>m(e).priority??t,g={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(m).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...e){return e.map(m).forEach(e=>{e.type.forEach(t=>{let n=this._addHandlers,r=this._queue;n[t]?n[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(e,t,n){let r=this._addHandlers,i=this._removeHandlers;if(r[e]||i[e])throw Error(`Extension type ${e} already has a handler`);r[e]=t,i[e]=n;let a=this._queue;return a[e]&&(a[e]?.forEach(e=>t(e)),delete a[e]),this},handleByMap(e,t){return this.handle(e,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,e=>{t.findIndex(t=>t.name===e.name)>=0||(t.push({name:e.name,value:e.ref}),t.sort((e,t)=>h(t.value,n)-h(e.value,n)))},e=>{let n=t.findIndex(t=>t.name===e.name);n!==-1&&t.splice(n,1)})},handleByList(e,t,n=-1){return this.handle(e,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((e,t)=>h(t,n)-h(e,n)))},e=>{let n=t.indexOf(e.ref);n!==-1&&t.splice(n,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}})),v=c(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),y,b,x=s((()=>{y=d(v(),1),b=y.default})),S,C,w,T,E,D,O,k,ee,te,A,j,ne,re,ie,ae,oe,M,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve=s((()=>{S={grad:.9,turn:360,rad:360/(2*Math.PI)},C=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},w=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},T=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},E=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},D=function(e){return{r:T(e.r,0,255),g:T(e.g,0,255),b:T(e.b,0,255),a:T(e.a)}},O=function(e){return{r:w(e.r),g:w(e.g),b:w(e.b),a:w(e.a,3)}},k=/^#([0-9a-f]{3,8})$/i,ee=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},te=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},A=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},j=function(e){return{h:E(e.h),s:T(e.s,0,100),l:T(e.l,0,100),a:T(e.a)}},ne=function(e){return{h:w(e.h),s:w(e.s),l:w(e.l),a:w(e.a,3)}},re=function(e){return A((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},ie=function(e){return{h:(t=te(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},ae=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,M=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,se=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ce={string:[[function(e){var t=k.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?w(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?w(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=M.exec(e)||se.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:D({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=ae.exec(e)||oe.exec(e);if(!t)return null;var n,r;return re(j({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(S[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return C(t)&&C(n)&&C(r)?D({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!C(t)||!C(n)||!C(r)?null:re(j({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!C(t)||!C(n)||!C(r)?null:A(function(e){return{h:E(e.h),s:T(e.s,0,100),v:T(e.v,0,100),a:T(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},le=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},ue=function(e){return typeof e==`string`?le(e.trim(),ce.string):typeof e==`object`&&e?le(e,ce.object):[null,void 0]},de=function(e,t){var n=ie(e);return{h:n.h,s:T(n.s+100*t,0,100),l:n.l,a:n.a}},fe=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},pe=function(e,t){var n=ie(e);return{h:n.h,s:n.s,l:T(n.l+100*t,0,100),a:n.a}},me=function(){function e(e){this.parsed=ue(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return w(fe(this.rgba),2)},e.prototype.isDark=function(){return fe(this.rgba)<.5},e.prototype.isLight=function(){return fe(this.rgba)>=.5},e.prototype.toHex=function(){return e=O(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?ee(w(255*i)):``,`#`+ee(t)+ee(n)+ee(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return O(this.rgba)},e.prototype.toRgbString=function(){return e=O(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return ne(ie(this.rgba))},e.prototype.toHslString=function(){return e=ne(ie(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=te(this.rgba),{h:w(e.h),s:w(e.s),v:w(e.v),a:w(e.a,3)};var e},e.prototype.invert=function(){return he({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),he(de(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),he(de(this.rgba,-e))},e.prototype.grayscale=function(){return he(de(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),he(pe(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),he(pe(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?he({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):w(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=ie(this.rgba);return typeof e==`number`?he({h:e,s:t.s,l:t.l,a:t.a}):w(t.h)},e.prototype.isEqual=function(e){return this.toHex()===he(e).toHex()},e}(),he=function(e){return e instanceof me?e:new me(e)},ge=[],_e=function(e){e.forEach(function(e){ge.indexOf(e)<0&&(e(me,ce),ge.push(e))})}}));function ye(e,t){var n={white:`#ffffff`,bisque:`#ffe4c4`,blue:`#0000ff`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,antiquewhite:`#faebd7`,aqua:`#00ffff`,azure:`#f0ffff`,whitesmoke:`#f5f5f5`,papayawhip:`#ffefd5`,plum:`#dda0dd`,blanchedalmond:`#ffebcd`,black:`#000000`,gold:`#ffd700`,goldenrod:`#daa520`,gainsboro:`#dcdcdc`,cornsilk:`#fff8dc`,cornflowerblue:`#6495ed`,burlywood:`#deb887`,aquamarine:`#7fffd4`,beige:`#f5f5dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkkhaki:`#bdb76b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,peachpuff:`#ffdab9`,darkmagenta:`#8b008b`,darkred:`#8b0000`,darkorchid:`#9932cc`,darkorange:`#ff8c00`,darkslateblue:`#483d8b`,gray:`#808080`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,wheat:`#f5deb3`,firebrick:`#b22222`,floralwhite:`#fffaf0`,ghostwhite:`#f8f8ff`,darkviolet:`#9400d3`,magenta:`#ff00ff`,green:`#008000`,dodgerblue:`#1e90ff`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,blueviolet:`#8a2be2`,forestgreen:`#228b22`,lawngreen:`#7cfc00`,indianred:`#cd5c5c`,indigo:`#4b0082`,fuchsia:`#ff00ff`,brown:`#a52a2a`,maroon:`#800000`,mediumblue:`#0000cd`,lightcoral:`#f08080`,darkturquoise:`#00ced1`,lightcyan:`#e0ffff`,ivory:`#fffff0`,lightyellow:`#ffffe0`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,linen:`#faf0e6`,mediumaquamarine:`#66cdaa`,lemonchiffon:`#fffacd`,lime:`#00ff00`,khaki:`#f0e68c`,mediumseagreen:`#3cb371`,limegreen:`#32cd32`,mediumspringgreen:`#00fa9a`,lightskyblue:`#87cefa`,lightblue:`#add8e6`,midnightblue:`#191970`,lightpink:`#ffb6c1`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,mintcream:`#f5fffa`,lightslategray:`#778899`,lightslategrey:`#778899`,navajowhite:`#ffdead`,navy:`#000080`,mediumvioletred:`#c71585`,powderblue:`#b0e0e6`,palegoldenrod:`#eee8aa`,oldlace:`#fdf5e6`,paleturquoise:`#afeeee`,mediumturquoise:`#48d1cc`,mediumorchid:`#ba55d3`,rebeccapurple:`#663399`,lightsteelblue:`#b0c4de`,mediumslateblue:`#7b68ee`,thistle:`#d8bfd8`,tan:`#d2b48c`,orchid:`#da70d6`,mediumpurple:`#9370db`,purple:`#800080`,pink:`#ffc0cb`,skyblue:`#87ceeb`,springgreen:`#00ff7f`,palegreen:`#98fb98`,red:`#ff0000`,yellow:`#ffff00`,slateblue:`#6a5acd`,lavenderblush:`#fff0f5`,peru:`#cd853f`,palevioletred:`#db7093`,violet:`#ee82ee`,teal:`#008080`,slategray:`#708090`,slategrey:`#708090`,aliceblue:`#f0f8ff`,darkseagreen:`#8fbc8f`,darkolivegreen:`#556b2f`,greenyellow:`#adff2f`,seagreen:`#2e8b57`,seashell:`#fff5ee`,tomato:`#ff6347`,silver:`#c0c0c0`,sienna:`#a0522d`,lavender:`#e6e6fa`,lightgreen:`#90ee90`,orange:`#ffa500`,orangered:`#ff4500`,steelblue:`#4682b4`,royalblue:`#4169e1`,turquoise:`#40e0d0`,yellowgreen:`#9acd32`,salmon:`#fa8072`,saddlebrown:`#8b4513`,sandybrown:`#f4a460`,rosybrown:`#bc8f8f`,darksalmon:`#e9967a`,lightgoldenrodyellow:`#fafad2`,snow:`#fffafa`,lightgrey:`#d3d3d3`,lightgray:`#d3d3d3`,dimgray:`#696969`,dimgrey:`#696969`,olivedrab:`#6b8e23`,olive:`#808000`},r={};for(var i in n)r[n[i]]=i;var a={};e.prototype.toName=function(t){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return`transparent`;var i,o,s=r[this.toHex()];if(s)return s;if(t?.closest){var c=this.toRgb(),l=1/0,u=`black`;if(!a.length)for(var d in n)a[d]=new e(n[d]).toRgb();for(var f in n){var p=(i=c,o=a[f],(i.r-o.r)**2+(i.g-o.g)**2+(i.b-o.b)**2);p<l&&(l=p,u=f)}return u}},t.string.push([function(t){var r=t.toLowerCase(),i=r===`transparent`?`#0000`:n[r];return i?new e(i).toRgb():null},`name`])}var be=s((()=>{})),xe,N,Se=s((()=>{ve(),be(),_e([ye]),xe=class e{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(t){if(t instanceof e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else if(t===null)throw Error(`Cannot set Color#value to null`);else(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}get value(){return this._value}_cloneSource(e){return typeof e==`string`||typeof e==`number`||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e==`object`&&e?{...e}:e}_isSourceEqual(e,t){let n=typeof e;if(n!==typeof t)return!1;if(n===`number`||n===`string`||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(e!==null&&t!==null){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}return e===t}toRgba(){let[e,t,n,r]=this._components;return{r:e,g:t,b:n,a:r}}toRgb(){let[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){let[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){let[t,n,r]=this._components;return this._arrayRgb||=[],e||=this._arrayRgb,e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||=[],e||=this._arrayRgba;let[t,n,r,i]=this._components;return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}toRgbArray(e){this._arrayRgb||=[],e||=this._arrayRgb;let[t,n,r]=this._components;return e[0]=t,e[1]=n,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){let[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(t){let[n,r,i,a]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let n=this._int>>16&255,r=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,r=r*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(r<<8)+i}toHex(){let e=this._int.toString(16);return`#${`000000`.substring(0,6-e.length)+e}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+`00`.substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(t){let n,r,i,a;if((typeof t==`number`||t instanceof Number)&&t>=0&&t<=16777215){let e=t;n=(e>>16&255)/255,r=(e>>8&255)/255,i=(e&255)/255,a=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,r,i,a=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,r,i,a=255]=t,n/=255,r/=255,i/=255,a/=255;else if(typeof t==`string`||typeof t==`object`){if(typeof t==`string`){let n=e.HEX_PATTERN.exec(t);n&&(t=`#${n[2]}`)}let o=he(t);o.isValid()&&({r:n,g:r,b:i,a}=o.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[e,t,n]=this._components;this._int=(e*255<<16)+(t*255<<8)+(n*255|0)}_clamp(e,t=0,n=1){return typeof e==`number`?Math.min(Math.max(e,t),n):(e.forEach((r,i)=>{e[i]=Math.min(Math.max(r,t),n)}),e)}static isColorLike(t){return typeof t==`number`||typeof t==`string`||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},xe.shared=new xe,xe._temp=new xe,xe.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i,N=xe})),Ce,we=s((()=>{Ce={cullArea:null,cullable:!1,cullableChildren:!0}})),Te,Ee,De,Oe=s((()=>{Te=Math.PI*2,Ee=180/Math.PI,De=Math.PI/180})),ke,Ae,je=s((()=>{ke=class e{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new e(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Ae.x=0,Ae.y=0,Ae}},Ae=new ke})),P,Me,Ne,F=s((()=>{Oe(),je(),P=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}toArray(e,t){this.array||=new Float32Array(9);let n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}apply(e,t){t||=new ke;let n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}applyInverse(e,t){t||=new ke;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(Te-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e}invert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ne.identity()}static get shared(){return Me.identity()}},Me=new P,Ne=new P})),Pe,Fe=s((()=>{Pe=class e{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(t){return new e(t??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}}));function I(e=`default`){return Ie[e]===void 0&&(Ie[e]=-1),++Ie[e]}var Ie,Le=s((()=>{Ie={default:-1}})),Re,L,ze,Be,R,z=s((()=>{Re=new Set,L=`8.0.0`,ze=`8.3.4`,Be={quiet:!1,noColor:!1},R=((e,t,n=3)=>{if(Be.quiet||Re.has(t))return;let r=Error().stack,i=`${t}
1
+ var mw_games=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=`0.2.1`,p,m,h,g,_=s((()=>{p=(e=>(e.Application=`application`,e.WebGLPipes=`webgl-pipes`,e.WebGLPipesAdaptor=`webgl-pipes-adaptor`,e.WebGLSystem=`webgl-system`,e.WebGPUPipes=`webgpu-pipes`,e.WebGPUPipesAdaptor=`webgpu-pipes-adaptor`,e.WebGPUSystem=`webgpu-system`,e.CanvasSystem=`canvas-system`,e.CanvasPipesAdaptor=`canvas-pipes-adaptor`,e.CanvasPipes=`canvas-pipes`,e.Asset=`asset`,e.LoadParser=`load-parser`,e.ResolveParser=`resolve-parser`,e.CacheParser=`cache-parser`,e.DetectionParser=`detection-parser`,e.MaskEffect=`mask-effect`,e.BlendMode=`blend-mode`,e.TextureSource=`texture-source`,e.TextureUploaderWebGL=`texture-uploader-webgl`,e.TextureUploaderWebGPU=`texture-uploader-webgpu`,e.Environment=`environment`,e.ShapeBuilder=`shape-builder`,e.Batcher=`batcher`,e))(p||{}),m=e=>{if(typeof e==`function`||typeof e==`object`&&e.extension){if(!e.extension)throw Error(`Extension class must have an extension object`);e={...typeof e.extension==`object`?e.extension:{type:e.extension},ref:e}}if(typeof e==`object`)e={...e};else throw Error(`Invalid extension type`);return typeof e.type==`string`&&(e.type=[e.type]),e},h=(e,t)=>m(e).priority??t,g={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(m).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...e){return e.map(m).forEach(e=>{e.type.forEach(t=>{let n=this._addHandlers,r=this._queue;n[t]?n[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(e,t,n){let r=this._addHandlers,i=this._removeHandlers;if(r[e]||i[e])throw Error(`Extension type ${e} already has a handler`);r[e]=t,i[e]=n;let a=this._queue;return a[e]&&(a[e]?.forEach(e=>t(e)),delete a[e]),this},handleByMap(e,t){return this.handle(e,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,e=>{t.findIndex(t=>t.name===e.name)>=0||(t.push({name:e.name,value:e.ref}),t.sort((e,t)=>h(t.value,n)-h(e.value,n)))},e=>{let n=t.findIndex(t=>t.name===e.name);n!==-1&&t.splice(n,1)})},handleByList(e,t,n=-1){return this.handle(e,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((e,t)=>h(t,n)-h(e,n)))},e=>{let n=t.indexOf(e.ref);n!==-1&&t.splice(n,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}})),v=c(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),y,b,x=s((()=>{y=d(v(),1),b=y.default})),S,C,w,T,E,D,O,k,ee,te,A,j,ne,re,ie,ae,oe,M,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve=s((()=>{S={grad:.9,turn:360,rad:360/(2*Math.PI)},C=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},w=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},T=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},E=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},D=function(e){return{r:T(e.r,0,255),g:T(e.g,0,255),b:T(e.b,0,255),a:T(e.a)}},O=function(e){return{r:w(e.r),g:w(e.g),b:w(e.b),a:w(e.a,3)}},k=/^#([0-9a-f]{3,8})$/i,ee=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},te=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},A=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},j=function(e){return{h:E(e.h),s:T(e.s,0,100),l:T(e.l,0,100),a:T(e.a)}},ne=function(e){return{h:w(e.h),s:w(e.s),l:w(e.l),a:w(e.a,3)}},re=function(e){return A((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},ie=function(e){return{h:(t=te(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},ae=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,M=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,se=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ce={string:[[function(e){var t=k.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?w(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?w(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=M.exec(e)||se.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:D({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=ae.exec(e)||oe.exec(e);if(!t)return null;var n,r;return re(j({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(S[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return C(t)&&C(n)&&C(r)?D({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!C(t)||!C(n)||!C(r)?null:re(j({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!C(t)||!C(n)||!C(r)?null:A(function(e){return{h:E(e.h),s:T(e.s,0,100),v:T(e.v,0,100),a:T(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},le=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},ue=function(e){return typeof e==`string`?le(e.trim(),ce.string):typeof e==`object`&&e?le(e,ce.object):[null,void 0]},de=function(e,t){var n=ie(e);return{h:n.h,s:T(n.s+100*t,0,100),l:n.l,a:n.a}},fe=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},pe=function(e,t){var n=ie(e);return{h:n.h,s:n.s,l:T(n.l+100*t,0,100),a:n.a}},me=function(){function e(e){this.parsed=ue(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return w(fe(this.rgba),2)},e.prototype.isDark=function(){return fe(this.rgba)<.5},e.prototype.isLight=function(){return fe(this.rgba)>=.5},e.prototype.toHex=function(){return e=O(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?ee(w(255*i)):``,`#`+ee(t)+ee(n)+ee(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return O(this.rgba)},e.prototype.toRgbString=function(){return e=O(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return ne(ie(this.rgba))},e.prototype.toHslString=function(){return e=ne(ie(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=te(this.rgba),{h:w(e.h),s:w(e.s),v:w(e.v),a:w(e.a,3)};var e},e.prototype.invert=function(){return he({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),he(de(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),he(de(this.rgba,-e))},e.prototype.grayscale=function(){return he(de(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),he(pe(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),he(pe(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?he({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):w(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=ie(this.rgba);return typeof e==`number`?he({h:e,s:t.s,l:t.l,a:t.a}):w(t.h)},e.prototype.isEqual=function(e){return this.toHex()===he(e).toHex()},e}(),he=function(e){return e instanceof me?e:new me(e)},ge=[],_e=function(e){e.forEach(function(e){ge.indexOf(e)<0&&(e(me,ce),ge.push(e))})}}));function ye(e,t){var n={white:`#ffffff`,bisque:`#ffe4c4`,blue:`#0000ff`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,antiquewhite:`#faebd7`,aqua:`#00ffff`,azure:`#f0ffff`,whitesmoke:`#f5f5f5`,papayawhip:`#ffefd5`,plum:`#dda0dd`,blanchedalmond:`#ffebcd`,black:`#000000`,gold:`#ffd700`,goldenrod:`#daa520`,gainsboro:`#dcdcdc`,cornsilk:`#fff8dc`,cornflowerblue:`#6495ed`,burlywood:`#deb887`,aquamarine:`#7fffd4`,beige:`#f5f5dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkkhaki:`#bdb76b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,peachpuff:`#ffdab9`,darkmagenta:`#8b008b`,darkred:`#8b0000`,darkorchid:`#9932cc`,darkorange:`#ff8c00`,darkslateblue:`#483d8b`,gray:`#808080`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,wheat:`#f5deb3`,firebrick:`#b22222`,floralwhite:`#fffaf0`,ghostwhite:`#f8f8ff`,darkviolet:`#9400d3`,magenta:`#ff00ff`,green:`#008000`,dodgerblue:`#1e90ff`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,blueviolet:`#8a2be2`,forestgreen:`#228b22`,lawngreen:`#7cfc00`,indianred:`#cd5c5c`,indigo:`#4b0082`,fuchsia:`#ff00ff`,brown:`#a52a2a`,maroon:`#800000`,mediumblue:`#0000cd`,lightcoral:`#f08080`,darkturquoise:`#00ced1`,lightcyan:`#e0ffff`,ivory:`#fffff0`,lightyellow:`#ffffe0`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,linen:`#faf0e6`,mediumaquamarine:`#66cdaa`,lemonchiffon:`#fffacd`,lime:`#00ff00`,khaki:`#f0e68c`,mediumseagreen:`#3cb371`,limegreen:`#32cd32`,mediumspringgreen:`#00fa9a`,lightskyblue:`#87cefa`,lightblue:`#add8e6`,midnightblue:`#191970`,lightpink:`#ffb6c1`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,mintcream:`#f5fffa`,lightslategray:`#778899`,lightslategrey:`#778899`,navajowhite:`#ffdead`,navy:`#000080`,mediumvioletred:`#c71585`,powderblue:`#b0e0e6`,palegoldenrod:`#eee8aa`,oldlace:`#fdf5e6`,paleturquoise:`#afeeee`,mediumturquoise:`#48d1cc`,mediumorchid:`#ba55d3`,rebeccapurple:`#663399`,lightsteelblue:`#b0c4de`,mediumslateblue:`#7b68ee`,thistle:`#d8bfd8`,tan:`#d2b48c`,orchid:`#da70d6`,mediumpurple:`#9370db`,purple:`#800080`,pink:`#ffc0cb`,skyblue:`#87ceeb`,springgreen:`#00ff7f`,palegreen:`#98fb98`,red:`#ff0000`,yellow:`#ffff00`,slateblue:`#6a5acd`,lavenderblush:`#fff0f5`,peru:`#cd853f`,palevioletred:`#db7093`,violet:`#ee82ee`,teal:`#008080`,slategray:`#708090`,slategrey:`#708090`,aliceblue:`#f0f8ff`,darkseagreen:`#8fbc8f`,darkolivegreen:`#556b2f`,greenyellow:`#adff2f`,seagreen:`#2e8b57`,seashell:`#fff5ee`,tomato:`#ff6347`,silver:`#c0c0c0`,sienna:`#a0522d`,lavender:`#e6e6fa`,lightgreen:`#90ee90`,orange:`#ffa500`,orangered:`#ff4500`,steelblue:`#4682b4`,royalblue:`#4169e1`,turquoise:`#40e0d0`,yellowgreen:`#9acd32`,salmon:`#fa8072`,saddlebrown:`#8b4513`,sandybrown:`#f4a460`,rosybrown:`#bc8f8f`,darksalmon:`#e9967a`,lightgoldenrodyellow:`#fafad2`,snow:`#fffafa`,lightgrey:`#d3d3d3`,lightgray:`#d3d3d3`,dimgray:`#696969`,dimgrey:`#696969`,olivedrab:`#6b8e23`,olive:`#808000`},r={};for(var i in n)r[n[i]]=i;var a={};e.prototype.toName=function(t){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return`transparent`;var i,o,s=r[this.toHex()];if(s)return s;if(t?.closest){var c=this.toRgb(),l=1/0,u=`black`;if(!a.length)for(var d in n)a[d]=new e(n[d]).toRgb();for(var f in n){var p=(i=c,o=a[f],(i.r-o.r)**2+(i.g-o.g)**2+(i.b-o.b)**2);p<l&&(l=p,u=f)}return u}},t.string.push([function(t){var r=t.toLowerCase(),i=r===`transparent`?`#0000`:n[r];return i?new e(i).toRgb():null},`name`])}var be=s((()=>{})),xe,N,Se=s((()=>{ve(),be(),_e([ye]),xe=class e{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(t){if(t instanceof e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else if(t===null)throw Error(`Cannot set Color#value to null`);else(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}get value(){return this._value}_cloneSource(e){return typeof e==`string`||typeof e==`number`||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e==`object`&&e?{...e}:e}_isSourceEqual(e,t){let n=typeof e;if(n!==typeof t)return!1;if(n===`number`||n===`string`||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(e!==null&&t!==null){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}return e===t}toRgba(){let[e,t,n,r]=this._components;return{r:e,g:t,b:n,a:r}}toRgb(){let[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){let[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){let[t,n,r]=this._components;return this._arrayRgb||=[],e||=this._arrayRgb,e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||=[],e||=this._arrayRgba;let[t,n,r,i]=this._components;return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}toRgbArray(e){this._arrayRgb||=[],e||=this._arrayRgb;let[t,n,r]=this._components;return e[0]=t,e[1]=n,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){let[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(t){let[n,r,i,a]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let n=this._int>>16&255,r=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,r=r*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(r<<8)+i}toHex(){let e=this._int.toString(16);return`#${`000000`.substring(0,6-e.length)+e}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+`00`.substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(t){let n,r,i,a;if((typeof t==`number`||t instanceof Number)&&t>=0&&t<=16777215){let e=t;n=(e>>16&255)/255,r=(e>>8&255)/255,i=(e&255)/255,a=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,r,i,a=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,r,i,a=255]=t,n/=255,r/=255,i/=255,a/=255;else if(typeof t==`string`||typeof t==`object`){if(typeof t==`string`){let n=e.HEX_PATTERN.exec(t);n&&(t=`#${n[2]}`)}let o=he(t);o.isValid()&&({r:n,g:r,b:i,a}=o.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[e,t,n]=this._components;this._int=(e*255<<16)+(t*255<<8)+(n*255|0)}_clamp(e,t=0,n=1){return typeof e==`number`?Math.min(Math.max(e,t),n):(e.forEach((r,i)=>{e[i]=Math.min(Math.max(r,t),n)}),e)}static isColorLike(t){return typeof t==`number`||typeof t==`string`||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},xe.shared=new xe,xe._temp=new xe,xe.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i,N=xe})),Ce,we=s((()=>{Ce={cullArea:null,cullable:!1,cullableChildren:!0}})),Te,Ee,De,Oe=s((()=>{Te=Math.PI*2,Ee=180/Math.PI,De=Math.PI/180})),ke,Ae,je=s((()=>{ke=class e{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new e(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Ae.x=0,Ae.y=0,Ae}},Ae=new ke})),P,Me,Ne,F=s((()=>{Oe(),je(),P=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}toArray(e,t){this.array||=new Float32Array(9);let n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}apply(e,t){t||=new ke;let n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}applyInverse(e,t){t||=new ke;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(Te-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e}invert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ne.identity()}static get shared(){return Me.identity()}},Me=new P,Ne=new P})),Pe,Fe=s((()=>{Pe=class e{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(t){return new e(t??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}}));function I(e=`default`){return Ie[e]===void 0&&(Ie[e]=-1),++Ie[e]}var Ie,Le=s((()=>{Ie={default:-1}})),Re,L,ze,Be,R,z=s((()=>{Re=new Set,L=`8.0.0`,ze=`8.3.4`,Be={quiet:!1,noColor:!1},R=((e,t,n=3)=>{if(Be.quiet||Re.has(t))return;let r=Error().stack,i=`${t}
2
2
  Deprecated since v${e}`,a=typeof console.groupCollapsed==`function`&&!Be.noColor;r===void 0?console.warn(`PixiJS Deprecation Warning: `,i):(r=r.split(`
3
3
  `).splice(n).join(`
4
4
  `),a?(console.groupCollapsed(`%cPixiJS Deprecation Warning: %c%s`,`color:#614108;background:#fffbe6`,`font-weight:normal;color:#614108;background:#fffbe6`,i),console.warn(r),console.groupEnd()):(console.warn(`PixiJS Deprecation Warning: `,i),console.warn(r))),Re.add(t)}),Object.defineProperties(R,{quiet:{get:()=>Be.quiet,set:e=>{Be.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>Be.noColor,set:e=>{Be.noColor=e},enumerable:!0,configurable:!1}})}));function B(...e){Ve!==He&&(Ve++,Ve===He?console.warn(`PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS.`):console.warn(`PixiJS Warning: `,...e))}var Ve,He,V=s((()=>{Ve=0,He=500})),Ue,We=s((()=>{Ue={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach(e=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}}})),Ge,Ke=s((()=>{Ge=class{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}})),qe,Je,Ye=s((()=>{We(),Ke(),qe=class{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Ge(e)),this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach(t=>{let n=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[n]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}},Je=new qe,Ue.register(Je)})),Xe,Ze=s((()=>{z(),Xe={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(e){typeof e==`boolean`&&e===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){R(`v8.6.0`,`cacheAsBitmap is deprecated, use cacheAsTexture instead.`),this.cacheAsTexture(e)}}}));function Qe(e,t,n){let r=e.length,i;if(t>=r||n===0)return;n=t+n>r?r-t:n;let a=r-n;for(i=t;i<a;++i)e[i]=e[i+n];e.length=a}var $e=s((()=>{})),et,tt=s((()=>{$e(),z(),et={allowChildren:!0,removeChildren(e=0,t){let n=t??this.children.length,r=n-e,i=[];if(r>0&&r<=n){for(let t=n-1;t>=e;t--){let e=this.children[t];e&&(i.push(e),e.parent=null)}Qe(this.children,e,n);let t=this.renderGroup||this.parentRenderGroup;t&&t.removeChildren(i);for(let e=0;e<i.length;++e){let t=i[e];t.parentRenderLayer?.detach(t),this.emit(`childRemoved`,t,this,e),i[e].emit(`removed`,this)}return i.length>0&&this._didViewChangeTick++,i}if(r===0&&this.children.length===0)return i;throw RangeError(`removeChildren: numeric values are outside the acceptable range.`)},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw Error(`The supplied Container must be a child of the caller`);return t},addChildAt(e,t){this.allowChildren||R(L,`addChildAt: Only Containers will be allowed to add children in v8.0.0`);let{children:n}=this;if(t<0||t>n.length)throw Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);let r=e.parent===this;if(e.parent){let n=e.parent.children.indexOf(e);if(r){if(n===t)return e;e.parent.children.splice(n,1)}else e.removeFromParent()}t===n.length?n.push(e):n.splice(t,0,e);let i=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),r?(i&&(i.structureDidChange=!0),e):(e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit(`childAdded`,e,this,t),e.emit(`added`,this),e)},swapChildren(e,t){if(e===t)return;let n=this.getChildIndex(e),r=this.getChildIndex(t);this.children[n]=t,this.children[r]=e;let i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){return e.length===1?this.reparentChildAt(e[0],this.children.length):(e.forEach(e=>this.reparentChildAt(e,this.children.length)),e[0])},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let r=this.worldTransform.clone();return r.invert(),n.prepend(r),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}}})),nt,rt=s((()=>{nt={collectRenderables(e,t,n){this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(e,t,n):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e):this.collectRenderablesWithEffects(e,t,n))},collectRenderablesSimple(e,t,n){let r=this.children,i=r.length;for(let a=0;a<i;a++)r[a].collectRenderables(e,t,n)},collectRenderablesWithEffects(e,t,n){let{renderPipes:r}=t;for(let t=0;t<this.effects.length;t++){let n=this.effects[t];r[n.pipe].push(n,this,e)}this.collectRenderablesSimple(e,t,n);for(let t=this.effects.length-1;t>=0;t--){let n=this.effects[t];r[n.pipe].pop(n,this,e)}}}})),it,at=s((()=>{it=class{constructor(){this.pipe=`filter`,this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}})),ot,st,ct=s((()=>{_(),Ye(),ot=class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){let n=this._tests[t];if(n.test(e))return Je.get(n.maskClass,e)}return e}returnMaskEffect(e){Je.return(e)}},st=new ot,g.handleByList(p.MaskEffect,st._effectClasses)})),lt,ut=s((()=>{at(),ct(),lt={_maskEffect:null,_maskOptions:{inverse:!1,channel:`red`},_filterEffect:null,effects:[],_markStructureAsChanged(){let e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0)},addEffect(e){this.effects.indexOf(e)===-1&&(this.effects.push(e),this.effects.sort((e,t)=>e.priority-t.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(e){let t=this.effects.indexOf(e);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(e){let t=this._maskEffect;t?.mask!==e&&(t&&(this.removeEffect(t),st.returnMaskEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=st.getMaskEffect(e),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(e){this._maskOptions={...this._maskOptions,...e},e.mask&&(this.mask=e.mask),this._markStructureAsChanged()},set filters(e){!Array.isArray(e)&&e&&(e=[e]);let t=this._filterEffect||=new it;e=e;let n=e?.length>0,r=n!==t.filters?.length>0;e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r&&(n?this.addEffect(t):(this.removeEffect(t),t.filters=e??null))},get filters(){return this._filterEffect?.filters},set filterArea(e){this._filterEffect||=new it,this._filterEffect.filterArea=e},get filterArea(){return this._filterEffect?.filterArea}}})),dt,ft=s((()=>{z(),dt={label:null,get name(){return R(L,`Container.name property has been removed, use Container.label instead`),this.label},set name(e){R(L,`Container.name property has been removed, use Container.label instead`),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){let n=this.children;for(let t=0;t<n.length;t++){let r=n[t];if(r.label===e||e instanceof RegExp&&e.test(r.label))return r}if(t)for(let t=0;t<n.length;t++){let r=n[t].getChildByLabel(e,!0);if(r)return r}return null},getChildrenByLabel(e,t=!1,n=[]){let r=this.children;for(let t=0;t<r.length;t++){let i=r[t];(i.label===e||e instanceof RegExp&&e.test(i.label))&&n.push(i)}if(t)for(let t=0;t<r.length;t++)r[t].getChildrenByLabel(e,!0,n);return n}}})),pt,H,mt=s((()=>{je(),pt=[new ke,new ke,new ke,new ke],H=class e{constructor(e=0,t=0,n=0,r=0){this.type=`rectangle`,this.x=Number(e),this.y=Number(t),this.width=Number(n),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new e(0,0,0,0)}clone(){return new e(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,n,r=.5){let{width:i,height:a}=this;if(i<=0||a<=0)return!1;let o=this.x,s=this.y,c=n*(1-r),l=n-c,u=o-c,d=o+i+c,f=s-c,p=s+a+c,m=o+l,h=o+i-l,g=s+l,_=s+a-l;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<h&&t>g&&t<_)}intersects(e,t){if(!t){let t=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=t)return!1;let n=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>n}let n=this.left,r=this.right,i=this.top,a=this.bottom;if(r<=n||a<=i)return!1;let o=pt[0].set(e.left,e.top),s=pt[1].set(e.left,e.bottom),c=pt[2].set(e.right,e.top),l=pt[3].set(e.right,e.bottom);if(c.x<=o.x||s.y<=o.y)return!1;let u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(o,o),t.apply(s,s),t.apply(c,c),t.apply(l,l),Math.max(o.x,s.x,c.x,l.x)<=n||Math.min(o.x,s.x,c.x,l.x)>=r||Math.max(o.y,s.y,c.y,l.y)<=i||Math.min(o.y,s.y,c.y,l.y)>=a))return!1;let d=u*(s.y-o.y),f=u*(o.x-s.x),p=d*n+f*i,m=d*r+f*i,h=d*n+f*a,g=d*r+f*a;if(Math.max(p,m,h,g)<=d*o.x+f*o.y||Math.min(p,m,h,g)>=d*l.x+f*l.y)return!1;let _=u*(o.y-c.y),v=u*(c.x-o.x),y=_*n+v*i,b=_*r+v*i,x=_*n+v*a,S=_*r+v*a;return!(Math.max(y,b,x,S)<=_*o.x+v*o.y||Math.min(y,b,x,S)>=_*l.x+v*l.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),i=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=r,this.height=Math.max(i-r,0),this}ceil(e=1,t=.001){let n=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=r-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),i=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=r,this.height=i-r,this}getBounds(t){return t||=new e,t.copyFrom(this),t}containsRect(e){if(this.width<=0||this.height<=0)return!1;let t=e.x,n=e.y,r=e.x+e.width,i=e.y+e.height;return t>=this.x&&t<this.x+this.width&&n>=this.y&&n<this.y+this.height&&r>=this.x&&r<=this.x+this.width&&i>=this.y&&i<=this.y+this.height}set(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}})),ht,gt,_t=s((()=>{F(),mt(),ht=new P,gt=class e{constructor(e=1/0,t=1/0,n=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ht,this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||=new H;let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ht,this}set(e,t,n,r){this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}addFrame(e,t,n,r,i){i||=this.matrix;let a=i.a,o=i.b,s=i.c,c=i.d,l=i.tx,u=i.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*e+s*t+l,g=o*e+c*t+u;h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*t+l,g=o*n+c*t+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*e+s*r+l,g=o*e+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*r+l,g=o*n+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){let t=this.minX,n=this.minY,r=this.maxX,i=this.maxY,{a,b:o,c:s,d:c,tx:l,ty:u}=e,d=a*t+s*n+l,f=o*t+c*n+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+s*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*t+s*i+l,f=o*t+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+s*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,n,r){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<n&&(this.minY=n),this.maxY>r&&(this.maxY=r),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new e(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,n,r){let i=this.minX,a=this.minY,o=this.maxX,s=this.maxY;r||=this.matrix;let c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let r=t;r<n;r+=2){let t=e[r],n=e[r+1],m=c*t+u*n+f,h=l*t+d*n+p;i=m<i?m:i,a=h<a?h:a,o=m>o?m:o,s=h>s?h:s}this.minX=i,this.minY=a,this.maxX=o,this.maxY=s}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}})),vt,yt,bt=s((()=>{F(),Ye(),_t(),vt=Je.getPool(P),yt=Je.getPool(gt)})),xt,St,Ct=s((()=>{F(),_t(),bt(),xt=new P,St={getFastGlobalBounds(e,t){t||=new gt,t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);let n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let r=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n||this.localDisplayStatus!==7||!this.measurable)return;let i=!!this.effects.length;if((this.renderGroup||i)&&(r=yt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let e=this.bounds;r.addFrame(e.minX,e.minY,e.maxX,e.maxY,this.groupTransform)}let t=this.children;for(let i=0;i<t.length;i++)t[i]._getGlobalBoundsRecursive(e,r,n)}if(i){let e=!1,n=this.renderGroup||this.parentRenderGroup;for(let t=0;t<this.effects.length;t++)this.effects[t].addBounds&&(e||(e=!0,r.applyMatrix(n.worldTransform)),this.effects[t].addBounds(r,!0));e&&r.applyMatrix(n.worldTransform.copyTo(xt).invert()),t.addBounds(r),yt.return(r)}else this.renderGroup&&(t.addBounds(r,this.relativeGroupTransform),yt.return(r))}}}));function wt(e,t,n){n.clear();let r,i;return e.parent?t?r=e.parent.worldTransform:(i=vt.get().identity(),r=Et(e,i)):r=P.IDENTITY,Tt(e,n,r,t),i&&vt.return(i),n.isValid||n.set(0,0,0,0),n}function Tt(e,t,n,r){if(!e.visible||!e.measurable)return;let i;r?i=e.worldTransform:(e.updateLocalTransform(),i=vt.get(),i.appendFrom(e.localTransform,n));let a=t,o=!!e.effects.length;if(o&&(t=yt.get().clear()),e.boundsArea)t.addRect(e.boundsArea,i);else{let n=e.bounds;n&&!n.isEmpty()&&(t.matrix=i,t.addBounds(n));for(let n=0;n<e.children.length;n++)Tt(e.children[n],t,i,r)}if(o){for(let n=0;n<e.effects.length;n++)e.effects[n].addBounds?.(t);a.addBounds(t,P.IDENTITY),yt.return(t)}r||vt.return(i)}function Et(e,t){let n=e.parent;return n&&(Et(n,t),n.updateLocalTransform(),t.append(n.localTransform)),t}var Dt=s((()=>{F(),bt()}));function Ot(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,r=e>>8&255,i=e&255,a=t>>16&255,o=t>>8&255,s=t&255,c=n*a/255|0,l=r*o/255|0,u=i*s/255|0;return(c<<16)+(l<<8)+u}var kt=s((()=>{}));function At(e,t){return e===jt?t:t===jt?e:Ot(e,t)}var jt,Mt=s((()=>{kt(),jt=16777215}));function Nt(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}var Pt,Ft=s((()=>{F(),Dt(),bt(),Mt(),Pt={getGlobalAlpha(e){if(e)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,n=this.parent;for(;n;)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new P,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();let n=Et(this,vt.get().identity());return e.appendFrom(this.localTransform,n),vt.return(n),e},getGlobalTint(e){if(e)return this.renderGroup?Nt(this.renderGroup.worldColor):this.parentRenderGroup?Nt(At(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,n=this.parent;for(;n;)t=At(t,n.localColor),n=n.parent;return Nt(t)}}}));function It(e,t,n){return t.clear(),n||=P.IDENTITY,Lt(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function Lt(e,t,n,r,i){let a;if(i)a=vt.get(),a=n.copyTo(a);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform();let t=e.localTransform;a=vt.get(),a.appendFrom(t,n)}let o=t,s=!!e.effects.length;if(s&&(t=yt.get().clear()),e.boundsArea)t.addRect(e.boundsArea,a);else{e.renderPipeId&&(t.matrix=a,t.addBounds(e.bounds));let n=e.children;for(let e=0;e<n.length;e++)Lt(n[e],t,a,r,!1)}if(s){for(let n=0;n<e.effects.length;n++)e.effects[n].addLocalBounds?.(t,r);o.addBounds(t,P.IDENTITY),yt.return(t)}vt.return(a)}var Rt=s((()=>{F(),bt()}));function zt(e,t){let n=e.children;for(let e=0;e<n.length;e++){let r=n[e],i=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==i||t.data[o+1]!==a)&&(t.data[t.index]=i,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,r.children.length&&zt(r,t)}return t.didChange}var Bt=s((()=>{})),Vt,Ht,Ut=s((()=>{F(),_t(),Dt(),Rt(),Bt(),Vt=new P,Ht={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n},getLocalBounds(){this._localBoundsCacheData||={data:[],index:1,didChange:!1,localBounds:new gt};let e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),zt(this,e),e.didChange&&It(this,e.localBounds,Vt),e.localBounds},getBounds(e,t){return wt(this,e,t||new gt)}}})),Wt,Gt=s((()=>{Wt={_onRender:null,set onRender(e){let t=this.renderGroup||this.parentRenderGroup;if(!e){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=e},get onRender(){return this._onRender}}}));function Kt(e,t){return e._zIndex-t._zIndex}var qt,Jt=s((()=>{qt={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Kt))}}})),Yt,Xt=s((()=>{je(),bt(),Yt={getGlobalPosition(e=new ke,t=!1){return this.parent?this.parent.toGlobal(this._position,e,t):(e.x=this._position.x,e.y=this._position.y),e},toGlobal(e,t,n=!1){let r=this.getGlobalTransform(vt.get(),n);return t=r.apply(e,t),vt.return(r),t},toLocal(e,t,n,r){t&&(e=t.toGlobal(e,n,r));let i=this.getGlobalTransform(vt.get(),r);return n=i.applyInverse(e,n),vt.return(i),n}}})),Zt,Qt=s((()=>{Le(),Zt=class{constructor(){this.uid=I(`instructionSet`),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,[`type`,`action`])}}}));function $t(e){return e+=+(e===0),--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function en(e){return!(e&e-1)&&!!e}var tn=s((()=>{}));function nn(e){let t={};for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return t}var rn=s((()=>{}));function an(e){let t=on[e];return t===void 0&&(on[e]=I(`resource`)),t}var on,sn,cn,ln=s((()=>{x(),Le(),z(),on=Object.create(null),sn=class e extends b{constructor(t={}){super(),this._resourceType=`textureSampler`,this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...e.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){R(L,`TextureStyle.wrapMode is now TextureStyle.addressMode`),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode=`linear`)}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit(`change`,this)}_generateResourceId(){let e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=an(e),this._resourceId}destroy(){this.destroyed=!0,this.emit(`destroy`,this),this.emit(`change`,this),this.removeAllListeners()}},sn.defaultOptions={addressMode:`clamp-to-edge`,scaleMode:`linear`},cn=sn})),un,dn,fn=s((()=>{x(),tn(),rn(),Le(),ln(),un=class e extends b{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=I(`textureSource`),this._resourceType=`textureSource`,this._resourceId=I(`resource`),this.uploadMethodId=`unknown`,this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format=`rgba8unorm`,this.dimension=`2d`,this.viewDimension=`2d`,this.arrayLayerCount=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...e.defaultOptions,...t},this.label=t.label??``,this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,this.pixelWidth=t.width?t.width*this._resolution:this.resource?this.resourceWidth??1:1,this.pixelHeight=t.height?t.height*this._resolution:this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new cn(nn(t)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._ownsStyle=!1,this._style?.off(`change`,this._onStyleChange,this),this._style=e,this._style?.on(`change`,this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit(`styleChange`,this)}update(){if(this.resource){let e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit(`update`,this)}destroy(){this.destroyed=!0,this.unload(),this.emit(`destroy`,this),this._style&&=(this._ownsStyle&&this._style.destroy(),null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=I(`resource`),this.emit(`change`,this),this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){let{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,n){n||=this._resolution,e||=this.width,t||=this.height;let r=Math.round(e*n),i=Math.round(t*n);return this.width=r/n,this.height=i/n,this._resolution=n,this.pixelWidth===r&&this.pixelHeight===i?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=i,this.emit(`resize`,this),this._resourceId=I(`resource`),this.emit(`change`,this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit(`updateMipmaps`,this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=en(this.pixelWidth)&&en(this.pixelHeight)}static test(e){throw Error(`Unimplemented`)}},un.defaultOptions={resolution:1,format:`bgra8unorm`,alphaMode:`premultiply-alpha-on-upload`,dimensions:`2d`,viewDimension:`2d`,arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1},dn=un}));function pn(){for(let e=0;e<16;e++){let t=[];vn.push(t);for(let n=0;n<16;n++){let r=bn(mn[e]*mn[n]+gn[e]*hn[n]),i=bn(hn[e]*mn[n]+_n[e]*hn[n]),a=bn(mn[e]*gn[n]+gn[e]*_n[n]),o=bn(hn[e]*gn[n]+_n[e]*_n[n]);for(let e=0;e<16;e++)if(mn[e]===r&&hn[e]===i&&gn[e]===a&&_n[e]===o){t.push(e);break}}}for(let e=0;e<16;e++){let t=new P;t.set(mn[e],hn[e],gn[e],_n[e],0,0),yn.push(t)}}var mn,hn,gn,_n,vn,yn,bn,U,xn=s((()=>{F(),mn=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],hn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],gn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],_n=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],vn=[],yn=[],bn=Math.sign,pn(),U={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:e=>mn[e],uY:e=>hn[e],vX:e=>gn[e],vY:e=>_n[e],inv:e=>e&8?e&15:-e&7,add:(e,t)=>vn[e][t],sub:(e,t)=>vn[e][U.inv(t)],rotate180:e=>e^4,isVertical:e=>(e&3)==2,byDirection:(e,t)=>Math.abs(e)*2<=Math.abs(t)?t>=0?U.S:U.N:Math.abs(t)*2<=Math.abs(e)?e>0?U.E:U.W:t>0?e>0?U.SE:U.SW:e>0?U.NE:U.NW,matrixAppendRotationInv:(e,t,n=0,r=0,i=0,a=0)=>{let o=yn[U.inv(t)],s=o.a,c=o.b,l=o.c,u=o.d,d=n-Math.min(0,s*i,l*a,s*i+l*a),f=r-Math.min(0,c*i,u*a,c*i+u*a),p=e.a,m=e.b,h=e.c,g=e.d;e.a=s*p+c*h,e.b=s*m+c*g,e.c=l*p+u*h,e.d=l*m+u*g,e.tx=d*p+f*h+e.tx,e.ty=d*m+f*g+e.ty},transformRectCoords:(e,t,n,r)=>{let{x:i,y:a,width:o,height:s}=e,{x:c,y:l,width:u,height:d}=t;return n===U.E?(r.set(i+c,a+l,o,s),r):n===U.S?r.set(u-a-s+c,i+l,s,o):n===U.W?r.set(u-i-o+c,d-a-s+l,o,s):n===U.N?r.set(a+c,d-i-o+l,s,o):r.set(i+c,a+l,o,s)}}})),Sn,Cn=s((()=>{Sn=()=>{}})),wn,Tn=s((()=>{_(),fn(),wn=class extends dn{constructor(e){let t=e.resource||new Float32Array(e.width*e.height*4),n=e.format;n||=t instanceof Float32Array?`rgba32float`:t instanceof Int32Array||t instanceof Uint32Array?`rgba32uint`:t instanceof Int16Array||t instanceof Uint16Array?`rgba16uint`:(t instanceof Int8Array,`bgra8unorm`),super({...e,resource:t,format:n}),this.uploadMethodId=`buffer`}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}},wn.extension=p.TextureSource})),En,Dn,On=s((()=>{F(),En=new P,Dn=class{constructor(e,t){this.mapCoord=new P,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,this.clampMargin=t===void 0?e.width<10?0:.5:t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture?.removeListener(`update`,this.update,this),this._texture=e,this._texture.addListener(`update`,this.update,this)),this.update()}destroy(){this._texture?.removeListener(`update`,this.update,this),this._texture=null}multiplyUvs(e,t){t===void 0&&(t=e);let n=this.mapCoord;for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];t[r]=i*n.a+a*n.c+n.tx,t[r+1]=i*n.b+a*n.d+n.ty}return t}update(){let e=this._texture;this._updateID++;let t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);let n=e.orig,r=e.trim;r&&(En.set(n.width/r.width,0,0,n.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(En));let i=e.source,a=this.uClampFrame,o=this.clampMargin/i._resolution,s=this.clampOffset/i._resolution;return a[0]=(e.frame.x+o+s)/i.width,a[1]=(e.frame.y+o+s)/i.height,a[2]=(e.frame.x+e.frame.width-o+s)/i.width,a[3]=(e.frame.y+e.frame.height-o+s)/i.height,this.uClampOffset[0]=this.clampOffset/i.pixelWidth,this.uClampOffset[1]=this.clampOffset/i.pixelHeight,this.isSimple=e.frame.width===i.width&&e.frame.height===i.height&&e.rotate===0,!0}}})),W,G=s((()=>{x(),xn(),mt(),Le(),z(),Cn(),Tn(),fn(),On(),W=class extends b{constructor({source:e,label:t,frame:n,orig:r,trim:i,defaultAnchor:a,defaultBorders:o,rotate:s,dynamic:c}={}){if(super(),this.uid=I(`texture`),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new H,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new dn,this.noFrame=!n,n)this.frame.copyFrom(n);else{let{width:e,height:t}=this._source;this.frame.width=e,this.frame.height=t}this.orig=r||this.frame,this.trim=i,this.rotate=s??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(e){this._source&&this._source.off(`resize`,this.update,this),this._source=e,e.on(`resize`,this.update,this),this.emit(`update`,this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||=new Dn(this),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:n,height:r}=this._source,i=t.x/n,a=t.y/r,o=t.width/n,s=t.height/r,c=this.rotate;if(c){let t=o/2,n=s/2,r=i+t,l=a+n;c=U.add(c,U.NW),e.x0=r+t*U.uX(c),e.y0=l+n*U.uY(c),c=U.add(c,2),e.x1=r+t*U.uX(c),e.y1=l+n*U.uY(c),c=U.add(c,2),e.x2=r+t*U.uX(c),e.y2=l+n*U.uY(c),c=U.add(c,2),e.x3=r+t*U.uX(c),e.y3=l+n*U.uY(c)}else e.x0=i,e.y0=a,e.x1=i+o,e.y1=a,e.x2=i+o,e.y2=a+s,e.x3=i,e.y3=a+s}destroy(e=!1){this._source&&(this._source.off(`resize`,this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit(`destroy`,this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit(`update`,this)}get baseTexture(){return R(L,`Texture.baseTexture is now Texture.source`),this._source}},W.EMPTY=new W({label:`EMPTY`,source:new dn({label:`EMPTY`})}),W.EMPTY.destroy=Sn,W.WHITE=new W({source:new wn({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:`premultiply-alpha-on-upload`,label:`WHITE`}),label:`WHITE`}),W.WHITE.destroy=Sn})),kn,An,jn,Mn=s((()=>{tn(),We(),fn(),G(),ln(),kn=0,An=class{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new cn(this.textureOptions)}createTexture(e,t,n,r){let i=new dn({...this.textureOptions,width:e,height:t,resolution:1,antialias:n,autoGarbageCollect:!1,autoGenerateMipmaps:r});return new W({source:i,label:`texturePool_${kn++}`})}getOptimalTexture(e,t,n=1,r,i=!1){let a=Math.ceil(e*n-1e-6),o=Math.ceil(t*n-1e-6);a=$t(a),o=$t(o);let s=+!!r,c=+!!i,l=(a<<17)+(o<<2)+(c<<1)+s;this._texturePool[l]||(this._texturePool[l]=[]);let u=this._texturePool[l].pop();return u||=this.createTexture(a,o,r,i),u.source._resolution=n,u.source.width=a/n,u.source.height=o/n,u.source.pixelWidth=a,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=e,u.frame.height=t,u.updateUvs(),this._poolKeyHash[u.uid]=l,u}getSameSizeTexture(e,t=!1){let n=e.source;return this.getOptimalTexture(e.width,e.height,n._resolution,t)}returnTexture(e,t=!1){let n=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[n].push(e)}clear(e){if(e=e!==!1,e)for(let e in this._texturePool){let t=this._texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this._texturePool={}}},jn=new An,Ue.register(jn)})),Nn,Pn=s((()=>{F(),Qt(),Mn(),Nn=class{constructor(){this.renderPipeId=`renderGroup`,this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new P,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Zt,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;let t=e.children;for(let e=0;e<t.length;e++){let n=t[e];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&=(jn.returnTexture(this.texture,!0),null)}updateCacheTexture(){this.textureNeedsUpdate=!0;let e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(let e in this.childrenToUpdate){let t=this.childrenToUpdate[e];t.list.fill(null),t.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.relativeRenderGroupDepth=e.parent===this.root?1:e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);let t=e.children;for(let e=0;e<t.length;e++)this.addChild(t[e])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let e=0;e<t.length;e++)this.removeChild(t[e])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]},t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){let t=this._onRenderContainers.indexOf(e);t!==-1&&this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(e=[]){let t=this.root.children;for(let n=0;n<t.length;n++)this._getChildren(t[n],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;let n=e.children;for(let e=0;e<n.length;e++)this._getChildren(n[e],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||=new P,this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||=new P,this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;let e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||=new P,this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}}));function Fn(e,t,n={}){for(let r in t)!n[r]&&t[r]!==void 0&&(e[r]=t[r])}var In=s((()=>{})),Ln,Rn,zn,Bn,K,Vn=s((()=>{x(),Se(),we(),_(),F(),Oe(),Fe(),Le(),z(),V(),Ye(),Ze(),tt(),rt(),ut(),ft(),Ct(),Ft(),Ut(),Gt(),Jt(),Xt(),Pn(),In(),Ln=new Pe(null),Rn=new Pe(null),zn=new Pe(null,1,1),Bn=new Pe(null),K=class e extends b{constructor(e={}){super(),this.uid=I(`renderable`),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new P,this.relativeGroupTransform=new P,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Pe(this,0,0),this._scale=zn,this._pivot=Rn,this._origin=Bn,this._skew=Ln,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode=`inherit`,this.groupBlendMode=`normal`,this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Fn(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(e=>this.addChild(e)),e.parent?.addChild(this)}static mixin(t){R(`8.8.0`,`Container.mixin is deprecated, please use extensions.mixin instead.`),g.mixin(e,t)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||R(L,`addChild: Only Containers will be allowed to add children in v8.0.0`),e.length>1){for(let t=0;t<e.length;t++)this.addChild(e[t]);return e[0]}let t=e[0],n=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),n&&(n.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,n&&n.addChild(t),this.emit(`childAdded`,t,this,this.children.length-1),t.emit(`added`,this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let t=0;t<e.length;t++)this.removeChild(e[t]);return e[0]}let t=e[0],n=this.children.indexOf(t);return n>-1&&(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit(`childRemoved`,t,this,n),t.emit(`removed`,this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Je.get(Nn,this),this.groupTransform=P.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Je.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||=new P,this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*Ee}set angle(e){this.rotation=e*De}get pivot(){return this._pivot===Rn&&(this._pivot=new Pe(this,0,0)),this._pivot}set pivot(e){this._pivot===Rn&&(this._pivot=new Pe(this,0,0),this._origin!==Bn&&B(`Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.`)),typeof e==`number`?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===Ln&&(this._skew=new Pe(this,0,0)),this._skew}set skew(e){this._skew===Ln&&(this._skew=new Pe(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===zn&&(this._scale=new Pe(this,1,1)),this._scale}set scale(e){this._scale===zn&&(this._scale=new Pe(this,0,0)),typeof e==`string`&&(e=parseFloat(e)),typeof e==`number`?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Bn&&(this._origin=new Pe(this,0,0)),this._origin}set origin(e){this._origin===Bn&&(this._origin=new Pe(this,0,0),this._pivot!==Rn&&B(`Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.`)),typeof e==`number`?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||={};let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let n=this.getLocalBounds();typeof e==`object`?(t=e.height??e.width,e=e.width):t??=e,e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x==`number`?e.x:this.position.x,typeof e.y==`number`?e.y:this.position.y),this.scale.set(typeof e.scaleX==`number`?e.scaleX:this.scale.x,typeof e.scaleY==`number`?e.scaleY:this.scale.y),this.rotation=typeof e.rotation==`number`?e.rotation:this.rotation,this.skew.set(typeof e.skewX==`number`?e.skewX:this.skew.x,typeof e.skewY==`number`?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX==`number`?e.pivotX:this.pivot.x,typeof e.pivotY==`number`?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX==`number`?e.originX:this.origin.x,typeof e.originY==`number`?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,n=this._scale,r=this._pivot,i=this._origin,a=this._position,o=n._x,s=n._y,c=r._x,l=r._y,u=-i._x,d=-i._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*s,t.d=this._sy*s,t.tx=a._x-(c*t.a+l*t.c)+(u*t.a+d*t.c)-u,t.ty=a._y-(c*t.b+l*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){let t=N.shared.setValue(e??16777215).toBgrNumber();t!==this.localColor&&(this.localColor=t,this._updateFlags|=1,this._onUpdate())}get tint(){return Nt(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate(),this.emit(`visibleChanged`,e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=+!!e;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit(`destroyed`,this),this.removeAllListeners(),(typeof e==`boolean`?e:e?.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}},g.mixin(K,et,St,Yt,Wt,Ht,lt,dt,qt,Ce,Xe,Pt,nt)})),Hn,Un=s((()=>{Hn=(e=>(e[e.INTERACTION=50]=`INTERACTION`,e[e.HIGH=25]=`HIGH`,e[e.NORMAL=0]=`NORMAL`,e[e.LOW=-25]=`LOW`,e[e.UTILITY=-50]=`UTILITY`,e))(Hn||{})})),Wn,Gn=s((()=>{Wn=class{constructor(e,t=null,n=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=r}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}}})),Kn,qn,Jn=s((()=>{Un(),Gn(),Kn=class e{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Wn(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=1/e.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,n=Hn.NORMAL){return this._addListener(new Wn(e,t,n))}addOnce(e,t,n=Hn.NORMAL){return this._addListener(new Wn(e,t,n,!0))}_addListener(e){let t=this._head.next,n=this._head;if(!t)e.connect(n);else{for(;t;){if(e.priority>t.priority){e.connect(n);break}n=t,t=t.next}e.previous||e.connect(n)}return this._startIfPossible(),this}remove(e,t){let n=this._head.next;for(;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){let e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*e.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let n=Math.min(Math.max(0,t)/1e3,e.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!e._shared){let t=e._shared=new e;t.autoStart=!0,t._protected=!0}return e._shared}static get system(){if(!e._system){let t=e._system=new e;t.autoStart=!0,t._protected=!0}return e._system}},Kn.targetFPMS=.06,qn=Kn})),Yn,Xn=s((()=>{Un(),Jn(),Yn=class{constructor(e){this._lastTransform=``,this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),t=this._canvas.width,n=this._canvas.height,r=e.width/t*this._renderer.resolution,i=e.height/n*this._renderer.resolution,a=`translate(${e.left}px, ${e.top}px) scale(${r}, ${i})`;a!==this._lastTransform&&(this._domElement.style.transform=a,this._lastTransform=a)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){`ResizeObserver`in globalThis?(this._observer&&=(this._observer.disconnect(),null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let e=this.canvas.width,n=this.canvas.height,r=t.contentRect.width/e*this._renderer.resolution,i=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||qn.shared.add(this.updateTranslation,this,Hn.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&qn.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform=``,this._lastScaleX=null,this._lastScaleY=null}}})),Zn,Qn=s((()=>{je(),Zn=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ke,this.page=new ke,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw Error(`initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}}));function $n(e){return function(t){return t.test(e)}}function er(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=$n(n),a={apple:{phone:i(tr)&&!i(lr),ipod:i(nr),tablet:!i(tr)&&(i(rr)||gr(t))&&!i(lr),universal:i(ir),device:(i(tr)||i(nr)||i(rr)||i(ir)||gr(t))&&!i(lr)},amazon:{phone:i(sr),tablet:!i(sr)&&i(cr),device:i(sr)||i(cr)},android:{phone:!i(lr)&&i(sr)||!i(lr)&&i(ar),tablet:!i(lr)&&!i(sr)&&!i(ar)&&(i(cr)||i(or)),device:!i(lr)&&(i(sr)||i(cr)||i(ar)||i(or))||i(/\bokhttp\b/i)},windows:{phone:i(lr),tablet:i(ur),device:i(lr)||i(ur)},other:{blackberry:i(dr),blackberry10:i(fr),opera:i(pr),firefox:i(hr),chrome:i(mr),device:i(dr)||i(fr)||i(pr)||i(hr)||i(mr)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r=s((()=>{tr=/iPhone/i,nr=/iPod/i,rr=/iPad/i,ir=/\biOS-universal(?:.+)Mac\b/i,ar=/\bAndroid(?:.+)Mobile\b/i,or=/Android/i,sr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,cr=/Silk/i,lr=/Windows Phone/i,ur=/\bWindows(?:.+)ARM\b/i,dr=/BlackBerry/i,fr=/BB10/i,pr=/Opera Mini/i,mr=/\b(CriOS|Chrome)(?:.+)Mobile/i,hr=/Mobile(?:.+)Firefox\b/i,gr=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`}})),vr=s((()=>{_r(),_r()})),yr,br=s((()=>{vr(),yr=(er.default??er)(globalThis.navigator)})),xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr=s((()=>{Xn(),Qn(),_(),br(),$e(),xr=9,Sr=100,Cr=0,wr=0,Tr=2,Er=1,Dr=-1e3,Or=-1e3,kr=2,Ar=class e{constructor(e,t=yr){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${Er}px`,e.style.height=`${Er}px`,e.style.position=`absolute`,e.style.top=`${Dr}px`,e.style.left=`${Or}px`,e.style.zIndex=kr.toString(),e.style.backgroundColor=`#FF0000`,e.title=`select to enable accessibility for this content`,e.addEventListener(`focus`,()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&=(document.body.removeChild(this._hookDiv),null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement(`div`),this._div.style.position=`absolute`,this._div.style.top=`${Cr}px`,this._div.style.left=`${wr}px`,this._div.style.pointerEvents=`none`,this._div.style.zIndex=Tr.toString(),this._canvasObserver=new Yn({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener(`mousemove`,this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){let n={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,n.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){let n=this._children[e];t.has(e)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Qe(this._children,e,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){let t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;let n=t._accessibleDiv,r=t.hitArea||t.getBounds().rectangle;if(t.hitArea){let e=t.worldTransform;n.style.left=`${e.tx+r.x*e.a}px`,n.style.top=`${e.ty+r.y*e.d}px`,n.style.width=`${r.width*e.a}px`,n.style.height=`${r.height*e.d}px`}else this._capHitArea(r),n.style.left=`${r.x}px`,n.style.top=`${r.y}px`,n.style.width=`${r.width}px`,n.style.height=`${r.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML=``,t.removeAttribute(`title`),t.removeAttribute(`aria-label`),t.tabIndex=0):(e.accessibleType===`button`?t=document.createElement(`button`):(t=document.createElement(e.accessibleType),t.style.cssText=`
@@ -1255,11 +1255,11 @@ fn mainFragment(
1255
1255
  `,end:`
1256
1256
  let addedAlpha = finalColor.a + vColorAdd.a;
1257
1257
  finalColor = vec4<f32>(finalColor.rgb + vColorAdd.rgb * addedAlpha, addedAlpha);
1258
- `}},bD=class extends fs{constructor(e){super({glProgram:ru({name:`color-transform-batch`,bits:[ou,vD,fu(e),xu]}),gpuProgram:nu({name:`color-transform-batch`,bits:[au,yD,uu(e),bu]}),resources:{batchSamplers:zd(e)}}),this.maxTextures=e}},xD=7,SD=class extends Ws{constructor(){let e=new Ls({data:new Float32Array(1),label:`mwg-color-transform-attribute-buffer`,usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),t=new Ls({data:new Uint32Array(1),label:`mwg-color-transform-index-buffer`,usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:e,format:`float32x2`,stride:28,offset:0},aUV:{buffer:e,format:`float32x2`,stride:28,offset:8},aColor:{buffer:e,format:`unorm8x4`,stride:28,offset:16},aTextureIdAndRound:{buffer:e,format:`uint16x2`,stride:28,offset:20},aColorAdd:{buffer:e,format:`unorm8x4`,stride:28,offset:24}},indexBuffer:t})}},CD=0,wD=e=>e.colorAdd??CD;function TD(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){e[n]=r*l+a*u+s,e[n+1]=o*u+i*l+c,e[n+2]=d,e[n+3]=f,t[n+4]=p,t[n+5]=m,t[n+6]=h}var ED=class e extends Nd{static{this.extension={type:[p.Batcher],name:`mwg-color-transform`}}constructor(t){super(t),this.geometry=new SD,this.name=e.extension.name,this.vertexSize=xD,this.shader=new bD(t.maxTextures)}packAttributes(e,t,n,r,i){let a=i<<16|e.roundPixels&65535,{a:o,b:s,c,d:l,tx:u,ty:d}=e.transform,{positions:f,uvs:p}=e,m=e.color,h=wD(e),g=e.attributeOffset,_=g+e.attributeSize;for(let e=g;e<_;e++){let i=e*2,g=f[i],_=f[i+1];t[r++]=o*g+c*_+u,t[r++]=l*_+s*g+d,t[r++]=p[i],t[r++]=p[i+1],n[r++]=m,n[r++]=a,n[r++]=h}}packQuadAttributes(e,t,n,r,i){let{a,b:o,c:s,d:c,tx:l,ty:u}=e.transform,{bounds:d}=e,f=e.texture.uvs,p=d.maxX,m=d.minX,h=d.maxY,g=d.minY,_=e.color,v=wD(e),y=i<<16|e.roundPixels&65535;TD(t,n,r,a,o,s,c,l,u,m,g,f.x0,f.y0,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,p,g,f.x1,f.y1,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,p,h,f.x2,f.y2,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,m,h,f.x3,f.y3,_,y,v)}_updateMaxTextures(e){this.shader.maxTextures!==e&&(this.shader.destroy(),this.shader=new bD(e))}destroy(){this.shader.destroy(),super.destroy()}},DD=`mwg-tinted-sprite`,OD=class{static{this.extension={type:[p.WebGLPipes,p.WebGPUPipes,p.CanvasPipes],name:DD}}constructor(e){this.renderer=e}addRenderable(e,t){let n=this.element(e);e.didViewUpdate&&this.sync(e,n),this.renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this.element(e);e.didViewUpdate&&this.sync(e,t),t._batcher.updateElement(t)}validateRenderable(e){let t=this.element(e);return!t._batcher.checkAndUpdateTexture(t,e.texture)}sync(e,t){t.bounds=e.visualBounds,t.texture=e.texture,t.colorAdd=e.colorAdd}element(e){let t=e._gpuData;return t[this.renderer.uid]??this.create(e,t)}create(e,t){let n=new kD;return n.renderable=e,n.transform=e.groupTransform,n.texture=e.texture,n.bounds=e.visualBounds,n.roundPixels=this.renderer._roundPixels|e._roundPixels,n.colorAdd=e.colorAdd,t[this.renderer.uid]=n,n}destroy(){this.renderer=null}},kD=class{constructor(){this.batcherName=ED.extension.name,this.topology=`triangle-list`,this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this.colorAdd=0,this._attributeStart=0,this._textureId=0,this._indexStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null,this.colorAdd=0}destroy(){this.reset()}},AD=!1;function jD(){AD||(AD=!0,g.add(ED),g.add(OD))}function MD(e,t,n,r=0){return(PD(r)<<24|PD(n)<<16|PD(t)<<8|PD(e))>>>0}function ND(e,t){return MD((e>>16&255)/255*t,(e>>8&255)/255*t,(e&255)/255*t)}function PD(e){return Math.max(0,Math.min(255,Math.round(e*255)))}var FD=CD,ID=class extends Ui{constructor(e){super(e),this._colorAdd=0,this.renderPipeId=DD}get colorAdd(){return this._colorAdd}set colorAdd(e){this._colorAdd!==e&&(this._colorAdd=e,this.onViewUpdate())}setColorAdd(e,t,n,r=0){this.colorAdd=MD(e,t,n,r)}lerpTint(e,t){let n=Math.round((1-t)*255);this.tint=n<<16|n<<8|n,this.colorAdd=ND(e,t)}silhouette(e){this.tint=0,this.colorAdd=ND(e,1)}resetColor(){this.tint=16777215,this.colorAdd=0}},LD=class{constructor(e,{fps:t=10,loop:n=!0}={}){if(e.length===0)throw Error(`an animation needs at least one frame`);this.frames=e,this.frameDuration=1/t,this.loop=n}get duration(){return this.frameDuration*this.frames.length}},RD=class extends ID{constructor(...e){super(...e),this.animations=new Map,this.current=null,this.currentName=null,this.frameIndex=0,this.timer=0,this.finished=!1,this.onFinish=null,this.paused=!1}add(e,t,n){return this.animations.set(e,new LD(t,n)),this}has(e){return this.animations.has(e)}get playing(){return this.currentName}get isFinished(){return this.finished}play(e,t=!1){if(!t&&this.currentName===e&&!this.finished)return this;let n=this.animations.get(e);if(!n)throw Error(`no animation named "${e}" on this sprite`);return this.current=n,this.currentName=e,this.frameIndex=0,this.timer=0,this.finished=!1,this.texture=n.frames[0],this}stop(){this.current=null,this.currentName=null}update(e){let t=this.current;if(!(!t||this.paused||this.finished)){for(this.timer+=e;this.timer>=t.frameDuration;)if(this.timer-=t.frameDuration,this.frameIndex<t.frames.length-1)this.frameIndex++;else if(t.loop)this.frameIndex=0;else{this.finished=!0,this.onFinish?.(this.currentName);break}this.texture=t.frames[this.frameIndex]}}},zD=class{constructor(e={}){if(this.entries=new Map,this.clock=0,this.budgetBytes=e.budgetBytes??1/0,!(this.budgetBytes>=0))throw Error(`asset stream budget must not be negative`);this.loadAssets=e.load??JD,this.releaseAssets=e.release??QD}async preload(e){if(!e.id)throw Error(`asset bundle needs an id`);if(e.estimatedBytes!==void 0&&e.estimatedBytes<0)throw Error(`asset bundle size must not be negative`);let t=this.entries.get(e.id);if(t?.ready){t.lastUsed=++this.clock;return}let n=e.paths.filter(e=>!this.isRetained(e));n.length>0&&await this.loadAssets([...n]),this.entries.set(e.id,{...e,lastUsed:++this.clock,ready:!0}),await this.enforceBudget(e.id)}async preloadLikely(e){for(let t of[...e].sort((e,t)=>(t.priority??0)-(e.priority??0)))await this.preload(t)}use(e){let t=this.entries.get(e);return t?.ready?(t.lastUsed=++this.clock,!0):!1}isReady(e){return this.entries.get(e)?.ready??!1}async unload(e){let t=this.entries.get(e);if(!t)return;this.entries.delete(e);let n=t.paths.filter(e=>!this.isRetained(e));n.length>0&&await this.releaseAssets(n)}get estimatedBytes(){return[...this.entries.values()].reduce((e,t)=>e+(t.estimatedBytes??0),0)}async enforceBudget(e){for(;this.estimatedBytes>this.budgetBytes;){let t=[...this.entries.values()].filter(t=>t.id!==e).sort((e,t)=>e.lastUsed-t.lastUsed)[0];if(!t)return;await this.unload(t.id)}}isRetained(e){return[...this.entries.values()].some(t=>t.ready&&t.paths.includes(e))}},BD=l({AssetStream:()=>zD,get:()=>XD,has:()=>KD,isCompiled:()=>WD,isLoaded:()=>ZD,load:()=>JD,paths:()=>GD,release:()=>QD,resolve:()=>qD,setBase:()=>HD,texture:()=>YD}),VD=``;function HD(e){VD=e.endsWith(`/`)||e===``?e:e+`/`}function UD(){return typeof window>`u`?void 0:window.__MWG_ASSETS__}function WD(){return UD()!==void 0}function GD(){return Object.keys(UD()??{})}function KD(e){let t=UD();return!t||e in t}function qD(e){let t=UD();if(!t)return VD+e;let n=t[e];if(n===void 0)throw Error(`asset "${e}" is not in this build - check it is under the folder passed to compile-resources`);return n}async function JD(e){let t=e.filter(e=>!Cw.cache.has(e));if(t.length!==0){for(let e of t)Cw.add({alias:e,src:qD(e)});await Cw.load(t)}}function YD(e){if(!Cw.cache.has(e))throw Error(`texture "${e}" has not been loaded - pass it to load() first`);return Cw.get(e)}function XD(e){if(!Cw.cache.has(e))throw Error(`asset "${e}" has not been loaded - pass it to load() first`);return Cw.get(e)}function ZD(e){return Cw.cache.has(e)}async function QD(e){let t=e.filter(e=>Cw.cache.has(e));t.length!==0&&await Cw.unload(t)}var $D=class e{constructor(e,t,n){this.frames=new Map,this.names=new Map,this.texture=e,this.frameWidth=t,this.frameHeight=n,this.columns=Math.floor(e.width/t),this.rows=Math.floor(e.height/n)}static grid(t,n,r=n){return new e(YD(t),n,r)}static fromTexture(t,n,r=n){return new e(t,n,r)}get count(){return this.columns*this.rows}name(e,t){return this.names.set(e,t),this}nameAll(e){for(let[t,n]of Object.entries(e))this.names.set(t,n);return this}indexOf(e){let t=this.names.get(e);if(t===void 0)throw Error(`this sheet has no frame named "${e}"`);return t}get(e){let t=typeof e==`string`?this.indexOf(e):e,n=this.frames.get(t);if(n)return n;if(t<0||t>=this.count)throw Error(`frame ${t} is outside this sheet, which holds ${this.count}`);let r=new W({source:this.texture.source,frame:new H(t%this.columns*this.frameWidth,Math.floor(t/this.columns)*this.frameHeight,this.frameWidth,this.frameHeight)});return this.frames.set(t,r),r}range(e,t){let n=[];for(let r=e;r<=t;r++)n.push(this.get(r));return n}pick(...e){return e.map(e=>this.get(e))}},eO=class{constructor(e={}){this.world=new K,this.x=0,this.y=0,this.viewWidth=0,this.viewHeight=0,this.screenX=0,this.screenY=0,this.followTarget=null,this.followIntensity=0,this.shakeMagnitude=0,this.shakeRemaining=0,this.shakeDuration=1,this.shakeX=0,this.shakeY=0,this.bounds=null,this.deadzone=e.deadzone??0,this.pixelPerfectTileSize=e.pixelPerfectTileSize,this._zoom=1,this.zoom=e.zoom??1}get zoom(){return this._zoom}set zoom(e){let t=Math.max(.01,e);this._zoom=this.pixelPerfectTileSize?nO(t,this.pixelPerfectTileSize):t}setViewport(e,t,n=0,r=0){this.viewWidth=e,this.viewHeight=t,this.screenX=n,this.screenY=r}get view(){let e=this.viewWidth/this._zoom,t=this.viewHeight/this._zoom,{x:n,y:r}=this.clampedCentre(this.x,this.y);return{x:n-e/2,y:r-t/2,width:e,height:t}}setBounds(e){this.bounds=e}snapTo(e,t){this.x=e,this.y=t,this.followTarget=null,this.followIntensity=0,this.apply()}panTo(e,t,n=4){this.followTarget={x:e,y:t},this.followIntensity=n}follow(e,t=8){this.followTarget=e,this.followIntensity=t}stopFollowing(){this.followTarget=null,this.followIntensity=0}shake(e,t=.4){this.shakeMagnitude=e,this.shakeRemaining=this.shakeDuration=t}update(e){if(this.followTarget&&this.followIntensity>0){let t=this.view.width*this.deadzone/2,n=this.view.height*this.deadzone/2,r=this.followTarget.x-this.x,i=this.followTarget.y-this.y;r=r>t?r-t:r<-t?r+t:0,i=i>n?i-n:i<-n?i+n:0;let a=1-Math.exp(-this.followIntensity*e);this.x+=r*a,this.y+=i*a}if(this.shakeRemaining>0){this.shakeRemaining-=e;let t=Math.max(0,this.shakeRemaining/this.shakeDuration);this.shakeX=xE(-this.shakeMagnitude,this.shakeMagnitude)*t,this.shakeY=xE(-this.shakeMagnitude,this.shakeMagnitude)*t}else this.shakeX=this.shakeY=0;this.apply()}toScreen(e,t){let{x:n,y:r}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);return{x:(e-n)*this._zoom+this.screenX+this.viewWidth/2,y:(t-r)*this._zoom+this.screenY+this.viewHeight/2}}toWorld(e,t){let{x:n,y:r}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);return{x:(e-this.screenX-this.viewWidth/2)/this._zoom+n,y:(t-this.screenY-this.viewHeight/2)/this._zoom+r}}clampedCentre(e,t){if(!this.bounds)return{x:e,y:t};let n=this.viewWidth/this._zoom/2,r=this.viewHeight/this._zoom/2,{minX:i,minY:a,maxX:o,maxY:s}=this.bounds;return{x:o-i<n*2?(i+o)/2:tO(e,i+n,o-n),y:s-a<r*2?(a+s)/2:tO(t,a+r,s-r)}}apply(){let{x:e,y:t}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);this.world.scale.set(this._zoom),this.world.x=Math.round(this.screenX+this.viewWidth/2-e*this._zoom),this.world.y=Math.round(this.screenY+this.viewHeight/2-t*this._zoom)}};function tO(e,t,n){return e<t?t:e>n?n:e}function nO(e,t){return Math.max(1,Math.round(e*t))/t}function rO(e={}){let t=new eO(e),n=oE.current;return t.setViewport(n.width,n.height),t}var iO=class{constructor(e){this.container=new K,this.clip=new px,this.camera=new eO(e),this.container.addChild(this.camera.world),this.container.addChild(this.clip),this.container.mask=this.clip,this.resize(e.x,e.y,e.width,e.height)}resize(e,t,n,r){this.camera.setViewport(n,r,e,t),this.clip.clear().rect(e,t,n,r).fill(16777215)}update(e){this.camera.update(e)}};function aO(e,t){if(e>=t){let n=Math.floor(e/2);return[{x:0,y:0,width:n,height:t},{x:n,y:0,width:e-n,height:t}]}let n=Math.floor(t/2);return[{x:0,y:0,width:e,height:n},{x:0,y:n,width:e,height:t-n}]}var oO={protanopia:[.567,.433,0,0,0,.558,.442,0,0,0,0,.242,.758,0,0,0,0,0,1,0],deuteranopia:[.625,.375,0,0,0,.7,.3,0,0,0,0,.3,.7,0,0,0,0,0,1,0],tritanopia:[.95,.05,0,0,0,0,.433,.567,0,0,0,.475,.525,0,0,0,0,0,1,0]};function sO(e){let t=new Dw;return t.matrix=oO[e],t}function cO(e,t){let n=[];for(let r of e)t.has(r)||n.push(r);return n}var lO=class extends K{constructor(e){super(),this.drawn=new Set,this.marker=new px,this.widthInCells=e.widthInCells,this.cellSize=e.cellSize??2,this.renderTexture=wf.create({width:e.widthInCells*this.cellSize,height:e.heightInCells*this.cellSize}),this.sprite=new Ui(this.renderTexture),this.addChild(this.sprite),this.addChild(this.marker)}get exploredCount(){return this.drawn.size}sync(e,t){let n=cO(e,this.drawn);if(n.length===0)return;let r=new px;for(let e of n){this.drawn.add(e);let n=e%this.widthInCells,i=Math.floor(e/this.widthInCells);r.rect(n*this.cellSize,i*this.cellSize,this.cellSize,this.cellSize).fill({color:t(n,i)})}oE.current.app.renderer.render({container:r,target:this.renderTexture,clear:!1}),r.destroy()}setMarker(e,t,n,r=16777215){if(this.marker.clear(),this.marker.circle(0,0,Math.max(1,this.cellSize)).fill({color:r}),n!==void 0){let e=this.cellSize*2;this.marker.moveTo(0,0).lineTo(Math.cos(n)*e,Math.sin(n)*e).stroke({color:r,width:1})}this.marker.x=(e+.5)*this.cellSize,this.marker.y=(t+.5)*this.cellSize}reset(){this.drawn.clear(),oE.current.app.renderer.render({container:new K,target:this.renderTexture,clear:!0})}destroy(e){this.renderTexture.destroy(!0),super.destroy(e)}},uO=-1,dO=7237230,fO=10132122;function pO(e,t){if(!Number.isInteger(e)||e<0||e>=4096)throw Error(`tileFrame needs a sheet index from 0 to 4095, got ${e}`);if(!Number.isInteger(t)||t<0||t>=1<<20)throw Error(`tileFrame needs a frame index from 0 to ${(1<<20)-1}, got ${t}`);return e<<20|t}function mO(e){return e>>>20}function hO(e){return e&(1<<20)-1}var gO=class extends K{constructor(e){if(super(),this.layers=[],this.layersByName=new Map,this.chunks=[],this.widthInTiles=e.width,this.heightInTiles=e.height,this.sheets=Array.isArray(e.sheet)?[...e.sheet]:[e.sheet],this.sheets.length===0)throw Error(`a TileMap needs at least one sheet`);if(this.tileWidth=e.tileWidth??this.sheets[0].frameWidth,this.tileHeight=e.tileHeight??this.sheets[0].frameHeight,this.shape=e.shape??`square`,this.heightStep=e.heightStep??this.tileHeight/2,!(this.heightStep>0))throw Error(`a TileMap's heightStep must be a positive number, got ${e.heightStep}`);this.chunkSize=e.chunkSize??16,this.chunkColumns=Math.ceil(this.widthInTiles/this.chunkSize),this.chunkRows=Math.ceil(this.heightInTiles/this.chunkSize);let t=this.widthInTiles*this.heightInTiles;this.cellTint=new Uint32Array(t).fill(16777215),this.cellAdd=new Uint32Array(t),this.cellHeight=new Int32Array(t),this.faces=Array(t).fill(null)}get layerCount(){return this.layers.length}get worldWidth(){switch(this.shape){case`square`:return this.widthInTiles*this.tileWidth;case`hex`:return this.widthInTiles<=0?0:(this.widthInTiles-1)*this.tileWidth*.75+this.tileWidth;case`isometric`:return(this.widthInTiles+this.heightInTiles)*(this.tileWidth/2);case`staggered`:return this.widthInTiles*this.tileWidth+this.tileWidth/2}}get worldHeight(){switch(this.shape){case`square`:return this.heightInTiles*this.tileHeight;case`hex`:return this.heightInTiles*this.tileHeight+this.tileHeight/2;case`isometric`:return(this.widthInTiles+this.heightInTiles)*(this.tileHeight/2);case`staggered`:return this.heightInTiles*(this.tileHeight/2)+this.tileHeight/2}}inside(e,t){return e>=0&&t>=0&&e<this.widthInTiles&&t<this.heightInTiles}index(e,t){return t*this.widthInTiles+e}addLayer(e,t){if(this.layersByName.has(e))throw Error(`this map already has a layer named "${e}"`);let n=this.widthInTiles*this.heightInTiles;if(t&&t.length!==n)throw Error(`layer "${e}" has ${t.length} cells, but the map has ${n}`);let r=new K,i=[];for(let e=0;e<this.chunkColumns*this.chunkRows;e++){let e=new K;i.push(e),r.addChild(e)}let a={name:e,data:t?Int32Array.from(t):new Int32Array(n).fill(-1),sprites:Array(n).fill(null),container:r};this.layers.push(a),this.layersByName.set(e,a),this.chunks.push(i),this.addChild(r);let o=this.layers.length===1;for(let e=0;e<this.heightInTiles;e++)for(let t=0;t<this.widthInTiles;t++){let n=a.data[this.index(t,e)];n!==-1&&this.buildSprite(a,t,e,n),o&&this.syncFaces(t,e)}return this}layerAt(e){let t=typeof e==`number`?this.layers[e]:this.layersByName.get(e);if(!t)throw Error(`no such layer: ${e}`);return t}chunkIndex(e,t){return Math.floor(t/this.chunkSize)*this.chunkColumns+Math.floor(e/this.chunkSize)}projectedCenter(e,t){switch(this.shape){case`square`:return{x:(e+.5)*this.tileWidth,y:(t+.5)*this.tileHeight};case`hex`:return fD(e,t,this.tileWidth,this.tileHeight);case`isometric`:return{x:(e-t+(this.heightInTiles-1))*(this.tileWidth/2)+this.tileWidth/2,y:(e+t)*(this.tileHeight/2)+this.tileHeight/2};case`staggered`:return{x:e*this.tileWidth+(t&1)*(this.tileWidth/2)+this.tileWidth/2,y:t*(this.tileHeight/2)+this.tileHeight/2}}}projectedTile(e,t){switch(this.shape){case`square`:return{x:Math.floor(e/this.tileWidth),y:Math.floor(t/this.tileHeight)};case`hex`:return pD(e,t,this.tileWidth,this.tileHeight);case`isometric`:{let n=(e-this.tileWidth/2)/(this.tileWidth/2)-(this.heightInTiles-1),r=(t-this.tileHeight/2)/(this.tileHeight/2);return{x:Math.round((n+r)/2),y:Math.round((r-n)/2)}}case`staggered`:{let n=Math.round((t-this.tileHeight/2)/(this.tileHeight/2));return{x:Math.round((e-this.tileWidth/2-(n&1)*(this.tileWidth/2))/this.tileWidth),y:n}}}}cellOrigin(e,t){let n=this.projectedCenter(e,t);return{x:n.x-this.tileWidth/2,y:n.y-this.tileHeight/2}}textureFor(e){let t=mO(e);if(t>=this.sheets.length)throw Error(`frame ${e} names sheet ${t}, but this map has ${this.sheets.length}`);return this.sheets[t].get(hO(e))}buildSprite(e,t,n,r){let i=new ID(this.textureFor(r)),a=this.cellOrigin(t,n);i.x=a.x,i.y=a.y-this.cellHeight[this.index(t,n)]*this.heightStep;let o=this.index(t,n);return i.tint=this.cellTint[o],i.colorAdd=this.cellAdd[o],e.sprites[o]=i,this.chunks[this.layers.indexOf(e)][this.chunkIndex(t,n)].addChild(i),i}getTile(e,t,n){return this.inside(t,n)?this.layerAt(e).data[this.index(t,n)]:-1}setTile(e,t,n,r){if(!this.inside(t,n))return;let i=this.layerAt(e),a=this.index(t,n);if(i.data[a]===r)return;i.data[a]=r;let o=i.sprites[a];r===-1?(o?.destroy(),i.sprites[a]=null):o?o.texture=this.textureFor(r):this.buildSprite(i,t,n,r),this.layers[0]===i&&this.syncFaces(t,n)}setLayerData(e,t){this.layerAt(e);for(let n=0;n<this.heightInTiles;n++)for(let r=0;r<this.widthInTiles;r++)this.setTile(e,r,n,t[this.index(r,n)]??-1)}setCellColor(e,t,n,r=0){if(!this.inside(e,t))return;let i=this.index(e,t);if(this.cellTint[i]===n&&this.cellAdd[i]===r)return;this.cellTint[i]=n,this.cellAdd[i]=r;for(let e of this.layers){let t=e.sprites[i];t&&(t.tint=n,t.colorAdd=r)}let a=this.faces[i];a&&(a.tint=n)}getCellTint(e,t){return this.inside(e,t)?this.cellTint[this.index(e,t)]:0}clearColors(){for(let e=0;e<this.heightInTiles;e++)for(let t=0;t<this.widthInTiles;t++)this.setCellColor(t,e,16777215,0)}setCellHeight(e,t,n){if(!this.inside(e,t))return;if(!Number.isInteger(n))throw Error(`a cell's height must be a whole number, got ${n}`);let r=this.index(e,t);if(this.cellHeight[r]===n)return;this.cellHeight[r]=n;let i=n*this.heightStep;for(let n of this.layers){let a=n.sprites[r];a&&(a.y=this.cellOrigin(e,t).y-i)}this.syncFaces(e,t)}getCellHeight(e,t){return this.inside(e,t)?this.cellHeight[this.index(e,t)]:0}get faceCount(){return this.faces.filter(e=>e!==null).length}syncFaces(e,t){if(this.layers.length===0)return;let n=this.index(e,t),r=(this.shape===`isometric`||this.shape===`staggered`)&&this.cellHeight[n]>0&&this.layers[0].data[n]!==-1,i=this.faces[n];if(!r){i&&(i.destroy(),this.faces[n]=null);return}let a=i??new px;if(this.drawFaces(a,e,t),a.tint=this.cellTint[n],!i){this.faces[n]=a;let r=this.chunks[0][this.chunkIndex(e,t)],i=this.layers[0].sprites[n];i?r.addChildAt(a,r.getChildIndex(i)):r.addChild(a)}}drawFaces(e,t,n){let r=this.cellOrigin(t,n),i=r.x,a=r.y,o=this.tileWidth/2,s=this.tileHeight/2,c=this.heightStep,l=this.cellHeight[this.index(t,n)];e.clear();for(let t=1;t<=l;t++){let n=t*c,r=(t-1)*c;e.poly([i,a+s-n,i+o,a+s*2-n,i+o,a+s*2-r,i,a+s-r]).fill(dO),e.poly([i+o,a+s*2-n,i+o*2,a+s-n,i+o*2,a+s-r,i+o,a+s*2-r]).fill(fO)}}toTile(e,t){return this.projectedTile(e,t)}tileCenter(e,t){let n=this.projectedCenter(e,t);return n.y-=this.getCellHeight(e,t)*this.heightStep,n}cull(e){let t=e.view,n=this.projectedTile(t.x,t.y),r=this.projectedTile(t.x+t.width,t.y),i=this.projectedTile(t.x,t.y+t.height),a=this.projectedTile(t.x+t.width,t.y+t.height),o=Math.min(n.x,r.x,i.x,a.x),s=Math.max(n.x,r.x,i.x,a.x),c=Math.min(n.y,r.y,i.y,a.y),l=Math.max(n.y,r.y,i.y,a.y),u=Math.floor(o/this.chunkSize)-1,d=Math.floor(s/this.chunkSize)+1,f=Math.floor(c/this.chunkSize)-1,p=Math.floor(l/this.chunkSize)+1;for(let e=0;e<this.chunkRows;e++){let t=e>=f&&e<=p;for(let n=0;n<this.chunkColumns;n++){let r=t&&n>=u&&n<=d,i=e*this.chunkColumns+n;for(let e of this.chunks)e[i].renderable=r}}}get visibleChunks(){return this.chunks.length===0?0:this.chunks[0].filter(e=>e.renderable).length}},_O=class extends K{constructor(...e){super(...e),this.layers=new Map}addLayer(e,t,n=0){this.removeLayer(e);let r=new ID(t);return this.layers.set(e,{sprite:r,order:n}),this.addChild(r),this.resort(),r}removeLayer(e){let t=this.layers.get(e);t&&(this.layers.delete(e),t.sprite.destroy())}layer(e){return this.layers.get(e)?.sprite}hasLayer(e){return this.layers.has(e)}setTexture(e,t){let n=this.layers.get(e);n&&(n.sprite.texture=t)}resort(){[...this.layers.values()].sort((e,t)=>e.order-t.order).forEach((e,t)=>this.setChildIndex(e.sprite,t))}},vO=class{constructor(e,t,n,r={}){this.elapsed=0,this.arrived=!1,this.sprite=e,this.fromX=t.x,this.fromY=t.y,this.toX=n.x,this.toY=n.y;let i=Math.hypot(n.x-t.x,n.y-t.y);this.duration=r.duration??i/(r.speed??400),this.duration<=0&&(this.duration=1e-6),e.x=t.x,e.y=t.y}get done(){return this.arrived}get progress(){return Math.min(1,this.elapsed/this.duration)}update(e){if(this.arrived)return!1;this.elapsed+=e;let t=this.progress;return this.sprite.x=this.fromX+(this.toX-this.fromX)*t,this.sprite.y=this.fromY+(this.toY-this.fromY)*t,t>=1&&(this.arrived=!0,!0)}},yO=class{constructor(e,t){this.idleOrMove=`idle`,this.inAction=!1,this.sprite=e,this.animationName=t.animationName,this.variant=t.variant??``,this.sprite.onFinish=()=>this.onSpriteFinish(),this.apply(this.idleOrMove)}get state(){return this.inAction?`action`:this.idleOrMove}get variantName(){return this.variant}setMoving(e,t){t!==void 0&&(this.variant=t),this.idleOrMove=e?`move`:`idle`,this.inAction||this.apply(this.idleOrMove)}playAction(e,t=!1){this.inAction&&!t||(e!==void 0&&(this.variant=e),this.inAction=!0,this.apply(`action`))}onSpriteFinish(){this.inAction&&(this.inAction=!1,this.apply(this.idleOrMove))}apply(e){let t=this.animationName(e,this.variant);this.sprite.has(t)&&this.sprite.play(t,e===`action`)}},bO=CO(),xO=new Map(bO.map((e,t)=>[SO(e),t]));function SO(e){let t=e.ne&&e.n&&e.e,n=e.se&&e.s&&e.e,r=e.sw&&e.s&&e.w,i=e.nw&&e.n&&e.w;return+!!e.n|(e.e?2:0)|(e.s?4:0)|(e.w?8:0)|(t?16:0)|(n?32:0)|(r?64:0)|(i?128:0)}function CO(){let e=new Set,t=[];for(let n=0;n<256;n++){let r={n:!!(n&1),e:!!(n&2),s:!!(n&4),w:!!(n&8),ne:!!(n&16),se:!!(n&32),sw:!!(n&64),nw:!!(n&128)},i=SO(r);e.has(i)||(e.add(i),t.push({mask:i,shape:{n:r.n,e:r.e,s:r.s,w:r.w,ne:r.ne&&r.n&&r.e,se:r.se&&r.s&&r.e,sw:r.sw&&r.s&&r.w,nw:r.nw&&r.n&&r.w}}))}return t.sort((e,t)=>e.mask-t.mask),t.map(e=>e.shape)}function wO(e){return xO.get(SO(e))}function TO(e,t,n,r){if(r.length!==bO.length)throw Error(`autotileFrames needs exactly ${bO.length} frames, got ${r.length}`);let i=new Int32Array(e*t);for(let a=0;a<t;a++)for(let t=0;t<e;t++){let o=a*e+t;if(!n(t,a)){i[o]=-1;continue}i[o]=r[wO({n:n(t,a-1),e:n(t+1,a),s:n(t,a+1),w:n(t-1,a),ne:n(t+1,a-1),se:n(t+1,a+1),sw:n(t-1,a+1),nw:n(t-1,a-1)})]}return i}var EO=[{workload:`sprites`,preferred:`PixiJS WebGL/WebGPU batcher`,fallback:`PixiJS WebGL`,reason:`high-volume textured 2D batches`},{workload:`ui`,preferred:`PixiJS display tree`,fallback:`PixiJS display tree`,reason:`themeable 2D layout and text`},{workload:`custom-shaders`,preferred:`backend-specific GLSL/WGSL only when profiled`,fallback:`PixiJS filters`,reason:`avoid maintaining paired shader sources without a measured gain`},{workload:`particles`,preferred:`PixiJS for 2D, Babylon.js for 3D`,fallback:`instanced sprites/meshes`,reason:`match simulation and depth to the scene`},{workload:`instanced-terrain`,preferred:`Babylon.js thin instances`,fallback:`PixiJS TileMap for 2D`,reason:`depth-tested repeated 3D geometry`},{workload:`voxels`,preferred:`Babylon.js thin instances`,fallback:`batched meshes`,reason:`color-grouped 3D voxels`},{workload:`animated-models`,preferred:`Babylon.js glTF animation groups`,fallback:`billboard sprites`,reason:`standard 3D interchange and animation support`},{workload:`large-3d-worlds`,preferred:`Babylon.js with streaming/culling`,fallback:`partitioned scenes`,reason:`scene graph, depth, and instancing`}];function DO(e={}){let t=e.createCanvas?.()??(typeof document>`u`?null:document.createElement(`canvas`)),n=!!t?.getContext(`webgl2`);return{webgl1:n||!!(t?.getContext(`webgl`)??t?.getContext(`experimental-webgl`)),webgl2:n,webgpu:e.webgpu??!!globalThis.navigator?.gpu,wgsl:e.wgsl??!1}}async function OO(){let e=globalThis.navigator?.gpu;if(!e)return{webgpu:!1,wgsl:!1};try{let t=await(await e.requestAdapter())?.requestDevice();return t?{webgpu:!0,wgsl:(await t.createShaderModule({code:`@compute @workgroup_size(1) fn main() {}`}).getCompilationInfo()).messages.length===0}:{webgpu:!1,wgsl:!1}}catch{return{webgpu:!1,wgsl:!1}}}var kO={panelBorder:4,padding:8,spacing:2,direction:`ltr`,font:{family:`ui-monospace, Consolas, "DejaVu Sans Mono", monospace`,size:12,lineHeight:1.4},color:{text:15263984,textDim:9079446,textHighlight:16770688,panelFill:1842214,panelBorder:4868702,selection:3820154,overlay:0},overlayAlpha:.5},AO={panelBorder:6,padding:10,spacing:4,direction:`ltr`,font:{family:kO.font.family,size:14,lineHeight:1.5},color:{text:16777215,textDim:13421772,textHighlight:16776960,panelFill:0,panelBorder:16777215,selection:16776960,overlay:0},overlayAlpha:.85},jO=kO;function MO(){return jO}var NO=new vT;function PO(e){jO={...kO,...e,font:{...kO.font,...e.font},color:{...kO.color,...e.color}},NO.dispatch(jO)}var FO=class extends Jw{constructor(e={}){let t=typeof e==`string`?{text:e}:e,n=MO();super({text:t.text??``,style:new KS({fontFamily:n.font.family,fontSize:t.size??n.font.size,fontWeight:t.bold?`bold`:`normal`,fill:t.color??n.color.text,lineHeight:(t.size??n.font.size)*n.font.lineHeight,align:t.align??(n.direction===`rtl`?`right`:`left`),wordWrap:t.wrapWidth!==void 0,wordWrapWidth:t.wrapWidth??0,breakWords:!0})}),this.themeListener=e=>this.restyle(e),this.opts=t,NO.add(this.themeListener)}setColor(e){this.style.fill=e}setText(e){this.text!==e&&(this.text=e)}restyle(e){this.style.fontFamily=e.font.family,this.opts.color===void 0&&(this.style.fill=e.color.text),this.opts.size===void 0&&(this.style.fontSize=e.font.size,this.style.lineHeight=e.font.size*e.font.lineHeight),this.opts.align===void 0&&(this.style.align=e.direction===`rtl`?`right`:`left`)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},IO=class extends sT{constructor(e={}){let t=typeof e==`string`?{text:e}:e,n=MO();super({text:t.text??``,style:LO(t,n)}),this.themeListener=e=>this.restyle(e),this.opts=t,NO.add(this.themeListener)}setText(e){this.text!==e&&(this.text=e)}restyle(e){this.style=LO(this.opts,e)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}};function LO(e,t){return{fontFamily:t.font.family,fontSize:e.size??t.font.size,fontWeight:e.bold?`bold`:`normal`,fill:e.color??t.color.text,align:e.align??(t.direction===`rtl`?`right`:`left`),wordWrap:e.wrapWidth!==void 0,wordWrapWidth:e.wrapWidth??0,breakWords:!0}}var RO=class extends K{constructor(e,t){super();let n=typeof t.border==`number`?{left:t.border,top:t.border,right:t.border,bottom:t.border}:t.border;this.sprite=new gT({texture:e,leftWidth:n.left,topHeight:n.top,rightWidth:n.right,bottomHeight:n.bottom}),this.addChild(this.sprite)}get border(){return{left:this.sprite.leftWidth,top:this.sprite.topHeight,right:this.sprite.rightWidth,bottom:this.sprite.bottomHeight}}resize(e,t){let n=this.border;this.sprite.width=Math.max(e,n.left+n.right),this.sprite.height=Math.max(t,n.top+n.bottom)}},zO=class extends K{constructor(e){super(),this.content=new K,this.onClose=new vT,this.titleLabel=null,this.innerWidth=0,this.innerHeight=0,this.currentWidth=0,this.currentHeight=0,this.themeListener=()=>this.restyle(),this.delegate=null;let t=MO();this.modal=e.modal??!0,this.closable=e.closable??!0,this.dims=e.dims??this.modal,this.anchor=e.anchor??`center`,this.background=t.panel?new RO(t.panel,{border:t.panelBorder}):new px,this.addChild(this.background),e.title!==void 0&&(this.titleLabel=new FO({text:e.title,color:t.color.textHighlight,bold:!0}),this.addChild(this.titleLabel)),this.addChild(this.content),this.resize(e.width,e.height),NO.add(this.themeListener)}restyle(){this.titleLabel?.setColor(MO().color.textHighlight),this.resize(this.currentWidth,this.currentHeight)}resize(e,t){this.currentWidth=e,this.currentHeight=t;let n=MO(),r=(this.background instanceof RO?this.background.border.left:2)+n.padding;this.background instanceof RO?this.background.resize(e,t):this.background.clear().roundRect(0,0,e,t,4).fill({color:n.color.panelFill}).stroke({color:n.color.panelBorder,width:1});let i=r;this.titleLabel&&(this.titleLabel.x=n.direction===`rtl`?e-r-this.titleLabel.width:r,this.titleLabel.y=r,i=r+this.titleLabel.height+n.padding),this.content.x=r,this.content.y=i,this.innerWidth=Math.max(0,e-r*2),this.innerHeight=Math.max(0,t-i-r)}get contentWidth(){return this.innerWidth}get contentHeight(){return this.innerHeight}setTitle(e){this.titleLabel?.setText(e)}handleAction(e){return this.delegate?.handleAction(e)?!0:e===`cancel`&&this.closable?(this.close(),!0):!1}update(e){}close(){this.onClose.dispatch(),this.parent?.removeChild(this),this.destroy({children:!0})}place(e,t){let n=this.getLocalBounds(),r=MO().padding*2;this.x=Math.round((e-n.width)/2),this.y=this.anchor===`bottom`?Math.round(t-n.height-r):this.anchor===`top`?r:Math.round((t-n.height)/2)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},BO=class extends K{constructor(){super(),this.windows=[],this.overlay=new px,this.viewportWidth=0,this.viewportHeight=0,this.listener=e=>this.handleAction(e),this.themeListener=()=>this.drawOverlay(),this.overlay.visible=!1,this.addChild(this.overlay),wT.add(this.listener),NO.add(this.themeListener)}setViewport(e,t){this.viewportWidth=e,this.viewportHeight=t,this.drawOverlay();for(let n of this.windows)n.place(e,t)}get top(){return this.windows[this.windows.length-1]??null}get isEmpty(){return this.windows.length===0}get depth(){return this.windows.length}push(e){return this.windows.push(e),this.addChild(e),e.onClose.add(()=>(this.forget(e),!1)),e.place(this.viewportWidth,this.viewportHeight),this.updateOverlay(),e}pop(){this.top?.close()}closeAll(){for(let e of[...this.windows].reverse())e.close()}forget(e){let t=this.windows.indexOf(e);t!==-1&&this.windows.splice(t,1),this.updateOverlay()}updateOverlay(){let e=this.windows.findIndex(e=>e.dims);if(e===-1){this.overlay.visible=!1;return}this.overlay.visible=!0,this.setChildIndex(this.overlay,Math.max(0,this.getChildIndex(this.windows[e])-1))}drawOverlay(){let e=MO();this.overlay.clear().rect(0,0,this.viewportWidth,this.viewportHeight).fill({color:e.color.overlay,alpha:e.overlayAlpha})}handleAction(e){return this.top?.handleAction(e)??!1}get blocksWorld(){return this.windows.some(e=>e.modal)}update(e){this.top?.update(e)}destroy(e){wT.remove(this.listener),NO.remove(this.themeListener),super.destroy(e)}},VO=class extends K{constructor(e){super(),this.items=[],this.rows=[],this.rowsLayer=new K,this.highlight=new px,this.mask_=new px,this.index=0,this.scroll=0,this.themeListener=()=>this.restyle();let t=MO();this.viewWidth=e.width,this.viewHeight=e.height,this.explicitRowHeight=e.rowHeight!==void 0,this.rowHeight=e.rowHeight??Math.ceil(t.font.size*t.font.lineHeight)+t.spacing,this.onSelect=e.onSelect??null,this.onHighlight=e.onHighlight??null,this.addChild(this.highlight),this.addChild(this.rowsLayer),this.addChild(this.mask_),this.rowsLayer.mask=this.mask_,this.drawMask(),this.eventMode=`static`,this.on(`wheel`,e=>this.move(e.deltaY>0?1:-1)),this.setItems(e.items??[]),NO.add(this.themeListener)}restyle(){let e=MO();this.explicitRowHeight||(this.rowHeight=Math.ceil(e.font.size*e.font.lineHeight)+e.spacing);let t=e.direction===`rtl`;this.rows.forEach((n,r)=>{n.y=r*this.rowHeight;let i=this.items[r],a=n.children.find(e=>e instanceof FO);if(a){a.setColor(i.disabled?e.color.textDim:e.color.text);let n=e.spacing+(i.icon?this.rowHeight:0);a.x=t?this.viewWidth-n-a.width:n,a.y=Math.round((this.rowHeight-a.height)/2)}i.icon&&(i.icon.x=t?this.viewWidth-e.spacing-this.rowHeight:e.spacing)}),this.refresh()}destroy(e){NO.remove(this.themeListener),super.destroy(e)}drawMask(){this.mask_.clear().rect(0,0,this.viewWidth,this.viewHeight).fill({color:16777215})}get visibleRows(){return Math.max(1,Math.floor(this.viewHeight/this.rowHeight))}get selectedIndex(){return this.index}get selected(){return this.items[this.index]??null}get length(){return this.items.length}setItems(e){this.items=e;for(let e of this.rows)e.destroy({children:!0});this.rows=[],this.rowsLayer.removeChildren();let t=MO(),n=t.direction===`rtl`;e.forEach((e,r)=>{let i=new K;i.y=r*this.rowHeight,i.eventMode=`static`,i.cursor=e.disabled?`default`:`pointer`,i.on(`pointerdown`,()=>{e.disabled||(this.select(r),this.confirm())}),e.icon&&(e.icon.x=n?this.viewWidth-t.spacing-this.rowHeight:t.spacing,i.addChild(e.icon));let a=new FO({text:e.text,color:e.disabled?t.color.textDim:t.color.text}),o=t.spacing+(e.icon?this.rowHeight:0);a.x=n?this.viewWidth-o-a.width:o,a.y=Math.round((this.rowHeight-a.height)/2),i.addChild(a),this.rows.push(i),this.rowsLayer.addChild(i)}),this.index=this.items.findIndex(e=>!e.disabled),this.index===-1&&(this.index=0),this.scroll=0,this.refresh()}resize(e,t){this.viewWidth=e,this.viewHeight=t,this.drawMask(),this.refresh()}move(e){if(this.items.length===0)return!1;let t=this.index;for(let n=0;n<this.items.length;n++)if(t=(t+e+this.items.length)%this.items.length,!this.items[t].disabled)return this.index=t,this.refresh(),this.onHighlight?.(this.items[t],t),!0;return!1}select(e){e<0||e>=this.items.length||this.items[e].disabled||(this.index=e,this.refresh(),this.onHighlight?.(this.items[e],e))}confirm(){let e=this.selected;return!e||e.disabled?!1:(this.onSelect?.(e,this.index),!0)}handleAction(e){switch(e){case`up`:return this.move(-1);case`down`:return this.move(1);case`confirm`:return this.confirm();default:return!1}}refresh(){let e=this.visibleRows;this.index<this.scroll?this.scroll=this.index:this.index>=this.scroll+e&&(this.scroll=this.index-e+1),this.scroll=Math.max(0,Math.min(this.scroll,Math.max(0,this.items.length-e))),this.rowsLayer.y=-this.scroll*this.rowHeight;let t=MO();if(this.items.length===0){this.highlight.clear();return}this.highlight.clear().rect(0,(this.index-this.scroll)*this.rowHeight,this.viewWidth,this.rowHeight).fill({color:t.color.selection})}},HO=class extends K{constructor(e){super(),this.items=[],this.cells=[],this.cellsLayer=new K,this.highlight=new px,this.pickupHighlight=new px,this.mask_=new px,this.index=0,this.scrollRow=0,this.pickedUp=null,this.pressedIndex=null,this.pressTimer=0,this.themeListener=()=>{let e=MO();this.items.forEach((t,n)=>{(t.quantity??1)<=1||(this.cells[n]?.children.find(e=>e instanceof FO))?.setColor(e.color.textHighlight)}),this.refresh()},this.viewWidth=e.width,this.viewHeight=e.height,this.columns=Math.max(1,e.columns),this.cellSize=e.cellSize??Math.floor(this.viewWidth/this.columns),this.longPressDuration=e.longPressDuration??.6,this.onSelect=e.onSelect??null,this.onHighlight=e.onHighlight??null,this.onQuickslot=e.onQuickslot??null,this.onReorder=e.onReorder??null,this.addChild(this.highlight),this.addChild(this.pickupHighlight),this.addChild(this.cellsLayer),this.addChild(this.mask_),this.cellsLayer.mask=this.mask_,this.drawMask(),this.eventMode=`static`,this.on(`wheel`,e=>this.move(0,e.deltaY>0?1:-1)),this.setItems(e.items??[]),NO.add(this.themeListener)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}drawMask(){this.mask_.clear().rect(0,0,this.viewWidth,this.viewHeight).fill({color:16777215})}get visibleRows(){return Math.max(1,Math.floor(this.viewHeight/this.cellSize))}get rows(){return Math.max(1,Math.ceil(this.items.length/this.columns))}get selectedIndex(){return this.index}get selected(){return this.items[this.index]??null}get length(){return this.items.length}setItems(e){this.items=e,this.pickedUp=null,this.pressedIndex=null;for(let e of this.cells)e.destroy({children:!0});this.cells=[],this.cellsLayer.removeChildren();let t=MO();e.forEach((e,n)=>{let r=Math.floor(n/this.columns),i=n%this.columns,a=new K;if(a.x=i*this.cellSize,a.y=r*this.cellSize,a.eventMode=`static`,a.cursor=e.disabled?`default`:`pointer`,e.icon.x=Math.round((this.cellSize-e.icon.width)/2),e.icon.y=Math.round((this.cellSize-e.icon.height)/2),e.disabled&&(e.icon.alpha=.4),a.addChild(e.icon),(e.quantity??1)>1){let n=new FO({text:String(e.quantity),size:10,color:t.color.textHighlight});n.x=this.cellSize-n.width-2,n.y=this.cellSize-n.height-1,a.addChild(n)}a.on(`pointerdown`,()=>{this.pressedIndex=n,this.pressTimer=0}),a.on(`pointerup`,()=>this.releaseCell(n)),a.on(`pointerupoutside`,()=>this.releaseCell(n)),this.cells.push(a),this.cellsLayer.addChild(a)}),this.index=this.items.findIndex(e=>!e.disabled),this.index===-1&&(this.index=0),this.scrollRow=0,this.refresh()}releaseCell(e){this.pressedIndex===e&&(this.pressedIndex=null,this.items[e]?.disabled||this.tapCell(e))}resize(e,t){this.viewWidth=e,this.viewHeight=t,this.drawMask(),this.refresh()}update(e){if(this.pressedIndex===null||(this.pressTimer+=e,this.pressTimer<this.longPressDuration))return;let t=this.pressedIndex;this.pressedIndex=null;let n=this.items[t];n&&!n.disabled&&this.onQuickslot?.(n,t)}tapCell(e){if(e<0||e>=this.items.length)return;if(this.pickedUp===null){if(this.items[e].disabled)return;this.pickedUp=e,this.refresh();return}let t=this.pickedUp;this.pickedUp=null,t!==e&&(this.swapCells(t,e),this.onReorder?.(t,e)),this.refresh()}swapCells(e,t){[this.items[e],this.items[t]]=[this.items[t],this.items[e]];let n=this.cells[e],r=this.cells[t],i=n.removeChildren(),a=r.removeChildren();for(let e of a)n.addChild(e);for(let e of i)r.addChild(e);n.cursor=this.items[e].disabled?`default`:`pointer`,r.cursor=this.items[t].disabled?`default`:`pointer`}cancelPickup(){this.pickedUp=null,this.refresh()}move(e,t){if(this.items.length===0)return!1;let n=this.items.length,r=this.rows,i=Math.floor(this.index/this.columns),a=this.index%this.columns;for(let o=0;o<r*this.columns;o++){a=(a+e+this.columns)%this.columns,i=(i+t+r)%r;let o=i*this.columns+a;if(o<n&&!this.items[o].disabled)return this.index=o,this.refresh(),this.onHighlight?.(this.items[o],o),!0}return!1}select(e){e<0||e>=this.items.length||this.items[e].disabled||(this.index=e,this.refresh(),this.onHighlight?.(this.items[e],e))}confirm(){let e=this.selected;return!e||e.disabled?!1:(this.onSelect?.(e,this.index),!0)}handleAction(e){switch(e){case`up`:return this.move(0,-1);case`down`:return this.move(0,1);case`left`:return this.move(-1,0);case`right`:return this.move(1,0);case`confirm`:return this.confirm();case`cancel`:return this.pickedUp!==null&&(this.cancelPickup(),!0);default:return!1}}cellRect(e){return{x:e%this.columns*this.cellSize,y:Math.floor(e/this.columns)*this.cellSize}}refresh(){let e=this.visibleRows,t=Math.floor(this.index/this.columns);t<this.scrollRow?this.scrollRow=t:t>=this.scrollRow+e&&(this.scrollRow=t-e+1),this.scrollRow=Math.max(0,Math.min(this.scrollRow,Math.max(0,this.rows-e))),this.cellsLayer.y=-this.scrollRow*this.cellSize;let n=MO();if(this.pickupHighlight.clear(),this.pickedUp!==null){let{x:e,y:t}=this.cellRect(this.pickedUp);this.pickupHighlight.rect(e,t,this.cellSize,this.cellSize).stroke({color:n.color.textHighlight,width:2})}if(this.highlight.clear(),this.items.length>0){let{x:e,y:t}=this.cellRect(this.index);this.highlight.rect(e,t,this.cellSize,this.cellSize).fill({color:n.color.selection})}}},UO=class extends zO{constructor(e){super({width:e.width,height:e.height,modal:!0,closable:!1,dims:e.dims,anchor:e.anchor??`bottom`}),this.pageIndex=0,this.revealed=0,this.portrait=null,this.portraitLayer=new K,this.choiceList=null,this.finished=!1,this.autoAdvanceElapsed=0,this.messageThemeListener=()=>this.restyleMessage(),this.pages=e.pages.map(e=>typeof e==`string`?{text:e}:e),this.speed=e.speed??40,this.mode=e.mode??`adv`,this.autoAdvance=e.autoAdvance,this.choices=e.choices??[],this.onDone=e.onDone??null;let t=MO();this.content.addChild(this.portraitLayer),this.speakerLabel=new FO({color:t.color.textHighlight,bold:!0}),this.content.addChild(this.speakerLabel),this.body=new FO({wrapWidth:this.contentWidth}),this.content.addChild(this.body),this.prompt=new FO({text:`▼`,color:t.color.textDim}),this.prompt.visible=!1,this.content.addChild(this.prompt),this.showPage(0),NO.add(this.messageThemeListener)}restyleMessage(){let e=MO();this.speakerLabel.setColor(e.color.textHighlight),this.prompt.setColor(e.color.textDim)}destroy(e){NO.remove(this.messageThemeListener),super.destroy(e)}showPage(e){let t=this.pages[e],n=MO(),r=n.direction===`rtl`;this.portraitLayer.removeChildren(),this.portrait=null;let i=0,a=this.contentWidth;t.portrait&&(this.portrait=new Ui(t.portrait),r&&(this.portrait.x=this.contentWidth-this.portrait.width),this.portraitLayer.addChild(this.portrait),a=this.contentWidth-this.portrait.width-n.padding,i=r?0:this.portrait.width+n.padding),this.speakerLabel.visible=this.mode===`adv`&&t.speaker!==void 0,this.speakerLabel.x=i,this.speakerLabel.setText(t.speaker??``),this.body.x=i,this.body.y=this.mode===`adv`&&t.speaker!==void 0?this.speakerLabel.height+n.spacing:0,this.body.style.wordWrapWidth=Math.max(16,a),this.revealed=this.speed>0?0:t.text.length,this.autoAdvanceElapsed=0,this.renderBody(),this.prompt.visible=!1,this.prompt.x=r?0:this.contentWidth-this.prompt.width,this.prompt.y=this.contentHeight-this.prompt.height}renderBody(){if(this.mode===`adv`){this.body.setText(this.pages[this.pageIndex].text.slice(0,Math.floor(this.revealed)));return}let e=this.pages.slice(0,this.pageIndex).map(e=>this.formatLine(e,e.text)),t=this.pages[this.pageIndex];e.push(this.formatLine(t,t.text.slice(0,Math.floor(this.revealed)))),this.body.setText(e.join(`
1258
+ `}},bD=class extends fs{constructor(e){super({glProgram:ru({name:`color-transform-batch`,bits:[ou,vD,fu(e),xu]}),gpuProgram:nu({name:`color-transform-batch`,bits:[au,yD,uu(e),bu]}),resources:{batchSamplers:zd(e)}}),this.maxTextures=e}},xD=7,SD=class extends Ws{constructor(){let e=new Ls({data:new Float32Array(1),label:`mwg-color-transform-attribute-buffer`,usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),t=new Ls({data:new Uint32Array(1),label:`mwg-color-transform-index-buffer`,usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:e,format:`float32x2`,stride:28,offset:0},aUV:{buffer:e,format:`float32x2`,stride:28,offset:8},aColor:{buffer:e,format:`unorm8x4`,stride:28,offset:16},aTextureIdAndRound:{buffer:e,format:`uint16x2`,stride:28,offset:20},aColorAdd:{buffer:e,format:`unorm8x4`,stride:28,offset:24}},indexBuffer:t})}},CD=0,wD=e=>e.colorAdd??CD;function TD(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){e[n]=r*l+a*u+s,e[n+1]=o*u+i*l+c,e[n+2]=d,e[n+3]=f,t[n+4]=p,t[n+5]=m,t[n+6]=h}var ED=class e extends Nd{static{this.extension={type:[p.Batcher],name:`mwg-color-transform`}}constructor(t){super(t),this.geometry=new SD,this.name=e.extension.name,this.vertexSize=xD,this.shader=new bD(t.maxTextures)}packAttributes(e,t,n,r,i){let a=i<<16|e.roundPixels&65535,{a:o,b:s,c,d:l,tx:u,ty:d}=e.transform,{positions:f,uvs:p}=e,m=e.color,h=wD(e),g=e.attributeOffset,_=g+e.attributeSize;for(let e=g;e<_;e++){let i=e*2,g=f[i],_=f[i+1];t[r++]=o*g+c*_+u,t[r++]=l*_+s*g+d,t[r++]=p[i],t[r++]=p[i+1],n[r++]=m,n[r++]=a,n[r++]=h}}packQuadAttributes(e,t,n,r,i){let{a,b:o,c:s,d:c,tx:l,ty:u}=e.transform,{bounds:d}=e,f=e.texture.uvs,p=d.maxX,m=d.minX,h=d.maxY,g=d.minY,_=e.color,v=wD(e),y=i<<16|e.roundPixels&65535;TD(t,n,r,a,o,s,c,l,u,m,g,f.x0,f.y0,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,p,g,f.x1,f.y1,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,p,h,f.x2,f.y2,_,y,v),r+=xD,TD(t,n,r,a,o,s,c,l,u,m,h,f.x3,f.y3,_,y,v)}_updateMaxTextures(e){this.shader.maxTextures!==e&&(this.shader.destroy(),this.shader=new bD(e))}destroy(){this.shader.destroy(),super.destroy()}},DD=`mwg-tinted-sprite`,OD=class{static{this.extension={type:[p.WebGLPipes,p.WebGPUPipes,p.CanvasPipes],name:DD}}constructor(e){this.renderer=e}addRenderable(e,t){let n=this.element(e);e.didViewUpdate&&this.sync(e,n),this.renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this.element(e);e.didViewUpdate&&this.sync(e,t),t._batcher.updateElement(t)}validateRenderable(e){let t=this.element(e);return!t._batcher.checkAndUpdateTexture(t,e.texture)}sync(e,t){t.bounds=e.visualBounds,t.texture=e.texture,t.colorAdd=e.colorAdd}element(e){let t=e._gpuData;return t[this.renderer.uid]??this.create(e,t)}create(e,t){let n=new kD;return n.renderable=e,n.transform=e.groupTransform,n.texture=e.texture,n.bounds=e.visualBounds,n.roundPixels=this.renderer._roundPixels|e._roundPixels,n.colorAdd=e.colorAdd,t[this.renderer.uid]=n,n}destroy(){this.renderer=null}},kD=class{constructor(){this.batcherName=ED.extension.name,this.topology=`triangle-list`,this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this.colorAdd=0,this._attributeStart=0,this._textureId=0,this._indexStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null,this.colorAdd=0}destroy(){this.reset()}},AD=!1;function jD(){AD||(AD=!0,g.add(ED),g.add(OD))}function MD(e,t,n,r=0){return(PD(r)<<24|PD(n)<<16|PD(t)<<8|PD(e))>>>0}function ND(e,t){return MD((e>>16&255)/255*t,(e>>8&255)/255*t,(e&255)/255*t)}function PD(e){return Math.max(0,Math.min(255,Math.round(e*255)))}var FD=CD,ID=class extends Ui{constructor(e){super(e),this._colorAdd=0,this.renderPipeId=DD}get colorAdd(){return this._colorAdd}set colorAdd(e){this._colorAdd!==e&&(this._colorAdd=e,this.onViewUpdate())}setColorAdd(e,t,n,r=0){this.colorAdd=MD(e,t,n,r)}lerpTint(e,t){let n=Math.round((1-t)*255);this.tint=n<<16|n<<8|n,this.colorAdd=ND(e,t)}silhouette(e){this.tint=0,this.colorAdd=ND(e,1)}resetColor(){this.tint=16777215,this.colorAdd=0}},LD=class{constructor(e,{fps:t=10,loop:n=!0}={}){if(e.length===0)throw Error(`an animation needs at least one frame`);this.frames=e,this.frameDuration=1/t,this.loop=n}get duration(){return this.frameDuration*this.frames.length}},RD=class extends ID{constructor(...e){super(...e),this.animations=new Map,this.current=null,this.currentName=null,this.frameIndex=0,this.timer=0,this.finished=!1,this.onFinish=null,this.paused=!1}add(e,t,n){return this.animations.set(e,new LD(t,n)),this}has(e){return this.animations.has(e)}get playing(){return this.currentName}get isFinished(){return this.finished}play(e,t=!1){if(!t&&this.currentName===e&&!this.finished)return this;let n=this.animations.get(e);if(!n)throw Error(`no animation named "${e}" on this sprite`);return this.current=n,this.currentName=e,this.frameIndex=0,this.timer=0,this.finished=!1,this.texture=n.frames[0],this}stop(){this.current=null,this.currentName=null}update(e){let t=this.current;if(!(!t||this.paused||this.finished)){for(this.timer+=e;this.timer>=t.frameDuration;)if(this.timer-=t.frameDuration,this.frameIndex<t.frames.length-1)this.frameIndex++;else if(t.loop)this.frameIndex=0;else{this.finished=!0,this.onFinish?.(this.currentName);break}this.texture=t.frames[this.frameIndex]}}},zD=class{constructor(e={}){if(this.entries=new Map,this.clock=0,this.budgetBytes=e.budgetBytes??1/0,!(this.budgetBytes>=0))throw Error(`asset stream budget must not be negative`);this.loadAssets=e.load??JD,this.releaseAssets=e.release??QD}async preload(e){if(!e.id)throw Error(`asset bundle needs an id`);if(e.estimatedBytes!==void 0&&e.estimatedBytes<0)throw Error(`asset bundle size must not be negative`);let t=this.entries.get(e.id);if(t?.ready){t.lastUsed=++this.clock;return}let n=e.paths.filter(e=>!this.isRetained(e));n.length>0&&await this.loadAssets([...n]),this.entries.set(e.id,{...e,lastUsed:++this.clock,ready:!0}),await this.enforceBudget(e.id)}async preloadLikely(e){for(let t of[...e].sort((e,t)=>(t.priority??0)-(e.priority??0)))await this.preload(t)}use(e){let t=this.entries.get(e);return t?.ready?(t.lastUsed=++this.clock,!0):!1}isReady(e){return this.entries.get(e)?.ready??!1}async unload(e){let t=this.entries.get(e);if(!t)return;this.entries.delete(e);let n=t.paths.filter(e=>!this.isRetained(e));n.length>0&&await this.releaseAssets(n)}get estimatedBytes(){return[...this.entries.values()].reduce((e,t)=>e+(t.estimatedBytes??0),0)}async enforceBudget(e){for(;this.estimatedBytes>this.budgetBytes;){let t=[...this.entries.values()].filter(t=>t.id!==e).sort((e,t)=>e.lastUsed-t.lastUsed)[0];if(!t)return;await this.unload(t.id)}}isRetained(e){return[...this.entries.values()].some(t=>t.ready&&t.paths.includes(e))}},BD=l({AssetStream:()=>zD,get:()=>XD,has:()=>KD,isCompiled:()=>WD,isLoaded:()=>ZD,load:()=>JD,paths:()=>GD,release:()=>QD,resolve:()=>qD,setBase:()=>HD,texture:()=>YD}),VD=``;function HD(e){VD=e.endsWith(`/`)||e===``?e:e+`/`}function UD(){return typeof window>`u`?void 0:window.__MWG_ASSETS__}function WD(){return UD()!==void 0}function GD(){return Object.keys(UD()??{})}function KD(e){let t=UD();return!t||e in t}function qD(e){let t=UD();if(!t)return VD+e;let n=t[e];if(n===void 0)throw Error(`asset "${e}" is not in this build - check it is under the folder passed to compile-resources`);return n}async function JD(e){let t=e.filter(e=>!Cw.cache.has(e));if(t.length!==0){for(let e of t)Cw.add({alias:e,src:qD(e)});await Cw.load(t)}}function YD(e){if(!Cw.cache.has(e))throw Error(`texture "${e}" has not been loaded - pass it to load() first`);return Cw.get(e)}function XD(e){if(!Cw.cache.has(e))throw Error(`asset "${e}" has not been loaded - pass it to load() first`);return Cw.get(e)}function ZD(e){return Cw.cache.has(e)}async function QD(e){let t=e.filter(e=>Cw.cache.has(e));t.length!==0&&await Cw.unload(t)}var $D=class e{constructor(e,t,n){this.frames=new Map,this.names=new Map,this.texture=e,this.frameWidth=t,this.frameHeight=n,this.columns=Math.floor(e.width/t),this.rows=Math.floor(e.height/n)}static grid(t,n,r=n){return new e(YD(t),n,r)}static fromTexture(t,n,r=n){return new e(t,n,r)}get count(){return this.columns*this.rows}name(e,t){return this.names.set(e,t),this}nameAll(e){for(let[t,n]of Object.entries(e))this.names.set(t,n);return this}indexOf(e){let t=this.names.get(e);if(t===void 0)throw Error(`this sheet has no frame named "${e}"`);return t}get(e){let t=typeof e==`string`?this.indexOf(e):e,n=this.frames.get(t);if(n)return n;if(t<0||t>=this.count)throw Error(`frame ${t} is outside this sheet, which holds ${this.count}`);let r=new W({source:this.texture.source,frame:new H(t%this.columns*this.frameWidth,Math.floor(t/this.columns)*this.frameHeight,this.frameWidth,this.frameHeight)});return this.frames.set(t,r),r}range(e,t){let n=[];for(let r=e;r<=t;r++)n.push(this.get(r));return n}pick(...e){return e.map(e=>this.get(e))}},eO=class{constructor(e={}){this.world=new K,this.x=0,this.y=0,this.viewWidth=0,this.viewHeight=0,this.screenX=0,this.screenY=0,this.followTarget=null,this.followIntensity=0,this.shakeMagnitude=0,this.shakeRemaining=0,this.shakeDuration=1,this.shakeX=0,this.shakeY=0,this.bounds=null,this.deadzone=e.deadzone??0,this.pixelPerfectTileSize=e.pixelPerfectTileSize,this._zoom=1,this.zoom=e.zoom??1}get zoom(){return this._zoom}set zoom(e){let t=Math.max(.01,e);this._zoom=this.pixelPerfectTileSize?nO(t,this.pixelPerfectTileSize):t}setViewport(e,t,n=0,r=0){this.viewWidth=e,this.viewHeight=t,this.screenX=n,this.screenY=r}get view(){let e=this.viewWidth/this._zoom,t=this.viewHeight/this._zoom,{x:n,y:r}=this.clampedCentre(this.x,this.y);return{x:n-e/2,y:r-t/2,width:e,height:t}}setBounds(e){this.bounds=e}snapTo(e,t){this.x=e,this.y=t,this.followTarget=null,this.followIntensity=0,this.apply()}panTo(e,t,n=4){this.followTarget={x:e,y:t},this.followIntensity=n}follow(e,t=8){this.followTarget=e,this.followIntensity=t}stopFollowing(){this.followTarget=null,this.followIntensity=0}shake(e,t=.4){this.shakeMagnitude=e,this.shakeRemaining=this.shakeDuration=t}update(e){if(this.followTarget&&this.followIntensity>0){let t=this.viewWidth/this._zoom*this.deadzone/2,n=this.viewHeight/this._zoom*this.deadzone/2,r=this.followTarget.x-this.x,i=this.followTarget.y-this.y;r=r>t?r-t:r<-t?r+t:0,i=i>n?i-n:i<-n?i+n:0;let a=1-Math.exp(-this.followIntensity*e);this.x+=r*a,this.y+=i*a}if(this.shakeRemaining>0){this.shakeRemaining-=e;let t=Math.max(0,this.shakeRemaining/this.shakeDuration);this.shakeX=xE(-this.shakeMagnitude,this.shakeMagnitude)*t,this.shakeY=xE(-this.shakeMagnitude,this.shakeMagnitude)*t}else this.shakeX=this.shakeY=0;this.apply()}toScreen(e,t){let{x:n,y:r}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);return{x:(e-n)*this._zoom+this.screenX+this.viewWidth/2,y:(t-r)*this._zoom+this.screenY+this.viewHeight/2}}toWorld(e,t){let{x:n,y:r}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);return{x:(e-this.screenX-this.viewWidth/2)/this._zoom+n,y:(t-this.screenY-this.viewHeight/2)/this._zoom+r}}clampedCentre(e,t){if(!this.bounds)return{x:e,y:t};let n=this.viewWidth/this._zoom/2,r=this.viewHeight/this._zoom/2,{minX:i,minY:a,maxX:o,maxY:s}=this.bounds;return{x:o-i<n*2?(i+o)/2:tO(e,i+n,o-n),y:s-a<r*2?(a+s)/2:tO(t,a+r,s-r)}}apply(){let{x:e,y:t}=this.clampedCentre(this.x+this.shakeX,this.y+this.shakeY);this.world.scale.set(this._zoom),this.world.x=Math.round(this.screenX+this.viewWidth/2-e*this._zoom),this.world.y=Math.round(this.screenY+this.viewHeight/2-t*this._zoom)}};function tO(e,t,n){return e<t?t:e>n?n:e}function nO(e,t){return Math.max(1,Math.round(e*t))/t}function rO(e={}){let t=new eO(e),n=oE.current;return t.setViewport(n.width,n.height),t}var iO=class{constructor(e){this.container=new K,this.clip=new px,this.camera=new eO(e),this.container.addChild(this.camera.world),this.container.addChild(this.clip),this.container.mask=this.clip,this.resize(e.x,e.y,e.width,e.height)}resize(e,t,n,r){this.camera.setViewport(n,r,e,t),this.clip.clear().rect(e,t,n,r).fill(16777215)}update(e){this.camera.update(e)}};function aO(e,t){if(e>=t){let n=Math.floor(e/2);return[{x:0,y:0,width:n,height:t},{x:n,y:0,width:e-n,height:t}]}let n=Math.floor(t/2);return[{x:0,y:0,width:e,height:n},{x:0,y:n,width:e,height:t-n}]}var oO={protanopia:[.567,.433,0,0,0,.558,.442,0,0,0,0,.242,.758,0,0,0,0,0,1,0],deuteranopia:[.625,.375,0,0,0,.7,.3,0,0,0,0,.3,.7,0,0,0,0,0,1,0],tritanopia:[.95,.05,0,0,0,0,.433,.567,0,0,0,.475,.525,0,0,0,0,0,1,0]};function sO(e){let t=new Dw;return t.matrix=oO[e],t}function cO(e,t){let n=[];for(let r of e)t.has(r)||n.push(r);return n}var lO=class extends K{constructor(e){super(),this.drawn=new Set,this.marker=new px,this.widthInCells=e.widthInCells,this.cellSize=e.cellSize??2,this.renderTexture=wf.create({width:e.widthInCells*this.cellSize,height:e.heightInCells*this.cellSize}),this.sprite=new Ui(this.renderTexture),this.addChild(this.sprite),this.addChild(this.marker)}get exploredCount(){return this.drawn.size}sync(e,t){let n=cO(e,this.drawn);if(n.length===0)return;let r=new px;for(let e of n){this.drawn.add(e);let n=e%this.widthInCells,i=Math.floor(e/this.widthInCells);r.rect(n*this.cellSize,i*this.cellSize,this.cellSize,this.cellSize).fill({color:t(n,i)})}oE.current.app.renderer.render({container:r,target:this.renderTexture,clear:!1}),r.destroy()}setMarker(e,t,n,r=16777215){if(this.marker.clear(),this.marker.circle(0,0,Math.max(1,this.cellSize)).fill({color:r}),n!==void 0){let e=this.cellSize*2;this.marker.moveTo(0,0).lineTo(Math.cos(n)*e,Math.sin(n)*e).stroke({color:r,width:1})}this.marker.x=(e+.5)*this.cellSize,this.marker.y=(t+.5)*this.cellSize}reset(){this.drawn.clear(),oE.current.app.renderer.render({container:new K,target:this.renderTexture,clear:!0})}destroy(e){this.renderTexture.destroy(!0),super.destroy(e)}},uO=-1,dO=7237230,fO=10132122;function pO(e,t){if(!Number.isInteger(e)||e<0||e>=4096)throw Error(`tileFrame needs a sheet index from 0 to 4095, got ${e}`);if(!Number.isInteger(t)||t<0||t>=1<<20)throw Error(`tileFrame needs a frame index from 0 to ${(1<<20)-1}, got ${t}`);return e<<20|t}function mO(e){return e>>>20}function hO(e){return e&(1<<20)-1}var gO=class extends K{constructor(e){if(super(),this.layers=[],this.layersByName=new Map,this.chunks=[],this.widthInTiles=e.width,this.heightInTiles=e.height,this.sheets=Array.isArray(e.sheet)?[...e.sheet]:[e.sheet],this.sheets.length===0)throw Error(`a TileMap needs at least one sheet`);if(this.tileWidth=e.tileWidth??this.sheets[0].frameWidth,this.tileHeight=e.tileHeight??this.sheets[0].frameHeight,this.shape=e.shape??`square`,this.heightStep=e.heightStep??this.tileHeight/2,!(this.heightStep>0))throw Error(`a TileMap's heightStep must be a positive number, got ${e.heightStep}`);this.chunkSize=e.chunkSize??16,this.chunkColumns=Math.ceil(this.widthInTiles/this.chunkSize),this.chunkRows=Math.ceil(this.heightInTiles/this.chunkSize);let t=this.widthInTiles*this.heightInTiles;this.cellTint=new Uint32Array(t).fill(16777215),this.cellAdd=new Uint32Array(t),this.cellHeight=new Int32Array(t),this.faces=Array(t).fill(null)}get layerCount(){return this.layers.length}get worldWidth(){switch(this.shape){case`square`:return this.widthInTiles*this.tileWidth;case`hex`:return this.widthInTiles<=0?0:(this.widthInTiles-1)*this.tileWidth*.75+this.tileWidth;case`isometric`:return(this.widthInTiles+this.heightInTiles)*(this.tileWidth/2);case`staggered`:return this.widthInTiles*this.tileWidth+this.tileWidth/2}}get worldHeight(){switch(this.shape){case`square`:return this.heightInTiles*this.tileHeight;case`hex`:return this.heightInTiles*this.tileHeight+this.tileHeight/2;case`isometric`:return(this.widthInTiles+this.heightInTiles)*(this.tileHeight/2);case`staggered`:return this.heightInTiles*(this.tileHeight/2)+this.tileHeight/2}}inside(e,t){return e>=0&&t>=0&&e<this.widthInTiles&&t<this.heightInTiles}index(e,t){return t*this.widthInTiles+e}addLayer(e,t){if(this.layersByName.has(e))throw Error(`this map already has a layer named "${e}"`);let n=this.widthInTiles*this.heightInTiles;if(t&&t.length!==n)throw Error(`layer "${e}" has ${t.length} cells, but the map has ${n}`);let r=new K,i=[];for(let e=0;e<this.chunkColumns*this.chunkRows;e++){let e=new K;i.push(e),r.addChild(e)}let a={name:e,data:t?Int32Array.from(t):new Int32Array(n).fill(-1),sprites:Array(n).fill(null),container:r};this.layers.push(a),this.layersByName.set(e,a),this.chunks.push(i),this.addChild(r);let o=this.layers.length===1;for(let e=0;e<this.heightInTiles;e++)for(let t=0;t<this.widthInTiles;t++){let n=a.data[this.index(t,e)];n!==-1&&this.buildSprite(a,t,e,n),o&&this.syncFaces(t,e)}return this}layerAt(e){let t=typeof e==`number`?this.layers[e]:this.layersByName.get(e);if(!t)throw Error(`no such layer: ${e}`);return t}chunkIndex(e,t){return Math.floor(t/this.chunkSize)*this.chunkColumns+Math.floor(e/this.chunkSize)}projectedCenter(e,t){switch(this.shape){case`square`:return{x:(e+.5)*this.tileWidth,y:(t+.5)*this.tileHeight};case`hex`:return fD(e,t,this.tileWidth,this.tileHeight);case`isometric`:return{x:(e-t+(this.heightInTiles-1))*(this.tileWidth/2)+this.tileWidth/2,y:(e+t)*(this.tileHeight/2)+this.tileHeight/2};case`staggered`:return{x:e*this.tileWidth+(t&1)*(this.tileWidth/2)+this.tileWidth/2,y:t*(this.tileHeight/2)+this.tileHeight/2}}}projectedTile(e,t){switch(this.shape){case`square`:return{x:Math.floor(e/this.tileWidth),y:Math.floor(t/this.tileHeight)};case`hex`:return pD(e,t,this.tileWidth,this.tileHeight);case`isometric`:{let n=(e-this.tileWidth/2)/(this.tileWidth/2)-(this.heightInTiles-1),r=(t-this.tileHeight/2)/(this.tileHeight/2);return{x:Math.round((n+r)/2),y:Math.round((r-n)/2)}}case`staggered`:{let n=Math.round((t-this.tileHeight/2)/(this.tileHeight/2));return{x:Math.round((e-this.tileWidth/2-(n&1)*(this.tileWidth/2))/this.tileWidth),y:n}}}}cellOrigin(e,t){let n=this.projectedCenter(e,t);return{x:n.x-this.tileWidth/2,y:n.y-this.tileHeight/2}}textureFor(e){let t=mO(e);if(t>=this.sheets.length)throw Error(`frame ${e} names sheet ${t}, but this map has ${this.sheets.length}`);return this.sheets[t].get(hO(e))}buildSprite(e,t,n,r){let i=new ID(this.textureFor(r)),a=this.cellOrigin(t,n);i.x=a.x,i.y=a.y-this.cellHeight[this.index(t,n)]*this.heightStep;let o=this.index(t,n);return i.tint=this.cellTint[o],i.colorAdd=this.cellAdd[o],e.sprites[o]=i,this.chunks[this.layers.indexOf(e)][this.chunkIndex(t,n)].addChild(i),i}getTile(e,t,n){return this.inside(t,n)?this.layerAt(e).data[this.index(t,n)]:-1}setTile(e,t,n,r){if(!this.inside(t,n))return;let i=this.layerAt(e),a=this.index(t,n);if(i.data[a]===r)return;i.data[a]=r;let o=i.sprites[a];r===-1?(o?.destroy(),i.sprites[a]=null):o?o.texture=this.textureFor(r):this.buildSprite(i,t,n,r),this.layers[0]===i&&this.syncFaces(t,n)}setLayerData(e,t){this.layerAt(e);for(let n=0;n<this.heightInTiles;n++)for(let r=0;r<this.widthInTiles;r++)this.setTile(e,r,n,t[this.index(r,n)]??-1)}setCellColor(e,t,n,r=0){if(!this.inside(e,t))return;let i=this.index(e,t);if(this.cellTint[i]===n&&this.cellAdd[i]===r)return;this.cellTint[i]=n,this.cellAdd[i]=r;for(let e of this.layers){let t=e.sprites[i];t&&(t.tint=n,t.colorAdd=r)}let a=this.faces[i];a&&(a.tint=n)}getCellTint(e,t){return this.inside(e,t)?this.cellTint[this.index(e,t)]:0}clearColors(){for(let e=0;e<this.heightInTiles;e++)for(let t=0;t<this.widthInTiles;t++)this.setCellColor(t,e,16777215,0)}setCellHeight(e,t,n){if(!this.inside(e,t))return;if(!Number.isInteger(n))throw Error(`a cell's height must be a whole number, got ${n}`);let r=this.index(e,t);if(this.cellHeight[r]===n)return;this.cellHeight[r]=n;let i=n*this.heightStep;for(let n of this.layers){let a=n.sprites[r];a&&(a.y=this.cellOrigin(e,t).y-i)}this.syncFaces(e,t)}getCellHeight(e,t){return this.inside(e,t)?this.cellHeight[this.index(e,t)]:0}get faceCount(){return this.faces.filter(e=>e!==null).length}syncFaces(e,t){if(this.layers.length===0)return;let n=this.index(e,t),r=(this.shape===`isometric`||this.shape===`staggered`)&&this.cellHeight[n]>0&&this.layers[0].data[n]!==-1,i=this.faces[n];if(!r){i&&(i.destroy(),this.faces[n]=null);return}let a=i??new px;if(this.drawFaces(a,e,t),a.tint=this.cellTint[n],!i){this.faces[n]=a;let r=this.chunks[0][this.chunkIndex(e,t)],i=this.layers[0].sprites[n];i?r.addChildAt(a,r.getChildIndex(i)):r.addChild(a)}}drawFaces(e,t,n){let r=this.cellOrigin(t,n),i=r.x,a=r.y,o=this.tileWidth/2,s=this.tileHeight/2,c=this.heightStep,l=this.cellHeight[this.index(t,n)];e.clear();for(let t=1;t<=l;t++){let n=t*c,r=(t-1)*c;e.poly([i,a+s-n,i+o,a+s*2-n,i+o,a+s*2-r,i,a+s-r]).fill(dO),e.poly([i+o,a+s*2-n,i+o*2,a+s-n,i+o*2,a+s-r,i+o,a+s*2-r]).fill(fO)}}toTile(e,t){return this.projectedTile(e,t)}tileCenter(e,t){let n=this.projectedCenter(e,t);return n.y-=this.getCellHeight(e,t)*this.heightStep,n}cull(e){let t=e.view,n=this.projectedTile(t.x,t.y),r=this.projectedTile(t.x+t.width,t.y),i=this.projectedTile(t.x,t.y+t.height),a=this.projectedTile(t.x+t.width,t.y+t.height),o=Math.min(n.x,r.x,i.x,a.x),s=Math.max(n.x,r.x,i.x,a.x),c=Math.min(n.y,r.y,i.y,a.y),l=Math.max(n.y,r.y,i.y,a.y),u=Math.floor(o/this.chunkSize)-1,d=Math.floor(s/this.chunkSize)+1,f=Math.floor(c/this.chunkSize)-1,p=Math.floor(l/this.chunkSize)+1;for(let e=0;e<this.chunkRows;e++){let t=e>=f&&e<=p;for(let n=0;n<this.chunkColumns;n++){let r=t&&n>=u&&n<=d,i=e*this.chunkColumns+n;for(let e of this.chunks)e[i].renderable=r}}}get visibleChunks(){return this.chunks.length===0?0:this.chunks[0].filter(e=>e.renderable).length}},_O=class extends K{constructor(...e){super(...e),this.layers=new Map}addLayer(e,t,n=0){this.removeLayer(e);let r=new ID(t);return this.layers.set(e,{sprite:r,order:n}),this.addChild(r),this.resort(),r}removeLayer(e){let t=this.layers.get(e);t&&(this.layers.delete(e),t.sprite.destroy())}layer(e){return this.layers.get(e)?.sprite}hasLayer(e){return this.layers.has(e)}setTexture(e,t){let n=this.layers.get(e);n&&(n.sprite.texture=t)}resort(){[...this.layers.values()].sort((e,t)=>e.order-t.order).forEach((e,t)=>this.setChildIndex(e.sprite,t))}},vO=class{constructor(e,t,n,r={}){this.elapsed=0,this.arrived=!1,this.sprite=e,this.fromX=t.x,this.fromY=t.y,this.toX=n.x,this.toY=n.y;let i=Math.hypot(n.x-t.x,n.y-t.y);this.duration=r.duration??i/(r.speed??400),this.duration<=0&&(this.duration=1e-6),e.x=t.x,e.y=t.y}get done(){return this.arrived}get progress(){return Math.min(1,this.elapsed/this.duration)}update(e){if(this.arrived)return!1;this.elapsed+=e;let t=this.progress;return this.sprite.x=this.fromX+(this.toX-this.fromX)*t,this.sprite.y=this.fromY+(this.toY-this.fromY)*t,t>=1&&(this.arrived=!0,!0)}},yO=class{constructor(e,t){this.idleOrMove=`idle`,this.inAction=!1,this.sprite=e,this.animationName=t.animationName,this.variant=t.variant??``,this.sprite.onFinish=()=>this.onSpriteFinish(),this.apply(this.idleOrMove)}get state(){return this.inAction?`action`:this.idleOrMove}get variantName(){return this.variant}setMoving(e,t){t!==void 0&&(this.variant=t),this.idleOrMove=e?`move`:`idle`,this.inAction||this.apply(this.idleOrMove)}playAction(e,t=!1){this.inAction&&!t||(e!==void 0&&(this.variant=e),this.inAction=!0,this.apply(`action`))}onSpriteFinish(){this.inAction&&(this.inAction=!1,this.apply(this.idleOrMove))}apply(e){let t=this.animationName(e,this.variant);this.sprite.has(t)&&this.sprite.play(t,e===`action`)}},bO=CO(),xO=new Map(bO.map((e,t)=>[SO(e),t]));function SO(e){let t=e.ne&&e.n&&e.e,n=e.se&&e.s&&e.e,r=e.sw&&e.s&&e.w,i=e.nw&&e.n&&e.w;return+!!e.n|(e.e?2:0)|(e.s?4:0)|(e.w?8:0)|(t?16:0)|(n?32:0)|(r?64:0)|(i?128:0)}function CO(){let e=new Set,t=[];for(let n=0;n<256;n++){let r={n:!!(n&1),e:!!(n&2),s:!!(n&4),w:!!(n&8),ne:!!(n&16),se:!!(n&32),sw:!!(n&64),nw:!!(n&128)},i=SO(r);e.has(i)||(e.add(i),t.push({mask:i,shape:{n:r.n,e:r.e,s:r.s,w:r.w,ne:r.ne&&r.n&&r.e,se:r.se&&r.s&&r.e,sw:r.sw&&r.s&&r.w,nw:r.nw&&r.n&&r.w}}))}return t.sort((e,t)=>e.mask-t.mask),t.map(e=>e.shape)}function wO(e){return xO.get(SO(e))}function TO(e,t,n,r){if(r.length!==bO.length)throw Error(`autotileFrames needs exactly ${bO.length} frames, got ${r.length}`);let i=new Int32Array(e*t);for(let a=0;a<t;a++)for(let t=0;t<e;t++){let o=a*e+t;if(!n(t,a)){i[o]=-1;continue}i[o]=r[wO({n:n(t,a-1),e:n(t+1,a),s:n(t,a+1),w:n(t-1,a),ne:n(t+1,a-1),se:n(t+1,a+1),sw:n(t-1,a+1),nw:n(t-1,a-1)})]}return i}var EO=[{workload:`sprites`,preferred:`PixiJS WebGL/WebGPU batcher`,fallback:`PixiJS WebGL`,reason:`high-volume textured 2D batches`},{workload:`ui`,preferred:`PixiJS display tree`,fallback:`PixiJS display tree`,reason:`themeable 2D layout and text`},{workload:`custom-shaders`,preferred:`backend-specific GLSL/WGSL only when profiled`,fallback:`PixiJS filters`,reason:`avoid maintaining paired shader sources without a measured gain`},{workload:`particles`,preferred:`PixiJS for 2D, Babylon.js for 3D`,fallback:`instanced sprites/meshes`,reason:`match simulation and depth to the scene`},{workload:`instanced-terrain`,preferred:`Babylon.js thin instances`,fallback:`PixiJS TileMap for 2D`,reason:`depth-tested repeated 3D geometry`},{workload:`voxels`,preferred:`Babylon.js thin instances`,fallback:`batched meshes`,reason:`color-grouped 3D voxels`},{workload:`animated-models`,preferred:`Babylon.js glTF animation groups`,fallback:`billboard sprites`,reason:`standard 3D interchange and animation support`},{workload:`large-3d-worlds`,preferred:`Babylon.js with streaming/culling`,fallback:`partitioned scenes`,reason:`scene graph, depth, and instancing`}];function DO(e={}){let t=e.createCanvas?.()??(typeof document>`u`?null:document.createElement(`canvas`)),n=!!t?.getContext(`webgl2`);return{webgl1:n||!!(t?.getContext(`webgl`)??t?.getContext(`experimental-webgl`)),webgl2:n,webgpu:e.webgpu??!!globalThis.navigator?.gpu,wgsl:e.wgsl??!1}}async function OO(){let e=globalThis.navigator?.gpu;if(!e)return{webgpu:!1,wgsl:!1};try{let t=await(await e.requestAdapter())?.requestDevice();return t?{webgpu:!0,wgsl:(await t.createShaderModule({code:`@compute @workgroup_size(1) fn main() {}`}).getCompilationInfo()).messages.length===0}:{webgpu:!1,wgsl:!1}}catch{return{webgpu:!1,wgsl:!1}}}var kO={panelBorder:4,padding:8,spacing:2,direction:`ltr`,font:{family:`ui-monospace, Consolas, "DejaVu Sans Mono", monospace`,size:12,lineHeight:1.4},color:{text:15263984,textDim:9079446,textHighlight:16770688,panelFill:1842214,panelBorder:4868702,selection:3820154,overlay:0},overlayAlpha:.5},AO={panelBorder:6,padding:10,spacing:4,direction:`ltr`,font:{family:kO.font.family,size:14,lineHeight:1.5},color:{text:16777215,textDim:13421772,textHighlight:16776960,panelFill:0,panelBorder:16777215,selection:16776960,overlay:0},overlayAlpha:.85},jO=kO;function MO(){return jO}var NO=new vT;function PO(e){jO={...kO,...e,font:{...kO.font,...e.font},color:{...kO.color,...e.color}},NO.dispatch(jO)}var FO=class extends Jw{constructor(e={}){let t=typeof e==`string`?{text:e}:e,n=MO();super({text:t.text??``,style:new KS({fontFamily:n.font.family,fontSize:t.size??n.font.size,fontWeight:t.bold?`bold`:`normal`,fill:t.color??n.color.text,lineHeight:(t.size??n.font.size)*n.font.lineHeight,align:t.align??(n.direction===`rtl`?`right`:`left`),wordWrap:t.wrapWidth!==void 0,wordWrapWidth:t.wrapWidth??0,breakWords:!0})}),this.themeListener=e=>this.restyle(e),this.opts=t,NO.add(this.themeListener)}setColor(e){this.style.fill=e}setText(e){this.text!==e&&(this.text=e)}restyle(e){this.style.fontFamily=e.font.family,this.opts.color===void 0&&(this.style.fill=e.color.text),this.opts.size===void 0&&(this.style.fontSize=e.font.size,this.style.lineHeight=e.font.size*e.font.lineHeight),this.opts.align===void 0&&(this.style.align=e.direction===`rtl`?`right`:`left`)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},IO=class extends sT{constructor(e={}){let t=typeof e==`string`?{text:e}:e,n=MO();super({text:t.text??``,style:LO(t,n)}),this.themeListener=e=>this.restyle(e),this.opts=t,NO.add(this.themeListener)}setText(e){this.text!==e&&(this.text=e)}restyle(e){this.style=LO(this.opts,e)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}};function LO(e,t){return{fontFamily:t.font.family,fontSize:e.size??t.font.size,fontWeight:e.bold?`bold`:`normal`,fill:e.color??t.color.text,align:e.align??(t.direction===`rtl`?`right`:`left`),wordWrap:e.wrapWidth!==void 0,wordWrapWidth:e.wrapWidth??0,breakWords:!0}}var RO=class extends K{constructor(e,t){super();let n=typeof t.border==`number`?{left:t.border,top:t.border,right:t.border,bottom:t.border}:t.border;this.sprite=new gT({texture:e,leftWidth:n.left,topHeight:n.top,rightWidth:n.right,bottomHeight:n.bottom}),this.addChild(this.sprite)}get border(){return{left:this.sprite.leftWidth,top:this.sprite.topHeight,right:this.sprite.rightWidth,bottom:this.sprite.bottomHeight}}resize(e,t){let n=this.border;this.sprite.width=Math.max(e,n.left+n.right),this.sprite.height=Math.max(t,n.top+n.bottom)}},zO=class extends K{constructor(e){super(),this.content=new K,this.onClose=new vT,this.titleLabel=null,this.innerWidth=0,this.innerHeight=0,this.currentWidth=0,this.currentHeight=0,this.themeListener=()=>this.restyle(),this.delegate=null;let t=MO();this.modal=e.modal??!0,this.closable=e.closable??!0,this.dims=e.dims??this.modal,this.anchor=e.anchor??`center`,this.background=t.panel?new RO(t.panel,{border:t.panelBorder}):new px,this.addChild(this.background),e.title!==void 0&&(this.titleLabel=new FO({text:e.title,color:t.color.textHighlight,bold:!0}),this.addChild(this.titleLabel)),this.addChild(this.content),this.resize(e.width,e.height),NO.add(this.themeListener)}restyle(){this.titleLabel?.setColor(MO().color.textHighlight),this.resize(this.currentWidth,this.currentHeight)}resize(e,t){this.currentWidth=e,this.currentHeight=t;let n=MO(),r=(this.background instanceof RO?this.background.border.left:2)+n.padding;this.background instanceof RO?this.background.resize(e,t):this.background.clear().roundRect(0,0,e,t,4).fill({color:n.color.panelFill}).stroke({color:n.color.panelBorder,width:1});let i=r;this.titleLabel&&(this.titleLabel.x=n.direction===`rtl`?e-r-this.titleLabel.width:r,this.titleLabel.y=r,i=r+this.titleLabel.height+n.padding),this.content.x=r,this.content.y=i,this.innerWidth=Math.max(0,e-r*2),this.innerHeight=Math.max(0,t-i-r)}get contentWidth(){return this.innerWidth}get contentHeight(){return this.innerHeight}setTitle(e){this.titleLabel?.setText(e)}handleAction(e){return this.delegate?.handleAction(e)?!0:e===`cancel`&&this.closable?(this.close(),!0):!1}update(e){}close(){this.onClose.dispatch(),this.parent?.removeChild(this),this.destroy({children:!0})}place(e,t){let n=this.getLocalBounds(),r=MO().padding*2;this.x=Math.round((e-n.width)/2),this.y=this.anchor===`bottom`?Math.round(t-n.height-r):this.anchor===`top`?r:Math.round((t-n.height)/2)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},BO=class extends K{constructor(){super(),this.windows=[],this.overlay=new px,this.viewportWidth=0,this.viewportHeight=0,this.listener=e=>this.handleAction(e),this.themeListener=()=>this.drawOverlay(),this.overlay.visible=!1,this.addChild(this.overlay),wT.add(this.listener),NO.add(this.themeListener)}setViewport(e,t){this.viewportWidth=e,this.viewportHeight=t,this.drawOverlay();for(let n of this.windows)n.place(e,t)}get top(){return this.windows[this.windows.length-1]??null}get isEmpty(){return this.windows.length===0}get depth(){return this.windows.length}push(e){return this.windows.push(e),this.addChild(e),e.onClose.add(()=>(this.forget(e),!1)),e.place(this.viewportWidth,this.viewportHeight),this.updateOverlay(),e}pop(){this.top?.close()}closeAll(){for(let e of[...this.windows].reverse())e.close()}forget(e){let t=this.windows.indexOf(e);t!==-1&&this.windows.splice(t,1),this.updateOverlay()}updateOverlay(){let e=this.windows.findIndex(e=>e.dims);if(e===-1){this.overlay.visible=!1;return}this.overlay.visible=!0,this.setChildIndex(this.overlay,Math.max(0,this.getChildIndex(this.windows[e])-1))}drawOverlay(){let e=MO();this.overlay.clear().rect(0,0,this.viewportWidth,this.viewportHeight).fill({color:e.color.overlay,alpha:e.overlayAlpha})}handleAction(e){return this.top?.handleAction(e)??!1}get blocksWorld(){return this.windows.some(e=>e.modal)}update(e){this.top?.update(e)}destroy(e){wT.remove(this.listener),NO.remove(this.themeListener),super.destroy(e)}},VO=class extends K{constructor(e){super(),this.items=[],this.rows=[],this.rowsLayer=new K,this.highlight=new px,this.mask_=new px,this.index=0,this.scroll=0,this.themeListener=()=>this.restyle();let t=MO();this.viewWidth=e.width,this.viewHeight=e.height,this.explicitRowHeight=e.rowHeight!==void 0,this.rowHeight=e.rowHeight??Math.ceil(t.font.size*t.font.lineHeight)+t.spacing,this.onSelect=e.onSelect??null,this.onHighlight=e.onHighlight??null,this.addChild(this.highlight),this.addChild(this.rowsLayer),this.addChild(this.mask_),this.rowsLayer.mask=this.mask_,this.drawMask(),this.eventMode=`static`,this.on(`wheel`,e=>this.move(e.deltaY>0?1:-1)),this.setItems(e.items??[]),NO.add(this.themeListener)}restyle(){let e=MO();this.explicitRowHeight||(this.rowHeight=Math.ceil(e.font.size*e.font.lineHeight)+e.spacing);let t=e.direction===`rtl`;this.rows.forEach((n,r)=>{n.y=r*this.rowHeight;let i=this.items[r],a=n.children.find(e=>e instanceof FO);if(a){a.setColor(i.disabled?e.color.textDim:e.color.text);let n=e.spacing+(i.icon?this.rowHeight:0);a.x=t?this.viewWidth-n-a.width:n,a.y=Math.round((this.rowHeight-a.height)/2)}i.icon&&(i.icon.x=t?this.viewWidth-e.spacing-this.rowHeight:e.spacing)}),this.refresh()}destroy(e){NO.remove(this.themeListener),super.destroy(e)}drawMask(){this.mask_.clear().rect(0,0,this.viewWidth,this.viewHeight).fill({color:16777215})}get visibleRows(){return Math.max(1,Math.floor(this.viewHeight/this.rowHeight))}get selectedIndex(){return this.index}get selected(){return this.items[this.index]??null}get length(){return this.items.length}setItems(e){this.items=e;for(let e of this.rows)e.destroy({children:!0});this.rows=[],this.rowsLayer.removeChildren();let t=MO(),n=t.direction===`rtl`;e.forEach((e,r)=>{let i=new K;i.y=r*this.rowHeight,i.eventMode=`static`,i.cursor=e.disabled?`default`:`pointer`,i.on(`pointerdown`,()=>{e.disabled||(this.select(r),this.confirm())}),e.icon&&(e.icon.x=n?this.viewWidth-t.spacing-this.rowHeight:t.spacing,i.addChild(e.icon));let a=new FO({text:e.text,color:e.disabled?t.color.textDim:t.color.text}),o=t.spacing+(e.icon?this.rowHeight:0);a.x=n?this.viewWidth-o-a.width:o,a.y=Math.round((this.rowHeight-a.height)/2),i.addChild(a),this.rows.push(i),this.rowsLayer.addChild(i)}),this.index=this.items.findIndex(e=>!e.disabled),this.index===-1&&(this.index=0),this.scroll=0,this.refresh()}resize(e,t){this.viewWidth=e,this.viewHeight=t,this.drawMask(),this.refresh()}move(e){if(this.items.length===0)return!1;let t=this.index;for(let n=0;n<this.items.length;n++)if(t=(t+e+this.items.length)%this.items.length,!this.items[t].disabled)return this.index=t,this.refresh(),this.onHighlight?.(this.items[t],t),!0;return!1}select(e){e<0||e>=this.items.length||this.items[e].disabled||(this.index=e,this.refresh(),this.onHighlight?.(this.items[e],e))}confirm(){let e=this.selected;return!e||e.disabled?!1:(this.onSelect?.(e,this.index),!0)}handleAction(e){switch(e){case`up`:return this.move(-1);case`down`:return this.move(1);case`confirm`:return this.confirm();default:return!1}}refresh(){let e=this.visibleRows;this.index<this.scroll?this.scroll=this.index:this.index>=this.scroll+e&&(this.scroll=this.index-e+1),this.scroll=Math.max(0,Math.min(this.scroll,Math.max(0,this.items.length-e))),this.rowsLayer.y=-this.scroll*this.rowHeight;let t=MO();if(this.items.length===0){this.highlight.clear();return}this.highlight.clear().rect(0,(this.index-this.scroll)*this.rowHeight,this.viewWidth,this.rowHeight).fill({color:t.color.selection})}},HO=class extends K{constructor(e){super(),this.items=[],this.cells=[],this.cellsLayer=new K,this.highlight=new px,this.pickupHighlight=new px,this.mask_=new px,this.index=0,this.scrollRow=0,this.pickedUp=null,this.pressedIndex=null,this.pressTimer=0,this.themeListener=()=>{let e=MO();this.items.forEach((t,n)=>{(t.quantity??1)<=1||(this.cells[n]?.children.find(e=>e instanceof FO))?.setColor(e.color.textHighlight)}),this.refresh()},this.viewWidth=e.width,this.viewHeight=e.height,this.columns=Math.max(1,e.columns),this.cellSize=e.cellSize??Math.floor(this.viewWidth/this.columns),this.longPressDuration=e.longPressDuration??.6,this.onSelect=e.onSelect??null,this.onHighlight=e.onHighlight??null,this.onQuickslot=e.onQuickslot??null,this.onReorder=e.onReorder??null,this.addChild(this.highlight),this.addChild(this.pickupHighlight),this.addChild(this.cellsLayer),this.addChild(this.mask_),this.cellsLayer.mask=this.mask_,this.drawMask(),this.eventMode=`static`,this.on(`wheel`,e=>this.move(0,e.deltaY>0?1:-1)),this.setItems(e.items??[]),NO.add(this.themeListener)}destroy(e){NO.remove(this.themeListener),super.destroy(e)}drawMask(){this.mask_.clear().rect(0,0,this.viewWidth,this.viewHeight).fill({color:16777215})}get visibleRows(){return Math.max(1,Math.floor(this.viewHeight/this.cellSize))}get rows(){return Math.max(1,Math.ceil(this.items.length/this.columns))}get selectedIndex(){return this.index}get selected(){return this.items[this.index]??null}get length(){return this.items.length}setItems(e){this.items=e,this.pickedUp=null,this.pressedIndex=null;for(let e of this.cells)e.destroy({children:!0});this.cells=[],this.cellsLayer.removeChildren();let t=MO();e.forEach((e,n)=>{let r=Math.floor(n/this.columns),i=n%this.columns,a=new K;if(a.x=i*this.cellSize,a.y=r*this.cellSize,a.eventMode=`static`,a.cursor=e.disabled?`default`:`pointer`,e.icon.x=Math.round((this.cellSize-e.icon.width)/2),e.icon.y=Math.round((this.cellSize-e.icon.height)/2),e.disabled&&(e.icon.alpha=.4),a.addChild(e.icon),(e.quantity??1)>1){let n=new FO({text:String(e.quantity),size:10,color:t.color.textHighlight});n.x=this.cellSize-n.width-2,n.y=this.cellSize-n.height-1,a.addChild(n)}a.on(`pointerdown`,()=>{this.pressedIndex=n,this.pressTimer=0}),a.on(`pointerup`,()=>this.releaseCell(n)),a.on(`pointerupoutside`,()=>this.releaseCell(n)),this.cells.push(a),this.cellsLayer.addChild(a)}),this.index=this.items.findIndex(e=>!e.disabled),this.index===-1&&(this.index=0),this.scrollRow=0,this.refresh()}releaseCell(e){this.pressedIndex===e&&(this.pressedIndex=null,this.items[e]?.disabled||this.tapCell(e))}resize(e,t){this.viewWidth=e,this.viewHeight=t,this.drawMask(),this.refresh()}update(e){if(this.pressedIndex===null||(this.pressTimer+=e,this.pressTimer<this.longPressDuration))return;let t=this.pressedIndex;this.pressedIndex=null;let n=this.items[t];n&&!n.disabled&&this.onQuickslot?.(n,t)}tapCell(e){if(e<0||e>=this.items.length)return;if(this.pickedUp===null){if(this.items[e].disabled)return;this.pickedUp=e,this.refresh();return}let t=this.pickedUp;this.pickedUp=null,t!==e&&(this.swapCells(t,e),this.onReorder?.(t,e)),this.refresh()}swapCells(e,t){[this.items[e],this.items[t]]=[this.items[t],this.items[e]];let n=this.cells[e],r=this.cells[t],i=n.removeChildren(),a=r.removeChildren();for(let e of a)n.addChild(e);for(let e of i)r.addChild(e);n.cursor=this.items[e].disabled?`default`:`pointer`,r.cursor=this.items[t].disabled?`default`:`pointer`}cancelPickup(){this.pickedUp=null,this.refresh()}move(e,t){if(this.items.length===0)return!1;let n=this.items.length,r=this.rows,i=Math.floor(this.index/this.columns),a=this.index%this.columns;for(let o=0;o<r*this.columns;o++){a=(a+e+this.columns)%this.columns,i=(i+t+r)%r;let o=i*this.columns+a;if(o<n&&!this.items[o].disabled)return this.index=o,this.refresh(),this.onHighlight?.(this.items[o],o),!0}return!1}select(e){e<0||e>=this.items.length||this.items[e].disabled||(this.index=e,this.refresh(),this.onHighlight?.(this.items[e],e))}confirm(){let e=this.selected;return!e||e.disabled?!1:(this.onSelect?.(e,this.index),!0)}handleAction(e){switch(e){case`up`:return this.move(0,-1);case`down`:return this.move(0,1);case`left`:return this.move(-1,0);case`right`:return this.move(1,0);case`confirm`:return this.confirm();case`cancel`:return this.pickedUp!==null&&(this.cancelPickup(),!0);default:return!1}}cellRect(e){return{x:e%this.columns*this.cellSize,y:Math.floor(e/this.columns)*this.cellSize}}refresh(){let e=this.visibleRows,t=Math.floor(this.index/this.columns);t<this.scrollRow?this.scrollRow=t:t>=this.scrollRow+e&&(this.scrollRow=t-e+1),this.scrollRow=Math.max(0,Math.min(this.scrollRow,Math.max(0,this.rows-e))),this.cellsLayer.y=-this.scrollRow*this.cellSize;let n=MO();if(this.pickupHighlight.clear(),this.pickedUp!==null){let{x:e,y:t}=this.cellRect(this.pickedUp);this.pickupHighlight.rect(e,t,this.cellSize,this.cellSize).stroke({color:n.color.textHighlight,width:2})}if(this.highlight.clear(),this.items.length>0){let{x:e,y:t}=this.cellRect(this.index);this.highlight.rect(e,t,this.cellSize,this.cellSize).fill({color:n.color.selection})}}},UO=class extends zO{constructor(e){super({width:e.width,height:e.height,modal:!0,closable:!1,dims:e.dims,anchor:e.anchor??`bottom`}),this.pageIndex=0,this.revealed=0,this.portrait=null,this.portraitLayer=new K,this.choiceList=null,this.finished=!1,this.autoAdvanceElapsed=0,this.messageThemeListener=()=>this.restyleMessage(),this.pages=e.pages.map(e=>typeof e==`string`?{text:e}:e),this.speed=e.speed??40,this.mode=e.mode??`adv`,this.autoAdvance=e.autoAdvance,this.choices=e.choices??[],this.onDone=e.onDone??null;let t=MO();this.content.addChild(this.portraitLayer),this.speakerLabel=new FO({color:t.color.textHighlight,bold:!0}),this.content.addChild(this.speakerLabel),this.body=new FO({wrapWidth:this.contentWidth}),this.content.addChild(this.body),this.prompt=new FO({text:`▼`,color:t.color.textDim}),this.prompt.visible=!1,this.content.addChild(this.prompt),this.showPage(0),NO.add(this.messageThemeListener)}restyleMessage(){let e=MO();this.speakerLabel.setColor(e.color.textHighlight),this.prompt.setColor(e.color.textDim)}destroy(e){NO.remove(this.messageThemeListener),super.destroy(e)}showPage(e){let t=this.pages[e],n=MO(),r=n.direction===`rtl`;this.portraitLayer.removeChildren(),this.portrait=null;let i=0,a=this.contentWidth;t.portrait&&(this.portrait=new Ui(t.portrait),r&&(this.portrait.x=this.contentWidth-this.portrait.width),this.portraitLayer.addChild(this.portrait),a=this.contentWidth-this.portrait.width-n.padding,i=r?0:this.portrait.width+n.padding),this.speakerLabel.visible=this.mode===`adv`&&t.speaker!==void 0,this.speakerLabel.x=i,this.speakerLabel.setText(t.speaker??``),this.body.x=i,this.body.y=this.mode===`adv`&&t.speaker!==void 0?this.speakerLabel.height+n.spacing:0,this.body.style.wordWrapWidth=Math.max(16,a),this.revealed=this.speed>0?0:t.text.length,this.autoAdvanceElapsed=0,this.renderBody(),this.prompt.visible=!1,this.prompt.x=r?0:this.contentWidth-this.prompt.width,this.prompt.y=this.contentHeight-this.prompt.height}renderBody(){if(this.mode===`adv`){this.body.setText(this.pages[this.pageIndex].text.slice(0,Math.floor(this.revealed)));return}let e=this.pages.slice(0,this.pageIndex).map(e=>this.formatLine(e,e.text)),t=this.pages[this.pageIndex];e.push(this.formatLine(t,t.text.slice(0,Math.floor(this.revealed)))),this.body.setText(e.join(`
1259
1259
 
1260
1260
  `))}formatLine(e,t){return e.speaker===void 0?t:`${e.speaker}: ${t}`}get pageComplete(){return this.revealed>=this.pages[this.pageIndex].text.length}update(e){if(!this.finished){if(!this.pageComplete){this.revealed=Math.min(this.pages[this.pageIndex].text.length,this.revealed+this.speed*e),this.renderBody();return}this.prompt.visible=!this.choiceList,!(this.autoAdvance===void 0||this.choiceList)&&(this.autoAdvanceElapsed+=e,this.autoAdvanceElapsed>=this.autoAdvance&&(this.autoAdvanceElapsed=0,this.advance()))}}handleAction(e){return this.delegate?super.handleAction(e):e===`confirm`?this.pageComplete?(this.advance(),!0):(this.revealed=this.pages[this.pageIndex].text.length,this.renderBody(),!0):!1}advance(){if(this.pageIndex<this.pages.length-1){this.pageIndex++,this.showPage(this.pageIndex);return}if(this.choices.length>0){this.showChoices();return}this.finish(void 0)}showChoices(){let e=MO(),t=this.choices.map(e=>({text:e.text,disabled:e.disabled,value:e.value??e.text})),n=Math.ceil(e.font.size*e.font.lineHeight)+e.spacing,r=t.length*n,i=this.body.y+this.body.height+e.padding,a=i+r-this.contentHeight;a>0&&this.grow(a),this.choiceList=new VO({width:this.contentWidth,height:r,items:t,onSelect:e=>this.finish(e.value)}),this.choiceList.y=i,this.content.addChild(this.choiceList),this.delegate=this.choiceList,this.prompt.visible=!1}grow(e){let t=this.getLocalBounds();this.resize(t.width,t.height+e),this.y=Math.max(0,this.y-e)}finish(e){this.finished||(this.finished=!0,this.onDone?.(e),this.close())}},WO=/[A-Za-z0-9]/;function GO(e,t){let{lineHeight:n,columnHeight:r}=t,i=t.rotate??WO,a=[],o=0,s=0;for(let t of e){if(t===`
1261
1261
  `){o++,s=0;continue}s*n>=r&&(o++,s=0);let e=i.test(t),c=o===0?0:-o*n;a.push({char:t,x:e?c-n/2:c,y:e?s*n+n/2:s*n,rotate:e}),s++}return a}var KO=class extends K{constructor(e){super(),this.themeListener=e=>this.build(e),this.opts=e,this.build(MO()),NO.add(this.themeListener)}build(e){this.removeChildren().forEach(e=>e.destroy());let t=this.opts.size??e.font.size,n=Math.ceil(t*e.font.lineHeight),r=GO(this.opts.text,{lineHeight:n,columnHeight:this.opts.columnHeight,rotate:this.opts.rotate});for(let n of r){let r=new Jw({text:n.char,style:{fontFamily:e.font.family,fontSize:t,fill:this.opts.color??e.color.text}});n.rotate&&(r.anchor.set(.5),r.rotation=Math.PI/2),r.x=n.x,r.y=n.y,this.addChild(r)}}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},qO=class extends K{constructor(e){super(),this.capturing=null,this.onKeyCaptured=e=>this.capturing?(e.preventDefault(),e.code===`Escape`?this.cancelCapture():this.finishCapture(this.capturing,e.code),!0):!1,this.actions=[...e.actions],this.labelFor=e.label??(e=>e),this.onConflict=e.onConflict??(()=>!0),this.list=new VO({width:e.width,height:e.height,rowHeight:e.rowHeight,items:this.rows()}),this.addChild(this.list)}rows(){return this.actions.map(e=>({text:this.rowText(e),value:e,disabled:this.capturing!==null&&this.capturing!==e}))}rowText(e){if(this.capturing===e)return`${this.labelFor(e)}: press a key...`;let t=FT(e);return`${this.labelFor(e)}: ${t.length?t.join(`, `):`(unbound)`}`}refresh(){let e=this.list.selectedIndex;this.list.setItems(this.rows()),this.list.select(e)}startCapture(e){this.capturing=e,this.refresh(),queueMicrotask(()=>{this.capturing===e&&TT.add(this.onKeyCaptured)})}cancelCapture(){TT.remove(this.onKeyCaptured),this.capturing=null,this.refresh()}finishCapture(e,t){TT.remove(this.onKeyCaptured),this.capturing=null;let n=NT(t).filter(t=>t!==e);if(n.length>0&&!this.onConflict(t,e,n)){this.refresh();return}for(let e of n)jT(e,FT(e).filter(e=>e!==t));jT(e,[t]),this.refresh()}get isCapturing(){return this.capturing!==null}handleAction(e){if(this.capturing)return!0;if(e===`confirm`){let e=this.list.selected?.value;return e&&this.startCapture(e),!0}return this.list.handleAction(e)}destroy(e){TT.remove(this.onKeyCaptured),super.destroy(e)}},JO=class extends K{constructor(e){super(),this.onClick=new vT,this.state=`idle`,this.themeListener=()=>this.draw(),this.width_=e.width,this.height_=e.height,this.disabled_=e.disabled??!1;let t=MO();this.background=t.panel?new RO(t.panel,{border:t.panelBorder}):new px,this.addChild(this.background),this.icon=e.icon??null,this.icon&&this.addChild(this.icon),this.labelText=e.text===void 0?null:new FO({text:e.text,align:`center`}),this.labelText&&this.addChild(this.labelText),e.onClick&&this.onClick.add(e.onClick),this.eventMode=`static`,this.on(`pointerover`,()=>this.setState(`hover`)),this.on(`pointerout`,()=>this.setState(`idle`)),this.on(`pointerdown`,()=>this.setState(`pressed`)),this.on(`pointerup`,()=>{let e=this.state===`pressed`;this.setState(`hover`),e&&this.onClick.dispatch()}),this.on(`pointerupoutside`,()=>this.setState(`idle`)),this.setState(this.disabled_?`disabled`:`idle`),NO.add(this.themeListener)}resize(e,t){this.width_=e,this.height_=t,this.draw()}setText(e){e===void 0?(this.labelText?.destroy(),this.labelText=null):this.labelText?this.labelText.setText(e):(this.labelText=new FO({text:e,align:`center`}),this.addChild(this.labelText)),this.layoutContent()}get disabled(){return this.disabled_}setDisabled(e){this.disabled_=e,this.setState(e?`disabled`:`idle`)}setState(e){this.disabled_&&e!==`disabled`||(this.state=e,this.cursor=this.disabled_?`default`:`pointer`,this.eventMode=this.disabled_?`none`:`static`,this.draw())}layoutContent(){let e=MO().direction===`rtl`;if(this.icon&&!this.labelText){this.icon.x=Math.round((this.width_-this.icon.width)/2),this.icon.y=Math.round((this.height_-this.icon.height)/2);return}if(this.icon&&this.labelText){let t=MO().spacing,n=this.icon.width+t+this.labelText.width,r=Math.round((this.width_-n)/2);this.icon.x=e?r+this.labelText.width+t:r,this.icon.y=Math.round((this.height_-this.icon.height)/2),this.labelText.x=e?r:r+this.icon.width+t,this.labelText.y=Math.round((this.height_-this.labelText.height)/2);return}this.labelText&&(this.labelText.x=Math.round((this.width_-this.labelText.width)/2),this.labelText.y=Math.round((this.height_-this.labelText.height)/2))}draw(){let e=MO(),t=this.state===`pressed`?10066329:this.state===`hover`?14540253:this.state===`disabled`?7829367:16777215;if(this.background instanceof RO)this.background.resize(this.width_,this.height_),this.background.tint=t;else{let t=this.state===`pressed`?e.color.selection:e.color.panelFill;this.background.clear().roundRect(0,0,this.width_,this.height_,4).fill({color:t,alpha:this.state===`disabled`?.5:1}).stroke({color:e.color.panelBorder,width:1})}this.labelText?.setColor(this.disabled_?e.color.textDim:e.color.text),this.icon&&(this.icon.alpha=this.disabled_?.4:1),this.layoutContent()}destroy(e){NO.remove(this.themeListener),super.destroy(e)}},YO=class extends K{constructor(e){super(),this.track=new px,this.fill=new px,this.themeListener=()=>this.draw(),this.width_=e.width,this.height_=e.height,this.explicitColor=e.color!==void 0,this.color=e.color??MO().color.textHighlight,this.fraction=XO((e.value??1)/(e.max??1)),this.fillTexture=e.fillTexture,this.backgroundTexture=e.backgroundTexture,this.roundUpToPixel=e.roundUpToPixel??!1,this.addChild(this.track),this.addChild(this.fill),this.draw(),NO.add(this.themeListener)}get value(){return this.fraction}setValue(e,t=1){this.fraction=XO(t>0?e/t:0),this.draw()}resize(e,t){this.width_=e,this.height_=t,this.draw()}draw(){let e=MO();if(this.explicitColor||(this.color=e.color.textHighlight),this.track.clear().rect(0,0,this.width_,this.height_),this.track.fill(this.backgroundTexture?{texture:this.backgroundTexture}:{color:e.color.panelFill}),this.fill.clear(),this.fraction>0){let e=this.width_*this.fraction,t=this.roundUpToPixel?Math.ceil(e):e;this.fill.rect(0,0,t,this.height_),this.fill.fill(this.fillTexture?this.explicitColor?{texture:this.fillTexture,color:this.color}:{texture:this.fillTexture}:{color:this.color})}}destroy(e){NO.remove(this.themeListener),super.destroy(e)}};function XO(e){return Math.max(0,Math.min(1,e))}var ZO=class extends K{constructor(e){super(),this.elapsed=0,this.done=!1,this.duration=e.duration??.8,this.rise=e.rise??24;let t=new FO({text:e.text,color:e.color,size:e.size});t.anchor.set(.5),this.addChild(t)}get finished(){return this.done}update(e){if(this.done)return;this.elapsed=Math.min(this.duration,this.elapsed+e);let t=this.duration>0?this.elapsed/this.duration:1;this.y=-this.rise*t,this.alpha=1-t,t>=1&&(this.done=!0,this.parent?.removeChild(this),this.destroy({children:!0}))}},QO=class extends K{constructor(e={}){super(),this.queue=[],this.current=null,this.phase=`fadeIn`,this.elapsed=0,this.fadeIn=e.fadeIn??.25,this.hold=e.hold??1,this.fadeOut=e.fadeOut??1.75,this.scaleFrom=e.scaleFrom??2}show(e){this.queue.push(e),this.current||this.start(this.queue.shift())}get isBusy(){return this.current!==null||this.queue.length>0}start(e){this.current=e,this.phase=`fadeIn`,this.elapsed=0,this.addChild(e),e.alpha=this.fadeIn>0?0:1,e.scale.set(this.fadeIn>0?this.scaleFrom:1)}update(e){let t=this.current;if(!t)return;if(this.elapsed+=e,this.phase===`fadeIn`){let e=this.fadeIn,n=e>0?Math.min(1,this.elapsed/e):1,r=mD.easeOutCubic(n);t.alpha=r,t.scale.set(this.scaleFrom+(1-this.scaleFrom)*r),n>=1&&this.advance();return}if(this.phase===`hold`){this.elapsed>=this.hold&&this.advance();return}let n=this.fadeOut,r=n>0?Math.min(1,this.elapsed/n):1;t.alpha=1-r,r>=1&&this.finish()}advance(){this.phase=this.phase===`fadeIn`?`hold`:`fadeOut`,this.elapsed=0}finish(){let e=this.current;if(!e)return;this.removeChild(e),e.destroy({children:!0}),this.current=null;let t=this.queue.shift();t&&this.start(t)}},$O=class extends K{constructor(e){super(),this.topics=e.topics;let t=e.listWidth??Math.floor(e.width/3),n=t+MO().spacing;this.list=new VO({width:t,height:e.height,items:this.topics.map(e=>({text:e.title})),onHighlight:(e,t)=>this.showBody(t),onSelect:(e,t)=>this.showBody(t)}),this.addChild(this.list),this.body=new FO({wrapWidth:e.width-n}),this.body.x=n,this.addChild(this.body),this.topics.length>0&&this.showBody(this.list.selectedIndex)}showBody(e){this.body.setText(this.topics[e]?.body??``)}handleAction(e){return this.list.handleAction(e)}},ek=class extends K{constructor(e){super(),this.backdrop=new px,this.progress=new YO({width:240,height:10,value:0}),this.width_=e.width,this.height_=e.height,this.onRetry=e.onRetry,this.onCancel=e.onCancel,this.title=new FO({text:e.title??`Loading`,size:18,bold:!0,align:`center`}),this.status=new FO({text:`Preparing...`,align:`center`}),this.addChild(this.backdrop,this.title,this.status,this.progress),this.layout()}setSnapshot(e){let t=e.total>0?e.completed/e.total:0;this.progress.setValue(t),e.status===`failed`?this.status.setText(`Loading failed. Retry or cancel.`):e.status===`cancelled`?this.status.setText(`Loading cancelled.`):e.status===`ready`?this.status.setText(`Ready`):this.status.setText(e.current?`Loading ${e.current}...`:`Preparing...`)}bind(e){this.setSnapshot(e.snapshot);let t=e=>this.setSnapshot(e);return e.changed.add(t),()=>e.changed.remove(t)}retry(){this.onRetry?.()}cancel(){this.onCancel?.()}resize(e,t){this.width_=e,this.height_=t,this.layout()}layout(){let e=MO().color;this.backdrop.clear().rect(0,0,this.width_,this.height_).fill({color:e.overlay,alpha:.92});let t=this.width_/2,n=this.height_/2;this.title.anchor.set(.5),this.status.anchor.set(.5),this.title.position.set(t,n-36),this.status.position.set(t,n-8),this.progress.position.set(t-120,n+16)}},tk={farLeft:.12,left:.28,center:.5,right:.72,farRight:.88},nk=class extends K{constructor(e,t){super(),this.backdropLayer=new K,this.actorLayer=new K,this.backdrop=null,this.outgoingBackdrop=null,this.actors=new Map,this.definitions=new Map,this.focused=null,this.tweener=new hD,this.dimAmount=.45,this.stageWidth=e,this.stageHeight=t,this.addChild(this.backdropLayer),this.addChild(this.actorLayer)}defineCharacter(e,t){this.definitions.set(e,t)}resize(e,t){this.stageWidth=e,this.stageHeight=t;for(let e of[this.backdrop,this.outgoingBackdrop])e&&this.fitBackdrop(e);for(let e of this.actors.values())this.placeActor(e)}setBackdrop(e,t=.4){this.outgoingBackdrop?.destroy();let n=this.backdrop;this.outgoingBackdrop=n;let r=new Ui(e);this.fitBackdrop(r),this.backdrop=r,this.backdropLayer.addChild(r);let i=()=>{this.outgoingBackdrop===n&&(n?.destroy(),this.outgoingBackdrop=null)};return t<=0?(i(),Promise.resolve()):(r.alpha=0,this.tweener.tween(t,e=>{r.alpha=e}).then(i))}fitBackdrop(e){let t=e.texture,n=Math.max(this.stageWidth/t.width,this.stageHeight/t.height);e.scale.set(n),e.x=Math.round((this.stageWidth-t.width*n)/2),e.y=Math.round((this.stageHeight-t.height*n)/2)}show(e,t={}){let n=this.definitions.get(e);if(!n)throw Error(`no character defined as "${e}"`);let r=t.expression??Object.keys(n.expressions)[0],i=this.actors.get(e);if(i)return t.at!==void 0&&(i.slot=this.slotOf(t.at)),this.setExpression(e,r),this.placeActor(i),Promise.resolve();let a=new ID(n.sheet.get(n.expressions[r])),o={id:e,sprite:a,definition:n,slot:this.slotOf(t.at??`center`),expression:r};this.actors.set(e,o),this.actorLayer.addChild(a),this.placeActor(o),this.applyFocus();let s=t.fade??.25;return s<=0?Promise.resolve():(a.alpha=0,this.tweener.tween(s,e=>{a.alpha=e}))}hide(e,t=.25){let n=this.actors.get(e);return n?(this.actors.delete(e),this.focused===e&&(this.focused=null),this.applyFocus(),t<=0?(n.sprite.destroy(),Promise.resolve()):this.tweener.tween(t,e=>{n.sprite.alpha=1-e}).then(()=>n.sprite.destroy())):Promise.resolve()}hideAll(e=.25){return Promise.all([...this.actors.keys()].map(t=>this.hide(t,e))).then(()=>void 0)}setExpression(e,t){let n=this.actors.get(e);if(!n)return;let r=n.definition.expressions[t];if(r===void 0)throw Error(`character "${e}" has no expression "${t}"`);n.expression=t,n.sprite.texture=n.definition.sheet.get(r)}focus(e){this.focused=e,this.applyFocus()}applyFocus(){let e=Math.round(255*(1-this.dimAmount)),t=e<<16|e<<8|e;for(let e of this.actors.values()){let n=this.focused!==null&&e.id!==this.focused;e.sprite.tint=n?t:16777215}}slotOf(e){return typeof e==`number`?e:tk[e]}placeActor(e){let t=e.definition,n=(t.height??.7)*this.stageHeight,r=n/t.sheet.frameHeight;e.sprite.scale.set(r),e.sprite.x=Math.round(e.slot*this.stageWidth-t.sheet.frameWidth*r/2),e.sprite.y=Math.round((t.baseline??.92)*this.stageHeight-n)}update(e){this.tweener.update(e)}get isBusy(){return this.tweener.isBusy}},rk=class{constructor(e){this.state={answers:{}},this.cancelled=!1,this.historyLog=[],this.seenLines=new Set,this.skipSeen=!1,this.options=e}cancel(){this.cancelled=!0}get history(){return this.historyLog}async showLast(){let e=this.historyLog.at(-1);if(!e)return!1;let{windows:t}=this.options;return await new Promise(n=>{t.push(new UO({width:this.options.boxWidth??480,height:this.options.boxHeight??120,speed:0,pages:[{text:e.text,speaker:e.speaker}],dims:!1,anchor:`bottom`,onDone:()=>n()}))}),!0}async run(e){for(let t of e){if(this.cancelled)break;let e=await this.step(t);if(e!==void 0)throw Error(`a "goto ${e}" only runs inside runStory, not a straight run`)}return this.state}async runStory(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(`this story has no passage named "${t}"`);let n=e[t],r=0;for(;r<n.length&&!this.cancelled;){let t=await this.step(n[r]);if(r++,t!==void 0){if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(`this story has no passage named "${t}"`);n=e[t],r=0}}return this.state}async step(e){let{stage:t}=this.options;if(`backdrop`in e){await t.setBackdrop(this.options.backdrop(e.backdrop),e.fade);return}if(`show`in e){await t.show(e.show,{at:e.at,expression:e.expression,fade:e.fade});return}if(`hide`in e){await t.hide(e.hide,e.fade);return}if(`hideAll`in e){await t.hideAll(e.fade);return}if(`expression`in e){t.setExpression(e.of,e.expression);return}if(`say`in e){await this.speak(e.say,e.as,e.speaker),this.recordHistory(e.say,e.as,e.speaker);return}if(`ask`in e){let t=await this.speak(e.ask,e.as,e.speaker,e.choices);return this.recordHistory(e.ask,e.as,e.speaker,t),e.store&&(this.state.answers[e.store]=t),e.choices.find(e=>(e.value??e.text)===t)?.goto}if(`goto`in e)return e.goto;if(`wait`in e){await new Promise(t=>setTimeout(t,e.wait*1e3));return}`call`in e&&await e.call(this.state)}recordHistory(e,t,n,r){let i=n??(t?this.options.displayName?.(t)??t:void 0);this.seenLines.add(ik(t,e)),this.historyLog.push({text:e,speaker:i,chosen:r})}speak(e,t,n,r){let{stage:i,windows:a}=this.options;i.focus(t??null);let o=n??(t?this.options.displayName?.(t)??t:void 0),s=this.skipSeen&&!r&&this.seenLines.has(ik(t,e));return new Promise(t=>{a.push(new UO({width:this.options.boxWidth??480,height:this.options.boxHeight??120,speed:s?0:this.options.speed??45,autoAdvance:s?0:void 0,mode:this.options.mode,pages:[{text:e,speaker:o}],choices:r,dims:!1,anchor:`bottom`,onDone:e=>t(e)}))})}};function ik(e,t){return`${e??``}${t}`}function ak(e){let t=ok(e);if(t.length===0)throw Error(`this twee source has no passages - passages start with ":: Name"`);let n={},r,i;for(let e of t){if(e.name===`StoryTitle`){r=e.body.trim()||void 0;continue}if(e.name===`StoryData`){i=ck(e.body);continue}if(Object.prototype.hasOwnProperty.call(n,e.name))throw Error(`this twee source defines "${e.name}" twice`);n[e.name]=lk(e.name,e.body)}let a=Object.keys(n);if(a.length===0)throw Error(`this twee source has no story passages, only StoryTitle/StoryData`);if(i!==void 0&&!Object.prototype.hasOwnProperty.call(n,i))throw Error(`StoryData starts at "${i}", which is not a passage in this file`);for(let[e,t]of Object.entries(n))for(let r of t)if(`ask`in r){for(let t of r.choices)if(t.goto!==void 0&&!Object.prototype.hasOwnProperty.call(n,t.goto))throw Error(`passage "${e}" links to "${t.goto}", which is not a passage in this file`)}return{story:n,start:i??a[0],title:r}}function ok(e){let t=[],n=null,r=[],i=()=>{n!==null&&t.push({name:n,body:r.join(`
1262
1262
  `)})};for(let t of e.split(`
1263
1263
  `))t.startsWith(`::`)?(i(),n=sk(t),r=[]):n!==null&&r.push(t);return i(),t}function sk(e){let t=e.slice(2).trim(),n=t.search(/[[{]/),r=(n===-1?t:t.slice(0,n)).trim();if(!r)throw Error(`a twee passage header needs a name, got "${e}"`);return r}function ck(e){let t;try{t=JSON.parse(e.trim())}catch{throw Error(`StoryData must be JSON - check the braces`)}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`StoryData must be a JSON object`);let n=t.start;if(n!==void 0&&typeof n!=`string`)throw Error(`StoryData "start" must be a passage name`);return n}function lk(e,t){let n=[],r=[];for(let i of t.split(`
1264
1264
  `)){let t=uk(i,r,e).replace(/\s+/g,` `).trim();t!==``&&n.push(t)}if(r.length===0)return n.map(e=>({say:e}));let i=n.pop()??``;return[...n.map(e=>({say:e})),{ask:i,choices:r}]}function uk(e,t,n){let r=``,i=e;for(;;){let a=i.indexOf(`[[`);if(a===-1)return r+i;let o=i.indexOf(`]]`,a);if(o===-1)throw Error(`passage "${n}" has a "[[" with no closing "]]" in "${e.trim()}"`);r+=i.slice(0,a),t.push(dk(i.slice(a+2,o),n)),i=i.slice(o+2)}}function dk(e,t){if(e.includes(`[`)||e.includes(`]`))throw Error(`passage "${t}" links with a setter ("${e.trim()}") - story-format macros are not imported, so the link is refused rather than half-read`);let n=e.indexOf(`->`);if(n!==-1)return{text:e.slice(0,n).trim(),goto:e.slice(n+2).trim()};let r=e.indexOf(`<-`);if(r!==-1)return{text:e.slice(r+2).trim(),goto:e.slice(0,r).trim()};let i=e.trim();return{text:i,goto:i}}function fk(e){return e===4?[[0,-1],[1,0],[0,1],[-1,0]]:[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]]}var pk={passable:!1,transparent:!1},mk={passable:!0,transparent:!0},hk=class e{constructor(e,t,n,r=0,i=`square`){this.rooms=[],this.width=e,this.shape=i,this.height=t,this.kinds=n,this.terrain=new Uint8Array(e*t).fill(r)}get cellCount(){return this.width*this.height}index(e,t){return t*this.width+e}xOf(e){return e%this.width}yOf(e){return Math.floor(e/this.width)}inside(e,t){return e>=0&&t>=0&&e<this.width&&t<this.height}neighbors(e,t,n=8){return this.shape===`hex`?sD(e,t):fk(n).map(([n,r])=>({x:e+n,y:t+r}))}insideWithBorder(e,t){return e>0&&t>0&&e<this.width-1&&t<this.height-1}get(e,t){return this.inside(e,t)?this.terrain[this.index(e,t)]:0}set(e,t,n){this.inside(e,t)&&(this.terrain[this.index(e,t)]=n)}kindAt(e,t){return this.kinds[this.get(e,t)]??pk}passable(e,t){return this.inside(e,t)&&this.kindAt(e,t).passable}transparent(e,t){return this.inside(e,t)&&this.kindAt(e,t).transparent}fillRect(e,t){for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++)this.set(r,n,t)}passableCells(){let e=[];for(let t=0;t<this.terrain.length;t++)this.kinds[this.terrain[t]]?.passable&&e.push(t);return e}toJSON(){return{width:this.width,height:this.height,shape:this.shape,terrain:[...this.terrain],rooms:this.rooms.map(e=>({...e}))}}static fromJSON(t,n){let r=new e(n.width,n.height,t,0,n.shape);return r.terrain.set(n.terrain.slice(0,r.terrain.length)),r.rooms=n.rooms.map(e=>({...e})),r}};function gk(e){return{x:Math.floor((e.left+e.right)/2),y:Math.floor((e.top+e.bottom)/2)}}function _k(e,t,n=0){return!(e.right+n<t.left||t.right+n<e.left||e.bottom+n<t.top||t.bottom+n<e.top)}var vk=[{passable:!1,transparent:!1},{passable:!0,transparent:!0}];function yk(e){let{width:t,height:n,rooms:r=14,minRoomSize:i=4,maxRoomSize:a=10,extraCorridors:o=3,wall:s=0,floor:c=1,kinds:l=[]}=e,u=new hk(t,n,[...vk,...l],s),d=[];for(let e=0;e<r*6&&d.length<r;e++){let e=CE(i,a),r=CE(i,a),o=SE(1,Math.max(2,t-e-1)),s=SE(1,Math.max(2,n-r-1)),l={left:o,top:s,right:o+e-1,bottom:s+r-1};l.right>=t-1||l.bottom>=n-1||d.some(e=>_k(l,e,2))||(d.push(l),u.fillRect(l,c))}for(let e=1;e<d.length;e++)bk(u,gk(d[e-1]),gk(d[e]),c);for(let e=0;e<o&&d.length>2;e++){let e=d[SE(d.length)],t=d[SE(d.length)];e!==t&&bk(u,gk(e),gk(t),c)}return u.rooms=d,u}function bk(e,t,n,r){TE(.5)?(xk(e,t.x,n.x,t.y,!0,r),xk(e,t.y,n.y,n.x,!1,r)):(xk(e,t.y,n.y,t.x,!1,r),xk(e,t.x,n.x,n.y,!0,r))}function xk(e,t,n,r,i,a){let o=t<=n?1:-1;for(let s=t;s!==n+o;s+=o){let t=i?s:r,n=i?r:s;e.insideWithBorder(t,n)&&e.set(t,n,a)}}function Sk(e,t=new Set){let n=e.passableCells().filter(e=>!t.has(e));return n.length>0?n[SE(n.length)]:null}function Ck(e,t){let n=null,r=-1;for(let i of e.rooms){let e=gk(i),a=(e.x-t.x)**2+(e.y-t.y)**2;a>r&&(r=a,n=i)}return n}var wk=23283064365386963e-26;new class e{constructor(){this._seed=0,this._s0=0,this._s1=0,this._s2=0,this._c=0}getSeed(){return this._seed}setSeed(e){return e=e<1?1/e:e,this._seed=e,this._s0=(e>>>0)*wk,e=e*69069+1>>>0,this._s1=e*wk,e=e*69069+1>>>0,this._s2=e*wk,this._c=1,this}getUniform(){let e=2091639*this._s0+this._c*wk;return this._s0=this._s1,this._s1=this._s2,this._c=e|0,this._s2=e-this._c,this._s2}getUniformInt(e,t){let n=Math.max(e,t),r=Math.min(e,t);return Math.floor(this.getUniform()*(n-r+1))+r}getNormal(e=0,t=1){let n,r,i;do n=2*this.getUniform()-1,r=2*this.getUniform()-1,i=n*n+r*r;while(i>1||i==0);return e+n*Math.sqrt(-2*Math.log(i)/i)*t}getPercentage(){return 1+Math.floor(this.getUniform()*100)}getItem(e){return e.length?e[Math.floor(this.getUniform()*e.length)]:null}shuffle(e){let t=[],n=e.slice();for(;n.length;){let e=n.indexOf(this.getItem(n));t.push(n.splice(e,1)[0])}return t}getWeightedValue(e){let t=0;for(let n in e)t+=e[n];let n=this.getUniform()*t,r,i=0;for(r in e)if(i+=e[r],n<i)return r;return r}getState(){return[this._s0,this._s1,this._s2,this._c]}setState(e){return this._s0=e[0],this._s1=e[1],this._s2=e[2],this._c=e[3],this}clone(){return new e().setState(this.getState())}}().setSeed(Date.now());var Tk=class{getContainer(){return null}setOptions(e){this._options=e}},Ek=class extends Tk{constructor(){super(),this._ctx=document.createElement(`canvas`).getContext(`2d`)}schedule(e){requestAnimationFrame(e)}getContainer(){return this._ctx.canvas}setOptions(e){super.setOptions(e);let t=`${e.fontStyle?`${e.fontStyle} `:``} ${e.fontSize}px ${e.fontFamily}`;this._ctx.font=t,this._updateSize(),this._ctx.font=t,this._ctx.textAlign=`center`,this._ctx.textBaseline=`middle`}clear(){let e=this._ctx.globalCompositeOperation;this._ctx.globalCompositeOperation=`copy`,this._ctx.fillStyle=this._options.bg,this._ctx.fillRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height),this._ctx.globalCompositeOperation=e}eventToPosition(e,t){let n=this._ctx.canvas,r=n.getBoundingClientRect();return e-=r.left,t-=r.top,e*=n.width/r.width,t*=n.height/r.height,e<0||t<0||e>=n.width||t>=n.height?[-1,-1]:this._normalizedEventToPosition(e,t)}};function Dk(e){return e.charAt(0).toUpperCase()+e.substring(1)}function Ok(e,...t){let n=Ok.map;return e.replace(/%(?:([a-z]+)|(?:{([^}]+)}))/gi,function(r,i,a,o){if(e.charAt(o-1)==`%`)return r.substring(1);if(!t.length)return r;let s=t[0],c=(i||a).split(`,`),l=c.shift()||``,u=n[l.toLowerCase()];if(!u)return r;s=t.shift();let d=s[u].apply(s,c),f=l.charAt(0);return f!=f.toLowerCase()&&(d=Dk(d)),d})}Ok.map={s:`toString`};var kk=class e extends Ek{constructor(){super(),this._spacingX=0,this._spacingY=0,this._canvasCache={}}setOptions(e){super.setOptions(e),this._canvasCache={}}draw(t,n){e.cache?this._drawWithCache(t):this._drawNoCache(t,n)}_drawWithCache(e){let[t,n,r,i,a]=e,o=``+r+i+a,s;if(o in this._canvasCache)s=this._canvasCache[o];else{let e=this._options.border;s=document.createElement(`canvas`);let t=s.getContext(`2d`);if(s.width=this._spacingX,s.height=this._spacingY,t.fillStyle=a,t.fillRect(e,e,s.width-e,s.height-e),r){t.fillStyle=i,t.font=this._ctx.font,t.textAlign=`center`,t.textBaseline=`middle`;let e=[].concat(r);for(let n=0;n<e.length;n++)t.fillText(e[n],this._spacingX/2,Math.ceil(this._spacingY/2))}this._canvasCache[o]=s}this._ctx.drawImage(s,t*this._spacingX,n*this._spacingY)}_drawNoCache(e,t){let[n,r,i,a,o]=e;if(t){let e=this._options.border;this._ctx.fillStyle=o,this._ctx.fillRect(n*this._spacingX+e,r*this._spacingY+e,this._spacingX-e,this._spacingY-e)}if(!i)return;this._ctx.fillStyle=a;let s=[].concat(i);for(let e=0;e<s.length;e++)this._ctx.fillText(s[e],(n+.5)*this._spacingX,Math.ceil((r+.5)*this._spacingY))}computeSize(e,t){return[Math.floor(e/this._spacingX),Math.floor(t/this._spacingY)]}computeFontSize(e,t){let n=Math.floor(e/this._options.width),r=Math.floor(t/this._options.height),i=this._ctx.font;this._ctx.font=`100px `+this._options.fontFamily;let a=Math.ceil(this._ctx.measureText(`W`).width);this._ctx.font=i;let o=a/100*r/n;return o>1&&(r=Math.floor(r/o)),Math.floor(r/this._options.spacing)}_normalizedEventToPosition(e,t){return[Math.floor(e/this._spacingX),Math.floor(t/this._spacingY)]}_updateSize(){let e=this._options,t=Math.ceil(this._ctx.measureText(`W`).width);this._spacingX=Math.ceil(e.spacing*t),this._spacingY=Math.ceil(e.spacing*e.fontSize),e.forceSquareRatio&&(this._spacingX=this._spacingY=Math.max(this._spacingX,this._spacingY)),this._ctx.canvas.width=e.width*this._spacingX,this._ctx.canvas.height=e.height*this._spacingY}};kk.cache=!1;var Ak={4:[[0,-1],[1,0],[0,1],[-1,0]],8:[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]],6:[[-1,-1],[1,-1],[2,0],[1,1],[-1,1],[-2,0]]},jk=class{constructor(e,t={}){this._lightPasses=e,this._options=Object.assign({topology:8},t)}_getCircle(e,t,n){let r=[],i,a,o;switch(this._options.topology){case 4:a=1,o=[0,1],i=[Ak[8][7],Ak[8][1],Ak[8][3],Ak[8][5]];break;case 6:i=Ak[6],a=1,o=[-1,1];break;case 8:i=Ak[4],a=2,o=[-1,1];break;default:throw Error(`Incorrect topology for FOV computation`)}let s=e+o[0]*n,c=t+o[1]*n;for(let e=0;e<i.length;e++)for(let t=0;t<n*a;t++)r.push([s,c]),s+=i[e][0],c+=i[e][1];return r}},Mk=class extends jk{compute(e,t,n,r){if(r(e,t,0,1),!this._lightPasses(e,t))return;let i=[],a,o,s,c,l;for(let u=1;u<=n;u++){let n=this._getCircle(e,t,u),d=360/n.length;for(let e=0;e<n.length;e++)if(s=n[e][0],c=n[e][1],a=d*(e-.5),o=a+d,l=!this._lightPasses(s,c),this._visibleCoords(Math.floor(a),Math.ceil(o),l,i)&&r(s,c,u,1),i.length==2&&i[0]==0&&i[1]==360)return}}_visibleCoords(e,t,n,r){if(e<0){let i=this._visibleCoords(0,t,n,r),a=this._visibleCoords(360+e,360,n,r);return i||a}let i=0;for(;i<r.length&&r[i]<e;)i++;if(i==r.length)return n&&r.push(e,t),!0;let a=0;if(i%2){for(;i<r.length&&r[i]<t;)i++,a++;return a!=0&&(n&&(a%2?r.splice(i-a,a,t):r.splice(i-a,a)),!0)}for(;i<r.length&&r[i]<t;)i++,a++;return e==r[i-a]&&a==1?!1:(n&&(a%2?r.splice(i-a,a,e):r.splice(i-a,a,e,t)),!0)}},Nk=class extends jk{compute(e,t,n,r){if(r(e,t,0,1),!this._lightPasses(e,t))return;let i=[],a,o,s,c,l,u;for(let d=1;d<=n;d++){let n=this._getCircle(e,t,d),f=n.length;for(let e=0;e<f;e++)if(a=n[e][0],o=n[e][1],c=[e?2*e-1:2*f-1,2*f],l=[2*e+1,2*f],s=!this._lightPasses(a,o),u=this._checkVisibility(c,l,s,i),u&&r(a,o,d,u),i.length==2&&i[0][0]==0&&i[1][0]==i[1][1])return}}_checkVisibility(e,t,n,r){if(e[0]>t[0])return(this._checkVisibility(e,[e[1],e[1]],n,r)+this._checkVisibility([0,1],t,n,r))/2;let i=0,a=!1;for(;i<r.length;){let t=r[i],n=t[0]*e[1]-e[0]*t[1];if(n>=0){n==0&&!(i%2)&&(a=!0);break}i++}let o=r.length,s=!1;for(;o--;){let e=r[o],n=t[0]*e[1]-e[0]*t[1];if(n>=0){n==0&&o%2&&(s=!0);break}}let c=!0;if((i==o&&(a||s)||a&&s&&i+1==o&&o%2||i>o&&i%2)&&(c=!1),!c)return 0;let l,u=o-i+1;if(u%2){if(i%2){let e=r[i];l=(t[0]*e[1]-e[0]*t[1])/(e[1]*t[1]),n&&r.splice(i,u,t)}else{let t=r[o];l=(t[0]*e[1]-e[0]*t[1])/(e[1]*t[1]),n&&r.splice(i,u,e)}}else if(i%2){let e=r[i],t=r[o];l=(t[0]*e[1]-e[0]*t[1])/(e[1]*t[1]),n&&r.splice(i,u)}else return n&&r.splice(i,u,e,t),1;let d=(t[0]*e[1]-e[0]*t[1])/(e[1]*t[1]);return l/d}},Pk=[[-1,0,0,1],[0,-1,1,0],[0,-1,-1,0],[-1,0,0,-1],[1,0,0,-1],[0,1,-1,0],[0,1,1,0],[1,0,0,1]],Fk={DiscreteShadowcasting:Mk,PreciseShadowcasting:Nk,RecursiveShadowcasting:class extends jk{compute(e,t,n,r){r(e,t,0,1);for(let i=0;i<Pk.length;i++)this._renderOctant(e,t,Pk[i],n,r)}compute180(e,t,n,r,i){i(e,t,0,1);let a=(r-1+8)%8,o=(r-2+8)%8,s=(r+1+8)%8;this._renderOctant(e,t,Pk[o],n,i),this._renderOctant(e,t,Pk[a],n,i),this._renderOctant(e,t,Pk[r],n,i),this._renderOctant(e,t,Pk[s],n,i)}compute90(e,t,n,r,i){i(e,t,0,1);let a=(r-1+8)%8;this._renderOctant(e,t,Pk[r],n,i),this._renderOctant(e,t,Pk[a],n,i)}_renderOctant(e,t,n,r,i){this._castVisibility(e,t,1,1,0,r+1,n[0],n[1],n[2],n[3],i)}_castVisibility(e,t,n,r,i,a,o,s,c,l,u){if(!(r<i))for(let d=n;d<=a;d++){let n=-d-1,f=-d,p=!1,m=0;for(;n<=0;){n+=1;let h=e+n*o+f*s,g=t+n*c+f*l,_=(n-.5)/(f+.5),v=(n+.5)/(f-.5);if(!(v>r)){if(_<i)break;if(n*n+f*f<a*a&&u(h,g,d,1),!p)!this._lightPasses(h,g)&&d<a&&(p=!0,this._castVisibility(e,t,d+1,r,_,a,o,s,c,l,u),m=v);else{if(!this._lightPasses(h,g)){m=v;continue}p=!1,r=m}}}if(p)break}}}};.5*(Math.sqrt(3)-1),(3-Math.sqrt(3))/6;var Ik=class{constructor(e,t,n,r={}){this._toX=e,this._toY=t,this._passableCallback=n,this._options=Object.assign({topology:8},r),this._dirs=Ak[this._options.topology],this._options.topology==8&&(this._dirs=[this._dirs[0],this._dirs[2],this._dirs[4],this._dirs[6],this._dirs[1],this._dirs[3],this._dirs[5],this._dirs[7]])}_getNeighbors(e,t){let n=[];for(let r=0;r<this._dirs.length;r++){let i=this._dirs[r],a=e+i[0],o=t+i[1];this._passableCallback(a,o)&&n.push([a,o])}return n}},Lk={Dijkstra:class extends Ik{constructor(e,t,n,r){super(e,t,n,r),this._computed={},this._todo=[],this._add(e,t,null)}compute(e,t,n){let r=e+`,`+t;if(r in this._computed||this._compute(e,t),!(r in this._computed))return;let i=this._computed[r];for(;i;)n(i.x,i.y),i=i.prev}_compute(e,t){for(;this._todo.length;){let n=this._todo.shift();if(n.x==e&&n.y==t)return;let r=this._getNeighbors(n.x,n.y);for(let e=0;e<r.length;e++){let t=r[e],i=t[0],a=t[1];i+`,`+a in this._computed||this._add(i,a,n)}}}_add(e,t,n){let r={x:e,y:t,prev:n};this._computed[e+`,`+t]=r,this._todo.push(r)}},AStar:class extends Ik{constructor(e,t,n,r={}){super(e,t,n,r),this._todo=[],this._done={}}compute(e,t,n){for(this._todo=[],this._done={},this._fromX=e,this._fromY=t,this._add(this._toX,this._toY,null);this._todo.length;){let n=this._todo.shift(),r=n.x+`,`+n.y;if(r in this._done)continue;if(this._done[r]=n,n.x==e&&n.y==t)break;let i=this._getNeighbors(n.x,n.y);for(let e=0;e<i.length;e++){let t=i[e],r=t[0],a=t[1];r+`,`+a in this._done||this._add(r,a,n)}}let r=this._done[e+`,`+t];if(r)for(;r;)n(r.x,r.y),r=r.prev}_add(e,t,n){let r=this._distance(e,t),i={x:e,y:t,prev:n,g:n?n.g+1:0,h:r},a=i.g+i.h;for(let e=0;e<this._todo.length;e++){let t=this._todo[e],n=t.g+t.h;if(a<n||a==n&&r<t.h){this._todo.splice(e,0,i);return}}this._todo.push(i)}_distance(e,t){switch(this._options.topology){case 4:return Math.abs(e-this._fromX)+Math.abs(t-this._fromY);case 6:let n=Math.abs(e-this._fromX),r=Math.abs(t-this._fromY);return r+Math.max(0,(n-r)/2);case 8:return Math.max(Math.abs(e-this._fromX),Math.abs(t-this._fromY))}}}};function Rk(e,t){return Math.max(Math.abs(e.x-t.x),Math.abs(e.y-t.y))}function zk(e,t){let n=[],r=e.x,i=e.y,a=Math.abs(t.x-e.x),o=-Math.abs(t.y-e.y),s=e.x<t.x?1:-1,c=e.y<t.y?1:-1,l=a+o;for(;n.push({x:r,y:i}),r!==t.x||i!==t.y;){let e=l*2;e>=o&&(l+=o,r+=s),e<=a&&(l+=a,i+=c)}return n}function Bk(e,t,n){let r=zk(t,n);for(let t=1;t<r.length-1;t++)if(!e.transparent(r[t].x,r[t].y))return!1;return!0}function Vk(e,t,n,r){return!(Rk(t,n)>r.range||(r.requireLineOfSight??!0)&&!Bk(e,t,n))}function Hk(e,t,n){switch(n.kind){case`single`:return[t];case`line`:return zk(e,t);case`cone`:return Uk(e,t,n.width);case`burst`:{let e=[],r=n.radius;for(let n=-r;n<=r;n++)for(let i=-r;i<=r;i++)i*i+n*n>r*r||e.push({x:t.x+i,y:t.y+n});return e}}}function Uk(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.max(Math.abs(r),Math.abs(i));if(a===0)return[{...e}];let o=Math.sign(r),s=Math.sign(i),c=r!==0&&i!==0?o:s,l=r!==0&&i!==0?-s:o,u=[];for(let t=1;t<=a;t++){let r=e.x+o*t,i=e.y+s*t,d=Math.round(t/a*n);for(let e=-d;e<=d;e++)u.push({x:r+c*e,y:i+l*e})}return u}function Wk(e,t,n,r){let i=new Set,a=[],o=t;for(let t=0;t<n;t++){let t=-1,n=r+1;for(let a=0;a<e.length;a++){if(i.has(a))continue;let s=Rk(o,e[a]);s<=r&&s<n&&(n=s,t=a)}if(t===-1)break;i.add(t),a.push(e[t]),o=e[t]}return a}function Gk(e,t,n,r){let i=[];for(let a=1;a<=r;a++){let r={x:t.x+n.x*a,y:t.y+n.y*a};if(!e.passable(r.x,r.y))break;i.push(r)}return i}var Kk=class{constructor(e){this.visible=new Set,this.explored=new Set,this.light=new Map,this.level=e,this.fov=e.shape===`hex`?null:new Fk.PreciseShadowcasting((t,n)=>e.transparent(t,n))}update(e,t,n,r){if(this.visible.clear(),this.light.clear(),r){this.updateFromHeight(e,t,n,r);return}if(this.fov){this.fov.compute(e,t,n,(e,t,n,r)=>{if(!this.level.inside(e,t))return;let i=this.level.index(e,t);this.visible.add(i),this.explored.add(i),this.light.set(i,r)});return}let i={x:e,y:t};for(let e of dD(i,n)){if(!this.level.inside(e.x,e.y))continue;let t=uD(i,e);t.slice(1,-1).some(e=>!this.level.inside(e.x,e.y)||!this.level.transparent(e.x,e.y))||this.lightCell(e.x,e.y,t.length-1,n)}}lightCell(e,t,n,r){let i=this.level.index(e,t);this.visible.add(i),this.explored.add(i),this.light.set(i,r===0?1:Math.max(0,1-n/(r+1)))}updateFromHeight(e,t,n,r){let i=r.height??r.heights.heightAt(e,t),a={x:e,y:t};if(this.level.shape===`hex`){for(let e of dD(a,n)){if(!this.level.inside(e.x,e.y))continue;let t=uD(a,e);this.heightBlocked(t,r.heights,i,r.heights.heightAt(e.x,e.y))||this.lightCell(e.x,e.y,t.length-1,n)}return}for(let o=t-n;o<=t+n;o++)for(let t=e-n;t<=e+n;t++){if(!this.level.inside(t,o)||Rk(a,{x:t,y:o})>n)continue;let e=zk(a,{x:t,y:o});this.heightBlocked(e,r.heights,i,r.heights.heightAt(t,o))||this.lightCell(t,o,e.length-1,n)}}heightBlocked(e,t,n,r){let i=Math.max(n,r);for(let n=1;n<e.length-1;n++){let r=e[n];if(!this.level.inside(r.x,r.y)||!this.level.transparent(r.x,r.y)||t.heightAt(r.x,r.y)>i)return!0}return!1}isVisible(e,t){return this.visible.has(this.level.index(e,t))}isExplored(e,t){return this.explored.has(this.level.index(e,t))}lightAt(e,t){return this.light.get(this.level.index(e,t))??0}reset(){this.visible.clear(),this.explored.clear(),this.light.clear()}revealAll(){for(let e=0;e<this.level.cellCount;e++)this.explored.add(e)}},qk=class{constructor(e){this.level=e,this.heights=new Int32Array(e.cellCount)}heightAt(e,t){return this.level.inside(e,t)?this.heights[this.level.index(e,t)]:0}set(e,t,n){if(!Number.isInteger(n))throw Error(`a cell's height must be a whole number, got ${n}`);this.level.inside(e,t)&&(this.heights[this.level.index(e,t)]=n)}},Jk=class{constructor(e){this.level=e}passable(e){let t=e.blocked;return(e,n)=>this.level.passable(e,n)?!t?.has(this.level.index(e,n)):!1}stepper(e){let t=this.passable(e),n=e.heights;if(!n)return(e,n,r,i)=>this.level.inside(e,n)&&this.level.inside(r,i)&&t(r,i);let r=e.climb??1;if(!Number.isInteger(r)||r<0)throw Error(`a climb limit must be a non-negative whole number, got ${e.climb}`);return(e,i,a,o)=>this.level.inside(e,i)&&this.level.inside(a,o)&&t(a,o)&&n.heightAt(a,o)-n.heightAt(e,i)<=r}find(e,t,n={}){if(this.level.shape===`hex`||n.heights){let r=this.distanceMap(t,n),i=[],a=e;for(let e=0;e<this.level.cellCount;e++){let e=this.descend(a,r,n);if(!e||(i.push(e),e.x===t.x&&e.y===t.y))break;a=e}return i}let r=new Lk.AStar(t.x,t.y,this.passable(n),{topology:n.topology??8}),i=[];return r.compute(e.x,e.y,(e,t)=>i.push({x:e,y:t})),i.slice(1)}step(e,t,n={}){return this.find(e,t,n)[0]??null}distanceMap(e,t={}){let n=new Int32Array(this.level.cellCount).fill(-1),r=this.passable(t),i=this.stepper(t);if(!r(e.x,e.y))return n;let a=[this.level.index(e.x,e.y)];n[a[0]]=0;for(let e=0;e<a.length;e++){let r=a[e],o=this.level.xOf(r),s=this.level.yOf(r),c=n[r]+1;for(let e of this.level.neighbors(o,s,t.topology??8)){if(!i(e.x,e.y,o,s))continue;let t=this.level.index(e.x,e.y);n[t]===-1&&(n[t]=c,a.push(t))}}return n}descend(e,t,n={}){let r=this.stepper(n),i=t[this.level.index(e.x,e.y)];if(i<=0)return null;let a=null,o=i;for(let i of this.level.neighbors(e.x,e.y,n.topology??8)){if(!r(e.x,e.y,i.x,i.y))continue;let n=t[this.level.index(i.x,i.y)];n!==-1&&n<o&&(o=n,a=i)}return a}autoExplore(e,t,n={}){let r=this.passable(n),i=this.stepper(n);if(!r(e.x,e.y))return[];let a=new Map,o=new Set([this.level.index(e.x,e.y)]),s=[e];for(let e=0;e<s.length;e++){let r=s[e];if(e>0&&!t.isExplored(r.x,r.y))return this.reconstruct(a,r);for(let e of this.level.neighbors(r.x,r.y,n.topology??8)){if(!i(r.x,r.y,e.x,e.y))continue;let t=this.level.index(e.x,e.y);o.has(t)||(o.add(t),a.set(t,r),s.push(e))}}return[]}reconstruct(e,t){let n=[t],r=e.get(this.level.index(t.x,t.y));for(;r;)n.push(r),r=e.get(this.level.index(r.x,r.y));return n.reverse()}},Yk=class{constructor(){this.entries=[],this.sequence=0,this.now=0}get size(){return this.entries.length}get actors(){return this.entries.map(e=>e.actor)}has(e){return this.entries.some(t=>t.actor===e)}add(e,t=0){this.entries.push({actor:e,time:this.now+t,sequence:this.sequence++}),this.sort()}remove(e){let t=this.entries.findIndex(t=>t.actor===e);t!==-1&&this.entries.splice(t,1)}clear(){this.entries.length=0,this.now=0,this.sequence=0}peek(){let e=this.entries[0];return e?(this.now=Math.max(this.now,e.time),e.actor):null}spend(e){let t=this.entries[0];if(!t)return;let n=t.actor.speed??1;t.time=this.now+e/(n>0?n:1),t.sequence=this.sequence++,this.sort()}timeOf(e){return this.entries.find(t=>t.actor===e)?.time??null}sort(){this.entries.sort((e,t)=>e.time-t.time||e.sequence-t.sequence)}};function Xk(e,t,n,r,i,a={}){let o=a.sightRadius??6,s=a.fleeBelow??0;if((a.disposition??`hostile`)!==`hostile`&&a.provoked!==!0)return{state:`wander`,step:Zk(e,n,a)};let c=new Kk(e);return c.update(n.x,n.y,o),c.isVisible(i.x,i.y)?r<=s?{state:`flee`,step:Qk(e,n,i,a)}:{state:`hunt`,step:t.step(n,i,a)}:{state:`wander`,step:Zk(e,n,a)}}function Zk(e,t,n){let r=$k(e,t,n);return r.length>0?EE(r):null}function Qk(e,t,n,r){let i=$k(e,t,r),a=null,o=eA(t,n);for(let e of i){let t=eA(e,n);t>o&&(o=t,a=e)}return a}function $k(e,t,n){let r=n.blocked,i=[];for(let[a,o]of fk(n.topology??8)){let n={x:t.x+a,y:t.y+o};e.passable(n.x,n.y)&&(r?.has(e.index(n.x,n.y))||i.push(n))}return i}function eA(e,t){return(e.x-t.x)**2+(e.y-t.y)**2}var tA=class e{constructor(e){this.revealedKind=new Map,this.discovered=new Set,this.level=e}conceal(e,t,n,r){let i=this.level.index(e,t);this.revealedKind.set(i,r),this.discovered.delete(i),this.level.set(e,t,n)}isSecret(e,t){let n=this.level.index(e,t);return this.revealedKind.has(n)&&!this.discovered.has(n)}isDiscovered(e,t){return this.discovered.has(this.level.index(e,t))}discover(e,t){if(!this.isSecret(e,t))return!1;let n=this.level.index(e,t);return this.discovered.add(n),this.level.set(e,t,this.revealedKind.get(n)),!0}toJSON(){return{revealed:[...this.revealedKind],discovered:[...this.discovered]}}static fromJSON(t,n){let r=new e(t);for(let[e,t]of n.revealed)r.revealedKind.set(e,t);for(let e of n.discovered)r.discovered.add(e);return r}},nA=class e{constructor(e){this.openKind=new Map,this.closedKind=new Map,this.lockedBy=new Map,this.open_=new Map,this.level=e}place(e,t,n){let r=this.level.index(e,t);this.openKind.set(r,n.open),this.closedKind.set(r,n.closed),this.open_.set(r,n.startOpen??!1),n.locked===void 0?this.lockedBy.delete(r):this.lockedBy.set(r,n.locked),this.level.set(e,t,this.open_.get(r)?n.open:n.closed)}isDoor(e,t){return this.open_.has(this.level.index(e,t))}isOpen(e,t){return this.open_.get(this.level.index(e,t))===!0}isLocked(e,t){return this.lockedBy.has(this.level.index(e,t))}requiredKey(e,t){return this.lockedBy.get(this.level.index(e,t))}open(e,t){let n=this.level.index(e,t);return!this.open_.has(n)||this.open_.get(n)||this.lockedBy.has(n)?!1:(this.open_.set(n,!0),this.level.set(e,t,this.openKind.get(n)),!0)}close(e,t){let n=this.level.index(e,t);return!this.open_.has(n)||!this.open_.get(n)?!1:(this.open_.set(n,!1),this.level.set(e,t,this.closedKind.get(n)),!0)}unlock(e,t){let n=this.level.index(e,t);return this.lockedBy.has(n)?(this.lockedBy.delete(n),!0):!1}toJSON(){let e=[];for(let[t,n]of this.openKind)e.push({cell:t,open:n,closed:this.closedKind.get(t),locked:this.lockedBy.get(t),isOpen:this.open_.get(t)===!0});return{doors:e}}static fromJSON(t,n){let r=new e(t);for(let e of n.doors){let n=t.xOf(e.cell),i=t.yOf(e.cell);r.place(n,i,{open:e.open,closed:e.closed,locked:e.locked,startOpen:e.isOpen})}return r}},rA=class e{constructor(e=[]){this.current=0;for(let t=1;t<e.length;t++)if(e[t]>=e[t-1])throw Error(`boss phase thresholds must descend`);this.thresholds=e}get phase(){return this.current}update(e){let t=0;for(;t<this.thresholds.length&&e<=this.thresholds[t];)t++;let n=[];for(;this.current<t;)this.current++,n.push(this.current);return n}reset(){this.current=0}toJSON(){return{phase:this.current}}static fromJSON(t,n){let r=new e(t);return r.current=n.phase,r}},iA=class e{constructor(e){this.remaining=new Map,this.cooldowns=new Map(Object.entries(e))}tick(){for(let[e,t]of this.remaining)t<=1?this.remaining.delete(e):this.remaining.set(e,t-1)}ready(){let e=[];for(let t of this.cooldowns.keys())this.remaining.has(t)||e.push(t);return e}use(e){let t=this.cooldowns.get(e);return t===void 0||this.remaining.has(e)?!1:(t>0&&this.remaining.set(e,t),!0)}toJSON(){return{remaining:[...this.remaining]}}static fromJSON(t,n){let r=new e(t);for(let[e,t]of n.remaining)r.remaining.set(e,t);return r}},aA=class e{constructor(e,t){this.width=e,this.height=t,this.volume=new Float32Array(e*t)}volumeAt(e,t){return e<0||t<0||e>=this.width||t>=this.height?0:this.volume[t*this.width+e]}total(){let e=0;for(let t=0;t<this.volume.length;t++)e+=this.volume[t];return e}seed(e,t,n){e<0||t<0||e>=this.width||t>=this.height||(this.volume[t*this.width+e]+=n)}spread(e,t=.25,n=.9){let r=new Float32Array(this.volume.length);for(let n=0;n<this.height;n++)for(let i=0;i<this.width;i++){let a=n*this.width+i,o=this.volume[a];if(o<=0)continue;let s=[];for(let[t,r]of fk(4)){let a=i+t,o=n+r;a<0||o<0||a>=this.width||o>=this.height||e(a,o)&&s.push(o*this.width+a)}if(s.length===0)r[a]+=o;else{let e=o*t/s.length;r[a]+=o-e*s.length;for(let t of s)r[t]+=e}}for(let e=0;e<r.length;e++){let t=r[e]*n;this.volume[e]=t<.001?0:t}}cellsAbove(e){let t=[];for(let n=0;n<this.height;n++)for(let r=0;r<this.width;r++){let i=this.volume[n*this.width+r];i>=e&&t.push({x:r,y:n,volume:i})}return t}toJSON(){return{width:this.width,height:this.height,volume:[...this.volume]}}static fromJSON(t){let n=new e(t.width,t.height);return n.volume.set(t.volume.slice(0,n.volume.length)),n}},oA=class{constructor(){this.hooks=[]}on(e,t,n){this.hooks.push({event:e,handler:t,source:n})}offSource(e){this.hooks=this.hooks.filter(t=>t.source!==e)}emit(e,t){for(let n of this.hooks)n.event===e&&n.handler(t)}modifyDamage(e,t,n){let r={attacker:e,defender:t,amount:n,prevented:!1};return this.emit(`beforeDamage`,r),r.amount=Math.max(0,r.amount),r.amount===0&&(r.prevented=!0),r}},sA=class{constructor(e){this.detected=!1,this.radius=e.radius}get isDetected(){return this.detected}checkDetection(e,t){if(this.detected)return!1;let n=t.some(t=>Rk(e,t)<=this.radius);return n&&(this.detected=!0),n}reset(){this.detected=!1}},cA=l({AbilityCycle:()=>iA,Blob:()=>aA,BossPhases:()=>rA,CombatHooks:()=>oA,DUNGEON_KINDS:()=>vk,Doors:()=>nA,Elevation:()=>qk,FLOOR:()=>mk,FieldOfView:()=>Kk,Level:()=>hk,Pathfinder:()=>Jk,Scheduler:()=>Yk,Secrets:()=>tA,Stealth:()=>sA,WALL:()=>pk,canTarget:()=>Vk,chainTargets:()=>Wk,chebyshevDistance:()=>Rk,coneCells:()=>Uk,decideMonsterAI:()=>Xk,findFreeCell:()=>Sk,furthestRoom:()=>Ck,generateDungeon:()=>yk,hasLineOfSight:()=>Bk,knockbackPath:()=>Gk,neighbourOffsets:()=>fk,rectCenter:()=>gk,rectsOverlap:()=>_k,resolveArea:()=>Hk,traceLine:()=>zk});function lA(e,t,n={}){let r={},i=t.replace(/\r/g,``).split(`
1265
- `),a=null,o=``,s=[],c=!1,l=()=>{if(a){if(r[a]!==void 0)throw Error(`Duplicate FTL message: ${a}`);if(s.length){if(!c)throw Error(`FTL select expression is not closed: ${a}`);let t=o.trim().match(/^\{\s*\$([\w-]+)\s*->\s*$/)?.[1];if(!t)throw Error(`Invalid FTL selector: ${o}`);r[a]=dA(e,t,s)}else r[a]=uA(o);a=null,o=``,s=[],c=!1}};for(let e of i){if(!e.trim()||e.trimStart().startsWith(`#`))continue;let t=e.match(/^([\w-]+)\s*=\s*(.*)$/);if(t){l(),a=t[1],o=t[2];continue}if(!a)throw Error(`FTL continuation has no message: ${e}`);if(e.trim()===`}`){if(!s.length||c)throw Error(`Unexpected FTL select terminator: ${e}`);c=!0;continue}if(c)throw Error(`FTL content follows a closed select expression: ${e}`);let n=e.match(/^\s*(\*)?\[([^\]]+)\]\s*(.*)$/);if(n){s.push({key:n[2],value:n[3],default:!!n[1]});continue}if(/^\s+/.test(e)){s.length?s[s.length-1].value+=` ${e.trim()}`:o+=` ${e.trim()}`;continue}throw Error(`Invalid FTL line: ${e}`)}return l(),{locale:e,direction:n.direction??(/^(ar|he|fa|ur)(?:-|$)/i.test(e)?`rtl`:`ltr`),messages:r}}function uA(e){return e.replace(/\{\s*\$([\w-]+)\s*\}/g,`{$1}`).trim()}function dA(e,t,n){let r=n.filter(e=>e.default);if(r.length!==1)throw Error(`FTL select expressions need exactly one default variant`);let i=r[0],a=new Intl.PluralRules(e);return{format(e={}){let r=e[t],o=n.find(e=>e.key===String(r)),s=typeof r==`number`?a.select(r):``;return uA((o??n.find(e=>e.key===s)??i).value)}}}var fA=l({direction:()=>bA,has:()=>CA,locale:()=>yA,parseFTL:()=>lA,reset:()=>DA,setActive:()=>vA,setBase:()=>_A,t:()=>xA,typographic:()=>SA}),pA=null,mA=null,hA=null,gA=null;function _A(e){pA=e}function vA(e){mA=e,hA=e?new Intl.PluralRules(e.locale):null}function yA(){return(mA??pA)?.locale??`en`}function bA(){return(mA??pA)?.direction??`ltr`}function xA(e,t){let n=mA?.messages[e]??pA?.messages[e];if(n===void 0)return e;let r=typeof n==`string`?n:TA(n)?n.format(t):wA(n,t?.count),i=t?EA(r,t):r;return(mA??pA)?.typography===!1?i:SA(i,yA())}function SA(e,t=yA()){return/^(fr|it|nl)(?:-|$)/i.test(t)?e.replace(/([\p{L}])'(?=[\p{L}])/gu,`$1’`):e}function CA(e){return mA?.messages[e]!==void 0||pA?.messages[e]!==void 0}function wA(e,t){return t===void 0?e.other??Object.values(e)[0]??``:e[(hA??(gA??=new Intl.PluralRules(`en`))).select(t)]??e.other??``}function TA(e){return`format`in e}function EA(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?e:String(r)})}function DA(){pA=null,mA=null,hA=null}function OA(e,t){let n=e=>t.filter(t=>t.op===e).sort((e,t)=>(e.order??0)-(t.order??0)),r=e;for(let e of n(`add`))r+=e.value;for(let e of n(`multiply`))r*=e.value;for(let e of n(`set`))r=e.value;return r}var kA=class{constructor(e){this.modifiers=[],this.cache=null,this.baseValues={...e.base},this.derived=e.derived??[]}base(e){return this.baseValues[e]??0}setBase(e,t){this.baseValues[e]=t,this.cache=null}addModifier(e){this.modifiers.push(e),this.cache=null}removeModifier(e){let t=this.modifiers.indexOf(e);t!==-1&&this.modifiers.splice(t,1),this.cache=null}removeModifiersFrom(e){this.modifiers=this.modifiers.filter(t=>t.source!==e),this.cache=null}get(e){return this.resolveAll()[e]??0}resolveAll(){if(this.cache)return this.cache;let e={...this.baseValues};for(let t of Object.keys(e))e[t]=OA(e[t],this.modifiersFor(t));for(let t of this.derived)e[t.name]=OA(t.from(e),this.modifiersFor(t.name));return this.cache=e,e}modifiersFor(e){return this.modifiers.filter(t=>t.stat===e)}};function AA(e,t,n){return{maxLevel:n,experienceFor:n=>n<=1?0:Math.round(e*(n-1)**t)}}var jA=class{constructor(e,t={}){this.curve=e,this.level=t.level??1,this.experience=t.experience??this.curve.experienceFor(this.level)}get experienceToNext(){return this.level>=this.curve.maxLevel?null:this.curve.experienceFor(this.level+1)-this.experience}addExperience(e){this.experience+=e;let t=0;for(;this.level<this.curve.maxLevel&&this.experience>=this.curve.experienceFor(this.level+1);)this.level++,t++;return t}};function MA(e,t,n=()=>CE(1,20)){return e+n()>=t}var NA=class{constructor(e,t={}){this.available=0,this.stats=e,this.capFor=t.cap??(()=>1/0),this.costFor=t.cost??(()=>1)}get points(){return this.available}grant(e){this.available+=e}canSpend(e){return this.nextRankCost(e)!==null}spend(e){let t=this.nextRankCost(e);if(t===null)return!1;let n=this.stats.base(e);return this.available-=t,this.stats.setBase(e,n+1),!0}nextRankCost(e){let t=this.stats.base(e);if(t>=this.capFor(e))return null;let n=this.costFor(e,t+1);return this.available>=n?n:null}},PA=class{constructor(e,t=null,n={}){this.worn=new Map,this.names=new Set(e),this.stats=t,this.isSlotLocked=n.locked??(()=>!1)}get(e){return this.worn.get(e)}isLocked(e){let t=this.worn.get(e);return t!==void 0&&this.isSlotLocked(e,t)}equip(e,t){if(this.assertSlot(e),this.isLocked(e))return;let n=this.unequip(e);this.worn.set(e,t);for(let e of t.modifiers??[])this.stats?.addModifier({...e,source:t});return n}unequip(e){let t=this.worn.get(e);if(t&&!this.isSlotLocked(e,t))return this.worn.delete(e),this.stats?.removeModifiersFrom(t),t}get slots(){return[...this.names]}assertSlot(e){if(!this.names.has(e))throw Error(`no such equipment slot: "${e}"`)}},FA=class{constructor(e={}){this.slots=[],this.capacity=e.capacity}get items(){return this.slots}get totalWeight(){return this.slots.reduce((e,t)=>e+this.weightOf(t),0)}weightOf(e){return(e.weight??0)*e.quantity+(e.contents?.totalWeight??0)}find(e){return this.slots.find(t=>t.id===e)}add(e){if(this.capacity!==void 0&&this.totalWeight+this.weightOf(e)>this.capacity)return!1;if(e.stackable){let t=this.slots.find(t=>t.id===e.id&&t.stackable);if(t)return t.quantity+=e.quantity,!0}return this.slots.push({...e}),!0}remove(e,t){let n=this.slots.findIndex(t=>t.id===e);if(n===-1)return;let r=this.slots[n];r.quantity-=t??r.quantity,r.quantity<=0&&this.slots.splice(n,1)}};function IA(e,t){let n=new Map;for(let e of t.ingredients)n.set(e.id,(n.get(e.id)??0)+e.quantity);for(let[t,r]of n){let n=e.find(t);if(!n||n.quantity<r)return!1}let r=t.ingredients.map(t=>({...e.find(t.id),quantity:t.quantity}));for(let n of t.ingredients)e.remove(n.id,n.quantity);if(e.add(t.result))return!0;for(let t of r)e.add(t);return!1}function LA(e,t,n){let r=Symbol(`statusEffect`);for(let t of n.modifiers)e.addModifier({...t,source:r});let i=t.add({duration:n.duration,tick:e=>n.tick?.(e),onExpire:()=>e.removeModifiersFrom(r)});return{cancel:()=>{t.remove(i),e.removeModifiersFrom(r)}}}function RA(e){e.identified=!0}function zA(e,t){return e.level=(e.level??0)+t,e.level}function BA(e,t){return e.maxDurability!==void 0&&(e.durability=Math.max(0,(e.durability??e.maxDurability)-t),e.durability<=0)}function VA(e,t){e.maxDurability!==void 0&&(e.durability=Math.min(e.maxDurability,(e.durability??e.maxDurability)+t))}function HA(e,t,n){let r=new Map;for(let t of Object.keys(n.fields))r.set(t,e[t]),e[t]=n.fields[t];let i=()=>{for(let[t,n]of r)e[t]=n},a=t.add({duration:n.duration,tick:e=>n.tick?.(e),onExpire:i});return{cancel:()=>{t.remove(a),i()}}}var UA=class{constructor(e){this.progress=0,this.max=e.max,this.regenRate=e.regenRate,this.value=e.current??e.max}get current(){return this.value}canAfford(e){return this.value>=e}spend(e){return this.canAfford(e)?(this.value-=e,!0):!1}advance(e=1){if(!(this.value>=this.max)){for(this.progress+=e;this.progress>=this.regenRate&&this.value<this.max;)this.progress-=this.regenRate,this.value++;this.value>=this.max&&(this.progress=0)}}};function WA(e){if(e.entries.length===0||!TE(e.chance??1))return null;let t=DE(e.entries.map(e=>e.weight));if(t===-1)return null;let n=e.entries[t];return{id:n.id,quantity:n.quantity??1}}var GA=class e{constructor(e){this.grantedTiers=0,this.balance=0,this.choices=new Map,this.track=e}get points(){return this.balance}openTiers(e){let t=[];return this.track.tiers.forEach((n,r)=>{e>=n.threshold&&t.push(r)}),t}grant(e){let t=0;for(;this.grantedTiers<this.track.tiers.length&&e>=this.track.tiers[this.grantedTiers].threshold;){let e=this.track.tiers[this.grantedTiers];e.kind===`points`&&(this.balance+=e.points??0,t+=e.points??0),this.grantedTiers++}return t}spend(e){return this.balance<e?!1:(this.balance-=e,!0)}choose(e,t,n){let r=this.track.tiers[e];if(!r)throw Error(`no such advancement tier: ${e}`);if(r.kind===`points`)throw Error(`tier ${e} grants points, it has no choice`);if(n<r.threshold)throw Error(`tier ${e} has not opened yet`);if(this.choices.has(e))throw Error(`tier ${e} is already decided`);if(!(r.options??[]).some(e=>e.id===t))throw Error(`tier ${e} has no option "${t}"`);this.choices.set(e,t)}choice(e){return this.choices.get(e)??null}toJSON(){return{grantedTiers:this.grantedTiers,balance:this.balance,choices:[...this.choices]}}static fromJSON(t,n){let r=new e(t);r.grantedTiers=n.grantedTiers,r.balance=n.balance;for(let[e,t]of n.choices)r.choices.set(e,t);return r}};function KA(e){let t=e.entries.filter(e=>e.weight>0);if(t.length===0)return null;let n=DE(t.map(e=>e.weight));return n===-1?null:t[n]}function qA(e){return e.affix}function JA(e,t){e.affix=t.id,t.curse&&(e.cursed=!0)}function YA(e){e.affix!==void 0&&(e.cursed=!1),delete e.affix}function XA(e,t){return t.map(t=>({stat:t.stat,op:t.op,value:t.base+t.perLevel*e}))}function ZA(e){if(e.labels.length<e.kinds.length)throw Error(`not enough appearances: ${e.kinds.length} kinds but only ${e.labels.length} labels`);let t=[...e.labels];for(let e=t.length-1;e>0;e--){let n=SE(0,e+1);[t[e],t[n]]=[t[n],t[e]]}let n=new Map;return e.kinds.forEach((e,r)=>n.set(e,t[r])),n}var QA=class e{constructor(e){this.assigned=new Map,this.tables=e}appearanceOf(e,t){let n=this.assigned.get(e);if(!n){let t=this.tables[e];if(!t)throw Error(`no such appearance category: "${e}"`);n=ZA(t),this.assigned.set(e,n)}let r=n.get(t);if(r===void 0)throw Error(`"${t}" is not in appearance category "${e}"`);return r}toJSON(){return{assigned:[...this.assigned].map(([e,t])=>[e,[...t]])}}static fromJSON(t,n){let r=new e(t);for(let[e,t]of n.assigned)r.assigned.set(e,new Map(t));return r}};function $A(e,t,n,r,i,a){let o=a.prices.get(r);if(!o)return!1;let s=t.find(r);if(!s||s.quantity<i)return!1;let c=o.buy*i;return e.base(a.currency)<c?!1:(t.remove(r,i),n.add({...s,quantity:i})?(e.setBase(a.currency,e.base(a.currency)-c),!0):(t.add({...s,quantity:i}),!1))}function ej(e,t,n,r,i,a){let o=a.prices.get(r);if(!o)return!1;let s=n.find(r);return!s||s.quantity<i?!1:(n.remove(r,i),t.add({...s,quantity:i}),e.setBase(a.currency,e.base(a.currency)+o.sell*i),!0)}function tj(e){let t=Array.isArray(e)?e:[e];for(let e of t)if(!Number.isFinite(e.amount)||e.amount<0)throw Error(`a resource cost must be a non-negative number, "${e.stat}" costs ${e.amount}`);return t}function nj(e){let t=new Map;for(let n of e)t.set(n.stat,(t.get(n.stat)??0)+n.amount);return t}function rj(e,t){return[...nj(tj(t))].every(([t,n])=>e.base(t)>=n)}function ij(e,t){let n=nj(tj(t));if(![...n].every(([t,n])=>e.base(t)>=n))return!1;for(let[t,r]of n)e.setBase(t,e.base(t)-r);return!0}function aj(e,t,n){return kE([...t]).slice(0,Math.min(n,t.length)).map(t=>{let n=Symbol(`trait:${t.name}`);for(let r of t.modifiers)e.addModifier({...r,source:n});return{trait:t,source:n}})}var oj=class{constructor(){this.affected=new Map}update(e,t){let n=new Set(e),r=e.filter(e=>!!e.aura),i=new Set(r);for(let i of r){let r=this.affected.get(i);r||(r=new Map,this.affected.set(i,r));for(let n of e){if(n===i)continue;let e=t(i,n),a=r.get(n);if(e&&!a){let e=Symbol(`aura:${i.aura.name}`);for(let t of i.aura.modifiers)n.stats.addModifier({...t,source:e});r.set(n,e)}else!e&&a&&(n.stats.removeModifiersFrom(a),r.delete(n))}for(let[e,t]of[...r])n.has(e)||(e.stats.removeModifiersFrom(t),r.delete(e))}for(let[e,t]of[...this.affected])if(!i.has(e)){for(let[e,n]of t)e.stats.removeModifiersFrom(n);this.affected.delete(e)}}},sj=class e{constructor(e){if(this.points=new Map,e.some(e=>!e.id||!Number.isFinite(e.threshold)||e.threshold<0))throw Error(`support levels need an id and a non-negative threshold`);this.levels=[...e].sort((e,t)=>e.threshold-t.threshold)}get(e,t){return this.points.get(cj(e,t))??0}level(e,t){let n=this.get(e,t),r=null;for(let e of this.levels){if(e.threshold>n)break;r=e}return r}add(e,t,n){if(!e||!t||e===t)throw Error(`support needs two different named units`);if(!Number.isFinite(n))throw Error(`support amount must be finite, got ${n}`);let r=this.level(e,t),i=cj(e,t),a=Math.max(0,(this.points.get(i)??0)+n);return this.points.set(i,a),{a:e,b:t,points:a,previousLevel:r,level:this.level(e,t)}}save(){return{pairs:[...this.points].map(([e,t])=>{let[n,r]=e.split(`\0`);return[n,r,t]})}}static restore(t,n){let r=new e(t);for(let[e,t,i]of n.pairs){if(!e||!t||e===t||!Number.isFinite(i)||i<0)throw Error(`invalid support save data`);let n=cj(e,t);if(r.points.has(n))throw Error(`invalid support save data: duplicate pair "${e}" / "${t}"`);r.points.set(n,i)}return r}};function cj(e,t){return[e,t].sort().join(`\0`)}var lj=l({Advancement:()=>GA,Appearances:()=>QA,AuraField:()=>oj,Charges:()=>UA,EquipmentSlots:()=>PA,Inventory:()=>FA,Progression:()=>jA,SkillPoints:()=>NA,StatBlock:()=>kA,SupportLedger:()=>sj,affixOf:()=>qA,applyAffix:()=>JA,applyItemStatusEffect:()=>HA,applyStatusEffect:()=>LA,assignAppearances:()=>ZA,assignTraits:()=>aj,buy:()=>$A,canAfford:()=>rj,craft:()=>IA,damageItem:()=>BA,enchant:()=>zA,identify:()=>RA,powerCurve:()=>AA,removeAffix:()=>YA,repairItem:()=>VA,rollAffix:()=>KA,rollLoot:()=>WA,scaledModifiers:()=>XA,sell:()=>ej,skillCheck:()=>MA,spend:()=>ij}),uj=class{constructor(){this.factories=new Map,this.loaded=new Map,this.currentId=null}define(e,t,n={}){this.factories.set(e,{create:t,persistent:n.persistent??!0})}enter(e,t){let n=this.factories.get(e);if(!n)throw Error(`no such map: "${e}"`);let r=this.loaded.get(e);return(!r||!n.persistent)&&(r=n.create(),this.loaded.set(e,r)),this.currentId=e,this.lastSpawn=t,r}get current(){return this.currentId?this.loaded.get(this.currentId)??null:null}get currentMapId(){return this.currentId}get spawn(){return this.lastSpawn}isLoaded(e){return this.loaded.has(e)}isPersistent(e){return this.factories.get(e)?.persistent??!0}unload(e){if(e===this.currentId)throw Error(`cannot unload the current map: "${e}"`);this.loaded.delete(e)}},dj=class{constructor(){this.locations=new Map}add(e){this.locations.set(e.id,e)}remove(e){this.locations.delete(e)}get(e){return this.locations.get(e)}at(e,t){for(let n of this.locations.values())if(n.x===e&&n.y===t)return n}get all(){return[...this.locations.values()]}},fj=class{constructor(){this.turn=0,this.effects=new Map}add(e){let t=Symbol();return this.effects.set(t,{...e}),t}remove(e){this.effects.delete(e)}has(e){return this.effects.has(e)}advance(e=1){this.turn+=e;for(let[t,n]of this.effects)n.tick(this.turn),n.duration!==void 0&&(n.duration-=e,n.duration<=0&&(this.effects.delete(t),n.onExpire?.()))}};function pj(e){if(e.entries.length===0||!TE(e.rate))return null;let t=DE(e.entries.map(e=>e.weight));return t===-1?null:e.entries[t].value}var mj=class e{constructor(e={}){if(this.changed=new vT,this.dayLength=e.dayLength??120,!(this.dayLength>0))throw Error(`an environment day must be longer than zero seconds`);if(this.boundaries=e.phaseBoundaries??[.2,.7,.8],this.boundaries[0]<=0||this.boundaries[0]>=this.boundaries[1]||this.boundaries[1]>=this.boundaries[2]||this.boundaries[2]>=1)throw Error(`environment phase boundaries must be ascending fractions strictly between 0 and 1`);if(this.seconds_=e.startSeconds??0,this.weather_=e.startWeather??`clear`,!Number.isFinite(this.seconds_))throw Error(`environment startSeconds must be finite`)}get day(){return Math.floor(this.seconds_/this.dayLength)}get seconds(){return this.seconds_}get weather(){return this.weather_}get phase(){let e=(this.seconds_%this.dayLength+this.dayLength)%this.dayLength/this.dayLength;return e<this.boundaries[0]?`dawn`:e<this.boundaries[1]?`day`:e<this.boundaries[2]?`dusk`:`night`}get night(){return this.phase===`night`}advance(e){if(!Number.isFinite(e)||e<0)throw Error(`environment advance must be non-negative, got ${e}`);this.seconds_+=e;let t=this.snapshot();return this.changed.dispatch(t),t}setWeather(e){if(!e)throw Error(`weather needs a non-empty id`);this.weather_=e;let t=this.snapshot();return this.changed.dispatch(t),t}snapshot(){return{day:this.day,seconds:this.seconds_,phase:this.phase,weather:this.weather_}}static restore(t,n){return new e({...t,startSeconds:n.seconds,startWeather:n.weather})}},hj=l({EnvironmentClock:()=>mj,Overworld:()=>dj,TurnClock:()=>fj,World:()=>uj,rollEncounter:()=>pj}),gj=536870911,_j={orthogonal:`square`,isometric:`isometric`,staggered:`staggered`};function vj(e,t,n){if(e.frameWidth!==t.tilewidth||e.frameHeight!==t.tileheight)throw Error(`the tileset at firstgid ${n} is cut to ${e.frameWidth}x${e.frameHeight}, but the map is ${t.tilewidth}x${t.tileheight}`)}function yj(e,t,n){let r=-1;for(let n=0;n<t.length&&t[n]<=e;n++)r=n;if(r===-1)throw Error(`layer "${n}" uses gid ${e}, below every tileset's firstgid (${t.join(`, `)})`);return r}function bj(e,t){let n=e.orientation??`orthogonal`,r=_j[n];if(!r)throw Error(`loadTiledMap does not read "${n}" maps yet`);if(r===`staggered`&&(e.staggeraxis??`y`)!==`y`)throw Error(`loadTiledMap only reads Y-axis staggered maps right now, this one is staggered on "${e.staggeraxis}"`);if(r===`staggered`&&(e.staggerindex??`odd`)!==`odd`)throw Error(`loadTiledMap only reads odd-index staggered maps right now, this one staggers "${e.staggerindex}"`);if(e.tilesets.length===0)throw Error(`loadTiledMap needs at least one tileset, this map has none`);let i=[...e.tilesets].sort((e,t)=>e.firstgid-t.firstgid),a,o;if(t instanceof $D){if(e.tilesets.length!==1)throw Error(`loadTiledMap was given one sheet but this map has ${e.tilesets.length} tilesets - pass one sheet per tileset`);vj(t,e,i[0].firstgid),a=[t],o=[i[0].firstgid]}else{if(t.length!==e.tilesets.length)throw Error(`loadTiledMap was given ${t.length} sheets but this map has ${e.tilesets.length} tilesets - pass one sheet per tileset`);a=i.map(n=>{let r=t.find(e=>e.firstgid===n.firstgid);if(!r)throw Error(`loadTiledMap was given no sheet for the tileset at firstgid ${n.firstgid}`);return vj(r.sheet,e,n.firstgid),r.sheet}),o=i.map(e=>e.firstgid)}let s=new gO({width:e.width,height:e.height,sheet:a,shape:r}),c=[];for(let t of e.layers)if(t.type===`tilelayer`){if(t.encoding&&t.encoding!==`csv`)throw Error(`layer "${t.name}" uses "${t.encoding}" encoding - export tile layers as CSV/plain, not compressed`);let e=(t.data??[]).map(e=>{let n=e&gj;if(n===0)return-1;let r=yj(n,o,t.name);return o.length===1?n-o[0]:pO(r,n-o[r])});s.addLayer(t.name,e)}else if(t.type===`objectgroup`)for(let n of t.objects??[])c.push({...n,tileX:Math.floor(n.x/e.tilewidth),tileY:Math.floor(n.y/e.tileheight)});return{map:s,objects:c}}function xj(e,t,n={}){let r=n.pick??SE,i=0;return t.forEach((t,n)=>{Sj(t,t.name??`#${n+1}`);let a=Cj(e,t);if(i+=a.length,a.length!==0)for(let[n,i]of a){let a=t.outputs[r(t.outputs.length)];for(let[r,o]of Object.entries(a))for(let a=0;a<t.height;a++)for(let s=0;s<t.width;s++){let c=o[a*t.width+s];c!==-1&&e.setTile(r,n+s,i+a,c)}}}),i}function Sj(e,t){if(!Number.isInteger(e.width)||e.width<=0||!Number.isInteger(e.height)||e.height<=0)throw Error(`automap rule "${t}" needs a positive width and height`);if(e.outputs.length===0)throw Error(`automap rule "${t}" has no outputs - a rule that matches and writes nothing is a mistake`);let n=e.width*e.height;for(let[r,i]of Object.entries(e.input))if(i.length!==n)throw Error(`automap rule "${t}" input "${r}" has ${i.length} cells, but the pattern is ${n}`);e.outputs.forEach((e,r)=>{for(let[i,a]of Object.entries(e))if(a.length!==n)throw Error(`automap rule "${t}" output ${r+1} "${i}" has ${a.length} cells, but the pattern is ${n}`)})}function Cj(e,t){let n=[];for(let r=0;r+t.height<=e.heightInTiles;r++)for(let i=0;i+t.width<=e.widthInTiles;i++)wj(e,t,i,r)&&n.push([i,r]);return n}function wj(e,t,n,r){for(let[i,a]of Object.entries(t.input))for(let o=0;o<t.height;o++)for(let s=0;s<t.width;s++){let c=a[o*t.width+s];if(c!==-1&&e.getTile(i,n+s,r+o)!==c)return!1}return!0}var Tj=class e{constructor(){this.switches=new Map,this.variables=new Map}switch(e){return this.switches.get(e)??!1}setSwitch(e,t){this.switches.set(e,t)}variable(e){return this.variables.get(e)??0}setVariable(e,t){this.variables.set(e,t)}toJSON(){return{switches:[...this.switches],variables:[...this.variables]}}static fromJSON(t){let n=new e;for(let[e,r]of t.switches)n.setSwitch(e,r);for(let[e,r]of t.variables)n.setVariable(e,r);return n}};function Ej(e,t){return`switch`in e?t.switch(e.switch)===e.equals:t.variable(e.variable)>=e.atLeast}function Dj(e,t){let n;for(let r of e.pages)(r.conditions??[]).every(e=>Ej(e,t))&&(n=r);return n}var Oj=class{constructor(e){this.cancelled=!1,this.options=e,this.state={game:e.game,answers:{}}}cancel(){this.cancelled=!0}async run(e){for(let t of e){if(this.cancelled)break;await this.step(t)}return this.state}async step(e){if(`say`in e){await this.speak(e.say,e.speaker);return}if(`ask`in e){let t=await this.speak(e.ask,e.speaker,e.choices);e.store&&(this.state.answers[e.store]=t);return}if(`wait`in e){await new Promise(t=>setTimeout(t,e.wait*1e3));return}if(`setSwitch`in e){this.state.game.setSwitch(e.setSwitch,e.value);return}if(`setVariable`in e){this.state.game.setVariable(e.setVariable,e.value);return}if(`addVariable`in e){let t=this.state.game.variable(e.addVariable);this.state.game.setVariable(e.addVariable,t+e.amount);return}if(`if`in e){let t=Ej(e.if,this.state.game);await this.run(t?e.then:e.else??[]);return}if(`move`in e){await this.options.move?.(e.move.target,e.move.steps);return}`call`in e&&await e.call(this.state)}speak(e,t,n){let{windows:r}=this.options;return new Promise(i=>{r.push(new UO({width:this.options.boxWidth??480,height:this.options.boxHeight??120,speed:this.options.speed??45,pages:[{text:e,speaker:t}],choices:n,anchor:`bottom`,onDone:e=>i(e)}))})}},kj=class{constructor(e,t,n,r){this.facing=`down`,this.target=null,this.progress=0,this.sprite=e,this.x=this.fromX=t,this.y=this.fromY=n,this.tileWidth=r.tileWidth,this.tileHeight=r.tileHeight,this.speed=r.speed??4,this.options=r,this.place(),this.playIdle()}get isMoving(){return this.target!==null}turnTo(e,t){this.target||(this.facing=Aj(e,t),this.playIdle())}moveBy(e,t){return!this.target&&(this.facing=Aj(e,t),this.fromX=this.x,this.fromY=this.y,this.target={x:this.x+e,y:this.y+t},this.progress=0,this.playWalk(),!0)}update(e){this.sprite.update(e),this.target&&(this.progress=Math.min(1,this.progress+this.speed*e),this.sprite.x=jj(this.fromX,this.target.x,this.progress)*this.tileWidth,this.sprite.y=jj(this.fromY,this.target.y,this.progress)*this.tileHeight,this.progress>=1&&(this.x=this.target.x,this.y=this.target.y,this.target=null,this.playIdle()))}place(){this.sprite.x=this.x*this.tileWidth,this.sprite.y=this.y*this.tileHeight}playWalk(){let e=this.options.walkAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}playIdle(){let e=this.options.idleAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}};function Aj(e,t){return e>0?`right`:e<0?`left`:t>0?`down`:`up`}function jj(e,t,n){return e+(t-e)*n}var Mj=class{constructor(e,t,n,r={}){this.facing=0,this.moving=!1,this.sprite=e,this.x=t,this.y=n,this.speed=r.speed??4,this.options=r,this.place(),this.playIdle()}get isMoving(){return this.moving}move(e,t,n){let r=Math.hypot(e,t);r>0?(this.facing=Math.atan2(t,e),this.x+=e/r*this.speed*n,this.y+=t/r*this.speed*n,this.moving||(this.moving=!0,this.playWalk())):this.moving&&(this.moving=!1,this.playIdle()),this.place(),this.sprite.update(n)}turnTo(e,t){this.moving||e===0&&t===0||(this.facing=Math.atan2(t,e),this.playIdle())}place(){this.sprite.x=this.x,this.sprite.y=this.y}playWalk(){let e=this.options.walkAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}playIdle(){let e=this.options.idleAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}};function Nj(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Pj(e,t){let n=e.x-t.x,r=e.y-t.y,i=e.radius+t.radius;return n*n+r*r<i*i}function Fj(e,t){let n=Rj(e.x,t.x,t.x+t.width),r=Rj(e.y,t.y,t.y+t.height),i=e.x-n,a=e.y-r;return i*i+a*a<e.radius*e.radius}function Ij(e,t,n,r){let{tileSize:i,isSolid:a}=r;if(!(i>0))throw Error(`collision tileSize must be positive`);let o=Lj(e.x,e.y,e.width,e.height,t,i,a,!0);return{x:o,y:Lj(o,e.y,e.width,e.height,n,i,a,!1)}}function Lj(e,t,n,r,i,a,o,s){if(i===0)return s?e:t;let c=s?e:t,l=s?n:r,u=c+i,d=Math.floor((s?t:e)/a),f=Math.floor(((s?t+r:e+n)-1e-6)/a),p=(e,t)=>s?o(e,t):o(t,e);if(i>0){let e=Math.floor((c+l-1e-6)/a),t=Math.floor((u+l-1e-6)/a);for(let n=e+1;n<=t;n++)for(let e=d;e<=f;e++)if(p(n,e))return n*a-l}else{let e=Math.floor(c/a),t=Math.floor(u/a);for(let n=e-1;n>=t;n--)for(let e=d;e<=f;e++)if(p(n,e))return(n+1)*a}return u}function Rj(e,t,n){return e<t?t:e>n?n:e}var zj=class e{constructor(){this.definitions=new Map,this.stageIndex=new Map,this.tracked=null}define(e){this.definitions.set(e.id,e)}track(e){e!==null&&this.require(e),this.tracked=e}trackedQuest(){return this.tracked!==null&&this.status(this.tracked)===`active`?this.tracked:null}trackedLocation(){let e=this.trackedQuest();return e?this.currentStage(e)?.location??null:null}markerFor(e,t){return e.some(e=>this.status(e)===`active`&&this.stageSatisfied(e,t))?`turnIn`:e.some(e=>this.status(e)===`available`)?`offer`:`none`}canStart(e){return(this.require(e).requires??[]).every(e=>this.status(e)===`complete`)}start(e){if(!this.canStart(e))throw Error(`quest "${e}" cannot start yet - a prerequisite is incomplete`);this.stageIndex.set(e,0)}status(e){let t=this.require(e),n=this.stageIndex.get(e);return n===void 0?this.canStart(e)?`available`:`unavailable`:n>=t.stages.length?`complete`:`active`}currentStage(e){return this.status(e)===`active`?this.require(e).stages[this.stageIndex.get(e)]:null}progress(e,t){let n=this.currentStage(e);return n?.counter?Math.min(1,t.variable(n.counter.variable)/n.counter.target):null}advance(e,t){return this.stageSatisfied(e,t)?(this.stageIndex.set(e,this.stageIndex.get(e)+1),!0):!1}stageSatisfied(e,t){let n=this.currentStage(e);return n?n.condition?Ej(n.condition,t):!n.counter||t.variable(n.counter.variable)>=n.counter.target:!1}require(e){let t=this.definitions.get(e);if(!t)throw Error(`no such quest: "${e}"`);return t}toJSON(){return{stageIndex:[...this.stageIndex],tracked:this.tracked}}static fromJSON(t,n){let r=new e;for(let e of t)r.define(e);for(let[e,t]of n.stageIndex)r.stageIndex.set(e,t);return n.tracked&&(r.tracked=n.tracked),r}},Bj=class{constructor(e){this.name=e}},Vj=4,Hj=8,Uj=new WeakMap;function Wj(e){return Uj.get(e)}function Gj(e,t){return Uj.set(e,t),e}var Kj=class{constructor(e){this.pos=0,this.symbols=[],this.objects=[],this.bytes=e}byte(){if(this.pos>=this.bytes.length)throw Error(`Marshal: unexpected end of input`);return this.bytes[this.pos++]}take(e){if(e<0)throw Error(`Marshal: negative length`);let t=this.bytes.subarray(this.pos,this.pos+e);if(t.length<e)throw Error(`Marshal: unexpected end of input`);return this.pos+=e,t}readFixnum(){let e=this.byte()<<24>>24;if(e===0)return 0;if(e>=5&&e<=127)return e-5;if(e<=-5&&e>=-128)return e+5;if(e>0){let t=0;for(let n=0;n<e;n++)t|=this.byte()<<8*n;return t>>>0}let t=-e,n=0;for(let e=0;e<t;e++)n|=this.byte()<<8*e;return(n>>>0)-2**(8*t)}readBytes(){return this.take(this.readFixnum())}readSymbol(){let e=new TextDecoder().decode(this.readBytes());return this.symbols.push(e),e}readSymbolLink(){let e=this.readFixnum(),t=this.symbols[e];if(t===void 0)throw Error(`Marshal: symbol link ${e} out of range`);return t}readSymbolValue(){let e=String.fromCharCode(this.byte());if(e===`:`)return this.readSymbol();if(e===`;`)return this.readSymbolLink();throw Error(`Marshal: expected a symbol, got tag "${e}"`)}link(e){return this.objects.push(e),e}readBignum(){let e=String.fromCharCode(this.byte())===`-`?-1:1,t=this.readFixnum(),n=0,r=1;for(let e=0;e<t;e++)n+=(this.byte()|this.byte()<<8)*r,r*=65536;return e*n}readFloat(){let e=new TextDecoder().decode(this.readBytes());return e===`inf`?1/0:e===`-inf`?-1/0:e===`nan`?NaN:Number(e)}readArray(){let e=[];this.link(e);let t=this.readFixnum();for(let n=0;n<t;n++)e.push(this.readValue());return e}readHash(e){let t=new Map;this.link(t);let n=this.readFixnum();for(let e=0;e<n;e++)t.set(this.readValue(),this.readValue());return e&&Uj.set(t,this.readValue()),t}readIvars(e){let t={};for(let n=0;n<e;n++)t[this.readSymbolValue()]=this.readValue();return t}readObject(){let e={class:``,ivars:{}};return this.link(e),e.class=this.readSymbolValue(),e.ivars=this.readIvars(this.readFixnum()),e}readIvarWrapped(){let e=this.readValue();return this.readIvars(this.readFixnum()),e}readUserDefined(){let e={class:``,raw:new Uint8Array};return this.link(e),e.class=this.readSymbolValue(),e.raw=this.readBytes().slice(),e}readUserMarshal(){let e={class:``,value:null};return this.link(e),e.class=this.readSymbolValue(),e.value=this.readValue(),e}readValue(){let e=String.fromCharCode(this.byte());switch(e){case`0`:return null;case`T`:return!0;case`F`:return!1;case`i`:return this.readFixnum();case`l`:return this.link(this.readBignum());case`f`:return this.link(this.readFloat());case`:`:return this.readSymbol();case`;`:return this.readSymbolLink();case`"`:return this.link(new TextDecoder().decode(this.readBytes()));case`[`:return this.readArray();case`{`:return this.readHash(!1);case`}`:return this.readHash(!0);case`o`:return this.readObject();case`I`:return this.readIvarWrapped();case`u`:return this.readUserDefined();case`U`:return this.readUserMarshal();case`@`:{let e=this.readFixnum(),t=this.objects[e];if(t===void 0)throw Error(`Marshal: object link ${e} out of range`);return t}default:throw Error(`Marshal: unsupported tag "${e}" (0x${e.charCodeAt(0).toString(16)})`)}}readDocument(){let e=this.byte(),t=this.byte();if(e!==Vj||t>Hj)throw Error(`Marshal: unsupported version ${e}.${t} (expected ${Vj}.${Hj} or lower)`);return this.readValue()}};function qj(e){return new Kj(e).readDocument()}function Jj(e){return typeof e==`object`&&!!e&&`class`in e&&`ivars`in e}function Yj(e){let t=[Vj,Hj];return Xj(t,e),new Uint8Array(t)}function Xj(e,t){if(t==null)e.push(Zj(`0`));else if(t===!0)e.push(Zj(`T`));else if(t===!1)e.push(Zj(`F`));else if(t instanceof Bj)e.push(Zj(`:`)),Qj(e,t.name);else if(typeof t==`number`)Number.isInteger(t)&&Math.abs(t)<2**30?(e.push(Zj(`i`)),$j(e,t)):(e.push(Zj(`f`)),Qj(e,Number.isFinite(t)?String(t):t>0?`inf`:t<0?`-inf`:`nan`));else if(typeof t==`string`)e.push(Zj(`"`)),Qj(e,t);else if(Array.isArray(t)){e.push(Zj(`[`)),$j(e,t.length);for(let n of t)Xj(e,n)}else if(t instanceof Map){let n=Uj.has(t);e.push(Zj(n?`}`:`{`)),$j(e,t.size);for(let[n,r]of t)Xj(e,n),Xj(e,r);n&&Xj(e,Uj.get(t))}else if(Jj(t)){e.push(Zj(`o`)),e.push(Zj(`:`)),Qj(e,t.class);let n=Object.entries(t.ivars);$j(e,n.length);for(let[t,r]of n)e.push(Zj(`:`)),Qj(e,t),Xj(e,r)}else throw Error(`Marshal: cannot encode a value of type ${typeof t}`)}function Zj(e){return e.charCodeAt(0)}function Qj(e,t){let n=new TextEncoder().encode(t);$j(e,n.length);for(let t of n)e.push(t)}function $j(e,t){if(t===0){e.push(0);return}if(t>0&&t<=122){e.push(t+5);return}if(t<0&&t>=-123){e.push(t-5&255);return}if(t>0){for(let n=1;n<=4;n++)if(t<2**(8*n)){e.push(n);for(let r=0;r<n;r++)e.push(t>>>8*r&255);return}}else for(let n=1;n<=4;n++)if(t>=-(2**(8*n))){e.push(-n&255);let r=t+2**(8*n);for(let t=0;t<n;t++)e.push(r>>>8*t&255);return}throw Error(`Marshal: integer ${t} is out of range for a Fixnum`)}var eM=l({EventRunner:()=>Oj,FreeMover:()=>Mj,GameState:()=>Tj,GridMover:()=>kj,QuestLog:()=>zj,RubySymbol:()=>Bj,aabbOverlap:()=>Nj,activePage:()=>Dj,automap:()=>xj,circleAabbOverlap:()=>Fj,circleOverlap:()=>Pj,conditionHolds:()=>Ej,decodeMarshal:()=>qj,encodeMarshal:()=>Yj,hashDefaultOf:()=>Wj,loadTiledMap:()=>bj,resolveAabbAgainstTiles:()=>Ij,withHashDefault:()=>Gj}),tM=AA(20,2,100),nM=class{constructor(e){this.species=e.species,this.deriveStats=e.deriveStats,this.progression=new jA(e.species.growth??tM,{level:e.level??1}),this.stats=new kA({base:this.computeBase()})}refreshStats(){let e=this.computeBase();for(let[t,n]of Object.entries(e))this.stats.setBase(t,n)}computeBase(){let e=this.progression.level;return this.deriveStats?this.deriveStats(this.species.baseStats,e):{...this.species.baseStats}}},rM=class{constructor(){this.multipliers=new Map}key(e,t){return`${e}:${t}`}set(e,t,n){this.multipliers.set(this.key(e,t),n)}get(e,t){return this.multipliers.get(this.key(e,t))??1}multiplierFor(e,t){return t.reduce((t,n)=>t*this.get(e,n),1)}},iM=class{constructor(e){this.storage=[],this.active=Array(e).fill(null)}get members(){return this.active}get boxed(){return this.storage}add(e){let t=this.active.indexOf(null);t===-1?this.storage.push(e):this.active[t]=e}store(e){let t=this.active[e];t&&(this.active[e]=null,this.storage.push(t))}withdraw(e,t){if(t<0||t>=this.active.length)return;let n=this.storage[e];if(!n)return;this.storage.splice(e,1);let r=this.active[t];this.active[t]=n,r&&this.storage.push(r)}get activeMembers(){return this.active.filter(e=>e!==null)}};function aM(e){return[...e].sort((e,t)=>(t.priority??0)-(e.priority??0)||t.speed-e.speed)}function oM(e,t){let n=null;for(let r of e)r.at(t)&&(n=r.into);return n}var sM=class{constructor(e,t){this.stages=new Map,this.modifiers=new Map,this.stats=e,this.max=t.max,this.multiplierFor=t.multiplier}get(e){return this.stages.get(e)??0}change(e,t){let n=this.get(e),r=Math.max(-this.max,Math.min(this.max,n+t)),i=r-n;return i===0?0:(this.stages.set(e,r),this.applyModifier(e,r),i)}applyModifier(e,t){let n=this.modifiers.get(e);if(n&&this.stats.removeModifier(n),t===0){this.modifiers.delete(e);return}let r={stat:e,op:`multiply`,value:this.multiplierFor(t)};this.stats.addModifier(r),this.modifiers.set(e,r)}resetAll(){for(let e of this.modifiers.values())this.stats.removeModifier(e);this.modifiers.clear(),this.stages.clear()}};function cM(e,t,n,r=(e,n)=>t.multiplierFor(e.type,n)){if(e.length===0)return null;let i=e[0],a=r(i,n);for(let t of e.slice(1)){let e=r(t,n);e>a&&(a=e,i=t)}return i}function lM(e,t,n,r){let i=null,a=uM(e,n,r);return t.forEach((e,t)=>{let o=uM(e.types,n,r);o<a&&(a=o,i=t)}),i}function uM(e,t,n){return Math.max(...n.map(n=>t.multiplierFor(n,e)))}var dM=class{constructor(){this.hooks=[]}on(e,t,n){this.hooks.push({event:e,handler:t,source:n})}offSource(e){this.hooks=this.hooks.filter(t=>t.source!==e)}emit(e,t,n){for(let r of this.hooks)r.event===e&&r.handler(t,n)}},fM=class{constructor(){this.conditions=new Map}set(e){this.conditions.set(e.id,{...e})}has(e){return this.conditions.has(e)}get(e){return this.conditions.get(e)}clear(e){this.conditions.delete(e)}get active(){return[...this.conditions.values()]}advance(){for(let[e,t]of this.conditions)t.duration!==void 0&&(--t.duration,t.duration<=0&&this.conditions.delete(e))}},pM=l({BattleHooks:()=>dM,Creature:()=>nM,Field:()=>fM,Party:()=>iM,StatStages:()=>sM,TypeMatrix:()=>rM,battleOrder:()=>aM,checkEvolution:()=>oM,chooseMove:()=>cM,chooseSwitch:()=>lM});function mM(e){let t=e.charCodeAt(0)-97,n=e.charCodeAt(1)-49;if(t<0||t>7||n<0||n>7||e.length!==2)throw Error(`not a square: "${e}"`);return n*8+t}function hM(e){return String.fromCharCode(97+(e&7))+String.fromCharCode(49+(e>>3))}function gM(e){let t=e.trim().split(/\s+/);if(t.length<4)throw Error(`not a FEN string: "${e}"`);let n=Array(64).fill(null),r=t[0].split(`/`);if(r.length!==8)throw Error(`a FEN placement needs 8 ranks: "${e}"`);if(r.forEach((t,r)=>{let i=7-r,a=0;for(let r of t)if(r>=`1`&&r<=`8`)a+=r.charCodeAt(0)-48;else{let o=r===r.toUpperCase()?`white`:`black`,s={p:`pawn`,n:`knight`,b:`bishop`,r:`rook`,q:`queen`,k:`king`}[r.toLowerCase()];if(!s||a>7)throw Error(`bad FEN rank "${t}" in "${e}"`);n[i*8+a]={side:o,kind:s},a++}if(a!==8)throw Error(`bad FEN rank "${t}" in "${e}"`)}),t[1]!==`w`&&t[1]!==`b`)throw Error(`a FEN side is "w" or "b": "${e}"`);let i={whiteKingside:!1,whiteQueenside:!1,blackKingside:!1,blackQueenside:!1};if(t[2]!==`-`)for(let n of t[2])if(n===`K`)i.whiteKingside=!0;else if(n===`Q`)i.whiteQueenside=!0;else if(n===`k`)i.blackKingside=!0;else if(n===`q`)i.blackQueenside=!0;else throw Error(`bad FEN castling "${t[2]}" in "${e}"`);let a=t[3]===`-`?null:mM(t[3]);if(a!==null){let n=t[1]===`w`?5:2;if(yM(a)!==n)throw Error(`bad FEN en passant square "${t[3]}" in "${e}"`)}let o={board:n,turn:t[1]===`w`?`white`:`black`,castling:i,enPassant:a};return OM(n,`white`),OM(n,`black`),o}function _M(e){return e===`white`?`black`:`white`}function vM(e){return e&7}function yM(e){return e>>3}function bM(e,t){return e>=0&&e<8&&t>=0&&t<8}function xM(){let e=[`rook`,`knight`,`bishop`,`queen`,`king`,`bishop`,`knight`,`rook`],t=Array(64).fill(null);for(let n=0;n<8;n++)t[n]={side:`white`,kind:e[n]},t[8+n]={side:`white`,kind:`pawn`},t[48+n]={side:`black`,kind:`pawn`},t[56+n]={side:`black`,kind:e[n]};return{board:t,turn:`white`,castling:{whiteKingside:!0,whiteQueenside:!0,blackKingside:!0,blackQueenside:!0},enPassant:null}}function SM(e){return{board:e.board.map(e=>e?{side:e.side,kind:e.kind}:null),turn:e.turn,castling:{...e.castling},enPassant:e.enPassant}}var CM=[[1,2],[2,1],[2,-1],[1,-2],[-1,-2],[-2,-1],[-2,1],[-1,2]],wM=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]],TM=[[1,1],[-1,1],[-1,-1],[1,-1]],EM=[[1,0],[0,1],[-1,0],[0,-1]];function DM(e,t,n){let r=vM(t),i=yM(t),a=n===`white`?i-1:i+1;for(let t of[-1,1]){if(!bM(r+t,a))continue;let i=e[a*8+r+t];if(i&&i.side===n&&i.kind===`pawn`)return!0}for(let[t,a]of CM){if(!bM(r+t,i+a))continue;let o=e[(i+a)*8+r+t];if(o&&o.side===n&&o.kind===`knight`)return!0}for(let[t,a]of wM){if(!bM(r+t,i+a))continue;let o=e[(i+a)*8+r+t];if(o&&o.side===n&&o.kind===`king`)return!0}let o=[{steps:TM,kinds:[`bishop`,`queen`]},{steps:EM,kinds:[`rook`,`queen`]}];for(let{steps:t,kinds:a}of o)for(let[o,s]of t){let t=r+o,c=i+s;for(;bM(t,c);){let r=e[c*8+t];if(r){if(r.side===n&&a.includes(r.kind))return!0;break}t+=o,c+=s}}return!1}function OM(e,t){let n=e.findIndex(e=>e!==null&&e.side===t&&e.kind===`king`);if(n===-1)throw Error(`a position without a ${t} king cannot be judged`);return n}function kM(e,t){return DM(e.board,OM(e.board,t),_M(t))}function AM(e,t){let n=e.board[t];if(!n||n.side!==e.turn)return[];let r=[],i=vM(t),a=yM(t),o=o=>{for(let[s,c]of o){let o=i+s,l=a+c;for(;bM(o,l);){let i=l*8+o,a=e.board[i];if(!a)r.push({from:t,to:i});else{a.side!==n.side&&r.push({from:t,to:i});break}o+=s,l+=c}}};switch(n.kind){case`pawn`:{let o=n.side===`white`?1:-1,s=n.side===`white`?1:6,c=n.side===`white`?7:0;if(bM(i,a+o)&&!e.board[(a+o)*8+i]){let n=(a+o)*8+i;if(a+o===c)for(let e of[`knight`,`bishop`,`rook`,`queen`])r.push({from:t,to:n,promotion:e});else r.push({from:t,to:n}),a===s&&!e.board[(a+2*o)*8+i]&&r.push({from:t,to:(a+2*o)*8+i})}for(let s of[-1,1]){if(!bM(i+s,a+o))continue;let l=(a+o)*8+i+s,u=e.board[l];if(u&&u.side!==n.side){if(a+o===c)for(let e of[`knight`,`bishop`,`rook`,`queen`])r.push({from:t,to:l,promotion:e});else r.push({from:t,to:l})}else!u&&l===e.enPassant&&r.push({from:t,to:l,enPassantTake:a*8+i+s})}break}case`knight`:for(let[o,s]of CM){if(!bM(i+o,a+s))continue;let c=(a+s)*8+i+o,l=e.board[c];(!l||l.side!==n.side)&&r.push({from:t,to:c})}break;case`bishop`:o(TM);break;case`rook`:o(EM);break;case`queen`:o(TM),o(EM);break;case`king`:{for(let[o,s]of wM){if(!bM(i+o,a+s))continue;let c=(a+s)*8+i+o,l=e.board[c];l&&l.side===n.side||l&&l.kind===`king`||r.push({from:t,to:c})}let o=n.side===`white`?0:56,s=n.side===`white`?{king:e.castling.whiteKingside,queen:e.castling.whiteQueenside}:{king:e.castling.blackKingside,queen:e.castling.blackQueenside};t===o+4&&!kM(e,n.side)&&(s.king&&!e.board[o+5]&&!e.board[o+6]&&!DM(e.board,o+5,_M(n.side))&&!DM(e.board,o+6,_M(n.side))&&r.push({from:t,to:o+6,castle:`kingside`}),s.queen&&!e.board[o+3]&&!e.board[o+2]&&!e.board[o+1]&&!DM(e.board,o+3,_M(n.side))&&!DM(e.board,o+2,_M(n.side))&&r.push({from:t,to:o+2,castle:`queenside`}));break}}return r}function jM(e,t){let n=e.board[t.from];if(!n)throw Error(`no piece on ${hM(t.from)} to move`);let r=(e,t)=>{let n=e===`white`?0:56;return t===n||t===n+7};n.kind===`king`&&(n.side===`white`?e.castling.whiteKingside=e.castling.whiteQueenside=!1:e.castling.blackKingside=e.castling.blackQueenside=!1),n.kind===`rook`&&r(n.side,t.from)&&(e.castling[MM(n.side,t.from)]=!1);let i=e.board[t.to];if(i&&i.kind===`rook`&&r(i.side,t.to)&&(e.castling[MM(i.side,t.to)]=!1),e.board[t.to]=t.promotion?{side:n.side,kind:t.promotion}:n,e.board[t.from]=null,t.enPassantTake!==void 0&&(e.board[t.enPassantTake]=null),t.castle){let r=n.side===`white`?0:56;t.castle===`kingside`?(e.board[r+5]=e.board[r+7],e.board[r+7]=null):(e.board[r+3]=e.board[r],e.board[r]=null)}e.enPassant=n.kind===`pawn`&&Math.abs(t.to-t.from)===16?(t.from+t.to)/2:null,e.turn=_M(n.side)}function MM(e,t){let n=vM(t)===7;return e===`white`?n?`whiteKingside`:`whiteQueenside`:n?`blackKingside`:`blackQueenside`}function NM(e){let t=[];for(let n=0;n<64;n++)if(!(!e.board[n]||e.board[n]?.side!==e.turn))for(let r of AM(e,n)){let n=SM(e);jM(n,r),!kM(n,e.turn)&&t.push({from:r.from,to:r.to,...r.promotion?{promotion:r.promotion}:{}})}return t}function PM(e,t){let n=e.board[t.from];if(!n||n.side!==e.turn)throw Error(`no ${e.turn} piece on ${hM(t.from)} to move`);let r=AM(e,t.from).find(e=>e.to===t.to&&(e.promotion??null)===(t.promotion??null));if(!r)throw Error(`${hM(t.from)}-${hM(t.to)} is not a legal move here`);let i=SM(e);if(jM(i,r),kM(i,e.turn))throw Error(`${hM(t.from)}-${hM(t.to)} leaves the king in check`);jM(e,r)}function FM(e){return NM(e).length>0?`ongoing`:kM(e,e.turn)?e.turn===`white`?`black-wins`:`white-wins`:`stalemate`}var IM={pawn:100,knight:320,bishop:330,rook:500,queen:900,king:0};function LM(e,t={}){return RM(e,t).move}function RM(e,t={}){let n=Math.max(1,Math.floor(t.depth??3)),r=t.maxNodes===void 0?1/0:Math.max(1,Math.floor(t.maxNodes)),i=VM(e,NM(e));if(i.length===0)return{move:null,score:BM(e,0),nodes:1};let a=0,o=i[0],s=-1/0,c=-1/0;for(let t of i){if(a>=r)break;let i=SM(e);PM(i,t);let u=-l(i,n-1,-1/0,-c,1);u>s&&(s=u,o=t),c=Math.max(c,u)}return{move:o,score:s,nodes:a};function l(e,t,n,i,o){if(a>=r)return zM(e);if(a++,FM(e)!==`ongoing`)return BM(e,o);if(t===0)return zM(e);let s=-1/0;for(let r of VM(e,NM(e))){let a=SM(e);if(PM(a,r),s=Math.max(s,-l(a,t-1,-i,-n,o+1)),n=Math.max(n,s),n>=i)break}return s}}function zM(e){let t=0;for(let n of e.board)n&&(t+=(n.side===`white`?1:-1)*IM[n.kind]);return e.turn===`white`?t:-t}function BM(e,t){return kM(e,e.turn)?-1e5+t:0}function VM(e,t){return t.slice().sort((t,n)=>HM(e,n)-HM(e,t))}function HM(e,t){let n=e.board[t.to];return(t.promotion?IM[t.promotion]:0)*10+(n?IM[n.kind]:0)}var UM=class{constructor(e,t,n){if(this.width=e,this.height=t,e<1||t<1)throw Error(`a board needs positive dimensions`);if(n&&n.length!==e*t)throw Error(`board cell count does not match dimensions`);this.cells=n?[...n]:Array(e*t).fill(null)}index(e,t){if(!this.inside(e,t))throw Error(`cell (${e},${t}) is outside the board`);return t*this.width+e}inside(e,t){return e>=0&&t>=0&&e<this.width&&t<this.height}get(e,t){return this.cells[this.index(e,t)]}set(e,t,n){this.cells[this.index(e,t)]=n}move(e,t){let n=this.get(e.x,e.y);if(n===null)throw Error(`cannot move an empty cell`);return this.set(e.x,e.y,null),this.set(t.x,t.y,n),n}};function WM(){let e=Array(64).fill(null);for(let t=0;t<3;t++)for(let n=0;n<8;n++)(n+t)%2&&(e[t*8+n]={side:`black`,king:!1});for(let t=5;t<8;t++)for(let n=0;n<8;n++)(n+t)%2&&(e[t*8+n]={side:`red`,king:!1});return{board:e,turn:`red`,forcedFrom:null}}function GM(e){let t=e.forcedFrom===null?e.board.map((t,n)=>t?.side===e.turn?n:-1).filter(e=>e>=0):[e.forcedFrom],n=t.flatMap(t=>qM(e,t,!0));return n.length>0?n:e.forcedFrom===null?t.flatMap(t=>qM(e,t,!1)):[]}function KM(e,t){if(!GM(e).some(e=>e.from===t.from&&e.to===t.to&&e.captures.length===t.captures.length))throw Error(`illegal checkers move`);let n=e.board[t.from];if(!n)throw Error(`no checkers piece on the source cell`);e.board[t.from]=null;for(let n of t.captures)e.board[n]=null;let r=!n.king&&(n.side===`red`&&Math.floor(t.to/8)===0||n.side===`black`&&Math.floor(t.to/8)===7);e.board[t.to]={...n,king:n.king||r};let i={board:e.board,turn:e.turn,forcedFrom:t.captures.length>0?t.to:null};t.captures.length===0||qM(i,t.to,!0).length===0?(e.turn=e.turn===`red`?`black`:`red`,e.forcedFrom=null):e.forcedFrom=t.to}function qM(e,t,n){let r=e.board[t];if(!r)return[];let i=t%8,a=Math.floor(t/8),o=r.king?[-1,1]:r.side===`red`?[-1]:[1],s=[];for(let c of o)for(let o of[-1,1]){let l=i+o,u=a+c,d=i+o*2,f=a+c*2;if(n){if(d<0||f<0||d>=8||f>=8)continue;let n=u*8+l,i=f*8+d;e.board[n]?.side!==r.side&&e.board[n]&&!e.board[i]&&s.push({from:t,to:i,captures:[n]})}else l>=0&&u>=0&&l<8&&u<8&&!e.board[u*8+l]&&s.push({from:t,to:u*8+l,captures:[]})}return s}function JM(e=9){if(e<2||e>25)throw Error(`Go size must be between 2 and 25`);return{size:e,board:Array(e*e).fill(null),turn:`black`,ko:null,passes:0}}function YM(e,t,n){let r=$M(e,t,n);if(e.board[r]||e.ko===r)throw Error(`Go cell is occupied or forbidden by ko`);let i=[...e.board];i[r]=e.turn;let a=e.turn===`black`?`white`:`black`,o=0,s=null;for(let t of eN(e,r)){if(i[t]!==a||nN(i,e.size,t)!==0)continue;let n=tN(i,e.size,t);n.length===1&&(s=n[0]);for(let e of n)i[e]=null;o+=n.length}if(nN(i,e.size,r)===0)throw Error(`suicide is not a legal Go move`);e.ko=o===1&&nN(i,e.size,r)===1?s:null,e.board=i,e.turn=a,e.passes=0}function XM(e){e.turn=e.turn===`black`?`white`:`black`,e.ko=null,e.passes++}function ZM(e){return e.passes>=2?`finished`:`ongoing`}function QM(e){let t={black:0,white:0},n=new Set;for(let r=0;r<e.board.length;r++){let i=e.board[r];if(i)t[i]++;else if(!n.has(r)){let i=tN(e.board,e.size,r),a=new Set;for(let t of i)for(let n of eN(e,t))e.board[n]&&a.add(e.board[n]);for(let e of i)n.add(e);a.size===1&&(t[[...a][0]]+=i.length)}}return t}function $M(e,t,n){if(t<0||n<0||t>=e.size||n>=e.size)throw Error(`Go cell is outside the board`);return n*e.size+t}function eN(e,t){let n=t%e.size,r=Math.floor(t/e.size);return[[n-1,r],[n+1,r],[n,r-1],[n,r+1]].filter(([t,n])=>t>=0&&n>=0&&t<e.size&&n<e.size).map(([t,n])=>n*e.size+t)}function tN(e,t,n){let r=e[n];if(!r)return[];let i=[],a=[n],o=new Set;for(;a.length;){let n=a.pop();if(o.has(n)||e[n]!==r)continue;o.add(n),i.push(n);let s=n%t,c=Math.floor(n/t);for(let[e,n]of[[s-1,c],[s+1,c],[s,c-1],[s,c+1]])e>=0&&n>=0&&e<t&&n<t&&a.push(n*t+e)}return i}function nN(e,t,n){let r=tN(e,t,n),i=new Set;for(let n of r){let r=n%t,a=Math.floor(n/t);for(let[n,o]of[[r-1,a],[r+1,a],[r,a-1],[r,a+1]])n>=0&&o>=0&&n<t&&o<t&&e[o*t+n]===null&&i.add(o*t+n)}return i.size}function rN(){let e=Array(24).fill(0);return e[0]=2,e[11]=5,e[16]=3,e[18]=5,e[23]=-2,e[12]=-5,e[7]=-3,e[5]=-5,{points:e,bar:{white:0,black:0},off:{white:0,black:0},turn:`white`}}function iN(){let e=vN(2,6);return e[0]===e[1]?[...e,...e]:e}function aN(e,t){let n=e.turn===`white`?1:-1,r=[];for(let i of t){if(e.bar[e.turn]>0){let t=e.turn===`white`?i-1:24-i;sN(e,t,n)&&r.push({from:`bar`,to:t,die:i});continue}for(let t=0;t<24;t++)if(e.points[t]*n>0){let a=t+i*n;a<0||a>=24?r.push({from:t,to:`off`,die:i}):sN(e,a,n)&&r.push({from:t,to:a,die:i})}}return r}function oN(e,t){if(!aN(e,[t.die]).some(e=>e.from===t.from&&e.to===t.to))throw Error(`illegal backgammon move`);let n=e.turn===`white`?1:-1;if(t.from===`bar`?e.bar[e.turn]--:e.points[t.from]-=n,t.to===`off`)e.off[e.turn]++;else{if(e.points[t.to]*n<0){let n=e.turn===`white`?`black`:`white`;e.points[t.to]=0,e.bar[n]++}e.points[t.to]+=n}}function sN(e,t,n){return e.points[t]*n>=-1}function cN(e=0){let t=[`clubs`,`diamonds`,`hearts`,`spades`],n=[];for(let e of t)for(let t=1;t<=13;t++)n.push({suit:e,rank:t});return n.concat(Array(e).fill(null).map(()=>({suit:`spades`,rank:1})))}function lN(e){return kE(e)}function uN(e,t,n){if(t<0||n<0||e.length<t*n)throw Error(`not enough cards to deal`);return Array.from({length:t},()=>e.splice(0,n))}function dN(e,t){if(e.length===0)throw Error(`a trick needs at least one play`);let n=e[0].card.suit,r=e=>e.rank===1?14:e.rank;return(t&&e.some(e=>e.card.suit===t)?e.filter(e=>e.card.suit===t):e.filter(e=>e.card.suit===n)).reduce((e,t)=>r(t.card)>r(e.card)?t:e).owner}function fN(e){let t=cN();return e===void 0?lN(t):yE(e,()=>lN(t)),{stock:t,waste:[],tableau:Array.from({length:7},(e,n)=>({down:t.splice(0,6-n),up:t.splice(0,1)})),foundations:[[],[],[],[]]}}function pN(e){e.stock.length===0&&(e.stock=e.waste.reverse(),e.waste=[]);let t=e.stock.pop()??null;return t&&e.waste.push(t),t}function mN(e,t,n,r=1){let i=e.tableau[t],a=e.tableau[n],o=i?.up.slice(-r);if(!i||!a||!o?.length||(a.up.length===0?o[0].rank!==13:!_N(o[0],a.up.at(-1))))throw Error(`illegal solitaire tableau move`);i.up.splice(-r,r),a.up.push(...o),i.down.length&&i.up.length===0&&i.up.push(i.down.pop())}function hN(e,t){let n=t===`waste`?e.waste.at(-1):e.tableau[t].up.at(-1);if(!n)throw Error(`no solitaire card to move`);let r=e.foundations.find(e=>e[0]?.suit===n.suit||e.length===0);if(!r||n.rank!==r.length+1)throw Error(`card cannot move to its foundation`);if(t===`waste`)e.waste.pop();else{let n=e.tableau[t];n.up.pop(),n.down.length&&n.up.length===0&&n.up.push(n.down.pop())}r.push(n)}function gN(e){return e.foundations.every(e=>e.length===13)}function _N(e,t){let n=e.suit===`diamonds`||e.suit===`hearts`,r=t.suit===`diamonds`||t.suit===`hearts`;return e.rank===t.rank-1&&n!==r}function vN(e,t){if(!Number.isInteger(e)||e<0||!Number.isInteger(t)||t<1)throw Error(`dice need a non-negative count and positive sides`);return Array.from({length:e},()=>CE(1,t))}function yN(e){let t=/^(\d+)d(\d+)([+-]\d+)?$/i.exec(e.trim());if(!t)throw Error(`bad dice expression: "${e}"`);return vN(Number(t[1]),Number(t[2])).reduce((e,t)=>e+t,Number(t[3]??0))}var bN=class{constructor(e,t){this.kept=new Set,this.count=e,this.sides=t,this.values=vN(e,t)}reRoll(){for(let e=0;e<this.values.length;e++)this.kept.has(e)||(this.values[e]=CE(1,this.sides))}keep(e){if(e<0||e>=this.count)throw Error(`die index is outside the cup`);this.kept.add(e)}clearKept(){this.kept.clear()}};function xN(e,t){if(e.length!==5||e.some(e=>e<1||e>6))throw Error(`a score sheet needs five d6 values`);let n=new Map;for(let t of e)n.set(t,(n.get(t)??0)+1);let r=e.reduce((e,t)=>e+t,0);if(t===`chance`)return r;if(t===`yahtzee`)return n.size===1?50:0;if(t===`fullHouse`)return[...n.values()].sort().join(`,`)===`2,3`?25:0;if(t===`threeKind`)return[...n.values()].some(e=>e>=3)?r:0;if(t===`fourKind`)return[...n.values()].some(e=>e>=4)?r:0;if(t===`smallStraight`||t===`largeStraight`){let e=[`1234`,`2345`,`3456`],r=[`12345`,`23456`],i=[...n.keys()].sort().join(``);return(t===`smallStraight`?e:r).some(e=>i.includes(e))?t===`smallStraight`?30:40:0}let i=[`ones`,`twos`,`threes`,`fours`,`fives`,`sixes`].indexOf(t)+1;return i>0?(n.get(i)??0)*i:0}function SN(e,t,n=`hex`){if(e<1||t<1)throw Error(`a tactical map needs positive dimensions`);return{width:e,height:t,shape:n,cells:Array.from({length:e*t},()=>({passable:!0,cover:0})),units:[],turn:``,round:1}}function CN(e,t,n){return NN(e,t,n)&&!MN(e,t,n)}function wN(e,t){if(!CN(e,t.x,t.y))throw Error(`tactical unit cannot be placed there`);e.units.push({...t}),e.turn||=t.owner}function TN(e,t){let n=jN(e,t);if(n.owner!==e.turn||n.actions<=0)return[];let r=LN(e,n,IN(e,n)),i=[];for(let a=0;a<e.height;a++)for(let o=0;o<e.width;o++){if(o===n.x&&a===n.y||!e.cells[a*e.width+o].passable||MN(e,o,a))continue;let s=RN(e,n,o,a,n.actions,r);s!==null&&i.push({unit:t,x:o,y:a,cost:s})}return i}function EN(e,t){let n=TN(e,t.unit).find(e=>e.x===t.x&&e.y===t.y);if(!n)throw Error(`illegal tactical move`);let r=jN(e,t.unit);r.x=t.x,r.y=t.y,r.actions-=n.cost}function DN(e,t){let n=jN(e,t);if(n.owner!==e.turn||n.actions<=0)throw Error(`only an active unit can enter overwatch`);n.actions=0,n.overwatch=!0}function ON(e,t,n){let r=jN(e,t),i=[];for(let t of[...e.units]){if(!t.overwatch||t.owner===r.owner||FN(e,t,r)>3)continue;let a=e.cells[r.y*e.width+r.x].cover??0,o=Math.max(0,n-a);if(r.hp=Math.max(0,r.hp-o),t.overwatch=!1,i.push({attacker:t.id,defender:r.id,damage:o,cover:a,killed:r.hp===0}),r.hp===0){e.units=e.units.filter(e=>e!==r);break}}return i}function kN(e,t,n,r){let i=jN(e,t),a=jN(e,n);if(i.owner!==e.turn||i.owner===a.owner)throw Error(`invalid tactical attack`);if(FN(e,i,a)>3)throw Error(`tactical target is out of range`);let o=e.cells[a.y*e.width+a.x].cover??0,s=Math.max(0,r-o);a.hp=Math.max(0,a.hp-s);let c=a.hp===0;return c&&(e.units=e.units.filter(e=>e!==a)),{attacker:t,defender:n,damage:s,cover:o,killed:c}}function AN(e){let t=[...new Set(e.units.map(e=>e.owner))];if(t.length===0)return;let n=t.indexOf(e.turn)+1;n>=t.length&&e.round++,e.turn=t[n%t.length];for(let t of e.units)t.owner===e.turn&&(t.actions=2,t.overwatch=!1)}function jN(e,t){let n=e.units.find(e=>e.id===t);if(!n)throw Error(`unknown tactical unit "${t}"`);return n}function MN(e,t,n){return e.units.some(e=>e.x===t&&e.y===n)}function NN(e,t,n){return t>=0&&n>=0&&t<e.width&&n<e.height}function PN(e,t,n){return e.shape===`hex`?sD(t,n):[{x:t-1,y:n},{x:t+1,y:n},{x:t,y:n-1},{x:t,y:n+1}]}function FN(e,t,n){return e.shape===`hex`?cD(t,n):Math.abs(t.x-n.x)+Math.abs(t.y-n.y)}function IN(e,t){return new Set(e.units.filter(n=>n.owner!==t.owner&&PN(e,t.x,t.y).some(e=>e.x===n.x&&e.y===n.y)).map(e=>e.id))}function LN(e,t,n){let r=new Set;for(let i of e.units)if(!(i.owner===t.owner||n.has(i.id)))for(let t of PN(e,i.x,i.y))r.add(`${t.x},${t.y}`);return r}function RN(e,t,n,r,i,a){let o=[{x:t.x,y:t.y,distance:0}],s=0,c=new Set([`${t.x},${t.y}`]);for(;s<o.length;){let t=o[s++];if(t.x===n&&t.y===r)return t.distance;if(!(t.distance>=i||t.distance>0&&a.has(`${t.x},${t.y}`)))for(let i of PN(e,t.x,t.y)){let a=`${i.x},${i.y}`;!NN(e,i.x,i.y)||c.has(a)||!e.cells[i.y*e.width+i.x].passable||MN(e,i.x,i.y)&&(i.x!==n||i.y!==r)||(c.add(a),o.push({x:i.x,y:i.y,distance:t.distance+1}))}}return null}var zN=class{constructor(e,t){if(this.visible=new Map,this.explored=new Map,e<1||t<1)throw Error(`fog needs positive dimensions`);this.width=e,this.height=t}sync(e,t,n){if(!e)throw Error(`fog needs a faction id`);let r=new Set;for(let e of t)for(let t of n(e))this.inside(t.x,t.y)&&r.add(this.index(t.x,t.y));this.visible.set(e,r);let i=this.explored.get(e)??new Set;for(let e of r)i.add(e);this.explored.set(e,i)}isVisible(e,t,n){return this.visible.get(e)?.has(this.index(t,n))??!1}isExplored(e,t,n){return this.explored.get(e)?.has(this.index(t,n))??!1}visibleCells(e){return[...this.visible.get(e)??[]]}exploredCells(e){return[...this.explored.get(e)??[]]}inside(e,t){return e>=0&&t>=0&&e<this.width&&t<this.height}index(e,t){return this.inside(e,t)?t*this.width+e:-1}};function BN(e){return{currency:e,pool:[]}}function VN(e,t,n,r){return e.currency<r||!CN(t,n.x,n.y)?!1:(wN(t,n),e.currency-=r,!0)}function HN(e,t,n,r,i){let a=e.pool.findIndex(e=>e.id===n);return a===-1||!CN(t,r,i)?!1:(wN(t,{...e.pool[a],x:r,y:i}),e.pool.splice(a,1),!0)}function UN(e,t,n){let r=t.units.findIndex(e=>e.id===n);if(r===-1)return!1;let{x:i,y:a,...o}=t.units[r];return e.pool.push(o),t.units.splice(r,1),!0}function WN(e,t,n){return e.units.filter(e=>e.owner===t).length*(n.incomePerUnit-n.upkeepPerUnit)}function GN(e,t,n,r){return e.currency+=WN(t,n,r),e.currency}var KN=l({BoardGrid:()=>UM,DiceCup:()=>bN,FactionFog:()=>zN,addTacticalUnit:()=>wN,applyBackgammonMove:()=>oN,applyCheckersMove:()=>KM,applyMove:()=>PM,applyUpkeep:()=>GN,armyIncome:()=>WN,backgammonMoves:()=>aN,bankUnit:()=>UN,canPlaceTacticalUnit:()=>CN,checkersMoves:()=>GM,chooseMove:()=>LM,cloneChess:()=>SM,createDeck:()=>cN,deal:()=>uN,dealSolitaire:()=>fN,drawSolitaire:()=>pN,endTacticalTurn:()=>AN,gameResult:()=>FM,goResult:()=>ZM,goScore:()=>QM,inCheck:()=>kM,legalMoves:()=>NM,moveSolitaireTableau:()=>mN,moveSolitaireToFoundation:()=>hN,moveTacticalUnit:()=>EN,parseFen:()=>gM,passGo:()=>XM,playGo:()=>YM,recall:()=>HN,recruit:()=>VN,rollBackgammonDice:()=>iN,rollDice:()=>vN,rollExpression:()=>yN,scoreDice:()=>xN,search:()=>RM,setTacticalOverwatch:()=>DN,shuffleDeck:()=>lN,solitaireWon:()=>gN,sq:()=>mM,squareName:()=>hM,startingArmy:()=>BN,startingBackgammon:()=>rN,startingCheckers:()=>WM,startingChess:()=>xM,startingGo:()=>JM,startingTactics:()=>SN,tacticalAttack:()=>kN,tacticalMoves:()=>TN,trickWinner:()=>dN,triggerTacticalOverwatch:()=>ON});function qN(e){return new Audio(qD(e))}var JN=new vT,YN=class{constructor(e,t={}){this.next=0;let n=Math.max(1,t.poolSize??4),r=t.create??qN;this.volume=t.volume??1,this.caption=t.caption,this.pool=Array.from({length:n},()=>r(e))}play(){let e=this.pool[this.next];this.next=(this.next+1)%this.pool.length,e.volume=this.volume,e.currentTime=0,e.play(),this.caption&&JN.dispatch({text:this.caption})}stopAll(){for(let e of this.pool)e.pause(),e.currentTime=0}},XN=class{constructor(e={}){this.current=null,this.fades=[],this.volume=e.volume??1,this.create=e.create??qN}play(e,t=1){let n=this.create(e);n.loop=!0;let r=this.current;if(this.current=n,t<=0){n.volume=this.volume,n.play(),r?.pause();return}n.volume=0,n.play(),this.fades.push({audio:n,elapsed:0,duration:t,from:0,to:this.volume,stopAtEnd:!1}),r&&this.fades.push({audio:r,elapsed:0,duration:t,from:r.volume,to:0,stopAtEnd:!0})}stop(e=1){let t=this.current;if(t){if(this.current=null,e<=0){t.pause();return}this.fades.push({audio:t,elapsed:0,duration:e,from:t.volume,to:0,stopAtEnd:!0})}}update(e){for(let t of[...this.fades]){t.elapsed+=e;let n=Math.min(1,t.elapsed/t.duration);t.audio.volume=t.from+(t.to-t.from)*n,n>=1&&(this.fades.splice(this.fades.indexOf(t),1),t.stopAtEnd&&(t.audio.pause(),t.audio.currentTime=0))}}},ZN=class{constructor(e){this.states=new Map,this.cues=new Map,this.currentTrack=null,this.music=e}define(e,t){this.states.set(e,t)}enter(e){let t=this.states.get(e);if(!t)throw Error(`Orchestrator: no state defined for "${e}"`);t.track!==this.currentTrack&&(this.music.play(t.track,t.fadeDuration),this.currentTrack=t.track)}on(e,t){this.cues.set(e,t)}trigger(e){this.cues.get(e)?.play()}};function QN(e={}){let t=e.waveform??`square`,n=e.frequency??440,r=e.duration??.15,i=e.volume??.3,a=e.decay??8,o=e.sampleRate??22050,s=e.seed??1;if(!(r>0))throw Error(`tone duration must be positive`);if(t!==`noise`&&!(n>0))throw Error(`tone frequency must be positive`);if(!(o>0))throw Error(`tone sample rate must be positive`);let c=Math.max(1,Math.round(r*o)),l=new Float32Array(c);for(let e=0;e<c;e++){let r=e/o,u=a>0?Math.exp(-a*e/c):1,d=2*Math.PI*n*r;l[e]=i*u*eP(t,d,s,e)}return nP(l,o)}function $N(e={},t=e=>new Audio(e)){let n=t(QN(e));return n.play(),n}function eP(e,t,n,r){switch(e){case`sine`:return Math.sin(t);case`square`:return Math.sin(t)>=0?1:-1;case`triangle`:{let e=t/(2*Math.PI),n=e-Math.floor(e);return 4*Math.abs(n-.5)-1}case`noise`:return tP(n,r)}}function tP(e,t){let n=Math.imul(e^t,2654435761)>>>0;return n=Math.imul(n^n>>>15,2246822519)>>>0,n=Math.imul(n^n>>>13,3266489917)>>>0,n^=n>>>16,(n>>>0)/4294967295*2-1}function nP(e,t){let n=e.length*2,r=new ArrayBuffer(44+n),i=new DataView(r);rP(i,0,`RIFF`),i.setUint32(4,36+n,!0),rP(i,8,`WAVE`),rP(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),rP(i,36,`data`),i.setUint32(40,n,!0);let a=44;for(let t of e){let e=Math.max(-1,Math.min(1,t));i.setInt16(a,Math.round(e*(e<0?32768:32767)),!0),a+=2}let o=``,s=new Uint8Array(r);for(let e of s)o+=String.fromCharCode(e);return`data:audio/wav;base64,${btoa(o)}`}function rP(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}var iP=5e5;function aP(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0,i=e=>{let n=``;for(let i=0;i<e;i++)n+=String.fromCharCode(t[r+i]);return r+=e,n},a=()=>{let e=n.getUint32(r,!1);return r+=4,e},o=()=>{let e=n.getUint16(r,!1);return r+=2,e},s=()=>{let e=0;for(;;){let n=t[r++];if(e=e<<7|n&127,!(n&128))return e}};if(i(4)!==`MThd`||a()!==6)throw Error(`invalid MIDI header chunk`);let c=o(),l=o(),u=o();if(c!==0&&c!==1)throw Error(`unsupported MIDI format ${c}`);if(u&32768)throw Error(`SMPTE-based MIDI timing is not supported`);let d=u,f=[];for(let e=0;e<l;e++){let e=i(4),n=a();if(e!==`MTrk`){r+=n;continue}let o=r+n,c=0,l=0;for(;r<o;){c+=s();let e=t[r];if(e<128?e=l:(r++,e<240&&(l=e)),e===255){let e=t[r++],n=s();if(e===81&&n===3){let e=t[r]<<16|t[r+1]<<8|t[r+2];f.push({tick:c,type:`tempo`,microsecondsPerQuarter:e})}r+=n}else if(e===240||e===247)r+=s();else{let n=e&240,i=e&15;if(n===128||n===144){let e=t[r++],a=t[r++],o=n===144&&a>0;f.push({tick:c,type:o?`noteOn`:`noteOff`,note:e,velocity:a,channel:i})}else if(n===160||n===176||n===224)r+=2;else if(n===192||n===208)r+=1;else throw Error(`unsupported MIDI status byte 0x${e.toString(16)}`)}}}return f.sort((e,t)=>e.tick-t.tick),{ticksPerQuarter:d,events:f}}function oP(e){let t=[],n=new Map,r=iP,i=0,a=0;for(let o of e.events){if(a+=(o.tick-i)*r/e.ticksPerQuarter/1e6,i=o.tick,o.type===`tempo`){r=o.microsecondsPerQuarter;continue}let s=`${o.channel}:${o.note}`;if(o.type===`noteOn`)n.set(s,{time:a,velocity:o.velocity});else{let e=n.get(s);e&&(t.push({time:e.time,duration:Math.max(.01,a-e.time),note:o.note,velocity:e.velocity,channel:o.channel}),n.delete(s))}}for(let[e,r]of n){let[n,i]=e.split(`:`).map(Number);t.push({time:r.time,duration:.3,note:i,velocity:r.velocity,channel:n})}return t.sort((e,t)=>e.time-t.time)}function sP(e){return 440*2**((e-69)/12)}var cP=class{constructor(e,t={}){this.elapsed=0,this.index=0,this.playing=!1,this.notes=oP(e),this.playFn=t.play??$N,this.waveform=t.waveform??`square`,this.volume=t.volume??.2}play(){this.playing=this.index<this.notes.length}pause(){this.playing=!1}stop(){this.playing=!1,this.elapsed=0,this.index=0}update(e){if(this.playing){for(this.elapsed+=e;this.index<this.notes.length&&this.notes[this.index].time<=this.elapsed;){let e=this.notes[this.index];this.playFn({waveform:this.waveform,frequency:sP(e.note),duration:e.duration,volume:this.volume*(e.velocity/127)}),this.index++}this.index>=this.notes.length&&(this.playing=!1)}}get isPlaying(){return this.playing}get duration(){let e=this.notes.at(-1);return e?e.time+e.duration:0}},lP=l({MidiPlayer:()=>cP,Music:()=>XN,Orchestrator:()=>ZN,Sound:()=>YN,createAudio:()=>qN,noteToFrequency:()=>sP,onCaption:()=>JN,parseMidi:()=>aP,playTone:()=>$N,scheduleMidi:()=>oP,synthesizeTone:()=>QN});return e.Achievements=eD,e.ActorAnimator=yO,Object.defineProperty(e,"Actors",{enumerable:!0,get:function(){return lj}}),e.AnimatedSprite=RD,e.Animation=LD,Object.defineProperty(e,"Audio",{enumerable:!0,get:function(){return lP}}),e.BLOB_SHAPES=bO,e.Bar=YO,Object.defineProperty(e,"Battle",{enumerable:!0,get:function(){return pM}}),e.BitmapLabel=IO,Object.defineProperty(e,"Board",{enumerable:!0,get:function(){return KN}}),e.Button=JO,e.COLOR_BLINDNESS_MATRICES=oO,e.Camera=eO,e.Collection=YE,e.ColorTransformBatcher=ED,e.DialogueStage=nk,e.EMPTY=uO,e.Easing=mD,e.FeedbackClient=nD,e.FloatingText=ZO,e.Game=oE,e.Generator=pE,e.HelpScreen=$O,Object.defineProperty(e,"I18n",{enumerable:!0,get:function(){return fA}}),e.IconGrid=HO,Object.defineProperty(e,"Input",{enumerable:!0,get:function(){return yT}}),e.Label=FO,e.LayeredSprite=_O,e.ListView=VO,e.LoadQueue=_D,e.LoadingScreen=ek,e.Logger=lE,e.MessageBox=UO,e.Minimap=lO,e.NO_COLOR_ADD=FD,e.NewsClient=KE,e.NewsSeenTracker=JE,e.NinePatch=RO,e.Player=ZE,e.PlayerInput=AE,e.Projectile=vO,e.RENDERING_DECISIONS=EO,Object.defineProperty(e,"Random",{enumerable:!0,get:function(){return dE}}),e.RebindScreen=qO,e.Recorder=XE,Object.defineProperty(e,"Resources",{enumerable:!0,get:function(){return BD}}),Object.defineProperty(e,"Roguelike",{enumerable:!0,get:function(){return cA}}),Object.defineProperty(e,"Rpg",{enumerable:!0,get:function(){return eM}}),e.RunHistory=GE,e.SaveSyncClient=WE,e.SaveSystem=UE,e.Scene=sE,e.SceneStack=_T,e.Session=tD,e.Signal=vT,e.Spawner=rD,e.SpriteSheet=$D,e.StageScript=rk,e.TileMap=gO,e.TintedSprite=ID,e.Toast=QO,e.Tweener=hD,e.UndoHistory=gD,e.VerticalLabel=KO,e.Viewport=iO,e.Window=zO,e.WindowStack=BO,Object.defineProperty(e,"World",{enumerable:!0,get:function(){return hj}}),e.autotileFrames=TO,e.bitmapLabelStyle=LO,e.blobIndex=wO,e.checkNoControlCharacters=LE,e.checkSize=IE,e.createCamera=rO,e.createColorBlindnessFilter=sO,e.defaultTheme=kO,e.deserializeReplay=$E,e.detectWebGpu=OO,e.hexDistance=cD,e.hexLine=uD,e.hexNeighbors=sD,e.hexRange=dD,e.hexToPixel=fD,e.highContrastTheme=AO,e.importTwee=ak,e.inspectGraphicsCapabilities=DO,e.layoutVertical=GO,e.newlyRevealed=cO,e.packColorAdd=MD,e.packTintAdd=ND,e.pixelToHex=pD,e.registerColorTransform=jD,e.sanitizeInboundText=RE,e.scramble=jE,e.serializeReplay=QE,e.setTheme=PO,e.snapZoom=nO,e.splitScreenHalves=aO,e.theme=MO,e.themeChanged=NO,e.tileFrame=pO,e.tileFrameIndex=hO,e.tileFrameSheet=mO,e.unscramble=ME,e.validateSchema=BE,e.version=f,e})({});
1265
+ `),a=null,o=``,s=[],c=!1,l=()=>{if(a){if(r[a]!==void 0)throw Error(`Duplicate FTL message: ${a}`);if(s.length){if(!c)throw Error(`FTL select expression is not closed: ${a}`);let t=o.trim().match(/^\{\s*\$([\w-]+)\s*->\s*$/)?.[1];if(!t)throw Error(`Invalid FTL selector: ${o}`);r[a]=dA(e,t,s)}else r[a]=uA(o);a=null,o=``,s=[],c=!1}};for(let e of i){if(!e.trim()||e.trimStart().startsWith(`#`))continue;let t=e.match(/^([\w-]+)\s*=\s*(.*)$/);if(t){l(),a=t[1],o=t[2];continue}if(!a)throw Error(`FTL continuation has no message: ${e}`);if(e.trim()===`}`){if(!s.length||c)throw Error(`Unexpected FTL select terminator: ${e}`);c=!0;continue}if(c)throw Error(`FTL content follows a closed select expression: ${e}`);let n=e.match(/^\s*(\*)?\[([^\]]+)\]\s*(.*)$/);if(n){s.push({key:n[2],value:n[3],default:!!n[1]});continue}if(/^\s+/.test(e)){s.length?s[s.length-1].value+=` ${e.trim()}`:o+=` ${e.trim()}`;continue}throw Error(`Invalid FTL line: ${e}`)}return l(),{locale:e,direction:n.direction??(/^(ar|he|fa|ur)(?:-|$)/i.test(e)?`rtl`:`ltr`),messages:r}}function uA(e){return e.replace(/\{\s*\$([\w-]+)\s*\}/g,`{$1}`).trim()}function dA(e,t,n){let r=n.filter(e=>e.default);if(r.length!==1)throw Error(`FTL select expressions need exactly one default variant`);let i=r[0],a=new Intl.PluralRules(e);return{format(e={}){let r=e[t],o=n.find(e=>e.key===String(r)),s=typeof r==`number`?a.select(r):``;return uA((o??n.find(e=>e.key===s)??i).value)}}}var fA=l({direction:()=>bA,has:()=>CA,locale:()=>yA,parseFTL:()=>lA,reset:()=>DA,setActive:()=>vA,setBase:()=>_A,t:()=>xA,typographic:()=>SA}),pA=null,mA=null,hA=null,gA=null;function _A(e){pA=e}function vA(e){mA=e,hA=e?new Intl.PluralRules(e.locale):null}function yA(){return(mA??pA)?.locale??`en`}function bA(){return(mA??pA)?.direction??`ltr`}function xA(e,t){let n=mA?.messages[e]??pA?.messages[e];if(n===void 0)return e;let r=typeof n==`string`?n:TA(n)?n.format(t):wA(n,t?.count),i=t?EA(r,t):r;return(mA??pA)?.typography===!1?i:SA(i,yA())}function SA(e,t=yA()){return/^(fr|it|nl)(?:-|$)/i.test(t)?e.replace(/([\p{L}])'(?=[\p{L}])/gu,`$1’`):e}function CA(e){return mA?.messages[e]!==void 0||pA?.messages[e]!==void 0}function wA(e,t){return t===void 0?e.other??Object.values(e)[0]??``:e[(hA??(gA??=new Intl.PluralRules(`en`))).select(t)]??e.other??``}function TA(e){return`format`in e}function EA(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?e:String(r)})}function DA(){pA=null,mA=null,hA=null}function OA(e,t){let n=e=>t.filter(t=>t.op===e).sort((e,t)=>(e.order??0)-(t.order??0)),r=e;for(let e of n(`add`))r+=e.value;for(let e of n(`multiply`))r*=e.value;for(let e of n(`set`))r=e.value;return r}var kA=class{constructor(e){this.modifiers=[],this.cache=null,this.baseValues={...e.base},this.derived=e.derived??[]}base(e){return this.baseValues[e]??0}setBase(e,t){this.baseValues[e]=t,this.cache=null}addModifier(e){this.modifiers.push(e),this.cache=null}removeModifier(e){let t=this.modifiers.indexOf(e);t!==-1&&this.modifiers.splice(t,1),this.cache=null}removeModifiersFrom(e){this.modifiers=this.modifiers.filter(t=>t.source!==e),this.cache=null}get(e){return this.resolveAll()[e]??0}resolveAll(){if(this.cache)return this.cache;let e={...this.baseValues};for(let t of Object.keys(e))e[t]=OA(e[t],this.modifiersFor(t));for(let t of this.derived)e[t.name]=OA(t.from(e),this.modifiersFor(t.name));return this.cache=e,e}modifiersFor(e){return this.modifiers.filter(t=>t.stat===e)}};function AA(e,t,n){return{maxLevel:n,experienceFor:n=>n<=1?0:Math.round(e*(n-1)**t)}}var jA=class{constructor(e,t={}){this.curve=e,this.level=t.level??1,this.experience=t.experience??this.curve.experienceFor(this.level)}get experienceToNext(){return this.level>=this.curve.maxLevel?null:this.curve.experienceFor(this.level+1)-this.experience}addExperience(e){this.experience+=e;let t=0;for(;this.level<this.curve.maxLevel&&this.experience>=this.curve.experienceFor(this.level+1);)this.level++,t++;return t}};function MA(e,t,n=()=>CE(1,20)){return e+n()>=t}var NA=class{constructor(e,t={}){this.available=0,this.stats=e,this.capFor=t.cap??(()=>1/0),this.costFor=t.cost??(()=>1)}get points(){return this.available}grant(e){this.available+=e}canSpend(e){return this.nextRankCost(e)!==null}spend(e){let t=this.nextRankCost(e);if(t===null)return!1;let n=this.stats.base(e);return this.available-=t,this.stats.setBase(e,n+1),!0}nextRankCost(e){let t=this.stats.base(e);if(t>=this.capFor(e))return null;let n=this.costFor(e,t+1);return this.available>=n?n:null}},PA=class{constructor(e,t=null,n={}){this.worn=new Map,this.names=new Set(e),this.stats=t,this.isSlotLocked=n.locked??(()=>!1)}get(e){return this.worn.get(e)}isLocked(e){let t=this.worn.get(e);return t!==void 0&&this.isSlotLocked(e,t)}equip(e,t){if(this.assertSlot(e),this.isLocked(e))return;let n=this.unequip(e);this.worn.set(e,t);for(let e of t.modifiers??[])this.stats?.addModifier({...e,source:t});return n}unequip(e){let t=this.worn.get(e);if(t&&!this.isSlotLocked(e,t))return this.worn.delete(e),this.stats?.removeModifiersFrom(t),t}get slots(){return[...this.names]}assertSlot(e){if(!this.names.has(e))throw Error(`no such equipment slot: "${e}"`)}},FA=class{constructor(e={}){this.slots=[],this.capacity=e.capacity}get items(){return this.slots}get totalWeight(){return this.slots.reduce((e,t)=>e+this.weightOf(t),0)}weightOf(e){return(e.weight??0)*e.quantity+(e.contents?.totalWeight??0)}find(e){return this.slots.find(t=>t.id===e)}add(e){if(this.capacity!==void 0&&this.totalWeight+this.weightOf(e)>this.capacity)return!1;if(e.stackable){let t=this.slots.find(t=>t.id===e.id&&t.stackable);if(t)return t.quantity+=e.quantity,!0}return this.slots.push({...e}),!0}remove(e,t){let n=this.slots.findIndex(t=>t.id===e);if(n===-1)return;let r=this.slots[n];r.quantity-=t??r.quantity,r.quantity<=0&&this.slots.splice(n,1)}};function IA(e,t){let n=new Map;for(let e of t.ingredients)n.set(e.id,(n.get(e.id)??0)+e.quantity);for(let[t,r]of n){let n=e.find(t);if(!n||n.quantity<r)return!1}let r=t.ingredients.map(t=>({...e.find(t.id),quantity:t.quantity}));for(let n of t.ingredients)e.remove(n.id,n.quantity);if(e.add(t.result))return!0;for(let t of r)e.add(t);return!1}function LA(e,t,n){let r=Symbol(`statusEffect`);for(let t of n.modifiers)e.addModifier({...t,source:r});let i=t.add({duration:n.duration,tick:e=>n.tick?.(e),onExpire:()=>e.removeModifiersFrom(r)});return{cancel:()=>{t.remove(i),e.removeModifiersFrom(r)}}}function RA(e){e.identified=!0}function zA(e,t){return e.level=(e.level??0)+t,e.level}function BA(e,t){return e.maxDurability!==void 0&&(e.durability=Math.max(0,(e.durability??e.maxDurability)-t),e.durability<=0)}function VA(e,t){e.maxDurability!==void 0&&(e.durability=Math.min(e.maxDurability,(e.durability??e.maxDurability)+t))}function HA(e,t,n){let r=new Map;for(let t of Object.keys(n.fields))r.set(t,e[t]),e[t]=n.fields[t];let i=()=>{for(let[t,n]of r)e[t]=n},a=t.add({duration:n.duration,tick:e=>n.tick?.(e),onExpire:i});return{cancel:()=>{t.remove(a),i()}}}var UA=class{constructor(e){this.progress=0,this.max=e.max,this.regenRate=e.regenRate,this.value=e.current??e.max}get current(){return this.value}canAfford(e){return this.value>=e}spend(e){return this.canAfford(e)?(this.value-=e,!0):!1}advance(e=1){if(!(this.value>=this.max)){for(this.progress+=e;this.progress>=this.regenRate&&this.value<this.max;)this.progress-=this.regenRate,this.value++;this.value>=this.max&&(this.progress=0)}}};function WA(e){if(e.entries.length===0||!TE(e.chance??1))return null;let t=DE(e.entries.map(e=>e.weight));if(t===-1)return null;let n=e.entries[t];return{id:n.id,quantity:n.quantity??1}}var GA=class e{constructor(e){this.grantedTiers=0,this.balance=0,this.choices=new Map,this.track=e}get points(){return this.balance}openTiers(e){let t=[];return this.track.tiers.forEach((n,r)=>{e>=n.threshold&&t.push(r)}),t}grant(e){let t=0;for(;this.grantedTiers<this.track.tiers.length&&e>=this.track.tiers[this.grantedTiers].threshold;){let e=this.track.tiers[this.grantedTiers];e.kind===`points`&&(this.balance+=e.points??0,t+=e.points??0),this.grantedTiers++}return t}spend(e){return this.balance<e?!1:(this.balance-=e,!0)}choose(e,t,n){let r=this.track.tiers[e];if(!r)throw Error(`no such advancement tier: ${e}`);if(r.kind===`points`)throw Error(`tier ${e} grants points, it has no choice`);if(n<r.threshold)throw Error(`tier ${e} has not opened yet`);if(this.choices.has(e))throw Error(`tier ${e} is already decided`);if(!(r.options??[]).some(e=>e.id===t))throw Error(`tier ${e} has no option "${t}"`);this.choices.set(e,t)}choice(e){return this.choices.get(e)??null}toJSON(){return{grantedTiers:this.grantedTiers,balance:this.balance,choices:[...this.choices]}}static fromJSON(t,n){let r=new e(t);r.grantedTiers=n.grantedTiers,r.balance=n.balance;for(let[e,t]of n.choices)r.choices.set(e,t);return r}};function KA(e){let t=e.entries.filter(e=>e.weight>0);if(t.length===0)return null;let n=DE(t.map(e=>e.weight));return n===-1?null:t[n]}function qA(e){return e.affix}function JA(e,t){e.affix=t.id,t.curse&&(e.cursed=!0)}function YA(e){e.affix!==void 0&&(e.cursed=!1),delete e.affix}function XA(e,t){return t.map(t=>({stat:t.stat,op:t.op,value:t.base+t.perLevel*e}))}function ZA(e){if(e.labels.length<e.kinds.length)throw Error(`not enough appearances: ${e.kinds.length} kinds but only ${e.labels.length} labels`);let t=[...e.labels];for(let e=t.length-1;e>0;e--){let n=SE(0,e+1);[t[e],t[n]]=[t[n],t[e]]}let n=new Map;return e.kinds.forEach((e,r)=>n.set(e,t[r])),n}var QA=class e{constructor(e){this.assigned=new Map,this.tables=e}appearanceOf(e,t){let n=this.assigned.get(e);if(!n){let t=this.tables[e];if(!t)throw Error(`no such appearance category: "${e}"`);n=ZA(t),this.assigned.set(e,n)}let r=n.get(t);if(r===void 0)throw Error(`"${t}" is not in appearance category "${e}"`);return r}toJSON(){return{assigned:[...this.assigned].map(([e,t])=>[e,[...t]])}}static fromJSON(t,n){let r=new e(t);for(let[e,t]of n.assigned)r.assigned.set(e,new Map(t));return r}};function $A(e,t,n,r,i,a){let o=a.prices.get(r);if(!o)return!1;let s=t.find(r);if(!s||s.quantity<i)return!1;let c=o.buy*i;return e.base(a.currency)<c?!1:(t.remove(r,i),n.add({...s,quantity:i})?(e.setBase(a.currency,e.base(a.currency)-c),!0):(t.add({...s,quantity:i}),!1))}function ej(e,t,n,r,i,a){let o=a.prices.get(r);if(!o)return!1;let s=n.find(r);return!s||s.quantity<i?!1:(n.remove(r,i),t.add({...s,quantity:i}),e.setBase(a.currency,e.base(a.currency)+o.sell*i),!0)}function tj(e){let t=Array.isArray(e)?e:[e];for(let e of t)if(!Number.isFinite(e.amount)||e.amount<0)throw Error(`a resource cost must be a non-negative number, "${e.stat}" costs ${e.amount}`);return t}function nj(e){let t=new Map;for(let n of e)t.set(n.stat,(t.get(n.stat)??0)+n.amount);return t}function rj(e,t){return[...nj(tj(t))].every(([t,n])=>e.base(t)>=n)}function ij(e,t){let n=nj(tj(t));if(![...n].every(([t,n])=>e.base(t)>=n))return!1;for(let[t,r]of n)e.setBase(t,e.base(t)-r);return!0}function aj(e,t,n){return kE([...t]).slice(0,Math.min(n,t.length)).map(t=>{let n=Symbol(`trait:${t.name}`);for(let r of t.modifiers)e.addModifier({...r,source:n});return{trait:t,source:n}})}var oj=class{constructor(){this.affected=new Map}update(e,t){let n=new Set(e),r=e.filter(e=>!!e.aura),i=new Set(r);for(let i of r){let r=this.affected.get(i);r||(r=new Map,this.affected.set(i,r));for(let n of e){if(n===i)continue;let e=t(i,n),a=r.get(n);if(e&&!a){let e=Symbol(`aura:${i.aura.name}`);for(let t of i.aura.modifiers)n.stats.addModifier({...t,source:e});r.set(n,e)}else!e&&a&&(n.stats.removeModifiersFrom(a),r.delete(n))}for(let[e,t]of[...r])n.has(e)||(e.stats.removeModifiersFrom(t),r.delete(e))}for(let[e,t]of[...this.affected])if(!i.has(e)){for(let[e,n]of t)e.stats.removeModifiersFrom(n);this.affected.delete(e)}}},sj=class e{constructor(e){if(this.points=new Map,e.some(e=>!e.id||!Number.isFinite(e.threshold)||e.threshold<0))throw Error(`support levels need an id and a non-negative threshold`);this.levels=[...e].sort((e,t)=>e.threshold-t.threshold)}get(e,t){return this.points.get(cj(e,t))??0}level(e,t){let n=this.get(e,t),r=null;for(let e of this.levels){if(e.threshold>n)break;r=e}return r}add(e,t,n){if(!e||!t||e===t)throw Error(`support needs two different named units`);if(!Number.isFinite(n))throw Error(`support amount must be finite, got ${n}`);let r=this.level(e,t),i=cj(e,t),a=Math.max(0,(this.points.get(i)??0)+n);return this.points.set(i,a),{a:e,b:t,points:a,previousLevel:r,level:this.level(e,t)}}save(){return{pairs:[...this.points].map(([e,t])=>{let[n,r]=e.split(`\0`);return[n,r,t]})}}static restore(t,n){let r=new e(t);for(let[e,t,i]of n.pairs){if(!e||!t||e===t||!Number.isFinite(i)||i<0)throw Error(`invalid support save data`);let n=cj(e,t);if(r.points.has(n))throw Error(`invalid support save data: duplicate pair "${e}" / "${t}"`);r.points.set(n,i)}return r}};function cj(e,t){return[e,t].sort().join(`\0`)}var lj=l({Advancement:()=>GA,Appearances:()=>QA,AuraField:()=>oj,Charges:()=>UA,EquipmentSlots:()=>PA,Inventory:()=>FA,Progression:()=>jA,SkillPoints:()=>NA,StatBlock:()=>kA,SupportLedger:()=>sj,affixOf:()=>qA,applyAffix:()=>JA,applyItemStatusEffect:()=>HA,applyStatusEffect:()=>LA,assignAppearances:()=>ZA,assignTraits:()=>aj,buy:()=>$A,canAfford:()=>rj,craft:()=>IA,damageItem:()=>BA,enchant:()=>zA,identify:()=>RA,powerCurve:()=>AA,removeAffix:()=>YA,repairItem:()=>VA,rollAffix:()=>KA,rollLoot:()=>WA,scaledModifiers:()=>XA,sell:()=>ej,skillCheck:()=>MA,spend:()=>ij}),uj=class{constructor(){this.factories=new Map,this.loaded=new Map,this.currentId=null}define(e,t,n={}){this.factories.set(e,{create:t,persistent:n.persistent??!0})}enter(e,t){let n=this.factories.get(e);if(!n)throw Error(`no such map: "${e}"`);let r=this.loaded.get(e);return(!r||!n.persistent)&&(r=n.create(),this.loaded.set(e,r)),this.currentId=e,this.lastSpawn=t,r}get current(){return this.currentId?this.loaded.get(this.currentId)??null:null}get currentMapId(){return this.currentId}get spawn(){return this.lastSpawn}isLoaded(e){return this.loaded.has(e)}isPersistent(e){return this.factories.get(e)?.persistent??!0}unload(e){if(e===this.currentId)throw Error(`cannot unload the current map: "${e}"`);this.loaded.delete(e)}},dj=class{constructor(){this.locations=new Map}add(e){this.locations.set(e.id,e)}remove(e){this.locations.delete(e)}get(e){return this.locations.get(e)}at(e,t){for(let n of this.locations.values())if(n.x===e&&n.y===t)return n}get all(){return[...this.locations.values()]}},fj=class{constructor(){this.turn=0,this.effects=new Map}add(e){let t=Symbol();return this.effects.set(t,{...e}),t}remove(e){this.effects.delete(e)}has(e){return this.effects.has(e)}advance(e=1){this.turn+=e;for(let[t,n]of this.effects)n.tick(this.turn),n.duration!==void 0&&(n.duration-=e,n.duration<=0&&(this.effects.delete(t),n.onExpire?.()))}};function pj(e){if(e.entries.length===0||!TE(e.rate))return null;let t=DE(e.entries.map(e=>e.weight));return t===-1?null:e.entries[t].value}var mj=class e{constructor(e={}){if(this.changed=new vT,this.dayLength=e.dayLength??120,!(this.dayLength>0))throw Error(`an environment day must be longer than zero seconds`);if(this.boundaries=e.phaseBoundaries??[.2,.7,.8],this.boundaries[0]<=0||this.boundaries[0]>=this.boundaries[1]||this.boundaries[1]>=this.boundaries[2]||this.boundaries[2]>=1)throw Error(`environment phase boundaries must be ascending fractions strictly between 0 and 1`);if(this.seconds_=e.startSeconds??0,this.weather_=e.startWeather??`clear`,!Number.isFinite(this.seconds_))throw Error(`environment startSeconds must be finite`)}get day(){return Math.floor(this.seconds_/this.dayLength)}get seconds(){return this.seconds_}get weather(){return this.weather_}get phase(){let e=(this.seconds_%this.dayLength+this.dayLength)%this.dayLength/this.dayLength;return e<this.boundaries[0]?`dawn`:e<this.boundaries[1]?`day`:e<this.boundaries[2]?`dusk`:`night`}get night(){return this.phase===`night`}advance(e){if(!Number.isFinite(e)||e<0)throw Error(`environment advance must be non-negative, got ${e}`);this.seconds_+=e;let t=this.snapshot();return this.changed.dispatch(t),t}setWeather(e){if(!e)throw Error(`weather needs a non-empty id`);this.weather_=e;let t=this.snapshot();return this.changed.dispatch(t),t}snapshot(){return{day:this.day,seconds:this.seconds_,phase:this.phase,weather:this.weather_}}static restore(t,n){return new e({...t,startSeconds:n.seconds,startWeather:n.weather})}},hj=l({EnvironmentClock:()=>mj,Overworld:()=>dj,TurnClock:()=>fj,World:()=>uj,rollEncounter:()=>pj}),gj=536870911,_j={orthogonal:`square`,isometric:`isometric`,staggered:`staggered`};function vj(e,t,n){if(e.frameWidth!==t.tilewidth||e.frameHeight!==t.tileheight)throw Error(`the tileset at firstgid ${n} is cut to ${e.frameWidth}x${e.frameHeight}, but the map is ${t.tilewidth}x${t.tileheight}`)}function yj(e,t,n){let r=-1;for(let n=0;n<t.length&&t[n]<=e;n++)r=n;if(r===-1)throw Error(`layer "${n}" uses gid ${e}, below every tileset's firstgid (${t.join(`, `)})`);return r}function bj(e,t){let n=e.orientation??`orthogonal`,r=_j[n];if(!r)throw Error(`loadTiledMap does not read "${n}" maps yet`);if(r===`staggered`&&(e.staggeraxis??`y`)!==`y`)throw Error(`loadTiledMap only reads Y-axis staggered maps right now, this one is staggered on "${e.staggeraxis}"`);if(r===`staggered`&&(e.staggerindex??`odd`)!==`odd`)throw Error(`loadTiledMap only reads odd-index staggered maps right now, this one staggers "${e.staggerindex}"`);if(e.tilesets.length===0)throw Error(`loadTiledMap needs at least one tileset, this map has none`);let i=[...e.tilesets].sort((e,t)=>e.firstgid-t.firstgid),a,o;if(t instanceof $D){if(e.tilesets.length!==1)throw Error(`loadTiledMap was given one sheet but this map has ${e.tilesets.length} tilesets - pass one sheet per tileset`);vj(t,e,i[0].firstgid),a=[t],o=[i[0].firstgid]}else{if(t.length!==e.tilesets.length)throw Error(`loadTiledMap was given ${t.length} sheets but this map has ${e.tilesets.length} tilesets - pass one sheet per tileset`);a=i.map(n=>{let r=t.find(e=>e.firstgid===n.firstgid);if(!r)throw Error(`loadTiledMap was given no sheet for the tileset at firstgid ${n.firstgid}`);return vj(r.sheet,e,n.firstgid),r.sheet}),o=i.map(e=>e.firstgid)}let s=new gO({width:e.width,height:e.height,sheet:a,shape:r}),c=[];for(let t of e.layers)if(t.type===`tilelayer`){if(t.encoding&&t.encoding!==`csv`)throw Error(`layer "${t.name}" uses "${t.encoding}" encoding - export tile layers as CSV/plain, not compressed`);let e=(t.data??[]).map(e=>{let n=e&gj;if(n===0)return-1;let r=yj(n,o,t.name);return o.length===1?n-o[0]:pO(r,n-o[r])});s.addLayer(t.name,e)}else if(t.type===`objectgroup`)for(let n of t.objects??[])c.push({...n,tileX:Math.floor(n.x/e.tilewidth),tileY:Math.floor(n.y/e.tileheight)});return{map:s,objects:c}}function xj(e,t,n={}){let r=n.pick??SE,i=0;return t.forEach((t,n)=>{Sj(t,t.name??`#${n+1}`);let a=Cj(e,t);if(i+=a.length,a.length!==0)for(let[n,i]of a){let a=t.outputs[r(t.outputs.length)];for(let[r,o]of Object.entries(a))for(let a=0;a<t.height;a++)for(let s=0;s<t.width;s++){let c=o[a*t.width+s];c!==-1&&e.setTile(r,n+s,i+a,c)}}}),i}function Sj(e,t){if(!Number.isInteger(e.width)||e.width<=0||!Number.isInteger(e.height)||e.height<=0)throw Error(`automap rule "${t}" needs a positive width and height`);if(e.outputs.length===0)throw Error(`automap rule "${t}" has no outputs - a rule that matches and writes nothing is a mistake`);let n=e.width*e.height;for(let[r,i]of Object.entries(e.input))if(i.length!==n)throw Error(`automap rule "${t}" input "${r}" has ${i.length} cells, but the pattern is ${n}`);e.outputs.forEach((e,r)=>{for(let[i,a]of Object.entries(e))if(a.length!==n)throw Error(`automap rule "${t}" output ${r+1} "${i}" has ${a.length} cells, but the pattern is ${n}`)})}function Cj(e,t){let n=[];for(let r=0;r+t.height<=e.heightInTiles;r++)for(let i=0;i+t.width<=e.widthInTiles;i++)wj(e,t,i,r)&&n.push([i,r]);return n}function wj(e,t,n,r){for(let[i,a]of Object.entries(t.input))for(let o=0;o<t.height;o++)for(let s=0;s<t.width;s++){let c=a[o*t.width+s];if(c!==-1&&e.getTile(i,n+s,r+o)!==c)return!1}return!0}var Tj=class e{constructor(){this.switches=new Map,this.variables=new Map}switch(e){return this.switches.get(e)??!1}setSwitch(e,t){this.switches.set(e,t)}variable(e){return this.variables.get(e)??0}setVariable(e,t){this.variables.set(e,t)}toJSON(){return{switches:[...this.switches],variables:[...this.variables]}}static fromJSON(t){let n=new e;for(let[e,r]of t.switches)n.setSwitch(e,r);for(let[e,r]of t.variables)n.setVariable(e,r);return n}};function Ej(e,t){return`switch`in e?t.switch(e.switch)===e.equals:t.variable(e.variable)>=e.atLeast}function Dj(e,t){let n;for(let r of e.pages)(r.conditions??[]).every(e=>Ej(e,t))&&(n=r);return n}var Oj=class{constructor(e){this.cancelled=!1,this.options=e,this.state={game:e.game,answers:{}}}cancel(){this.cancelled=!0}async run(e){for(let t of e){if(this.cancelled)break;await this.step(t)}return this.state}async step(e){if(`say`in e){await this.speak(e.say,e.speaker);return}if(`ask`in e){let t=await this.speak(e.ask,e.speaker,e.choices);e.store&&(this.state.answers[e.store]=t);return}if(`wait`in e){await new Promise(t=>setTimeout(t,e.wait*1e3));return}if(`setSwitch`in e){this.state.game.setSwitch(e.setSwitch,e.value);return}if(`setVariable`in e){this.state.game.setVariable(e.setVariable,e.value);return}if(`addVariable`in e){let t=this.state.game.variable(e.addVariable);this.state.game.setVariable(e.addVariable,t+e.amount);return}if(`if`in e){let t=Ej(e.if,this.state.game);await this.run(t?e.then:e.else??[]);return}if(`move`in e){await this.options.move?.(e.move.target,e.move.steps);return}`call`in e&&await e.call(this.state)}speak(e,t,n){let{windows:r}=this.options;return new Promise(i=>{r.push(new UO({width:this.options.boxWidth??480,height:this.options.boxHeight??120,speed:this.options.speed??45,pages:[{text:e,speaker:t}],choices:n,anchor:`bottom`,onDone:e=>i(e)}))})}},kj=class{constructor(e,t,n,r){this.facing=`down`,this.target=null,this.progress=0,this.sprite=e,this.x=this.fromX=t,this.y=this.fromY=n,this.tileWidth=r.tileWidth,this.tileHeight=r.tileHeight,this.speed=r.speed??4,this.options=r,this.place(),this.playIdle()}get isMoving(){return this.target!==null}turnTo(e,t){this.target||(this.facing=Aj(e,t),this.playIdle())}moveBy(e,t){return!this.target&&(this.facing=Aj(e,t),this.fromX=this.x,this.fromY=this.y,this.target={x:this.x+e,y:this.y+t},this.progress=0,this.playWalk(),!0)}update(e){this.sprite.update(e),this.target&&(this.progress=Math.min(1,this.progress+this.speed*e),this.sprite.x=jj(this.fromX,this.target.x,this.progress)*this.tileWidth,this.sprite.y=jj(this.fromY,this.target.y,this.progress)*this.tileHeight,this.progress>=1&&(this.x=this.target.x,this.y=this.target.y,this.target=null,this.playIdle()))}place(){this.sprite.x=this.x*this.tileWidth,this.sprite.y=this.y*this.tileHeight}playWalk(){let e=this.options.walkAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}playIdle(){let e=this.options.idleAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}};function Aj(e,t){return e>0?`right`:e<0?`left`:t>0?`down`:`up`}function jj(e,t,n){return e+(t-e)*n}var Mj=class{constructor(e,t,n,r={}){this.facing=0,this.moving=!1,this.sprite=e,this.x=t,this.y=n,this.speed=r.speed??4,this.options=r,this.place(),this.playIdle()}get isMoving(){return this.moving}move(e,t,n){let r=Math.hypot(e,t);r>0?(this.facing=Math.atan2(t,e),this.x+=e/r*this.speed*n,this.y+=t/r*this.speed*n,this.moving||(this.moving=!0,this.playWalk())):this.moving&&(this.moving=!1,this.playIdle()),this.place(),this.sprite.update(n)}turnTo(e,t){this.moving||e===0&&t===0||(this.facing=Math.atan2(t,e),this.playIdle())}place(){this.sprite.x=this.x,this.sprite.y=this.y}playWalk(){let e=this.options.walkAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}playIdle(){let e=this.options.idleAnimation?.(this.facing);e&&this.sprite.has(e)&&this.sprite.play(e)}};function Nj(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Pj(e,t){let n=e.x-t.x,r=e.y-t.y,i=e.radius+t.radius;return n*n+r*r<i*i}function Fj(e,t){let n=Rj(e.x,t.x,t.x+t.width),r=Rj(e.y,t.y,t.y+t.height),i=e.x-n,a=e.y-r;return i*i+a*a<e.radius*e.radius}function Ij(e,t,n,r){let{tileSize:i,isSolid:a}=r;if(!(i>0))throw Error(`collision tileSize must be positive`);let o=Lj(e.x,e.y,e.width,e.height,t,i,a,!0);return{x:o,y:Lj(o,e.y,e.width,e.height,n,i,a,!1)}}function Lj(e,t,n,r,i,a,o,s){if(i===0)return s?e:t;let c=s?e:t,l=s?n:r,u=c+i,d=Math.floor((s?t:e)/a),f=Math.floor(((s?t+r:e+n)-1e-6)/a),p=(e,t)=>s?o(e,t):o(t,e);if(i>0){let e=Math.floor((c+l-1e-6)/a),t=Math.floor((u+l-1e-6)/a);for(let n=e+1;n<=t;n++)for(let e=d;e<=f;e++)if(p(n,e))return n*a-l}else{let e=Math.floor(c/a),t=Math.floor(u/a);for(let n=e-1;n>=t;n--)for(let e=d;e<=f;e++)if(p(n,e))return(n+1)*a}return u}function Rj(e,t,n){return e<t?t:e>n?n:e}var zj=class e{constructor(){this.definitions=new Map,this.stageIndex=new Map,this.tracked=null}define(e){this.definitions.set(e.id,e)}track(e){e!==null&&this.require(e),this.tracked=e}trackedQuest(){return this.tracked!==null&&this.status(this.tracked)===`active`?this.tracked:null}trackedLocation(){let e=this.trackedQuest();return e?this.currentStage(e)?.location??null:null}markerFor(e,t){return e.some(e=>this.status(e)===`active`&&this.stageSatisfied(e,t))?`turnIn`:e.some(e=>this.status(e)===`available`)?`offer`:`none`}canStart(e){return(this.require(e).requires??[]).every(e=>this.status(e)===`complete`)}start(e){if(!this.canStart(e))throw Error(`quest "${e}" cannot start yet - a prerequisite is incomplete`);this.stageIndex.set(e,0)}status(e){let t=this.require(e),n=this.stageIndex.get(e);return n===void 0?this.canStart(e)?`available`:`unavailable`:n>=t.stages.length?`complete`:`active`}currentStage(e){return this.status(e)===`active`?this.require(e).stages[this.stageIndex.get(e)]:null}progress(e,t){let n=this.currentStage(e);return n?.counter?Math.min(1,t.variable(n.counter.variable)/n.counter.target):null}advance(e,t){return this.stageSatisfied(e,t)?(this.stageIndex.set(e,this.stageIndex.get(e)+1),!0):!1}stageSatisfied(e,t){let n=this.currentStage(e);return n?n.condition?Ej(n.condition,t):!n.counter||t.variable(n.counter.variable)>=n.counter.target:!1}require(e){let t=this.definitions.get(e);if(!t)throw Error(`no such quest: "${e}"`);return t}toJSON(){return{stageIndex:[...this.stageIndex],tracked:this.tracked}}static fromJSON(t,n){let r=new e;for(let e of t)r.define(e);for(let[e,t]of n.stageIndex)r.stageIndex.set(e,t);return n.tracked&&(r.tracked=n.tracked),r}},Bj=class{constructor(e){this.name=e}},Vj=4,Hj=8,Uj=new WeakMap;function Wj(e){return Uj.get(e)}function Gj(e,t){return Uj.set(e,t),e}var Kj=class{constructor(e){this.pos=0,this.symbols=[],this.objects=[],this.bytes=e}byte(){if(this.pos>=this.bytes.length)throw Error(`Marshal: unexpected end of input`);return this.bytes[this.pos++]}take(e){if(e<0)throw Error(`Marshal: negative length`);let t=this.bytes.subarray(this.pos,this.pos+e);if(t.length<e)throw Error(`Marshal: unexpected end of input`);return this.pos+=e,t}readFixnum(){let e=this.byte()<<24>>24;if(e===0)return 0;if(e>=5&&e<=127)return e-5;if(e<=-5&&e>=-128)return e+5;if(e>0){let t=0;for(let n=0;n<e;n++)t|=this.byte()<<8*n;return t>>>0}let t=-e,n=0;for(let e=0;e<t;e++)n|=this.byte()<<8*e;return(n>>>0)-2**(8*t)}readBytes(){return this.take(this.readFixnum())}readSymbol(){let e=new TextDecoder().decode(this.readBytes());return this.symbols.push(e),e}readSymbolLink(){let e=this.readFixnum(),t=this.symbols[e];if(t===void 0)throw Error(`Marshal: symbol link ${e} out of range`);return t}readSymbolValue(){let e=String.fromCharCode(this.byte());if(e===`:`)return this.readSymbol();if(e===`;`)return this.readSymbolLink();throw Error(`Marshal: expected a symbol, got tag "${e}"`)}link(e){return this.objects.push(e),e}readBignum(){let e=String.fromCharCode(this.byte())===`-`?-1:1,t=this.readFixnum(),n=0,r=1;for(let e=0;e<t;e++)n+=(this.byte()|this.byte()<<8)*r,r*=65536;return e*n}readFloat(){let e=new TextDecoder().decode(this.readBytes());return e===`inf`?1/0:e===`-inf`?-1/0:e===`nan`?NaN:Number(e)}readArray(){let e=[];this.link(e);let t=this.readFixnum();for(let n=0;n<t;n++)e.push(this.readValue());return e}readHash(e){let t=new Map;this.link(t);let n=this.readFixnum();for(let e=0;e<n;e++)t.set(this.readValue(),this.readValue());return e&&Uj.set(t,this.readValue()),t}readIvars(e){let t={};for(let n=0;n<e;n++)t[this.readSymbolValue()]=this.readValue();return t}readObject(){let e={class:``,ivars:{}};return this.link(e),e.class=this.readSymbolValue(),e.ivars=this.readIvars(this.readFixnum()),e}readIvarWrapped(){let e=this.readValue();return this.readIvars(this.readFixnum()),e}readUserDefined(){let e={class:``,raw:new Uint8Array};return this.link(e),e.class=this.readSymbolValue(),e.raw=this.readBytes().slice(),e}readUserMarshal(){let e={class:``,value:null};return this.link(e),e.class=this.readSymbolValue(),e.value=this.readValue(),e}readValue(){let e=String.fromCharCode(this.byte());switch(e){case`0`:return null;case`T`:return!0;case`F`:return!1;case`i`:return this.readFixnum();case`l`:return this.link(this.readBignum());case`f`:return this.link(this.readFloat());case`:`:return this.readSymbol();case`;`:return this.readSymbolLink();case`"`:return this.link(new TextDecoder().decode(this.readBytes()));case`[`:return this.readArray();case`{`:return this.readHash(!1);case`}`:return this.readHash(!0);case`o`:return this.readObject();case`I`:return this.readIvarWrapped();case`u`:return this.readUserDefined();case`U`:return this.readUserMarshal();case`@`:{let e=this.readFixnum(),t=this.objects[e];if(t===void 0)throw Error(`Marshal: object link ${e} out of range`);return t}default:throw Error(`Marshal: unsupported tag "${e}" (0x${e.charCodeAt(0).toString(16)})`)}}readDocument(){let e=this.byte(),t=this.byte();if(e!==Vj||t>Hj)throw Error(`Marshal: unsupported version ${e}.${t} (expected ${Vj}.${Hj} or lower)`);return this.readValue()}};function qj(e){return new Kj(e).readDocument()}function Jj(e){return typeof e==`object`&&!!e&&`class`in e&&`ivars`in e}function Yj(e){let t=[Vj,Hj];return Xj(t,e),new Uint8Array(t)}function Xj(e,t){if(t==null)e.push(Zj(`0`));else if(t===!0)e.push(Zj(`T`));else if(t===!1)e.push(Zj(`F`));else if(t instanceof Bj)e.push(Zj(`:`)),Qj(e,t.name);else if(typeof t==`number`)Number.isInteger(t)&&Math.abs(t)<2**30?(e.push(Zj(`i`)),$j(e,t)):(e.push(Zj(`f`)),Qj(e,Number.isFinite(t)?String(t):t>0?`inf`:t<0?`-inf`:`nan`));else if(typeof t==`string`)e.push(Zj(`"`)),Qj(e,t);else if(Array.isArray(t)){e.push(Zj(`[`)),$j(e,t.length);for(let n of t)Xj(e,n)}else if(t instanceof Map){let n=Uj.has(t);e.push(Zj(n?`}`:`{`)),$j(e,t.size);for(let[n,r]of t)Xj(e,n),Xj(e,r);n&&Xj(e,Uj.get(t))}else if(Jj(t)){e.push(Zj(`o`)),e.push(Zj(`:`)),Qj(e,t.class);let n=Object.entries(t.ivars);$j(e,n.length);for(let[t,r]of n)e.push(Zj(`:`)),Qj(e,t),Xj(e,r)}else throw Error(`Marshal: cannot encode a value of type ${typeof t}`)}function Zj(e){return e.charCodeAt(0)}function Qj(e,t){let n=new TextEncoder().encode(t);$j(e,n.length);for(let t of n)e.push(t)}function $j(e,t){if(t===0){e.push(0);return}if(t>0&&t<=122){e.push(t+5);return}if(t<0&&t>=-123){e.push(t-5&255);return}if(t>0){for(let n=1;n<=4;n++)if(t<2**(8*n)){e.push(n);for(let r=0;r<n;r++)e.push(t>>>8*r&255);return}}else for(let n=1;n<=4;n++)if(t>=-(2**(8*n))){e.push(-n&255);let r=t+2**(8*n);for(let t=0;t<n;t++)e.push(r>>>8*t&255);return}throw Error(`Marshal: integer ${t} is out of range for a Fixnum`)}var eM=l({EventRunner:()=>Oj,FreeMover:()=>Mj,GameState:()=>Tj,GridMover:()=>kj,QuestLog:()=>zj,RubySymbol:()=>Bj,aabbOverlap:()=>Nj,activePage:()=>Dj,automap:()=>xj,circleAabbOverlap:()=>Fj,circleOverlap:()=>Pj,conditionHolds:()=>Ej,decodeMarshal:()=>qj,encodeMarshal:()=>Yj,hashDefaultOf:()=>Wj,loadTiledMap:()=>bj,resolveAabbAgainstTiles:()=>Ij,withHashDefault:()=>Gj}),tM=AA(20,2,100),nM=class{constructor(e){this.species=e.species,this.deriveStats=e.deriveStats,this.progression=new jA(e.species.growth??tM,{level:e.level??1}),this.stats=new kA({base:this.computeBase()})}refreshStats(){let e=this.computeBase();for(let[t,n]of Object.entries(e))this.stats.setBase(t,n)}computeBase(){let e=this.progression.level;return this.deriveStats?this.deriveStats(this.species.baseStats,e):{...this.species.baseStats}}},rM=class{constructor(){this.multipliers=new Map}key(e,t){return`${e}:${t}`}set(e,t,n){this.multipliers.set(this.key(e,t),n)}get(e,t){return this.multipliers.get(this.key(e,t))??1}multiplierFor(e,t){return t.reduce((t,n)=>t*this.get(e,n),1)}},iM=class{constructor(e){this.storage=[],this.active=Array(e).fill(null)}get members(){return this.active}get boxed(){return this.storage}add(e){let t=this.active.indexOf(null);t===-1?this.storage.push(e):this.active[t]=e}store(e){let t=this.active[e];t&&(this.active[e]=null,this.storage.push(t))}withdraw(e,t){if(t<0||t>=this.active.length)return;let n=this.storage[e];if(!n)return;this.storage.splice(e,1);let r=this.active[t];this.active[t]=n,r&&this.storage.push(r)}get activeMembers(){return this.active.filter(e=>e!==null)}};function aM(e){return[...e].sort((e,t)=>(t.priority??0)-(e.priority??0)||t.speed-e.speed)}function oM(e,t){let n=null;for(let r of e)r.at(t)&&(n=r.into);return n}var sM=class{constructor(e,t){this.stages=new Map,this.modifiers=new Map,this.stats=e,this.max=t.max,this.multiplierFor=t.multiplier}get(e){return this.stages.get(e)??0}change(e,t){let n=this.get(e),r=Math.max(-this.max,Math.min(this.max,n+t)),i=r-n;return i===0?0:(this.stages.set(e,r),this.applyModifier(e,r),i)}applyModifier(e,t){let n=this.modifiers.get(e);if(n&&this.stats.removeModifier(n),t===0){this.modifiers.delete(e);return}let r={stat:e,op:`multiply`,value:this.multiplierFor(t)};this.stats.addModifier(r),this.modifiers.set(e,r)}resetAll(){for(let e of this.modifiers.values())this.stats.removeModifier(e);this.modifiers.clear(),this.stages.clear()}};function cM(e,t,n,r=(e,n)=>t.multiplierFor(e.type,n)){if(e.length===0)return null;let i=e[0],a=r(i,n);for(let t of e.slice(1)){let e=r(t,n);e>a&&(a=e,i=t)}return i}function lM(e,t,n,r){let i=null,a=uM(e,n,r);return t.forEach((e,t)=>{let o=uM(e.types,n,r);o<a&&(a=o,i=t)}),i}function uM(e,t,n){return Math.max(...n.map(n=>t.multiplierFor(n,e)))}var dM=class{constructor(){this.hooks=[]}on(e,t,n){this.hooks.push({event:e,handler:t,source:n})}offSource(e){this.hooks=this.hooks.filter(t=>t.source!==e)}emit(e,t,n){for(let r of this.hooks)r.event===e&&r.handler(t,n)}},fM=class{constructor(){this.conditions=new Map}set(e){this.conditions.set(e.id,{...e})}has(e){return this.conditions.has(e)}get(e){return this.conditions.get(e)}clear(e){this.conditions.delete(e)}get active(){return[...this.conditions.values()]}advance(){for(let[e,t]of this.conditions)t.duration!==void 0&&(--t.duration,t.duration<=0&&this.conditions.delete(e))}},pM=l({BattleHooks:()=>dM,Creature:()=>nM,Field:()=>fM,Party:()=>iM,StatStages:()=>sM,TypeMatrix:()=>rM,battleOrder:()=>aM,checkEvolution:()=>oM,chooseMove:()=>cM,chooseSwitch:()=>lM});function mM(e){let t=e.charCodeAt(0)-97,n=e.charCodeAt(1)-49;if(t<0||t>7||n<0||n>7||e.length!==2)throw Error(`not a square: "${e}"`);return n*8+t}function hM(e){return String.fromCharCode(97+(e&7))+String.fromCharCode(49+(e>>3))}function gM(e){let t=e.trim().split(/\s+/);if(t.length<4)throw Error(`not a FEN string: "${e}"`);let n=Array(64).fill(null),r=t[0].split(`/`);if(r.length!==8)throw Error(`a FEN placement needs 8 ranks: "${e}"`);if(r.forEach((t,r)=>{let i=7-r,a=0;for(let r of t)if(r>=`1`&&r<=`8`)a+=r.charCodeAt(0)-48;else{let o=r===r.toUpperCase()?`white`:`black`,s={p:`pawn`,n:`knight`,b:`bishop`,r:`rook`,q:`queen`,k:`king`}[r.toLowerCase()];if(!s||a>7)throw Error(`bad FEN rank "${t}" in "${e}"`);n[i*8+a]={side:o,kind:s},a++}if(a!==8)throw Error(`bad FEN rank "${t}" in "${e}"`)}),t[1]!==`w`&&t[1]!==`b`)throw Error(`a FEN side is "w" or "b": "${e}"`);let i={whiteKingside:!1,whiteQueenside:!1,blackKingside:!1,blackQueenside:!1};if(t[2]!==`-`)for(let n of t[2])if(n===`K`)i.whiteKingside=!0;else if(n===`Q`)i.whiteQueenside=!0;else if(n===`k`)i.blackKingside=!0;else if(n===`q`)i.blackQueenside=!0;else throw Error(`bad FEN castling "${t[2]}" in "${e}"`);let a=t[3]===`-`?null:mM(t[3]);if(a!==null){let n=t[1]===`w`?5:2;if(yM(a)!==n)throw Error(`bad FEN en passant square "${t[3]}" in "${e}"`)}let o={board:n,turn:t[1]===`w`?`white`:`black`,castling:i,enPassant:a};return OM(n,`white`),OM(n,`black`),o}function _M(e){return e===`white`?`black`:`white`}function vM(e){return e&7}function yM(e){return e>>3}function bM(e,t){return e>=0&&e<8&&t>=0&&t<8}function xM(){let e=[`rook`,`knight`,`bishop`,`queen`,`king`,`bishop`,`knight`,`rook`],t=Array(64).fill(null);for(let n=0;n<8;n++)t[n]={side:`white`,kind:e[n]},t[8+n]={side:`white`,kind:`pawn`},t[48+n]={side:`black`,kind:`pawn`},t[56+n]={side:`black`,kind:e[n]};return{board:t,turn:`white`,castling:{whiteKingside:!0,whiteQueenside:!0,blackKingside:!0,blackQueenside:!0},enPassant:null}}function SM(e){return{board:e.board.map(e=>e?{side:e.side,kind:e.kind}:null),turn:e.turn,castling:{...e.castling},enPassant:e.enPassant}}var CM=[[1,2],[2,1],[2,-1],[1,-2],[-1,-2],[-2,-1],[-2,1],[-1,2]],wM=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]],TM=[[1,1],[-1,1],[-1,-1],[1,-1]],EM=[[1,0],[0,1],[-1,0],[0,-1]];function DM(e,t,n){let r=vM(t),i=yM(t),a=n===`white`?i-1:i+1;for(let t of[-1,1]){if(!bM(r+t,a))continue;let i=e[a*8+r+t];if(i&&i.side===n&&i.kind===`pawn`)return!0}for(let[t,a]of CM){if(!bM(r+t,i+a))continue;let o=e[(i+a)*8+r+t];if(o&&o.side===n&&o.kind===`knight`)return!0}for(let[t,a]of wM){if(!bM(r+t,i+a))continue;let o=e[(i+a)*8+r+t];if(o&&o.side===n&&o.kind===`king`)return!0}let o=[{steps:TM,kinds:[`bishop`,`queen`]},{steps:EM,kinds:[`rook`,`queen`]}];for(let{steps:t,kinds:a}of o)for(let[o,s]of t){let t=r+o,c=i+s;for(;bM(t,c);){let r=e[c*8+t];if(r){if(r.side===n&&a.includes(r.kind))return!0;break}t+=o,c+=s}}return!1}function OM(e,t){let n=e.findIndex(e=>e!==null&&e.side===t&&e.kind===`king`);if(n===-1)throw Error(`a position without a ${t} king cannot be judged`);return n}function kM(e,t){return DM(e.board,OM(e.board,t),_M(t))}function AM(e,t){let n=e.board[t];if(!n||n.side!==e.turn)return[];let r=[],i=vM(t),a=yM(t),o=o=>{for(let[s,c]of o){let o=i+s,l=a+c;for(;bM(o,l);){let i=l*8+o,a=e.board[i];if(!a)r.push({from:t,to:i});else{a.side!==n.side&&r.push({from:t,to:i});break}o+=s,l+=c}}};switch(n.kind){case`pawn`:{let o=n.side===`white`?1:-1,s=n.side===`white`?1:6,c=n.side===`white`?7:0;if(bM(i,a+o)&&!e.board[(a+o)*8+i]){let n=(a+o)*8+i;if(a+o===c)for(let e of[`knight`,`bishop`,`rook`,`queen`])r.push({from:t,to:n,promotion:e});else r.push({from:t,to:n}),a===s&&!e.board[(a+2*o)*8+i]&&r.push({from:t,to:(a+2*o)*8+i})}for(let s of[-1,1]){if(!bM(i+s,a+o))continue;let l=(a+o)*8+i+s,u=e.board[l];if(u&&u.side!==n.side){if(a+o===c)for(let e of[`knight`,`bishop`,`rook`,`queen`])r.push({from:t,to:l,promotion:e});else r.push({from:t,to:l})}else!u&&l===e.enPassant&&r.push({from:t,to:l,enPassantTake:a*8+i+s})}break}case`knight`:for(let[o,s]of CM){if(!bM(i+o,a+s))continue;let c=(a+s)*8+i+o,l=e.board[c];(!l||l.side!==n.side)&&r.push({from:t,to:c})}break;case`bishop`:o(TM);break;case`rook`:o(EM);break;case`queen`:o(TM),o(EM);break;case`king`:{for(let[o,s]of wM){if(!bM(i+o,a+s))continue;let c=(a+s)*8+i+o,l=e.board[c];l&&l.side===n.side||l&&l.kind===`king`||r.push({from:t,to:c})}let o=n.side===`white`?0:56,s=n.side===`white`?{king:e.castling.whiteKingside,queen:e.castling.whiteQueenside}:{king:e.castling.blackKingside,queen:e.castling.blackQueenside};t===o+4&&!kM(e,n.side)&&(s.king&&!e.board[o+5]&&!e.board[o+6]&&!DM(e.board,o+5,_M(n.side))&&!DM(e.board,o+6,_M(n.side))&&r.push({from:t,to:o+6,castle:`kingside`}),s.queen&&!e.board[o+3]&&!e.board[o+2]&&!e.board[o+1]&&!DM(e.board,o+3,_M(n.side))&&!DM(e.board,o+2,_M(n.side))&&r.push({from:t,to:o+2,castle:`queenside`}));break}}return r}function jM(e,t){let n=e.board[t.from];if(!n)throw Error(`no piece on ${hM(t.from)} to move`);let r=(e,t)=>{let n=e===`white`?0:56;return t===n||t===n+7};n.kind===`king`&&(n.side===`white`?e.castling.whiteKingside=e.castling.whiteQueenside=!1:e.castling.blackKingside=e.castling.blackQueenside=!1),n.kind===`rook`&&r(n.side,t.from)&&(e.castling[MM(n.side,t.from)]=!1);let i=e.board[t.to];if(i&&i.kind===`rook`&&r(i.side,t.to)&&(e.castling[MM(i.side,t.to)]=!1),e.board[t.to]=t.promotion?{side:n.side,kind:t.promotion}:n,e.board[t.from]=null,t.enPassantTake!==void 0&&(e.board[t.enPassantTake]=null),t.castle){let r=n.side===`white`?0:56;t.castle===`kingside`?(e.board[r+5]=e.board[r+7],e.board[r+7]=null):(e.board[r+3]=e.board[r],e.board[r]=null)}e.enPassant=n.kind===`pawn`&&Math.abs(t.to-t.from)===16?(t.from+t.to)/2:null,e.turn=_M(n.side)}function MM(e,t){let n=vM(t)===7;return e===`white`?n?`whiteKingside`:`whiteQueenside`:n?`blackKingside`:`blackQueenside`}function NM(e){let t=[];for(let n=0;n<64;n++)if(!(!e.board[n]||e.board[n]?.side!==e.turn))for(let r of AM(e,n)){let n=SM(e);jM(n,r),!kM(n,e.turn)&&t.push({from:r.from,to:r.to,...r.promotion?{promotion:r.promotion}:{}})}return t}function PM(e,t){let n=e.board[t.from];if(!n||n.side!==e.turn)throw Error(`no ${e.turn} piece on ${hM(t.from)} to move`);let r=AM(e,t.from).find(e=>e.to===t.to&&(e.promotion??null)===(t.promotion??null));if(!r)throw Error(`${hM(t.from)}-${hM(t.to)} is not a legal move here`);let i=SM(e);if(jM(i,r),kM(i,e.turn))throw Error(`${hM(t.from)}-${hM(t.to)} leaves the king in check`);jM(e,r)}function FM(e){return NM(e).length>0?`ongoing`:kM(e,e.turn)?e.turn===`white`?`black-wins`:`white-wins`:`stalemate`}var IM={pawn:100,knight:320,bishop:330,rook:500,queen:900,king:0};function LM(e,t={}){return RM(e,t).move}function RM(e,t={}){let n=Math.max(1,Math.floor(t.depth??3)),r=t.maxNodes===void 0?1/0:Math.max(1,Math.floor(t.maxNodes)),i=VM(e,NM(e));if(i.length===0)return{move:null,score:BM(e,0),nodes:1};let a=0,o=i[0],s=-1/0,c=-1/0;for(let t of i){if(a>=r)break;let i=SM(e);PM(i,t);let u=-l(i,n-1,-1/0,-c,1);u>s&&(s=u,o=t),c=Math.max(c,u)}return{move:o,score:s,nodes:a};function l(e,t,n,i,o){if(a>=r)return zM(e);if(a++,FM(e)!==`ongoing`)return BM(e,o);if(t===0)return zM(e);let s=-1/0;for(let r of VM(e,NM(e))){let a=SM(e);if(PM(a,r),s=Math.max(s,-l(a,t-1,-i,-n,o+1)),n=Math.max(n,s),n>=i)break}return s}}function zM(e){let t=0;for(let n of e.board)n&&(t+=(n.side===`white`?1:-1)*IM[n.kind]);return e.turn===`white`?t:-t}function BM(e,t){return kM(e,e.turn)?-1e5+t:0}function VM(e,t){return t.slice().sort((t,n)=>HM(e,n)-HM(e,t))}function HM(e,t){let n=e.board[t.to];return(t.promotion?IM[t.promotion]:0)*10+(n?IM[n.kind]:0)}var UM=class{constructor(e,t,n){if(this.width=e,this.height=t,e<1||t<1)throw Error(`a board needs positive dimensions`);if(n&&n.length!==e*t)throw Error(`board cell count does not match dimensions`);this.cells=n?[...n]:Array(e*t).fill(null)}index(e,t){if(!this.inside(e,t))throw Error(`cell (${e},${t}) is outside the board`);return t*this.width+e}inside(e,t){return e>=0&&t>=0&&e<this.width&&t<this.height}get(e,t){return this.cells[this.index(e,t)]}set(e,t,n){this.cells[this.index(e,t)]=n}move(e,t){let n=this.get(e.x,e.y);if(n===null)throw Error(`cannot move an empty cell`);return this.set(e.x,e.y,null),this.set(t.x,t.y,n),n}};function WM(){let e=Array(64).fill(null);for(let t=0;t<3;t++)for(let n=0;n<8;n++)(n+t)%2&&(e[t*8+n]={side:`black`,king:!1});for(let t=5;t<8;t++)for(let n=0;n<8;n++)(n+t)%2&&(e[t*8+n]={side:`red`,king:!1});return{board:e,turn:`red`,forcedFrom:null}}function GM(e){let t=e.forcedFrom===null?e.board.map((t,n)=>t?.side===e.turn?n:-1).filter(e=>e>=0):[e.forcedFrom],n=t.flatMap(t=>qM(e,t,!0));return n.length>0?n:e.forcedFrom===null?t.flatMap(t=>qM(e,t,!1)):[]}function KM(e,t){if(!GM(e).some(e=>e.from===t.from&&e.to===t.to&&e.captures.length===t.captures.length))throw Error(`illegal checkers move`);let n=e.board[t.from];if(!n)throw Error(`no checkers piece on the source cell`);e.board[t.from]=null;for(let n of t.captures)e.board[n]=null;let r=!n.king&&(n.side===`red`&&Math.floor(t.to/8)===0||n.side===`black`&&Math.floor(t.to/8)===7);e.board[t.to]={...n,king:n.king||r};let i={board:e.board,turn:e.turn,forcedFrom:t.captures.length>0?t.to:null};t.captures.length===0||qM(i,t.to,!0).length===0?(e.turn=e.turn===`red`?`black`:`red`,e.forcedFrom=null):e.forcedFrom=t.to}function qM(e,t,n){let r=e.board[t];if(!r)return[];let i=t%8,a=Math.floor(t/8),o=r.king?[-1,1]:r.side===`red`?[-1]:[1],s=[];for(let c of o)for(let o of[-1,1]){let l=i+o,u=a+c,d=i+o*2,f=a+c*2;if(n){if(d<0||f<0||d>=8||f>=8)continue;let n=u*8+l,i=f*8+d;e.board[n]?.side!==r.side&&e.board[n]&&!e.board[i]&&s.push({from:t,to:i,captures:[n]})}else l>=0&&u>=0&&l<8&&u<8&&!e.board[u*8+l]&&s.push({from:t,to:u*8+l,captures:[]})}return s}function JM(e=9){if(e<2||e>25)throw Error(`Go size must be between 2 and 25`);return{size:e,board:Array(e*e).fill(null),turn:`black`,ko:null,passes:0}}function YM(e,t,n){let r=$M(e,t,n);if(e.board[r]||e.ko===r)throw Error(`Go cell is occupied or forbidden by ko`);let i=[...e.board];i[r]=e.turn;let a=e.turn===`black`?`white`:`black`,o=0,s=null;for(let t of eN(e,r)){if(i[t]!==a||nN(i,e.size,t)!==0)continue;let n=tN(i,e.size,t);n.length===1&&(s=n[0]);for(let e of n)i[e]=null;o+=n.length}if(nN(i,e.size,r)===0)throw Error(`suicide is not a legal Go move`);e.ko=o===1&&nN(i,e.size,r)===1?s:null,e.board=i,e.turn=a,e.passes=0}function XM(e){e.turn=e.turn===`black`?`white`:`black`,e.ko=null,e.passes++}function ZM(e){return e.passes>=2?`finished`:`ongoing`}function QM(e){let t={black:0,white:0},n=new Set;for(let r=0;r<e.board.length;r++){let i=e.board[r];if(i)t[i]++;else if(!n.has(r)){let i=tN(e.board,e.size,r),a=new Set;for(let t of i)for(let n of eN(e,t))e.board[n]&&a.add(e.board[n]);for(let e of i)n.add(e);a.size===1&&(t[[...a][0]]+=i.length)}}return t}function $M(e,t,n){if(t<0||n<0||t>=e.size||n>=e.size)throw Error(`Go cell is outside the board`);return n*e.size+t}function eN(e,t){let n=t%e.size,r=Math.floor(t/e.size);return[[n-1,r],[n+1,r],[n,r-1],[n,r+1]].filter(([t,n])=>t>=0&&n>=0&&t<e.size&&n<e.size).map(([t,n])=>n*e.size+t)}function tN(e,t,n){let r=e[n];if(!r)return[];let i=[],a=[n],o=new Set;for(;a.length;){let n=a.pop();if(o.has(n)||e[n]!==r)continue;o.add(n),i.push(n);let s=n%t,c=Math.floor(n/t);for(let[e,n]of[[s-1,c],[s+1,c],[s,c-1],[s,c+1]])e>=0&&n>=0&&e<t&&n<t&&a.push(n*t+e)}return i}function nN(e,t,n){let r=tN(e,t,n),i=new Set;for(let n of r){let r=n%t,a=Math.floor(n/t);for(let[n,o]of[[r-1,a],[r+1,a],[r,a-1],[r,a+1]])n>=0&&o>=0&&n<t&&o<t&&e[o*t+n]===null&&i.add(o*t+n)}return i.size}function rN(){let e=Array(24).fill(0);return e[0]=2,e[11]=5,e[16]=3,e[18]=5,e[23]=-2,e[12]=-5,e[7]=-3,e[5]=-5,{points:e,bar:{white:0,black:0},off:{white:0,black:0},turn:`white`}}function iN(){let e=vN(2,6);return e[0]===e[1]?[...e,...e]:e}function aN(e,t){let n=e.turn===`white`?1:-1,r=[];for(let i of t){if(e.bar[e.turn]>0){let t=e.turn===`white`?i-1:24-i;sN(e,t,n)&&r.push({from:`bar`,to:t,die:i});continue}for(let t=0;t<24;t++)if(e.points[t]*n>0){let a=t+i*n;a<0||a>=24?r.push({from:t,to:`off`,die:i}):sN(e,a,n)&&r.push({from:t,to:a,die:i})}}return r}function oN(e,t){if(!aN(e,[t.die]).some(e=>e.from===t.from&&e.to===t.to))throw Error(`illegal backgammon move`);let n=e.turn===`white`?1:-1;if(t.from===`bar`?e.bar[e.turn]--:e.points[t.from]-=n,t.to===`off`)e.off[e.turn]++;else{if(e.points[t.to]*n<0){let n=e.turn===`white`?`black`:`white`;e.points[t.to]=0,e.bar[n]++}e.points[t.to]+=n}}function sN(e,t,n){return e.points[t]*n>=-1}function cN(e=0){let t=[`clubs`,`diamonds`,`hearts`,`spades`],n=[];for(let e of t)for(let t=1;t<=13;t++)n.push({suit:e,rank:t});return n.concat(Array(e).fill(null).map(()=>({suit:`spades`,rank:1})))}function lN(e){return kE(e)}function uN(e,t,n){if(t<0||n<0||e.length<t*n)throw Error(`not enough cards to deal`);return Array.from({length:t},()=>e.splice(0,n))}function dN(e,t){if(e.length===0)throw Error(`a trick needs at least one play`);let n=e[0].card.suit,r=e=>e.rank===1?14:e.rank;return(t&&e.some(e=>e.card.suit===t)?e.filter(e=>e.card.suit===t):e.filter(e=>e.card.suit===n)).reduce((e,t)=>r(t.card)>r(e.card)?t:e).owner}function fN(e){let t=cN();return e===void 0?lN(t):yE(e,()=>lN(t)),{stock:t,waste:[],tableau:Array.from({length:7},(e,n)=>({down:t.splice(0,6-n),up:t.splice(0,1)})),foundations:[[],[],[],[]]}}function pN(e){e.stock.length===0&&(e.stock=e.waste.reverse(),e.waste=[]);let t=e.stock.pop()??null;return t&&e.waste.push(t),t}function mN(e,t,n,r=1){let i=e.tableau[t],a=e.tableau[n],o=i?.up.slice(-r);if(!i||!a||!o?.length||(a.up.length===0?o[0].rank!==13:!_N(o[0],a.up.at(-1))))throw Error(`illegal solitaire tableau move`);i.up.splice(-r,r),a.up.push(...o),i.down.length&&i.up.length===0&&i.up.push(i.down.pop())}function hN(e,t){let n=t===`waste`?e.waste.at(-1):e.tableau[t].up.at(-1);if(!n)throw Error(`no solitaire card to move`);let r=e.foundations.find(e=>e[0]?.suit===n.suit||e.length===0);if(!r||n.rank!==r.length+1)throw Error(`card cannot move to its foundation`);if(t===`waste`)e.waste.pop();else{let n=e.tableau[t];n.up.pop(),n.down.length&&n.up.length===0&&n.up.push(n.down.pop())}r.push(n)}function gN(e){return e.foundations.every(e=>e.length===13)}function _N(e,t){let n=e.suit===`diamonds`||e.suit===`hearts`,r=t.suit===`diamonds`||t.suit===`hearts`;return e.rank===t.rank-1&&n!==r}function vN(e,t){if(!Number.isInteger(e)||e<0||!Number.isInteger(t)||t<1)throw Error(`dice need a non-negative count and positive sides`);return Array.from({length:e},()=>CE(1,t))}function yN(e){let t=/^(\d+)d(\d+)([+-]\d+)?$/i.exec(e.trim());if(!t)throw Error(`bad dice expression: "${e}"`);return vN(Number(t[1]),Number(t[2])).reduce((e,t)=>e+t,Number(t[3]??0))}var bN=class{constructor(e,t){this.kept=new Set,this.count=e,this.sides=t,this.values=vN(e,t)}reRoll(){for(let e=0;e<this.values.length;e++)this.kept.has(e)||(this.values[e]=CE(1,this.sides))}keep(e){if(e<0||e>=this.count)throw Error(`die index is outside the cup`);this.kept.add(e)}clearKept(){this.kept.clear()}};function xN(e,t){if(e.length!==5||e.some(e=>e<1||e>6))throw Error(`a score sheet needs five d6 values`);let n=new Map;for(let t of e)n.set(t,(n.get(t)??0)+1);let r=e.reduce((e,t)=>e+t,0);if(t===`chance`)return r;if(t===`yahtzee`)return n.size===1?50:0;if(t===`fullHouse`)return[...n.values()].sort().join(`,`)===`2,3`?25:0;if(t===`threeKind`)return[...n.values()].some(e=>e>=3)?r:0;if(t===`fourKind`)return[...n.values()].some(e=>e>=4)?r:0;if(t===`smallStraight`||t===`largeStraight`){let e=[`1234`,`2345`,`3456`],r=[`12345`,`23456`],i=[...n.keys()].sort().join(``);return(t===`smallStraight`?e:r).some(e=>i.includes(e))?t===`smallStraight`?30:40:0}let i=[`ones`,`twos`,`threes`,`fours`,`fives`,`sixes`].indexOf(t)+1;return i>0?(n.get(i)??0)*i:0}function SN(e,t,n=`hex`){if(e<1||t<1)throw Error(`a tactical map needs positive dimensions`);return{width:e,height:t,shape:n,cells:Array.from({length:e*t},()=>({passable:!0,cover:0})),units:[],turn:``,round:1}}function CN(e,t,n){return NN(e,t,n)&&!MN(e,t,n)}function wN(e,t){if(!CN(e,t.x,t.y))throw Error(`tactical unit cannot be placed there`);e.units.push({...t}),e.turn||=t.owner}function TN(e,t){let n=jN(e,t);if(n.owner!==e.turn||n.actions<=0)return[];let r=LN(e,n,IN(e,n)),i=[];for(let a=0;a<e.height;a++)for(let o=0;o<e.width;o++){if(o===n.x&&a===n.y||!e.cells[a*e.width+o].passable||MN(e,o,a))continue;let s=RN(e,n,o,a,n.actions,r);s!==null&&i.push({unit:t,x:o,y:a,cost:s})}return i}function EN(e,t){let n=TN(e,t.unit).find(e=>e.x===t.x&&e.y===t.y);if(!n)throw Error(`illegal tactical move`);let r=jN(e,t.unit);r.x=t.x,r.y=t.y,r.actions-=n.cost}function DN(e,t){let n=jN(e,t);if(n.owner!==e.turn||n.actions<=0)throw Error(`only an active unit can enter overwatch`);n.actions=0,n.overwatch=!0}function ON(e,t,n){let r=jN(e,t),i=[];for(let t of[...e.units]){if(!t.overwatch||t.owner===r.owner||FN(e,t,r)>3)continue;let a=e.cells[r.y*e.width+r.x].cover??0,o=Math.max(0,n-a);if(r.hp=Math.max(0,r.hp-o),t.overwatch=!1,i.push({attacker:t.id,defender:r.id,damage:o,cover:a,killed:r.hp===0}),r.hp===0){e.units=e.units.filter(e=>e!==r);break}}return i}function kN(e,t,n,r){let i=jN(e,t),a=jN(e,n);if(i.owner!==e.turn||i.owner===a.owner)throw Error(`invalid tactical attack`);if(FN(e,i,a)>3)throw Error(`tactical target is out of range`);let o=e.cells[a.y*e.width+a.x].cover??0,s=Math.max(0,r-o);a.hp=Math.max(0,a.hp-s);let c=a.hp===0;return c&&(e.units=e.units.filter(e=>e!==a)),{attacker:t,defender:n,damage:s,cover:o,killed:c}}function AN(e){let t=[...new Set(e.units.map(e=>e.owner))];if(t.length===0)return;let n=t.indexOf(e.turn)+1;n>=t.length&&e.round++,e.turn=t[n%t.length];for(let t of e.units)t.owner===e.turn&&(t.actions=2,t.overwatch=!1)}function jN(e,t){let n=e.units.find(e=>e.id===t);if(!n)throw Error(`unknown tactical unit "${t}"`);return n}function MN(e,t,n){return e.units.some(e=>e.x===t&&e.y===n)}function NN(e,t,n){return t>=0&&n>=0&&t<e.width&&n<e.height}function PN(e,t,n){return e.shape===`hex`?sD(t,n):[{x:t-1,y:n},{x:t+1,y:n},{x:t,y:n-1},{x:t,y:n+1}]}function FN(e,t,n){return e.shape===`hex`?cD(t,n):Math.abs(t.x-n.x)+Math.abs(t.y-n.y)}function IN(e,t){return new Set(e.units.filter(n=>n.owner!==t.owner&&PN(e,t.x,t.y).some(e=>e.x===n.x&&e.y===n.y)).map(e=>e.id))}function LN(e,t,n){let r=new Set;for(let i of e.units)if(!(i.owner===t.owner||n.has(i.id)))for(let t of PN(e,i.x,i.y))r.add(`${t.x},${t.y}`);return r}function RN(e,t,n,r,i,a){let o=[{x:t.x,y:t.y,distance:0}],s=0,c=new Set([`${t.x},${t.y}`]);for(;s<o.length;){let t=o[s++];if(t.x===n&&t.y===r)return t.distance;if(!(t.distance>=i||t.distance>0&&a.has(`${t.x},${t.y}`)))for(let i of PN(e,t.x,t.y)){let a=`${i.x},${i.y}`;!NN(e,i.x,i.y)||c.has(a)||!e.cells[i.y*e.width+i.x].passable||MN(e,i.x,i.y)&&(i.x!==n||i.y!==r)||(c.add(a),o.push({x:i.x,y:i.y,distance:t.distance+1}))}}return null}var zN=class{constructor(e,t){if(this.visible=new Map,this.explored=new Map,e<1||t<1)throw Error(`fog needs positive dimensions`);this.width=e,this.height=t}sync(e,t,n){if(!e)throw Error(`fog needs a faction id`);let r=new Set;for(let e of t)for(let t of n(e))this.inside(t.x,t.y)&&r.add(this.index(t.x,t.y));this.visible.set(e,r);let i=this.explored.get(e)??new Set;for(let e of r)i.add(e);this.explored.set(e,i)}isVisible(e,t,n){return this.visible.get(e)?.has(this.index(t,n))??!1}isExplored(e,t,n){return this.explored.get(e)?.has(this.index(t,n))??!1}visibleCells(e){return[...this.visible.get(e)??[]]}exploredCells(e){return[...this.explored.get(e)??[]]}inside(e,t){return e>=0&&t>=0&&e<this.width&&t<this.height}index(e,t){return this.inside(e,t)?t*this.width+e:-1}};function BN(e){return{currency:e,pool:[]}}function VN(e,t,n,r){return e.currency<r||!CN(t,n.x,n.y)?!1:(wN(t,n),e.currency-=r,!0)}function HN(e,t,n,r,i){let a=e.pool.findIndex(e=>e.id===n);return a===-1||!CN(t,r,i)?!1:(wN(t,{...e.pool[a],x:r,y:i}),e.pool.splice(a,1),!0)}function UN(e,t,n){let r=t.units.findIndex(e=>e.id===n);if(r===-1)return!1;let{x:i,y:a,...o}=t.units[r];return e.pool.push(o),t.units.splice(r,1),!0}function WN(e,t,n){return e.units.filter(e=>e.owner===t).length*(n.incomePerUnit-n.upkeepPerUnit)}function GN(e,t,n,r){return e.currency+=WN(t,n,r),e.currency}var KN=l({BoardGrid:()=>UM,DiceCup:()=>bN,FactionFog:()=>zN,addTacticalUnit:()=>wN,applyBackgammonMove:()=>oN,applyCheckersMove:()=>KM,applyMove:()=>PM,applyUpkeep:()=>GN,armyIncome:()=>WN,backgammonMoves:()=>aN,bankUnit:()=>UN,canPlaceTacticalUnit:()=>CN,checkersMoves:()=>GM,chooseMove:()=>LM,cloneChess:()=>SM,createDeck:()=>cN,deal:()=>uN,dealSolitaire:()=>fN,drawSolitaire:()=>pN,endTacticalTurn:()=>AN,gameResult:()=>FM,goResult:()=>ZM,goScore:()=>QM,inCheck:()=>kM,legalMoves:()=>NM,moveSolitaireTableau:()=>mN,moveSolitaireToFoundation:()=>hN,moveTacticalUnit:()=>EN,parseFen:()=>gM,passGo:()=>XM,playGo:()=>YM,recall:()=>HN,recruit:()=>VN,rollBackgammonDice:()=>iN,rollDice:()=>vN,rollExpression:()=>yN,scoreDice:()=>xN,search:()=>RM,setTacticalOverwatch:()=>DN,shuffleDeck:()=>lN,solitaireWon:()=>gN,sq:()=>mM,squareName:()=>hM,startingArmy:()=>BN,startingBackgammon:()=>rN,startingCheckers:()=>WM,startingChess:()=>xM,startingGo:()=>JM,startingTactics:()=>SN,tacticalAttack:()=>kN,tacticalMoves:()=>TN,trickWinner:()=>dN,triggerTacticalOverwatch:()=>ON});function qN(e){return new Audio(qD(e))}var JN=new vT,YN=class{constructor(e,t={}){this.next=0;let n=Math.max(1,t.poolSize??4),r=t.create??qN;this.volume=t.volume??1,this.caption=t.caption,this.pool=Array.from({length:n},()=>r(e))}play(){let e=this.pool[this.next];this.next=(this.next+1)%this.pool.length,e.volume=this.volume,e.currentTime=0,Promise.resolve(e.play()).catch(()=>{}),this.caption&&JN.dispatch({text:this.caption})}stopAll(){for(let e of this.pool)e.pause(),e.currentTime=0}},XN=class{constructor(e={}){this.current=null,this.fades=[],this.volume=e.volume??1,this.create=e.create??qN}play(e,t=1){let n=this.create(e);n.loop=!0;let r=this.current;if(this.current=n,t<=0){n.volume=this.volume,Promise.resolve(n.play()).catch(()=>{}),r?.pause();return}n.volume=0,Promise.resolve(n.play()).catch(()=>{}),this.fades.push({audio:n,elapsed:0,duration:t,from:0,to:this.volume,stopAtEnd:!1}),r&&this.fades.push({audio:r,elapsed:0,duration:t,from:r.volume,to:0,stopAtEnd:!0})}stop(e=1){let t=this.current;if(t){if(this.current=null,e<=0){t.pause();return}this.fades.push({audio:t,elapsed:0,duration:e,from:t.volume,to:0,stopAtEnd:!0})}}update(e){for(let t of[...this.fades]){t.elapsed+=e;let n=Math.min(1,t.elapsed/t.duration);t.audio.volume=t.from+(t.to-t.from)*n,n>=1&&(this.fades.splice(this.fades.indexOf(t),1),t.stopAtEnd&&(t.audio.pause(),t.audio.currentTime=0))}}},ZN=class{constructor(e){this.states=new Map,this.cues=new Map,this.currentTrack=null,this.music=e}define(e,t){this.states.set(e,t)}enter(e){let t=this.states.get(e);if(!t)throw Error(`Orchestrator: no state defined for "${e}"`);t.track!==this.currentTrack&&(this.music.play(t.track,t.fadeDuration),this.currentTrack=t.track)}on(e,t){this.cues.set(e,t)}trigger(e){this.cues.get(e)?.play()}};function QN(e={}){let t=e.waveform??`square`,n=e.frequency??440,r=e.duration??.15,i=e.volume??.3,a=e.decay??8,o=e.sampleRate??22050,s=e.seed??1;if(!(r>0))throw Error(`tone duration must be positive`);if(t!==`noise`&&!(n>0))throw Error(`tone frequency must be positive`);if(!(o>0))throw Error(`tone sample rate must be positive`);let c=Math.max(1,Math.round(r*o)),l=new Float32Array(c);for(let e=0;e<c;e++){let r=e/o,u=a>0?Math.exp(-a*e/c):1,d=2*Math.PI*n*r;l[e]=i*u*eP(t,d,s,e)}return nP(l,o)}function $N(e={},t=e=>new Audio(e)){let n=t(QN(e));return Promise.resolve(n.play()).catch(()=>{}),n}function eP(e,t,n,r){switch(e){case`sine`:return Math.sin(t);case`square`:return Math.sin(t)>=0?1:-1;case`triangle`:{let e=t/(2*Math.PI),n=e-Math.floor(e);return 4*Math.abs(n-.5)-1}case`noise`:return tP(n,r)}}function tP(e,t){let n=Math.imul(e^t,2654435761)>>>0;return n=Math.imul(n^n>>>15,2246822519)>>>0,n=Math.imul(n^n>>>13,3266489917)>>>0,n^=n>>>16,(n>>>0)/4294967295*2-1}function nP(e,t){let n=e.length*2,r=new ArrayBuffer(44+n),i=new DataView(r);rP(i,0,`RIFF`),i.setUint32(4,36+n,!0),rP(i,8,`WAVE`),rP(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),rP(i,36,`data`),i.setUint32(40,n,!0);let a=44;for(let t of e){let e=Math.max(-1,Math.min(1,t));i.setInt16(a,Math.round(e*(e<0?32768:32767)),!0),a+=2}let o=``,s=new Uint8Array(r);for(let e of s)o+=String.fromCharCode(e);return`data:audio/wav;base64,${btoa(o)}`}function rP(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}var iP=5e5;function aP(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0,i=e=>{let n=``;for(let i=0;i<e;i++)n+=String.fromCharCode(t[r+i]);return r+=e,n},a=()=>{let e=n.getUint32(r,!1);return r+=4,e},o=()=>{let e=n.getUint16(r,!1);return r+=2,e},s=()=>{let e=0;for(;;){let n=t[r++];if(e=e<<7|n&127,!(n&128))return e}};if(i(4)!==`MThd`||a()!==6)throw Error(`invalid MIDI header chunk`);let c=o(),l=o(),u=o();if(c!==0&&c!==1)throw Error(`unsupported MIDI format ${c}`);if(u&32768)throw Error(`SMPTE-based MIDI timing is not supported`);let d=u,f=[];for(let e=0;e<l;e++){let e=i(4),n=a();if(e!==`MTrk`){r+=n;continue}let o=r+n,c=0,l=0;for(;r<o;){c+=s();let e=t[r];if(e<128?e=l:(r++,e<240&&(l=e)),e===255){let e=t[r++],n=s();if(e===81&&n===3){let e=t[r]<<16|t[r+1]<<8|t[r+2];f.push({tick:c,type:`tempo`,microsecondsPerQuarter:e})}r+=n}else if(e===240||e===247)r+=s();else{let n=e&240,i=e&15;if(n===128||n===144){let e=t[r++],a=t[r++],o=n===144&&a>0;f.push({tick:c,type:o?`noteOn`:`noteOff`,note:e,velocity:a,channel:i})}else if(n===160||n===176||n===224)r+=2;else if(n===192||n===208)r+=1;else throw Error(`unsupported MIDI status byte 0x${e.toString(16)}`)}}}return f.sort((e,t)=>e.tick-t.tick),{ticksPerQuarter:d,events:f}}function oP(e){let t=[],n=new Map,r=iP,i=0,a=0;for(let o of e.events){if(a+=(o.tick-i)*r/e.ticksPerQuarter/1e6,i=o.tick,o.type===`tempo`){r=o.microsecondsPerQuarter;continue}let s=`${o.channel}:${o.note}`;if(o.type===`noteOn`)n.set(s,{time:a,velocity:o.velocity});else{let e=n.get(s);e&&(t.push({time:e.time,duration:Math.max(.01,a-e.time),note:o.note,velocity:e.velocity,channel:o.channel}),n.delete(s))}}for(let[e,r]of n){let[n,i]=e.split(`:`).map(Number);t.push({time:r.time,duration:.3,note:i,velocity:r.velocity,channel:n})}return t.sort((e,t)=>e.time-t.time)}function sP(e){return 440*2**((e-69)/12)}var cP=class{constructor(e,t={}){this.elapsed=0,this.index=0,this.playing=!1,this.notes=oP(e),this.playFn=t.play??$N,this.waveform=t.waveform??`square`,this.volume=t.volume??.2}play(){this.playing=this.index<this.notes.length}pause(){this.playing=!1}stop(){this.playing=!1,this.elapsed=0,this.index=0}update(e){if(this.playing){for(this.elapsed+=e;this.index<this.notes.length&&this.notes[this.index].time<=this.elapsed;){let e=this.notes[this.index];this.playFn({waveform:this.waveform,frequency:sP(e.note),duration:e.duration,volume:this.volume*(e.velocity/127)}),this.index++}this.index>=this.notes.length&&(this.playing=!1)}}get isPlaying(){return this.playing}get duration(){let e=this.notes.at(-1);return e?e.time+e.duration:0}},lP=l({MidiPlayer:()=>cP,Music:()=>XN,Orchestrator:()=>ZN,Sound:()=>YN,createAudio:()=>qN,noteToFrequency:()=>sP,onCaption:()=>JN,parseMidi:()=>aP,playTone:()=>$N,scheduleMidi:()=>oP,synthesizeTone:()=>QN});return e.Achievements=eD,e.ActorAnimator=yO,Object.defineProperty(e,"Actors",{enumerable:!0,get:function(){return lj}}),e.AnimatedSprite=RD,e.Animation=LD,Object.defineProperty(e,"Audio",{enumerable:!0,get:function(){return lP}}),e.BLOB_SHAPES=bO,e.Bar=YO,Object.defineProperty(e,"Battle",{enumerable:!0,get:function(){return pM}}),e.BitmapLabel=IO,Object.defineProperty(e,"Board",{enumerable:!0,get:function(){return KN}}),e.Button=JO,e.COLOR_BLINDNESS_MATRICES=oO,e.Camera=eO,e.Collection=YE,e.ColorTransformBatcher=ED,e.DialogueStage=nk,e.EMPTY=uO,e.Easing=mD,e.FeedbackClient=nD,e.FloatingText=ZO,e.Game=oE,e.Generator=pE,e.HelpScreen=$O,Object.defineProperty(e,"I18n",{enumerable:!0,get:function(){return fA}}),e.IconGrid=HO,Object.defineProperty(e,"Input",{enumerable:!0,get:function(){return yT}}),e.Label=FO,e.LayeredSprite=_O,e.ListView=VO,e.LoadQueue=_D,e.LoadingScreen=ek,e.Logger=lE,e.MessageBox=UO,e.Minimap=lO,e.NO_COLOR_ADD=FD,e.NewsClient=KE,e.NewsSeenTracker=JE,e.NinePatch=RO,e.Player=ZE,e.PlayerInput=AE,e.Projectile=vO,e.RENDERING_DECISIONS=EO,Object.defineProperty(e,"Random",{enumerable:!0,get:function(){return dE}}),e.RebindScreen=qO,e.Recorder=XE,Object.defineProperty(e,"Resources",{enumerable:!0,get:function(){return BD}}),Object.defineProperty(e,"Roguelike",{enumerable:!0,get:function(){return cA}}),Object.defineProperty(e,"Rpg",{enumerable:!0,get:function(){return eM}}),e.RunHistory=GE,e.SaveSyncClient=WE,e.SaveSystem=UE,e.Scene=sE,e.SceneStack=_T,e.Session=tD,e.Signal=vT,e.Spawner=rD,e.SpriteSheet=$D,e.StageScript=rk,e.TileMap=gO,e.TintedSprite=ID,e.Toast=QO,e.Tweener=hD,e.UndoHistory=gD,e.VerticalLabel=KO,e.Viewport=iO,e.Window=zO,e.WindowStack=BO,Object.defineProperty(e,"World",{enumerable:!0,get:function(){return hj}}),e.autotileFrames=TO,e.bitmapLabelStyle=LO,e.blobIndex=wO,e.checkNoControlCharacters=LE,e.checkSize=IE,e.createCamera=rO,e.createColorBlindnessFilter=sO,e.defaultTheme=kO,e.deserializeReplay=$E,e.detectWebGpu=OO,e.hexDistance=cD,e.hexLine=uD,e.hexNeighbors=sD,e.hexRange=dD,e.hexToPixel=fD,e.highContrastTheme=AO,e.importTwee=ak,e.inspectGraphicsCapabilities=DO,e.layoutVertical=GO,e.newlyRevealed=cO,e.packColorAdd=MD,e.packTintAdd=ND,e.pixelToHex=pD,e.registerColorTransform=jD,e.sanitizeInboundText=RE,e.scramble=jE,e.serializeReplay=QE,e.setTheme=PO,e.snapZoom=nO,e.splitScreenHalves=aO,e.theme=MO,e.themeChanged=NO,e.tileFrame=pO,e.tileFrameIndex=hO,e.tileFrameSheet=mO,e.unscramble=ME,e.validateSchema=BE,e.version=f,e})({});
@@ -1 +1 @@
1
- {"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../src/render/Camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC7B,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,MAAM;IAClB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,8CAAmB;IAEjC,yCAAyC;IACzC,CAAC,SAAK;IACN,CAAC,SAAK;IAEN,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAA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;KAAE,GAAG,IAAI,GAAG,IAAI,CAEzF;IAED,wEAAwE;IACxE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAMjC;IAED,kCAAkC;IAClC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,IAAI,CAG/C;IAED,oEAAoE;IACpE,MAAM,CAAC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,SAAS,SAAI,GAAG,IAAI,CAG5D;IAED,aAAa,IAAI,IAAI,CAGpB;IAED,2DAA2D;IAC3D,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,IAAI,CAG7C;IAED,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAgCvB;IAED,mCAAmC;IACnC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAUvD;IAED,oEAAoE;IACpE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAMtD;IAID,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,KAAK;CAQb;AAMD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CAMhE"}
@@ -89,8 +89,10 @@ export class Camera {
89
89
  }
90
90
  update(dt) {
91
91
  if (this.followTarget && this.followIntensity > 0) {
92
- const deadX = (this.view.width * this.deadzone) / 2;
93
- const deadY = (this.view.height * this.deadzone) / 2;
92
+ //half the view's world-unit size, not this.view itself: that getter also clamps to
93
+ //bounds, which the deadzone has no use for and would cost an extra allocation here
94
+ const deadX = (this.viewWidth / this._zoom * this.deadzone) / 2;
95
+ const deadY = (this.viewHeight / this._zoom * this.deadzone) / 2;
94
96
  let dx = this.followTarget.x - this.x;
95
97
  let dy = this.followTarget.y - this.y;
96
98
  //inside the deadzone the camera simply does not move
@@ -1 +1 @@
1
- {"version":3,"file":"Camera.js","sourceRoot":"","sources":["../../src/render/Camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAuC5C,MAAM,OAAO,MAAM;IAiClB,YAAY,OAAO,GAAkB,EAAE;QAhCvC,4CAA4C;QACnC,UAAK,GAAG,IAAI,SAAS,EAAE,CAAC;QAEjC,yCAAyC;QACzC,MAAC,GAAG,CAAC,CAAC;QACN,MAAC,GAAG,CAAC,CAAC;QAME,cAAS,GAAG,CAAC,CAAC;QACd,eAAU,GAAG,CAAC,CAAC;QACvB,qFAAqF;QACrF,uFAAuF;QAC/E,YAAO,GAAG,CAAC,CAAC;QACZ,YAAO,GAAG,CAAC,CAAC;QAEZ,iBAAY,GAAoC,IAAI,CAAC;QAC7D,kFAAkF;QAClF,kEAAkE;QAC1D,oBAAe,GAAG,CAAC,CAAC;QAEpB,mBAAc,GAAG,CAAC,CAAC;QACnB,mBAAc,GAAG,CAAC,CAAC;QACnB,kBAAa,GAAG,CAAC,CAAC;QAClB,WAAM,GAAG,CAAC,CAAC;QACX,WAAM,GAAG,CAAC,CAAC;QAEnB,yFAAyF;QACjF,WAAM,GAAsE,IAAI,CAAC;QAGxF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,oBAAoB,GAA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`package.json` automatically, chosen because this project's own build already
10
10
  * has no step before `tsc`/`vite` that this would need to run ahead of.
11
11
  */
12
- export declare const version = "0.2.0";
12
+ export declare const version = "0.2.1";
13
13
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -9,5 +9,5 @@
9
9
  * this from `package.json` automatically, chosen because this project's own build already
10
10
  * has no step before `tsc`/`vite` that this would need to run ahead of.
11
11
  */
12
- export const version = '0.2.0';
12
+ export const version = '0.2.1';
13
13
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datamoc/mw_games",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A local-file game framework for 2D top-down games, with optional 3D, mobile, and desktop packaging.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",