-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathpathfinding-browser.min.js
More file actions
1 lines (1 loc) · 25.6 KB
/
pathfinding-browser.min.js
File metadata and controls
1 lines (1 loc) · 25.6 KB
1
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.PF=e()}}(function(){return function e(t,i,n){function r(a,s){if(!i[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=i[a]={exports:{}};t[a][0].call(u.exports,function(e){var i=t[a][1][e];return r(i?i:e)},u,u.exports,e,t,i,n)}return i[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)r(n[a]);return r}({1:[function(e,t){t.exports=e("./lib/heap")},{"./lib/heap":2}],2:[function(e,t){(function(){var e,i,n,r,o,a,s,l,u,h,p,c,f,d,g;n=Math.floor,h=Math.min,i=function(e,t){return t>e?-1:e>t?1:0},u=function(e,t,r,o,a){var s;if(null==r&&(r=0),null==a&&(a=i),0>r)throw new Error("lo must be non-negative");for(null==o&&(o=e.length);o>r;)s=n((r+o)/2),a(t,e[s])<0?o=s:r=s+1;return[].splice.apply(e,[r,r-r].concat(t)),t},a=function(e,t,n){return null==n&&(n=i),e.push(t),d(e,0,e.length-1,n)},o=function(e,t){var n,r;return null==t&&(t=i),n=e.pop(),e.length?(r=e[0],e[0]=n,g(e,0,t)):r=n,r},l=function(e,t,n){var r;return null==n&&(n=i),r=e[0],e[0]=t,g(e,0,n),r},s=function(e,t,n){var r;return null==n&&(n=i),e.length&&n(e[0],t)<0&&(r=[e[0],t],t=r[0],e[0]=r[1],g(e,0,n)),t},r=function(e,t){var r,o,a,s,l,u;for(null==t&&(t=i),s=function(){u=[];for(var t=0,i=n(e.length/2);i>=0?i>t:t>i;i>=0?t++:t--)u.push(t);return u}.apply(this).reverse(),l=[],o=0,a=s.length;a>o;o++)r=s[o],l.push(g(e,r,t));return l},f=function(e,t,n){var r;return null==n&&(n=i),r=e.indexOf(t),-1!==r?(d(e,0,r,n),g(e,r,n)):void 0},p=function(e,t,n){var o,a,l,u,h;if(null==n&&(n=i),a=e.slice(0,t),!a.length)return a;for(r(a,n),h=e.slice(t),l=0,u=h.length;u>l;l++)o=h[l],s(a,o,n);return a.sort(n).reverse()},c=function(e,t,n){var a,s,l,p,c,f,d,g,b,A;if(null==n&&(n=i),10*t<=e.length){if(p=e.slice(0,t).sort(n),!p.length)return p;for(l=p[p.length-1],g=e.slice(t),c=0,d=g.length;d>c;c++)a=g[c],n(a,l)<0&&(u(p,a,0,null,n),p.pop(),l=p[p.length-1]);return p}for(r(e,n),A=[],s=f=0,b=h(t,e.length);b>=0?b>f:f>b;s=b>=0?++f:--f)A.push(o(e,n));return A},d=function(e,t,n,r){var o,a,s;for(null==r&&(r=i),o=e[n];n>t&&(s=n-1>>1,a=e[s],r(o,a)<0);)e[n]=a,n=s;return e[n]=o},g=function(e,t,n){var r,o,a,s,l;for(null==n&&(n=i),o=e.length,l=t,a=e[t],r=2*t+1;o>r;)s=r+1,o>s&&!(n(e[r],e[s])<0)&&(r=s),e[t]=e[r],t=r,r=2*t+1;return e[t]=a,d(e,l,t,n)},e=function(){function e(e){this.cmp=null!=e?e:i,this.nodes=[]}return e.push=a,e.pop=o,e.replace=l,e.pushpop=s,e.heapify=r,e.updateItem=f,e.nlargest=p,e.nsmallest=c,e.prototype.push=function(e){return a(this.nodes,e,this.cmp)},e.prototype.pop=function(){return o(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return s(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return r(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return f(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return t=new e,t.nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),("undefined"!=typeof t&&null!==t?t.exports:void 0)?t.exports=e:window.Heap=e}).call(this)},{}],3:[function(e,t){var i={Always:1,Never:2,IfAtMostOneObstacle:3,OnlyWhenNoObstacles:4};t.exports=i},{}],4:[function(e,t){function i(e,t,i){this.width=e,this.height=t,this.nodes=this._buildNodes(e,t,i)}var n=e("./Node"),r=e("./DiagonalMovement");i.prototype._buildNodes=function(e,t,i){var r,o,a=new Array(t);for(r=0;t>r;++r)for(a[r]=new Array(e),o=0;e>o;++o)a[r][o]=new n(o,r);if(void 0===i)return a;if(i.length!==t||i[0].length!==e)throw new Error("Matrix size does not fit");for(r=0;t>r;++r)for(o=0;e>o;++o)i[r][o]&&(a[r][o].walkable=!1);return a},i.prototype.getNodeAt=function(e,t){return this.nodes[t][e]},i.prototype.isWalkableAt=function(e,t){return this.isInside(e,t)&&this.nodes[t][e].walkable},i.prototype.isInside=function(e,t){return e>=0&&e<this.width&&t>=0&&t<this.height},i.prototype.setWalkableAt=function(e,t,i){this.nodes[t][e].walkable=i},i.prototype.getNeighbors=function(e,t){var i=e.x,n=e.y,o=[],a=!1,s=!1,l=!1,u=!1,h=!1,p=!1,c=!1,f=!1,d=this.nodes;if(this.isWalkableAt(i,n-1)&&(o.push(d[n-1][i]),a=!0),this.isWalkableAt(i+1,n)&&(o.push(d[n][i+1]),l=!0),this.isWalkableAt(i,n+1)&&(o.push(d[n+1][i]),h=!0),this.isWalkableAt(i-1,n)&&(o.push(d[n][i-1]),c=!0),t===r.Never)return o;if(t===r.OnlyWhenNoObstacles)s=c&&a,u=a&&l,p=l&&h,f=h&&c;else if(t===r.IfAtMostOneObstacle)s=c||a,u=a||l,p=l||h,f=h||c;else{if(t!==r.Always)throw new Error("Incorrect value of diagonalMovement");s=!0,u=!0,p=!0,f=!0}return s&&this.isWalkableAt(i-1,n-1)&&o.push(d[n-1][i-1]),u&&this.isWalkableAt(i+1,n-1)&&o.push(d[n-1][i+1]),p&&this.isWalkableAt(i+1,n+1)&&o.push(d[n+1][i+1]),f&&this.isWalkableAt(i-1,n+1)&&o.push(d[n+1][i-1]),o},i.prototype.clone=function(){var e,t,r=this.width,o=this.height,a=this.nodes,s=new i(r,o),l=new Array(o);for(e=0;o>e;++e)for(l[e]=new Array(r),t=0;r>t;++t)l[e][t]=new n(t,e,a[e][t].walkable);return s.nodes=l,s},t.exports=i},{"./DiagonalMovement":3,"./Node":6}],5:[function(e,t){t.exports={manhattan:function(e,t){return e+t},euclidean:function(e,t){return Math.sqrt(e*e+t*t)},octile:function(e,t){var i=Math.SQRT2-1;return t>e?i*e+t:i*t+e},chebyshev:function(e,t){return Math.max(e,t)}}},{}],6:[function(e,t){function i(e,t,i){this.x=e,this.y=t,this.walkable=void 0===i?!0:i}t.exports=i},{}],7:[function(e,t,i){function n(e){for(var t=[[e.x,e.y]];e.parent;)e=e.parent,t.push([e.x,e.y]);return t.reverse()}function r(e,t){var i=n(e),r=n(t);return i.concat(r.reverse())}function o(e){var t,i,n,r,o,a=0;for(t=1;t<e.length;++t)i=e[t-1],n=e[t],r=i[0]-n[0],o=i[1]-n[1],a+=Math.sqrt(r*r+o*o);return a}function a(e,t,i,n){var r,o,a,s,l,u,h=Math.abs,p=[];for(a=h(i-e),s=h(n-t),r=i>e?1:-1,o=n>t?1:-1,l=a-s;;){if(p.push([e,t]),e===i&&t===n)break;u=2*l,u>-s&&(l-=s,e+=r),a>u&&(l+=a,t+=o)}return p}function s(e){var t,i,n,r,o,s,l=[],u=e.length;if(2>u)return l;for(o=0;u-1>o;++o)for(t=e[o],i=e[o+1],n=a(t[0],t[1],i[0],i[1]),r=n.length,s=0;r-1>s;++s)l.push(n[s]);return l.push(e[u-1]),l}function l(e,t){var i,n,r,o,s,l,u,h,p,c,f,d=t.length,g=t[0][0],b=t[0][1],A=t[d-1][0],v=t[d-1][1];for(i=g,n=b,s=[[i,n]],l=2;d>l;++l){for(h=t[l],r=h[0],o=h[1],p=a(i,n,r,o),f=!1,u=1;u<p.length;++u)if(c=p[u],!e.isWalkableAt(c[0],c[1])){f=!0;break}f&&(lastValidCoord=t[l-1],s.push(lastValidCoord),i=lastValidCoord[0],n=lastValidCoord[1])}return s.push([A,v]),s}function u(e){if(e.length<3)return e;var t,i,n,r,o,a,s=[],l=e[0][0],u=e[0][1],h=e[1][0],p=e[1][1],c=h-l,f=p-u;for(o=Math.sqrt(c*c+f*f),c/=o,f/=o,s.push([l,u]),a=2;a<e.length;a++)t=h,i=p,n=c,r=f,h=e[a][0],p=e[a][1],c=h-t,f=p-i,o=Math.sqrt(c*c+f*f),c/=o,f/=o,(c!==n||f!==r)&&s.push([t,i]);return s.push([h,p]),s}i.backtrace=n,i.biBacktrace=r,i.pathLength=o,i.interpolate=a,i.expandPath=s,i.smoothenPath=l,i.compressPath=u},{}],8:[function(e,t){t.exports={Heap:e("heap"),Node:e("./core/Node"),Grid:e("./core/Grid"),Util:e("./core/Util"),DiagonalMovement:e("./core/DiagonalMovement"),Heuristic:e("./core/Heuristic"),AStarFinder:e("./finders/AStarFinder"),BestFirstFinder:e("./finders/BestFirstFinder"),BreadthFirstFinder:e("./finders/BreadthFirstFinder"),DijkstraFinder:e("./finders/DijkstraFinder"),BiAStarFinder:e("./finders/BiAStarFinder"),BiBestFirstFinder:e("./finders/BiBestFirstFinder"),BiBreadthFirstFinder:e("./finders/BiBreadthFirstFinder"),BiDijkstraFinder:e("./finders/BiDijkstraFinder"),IDAStarFinder:e("./finders/IDAStarFinder"),JumpPointFinder:e("./finders/JumpPointFinder"),ThetaStarFinder:e("./finders/ThetaStarFinder")}},{"./core/DiagonalMovement":3,"./core/Grid":4,"./core/Heuristic":5,"./core/Node":6,"./core/Util":7,"./finders/AStarFinder":9,"./finders/BestFirstFinder":10,"./finders/BiAStarFinder":11,"./finders/BiBestFirstFinder":12,"./finders/BiBreadthFirstFinder":13,"./finders/BiDijkstraFinder":14,"./finders/BreadthFirstFinder":15,"./finders/DijkstraFinder":16,"./finders/IDAStarFinder":17,"./finders/JumpPointFinder":22,"./finders/ThetaStarFinder":24,heap:1}],9:[function(e,t){function i(e){e=e||{},this.allowDiagonal=e.allowDiagonal,this.dontCrossCorners=e.dontCrossCorners,this.heuristic=e.heuristic||o.manhattan,this.weight=e.weight||1,this.diagonalMovement=e.diagonalMovement,this.diagonalMovement||(this.diagonalMovement=this.allowDiagonal?this.dontCrossCorners?a.OnlyWhenNoObstacles:a.IfAtMostOneObstacle:a.Never),this.heuristic=this.diagonalMovement===a.Never?e.heuristic||o.manhattan:e.heuristic||o.octile}var n=e("heap"),r=e("../core/Util"),o=e("../core/Heuristic"),a=e("../core/DiagonalMovement");i.prototype.findPath=function(e,t,i,o,a){var s,l,u,h,p,c,f,d,g=new n(function(e,t){return e.f-t.f}),b=a.getNodeAt(e,t),A=a.getNodeAt(i,o),v=this.heuristic,k=this.diagonalMovement,y=this.weight,m=Math.abs,W=Math.SQRT2;for(b.g=0,b.f=0,g.push(b),b.opened=!0;!g.empty();){if(s=g.pop(),s.closed=!0,s===A)return r.backtrace(A);for(l=a.getNeighbors(s,k),h=0,p=l.length;p>h;++h)u=l[h],u.closed||(c=u.x,f=u.y,d=s.g+(c-s.x===0||f-s.y===0?1:W),(!u.opened||d<u.g)&&(u.g=d,u.h=u.h||y*v(m(c-i),m(f-o)),u.f=u.g+u.h,u.parent=s,u.opened?g.updateItem(u):(g.push(u),u.opened=!0)))}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Heuristic":5,"../core/Util":7,heap:1}],10:[function(e,t){function i(e){n.call(this,e);var t=this.heuristic;this.heuristic=function(e,i){return 1e6*t(e,i)}}var n=e("./AStarFinder");i.prototype=new n,i.prototype.constructor=i,t.exports=i},{"./AStarFinder":9}],11:[function(e,t){function i(e){e=e||{},this.allowDiagonal=e.allowDiagonal,this.dontCrossCorners=e.dontCrossCorners,this.diagonalMovement=e.diagonalMovement,this.heuristic=e.heuristic||o.manhattan,this.weight=e.weight||1,this.diagonalMovement||(this.diagonalMovement=this.allowDiagonal?this.dontCrossCorners?a.OnlyWhenNoObstacles:a.IfAtMostOneObstacle:a.Never),this.heuristic=this.diagonalMovement===a.Never?e.heuristic||o.manhattan:e.heuristic||o.octile}var n=e("heap"),r=e("../core/Util"),o=e("../core/Heuristic"),a=e("../core/DiagonalMovement");i.prototype.findPath=function(e,t,i,o,a){var s,l,u,h,p,c,f,d,g=function(e,t){return e.f-t.f},b=new n(g),A=new n(g),v=a.getNodeAt(e,t),k=a.getNodeAt(i,o),y=this.heuristic,m=this.diagonalMovement,W=this.weight,M=Math.abs,w=Math.SQRT2,N=1,x=2;for(v.g=0,v.f=0,b.push(v),v.opened=N,k.g=0,k.f=0,A.push(k),k.opened=x;!b.empty()&&!A.empty();){for(s=b.pop(),s.closed=!0,l=a.getNeighbors(s,m),h=0,p=l.length;p>h;++h)if(u=l[h],!u.closed){if(u.opened===x)return r.biBacktrace(s,u);c=u.x,f=u.y,d=s.g+(c-s.x===0||f-s.y===0?1:w),(!u.opened||d<u.g)&&(u.g=d,u.h=u.h||W*y(M(c-i),M(f-o)),u.f=u.g+u.h,u.parent=s,u.opened?b.updateItem(u):(b.push(u),u.opened=N))}for(s=A.pop(),s.closed=!0,l=a.getNeighbors(s,m),h=0,p=l.length;p>h;++h)if(u=l[h],!u.closed){if(u.opened===N)return r.biBacktrace(u,s);c=u.x,f=u.y,d=s.g+(c-s.x===0||f-s.y===0?1:w),(!u.opened||d<u.g)&&(u.g=d,u.h=u.h||W*y(M(c-e),M(f-t)),u.f=u.g+u.h,u.parent=s,u.opened?A.updateItem(u):(A.push(u),u.opened=x))}}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Heuristic":5,"../core/Util":7,heap:1}],12:[function(e,t){function i(e){n.call(this,e);var t=this.heuristic;this.heuristic=function(e,i){return 1e6*t(e,i)}}var n=e("./BiAStarFinder");i.prototype=new n,i.prototype.constructor=i,t.exports=i},{"./BiAStarFinder":11}],13:[function(e,t){function i(e){e=e||{},this.allowDiagonal=e.allowDiagonal,this.dontCrossCorners=e.dontCrossCorners,this.diagonalMovement=e.diagonalMovement,this.diagonalMovement||(this.diagonalMovement=this.allowDiagonal?this.dontCrossCorners?r.OnlyWhenNoObstacles:r.IfAtMostOneObstacle:r.Never)}var n=e("../core/Util"),r=e("../core/DiagonalMovement");i.prototype.findPath=function(e,t,i,r,o){var a,s,l,u,h,p=o.getNodeAt(e,t),c=o.getNodeAt(i,r),f=[],d=[],g=this.diagonalMovement,b=0,A=1;for(f.push(p),p.opened=!0,p.by=b,d.push(c),c.opened=!0,c.by=A;f.length&&d.length;){for(l=f.shift(),l.closed=!0,a=o.getNeighbors(l,g),u=0,h=a.length;h>u;++u)if(s=a[u],!s.closed)if(s.opened){if(s.by===A)return n.biBacktrace(l,s)}else f.push(s),s.parent=l,s.opened=!0,s.by=b;for(l=d.shift(),l.closed=!0,a=o.getNeighbors(l,g),u=0,h=a.length;h>u;++u)if(s=a[u],!s.closed)if(s.opened){if(s.by===b)return n.biBacktrace(s,l)}else d.push(s),s.parent=l,s.opened=!0,s.by=A}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Util":7}],14:[function(e,t){function i(e){n.call(this,e),this.heuristic=function(){return 0}}var n=e("./BiAStarFinder");i.prototype=new n,i.prototype.constructor=i,t.exports=i},{"./BiAStarFinder":11}],15:[function(e,t){function i(e){e=e||{},this.allowDiagonal=e.allowDiagonal,this.dontCrossCorners=e.dontCrossCorners,this.diagonalMovement=e.diagonalMovement,this.diagonalMovement||(this.diagonalMovement=this.allowDiagonal?this.dontCrossCorners?r.OnlyWhenNoObstacles:r.IfAtMostOneObstacle:r.Never)}var n=e("../core/Util"),r=e("../core/DiagonalMovement");i.prototype.findPath=function(e,t,i,r,o){var a,s,l,u,h,p=[],c=this.diagonalMovement,f=o.getNodeAt(e,t),d=o.getNodeAt(i,r);for(p.push(f),f.opened=!0;p.length;){if(l=p.shift(),l.closed=!0,l===d)return n.backtrace(d);for(a=o.getNeighbors(l,c),u=0,h=a.length;h>u;++u)s=a[u],s.closed||s.opened||(p.push(s),s.opened=!0,s.parent=l)}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Util":7}],16:[function(e,t){function i(e){n.call(this,e),this.heuristic=function(){return 0}}var n=e("./AStarFinder");i.prototype=new n,i.prototype.constructor=i,t.exports=i},{"./AStarFinder":9}],17:[function(e,t){function i(e){e=e||{},this.allowDiagonal=e.allowDiagonal,this.dontCrossCorners=e.dontCrossCorners,this.diagonalMovement=e.diagonalMovement,this.heuristic=e.heuristic||n.manhattan,this.weight=e.weight||1,this.trackRecursion=e.trackRecursion||!1,this.timeLimit=e.timeLimit||1/0,this.diagonalMovement||(this.diagonalMovement=this.allowDiagonal?this.dontCrossCorners?o.OnlyWhenNoObstacles:o.IfAtMostOneObstacle:o.Never),this.heuristic=this.diagonalMovement===o.Never?e.heuristic||n.manhattan:e.heuristic||n.octile}var n=(e("../core/Util"),e("../core/Heuristic")),r=e("../core/Node"),o=e("../core/DiagonalMovement");i.prototype.findPath=function(e,t,i,n,o){var a,s,l,u=0,h=(new Date).getTime(),p=function(e,t){return this.heuristic(Math.abs(t.x-e.x),Math.abs(t.y-e.y))}.bind(this),c=function(e,t){return e.x===t.x||e.y===t.y?1:Math.SQRT2},f=function(e,t,i,n,a){if(u++,this.timeLimit>0&&(new Date).getTime()-h>1e3*this.timeLimit)return 1/0;var s=t+p(e,g)*this.weight;if(s>i)return s;if(e==g)return n[a]=[e.x,e.y],e;var l,d,b,A,v=o.getNeighbors(e,this.diagonalMovement);for(b=0,l=1/0;A=v[b];++b){if(this.trackRecursion&&(A.retainCount=A.retainCount+1||1,A.tested!==!0&&(A.tested=!0)),d=f(A,t+c(e,A),i,n,a+1),d instanceof r)return n[a]=[e.x,e.y],d;this.trackRecursion&&0===--A.retainCount&&(A.tested=!1),l>d&&(l=d)}return l}.bind(this),d=o.getNodeAt(e,t),g=o.getNodeAt(i,n),b=p(d,g);for(a=0;!0;++a){if(s=[],l=f(d,0,b,s,0),1/0===l)return[];if(l instanceof r)return s;b=l}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Heuristic":5,"../core/Node":6,"../core/Util":7}],18:[function(e,t){function i(e){n.call(this,e)}var n=e("./JumpPointFinderBase"),r=e("../core/DiagonalMovement");i.prototype=new n,i.prototype.constructor=i,i.prototype._jump=function(e,t,i,n){var r=this.grid,o=e-i,a=t-n;if(!r.isWalkableAt(e,t))return null;if(this.trackJumpRecursion===!0&&(r.getNodeAt(e,t).tested=!0),r.getNodeAt(e,t)===this.endNode)return[e,t];if(0!==o&&0!==a){if(r.isWalkableAt(e-o,t+a)&&!r.isWalkableAt(e-o,t)||r.isWalkableAt(e+o,t-a)&&!r.isWalkableAt(e,t-a))return[e,t];if(this._jump(e+o,t,e,t)||this._jump(e,t+a,e,t))return[e,t]}else if(0!==o){if(r.isWalkableAt(e+o,t+1)&&!r.isWalkableAt(e,t+1)||r.isWalkableAt(e+o,t-1)&&!r.isWalkableAt(e,t-1))return[e,t]}else if(r.isWalkableAt(e+1,t+a)&&!r.isWalkableAt(e+1,t)||r.isWalkableAt(e-1,t+a)&&!r.isWalkableAt(e-1,t))return[e,t];return this._jump(e+o,t+a,e,t)},i.prototype._findNeighbors=function(e){var t,i,n,o,a,s,l,u,h=e.parent,p=e.x,c=e.y,f=this.grid,d=[];if(h)t=h.x,i=h.y,n=(p-t)/Math.max(Math.abs(p-t),1),o=(c-i)/Math.max(Math.abs(c-i),1),0!==n&&0!==o?(f.isWalkableAt(p,c+o)&&d.push([p,c+o]),f.isWalkableAt(p+n,c)&&d.push([p+n,c]),f.isWalkableAt(p+n,c+o)&&d.push([p+n,c+o]),f.isWalkableAt(p-n,c)||d.push([p-n,c+o]),f.isWalkableAt(p,c-o)||d.push([p+n,c-o])):0===n?(f.isWalkableAt(p,c+o)&&d.push([p,c+o]),f.isWalkableAt(p+1,c)||d.push([p+1,c+o]),f.isWalkableAt(p-1,c)||d.push([p-1,c+o])):(f.isWalkableAt(p+n,c)&&d.push([p+n,c]),f.isWalkableAt(p,c+1)||d.push([p+n,c+1]),f.isWalkableAt(p,c-1)||d.push([p+n,c-1]));else for(a=f.getNeighbors(e,r.Always),l=0,u=a.length;u>l;++l)s=a[l],d.push([s.x,s.y]);return d},t.exports=i},{"../core/DiagonalMovement":3,"./JumpPointFinderBase":23}],19:[function(e,t){function i(e){n.call(this,e)}var n=e("./JumpPointFinderBase"),r=e("../core/DiagonalMovement");i.prototype=new n,i.prototype.constructor=i,i.prototype._jump=function(e,t,i,n){var r=this.grid,o=e-i,a=t-n;if(!r.isWalkableAt(e,t))return null;if(this.trackJumpRecursion===!0&&(r.getNodeAt(e,t).tested=!0),r.getNodeAt(e,t)===this.endNode)return[e,t];if(0!==o&&0!==a){if(r.isWalkableAt(e-o,t+a)&&!r.isWalkableAt(e-o,t)||r.isWalkableAt(e+o,t-a)&&!r.isWalkableAt(e,t-a))return[e,t];if(this._jump(e+o,t,e,t)||this._jump(e,t+a,e,t))return[e,t]}else if(0!==o){if(r.isWalkableAt(e+o,t+1)&&!r.isWalkableAt(e,t+1)||r.isWalkableAt(e+o,t-1)&&!r.isWalkableAt(e,t-1))return[e,t]}else if(r.isWalkableAt(e+1,t+a)&&!r.isWalkableAt(e+1,t)||r.isWalkableAt(e-1,t+a)&&!r.isWalkableAt(e-1,t))return[e,t];return r.isWalkableAt(e+o,t)||r.isWalkableAt(e,t+a)?this._jump(e+o,t+a,e,t):null},i.prototype._findNeighbors=function(e){var t,i,n,o,a,s,l,u,h=e.parent,p=e.x,c=e.y,f=this.grid,d=[];if(h)t=h.x,i=h.y,n=(p-t)/Math.max(Math.abs(p-t),1),o=(c-i)/Math.max(Math.abs(c-i),1),0!==n&&0!==o?(f.isWalkableAt(p,c+o)&&d.push([p,c+o]),f.isWalkableAt(p+n,c)&&d.push([p+n,c]),(f.isWalkableAt(p,c+o)||f.isWalkableAt(p+n,c))&&d.push([p+n,c+o]),!f.isWalkableAt(p-n,c)&&f.isWalkableAt(p,c+o)&&d.push([p-n,c+o]),!f.isWalkableAt(p,c-o)&&f.isWalkableAt(p+n,c)&&d.push([p+n,c-o])):0===n?f.isWalkableAt(p,c+o)&&(d.push([p,c+o]),f.isWalkableAt(p+1,c)||d.push([p+1,c+o]),f.isWalkableAt(p-1,c)||d.push([p-1,c+o])):f.isWalkableAt(p+n,c)&&(d.push([p+n,c]),f.isWalkableAt(p,c+1)||d.push([p+n,c+1]),f.isWalkableAt(p,c-1)||d.push([p+n,c-1]));else for(a=f.getNeighbors(e,r.IfAtMostOneObstacle),l=0,u=a.length;u>l;++l)s=a[l],d.push([s.x,s.y]);return d},t.exports=i},{"../core/DiagonalMovement":3,"./JumpPointFinderBase":23}],20:[function(e,t){function i(e){n.call(this,e)}var n=e("./JumpPointFinderBase"),r=e("../core/DiagonalMovement");i.prototype=new n,i.prototype.constructor=i,i.prototype._jump=function(e,t,i,n){var r=this.grid,o=e-i,a=t-n;if(!r.isWalkableAt(e,t))return null;if(this.trackJumpRecursion===!0&&(r.getNodeAt(e,t).tested=!0),r.getNodeAt(e,t)===this.endNode)return[e,t];if(0!==o&&0!==a){if(this._jump(e+o,t,e,t)||this._jump(e,t+a,e,t))return[e,t]}else if(0!==o){if(r.isWalkableAt(e,t-1)&&!r.isWalkableAt(e-o,t-1)||r.isWalkableAt(e,t+1)&&!r.isWalkableAt(e-o,t+1))return[e,t]}else if(0!==a&&(r.isWalkableAt(e-1,t)&&!r.isWalkableAt(e-1,t-a)||r.isWalkableAt(e+1,t)&&!r.isWalkableAt(e+1,t-a)))return[e,t];return r.isWalkableAt(e+o,t)&&r.isWalkableAt(e,t+a)?this._jump(e+o,t+a,e,t):null},i.prototype._findNeighbors=function(e){var t,i,n,o,a,s,l,u,h=e.parent,p=e.x,c=e.y,f=this.grid,d=[];if(h)if(t=h.x,i=h.y,n=(p-t)/Math.max(Math.abs(p-t),1),o=(c-i)/Math.max(Math.abs(c-i),1),0!==n&&0!==o)f.isWalkableAt(p,c+o)&&d.push([p,c+o]),f.isWalkableAt(p+n,c)&&d.push([p+n,c]),f.isWalkableAt(p,c+o)&&f.isWalkableAt(p+n,c)&&d.push([p+n,c+o]);else{var g;if(0!==n){g=f.isWalkableAt(p+n,c);var b=f.isWalkableAt(p,c+1),A=f.isWalkableAt(p,c-1);g&&(d.push([p+n,c]),b&&d.push([p+n,c+1]),A&&d.push([p+n,c-1])),b&&d.push([p,c+1]),A&&d.push([p,c-1])}else if(0!==o){g=f.isWalkableAt(p,c+o);var v=f.isWalkableAt(p+1,c),k=f.isWalkableAt(p-1,c);g&&(d.push([p,c+o]),v&&d.push([p+1,c+o]),k&&d.push([p-1,c+o])),v&&d.push([p+1,c]),k&&d.push([p-1,c])}}else for(a=f.getNeighbors(e,r.OnlyWhenNoObstacles),l=0,u=a.length;u>l;++l)s=a[l],d.push([s.x,s.y]);return d},t.exports=i},{"../core/DiagonalMovement":3,"./JumpPointFinderBase":23}],21:[function(e,t){function i(e){n.call(this,e)}var n=e("./JumpPointFinderBase"),r=e("../core/DiagonalMovement");i.prototype=new n,i.prototype.constructor=i,i.prototype._jump=function(e,t,i,n){var r=this.grid,o=e-i,a=t-n;if(!r.isWalkableAt(e,t))return null;if(this.trackJumpRecursion===!0&&(r.getNodeAt(e,t).tested=!0),r.getNodeAt(e,t)===this.endNode)return[e,t];if(0!==o){if(r.isWalkableAt(e,t-1)&&!r.isWalkableAt(e-o,t-1)||r.isWalkableAt(e,t+1)&&!r.isWalkableAt(e-o,t+1))return[e,t]}else{if(0===a)throw new Error("Only horizontal and vertical movements are allowed");if(r.isWalkableAt(e-1,t)&&!r.isWalkableAt(e-1,t-a)||r.isWalkableAt(e+1,t)&&!r.isWalkableAt(e+1,t-a))return[e,t];if(this._jump(e+1,t,e,t)||this._jump(e-1,t,e,t))return[e,t]}return this._jump(e+o,t+a,e,t)},i.prototype._findNeighbors=function(e){var t,i,n,o,a,s,l,u,h=e.parent,p=e.x,c=e.y,f=this.grid,d=[];if(h)t=h.x,i=h.y,n=(p-t)/Math.max(Math.abs(p-t),1),o=(c-i)/Math.max(Math.abs(c-i),1),0!==n?(f.isWalkableAt(p,c-1)&&d.push([p,c-1]),f.isWalkableAt(p,c+1)&&d.push([p,c+1]),f.isWalkableAt(p+n,c)&&d.push([p+n,c])):0!==o&&(f.isWalkableAt(p-1,c)&&d.push([p-1,c]),f.isWalkableAt(p+1,c)&&d.push([p+1,c]),f.isWalkableAt(p,c+o)&&d.push([p,c+o]));else for(a=f.getNeighbors(e,r.Never),l=0,u=a.length;u>l;++l)s=a[l],d.push([s.x,s.y]);return d},t.exports=i},{"../core/DiagonalMovement":3,"./JumpPointFinderBase":23}],22:[function(e,t){function i(e){return e=e||{},e.diagonalMovement===n.Never?new r(e):e.diagonalMovement===n.Always?new o(e):e.diagonalMovement===n.OnlyWhenNoObstacles?new a(e):new s(e)}var n=e("../core/DiagonalMovement"),r=e("./JPFNeverMoveDiagonally"),o=e("./JPFAlwaysMoveDiagonally"),a=e("./JPFMoveDiagonallyIfNoObstacles"),s=e("./JPFMoveDiagonallyIfAtMostOneObstacle");t.exports=i},{"../core/DiagonalMovement":3,"./JPFAlwaysMoveDiagonally":18,"./JPFMoveDiagonallyIfAtMostOneObstacle":19,"./JPFMoveDiagonallyIfNoObstacles":20,"./JPFNeverMoveDiagonally":21}],23:[function(e,t){function i(e){e=e||{},this.heuristic=e.heuristic||o.manhattan,this.trackJumpRecursion=e.trackJumpRecursion||!1}{var n=e("heap"),r=e("../core/Util"),o=e("../core/Heuristic");e("../core/DiagonalMovement")}i.prototype.findPath=function(e,t,i,o,a){var s,l=this.openList=new n(function(e,t){return e.f-t.f}),u=this.startNode=a.getNodeAt(e,t),h=this.endNode=a.getNodeAt(i,o);for(this.grid=a,u.g=0,u.f=0,l.push(u),u.opened=!0;!l.empty();){if(s=l.pop(),s.closed=!0,s===h)return r.expandPath(r.backtrace(h));this._identifySuccessors(s)}return[]},i.prototype._identifySuccessors=function(e){{var t,i,n,r,a,s,l,u,h,p,c=this.grid,f=this.heuristic,d=this.openList,g=this.endNode.x,b=this.endNode.y,A=e.x,v=e.y,k=Math.abs;Math.max}for(t=this._findNeighbors(e),r=0,a=t.length;a>r;++r)if(i=t[r],n=this._jump(i[0],i[1],A,v)){if(s=n[0],l=n[1],p=c.getNodeAt(s,l),p.closed)continue;u=o.octile(k(s-A),k(l-v)),h=e.g+u,(!p.opened||h<p.g)&&(p.g=h,p.h=p.h||f(k(s-g),k(l-b)),p.f=p.g+p.h,p.parent=e,p.opened?d.updateItem(p):(d.push(p),p.opened=!0))}},t.exports=i},{"../core/DiagonalMovement":3,"../core/Heuristic":5,"../core/Util":7,heap:1}],24:[function(e,t){function i(e){this.allowDiagonal=!0,this.dontCrossCorners=!0,this.heuristic=o.euclidean,this.weight=e.weight||1.1,this.diagonalMovement=a.OnlyWhenNoObstacles}var n=e("heap"),r=e("../core/Util"),o=e("../core/Heuristic"),a=e("../core/DiagonalMovement");i.prototype.distance=function(e,t,i,n){return e-=i,t-=n,Math.sqrt(e*e+t*t)},i.prototype.lineOfSight=function(e,t,i,n,r){var o,a,s,l,u,h=e,p=t,c=i,f=n,d=c-h,g=f-p;if(0>d?(d=-d,o=-1):o=1,0>g?(g=-g,a=-1):a=1,0==d){for(p+=a;p!=f;p+=a)if(!r.isWalkableAt(h,p))return!1;return!0}if(0==g){for(h+=o;h!=c;h+=o)if(!r.isWalkableAt(h,p))return!1;return!0}if(d>=g){if(!r.isWalkableAt(h,p+a)||!r.isWalkableAt(c,f-a))return!1;for(l=p,u=f,s=g;s+=g,s>=d?(h+=o,p+=a,c-=o,f-=a,s-=d):(h+=o,c-=o),h!=c+o;){if(h==c){if(p==f){if(!r.isWalkableAt(h,p-a)||!r.isWalkableAt(h,p)||!r.isWalkableAt(h,p+a))return!1}else if(!r.isWalkableAt(h,p)||!r.isWalkableAt(c,f))return!1;break}if(p!=l&&!r.isWalkableAt(h,p-a))return!1;if(!r.isWalkableAt(h,p)||!r.isWalkableAt(h,p+a))return!1;if(f!=u&&!r.isWalkableAt(c,f+a))return!1;if(!r.isWalkableAt(c,f)||!r.isWalkableAt(c,f-a))return!1}}else{if(!r.isWalkableAt(h+o,p)||!r.isWalkableAt(c-o,f))return!1;for(l=h,u=c,s=d;s+=d,s>=g?(h+=o,p+=a,c-=o,f-=a,s-=g):(p+=a,f-=a),p!=f+a;){if(p==f){if(h==c){if(!r.isWalkableAt(h-o,p)||!r.isWalkableAt(h,p)||!r.isWalkableAt(h+o,p))return!1}else if(!r.isWalkableAt(h,p)||!r.isWalkableAt(c,f))return!1;break}if(h!=l&&!r.isWalkableAt(h-o,p))return!1;if(!r.isWalkableAt(h,p)||!r.isWalkableAt(h+o,p))return!1;if(c!=u&&!r.isWalkableAt(c+o,f))return!1;if(!r.isWalkableAt(c,f)||!r.isWalkableAt(c-o,f))return!1}}return!0},i.prototype.findPath=function(e,t,i,o,a){var s,l,u,h,p,c,f,d,g=new n(function(e,t){return e.f-t.f}),b=a.getNodeAt(e,t),A=a.getNodeAt(i,o),v=this.distance,k=this.lineOfSight,y=this.diagonalMovement,m=this.weight;for(b.g=0,b.f=0,g.push(b),b.opened=!0;!g.empty();){if(s=g.pop(),s.closed=!0,s===A)return r.backtrace(A);for(l=a.getNeighbors(s,y),h=0,p=l.length;p>h;++h)if(u=l[h],!u.closed){if(c=u.x,f=u.y,s.parent&&k(c,f,s.parent.x,s.parent.y,a)){if(d=s.parent.g+v(c,f,s.parent.x,s.parent.y),u.opened&&!(d<u.g))continue;u.g=d,u.parent=s.parent}else{if(d=s.g+v(c,f,s.x,s.y),u.opened&&!(d<u.g))continue;u.g=d,u.parent=s}u.h=u.h||m*v(c,f,i,o),u.f=u.g+u.h,u.opened?g.updateItem(u):(g.push(u),u.opened=!0)}}return[]},t.exports=i},{"../core/DiagonalMovement":3,"../core/Heuristic":5,"../core/Util":7,heap:1}]},{},[8])(8)});