"use strict";var turf=(()=>{var ny=Object.create;var co=Object.defineProperty,ry=Object.defineProperties,iy=Object.getOwnPropertyDescriptor,oy=Object.getOwnPropertyDescriptors,sy=Object.getOwnPropertyNames,tf=Object.getOwnPropertySymbols,uy=Object.getPrototypeOf,ef=Object.prototype.hasOwnProperty,ay=Object.prototype.propertyIsEnumerable;var Ma=(n,t,e)=>t in n?co(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ve=(n,t)=>{for(var e in t||(t={}))ef.call(t,e)&&Ma(n,e,t[e]);if(tf)for(var e of tf(t))ay.call(t,e)&&Ma(n,e,t[e]);return n},Nr=(n,t)=>ry(n,oy(t));var pn=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}},Tr=(n,t)=>{for(var e in t)co(n,e,{get:t[e],enumerable:!0})},nf=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sy(t))!ef.call(n,i)&&i!==e&&co(n,i,{get:()=>t[i],enumerable:!(r=iy(t,i))||r.enumerable});return n};var Jn=(n,t,e)=>(e=n!=null?ny(uy(n)):{},nf(t||!n||!n.__esModule?co(e,"default",{value:n,enumerable:!0}):e,n)),ly=n=>nf(co({},"__esModule",{value:!0}),n);var et=(n,t,e)=>Ma(n,typeof t!="symbol"?t+"":t,e);var Li=pn((Aa,Fa)=>{(function(n,t){typeof Aa=="object"&&typeof Fa!="undefined"?Fa.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self).RBush=t()})(Aa,function(){"use strict";function n(M,L,C,q,V){(function X(G,J,k,N,T){for(;N>k;){if(N-k>600){var D=N-k+1,B=J-k+1,K=Math.log(D),w=.5*Math.exp(2*K/3),R=.5*Math.sqrt(K*w*(D-w)/D)*(B-D/2<0?-1:1),x=Math.max(k,Math.floor(J-B*w/D+R)),b=Math.min(N,Math.floor(J+(D-B)*w/D+R));X(G,J,x,b,T)}var E=G[J],A=k,z=N;for(t(G,k,J),T(G[N],E)>0&&t(G,k,N);A0;)z--}T(G[k],E)===0?t(G,k,z):t(G,++z,N),z<=J&&(k=z+1),J<=z&&(N=z-1)}})(M,L,C||0,q||M.length-1,V||e)}function t(M,L,C){var q=M[L];M[L]=M[C],M[C]=q}function e(M,L){return ML?1:0}var r=function(M){M===void 0&&(M=9),this._maxEntries=Math.max(4,M),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(M,L,C){if(!C)return L.indexOf(M);for(var q=0;q=M.minX&&L.maxY>=M.minY}function I(M){return{children:M,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function F(M,L,C,q,V){for(var X=[L,C];X.length;)if(!((C=X.pop())-(L=X.pop())<=q)){var G=L+Math.ceil((C-L)/q/2)*q;n(M,G,L,C,V),X.push(L,G,G,C)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(M){var L=this.data,C=[];if(!_(M,L))return C;for(var q=this.toBBox,V=[];L;){for(var X=0;X=0&&V[L].children.length>this._maxEntries;)this._split(V,L),L--;this._adjustParentBBoxes(q,V,L)},r.prototype._split=function(M,L){var C=M[L],q=C.children.length,V=this._minEntries;this._chooseSplitAxis(C,V,q);var X=this._chooseSplitIndex(C,V,q),G=I(C.children.splice(X,C.children.length-X));G.height=C.height,G.leaf=C.leaf,u(C,this.toBBox),u(G,this.toBBox),L?M[L-1].children.push(G):this._splitRoot(C,G)},r.prototype._splitRoot=function(M,L){this.data=I([M,L]),this.data.height=M.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(M,L,C){for(var q,V,X,G,J,k,N,T=1/0,D=1/0,B=L;B<=C-L;B++){var K=l(M,0,B,this.toBBox),w=l(M,B,C,this.toBBox),R=(V=K,X=w,G=void 0,J=void 0,k=void 0,N=void 0,G=Math.max(V.minX,X.minX),J=Math.max(V.minY,X.minY),k=Math.min(V.maxX,X.maxX),N=Math.min(V.maxY,X.maxY),Math.max(0,k-G)*Math.max(0,N-J)),x=d(K)+d(w);R=L;T--){var D=M.children[T];c(G,M.leaf?V(D):D),J+=y(G)}return J},r.prototype._adjustParentBBoxes=function(M,L,C){for(var q=C;q>=0;q--)c(L[q],M)},r.prototype._condense=function(M){for(var L=M.length-1,C=void 0;L>=0;L--)M[L].children.length===0?L>0?(C=M[L-1].children).splice(C.indexOf(M[L]),1):this.clear():u(M[L],this.toBBox)},r})});var Zf=pn((tb,Hf)=>{"use strict";Hf.exports=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var r,i,u;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(i=r;i--!==0;)if(!n(t[i],e[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(u=Object.keys(t),r=u.length,r!==Object.keys(e).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(e,u[i]))return!1;for(i=r;i--!==0;){var l=u[i];if(!n(t[l],e[l]))return!1}return!0}return t!==t&&e!==e}});var oh=pn((Wa,ja)=>{(function(n,t){typeof Wa=="object"&&typeof ja!="undefined"?ja.exports=t():typeof define=="function"&&define.amd?define(t):(n=typeof globalThis!="undefined"?globalThis:n||self).jsts=t()})(Wa,(function(){"use strict";function n(g,o){if(!(g instanceof o))throw new TypeError("Cannot call a class as a function")}function t(g,o){for(var s=0;sg.length)&&(o=g.length);for(var s=0,a=new Array(o);s=g.length?{done:!0}:{done:!1,value:g[a++]}},e:function(O){throw O},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var m,P=!0,S=!1;return{s:function(){s=s.call(g)},n:function(){var O=s.next();return P=O.done,O},e:function(O){S=!0,m=O},f:function(){try{P||s.return==null||s.return()}finally{if(S)throw m}}}}var L=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(o){this._quadrantSegments=o,this._quadrantSegments===0&&(this._joinStyle=g.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=g.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),o<=0&&(this._quadrantSegments=1),this._joinStyle!==g.JOIN_ROUND&&(this._quadrantSegments=g.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(o){this._joinStyle=o}},{key:"setSimplifyFactor",value:function(o){this._simplifyFactor=o<0?0:o}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(o){this._endCapStyle=o}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(o){this._mitreLimit=o}},{key:"setSingleSided",value:function(o){this._isSingleSided=o}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=g.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=g.CAP_ROUND,this._joinStyle=g.JOIN_ROUND,this._mitreLimit=g.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=g.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this.setQuadrantSegments(o)}else if(arguments.length===2){var s=arguments[0],a=arguments[1];this.setQuadrantSegments(s),this.setEndCapStyle(a)}else if(arguments.length===4){var f=arguments[0],m=arguments[1],P=arguments[2],S=arguments[3];this.setQuadrantSegments(f),this.setEndCapStyle(m),this.setJoinStyle(P),this.setMitreLimit(S)}}}},{key:"bufferDistanceError",value:function(o){var s=Math.PI/2/o;return 1-Math.cos(s/2)}}]),g})();L.CAP_ROUND=1,L.CAP_FLAT=2,L.CAP_SQUARE=3,L.JOIN_ROUND=1,L.JOIN_MITRE=2,L.JOIN_BEVEL=3,L.DEFAULT_QUADRANT_SEGMENTS=8,L.DEFAULT_MITRE_LIMIT=5,L.DEFAULT_SIMPLIFY_FACTOR=.01;var C=(function(g){r(s,g);var o=y(s);function s(a){var f;return n(this,s),(f=o.call(this,a)).name=Object.keys({Exception:s})[0],f}return e(s,[{key:"toString",value:function(){return this.message}}]),s})(h(Error)),q=(function(g){r(s,g);var o=y(s);function s(a){var f;return n(this,s),(f=o.call(this,a)).name=Object.keys({IllegalArgumentException:s})[0],f}return s})(C),V=(function(){function g(){n(this,g)}return e(g,[{key:"filter",value:function(o){}}]),g})();function X(){}function G(){}function J(){}var k,N,T,D,B,K,w,R,x=(function(){function g(){n(this,g)}return e(g,null,[{key:"equalsWithTolerance",value:function(o,s,a){return Math.abs(o-s)<=a}}]),g})(),b=(function(){function g(o,s){n(this,g),this.low=s||0,this.high=o||0}return e(g,null,[{key:"toBinaryString",value:function(o){var s,a="";for(s=2147483648;s>0;s>>>=1)a+=(o.high&s)===s?"1":"0";for(s=2147483648;s>0;s>>>=1)a+=(o.low&s)===s?"1":"0";return a}}]),g})();function E(){}function A(){}E.NaN=NaN,E.isNaN=function(g){return Number.isNaN(g)},E.isInfinite=function(g){return!Number.isFinite(g)},E.MAX_VALUE=Number.MAX_VALUE,E.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,E.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,typeof Float64Array=="function"&&typeof Int32Array=="function"?(K=2146435072,w=new Float64Array(1),R=new Int32Array(w.buffer),E.doubleToLongBits=function(g){w[0]=g;var o=0|R[0],s=0|R[1];return(s&K)===K&&(1048575&s)!=0&&o!==0&&(o=0,s=2146959360),new b(s,o)},E.longBitsToDouble=function(g){return R[0]=g.low,R[1]=g.high,w[0]}):(k=1023,N=Math.log2,T=Math.floor,D=Math.pow,B=(function(){for(var g=53;g>0;g--){var o=D(2,g)-1;if(T(N(o))+1===g)return o}return 0})(),E.doubleToLongBits=function(g){var o,s,a,f,m,P,S,O,Y;if(g<0||1/g===Number.NEGATIVE_INFINITY?(P=1<<31,g=-g):P=0,g===0)return new b(O=P,Y=0);if(g===1/0)return new b(O=2146435072|P,Y=0);if(g!=g)return new b(O=2146959360,Y=0);if(f=0,Y=0,(o=T(g))>1)if(o<=B)(f=T(N(o)))<=20?(Y=0,O=o<<20-f&1048575):(Y=o%(s=D(2,a=f-20))<<32-a,O=o/s&1048575);else for(a=o,Y=0;(a=T(s=a/2))!==0;)f++,Y>>>=1,Y|=(1&O)<<31,O>>>=1,s!==a&&(O|=524288);if(S=f+k,m=o===0,o=g-o,f<52&&o!==0)for(a=0;;){if((s=2*o)>=1?(o=s-1,m?(S--,m=!1):(a<<=1,a|=1,f++)):(o=s,m?--S==0&&(f++,m=!1):(a<<=1,f++)),f===20)O|=a,a=0;else if(f===52){Y|=a;break}if(s===1){f<20?O|=a<<20-f:f<52&&(Y|=a<<52-f);break}}return O|=S<<20,new b(O|=P,Y)},E.longBitsToDouble=function(g){var o,s,a,f,m=g.high,P=g.low,S=m&1<<31?-1:1;for(a=((2146435072&m)>>20)-k,f=0,s=1<<19,o=1;o<=20;o++)m&s&&(f+=D(2,-o)),s>>>=1;for(s=1<<31,o=21;o<=52;o++)P&s&&(f+=D(2,-o)),s>>>=1;if(a===-1023){if(f===0)return 0*S;a=-1022}else{if(a===1024)return f===0?S/0:NaN;f+=1}return S*f*D(2,a)});var z=(function(g){r(s,g);var o=y(s);function s(a){var f;return n(this,s),(f=o.call(this,a)).name=Object.keys({RuntimeException:s})[0],f}return s})(C),W=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,null,[{key:"constructor_",value:function(){if(arguments.length===0)z.constructor_.call(this);else if(arguments.length===1){var a=arguments[0];z.constructor_.call(this,a)}}}]),s})(z),j=(function(){function g(){n(this,g)}return e(g,null,[{key:"shouldNeverReachHere",value:function(){if(arguments.length===0)g.shouldNeverReachHere(null);else if(arguments.length===1){var o=arguments[0];throw new W("Should never reach here"+(o!==null?": "+o:""))}}},{key:"isTrue",value:function(){if(arguments.length===1){var o=arguments[0];g.isTrue(o,null)}else if(arguments.length===2){var s=arguments[0],a=arguments[1];if(!s)throw a===null?new W:new W(a)}}},{key:"equals",value:function(){if(arguments.length===2){var o=arguments[0],s=arguments[1];g.equals(o,s,null)}else if(arguments.length===3){var a=arguments[0],f=arguments[1],m=arguments[2];if(!f.equals(a))throw new W("Expected "+a+" but encountered "+f+(m!==null?": "+m:""))}}}]),g})(),tt=new ArrayBuffer(8),ot=new Float64Array(tt),rt=new Int32Array(tt),$=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getM",value:function(){return E.NaN}},{key:"setOrdinate",value:function(o,s){switch(o){case g.X:this.x=s;break;case g.Y:this.y=s;break;case g.Z:this.setZ(s);break;default:throw new q("Invalid ordinate index: "+o)}}},{key:"equals2D",value:function(){if(arguments.length===1){var o=arguments[0];return this.x===o.x&&this.y===o.y}if(arguments.length===2){var s=arguments[0],a=arguments[1];return!!x.equalsWithTolerance(this.x,s.x,a)&&!!x.equalsWithTolerance(this.y,s.y,a)}}},{key:"setM",value:function(o){throw new q("Invalid ordinate index: "+g.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(o){switch(o){case g.X:return this.x;case g.Y:return this.y;case g.Z:return this.getZ()}throw new q("Invalid ordinate index: "+o)}},{key:"equals3D",value:function(o){return this.x===o.x&&this.y===o.y&&(this.getZ()===o.getZ()||E.isNaN(this.getZ())&&E.isNaN(o.getZ()))}},{key:"equals",value:function(o){return o instanceof g&&this.equals2D(o)}},{key:"equalInZ",value:function(o,s){return x.equalsWithTolerance(this.getZ(),o.getZ(),s)}},{key:"setX",value:function(o){this.x=o}},{key:"compareTo",value:function(o){var s=o;return this.xs.x?1:this.ys.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(o){this.z=o}},{key:"clone",value:function(){try{return null}catch(o){if(o instanceof CloneNotSupportedException)return j.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw o}}},{key:"copy",value:function(){return new g(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(o){var s=this.x-o.x,a=this.y-o.y,f=this.getZ()-o.getZ();return Math.sqrt(s*s+a*a+f*f)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(o){this.y=o}},{key:"distance",value:function(o){var s=this.x-o.x,a=this.y-o.y;return Math.sqrt(s*s+a*a)}},{key:"hashCode",value:function(){var o=17;return o=37*(o=37*o+g.hashCode(this.x))+g.hashCode(this.y)}},{key:"setCoordinate",value:function(o){this.x=o.x,this.y=o.y,this.z=o.getZ()}},{key:"interfaces_",get:function(){return[X,G,J]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,arguments.length===0)g.constructor_.call(this,0,0);else if(arguments.length===1){var o=arguments[0];g.constructor_.call(this,o.x,o.y,o.getZ())}else if(arguments.length===2){var s=arguments[0],a=arguments[1];g.constructor_.call(this,s,a,g.NULL_ORDINATE)}else if(arguments.length===3){var f=arguments[0],m=arguments[1],P=arguments[2];this.x=f,this.y=m,this.z=P}}},{key:"hashCode",value:function(o){return ot[0]=o,rt[0]^rt[1]}}]),g})(),ht=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"compare",value:function(o,s){var a=g.compare(o.x,s.x);if(a!==0)return a;var f=g.compare(o.y,s.y);return f!==0?f:this._dimensionsToTest<=2?0:g.compare(o.getZ(),s.getZ())}},{key:"interfaces_",get:function(){return[A]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,arguments.length===0)g.constructor_.call(this,2);else if(arguments.length===1){var o=arguments[0];if(o!==2&&o!==3)throw new q("only 2 or 3 dimensions may be specified");this._dimensionsToTest=o}}},{key:"compare",value:function(o,s){return os?1:E.isNaN(o)?E.isNaN(s)?0:-1:E.isNaN(s)?1:0}}]),g})();$.DimensionalComparator=ht,$.NULL_ORDINATE=E.NaN,$.X=0,$.Y=1,$.Z=2,$.M=3;var ct=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(o){if(!(o instanceof g))return!1;var s=o;return this.isNull()?s.isNull():this._maxx===s.getMaxX()&&this._maxy===s.getMaxY()&&this._minx===s.getMinX()&&this._miny===s.getMinY()}},{key:"intersection",value:function(o){if(this.isNull()||o.isNull()||!this.intersects(o))return new g;var s=this._minx>o._minx?this._minx:o._minx,a=this._miny>o._miny?this._miny:o._miny;return new g(s,this._maxx=this._minx&&s.getMaxX()<=this._maxx&&s.getMinY()>=this._miny&&s.getMaxY()<=this._maxy}}else if(arguments.length===2){var a=arguments[0],f=arguments[1];return!this.isNull()&&a>=this._minx&&a<=this._maxx&&f>=this._miny&&f<=this._maxy}}},{key:"intersects",value:function(){if(arguments.length===1){if(arguments[0]instanceof g){var o=arguments[0];return!this.isNull()&&!o.isNull()&&!(o._minx>this._maxx||o._maxxthis._maxy||o._maxythis._maxx)return!1;var P=a.x>f.x?a.x:f.x;if(Pthis._maxy)return!1;var O=a.y>f.y?a.y:f.y;return!(Othis._maxx||Ythis._maxy||ntthis._maxx&&(this._maxx=s._maxx),s._minythis._maxy&&(this._maxy=s._maxy))}}else if(arguments.length===2){var a=arguments[0],f=arguments[1];this.isNull()?(this._minx=a,this._maxx=a,this._miny=f,this._maxy=f):(athis._maxx&&(this._maxx=a),fthis._maxy&&(this._maxy=f))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var o=this.getWidth(),s=this.getHeight();return os._minx?1:this._minys._miny?1:this._maxxs._maxx?1:this._maxys._maxy?1:0}},{key:"translate",value:function(o,s){if(this.isNull())return null;this.init(this.getMinX()+o,this.getMaxX()+o,this.getMinY()+s,this.getMaxY()+s)}},{key:"copy",value:function(){return new g(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(o){return!(!this.isNull()&&!o.isNull())||o._minx>this._maxx||o._maxxthis._maxy||o._maxys?o:s}},{key:"expandBy",value:function(){if(arguments.length===1){var o=arguments[0];this.expandBy(o,o)}else if(arguments.length===2){var s=arguments[0],a=arguments[1];if(this.isNull())return null;this._minx-=s,this._maxx+=s,this._miny-=a,this._maxy+=a,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(arguments.length===1){if(arguments[0]instanceof g){var o=arguments[0];return this.covers(o)}if(arguments[0]instanceof $){var s=arguments[0];return this.covers(s)}}else if(arguments.length===2){var a=arguments[0],f=arguments[1];return this.covers(a,f)}}},{key:"centre",value:function(){return this.isNull()?null:new $((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(arguments.length===0)this.setToNull();else if(arguments.length===1){if(arguments[0]instanceof $){var o=arguments[0];this.init(o.x,o.x,o.y,o.y)}else if(arguments[0]instanceof g){var s=arguments[0];this._minx=s._minx,this._maxx=s._maxx,this._miny=s._miny,this._maxy=s._maxy}}else if(arguments.length===2){var a=arguments[0],f=arguments[1];this.init(a.x,f.x,a.y,f.y)}else if(arguments.length===4){var m=arguments[0],P=arguments[1],S=arguments[2],O=arguments[3];mo._maxx&&(s=this._minx-o._maxx);var a=0;return this._maxyo._maxy&&(a=this._miny-o._maxy),s===0?a:a===0?s:Math.sqrt(s*s+a*a)}},{key:"hashCode",value:function(){var o=17;return o=37*(o=37*(o=37*(o=37*o+$.hashCode(this._minx))+$.hashCode(this._maxx))+$.hashCode(this._miny))+$.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[X,J]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,arguments.length===0)this.init();else if(arguments.length===1){if(arguments[0]instanceof $){var o=arguments[0];this.init(o.x,o.x,o.y,o.y)}else if(arguments[0]instanceof g){var s=arguments[0];this.init(s)}}else if(arguments.length===2){var a=arguments[0],f=arguments[1];this.init(a.x,f.x,a.y,f.y)}else if(arguments.length===4){var m=arguments[0],P=arguments[1],S=arguments[2],O=arguments[3];this.init(m,P,S,O)}}},{key:"intersects",value:function(){if(arguments.length===3){var o=arguments[0],s=arguments[1],a=arguments[2];return a.x>=(o.xs.x?o.x:s.x)&&a.y>=(o.ys.y?o.y:s.y)}if(arguments.length===4){var f=arguments[0],m=arguments[1],P=arguments[2],S=arguments[3],O=Math.min(P.x,S.x),Y=Math.max(P.x,S.x),nt=Math.min(f.x,m.x),st=Math.max(f.x,m.x);return!(nt>Y)&&!(stY)&&!(st=this.size())throw new vn;return this.array[a]}},{key:"push",value:function(a){return this.array.push(a),a}},{key:"pop",value:function(){if(this.array.length===0)throw new gn;return this.array.pop()}},{key:"peek",value:function(){if(this.array.length===0)throw new gn;return this.array[this.array.length-1]}},{key:"empty",value:function(){return this.array.length===0}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(a){return this.array.indexOf(a)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}]),s})(qe);function Xt(g,o){return g.interfaces_&&g.interfaces_.indexOf(o)>-1}var xn=(function(){function g(o){n(this,g),this.str=o}return e(g,[{key:"append",value:function(o){this.str+=o}},{key:"setCharAt",value:function(o,s){this.str=this.str.substr(0,o)+s+this.str.substr(o+1)}},{key:"toString",value:function(){return this.str}}]),g})(),_n=(function(){function g(o){n(this,g),this.value=o}return e(g,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(o){return this.valueo?1:0}}],[{key:"compare",value:function(o,s){return os?1:0}},{key:"isNan",value:function(o){return Number.isNaN(o)}},{key:"valueOf",value:function(o){return new g(o)}}]),g})(),ze=(function(){function g(){n(this,g)}return e(g,null,[{key:"isWhitespace",value:function(o){return o<=32&&o>=0||o===127}},{key:"toUpperCase",value:function(o){return o.toUpperCase()}}]),g})(),zt=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"le",value:function(o){return this._hi9?(st=!0,lt="9"):lt="0"+nt,S.append(lt),a=a.subtract(g.valueOf(nt)).multiply(g.TEN),st&&a.selfAdd(g.TEN);var yt=!0,mt=g.magnitude(a._hi);if(mt<0&&Math.abs(mt)>=O-Y&&(yt=!1),!yt)break}return s[0]=f,S.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof g){var o=arguments[0];return this.add(o.negate())}if(typeof arguments[0]=="number"){var s=arguments[0];return this.add(-s)}}},{key:"equals",value:function(){if(arguments.length===1&&arguments[0]instanceof g){var o=arguments[0];return this._hi===o._hi&&this._lo===o._lo}}},{key:"isZero",value:function(){return this._hi===0&&this._lo===0}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof g){var o=arguments[0];return this.isNaN()?this:this.selfAdd(-o._hi,-o._lo)}if(typeof arguments[0]=="number"){var s=arguments[0];return this.isNaN()?this:this.selfAdd(-s,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(o){return this.le(o)?this:o}},{key:"selfDivide",value:function(){if(arguments.length===1){if(arguments[0]instanceof g){var o=arguments[0];return this.selfDivide(o._hi,o._lo)}if(typeof arguments[0]=="number"){var s=arguments[0];return this.selfDivide(s,0)}}else if(arguments.length===2){var a=arguments[0],f=arguments[1],m=null,P=null,S=null,O=null,Y=null,nt=null,st=null,lt=null;return Y=this._hi/a,lt=(m=(nt=g.SPLIT*Y)-(m=nt-Y))*(S=(lt=g.SPLIT*a)-(S=lt-a))-(st=Y*a)+m*(O=a-S)+(P=Y-m)*S+P*O,lt=Y+(nt=(this._hi-st-lt+this._lo-Y*f)/a),this._hi=lt,this._lo=Y-lt+nt,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof g){var o=arguments[0],s=null,a=null,f=null,m=null,P=null,S=null,O=null,Y=null;a=(P=this._hi/o._hi)-(s=(S=g.SPLIT*P)-(s=S-P)),Y=s*(f=(Y=g.SPLIT*o._hi)-(f=Y-o._hi))-(O=P*o._hi)+s*(m=o._hi-f)+a*f+a*m;var nt=Y=P+(S=(this._hi-O-Y+this._lo-P*o._lo)/o._hi),st=P-Y+S;return new g(nt,st)}if(typeof arguments[0]=="number"){var lt=arguments[0];return E.isNaN(lt)?g.createNaN():g.copy(this).selfDivide(lt,0)}}},{key:"ge",value:function(o){return this._hi>o._hi||this._hi===o._hi&&this._lo>=o._lo}},{key:"pow",value:function(o){if(o===0)return g.valueOf(1);var s=new g(this),a=g.valueOf(1),f=Math.abs(o);if(f>1)for(;f>0;)f%2==1&&a.selfMultiply(s),(f/=2)>0&&(s=s.sqr());else a=s;return o<0?a.reciprocal():a}},{key:"ceil",value:function(){if(this.isNaN())return g.NaN;var o=Math.ceil(this._hi),s=0;return o===this._hi&&(s=Math.ceil(this._lo)),new g(o,s)}},{key:"compareTo",value:function(o){var s=o;return this._his._hi?1:this._los._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof g){var o=arguments[0];return this.init(o),this}if(typeof arguments[0]=="number"){var s=arguments[0];return this.init(s),this}}},{key:"max",value:function(o){return this.ge(o)?this:o}},{key:"sqrt",value:function(){if(this.isZero())return g.valueOf(0);if(this.isNegative())return g.NaN;var o=1/Math.sqrt(this._hi),s=this._hi*o,a=g.valueOf(s),f=this.subtract(a.sqr())._hi*(.5*o);return a.add(f)}},{key:"selfAdd",value:function(){if(arguments.length===1){if(arguments[0]instanceof g){var o=arguments[0];return this.selfAdd(o._hi,o._lo)}if(typeof arguments[0]=="number"){var s=arguments[0],a=null,f=null,m=null,P=null,S=null,O=null;return P=(m=this._hi+s)-(S=m-this._hi),f=(O=(P=s-S+(this._hi-P))+this._lo)+(m-(a=m+O)),this._hi=a+f,this._lo=f+(a-this._hi),this}}else if(arguments.length===2){var Y=arguments[0],nt=arguments[1],st=null,lt=null,yt=null,mt=null,Bt=null,Jt=null,Zt=null;mt=this._hi+Y,lt=this._lo+nt,Bt=mt-(Jt=mt-this._hi),yt=lt-(Zt=lt-this._lo);var de=(st=mt+(Jt=(Bt=Y-Jt+(this._hi-Bt))+lt))+(Jt=(yt=nt-Zt+(this._lo-yt))+(Jt+(mt-st))),Ie=Jt+(st-de);return this._hi=de,this._lo=Ie,this}}},{key:"selfMultiply",value:function(){if(arguments.length===1){if(arguments[0]instanceof g){var o=arguments[0];return this.selfMultiply(o._hi,o._lo)}if(typeof arguments[0]=="number"){var s=arguments[0];return this.selfMultiply(s,0)}}else if(arguments.length===2){var a=arguments[0],f=arguments[1],m=null,P=null,S=null,O=null,Y=null,nt=null;m=(Y=g.SPLIT*this._hi)-this._hi,nt=g.SPLIT*a,m=Y-m,P=this._hi-m,S=nt-a;var st=(Y=this._hi*a)+(nt=m*(S=nt-S)-Y+m*(O=a-S)+P*S+P*O+(this._hi*f+this._lo*a)),lt=nt+(m=Y-st);return this._hi=st,this._lo=lt,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return g.NaN;var o=Math.floor(this._hi),s=0;return o===this._hi&&(s=Math.floor(this._lo)),new g(o,s)}},{key:"negate",value:function(){return this.isNaN()?this:new g(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(o){if(o instanceof CloneNotSupportedException)return null;throw o}}},{key:"multiply",value:function(){if(arguments[0]instanceof g){var o=arguments[0];return o.isNaN()?g.createNaN():g.copy(this).selfMultiply(o)}if(typeof arguments[0]=="number"){var s=arguments[0];return E.isNaN(s)?g.createNaN():g.copy(this).selfMultiply(s,0)}}},{key:"isNaN",value:function(){return E.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var o=g.magnitude(this._hi);return o>=-3&&o<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var o=this.getSpecialNumberString();if(o!==null)return o;var s=new Array(1).fill(null),a=this.extractSignificantDigits(!0,s),f=s[0]+1,m=a;if(a.charAt(0)===".")m="0"+a;else if(f<0)m="0."+g.stringOfChar("0",-f)+a;else if(a.indexOf(".")===-1){var P=f-a.length;m=a+g.stringOfChar("0",P)+".0"}return this.isNegative()?"-"+m:m}},{key:"reciprocal",value:function(){var o,s,a,f,m=null,P=null,S=null,O=null;o=(a=1/this._hi)-(m=(S=g.SPLIT*a)-(m=S-a)),P=(O=g.SPLIT*this._hi)-this._hi;var Y=a+(S=(1-(f=a*this._hi)-(O=m*(P=O-P)-f+m*(s=this._hi-P)+o*P+o*s)-a*this._lo)/this._hi);return new g(Y,a-Y+S)}},{key:"toSciNotation",value:function(){if(this.isZero())return g.SCI_NOT_ZERO;var o=this.getSpecialNumberString();if(o!==null)return o;var s=new Array(1).fill(null),a=this.extractSignificantDigits(!1,s),f=g.SCI_NOT_EXPONENT_CHAR+s[0];if(a.charAt(0)==="0")throw new IllegalStateException("Found leading zero: "+a);var m="";a.length>1&&(m=a.substring(1));var P=a.charAt(0)+"."+m;return this.isNegative()?"-"+P+f:P+f}},{key:"abs",value:function(){return this.isNaN()?g.NaN:this.isNegative()?this.negate():new g(this)}},{key:"isPositive",value:function(){return this._hi>0||this._hi===0&&this._lo>0}},{key:"lt",value:function(o){return this._hio._hi||this._hi===o._hi&&this._lo>o._lo}},{key:"isNegative",value:function(){return this._hi<0||this._hi===0&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?g.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[J,X,G]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,arguments.length===0)this.init(0);else if(arguments.length===1){if(typeof arguments[0]=="number"){var o=arguments[0];this.init(o)}else if(arguments[0]instanceof g){var s=arguments[0];this.init(s)}else if(typeof arguments[0]=="string"){var a=arguments[0];g.constructor_.call(this,g.parse(a))}}else if(arguments.length===2){var f=arguments[0],m=arguments[1];this.init(f,m)}}},{key:"determinant",value:function(){if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var o=arguments[0],s=arguments[1],a=arguments[2],f=arguments[3];return g.determinant(g.valueOf(o),g.valueOf(s),g.valueOf(a),g.valueOf(f))}if(arguments[3]instanceof g&&arguments[2]instanceof g&&arguments[0]instanceof g&&arguments[1]instanceof g){var m=arguments[0],P=arguments[1],S=arguments[2],O=arguments[3],Y=m.multiply(O).selfSubtract(P.multiply(S));return Y}}},{key:"sqr",value:function(o){return g.valueOf(o).selfMultiply(o)}},{key:"valueOf",value:function(){if(typeof arguments[0]=="string"){var o=arguments[0];return g.parse(o)}if(typeof arguments[0]=="number"){var s=arguments[0];return new g(s)}}},{key:"sqrt",value:function(o){return g.valueOf(o).sqrt()}},{key:"parse",value:function(o){for(var s=0,a=o.length;ze.isWhitespace(o.charAt(s));)s++;var f=!1;if(s=a);){var st=o.charAt(s);if(s++,ze.isDigit(st)){var lt=st-"0";P.selfMultiply(g.TEN),P.selfAdd(lt),S++}else{if(st!=="."){if(st==="e"||st==="E"){var yt=o.substring(s);try{Y=_n.parseInt(yt)}catch(de){throw de instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+yt+" in string "+o):de}break}throw new NumberFormatException("Unexpected character '"+st+"' at position "+s+" in string "+o)}O=S,nt=!0}}var mt=P;nt||(O=S);var Bt=S-O-Y;if(Bt===0)mt=P;else if(Bt>0){var Jt=g.TEN.pow(Bt);mt=P.divide(Jt)}else if(Bt<0){var Zt=g.TEN.pow(-Bt);mt=P.multiply(Zt)}return f?mt.negate():mt}},{key:"createNaN",value:function(){return new g(E.NaN,E.NaN)}},{key:"copy",value:function(o){return new g(o)}},{key:"magnitude",value:function(o){var s=Math.abs(o),a=Math.log(s)/Math.log(10),f=Math.trunc(Math.floor(a));return 10*Math.pow(10,f)<=s&&(f+=1),f}},{key:"stringOfChar",value:function(o,s){for(var a=new xn,f=0;f0){if(P<=0)return g.signum(S);f=m+P}else{if(!(m<0)||P>=0)return g.signum(S);f=-m-P}var O=g.DP_SAFE_EPSILON*f;return S>=O||-S>=O?g.signum(S):2}},{key:"signum",value:function(o){return o>0?1:o<0?-1:0}}]),g})();ae.DP_SAFE_EPSILON=1e-15;var bt=(function(){function g(){n(this,g)}return e(g,[{key:"getM",value:function(o){if(this.hasM()){var s=this.getDimension()-this.getMeasures();return this.getOrdinate(o,s)}return E.NaN}},{key:"setOrdinate",value:function(o,s,a){}},{key:"getZ",value:function(o){return this.hasZ()?this.getOrdinate(o,2):E.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(o,s){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(o){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(o){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(o){}},{key:"copy",value:function(){}},{key:"getY",value:function(o){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[G]}}]),g})();bt.X=0,bt.Y=1,bt.Z=2,bt.M=3;var Rt=(function(){function g(){n(this,g)}return e(g,null,[{key:"index",value:function(o,s,a){return ae.orientationIndex(o,s,a)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var o=arguments[0],s=o.length-1;if(s<3)throw new q("Ring has fewer than 4 points, so orientation cannot be determined");for(var a=o[0],f=0,m=1;m<=s;m++){var P=o[m];P.y>a.y&&(a=P,f=m)}var S=f;do(S-=1)<0&&(S=s);while(o[S].equals2D(a)&&S!==f);var O=f;do O=(O+1)%s;while(o[O].equals2D(a)&&O!==f);var Y=o[S],nt=o[O];if(Y.equals2D(a)||nt.equals2D(a)||Y.equals2D(nt))return!1;var st=g.index(Y,a,nt),lt=null;return lt=st===0?Y.x>nt.x:st>0,lt}if(Xt(arguments[0],bt)){var yt=arguments[0],mt=yt.size()-1;if(mt<3)throw new q("Ring has fewer than 4 points, so orientation cannot be determined");for(var Bt=yt.getCoordinate(0),Jt=0,Zt=1;Zt<=mt;Zt++){var de=yt.getCoordinate(Zt);de.y>Bt.y&&(Bt=de,Jt=Zt)}var Ie=null,$e=Jt;do($e-=1)<0&&($e=mt),Ie=yt.getCoordinate($e);while(Ie.equals2D(Bt)&&$e!==Jt);var Sn=null,Yn=Jt;do Yn=(Yn+1)%mt,Sn=yt.getCoordinate(Yn);while(Sn.equals2D(Bt)&&Yn!==Jt);if(Ie.equals2D(Bt)||Sn.equals2D(Bt)||Ie.equals2D(Sn))return!1;var dr=g.index(Ie,Bt,Sn);return dr===0?Ie.x>Sn.x:dr>0}}}]),g})();Rt.CLOCKWISE=-1,Rt.RIGHT=Rt.CLOCKWISE,Rt.COUNTERCLOCKWISE=1,Rt.LEFT=Rt.COUNTERCLOCKWISE,Rt.COLLINEAR=0,Rt.STRAIGHT=Rt.COLLINEAR;var Pe=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(o,s){var a=this.getRightmostSideOfSegment(o,s);return a<0&&(a=this.getRightmostSideOfSegment(o,s-1)),a<0&&(this._minCoord=null,this.checkForRightmostCoordinate(o)),a}},{key:"findRightmostEdgeAtVertex",value:function(){var o=this._minDe.getEdge().getCoordinates();j.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&a.y>this._minCoord.y&&f===Rt.CLOCKWISE)&&(m=!0),m&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(o,s){var a=o.getEdge().getCoordinates();if(s<0||s+1>=a.length||a[s].y===a[s+1].y)return-1;var f=ft.LEFT;return a[s].ythis._minCoord.x)&&(this._minDe=o,this._minIndex=a,this._minCoord=s[a])}},{key:"findRightmostEdgeAtNode",value:function(){var o=this._minDe.getNode().getEdges();this._minDe=o.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(o){for(var s=o.iterator();s.hasNext();){var a=s.next();a.isForward()&&this.checkForRightmostCoordinate(a)}j.isTrue(this._minIndex!==0||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),this._minIndex===0?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===ft.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),g})(),Fe=(function(g){r(s,g);var o=y(s);function s(a,f){var m;return n(this,s),(m=o.call(this,f?a+" [ "+f+" ]":a)).pt=f?new $(f):void 0,m.name=Object.keys({TopologyException:s})[0],m}return e(s,[{key:"getCoordinate",value:function(){return this.pt}}]),s})(z),Pn=(function(){function g(){n(this,g),this.array=[]}return e(g,[{key:"addLast",value:function(o){this.array.push(o)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return this.array.length===0}}]),g})(),qt=(function(g,o){r(a,g);var s=y(a);function a(f){var m;return n(this,a),(m=s.call(this)).array=[],f instanceof vt&&m.addAll(f),m}return e(a,[{key:"interfaces_",get:function(){return[qe,vt]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(f){return arguments.length===1?this.array.push(f):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(f){var m,P=M(f);try{for(P.s();!(m=P.n()).done;){var S=m.value;this.array.push(S)}}catch(O){P.e(O)}finally{P.f()}}},{key:"set",value:function(f,m){var P=this.array[f];return this.array[f]=m,P}},{key:"iterator",value:function(){return new $n(this)}},{key:"get",value:function(f){if(f<0||f>=this.size())throw new vn;return this.array[f]}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"sort",value:function(f){f?this.array.sort((function(m,P){return f.compare(m,P)})):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(f){for(var m=0,P=this.array.length;m=1&&s.getDepth(ft.LEFT)<=0&&!s.isInteriorAreaEdge()&&s.setInResult(!0)}}},{key:"computeDepths",value:function(o){var s=new Tt,a=new Pn,f=o.getNode();for(a.addLast(f),s.add(f),o.setVisited(!0);!a.isEmpty();){var m=a.removeFirst();s.add(m),this.computeNodeDepth(m);for(var P=m.getEdges().iterator();P.hasNext();){var S=P.next().getSym();if(!S.isVisited()){var O=S.getNode();s.contains(O)||(a.addLast(O),s.add(O))}}}}},{key:"compareTo",value:function(o){var s=o;return this._rightMostCoord.xs._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(this._env===null){for(var o=new ct,s=this._dirEdgeList.iterator();s.hasNext();)for(var a=s.next().getEdge().getCoordinates(),f=0;fs.x?o.x:s.x,O=o.y>s.y?o.y:s.y,Y=a.xf.x?a.x:f.x,lt=a.y>f.y?a.y:f.y,yt=((m>Y?m:Y)+(Snt?P:nt)+(Oa?a:o}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var f=arguments[0],m=arguments[1],P=arguments[2];return fP?P:f}}},{key:"wrap",value:function(o,s){return o<0?s- -o%s:o%s}},{key:"max",value:function(){if(arguments.length===3){var o=arguments[0],s=arguments[1],a=arguments[2],f=o;return s>f&&(f=s),a>f&&(f=a),f}if(arguments.length===4){var m=arguments[0],P=arguments[1],S=arguments[2],O=arguments[3],Y=m;return P>Y&&(Y=P),S>Y&&(Y=S),O>Y&&(Y=O),Y}}},{key:"average",value:function(o,s){return(o+s)/2}}]),g})();Ke.LOG_10=Math.log(10);var Oe=(function(){function g(){n(this,g)}return e(g,null,[{key:"segmentToSegment",value:function(o,s,a,f){if(o.equals(s))return g.pointToSegment(o,a,f);if(a.equals(f))return g.pointToSegment(f,o,s);var m=!1;if(ct.intersects(o,s,a,f)){var P=(s.x-o.x)*(f.y-a.y)-(s.y-o.y)*(f.x-a.x);if(P===0)m=!0;else{var S=(o.y-a.y)*(f.x-a.x)-(o.x-a.x)*(f.y-a.y),O=((o.y-a.y)*(s.x-o.x)-(o.x-a.x)*(s.y-o.y))/P,Y=S/P;(Y<0||Y>1||O<0||O>1)&&(m=!0)}}else m=!0;return m?Ke.min(g.pointToSegment(o,a,f),g.pointToSegment(s,a,f),g.pointToSegment(a,o,s),g.pointToSegment(f,o,s)):0}},{key:"pointToSegment",value:function(o,s,a){if(s.x===a.x&&s.y===a.y)return o.distance(s);var f=(a.x-s.x)*(a.x-s.x)+(a.y-s.y)*(a.y-s.y),m=((o.x-s.x)*(a.x-s.x)+(o.y-s.y)*(a.y-s.y))/f;if(m<=0)return o.distance(s);if(m>=1)return o.distance(a);var P=((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/f;return Math.abs(P)*Math.sqrt(f)}},{key:"pointToLinePerpendicular",value:function(o,s,a){var f=(a.x-s.x)*(a.x-s.x)+(a.y-s.y)*(a.y-s.y),m=((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/f;return Math.abs(m)*Math.sqrt(f)}},{key:"pointToSegmentString",value:function(o,s){if(s.length===0)throw new q("Line array must contain at least one vertex");for(var a=o.distance(s[0]),f=0;f0)&&(P=O,m=S)}return m}}},{key:"extend",value:function(o,s,a){var f=o.create(a,s.getDimension()),m=s.size();if(g.copy(s,0,f,0,m),m>0)for(var P=m;P0)&&(s=f)}return s}}]),g})(),xt=(function(){function g(){n(this,g)}return e(g,null,[{key:"toDimensionSymbol",value:function(o){switch(o){case g.FALSE:return g.SYM_FALSE;case g.TRUE:return g.SYM_TRUE;case g.DONTCARE:return g.SYM_DONTCARE;case g.P:return g.SYM_P;case g.L:return g.SYM_L;case g.A:return g.SYM_A}throw new q("Unknown dimension value: "+o)}},{key:"toDimensionValue",value:function(o){switch(ze.toUpperCase(o)){case g.SYM_FALSE:return g.FALSE;case g.SYM_TRUE:return g.TRUE;case g.SYM_DONTCARE:return g.DONTCARE;case g.SYM_P:return g.P;case g.SYM_L:return g.L;case g.SYM_A:return g.A}throw new q("Unknown dimension symbol: "+o)}}]),g})();xt.P=0,xt.L=1,xt.A=2,xt.FALSE=-1,xt.TRUE=-2,xt.DONTCARE=-3,xt.SYM_FALSE="F",xt.SYM_TRUE="T",xt.SYM_DONTCARE="*",xt.SYM_P="0",xt.SYM_L="1",xt.SYM_A="2";var nn=(function(){function g(){n(this,g)}return e(g,[{key:"filter",value:function(o){}}]),g})(),gr=(function(){function g(){n(this,g)}return e(g,[{key:"filter",value:function(o,s){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),g})(),Mr=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new ct:this._points.expandEnvelope(new ct)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new s(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof ut){var a=arguments[0],f=arguments[1];if(!this.isEquivalentClass(a))return!1;var m=a;if(this._points.size()!==m._points.size())return!1;for(var P=0;P0){var m=this._points.copy();Qn.reverse(m),this._points=m}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?xt.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var a=this._points.copy();return Qn.reverse(a),this.getFactory().createLineString(a)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return ut.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return pa.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(arguments.length===1){for(var a=arguments[0],f=a,m=0,P=0;m= 2)");this._points=a}},{key:"isCoordinate",value:function(a){for(var f=0;f=1&&this.getCoordinateSequence().size()= 4)")}},{key:"getGeometryType",value:function(){return ut.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var a=arguments[0],f=arguments[1];Mr.constructor_.call(this,a,f),this.validateConstruction()}}]),s})(Mr);U.MINIMUM_VALID_SIZE=4;var Z=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"setOrdinate",value:function(a,f){switch(a){case s.X:this.x=f;break;case s.Y:this.y=f;break;default:throw new q("Invalid ordinate index: "+a)}}},{key:"getZ",value:function(){return $.NULL_ORDINATE}},{key:"getOrdinate",value:function(a){switch(a){case s.X:return this.x;case s.Y:return this.y}throw new q("Invalid ordinate index: "+a)}},{key:"setZ",value:function(a){throw new q("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(a){this.x=a.x,this.y=a.y,this.z=a.getZ()}}],[{key:"constructor_",value:function(){if(arguments.length===0)$.constructor_.call(this);else if(arguments.length===1){if(arguments[0]instanceof s){var a=arguments[0];$.constructor_.call(this,a.x,a.y)}else if(arguments[0]instanceof $){var f=arguments[0];$.constructor_.call(this,f.x,f.y)}}else if(arguments.length===2){var m=arguments[0],P=arguments[1];$.constructor_.call(this,m,P,$.NULL_ORDINATE)}}}]),s})($);Z.X=0,Z.Y=1,Z.Z=-1,Z.M=-1;var Q=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(a,f){switch(a){case s.X:this.x=f;break;case s.Y:this.y=f;break;case s.M:this._m=f;break;default:throw new q("Invalid ordinate index: "+a)}}},{key:"setM",value:function(a){this._m=a}},{key:"getZ",value:function(){return $.NULL_ORDINATE}},{key:"getOrdinate",value:function(a){switch(a){case s.X:return this.x;case s.Y:return this.y;case s.M:return this._m}throw new q("Invalid ordinate index: "+a)}},{key:"setZ",value:function(a){throw new q("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(a){this.x=a.x,this.y=a.y,this.z=a.getZ(),this._m=a.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)$.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof s){var a=arguments[0];$.constructor_.call(this,a.x,a.y),this._m=a._m}else if(arguments[0]instanceof $){var f=arguments[0];$.constructor_.call(this,f.x,f.y),this._m=this.getM()}}else if(arguments.length===3){var m=arguments[0],P=arguments[1],S=arguments[2];$.constructor_.call(this,m,P,$.NULL_ORDINATE),this._m=S}}}]),s})($);Q.X=0,Q.Y=1,Q.Z=-1,Q.M=2;var it=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(a,f){switch(a){case $.X:this.x=f;break;case $.Y:this.y=f;break;case $.Z:this.z=f;break;case $.M:this._m=f;break;default:throw new q("Invalid ordinate index: "+a)}}},{key:"setM",value:function(a){this._m=a}},{key:"getOrdinate",value:function(a){switch(a){case $.X:return this.x;case $.Y:return this.y;case $.Z:return this.getZ();case $.M:return this.getM()}throw new q("Invalid ordinate index: "+a)}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(a){this.x=a.x,this.y=a.y,this.z=a.getZ(),this._m=a.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)$.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof s){var a=arguments[0];$.constructor_.call(this,a),this._m=a._m}else if(arguments[0]instanceof $){var f=arguments[0];$.constructor_.call(this,f),this._m=this.getM()}}else if(arguments.length===4){var m=arguments[0],P=arguments[1],S=arguments[2],O=arguments[3];$.constructor_.call(this,m,P,S),this._m=O}}}]),s})($),at=(function(){function g(){n(this,g)}return e(g,null,[{key:"measures",value:function(o){return o instanceof Z?0:o instanceof Q||o instanceof it?1:0}},{key:"dimension",value:function(o){return o instanceof Z?2:o instanceof Q?3:o instanceof it?4:3}},{key:"create",value:function(){if(arguments.length===1){var o=arguments[0];return g.create(o,0)}if(arguments.length===2){var s=arguments[0],a=arguments[1];return s===2?new Z:s===3&&a===0?new $:s===3&&a===1?new Q:s===4&&a===1?new it:new $}}}]),g})(),gt=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"getCoordinate",value:function(a){return this.get(a)}},{key:"addAll",value:function(){if(arguments.length===2&&typeof arguments[1]=="boolean"&&Xt(arguments[0],vt)){for(var a=arguments[0],f=arguments[1],m=!1,P=a.iterator();P.hasNext();)this.add(P.next(),f),m=!0;return m}return v(i(s.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var a=v(i(s.prototype),"clone",this).call(this),f=0;f=1){var O=this.get(this.size()-1);if(O.equals2D(P))return null}v(i(s.prototype),"add",this).call(this,P)}else if(arguments[0]instanceof Object&&typeof arguments[1]=="boolean"){var Y=arguments[0],nt=arguments[1];return this.add(Y,nt),!0}}else if(arguments.length===3){if(typeof arguments[2]=="boolean"&&arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var st=arguments[0],lt=arguments[1],yt=arguments[2];if(yt)for(var mt=0;mt=0;Bt--)this.add(st[Bt],lt);return!0}if(typeof arguments[2]=="boolean"&&Number.isInteger(arguments[0])&&arguments[1]instanceof $){var Jt=arguments[0],Zt=arguments[1],de=arguments[2];if(!de){var Ie=this.size();if(Ie>0){if(Jt>0){var $e=this.get(Jt-1);if($e.equals2D(Zt))return null}if(Jtao&&(lo=-1);for(var Si=$r;Si!==ao;Si+=lo)this.add(Yn[Si],dr);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var a=this.get(0).copy();this.add(a,!1)}}}],[{key:"constructor_",value:function(){if(arguments.length!==0){if(arguments.length===1){var a=arguments[0];this.ensureCapacity(a.length),this.add(a,!0)}else if(arguments.length===2){var f=arguments[0],m=arguments[1];this.ensureCapacity(f.length),this.add(f,m)}}}}]),s})(qt);gt.coordArrayType=new Array(0).fill(null);var dt=(function(){function g(){n(this,g)}return e(g,null,[{key:"isRing",value:function(o){return!(o.length<4)&&!!o[0].equals2D(o[o.length-1])}},{key:"ptNotInList",value:function(o,s){for(var a=0;a=o?s:[]}},{key:"indexOf",value:function(o,s){for(var a=0;a0)&&(s=o[a]);return s}},{key:"extract",value:function(o,s,a){s=Ke.clamp(s,0,o.length);var f=(a=Ke.clamp(a,-1,o.length))-s+1;a<0&&(f=0),s>=o.length&&(f=0),af.length)return 1;if(a.length===0)return 0;var m=dt.compare(a,f);return dt.isEqualReversed(a,f)?0:m}},{key:"OLDcompare",value:function(o,s){var a=o,f=s;if(a.lengthf.length)return 1;if(a.length===0)return 0;for(var m=dt.increasingDirection(a),P=dt.increasingDirection(f),S=m>0?0:a.length-1,O=P>0?0:a.length-1,Y=0;Y0){var o=new Re(17*this._coordinates.length);o.append("("),o.append(this._coordinates[0]);for(var s=1;s3&&(f=3),f<2&&(f=2),new Gt(a,f)}if(arguments.length===3){var m=arguments[0],P=arguments[1],S=arguments[2],O=P-S;return S>1&&(S=1),O>3&&(O=3),O<2&&(O=2),new Gt(m,O+S,S)}}}},{key:"interfaces_",get:function(){return[no,J]}}],[{key:"instance",value:function(){return g.instanceObject}}]),g})();Je.instanceObject=new Je;var bn=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"copyInternal",value:function(){for(var a=new Array(this._geometries.length).fill(null),f=0;f=0?o:s}}]),g})(),vi=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"readResolve",value:function(){return g.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[J]}}],[{key:"constructor_",value:function(){this._name=null;var o=arguments[0];this._name=o,g.nameToTypeMap.put(o,this)}}]),g})();vi.nameToTypeMap=new Wr,on.Type=vi,on.FIXED=new vi("FIXED"),on.FLOATING=new vi("FLOATING"),on.FLOATING_SINGLE=new vi("FLOATING SINGLE"),on.maximumPreciseValue=9007199254740992;var ya=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"copyInternal",value:function(){for(var a=new Array(this._geometries.length).fill(null),f=0;f1){if(O instanceof yi)return this.createMultiPolygon(g.toPolygonArray(o));if(O instanceof Mr)return this.createMultiLineString(g.toLineStringArray(o));if(O instanceof di)return this.createMultiPoint(g.toPointArray(o));j.shouldNeverReachHere("Unhandled geometry type: "+O.getGeometryType())}return O}},{key:"createMultiPointFromCoords",value:function(o){return this.createMultiPoint(o!==null?this.getCoordinateSequenceFactory().create(o):null)}},{key:"createPoint",value:function(){if(arguments.length===0)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof $){var o=arguments[0];return this.createPoint(o!==null?this.getCoordinateSequenceFactory().create([o]):null)}if(Xt(arguments[0],bt)){var s=arguments[0];return new di(s,this)}}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(arguments.length===0)return this.createPolygon(null,null);if(arguments.length===1){if(Xt(arguments[0],bt)){var o=arguments[0];return this.createPolygon(this.createLinearRing(o))}if(arguments[0]instanceof Array){var s=arguments[0];return this.createPolygon(this.createLinearRing(s))}if(arguments[0]instanceof U){var a=arguments[0];return this.createPolygon(a,null)}}else if(arguments.length===2){var f=arguments[0],m=arguments[1];return new yi(f,m,this)}}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){if(arguments.length===0)return new rn(null,this);if(arguments.length===1){var o=arguments[0];return new rn(o,this)}}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(arguments.length===0)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var o=arguments[0];return this.createLinearRing(o!==null?this.getCoordinateSequenceFactory().create(o):null)}if(Xt(arguments[0],bt)){var s=arguments[0];return new U(s,this)}}}},{key:"createMultiPolygon",value:function(){if(arguments.length===0)return new bn(null,this);if(arguments.length===1){var o=arguments[0];return new bn(o,this)}}},{key:"createMultiPoint",value:function(){if(arguments.length===0)return new io(null,this);if(arguments.length===1){if(arguments[0]instanceof Array){var o=arguments[0];return new io(o,this)}if(Xt(arguments[0],bt)){var s=arguments[0];if(s===null)return this.createMultiPoint(new Array(0).fill(null));for(var a=new Array(s.size()).fill(null),f=0;f="a"&&o<="z"||o>="A"&&o<="Z"}},{key:"isNumeric_",value:function(o,s){return o>="0"&&o<="9"||o=="."&&!(s!==void 0&&s)}},{key:"isWhiteSpace_",value:function(o){return o==" "||o==" "||o=="\r"||o==` `}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var o,s=this.nextChar_(),a=this.index_,f=s;if(s=="(")o=pr;else if(s==",")o=_i;else if(s==")")o=Cr;else if(this.isNumeric_(s)||s=="-")o=Pc,f=this.readNumber_();else if(this.isAlpha_(s))o=as,f=this.readText_();else{if(this.isWhiteSpace_(s))return this.nextToken();if(s!=="")throw new Error("Unexpected character: "+s);o=fd}return{position:a,value:f,type:o}}},{key:"readNumber_",value:function(){var o,s=this.index_,a=!1,f=!1;do o=="."?a=!0:o!="e"&&o!="E"||(f=!0),o=this.nextChar_();while(this.isNumeric_(o,a)||!f&&(o=="e"||o=="E")||f&&(o=="-"||o=="+"));return parseFloat(this.wkt.substring(s,this.index_--))}},{key:"readText_",value:function(){var o,s=this.index_;do o=this.nextChar_();while(this.isAlpha_(o));return this.wkt.substring(s,this.index_--).toUpperCase()}}]),g})(),pd=(function(){function g(o,s){n(this,g),this.lexer_=o,this.token_,this.layout_=va,this.factory=s}return e(g,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(o){return this.token_.type==o}},{key:"match",value:function(o){var s=this.isTokenType(o);return s&&this.consume_(),s}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var o=va,s=this.token_;if(this.isTokenType(as)){var a=s.value;a==="Z"?o=ad:a==="M"?o=ld:a==="ZM"&&(o=cd),o!==va&&this.consume_()}return o}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(pr)){var o=[];do o.push(this.parseGeometry_());while(this.match(_i));if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(pr)){var o=this.parsePoint_();if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(pr)){var o=this.parsePointList_();if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(pr)){var o=this.parseLineStringTextList_();if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var o;if(this.match(pr)){if(o=this.token_.type==pr?this.parsePointTextList_():this.parsePointList_(),this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(pr)){var o=this.parseLineStringTextList_();if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(pr)){var o=this.parsePolygonTextList_();if(this.match(Cr))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var o=[],s=this.layout_.length,a=0;a1?o.createPolygon(Zt[0],Zt.slice(1)):o.createPolygon(Zt[0])},f=this.token_;if(this.match(as)){var m=f.value;if(this.layout_=this.parseGeometryLayout_(),m=="GEOMETRYCOLLECTION"){var P=this.parseGeometryCollectionText_();return o.createGeometryCollection(P)}switch(m){case"POINT":var S=this.parsePointText_();return S?o.createPoint(c($,_(S))):o.createPoint();case"LINESTRING":var O=this.parseLineStringText_().map(s);return o.createLineString(O);case"LINEARRING":var Y=this.parseLineStringText_().map(s);return o.createLinearRing(Y);case"POLYGON":var nt=this.parsePolygonText_();return nt&&nt.length!==0?a(nt):o.createPolygon();case"MULTIPOINT":var st=this.parseMultiPointText_();if(!st||st.length===0)return o.createMultiPoint();var lt=st.map(s).map((function(Jt){return o.createPoint(Jt)}));return o.createMultiPoint(lt);case"MULTILINESTRING":var yt=this.parseMultiLineStringText_().map((function(Jt){return o.createLineString(Jt.map(s))}));return o.createMultiLineString(yt);case"MULTIPOLYGON":var mt=this.parseMultiPolygonText_();if(!mt||mt.length===0)return o.createMultiPolygon();var Bt=mt.map(a);return o.createMultiPolygon(Bt);default:throw new Error("Invalid geometry type: "+m)}}throw new Error(this.formatErrorMessage_())}}]),g})();function Ec(g){if(g.isEmpty())return"";var o=g.getCoordinate(),s=[o.x,o.y];return o.z===void 0||Number.isNaN(o.z)||s.push(o.z),o.m===void 0||Number.isNaN(o.m)||s.push(o.m),s.join(" ")}function oo(g){for(var o=g.getCoordinates().map((function(m){var P=[m.x,m.y];return m.z===void 0||Number.isNaN(m.z)||P.push(m.z),m.m===void 0||Number.isNaN(m.m)||P.push(m.m),P})),s=[],a=0,f=o.length;a0&&(o+=" "+a),g.isEmpty()?o+" "+_c:o+" ("+s(g)+")"}var dd=(function(){function g(o){n(this,g),this.geometryFactory=o||new xi,this.precisionModel=this.geometryFactory.getPrecisionModel()}return e(g,[{key:"read",value:function(o){var s=new gd(o);return new pd(s,this.geometryFactory).parse()}},{key:"write",value:function(o){return Sc(o)}}]),g})(),xa=(function(){function g(o){n(this,g),this.parser=new dd(o)}return e(g,[{key:"write",value:function(o){return this.parser.write(o)}}],[{key:"toLineString",value:function(o,s){if(arguments.length!==2)throw new Error("Not implemented");return"LINESTRING ( "+o.x+" "+o.y+", "+s.x+" "+s.y+" )"}}]),g})(),Se=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getIndexAlongSegment",value:function(o,s){return this.computeIntLineIndex(),this._intLineIndex[o][s]}},{key:"getTopologySummary",value:function(){var o=new Re;return this.isEndPoint()&&o.append(" endpoint"),this._isProper&&o.append(" proper"),this.isCollinear()&&o.append(" collinear"),o.toString()}},{key:"computeIntersection",value:function(o,s,a,f){this._inputLines[0][0]=o,this._inputLines[0][1]=s,this._inputLines[1][0]=a,this._inputLines[1][1]=f,this._result=this.computeIntersect(o,s,a,f)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(arguments.length===0)this._intLineIndex===null&&(this._intLineIndex=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(arguments.length===1){var o=arguments[0],s=this.getEdgeDistance(o,0),a=this.getEdgeDistance(o,1);s>a?(this._intLineIndex[o][0]=0,this._intLineIndex[o][1]=1):(this._intLineIndex[o][0]=1,this._intLineIndex[o][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(o){this._precisionModel=o}},{key:"isInteriorIntersection",value:function(){if(arguments.length===0)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(arguments.length===1){for(var o=arguments[0],s=0;sm?f:m;else{var S=Math.abs(o.x-s.x),O=Math.abs(o.y-s.y);(P=f>m?S:O)!==0||o.equals(s)||(P=Math.max(S,O))}return j.isTrue(!(P===0&&!o.equals(s)),"Bad distance calculation"),P}},{key:"nonRobustComputeEdgeDistance",value:function(o,s,a){var f=o.x-s.x,m=o.y-s.y,P=Math.sqrt(f*f+m*m);return j.isTrue(!(P===0&&!o.equals(s)),"Invalid distance calculation"),P}}]),g})();Se.DONT_INTERSECT=0,Se.DO_INTERSECT=1,Se.COLLINEAR=2,Se.NO_INTERSECTION=0,Se.POINT_INTERSECTION=1,Se.COLLINEAR_INTERSECTION=2;var jr=(function(g){r(s,g);var o=y(s);function s(){return n(this,s),o.call(this)}return e(s,[{key:"isInSegmentEnvelopes",value:function(a){var f=new ct(this._inputLines[0][0],this._inputLines[0][1]),m=new ct(this._inputLines[1][0],this._inputLines[1][1]);return f.contains(a)&&m.contains(a)}},{key:"computeIntersection",value:function(){if(arguments.length!==3)return v(i(s.prototype),"computeIntersection",this).apply(this,arguments);var a=arguments[0],f=arguments[1],m=arguments[2];if(this._isProper=!1,ct.intersects(f,m,a)&&Rt.index(f,m,a)===0&&Rt.index(m,f,a)===0)return this._isProper=!0,(a.equals(f)||a.equals(m))&&(this._isProper=!1),this._result=Se.POINT_INTERSECTION,null;this._result=Se.NO_INTERSECTION}},{key:"intersection",value:function(a,f,m,P){var S=this.intersectionSafe(a,f,m,P);return this.isInSegmentEnvelopes(S)||(S=new $(s.nearestEndpoint(a,f,m,P))),this._precisionModel!==null&&this._precisionModel.makePrecise(S),S}},{key:"checkDD",value:function(a,f,m,P,S){var O=ae.intersection(a,f,m,P),Y=this.isInSegmentEnvelopes(O);je.out.println("DD in env = "+Y+" --------------------- "+O),S.distance(O)>1e-4&&je.out.println("Distance = "+S.distance(O))}},{key:"intersectionSafe",value:function(a,f,m,P){var S=Lr.intersection(a,f,m,P);return S===null&&(S=s.nearestEndpoint(a,f,m,P)),S}},{key:"computeCollinearIntersection",value:function(a,f,m,P){var S=ct.intersects(a,f,m),O=ct.intersects(a,f,P),Y=ct.intersects(m,P,a),nt=ct.intersects(m,P,f);return S&&O?(this._intPt[0]=m,this._intPt[1]=P,Se.COLLINEAR_INTERSECTION):Y&&nt?(this._intPt[0]=a,this._intPt[1]=f,Se.COLLINEAR_INTERSECTION):S&&Y?(this._intPt[0]=m,this._intPt[1]=a,!m.equals(a)||O||nt?Se.COLLINEAR_INTERSECTION:Se.POINT_INTERSECTION):S&&nt?(this._intPt[0]=m,this._intPt[1]=f,!m.equals(f)||O||Y?Se.COLLINEAR_INTERSECTION:Se.POINT_INTERSECTION):O&&Y?(this._intPt[0]=P,this._intPt[1]=a,!P.equals(a)||S||nt?Se.COLLINEAR_INTERSECTION:Se.POINT_INTERSECTION):O&&nt?(this._intPt[0]=P,this._intPt[1]=f,!P.equals(f)||S||Y?Se.COLLINEAR_INTERSECTION:Se.POINT_INTERSECTION):Se.NO_INTERSECTION}},{key:"computeIntersect",value:function(a,f,m,P){if(this._isProper=!1,!ct.intersects(a,f,m,P))return Se.NO_INTERSECTION;var S=Rt.index(a,f,m),O=Rt.index(a,f,P);if(S>0&&O>0||S<0&&O<0)return Se.NO_INTERSECTION;var Y=Rt.index(m,P,a),nt=Rt.index(m,P,f);return Y>0&&nt>0||Y<0&&nt<0?Se.NO_INTERSECTION:S===0&&O===0&&Y===0&&nt===0?this.computeCollinearIntersection(a,f,m,P):(S===0||O===0||Y===0||nt===0?(this._isProper=!1,a.equals2D(m)||a.equals2D(P)?this._intPt[0]=a:f.equals2D(m)||f.equals2D(P)?this._intPt[0]=f:S===0?this._intPt[0]=new $(m):O===0?this._intPt[0]=new $(P):Y===0?this._intPt[0]=new $(a):nt===0&&(this._intPt[0]=new $(f))):(this._isProper=!0,this._intPt[0]=this.intersection(a,f,m,P)),Se.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(a,f,m,P){var S=a,O=Oe.pointToSegment(a,m,P),Y=Oe.pointToSegment(f,m,P);return Yf&&(a=s.x,f=o.x),this._p.x>=a&&this._p.x<=f&&(this._isPointOnSegment=!0),null}if(o.y>this._p.y&&s.y<=this._p.y||s.y>this._p.y&&o.y<=this._p.y){var m=Rt.index(o,s,this._p);if(m===Rt.COLLINEAR)return this._isPointOnSegment=!0,null;s.ythis.location.length){var s=new Array(3).fill(null);s[ft.ON]=this.location[ft.ON],s[ft.LEFT]=H.NONE,s[ft.RIGHT]=H.NONE,this.location=s}for(var a=0;a1&&o.append(H.toLocationSymbol(this.location[ft.LEFT])),o.append(H.toLocationSymbol(this.location[ft.ON])),this.location.length>1&&o.append(H.toLocationSymbol(this.location[ft.RIGHT])),o.toString()}},{key:"setLocations",value:function(o,s,a){this.location[ft.ON]=o,this.location[ft.LEFT]=s,this.location[ft.RIGHT]=a}},{key:"get",value:function(o){return o1}},{key:"isAnyNull",value:function(){for(var o=0;othis._maxNodeDegree&&(this._maxNodeDegree=s),o=this.getNext(o)}while(o!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(o,s,a){var f=o.getCoordinates();if(s){var m=1;a&&(m=0);for(var P=m;P=0;O--)this._pts.add(f[O])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var o=this._startDe;do o.getEdge().setInResult(!0),o=o.getNext();while(o!==this._startDe)}},{key:"containsPoint",value:function(o){var s=this.getLinearRing();if(!s.getEnvelopeInternal().contains(o)||!_a.isInRing(o,s.getCoordinates()))return!1;for(var a=this._holes.iterator();a.hasNext();)if(a.next().containsPoint(o))return!1;return!0}},{key:"addHole",value:function(o){this._holes.add(o)}},{key:"isShell",value:function(){return this._shell===null}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(arguments.length===1){var o=arguments[0];this.mergeLabel(o,0),this.mergeLabel(o,1)}else if(arguments.length===2){var s=arguments[0],a=arguments[1],f=s.getLocation(a,ft.RIGHT);if(f===H.NONE)return null;if(this._label.getLocation(a)===H.NONE)return this._label.setLocation(a,f),null}}},{key:"setShell",value:function(o){this._shell=o,o!==null&&o.addHole(this)}},{key:"toPolygon",value:function(o){for(var s=new Array(this._holes.size()).fill(null),a=0;a=2,"found partial label"),this.computeIM(o)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this._label=o}}}}]),g})(),cs=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"isIncidentEdgeInResult",value:function(){for(var a=this.getEdges().getEdges().iterator();a.hasNext();)if(a.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(a){a.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(a){}},{key:"computeMergedLocation",value:function(a,f){var m=H.NONE;if(m=this._label.getLocation(f),!a.isNull(f)){var P=a.getLocation(f);m!==H.BOUNDARY&&(m=P)}return m}},{key:"setLabel",value:function(){if(arguments.length!==2||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return v(i(s.prototype),"setLabel",this).apply(this,arguments);var a=arguments[0],f=arguments[1];this._label===null?this._label=new Cn(a,f):this._label.setLocation(a,f)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof s){var a=arguments[0];this.mergeLabel(a._label)}else if(arguments[0]instanceof Cn)for(var f=arguments[0],m=0;m<2;m++){var P=this.computeMergedLocation(f,m),S=this._label.getLocation(m);S===H.NONE&&this._label.setLocation(m,P)}}},{key:"add",value:function(a){this._edges.insert(a),a.setNode(this)}},{key:"setLabelBoundary",value:function(a){if(this._label===null)return null;var f=H.NONE;this._label!==null&&(f=this._label.getLocation(a));var m=null;switch(f){case H.BOUNDARY:m=H.INTERIOR;break;case H.INTERIOR:default:m=H.BOUNDARY}this._label.setLocation(a,m)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var a=arguments[0],f=arguments[1];this._coord=a,this._edges=f,this._label=new Cn(0,H.NONE)}}]),s})(kc),_d=(function(g){r(s,g);var o=y(s);function s(){return n(this,s),o.apply(this,arguments)}return s})(we);function Ic(g){return g==null?0:g.color}function ge(g){return g==null?null:g.parent}function er(g,o){g!==null&&(g.color=o)}function Pa(g){return g==null?null:g.left}function Lc(g){return g==null?null:g.right}var so=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),(a=o.call(this)).root_=null,a.size_=0,a}return e(s,[{key:"get",value:function(a){for(var f=this.root_;f!==null;){var m=a.compareTo(f.key);if(m<0)f=f.left;else{if(!(m>0))return f.value;f=f.right}}return null}},{key:"put",value:function(a,f){if(this.root_===null)return this.root_={key:a,value:f,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var m,P,S=this.root_;do if(m=S,(P=a.compareTo(S.key))<0)S=S.left;else{if(!(P>0)){var O=S.value;return S.value=f,O}S=S.right}while(S!==null);var Y={key:a,left:null,right:null,value:f,parent:m,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return P<0?m.left=Y:m.right=Y,this.fixAfterInsertion(Y),this.size_++,null}},{key:"fixAfterInsertion",value:function(a){var f;for(a.color=1;a!=null&&a!==this.root_&&a.parent.color===1;)ge(a)===Pa(ge(ge(a)))?Ic(f=Lc(ge(ge(a))))===1?(er(ge(a),0),er(f,0),er(ge(ge(a)),1),a=ge(ge(a))):(a===Lc(ge(a))&&(a=ge(a),this.rotateLeft(a)),er(ge(a),0),er(ge(ge(a)),1),this.rotateRight(ge(ge(a)))):Ic(f=Pa(ge(ge(a))))===1?(er(ge(a),0),er(f,0),er(ge(ge(a)),1),a=ge(ge(a))):(a===Pa(ge(a))&&(a=ge(a),this.rotateRight(a)),er(ge(a),0),er(ge(ge(a)),1),this.rotateLeft(ge(ge(a))));this.root_.color=0}},{key:"values",value:function(){var a=new qt,f=this.getFirstEntry();if(f!==null)for(a.add(f.value);(f=s.successor(f))!==null;)a.add(f.value);return a}},{key:"entrySet",value:function(){var a=new Tt,f=this.getFirstEntry();if(f!==null)for(a.add(f);(f=s.successor(f))!==null;)a.add(f);return a}},{key:"rotateLeft",value:function(a){if(a!=null){var f=a.right;a.right=f.left,f.left!=null&&(f.left.parent=a),f.parent=a.parent,a.parent==null?this.root_=f:a.parent.left===a?a.parent.left=f:a.parent.right=f,f.left=a,a.parent=f}}},{key:"rotateRight",value:function(a){if(a!=null){var f=a.left;a.left=f.right,f.right!=null&&(f.right.parent=a),f.parent=a.parent,a.parent==null?this.root_=f:a.parent.right===a?a.parent.right=f:a.parent.left=f,f.right=a,a.parent=f}}},{key:"getFirstEntry",value:function(){var a=this.root_;if(a!=null)for(;a.left!=null;)a=a.left;return a}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(a){for(var f=this.root_;f!==null;){var m=a.compareTo(f.key);if(m<0)f=f.left;else{if(!(m>0))return!0;f=f.right}}return!1}}],[{key:"successor",value:function(a){var f;if(a===null)return null;if(a.right!==null){for(f=a.right;f.left!==null;)f=f.left;return f}f=a.parent;for(var m=a;f!==null&&m===f.right;)m=f,f=f.parent;return f}}]),s})(_d),Mc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"find",value:function(o){return this.nodeMap.get(o)}},{key:"addNode",value:function(){if(arguments[0]instanceof $){var o=arguments[0],s=this.nodeMap.get(o);return s===null&&(s=this.nodeFact.createNode(o),this.nodeMap.put(o,s)),s}if(arguments[0]instanceof cs){var a=arguments[0],f=this.nodeMap.get(a.getCoordinate());return f===null?(this.nodeMap.put(a.getCoordinate(),a),a):(f.mergeLabel(a),f)}}},{key:"print",value:function(o){for(var s=this.iterator();s.hasNext();)s.next().print(o)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(o){for(var s=new qt,a=this.iterator();a.hasNext();){var f=a.next();f.getLabel().getLocation(o)===H.BOUNDARY&&s.add(f)}return s}},{key:"add",value:function(o){var s=o.getCoordinate();this.addNode(s).add(o)}}],[{key:"constructor_",value:function(){this.nodeMap=new so,this.nodeFact=null;var o=arguments[0];this.nodeFact=o}}]),g})(),sn=(function(){function g(){n(this,g)}return e(g,null,[{key:"isNorthern",value:function(o){return o===g.NE||o===g.NW}},{key:"isOpposite",value:function(o,s){return o!==s&&(o-s+4)%4===2}},{key:"commonHalfPlane",value:function(o,s){if(o===s)return o;if((o-s+4)%4===2)return-1;var a=os?o:s)===3?3:a}},{key:"isInHalfPlane",value:function(o,s){return s===g.SE?o===g.SE||o===g.SW:o===s||o===s+1}},{key:"quadrant",value:function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var o=arguments[0],s=arguments[1];if(o===0&&s===0)throw new q("Cannot compute the quadrant for point ( "+o+", "+s+" )");return o>=0?s>=0?g.NE:g.SE:s>=0?g.NW:g.SW}if(arguments[0]instanceof $&&arguments[1]instanceof $){var a=arguments[0],f=arguments[1];if(f.x===a.x&&f.y===a.y)throw new q("Cannot compute the quadrant for two identical points "+a);return f.x>=a.x?f.y>=a.y?g.NE:g.SE:f.y>=a.y?g.NW:g.SW}}}]),g})();sn.NE=0,sn.NW=1,sn.SW=2,sn.SE=3;var Cc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"compareDirection",value:function(o){return this._dx===o._dx&&this._dy===o._dy?0:this._quadrant>o._quadrant?1:this._quadrant2){P.linkDirectedEdgesForMinimalEdgeRings();var S=P.buildMinimalRings(),O=this.findShell(S);O!==null?(this.placePolygonHoles(O,S),s.add(O)):a.addAll(S)}else f.add(P)}return f}},{key:"buildMaximalEdgeRings",value:function(o){for(var s=new qt,a=o.iterator();a.hasNext();){var f=a.next();if(f.isInResult()&&f.getLabel().isArea()&&f.getEdgeRing()===null){var m=new xd(f,this._geometryFactory);s.add(m),m.setInResult()}}return s}},{key:"placePolygonHoles",value:function(o,s){for(var a=s.iterator();a.hasNext();){var f=a.next();f.isHole()&&f.setShell(o)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(o){for(var s=0,a=null,f=o.iterator();f.hasNext();){var m=f.next();m.isHole()||(a=m,s++)}return j.isTrue(s<=1,"found two shells in MinimalEdgeRing list"),a}},{key:"add",value:function(){if(arguments.length===1){var o=arguments[0];this.add(o.getEdgeEnds(),o.getNodes())}else if(arguments.length===2){var s=arguments[0],a=arguments[1];Tc.linkResultDirectedEdges(a);var f=this.buildMaximalEdgeRings(s),m=new qt,P=this.buildMinimalEdgeRings(f,this._shellList,m);this.sortShellsAndHoles(P,this._shellList,m),this.placeFreeHoles(this._shellList,m)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new qt;var o=arguments[0];this._geometryFactory=o}},{key:"findEdgeRingContaining",value:function(o,s){for(var a=o.getLinearRing(),f=a.getEnvelopeInternal(),m=a.getCoordinateN(0),P=null,S=null,O=s.iterator();O.hasNext();){var Y=O.next(),nt=Y.getLinearRing(),st=nt.getEnvelopeInternal();if(!st.equals(f)&&st.contains(f)){m=dt.ptNotInList(a.getCoordinates(),nt.getCoordinates());var lt=!1;_a.isInRing(m,nt.getCoordinates())&&(lt=!0),lt&&(P===null||S.contains(st))&&(S=(P=Y).getLinearRing().getEnvelopeInternal())}}return P}}]),g})(),Oc=(function(){function g(){n(this,g)}return e(g,[{key:"getBounds",value:function(){}}]),g})(),mr=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[Oc,J]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var o=arguments[0],s=arguments[1];this._bounds=o,this._item=s}}]),g})(),fs=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"poll",value:function(){if(this.isEmpty())return null;var o=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),o}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(o){for(var s=null,a=this._items.get(o);2*o<=this._size&&((s=2*o)!==this._size&&this._items.get(s+1).compareTo(this._items.get(s))<0&&s++,this._items.get(s).compareTo(a)<0);o=s)this._items.set(o,this._items.get(s));this._items.set(o,a)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return this._size===0}},{key:"add",value:function(o){this._items.add(null),this._size+=1;var s=this._size;for(this._items.set(0,o);o.compareTo(this._items.get(Math.trunc(s/2)))<0;s/=2)this._items.set(s,this._items.get(Math.trunc(s/2)));this._items.set(s,o)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new qt,this._items.add(null)}}]),g})(),bd=(function(){function g(){n(this,g)}return e(g,[{key:"insert",value:function(o,s){}},{key:"remove",value:function(o,s){}},{key:"query",value:function(){}}]),g})(),Nn=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(o){j.isTrue(this._bounds===null),this._childBoundables.add(o)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return this._bounds===null&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[Oc,J]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new qt,this._bounds=null,this._level=null,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this._level=o}}}}]),g})(),Pi={reverseOrder:function(){return{compare:function(g,o){return o.compareTo(g)}}},min:function(g){return Pi.sort(g),g.get(0)},sort:function(g,o){var s=g.toArray();o?tr.sort(s,o):tr.sort(s);for(var a=g.iterator(),f=0,m=s.length;fg.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,o,s),null):(this.expand(this._boundable2,this._boundable1,!0,o,s),null);if(a)return this.expand(this._boundable1,this._boundable2,!1,o,s),null;if(f)return this.expand(this._boundable2,this._boundable1,!0,o,s),null;throw new q("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(g.isComposite(this._boundable1)||g.isComposite(this._boundable2))}},{key:"compareTo",value:function(o){var s=o;return this._distances._distance?1:0}},{key:"expand",value:function(o,s,a,f,m){for(var P=o.getChildBoundables().iterator();P.hasNext();){var S=P.next(),O=null;(O=a?new g(s,S,this._itemDistance):new g(S,s,this._itemDistance)).getDistance()-2),f.getLevel()===a)return m.add(f),null;for(var P=f.getChildBoundables().iterator();P.hasNext();){var S=P.next();S instanceof Nn?this.boundablesAtLevel(a,S,m):(j.isTrue(S instanceof mr),a===-1&&m.add(S))}return null}}},{key:"query",value:function(){if(arguments.length===1){var o=arguments[0];this.build();var s=new qt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),o)&&this.queryInternal(o,this._root,s),s}if(arguments.length===2){var a=arguments[0],f=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),a)&&this.queryInternal(a,this._root,f)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(arguments.length===2){var o=arguments[0],s=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),o)&&this.remove(o,this._root,s)}if(arguments.length===3){var a=arguments[0],f=arguments[1],m=arguments[2],P=this.removeItem(f,m);if(P)return!0;for(var S=null,O=f.getChildBoundables().iterator();O.hasNext();){var Y=O.next();if(this.getIntersectsOp().intersects(Y.getBounds(),a)&&Y instanceof Nn&&(P=this.remove(a,Y,m))){S=Y;break}}return S!==null&&S.getChildBoundables().isEmpty()&&f.getChildBoundables().remove(S),P}}},{key:"createHigherLevels",value:function(o,s){j.isTrue(!o.isEmpty());var a=this.createParentBoundables(o,s+1);return a.size()===1?a.get(0):this.createHigherLevels(a,s+1)}},{key:"depth",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(arguments.length===1){for(var o=arguments[0],s=0,a=o.getChildBoundables().iterator();a.hasNext();){var f=a.next();if(f instanceof Nn){var m=this.depth(f);m>s&&(s=m)}}return s+1}}},{key:"createParentBoundables",value:function(o,s){j.isTrue(!o.isEmpty());var a=new qt;a.add(this.createNode(s));var f=new qt(o);Pi.sort(f,this.getComparator());for(var m=f.iterator();m.hasNext();){var P=m.next();this.lastNode(a).getChildBoundables().size()===this.getNodeCapacity()&&a.add(this.createNode(s)),this.lastNode(a).addChildBoundable(P)}return a}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[J]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new qt,this._nodeCapacity=null,arguments.length===0)g.constructor_.call(this,g.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var o=arguments[0];j.isTrue(o>1,"Node capacity must be greater than 1"),this._nodeCapacity=o}}},{key:"compareDoubles",value:function(o,s){return o>s?1:o0);for(var m=new qt,P=0;P=0;){var st=Y.poll(),lt=st.getDistance();if(lt>=O)break;if(st.isLeaves())if(nt.size()lt&&(nt.poll(),nt.add(st));var mt=nt.peek();O=mt.getDistance()}else st.expandToQueue(Y,O)}return s.getItems(nt)}}},{key:"createNode",value:function(a){return new Ac(a)}},{key:"size",value:function(){return arguments.length===0?v(i(s.prototype),"size",this).call(this):v(i(s.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof ct))return v(i(s.prototype),"insert",this).apply(this,arguments);var a=arguments[0],f=arguments[1];if(a.isNull())return null;v(i(s.prototype),"insert",this).call(this,a,f)}},{key:"getIntersectsOp",value:function(){return s.intersectsOp}},{key:"verticalSlices",value:function(a,f){for(var m=Math.trunc(Math.ceil(a.size()/f)),P=new Array(f).fill(null),S=a.iterator(),O=0;O0;){var Y=O.poll(),nt=Y.getDistance();if(nt>=P)break;Y.isLeaves()?(P=nt,S=Y):Y.expandToQueue(O,P)}return S===null?null:[S.getBoundable(0).getItem(),S.getBoundable(1).getItem()]}}else{if(arguments.length===2){var st=arguments[0],lt=arguments[1];if(this.isEmpty()||st.isEmpty())return null;var yt=new bi(this.getRoot(),st.getRoot(),lt);return this.nearestNeighbour(yt)}if(arguments.length===3){var mt=arguments[0],Bt=arguments[1],Jt=arguments[2],Zt=new mr(mt,Bt),de=new bi(this.getRoot(),Zt,Jt);return this.nearestNeighbour(de)[0]}if(arguments.length===4){var Ie=arguments[0],$e=arguments[1],Sn=arguments[2],Yn=arguments[3],dr=new mr(Ie,$e),$r=new bi(this.getRoot(),dr,Sn);return this.nearestNeighbourK($r,Yn)}}}},{key:"isWithinDistance",value:function(){if(arguments.length===2){var a=arguments[0],f=arguments[1],m=E.POSITIVE_INFINITY,P=new fs;for(P.add(a);!P.isEmpty();){var S=P.poll(),O=S.getDistance();if(O>f)return!1;if(S.maximumDistance()<=f)return!0;if(S.isLeaves()){if((m=O)<=f)return!0}else S.expandToQueue(P,m)}return!1}if(arguments.length===3){var Y=arguments[0],nt=arguments[1],st=arguments[2],lt=new bi(this.getRoot(),Y.getRoot(),nt);return this.isWithinDistance(lt,st)}}},{key:"interfaces_",get:function(){return[bd,J]}}],[{key:"constructor_",value:function(){if(arguments.length===0)s.constructor_.call(this,s.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var a=arguments[0];Ei.constructor_.call(this,a)}}},{key:"centreX",value:function(a){return s.avg(a.getMinX(),a.getMaxX())}},{key:"avg",value:function(a,f){return(a+f)/2}},{key:"getItems",value:function(a){for(var f=new Array(a.size()).fill(null),m=0;!a.isEmpty();){var P=a.poll();f[m]=P.getBoundable(0).getItem(),m++}return f}},{key:"centreY",value:function(a){return s.avg(a.getMinY(),a.getMaxY())}}]),s})(Ei),Ac=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"computeBounds",value:function(){for(var a=null,f=this.getChildBoundables().iterator();f.hasNext();){var m=f.next();a===null?a=new ct(m.getBounds()):a.expandToInclude(m.getBounds())}return a}}],[{key:"constructor_",value:function(){var a=arguments[0];Nn.constructor_.call(this,a)}}]),s})(Nn);nr.STRtreeNode=Ac,nr.xComparator=new((function(){function g(){n(this,g)}return e(g,[{key:"interfaces_",get:function(){return[A]}},{key:"compare",value:function(o,s){return Ei.compareDoubles(nr.centreX(o.getBounds()),nr.centreX(s.getBounds()))}}]),g})()),nr.yComparator=new((function(){function g(){n(this,g)}return e(g,[{key:"interfaces_",get:function(){return[A]}},{key:"compare",value:function(o,s){return Ei.compareDoubles(nr.centreY(o.getBounds()),nr.centreY(s.getBounds()))}}]),g})()),nr.intersectsOp=new((function(){function g(){n(this,g)}return e(g,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(o,s){return o.intersects(s)}}]),g})()),nr.DEFAULT_NODE_CAPACITY=10;var Sd=(function(){function g(){n(this,g)}return e(g,null,[{key:"relativeSign",value:function(o,s){return os?1:0}},{key:"compare",value:function(o,s,a){if(s.equals2D(a))return 0;var f=g.relativeSign(s.x,a.x),m=g.relativeSign(s.y,a.y);switch(o){case 0:return g.compareValue(f,m);case 1:return g.compareValue(m,f);case 2:return g.compareValue(m,-f);case 3:return g.compareValue(-f,m);case 4:return g.compareValue(-f,-m);case 5:return g.compareValue(-m,-f);case 6:return g.compareValue(-m,f);case 7:return g.compareValue(f,-m)}return j.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(o,s){return o<0?-1:o>0?1:s<0?-1:s>0?1:0}}]),g})(),kd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(o){o.print(this.coord),o.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(o){var s=o;return this.segmentIndexs.segmentIndex?1:this.coord.equals2D(s.coord)?0:this._isInterior?s._isInterior?Sd.compare(this._segmentOctant,this.coord,s.coord):1:-1}},{key:"isEndPoint",value:function(o){return this.segmentIndex===0&&!this._isInterior||this.segmentIndex===o}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[X]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var o=arguments[0],s=arguments[1],a=arguments[2],f=arguments[3];this._segString=o,this.coord=new $(s),this.segmentIndex=a,this._segmentOctant=f,this._isInterior=!s.equals2D(o.getCoordinate(a))}}]),g})(),Id=(function(){function g(){n(this,g)}return e(g,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),g})(),Ld=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getSplitCoordinates",value:function(){var o=new gt;this.addEndpoints();for(var s=this.iterator(),a=s.next();s.hasNext();){var f=s.next();this.addEdgeCoordinates(a,f,o),a=f}return o.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var o=new qt;this.findCollapsesFromInsertedNodes(o),this.findCollapsesFromExistingVertices(o);for(var s=o.iterator();s.hasNext();){var a=s.next().intValue();this.add(this._edge.getCoordinate(a),a)}}},{key:"createSplitEdgePts",value:function(o,s){var a=s.segmentIndex-o.segmentIndex+2;if(a===2)return[new $(o.coord),new $(s.coord)];var f=this._edge.getCoordinate(s.segmentIndex),m=s.isInterior()||!s.coord.equals2D(f);m||a--;var P=new Array(a).fill(null),S=0;P[S++]=new $(o.coord);for(var O=o.segmentIndex+1;O<=s.segmentIndex;O++)P[S++]=this._edge.getCoordinate(O);return m&&(P[S]=new $(s.coord)),P}},{key:"print",value:function(o){o.println("Intersections:");for(var s=this.iterator();s.hasNext();)s.next().print(o)}},{key:"findCollapsesFromExistingVertices",value:function(o){for(var s=0;s=0?s>=0?a>=f?0:1:a>=f?7:6:s>=0?a>=f?3:2:a>=f?4:5}if(arguments[0]instanceof $&&arguments[1]instanceof $){var m=arguments[0],P=arguments[1],S=P.x-m.x,O=P.y-m.y;if(S===0&&O===0)throw new q("Cannot compute the octant for two identical points "+m);return g.octant(S,O)}}}]),g})(),Cd=(function(){function g(){n(this,g)}return e(g,[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(o){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(o){}},{key:"getData",value:function(){}}]),g})(),Nd=(function(){function g(){n(this,g)}return e(g,[{key:"addIntersection",value:function(o,s){}},{key:"interfaces_",get:function(){return[Cd]}}]),g})(),Kr=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(o){return this._pts[o]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(o){return o===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(o),this.getCoordinate(o+1))}},{key:"setData",value:function(o){this._data=o}},{key:"safeOctant",value:function(o,s){return o.equals2D(s)?0:Md.octant(o,s)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(arguments.length===2){var o=arguments[0],s=arguments[1];this.addIntersectionNode(o,s)}else if(arguments.length===4){var a=arguments[0],f=arguments[1],m=arguments[3],P=new $(a.getIntersection(m));this.addIntersection(P,f)}}},{key:"toString",value:function(){return xa.toLineString(new Gt(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(o,s){var a=s,f=a+1;if(f=0&&a>=0||s<=0&&a<=0?Math.max(s,a):0}if(arguments[0]instanceof $){var f=arguments[0];return Rt.index(this.p0,this.p1,f)}}},{key:"toGeometry",value:function(o){return o.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(o){if(!(o instanceof g))return!1;var s=o;return this.p0.equals(s.p0)&&this.p1.equals(s.p1)}},{key:"intersection",value:function(o){var s=new jr;return s.computeIntersection(this.p0,this.p1,o.p0,o.p1),s.hasIntersection()?s.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof $){var o=arguments[0];if(o.equals(this.p0)||o.equals(this.p1))return new $(o);var s=this.projectionFactor(o),a=new $;return a.x=this.p0.x+s*(this.p1.x-this.p0.x),a.y=this.p0.y+s*(this.p1.y-this.p0.y),a}if(arguments[0]instanceof g){var f=arguments[0],m=this.projectionFactor(f.p0),P=this.projectionFactor(f.p1);if(m>=1&&P>=1||m<=0&&P<=0)return null;var S=this.project(f.p0);m<0&&(S=this.p0),m>1&&(S=this.p1);var O=this.project(f.p1);return P<0&&(O=this.p0),P>1&&(O=this.p1),new g(S,O)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(o){return o===0?this.p0:this.p1}},{key:"distancePerpendicular",value:function(o){return Oe.pointToLinePerpendicular(o,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return g.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(o){if(o.equals(this.p0))return 0;if(o.equals(this.p1))return 1;var s=this.p1.x-this.p0.x,a=this.p1.y-this.p0.y,f=s*s+a*a;return f<=0?E.NaN:((o.x-this.p0.x)*s+(o.y-this.p0.y)*a)/f}},{key:"closestPoints",value:function(o){var s=this.intersection(o);if(s!==null)return[s,s];var a=new Array(2).fill(null),f=E.MAX_VALUE,m=null,P=this.closestPoint(o.p0);f=P.distance(o.p0),a[0]=P,a[1]=o.p0;var S=this.closestPoint(o.p1);(m=S.distance(o.p1))0&&s<1?this.project(o):this.p0.distance(o)1||E.isNaN(s))&&(s=1),s}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(o){var s=this.p1.getY()-this.p0.getY(),a=this.p0.getX()-this.p1.getX(),f=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),m=s*s+a*a,P=s*s-a*a,S=o.getX(),O=o.getY();return new $((-P*S-2*s*a*O-2*s*f)/m,(P*O-2*s*a*S-2*a*f)/m)}},{key:"distance",value:function(){if(arguments[0]instanceof g){var o=arguments[0];return Oe.segmentToSegment(this.p0,this.p1,o.p0,o.p1)}if(arguments[0]instanceof $){var s=arguments[0];return Oe.pointToSegment(s,this.p0,this.p1)}}},{key:"pointAlong",value:function(o){var s=new $;return s.x=this.p0.x+o*(this.p1.x-this.p0.x),s.y=this.p0.y+o*(this.p1.y-this.p0.y),s}},{key:"hashCode",value:function(){var o=E.doubleToLongBits(this.p0.x);o^=31*E.doubleToLongBits(this.p0.y);var s=Math.trunc(o)^Math.trunc(o>>32),a=E.doubleToLongBits(this.p1.x);return a^=31*E.doubleToLongBits(this.p1.y),s^(Math.trunc(a)^Math.trunc(a>>32))}},{key:"interfaces_",get:function(){return[X,J]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,arguments.length===0)g.constructor_.call(this,new $,new $);else if(arguments.length===1){var o=arguments[0];g.constructor_.call(this,o.p0,o.p1)}else if(arguments.length===2){var s=arguments[0],a=arguments[1];this.p0=s,this.p1=a}else if(arguments.length===4){var f=arguments[0],m=arguments[1],P=arguments[2],S=arguments[3];g.constructor_.call(this,new $(f,m),new $(P,S))}}},{key:"midPoint",value:function(o,s){return new $((o.x+s.x)/2,(o.y+s.y)/2)}}]),g})(),Td=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"overlap",value:function(){if(arguments.length!==2){if(arguments.length===4){var o=arguments[0],s=arguments[1],a=arguments[2],f=arguments[3];o.getLineSegment(s,this._overlapSeg1),a.getLineSegment(f,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new En,this._overlapSeg2=new En}}]),g})(),Fc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getLineSegment",value:function(o,s){s.p0=this._pts[o],s.p1=this._pts[o+1]}},{key:"computeSelect",value:function(o,s,a,f){var m=this._pts[s],P=this._pts[a];if(a-s==1)return f.select(this,s),null;if(!o.intersects(m,P))return null;var S=Math.trunc((s+a)/2);s=o.length-1)return o.length-1;for(var f=sn.quadrant(o[a],o[a+1]),m=s+1;mm.getId()&&(m.computeOverlaps(S,a),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new qt,this._index=new nr,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,arguments.length!==0){if(arguments.length===1){var a=arguments[0];Dc.constructor_.call(this,a)}}}}]),s})(Dc),Gc=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"overlap",value:function(){if(arguments.length!==4)return v(i(s.prototype),"overlap",this).apply(this,arguments);var a=arguments[0],f=arguments[1],m=arguments[2],P=arguments[3],S=a.getContext(),O=m.getContext();this._si.processIntersections(S,f,O,P)}}],[{key:"constructor_",value:function(){this._si=null;var a=arguments[0];this._si=a}}]),s})(Td);wa.SegmentOverlapAction=Gc;var Un=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"isDeletable",value:function(o,s,a,f){var m=this._inputLine[o],P=this._inputLine[s],S=this._inputLine[a];return!!this.isConcave(m,P,S)&&!!this.isShallow(m,P,S,f)&&this.isShallowSampled(m,P,o,a,f)}},{key:"deleteShallowConcavities",value:function(){for(var o=1,s=this.findNextNonDeletedIndex(o),a=this.findNextNonDeletedIndex(s),f=!1;a=0;f--)this.addPt(o[f])}},{key:"isRedundant",value:function(o){if(this._ptList.size()<1)return!1;var s=this._ptList.get(this._ptList.size()-1);return o.distance(s)Math.PI;)o-=g.PI_TIMES_2;for(;o<=-Math.PI;)o+=g.PI_TIMES_2;return o}},{key:"angle",value:function(){if(arguments.length===1){var o=arguments[0];return Math.atan2(o.y,o.x)}if(arguments.length===2){var s=arguments[0],a=arguments[1],f=a.x-s.x,m=a.y-s.y;return Math.atan2(m,f)}}},{key:"isAcute",value:function(o,s,a){var f=o.x-s.x,m=o.y-s.y;return f*(a.x-s.x)+m*(a.y-s.y)>0}},{key:"isObtuse",value:function(o,s,a){var f=o.x-s.x,m=o.y-s.y;return f*(a.x-s.x)+m*(a.y-s.y)<0}},{key:"interiorAngle",value:function(o,s,a){var f=g.angle(s,o),m=g.angle(s,a);return Math.abs(m-f)}},{key:"normalizePositive",value:function(o){if(o<0){for(;o<0;)o+=g.PI_TIMES_2;o>=g.PI_TIMES_2&&(o=0)}else{for(;o>=g.PI_TIMES_2;)o-=g.PI_TIMES_2;o<0&&(o=0)}return o}},{key:"angleBetween",value:function(o,s,a){var f=g.angle(s,o),m=g.angle(s,a);return g.diff(f,m)}},{key:"diff",value:function(o,s){var a=null;return(a=oMath.PI&&(a=2*Math.PI-a),a}},{key:"toRadians",value:function(o){return o*Math.PI/180}},{key:"getTurn",value:function(o,s){var a=Math.sin(s-o);return a>0?g.COUNTERCLOCKWISE:a<0?g.CLOCKWISE:g.NONE}},{key:"angleBetweenOriented",value:function(o,s,a){var f=g.angle(s,o),m=g.angle(s,a)-f;return m<=-Math.PI?m+g.PI_TIMES_2:m>Math.PI?m-g.PI_TIMES_2:m}}]),g})();wn.PI_TIMES_2=2*Math.PI,wn.PI_OVER_2=Math.PI/2,wn.PI_OVER_4=Math.PI/4,wn.COUNTERCLOCKWISE=Rt.COUNTERCLOCKWISE,wn.CLOCKWISE=Rt.CLOCKWISE,wn.NONE=Rt.COLLINEAR;var uo=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"addNextSegment",value:function(o,s){if(this._s0=this._s1,this._s1=this._s2,this._s2=o,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var a=Rt.index(this._s0,this._s1,this._s2),f=a===Rt.CLOCKWISE&&this._side===ft.LEFT||a===Rt.COUNTERCLOCKWISE&&this._side===ft.RIGHT;a===0?this.addCollinear(s):f?this.addOutsideTurn(a,s):this.addInsideTurn(a,s)}},{key:"addLineEndCap",value:function(o,s){var a=new En(o,s),f=new En;this.computeOffsetSegment(a,ft.LEFT,this._distance,f);var m=new En;this.computeOffsetSegment(a,ft.RIGHT,this._distance,m);var P=s.x-o.x,S=s.y-o.y,O=Math.atan2(S,P);switch(this._bufParams.getEndCapStyle()){case L.CAP_ROUND:this._segList.addPt(f.p1),this.addDirectedFillet(s,O+Math.PI/2,O-Math.PI/2,Rt.CLOCKWISE,this._distance),this._segList.addPt(m.p1);break;case L.CAP_FLAT:this._segList.addPt(f.p1),this._segList.addPt(m.p1);break;case L.CAP_SQUARE:var Y=new $;Y.x=Math.abs(this._distance)*Math.cos(O),Y.y=Math.abs(this._distance)*Math.sin(O);var nt=new $(f.p1.x+Y.x,f.p1.y+Y.y),st=new $(m.p1.x+Y.x,m.p1.y+Y.y);this._segList.addPt(nt),this._segList.addPt(st)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(o,s,a,f){var m=Lr.intersection(s.p0,s.p1,a.p0,a.p1);if(m!==null&&(f<=0?1:m.distance(o)/Math.abs(f))<=this._bufParams.getMitreLimit())return this._segList.addPt(m),null;this.addLimitedMitreJoin(s,a,f,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(o,s){if(this._offset0.p1.distance(this._offset1.p0)=st&&(O-=2*Math.PI),this._segList.addPt(s),this.addDirectedFillet(o,O,st,f,m),this._segList.addPt(a)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(o,s,a){this._s1=o,this._s2=s,this._side=a,this._seg1.setCoordinates(o,s),this.computeOffsetSegment(this._seg1,a,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(o,s,a,f){var m=this._seg0.p1,P=wn.angle(m,this._seg0.p0),S=wn.angleBetweenOriented(this._seg0.p0,m,this._seg1.p1)/2,O=wn.normalize(P+S),Y=wn.normalize(O+Math.PI),nt=f*a,st=a-nt*Math.abs(Math.sin(S)),lt=m.x+nt*Math.cos(Y),yt=m.y+nt*Math.sin(Y),mt=new $(lt,yt),Bt=new En(m,mt),Jt=Bt.pointAlongOffset(1,st),Zt=Bt.pointAlongOffset(1,-st);this._side===ft.LEFT?(this._segList.addPt(Jt),this._segList.addPt(Zt)):(this._segList.addPt(Zt),this._segList.addPt(Jt))}},{key:"addDirectedFillet",value:function(o,s,a,f,m){var P=f===Rt.CLOCKWISE?-1:1,S=Math.abs(s-a),O=Math.trunc(S/this._filletAngleQuantum+.5);if(O<1)return null;for(var Y=S/O,nt=new $,st=0;st0){var a=new $((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(a);var f=new $((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(f)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(o){var s=new $(o.x+this._distance,o.y);this._segList.addPt(s),this.addDirectedFillet(o,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(o,s){this._segList.addPt(o.p1),this._segList.addPt(s.p0)}},{key:"init",value:function(o){this._distance=o,this._maxCurveSegmentError=o*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Bc,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(o*g.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(o){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===L.JOIN_BEVEL||this._bufParams.getJoinStyle()===L.JOIN_MITRE?(o&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,Rt.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new En,this._seg1=new En,this._offset0=new En,this._offset1=new En,this._side=0,this._hasNarrowConcaveAngle=!1;var o=arguments[0],s=arguments[1],a=arguments[2];this._precisionModel=o,this._bufParams=s,this._li=new jr,this._filletAngleQuantum=Math.PI/2/s.getQuadrantSegments(),s.getQuadrantSegments()>=8&&s.getJoinStyle()===L.JOIN_ROUND&&(this._closingSegLengthFactor=g.MAX_CLOSING_SEG_LEN_FACTOR),this.init(a)}}]),g})();uo.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,uo.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,uo.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,uo.MAX_CLOSING_SEG_LEN_FACTOR=80;var Rd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getOffsetCurve",value:function(o,s){if(this._distance=s,s===0)return null;var a=s<0,f=Math.abs(s),m=this.getSegGen(f);o.length<=1?this.computePointCurve(o[0],m):this.computeOffsetCurve(o,a,m);var P=m.getCoordinates();return a&&dt.reverse(P),P}},{key:"computeSingleSidedBufferCurve",value:function(o,s,a){var f=this.simplifyTolerance(this._distance);if(s){a.addSegments(o,!0);var m=Un.simplify(o,-f),P=m.length-1;a.initSideSegments(m[P],m[P-1],ft.LEFT),a.addFirstSegment();for(var S=P-2;S>=0;S--)a.addNextSegment(m[S],!0)}else{a.addSegments(o,!1);var O=Un.simplify(o,f),Y=O.length-1;a.initSideSegments(O[0],O[1],ft.LEFT),a.addFirstSegment();for(var nt=2;nt<=Y;nt++)a.addNextSegment(O[nt],!0)}a.addLastSegment(),a.closeRing()}},{key:"computeRingBufferCurve",value:function(o,s,a){var f=this.simplifyTolerance(this._distance);s===ft.RIGHT&&(f=-f);var m=Un.simplify(o,f),P=m.length-1;a.initSideSegments(m[P-1],m[0],s);for(var S=1;S<=P;S++){var O=S!==1;a.addNextSegment(m[S],O)}a.closeRing()}},{key:"computeLineBufferCurve",value:function(o,s){var a=this.simplifyTolerance(this._distance),f=Un.simplify(o,a),m=f.length-1;s.initSideSegments(f[0],f[1],ft.LEFT);for(var P=2;P<=m;P++)s.addNextSegment(f[P],!0);s.addLastSegment(),s.addLineEndCap(f[m-1],f[m]);var S=Un.simplify(o,-a),O=S.length-1;s.initSideSegments(S[O],S[O-1],ft.LEFT);for(var Y=O-2;Y>=0;Y--)s.addNextSegment(S[Y],!0);s.addLastSegment(),s.addLineEndCap(S[1],S[0]),s.closeRing()}},{key:"computePointCurve",value:function(o,s){switch(this._bufParams.getEndCapStyle()){case L.CAP_ROUND:s.createCircle(o);break;case L.CAP_SQUARE:s.createSquare(o)}}},{key:"getLineCurve",value:function(o,s){if(this._distance=s,this.isLineOffsetEmpty(s))return null;var a=Math.abs(s),f=this.getSegGen(a);if(o.length<=1)this.computePointCurve(o[0],f);else if(this._bufParams.isSingleSided()){var m=s<0;this.computeSingleSidedBufferCurve(o,m,f)}else this.computeLineBufferCurve(o,f);return f.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(o){return o*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(o,s,a){if(this._distance=a,o.length<=2)return this.getLineCurve(o,a);if(a===0)return g.copyCoordinates(o);var f=this.getSegGen(a);return this.computeRingBufferCurve(o,s,f),f.getCoordinates()}},{key:"computeOffsetCurve",value:function(o,s,a){var f=this.simplifyTolerance(this._distance);if(s){var m=Un.simplify(o,-f),P=m.length-1;a.initSideSegments(m[P],m[P-1],ft.LEFT),a.addFirstSegment();for(var S=P-2;S>=0;S--)a.addNextSegment(m[S],!0)}else{var O=Un.simplify(o,f),Y=O.length-1;a.initSideSegments(O[0],O[1],ft.LEFT),a.addFirstSegment();for(var nt=2;nt<=Y;nt++)a.addNextSegment(O[nt],!0)}a.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(o){return o===0||o<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(o){return new uo(this._precisionModel,this._bufParams,o)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var o=arguments[0],s=arguments[1];this._precisionModel=o,this._bufParams=s}},{key:"copyCoordinates",value:function(o){for(var s=new Array(o.length).fill(null),a=0;am.getMaxY()||this.findStabbedSegments(o,f.getDirectedEdges(),s)}return s}if(arguments.length===3){if(Xt(arguments[2],qe)&&arguments[0]instanceof $&&arguments[1]instanceof ba)for(var P=arguments[0],S=arguments[1],O=arguments[2],Y=S.getEdge().getCoordinates(),nt=0;ntthis._seg.p1.y&&this._seg.reverse();var st=Math.max(this._seg.p0.x,this._seg.p1.x);if(!(stthis._seg.p1.y||Rt.index(this._seg.p0,this._seg.p1,P)===Rt.RIGHT)){var lt=S.getDepth(ft.LEFT);this._seg.p0.equals(Y[nt])||(lt=S.getDepth(ft.RIGHT));var yt=new zc(this._seg,lt);O.add(yt)}}else if(Xt(arguments[2],qe)&&arguments[0]instanceof $&&Xt(arguments[1],qe))for(var mt=arguments[0],Bt=arguments[1],Jt=arguments[2],Zt=Bt.iterator();Zt.hasNext();){var de=Zt.next();de.isForward()&&this.findStabbedSegments(mt,de,Jt)}}}},{key:"getDepth",value:function(o){var s=this.findStabbedSegments(o);return s.size()===0?0:Pi.min(s)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new En;var o=arguments[0];this._subgraphs=o}}]),g})(),zc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"compareTo",value:function(o){var s=o;if(this._upwardSeg.minX()>=s._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=s._upwardSeg.minX())return-1;var a=this._upwardSeg.orientationIndex(s._upwardSeg);return a!==0||(a=-1*s._upwardSeg.orientationIndex(this._upwardSeg))!==0?a:this._upwardSeg.compareTo(s._upwardSeg)}},{key:"compareX",value:function(o,s){var a=o.p0.compareTo(s.p0);return a!==0?a:o.p1.compareTo(s.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[X]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var o=arguments[0],s=arguments[1];this._upwardSeg=new En(o),this._leftDepth=s}}]),g})();qc.DepthSegment=zc;var Xc=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,null,[{key:"constructor_",value:function(){C.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),s})(C),Sa=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"getY",value:function(){var o=this.y/this.w;if(E.isNaN(o)||E.isInfinite(o))throw new Xc;return o}},{key:"getX",value:function(){var o=this.x/this.w;if(E.isNaN(o)||E.isInfinite(o))throw new Xc;return o}},{key:"getCoordinate",value:function(){var o=new $;return o.x=this.getX(),o.y=this.getY(),o}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,arguments.length===0)this.x=0,this.y=0,this.w=1;else if(arguments.length===1){var o=arguments[0];this.x=o.x,this.y=o.y,this.w=1}else if(arguments.length===2){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var s=arguments[0],a=arguments[1];this.x=s,this.y=a,this.w=1}else if(arguments[0]instanceof g&&arguments[1]instanceof g){var f=arguments[0],m=arguments[1];this.x=f.y*m.w-m.y*f.w,this.y=m.x*f.w-f.x*m.w,this.w=f.x*m.y-m.x*f.y}else if(arguments[0]instanceof $&&arguments[1]instanceof $){var P=arguments[0],S=arguments[1];this.x=P.y-S.y,this.y=S.x-P.x,this.w=P.x*S.y-S.x*P.y}}else if(arguments.length===3){var O=arguments[0],Y=arguments[1],nt=arguments[2];this.x=O,this.y=Y,this.w=nt}else if(arguments.length===4){var st=arguments[0],lt=arguments[1],yt=arguments[2],mt=arguments[3],Bt=st.y-lt.y,Jt=lt.x-st.x,Zt=st.x*lt.y-lt.x*st.y,de=yt.y-mt.y,Ie=mt.x-yt.x,$e=yt.x*mt.y-mt.x*yt.y;this.x=Jt*$e-Ie*Zt,this.y=de*Zt-Bt*$e,this.w=Bt*Ie-de*Jt}}}]),g})(),Ad=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"area",value:function(){return g.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return g.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(o){if(o===null)throw new q("Supplied point is null.");return g.interpolateZ(o,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return g.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return g.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return g.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return g.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return g.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return g.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var o=arguments[0],s=arguments[1],a=arguments[2];this.p0=o,this.p1=s,this.p2=a}},{key:"area",value:function(o,s,a){return Math.abs(((a.x-o.x)*(s.y-o.y)-(s.x-o.x)*(a.y-o.y))/2)}},{key:"signedArea",value:function(o,s,a){return((a.x-o.x)*(s.y-o.y)-(s.x-o.x)*(a.y-o.y))/2}},{key:"det",value:function(o,s,a,f){return o*f-s*a}},{key:"interpolateZ",value:function(o,s,a,f){var m=s.x,P=s.y,S=a.x-m,O=f.x-m,Y=a.y-P,nt=f.y-P,st=S*nt-O*Y,lt=o.x-m,yt=o.y-P,mt=(nt*lt-O*yt)/st,Bt=(-Y*lt+S*yt)/st;return s.getZ()+mt*(a.getZ()-s.getZ())+Bt*(f.getZ()-s.getZ())}},{key:"longestSideLength",value:function(o,s,a){var f=o.distance(s),m=s.distance(a),P=a.distance(o),S=f;return m>S&&(S=m),P>S&&(S=P),S}},{key:"circumcentreDD",value:function(o,s,a){var f=zt.valueOf(o.x).subtract(a.x),m=zt.valueOf(o.y).subtract(a.y),P=zt.valueOf(s.x).subtract(a.x),S=zt.valueOf(s.y).subtract(a.y),O=zt.determinant(f,m,P,S).multiply(2),Y=f.sqr().add(m.sqr()),nt=P.sqr().add(S.sqr()),st=zt.determinant(m,Y,S,nt),lt=zt.determinant(f,Y,P,nt),yt=zt.valueOf(a.x).subtract(st.divide(O)).doubleValue(),mt=zt.valueOf(a.y).add(lt.divide(O)).doubleValue();return new $(yt,mt)}},{key:"isAcute",value:function(o,s,a){return!!wn.isAcute(o,s,a)&&!!wn.isAcute(s,a,o)&&!!wn.isAcute(a,o,s)}},{key:"circumcentre",value:function(o,s,a){var f=a.x,m=a.y,P=o.x-f,S=o.y-m,O=s.x-f,Y=s.y-m,nt=2*g.det(P,S,O,Y),st=g.det(S,P*P+S*S,Y,O*O+Y*Y),lt=g.det(P,P*P+S*S,O,O*O+Y*Y);return new $(f-st/nt,m+lt/nt)}},{key:"perpendicularBisector",value:function(o,s){var a=s.x-o.x,f=s.y-o.y,m=new Sa(o.x+a/2,o.y+f/2,1),P=new Sa(o.x-f+a/2,o.y+a+f/2,1);return new Sa(m,P)}},{key:"angleBisector",value:function(o,s,a){var f=s.distance(o),m=f/(f+s.distance(a)),P=a.x-o.x,S=a.y-o.y;return new $(o.x+m*P,o.y+m*S)}},{key:"area3D",value:function(o,s,a){var f=s.x-o.x,m=s.y-o.y,P=s.getZ()-o.getZ(),S=a.x-o.x,O=a.y-o.y,Y=a.getZ()-o.getZ(),nt=m*Y-P*O,st=P*S-f*Y,lt=f*O-m*S,yt=nt*nt+st*st+lt*lt,mt=Math.sqrt(yt)/2;return mt}},{key:"centroid",value:function(o,s,a){var f=(o.x+s.x+a.x)/3,m=(o.y+s.y+a.y)/3;return new $(f,m)}},{key:"inCentre",value:function(o,s,a){var f=s.distance(a),m=o.distance(a),P=o.distance(s),S=f+m+P,O=(f*o.x+m*s.x+P*a.x)/S,Y=(f*o.y+m*s.y+P*a.y)/S;return new $(O,Y)}}]),g})(),Fd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"addRingSide",value:function(o,s,a,f,m){if(s===0&&o.length=U.MINIMUM_VALID_SIZE&&Rt.isCCW(o)&&(P=m,S=f,a=ft.opposite(a));var O=this._curveBuilder.getRingCurve(o,a,s);this.addCurve(O,P,S)}},{key:"addRingBothSides",value:function(o,s){this.addRingSide(o,s,ft.LEFT,H.EXTERIOR,H.INTERIOR),this.addRingSide(o,s,ft.RIGHT,H.INTERIOR,H.EXTERIOR)}},{key:"addPoint",value:function(o){if(this._distance<=0)return null;var s=o.getCoordinates(),a=this._curveBuilder.getLineCurve(s,this._distance);this.addCurve(a,H.EXTERIOR,H.INTERIOR)}},{key:"addPolygon",value:function(o){var s=this._distance,a=ft.LEFT;this._distance<0&&(s=-this._distance,a=ft.RIGHT);var f=o.getExteriorRing(),m=dt.removeRepeatedPoints(f.getCoordinates());if(this._distance<0&&this.isErodedCompletely(f,this._distance)||this._distance<=0&&m.length<3)return null;this.addRingSide(m,s,a,H.EXTERIOR,H.INTERIOR);for(var P=0;P0&&this.isErodedCompletely(S,-this._distance)||this.addRingSide(O,s,ft.opposite(a),H.INTERIOR,H.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(o,s){var a=new Ad(o[0],o[1],o[2]),f=a.inCentre();return Oe.pointToSegment(f,a.p0,a.p1)m}},{key:"addCollection",value:function(o){for(var s=0;s=this._max)throw new Nt;var o=this._parent.getGeometryN(this._index++);return o instanceof rn?(this._subcollectionIterator=new g(o),this._subcollectionIterator.next()):o}},{key:"remove",value:function(){throw new St(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[Id]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var o=arguments[0];this._parent=o,this._atStart=!0,this._index=0,this._max=o.getNumGeometries()}},{key:"isAtomic",value:function(o){return!(o instanceof rn)}}]),g})(),Bd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"locate",value:function(o){return g.locate(o,this._geom)}},{key:"interfaces_",get:function(){return[Dd]}}],[{key:"constructor_",value:function(){this._geom=null;var o=arguments[0];this._geom=o}},{key:"locatePointInPolygon",value:function(o,s){if(s.isEmpty())return H.EXTERIOR;var a=s.getExteriorRing(),f=g.locatePointInRing(o,a);if(f!==H.INTERIOR)return f;for(var m=0;m=0;m--){var P=this._edgeList.get(m),S=P.getSym();f===null&&(f=S),a!==null&&S.setNext(a),a=P}f.setNext(a)}},{key:"computeDepths",value:function(){if(arguments.length===1){var a=arguments[0],f=this.findIndex(a),m=a.getDepth(ft.LEFT),P=a.getDepth(ft.RIGHT),S=this.computeDepths(f+1,this._edgeList.size(),m),O=this.computeDepths(0,f,S);if(O!==P)throw new Fe("depth mismatch at "+a.getCoordinate())}else if(arguments.length===3){for(var Y=arguments[0],nt=arguments[1],st=arguments[2],lt=st,yt=Y;yt=0;S--){var O=this._resultAreaEdgeList.get(S),Y=O.getSym();switch(f===null&&O.getEdgeRing()===a&&(f=O),P){case this._SCANNING_FOR_INCOMING:if(Y.getEdgeRing()!==a)continue;m=Y,P=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(O.getEdgeRing()!==a)continue;m.setNextMin(O),P=this._SCANNING_FOR_INCOMING}}P===this._LINKING_TO_OUTGOING&&(j.isTrue(f!==null,"found null for first outgoing dirEdge"),j.isTrue(f.getEdgeRing()===a,"unable to link last incoming dirEdge"),m.setNextMin(f))}},{key:"getOutgoingDegree",value:function(){if(arguments.length===0){for(var a=0,f=this.iterator();f.hasNext();){var m=f.next();m.isInResult()&&a++}return a}if(arguments.length===1){for(var P=arguments[0],S=0,O=this.iterator();O.hasNext();){var Y=O.next();Y.getEdgeRing()===P&&S++}return S}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var a=H.NONE,f=this.iterator();f.hasNext();){var m=f.next(),P=m.getSym();if(!m.isLineEdge()){if(m.isInResult()){a=H.INTERIOR;break}if(P.isInResult()){a=H.EXTERIOR;break}}}if(a===H.NONE)return null;for(var S=a,O=this.iterator();O.hasNext();){var Y=O.next(),nt=Y.getSym();Y.isLineEdge()?Y.getEdge().setCovered(S===H.INTERIOR):(Y.isInResult()&&(S=H.EXTERIOR),nt.isInResult()&&(S=H.INTERIOR))}}},{key:"computeLabelling",value:function(a){v(i(s.prototype),"computeLabelling",this).call(this,a),this._label=new Cn(H.NONE);for(var f=this.iterator();f.hasNext();)for(var m=f.next().getEdge().getLabel(),P=0;P<2;P++){var S=m.getLocation(P);S!==H.INTERIOR&&S!==H.BOUNDARY||this._label.setLocation(P,H.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}]),s})(qd),Xd=(function(g){r(s,g);var o=y(s);function s(){return n(this,s),o.call(this)}return e(s,[{key:"createNode",value:function(a){return new cs(a,new zd)}}]),s})(Nc),Uc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"compareTo",value:function(o){var s=o;return g.compareOriented(this._pts,this._orientation,s._pts,s._orientation)}},{key:"interfaces_",get:function(){return[X]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var o=arguments[0];this._pts=o,this._orientation=g.orientation(o)}},{key:"orientation",value:function(o){return dt.increasingDirection(o)===1}},{key:"compareOriented",value:function(o,s,a,f){for(var m=s?1:-1,P=f?1:-1,S=s?o.length:-1,O=f?a.length:-1,Y=s?0:o.length-1,nt=f?0:a.length-1;;){var st=o[Y].compareTo(a[nt]);if(st!==0)return st;var lt=(Y+=m)===S,yt=(nt+=P)===O;if(lt&&!yt)return-1;if(!lt&&yt)return 1;if(lt&&yt)return 0}}}]),g})(),Ud=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"print",value:function(o){o.print("MULTILINESTRING ( ");for(var s=0;s0&&o.print(","),o.print("(");for(var f=a.getCoordinates(),m=0;m0&&o.print(","),o.print(f[m].x+" "+f[m].y);o.println(")")}o.print(") ")}},{key:"addAll",value:function(o){for(var s=o.iterator();s.hasNext();)this.add(s.next())}},{key:"findEdgeIndex",value:function(o){for(var s=0;so?1:this.dists?1:0}},{key:"interfaces_",get:function(){return[X]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var o=arguments[0],s=arguments[1],a=arguments[2];this.coord=new $(o),this.segmentIndex=s,this.dist=a}}]),g})(),Vd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"print",value:function(o){o.println("Intersections:");for(var s=this.iterator();s.hasNext();)s.next().print(o)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(o){this.addEndpoints();for(var s=this.iterator(),a=s.next();s.hasNext();){var f=s.next(),m=this.createSplitEdge(a,f);o.add(m),a=f}}},{key:"addEndpoints",value:function(){var o=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[o],o,0)}},{key:"createSplitEdge",value:function(o,s){var a=s.segmentIndex-o.segmentIndex+2,f=this.edge.pts[s.segmentIndex],m=s.dist>0||!s.coord.equals2D(f);m||a--;var P=new Array(a).fill(null),S=0;P[S++]=new $(o.coord);for(var O=o.segmentIndex+1;O<=s.segmentIndex;O++)P[S++]=this.edge.pts[O];return m&&(P[S]=s.coord),new Vc(P,new Cn(this.edge._label))}},{key:"add",value:function(o,s,a){var f=new Jd(o,s,a),m=this._nodeMap.get(f);return m!==null?m:(this._nodeMap.put(f,f),f)}},{key:"isIntersection",value:function(o){for(var s=this.iterator();s.hasNext();)if(s.next().coord.equals(o))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new so,this.edge=null;var o=arguments[0];this.edge=o}}]),g})(),Hd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])||g.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||g.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||g.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY]))&&this._matrix[H.EXTERIOR][H.INTERIOR]===xt.FALSE&&this._matrix[H.EXTERIOR][H.BOUNDARY]===xt.FALSE}},{key:"isCoveredBy",value:function(){return(g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])||g.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||g.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||g.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY]))&&this._matrix[H.INTERIOR][H.EXTERIOR]===xt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===xt.FALSE}},{key:"set",value:function(){if(arguments.length===1)for(var o=arguments[0],s=0;s=0&&s>=0&&this.setAtLeast(o,s,a)}},{key:"isWithin",value:function(){return g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&this._matrix[H.INTERIOR][H.EXTERIOR]===xt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===xt.FALSE}},{key:"isTouches",value:function(o,s){return o>s?this.isTouches(s,o):(o===xt.A&&s===xt.A||o===xt.L&&s===xt.L||o===xt.L&&s===xt.A||o===xt.P&&s===xt.A||o===xt.P&&s===xt.L)&&this._matrix[H.INTERIOR][H.INTERIOR]===xt.FALSE&&(g.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||g.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||g.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY]))}},{key:"isOverlaps",value:function(o,s){return o===xt.P&&s===xt.P||o===xt.A&&s===xt.A?g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&g.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR])&&g.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR]):o===xt.L&&s===xt.L&&this._matrix[H.INTERIOR][H.INTERIOR]===1&&g.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR])&&g.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR])}},{key:"isEquals",value:function(o,s){return o===s&&g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&this._matrix[H.INTERIOR][H.EXTERIOR]===xt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===xt.FALSE&&this._matrix[H.EXTERIOR][H.INTERIOR]===xt.FALSE&&this._matrix[H.EXTERIOR][H.BOUNDARY]===xt.FALSE}},{key:"toString",value:function(){for(var o=new Re("123456789"),s=0;s<3;s++)for(var a=0;a<3;a++)o.setCharAt(3*s+a,xt.toDimensionSymbol(this._matrix[s][a]));return o.toString()}},{key:"setAll",value:function(o){for(var s=0;s<3;s++)for(var a=0;a<3;a++)this._matrix[s][a]=o}},{key:"get",value:function(o,s){return this._matrix[o][s]}},{key:"transpose",value:function(){var o=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=o,o=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=o,o=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=o,this}},{key:"matches",value:function(o){if(o.length!==9)throw new q("Should be length 9: "+o);for(var s=0;s<3;s++)for(var a=0;a<3;a++)if(!g.matches(this._matrix[s][a],o.charAt(3*s+a)))return!1;return!0}},{key:"add",value:function(o){for(var s=0;s<3;s++)for(var a=0;a<3;a++)this.setAtLeast(s,a,o.get(s,a))}},{key:"isDisjoint",value:function(){return this._matrix[H.INTERIOR][H.INTERIOR]===xt.FALSE&&this._matrix[H.INTERIOR][H.BOUNDARY]===xt.FALSE&&this._matrix[H.BOUNDARY][H.INTERIOR]===xt.FALSE&&this._matrix[H.BOUNDARY][H.BOUNDARY]===xt.FALSE}},{key:"isCrosses",value:function(o,s){return o===xt.P&&s===xt.L||o===xt.P&&s===xt.A||o===xt.L&&s===xt.A?g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&g.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR]):o===xt.L&&s===xt.P||o===xt.A&&s===xt.P||o===xt.A&&s===xt.L?g.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&g.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR]):o===xt.L&&s===xt.L&&this._matrix[H.INTERIOR][H.INTERIOR]===0}},{key:"interfaces_",get:function(){return[G]}}],[{key:"constructor_",value:function(){if(this._matrix=null,arguments.length===0)this._matrix=Array(3).fill().map((function(){return Array(3)})),this.setAll(xt.FALSE);else if(arguments.length===1){if(typeof arguments[0]=="string"){var o=arguments[0];g.constructor_.call(this),this.set(o)}else if(arguments[0]instanceof g){var s=arguments[0];g.constructor_.call(this),this._matrix[H.INTERIOR][H.INTERIOR]=s._matrix[H.INTERIOR][H.INTERIOR],this._matrix[H.INTERIOR][H.BOUNDARY]=s._matrix[H.INTERIOR][H.BOUNDARY],this._matrix[H.INTERIOR][H.EXTERIOR]=s._matrix[H.INTERIOR][H.EXTERIOR],this._matrix[H.BOUNDARY][H.INTERIOR]=s._matrix[H.BOUNDARY][H.INTERIOR],this._matrix[H.BOUNDARY][H.BOUNDARY]=s._matrix[H.BOUNDARY][H.BOUNDARY],this._matrix[H.BOUNDARY][H.EXTERIOR]=s._matrix[H.BOUNDARY][H.EXTERIOR],this._matrix[H.EXTERIOR][H.INTERIOR]=s._matrix[H.EXTERIOR][H.INTERIOR],this._matrix[H.EXTERIOR][H.BOUNDARY]=s._matrix[H.EXTERIOR][H.BOUNDARY],this._matrix[H.EXTERIOR][H.EXTERIOR]=s._matrix[H.EXTERIOR][H.EXTERIOR]}}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&typeof arguments[1]=="string"){var o=arguments[0],s=arguments[1];return s===xt.SYM_DONTCARE||s===xt.SYM_TRUE&&(o>=0||o===xt.TRUE)||s===xt.SYM_FALSE&&o===xt.FALSE||s===xt.SYM_P&&o===xt.P||s===xt.SYM_L&&o===xt.L||s===xt.SYM_A&&o===xt.A}if(typeof arguments[0]=="string"&&typeof arguments[1]=="string"){var a=arguments[0],f=arguments[1],m=new g(a);return m.matches(f)}}},{key:"isTrue",value:function(o){return o>=0||o===xt.TRUE}}]),g})(),Zd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(o){return o===null||o.length===0?null:(this.ensureCapacity(this._size+o.length),je.arraycopy(o,0,this._data,this._size,o.length),void(this._size+=o.length))}},{key:"ensureCapacity",value:function(o){if(o<=this._data.length)return null;var s=Math.max(o,2*this._data.length);this._data=tr.copyOf(this._data,s)}},{key:"toArray",value:function(){var o=new Array(this._size).fill(null);return je.arraycopy(this._data,0,o,0,this._size),o}},{key:"add",value:function(o){this.ensureCapacity(this._size+1),this._data[this._size]=o,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,arguments.length===0)g.constructor_.call(this,10);else if(arguments.length===1){var o=arguments[0];this._data=new Array(o).fill(null)}}}]),g})(),Wd=(function(){function g(){n(this,g)}return e(g,[{key:"getChainStartIndices",value:function(o){var s=0,a=new Zd(Math.trunc(o.length/2));a.add(s);do{var f=this.findChainEnd(o,s);a.add(f),s=f}while(sa?s:a}},{key:"getMinX",value:function(o){var s=this.pts[this.startIndex[o]].x,a=this.pts[this.startIndex[o+1]].x;return ss&&(f=1),this._depth[o][a]=f}}}},{key:"getDelta",value:function(o){return this._depth[o][ft.RIGHT]-this._depth[o][ft.LEFT]}},{key:"getLocation",value:function(o,s){return this._depth[o][s]<=0?H.EXTERIOR:H.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(arguments.length===1)for(var o=arguments[0],s=0;s<2;s++)for(var a=1;a<3;a++){var f=o.getLocation(s,a);f!==H.EXTERIOR&&f!==H.INTERIOR||(this.isNull(s,a)?this._depth[s][a]=g.depthAtLocation(f):this._depth[s][a]+=g.depthAtLocation(f))}else if(arguments.length===3){var m=arguments[0],P=arguments[1],S=arguments[2];S===H.INTERIOR&&this._depth[m][P]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map((function(){return Array(3)}));for(var o=0;o<2;o++)for(var s=0;s<3;s++)this._depth[o][s]=g.NULL_VALUE}},{key:"depthAtLocation",value:function(o){return o===H.EXTERIOR?0:o===H.INTERIOR?1:g.NULL_VALUE}}]),g})();Jc.NULL_VALUE=-1;var Vc=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var a=new Array(2).fill(null);return a[0]=this.pts[0],a[1]=this.pts[1],new s(a,Cn.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(a){this._isIsolated=a}},{key:"setName",value:function(a){this._name=a}},{key:"equals",value:function(a){if(!(a instanceof s))return!1;var f=a;if(this.pts.length!==f.pts.length)return!1;for(var m=!0,P=!0,S=this.pts.length,O=0;O0?this.pts[0]:null;if(arguments.length===1){var a=arguments[0];return this.pts[a]}}},{key:"print",value:function(a){a.print("edge "+this._name+": "),a.print("LINESTRING (");for(var f=0;f0&&a.print(","),a.print(this.pts[f].x+" "+this.pts[f].y);a.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(a){s.updateIM(this._label,a)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&this.pts.length===3&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(a){a.print("edge "+this._name+": ");for(var f=this.pts.length-1;f>=0;f--)a.print(this.pts[f]+" ");a.println("")}},{key:"getMonotoneChainEdge",value:function(){return this._mce===null&&(this._mce=new jd(this)),this._mce}},{key:"getEnvelope",value:function(){if(this._env===null){this._env=new ct;for(var a=0;a0&&a.append(","),a.append(this.pts[f].x+" "+this.pts[f].y);return a.append(") "+this._label+" "+this._depthDelta),a.toString()}},{key:"isPointwiseEqual",value:function(a){if(this.pts.length!==a.pts.length)return!1;for(var f=0;ff||this._maxyP;if(S)return!1;var O=this.intersectsToleranceSquare(o,s);return j.isTrue(!(S&&O),"Found bad envelope test"),O}},{key:"initCorners",value:function(o){var s=.5;this._minx=o.x-s,this._maxx=o.x+s,this._miny=o.y-s,this._maxy=o.y+s,this._corner[0]=new $(this._maxx,this._maxy),this._corner[1]=new $(this._minx,this._maxy),this._corner[2]=new $(this._minx,this._miny),this._corner[3]=new $(this._maxx,this._miny)}},{key:"intersects",value:function(o,s){return this._scaleFactor===1?this.intersectsScaled(o,s):(this.copyScaled(o,this._p0Scaled),this.copyScaled(s,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(o){return Math.round(o*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(o,s){s.x=this.scale(o.x),s.y=this.scale(o.y)}},{key:"getSafeEnvelope",value:function(){if(this._safeEnv===null){var o=g.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new ct(this._originalPt.x-o,this._originalPt.x+o,this._originalPt.y-o,this._originalPt.y+o)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(o,s){return this._li.computeIntersection(o,s,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,s,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,s,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,s,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}},{key:"intersectsToleranceSquare",value:function(o,s){var a=!1,f=!1;return this._li.computeIntersection(o,s,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(o,s,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(a=!0),this._li.computeIntersection(o,s,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(f=!0),this._li.computeIntersection(o,s,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!a||!f)||!!o.equals(this._pt)||!!s.equals(this._pt))))}},{key:"addSnappedNode",value:function(o,s){var a=o.getCoordinate(s),f=o.getCoordinate(s+1);return!!this.intersects(a,f)&&(o.addIntersection(this.getCoordinate(),s),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var o=arguments[0],s=arguments[1],a=arguments[2];if(this._originalPt=o,this._pt=o,this._scaleFactor=s,this._li=a,s<=0)throw new q("Scale factor must be non-zero");s!==1&&(this._pt=new $(this.scale(o.x),this.scale(o.y)),this._p0Scaled=new $,this._p1Scaled=new $),this.initCorners(this._pt)}}]),g})();ka.SAFE_ENV_EXPANSION_FACTOR=.75;var $d=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"select",value:function(){if(arguments.length!==1){if(arguments.length===2){var o=arguments[0],s=arguments[1];o.getLineSegment(s,this.selectedSegment),this.select(this.selectedSegment)}}}}],[{key:"constructor_",value:function(){this.selectedSegment=new En}}]),g})(),Wc=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"snap",value:function(){if(arguments.length===1){var o=arguments[0];return this.snap(o,null,-1)}if(arguments.length===3){var s=arguments[0],a=arguments[1],f=arguments[2],m=s.getSafeEnvelope(),P=new jc(s,a,f);return this._index.query(m,new((function(){function S(){n(this,S)}return e(S,[{key:"interfaces_",get:function(){return[Rc]}},{key:"visitItem",value:function(O){O.select(m,P)}}]),S})())),P.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var o=arguments[0];this._index=o}}]),g})(),jc=(function(g){r(s,g);var o=y(s);function s(){var a;return n(this,s),a=o.call(this),s.constructor_.apply(p(a),arguments),a}return e(s,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(arguments.length===2&&Number.isInteger(arguments[1])&&arguments[0]instanceof Fc))return v(i(s.prototype),"select",this).apply(this,arguments);var a=arguments[0],f=arguments[1],m=a.getContext();if(this._parentEdge===m&&(f===this._hotPixelVertexIndex||f+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(m,f)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var a=arguments[0],f=arguments[1],m=arguments[2];this._hotPixel=a,this._parentEdge=f,this._hotPixelVertexIndex=m}}]),s})($d);Wc.HotPixelSnapAction=jc;var Qd=(function(){function g(){n(this,g),g.constructor_.apply(this,arguments)}return e(g,[{key:"processIntersections",value:function(o,s,a,f){if(o===a&&s===f)return null;var m=o.getCoordinates()[s],P=o.getCoordinates()[s+1],S=a.getCoordinates()[f],O=a.getCoordinates()[f+1];if(this._li.computeIntersection(m,P,S,O),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var Y=0;Y=0;o--){try{this.bufferReducedPrecision(o)}catch(m){if(!(m instanceof Fe))throw m;this._saveException=m}if(this._resultGeometry!==null)return null}throw this._saveException}if(arguments.length===1){var s=arguments[0],a=g.precisionScaleFactor(this._argGeom,this._distance,s),f=new on(a);this.bufferFixedPrecision(f)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),this._resultGeometry!==null)return null;var o=this._argGeom.getFactory().getPrecisionModel();o.getType()===on.FIXED?this.bufferFixedPrecision(o):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(o){this._bufParams.setQuadrantSegments(o)}},{key:"bufferOriginalPrecision",value:function(){try{var o=new Hc(this._bufParams);this._resultGeometry=o.buffer(this._argGeom,this._distance)}catch(s){if(!(s instanceof z))throw s;this._saveException=s}}},{key:"getResultGeometry",value:function(o){return this._distance=o,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(o){this._bufParams.setEndCapStyle(o)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new L,this._resultGeometry=null,this._saveException=null,arguments.length===1){var o=arguments[0];this._argGeom=o}else if(arguments.length===2){var s=arguments[0],a=arguments[1];this._argGeom=s,this._bufParams=a}}},{key:"bufferOp",value:function(){if(arguments.length===2){var o=arguments[0],s=arguments[1],a=new g(o),f=a.getResultGeometry(s);return f}if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof ut&&typeof arguments[1]=="number"){var m=arguments[0],P=arguments[1],S=arguments[2],O=new g(m);O.setQuadrantSegments(S);var Y=O.getResultGeometry(P);return Y}if(arguments[2]instanceof L&&arguments[0]instanceof ut&&typeof arguments[1]=="number"){var nt=arguments[0],st=arguments[1],lt=arguments[2],yt=new g(nt,lt),mt=yt.getResultGeometry(st);return mt}}else if(arguments.length===4){var Bt=arguments[0],Jt=arguments[1],Zt=arguments[2],de=arguments[3],Ie=new g(Bt);Ie.setQuadrantSegments(Zt),Ie.setEndCapStyle(de);var $e=Ie.getResultGeometry(Jt);return $e}}},{key:"precisionScaleFactor",value:function(o,s,a){var f=o.getEnvelopeInternal(),m=Ke.max(Math.abs(f.getMaxX()),Math.abs(f.getMaxY()),Math.abs(f.getMinX()),Math.abs(f.getMinY()))+2*(s>0?s:0),P=a-Math.trunc(Math.log(m)/Math.log(10)+1);return Math.pow(10,P)}}]),g})();wi.CAP_ROUND=L.CAP_ROUND,wi.CAP_BUTT=L.CAP_FLAT,wi.CAP_FLAT=L.CAP_FLAT,wi.CAP_SQUARE=L.CAP_SQUARE,wi.MAX_PRECISION_DIGITS=12;var ey=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],Kc=(function(){function g(o){n(this,g),this.geometryFactory=o||new xi}return e(g,[{key:"read",value:function(o){var s,a=(s=typeof o=="string"?JSON.parse(o):o).type;if(!Tn[a])throw new Error("Unknown GeoJSON type: "+s.type);return ey.indexOf(a)!==-1?Tn[a].call(this,s.coordinates):a==="GeometryCollection"?Tn[a].call(this,s.geometries):Tn[a].call(this,s)}},{key:"write",value:function(o){var s=o.getGeometryType();if(!rr[s])throw new Error("Geometry is not supported");return rr[s].call(this,o)}}]),g})(),Tn={Feature:function(g){var o={};for(var s in g)o[s]=g[s];if(g.geometry){var a=g.geometry.type;if(!Tn[a])throw new Error("Unknown GeoJSON type: "+g.type);o.geometry=this.read(g.geometry)}return g.bbox&&(o.bbox=Tn.bbox.call(this,g.bbox)),o},FeatureCollection:function(g){var o={};if(g.features){o.features=[];for(var s=0;s{(function(n,t){typeof gl=="object"&&typeof pl!="undefined"?pl.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(gl,function(){"use strict";var n=function(r,i){if(r===void 0&&(r=[]),i===void 0&&(i=t),this.data=r,this.length=this.data.length,this.compare=i,this.length>0)for(var u=(this.length>>1)-1;u>=0;u--)this._down(u)};n.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var i=this,u=i.data,l=i.compare,c=u[r];r>0;){var h=r-1>>1,p=u[h];if(l(c,p)>=0)break;u[r]=p,r=h}u[r]=c},n.prototype._down=function(r){for(var i=this,u=i.data,l=i.compare,c=this.length>>1,h=u[r];r=0)break;u[r]=d,r=p}u[r]=h};function t(e,r){return er?1:0}return n})});var zh=pn((QM,qh)=>{qh.exports=function(t,e,r,i){var u=t[0],l=t[1],c=!1;r===void 0&&(r=0),i===void 0&&(i=e.length);for(var h=(i-r)/2,p=0,d=h-1;pl!=I>l&&u<(_-y)*(l-v)/(I-v)+y;F&&(c=!c)}return c}});var Uh=pn((tC,Xh)=>{Xh.exports=function(t,e,r,i){var u=t[0],l=t[1],c=!1;r===void 0&&(r=0),i===void 0&&(i=e.length);for(var h=i-r,p=0,d=h-1;pl!=I>l&&u<(_-y)*(l-v)/(I-v)+y;F&&(c=!c)}return c}});var Vh=pn((eC,ru)=>{var Yh=zh(),Jh=Uh();ru.exports=function(t,e,r,i){return e.length>0&&Array.isArray(e[0])?Jh(t,e,r,i):Yh(t,e,r,i)};ru.exports.nested=Jh;ru.exports.flat=Yh});var Zh=pn((iu,Hh)=>{(function(n,t){typeof iu=="object"&&typeof Hh!="undefined"?t(iu):typeof define=="function"&&define.amd?define(["exports"],t):t((n=n||self).predicates={})})(iu,function(n){"use strict";let e=33306690738754706e-32;function r(_,I,F,M,L){let C,q,V,X,G=I[0],J=M[0],k=0,N=0;J>G==J>-G?(C=G,G=I[++k]):(C=J,J=M[++N]);let T=0;if(k<_&&NG==J>-G?(V=C-((q=G+C)-G),G=I[++k]):(V=C-((q=J+C)-J),J=M[++N]),C=q,V!==0&&(L[T++]=V);k<_&&NG==J>-G?(V=C-((q=C+G)-(X=q-C))+(G-X),G=I[++k]):(V=C-((q=C+J)-(X=q-C))+(J-X),J=M[++N]),C=q,V!==0&&(L[T++]=V);for(;k<_;)V=C-((q=C+G)-(X=q-C))+(G-X),G=I[++k],C=q,V!==0&&(L[T++]=V);for(;N0!=V>0)return X;let G=Math.abs(q+V);return Math.abs(X)>=u*G?X:-(function(J,k,N,T,D,B,K){let w,R,x,b,E,A,z,W,j,tt,ot,rt,$,ht,ct,ut,H,vt,Nt=J-D,St=N-D,Ot=k-B,Tt=T-B;E=(ct=(W=Nt-(z=(A=134217729*Nt)-(A-Nt)))*(tt=Tt-(j=(A=134217729*Tt)-(A-Tt)))-((ht=Nt*Tt)-z*j-W*j-z*tt))-(ot=ct-(H=(W=Ot-(z=(A=134217729*Ot)-(A-Ot)))*(tt=St-(j=(A=134217729*St)-(A-St)))-((ut=Ot*St)-z*j-W*j-z*tt))),h[0]=ct-(ot+E)+(E-H),E=($=ht-((rt=ht+ot)-(E=rt-ht))+(ot-E))-(ot=$-ut),h[1]=$-(ot+E)+(E-ut),E=(vt=rt+ot)-rt,h[2]=rt-(vt-E)+(ot-E),h[3]=vt;let he=(function(Xn,Xt){let xn=Xt[0];for(let _n=1;_n=ft||-he>=ft||(w=J-(Nt+(E=J-Nt))+(E-D),x=N-(St+(E=N-St))+(E-D),R=k-(Ot+(E=k-Ot))+(E-B),b=T-(Tt+(E=T-Tt))+(E-B),w===0&&R===0&&x===0&&b===0)||(ft=c*K+e*Math.abs(he),(he+=Nt*b+Tt*w-(Ot*x+St*R))>=ft||-he>=ft))return he;E=(ct=(W=w-(z=(A=134217729*w)-(A-w)))*(tt=Tt-(j=(A=134217729*Tt)-(A-Tt)))-((ht=w*Tt)-z*j-W*j-z*tt))-(ot=ct-(H=(W=R-(z=(A=134217729*R)-(A-R)))*(tt=St-(j=(A=134217729*St)-(A-St)))-((ut=R*St)-z*j-W*j-z*tt))),v[0]=ct-(ot+E)+(E-H),E=($=ht-((rt=ht+ot)-(E=rt-ht))+(ot-E))-(ot=$-ut),v[1]=$-(ot+E)+(E-ut),E=(vt=rt+ot)-rt,v[2]=rt-(vt-E)+(ot-E),v[3]=vt;let gn=r(4,h,4,v,p);E=(ct=(W=Nt-(z=(A=134217729*Nt)-(A-Nt)))*(tt=b-(j=(A=134217729*b)-(A-b)))-((ht=Nt*b)-z*j-W*j-z*tt))-(ot=ct-(H=(W=Ot-(z=(A=134217729*Ot)-(A-Ot)))*(tt=x-(j=(A=134217729*x)-(A-x)))-((ut=Ot*x)-z*j-W*j-z*tt))),v[0]=ct-(ot+E)+(E-H),E=($=ht-((rt=ht+ot)-(E=rt-ht))+(ot-E))-(ot=$-ut),v[1]=$-(ot+E)+(E-ut),E=(vt=rt+ot)-rt,v[2]=rt-(vt-E)+(ot-E),v[3]=vt;let vn=r(gn,p,4,v,d);E=(ct=(W=w-(z=(A=134217729*w)-(A-w)))*(tt=b-(j=(A=134217729*b)-(A-b)))-((ht=w*b)-z*j-W*j-z*tt))-(ot=ct-(H=(W=R-(z=(A=134217729*R)-(A-R)))*(tt=x-(j=(A=134217729*x)-(A-x)))-((ut=R*x)-z*j-W*j-z*tt))),v[0]=ct-(ot+E)+(E-H),E=($=ht-((rt=ht+ot)-(E=rt-ht))+(ot-E))-(ot=$-ut),v[1]=$-(ot+E)+(E-ut),E=(vt=rt+ot)-rt,v[2]=rt-(vt-E)+(ot-E),v[3]=vt;let qe=r(vn,d,4,v,y);return y[qe-1]})(_,I,F,M,L,C,G)},n.orient2dfast=function(_,I,F,M,L,C){return(I-C)*(F-L)-(_-L)*(M-C)},Object.defineProperty(n,"__esModule",{value:!0})})});var tg=pn((nC,xl)=>{"use strict";var Wh=Li(),su=ml(),X0=Vh(),U0=Zh().orient2d;su.default&&(su=su.default);xl.exports=Qh;xl.exports.default=Qh;function Qh(n,t,e){t=Math.max(0,t===void 0?2:t),e=e||0;var r=Z0(n),i=new Wh(16);i.toBBox=function(C){return{minX:C[0],minY:C[1],maxX:C[0],maxY:C[1]}},i.compareMinX=function(C,q){return C[0]-q[0]},i.compareMinY=function(C,q){return C[1]-q[1]},i.load(n);for(var u=[],l=0,c;lu||c.push({node:d,dist:y})}for(;c.length&&!c.peek().node.children;){var v=c.pop(),_=v.node,I=vl(_,t,e),F=vl(_,r,i);if(v.dist=t.minX&&n[0]<=t.maxX&&n[1]>=t.minY&&n[1]<=t.maxY}function Kh(n,t,e){for(var r=Math.min(n[0],t[0]),i=Math.min(n[1],t[1]),u=Math.max(n[0],t[0]),l=Math.max(n[1],t[1]),c=e.search({minX:r,minY:i,maxX:u,maxY:l}),h=0;h0!=Gi(n,t,r)>0&&Gi(e,r,n)>0!=Gi(e,r,t)>0}function dl(n){var t=n.p,e=n.next.p;return n.minX=Math.min(t[0],e[0]),n.minY=Math.min(t[1],e[1]),n.maxX=Math.max(t[0],e[0]),n.maxY=Math.max(t[1],e[1]),n}function Z0(n){for(var t=n[0],e=n[0],r=n[0],i=n[0],u=0;ur[0]&&(r=l),l[1]i[1]&&(i=l)}var c=[t,e,r,i],h=c.slice();for(u=0;u1?(r=e[0],i=e[1]):c>0&&(r+=u*c,i+=l*c)}return u=n[0]-r,l=n[1]-i,u*u+l*l}function ou(n,t,e,r,i,u,l,c){var h=e-n,p=r-t,d=l-i,y=c-u,v=n-i,_=t-u,I=h*h+p*p,F=h*d+p*y,M=d*d+y*y,L=h*v+p*_,C=d*v+y*_,q=I*M-F*F,V,X,G,J,k=q,N=q;q===0?(X=0,k=1,J=C,N=M):(X=F*C-M*L,J=I*C-F*L,X<0?(X=0,J=C,N=M):X>k&&(X=k,J=C+F,N=M)),J<0?(J=0,-L<0?X=0:-L>I?X=k:(X=-L,k=I)):J>N&&(J=N,-L+F<0?X=0:-L+F>I?X=k:(X=-L+F,k=I)),V=X===0?0:X/k,G=J===0?0:J/N;var T=(1-V)*n+V*e,D=(1-V)*t+V*r,B=(1-G)*i+G*l,K=(1-G)*u+G*c,w=B-T,R=K-D;return w*w+R*R}function W0(n,t){return n[0]===t[0]?n[1]-t[1]:n[0]-t[0]}function j0(n){n.sort(W0);for(var t=[],e=0;e=2&&Gi(t[t.length-2],t[t.length-1],n[e])<=0;)t.pop();t.push(n[e])}for(var r=[],i=n.length-1;i>=0;i--){for(;r.length>=2&&Gi(r[r.length-2],r[r.length-1],n[i])<=0;)r.pop();r.push(n[i])}return r.pop(),t.pop(),t.concat(r)}});var Ll=pn((wC,mg)=>{"use strict";mg.exports={eudist:function(t,e,r){for(var i=t.length,u=0,l=0;l{"use strict";var dg=Ll(),nv=dg.eudist,rv=dg.dist;yg.exports={kmrand:function(t,e){for(var r={},i=[],u=e<<2,l=t.length,c=t[0].length>0;i.length0;){var h=t[Math.floor(Math.random()*l)],p=c?h.join("_"):""+h;r[p]||(r[p]=!0,i.push(h))}if(i.length0,c={},h=t[Math.floor(Math.random()*u)],p=l?h.join("_"):""+h;for(i.push(h),c[p]=!0;i.length{"use strict";var Ml=Ll(),Pg=vg(),iv=Ml.eudist,kC=Ml.mandist,IC=Ml.dist,ov=Pg.kmrand,sv=Pg.kmpp,xg=1e4;function _g(n,t,e){e=e||[];for(var r=0;r0,_=[];if(e)e=="kmrand"?i=ov(n,t):e=="kmpp"?i=sv(n,t):i=e;else for(var I={};i.length{(function(n,t){typeof Fl=="object"&&typeof Dl!="undefined"?Dl.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.JSBI=t())})(Fl,function(){"use strict";var n=Math.imul,t=Math.clz32;function e(T,D){(D==null||D>T.length)&&(D=T.length);for(var B=0,K=Array(D);B=T.length?{done:!0}:{done:!1,value:T[K++]}},e:function(E){throw E},f:w}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var R,x=!0,b=!1;return{s:function(){B=B.call(T)},n:function(){var E=B.next();return x=E.done,E},e:function(E){b=!0,R=E},f:function(){try{x||B.return==null||B.return()}finally{if(b)throw R}}}}function y(T){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(D){return D.__proto__||Object.getPrototypeOf(D)},y(T)}function v(T,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function");T.prototype=Object.create(D&&D.prototype,{constructor:{value:T,writable:!0,configurable:!0}}),Object.defineProperty(T,"prototype",{writable:!1}),D&&C(T,D)}function _(T){try{return Function.toString.call(T).indexOf("[native code]")!==-1}catch(D){return typeof T=="function"}}function I(){try{var T=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(D){}return(I=function(){return!!T})()}function F(T,D){var B=T==null?null:typeof Symbol!="undefined"&&T[Symbol.iterator]||T["@@iterator"];if(B!=null){var K,w,R,x,b=[],E=!0,A=!1;try{if(R=(B=B.call(T)).next,D===0){if(Object(B)!==B)return;E=!1}else for(;!(E=(K=R.call(B)).done)&&(b.push(K.value),b.length!==D);E=!0);}catch(z){A=!0,w=z}finally{try{if(!E&&B.return!=null&&(x=B.return(),Object(x)!==x))return}finally{if(A)throw w}}return b}}function M(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function L(T,D){if(D&&(typeof D=="object"||typeof D=="function"))return D;if(D!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return i(T)}function C(T,D){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(B,K){return B.__proto__=K,B},C(T,D)}function q(T,D){return r(T)||F(T,D)||J(T,D)||M()}function V(T,D){if(typeof T!="object"||!T)return T;var B=T[Symbol.toPrimitive];if(B!==void 0){var K=B.call(T,D||"default");if(typeof K!="object")return K;throw new TypeError("@@toPrimitive must return a primitive value.")}return(D==="string"?String:Number)(T)}function X(T){var D=V(T,"string");return typeof D=="symbol"?D:D+""}function G(T){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},G(T)}function J(T,D){if(T){if(typeof T=="string")return e(T,D);var B={}.toString.call(T).slice(8,-1);return B==="Object"&&T.constructor&&(B=T.constructor.name),B==="Map"||B==="Set"?Array.from(T):B==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(B)?e(T,D):void 0}}function k(T){var D=typeof Map=="function"?new Map:void 0;return k=function(B){function K(){return c(B,arguments,y(this).constructor)}if(B===null||!_(B))return B;if(typeof B!="function")throw new TypeError("Super expression must either be null or a function");if(D!==void 0){if(D.has(B))return D.get(B);D.set(B,K)}return K.prototype=Object.create(B.prototype,{constructor:{value:K,enumerable:!1,writable:!0,configurable:!0}}),C(K,B)},k(T)}var N=(function(T){var D=Math.abs,B=Math.max,K=Math.floor;function w(R,x){var b;if(l(this,w),b=u(this,w,[R]),b.sign=x,Object.setPrototypeOf(b,w.prototype),R>w.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return b}return v(w,T),p(w,[{key:"toDebugString",value:function(){var x,b=["BigInt["],E=d(this);try{for(E.s();!(x=E.n()).done;){var A=x.value;b.push((A&&(A>>>0).toString(16))+", ")}}catch(z){E.e(z)}finally{E.f()}return b.push("]"),b.join("")}},{key:"toString",value:function(){var x=0x||36this.length&&(E=this.length);for(var A=32767&x,z=x>>>15,W=0,j=b,tt=0;tt>>15,ht=w.__imul(rt,A),ct=w.__imul(rt,z),ut=w.__imul($,A),H=w.__imul($,z),vt=j+ht+W;W=vt>>>30,vt&=1073741823,vt+=((32767&ct)<<15)+((32767&ut)<<15),W+=vt>>>30,j=H+(ct>>>15)+(ut>>>15),this.__setDigit(tt,1073741823&vt)}if(W!==0||j!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(x,b,E){for(var A,z=0,W=0;W>>15,this.__setHalfDigit(b+W,32767&A);return z}},{key:"__inplaceSub",value:function(x,b,E){var A=E-1>>>1,z=0;if(1&b){b>>=1;for(var W=this.__digit(b),j=32767&W,tt=0;tt>>15)-(32767&ot)-z;z=1&rt>>>15,this.__setDigit(b+tt,(32767&rt)<<15|32767&j),W=this.__digit(b+tt+1),j=(32767&W)-(ot>>>15)-z,z=1&j>>>15}var $=x.__digit(tt),ht=(W>>>15)-(32767&$)-z;z=1&ht>>>15,this.__setDigit(b+tt,(32767&ht)<<15|32767&j);var ct=$>>>15;if(b+tt+1>=this.length)throw new RangeError("out of bounds");(1&E)==0&&(W=this.__digit(b+tt+1),j=(32767&W)-ct-z,z=1&j>>>15,this.__setDigit(b+x.length,1073709056&W|32767&j))}else{b>>=1;for(var ut=0;ut>>15;var St=(H>>>15)-(vt>>>15)-z;z=1&St>>>15,this.__setDigit(b+ut,(32767&St)<<15|32767&Nt)}var Ot=this.__digit(b+ut),Tt=x.__digit(ut),he=(32767&Ot)-(32767&Tt)-z;z=1&he>>>15;var ft=0;(1&E)==0&&(ft=(Ot>>>15)-(Tt>>>15)-z,z=1&ft>>>15),this.__setDigit(b+ut,(32767&ft)<<15|32767&he)}return z}},{key:"__inplaceRightShift",value:function(x){if(x!==0){for(var b,E=this.__digit(0)>>>x,A=this.length-1,z=0;z>>x;this.__setDigit(A,E)}}},{key:"__digit",value:function(x){return this[x]}},{key:"__unsignedDigit",value:function(x){return this[x]>>>0}},{key:"__setDigit",value:function(x,b){this[x]=0|b}},{key:"__setDigitGrow",value:function(x,b){this[x]=0|b}},{key:"__halfDigitLength",value:function(){var x=this.length;return 32767>=this.__unsignedDigit(x-1)?2*x-1:2*x}},{key:"__halfDigit",value:function(x){return 32767&this[x>>>1]>>>15*(1&x)}},{key:"__setHalfDigit",value:function(x,b){var E=x>>>1,A=this.__digit(E),z=1&x?32767&A|b<<15:1073709056&A|32767&b;this.__setDigit(E,z)}}],[{key:"BigInt",value:function(x){var b=Number.isFinite;if(typeof x=="number"){if(x===0)return w.__zero();if(w.__isOneDigitInt(x))return 0>x?w.__oneDigit(-x,!0):w.__oneDigit(x,!1);if(!b(x)||K(x)!==x)throw new RangeError("The number "+x+" cannot be converted to BigInt because it is not an integer");return w.__fromDouble(x)}if(typeof x=="string"){var E=w.__fromString(x);if(E===null)throw new SyntaxError("Cannot convert "+x+" to a BigInt");return E}if(typeof x=="boolean")return x===!0?w.__oneDigit(1,!1):w.__zero();if(G(x)==="object"){if(x.constructor===w)return x;var A=w.__toPrimitive(x);return w.BigInt(A)}throw new TypeError("Cannot convert "+x+" to a BigInt")}},{key:"toNumber",value:function(x){var b=x.length;if(b===0)return 0;if(b===1){var E=x.__unsignedDigit(0);return x.sign?-E:E}var A=x.__digit(b-1),z=w.__clz30(A),W=30*b-z;if(1024>>=12;var ht=rt-12,ct=12<=rt?0:tt<<20+rt,ut=20+rt;for(0>>30-ht,ct=tt<>>30-ut,ut-=30;var H=w.__decideRounding(x,ut,ot,tt);if((H===1||H===0&&(1&ct)==1)&&(ct=ct+1>>>0,ct===0&&($++,$>>>20!=0&&($=0,j++,1023=w.__kMaxLengthBits)throw new RangeError("BigInt too big");if(x.length===1&&x.__digit(0)===2){var A=1+(0|E/30),z=x.sign&&(1&E)!=0,W=new w(A,z);W.__initializeDigits();var j=1<>=1;E!==0;E>>=1)ot=w.multiply(ot,ot),(1&E)!=0&&(tt===null?tt=ot:tt=w.multiply(tt,ot));return tt}},{key:"multiply",value:function(x,b){if(x.length===0)return x;if(b.length===0)return b;var E=x.length+b.length;30<=x.__clzmsd()+b.__clzmsd()&&E--;var A=new w(E,x.sign!==b.sign);A.__initializeDigits();for(var z=0;zw.__absoluteCompare(x,b))return w.__zero();var E,A=x.sign!==b.sign,z=b.__unsignedDigit(0);if(b.length===1&&32767>=z){if(z===1)return A===x.sign?x:w.unaryMinus(x);E=w.__absoluteDivSmall(x,z,null)}else E=w.__absoluteDivLarge(x,b,!0,!1);return E.sign=A,E.__trim()}},{key:"remainder",value:function(x,b){if(b.length===0)throw new RangeError("Division by zero");if(0>w.__absoluteCompare(x,b))return x;var E=b.__unsignedDigit(0);if(b.length===1&&32767>=E){if(E===1)return w.__zero();var A=w.__absoluteModSmall(x,E);return A===0?w.__zero():w.__oneDigit(A,x.sign)}var z=w.__absoluteDivLarge(x,b,!1,!0);return z.sign=x.sign,z.__trim()}},{key:"add",value:function(x,b){var E=x.sign;return E===b.sign?w.__absoluteAdd(x,b,E):0<=w.__absoluteCompare(x,b)?w.__absoluteSub(x,b,E):w.__absoluteSub(b,x,!E)}},{key:"subtract",value:function(x,b){var E=x.sign;return E===b.sign?0<=w.__absoluteCompare(x,b)?w.__absoluteSub(x,b,E):w.__absoluteSub(b,x,!E):w.__absoluteAdd(x,b,E)}},{key:"leftShift",value:function(x,b){return b.length===0||x.length===0?x:b.sign?w.__rightShiftByAbsolute(x,b):w.__leftShiftByAbsolute(x,b)}},{key:"signedRightShift",value:function(x,b){return b.length===0||x.length===0?x:b.sign?w.__leftShiftByAbsolute(x,b):w.__rightShiftByAbsolute(x,b)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(x,b){return 0>w.__compareToBigInt(x,b)}},{key:"lessThanOrEqual",value:function(x,b){return 0>=w.__compareToBigInt(x,b)}},{key:"greaterThan",value:function(x,b){return 0x)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(x===0)return w.__zero();if(x>=w.__kMaxLengthBits)return b;var E=0|(x+29)/30;if(b.lengthx)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(x===0)return w.__zero();if(b.sign){if(x>w.__kMaxLengthBits)throw new RangeError("BigInt too big");return w.__truncateAndSubFromPowerOfTwo(x,b,!1)}if(x>=w.__kMaxLengthBits)return b;var E=0|(x+29)/30;if(b.length>>A))return b}return w.__truncateToNBits(x,b)}},{key:"ADD",value:function(x,b){if(x=w.__toPrimitive(x),b=w.__toPrimitive(b),typeof x=="string")return typeof b!="string"&&(b=b.toString()),x+b;if(typeof b=="string")return x.toString()+b;if(x=w.__toNumeric(x),b=w.__toNumeric(b),w.__isBigInt(x)&&w.__isBigInt(b))return w.add(x,b);if(typeof x=="number"&&typeof b=="number")return x+b;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(x,b){return w.__compare(x,b,0)}},{key:"LE",value:function(x,b){return w.__compare(x,b,1)}},{key:"GT",value:function(x,b){return w.__compare(x,b,2)}},{key:"GE",value:function(x,b){return w.__compare(x,b,3)}},{key:"EQ",value:function(x,b){for(;;){if(w.__isBigInt(x))return w.__isBigInt(b)?w.equal(x,b):w.EQ(b,x);if(typeof x=="number"){if(w.__isBigInt(b))return w.__equalToNumber(b,x);if(G(b)!=="object")return x==b;b=w.__toPrimitive(b)}else if(typeof x=="string"){if(w.__isBigInt(b))return x=w.__fromString(x),x!==null&&w.equal(x,b);if(G(b)!=="object")return x==b;b=w.__toPrimitive(b)}else if(typeof x=="boolean"){if(w.__isBigInt(b))return w.__equalToNumber(b,+x);if(G(b)!=="object")return x==b;b=w.__toPrimitive(b)}else if(G(x)==="symbol"){if(w.__isBigInt(b))return!1;if(G(b)!=="object")return x==b;b=w.__toPrimitive(b)}else if(G(x)==="object"){if(G(b)==="object"&&b.constructor!==w)return x==b;x=w.__toPrimitive(x)}else return x==b}}},{key:"NE",value:function(x,b){return!w.EQ(x,b)}},{key:"DataViewGetBigInt64",value:function(x,b){var E=2>>30),rt.__setDigit(2,tt>>>28),rt.__trim()}},{key:"DataViewSetBigInt64",value:function(x,b,E){var A=3>>2,2b)z=-b-1;else{if(E===0)return-1;E--,A=x.__digit(E),z=29}var W=1<x;w.__kBitConversionDouble[0]=x;var E,A=2047&w.__kBitConversionInts[w.__kBitConversionIntHigh]>>>20,z=A-1023,W=(0|z/30)+1,j=new w(W,b),tt=1048576,ot=1048575&w.__kBitConversionInts[w.__kBitConversionIntHigh]|tt,rt=w.__kBitConversionInts[w.__kBitConversionIntLow],$=20,ht=z%30,ct=0;if(ht<$){var ut=$-ht;ct=ut+32,E=ot>>>ut,ot=ot<<32-ut|rt>>>ut,rt<<=32-ut}else if(ht===$)ct=32,E=ot,ot=rt,rt=0;else{var H=ht-$;ct=32-H,E=ot<>>32-H,ot=rt<>>2,ot=ot<<30|rt>>>2,rt<<=30):E=0,j.__setDigit(vt,E);return j.__trim()}},{key:"__isWhitespace",value:function(x){return 13>=x&&9<=x||(159>=x?x==32:131071>=x?x==160||x==5760:196607>=x?(x&=131071,10>=x||x==40||x==41||x==47||x==95||x==4096):x==65279)}},{key:"__fromString",value:function(x){var b=11073741824/tt)return null;var rt=tt*j+ot>>>w.__kBitsPerCharTableShift,$=0|(rt+29)/30,ht=new w($,!1),ct=10>b?b:10,ut=10>=w.__kBitsPerCharTableShift;var H=[],vt=[],Nt=!1;do{for(var St,Ot=0,Tt=0;;){if(St=void 0,W-48>>>0>>0>>0>>0>>w.__kBitsPerCharTableShift)/30;ht.__inplaceMultiplyAdd(qe,vn,Xt)}while(!he)}if(z!==A){if(!w.__isWhitespace(W))return null;for(z++;z>>ot-W)}if(z!==0){if(A>=x.length)throw new Error("implementation bug");x.__setDigit(A++,z)}for(;A>>1)+(85&A),A=(51&A>>>2)+(51&A),A=(15&A>>>4)+(15&A);var z=A,W=b-1,j=x.__digit(E-1),tt=w.__clz30(j),ot=30*E-tt,rt=0|(ot+z-1)/z;if(x.sign&&rt++,268435456>>St,ut=30-St;ut>=z;)$[ht--]=w.__kConversionChars[ct&W],ct>>>=z,ut-=z}var Ot=(ct|j<>>z-ut;ct!==0;)$[ht--]=w.__kConversionChars[ct&W],ct>>>=z;if(x.sign&&($[ht--]="-"),ht!==-1)throw new Error("implementation bug");return $.join("")}},{key:"__toStringGeneric",value:function(x,b,E){var A=x.length;if(A===0)return"";if(A===1){var z=x.__unsignedDigit(0).toString(b);return E===!1&&x.sign&&(z="-"+z),z}var W=30*A-w.__clz30(x.__digit(A-1)),j=w.__kMaxBitsPerChar[b],tt=j-1,ot=W*w.__kBitsPerCharTableMultiplier;ot+=tt-1,ot=0|ot/tt;var rt,$,ht=ot+1>>1,ct=w.exponentiate(w.__oneDigit(b,!1),w.__oneDigit(ht,!1)),ut=ct.__unsignedDigit(0);if(ct.length===1&&32767>=ut){rt=new w(x.length,!1),rt.__initializeDigits();for(var H,vt=0,Nt=2*x.length-1;0<=Nt;Nt--)H=vt<<15|x.__halfDigit(Nt),rt.__setHalfDigit(Nt,0|H/ut),vt=0|H%ut;$=vt.toString(b)}else{var St=w.__absoluteDivLarge(x,ct,!0,!0);rt=St.quotient;var Ot=St.remainder.__trim();$=w.__toStringGeneric(Ot,b,!0)}rt.__trim();for(var Tt=w.__toStringGeneric(rt,b,!0);$.lengthA?w.__absoluteLess(E):0}},{key:"__compareToNumber",value:function(x,b){if(w.__isOneDigitInt(b)){var E=x.sign,A=0>b;if(E!==A)return w.__unequalSign(E);if(x.length===0){if(A)throw new Error("implementation bug");return b===0?0:-1}if(1z?w.__absoluteGreater(E):Wb;if(E!==A)return w.__unequalSign(E);if(b===0)throw new Error("implementation bug: should be handled elsewhere");if(x.length===0)return-1;w.__kBitConversionDouble[0]=b;var z=2047&w.__kBitConversionInts[w.__kBitConversionIntHigh]>>>20;if(z==2047)throw new Error("implementation bug: handled elsewhere");var W=z-1023;if(0>W)return w.__absoluteGreater(E);var j=x.length,tt=x.__digit(j-1),ot=w.__clz30(tt),rt=30*j-ot,$=W+1;if(rt<$)return w.__absoluteLess(E);if(rt>$)return w.__absoluteGreater(E);var ht=1048576,ct=1048576|1048575&w.__kBitConversionInts[w.__kBitConversionIntHigh],ut=w.__kBitConversionInts[w.__kBitConversionIntLow],H=20,vt=29-ot;if(vt!==(0|(rt-1)%30))throw new Error("implementation bug");var Nt,St=0;if(vt>>Ot,ct=ct<<32-Ot|ut>>>Ot,ut<<=32-Ot}else if(vt===H)St=32,Nt=ct,ct=ut,ut=0;else{var Tt=vt-H;St=32-Tt,Nt=ct<>>32-Tt,ct=ut<>>=0,Nt>>>=0,tt>Nt)return w.__absoluteGreater(E);if(tt>>2,ct=ct<<30|ut>>>2,ut<<=30):Nt=0;var ft=x.__unsignedDigit(he);if(ft>Nt)return w.__absoluteGreater(E);if(ftb&&x.__unsignedDigit(0)===D(b):w.__compareToDouble(x,b)===0}},{key:"__comparisonResultToBool",value:function(x,b){return b===0?0>x:b===1?0>=x:b===2?0b;case 3:return x>=b}if(w.__isBigInt(x)&&typeof b=="string")return b=w.__fromString(b),b!==null&&w.__comparisonResultToBool(w.__compareToBigInt(x,b),E);if(typeof x=="string"&&w.__isBigInt(b))return x=w.__fromString(x),x!==null&&w.__comparisonResultToBool(w.__compareToBigInt(x,b),E);if(x=w.__toNumeric(x),b=w.__toNumeric(b),w.__isBigInt(x)){if(w.__isBigInt(b))return w.__comparisonResultToBool(w.__compareToBigInt(x,b),E);if(typeof b!="number")throw new Error("implementation bug");return w.__comparisonResultToBool(w.__compareToNumber(x,b),E)}if(typeof x!="number")throw new Error("implementation bug");if(w.__isBigInt(b))return w.__comparisonResultToBool(w.__compareToNumber(b,x),2^E);if(typeof b!="number")throw new Error("implementation bug");return E===0?xb:E===3?x>=b:void 0}},{key:"__absoluteAdd",value:function(x,b,E){if(x.length>>30,W.__setDigit(tt,1073741823&z);for(;tt>>30,W.__setDigit(tt,1073741823&ot)}return tt>>30,z.__setDigit(j,1073741823&A);for(;j>>30,z.__setDigit(j,1073741823&tt)}return z.__trim()}},{key:"__absoluteAddOne",value:function(x,b){var E=2>>30,E.__setDigit(j,1073741823&z);return W!==0&&E.__setDigitGrow(A,1),E}},{key:"__absoluteSubOne",value:function(x,b){var E=x.length;b=b||E;for(var A,z=new w(b,!1),W=1,j=0;j>>30,z.__setDigit(j,1073741823&A);if(W!==0)throw new Error("implementation bug");for(var tt=E;ttA?0:x.__unsignedDigit(A)>b.__unsignedDigit(A)?1:-1}},{key:"__multiplyAccumulate",value:function(x,b,E,A){if(b!==0){for(var z=32767&b,W=b>>>15,j=0,tt=0,ot=0;ot>>15,ut=w.__imul(ht,z),H=w.__imul(ht,W),vt=w.__imul(ct,z),Nt=w.__imul(ct,W);rt+=tt+ut+j,j=rt>>>30,rt&=1073741823,rt+=((32767&H)<<15)+((32767&vt)<<15),j+=rt>>>30,tt=Nt+(H>>>15)+(vt>>>15),E.__setDigit(A,1073741823&rt)}for(;j!==0||tt!==0;A++){var St=E.__digit(A);St+=j+tt,tt=0,j=St>>>30,E.__setDigit(A,1073741823&St)}}}},{key:"__internalMultiplyAdd",value:function(x,b,E,A,z){for(var W=E,j=0,tt=0;tt>>15,b),ht=rt+((32767&$)<<15)+j+W;W=ht>>>30,j=$>>>15,z.__setDigit(tt,1073741823&ht)}if(z.length>A)for(z.__setDigit(A++,W+j);A>>0,j=0|W/b;A=0|W%b,W=(A<<15|x.__halfDigit(z-1))>>>0;var tt=0|W/b;A=0|W%b,E.__setDigit(z>>>1,j<<15|tt)}return E}},{key:"__absoluteModSmall",value:function(x,b){for(var E,A=0,z=2*x.length-1;0<=z;z--)E=(A<<15|x.__halfDigit(z))>>>0,A=0|E%b;return A}},{key:"__absoluteDivLarge",value:function(x,b,E,A){var z=b.__halfDigitLength(),W=b.length,j=x.__halfDigitLength()-z,tt=null;E&&(tt=new w(j+2>>>1,!1),tt.__initializeDigits());var ot=new w(z+2>>>1,!1);ot.__initializeDigits();var rt=w.__clz15(b.__halfDigit(z-1));0>>0;H=0|Nt/ht;for(var St=0|Nt%ht,Ot=b.__halfDigit(z-2),Tt=$.__halfDigit(ut+z-2);w.__imul(H,Ot)>>>0>(St<<16|Tt)>>>0&&(H--,St+=ht,!(32767>>1,ct|H))}if(A)return $.__inplaceRightShift(rt),E?{quotient:tt,remainder:$}:$;if(E)return tt;throw new Error("unreachable")}},{key:"__clz15",value:function(x){return w.__clz30(x)-15}},{key:"__specialLeftShift",value:function(x,b,E){var A=x.length,z=A+E,W=new w(z,!1);if(b===0){for(var j=0;j>>30-b;return 0E)throw new RangeError("BigInt too big");var A=0|E/30,z=E%30,W=x.length,j=z!==0&&x.__digit(W-1)>>>30-z!=0,tt=W+A+(j?1:0),ot=new w(tt,x.sign);if(z===0){for(var rt=0;rt>>30-z;if(j)ot.__setDigit(W+A,$);else if($!==0)throw new Error("implementation bug")}return ot.__trim()}},{key:"__rightShiftByAbsolute",value:function(x,b){var E=x.length,A=x.sign,z=w.__toShiftAmount(b);if(0>z)return w.__rightShiftByMaximum(A);var W=0|z/30,j=z%30,tt=E-W;if(0>=tt)return w.__rightShiftByMaximum(A);var ot=!1;if(A){var rt=(1<>>j,St=E-W-1,Ot=0;Ot>>j;ut.__setDigit(St,Nt)}return ot&&(ut=w.__absoluteAddOne(ut,!0,ut)),ut.__trim()}},{key:"__rightShiftByMaximum",value:function(x){return x?w.__oneDigit(1,!0):w.__zero()}},{key:"__toShiftAmount",value:function(x){if(1w.__kMaxLengthBits?-1:b}},{key:"__toPrimitive",value:function(x){var b=1>>tt}return A.__setDigit(z,j),A.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(x,b,E){for(var A=Math.min,z,W=0|(x+29)/30,j=new w(W,E),tt=0,ot=W-1,rt=0,$=A(ot,b.length);tt<$;tt++)z=0-b.__digit(tt)-rt,rt=1&z>>>30,j.__setDigit(tt,1073741823&z);for(;tt>>H;var vt=1<<32-H;ht=vt-ct-rt,ht&=vt-1}return j.__setDigit(ot,ht),j.__trim()}},{key:"__digitPow",value:function(x,b){for(var E=1;0>>=1,x*=x;return E}},{key:"__detectBigEndian",value:function(){return w.__kBitConversionDouble[0]=-0,w.__kBitConversionInts[0]!==0}},{key:"__isOneDigitInt",value:function(x){return(1073741823&x)===x}}])})(k(Array));return N.__kMaxLength=33554432,N.__kMaxLengthBits=N.__kMaxLength<<5,N.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],N.__kBitsPerCharTableShift=5,N.__kBitsPerCharTableMultiplier=1<>>0)/D)},N.__imul=n||function(T,D){return 0|T*D},N})});var Nm=pn((k3,fc)=>{"use strict";fc.exports=ua;fc.exports.default=ua;function ua(n,t,e){e=e||2;var r=t&&t.length,i=r?t[0]*e:n.length,u=Lm(n,0,i,e,!0),l=[];if(!u||u.next===u.prev)return l;var c,h,p,d,y,v,_;if(r&&(u=Qx(n,t,u,e)),n.length>80*e){c=p=n[0],h=d=n[1];for(var I=e;Ip&&(p=y),v>d&&(d=v);_=Math.max(p-c,d-h),_=_!==0?32767/_:0}return Wo(u,l,e,c,h,_,0),l}function Lm(n,t,e,r,i){var u,l;if(i===cc(n,t,e,r)>0)for(u=t;u=t;u-=r)l=Im(u,n[u],n[u+1],l);return l&&aa(l,l.next)&&(Ko(l),l=l.next),l}function hi(n,t){if(!n)return n;t||(t=n);var e=n,r;do if(r=!1,!e.steiner&&(aa(e,e.next)||Ne(e.prev,e,e.next)===0)){if(Ko(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Wo(n,t,e,r,i,u,l){if(n){!l&&u&&i1(n,r,i,u);for(var c=n,h,p;n.prev!==n.next;){if(h=n.prev,p=n.next,u?jx(n,r,i,u):Wx(n)){t.push(h.i/e|0),t.push(n.i/e|0),t.push(p.i/e|0),Ko(n),n=p.next,c=p.next;continue}if(n=p,n===c){l?l===1?(n=Kx(hi(n),t,e),Wo(n,t,e,r,i,u,2)):l===2&&$x(n,t,e,r,i,u):Wo(hi(n),t,e,r,i,u,1);break}}}}function Wx(n){var t=n.prev,e=n,r=n.next;if(Ne(t,e,r)>=0)return!1;for(var i=t.x,u=e.x,l=r.x,c=t.y,h=e.y,p=r.y,d=iu?i>l?i:l:u>l?u:l,_=c>h?c>p?c:p:h>p?h:p,I=r.next;I!==t;){if(I.x>=d&&I.x<=v&&I.y>=y&&I.y<=_&&ji(i,c,u,h,l,p,I.x,I.y)&&Ne(I.prev,I,I.next)>=0)return!1;I=I.next}return!0}function jx(n,t,e,r){var i=n.prev,u=n,l=n.next;if(Ne(i,u,l)>=0)return!1;for(var c=i.x,h=u.x,p=l.x,d=i.y,y=u.y,v=l.y,_=ch?c>p?c:p:h>p?h:p,M=d>y?d>v?d:v:y>v?y:v,L=ac(_,I,t,e,r),C=ac(F,M,t,e,r),q=n.prevZ,V=n.nextZ;q&&q.z>=L&&V&&V.z<=C;){if(q.x>=_&&q.x<=F&&q.y>=I&&q.y<=M&&q!==i&&q!==l&&ji(c,d,h,y,p,v,q.x,q.y)&&Ne(q.prev,q,q.next)>=0||(q=q.prevZ,V.x>=_&&V.x<=F&&V.y>=I&&V.y<=M&&V!==i&&V!==l&&ji(c,d,h,y,p,v,V.x,V.y)&&Ne(V.prev,V,V.next)>=0))return!1;V=V.nextZ}for(;q&&q.z>=L;){if(q.x>=_&&q.x<=F&&q.y>=I&&q.y<=M&&q!==i&&q!==l&&ji(c,d,h,y,p,v,q.x,q.y)&&Ne(q.prev,q,q.next)>=0)return!1;q=q.prevZ}for(;V&&V.z<=C;){if(V.x>=_&&V.x<=F&&V.y>=I&&V.y<=M&&V!==i&&V!==l&&ji(c,d,h,y,p,v,V.x,V.y)&&Ne(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function Kx(n,t,e){var r=n;do{var i=r.prev,u=r.next.next;!aa(i,u)&&Mm(i,r,r.next,u)&&jo(i,u)&&jo(u,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Ko(r),Ko(r.next),r=n=u),r=r.next}while(r!==n);return hi(r)}function $x(n,t,e,r,i,u){var l=n;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&u1(l,c)){var h=Cm(l,c);l=hi(l,l.next),h=hi(h,h.next),Wo(l,t,e,r,i,u,0),Wo(h,t,e,r,i,u,0);return}c=c.next}l=l.next}while(l!==n)}function Qx(n,t,e,r){var i=[],u,l,c,h,p;for(u=0,l=t.length;u=e.next.y&&e.next.y!==e.y){var c=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=r&&c>u&&(u=c,l=e.x=e.x&&e.x>=p&&r!==e.x&&ji(il.x||e.x===l.x&&r1(l,e)))&&(l=e,y=v)),e=e.next;while(e!==h);return l}function r1(n,t){return Ne(n.prev,n,t.prev)<0&&Ne(t.next,n,n.next)<0}function i1(n,t,e,r){var i=n;do i.z===0&&(i.z=ac(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,o1(i)}function o1(n){var t,e,r,i,u,l,c,h,p=1;do{for(e=n,n=null,u=null,l=0;e;){for(l++,r=e,c=0,t=0;t0||h>0&&r;)c!==0&&(h===0||!r||e.z<=r.z)?(i=e,e=e.nextZ,c--):(i=r,r=r.nextZ,h--),u?u.nextZ=i:n=i,i.prevZ=u,u=i;e=r}u.nextZ=null,p*=2}while(l>1);return n}function ac(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function s1(n){var t=n,e=n;do(t.x=(n-l)*(u-c)&&(n-l)*(r-c)>=(e-l)*(t-c)&&(e-l)*(u-c)>=(i-l)*(r-c)}function u1(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!a1(n,t)&&(jo(n,t)&&jo(t,n)&&l1(n,t)&&(Ne(n.prev,n,t.prev)||Ne(n,t.prev,t))||aa(n,t)&&Ne(n.prev,n,n.next)>0&&Ne(t.prev,t,t.next)>0)}function Ne(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function aa(n,t){return n.x===t.x&&n.y===t.y}function Mm(n,t,e,r){var i=sa(Ne(n,t,e)),u=sa(Ne(n,t,r)),l=sa(Ne(e,r,n)),c=sa(Ne(e,r,t));return!!(i!==u&&l!==c||i===0&&oa(n,e,t)||u===0&&oa(n,r,t)||l===0&&oa(e,n,r)||c===0&&oa(e,t,r))}function oa(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function sa(n){return n>0?1:n<0?-1:0}function a1(n,t){var e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&Mm(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function jo(n,t){return Ne(n.prev,n,n.next)<0?Ne(n,t,n.next)>=0&&Ne(n,n.prev,t)>=0:Ne(n,t,n.prev)<0||Ne(n,n.next,t)<0}function l1(n,t){var e=n,r=!1,i=(n.x+t.x)/2,u=(n.y+t.y)/2;do e.y>u!=e.next.y>u&&e.next.y!==e.y&&i<(e.next.x-e.x)*(u-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function Cm(n,t){var e=new lc(n.i,n.x,n.y),r=new lc(t.i,t.x,t.y),i=n.next,u=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,u.next=r,r.prev=u,r}function Im(n,t,e,r){var i=new lc(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ko(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function lc(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}ua.deviation=function(n,t,e,r){var i=t&&t.length,u=i?t[0]*e:n.length,l=Math.abs(cc(n,0,u,e));if(i)for(var c=0,h=t.length;c0&&(r+=n[i-1].length,e.holes.push(r))}return e}});var I1={};Tr(I1,{along:()=>hf,angle:()=>pf,applyFilter:()=>au,area:()=>ir,areaFactors:()=>hs,azimuthToBearing:()=>lf,bbox:()=>jt,bboxClip:()=>wf,bboxPolygon:()=>or,bearing:()=>In,bearingToAzimuth:()=>Rr,bezierSpline:()=>Sf,booleanClockwise:()=>Ii,booleanConcave:()=>kf,booleanContains:()=>Ff,booleanCrosses:()=>Ts,booleanDisjoint:()=>Ni,booleanEqual:()=>si,booleanIntersects:()=>Os,booleanOverlap:()=>Wf,booleanParallel:()=>Kf,booleanPointInPolygon:()=>Ct,booleanPointOnLine:()=>Yt,booleanTouches:()=>Qf,booleanValid:()=>nh,booleanWithin:()=>As,buffer:()=>Rh,center:()=>Ar,centerMean:()=>Di,centerMedian:()=>Gh,centerOfMass:()=>_l,centroid:()=>We,circle:()=>Bi,cleanCoords:()=>An,clone:()=>se,cloneProperties:()=>So,clusterEach:()=>bl,clusterReduce:()=>og,clusters:()=>lu,clustersDbscan:()=>pg,clustersKmeans:()=>Sg,collect:()=>Ig,collectionOf:()=>Qe,combine:()=>Lg,concave:()=>Vg,containsNumber:()=>Ca,convertArea:()=>ds,convertLength:()=>Vn,convex:()=>uu,coordAll:()=>ri,coordEach:()=>ne,coordReduce:()=>xs,createBins:()=>El,degreesToRadians:()=>_e,destination:()=>an,difference:()=>tp,dissolve:()=>pp,distance:()=>$t,distanceWeight:()=>Tu,earthRadius:()=>ke,ellipse:()=>Ru,envelope:()=>Au,explode:()=>Yr,factors:()=>gs,feature:()=>te,featureCollection:()=>pt,featureEach:()=>Dt,featureOf:()=>ni,featureReduce:()=>_s,filterProperties:()=>sg,findPoint:()=>vf,findSegment:()=>yf,flatten:()=>Do,flattenEach:()=>le,flattenReduce:()=>df,flip:()=>mp,geojsonRbush:()=>ii,geojsonType:()=>ff,geomEach:()=>ve,geomReduce:()=>Ps,geometry:()=>rf,geometryCollection:()=>ps,getCluster:()=>ig,getCoord:()=>Ut,getCoords:()=>Lt,getGeom:()=>Wt,getType:()=>be,greatCircle:()=>dp,helpers:()=>ys,hexGrid:()=>Bu,interpolate:()=>bp,intersect:()=>Jr,invariant:()=>vs,isNumber:()=>ye,isObject:()=>Ft,isobands:()=>kp,isolines:()=>Lp,kinks:()=>Mp,length:()=>Yu,lengthToDegrees:()=>ms,lengthToRadians:()=>Or,lineArc:()=>Ju,lineChunk:()=>Np,lineEach:()=>Ta,lineIntersect:()=>tn,lineOffset:()=>Rp,lineOverlap:()=>Rs,lineReduce:()=>Es,lineSegment:()=>yr,lineSlice:()=>Ap,lineSliceAlong:()=>Vu,lineSplit:()=>Mi,lineString:()=>At,lineStrings:()=>uf,lineToPolygon:()=>Gp,mask:()=>Bp,meta:()=>ws,midpoint:()=>qp,moranIndex:()=>zp,multiLineString:()=>kn,multiPoint:()=>Qr,multiPolygon:()=>He,nearestNeighborAnalysis:()=>bx,nearestPoint:()=>Vr,nearestPointOnLine:()=>mn,nearestPointToLine:()=>Yp,planepoint:()=>Jp,point:()=>wt,pointGrid:()=>qu,pointOnFeature:()=>Hp,pointToLineDistance:()=>Hi,pointToPolygonDistance:()=>Wu,points:()=>of,pointsWithinPolygon:()=>Zu,polygon:()=>Mt,polygonSmooth:()=>Kp,polygonTangents:()=>Qp,polygonToLine:()=>sr,polygonize:()=>jp,polygons:()=>sf,projection:()=>$u,propEach:()=>Na,propReduce:()=>mf,propertiesContainsFilter:()=>wl,quadratAnalysis:()=>Ox,radiansToDegrees:()=>un,radiansToLength:()=>ti,random:()=>ea,randomLineString:()=>lm,randomPoint:()=>um,randomPolygon:()=>am,randomPosition:()=>sm,rectangleGrid:()=>zu,rewind:()=>gm,rhumbBearing:()=>On,rhumbDestination:()=>Ur,rhumbDistance:()=>hr,round:()=>af,sample:()=>pm,sector:()=>dm,segmentEach:()=>Rn,segmentReduce:()=>bs,shortestPath:()=>xm,simplify:()=>bm,square:()=>Em,squareGrid:()=>Vi,standardDeviationalEllipse:()=>Sm,tag:()=>km,tesselate:()=>Rm,tin:()=>hu,toMercator:()=>nm,toWgs84:()=>rm,transformRotate:()=>Ou,transformScale:()=>ra,transformTranslate:()=>Am,triangleGrid:()=>Xu,truncate:()=>ks,union:()=>zm,unkinkPolygon:()=>Vm,validateBBox:()=>ei,validateId:()=>cf,voronoi:()=>ud});var ys={};Tr(ys,{areaFactors:()=>hs,azimuthToBearing:()=>lf,bearingToAzimuth:()=>Rr,convertArea:()=>ds,convertLength:()=>Vn,degreesToRadians:()=>_e,earthRadius:()=>ke,factors:()=>gs,feature:()=>te,featureCollection:()=>pt,geometry:()=>rf,geometryCollection:()=>ps,isNumber:()=>ye,isObject:()=>Ft,lengthToDegrees:()=>ms,lengthToRadians:()=>Or,lineString:()=>At,lineStrings:()=>uf,multiLineString:()=>kn,multiPoint:()=>Qr,multiPolygon:()=>He,point:()=>wt,points:()=>of,polygon:()=>Mt,polygons:()=>sf,radiansToDegrees:()=>un,radiansToLength:()=>ti,round:()=>af,validateBBox:()=>ei,validateId:()=>cf});var ke=63710088e-1,gs={centimeters:ke*100,centimetres:ke*100,degrees:360/(2*Math.PI),feet:ke*3.28084,inches:ke*39.37,kilometers:ke/1e3,kilometres:ke/1e3,meters:ke,metres:ke,miles:ke/1609.344,millimeters:ke*1e3,millimetres:ke*1e3,nauticalmiles:ke/1852,radians:1,yards:ke*1.0936},hs={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function te(n,t,e={}){let r={type:"Feature"};return(e.id===0||e.id)&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.properties=t||{},r.geometry=n,r}function rf(n,t,e={}){switch(n){case"Point":return wt(t).geometry;case"LineString":return At(t).geometry;case"Polygon":return Mt(t).geometry;case"MultiPoint":return Qr(t).geometry;case"MultiLineString":return kn(t).geometry;case"MultiPolygon":return He(t).geometry;default:throw new Error(n+" is invalid")}}function wt(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ye(n[0])||!ye(n[1]))throw new Error("coordinates must contain numbers");return te({type:"Point",coordinates:n},t,e)}function of(n,t,e={}){return pt(n.map(r=>wt(r,t)),e)}function Mt(n,t,e={}){for(let i of n){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let u=0;uMt(r,t)),e)}function At(n,t,e={}){if(n.length<2)throw new Error("coordinates must be an array of two or more positions");return te({type:"LineString",coordinates:n},t,e)}function uf(n,t,e={}){return pt(n.map(r=>At(r,t)),e)}function pt(n,t={}){let e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function kn(n,t,e={}){return te({type:"MultiLineString",coordinates:n},t,e)}function Qr(n,t,e={}){return te({type:"MultiPoint",coordinates:n},t,e)}function He(n,t,e={}){return te({type:"MultiPolygon",coordinates:n},t,e)}function ps(n,t,e={}){return te({type:"GeometryCollection",geometries:n},t,e)}function af(n,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");let e=Math.pow(10,t||0);return Math.round(n*e)/e}function ti(n,t="kilometers"){let e=gs[t];if(!e)throw new Error(t+" units is invalid");return n*e}function Or(n,t="kilometers"){let e=gs[t];if(!e)throw new Error(t+" units is invalid");return n/e}function ms(n,t){return un(Or(n,t))}function Rr(n){let t=n%360;return t<0&&(t+=360),t}function lf(n){return n=n%360,n>180?n-360:n<-180?n+360:n}function un(n){return n%(2*Math.PI)*180/Math.PI}function _e(n){return n%360*Math.PI/180}function Vn(n,t="kilometers",e="kilometers"){if(!(n>=0))throw new Error("length must be a positive number");return ti(Or(n,t),e)}function ds(n,t="meters",e="kilometers"){if(!(n>=0))throw new Error("area must be a positive number");let r=hs[t];if(!r)throw new Error("invalid original units");let i=hs[e];if(!i)throw new Error("invalid final units");return n/r*i}function ye(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Ft(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function ei(n){if(!n)throw new Error("bbox is required");if(!Array.isArray(n))throw new Error("bbox must be an Array");if(n.length!==4&&n.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");n.forEach(t=>{if(!ye(t))throw new Error("bbox must only contain numbers")})}function cf(n){if(!n)throw new Error("id is required");if(["string","number"].indexOf(typeof n)===-1)throw new Error("id must be a number or a string")}var vs={};Tr(vs,{collectionOf:()=>Qe,containsNumber:()=>Ca,featureOf:()=>ni,geojsonType:()=>ff,getCoord:()=>Ut,getCoords:()=>Lt,getGeom:()=>Wt,getType:()=>be});function Ut(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Lt(n){if(Array.isArray(n))return n;if(n.type==="Feature"){if(n.geometry!==null)return n.geometry.coordinates}else if(n.coordinates)return n.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ca(n){if(n.length>1&&ye(n[0])&&ye(n[1]))return!0;if(Array.isArray(n[0])&&n[0].length)return Ca(n[0]);throw new Error("coordinates must only contain numbers")}function ff(n,t,e){if(!t||!e)throw new Error("type and name required");if(!n||n.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+n.type)}function ni(n,t,e){if(!n)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!n||n.type!=="Feature"||!n.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!n.geometry||n.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+n.geometry.type)}function Qe(n,t,e){if(!n)throw new Error("No featureCollection passed");if(!e)throw new Error(".collectionOf() requires a name");if(!n||n.type!=="FeatureCollection")throw new Error("Invalid input to "+e+", FeatureCollection required");for(let r of n.features){if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!r.geometry||r.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+r.geometry.type)}}function Wt(n){return n.type==="Feature"?n.geometry:n}function be(n,t){return n.type==="FeatureCollection"?"FeatureCollection":n.type==="GeometryCollection"?"GeometryCollection":n.type==="Feature"&&n.geometry!==null?n.geometry.type:n.type}function In(n,t,e={}){if(e.final===!0)return cy(n,t);let r=Ut(n),i=Ut(t),u=_e(r[0]),l=_e(i[0]),c=_e(r[1]),h=_e(i[1]),p=Math.sin(l-u)*Math.cos(h),d=Math.cos(c)*Math.sin(h)-Math.sin(c)*Math.cos(h)*Math.cos(l-u);return un(Math.atan2(p,d))}function cy(n,t){let e=In(t,n);return e=(e+180)%360,e}function an(n,t,e,r={}){let i=Ut(n),u=_e(i[0]),l=_e(i[1]),c=_e(e),h=Or(t,r.units),p=Math.asin(Math.sin(l)*Math.cos(h)+Math.cos(l)*Math.sin(h)*Math.cos(c)),d=u+Math.atan2(Math.sin(c)*Math.sin(h)*Math.cos(l),Math.cos(h)-Math.sin(l)*Math.sin(p)),y=un(d),v=un(p);return i[2]!==void 0?wt([y,v,i[2]],r.properties):wt([y,v],r.properties)}function $t(n,t,e={}){var r=Ut(n),i=Ut(t),u=_e(i[1]-r[1]),l=_e(i[0]-r[0]),c=_e(r[1]),h=_e(i[1]),p=Math.pow(Math.sin(u/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(h);return ti(2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)),e.units)}function hf(n,t,e={}){let i=Wt(n).coordinates,u=0;for(let l=0;l=u&&l===i.length-1);l++)if(u>=t){let c=t-u;if(c){let h=In(i[l],i[l-1])-180;return an(i[l],c,h,e)}else return wt(i[l])}else u+=$t(i[l],i[l+1],e);return wt(i[i.length-1])}function On(n,t,e={}){let r;return e.final?r=gf(Ut(t),Ut(n)):r=gf(Ut(n),Ut(t)),r>180?-(360-r):r}function gf(n,t){let e=_e(n[1]),r=_e(t[1]),i=_e(t[0]-n[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);let u=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(e/2+Math.PI/4)),l=Math.atan2(i,u);return(un(l)+360)%360}function pf(n,t,e,r={}){if(!Ft(r))throw new Error("options is invalid");if(!n)throw new Error("startPoint is required");if(!t)throw new Error("midPoint is required");if(!e)throw new Error("endPoint is required");let i=n,u=t,l=e,c=Rr(r.mercator!==!0?In(u,i):On(u,i)),h=Rr(r.mercator!==!0?In(u,l):On(u,l));hri,coordEach:()=>ne,coordReduce:()=>xs,featureEach:()=>Dt,featureReduce:()=>_s,findPoint:()=>vf,findSegment:()=>yf,flattenEach:()=>le,flattenReduce:()=>df,geomEach:()=>ve,geomReduce:()=>Ps,lineEach:()=>Ta,lineReduce:()=>Es,propEach:()=>Na,propReduce:()=>mf,segmentEach:()=>Rn,segmentReduce:()=>bs});function ne(n,t,e){if(n!==null)for(var r,i,u,l,c,h,p,d=0,y=0,v,_=n.type,I=_==="FeatureCollection",F=_==="Feature",M=I?n.features.length:1,L=0;Lh||I>p||F>d){c=y,h=r,p=I,d=F,u=0;return}var M=At([c,y],e.properties);if(t(M,r,i,F,u)===!1)return!1;u++,c=y})===!1)return!1}}})}function bs(n,t,e){var r=e,i=!1;return Rn(n,function(u,l,c,h,p){i===!1&&e===void 0?r=u:r=t(r,u,l,c,h,p),i=!0}),r}function Ta(n,t){if(!n)throw new Error("geojson is required");le(n,function(e,r,i){if(e.geometry!==null){var u=e.geometry.type,l=e.geometry.coordinates;switch(u){case"LineString":if(t(e,r,i,0,0)===!1)return!1;break;case"Polygon":for(var c=0;ct+fy(e),0)}function fy(n){let t=0,e;switch(n.type){case"Polygon":return xf(n.coordinates);case"MultiPolygon":for(e=0;e0){t+=Math.abs(_f(n[0]));for(let e=1;e=t?(r+2)%t:r+2],c=i[0]*Oa,h=u[1]*Oa,p=l[0]*Oa;e+=(p-c)*Math.sin(h),r++}return e*hy}function jt(n,t={}){if(n.bbox!=null&&t.recompute!==!0)return n.bbox;let e=[1/0,1/0,-1/0,-1/0];return ne(n,r=>{e[0]>r[0]&&(e[0]=r[0]),e[1]>r[1]&&(e[1]=r[1]),e[2]t[2]&&(e|=2),n[1]t[3]&&(e|=8),e}function wf(n,t){let e=Wt(n),r=e.type,i=n.type==="Feature"?n.properties:{},u=e.coordinates;switch(r){case"LineString":case"MultiLineString":{let l=[];return r==="LineString"&&(u=[u]),u.forEach(c=>{Pf(c,t,l)}),l.length===1?At(l[0],i):kn(l,i)}case"Polygon":return Mt(Ef(u,t),i);case"MultiPolygon":return He(u.map(l=>Ef(l,t)),i);default:throw new Error("geometry "+r+" not supported")}}function Ef(n,t){let e=[];for(let r of n){let i=bf(r,t);i.length>0&&((i[0][0]!==i[i.length-1][0]||i[0][1]!==i[i.length-1][1])&&i.push(i[0]),i.length>=4&&e.push(i))}return e}function or(n,t={}){let e=Number(n[0]),r=Number(n[1]),i=Number(n[2]),u=Number(n[3]);if(n.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");let l=[e,r];return Mt([[l,[i,r],[i,u],[e,u],l]],t.properties,{bbox:n,id:t.id})}var Ss=class{constructor(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(let e=0;et&&(e.push(i),r=u)}return e}vector(t){let e=this.pos(t+10),r=this.pos(t-10);return{angle:180*Math.atan2(e.y-r.y,e.x-r.x)/3.14,speed:Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y)+(r.z-e.z)*(r.z-e.z))}}pos(t){let e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);let r=e/this.duration;if(r>=1)return this.points[this.length-1];let i=Math.floor((this.points.length-1)*r),u=(this.length-1)*r-i;return gy(u,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])}};function gy(n,t,e,r,i){let u=py(n);return{x:i.x*u[0]+r.x*u[1]+e.x*u[2]+t.x*u[3],y:i.y*u[0]+r.y*u[1]+e.y*u[2]+t.y*u[3],z:i.z*u[0]+r.z*u[1]+e.z*u[2]+t.z*u[3]}}function py(n){let t=n*n;return[t*n,3*t*(1-n),3*n*(1-n)*(1-n),(1-n)*(1-n)*(1-n)]}function Sf(n,t={}){let e=t.resolution||1e4,r=t.sharpness||.85,i=[],u=Wt(n).coordinates.map(p=>({x:p[0],y:p[1]})),l=new Ss({duration:e,points:u,sharpness:r}),c=p=>{var d=l.pos(p);Math.floor(p/100)%2===0&&i.push([d.x,d.y])};for(var h=0;h0}function kf(n){let t=Wt(n).coordinates;if(t[0].length<=4)return!1;let e=!1,r=t[0].length-1;for(let i=0;i0;else if(e!==p>0)return!0}return!1}function my(n,t){var e=0,r=0,i=0,u=0,l=0,c=0,h=0,p=0,d=null,y=null,v=n[0],_=n[1],I=t.length;for(e;e0&&p>0){d=y,c=p,l=d[0]-v;continue}if(h=y[0]-n[0],p>0&&c<=0){if(u=l*p-h*c,u>0)i=i+1;else if(u===0)return 0}else if(c>0&&p<=0){if(u=l*p-h*c,u<0)i=i+1;else if(u===0)return 0}else if(p===0&&c<0){if(u=l*p-h*c,u===0)return 0}else if(c===0&&p<0){if(u=l*p-h*c,u===0)return 0}else if(c===0&&p===0){if(h<=0&&l>=0)return 0;if(l<=0&&h>=0)return 0}d=y,c=p,l=h}}return i%2!==0}var If=my;function Ct(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");let r=Ut(n),i=Wt(t),u=i.type,l=t.bbox,c=i.coordinates;if(l&&dy(r,l)===!1)return!1;u==="Polygon"&&(c=[c]);let h=!1;for(var p=0;p=n[0]&&t[3]>=n[1]}function Yt(n,t,e={}){let r=Ut(n),i=Lt(t);for(let u=0;ui)return!1}else if(F!==0)return!1;if(Math.abs(_)===Math.abs(I)&&Math.abs(_)===0)return r?!1:e[0]===n[0]&&e[1]===n[1];if(r){if(r==="start")return Math.abs(_)>=Math.abs(I)?_>0?c0?h=Math.abs(I)?_>0?c<=u&&u0?h<=l&&l=Math.abs(I)?_>0?c0?h=Math.abs(I)?_>0?c<=u&&u<=p:p<=u&&u<=c:I>0?h<=l&&l<=d:d<=l&&l<=h;return!1}var Lf=Jn(Li());function Da(n){var t;if(n.bbox)t=n.bbox;else if(Array.isArray(n)&&n.length===4)t=n;else if(Array.isArray(n)&&n.length===6)t=[n[0],n[1],n[3],n[4]];else if(n.type==="Feature")t=jt(n);else if(n.type==="FeatureCollection")t=jt(n);else throw new Error("invalid geojson");return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}}var Ga=class{constructor(t=9){et(this,"tree");this.tree=new Lf.default(t),this.tree.toBBox=Da}insert(t){if(t.type!=="Feature")throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:jt(t),this.tree.insert(t),this}load(t){var e=[];return Array.isArray(t)?t.forEach(function(r){if(r.type!=="Feature")throw new Error("invalid features");r.bbox=r.bbox?r.bbox:jt(r),e.push(r)}):Dt(t,function(r){if(r.type!=="Feature")throw new Error("invalid features");r.bbox=r.bbox?r.bbox:jt(r),e.push(r)}),this.tree.load(e),this}remove(t,e){if(t.type!=="Feature")throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:jt(t),this.tree.remove(t,e),this}clear(){return this.tree.clear(),this}search(t){var e=this.tree.search(Da(t));return pt(e)}collides(t){return this.tree.collides(Da(t))}all(){let t=this.tree.all();return pt(t)}toJSON(){return this.tree.toJSON()}fromJSON(t){return this.tree.fromJSON(t),this}};function ii(n){return new Ga(n)}function ks(n,t){if(t=t!=null?t:{},!Ft(t))throw new Error("options is invalid");var e=t.precision,r=t.coordinates,i=t.mutate;if(e=e==null||isNaN(e)?6:e,r=r==null||isNaN(r)?3:r,!n)throw new Error(" is required");if(typeof e!="number")throw new Error(" must be a number");if(typeof r!="number")throw new Error(" must be a number");(i===!1||i===void 0)&&(n=JSON.parse(JSON.stringify(n)));var u=Math.pow(10,e);return ne(n,function(l){vy(l,u,r)}),n}function vy(n,t,e){n.length>e&&n.splice(e,n.length);for(var r=0;r{xy(e,t)}),pt(t)}function xy(n,t){let e=[],r=n.geometry;if(r!==null){switch(r.type){case"Polygon":e=Lt(r);break;case"LineString":e=[Lt(r)]}e.forEach(i=>{_y(i,n.properties).forEach(l=>{l.id=t.length,t.push(l)})})}}function _y(n,t){let e=[];return n.reduce((r,i)=>{let u=At([r,i],t);return u.bbox=Py(r,i),e.push(u),i}),e}function Py(n,t){let e=n[0],r=n[1],i=t[0],u=t[1],l=ei?e:i,p=r>u?r:u;return[l,c,h,p]}var Cs=class{constructor(t=[],e=by){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let u=t-1>>1,l=e[u];if(r(i,l)>=0)break;e[t]=l,t=u}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,u=e[t];for(;t=0)break;e[t]=c,t=l}e[t]=u}};function by(n,t){return nt?1:0}function Cf(n,t){return n.p.x>t.p.x?1:n.p.xt.p.y?1:-1:1}function Ey(n,t){return n.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:n.rightSweepEvent.p.x0?(d.isLeftEndpoint=!0,p.isLeftEndpoint=!1):(p.isLeftEndpoint=!0,d.isLeftEndpoint=!1),t.push(p),t.push(d),l=c,Ms=Ms+1}}Is=Is+1}var Ba=class{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}};function Sy(n,t){if(n===null||t===null||n.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.rightSweepEvent)||n.leftSweepEvent.isSamePoint(t.leftSweepEvent)||n.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;let e=n.leftSweepEvent.p.x,r=n.leftSweepEvent.p.y,i=n.rightSweepEvent.p.x,u=n.rightSweepEvent.p.y,l=t.leftSweepEvent.p.x,c=t.leftSweepEvent.p.y,h=t.rightSweepEvent.p.x,p=t.rightSweepEvent.p.y,d=(p-c)*(i-e)-(h-l)*(u-r),y=(h-l)*(r-c)-(p-c)*(e-l),v=(i-e)*(r-c)-(u-r)*(e-l);if(d===0)return!1;let _=y/d,I=v/d;if(_>=0&&_<=1&&I>=0&&I<=1){let F=e+_*(i-e),M=r+_*(u-r);return[F,M]}return!1}function ky(n,t){t=t||!1;let e=[],r=new Cs([],Ey);for(;n.length;){let i=n.pop();if(i.isLeftEndpoint){let u=new Ba(i);for(let l=0;l{let d=p.join(",");h[d]||(h[d]=!0,c.push(p))})}else c=l;return pt(c.map(h=>wt(h)))}function mn(n,t,e={}){if(!n||!t)throw new Error("lines and inputPoint are required arguments");let r=Ut(t),i=wt([1/0,1/0],{lineStringIndex:-1,segmentIndex:-1,totalDistance:-1,lineDistance:-1,segmentDistance:-1,pointDistance:1/0,multiFeatureIndex:-1,index:-1,location:-1,dist:1/0}),u=0,l=0,c=-1;return le(n,function(h,p,d){c!==d&&(c=d,l=0);let y=Lt(h),v=y.length-2;for(let _=0;_0?[[...t],!0]:[[...e],!1];let c=fo(l,u);if(c[0]===0&&c[1]===0&&c[2]===0)return[[...t],!0];let h=fo(c,l),p=Of(h),d=[-p[0],-p[1],-p[2]],y=oi(u,p)>oi(u,d)?p:d,v=Of(l),_=oi(fo(r,y),v),I=oi(fo(y,i),v);return _>=0&&I>=0?[My(y),!1]:oi(r,u)>oi(i,u)?[[...n],!1]:[[...t],!0]}function Mi(n,t){if(!n)throw new Error("line is required");if(!t)throw new Error("splitter is required");let e=be(n),r=be(t);if(e!=="LineString")throw new Error("line must be LineString");if(r==="FeatureCollection")throw new Error("splitter cannot be a FeatureCollection");if(r==="GeometryCollection")throw new Error("splitter cannot be a GeometryCollection");var i=ks(t,{precision:7});switch(n.type!=="Feature"&&(n=te(n)),r){case"Point":return Xa(n,i);case"MultiPoint":return Rf(n,i);case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":return Rf(n,tn(n,i,{ignoreSelfIntersections:!0}))}}function Rf(n,t){var e=[],r=ii();return le(t,function(i){if(e.forEach(function(c,h){c.id=h}),!e.length)e=Xa(n,i).features,r.load(pt(e));else{var u=r.search(i);if(u.features.length){var l=Af(i,u);e=e.filter(function(c){return c.id!==l.id}),r.remove(l),Dt(Xa(l,i),function(c){e.push(c),r.insert(c)})}}}),pt(e)}function Xa(n,t){var e=[],r=Lt(n)[0],i=Lt(n)[n.geometry.coordinates.length-1];if(za(r,Ut(t))||za(i,Ut(t)))return pt([n]);var u=ii(),l=yr(n);u.load(l);var c=u.search(t);if(!c.features.length)return pt([n]);var h=Af(t,c),p=[r],d=_s(l,function(y,v,_){var I=Lt(v)[1],F=Ut(t);return _===h.id?(y.push(F),e.push(At(y)),za(F,I)?[F]:[F,I]):(y.push(I),y)},p);return d.length>1&&e.push(At(d)),pt(e)}function Af(n,t){if(!t.features.length)throw new Error("lines must contain features");if(t.features.length===1)return t.features[0];var e,r=1/0;return Dt(t,function(i){var u=mn(i,n),l=u.properties.dist;lUa({type:"Polygon",coordinates:e},t))}function Ty(n,t){return t.coordinates.every(e=>Ua(n,{type:"Polygon",coordinates:e}))}function Oy(n,t){let e,r=!1;for(e=0;et[0]||n[2]t[1]||n[3]{u.push(Gf(l,i))}),pt(u)}function Gf(n,t){return n.length>1?kn(n,t):At(n[0],t)}var Uy=Object.defineProperty,Ci=(n,t)=>Uy(n,"name",{value:t,configurable:!0}),qf=class{constructor(t){this.direction=!1,this.compareProperties=!0;var e,r,i;this.precision=10**-((e=t==null?void 0:t.precision)!=null?e:17),this.direction=(r=t==null?void 0:t.direction)!=null?r:!1,this.compareProperties=(i=t==null?void 0:t.compareProperties)!=null?i:!0}compare(t,e){if(t.type!==e.type||!ho(t,e))return!1;switch(t.type){case"Point":return this.compareCoord(t.coordinates,e.coordinates);case"LineString":return this.compareLine(t.coordinates,e.coordinates);case"Polygon":return this.comparePolygon(t,e);case"GeometryCollection":return this.compareGeometryCollection(t,e);case"Feature":return this.compareFeature(t,e);case"FeatureCollection":return this.compareFeatureCollection(t,e);default:if(t.type.startsWith("Multi")){let r=Ja(t),i=Ja(e);return r.every(u=>i.some(l=>this.compare(u,l)))}}return!1}compareCoord(t,e){return t.length===e.length&&t.every((r,i)=>Math.abs(r-e[i])=0&&(r=[].concat(t.slice(i,t.length),t.slice(1,i+1))),r}comparePath(t,e){return t.every((r,i)=>this.compareCoord(r,e[i]))}comparePolygon(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){let r=t.coordinates.slice(1,t.coordinates.length),i=e.coordinates.slice(1,e.coordinates.length);return r.every(u=>i.some(l=>this.compareLine(u,l,1,!0)))}return!1}compareGeometryCollection(t,e){return ho(t.geometries,e.geometries)&&this.compareBBox(t,e)&&t.geometries.every((r,i)=>this.compare(r,e.geometries[i]))}compareFeature(t,e){return t.id===e.id&&(this.compareProperties?Va(t.properties,e.properties):!0)&&this.compareBBox(t,e)&&this.compare(t.geometry,e.geometry)}compareFeatureCollection(t,e){return ho(t.features,e.features)&&this.compareBBox(t,e)&&t.features.every((r,i)=>this.compare(r,e.features[i]))}compareBBox(t,e){return!t.bbox&&!e.bbox||(t.bbox&&e.bbox?this.compareCoord(t.bbox,e.bbox):!1)}};Ci(qf,"GeojsonEquality");var Yy=qf;function ho(n,t){return n.coordinates?n.coordinates.length===t.coordinates.length:n.length===t.length}Ci(ho,"sameLength");function Ja(n){return n.coordinates.map(t=>({type:n.type.replace("Multi",""),coordinates:t}))}Ci(Ja,"explode");function go(n,t,e){return new Yy(e).compare(n,t)}Ci(go,"geojsonEquality");function Va(n,t){if(n===null&&t===null)return!0;if(n===null||t===null)return!1;let e=Object.keys(n),r=Object.keys(t);if(e.length!==r.length)return!1;for(var i of e){let u=n[i],l=t[i],c=Bf(u)&&Bf(l);if(c&&!Va(u,l)||!c&&u!==l)return!1}return!0}Ci(Va,"equal");var Bf=Ci(n=>n!=null&&typeof n=="object","isObject");function An(n,t={}){var e=typeof t=="object"?t.mutate:t;if(!n)throw new Error("geojson is required");var r=be(n),i=[];switch(r){case"LineString":i=Ha(n,r);break;case"MultiLineString":case"Polygon":Lt(n).forEach(function(l){i.push(Ha(l,r))});break;case"MultiPolygon":Lt(n).forEach(function(l){var c=[];l.forEach(function(h){c.push(Ha(h,r))}),i.push(c)});break;case"Point":return n;case"MultiPoint":var u={};Lt(n).forEach(function(l){var c=l.join("-");Object.prototype.hasOwnProperty.call(u,c)||(i.push(l),u[c]=!0)});break;default:throw new Error(r+" geometry not supported")}return n.coordinates?e===!0?(n.coordinates=i,n):{type:r,coordinates:i}:e===!0?(n.geometry.coordinates=i,n):te({type:r,coordinates:i},n.properties,{bbox:n.bbox,id:n.id})}function Ha(n,t){let e=Lt(n);if(e.length===2&&!zf(e[0],e[1]))return e;let r=[],i=0,u=1,l=2;for(r.push(e[i]);l=0))throw new Error("precision must be a positive number");let i=Wt(n).type,u=Wt(t).type;return i!==u?!1:go(An(n),An(t),{precision:r})}function Ts(n,t){var e=Wt(n),r=Wt(t),i=e.type,u=r.type;switch(i){case"MultiPoint":switch(u){case"LineString":return Xf(e,r);case"Polygon":return Yf(e,r);default:throw new Error("feature2 "+u+" geometry not supported")}case"LineString":switch(u){case"MultiPoint":return Xf(r,e);case"LineString":return Jy(e,r);case"Polygon":return Uf(e,r);default:throw new Error("feature2 "+u+" geometry not supported")}case"Polygon":switch(u){case"MultiPoint":return Yf(r,e);case"LineString":return Uf(r,e);default:throw new Error("feature2 "+u+" geometry not supported")}default:throw new Error("feature1 "+i+" geometry not supported")}}function Xf(n,t){for(var e=!1,r=!1,i=n.coordinates.length,u=0;u0}function Yf(n,t){var e=!1,r=!1,i=n.coordinates.length;for(let u=0;u=Math.abs(c)?l>0?n[0]<=e[0]&&e[0]<=t[0]:t[0]<=e[0]&&e[0]<=n[0]:c>0?n[1]<=e[1]&&e[1]<=t[1]:t[1]<=e[1]&&e[1]<=n[1]:Math.abs(l)>=Math.abs(c)?l>0?n[0]0?n[1]{le(t,u=>{if(r===!1)return!1;r=Hy(i.geometry,u.geometry,e)})}),r}function Hy(n,t,e){switch(n.type){case"Point":switch(t.type){case"Point":return!Ky(n.coordinates,t.coordinates);case"LineString":return!Jf(t,n);case"Polygon":return!Ct(n,t)}break;case"LineString":switch(t.type){case"Point":return!Jf(n,t);case"LineString":return!Zy(n,t,e);case"Polygon":return!Vf(t,n,e)}break;case"Polygon":switch(t.type){case"Point":return!Ct(t,n);case"LineString":return!Vf(n,t,e);case"Polygon":return!Wy(t,n,e)}}return!1}function Jf(n,t){for(let e=0;e0}function Vf(n,t,e){for(let i of t.coordinates)if(Ct(i,n))return!0;return tn(t,sr(n),{ignoreSelfIntersections:e}).features.length>0}function Wy(n,t,e){for(let i of n.coordinates[0])if(Ct(i,t))return!0;for(let i of t.coordinates[0])if(Ct(i,n))return!0;return tn(sr(n),sr(t),{ignoreSelfIntersections:e}).features.length>0}function jy(n,t,e){let r=e[0]-n[0],i=e[1]-n[1],u=t[0]-n[0],l=t[1]-n[1];return r*l-i*u!==0?!1:Math.abs(u)>=Math.abs(l)?u>0?n[0]<=e[0]&&e[0]<=t[0]:t[0]<=e[0]&&e[0]<=n[0]:l>0?n[1]<=e[1]&&e[1]<=t[1]:t[1]<=e[1]&&e[1]<=n[1]}function Ky(n,t){return n[0]===t[0]&&n[1]===t[1]}function Os(n,t,{ignoreSelfIntersections:e=!0}={}){let r=!1;return le(n,i=>{le(t,u=>{if(r===!0)return!0;r=!Ni(i.geometry,u.geometry,{ignoreSelfIntersections:e})})}),r}var Ti=Jn(Zf());function Rs(n,t,e={}){if(e=e||{},!Ft(e))throw new Error("options is invalid");var r=e.tolerance||0,i=[],u=ii();let l=yr(n);u.load(l);var c;let h=[];return Rn(t,function(p){var d=!1;p&&(Dt(u.search(p),function(y){if(d===!1){var v=Lt(p).sort(),_=Lt(y).sort();if((0,Ti.default)(v,_))d=!0,c?c=Za(c,p)||c:c=p;else if(r===0?Yt(v[0],y)&&Yt(v[1],y):mn(y,v[0]).properties.dist<=r&&mn(y,v[1]).properties.dist<=r)d=!0,c?c=Za(c,p)||c:c=p;else if(r===0?Yt(_[0],p)&&Yt(_[1],p):mn(p,_[0]).properties.dist<=r&&mn(p,_[1]).properties.dist<=r)if(c){let I=Za(c,y);I?c=I:h.push(y)}else c=y}}),d===!1&&c&&(i.push(c),h.length&&(i=i.concat(h),h=[]),c=void 0))}),c&&i.push(c),pt(i)}function Za(n,t){var e=Lt(t),r=Lt(n),i=r[0],u=r[r.length-1],l=n.geometry.coordinates;if((0,Ti.default)(e[0],i))l.unshift(e[1]);else if((0,Ti.default)(e[0],u))l.push(e[1]);else if((0,Ti.default)(e[1],i))l.unshift(e[0]);else if((0,Ti.default)(e[1],u))l.push(e[0]);else return;return n}function Wf(n,t){let e=Wt(n),r=Wt(t),i=e.type,u=r.type;if(i==="MultiPoint"&&u!=="MultiPoint"||(i==="LineString"||i==="MultiLineString")&&u!=="LineString"&&u!=="MultiLineString"||(i==="Polygon"||i==="MultiPolygon")&&u!=="Polygon"&&u!=="MultiPolygon")throw new Error("features must be of the same type");if(i==="Point")throw new Error("Point geometry not supported");if(go(n,t,{precision:6}))return!1;let l=0;switch(i){case"MultiPoint":for(var c=0;c{Rn(t,v=>{Rs(y,v).features.length&&l++})});break;case"Polygon":case"MultiPolygon":Rn(n,y=>{Rn(t,v=>{tn(y,v).features.length&&l++})});break}return l>0}function Kf(n,t){if(!n)throw new Error("line1 is required");if(!t)throw new Error("line2 is required");var e=jf(n,"line1");if(e!=="LineString")throw new Error("line1 must be a LineString");var r=jf(t,"line2");if(r!=="LineString")throw new Error("line2 must be a LineString");for(var i=yr(An(n)).features,u=yr(An(t)).features,l=0;l1;case"MultiPoint":for(var i=0;i0&&tn(Mt([r[0]]),Mt([r[i]])).features.length>1)return!1;return!0;case"MultiPolygon":for(var i=0;i0&&tn(Mt([u[0]]),Mt([u[l]])).features.length>1)return!1;return!0;default:return!1}}function th(n){return n[0][0]===n[n.length-1][0]&&n[0][1]===n[n.length-1][1]}function eh(n){for(var t=0;tt[0]||n[2]t[1]||n[3]1?0:n<-1?oe:Math.acos(n)}function Be(n){return n>1?Ge:n<-1?-Ge:Math.asin(n)}function cn(){}function zs(n,t){n&&ah.hasOwnProperty(n.type)&&ah[n.type](n,t)}var uh={Feature:function(n,t){zs(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++roe?n-Ze:n<-oe?n+Ze:n,t]}$a.invert=$a;function Qa(n,t,e){return(n%=Ze)?t||e?Us(fh(n),hh(t,e)):fh(n):t||e?hh(t,e):$a}function ch(n){return function(t,e){return t+=n,[t>oe?t-Ze:t<-oe?t+Ze:t,e]}}function fh(n){var t=ch(n);return t.invert=ch(-n),t}function hh(n,t){var e=Vt(n),r=Ht(n),i=Vt(t),u=Ht(t);function l(c,h){var p=Vt(h),d=Vt(c)*p,y=Ht(c)*p,v=Ht(h),_=v*e+d*r;return[Xe(y*i-_*u,d*e-v*r),Be(_*i+y*u)]}return l.invert=function(c,h){var p=Vt(h),d=Vt(c)*p,y=Ht(c)*p,v=Ht(h),_=v*i-y*u;return[Xe(y*i+v*u,d*e+_*r),Be(_*e-d*r)]},l}function ph(n,t,e,r,i,u){if(e){var l=Vt(t),c=Ht(t),h=r*e;i==null?(i=t+r*Ze,u=t-h/2):(i=gh(l,i),u=gh(l,u),(r>0?iu)&&(i+=r*Ze));for(var p,d=i;r>0?d>u:d1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function mh(n,t,e,r,i,u){var l=n[0],c=n[1],h=t[0],p=t[1],d=0,y=1,v=h-l,_=p-c,I;if(I=e-l,!(!v&&I>0)){if(I/=v,v<0){if(I0){if(I>y)return;I>d&&(d=I)}if(I=i-l,!(!v&&I<0)){if(I/=v,v<0){if(I>y)return;I>d&&(d=I)}else if(v>0){if(I0)){if(I/=_,_<0){if(I0){if(I>y)return;I>d&&(d=I)}if(I=u-c,!(!_&&I<0)){if(I/=_,_<0){if(I>y)return;I>d&&(d=I)}else if(_>0){if(I0&&(n[0]=l+d*v,n[1]=c+d*_),y<1&&(t[0]=l+y*v,t[1]=c+y*_),!0}}}}}function Ai(n,t){return ce(n[0]-t[0])=0;--c)i.point((y=d[c])[0],y[1]);else r(v.x,v.p.x,-1,i);v=v.p}v=v.o,d=v.z,_=!_}while(!v.v);i.lineEnd()}}}function dh(n){if(t=n.length){for(var t,e=0,r=n[0],i;++et?1:n>=t?0:NaN}function tl(n){return n.length===1&&(n=c0(n)),{left:function(t,e,r,i){for(r==null&&(r=0),i==null&&(i=t.length);r>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(r==null&&(r=0),i==null&&(i=t.length);r>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function c0(n){return function(t,e){return Dr(n(t),e)}}var yh=tl(Dr),f0=yh.right,h0=yh.left;var vh=Array.prototype,p0=vh.slice,m0=vh.map;var QE=Math.sqrt(50),tw=Math.sqrt(10),ew=Math.sqrt(2);function xo(n){for(var t=n.length,e,r=-1,i=0,u,l;++r=0;)for(l=n[t],e=l.length;--e>=0;)u[--i]=l[e];return u}var _o=1e9,Zs=-_o;function el(n,t,e,r){function i(p,d){return n<=p&&p<=e&&t<=d&&d<=r}function u(p,d,y,v){var _=0,I=0;if(p==null||(_=l(p,y))!==(I=l(d,y))||h(p,d)<0^y>0)do v.point(_===0||_===3?n:e,_>1?r:t);while((_=(_+y+4)%4)!==I);else v.point(d[0],d[1])}function l(p,d){return ce(p[0]-n)0?0:3:ce(p[0]-e)0?2:1:ce(p[1]-t)0?1:0:d>0?3:2}function c(p,d){return h(p.x,d.x)}function h(p,d){var y=l(p,1),v=l(d,1);return y!==v?y-v:y===0?d[1]-p[1]:y===1?p[0]-d[0]:y===2?p[1]-d[1]:d[0]-p[0]}return function(p){var d=p,y=Ys(),v,_,I,F,M,L,C,q,V,X,G,J={point:k,lineStart:B,lineEnd:K,polygonStart:T,polygonEnd:D};function k(R,x){i(R,x)&&d.point(R,x)}function N(){for(var R=0,x=0,b=_.length;xr&&(ot-j)*(r-tt)>(rt-tt)*(n-j)&&++R:rt<=r&&(ot-j)*(r-tt)<(rt-tt)*(n-j)&&--R;return R}function T(){d=y,v=[],_=[],G=!0}function D(){var R=N(),x=G&&R,b=(v=xo(v)).length;(x||b)&&(p.polygonStart(),x&&(p.lineStart(),u(null,null,1,p),p.lineEnd()),b&&Vs(v,c,R,u,p),p.polygonEnd()),d=p,v=_=I=null}function B(){J.point=w,_&&_.push(I=[]),X=!0,V=!1,C=q=NaN}function K(){v&&(w(F,M),L&&V&&y.rejoin(),v.push(y.result())),J.point=k,V&&d.lineEnd()}function w(R,x){var b=i(R,x);if(_&&I.push([R,x]),X)F=R,M=x,L=b,X=!1,b&&(d.lineStart(),d.point(R,x));else if(b&&V)d.point(R,x);else{var E=[C=Math.max(Zs,Math.min(_o,C)),q=Math.max(Zs,Math.min(_o,q))],A=[R=Math.max(Zs,Math.min(_o,R)),x=Math.max(Zs,Math.min(_o,x))];mh(E,A,n,t,e,r)?(V||(d.lineStart(),d.point(E[0],E[1])),d.point(A[0],A[1]),b||d.lineEnd(),G=!1):b&&(d.lineStart(),d.point(R,x),G=!1)}C=R,q=x,V=b}return J}}var nl=dn();function rl(n,t){var e=t[0],r=t[1],i=[Ht(e),-Vt(e),0],u=0,l=0;nl.reset();for(var c=0,h=n.length;c=0?1:-1,k=J*G,N=k>oe,T=I*V;if(nl.add(Xe(T*J*Ht(k),F*X+T*Vt(k))),u+=N?G+J*Ze:G,N^v>=e^C>=e){var D=ui(Zn(y),Zn(L));Ri(D);var B=ui(i,D);Ri(B);var K=(N^G>=0?-1:1)*Be(B[2]);(r>K||r===K&&(D[0]||D[1]))&&(l+=N^G>=0?1:-1)}}return(u<-Kt||ubo&&(bo=n),tjs&&(js=t)}var Ks=S0;function il(n){this._context=n}il.prototype={_radius:4.5,pointRadius:function(n){return this._radius=n,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(n,t){switch(this._point){case 0:{this._context.moveTo(n,t),this._point=1;break}case 1:{this._context.lineTo(n,t);break}default:{this._context.moveTo(n+this._radius,t),this._context.arc(n,t,this._radius,0,Ze);break}}},result:cn};var wk=dn();function ol(){this._string=[]}ol.prototype={_radius:4.5,_circle:Ph(4.5),pointRadius:function(n){return(n=+n)!==this._radius&&(this._radius=n,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(n,t){switch(this._point){case 0:{this._string.push("M",n,",",t),this._point=1;break}case 1:{this._string.push("L",n,",",t);break}default:{this._circle==null&&(this._circle=Ph(this._radius)),this._string.push("M",n,",",t,this._circle);break}}},result:function(){if(this._string.length){var n=this._string.join("");return this._string=[],n}else return null}};function Ph(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function $s(n,t,e,r){return function(i,u){var l=t(u),c=i.invert(r[0],r[1]),h=Ys(),p=t(h),d=!1,y,v,_,I={point:F,lineStart:L,lineEnd:C,polygonStart:function(){I.point=q,I.lineStart=V,I.lineEnd=X,v=[],y=[]},polygonEnd:function(){I.point=F,I.lineStart=L,I.lineEnd=C,v=xo(v);var G=rl(y,c);v.length?(d||(u.polygonStart(),d=!0),Vs(v,L0,G,e,u)):G&&(d||(u.polygonStart(),d=!0),u.lineStart(),e(null,null,1,u),u.lineEnd()),d&&(u.polygonEnd(),d=!1),v=y=null},sphere:function(){u.polygonStart(),u.lineStart(),e(null,null,1,u),u.lineEnd(),u.polygonEnd()}};function F(G,J){var k=i(G,J);n(G=k[0],J=k[1])&&u.point(G,J)}function M(G,J){var k=i(G,J);l.point(k[0],k[1])}function L(){I.point=M,l.lineStart()}function C(){I.point=F,l.lineEnd()}function q(G,J){_.push([G,J]);var k=i(G,J);p.point(k[0],k[1])}function V(){p.lineStart(),_=[]}function X(){q(_[0][0],_[0][1]),p.lineEnd();var G=p.clean(),J=h.result(),k,N=J.length,T,D,B;if(_.pop(),y.push(_),_=null,!!N){if(G&1){if(D=J[0],(T=D.length-1)>0){for(d||(u.polygonStart(),d=!0),u.lineStart(),k=0;k1&&G&2&&J.push(J.pop().concat(J.shift())),v.push(J.filter(I0))}}return I}}function I0(n){return n.length>1}function L0(n,t){return((n=n.x)[0]<0?n[1]-Ge-Kt:Ge-n[1])-((t=t.x)[0]<0?t[1]-Ge-Kt:Ge-t[1])}var sl=$s(function(){return!0},M0,N0,[-oe,-Ge]);function M0(n){var t=NaN,e=NaN,r=NaN,i;return{lineStart:function(){n.lineStart(),i=1},point:function(u,l){var c=u>0?oe:-oe,h=ce(u-t);ce(h-oe)0?Ge:-Ge),n.point(r,e),n.lineEnd(),n.lineStart(),n.point(c,e),n.point(u,e),i=0):r!==c&&h>=oe&&(ce(t-r)Kt?Hn((Ht(t)*(u=Vt(r))*Ht(e)-Ht(r)*(i=Vt(t))*Ht(n))/(i*u*l)):(t+r)/2}function N0(n,t,e,r){var i;if(n==null)i=e*Ge,r.point(-oe,i),r.point(0,i),r.point(oe,i),r.point(oe,0),r.point(oe,-i),r.point(0,-i),r.point(-oe,-i),r.point(-oe,0),r.point(-oe,i);else if(ce(n[0]-t[0])>Kt){var u=n[0]0,i=ce(e)>Kt;function u(d,y,v,_){ph(_,n,t,v,d,y)}function l(d,y){return Vt(d)*Vt(y)>e}function c(d){var y,v,_,I,F;return{lineStart:function(){I=_=!1,F=1},point:function(M,L){var C=[M,L],q,V=l(M,L),X=r?V?0:p(M,L):V?p(M+(M<0?oe:-oe),L):0;if(!y&&(I=_=V)&&d.lineStart(),V!==_&&(q=h(y,C),(!q||Ai(y,q)||Ai(C,q))&&(C[0]+=Kt,C[1]+=Kt,V=l(C[0],C[1]))),V!==_)F=0,V?(d.lineStart(),q=h(C,y),d.point(q[0],q[1])):(q=h(y,C),d.point(q[0],q[1]),d.lineEnd()),y=q;else if(i&&y&&r^V){var G;!(X&v)&&(G=h(C,y,!0))&&(F=0,r?(d.lineStart(),d.point(G[0][0],G[0][1]),d.point(G[1][0],G[1][1]),d.lineEnd()):(d.point(G[1][0],G[1][1]),d.lineEnd(),d.lineStart(),d.point(G[0][0],G[0][1])))}V&&(!y||!Ai(y,C))&&d.point(C[0],C[1]),y=C,_=V,v=X},lineEnd:function(){_&&d.lineEnd(),y=null},clean:function(){return F|(I&&_)<<1}}}function h(d,y,v){var _=Zn(d),I=Zn(y),F=[1,0,0],M=ui(_,I),L=yo(M,M),C=M[0],q=L-C*C;if(!q)return!v&&d;var V=e*L/q,X=-e*C/q,G=ui(F,M),J=vo(F,V),k=vo(M,X);Xs(J,k);var N=G,T=yo(J,N),D=yo(N,N),B=T*T-D*(yo(J,J)-1);if(!(B<0)){var K=De(B),w=vo(N,(-T-K)/D);if(Xs(w,J),w=Oi(w),!v)return w;var R=d[0],x=y[0],b=d[1],E=y[1],A;x0^w[1]<(ce(w[0]-R)oe^(R<=w[0]&&w[0]<=x)){var tt=vo(N,(-T+K)/D);return Xs(tt,J),[w,Oi(tt)]}}}function p(d,y){var v=r?n:oe-n,_=0;return d<-v?_|=1:d>v&&(_|=2),y<-v?_|=4:y>v&&(_|=8),_}return $s(l,c,u,r?[0,-n]:[-oe,n-oe])}function Eo(n){return function(t){var e=new ul;for(var r in n)e[r]=n[r];return e.stream=t,e}}function ul(){}ul.prototype={constructor:ul,point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function wo(n,t,e){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],u=n.clipExtent&&n.clipExtent();n.scale(150).translate([0,0]),u!=null&&n.clipExtent(null),Fr(e,n.stream(Ks));var l=Ks.result(),c=Math.min(r/(l[1][0]-l[0][0]),i/(l[1][1]-l[0][1])),h=+t[0][0]+(r-c*(l[1][0]+l[0][0]))/2,p=+t[0][1]+(i-c*(l[1][1]+l[0][1]))/2;return u!=null&&n.clipExtent(u),n.scale(c*150).translate([h,p])}function Qs(n,t,e){return wo(n,[[0,0],t],e)}var Eh=16,T0=Vt(30*Le);function al(n,t){return+t?R0(n,t):O0(n)}function O0(n){return Eo({point:function(t,e){t=n(t,e),this.stream.point(t[0],t[1])}})}function R0(n,t){function e(r,i,u,l,c,h,p,d,y,v,_,I,F,M){var L=p-r,C=d-i,q=L*L+C*C;if(q>4*t&&F--){var V=l+v,X=c+_,G=h+I,J=De(V*V+X*X+G*G),k=Be(G/=J),N=ce(ce(G)-1)t||ce((L*K+C*w)/q-.5)>.3||l*v+c*_+h*I2?w[2]%360*Le:0,B()):[p*ln,d*ln,y*ln]},N.precision=function(w){return arguments.length?(G=al(D,X=w*w),K()):De(X)},N.fitExtent=function(w,R){return wo(N,w,R)},N.fitSize=function(w,R){return Qs(N,w,R)};function B(){_=Us(v=Qa(p,d,y),t);var w=t(c,h);return u=r-w[0]*e,l=i+w[1]*e,K()}function K(){return J=k=null,N}return function(){return t=n.apply(this,arguments),N.invert=t.invert&&T,B()}}function tu(n){return function(t,e){var r=Vt(t),i=Vt(e),u=n(r*i);return[u*i*Ht(t),u*Ht(e)]}}function ur(n){return function(t,e){var r=De(t*t+e*e),i=n(r),u=Ht(i),l=Vt(i);return[Xe(t*u,r*l),Be(r&&e*u/r)]}}var Ih=tu(function(n){return De(2/(1+n))});Ih.invert=ur(function(n){return 2*Be(n/2)});var cl=tu(function(n){return(n=qs(n))&&n/Ht(n)});cl.invert=ur(function(n){return n});function fl(){return Wn(cl).scale(79.4188).clipAngle(180-.001)}function hl(n,t){return[n,po(mo((Ge+t)/2))]}hl.invert=function(n,t){return[n,2*Hn(Bs(t))-Ge]};function eu(n,t){return[n,t]}eu.invert=eu;function Lh(n,t){var e=Vt(t),r=Vt(n)*e;return[e*Ht(n)/r,Ht(t)/r]}Lh.invert=ur(Hn);function Mh(n,t){var e=t*t,r=e*e;return[n*(.8707-.131979*e+r*(-.013791+r*(.003971*e-.001529*r))),t*(1.007226+e*(.015085+r*(-.044475+.028874*e-.005916*r)))]}Mh.invert=function(n,t){var e=t,r=25,i;do{var u=e*e,l=u*u;e-=i=(e*(1.007226+u*(.015085+l*(-.044475+.028874*u-.005916*l)))-t)/(1.007226+u*(.015085*3+l*(-.044475*7+.028874*9*u-.005916*11*l)))}while(ce(i)>Kt&&--r>0);return[n/(.8707+(u=e*e)*(-.131979+u*(-.013791+u*u*u*(.003971-.001529*u)))),e]};function Ch(n,t){return[Vt(t)*Ht(n),Ht(t)]}Ch.invert=ur(Be);function Nh(n,t){var e=Vt(t),r=1+Vt(n)*e;return[e*Ht(n)/r,Ht(t)/r]}Nh.invert=ur(function(n){return 2*Hn(n)});function Th(n,t){return[po(mo((Ge+t)/2)),-n]}Th.invert=function(n,t){return[-t,2*Hn(Bs(n))-Ge]};var{BufferOp:G0,GeoJSONReader:B0,GeoJSONWriter:q0}=Oh.default;function Rh(n,t,e){e=e||{};var r=e.units||"kilometers",i=e.steps||8;if(!n)throw new Error("geojson is required");if(typeof e!="object")throw new Error("options must be an object");if(typeof i!="number")throw new Error("steps must be an number");if(t===void 0)throw new Error("radius is required");if(i<=0)throw new Error("steps must be greater than 0");var u=[];switch(n.type){case"GeometryCollection":return ve(n,function(l){var c=nu(l,t,r,i);c&&u.push(c)}),pt(u);case"FeatureCollection":return Dt(n,function(l){var c=nu(l,t,r,i);c&&Dt(c,function(h){h&&u.push(h)})}),pt(u)}return nu(n,t,r,i)}function nu(n,t,e,r){var i=n.properties||{},u=n.type==="Feature"?n.geometry:n;if(u.type==="GeometryCollection"){var l=[];return ve(n,function(F){var M=nu(F,t,e,r);M&&l.push(M)}),pt(l)}var c=z0(u),h={type:u.type,coordinates:Fh(u.coordinates,c)},p=new B0,d=p.read(h),y=ti(Or(t,e),"meters"),v=G0.bufferOp(d,y,r),_=new q0;if(v=_.write(v),!Ah(v.coordinates)){var I={type:v.type,coordinates:Dh(v.coordinates,c)};return te(I,i)}}function Ah(n){return Array.isArray(n[0])?Ah(n[0]):isNaN(n[0])}function Fh(n,t){return typeof n[0]!="object"?t(n):n.map(function(e){return Fh(e,t)})}function Dh(n,t){return typeof n[0]!="object"?t.invert(n):n.map(function(e){return Dh(e,t)})}function z0(n){var t=Ar(n).geometry.coordinates,e=[-t[0],-t[1]];return fl().rotate(e).scale(ke)}function Di(n,t={}){let e=0,r=0,i=0;return ve(n,function(u,l,c){let h=t.weight?c==null?void 0:c[t.weight]:void 0;if(h=h==null?1:h,!ye(h))throw new Error("weight value must be a number for feature index "+l);h=Number(h),h>0&&ne(u,function(p){e+=p[0]*h,r+=p[1]*h,i+=h})}),wt([e/i,r/i],t.properties,t)}function We(n,t={}){let e=0,r=0,i=0;return ne(n,function(u){e+=u[0],r+=u[1],i++},!0),wt([e/i,r/i],t.properties)}function Gh(n,t={}){if(t=t||{},!Ft(t))throw new Error("options is invalid");var e=t.counter||10;if(!ye(e))throw new Error("counter must be a number");var r=t.weight,i=Di(n,{weight:t.weight}),u=pt([]);Dt(n,function(c){var h;u.features.push(We(c,{properties:{weight:(h=c.properties)==null?void 0:h[r]}}))});let l={tolerance:t.tolerance,medianCandidates:[]};return Bh(i.geometry.coordinates,[0,0],u,l,e)}function Bh(n,t,e,r,i){var u=r.tolerance||.001,l=0,c=0,h=0,p=0;if(Dt(e,function(v){var L;var _=(L=v.properties)==null?void 0:L.weight,I=_==null?1:_;if(I=Number(I),!ye(I))throw new Error("weight value must be a number");if(I>0){p+=1;var F=I*$t(v,n);F===0&&(F=1);var M=I/F;l+=v.geometry.coordinates[0]*M,c+=v.geometry.coordinates[1]*M,h+=M}}),p<1)throw new Error("no features to measure");var d=l/h,y=c/h;return p===1||i===0||Math.abs(d-t[0]){e.push([i[0],i[1]])}),!e.length)return null;let r=(0,eg.default)(e,t.concavity);return r.length>3?Mt([r]):null}function _l(n,t={}){switch(be(n)){case"Point":return wt(Ut(n),t.properties);case"Polygon":var e=[];ne(n,function(V){e.push(V)});var r=We(n,{properties:t.properties}),i=r.geometry.coordinates,u=0,l=0,c=0,h,p,d,y,v,_,I,F,M=e.map(function(V){return[V[0]-i[0],V[1]-i[1]]});for(h=0;h{switch(e){case"type":case"properties":case"geometry":return;default:t[e]=n[e]}}),t.properties=So(n.properties),n.geometry==null?t.geometry=null:t.geometry=Pl(n.geometry),t}function So(n){let t={};return n&&Object.keys(n).forEach(e=>{let r=n[e];typeof r=="object"?r===null?t[e]=null:Array.isArray(r)?t[e]=r.map(i=>i):t[e]=So(r):t[e]=r}),t}function K0(n){let t={type:"FeatureCollection"};return Object.keys(n).forEach(e=>{switch(e){case"type":case"features":return;default:t[e]=n[e]}}),t.features=n.features.map(e=>ng(e)),t}function Pl(n){let t={type:n.type};return n.bbox&&(t.bbox=n.bbox),n.type==="GeometryCollection"?(t.geometries=n.geometries.map(e=>Pl(e)),t):(t.coordinates=rg(n.coordinates),t)}function rg(n){let t=n;return typeof t[0]!="object"?t.slice():t.map(e=>rg(e))}var lu={};Tr(lu,{applyFilter:()=>au,clusterEach:()=>bl,clusterReduce:()=>og,createBins:()=>El,filterProperties:()=>sg,getCluster:()=>ig,propertiesContainsFilter:()=>wl});function ig(n,t){if(!n)throw new Error("geojson is required");if(n.type!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(t==null)throw new Error("filter is required");var e=[];return Dt(n,function(r){au(r.properties,t)&&e.push(r)}),pt(e)}function bl(n,t,e){if(!n)throw new Error("geojson is required");if(n.type!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(t==null)throw new Error("property is required");for(var r=El(n,t),i=Object.keys(r),u=0;u>4;if(i!==Sl)throw new Error(`Got v${i} data when expected v${Sl}.`);let u=ug[r&15];if(!u)throw new Error("Unrecognized array type.");let[l]=new Uint16Array(t,2,1),[c]=new Uint32Array(t,4,1);return new n(c,l,u,t)}constructor(t,e=64,r=Float64Array,i){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let u=ug.indexOf(this.ArrayType),l=t*2*this.ArrayType.BYTES_PER_ELEMENT,c=t*this.IndexArrayType.BYTES_PER_ELEMENT,h=(8-c%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${r}.`);i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,ko,t),this.coords=new this.ArrayType(this.data,ko+c+h,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(ko+l+c+h),this.ids=new this.IndexArrayType(this.data,ko,t),this.coords=new this.ArrayType(this.data,ko+c+h,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(Sl<<4)+u]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Il(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:u,coords:l,nodeSize:c}=this,h=[0,u.length-1,0],p=[];for(;h.length;){let d=h.pop()||0,y=h.pop()||0,v=h.pop()||0;if(y-v<=c){for(let M=v;M<=y;M++){let L=l[2*M],C=l[2*M+1];L>=t&&L<=r&&C>=e&&C<=i&&p.push(u[M])}continue}let _=v+y>>1,I=l[2*_],F=l[2*_+1];I>=t&&I<=r&&F>=e&&F<=i&&p.push(u[_]),(d===0?t<=I:e<=F)&&(h.push(v),h.push(_-1),h.push(1-d)),(d===0?r>=I:i>=F)&&(h.push(_+1),h.push(y),h.push(1-d))}return p}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:i,coords:u,nodeSize:l}=this,c=[0,i.length-1,0],h=[],p=r*r;for(;c.length;){let d=c.pop()||0,y=c.pop()||0,v=c.pop()||0;if(y-v<=l){for(let M=v;M<=y;M++)ag(u[2*M],u[2*M+1],t,e)<=p&&h.push(i[M]);continue}let _=v+y>>1,I=u[2*_],F=u[2*_+1];ag(I,F,t,e)<=p&&h.push(i[_]),(d===0?t-r<=I:e-r<=F)&&(c.push(v),c.push(_-1),c.push(1-d)),(d===0?t+r>=I:e+r>=F)&&(c.push(_+1),c.push(y),c.push(1-d))}return h}};function Il(n,t,e,r,i,u){if(i-r<=e)return;let l=r+i>>1;lg(n,t,l,r,i,u),Il(n,t,e,r,l-1,1-u),Il(n,t,e,l+1,i,1-u)}function lg(n,t,e,r,i,u){for(;i>r;){if(i-r>600){let p=i-r+1,d=e-r+1,y=Math.log(p),v=.5*Math.exp(2*y/3),_=.5*Math.sqrt(y*v*(p-v)/p)*(d-p/2<0?-1:1),I=Math.max(r,Math.floor(e-d*v/p+_)),F=Math.min(i,Math.floor(e+(p-d)*v/p+_));lg(n,t,e,I,F,u)}let l=t[2*e+u],c=r,h=i;for(Io(n,t,r,e),t[2*i+u]>l&&Io(n,t,r,i);cl;)h--}t[2*r+u]===l?Io(n,t,r,h):(h++,Io(n,t,h,i)),h<=e&&(r=h+1),e<=h&&(i=h-1)}}function Io(n,t,e,r){kl(n,e,r),kl(t,2*e,2*r),kl(t,2*e+1,2*r+1)}function kl(n,t,e){let r=n[t];n[t]=n[e],n[e]=r}function ag(n,t,e,r){let i=n-e,u=t-r;return i*i+u*u}var hg=Jn(ml(),1),$0=6371,ar=Math.PI/180;function gg(n,t,e,r=1/0,i=1/0,u){let l=1,c=[];r===void 0&&(r=1/0),i!==void 0&&(l=ai(i/$0));let h=new hg.default([],Q0),p={left:0,right:n.ids.length-1,axis:0,dist:0,minLng:-180,minLat:-90,maxLng:180,maxLat:90},d=Math.cos(e*ar);for(;p;){let y=p.right,v=p.left;if(y-v<=n.nodeSize)for(let _=v;_<=y;_++){let I=n.ids[_];if(!u||u(I)){let F=fg(t,e,n.coords[2*_],n.coords[2*_+1],d);h.push({id:I,dist:F})}}else{let _=v+y>>1,I=n.coords[2*_],F=n.coords[2*_+1],M=n.ids[_];if(!u||u(M)){let V=fg(t,e,I,F,d);h.push({id:M,dist:V})}let L=(p.axis+1)%2,C={left:v,right:_-1,axis:L,minLng:p.minLng,minLat:p.minLat,maxLng:p.axis===0?I:p.maxLng,maxLat:p.axis===1?F:p.maxLat,dist:0},q={left:_+1,right:y,axis:L,minLng:p.axis===0?I:p.minLng,minLat:p.axis===1?F:p.minLat,maxLng:p.maxLng,maxLat:p.maxLat,dist:0};C.dist=cg(t,e,d,C),q.dist=cg(t,e,d,q),h.push(C),h.push(q)}for(;h.length&&h.peek().id!=null;){let _=h.pop();if(_.dist>l||(c.push(_.id),c.length===r))return c}p=h.pop()}return c}function cg(n,t,e,r){let i=r.minLng,u=r.maxLng,l=r.minLat,c=r.maxLat;if(n>=i&&n<=u)return tc?ai((t-c)*ar):0;let h=Math.min(ai((n-i)*ar),ai((n-u)*ar)),p=tv(t,h);return p>l&&p0?90:-90:Math.atan(Math.tan(n*ar)/e)/ar}function pg(n,t,e={}){e.mutate!==!0&&(n=se(n));let r=e.minPoints||3,i=new Lo(n.features.length);for(let v of n.features)i.add(v.geometry.coordinates[0],v.geometry.coordinates[1]);i.finish();var u=n.features.map(v=>!1),l=n.features.map(v=>!1),c=n.features.map(v=>!1),h=n.features.map(v=>-1);let p=v=>{let _=n.features[v],[I,F]=_.geometry.coordinates;return gg(i,I,F,void 0,t).map(M=>({minX:n.features[M].geometry.coordinates[0],minY:n.features[M].geometry.coordinates[1],maxX:n.features[M].geometry.coordinates[0],maxY:n.features[M].geometry.coordinates[1],index:M}))},d=(v,_)=>{for(var I=0;I<_.length;I++){var F=_[I];let M=F.index;if(!u[M]){u[M]=!0;let L=p(M);L.length>=r&&_.push(...L)}l[M]||(l[M]=!0,h[M]=v)}};var y=0;return n.features.forEach((v,_)=>{if(u[_])return;let I=p(_);if(I.length>=r){let F=y;y++,u[_]=!0,d(F,I)}else c[_]=!0}),n.features.forEach((v,_)=>{var I=n.features[_];I.properties||(I.properties={}),h[_]>=0?(I.properties.dbscan=c[_]?"edge":"core",I.properties.cluster=h[_]):I.properties.dbscan="noise"}),n}var wg=Jn(Eg());function Sg(n,t={}){var e=n.features.length;t.numberOfClusters=t.numberOfClusters||Math.round(Math.sqrt(e/2)),t.numberOfClusters>e&&(t.numberOfClusters=e),t.mutate!==!0&&(n=se(n));var r=ri(n),i=r.slice(0,t.numberOfClusters),u=(0,wg.default)(r,t.numberOfClusters,i),l={};return u.centroids.forEach(function(c,h){l[h]=c}),Dt(n,function(c,h){var p=u.idxs[h];c.properties.cluster=p,c.properties.centroid=l[p]}),n}var kg=Jn(Li());function Ig(n,t,e,r){var i=new kg.default(6),u=t.features.map(function(l){var c;return{minX:l.geometry.coordinates[0],minY:l.geometry.coordinates[1],maxX:l.geometry.coordinates[0],maxY:l.geometry.coordinates[1],property:(c=l.properties)==null?void 0:c[e]}});return i.load(u),n.features.forEach(function(l){l.properties||(l.properties={});var c=jt(l),h=i.search({minX:c[0],minY:c[1],maxX:c[2],maxY:c[3]}),p=[];h.forEach(function(d){Ct([d.minX,d.minY],l)&&p.push(d.property)}),l.properties[r]=p}),n}function Lg(n){var t={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return Dt(n,e=>{var r;switch((r=e.geometry)==null?void 0:r.type){case"Point":t.MultiPoint.coordinates.push(e.geometry.coordinates),t.MultiPoint.properties.push(e.properties);break;case"MultiPoint":t.MultiPoint.coordinates.push(...e.geometry.coordinates),t.MultiPoint.properties.push(e.properties);break;case"LineString":t.MultiLineString.coordinates.push(e.geometry.coordinates),t.MultiLineString.properties.push(e.properties);break;case"MultiLineString":t.MultiLineString.coordinates.push(...e.geometry.coordinates),t.MultiLineString.properties.push(e.properties);break;case"Polygon":t.MultiPolygon.coordinates.push(e.geometry.coordinates),t.MultiPolygon.properties.push(e.properties);break;case"MultiPolygon":t.MultiPolygon.coordinates.push(...e.geometry.coordinates),t.MultiPolygon.properties.push(e.properties);break;default:break}}),pt(Object.keys(t).filter(function(e){return t[e].coordinates.length}).sort().map(function(e){var r={type:e,coordinates:t[e].coordinates},i={collectedProperties:t[e].properties};return te(r,i)}))}function hu(n,t){let e=!1;return pt(cv(n.features.map(r=>{let i={x:r.geometry.coordinates[0],y:r.geometry.coordinates[1]};return t?i.z=r.properties[t]:r.geometry.coordinates.length===3&&(e=!0,i.z=r.geometry.coordinates[2]),i})).map(r=>{let i=[r.a.x,r.a.y],u=[r.b.x,r.b.y],l=[r.c.x,r.c.y],c={};return e?(i.push(r.a.z),u.push(r.b.z),l.push(r.c.z)):c={a:r.a.z,b:r.b.z,c:r.c.z},Mt([[i,u,l,i]],c)}))}var fu=class{constructor(t,e,r){et(this,"a");et(this,"b");et(this,"c");et(this,"x");et(this,"y");et(this,"r");this.a=t,this.b=e,this.c=r;let i=e.x-t.x,u=e.y-t.y,l=r.x-t.x,c=r.y-t.y,h=i*(t.x+e.x)+u*(t.y+e.y),p=l*(t.x+r.x)+c*(t.y+r.y),d=2*(i*(r.y-e.y)-u*(r.x-e.x)),y,v;this.x=(c*h-u*p)/d,this.y=(i*p-l*h)/d,y=this.x-t.x,v=this.y-t.y,this.r=y*y+v*v}};function av(n,t){return t.x-n.x}function lv(n){let t=n.length,e,r,i,u,l;t:for(;t;)for(r=n[--t],e=n[--t],i=t;i;)if(l=n[--i],u=n[--i],e===u&&r===l||e===l&&r===u){n.splice(t,2),n.splice(i,2),t-=2;continue t}}function cv(n){if(n.length<3)return[];n.sort(av);let t=n.length-1,e=n[t].x,r=n[0].x,i=n[t].y,u=i,l=1e-12,c,h,p,d,y,v;for(;t--;)n[t].yu&&(u=n[t].y);let _=r-e,I=u-i,F=_>I?_:I,M=(r+e)*.5,L=(u+i)*.5,C=[new fu({__sentinel:!0,x:M-20*F,y:L-F},{__sentinel:!0,x:M,y:L+20*F},{__sentinel:!0,x:M+20*F,y:L-F})],q=[],V=[],X;for(t=n.length;t--;){for(V.length=0,X=C.length;X--;){if(_=n[t].x-C[X].x,_>0&&_*_>C[X].r){q.push(C[X]),C.splice(X,1);continue}I=n[t].y-C[X].y,!(_*_+I*I>C[X].r)&&(V.push(C[X].a,C[X].b,C[X].b,C[X].c,C[X].c,C[X].a),C.splice(X,1))}for(lv(V),X=V.length;X;)h=V[--X],c=V[--X],p=n[t],d=h.x-c.x,y=h.y-c.y,v=2*(d*(p.y-h.y)-y*(p.x-h.x)),Math.abs(v)>l&&C.push(new fu(c,h,p))}for(Array.prototype.push.apply(q,C),t=q.length;t--;)(q[t].a.__sentinel||q[t].b.__sentinel||q[t].c.__sentinel)&&q.splice(t,1);return q}function Mg(n,t={}){if(t=t||{},!Ft(t))throw new Error("options is invalid");let e=t.mutate;if(be(n)!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(!n.features.length)throw new Error("geojson is empty");(e===!1||e===void 0)&&(n=se(n));let r=[],i=Es(n,(u,l)=>{let c=fv(u,l);return c||(r.push(u),l)});return i&&r.push(i),r.length?r.length===1?r[0]:kn(r.map(u=>u.coordinates)):null}function gu(n){return n[0].toString()+","+n[1].toString()}function fv(n,t){let e=n.geometry.coordinates,r=t.geometry.coordinates,i=gu(e[0]),u=gu(e[e.length-1]),l=gu(r[0]),c=gu(r[r.length-1]),h;if(i===c)h=r.concat(e.slice(1));else if(l===u)h=e.concat(r.slice(1));else if(i===l)h=e.slice(1).reverse().concat(r);else if(u===c)h=e.concat(r.reverse().slice(1));else return null;return At(h)}function Cl(n){return n}function pu(n){if(n==null)return Cl;var t,e,r=n.scale[0],i=n.scale[1],u=n.translate[0],l=n.translate[1];return function(c,h){h||(t=e=0);var p=2,d=c.length,y=new Array(d);for(y[0]=(t+=c[0])*r+u,y[1]=(e+=c[1])*i+l;p1)for(var y=1,v=c(p[0]),_,I;yv&&(I=p[0],p[0]=p[y],p[y]=I,v=_);return p}).filter(function(h){return h.length>0})}}var Gr=Object.prototype.hasOwnProperty;function Tg(n){var t=1/0,e=1/0,r=-1/0,i=-1/0;function u(y){y!=null&&Gr.call(l,y.type)&&l[y.type](y)}var l={GeometryCollection:function(y){y.geometries.forEach(u)},Point:function(y){c(y.coordinates)},MultiPoint:function(y){y.coordinates.forEach(c)},LineString:function(y){h(y.arcs)},MultiLineString:function(y){y.arcs.forEach(h)},Polygon:function(y){y.arcs.forEach(h)},MultiPolygon:function(y){y.arcs.forEach(p)}};function c(y){var v=y[0],_=y[1];vr&&(r=v),_i&&(i=_)}function h(y){y.forEach(c)}function p(y){y.forEach(h)}for(var d in n)u(n[d]);return r>=t&&i>=e?[t,e,r,i]:void 0}function Og(n,t,e,r,i){arguments.length===3&&(r=Array,i=null);for(var u=new r(n=1<=n)throw new Error("full hashset");_=u[v=v+1&l]}return u[v]=y,!0}function p(y){for(var v=t(y)&l,_=u[v],I=0;_!=i;){if(e(_,y))return!0;if(++I>=n)break;_=u[v=v+1&l]}return!1}function d(){for(var y=[],v=0,_=u.length;v<_;++v){var I=u[v];I!=i&&y.push(I)}return y}return{add:h,has:p,values:d}}function qi(n,t,e,r,i,u){arguments.length===3&&(r=u=Array,i=null);for(var l=new r(n=1<=n)throw new Error("full hashmap");L=l[M=M+1&h]}return l[M]=I,c[M]=F,F}function y(I,F){for(var M=t(I)&h,L=l[M],C=0;L!=i;){if(e(L,I))return c[M];if(++C>=n)throw new Error("full hashmap");L=l[M=M+1&h]}return l[M]=I,c[M]=F,F}function v(I,F){for(var M=t(I)&h,L=l[M],C=0;L!=i;){if(e(L,I))return c[M];if(++C>=n)break;L=l[M=M+1&h]}return F}function _(){for(var I=[],F=0,M=l.length;F>7^du[2]^du[3],t&2147483647}function Fg(n){var t=n.coordinates,e=n.lines,r=n.rings,i=G(),u=new Int32Array(t.length),l=new Int32Array(t.length),c=new Int32Array(t.length),h=new Int8Array(t.length),p=0,d,y,v,_,I;for(d=0,y=t.length;d=0){var x=c[K];(R!==B||x!==w)&&(R!==w||x!==B)&&(++p,h[K]=1)}else l[K]=B,c[K]=w}}function G(){for(var D=qi(t.length*1.4,J,k,Int32Array,-1,Int32Array),B=new Int32Array(t.length),K=0,w=t.length;K>1),i;t0&&e&&Ug(n,e,t),i=Gg(Dg(qg(n))),u=i.coordinates,l=qi(i.arcs.length*1.4,vv,xv);n=i.objects,i.bbox=e,i.arcs=i.arcs.map(function(v,_){return l.set(v,_),u.slice(v[0],v[1]+1)}),delete i.coordinates,u=null;function c(v){v&&Gr.call(h,v.type)&&h[v.type](v)}var h={GeometryCollection:function(v){v.geometries.forEach(c)},LineString:function(v){v.arcs=p(v.arcs)},MultiLineString:function(v){v.arcs=v.arcs.map(p)},Polygon:function(v){v.arcs=v.arcs.map(p)},MultiPolygon:function(v){v.arcs=v.arcs.map(d)}};function p(v){var _=[];do{var I=l.get(v);_.push(v[0]{e.push(u.geometry)});let r=Al({geoms:ps(e).geometry});return Tl(r,r.objects.geoms.geometries)}function Jg(n,t={}){if(t=t||{},!Ft(t))throw new Error("options is invalid");let e=t.mutate;if(be(n)!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(!n.features.length)throw new Error("geojson is empty");(e===!1||e===void 0)&&(n=se(n));let r=_v(n);if(!r)throw new Error("geojson must be homogenous");let i=n;switch(r){case"LineString":return Mg(i,t);case"Polygon":return Yg(i,t);default:throw new Error(r+" is not supported")}}function _v(n){let t={};le(n,r=>{t[r.geometry.type]=!0});let e=Object.keys(t);return e.length===1?e[0]:null}function Vg(n,t={}){let e=t.maxEdge||1/0,r=Pv(n),i=hu(r);if(i.features=i.features.filter(l=>{let c=l.geometry.coordinates[0][0],h=l.geometry.coordinates[0][1],p=l.geometry.coordinates[0][2],d=$t(c,h,t),y=$t(h,p,t),v=$t(c,p,t);return d<=e&&y<=e&&v<=e}),i.features.length<1)return null;let u=Jg(i);return u.coordinates.length===1&&(u.coordinates=u.coordinates[0],u.type="Polygon"),te(u)}function Pv(n){let t=[],e={};return Dt(n,r=>{if(!r.geometry)return;let i=r.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(e,i)||(t.push(r),e[i]=!0)}),pt(t)}var pe=Jn(Hg(),1);var ie;(function(n){n[n.NoClip=0]="NoClip",n[n.Intersection=1]="Intersection",n[n.Union=2]="Union",n[n.Difference=3]="Difference",n[n.Xor=4]="Xor"})(ie||(ie={}));var xe;(function(n){n[n.Subject=0]="Subject",n[n.Clip=1]="Clip"})(xe||(xe={}));var ee;(function(n){n[n.EvenOdd=0]="EvenOdd",n[n.NonZero=1]="NonZero",n[n.Positive=2]="Positive",n[n.Negative=3]="Negative"})(ee||(ee={}));var re;(function(n){n[n.IsOn=0]="IsOn",n[n.IsInside=1]="IsInside",n[n.IsOutside=2]="IsOutside"})(re||(re={}));var _t;(function(n){n.MaxInt64=pe.default.BigInt("9223372036854775807"),n.MaxCoord=pe.default.toNumber(pe.default.divide(n.MaxInt64,pe.default.BigInt(4))),n.max_coord=n.MaxCoord,n.min_coord=-n.MaxCoord,n.Invalid64=pe.default.toNumber(n.MaxInt64),n.floatingPointTolerance=1e-12,n.defaultMinimumEdgeLength=.1;function t(X,G,J){return(G.x-X.x)*(J.y-G.y)-(G.y-X.y)*(J.x-G.x)}n.crossProduct=t;function e(X,G,J){let k=G.x-X.x,N=J.y-G.y,T=G.y-X.y,D=J.x-G.x;if(Math.abs(k)<9e7&&Math.abs(N)<9e7&&Math.abs(T)<9e7&&Math.abs(D)<9e7){let ot=k*N,rt=T*D;return ot>rt?1:ot0?1:0,K=N<0?-1:N>0?1:0,w=T<0?-1:T>0?1:0,R=D<0?-1:D>0?1:0,x=B*K,b=w*R;if(x!==b)return x>b?1:-1;if(x===0)return 0;let E=pe.default.BigInt(k),A=pe.default.BigInt(N),z=pe.default.BigInt(T),W=pe.default.BigInt(D),j=pe.default.multiply(E,A),tt=pe.default.multiply(z,W);return pe.default.equal(j,tt)?0:pe.default.greaterThen(j,tt)?1:-1}n.crossProductSign=e;function r(X){if(X<-8||X>8)throw new Error("Error: Precision is out of range.")}n.checkPrecision=r;function i(X){return Math.abs(X)<=n.floatingPointTolerance}n.isAlmostZero=i;function u(X){return X<0?-1:X>0?1:0}n.triSign=u;function l(X,G){let J=pe.default.BigInt(X),k=pe.default.BigInt(G),N=pe.default.multiply(J,k);return{lo64:pe.default.toNumber(pe.default.bitwiseAnd(N,pe.default.BigInt("0xffffffffffffffffn"))),hi64:pe.default.toNumber(pe.default.signedRightShift(N,pe.default.BigInt(64)))}}n.multiplyUInt64=l;function c(X,G,J,k){let N=Math.abs(X),T=Math.abs(G),D=Math.abs(J),B=Math.abs(k);if(N<46341&&T<46341&&D<46341&&B<46341||N<9e7&&T<9e7&&D<9e7&&B<9e7)return X*G===J*k;let K=(X<0?-1:X>0?1:0)*(G<0?-1:G>0?1:0),w=(J<0?-1:J>0?1:0)*(k<0?-1:k>0?1:0);if(K!==w)return!1;if(K===0)return!0;let R=pe.default.BigInt(N),x=pe.default.BigInt(T),b=pe.default.BigInt(D),E=pe.default.BigInt(B);return pe.default.equal(pe.default.multiply(R,x),pe.default.multiply(b,E))}n.productsAreEqual=c;function h(X,G,J){let k=G.x-X.x,N=J.y-G.y,T=G.y-X.y,D=J.x-G.x;return c(k,N,T,D)}n.isCollinear=h;function p(X,G,J){return(G.x-X.x)*(J.x-G.x)+(G.y-X.y)*(J.y-G.y)}n.dotProduct=p;function d(X,G){return X.y*G.x-G.y*X.x}n.crossProductD=d;function y(X,G){return X.x*G.x+X.y*G.y}n.dotProductD=y;function v(X){let G=Math.floor(X),J=X-G;return Math.abs(J-.5)<1e-10?G%2===0?G:G+1:Math.round(X)}n.roundToEven=v;function _(X){return X>=n.max_coord||X<=n.min_coord?n.Invalid64:Math.round(X)}n.checkCastInt64=_;function I(X,G,J,k){let N=G.y-X.y,T=G.x-X.x,D=k.y-J.y,B=k.x-J.x,K=N*B-D*T;if(K===0)return{intersects:!1,point:{x:0,y:0,z:0}};let w=((X.x-J.x)*D-(X.y-J.y)*B)/K,R;if(w<=0)R={x:X.x,y:X.y,z:0};else if(w>=1)R={x:G.x,y:G.y,z:0};else{let x=X.x+w*T,b=X.y+w*N;R={x:Math.trunc(x),y:Math.trunc(b),z:0}}return{intersects:!0,point:R}}n.getLineIntersectPt=I;function F(X,G,J,k){let N=G.y-X.y,T=G.x-X.x,D=k.y-J.y,B=k.x-J.x,K=N*B-D*T;if(K===0)return{success:!1,ip:{x:0,y:0,z:0}};let w=((X.x-J.x)*D-(X.y-J.y)*B)/K,R;return w<=0?R=Nr(Ve({},X),{z:0}):w>=1?R=Nr(Ve({},G),{z:0}):R={x:X.x+w*T,y:X.y+w*N,z:0},{success:!0,ip:R}}n.getLineIntersectPtD=F;function M(X,G,J,k,N=!1){if(!N)return t(X,J,k)*t(G,J,k)<0&&t(J,X,G)*t(k,X,G)<0;let T=t(X,J,k),D=t(G,J,k);if(T*D>0)return!1;let B=t(J,X,G),K=t(k,X,G);return B*K>0?!1:T!==0||D!==0||B!==0||K!==0}n.segsIntersect=M;function L(X){if(X.length===0)return{left:0,top:0,right:0,bottom:0};let G={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let J of X)J.xG.right&&(G.right=J.x),J.yG.bottom&&(G.bottom=J.y);return G.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:G}n.getBounds=L;function C(X,G,J){if(G.x===J.x&&G.y===J.y)return{x:G.x,y:G.y,z:0};let k=J.x-G.x,N=J.y-G.y,T=((X.x-G.x)*k+(X.y-G.y)*N)/(k*k+N*N),D=T<0?0:T>1?1:T;return{x:Math.round(G.x+D*k),y:Math.round(G.y+D*N),z:0}}n.getClosestPtOnSegment=C;function q(X,G){let J=G.length,k=0;if(J<3)return re.IsOutside;for(;kX.y;)B++;if(B===K)continue;let R=G[B],x=B>0?G[B-1]:G[J-1];if(R.y===X.y){if(R.x===X.x||R.y===x.y&&X.xx.x&&X.x>R.x)D=1-D;else{let b=e(x,R,X);if(b===0)return re.IsOn;b<0===N&&(D=1-D)}N=!N,B++}if(N===T)return D===0?re.IsOutside:re.IsInside;B===J&&(B=0);let w=B===0?e(G[J-1],G[0],X):e(G[B-1],G[B],X);return w===0?re.IsOn:(w<0===N&&(D=1-D),D===0?re.IsOutside:re.IsInside)}n.pointInPolygon=q;function V(X,G){let J=re.IsOn;for(let T of X)switch(q(T,G)){case re.IsOutside:if(J===re.IsOutside)return!1;J=re.IsOutside;break;case re.IsInside:if(J===re.IsInside)return!0;J=re.IsInside;break;default:break}let k=L(X),N={x:Math.round((k.left+k.right)/2),y:Math.round((k.top+k.bottom)/2)};return q(N,G)!==re.IsOutside}n.path2ContainsPath1=V})(_t||(_t={}));var ue;(function(n){function t(h=0,p=0,d=0){return{x:Math.round(h),y:Math.round(p),z:d}}n.create=t;function e(h){return{x:Math.round(h.x),y:Math.round(h.y),z:h.z||0}}n.fromPointD=e;function r(h,p){return{x:Math.round(h.x*p),y:Math.round(h.y*p),z:h.z||0}}n.scale=r;function i(h,p){return h.x===p.x&&h.y===p.y}n.equals=i;function u(h,p){return{x:h.x+p.x,y:h.y+p.y,z:0}}n.add=u;function l(h,p){return{x:h.x-p.x,y:h.y-p.y,z:0}}n.subtract=l;function c(h){return h.z!==void 0&&h.z!==0?`${h.x},${h.y},${h.z} `:`${h.x},${h.y} `}n.toString=c})(ue||(ue={}));var Fn;(function(n){function t(c=0,h=0,p=0){return{x:c,y:h,z:p}}n.create=t;function e(c){return{x:c.x,y:c.y,z:c.z||0}}n.fromPoint64=e;function r(c,h){return{x:c.x*h,y:c.y*h,z:c.z||0}}n.scale=r;function i(c,h){return _t.isAlmostZero(c.x-h.x)&&_t.isAlmostZero(c.y-h.y)}n.equals=i;function u(c){c.x=-c.x,c.y=-c.y}n.negate=u;function l(c,h=2){return c.z!==void 0&&c.z!==0?`${c.x.toFixed(h)},${c.y.toFixed(h)},${c.z}`:`${c.x.toFixed(h)},${c.y.toFixed(h)}`}n.toString=l})(Fn||(Fn={}));var Me;(function(n){function t(v=0,_=0,I=0,F=0){return{left:v,top:_,right:I,bottom:F}}n.create=t;function e(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}}n.createInvalid=e;function r(v){return v.right-v.left}n.width=r;function i(v){return v.bottom-v.top}n.height=i;function u(v){return v.bottom<=v.top||v.right<=v.left}n.isEmpty=u;function l(v){return v.leftv.left&&_.xv.top&&_.y=v.left&&_.right<=v.right&&_.top>=v.top&&_.bottom<=v.bottom}n.containsRect=p;function d(v,_){return Math.max(v.left,_.left)<=Math.min(v.right,_.right)&&Math.max(v.top,_.top)<=Math.min(v.bottom,_.bottom)}n.intersects=d;function y(v){return[{x:v.left,y:v.top,z:0},{x:v.right,y:v.top,z:0},{x:v.right,y:v.bottom,z:0},{x:v.left,y:v.bottom,z:0}]}n.asPath=y})(Me||(Me={}));var xr;(function(n){function t(y=0,v=0,_=0,I=0){return{left:y,top:v,right:_,bottom:I}}n.create=t;function e(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}}n.createInvalid=e;function r(y){return y.right-y.left}n.width=r;function i(y){return y.bottom-y.top}n.height=i;function u(y){return y.bottom<=y.top||y.right<=y.left}n.isEmpty=u;function l(y){return{x:(y.left+y.right)/2,y:(y.top+y.bottom)/2}}n.midPoint=l;function c(y,v){return v.x>y.left&&v.xy.top&&v.y=y.left&&v.right<=y.right&&v.top>=y.top&&v.bottom<=y.bottom}n.containsRect=h;function p(y,v){return Math.max(y.left,v.left)li.reverse64(l))}n.reverse64=r;function i(u){return u.map(l=>li.reverseD(l))}n.reverseD=i})(Gl||(Gl={}));var Bl=Me.createInvalid(),ql=xr.createInvalid();var me;(function(n){n[n.None=0]="None",n[n.OpenStart=1]="OpenStart",n[n.OpenEnd=2]="OpenEnd",n[n.LocalMax=4]="LocalMax",n[n.LocalMin=8]="LocalMin"})(me||(me={}));var zl=class{constructor(){et(this,"data",[])}push(t){this.data.push(t),this.siftUp(this.data.length-1)}pop(){if(this.data.length===0)return null;let t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.siftDown(0)),t}clear(){this.data.length=0}siftUp(t){for(;t>0;){let e=t-1>>1;if(this.data[e]>=this.data[t])break;[this.data[e],this.data[t]]=[this.data[t],this.data[e]],t=e}}siftDown(t){let e=this.data.length;for(;;){let r=t,i=(t<<1)+1,u=i+1;if(ithis.data[r]&&(r=i),uthis.data[r]&&(r=u),r===t)break;[this.data[t],this.data[r]]=[this.data[r],this.data[t]],t=r}}},Co=class{constructor(t,e,r){et(this,"pt");et(this,"next",null);et(this,"prev",null);et(this,"flags");this.pt=t,this.flags=e,this.prev=r}},No=class{constructor(t,e,r=!1){et(this,"vertex");et(this,"polytype");et(this,"isOpen");this.vertex=t,this.polytype=e,this.isOpen=r}equals(t){return t!==null&&this.vertex===t.vertex}};function Zg(n,t,e){return{pt:{x:n.x,y:n.y,z:n.z||0},edge1:t,edge2:e}}var bu=class bu{constructor(t,e){et(this,"_debugId");et(this,"pt");et(this,"next");et(this,"prev");et(this,"outrec");et(this,"horz");this._debugId=bu._nextId++,this.pt=t,this.outrec=e,this.next=this,this.prev=this,this.horz=null}};et(bu,"_nextId",1);var _r=bu,fn;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right"})(fn||(fn={}));var Xl;(function(n){n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top"})(Xl||(Xl={}));var Eu=class Eu{constructor(){et(this,"_debugId");et(this,"idx",0);et(this,"owner",null);et(this,"frontEdge",null);et(this,"backEdge",null);et(this,"pts",null);et(this,"polypath",null);et(this,"bounds",{left:0,top:0,right:0,bottom:0});et(this,"path",[]);et(this,"isOpen",!1);et(this,"splits",null);et(this,"recursiveSplit",null);this._debugId=Eu._nextId++}};et(Eu,"_nextId",1);var yu=Eu,vu=class{constructor(t){et(this,"leftOp");et(this,"rightOp");et(this,"leftToRight");this.leftOp=t,this.rightOp=null,this.leftToRight=!0}},To=class{constructor(t,e){et(this,"op1");et(this,"op2");this.op1=t,this.op2=e}},Oo=class{constructor(){et(this,"bot",{x:0,y:0,z:0});et(this,"top",{x:0,y:0,z:0});et(this,"curX",0);et(this,"dx",0);et(this,"windDx",0);et(this,"windCount",0);et(this,"windCount2",0);et(this,"outrec",null);et(this,"prevInAEL",null);et(this,"nextInAEL",null);et(this,"prevInSEL",null);et(this,"nextInSEL",null);et(this,"jump",null);et(this,"vertexTop",null);et(this,"localMin",null);et(this,"isLeftBound",!1);et(this,"joinWith",fn.None)}},xu;(function(n){function t(r,i,u,l){if((r.flags&me.LocalMin)!==me.None)return;r.flags|=me.LocalMin;let c=new No(r,i,u);l.push(c)}n.addLocMin=t;function e(r,i,u,l,c){for(let h=0,p=r.length;hy.pt.y}let I=_;v=y;let F=y.next;for(;F!==y;)F.pt.y>v.pt.y&&_?(v.flags|=me.LocalMax,_=!1):F.pt.y0&&(r+=this.children[l].toStringInternal(l,e+1));return r}toString(){if(this.level>0)return"";let t=this.children.length===1?"":"s",e=`Polytree with ${this.children.length} polygon${t}. `;for(let r=0;r0&&(e+=this.children[r].toStringInternal(r,1));return e+` `}};var Pu=class n extends _u{constructor(e=null){super(e);et(this,"scale",1);et(this,"polygon",null)}get poly(){return this.polygon}addChild(e){let r=new n(this);return r.scale=this.scale,r.polygon=zi.scalePathD(e,1/this.scale),this.children.push(r),r}addChildD(e){let r=new n(this);return r.scale=this.scale,r.polygon=e,this.children.push(r),r}child(e){if(e<0||e>=this.children.length)throw new Error("Index out of range");return this.children[e]}area(){let e=this.polygon===null?0:zi.areaD(this.polygon);for(let r of this.children)e+=r.area();return e}};var Pr=class extends Pu{get scaleValue(){return this.scale}},Br=class n{constructor(){et(this,"cliptype",ie.NoClip);et(this,"fillrule",ee.EvenOdd);et(this,"actives",null);et(this,"sel",null);et(this,"minimaList",[]);et(this,"intersectList",[]);et(this,"vertexList",[]);et(this,"outrecList",[]);et(this,"scanlineHeap",new zl);et(this,"scanlineSet",new Set);et(this,"scanlineArr",[]);et(this,"useScanlineArray",!1);et(this,"horzSegList",[]);et(this,"horzJoinList",[]);et(this,"currentLocMin",0);et(this,"currentBotY",0);et(this,"isSortedMinimaList",!1);et(this,"hasOpenPaths",!1);et(this,"usingPolytree",!1);et(this,"succeeded",!1);et(this,"preserveCollinear",!0);et(this,"reverseSolution",!1)}getZCallback(){}xyEqual(t,e){return t.x===e.x&&t.y===e.y}setZ(t,e,r){let i=this.getZCallback();i&&(n.getPolyType(t)===xe.Subject?(this.xyEqual(r,t.bot)?r.z=t.bot.z:this.xyEqual(r,t.top)?r.z=t.top.z:this.xyEqual(r,e.bot)?r.z=e.bot.z:this.xyEqual(r,e.top)?r.z=e.top.z:r.z=0,i(t.bot,t.top,e.bot,e.top,r)):(this.xyEqual(r,e.bot)?r.z=e.bot.z:this.xyEqual(r,e.top)?r.z=e.top.z:this.xyEqual(r,t.bot)?r.z=t.bot.z:this.xyEqual(r,t.top)?r.z=t.top.z:r.z=0,i(e.bot,e.top,t.bot,t.top,r)))}static isOdd(t){return(t&1)!==0}static isHotEdge(t){return t.outrec!=null}static isOpen(t){return t.localMin.isOpen}static isOpenEnd(t){return t.localMin.isOpen&&n.isOpenEndVertex(t.vertexTop)}static isOpenEndVertex(t){return(t.flags&(me.OpenStart|me.OpenEnd))!==me.None}static getPrevHotEdge(t){let e=t.prevInAEL;for(;e!==null&&(n.isOpen(e)||!n.isHotEdge(e));)e=e.prevInAEL;return e}static isFront(t){return t===t.outrec.frontEdge}static getDx(t,e){let r=e.y-t.y;return r!==0?(e.x-t.x)/r:e.x>t.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(t,e){return e===t.top.y||t.top.x===t.bot.x?t.top.x:e===t.bot.y?t.bot.x:_t.roundToEven(t.bot.x+t.dx*(e-t.bot.y))}static isHorizontal(t){return t.top.y===t.bot.y}static isHeadingRightHorz(t){return t.dx===Number.NEGATIVE_INFINITY}static isHeadingLeftHorz(t){return t.dx===Number.POSITIVE_INFINITY}static swapActives(t,e){return[e,t]}static getPolyType(t){return t.localMin.polytype}static isSamePolyType(t,e){return t.localMin.polytype===e.localMin.polytype}static setDx(t){t.dx=n.getDx(t.bot,t.top)}static nextVertex(t){return t.windDx>0?t.vertexTop.next:t.vertexTop.prev}static prevPrevVertex(t){return t.windDx>0?t.vertexTop.prev.prev:t.vertexTop.next.next}static isMaxima(t){return"flags"in t?(t.flags&me.LocalMax)!==me.None:n.isMaxima(t.vertexTop)}static getMaximaPair(t){let e=t.nextInAEL;for(;e!==null;){if(e.vertexTop===t.vertexTop)return e;e=e.nextInAEL}return null}boundingBoxesOverlap(t,e,r,i){let u=Math.min(t.x,e.x),l=Math.max(t.x,e.x),c=Math.min(t.y,e.y),h=Math.max(t.y,e.y),p=Math.min(r.x,i.x),d=Math.max(r.x,i.x),y=Math.min(r.y,i.y),v=Math.max(r.y,i.y);return!(le.vertex.pt.y-t.vertex.pt.y),this.isSortedMinimaList=!0),this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.useScanlineArray=this.minimaList.length<=16;for(let t=this.minimaList.length-1;t>=0;t--)this.insertScanline(this.minimaList[t].vertex.pt.y);this.currentBotY=0,this.currentLocMin=0,this.actives=null,this.sel=null,this.succeeded=!0}upgradeScanlineStructureFromArray(){let t=this.scanlineArr;for(let e=0,r=t.length;e64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(t)||(this.scanlineSet.add(t),this.scanlineHeap.push(t))}popScanline(){if(this.useScanlineArray){let e=this.scanlineArr,r=e.length;if(r===0)return{success:!1,y:0};let i=0,u=e[0];for(let l=1;lu&&(u=c,i=l)}return e[i]=e[r-1],e.pop(),{success:!0,y:u}}let t=this.scanlineHeap.pop();return t===null?{success:!1,y:0}:(this.scanlineSet.delete(t),{success:!0,y:t})}hasLocMinAtY(t){return this.currentLocMint.right&&(t.right=r.pt.x),r.pt.yt.bottom&&(t.bottom=r.pt.y),r=r.next;while(r!==e)}return Me.isEmpty(t)?{left:0,top:0,right:0,bottom:0}:t}executeInternal(t,e){if(t===ie.NoClip)return;this.fillrule=e,this.cliptype=t,this.reset();let r=this.popScanline();if(!r.success)return;let i=r.y;for(;this.succeeded;){this.insertLocalMinimaIntoAEL(i);let u;for(;(u=this.popHorz())!==null;)this.doHorizontal(u);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=i;let l=this.popScanline();if(!l.success)break;for(i=l.y,this.doIntersections(i),this.doTopOfScanbeam(i);(u=this.popHorz())!==null;)this.doHorizontal(u)}this.succeeded&&this.processHorzJoins()}insertLocalMinimaIntoAEL(t){for(;this.hasLocMinAtY(t);){let e=this.popLocalMinima(),r;(e.vertex.flags&me.OpenStart)!==me.None?r=null:(r=new Oo,r.bot={x:e.vertex.pt.x,y:e.vertex.pt.y,z:e.vertex.pt.z||0},r.curX=e.vertex.pt.x,r.windDx=-1,r.vertexTop=e.vertex.prev,r.top={x:e.vertex.prev.pt.x,y:e.vertex.prev.pt.y,z:e.vertex.prev.pt.z||0},r.outrec=null,r.localMin=e,n.setDx(r));let i;(e.vertex.flags&me.OpenEnd)!==me.None?i=null:(i=new Oo,i.bot={x:e.vertex.pt.x,y:e.vertex.pt.y,z:e.vertex.pt.z||0},i.curX=e.vertex.pt.x,i.windDx=1,i.vertexTop=e.vertex.next,i.top={x:e.vertex.next.pt.x,y:e.vertex.next.pt.y,z:e.vertex.next.pt.z||0},i.outrec=null,i.localMin=e,n.setDx(i)),r!==null&&i!==null?n.isHorizontal(r)?n.isHeadingRightHorz(r)&&([r,i]=n.swapActives(r,i)):n.isHorizontal(i)?n.isHeadingLeftHorz(i)&&([r,i]=n.swapActives(r,i)):r.dxp||!u&&d.curX_.x||!u&&n.topX(d,_.y)<_.x)break}else if(u&&n.topX(d,_.y)>=_.x||!u&&n.topX(d,_.y)<=_.x)break}}let v={x:d.curX,y:r};u?(this.intersectEdges(t,d,v),this.swapPositionsInAEL(t,d),this.checkJoinLeft(d,v),t.curX=d.curX,d=t.nextInAEL):(this.intersectEdges(d,t,v),this.swapPositionsInAEL(d,t),this.checkJoinRight(d,v),t.curX=d.curX,d=t.prevInAEL),n.isHotEdge(t)&&this.addToHorzSegList(this.getLastOp(t))}if(e&&n.isOpenEnd(t)){n.isHotEdge(t)&&(this.addOutPt(t,t.top),n.isFront(t)?t.outrec.frontEdge=null:t.outrec.backEdge=null,t.outrec=null),this.deleteFromAEL(t);return}if(n.nextVertex(t).pt.y!==t.top.y)break;n.isHotEdge(t)&&this.addOutPt(t,t.top),this.updateEdgeIntoAEL(t);let y=this.resetHorzDirection(t,i);h=y.leftX,p=y.rightX}if(n.isHotEdge(t)){let d=this.addOutPt(t,t.top);this.addToHorzSegList(d)}this.updateEdgeIntoAEL(t)}convertHorzSegsToJoins(){let t=0;for(let e of this.horzSegList)this.updateHorzSegment(e)&&t++;if(!(t<2)){this.horzSegList.sort((e,r)=>this.horzSegSort(e,r));for(let e=0;e=r.rightOp.pt.x||u.leftToRight===r.leftToRight||u.rightOp.pt.x<=r.leftOp.pt.x)continue;let l=r.leftOp.pt.y;if(r.leftToRight){for(;r.leftOp.next.pt.y===l&&r.leftOp.next.pt.x<=u.leftOp.pt.x;)r.leftOp=r.leftOp.next;for(;u.leftOp.prev.pt.y===l&&u.leftOp.prev.pt.x<=r.leftOp.pt.x;)u.leftOp=u.leftOp.prev;let c=new To(this.duplicateOp(r.leftOp,!0),this.duplicateOp(u.leftOp,!1));this.horzJoinList.push(c)}else{for(;r.leftOp.prev.pt.y===l&&r.leftOp.prev.pt.x<=u.leftOp.pt.x;)r.leftOp=r.leftOp.prev;for(;u.leftOp.next.pt.y===l&&u.leftOp.next.pt.x<=r.leftOp.pt.x;)u.leftOp=u.leftOp.next;let c=new To(this.duplicateOp(u.leftOp,!0),this.duplicateOp(r.leftOp,!1));this.horzJoinList.push(c)}}}}}updateHorzSegment(t){let e=t.leftOp,r=this.getRealOutRec(e.outrec),i=r.frontEdge!==null,u=e.pt.y,l=e,c=e;if(i){let p=r.pts,d=p.next;for(;l!==d&&l.prev.pt.y===u;)l=l.prev;for(;c!==p&&c.next.pt.y===u;)c=c.next}else{for(;l.prev!==c&&l.prev.pt.y===u;)l=l.prev;for(;c.next!==l&&c.next.pt.y===u;)c=c.next}let h=this.setHorzSegHeadingForward(t,l,c)&&t.leftOp.horz===null;return h?t.leftOp.horz=t:t.rightOp=null,h}setHorzSegHeadingForward(t,e,r){return e.pt.x===r.pt.x?!1:(e.pt.xt.y;)r=r.next;if(r===e)break;if(r.pt.y===t.y){if(r.pt.x===t.x||r.pt.y===r.prev.pt.y&&t.x0}processIntersectList(){this.intersectList.sort((t,e)=>t.pt.y!==e.pt.y?t.pt.y>e.pt.y?-1:1:t.pt.x!==e.pt.x?t.pt.xe.edge2.curX?1:0);for(let t=0;tthis.currentBotY||u.y100&&h>100?c>h?u=_t.getClosestPtOnSegment(u,t.bot,t.top):u=_t.getClosestPtOnSegment(u,e.bot,e.top):c>100?u=_t.getClosestPtOnSegment(u,t.bot,t.top):h>100?u=_t.getClosestPtOnSegment(u,e.bot,e.top):(u.y0)for(;e.next.pt.y===e.pt.y&&(e.flags&(me.OpenEnd|me.LocalMax))===me.None;)e=e.next;else for(;e.prev.pt.y===e.pt.y&&(e.flags&(me.OpenEnd|me.LocalMax))===me.None;)e=e.prev;return n.isMaxima(e)||(e=null),e}getCurrYMaximaVertex(t){let e=t.vertexTop;if(t.windDx>0)for(;e.next.pt.y===e.pt.y;)e=e.next;else for(;e.prev.pt.y===e.pt.y;)e=e.prev;return n.isMaxima(e)||(e=null),e}resetHorzDirection(t,e){if(t.bot.x===t.top.x){let r=t.curX,i=t.curX,u=t.nextInAEL;for(;u!==null&&u.vertexTop!==e;)u=u.nextInAEL;return{isLeftToRight:u!==null,leftX:r,rightX:i}}return t.curX1?e.windDx*t.windDx<0?t.windCount=e.windCount:t.windCount=e.windCount+t.windDx:t.windCount=n.isOpen(t)?1:t.windDx:e.windDx*t.windDx<0?t.windCount=e.windCount:t.windCount=e.windCount+t.windDx,t.windCount2=e.windCount2,e=e.nextInAEL),this.fillrule===ee.EvenOdd)for(;e!==t;)n.getPolyType(e)!==r&&!n.isOpen(e)&&(t.windCount2=t.windCount2===0?1:0),e=e.nextInAEL;else for(;e!==t;)n.getPolyType(e)!==r&&!n.isOpen(e)&&(t.windCount2+=e.windDx),e=e.nextInAEL}isContributingOpen(t){let e,r;switch(this.fillrule){case ee.Positive:r=t.windCount>0,e=t.windCount2>0;break;case ee.Negative:r=t.windCount<0,e=t.windCount2<0;break;default:r=t.windCount!==0,e=t.windCount2!==0;break}switch(this.cliptype){case ie.Intersection:return e;case ie.Union:return!r&&!e;default:return!e}}isContributingClosed(t){switch(this.fillrule){case ee.Positive:if(t.windCount!==1)return!1;break;case ee.Negative:if(t.windCount!==-1)return!1;break;case ee.NonZero:if(Math.abs(t.windCount)!==1)return!1;break}switch(this.cliptype){case ie.Intersection:return this.fillrule===ee.Positive?t.windCount2>0:this.fillrule===ee.Negative?t.windCount2<0:t.windCount2!==0;case ie.Union:return this.fillrule===ee.Positive?t.windCount2<=0:this.fillrule===ee.Negative?t.windCount2>=0:t.windCount2===0;case ie.Difference:let e=this.fillrule===ee.Positive?t.windCount2<=0:this.fillrule===ee.Negative?t.windCount2>=0:t.windCount2===0;return n.getPolyType(t)===xe.Subject?e:!e;case ie.Xor:return!0;default:return!1}}addLocalMinPoly(t,e,r,i=!1){let u=this.newOutRec();if(t.outrec=u,e.outrec=u,n.isOpen(t))u.owner=null,u.isOpen=!0,t.windDx>0?this.setSides(u,t,e):this.setSides(u,e,t);else{u.isOpen=!1;let c=n.getPrevHotEdge(t);c!==null?(this.usingPolytree&&this.setOwner(u,c.outrec),u.owner=c.outrec,this.outrecIsAscending(c)===i?this.setSides(u,e,t):this.setSides(u,t,e)):(u.owner=null,i?this.setSides(u,t,e):this.setSides(u,e,t))}let l=new _r(r,u);return u.pts=l,l}outrecIsAscending(t){return t===t.outrec.frontEdge}newOutRec(){let t=new yu;return t.idx=this.outrecList.length,this.outrecList.push(t),t}startOpenPath(t,e){let r=this.newOutRec();r.isOpen=!0,t.windDx>0?(r.frontEdge=t,r.backEdge=null):(r.frontEdge=null,r.backEdge=t),t.outrec=r;let i=new _r(e,r);return r.pts=i,i}checkJoinLeft(t,e,r=!1){let i=t.prevInAEL;if(!(i===null||!n.isHotEdge(t)||!n.isHotEdge(i)||n.isHorizontal(t)||n.isHorizontal(i)||n.isOpen(t)||n.isOpen(i))&&!((e.ye.y||i.bot.y>e.y))){if(r){if(this.perpendicDistFromLineSqrd(e,i.bot,i.top)>.25)return}else if(t.curX!==i.curX)return;_t.isCollinear(t.top,e,i.top)&&(t.outrec.idx===i.outrec.idx?this.addLocalMaxPoly(i,t,e):t.outrec.idxe.y||i.bot.y>e.y))){if(r){if(this.perpendicDistFromLineSqrd(e,i.bot,i.top)>.25)return}else if(t.curX!==i.curX)return;_t.isCollinear(t.top,e,i.top)&&(t.outrec.idx===i.outrec.idx?this.addLocalMaxPoly(t,i,e):t.outrec.idx0?this.setSides(p.outrec,t,p):this.setSides(p.outrec,p,t);return}i=this.startOpenPath(t,r)}else i=this.startOpenPath(t,r);this.setZ(t,e,i.pt);return}this.isJoined(t)&&this.split(t,r),this.isJoined(e)&&this.split(e,r);let u,l;switch(t.localMin.polytype===e.localMin.polytype?this.fillrule===ee.EvenOdd?(u=t.windCount,t.windCount=e.windCount,e.windCount=u):(t.windCount+e.windDx===0?t.windCount=-t.windCount:t.windCount+=e.windDx,e.windCount-t.windDx===0?e.windCount=-e.windCount:e.windCount-=t.windDx):(this.fillrule!==ee.EvenOdd?t.windCount2+=e.windDx:t.windCount2=t.windCount2===0?1:0,this.fillrule!==ee.EvenOdd?e.windCount2-=t.windDx:e.windCount2=e.windCount2===0?1:0),this.fillrule){case ee.Positive:u=t.windCount,l=e.windCount;break;case ee.Negative:u=-t.windCount,l=-e.windCount;break;default:u=Math.abs(t.windCount),l=Math.abs(e.windCount);break}let c=u===0||u===1,h=l===0||l===1;if(!(!n.isHotEdge(t)&&!c||!n.isHotEdge(e)&&!h))if(n.isHotEdge(t)&&n.isHotEdge(e))if(u!==0&&u!==1||l!==0&&l!==1||t.localMin.polytype!==e.localMin.polytype&&this.cliptype!==ie.Xor)i=this.addLocalMaxPoly(t,e,r),i&&this.setZ(t,e,i.pt);else if(n.isFront(t)||t.outrec===e.outrec){i=this.addLocalMaxPoly(t,e,r),i&&this.setZ(t,e,i.pt);let p=this.addLocalMinPoly(t,e,r);this.setZ(t,e,p.pt)}else{i=this.addOutPt(t,r),this.setZ(t,e,i.pt);let p=this.addOutPt(e,r);this.setZ(t,e,p.pt),this.swapOutrecs(t,e)}else if(n.isHotEdge(t))i=this.addOutPt(t,r),this.setZ(t,e,i.pt),this.swapOutrecs(t,e);else if(n.isHotEdge(e))i=this.addOutPt(e,r),this.setZ(t,e,i.pt),this.swapOutrecs(t,e);else{let p,d;switch(this.fillrule){case ee.Positive:p=t.windCount2,d=e.windCount2;break;case ee.Negative:p=-t.windCount2,d=-e.windCount2;break;default:p=Math.abs(t.windCount2),d=Math.abs(e.windCount2);break}if(!n.isSamePolyType(t,e))i=this.addLocalMinPoly(t,e,r),this.setZ(t,e,i.pt);else if(u===1&&l===1){switch(i=null,this.cliptype){case ie.Union:if(p>0&&d>0)return;i=this.addLocalMinPoly(t,e,r);break;case ie.Difference:(n.getPolyType(t)===xe.Clip&&p>0&&d>0||n.getPolyType(t)===xe.Subject&&p<=0&&d<=0)&&(i=this.addLocalMinPoly(t,e,r));break;case ie.Xor:i=this.addLocalMinPoly(t,e,r);break;default:if(p<=0||d<=0)return;i=this.addLocalMinPoly(t,e,r);break}i&&this.setZ(t,e,i.pt)}}}swapPositionsInAEL(t,e){let r=e.nextInAEL;r!==null&&(r.prevInAEL=t);let i=t.prevInAEL;i!==null&&(i.nextInAEL=e),e.prevInAEL=i,e.nextInAEL=t,t.prevInAEL=e,t.nextInAEL=r,e.prevInAEL===null&&(this.actives=e)}isValidAelOrder(t,e){if(e.curX!==t.curX)return e.curX>t.curX;let r=_t.crossProduct(t.top,e.bot,e.top);if(r!==0)return r<0;if(!n.isMaxima(t)&&t.top.y>e.top.y)return _t.crossProduct(e.bot,t.top,n.nextVertex(t).pt)<=0;if(!n.isMaxima(e)&&e.top.y>t.top.y)return _t.crossProduct(e.bot,e.top,n.nextVertex(e).pt)>=0;let i=e.bot.y,u=e.isLeftBound;return t.bot.y!==i||t.localMin.vertex.pt.y!==i?e.isLeftBound:t.isLeftBound!==u?u:_t.isCollinear(n.prevPrevVertex(t).pt,t.bot,t.top)?!0:_t.crossProduct(n.prevPrevVertex(t).pt,e.bot,n.prevPrevVertex(e).pt)>0===u}isJoined(t){return t.joinWith!==fn.None}split(t,e){t.joinWith===fn.Right?(t.joinWith=fn.None,t.nextInAEL.joinWith=fn.None,this.addLocalMinPoly(t,t.nextInAEL,e,!0)):(t.joinWith=fn.None,t.prevInAEL.joinWith=fn.None,this.addLocalMinPoly(t.prevInAEL,t,e,!0))}setSides(t,e,r){t.frontEdge=e,t.backEdge=r}findEdgeWithMatchingLocMin(t){var r,i;let e=t.nextInAEL;for(;e!==null;){if((r=e.localMin)!=null&&r.equals(t.localMin))return e;!n.isHorizontal(e)&&!(t.bot.x===e.bot.x&&t.bot.y===e.bot.y)?e=null:e=e.nextInAEL}for(e=t.prevInAEL;e!==null;){if((i=e.localMin)!=null&&i.equals(t.localMin))return e;if(!n.isHorizontal(e)&&!(t.bot.x===e.bot.x&&t.bot.y===e.bot.y))return null;e=e.prevInAEL}return e}addOutPt(t,e){let r=t.outrec,i=n.isFront(t),u=r.pts,l=u.next;if(i&&e.x===u.pt.x&&e.y===u.pt.y)return u;if(!i&&e.x===l.pt.x&&e.y===l.pt.y)return l;let c=new _r(e,r);return l.prev=c,c.prev=u,c.next=l,u.next=c,i&&(r.pts=c),c}addLocalMaxPoly(t,e,r){if(this.isJoined(t)&&this.split(t,r),this.isJoined(e)&&this.split(e,r),n.isFront(t)===n.isFront(e))if(n.isOpenEnd(t))this.swapFrontBackSides(t.outrec);else if(n.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else return this.succeeded=!1,null;let i=this.addOutPt(t,r);if(t.outrec===e.outrec){let u=t.outrec;if(u.pts=i,this.usingPolytree){let l=n.getPrevHotEdge(t);l===null?u.owner=null:this.setOwner(u,l.outrec)}this.uncoupleOutRec(t)}else n.isOpen(t)?t.windDx<0?this.joinOutrecPaths(t,e):this.joinOutrecPaths(e,t):t.outrec.idx1)||!(d>h)&&p>0!=c>0)return;let y=this.newOutRec();y.owner=t.owner,e.outrec=y,e.next.outrec=y;let v=new _r(l,y);v.prev=e.next,v.next=e,y.pts=v,e.prev=v,e.next.next=v,this.usingPolytree&&(this.path1InsidePath2(r,v)?(y.splits===null&&(y.splits=[]),y.splits.push(t.idx)):(t.splits===null&&(t.splits=[]),t.splits.push(y.idx)))}static areaOutPt(t){let e=0,r=t;do e+=(r.prev.pt.y+r.pt.y)*(r.prev.pt.x-r.pt.x),r=r.next;while(r!==t);return e*.5}areaTriangle(t,e,r){return(r.y+t.y)*(r.x-t.x)+(t.y+e.y)*(t.x-e.x)+(e.y+r.y)*(e.x-r.x)}isValidOwner(t,e){for(;e!==null&&e!==t;)e=e.owner;return e===null}containsRect(t,e){return e.left>=t.left&&e.right<=t.right&&e.top>=t.top&&e.bottom<=t.bottom}checkSplitOwner(t,e){for(let r=0;r=0&&u.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},Ee=class Ee{constructor(t=2,e=0,r=!1,i=!1){et(this,"groupList",[]);et(this,"pathOut",[]);et(this,"normals",[]);et(this,"solution",[]);et(this,"solutionTree",null);et(this,"groupDelta",0);et(this,"delta",0);et(this,"mitLimSqr",0);et(this,"stepsPerRad",0);et(this,"stepSin",0);et(this,"stepCos",0);et(this,"joinType",cr.Bevel);et(this,"endType",Te.Polygon);et(this,"arcTolerance",0);et(this,"mergeGroups",!0);et(this,"miterLimit",2);et(this,"preserveCollinear",!1);et(this,"reverseSolution",!1);et(this,"zCallback");et(this,"deltaCallback",null);et(this,"ZCB",(t,e,r,i,u)=>{(t.z||0)!==0&&(t.z===r.z||t.z===i.z)?u.z=t.z:(r.z||0)!==0&&r.z===e.z?u.z=r.z:(e.z||0)!==0&&e.z===i.z?u.z=e.z:this.zCallback&&this.zCallback(t,e,r,i,u)});this.miterLimit=t,this.arcTolerance=e,this.mergeGroups=!0,this.preserveCollinear=r,this.reverseSolution=i}clear(){this.groupList.length=0}addPath(t,e,r){if(t.length===0)return;let i=[t];this.addPaths(i,e,r)}addPaths(t,e,r){t.length!==0&&this.groupList.push(new Ul(t,e,r))}calcSolutionCapacity(){let t=0;for(let e of this.groupList)t+=e.endType===Te.Joined?e.inPaths.length*2:e.inPaths.length;return t}checkPathsReversed(){let t=!1;for(let e of this.groupList)if(e.endType===Te.Polygon){t=e.pathsReversed;break}return t}executeInternal(t){if(this.groupList.length===0)return;if(Math.abs(t)<.5){for(let u of this.groupList)for(let l of u.inPaths)this.solution.push(l);return}this.delta=t,this.mitLimSqr=this.miterLimit<=1?2:2/Ee.sqr(this.miterLimit);for(let u of this.groupList)this.doGroupOffset(u);if(this.groupList.length===0)return;let e=this.checkPathsReversed(),r=e?ee.Negative:ee.Positive,i=new lr;i.preserveCollinear=this.preserveCollinear,i.reverseSolution=this.reverseSolution!==e,i.zCallback=this.ZCB,i.addSubject(this.solution),this.solutionTree!==null?i.execute(ie.Union,r,this.solutionTree):i.execute(ie.Union,r,this.solution)}execute(t,e){if(Array.isArray(e)){let r=e;r.length=0,this.solution=r,this.executeInternal(t)}else{let r=e;r.clear(),this.solutionTree=r,this.solution=[],this.executeInternal(t)}}executeWithCallback(t,e){this.deltaCallback=t,this.execute(1,e)}static getUnitNormal(t,e){let r=e.x-t.x,i=e.y-t.y;if(r===0&&i===0)return{x:0,y:0};let u=1/Math.sqrt(r*r+i*i);return{x:i*u,y:-r*u}}static getLowestPathInfo(t){let e=-1,r=!1,i={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let u=0;u=i.x)){if(l===Number.MAX_VALUE){if(l=Ee.area(t[u]),l===0)break;r=l<0}e=u,i.x=c.x,i.y=c.y}}return{idx:e,isNegArea:r}}static translatePoint(t,e,r){return{x:t.x+e,y:t.y+r}}static reflectPoint(t,e){return{x:e.x+(e.x-t.x),y:e.y+(e.y-t.y)}}static almostZero(t,e=.001){return Math.abs(t).01?this.arcTolerance:h*Ee.arc_const,d=Math.PI/Math.acos(1-p/h);this.stepSin=Math.sin(2*Math.PI/d),this.stepCos=Math.cos(2*Math.PI/d),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=d/(2*Math.PI)}let u=t[e],l={x:this.normals[r].x*this.groupDelta,y:this.normals[r].y*this.groupDelta};e===r&&Fn.negate(l),this.pathOut.push({x:Math.round(u.x+l.x),y:Math.round(u.y+l.y)});let c=Math.ceil(this.stepsPerRad*Math.abs(i));for(let h=1;h1?u=1:u<-1&&(u=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(e,this.normals,r,i),t.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)-.999&&u*this.groupDelta<0)this.pathOut.push(this.getPerpendic(e[r],this.normals[i])),this.pathOut.push(e[r]),this.pathOut.push(this.getPerpendic(e[r],this.normals[r]));else if(l>.999&&this.joinType!==cr.Round)this.doMiter(e,r,i,l);else switch(this.joinType){case cr.Miter:l>this.mitLimSqr-1?this.doMiter(e,r,i,l):this.doSquare(e,r,i);break;case cr.Round:this.doRound(e,r,i,Math.atan2(u,l));break;case cr.Bevel:this.doBevel(e,r,i);break;default:this.doSquare(e,r,i);break}}offsetPolygon(t,e){this.pathOut=[];let r=e.length,i=r-1;for(let u=0;u0;i--)this.normals[i]={x:-this.normals[i-1].x,y:-this.normals[i-1].y};if(this.normals[0]=this.normals[r],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(e,this.normals,r,r)),Math.abs(this.groupDelta)0;i--)this.offsetPoint(t,e,i,u),u=i;this.solution.push([...this.pathOut])}doGroupOffset(t){t.endType===Te.Polygon?(t.lowestPathIdx<0&&(this.delta=Math.abs(this.delta)),this.groupDelta=t.pathsReversed?-this.delta:this.delta):this.groupDelta=Math.abs(this.delta);let e=Math.abs(this.groupDelta);if(this.joinType=t.joinType,this.endType=t.endType,t.joinType===cr.Round||t.endType===Te.Round){let r=this.arcTolerance>.01?this.arcTolerance:e*Ee.arc_const,i=Math.PI/Math.acos(1-r/e);this.stepSin=Math.sin(2*Math.PI/i),this.stepCos=Math.cos(2*Math.PI/i),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=i/(2*Math.PI)}for(let r of t.inPaths){this.pathOut=[];let i=r.length;if(i===1){let u=r[0];if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0),t.pathsReversed&&(this.groupDelta=-this.groupDelta)),t.endType===Te.Round){let l=Math.ceil(this.stepsPerRad*2*Math.PI);this.pathOut=Ee.ellipse(u,Math.abs(this.groupDelta),Math.abs(this.groupDelta),l)}else{let l=Math.ceil(Math.abs(this.groupDelta)),c={left:u.x-l,top:u.y-l,right:u.x+l,bottom:u.y+l};this.pathOut=[{x:c.left,y:c.top},{x:c.right,y:c.top},{x:c.right,y:c.bottom},{x:c.left,y:c.bottom}]}this.solution.push([...this.pathOut]);continue}switch(i===2&&t.endType===Te.Joined&&(this.endType=t.joinType===cr.Round?Te.Round:Te.Square),this.buildNormals(r),this.endType){case Te.Polygon:this.offsetPolygon(t,r);break;case Te.Joined:this.offsetOpenJoined(t,r);break;default:this.offsetOpenPath(t,r);break}}}static stripDuplicates(t,e){let r=t.length,i=[];if(r===0)return i;let u=t[0];i.push(u);for(let l=1;l1)break}return r<=0}static isClockwise(t,e,r,i,u){return n.areOpposites(t,e)?_t.crossProduct(r,u,i)<0:n.headingClockwise(t,e)}static areOpposites(t,e){return Math.abs(t-e)===2}static headingClockwise(t,e){return(t+1)%4===e}static getAdjacentLocation(t,e){return(t+(e?1:3))%4}static unlinkOp(t){return t.next===t?null:(t.prev.next=t.next,t.next.prev=t.prev,t.next)}static unlinkOpBack(t){return t.next===t?null:(t.prev.next=t.next,t.next.prev=t.prev,t.prev)}static getEdgesForPt(t,e){let r=0;return t.x===e.left?r=1:t.x===e.right&&(r=4),t.y===e.top?r+=2:t.y===e.bottom&&(r+=8),r}static isHeadingClockwise(t,e,r){switch(r){case 0:return e.yt.x;case 2:return e.y>t.y;default:return e.xr.x}static hasVertOverlap(t,e,r,i){return t.yr.y}static addToEdge(t,e){e.edge===null&&(e.edge=t,t.push(e))}static uncoupleEdge(t){if(t.edge!==null){for(let e=0;e=t.top&&e.y<=t.bottom)return{location:kt.left,isOnRect:!0};if(e.x===t.right&&e.y>=t.top&&e.y<=t.bottom)return{location:kt.right,isOnRect:!0};if(e.y===t.top&&e.x>=t.left&&e.x<=t.right)return{location:kt.top,isOnRect:!0};if(e.y===t.bottom&&e.x>=t.left&&e.x<=t.right)return{location:kt.bottom,isOnRect:!0};let r;return e.xt.right?r=kt.right:e.yt.bottom?r=kt.bottom:r=kt.inside,{location:r,isOnRect:!1}}static isHorizontal(t,e){return t.y===e.y}static getSegmentIntersection(t,e,r,i){let u=_t.crossProduct(t,r,i),l=_t.crossProduct(e,r,i);if(u===0){let p=t;return l===0?{intersects:!1,point:p}:ue.equals(t,r)||ue.equals(t,i)?{intersects:!0,point:p}:n.isHorizontal(r,i)?{intersects:t.x>r.x==t.xr.y==t.yr.x==e.xr.y==e.y0==l>0)return{intersects:!1,point:{x:0,y:0}};let c=_t.crossProduct(r,t,e),h=_t.crossProduct(i,t,e);if(c===0){let p=r;return ue.equals(r,t)||ue.equals(r,e)?{intersects:!0,point:p}:n.isHorizontal(t,e)?{intersects:r.x>t.x==r.xt.y==r.yt.x==i.xt.y==i.y0==h>0?{intersects:!1,point:{x:0,y:0}}:_t.getLineIntersectPt(t,e,r,i)}static getIntersection(t,e,r,i){let u={x:0,y:0},l=i;switch(i){case kt.left:{let c=n.getSegmentIntersection(e,r,t[0],t[3]);if(c.intersects)return u=c.point,{intersects:!0,point:u,newLocation:l};if(e.yi)break;t[u].x>=this.rect.right?l=kt.right:t[u].y<=this.rect.top?l=kt.top:t[u].y>=this.rect.bottom?l=kt.bottom:l=kt.inside;break;case kt.top:for(;u<=i&&t[u].y<=this.rect.top;)u++;if(u>i)break;t[u].y>=this.rect.bottom?l=kt.bottom:t[u].x<=this.rect.left?l=kt.left:t[u].x>=this.rect.right?l=kt.right:l=kt.inside;break;case kt.right:for(;u<=i&&t[u].x>=this.rect.right;)u++;if(u>i)break;t[u].x<=this.rect.left?l=kt.left:t[u].y<=this.rect.top?l=kt.top:t[u].y>=this.rect.bottom?l=kt.bottom:l=kt.inside;break;case kt.bottom:for(;u<=i&&t[u].y>=this.rect.bottom;)u++;if(u>i)break;t[u].y<=this.rect.top?l=kt.top:t[u].x<=this.rect.left?l=kt.left:t[u].x>=this.rect.right?l=kt.right:l=kt.inside;break;case kt.inside:for(;u<=i;){if(t[u].xthis.rect.right)l=kt.right;else if(t[u].y>this.rect.bottom)l=kt.bottom;else if(t[u].y0}executeInternal(t){if(t.length<3||Me.isEmpty(this.rect))return;let e=[],r=kt.inside,i=r,u=r,l=t.length-1,c=n.getLocation(this.rect,t[l]),h=c.location;if(c.isOnRect){let y=l-1;for(;y>=0;){let v=n.getLocation(this.rect,t[y]);if(!v.isOnRect){u=v.location;break}y--}if(y<0){for(let v of t)this.add(v);return}u===kt.inside&&(h=kt.inside)}let p=h,d=0;for(;d<=l;){u=h;let y=i,v=this.getNextLocation(t,h,d,l);if(h=v.location,d=v.index,d>l)break;let _=d===0?t[l]:t[d-1];i=h;let I=n.getIntersection(this.rectPath,t[d],_,i);if(!I.intersects){if(y===kt.inside){let M=n.isClockwise(u,h,_,t[d],this.mp);do e.push(u),u=n.getAdjacentLocation(u,M);while(u!==h);i=y}else if(u!==kt.inside&&u!==h){let M=n.isClockwise(u,h,_,t[d],this.mp);do u=this.addCornerWithDirection(u,M);while(u!==h)}++d;continue}let F=I.point;if(i=I.newLocation,h===kt.inside){if(r===kt.inside)r=i,e.push(u);else if(u!==i){let M=n.isClockwise(u,i,_,t[d],this.mp);do u=this.addCornerWithDirection(u,M);while(u!==i)}}else if(u!==kt.inside){h=u;let L=n.getIntersection(this.rectPath,_,t[d],h).point;if(y!==kt.inside&&y!==h&&this.addCorner(y,h),r===kt.inside&&(r=h,e.push(u)),h=i,this.add(L),ue.equals(F,L)){h=n.getLocation(this.rect,t[d]).location,this.addCorner(i,h),i=h;continue}}else h=i,r===kt.inside&&(r=i);this.add(F)}if(r===kt.inside){if(p===kt.inside||!Me.containsRect(this.pathBounds,this.rect)||!n.path1ContainsPath2(t,this.rectPath))return;let y=n.startLocsAreClockwise(e);for(let v=0;v<4;v++){let _=y?v:3-v;this.add(this.rectPath[_]),n.addToEdge(this.edges[_*2],this.results[0])}}else if(h!==kt.inside&&(h!==r||e.length>2)){if(e.length>0){u=h;for(let y of e)u!==y&&(u=this.addCornerWithDirection(u,n.headingClockwise(u,y)),u=y);h=u}h!==r&&this.addCornerWithDirection(h,n.headingClockwise(h,r))}}execute(t){let e=[];if(Me.isEmpty(this.rect))return e;for(let r of t)if(!(r.length<3)&&(this.pathBounds=_t.getBounds(r),!!Me.intersects(this.rect,this.pathBounds))){if(Me.containsRect(this.rect,this.pathBounds)){e.push(r);continue}this.executeInternal(r),this.checkEdges();for(let i=0;i<4;++i)this.tidyEdgePair(i,this.edges[i*2],this.edges[i*2+1]);for(let i of this.results){let u=this.getPath(i);u.length>0&&e.push(u)}this.results.length=0;for(let i=0;i<8;i++)this.edges[i].length=0}return e}checkEdges(){for(let t=0;tI.prev.pt.x,L=F.pt.x>F.prev.pt.x):(M=I.pt.y>I.prev.pt.y,L=F.pt.y>F.prev.pt.y),I.next===I.prev||ue.equals(I.pt,I.prev.pt)?L===u?(e[l]=F,r[c++]=null):(r[c]=F,e[l++]=null):F.next===F.prev||ue.equals(F.pt,F.prev.pt)?M===u?(e[l]=I,r[c++]=null):(r[c]=I,e[l++]=null):M===L?M===u?(e[l]=I,n.uncoupleEdge(F),n.addToEdge(e,F),r[c++]=null):(e[l++]=null,r[c]=F,n.uncoupleEdge(I),n.addToEdge(r,I),c=0):(M===u?e[l]=I:r[c]=I,L===u?e[l]=F:r[c]=F)}}getPath(t){let e=[];if(t===null||t.prev===t.next)return e;let r=t.next;for(;r!==null&&r!==t;)_t.isCollinear(r.prev.pt,r.pt,r.next.pt)?(t=r.prev,r=n.unlinkOp(r)):r=r.next;if(r===null)return[];for(e.push(t.pt),r=t.next;r!==t;)e.push(r.pt),r=r.next;return e}},Xi=class extends jn{constructor(t){super(t)}execute(t){let e=[];if(Me.isEmpty(this.rect))return e;for(let r of t)if(!(r.length<2)&&(this.pathBounds=_t.getBounds(r),!!Me.intersects(this.rect,this.pathBounds))){this.executeInternalLines(r);for(let i of this.results){let u=this.getPathLines(i);u.length>0&&e.push(u)}this.results.length=0;for(let i=0;i<8;i++)this.edges[i].length=0}return e}getPathLines(t){let e=[];if(t===null||t===t.next)return e;t=t.next,e.push(t.pt);let r=t.next;for(;r!==t;)e.push(r.pt),r=r.next;return e}executeInternalLines(t){if(this.results.length=0,t.length<2||Me.isEmpty(this.rect))return;let e=kt.inside,r=1,i=t.length-1,u=jn.getLocation(this.rect,t[0]),l=u.location;if(u.isOnRect){for(;r<=i;){let c=jn.getLocation(this.rect,t[r]);if(!c.isOnRect){e=c.location;break}r++}if(r>i){for(let c of t)this.add(c);return}e===kt.inside&&(l=kt.inside),r=1}for(l===kt.inside&&this.add(t[0]);r<=i;){e=l;let c=this.getNextLocation(t,l,r,i);if(l=c.location,r=c.index,r>i)break;let h=t[r-1],p=l,d=jn.getIntersection(this.rectPath,t[r],h,p);if(!d.intersects){++r;continue}let y=d.point;if(p=d.newLocation,l===kt.inside)this.add(y,!0);else if(e!==kt.inside){p=e;let _=jn.getIntersection(this.rectPath,h,t[r],p).point;this.add(_,!0),this.add(y)}else this.add(y)}}};var zr;(function(n){function t(v,_,I,F){let M=F?0:1,L=v.length,C=_.length,q=[];for(let J of _){let k=[];if(I)for(let N of v)k.push(ue.add(J,N));else for(let N of v)k.push(ue.subtract(J,N));q.push(k)}let V=[],X=F?C-1:0,G=L-1;for(let J=M;J=0}function c(v){let _=0,I=v.length;if(I<3)return 0;let F=v[I-1];for(let M of v)_+=(F.y+M.y)*(F.x-M.x),F=M;return _*.5}function h(v){return[...v].reverse()}function p(v,_){let I=[];for(let F of v)I.push({x:_t.roundToEven(F.x*_),y:_t.roundToEven(F.y*_)});return I}function d(v,_){let I=[];for(let F of v){let M=[];for(let L of F)M.push({x:L.x*_,y:L.y*_});I.push(M)}return I}function y(v,_){let I=[],F=new lr;return F.addPaths(v,xe.Subject),F.execute(ie.Union,_,I),I}})(zr||(zr={}));var Er;(function(n){n[n.success=0]="success",n[n.fail=1]="fail",n[n.noPolygons=2]="noPolygons",n[n.pathsIntersect=3]="pathsIntersect"})(Er||(Er={}));var Ae;(function(n){n[n.loose=0]="loose",n[n.ascend=1]="ascend",n[n.descend=2]="descend"})(Ae||(Ae={}));var Ln;(function(n){n[n.none=0]="none",n[n.collinear=1]="collinear",n[n.intersect=2]="intersect"})(Ln||(Ln={}));var br;(function(n){n[n.neither=0]="neither",n[n.left=1]="left",n[n.right=2]="right"})(br||(br={}));var Ao=class{constructor(t){et(this,"pt");et(this,"edges",[]);et(this,"innerLM",!1);this.pt=t}},Yl=class{constructor(){et(this,"vL",null);et(this,"vR",null);et(this,"vB",null);et(this,"vT",null);et(this,"kind",Ae.loose);et(this,"triA",null);et(this,"triB",null);et(this,"isActive",!1);et(this,"nextE",null);et(this,"prevE",null)}},Jl=class{constructor(t,e,r){et(this,"edges",new Array(3));this.edges[0]=t,this.edges[1]=e,this.edges[2]=r}},Ui=class n{constructor(t=!0){et(this,"allVertices",[]);et(this,"allEdges",[]);et(this,"allTriangles",[]);et(this,"pendingDelaunayStack",[]);et(this,"horzEdgeStack",[]);et(this,"locMinStack",[]);et(this,"useDelaunay");et(this,"firstActive",null);et(this,"lowermostVertex",null);this.useDelaunay=t}addPath(t){let e=t.length;if(e===0)return;let r=0,i,u,l=n.findLocMinIdx(t,e,r);if(!l.found)return;for(r=l.idx,i=n.prev(r,e);t[i].x===t[r].x&&t[i].y===t[r].y;)i=n.prev(i,e);u=n.next(r,e);let c=r;for(;_t.crossProductSign(t[i],t[c],t[u])===0;){let _=n.findLocMinIdx(t,e,c);if(!_.found)return;for(c=_.idx,i=n.prev(c,e);t[i].x===t[c].x&&t[i].y===t[c].y;)i=n.prev(i,e);u=n.next(c,e)}let h=this.allVertices.length,p=new Ao(t[c]);this.allVertices.push(p),n.leftTurning(t[i],t[c],t[u])&&(p.innerLM=!0);let d=p;for(c=u;;){if(this.locMinStack.push(d),(this.lowermostVertex===null||d.pt.y>this.lowermostVertex.pt.y||d.pt.y===this.lowermostVertex.pt.y&&d.pt.x=d.pt.y;){let I=new Ao(t[c]);for(this.allVertices.push(I),this.createEdge(I,d,Ae.descend),d=I,c=u,u=n.next(c,e);_t.crossProductSign(d.pt,t[c],t[u])===0;)c=u,u=n.next(c,e)}if(c===r)break;n.leftTurning(_.pt,d.pt,t[c])&&(d.innerLM=!0)}this.createEdge(p,d,Ae.descend);let y=this.allVertices.length-h,v=h;if(y<3||y===3&&(n.distSqr(this.allVertices[v].pt,this.allVertices[v+1].pt)<=1||n.distSqr(this.allVertices[v+1].pt,this.allVertices[v+2].pt)<=1||n.distSqr(this.allVertices[v+2].pt,this.allVertices[v].pt)<=1))for(let _=h;_2}cleanUp(){this.allVertices.length=0,this.allEdges.length=0,this.allTriangles.length=0,this.pendingDelaunayStack.length=0,this.horzEdgeStack.length=0,this.locMinStack.length=0,this.firstActive=null,this.lowermostVertex=null}fixupEdgeIntersects(){for(let t=0;t=e.vR.pt.x)break;if(i.vT.pt.ye.vT.pt.y&&n.segsIntersect(i.vL.pt,i.vR.pt,e.vL.pt,e.vR.pt)===Ln.intersect&&!this.removeIntersection(i,e))return!1}}return!0}mergeDupOrCollinearVertices(){if(this.allVertices.length<2)return;let t=0;for(let e=1;e1)return!1;let c=i.vT;return n.removeEdgeFromVertex(c,i),i.vL===c?i.vL=r:i.vR=r,i.vT=r,r.edges.push(i),r.innerLM=!1,i.vB.innerLM&&n.getLocMinAngle(i.vB)<=0&&(i.vB.innerLM=!1),this.createEdge(r,c,i.kind),!0}createEdge(t,e,r){let i=new Yl;return this.allEdges.push(i),t.pt.y===e.pt.y?(i.vB=t,i.vT=e):t.pt.y=e&&i.vB.pt.y>=r&&i.vB!==t&&i.vT!==t&&!n.leftTurning(i.vL.pt,t.pt,i.vR.pt)){let d=n.shortestDistFromSegment(t.pt,i.vL.pt,i.vR.pt);(u===null||dh&&i.vL.pt.xr&&i.vT.pt.yr?i.vT:i.vB,h=c.pt.x,p=c.pt.y),i=i.nextE;else for(;i!==null;)i.vR.pt.xe&&i.vB.pt.y>r&&i.vT.pt.yr?i.vT:i.vB,h=c.pt.x,p=c.pt.y),i=i.nextE;return this.createEdge(c,t,Ae.loose)}horizontalBetween(t,e){let r=t.pt.y,i,u;t.pt.x>e.pt.x?(i=e.pt.x,u=t.pt.x):(i=t.pt.x,u=e.pt.x);let l=this.firstActive;for(;l!==null&&!(l.vL.pt.y===r&&l.vR.pt.y===r&&l.vL.pt.x>=i&&l.vR.pt.x<=u&&(l.vL.pt.x!==i||l.vL.pt.x!==u));)l=l.nextE;return l}doTriangulateLeft(t,e,r){let i=null,u=null,l=t.vB===e?t.vT:t.vB;for(let h of e.edges){if(h===t||!h.isActive)continue;let p=h.vT===e?h.vB:h.vT;if(p===l)continue;let d=_t.crossProductSign(l.pt,e.pt,p.pt);if(d===0){if(l.pt.x>e.pt.x==e.pt.x>p.pt.x)continue}else if(d>0||i!==null&&!n.leftTurning(p.pt,e.pt,i.pt))continue;i=p,u=h}if(i===null||i.pt.ye.pt.y&&n.isRightEdge(u))return;let c=n.findLinkingEdge(i,l,i.pt.ye.pt.x==e.pt.x>p.pt.x)continue}else if(d<0||i!==null&&!n.rightTurning(p.pt,e.pt,i.pt))continue;i=p,u=h}if(i===null||i.pt.ye.pt.y&&n.isLeftEdge(u))return;let c=n.findLinkingEdge(i,l,i.pt.y>l.pt.y);if(c===null){if(i.pt.y===l.pt.y&&l.pt.y===r&&this.horizontalBetween(i,l)!==null)return;c=this.createEdge(i,l,Ae.loose)}this.createTriangle(t,c,u),n.edgeCompleted(c)||this.doTriangulateRight(c,i,r)}addEdgeToActives(t){t.isActive||(t.prevE=null,t.nextE=this.firstActive,t.isActive=!0,this.firstActive!==null&&(this.firstActive.prevE=t),this.firstActive=t)}removeEdgeFromActives(t){n.removeEdgeFromVertex(t.vB,t),n.removeEdgeFromVertex(t.vT,t);let e=t.prevE,r=t.nextE;r!==null&&(r.prevE=e),e!==null&&(e.nextE=r),t.isActive=!1,this.firstActive===t&&(this.firstActive=r)}execute(t){let e=[];if(!this.addPaths(t))return{result:Er.noPolygons,solution:e};if(this.lowermostVertex.innerLM){for(;this.locMinStack.length>0;){let i=this.locMinStack.pop();i.innerLM=!i.innerLM}for(let i of this.allEdges)i.kind===Ae.ascend?i.kind=Ae.descend:i.kind===Ae.descend&&(i.kind=Ae.ascend)}else this.locMinStack.length=0;if(this.allEdges.sort((i,u)=>i.vL.pt.xu.vL.pt.x?1:0),!this.fixupEdgeIntersects())return this.cleanUp(),{result:Er.pathsIntersect,solution:e};this.allVertices.sort((i,u)=>i.pt.y===u.pt.y?i.pt.xu.pt.x?1:0:u.pt.y0;){let u=this.locMinStack.pop(),l=this.createInnerLocMinLooseEdge(u);if(l===null)return this.cleanUp(),{result:Er.fail,solution:e};n.isHorizontal(l)?l.vL===l.vB?this.doTriangulateLeft(l,l.vB,r):this.doTriangulateRight(l,l.vB,r):(this.doTriangulateLeft(l,l.vB,r),n.edgeCompleted(l)||this.doTriangulateRight(l,l.vB,r)),this.addEdgeToActives(u.edges[0]),this.addEdgeToActives(u.edges[1])}for(;this.horzEdgeStack.length>0;){let u=this.horzEdgeStack.pop();n.edgeCompleted(u)||(u.vB===u.vL?n.isLeftEdge(u)&&this.doTriangulateLeft(u,u.vB,r):n.isRightEdge(u)&&this.doTriangulateRight(u,u.vB,r))}r=i.pt.y}for(let u=i.edges.length-1;u>=0;--u){if(u>=i.edges.length)continue;let l=i.edges[u];n.edgeCompleted(l)||n.isLooseEdge(l)||(i===l.vB?(n.isHorizontal(l)&&this.horzEdgeStack.push(l),i.innerLM||this.addEdgeToActives(l)):n.isHorizontal(l)?this.horzEdgeStack.push(l):n.isLeftEdge(l)?this.doTriangulateLeft(l,l.vB,i.pt.y):this.doTriangulateRight(l,l.vB,i.pt.y))}i.innerLM&&this.locMinStack.push(i)}for(;this.horzEdgeStack.length>0;){let i=this.horzEdgeStack.pop();!n.edgeCompleted(i)&&i.vB===i.vL&&this.doTriangulateLeft(i,i.vB,r)}if(this.useDelaunay)for(;this.pendingDelaunayStack.length>0;){let i=this.pendingDelaunayStack.pop();this.forceLegal(i)}for(let i of this.allTriangles){let u=n.pathFromTriangle(i),l=_t.crossProductSign(u[0],u[1],u[2]);l!==0&&(l<0&&u.reverse(),e.push(u))}return this.cleanUp(),{result:Er.success,solution:e}}static isLooseEdge(t){return t.kind===Ae.loose}static isLeftEdge(t){return t.kind===Ae.ascend}static isRightEdge(t){return t.kind===Ae.descend}static isHorizontal(t){return t.vB.pt.y===t.vT.pt.y}static leftTurning(t,e,r){return _t.crossProductSign(t,e,r)<0}static rightTurning(t,e,r){return _t.crossProductSign(t,e,r)>0}static edgeCompleted(t){return t.triA===null?!1:t.triB!==null?!0:t.kind!==Ae.loose}static edgeContains(t,e){return t.vL===e?br.left:t.vR===e?br.right:br.neither}static getAngle(t,e,r){let i=Number(e.x-t.x),u=Number(e.y-t.y),l=Number(e.x-r.x),c=Number(e.y-r.y),h=i*l+u*c,p=i*c-u*l;return Math.atan2(p,h)}static getLocMinAngle(t){let e,r;return t.edges[0].kind===Ae.ascend?(e=0,r=1):(r=0,e=1),n.getAngle(t.edges[r].vT.pt,t.pt,t.edges[e].vT.pt)}static removeEdgeFromVertex(t,e){let r=t.edges.indexOf(e);if(r<0)throw new Error("Edge not found in vertex");t.edges.splice(r,1)}static findLocMinIdx(t,e,r){if(e<3)return{found:!1,idx:r};let i=r,u=(r+1)%e;for(;t[u].y<=t[r].y;)if(r=u,u=(u+1)%e,r===i)return{found:!1,idx:r};for(;t[u].y>=t[r].y;)r=u,u=(u+1)%e;return{found:!0,idx:r}}static prev(t,e){return t===0?e-1:t-1}static next(t,e){return(t+1)%e}static findLinkingEdge(t,e,r){let i=null;for(let u of t.edges)if(u.vL===e||u.vR===e){if(u.kind===Ae.loose||u.kind===Ae.ascend===r)return u;i=u}return i}static pathFromTriangle(t){let e=[t.edges[0].vL.pt,t.edges[0].vR.pt],r=t.edges[1];return r.vL.pt.x===e[0].x&&r.vL.pt.y===e[0].y||r.vL.pt.x===e[1].x&&r.vL.pt.y===e[1].y?e.push(r.vR.pt):e.push(r.vL.pt),e}static inCircleTest(t,e,r,i){let u=Number(t.x-i.x),l=Number(t.y-i.y),c=u*u+l*l,h=Number(e.x-i.x),p=Number(e.y-i.y),d=h*h+p*p,y=Number(r.x-i.x),v=Number(r.y-i.y),_=y*y+v*v;return u*(p*_-v*d)-h*(l*_-v*c)+y*(l*d-p*c)}static shortestDistFromSegment(t,e,r){let i=Number(r.x-e.x),u=Number(r.y-e.y),l=Number(t.x-e.x),c=Number(t.y-e.y),h=l*i+c*u,p=i*i+u*u;return h<0?n.distanceSqr(t,e):h>p?n.distanceSqr(t,r):(l*u-i*c)*(l*u-i*c)/p}static segsIntersect(t,e,r,i){let u=Number(e.y-t.y),l=Number(e.x-t.x),c=Number(i.y-r.y),h=Number(i.x-r.x),p=u*h-c*l;if(p===0)return Ln.collinear;let d=Number(t.x-r.x)*c-Number(t.y-r.y)*h;if(d===0)return Ln.none;if(d>0){if(p<0||d>=p)return Ln.none}else if(p>0||d<=p)return Ln.none;if(d=Number(t.x-r.x)*u-Number(t.y-r.y)*l,d===0)return Ln.none;if(d>0){if(p>0&&dp)return Ln.intersect;return Ln.none}static distSqr(t,e){let r=Number(t.x-e.x),i=Number(t.y-e.y);return r*r+i*i}static distanceSqr(t,e){let r=Number(t.x-e.x),i=Number(t.y-e.y);return r*r+i*i}};var Fo;(function(n){n.invalidRect64=Bl,n.invalidRectD=ql;function t(U,Z,Q){return p(ie.Intersection,U,Z,Q)}n.intersect=t;function e(U,Z,Q,it=2){return y(ie.Intersection,U,Z,Q,it)}n.intersectD=e;function r(U,Z,Q){return typeof Z=="number"?p(ie.Union,U,null,Z):p(ie.Union,U,Z,Q)}n.union=r;function i(U,Z,Q,it){return typeof Z=="number"?y(ie.Union,U,null,Z):y(ie.Union,U,Z,Q,it||2)}n.unionD=i;function u(U,Z,Q){return p(ie.Difference,U,Z,Q)}n.difference=u;function l(U,Z,Q,it=2){return y(ie.Difference,U,Z,Q,it)}n.differenceD=l;function c(U,Z,Q){return p(ie.Xor,U,Z,Q)}n.xor=c;function h(U,Z,Q,it=2){return y(ie.Xor,U,Z,Q,it)}n.xorD=h;function p(U,Z,Q,it){let at=[];if(Z===null)return at;let gt=new lr;return gt.addPaths(Z,xe.Subject),Q!==null&>.addPaths(Q,xe.Clip),gt.execute(U,it,at),at}n.booleanOp=p;function d(U,Z,Q,it,at){if(Z===null)return;let gt=new lr;gt.addPaths(Z,xe.Subject),Q!==null&>.addPaths(Q,xe.Clip),gt.execute(U,at,it)}n.booleanOpWithPolyTree=d;function y(U,Z,Q,it,at=2){let gt=[],dt=new Dn(at);return dt.addSubjectPaths(Z),Q!==null&&dt.addClipPaths(Q),dt.execute(U,it,gt),gt}n.booleanOpD=y;function v(U,Z,Q,it,at,gt=2){if(Z===null)return;let dt=new Dn(gt);dt.addSubjectPaths(Z),Q!==null&&dt.addClipPaths(Q),dt.execute(U,at,it)}n.booleanOpDWithPolyTree=v;function _(U,Z,Q,it,at=2,gt=0){let dt=new qr(at,gt);dt.addPaths(U,Q,it);let It=[];return dt.execute(Z,It),It}n.inflatePaths=_;function I(U,Z,Q,it,at=2,gt=2,dt=0){_t.checkPrecision(gt);let It=Math.pow(10,gt),Et=ot(U,It),Re=new qr(at,It*dt);Re.addPaths(Et,Q,it);let Gt=[];return Re.execute(Z*It,Gt),j(Gt,1/It)}n.inflatePathsD=I;function F(U,Z,Q){if("left"in U&&typeof U.left=="number"&&Number.isInteger(U.left)){let it=U;if(Me.isEmpty(it))return[];if(Array.isArray(Z[0])){let at=Z;return at.length===0?[]:new jn(it).execute(at)}else{let at=Z;return at.length===0?[]:F(it,[at])}}else{let it=U,at=Q||2;if(_t.checkPrecision(at),xr.isEmpty(it))return[];let gt=Math.pow(10,at),dt=E(it,gt);if(Array.isArray(Z[0])){let It=Z;if(It.length===0)return[];let Et=ot(It,gt),Gt=new jn(dt).execute(Et);return j(Gt,1/gt)}else{let It=Z;return It.length===0?[]:F(it,[It],at)}}}n.rectClip=F;function M(U,Z,Q){if("left"in U&&typeof U.left=="number"&&Number.isInteger(U.left)){let it=U;if(Me.isEmpty(it))return[];if(Array.isArray(Z[0])){let at=Z;return at.length===0?[]:new Xi(it).execute(at)}else{let at=Z;return at.length===0?[]:M(it,[at])}}else{let it=U,at=Q||2;if(_t.checkPrecision(at),xr.isEmpty(it))return[];let gt=Math.pow(10,at),dt=E(it,gt);if(Array.isArray(Z[0])){let It=Z;if(It.length===0)return[];let Et=ot(It,gt),Gt=new Xi(dt).execute(Et);return j(Gt,1/gt)}else{let It=Z;return It.length===0?[]:M(it,[It],at)}}}n.rectClipLines=M;function L(U,Z,Q){return zr.sum(U,Z,Q)}n.minkowskiSum=L;function C(U,Z,Q){return zr.sumD(U,Z,Q)}n.minkowskiSumD=C;function q(U,Z,Q){return zr.diff(U,Z,Q)}n.minkowskiDiff=q;function V(U,Z,Q){return zr.diffD(U,Z,Q)}n.minkowskiDiffD=V;function X(U){let Z=0,Q=U.length;if(Q<3)return 0;let it=U[Q-1];for(let at of U)Z+=(it.y+at.y)*(it.x-at.x),it=at;return Z*.5}n.area=X;function G(U){let Z=0;for(let Q of U)Z+=X(Q);return Z}n.areaPaths=G;function J(U){let Z=0,Q=U.length;if(Q<3)return 0;let it=U[Q-1];for(let at of U)Z+=(it.y+at.y)*(it.x-at.x),it=at;return Z*.5}n.areaD=J;function k(U){let Z=0;for(let Q of U)Z+=J(Q);return Z}n.areaPathsD=k;function N(U){return X(U)>=0}n.isPositive=N;function T(U){return J(U)>=0}n.isPositiveD=T;function D(U){let Z="";for(let Q of U)Z+=ue.toString(Q);return Z+` `}n.path64ToString=D;function B(U){let Z="";for(let Q of U)Z+=D(Q);return Z}n.paths64ToString=B;function K(U,Z=2){let Q="";for(let it of U)Q+=Fn.toString(it,Z);return Q+` `}n.pathDToString=K;function w(U,Z=2){let Q="";for(let it of U)Q+=K(it,Z);return Q}n.pathsDToString=w;function R(U,Z,Q){let it=[];for(let at of U)it.push({x:at.x+Z,y:at.y+Q});return it}n.offsetPath=R;function x(U,Z){return{x:Math.round(U.x*Z),y:Math.round(U.y*Z)}}n.scalePoint64=x;function b(U,Z){return{x:U.x*Z,y:U.y*Z}}n.scalePointD=b;function E(U,Z){return{left:Math.round(U.left*Z),top:Math.round(U.top*Z),right:Math.round(U.right*Z),bottom:Math.round(U.bottom*Z)}}n.scaleRect=E;function A(U,Z){if(_t.isAlmostZero(Z-1))return U;let Q=[];for(let it of U)Q.push({x:Math.round(it.x*Z),y:Math.round(it.y*Z)});return Q}n.scalePath=A;function z(U,Z){if(_t.isAlmostZero(Z-1))return U;let Q=[];for(let it of U)Q.push(A(it,Z));return Q}n.scalePaths=z;function W(U,Z){if(_t.isAlmostZero(Z-1))return U;let Q=[];for(let it of U)Q.push(Fn.scale(it,Z));return Q}n.scalePathD=W;function j(U,Z){if(_t.isAlmostZero(Z-1))return U;let Q=[];for(let it of U)Q.push(W(it,Z));return Q}n.scalePathsD=j;function tt(U,Z){let Q=[];for(let it of U)Q.push({x:Math.round(it.x*Z),y:Math.round(it.y*Z)});return Q}n.scalePath64=tt;function ot(U,Z){let Q=[];for(let it of U)Q.push(tt(it,Z));return Q}n.scalePaths64=ot;function rt(U,Z){let Q=[];for(let it of U)Q.push({x:it.x*Z,y:it.y*Z});return Q}n.scalePathDFromInt=rt;function $(U,Z){let Q=[];for(let it of U)Q.push(rt(it,Z));return Q}n.scalePathsDFromInt=$;function ht(U){let Z=[];for(let Q of U)Z.push(ue.fromPointD(Q));return Z}n.path64FromD=ht;function ct(U){let Z=[];for(let Q of U)Z.push(ht(Q));return Z}n.paths64FromD=ct;function ut(U){let Z=[];for(let Q of U)Z.push(H(Q));return Z}n.pathsD=ut;function H(U){let Z=[];for(let Q of U)Z.push(Fn.fromPoint64(Q));return Z}n.pathD=H;function vt(U,Z,Q){let it=[];for(let at of U)it.push({x:at.x+Z,y:at.y+Q});return it}n.translatePath=vt;function Nt(U,Z,Q){let it=[];for(let at of U)it.push(R(at,Z,Q));return it}n.translatePaths=Nt;function St(U,Z,Q){let it=[];for(let at of U)it.push({x:at.x+Z,y:at.y+Q});return it}n.translatePathD=St;function Ot(U,Z,Q){let it=[];for(let at of U)it.push(St(at,Z,Q));return it}n.translatePathsD=Ot;function Tt(U){return[...U].reverse()}n.reversePath=Tt;function he(U){return[...U].reverse()}n.reversePathD=he;function ft(U){let Z=[];for(let Q of U)Z.push(Tt(Q));return Z}n.reversePaths=ft;function gn(U){let Z=[];for(let Q of U)Z.push(he(Q));return Z}n.reversePathsD=gn;function vn(U){return _t.getBounds(U)}n.getBounds=vn;function qe(U){let Z=Me.createInvalid();for(let Q of U)for(let it of Q)it.xZ.right&&(Z.right=it.x),it.yZ.bottom&&(Z.bottom=it.y);return Z.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:Z}n.getBoundsPaths=qe;function Xn(U){let Z=xr.createInvalid();for(let Q of U)Q.xZ.right&&(Z.right=Q.x),Q.yZ.bottom&&(Z.bottom=Q.y);return Math.abs(Z.left-Number.MAX_VALUE)<_t.floatingPointTolerance?{left:0,top:0,right:0,bottom:0}:Z}n.getBoundsD=Xn;function Xt(U){let Z=xr.createInvalid();for(let Q of U)for(let it of Q)it.xZ.right&&(Z.right=it.x),it.yZ.bottom&&(Z.bottom=it.y);return Math.abs(Z.left-Number.MAX_VALUE)<_t.floatingPointTolerance?{left:0,top:0,right:0,bottom:0}:Z}n.getBoundsPathsD=Xt;function xn(U){let Z=Math.floor(U.length/2),Q=[];for(let it=0;it0&&Z.push(U.poly);for(let Q=0;Q0&&Z.push(U.poly);for(let Q=0;QZ&&ue.equals(U[Z],U[Q]);)at[Q--]=!1;for(let It=Z+1;ItZ+1&&no(U,Z,gt,it,at),gtZ&&Fn.equals(U[Z],U[Q]);)at[Q--]=!1;for(let It=Z+1;ItZ+1&&ro(U,Z,gt,it,at),gt0&&Q[U];)--U;if(!Q[U])return U;for(U=Z;Q[U];)--U;return U}function Mr(U,Z,Q=!0){let it=U.length,at=it-1,gt=ze(Z);if(it<4)return U;let dt=new Array(it).fill(!1),It=new Array(it).fill(0),Et=0;Q?(It[0]=Oe(U[0],U[at],U[1]),It[at]=Oe(U[at],U[0],U[at-1])):(It[0]=Number.MAX_VALUE,It[at]=Number.MAX_VALUE);for(let Gt=1;Gtgt){let we=Et;do Et=nn(Et,at,dt);while(Et!==we&&It[Et]>gt);if(Et===we)break}let Gt=gr(Et,at,dt),Je=nn(Et,at,dt);if(Je===Gt)break;let bn;if(It[Je]gt){let we=Et;do Et=nn(Et,at,dt);while(Et!==we&&It[Et]>gt);if(Et===we)break}let Gt=gr(Et,at,dt),Je=nn(Et,at,dt);if(Je===Gt)break;let bn;if(It[Je]2&&_t.isCollinear(at[at.length-1],at[at.length-2],at[0]);)at.pop();at.length<3&&(at.length=0)}return at}n.trimCollinear=tr;function ss(U,Z,Q=!1){_t.checkPrecision(Z);let it=Math.pow(10,Z),at=tt(U,it);return at=tr(at,Q),rt(at,1/it)}n.trimCollinearD=ss;function yi(U,Z){return _t.pointInPolygon(U,Z)}n.pointInPolygon=yi;function ma(U,Z,Q=2){_t.checkPrecision(Q);let it=Math.pow(10,Q),at=ue.fromPointD(Fn.scale(U,it)),gt=tt(Z,it);return _t.pointInPolygon(at,gt)}n.pointInPolygonD=ma;function us(U,Z,Q=0,it=0){if(Z<=0)return[];Q<=0&&(Q=Z),it<=2&&(it=Math.ceil(Math.PI*Math.sqrt((Z+Q)/2)));let at=Math.sin(2*Math.PI/it),gt=Math.cos(2*Math.PI/it),dt=gt,It=at,Et=[{x:Math.round(U.x+Z),y:U.y}];for(let Re=1;Re8?it=Math.pow(10,8):it=Math.pow(10,Z);let at=ot(U,it),gt=new Ui(Q),{result:dt,solution:It}=gt.execute(at),Et;return dt===Er.success?Et=j(It,1/it):Et=[],{result:dt,solution:Et}}n.triangulateD=io})(Fo||(Fo={}));var{intersect:lO,intersectD:cO,union:fO,unionD:hO,difference:gO,differenceD:pO,xor:mO,xorD:dO,booleanOp:yO,booleanOpWithPolyTree:vO,booleanOpD:xO,booleanOpDWithPolyTree:_O,inflatePaths:PO,inflatePathsD:bO,rectClip:EO,rectClipLines:wO,minkowskiSum:SO,minkowskiSumD:kO,minkowskiDiff:IO,minkowskiDiffD:LO,area:MO,areaPaths:CO,areaD:wr,areaPathsD:NO,isPositive:TO,isPositiveD:OO,getBounds:RO,getBoundsPaths:AO,getBoundsD:FO,getBoundsPathsD:DO,makePath:GO,makePathD:BO,scalePath64:qO,scalePaths64:zO,scalePathD:XO,scalePathsD:UO,translatePath:YO,translatePaths:JO,translatePathD:VO,translatePathsD:HO,reversePath:ZO,reversePathD:WO,reversePaths:jO,reversePathsD:KO,stripDuplicates:$O,trimCollinear:QO,trimCollinearD:tR,pointInPolygon:eR,pointInPolygonD:nR,ellipse:rR,ellipseD:iR,simplifyPath:oR,simplifyPaths:sR,simplifyPathD:uR,simplifyPathsD:aR,ramerDouglasPeucker:lR,ramerDouglasPeuckerPaths:cR,ramerDouglasPeuckerD:fR,ramerDouglasPeuckerPathsD:hR,triangulate:gR,triangulateD:pR}=Fo;var Kg=8;function Vl(n){let t=[];for(let e of n)for(let r of wu(e))t.push(r);return t}function wu(n){let t=[];for(let[e,r]of n.entries()){let i=e===0?bv(Wg(r)):Ev(Wg(r));t.push(i)}return t}function bv(n){return wr(n)<0?n.reverse():n}function Ev(n){return wr(n)>0?[...n].reverse():n}function Wg(n){return n.map(([t,e])=>({x:t,y:e}))}function $g(n){let t=[];for(let e=0;e0&&e.push(r);for(let i=0;i0&&e.push(l)}t.push(e)}for(let e=0;e0&&t){let r=e[0],i=e[e.length-1];(r[0]!==i[0]||r[1]!==i[1])&&e.push([r[0],r[1]])}return e}function tp(n){if(n.features.length<2)throw new Error("Must have at least 2 features");let t=new Dn(Kg);ve(n,(i,u)=>{i.type==="MultiPolygon"?u===0?t.addSubjectPaths(Vl(i.coordinates)):t.addClipPaths(Vl(i.coordinates)):u===0?t.addSubjectPaths(wu(i.coordinates)):t.addClipPaths(wu(i.coordinates))});let e=new Pr;t.execute(ie.Difference,ee.EvenOdd,e);let r=$g(e);return r===null?null:te(r)}function Do(n){if(!n)throw new Error("geojson is required");var t=[];return le(n,function(e){t.push(e)}),pt(t)}var Nu={};Tr(Nu,{difference:()=>Yv,intersection:()=>Xv,setPrecision:()=>Jv,union:()=>Ir,xor:()=>Uv});var wv=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Hl=Math.ceil,Bn=Math.floor,yn="[BigNumber Error] ",ep=yn+"Number primitive has more than 15 significant digits: ",Kn=1e14,Qt=14,Zl=9007199254740991,Wl=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Xr=1e7,Ue=1e9;function np(n){var t,e,r,i=C.prototype={constructor:C,toString:null,valueOf:null},u=new C(1),l=20,c=4,h=-7,p=21,d=-1e7,y=1e7,v=!1,_=1,I=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz",L=!0;function C(k,N){var T,D,B,K,w,R,x,b,E=this;if(!(E instanceof C))return new C(k,N);if(N==null){if(k&&k._isBigNumber===!0){E.s=k.s,!k.c||k.e>y?E.c=E.e=null:k.e=10;w/=10,K++);K>y?E.c=E.e=null:(E.e=K,E.c=[k]);return}b=String(k)}else{if(!wv.test(b=String(k)))return r(E,b,R);E.s=b.charCodeAt(0)==45?(b=b.slice(1),-1):1}(K=b.indexOf("."))>-1&&(b=b.replace(".","")),(w=b.search(/e/i))>0?(K<0&&(K=w),K+=+b.slice(w+1),b=b.substring(0,w)):K<0&&(K=b.length)}else{if(Ce(N,2,M.length,"Base"),N==10&&L)return E=new C(k),G(E,l+E.e+1,c);if(b=String(k),R=typeof k=="number"){if(k*0!=0)return r(E,b,R,N);if(E.s=1/k<0?(b=b.slice(1),-1):1,C.DEBUG&&b.replace(/^0\.0*|\./,"").length>15)throw Error(ep+k)}else E.s=b.charCodeAt(0)===45?(b=b.slice(1),-1):1;for(T=M.slice(0,N),K=w=0,x=b.length;wK){K=x;continue}}else if(!B&&(b==b.toUpperCase()&&(b=b.toLowerCase())||b==b.toLowerCase()&&(b=b.toUpperCase()))){B=!0,w=-1,K=0;continue}return r(E,String(k),R,N)}R=!1,b=e(b,N,10,E.s),(K=b.indexOf("."))>-1?b=b.replace(".",""):K=b.length}for(w=0;b.charCodeAt(w)===48;w++);for(x=b.length;b.charCodeAt(--x)===48;);if(b=b.slice(w,++x)){if(x-=w,R&&C.DEBUG&&x>15&&(k>Zl||k!==Bn(k)))throw Error(ep+E.s*k);if((K=K-w-1)>y)E.c=E.e=null;else if(K=-Ue&&B<=Ue&&B===Bn(B)){if(D[0]===0){if(B===0&&D.length===1)return!0;break t}if(N=(B+1)%Qt,N<1&&(N+=Qt),String(D[0]).length==N){for(N=0;N=Kn||T!==Bn(T))break t;if(T!==0)return!0}}}else if(D===null&&B===null&&(K===null||K===1||K===-1))return!0;throw Error(yn+"Invalid BigNumber: "+k)},C.maximum=C.max=function(){return V(arguments,-1)},C.minimum=C.min=function(){return V(arguments,1)},C.random=(function(){var k=9007199254740992,N=Math.random()*k&2097151?function(){return Bn(Math.random()*k)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(T){var D,B,K,w,R,x=0,b=[],E=new C(u);if(T==null?T=l:Ce(T,0,Ue),w=Hl(T/Qt),v)if(crypto.getRandomValues){for(D=crypto.getRandomValues(new Uint32Array(w*=2));x>>11),R>=9e15?(B=crypto.getRandomValues(new Uint32Array(2)),D[x]=B[0],D[x+1]=B[1]):(b.push(R%1e14),x+=2);x=w/2}else if(crypto.randomBytes){for(D=crypto.randomBytes(w*=7);x=9e15?crypto.randomBytes(7).copy(D,x):(b.push(R%1e14),x+=7);x=w/7}else throw v=!1,Error(yn+"crypto unavailable");if(!v)for(;x=10;R/=10,x++);xB-1&&(R[w+1]==null&&(R[w+1]=0),R[w+1]+=R[w]/B|0,R[w]%=B)}return R.reverse()}return function(T,D,B,K,w){var R,x,b,E,A,z,W,j,tt=T.indexOf("."),ot=l,rt=c;for(tt>=0&&(E=I,I=0,T=T.replace(".",""),j=new C(D),z=j.pow(T.length-tt),I=E,j.c=N(Sr(Gn(z.c),z.e,"0"),10,B,k),j.e=j.c.length),W=N(T,D,B,w?(R=M,k):(R=k,M)),b=E=W.length;W[--E]==0;W.pop());if(!W[0])return R.charAt(0);if(tt<0?--b:(z.c=W,z.e=b,z.s=K,z=t(z,j,ot,rt,B),W=z.c,A=z.r,b=z.e),x=b+ot+1,tt=W[x],E=B/2,A=A||x<0||W[x+1]!=null,A=rt<4?(tt!=null||A)&&(rt==0||rt==(z.s<0?3:2)):tt>E||tt==E&&(rt==4||A||rt==6&&W[x-1]&1||rt==(z.s<0?8:7)),x<1||!W[0])T=A?Sr(R.charAt(1),-ot,R.charAt(0)):R.charAt(0);else{if(W.length=x,A)for(--B;++W[--x]>B;)W[x]=0,x||(++b,W=[1].concat(W));for(E=W.length;!W[--E];);for(tt=0,T="";tt<=E;T+=R.charAt(W[tt++]));T=Sr(T,b,R.charAt(0))}return T}})(),t=(function(){function k(D,B,K){var w,R,x,b,E=0,A=D.length,z=B%Xr,W=B/Xr|0;for(D=D.slice();A--;)x=D[A]%Xr,b=D[A]/Xr|0,w=W*x+b*z,R=z*x+w%Xr*Xr+E,E=(R/K|0)+(w/Xr|0)+W*b,D[A]=R%K;return E&&(D=[E].concat(D)),D}function N(D,B,K,w){var R,x;if(K!=w)x=K>w?1:-1;else for(R=x=0;RB[R]?1:-1;break}return x}function T(D,B,K,w){for(var R=0;K--;)D[K]-=R,R=D[K]1;D.splice(0,1));}return function(D,B,K,w,R){var x,b,E,A,z,W,j,tt,ot,rt,$,ht,ct,ut,H,vt,Nt,St=D.s==B.s?1:-1,Ot=D.c,Tt=B.c;if(!Ot||!Ot[0]||!Tt||!Tt[0])return new C(!D.s||!B.s||(Ot?Tt&&Ot[0]==Tt[0]:!Tt)?NaN:Ot&&Ot[0]==0||!Tt?St*0:St/0);for(tt=new C(St),ot=tt.c=[],b=D.e-B.e,St=K+b+1,R||(R=Kn,b=qn(D.e/Qt)-qn(B.e/Qt),St=St/Qt|0),E=0;Tt[E]==(Ot[E]||0);E++);if(Tt[E]>(Ot[E]||0)&&b--,St<0)ot.push(1),A=!0;else{for(ut=Ot.length,vt=Tt.length,E=0,St+=2,z=Bn(R/(Tt[0]+1)),z>1&&(Tt=k(Tt,z,R),Ot=k(Ot,z,R),vt=Tt.length,ut=Ot.length),ct=vt,rt=Ot.slice(0,vt),$=rt.length;$=R/2&&H++;do{if(z=0,x=N(Tt,rt,vt,$),x<0){if(ht=rt[0],vt!=$&&(ht=ht*R+(rt[1]||0)),z=Bn(ht/H),z>1)for(z>=R&&(z=R-1),W=k(Tt,z,R),j=W.length,$=rt.length;N(W,rt,j,$)==1;)z--,T(W,vt=10;St/=10,E++);G(tt,K+(tt.e=E+b*Qt-1)+1,w,A)}else tt.e=b,tt.r=+A;return tt}})();function q(k,N,T,D){var B,K,w,R,x;if(T==null?T=c:Ce(T,0,8),!k.c)return k.toString();if(B=k.c[0],w=k.e,N==null)x=Gn(k.c),x=D==1||D==2&&(w<=h||w>=p)?ku(x,w):Sr(x,w,"0");else if(k=G(new C(k),N,T),K=k.e,x=Gn(k.c),R=x.length,D==1||D==2&&(N<=K||K<=h)){for(;RR){if(--N>0)for(x+=".";N--;x+="0");}else if(N+=K-R,N>0)for(K+1==R&&(x+=".");N--;x+="0");return k.s<0&&B?"-"+x:x}function V(k,N){for(var T,D,B=1,K=new C(k[0]);B=10;B/=10,D++);return(T=D+T*Qt-1)>y?k.c=k.e=null:T=10;R/=10,B++);if(K=N-B,K<0)K+=Qt,w=N,x=A[b=0],E=Bn(x/z[B-w-1]%10);else if(b=Hl((K+1)/Qt),b>=A.length)if(D){for(;A.length<=b;A.push(0));x=E=0,B=1,K%=Qt,w=K-Qt+1}else break t;else{for(x=R=A[b],B=1;R>=10;R/=10,B++);K%=Qt,w=K-Qt+B,E=w<0?0:Bn(x/z[B-w-1]%10)}if(D=D||N<0||A[b+1]!=null||(w<0?x:x%z[B-w-1]),D=T<4?(E||D)&&(T==0||T==(k.s<0?3:2)):E>5||E==5&&(T==4||D||T==6&&(K>0?w>0?x/z[B-w]:0:A[b-1])%10&1||T==(k.s<0?8:7)),N<1||!A[0])return A.length=0,D?(N-=k.e+1,A[0]=z[(Qt-N%Qt)%Qt],k.e=-N||0):A[0]=k.e=0,k;if(K==0?(A.length=b,R=1,b--):(A.length=b+1,R=z[Qt-K],A[b]=w>0?Bn(x/z[B-w]%z[w])*R:0),D)for(;;)if(b==0){for(K=1,w=A[0];w>=10;w/=10,K++);for(w=A[0]+=R,R=1;w>=10;w/=10,R++);K!=R&&(k.e++,A[0]==Kn&&(A[0]=1));break}else{if(A[b]+=R,A[b]!=Kn)break;A[b--]=0,R=1}for(K=A.length;A[--K]===0;A.pop());}k.e>y?k.c=k.e=null:k.e=p?ku(N,T):Sr(N,T,"0"),k.s<0?"-"+N:N)}return i.absoluteValue=i.abs=function(){var k=new C(this);return k.s<0&&(k.s=1),k},i.comparedTo=function(k,N){return ci(this,new C(k,N))},i.decimalPlaces=i.dp=function(k,N){var T,D,B,K=this;if(k!=null)return Ce(k,0,Ue),N==null?N=c:Ce(N,0,8),G(new C(K),k+K.e+1,N);if(!(T=K.c))return null;if(D=((B=T.length-1)-qn(this.e/Qt))*Qt,B=T[B])for(;B%10==0;B/=10,D--);return D<0&&(D=0),D},i.dividedBy=i.div=function(k,N){return t(this,new C(k,N),l,c)},i.dividedToIntegerBy=i.idiv=function(k,N){return t(this,new C(k,N),0,1)},i.exponentiatedBy=i.pow=function(k,N){var T,D,B,K,w,R,x,b,E,A=this;if(k=new C(k),k.c&&!k.isInteger())throw Error(yn+"Exponent not an integer: "+J(k));if(N!=null&&(N=new C(N)),R=k.e>14,!A.c||!A.c[0]||A.c[0]==1&&!A.e&&A.c.length==1||!k.c||!k.c[0])return E=new C(Math.pow(+J(A),R?k.s*(2-Su(k)):+J(k))),N?E.mod(N):E;if(x=k.s<0,N){if(N.c?!N.c[0]:!N.s)return new C(NaN);D=!x&&A.isInteger()&&N.isInteger(),D&&(A=A.mod(N))}else{if(k.e>9&&(A.e>0||A.e<-1||(A.e==0?A.c[0]>1||R&&A.c[1]>=24e7:A.c[0]<8e13||R&&A.c[0]<=9999975e7)))return K=A.s<0&&Su(k)?-0:0,A.e>-1&&(K=1/K),new C(x?1/K:K);I&&(K=Hl(I/Qt+2))}for(R?(T=new C(.5),x&&(k.s=1),b=Su(k)):(B=Math.abs(+J(k)),b=B%2),E=new C(u);;){if(b){if(E=E.times(A),!E.c)break;K?E.c.length>K&&(E.c.length=K):D&&(E=E.mod(N))}if(B){if(B=Bn(B/2),B===0)break;b=B%2}else if(k=k.times(T),G(k,k.e+1,1),k.e>14)b=Su(k);else{if(B=+J(k),B===0)break;b=B%2}A=A.times(A),K?A.c&&A.c.length>K&&(A.c.length=K):D&&(A=A.mod(N))}return D?E:(x&&(E=u.div(E)),N?E.mod(N):K?G(E,I,c,w):E)},i.integerValue=function(k){var N=new C(this);return k==null?k=c:Ce(k,0,8),G(N,N.e+1,k)},i.isEqualTo=i.eq=function(k,N){return ci(this,new C(k,N))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(k,N){return ci(this,new C(k,N))>0},i.isGreaterThanOrEqualTo=i.gte=function(k,N){return(N=ci(this,new C(k,N)))===1||N===0},i.isInteger=function(){return!!this.c&&qn(this.e/Qt)>this.c.length-2},i.isLessThan=i.lt=function(k,N){return ci(this,new C(k,N))<0},i.isLessThanOrEqualTo=i.lte=function(k,N){return(N=ci(this,new C(k,N)))===-1||N===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(k,N){var T,D,B,K,w=this,R=w.s;if(k=new C(k,N),N=k.s,!R||!N)return new C(NaN);if(R!=N)return k.s=-N,w.plus(k);var x=w.e/Qt,b=k.e/Qt,E=w.c,A=k.c;if(!x||!b){if(!E||!A)return E?(k.s=-N,k):new C(A?w:NaN);if(!E[0]||!A[0])return A[0]?(k.s=-N,k):new C(E[0]?w:c==3?-0:0)}if(x=qn(x),b=qn(b),E=E.slice(),R=x-b){for((K=R<0)?(R=-R,B=E):(b=x,B=A),B.reverse(),N=R;N--;B.push(0));B.reverse()}else for(D=(K=(R=E.length)<(N=A.length))?R:N,R=N=0;N0)for(;N--;E[T++]=0);for(N=Kn-1;D>R;){if(E[--D]=0;){for(T=0,z=ht[B]%ot,W=ht[B]/ot|0,w=x,K=B+w;K>B;)b=$[--w]%ot,E=$[w]/ot|0,R=W*b+E*z,b=z*b+R%ot*ot+j[K]+T,T=(b/tt|0)+(R/ot|0)+W*E,j[K--]=b%tt;j[K]=T}return T?++D:j.splice(0,1),X(k,j,D)},i.negated=function(){var k=new C(this);return k.s=-k.s||null,k},i.plus=function(k,N){var T,D=this,B=D.s;if(k=new C(k,N),N=k.s,!B||!N)return new C(NaN);if(B!=N)return k.s=-N,D.minus(k);var K=D.e/Qt,w=k.e/Qt,R=D.c,x=k.c;if(!K||!w){if(!R||!x)return new C(B/0);if(!R[0]||!x[0])return x[0]?k:new C(R[0]?D:B*0)}if(K=qn(K),w=qn(w),R=R.slice(),B=K-w){for(B>0?(w=K,T=x):(B=-B,T=R),T.reverse();B--;T.push(0));T.reverse()}for(B=R.length,N=x.length,B-N<0&&(T=x,x=R,R=T,N=B),B=0;N;)B=(R[--N]=R[N]+x[N]+B)/Kn|0,R[N]=Kn===R[N]?0:R[N]%Kn;return B&&(R=[B].concat(R),++w),X(k,R,w)},i.precision=i.sd=function(k,N){var T,D,B,K=this;if(k!=null&&k!==!!k)return Ce(k,1,Ue),N==null?N=c:Ce(N,0,8),G(new C(K),k,N);if(!(T=K.c))return null;if(B=T.length-1,D=B*Qt+1,B=T[B]){for(;B%10==0;B/=10,D--);for(B=T[0];B>=10;B/=10,D++);}return k&&K.e+1>D&&(D=K.e+1),D},i.shiftedBy=function(k){return Ce(k,-Zl,Zl),this.times("1e"+k)},i.squareRoot=i.sqrt=function(){var k,N,T,D,B,K=this,w=K.c,R=K.s,x=K.e,b=l+4,E=new C("0.5");if(R!==1||!w||!w[0])return new C(!R||R<0&&(!w||w[0])?NaN:w?K:1/0);if(R=Math.sqrt(+J(K)),R==0||R==1/0?(N=Gn(w),(N.length+x)%2==0&&(N+="0"),R=Math.sqrt(+N),x=qn((x+1)/2)-(x<0||x%2),R==1/0?N="5e"+x:(N=R.toExponential(),N=N.slice(0,N.indexOf("e")+1)+x),T=new C(N)):T=new C(R+""),T.c[0]){for(x=T.e,R=x+b,R<3&&(R=0);;)if(B=T,T=E.times(B.plus(t(K,B,b,1))),Gn(B.c).slice(0,R)===(N=Gn(T.c)).slice(0,R))if(T.e0&&j>0){for(K=j%R||R,E=W.substr(0,K);K0&&(E+=b+W.slice(K)),z&&(E="-"+E)}D=A?E+(T.decimalSeparator||"")+((x=+T.fractionGroupSize)?A.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(T.fractionGroupSeparator||"")):A):E}return(T.prefix||"")+D+(T.suffix||"")},i.toFraction=function(k){var N,T,D,B,K,w,R,x,b,E,A,z,W=this,j=W.c;if(k!=null&&(R=new C(k),!R.isInteger()&&(R.c||R.s!==1)||R.lt(u)))throw Error(yn+"Argument "+(R.isInteger()?"out of range: ":"not an integer: ")+J(R));if(!j)return new C(W);for(N=new C(u),b=T=new C(u),D=x=new C(u),z=Gn(j),K=N.e=z.length-W.e-1,N.c[0]=Wl[(w=K%Qt)<0?Qt+w:w],k=!k||R.comparedTo(N)>0?K>0?N:b:R,w=y,y=1/0,R=new C(z),x.c[0]=0;E=t(R,N,0,1),B=T.plus(E.times(D)),B.comparedTo(k)!=1;)T=D,D=B,b=x.plus(E.times(B=b)),x=B,N=R.minus(E.times(B=N)),R=B;return B=t(k.minus(T),D,0,1),x=x.plus(B.times(b)),T=T.plus(B.times(D)),x.s=b.s=W.s,K=K*2,A=t(b,D,K,c).minus(W).abs().comparedTo(t(x,T,K,c).minus(W).abs())<1?[b,D]:[x,T],y=w,A},i.toNumber=function(){return+J(this)},i.toPrecision=function(k,N){return k!=null&&Ce(k,1,Ue),q(this,k,N,2)},i.toString=function(k){var N,T=this,D=T.s,B=T.e;return B===null?D?(N="Infinity",D<0&&(N="-"+N)):N="NaN":(k==null?N=B<=h||B>=p?ku(Gn(T.c),B):Sr(Gn(T.c),B,"0"):k===10&&L?(T=G(new C(T),l+B+1,c),N=Sr(Gn(T.c),T.e,"0")):(Ce(k,2,M.length,"Base"),N=e(Sr(Gn(T.c),B,"0"),10,k,D,!0)),D<0&&T.c[0]&&(N="-"+N)),N},i.valueOf=i.toJSON=function(){return J(this)},i._isBigNumber=!0,i[Symbol.toStringTag]="BigNumber",i[Symbol.for("nodejs.util.inspect.custom")]=i.valueOf,n!=null&&C.set(n),C}function qn(n){var t=n|0;return n>0||n===t?t:t-1}function Gn(n){for(var t,e,r=1,i=n.length,u=n[0]+"";rp^e?1:-1;for(c=(h=i.length)<(p=u.length)?h:p,l=0;lu[l]^e?1:-1;return h==p?0:h>p^e?1:-1}function Ce(n,t,e,r){if(ne||n!==Bn(n))throw Error(yn+(r||"Argument")+(typeof n=="number"?ne?" out of range: ":" not an integer: ":" not a primitive number: ")+String(n))}function Su(n){var t=n.c.length-1;return qn(n.e/Qt)==t&&n.c[t]%2!=0}function ku(n,t){return(n.length>1?n.charAt(0)+"."+n.slice(1):n)+(t<0?"e":"e+")+t}function Sr(n,t,e){var r,i;if(t<0){for(i=e+".";++t;i+=e);n=i+n}else if(r=n.length,++t>r){for(i=e,t-=r;--t;i+=e);n+=i}else t0){let p=l.left;if(p==null||(h=c(p.key,n),h>0&&(l.left=p.right,p.right=l,l=p,p=l.left,p==null)))break;e==null?r=l:e.left=l,e=l,l=p}else if(h<0){let p=l.right;if(p==null||(h=c(p.key,n),h<0&&(l.right=p.left,p.left=l,l=p,p=l.right,p==null)))break;i==null?u=l:i.right=l,i=l,l=p}else break;return i!=null&&(i.right=l.left,l.left=u),e!=null&&(e.left=l.right,l.right=r),this.root!==l&&(this.root=l,this.splayCount++),h}splayMin(n){let t=n,e=t.left;for(;e!=null;){let r=e;t.left=r.right,r.right=t,t=r,e=t.left}return t}splayMax(n){let t=n,e=t.right;for(;e!=null;){let r=e;t.right=r.left,r.left=t,t=r,e=t.right}return t}_delete(n){if(this.root==null||this.splay(n)!=0)return null;let e=this.root,r=e,i=e.left;if(this.size--,i==null)this.root=e.right;else{let u=e.right;e=this.splayMax(i),e.right=u,this.root=e}return this.modificationCount++,r}addNewRoot(n,t){this.size++,this.modificationCount++;let e=this.root;if(e==null){this.root=n;return}t<0?(n.left=e,n.right=e.right,e.right=null):(n.right=e,n.left=e.left,e.left=null),this.root=n}_first(){let n=this.root;return n==null?null:(this.root=this.splayMin(n),this.root)}_last(){let n=this.root;return n==null?null:(this.root=this.splayMax(n),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(n){return this.validKey(n)&&this.splay(n)==0}defaultCompare(){return(n,t)=>nt?1:0}wrap(){return{getRoot:()=>this.root,setRoot:n=>{this.root=n},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:n=>{this.splayCount=n},splay:n=>this.splay(n),has:n=>this.has(n)}}};var rp,ip,fi=class Bo extends Iv{constructor(e,r){super();et(this,"root",null);et(this,"compare");et(this,"validKey");et(this,rp,"[object Set]");this.compare=e!=null?e:this.defaultCompare(),this.validKey=r!=null?r:(i=>i!=null&&i!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(let r of e)this.delete(r)}forEach(e){let r=this[Symbol.iterator](),i;for(;i=r.next(),!i.done;)e(i.value,i.value,this)}add(e){let r=this.splay(e);return r!=0&&this.addNewRoot(new Go(e),r),this}addAndReturn(e){let r=this.splay(e);return r!=0&&this.addNewRoot(new Go(e),r),this.root.key}addAll(e){for(let r of e)this.add(r)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(this.size==0)throw"Bad state: No element";return this._first().key}last(){if(this.size==0)throw"Bad state: No element";return this._last().key}lastBefore(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let i=this.root.left;if(i==null)return null;let u=i.right;for(;u!=null;)i=u,u=i.right;return i.key}firstAfter(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let i=this.root.right;if(i==null)return null;let u=i.left;for(;u!=null;)i=u,u=i.left;return i.key}retainAll(e){let r=new Bo(this.compare,this.validKey),i=this.modificationCount;for(let u of e){if(i!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(u)&&this.splay(u)==0&&r.add(this.root.key)}r.size!=this.size&&(this.root=r.root,this.size=r.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(e){let r=new Bo(this.compare,this.validKey);for(let i of this)e.has(i)&&r.add(i);return r}difference(e){let r=new Bo(this.compare,this.validKey);for(let i of this)e.has(i)||r.add(i);return r}union(e){let r=this.clone();return r.addAll(e),r}clone(){let e=new Bo(this.compare,this.validKey);return e.size=this.size,e.root=this.copyNode(this.root),e}copyNode(e){if(e==null)return null;function r(u,l){let c,h;do{if(c=u.left,h=u.right,c!=null){let p=new Go(c.key);l.left=p,r(c,p)}if(h!=null){let p=new Go(h.key);l.right=p,u=h,l=p}}while(h!=null)}let i=new Go(e.key);return r(e,i),i}toSet(){return this.clone()}entries(){return new Mv(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(ip=Symbol.iterator,rp=Symbol.toStringTag,ip)](){return new Lv(this.wrap())}},op=class{constructor(n){et(this,"tree");et(this,"path",new Array);et(this,"modificationCount",null);et(this,"splayCount");this.tree=n,this.splayCount=n.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;let n=this.path[this.path.length-1];return this.getValue(n)}rebuildPath(n){this.path.splice(0,this.path.length),this.tree.splay(n),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(n){for(;n!=null;)this.path.push(n),n=n.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;e!=null;)this.path.push(e),e=e.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let n=this.path[this.path.length-1],t=n.right;if(t!=null){for(;t!=null;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===n;)n=this.path.pop();return this.path.length>0}},Lv=class extends op{getValue(n){return n.key}},Mv=class extends op{getValue(n){return[n.key,n.key]}};var fp=n=>()=>n,jl=n=>{let t=n?(e,r)=>r.minus(e).abs().isLessThanOrEqualTo(n):fp(!1);return(e,r)=>t(e,r)?0:e.comparedTo(r)};function Cv(n){let t=n?(e,r,i,u,l)=>e.exponentiatedBy(2).isLessThanOrEqualTo(u.minus(r).exponentiatedBy(2).plus(l.minus(i).exponentiatedBy(2)).times(n)):fp(!1);return(e,r,i)=>{let u=e.x,l=e.y,c=i.x,h=i.y,p=l.minus(h).times(r.x.minus(c)).minus(u.minus(c).times(r.y.minus(h)));return t(p,u,l,c,h)?0:p.comparedTo(0)}}var Nv=n=>n,Tv=n=>{if(n){let t=new fi(jl(n)),e=new fi(jl(n)),r=(u,l)=>l.addAndReturn(u),i=u=>({x:r(u.x,t),y:r(u.y,e)});return i({x:new zn(0),y:new zn(0)}),i}return Nv},Kl=n=>({set:t=>{kr=Kl(t)},reset:()=>Kl(n),compare:jl(n),snap:Tv(n),orient:Cv(n)}),kr=Kl(),qo=(n,t)=>n.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(n.ur.x)&&n.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(n.ur.y),$l=(n,t)=>{if(t.ur.x.isLessThan(n.ll.x)||n.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(n.ll.y)||n.ur.y.isLessThan(t.ll.y))return null;let e=n.ll.x.isLessThan(t.ll.x)?t.ll.x:n.ll.x,r=n.ur.x.isLessThan(t.ur.x)?n.ur.x:t.ur.x,i=n.ll.y.isLessThan(t.ll.y)?t.ll.y:n.ll.y,u=n.ur.y.isLessThan(t.ur.y)?n.ur.y:t.ur.y;return{ll:{x:e,y:i},ur:{x:r,y:u}}},Iu=(n,t)=>n.x.times(t.y).minus(n.y.times(t.x)),hp=(n,t)=>n.x.times(t.x).plus(n.y.times(t.y)),Mu=n=>hp(n,n).sqrt(),Ov=(n,t,e)=>{let r={x:t.x.minus(n.x),y:t.y.minus(n.y)},i={x:e.x.minus(n.x),y:e.y.minus(n.y)};return Iu(i,r).div(Mu(i)).div(Mu(r))},Rv=(n,t,e)=>{let r={x:t.x.minus(n.x),y:t.y.minus(n.y)},i={x:e.x.minus(n.x),y:e.y.minus(n.y)};return hp(i,r).div(Mu(i)).div(Mu(r))},sp=(n,t,e)=>t.y.isZero()?null:{x:n.x.plus(t.x.div(t.y).times(e.minus(n.y))),y:e},up=(n,t,e)=>t.x.isZero()?null:{x:e,y:n.y.plus(t.y.div(t.x).times(e.minus(n.x)))},Av=(n,t,e,r)=>{if(t.x.isZero())return up(e,r,n.x);if(r.x.isZero())return up(n,t,e.x);if(t.y.isZero())return sp(e,r,n.y);if(r.y.isZero())return sp(n,t,e.y);let i=Iu(t,r);if(i.isZero())return null;let u={x:e.x.minus(n.x),y:e.y.minus(n.y)},l=Iu(u,t).div(i),c=Iu(u,r).div(i),h=n.x.plus(c.times(t.x)),p=e.x.plus(l.times(r.x)),d=n.y.plus(c.times(t.y)),y=e.y.plus(l.times(r.y)),v=h.plus(p).div(2),_=d.plus(y).div(2);return{x:v,y:_}},fr=class gp{constructor(t,e){et(this,"point");et(this,"isLeft");et(this,"segment");et(this,"otherSE");et(this,"consumedBy");t.events===void 0?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}static compare(t,e){let r=gp.comparePoints(t.point,e.point);return r!==0?r:(t.point!==e.point&&t.link(e),t.isLeft!==e.isLeft?t.isLeft?1:-1:Cu.compare(t.segment,e.segment))}static comparePoints(t,e){return t.x.isLessThan(e.x)?-1:t.x.isGreaterThan(e.x)?1:t.y.isLessThan(e.y)?-1:t.y.isGreaterThan(e.y)?1:0}link(t){if(t.point===this.point)throw new Error("Tried to link already linked events");let e=t.point.events;for(let r=0,i=e.length;r{let u=i.otherSE;e.set(i,{sine:Ov(this.point,t.point,u.point),cosine:Rv(this.point,t.point,u.point)})};return(i,u)=>{e.has(i)||r(i),e.has(u)||r(u);let{sine:l,cosine:c}=e.get(i),{sine:h,cosine:p}=e.get(u);return l.isGreaterThanOrEqualTo(0)&&h.isGreaterThanOrEqualTo(0)?c.isLessThan(p)?1:c.isGreaterThan(p)?-1:0:l.isLessThan(0)&&h.isLessThan(0)?c.isLessThan(p)?-1:c.isGreaterThan(p)?1:0:h.isLessThan(l)?-1:h.isGreaterThan(l)?1:0}}},Fv=class Ql{constructor(t){et(this,"events");et(this,"poly");et(this,"_isExteriorRing");et(this,"_enclosingRing");this.events=t;for(let e=0,r=t.length;e0&&(t=h)}let e=t.segment.prevInResult(),r=e?e.prevInResult():null;for(;;){if(!e)return null;if(!r)return e.ringOut;if(r.ringOut!==e.ringOut)return((i=r.ringOut)==null?void 0:i.enclosingRing())!==e.ringOut?e.ringOut:(u=e.ringOut)==null?void 0:u.enclosingRing();e=r.prevInResult(),r=e?e.prevInResult():null}}},ap=class{constructor(n){et(this,"exteriorRing");et(this,"interiorRings");this.exteriorRing=n,n.poly=this,this.interiorRings=[]}addInterior(n){this.interiorRings.push(n),n.poly=this}getGeom(){let n=this.exteriorRing.getGeom();if(n===null)return null;let t=[n];for(let e=0,r=this.interiorRings.length;e0?(this.tree.delete(t),e.push(n)):(this.segments.push(t),t.prev=r)}else{if(r&&i){let u=r.getIntersection(i);if(u!==null){if(!r.isAnEndpoint(u)){let l=this._splitSafely(r,u);for(let c=0,h=l.length;c0)return-1;let v=e.comparePoint(t.rightSE.point);return v!==0?v:-1}if(r.isGreaterThan(i)){if(c.isLessThan(h)&&c.isLessThan(d))return-1;if(c.isGreaterThan(h)&&c.isGreaterThan(d))return 1;let y=e.comparePoint(t.leftSE.point);if(y!==0)return y;let v=t.comparePoint(e.rightSE.point);return v<0?1:v>0?-1:1}if(c.isLessThan(h))return-1;if(c.isGreaterThan(h))return 1;if(u.isLessThan(l)){let y=e.comparePoint(t.rightSE.point);if(y!==0)return y}if(u.isGreaterThan(l)){let y=t.comparePoint(e.rightSE.point);if(y<0)return 1;if(y>0)return-1}if(!u.eq(l)){let y=p.minus(c),v=u.minus(r),_=d.minus(h),I=l.minus(i);if(y.isGreaterThan(v)&&_.isLessThan(I))return 1;if(y.isLessThan(v)&&_.isGreaterThan(I))return-1}return u.isGreaterThan(l)?1:u.isLessThan(l)||p.isLessThan(d)?-1:p.isGreaterThan(d)?1:t.ide.id?1:0}static fromRing(t,e,r){let i,u,l,c=fr.comparePoints(t,e);if(c<0)i=t,u=e,l=1;else if(c>0)i=e,u=t,l=-1;else throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);let h=new fr(i,!0),p=new fr(u,!1);return new Lu(h,p,[r],[l])}replaceRightSE(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t.isLessThan(e)?t:e},ur:{x:this.rightSE.point.x,y:t.isGreaterThan(e)?t:e}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(t){return t.x.eq(this.leftSE.point.x)&&t.y.eq(this.leftSE.point.y)||t.x.eq(this.rightSE.point.x)&&t.y.eq(this.rightSE.point.y)}comparePoint(t){return kr.orient(this.leftSE.point,t,this.rightSE.point)}getIntersection(t){let e=this.bbox(),r=t.bbox(),i=$l(e,r);if(i===null)return null;let u=this.leftSE.point,l=this.rightSE.point,c=t.leftSE.point,h=t.rightSE.point,p=qo(e,c)&&this.comparePoint(c)===0,d=qo(r,u)&&t.comparePoint(u)===0,y=qo(e,h)&&this.comparePoint(h)===0,v=qo(r,l)&&t.comparePoint(l)===0;if(d&&p)return v&&!y?l:!v&&y?h:null;if(d)return y&&u.x.eq(h.x)&&u.y.eq(h.y)?null:u;if(p)return v&&l.x.eq(c.x)&&l.y.eq(c.y)?null:c;if(v&&y)return null;if(v)return l;if(y)return h;let _=Av(u,this.vector(),c,t.vector());return _===null||!qo(i,_)?null:kr.snap(_)}split(t){let e=[],r=t.events!==void 0,i=new fr(t,!0),u=new fr(t,!1),l=this.rightSE;this.replaceRightSE(u),e.push(u),e.push(i);let c=new Lu(i,l,this.rings.slice(),this.windings.slice());return fr.comparePoints(c.leftSE.point,c.rightSE.point)>0&&c.swapEvents(),fr.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),u.checkForConsuming()),e}swapEvents(){let t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,r=this.windings.length;e0){let u=e;e=r,r=u}if(e.prev===r){let u=e;e=r,r=u}for(let u=0,l=r.rings.length;ui.length===1&&i[0].isSubject;this._isInResult=r(t)!==r(e);break}}return this._isInResult}},lp=class{constructor(n,t,e){et(this,"poly");et(this,"isExterior");et(this,"segments");et(this,"bbox");if(!Array.isArray(n)||n.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=t,this.isExterior=e,this.segments=[],typeof n[0][0]!="number"||typeof n[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let r=kr.snap({x:new zn(n[0][0]),y:new zn(n[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let u=1,l=n.length;uYi.run("union",n,t),Xv=(n,...t)=>Yi.run("intersection",n,t),Uv=(n,...t)=>Yi.run("xor",n,t),Yv=(n,...t)=>Yi.run("difference",n,t),Jv=kr.set;function pp(n,t={}){if(t=t||{},!Ft(t))throw new Error("options is invalid");let{propertyName:e}=t;Qe(n,"Polygon","dissolve");let r=[];if(e){let i={};Dt(n,function(l){l.properties&&(Object.prototype.hasOwnProperty.call(i,l.properties[e])||(i[l.properties[e]]=[]),i[l.properties[e]].push(l))});let u=Object.keys(i);for(let l=0;l{c.push(We(y))});let h=[];for(let y=0;y_+I,0);for(let _=0;_180?-360:r[0]-i[0]>180?360:0;let u=Hv(r,i);return Vn(u,"meters",e.units)}function Hv(n,t,e){e=e===void 0?ke:Number(e);let r=e,i=n[1]*Math.PI/180,u=t[1]*Math.PI/180,l=u-i,c=Math.abs(t[0]-n[0])*Math.PI/180;c>Math.PI&&(c-=2*Math.PI);let h=Math.log(Math.tan(u/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),p=Math.abs(h)>1e-11?l/h:Math.cos(i);return Math.sqrt(l*l+p*p*c*c)*r}function Ur(n,t,e,r={}){let i=t<0,u=Vn(Math.abs(t),r.units,"meters");i&&(u=-Math.abs(u));let l=Ut(n),c=Zv(l,u,e);return c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0,wt(c,r.properties)}function Zv(n,t,e,r){r=r===void 0?ke:Number(r);let i=t/r,u=n[0]*Math.PI/180,l=_e(n[1]),c=_e(e),h=i*Math.cos(c),p=l+h;Math.abs(p)>Math.PI/2&&(p=p>0?Math.PI-p:-Math.PI-p);let d=Math.log(Math.tan(p/2+Math.PI/4)/Math.tan(l/2+Math.PI/4)),y=Math.abs(d)>1e-11?h/d:Math.cos(l),v=i*Math.sin(c)/y;return[((u+v)*180/Math.PI+540)%360-180,p*180/Math.PI]}function Ou(n,t,e){if(e=e||{},!Ft(e))throw new Error("options is invalid");let r=e.pivot,i=e.mutate;if(!n)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("angle is required");if(t===0)return n;let u=r!=null?r:We(n);return(i===!1||i===void 0)&&(n=se(n)),ne(n,function(l){let h=On(u,l)+t,p=hr(u,l),d=Lt(Ur(u,p,h));l[0]=d[0],l[1]=d[1]}),n}function Ru(n,t,e,r){r=r||{};let i=r.steps||64,u=r.units||"kilometers",l=r.angle||0,c=r.pivot||n,h=r.properties||{};if(!n)throw new Error("center is required");if(!t)throw new Error("xSemiAxis is required");if(!e)throw new Error("ySemiAxis is required");if(!Ft(r))throw new Error("options must be an object");if(!ye(i))throw new Error("steps must be a number");if(!ye(l))throw new Error("angle must be a number");let p=Ut(Ou(wt(Ut(n)),l,{pivot:c}));l=-90+l,i=Math.ceil(i/4);let d=[],y=[],v=t,_=e,I=_,F=(v-_)/(Math.PI/2),M=(v+_)*Math.PI/4,L=.5,C=i,q=0,V=0;for(let G=0;Ge!==void 0).map(e=>e.coords)},properties:this.properties}}wkt(){if(this.geometries.length===0)return"";let t=[];for(let e of this.geometries){if(!e||e.coords.length===0){t.push("LINESTRING EMPTY");continue}let r=e.coords.filter(i=>i!==void 0).map(i=>{var c,h;let u=(c=i[0])!=null?c:0,l=(h=i[1])!=null?h:0;return`${u} ${l}`});r.length===0?t.push("LINESTRING EMPTY"):t.push(`LINESTRING(${r.join(",")})`)}return t.join("; ")}};var Uo=class{constructor(){et(this,"coords",[]);et(this,"length",0)}move_to(t){this.length++,this.coords.push(t)}};var Yo=class{constructor(t,e,r){et(this,"start");et(this,"end");et(this,"properties");et(this,"g");if(!t||t.x===void 0||t.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||e.x===void 0||e.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new Ji(t.x,t.y),this.end=new Ji(e.x,e.y),this.properties=r||{};let i=this.start.x-this.end.x,u=this.start.y-this.end.y,l=Math.pow(Math.sin(u/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(i/2),2);if(this.g=2*Math.asin(Math.sqrt(l)),this.g===Math.PI)throw new Error("it appears "+this.start.view()+" and "+this.end.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)}interpolate(t){let e=Math.sin((1-t)*this.g)/Math.sin(this.g),r=Math.sin(t*this.g)/Math.sin(this.g),i=e*Math.cos(this.start.y)*Math.cos(this.start.x)+r*Math.cos(this.end.y)*Math.cos(this.end.x),u=e*Math.cos(this.start.y)*Math.sin(this.start.x)+r*Math.cos(this.end.y)*Math.sin(this.end.x),l=e*Math.sin(this.start.y)+r*Math.sin(this.end.y),c=Du*Math.atan2(l,Math.sqrt(Math.pow(i,2)+Math.pow(u,2)));return[Du*Math.atan2(u,i),c]}Arc(t,e){var v,_,I,F,M,L,C,q,V,X,G,J,k,N,T,D,B,K,w,R,x,b,E,A,z,W,j,tt,ot,rt,$,ht,ct,ut,H,vt,Nt,St,Ot,Tt,he,ft,gn,vn,qe,Xn,Xt,xn,_n,ze,zt;let r=[];if(!t||t<=2)r.push([this.start.lon,this.start.lat]),r.push([this.end.lon,this.end.lat]);else{let ae=1/(t-1);for(let bt=0;btp&&(Rt>c&&btc&&Rtu&&(u=Pe)}let d=[];if(i&&u0&&Math.abs(Rt-((V=(q=r[bt-1])==null?void 0:q[0])!=null?V:0))>p){let Pe=parseFloat(((G=(X=r[bt-1])==null?void 0:X[0])!=null?G:0).toString()),Fe=parseFloat(((k=(J=r[bt-1])==null?void 0:J[1])!=null?k:0).toString()),Pn=parseFloat(((T=(N=r[bt])==null?void 0:N[0])!=null?T:0).toString()),qt=parseFloat(((B=(D=r[bt])==null?void 0:D[1])!=null?B:0).toString());if(Pe>-180&&Pe-180&&((x=(R=r[bt-1])==null?void 0:R[0])!=null?x:0)c&&Pe<180&&Pn===-180&&bt+1c&&(($=(rt=r[bt-1])==null?void 0:rt[0])!=null?$:0)<180){ae.push([180,(ct=(ht=r[bt])==null?void 0:ht[1])!=null?ct:0]),bt++,ae.push([(H=(ut=r[bt])==null?void 0:ut[0])!=null?H:0,(Nt=(vt=r[bt])==null?void 0:vt[1])!=null?Nt:0]);continue}if(Pec){let $n=Pe,Hr=Pn,Lr=$n,je=Fe,Ke=qt,Oe=je}if(Pe>c&&Pn=180&&Pec?180:-180,Hr]),ae=[],ae.push([((he=(Tt=r[bt-1])==null?void 0:Tt[0])!=null?he:0)>c?-180:180,Hr]),d.push(ae)}else ae=[],d.push(ae);ae.push([Rt,(gn=(ft=r[bt])==null?void 0:ft[1])!=null?gn:0])}else ae.push([(qe=(vn=r[bt])==null?void 0:vn[0])!=null?qe:0,(Xt=(Xn=r[bt])==null?void 0:Xn[1])!=null?Xt:0])}}else{let ae=[];d.push(ae);for(let bt=0;bt0?[...n].reverse():n}function yp(n){return n.map(([t,e])=>({x:t,y:e}))}function _p(n){let t=[];for(let e=0;e0&&e.push(r);for(let i=0;i0&&e.push(l)}t.push(e)}for(let e=0;e0&&t){let r=e[0],i=e[e.length-1];(r[0]!==i[0]||r[1]!==i[1])&&e.push([r[0],r[1]])}return e}function Jr(n,t={}){if(n.features.length<2)throw new Error("Must have at least 2 features");let e=new Dn(xp);ve(n,(u,l)=>{u.type==="MultiPolygon"?l===0?e.addSubjectPaths(ec(u.coordinates)):e.addClipPaths(ec(u.coordinates)):l===0?e.addSubjectPaths(Gu(u.coordinates)):e.addClipPaths(Gu(u.coordinates))});let r=new Pr;e.execute(ie.Intersection,ee.EvenOdd,r);let i=_p(r);return i===null?null:te(i,t.properties)}function Bu(n,t,e={}){let r=JSON.stringify(e.properties||{}),[i,u,l,c]=n,h=(u+c)/2,p=(i+l)/2,y=t*2/$t([i,h],[l,h],e)*(l-i),_=t*2/$t([p,u],[p,c],e)*(c-u),I=y/2,F=I*2,M=Math.sqrt(3)/2*_,L=l-i,C=c-u,q=3/4*F,V=M,X=(L-F)/(F-I/2),G=Math.floor(X),J=(G*q-I/2-L)/2-I/2+q/2,k=Math.floor((C-M)/M),N=(C-k*M)/2,T=k*M-C>M/2;T&&(N-=M/4);let D=[],B=[];for(let w=0;w<6;w++){let R=2*Math.PI/6*w;D.push(Math.cos(R)),B.push(Math.sin(R))}let K=[];for(let w=0;w<=G;w++)for(let R=0;R<=k;R++){let x=w%2===1;if(R===0&&x||R===0&&T)continue;let b=w*q+i-J,E=R*V+u+N;if(x&&(E-=M/2),e.triangles===!0)$v([b,E],y/2,_/2,JSON.parse(r),D,B).forEach(function(A){e.mask?Jr(pt([e.mask,A]))&&K.push(A):K.push(A)});else{let A=Kv([b,E],y/2,_/2,JSON.parse(r),D,B);e.mask?Jr(pt([e.mask,A]))&&K.push(A):K.push(A)}}return pt(K)}function Kv(n,t,e,r,i,u){let l=[];for(let c=0;c<6;c++){let h=n[0]+t*i[c],p=n[1]+e*u[c];l.push([h,p])}return l.push(l[0].slice()),Mt([l],r)}function $v(n,t,e,r,i,u){let l=[];for(let c=0;c<6;c++){let h=[];h.push(n),h.push([n[0]+t*i[c],n[1]+e*u[c]]),h.push([n[0]+t*i[(c+1)%6],n[1]+e*u[(c+1)%6]]),h.push(n),l.push(Mt([h],r))}return l}function qu(n,t,e={}){e.mask&&!e.units&&(e.units="kilometers");for(var r=[],i=n[0],u=n[1],l=n[2],c=n[3],h=t/$t([i,u],[l,u],e),p=h*(l-i),d=t/$t([i,u],[i,c],e),y=d*(c-u),v=l-i,_=c-u,I=Math.floor(v/p),F=Math.floor(_/y),M=(v-I*p)/2,L=(_-F*y)/2,C=i+M;C<=l;){for(var q=u+L;q<=c;){var V=wt([C,q],e.properties);e.mask?As(V,e.mask)&&r.push(V):r.push(V),q+=y}C+=p}return pt(r)}function zu(n,t,e,r={}){let i=[],u=n[0],l=n[1],c=n[2],h=n[3],p=c-u,d=Vn(t,r.units,"degrees"),y=h-l,v=Vn(e,r.units,"degrees"),_=Math.floor(Math.abs(p)/d),I=Math.floor(Math.abs(y)/v),F=(p-_*d)/2,M=(y-I*v)/2,L=u+F;for(let C=0;C<_;C++){let q=l+M;for(let V=0;V{var u=Lt(i)[1];e[u]||(e[u]=[]),e[u].push(i)});let r=[];for(let i of Object.values(e))r.push(i.sort((u,l)=>Lt(u)[0]-Lt(l)[0]));return r.sort(t?(i,u)=>Lt(i[0])[1]-Lt(u[0])[1]:(i,u)=>Lt(u[0])[1]-Lt(i[0])[1]),r}function kp(n,t,e){if(e=e||{},!Ft(e))throw new Error("options is invalid");let r=e.zProperty||"elevation",i=e.commonProperties||{},u=e.breaksProperties||[];if(Qe(n,"Point","Input must contain Points"),!t)throw new Error("breaks is required");if(!Array.isArray(t))throw new Error("breaks is not an Array");if(!Ft(i))throw new Error("commonProperties is not an Object");if(!Array.isArray(u))throw new Error("breaksProperties is not an Array");let l=Ep(n,{zProperty:r,flip:!0}),c=l[0].length;if(l.length<2||c<2)throw new Error("Matrix of points must be at least 2x2");for(let d=1;d{if(u[y]&&!Ft(u[y]))throw new Error("Each mappedProperty is required to be an Object");let v=Ve(Ve({},i),u[y]);return v[r]=d[r],He(d.groupedRings,v)});return pt(p)}function tx(n,t,e){let r=[],i;for(let u=1;u_.map(I=>[I[0],I[1]]).reverse()),d=ex(i.concat(p),n),y=rx(d),v=ix(y);if(v.length===0&&n[0][0]=c){let _=n[0].length,I=n.length;v.push([[[0,0],[_-1,0],[_-1,I-1],[0,I-1],[0,0]]])}r.push({groupedRings:v,[e]:c+"-"+l}),i=h}return r}function wp(n,t){let e=[],r=n[0].length,i=n.length;for(let l=0;l=t?8:0)|(h>=t?4:0)|(p>=t?2:0)|(d>=t?1:0)){case 0:continue;case 1:e.push([[c+u(d,p),l],[c,l+u(d,y)]]);break;case 2:e.push([[c+1,l+u(p,h)],[c+u(d,p),l]]);break;case 3:e.push([[c+1,l+u(p,h)],[c,l+u(d,y)]]);break;case 4:e.push([[c+u(y,h),l+1],[c+1,l+u(p,h)]]);break;case 5:{(y+h+p+d)/4>=t?e.push([[c+u(y,h),l+1],[c,l+u(d,y)]],[[c+u(d,p),l],[c+1,l+u(p,h)]]):e.push([[c+u(y,h),l+1],[c+1,l+u(p,h)]],[[c+u(d,p),l],[c,l+u(d,y)]]);break}case 6:e.push([[c+u(y,h),l+1],[c+u(d,p),l]]);break;case 7:e.push([[c+u(y,h),l+1],[c,l+u(d,y)]]);break;case 8:e.push([[c,l+u(d,y)],[c+u(y,h),l+1]]);break;case 9:e.push([[c+u(d,p),l],[c+u(y,h),l+1]]);break;case 10:{(y+h+p+d)/4>=t?e.push([[c,l+u(d,y)],[c+u(d,p),l]],[[c+1,l+u(p,h)],[c+u(y,h),l+1]]):e.push([[c,l+u(d,y)],[c+u(y,h),l+1]],[[c+1,l+u(p,h)],[c+u(d,p),l]]);break}case 11:e.push([[c+1,l+u(p,h)],[c+u(y,h),l+1]]);break;case 12:e.push([[c,l+u(d,y)],[c+1,l+u(p,h)]]);break;case 13:e.push([[c+u(d,p),l],[c+1,l+u(p,h)]]);break;case 14:e.push([[c,l+u(d,y)],[c+u(d,p),l]]);break;case 15:continue}}return e;function u(l,c){if(l===c)return .5;let h=(t-l)/(c-l);return h>1?1:h<0?0:h}}function ex(n,t){let e=t.length,r=t[0].length,i=[],u=[];for(;n.length>0;){let l=[...n.shift()];i.push(l);let c;do{c=!1;for(let h=0;h0;){let l=i[0];if(l[0][0]===l[l.length-1][0]&&l[0][1]===l[l.length-1][1]){u.push(l),i.shift();continue}let c=l[l.length-1],h,p;if(c[0]===0&&c[1]!==0)h=Uu(i,d=>d[0][0]===0&&d[0][1]y[0][1]-d[0][1]),p=[0,0];else if(c[1]===0&&c[0]!==r-1)h=Uu(i,d=>d[0][1]===0&&d[0][0]>c[0],(d,y)=>d[0][0]-y[0][0]),p=[r-1,0];else if(c[0]===r-1&&c[1]!==e-1)h=Uu(i,d=>d[0][0]===r-1&&d[0][1]>c[1],(d,y)=>d[0][1]-y[0][1]),p=[r-1,e-1];else if(c[1]===e-1&&c[0]!==0)h=Uu(i,d=>d[0][1]===e-1&&d[0][0]y[0][0]-d[0][0]),p=[0,e-1];else throw new Error("Contour not closed but is not along an edge");if(h===-1)l.push(p);else if(h===0)l.push([l[0][0],l[0][1]]),u.push(l),i.shift();else{let d=i[h];i.splice(h,1);for(let y of d)l.push(y)}}for(let l=0;l[F[0]*d+l,F[1]*y+c])})}),v})}function rx(n){let t=n.map(function(e){return{ring:e,area:ir(Mt([e]))}});return t.sort(function(e,r){return r.area-e.area}),t.map(function(e){return e.ring})}function ix(n){let t=n.map(r=>({lrCoordinates:r,grouped:!1})),e=[];for(;!ox(t);)for(let r=0;r0)&&(r=i);return r}function Ip(n,t={}){if(!Ft(t))throw new Error("options is invalid");let{zProperty:e="elevation",flip:r=!1,flags:i=!1}=t;Qe(n,"Point","input must contain Points");for(var u=sx(n,r),l=[],c=0;c{var u=Lt(i)[1];e[u]||(e[u]=[]),e[u].push(i)});let r=[];for(let i of Object.values(e))r.push(i.sort((u,l)=>Lt(u)[0]-Lt(l)[0]));return r.sort(t?(i,u)=>Lt(i[0])[1]-Lt(u[0])[1]:(i,u)=>Lt(u[0])[1]-Lt(i[0])[1]),r}function Lp(n,t,e){if(e=e||{},!Ft(e))throw new Error("options is invalid");let r=e.zProperty||"elevation",i=e.commonProperties||{},u=e.breaksProperties||[];if(Qe(n,"Point","Input must contain Points"),!t)throw new Error("breaks is required");if(!Array.isArray(t))throw new Error("breaks must be an Array");if(!Ft(i))throw new Error("commonProperties must be an Object");if(!Array.isArray(u))throw new Error("breaksProperties must be an Array");let l=Ip(n,{zProperty:r,flip:!0}),c=l[0].length;if(l.length<2||c<2)throw new Error("Matrix of points must be at least 2x2");for(let d=1;d=t?8:0)|(p>=t?4:0)|(d>=t?2:0)|(y>=t?1:0)){case 0:continue;case 1:e.push([[h+l(y,d),c],[h,c+l(y,v)]]);break;case 2:e.push([[h+1,c+l(d,p)],[h+l(y,d),c]]);break;case 3:e.push([[h+1,c+l(d,p)],[h,c+l(y,v)]]);break;case 4:e.push([[h+l(v,p),c+1],[h+1,c+l(d,p)]]);break;case 5:{(v+p+d+y)/4>=t?e.push([[h+l(v,p),c+1],[h,c+l(y,v)]],[[h+l(y,d),c],[h+1,c+l(d,p)]]):e.push([[h+l(v,p),c+1],[h+1,c+l(d,p)]],[[h+l(y,d),c],[h,c+l(y,v)]]);break}case 6:e.push([[h+l(v,p),c+1],[h+l(y,d),c]]);break;case 7:e.push([[h+l(v,p),c+1],[h,c+l(y,v)]]);break;case 8:e.push([[h,c+l(y,v)],[h+l(v,p),c+1]]);break;case 9:e.push([[h+l(y,d),c],[h+l(v,p),c+1]]);break;case 10:{(v+p+d+y)/4>=t?e.push([[h,c+l(y,v)],[h+l(y,d),c]],[[h+1,c+l(d,p)],[h+l(v,p),c+1]]):e.push([[h,c+l(y,v)],[h+l(v,p),c+1]],[[h+1,c+l(d,p)],[h+l(y,d),c]]);break}case 11:e.push([[h+1,c+l(d,p)],[h+l(v,p),c+1]]);break;case 12:e.push([[h,c+l(y,v)],[h+1,c+l(d,p)]]);break;case 13:e.push([[h+l(y,d),c],[h+1,c+l(d,p)]]);break;case 14:e.push([[h,c+l(y,v)],[h+l(y,d),c]]);break;case 15:continue}}let u=[];for(;e.length>0;){let c=[...e.shift()];u.push(c);let h;do{h=!1;for(let p=0;p1?1:p<0?0:p}}function lx(n,t,e){let r=jt(e),i=r[2]-r[0],u=r[3]-r[1],l=r[0],c=r[1],h=t[0].length-1,p=t.length-1,d=i/h,y=u/p,v=_=>{_[0]=_[0]*d+l,_[1]=_[1]*y+c};return n.forEach(_=>{ne(_,v)}),n}function Mp(n){let t,e,r={type:"FeatureCollection",features:[]};if(n.type==="Feature"?e=n.geometry:e=n,e.type==="LineString")t=[e.coordinates];else if(e.type==="MultiLineString")t=e.coordinates;else if(e.type==="MultiPolygon")t=[].concat(...e.coordinates);else if(e.type==="Polygon")t=e.coordinates;else throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");return t.forEach(i=>{t.forEach(u=>{for(let l=0;l=0&&p<=1&&(_.onLine1=!0),d>=0&&d<=1&&(_.onLine2=!0),_.onLine1&&_.onLine2?[_.x,_.y]:!1)}function Yu(n,t={}){return bs(n,(e,r)=>{let i=r.geometry.coordinates;return e+$t(i[0],i[1],t)},0)}function Ju(n,t,e,r,i={}){let u=i.steps||64,l=Cp(e),c=Cp(r),h=!Array.isArray(n)&&n.type==="Feature"?n.properties:{};if(l===c)return At(Bi(n,t,i).geometry.coordinates[0],h);let p=l,d=l=h&&_===u.length-1);_++){if(h>t&&l.length===0){let I=t-h;if(!I)return l.push(u[_]),At(l);d=In(u[_],u[_-1])-180,y=an(u[_],I,d,{units:i}),l.push(y.geometry.coordinates)}if(h>=e)return p=e-h,p?(d=In(u[_],u[_-1])-180,y=an(u[_],p,d,{units:i}),l.push(y.geometry.coordinates),At(l)):(l.push(u[_]),At(l));if(h>=t&&l.push(u[_]),_===u.length-1)return At(l);h+=$t(u[_],u[_+1],{units:i})}if(h{i&&(l.geometry.coordinates=l.geometry.coordinates.reverse()),fx(l,t,r,c=>{u.push(c)})}),pt(u)}function fx(n,t,e,r){var i=Yu(n,{units:e});if(i<=t)return r(n);var u=i/t;Number.isInteger(u)||(u=Math.floor(u)+1);for(var l=0;l0){var d=r[h-1],y=Tp(p,d);y!==!1&&(d[1]=y,p[0]=y),l.push(d[0]),h===u.length-2&&(l.push(p[0]),l.push(p[1]))}u.length===2&&(l.push(p[0]),l.push(p[1]))}}),At(l,n.type==="Feature"?n.properties:{})}function yx(n,t,e){var r=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),i=n[0]+e*(t[1]-n[1])/r,u=t[0]+e*(t[1]-n[1])/r,l=n[1]+e*(n[0]-t[0])/r,c=t[1]+e*(n[0]-t[0])/r;return[[i,l],[u,c]]}function Ap(n,t,e){let r=Lt(e);if(be(e)!=="LineString")throw new Error("line must be a LineString");let i=mn(e,n),u=mn(e,t),l=i.properties.index<=u.properties.index?[i,u]:[u,i],c=[l[0].geometry.coordinates];for(let h=l[0].properties.index+1;hh?(c.unshift(p),h=d):c.push(p)}else c.push(p)}),Mt(c,t);default:throw new Error("geometry type "+l+" is not supported")}}function Dp(n){var t=n[0],e=t[0],r=t[1],i=n[n.length-1],u=i[0],l=i[1];return(e!==u||r!==l)&&n.push(t),n}function vx(n){var t=n[0],e=n[1],r=n[2],i=n[3];return Math.abs(t-r)*Math.abs(e-i)}function Bp(n,t,e){var c;let r=(c=e==null?void 0:e.mutate)!=null?c:!1,i=t;t&&r===!1&&(i=se(t));let u=_x(i),l=null;return n.type==="FeatureCollection"?l=xx(n):n.type==="Feature"?l=rc(Ir(n.geometry.coordinates)):l=rc(Ir(n.coordinates)),l.geometry.coordinates.forEach(function(h){u.geometry.coordinates.push(h[0])}),u}function xx(n){let t=n.features.length===2?Ir(n.features[0].geometry.coordinates,n.features[1].geometry.coordinates):Ir.apply(Nu,n.features.map(function(e){return e.geometry.coordinates}));return rc(t)}function rc(n){return He(n)}function _x(n){let e=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]];return n&&(n.type==="Feature"?e=n.geometry.coordinates:e=n.coordinates),Mt(e)}function qp(n,t){let e=$t(n,t),r=In(n,t);return an(n,e/2,r)}function zp(n,t){var k,N;let e=t.inputField,r=t.threshold||1e5,i=t.p||2,u=(k=t.binary)!=null?k:!1,l=t.alpha||-1,c=(N=t.standardization)!=null?N:!0,h=Tu(n,{alpha:l,binary:u,p:i,standardization:c,threshold:r}),p=[];Dt(n,T=>{let D=T.properties||{};p.push(D[e])});let d=Xp(p),y=Px(p),v=0,_=0,I=0,F=0,M=h.length;for(let T=0;T{let h=$t(n,l,e);h{u.push(We(y))});let l=u.length,c=u.map((y,v)=>{let _=pt(u.filter((I,F)=>F!==v));return $t(y,Vr(y,_).geometry.coordinates,{units:i})}).reduce((y,v)=>y+v,0)/l,h=l/ds(ir(e),"meters",i),p=1/(2*Math.sqrt(h)),d=.26136/Math.sqrt(l*h);return r.nearestNeighborAnalysis={units:i,arealUnits:i+"\xB2",observedMeanDistance:c,expectedMeanDistance:p,nearestNeighborIndex:c/p,numberOfPoints:l,zScore:(c-p)/d},e.properties=r,e}function Hi(n,t,e={}){var c,h;let r=(c=e.method)!=null?c:"geodesic",i=(h=e.units)!=null?h:"kilometers";if(!n)throw new Error("pt is required");if(Array.isArray(n)?n=wt(n):n.type==="Point"?n=te(n):ni(n,"Point","point"),!t)throw new Error("line is required");Array.isArray(t)?t=At(t):t.type==="LineString"?t=te(t):ni(t,"LineString","line");let u=1/0,l=n.geometry.coordinates;return Rn(t,p=>{if(p){let d=p.geometry.coordinates[0],y=p.geometry.coordinates[1],v=Ex(l,d,y,{method:r});v{let p=Hi(h,t,{units:r});p{r.type==="Point"&&t.push({type:"Feature",properties:{},geometry:r})}),{type:"FeatureCollection",features:t};case"FeatureCollection":return n.features=n.features.filter(r=>r.geometry.type==="Point"),n;default:throw new Error("points must be a Point Collection")}}function Jp(n,t){let e=Ut(n),u=Wt(t).coordinates[0];if(u.length<4)throw new Error("OuterRing of a Polygon must have 4 or more Positions.");let l=t.type==="Feature"&&t.properties||{},c=l.a,h=l.b,p=l.c,d=e[0],y=e[1],v=u[0][0],_=u[0][1],I=c!==void 0?c:u[0][2],F=u[1][0],M=u[1][1],L=h!==void 0?h:u[1][2],C=u[2][0],q=u[2][1],V=p!==void 0?p:u[2][2];return(V*(d-v)*(y-M)+I*(d-F)*(y-q)+L*(d-C)*(y-_)-L*(d-v)*(y-q)-V*(d-F)*(y-_)-I*(d-C)*(y-M))/((d-v)*(y-M)+(d-F)*(y-q)+(d-C)*(y-_)-(d-v)*(y-q)-(d-F)*(y-_)-(d-C)*(y-M))}function Hp(n){let t=Sx(n),e=Ar(t),r=!1,i=0;for(;!r&&iWu(n,Mt(y),{method:r,units:i}));return Math.min(...d.map(Math.abs))*(Ct(n,t)?-1:1)}if(u.coordinates.length>1){let[d,...y]=u.coordinates.map(_=>Wu(n,Mt([_]),{method:r,units:i}));if(d>=0)return d;let v=Math.min(...y);return v<0?Math.abs(v):Math.max(v*-1,d)}let l=sr(u),c=1/0;return le(l,d=>{c=Math.min(c,Hi(n,d,{method:r,units:i}))}),Ct(n,u)?-c:c}function kx(n){return(n>0)-(n<0)||+n}function Zi(n,t,e){let r=t[0]-n[0],i=t[1]-n[1],u=e[0]-t[0],l=e[1]-t[1];return kx(r*l-u*i)}function Zp(n,t){let e=n.geometry.coordinates[0].map(l=>l[0]),r=n.geometry.coordinates[0].map(l=>l[1]),i=t.geometry.coordinates[0].map(l=>l[0]),u=t.geometry.coordinates[0].map(l=>l[1]);return Math.max.apply(null,e)===Math.max.apply(null,i)&&Math.max.apply(null,r)===Math.max.apply(null,u)&&Math.min.apply(null,e)===Math.min.apply(null,i)&&Math.min.apply(null,r)===Math.min.apply(null,u)}function ic(n,t){return t.geometry.coordinates[0].every(e=>Ct(wt(e),n))}function Wp(n,t){return n[0]===t[0]&&n[1]===t[1]}var Jo=class n{static buildId(t){return t.join(",")}constructor(t){this.id=n.buildId(t),this.coordinates=t,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}removeInnerEdge(t){this.innerEdges=this.innerEdges.filter(e=>e.from.id!==t.from.id)}removeOuterEdge(t){this.outerEdges=this.outerEdges.filter(e=>e.to.id!==t.to.id)}addOuterEdge(t){this.outerEdges.push(t),this.outerEdgesSorted=!1}sortOuterEdges(){this.outerEdgesSorted||(this.outerEdges.sort((t,e)=>{let r=t.to,i=e.to;if(r.coordinates[0]-this.coordinates[0]>=0&&i.coordinates[0]-this.coordinates[0]<0)return 1;if(r.coordinates[0]-this.coordinates[0]<0&&i.coordinates[0]-this.coordinates[0]>=0)return-1;if(r.coordinates[0]-this.coordinates[0]===0&&i.coordinates[0]-this.coordinates[0]===0)return r.coordinates[1]-this.coordinates[1]>=0||i.coordinates[1]-this.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];let u=Zi(this.coordinates,r.coordinates,i.coordinates);if(u<0)return 1;if(u>0)return-1;let l=Math.pow(r.coordinates[0]-this.coordinates[0],2)+Math.pow(r.coordinates[1]-this.coordinates[1],2),c=Math.pow(i.coordinates[0]-this.coordinates[0],2)+Math.pow(i.coordinates[1]-this.coordinates[1],2);return l-c}),this.outerEdgesSorted=!0)}getOuterEdges(){return this.sortOuterEdges(),this.outerEdges}getOuterEdge(t){return this.sortOuterEdges(),this.outerEdges[t]}addInnerEdge(t){this.innerEdges.push(t)}};var ju=class n{getSymetric(){return this.symetric||(this.symetric=new n(this.to,this.from),this.symetric.symetric=this),this.symetric}constructor(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}deleteEdge(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)}isEqual(t){return this.from.id===t.from.id&&this.to.id===t.to.id}toString(){return`Edge { ${this.from.id} -> ${this.to.id} }`}toLineString(){return At([this.from.coordinates,this.to.coordinates])}compareTo(t){return Zi(t.from.coordinates,t.to.coordinates,this.to.coordinates)}};var Wi=class{constructor(){this.edges=[],this.polygon=void 0,this.envelope=void 0}push(t){this.edges.push(t),this.polygon=this.envelope=void 0}get(t){return this.edges[t]}get length(){return this.edges.length}forEach(t){this.edges.forEach(t)}map(t){return this.edges.map(t)}some(t){return this.edges.some(t)}isValid(){return!0}isHole(){let t=this.edges.reduce((u,l,c)=>(l.from.coordinates[1]>this.edges[u].from.coordinates[1]&&(u=c),u),0),e=(t===0?this.length:t)-1,r=(t+1)%this.length,i=Zi(this.edges[e].from.coordinates,this.edges[t].from.coordinates,this.edges[r].from.coordinates);return i===0?this.edges[e].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0}toMultiPoint(){return Qr(this.edges.map(t=>t.from.coordinates))}toPolygon(){if(this.polygon)return this.polygon;let t=this.edges.map(e=>e.from.coordinates);return t.push(this.edges[0].from.coordinates),this.polygon=Mt([t])}getEnvelope(){return this.envelope?this.envelope:this.envelope=Au(this.toPolygon())}static findEdgeRingContaining(t,e){let r=t.getEnvelope(),i,u;return e.forEach(l=>{let c=l.getEnvelope();if(u&&(i=u.getEnvelope()),!Zp(c,r)&&ic(c,r)){let h=t.map(d=>d.from.coordinates),p;for(let d of h)l.some(y=>Wp(d,y.from.coordinates))||(p=d);p&&l.inside(wt(p))&&(!u||ic(i,c))&&(u=l)}}),u}inside(t){return Ct(t,this.toPolygon())}};function Ix(n){if(!n)throw new Error("No geojson passed");if(n.type!=="FeatureCollection"&&n.type!=="GeometryCollection"&&n.type!=="MultiLineString"&&n.type!=="LineString"&&n.type!=="Feature")throw new Error(`Invalid input type '${n.type}'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature`)}var Ku=class n{static fromGeoJson(t){Ix(t);let e=new n;return le(t,r=>{ni(r,"LineString","Graph::fromGeoJson"),xs(r,(i,u)=>{if(i){let l=e.getNode(i),c=e.getNode(u);e.addEdge(l,c)}return u})}),e}getNode(t){let e=Jo.buildId(t),r=this.nodes[e];return r||(r=this.nodes[e]=new Jo(t)),r}addEdge(t,e){let r=new ju(t,e),i=r.getSymetric();this.edges.push(r),this.edges.push(i)}constructor(){this.edges=[],this.nodes={}}deleteDangles(){Object.keys(this.nodes).map(t=>this.nodes[t]).forEach(t=>this._removeIfDangle(t))}_removeIfDangle(t){if(t.innerEdges.length<=1){let e=t.getOuterEdges().map(r=>r.to);this.removeNode(t),e.forEach(r=>this._removeIfDangle(r))}}deleteCutEdges(){this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(t=>{t.label===t.symetric.label&&(this.removeEdge(t.symetric),this.removeEdge(t))})}_computeNextCWEdges(t){typeof t=="undefined"?Object.keys(this.nodes).forEach(e=>this._computeNextCWEdges(this.nodes[e])):t.getOuterEdges().forEach((e,r)=>{t.getOuterEdge((r===0?t.getOuterEdges().length:r)-1).symetric.next=e})}_computeNextCCWEdges(t,e){let r=t.getOuterEdges(),i,u;for(let l=r.length-1;l>=0;--l){let c=r[l],h=c.symetric,p,d;c.label===e&&(p=c),h.label===e&&(d=h),!(!p||!d)&&(d&&(u=d),p&&(u&&(u.next=p,u=void 0),i||(i=p)))}u&&(u.next=i)}_findLabeledEdgeRings(){let t=[],e=0;return this.edges.forEach(r=>{if(r.label>=0)return;t.push(r);let i=r;do i.label=e,i=i.next;while(!r.isEqual(i));e++}),t}getEdgeRings(){this._computeNextCWEdges(),this.edges.forEach(e=>{e.label=void 0}),this._findLabeledEdgeRings().forEach(e=>{this._findIntersectionNodes(e).forEach(r=>{this._computeNextCCWEdges(r,e.label)})});let t=[];return this.edges.forEach(e=>{e.ring||t.push(this._findEdgeRing(e))}),t}_findIntersectionNodes(t){let e=[],r=t;do{let i=0;r.from.getOuterEdges().forEach(u=>{u.label===t.label&&++i}),i>1&&e.push(r.from),r=r.next}while(!t.isEqual(r));return e}_findEdgeRing(t){let e=t,r=new Wi;do r.push(e),e.ring=r,e=e.next;while(!t.isEqual(e));return r}removeNode(t){t.getOuterEdges().forEach(e=>this.removeEdge(e)),t.innerEdges.forEach(e=>this.removeEdge(e)),delete this.nodes[t.id]}removeEdge(t){this.edges=this.edges.filter(e=>!e.isEqual(t)),t.deleteEdge()}};function jp(n){let t=Ku.fromGeoJson(n);t.deleteDangles(),t.deleteCutEdges();let e=[],r=[];return t.getEdgeRings().filter(i=>i.isValid()).forEach(i=>{i.isHole()?e.push(i):r.push(i)}),e.forEach(i=>{Wi.findEdgeRingContaining(i,r)&&r.push(i)}),pt(r.map(i=>i.toPolygon()))}function Kp(n,t){t=t||{},t.iterations=t.iterations||1;let{iterations:e}=t,r=[];if(!n)throw new Error("inputPolys is required");return ve(n,function(i,u,l){if(i.type==="Polygon"){let c=[[]];for(let h=0;h0&&(d=Mt(c).geometry),Lx(d,p),c=p.slice(0)}r.push(Mt(c,l))}else if(i.type==="MultiPolygon"){let c=[[[]]];for(let h=0;h0&&(d=He(c).geometry),Mx(d,p),c=p.slice(0)}r.push(He(c,l))}else throw new Error("geometry is invalid, must be Polygon or MultiPolygon")}),pt(r)}function Lx(n,t){var e,r;ne(n,function(i,u,l,c,h){if(r!==h)t.push([]);else{var p=e[0],d=e[1],y=i[0],v=i[1];t[h].push([.75*p+.25*y,.75*d+.25*v]),t[h].push([.25*p+.75*y,.25*d+.75*v])}e=i,r=h},!1),t.forEach(function(i){i.push(i[0])})}function Mx(n,t){let e,r,i;ne(n,function(u,l,c,h,p){if(r!==h)t.push([[]]);else if(i!==p)t[h].push([]);else{var d=e[0],y=e[1],v=u[0],_=u[1];t[h][p].push([.75*d+.25*v,.75*y+.25*_]),t[h][p].push([.25*d+.75*v,.25*y+.75*_])}e=u,r=h,i=p},!1),t.forEach(function(u){u.forEach(function(l){l.push(l[0])})})}function Qp(n,t){let e=Lt(n),r=Lt(t),i=[],u=[],l,c=jt(t),h=0,p=null;switch(e[0]>c[0]&&e[0]c[1]&&e[1]0?Nx(t,l,r)||(r=l):e>0&&h<=0&&(Cx(t,l,i)||(i=l)),e=h}return[r,i]}function Cx(n,t,e){return Vo(n,t,e)>0}function Nx(n,t,e){return Vo(n,t,e)<0}function Vo(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}var $u={};Tr($u,{toMercator:()=>nm,toWgs84:()=>rm});function nm(n,t={}){return im(n,"mercator",t)}function rm(n,t={}){return im(n,"wgs84",t)}function im(n,t,e={}){e=e||{};var r=e.mutate;if(!n)throw new Error("geojson is required");return Array.isArray(n)&&ye(n[0])?n=t==="mercator"?tm(n):em(n):(r!==!0&&(n=se(n)),ne(n,function(i){var u=t==="mercator"?tm(i):em(i);i[0]=u[0],i[1]=u[1]})),n}function tm(n){var t=Math.PI/180,e=6378137,r=20037508342789244e-9,i=Math.abs(n[0])<=180?n[0]:n[0]-Tx(n[0])*360,u=[e*i*t,e*Math.log(Math.tan(Math.PI*.25+.5*n[1]*t))];return u[0]>r&&(u[0]=r),u[0]<-r&&(u[0]=-r),u[1]>r&&(u[1]=r),u[1]<-r&&(u[1]=-r),u}function em(n){var t=180/Math.PI,e=6378137;return[n[0]*t/e,(Math.PI*.5-2*Math.atan(Math.exp(-n[1]/e)))*t]}function Tx(n){return n<0?-1:n>0?1:0}function Ox(n,t){t=t||{};let e=t.studyBbox||jt(n),r=t.confidenceLevel||20,i=n.features,u=i.length,l=ir(or(e)),c=Math.sqrt(l/u*2),p=Vi(e,c,{units:"meters"}).features,d={};for(let J=0;Jv&&(v=k)}let _=[],I=Object.keys(d).length,F=y/I,M=0;for(let J=0;Jq&&(q=k)}let X=Rx[r]/Math.sqrt(I),G={criticalValue:X,isRandom:!0,maxAbsoluteDifference:q,observedDistribution:L};return q>X&&(G.isRandom=!1),G}var Rx={20:1.07275,15:1.13795,10:1.22385,5:1.3581,2:1.51743,1:1.62762};function Ax(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}function Fx(n){let t=[];function e(r){return r===0||r===1?1:t[r]>0?t[r]:t[r]=e(r-1)*r}return e(n)}var ea={};Tr(ea,{randomLineString:()=>lm,randomPoint:()=>um,randomPolygon:()=>am,randomPosition:()=>sm});function sm(n){return ta(n),Qu(n)}function Qu(n){return Array.isArray(n)?om(n):n&&n.bbox?om(n.bbox):[Gx(),Bx()]}function ta(n){n!=null&&(Array.isArray(n)?ei(n):n.bbox!=null&&ei(n.bbox))}function um(n,t={}){ta(t.bbox),n==null&&(n=1);let e=[];for(let r=0;ri)throw new Error("max_radial_length is greater than the radius of the bbox");let u=[t.bbox[0]+t.max_radial_length,t.bbox[1]+t.max_radial_length,t.bbox[2]-t.max_radial_length,t.bbox[3]-t.max_radial_length],l=[];for(let c=0;c{v[y]=y>0?d+v[y-1]:d}),p.forEach(d=>{d=d*2*Math.PI/p[p.length-1];let y=Math.random();h.push([y*(t.max_radial_length||10)*Math.sin(d),y*(t.max_radial_length||10)*Math.cos(d)])}),h[h.length-1]=h[0],h=h.reverse().map(Dx(Qu(u))),l.push(Mt([h]))}return pt(l)}function lm(n,t={}){if(t=t||{},!Ft(t))throw new Error("options is invalid");let e=t.bbox;ta(e);let r=t.num_vertices,i=t.max_length,u=t.max_rotation;n==null&&(n=1),(!ye(r)||r===void 0||r<2)&&(r=10),(!ye(i)||i===void 0)&&(i=1e-4),(!ye(u)||u===void 0)&&(u=Math.PI/8);let l=[];for(let c=0;c[t[0]+n[0],t[1]+n[1]]}function cm(){return Math.random()-.5}function Gx(){return cm()*360}function Bx(){return cm()*180}function om(n){return[Math.random()*(n[2]-n[0])+n[0],Math.random()*(n[3]-n[1])+n[1]]}function gm(n,t={}){var u,l;if(t=t||{},!Ft(t))throw new Error("options is invalid");let e=(u=t.mutate)!=null?u:!1,r=(l=t.reverse)!=null?l:!1;if(!n)throw new Error(" is required");if(typeof r!="boolean")throw new Error(" must be a boolean");if(typeof e!="boolean")throw new Error(" must be a boolean");!e&&n.type!=="Point"&&n.type!=="MultiPoint"&&(n=se(n));let i=[];switch(n.type){case"GeometryCollection":return ve(n,function(c){na(c,r)}),n;case"FeatureCollection":return Dt(n,function(c){let h=na(c,r);Dt(h,function(p){i.push(p)})}),pt(i)}return na(n,r)}function na(n,t){switch(n.type==="Feature"?n.geometry.type:n.type){case"GeometryCollection":return ve(n,function(r){na(r,t)}),n;case"LineString":return fm(Lt(n),t),n;case"Polygon":return hm(Lt(n),t),n;case"MultiLineString":return Lt(n).forEach(function(r){fm(r,t)}),n;case"MultiPolygon":return Lt(n).forEach(function(r){hm(r,t)}),n;case"Point":case"MultiPoint":return n}}function fm(n,t){Ii(n)===t&&n.reverse()}function hm(n,t){Ii(n[0])!==t&&n[0].reverse();for(let e=1;ei;)l=Math.floor((r+1)*Math.random()),u=e[l],e[l]=e[r],e[r]=u;return e.slice(i)}function dm(n,t,e,r,i={}){if(i=i||{},!Ft(i))throw new Error("options is invalid");let u=i.properties;if(!n)throw new Error("center is required");if(e==null)throw new Error("bearing1 is required");if(r==null)throw new Error("bearing2 is required");if(!t)throw new Error("radius is required");if(typeof i!="object")throw new Error("options must be an object");if(mm(e)===mm(r))return Bi(n,t,i);let l=Lt(n),c=Ju(n,t,e,r,i),h=[[l]];return ne(c,function(p){h[0].push(p)}),h[0].push(l),Mt(h,u)}function mm(n){let t=n%360;return t<0&&(t+=360),t}function ra(n,t,e){if(e=e||{},!Ft(e))throw new Error("options is invalid");let r=e.origin||"centroid",i=e.mutate||!1;if(!n)throw new Error("geojson required");if(typeof t!="number"||t<=0)throw new Error("invalid factor");let u=Array.isArray(r)||typeof r=="object";return i!==!0&&(n=se(n)),n.type==="FeatureCollection"&&!u?(Dt(n,function(l,c){n.features[c]=ym(l,t,r)}),n):ym(n,t,r)}function ym(n,t,e){let r=be(n)==="Point",i=zx(n,e);return t===1||r||(ne(n,function(u){let l=hr(i,u),c=On(i,u),h=l*t,p=Lt(Ur(i,h,c));u[0]=p[0],u[1]=p[1],u.length===3&&(u[2]*=t)}),delete n.bbox),n}function zx(n,t){if(t==null&&(t="centroid"),Array.isArray(t)||typeof t=="object")return Ut(t);let e=n.bbox?n.bbox:jt(n,{recompute:!0}),r=e[0],i=e[1],u=e[2],l=e[3];switch(t){case"sw":case"southwest":case"westsouth":case"bottomleft":return wt([r,i]);case"se":case"southeast":case"eastsouth":case"bottomright":return wt([u,i]);case"nw":case"northwest":case"westnorth":case"topleft":return wt([r,l]);case"ne":case"northeast":case"eastnorth":case"topright":return wt([u,l]);case"center":return Ar(n);case void 0:case null:case"centroid":return We(n);default:throw new Error("invalid origin")}}function vm(n){for(var t=n,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function Xx(){return new sc(function(n){return n.f})}var Ho={search:function(n,t,e,r={}){var F;n.cleanDirty(),r=r||{};var i=Ho.heuristics.manhattan,u=(F=r.closest)!=null?F:!1,l=Xx(),c=t;for(t.h=i(t,e),l.push(t);l.size()>0;){var h=l.pop();if(h===e)return vm(h);h.closed=!0;for(var p=n.neighbors(h),d=0,y=p.length;d0&&(this.content[0]=e,this.bubbleUp(0)),t}remove(t){var e=this.content.indexOf(t),r=this.content.pop();e!==this.content.length-1&&(this.content[e]=r,this.scoreFunction(r)0;){var r=(t+1>>1)-1,i=this.content[r];if(this.scoreFunction(e)=d;){let x=[],b=[],E=p+L,A=0;for(;E<=y;){let z=wt([E,N]),W=Ux(z,r);x.push(W?0:1),b.push(E+"|"+N);let j=$t(z,n);!W&&j1?(r=e[0],i=e[1]):c>0&&(r+=u*c,i+=l*c)}return u=n[0]-r,l=n[1]-i,u*u+l*l}function Vx(n,t){for(var e=n[0],r=[e],i,u=1,l=n.length;ut&&(r.push(i),e=i);return e!==i&&r.push(i),r}function uc(n,t,e,r,i){for(var u=r,l,c=t+1;cu&&(l=c,u=h)}u>r&&(l-t>1&&uc(n,t,l,r,i),i.push(n[l]),e-l>1&&uc(n,l,e,r,i))}function Hx(n,t){var e=n.length-1,r=[n[0]];return uc(n,0,e,t,r),r.push(n[e]),r}function Zo(n,t,e){if(n.length<=2)return n;var r=t!==void 0?t*t:1;return n=e?n:Vx(n,r),n=Hx(n,r),n}function bm(n,t={}){var u,l,c;if(t=t!=null?t:{},!Ft(t))throw new Error("options is invalid");let e=(u=t.tolerance)!=null?u:1,r=(l=t.highQuality)!=null?l:!1,i=(c=t.mutate)!=null?c:!1;if(!n)throw new Error("geojson is required");if(e&&e<0)throw new Error("invalid tolerance");return i!==!0&&(n=se(n)),ve(n,function(h){Zx(h,e,r)}),n}function Zx(n,t,e){let r=n.type;if(r==="Point"||r==="MultiPoint")return n;if(An(n,{mutate:!0}),r!=="GeometryCollection")switch(r){case"LineString":n.coordinates=Zo(n.coordinates,t,e);break;case"MultiLineString":n.coordinates=n.coordinates.map(i=>Zo(i,t,e));break;case"Polygon":n.coordinates=_m(n.coordinates,t,e);break;case"MultiPolygon":n.coordinates=n.coordinates.map(i=>_m(i,t,e))}return n}function _m(n,t,e){return n.map(function(r){if(r.length<4)throw new Error("invalid polygon");let i=t,u=Zo(r,i,e);for(;!Pm(u)&&i>=Number.EPSILON;)i-=i*.01,u=Zo(r,i,e);return Pm(u)?((u[u.length-1][0]!==u[0][0]||u[u.length-1][1]!==u[0][1])&&u.push(u[0]),u):r})}function Pm(n){return n.length<3?!1:!(n.length===3&&n[2][0]===n[0][0]&&n[2][1]===n[0][1])}function Em(n){var t=n[0],e=n[1],r=n[2],i=n[3],u=$t(n.slice(0,2),[r,e]),l=$t(n.slice(0,2),[t,i]);if(u>=l){var c=(e+i)/2;return[t,c-(r-t)/2,r,c+(r-t)/2]}else{var h=(t+r)/2;return[h-(i-e)/2,e,h+(i-e)/2,i]}}function Sm(n,t){var J;if(t=t||{},!Ft(t))throw new Error("options is invalid");let e=t.steps||64,r=t.weight,i=t.properties||{};if(!ye(e))throw new Error("steps must be a number");if(!Ft(i))throw new Error("properties must be a number");let u=ri(n).length,l=Di(n,{weight:r}),c=0,h=0,p=0;Dt(n,function(k){var D;let N=r&&((D=k.properties)==null?void 0:D[r])||1,T=wm(Lt(k),Lt(l));c+=Math.pow(T.x,2)*N,h+=Math.pow(T.y,2)*N,p+=T.x*T.y*N});let d=c-h,y=Math.sqrt(Math.pow(d,2)+4*Math.pow(p,2)),v=2*p,_=Math.atan((d+y)/v),I=_*180/Math.PI,F=0,M=0,L=0;Dt(n,function(k){var D;let N=r&&((D=k.properties)==null?void 0:D[r])||1,T=wm(Lt(k),Lt(l));F+=Math.pow(T.x*Math.cos(_)-T.y*Math.sin(_),2)*N,M+=Math.pow(T.x*Math.sin(_)+T.y*Math.cos(_),2)*N,L+=N});let C=Math.sqrt(2*F/L),q=Math.sqrt(2*M/L),V=Ru(l,C,q,{units:"degrees",angle:I,steps:e,properties:i}),X=Zu(n,pt([V])),G={meanCenterCoordinates:Lt(l),semiMajorAxis:C,semiMinorAxis:q,numberOfFeatures:u,angle:I,percentageWithinEllipse:100*ri(X).length/u};return V.properties=(J=V.properties)!=null?J:{},V.properties.standardDeviationalEllipse=G,V}function wm(n,t){return{x:n[0]-t[0],y:n[1]-t[1]}}function km(n,t,e,r){return n=se(n),t=se(t),Dt(n,function(i){i.properties||(i.properties={}),Dt(t,function(u){i.properties&&u.properties&&i.properties[r]===void 0&&Ct(i,u)&&(i.properties[r]=u.properties[e])})}),n}var Om=Jn(Nm());function Rm(n){if(!n.geometry||n.geometry.type!=="Polygon"&&n.geometry.type!=="MultiPolygon")throw new Error("input must be a Polygon or MultiPolygon");let t={type:"FeatureCollection",features:[]};return n.geometry.type==="Polygon"?t.features=Tm(n.geometry.coordinates):n.geometry.coordinates.forEach(function(e){t.features=t.features.concat(Tm(e))}),t}function Tm(n){let t=c1(n),e=3,r=(0,Om.default)(t.vertices,t.holes,e),i=[],u=[];r.forEach(function(c,h){let p=r[h];t.vertices[p*e+2]!==void 0?u.push([t.vertices[p*e],t.vertices[p*e+1],t.vertices[p*e+2]]):u.push([t.vertices[p*e],t.vertices[p*e+1]])});for(var l=0;l0&&(r+=n[i-1].length,e.holes.push(r))}return e}function Am(n,t,e,r){if(r=r||{},!Ft(r))throw new Error("options is invalid");var i=r.units,u=r.zTranslation,l=r.mutate;if(!n)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("distance is required");if(u&&typeof u!="number"&&isNaN(u))throw new Error("zTranslation is not a number");if(u=u!==void 0?u:0,t===0&&u===0)return n;if(e==null||isNaN(e))throw new Error("direction is required");return t<0&&(t=-t,e=e+180),(l===!1||l===void 0)&&(n=se(n)),ne(n,function(c){var h=Lt(Ur(c,t,e,{units:i}));c[0]=h[0],c[1]=h[1],u&&c.length===3&&(c[2]+=u)}),n}var Gm=8;function hc(n){let t=[];for(let e of n)for(let r of la(e))t.push(r);return t}function la(n){let t=[];for(let[e,r]of n.entries()){let i=e===0?f1(Fm(r)):h1(Fm(r));t.push(i)}return t}function f1(n){return wr(n)<0?n.reverse():n}function h1(n){return wr(n)>0?[...n].reverse():n}function Fm(n){return n.map(([t,e])=>({x:t,y:e}))}function Bm(n){let t=[];for(let e=0;e0&&e.push(r);for(let i=0;i0&&e.push(l)}t.push(e)}for(let e=0;e0&&t){let r=e[0],i=e[e.length-1];(r[0]!==i[0]||r[1]!==i[1])&&e.push([r[0],r[1]])}return e}function zm(n,t={}){if(n.features.length<2)throw new Error("Must have at least 2 features");let e=new Dn(Gm);ve(n,(u,l)=>{u.type==="MultiPolygon"?l===0?e.addSubjectPaths(hc(u.coordinates)):e.addClipPaths(hc(u.coordinates)):l===0?e.addSubjectPaths(la(u.coordinates)):e.addClipPaths(la(u.coordinates))});let r=new Pr;e.execute(ie.Union,ee.NonZero,r);let i=Bm(r);return i===null?null:te(i,t.properties)}var Xm=Jn(Li(),1);function Um(n,t){if(n.geometry.type!=="Polygon")throw new Error("The input feature must be a Polygon");for(var e=n.geometry.coordinates,r=[],i={},u=[],l=0;l=1||J<=0||k>=1||k<=0)){var N=G,T=!i[N.toString()];T&&(i[N.toString()]=!0),t&&r.push(t(G,I,F,C,q,J,M,L,V,X,k,T))}}}function _(I,F){var M=e[I][F],L=e[I][F+1],C,q,V,X;return M[0]p[tt.isect].coord?-1:1});for(var G=[];M.length>0;){var J=M.pop(),k=J.isect,N=J.parent,T=J.winding,D=G.length,B=[p[k].coord],K=k;if(p[k].ringAndEdge1Walkable)var w=p[k].ringAndEdge1,R=p[k].nxtIsectAlongRingAndEdge1;else var w=p[k].ringAndEdge2,R=p[k].nxtIsectAlongRingAndEdge2;for(;!Qo(p[k].coord,p[R].coord);){B.push(p[R].coord);for(var x=void 0,L=0;L1)for(var ot=0;ot=0==t}function p1(n){for(var t=0,e=0;e0)){if(F/=_,_<0){if(F0){if(F>v)return;F>y&&(y=F)}if(F=r-c,!(!_&&F<0)){if(F/=_,_<0){if(F>v)return;F>y&&(y=F)}else if(_>0){if(F0)){if(F/=I,I<0){if(F0){if(F>v)return;F>y&&(y=F)}if(F=i-h,!(!I&&F<0)){if(F/=I,I<0){if(F>v)return;F>y&&(y=F)}else if(I>0){if(F0)&&!(v<1)||(y>0&&(n[0]=[c+y*_,h+y*I]),v<1&&(n[1]=[c+v*_,h+v*I])),!0}}}}}function y1(n,t,e,r,i){var u=n[1];if(u)return!0;var l=n[0],c=n.left,h=n.right,p=c[0],d=c[1],y=h[0],v=h[1],_=(p+y)/2,I=(d+v)/2,F,M;if(v===d){if(_=r)return;if(p>y){if(!l)l=[_,e];else if(l[1]>=i)return;u=[_,i]}else{if(!l)l=[_,i];else if(l[1]1)if(p>y){if(!l)l=[(e-M)/F,e];else if(l[1]>=i)return;u=[(i-M)/F,i]}else{if(!l)l=[(i-M)/F,i];else if(l[1]=r)return;u=[r,F*r+M]}else{if(!l)l=[r,F*r+M];else if(l[0]fe||Math.abs(u[0][1]-u[1][1])>fe))&&delete Ye[i]}function Km(n){return hn[n.index]={site:n,halfedges:[]}}function v1(n,t){var e=n.site,r=t.left,i=t.right;return e===i&&(i=r,r=e),i?Math.atan2(i[1]-r[1],i[0]-r[0]):(e===r?(r=t[1],i=t[0]):(r=t[0],i=t[1]),Math.atan2(r[0]-i[0],i[1]-r[1]))}function dc(n,t){return t[+(t.left!==n.site)]}function x1(n,t){return t[+(t.left===n.site)]}function $m(){for(var n=0,t=hn.length,e,r,i,u;nfe||Math.abs(M-_)>fe)&&(p.splice(h,0,Ye.push(to(c,I,Math.abs(F-n)fe?[n,Math.abs(v-n)fe?[Math.abs(_-r)fe?[e,Math.abs(v-e)fe?[Math.abs(_-t)=-ed)){var _=h*h+p*p,I=d*d+y*y,F=(y*_-p*I)/v,M=(h*I-d*_)/v,L=td.pop()||new _1;L.arc=n,L.site=i,L.x=F+l,L.y=(L.cy=M+c)+Math.sqrt(F*F+M*M),n.circle=L;for(var C=null,q=eo._;q;)if(L.yfe)c=c.L;else if(l=t-b1(c,e),l>fe){if(!c.R){r=c;break}c=c.R}else{u>-fe?(r=c.P,i=c):l>-fe?(r=c,i=c.N):r=i=c;break}Km(n);var h=nd(n);if(mi.insert(r,h),!(!r&&!i)){if(r===i){pi(r),i=nd(r.site),mi.insert(h,i),h.edge=i.edge=Qi(r.site,h.site),gi(r),gi(i);return}if(!i){h.edge=Qi(r.site,h.site);return}pi(r),pi(i);var p=r.site,d=p[0],y=p[1],v=n[0]-d,_=n[1]-y,I=i.site,F=I[0]-d,M=I[1]-y,L=2*(v*M-_*F),C=v*v+_*_,q=F*F+M*M,V=[(M*C-_*q)/L+d,(v*q-F*C)/L+y];ns(i.edge,p,I,V),h.edge=Qi(p,n,null,V),i.edge=Qi(n,I,null,V),gi(r),gi(i)}}function sd(n,t){var e=n.site,r=e[0],i=e[1],u=i-t;if(!u)return r;var l=n.P;if(!l)return-1/0;e=l.site;var c=e[0],h=e[1],p=h-t;if(!p)return c;var d=c-r,y=1/u-1/p,v=d/p;return y?(-v+Math.sqrt(v*v-2*y*(d*d/(-2*p)-h+p/2+i-u/2)))/y+r:(r+c)/2}function b1(n,t){var e=n.N;if(e)return sd(e,t);var r=n.site;return r[1]===t?r[0]:1/0}var fe=1e-6,ed=1e-12,mi,hn,eo,Ye;function E1(n,t,e){return(n[0]-e[0])*(t[1]-n[1])-(n[0]-t[0])*(e[1]-n[1])}function w1(n,t){return t[1]-n[1]||t[0]-n[0]}function rs(n,t){var e=n.sort(w1).pop(),r,i,u;for(Ye=[],hn=new Array(n.length),mi=new mc,eo=new mc;;)if(u=ga,e&&(!u||e[1]=l)return null;var h=n-c.site[0],p=t-c.site[1],d=h*h+p*p;do c=r.cells[i=u],u=null,c.halfedges.forEach(function(y){var v=r.edges[y],_=v.left;if(!((_===c.site||!_)&&!(_=v.right))){var I=n-_[0],F=t-_[1],M=I*I+F*F;Mr.geometry.coordinates[0]).y(r=>r.geometry.coordinates[1]).extent([[e[0],e[1]],[e[2],e[3]]]).polygons(n.features).map(function(r,i){return Object.assign(k1(r),{properties:So(n.features[i].properties)})}))}return ly(I1);})(); //# sourceMappingURL=turf.min.js.map