memoscan
← all memos

Memo 0xd007da60…eee233 on Ethereum

qr.prototype.createCell=function(e){var t=this.cellJunkyard.pop();return t?t.init(e):new this.Cell(e)},qr.prototype.Cell.prototype.prepareHalfedges=function(){for(var e,t=this.halfedges,r=t.length;r--;)(e=t[r].edge).vb&&e.va||t.splice(r,1);return t.sort((function(e,t){return t.angle-e.angle})),t.length},qr.prototype.Cell.prototype.getNeighborIds=function(){for(var e,t=[],r=this.halfedges.length;r--;)null!==(e=this.halfedges[r].edge).lSite&&e.lSite.voronoiId!=this.site.voronoiId?t.push(e.lSite.voronoiId):null!==e.rSite&&e.rSite.voronoiId!=this.site.voronoiId&&t.push(e.rSite.voronoiId);return t},qr.prototype.Cell.prototype.getBbox=function(){for(var e,t,r,n=this.halfedges,o=n.length,i=1/0,l=1/0,s=-1/0,a=-1/0;o--;)(t=(e=n[o].getStartpoint()).x)<i&&(i=t),(r=e.y)<l&&(l=r),t>s&&(s=t),r>a&&(a=r);return{x:i,y:l,width:s-i,height:a-l}},qr.prototype.Cell.prototype.pointIntersection=function(e,t){for(var r,n,o,i,l=this.halfedges,s=l.length;s--;){if(n=(r=l[s]).getStartpoint(),o=r.getEndpoint(),!(i=(t-n.y)*(o.x-n.x)-(e-n.x)*(o.y-n.y)))return 0;if(i>0)return-1}return 1},qr.prototype.Vertex=function(e,t){this.x=e,this.y=t},qr.prototype.Edge=function(e,t){this.lSite=e,this.rSite=t,this.va=this.vb=null},qr.prototype.Halfedge=function(e,t,r){if(this.site=t,this.edge=e,r)this.angle=Math.atan2(r.y-t.y,r.x-t.x);else{var n=e.va,o=e.vb;this.angle=e.lSite===t?Math.atan2(o.x-n.x,n.y-o.y):Math.atan2(n.x-o.x,o.y-n.y)}},qr.prototype.createHalfedge=function(e,t,r){return new this.Halfedge(e,t,r)},qr.prototype.Halfedge.prototype.getStartpoint=function(){return this.edge.lSite===this.site?this.edge.va:this.edge.vb},qr.prototype.Halfedge.prototype.getEndpoint=function(){return this.edge.lSite===this.site?this.edge.vb:this.edge.va},qr.prototype.createVertex=function(e,t){var r=this.vertexJunkyard.pop();return r?(r.x=e,r.y=t):r=new this.Vertex(e,t),this.vertices.push(r),r},qr.prototype.createEdge=function(e,t,r,n){var o=this.edgeJunkyard.pop();return o?(o.lSite=e,o.rSite=t,o.va=o.vb=null):o=new this.Edge(e,t),this.edges.push(o),r&&this.setEdgeStartpoint(o,e,t,r),n&&this.setEdgeEndpoint(o,e,t,n),this.cells[e.voronoiId].halfedges.push(this.createHalfedge(o,e,t)),this.cells[t.voronoiId].halfedges.push(this.createHalfedge(o,t,e)),o},qr.prototype.createBorderEdge=function(e,t,r){var n=this.edgeJunkyard.pop();return n?(n.lSite=e,n.rSite=null):n=new this.Edge(e,null),n.va=t,n.vb=r,this.edges.push(n),n},qr.prototype.setEdgeStartpoint=function(e,t,r,n){e.va||e.vb?e.lSite===r?e.vb=n:e.va=n:(e.va=n,e.lSite=t,e.rSite=r)},qr.prototype.setEdgeEndpoint=function(e,t,r,n){this.setEdgeStartpoint(e,r,t,n)},qr.prototype.Beachsection=function(){},qr.prototype.createBeachsection=function(e){var t=this.beachsectionJunkyard.pop();return t||(t=new this.Beachsection),t.site=e,t},qr.prototype.leftBreakPoint=function(e,t){var r=e.site,n=r.x,o=r.y,i=o-t;if(!i)return n;var l=e.rbPrevious;if(!l)return-1/0;var s=(r=l.site).x,a=r.y,u=a-t;if(!u)return s;var h=s-n,c=1/i-1/u,f=h/u;return c?(-f+this.sqrt(f*f-2*c*(h*h/(-2*u)-a+u/2+o-i/2)))/c+n:(n+s)/2},qr.prototype.rightBreakPoint=function(e,t){var r=e.rbNext;if(r)return this.leftBreakPoint(r,t);var n=e.site;return n.y===t?n.x:1/0},qr.prototype.detachBeachsection=function(e){this.detachCircleEvent(e),this.beachline.rbRemoveNode(e),this.beachsectionJunkyard.push(e)},qr.prototype.removeBeachsection=function(e){var t=e.circleEvent,r=t.x,n=t.ycenter,o=this.createVertex(r,n),i=e.rbPrevious,l=e.rbNext,s=[e],a=Math.abs;this.detachBeachsection(e);for(var u=i;u.circleEvent&&a(r-u.circleEvent.x)<1e-9&&a(n-u.circleEvent.ycenter)<1e-9;)i=u.rbPrevious,s.unshift(u),this.detachBeachsection(u),u=i;s.unshift(u),this.detachCircleEvent(u);for(var h=l;h.circleEvent&&a(r-h.circleEvent.x)<1e-9&&a(n-h.circleEvent.ycenter)<1e-9;)l=h.rbNext,s.push(h),this.detachBeachsection(h),h=l;s.push(h),this.detachCircleEvent(h);var c,f=s.length;for(c=1;c<f;c++)h=s[c],u=s[c-1],this.setEdgeStartpoint(h.edge,u.site,h.site,o);u=s[0],(h=s[f-1]).edge=this.createEdge(u.site,h.site,void 0,o),this.attachCircleEvent(u),this.attachCircleEvent(h)},qr.prototype.addBeachsection=function(e){for(var t,r,n,o,i=e.x,l=e.y,s=this.beachline.root;s;)if((n=this.leftBreakPoint(s,l)-i)>1e-9)s=s.rbLeft;else{if(!((o=i-this.rightBreakPoint(s,l))>1e-9)){n>-1e-9?(t=s.rbPrevious,r=s):o>-1e-9?(t=s,r=s.rbNext):t=r=s;break}if(!s.rbRight){t=s;break}s=s.rbRight}var a=this.createBeachsection(e);if(this.beachline.rbInsertSuccessor(t,a),t||r){if(t===r)return this.detachCircleEvent(t),r=this.createBeachsection(t.site),this.beachline.rbInsertSuccessor(a,r),a.edge=r.edge=this.createEdge(t.site,a.site),this.attachCircleEvent(t),void this.attachCircleEvent(r);if(!t||r){if(t!==r){this.detachCircleEvent(t),this.detachCircleEvent(r);var u=t.site,h=u.x,c=u.y,f=e.x-h,d=e.y-c,p=r.site,g=p.x-h,y=p.y-c,v=2*(f*y-d*g),x=f*f+d*d,b=g*g+y*y,m=this.createVertex((y*x-d*b)/v+h,(f*b-g*x)/v+c);return this.setEdgeStartpoint(r.edge,u,p,m),a.edge=this.createEdge(u,e,void 0,m),r.edge=this.createEdge(e,p,void 0,m),this.attachCircleEvent(t),void this.attachCircleEvent(r)}}else a.edge=this.createEdge(t.site,a.site)}},qr.prototype.CircleEvent=function(){this.arc=null,this.rbLeft=null,this.rbNext=null,this.rbParent=null,this.rbPrevious=null,this.rbRed=!1,this.rbRight=null,this.site=null,this.x=this.y=this.ycenter=0},qr.prototype.attachCircleEvent=function(e){var t=e.rbPrevious,r=e.rbNext;if(t&&r){var n=t.site,o=e.site,i=r.site;if(n!==i){var l=o.x,s=o.y,a=n.x-l,u=n.y-s,h=i.x-l,c=i.y-s,f=2*(a*c-u*h);if(!(f>=-2e-12)){var d=a*a+u*u,p=h*h+c*c,g=(c*d-u*p)/f,y=(a*p-h*d)/f,v=y+s,x=this.circleEventJunkyard.pop();x||(x=new this.CircleEvent),x.arc=e,x.site=o,x.x=g+l,x.y=v+this.sqrt(g*g+y*y),x.ycenter=v,e.circleEvent=x;for(var b=null,m=this.circleEvents.root;m;)if(x.y<m.y||x.y===m.y&&x.x<=m.x){if(!m.rbLeft){b=m.rbPrevious;break}m=m.rbLeft}else{if(!m.rbRight){b=m;break}m=m.rbRight}this.circleEvents.rbInsertSuccessor(b,x),b||(this.firstCircleEvent=x)}}}},qr.prototype.detachCircleEvent=function(e){var t=e.circleEvent;t&&(t.rbPrevious||(this.firstCircleEvent=t.rbNext),this.circleEvents.rbRemoveNode(t),this.circleEventJunkyard.push(t),e.circleEvent=null)},qr.prototype.connectEdge=function(e,t){var r=e.vb;if(r)return!0;var n,o,i=e.va,l=t.xl,s=t.xr,a=t.yt,u=t.yb,h=e.lSite,c=e.rSite,f=h.x,d=h.y,p=c.x,g=c.y,y=(f+p)/2,v=(d+g)/2;if(this.cells[h.voronoiId].closeMe=!0,this.cells[c.voronoiId].closeMe=!0,g!==d&&(o=v-(n=(f-p)/(g-d))*y),void 0===n){if(y<l||y>=s)return!1;if(f>p){if(!i||i.y<a)i=this.createVertex(y,a);else if(i.y>=u)return!1;r=this.createVertex(y,u)}else{if(!i||i.y>u)i=this.createVertex(y,u);else if(i.y<a)return!1;r=this.createVertex(y,a)}}else if(n<-1||n>1)if(f>p){if(!i||i.y<a)i=this.createVertex((a-o)/n,a);else if(i.y>=u)return!1;r=this.createVertex((u-o)/n,u)}else{if(!i||i.y>u)i=this.createVertex((u-o)/n,u);else if(i.y<a)return!1;r=this.createVertex((a-o)/n,a)}else if(d<g){if(!i||i.x<l)i=this.createVertex(l,n*l+o);else if(i.x>=s)return!1;r=this.createVertex(s,n*s+o)}else{if(!i||i.x>s)i=this.createVertex(s,n*s+o);else if(i.x<l)return!1;r=this.createVertex(l,n*l+o)}return e.va=i,e.vb=r,!0},qr.prototype.clipEdge=function(e,t){var r=e.va.x,n=e.va.y,o=0,i=1,l=e.vb.x-r,s=e.vb.y-n,a=r-t.xl;if(0===l&&a<0)return!1;var u=-a/l;if(l<0){if(u<o)return!1;u<i&&(i=u)}else if(l>0){if(u>i)return!1;u>o&&(o=u)}if(a=t.xr-r,0===l&&a<0)return!1;if(u=a/l,l<0){if(u>i)return!1;u>o&&(o=u)}else if(l>0){if(u<o)return!1;u<i&&(i=u)}if(a=n-t.yt,0===s&&a<0)return!1;if(u=-a/s,s<0){if(u<o)return!1;u<i&&(i=u)}else if(s>0){if(u>i)return!1;u>o&&(o=u)}if(a=t.yb-n,0===s&&a<0)return!1;if(u=a/s,s<0){if(u>i)return!1;u>o&&(o=u)}else if(s>0){if(u<o)return!1;u<i&&(i=u)}return o>0&&(e.va=this.createVertex(r+o*l,n+o*s)),i<1&&(e.vb=this.createVertex(r+i*l,n+i*s)),(o>0||i<1)&&(this.cells[e.lSite.voronoiId].closeMe=!0,this.cells[e.rSite.voronoiId].closeMe=!0),!0},qr.prototype.clipEdges=function(e){for(var t,r=this.edges,n=r.length,o=Math.abs;n--;)t=r[n],(!this.connectEdge(t,e)||!this.clipEdge(t,e)||o(t.va.x-t.vb.x)<1e-9&&o(t.va.y-t.vb.y)<1e-9)&&(t.va=t.vb=null,r.splice(n,1))},qr.prototype.closeCells=function(e){for(var t,r,n,o,i,l,s,a,u,h=e.xl,c=e.xr,f=e.yt,d=e.yb,p=this.cells,g=p.length,y=Math.abs;g--;)if((t=p[g]).prepareHalfedges()&&t.closeMe){for(o=(n=t.halfedges).length,r=0;r<o;){if(l=n[r].getEndpoint(),a=n[(r+1)%o].getStartpoint(),y(l.x-a.x)>=1e-9||y(l.y-a.y)>=1e-9)switch(!0){case this.equalWithEpsilon(l.x,h)&&this.lessThanWithEpsilon(l.y,d):if(u=this.equalWithEpsilon(a.x,h),s=this.createVertex(h,u?a.y:d),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;l=s;case this.equalWithEpsilon(l.y,d)&&this.lessThanWithEpsilon(l.x,c):if(u=this.equalWithEpsilon(a.y,d),s=this.createVertex(u?a.x:c,d),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;l=s;case this.equalWithEpsilon(l.x,c)&&this.greaterThanWithEpsilon(l.y,f):if(u=this.equalWithEpsilon(a.x,c),s=this.createVertex(c,u?a.y:f),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;l=s;case this.equalWithEpsilon(l.y,f)&&this.greaterThanWithEpsilon(l.x,h):if(u=this.equalWithEpsilon(a.y,f),s=this.createVertex(u?a.x:h,f),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;if(l=s,u=this.equalWithEpsilon(a.x,h),s=this.createVertex(h,u?a.y:d),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;if(l=s,u=this.equalWithEpsilon(a.y,d),s=this.createVertex(u?a.x:c,d),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;if(l=s,u=this.equalWithEpsilon(a.x,c),s=this.createVertex(c,u?a.y:f),i=this.createBorderEdge(t.site,l,s),r++,n.splice(r,0,this.createHalfedge(i,t.site,null)),o++,u)break;default:throw"Voronoi.closeCells() > this makes no sense!"}r++}t.closeMe=!1}},qr.prototype.quantizeSites=function(e){for(var t,r=this.ε,n=e.length;n--;)(t=e[n]).x=Math.floor(t.x/r)*r,t.y=Math.floor(t.y/r)*r},qr.prototype.recycle=function(e){if(e){if(!(e instanceof this.Diagram))throw"Voronoi.recycleDiagram() > Need a Diagram object.";this.toRecycle=e}},qr.prototype.compute=function(e,t){var r=new Date;this.reset(),this.toRecycle&&(this.vertexJunkyard=this.vertexJunkyard.concat(this.toRecycle.vertices),this.edgeJunkyard=this.edgeJunkyard.concat(this.toRecycle.edges),this.cellJunkyard=this.cellJunkyard.concat(this.toRecycle.cells),this.toRecycle=null);var n=e.slice(0);n.sort((function(e,t){var r=t.y-e.y;return r||t.x-e.x}));for(var o,i,l,s=n.pop(),a=0,u=this.cells;;)if(l=this.firstCircleEvent,s&&(!l||s.y<l.y||s.y===l.y&&s.x<l.x))s.x===o&&s.y===i||(u[a]=this.createCell(s),s.voronoiId=a++,this.addBeachsection(s),i=s.y,o=s.x),s=n.pop();else{if(!l)break;this.removeBeachsection(l.arc)}this.clipEdges(t),this.closeCells(t);var h=new Date,c=new this.Diagram;return c.cells=this.cells,c.edges=this.edges,c.vertices=this.vertices,c.execTime=h.getTime()-r.getTime(),this.reset(),c};var Vr=Math.PI/3,zr=[[0,0],[0,-1],[-1,0],[1,0],[0,1],[-1,-1],[1,-1],[-1,1],[1,1],[0,-2],[-2,0],[2,0],[0,2],[-1,-2],[1,-2],[-2,-1],[2,-1],[-2,1],[2,1],[-1,2],[1,2]],jr=zr.length;function Ur(e,t){this.width=e.shape[0],this.height=e.shape[1],this.radius=e.radius||e.minDistance,this.maxTries=Math.max(3,Math.ceil(e.tries||30)),this.rng=lr;const r=1e-14*Math.max(1,Math.max(this.width,this.height)/64|0);var n;this.squaredRadius=this.radius*this.radius,this.radiusPlusEpsilon=this.radius+r,this.cellSize=this.radius*Math.SQRT1_2,this.angleIncrement=2*Math.PI/this.maxTries,this.angleIncrementOnSuccess=Vr+2e-14,this.triesIncrementOnSuccess=Math.ceil(this.angleIncrementOnSuccess/this.angleIncrement),this.processList=[],this.samplePoints=[],this.gridShape=[Math.ceil(this.width/this.cellSize),Math.ceil(this.height/this.cellSize)],this.grid={strideX:(n=this.gridShape)[1],data:new Uint32Array(n[0]*n[1])}}Ur.prototype.width=null,Ur.prototype.height=null,Ur.prototype.radius=null,Ur.prototype.radiusPlusEpsilon=null,Ur.prototype.squaredRadius=null,Ur.prototype.cellSize=null,Ur.prototype.angleIncrement=null,Ur.prototype.angleIncrementOnSuccess=null,Ur.prototype.triesIncrementOnSuccess=null,Ur.prototype.maxTries=null,Ur.prototype.rng=null,Ur.prototype.processList=null,Ur.prototype.samplePoints=null,Ur.prototype.gridShape=null,Ur.prototype.grid=null,Ur.prototype.addRandomPoint=function(){return this.directAddPoint([this.rng()*this.width,this.rng()*this.height,this.rng()*Math.PI*2,0])},Ur.prototype.addPoint=function(e){return 2===e.length&&e[0]>=0&&e[0]<this.width&&e[1]>=0&&e[1]<this.height?this.directAddPoint([e[0],e[1],this.rng()*Math.PI*2,0]):null},Ur.prototype.directAddPoint=function(e){var t=[e[0],e[1]];this.processList.push(e),this.samplePoints.push(t);var r=(e[0]/this.cellSize|0)*this.grid.strideX+(e[1]/this.cellSize|0);return this.grid.data[r]=this.samplePoints.length,t},Ur.prototype.inNeighbourhood=function(e){var t,r,n,o,i,l=this.grid.strideX,s=this.gridShape[0],a=this.gridShape[1],u=e[0]/this.cellSize|0,h=e[1]/this.cellSize|0;for(t=0;t<jr;t++)if(n=u+zr[t][0],o=h+zr[t][1],-1!==(r=n<0||o<0||n>=s||o>=a?-1:n*l+o)&&0!==this.grid.data[r]&&(i=this.samplePoints[this.grid.data[r]-1],Math.pow(e[0]-i[0],2)+Math.pow(e[1]-i[1],2)<this.squaredRadius))return!0;return!1},Ur.prototype.next=function(){for(var e,t,r,n;this.processList.length>0;){var o=this.processList.length*this.rng()|0;for(r=(t=this.processList[o])[2],0===(e=t[3])&&(r+=(this.rng()-.5)*Vr*4);e<this.maxTries;e++){if((n=[t[0]+Math.cos(r)*this.radiusPlusEpsilon,t[1]+Math.sin(r)*this.radiusPlusEpsilon,r,0])[0]>=0&&n[0]<this.width&&n[1]>=0&&n[1]<this.height&&!this.inNeighbourhood(n))return t[2]=r+this.angleIncrementOnSuccess+this.rng()*this.angleIncrement,t[3]=e+this.triesIncrementOnSuccess,this.directAddPoint(n);r+=this.angleIncrement}if(e>=this.maxTries){const e=this.processList.pop();o<this.processList.length&&(this.processList[o]=e)}}return null},Ur.prototype.fill=function(){for(0===this.samplePoints.length&&this.addRandomPoint();this.next(););return this.samplePoints},Ur.prototype.getAllPoints=function(){return this.samplePoints},Ur.prototype.reset=function(){var e,t=this.grid.data;for(e=0;e<t.length;e++)t[e]=0;this.samplePoints=[],this.processList.length=0};!function e(t,r,n){function o(l,s){if(!r[l]){if(!t[l]){var a="function"==typeof require&&require;if(!s&&a)return a(l,!0);if(i)return i(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[l]={exports:{}};t[l][0].call(h.exports,(function(e){var r=t[l][1][e];return o(r||e)}),h,h.exports,e,t,r,n)}return r[l].exports}for(var i="function"==typeof require&&require,l=0;l<n.length;l++)o(n[l]);return o}({1:[function(e,t,r){var n,o=e("./lib/build-log"),i=e("./lib/epsilon"),l=e("./lib/intersecter"),s=e("./lib/segment-chainer"),a=e("./lib/segment-selector"),u=e("./lib/geojson"),h=!1,c=i();function f(e,t,r){var o=n.segments(e),i=n.segments(t),l=r(n.combine(o,i));return n.polygon(l)}n={buildLog:function(e){return!0===e?h=o():!1===e&&(h=!1),!1!==h&&h.list},epsilon:function(e){return c.epsilon(e)},segments:function(e){var t=l(!0,c,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:l(!1,c,h).calculate(e.segments,e.inverted,t.segments,t.inverted),inverted1:e.inverted,inverted2:t.inverted}},selectUnion:function(e){return{segments:a.union(e.combined,h),inverted:e.inverted1||e.inverted2}},selectIntersect:function(e){return{segments:a.intersect(e.combined,h),inverted:e.inverted1&&e.inverted2}},selectDifference:function(e){return{segments:a.difference(e.combined,h),inverted:e.inverted1&&!e.inverted2}},selectDifferenceRev:function(e){return{segments:a.differenceRev(e.combined,h),inverted:!e.inverted1&&e.inverted2}},selectXor:function(e){return{segments:a.xor(e.combined,h),inverted:e.inverted1!==e.inverted2}},polygon:function(e){return{regions:s(e.segments,c,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return u.toPolygon(n,e)},polygonToGeoJSON:function(e){return u.fromPolygon(n,c,e)},union:function(e,t){return f(e,t,n.selectUnion)},intersect:function(e,t){return f(e,t,n.selectIntersect)},difference:function(e,t){return f(e,t,n.selectDifference)},differenceRev:function(e,t){return f(e,t,n.selectDifferenceRev)},xor:function(e,t){return f(e,t,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),t.exports=n},{"./lib/build-log":2,"./lib/epsilon":3,"./lib/geojson":4,"./lib/intersecter":5,"./lib/segment-chainer":7,"./lib/segment-selector":8}],2:[function(e,t,r){t.exports=function(){var e,t=0,r=!1;function n(t,r){return e.list.push({type:t,data:r?JSON.parse(JSON.stringify(r)):void 0}),e}return e={list:[],segmentId:function(){return t++},checkIntersection:function(e,t){return n("check",{seg1:e,seg2:t})},segmentChop:function(e,t){return n("div_seg",{seg:e,pt:t}),n("chop",{seg:e,pt:t})},statusRemove:function(e){return n("pop_seg",{seg:e})},segmentUpdate:function(e){return n("seg_update",{seg:e})},segmentNew:function(e,t){return n("new_seg",{seg:e,primary:t})},segmentRemove:function(e){return n("rem_seg",{seg:e})},tempStatus:function(e,t,r){return n("temp_status",{seg:e,above:t,below:r})},rewind:function(e){return n("rewind",{seg:e})},status:function(e,t,r){return n("status",{seg:e,above:t,below:r})},vert:function(t){return t===r?e:(r=t,n("vert",{x:t}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),n("log",{txt:e})},reset:function(){return n("reset")},selected:function(e){return n("selected",{segs:e})},chainStart:function(e){return n("chain_start",{seg:e})},chainRemoveHead:function(e,t){return n("chain_rem_head",{index:e,pt:t})},chainRemoveTail:function(e,t){return n("chain_rem_tail",{index:e,pt:t})},chainNew:function(e,t){return n("chain_new",{pt1:e,pt2:t})},chainMatch:function(e){return n("chain_match",{index:e})},chainClose:function(e){return n("chain_close",{index:e})},chainAddHead:function(e,t){return n("chain_add_head",{index:e,pt:t})},chainAddTail:function(e,t){return n("chain_add_tail",{index:e,pt:t})},chainConnect:function(e,t){return n("chain_con",{index1:e,index2:t})},chainReverse:function(e){return n("chain_rev",{index:e})},chainJoin:function(e,t){return n("chain_join",{index1:e,index2:t})},done:function(){return n("done")}}}},{}],3:[function(e,t,r){t.exports=function(e){"number"!=typeof e&&(e=1e-10);var t={epsilon:function(t){return"number"==typeof t&&(e=t),e},pointAboveOrOnLine:function(t,r,n){var o=r[0],i=r[1],l=n[0],s=n[1],a=t[0];return(l-o)*(t[1]-i)-(s-i)*(a-o)>=-e},pointBetween:function(t,r,n){var o=t[1]-r[1],i=n[0]-r[0],l=t[0]-r[0],s=n[1]-r[1],a=l*i+o*s;return!(a<e)&&!(a-(i*i+s*s)>-e)},pointsSameX:function(t,r){return Math.abs(t[0]-r[0])<e},pointsSameY:function(t,r){return Math.abs(t[1]-r[1])<e},pointsSame:function(e,r){return t.pointsSameX(e,r)&&t.pointsSameY(e,r)},pointsCompare:function(e,r){return t.pointsSameX(e,r)?t.pointsSameY(e,r)?0:e[1]<r[1]?-1:1:e[0]<r[0]?-1:1},pointsCollinear:function(t,r,n){var o=t[0]-r[0],i=t[1]-r[1],l=r[0]-n[0],s=r[1]-n[1];return Math.abs(o*s-l*i)<e},linesIntersect:function(t,r,n,o){var i=r[0]-t[0],l=r[1]-t[1],s=o[0]-n[0],a=o[1]-n[1],u=i*a-l*s;if(Math.abs(u)<e)return!1;var h=t[0]-n[0],c=t[1]-n[1],f=(s*c-a*h)/u,d=(i*c-l*h)/u,p={alongA:0,alongB:0,pt:[t[0]+f*i,t[1]+f*l]};return p.alongA=f<=-e?-2:f<e?-1:f-1<=-e?0:f-1<e?1:2,p.alongB=d<=-e?-2:d<e?-1:d-1<=-e?0:d-1<e?1:2,p},pointInsideRegion:function(t,r){for(var n=t[0],o=t[1],i=r[r.length-1][0],l=r[r.length-1][1],s=!1,a=0;a<r.length;a++){var u=r[a][0],h=r[a][1];h-o>e!=l-o>e&&(i-u)*(o-h)/(l-h)+u-n>e&&(s=!s),i=u,l=h}return s}};return t}},{}],4:[function(e,t,r){var n={toPolygon:function(e,t){function r(t){if(t.length<=0)return e.segments({inverted:!1,regions:[]});function r(t){var r=t.slice(0,t.length-1);return e.segments({inverted:!1,regions:[r]})}for(var n=r(t[0]),o=1;o<t.length;o++)n=e.selectDifference(e.combine(n,r(t[o])));return n}if("Polygon"===t.type)return e.polygon(r(t.coordinates));if("MultiPolygon"===t.type){for(var n=e.segments({inverted:!1,regions:[]}),o=0;o<t.coordinates.length;o++)n=e.selectUnion(e.combine(n,r(t.coordinates[o])));return e.polygon(n)}throw new Error("PolyBool: Cannot convert GeoJSON object to PolyBool polygon")},fromPolygon:function(e,t,r){function n(e,r){return t.pointInsideRegion([.5*(e[0][0]+e[1][0]),.5*(e[0][1]+e[1][1])],r)}function o(e){return{region:e,children:[]}}r=e.polygon(e.segments(r));var i=o(null);function l(e,t){for(var r=0;r<e.children.length;r++){if(n(t,(s=e.children[r]).region))return void l(s,t)}var i=o(t);for(r=0;r<e.children.length;r++){var s;n((s=e.children[r]).region,t)&&(i.children.push(s),e.children.splice(r,1),r--)}e.children.push(i)}for(var s=0;s<r.regions.length;s++){var a=r.regions[s];a.length<3||l(i,a)}function u(e,t){for(var r=0,n=e[e.length-1][0],o=e[e.length-1][1],i=[],l=0;l<e.length;l++){var s=e[l][0],a=e[l][1];i.push([s,a]),r+=a*n-s*o,n=s,o=a}return r<0!==t&&i.reverse(),i.push([i[0][0],i[0][1]]),i}var h=[];function c(e){var t=[u(e.region,!1)];h.push(t);for(var r=0;r<e.children.length;r++)t.push(f(e.children[r]))}function f(e){for(var t=0;t<e.children.length;t++)c(e.children[t]);return u(e.region,!0)}for(s=0;s<i.children.length;s++)c(i.children[s]);return h.length<=0?{type:"Polygon",coordinates:[]}:1==h.length?{type:"Polygon",coordinates:h[0]}:{type:"MultiPolygon",coordinates:h}}};t.exports=n},{}],5:[function(e,t,r){var n=e("./linked-list");t.exports=function(e,t,r){function o(e,t,n){return{id:r?r.segmentId():-1,start:e,end:t,myFill:{above:n.myFill.above,below:n.myFill.below},otherFill:null}}var i=n.create();function l(e,r){i.insertBefore(e,(function(n){return function(e,r,n,o,i,l){var s=t.pointsCompare(r,i);return 0!==s?s:t.pointsSame(n,l)?0:e!==o?e?1:-1:t.pointAboveOrOnLine(n,o?i:l,o?l:i)?1:-1}(e.isStart,e.pt,r,n.isStart,n.pt,n.other.pt)<0}))}function s(e,t){var r=function(e,t){var r=n.node({isStart:!0,pt:e.start,seg:e,primary:t,other:null,status:null});return l(r,e.end),r}(e,t);return function(e,t,r){var o=n.node({isStart:!1,pt:t.end,seg:t,primary:r,other:e,status:null});e.other=o,l(o,e.pt)}(r,e,t),r}function a(e,t){var n=o(t,e.seg.end,e.seg);return function(e,t){r&&r.segmentChop(e.seg,t),e.other.remove(),e.seg.end=t,e.other.pt=t,l(e.other,e.pt)}(e,t),s(n,e.primary)}function u(o,l){var s=n.create();function u(e){return s.findTransition((function(r){var n,o,i,l,s,a;return(n=e,o=r.ev,i=n.seg.start,l=n.seg.end,s=o.seg.start,a=o.seg.end,t.pointsCollinear(i,s,a)?t.pointsCollinear(l,s,a)||t.pointAboveOrOnLine(l,s,a)?1:-1:t.pointAboveOrOnLine(i,s,a)?1:-1)>0}))}function h(e,n){var o=e.seg,i=n.seg,l=o.start,s=o.end,u=i.start,h=i.end;r&&r.checkIntersection(o,i);var c=t.linesIntersect(l,s,u,h);if(!1===c){if(!t.pointsCollinear(l,s,u))return!1;if(t.pointsSame(l,h)||t.pointsSame(s,u))return!1;var f=t.pointsSame(l,u),d=t.pointsSame(s,h);if(f&&d)return n;var p=!f&&t.pointBetween(l,u,h),g=!d&&t.pointBetween(s,u,h);if(f)return g?a(n,s):a(e,h),n;p&&(d||(g?a(n,s):a(e,h)),a(n,l))}else 0===c.alongA&&(-1===c.alongB?a(e,u):0===c.alongB?a(e,c.pt):1===c.alongB&&a(e,h)),0===c.alongB&&(-1===c.alongA?a(n,l):0===c.alongA?a(n,c.pt):1===c.alongA&&a(n,s));return!1}for(var c=[];!i.isEmpty();){var f=i.getHead();if(r&&r.vert(f.pt[0]),f.isStart){r&&r.segmentNew(f.seg,f.primary);var d=u(f),p=d.before?d.before.ev:null,g=d.after?d.after.ev:null;function y(){if(p){var e=h(f,p);if(e)return e}return!!g&&h(f,g)}r&&r.tempStatus(f.seg,!!p&&p.seg,!!g&&g.seg);var v,x=y();if(x){var b;if(e)(b=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above);else x.seg.otherFill=f.seg.myFill;r&&r.segmentUpdate(x.seg),f.other.remove(),f.remove()}if(i.getHead()!==f){r&&r.rewind(f.seg);continue}if(e)b=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below,f.seg.myFill.below=g?g.seg.myFill.above:o,f.seg.myFill.above=b?!f.seg.myFill.below:f.seg.myFill.below;else if(null===f.seg.otherFill)v=g?f.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:f.primary?l:o,f.seg.otherFill={above:v,below:v};r&&r.status(f.seg,!!p&&p.seg,!!g&&g.seg),f.other.status=d.insert(n.node({ev:f}))}else{var m=f.status;if(null===m)throw new Error("Epsilon Issue");