grid-engine
Version:
Phaser3 plugin for grid based movement on a 2D game board.
3 lines • 220 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,Ib=Object.getPrototypeOf,bc=Object.prototype.hasOwnProperty,Mb=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,K=(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))Mb.call(e,r)&&vc(a,r,e[r]);return a},Bt=(a,e)=>Sb(a,Eb(e));var de=(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(Ib(a)):{},Ab(e||!a||!a.__esModule?oa(r,"default",{value:a,enumerable:!0}):r,a));var ga=de(Oi=>{var Jb=function(a,e){return a<e?-1:a>e?1:0},Zb=function(a,e){return a<e?1:a>e?-1:0};function tP(a){return function(e,r){return a(r,e)}}function eP(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=Jb;Oi.DEFAULT_REVERSE_COMPARATOR=Zb;Oi.reverseComparator=tP;Oi.createTupleComparator=eP});var Wc=de(da=>{da.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer!="undefined";da.SYMBOL_SUPPORT=typeof Symbol!="undefined"});var Ei=de((IC,$c)=>{var zc=Wc(),rP=zc.ARRAY_BUFFER_SUPPORT,iP=zc.SYMBOL_SUPPORT;$c.exports=function(e,r){var o,s,u,h,p;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)||rP&&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(iP&&Symbol.iterator in e&&typeof e.next!="function"&&(e=e[Symbol.iterator]()),typeof e.next=="function"){for(o=e,u=0;p=o.next(),p.done!==!0;)r(p.value,u),u++;return}for(s in e)e.hasOwnProperty(s)&&r(e[s],s)}});var th=de((MC,Zc)=>{var qc=ga(),Yc=Ei(),Xc=qc.DEFAULT_COMPARATOR,oP=qc.reverseComparator;function Ot(a){if(this.clear(),this.comparator=a||Xc,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.")}Ot.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function nP(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}Ot.prototype.push=function(a){var e=nP(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};Ot.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 sP(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 aP(a,e,r){Jc(a,e),e.left=e,e.right=e,sP(r,e),r.degree++,e.parent=r}function uP(a){var e=new Array(a.size),r=Kc(a.root),o,s,u,h,p,g;for(o=0,s=r.length;o<s;o++){for(u=r[o],p=u.degree;e[p];)h=e[p],a.comparator(u.item,h.item)>0&&(g=u,u=h,h=g),aP(a,h,u),e[p]=null,p++;e[p]=u}for(o=0;o<a.size;o++)e[o]&&a.comparator(e[o].item,a.min.item)<=0&&(a.min=e[o])}Ot.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,uP(this)),this.size--,a.item}};Ot.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:Ot,enumerable:!1}),a};typeof Symbol!="undefined"&&(Ot.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ot.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=oP(this.comparator)}mn.prototype=Ot.prototype;Ot.from=function(a,e){var r=new Ot(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};Ot.MinFibonacciHeap=Ot;Ot.MaxFibonacciHeap=mn;Zc.exports=Ot});var ya=de(Te=>{var lP=Math.pow(2,8)-1,cP=Math.pow(2,16)-1,hP=Math.pow(2,32)-1,fP=Math.pow(2,7)-1,pP=Math.pow(2,15)-1,mP=Math.pow(2,31)-1;Te.getPointerArray=function(a){var e=a-1;if(e<=lP)return Uint8Array;if(e<=cP)return Uint16Array;if(e<=hP)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};Te.getSignedPointerArray=function(a){var e=a-1;return e<=fP?Int8Array:e<=pP?Int16Array:e<=mP?Int32Array:Float64Array};Te.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 gP={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};Te.getMinimalRepresentation=function(a,e){var r=null,o=0,s,u,h,p,g;for(p=0,g=a.length;p<g;p++)h=e?e(a[p]):a[p],u=Te.getNumberType(h),s=gP[u.name],s>o&&(o=s,r=u);return r};Te.isTypedArray=function(a){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView(a)};Te.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};Te.indices=function(a){for(var e=Te.getPointerArray(a),r=new e(a),o=0;o<a;o++)r[o]=o;return r}});var ba=de(Di=>{var eh=Ei(),rh=ya();function dP(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 yP(a){var e=va(a),r=typeof e=="number"?new Array(e):[],o=0;return eh(a,function(s){r[o++]=s}),r}function vP(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=dP;Di.guessLength=va;Di.toArray=yP;Di.toArrayWithIndices=vP});var ah=de((FC,sh)=>{var gn=Ei(),ih=ga(),xe=ba(),yn=ih.DEFAULT_COMPARATOR,Pa=ih.reverseComparator;function Ta(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 Ii(a,e,r){for(var o=e.length,s=r,u=e[r],h=2*r+1,p;h<o;)p=h+1,p<o&&a(e[h],e[p])>=0&&(h=p),e[r]=e[h],r=h,h=2*r+1;e[r]=u,Ta(a,e,s,r)}function oh(a,e,r){e.push(r),Ta(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,Ii(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,Ii(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,Ii(a,e,0)),r}function vr(a,e){for(var r=e.length,o=r>>1,s=o;--s>=0;)Ii(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 bP(a,e,r){arguments.length===2&&(r=e,e=a,a=yn);var o=Pa(a),s,u,h,p=1/0,g;if(e===1){if(xe.isArrayLike(r)){for(s=0,u=r.length;s<u;s++)h=r[s],(p===1/0||a(h,p)<0)&&(p=h);return g=new r.constructor(1),g[0]=p,g}return gn(r,function(L){(p===1/0||a(L,p)<0)&&(p=L)}),[p]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(a);for(g=r.slice(0,e),vr(o,g),s=e,u=r.length;s<u;s++)o(r[s],g[0])>0&&Wr(o,g,r[s]);return g.sort(a)}var T=xe.guessLength(r);return T!==null&&T<e&&(e=T),g=new Array(e),s=0,gn(r,function(L){s<e?g[s]=L:(s===e&&vr(o,g),o(L,g[0])>0&&Wr(o,g,L)),s++}),g.length>s&&(g.length=s),g.sort(a)}function PP(a,e,r){arguments.length===2&&(r=e,e=a,a=yn);var o=Pa(a),s,u,h,p=-1/0,g;if(e===1){if(xe.isArrayLike(r)){for(s=0,u=r.length;s<u;s++)h=r[s],(p===-1/0||a(h,p)>0)&&(p=h);return g=new r.constructor(1),g[0]=p,g}return gn(r,function(L){(p===-1/0||a(L,p)>0)&&(p=L)}),[p]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(o);for(g=r.slice(0,e),vr(a,g),s=e,u=r.length;s<u;s++)a(r[s],g[0])>0&&Wr(a,g,r[s]);return g.sort(o)}var T=xe.guessLength(r);return T!==null&&T<e&&(e=T),g=new Array(e),s=0,gn(r,function(L){s<e?g[s]=L:(s===e&&vr(a,g),a(L,g[0])>0&&Wr(a,g,L)),s++}),g.length>s&&(g.length=s),g.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 dn(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=Pa(this.comparator)}dn.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};dn.from=function(a,e){var r=new dn(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=Ii;et.siftDown=Ta;et.push=oh;et.pop=xa;et.replace=Wr;et.pushpop=nh;et.heapify=vr;et.consume=wa;et.nsmallest=bP;et.nlargest=PP;et.MinHeap=et;et.MaxHeap=dn;sh.exports=et});var fh=de((kC,hh)=>{var uh="";function lh(a,e,r){for(var o=e.length,s=[],u=o,h=-1,p,g=0,T;u--;)h=Math.max(a[e[u]+r],h);for(T=h>>24&&32||h>>16&&24||h>>8&&16||8;g<T;g+=4){for(u=16;u--;)s[u]=[];for(u=o;u--;)s[a[e[u]+r]>>g&15].push(e[u]);for(p=0;p<16;p++)for(h=s[p].length;h--;)e[++u]=s[p][h]}}function TP(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,p=s,g=0,T,L=[],D=[];if(e===1)return[0];for(;p--;)r[p]=(p*3>>1)+1;for(p=3;p--;)lh(a,r,p);for(g=o[(r[0]/3|0)+(r[0]%3===1?0:h)]=1,p=1;p<s;p++)(a[r[p]]!==a[r[p-1]]||a[r[p]+1]!==a[r[p-1]+1]||a[r[p]+2]!==a[r[p-1]+2])&&g++,o[(r[p]/3|0)+(r[p]%3===1?0:h)]=g;if(g<s)for(o=Ca(o,s),p=s;p--;)r[p]=o[p]<h?o[p]*3+1:(o[p]-h)*3+2;for(p=s;p--;)L[r[p]]=p;for(L[e]=-1,L[e+1]=-2,o=e%3===1?[e-1]:[],p=0;p<s;p++)r[p]%3===1&&o.push(r[p]-1);for(lh(a,o,0),p=0,g=0,T=0;p<s&&g<u;)D[T++]=TP(a,L,r[p],o[g])<0?r[p++]:o[g++];for(;p<s;)D[T++]=r[p++];for(;g<u;)D[T++]=o[g++];return D}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 p=Object.create(null),g=Object.keys(h).sort();for(u=0,s=g.length;u<s;u++)p[g[u]]=u+1;for(u=0;u<e;u++)o[u]=p[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=de((VC,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=de((GC,yh)=>{var gh=mh(),xP=Ei(),wP=ba(),dh=ya(),CP=function(a){return Math.max(1,Math.ceil(a*1.5))},_P=function(a){var e=dh.getPointerArray(a);return new e(a)};function q(a,e){if(arguments.length<1)throw new Error("mnemonist/vector: expecting at least a byte array constructor.");var r=e||0,o=CP,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)}q.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};q.prototype.get=function(a){if(!(this.length<a))return this.array[a]};q.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};q.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),dh.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};q.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};q.prototype.resize=function(a){return a===this.length?this:a<this.length?(this.length=a,this):(this.length=a,this.reallocate(a),this)};q.prototype.push=function(a){return this.capacity===this.length&&this.grow(),this.array[this.length++]=a,this.length};q.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]};q.prototype.values=function(){var a=this.array,e=this.length,r=0;return new gh(function(){if(r>=e)return{done:!0};var o=a[r];return r++,{value:o,done:!1}})};q.prototype.entries=function(){var a=this.array,e=this.length,r=0;return new gh(function(){if(r>=e)return{done:!0};var o=a[r];return{value:[r++,o],done:!1}})};typeof Symbol!="undefined"&&(q.prototype[Symbol.iterator]=q.prototype.values);q.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:q,enumerable:!1}),a};typeof Symbol!="undefined"&&(q.prototype[Symbol.for("nodejs.util.inspect.custom")]=q.prototype.inspect);q.from=function(a,e,r){if(arguments.length<3&&(r=wP.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 q(e,r);return xP(a,function(s){o.push(s)}),o};function Ce(a){var e=function(o){q.call(this,a,o)};for(var r in q.prototype)q.prototype.hasOwnProperty(r)&&(e.prototype[r]=q.prototype[r]);return e.from=function(o,s){return q.from(o,a,s)},typeof Symbol!="undefined"&&(e.prototype[Symbol.iterator]=e.prototype.values),e}q.Int8Vector=Ce(Int8Array);q.Uint8Vector=Ce(Uint8Array);q.Uint8ClampedVector=Ce(Uint8ClampedArray);q.Int16Vector=Ce(Int16Array);q.Uint16Vector=Ce(Uint16Array);q.Int32Vector=Ce(Int32Array);q.Uint32Vector=Ce(Uint32Array);q.Float32Vector=Ce(Float32Array);q.Float64Vector=Ce(Float64Array);q.PointerVector=Ce(_P);yh.exports=q});var P=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 P(e.position.x,e.position.y),layer:e.charLayer}}static fromInternal(e){return{position:e.position.toPosition(),charLayer:e.layer}}};var At=(T=>(T.NONE="none",T.LEFT="left",T.UP_LEFT="up-left",T.UP="up",T.UP_RIGHT="up-right",T.RIGHT="right",T.DOWN_RIGHT="down-right",T.DOWN="down",T.DOWN_LEFT="down-left",T))(At||{}),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:P.UP,down:P.DOWN,left:P.LEFT,right:P.RIGHT,none:P.ZERO,"up-left":P.UP_LEFT,"up-right":P.UP_RIGHT,"down-right":P.DOWN_RIGHT,"down-left":P.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},Pc=["up","up-right","right","down-right","down","down-left","left","up-left"],kb=["down-left","down-right","up-right","up-left"];function Pi(){return["up","down","left","right","none","up-left","up-right","down-right","down-left"]}function fr(a){return kb.includes(a)}function Tc(a,e=1){return a==="none"?"none":Pc[(bi[a]+8-Math.abs(e)%8)%8]}function ko(a,e=1){return a==="none"?"none":Pc[(bi[a]+e)%8]}function Ht(a){return Fb[a]}function Ti(a){return Rb[a]}function Pt(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 Gr=(r=>(r[r.FOUR=4]="FOUR",r[r.EIGHT=8]="EIGHT",r))(Gr||{});function Qe(a){return typeof a=="string"&&Pi().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 p(L){try{T(o.next(L))}catch(D){h(D)}}function g(L){try{T(o.throw(L))}catch(D){h(D)}}function T(L){L.done?u(L.value):s(L.value).then(p,g)}T((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=p(0),h.throw=p(1),h.return=p(2),typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function p(T){return function(L){return g([T,L])}}function g(T){if(o)throw new TypeError("Generator is already executing.");for(;h&&(h=0,T[0]&&(r=0)),r;)try{if(o=1,s&&(u=T[0]&2?s.return:T[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,T[1])).done)return u;switch(s=0,u&&(T=[T[0]&2,u.value]),T[0]){case 0:case 1:u=T;break;case 4:return r.label++,{value:T[1],done:!1};case 5:r.label++,s=T[1],T=[0];continue;case 7:T=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(T[0]===6||T[0]===2)){r=0;continue}if(T[0]===3&&(!u||T[1]>u[0]&&T[1]<u[3])){r.label=T[1];break}if(T[0]===6&&r.label<u[1]){r.label=u[1],u=T;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(T);break}u[2]&&r.ops.pop(),r.trys.pop();continue}T=e.call(a,r)}catch(L){T=[6,L],s=0}finally{o=u=0}if(T[0]&5)throw T[1];return{value:T[0]?T[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(p){h={error:p}}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),p("next"),p("throw"),p("return",h),s[Symbol.asyncIterator]=function(){return this},s;function h(M){return function(H){return Promise.resolve(H).then(M,D)}}function p(M,H){o[M]&&(s[M]=function(B){return new Promise(function(st,ft){u.push([M,B,st,ft])>1||g(M,B)})},H&&(s[M]=H(s[M])))}function g(M,H){try{T(o[M](H))}catch(B){Y(u[0][3],B)}}function T(M){M.value instanceof pr?Promise.resolve(M.value.v).then(L,D):Y(u[0][2],M)}function L(M){g("next",M)}function D(M){g("throw",M)}function Y(M,H){M(H),u.shift(),u.length&&g(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(p,g){h=a[u](h),s(p,g,h.done,h.value)})}}function s(u,h,p,g){Promise.resolve(g).then(function(T){u({value:T,done:p})},h)}}function X(a){return typeof a=="function"}function Go(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 No=Go(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 Nr=(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 p=ke(h),g=p.next();!g.done;g=p.next()){var T=g.value;T.remove(this)}}catch(B){e={error:B}}finally{try{g&&!g.done&&(r=p.return)&&r.call(p)}finally{if(e)throw e.error}}else h.remove(this);var L=this.initialTeardown;if(X(L))try{L()}catch(B){u=B instanceof No?B.errors:[B]}var D=this._finalizers;if(D){this._finalizers=null;try{for(var Y=ke(D),M=Y.next();!M.done;M=Y.next()){var H=M.value;try{_c(H)}catch(B){u=u!=null?u:[],B instanceof No?u=ve(ve([],ye(u)),ye(B.errors)):u.push(B)}}}catch(B){o={error:B}}finally{try{M&&!M.done&&(s=Y.return)&&s.call(Y)}finally{if(o)throw o.error}}}if(u)throw new No(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=Nr.EMPTY;function jo(a){return a instanceof Nr||a&&"closed"in a&&X(a.remove)&&X(a.add)&&X(a.unsubscribe)}function _c(a){X(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})(Nr);var Vb=Function.prototype.bind;function ua(a,e){return Vb.call(a,e)}var Gb=(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(X(r)||!r)h={next:r!=null?r:void 0,error:o!=null?o:void 0,complete:s!=null?s:void 0};else{var p;u&&ae.useDeprecatedNextContext?(p=Object.create(r),p.unsubscribe=function(){return u.unsubscribe()},h={next:r.next&&ua(r.next,p),error:r.error&&ua(r.error,p),complete:r.complete&&ua(r.complete,p)}):h=r}return u.destination=new Gb(h),u}return e})(Ci);function Bo(a){ae.useDeprecatedSynchronousErrorHandling?Ec(a):Uo(a)}function Nb(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:Nb,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,p=h.operator,g=h.source;u.add(p?p.call(u,g):g?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(p){try{e(p)}catch(g){u(g),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&&X(a.next)&&X(a.error)&&X(a.complete)}function Bb(a){return a&&a instanceof Ci||Ub(a)&&jo(a)}function Hb(a){return X(a==null?void 0:a.lift)}function Ct(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,p){var g=a.call(this,r)||this;return g.onFinalize=h,g.shouldUnsubscribe=p,g._next=o?function(T){try{o(T)}catch(L){r.error(L)}}:a.prototype._next,g._error=u?function(T){try{u(T)}catch(L){r.error(L)}finally{this.unsubscribe()}}:a.prototype._error,g._complete=s?function(){try{s()}catch(T){r.error(T)}finally{this.unsubscribe()}}:a.prototype._complete,g}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 Ic=Go(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 Mc(this,this);return o.operator=r,o},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ic},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),p=h.next();!p.done;p=h.next()){var g=p.value;g.next(r)}}catch(T){s={error:T}}finally{try{p&&!p.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,p=s.observers;return u||h?sa:(this.currentObservers=null,p.push(r),new Nr(function(){o.currentObservers=null,xi(p,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 Mc(r,o)},e})(vt);var Mc=(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 zo=new vt(function(a){return a.complete()});function Ac(a){return a&&X(a.schedule)}function Rc(a){return a[a.length-1]}function $o(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 X(a==null?void 0:a.then)}function Qo(a){return X(a[Br])}function Ko(a){return Symbol.asyncIterator&&X(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 zb(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Zo=zb();function tn(a){return X(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 X(a==null?void 0:a.getReader)}function Rt(a){if(a instanceof vt)return a;if(a!=null){if(Qo(a))return $b(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 $b(a){return new vt(function(e){var r=a[Br]();if(X(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(p){r={error:p}}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,p;return Vo(this,function(g){switch(g.label){case 0:g.trys.push([0,5,6,11]),r=Cc(a),g.label=1;case 1:return[4,r.next()];case 2:if(o=g.sent(),!!o.done)return[3,4];if(h=o.value,e.next(h),e.closed)return[2];g.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return p=g.sent(),s={error:p},[3,11];case 6:return g.trys.push([6,,9,10]),o&&!o.done&&(u=r.return)?[4,u.call(r)]:[3,8];case 7:g.sent(),g.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),Ct(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),Ct(function(r,o){o.add(a.schedule(function(){return r.subscribe(o)},e))})}function kc(a,e){return Rt(a).pipe(nn(e),on(e))}function Vc(a,e){return Rt(a).pipe(nn(e),on(e))}function Gc(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 Nc(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(p){r.error(p);return}h?r.complete():r.next(u)},0,!0)}),function(){return X(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 Gc(a,e);if(Xo(a))return Vc(a,e);if(Ko(a))return sn(a,e);if(tn(a))return Nc(a,e);if(rn(a))return jc(a,e)}throw Jo(a)}function an(a,e){return e?Uc(a,e):Rt(a)}function be(a,e){return Ct(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,p){var g=[],T=0,L=0,D=!1,Y=function(){D&&!g.length&&!T&&e.complete()},M=function(B){return T<o?H(B):g.push(B)},H=function(B){u&&e.next(B),T++;var st=!1;Rt(r(B,L++)).subscribe(Wt(e,function(ft){s==null||s(ft),u?M(ft):e.next(ft)},function(){st=!0},void 0,function(){if(st)try{T--;for(var ft=function(){var er=g.shift();h?Zt(e,h,function(){return H(er)}):H(er)};g.length&&T<o;)ft();Y()}catch(er){e.error(er)}}))};return a.subscribe(Wt(e,M,function(){D=!0,Y()})),function(){p==null||p()}}function fa(a,e,r){return r===void 0&&(r=1/0),X(e)?fa(function(o,s){return be(function(u,h){return e(o,u,s,h)})(Rt(a(o,s)))},r):(typeof e=="number"&&(r=e),Ct(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=$o(a),o=qo(a,1/0),s=a;return s.length?s.length===1?Rt(s[0]):un(o)(an(s,r)):zo}function Tt(a,e){return Ct(function(r,o){var s=0;r.subscribe(Wt(o,function(u){return a.call(e,u,s++)&&o.next(u)}))})}function Ft(a){return a<=0?function(){return zo}:Ct(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=$o(a),o=qo(a,1/0);return Ct(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 gt(a){return Ct(function(e,r){Rt(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 P(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(K({},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 P(o,s),e);return this.tilemap.hasBlockingTile(u,r,Ti(e),this.ignoreMissingTiles)})}revertCurrentMovement(){this.isMoving()&&(this.currentMovementReverted=!0,this.movementDirection=Ti(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 P(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 gr=class gr{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)return this.walkingAnimationMapping[e]||this.walkingAnimationMapping[this.fallbackDirection(e)]}fallbackDirect