grid-engine
Version:
Phaser3 plugin for grid based movement on a 2D game board.
3 lines • 224 kB
JavaScript
var Lb=Object.create;var oa=Object.defineProperty,Sb=Object.defineProperties,Ob=Object.getOwnPropertyDescriptor,Eb=Object.getOwnPropertyDescriptors,Db=Object.getOwnPropertyNames,yc=Object.getOwnPropertySymbols,Mb=Object.getPrototypeOf,bc=Object.prototype.hasOwnProperty,Ib=Object.prototype.propertyIsEnumerable;var vc=(a,e,r)=>e in a?oa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,q=(a,e)=>{for(var r in e||(e={}))bc.call(e,r)&&vc(a,r,e[r]);if(yc)for(var r of yc(e))Ib.call(e,r)&&vc(a,r,e[r]);return a},_t=(a,e)=>Sb(a,Eb(e));var ge=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ab=(a,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Db(e))!bc.call(a,s)&&s!==r&&oa(a,s,{get:()=>e[s],enumerable:!(o=Ob(e,s))||o.enumerable});return a};var Fo=(a,e,r)=>(r=a!=null?Lb(Mb(a)):{},Ab(e||!a||!a.__esModule?oa(r,"default",{value:a,enumerable:!0}):r,a));var da=ge(Oi=>{var Zb=function(a,e){return a<e?-1:a>e?1:0},tT=function(a,e){return a<e?1:a>e?-1:0};function eT(a){return function(e,r){return a(r,e)}}function rT(a){return a===2?function(e,r){return e[0]<r[0]?-1:e[0]>r[0]?1:e[1]<r[1]?-1:e[1]>r[1]?1:0}:function(e,r){for(var o=0;o<a;){if(e[o]<r[o])return-1;if(e[o]>r[o])return 1;o++}return 0}}Oi.DEFAULT_COMPARATOR=Zb;Oi.DEFAULT_REVERSE_COMPARATOR=tT;Oi.reverseComparator=eT;Oi.createTupleComparator=rT});var Wc=ge(ga=>{ga.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer!="undefined";ga.SYMBOL_SUPPORT=typeof Symbol!="undefined"});var Ei=ge((kC,zc)=>{var $c=Wc(),iT=$c.ARRAY_BUFFER_SUPPORT,oT=$c.SYMBOL_SUPPORT;zc.exports=function(e,r){var o,s,u,h,f;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if(typeof r!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||iT&&ArrayBuffer.isView(e)||typeof e=="string"||e.toString()==="[object Arguments]"){for(u=0,h=e.length;u<h;u++)r(e[u],u);return}if(typeof e.forEach=="function"){e.forEach(r);return}if(oT&&Symbol.iterator in e&&typeof e.next!="function"&&(e=e[Symbol.iterator]()),typeof e.next=="function"){for(o=e,u=0;f=o.next(),f.done!==!0;)r(f.value,u),u++;return}for(s in e)e.hasOwnProperty(s)&&r(e[s],s)}});var th=ge((VC,Zc)=>{var qc=da(),Yc=Ei(),Xc=qc.DEFAULT_COMPARATOR,nT=qc.reverseComparator;function Dt(a){if(this.clear(),this.comparator=a||Xc,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.")}Dt.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function sT(a){return{item:a,degree:0}}function Qc(a,e){a.root?(e.right=a.root.right,e.left=a.root,a.root.right.left=e,a.root.right=e):a.root=e}Dt.prototype.push=function(a){var e=sT(a);return e.left=e,e.right=e,Qc(this,e),(!this.min||this.comparator(e.item,this.min.item)<=0)&&(this.min=e),++this.size};Dt.prototype.peek=function(){return this.min?this.min.item:void 0};function Kc(a){for(var e=[],r=a,o=!1;!(r===a&&o);)r===a&&(o=!0),e.push(r),r=r.right;return e}function Jc(a,e){a.root===e&&(a.root=e.right),e.left.right=e.right,e.right.left=e.left}function aT(a,e){a.child?(e.right=a.child.right,e.left=a.child,a.child.right.left=e,a.child.right=e):a.child=e}function uT(a,e,r){Jc(a,e),e.left=e,e.right=e,aT(r,e),r.degree++,e.parent=r}function lT(a){var e=new Array(a.size),r=Kc(a.root),o,s,u,h,f,d;for(o=0,s=r.length;o<s;o++){for(u=r[o],f=u.degree;e[f];)h=e[f],a.comparator(u.item,h.item)>0&&(d=u,u=h,h=d),uT(a,h,u),e[f]=null,f++;e[f]=u}for(o=0;o<a.size;o++)e[o]&&a.comparator(e[o].item,a.min.item)<=0&&(a.min=e[o])}Dt.prototype.pop=function(){if(this.size){var a=this.min;if(a.child){var e=Kc(a.child),r,o,s;for(o=0,s=e.length;o<s;o++)r=e[o],Qc(this,r),delete r.parent}return Jc(this,a),a===a.right?(this.min=null,this.root=null):(this.min=a.right,lT(this)),this.size--,a.item}};Dt.prototype.inspect=function(){var a={size:this.size};return this.min&&"item"in this.min&&(a.top=this.min.item),Object.defineProperty(a,"constructor",{value:Dt,enumerable:!1}),a};typeof Symbol!="undefined"&&(Dt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Dt.prototype.inspect);function mn(a){if(this.clear(),this.comparator=a||Xc,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.");this.comparator=nT(this.comparator)}mn.prototype=Dt.prototype;Dt.from=function(a,e){var r=new Dt(e);return Yc(a,function(o){r.push(o)}),r};mn.from=function(a,e){var r=new mn(e);return Yc(a,function(o){r.push(o)}),r};Dt.MinFibonacciHeap=Dt;Dt.MaxFibonacciHeap=mn;Zc.exports=Dt});var ya=ge(Pe=>{var cT=Math.pow(2,8)-1,hT=Math.pow(2,16)-1,fT=Math.pow(2,32)-1,pT=Math.pow(2,7)-1,mT=Math.pow(2,15)-1,dT=Math.pow(2,31)-1;Pe.getPointerArray=function(a){var e=a-1;if(e<=cT)return Uint8Array;if(e<=hT)return Uint16Array;if(e<=fT)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};Pe.getSignedPointerArray=function(a){var e=a-1;return e<=pT?Int8Array:e<=mT?Int16Array:e<=dT?Int32Array:Float64Array};Pe.getNumberType=function(a){return a===(a|0)?Math.sign(a)===-1?a<=127&&a>=-128?Int8Array:a<=32767&&a>=-32768?Int16Array:Int32Array:a<=255?Uint8Array:a<=65535?Uint16Array:Uint32Array:Float64Array};var gT={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};Pe.getMinimalRepresentation=function(a,e){var r=null,o=0,s,u,h,f,d;for(f=0,d=a.length;f<d;f++)h=e?e(a[f]):a[f],u=Pe.getNumberType(h),s=gT[u.name],s>o&&(o=s,r=u);return r};Pe.isTypedArray=function(a){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView(a)};Pe.concat=function(){var a=0,e,r,o;for(e=0,o=arguments.length;e<o;e++)a+=arguments[e].length;var s=new arguments[0].constructor(a);for(e=0,r=0;e<o;e++)s.set(arguments[e],r),r+=arguments[e].length;return s};Pe.indices=function(a){for(var e=Pe.getPointerArray(a),r=new e(a),o=0;o<a;o++)r[o]=o;return r}});var ba=ge(Di=>{var eh=Ei(),rh=ya();function yT(a){return Array.isArray(a)||rh.isTypedArray(a)}function va(a){if(typeof a.length=="number")return a.length;if(typeof a.size=="number")return a.size}function vT(a){var e=va(a),r=typeof e=="number"?new Array(e):[],o=0;return eh(a,function(s){r[o++]=s}),r}function bT(a){var e=va(a),r=typeof e=="number"?rh.getPointerArray(e):Array,o=typeof e=="number"?new Array(e):[],s=typeof e=="number"?new r(e):[],u=0;return eh(a,function(h){o[u]=h,s[u]=u++}),[o,s]}Di.isArrayLike=yT;Di.guessLength=va;Di.toArray=vT;Di.toArrayWithIndices=bT});var ah=ge((jC,sh)=>{var dn=Ei(),ih=da(),xe=ba(),yn=ih.DEFAULT_COMPARATOR,Ta=ih.reverseComparator;function Pa(a,e,r,o){for(var s=e[o],u,h;o>r;){if(u=o-1>>1,h=e[u],a(s,h)<0){e[o]=h,o=u;continue}break}e[o]=s}function Mi(a,e,r){for(var o=e.length,s=r,u=e[r],h=2*r+1,f;h<o;)f=h+1,f<o&&a(e[h],e[f])>=0&&(h=f),e[r]=e[h],r=h,h=2*r+1;e[r]=u,Pa(a,e,s,r)}function oh(a,e,r){e.push(r),Pa(a,e,0,e.length-1)}function xa(a,e){var r=e.pop();if(e.length!==0){var o=e[0];return e[0]=r,Mi(a,e,0),o}return r}function Wr(a,e,r){if(e.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var o=e[0];return e[0]=r,Mi(a,e,0),o}function nh(a,e,r){var o;return e.length!==0&&a(e[0],r)<0&&(o=e[0],e[0]=r,r=o,Mi(a,e,0)),r}function vr(a,e){for(var r=e.length,o=r>>1,s=o;--s>=0;)Mi(a,e,s)}function wa(a,e){for(var r=e.length,o=0,s=new Array(r);o<r;)s[o++]=xa(a,e);return s}function TT(a,e,r){arguments.length===2&&(r=e,e=a,a=yn);var o=Ta(a),s,u,h,f=1/0,d;if(e===1){if(xe.isArrayLike(r)){for(s=0,u=r.length;s<u;s++)h=r[s],(f===1/0||a(h,f)<0)&&(f=h);return d=new r.constructor(1),d[0]=f,d}return dn(r,function(_){(f===1/0||a(_,f)<0)&&(f=_)}),[f]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(a);for(d=r.slice(0,e),vr(o,d),s=e,u=r.length;s<u;s++)o(r[s],d[0])>0&&Wr(o,d,r[s]);return d.sort(a)}var P=xe.guessLength(r);return P!==null&&P<e&&(e=P),d=new Array(e),s=0,dn(r,function(_){s<e?d[s]=_:(s===e&&vr(o,d),o(_,d[0])>0&&Wr(o,d,_)),s++}),d.length>s&&(d.length=s),d.sort(a)}function PT(a,e,r){arguments.length===2&&(r=e,e=a,a=yn);var o=Ta(a),s,u,h,f=-1/0,d;if(e===1){if(xe.isArrayLike(r)){for(s=0,u=r.length;s<u;s++)h=r[s],(f===-1/0||a(h,f)>0)&&(f=h);return d=new r.constructor(1),d[0]=f,d}return dn(r,function(_){(f===-1/0||a(_,f)>0)&&(f=_)}),[f]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(o);for(d=r.slice(0,e),vr(a,d),s=e,u=r.length;s<u;s++)a(r[s],d[0])>0&&Wr(a,d,r[s]);return d.sort(o)}var P=xe.guessLength(r);return P!==null&&P<e&&(e=P),d=new Array(e),s=0,dn(r,function(_){s<e?d[s]=_:(s===e&&vr(a,d),a(_,d[0])>0&&Wr(a,d,_)),s++}),d.length>s&&(d.length=s),d.sort(o)}function et(a){if(this.clear(),this.comparator=a||yn,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}et.prototype.clear=function(){this.items=[],this.size=0};et.prototype.push=function(a){return oh(this.comparator,this.items,a),++this.size};et.prototype.peek=function(){return this.items[0]};et.prototype.pop=function(){return this.size!==0&&this.size--,xa(this.comparator,this.items)};et.prototype.replace=function(a){return Wr(this.comparator,this.items,a)};et.prototype.pushpop=function(a){return nh(this.comparator,this.items,a)};et.prototype.consume=function(){return this.size=0,wa(this.comparator,this.items)};et.prototype.toArray=function(){return wa(this.comparator,this.items.slice())};et.prototype.inspect=function(){var a=this.toArray();return Object.defineProperty(a,"constructor",{value:et,enumerable:!1}),a};typeof Symbol!="undefined"&&(et.prototype[Symbol.for("nodejs.util.inspect.custom")]=et.prototype.inspect);function gn(a){if(this.clear(),this.comparator=a||yn,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=Ta(this.comparator)}gn.prototype=et.prototype;et.from=function(a,e){var r=new et(e),o;return xe.isArrayLike(a)?o=a.slice():o=xe.toArray(a),vr(r.comparator,o),r.items=o,r.size=o.length,r};gn.from=function(a,e){var r=new gn(e),o;return xe.isArrayLike(a)?o=a.slice():o=xe.toArray(a),vr(r.comparator,o),r.items=o,r.size=o.length,r};et.siftUp=Mi;et.siftDown=Pa;et.push=oh;et.pop=xa;et.replace=Wr;et.pushpop=nh;et.heapify=vr;et.consume=wa;et.nsmallest=TT;et.nlargest=PT;et.MinHeap=et;et.MaxHeap=gn;sh.exports=et});var fh=ge((UC,hh)=>{var uh="";function lh(a,e,r){for(var o=e.length,s=[],u=o,h=-1,f,d=0,P;u--;)h=Math.max(a[e[u]+r],h);for(P=h>>24&&32||h>>16&&24||h>>8&&16||8;d<P;d+=4){for(u=16;u--;)s[u]=[];for(u=o;u--;)s[a[e[u]+r]>>d&15].push(e[u]);for(f=0;f<16;f++)for(h=s[f].length;h--;)e[++u]=s[f][h]}}function xT(a,e,r,o){return a[r]-a[o]||(r%3===2?a[r+1]-a[o+1]||e[r+2]-e[o+2]:e[r+1]-e[o+1])}function Ca(a,e){var r=[],o=[],s=2*e/3|0,u=e-s,h=s+1>>1,f=s,d=0,P,_=[],E=[];if(e===1)return[0];for(;f--;)r[f]=(f*3>>1)+1;for(f=3;f--;)lh(a,r,f);for(d=o[(r[0]/3|0)+(r[0]%3===1?0:h)]=1,f=1;f<s;f++)(a[r[f]]!==a[r[f-1]]||a[r[f]+1]!==a[r[f-1]+1]||a[r[f]+2]!==a[r[f-1]+2])&&d++,o[(r[f]/3|0)+(r[f]%3===1?0:h)]=d;if(d<s)for(o=Ca(o,s),f=s;f--;)r[f]=o[f]<h?o[f]*3+1:(o[f]-h)*3+2;for(f=s;f--;)_[r[f]]=f;for(_[e]=-1,_[e+1]=-2,o=e%3===1?[e-1]:[],f=0;f<s;f++)r[f]%3===1&&o.push(r[f]-1);for(lh(a,o,0),f=0,d=0,P=0;f<s&&d<u;)E[P++]=xT(a,_,r[f],o[d])<0?r[f++]:o[d++];for(;f<s;)E[P++]=r[f++];for(;d<u;)E[P++]=o[d++];return E}function ch(a){var e=a.length,r=e%3,o=new Array(e+r),s,u;if(typeof a!="string"){var h=Object.create(null);for(u=0;u<e;u++)h[a[u]]||(h[a[u]]=!0);var f=Object.create(null),d=Object.keys(h).sort();for(u=0,s=d.length;u<s;u++)f[d[u]]=u+1;for(u=0;u<e;u++)o[u]=f[a[u]]}else for(u=0;u<e;u++)o[u]=a.charCodeAt(u);for(u=e;u<e+r;u++)o[u]=0;return o}function Je(a){this.hasArbitrarySequence=typeof a!="string",this.string=a,this.length=a.length,this.array=Ca(ch(a),this.length)}Je.prototype.toString=function(){return this.array.join(",")};Je.prototype.toJSON=function(){return this.array};Je.prototype.inspect=function(){for(var a=new Array(this.length),e=0;e<this.length;e++)a[e]=this.string.slice(this.array[e]);return Object.defineProperty(a,"constructor",{value:Je,enumerable:!1}),a};typeof Symbol!="undefined"&&(Je.prototype[Symbol.for("nodejs.util.inspect.custom")]=Je.prototype.inspect);function Ze(a){if(this.hasArbitrarySequence=typeof a[0]!="string",this.size=a.length,this.hasArbitrarySequence){this.text=[];for(var e=0,r=this.size;e<r;e++)this.text.push.apply(this.text,a[e]),e<r-1&&this.text.push(uh)}else this.text=a.join(uh);this.firstLength=a[0].length,this.length=this.text.length,this.array=Ca(ch(this.text),this.length)}Ze.prototype.longestCommonSubsequence=function(){var a=this.hasArbitrarySequence?[]:"",e,r,o,s,u;for(r=1;r<this.length;r++)if(s=this.array[r],u=this.array[r-1],!(s<this.firstLength&&u<this.firstLength)&&!(s>this.firstLength&&u>this.firstLength)){for(e=Math.min(this.length-s,this.length-u),o=0;o<e;o++)if(this.text[s+o]!==this.text[u+o]){e=o;break}e>a.length&&(a=this.text.slice(s,s+e))}return a};Ze.prototype.toString=function(){return this.array.join(",")};Ze.prototype.toJSON=function(){return this.array};Ze.prototype.inspect=function(){for(var a=new Array(this.length),e=0;e<this.length;e++)a[e]=this.text.slice(this.array[e]);return Object.defineProperty(a,"constructor",{value:Ze,enumerable:!1}),a};typeof Symbol!="undefined"&&(Ze.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ze.prototype.inspect);Je.GeneralizedSuffixArray=Ze;hh.exports=Je});var mh=ge((BC,ph)=>{function we(a){if(typeof a!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=a}typeof Symbol!="undefined"&&(we.prototype[Symbol.iterator]=function(){return this});we.of=function(){var a=arguments,e=a.length,r=0;return new we(function(){return r>=e?{done:!0}:{done:!1,value:a[r++]}})};we.empty=function(){var a=new we(function(){return{done:!0}});return a};we.fromSequence=function(a){var e=0,r=a.length;return new we(function(){return e>=r?{done:!0}:{done:!1,value:a[e++]}})};we.is=function(a){return a instanceof we?!0:typeof a=="object"&&a!==null&&typeof a.next=="function"};ph.exports=we});var vh=ge((HC,yh)=>{var dh=mh(),wT=Ei(),CT=ba(),gh=ya(),_T=function(a){return Math.max(1,Math.ceil(a*1.5))},LT=function(a){var e=gh.getPointerArray(a);return new e(a)};function Y(a,e){if(arguments.length<1)throw new Error("mnemonist/vector: expecting at least a byte array constructor.");var r=e||0,o=_T,s=0,u=!1;typeof e=="object"&&(r=e.initialCapacity||0,s=e.initialLength||0,o=e.policy||o,u=e.factory===!0),this.factory=u?a:null,this.ArrayClass=a,this.length=s,this.capacity=Math.max(s,r),this.policy=o,this.array=new a(this.capacity)}Y.prototype.set=function(a,e){if(this.length<a)throw new Error("Vector("+this.ArrayClass.name+").set: index out of bounds.");return this.array[a]=e,this};Y.prototype.get=function(a){if(!(this.length<a))return this.array[a]};Y.prototype.applyPolicy=function(a){var e=this.policy(a||this.capacity);if(typeof e!="number"||e<0)throw new Error("mnemonist/vector.applyPolicy: policy returned an invalid value (expecting a positive integer).");if(e<=this.capacity)throw new Error("mnemonist/vector.applyPolicy: policy returned a less or equal capacity to allocate.");return e};Y.prototype.reallocate=function(a){if(a===this.capacity)return this;var e=this.array;if(a<this.length&&(this.length=a),a>this.capacity)if(this.factory===null?this.array=new this.ArrayClass(a):this.array=this.factory(a),gh.isTypedArray(this.array))this.array.set(e,0);else for(var r=0,o=this.length;r<o;r++)this.array[r]=e[r];else this.array=e.slice(0,a);return this.capacity=a,this};Y.prototype.grow=function(a){var e;if(typeof a=="number"){if(this.capacity>=a)return this;for(e=this.capacity;e<a;)e=this.applyPolicy(e);return this.reallocate(e),this}return e=this.applyPolicy(),this.reallocate(e),this};Y.prototype.resize=function(a){return a===this.length?this:a<this.length?(this.length=a,this):(this.length=a,this.reallocate(a),this)};Y.prototype.push=function(a){return this.capacity===this.length&&this.grow(),this.array[this.length++]=a,this.length};Y.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]};Y.prototype.values=function(){var a=this.array,e=this.length,r=0;return new dh(function(){if(r>=e)return{done:!0};var o=a[r];return r++,{value:o,done:!1}})};Y.prototype.entries=function(){var a=this.array,e=this.length,r=0;return new dh(function(){if(r>=e)return{done:!0};var o=a[r];return{value:[r++,o],done:!1}})};typeof Symbol!="undefined"&&(Y.prototype[Symbol.iterator]=Y.prototype.values);Y.prototype.inspect=function(){var a=this.array.slice(0,this.length);return a.type=this.array.constructor.name,a.items=this.length,a.capacity=this.capacity,Object.defineProperty(a,"constructor",{value:Y,enumerable:!1}),a};typeof Symbol!="undefined"&&(Y.prototype[Symbol.for("nodejs.util.inspect.custom")]=Y.prototype.inspect);Y.from=function(a,e,r){if(arguments.length<3&&(r=CT.guessLength(a),typeof r!="number"))throw new Error("mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.");var o=new Y(e,r);return wT(a,function(s){o.push(s)}),o};function Ce(a){var e=function(o){Y.call(this,a,o)};for(var r in Y.prototype)Y.prototype.hasOwnProperty(r)&&(e.prototype[r]=Y.prototype[r]);return e.from=function(o,s){return Y.from(o,a,s)},typeof Symbol!="undefined"&&(e.prototype[Symbol.iterator]=e.prototype.values),e}Y.Int8Vector=Ce(Int8Array);Y.Uint8Vector=Ce(Uint8Array);Y.Uint8ClampedVector=Ce(Uint8ClampedArray);Y.Int16Vector=Ce(Int16Array);Y.Uint16Vector=Ce(Uint16Array);Y.Int32Vector=Ce(Int32Array);Y.Uint32Vector=Ce(Uint32Array);Y.Float32Vector=Ce(Float32Array);Y.Float64Vector=Ce(Float64Array);Y.PointerVector=Ce(LT);yh.exports=Y});var T=class a{static get ZERO(){return new a(0,0)}static get ONE(){return new a(1,1)}static get UP(){return new a(0,-1)}static get DOWN(){return new a(0,1)}static get LEFT(){return new a(-1,0)}static get RIGHT(){return new a(1,0)}static get UP_LEFT(){return new a(-1,-1)}static get UP_RIGHT(){return new a(1,-1)}static get DOWN_RIGHT(){return new a(1,1)}static get DOWN_LEFT(){return new a(-1,1)}constructor(e,r){typeof e=="number"?(this.x=e,this.y=r||0):(this.x=e.x,this.y=e.y)}clone(){return new a(this.x,this.y)}add(e){return new a(this.x+e.x,this.y+e.y)}multiply(e){return new a(this.x*e.x,this.y*e.y)}divide(e){return new a(this.x/e.x,this.y/e.y)}subtract(e){return new a(this.x-e.x,this.y-e.y)}equals(e){return this.x===e.x&&this.y===e.y}abs(){return new a(Math.abs(this.x),Math.abs(this.y))}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}modulo(e){return new a(this.x%e.x,this.y%e.y)}scalarModulo(e){return new a(this.x%e,this.y%e)}scalarMult(e){return new a(this.x*e,this.y*e)}toPosition(){return{x:this.x,y:this.y}}toString(){return`${this.x}#${this.y}`}};var A=class{static equal(e,r){return e.position.x===r.position.x&&e.position.y===r.position.y&&e.layer===r.layer}static copyOver(e,r){r.position.x=e.position.x,r.position.y=e.position.y,r.layer=e.layer}static clone(e){return{position:e.position.clone(),layer:e.layer}}static toString(e){return`${e.position.toString()}#${e.layer}`}static toInternal(e){return{position:new T(e.position.x,e.position.y),layer:e.charLayer}}static fromInternal(e){return{position:e.position.toPosition(),charLayer:e.layer}}};var Ft=(P=>(P.NONE="none",P.LEFT="left",P.UP_LEFT="up-left",P.UP="up",P.UP_RIGHT="up-right",P.RIGHT="right",P.DOWN_RIGHT="down-right",P.DOWN="down",P.DOWN_LEFT="down-left",P))(Ft||{}),Rb={up:"down",down:"up",left:"right",right:"left",none:"none","up-left":"down-right","up-right":"down-left","down-right":"up-left","down-left":"up-right"},Fb={up:T.UP,down:T.DOWN,left:T.LEFT,right:T.RIGHT,none:T.ZERO,"up-left":T.UP_LEFT,"up-right":T.UP_RIGHT,"down-right":T.DOWN_RIGHT,"down-left":T.DOWN_LEFT},bi={up:0,"up-right":1,right:2,"down-right":3,down:4,"down-left":5,left:6,"up-left":7,none:NaN},Tc=["up","up-right","right","down-right","down","down-left","left","up-left"],kb=["down-left","down-right","up-right","up-left"];function Ti(){return["up","down","left","right","none","up-left","up-right","down-right","down-left"]}function fr(a){return kb.includes(a)}function Pc(a,e=1){return a==="none"?"none":Tc[(bi[a]+8-Math.abs(e)%8)%8]}function ko(a,e=1){return a==="none"?"none":Tc[(bi[a]+e)%8]}function Ht(a){return Fb[a]}function Pi(a){return Rb[a]}function Tt(a,e){if(a.x===e.x){if(a.y>e.y)return"up";if(a.y<e.y)return"down"}else if(a.y===e.y){if(a.x>e.x)return"left";if(a.x<e.x)return"right"}else if(a.x>e.x){if(a.y<e.y)return"down-left";if(a.y>e.y)return"up-left"}else if(a.x<e.x){if(a.y<e.y)return"down-right";if(a.y>e.y)return"up-right"}return"none"}var Nr=(r=>(r[r.FOUR=4]="FOUR",r[r.EIGHT=8]="EIGHT",r))(Nr||{});function Qe(a){return typeof a=="string"&&Ti().includes(a)}var na=function(a,e){return na=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])},na(a,e)};function Ke(a,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");na(a,e);function r(){this.constructor=a}a.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function xc(a,e,r,o){function s(u){return u instanceof r?u:new r(function(h){h(u)})}return new(r||(r=Promise))(function(u,h){function f(_){try{P(o.next(_))}catch(E){h(E)}}function d(_){try{P(o.throw(_))}catch(E){h(E)}}function P(_){_.done?u(_.value):s(_.value).then(f,d)}P((o=o.apply(a,e||[])).next())})}function Vo(a,e){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},o,s,u,h=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return h.next=f(0),h.throw=f(1),h.return=f(2),typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function f(P){return function(_){return d([P,_])}}function d(P){if(o)throw new TypeError("Generator is already executing.");for(;h&&(h=0,P[0]&&(r=0)),r;)try{if(o=1,s&&(u=P[0]&2?s.return:P[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,P[1])).done)return u;switch(s=0,u&&(P=[P[0]&2,u.value]),P[0]){case 0:case 1:u=P;break;case 4:return r.label++,{value:P[1],done:!1};case 5:r.label++,s=P[1],P=[0];continue;case 7:P=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(P[0]===6||P[0]===2)){r=0;continue}if(P[0]===3&&(!u||P[1]>u[0]&&P[1]<u[3])){r.label=P[1];break}if(P[0]===6&&r.label<u[1]){r.label=u[1],u=P;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(P);break}u[2]&&r.ops.pop(),r.trys.pop();continue}P=e.call(a,r)}catch(_){P=[6,_],s=0}finally{o=u=0}if(P[0]&5)throw P[1];return{value:P[0]?P[1]:void 0,done:!0}}}function ke(a){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&a[e],o=0;if(r)return r.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&o>=a.length&&(a=void 0),{value:a&&a[o++],done:!a}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(a,e){var r=typeof Symbol=="function"&&a[Symbol.iterator];if(!r)return a;var o=r.call(a),s,u=[],h;try{for(;(e===void 0||e-- >0)&&!(s=o.next()).done;)u.push(s.value)}catch(f){h={error:f}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(h)throw h.error}}return u}function ve(a,e,r){if(r||arguments.length===2)for(var o=0,s=e.length,u;o<s;o++)(u||!(o in e))&&(u||(u=Array.prototype.slice.call(e,0,o)),u[o]=e[o]);return a.concat(u||Array.prototype.slice.call(e))}function pr(a){return this instanceof pr?(this.v=a,this):new pr(a)}function wc(a,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=r.apply(a,e||[]),s,u=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",h),s[Symbol.asyncIterator]=function(){return this},s;function h(I){return function(H){return Promise.resolve(H).then(I,E)}}function f(I,H){o[I]&&(s[I]=function(B){return new Promise(function(st,ft){u.push([I,B,st,ft])>1||d(I,B)})},H&&(s[I]=H(s[I])))}function d(I,H){try{P(o[I](H))}catch(B){X(u[0][3],B)}}function P(I){I.value instanceof pr?Promise.resolve(I.value.v).then(_,E):X(u[0][2],I)}function _(I){d("next",I)}function E(I){d("throw",I)}function X(I,H){I(H),u.shift(),u.length&&d(u[0][0],u[0][1])}}function Cc(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=a[Symbol.asyncIterator],r;return e?e.call(a):(a=typeof ke=="function"?ke(a):a[Symbol.iterator](),r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r);function o(u){r[u]=a[u]&&function(h){return new Promise(function(f,d){h=a[u](h),s(f,d,h.done,h.value)})}}function s(u,h,f,d){Promise.resolve(d).then(function(P){u({value:P,done:f})},h)}}function Q(a){return typeof a=="function"}function No(a){var e=function(o){Error.call(o),o.stack=new Error().stack},r=a(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Go=No(function(a){return function(r){a(this),this.message=r?r.length+` errors occurred during unsubscription:
`+r.map(function(o,s){return s+1+") "+o.toString()}).join(`
`):"",this.name="UnsubscriptionError",this.errors=r}});function xi(a,e){if(a){var r=a.indexOf(e);0<=r&&a.splice(r,1)}}var Gr=(function(){function a(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return a.prototype.unsubscribe=function(){var e,r,o,s,u;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var f=ke(h),d=f.next();!d.done;d=f.next()){var P=d.value;P.remove(this)}}catch(B){e={error:B}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}else h.remove(this);var _=this.initialTeardown;if(Q(_))try{_()}catch(B){u=B instanceof Go?B.errors:[B]}var E=this._finalizers;if(E){this._finalizers=null;try{for(var X=ke(E),I=X.next();!I.done;I=X.next()){var H=I.value;try{_c(H)}catch(B){u=u!=null?u:[],B instanceof Go?u=ve(ve([],ye(u)),ye(B.errors)):u.push(B)}}}catch(B){o={error:B}}finally{try{I&&!I.done&&(s=X.return)&&s.call(X)}finally{if(o)throw o.error}}}if(u)throw new Go(u)}},a.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)_c(e);else{if(e instanceof a){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},a.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},a.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},a.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&xi(r,e)},a.prototype.remove=function(e){var r=this._finalizers;r&&xi(r,e),e instanceof a&&e._removeParent(this)},a.EMPTY=(function(){var e=new a;return e.closed=!0,e})(),a})();var sa=Gr.EMPTY;function jo(a){return a instanceof Gr||a&&"closed"in a&&Q(a.remove)&&Q(a.add)&&Q(a.unsubscribe)}function _c(a){Q(a)?a():a.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var jr={setTimeout:function(a,e){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];var s=jr.delegate;return s!=null&&s.setTimeout?s.setTimeout.apply(s,ve([a,e],ye(r))):setTimeout.apply(void 0,ve([a,e],ye(r)))},clearTimeout:function(a){var e=jr.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(a)},delegate:void 0};function Uo(a){jr.setTimeout(function(){var e=ae.onUnhandledError;if(e)e(a);else throw a})}function wi(){}var Lc=(function(){return aa("C",void 0,void 0)})();function Sc(a){return aa("E",void 0,a)}function Oc(a){return aa("N",a,void 0)}function aa(a,e,r){return{kind:a,value:e,error:r}}var mr=null;function Ur(a){if(ae.useDeprecatedSynchronousErrorHandling){var e=!mr;if(e&&(mr={errorThrown:!1,error:null}),a(),e){var r=mr,o=r.errorThrown,s=r.error;if(mr=null,o)throw s}}else a()}function Ec(a){ae.useDeprecatedSynchronousErrorHandling&&mr&&(mr.errorThrown=!0,mr.error=a)}var Ci=(function(a){Ke(e,a);function e(r){var o=a.call(this)||this;return o.isStopped=!1,r?(o.destination=r,jo(r)&&r.add(o)):o.destination=jb,o}return e.create=function(r,o,s){return new Ho(r,o,s)},e.prototype.next=function(r){this.isStopped?la(Oc(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?la(Sc(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?la(Lc,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,a.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(Gr);var Vb=Function.prototype.bind;function ua(a,e){return Vb.call(a,e)}var Nb=(function(){function a(e){this.partialObserver=e}return a.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(o){Bo(o)}},a.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(o){Bo(o)}else Bo(e)},a.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Bo(r)}},a})(),Ho=(function(a){Ke(e,a);function e(r,o,s){var u=a.call(this)||this,h;if(Q(r)||!r)h={next:r!=null?r:void 0,error:o!=null?o:void 0,complete:s!=null?s:void 0};else{var f;u&&ae.useDeprecatedNextContext?(f=Object.create(r),f.unsubscribe=function(){return u.unsubscribe()},h={next:r.next&&ua(r.next,f),error:r.error&&ua(r.error,f),complete:r.complete&&ua(r.complete,f)}):h=r}return u.destination=new Nb(h),u}return e})(Ci);function Bo(a){ae.useDeprecatedSynchronousErrorHandling?Ec(a):Uo(a)}function Gb(a){throw a}function la(a,e){var r=ae.onStoppedNotification;r&&jr.setTimeout(function(){return r(a,e)})}var jb={closed:!0,next:wi,error:Gb,complete:wi};var Br=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Wo(a){return a}function ca(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];return ha(a)}function ha(a){return a.length===0?Wo:a.length===1?a[0]:function(r){return a.reduce(function(o,s){return s(o)},r)}}var vt=(function(){function a(e){e&&(this._subscribe=e)}return a.prototype.lift=function(e){var r=new a;return r.source=this,r.operator=e,r},a.prototype.subscribe=function(e,r,o){var s=this,u=Bb(e)?e:new Ho(e,r,o);return Ur(function(){var h=s,f=h.operator,d=h.source;u.add(f?f.call(u,d):d?s._subscribe(u):s._trySubscribe(u))}),u},a.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},a.prototype.forEach=function(e,r){var o=this;return r=Dc(r),new r(function(s,u){var h=new Ho({next:function(f){try{e(f)}catch(d){u(d),h.unsubscribe()}},error:u,complete:s});o.subscribe(h)})},a.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},a.prototype[Br]=function(){return this},a.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return ha(e)(this)},a.prototype.toPromise=function(e){var r=this;return e=Dc(e),new e(function(o,s){var u;r.subscribe(function(h){return u=h},function(h){return s(h)},function(){return o(u)})})},a.create=function(e){return new a(e)},a})();function Dc(a){var e;return(e=a!=null?a:ae.Promise)!==null&&e!==void 0?e:Promise}function Ub(a){return a&&Q(a.next)&&Q(a.error)&&Q(a.complete)}function Bb(a){return a&&a instanceof Ci||Ub(a)&&jo(a)}function Hb(a){return Q(a==null?void 0:a.lift)}function Lt(a){return function(e){if(Hb(e))return e.lift(function(r){try{return a(r,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wt(a,e,r,o,s){return new Wb(a,e,r,o,s)}var Wb=(function(a){Ke(e,a);function e(r,o,s,u,h,f){var d=a.call(this,r)||this;return d.onFinalize=h,d.shouldUnsubscribe=f,d._next=o?function(P){try{o(P)}catch(_){r.error(_)}}:a.prototype._next,d._error=u?function(P){try{u(P)}catch(_){r.error(_)}finally{this.unsubscribe()}}:a.prototype._error,d._complete=s?function(){try{s()}catch(P){r.error(P)}finally{this.unsubscribe()}}:a.prototype._complete,d}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;a.prototype.unsubscribe.call(this),!o&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e})(Ci);var Mc=No(function(a){return function(){a(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var J=(function(a){Ke(e,a);function e(){var r=a.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var o=new Ic(this,this);return o.operator=r,o},e.prototype._throwIfClosed=function(){if(this.closed)throw new Mc},e.prototype.next=function(r){var o=this;Ur(function(){var s,u;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var h=ke(o.currentObservers),f=h.next();!f.done;f=h.next()){var d=f.value;d.next(r)}}catch(P){s={error:P}}finally{try{f&&!f.done&&(u=h.return)&&u.call(h)}finally{if(s)throw s.error}}}})},e.prototype.error=function(r){var o=this;Ur(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=r;for(var s=o.observers;s.length;)s.shift().error(r)}})},e.prototype.complete=function(){var r=this;Ur(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var o=r.observers;o.length;)o.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),a.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var o=this,s=this,u=s.hasError,h=s.isStopped,f=s.observers;return u||h?sa:(this.currentObservers=null,f.push(r),new Gr(function(){o.currentObservers=null,xi(f,r)}))},e.prototype._checkFinalizedStatuses=function(r){var o=this,s=o.hasError,u=o.thrownError,h=o.isStopped;s?r.error(u):h&&r.complete()},e.prototype.asObservable=function(){var r=new vt;return r.source=this,r},e.create=function(r,o){return new Ic(r,o)},e})(vt);var Ic=(function(a){Ke(e,a);function e(r,o){var s=a.call(this)||this;return s.destination=r,s.source=o,s}return e.prototype.next=function(r){var o,s;(s=(o=this.destination)===null||o===void 0?void 0:o.next)===null||s===void 0||s.call(o,r)},e.prototype.error=function(r){var o,s;(s=(o=this.destination)===null||o===void 0?void 0:o.error)===null||s===void 0||s.call(o,r)},e.prototype.complete=function(){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||o===void 0||o.call(r)},e.prototype._subscribe=function(r){var o,s;return(s=(o=this.source)===null||o===void 0?void 0:o.subscribe(r))!==null&&s!==void 0?s:sa},e})(J);var $o=new vt(function(a){return a.complete()});function Ac(a){return a&&Q(a.schedule)}function Rc(a){return a[a.length-1]}function zo(a){return Ac(Rc(a))?a.pop():void 0}function qo(a,e){return typeof Rc(a)=="number"?a.pop():e}var Yo=(function(a){return a&&typeof a.length=="number"&&typeof a!="function"});function Xo(a){return Q(a==null?void 0:a.then)}function Qo(a){return Q(a[Br])}function Ko(a){return Symbol.asyncIterator&&Q(a==null?void 0:a[Symbol.asyncIterator])}function Jo(a){return new TypeError("You provided "+(a!==null&&typeof a=="object"?"an invalid object":"'"+a+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function $b(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Zo=$b();function tn(a){return Q(a==null?void 0:a[Zo])}function en(a){return wc(this,arguments,function(){var r,o,s,u;return Vo(this,function(h){switch(h.label){case 0:r=a.getReader(),h.label=1;case 1:h.trys.push([1,,9,10]),h.label=2;case 2:return[4,pr(r.read())];case 3:return o=h.sent(),s=o.value,u=o.done,u?[4,pr(void 0)]:[3,5];case 4:return[2,h.sent()];case 5:return[4,pr(s)];case 6:return[4,h.sent()];case 7:return h.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function rn(a){return Q(a==null?void 0:a.getReader)}function kt(a){if(a instanceof vt)return a;if(a!=null){if(Qo(a))return zb(a);if(Yo(a))return qb(a);if(Xo(a))return Yb(a);if(Ko(a))return Fc(a);if(tn(a))return Xb(a);if(rn(a))return Qb(a)}throw Jo(a)}function zb(a){return new vt(function(e){var r=a[Br]();if(Q(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function qb(a){return new vt(function(e){for(var r=0;r<a.length&&!e.closed;r++)e.next(a[r]);e.complete()})}function Yb(a){return new vt(function(e){a.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,Uo)})}function Xb(a){return new vt(function(e){var r,o;try{for(var s=ke(a),u=s.next();!u.done;u=s.next()){var h=u.value;if(e.next(h),e.closed)return}}catch(f){r={error:f}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}e.complete()})}function Fc(a){return new vt(function(e){Kb(a,e).catch(function(r){return e.error(r)})})}function Qb(a){return Fc(en(a))}function Kb(a,e){var r,o,s,u;return xc(this,void 0,void 0,function(){var h,f;return Vo(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),r=Cc(a),d.label=1;case 1:return[4,r.next()];case 2:if(o=d.sent(),!!o.done)return[3,4];if(h=o.value,e.next(h),e.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=d.sent(),s={error:f},[3,11];case 6:return d.trys.push([6,,9,10]),o&&!o.done&&(u=r.return)?[4,u.call(r)]:[3,8];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Zt(a,e,r,o,s){o===void 0&&(o=0),s===void 0&&(s=!1);var u=e.schedule(function(){r(),s?a.add(this.schedule(null,o)):this.unsubscribe()},o);if(a.add(u),!s)return u}function on(a,e){return e===void 0&&(e=0),Lt(function(r,o){r.subscribe(Wt(o,function(s){return Zt(o,a,function(){return o.next(s)},e)},function(){return Zt(o,a,function(){return o.complete()},e)},function(s){return Zt(o,a,function(){return o.error(s)},e)}))})}function nn(a,e){return e===void 0&&(e=0),Lt(function(r,o){o.add(a.schedule(function(){return r.subscribe(o)},e))})}function kc(a,e){return kt(a).pipe(nn(e),on(e))}function Vc(a,e){return kt(a).pipe(nn(e),on(e))}function Nc(a,e){return new vt(function(r){var o=0;return e.schedule(function(){o===a.length?r.complete():(r.next(a[o++]),r.closed||this.schedule())})})}function Gc(a,e){return new vt(function(r){var o;return Zt(r,e,function(){o=a[Zo](),Zt(r,e,function(){var s,u,h;try{s=o.next(),u=s.value,h=s.done}catch(f){r.error(f);return}h?r.complete():r.next(u)},0,!0)}),function(){return Q(o==null?void 0:o.return)&&o.return()}})}function sn(a,e){if(!a)throw new Error("Iterable cannot be null");return new vt(function(r){Zt(r,e,function(){var o=a[Symbol.asyncIterator]();Zt(r,e,function(){o.next().then(function(s){s.done?r.complete():r.next(s.value)})},0,!0)})})}function jc(a,e){return sn(en(a),e)}function Uc(a,e){if(a!=null){if(Qo(a))return kc(a,e);if(Yo(a))return Nc(a,e);if(Xo(a))return Vc(a,e);if(Ko(a))return sn(a,e);if(tn(a))return Gc(a,e);if(rn(a))return jc(a,e)}throw Jo(a)}function an(a,e){return e?Uc(a,e):kt(a)}function be(a,e){return Lt(function(r,o){var s=0;r.subscribe(Wt(o,function(u){o.next(a.call(e,u,s++))}))})}function Bc(a,e,r,o,s,u,h,f){var d=[],P=0,_=0,E=!1,X=function(){E&&!d.length&&!P&&e.complete()},I=function(B){return P<o?H(B):d.push(B)},H=function(B){u&&e.next(B),P++;var st=!1;kt(r(B,_++)).subscribe(Wt(e,function(ft){s==null||s(ft),u?I(ft):e.next(ft)},function(){st=!0},void 0,function(){if(st)try{P--;for(var ft=function(){var er=d.shift();h?Zt(e,h,function(){return H(er)}):H(er)};d.length&&P<o;)ft();X()}catch(er){e.error(er)}}))};return a.subscribe(Wt(e,I,function(){E=!0,X()})),function(){f==null||f()}}function fa(a,e,r){return r===void 0&&(r=1/0),Q(e)?fa(function(o,s){return be(function(u,h){return e(o,u,s,h)})(kt(a(o,s)))},r):(typeof e=="number"&&(r=e),Lt(function(o,s){return Bc(o,s,a,r)}))}function un(a){return a===void 0&&(a=1/0),fa(Wo,a)}function pa(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];var r=zo(a),o=qo(a,1/0),s=a;return s.length?s.length===1?kt(s[0]):un(o)(an(s,r)):$o}function Pt(a,e){return Lt(function(r,o){var s=0;r.subscribe(Wt(o,function(u){return a.call(e,u,s++)&&o.next(u)}))})}function xt(a){return a<=0?function(){return $o}:Lt(function(e,r){var o=0;e.subscribe(Wt(r,function(s){++o<=a&&(r.next(s),a<=o&&r.complete())}))})}function Hc(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];var r=zo(a),o=qo(a,1/0);return Lt(function(s,u){un(o)(an(ve([s],ye(a)),r)).subscribe(u)})}function ma(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];return Hc.apply(void 0,ve([],ye(a)))}function dt(a){return Lt(function(e,r){kt(a).subscribe(Wt(r,function(){return r.complete()},wi)),!r.closed&&e.subscribe(r)})}var Ve=1e3,ln=class{constructor(e,r){this.id=e;this.movementDirection="none";this._tilePos={position:new T(0,0),layer:void 0};this.movementStarted$=new J;this.movementStopped$=new J;this.directionChanged$=new J;this.positionChangeStarted$=new J;this.positionChangeFinished$=new J;this.tilePositionSet$=new J;this.autoMovementSet$=new J;this.lastMovementImpulse="none";this.facingDirection="down";this.depthChanged$=new J;this.movementProgress=0;this.currentMovementReverted=!1;var o,s,u;this.tilemap=r.tilemap,this.speed=r.speed,this.collidesWithTilesInternal=r.collidesWithTiles,this._tilePos.layer=r.charLayer,this.ignoreMissingTiles=(o=r.ignoreMissingTiles)!=null?o:!1,this.collisionGroups=new Set(r.collisionGroups||[]),this.ignoreCollisionGroups=new Set(r.ignoreCollisionGroups||[]),this.labels=new Set(r.labels||[]),this.numberOfDirections=r.numberOfDirections,r.facingDirection&&this.turnTowards(r.facingDirection),this.tileWidth=(s=r.tileWidth)!=null?s:1,this.tileHeight=(u=r.tileHeight)!=null?u:1}getId(){return this.id}getSpeed(){return this.speed}setSpeed(e){this.speed=e}setMovement(e){this.autoMovementSet$.next(e),this.movement=e}getMovement(){return this.movement}collidesWithTiles(){return this.collidesWithTilesInternal}setCollidesWithTiles(e){this.collidesWithTilesInternal=e}getIgnoreMissingTiles(){return this.ignoreMissingTiles}setIgnoreMissingTiles(e){this.ignoreMissingTiles=e}setTilePosition(e){this.currentMovementReverted=!1,this.isMoving()&&this.movementStopped$.next(this.movementDirection),this.tilePositionSet$.next(q({},e)),this.fire(this.positionChangeStarted$,this.tilePos,e),this.fire(this.positionChangeFinished$,this.tilePos,e),this.movementDirection="none",this.lastMovementImpulse="none",this.tilePos=e,this.movementProgress=0}getTilePos(){return this.tilePos}getNextTilePos(){if(!this.isMoving())return this.tilePos;if(this.currentMovementReverted)return this.tilePos;let e=this.tilePos.layer,r=this.tilePosInDirection(this.tilePos.position,this.movementDirection),o=this.tilemap.getTransition(r,this.tilePos.layer);return o&&(e=o),{position:this.tilePosInDirection(this.tilePos.position,this.movementDirection),layer:e}}getTileWidth(){return this.tileWidth}getTileHeight(){return this.tileHeight}move(e){this.lastMovementImpulse=e,e!="none"&&(this.isMoving()||(this.isBlockingDirection(e)?this.changeFacingDirection(e):this.startMoving(e)))}update(e){var r;(r=this.movement)==null||r.update(e),this.isMoving()&&this.updateCharacterPosition(e),this.lastMovementImpulse="none"}getMovementDirection(){return this.movementDirection}isBlockingDirection(e){if(e=="none")return!1;let r=this.tilePosInDirection(this.getNextTilePos().position,e),o=this.tilemap.getTransition(r,this.getNextTilePos().layer)||this.getNextTilePos().layer;return this.collidesWithTilesInternal&&this.isTileBlocking(e,o)?!0:this.isCharBlocking(e,o)}isTileBlocking(e,r){return this.someCharTile((o,s)=>{let u=this.tilePosInDirection(new T(o,s),e);return this.tilemap.hasBlockingTile(u,r,Pi(e),this.ignoreMissingTiles)})}revertCurrentMovement(){this.isMoving()&&(this.currentMovementReverted=!0,this.movementDirection=Pi(this.movementDirection),this.movementStopped$.next(this.facingDirection),this.facingDirection=this.movementDirection,this.movementProgress=Ve-this.movementProgress,this.movementStarted$.next(this.facingDirection))}isCurrentMovementReverted(){return this.currentMovementReverted}isCharBlocking(e,r){return this.someCharTile((o,s)=>{let u=this.tilePosInDirection(new T(o,s),e);return this.tilemap.hasBlockingChar(u,r,this.getCollisionGroups(),new Set([this.getId()]),this.ignoreCollisionGroups)})}isMoving(){return this.movementDirection!="none"}turnTowards(e){this.isMoving()||e!="none"&&this.changeFacingDirection(e)}changeFacingDirection(e){this.facingDirection!==e&&(this.facingDirection=e,this.directionChanged$.next(e))}getFacingDirection(){return this.facingDirection}getFacingPosition(){return this._tilePos.position.add(Ht(this.facingDirection))}addCollisionGroup(e){this.collisionGroups.add(e)}setCollisionGroups(e){this.collisionGroups=new Set(e)}setIgnoreCollisionGroups(e){this.ignoreCollisionGroups=new Set(e)}getCollisionGroups(){return Array.from(this.collisionGroups)}getIgnoreCollisionGroups(){return Array.from(this.ignoreCollisionGroups)}hasCollisionGroup(e){return this.collisionGroups.has(e)}removeCollisionGroup(e){this.collisionGroups.delete(e)}removeAllCollisionGroups(){this.collisionGroups.clear()}addLabels(e){for(let r of e)this.labels.add(r)}getLabels(){return[...this.labels.values()]}hasLabel(e){return this.labels.has(e)}clearLabels(){this.labels.clear()}removeLabels(e){for(let r of e)this.labels.delete(r)}getNumberOfDirections(){return this.numberOfDirections}movementStarted(){return this.movementStarted$}movementStopped(){return this.movementStopped$}directionChanged(){return this.directionChanged$}tilePositionSet(){return this.tilePositionSet$}positionChangeStarted(){return this.positionChangeStarted$}positionChangeFinished(){return this.positionChangeFinished$}autoMovementSet(){return this.autoMovementSet$}depthChanged(){return this.depthChanged$}getMovementProgress(){return this.movementProgress}setMovementProgress(e){let r=Math.max(0,Math.min(Ve,e));this.movementProgress=r}hasWalkedHalfATile(){return this.movementProgress>Ve/2}willCrossTileBorderThisUpdate(e){return this.movementProgress+this.maxProgressForDelta(e)>=Ve}updateCharacterPosition(e){let r=this.willCrossTileBorderThisUpdate(e),s=1-(r?Ve-this.movementProgress:this.maxProgressForDelta(e))/this.maxProgressForDelta(e);this.movementProgress=Math.min(this.movementProgress+this.maxProgressForDelta(e),Ve),r&&(this.movementProgress=0,this.shouldContinueMoving()?(this.fire(this.positionChangeFinished$,this.tilePos,this.getNextTilePos()),this.tilePos=this.getNextTilePos(),this.startMoving(this.lastMovementImpulse),s>0&&this.updateCharacterPosition(e*s)):this.stopMoving())}maxProgressForDelta(e){let o=e/1e3;return Math.floor(o*this.speed*Ve)}get tilePos(){return A.clone(this._tilePos)}set tilePos(e){A.copyOver(e,this._tilePos)}startMoving(e){e!=="none"&&(this.currentMovementReverted=!1,e!=this.movementDirection&&this.movementStarted$.next(e),this.movementDirection=e,this.facingDirection=e,this.fire(this.positionChangeStarted$,this.tilePos,this.getNextTilePos()))}tilePosInDirection(e,r){return e.add(Ht(this.tilemap.toMapDirection(r)))}shouldContinueMoving(){return this.lastMovementImpulse!=="none"&&!this.isBlockingDirection(this.lastMovementImpulse)}stopMoving(){if(this.movementDirection==="none")return;let e=this.tilePos,r=this.getNextTilePos(),o=this.movementDirection;this.tilePos=this.getNextTilePos(),this.movementDirection="none",this.movementStopped$.next(o),this.currentMovementReverted=!1,this.fire(this.positionChangeFinished$,e,r)}fire(e,{position:r,layer:o},{position:s,layer:u}){e.next({exitTile:r,enterTile:s,exitLayer:o,enterLayer:u})}someCharTile(e){let r=this.getNextTilePos().position;for(let o=r.x;o<r.x+this.getTileWidth();o++)for(let s=r.y;s<r.y+this.getTileHeight();s++)if(e(o,s))return!0;return!1}};var dr=class dr{constructor(e,r){this.walkingAnimationMapping=e;this.charsInRow=r;this.lastFootLeft=!1;this.directionToFrameRow={down:0,"down-left":1,"down-right":2,left:1,right:2,up:3,"up-left":1,"up-right":2};this._isEnabled=!0;this.frameChange$=new J;this.setWalkingAnimationMapping(e)}frameChange(){return this.frameChange$}setIsEnabled(e){this._isEnabled=e}isEnabled(){return this._isEnabled}updateCharacterFrame(e,r,o){this._isEnabled&&(r?this.setStandingFrameDuringWalk(e,o):this.setWalkingFrame(e))}setStandingFrame(e){this._isEnabled&&this._setStandingFrame(e)}setWalkingAnimationMapping(e){this.walkingAnimationMapping=e,this._isEnabled=this.walkingAnimationMapping!==void 0}getWalkingAnimationMapping(){return this.walkingAnimationMapping}getCharsInRow(){return this.charsInRow}setStandingFrameDuringWalk(e,r){this.isCurrentFrameStanding(e,r)||(this.lastFootLeft=!this.lastFootLeft),this._setStandingFrame(e)}setWalkingFrame(e){let r=this.framesOfDirection(e);r&&this.frameChange$.next(this.lastFootLeft?r.rightFoot:r.leftFoot)}_setStandingFrame(e){let r=this.framesOfDirection(e);r&&this.frameChange$.next(r.standing)}isCurrentFrameStanding(e,r){var o;return r===((o=this.framesOfDirection(e))==null?void 0:o.standing)}framesOfDirection(e){return typeof this.walkingAnimationMapping=="number"?this.getFramesForCharIndex(e,this.walkingAnimationMapping):this.getFramesForAnimationMapping(e)}getFramesForAnimationMapping(e){if(!this.walkingAnimationMapping||typeof this.walkingAnimationMapping=="number"||e==="none")return;let r=this.fallbackDirection(e);if(r!=="non