leaflet-polydraw 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/leaflet-polydraw.css +1 -1
- package/dist/polydraw.es.js +1035 -655
- package/dist/polydraw.es.js.map +1 -1
- package/dist/polydraw.umd.min.js +1 -1
- package/dist/polydraw.umd.min.js.map +1 -1
- package/dist/styles/polydraw.css +58 -0
- package/dist/types/constants.d.ts +67 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/geojson-helpers.d.ts +92 -0
- package/dist/types/geojson-helpers.d.ts.map +1 -0
- package/dist/types/managers/polygon-draw-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-interaction-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-mutation-manager.d.ts +15 -0
- package/dist/types/managers/polygon-mutation-manager.d.ts.map +1 -1
- package/dist/types/polydraw.d.ts +5 -0
- package/dist/types/polydraw.d.ts.map +1 -1
- package/dist/types/polygon.util.d.ts.map +1 -1
- package/dist/types/turf-helper.d.ts +11 -2
- package/dist/types/turf-helper.d.ts.map +1 -1
- package/dist/types/types/polydraw-interfaces.d.ts +1 -0
- package/dist/types/types/polydraw-interfaces.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +11 -15
package/dist/polydraw.umd.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).LeafletPolydraw=e(t.L)}(this,function(t){"use strict";var e,n,i=Object.defineProperty,r=(t,e,n)=>((t,e,n)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);function o(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}return e.default=t,Object.freeze(e)}const s=o(t),a={mergePolygons:!0,kinks:!1,modes:{draw:!0,subtract:!0,deleteAll:!0,p2p:!0,attachElbow:!0,dragElbow:!0,dragPolygons:!0,edgeDeletion:!0},dragPolygons:{opacity:.7,dragCursor:"move",hoverCursor:"grab",markerBehavior:"hide",markerAnimationDuration:200,modifierSubtract:{keys:{windows:"ctrlKey",mac:"metaKey",linux:"ctrlKey"},hideMarkersOnDrag:!0}},edgeDeletion:{keys:{windows:"ctrlKey",mac:"metaKey",linux:"ctrlKey"},minVertices:3},markers:{deleteMarker:!0,infoMarker:!0,menuMarker:!0,coordsTitle:!0,zIndexOffset:0,markerIcon:{styleClasses:["polygon-marker"],zIndexOffset:null},holeIcon:{styleClasses:["polygon-marker","hole"],zIndexOffset:null},markerInfoIcon:{position:3,showArea:!0,showPerimeter:!0,useMetrics:!0,usePerimeterMinValue:!1,areaLabel:"Area",perimeterLabel:"Perimeter",values:{min:{metric:"50",imperial:"100"},unknown:{metric:"-",imperial:"-"}},units:{unknownUnit:"",metric:{onlyMetrics:!0,perimeter:{m:"m",km:"km"},area:{m2:"m²",km2:"km²",daa:"daa",ha:"ha"}},imperial:{perimeter:{feet:"ft",yards:"yd",miles:"mi"},area:{feet2:"ft²",yards2:"yd²",acres:"ac",miles2:"mi²"}}},styleClasses:["polygon-marker","info"],zIndexOffset:1e4},markerMenuIcon:{position:7,styleClasses:["polygon-marker","menu"],zIndexOffset:1e4},markerDeleteIcon:{position:5,styleClasses:["polygon-marker","delete"],zIndexOffset:1e4},holeMarkers:{menuMarker:!1,deleteMarker:!0,infoMarker:!1},visualOptimization:{sharpAngleThreshold:30,thresholdBoundingBox:.05,thresholdDistance:.05,useDistance:!0,useBoundingBox:!1,useAngles:!1}},polyLineOptions:{opacity:1,smoothFactor:0,noClip:!0,clickable:!1,weight:2},subtractLineOptions:{opacity:1,smoothFactor:0,noClip:!0,clickable:!1,weight:2},polygonOptions:{smoothFactor:.3,noClip:!0},holeOptions:{weight:2,opacity:1,fillOpacity:.5},polygonCreation:{method:"concaveman",simplification:{mode:"simple",tolerance:1e-5,highQuality:!1}},simplification:{simplifyTolerance:{tolerance:1e-4,highQuality:!1,mutate:!1},dynamicMode:{fractionGuard:.9,multipiler:2}},menuOperations:{simplify:{processHoles:!0},doubleElbows:{processHoles:!0},bbox:{processHoles:!0}},boundingBox:{addMidPointMarkers:!0},bezier:{resolution:1e4,sharpness:.75},colors:{dragPolygons:{subtract:"#D9460F"},p2p:{closingMarker:"#4CAF50"},edgeHover:"#7a9441",edgeDeletion:{hover:"#D9460F"},polyline:"#50622b",subtractLine:"#50622b",polygon:{border:"#50622b",fill:"#b4cd8a"},hole:{border:"#aa0000",fill:"#ffcccc"},styles:{controlButton:{backgroundColor:"#fff",color:"#000"},controlButtonHover:{backgroundColor:"#f4f4f4"},controlButtonActive:{backgroundColor:"rgb(128, 218, 255)",color:"#fff"},indicatorActive:{backgroundColor:"#ffcc00"},p2pMarker:{backgroundColor:"#fff",borderColor:"#50622b"}}}};var l=(t=>(t[t.Off=0]="Off",t[t.Add=1]="Add",t[t.Edit=2]="Edit",t[t.Subtract=4]="Subtract",t[t.AppendMarker=8]="AppendMarker",t[t.LoadPredefined=16]="LoadPredefined",t[t.PointToPoint=32]="PointToPoint",t))(l||{}),u=(t=>(t[t.SouthWest=0]="SouthWest",t[t.South=1]="South",t[t.SouthEast=2]="SouthEast",t[t.East=3]="East",t[t.NorthEast=4]="NorthEast",t[t.North=5]="North",t[t.NorthWest=6]="NorthWest",t[t.West=7]="West",t[t.Hole=8]="Hole",t))(u||{}),h=6371008.8,c={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*h,kilometers:6371.0088,kilometres:6371.0088,meters:h,metres:h,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:h/1852,radians:1,yards:6967335.223679999};function f(t,e,n={}){const i={type:"Feature"};return(0===n.id||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=e||{},i.geometry=t,i}function g(t,e,n={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!E(t[0])||!E(t[1]))throw new Error("coordinates must contain numbers");return f({type:"Point",coordinates:t},e,n)}function d(t,e,n={}){for(const i of t){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 t=0;t<i[i.length-1].length;t++)if(i[i.length-1][t]!==i[0][t])throw new Error("First and last Position are not equivalent.")}return f({type:"Polygon",coordinates:t},e,n)}function p(t,e,n={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return f({type:"LineString",coordinates:t},e,n)}function y(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function v(t,e,n={}){return f({type:"MultiPolygon",coordinates:t},e,n)}function m(t,e="kilometers"){const n=c[e];if(!n)throw new Error(e+" units is invalid");return t*n}function _(t,e="kilometers"){const n=c[e];if(!n)throw new Error(e+" units is invalid");return t/n}function k(t){return 180*(t%(2*Math.PI))/Math.PI}function x(t){return t%360*Math.PI/180}function E(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function w(t,e,n){if(null!==t)for(var i,r,o,s,a,l,u,h,c=0,f=0,g=t.type,d="FeatureCollection"===g,p="Feature"===g,y=d?t.features.length:1,v=0;v<y;v++){a=(h=!!(u=d?t.features[v].geometry:p?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var m=0;m<a;m++){var _=0,k=0;if(null!==(s=h?u.geometries[m]:u)){l=s.coordinates;var x=s.type;switch(c=!n||"Polygon"!==x&&"MultiPolygon"!==x?0:1,x){case null:break;case"Point":if(!1===e(l,f,v,_,k))return!1;f++,_++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===e(l[i],f,v,_,k))return!1;f++,"MultiPoint"===x&&_++}"LineString"===x&&_++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(r=0;r<l[i].length-c;r++){if(!1===e(l[i][r],f,v,_,k))return!1;f++}"MultiLineString"===x&&_++,"Polygon"===x&&k++}"Polygon"===x&&_++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(k=0,r=0;r<l[i].length;r++){for(o=0;o<l[i][r].length-c;o++){if(!1===e(l[i][r][o],f,v,_,k))return!1;f++}k++}_++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===w(s.geometries[i],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function I(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function M(t,e){var n,i,r,o,s,a,l,u,h,c,f=0,g="FeatureCollection"===t.type,d="Feature"===t.type,p=g?t.features.length:1;for(n=0;n<p;n++){for(a=g?t.features[n].geometry:d?t.geometry:t,u=g?t.features[n].properties:d?t.properties:{},h=g?t.features[n].bbox:d?t.bbox:void 0,c=g?t.features[n].id:d?t.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=l?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,f,u,h,c))return!1;break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===e(o.geometries[i],f,u,h,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,f,u,h,c))return!1;f++}}function b(t,e){M(t,function(t,n,i,r,o){var s,a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==e(f(t,i,{bbox:r,id:o}),n,0)&&void 0}switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<t.coordinates.length;l++){var u=t.coordinates[l];if(!1===e(f({type:s,coordinates:u},i),n,l))return!1}})}function S(t,e,n){var i=n,r=!1;return function(t,e){b(t,function(t,n,i){var r=0;if(t.geometry){var o=t.geometry.type;if("Point"!==o&&"MultiPoint"!==o){var s,a=0,l=0,u=0;return!1!==w(t,function(o,h,c,f,g){if(void 0===s||n>a||f>l||g>u)return s=o,a=n,l=f,u=g,void(r=0);var d=p([s,o],t.properties);if(!1===e(d,n,i,g,r))return!1;r++,s=o})&&void 0}}})}(t,function(t,o,s,a,l){i=!1===r&&void 0===n?t:e(i,t,o,s,a,l),r=!0}),i}function N(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function L(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}),n}var P,C={exports:{}},T={exports:{}};function O(){return P||(P=1,T.exports=function(){function t(t,i,r,o,s){!function t(n,i,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,l=i-r+1,u=Math.log(a),h=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*h*(a-h)/a)*(l-a/2<0?-1:1);t(n,i,Math.max(r,Math.floor(i-l*h/a+c)),Math.min(o,Math.floor(i+(a-l)*h/a+c)),s)}var f=n[i],g=r,d=o;for(e(n,r,i),s(n[o],f)>0&&e(n,r,o);g<d;){for(e(n,g,d),g++,d--;s(n[g],f)<0;)g++;for(;s(n[d],f)>0;)d--}0===s(n[r],f)?e(n,r,d):e(n,++d,o),d<=i&&(r=d+1),i<=d&&(o=d-1)}}(t,i,r||0,o||t.length-1,s||n)}function e(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function n(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function o(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,i,r){r||(r=d(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o=e;o<n;o++){var s=t.children[o];a(r,t.leaf?i(s):s)}return r}function a(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function l(t,e){return t.minX-e.minX}function u(t,e){return t.minY-e.minY}function h(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function c(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function g(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function d(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function p(e,n,i,r,o){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var a=n+Math.ceil((i-n)/r/2)*r;t(e,a,n,i,o),s.push(n,a,a,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!g(t,e))return n;for(var i=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?i(s):s;g(t,a)&&(e.leaf?n.push(s):f(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!g(t,e))return!1;for(var n=[];e;){for(var i=0;i<e.children.length;i++){var r=e.children[i],o=e.leaf?this.toBBox(r):r;if(g(t,o)){if(e.leaf||f(t,o))return!0;n.push(r)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=d([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,i,o,s=this.data,a=this.toBBox(t),l=[],u=[];s||l.length;){if(s||(s=l.pop(),i=l[l.length-1],n=u.pop(),o=!0),s.leaf){var h=r(t,s.children,e);if(-1!==h)return s.children.splice(h,1),l.push(s),this._condense(l),this}o||s.leaf||!f(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(l.push(s),u.push(n),n=0,i=s,s=s.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,i){var r,s=n-e+1,a=this._maxEntries;if(s<=a)return o(r=d(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),(r=d([])).leaf=!1,r.height=i;var l=Math.ceil(s/a),u=l*Math.ceil(Math.sqrt(a));p(t,e,n,u,this.compareMinX);for(var h=e;h<=n;h+=u){var c=Math.min(h+u-1,n);p(t,h,c,l,this.compareMinY);for(var f=h;f<=c;f+=l){var g=Math.min(f+l-1,c);r.children.push(this._build(t,f,g,i-1))}}return o(r,this.toBBox),r},i.prototype._chooseSubtree=function(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){for(var r=1/0,o=1/0,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],u=h(l),c=(f=t,g=l,(Math.max(g.maxX,f.maxX)-Math.min(g.minX,f.minX))*(Math.max(g.maxY,f.maxY)-Math.min(g.minY,f.minY))-u);c<o?(o=c,r=u<r?u:r,s=l):c===o&&u<r&&(r=u,s=l)}e=s||e.children[0]}var f,g;return e},i.prototype._insert=function(t,e,n){var i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),a(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)},i.prototype._split=function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),a=d(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,o(n,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},i.prototype._splitRoot=function(t,e){this.data=d([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var i,r,o,a,l,u,c,f=1/0,g=1/0,d=e;d<=n-e;d++){var p=s(t,0,d,this.toBBox),y=s(t,d,n,this.toBBox),v=(r=p,o=y,a=void 0,l=void 0,u=void 0,c=void 0,a=Math.max(r.minX,o.minX),l=Math.max(r.minY,o.minY),u=Math.min(r.maxX,o.maxX),c=Math.min(r.maxY,o.maxY),Math.max(0,u-a)*Math.max(0,c-l)),m=h(p)+h(y);v<f?(f=v,i=d,g=m<g?m:g):v===f&&m<g&&(g=m,i=d)}return i||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var i=t.leaf?this.compareMinX:l,r=t.leaf?this.compareMinY:u;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},i.prototype._allDistMargin=function(t,e,n,i){t.children.sort(i);for(var r=this.toBBox,o=s(t,0,e,r),l=s(t,n-e,n,r),u=c(o)+c(l),h=e;h<n-e;h++){var f=t.children[h];a(o,t.leaf?r(f):f),u+=c(o)}for(var g=n-e-1;g>=e;g--){var d=t.children[g];a(l,t.leaf?r(d):d),u+=c(l)}return u},i.prototype._adjustParentBBoxes=function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},i}()),T.exports}function A(t,e){return t<e?-1:t>e?1:0}const D=Object.freeze(Object.defineProperty({__proto__:null,default:class{constructor(t=[],e=A){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const 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){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}},Symbol.toStringTag,{value:"Module"})),R=L(D);var F,G,B,Y,q,z={exports:{}};function H(){if(q)return z.exports;q=1;var t=G?F:(G=1,F=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=(i-n)/2,l=0,u=a-1;l<a;u=l++){var h=e[n+2*l+0],c=e[n+2*l+1],f=e[n+2*u+0],g=e[n+2*u+1];c>o!=g>o&&r<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s}),e=Y?B:(Y=1,B=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=i-n,l=0,u=a-1;l<a;u=l++){var h=e[l+n][0],c=e[l+n][1],f=e[u+n][0],g=e[u+n][1];c>o!=g>o&&r<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s});return z.exports=function(n,i,r,o){return i.length>0&&Array.isArray(i[0])?e(n,i,r,o):t(n,i,r,o)},z.exports.nested=e,z.exports.flat=t,z.exports}var U,X,V={exports:{}};function j(){return U||(U=1,function(t){const e=134217729,n=33306690738754706e-32;function i(t,e,n,i,r){let o,s,a,l,u=e[0],h=i[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=i[++f]);let g=0;if(c<t&&f<n)for(h>u==h>-u?(a=o-((s=u+o)-u),u=e[++c]):(a=o-((s=h+o)-h),h=i[++f]),o=s,0!==a&&(r[g++]=a);c<t&&f<n;)h>u==h>-u?(a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++c]):(a=o-((s=o+h)-(l=s-o))+(h-l),h=i[++f]),o=s,0!==a&&(r[g++]=a);for(;c<t;)a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++c],o=s,0!==a&&(r[g++]=a);for(;f<n;)a=o-((s=o+h)-(l=s-o))+(h-l),h=i[++f],o=s,0!==a&&(r[g++]=a);return 0===o&&0!==g||(r[g++]=o),g}function r(t){return new Float64Array(t)}const o=33306690738754716e-32,s=22204460492503146e-32,a=11093356479670487e-47,l=r(4),u=r(8),h=r(12),c=r(16),f=r(4);t.orient2d=function(t,r,g,d,p,y){const v=(r-y)*(g-p),m=(t-p)*(d-y),_=v-m;if(0===v||0===m||v>0!=m>0)return _;const k=Math.abs(v+m);return Math.abs(_)>=o*k?_:-function(t,r,o,g,d,p,y){let v,m,_,k,x,E,w,I,M,b,S,N,L,P,C,T,O,A;const D=t-d,R=o-d,F=r-p,G=g-p;x=(C=(I=D-(w=(E=e*D)-(E-D)))*(b=G-(M=(E=e*G)-(E-G)))-((P=D*G)-w*M-I*M-w*b))-(S=C-(O=(I=F-(w=(E=e*F)-(E-F)))*(b=R-(M=(E=e*R)-(E-R)))-((T=F*R)-w*M-I*M-w*b))),l[0]=C-(S+x)+(x-O),x=(L=P-((N=P+S)-(x=N-P))+(S-x))-(S=L-T),l[1]=L-(S+x)+(x-T),x=(A=N+S)-N,l[2]=N-(A-x)+(S-x),l[3]=A;let B=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,l),Y=s*y;if(B>=Y||-B>=Y)return B;if(v=t-(D+(x=t-D))+(x-d),_=o-(R+(x=o-R))+(x-d),m=r-(F+(x=r-F))+(x-p),k=g-(G+(x=g-G))+(x-p),0===v&&0===m&&0===_&&0===k)return B;if(Y=a*y+n*Math.abs(B),(B+=D*k+G*v-(F*_+R*m))>=Y||-B>=Y)return B;x=(C=(I=v-(w=(E=e*v)-(E-v)))*(b=G-(M=(E=e*G)-(E-G)))-((P=v*G)-w*M-I*M-w*b))-(S=C-(O=(I=m-(w=(E=e*m)-(E-m)))*(b=R-(M=(E=e*R)-(E-R)))-((T=m*R)-w*M-I*M-w*b))),f[0]=C-(S+x)+(x-O),x=(L=P-((N=P+S)-(x=N-P))+(S-x))-(S=L-T),f[1]=L-(S+x)+(x-T),x=(A=N+S)-N,f[2]=N-(A-x)+(S-x),f[3]=A;const q=i(4,l,4,f,u);x=(C=(I=D-(w=(E=e*D)-(E-D)))*(b=k-(M=(E=e*k)-(E-k)))-((P=D*k)-w*M-I*M-w*b))-(S=C-(O=(I=F-(w=(E=e*F)-(E-F)))*(b=_-(M=(E=e*_)-(E-_)))-((T=F*_)-w*M-I*M-w*b))),f[0]=C-(S+x)+(x-O),x=(L=P-((N=P+S)-(x=N-P))+(S-x))-(S=L-T),f[1]=L-(S+x)+(x-T),x=(A=N+S)-N,f[2]=N-(A-x)+(S-x),f[3]=A;const z=i(q,u,4,f,h);x=(C=(I=v-(w=(E=e*v)-(E-v)))*(b=k-(M=(E=e*k)-(E-k)))-((P=v*k)-w*M-I*M-w*b))-(S=C-(O=(I=m-(w=(E=e*m)-(E-m)))*(b=_-(M=(E=e*_)-(E-_)))-((T=m*_)-w*M-I*M-w*b))),f[0]=C-(S+x)+(x-O),x=(L=P-((N=P+S)-(x=N-P))+(S-x))-(S=L-T),f[1]=L-(S+x)+(x-T),x=(A=N+S)-N,f[2]=N-(A-x)+(S-x),f[3]=A;const H=i(z,h,4,f,c);return c[H-1]}(t,r,g,d,p,y,k)},t.orient2dfast=function(t,e,n,i,r,o){return(e-o)*(n-r)-(t-r)*(i-o)},Object.defineProperty(t,"__esModule",{value:!0})}(V.exports)),V.exports}const K=N(function(){if(X)return C.exports;X=1;var t=O(),e=R,n=H(),i=j().orient2d;function r(e,i,r){i=Math.max(0,void 0===i?2:i),r=r||0;var s=function(t){for(var e=t[0],i=t[0],r=t[0],o=t[0],s=0;s<t.length;s++){var a=t[s];a[0]<e[0]&&(e=a),a[0]>r[0]&&(r=a),a[1]<i[1]&&(i=a),a[1]>o[1]&&(o=a)}var l=[e,i,r,o],u=l.slice();for(s=0;s<t.length;s++)n(t[s],l)||u.push(t[s]);return function(t){t.sort(v);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&h(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var i=[],r=t.length-1;r>=0;r--){for(;i.length>=2&&h(i[i.length-2],i[i.length-1],t[r])<=0;)i.pop();i.push(t[r])}return i.pop(),e.pop(),e.concat(i)}(u)}(e),a=new t(16);a.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},a.compareMinX=function(t,e){return t[0]-e[0]},a.compareMinY=function(t,e){return t[1]-e[1]},a.load(e);for(var l,u=[],c=0;c<s.length;c++){var p=s[c];a.remove(p),l=g(p,l),u.push(l)}var y=new t(16);for(c=0;c<u.length;c++)y.insert(f(u[c]));for(var m=i*i,_=r*r;u.length;){var k=u.shift(),x=k.p,E=k.next.p,w=d(x,E);if(!(w<_)){var I=w/m;(p=o(a,k.prev.p,x,E,k.next.next.p,I,y))&&Math.min(d(p,x),d(p,E))<=I&&(u.push(k),u.push(g(p,k)),a.remove(p),y.remove(k),y.insert(f(k)),y.insert(f(k.next)))}}k=l;var M=[];do{M.push(k.p),k=k.next}while(k!==l);return M.push(k.p),M}function o(t,n,i,r,o,l,h){for(var c=new e([],s),f=t.data;f;){for(var g=0;g<f.children.length;g++){var d=f.children[g],y=f.leaf?p(d,i,r):a(i,r,d);y>l||c.push({node:d,dist:y})}for(;c.length&&!c.peek().node.children;){var v=c.pop(),m=v.node,_=p(m,n,i),k=p(m,r,o);if(v.dist<_&&v.dist<k&&u(i,m,h)&&u(r,m,h))return m}(f=c.pop())&&(f=f.node)}return null}function s(t,e){return t.dist-e.dist}function a(t,e,n){if(l(t,n)||l(e,n))return 0;var i=y(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=y(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var o=y(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=y(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,o,s)}function l(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function u(t,e,n){for(var i=Math.min(t[0],e[0]),r=Math.min(t[1],e[1]),o=Math.max(t[0],e[0]),s=Math.max(t[1],e[1]),a=n.search({minX:i,minY:r,maxX:o,maxY:s}),l=0;l<a.length;l++)if(c(a[l].p,a[l].next.p,t,e))return!1;return!0}function h(t,e,n){return i(t[0],t[1],e[0],e[1],n[0],n[1])}function c(t,e,n,i){return t!==i&&e!==n&&h(t,e,n)>0!=h(t,e,i)>0&&h(n,i,t)>0!=h(n,i,e)>0}function f(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function g(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function d(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function p(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function y(t,e,n,i,r,o,s,a){var l,u,h,c,f=n-t,g=i-e,d=s-r,p=a-o,y=t-r,v=e-o,m=f*f+g*g,_=f*d+g*p,k=d*d+p*p,x=f*y+g*v,E=d*y+p*v,w=m*k-_*_,I=w,M=w;0===w?(u=0,I=1,c=E,M=k):(c=m*E-_*x,(u=_*E-k*x)<0?(u=0,c=E,M=k):u>I&&(u=I,c=E+_,M=k)),c<0?(c=0,-x<0?u=0:-x>m?u=I:(u=-x,I=m)):c>M&&(c=M,-x+_<0?u=0:-x+_>m?u=I:(u=-x+_,I=m));var b=(1-(h=0===c?0:c/M))*r+h*s-((1-(l=0===u?0:u/I))*t+l*n),S=(1-h)*o+h*a-((1-l)*e+l*i);return b*b+S*S}function v(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}return e.default&&(e=e.default),C.exports=r,C.exports.default=r,C.exports}());function W(t,e={}){e.concavity=e.concavity||1/0;const n=[];if(w(t,t=>{n.push([t[0],t[1]])}),!n.length)return null;const i=K(n,e.concavity);return i.length>3?d([i]):null}var Z=W;function J(t,e={}){let n=0,i=0,r=0;return w(t,function(t){n+=t[0],i+=t[1],r++},!0),g([n/r,i/r],e.properties)}var $=J;function Q(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return[...t.geometry.coordinates];if("Point"===t.type)return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function tt(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function et(t){return"Feature"===t.type?t.geometry:t}function nt(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}var it=function t(e,n={}){switch(nt(e)){case"Point":return g(Q(e),n.properties);case"Polygon":var i=[];w(e,function(t){i.push(t)});var r,o,s,a,l,u,h,c,f=J(e,{properties:n.properties}),d=f.geometry.coordinates,p=0,y=0,v=0,m=i.map(function(t){return[t[0]-d[0],t[1]-d[1]]});for(r=0;r<i.length-1;r++)a=(o=m[r])[0],u=o[1],l=(s=m[r+1])[0],v+=c=a*(h=s[1])-l*u,p+=(a+l)*c,y+=(u+h)*c;if(0===v)return f;var _=1/(6*(.5*v));return g([d[0]+_*p,d[1]+_*y],n.properties);default:var k=W(e);return k?t(k,{properties:n.properties}):J(e,{properties:n.properties})}};class rt{constructor(t=[],e=ot){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const 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){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}function ot(t,e){return t<e?-1:t>e?1:0}function st(t,e){return t.p.x>e.p.x?1:t.p.x<e.p.x?-1:t.p.y!==e.p.y?t.p.y>e.p.y?1:-1:1}function at(t,e){return t.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:t.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:t.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?t.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class lt{constructor(t,e,n,i){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}let ut=0,ht=0,ct=0;function ft(t,e){const n="Feature"===t.type?t.geometry:t;let i=n.coordinates;"Polygon"!==n.type&&"MultiLineString"!==n.type||(i=[i]),"LineString"===n.type&&(i=[[i]]);for(let r=0;r<i.length;r++)for(let t=0;t<i[r].length;t++){let n=i[r][t][0],o=null;ht+=1;for(let s=0;s<i[r][t].length-1;s++){o=i[r][t][s+1];const a=new lt(n,ut,ht,ct),l=new lt(o,ut,ht,ct+1);a.otherEvent=l,l.otherEvent=a,st(a,l)>0?(l.isLeftEndpoint=!0,a.isLeftEndpoint=!1):(a.isLeftEndpoint=!0,l.isLeftEndpoint=!1),e.push(a),e.push(l),n=o,ct+=1}}ut+=1}let gt=class{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}};function dt(t,e){if(null===t||null===e)return!1;if(t.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.rightSweepEvent)||t.leftSweepEvent.isSamePoint(e.leftSweepEvent)||t.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const n=t.leftSweepEvent.p.x,i=t.leftSweepEvent.p.y,r=t.rightSweepEvent.p.x,o=t.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,l=e.rightSweepEvent.p.x,u=e.rightSweepEvent.p.y,h=(u-a)*(r-n)-(l-s)*(o-i),c=(l-s)*(i-a)-(u-a)*(n-s),f=(r-n)*(i-a)-(o-i)*(n-s);if(0===h)return!1;const g=c/h,d=f/h;if(g>=0&&g<=1&&d>=0&&d<=1){return[n+g*(r-n),i+g*(o-i)]}return!1}var pt=function(t,e){const n=new rt([],st);return function(t,e){if("FeatureCollection"===t.type){const n=t.features;for(let t=0;t<n.length;t++)ft(n[t],e)}else ft(t,e)}(t,n),function(t,e){e=e||!1;const n=[],i=new rt([],at);for(;t.length;){const r=t.pop();if(r.isLeftEndpoint){const t=new gt(r);for(let o=0;o<i.data.length;o++){const s=i.data[o];if(e&&s.leftSweepEvent.featureId===r.featureId)continue;const a=dt(t,s);!1!==a&&n.push(a)}i.push(t)}else!1===r.isLeftEndpoint&&i.pop()}return n}(n,e)};var yt=function(t,e,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:r=!0}=n;let o=[];"FeatureCollection"===t.type?o=o.concat(t.features):"Feature"===t.type?o.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||o.push(f(t)),"FeatureCollection"===e.type?o=o.concat(e.features):"Feature"===e.type?o.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||o.push(f(e));const s=pt(y(o),r);let a=[];if(i){const t={};s.forEach(e=>{const n=e.join(",");t[n]||(t[n]=!0,a.push(e))})}else a=s;return y(a.map(t=>g(t)))},vt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mt=Math.ceil,_t=Math.floor,kt="[BigNumber Error] ",xt=kt+"Number primitive has more than 15 significant digits: ",Et=1e14,wt=14,It=9007199254740991,Mt=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],bt=1e7,St=1e9;function Nt(t){var e=0|t;return t>0||t===e?e:e-1}function Lt(t){for(var e,n,i=1,r=t.length,o=t[0]+"";i<r;){for(e=t[i++]+"",n=wt-e.length;n--;e="0"+e);o+=e}for(r=o.length;48===o.charCodeAt(--r););return o.slice(0,r+1||1)}function Pt(t,e){var n,i,r=t.c,o=e.c,s=t.s,a=e.s,l=t.e,u=e.e;if(!s||!a)return null;if(n=r&&!r[0],i=o&&!o[0],n||i)return n?i?0:-a:s;if(s!=a)return s;if(n=s<0,i=l==u,!r||!o)return i?0:!r^n?1:-1;if(!i)return l>u^n?1:-1;for(a=(l=r.length)<(u=o.length)?l:u,s=0;s<a;s++)if(r[s]!=o[s])return r[s]>o[s]^n?1:-1;return l==u?0:l>u^n?1:-1}function Ct(t,e,n,i){if(t<e||t>n||t!==_t(t))throw Error(kt+(i||"Argument")+("number"==typeof t?t<e||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function Tt(t){var e=t.c.length-1;return Nt(t.e/wt)==e&&t.c[e]%2!=0}function Ot(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function At(t,e,n){var i,r;if(e<0){for(r=n+".";++e;r+=n);t=r+t}else if(++e>(i=t.length)){for(r=n,e-=i;--e;r+=n);t+=r}else e<i&&(t=t.slice(0,e)+"."+t.slice(e));return t}var Dt=function t(e){var n,i,r,o,s,a=x.prototype={constructor:x,toString:null,valueOf:null},l=new x(1),u=20,h=4,c=-7,f=21,g=-1e7,d=1e7,p=!1,y=1,v=0,m={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},_="0123456789abcdefghijklmnopqrstuvwxyz",k=!0;function x(t,e){var n,o,s,a,l,c,f,p,y=this;if(!(y instanceof x))return new x(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>d?y.c=y.e=null:t.e<g?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((c="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,l=t;l>=10;l/=10,a++);return void(a>d?y.c=y.e=null:(y.e=a,y.c=[t]))}p=String(t)}else{if(!vt.test(p=String(t)))return r(y,p,c);y.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(a=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(a<0&&(a=l),a+=+p.slice(l+1),p=p.substring(0,l)):a<0&&(a=p.length)}else{if(Ct(e,2,_.length,"Base"),10==e&&k)return M(y=new x(t),u+y.e+1,h);if(p=String(t),c="number"==typeof t){if(0*t!=0)return r(y,p,c,e);if(y.s=1/t<0?(p=p.slice(1),-1):1,x.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(xt+t)}else y.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(n=_.slice(0,e),a=l=0,f=p.length;l<f;l++)if(n.indexOf(o=p.charAt(l))<0){if("."==o){if(l>a){a=f;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,a=0;continue}return r(y,String(t),c,e)}c=!1,(a=(p=i(p,e,10,y.s)).indexOf("."))>-1?p=p.replace(".",""):a=p.length}for(l=0;48===p.charCodeAt(l);l++);for(f=p.length;48===p.charCodeAt(--f););if(p=p.slice(l,++f)){if(f-=l,c&&x.DEBUG&&f>15&&(t>It||t!==_t(t)))throw Error(xt+y.s*t);if((a=a-l-1)>d)y.c=y.e=null;else if(a<g)y.c=[y.e=0];else{if(y.e=a,y.c=[],l=(a+1)%wt,a<0&&(l+=wt),l<f){for(l&&y.c.push(+p.slice(0,l)),f-=wt;l<f;)y.c.push(+p.slice(l,l+=wt));l=wt-(p=p.slice(l)).length}else l-=f;for(;l--;p+="0");y.c.push(+p)}}else y.c=[y.e=0]}function E(t,e,n,i){var r,o,s,a,l;if(null==n?n=h:Ct(n,0,8),!t.c)return t.toString();if(r=t.c[0],s=t.e,null==e)l=Lt(t.c),l=1==i||2==i&&(s<=c||s>=f)?Ot(l,s):At(l,s,"0");else if(o=(t=M(new x(t),e,n)).e,a=(l=Lt(t.c)).length,1==i||2==i&&(e<=o||o<=c)){for(;a<e;l+="0",a++);l=Ot(l,o)}else if(e-=s+(2===i&&o>s),l=At(l,o,"0"),o+1>a){if(--e>0)for(l+=".";e--;l+="0");}else if((e+=o-a)>0)for(o+1==a&&(l+=".");e--;l+="0");return t.s<0&&r?"-"+l:l}function w(t,e){for(var n,i,r=1,o=new x(t[0]);r<t.length;r++)(!(i=new x(t[r])).s||(n=Pt(o,i))===e||0===n&&o.s===e)&&(o=i);return o}function I(t,e,n){for(var i=1,r=e.length;!e[--r];e.pop());for(r=e[0];r>=10;r/=10,i++);return(n=i+n*wt-1)>d?t.c=t.e=null:n<g?t.c=[t.e=0]:(t.e=n,t.c=e),t}function M(t,e,n,i){var r,o,s,a,l,u,h,c=t.c,f=Mt;if(c){t:{for(r=1,a=c[0];a>=10;a/=10,r++);if((o=e-r)<0)o+=wt,s=e,l=c[u=0],h=_t(l/f[r-s-1]%10);else if((u=mt((o+1)/wt))>=c.length){if(!i)break t;for(;c.length<=u;c.push(0));l=h=0,r=1,s=(o%=wt)-wt+1}else{for(l=a=c[u],r=1;a>=10;a/=10,r++);h=(s=(o%=wt)-wt+r)<0?0:_t(l/f[r-s-1]%10)}if(i=i||e<0||null!=c[u+1]||(s<0?l:l%f[r-s-1]),i=n<4?(h||i)&&(0==n||n==(t.s<0?3:2)):h>5||5==h&&(4==n||i||6==n&&(o>0?s>0?l/f[r-s]:0:c[u-1])%10&1||n==(t.s<0?8:7)),e<1||!c[0])return c.length=0,i?(e-=t.e+1,c[0]=f[(wt-e%wt)%wt],t.e=-e||0):c[0]=t.e=0,t;if(0==o?(c.length=u,a=1,u--):(c.length=u+1,a=f[wt-o],c[u]=s>0?_t(l/f[r-s]%f[s])*a:0),i)for(;;){if(0==u){for(o=1,s=c[0];s>=10;s/=10,o++);for(s=c[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,c[0]==Et&&(c[0]=1));break}if(c[u]+=a,c[u]!=Et)break;c[u--]=0,a=1}for(o=c.length;0===c[--o];c.pop());}t.e>d?t.c=t.e=null:t.e<g&&(t.c=[t.e=0])}return t}function b(t){var e,n=t.e;return null===n?t.toString():(e=Lt(t.c),e=n<=c||n>=f?Ot(e,n):At(e,n,"0"),t.s<0?"-"+e:e)}return x.clone=t,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(t){var e,n;if(null!=t){if("object"!=typeof t)throw Error(kt+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(Ct(n=t[e],0,St,e),u=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(Ct(n=t[e],0,8,e),h=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(Ct(n[0],-St,0,e),Ct(n[1],0,St,e),c=n[0],f=n[1]):(Ct(n,-St,St,e),c=-(f=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)Ct(n[0],-St,-1,e),Ct(n[1],1,St,e),g=n[0],d=n[1];else{if(Ct(n,-St,St,e),!n)throw Error(kt+e+" cannot be zero: "+n);g=-(d=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(kt+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw p=!n,Error(kt+"crypto unavailable");p=n}else p=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(Ct(n=t[e],0,9,e),y=n),t.hasOwnProperty(e="POW_PRECISION")&&(Ct(n=t[e],0,St,e),v=n),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(n=t[e]))throw Error(kt+e+" not an object: "+n);m=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(kt+e+" invalid: "+n);k="0123456789"==n.slice(0,10),_=n}}return{DECIMAL_PLACES:u,ROUNDING_MODE:h,EXPONENTIAL_AT:[c,f],RANGE:[g,d],CRYPTO:p,MODULO_MODE:y,POW_PRECISION:v,FORMAT:m,ALPHABET:_}},x.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!x.DEBUG)return!0;var e,n,i=t.c,r=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(i)){if((1===o||-1===o)&&r>=-St&&r<=St&&r===_t(r)){if(0===i[0]){if(0===r&&1===i.length)return!0;break t}if((e=(r+1)%wt)<1&&(e+=wt),String(i[0]).length==e){for(e=0;e<i.length;e++)if((n=i[e])<0||n>=Et||n!==_t(n))break t;if(0!==n)return!0}}}else if(null===i&&null===r&&(null===o||1===o||-1===o))return!0;throw Error(kt+"Invalid BigNumber: "+t)},x.maximum=x.max=function(){return w(arguments,-1)},x.minimum=x.min=function(){return w(arguments,1)},x.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return _t(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,n,i,r,o,a=0,h=[],c=new x(l);if(null==t?t=u:Ct(t,0,St),r=mt(t/wt),p)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(r*=2));a<r;)(o=131072*e[a]+(e[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),e[a]=n[0],e[a+1]=n[1]):(h.push(o%1e14),a+=2);a=r/2}else{if(!crypto.randomBytes)throw p=!1,Error(kt+"crypto unavailable");for(e=crypto.randomBytes(r*=7);a<r;)(o=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(h.push(o%1e14),a+=7);a=r/7}if(!p)for(;a<r;)(o=s())<9e15&&(h[a++]=o%1e14);for(r=h[--a],t%=wt,r&&t&&(o=Mt[wt-t],h[a]=_t(r/o)*o);0===h[a];h.pop(),a--);if(a<0)h=[i=0];else{for(i=-1;0===h[0];h.splice(0,1),i-=wt);for(a=1,o=h[0];o>=10;o/=10,a++);a<wt&&(i-=wt-a)}return c.e=i,c.c=h,c}),x.sum=function(){for(var t=1,e=arguments,n=new x(e[0]);t<e.length;)n=n.plus(e[t++]);return n},i=function(){var t="0123456789";function e(t,e,n,i){for(var r,o,s=[0],a=0,l=t.length;a<l;){for(o=s.length;o--;s[o]*=e);for(s[0]+=i.indexOf(t.charAt(a++)),r=0;r<s.length;r++)s[r]>n-1&&(null==s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/n|0,s[r]%=n)}return s.reverse()}return function(i,r,o,s,a){var l,c,f,g,d,p,y,m,k=i.indexOf("."),E=u,w=h;for(k>=0&&(g=v,v=0,i=i.replace(".",""),p=(m=new x(r)).pow(i.length-k),v=g,m.c=e(At(Lt(p.c),p.e,"0"),10,o,t),m.e=m.c.length),f=g=(y=e(i,r,o,a?(l=_,t):(l=t,_))).length;0==y[--g];y.pop());if(!y[0])return l.charAt(0);if(k<0?--f:(p.c=y,p.e=f,p.s=s,y=(p=n(p,m,E,w,o)).c,d=p.r,f=p.e),k=y[c=f+E+1],g=o/2,d=d||c<0||null!=y[c+1],d=w<4?(null!=k||d)&&(0==w||w==(p.s<0?3:2)):k>g||k==g&&(4==w||d||6==w&&1&y[c-1]||w==(p.s<0?8:7)),c<1||!y[0])i=d?At(l.charAt(1),-E,l.charAt(0)):l.charAt(0);else{if(y.length=c,d)for(--o;++y[--c]>o;)y[c]=0,c||(++f,y=[1].concat(y));for(g=y.length;!y[--g];);for(k=0,i="";k<=g;i+=l.charAt(y[k++]));i=At(i,f,l.charAt(0))}return i}}(),n=function(){function t(t,e,n){var i,r,o,s,a=0,l=t.length,u=e%bt,h=e/bt|0;for(t=t.slice();l--;)a=((r=u*(o=t[l]%bt)+(i=h*o+(s=t[l]/bt|0)*u)%bt*bt+a)/n|0)+(i/bt|0)+h*s,t[l]=r%n;return a&&(t=[a].concat(t)),t}function e(t,e,n,i){var r,o;if(n!=i)o=n>i?1:-1;else for(r=o=0;r<n;r++)if(t[r]!=e[r]){o=t[r]>e[r]?1:-1;break}return o}function n(t,e,n,i){for(var r=0;n--;)t[n]-=r,r=t[n]<e[n]?1:0,t[n]=r*i+t[n]-e[n];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(i,r,o,s,a){var l,u,h,c,f,g,d,p,y,v,m,_,k,E,w,I,b,S=i.s==r.s?1:-1,N=i.c,L=r.c;if(!(N&&N[0]&&L&&L[0]))return new x(i.s&&r.s&&(N?!L||N[0]!=L[0]:L)?N&&0==N[0]||!L?0*S:S/0:NaN);for(y=(p=new x(S)).c=[],S=o+(u=i.e-r.e)+1,a||(a=Et,u=Nt(i.e/wt)-Nt(r.e/wt),S=S/wt|0),h=0;L[h]==(N[h]||0);h++);if(L[h]>(N[h]||0)&&u--,S<0)y.push(1),c=!0;else{for(E=N.length,I=L.length,h=0,S+=2,(f=_t(a/(L[0]+1)))>1&&(L=t(L,f,a),N=t(N,f,a),I=L.length,E=N.length),k=I,m=(v=N.slice(0,I)).length;m<I;v[m++]=0);b=L.slice(),b=[0].concat(b),w=L[0],L[1]>=a/2&&w++;do{if(f=0,(l=e(L,v,I,m))<0){if(_=v[0],I!=m&&(_=_*a+(v[1]||0)),(f=_t(_/w))>1)for(f>=a&&(f=a-1),d=(g=t(L,f,a)).length,m=v.length;1==e(g,v,d,m);)f--,n(g,I<d?b:L,d,a),d=g.length,l=1;else 0==f&&(l=f=1),d=(g=L.slice()).length;if(d<m&&(g=[0].concat(g)),n(v,g,m,a),m=v.length,-1==l)for(;e(L,v,I,m)<1;)f++,n(v,I<m?b:L,m,a),m=v.length}else 0===l&&(f++,v=[0]);y[h++]=f,v[0]?v[m++]=N[k]||0:(v=[N[k]],m=1)}while((k++<E||null!=v[0])&&S--);c=null!=v[0],y[0]||y.splice(0,1)}if(a==Et){for(h=1,S=y[0];S>=10;S/=10,h++);M(p,o+(p.e=h+u*wt-1)+1,s,c)}else p.e=u,p.r=+c;return p}}(),r=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,n=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,r=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,s,a,l){var u,h=a?s:s.replace(r,"");if(i.test(h))o.s=isNaN(h)?null:h<0?-1:1;else{if(!a&&(h=h.replace(t,function(t,e,n){return u="x"==(n=n.toLowerCase())?16:"b"==n?2:8,l&&l!=u?t:e}),l&&(u=l,h=h.replace(e,"$1").replace(n,"0.$1")),s!=h))return new x(h,u);if(x.DEBUG)throw Error(kt+"Not a"+(l?" base "+l:"")+" number: "+s);o.s=null}o.c=o.e=null}}(),a.absoluteValue=a.abs=function(){var t=new x(this);return t.s<0&&(t.s=1),t},a.comparedTo=function(t,e){return Pt(this,new x(t,e))},a.decimalPlaces=a.dp=function(t,e){var n,i,r,o=this;if(null!=t)return Ct(t,0,St),null==e?e=h:Ct(e,0,8),M(new x(o),t+o.e+1,e);if(!(n=o.c))return null;if(i=((r=n.length-1)-Nt(this.e/wt))*wt,r=n[r])for(;r%10==0;r/=10,i--);return i<0&&(i=0),i},a.dividedBy=a.div=function(t,e){return n(this,new x(t,e),u,h)},a.dividedToIntegerBy=a.idiv=function(t,e){return n(this,new x(t,e),0,1)},a.exponentiatedBy=a.pow=function(t,e){var n,i,r,o,s,a,u,c,f=this;if((t=new x(t)).c&&!t.isInteger())throw Error(kt+"Exponent not an integer: "+b(t));if(null!=e&&(e=new x(e)),s=t.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!t.c||!t.c[0])return c=new x(Math.pow(+b(f),s?t.s*(2-Tt(t)):+b(t))),e?c.mod(e):c;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new x(NaN);(i=!a&&f.isInteger()&&e.isInteger())&&(f=f.mod(e))}else{if(t.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||s&&f.c[1]>=24e7:f.c[0]<8e13||s&&f.c[0]<=9999975e7)))return o=f.s<0&&Tt(t)?-0:0,f.e>-1&&(o=1/o),new x(a?1/o:o);v&&(o=mt(v/wt+2))}for(s?(n=new x(.5),a&&(t.s=1),u=Tt(t)):u=(r=Math.abs(+b(t)))%2,c=new x(l);;){if(u){if(!(c=c.times(f)).c)break;o?c.c.length>o&&(c.c.length=o):i&&(c=c.mod(e))}if(r){if(0===(r=_t(r/2)))break;u=r%2}else if(M(t=t.times(n),t.e+1,1),t.e>14)u=Tt(t);else{if(0===(r=+b(t)))break;u=r%2}f=f.times(f),o?f.c&&f.c.length>o&&(f.c.length=o):i&&(f=f.mod(e))}return i?c:(a&&(c=l.div(c)),e?c.mod(e):o?M(c,v,h,undefined):c)},a.integerValue=function(t){var e=new x(this);return null==t?t=h:Ct(t,0,8),M(e,e.e+1,t)},a.isEqualTo=a.eq=function(t,e){return 0===Pt(this,new x(t,e))},a.isFinite=function(){return!!this.c},a.isGreaterThan=a.gt=function(t,e){return Pt(this,new x(t,e))>0},a.isGreaterThanOrEqualTo=a.gte=function(t,e){return 1===(e=Pt(this,new x(t,e)))||0===e},a.isInteger=function(){return!!this.c&&Nt(this.e/wt)>this.c.length-2},a.isLessThan=a.lt=function(t,e){return Pt(this,new x(t,e))<0},a.isLessThanOrEqualTo=a.lte=function(t,e){return-1===(e=Pt(this,new x(t,e)))||0===e},a.isNaN=function(){return!this.s},a.isNegative=function(){return this.s<0},a.isPositive=function(){return this.s>0},a.isZero=function(){return!!this.c&&0==this.c[0]},a.minus=function(t,e){var n,i,r,o,s=this,a=s.s;if(e=(t=new x(t,e)).s,!a||!e)return new x(NaN);if(a!=e)return t.s=-e,s.plus(t);var l=s.e/wt,u=t.e/wt,c=s.c,f=t.c;if(!l||!u){if(!c||!f)return c?(t.s=-e,t):new x(f?s:NaN);if(!c[0]||!f[0])return f[0]?(t.s=-e,t):new x(c[0]?s:3==h?-0:0)}if(l=Nt(l),u=Nt(u),c=c.slice(),a=l-u){for((o=a<0)?(a=-a,r=c):(u=l,r=f),r.reverse(),e=a;e--;r.push(0));r.reverse()}else for(i=(o=(a=c.length)<(e=f.length))?a:e,a=e=0;e<i;e++)if(c[e]!=f[e]){o=c[e]<f[e];break}if(o&&(r=c,c=f,f=r,t.s=-t.s),(e=(i=f.length)-(n=c.length))>0)for(;e--;c[n++]=0);for(e=Et-1;i>a;){if(c[--i]<f[i]){for(n=i;n&&!c[--n];c[n]=e);--c[n],c[i]+=Et}c[i]-=f[i]}for(;0==c[0];c.splice(0,1),--u);return c[0]?I(t,c,u):(t.s=3==h?-1:1,t.c=[t.e=0],t)},a.modulo=a.mod=function(t,e){var i,r,o=this;return t=new x(t,e),!o.c||!t.s||t.c&&!t.c[0]?new x(NaN):!t.c||o.c&&!o.c[0]?new x(o):(9==y?(r=t.s,t.s=1,i=n(o,t,0,3),t.s=r,i.s*=r):i=n(o,t,0,y),(t=o.minus(i.times(t))).c[0]||1!=y||(t.s=o.s),t)},a.multipliedBy=a.times=function(t,e){var n,i,r,o,s,a,l,u,h,c,f,g,d,p,y,v=this,m=v.c,_=(t=new x(t,e)).c;if(!(m&&_&&m[0]&&_[0]))return!v.s||!t.s||m&&!m[0]&&!_||_&&!_[0]&&!m?t.c=t.e=t.s=null:(t.s*=v.s,m&&_?(t.c=[0],t.e=0):t.c=t.e=null),t;for(i=Nt(v.e/wt)+Nt(t.e/wt),t.s*=v.s,(l=m.length)<(c=_.length)&&(d=m,m=_,_=d,r=l,l=c,c=r),r=l+c,d=[];r--;d.push(0));for(p=Et,y=bt,r=c;--r>=0;){for(n=0,f=_[r]%y,g=_[r]/y|0,o=r+(s=l);o>r;)n=((u=f*(u=m[--s]%y)+(a=g*u+(h=m[s]/y|0)*f)%y*y+d[o]+n)/p|0)+(a/y|0)+g*h,d[o--]=u%p;d[o]=n}return n?++i:d.splice(0,1),I(t,d,i)},a.negated=function(){var t=new x(this);return t.s=-t.s||null,t},a.plus=function(t,e){var n,i=this,r=i.s;if(e=(t=new x(t,e)).s,!r||!e)return new x(NaN);if(r!=e)return t.s=-e,i.minus(t);var o=i.e/wt,s=t.e/wt,a=i.c,l=t.c;if(!o||!s){if(!a||!l)return new x(r/0);if(!a[0]||!l[0])return l[0]?t:new x(a[0]?i:0*r)}if(o=Nt(o),s=Nt(s),a=a.slice(),r=o-s){for(r>0?(s=o,n=l):(r=-r,n=a),n.reverse();r--;n.push(0));n.reverse()}for((r=a.length)-(e=l.length)<0&&(n=l,l=a,a=n,e=r),r=0;e;)r=(a[--e]=a[e]+l[e]+r)/Et|0,a[e]=Et===a[e]?0:a[e]%Et;return r&&(a=[r].concat(a),++s),I(t,a,s)},a.precision=a.sd=function(t,e){var n,i,r,o=this;if(null!=t&&t!==!!t)return Ct(t,1,St),null==e?e=h:Ct(e,0,8),M(new x(o),t,e);if(!(n=o.c))return null;if(i=(r=n.length-1)*wt+1,r=n[r]){for(;r%10==0;r/=10,i--);for(r=n[0];r>=10;r/=10,i++);}return t&&o.e+1>i&&(i=o.e+1),i},a.shiftedBy=function(t){return Ct(t,-9007199254740991,It),this.times("1e"+t)},a.squareRoot=a.sqrt=function(){var t,e,i,r,o,s=this,a=s.c,l=s.s,c=s.e,f=u+4,g=new x("0.5");if(1!==l||!a||!a[0])return new x(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+b(s)))||l==1/0?(((e=Lt(a)).length+c)%2==0&&(e+="0"),l=Math.sqrt(+e),c=Nt((c+1)/2)-(c<0||c%2),i=new x(e=l==1/0?"5e"+c:(e=l.toExponential()).slice(0,e.indexOf("e")+1)+c)):i=new x(l+""),i.c[0])for((l=(c=i.e)+f)<3&&(l=0);;)if(o=i,i=g.times(o.plus(n(s,o,f,1))),Lt(o.c).slice(0,l)===(e=Lt(i.c)).slice(0,l)){if(i.e<c&&--l,"9999"!=(e=e.slice(l-3,l+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(M(i,i.e+u+2,1),t=!i.times(i).eq(s));break}if(!r&&(M(o,o.e+u+2,0),o.times(o).eq(s))){i=o;break}f+=4,l+=4,r=1}return M(i,i.e+u+1,h,t)},a.toExponential=function(t,e){return null!=t&&(Ct(t,0,St),t++),E(this,t,e,1)},a.toFixed=function(t,e){return null!=t&&(Ct(t,0,St),t=t+this.e+1),E(this,t,e)},a.toFormat=function(t,e,n){var i,r=this;if(null==n)null!=t&&e&&"object"==typeof e?(n=e,e=null):t&&"object"==typeof t?(n=t,t=e=null):n=m;else if("object"!=typeof n)throw Error(kt+"Argument not an object: "+n);if(i=r.toFixed(t,e),r.c){var o,s=i.split("."),a=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||"",h=s[0],c=s[1],f=r.s<0,g=f?h.slice(1):h,d=g.length;if(l&&(o=a,a=l,l=o,d-=o),a>0&&d>0){for(o=d%a||a,h=g.substr(0,o);o<d;o+=a)h+=u+g.substr(o,a);l>0&&(h+=u+g.slice(o)),f&&(h="-"+h)}i=c?h+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):h}return(n.prefix||"")+i+(n.suffix||"")},a.toFraction=function(t){var e,i,r,o,s,a,u,c,f,g,p,y,v=this,m=v.c;if(null!=t&&(!(u=new x(t)).isInteger()&&(u.c||1!==u.s)||u.lt(l)))throw Error(kt+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+b(u));if(!m)return new x(v);for(e=new x(l),f=i=new x(l),r=c=new x(l),y=Lt(m),s=e.e=y.length-v.e-1,e.c[0]=Mt[(a=s%wt)<0?wt+a:a],t=!t||u.comparedTo(e)>0?s>0?e:f:u,a=d,d=1/0,u=new x(y),c.c[0]=0;g=n(u,e,0,1),1!=(o=i.plus(g.times(r))).comparedTo(t);)i=r,r=o,f=c.plus(g.times(o=f)),c=o,e=u.minus(g.times(o=e)),u=o;return o=n(t.minus(i),r,0,1),c=c.plus(o.times(f)),i=i.plus(o.times(r)),c.s=f.s=v.s,p=n(f,r,s*=2,h).minus(v).abs().comparedTo(n(c,i,s,h).minus(v).abs())<1?[f,r]:[c,i],d=a,p},a.toNumber=function(){return+b(this)},a.toPrecision=function(t,e){return null!=t&&Ct(t,1,St),E(this,t,e,2)},a.toString=function(t){var e,n=this,r=n.s,o=n.e;return null===o?r?(e="Infinity",r<0&&(e="-"+e)):e="NaN":(null==t?e=o<=c||o>=f?Ot(Lt(n.c),o):At(Lt(n.c),o,"0"):10===t&&k?e=At(Lt((n=M(new x(n),u+o+1,h)).c),n.e,"0"):(Ct(t,2,_.length,"Base"),e=i(At(Lt(n.c),o,"0"),10,t,r,!0)),r<0&&n.c[0]&&(e="-"+e)),e},a.valueOf=a.toJSON=function(){return b(this)},a._isBigNumber=!0,a[Symbol.toStringTag]="BigNumber",a[Symbol.for("nodejs.util.inspect.custom")]=a.valueOf,null!=e&&x.set(e),x}(),Rt=class{constructor(t){r(this,"key"),r(this,"left",null),r(this,"right",null),this.key=t}},Ft=class extends Rt{constructor(t){super(t)}},Gt=class{constructor(){r(this,"size",0),r(this,"modificationCount",0),r(this,"splayCount",0)}splay(t){const e=this.root;if(null==e)return this.compare(t,t),-1;let n=null,i=null,r=null,o=null,s=e;const a=this.compare;let l;for(;;)if(l=a(s.key,t),l>0){let e=s.left;if(null==e)break;if(l=a(e.key,t),l>0&&(s.left=e.right,e.right=s,s=e,e=s.left,null==e))break;null==n?i=s:n.left=s,n=s,s=e}else{if(!(l<0))break;{let e=s.right;if(null==e)break;if(l=a(e.key,t),l<0&&(s.right=e.left,e.left=s,s=e,e=s.right,null==e))break;null==r?o=s:r.right=s,r=s,s=e}}return null!=r&&(r.right=s.left,s.left=o),null!=n&&(n.left=s.right,s.right=i),this.root!==s&&(this.root=s,this.splayCount++),l}splayMin(t){let e=t,n=e.left;for(;null!=n;){const t=n;e.left=t.right,t.right=e,e=t,n=e.left}return e}splayMax(t){let e=t,n=e.right;for(;null!=n;){const t=n;e.right=t.left,t.left=e,e=t,n=e.right}return e}_delete(t){if(null==this.root)return null;if(0!=this.splay(t))return null;let e=this.root;const n=e,i=e.left;if(this.size--,null==i)this.root=e.right;else{const t=e.right;e=this.splayMax(i),e.right=t,this.root=e}return this.modificationCount++,n}addNewRoot(t,e){this.size++,this.modificationCount++;const n=this.root;null!=n?(e<0?(t.left=n,t.right=n.right,n.right=null):(t.right=n,t.left=n.left,n.left=null),this.root=t):this.root=t}_first(){const t=this.root;return null==t?null:(this.root=this.splayMin(t),this.root)}_last(){const t=this.root;return null==t?null:(this.root=this.splayMax(t),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(t){return this.validKey(t)&&0==this.splay(t)}defaultCompare(){return(t,e)=>t<e?-1:t>e?1:0}wrap(){return{getRoot:()=>this.root,setRoot:t=>{this.root=t},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:t=>{this.splayCount=t},splay:t=>this.splay(t),has:t=>this.has(t)}}},Bt=class t extends Gt{constructor(t,n){super(),r(this,"root",null),r(this,"compare"),r(this,"validKey"),r(this,e,"[object Set]"),this.compare=t??this.defaultCompare(),this.validKey=n??(t=>null!=t&&null!=t)}delete(t){return!!this.validKey(t)&&null!=this._delete(t)}deleteAll(t){for(const e of t)this.delete(e)}forEach(t){const e=this[Symbol.iterator]();let n;for(;n=e.next(),!n.done;)t(n.value,n.value,this)}add(t){const e=this.splay(t);return 0!=e&&this.addNewRoot(new Ft(t),e),this}addAndReturn(t){const e=this.splay(t);return 0!=e&&this.addNewRoot(new Ft(t),e),this.root.key}addAll(t){for(const e of t)this.add(e)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)<0)return this.root.key;let e=this.root.left;if(null==e)return null;let n=e.right;for(;null!=n;)e=n,n=e.right;return e.key}firstAfter(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)>0)return this.root.key;let e=this.root.right;if(null==e)return null;let n=e.left;for(;null!=n;)e=n,n=e.left;return e.key}retainAll(e){const n=new t(this.compare,this.validKey),i=this.modificationCount;for(const t of e){if(i!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(t)&&0==this.splay(t)&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(t){if(!this.validKey(t))return null;return 0!=this.splay(t)?null:this.root.key}intersection(e){const n=new t(this.compare,this.validKey);for(const t of this)e.has(t)&&n.add(t);return n}difference(e){const n=new t(this.compare,this.validKey);for(const t of this)e.has(t)||n.add(t);return n}union(t){const e=this.clone();return e.addAll(t),e}clone(){const e=new t(this.compare,this.validKey);return e.size=this.size,e.root=this.copyNode(this.root),e}copyNode(t){if(null==t)return null;const e=new Ft(t.key);return function t(e,n){let i,r;do{if(i=e.left,r=e.right,null!=i){const e=new Ft(i.key);n.left=e,t(i,e)}if(null!=r){const t=new Ft(r.key);n.right=t,e=r,n=t}}while(null!=r)}(t,e),e}toSet(){return this.clone()}entries(){return new zt(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(n=Symbol.iterator,e=Symbol.toStringTag,n)](){return new qt(this.wrap())}},Yt=class{constructor(t){r(this,"tree"),r(this,"path",new Array),r(this,"modificationCount",null),r(this,"splayCount"),this.tree=t,this.splayCount=t.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;const t=this.path[this.path.length-1];return this.getValue(t)}rebuildPath(t){this.path.splice(0,this.path.length),this.tree.splay(t),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(t){for(;null!=t;)this.path.push(t),t=t.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let t=this.tree.getRoot();for(;null!=t;)this.path.push(t),t=t.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 t=this.path[this.path.length-1],e=t.right;if(null!=e){for(;null!=e;)this.path.push(e),e=e.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===t;)t=this.path.pop();return this.path.length>0}},qt=class extends Yt{getValue(t){return t.key}},zt=class extends Yt{getValue(t){return[t.key,t.key]}},Ht=t=>()=>t,Ut=t=>{const e=t?(e,n)=>n.minus(e).abs().isLessThanOrEqualTo(t):Ht(!1);return(t,n)=>e(t,n)?0:t.comparedTo(n)};function Xt(t){const e=t?(e,n,i,r,o)=>e.exponentiatedBy(2).isLessThanOrEqualTo(r.minus(n).exponentiatedBy(2).plus(o.minus(i).exponentiatedBy(2)).times(t)):Ht(!1);return(t,n,i)=>{const r=t.x,o=t.y,s=i.x,a=i.y,l=o.minus(a).times(n.x.minus(s)).minus(r.minus(s).times(n.y.minus(a)));return e(l,r,o,s,a)?0:l.comparedTo(0)}}var Vt=t=>t,jt=t=>{if(t){const e=new Bt(Ut(t)),n=new Bt(Ut(t)),i=(t,e)=>e.addAndReturn(t),r=t=>({x:i(t.x,e),y:i(t.y,n)});return r({x:new Dt(0),y:new Dt(0)}),r}return Vt},Kt=t=>({set:t=>{Wt=Kt(t)},reset:()=>Kt(t),compare:Ut(t),snap:jt(t),orient:Xt(t)}),Wt=Kt(),Zt=(t,e)=>t.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(t.ur.x)&&t.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(t.ur.y),Jt=(t,e)=>{if(e.ur.x.isLessThan(t.ll.x)||t.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(t.ll.y)||t.ur.y.isLessThan(e.ll.y))return null;const n=t.ll.x.isLessThan(e.ll.x)?e.ll.x:t.ll.x,i=t.ur.x.isLessThan(e.ur.x)?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y.isLessThan(e.ll.y)?e.ll.y:t.ll.y},ur:{x:i,y:t.ur.y.isLessThan(e.ur.y)?t.ur.y:e.ur.y}}},$t=(t,e)=>t.x.times(e.y).minus(t.y.times(e.x)),Qt=(t,e)=>t.x.times(e.x).plus(t.y.times(e.y)),te=t=>Qt(t,t).sqrt(),ee=(t,e,n)=>{const i={x:e.x.minus(t.x),y:e.y.minus(t.y)},r={x:n.x.minus(t.x),y:n.y.minus(t.y)};return $t(r,i).div(te(r)).div(te(i))},ne=(t,e,n)=>{const i={x:e.x.minus(t.x),y:e.y.minus(t.y)},r={x:n.x.minus(t.x),y:n.y.minus(t.y)};return Qt(r,i).div(te(r)).div(te(i))},ie=(t,e,n)=>e.y.isZero()?null:{x:t.x.plus(e.x.div(e.y).times(n.minus(t.y))),y:n},re=(t,e,n)=>e.x.isZero()?null:{x:n,y:t.y.plus(e.y.div(e.x).times(n.minus(t.x)))},oe=class t{constructor(t,e){r(this,"point"),r(this,"isLeft"),r(this,"segment"),r(this,"otherSE"),r(this,"consumedBy"),void 0===t.events?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}static compare(e,n){const i=t.comparePoints(e.point,n.point);return 0!==i?i:(e.point!==n.point&&e.link(n),e.isLeft!==n.isLeft?e.isLeft?1:-1:ge.compare(e.segment,n.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");const e=t.point.events;for(let n=0,i=e.length;n<i;n++){const t=e[n];this.point.events.push(t),t.point=this.point}this.checkForConsuming()}checkForConsuming(){const t=this.point.events.length;for(let e=0;e<t;e++){const n=this.point.events[e];if(void 0===n.segment.consumedBy)for(let i=e+1;i<t;i++){const t=this.point.events[i];void 0===t.consumedBy&&(n.otherSE.point.events===t.otherSE.point.events&&n.segment.consume(t.segment))}}}getAvailableLinkedEvents(){const t=[];for(let e=0,n=this.point.events.length;e<n;e++){const n=this.point.events[e];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&t.push(n)}return t}getLeftmostComparator(t){const e=new Map,n=n=>{const i=n.otherSE;e.set(n,{sine:ee(this.point,t.point,i.point),cosine:ne(this.point,t.point,i.point)})};return(t,i)=>{e.has(t)||n(t),e.has(i)||n(i);const{sine:r,cosine:o}=e.get(t),{sine:s,cosine:a}=e.get(i);return r.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?o.isLessThan(a)?1:o.isGreaterThan(a)?-1:0:r.isLessThan(0)&&s.isLessThan(0)?o.isLessThan(a)?-1:o.isGreaterThan(a)?1:0:s.isLessThan(r)?-1:s.isGreaterThan(r)?1:0}}},se=class t{constructor(t){r(this,"events"),r(this,"poly"),r(this,"_isExteriorRing"),r(this,"_enclosingRing"),this.events=t;for(let e=0,n=t.length;e<n;e++)t[e].segment.ringOut=this;this.poly=null}static factory(e){const n=[];for(let i=0,r=e.length;i<r;i++){const r=e[i];if(!r.isInResult()||r.ringOut)continue;let o=null,s=r.leftSE,a=r.rightSE;const l=[s],u=s.point,h=[];for(;o=s,s=a,l.push(s),s.point!==u;)for(;;){const e=s.getAvailableLinkedEvents();if(0===e.length){const t=l[0].point,e=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${t.x}, ${t.y}]. Last matching segment found ends at [${e.x}, ${e.y}].`)}if(1===e.length){a=e[0].otherSE;break}let i=null;for(let t=0,n=h.length;t<n;t++)if(h[t].point===s.point){i=t;break}if(null!==i){const e=h.splice(i)[0],r=l.splice(e.index);r.unshift(r[0].otherSE),n.push(new t(r.reverse()));continue}h.push({index:l.length,point:s.point});const r=s.getLeftmostComparator(o);a=e.sort(r)[0].otherSE;break}n.push(new t(l))}return n}getGeom(){let t=this.events[0].point;const e=[t];for(let l=1,u=this.events.length-1;l<u;l++){const n=this.events[l].point,i=this.events[l+1].point;0!==Wt.orient(n,t,i)&&(e.push(n),t=n)}if(1===e.length)return null;const n=e[0],i=e[1];0===Wt.orient(n,t,i)&&e.shift(),e.push(e[0]);const r=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:e.length-1,s=this.isExteriorRing()?e.length:-1,a=[];for(let l=o;l!=s;l+=r)a.push([e[l].x.toNumber(),e[l].y.toNumber()]);return a}isExteriorRing(){if(void 0===this._isExteriorRing){const t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){var t,e;let n=this.events[0];for(let o=1,s=this.events.length;o<s;o++){const t=this.events[o];oe.compare(n,t)>0&&(n=t)}let i=n.segment.prevInResult(),r=i?i.prevInResult():null;for(;;){if(!i)return null;if(!r)return i.ringOut;if(r.ringOut!==i.ringOut)return(null==(t=r.ringOut)?void 0:t.enclosingRing())!==i.ringOut?i.ringOut:null==(e=i.ringOut)?void 0:e.enclosingRing();i=r.prevInResult(),r=i?i.prevInResult():null}}},ae=class{constructor(t){r(this,"exteriorRing"),r(this,"interiorRings"),this.exteriorRing=t,t.poly=this,this.interiorRings=[]}addInterior(t){this.interiorRings.push(t),t.poly=this}getGeom(){const t=this.exteriorRing.getGeom();if(null===t)return null;const e=[t];for(let n=0,i=this.interiorRings.length;n<i;n++){const t=this.interiorRings[n].getGeom();null!==t&&e.push(t)}return e}},le=class{constructor(t){r(this,"rings"),r(this,"polys"),this.rings=t,this.polys=this._composePolys(t)}getGeom(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getGeom();null!==n&&t.push(n)}return t}_composePolys(t){var e;const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];if(!r.poly)if(r.isExteriorRing())n.push(new ae(r));else{const t=r.enclosingRing();(null==t?void 0:t.poly)||n.push(new ae(t)),null==(e=null==t?void 0:t.poly)||e.addInterior(r)}}return n}},ue=class{constructor(t,e=ge.compare){r(this,"queue"),r(this,"tree"),r(this,"segments"),this.queue=t,this.tree=new Bt(e),this.segments=[]}process(t){const e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.delete(t.otherSE):this.tree.delete(e),n;t.isLeft&&this.tree.add(e);let i=e,r=e;do{i=this.tree.lastBefore(i)}while(null!=i&&null!=i.consumedBy);do{r=this.tree.firstAfter(r)}while(null!=r&&null!=r.consumedBy);if(t.isLeft){let o=null;if(i){const t=i.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(o=t),!i.isAnEndpoint(t))){const e=this._splitSafely(i,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}let s=null;if(r){const t=r.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(s=t),!r.isAnEndpoint(t))){const e=this._splitSafely(r,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}if(null!==o||null!==s){let t=null;if(null===o)t=s;else if(null===s)t=o;else{t=oe.comparePoints(o,s)<=0?o:s}this.queue.delete(e.rightSE),n.push(e.rightSE);const i=e.split(t);for(let e=0,r=i.length;e<r;e++)n.push(i[e])}n.length>0?(this.tree.delete(e),n.push(t)):(this.segments.push(e),e.prev=i)}else{if(i&&r){const t=i.getIntersection(r);if(null!==t){if(!i.isAnEndpoint(t)){const e=this._splitSafely(i,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}if(!r.isAnEndpoint(t)){const e=this._splitSafely(r,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}}this.tree.delete(e)}return n}_splitSafely(t,e){this.tree.delete(t);const n=t.rightSE;this.queue.delete(n);const i=t.split(e);return i.push(n),void 0===t.consumedBy&&this.tree.add(t),i}},he=new class{constructor(){r(this,"type"),r(this,"numMultiPolys")}run(t,e,n){he.type=t;const i=[new ye(e,!0)];for(let l=0,u=n.length;l<u;l++)i.push(new ye(n[l],!1));if(he.numMultiPolys=i.length,"difference"===he.type){const t=i[0];let e=1;for(;e<i.length;)null!==Jt(i[e].bbox,t.bbox)?e++:i.splice(e,1)}if("intersection"===he.type)for(let l=0,u=i.length;l<u;l++){const t=i[l];for(let e=l+1,n=i.length;e<n;e++)if(null===Jt(t.bbox,i[e].bbox))return[]}const r=new Bt(oe.compare);for(let l=0,u=i.length;l<u;l++){const t=i[l].getSweepEvents();for(let e=0,n=t.length;e<n;e++)r.add(t[e])}const o=new ue(r);let s=null;for(0!=r.size&&(s=r.first(),r.delete(s));s;){const t=o.process(s);for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0===n.consumedBy&&r.add(n)}0!=r.size?(s=r.first(),r.delete(s)):s=null}Wt.reset();const a=se.factory(o.segments);return new le(a).getGeom()}},ce=he,fe=0,ge=class t{constructor(t,e,n,i){r(this,"id"),r(this,"leftSE"),r(this,"rightSE"),r(this,"rings"),r(this,"windings"),r(this,"ringOut"),r(this,"consumedBy"),r(this,"prev"),r(this,"_prevInResult"),r(this,"_beforeState"),r(this,"_afterState"),r(this,"_isInResult"),this.id=++fe,this.leftSE=t,t.segment=this,t.otherSE=e,this.rightSE=e,e.segment=this,e.otherSE=t,this.rings=n,this.windings=i}static compare(t,e){const n=t.leftSE.point.x,i=e.leftSE.point.x,r=t.rightSE.point.x,o=e.rightSE.point.x;if(o.isLessThan(n))return 1;if(r.isLessThan(i))return-1;const s=t.leftSE.point.y,a=e.leftSE.point.y,l=t.rightSE.point.y,u=e.rightSE.point.y;if(n.isLessThan(i)){if(a.isLessThan(s)&&a.isLessThan(l))return 1;if(a.isGreaterThan(s)&&a.isGreaterThan(l))return-1;const n=t.comparePoint(e.leftSE.point);if(n<0)return 1;if(n>0)return-1;const i=e.comparePoint(t.rightSE.point);return 0!==i?i:-1}if(n.isGreaterThan(i)){if(s.isLessThan(a)&&s.isLessThan(u))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(u))return 1;const n=e.comparePoint(t.leftSE.point);if(0!==n)return n;const i=t.comparePoint(e.rightSE.point);return i<0?1:i>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(r.isLessThan(o)){const n=e.comparePoint(t.rightSE.point);if(0!==n)return n}if(r.isGreaterThan(o)){const n=t.comparePoint(e.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!r.eq(o)){const t=l.minus(s),e=r.minus(n),h=u.minus(a),c=o.minus(i);if(t.isGreaterThan(e)&&h.isLessThan(c))return 1;if(t.isLessThan(e)&&h.isGreaterThan(c))return-1}return r.isGreaterThan(o)?1:r.isLessThan(o)||l.isLessThan(u)?-1:l.isGreaterThan(u)?1:t.id<e.id?-1:t.id>e.id?1:0}static fromRing(e,n,i){let r,o,s;const a=oe.comparePoints(e,n);if(a<0)r=e,o=n,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);r=n,o=e,s=-1}const l=new oe(r,!0),u=new oe(o,!1);return new t(l,u,[i],[s])}replaceRightSE(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const 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 Wt.orient(this.leftSE.point,t,this.rightSE.point)}getIntersection(t){const e=this.bbox(),n=t.bbox(),i=Jt(e,n);if(null===i)return null;const r=this.leftSE.point,o=this.rightSE.point,s=t.leftSE.point,a=t.rightSE.point,l=Zt(e,s)&&0===this.comparePoint(s),u=Zt(n,r)&&0===t.comparePoint(r),h=Zt(e,a)&&0===this.comparePoint(a),c=Zt(n,o)&&0===t.comparePoint(o);if(u&&l)return c&&!h?o:!c&&h?a:null;if(u)return h&&r.x.eq(a.x)&&r.y.eq(a.y)?null:r;if(l)return c&&o.x.eq(s.x)&&o.y.eq(s.y)?null:s;if(c&&h)return null;if(c)return o;if(h)return a;const f=((t,e,n,i)=>{if(e.x.isZero())return re(n,i,t.x);if(i.x.isZero())return re(t,e,n.x);if(e.y.isZero())return ie(n,i,t.y);if(i.y.isZero())return ie(t,e,n.y);const r=$t(e,i);if(r.isZero())return null;const o={x:n.x.minus(t.x),y:n.y.minus(t.y)},s=$t(o,e).div(r),a=$t(o,i).div(r),l=t.x.plus(a.times(e.x)),u=n.x.plus(s.times(i.x)),h=t.y.plus(a.times(e.y)),c=n.y.plus(s.times(i.y));return{x:l.plus(u).div(2),y:h.plus(c).div(2)}})(r,this.vector(),s,t.vector());return null===f?null:Zt(i,f)?Wt.snap(f):null}split(e){const n=[],i=void 0!==e.events,r=new oe(e,!0),o=new oe(e,!1),s=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(r);const a=new t(r,s,this.rings.slice(),this.windings.slice());return oe.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),oe.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),o.checkForConsuming()),n}swapEvents(){const t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,n=this.windings.length;e<n;e++)this.windings[e]*=-1}consume(e){let n=this,i=e;for(;n.consumedBy;)n=n.consumedBy;for(;i.consumedBy;)i=i.consumedBy;const r=t.compare(n,i);if(0!==r){if(r>0){const t=n;n=i,i=t}if(n.prev===i){const t=n;n=i,i=t}for(let t=0,e=i.rings.length;t<e;t++){const e=i.rings[t],r=i.windings[t],o=n.rings.indexOf(e);-1===o?(n.rings.push(e),n.windings.push(r)):n.windings[o]+=r}i.rings=null,i.windings=null,i.consumedBy=n,i.leftSE.consumedBy=n.leftSE,i.rightSE.consumedBy=n.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};const e=this._afterState.rings,n=this._afterState.windings,i=this._afterState.multiPolys;for(let s=0,a=this.rings.length;s<a;s++){const t=this.rings[s],i=this.windings[s],r=e.indexOf(t);-1===r?(e.push(t),n.push(i)):n[r]+=i}const r=[],o=[];for(let s=0,a=e.length;s<a;s++){if(0===n[s])continue;const t=e[s],i=t.poly;if(-1===o.indexOf(i))if(t.isExterior)r.push(i);else{-1===o.indexOf(i)&&o.push(i);const e=r.indexOf(t.poly);-1!==e&&r.splice(e,1)}}for(let s=0,a=r.length;s<a;s++){const t=r[s].multiPoly;-1===i.indexOf(t)&&i.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(ce.type){case"union":{const n=0===t.length,i=0===e.length;this._isInResult=n!==i;break}case"intersection":{let n,i;t.length<e.length?(n=t.length,i=e.length):(n=e.length,i=t.length),this._isInResult=i===ce.numMultiPolys&&n<i;break}case"xor":{const n=Math.abs(t.length-e.length);this._isInResult=n%2==1;break}case"difference":{const n=t=>1===t.length&&t[0].isSubject;this._isInResult=n(t)!==n(e);break}}return this._isInResult}},de=class{constructor(t,e,n){if(r(this,"poly"),r(this,"isExterior"),r(this,"segments"),r(this,"bbox"),!Array.isArray(t)||0===t.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=n,this.segments=[],"number"!=typeof t[0][0]||"number"!=typeof t[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const i=Wt.snap({x:new Dt(t[0][0]),y:new Dt(t[0][1])});this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};let o=i;for(let r=1,s=t.length;r<s;r++){if("number"!=typeof t[r][0]||"number"!=typeof t[r][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const e=Wt.snap({x:new Dt(t[r][0]),y:new Dt(t[r][1])});e.x.eq(o.x)&&e.y.eq(o.y)||(this.segments.push(ge.fromRing(o,e,this)),e.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.x),e.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.y),e.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.x),e.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.y),o=e)}i.x.eq(o.x)&&i.y.eq(o.y)||this.segments.push(ge.fromRing(o,i,this))}getSweepEvents(){const t=[];for(let e=0,n=this.segments.length;e<n;e++){const n=this.segments[e];t.push(n.leftSE),t.push(n.rightSE)}return t}},pe=class{constructor(t,e){if(r(this,"multiPoly"),r(this,"exteriorRing"),r(this,"interiorRings"),r(this,"bbox"),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new de(t[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let n=1,i=t.length;n<i;n++){const e=new de(t[n],this,!1);e.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.bbox.ll.x),e.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.bbox.ll.y),e.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.bbox.ur.x),e.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.bbox.ur.y),this.interiorRings.push(e)}this.multiPoly=e}getSweepEvents(){const t=this.exteriorRing.getSweepEvents();for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getSweepEvents();for(let e=0,i=n.length;e<i;e++)t.push(n[e])}return t}},ye=class{constructor(t,e){if(r(this,"isSubject"),r(this,"polys"),r(this,"bbox"),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof t[0][0][0]&&(t=[t])}catch(n){}this.polys=[],this.bbox={ll:{x:new Dt(Number.POSITIVE_INFINITY),y:new Dt(Number.POSITIVE_INFINITY)},ur:{x:new Dt(Number.NEGATIVE_INFINITY),y:new Dt(Number.NEGATIVE_INFINITY)}};for(let i=0,r=t.length;i<r;i++){const e=new pe(t[i],this);e.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.bbox.ll.x),e.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.bbox.ll.y),e.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.bbox.ur.x),e.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.bbox.ur.y),this.polys.push(e)}this.isSubject=e}getSweepEvents(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getSweepEvents();for(let e=0,i=n.length;e<i;e++)t.push(n[e])}return t}};Wt.set;var ve=function(t,e={}){const n=[];if(M(t,t=>{n.push(t.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const i=((t,...e)=>ce.run("union",t,e))(n[0],...n.slice(1));return 0===i.length?null:1===i.length?d(i[0],e.properties):v(i,e.properties)};var me=function(t,e={}){const n=[];if(M(t,t=>{n.push(t.coordinates)}),n.length<2)throw new Error("Must specify at least 2 geometries");const i=((t,...e)=>ce.run("intersection",t,e))(n[0],...n.slice(1));return 0===i.length?null:1===i.length?d(i[0],e.properties):v(i,e.properties)};var _e=function(t){const e=[];if(M(t,t=>{e.push(t.coordinates)}),e.length<2)throw new Error("Must have at least two features");const n=t.features[0].properties||{},i=((t,...e)=>ce.run("difference",t,e))(e[0],...e.slice(1));return 0===i.length?null:1===i.length?d(i[0],n):v(i,n)};var ke=function(t){const e=[];return"FeatureCollection"===t.type?I(t,function(t){w(t,function(n){e.push(g(n,t.properties))})}):"Feature"===t.type?w(t,function(n){e.push(g(n,t.properties))}):w(t,function(t){e.push(g(t))}),y(e)};function xe(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return w(t,t=>{n[0]>t[0]&&(n[0]=t[0]),n[1]>t[1]&&(n[1]=t[1]),n[2]<t[0]&&(n[2]=t[0]),n[3]<t[1]&&(n[3]=t[1])}),n}var Ee=xe;var we,Ie={exports:{}};var Me=(we||(we=1,Ie.exports=function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e(t,e,n){return e=l(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(e,n||[],l(t).constructor):e.apply(t,n))}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){if(h())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var r=new(t.bind.apply(t,i));return n&&c(r,n.prototype),r}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,d(i.key),i)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=p(t))||e){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function a(){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},a.apply(null,arguments)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!t})()}function c(t,e){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e,n,i){var r=a(l(1&i?t.prototype:t),e,n);return 2&i&&"function"==typeof r?function(t){return r.apply(n,t)}:r}function g(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return i(t,arguments,l(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},y(t)}var v=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=t.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=t.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==t.JOIN_ROUND&&(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(t){this._joinStyle=t}},{key:"setSimplifyFactor",value:function(t){this._simplifyFactor=t<0?0:t}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(t){this._endCapStyle=t}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(t){this._mitreLimit=t}},{key:"setSingleSided",value:function(t){this._isSingleSided=t}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(i)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}])}();v.CAP_ROUND=1,v.CAP_FLAT=2,v.CAP_SQUARE=3,v.JOIN_ROUND=1,v.JOIN_MITRE=2,v.JOIN_BEVEL=3,v.DEFAULT_QUADRANT_SEGMENTS=8,v.DEFAULT_MITRE_LIMIT=5,v.DEFAULT_SIMPLIFY_FACTOR=.01;var m=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({Exception:i})[0],r}return u(i,t),o(i,[{key:"toString",value:function(){return this.message}}])}(y(Error)),_=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({IllegalArgumentException:i})[0],r}return u(i,t),o(i)}(m),k=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]);function x(){}function E(){}function w(){}var I,M,b,S,N,L,P,C,T=o(function t(){n(this,t)},null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}]),O=o(function t(e,i){n(this,t),this.low=i||0,this.high=e||0},null,[{key:"toBinaryString",value:function(t){var e,n="";for(e=2147483648;e>0;e>>>=1)n+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)n+=(t.low&e)===e?"1":"0";return n}}]);function A(){}function D(){}A.NaN=NaN,A.isNaN=function(t){return Number.isNaN(t)},A.isInfinite=function(t){return!Number.isFinite(t)},A.MAX_VALUE=Number.MAX_VALUE,A.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,A.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(L=2146435072,P=new Float64Array(1),C=new Int32Array(P.buffer),A.doubleToLongBits=function(t){P[0]=t;var e=0|C[0],n=0|C[1];return(n&L)===L&&1048575&n&&0!==e&&(e=0,n=2146959360),new O(n,e)},A.longBitsToDouble=function(t){return C[0]=t.low,C[1]=t.high,P[0]}):(I=1023,M=Math.log2,b=Math.floor,S=Math.pow,N=function(){for(var t=53;t>0;t--){var e=S(2,t)-1;if(b(M(e))+1===t)return e}return 0}(),A.doubleToLongBits=function(t){var e,n,i,r,o,s,a,l,u;if(t<0||1/t===Number.NEGATIVE_INFINITY?(s=1<<31,t=-t):s=0,0===t)return new O(l=s,u=0);if(t===1/0)return new O(l=2146435072|s,u=0);if(t!=t)return new O(l=2146959360,u=0);if(r=0,u=0,(e=b(t))>1)if(e<=N)(r=b(M(e)))<=20?(u=0,l=e<<20-r&1048575):(u=e%(n=S(2,i=r-20))<<32-i,l=e/n&1048575);else for(i=e,u=0;0!==(i=b(n=i/2));)r++,u>>>=1,u|=(1&l)<<31,l>>>=1,n!==i&&(l|=524288);if(a=r+I,o=0===e,e=t-e,r<52&&0!==e)for(i=0;;){if((n=2*e)>=1?(e=n-1,o?(a--,o=!1):(i<<=1,i|=1,r++)):(e=n,o?0==--a&&(r++,o=!1):(i<<=1,r++)),20===r)l|=i,i=0;else if(52===r){u|=i;break}if(1===n){r<20?l|=i<<20-r:r<52&&(u|=i<<52-r);break}}return l|=a<<20,new O(l|=s,u)},A.longBitsToDouble=function(t){var e,n,i,r,o=t.high,s=t.low,a=o&1<<31?-1:1;for(i=((2146435072&o)>>20)-I,r=0,n=1<<19,e=1;e<=20;e++)o&n&&(r+=S(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)s&n&&(r+=S(2,-e)),n>>>=1;if(-1023===i){if(0===r)return 0*a;i=-1022}else{if(1024===i)return 0===r?a/0:NaN;r+=1}return a*r*S(2,i)});var R=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({RuntimeException:i})[0],r}return u(i,t),o(i)}(m),F=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,null,[{key:"constructor_",value:function(){if(0===arguments.length)R.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];R.constructor_.call(this,t)}}}])}(R),G=function(){function t(){n(this,t)}return o(t,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)t.shouldNeverReachHere(null);else if(1===arguments.length){var e=arguments[0];throw new F("Should never reach here"+(null!==e?": "+e:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var e=arguments[0];t.isTrue(e,null)}else if(2===arguments.length){var n=arguments[1];if(!arguments[0])throw null===n?new F:new F(n)}}},{key:"equals",value:function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];t.equals(e,n,null)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];if(!r.equals(i))throw new F("Expected "+i+" but encountered "+r+(null!==o?": "+o:""))}}}])}(),B=new ArrayBuffer(8),Y=new Float64Array(B),q=new Int32Array(B),z=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getM",value:function(){return A.NaN}},{key:"setOrdinate",value:function(e,n){switch(e){case t.X:this.x=n;break;case t.Y:this.y=n;break;case t.Z:this.setZ(n);break;default:throw new _("Invalid ordinate index: "+e)}}},{key:"equals2D",value:function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!T.equalsWithTolerance(this.x,e.x,n)&&!!T.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(e){throw new _("Invalid ordinate index: "+t.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(e){switch(e){case t.X:return this.x;case t.Y:return this.y;case t.Z:return this.getZ()}throw new _("Invalid ordinate index: "+e)}},{key:"equals3D",value:function(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||A.isNaN(this.getZ())&&A.isNaN(t.getZ()))}},{key:"equals",value:function(e){return e instanceof t&&this.equals2D(e)}},{key:"equalInZ",value:function(t,e){return T.equalsWithTolerance(this.getZ(),t.getZ(),e)}},{key:"setX",value:function(t){this.x=t}},{key:"compareTo",value:function(t){var e=t;return this.x<e.x?-1:this.x>e.x?1:this.y<e.y?-1:this.y>e.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(t){this.z=t}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return G.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new t(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+i*i)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(t){this.y=t}},{key:"distance",value:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var e=17;return 37*(e=37*e+t.hashCode(this.x))+t.hashCode(this.y)}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}},{key:"interfaces_",get:function(){return[x,E,w]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)t.constructor_.call(this,0,0);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.x,e.y,e.getZ())}else if(2===arguments.length){var n=arguments[0],i=arguments[1];t.constructor_.call(this,n,i,t.NULL_ORDINATE)}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this.x=r,this.y=o,this.z=s}}},{key:"hashCode",value:function(t){return Y[0]=t,q[0]^q[1]}}])}(),H=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compare",value:function(e,n){var i=t.compare(e.x,n.x);if(0!==i)return i;var r=t.compare(e.y,n.y);return 0!==r?r:this._dimensionsToTest<=2?0:t.compare(e.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[D]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)t.constructor_.call(this,2);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new _("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}},{key:"compare",value:function(t,e){return t<e?-1:t>e?1:A.isNaN(t)?A.isNaN(e)?0:-1:A.isNaN(e)?1:0}}])}();z.DimensionalComparator=H,z.NULL_ORDINATE=A.NaN,z.X=0,z.Y=1,z.Z=2,z.M=3;var U=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.isNull()?n.isNull():this._maxx===n.getMaxX()&&this._maxy===n.getMaxY()&&this._minx===n.getMinX()&&this._miny===n.getMinY()}},{key:"intersection",value:function(e){if(this.isNull()||e.isNull()||!this.intersects(e))return new t;var n=this._minx>e._minx?this._minx:e._minx,i=this._miny>e._miny?this._miny:e._miny;return new t(n,this._maxx<e._maxx?this._maxx:e._maxx,i,this._maxy<e._maxy?this._maxy:e._maxy)}},{key:"isNull",value:function(){return this._maxx<this._minx}},{key:"getMaxX",value:function(){return this._maxx}},{key:"covers",value:function(){if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];return this.covers(e.x,e.y)}if(arguments[0]instanceof t){var n=arguments[0];return!this.isNull()&&!n.isNull()&&n.getMinX()>=this._minx&&n.getMaxX()<=this._maxx&&n.getMinY()>=this._miny&&n.getMaxY()<=this._maxy}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return!this.isNull()&&i>=this._minx&&i<=this._maxx&&r>=this._miny&&r<=this._maxy}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return!this.isNull()&&!e.isNull()&&!(e._minx>this._maxx||e._maxx<this._minx||e._miny>this._maxy||e._maxy<this._miny)}if(arguments[0]instanceof z){var n=arguments[0];return this.intersects(n.x,n.y)}}else if(2===arguments.length){if(arguments[0]instanceof z&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1];return!(this.isNull()||(i.x<r.x?i.x:r.x)>this._maxx||(i.x>r.x?i.x:r.x)<this._minx||(i.y<r.y?i.y:r.y)>this._maxy||(i.y>r.y?i.y:r.y)<this._miny)}if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return!this.isNull()&&!(o>this._maxx||o<this._minx||s>this._maxy||s<this._miny)}}}},{key:"getMinY",value:function(){return this._miny}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return Math.sqrt(t*t+e*e)}},{key:"getMinX",value:function(){return this._minx}},{key:"expandToInclude",value:function(){if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.expandToInclude(e.x,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];if(n.isNull())return null;this.isNull()?(this._minx=n.getMinX(),this._maxx=n.getMaxX(),this._miny=n.getMinY(),this._maxy=n.getMaxY()):(n._minx<this._minx&&(this._minx=n._minx),n._maxx>this._maxx&&(this._maxx=n._maxx),n._miny<this._miny&&(this._miny=n._miny),n._maxy>this._maxy&&(this._maxy=n._maxy))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.isNull()?(this._minx=i,this._maxx=i,this._miny=r,this._maxy=r):(i<this._minx&&(this._minx=i),i>this._maxx&&(this._maxx=i),r<this._miny&&(this._miny=r),r>this._maxy&&(this._maxy=r))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t<e?t:e}},{key:"getWidth",value:function(){return this.isNull()?0:this._maxx-this._minx}},{key:"compareTo",value:function(t){var e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this._minx<e._minx?-1:this._minx>e._minx?1:this._miny<e._miny?-1:this._miny>e._miny?1:this._maxx<e._maxx?-1:this._maxx>e._maxx?1:this._maxy<e._maxy?-1:this._maxy>e._maxy?1:0}},{key:"translate",value:function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}},{key:"copy",value:function(){return new t(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(t){return!(!this.isNull()&&!t.isNull())||t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny}},{key:"getHeight",value:function(){return this.isNull()?0:this._maxy-this._miny}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e}},{key:"expandBy",value:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.covers(e)}if(arguments[0]instanceof z){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return this.covers(i,r)}}},{key:"centre",value:function(){return this.isNull()?null:new z((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this._minx=n._minx,this._maxx=n._maxx,this._miny=n._miny,this._maxy=n._maxy}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];o<s?(this._minx=o,this._maxx=s):(this._minx=s,this._maxx=o),a<l?(this._miny=a,this._maxy=l):(this._miny=l,this._maxy=a)}}},{key:"getMaxY",value:function(){return this._maxy}},{key:"distance",value:function(t){if(this.intersects(t))return 0;var e=0;this._maxx<t._minx?e=t._minx-this._maxx:this._minx>t._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxy<t._miny?n=t._miny-this._maxy:this._miny>t._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*(t=37*(t=37*t+z.hashCode(this._minx))+z.hashCode(this._maxx))+z.hashCode(this._miny))+z.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[x,w]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];this.init(o,s,a,l)}}},{key:"intersects",value:function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.x<e.x?t.x:e.x)&&n.x<=(t.x>e.x?t.x:e.x)&&n.y>=(t.y<e.y?t.y:e.y)&&n.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),l=Math.max(o.x,s.x),u=Math.min(i.x,r.x),h=Math.max(i.x,r.x);return!(u>l||h<a||(a=Math.min(o.y,s.y),l=Math.max(o.y,s.y),u=Math.min(i.y,r.y),h=Math.max(i.y,r.y),u>l||h<a))}}}])}(),X=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this._factory}},{key:"getGeometryN",value:function(t){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(t){return this===t||this.equalsExact(t,0)}},{key:"geometryChanged",value:function(){this.apply(t.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this._envelope=null}},{key:"equalsNorm",value:function(t){return null!==t&&this.norm().equalsExact(t.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var t;if(1===arguments.length){var e=arguments[0];return t=e,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(e)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return t=n,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(n,i)}}},{key:"getUserData",value:function(){return this._userData}},{key:"getSRID",value:function(){return this._SRID}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(e){if(e.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION)throw new _("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(t,e,n){return 0===n?t.equals(e):t.distance(e)<=n}},{key:"norm",value:function(){var t=this.copy();return t.normalize(),t}},{key:"reverse",value:function(){var t=this.reverseInternal();return null!=this.envelope&&(t.envelope=this.envelope.copy()),t.setSRID(this.getSRID()),t}},{key:"copy",value:function(){var t=this.copyInternal();return t.envelope=null==this._envelope?null:this._envelope.copy(),t._SRID=this._SRID,t._userData=this._userData,t}},{key:"getPrecisionModel",value:function(){return this._factory.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new U(this._envelope)}},{key:"setSRID",value:function(t){this._SRID=t}},{key:"setUserData",value:function(t){this._userData=t}},{key:"compare",value:function(t,e){for(var n=t.iterator(),i=e.iterator();n.hasNext()&&i.hasNext();){var r=n.next(),o=i.next(),s=r.compareTo(o);if(0!==s)return s}return n.hasNext()?1:i.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(t){return this.getClass()===t.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===t.TYPECODE_MULTIPOINT||this.getTypeCode()===t.TYPECODE_MULTILINESTRING||this.getTypeCode()===t.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[E,x,w]}},{key:"getClass",value:function(){return t}}],[{key:"hasNonEmptyElements",value:function(t){for(var e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(t){for(var e=0;e<t.length;e++)if(null===t[e])return!0;return!1}}])}();X.constructor_=function(t){t&&(this._envelope=null,this._userData=null,this._factory=t,this._SRID=t.getSRID())},X.TYPECODE_POINT=0,X.TYPECODE_MULTIPOINT=1,X.TYPECODE_LINESTRING=2,X.TYPECODE_LINEARRING=3,X.TYPECODE_MULTILINESTRING=4,X.TYPECODE_POLYGON=5,X.TYPECODE_MULTIPOLYGON=6,X.TYPECODE_GEOMETRYCOLLECTION=7,X.TYPENAME_POINT="Point",X.TYPENAME_MULTIPOINT="MultiPoint",X.TYPENAME_LINESTRING="LineString",X.TYPENAME_LINEARRING="LinearRing",X.TYPENAME_MULTILINESTRING="MultiLineString",X.TYPENAME_POLYGON="Polygon",X.TYPENAME_MULTIPOLYGON="MultiPolygon",X.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",X.geometryChangedFilter={get interfaces_(){return[k]},filter:function(t){t.geometryChangedAction()}};var V=function(){function t(){n(this,t)}return o(t,null,[{key:"toLocationSymbol",value:function(e){switch(e){case t.EXTERIOR:return"e";case t.BOUNDARY:return"b";case t.INTERIOR:return"i";case t.NONE:return"-"}throw new _("Unknown location value: "+e)}}])}();V.INTERIOR=0,V.BOUNDARY=1,V.EXTERIOR=2,V.NONE=-1;var j=o(function t(){n(this,t)},[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}]),K=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({NoSuchElementException:i})[0],r}return u(i,t),o(i)}(m),W=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({UnsupportedOperationException:i})[0],r}return u(i,t),o(i)}(m),Z=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i,[{key:"contains",value:function(){}}])}(j),J=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).map=new Map,t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"contains",value:function(t){var e=t.hashCode?t.hashCode():t;return!!this.map.has(e)}},{key:"add",value:function(t){var e=t.hashCode?t.hashCode():t;return!this.map.has(e)&&!!this.map.set(e,t)}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(r){n.e(r)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new W}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return 0===this.map.size}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new $(this.map)}},{key:Symbol.iterator,value:function(){return this.map}}])}(Z),$=o(function t(e){n(this,t),this.iterator=e.values();var i=this.iterator.next(),r=i.done,o=i.value;this.done=r,this.value=o},[{key:"next",value:function(){if(this.done)throw new K;var t=this.value,e=this.iterator.next(),n=e.done,i=e.value;return this.done=n,this.value=i,t}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new W}}]),Q=function(){function t(){n(this,t)}return o(t,null,[{key:"opposite",value:function(e){return e===t.LEFT?t.RIGHT:e===t.RIGHT?t.LEFT:e}}])}();Q.ON=0,Q.LEFT=1,Q.RIGHT=2;var tt=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({EmptyStackException:i})[0],r}return u(i,t),o(i)}(m),et=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({IndexOutOfBoundsException:i})[0],r}return u(i,t),o(i)}(m),nt=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}])}(j),it=function(t){function i(){var t;return n(this,i),(t=e(this,i)).array=[],t}return u(i,t),o(i,[{key:"add",value:function(t){return this.array.push(t),!0}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new et;return this.array[t]}},{key:"push",value:function(t){return this.array.push(t),t}},{key:"pop",value:function(){if(0===this.array.length)throw new tt;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new tt;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(t){return this.array.indexOf(t)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}])}(nt);function rt(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var ot=o(function t(e){n(this,t),this.str=e},[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),st=function(){function t(e){n(this,t),this.value=e}return o(t,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(t){return this.value<t?-1:this.value>t?1:0}}],[{key:"compare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"isNan",value:function(t){return Number.isNaN(t)}},{key:"valueOf",value:function(e){return new t(e)}}])}(),at=o(function t(){n(this,t)},null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}]),lt=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"le",value:function(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<=t._lo}},{key:"extractSignificantDigits",value:function(e,n){var i=this.abs(),r=t.magnitude(i._hi),o=t.TEN.pow(r);(i=i.divide(o)).gt(t.TEN)?(i=i.divide(t.TEN),r+=1):i.lt(t.ONE)&&(i=i.multiply(t.TEN),r-=1);for(var s=r+1,a=new ot,l=t.MAX_PRINT_DIGITS-1,u=0;u<=l;u++){e&&u===s&&a.append(".");var h=Math.trunc(i._hi);if(h<0)break;var c=!1,f=0;h>9?(c=!0,f="9"):f="0"+h,a.append(f),i=i.subtract(t.valueOf(h)).multiply(t.TEN),c&&i.selfAdd(t.TEN);var g=!0,d=t.magnitude(i._hi);if(d<0&&Math.abs(d)>=l-u&&(g=!1),!g)break}return n[0]=r,a.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 t){var e=arguments[0];return this.add(e.negate())}if("number"==typeof arguments[0]){var n=arguments[0];return this.add(-n)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof t){var e=arguments[0];return this._hi===e._hi&&this._lo===e._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e._hi,-e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.isNaN()?this:this.selfAdd(-n,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(t){return this.le(t)?this:t}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfDivide(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var i,r,o,s,a=arguments[0],l=arguments[1],u=null,h=null,c=null,f=null;return o=this._hi/a,f=(u=(c=t.SPLIT*o)-(u=c-o))*(h=(f=t.SPLIT*a)-(h=f-a))-(s=o*a)+u*(r=a-h)+(i=o-u)*h+i*r,f=o+(c=(this._hi-s-f+this._lo-o*l)/a),this._hi=f,this._lo=o-f+c,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof t){var e,n,i,r,o=arguments[0],s=null,a=null,l=null,u=null;return e=(i=this._hi/o._hi)-(s=(l=t.SPLIT*i)-(s=l-i)),u=s*(a=(u=t.SPLIT*o._hi)-(a=u-o._hi))-(r=i*o._hi)+s*(n=o._hi-a)+e*a+e*n,new t(u=i+(l=(this._hi-r-u+this._lo-i*o._lo)/o._hi),i-u+l)}if("number"==typeof arguments[0]){var h=arguments[0];return A.isNaN(h)?t.createNaN():t.copy(this).selfDivide(h,0)}}},{key:"ge",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}},{key:"pow",value:function(e){if(0===e)return t.valueOf(1);var n=new t(this),i=t.valueOf(1),r=Math.abs(e);if(r>1)for(;r>0;)r%2==1&&i.selfMultiply(n),(r/=2)>0&&(n=n.sqr());else i=n;return e<0?i.reciprocal():i}},{key:"ceil",value:function(){if(this.isNaN())return t.NaN;var e=Math.ceil(this._hi),n=0;return e===this._hi&&(n=Math.ceil(this._lo)),new t(e,n)}},{key:"compareTo",value:function(t){var e=t;return this._hi<e._hi?-1:this._hi>e._hi?1:this._lo<e._lo?-1:this._lo>e._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.init(e),this}if("number"==typeof arguments[0]){var n=arguments[0];return this.init(n),this}}},{key:"max",value:function(t){return this.ge(t)?this:t}},{key:"sqrt",value:function(){if(this.isZero())return t.valueOf(0);if(this.isNegative())return t.NaN;var e=1/Math.sqrt(this._hi),n=this._hi*e,i=t.valueOf(n),r=this.subtract(i.sqr())._hi*(.5*e);return i.add(r)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfAdd(e._hi,e._lo)}if("number"==typeof arguments[0]){var n,i,r,o,s,a=arguments[0],l=null;return l=(r=this._hi+a)-(o=r-this._hi),i=(s=(l=a-o+(this._hi-l))+this._lo)+(r-(n=r+s)),this._hi=n+i,this._lo=i+(n-this._hi),this}}else if(2===arguments.length){var u,h,c,f,g=arguments[0],d=arguments[1],p=null,y=null,v=null;c=this._hi+g,h=this._lo+d,y=c-(v=c-this._hi),p=h-(f=h-this._lo);var m=(u=c+(v=(y=g-v+(this._hi-y))+h))+(v=(p=d-f+(this._lo-p))+(v+(c-u))),_=v+(u-m);return this._hi=m,this._lo=_,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfMultiply(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var i,r,o=arguments[0],s=arguments[1],a=null,l=null,u=null,h=null;a=(u=t.SPLIT*this._hi)-this._hi,h=t.SPLIT*o,a=u-a,i=this._hi-a,l=h-o;var c=(u=this._hi*o)+(h=a*(l=h-l)-u+a*(r=o-l)+i*l+i*r+(this._hi*s+this._lo*o)),f=h+(a=u-c);return this._hi=c,this._lo=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return t.NaN;var e=Math.floor(this._hi),n=0;return e===this._hi&&(n=Math.floor(this._lo)),new t(e,n)}},{key:"negate",value:function(){return this.isNaN()?this:new t(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}},{key:"multiply",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return e.isNaN()?t.createNaN():t.copy(this).selfMultiply(e)}if("number"==typeof arguments[0]){var n=arguments[0];return A.isNaN(n)?t.createNaN():t.copy(this).selfMultiply(n,0)}}},{key:"isNaN",value:function(){return A.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var e=t.magnitude(this._hi);return e>=-3&&e<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!0,n),r=n[0]+1,o=i;if("."===i.charAt(0))o="0"+i;else if(r<0)o="0."+t.stringOfChar("0",-r)+i;else if(-1===i.indexOf(".")){var s=r-i.length;o=i+t.stringOfChar("0",s)+".0"}return this.isNegative()?"-"+o:o}},{key:"reciprocal",value:function(){var e,n,i,r,o=null,s=null,a=null,l=null;e=(i=1/this._hi)-(o=(a=t.SPLIT*i)-(o=a-i)),s=(l=t.SPLIT*this._hi)-this._hi;var u=i+(a=(1-(r=i*this._hi)-(l=o*(s=l-s)-r+o*(n=this._hi-s)+e*s+e*n)-i*this._lo)/this._hi);return new t(u,i-u+a)}},{key:"toSciNotation",value:function(){if(this.isZero())return t.SCI_NOT_ZERO;var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!1,n),r=t.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===i.charAt(0))throw new IllegalStateException("Found leading zero: "+i);var o="";i.length>1&&(o=i.substring(1));var s=i.charAt(0)+"."+o;return this.isNegative()?"-"+s+r:s+r}},{key:"abs",value:function(){return this.isNaN()?t.NaN:this.isNegative()?this.negate():new t(this)}},{key:"isPositive",value:function(){return this._hi>0||0===this._hi&&this._lo>0}},{key:"lt",value:function(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<t._lo}},{key:"add",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return t.copy(this).selfAdd(e)}if("number"==typeof arguments[0]){var n=arguments[0];return t.copy(this).selfAdd(n)}}},{key:"init",value:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this._hi=e,this._lo=0}else if(arguments[0]instanceof t){var n=arguments[0];this._hi=n._hi,this._lo=n._lo}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this._hi=i,this._lo=r}}},{key:"gt",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>t._lo}},{key:"isNegative",value:function(){return this._hi<0||0===this._hi&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?t.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[w,x,E]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var i=arguments[0];t.constructor_.call(this,t.parse(i))}}else if(2===arguments.length){var r=arguments[0],o=arguments[1];this.init(r,o)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3];return t.determinant(t.valueOf(e),t.valueOf(n),t.valueOf(i),t.valueOf(r))}if(arguments[3]instanceof t&&arguments[2]instanceof t&&arguments[0]instanceof t&&arguments[1]instanceof t){var o=arguments[1],s=arguments[2],a=arguments[3];return arguments[0].multiply(a).selfSubtract(o.multiply(s))}}},{key:"sqr",value:function(e){return t.valueOf(e).selfMultiply(e)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var e=arguments[0];return t.parse(e)}if("number"==typeof arguments[0])return new t(arguments[0])}},{key:"sqrt",value:function(e){return t.valueOf(e).sqrt()}},{key:"parse",value:function(e){for(var n=0,i=e.length;at.isWhitespace(e.charAt(n));)n++;var r=!1;if(n<i){var o=e.charAt(n);"-"!==o&&"+"!==o||(n++,"-"===o&&(r=!0))}for(var s=new t,a=0,l=0,u=0,h=!1;!(n>=i);){var c=e.charAt(n);if(n++,at.isDigit(c)){var f=c-"0";s.selfMultiply(t.TEN),s.selfAdd(f),a++}else{if("."!==c){if("e"===c||"E"===c){var g=e.substring(n);try{u=st.parseInt(g)}catch(m){throw m instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+g+" in string "+e):m}break}throw new NumberFormatException("Unexpected character '"+c+"' at position "+n+" in string "+e)}l=a,h=!0}}var d=s;h||(l=a);var p=a-l-u;if(0===p)d=s;else if(p>0){var y=t.TEN.pow(p);d=s.divide(y)}else if(p<0){var v=t.TEN.pow(-p);d=s.multiply(v)}return r?d.negate():d}},{key:"createNaN",value:function(){return new t(A.NaN,A.NaN)}},{key:"copy",value:function(e){return new t(e)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i}},{key:"stringOfChar",value:function(t,e){for(var n=new ot,i=0;i<e;i++)n.append(t);return n.toString()}}])}();lt.PI=new lt(3.141592653589793,12246467991473532e-32),lt.TWO_PI=new lt(6.283185307179586,24492935982947064e-32),lt.PI_2=new lt(1.5707963267948966,6123233995736766e-32),lt.E=new lt(2.718281828459045,14456468917292502e-32),lt.NaN=new lt(A.NaN,A.NaN),lt.EPS=123259516440783e-46,lt.SPLIT=134217729,lt.MAX_PRINT_DIGITS=32,lt.TEN=lt.valueOf(10),lt.ONE=lt.valueOf(1),lt.SCI_NOT_EXPONENT_CHAR="E",lt.SCI_NOT_ZERO="0.0E0";var ut=function(){function t(){n(this,t)}return o(t,null,[{key:"orientationIndex",value:function(e,n,i){var r=t.orientationIndexFilter(e,n,i);if(r<=1)return r;var o=lt.valueOf(n.x).selfAdd(-e.x),s=lt.valueOf(n.y).selfAdd(-e.y),a=lt.valueOf(i.x).selfAdd(-n.x),l=lt.valueOf(i.y).selfAdd(-n.y);return o.selfMultiply(l).selfSubtract(s.selfMultiply(a)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof lt&&arguments[2]instanceof lt&&arguments[0]instanceof lt&&arguments[1]instanceof lt){var t=arguments[1],e=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(t.multiply(e)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=lt.valueOf(i),l=lt.valueOf(r),u=lt.valueOf(o),h=lt.valueOf(s);return a.multiply(h).selfSubtract(l.multiply(u)).signum()}}},{key:"intersection",value:function(t,e,n,i){var r=new lt(t.y).selfSubtract(e.y),o=new lt(e.x).selfSubtract(t.x),s=new lt(t.x).selfMultiply(e.y).selfSubtract(new lt(e.x).selfMultiply(t.y)),a=new lt(n.y).selfSubtract(i.y),l=new lt(i.x).selfSubtract(n.x),u=new lt(n.x).selfMultiply(i.y).selfSubtract(new lt(i.x).selfMultiply(n.y)),h=o.multiply(u).selfSubtract(l.multiply(s)),c=a.multiply(s).selfSubtract(r.multiply(u)),f=r.multiply(l).selfSubtract(a.multiply(o)),g=h.selfDivide(f).doubleValue(),d=c.selfDivide(f).doubleValue();return A.isNaN(g)||A.isInfinite(g)||A.isNaN(d)||A.isInfinite(d)?null:new z(g,d)}},{key:"orientationIndexFilter",value:function(e,n,i){var r=null,o=(e.x-i.x)*(n.y-i.y),s=(e.y-i.y)*(n.x-i.x),a=o-s;if(o>0){if(s<=0)return t.signum(a);r=o+s}else{if(!(o<0))return t.signum(a);if(s>=0)return t.signum(a);r=-o-s}var l=t.DP_SAFE_EPSILON*r;return a>=l||-a>=l?t.signum(a):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}])}();ut.DP_SAFE_EPSILON=1e-15;var ht=o(function t(){n(this,t)},[{key:"getM",value:function(t){if(this.hasM()){var e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return A.NaN}},{key:"setOrdinate",value:function(t,e,n){}},{key:"getZ",value:function(t){return this.hasZ()?this.getOrdinate(t,2):A.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(t,e){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(t){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(t){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(t){}},{key:"copy",value:function(){}},{key:"getY",value:function(t){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[E]}}]);ht.X=0,ht.Y=1,ht.Z=2,ht.M=3;var ct=function(){function t(){n(this,t)}return o(t,null,[{key:"index",value:function(t,e,n){return ut.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var e=arguments[0],n=e.length-1;if(n<3)throw new _("Ring has fewer than 4 points, so orientation cannot be determined");for(var i=e[0],r=0,o=1;o<=n;o++){var s=e[o];s.y>i.y&&(i=s,r=o)}var a=r;do{(a-=1)<0&&(a=n)}while(e[a].equals2D(i)&&a!==r);var l=r;do{l=(l+1)%n}while(e[l].equals2D(i)&&l!==r);var u=e[a],h=e[l];if(u.equals2D(i)||h.equals2D(i)||u.equals2D(h))return!1;var c=t.index(u,i,h);return 0===c?u.x>h.x:c>0}if(rt(arguments[0],ht)){var f=arguments[0],g=f.size()-1;if(g<3)throw new _("Ring has fewer than 4 points, so orientation cannot be determined");for(var d=f.getCoordinate(0),p=0,y=1;y<=g;y++){var v=f.getCoordinate(y);v.y>d.y&&(d=v,p=y)}var m=null,k=p;do{(k-=1)<0&&(k=g),m=f.getCoordinate(k)}while(m.equals2D(d)&&k!==p);var x=null,E=p;do{E=(E+1)%g,x=f.getCoordinate(E)}while(x.equals2D(d)&&E!==p);if(m.equals2D(d)||x.equals2D(d)||m.equals2D(x))return!1;var w=t.index(m,d,x);return 0===w?m.x>x.x:w>0}}}])}();ct.CLOCKWISE=-1,ct.RIGHT=ct.CLOCKWISE,ct.COUNTERCLOCKWISE=1,ct.LEFT=ct.COUNTERCLOCKWISE,ct.COLLINEAR=0,ct.STRAIGHT=ct.COLLINEAR;var ft=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n}},{key:"findRightmostEdgeAtVertex",value:function(){var t=this._minDe.getEdge().getCoordinates();G.isTrue(this._minIndex>0&&this._minIndex<t.length,"rightmost point expected to be interior vertex of edge");var e=t[this._minIndex-1],n=t[this._minIndex+1],i=ct.index(this._minCoord,n,e),r=!1;(e.y<this._minCoord.y&&n.y<this._minCoord.y&&i===ct.COUNTERCLOCKWISE||e.y>this._minCoord.y&&n.y>this._minCoord.y&&i===ct.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var i=Q.LEFT;return n[e].y<n[e+1].y&&(i=Q.RIGHT),i}},{key:"getEdge",value:function(){return this._orientedDe}},{key:"checkForRightmostCoordinate",value:function(t){for(var e=t.getEdge().getCoordinates(),n=0;n<e.length-1;n++)(null===this._minCoord||e[n].x>this._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])}},{key:"findRightmostEdgeAtNode",value:function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}G.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Q.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),gt=function(t){function i(t,r){var o;return n(this,i),(o=e(this,i,[r?t+" [ "+r+" ]":t])).pt=r?new z(r):void 0,o.name=Object.keys({TopologyException:i})[0],o}return u(i,t),o(i,[{key:"getCoordinate",value:function(){return this.pt}}])}(R),dt=o(function t(){n(this,t),this.array=[]},[{key:"addLast",value:function(t){this.array.push(t)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}]),pt=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).array=[],t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"interfaces_",get:function(){return[nt,j]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.array.push(i)}}catch(r){n.e(r)}finally{n.f()}}},{key:"set",value:function(t,e){var n=this.array[t];return this.array[t]=e,n}},{key:"iterator",value:function(){return new yt(this)}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new et;return this.array[t]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(t){t?this.array.sort(function(e,n){return t.compare(e,n)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(t){for(var e=0,n=this.array.length;e<n;e++)if(this.array[e]===t)return!!this.array.splice(e,1);return!1}},{key:Symbol.iterator,value:function(){return this.array.values()}}])}(nt),yt=o(function t(e){n(this,t),this.arrayList=e,this.position=0},[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new K;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(t){return this.arrayList.set(this.position-1,t)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}]),vt=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"clearVisitedEdges",value:function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this._rightMostCoord}},{key:"computeNodeDepth",value:function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new gt("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var r=t.getEdges().iterator();r.hasNext();){var o=r.next();o.setVisited(!0),this.copySymDepths(o)}}},{key:"computeDepth",value:function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(Q.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)}},{key:"create",value:function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}},{key:"findResultEdges",value:function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(Q.RIGHT)>=1&&e.getDepth(Q.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}},{key:"computeDepths",value:function(t){var e=new J,n=new dt,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}}},{key:"compareTo",value:function(t){var e=t;return this._rightMostCoord.x<e._rightMostCoord.x?-1:this._rightMostCoord.x>e._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(null===this._env){for(var t=new U,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),i=0;i<n.length-1;i++)t.expandToInclude(n[i]);this._env=t}return this._env}},{key:"addReachable",value:function(t){var e=new it;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}}},{key:"copySymDepths",value:function(t){var e=t.getSym();e.setDepth(Q.LEFT,t.getDepth(Q.RIGHT)),e.setDepth(Q.RIGHT,t.getDepth(Q.LEFT))}},{key:"add",value:function(t,e){t.setVisited(!0),this._nodes.add(t);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();this._dirEdgeList.add(i);var r=i.getSym().getNode();r.isVisited()||e.push(r)}}},{key:"getNodes",value:function(){return this._nodes}},{key:"getDirectedEdges",value:function(){return this._dirEdgeList}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._finder=null,this._dirEdgeList=new pt,this._nodes=new pt,this._rightMostCoord=null,this._env=null,this._finder=new ft}}]),mt=o(function t(){n(this,t)},null,[{key:"intersection",value:function(t,e,n,i){var r=t.x<e.x?t.x:e.x,o=t.y<e.y?t.y:e.y,s=t.x>e.x?t.x:e.x,a=t.y>e.y?t.y:e.y,l=n.x<i.x?n.x:i.x,u=n.y<i.y?n.y:i.y,h=n.x>i.x?n.x:i.x,c=n.y>i.y?n.y:i.y,f=((r>l?r:l)+(s<h?s:h))/2,g=((o>u?o:u)+(a<c?a:c))/2,d=t.x-f,p=t.y-g,y=e.x-f,v=e.y-g,m=n.x-f,_=n.y-g,k=i.x-f,x=i.y-g,E=p-v,w=y-d,I=d*v-y*p,M=_-x,b=k-m,S=m*x-k*_,N=E*b-M*w,L=(w*S-b*I)/N,P=(M*I-E*S)/N;return A.isNaN(L)||A.isInfinite(L)||A.isNaN(P)||A.isInfinite(P)?null:new z(L+f,P+g)}}]),_t=o(function t(){n(this,t)},null,[{key:"arraycopy",value:function(t,e,n,i,r){for(var o=0,s=e;s<e+r;s++)n[i+o]=t[s],o++}},{key:"getProperty",value:function(t){return{"line.separator":"\n"}[t]}}]),kt=function(){function t(){n(this,t)}return o(t,null,[{key:"log10",value:function(e){var n=Math.log(e);return A.isInfinite(n)||A.isNaN(n)?n:n/t.LOG_10}},{key:"min",value:function(t,e,n,i){var r=t;return e<r&&(r=e),n<r&&(r=n),i<r&&(r=i),r}},{key:"clamp",value:function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],n=arguments[2];return t<e?e:t>n?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],o=arguments[2];return i<r?r:i>o?o:i}}},{key:"wrap",value:function(t,e){return t<0?e- -t%e:t%e}},{key:"max",value:function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var i=arguments[1],r=arguments[2],o=arguments[3],s=arguments[0];return i>s&&(s=i),r>s&&(s=r),o>s&&(s=o),s}}},{key:"average",value:function(t,e){return(t+e)/2}}])}();kt.LOG_10=Math.log(10);var xt=function(){function t(){n(this,t)}return o(t,null,[{key:"segmentToSegment",value:function(e,n,i,r){if(e.equals(n))return t.pointToSegment(e,i,r);if(i.equals(r))return t.pointToSegment(r,e,n);var o=!1;if(U.intersects(e,n,i,r)){var s=(n.x-e.x)*(r.y-i.y)-(n.y-e.y)*(r.x-i.x);if(0===s)o=!0;else{var a=(e.y-i.y)*(r.x-i.x)-(e.x-i.x)*(r.y-i.y),l=((e.y-i.y)*(n.x-e.x)-(e.x-i.x)*(n.y-e.y))/s,u=a/s;(u<0||u>1||l<0||l>1)&&(o=!0)}}else o=!0;return o?kt.min(t.pointToSegment(e,i,r),t.pointToSegment(n,i,r),t.pointToSegment(i,e,n),t.pointToSegment(r,e,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;if(r<=0)return t.distance(e);if(r>=1)return t.distance(n);var o=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(o)*Math.sqrt(i)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)}},{key:"pointToSegmentString",value:function(e,n){if(0===n.length)throw new _("Line array must contain at least one vertex");for(var i=e.distance(n[0]),r=0;r<n.length-1;r++){var o=t.pointToSegment(e,n[r],n[r+1]);o<i&&(i=o)}return i}}])}(),Et=o(function t(){n(this,t)},[{key:"create",value:function(){if(1===arguments.length)arguments[0]instanceof Array||rt(arguments[0],ht);else if(2===arguments.length);else if(3===arguments.length){var t=arguments[0],e=arguments[1];return this.create(t,e)}}}]),wt=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]),It=o(function t(){n(this,t)},null,[{key:"ofLine",value:function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new z;t.getCoordinate(0,i);for(var r=i.x,o=i.y,s=1;s<e;s++){t.getCoordinate(s,i);var a=i.x,l=i.y,u=a-r,h=l-o;n+=Math.sqrt(u*u+h*h),r=a,o=l}return n}}]),Mt=o(function t(){n(this,t)}),bt=function(){function t(){n(this,t)}return o(t,null,[{key:"copyCoord",value:function(t,e,n,i){for(var r=Math.min(t.getDimension(),n.getDimension()),o=0;o<r;o++)n.setOrdinate(i,o,t.getOrdinate(e,o))}},{key:"isRing",value:function(t){var e=t.size();return 0===e||!(e<=3)&&t.getOrdinate(0,ht.X)===t.getOrdinate(e-1,ht.X)&&t.getOrdinate(0,ht.Y)===t.getOrdinate(e-1,ht.Y)}},{key:"scroll",value:function(){if(2===arguments.length){if(rt(arguments[0],ht)&&Number.isInteger(arguments[1])){var e=arguments[0],n=arguments[1];t.scroll(e,n,t.isRing(e))}else if(rt(arguments[0],ht)&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1],o=t.indexOf(r,i);if(o<=0)return null;t.scroll(i,o)}}else if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2];if(a<=0)return null;for(var u=s.copy(),h=l?s.size()-1:s.size(),c=0;c<h;c++)for(var f=0;f<s.getDimension();f++)s.setOrdinate(c,f,u.getOrdinate((a+c)%h,f));if(l)for(var g=0;g<s.getDimension();g++)s.setOrdinate(h,g,s.getOrdinate(0,g))}}},{key:"isEqual",value:function(t,e){var n=t.size();if(n!==e.size())return!1;for(var i=Math.min(t.getDimension(),e.getDimension()),r=0;r<n;r++)for(var o=0;o<i;o++){var s=t.getOrdinate(r,o),a=e.getOrdinate(r,o);if(!(t.getOrdinate(r,o)===e.getOrdinate(r,o)||A.isNaN(s)&&A.isNaN(a)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(1===arguments.length){var e=arguments[0];return t.minCoordinateIndex(e,0,e.size()-1)}if(3===arguments.length){for(var n=arguments[0],i=arguments[2],r=-1,o=null,s=arguments[1];s<=i;s++){var a=n.getCoordinate(s);(null===o||o.compareTo(a)>0)&&(o=a,r=s)}return r}}},{key:"extend",value:function(e,n,i){var r=e.create(i,n.getDimension()),o=n.size();if(t.copy(n,0,r,0,o),o>0)for(var s=o;s<i;s++)t.copy(n,o-1,r,s,1);return r}},{key:"reverse",value:function(e){for(var n=e.size()-1,i=Math.trunc(n/2),r=0;r<=i;r++)t.swap(e,r,n-r)}},{key:"swap",value:function(t,e,n){if(e===n)return null;for(var i=0;i<t.getDimension();i++){var r=t.getOrdinate(e,i);t.setOrdinate(e,i,t.getOrdinate(n,i)),t.setOrdinate(n,i,r)}}},{key:"copy",value:function(e,n,i,r,o){for(var s=0;s<o;s++)t.copyCoord(e,n+s,i,r+s)}},{key:"ensureValidRing",value:function(e,n){var i=n.size();return 0===i?n:i<=3?t.createClosedRing(e,n,4):n.getOrdinate(0,ht.X)===n.getOrdinate(i-1,ht.X)&&n.getOrdinate(0,ht.Y)===n.getOrdinate(i-1,ht.Y)?n:t.createClosedRing(e,n,i+1)}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.size();n++)if(t.x===e.getOrdinate(n,ht.X)&&t.y===e.getOrdinate(n,ht.Y))return n;return-1}},{key:"createClosedRing",value:function(e,n,i){var r=e.create(i,n.getDimension()),o=n.size();t.copy(n,0,r,0,o);for(var s=o;s<i;s++)t.copy(n,0,r,s,1);return r}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.size();n++){var i=t.getCoordinate(n);(null===e||e.compareTo(i)>0)&&(e=i)}return e}}])}(),St=function(){function t(){n(this,t)}return o(t,null,[{key:"toDimensionSymbol",value:function(e){switch(e){case t.FALSE:return t.SYM_FALSE;case t.TRUE:return t.SYM_TRUE;case t.DONTCARE:return t.SYM_DONTCARE;case t.P:return t.SYM_P;case t.L:return t.SYM_L;case t.A:return t.SYM_A}throw new _("Unknown dimension value: "+e)}},{key:"toDimensionValue",value:function(e){switch(at.toUpperCase(e)){case t.SYM_FALSE:return t.FALSE;case t.SYM_TRUE:return t.TRUE;case t.SYM_DONTCARE:return t.DONTCARE;case t.SYM_P:return t.P;case t.SYM_L:return t.L;case t.SYM_A:return t.A}throw new _("Unknown dimension symbol: "+e)}}])}();St.P=0,St.L=1,St.A=2,St.FALSE=-1,St.TRUE=-2,St.DONTCARE=-3,St.SYM_FALSE="F",St.SYM_TRUE="T",St.SYM_DONTCARE="*",St.SYM_P="0",St.SYM_L="1",St.SYM_A="2";var Nt=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]),Lt=o(function t(){n(this,t)},[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),Pt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new U:this._points.expandEnvelope(new U)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new i(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._points.size()!==n._points.size())return!1;for(var r=0;r<this._points.size();r++)if(!this.equal(this._points.getCoordinate(r),n._points.getCoordinate(r),e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<Math.trunc(this._points.size()/2);t++){var e=this._points.size()-1-t;if(!this._points.getCoordinate(t).equals(this._points.getCoordinate(e))){if(this._points.getCoordinate(t).compareTo(this._points.getCoordinate(e))>0){var n=this._points.copy();bt.reverse(n),this._points=n}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?St.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var t=this._points.copy();return bt.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return X.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return It.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e<this._points.size()&&n<t._points.size();){var i=this._points.getCoordinate(e).compareTo(t._points.getCoordinate(n));if(0!==i)return i;e++,n++}return e<this._points.size()?1:n<t._points.size()?-1:0}if(2===arguments.length){var r=arguments[0];return arguments[1].compare(this._points,r._points)}}},{key:"apply",value:function(){if(rt(arguments[0],wt))for(var t=arguments[0],e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e));else if(rt(arguments[0],Lt)){var n=arguments[0];if(0===this._points.size())return null;for(var i=0;i<this._points.size()&&(n.filter(this._points,i),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else(rt(arguments[0],Nt)||rt(arguments[0],k))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){throw new W}},{key:"isEquivalentClass",value:function(t){return t instanceof i}},{key:"getCoordinateN",value:function(t){return this._points.getCoordinate(t)}},{key:"getGeometryType",value:function(){return X.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this._points}},{key:"isEmpty",value:function(){return 0===this._points.size()}},{key:"init",value:function(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new _("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this._points=t}},{key:"isCoordinate",value:function(t){for(var e=0;e<this._points.size();e++)if(this._points.getCoordinate(e).equals(t))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(t){return this.getFactory().createPoint(this._points.getCoordinate(t))}},{key:"interfaces_",get:function(){return[Mt]}}],[{key:"constructor_",value:function(){if(this._points=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];X.constructor_.call(this,e),this.init(t)}}}])}(X),Ct=o(function t(){n(this,t)}),Tt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){if(this.isEmpty())return new U;var t=new U;return t.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),t}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new i(this._coordinates.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&(!(!this.isEmpty()||!t.isEmpty())||this.isEmpty()===t.isEmpty()&&this.equal(t.getCoordinate(),this.getCoordinate(),e))}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this._coordinates.copy())}},{key:"getTypeCode",value:function(){return X.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0];return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length){var e=arguments[0];return arguments[1].compare(this._coordinates,e._coordinates)}}},{key:"apply",value:function(){if(rt(arguments[0],wt)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(rt(arguments[0],Lt)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else(rt(arguments[0],Nt)||rt(arguments[0],k))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return X.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this._coordinates}},{key:"getY",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return 0===this._coordinates.size()}},{key:"init",value:function(t){null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),G.isTrue(t.size()<=1),this._coordinates=t}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[Ct]}}],[{key:"constructor_",value:function(){this._coordinates=null;var t=arguments[0],e=arguments[1];X.constructor_.call(this,e),this.init(t)}}])}(X),Ot=function(){function t(){n(this,t)}return o(t,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var e=arguments[0];return Math.abs(t.ofRingSigned(e))}if(rt(arguments[0],ht)){var n=arguments[0];return Math.abs(t.ofRingSigned(n))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var t=arguments[0];if(t.length<3)return 0;for(var e=0,n=t[0].x,i=1;i<t.length-1;i++){var r=t[i].x-n,o=t[i+1].y;e+=r*(t[i-1].y-o)}return e/2}if(rt(arguments[0],ht)){var s=arguments[0],a=s.size();if(a<3)return 0;var l=new z,u=new z,h=new z;s.getCoordinate(0,u),s.getCoordinate(1,h);var c=u.x;h.x-=c;for(var f=0,g=1;g<a-1;g++)l.y=u.y,u.x=h.x,u.y=h.y,s.getCoordinate(g+1,h),h.x-=c,f+=u.x*(l.y-h.y);return f/2}}}])}(),At=o(function t(){n(this,t)},null,[{key:"sort",value:function(){var t=arguments,e=arguments[0];if(1===arguments.length)e.sort(function(t,e){return t.compareTo(e)});else if(2===arguments.length)e.sort(function(e,n){return t[1].compare(e,n)});else if(3===arguments.length){var n=e.slice(arguments[1],arguments[2]);n.sort();var i=e.slice(0,arguments[1]).concat(n,e.slice(arguments[2],e.length));e.splice(0,e.length);var r,o=s(i);try{for(o.s();!(r=o.n()).done;){var a=r.value;e.push(a)}}catch(g){o.e(g)}finally{o.f()}}else if(4===arguments.length){var l=e.slice(arguments[1],arguments[2]);l.sort(function(e,n){return t[3].compare(e,n)});var u=e.slice(0,arguments[1]).concat(l,e.slice(arguments[2],e.length));e.splice(0,e.length);var h,c=s(u);try{for(c.s();!(h=c.n()).done;){var f=h.value;e.push(f)}}catch(g){c.e(g)}finally{c.f()}}}},{key:"asList",value:function(t){var e,n=new pt,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n.add(r)}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"copyOf",value:function(t,e){return t.slice(0,e)}}]),Dt=o(function t(){n(this,t)}),Rt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){return this._shell.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=this._shell.getCoordinates(),i=0;i<n.length;i++)t[++e]=n[i];for(var r=0;r<this._holes.length;r++)for(var o=this._holes[r].getCoordinates(),s=0;s<o.length;s++)t[++e]=o[s];return t}},{key:"getArea",value:function(){var t=0;t+=Ot.ofRing(this._shell.getCoordinateSequence());for(var e=0;e<this._holes.length;e++)t-=Ot.ofRing(this._holes[e].getCoordinateSequence());return t}},{key:"copyInternal",value:function(){for(var t=this._shell.copy(),e=new Array(this._holes.length).fill(null),n=0;n<this._holes.length;n++)e[n]=this._holes[n].copy();return new i(t,e,this._factory)}},{key:"isRectangle",value:function(){if(0!==this.getNumInteriorRing())return!1;if(null===this._shell)return!1;if(5!==this._shell.getNumPoints())return!1;for(var t=this._shell.getCoordinateSequence(),e=this.getEnvelopeInternal(),n=0;n<5;n++){var i=t.getX(n);if(i!==e.getMinX()&&i!==e.getMaxX())return!1;var r=t.getY(n);if(r!==e.getMinY()&&r!==e.getMaxY())return!1}for(var o=t.getX(0),s=t.getY(0),a=1;a<=4;a++){var l=t.getX(a),u=t.getY(a);if(l!==o==(u!==s))return!1;o=l,s=u}return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t,r=this._shell,o=n._shell;if(!r.equalsExact(o,e))return!1;if(this._holes.length!==n._holes.length)return!1;for(var s=0;s<this._holes.length;s++)if(!this._holes[s].equalsExact(n._holes[s],e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){if(0===arguments.length){this._shell=this.normalized(this._shell,!0);for(var t=0;t<this._holes.length;t++)this._holes[t]=this.normalized(this._holes[t],!1);At.sort(this._holes)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(e.isEmpty())return null;var i=e.getCoordinateSequence(),r=bt.minCoordinateIndex(i,0,i.size()-2);bt.scroll(i,r,!0),ct.isCCW(i)===n&&bt.reverse(i)}}},{key:"getCoordinate",value:function(){return this._shell.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this._holes.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var t=this.getExteriorRing().reverse(),e=new Array(this.getNumInteriorRing()).fill(null),n=0;n<e.length;n++)e[n]=this.getInteriorRingN(n).reverse();return this.getFactory().createPolygon(t,e)}},{key:"getTypeCode",value:function(){return X.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var t=0;t+=this._shell.getLength();for(var e=0;e<this._holes.length;e++)t+=this._holes[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=this._shell.getNumPoints(),e=0;e<this._holes.length;e++)t+=this._holes[e].getNumPoints();return t}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(t,e){var n=t.copy();return this.normalize(n,e),n}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=this._shell,n=t._shell;return e.compareToSameClass(n)}if(2===arguments.length){var i=arguments[1],r=arguments[0],o=this._shell,s=r._shell,a=o.compareToSameClass(s,i);if(0!==a)return a;for(var l=this.getNumInteriorRing(),u=r.getNumInteriorRing(),h=0;h<l&&h<u;){var c=this.getInteriorRingN(h),f=r.getInteriorRingN(h),g=c.compareToSameClass(f,i);if(0!==g)return g;h++}return h<l?1:h<u?-1:0}}},{key:"apply",value:function(){if(rt(arguments[0],wt)){var t=arguments[0];this._shell.apply(t);for(var e=0;e<this._holes.length;e++)this._holes[e].apply(t)}else if(rt(arguments[0],Lt)){var n=arguments[0];if(this._shell.apply(n),!n.isDone())for(var i=0;i<this._holes.length&&(this._holes[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(rt(arguments[0],Nt))arguments[0].filter(this);else if(rt(arguments[0],k)){var r=arguments[0];r.filter(this),this._shell.apply(r);for(var o=0;o<this._holes.length;o++)this._holes[o].apply(r)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var t=new Array(this._holes.length+1).fill(null);t[0]=this._shell;for(var e=0;e<this._holes.length;e++)t[e+1]=this._holes[e];return t.length<=1?this.getFactory().createLinearRing(t[0].getCoordinateSequence()):this.getFactory().createMultiLineString(t)}},{key:"getGeometryType",value:function(){return X.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this._shell}},{key:"isEmpty",value:function(){return this._shell.isEmpty()}},{key:"getInteriorRingN",value:function(t){return this._holes[t]}},{key:"interfaces_",get:function(){return[Dt]}}],[{key:"constructor_",value:function(){this._shell=null,this._holes=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(X.constructor_.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),X.hasNullElements(e))throw new _("holes must not contain null elements");if(t.isEmpty()&&X.hasNonEmptyElements(e))throw new _("shell is empty but holes are not");this._shell=t,this._holes=e}}])}(X),Ft=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i)}(Z),Gt=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).array=[],t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"contains",value:function(t){var e,n=s(this.array);try{for(n.s();!(e=n.n()).done;)if(0===e.value.compareTo(t))return!0}catch(i){n.e(i)}finally{n.f()}return!1}},{key:"add",value:function(t){if(this.contains(t))return!1;for(var e=0,n=this.array.length;e<n;e++)if(1===this.array[e].compareTo(t))return!!this.array.splice(e,0,t);return this.array.push(t),!0}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(r){n.e(r)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new W}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new Bt(this.array)}}])}(Ft),Bt=o(function t(e){n(this,t),this.array=e,this.position=0},[{key:"next",value:function(){if(this.position===this.array.length)throw new K;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new W}}]),Yt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){for(var t=new U,e=0;e<this._geometries.length;e++)t.expandToInclude(this._geometries[e].getEnvelopeInternal());return t}},{key:"getGeometryN",value:function(t){return this._geometries[t]}},{key:"getCoordinates",value:function(){for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=0;n<this._geometries.length;n++)for(var i=this._geometries[n].getCoordinates(),r=0;r<i.length;r++)t[++e]=i[r];return t}},{key:"getArea",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getArea();return t}},{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._geometries.length!==n._geometries.length)return!1;for(var r=0;r<this._geometries.length;r++)if(!this._geometries[r].equalsExact(n._geometries[r],e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<this._geometries.length;t++)this._geometries[t].normalize();At.sort(this._geometries)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var t=St.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getBoundaryDimension());return t}},{key:"reverseInternal",value:function(){for(var t=this._geometries.length,e=new pt(t),n=0;n<t;n++)e.add(this._geometries[n].reverse());return this.getFactory().buildGeometry(e)}},{key:"getTypeCode",value:function(){return X.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var t=St.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getDimension());return t}},{key:"getLength",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getNumPoints();return t}},{key:"getNumGeometries",value:function(){return this._geometries.length}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=new Gt(At.asList(this._geometries)),n=new Gt(At.asList(t._geometries));return this.compare(e,n)}if(2===arguments.length){for(var i=arguments[1],r=arguments[0],o=this.getNumGeometries(),s=r.getNumGeometries(),a=0;a<o&&a<s;){var l=this.getGeometryN(a),u=r.getGeometryN(a),h=l.compareToSameClass(u,i);if(0!==h)return h;a++}return a<o?1:a<s?-1:0}}},{key:"apply",value:function(){if(rt(arguments[0],wt))for(var t=arguments[0],e=0;e<this._geometries.length;e++)this._geometries[e].apply(t);else if(rt(arguments[0],Lt)){var n=arguments[0];if(0===this._geometries.length)return null;for(var i=0;i<this._geometries.length&&(this._geometries[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(rt(arguments[0],Nt)){var r=arguments[0];r.filter(this);for(var o=0;o<this._geometries.length;o++)this._geometries[o].apply(r)}else if(rt(arguments[0],k)){var s=arguments[0];s.filter(this);for(var a=0;a<this._geometries.length;a++)this._geometries[a].apply(s)}}},{key:"getBoundary",value:function(){return X.checkNotGeometryCollection(this),G.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return X.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isEmpty())return!1;return!0}}],[{key:"constructor_",value:function(){if(this._geometries=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];if(X.constructor_.call(this,e),null===t&&(t=[]),X.hasNullElements(t))throw new _("geometries must not contain null elements");this._geometries=t}}}])}(X),qt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(1===arguments.length&&Number.isInteger(arguments[0])){var t=arguments[0];return this._geometries[t].getCoordinate()}return f(i,"getCoordinate",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[Ct]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Yt.constructor_.call(this,t,e)}}])}(Yt),zt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){return new i(this._points.copy(),this._factory)}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||f(i,"isClosed",this,1).call(this)}},{key:"reverseInternal",value:function(){var t=this._points.copy();return bt.reverse(t),this.getFactory().createLinearRing(t)}},{key:"getTypeCode",value:function(){return X.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!f(i,"isClosed",this,1).call(this))throw new _("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<i.MINIMUM_VALID_SIZE)throw new _("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")}},{key:"getGeometryType",value:function(){return X.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Pt.constructor_.call(this,t,e),this.validateConstruction()}}])}(Pt);zt.MINIMUM_VALID_SIZE=4;var Ht=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y}throw new _("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new _("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)z.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];z.constructor_.call(this,n,r,z.NULL_ORDINATE)}}}])}(z);Ht.X=0,Ht.Y=1,Ht.Z=-1,Ht.M=-1;var Ut=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;case i.M:this._m=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y;case i.M:return this._m}throw new _("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new _("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2];z.constructor_.call(this,n,r,z.NULL_ORDINATE),this._m=o}}}])}(z);Ut.X=0,Ut.Y=1,Ut.Z=-1,Ut.M=2;var Xt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case z.X:this.x=e;break;case z.Y:this.y=e;break;case z.Z:this.z=e;break;case z.M:this._m=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getOrdinate",value:function(t){switch(t){case z.X:return this.x;case z.Y:return this.y;case z.Z:return this.getZ();case z.M:return this.getM()}throw new _("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3];z.constructor_.call(this,n,r,o),this._m=s}}}])}(z),Vt=function(){function t(){n(this,t)}return o(t,null,[{key:"measures",value:function(t){return t instanceof Ht?0:t instanceof Ut||t instanceof Xt?1:0}},{key:"dimension",value:function(t){return t instanceof Ht?2:t instanceof Ut?3:t instanceof Xt?4:3}},{key:"create",value:function(){if(1===arguments.length){var e=arguments[0];return t.create(e,0)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return 2===n?new Ht:3===n&&0===i?new z:3===n&&1===i?new Ut:4===n&&1===i?new Xt:new z}}}])}(),jt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&rt(arguments[0],j)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return f(i,"addAll",this,1).apply(this,arguments)}},{key:"clone",value:function(){for(var t=f(i,"clone",this,1).call(this),e=0;e<this.size();e++)t.add(e,this.get(e).clone());return t}},{key:"toCoordinateArray",value:function(){if(0===arguments.length)return this.toArray(i.coordArrayType);if(1===arguments.length){if(arguments[0])return this.toArray(i.coordArrayType);for(var t=this.size(),e=new Array(t).fill(null),n=0;n<t;n++)e[n]=this.get(t-n-1);return e}}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];return f(i,"add",this,1).call(this,t)}if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return this.add(e,n,!0),!0}if(arguments[0]instanceof z&&"boolean"==typeof arguments[1]){var r=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(r))return null;f(i,"add",this,1).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return this.add(o,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var a=arguments[0],l=arguments[1];if(arguments[2])for(var u=0;u<a.length;u++)this.add(a[u],l);else for(var h=a.length-1;h>=0;h--)this.add(a[h],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof z){var c=arguments[0],g=arguments[1];if(!arguments[2]){var d=this.size();if(d>0){if(c>0&&this.get(c-1).equals2D(g))return null;if(c<d&&this.get(c).equals2D(g))return null}}f(i,"add",this,1).call(this,c,g)}}else if(4===arguments.length){var p=arguments[0],y=arguments[1],v=arguments[2],m=arguments[3],_=1;v>m&&(_=-1);for(var k=v;k!==m;k+=_)this.add(p[k],y);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var t=this.get(0).copy();this.add(t,!1)}}}],[{key:"constructor_",value:function(){if(0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}}])}(pt);jt.coordArrayType=new Array(0).fill(null);var Kt=function(){function t(){n(this,t)}return o(t,null,[{key:"isRing",value:function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))}},{key:"ptNotInList",value:function(e,n){for(var i=0;i<e.length;i++){var r=e[i];if(t.indexOf(r,n)<0)return r}return null}},{key:"scroll",value:function(e,n){var i=t.indexOf(n,e);if(i<0)return null;var r=new Array(e.length).fill(null);_t.arraycopy(e,i,r,0,e.length-i),_t.arraycopy(e,0,r,e.length-i,i),_t.arraycopy(r,0,e,0,e.length)}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].equals(e[n]))return!1;return!0}if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];if(i===r)return!0;if(null===i||null===r)return!1;if(i.length!==r.length)return!1;for(var s=0;s<i.length;s++)if(0!==o.compare(i[s],r[s]))return!1;return!0}}},{key:"intersection",value:function(t,e){for(var n=new jt,i=0;i<t.length;i++)e.intersects(t[i])&&n.add(t[i],!0);return n.toCoordinateArray()}},{key:"measures",value:function(t){if(null===t||0===t.length)return 0;var e,n=0,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Vt.measures(r))}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"hasRepeatedPoints",value:function(t){for(var e=1;e<t.length;e++)if(t[e-1].equals(t[e]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(e){return t.hasRepeatedPoints(e)?new jt(e,!1).toCoordinateArray():e}},{key:"reverse",value:function(t){for(var e=t.length-1,n=Math.trunc(e/2),i=0;i<=n;i++){var r=t[i];t[i]=t[e-i],t[e-i]=r}}},{key:"removeNull",value:function(t){for(var e=0,n=0;n<t.length;n++)null!==t[n]&&e++;var i=new Array(e).fill(null);if(0===e)return i;for(var r=0,o=0;o<t.length;o++)null!==t[o]&&(i[r++]=t[o]);return i}},{key:"copyDeep",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new Array(t.length).fill(null),n=0;n<t.length;n++)e[n]=t[n].copy();return e}if(5===arguments.length)for(var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4],l=0;l<a;l++)o[s+l]=i[r+l].copy()}},{key:"isEqualReversed",value:function(t,e){for(var n=0;n<t.length;n++){var i=t[n],r=e[t.length-n-1];if(0!==i.compareTo(r))return!1}return!0}},{key:"envelope",value:function(t){for(var e=new U,n=0;n<t.length;n++)e.expandToInclude(t[n]);return e}},{key:"toCoordinateArray",value:function(e){return e.toArray(t.coordArrayType)}},{key:"dimension",value:function(t){if(null===t||0===t.length)return 3;var e,n=0,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Vt.dimension(r))}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"atLeastNCoordinatesOrNothing",value:function(t,e){return e.length>=t?e:[]}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.length;n++)if(t.equals(e[n]))return n;return-1}},{key:"increasingDirection",value:function(t){for(var e=0;e<Math.trunc(t.length/2);e++){var n=t.length-1-e,i=t[e].compareTo(t[n]);if(0!==i)return i}return 1}},{key:"compare",value:function(t,e){for(var n=0;n<t.length&&n<e.length;){var i=t[n].compareTo(e[n]);if(0!==i)return i;n++}return n<e.length?-1:n<t.length?1:0}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.length;n++)(null===e||e.compareTo(t[n])>0)&&(e=t[n]);return e}},{key:"extract",value:function(t,e,n){e=kt.clamp(e,0,t.length);var i=(n=kt.clamp(n,-1,t.length))-e+1;n<0&&(i=0),e>=t.length&&(i=0),n<e&&(i=0);var r=new Array(i).fill(null);if(0===i)return r;for(var o=0,s=e;s<=n;s++)r[o++]=t[s];return r}}])}(),Wt=o(function t(){n(this,t)},[{key:"compare",value:function(t,e){var n=t,i=e;return Kt.compare(n,i)}},{key:"interfaces_",get:function(){return[D]}}]),Zt=o(function t(){n(this,t)},[{key:"compare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;var r=Kt.compare(n,i);return Kt.isEqualReversed(n,i)?0:r}},{key:"OLDcompare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;for(var r=Kt.increasingDirection(n),o=Kt.increasingDirection(i),s=r>0?0:n.length-1,a=o>0?0:n.length-1,l=0;l<n.length;l++){var u=n[s].compareTo(i[a]);if(0!==u)return u;s+=r,a+=o}return 0}},{key:"interfaces_",get:function(){return[D]}}]);Kt.ForwardComparator=Wt,Kt.BidirectionalComparator=Zt,Kt.coordArrayType=new Array(0).fill(null);var Jt=o(function t(e){n(this,t),this.str=e},[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),$t=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getM",value:function(t){return this.hasM()?this._coordinates[t].getM():A.NaN}},{key:"setOrdinate",value:function(t,e,n){switch(e){case ht.X:this._coordinates[t].x=n;break;case ht.Y:this._coordinates[t].y=n;break;default:this._coordinates[t].setOrdinate(e,n)}}},{key:"getZ",value:function(t){return this.hasZ()?this._coordinates[t].getZ():A.NaN}},{key:"size",value:function(){return this._coordinates.length}},{key:"getOrdinate",value:function(t,e){switch(e){case ht.X:return this._coordinates[t].x;case ht.Y:return this._coordinates[t].y;default:return this._coordinates[t].getOrdinate(e)}}},{key:"getCoordinate",value:function(){if(1===arguments.length){var t=arguments[0];return this._coordinates[t]}if(2===arguments.length){var e=arguments[0];arguments[1].setCoordinate(this._coordinates[e])}}},{key:"getCoordinateCopy",value:function(t){var e=this.createCoordinate();return e.setCoordinate(this._coordinates[t]),e}},{key:"createCoordinate",value:function(){return Vt.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this._dimension}},{key:"getX",value:function(t){return this._coordinates[t].x}},{key:"getMeasures",value:function(){return this._measures}},{key:"expandEnvelope",value:function(t){for(var e=0;e<this._coordinates.length;e++)t.expandToInclude(this._coordinates[e]);return t}},{key:"copy",value:function(){for(var e=new Array(this.size()).fill(null),n=0;n<this._coordinates.length;n++){var i=this.createCoordinate();i.setCoordinate(this._coordinates[n]),e[n]=i}return new t(e,this._dimension,this._measures)}},{key:"toString",value:function(){if(this._coordinates.length>0){var t=new Jt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e<this._coordinates.length;e++)t.append(", "),t.append(this._coordinates[e]);return t.append(")"),t.toString()}return"()"}},{key:"getY",value:function(t){return this._coordinates[t].y}},{key:"toCoordinateArray",value:function(){return this._coordinates}},{key:"interfaces_",get:function(){return[ht,w]}}],[{key:"constructor_",value:function(){if(this._dimension=3,this._measures=0,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];t.constructor_.call(this,e,Kt.dimension(e),Kt.measures(e))}else if(Number.isInteger(arguments[0])){var n=arguments[0];this._coordinates=new Array(n).fill(null);for(var i=0;i<n;i++)this._coordinates[i]=new z}else if(rt(arguments[0],ht)){var r=arguments[0];if(null===r)return this._coordinates=new Array(0).fill(null),null;this._dimension=r.getDimension(),this._measures=r.getMeasures(),this._coordinates=new Array(r.size()).fill(null);for(var o=0;o<this._coordinates.length;o++)this._coordinates[o]=r.getCoordinateCopy(o)}}else if(2===arguments.length){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var s=arguments[0],a=arguments[1];t.constructor_.call(this,s,a,Kt.measures(s))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var l=arguments[0],u=arguments[1];this._coordinates=new Array(l).fill(null),this._dimension=u;for(var h=0;h<l;h++)this._coordinates[h]=Vt.create(u)}}else if(3===arguments.length)if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var c=arguments[0],f=arguments[1],g=arguments[2];this._dimension=f,this._measures=g,this._coordinates=null===c?new Array(0).fill(null):c}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var d=arguments[0],p=arguments[1],y=arguments[2];this._coordinates=new Array(d).fill(null),this._dimension=p,this._measures=y;for(var v=0;v<d;v++)this._coordinates[v]=this.createCoordinate()}}}])}(),Qt=function(){function t(){n(this,t)}return o(t,[{key:"readResolve",value:function(){return t.instance()}},{key:"create",value:function(){if(1===arguments.length){if(arguments[0]instanceof Array)return new $t(arguments[0]);if(rt(arguments[0],ht))return new $t(arguments[0])}else{if(2===arguments.length){var t=arguments[1];return t>3&&(t=3),t<2&&(t=2),new $t(arguments[0],t)}if(3===arguments.length){var e=arguments[2],n=arguments[1]-e;return e>1&&(e=1),n>3&&(n=3),n<2&&(n=2),new $t(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[Et,w]}}],[{key:"instance",value:function(){return t.instanceObject}}])}();Qt.instanceObject=new Qt;var te=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var t=new pt,e=0;e<this._geometries.length;e++)for(var n=this._geometries[e].getBoundary(),i=0;i<n.getNumGeometries();i++)t.add(n.getGeometryN(i));var r=new Array(t.size()).fill(null);return this.getFactory().createMultiLineString(t.toArray(r))}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[Dt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Yt.constructor_.call(this,t,e)}}])}(Yt),ee=o(function t(){n(this,t)},[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}]),ne=function(t){function i(){var t;return n(this,i),(t=e(this,i)).map=new Map,t}return u(i,t),o(i,[{key:"get",value:function(t){return this.map.get(t)||null}},{key:"put",value:function(t,e){return this.map.set(t,e),e}},{key:"values",value:function(){for(var t=new pt,e=this.map.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t}},{key:"entrySet",value:function(){var t=new J;return this.map.entries().forEach(function(e){return t.add(e)}),t}},{key:"size",value:function(){return this.map.size()}}])}(ee),ie=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this._modelType===n._modelType&&this._scale===n._scale}},{key:"compareTo",value:function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits();return st.compare(n,i)}},{key:"getScale",value:function(){return this._scale}},{key:"isFloating",value:function(){return this._modelType===t.FLOATING||this._modelType===t.FLOATING_SINGLE}},{key:"getType",value:function(){return this._modelType}},{key:"toString",value:function(){var e="UNKNOWN";return this._modelType===t.FLOATING?e="Floating":this._modelType===t.FLOATING_SINGLE?e="Floating-Single":this._modelType===t.FIXED&&(e="Fixed (Scale="+this.getScale()+")"),e}},{key:"makePrecise",value:function(){if("number"==typeof arguments[0]){var e=arguments[0];return A.isNaN(e)||this._modelType===t.FLOATING_SINGLE?e:this._modelType===t.FIXED?Math.round(e*this._scale)/this._scale:e}if(arguments[0]instanceof z){var n=arguments[0];if(this._modelType===t.FLOATING)return null;n.x=this.makePrecise(n.x),n.y=this.makePrecise(n.y)}}},{key:"getMaximumSignificantDigits",value:function(){var e=16;return this._modelType===t.FLOATING?e=16:this._modelType===t.FLOATING_SINGLE?e=6:this._modelType===t.FIXED&&(e=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),e}},{key:"setScale",value:function(t){this._scale=Math.abs(t)}},{key:"interfaces_",get:function(){return[w,x]}}],[{key:"constructor_",value:function(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof re){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var i=arguments[0];this._modelType=i._modelType,this._scale=i._scale}}},{key:"mostPrecise",value:function(t,e){return t.compareTo(e)>=0?t:e}}])}(),re=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"readResolve",value:function(){return t.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){this._name=null;var e=arguments[0];this._name=e,t.nameToTypeMap.put(e,this)}}])}();re.nameToTypeMap=new ne,ie.Type=re,ie.FIXED=new re("FIXED"),ie.FLOATING=new re("FLOATING"),ie.FLOATING_SINGLE=new re("FLOATING SINGLE"),ie.maximumPreciseValue=9007199254740992;var oe=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?St.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new W}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[Mt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Yt.constructor_.call(this,t,e)}}])}(Yt),se=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"createEmpty",value:function(t){switch(t){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new _("Invalid dimension: "+t)}}},{key:"toGeometry",value:function(t){return t.isNull()?this.createPoint():t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new z(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new z(t.getMinX(),t.getMinY()),new z(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new z(t.getMinX(),t.getMinY()),new z(t.getMinX(),t.getMaxY()),new z(t.getMaxX(),t.getMaxY()),new z(t.getMaxX(),t.getMinY()),new z(t.getMinX(),t.getMinY())]),null)}},{key:"createLineString",value:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLineString(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(rt(arguments[0],ht))return new Pt(arguments[0],this)}}},{key:"createMultiLineString",value:function(){return 0===arguments.length?new oe(null,this):1===arguments.length?new oe(arguments[0],this):void 0}},{key:"buildGeometry",value:function(e){for(var n=null,i=!1,r=!1,o=e.iterator();o.hasNext();){var s=o.next(),a=s.getTypeCode();null===n&&(n=a),a!==n&&(i=!0),s instanceof Yt&&(r=!0)}if(null===n)return this.createGeometryCollection();if(i||r)return this.createGeometryCollection(t.toGeometryArray(e));var l=e.iterator().next();if(e.size()>1){if(l instanceof Rt)return this.createMultiPolygon(t.toPolygonArray(e));if(l instanceof Pt)return this.createMultiLineString(t.toLineStringArray(e));if(l instanceof Tt)return this.createMultiPoint(t.toPointArray(e));G.shouldNeverReachHere("Unhandled geometry type: "+l.getGeometryType())}return l}},{key:"createMultiPointFromCoords",value:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof z){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(rt(arguments[0],ht))return new Tt(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(rt(arguments[0],ht)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof zt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length)return new Rt(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Yt(null,this):1===arguments.length?new Yt(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(rt(arguments[0],ht))return new zt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new te(null,this):1===arguments.length?new te(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new qt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new qt(arguments[0],this);if(rt(arguments[0],ht)){var t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));for(var e=new Array(t.size()).fill(null),n=0;n<t.size();n++){var i=this.getCoordinateSequenceFactory().create(1,t.getDimension(),t.getMeasures());bt.copy(t,n,i,0,1),e[n]=this.createPoint(i)}return this.createMultiPoint(e)}}}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._precisionModel=null,this._coordinateSequenceFactory=null,this._SRID=null,0===arguments.length)t.constructor_.call(this,new ie,0);else if(1===arguments.length){if(rt(arguments[0],Et)){var e=arguments[0];t.constructor_.call(this,new ie,0,e)}else if(arguments[0]instanceof ie){var n=arguments[0];t.constructor_.call(this,n,0,t.getDefaultCoordinateSequenceFactory())}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];t.constructor_.call(this,i,r,t.getDefaultCoordinateSequenceFactory())}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this._precisionModel=o,this._coordinateSequenceFactory=a,this._SRID=s}}},{key:"toMultiPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toGeometryArray",value:function(t){if(null===t)return null;var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return Qt.instance()}},{key:"toMultiLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toMultiPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLinearRingArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"createPointFromInternalCoord",value:function(t,e){return e.getPrecisionModel().makePrecise(t),e.getFactory().createPoint(t)}}])}(),ae="XY",le="XYZ",ue="XYM",he="XYZM",ce={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},fe="EMPTY",ge=1,de=2,pe=3,ye=4,ve=5,me=6;for(var _e in ce)ce[_e].toUpperCase();var ke=o(function t(e){n(this,t),this.wkt=e,this.index_=-1},[{key:"isAlpha_",value:function(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}},{key:"isNumeric_",value:function(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}},{key:"isWhiteSpace_",value:function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var t,e=this.nextChar_(),n=this.index_,i=e;if("("==e)t=de;else if(","==e)t=ve;else if(")"==e)t=pe;else if(this.isNumeric_(e)||"-"==e)t=ye,i=this.readNumber_();else if(this.isAlpha_(e))t=ge,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=me}return{position:n,value:i,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,i=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(i=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!i&&("e"==t||"E"==t)||i&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}},{key:"readText_",value:function(){var t,e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}]),xe=o(function t(e,i){n(this,t),this.lexer_=e,this.token_,this.layout_=ae,this.factory=i},[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(t){return this.token_.type==t}},{key:"match",value:function(t){var e=this.isTokenType(t);return e&&this.consume_(),e}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var t=ae,e=this.token_;if(this.isTokenType(ge)){var n=e.value;"Z"===n?t=le:"M"===n?t=ue:"ZM"===n&&(t=he),t!==ae&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(de)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(ve));if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(de)){var t=this.parsePoint_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(de)){var t=this.parsePointList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(de)){var t=this.parseLineStringTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(de)){if(t=this.token_.type==de?this.parsePointTextList_():this.parsePointList_(),this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(de)){var t=this.parseLineStringTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(de)){var t=this.parsePolygonTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var t=[],e=this.layout_.length,n=0;n<e;++n){var i=this.token_;if(!this.match(ye))break;t.push(i.value)}if(t.length==e)return t;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var t=[this.parsePoint_()];this.match(ve);)t.push(this.parsePoint_());return t}},{key:"parsePointTextList_",value:function(){for(var t=[this.parsePointText_()];this.match(ve);)t.push(this.parsePointText_());return t}},{key:"parseLineStringTextList_",value:function(){for(var t=[this.parseLineStringText_()];this.match(ve);)t.push(this.parseLineStringText_());return t}},{key:"parsePolygonTextList_",value:function(){for(var t=[this.parsePolygonText_()];this.match(ve);)t.push(this.parsePolygonText_());return t}},{key:"isEmptyGeometry_",value:function(){var t=this.isTokenType(ge)&&this.token_.value==fe;return t&&this.consume_(),t}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var t=this.factory,e=function(t){return i(z,g(t))},n=function(n){var i=n.map(function(n){return t.createLinearRing(n.map(e))});return i.length>1?t.createPolygon(i[0],i.slice(1)):t.createPolygon(i[0])},r=this.token_;if(this.match(ge)){var o=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==o){var s=this.parseGeometryCollectionText_();return t.createGeometryCollection(s)}switch(o){case"POINT":var a=this.parsePointText_();return a?t.createPoint(i(z,g(a))):t.createPoint();case"LINESTRING":var l=this.parseLineStringText_().map(e);return t.createLineString(l);case"LINEARRING":var u=this.parseLineStringText_().map(e);return t.createLinearRing(u);case"POLYGON":var h=this.parsePolygonText_();return h&&0!==h.length?n(h):t.createPolygon();case"MULTIPOINT":var c=this.parseMultiPointText_();if(!c||0===c.length)return t.createMultiPoint();var f=c.map(e).map(function(e){return t.createPoint(e)});return t.createMultiPoint(f);case"MULTILINESTRING":var d=this.parseMultiLineStringText_().map(function(n){return t.createLineString(n.map(e))});return t.createMultiLineString(d);case"MULTIPOLYGON":var p=this.parseMultiPolygonText_();if(!p||0===p.length)return t.createMultiPolygon();var y=p.map(n);return t.createMultiPolygon(y);default:throw new Error("Invalid geometry type: "+o)}}throw new Error(this.formatErrorMessage_())}}]);function Ee(t){if(t.isEmpty())return"";var e=t.getCoordinate(),n=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||n.push(e.z),void 0===e.m||Number.isNaN(e.m)||n.push(e.m),n.join(" ")}function we(t){for(var e=t.getCoordinates().map(function(t){var e=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||e.push(t.z),void 0===t.m||Number.isNaN(t.m)||e.push(t.m),e}),n=[],i=0,r=e.length;i<r;++i)n.push(e[i].join(" "));return n.join(", ")}function Ie(t){var e=[];e.push("("+we(t.getExteriorRing())+")");for(var n=0,i=t.getNumInteriorRing();n<i;++n)e.push("("+we(t.getInteriorRingN(n))+")");return e.join(", ")}var Me={Point:Ee,LineString:we,LinearRing:we,Polygon:Ie,MultiPoint:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+Ee(t.getGeometryN(n))+")");return e.join(", ")},MultiLineString:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+we(t.getGeometryN(n))+")");return e.join(", ")},MultiPolygon:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+Ie(t.getGeometryN(n))+")");return e.join(", ")},GeometryCollection:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push(be(t.getGeometryN(n)));return e.join(", ")}};function be(t){var e=t.getGeometryType(),n=Me[e];e=e.toUpperCase();var i=function(t){var e="";if(t.isEmpty())return e;var n=t.getCoordinate();return void 0===n.z||Number.isNaN(n.z)||(e+="Z"),void 0===n.m||Number.isNaN(n.m)||(e+="M"),e}(t);return i.length>0&&(e+=" "+i),t.isEmpty()?e+" "+fe:e+" ("+n(t)+")"}var Se=o(function t(e){n(this,t),this.geometryFactory=e||new se,this.precisionModel=this.geometryFactory.getPrecisionModel()},[{key:"read",value:function(t){var e=new ke(t);return new xe(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return be(t)}}]),Ne=o(function t(e){n(this,t),this.parser=new Se(e)},[{key:"write",value:function(t){return this.parser.write(t)}}],[{key:"toLineString",value:function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}]),Le=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}},{key:"getTopologySummary",value:function(){var t=new Jt;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}},{key:"computeIntersection",value:function(t,e,n,i){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(t,e,n,i)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;e<this._result;e++)if(!this._intPt[e].equals2D(this._inputLines[t][0])&&!this._intPt[e].equals2D(this._inputLines[t][1]))return!0;return!1}}},{key:"getIntersection",value:function(t){return this._intPt[t]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&!this._isProper}},{key:"hasIntersection",value:function(){return this._result!==t.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(e,n){return t.computeEdgeDistance(this._intPt[n],this._inputLines[e][0],this._inputLines[e][1])}},{key:"isCollinear",value:function(){return this._result===t.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return Ne.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+Ne.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(t,e){return this._inputLines[t][e]}},{key:"isIntersection",value:function(t){for(var e=0;e<this._result;e++)if(this._intPt[e].equals2D(t))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[t][e]]}}],[{key:"constructor_",value:function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new z,this._intPt[1]=new z,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}},{key:"computeEdgeDistance",value:function(t,e,n){var i=Math.abs(n.x-e.x),r=Math.abs(n.y-e.y),o=-1;if(t.equals(e))o=0;else if(t.equals(n))o=i>r?i:r;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=i>r?s:a)||t.equals(e)||(o=Math.max(s,a))}return G.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y,o=Math.sqrt(i*i+r*r);return G.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o}}])}();Le.DONT_INTERSECT=0,Le.DO_INTERSECT=1,Le.COLLINEAR=2,Le.NO_INTERSECTION=0,Le.POINT_INTERSECTION=1,Le.COLLINEAR_INTERSECTION=2;var Pe=function(t){function i(){return n(this,i),e(this,i)}return u(i,t),o(i,[{key:"isInSegmentEnvelopes",value:function(t){var e=new U(this._inputLines[0][0],this._inputLines[0][1]),n=new U(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return f(i,"computeIntersection",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this._isProper=!1,U.intersects(e,n,t)&&0===ct.index(e,n,t)&&0===ct.index(n,e,t))return this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this._result=Le.POINT_INTERSECTION,null;this._result=Le.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,r){var o=this.intersectionSafe(t,e,n,r);return this.isInSegmentEnvelopes(o)||(o=new z(i.nearestEndpoint(t,e,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o}},{key:"checkDD",value:function(t,e,n,i,r){var o=ut.intersection(t,e,n,i),s=this.isInSegmentEnvelopes(o);_t.out.println("DD in env = "+s+" --------------------- "+o),r.distance(o)>1e-4&&_t.out.println("Distance = "+r.distance(o))}},{key:"intersectionSafe",value:function(t,e,n,r){var o=mt.intersection(t,e,n,r);return null===o&&(o=i.nearestEndpoint(t,e,n,r)),o}},{key:"computeCollinearIntersection",value:function(t,e,n,i){var r=U.intersects(t,e,n),o=U.intersects(t,e,i),s=U.intersects(n,i,t),a=U.intersects(n,i,e);return r&&o?(this._intPt[0]=n,this._intPt[1]=i,Le.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=t,this._intPt[1]=e,Le.COLLINEAR_INTERSECTION):r&&s?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||a?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):r&&a?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||s?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):o&&s?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||r||a?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):o&&a?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||r||s?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):Le.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,i){if(this._isProper=!1,!U.intersects(t,e,n,i))return Le.NO_INTERSECTION;var r=ct.index(t,e,n),o=ct.index(t,e,i);if(r>0&&o>0||r<0&&o<0)return Le.NO_INTERSECTION;var s=ct.index(n,i,t),a=ct.index(n,i,e);return s>0&&a>0||s<0&&a<0?Le.NO_INTERSECTION:0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(t,e,n,i):(0===r||0===o||0===s||0===a?(this._isProper=!1,t.equals2D(n)||t.equals2D(i)?this._intPt[0]=t:e.equals2D(n)||e.equals2D(i)?this._intPt[0]=e:0===r?this._intPt[0]=new z(n):0===o?this._intPt[0]=new z(i):0===s?this._intPt[0]=new z(t):0===a&&(this._intPt[0]=new z(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,n,i)),Le.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,i){var r=t,o=xt.pointToSegment(t,n,i),s=xt.pointToSegment(e,n,i);return s<o&&(o=s,r=e),(s=xt.pointToSegment(n,t,e))<o&&(o=s,r=n),(s=xt.pointToSegment(i,t,e))<o&&(o=s,r=i),r}}])}(Le),Ce=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"countSegment",value:function(t,e){if(t.x<this._p.x&&e.x<this._p.x)return null;if(this._p.x===e.x&&this._p.y===e.y)return this._isPointOnSegment=!0,null;if(t.y===this._p.y&&e.y===this._p.y){var n=t.x,i=e.x;return n>i&&(n=e.x,i=t.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var r=ct.index(t,e,this._p);if(r===ct.COLLINEAR)return this._isPointOnSegment=!0,null;e.y<t.y&&(r=-r),r===ct.LEFT&&this._crossingCount++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==V.EXTERIOR}},{key:"getLocation",value:function(){return this._isPointOnSegment?V.BOUNDARY:this._crossingCount%2==1?V.INTERIOR:V.EXTERIOR}},{key:"isOnSegment",value:function(){return this._isPointOnSegment}}],[{key:"constructor_",value:function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof z&&rt(arguments[1],ht)){for(var e=arguments[1],n=new t(arguments[0]),i=new z,r=new z,o=1;o<e.size();o++)if(e.getCoordinate(o,i),e.getCoordinate(o-1,r),n.countSegment(i,r),n.isOnSegment())return n.getLocation();return n.getLocation()}if(arguments[0]instanceof z&&arguments[1]instanceof Array){for(var s=arguments[1],a=new t(arguments[0]),l=1;l<s.length;l++){var u=s[l],h=s[l-1];if(a.countSegment(u,h),a.isOnSegment())return a.getLocation()}return a.getLocation()}}}])}(),Te=function(){function t(){n(this,t)}return o(t,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof z&&rt(arguments[1],ht)){for(var t=arguments[0],e=arguments[1],n=new Pe,i=new z,r=new z,o=e.size(),s=1;s<o;s++)if(e.getCoordinate(s-1,i),e.getCoordinate(s,r),n.computeIntersection(t,i,r),n.hasIntersection())return!0;return!1}if(arguments[0]instanceof z&&arguments[1]instanceof Array){for(var a=arguments[0],l=arguments[1],u=new Pe,h=1;h<l.length;h++){var c=l[h-1],f=l[h];if(u.computeIntersection(a,c,f),u.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(t,e){return Ce.locatePointInRing(t,e)}},{key:"isInRing",value:function(e,n){return t.locateInRing(e,n)!==V.EXTERIOR}}])}(),Oe=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"setAllLocations",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t}},{key:"isNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==V.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]===V.NONE&&(this.location[e]=t)}},{key:"isLine",value:function(){return 1===this.location.length}},{key:"merge",value:function(t){if(t.location.length>this.location.length){var e=new Array(3).fill(null);e[Q.ON]=this.location[Q.ON],e[Q.LEFT]=V.NONE,e[Q.RIGHT]=V.NONE,this.location=e}for(var n=0;n<this.location.length;n++)this.location[n]===V.NONE&&n<t.location.length&&(this.location[n]=t.location[n])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var t=this.location[Q.LEFT];this.location[Q.LEFT]=this.location[Q.RIGHT],this.location[Q.RIGHT]=t}},{key:"toString",value:function(){var t=new ot;return this.location.length>1&&t.append(V.toLocationSymbol(this.location[Q.LEFT])),t.append(V.toLocationSymbol(this.location[Q.ON])),this.location.length>1&&t.append(V.toLocationSymbol(this.location[Q.RIGHT])),t.toString()}},{key:"setLocations",value:function(t,e,n){this.location[Q.ON]=t,this.location[Q.LEFT]=e,this.location[Q.RIGHT]=n}},{key:"get",value:function(t){return t<this.location.length?this.location[t]:V.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===V.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(1===arguments.length){var t=arguments[0];this.setLocation(Q.ON,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.location[e]=n}}},{key:"init",value:function(t){this.location=new Array(t).fill(null),this.setAllLocations(V.NONE)}},{key:"isEqualOnSide",value:function(t,e){return this.location[e]===t.location[e]}},{key:"allPositionsEqual",value:function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0}}],[{key:"constructor_",value:function(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];this.init(e.length)}else if(Number.isInteger(arguments[0])){var n=arguments[0];this.init(1),this.location[Q.ON]=n}else if(arguments[0]instanceof t){var i=arguments[0];if(this.init(i.location.length),null!==i)for(var r=0;r<this.location.length;r++)this.location[r]=i.location[r]}}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.init(3),this.location[Q.ON]=o,this.location[Q.LEFT]=s,this.location[Q.RIGHT]=a}}}])}(),Ae=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getGeometryCount",value:function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t}},{key:"setAllLocations",value:function(t,e){this.elt[t].setAllLocations(e)}},{key:"isNull",value:function(t){return this.elt[t].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(1===arguments.length){var t=arguments[0];this.setAllLocationsIfNull(0,t),this.setAllLocationsIfNull(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.elt[e].setAllLocationsIfNull(n)}}},{key:"isLine",value:function(t){return this.elt[t].isLine()}},{key:"merge",value:function(t){for(var e=0;e<2;e++)null===this.elt[e]&&null!==t.elt[e]?this.elt[e]=new Oe(t.elt[e]):this.elt[e].merge(t.elt[e])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(1===arguments.length){var t=arguments[0];return this.elt[t].get(Q.ON)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.elt[e].get(n)}}},{key:"toString",value:function(){var t=new ot;return null!==this.elt[0]&&(t.append("A:"),t.append(this.elt[0].toString())),null!==this.elt[1]&&(t.append(" B:"),t.append(this.elt[1].toString())),t.toString()}},{key:"isArea",value:function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var t=arguments[0];return this.elt[t].isArea()}}},{key:"isAnyNull",value:function(t){return this.elt[t].isAnyNull()}},{key:"setLocation",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.elt[t].setLocation(Q.ON,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.elt[n].setLocation(i,r)}}},{key:"isEqualOnSide",value:function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)}},{key:"allPositionsEqual",value:function(t,e){return this.elt[t].allPositionsEqual(e)}},{key:"toLine",value:function(t){this.elt[t].isArea()&&(this.elt[t]=new Oe(this.elt[t].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var e=arguments[0];this.elt[0]=new Oe(e),this.elt[1]=new Oe(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.elt[0]=new Oe(n.elt[0]),this.elt[1]=new Oe(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new Oe(V.NONE),this.elt[1]=new Oe(V.NONE),this.elt[i].setLocation(r)}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.elt[0]=new Oe(o,s,a),this.elt[1]=new Oe(o,s,a)}else if(4===arguments.length){var l=arguments[0],u=arguments[1],h=arguments[2],c=arguments[3];this.elt[0]=new Oe(V.NONE,V.NONE,V.NONE),this.elt[1]=new Oe(V.NONE,V.NONE,V.NONE),this.elt[l].setLocations(u,h,c)}}},{key:"toLineLabel",value:function(e){for(var n=new t(V.NONE),i=0;i<2;i++)n.setLocation(i,e.getLocation(i));return n}}])}(),De=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"computeRing",value:function(){if(null!==this._ring)return null;for(var t=new Array(this._pts.size()).fill(null),e=0;e<this._pts.size();e++)t[e]=this._pts.get(e);this._ring=this._geometryFactory.createLinearRing(t),this._isHole=ct.isCCW(this._ring.getCoordinates())}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"computePoints",value:function(t){this._startDe=t;var e=t,n=!0;do{if(null===e)throw new gt("Found null DirectedEdge");if(e.getEdgeRing()===this)throw new gt("Directed Edge visited twice during ring-building at "+e.getCoordinate());this._edges.add(e);var i=e.getLabel();G.isTrue(i.isArea()),this.mergeLabel(i),this.addPoints(e.getEdge(),e.isForward(),n),n=!1,this.setEdgeRing(e,this),e=this.getNext(e)}while(e!==this._startDe)}},{key:"getLinearRing",value:function(){return this._ring}},{key:"getCoordinate",value:function(t){return this._pts.get(t)}},{key:"computeMaxNodeDegree",value:function(){this._maxNodeDegree=0;var t=this._startDe;do{var e=t.getNode().getEdges().getOutgoingDegree(this);e>this._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var o=r;o<i.length;o++)this._pts.add(i[o])}else{var s=i.length-2;n&&(s=i.length-1);for(var a=s;a>=0;a--)this._pts.add(i[a])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)}},{key:"containsPoint",value:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Te.isInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0}},{key:"addHole",value:function(t){this._holes.add(t)}},{key:"isShell",value:function(){return null===this._shell}},{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(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,Q.RIGHT);if(n===V.NONE)return null;if(this._label.getLocation(e)===V.NONE)return this._label.setLocation(e,n),null}}},{key:"setShell",value:function(t){this._shell=t,null!==t&&t.addHole(this)}},{key:"toPolygon",value:function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n<this._holes.size();n++)e[n]=this._holes.get(n).getLinearRing();return t.createPolygon(this.getLinearRing(),e)}}],[{key:"constructor_",value:function(){if(this._startDe=null,this._maxNodeDegree=-1,this._edges=new pt,this._pts=new pt,this._label=new Ae(V.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new pt,this._geometryFactory=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._geometryFactory=e,this.computePoints(t),this.computeRing()}}}]),Re=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"setEdgeRing",value:function(t,e){t.setMinEdgeRing(e)}},{key:"getNext",value:function(t){return t.getNextMin()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];De.constructor_.call(this,t,e)}}])}(De),Fe=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"buildMinimalRings",value:function(){var t=new pt,e=this._startDe;do{if(null===e.getMinEdgeRing()){var n=new Re(e,this._geometryFactory);t.add(n)}e=e.getNext()}while(e!==this._startDe);return t}},{key:"setEdgeRing",value:function(t,e){t.setEdgeRing(e)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var t=this._startDe;do{t.getNode().getEdges().linkMinimalDirectedEdges(this),t=t.getNext()}while(t!==this._startDe)}},{key:"getNext",value:function(t){return t.getNext()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];De.constructor_.call(this,t,e)}}])}(De),Ge=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"setVisited",value:function(t){this._isVisited=t}},{key:"setInResult",value:function(t){this._isInResult=t}},{key:"isCovered",value:function(){return this._isCovered}},{key:"isCoveredSet",value:function(){return this._isCoveredSet}},{key:"setLabel",value:function(t){this._label=t}},{key:"getLabel",value:function(){return this._label}},{key:"setCovered",value:function(t){this._isCovered=t,this._isCoveredSet=!0}},{key:"updateIM",value:function(t){G.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(t)}},{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,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._label=t}}}]),Be=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"isIncidentEdgeInResult",value:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(t){t.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(t){}},{key:"computeMergedLocation",value:function(t,e){var n=V.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==V.BOUNDARY&&(n=i)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return f(i,"setLabel",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this._label?this._label=new Ae(t,e):this._label.setLocation(t,e)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof i){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof Ae)for(var e=arguments[0],n=0;n<2;n++){var r=this.computeMergedLocation(e,n);this._label.getLocation(n)===V.NONE&&this._label.setLocation(n,r)}}},{key:"add",value:function(t){this._edges.insert(t),t.setNode(this)}},{key:"setLabelBoundary",value:function(t){if(null===this._label)return null;var e=V.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case V.BOUNDARY:n=V.INTERIOR;break;case V.INTERIOR:default:n=V.BOUNDARY}this._label.setLocation(t,n)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var t=arguments[0],e=arguments[1];this._coord=t,this._edges=e,this._label=new Ae(0,V.NONE)}}])}(Ge),Ye=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i)}(ee);function qe(t){return null==t?0:t.color}function ze(t){return null==t?null:t.parent}function He(t,e){null!==t&&(t.color=e)}function Ue(t){return null==t?null:t.left}function Xe(t){return null==t?null:t.right}var Ve=function(t){function i(){var t;return n(this,i),(t=e(this,i)).root_=null,t.size_=0,t}return u(i,t),o(i,[{key:"get",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null}},{key:"put",value:function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var o=r.value;return r.value=e,o}r=r.right}}while(null!==r);var s={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null}},{key:"fixAfterInsertion",value:function(t){var e;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)ze(t)===Ue(ze(ze(t)))?1===qe(e=Xe(ze(ze(t))))?(He(ze(t),0),He(e,0),He(ze(ze(t)),1),t=ze(ze(t))):(t===Xe(ze(t))&&(t=ze(t),this.rotateLeft(t)),He(ze(t),0),He(ze(ze(t)),1),this.rotateRight(ze(ze(t)))):1===qe(e=Ue(ze(ze(t))))?(He(ze(t),0),He(e,0),He(ze(ze(t)),1),t=ze(ze(t))):(t===Ue(ze(t))&&(t=ze(t),this.rotateRight(t)),He(ze(t),0),He(ze(ze(t)),1),this.rotateLeft(ze(ze(t))));this.root_.color=0}},{key:"values",value:function(){var t=new pt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=i.successor(e));)t.add(e.value);return t}},{key:"entrySet",value:function(){var t=new J,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=i.successor(e));)t.add(e);return t}},{key:"rotateLeft",value:function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"rotateRight",value:function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"getFirstEntry",value:function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return!0;e=e.right}}return!1}}],[{key:"successor",value:function(t){var e;if(null===t)return null;if(null!==t.right){for(e=t.right;null!==e.left;)e=e.left;return e}e=t.parent;for(var n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e}}])}(Ye),je=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof z){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Be){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}}},{key:"print",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(t){for(var e=new pt,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===V.BOUNDARY&&e.add(i)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new Ve,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}]),Ke=function(){function t(){n(this,t)}return o(t,null,[{key:"isNorthern",value:function(e){return e===t.NE||e===t.NW}},{key:"isOpposite",value:function(t,e){return t!==e&&2==(t-e+4)%4}},{key:"commonHalfPlane",value:function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=t<e?t:e;return 0===n&&3===(t>e?t:e)?3:n}},{key:"isInHalfPlane",value:function(e,n){return n===t.SE?e===t.SE||e===t.SW:e===n||e===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];if(0===e&&0===n)throw new _("Cannot compute the quadrant for point ( "+e+", "+n+" )");return e>=0?n>=0?t.NE:t.SE:n>=0?t.NW:t.SW}if(arguments[0]instanceof z&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1];if(r.x===i.x&&r.y===i.y)throw new _("Cannot compute the quadrant for two identical points "+i);return r.x>=i.x?r.y>=i.y?t.NE:t.SE:r.y>=i.y?t.NW:t.SW}}}])}();Ke.NE=0,Ke.NW=1,Ke.SW=2,Ke.SE=3;var We=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compareDirection",value:function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant<t._quadrant?-1:ct.index(t._p0,t._p1,this._p1)}},{key:"getDy",value:function(){return this._dy}},{key:"getCoordinate",value:function(){return this._p0}},{key:"setNode",value:function(t){this._node=t}},{key:"print",value:function(t){var e=Math.atan2(this._dy,this._dx),n=this.getClass().getName(),i=n.lastIndexOf("."),r=n.substring(i+1);t.print(" "+r+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+e+" "+this._label)}},{key:"compareTo",value:function(t){var e=t;return this.compareDirection(e)}},{key:"getDirectedCoordinate",value:function(){return this._p1}},{key:"getDx",value:function(){return this._dx}},{key:"getLabel",value:function(){return this._label}},{key:"getEdge",value:function(){return this._edge}},{key:"getQuadrant",value:function(){return this._quadrant}},{key:"getNode",value:function(){return this._node}},{key:"toString",value:function(){var t=Math.atan2(this._dy,this._dx),e=this.getClass().getName(),n=e.lastIndexOf(".");return" "+e.substring(n+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+t+" "+this._label}},{key:"computeLabel",value:function(t){}},{key:"init",value:function(t,e){this._p0=t,this._p1=e,this._dx=e.x-t.x,this._dy=e.y-t.y,this._quadrant=Ke.quadrant(this._dx,this._dy),G.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var e=arguments[0];this._edge=e}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];t.constructor_.call(this,n,i,r,null)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];t.constructor_.call(this,o),this.init(s,a),this._label=l}}}])}(),Ze=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getNextMin",value:function(){return this._nextMin}},{key:"getDepth",value:function(t){return this._depth[t]}},{key:"setVisited",value:function(t){this._isVisited=t}},{key:"computeDirectedLabel",value:function(){this._label=new Ae(this._edge.getLabel()),this._isForward||this._label.flip()}},{key:"getNext",value:function(){return this._next}},{key:"setDepth",value:function(t,e){if(-999!==this._depth[t]&&this._depth[t]!==e)throw new gt("assigned depths do not match",this.getCoordinate());this._depth[t]=e}},{key:"isInteriorAreaEdge",value:function(){for(var t=!0,e=0;e<2;e++)this._label.isArea(e)&&this._label.getLocation(e,Q.LEFT)===V.INTERIOR&&this._label.getLocation(e,Q.RIGHT)===V.INTERIOR||(t=!1);return t}},{key:"setNextMin",value:function(t){this._nextMin=t}},{key:"print",value:function(t){f(i,"print",this,1).call(this,t),t.print(" "+this._depth[Q.LEFT]+"/"+this._depth[Q.RIGHT]),t.print(" ("+this.getDepthDelta()+")"),this._isInResult&&t.print(" inResult")}},{key:"setMinEdgeRing",value:function(t){this._minEdgeRing=t}},{key:"isLineEdge",value:function(){var t=this._label.isLine(0)||this._label.isLine(1),e=!this._label.isArea(0)||this._label.allPositionsEqual(0,V.EXTERIOR),n=!this._label.isArea(1)||this._label.allPositionsEqual(1,V.EXTERIOR);return t&&e&&n}},{key:"setEdgeRing",value:function(t){this._edgeRing=t}},{key:"getMinEdgeRing",value:function(){return this._minEdgeRing}},{key:"getDepthDelta",value:function(){var t=this._edge.getDepthDelta();return this._isForward||(t=-t),t}},{key:"setInResult",value:function(t){this._isInResult=t}},{key:"getSym",value:function(){return this._sym}},{key:"isForward",value:function(){return this._isForward}},{key:"getEdge",value:function(){return this._edge}},{key:"printEdge",value:function(t){this.print(t),t.print(" "),this._isForward?this._edge.print(t):this._edge.printReverse(t)}},{key:"setSym",value:function(t){this._sym=t}},{key:"setVisitedEdge",value:function(t){this.setVisited(t),this._sym.setVisited(t)}},{key:"setEdgeDepths",value:function(t,e){var n=this.getEdge().getDepthDelta();this._isForward||(n=-n);var i=1;t===Q.LEFT&&(i=-1);var r=Q.opposite(t),o=e+n*i;this.setDepth(t,e),this.setDepth(r,o)}},{key:"getEdgeRing",value:function(){return this._edgeRing}},{key:"isInResult",value:function(){return this._isInResult}},{key:"setNext",value:function(t){this._next=t}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999];var t=arguments[0],e=arguments[1];if(We.constructor_.call(this,t),this._isForward=e,e)this.init(t.getCoordinate(0),t.getCoordinate(1));else{var n=t.getNumPoints()-1;this.init(t.getCoordinate(n),t.getCoordinate(n-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(t,e){return t===V.EXTERIOR&&e===V.INTERIOR?1:t===V.INTERIOR&&e===V.EXTERIOR?-1:0}}])}(We),Je=o(function t(){n(this,t)},[{key:"createNode",value:function(t){return new Be(t,null)}}]),$e=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"printEdges",value:function(t){t.println("Edges:");for(var e=0;e<this._edges.size();e++){t.println("edge "+e+":");var n=this._edges.get(e);n.print(t),n.eiList.print(t)}}},{key:"find",value:function(t){return this._nodes.find(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof Be){var t=arguments[0];return this._nodes.addNode(t)}if(arguments[0]instanceof z){var e=arguments[0];return this._nodes.addNode(e)}}},{key:"getNodeIterator",value:function(){return this._nodes.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(t){_t.out.println(t)}},{key:"isBoundaryNode",value:function(t,e){var n=this._nodes.find(e);if(null===n)return!1;var i=n.getLabel();return null!==i&&i.getLocation(t)===V.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(t,e,n,i){return!!t.equals(n)&&ct.index(t,e,i)===ct.COLLINEAR&&Ke.quadrant(t,e)===Ke.quadrant(n,i)}},{key:"getEdgeEnds",value:function(){return this._edgeEndList}},{key:"debugPrint",value:function(t){_t.out.print(t)}},{key:"getEdgeIterator",value:function(){return this._edges.iterator()}},{key:"findEdgeInSameDirection",value:function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(this.matchInSameDirection(t,e,r[0],r[1]))return i;if(this.matchInSameDirection(t,e,r[r.length-1],r[r.length-2]))return i}return null}},{key:"insertEdge",value:function(t){this._edges.add(t)}},{key:"findEdgeEnd",value:function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null}},{key:"addEdges",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this._edges.add(n);var i=new Ze(n,!0),r=new Ze(n,!1);i.setSym(r),r.setSym(i),this.add(i),this.add(r)}}},{key:"add",value:function(t){this._nodes.add(t),this._edgeEndList.add(t)}},{key:"getNodes",value:function(){return this._nodes.values()}},{key:"findEdge",value:function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(t.equals(r[0])&&e.equals(r[1]))return i}return null}}],[{key:"constructor_",value:function(){if(this._edges=new pt,this._nodes=null,this._edgeEndList=new pt,0===arguments.length)this._nodes=new je(new Je);else if(1===arguments.length){var t=arguments[0];this._nodes=new je(t)}}},{key:"linkResultDirectedEdges",value:function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()}}]),Qe=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"sortShellsAndHoles",value:function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isHole()?n.add(r):e.add(r)}}},{key:"computePolygons",value:function(t){for(var e=new pt,n=t.iterator();n.hasNext();){var i=n.next().toPolygon(this._geometryFactory);e.add(i)}return e}},{key:"placeFreeHoles",value:function(e,n){for(var i=n.iterator();i.hasNext();){var r=i.next();if(null===r.getShell()){var o=t.findEdgeRingContaining(r,e);if(null===o)throw new gt("unable to assign hole to a shell",r.getCoordinate(0));r.setShell(o)}}}},{key:"buildMinimalEdgeRings",value:function(t,e,n){for(var i=new pt,r=t.iterator();r.hasNext();){var o=r.next();if(o.getMaxNodeDegree()>2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else i.add(o)}return i}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new pt,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new Fe(i,this._geometryFactory);e.add(r),r.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return G.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];$e.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new pt,o=this.buildMinimalEdgeRings(i,this._shellList,r);this.sortShellsAndHoles(o,this._shellList,r),this.placeFreeHoles(this._shellList,r)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new pt;var t=arguments[0];this._geometryFactory=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var l=a.next(),u=l.getLinearRing(),h=u.getEnvelopeInternal();if(!h.equals(i)&&h.contains(i)){r=Kt.ptNotInList(n.getCoordinates(),u.getCoordinates());var c=!1;Te.isInRing(r,u.getCoordinates())&&(c=!0),c&&(null===o||s.contains(h))&&(s=(o=l).getLinearRing().getEnvelopeInternal())}}return o}}])}(),tn=o(function t(){n(this,t)},[{key:"getBounds",value:function(){}}]),en=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[tn,w]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}}]),nn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"poll",value:function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)}},{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 0===this._size}},{key:"add",value:function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new pt,this._items.add(null)}}]),rn=o(function t(){n(this,t)},[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}]),on=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{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(t){G.isTrue(null===this._bounds),this._childBoundables.add(t)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[tn,w]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new pt,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}}}]),sn={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return sn.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?At.sort(n,e):At.sort(n);for(var i=t.iterator(),r=0,o=n.length;r<o;r++)i.next(),i.set(n[r])},singletonList:function(t){var e=new pt;return e.add(t),e}},an=function(){function t(){n(this,t)}return o(t,null,[{key:"maxDistance",value:function(e,n,i,r,o,s,a,l){var u=t.distance(e,n,o,s);return u=Math.max(u,t.distance(e,n,a,l)),u=Math.max(u,t.distance(i,r,o,s)),Math.max(u,t.distance(i,r,a,l))}},{key:"distance",value:function(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}},{key:"maximumDistance",value:function(e,n){var i=Math.min(e.getMinX(),n.getMinX()),r=Math.min(e.getMinY(),n.getMinY()),o=Math.max(e.getMaxX(),n.getMaxX()),s=Math.max(e.getMaxY(),n.getMaxY());return t.distance(i,r,o,s)}},{key:"minMaxDistance",value:function(e,n){var i=e.getMinX(),r=e.getMinY(),o=e.getMaxX(),s=e.getMaxY(),a=n.getMinX(),l=n.getMinY(),u=n.getMaxX(),h=n.getMaxY(),c=t.maxDistance(i,r,i,s,a,l,a,h);return c=Math.min(c,t.maxDistance(i,r,i,s,a,l,u,l)),c=Math.min(c,t.maxDistance(i,r,i,s,u,h,a,h)),c=Math.min(c,t.maxDistance(i,r,i,s,u,h,u,l)),c=Math.min(c,t.maxDistance(i,r,o,r,a,l,a,h)),c=Math.min(c,t.maxDistance(i,r,o,r,a,l,u,l)),c=Math.min(c,t.maxDistance(i,r,o,r,u,h,a,h)),c=Math.min(c,t.maxDistance(i,r,o,r,u,h,u,l)),c=Math.min(c,t.maxDistance(o,s,i,s,a,l,a,h)),c=Math.min(c,t.maxDistance(o,s,i,s,a,l,u,l)),c=Math.min(c,t.maxDistance(o,s,i,s,u,h,a,h)),c=Math.min(c,t.maxDistance(o,s,i,s,u,h,u,l)),c=Math.min(c,t.maxDistance(o,s,o,r,a,l,a,h)),c=Math.min(c,t.maxDistance(o,s,o,r,a,l,u,l)),c=Math.min(c,t.maxDistance(o,s,o,r,u,h,a,h)),Math.min(c,t.maxDistance(o,s,o,r,u,h,u,l))}}])}(),ln=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"maximumDistance",value:function(){return an.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}},{key:"expandToQueue",value:function(e,n){var i=t.isComposite(this._boundable1),r=t.isComposite(this._boundable2);if(i&&r)return t.area(this._boundable1)>t.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,e,n),null):(this.expand(this._boundable2,this._boundable1,!0,e,n),null);if(i)return this.expand(this._boundable1,this._boundable2,!1,e,n),null;if(r)return this.expand(this._boundable2,this._boundable1,!0,e,n),null;throw new _("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(t.isComposite(this._boundable1)||t.isComposite(this._boundable2))}},{key:"compareTo",value:function(t){var e=t;return this._distance<e._distance?-1:this._distance>e._distance?1:0}},{key:"expand",value:function(e,n,i,r,o){for(var s=e.getChildBoundables().iterator();s.hasNext();){var a=s.next(),l=null;(l=i?new t(n,a,this._itemDistance):new t(a,n,this._itemDistance)).getDistance()<o&&r.add(l)}}},{key:"getBoundable",value:function(t){return 0===t?this._boundable1:this._boundable2}},{key:"getDistance",value:function(){return this._distance}},{key:"distance",value:function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var t=arguments[0],e=arguments[1],n=arguments[2];this._boundable1=t,this._boundable2=e,this._itemDistance=n,this._distance=this.distance()}},{key:"area",value:function(t){return t.getBounds().getArea()}},{key:"isComposite",value:function(t){return t instanceof on}}])}(),un=o(function t(){n(this,t)},[{key:"visitItem",value:function(t){}}]),hn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"queryInternal",value:function(){if(rt(arguments[2],un)&&arguments[0]instanceof Object&&arguments[1]instanceof on)for(var t=arguments[0],e=arguments[2],n=arguments[1].getChildBoundables(),i=0;i<n.size();i++){var r=n.get(i);this.getIntersectsOp().intersects(r.getBounds(),t)&&(r instanceof on?this.queryInternal(t,r,e):r instanceof en?e.visitItem(r.getItem()):G.shouldNeverReachHere())}else if(rt(arguments[2],nt)&&arguments[0]instanceof Object&&arguments[1]instanceof on)for(var o=arguments[0],s=arguments[2],a=arguments[1].getChildBoundables(),l=0;l<a.size();l++){var u=a.get(l);this.getIntersectsOp().intersects(u.getBounds(),o)&&(u instanceof on?this.queryInternal(o,u,s):u instanceof en?s.add(u.getItem()):G.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this._nodeCapacity}},{key:"lastNode",value:function(t){return t.get(t.size()-1)}},{key:"size",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof on?t+=this.size(n):n instanceof en&&(t+=1)}return t}}},{key:"removeItem",value:function(t,e){for(var n=null,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof en&&r.getItem()===e&&(n=r)}return null!==n&&(t.getChildBoundables().remove(n),!0)}},{key:"itemsTree",value:function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new pt:t}if(1===arguments.length){for(var e=arguments[0],n=new pt,i=e.getChildBoundables().iterator();i.hasNext();){var r=i.next();if(r instanceof on){var o=this.itemsTree(r);null!==o&&n.add(o)}else r instanceof en?n.add(r.getItem()):G.shouldNeverReachHere()}return n.size()<=0?null:n}}},{key:"insert",value:function(t,e){G.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new en(t,e))}},{key:"boundablesAtLevel",value:function(){if(1===arguments.length){var t=arguments[0],e=new pt;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];if(G.isTrue(n>-2),i.getLevel()===n)return r.add(i),null;for(var o=i.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof on?this.boundablesAtLevel(n,s,r):(G.isTrue(s instanceof en),-1===n&&r.add(s))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new pt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,i)}}},{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(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=this.removeItem(i,r);if(o)return!0;for(var s=null,a=i.getChildBoundables().iterator();a.hasNext();){var l=a.next();if(this.getIntersectsOp().intersects(l.getBounds(),n)&&l instanceof on&&(o=this.remove(n,l,r))){s=l;break}}return null!==s&&s.getChildBoundables().isEmpty()&&i.getChildBoundables().remove(s),o}}},{key:"createHigherLevels",value:function(t,e){G.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof on){var i=this.depth(n);i>t&&(t=i)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){G.isTrue(!t.isEmpty());var n=new pt;n.add(this.createNode(e));var i=new pt(t);sn.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var o=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new pt,this._nodeCapacity=null,0===arguments.length)t.constructor_.call(this,t.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var e=arguments[0];G.isTrue(e>1,"Node capacity must be greater than 1"),this._nodeCapacity=e}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t<e?-1:0}}])}();hn.IntersectsOp=function(){},hn.DEFAULT_NODE_CAPACITY=10;var cn=o(function t(){n(this,t)},[{key:"distance",value:function(t,e){}}]),fn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"createParentBoundablesFromVerticalSlices",value:function(t,e){G.isTrue(t.length>0);for(var n=new pt,i=0;i<t.length;i++)n.addAll(this.createParentBoundablesFromVerticalSlice(t[i],e));return n}},{key:"nearestNeighbourK",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.nearestNeighbourK(t,A.POSITIVE_INFINITY,e)}if(3===arguments.length){var n=arguments[0],r=arguments[2],o=arguments[1],s=new nn;s.add(n);for(var a=new nn;!s.isEmpty()&&o>=0;){var l=s.poll(),u=l.getDistance();if(u>=o)break;l.isLeaves()?a.size()<r?a.add(l):(a.peek().getDistance()>u&&(a.poll(),a.add(l)),o=a.peek().getDistance()):l.expandToQueue(s,o)}return i.getItems(a)}}},{key:"createNode",value:function(t){return new gn(t)}},{key:"size",value:function(){return 0===arguments.length?f(i,"size",this,1).call(this):f(i,"size",this,1).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof U))return f(i,"insert",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;f(i,"insert",this,1).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return i.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),i=new Array(e).fill(null),r=t.iterator(),o=0;o<e;o++){i[o]=new pt;for(var s=0;r.hasNext()&&s<n;){var a=r.next();i[o].add(a),s++}}return i}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];return f(i,"query",this,1).call(this,t)}if(2===arguments.length){var e=arguments[0],n=arguments[1];f(i,"query",this,1).call(this,e,n)}}},{key:"getComparator",value:function(){return i.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(t,e){return f(i,"createParentBoundables",this,1).call(this,t,e)}},{key:"remove",value:function(){if(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof U){var t=arguments[0],e=arguments[1];return f(i,"remove",this,1).call(this,t,e)}return f(i,"remove",this,1).apply(this,arguments)}},{key:"depth",value:function(){return 0===arguments.length?f(i,"depth",this,1).call(this):f(i,"depth",this,1).apply(this,arguments)}},{key:"createParentBoundables",value:function(t,e){G.isTrue(!t.isEmpty());var n=Math.trunc(Math.ceil(t.size()/this.getNodeCapacity())),r=new pt(t);sn.sort(r,i.xComparator);var o=this.verticalSlices(r,Math.trunc(Math.ceil(Math.sqrt(n))));return this.createParentBoundablesFromVerticalSlices(o,e)}},{key:"nearestNeighbour",value:function(){if(1===arguments.length){if(rt(arguments[0],cn)){var t=arguments[0];if(this.isEmpty())return null;var e=new ln(this.getRoot(),this.getRoot(),t);return this.nearestNeighbour(e)}if(arguments[0]instanceof ln){var n=arguments[0],i=A.POSITIVE_INFINITY,r=null,o=new nn;for(o.add(n);!o.isEmpty()&&i>0;){var s=o.poll(),a=s.getDistance();if(a>=i)break;s.isLeaves()?(i=a,r=s):s.expandToQueue(o,i)}return null===r?null:[r.getBoundable(0).getItem(),r.getBoundable(1).getItem()]}}else{if(2===arguments.length){var l=arguments[0],u=arguments[1];if(this.isEmpty()||l.isEmpty())return null;var h=new ln(this.getRoot(),l.getRoot(),u);return this.nearestNeighbour(h)}if(3===arguments.length){var c=arguments[2],f=new en(arguments[0],arguments[1]),g=new ln(this.getRoot(),f,c);return this.nearestNeighbour(g)[0]}if(4===arguments.length){var d=arguments[2],p=arguments[3],y=new en(arguments[0],arguments[1]),v=new ln(this.getRoot(),y,d);return this.nearestNeighbourK(v,p)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=A.POSITIVE_INFINITY,i=new nn;for(i.add(t);!i.isEmpty();){var r=i.poll(),o=r.getDistance();if(o>e)return!1;if(r.maximumDistance()<=e)return!0;if(r.isLeaves()){if((n=o)<=e)return!0}else r.expandToQueue(i,n)}return!1}if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2],u=new ln(this.getRoot(),s.getRoot(),a);return this.isWithinDistance(u,l)}}},{key:"interfaces_",get:function(){return[rn,w]}}],[{key:"constructor_",value:function(){if(0===arguments.length)i.constructor_.call(this,i.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];hn.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return i.avg(t.getMinX(),t.getMaxX())}},{key:"avg",value:function(t,e){return(t+e)/2}},{key:"getItems",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;!t.isEmpty();){var i=t.poll();e[n]=i.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return i.avg(t.getMinY(),t.getMaxY())}}])}(hn),gn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new U(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];on.constructor_.call(this,t)}}])}(on);fn.STRtreeNode=gn,fn.xComparator=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[D]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreX(t.getBounds()),fn.centreX(e.getBounds()))}}])),fn.yComparator=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[D]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreY(t.getBounds()),fn.centreY(e.getBounds()))}}])),fn.intersectsOp=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}])),fn.DEFAULT_NODE_CAPACITY=10;var dn=function(){function t(){n(this,t)}return o(t,null,[{key:"relativeSign",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"compare",value:function(e,n,i){if(n.equals2D(i))return 0;var r=t.relativeSign(n.x,i.x),o=t.relativeSign(n.y,i.y);switch(e){case 0:return t.compareValue(r,o);case 1:return t.compareValue(o,r);case 2:return t.compareValue(o,-r);case 3:return t.compareValue(-r,o);case 4:return t.compareValue(-r,-o);case 5:return t.compareValue(-o,-r);case 6:return t.compareValue(-o,r);case 7:return t.compareValue(r,-o)}return G.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}])}(),pn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(t){var e=t;return this.segmentIndex<e.segmentIndex?-1:this.segmentIndex>e.segmentIndex?1:this.coord.equals2D(e.coord)?0:this._isInterior?e._isInterior?dn.compare(this._segmentOctant,this.coord,e.coord):1:-1}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t}},{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 t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._segString=t,this.coord=new z(e),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))}}]),yn=o(function t(){n(this,t)},[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),vn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getSplitCoordinates",value:function(){var t=new jt;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new pt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}}},{key:"createSplitEdgePts",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2;if(2===n)return[new z(t.coord),new z(e.coord)];var i=this._edge.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this._edge.getCoordinate(a);return r&&(o[s]=new z(e.coord)),o}},{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"findCollapsesFromExistingVertices",value:function(t){for(var e=0;e<this._edge.size()-2;e++){var n=this._edge.getCoordinate(e);this._edge.getCoordinate(e+1);var i=this._edge.getCoordinate(e+2);n.equals2D(i)&&t.add(st.valueOf(e+1))}}},{key:"addEdgeCoordinates",value:function(t,e,n){var i=this.createSplitEdgePts(t,e);n.add(i,!1)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints(),this.addCollapsedNodes();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"findCollapseIndex",value:function(t,e,n){if(!t.coord.equals2D(e.coord))return!1;var i=e.segmentIndex-t.segmentIndex;return e.isInterior()||i--,1===i&&(n[0]=t.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(t){for(var e=new Array(1).fill(null),n=this.iterator(),i=n.next();n.hasNext();){var r=n.next();this.findCollapseIndex(i,r,e)&&t.add(st.valueOf(e[0])),i=r}}},{key:"getEdge",value:function(){return this._edge}},{key:"addEndpoints",value:function(){var t=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(t),t)}},{key:"createSplitEdge",value:function(t,e){var n=this.createSplitEdgePts(t,e);return new xn(n,this._edge.getData())}},{key:"add",value:function(t,e){var n=new pn(this._edge,t,e,this._edge.getSegmentOctant(e)),i=this._nodeMap.get(n);return null!==i?(G.isTrue(i.coord.equals2D(t),"Found equal nodes with different coordinates"),i):(this._nodeMap.put(n,n),n)}},{key:"checkSplitEdgesCorrectness",value:function(t){var e=this._edge.getCoordinates(),n=t.get(0).getCoordinate(0);if(!n.equals2D(e[0]))throw new R("bad split edge start point at "+n);var i=t.get(t.size()-1).getCoordinates(),r=i[i.length-1];if(!r.equals2D(e[e.length-1]))throw new R("bad split edge end point at "+r)}}],[{key:"constructor_",value:function(){this._nodeMap=new Ve,this._edge=null;var t=arguments[0];this._edge=t}}]),mn=function(){function t(){n(this,t)}return o(t,null,[{key:"octant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];if(0===e&&0===n)throw new _("Cannot compute the octant for point ( "+e+", "+n+" )");var i=Math.abs(e),r=Math.abs(n);return e>=0?n>=0?i>=r?0:1:i>=r?7:6:n>=0?i>=r?3:2:i>=r?4:5}if(arguments[0]instanceof z&&arguments[1]instanceof z){var o=arguments[0],s=arguments[1],a=s.x-o.x,l=s.y-o.y;if(0===a&&0===l)throw new _("Cannot compute the octant for two identical points "+o);return t.octant(a,l)}}}])}(),_n=o(function t(){n(this,t)},[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(t){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(t){}},{key:"getData",value:function(){}}]),kn=o(function t(){n(this,t)},[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[_n]}}]),xn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(t){return this._pts[t]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}},{key:"setData",value:function(t){this._data=t}},{key:"safeOctant",value:function(t,e){return t.equals2D(e)?0:mn.octant(t,e)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],i=arguments[3],r=new z(arguments[0].getIntersection(i));this.addIntersection(r,n)}}},{key:"toString",value:function(){return Ne.toLineString(new $t(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(t,e){var n=e,i=n+1;if(i<this._pts.length){var r=this._pts[i];t.equals2D(r)&&(n=i)}return this._nodeList.add(t,n)}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}},{key:"interfaces_",get:function(){return[kn]}}],[{key:"constructor_",value:function(){this._nodeList=new vn(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e}},{key:"getNodedSubstrings",value:function(){if(1===arguments.length){var e=arguments[0],n=new pt;return t.getNodedSubstrings(e,n),n}if(2===arguments.length)for(var i=arguments[1],r=arguments[0].iterator();r.hasNext();)r.next().getNodeList().addSplitEdges(i)}}])}(),En=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof t){var e=arguments[0],n=ct.index(this.p0,this.p1,e.p0),i=ct.index(this.p0,this.p1,e.p1);return n>=0&&i>=0||n<=0&&i<=0?Math.max(n,i):0}if(arguments[0]instanceof z){var r=arguments[0];return ct.index(this.p0,this.p1,r)}}},{key:"toGeometry",value:function(t){return t.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new Pe;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof z){var e=arguments[0];if(e.equals(this.p0)||e.equals(this.p1))return new z(e);var n=this.projectionFactor(e),i=new z;return i.x=this.p0.x+n*(this.p1.x-this.p0.x),i.y=this.p0.y+n*(this.p1.y-this.p0.y),i}if(arguments[0]instanceof t){var r=arguments[0],o=this.projectionFactor(r.p0),s=this.projectionFactor(r.p1);if(o>=1&&s>=1)return null;if(o<=0&&s<=0)return null;var a=this.project(r.p0);o<0&&(a=this.p0),o>1&&(a=this.p1);var l=this.project(r.p1);return s<0&&(l=this.p0),s>1&&(l=this.p1),new t(a,l)}}},{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(t){return 0===t?this.p0:this.p1}},{key:"distancePerpendicular",value:function(t){return xt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return t.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?A.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=A.MAX_VALUE,r=null,o=this.closestPoint(t.p0);i=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(r=s.distance(t.p1))<i&&(i=r,n[0]=s,n[1]=t.p1);var a=t.closestPoint(this.p0);(r=a.distance(this.p0))<i&&(i=r,n[0]=this.p0,n[1]=a);var l=t.closestPoint(this.p1);return(r=l.distance(this.p1))<i&&(i=r,n[0]=this.p1,n[1]=l),n}},{key:"closestPoint",value:function(t){var e=this.projectionFactor(t);return e>0&&e<1?this.project(t):this.p0.distance(t)<this.p1.distance(t)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(t){var e=t,n=this.p0.compareTo(e.p0);return 0!==n?n:this.p1.compareTo(e.p1)}},{key:"reverse",value:function(){var t=this.p0;this.p0=this.p1,this.p1=t}},{key:"equalsTopo",value:function(t){return this.p0.equals(t.p0)&&this.p1.equals(t.p1)||this.p0.equals(t.p1)&&this.p1.equals(t.p0)}},{key:"lineIntersection",value:function(t){return mt.intersection(this.p0,this.p1,t.p0,t.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(t,e){var n=this.p0.x+t*(this.p1.x-this.p0.x),i=this.p0.y+t*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y,s=Math.sqrt(r*r+o*o),a=0,l=0;if(0!==e){if(s<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");a=e*r/s,l=e*o/s}return new z(n-l,i+a)}},{key:"setCoordinates",value:function(){if(1===arguments.length){var t=arguments[0];this.setCoordinates(t.p0,t.p1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p0.x=e.x,this.p0.y=e.y,this.p1.x=n.x,this.p1.y=n.y}}},{key:"segmentFraction",value:function(t){var e=this.projectionFactor(t);return e<0?e=0:(e>1||A.isNaN(e))&&(e=1),e}},{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(t){var e=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),i=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=e*e+n*n,o=e*e-n*n,s=t.getX(),a=t.getY();return new z((-o*s-2*e*n*a-2*e*i)/r,(o*a-2*e*n*s-2*n*i)/r)}},{key:"distance",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return xt.segmentToSegment(this.p0,this.p1,e.p0,e.p1)}if(arguments[0]instanceof z){var n=arguments[0];return xt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new z;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e}},{key:"hashCode",value:function(){var t=A.doubleToLongBits(this.p0.x);t^=31*A.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=A.doubleToLongBits(this.p1.x);return n^=31*A.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)}},{key:"interfaces_",get:function(){return[x,w]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)t.constructor_.call(this,new z,new z);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.p0,e.p1)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.p0=n,this.p1=i}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];t.constructor_.call(this,new z(r,o),new z(s,a))}}},{key:"midPoint",value:function(t,e){return new z((t.x+e.x)/2,(t.y+e.y)/2)}}])}(),wn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"overlap",value:function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new En,this._overlapSeg2=new En}}]),In=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getLineSegment",value:function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]}},{key:"computeSelect",value:function(t,e,n,i){var r=this._pts[e],o=this._pts[n];if(n-e==1)return i.select(this,e),null;if(!t.intersects(r,o))return null;var s=Math.trunc((e+n)/2);e<s&&this.computeSelect(t,e,s,i),s<n&&this.computeSelect(t,s,n,i)}},{key:"getCoordinates",value:function(){for(var t=new Array(this._end-this._start+1).fill(null),e=0,n=this._start;n<=this._end;n++)t[e++]=this._pts[n];return t}},{key:"computeOverlaps",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.computeOverlaps(this._start,this._end,t,t._start,t._end,e)}else if(6===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=arguments[3],s=arguments[4],a=arguments[5];if(i-n==1&&s-o==1)return a.overlap(this,n,r,o),null;if(!this.overlaps(n,i,r,o,s))return null;var l=Math.trunc((n+i)/2),u=Math.trunc((o+s)/2);n<l&&(o<u&&this.computeOverlaps(n,l,r,o,u,a),u<s&&this.computeOverlaps(n,l,r,u,s,a)),l<i&&(o<u&&this.computeOverlaps(l,i,r,o,u,a),u<s&&this.computeOverlaps(l,i,r,u,s,a))}}},{key:"setId",value:function(t){this._id=t}},{key:"select",value:function(t,e){this.computeSelect(t,this._start,this._end,e)}},{key:"getEnvelope",value:function(){if(null===this._env){var t=this._pts[this._start],e=this._pts[this._end];this._env=new U(t,e)}return this._env}},{key:"overlaps",value:function(t,e,n,i,r){return U.intersects(this._pts[t],this._pts[e],n._pts[i],n._pts[r])}},{key:"getEndIndex",value:function(){return this._end}},{key:"getStartIndex",value:function(){return this._start}},{key:"getContext",value:function(){return this._context}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=i}}]),Mn=function(){function t(){n(this,t)}return o(t,null,[{key:"findChainEnd",value:function(t,e){for(var n=e;n<t.length-1&&t[n].equals2D(t[n+1]);)n++;if(n>=t.length-1)return t.length-1;for(var i=Ke.quadrant(t[n],t[n+1]),r=e+1;r<t.length&&(t[r-1].equals2D(t[r])||Ke.quadrant(t[r-1],t[r])===i);)r++;return r-1}},{key:"getChains",value:function(){if(1===arguments.length){var e=arguments[0];return t.getChains(e,null)}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=new pt,o=0;do{var s=t.findChainEnd(n,o),a=new In(n,o,s,i);r.add(a),o=s}while(o<n.length-1);return r}}}])}(),bn=o(function t(){n(this,t)},[{key:"computeNodes",value:function(t){}},{key:"getNodedSubstrings",value:function(){}}]),Sn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"setSegmentIntersector",value:function(t){this._segInt=t}},{key:"interfaces_",get:function(){return[bn]}}],[{key:"constructor_",value:function(){if(this._segInt=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}}}]),Nn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getMonotoneChains",value:function(){return this._monoChains}},{key:"getNodedSubstrings",value:function(){return xn.getNodedSubstrings(this._nodedSegStrings)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(t){for(var e=Mn.getChains(t.getCoordinates(),t).iterator();e.hasNext();){var n=e.next();n.setId(this._idCounter++),this._index.insert(n.getEnvelope(),n),this._monoChains.add(n)}}},{key:"computeNodes",value:function(t){this._nodedSegStrings=t;for(var e=t.iterator();e.hasNext();)this.add(e.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var t=new Ln(this._segInt),e=this._monoChains.iterator();e.hasNext();)for(var n=e.next(),i=this._index.query(n.getEnvelope()).iterator();i.hasNext();){var r=i.next();if(r.getId()>n.getId()&&(n.computeOverlaps(r,t),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new pt,this._index=new fn,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];Sn.constructor_.call(this,t)}}}])}(Sn),Ln=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"overlap",value:function(){if(4!==arguments.length)return f(i,"overlap",this,1).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],r=arguments[0].getContext(),o=e.getContext();this._si.processIntersections(r,t,o,n)}}],[{key:"constructor_",value:function(){this._si=null;var t=arguments[0];this._si=t}}])}(wn);Nn.SegmentOverlapAction=Ln;var Pn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isDeletable",value:function(t,e,n,i){var r=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(r,o,s)&&!!this.isShallow(r,o,s,i)&&this.isShallowSampled(r,o,t,n,i)}},{key:"deleteShallowConcavities",value:function(){for(var e=1,n=this.findNextNonDeletedIndex(e),i=this.findNextNonDeletedIndex(n),r=!1;i<this._inputLine.length;){var o=!1;this.isDeletable(e,n,i,this._distanceTol)&&(this._isDeleted[n]=t.DELETE,o=!0,r=!0),e=o?i:n,n=this.findNextNonDeletedIndex(e),i=this.findNextNonDeletedIndex(n)}return r}},{key:"isShallowConcavity",value:function(t,e,n,i){return ct.index(t,e,n)===this._angleOrientation&&xt.pointToSegment(e,t,n)<i}},{key:"isShallowSampled",value:function(e,n,i,r,o){var s=Math.trunc((r-i)/t.NUM_PTS_TO_CHECK);s<=0&&(s=1);for(var a=i;a<r;a+=s)if(!this.isShallow(e,n,this._inputLine[a],o))return!1;return!0}},{key:"isConcave",value:function(t,e,n){return ct.index(t,e,n)===this._angleOrientation}},{key:"simplify",value:function(t){this._distanceTol=Math.abs(t),t<0&&(this._angleOrientation=ct.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var e=!1;do{e=this.deleteShallowConcavities()}while(e);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(e){for(var n=e+1;n<this._inputLine.length&&this._isDeleted[n]===t.DELETE;)n++;return n}},{key:"isShallow",value:function(t,e,n,i){return xt.pointToSegment(e,t,n)<i}},{key:"collapseLine",value:function(){for(var e=new jt,n=0;n<this._inputLine.length;n++)this._isDeleted[n]!==t.DELETE&&e.add(this._inputLine[n]);return e.toCoordinateArray()}}],[{key:"constructor_",value:function(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=ct.COUNTERCLOCKWISE;var t=arguments[0];this._inputLine=t}},{key:"simplify",value:function(e,n){return new t(e).simplify(n)}}])}();Pn.INIT=0,Pn.DELETE=1,Pn.KEEP=1,Pn.NUM_PTS_TO_CHECK=10;var Cn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getCoordinates",value:function(){return this._ptList.toArray(t.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"addPt",value:function(t){var e=new z(t);if(this._precisionModel.makePrecise(e),this.isRedundant(e))return null;this._ptList.add(e)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(t,e){if(e)for(var n=0;n<t.length;n++)this.addPt(t[n]);else for(var i=t.length-1;i>=0;i--)this.addPt(t[i])}},{key:"isRedundant",value:function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)<this._minimimVertexDistance}},{key:"toString",value:function(){return(new se).createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this._ptList.size()<1)return null;var t=new z(this._ptList.get(0)),e=this._ptList.get(this._ptList.size()-1);if(t.equals(e))return null;this._ptList.add(t)}},{key:"setMinimumVertexDistance",value:function(t){this._minimimVertexDistance=t}}],[{key:"constructor_",value:function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new pt}}])}();Cn.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var Tn=function(){function t(){n(this,t)}return o(t,null,[{key:"toDegrees",value:function(t){return 180*t/Math.PI}},{key:"normalize",value:function(e){for(;e>Math.PI;)e-=t.PI_TIMES_2;for(;e<=-Math.PI;)e+=t.PI_TIMES_2;return e}},{key:"angle",value:function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}}},{key:"isAcute",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)<0}},{key:"interiorAngle",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i);return Math.abs(o-r)}},{key:"normalizePositive",value:function(e){if(e<0){for(;e<0;)e+=t.PI_TIMES_2;e>=t.PI_TIMES_2&&(e=0)}else{for(;e>=t.PI_TIMES_2;)e-=t.PI_TIMES_2;e<0&&(e=0)}return e}},{key:"angleBetween",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i);return t.diff(r,o)}},{key:"diff",value:function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n}},{key:"toRadians",value:function(t){return t*Math.PI/180}},{key:"getTurn",value:function(e,n){var i=Math.sin(n-e);return i>0?t.COUNTERCLOCKWISE:i<0?t.CLOCKWISE:t.NONE}},{key:"angleBetweenOriented",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i)-r;return o<=-Math.PI?o+t.PI_TIMES_2:o>Math.PI?o-t.PI_TIMES_2:o}}])}();Tn.PI_TIMES_2=2*Math.PI,Tn.PI_OVER_2=Math.PI/2,Tn.PI_OVER_4=Math.PI/4,Tn.COUNTERCLOCKWISE=ct.COUNTERCLOCKWISE,Tn.CLOCKWISE=ct.CLOCKWISE,Tn.NONE=ct.COLLINEAR;var On=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"addNextSegment",value:function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,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 n=ct.index(this._s0,this._s1,this._s2),i=n===ct.CLOCKWISE&&this._side===Q.LEFT||n===ct.COUNTERCLOCKWISE&&this._side===Q.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new En(t,e),i=new En;this.computeOffsetSegment(n,Q.LEFT,this._distance,i);var r=new En;this.computeOffsetSegment(n,Q.RIGHT,this._distance,r);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case v.CAP_ROUND:this._segList.addPt(i.p1),this.addDirectedFillet(e,a+Math.PI/2,a-Math.PI/2,ct.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case v.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case v.CAP_SQUARE:var l=new z;l.x=Math.abs(this._distance)*Math.cos(a),l.y=Math.abs(this._distance)*Math.sin(a);var u=new z(i.p1.x+l.x,i.p1.y+l.y),h=new z(r.p1.x+l.x,r.p1.y+l.y);this._segList.addPt(u),this._segList.addPt(h)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,i){var r=mt.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==r&&(i<=0?1:r.distance(t)/Math.abs(i))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null;this.addLimitedMitreJoin(e,n,i,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(e,n){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*t.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===v.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===v.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(n&&this._segList.addPt(this._offset0.p1),this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,e,this._distance),this._segList.addPt(this._offset1.p0))}},{key:"createSquare",value:function(t){this._segList.addPt(new z(t.x+this._distance,t.y+this._distance)),this._segList.addPt(new z(t.x+this._distance,t.y-this._distance)),this._segList.addPt(new z(t.x-this._distance,t.y-this._distance)),this._segList.addPt(new z(t.x-this._distance,t.y+this._distance)),this._segList.closeRing()}},{key:"addSegments",value:function(t,e){this._segList.addPts(t,e)}},{key:"addFirstSegment",value:function(){this._segList.addPt(this._offset1.p0)}},{key:"addCornerFillet",value:function(t,e,n,i,r){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),l=n.x-t.x,u=n.y-t.y,h=Math.atan2(u,l);i===ct.CLOCKWISE?a<=h&&(a+=2*Math.PI):a>=h&&(a-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,a,h,i,r),this._segList.addPt(n)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(t,e,n,i){var r=this._seg0.p1,o=Tn.angle(r,this._seg0.p0),s=Tn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=Tn.normalize(o+s),l=Tn.normalize(a+Math.PI),u=i*n,h=n-u*Math.abs(Math.sin(s)),c=r.x+u*Math.cos(l),f=r.y+u*Math.sin(l),g=new z(c,f),d=new En(r,g),p=d.pointAlongOffset(1,h),y=d.pointAlongOffset(1,-h);this._side===Q.LEFT?(this._segList.addPt(p),this._segList.addPt(y)):(this._segList.addPt(y),this._segList.addPt(p))}},{key:"addDirectedFillet",value:function(t,e,n,i,r){var o=i===ct.CLOCKWISE?-1:1,s=Math.abs(e-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;for(var l=s/a,u=new z,h=0;h<a;h++){var c=e+o*h*l;u.x=t.x+r*Math.cos(c),u.y=t.y+r*Math.sin(c),this._segList.addPt(u)}}},{key:"computeOffsetSegment",value:function(t,e,n,i){var r=e===Q.LEFT?1:-1,o=t.p1.x-t.p0.x,s=t.p1.y-t.p0.y,a=Math.sqrt(o*o+s*s),l=r*n*o/a,u=r*n*s/a;i.p0.x=t.p0.x-u,i.p0.y=t.p0.y+l,i.p1.x=t.p1.x-u,i.p1.y=t.p1.y+l}},{key:"addInsideTurn",value:function(e,n){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*t.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var i=new z((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(i);var r=new z((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(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(t){var e=new z(t.x+this._distance,t.y);this._segList.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)}},{key:"init",value:function(e){this._distance=e,this._maxCurveSegmentError=e*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Cn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(e*t.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===v.JOIN_BEVEL||this._bufParams.getJoinStyle()===v.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,ct.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 e=arguments[0],n=arguments[1],i=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new Pe,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===v.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(i)}}])}();On.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,On.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,On.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,On.MAX_CLOSING_SEG_LEN_FACTOR=80;var An=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getOffsetCurve",value:function(t,e){if(this._distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var o=r.getCoordinates();return n&&Kt.reverse(o),o}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var r=Pn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Q.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{n.addSegments(t,!1);var a=Pn.simplify(t,i),l=a.length-1;n.initSideSegments(a[0],a[1],Q.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(a[u],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);e===Q.RIGHT&&(i=-i);var r=Pn.simplify(t,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(r[s],a)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this._distance),i=Pn.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],Q.LEFT);for(var o=2;o<=r;o++)e.addNextSegment(i[o],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var s=Pn.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],Q.LEFT);for(var l=a-2;l>=0;l--)e.addNextSegment(s[l],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()}},{key:"computePointCurve",value:function(t,e){switch(this._bufParams.getEndCapStyle()){case v.CAP_ROUND:e.createCircle(t);break;case v.CAP_SQUARE:e.createSquare(t)}}},{key:"getLineCurve",value:function(t,e){if(this._distance=e,this.isLineOffsetEmpty(e))return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this._bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);return i.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(t){return t*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(e,n,i){if(this._distance=i,e.length<=2)return this.getLineCurve(e,i);if(0===i)return t.copyCoordinates(e);var r=this.getSegGen(i);return this.computeRingBufferCurve(e,n,r),r.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){var r=Pn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Q.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{var a=Pn.simplify(t,i),l=a.length-1;n.initSideSegments(a[0],a[1],Q.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(a[u],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(t){return new On(this._precisionModel,this._bufParams,t)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e}},{key:"copyCoordinates",value:function(t){for(var e=new Array(t.length).fill(null),n=0;n<e.length;n++)e[n]=new z(t[n]);return e}}])}(),Dn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"findStabbedSegments",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new pt,n=this._subgraphs.iterator();n.hasNext();){var i=n.next(),r=i.getEnvelope();t.y<r.getMinY()||t.y>r.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(rt(arguments[2],nt)&&arguments[0]instanceof z&&arguments[1]instanceof Ze){for(var o=arguments[0],s=arguments[1],a=arguments[2],l=s.getEdge().getCoordinates(),u=0;u<l.length-1;u++)if(this._seg.p0=l[u],this._seg.p1=l[u+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)<o.x||this._seg.isHorizontal()||o.y<this._seg.p0.y||o.y>this._seg.p1.y||ct.index(this._seg.p0,this._seg.p1,o)===ct.RIGHT)){var h=s.getDepth(Q.LEFT);this._seg.p0.equals(l[u])||(h=s.getDepth(Q.RIGHT));var c=new Rn(this._seg,h);a.add(c)}}else if(rt(arguments[2],nt)&&arguments[0]instanceof z&&rt(arguments[1],nt))for(var f=arguments[0],g=arguments[2],d=arguments[1].iterator();d.hasNext();){var p=d.next();p.isForward()&&this.findStabbedSegments(f,p,g)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:sn.min(e)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new En;var t=arguments[0];this._subgraphs=t}}]),Rn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"compareTo",value:function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)}},{key:"compareX",value:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.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 t=arguments[0],e=arguments[1];this._upwardSeg=new En(t),this._leftDepth=e}}]);Dn.DepthSegment=Rn;var Fn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,null,[{key:"constructor_",value:function(){m.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}])}(m),Gn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getY",value:function(){var t=this.y/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getCoordinate",value:function(){var t=new z;return t.x=this.getX(),t.y=this.getY(),t}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this.x=n,this.y=i,this.w=1}else if(arguments[0]instanceof t&&arguments[1]instanceof t){var r=arguments[0],o=arguments[1];this.x=r.y*o.w-o.y*r.w,this.y=o.x*r.w-r.x*o.w,this.w=r.x*o.y-o.x*r.y}else if(arguments[0]instanceof z&&arguments[1]instanceof z){var s=arguments[0],a=arguments[1];this.x=s.y-a.y,this.y=a.x-s.x,this.w=s.x*a.y-a.x*s.y}}else if(3===arguments.length){var l=arguments[0],u=arguments[1],h=arguments[2];this.x=l,this.y=u,this.w=h}else if(4===arguments.length){var c=arguments[0],f=arguments[1],g=arguments[2],d=arguments[3],p=c.y-f.y,y=f.x-c.x,v=c.x*f.y-f.x*c.y,m=g.y-d.y,_=d.x-g.x,k=g.x*d.y-d.x*g.y;this.x=y*k-_*v,this.y=m*v-p*k,this.w=p*_-m*y}}}])}(),Bn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"area",value:function(){return t.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return t.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(e){if(null===e)throw new _("Supplied point is null.");return t.interpolateZ(e,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return t.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return t.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return t.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return t.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return t.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return t.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}},{key:"area",value:function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)}},{key:"signedArea",value:function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2}},{key:"det",value:function(t,e,n,i){return t*i-e*n}},{key:"interpolateZ",value:function(t,e,n,i){var r=e.x,o=e.y,s=n.x-r,a=i.x-r,l=n.y-o,u=i.y-o,h=s*u-a*l,c=t.x-r,f=t.y-o,g=(u*c-a*f)/h,d=(-l*c+s*f)/h;return e.getZ()+g*(n.getZ()-e.getZ())+d*(i.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var i=t.distance(e),r=e.distance(n),o=n.distance(t),s=i;return r>s&&(s=r),o>s&&(s=o),s}},{key:"circumcentreDD",value:function(t,e,n){var i=lt.valueOf(t.x).subtract(n.x),r=lt.valueOf(t.y).subtract(n.y),o=lt.valueOf(e.x).subtract(n.x),s=lt.valueOf(e.y).subtract(n.y),a=lt.determinant(i,r,o,s).multiply(2),l=i.sqr().add(r.sqr()),u=o.sqr().add(s.sqr()),h=lt.determinant(r,l,s,u),c=lt.determinant(i,l,o,u),f=lt.valueOf(n.x).subtract(h.divide(a)).doubleValue(),g=lt.valueOf(n.y).add(c.divide(a)).doubleValue();return new z(f,g)}},{key:"isAcute",value:function(t,e,n){return!!Tn.isAcute(t,e,n)&&!!Tn.isAcute(e,n,t)&&!!Tn.isAcute(n,t,e)}},{key:"circumcentre",value:function(e,n,i){var r=i.x,o=i.y,s=e.x-r,a=e.y-o,l=n.x-r,u=n.y-o,h=2*t.det(s,a,l,u),c=t.det(a,s*s+a*a,u,l*l+u*u),f=t.det(s,s*s+a*a,l,l*l+u*u);return new z(r-c/h,o+f/h)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new Gn(t.x+n/2,t.y+i/2,1),o=new Gn(t.x-i+n/2,t.y+n+i/2,1);return new Gn(r,o)}},{key:"angleBisector",value:function(t,e,n){var i=e.distance(t),r=i/(i+e.distance(n)),o=n.x-t.x,s=n.y-t.y;return new z(t.x+r*o,t.y+r*s)}},{key:"area3D",value:function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=e.getZ()-t.getZ(),s=n.x-t.x,a=n.y-t.y,l=n.getZ()-t.getZ(),u=r*l-o*a,h=o*s-i*l,c=i*a-r*s,f=u*u+h*h+c*c;return Math.sqrt(f)/2}},{key:"centroid",value:function(t,e,n){var i=(t.x+e.x+n.x)/3,r=(t.y+e.y+n.y)/3;return new z(i,r)}},{key:"inCentre",value:function(t,e,n){var i=e.distance(n),r=t.distance(n),o=t.distance(e),s=i+r+o,a=(i*t.x+r*e.x+o*n.x)/s,l=(i*t.y+r*e.y+o*n.y)/s;return new z(a,l)}}])}(),Yn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"addRingSide",value:function(t,e,n,i,r){if(0===e&&t.length<zt.MINIMUM_VALID_SIZE)return null;var o=i,s=r;t.length>=zt.MINIMUM_VALID_SIZE&&ct.isCCW(t)&&(o=r,s=i,n=Q.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,Q.LEFT,V.EXTERIOR,V.INTERIOR),this.addRingSide(t,e,Q.RIGHT,V.INTERIOR,V.EXTERIOR)}},{key:"addPoint",value:function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,V.EXTERIOR,V.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this._distance,n=Q.LEFT;this._distance<0&&(e=-this._distance,n=Q.RIGHT);var i=t.getExteriorRing(),r=Kt.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addRingSide(r,e,n,V.EXTERIOR,V.INTERIOR);for(var o=0;o<t.getNumInteriorRing();o++){var s=t.getInteriorRingN(o),a=Kt.removeRepeatedPoints(s.getCoordinates());this._distance>0&&this.isErodedCompletely(s,-this._distance)||this.addRingSide(a,e,Q.opposite(n),V.INTERIOR,V.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new Bn(t[0],t[1],t[2]),i=n.inCentre();return xt.pointToSegment(i,n.p0,n.p1)<Math.abs(e)}},{key:"addLineString",value:function(t){if(this._curveBuilder.isLineOffsetEmpty(this._distance))return null;var e=Kt.removeRepeatedPoints(t.getCoordinates());if(Kt.isRing(e)&&!this._curveBuilder.getBufferParameters().isSingleSided())this.addRingBothSides(e,this._distance);else{var n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,V.EXTERIOR,V.INTERIOR)}}},{key:"addCurve",value:function(t,e,n){if(null===t||t.length<2)return null;var i=new xn(t,new Ae(0,V.BOUNDARY,e,n));this._curveList.add(i)}},{key:"getCurves",value:function(){return this.add(this._inputGeom),this._curveList}},{key:"add",value:function(t){if(t.isEmpty())return null;if(t instanceof Rt)this.addPolygon(t);else if(t instanceof Pt)this.addLineString(t);else if(t instanceof Tt)this.addPoint(t);else if(t instanceof qt)this.addCollection(t);else if(t instanceof oe)this.addCollection(t);else if(t instanceof te)this.addCollection(t);else{if(!(t instanceof Yt))throw new W(t.getGeometryType());this.addCollection(t)}}},{key:"isErodedCompletely",value:function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r}},{key:"addCollection",value:function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}}}],[{key:"constructor_",value:function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new pt;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n}}]),qn=o(function t(){n(this,t)},[{key:"locate",value:function(t){}}]),zn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"next",value:function(){if(this._atStart)return this._atStart=!1,t.isAtomic(this._parent)&&this._index++,this._parent;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new K;var e=this._parent.getGeometryN(this._index++);return e instanceof Yt?(this._subcollectionIterator=new t(e),this._subcollectionIterator.next()):e}},{key:"remove",value:function(){throw new W(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[yn]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()}},{key:"isAtomic",value:function(t){return!(t instanceof Yt)}}])}(),Hn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"locate",value:function(e){return t.locate(e,this._geom)}},{key:"interfaces_",get:function(){return[qn]}}],[{key:"constructor_",value:function(){this._geom=null;var t=arguments[0];this._geom=t}},{key:"locatePointInPolygon",value:function(e,n){if(n.isEmpty())return V.EXTERIOR;var i=n.getExteriorRing(),r=t.locatePointInRing(e,i);if(r!==V.INTERIOR)return r;for(var o=0;o<n.getNumInteriorRing();o++){var s=n.getInteriorRingN(o),a=t.locatePointInRing(e,s);if(a===V.BOUNDARY)return V.BOUNDARY;if(a===V.INTERIOR)return V.EXTERIOR}return V.INTERIOR}},{key:"locatePointInRing",value:function(t,e){return e.getEnvelopeInternal().intersects(t)?Te.locateInRing(t,e.getCoordinates()):V.EXTERIOR}},{key:"containsPointInPolygon",value:function(e,n){return V.EXTERIOR!==t.locatePointInPolygon(e,n)}},{key:"locateInGeometry",value:function(e,n){if(n instanceof Rt)return t.locatePointInPolygon(e,n);if(n instanceof Yt)for(var i=new zn(n);i.hasNext();){var r=i.next();if(r!==n){var o=t.locateInGeometry(e,r);if(o!==V.EXTERIOR)return o}}return V.EXTERIOR}},{key:"isContained",value:function(e,n){return V.EXTERIOR!==t.locate(e,n)}},{key:"locate",value:function(e,n){return n.isEmpty()?V.EXTERIOR:n.getEnvelopeInternal().intersects(e)?t.locateInGeometry(e,n):V.EXTERIOR}}])}(),Un=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getNextCW",value:function(t){this.getEdges();var e=this._edgeList.indexOf(t),n=e-1;return 0===e&&(n=this._edgeList.size()-1),this._edgeList.get(n)}},{key:"propagateSideLabels",value:function(t){for(var e=V.NONE,n=this.iterator();n.hasNext();){var i=n.next().getLabel();i.isArea(t)&&i.getLocation(t,Q.LEFT)!==V.NONE&&(e=i.getLocation(t,Q.LEFT))}if(e===V.NONE)return null;for(var r=e,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getLabel();if(a.getLocation(t,Q.ON)===V.NONE&&a.setLocation(t,Q.ON,r),a.isArea(t)){var l=a.getLocation(t,Q.LEFT),u=a.getLocation(t,Q.RIGHT);if(u!==V.NONE){if(u!==r)throw new gt("side location conflict",s.getCoordinate());l===V.NONE&&G.shouldNeverReachHere("found single null side (at "+s.getCoordinate()+")"),r=l}else G.isTrue(a.getLocation(t,Q.LEFT)===V.NONE,"found single null side"),a.setLocation(t,Q.RIGHT,r),a.setLocation(t,Q.LEFT,r)}}}},{key:"getCoordinate",value:function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null}},{key:"print",value:function(t){_t.out.println("EdgeEndStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"isAreaLabelsConsistent",value:function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,i=e.get(n).getLabel().getLocation(t,Q.LEFT);G.isTrue(i!==V.NONE,"Found unlabelled area edge");for(var r=i,o=this.iterator();o.hasNext();){var s=o.next().getLabel();G.isTrue(s.isArea(t),"Found non-area edge");var a=s.getLocation(t,Q.LEFT),l=s.getLocation(t,Q.RIGHT);if(a===l)return!1;if(l!==r)return!1;r=a}return!0}},{key:"findIndex",value:function(t){this.iterator();for(var e=0;e<this._edgeList.size();e++)if(this._edgeList.get(e)===t)return e;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return null===this._edgeList&&(this._edgeList=new pt(this._edgeMap.values())),this._edgeList}},{key:"getLocation",value:function(t,e,n){return this._ptInAreaLocation[t]===V.NONE&&(this._ptInAreaLocation[t]=Hn.locate(e,n[t].getGeometry())),this._ptInAreaLocation[t]}},{key:"toString",value:function(){var t=new ot;t.append("EdgeEndStar: "+this.getCoordinate()),t.append("\n");for(var e=this.iterator();e.hasNext();){var n=e.next();t.append(n),t.append("\n")}return t.toString()}},{key:"computeEdgeEndLabels",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)}},{key:"computeLabelling",value:function(t){this.computeEdgeEndLabels(t[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var e=[!1,!1],n=this.iterator();n.hasNext();)for(var i=n.next().getLabel(),r=0;r<2;r++)i.isLine(r)&&i.getLocation(r)===V.BOUNDARY&&(e[r]=!0);for(var o=this.iterator();o.hasNext();)for(var s=o.next(),a=s.getLabel(),l=0;l<2;l++)if(a.isAnyNull(l)){var u=V.NONE;if(e[l])u=V.EXTERIOR;else{var h=s.getCoordinate();u=this.getLocation(l,h,t)}a.setAllLocationsIfNull(l,u)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(t,e){this._edgeMap.put(t,e),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new Ve,this._edgeList=null,this._ptInAreaLocation=[V.NONE,V.NONE]}}]),Xn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var t=null,e=null,n=this._SCANNING_FOR_INCOMING,i=0;i<this._resultAreaEdgeList.size();i++){var r=this._resultAreaEdgeList.get(i),o=r.getSym();if(r.getLabel().isArea())switch(null===t&&r.isInResult()&&(t=r),n){case this._SCANNING_FOR_INCOMING:if(!o.isInResult())continue;e=o,n=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!r.isInResult())continue;e.setNext(r),n=this._SCANNING_FOR_INCOMING}}if(n===this._LINKING_TO_OUTGOING){if(null===t)throw new gt("no outgoing dirEdge found",this.getCoordinate());G.isTrue(t.isInResult(),"unable to link last incoming dirEdge"),e.setNext(t)}}},{key:"insert",value:function(t){var e=t;this.insertEdgeEnd(e,e)}},{key:"getRightmostEdge",value:function(){var t=this.getEdges(),e=t.size();if(e<1)return null;var n=t.get(0);if(1===e)return n;var i=t.get(e-1),r=n.getQuadrant(),o=i.getQuadrant();return Ke.isNorthern(r)&&Ke.isNorthern(o)?n:Ke.isNorthern(r)||Ke.isNorthern(o)?0!==n.getDy()?n:0!==i.getDy()?i:(G.shouldNeverReachHere("found two horizontal edges incident on node"),null):i}},{key:"print",value:function(t){_t.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();){var n=e.next();t.print("out "),n.print(t),t.println(),t.print("in "),n.getSym().print(t),t.println()}}},{key:"getResultAreaEdges",value:function(){if(null!==this._resultAreaEdgeList)return this._resultAreaEdgeList;this._resultAreaEdgeList=new pt;for(var t=this.iterator();t.hasNext();){var e=t.next();(e.isInResult()||e.getSym().isInResult())&&this._resultAreaEdgeList.add(e)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next().getLabel();n.setAllLocationsIfNull(0,t.getLocation(0)),n.setAllLocationsIfNull(1,t.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var t=null,e=null,n=this._edgeList.size()-1;n>=0;n--){var i=this._edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(Q.LEFT),i=t.getDepth(Q.RIGHT),r=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,r)!==i)throw new gt("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a<o;a++){var l=this._edgeList.get(a);l.setEdgeDepths(Q.RIGHT,s),s=l.getDepth(Q.LEFT)}return s}}},{key:"mergeSymLabels",value:function(){for(var t=this.iterator();t.hasNext();){var e=t.next();e.getLabel().merge(e.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(t){for(var e=null,n=null,i=this._SCANNING_FOR_INCOMING,r=this._resultAreaEdgeList.size()-1;r>=0;r--){var o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),i){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(G.isTrue(null!==e,"found null for first outgoing dirEdge"),G.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();)e.next().isInResult()&&t++;return t}if(1===arguments.length){for(var n=arguments[0],i=0,r=this.iterator();r.hasNext();)r.next().getEdgeRing()===n&&i++;return i}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var t=V.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=V.INTERIOR;break}if(i.isInResult()){t=V.EXTERIOR;break}}}if(t===V.NONE)return null;for(var r=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===V.INTERIOR):(s.isInResult()&&(r=V.EXTERIOR),a.isInResult()&&(r=V.INTERIOR))}}},{key:"computeLabelling",value:function(t){f(i,"computeLabelling",this,1).call(this,t),this._label=new Ae(V.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),r=0;r<2;r++){var o=n.getLocation(r);o!==V.INTERIOR&&o!==V.BOUNDARY||this._label.setLocation(r,V.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}])}(Un),Vn=function(t){function i(){return n(this,i),e(this,i)}return u(i,t),o(i,[{key:"createNode",value:function(t){return new Be(t,new Xn)}}])}(Je),jn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compareTo",value:function(e){var n=e;return t.compareOriented(this._pts,this._orientation,n._pts,n._orientation)}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)}},{key:"orientation",value:function(t){return 1===Kt.increasingDirection(t)}},{key:"compareOriented",value:function(t,e,n,i){for(var r=e?1:-1,o=i?1:-1,s=e?t.length:-1,a=i?n.length:-1,l=e?0:t.length-1,u=i?0:n.length-1;;){var h=t[l].compareTo(n[u]);if(0!==h)return h;var c=(l+=r)===s,f=(u+=o)===a;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}}}])}(),Kn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"print",value:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e<this._edges.size();e++){var n=this._edges.get(e);e>0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r<i.length;r++)r>0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")}},{key:"addAll",value:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())}},{key:"findEdgeIndex",value:function(t){for(var e=0;e<this._edges.size();e++)if(this._edges.get(e).equals(t))return e;return-1}},{key:"iterator",value:function(){return this._edges.iterator()}},{key:"getEdges",value:function(){return this._edges}},{key:"get",value:function(t){return this._edges.get(t)}},{key:"findEqualEdge",value:function(t){var e=new jn(t.getCoordinates());return this._ocaMap.get(e)}},{key:"add",value:function(t){this._edges.add(t);var e=new jn(t.getCoordinates());this._ocaMap.put(e,t)}}],[{key:"constructor_",value:function(){this._edges=new pt,this._ocaMap=new Ve}}]),Wn=o(function t(){n(this,t)},[{key:"processIntersections",value:function(t,e,n,i){}},{key:"isDone",value:function(){}}]),Zn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isTrivialIntersection",value:function(e,n,i,r){if(e===i&&1===this._li.getIntersectionNum()){if(t.isAdjacentSegments(n,r))return!0;if(e.isClosed()){var o=e.size()-1;if(0===n&&r===o||0===r&&n===o)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this._properIntersectionPoint}},{key:"hasProperInteriorIntersection",value:function(){return this._hasProperInterior}},{key:"getLineIntersector",value:function(){return this._li}},{key:"hasProperIntersection",value:function(){return this._hasProper}},{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))}},{key:"hasIntersection",value:function(){return this._hasIntersection}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this._hasInterior}},{key:"interfaces_",get:function(){return[Wn]}}],[{key:"constructor_",value:function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this._li=t}},{key:"isAdjacentSegments",value:function(t,e){return 1===Math.abs(t-e)}}])}(),Jn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex),t.println(" dist = "+this.dist)}},{key:"compareTo",value:function(t){var e=t;return this.compare(e.segmentIndex,e.dist)}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===t}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(t,e){return this.segmentIndex<t?-1:this.segmentIndex>t?1:this.dist<e?-1:this.dist>e?1:0}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new z(t),this.segmentIndex=e,this.dist=n}}]),$n=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"addEndpoints",value:function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)}},{key:"createSplitEdge",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=this.edge.pts[e.segmentIndex],r=e.dist>0||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return r&&(o[s]=e.coord),new ri(o,new Ae(this.edge._label))}},{key:"add",value:function(t,e,n){var i=new Jn(t,e,n),r=this._nodeMap.get(i);return null!==r?r:(this._nodeMap.put(i,i),i)}},{key:"isIntersection",value:function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new Ve,this.edge=null;var t=arguments[0];this.edge=t}}]),Qn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])||t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))&&this._matrix[V.EXTERIOR][V.INTERIOR]===St.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===St.FALSE}},{key:"isCoveredBy",value:function(){return(t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])||t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))&&this._matrix[V.INTERIOR][V.EXTERIOR]===St.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===St.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this._matrix[n][i]=St.toDimensionValue(t.charAt(e))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]=s}}},{key:"isContains",value:function(){return t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.EXTERIOR][V.INTERIOR]===St.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===St.FALSE}},{key:"setAtLeast",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this.setAtLeast(n,i,St.toDimensionValue(t.charAt(e)))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]<s&&(this._matrix[r][o]=s)}}},{key:"setAtLeastIfValid",value:function(t,e,n){t>=0&&e>=0&&this.setAtLeast(t,e,n)}},{key:"isWithin",value:function(){return t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.INTERIOR][V.EXTERIOR]===St.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===St.FALSE}},{key:"isTouches",value:function(e,n){return e>n?this.isTouches(n,e):(e===St.A&&n===St.A||e===St.L&&n===St.L||e===St.L&&n===St.A||e===St.P&&n===St.A||e===St.P&&n===St.L)&&this._matrix[V.INTERIOR][V.INTERIOR]===St.FALSE&&(t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))}},{key:"isOverlaps",value:function(e,n){return e===St.P&&n===St.P||e===St.A&&n===St.A?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR]):e===St.L&&n===St.L&&1===this._matrix[V.INTERIOR][V.INTERIOR]&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR])}},{key:"isEquals",value:function(e,n){return e===n&&t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.INTERIOR][V.EXTERIOR]===St.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===St.FALSE&&this._matrix[V.EXTERIOR][V.INTERIOR]===St.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===St.FALSE}},{key:"toString",value:function(){for(var t=new Jt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,St.toDimensionSymbol(this._matrix[e][n]));return t.toString()}},{key:"setAll",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this._matrix[e][n]=t}},{key:"get",value:function(t,e){return this._matrix[t][e]}},{key:"transpose",value:function(){var t=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=t,t=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=t,t=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=t,this}},{key:"matches",value:function(e){if(9!==e.length)throw new _("Should be length 9: "+e);for(var n=0;n<3;n++)for(var i=0;i<3;i++)if(!t.matches(this._matrix[n][i],e.charAt(3*n+i)))return!1;return!0}},{key:"add",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))}},{key:"isDisjoint",value:function(){return this._matrix[V.INTERIOR][V.INTERIOR]===St.FALSE&&this._matrix[V.INTERIOR][V.BOUNDARY]===St.FALSE&&this._matrix[V.BOUNDARY][V.INTERIOR]===St.FALSE&&this._matrix[V.BOUNDARY][V.BOUNDARY]===St.FALSE}},{key:"isCrosses",value:function(e,n){return e===St.P&&n===St.L||e===St.P&&n===St.A||e===St.L&&n===St.A?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR]):e===St.L&&n===St.P||e===St.A&&n===St.P||e===St.A&&n===St.L?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR]):e===St.L&&n===St.L&&0===this._matrix[V.INTERIOR][V.INTERIOR]}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(St.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var e=arguments[0];t.constructor_.call(this),this.set(e)}else if(arguments[0]instanceof t){var n=arguments[0];t.constructor_.call(this),this._matrix[V.INTERIOR][V.INTERIOR]=n._matrix[V.INTERIOR][V.INTERIOR],this._matrix[V.INTERIOR][V.BOUNDARY]=n._matrix[V.INTERIOR][V.BOUNDARY],this._matrix[V.INTERIOR][V.EXTERIOR]=n._matrix[V.INTERIOR][V.EXTERIOR],this._matrix[V.BOUNDARY][V.INTERIOR]=n._matrix[V.BOUNDARY][V.INTERIOR],this._matrix[V.BOUNDARY][V.BOUNDARY]=n._matrix[V.BOUNDARY][V.BOUNDARY],this._matrix[V.BOUNDARY][V.EXTERIOR]=n._matrix[V.BOUNDARY][V.EXTERIOR],this._matrix[V.EXTERIOR][V.INTERIOR]=n._matrix[V.EXTERIOR][V.INTERIOR],this._matrix[V.EXTERIOR][V.BOUNDARY]=n._matrix[V.EXTERIOR][V.BOUNDARY],this._matrix[V.EXTERIOR][V.EXTERIOR]=n._matrix[V.EXTERIOR][V.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return n===St.SYM_DONTCARE||n===St.SYM_TRUE&&(e>=0||e===St.TRUE)||n===St.SYM_FALSE&&e===St.FALSE||n===St.SYM_P&&e===St.P||n===St.SYM_L&&e===St.L||n===St.SYM_A&&e===St.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var i=arguments[1];return new t(arguments[0]).matches(i)}}},{key:"isTrue",value:function(t){return t>=0||t===St.TRUE}}])}(),ti=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(t){return null===t||0===t.length?null:(this.ensureCapacity(this._size+t.length),_t.arraycopy(t,0,this._data,this._size,t.length),void(this._size+=t.length))}},{key:"ensureCapacity",value:function(t){if(t<=this._data.length)return null;var e=Math.max(t,2*this._data.length);this._data=At.copyOf(this._data,e)}},{key:"toArray",value:function(){var t=new Array(this._size).fill(null);return _t.arraycopy(this._data,0,t,0,this._size),t}},{key:"add",value:function(t){this.ensureCapacity(this._size+1),this._data[this._size]=t,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,0===arguments.length)t.constructor_.call(this,10);else if(1===arguments.length){var e=arguments[0];this._data=new Array(e).fill(null)}}}])}(),ei=function(){function t(){n(this,t)}return o(t,[{key:"getChainStartIndices",value:function(t){var e=0,n=new ti(Math.trunc(t.length/2));n.add(e);do{var i=this.findChainEnd(t,e);n.add(i),e=i}while(e<t.length-1);return n.toArray()}},{key:"findChainEnd",value:function(t,e){for(var n=Ke.quadrant(t[e],t[e+1]),i=e+1;i<t.length&&Ke.quadrant(t[i-1],t[i])===n;)i++;return i-1}},{key:"OLDgetChainStartIndices",value:function(e){var n=0,i=new pt;i.add(n);do{var r=this.findChainEnd(e,n);i.add(r),n=r}while(n<e.length-1);return t.toIntArray(i)}}],[{key:"toIntArray",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e}}])}(),ni=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e>n?e:n}},{key:"getMinX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e<n?e:n}},{key:"computeIntersectsForChain",value:function(){if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.computeIntersectsForChain(this.startIndex[t],this.startIndex[t+1],e,e.startIndex[n],e.startIndex[n+1],i)}else if(6===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],l=arguments[4],u=arguments[5];if(o-r==1&&l-a==1)return u.addIntersections(this.e,r,s.e,a),null;if(!this.overlaps(r,o,s,a,l))return null;var h=Math.trunc((r+o)/2),c=Math.trunc((a+l)/2);r<h&&(a<c&&this.computeIntersectsForChain(r,h,s,a,c,u),c<l&&this.computeIntersectsForChain(r,h,s,c,l,u)),h<o&&(a<c&&this.computeIntersectsForChain(h,o,s,a,c,u),c<l&&this.computeIntersectsForChain(h,o,s,c,l,u))}}},{key:"overlaps",value:function(t,e,n,i,r){return U.intersects(this.pts[t],this.pts[e],n.pts[i],n.pts[r])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(t,e){for(var n=0;n<this.startIndex.length-1;n++)for(var i=0;i<t.startIndex.length-1;i++)this.computeIntersectsForChain(n,t,i,e)}}],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var t=arguments[0];this.e=t,this.pts=t.getCoordinates();var e=new ei;this.startIndex=e.getChainStartIndices(this.pts)}}]),ii=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getDepth",value:function(t,e){return this._depth[t][e]}},{key:"setDepth",value:function(t,e,n){this._depth[t][e]=n}},{key:"isNull",value:function(){if(0===arguments.length){for(var e=0;e<2;e++)for(var n=0;n<3;n++)if(this._depth[e][n]!==t.NULL_VALUE)return!1;return!0}if(1===arguments.length){var i=arguments[0];return this._depth[i][1]===t.NULL_VALUE}if(2===arguments.length){var r=arguments[0],o=arguments[1];return this._depth[r][o]===t.NULL_VALUE}}},{key:"normalize",value:function(){for(var t=0;t<2;t++)if(!this.isNull(t)){var e=this._depth[t][1];this._depth[t][2]<e&&(e=this._depth[t][2]),e<0&&(e=0);for(var n=1;n<3;n++){var i=0;this._depth[t][n]>e&&(i=1),this._depth[t][n]=i}}}},{key:"getDelta",value:function(t){return this._depth[t][Q.RIGHT]-this._depth[t][Q.LEFT]}},{key:"getLocation",value:function(t,e){return this._depth[t][e]<=0?V.EXTERIOR:V.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(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var i=1;i<3;i++){var r=e.getLocation(n,i);r!==V.EXTERIOR&&r!==V.INTERIOR||(this.isNull(n,i)?this._depth[n][i]=t.depthAtLocation(r):this._depth[n][i]+=t.depthAtLocation(r))}else if(3===arguments.length){var o=arguments[0],s=arguments[1];arguments[2]===V.INTERIOR&&this._depth[o][s]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var e=0;e<2;e++)for(var n=0;n<3;n++)this._depth[e][n]=t.NULL_VALUE}},{key:"depthAtLocation",value:function(e){return e===V.EXTERIOR?0:e===V.INTERIOR?1:t.NULL_VALUE}}])}();ii.NULL_VALUE=-1;var ri=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new i(t,Ae.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(t){this._isIsolated=t}},{key:"setName",value:function(t){this._name=t}},{key:"equals",value:function(t){if(!(t instanceof i))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,r=!0,o=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(e.pts[s])||(n=!1),this.pts[s].equals2D(e.pts[--o])||(r=!1),!n&&!r)return!1;return!0}},{key:"getCoordinate",value:function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}}},{key:"print",value:function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(t){i.updateIM(this._label,t)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&3===this.pts.length&&!!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(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this._mce&&(this._mce=new ni(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new U;for(var t=0;t<this.pts.length;t++)this._env.expandToInclude(this.pts[t])}return this._env}},{key:"addIntersection",value:function(t,e,n,i){var r=new z(t.getIntersection(i)),o=e,s=t.getEdgeDistance(n,i),a=o+1;if(a<this.pts.length){var l=this.pts[a];r.equals2D(l)&&(o=a,s=0)}this.eiList.add(r,o,s)}},{key:"toString",value:function(){var t=new Jt;t.append("edge "+this._name+": "),t.append("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()}},{key:"isPointwiseEqual",value:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e<this.pts.length;e++)if(!this.pts[e].equals2D(t.pts[e]))return!1;return!0}},{key:"setDepthDelta",value:function(t){this._depthDelta=t}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}}],[{key:"constructor_",value:function(){if(this.pts=null,this._env=null,this.eiList=new $n(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new ii,this._depthDelta=0,1===arguments.length){var t=arguments[0];i.constructor_.call(this,t,null)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.pts=e,this._label=n}}},{key:"updateIM",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Qn&&arguments[0]instanceof Ae))return f(i,"updateIM",this).apply(this,arguments);var t=arguments[0],e=arguments[1];e.setAtLeastIfValid(t.getLocation(0,Q.ON),t.getLocation(1,Q.ON),1),t.isArea()&&(e.setAtLeastIfValid(t.getLocation(0,Q.LEFT),t.getLocation(1,Q.LEFT),2),e.setAtLeastIfValid(t.getLocation(0,Q.RIGHT),t.getLocation(1,Q.RIGHT),2))}}])}(Ge),oi=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"setWorkingPrecisionModel",value:function(t){this._workingPrecisionModel=t}},{key:"insertUniqueEdge",value:function(e){var n=this._edgeList.findEqualEdge(e);if(null!==n){var i=n.getLabel(),r=e.getLabel();n.isPointwiseEqual(e)||(r=new Ae(e.getLabel())).flip(),i.merge(r);var o=t.depthDelta(r),s=n.getDepthDelta()+o;n.setDepthDelta(s)}else this._edgeList.add(e),e.setDepthDelta(t.depthDelta(e.getLabel()))}},{key:"buildSubgraphs",value:function(t,e){for(var n=new pt,i=t.iterator();i.hasNext();){var r=i.next(),o=r.getRightmostCoordinate(),s=new Dn(n).getDepth(o);r.computeDepth(s),r.findResultEdges(),n.add(r),e.add(r.getDirectedEdges(),r.getNodes())}}},{key:"createSubgraphs",value:function(t){for(var e=new pt,n=t.getNodes().iterator();n.hasNext();){var i=n.next();if(!i.isVisited()){var r=new vt;r.create(i),e.add(r)}}return sn.sort(e,sn.reverseOrder()),e}},{key:"createEmptyResultGeometry",value:function(){return this._geomFact.createPolygon()}},{key:"getNoder",value:function(t){if(null!==this._workingNoder)return this._workingNoder;var e=new Nn,n=new Pe;return n.setPrecisionModel(t),e.setSegmentIntersector(new Zn(n)),e}},{key:"buffer",value:function(t,e){var n=this._workingPrecisionModel;null===n&&(n=t.getPrecisionModel()),this._geomFact=t.getFactory();var i=new An(n,this._bufParams),r=new Yn(t,e,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this._graph=new $e(new Vn),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),s=new Qe(this._geomFact);this.buildSubgraphs(o,s);var a=s.getPolygons();return a.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(a)}},{key:"computeNodedEdges",value:function(t,e){var n=this.getNoder(e);n.computeNodes(t);for(var i=n.getNodedSubstrings().iterator();i.hasNext();){var r=i.next(),o=r.getCoordinates();if(2!==o.length||!o[0].equals2D(o[1])){var s=r.getData(),a=new ri(r.getCoordinates(),new Ae(s));this.insertUniqueEdge(a)}}}},{key:"setNoder",value:function(t){this._workingNoder=t}}],[{key:"constructor_",value:function(){this._bufParams=null,this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Kn;var t=arguments[0];this._bufParams=t}},{key:"depthDelta",value:function(t){var e=t.getLocation(0,Q.LEFT),n=t.getLocation(0,Q.RIGHT);return e===V.INTERIOR&&n===V.EXTERIOR?1:e===V.EXTERIOR&&n===V.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(t){for(var e=new se,n=new pt;t.hasNext();){var i=t.next(),r=e.createLineString(i.getCoordinates());n.add(r)}return e.buildGeometry(n)}}])}(),si=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"rescale",value:function(){if(rt(arguments[0],j))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.rescale(e.getCoordinates())}else if(arguments[0]instanceof Array){for(var n=arguments[0],i=0;i<n.length;i++)n[i].x=n[i].x/this._scaleFactor+this._offsetX,n[i].y=n[i].y/this._scaleFactor+this._offsetY;2===n.length&&n[0].equals2D(n[1])&&_t.out.println(n)}}},{key:"scale",value:function(){if(rt(arguments[0],j)){for(var t=arguments[0],e=new pt(t.size()),n=t.iterator();n.hasNext();){var i=n.next();e.add(new xn(this.scale(i.getCoordinates()),i.getData()))}return e}if(arguments[0]instanceof Array){for(var r=arguments[0],o=new Array(r.length).fill(null),s=0;s<r.length;s++)o[s]=new z(Math.round((r[s].x-this._offsetX)*this._scaleFactor),Math.round((r[s].y-this._offsetY)*this._scaleFactor),r[s].getZ());return Kt.removeRepeatedPoints(o)}}},{key:"isIntegerPrecision",value:function(){return 1===this._scaleFactor}},{key:"getNodedSubstrings",value:function(){var t=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(t),t}},{key:"computeNodes",value:function(t){var e=t;this._isScaled&&(e=this.scale(t)),this._noder.computeNodes(e)}},{key:"interfaces_",get:function(){return[bn]}}],[{key:"constructor_",value:function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){var e=arguments[0],n=arguments[1];t.constructor_.call(this,e,n,0,0)}else if(4===arguments.length){var i=arguments[0],r=arguments[1];this._noder=i,this._scaleFactor=r,this._isScaled=!this.isIntegerPrecision()}}}])}(),ai=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"checkEndPtVertexIntersections",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next().getCoordinates();this.checkEndPtVertexIntersections(e[0],this._segStrings),this.checkEndPtVertexIntersections(e[e.length-1],this._segStrings)}else if(2===arguments.length)for(var n=arguments[0],i=arguments[1].iterator();i.hasNext();)for(var r=i.next().getCoordinates(),o=1;o<r.length-1;o++)if(r[o].equals(n))throw new R("found endpt/interior pt intersection at index "+o+" :pt "+n)}},{key:"checkInteriorIntersections",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();)for(var e=t.next(),n=this._segStrings.iterator();n.hasNext();){var i=n.next();this.checkInteriorIntersections(e,i)}else if(2===arguments.length)for(var r=arguments[0],o=arguments[1],s=r.getCoordinates(),a=o.getCoordinates(),l=0;l<s.length-1;l++)for(var u=0;u<a.length-1;u++)this.checkInteriorIntersections(r,l,o,u);else if(4===arguments.length){var h=arguments[0],c=arguments[1],f=arguments[2],g=arguments[3];if(h===f&&c===g)return null;var d=h.getCoordinates()[c],p=h.getCoordinates()[c+1],y=f.getCoordinates()[g],v=f.getCoordinates()[g+1];if(this._li.computeIntersection(d,p,y,v),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,d,p)||this.hasInteriorIntersection(this._li,y,v)))throw new R("found non-noded intersection at "+d+"-"+p+" and "+y+"-"+v)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next();this.checkCollapses(e)}else if(1===arguments.length)for(var n=arguments[0].getCoordinates(),i=0;i<n.length-2;i++)this.checkCollapse(n[i],n[i+1],n[i+2])}},{key:"hasInteriorIntersection",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++){var r=t.getIntersection(i);if(!r.equals(e)&&!r.equals(n))return!0}return!1}},{key:"checkCollapse",value:function(e,n,i){if(e.equals(i))throw new R("found non-noded collapse at "+t.fact.createLineString([e,n,i]))}}],[{key:"constructor_",value:function(){this._li=new Pe,this._segStrings=null;var t=arguments[0];this._segStrings=t}}])}();ai.fact=new se;var li=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"intersectsScaled",value:function(t,e){var n=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.y,e.y),s=this._maxx<n||this._minx>i||this._maxy<r||this._miny>o;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return G.isTrue(!(s&&a),"Found bad envelope test"),a}},{key:"initCorners",value:function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new z(this._maxx,this._maxy),this._corner[1]=new z(this._minx,this._maxy),this._corner[2]=new z(this._minx,this._miny),this._corner[3]=new z(this._maxx,this._miny)}},{key:"intersects",value:function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(t){return Math.round(t*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._safeEnv){var e=t.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new U(this._originalPt.x-e,this._originalPt.x+e,this._originalPt.y-e,this._originalPt.y+e)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))}},{key:"intersectsToleranceSquare",value:function(t,e){var n=!1,i=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&i||t.equals(this._pt)||e.equals(this._pt)))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!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 t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new _("Scale factor must be non-zero");1!==e&&(this._pt=new z(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new z,this._p1Scaled=new z),this.initCorners(this._pt)}}])}();li.SAFE_ENV_EXPANSION_FACTOR=.75;var ui=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"select",value:function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new En}}]),hi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"snap",value:function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],i=arguments[1],r=arguments[2],s=e.getSafeEnvelope(),a=new ci(e,i,r);return this._index.query(s,new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[un]}},{key:"visitItem",value:function(t){t.select(s,a)}}]))),a.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}]),ci=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof In))return f(i,"select",this,1).apply(this,arguments);var t=arguments[1],e=arguments[0].getContext();if(this._parentEdge===e&&(t===this._hotPixelVertexIndex||t+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(e,t)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._hotPixel=t,this._parentEdge=e,this._hotPixelVertexIndex=n}}])}(ui);hi.HotPixelSnapAction=ci;var fi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l<this._li.getIntersectionNum();l++)this._interiorIntersections.add(this._li.getIntersection(l));t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this._interiorIntersections}},{key:"interfaces_",get:function(){return[Wn]}}],[{key:"constructor_",value:function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new pt}}]),gi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"checkCorrectness",value:function(t){var e=xn.getNodedSubstrings(t),n=new ai(e);try{n.checkValid()}catch(i){if(!(i instanceof m))throw i;i.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return xn.getNodedSubstrings(this._nodedSegStrings)}},{key:"snapRound",value:function(t,e){var n=this.findInteriorIntersections(t,e);this.computeIntersectionSnaps(n),this.computeVertexSnaps(t)}},{key:"findInteriorIntersections",value:function(t,e){var n=new fi(e);return this._noder.setSegmentIntersector(n),this._noder.computeNodes(t),n.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(rt(arguments[0],j))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.computeVertexSnaps(e)}else if(arguments[0]instanceof xn)for(var n=arguments[0],i=n.getCoordinates(),r=0;r<i.length;r++){var o=new li(i[r],this._scaleFactor,this._li);this._pointSnapper.snap(o,n,r)&&n.addIntersection(i[r],r)}}},{key:"computeNodes",value:function(t){this._nodedSegStrings=t,this._noder=new Nn,this._pointSnapper=new hi(this._noder.getIndex()),this.snapRound(t,this._li)}},{key:"computeIntersectionSnaps",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=new li(n,this._scaleFactor,this._li);this._pointSnapper.snap(i)}}},{key:"interfaces_",get:function(){return[bn]}}],[{key:"constructor_",value:function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var t=arguments[0];this._pm=t,this._li=new Pe,this._li.setPrecisionModel(t),this._scaleFactor=t.getScale()}}]),di=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"bufferFixedPrecision",value:function(t){var e=new si(new gi(new ie(1)),t.getScale()),n=new oi(this._bufParams);n.setWorkingPrecisionModel(t),n.setNoder(e),this._resultGeometry=n.buffer(this._argGeom,this._distance)}},{key:"bufferReducedPrecision",value:function(){if(0===arguments.length){for(var e=t.MAX_PRECISION_DIGITS;e>=0;e--){try{this.bufferReducedPrecision(e)}catch(o){if(!(o instanceof gt))throw o;this._saveException=o}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],i=t.precisionScaleFactor(this._argGeom,this._distance,n),r=new ie(i);this.bufferFixedPrecision(r)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===ie.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this._bufParams.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new oi(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(e){if(!(e instanceof R))throw e;this._saveException=e}}},{key:"getResultGeometry",value:function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(t){this._bufParams.setEndCapStyle(t)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new v,this._resultGeometry=null,this._saveException=null,1===arguments.length){var t=arguments[0];this._argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._argGeom=e,this._bufParams=n}}},{key:"bufferOp",value:function(){if(2===arguments.length){var e=arguments[1];return new t(arguments[0]).getResultGeometry(e)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof X&&"number"==typeof arguments[1]){var n=arguments[1],i=arguments[2],r=new t(arguments[0]);return r.setQuadrantSegments(i),r.getResultGeometry(n)}if(arguments[2]instanceof v&&arguments[0]instanceof X&&"number"==typeof arguments[1]){var o=arguments[1];return new t(arguments[0],arguments[2]).getResultGeometry(o)}}else if(4===arguments.length){var s=arguments[1],a=arguments[2],l=arguments[3],u=new t(arguments[0]);return u.setQuadrantSegments(a),u.setEndCapStyle(l),u.getResultGeometry(s)}}},{key:"precisionScaleFactor",value:function(t,e,n){var i=t.getEnvelopeInternal(),r=kt.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)}}])}();di.CAP_ROUND=v.CAP_ROUND,di.CAP_BUTT=v.CAP_FLAT,di.CAP_FLAT=v.CAP_FLAT,di.CAP_SQUARE=v.CAP_SQUARE,di.MAX_PRECISION_DIGITS=12;var pi=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],yi=o(function t(e){n(this,t),this.geometryFactory=e||new se},[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!vi[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==pi.indexOf(n)?vi[n].call(this,e.coordinates):"GeometryCollection"===n?vi[n].call(this,e.geometries):vi[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!mi[e])throw new Error("Geometry is not supported");return mi[e].call(this,t)}}]),vi={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!vi[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=vi.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n<t.features.length;++n)e.features.push(this.read(t.features[n]))}return t.bbox&&(e.bbox=this.parse.bbox.call(this,t.bbox)),e},coordinates:function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n];e.push(i(z,g(r)))}return e},bbox:function(t){return this.geometryFactory.createLinearRing([new z(t[0],t[1]),new z(t[2],t[1]),new z(t[2],t[3]),new z(t[0],t[3]),new z(t[0],t[1])])},Point:function(t){var e=i(z,g(t));return this.geometryFactory.createPoint(e)},MultiPoint:function(t){for(var e=[],n=0;n<t.length;++n)e.push(vi.Point.call(this,t[n]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=vi.coordinates.call(this,t);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push(vi.LineString.call(this,t[n]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=vi.coordinates.call(this,t[0]),n=this.geometryFactory.createLinearRing(e),i=[],r=1;r<t.length;++r){var o=t[r],s=vi.coordinates.call(this,o),a=this.geometryFactory.createLinearRing(s);i.push(a)}return this.geometryFactory.createPolygon(n,i)},MultiPolygon:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(vi.Polygon.call(this,i))}return this.geometryFactory.createMultiPolygon(e)},GeometryCollection:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(this.read(i))}return this.geometryFactory.createGeometryCollection(e)}},mi={coordinate:function(t){var e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e},Point:function(t){return{type:"Point",coordinates:mi.coordinate.call(this,t.getCoordinate())}},MultiPoint:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.Point.call(this,i);e.push(r.coordinates)}return{type:"MultiPoint",coordinates:e}},LineString:function(t){for(var e=[],n=t.getCoordinates(),i=0;i<n.length;++i){var r=n[i];e.push(mi.coordinate.call(this,r))}return{type:"LineString",coordinates:e}},MultiLineString:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.LineString.call(this,i);e.push(r.coordinates)}return{type:"MultiLineString",coordinates:e}},Polygon:function(t){var e=[],n=mi.LineString.call(this,t._shell);e.push(n.coordinates);for(var i=0;i<t._holes.length;++i){var r=t._holes[i],o=mi.LineString.call(this,r);e.push(o.coordinates)}return{type:"Polygon",coordinates:e}},MultiPolygon:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.Polygon.call(this,i);e.push(r.coordinates)}return{type:"MultiPolygon",coordinates:e}},GeometryCollection:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=i.getGeometryType();e.push(mi[r].call(this,i))}return{type:"GeometryCollection",geometries:e}}};return{BufferOp:di,GeoJSONReader:o(function t(e){n(this,t),this.parser=new yi(e||new se)},[{key:"read",value:function(t){return this.parser.read(t)}}]),GeoJSONWriter:o(function t(){n(this,t),this.parser=new yi(this.geometryFactory)},[{key:"write",value:function(t){return this.parser.write(t)}}])}}()),Ie.exports);const be=N(Me);function Se(){return new Ne}function Ne(){this.reset()}Ne.prototype={constructor:Ne,reset:function(){this.s=this.t=0},add:function(t){Pe(Le,t,this.t),Pe(this,Le.s,this.s),this.s?this.t+=Le.t:this.s=Le.t},valueOf:function(){return this.s}};var Le=new Ne;function Pe(t,e,n){var i=t.s=e+n,r=i-e,o=i-r;t.t=e-o+(n-r)}var Ce=1e-6,Te=Math.PI,Oe=Te/2,Ae=Te/4,De=2*Te,Re=180/Te,Fe=Te/180,Ge=Math.abs,Be=Math.atan,Ye=Math.atan2,qe=Math.cos,ze=Math.sin,He=Math.sqrt;function Ue(t){return t>1?0:t<-1?Te:Math.acos(t)}function Xe(t){return t>1?Oe:t<-1?-Oe:Math.asin(t)}function Ve(){}function je(t,e){t&&Je.hasOwnProperty(t.type)&&Je[t.type](t,e)}var Ke,We,Ze={Feature:function(t,e){je(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i<r;)je(n[i].geometry,e)}},Je={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)t=n[i],e.point(t[0],t[1],t[2])},LineString:function(t,e){$e(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)$e(n[i],e,0)},Polygon:function(t,e){Qe(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)Qe(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,r=n.length;++i<r;)je(n[i],e)}};function $e(t,e,n){var i,r=-1,o=t.length-n;for(e.lineStart();++r<o;)i=t[r],e.point(i[0],i[1],i[2]);e.lineEnd()}function Qe(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)$e(t[n],e,1);e.polygonEnd()}function tn(t){return[Ye(t[1],t[0]),Xe(t[2])]}function en(t){var e=t[0],n=t[1],i=qe(n);return[i*qe(e),i*ze(e),ze(n)]}function nn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function rn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function on(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function sn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function an(t){var e=He(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ln(t,e){function n(n,i){return n=t(n,i),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,i){return(n=e.invert(n,i))&&t.invert(n[0],n[1])}),n}function un(t,e){return[t>Te?t-De:t<-Te?t+De:t,e]}function hn(t){return function(e,n){return[(e+=t)>Te?e-De:e<-Te?e+De:e,n]}}function cn(t){var e=hn(t);return e.invert=hn(-t),e}function fn(t,e){var n=qe(t),i=ze(t),r=qe(e),o=ze(e);function s(t,e){var s=qe(e),a=qe(t)*s,l=ze(t)*s,u=ze(e),h=u*n+a*i;return[Ye(l*r-h*o,a*n-u*i),Xe(h*r+l*o)]}return s.invert=function(t,e){var s=qe(e),a=qe(t)*s,l=ze(t)*s,u=ze(e),h=u*r-l*o;return[Ye(l*r+u*o,a*n+h*i),Xe(h*n-a*i)]},s}function gn(t,e){(e=en(e))[0]-=t,an(e);var n=Ue(-e[1]);return((-e[2]<0?-n:n)+De-Ce)%De}function dn(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:Ve,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function pn(t,e){return Ge(t[0]-e[0])<Ce&&Ge(t[1]-e[1])<Ce}function yn(t,e,n,i){this.x=t,this.z=e,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function vn(t,e,n,i,r){var o,s,a=[],l=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,i=t[0],s=t[e];if(pn(i,s)){for(r.lineStart(),o=0;o<e;++o)r.point((i=t[o])[0],i[1]);r.lineEnd()}else a.push(n=new yn(i,t,null,!0)),l.push(n.o=new yn(i,null,n,!1)),a.push(n=new yn(s,t,null,!1)),l.push(n.o=new yn(s,null,n,!0))}}),a.length){for(l.sort(e),mn(a),mn(l),o=0,s=l.length;o<s;++o)l[o].e=n=!n;for(var u,h,c=a[0];;){for(var f=c,g=!0;f.v;)if((f=f.n)===c)return;u=f.z,r.lineStart();do{if(f.v=f.o.v=!0,f.e){if(g)for(o=0,s=u.length;o<s;++o)r.point((h=u[o])[0],h[1]);else i(f.x,f.n.x,1,r);f=f.n}else{if(g)for(u=f.p.z,o=u.length-1;o>=0;--o)r.point((h=u[o])[0],h[1]);else i(f.x,f.p.x,-1,r);f=f.p}u=(f=f.o).z,g=!g}while(!f.v);r.lineEnd()}}}function mn(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i<e;)r.n=n=t[i],n.p=r,r=n;r.n=n=t[0],n.p=r}}function _n(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function kn(t){for(var e,n,i,r=t.length,o=-1,s=0;++o<r;)s+=t[o].length;for(n=new Array(s);--r>=0;)for(e=(i=t[r]).length;--e>=0;)n[--s]=i[e];return n}Se(),Se(),Se(),un.invert=un,1===(Ke=_n).length&&(We=Ke,Ke=function(t,e){return _n(We(t),e)});var xn=1e9,En=-xn;function wn(t,e,n,i){function r(r,o){return t<=r&&r<=n&&e<=o&&o<=i}function o(r,o,a,u){var h=0,c=0;if(null==r||(h=s(r,a))!==(c=s(o,a))||l(r,o)<0^a>0)do{u.point(0===h||3===h?t:n,h>1?i:e)}while((h=(h+a+4)%4)!==c);else u.point(o[0],o[1])}function s(i,r){return Ge(i[0]-t)<Ce?r>0?0:3:Ge(i[0]-n)<Ce?r>0?2:1:Ge(i[1]-e)<Ce?r>0?1:0:r>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var n=s(t,1),i=s(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(s){var l,u,h,c,f,g,d,p,y,v,m,_=s,k=dn(),x={point:E,lineStart:function(){x.point=w,u&&u.push(h=[]);v=!0,y=!1,d=p=NaN},lineEnd:function(){l&&(w(c,f),g&&y&&k.rejoin(),l.push(k.result()));x.point=E,y&&_.lineEnd()},polygonStart:function(){_=k,l=[],u=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=u.length;n<r;++n)for(var o,s,a=u[n],l=1,h=a.length,c=a[0],f=c[0],g=c[1];l<h;++l)o=f,s=g,f=(c=a[l])[0],g=c[1],s<=i?g>i&&(f-o)*(i-s)>(g-s)*(t-o)&&++e:g<=i&&(f-o)*(i-s)<(g-s)*(t-o)&&--e;return e}(),n=m&&e,r=(l=kn(l)).length;(n||r)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&vn(l,a,e,o,s),s.polygonEnd());_=s,l=u=h=null}};function E(t,e){r(t,e)&&_.point(t,e)}function w(o,s){var a=r(o,s);if(u&&h.push([o,s]),v)c=o,f=s,g=a,v=!1,a&&(_.lineStart(),_.point(o,s));else if(a&&y)_.point(o,s);else{var l=[d=Math.max(En,Math.min(xn,d)),p=Math.max(En,Math.min(xn,p))],k=[o=Math.max(En,Math.min(xn,o)),s=Math.max(En,Math.min(xn,s))];!function(t,e,n,i,r,o){var s,a=t[0],l=t[1],u=0,h=1,c=e[0]-a,f=e[1]-l;if(s=n-a,c||!(s>0)){if(s/=c,c<0){if(s<u)return;s<h&&(h=s)}else if(c>0){if(s>h)return;s>u&&(u=s)}if(s=r-a,c||!(s<0)){if(s/=c,c<0){if(s>h)return;s>u&&(u=s)}else if(c>0){if(s<u)return;s<h&&(h=s)}if(s=i-l,f||!(s>0)){if(s/=f,f<0){if(s<u)return;s<h&&(h=s)}else if(f>0){if(s>h)return;s>u&&(u=s)}if(s=o-l,f||!(s<0)){if(s/=f,f<0){if(s>h)return;s>u&&(u=s)}else if(f>0){if(s<u)return;s<h&&(h=s)}return u>0&&(t[0]=a+u*c,t[1]=l+u*f),h<1&&(e[0]=a+h*c,e[1]=l+h*f),!0}}}}}(l,k,t,e,n,i)?a&&(_.lineStart(),_.point(o,s),m=!1):(y||(_.lineStart(),_.point(l[0],l[1])),_.point(k[0],k[1]),a||_.lineEnd(),m=!1)}d=o,p=s,y=a}return x}}var In=Se();function Mn(t){return t}Se(),Se(),Se();var bn=1/0,Sn=bn,Nn=-bn,Ln=Nn,Pn={point:function(t,e){t<bn&&(bn=t);t>Nn&&(Nn=t);e<Sn&&(Sn=e);e>Ln&&(Ln=e)},lineStart:Ve,lineEnd:Ve,polygonStart:Ve,polygonEnd:Ve,result:function(){var t=[[bn,Sn],[Nn,Ln]];return Nn=Ln=-(Sn=bn=1/0),t}};function Cn(t,e,n,i){return function(r,o){var s,a,l,u=e(o),h=r.invert(i[0],i[1]),c=dn(),f=e(c),g=!1,d={point:p,lineStart:v,lineEnd:m,polygonStart:function(){d.point=_,d.lineStart=k,d.lineEnd=x,a=[],s=[]},polygonEnd:function(){d.point=p,d.lineStart=v,d.lineEnd=m,a=kn(a);var t=function(t,e){var n=e[0],i=e[1],r=[ze(n),-qe(n),0],o=0,s=0;In.reset();for(var a=0,l=t.length;a<l;++a)if(h=(u=t[a]).length)for(var u,h,c=u[h-1],f=c[0],g=c[1]/2+Ae,d=ze(g),p=qe(g),y=0;y<h;++y,f=m,d=k,p=x,c=v){var v=u[y],m=v[0],_=v[1]/2+Ae,k=ze(_),x=qe(_),E=m-f,w=E>=0?1:-1,I=w*E,M=I>Te,b=d*k;if(In.add(Ye(b*w*ze(I),p*x+b*qe(I))),o+=M?E+w*De:E,M^f>=n^m>=n){var S=rn(en(c),en(v));an(S);var N=rn(r,S);an(N);var L=(M^E>=0?-1:1)*Xe(N[2]);(i>L||i===L&&(S[0]||S[1]))&&(s+=M^E>=0?1:-1)}}return(o<-1e-6||o<Ce&&In<-1e-6)^1&s}(s,h);a.length?(g||(o.polygonStart(),g=!0),vn(a,On,t,n,o)):t&&(g||(o.polygonStart(),g=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),g&&(o.polygonEnd(),g=!1),a=s=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function p(e,n){var i=r(e,n);t(e=i[0],n=i[1])&&o.point(e,n)}function y(t,e){var n=r(t,e);u.point(n[0],n[1])}function v(){d.point=y,u.lineStart()}function m(){d.point=p,u.lineEnd()}function _(t,e){l.push([t,e]);var n=r(t,e);f.point(n[0],n[1])}function k(){f.lineStart(),l=[]}function x(){_(l[0][0],l[0][1]),f.lineEnd();var t,e,n,i,r=f.clean(),u=c.result(),h=u.length;if(l.pop(),s.push(l),l=null,h)if(1&r){if((e=(n=u[0]).length-1)>0){for(g||(o.polygonStart(),g=!0),o.lineStart(),t=0;t<e;++t)o.point((i=n[t])[0],i[1]);o.lineEnd()}}else h>1&&2&r&&u.push(u.pop().concat(u.shift())),a.push(u.filter(Tn))}return d}}function Tn(t){return t.length>1}function On(t,e){return((t=t.x)[0]<0?t[1]-Oe-Ce:Oe-t[1])-((e=e.x)[0]<0?e[1]-Oe-Ce:Oe-e[1])}Se();const An=Cn(function(){return!0},function(t){var e,n=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?Te:-Te,l=Ge(o-n);Ge(l-Te)<Ce?(t.point(n,i=(i+s)/2>0?Oe:-Oe),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),e=0):r!==a&&l>=Te&&(Ge(n-r)<Ce&&(n-=r*Ce),Ge(o-a)<Ce&&(o-=a*Ce),i=function(t,e,n,i){var r,o,s=ze(t-n);return Ge(s)>Ce?Be((ze(e)*(o=qe(i))*ze(n)-ze(i)*(r=qe(e))*ze(t))/(r*o*s)):(e+i)/2}(n,i,o,s),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),e=0),t.point(n=o,i=s),r=a},lineEnd:function(){t.lineEnd(),n=i=NaN},clean:function(){return 2-e}}},function(t,e,n,i){var r;if(null==t)r=n*Oe,i.point(-Te,r),i.point(0,r),i.point(Te,r),i.point(Te,0),i.point(Te,-r),i.point(0,-r),i.point(-Te,-r),i.point(-Te,0),i.point(-Te,r);else if(Ge(t[0]-e[0])>Ce){var o=t[0]<e[0]?Te:-Te;r=n*o/2,i.point(-o,r),i.point(0,r),i.point(o,r)}else i.point(e[0],e[1])},[-Te,-Oe]);function Dn(t,e){var n=qe(t),i=n>0,r=Ge(n)>Ce;function o(t,e){return qe(t)*qe(e)>n}function s(t,e,i){var r=[1,0,0],o=rn(en(t),en(e)),s=nn(o,o),a=o[0],l=s-a*a;if(!l)return!i&&t;var u=n*s/l,h=-n*a/l,c=rn(r,o),f=sn(r,u);on(f,sn(o,h));var g=c,d=nn(f,g),p=nn(g,g),y=d*d-p*(nn(f,f)-1);if(!(y<0)){var v=He(y),m=sn(g,(-d-v)/p);if(on(m,f),m=tn(m),!i)return m;var _,k=t[0],x=e[0],E=t[1],w=e[1];x<k&&(_=k,k=x,x=_);var I=x-k,M=Ge(I-Te)<Ce;if(!M&&w<E&&(_=E,E=w,w=_),M||I<Ce?M?E+w>0^m[1]<(Ge(m[0]-k)<Ce?E:w):E<=m[1]&&m[1]<=w:I>Te^(k<=m[0]&&m[0]<=x)){var b=sn(g,(-d+v)/p);return on(b,f),[m,tn(b)]}}}function a(e,n){var r=i?t:Te-t,o=0;return e<-r?o|=1:e>r&&(o|=2),n<-r?o|=4:n>r&&(o|=8),o}return Cn(o,function(t){var e,n,l,u,h;return{lineStart:function(){u=l=!1,h=1},point:function(c,f){var g,d=[c,f],p=o(c,f),y=i?p?0:a(c,f):p?a(c+(c<0?Te:-Te),f):0;if(!e&&(u=l=p)&&t.lineStart(),p!==l&&(!(g=s(e,d))||pn(e,g)||pn(d,g))&&(d[0]+=Ce,d[1]+=Ce,p=o(d[0],d[1])),p!==l)h=0,p?(t.lineStart(),g=s(d,e),t.point(g[0],g[1])):(g=s(e,d),t.point(g[0],g[1]),t.lineEnd()),e=g;else if(r&&e&&i^p){var v;y&n||!(v=s(d,e,!0))||(h=0,i?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!p||e&&pn(e,d)||t.point(d[0],d[1]),e=d,l=p,n=y},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return h|(u&&l)<<1}}},function(n,i,r,o){!function(t,e,n,i,r,o){if(n){var s=qe(e),a=ze(e),l=i*n;null==r?(r=e+i*De,o=e-l/2):(r=gn(s,r),o=gn(s,o),(i>0?r<o:r>o)&&(r+=i*De));for(var u,h=r;i>0?h>o:h<o;h-=l)u=tn([s,-a*qe(h),-a*ze(h)]),t.point(u[0],u[1])}}(o,t,e,r,n,i)},i?[0,-t]:[-Te,t-Te])}function Rn(t){return function(e){var n=new Fn;for(var i in t)n[i]=t[i];return n.stream=e,n}}function Fn(){}function Gn(t,e,n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),null!=o&&t.clipExtent(null),function(t,e){t&&Ze.hasOwnProperty(t.type)?Ze[t.type](t,e):je(t,e)}(n,t.stream(Pn));var s=Pn.result(),a=Math.min(i/(s[1][0]-s[0][0]),r/(s[1][1]-s[0][1])),l=+e[0][0]+(i-a*(s[1][0]+s[0][0]))/2,u=+e[0][1]+(r-a*(s[1][1]+s[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*a).translate([l,u])}Fn.prototype={constructor:Fn,point:function(t,e){this.stream.point(t,e)},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()}};var Bn=qe(30*Fe);function Yn(t,e){return+e?function(t,e){function n(i,r,o,s,a,l,u,h,c,f,g,d,p,y){var v=u-i,m=h-r,_=v*v+m*m;if(_>4*e&&p--){var k=s+f,x=a+g,E=l+d,w=He(k*k+x*x+E*E),I=Xe(E/=w),M=Ge(Ge(E)-1)<Ce||Ge(o-c)<Ce?(o+c)/2:Ye(x,k),b=t(M,I),S=b[0],N=b[1],L=S-i,P=N-r,C=m*L-v*P;(C*C/_>e||Ge((v*L+m*P)/_-.5)>.3||s*f+a*g+l*d<Bn)&&(n(i,r,o,s,a,l,S,N,M,k/=w,x/=w,E,p,y),y.point(S,N),n(S,N,M,k,x,E,u,h,c,f,g,d,p,y))}}return function(e){var i,r,o,s,a,l,u,h,c,f,g,d,p={point:y,lineStart:v,lineEnd:_,polygonStart:function(){e.polygonStart(),p.lineStart=k},polygonEnd:function(){e.polygonEnd(),p.lineStart=v}};function y(n,i){n=t(n,i),e.point(n[0],n[1])}function v(){h=NaN,p.point=m,e.lineStart()}function m(i,r){var o=en([i,r]),s=t(i,r);n(h,c,u,f,g,d,h=s[0],c=s[1],u=i,f=o[0],g=o[1],d=o[2],16,e),e.point(h,c)}function _(){p.point=y,e.lineEnd()}function k(){v(),p.point=x,p.lineEnd=E}function x(t,e){m(i=t,e),r=h,o=c,s=f,a=g,l=d,p.point=m}function E(){n(h,c,u,f,g,d,r,o,i,s,a,l,16,e),p.lineEnd=_,_()}return p}}(t,e):function(t){return Rn({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var qn=Rn({point:function(t,e){this.stream.point(t*Fe,e*Fe)}});function zn(t){return function(t){var e,n,i,r,o,s,a,l,u,h,c=150,f=480,g=250,d=0,p=0,y=0,v=0,m=0,_=null,k=An,x=null,E=Mn,w=.5,I=Yn(S,w);function M(t){return[(t=o(t[0]*Fe,t[1]*Fe))[0]*c+n,i-t[1]*c]}function b(t){return(t=o.invert((t[0]-n)/c,(i-t[1])/c))&&[t[0]*Re,t[1]*Re]}function S(t,r){return[(t=e(t,r))[0]*c+n,i-t[1]*c]}function N(){o=ln(r=function(t,e,n){return(t%=De)?e||n?ln(cn(t),fn(e,n)):cn(t):e||n?fn(e,n):un}(y,v,m),e);var t=e(d,p);return n=f-t[0]*c,i=g+t[1]*c,L()}function L(){return u=h=null,M}return M.stream=function(t){return u&&h===t?u:u=qn(k(r,I(E(h=t))))},M.clipAngle=function(t){return arguments.length?(k=+t?Dn(_=t*Fe,6*Fe):(_=null,An),L()):_*Re},M.clipExtent=function(t){return arguments.length?(E=null==t?(x=s=a=l=null,Mn):wn(x=+t[0][0],s=+t[0][1],a=+t[1][0],l=+t[1][1]),L()):null==x?null:[[x,s],[a,l]]},M.scale=function(t){return arguments.length?(c=+t,N()):c},M.translate=function(t){return arguments.length?(f=+t[0],g=+t[1],N()):[f,g]},M.center=function(t){return arguments.length?(d=t[0]%360*Fe,p=t[1]%360*Fe,N()):[d*Re,p*Re]},M.rotate=function(t){return arguments.length?(y=t[0]%360*Fe,v=t[1]%360*Fe,m=t.length>2?t[2]%360*Fe:0,N()):[y*Re,v*Re,m*Re]},M.precision=function(t){return arguments.length?(I=Yn(S,w=t*t),L()):He(w)},M.fitExtent=function(t,e){return Gn(M,t,e)},M.fitSize=function(t,e){return function(t,e,n){return Gn(t,[[0,0],e],n)}(M,t,e)},function(){return e=t.apply(this,arguments),M.invert=e.invert&&b,N()}}(function(){return t})()}function Hn(t){return function(e,n){var i=qe(e),r=qe(n),o=t(i*r);return[o*r*ze(e),o*ze(n)]}}function Un(t){return function(e,n){var i=He(e*e+n*n),r=t(i),o=ze(r),s=qe(r);return[Ye(e*o,i*s),Xe(i&&n*o/i)]}}Hn(function(t){return He(2/(1+t))}).invert=Un(function(t){return 2*Xe(t/2)});var Xn=Hn(function(t){return(t=Ue(t))&&t/ze(t)});function Vn(t,e){return[t,e]}Xn.invert=Un(function(t){return t}),Vn.invert=Vn;var{BufferOp:jn,GeoJSONReader:Kn,GeoJSONWriter:Wn}=be;function Zn(t,e,n,i){var r=t.properties||{},o="Feature"===t.type?t.geometry:t;if("GeometryCollection"===o.type){var s=[];return M(t,function(t){var r=Zn(t,e,n,i);r&&s.push(r)}),y(s)}var a=function(t){var e=function(t,e={}){const n=xe(t);return g([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}(t).geometry.coordinates,n=[-e[0],-e[1]];return zn(Xn).scale(79.4188).clipAngle(179.999).rotate(n).scale(h)}(o),l={type:o.type,coordinates:$n(o.coordinates,a)},u=(new Kn).read(l),c=m(_(e,n),"meters"),d=jn.bufferOp(u,c,i);if(!Jn((d=(new Wn).write(d)).coordinates))return f({type:d.type,coordinates:Qn(d.coordinates,a)},r)}function Jn(t){return Array.isArray(t[0])?Jn(t[0]):isNaN(t[0])}function $n(t,e){return"object"!=typeof t[0]?e(t):t.map(function(t){return $n(t,e)})}function Qn(t,e){return"object"!=typeof t[0]?e.invert(t):t.map(function(t){return Qn(t,e)})}var ti=function(t,e,n){var i=(n=n||{}).units||"kilometers",r=n.steps||8;if(!t)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");var o=[];switch(t.type){case"GeometryCollection":return M(t,function(t){var n=Zn(t,e,i,r);n&&o.push(n)}),y(o);case"FeatureCollection":return I(t,function(t){var n=Zn(t,e,i,r);n&&I(n,function(t){t&&o.push(t)})}),y(o)}return Zn(t,e,i,r)};function ei(t,e={}){var n="object"==typeof e?e.mutate:e;if(!t)throw new Error("geojson is required");var i=nt(t),r=[];switch(i){case"LineString":r=ni(t,i);break;case"MultiLineString":case"Polygon":tt(t).forEach(function(t){r.push(ni(t,i))});break;case"MultiPolygon":tt(t).forEach(function(t){var e=[];t.forEach(function(t){e.push(ni(t,i))}),r.push(e)});break;case"Point":return t;case"MultiPoint":var o={};tt(t).forEach(function(t){var e=t.join("-");Object.prototype.hasOwnProperty.call(o,e)||(r.push(t),o[e]=!0)});break;default:throw new Error(i+" geometry not supported")}return t.coordinates?!0===n?(t.coordinates=r,t):{type:i,coordinates:r}:!0===n?(t.geometry.coordinates=r,t):f({type:i,coordinates:r},t.properties,{bbox:t.bbox,id:t.id})}function ni(t,e){var n=tt(t);if(2===n.length&&!ii(n[0],n[1]))return n;var i=[],r=n.length-1,o=i.length;i.push(n[0]);for(var s=1;s<r;s++){var a=i[i.length-1];n[s][0]===a[0]&&n[s][1]===a[1]||(i.push(n[s]),(o=i.length)>2&&ri(i[o-3],i[o-1],i[o-2])&&i.splice(i.length-2,1))}if(i.push(n[n.length-1]),o=i.length,("Polygon"===e||"MultiPolygon"===e)&&ii(n[0],n[n.length-1])&&o<4)throw new Error("invalid polygon");return"LineString"===e&&o<3||ri(i[o-3],i[o-1],i[o-2])&&i.splice(i.length-2,1),i}function ii(t,e){return t[0]===e[0]&&t[1]===e[1]}function ri(t,e,n){var i=n[0],r=n[1],o=t[0],s=t[1],a=e[0],l=e[1],u=a-o,h=l-s;return 0===(i-o)*h-(r-s)*u&&(Math.abs(u)>=Math.abs(h)?u>0?o<=i&&i<=a:a<=i&&i<=o:h>0?s<=r&&r<=l:l<=r&&r<=s)}function oi(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return si(t);case"FeatureCollection":return function(t){const e={type:"FeatureCollection"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"features":return;default:e[n]=t[n]}}),e.features=t.features.map(t=>si(t)),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return li(t);default:throw new Error("unknown GeoJSON type")}}function si(t){const e={type:"Feature"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}),e.properties=ai(t.properties),null==t.geometry?e.geometry=null:e.geometry=li(t.geometry),e}function ai(t){const e={};return t?(Object.keys(t).forEach(n=>{const i=t[n];"object"==typeof i?null===i?e[n]=null:Array.isArray(i)?e[n]=i.map(t=>t):e[n]=ai(i):e[n]=i}),e):e}function li(t){const e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(t=>li(t)),e):(e.coordinates=ui(t.coordinates),e)}function ui(t){const e=t;return"object"!=typeof e[0]?e.slice():e.map(t=>ui(t))}function hi(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function ci(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function fi(t,e,n,i,r){for(var o,s=i,a=e+1;a<n;a++){var l=ci(t[a],t[e],t[n]);l>s&&(o=a,s=l)}s>i&&(o-e>1&&fi(t,e,o,i,r),r.push(t[o]),n-o>1&&fi(t,o,n,i,r))}function gi(t,e){var n=t.length-1,i=[t[0]];return fi(t,0,n,e,i),i.push(t[n]),i}function di(t,e,n){if(t.length<=2)return t;var i=void 0!==e?e*e:1;return t=n?t:function(t,e){for(var n,i=t[0],r=[i],o=1,s=t.length;o<s;o++)hi(n=t[o],i)>e&&(r.push(n),i=n);return i!==n&&r.push(n),r}(t,i),t=gi(t,i)}function pi(t,e,n){return t.map(function(t){if(t.length<4)throw new Error("invalid polygon");let i=e,r=di(t,i,n);for(;!yi(r);)i-=.01*i,r=di(t,i,n);return r[r.length-1][0]===r[0][0]&&r[r.length-1][1]===r[0][1]||r.push(r[0]),r})}function yi(t){return!(t.length<3)&&!(3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}var vi=function(t,e={}){var n,i,r,o;if(null===(o=e=null!=e?e:{})||"object"!=typeof o||Array.isArray(o))throw new Error("options is invalid");const s=null!=(n=e.tolerance)?n:1,a=null!=(i=e.highQuality)&&i,l=null!=(r=e.mutate)&&r;if(!t)throw new Error("geojson is required");if(s&&s<0)throw new Error("invalid tolerance");return!0!==l&&(t=oi(t)),M(t,function(t){!function(t,e,n){const i=t.type;if("Point"===i||"MultiPoint"===i)return t;if(ei(t,{mutate:!0}),"GeometryCollection"!==i)switch(i){case"LineString":t.coordinates=di(t.coordinates,e,n);break;case"MultiLineString":t.coordinates=t.coordinates.map(t=>di(t,e,n));break;case"Polygon":t.coordinates=pi(t.coordinates,e,n);break;case"MultiPolygon":t.coordinates=t.coordinates.map(t=>pi(t,e,n))}}(t,s,a)}),t};function mi(t,e,n,i,r,o,s,a){let l,u,h,c,f;const g={x:null,y:null,onLine1:!1,onLine2:!1};return l=(a-o)*(n-t)-(s-r)*(i-e),0===l?null!==g.x&&null!==g.y&&g:(u=e-o,h=t-r,c=(s-r)*u-(a-o)*h,f=(n-t)*u-(i-e)*h,u=c/l,h=f/l,g.x=t+u*(n-t),g.y=e+u*(i-e),u>=0&&u<=1&&(g.onLine1=!0),h>=0&&h<=1&&(g.onLine2=!0),!(!g.onLine1||!g.onLine2)&&[g.x,g.y])}var _i=function(t){let e,n;const i={type:"FeatureCollection",features:[]};if(n="Feature"===t.type?t.geometry:t,"LineString"===n.type)e=[n.coordinates];else if("MultiLineString"===n.type)e=n.coordinates;else if("MultiPolygon"===n.type)e=[].concat(...n.coordinates);else{if("Polygon"!==n.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=n.coordinates}return e.forEach(t=>{e.forEach(e=>{for(let n=0;n<t.length-1;n++)for(let r=n;r<e.length-1;r++){if(t===e){if(1===Math.abs(n-r))continue;if(0===n&&r===t.length-2&&t[n][0]===t[t.length-1][0]&&t[n][1]===t[t.length-1][1])continue}const o=mi(t[n][0],t[n][1],t[n+1][0],t[n+1][1],e[r][0],e[r][1],e[r+1][0],e[r+1][1]);o&&i.features.push(g([o[0],o[1]]))}})}),i};function ki(t,e,n,i,r){xi(t,e,n||0,i||t.length-1,r||wi)}function xi(t,e,n,i,r){for(;i>n;){if(i-n>600){var o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);xi(t,e,Math.max(n,Math.floor(e-s*l/o+u)),Math.min(i,Math.floor(e+(o-s)*l/o+u)),r)}var h=t[e],c=n,f=i;for(Ei(t,n,e),r(t[i],h)>0&&Ei(t,n,i);c<f;){for(Ei(t,c,f),c++,f--;r(t[c],h)<0;)c++;for(;r(t[f],h)>0;)f--}0===r(t[n],h)?Ei(t,n,f):Ei(t,++f,i),f<=e&&(n=f+1),e<=f&&(i=f-1)}}function Ei(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function wi(t,e){return t<e?-1:t>e?1:0}class Ii{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!Ri(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?i(s):s;Ri(t,a)&&(e.leaf?n.push(s):Di(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!Ri(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],o=e.leaf?this.toBBox(r):r;if(Ri(t,o)){if(e.leaf||Di(t,o))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Fi([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],o=[];let s,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],s=o.pop(),l=!0),n.leaf){const i=Mi(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!Di(n,i)?a?(s++,n=a.children[s],l=!1):n=null:(r.push(n),o.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let o,s=this._maxEntries;if(r<=s)return o=Fi(t.slice(e,n+1)),bi(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=Fi([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));Gi(t,e,n,l,this.compareMinX);for(let u=e;u<=n;u+=l){const e=Math.min(u+l-1,n);Gi(t,u,e,a,this.compareMinY);for(let n=u;n<=e;n+=a){const r=Math.min(n+a-1,e);o.children.push(this._build(t,n,r,i-1))}}return bi(o,this.toBBox),o}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let o=0;o<e.children.length;o++){const s=e.children[o],a=Ci(s),l=Oi(t,s)-a;l<r?(r=l,i=a<i?a:i,n=s):l===r&&a<i&&(i=a,n=s)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),Ni(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),s=Fi(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,bi(n,this.toBBox),bi(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=Fi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,bi(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=Si(t,0,s,this.toBBox),a=Si(t,s,n,this.toBBox),l=Ai(e,a),u=Ci(e)+Ci(a);l<r?(r=l,i=s,o=u<o?u:o):l===r&&u<o&&(o=u,i=s)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:Li,r=t.leaf?this.compareMinY:Pi;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,o=Si(t,0,e,r),s=Si(t,n-e,n,r);let a=Ti(o)+Ti(s);for(let l=e;l<n-e;l++){const e=t.children[l];Ni(o,t.leaf?r(e):e),a+=Ti(o)}for(let l=n-e-1;l>=e;l--){const e=t.children[l];Ni(s,t.leaf?r(e):e),a+=Ti(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Ni(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():bi(t[n],this.toBBox)}}function Mi(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function bi(t,e){Si(t,0,t.children.length,e,t)}function Si(t,e,n,i,r){r||(r=Fi(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];Ni(r,t.leaf?i(e):e)}return r}function Ni(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Li(t,e){return t.minX-e.minX}function Pi(t,e){return t.minY-e.minY}function Ci(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Ti(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Oi(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Ai(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function Di(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Ri(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Fi(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Gi(t,e,n,i,r){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=i)continue;const s=e+Math.ceil((n-e)/i/2)*i;ki(t,s,e,n,r),o.push(e,s,s,n)}}function Bi(t){return function(t,e,n){var i=n;return M(t,function(t,n,r,o,s){i=e(i,t,n,r,o,s)}),i}(t,(t,e)=>t+function(t){let e,n=0;switch(t.type){case"Polygon":return Yi(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)n+=Yi(t.coordinates[e]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e),0)}function Yi(t){let e=0;if(t&&t.length>0){e+=Math.abs(Hi(t[0]));for(let n=1;n<t.length;n++)e-=Math.abs(Hi(t[n]))}return e}var qi=20294876564838.72,zi=Math.PI/180;function Hi(t){const e=t.length-1;if(e<=2)return 0;let n=0,i=0;for(;i<e;){const r=t[i],o=t[i+1===e?0:i+1],s=t[i+2>=e?(i+2)%e:i+2],a=r[0]*zi,l=o[1]*zi;n+=(s[0]*zi-a)*Math.sin(l),i++}return n*qi}var Ui=Bi;const Xi=11102230246251565e-32,Vi=134217729,ji=(3+8*Xi)*Xi;function Ki(t,e,n,i,r){let o,s,a,l,u=e[0],h=i[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=i[++f]);let g=0;if(c<t&&f<n)for(h>u==h>-u?(s=u+o,a=o-(s-u),u=e[++c]):(s=h+o,a=o-(s-h),h=i[++f]),o=s,0!==a&&(r[g++]=a);c<t&&f<n;)h>u==h>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c]):(s=o+h,l=s-o,a=o-(s-l)+(h-l),h=i[++f]),o=s,0!==a&&(r[g++]=a);for(;c<t;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c],o=s,0!==a&&(r[g++]=a);for(;f<n;)s=o+h,l=s-o,a=o-(s-l)+(h-l),h=i[++f],o=s,0!==a&&(r[g++]=a);return 0===o&&0!==g||(r[g++]=o),g}function Wi(t){return new Float64Array(t)}const Zi=Wi(4),Ji=Wi(8),$i=Wi(12),Qi=Wi(16),tr=Wi(4);function er(t,e,n,i,r,o){const s=(e-o)*(n-r),a=(t-r)*(i-o),l=s-a,u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(t,e,n,i,r,o,s){let a,l,u,h,c,f,g,d,p,y,v,m,_,k,x,E,w,I;const M=t-r,b=n-r,S=e-o,N=i-o;k=M*N,f=Vi*M,g=f-(f-M),d=M-g,f=Vi*N,p=f-(f-N),y=N-p,x=d*y-(k-g*p-d*p-g*y),E=S*b,f=Vi*S,g=f-(f-S),d=S-g,f=Vi*b,p=f-(f-b),y=b-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,Zi[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,Zi[1]=_-(v+c)+(c-E),I=m+v,c=I-m,Zi[2]=m-(I-c)+(v-c),Zi[3]=I;let L=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,Zi),P=22204460492503146e-32*s;if(L>=P||-L>=P)return L;if(c=t-M,a=t-(M+c)+(c-r),c=n-b,u=n-(b+c)+(c-r),c=e-S,l=e-(S+c)+(c-o),c=i-N,h=i-(N+c)+(c-o),0===a&&0===l&&0===u&&0===h)return L;if(P=11093356479670487e-47*s+ji*Math.abs(L),L+=M*h+N*a-(S*u+b*l),L>=P||-L>=P)return L;k=a*N,f=Vi*a,g=f-(f-a),d=a-g,f=Vi*N,p=f-(f-N),y=N-p,x=d*y-(k-g*p-d*p-g*y),E=l*b,f=Vi*l,g=f-(f-l),d=l-g,f=Vi*b,p=f-(f-b),y=b-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,tr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,tr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,tr[2]=m-(I-c)+(v-c),tr[3]=I;const C=Ki(4,Zi,4,tr,Ji);k=M*h,f=Vi*M,g=f-(f-M),d=M-g,f=Vi*h,p=f-(f-h),y=h-p,x=d*y-(k-g*p-d*p-g*y),E=S*u,f=Vi*S,g=f-(f-S),d=S-g,f=Vi*u,p=f-(f-u),y=u-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,tr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,tr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,tr[2]=m-(I-c)+(v-c),tr[3]=I;const T=Ki(C,Ji,4,tr,$i);k=a*h,f=Vi*a,g=f-(f-a),d=a-g,f=Vi*h,p=f-(f-h),y=h-p,x=d*y-(k-g*p-d*p-g*y),E=l*u,f=Vi*l,g=f-(f-l),d=l-g,f=Vi*u,p=f-(f-u),y=u-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,tr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,tr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,tr[2]=m-(I-c)+(v-c),tr[3]=I;const O=Ki(T,$i,4,tr,Qi);return Qi[O-1]}(t,e,n,i,r,o,u)}function nr(t,e){var n,i,r,o,s,a,l,u,h,c=0,f=t[0],g=t[1],d=e.length;for(n=0;n<d;n++){i=0;var p=e[n],y=p.length-1;if((u=p[0])[0]!==p[y][0]&&u[1]!==p[y][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-f,s=u[1]-g;i<y;i++){if(a=(h=p[i+1])[0]-f,l=h[1]-g,0===s&&0===l){if(a<=0&&o>=0||o<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(r=er(o,a,s,l,0,0)))return 0;(r>0&&l>0&&s<=0||r<0&&l<=0&&s>0)&&c++}u=h,s=l,o=a}}return c%2!=0}function ir(t,e,n={}){if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");const i=Q(t),r=et(e),o=r.type,s=e.bbox;let a=r.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(i,s))return!1;"Polygon"===o&&(a=[a]);let l=!1;for(var u=0;u<a.length;++u){const t=nr(i,a[u]);if(0===t)return!n.ignoreBoundary;t&&(l=!0)}return l}var rr=ir;function or(t,e,n){if("Polygon"!==t.geometry.type)throw new Error("The input feature must be a Polygon");void 0===n&&(n=1);var i=t.geometry.coordinates,r=[],o={};if(n){for(var s=[],a=0;a<i.length;a++)for(var l=0;l<i[a].length-1;l++)s.push(p(a,l));var u=new Ii;u.load(s)}for(var h=0;h<i.length;h++)for(var c=0;c<i[h].length-1;c++){if(n)u.search(p(h,c)).forEach(function(t){var e=t.ring,n=t.edge;d(h,c,e,n)});else for(var f=0;f<i.length;f++)for(var g=0;g<i[f].length-1;g++)d(h,c,f,g)}return e||(r={type:"Feature",geometry:{type:"MultiPoint",coordinates:r}}),r;function d(t,n,s,a){var l,u,h=i[t][n],c=i[t][n+1],f=i[s][a],g=i[s][a+1],d=function(t,e,n,i){if(sr(t,n)||sr(t,i)||sr(e,n)||sr(i,n))return null;var r=t[0],o=t[1],s=e[0],a=e[1],l=n[0],u=n[1],h=i[0],c=i[1],f=(r-s)*(u-c)-(o-a)*(l-h);return 0===f?null:[((r*a-o*s)*(l-h)-(r-s)*(l*c-u*h))/f,((r*a-o*s)*(u-c)-(o-a)*(l*c-u*h))/f]}(h,c,f,g);if(null!==d&&(l=c[0]!==h[0]?(d[0]-h[0])/(c[0]-h[0]):(d[1]-h[1])/(c[1]-h[1]),u=g[0]!==f[0]?(d[0]-f[0])/(g[0]-f[0]):(d[1]-f[1])/(g[1]-f[1]),!(l>=1||l<=0||u>=1||u<=0))){var p=d,y=!o[p];y&&(o[p]=!0),e?r.push(e(d,t,n,h,c,l,s,a,f,g,u,y)):r.push(d)}}function p(t,e){var n,r,o,s,a=i[t][e],l=i[t][e+1];return a[0]<l[0]?(n=a[0],r=l[0]):(n=l[0],r=a[0]),a[1]<l[1]?(o=a[1],s=l[1]):(o=l[1],s=a[1]),{minX:n,minY:o,maxX:r,maxY:s,ring:t,edge:e}}}function sr(t,e){if(!t||!e)return!1;if(t.length!==e.length)return!1;for(var n=0,i=t.length;n<i;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!sr(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0}function ar(t){if("Feature"!=t.type)throw new Error("The input must a geojson object of type Feature");if(void 0===t.geometry||null==t.geometry)throw new Error("The input must a geojson object with a non-empty geometry");if("Polygon"!=t.geometry.type)throw new Error("The input must be a geojson Polygon");for(var e=t.geometry.coordinates.length,n=[],i=0;i<e;i++){var r=t.geometry.coordinates[i];fr(r[0],r[r.length-1])||r.push(r[0]);for(var o=0;o<r.length-1;o++)n.push(r[o])}if(!function(t){for(var e={},n=1,i=0,r=t.length;i<r;++i){if(Object.prototype.hasOwnProperty.call(e,t[i])){n=0;break}e[t[i]]=1}return n}(n))throw new Error("The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)");var s=n.length,a=or(t,function(t,e,n,i,r,o,s,a,l,u,h,c){return[t,e,n,i,r,o,s,a,l,u,h,c]}),l=a.length;if(0==l){var u=[];for(i=0;i<e;i++)u.push(d([t.geometry.coordinates[i]],{parent:-1,winding:cr(t.geometry.coordinates[i])}));var h=y(u);return G(),B(),h}var c=[],f=[];for(i=0;i<e;i++){c.push([]);for(o=0;o<t.geometry.coordinates[i].length-1;o++)c[i].push([new lr(t.geometry.coordinates[i][gr(o+1,t.geometry.coordinates[i].length-1)],1,[i,o],[i,gr(o+1,t.geometry.coordinates[i].length-1)],void 0)]),f.push(new ur(t.geometry.coordinates[i][o],[i,gr(o-1,t.geometry.coordinates[i].length-1)],[i,o],void 0,void 0,!1,!0))}for(i=0;i<l;i++)c[a[i][1]][a[i][2]].push(new lr(a[i][0],a[i][5],[a[i][1],a[i][2]],[a[i][6],a[i][7]],void 0)),a[i][11]&&f.push(new ur(a[i][0],[a[i][1],a[i][2]],[a[i][6],a[i][7]],void 0,void 0,!0,!0));var g=f.length;for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)c[i][o].sort(function(t,e){return t.param<e.param?-1:1});var p=[];for(i=0;i<g;i++)p.push({minX:f[i].coord[0],minY:f[i].coord[1],maxX:f[i].coord[0],maxY:f[i].coord[1],index:i});var v=new Ii;v.load(p);for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)for(var m=0;m<c[i][o].length;m++){k=m==c[i][o].length-1?c[i][gr(o+1,t.geometry.coordinates[i].length-1)][0].coord:c[i][o][m+1].coord;var _=v.search({minX:k[0],minY:k[1],maxX:k[0],maxY:k[1]})[0];c[i][o][m].nxtIsectAlongEdgeIn=_.index}for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)for(m=0;m<c[i][o].length;m++){var k=c[i][o][m].coord,x=(_=v.search({minX:k[0],minY:k[1],maxX:k[0],maxY:k[1]})[0]).index;x<s?f[x].nxtIsectAlongRingAndEdge2=c[i][o][m].nxtIsectAlongEdgeIn:fr(f[x].ringAndEdge1,c[i][o][m].ringAndEdgeIn)?f[x].nxtIsectAlongRingAndEdge1=c[i][o][m].nxtIsectAlongEdgeIn:f[x].nxtIsectAlongRingAndEdge2=c[i][o][m].nxtIsectAlongEdgeIn}var E=[];for(i=0,o=0;o<e;o++){var w=i;for(m=0;m<t.geometry.coordinates[o].length-1;m++)f[i].coord[0]<f[w].coord[0]&&(w=i),i++;var I=f[w].nxtIsectAlongRingAndEdge2;for(m=0;m<f.length;m++)if(f[m].nxtIsectAlongRingAndEdge1==w||f[m].nxtIsectAlongRingAndEdge2==w){var M=m;break}var b=hr([f[M].coord,f[w].coord,f[I].coord],!0)?1:-1;E.push({isect:w,parent:-1,winding:b})}E.sort(function(t,e){return f[t.isect].coord>f[e.isect].coord?-1:1});for(u=[];E.length>0;){var S=E.pop(),N=S.isect,L=S.parent,P=S.winding,C=u.length,T=[f[N].coord],O=N;if(f[N].ringAndEdge1Walkable)var A=f[N].ringAndEdge1,D=f[N].nxtIsectAlongRingAndEdge1;else A=f[N].ringAndEdge2,D=f[N].nxtIsectAlongRingAndEdge2;for(;!fr(f[N].coord,f[D].coord);){T.push(f[D].coord);var R=void 0;for(i=0;i<E.length;i++)if(E[i].isect==D){R=i;break}if(null!=R&&E.splice(R,1),fr(A,f[D].ringAndEdge1)){if(A=f[D].ringAndEdge2,f[D].ringAndEdge2Walkable=!1,f[D].ringAndEdge1Walkable){var F={isect:D};hr([f[O].coord,f[D].coord,f[f[D].nxtIsectAlongRingAndEdge2].coord],1==P)?(F.parent=L,F.winding=-P):(F.parent=C,F.winding=P),E.push(F)}O=D,D=f[D].nxtIsectAlongRingAndEdge2}else{if(A=f[D].ringAndEdge1,f[D].ringAndEdge1Walkable=!1,f[D].ringAndEdge2Walkable){F={isect:D};hr([f[O].coord,f[D].coord,f[f[D].nxtIsectAlongRingAndEdge1].coord],1==P)?(F.parent=L,F.winding=-P):(F.parent=C,F.winding=P),E.push(F)}O=D,D=f[D].nxtIsectAlongRingAndEdge1}}T.push(f[D].coord),u.push(d([T],{index:C,parent:L,winding:P,netWinding:void 0}))}h=y(u);function G(){for(var t=[],e=0;e<h.features.length;e++)-1==h.features[e].properties.parent&&t.push(e);if(t.length>1)for(e=0;e<t.length;e++){for(var n=-1,i=1/0,r=0;r<h.features.length;r++)t[e]!=r&&ir(h.features[t[e]].geometry.coordinates[0][0],h.features[r],{ignoreBoundary:!0})&&Bi(h.features[r])<i&&(n=r);h.features[t[e]].properties.parent=n}}function B(){for(var t=0;t<h.features.length;t++)if(-1==h.features[t].properties.parent){var e=h.features[t].properties.winding;h.features[t].properties.netWinding=e,Y(t,e)}}function Y(t,e){for(var n=0;n<h.features.length;n++)if(h.features[n].properties.parent==t){var i=e+h.features[n].properties.winding;h.features[n].properties.netWinding=i,Y(n,i)}}return G(),B(),h}var lr=function(t,e,n,i,r){this.coord=t,this.param=e,this.ringAndEdgeIn=n,this.ringAndEdgeOut=i,this.nxtIsectAlongEdgeIn=r},ur=function(t,e,n,i,r,o,s){this.coord=t,this.ringAndEdge1=e,this.ringAndEdge2=n,this.nxtIsectAlongRingAndEdge1=i,this.nxtIsectAlongRingAndEdge2=r,this.ringAndEdge1Walkable=o,this.ringAndEdge2Walkable=s};function hr(t,e){if(void 0===e&&(e=!0),3!=t.length)throw new Error("This function requires an array of three points [x,y]");return(t[1][0]-t[0][0])*(t[2][1]-t[0][1])-(t[1][1]-t[0][1])*(t[2][0]-t[0][0])>=0==e}function cr(t){for(var e=0,n=0;n<t.length-1;n++)t[n][0]<t[e][0]&&(e=n);if(hr([t[gr(e-1,t.length-1)],t[e],t[gr(e+1,t.length-1)]],!0))var i=1;else i=-1;return i}function fr(t,e){if(!t||!e)return!1;if(t.length!=e.length)return!1;for(var n=0,i=t.length;n<i;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!fr(t[n],e[n]))return!1}else if(t[n]!=e[n])return!1;return!0}function gr(t,e){return(t%e+e)%e}var dr=function(t){var e=[];return b(t,function(t){"Polygon"===t.geometry.type&&I(ar(t),function(n){e.push(d(n.geometry.coordinates,t.properties))})}),y(e)};function pr(t,e,n={}){if(!0===n.final)return function(t,e){let n=pr(e,t);return n=(n+180)%360,n}(t,e);const i=Q(t),r=Q(e),o=x(i[0]),s=x(r[0]),a=x(i[1]),l=x(r[1]),u=Math.sin(s-o)*Math.cos(l),h=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return k(Math.atan2(u,h))}function yr(t,e,n={}){var i=Q(t),r=Q(e),o=x(r[1]-i[1]),s=x(r[0]-i[0]),a=x(i[1]),l=x(r[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return m(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}var vr=yr;var mr=function(t,e){return function(t,e,n,i={}){const r=Q(t),o=x(r[0]),s=x(r[1]),a=x(n),l=_(e,i.units),u=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a));return g([k(o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(u))),k(u)],i.properties)}(t,yr(t,e)/2,pr(t,e))};function _r(t,e,n={}){const i=Q(t),r=tt(e);for(let o=0;o<r.length-1;o++){let t=!1;if(n.ignoreEndVertices&&(0===o&&(t="start"),o===r.length-2&&(t="end"),0===o&&o+1===r.length-1&&(t="both")),kr(r[o],r[o+1],i,t,void 0===n.epsilon?null:n.epsilon))return!0}return!1}function kr(t,e,n,i,r){const o=n[0],s=n[1],a=t[0],l=t[1],u=e[0],h=e[1],c=u-a,f=h-l,g=(n[0]-a)*f-(n[1]-l)*c;if(null!==r){if(Math.abs(g)>r)return!1}else if(0!==g)return!1;return Math.abs(c)===Math.abs(f)&&0===Math.abs(c)?!i&&(n[0]===t[0]&&n[1]===t[1]):i?"start"===i?Math.abs(c)>=Math.abs(f)?c>0?a<o&&o<=u:u<=o&&o<a:f>0?l<s&&s<=h:h<=s&&s<l:"end"===i?Math.abs(c)>=Math.abs(f)?c>0?a<=o&&o<u:u<o&&o<=a:f>0?l<=s&&s<h:h<s&&s<=l:"both"===i&&(Math.abs(c)>=Math.abs(f)?c>0?a<o&&o<u:u<o&&o<a:f>0?l<s&&s<h:h<s&&s<l):Math.abs(c)>=Math.abs(f)?c>0?a<=o&&o<=u:u<=o&&o<=a:f>0?l<=s&&s<=h:h<=s&&s<=l}function xr(t,e){return!(t[0]>e[0])&&(!(t[2]<e[2])&&(!(t[1]>e[1])&&!(t[3]<e[3])))}function Er(t,e){return t[0]===e[0]&&t[1]===e[1]}function wr(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}var Ir=function(t,e){var n=et(t),i=et(e),r=n.type,o=i.type;switch(r){case"Point":switch(o){case"MultiPoint":return function(t,e){var n,i=!1;for(n=0;n<e.coordinates.length;n++)if(Er(e.coordinates[n],t.coordinates)){i=!0;break}return i}(n,i);case"LineString":return _r(n,i,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return ir(n,i,{ignoreBoundary:!0});default:throw new Error("feature2 "+o+" geometry not supported")}case"MultiPoint":switch(o){case"MultiPoint":return function(t,e){for(var n=0;n<t.coordinates.length;n++){for(var i=!1,r=0;r<e.coordinates.length;r++)Er(t.coordinates[n],e.coordinates[r])&&(i=!0);if(!i)return!1}return!0}(n,i);case"LineString":return function(t,e){for(var n=!1,i=0;i<t.coordinates.length;i++){if(!_r(t.coordinates[i],e))return!1;n||(n=_r(t.coordinates[i],e,{ignoreEndVertices:!0}))}return n}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){for(var n=!0,i=!1,r=0;r<t.coordinates.length;r++){if(!(i=ir(t.coordinates[r],e))){n=!1;break}i=ir(t.coordinates[r],e,{ignoreBoundary:!0})}return n&&i}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"LineString":return function(t,e){for(var n=0;n<t.coordinates.length;n++)if(!_r(t.coordinates[n],e))return!1;return!0}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){var n=xe(e),i=xe(t);if(!xr(n,i))return!1;for(var r=!1,o=0;o<t.coordinates.length;o++){if(!ir(t.coordinates[o],e))return!1;if(r||(r=ir(t.coordinates[o],e,{ignoreBoundary:!0})),!r&&o<t.coordinates.length-1)r=ir(wr(t.coordinates[o],t.coordinates[o+1]),e,{ignoreBoundary:!0})}return r}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}case"Polygon":switch(o){case"Polygon":case"MultiPolygon":return function(t,e){var n=xe(t);if(!xr(xe(e),n))return!1;for(var i=0;i<t.coordinates[0].length;i++)if(!ir(t.coordinates[0][i],e))return!1;return!0}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}default:throw new Error("feature1 "+r+" geometry not supported")}},Mr=Object.defineProperty,br=(t,e)=>Mr(t,"name",{value:e,configurable:!0}),Sr=class{constructor(t){var e,n,i;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(e=null==t?void 0:t.precision)?e:17),this.direction=null!=(n=null==t?void 0:t.direction)&&n,this.compareProperties=null==(i=null==t?void 0:t.compareProperties)||i}compare(t,e){if(t.type!==e.type)return!1;if(!Lr(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")){const n=Pr(t),i=Pr(e);return n.every(t=>i.some(e=>this.compare(t,e)))}}return!1}compareCoord(t,e){return t.length===e.length&&t.every((t,n)=>Math.abs(t-e[n])<this.precision)}compareLine(t,e,n=0,i=!1){if(!Lr(t,e))return!1;const r=t;let o=e;if(i&&!this.compareCoord(r[0],o[0])){const t=this.fixStartIndex(o,r);if(!t)return!1;o=t}const s=this.compareCoord(r[n],o[n]);return this.direction||s?this.comparePath(r,o):!!this.compareCoord(r[n],o[o.length-(1+n)])&&this.comparePath(r.slice().reverse(),o)}fixStartIndex(t,e){let n,i=-1;for(let r=0;r<t.length;r++)if(this.compareCoord(t[r],e[0])){i=r;break}return i>=0&&(n=[].concat(t.slice(i,t.length),t.slice(1,i+1))),n}comparePath(t,e){return t.every((t,n)=>this.compareCoord(t,e[n]))}comparePolygon(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){const n=t.coordinates.slice(1,t.coordinates.length),i=e.coordinates.slice(1,e.coordinates.length);return n.every(t=>i.some(e=>this.compareLine(t,e,1,!0)))}return!1}compareGeometryCollection(t,e){return Lr(t.geometries,e.geometries)&&this.compareBBox(t,e)&&t.geometries.every((t,n)=>this.compare(t,e.geometries[n]))}compareFeature(t,e){return t.id===e.id&&(!this.compareProperties||Tr(t.properties,e.properties))&&this.compareBBox(t,e)&&this.compare(t.geometry,e.geometry)}compareFeatureCollection(t,e){return Lr(t.features,e.features)&&this.compareBBox(t,e)&&t.features.every((t,n)=>this.compare(t,e.features[n]))}compareBBox(t,e){return Boolean(!t.bbox&&!e.bbox)||!(!t.bbox||!e.bbox)&&this.compareCoord(t.bbox,e.bbox)}};br(Sr,"GeojsonEquality");var Nr=Sr;function Lr(t,e){return t.coordinates?t.coordinates.length===e.coordinates.length:t.length===e.length}function Pr(t){return t.coordinates.map(e=>({type:t.type.replace("Multi",""),coordinates:e}))}function Cr(t,e,n){return new Nr(n).compare(t,e)}function Tr(t,e){if(null===t&&null===e)return!0;if(null===t||null===e)return!1;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(var r of n){const n=t[r],i=e[r],o=Or(n)&&Or(i);if(o&&!Tr(n,i)||!o&&n!==i)return!1}return!0}br(Lr,"sameLength"),br(Pr,"explode"),br(Cr,"geojsonEquality"),br(Tr,"equal");var Or=br(t=>null!=t&&"object"==typeof t,"isObject");var Ar=function(t,e,n={}){let i=n.precision;if(i=null==i||isNaN(i)?6:i,"number"!=typeof i||!(i>=0))throw new Error("precision must be a positive number");return et(t).type===et(e).type&&Cr(ei(t),ei(e),{precision:i})};var Dr=function(t,e={}){const n=Number(t[0]),i=Number(t[1]),r=Number(t[2]),o=Number(t[3]);if(6===t.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");const s=[n,i];return d([[s,[r,i],[r,o],[n,o],s]],e.properties,{bbox:t,id:e.id})},Rr=Object.defineProperty,Fr=Object.defineProperties,Gr=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertySymbols,Yr=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable,zr=(t,e,n)=>e in t?Rr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Hr=(t,e)=>{for(var n in e||(e={}))Yr.call(e,n)&&zr(t,n,e[n]);if(Br)for(var n of Br(e))qr.call(e,n)&&zr(t,n,e[n]);return t},Ur=(t,e)=>Fr(t,Gr(e));var Xr=function(t,e,n={}){if(!t)throw new Error("targetPoint is required");if(!e)throw new Error("points is required");let i=1/0,r=0;I(e,(e,o)=>{const s=yr(t,e,n);s<i&&(r=o,i=s)});const o=oi(e.features[r]);return Ur(Hr({},o),{properties:Ur(Hr({},o.properties),{featureIndex:r,distanceToPoint:i})})};function Vr(t,e){return t.length>1?function(t,e,n={}){return f({type:"MultiLineString",coordinates:t},e,n)}(t,e):p(t[0],e)}var jr=function(t,e={}){const n=et(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return function(t,e={}){const n=et(t),i=n.coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{};return Vr(i,r)}(n,e);case"MultiPolygon":return function(t,e={}){const n=et(t),i=n.coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{},o=[];return i.forEach(t=>{o.push(Vr(t,r))}),y(o)}(n,e);default:throw new Error("invalid poly")}};function Kr(t,e,n,i){e=e||("Feature"===t.type?t.properties:{});var r=et(t),o=r.coordinates,s=r.type;if(!o.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return n&&(o=Wr(o)),d([o],e);case"MultiLineString":var a=[],l=0;return o.forEach(function(t){if(n&&(t=Wr(t)),i){var e=(r=xe(p(t)),o=r[0],s=r[1],u=r[2],h=r[3],Math.abs(o-u)*Math.abs(s-h));e>l?(a.unshift(t),l=e):a.push(t)}else a.push(t);var r,o,s,u,h}),d(a,e);default:throw new Error("geometry type "+s+" is not supported")}}function Wr(t){var e=t[0],n=e[0],i=e[1],r=t[t.length-1],o=r[0],s=r[1];return n===o&&i===s||t.push(e),t}var Zr=function(t,e={}){var n,i,r,o=e.properties,s=null==(n=e.autoComplete)||n,a=null==(i=e.orderCoords)||i;if(null!=(r=e.mutate)&&r||(t=oi(t)),"FeatureCollection"===t.type){var l=[];return t.features.forEach(function(t){l.push(tt(Kr(t,{},s,a)))}),v(l,o)}return Kr(t,o,s,a)},Jr=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;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(let e=0;e<this.length-1;e++){const t=this.points[e],n=this.points[e+1];this.centers.push({x:(t.x+n.x)/2,y:(t.y+n.y)/2,z:(t.z+n.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(let e=0;e<this.centers.length-1;e++){const t=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,n=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,i=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+t),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+n),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+i)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+t),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+n),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+i)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}cacheSteps(t){const e=[];let n=this.pos(0);e.push(0);for(let i=0;i<this.duration;i+=10){const r=this.pos(i);Math.sqrt((r.x-n.x)*(r.x-n.x)+(r.y-n.y)*(r.y-n.y)+(r.z-n.z)*(r.z-n.z))>t&&(e.push(i),n=r)}return e}vector(t){const e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}}pos(t){let e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);const n=e/this.duration;if(n>=1)return this.points[this.length-1];const i=Math.floor((this.points.length-1)*n);return function(t,e,n,i,r){const o=function(t){const e=t*t,n=e*t;return[n,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:r.x*o[0]+i.x*o[1]+n.x*o[2]+e.x*o[3],y:r.y*o[0]+i.y*o[1]+n.y*o[2]+e.y*o[3],z:r.z*o[0]+i.z*o[1]+n.z*o[2]+e.z*o[3]}}((this.length-1)*n-i,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])}};var $r=function(t,e={}){const n=e.resolution||1e4,i=e.sharpness||.85,r=[],o=et(t).coordinates.map(t=>({x:t[0],y:t[1]})),s=new Jr({duration:n,points:o,sharpness:i}),a=t=>{var e=s.pos(t);Math.floor(t/100)%2==0&&r.push([e.x,e.y])};for(var l=0;l<s.duration;l+=10)a(l);return a(s.duration),p(r,e.properties)};var Qr=function(t,e={}){return S(t,(t,n)=>{const i=n.geometry.coordinates;return t+yr(i[0],i[1],e)},0)};class to{constructor(t){r(this,"config",a),this.config={...a,...t}}union(t,e){try{const n=y([t,e]),i=ve(n);return i?this.getTurfPolygon(i):null}catch(n){return console.warn("Error in union:",n instanceof Error?n.message:String(n)),null}}createPolygonFromTrace(t){var e;const n=(null==(e=this.config.polygonCreation)?void 0:e.method)||"concaveman";switch(n){case"concaveman":return this.turfConcaveman(t);case"convex":return this.createConvexPolygon(t);case"direct":return this.createDirectPolygon(t);case"buffer":return this.createBufferedPolygon(t);default:return console.warn(`Unknown polygon creation method: ${n}, falling back to concaveman`),this.turfConcaveman(t)}}turfConcaveman(t){const e=ke(t).features.map(t=>t.geometry.coordinates);return v([[K(e)]])}createConvexPolygon(t){const e=ke(t),n=Z(e);return n?this.getTurfPolygon(n):this.createDirectPolygon(t)}createDirectPolygon(t){let e;if("LineString"===t.geometry.type)e=t.geometry.coordinates;else if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{e=ke(t).features.map(t=>t.geometry.coordinates)}if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e.length<4?(console.warn("Not enough points for direct polygon, falling back to concaveman"),this.turfConcaveman(t)):v([[e]])}createBufferedPolygon(t){try{let e;if("LineString"===t.geometry.type)e=t;else{const n=ke(t).features.map(t=>t.geometry.coordinates);e=p(n)}const n=ti(e,.001,{units:"kilometers"});return n?this.getTurfPolygon(n):this.createDirectPolygon(t)}catch(e){return console.warn("Buffer polygon creation failed:",e instanceof Error?e.message:String(e)),this.createDirectPolygon(t)}}getSimplified(t,e=!1){var n,i,r,o,s,a;const l=(null==(i=null==(n=this.config.polygonCreation)?void 0:n.simplification)?void 0:i.mode)||"simple";if("simple"===l){const e={tolerance:(null==(o=null==(r=this.config.polygonCreation)?void 0:r.simplification)?void 0:o.tolerance)||1e-4,highQuality:(null==(a=null==(s=this.config.polygonCreation)?void 0:s.simplification)?void 0:a.highQuality)||!1,mutate:!1};return vi(t,e)}if("dynamic"===l){const n=t.geometry.coordinates[0][0].length,i=this.config.simplification.simplifyTolerance;if(e){let e=vi(t,i);const r=this.config.simplification.dynamicMode.fractionGuard,o=this.config.simplification.dynamicMode.multipiler;for(;e.geometry.coordinates[0][0].length>4&&e.geometry.coordinates[0][0].length/(n+2)>r;)i.tolerance=i.tolerance*o,e=vi(t,i);return e}return vi(t,i)}if("none"===l)return t;console.warn(`Unknown simplification mode: ${l}, falling back to simple`);return vi(t,{tolerance:1e-4,highQuality:!1,mutate:!1})}getTurfPolygon(t){let e;return e="Polygon"===t.geometry.type?v([t.geometry.coordinates]):v(t.geometry.coordinates),e}getMultiPolygon(t){return v(t)}getKinks(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return[t];const e=this.removeDuplicateVertices(t);if(!e||!e.geometry||!e.geometry.coordinates)return console.warn("Feature became invalid after cleaning in getKinks"),[t];if(this.polygonHasHoles(e))return this.getKinksWithHolePreservation(e);{const t=dr(e),n=[];return I(t,t=>{n.push(t)}),n}}catch(e){return console.warn("Error processing kinks:",e instanceof Error?e.message:String(e)),[t]}}getCoords(t){return tt(t)}hasKinks(t){return _i(t).features.length>0}getConvexHull(t){try{const e=y([t]);return Z(e)}catch(e){return console.warn("Error in getConvexHull:",e instanceof Error?e.message:String(e)),null}}getMidpoint(t,e){const n=g([t.lng,t.lat]),i=g([e.lng,e.lat]),r=mr(n,i);return{lat:r.geometry.coordinates[1],lng:r.geometry.coordinates[0]}}polygonIntersect(t,e){try{if(!(t&&t.geometry&&t.geometry.coordinates&&e&&e.geometry&&e.geometry.coordinates))return console.warn("Invalid features passed to polygonIntersect"),!1;try{const n=y([t,e]),i=me(n);if(i&&i.geometry&&("Polygon"===i.geometry.type||"MultiPolygon"===i.geometry.type)){if(Ui(i)>1e-6)return!0}}catch(n){}try{const n=ke(t),i=ke(e);for(const e of i.features)if(rr(e,t))return!0;for(const t of n.features)if(rr(t,e))return!0}catch(n){}try{const n=tt(t),r=tt(e);for(const t of n){const e=t[0];for(let t=0;t<e.length-1;t++){const n=p([e[t],e[t+1]]);for(const t of r){const e=t[0];for(let t=0;t<e.length-1;t++){const r=p([e[t],e[t+1]]);try{const t=yt(n,r);if(t&&t.features&&t.features.length>0)return!0}catch(i){}}}}}}catch(n){}return!1}catch(n){return console.warn("Error in polygonIntersect:",n instanceof Error?n.message:String(n)),!1}}getIntersection(t,e){try{const n=y([t,e]),i=me(n);return i&&i.geometry&&("Polygon"===i.geometry.type||"MultiPolygon"===i.geometry.type)?i:null}catch(n){return console.warn("Error in getIntersection:",n instanceof Error?n.message:String(n)),null}}getDistance(t,e){return vr(t,e)}isWithin(t,e){return Ir(d([t]),d([e]))}isPolygonCompletelyWithin(t,e){try{return Ir(t,e)}catch(n){const i=tt(t),r=tt(e);for(const t of i)for(const e of t)for(const t of e){const e=g(t);let n=!1;for(const t of r){for(const i of t){const t=d([i]);if(rr(e,t)){n=!0;break}}if(n)break}if(!n)return!1}return!0}}toPointFeature(t){var e,n;if("Feature"===(null==t?void 0:t.type)&&"Point"===(null==(e=t.geometry)?void 0:e.type))return t;if(Array.isArray(t)&&t.length>=2&&"number"==typeof t[0]&&"number"==typeof t[1])return g(t);if("number"==typeof(null==t?void 0:t.lat)&&"number"==typeof(null==t?void 0:t.lng)){const e=t;return g([e.lng,e.lat])}if((null==(n=null==t?void 0:t.geometry)?void 0:n.coordinates)&&Array.isArray(t.geometry.coordinates))return g(t.geometry.coordinates);throw new Error("Unsupported point format provided to toPointFeature")}isPointInsidePolygon(t,e){try{const n=this.toPointFeature(t);return rr(n,e)}catch(n){return!1}}equalPolygons(t,e){return Ar(t,e)}convertToBoundingBoxPolygon(t){const e=Ee(t.geometry);return Dr(e)}polygonToMultiPolygon(t){return v([t.geometry.coordinates])}injectPointToPolygon(t,e,n){const i=JSON.parse(JSON.stringify(t));let r;if("MultiPolygon"===i.geometry.type)r=i.geometry.coordinates[0][n];else{if("Polygon"!==i.geometry.type)return i;r=i.geometry.coordinates[n]}if(!r)return i;let o=1/0,s=0;for(let a=0;a<r.length-1;a++){const t=r[a],n=r[a+1],i=this.distanceToLineSegment(e,t,n);i<o&&(o=i,s=a+1)}return r.splice(s,0,e),i}distanceToLineSegment(t,e,n){const i=t[0]-e[0],r=t[1]-e[1],o=n[0]-e[0],s=n[1]-e[1],a=i*o+r*s,l=o*o+s*s;if(0===l)return Math.sqrt(i*i+r*r);const u=a/l;let h,c;u<0?(h=e[0],c=e[1]):u>1?(h=n[0],c=n[1]):(h=e[0]+u*o,c=e[1]+u*s);const f=t[0]-h,g=t[1]-c;return Math.sqrt(f*f+g*g)}polygonDifference(t,e){try{const n=y([t,e]),i=_e(n);return i?this.getTurfPolygon(i):null}catch(n){return console.warn("Error in polygonDifference:",n instanceof Error?n.message:String(n)),null}}getBoundingBoxCompassPosition(t,e,n,i){return null}getNearestPointIndex(t,e){return Xr(t,e).properties.featureIndex}getCoord(t){return[t.lng,t.lat]}getFeaturePointCollection(t){const e=[];t.forEach(t=>{const n=g([t.lng,t.lat],{});e.push(n)});return y(e)}getPolygonArea(t){return Ui(t)}getPolygonPerimeter(t){return Qr(t,{units:"kilometers"})}getCenterOfMass(t){return it(t)}getDoubleElbowLatLngs(t){const e=[],n=t.length,i=t[0].lat===t[n-1].lat&&t[0].lng===t[n-1].lng?n-1:n;for(let r=0;r<i;r++){const n=t[r],o=t[(r+1)%i];e.push(new s.LatLng(n.lat,n.lng));const a=mr(g([n.lng,n.lat]),g([o.lng,o.lat]));e.push(new s.LatLng(a.geometry.coordinates[1],a.geometry.coordinates[0]))}return e}getBezierMultiPolygon(t){const e=jr(this.getMultiPolygon(t));e.features[0].geometry.coordinates.push(e.features[0].geometry.coordinates[0]);const n=$r(e.features[0],{resolution:this.config.bezier.resolution,sharpness:this.config.bezier.sharpness});return Zr(n)}polygonHasHoles(t){try{return"Polygon"===t.geometry.type?t.geometry.coordinates.length>1:"MultiPolygon"===t.geometry.type&&t.geometry.coordinates.some(t=>t.length>1)}catch(e){return console.warn("Error checking for holes:",e instanceof Error?e.message:String(e)),!1}}getKinksWithHolePreservation(t){try{if("Polygon"===t.geometry.type){const e=t.geometry.coordinates,n=e[0],i=e.slice(1),r={type:"Feature",geometry:{type:"Polygon",coordinates:[n]},properties:t.properties||{}},o=this.hasKinks(r),s=this.checkOuterRingHoleIntersection(n,i);if(o||s){if(this.checkIfDragCompletelyThroughHole(n,i))return this.handleCompleteHoleTraversal(r,i);const t=dr(r),e=[];return I(t,t=>{const n=this.subtractIntersectingHoles(t,i);e.push(n)}),e}return[t]}if("MultiPolygon"===t.geometry.type){const e=[];for(const n of t.geometry.coordinates){const i={type:"Feature",geometry:{type:"Polygon",coordinates:n},properties:t.properties||{}},r=this.getKinksWithHolePreservation(i);e.push(...r)}return e}return[t]}catch(e){return console.warn("Error in getKinksWithHolePreservation:",e instanceof Error?e.message:String(e)),[t]}}checkIfDragCompletelyThroughHole(t,e){try{if(this.findDuplicatePoints(t).length>0)return!0;const n=this.findSelfIntersectionLine(t);if(n&&e.length>0)for(const t of e)if(this.lineCompletelyTraversesHole(n,t))return!0;if(this.hasKinks({type:"Feature",geometry:{type:"Polygon",coordinates:[t]},properties:{}}))for(const i of e)if(this.holeIsCutByKinks(t,i))return!0;return!1}catch(n){return console.warn("Error checking complete hole traversal:",n instanceof Error?n.message:String(n)),!1}}findSelfIntersectionLine(t){try{const e=new Map;for(let n=0;n<t.length-1;n++){const i=t[n],r=`${i[0]},${i[1]}`;e.has(r)?e.get(r).indices.push(n):e.set(r,{point:i,indices:[n]})}for(const[,n]of e)if(n.indices.length>=2){const e=n.indices[0],i=n.indices[1],r=[];for(let n=e;n<=i;n++)r.push(t[n]);return r}return null}catch(e){return console.warn("Error finding self-intersection line:",e instanceof Error?e.message:String(e)),null}}lineCompletelyTraversesHole(t,e){try{if(t.length<2)return!1;const n=t[0],i=t[t.length-1],r=d([e]),o=rr(g(n),r);return o!==rr(g(i),r)}catch(n){return console.warn("Error checking line hole traversal:",n instanceof Error?n.message:String(n)),!1}}holeIsCutByKinks(t,e){try{const n=d([t]),i=d([e]),r=_i(n);if(0===r.features.length)return!1;for(const t of r.features){const e=t.geometry.coordinates;try{if(vr(g(e),$(i))<.01)return!0;if(rr(g(e),i))return!0}catch{if(rr(g(e),i))return!0}}return!1}catch(n){return console.warn("Error checking hole cut by kinks:",n.message),!1}}findDuplicatePoints(t){const e=[],n=new Set;for(let i=0;i<t.length-1;i++){const r=t[i],o=`${r[0]},${r[1]}`;n.has(o)?e.push(r):n.add(o)}return e}checkOuterRingHoleIntersection(t,e){try{if(0===e.length)return!1;const n=d([t]);for(const i of e){const e=d([i]);if(this.getIntersection(n,e))return!0;for(let n=0;n<t.length-1;n++){const i=t[n];if(rr(g(i),e))return!0}}return!1}catch(n){return!1}}handleCompleteHoleTraversal(t,e){try{const e={type:"Feature",geometry:{type:"Polygon",coordinates:[t.geometry.coordinates[0]]},properties:t.properties||{}},n=dr(e),i=[];return I(n,t=>{t._polydrawHoleTraversalOccurred=!0,i.push(t)}),i}catch(n){console.warn("Error handling complete hole traversal:",n instanceof Error?n.message:String(n));try{const e={...t,geometry:{...t.geometry,coordinates:[t.geometry.coordinates[0]]}};return e._polydrawHoleTraversalOccurred=!0,[e]}catch(i){return[t]}}}subtractIntersectingHoles(t,e){try{let n=t;for(const t of e){const e=d([t]);if(this.getIntersection(e,n)){const t=this.polygonDifference(n,e);if(t)if("Polygon"===t.geometry.type)n=t;else if("MultiPolygon"===t.geometry.type){const e=t;let i=0,r=null;for(const t of e.geometry.coordinates){const e={type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{}},n=Ui(e);n>i&&(i=n,r=e)}r&&(n=r)}}}return n}catch(n){return console.warn("Error subtracting intersecting holes:",n instanceof Error?n.message:String(n)),t}}removeDuplicateVertices(t){if(!t||!t.geometry||!t.geometry.coordinates)return console.warn("Invalid feature passed to removeDuplicateVertices"),t;const e=t=>{if(!t||t.length<3)return console.warn("Invalid coordinates array - need at least 3 points for a polygon"),t||[];const e=[],n=1e-6;for(let i=0;i<t.length;i++){const r=t[i],o=t[(i+1)%t.length];if(!r||!Array.isArray(r)||r.length<2||!o||!Array.isArray(o)||o.length<2)continue;const s=Math.abs(r[1]-o[1]),a=Math.abs(r[0]-o[0]);(s>n||a>n)&&e.push(r)}if(e.length<3)return console.warn("After cleaning, polygon has less than 3 points"),t;if(e.length>0){const t=e[0],i=e[e.length-1],r=Math.abs(t[1]-i[1]),o=Math.abs(t[0]-i[0]);(r>n||o>n)&&e.push([t[0],t[1]])}return e};try{if("Polygon"===t.geometry.type){const n=t.geometry.coordinates.map(t=>e(t));return n.some(t=>t.length<4)?(console.warn("Cleaned polygon has invalid ring with less than 4 coordinates"),t):{...t,geometry:{...t.geometry,coordinates:n}}}if("MultiPolygon"===t.geometry.type){const n=t.geometry.coordinates.map(t=>t.map(t=>e(t)));return n.some(t=>t.some(t=>t.length<4))?(console.warn("Cleaned multipolygon has invalid ring with less than 4 coordinates"),t):{...t,geometry:{...t.geometry,coordinates:n}}}}catch(n){return console.warn("Error in removeDuplicateVertices:",n instanceof Error?n.message:String(n)),t}return t}}const eo=()=>"ontouchstart"in window||navigator.maxTouchPoints>0;class no{static getBounds(t,e=0){const n=[];t.forEach(t=>{isNaN(t.lat)||isNaN(t.lng),n.push(t)});const i=new s.Polyline(n).getBounds();return 0!==e?i.pad(e):i}}class io{constructor(t=0,e=0,n=0,i=0){r(this,"direction",{East:new s.LatLng(0,0),North:new s.LatLng(0,0),NorthEast:new s.LatLng(0,0),NorthWest:new s.LatLng(0,0),South:new s.LatLng(0,0),SouthEast:new s.LatLng(0,0),SouthWest:new s.LatLng(0,0),West:new s.LatLng(0,0)}),this.direction.North=new s.LatLng(n,(e+i)/2),this.direction.NorthEast=new s.LatLng(n,i),this.direction.East=new s.LatLng((t+n)/2,i),this.direction.SouthEast=new s.LatLng(t,i),this.direction.South=new s.LatLng(t,(e+i)/2),this.direction.SouthWest=new s.LatLng(t,e),this.direction.West=new s.LatLng((t+n)/2,e),this.direction.NorthWest=new s.LatLng(n,e)}getDirection(t){switch(t){case u.SouthWest:return this.direction.SouthWest;case u.West:return this.direction.West;case u.NorthWest:return this.direction.NorthWest;case u.North:return this.direction.North;case u.NorthEast:return this.direction.NorthEast;case u.East:return this.direction.East;case u.SouthEast:return this.direction.SouthEast;case u.South:return this.direction.South;default:throw new Error}}getPositions(t=u.SouthWest,e=!1,n=!0){const i=[],r=this.getPositionAsArray(t,e);return r.forEach(t=>{i.push([t.lng,t.lat])}),n&&i.push([r[0].lng,r[0].lat]),i}getPositionAsArray(t=u.NorthEast,e=!1){const n=[];if(e?(n.push(this.direction.SouthWest),n.push(this.direction.West),n.push(this.direction.NorthWest),n.push(this.direction.North),n.push(this.direction.NorthEast),n.push(this.direction.East),n.push(this.direction.SouthEast),n.push(this.direction.South)):(n.push(this.direction.SouthWest),n.push(this.direction.South),n.push(this.direction.SouthEast),n.push(this.direction.East),n.push(this.direction.NorthEast),n.push(this.direction.North),n.push(this.direction.NorthWest),n.push(this.direction.West)),t!==u.SouthWest){n.splice(0,t).forEach((e,i)=>{n.splice(t+i,0,e)})}return n}}class ro{constructor(t,e){if(r(this,"metricLength",""),r(this,"metricUnit",""),r(this,"imperialLength",""),r(this,"imperialUnit",""),null!==t||void 0!==t){0===t?e.markers.markerInfoIcon.usePerimeterMinValue?(this.metricLength=e.markers.markerInfoIcon.values.min.metric,this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m,this.imperialLength=e.markers.markerInfoIcon.values.min.imperial,this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.feet):(this.metricLength=e.markers.markerInfoIcon.values.unknown.metric,this.metricUnit=e.markers.markerInfoIcon.units.unknownUnit,this.imperialLength=e.markers.markerInfoIcon.values.unknown.imperial,this.imperialUnit=e.markers.markerInfoIcon.units.unknownUnit):t<100?(this.metricLength=(10*Math.ceil(t/10)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<500?(this.metricLength=(50*Math.ceil(t/50)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<1e3?(this.metricLength=(100*Math.ceil(t/100)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<1e4?(this.metricLength=(100*Math.ceil(t/100)/1e3).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.km):(this.metricLength=(1e3*Math.ceil(t/1e3)/1e3).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.km);const n=t/.0254/12,i=n/3,r=i/1760;t<1e3/2.54?(this.imperialLength=(10*Math.ceil(n/10)).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.feet):t<1e3/2.54*3?(this.imperialLength=(10*Math.ceil(i/10)).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.yards):t<1609?(this.imperialLength=r.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles):t<16093?(this.imperialLength=r.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles):(this.imperialLength=r.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles)}}}class oo{constructor(t,e){r(this,"metricArea",""),r(this,"metricUnit",""),r(this,"imperialArea",""),r(this,"imperialUnit","");const n=t,i=e.markers.markerInfoIcon.units.metric.onlyMetrics;if(null!==n||void 0!==n){0===n?(this.metricArea="-",this.metricUnit=e.markers.markerInfoIcon.units.unknownUnit,this.imperialArea="-",this.imperialUnit=e.markers.markerInfoIcon.units.unknownUnit):n<1e4?(this.metricArea=Math.round(n).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.m2):n<1e5?i?(this.metricArea=(n/1e6).toFixed(2),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=(n/1e3).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.daa):n<1e7?i?(this.metricArea=(n/1e6).toFixed(2),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=Math.round(n/1e3).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.daa):n<1e8?i?(this.metricArea=(n/1e6).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=Math.round(n/1e4).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.ha):(this.metricArea=Math.round(n/1e6).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2);const t=.0069444*(1550*n),r=.11111*t,o=20661e-8*r,s=3.2283e-7*r;n<92.9?(this.imperialArea=Math.round(t).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.feet2):n<836.14?(this.imperialArea=r.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.yards2):n<40469.6?(this.imperialArea=o.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<404696?(this.imperialArea=o.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<4046960?(this.imperialArea=o.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<25900404?(this.imperialArea=s.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2):n<259004040?(this.imperialArea=s.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2):(this.imperialArea=s.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2)}}}class so{static getCenter(t){const e=Math.PI;let n=0,i=0,r=0;t.forEach(t=>{let o=t.lat,s=t.lng;o=o*e/180,s=s*e/180,n+=Math.cos(o)*Math.cos(s),i+=Math.cos(o)*Math.sin(s),r+=Math.sin(o)});let o=Math.atan2(i,n);const s=Math.sqrt(n*n+i*i);let a=Math.atan2(r,s);a=180*a/e,o=180*o/e;return{lat:a,lng:o}}static getSouthWest(t){return this.getBounds(t).getSouthWest()}static getNorthEast(t){return this.getBounds(t).getNorthEast()}static getNorthWest(t){return this.getBounds(t).getNorthWest()}static getSouthEast(t){return this.getBounds(t).getSouthEast()}static getNorth(t){return this.getBounds(t).getNorth()}static getSouth(t){return this.getBounds(t).getSouth()}static getWest(t){return this.getBounds(t).getWest()}static getEast(t){return this.getBounds(t).getEast()}static getSqmArea(t){const e=new s.Polygon(t).toGeoJSON();return this.turfHelper.getPolygonArea(e)}static getPerimeter(t){const e=new s.Polygon(t).toGeoJSON();return 1e3*this.turfHelper.getPolygonPerimeter(e)}static getPolygonChecksum(t){const e=t.filter((t,e,n)=>{const i=n.find(e=>e.lat===t.lat&&e.lng===t.lng);return!!i&&n.indexOf(i)===e});return e.reduce((t,e)=>+t+ +e.lat,0)*e.reduce((t,e)=>+t+ +e.lng,0)}static getMidPoint(t,e){const n=this.turfHelper.getMidpoint(t,e);return{lat:n.lat,lng:n.lng}}static getBounds(t){const e=[];t.forEach(t=>{isNaN(t.lat)||isNaN(t.lng),e.push(t)});return new s.Polyline(e).getBounds()}static getCenterOfMass(t){const e=this.turfHelper.getCenterOfMass(t);return{lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]}}}r(so,"turfHelper",new to(a));class ao{constructor(t){if(r(this,"polygon",[]),r(this,"trashcanPoint",[]),r(this,"sqmArea",[]),r(this,"perimeter",[]),!Array.isArray(t))return;if(t.length>0&&Array.isArray(t[0])&&t[0].length>0&&"object"==typeof t[0][0]&&"lat"in t[0][0]){const e=t[0];return this.trashcanPoint[0]=this.getTrashcanPoint(e),this.sqmArea[0]=this.calculatePolygonArea(e),this.perimeter[0]=this.calculatePolygonPerimeter(e),void(this.polygon[0]=[e])}if(t.length>0&&t[0]&&"object"==typeof t[0]&&"lat"in t[0]){const e=t,n=[[e]];return this.trashcanPoint[0]=this.getTrashcanPoint(e),this.sqmArea[0]=this.calculatePolygonArea(e),this.perimeter[0]=this.calculatePolygonPerimeter(e),void(this.polygon[0]=n[0])}t.forEach((t,e)=>{t&&Array.isArray(t)&&t[0]&&Array.isArray(t[0])&&(this.trashcanPoint[e]=this.getTrashcanPoint(t[0]),this.sqmArea[e]=this.calculatePolygonArea(t[0]),this.perimeter[e]=this.calculatePolygonPerimeter(t[0]),this.polygon[e]=t)})}setSqmArea(t){this.sqmArea[0]=t}getTrashcanPoint(t){if(!Array.isArray(t)||0===t.length)return console.warn("getTrashcanPoint: Invalid polygon array:",t),{lat:0,lng:0};const e=t.filter(t=>t&&"object"==typeof t&&"number"==typeof t.lat&&"number"==typeof t.lng&&!isNaN(t.lat)&&!isNaN(t.lng));if(0===e.length)return console.warn("getTrashcanPoint: No valid coordinates found:",t),{lat:0,lng:0};const n=Math.max(...e.map(t=>t.lat)),i=e.findIndex(t=>t.lat===n);if(-1===i)return console.warn("getTrashcanPoint: Could not find max lat coordinate"),{lat:0,lng:0};let r,o;if(i>0?(r=e[i-1],o=i<e.length-1?e[i+1]:e[0]):(r=e[e.length-1],o=e[i+1]),!r||!o)return console.warn("getTrashcanPoint: Could not determine previous/next points"),e[i]||{lat:0,lng:0};const s=r.lng<o.lng?r:o;return so.getMidPoint(e[i],s)}calculatePolygonArea(t){return so.getSqmArea(t)}calculatePolygonPerimeter(t){return so.getPerimeter(t)}}class lo{constructor(t){r(this,"polygonInfoListeners",[]),r(this,"polygonDrawStateListeners",[]),r(this,"polygonInformationStorage",[]),this.mapStateService=t}onPolygonInfoUpdated(t){this.polygonInfoListeners.push(t)}emitPolygonInfoUpdated(){for(const t of this.polygonInfoListeners)t(this.polygonInformationStorage)}onPolygonDrawStateUpdated(t){this.polygonDrawStateListeners.push(t)}updatePolygons(){const t=[];this.polygonInformationStorage.length>0&&this.polygonInformationStorage.forEach(e=>{const n=[];e.polygon.forEach(t=>{t.forEach(t=>{const e=[...t];t.length>0&&t[0].toString()!==t[t.length-1].toString()&&e.push(t[0]),n.push(e)})}),t.push(n)}),this.mapStateService.updatePolygons(t),this.saveCurrentState()}saveCurrentState(){this.emitPolygonInfoUpdated()}deleteTrashcan(t){const e=this.polygonInformationStorage.findIndex(e=>e.polygon[0]===t);-1!==e&&(this.polygonInformationStorage.splice(e,1),this.updatePolygons())}deleteTrashCanOnMulti(t){let e=0;this.polygonInformationStorage.forEach((n,i)=>{const r=n.polygon.findIndex(e=>e.toString()===t.toString());r>=0&&(e=i,n.trashcanPoint.splice(r,1),n.sqmArea.splice(r,1),n.perimeter.splice(r,1),n.polygon.splice(r,1))}),this.updatePolygons(),this.polygonInformationStorage.length>1&&this.polygonInformationStorage.splice(e,1)}deletePolygonInformationStorage(){this.polygonInformationStorage=[]}createPolygonInformationStorage(t){t.length>0&&(t.forEach(t=>{var e;const n=null==(e=t.getLayers)?void 0:e.call(t);if(null==n?void 0:n[0]){const t=n[0].getLatLngs(),e=new ao(t);this.polygonInformationStorage.push(e)}}),this.updatePolygons())}}class uo{constructor(){r(this,"map",null),r(this,"mapListeners",[])}onMapUpdated(t){this.map&&t(this.map),this.mapListeners.push(t)}emitMapUpdated(){if(this.map)for(const t of this.mapListeners)t(this.map)}updateMapState(t){this.map=t,this.emitMapUpdated()}updatePolygons(t){}}class ho{constructor(){r(this,"eventListeners",new Map)}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){const n=this.eventListeners.get(t);if(n){const t=n.indexOf(e);t>-1&&n.splice(t,1)}}emit(t,e){var n;this.eventListeners.has(t)&&(null==(n=this.eventListeners.get(t))||n.forEach(t=>{t(e)}))}}class co{constructor(t,e){r(this,"state"),r(this,"config"),r(this,"eventManager"),this.config=t,this.eventManager=e,this.state=this.createInitialState()}createInitialState(){return{polygonDragging:this.config.modes.dragPolygons??!1,markerDragging:this.config.modes.dragElbow??!1,edgeClicking:!0,polygonClicking:!0,canStartDrawing:!0,canCompletePolygon:!1,mapDragging:!0,mapZooming:!0,mapDoubleClickZoom:!0,currentMode:l.Off,isDrawingActive:!1,isModifierKeyHeld:!1,showCrosshairCursor:!1,showDragCursor:!1}}updateStateForMode(t){switch(this.state.currentMode=t,t){case l.Off:this.setOffModeState();break;case l.Add:case l.Subtract:this.setDrawingModeState();break;case l.PointToPoint:this.setPointToPointModeState()}this.state.isDrawingActive=t!==l.Off,this.eventManager.emit("polydraw:mode:change",{mode:t})}setOffModeState(){this.state.polygonDragging=this.config.modes.dragPolygons??!1,this.state.markerDragging=this.config.modes.dragElbow??!1,this.state.edgeClicking=!0,this.state.polygonClicking=!0,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!1,this.state.mapDragging=!0,this.state.mapZooming=!0,this.state.mapDoubleClickZoom=!0,this.state.showCrosshairCursor=!1,this.state.showDragCursor=!1}setDrawingModeState(){this.state.polygonDragging=!1,this.state.markerDragging=!1,this.state.edgeClicking=!1,this.state.polygonClicking=!1,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!0,this.state.mapDragging=!1,this.state.mapZooming=!1,this.state.mapDoubleClickZoom=!1,this.state.showCrosshairCursor=!0,this.state.showDragCursor=!1}setPointToPointModeState(){this.state.polygonDragging=!1,this.state.markerDragging=!1,this.state.edgeClicking=!1,this.state.polygonClicking=!1,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!0,this.state.mapDragging=!1,this.state.mapZooming=!1,this.state.mapDoubleClickZoom=!1,this.state.showCrosshairCursor=!0,this.state.showDragCursor=!1}setModifierKeyState(t){this.state.isModifierKeyHeld=t,this.state.currentMode,l.Off}canPerformAction(t){switch(t){case"polygonDrag":return this.state.polygonDragging;case"markerDrag":return this.state.markerDragging;case"edgeClick":return this.state.edgeClicking;case"polygonClick":return this.state.polygonClicking;case"startDrawing":return this.state.canStartDrawing;case"completePolygon":return this.state.canCompletePolygon;case"mapDrag":return this.state.mapDragging;case"mapZoom":return this.state.mapZooming;case"mapDoubleClickZoom":return this.state.mapDoubleClickZoom;default:return!1}}isInDrawingMode(){return this.state.isDrawingActive}isInOffMode(){return this.state.currentMode===l.Off}getCurrentMode(){return this.state.currentMode}getState(){return{...this.state}}shouldShowCrosshairCursor(){return this.state.showCrosshairCursor}shouldShowDragCursor(){return this.state.showDragCursor}updateConfig(t){this.config=t,this.updateStateForMode(this.state.currentMode)}}class fo{constructor(t){r(this,"turfHelper"),r(this,"map"),r(this,"config"),r(this,"modeManager"),r(this,"eventManager"),r(this,"tracer"),r(this,"p2pMarkers",[]),r(this,"isModifierKeyHeld",!1),r(this,"markerModifierHandlers",new WeakMap),this.turfHelper=t.turfHelper,this.map=t.map,this.config=t.config,this.modeManager=t.modeManager,this.eventManager=t.eventManager,this.tracer=t.tracer}mouseMove(t){if("latlng"in t&&t.latlng)this.tracer.addLatLng(t.latlng);else if("touches"in t&&t.touches&&t.touches.length>0){const e=this.map.containerPointToLatLng([t.touches[0].clientX,t.touches[0].clientY]);this.tracer.addLatLng(e)}}async mouseUpLeave(t){const e=this.tracer.toGeoJSON();if(!e||!e.geometry||!e.geometry.coordinates||e.geometry.coordinates.length<3)return{success:!1,error:"Not enough points to form a valid polygon. Event: "+JSON.stringify(t)};let n;try{n=this.turfHelper.createPolygonFromTrace(e)}catch(i){return{success:!1,error:(i instanceof Error?i.message:"Failed to create polygon from trace")+". Event: "+JSON.stringify(t)}}return n&&n.geometry&&n.geometry.coordinates&&0!==n.geometry.coordinates.length?(this.eventManager.emit("polydraw:polygon:created",{polygon:n,mode:this.modeManager.getCurrentMode()}),{success:!0,polygon:n}):{success:!1,error:"Invalid polygon created from trace. Event: "+JSON.stringify(t)}}setModifierKey(t){this.isModifierKeyHeld=t}handlePointToPointClick(t){if(t){if(this.p2pMarkers.length>=3){const e=this.p2pMarkers[0].getLatLng();if(this.isClickingFirstPoint(t,e))return void this.completePointToPointPolygon()}try{const e=0===this.p2pMarkers.length,n=e?"leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker":"leaflet-polydraw-p2p-marker",i=new s.Marker(t,{icon:s.divIcon({className:n,iconSize:e?[20,20]:[16,16]}),draggable:this.config.modes.dragElbow}).addTo(this.map);i.on("mousedown",t=>{s.DomEvent.stopPropagation(t)}),i.on("drag",()=>{this.updateP2PTracer()}),i.on("click",t=>{this.isModifierKeyHeld&&this.config.modes.edgeDeletion&&(this.deleteP2PMarker(i),s.DomEvent.stopPropagation(t))}),i.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(i,!0)),i.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(i,!1)),e&&(i.on("mouseover",()=>{if(this.p2pMarkers.length>=3){const t=i.getElement();t&&(t.style.backgroundColor=this.config.colors.p2p.closingMarker,t.style.borderColor=this.config.colors.p2p.closingMarker,t.style.cursor="pointer",t.title="Click to close polygon")}}),i.on("mouseout",()=>{const t=i.getElement();t&&(t.style.backgroundColor="",t.style.borderColor="",t.style.cursor="",t.title="")}),i.on("click",t=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion)return this.deleteP2PMarker(i),void s.DomEvent.stopPropagation(t);this.p2pMarkers.length>=3&&(s.DomEvent.stopPropagation(t),this.completePointToPointPolygon())})),this.p2pMarkers.push(i),this.updateP2PTracer()}catch(e){}}}handleDoubleClick(t){this.modeManager.getCurrentMode()===l.PointToPoint&&this.p2pMarkers.length>=3&&this.completePointToPointPolygon()}completePointToPointPolygon(){const t=this.p2pMarkers.map(t=>t.getLatLng());if(t.length<3)return;const e=[...t],n=t[0],i=t[t.length-1];n.lat===i.lat&&n.lng===i.lng||e.push(n);try{const t=e.map(t=>[t.lng,t.lat]),n=this.turfHelper.getMultiPolygon([[t]]);this.clearP2pMarkers(),this.resetTracer(),this.eventManager.emit("polydraw:polygon:created",{polygon:n,mode:l.PointToPoint,isPointToPoint:!0})}catch(r){console.warn("Error completing point-to-point polygon:",r),this.clearP2pMarkers(),this.resetTracer()}}cancelPointToPointDrawing(){this.clearP2pMarkers(),this.resetTracer(),this.eventManager.emit("polydraw:draw:cancel",{mode:l.PointToPoint})}clearP2pMarkers(){this.p2pMarkers.forEach(t=>this.map.removeLayer(t)),this.p2pMarkers=[]}resetTracer(){this.tracer.setLatLngs([]);try{this.tracer.setStyle({dashArray:void 0})}catch(t){}}isClickingFirstPoint(t,e){if(!e)return!1;const n=this.map.getZoom(),i=5e-4/Math.pow(2,Math.max(0,n-10)),r=Math.abs(t.lat-e.lat),o=Math.abs(t.lng-e.lng);return r<i&&o<i}updateP2PTracer(){const t=this.p2pMarkers.map(t=>t.getLatLng());if(this.tracer.setLatLngs(t),this.p2pMarkers.length>=2)try{this.tracer.setStyle({color:this.config.colors.polyline,dashArray:"5, 5"})}catch(e){}else try{this.tracer.setStyle({dashArray:void 0})}catch(e){}}deleteP2PMarker(t){const e=this.p2pMarkers.findIndex(e=>e===t);e>-1&&(this.p2pMarkers.splice(e,1),this.map.removeLayer(t),this.updateP2PTracer(),0===e&&this.p2pMarkers.length>0&&this.setupFirstMarker())}getP2pMarkers(){return[...this.p2pMarkers]}isInPointToPointMode(){return this.modeManager.getCurrentMode()===l.PointToPoint}getTracerPointsCount(){return this.tracer.getLatLngs().length}setupFirstMarker(){if(0===this.p2pMarkers.length)return;const t=this.p2pMarkers[0],e=t.getElement();e&&(e.classList.add("leaflet-polydraw-p2p-first-marker"),t.setIcon(s.divIcon({className:"leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker",iconSize:[20,20]}))),t.off("mouseover"),t.off("mouseout"),t.off("click"),t.on("mouseover",()=>{if(this.p2pMarkers.length>=3){const e=t.getElement();e&&(e.style.backgroundColor=this.config.colors.p2p.closingMarker,e.style.borderColor=this.config.colors.p2p.closingMarker,e.style.cursor="pointer",e.title="Click to close polygon")}}),t.on("mouseout",()=>{const e=t.getElement();e&&(e.style.backgroundColor="",e.style.borderColor="",e.style.cursor="",e.title="")}),t.on("click",e=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion)return this.deleteP2PMarker(t),void s.DomEvent.stopPropagation(e);this.p2pMarkers.length>=3&&(s.DomEvent.stopPropagation(e),this.completePointToPointPolygon())})}onMarkerHoverForEdgeDeletion(t,e){const n=t.getElement();if(n)if(e){const e=t=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion){n.classList.add("edge-deletion-hover");try{this.map.getContainer().style.cursor="pointer"}catch(e){}}else{n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(e){}}};this.markerModifierHandlers.set(t,e),document.addEventListener("keydown",e),document.addEventListener("keyup",e),n.addEventListener("mousemove",e)}else{n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(i){}const e=this.markerModifierHandlers.get(t);e&&(document.removeEventListener("keydown",e),document.removeEventListener("keyup",e),n.removeEventListener("mousemove",e),this.markerModifierHandlers.delete(t))}}}class go{constructor(t){r(this,"turfHelper"),r(this,"config"),this.turfHelper=t.turfHelper,this.config=t.config}checkPolygonIntersection(t,e){try{const n=this.turfHelper.isPolygonCompletelyWithin(t,e),i=this.turfHelper.isPolygonCompletelyWithin(e,t);if(n||i)return!0}catch(n){}try{if(this.turfHelper.polygonIntersect(t,e))return!0}catch(n){}try{const n=this.turfHelper.getIntersection(t,e);if(n&&n.geometry&&("Polygon"===n.geometry.type||"MultiPolygon"===n.geometry.type)){if(this.turfHelper.getPolygonArea(n)>1e-6)return!0}}catch(n){}try{const n=this.turfHelper.getCoords(t),i=this.turfHelper.getCoords(e);for(const e of i)for(const n of e[0]){const e={type:"Feature",geometry:{type:"Point",coordinates:n},properties:{}};if(this.turfHelper.isPointInsidePolygon(e,t))return!0}for(const t of n)for(const n of t[0]){const t={type:"Feature",geometry:{type:"Point",coordinates:n},properties:{}};if(this.turfHelper.isPointInsidePolygon(t,e))return!0}}catch(n){}return!1}unionPolygons(t,e){try{let n=e;for(const e of t){const t=this.turfHelper.union(n,e);t&&(n=t)}return{success:!0,result:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in unionPolygons"}}}subtractPolygon(t,e){try{const n=this.turfHelper.polygonDifference(t,e);if(n){const t=this.turfHelper.getCoords(n),e=[];for(const n of t)e.push(this.turfHelper.getMultiPolygon([n]));return{success:!0,results:e}}return{success:!0,results:[]}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in subtractPolygon"}}}simplifyPolygon(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};const r=(null==(n=null==(e=this.config.menuOperations)?void 0:e.simplify)?void 0:n.processHoles)??!0,o=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];if(0===n||r){if(i.length<=4){e.push(i);continue}const t=[];for(let e=0;e<i.length;e+=2)t.push(i[e]);const n=t[0],r=t[t.length-1];n[0]===r[0]&&n[1]===r[1]||t.push(n),t.length<4?e.push(i):e.push(t)}else e.push(i)}return e}),s=this.turfHelper.getMultiPolygon(o);return{success:!0,result:this.turfHelper.getTurfPolygon(s)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in simplifyPolygon"}}}convertToBoundingBox(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};if(!((null==(n=null==(e=this.config.menuOperations)?void 0:e.bbox)?void 0:n.processHoles)??!0)){const e=this.turfHelper.convertToBoundingBoxPolygon(t);return{success:!0,result:this.turfHelper.getTurfPolygon(e)}}const r=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];let r=1/0,o=-1/0,s=1/0,a=-1/0;for(const t of i)if(Array.isArray(t)&&t.length>=2){const e=t[0],n=t[1];"number"!=typeof e||"number"!=typeof n||isNaN(e)||isNaN(n)||(s=Math.min(s,e),a=Math.max(a,e),r=Math.min(r,n),o=Math.max(o,n))}if(r!==1/0&&o!==-1/0&&s!==1/0&&a!==-1/0){const t=[[s,r],[s,o],[a,o],[a,r],[s,r]];e.push(t)}else e.push(i)}return e}),o=this.turfHelper.getMultiPolygon(r);return{success:!0,result:this.turfHelper.getTurfPolygon(o)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in convertToBoundingBox"}}}bezierifyPolygon(t){try{const e=this.turfHelper.getCoords(t),n=this.turfHelper.getBezierMultiPolygon(e);return{success:!0,result:this.turfHelper.getTurfPolygon(n)}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error in bezierifyPolygon"}}}doubleElbowsPolygon(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};const r=(null==(n=null==(e=this.config.menuOperations)?void 0:e.doubleElbows)?void 0:n.processHoles)??!0,o=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];if(0===n||r){const t=i.map(t=>({lat:t[1],lng:t[0]})),n=this.turfHelper.getDoubleElbowLatLngs(t).map(t=>[t.lng,t.lat]);e.push(n)}else e.push(i)}return e}),s=this.turfHelper.getMultiPolygon(o);return{success:!0,result:this.turfHelper.getTurfPolygon(s)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in doubleElbowsPolygon"}}}}class po{static createDivIcon(t){const e=t.join(" ");return s.divIcon({className:e})}}class yo{constructor(t,e){r(this,"markerFeatureGroupMap",new WeakMap),r(this,"markerModifierHandlers",new WeakMap),r(this,"_activeMarker",null),r(this,"isDraggingMarker",!1),r(this,"turfHelper"),r(this,"polygonInformation"),r(this,"map"),r(this,"config"),r(this,"modeManager"),r(this,"eventManager"),r(this,"currentDragPolygon",null),r(this,"currentModifierDragMode",!1),r(this,"isModifierKeyHeld",!1),r(this,"_openMenuPopup",null),r(this,"getFeatureGroups"),r(this,"removeFeatureGroup"),r(this,"onPolygonMouseMove",t=>{if(!this.currentDragPolygon||!this.currentDragPolygon._polydrawDragData||!this.currentDragPolygon._polydrawDragData.isDragging)return;const e=this.currentDragPolygon,n=e._polydrawDragData,i=t.originalEvent&&"metaKey"in t.originalEvent?t.originalEvent:t;this.detectDragSubtractModifierKey(i)!==this.currentModifierDragMode&&this.handleModifierToggleDuringDrag(i);const r=n.startPosition,o=t.latlng,s=o.lat-r.lat,a=o.lng-r.lng,l=this.offsetPolygonCoordinates(n.startLatLngs,s,a);e.setLatLngs(l),this.updateMarkersAndHoleLinesDuringDrag(e,s,a)}),r(this,"onPolygonMouseUp",t=>{if(!this.currentDragPolygon||!this.currentDragPolygon._polydrawDragData||!this.currentDragPolygon._polydrawDragData.isDragging)return;const e=this.currentDragPolygon;e._polydrawDragData.isDragging=!1,this.map.off("mousemove",this.onPolygonMouseMove,this),this.map.off("mouseup",this.onPolygonMouseUp,this),this.map.dragging&&this.map.dragging.enable(),e._polydrawDragData&&null!=e._polydrawDragData.originalOpacity&&e.setStyle({fillOpacity:e._polydrawDragData.originalOpacity}),this.setMarkerVisibility(e,!0);try{this.map.getContainer().style.cursor=""}catch(n){}this.updatePolygonAfterDrag(e),e._polydrawOriginalMarkerPositions&&(e._polydrawOriginalMarkerPositions.clear(),delete e._polydrawOriginalMarkerPositions),e._polydrawOriginalHoleLinePositions&&(e._polydrawOriginalHoleLinePositions.clear(),delete e._polydrawOriginalHoleLinePositions),e._polydrawCurrentDragSession&&delete e._polydrawCurrentDragSession,this.currentDragPolygon=null}),r(this,"onMarkerHoverForEdgeDeletionEvent",t=>{if(!this.isModifierKeyHeld)return;const e=t.target;e&&(e.style.backgroundColor=this.config.colors.edgeDeletion.hover,e.style.borderColor=this.config.colors.edgeDeletion.hover,e.classList.add("edge-deletion-hover"))}),r(this,"onMarkerLeaveForEdgeDeletionEvent",t=>{const e=t.target;e&&(e.style.backgroundColor="",e.style.borderColor="",e.classList.remove("edge-deletion-hover"))}),this.turfHelper=t.turfHelper,this.polygonInformation=t.polygonInformation,this.map=t.map,this.config=t.config,this.modeManager=t.modeManager,this.eventManager=t.eventManager,this.getFeatureGroups=e.getFeatureGroups,this.removeFeatureGroup=e.removeFeatureGroup}addMarkers(t,e){let n=this.getMarkerIndex(t,this.config.markers.markerMenuIcon.position),i=this.getMarkerIndex(t,this.config.markers.markerDeleteIcon.position),r=this.getMarkerIndex(t,this.config.markers.markerInfoIcon.position);const o=this.ensureMarkerSeparation(t.length,{menu:{index:n,enabled:this.config.markers.menuMarker},delete:{index:i,enabled:this.config.markers.deleteMarker},info:{index:r,enabled:this.config.markers.infoMarker}});n=o.menu,i=o.delete,r=o.info,t.forEach((o,a)=>{let l=this.config.markers.markerIcon.styleClasses;a===n&&this.config.markers.menuMarker&&(l=this.config.markers.markerMenuIcon.styleClasses),a===i&&this.config.markers.deleteMarker&&(l=this.config.markers.markerDeleteIcon.styleClasses),a===r&&this.config.markers.infoMarker&&(l=this.config.markers.markerInfoIcon.styleClasses);const u=Array.isArray(l)?l:[l],h=a===n&&this.config.markers.menuMarker||a===i&&this.config.markers.deleteMarker||a===r&&this.config.markers.infoMarker,c=new s.Marker(o,{icon:this.createDivIcon(u),draggable:this.config.modes.dragElbow,title:this.config.markers.coordsTitle?this.getLatLngInfoString(o):"",zIndexOffset:this.config.markers.markerIcon.zIndexOffset??this.config.markers.zIndexOffset});e.addLayer(c).addTo(this.map),this.markerFeatureGroupMap.set(c,e),c.on("add",()=>{const t=c.getElement();t&&(t.style.pointerEvents="auto")}),c.on("click",t=>{var e,n;this.isDraggingMarker&&(null==(n=null==(e=t.originalEvent)?void 0:e.stopPropagation)||n.call(e),s.DomEvent.stopPropagation(t))}),c.on("dragstart",()=>{this.isDraggingMarker=!0,this._activeMarker=c}),c.on("dragend",t=>{const e=this.markerFeatureGroupMap.get(c);this.modeManager.canPerformAction("markerDrag")&&e&&this.markerDragEnd(e),this._activeMarker=null,s.DomEvent.stopPropagation(t),setTimeout(()=>{this.isDraggingMarker=!1},10)});const f=c.getElement();if(f&&(f.addEventListener("touchstart",t=>{t.stopPropagation()},{passive:!0}),f.addEventListener("touchend",t=>{if(t.preventDefault(),t.stopPropagation(),c.fire("click"),this.isDraggingMarker&&!h){const t=this.markerFeatureGroupMap.get(c);this.modeManager.canPerformAction("markerDrag")&&t&&this.markerDragEnd(t)}this._activeMarker=null})),a===n||a===i||a===r){const t=c.getElement();t&&(t.style.zIndex="10000")}if(this.config.modes.dragElbow){const t=t=>()=>{this.modeManager.canPerformAction("markerDrag")&&this.markerDrag(t)};c.on("drag",t(e))}if(a===n&&this.config.markers.menuMarker&&(c.options.zIndexOffset=this.config.markers.markerMenuIcon.zIndexOffset??this.config.markers.zIndexOffset,c.on("click",()=>{const n=this.getPolygonGeoJSONFromFeatureGroup(e),i=so.getCenterOfMass(n);this.generateMenuMarkerPopup(t,e).setLatLng(i).openOn(this.map)}),c.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),c.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})),a===r&&this.config.markers.infoMarker){const t=this.getPolygonGeoJSONFromFeatureGroup(e),n=this.turfHelper.getPolygonArea(t),i=this.getTotalPolygonPerimeter(t);c.options.zIndexOffset=this.config.markers.markerInfoIcon.zIndexOffset??this.config.markers.zIndexOffset,c.on("click",()=>{const e=this.generateInfoMarkerPopup(n,i),r=so.getCenterOfMass(t);e.setLatLng(r).openOn(this.map)}),c.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),c.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})}c.on("mousedown",t=>{this.modeManager.isInOffMode()||(s.DomEvent.stopPropagation(t),this.map.fire("mousedown",t)),this._activeMarker=c}),c.on("click",t=>{if(this.modeManager.isInOffMode())if(this.isEdgeDeletionModifierKeyPressed(t.originalEvent)){const n=e.getLayers().find(t=>t instanceof s.Polygon);n&&this.elbowClicked(t,n,c.getLatLng())}else a===i&&this.config.markers.deleteMarker&&(this.map.closePopup(),this.removeFeatureGroup(e),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups()),this.eventManager.emit("polydraw:polygon:deleted",void 0))}),c.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(c,!0)),c.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(c,!1))});const a=this.map.getContainer();a&&(a.style.touchAction="manipulation")}addHoleMarkers(t,e){var n,i,r;const o=(null==(n=this.config.markers.holeMarkers)?void 0:n.menuMarker)??!1,a=(null==(i=this.config.markers.holeMarkers)?void 0:i.deleteMarker)??!1,l=(null==(r=this.config.markers.holeMarkers)?void 0:r.infoMarker)??!1;let u=this.getMarkerIndex(t,this.config.markers.markerMenuIcon.position),h=this.getMarkerIndex(t,this.config.markers.markerDeleteIcon.position),c=this.getMarkerIndex(t,this.config.markers.markerInfoIcon.position);const f=this.ensureMarkerSeparation(t.length,{menu:{index:u,enabled:o},delete:{index:h,enabled:a},info:{index:c,enabled:l}});u=f.menu,h=f.delete,c=f.info,t.forEach((n,i)=>{let r=this.config.markers.holeIcon.styleClasses;i===u&&o&&(r=this.config.markers.markerMenuIcon.styleClasses),i===h&&a&&(r=this.config.markers.markerDeleteIcon.styleClasses),i===c&&l&&(r=this.config.markers.markerInfoIcon.styleClasses);const f=Array.isArray(r)?r:[r],g=i===u&&o||i===h&&a||i===c&&l,d=new s.Marker(n,{icon:this.createDivIcon(f),draggable:this.config.modes.dragElbow,title:this.config.markers.coordsTitle?this.getLatLngInfoString(n):"",zIndexOffset:this.config.markers.holeIcon.zIndexOffset??this.config.markers.zIndexOffset});e.addLayer(d).addTo(this.map),this.markerFeatureGroupMap.set(d,e),d.on("add",()=>{const t=d.getElement();t&&(t.style.pointerEvents="auto")}),d.on("click",t=>{var e,n;this.isDraggingMarker&&(null==(n=null==(e=t.originalEvent)?void 0:e.stopPropagation)||n.call(e),s.DomEvent.stopPropagation(t))}),d.on("dragstart",()=>{this.isDraggingMarker=!0,this._activeMarker=d}),d.on("dragend",t=>{const e=this.markerFeatureGroupMap.get(d);this.modeManager.canPerformAction("markerDrag")&&e&&this.markerDragEnd(e),this._activeMarker=null,s.DomEvent.stopPropagation(t),setTimeout(()=>{this.isDraggingMarker=!1},10)});const p=d.getElement();if(p&&(p.addEventListener("touchstart",t=>{t.stopPropagation()},{passive:!0}),p.addEventListener("touchend",t=>{if(t.preventDefault(),t.stopPropagation(),d.fire("click"),this.isDraggingMarker&&!g){const t=this.markerFeatureGroupMap.get(d);this.modeManager.canPerformAction("markerDrag")&&t&&this.markerDragEnd(t)}this._activeMarker=null})),i===u||i===h||i===c){const t=d.getElement();t&&(t.style.zIndex="10000")}if(this.config.modes.dragElbow){const t=t=>()=>{this.modeManager.canPerformAction("markerDrag")&&this.markerDrag(t)};d.on("drag",t(e))}if(i===u&&o&&(d.options.zIndexOffset=this.config.markers.markerMenuIcon.zIndexOffset??this.config.markers.zIndexOffset,d.on("click",()=>{const n=t.map(t=>[t.lng,t.lat]);n.push(n[0]);const i={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}},r=so.getCenterOfMass(i);this.generateMenuMarkerPopup(t,e).setLatLng(r).openOn(this.map)}),d.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),d.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})),i===c&&l){const e=t.map(t=>[t.lng,t.lat]);e.push(e[0]);const i={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[e]}},r=this.turfHelper.getPolygonArea(i),o=1e3*this.turfHelper.getPolygonPerimeter(i);d.options.zIndexOffset=this.config.markers.markerInfoIcon.zIndexOffset??this.config.markers.zIndexOffset,d.on("click",()=>{this.generateInfoMarkerPopup(r,o).setLatLng(n).openOn(this.map)})}d.on("mousedown",t=>{this.modeManager.isInOffMode()||(s.DomEvent.stopPropagation(t),this.map.fire("mousedown",t)),this._activeMarker=d}),d.on("click",t=>{if(this.modeManager.isInOffMode())if(this.isEdgeDeletionModifierKeyPressed(t.originalEvent)){const n=e.getLayers().find(t=>t instanceof s.Polygon);n&&this.elbowClicked(t,n,d.getLatLng())}else if(i===h&&a){this.map.closePopup();const t=e.getLayers().find(t=>t instanceof s.Polygon);if(t){const n=t.getLatLngs();let i=[];if(Array.isArray(n)&&n.length>0)if(Array.isArray(n[0])){const t=n[0];i=Array.isArray(t)&&Array.isArray(t[0])?n[0]:n}else i=[n];const r=d.getLatLng();let o=-1;for(let t=1;t<i.length;t++)if(i[t].some(t=>t.lat===r.lat&&t.lng===r.lng)){o=t;break}if(o>0){const t=i.filter((t,e)=>e!==o).map(t=>{const e=t.map(t=>[t.lng,t.lat]);if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e}),n=this.turfHelper.getMultiPolygon([t]);this.removeFeatureGroup(e),this.eventManager.emit("polydraw:polygon:updated",{operation:"removeHole",polygon:n})}}}}),d.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(d,!0)),d.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(d,!1))})}addEdgeClickListeners(t,e){const n=t.getLatLngs();let i;if(Array.isArray(n)&&n.length>0){if(Array.isArray(n[0]))if(Array.isArray(n[0][0])&&n[0][0].length>0){n[0][0][0];i=n[0]}else i=n[0][0]&&"object"==typeof n[0][0]&&"lat"in n[0][0]?n:n[0];else i=(n[0]&&"object"==typeof n[0]&&n[0],[n]);i.forEach((n,i)=>{for(let r=0;r<n.length;r++){const o=n[r],a=n[(r+1)%n.length];if(o.lat===a.lat&&o.lng===a.lng)continue;const l=s.polyline([o,a],{color:"transparent",weight:10,opacity:0,interactive:!0});l._polydrawEdgeInfo={ringIndex:i,edgeIndex:r,startPoint:o,endPoint:a,parentPolygon:t,parentFeatureGroup:e},l.on("click",t=>{this.onEdgeClick(t,l)}),l.on("mouseover",()=>{this.highlightEdgeOnHover(l,!0)}),l.on("mouseout",()=>{this.highlightEdgeOnHover(l,!1)}),e.addLayer(l)}})}}enablePolygonDragging(t,e){this.config.modes.dragPolygons&&(t._polydrawOriginalLatLngs=e,t._polydrawDragData={isDragging:!1,startPosition:null,startLatLngs:null,originalOpacity:t.options.fillOpacity},t.on("mousedown",e=>{if(!this.modeManager.isInOffMode())return s.DomEvent.stopPropagation(e),void this.map.fire("mousedown",e);if(!this.modeManager.canPerformAction("polygonDrag"))return;s.DomEvent.stopPropagation(e.originalEvent),s.DomEvent.preventDefault(e.originalEvent);const n=this.detectDragSubtractModifierKey(e.originalEvent);this.currentModifierDragMode=n,this.isModifierKeyHeld=n,t._polydrawDragData.isDragging=!0,t._polydrawDragData.startPosition=e.latlng,t._polydrawDragData.startLatLngs=t.getLatLngs(),t.setStyle({fillOpacity:this.config.dragPolygons.opacity}),this.map.dragging&&this.map.dragging.disable(),this.setSubtractVisualMode(t,n),this.setMarkerVisibility(t,!1);try{this.map.getContainer().style.cursor=this.config.dragPolygons.dragCursor||"move"}catch(i){}this.map.on("mousemove",this.onPolygonMouseMove,this),this.map.on("mouseup",this.onPolygonMouseUp,this),this.currentDragPolygon=t}),t.on("mouseover",()=>{if(!t._polydrawDragData||!t._polydrawDragData.isDragging)try{this.map.getContainer().style.cursor=this.config.dragPolygons.hoverCursor||"grab"}catch(e){}}),t.on("mouseout",()=>{if(!t._polydrawDragData||!t._polydrawDragData.isDragging)try{this.map.getContainer().style.cursor=""}catch(e){}}))}updateMarkerDraggableState(){const t=this.modeManager.canPerformAction("markerDrag");this.getFeatureGroups().forEach(e=>{e.eachLayer(e=>{if(e instanceof s.Marker){const i=e;try{i.options.draggable=t,i.dragging&&(t?i.dragging.enable():i.dragging.disable())}catch(n){}}})})}updateAllMarkersForEdgeDeletion(t){this.getFeatureGroups().forEach(e=>{e.eachLayer(e=>{e instanceof s.Marker&&this.updateMarkerForEdgeDeletion(e,t)})})}updateMarkerForEdgeDeletion(t,e){const n=t.getElement();n&&(e?(n.addEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.addEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent)):(n.removeEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.removeEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent),n.style.backgroundColor="",n.style.borderColor=""))}setModifierKeyHeld(t){this.isModifierKeyHeld=t}onEdgeClick(t,e){if(!this.config.modes.attachElbow)return;if(!this.modeManager.isInOffMode())return;const n=e._polydrawEdgeInfo;if(!n)return;const i=t.latlng,r=n.parentPolygon,o=n.parentFeatureGroup;if(r&&o)try{if("function"!=typeof r.toGeoJSON)return;const t=r.toGeoJSON();if("MultiPolygon"===t.geometry.type||"Polygon"===t.geometry.type){const e=this.turfHelper.injectPointToPolygon(t,[i.lng,i.lat],n.ringIndex);if(e){const t=r._polydrawOptimizationLevel||0;this.removeFeatureGroup(o),this.eventManager.emit("polydraw:polygon:updated",{operation:"addVertex",polygon:e,optimizationLevel:t})}}}catch(a){}s.DomEvent.stopPropagation(t)}highlightEdgeOnHover(t,e){e?t.setStyle({color:this.config.colors.edgeHover,weight:4,opacity:1}):t.setStyle({color:"transparent",weight:10,opacity:0})}elbowClicked(t,e,n){if(!this.config.modes.edgeDeletion)return;if(!this.isEdgeDeletionModifierKeyPressed(t.originalEvent))return;const i=n??t.latlng,r=e.getLatLngs();let o=[];if(!(Array.isArray(r)&&r.length>0))return;if(Array.isArray(r[0])){const t=r[0];o=Array.isArray(t)&&Array.isArray(t[0])?r[0]:r}else o=[r];let s=-1,a=-1;for(let c=0;c<o.length;c++){const t=o[c];for(let e=0;e<t.length;e++){const n=t[e];if(n.lat===i.lat&&n.lng===i.lng){s=c,a=e;break}}if(-1!==s)break}if(-1===s||-1===a)return;if(o[s].length<=this.config.edgeDeletion.minVertices)return;const l=o.map((t,e)=>{if(e!==s)return t.slice();const n=t.slice();return n.splice(a,1),n}).map(t=>{const e=t.map(t=>[t.lng,t.lat]);if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e});let u=null;for(const c of this.getFeatureGroups()){let t=!1;if(c.eachLayer(n=>{n===e&&(t=!0)}),t){u=c;break}}u&&this.removeFeatureGroup(u);const h=this.turfHelper.getMultiPolygon([l]);this.eventManager.emit("polydraw:polygon:updated",{operation:"removeVertex",polygon:h})}markerDrag(t){if(!this._activeMarker)return void console.warn("No active marker set for dragging.");const e=[];let n=[],i=[];const r=t.getLayers(),o=r.find(t=>t instanceof s.Polygon),a=o.getLatLngs();let l=0;const u=r.filter(t=>t instanceof s.Marker);if(a.length>1)for(let s=0;s<a.length;s++)if(n=[],i=[],0===s){if(a[0].length>1)for(let t=0;t<a[0].length;t++){for(let e=0;e<a[0][t].length;e++)u[e]&&n.push(u[e].getLatLng());i.push(n)}else{for(let t=0;t<a[0][0].length;t++)u[t]&&n.push(u[t].getLatLng());i.push(n)}e.push(i)}else{l+=a[s-1].length;for(let t=l;t<a[s][0].length+l;t++)u[t]&&n.push(u[t].getLatLng());i.push(n),e.push(i)}else{i=[];let t=0;for(let e=0;e<a[0].length;e++){if(n=[],0===e)if(a[0][e].length>1)for(let t=0;t<a[0][e].length;t++)u[t]&&n.push(u[t].getLatLng());else for(let t=0;t<a[0][0].length;t++)u[t]&&n.push(u[t].getLatLng());else{t+=a[0][e-1].length;for(let i=t;i<a[0][e].length+t;i++)u[i]&&n.push(u[i].getLatLng())}i.push(n)}e.push(i)}o.setLatLngs(e)}async markerDragEnd(t){this.polygonInformation.deletePolygonInformationStorage();const e=t.toGeoJSON();if(e.features&&0!==e.features.length){if(this.removeFeatureGroup(t),"MultiPolygon"===e.features[0].geometry.type)for(const t of e.features[0].geometry.coordinates){const e=this.turfHelper.getMultiPolygon([t]);if(this.turfHelper.hasKinks(e)){const t=this.turfHelper.getKinks(e);for(const e of t)this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:this.turfHelper.getTurfPolygon(e),allowMerge:!0})}else this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:e,allowMerge:!0})}else{const t=this.turfHelper.getMultiPolygon([e.features[0].geometry.coordinates]);if(this.turfHelper.hasKinks(t)){const e=this.turfHelper.getKinks(t);for(const t of e)this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:this.turfHelper.getTurfPolygon(t),allowMerge:!0})}else this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:t,allowMerge:!0})}this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}}offsetPolygonCoordinates(t,e,n){return t?Array.isArray(t[0])?t.map(t=>this.offsetPolygonCoordinates(t,e,n)):t.map(t=>s.latLng(t.lat+e,t.lng+n)):t}updateMarkersAndHoleLinesDuringDrag(t,e,n){try{let i=null;for(const e of this.getFeatureGroups()){let n=!1;if(e.eachLayer(e=>{e===t&&(n=!0)}),n){i=e;break}}if(!i)return;const r="_polydrawDragSession_"+Date.now()+"_"+s.Util.stamp(t);t._polydrawCurrentDragSession||(t._polydrawCurrentDragSession=r,t._polydrawOriginalMarkerPositions=new Map,t._polydrawOriginalHoleLinePositions=new Map,i.eachLayer(e=>{if(e instanceof s.Marker)t._polydrawOriginalMarkerPositions.set(e,e.getLatLng());else if(e instanceof s.Polyline&&!(e instanceof s.Polygon)){const n=e.getLatLngs();t._polydrawOriginalHoleLinePositions.set(e,n)}})),i.eachLayer(i=>{if(i instanceof s.Marker){const r=t._polydrawOriginalMarkerPositions.get(i);if(r){const t={lat:r.lat+e,lng:r.lng+n};i.setLatLng(t)}}else if(i instanceof s.Polyline&&!(i instanceof s.Polygon)){const r=t._polydrawOriginalHoleLinePositions.get(i);if(r){let t;t=Array.isArray(r[0])?r.map(t=>t.map(t=>s.latLng(t.lat+e,t.lng+n))):r.map(t=>s.latLng(t.lat+e,t.lng+n)),i.setLatLngs(t)}}})}catch(i){console.warn("Error updating markers during drag:",i)}}async updatePolygonAfterDrag(t){try{let e=null;for(const r of this.getFeatureGroups())if(r.eachLayer(n=>{n===t&&(e=r)}),e)break;if(!e)return;const n=t.toGeoJSON();if(this.isModifierDragActive())return this.performModifierSubtract(n,e),this.currentModifierDragMode=!1,void(this.isModifierKeyHeld=!1);this.removeFeatureGroup(e);const i=this.turfHelper.getTurfPolygon(n);this.eventManager.emit("polydraw:polygon:updated",{operation:"polygonDrag",polygon:i,allowMerge:!0}),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}catch(e){}}getDragSubtractModifierKey(){const{keys:t}=this.config.dragPolygons.modifierSubtract,e=navigator.userAgent.toLowerCase(),n=e.includes("mac"),i=e.includes("windows");return n&&t.mac?t.mac:i&&t.windows?t.windows:t.linux?t.linux:n?"metaKey":"ctrlKey"}detectDragSubtractModifierKey(t){if(eo())return!1;return t[this.getDragSubtractModifierKey()]||!1}setSubtractVisualMode(t,e){if(t&&t.setStyle)try{e?t.setStyle({color:this.config.colors.dragPolygons.subtract}):t.setStyle({color:this.config.colors.polygon.border}),this.updateMarkerColorsForSubtractMode(t,e)}catch(n){}}updateMarkerColorsForSubtractMode(t,e){try{let n=null;for(const e of this.getFeatureGroups())if(e.eachLayer(i=>{i===t&&(n=e)}),n)break;if(!n)return;const i=n,r=this.config.dragPolygons.modifierSubtract.hideMarkersOnDrag;i.eachLayer(t=>{if(t instanceof s.Marker){const n=t.getElement();n&&(e?r?(n.style.display="none",n.classList.add("subtract-mode-hidden")):(n.style.backgroundColor=this.config.colors.dragPolygons.subtract,n.style.borderColor=this.config.colors.dragPolygons.subtract,n.classList.add("subtract-mode")):r?(n.style.display="",n.classList.remove("subtract-mode-hidden")):(n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("subtract-mode")))}})}catch(n){}}handleModifierToggleDuringDrag(t){const e=this.detectDragSubtractModifierKey(t);this.currentModifierDragMode=e,this.isModifierKeyHeld=e,this.currentDragPolygon&&this.setSubtractVisualMode(this.currentDragPolygon,e)}isModifierDragActive(){return this.currentModifierDragMode}performModifierSubtract(t,e){try{const n=this.turfHelper.getTurfPolygon(t),i=[];this.getFeatureGroups().forEach(t=>{if(t!==e)try{const e=t.toGeoJSON();if(!e||!e.features||!e.features[0])return;const s=e.features[0];if(!s.geometry||!s.geometry.coordinates)return;const a=this.turfHelper.getTurfPolygon(s);try{const e=this.turfHelper.getIntersection(a,n);if(e&&e.geometry&&"coordinates"in e.geometry){e.geometry.coordinates.length>0&&i.push(t)}}catch(r){try{this.turfHelper.polygonIntersect(a,n)&&i.push(t)}catch(o){}}}catch(s){}}),this.removeFeatureGroup(e),i.forEach(t=>{try{const i=t.toGeoJSON(),r=this.turfHelper.getTurfPolygon(i.features[0]);this.removeFeatureGroup(t);try{const t=this.turfHelper.polygonDifference(r,n);if(t&&t.geometry){const e=this.turfHelper.getCoords(t);for(const t of e){const e=this.turfHelper.getMultiPolygon([t]);this.eventManager.emit("polydraw:polygon:updated",{operation:"modifierSubtract",polygon:this.turfHelper.getTurfPolygon(e),allowMerge:!1})}}}catch(e){console.warn("Failed to perform difference operation:",e),this.eventManager.emit("polydraw:polygon:updated",{operation:"modifierSubtractFallback",polygon:r,allowMerge:!1})}}catch(i){console.warn("Error in modifier subtract operation:",i)}}),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}catch(n){console.warn("Error in performModifierSubtract:",n)}}getEdgeDeletionModifierKey(){const{keys:t}=this.config.edgeDeletion,e=navigator.userAgent.toLowerCase(),n=e.includes("mac"),i=e.includes("windows");return n&&t.mac?t.mac:i&&t.windows?t.windows:t.linux?t.linux:n?"metaKey":"ctrlKey"}isEdgeDeletionModifierKeyPressed(t){if(eo())return!1;return!!t[this.getEdgeDeletionModifierKey()]}onMarkerHoverForEdgeDeletion(t,e){const n=t.getElement();if(n)if(e){const e=t=>{if(this.isEdgeDeletionModifierKeyPressed(t)){n.style.backgroundColor=this.config.colors.edgeDeletion.hover,n.style.borderColor=this.config.colors.edgeDeletion.hover,n.classList.add("edge-deletion-hover");try{this.map.getContainer().style.cursor="pointer"}catch(e){}}else{n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(e){}}};e(new MouseEvent("mouseover")),this.markerModifierHandlers.set(t,e),document.addEventListener("keydown",e),document.addEventListener("keyup",e),n.addEventListener("mousemove",e)}else{n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(i){}const e=this.markerModifierHandlers.get(t);e&&(document.removeEventListener("keydown",e),document.removeEventListener("keyup",e),n.removeEventListener("mousemove",e),this.markerModifierHandlers.delete(t))}}getMarkerIndex(t,e){const n=no.getBounds(t,Math.sqrt(2)/2),i=new io(n.getSouth(),n.getWest(),n.getNorth(),n.getEast()).getDirection(e),r={lat:i.lat,lng:i.lng},o=this.turfHelper.getCoord(r),s=this.turfHelper.getFeaturePointCollection(t);return this.turfHelper.getNearestPointIndex(o,s)}ensureMarkerSeparation(t,e){const n=[];if(e.menu.enabled&&n.push({type:"menu",index:e.menu.index}),e.delete.enabled&&n.push({type:"delete",index:e.delete.index}),e.info.enabled&&n.push({type:"info",index:e.info.index}),n.length<2)return{menu:e.menu.index,delete:e.delete.index,info:e.info.index};const i={...e},r=new Set,o=["info","delete","menu"];for(const s of o){const e=i[s];if(e.enabled)if(r.has(e.index)){const n=this.findAlternativeMarkerPosition(t,e.index,r);i[s].index=n,r.add(n)}else r.add(e.index)}return{menu:i.menu.index,delete:i.delete.index,info:i.info.index}}findAlternativeMarkerPosition(t,e,n){const i=t,r=Math.max(1,Math.floor(t/8));for(let o=1;o<i;o++){const i=[(e+o*r)%t,(e-o*r+t)%t];for(const t of i)if(!n.has(t))return t}for(let o=0;o<t;o++)if(!n.has(o))return o;return e}createDivIcon(t){return po.createDivIcon(t)}getLatLngInfoString(t){return"Latitude: "+t.lat+" Longitude: "+t.lng}setMarkerVisibility(t,e){const n=this.getFeatureGroups().find(e=>e.hasLayer(t));n&&n.eachLayer(t=>{if(t instanceof s.Marker){const n=t.getElement();if(n){const t=this.config.dragPolygons.markerBehavior,i=this.config.dragPolygons.markerAnimationDuration;"hide"===t?n.style.display=e?"":"none":"fade"===t&&(n.style.transition=`opacity ${i}ms ease`,n.style.opacity=e?"1":"0")}}})}generateMenuMarkerPopup(t,e){const n=document.createElement("div");n.classList.add("alter-marker-outer-wrapper");const i=document.createElement("div");i.classList.add("alter-marker-wrapper");const r=document.createElement("div");r.classList.add("content");const o=document.createElement("div");o.classList.add("marker-menu-content");const a=document.createElement("div");a.classList.add("marker-menu-button","simplify"),a.title="Simplify";const l=document.createElement("div");l.classList.add("marker-menu-button","double-elbows"),l.title="DoubleElbows";const u=document.createElement("div");u.classList.add("marker-menu-button","bbox"),u.title="Bounding box";const h=document.createElement("div");h.classList.add("marker-menu-button","bezier"),h.title="Curve";const c=document.createElement("span");c.classList.add("alpha-banner"),c.textContent="ALPHA",h.appendChild(c);const f=document.createElement("div");f.classList.add("separator"),n.appendChild(i),i.appendChild(r),r.appendChild(o),o.appendChild(a),o.appendChild(f.cloneNode()),o.appendChild(l),o.appendChild(f.cloneNode()),o.appendChild(u),o.appendChild(f.cloneNode()),o.appendChild(h);const g=()=>{this._openMenuPopup&&(this.map.closePopup(this._openMenuPopup),this._openMenuPopup=null)};a.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"simplify",latLngs:t,featureGroup:e}),g()}),a.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"simplify",latLngs:t,featureGroup:e}),g()},u.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"bbox",latLngs:t,featureGroup:e}),g()}),u.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"bbox",latLngs:t,featureGroup:e}),g()},l.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"doubleElbows",latLngs:t,featureGroup:e}),g()}),l.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"doubleElbows",latLngs:t,featureGroup:e}),g()},h.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"bezier",latLngs:t,featureGroup:e}),g()}),h.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"bezier",latLngs:t,featureGroup:e}),g()},s.DomEvent.disableClickPropagation(n),n.style.pointerEvents="auto",n.querySelectorAll(".marker-menu-button").forEach(t=>{t.style.pointerEvents="auto",t.addEventListener("click",t=>t.stopPropagation())});const d=window.innerWidth<=600,p=s.popup({closeButton:!0,autoClose:!0,className:"menu-popup"+(d?" mobile-popup":"")}).setContent(n);return this._openMenuPopup=p,p}getPolygonGeoJSONFromFeatureGroup(t){try{const e=t.getLayers().find(t=>t instanceof s.Polygon);if(!e)throw new Error("No polygon found in feature group");return e.toGeoJSON()}catch(e){return e instanceof Error?console.warn("Error getting polygon GeoJSON from feature group:",e.message):console.warn("Error getting polygon GeoJSON from feature group:",e),{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}}getTotalPolygonPerimeter(t){try{if(!t||!t.geometry)return 0;let e=0;if("Polygon"===t.geometry.type){const n=t.geometry.coordinates;for(const t of n){const n={type:"Feature",geometry:{type:"Polygon",coordinates:[t]},properties:{}};e+=this.turfHelper.getPolygonPerimeter(n)}}else if("MultiPolygon"===t.geometry.type){const n=t.geometry.coordinates;for(const t of n)for(const n of t){const t={type:"Feature",geometry:{type:"Polygon",coordinates:[n]},properties:{}};e+=this.turfHelper.getPolygonPerimeter(t)}}return 1e3*e}catch(e){return e instanceof Error?console.warn("Error calculating total polygon perimeter:",e.message):console.warn("Error calculating total polygon perimeter:",e),1e3*this.turfHelper.getPolygonPerimeter(t)}}generateInfoMarkerPopup(t,e){const n=new ro(e,this.config),i=new oo(t,this.config),r=document.createElement("div");r.classList.add("info-marker-outer-wrapper");const o=document.createElement("div");o.classList.add("info-marker-wrapper");const a=document.createElement("div");a.classList.add("content");const l=document.createElement("div");l.classList.add("info-marker-content");const u=document.createElement("div");u.classList.add("info-item","area"),u.innerHTML=`<strong>Area:</strong> ${i.metricArea} ${i.metricUnit}`;const h=document.createElement("div");h.classList.add("info-item","perimeter"),h.innerHTML=`<strong>Perimeter:</strong> ${n.metricLength} ${n.metricUnit}`,l.appendChild(u),l.appendChild(h),a.appendChild(l),r.appendChild(o),o.appendChild(a),s.DomEvent.disableClickPropagation(r),r.style.pointerEvents="auto",r.querySelectorAll("button").forEach(t=>{t.style.pointerEvents="auto",t.addEventListener("click",t=>t.stopPropagation())});const c=window.innerWidth<=600;return s.popup({closeButton:!0,autoClose:!0,className:"info-popup"+(c?" mobile-popup":"")}).setContent(r)}}class vo{constructor(t){r(this,"turfHelper"),r(this,"map"),r(this,"config"),r(this,"eventManager"),r(this,"getFeatureGroups"),r(this,"geometryManager"),r(this,"interactionManager"),this.turfHelper=t.turfHelper,this.map=t.map,this.config=t.config,this.eventManager=t.eventManager,this.getFeatureGroups=t.getFeatureGroups,this.initializeSpecializedManagers(t)}initializeSpecializedManagers(t){this.geometryManager=new go({turfHelper:t.turfHelper,config:t.config}),this.interactionManager=new yo({turfHelper:t.turfHelper,polygonInformation:t.polygonInformation,map:t.map,config:t.config,modeManager:t.modeManager,eventManager:this.eventManager},{getFeatureGroups:this.getFeatureGroups,addFeatureGroup:t=>this.addFeatureGroupInternal(t),removeFeatureGroup:t=>this.removeFeatureGroupInternal(t)}),this.setupEventForwarding()}setupEventForwarding(){this.eventManager.on("polydraw:draw:cancel",t=>{this.emit("drawCancelled",t)}),this.eventManager.on("polydraw:polygon:updated",t=>{this.handlePolygonModified(t)}),this.eventManager.on("polydraw:menu:action",t=>{this.handleMenuAction(t)}),this.eventManager.on("polydraw:check:intersection",t=>{const e=this.geometryManager.checkPolygonIntersection(t.polygon1,t.polygon2);t.callback(e)}),this.eventManager.on("polydraw:subtract",t=>{this.subtractPolygon(t.subtractPolygon)}),this.eventManager.on("polydraw:polygon:deleted",()=>{this.emit("polygonDeleted",void 0)})}async handlePolygonModified(t){const e={simplify:"addVertex"!==t.operation&&"markerDrag"!==t.operation&&"polygonDrag"!==t.operation,noMerge:!t.allowMerge,visualOptimizationLevel:t.optimizationLevel||0};await this.addPolygon(t.polygon,e)}async handleMenuAction(t){const e=this.getCompletePolygonFromFeatureGroup(t.featureGroup);let n;switch(this.removeFeatureGroupInternal(t.featureGroup),t.action){case"simplify":n=this.geometryManager.simplifyPolygon(e);break;case"bbox":n=this.geometryManager.convertToBoundingBox(e);break;case"doubleElbows":n=this.geometryManager.doubleElbowsPolygon(e);break;case"bezier":n=this.geometryManager.bezierifyPolygon(e);break;default:return}n.success&&n.result&&await this.addPolygon(n.result,{simplify:!1})}get polygonInteractionManager(){return this.interactionManager}on(t,e){this.eventManager.on(t,e)}emit(t,e){this.eventManager.emit(t,e)}async addPolygon(t,e={}){const{noMerge:n=!1}=e;try{return this.config.mergePolygons&&!n&&this.getFeatureGroups().length>0&&!this.config.kinks?await this.mergePolygon(t,e):await this.addPolygonLayer(t,e)}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in addPolygon"}}}async subtractPolygon(t){try{const n=[];this.getFeatureGroups().forEach(e=>{try{const i=e.toGeoJSON();if(!i||!i.features||!i.features[0])return;const r=i.features[0];if(!r.geometry||!r.geometry.coordinates)return;const o=this.turfHelper.getTurfPolygon(r);this.geometryManager.checkPolygonIntersection(o,t)&&n.push(e)}catch(i){}});const i=[];for(const r of n)try{const e=r.toGeoJSON(),n=this.turfHelper.getTurfPolygon(e.features[0]),o=this.geometryManager.subtractPolygon(n,t);if(this.removeFeatureGroupInternal(r),o.success&&o.results)for(const t of o.results){const e=await this.addPolygonLayer(t,{simplify:!0});e.success&&e.featureGroups&&i.push(...e.featureGroups)}}catch(e){}return this.emit("polygonSubtracted",{subtractedPolygon:t,affectedFeatureGroups:n,resultFeatureGroups:i}),this.emit("polygonOperationComplete",{operation:"subtract",polygon:t,resultFeatureGroups:i}),{success:!0,featureGroups:i}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error in subtractPolygon"}}}async addPolygonLayer(t,e={}){const{simplify:n=!0,dynamicTolerance:i=!1,visualOptimizationLevel:r=0}=e;try{if(!t||!t.geometry||!t.geometry.coordinates)return{success:!1,error:"Invalid polygon data"};const e=new s.FeatureGroup,a=n?this.turfHelper.getSimplified(t,i):t;let l,u;try{if(l=this.getPolygon(a),!l)return{success:!1,error:"Failed to create polygon"};l._polydrawOptimizationLevel=r,e.addLayer(l)}catch(o){return{success:!1,error:"Failed to create polygon layer"}}try{const t=l.getLatLngs();u=Array.isArray(t)&&t.length>0?Array.isArray(t[0])?Array.isArray(t[0][0])?t[0]:t:[t]:[]}catch(o){u=[]}try{u.forEach((t,n)=>{if(!t||!Array.isArray(t))return;const i=[];if(t.forEach(t=>{Array.isArray(t)&&t.length>=2?i.push({lat:t[1],lng:t[0]}):"object"==typeof t&&null!==t&&"lat"in t&&"lng"in t&&i.push(t)}),0!==i.length)try{if(0===n)this.interactionManager.addMarkers(i,e);else{const n=s.polyline(t,{color:this.config.colors.hole.border,weight:this.config.holeOptions.weight||2,opacity:this.config.holeOptions.opacity||1,fillColor:this.config.colors.hole.fill,fillOpacity:this.config.holeOptions.fillOpacity||.5});e.addLayer(n),this.interactionManager.addHoleMarkers(i,e)}}catch(r){}})}catch(o){}try{this.interactionManager.addEdgeClickListeners(l,e)}catch(o){}this.getFeatureGroups().push(e);try{e.addTo(this.map)}catch(o){}return this.emit("polygonAdded",{polygon:a,featureGroup:e}),this.emit("polygonOperationComplete",{operation:"add",polygon:a,featureGroup:e}),{success:!0,featureGroups:[e]}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error in addPolygonLayer"}}}async mergePolygon(t,e={}){try{const n=[],i=[];let r=!1;return this.getFeatureGroups().forEach(e=>{try{const s=e.toGeoJSON();if(!s||!s.features||!s.features[0])return;const a=s.features[0];if(!a.geometry||!a.geometry.coordinates)return;if(this.isPositionArrayofArrays(a.geometry.coordinates))a.geometry.coordinates.forEach(o=>{try{const s=this.turfHelper.getMultiPolygon([o]);r=this.geometryManager.checkPolygonIntersection(s,t),r&&(i.push(e),n.push(s))}catch(s){}});else try{const o=this.turfHelper.getTurfPolygon(a);r=this.geometryManager.checkPolygonIntersection(o,t),r&&(i.push(e),n.push(o))}catch(o){}}catch(o){}}),i.length>0?await this.unionPolygons(i,t,n,e):await this.addPolygonLayer(t,e)}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in mergePolygon"}}}async unionPolygons(t,e,n,i={}){try{t.forEach(t=>{this.removeFeatureGroupInternal(t)});const r=this.geometryManager.unionPolygons(n,e);if(r.success&&r.result){const t=await this.addPolygonLayer(r.result,i);return this.emit("polygonsUnioned",{originalPolygons:n,resultPolygon:r.result,featureGroups:t.featureGroups}),t}return{success:!1,error:r.error||"Failed to union polygons"}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Unknown error in unionPolygons"}}}isPositionArrayofArrays(t){if(!Array.isArray(t)||0===t.length)return!1;const e=t[0];if(!Array.isArray(e)||0===e.length)return!1;const n=e[0];if(!Array.isArray(n)||0===n.length)return!1;const i=n[0];return this.isPosition(i)}isPosition(t){return Array.isArray(t)&&t.length>=2&&t.every(t=>"number"==typeof t)}getPolygon(t){const e=s.GeoJSON.geometryToLayer(t);return e.setStyle({...this.config.polygonOptions,color:this.config.colors.polygon.border,fillColor:this.config.colors.polygon.fill}),e._polydrawUniqueId=s.Util.stamp(e)+"_"+Date.now(),delete e._polydrawDragData,delete e._polydrawOriginalLatLngs,delete e._polydrawCurrentDragSession,delete e._polydrawOriginalMarkerPositions,delete e._polydrawOriginalHoleLinePositions,this.config.modes.dragPolygons&&this.interactionManager.enablePolygonDragging(e,t),e}addFeatureGroupInternal(t){this.getFeatureGroups().push(t)}removeFeatureGroupInternal(t){t.clearLayers();const e=this.getFeatureGroups(),n=e.indexOf(t);n>-1&&e.splice(n,1),this.map.removeLayer(t)}getCompletePolygonFromFeatureGroup(t){try{let e=null;if(t.eachLayer(t=>{t instanceof s.Polygon&&(e=t)}),!e)throw new Error("No polygon found in feature group");return e.toGeoJSON()}catch(e){return e instanceof Error&&console.warn("Error getting complete polygon GeoJSON from feature group:",e.message),{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}}updateMarkerDraggableState(){this.interactionManager.updateMarkerDraggableState()}updateAllMarkersForEdgeDeletion(t){this.interactionManager.updateAllMarkersForEdgeDeletion(t)}setModifierKeyHeld(t){this.interactionManager.setModifierKeyHeld(t)}checkPolygonIntersection(t,e){return this.geometryManager.checkPolygonIntersection(t,e)}getPolygonCenter(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return null;let e;if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{if("MultiPolygon"!==t.geometry.type)return null;e=t.geometry.coordinates[0][0]}if(!Array.isArray(e)||0===e.length)return null;let n=0,i=0,r=0;for(const t of e)if(Array.isArray(t)&&t.length>=2){const e=t[0],o=t[1];"number"!=typeof e||"number"!=typeof o||isNaN(e)||isNaN(o)||(i+=e,n+=o,r++)}return 0===r?null:{lat:n/r,lng:i/r}}catch(e){return null}}getBoundingBox(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return null;let e;if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{if("MultiPolygon"!==t.geometry.type)return null;e=t.geometry.coordinates[0][0]}if(!Array.isArray(e)||0===e.length)return null;let n=1/0,i=-1/0,r=1/0,o=-1/0;for(const t of e)if(Array.isArray(t)&&t.length>=2){const e=t[0],s=t[1];"number"!=typeof e||"number"!=typeof s||isNaN(e)||isNaN(s)||(r=Math.min(r,e),o=Math.max(o,e),n=Math.min(n,s),i=Math.max(i,s))}return n===1/0||i===-1/0||r===1/0||o===-1/0?null:{minLat:n,maxLat:i,minLng:r,maxLng:o}}catch(e){return null}}addMarker(t,e){this.interactionManager.addMarkers(t,e)}addHoleMarker(t,e){this.interactionManager.addHoleMarkers(t,e)}addEdgeClickListeners(t,e){this.interactionManager.addEdgeClickListeners(t,e)}enablePolygonDragging(t,e){this.interactionManager.enablePolygonDragging(t,e)}getMarkerIndex(t,e){return 0}ensureMarkerSeparation(t,e){var n,i,r;return{menu:(null==(n=e.menu)?void 0:n.index)??0,delete:(null==(i=e.delete)?void 0:i.index)??1,info:(null==(r=e.info)?void 0:r.index)??2}}findAlternativeMarkerPosition(t,e,n){return(e+1)%t}createDivIcon(t){return s.divIcon({className:t.join(" ")})}getLatLngInfoString(t){return"Latitude: "+t.lat+" Longitude: "+t.lng}generateMenuMarkerPopup(t,e){const n=document.createElement("div");return n.innerHTML="Menu",n}getPolygonGeoJSONFromFeatureGroup(t){return{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}getTotalPolygonPerimeter(t){return 1e3}generateInfoMarkerPopup(t,e){const n=document.createElement("div");return n.innerHTML=`Area: ${t}, Perimeter: ${e}`,n}onMarkerHoverForEdgeDeletion(t,e){}highlightEdgeOnHover(t,e){}onEdgeClick(t,e){}removeFeatureGroup(t){this.removeFeatureGroupInternal(t)}onPolygonMouseMove(t){}onPolygonMouseUp(t){}updatePolygonAfterDrag(t){}setSubtractVisualMode(t,e){}performModifierSubtract(t,e){try{const n=this.turfHelper.getTurfPolygon(t),i=[];this.getFeatureGroups().forEach(t=>{if(t!==e)try{const e=t.toGeoJSON();if(!e||!e.features||!e.features[0])return;const r=e.features[0];if(!r.geometry||!r.geometry.coordinates)return;const o=this.turfHelper.getTurfPolygon(r);this.geometryManager.checkPolygonIntersection(o,n)&&i.push(t)}catch(r){}}),this.removeFeatureGroupInternal(e),i.forEach(t=>{try{const e=t.toGeoJSON(),i=this.turfHelper.getTurfPolygon(e.features[0]);this.removeFeatureGroupInternal(t);const r=this.geometryManager.subtractPolygon(i,n);if(r.success&&r.results)for(const t of r.results)this.addPolygonLayer(t,{simplify:!0})}catch(e){}})}catch(n){}}}class mo extends s.Control{constructor(t){super(t),r(this,"map"),r(this,"tracer"),r(this,"turfHelper"),r(this,"subContainer"),r(this,"config"),r(this,"mapStateService"),r(this,"eventManager"),r(this,"polygonInformation"),r(this,"modeManager"),r(this,"polygonDrawManager"),r(this,"polygonMutationManager"),r(this,"arrayOfFeatureGroups",[]),r(this,"drawMode",l.Off),r(this,"drawModeListeners",[]),r(this,"_boundKeyDownHandler"),r(this,"_boundKeyUpHandler"),r(this,"isModifierKeyHeld",!1),r(this,"_boundTouchMove"),r(this,"_boundTouchEnd"),r(this,"_boundTouchStart"),r(this,"_handleActivateToggle",()=>{const t=this.getContainer();if(!t)return;const e=t.querySelector(".icon-activate");s.DomUtil.hasClass(e,"active")?(s.DomUtil.removeClass(e,"active"),this.subContainer&&(this.subContainer.style.maxHeight="0px")):(s.DomUtil.addClass(e,"active"),this.subContainer&&(this.subContainer.style.maxHeight="250px")),this.updateActivateButtonIndicator()}),r(this,"_handleDrawClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.Add?(this.setDrawMode(l.Add),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"_handleSubtractClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.Subtract?(this.setDrawMode(l.Subtract),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"_handleEraseClick",t=>{this.map.closePopup(),t&&(t.preventDefault(),t.stopPropagation()),0!==this.arrayOfFeatureGroups.length&&this.removeAllFeatureGroups()}),r(this,"_handlePointToPointClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.PointToPoint?(this.setDrawMode(l.PointToPoint),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"onMarkerHoverForEdgeDeletionEvent",t=>{if(!this.isModifierKeyHeld)return;const e=t.target;e&&(e.style.backgroundColor=this.config.colors.edgeDeletion.hover,e.style.borderColor=this.config.colors.edgeDeletion.hover,e.classList.add("edge-deletion-hover"))}),r(this,"onMarkerLeaveForEdgeDeletionEvent",t=>{const e=t.target;e&&(e.style.backgroundColor="",e.style.borderColor="",e.classList.remove("edge-deletion-hover"))}),this.config=a,(null==t?void 0:t.configPath)?this.loadExternalConfig(t.configPath,null==t?void 0:t.config):(this.config={...a,...(null==t?void 0:t.config)||{}},this.initializeComponents())}onAdd(t){const e=t,n=s.Browser;e._onResize=()=>{},n.touch&&n.mobile&&(e.tap=!1),this.map=t,this.setupKeyboardHandlers();const i=s.DomUtil.create("div","leaflet-control leaflet-bar");return this.initializeUI(i),this.createTracer(),this.initializeManagers(),this.setupEventListeners(),i}onRemove(t){this.removeKeyboardHandlers(),this.tracer&&this.map.removeLayer(this.tracer),this.removeAllFeatureGroups()}addTo(t){return super.addTo(t),this}getFeatureGroups(){return this.arrayOfFeatureGroups}async addPredefinedPolygon(t,e){if(!t||0===t.length)throw new Error("Cannot add empty polygon array");if(!this.map)throw new Error("Map not initialized");if(!this.polygonMutationManager)throw new Error("PolygonMutationManager not initialized");const n=(null==e?void 0:e.visualOptimizationLevel)??0;for(const[r,o]of t.entries()){if(!o||!o[0]||o[0].length<4)throw new Error(`Invalid polygon data at index ${r}: A polygon must have at least 3 unique vertices.`);try{const t=o.map(t=>t.map(t=>[t.lng,t.lat])),e=this.turfHelper.getMultiPolygon([t]),i=await this.polygonMutationManager.addPolygon(e,{simplify:!1,noMerge:!1,visualOptimizationLevel:n});if(!i.success)throw console.error("Error adding polygon via manager:",i.error),new Error(i.error||"Failed to add polygon");this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}catch(i){throw console.error("Error adding auto polygon:",i),i}}}setDrawMode(t){const e=this.drawMode;this._updateDrawModeState(t),e===l.PointToPoint&&t!==l.PointToPoint?(this.polygonDrawManager.clearP2pMarkers(),this.stopDraw()):(t===l.Off||t!==l.PointToPoint)&&this.stopDraw(),this.map&&(this._updateUIAfterDrawModeChange(t),this._updateMapInteractions())}getDrawMode(){return this.modeManager.getCurrentMode()}on(t,e){this.eventManager.on(t,e)}off(t,e){this.eventManager.off(t,e)}removeAllFeatureGroups(){this.arrayOfFeatureGroups.forEach(t=>{try{this.map.removeLayer(t)}catch(e){}}),this.arrayOfFeatureGroups.length=0,this.polygonInformation.deletePolygonInformationStorage(),this.polygonInformation.updatePolygons(),this.updateActivateButtonIndicator()}initializeUI(t){!function(t){const e=document.createElement("style");e.innerHTML=`\n .leaflet-control a { background-color: ${t.colors.styles.controlButton.backgroundColor}; color: ${t.colors.styles.controlButton.color}; display: flex; align-items: center; justify-content: center; }\n .leaflet-control a:hover { background-color: ${t.colors.styles.controlButtonHover.backgroundColor}; }\n .leaflet-control a.active { background-color: ${t.colors.styles.controlButtonActive.backgroundColor}; color: ${t.colors.styles.controlButtonActive.color}; }\n .polydraw-indicator-active { background-color: ${t.colors.styles.indicatorActive.backgroundColor} !important; }\n .crosshair-cursor-enabled { cursor: crosshair !important; }\n .crosshair-cursor-enabled * { cursor: crosshair !important; }\n .leaflet-polydraw-p2p-marker { background-color: ${t.colors.styles.p2pMarker.backgroundColor}; border: 2px solid ${t.colors.styles.p2pMarker.borderColor}; border-radius: 50%; box-sizing: border-box; }\n .leaflet-polydraw-p2p-first-marker { position: relative; }\n .leaflet-polydraw-p2p-first-marker:hover { transform: scale(1.5); transition: all 0.2s ease; }\n `,document.head.appendChild(e)}(this.config),s.DomEvent.disableClickPropagation(t),s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stopPropagation),t.style.display="flex",t.style.flexDirection="column-reverse",this.subContainer=s.DomUtil.create("div","sub-buttons",t),this.subContainer.style.maxHeight="0px",this.subContainer.style.overflow="hidden",this.subContainer.style.transition="max-height 0.3s ease",function(t,e,n,i,r,o,a,l){const u=s.DomUtil.create("a","icon-activate",t);if(u.href="#",u.title="Activate",u.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(u,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(u,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(u,"click",s.DomEvent.stop).on(u,"click",i),n.modes.draw){const t=s.DomUtil.create("a","icon-draw",e);t.href="#",t.title="Draw",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M15 7.49996L17.5 9.99996M7.5 20L19.25 8.24996C19.9404 7.5596 19.9404 6.44032 19.25 5.74996V5.74996C18.5596 5.0596 17.4404 5.05961 16.75 5.74996L5 17.5V20H7.5ZM7.5 20H15.8787C17.0503 20 18 19.0502 18 17.8786V17.8786C18 17.316 17.7765 16.7765 17.3787 16.3786L17 16M4.5 4.99996C6.5 2.99996 10 3.99996 10 5.99996C10 8.5 4 8.5 4 11C4 11.8759 4.53314 12.5256 5.22583 13" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",r)}if(n.modes.subtract){const t=s.DomUtil.create("a","icon-subtract",e);t.href="#",t.title="Subtract",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M15.0722 3.9967L20.7508 9.83395L17.0544 13.5304L13.0758 17.5H21.0041V19H7.93503L4.00195 15.0669L15.0722 3.9967ZM10.952 17.5L15.4628 12.9994L11.8268 9.3634L6.12327 15.0669L8.55635 17.5H10.952Z" fill="#1F2328"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",o)}if(n.modes.p2p&&!eo()){const t=s.DomUtil.create("a","icon-p2p",e);t.href="#",t.title="Point to Point",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",l)}if(n.modes.deleteAll){const t=s.DomUtil.create("a","icon-erase",e);t.href="#",t.title="Erase All",t.innerHTML='<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) --\x3e\n<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">\n<style type="text/css">\n\t.st0{fill:#000000}\n\t.st1{fill:#333333;fill-opacity:0;}\n</style>\n<title>trash</title>\n<rect class="st1" width="48" height="48"/>\n<polygon class="st0" points="26.6,10 26.6,7.8 21.4,7.8 21.4,10 12.6,10 12.6,12.8 35.4,12.8 35.4,10 "/>\n<path class="st0" d="M35.4,15.4H12.6v4.3h1.8V37c0,1.1,0.9,2,2,2h15.2c1.1,0,2-0.9,2-2V19.7h1.8V15.4z M19.7,34.2c0,0.5-0.4,1-1,1\n\tc-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1V34.2z M25.3,33.8c0,0.7-0.6,1.3-1.3,1.3c-0.7,0-1.3-0.6-1.3-1.3V23\n\tc0-0.7,0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3V33.8z M30.3,34.2c0,0.5-0.4,1-1,1c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1\n\tc0.5,0,1,0.4,1,1V34.2z"/>\n</svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",a)}}(t,this.subContainer,this.config,this._handleActivateToggle,this._handleDrawClick,this._handleSubtractClick,this._handleEraseClick,this._handlePointToPointClick);this.drawModeListeners.push(e=>{const n=t.querySelector(".icon-draw"),i=t.querySelector(".icon-subtract");n&&n.classList.toggle("active",e===l.Add),i&&i.classList.toggle("active",e===l.Subtract)})}setupEventListeners(){this.polygonMutationManager.on("polygonOperationComplete",()=>{this.updateActivateButtonIndicator(),this.modeManager.updateStateForMode(l.Off),this.drawMode=l.Off,this.emitDrawModeChanged(),this.updateMarkerDraggableState();const t=this.modeManager.shouldShowCrosshairCursor(),e=this.modeManager.canPerformAction("mapDrag"),n=this.modeManager.canPerformAction("mapZoom"),i=this.modeManager.canPerformAction("mapDoubleClickZoom");t?s.DomUtil.addClass(this.map.getContainer(),"crosshair-cursor-enabled"):s.DomUtil.removeClass(this.map.getContainer(),"crosshair-cursor-enabled"),this.events(!1),this.setLeafletMapEvents(e,i,n);try{this.tracer.setStyle({color:""})}catch(r){}}),this.polygonMutationManager.on("polygonDeleted",()=>{this.updateActivateButtonIndicator()}),this.eventManager.on("polydraw:polygon:created",async t=>{this.stopDraw(),t.isPointToPoint?await this.polygonMutationManager.addPolygon(t.polygon,{simplify:!1,noMerge:!1}):await this.handleFreehandDrawCompletion(t.polygon),this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}),this.eventManager.on("polydraw:draw:cancel",()=>{this.stopDraw(),this.setDrawMode(l.Off)})}createTracer(){this.tracer=s.polyline([],{...this.config.polyLineOptions,color:this.config.colors.polyline});try{this.tracer.addTo(this.map)}catch(t){}}initializeManagers(){this.polygonDrawManager=new fo({turfHelper:this.turfHelper,map:this.map,config:this.config,modeManager:this.modeManager,eventManager:this.eventManager,tracer:this.tracer}),this.polygonMutationManager=new vo({turfHelper:this.turfHelper,polygonInformation:this.polygonInformation,map:this.map,config:this.config,modeManager:this.modeManager,eventManager:this.eventManager,getFeatureGroups:()=>this.arrayOfFeatureGroups})}async loadExternalConfig(t,e){try{const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load config from ${t}: ${n.status} ${n.statusText}`);const i=await n.json();this.config={...a,...i,...e||{}},this.initializeComponents()}catch(n){console.warn("Failed to load external config, falling back to default + inline config:",n),this.config={...a,...e||{}},this.initializeComponents()}}_updateDrawModeState(t){this.drawMode=t,this.modeManager.updateStateForMode(t),this.emitDrawModeChanged(),this.updateMarkerDraggableState()}_updateUIAfterDrawModeChange(t){this.modeManager.shouldShowCrosshairCursor()?s.DomUtil.addClass(this.map.getContainer(),"crosshair-cursor-enabled"):s.DomUtil.removeClass(this.map.getContainer(),"crosshair-cursor-enabled");try{switch(t){case l.Off:this.tracer.setStyle({color:""});break;case l.Add:this.tracer.setStyle({color:this.config.colors.polyline,dashArray:void 0});break;case l.Subtract:this.tracer.setStyle({color:this.config.colors.subtractLine,dashArray:void 0});break;case l.PointToPoint:this.tracer.setStyle({color:this.config.colors.polyline,dashArray:"5, 5"})}}catch(e){}}_updateMapInteractions(){const t=this.modeManager.canPerformAction("mapDrag"),e=this.modeManager.canPerformAction("mapZoom"),n=this.modeManager.canPerformAction("mapDoubleClickZoom");this.events(this.drawMode!==l.Off),this.setLeafletMapEvents(t,n,e)}initializeComponents(){this.turfHelper=new to(this.config),this.mapStateService=new uo,this.eventManager=new ho,this.polygonInformation=new lo(this.mapStateService),this.modeManager=new co(this.config,this.eventManager),this.polygonInformation.onPolygonInfoUpdated(t=>{this.updateActivateButtonIndicator()}),this._boundKeyDownHandler=this.handleKeyDown.bind(this)}emitDrawModeChanged(){this.eventManager.emit("polydraw:mode:change",{mode:this.modeManager.getCurrentMode()});for(const t of this.drawModeListeners)t(this.modeManager.getCurrentMode())}updateMarkerDraggableState(){const t=this.modeManager.canPerformAction("markerDrag");this.arrayOfFeatureGroups.forEach(e=>{e.eachLayer(e=>{if(e instanceof s.Marker){const i=e;try{i.options.draggable=t,i.dragging&&(t?i.dragging.enable():i.dragging.disable())}catch(n){}}})})}stopDraw(){this.resetTracker(),this.drawStartedEvents(!1)}setLeafletMapEvents(t,e,n){t?this.map.dragging.enable():this.map.dragging.disable(),e?this.map.doubleClickZoom.enable():this.map.doubleClickZoom.disable(),n?this.map.scrollWheelZoom.enable():this.map.scrollWheelZoom.disable()}resetTracker(){this.tracer.setLatLngs([])}drawStartedEvents(t){const e=t?"on":"off";this.map[e]("mousemove",this.mouseMove,this),this.map[e]("mouseup",this.mouseUpLeave,this),t?(this._boundTouchMove=t=>this.mouseMove(t),this._boundTouchEnd=t=>this.mouseUpLeave(t),this.map.getContainer().addEventListener("touchmove",this._boundTouchMove,{passive:!1}),this.map.getContainer().addEventListener("touchend",this._boundTouchEnd,{passive:!1})):(this._boundTouchMove&&this.map.getContainer().removeEventListener("touchmove",this._boundTouchMove),this._boundTouchEnd&&this.map.getContainer().removeEventListener("touchend",this._boundTouchEnd))}events(t){const e=t?"on":"off";this.map[e]("mousedown",this.mouseDown,this),this.map[e]("dblclick",this.handleDoubleClick,this),t?(this._boundTouchStart=t=>this.mouseDown(t),this.map.getContainer().addEventListener("touchstart",this._boundTouchStart,{passive:!1})):this._boundTouchStart&&this.map.getContainer().removeEventListener("touchstart",this._boundTouchStart)}mouseDown(t){if("cancelable"in t&&t.cancelable&&t.preventDefault(),this.modeManager.isInOffMode())return;let e;"latlng"in t&&t.latlng?e=t.latlng:"touches"in t&&t.touches&&t.touches.length>0&&(e=this.map.containerPointToLatLng([t.touches[0].clientX,t.touches[0].clientY])),e&&(this.modeManager.getCurrentMode()!==l.PointToPoint?(this.tracer.setLatLngs([e]),this.startDraw()):this.polygonDrawManager.handlePointToPointClick(e))}mouseMove(t){if("cancelable"in t&&t.cancelable&&t.preventDefault(),"latlng"in t&&t.latlng)this.tracer.addLatLng(t.latlng);else if("touches"in t&&t.touches&&t.touches.length>0){const e=this.map.containerPointToLatLng([t.touches[0].clientX,t.touches[0].clientY]);this.tracer.addLatLng(e)}}async mouseUpLeave(t){"cancelable"in t&&t.cancelable&&t.preventDefault(),this.polygonInformation.deletePolygonInformationStorage();const e=this.tracer.toGeoJSON();if(!e||!e.geometry||!e.geometry.coordinates||e.geometry.coordinates.length<3)return void this.stopDraw();let n;try{n=this.turfHelper.createPolygonFromTrace(e)}catch(i){return void this.stopDraw()}if(n&&n.geometry&&n.geometry.coordinates&&0!==n.geometry.coordinates.length){this.stopDraw();try{switch(this.modeManager.getCurrentMode()){case l.Add:{const t=await this.polygonMutationManager.addPolygon(n,{simplify:!0,noMerge:!1});t.success||console.error("Error adding polygon via manager:",t.error);break}case l.Subtract:{const t=await this.polygonMutationManager.subtractPolygon(n);t.success||console.error("Error subtracting polygon via manager:",t.error);break}}}catch(i){console.error("Error in mouseUpLeave polygon operation:",i)}this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}else this.stopDraw()}async handleFreehandDrawCompletion(t){try{switch(this.modeManager.getCurrentMode()){case l.Add:{const e=await this.polygonMutationManager.addPolygon(t,{simplify:!0,noMerge:!1});e.success||console.error("Error adding polygon via manager:",e.error);break}case l.Subtract:{const e=await this.polygonMutationManager.subtractPolygon(t);e.success||console.error("Error subtracting polygon via manager:",e.error);break}}}catch(e){console.error("Error in mouseUpLeave polygon operation:",e)}}startDraw(){this.drawStartedEvents(!0)}setupKeyboardHandlers(){this._boundKeyUpHandler=this.handleKeyUp.bind(this),document.addEventListener("keydown",this._boundKeyDownHandler),document.addEventListener("keyup",this._boundKeyUpHandler)}removeKeyboardHandlers(){document.removeEventListener("keydown",this._boundKeyDownHandler),document.removeEventListener("keyup",this._boundKeyUpHandler)}handleKeyDown(t){"Escape"===t.key&&this.modeManager.getCurrentMode()===l.PointToPoint&&this.polygonDrawManager.cancelPointToPointDrawing();this.isModifierKeyPressed(t)&&!this.isModifierKeyHeld&&(this.isModifierKeyHeld=!0,this.polygonDrawManager.setModifierKey(!0),this.updateAllMarkersForEdgeDeletion(!0))}handleKeyUp(t){!this.isModifierKeyPressed(t)&&this.isModifierKeyHeld&&(this.isModifierKeyHeld=!1,this.polygonDrawManager.setModifierKey(!1),this.updateAllMarkersForEdgeDeletion(!1))}updateAllMarkersForEdgeDeletion(t){this.arrayOfFeatureGroups.forEach(e=>{e.eachLayer(e=>{e instanceof s.Marker&&this.updateMarkerForEdgeDeletion(e,t)})})}updateMarkerForEdgeDeletion(t,e){const n=t.getElement();n&&(e?(n.addEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.addEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent)):(n.removeEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.removeEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent),n.style.backgroundColor="",n.style.borderColor=""))}handleDoubleClick(t){this.modeManager.getCurrentMode()===l.PointToPoint&&this.polygonDrawManager.handleDoubleClick(t)}isModifierKeyPressed(t){return navigator.userAgent.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey}updateActivateButtonIndicator(){if("function"!=typeof this.getContainer)return;const t=this.getContainer();if(!t)return;const e=t.querySelector(".icon-activate");if(!e)return;const n=this.arrayOfFeatureGroups.length>0,i=!s.DomUtil.hasClass(e,"active");n&&i?s.DomUtil.addClass(e,"polydraw-indicator-active"):s.DomUtil.removeClass(e,"polydraw-indicator-active")}}return s.control.polydraw=function(t){return new mo(t)},mo});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).LeafletPolydraw=e(t.L)}(this,function(t){"use strict";var e,n,i=Object.defineProperty,r=(t,e,n)=>((t,e,n)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);function o(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}return e.default=t,Object.freeze(e)}const s=o(t),a={mergePolygons:!0,kinks:!1,modes:{draw:!0,subtract:!0,deleteAll:!0,p2p:!0,attachElbow:!0,dragElbow:!0,dragPolygons:!0,edgeDeletion:!0},dragPolygons:{opacity:.7,dragCursor:"move",hoverCursor:"grab",markerBehavior:"hide",markerAnimationDuration:200,modifierSubtract:{keys:{windows:"ctrlKey",mac:"metaKey",linux:"ctrlKey"},hideMarkersOnDrag:!0}},edgeDeletion:{keys:{windows:"ctrlKey",mac:"metaKey",linux:"ctrlKey"},minVertices:3},markers:{deleteMarker:!0,infoMarker:!0,menuMarker:!0,coordsTitle:!0,zIndexOffset:0,markerIcon:{styleClasses:["polygon-marker"],zIndexOffset:null},holeIcon:{styleClasses:["polygon-marker","hole"],zIndexOffset:null},markerInfoIcon:{position:3,showArea:!0,showPerimeter:!0,useMetrics:!0,usePerimeterMinValue:!1,areaLabel:"Area",perimeterLabel:"Perimeter",values:{min:{metric:"50",imperial:"100"},unknown:{metric:"-",imperial:"-"}},units:{unknownUnit:"",metric:{onlyMetrics:!0,perimeter:{m:"m",km:"km"},area:{m2:"m²",km2:"km²",daa:"daa",ha:"ha"}},imperial:{perimeter:{feet:"ft",yards:"yd",miles:"mi"},area:{feet2:"ft²",yards2:"yd²",acres:"ac",miles2:"mi²"}}},styleClasses:["polygon-marker","info"],zIndexOffset:1e4},markerMenuIcon:{position:7,styleClasses:["polygon-marker","menu"],zIndexOffset:1e4},markerDeleteIcon:{position:5,styleClasses:["polygon-marker","delete"],zIndexOffset:1e4},holeMarkers:{menuMarker:!1,deleteMarker:!0,infoMarker:!1},visualOptimization:{sharpAngleThreshold:30,thresholdBoundingBox:.05,thresholdDistance:.05,useDistance:!0,useBoundingBox:!1,useAngles:!1}},polyLineOptions:{opacity:1,smoothFactor:0,noClip:!0,clickable:!1,weight:2},subtractLineOptions:{opacity:1,smoothFactor:0,noClip:!0,clickable:!1,weight:2},polygonOptions:{smoothFactor:.3,noClip:!0},holeOptions:{weight:2,opacity:1,fillOpacity:.5},polygonCreation:{method:"concaveman",simplification:{mode:"simple",tolerance:1e-5,highQuality:!1}},simplification:{simplifyTolerance:{tolerance:1e-4,highQuality:!1,mutate:!1},dynamicMode:{fractionGuard:.9,multiplier:2}},menuOperations:{simplify:{processHoles:!0},doubleElbows:{processHoles:!0},bbox:{processHoles:!0}},boundingBox:{addMidPointMarkers:!0},bezier:{resolution:1e4,sharpness:.75},colors:{dragPolygons:{subtract:"#D9460F"},p2p:{closingMarker:"#4CAF50"},edgeHover:"#7a9441",edgeDeletion:{hover:"#D9460F"},polyline:"#50622b",subtractLine:"#D9460F",polygon:{border:"#50622b",fill:"#b4cd8a"},hole:{border:"#aa0000",fill:"#ffcccc"},styles:{controlButton:{backgroundColor:"#fff",color:"#000"},controlButtonHover:{backgroundColor:"#f4f4f4"},controlButtonActive:{backgroundColor:"rgb(128, 218, 255)",color:"#fff"},indicatorActive:{backgroundColor:"#ffcc00"},p2pMarker:{backgroundColor:"#fff",borderColor:"#50622b"}}}};var l=(t=>(t[t.Off=0]="Off",t[t.Add=1]="Add",t[t.Edit=2]="Edit",t[t.Subtract=4]="Subtract",t[t.AppendMarker=8]="AppendMarker",t[t.LoadPredefined=16]="LoadPredefined",t[t.PointToPoint=32]="PointToPoint",t))(l||{}),u=(t=>(t[t.SouthWest=0]="SouthWest",t[t.South=1]="South",t[t.SouthEast=2]="SouthEast",t[t.East=3]="East",t[t.NorthEast=4]="NorthEast",t[t.North=5]="North",t[t.NorthWest=6]="NorthWest",t[t.West=7]="West",t[t.Hole=8]="Hole",t))(u||{});const h=6371e3,c=6371,f=3959,g=Math.PI/180,d=180/Math.PI;function p(t,e={}){return{type:"Feature",geometry:{type:"Point",coordinates:t},properties:e}}function y(t,e={}){return{type:"Feature",geometry:{type:"LineString",coordinates:t},properties:e}}function v(t,e={}){return{type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:e}}function m(t,e={}){return{type:"Feature",geometry:{type:"MultiPolygon",coordinates:t},properties:e}}function _(t){return{type:"FeatureCollection",features:t}}function k(t){if("Polygon"===t.geometry.type)return[t.geometry.coordinates];if("MultiPolygon"===t.geometry.type)return t.geometry.coordinates;throw new Error("Feature must be a Polygon or MultiPolygon")}function x(t,e,n="kilometers"){const i=Array.isArray(t)?t:t.geometry.coordinates,r=Array.isArray(e)?e:e.geometry.coordinates,[o,s]=i,[a,l]=r,u="miles"===n?f:"meters"===n?h:c,g=M(l-s),d=M(a-o),p=Math.sin(g/2)*Math.sin(g/2)+Math.cos(M(s))*Math.cos(M(l))*Math.sin(d/2)*Math.sin(d/2);return u*(2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)))}function E(t,e){const n=Array.isArray(t)?t:t.geometry.coordinates,i=Array.isArray(e)?e:e.geometry.coordinates,[r,o]=n,[s,a]=i;return p([(r+s)/2,(o+a)/2])}function w(t){const e=k(t);let n=0;for(const i of e)for(let t=0;t<i.length;t++){const e=S(i[t]);n+=0===t?Math.abs(e):-Math.abs(e)}return Math.abs(n)}function I(t){const e=k(t);let n=0,i=0,r=0;for(const o of e)for(const t of o)for(const e of t)n+=e[0],i+=e[1],r++;return p([n/r,i/r])}function M(t){return t*g}function S(t){let e=0;const n=t.length;for(let i=0;i<n-1;i++){const[n,r]=t[i],[o,s]=t[i+1];e+=n*s-o*r}return.5*Math.abs(e)*Math.pow(h*g,2)}var b=6371008.8,N={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*b,kilometers:6371.0088,kilometres:6371.0088,meters:b,metres:b,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:b/1852,radians:1,yards:6967335.223679999};function L(t,e,n={}){const i={type:"Feature"};return(0===n.id||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=e||{},i.geometry=t,i}function P(t,e,n={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!F(t[0])||!F(t[1]))throw new Error("coordinates must contain numbers");return L({type:"Point",coordinates:t},e,n)}function C(t,e,n={}){for(const i of t){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 t=0;t<i[i.length-1].length;t++)if(i[i.length-1][t]!==i[0][t])throw new Error("First and last Position are not equivalent.")}return L({type:"Polygon",coordinates:t},e,n)}function T(t,e,n={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return L({type:"LineString",coordinates:t},e,n)}function O(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function A(t,e,n={}){return L({type:"MultiPolygon",coordinates:t},e,n)}function R(t,e="kilometers"){const n=N[e];if(!n)throw new Error(e+" units is invalid");return t*n}function D(t){return t%360*Math.PI/180}function F(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function G(t,e,n){if(null!==t)for(var i,r,o,s,a,l,u,h,c=0,f=0,g=t.type,d="FeatureCollection"===g,p="Feature"===g,y=d?t.features.length:1,v=0;v<y;v++){a=(h=!!(u=d?t.features[v].geometry:p?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var m=0;m<a;m++){var _=0,k=0;if(null!==(s=h?u.geometries[m]:u)){l=s.coordinates;var x=s.type;switch(c=!n||"Polygon"!==x&&"MultiPolygon"!==x?0:1,x){case null:break;case"Point":if(!1===e(l,f,v,_,k))return!1;f++,_++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===e(l[i],f,v,_,k))return!1;f++,"MultiPoint"===x&&_++}"LineString"===x&&_++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(r=0;r<l[i].length-c;r++){if(!1===e(l[i][r],f,v,_,k))return!1;f++}"MultiLineString"===x&&_++,"Polygon"===x&&k++}"Polygon"===x&&_++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(k=0,r=0;r<l[i].length;r++){for(o=0;o<l[i][r].length-c;o++){if(!1===e(l[i][r][o],f,v,_,k))return!1;f++}k++}_++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===G(s.geometries[i],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function B(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function q(t,e){var n,i,r,o,s,a,l,u,h,c,f=0,g="FeatureCollection"===t.type,d="Feature"===t.type,p=g?t.features.length:1;for(n=0;n<p;n++){for(a=g?t.features[n].geometry:d?t.geometry:t,u=g?t.features[n].properties:d?t.properties:{},h=g?t.features[n].bbox:d?t.bbox:void 0,c=g?t.features[n].id:d?t.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=l?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,f,u,h,c))return!1;break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===e(o.geometries[i],f,u,h,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,f,u,h,c))return!1;f++}}function Y(t,e){q(t,function(t,n,i,r,o){var s,a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==e(L(t,i,{bbox:r,id:o}),n,0)&&void 0}switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<t.coordinates.length;l++){var u=t.coordinates[l];if(!1===e(L({type:s,coordinates:u},i),n,l))return!1}})}function z(t,e,n){var i=n,r=!1;return function(t,e){Y(t,function(t,n,i){var r=0;if(t.geometry){var o=t.geometry.type;if("Point"!==o&&"MultiPoint"!==o){var s,a=0,l=0,u=0;return!1!==G(t,function(o,h,c,f,g){if(void 0===s||n>a||f>l||g>u)return s=o,a=n,l=f,u=g,void(r=0);var d=T([s,o],t.properties);if(!1===e(d,n,i,g,r))return!1;r++,s=o})&&void 0}}})}(t,function(t,o,s,a,l){i=!1===r&&void 0===n?t:e(i,t,o,s,a,l),r=!0}),i}function H(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function U(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}),n}var X,V={exports:{}},j={exports:{}};function K(){return X||(X=1,j.exports=function(){function t(t,i,r,o,s){!function t(n,i,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,l=i-r+1,u=Math.log(a),h=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*h*(a-h)/a)*(l-a/2<0?-1:1);t(n,i,Math.max(r,Math.floor(i-l*h/a+c)),Math.min(o,Math.floor(i+(a-l)*h/a+c)),s)}var f=n[i],g=r,d=o;for(e(n,r,i),s(n[o],f)>0&&e(n,r,o);g<d;){for(e(n,g,d),g++,d--;s(n[g],f)<0;)g++;for(;s(n[d],f)>0;)d--}0===s(n[r],f)?e(n,r,d):e(n,++d,o),d<=i&&(r=d+1),i<=d&&(o=d-1)}}(t,i,r||0,o||t.length-1,s||n)}function e(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function n(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function o(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,i,r){r||(r=d(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o=e;o<n;o++){var s=t.children[o];a(r,t.leaf?i(s):s)}return r}function a(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function l(t,e){return t.minX-e.minX}function u(t,e){return t.minY-e.minY}function h(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function c(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function g(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function d(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function p(e,n,i,r,o){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var a=n+Math.ceil((i-n)/r/2)*r;t(e,a,n,i,o),s.push(n,a,a,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!g(t,e))return n;for(var i=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?i(s):s;g(t,a)&&(e.leaf?n.push(s):f(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!g(t,e))return!1;for(var n=[];e;){for(var i=0;i<e.children.length;i++){var r=e.children[i],o=e.leaf?this.toBBox(r):r;if(g(t,o)){if(e.leaf||f(t,o))return!0;n.push(r)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=d([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,i,o,s=this.data,a=this.toBBox(t),l=[],u=[];s||l.length;){if(s||(s=l.pop(),i=l[l.length-1],n=u.pop(),o=!0),s.leaf){var h=r(t,s.children,e);if(-1!==h)return s.children.splice(h,1),l.push(s),this._condense(l),this}o||s.leaf||!f(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(l.push(s),u.push(n),n=0,i=s,s=s.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,i){var r,s=n-e+1,a=this._maxEntries;if(s<=a)return o(r=d(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),(r=d([])).leaf=!1,r.height=i;var l=Math.ceil(s/a),u=l*Math.ceil(Math.sqrt(a));p(t,e,n,u,this.compareMinX);for(var h=e;h<=n;h+=u){var c=Math.min(h+u-1,n);p(t,h,c,l,this.compareMinY);for(var f=h;f<=c;f+=l){var g=Math.min(f+l-1,c);r.children.push(this._build(t,f,g,i-1))}}return o(r,this.toBBox),r},i.prototype._chooseSubtree=function(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){for(var r=1/0,o=1/0,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],u=h(l),c=(f=t,g=l,(Math.max(g.maxX,f.maxX)-Math.min(g.minX,f.minX))*(Math.max(g.maxY,f.maxY)-Math.min(g.minY,f.minY))-u);c<o?(o=c,r=u<r?u:r,s=l):c===o&&u<r&&(r=u,s=l)}e=s||e.children[0]}var f,g;return e},i.prototype._insert=function(t,e,n){var i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),a(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)},i.prototype._split=function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),a=d(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,o(n,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},i.prototype._splitRoot=function(t,e){this.data=d([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var i,r,o,a,l,u,c,f=1/0,g=1/0,d=e;d<=n-e;d++){var p=s(t,0,d,this.toBBox),y=s(t,d,n,this.toBBox),v=(r=p,o=y,a=void 0,l=void 0,u=void 0,c=void 0,a=Math.max(r.minX,o.minX),l=Math.max(r.minY,o.minY),u=Math.min(r.maxX,o.maxX),c=Math.min(r.maxY,o.maxY),Math.max(0,u-a)*Math.max(0,c-l)),m=h(p)+h(y);v<f?(f=v,i=d,g=m<g?m:g):v===f&&m<g&&(g=m,i=d)}return i||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var i=t.leaf?this.compareMinX:l,r=t.leaf?this.compareMinY:u;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},i.prototype._allDistMargin=function(t,e,n,i){t.children.sort(i);for(var r=this.toBBox,o=s(t,0,e,r),l=s(t,n-e,n,r),u=c(o)+c(l),h=e;h<n-e;h++){var f=t.children[h];a(o,t.leaf?r(f):f),u+=c(o)}for(var g=n-e-1;g>=e;g--){var d=t.children[g];a(l,t.leaf?r(d):d),u+=c(l)}return u},i.prototype._adjustParentBBoxes=function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},i}()),j.exports}function W(t,e){return t<e?-1:t>e?1:0}const Z=Object.freeze(Object.defineProperty({__proto__:null,default:class{constructor(t=[],e=W){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const 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){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}},Symbol.toStringTag,{value:"Module"})),J=U(Z);var $,Q,tt,et,nt,it={exports:{}};function rt(){if(nt)return it.exports;nt=1;var t=Q?$:(Q=1,$=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=(i-n)/2,l=0,u=a-1;l<a;u=l++){var h=e[n+2*l+0],c=e[n+2*l+1],f=e[n+2*u+0],g=e[n+2*u+1];c>o!=g>o&&r<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s}),e=et?tt:(et=1,tt=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=i-n,l=0,u=a-1;l<a;u=l++){var h=e[l+n][0],c=e[l+n][1],f=e[u+n][0],g=e[u+n][1];c>o!=g>o&&r<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s});return it.exports=function(n,i,r,o){return i.length>0&&Array.isArray(i[0])?e(n,i,r,o):t(n,i,r,o)},it.exports.nested=e,it.exports.flat=t,it.exports}var ot,st,at={exports:{}};function lt(){return ot||(ot=1,function(t){const e=134217729,n=33306690738754706e-32;function i(t,e,n,i,r){let o,s,a,l,u=e[0],h=i[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=i[++f]);let g=0;if(c<t&&f<n)for(h>u==h>-u?(a=o-((s=u+o)-u),u=e[++c]):(a=o-((s=h+o)-h),h=i[++f]),o=s,0!==a&&(r[g++]=a);c<t&&f<n;)h>u==h>-u?(a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++c]):(a=o-((s=o+h)-(l=s-o))+(h-l),h=i[++f]),o=s,0!==a&&(r[g++]=a);for(;c<t;)a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++c],o=s,0!==a&&(r[g++]=a);for(;f<n;)a=o-((s=o+h)-(l=s-o))+(h-l),h=i[++f],o=s,0!==a&&(r[g++]=a);return 0===o&&0!==g||(r[g++]=o),g}function r(t){return new Float64Array(t)}const o=33306690738754716e-32,s=22204460492503146e-32,a=11093356479670487e-47,l=r(4),u=r(8),h=r(12),c=r(16),f=r(4);t.orient2d=function(t,r,g,d,p,y){const v=(r-y)*(g-p),m=(t-p)*(d-y),_=v-m;if(0===v||0===m||v>0!=m>0)return _;const k=Math.abs(v+m);return Math.abs(_)>=o*k?_:-function(t,r,o,g,d,p,y){let v,m,_,k,x,E,w,I,M,S,b,N,L,P,C,T,O,A;const R=t-d,D=o-d,F=r-p,G=g-p;x=(C=(I=R-(w=(E=e*R)-(E-R)))*(S=G-(M=(E=e*G)-(E-G)))-((P=R*G)-w*M-I*M-w*S))-(b=C-(O=(I=F-(w=(E=e*F)-(E-F)))*(S=D-(M=(E=e*D)-(E-D)))-((T=F*D)-w*M-I*M-w*S))),l[0]=C-(b+x)+(x-O),x=(L=P-((N=P+b)-(x=N-P))+(b-x))-(b=L-T),l[1]=L-(b+x)+(x-T),x=(A=N+b)-N,l[2]=N-(A-x)+(b-x),l[3]=A;let B=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,l),q=s*y;if(B>=q||-B>=q)return B;if(v=t-(R+(x=t-R))+(x-d),_=o-(D+(x=o-D))+(x-d),m=r-(F+(x=r-F))+(x-p),k=g-(G+(x=g-G))+(x-p),0===v&&0===m&&0===_&&0===k)return B;if(q=a*y+n*Math.abs(B),(B+=R*k+G*v-(F*_+D*m))>=q||-B>=q)return B;x=(C=(I=v-(w=(E=e*v)-(E-v)))*(S=G-(M=(E=e*G)-(E-G)))-((P=v*G)-w*M-I*M-w*S))-(b=C-(O=(I=m-(w=(E=e*m)-(E-m)))*(S=D-(M=(E=e*D)-(E-D)))-((T=m*D)-w*M-I*M-w*S))),f[0]=C-(b+x)+(x-O),x=(L=P-((N=P+b)-(x=N-P))+(b-x))-(b=L-T),f[1]=L-(b+x)+(x-T),x=(A=N+b)-N,f[2]=N-(A-x)+(b-x),f[3]=A;const Y=i(4,l,4,f,u);x=(C=(I=R-(w=(E=e*R)-(E-R)))*(S=k-(M=(E=e*k)-(E-k)))-((P=R*k)-w*M-I*M-w*S))-(b=C-(O=(I=F-(w=(E=e*F)-(E-F)))*(S=_-(M=(E=e*_)-(E-_)))-((T=F*_)-w*M-I*M-w*S))),f[0]=C-(b+x)+(x-O),x=(L=P-((N=P+b)-(x=N-P))+(b-x))-(b=L-T),f[1]=L-(b+x)+(x-T),x=(A=N+b)-N,f[2]=N-(A-x)+(b-x),f[3]=A;const z=i(Y,u,4,f,h);x=(C=(I=v-(w=(E=e*v)-(E-v)))*(S=k-(M=(E=e*k)-(E-k)))-((P=v*k)-w*M-I*M-w*S))-(b=C-(O=(I=m-(w=(E=e*m)-(E-m)))*(S=_-(M=(E=e*_)-(E-_)))-((T=m*_)-w*M-I*M-w*S))),f[0]=C-(b+x)+(x-O),x=(L=P-((N=P+b)-(x=N-P))+(b-x))-(b=L-T),f[1]=L-(b+x)+(x-T),x=(A=N+b)-N,f[2]=N-(A-x)+(b-x),f[3]=A;const H=i(z,h,4,f,c);return c[H-1]}(t,r,g,d,p,y,k)},t.orient2dfast=function(t,e,n,i,r,o){return(e-o)*(n-r)-(t-r)*(i-o)},Object.defineProperty(t,"__esModule",{value:!0})}(at.exports)),at.exports}const ut=H(function(){if(st)return V.exports;st=1;var t=K(),e=J,n=rt(),i=lt().orient2d;function r(e,i,r){i=Math.max(0,void 0===i?2:i),r=r||0;var s=function(t){for(var e=t[0],i=t[0],r=t[0],o=t[0],s=0;s<t.length;s++){var a=t[s];a[0]<e[0]&&(e=a),a[0]>r[0]&&(r=a),a[1]<i[1]&&(i=a),a[1]>o[1]&&(o=a)}var l=[e,i,r,o],u=l.slice();for(s=0;s<t.length;s++)n(t[s],l)||u.push(t[s]);return function(t){t.sort(v);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&h(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var i=[],r=t.length-1;r>=0;r--){for(;i.length>=2&&h(i[i.length-2],i[i.length-1],t[r])<=0;)i.pop();i.push(t[r])}return i.pop(),e.pop(),e.concat(i)}(u)}(e),a=new t(16);a.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},a.compareMinX=function(t,e){return t[0]-e[0]},a.compareMinY=function(t,e){return t[1]-e[1]},a.load(e);for(var l,u=[],c=0;c<s.length;c++){var p=s[c];a.remove(p),l=g(p,l),u.push(l)}var y=new t(16);for(c=0;c<u.length;c++)y.insert(f(u[c]));for(var m=i*i,_=r*r;u.length;){var k=u.shift(),x=k.p,E=k.next.p,w=d(x,E);if(!(w<_)){var I=w/m;(p=o(a,k.prev.p,x,E,k.next.next.p,I,y))&&Math.min(d(p,x),d(p,E))<=I&&(u.push(k),u.push(g(p,k)),a.remove(p),y.remove(k),y.insert(f(k)),y.insert(f(k.next)))}}k=l;var M=[];do{M.push(k.p),k=k.next}while(k!==l);return M.push(k.p),M}function o(t,n,i,r,o,l,h){for(var c=new e([],s),f=t.data;f;){for(var g=0;g<f.children.length;g++){var d=f.children[g],y=f.leaf?p(d,i,r):a(i,r,d);y>l||c.push({node:d,dist:y})}for(;c.length&&!c.peek().node.children;){var v=c.pop(),m=v.node,_=p(m,n,i),k=p(m,r,o);if(v.dist<_&&v.dist<k&&u(i,m,h)&&u(r,m,h))return m}(f=c.pop())&&(f=f.node)}return null}function s(t,e){return t.dist-e.dist}function a(t,e,n){if(l(t,n)||l(e,n))return 0;var i=y(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=y(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var o=y(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=y(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,o,s)}function l(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function u(t,e,n){for(var i=Math.min(t[0],e[0]),r=Math.min(t[1],e[1]),o=Math.max(t[0],e[0]),s=Math.max(t[1],e[1]),a=n.search({minX:i,minY:r,maxX:o,maxY:s}),l=0;l<a.length;l++)if(c(a[l].p,a[l].next.p,t,e))return!1;return!0}function h(t,e,n){return i(t[0],t[1],e[0],e[1],n[0],n[1])}function c(t,e,n,i){return t!==i&&e!==n&&h(t,e,n)>0!=h(t,e,i)>0&&h(n,i,t)>0!=h(n,i,e)>0}function f(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function g(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function d(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function p(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function y(t,e,n,i,r,o,s,a){var l,u,h,c,f=n-t,g=i-e,d=s-r,p=a-o,y=t-r,v=e-o,m=f*f+g*g,_=f*d+g*p,k=d*d+p*p,x=f*y+g*v,E=d*y+p*v,w=m*k-_*_,I=w,M=w;0===w?(u=0,I=1,c=E,M=k):(c=m*E-_*x,(u=_*E-k*x)<0?(u=0,c=E,M=k):u>I&&(u=I,c=E+_,M=k)),c<0?(c=0,-x<0?u=0:-x>m?u=I:(u=-x,I=m)):c>M&&(c=M,-x+_<0?u=0:-x+_>m?u=I:(u=-x+_,I=m));var S=(1-(h=0===c?0:c/M))*r+h*s-((1-(l=0===u?0:u/I))*t+l*n),b=(1-h)*o+h*a-((1-l)*e+l*i);return S*S+b*b}function v(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}return e.default&&(e=e.default),V.exports=r,V.exports.default=r,V.exports}());function ht(t,e={}){e.concavity=e.concavity||1/0;const n=[];if(G(t,t=>{n.push([t[0],t[1]])}),!n.length)return null;const i=ut(n,e.concavity);return i.length>3?C([i]):null}var ct=ht;function ft(t,e={}){let n=0,i=0,r=0;return G(t,function(t){n+=t[0],i+=t[1],r++},!0),P([n/r,i/r],e.properties)}function gt(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return[...t.geometry.coordinates];if("Point"===t.type)return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function dt(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function pt(t){return"Feature"===t.type?t.geometry:t}function yt(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}var vt=function t(e,n={}){switch(yt(e)){case"Point":return P(gt(e),n.properties);case"Polygon":var i=[];G(e,function(t){i.push(t)});var r,o,s,a,l,u,h,c,f=ft(e,{properties:n.properties}),g=f.geometry.coordinates,d=0,p=0,y=0,v=i.map(function(t){return[t[0]-g[0],t[1]-g[1]]});for(r=0;r<i.length-1;r++)a=(o=v[r])[0],u=o[1],l=(s=v[r+1])[0],y+=c=a*(h=s[1])-l*u,d+=(a+l)*c,p+=(u+h)*c;if(0===y)return f;var m=1/(6*(.5*y));return P([g[0]+m*d,g[1]+m*p],n.properties);default:var _=ht(e);return _?t(_,{properties:n.properties}):ft(e,{properties:n.properties})}};class mt{constructor(t=[],e=_t){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const 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){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}function _t(t,e){return t<e?-1:t>e?1:0}function kt(t,e){return t.p.x>e.p.x?1:t.p.x<e.p.x?-1:t.p.y!==e.p.y?t.p.y>e.p.y?1:-1:1}function xt(t,e){return t.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:t.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:t.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?t.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class Et{constructor(t,e,n,i){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}let wt=0,It=0,Mt=0;function St(t,e){const n="Feature"===t.type?t.geometry:t;let i=n.coordinates;"Polygon"!==n.type&&"MultiLineString"!==n.type||(i=[i]),"LineString"===n.type&&(i=[[i]]);for(let r=0;r<i.length;r++)for(let t=0;t<i[r].length;t++){let n=i[r][t][0],o=null;It+=1;for(let s=0;s<i[r][t].length-1;s++){o=i[r][t][s+1];const a=new Et(n,wt,It,Mt),l=new Et(o,wt,It,Mt+1);a.otherEvent=l,l.otherEvent=a,kt(a,l)>0?(l.isLeftEndpoint=!0,a.isLeftEndpoint=!1):(a.isLeftEndpoint=!0,l.isLeftEndpoint=!1),e.push(a),e.push(l),n=o,Mt+=1}}wt+=1}let bt=class{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}};function Nt(t,e){if(null===t||null===e)return!1;if(t.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.rightSweepEvent)||t.leftSweepEvent.isSamePoint(e.leftSweepEvent)||t.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const n=t.leftSweepEvent.p.x,i=t.leftSweepEvent.p.y,r=t.rightSweepEvent.p.x,o=t.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,l=e.rightSweepEvent.p.x,u=e.rightSweepEvent.p.y,h=(u-a)*(r-n)-(l-s)*(o-i),c=(l-s)*(i-a)-(u-a)*(n-s),f=(r-n)*(i-a)-(o-i)*(n-s);if(0===h)return!1;const g=c/h,d=f/h;if(g>=0&&g<=1&&d>=0&&d<=1){return[n+g*(r-n),i+g*(o-i)]}return!1}var Lt=function(t,e){const n=new mt([],kt);return function(t,e){if("FeatureCollection"===t.type){const n=t.features;for(let t=0;t<n.length;t++)St(n[t],e)}else St(t,e)}(t,n),function(t,e){e=e||!1;const n=[],i=new mt([],xt);for(;t.length;){const r=t.pop();if(r.isLeftEndpoint){const t=new bt(r);for(let o=0;o<i.data.length;o++){const s=i.data[o];if(e&&s.leftSweepEvent.featureId===r.featureId)continue;const a=Nt(t,s);!1!==a&&n.push(a)}i.push(t)}else!1===r.isLeftEndpoint&&i.pop()}return n}(n,e)};var Pt=function(t,e,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:r=!0}=n;let o=[];"FeatureCollection"===t.type?o=o.concat(t.features):"Feature"===t.type?o.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||o.push(L(t)),"FeatureCollection"===e.type?o=o.concat(e.features):"Feature"===e.type?o.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||o.push(L(e));const s=Lt(O(o),r);let a=[];if(i){const t={};s.forEach(e=>{const n=e.join(",");t[n]||(t[n]=!0,a.push(e))})}else a=s;return O(a.map(t=>P(t)))},Ct=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Tt=Math.ceil,Ot=Math.floor,At="[BigNumber Error] ",Rt=At+"Number primitive has more than 15 significant digits: ",Dt=1e14,Ft=14,Gt=9007199254740991,Bt=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],qt=1e7,Yt=1e9;function zt(t){var e=0|t;return t>0||t===e?e:e-1}function Ht(t){for(var e,n,i=1,r=t.length,o=t[0]+"";i<r;){for(e=t[i++]+"",n=Ft-e.length;n--;e="0"+e);o+=e}for(r=o.length;48===o.charCodeAt(--r););return o.slice(0,r+1||1)}function Ut(t,e){var n,i,r=t.c,o=e.c,s=t.s,a=e.s,l=t.e,u=e.e;if(!s||!a)return null;if(n=r&&!r[0],i=o&&!o[0],n||i)return n?i?0:-a:s;if(s!=a)return s;if(n=s<0,i=l==u,!r||!o)return i?0:!r^n?1:-1;if(!i)return l>u^n?1:-1;for(a=(l=r.length)<(u=o.length)?l:u,s=0;s<a;s++)if(r[s]!=o[s])return r[s]>o[s]^n?1:-1;return l==u?0:l>u^n?1:-1}function Xt(t,e,n,i){if(t<e||t>n||t!==Ot(t))throw Error(At+(i||"Argument")+("number"==typeof t?t<e||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function Vt(t){var e=t.c.length-1;return zt(t.e/Ft)==e&&t.c[e]%2!=0}function jt(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function Kt(t,e,n){var i,r;if(e<0){for(r=n+".";++e;r+=n);t=r+t}else if(++e>(i=t.length)){for(r=n,e-=i;--e;r+=n);t+=r}else e<i&&(t=t.slice(0,e)+"."+t.slice(e));return t}var Wt=function t(e){var n,i,r,o,s,a=x.prototype={constructor:x,toString:null,valueOf:null},l=new x(1),u=20,h=4,c=-7,f=21,g=-1e7,d=1e7,p=!1,y=1,v=0,m={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},_="0123456789abcdefghijklmnopqrstuvwxyz",k=!0;function x(t,e){var n,o,s,a,l,c,f,p,y=this;if(!(y instanceof x))return new x(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>d?y.c=y.e=null:t.e<g?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((c="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,l=t;l>=10;l/=10,a++);return void(a>d?y.c=y.e=null:(y.e=a,y.c=[t]))}p=String(t)}else{if(!Ct.test(p=String(t)))return r(y,p,c);y.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(a=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(a<0&&(a=l),a+=+p.slice(l+1),p=p.substring(0,l)):a<0&&(a=p.length)}else{if(Xt(e,2,_.length,"Base"),10==e&&k)return M(y=new x(t),u+y.e+1,h);if(p=String(t),c="number"==typeof t){if(0*t!=0)return r(y,p,c,e);if(y.s=1/t<0?(p=p.slice(1),-1):1,x.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(Rt+t)}else y.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(n=_.slice(0,e),a=l=0,f=p.length;l<f;l++)if(n.indexOf(o=p.charAt(l))<0){if("."==o){if(l>a){a=f;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,a=0;continue}return r(y,String(t),c,e)}c=!1,(a=(p=i(p,e,10,y.s)).indexOf("."))>-1?p=p.replace(".",""):a=p.length}for(l=0;48===p.charCodeAt(l);l++);for(f=p.length;48===p.charCodeAt(--f););if(p=p.slice(l,++f)){if(f-=l,c&&x.DEBUG&&f>15&&(t>Gt||t!==Ot(t)))throw Error(Rt+y.s*t);if((a=a-l-1)>d)y.c=y.e=null;else if(a<g)y.c=[y.e=0];else{if(y.e=a,y.c=[],l=(a+1)%Ft,a<0&&(l+=Ft),l<f){for(l&&y.c.push(+p.slice(0,l)),f-=Ft;l<f;)y.c.push(+p.slice(l,l+=Ft));l=Ft-(p=p.slice(l)).length}else l-=f;for(;l--;p+="0");y.c.push(+p)}}else y.c=[y.e=0]}function E(t,e,n,i){var r,o,s,a,l;if(null==n?n=h:Xt(n,0,8),!t.c)return t.toString();if(r=t.c[0],s=t.e,null==e)l=Ht(t.c),l=1==i||2==i&&(s<=c||s>=f)?jt(l,s):Kt(l,s,"0");else if(o=(t=M(new x(t),e,n)).e,a=(l=Ht(t.c)).length,1==i||2==i&&(e<=o||o<=c)){for(;a<e;l+="0",a++);l=jt(l,o)}else if(e-=s+(2===i&&o>s),l=Kt(l,o,"0"),o+1>a){if(--e>0)for(l+=".";e--;l+="0");}else if((e+=o-a)>0)for(o+1==a&&(l+=".");e--;l+="0");return t.s<0&&r?"-"+l:l}function w(t,e){for(var n,i,r=1,o=new x(t[0]);r<t.length;r++)(!(i=new x(t[r])).s||(n=Ut(o,i))===e||0===n&&o.s===e)&&(o=i);return o}function I(t,e,n){for(var i=1,r=e.length;!e[--r];e.pop());for(r=e[0];r>=10;r/=10,i++);return(n=i+n*Ft-1)>d?t.c=t.e=null:n<g?t.c=[t.e=0]:(t.e=n,t.c=e),t}function M(t,e,n,i){var r,o,s,a,l,u,h,c=t.c,f=Bt;if(c){t:{for(r=1,a=c[0];a>=10;a/=10,r++);if((o=e-r)<0)o+=Ft,s=e,l=c[u=0],h=Ot(l/f[r-s-1]%10);else if((u=Tt((o+1)/Ft))>=c.length){if(!i)break t;for(;c.length<=u;c.push(0));l=h=0,r=1,s=(o%=Ft)-Ft+1}else{for(l=a=c[u],r=1;a>=10;a/=10,r++);h=(s=(o%=Ft)-Ft+r)<0?0:Ot(l/f[r-s-1]%10)}if(i=i||e<0||null!=c[u+1]||(s<0?l:l%f[r-s-1]),i=n<4?(h||i)&&(0==n||n==(t.s<0?3:2)):h>5||5==h&&(4==n||i||6==n&&(o>0?s>0?l/f[r-s]:0:c[u-1])%10&1||n==(t.s<0?8:7)),e<1||!c[0])return c.length=0,i?(e-=t.e+1,c[0]=f[(Ft-e%Ft)%Ft],t.e=-e||0):c[0]=t.e=0,t;if(0==o?(c.length=u,a=1,u--):(c.length=u+1,a=f[Ft-o],c[u]=s>0?Ot(l/f[r-s]%f[s])*a:0),i)for(;;){if(0==u){for(o=1,s=c[0];s>=10;s/=10,o++);for(s=c[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,c[0]==Dt&&(c[0]=1));break}if(c[u]+=a,c[u]!=Dt)break;c[u--]=0,a=1}for(o=c.length;0===c[--o];c.pop());}t.e>d?t.c=t.e=null:t.e<g&&(t.c=[t.e=0])}return t}function S(t){var e,n=t.e;return null===n?t.toString():(e=Ht(t.c),e=n<=c||n>=f?jt(e,n):Kt(e,n,"0"),t.s<0?"-"+e:e)}return x.clone=t,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(t){var e,n;if(null!=t){if("object"!=typeof t)throw Error(At+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(Xt(n=t[e],0,Yt,e),u=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(Xt(n=t[e],0,8,e),h=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(Xt(n[0],-Yt,0,e),Xt(n[1],0,Yt,e),c=n[0],f=n[1]):(Xt(n,-Yt,Yt,e),c=-(f=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)Xt(n[0],-Yt,-1,e),Xt(n[1],1,Yt,e),g=n[0],d=n[1];else{if(Xt(n,-Yt,Yt,e),!n)throw Error(At+e+" cannot be zero: "+n);g=-(d=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(At+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw p=!n,Error(At+"crypto unavailable");p=n}else p=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(Xt(n=t[e],0,9,e),y=n),t.hasOwnProperty(e="POW_PRECISION")&&(Xt(n=t[e],0,Yt,e),v=n),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(n=t[e]))throw Error(At+e+" not an object: "+n);m=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(At+e+" invalid: "+n);k="0123456789"==n.slice(0,10),_=n}}return{DECIMAL_PLACES:u,ROUNDING_MODE:h,EXPONENTIAL_AT:[c,f],RANGE:[g,d],CRYPTO:p,MODULO_MODE:y,POW_PRECISION:v,FORMAT:m,ALPHABET:_}},x.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!x.DEBUG)return!0;var e,n,i=t.c,r=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(i)){if((1===o||-1===o)&&r>=-Yt&&r<=Yt&&r===Ot(r)){if(0===i[0]){if(0===r&&1===i.length)return!0;break t}if((e=(r+1)%Ft)<1&&(e+=Ft),String(i[0]).length==e){for(e=0;e<i.length;e++)if((n=i[e])<0||n>=Dt||n!==Ot(n))break t;if(0!==n)return!0}}}else if(null===i&&null===r&&(null===o||1===o||-1===o))return!0;throw Error(At+"Invalid BigNumber: "+t)},x.maximum=x.max=function(){return w(arguments,-1)},x.minimum=x.min=function(){return w(arguments,1)},x.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return Ot(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,n,i,r,o,a=0,h=[],c=new x(l);if(null==t?t=u:Xt(t,0,Yt),r=Tt(t/Ft),p)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(r*=2));a<r;)(o=131072*e[a]+(e[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),e[a]=n[0],e[a+1]=n[1]):(h.push(o%1e14),a+=2);a=r/2}else{if(!crypto.randomBytes)throw p=!1,Error(At+"crypto unavailable");for(e=crypto.randomBytes(r*=7);a<r;)(o=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(h.push(o%1e14),a+=7);a=r/7}if(!p)for(;a<r;)(o=s())<9e15&&(h[a++]=o%1e14);for(r=h[--a],t%=Ft,r&&t&&(o=Bt[Ft-t],h[a]=Ot(r/o)*o);0===h[a];h.pop(),a--);if(a<0)h=[i=0];else{for(i=-1;0===h[0];h.splice(0,1),i-=Ft);for(a=1,o=h[0];o>=10;o/=10,a++);a<Ft&&(i-=Ft-a)}return c.e=i,c.c=h,c}),x.sum=function(){for(var t=1,e=arguments,n=new x(e[0]);t<e.length;)n=n.plus(e[t++]);return n},i=function(){var t="0123456789";function e(t,e,n,i){for(var r,o,s=[0],a=0,l=t.length;a<l;){for(o=s.length;o--;s[o]*=e);for(s[0]+=i.indexOf(t.charAt(a++)),r=0;r<s.length;r++)s[r]>n-1&&(null==s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/n|0,s[r]%=n)}return s.reverse()}return function(i,r,o,s,a){var l,c,f,g,d,p,y,m,k=i.indexOf("."),E=u,w=h;for(k>=0&&(g=v,v=0,i=i.replace(".",""),p=(m=new x(r)).pow(i.length-k),v=g,m.c=e(Kt(Ht(p.c),p.e,"0"),10,o,t),m.e=m.c.length),f=g=(y=e(i,r,o,a?(l=_,t):(l=t,_))).length;0==y[--g];y.pop());if(!y[0])return l.charAt(0);if(k<0?--f:(p.c=y,p.e=f,p.s=s,y=(p=n(p,m,E,w,o)).c,d=p.r,f=p.e),k=y[c=f+E+1],g=o/2,d=d||c<0||null!=y[c+1],d=w<4?(null!=k||d)&&(0==w||w==(p.s<0?3:2)):k>g||k==g&&(4==w||d||6==w&&1&y[c-1]||w==(p.s<0?8:7)),c<1||!y[0])i=d?Kt(l.charAt(1),-E,l.charAt(0)):l.charAt(0);else{if(y.length=c,d)for(--o;++y[--c]>o;)y[c]=0,c||(++f,y=[1].concat(y));for(g=y.length;!y[--g];);for(k=0,i="";k<=g;i+=l.charAt(y[k++]));i=Kt(i,f,l.charAt(0))}return i}}(),n=function(){function t(t,e,n){var i,r,o,s,a=0,l=t.length,u=e%qt,h=e/qt|0;for(t=t.slice();l--;)a=((r=u*(o=t[l]%qt)+(i=h*o+(s=t[l]/qt|0)*u)%qt*qt+a)/n|0)+(i/qt|0)+h*s,t[l]=r%n;return a&&(t=[a].concat(t)),t}function e(t,e,n,i){var r,o;if(n!=i)o=n>i?1:-1;else for(r=o=0;r<n;r++)if(t[r]!=e[r]){o=t[r]>e[r]?1:-1;break}return o}function n(t,e,n,i){for(var r=0;n--;)t[n]-=r,r=t[n]<e[n]?1:0,t[n]=r*i+t[n]-e[n];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(i,r,o,s,a){var l,u,h,c,f,g,d,p,y,v,m,_,k,E,w,I,S,b=i.s==r.s?1:-1,N=i.c,L=r.c;if(!(N&&N[0]&&L&&L[0]))return new x(i.s&&r.s&&(N?!L||N[0]!=L[0]:L)?N&&0==N[0]||!L?0*b:b/0:NaN);for(y=(p=new x(b)).c=[],b=o+(u=i.e-r.e)+1,a||(a=Dt,u=zt(i.e/Ft)-zt(r.e/Ft),b=b/Ft|0),h=0;L[h]==(N[h]||0);h++);if(L[h]>(N[h]||0)&&u--,b<0)y.push(1),c=!0;else{for(E=N.length,I=L.length,h=0,b+=2,(f=Ot(a/(L[0]+1)))>1&&(L=t(L,f,a),N=t(N,f,a),I=L.length,E=N.length),k=I,m=(v=N.slice(0,I)).length;m<I;v[m++]=0);S=L.slice(),S=[0].concat(S),w=L[0],L[1]>=a/2&&w++;do{if(f=0,(l=e(L,v,I,m))<0){if(_=v[0],I!=m&&(_=_*a+(v[1]||0)),(f=Ot(_/w))>1)for(f>=a&&(f=a-1),d=(g=t(L,f,a)).length,m=v.length;1==e(g,v,d,m);)f--,n(g,I<d?S:L,d,a),d=g.length,l=1;else 0==f&&(l=f=1),d=(g=L.slice()).length;if(d<m&&(g=[0].concat(g)),n(v,g,m,a),m=v.length,-1==l)for(;e(L,v,I,m)<1;)f++,n(v,I<m?S:L,m,a),m=v.length}else 0===l&&(f++,v=[0]);y[h++]=f,v[0]?v[m++]=N[k]||0:(v=[N[k]],m=1)}while((k++<E||null!=v[0])&&b--);c=null!=v[0],y[0]||y.splice(0,1)}if(a==Dt){for(h=1,b=y[0];b>=10;b/=10,h++);M(p,o+(p.e=h+u*Ft-1)+1,s,c)}else p.e=u,p.r=+c;return p}}(),r=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,n=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,r=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,s,a,l){var u,h=a?s:s.replace(r,"");if(i.test(h))o.s=isNaN(h)?null:h<0?-1:1;else{if(!a&&(h=h.replace(t,function(t,e,n){return u="x"==(n=n.toLowerCase())?16:"b"==n?2:8,l&&l!=u?t:e}),l&&(u=l,h=h.replace(e,"$1").replace(n,"0.$1")),s!=h))return new x(h,u);if(x.DEBUG)throw Error(At+"Not a"+(l?" base "+l:"")+" number: "+s);o.s=null}o.c=o.e=null}}(),a.absoluteValue=a.abs=function(){var t=new x(this);return t.s<0&&(t.s=1),t},a.comparedTo=function(t,e){return Ut(this,new x(t,e))},a.decimalPlaces=a.dp=function(t,e){var n,i,r,o=this;if(null!=t)return Xt(t,0,Yt),null==e?e=h:Xt(e,0,8),M(new x(o),t+o.e+1,e);if(!(n=o.c))return null;if(i=((r=n.length-1)-zt(this.e/Ft))*Ft,r=n[r])for(;r%10==0;r/=10,i--);return i<0&&(i=0),i},a.dividedBy=a.div=function(t,e){return n(this,new x(t,e),u,h)},a.dividedToIntegerBy=a.idiv=function(t,e){return n(this,new x(t,e),0,1)},a.exponentiatedBy=a.pow=function(t,e){var n,i,r,o,s,a,u,c,f=this;if((t=new x(t)).c&&!t.isInteger())throw Error(At+"Exponent not an integer: "+S(t));if(null!=e&&(e=new x(e)),s=t.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!t.c||!t.c[0])return c=new x(Math.pow(+S(f),s?t.s*(2-Vt(t)):+S(t))),e?c.mod(e):c;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new x(NaN);(i=!a&&f.isInteger()&&e.isInteger())&&(f=f.mod(e))}else{if(t.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||s&&f.c[1]>=24e7:f.c[0]<8e13||s&&f.c[0]<=9999975e7)))return o=f.s<0&&Vt(t)?-0:0,f.e>-1&&(o=1/o),new x(a?1/o:o);v&&(o=Tt(v/Ft+2))}for(s?(n=new x(.5),a&&(t.s=1),u=Vt(t)):u=(r=Math.abs(+S(t)))%2,c=new x(l);;){if(u){if(!(c=c.times(f)).c)break;o?c.c.length>o&&(c.c.length=o):i&&(c=c.mod(e))}if(r){if(0===(r=Ot(r/2)))break;u=r%2}else if(M(t=t.times(n),t.e+1,1),t.e>14)u=Vt(t);else{if(0===(r=+S(t)))break;u=r%2}f=f.times(f),o?f.c&&f.c.length>o&&(f.c.length=o):i&&(f=f.mod(e))}return i?c:(a&&(c=l.div(c)),e?c.mod(e):o?M(c,v,h,undefined):c)},a.integerValue=function(t){var e=new x(this);return null==t?t=h:Xt(t,0,8),M(e,e.e+1,t)},a.isEqualTo=a.eq=function(t,e){return 0===Ut(this,new x(t,e))},a.isFinite=function(){return!!this.c},a.isGreaterThan=a.gt=function(t,e){return Ut(this,new x(t,e))>0},a.isGreaterThanOrEqualTo=a.gte=function(t,e){return 1===(e=Ut(this,new x(t,e)))||0===e},a.isInteger=function(){return!!this.c&&zt(this.e/Ft)>this.c.length-2},a.isLessThan=a.lt=function(t,e){return Ut(this,new x(t,e))<0},a.isLessThanOrEqualTo=a.lte=function(t,e){return-1===(e=Ut(this,new x(t,e)))||0===e},a.isNaN=function(){return!this.s},a.isNegative=function(){return this.s<0},a.isPositive=function(){return this.s>0},a.isZero=function(){return!!this.c&&0==this.c[0]},a.minus=function(t,e){var n,i,r,o,s=this,a=s.s;if(e=(t=new x(t,e)).s,!a||!e)return new x(NaN);if(a!=e)return t.s=-e,s.plus(t);var l=s.e/Ft,u=t.e/Ft,c=s.c,f=t.c;if(!l||!u){if(!c||!f)return c?(t.s=-e,t):new x(f?s:NaN);if(!c[0]||!f[0])return f[0]?(t.s=-e,t):new x(c[0]?s:3==h?-0:0)}if(l=zt(l),u=zt(u),c=c.slice(),a=l-u){for((o=a<0)?(a=-a,r=c):(u=l,r=f),r.reverse(),e=a;e--;r.push(0));r.reverse()}else for(i=(o=(a=c.length)<(e=f.length))?a:e,a=e=0;e<i;e++)if(c[e]!=f[e]){o=c[e]<f[e];break}if(o&&(r=c,c=f,f=r,t.s=-t.s),(e=(i=f.length)-(n=c.length))>0)for(;e--;c[n++]=0);for(e=Dt-1;i>a;){if(c[--i]<f[i]){for(n=i;n&&!c[--n];c[n]=e);--c[n],c[i]+=Dt}c[i]-=f[i]}for(;0==c[0];c.splice(0,1),--u);return c[0]?I(t,c,u):(t.s=3==h?-1:1,t.c=[t.e=0],t)},a.modulo=a.mod=function(t,e){var i,r,o=this;return t=new x(t,e),!o.c||!t.s||t.c&&!t.c[0]?new x(NaN):!t.c||o.c&&!o.c[0]?new x(o):(9==y?(r=t.s,t.s=1,i=n(o,t,0,3),t.s=r,i.s*=r):i=n(o,t,0,y),(t=o.minus(i.times(t))).c[0]||1!=y||(t.s=o.s),t)},a.multipliedBy=a.times=function(t,e){var n,i,r,o,s,a,l,u,h,c,f,g,d,p,y,v=this,m=v.c,_=(t=new x(t,e)).c;if(!(m&&_&&m[0]&&_[0]))return!v.s||!t.s||m&&!m[0]&&!_||_&&!_[0]&&!m?t.c=t.e=t.s=null:(t.s*=v.s,m&&_?(t.c=[0],t.e=0):t.c=t.e=null),t;for(i=zt(v.e/Ft)+zt(t.e/Ft),t.s*=v.s,(l=m.length)<(c=_.length)&&(d=m,m=_,_=d,r=l,l=c,c=r),r=l+c,d=[];r--;d.push(0));for(p=Dt,y=qt,r=c;--r>=0;){for(n=0,f=_[r]%y,g=_[r]/y|0,o=r+(s=l);o>r;)n=((u=f*(u=m[--s]%y)+(a=g*u+(h=m[s]/y|0)*f)%y*y+d[o]+n)/p|0)+(a/y|0)+g*h,d[o--]=u%p;d[o]=n}return n?++i:d.splice(0,1),I(t,d,i)},a.negated=function(){var t=new x(this);return t.s=-t.s||null,t},a.plus=function(t,e){var n,i=this,r=i.s;if(e=(t=new x(t,e)).s,!r||!e)return new x(NaN);if(r!=e)return t.s=-e,i.minus(t);var o=i.e/Ft,s=t.e/Ft,a=i.c,l=t.c;if(!o||!s){if(!a||!l)return new x(r/0);if(!a[0]||!l[0])return l[0]?t:new x(a[0]?i:0*r)}if(o=zt(o),s=zt(s),a=a.slice(),r=o-s){for(r>0?(s=o,n=l):(r=-r,n=a),n.reverse();r--;n.push(0));n.reverse()}for((r=a.length)-(e=l.length)<0&&(n=l,l=a,a=n,e=r),r=0;e;)r=(a[--e]=a[e]+l[e]+r)/Dt|0,a[e]=Dt===a[e]?0:a[e]%Dt;return r&&(a=[r].concat(a),++s),I(t,a,s)},a.precision=a.sd=function(t,e){var n,i,r,o=this;if(null!=t&&t!==!!t)return Xt(t,1,Yt),null==e?e=h:Xt(e,0,8),M(new x(o),t,e);if(!(n=o.c))return null;if(i=(r=n.length-1)*Ft+1,r=n[r]){for(;r%10==0;r/=10,i--);for(r=n[0];r>=10;r/=10,i++);}return t&&o.e+1>i&&(i=o.e+1),i},a.shiftedBy=function(t){return Xt(t,-9007199254740991,Gt),this.times("1e"+t)},a.squareRoot=a.sqrt=function(){var t,e,i,r,o,s=this,a=s.c,l=s.s,c=s.e,f=u+4,g=new x("0.5");if(1!==l||!a||!a[0])return new x(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+S(s)))||l==1/0?(((e=Ht(a)).length+c)%2==0&&(e+="0"),l=Math.sqrt(+e),c=zt((c+1)/2)-(c<0||c%2),i=new x(e=l==1/0?"5e"+c:(e=l.toExponential()).slice(0,e.indexOf("e")+1)+c)):i=new x(l+""),i.c[0])for((l=(c=i.e)+f)<3&&(l=0);;)if(o=i,i=g.times(o.plus(n(s,o,f,1))),Ht(o.c).slice(0,l)===(e=Ht(i.c)).slice(0,l)){if(i.e<c&&--l,"9999"!=(e=e.slice(l-3,l+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(M(i,i.e+u+2,1),t=!i.times(i).eq(s));break}if(!r&&(M(o,o.e+u+2,0),o.times(o).eq(s))){i=o;break}f+=4,l+=4,r=1}return M(i,i.e+u+1,h,t)},a.toExponential=function(t,e){return null!=t&&(Xt(t,0,Yt),t++),E(this,t,e,1)},a.toFixed=function(t,e){return null!=t&&(Xt(t,0,Yt),t=t+this.e+1),E(this,t,e)},a.toFormat=function(t,e,n){var i,r=this;if(null==n)null!=t&&e&&"object"==typeof e?(n=e,e=null):t&&"object"==typeof t?(n=t,t=e=null):n=m;else if("object"!=typeof n)throw Error(At+"Argument not an object: "+n);if(i=r.toFixed(t,e),r.c){var o,s=i.split("."),a=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||"",h=s[0],c=s[1],f=r.s<0,g=f?h.slice(1):h,d=g.length;if(l&&(o=a,a=l,l=o,d-=o),a>0&&d>0){for(o=d%a||a,h=g.substr(0,o);o<d;o+=a)h+=u+g.substr(o,a);l>0&&(h+=u+g.slice(o)),f&&(h="-"+h)}i=c?h+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):h}return(n.prefix||"")+i+(n.suffix||"")},a.toFraction=function(t){var e,i,r,o,s,a,u,c,f,g,p,y,v=this,m=v.c;if(null!=t&&(!(u=new x(t)).isInteger()&&(u.c||1!==u.s)||u.lt(l)))throw Error(At+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+S(u));if(!m)return new x(v);for(e=new x(l),f=i=new x(l),r=c=new x(l),y=Ht(m),s=e.e=y.length-v.e-1,e.c[0]=Bt[(a=s%Ft)<0?Ft+a:a],t=!t||u.comparedTo(e)>0?s>0?e:f:u,a=d,d=1/0,u=new x(y),c.c[0]=0;g=n(u,e,0,1),1!=(o=i.plus(g.times(r))).comparedTo(t);)i=r,r=o,f=c.plus(g.times(o=f)),c=o,e=u.minus(g.times(o=e)),u=o;return o=n(t.minus(i),r,0,1),c=c.plus(o.times(f)),i=i.plus(o.times(r)),c.s=f.s=v.s,p=n(f,r,s*=2,h).minus(v).abs().comparedTo(n(c,i,s,h).minus(v).abs())<1?[f,r]:[c,i],d=a,p},a.toNumber=function(){return+S(this)},a.toPrecision=function(t,e){return null!=t&&Xt(t,1,Yt),E(this,t,e,2)},a.toString=function(t){var e,n=this,r=n.s,o=n.e;return null===o?r?(e="Infinity",r<0&&(e="-"+e)):e="NaN":(null==t?e=o<=c||o>=f?jt(Ht(n.c),o):Kt(Ht(n.c),o,"0"):10===t&&k?e=Kt(Ht((n=M(new x(n),u+o+1,h)).c),n.e,"0"):(Xt(t,2,_.length,"Base"),e=i(Kt(Ht(n.c),o,"0"),10,t,r,!0)),r<0&&n.c[0]&&(e="-"+e)),e},a.valueOf=a.toJSON=function(){return S(this)},a._isBigNumber=!0,a[Symbol.toStringTag]="BigNumber",a[Symbol.for("nodejs.util.inspect.custom")]=a.valueOf,null!=e&&x.set(e),x}(),Zt=class{constructor(t){r(this,"key"),r(this,"left",null),r(this,"right",null),this.key=t}},Jt=class extends Zt{constructor(t){super(t)}},$t=class{constructor(){r(this,"size",0),r(this,"modificationCount",0),r(this,"splayCount",0)}splay(t){const e=this.root;if(null==e)return this.compare(t,t),-1;let n=null,i=null,r=null,o=null,s=e;const a=this.compare;let l;for(;;)if(l=a(s.key,t),l>0){let e=s.left;if(null==e)break;if(l=a(e.key,t),l>0&&(s.left=e.right,e.right=s,s=e,e=s.left,null==e))break;null==n?i=s:n.left=s,n=s,s=e}else{if(!(l<0))break;{let e=s.right;if(null==e)break;if(l=a(e.key,t),l<0&&(s.right=e.left,e.left=s,s=e,e=s.right,null==e))break;null==r?o=s:r.right=s,r=s,s=e}}return null!=r&&(r.right=s.left,s.left=o),null!=n&&(n.left=s.right,s.right=i),this.root!==s&&(this.root=s,this.splayCount++),l}splayMin(t){let e=t,n=e.left;for(;null!=n;){const t=n;e.left=t.right,t.right=e,e=t,n=e.left}return e}splayMax(t){let e=t,n=e.right;for(;null!=n;){const t=n;e.right=t.left,t.left=e,e=t,n=e.right}return e}_delete(t){if(null==this.root)return null;if(0!=this.splay(t))return null;let e=this.root;const n=e,i=e.left;if(this.size--,null==i)this.root=e.right;else{const t=e.right;e=this.splayMax(i),e.right=t,this.root=e}return this.modificationCount++,n}addNewRoot(t,e){this.size++,this.modificationCount++;const n=this.root;null!=n?(e<0?(t.left=n,t.right=n.right,n.right=null):(t.right=n,t.left=n.left,n.left=null),this.root=t):this.root=t}_first(){const t=this.root;return null==t?null:(this.root=this.splayMin(t),this.root)}_last(){const t=this.root;return null==t?null:(this.root=this.splayMax(t),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(t){return this.validKey(t)&&0==this.splay(t)}defaultCompare(){return(t,e)=>t<e?-1:t>e?1:0}wrap(){return{getRoot:()=>this.root,setRoot:t=>{this.root=t},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:t=>{this.splayCount=t},splay:t=>this.splay(t),has:t=>this.has(t)}}},Qt=class t extends $t{constructor(t,n){super(),r(this,"root",null),r(this,"compare"),r(this,"validKey"),r(this,e,"[object Set]"),this.compare=t??this.defaultCompare(),this.validKey=n??(t=>null!=t&&null!=t)}delete(t){return!!this.validKey(t)&&null!=this._delete(t)}deleteAll(t){for(const e of t)this.delete(e)}forEach(t){const e=this[Symbol.iterator]();let n;for(;n=e.next(),!n.done;)t(n.value,n.value,this)}add(t){const e=this.splay(t);return 0!=e&&this.addNewRoot(new Jt(t),e),this}addAndReturn(t){const e=this.splay(t);return 0!=e&&this.addNewRoot(new Jt(t),e),this.root.key}addAll(t){for(const e of t)this.add(e)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)<0)return this.root.key;let e=this.root.left;if(null==e)return null;let n=e.right;for(;null!=n;)e=n,n=e.right;return e.key}firstAfter(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)>0)return this.root.key;let e=this.root.right;if(null==e)return null;let n=e.left;for(;null!=n;)e=n,n=e.left;return e.key}retainAll(e){const n=new t(this.compare,this.validKey),i=this.modificationCount;for(const t of e){if(i!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(t)&&0==this.splay(t)&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(t){if(!this.validKey(t))return null;return 0!=this.splay(t)?null:this.root.key}intersection(e){const n=new t(this.compare,this.validKey);for(const t of this)e.has(t)&&n.add(t);return n}difference(e){const n=new t(this.compare,this.validKey);for(const t of this)e.has(t)||n.add(t);return n}union(t){const e=this.clone();return e.addAll(t),e}clone(){const e=new t(this.compare,this.validKey);return e.size=this.size,e.root=this.copyNode(this.root),e}copyNode(t){if(null==t)return null;const e=new Jt(t.key);return function t(e,n){let i,r;do{if(i=e.left,r=e.right,null!=i){const e=new Jt(i.key);n.left=e,t(i,e)}if(null!=r){const t=new Jt(r.key);n.right=t,e=r,n=t}}while(null!=r)}(t,e),e}toSet(){return this.clone()}entries(){return new ne(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(n=Symbol.iterator,e=Symbol.toStringTag,n)](){return new ee(this.wrap())}},te=class{constructor(t){r(this,"tree"),r(this,"path",new Array),r(this,"modificationCount",null),r(this,"splayCount"),this.tree=t,this.splayCount=t.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;const t=this.path[this.path.length-1];return this.getValue(t)}rebuildPath(t){this.path.splice(0,this.path.length),this.tree.splay(t),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(t){for(;null!=t;)this.path.push(t),t=t.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let t=this.tree.getRoot();for(;null!=t;)this.path.push(t),t=t.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 t=this.path[this.path.length-1],e=t.right;if(null!=e){for(;null!=e;)this.path.push(e),e=e.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===t;)t=this.path.pop();return this.path.length>0}},ee=class extends te{getValue(t){return t.key}},ne=class extends te{getValue(t){return[t.key,t.key]}},ie=t=>()=>t,re=t=>{const e=t?(e,n)=>n.minus(e).abs().isLessThanOrEqualTo(t):ie(!1);return(t,n)=>e(t,n)?0:t.comparedTo(n)};function oe(t){const e=t?(e,n,i,r,o)=>e.exponentiatedBy(2).isLessThanOrEqualTo(r.minus(n).exponentiatedBy(2).plus(o.minus(i).exponentiatedBy(2)).times(t)):ie(!1);return(t,n,i)=>{const r=t.x,o=t.y,s=i.x,a=i.y,l=o.minus(a).times(n.x.minus(s)).minus(r.minus(s).times(n.y.minus(a)));return e(l,r,o,s,a)?0:l.comparedTo(0)}}var se=t=>t,ae=t=>{if(t){const e=new Qt(re(t)),n=new Qt(re(t)),i=(t,e)=>e.addAndReturn(t),r=t=>({x:i(t.x,e),y:i(t.y,n)});return r({x:new Wt(0),y:new Wt(0)}),r}return se},le=t=>({set:t=>{ue=le(t)},reset:()=>le(t),compare:re(t),snap:ae(t),orient:oe(t)}),ue=le(),he=(t,e)=>t.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(t.ur.x)&&t.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(t.ur.y),ce=(t,e)=>{if(e.ur.x.isLessThan(t.ll.x)||t.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(t.ll.y)||t.ur.y.isLessThan(e.ll.y))return null;const n=t.ll.x.isLessThan(e.ll.x)?e.ll.x:t.ll.x,i=t.ur.x.isLessThan(e.ur.x)?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y.isLessThan(e.ll.y)?e.ll.y:t.ll.y},ur:{x:i,y:t.ur.y.isLessThan(e.ur.y)?t.ur.y:e.ur.y}}},fe=(t,e)=>t.x.times(e.y).minus(t.y.times(e.x)),ge=(t,e)=>t.x.times(e.x).plus(t.y.times(e.y)),de=t=>ge(t,t).sqrt(),pe=(t,e,n)=>{const i={x:e.x.minus(t.x),y:e.y.minus(t.y)},r={x:n.x.minus(t.x),y:n.y.minus(t.y)};return fe(r,i).div(de(r)).div(de(i))},ye=(t,e,n)=>{const i={x:e.x.minus(t.x),y:e.y.minus(t.y)},r={x:n.x.minus(t.x),y:n.y.minus(t.y)};return ge(r,i).div(de(r)).div(de(i))},ve=(t,e,n)=>e.y.isZero()?null:{x:t.x.plus(e.x.div(e.y).times(n.minus(t.y))),y:n},me=(t,e,n)=>e.x.isZero()?null:{x:n,y:t.y.plus(e.y.div(e.x).times(n.minus(t.x)))},_e=class t{constructor(t,e){r(this,"point"),r(this,"isLeft"),r(this,"segment"),r(this,"otherSE"),r(this,"consumedBy"),void 0===t.events?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}static compare(e,n){const i=t.comparePoints(e.point,n.point);return 0!==i?i:(e.point!==n.point&&e.link(n),e.isLeft!==n.isLeft?e.isLeft?1:-1:be.compare(e.segment,n.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");const e=t.point.events;for(let n=0,i=e.length;n<i;n++){const t=e[n];this.point.events.push(t),t.point=this.point}this.checkForConsuming()}checkForConsuming(){const t=this.point.events.length;for(let e=0;e<t;e++){const n=this.point.events[e];if(void 0===n.segment.consumedBy)for(let i=e+1;i<t;i++){const t=this.point.events[i];void 0===t.consumedBy&&(n.otherSE.point.events===t.otherSE.point.events&&n.segment.consume(t.segment))}}}getAvailableLinkedEvents(){const t=[];for(let e=0,n=this.point.events.length;e<n;e++){const n=this.point.events[e];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&t.push(n)}return t}getLeftmostComparator(t){const e=new Map,n=n=>{const i=n.otherSE;e.set(n,{sine:pe(this.point,t.point,i.point),cosine:ye(this.point,t.point,i.point)})};return(t,i)=>{e.has(t)||n(t),e.has(i)||n(i);const{sine:r,cosine:o}=e.get(t),{sine:s,cosine:a}=e.get(i);return r.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?o.isLessThan(a)?1:o.isGreaterThan(a)?-1:0:r.isLessThan(0)&&s.isLessThan(0)?o.isLessThan(a)?-1:o.isGreaterThan(a)?1:0:s.isLessThan(r)?-1:s.isGreaterThan(r)?1:0}}},ke=class t{constructor(t){r(this,"events"),r(this,"poly"),r(this,"_isExteriorRing"),r(this,"_enclosingRing"),this.events=t;for(let e=0,n=t.length;e<n;e++)t[e].segment.ringOut=this;this.poly=null}static factory(e){const n=[];for(let i=0,r=e.length;i<r;i++){const r=e[i];if(!r.isInResult()||r.ringOut)continue;let o=null,s=r.leftSE,a=r.rightSE;const l=[s],u=s.point,h=[];for(;o=s,s=a,l.push(s),s.point!==u;)for(;;){const e=s.getAvailableLinkedEvents();if(0===e.length){const t=l[0].point,e=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${t.x}, ${t.y}]. Last matching segment found ends at [${e.x}, ${e.y}].`)}if(1===e.length){a=e[0].otherSE;break}let i=null;for(let t=0,n=h.length;t<n;t++)if(h[t].point===s.point){i=t;break}if(null!==i){const e=h.splice(i)[0],r=l.splice(e.index);r.unshift(r[0].otherSE),n.push(new t(r.reverse()));continue}h.push({index:l.length,point:s.point});const r=s.getLeftmostComparator(o);a=e.sort(r)[0].otherSE;break}n.push(new t(l))}return n}getGeom(){let t=this.events[0].point;const e=[t];for(let l=1,u=this.events.length-1;l<u;l++){const n=this.events[l].point,i=this.events[l+1].point;0!==ue.orient(n,t,i)&&(e.push(n),t=n)}if(1===e.length)return null;const n=e[0],i=e[1];0===ue.orient(n,t,i)&&e.shift(),e.push(e[0]);const r=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:e.length-1,s=this.isExteriorRing()?e.length:-1,a=[];for(let l=o;l!=s;l+=r)a.push([e[l].x.toNumber(),e[l].y.toNumber()]);return a}isExteriorRing(){if(void 0===this._isExteriorRing){const t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){var t,e;let n=this.events[0];for(let o=1,s=this.events.length;o<s;o++){const t=this.events[o];_e.compare(n,t)>0&&(n=t)}let i=n.segment.prevInResult(),r=i?i.prevInResult():null;for(;;){if(!i)return null;if(!r)return i.ringOut;if(r.ringOut!==i.ringOut)return(null==(t=r.ringOut)?void 0:t.enclosingRing())!==i.ringOut?i.ringOut:null==(e=i.ringOut)?void 0:e.enclosingRing();i=r.prevInResult(),r=i?i.prevInResult():null}}},xe=class{constructor(t){r(this,"exteriorRing"),r(this,"interiorRings"),this.exteriorRing=t,t.poly=this,this.interiorRings=[]}addInterior(t){this.interiorRings.push(t),t.poly=this}getGeom(){const t=this.exteriorRing.getGeom();if(null===t)return null;const e=[t];for(let n=0,i=this.interiorRings.length;n<i;n++){const t=this.interiorRings[n].getGeom();null!==t&&e.push(t)}return e}},Ee=class{constructor(t){r(this,"rings"),r(this,"polys"),this.rings=t,this.polys=this._composePolys(t)}getGeom(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getGeom();null!==n&&t.push(n)}return t}_composePolys(t){var e;const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];if(!r.poly)if(r.isExteriorRing())n.push(new xe(r));else{const t=r.enclosingRing();(null==t?void 0:t.poly)||n.push(new xe(t)),null==(e=null==t?void 0:t.poly)||e.addInterior(r)}}return n}},we=class{constructor(t,e=be.compare){r(this,"queue"),r(this,"tree"),r(this,"segments"),this.queue=t,this.tree=new Qt(e),this.segments=[]}process(t){const e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.delete(t.otherSE):this.tree.delete(e),n;t.isLeft&&this.tree.add(e);let i=e,r=e;do{i=this.tree.lastBefore(i)}while(null!=i&&null!=i.consumedBy);do{r=this.tree.firstAfter(r)}while(null!=r&&null!=r.consumedBy);if(t.isLeft){let o=null;if(i){const t=i.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(o=t),!i.isAnEndpoint(t))){const e=this._splitSafely(i,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}let s=null;if(r){const t=r.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(s=t),!r.isAnEndpoint(t))){const e=this._splitSafely(r,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}if(null!==o||null!==s){let t=null;if(null===o)t=s;else if(null===s)t=o;else{t=_e.comparePoints(o,s)<=0?o:s}this.queue.delete(e.rightSE),n.push(e.rightSE);const i=e.split(t);for(let e=0,r=i.length;e<r;e++)n.push(i[e])}n.length>0?(this.tree.delete(e),n.push(t)):(this.segments.push(e),e.prev=i)}else{if(i&&r){const t=i.getIntersection(r);if(null!==t){if(!i.isAnEndpoint(t)){const e=this._splitSafely(i,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}if(!r.isAnEndpoint(t)){const e=this._splitSafely(r,t);for(let t=0,i=e.length;t<i;t++)n.push(e[t])}}}this.tree.delete(e)}return n}_splitSafely(t,e){this.tree.delete(t);const n=t.rightSE;this.queue.delete(n);const i=t.split(e);return i.push(n),void 0===t.consumedBy&&this.tree.add(t),i}},Ie=new class{constructor(){r(this,"type"),r(this,"numMultiPolys")}run(t,e,n){Ie.type=t;const i=[new Pe(e,!0)];for(let l=0,u=n.length;l<u;l++)i.push(new Pe(n[l],!1));if(Ie.numMultiPolys=i.length,"difference"===Ie.type){const t=i[0];let e=1;for(;e<i.length;)null!==ce(i[e].bbox,t.bbox)?e++:i.splice(e,1)}if("intersection"===Ie.type)for(let l=0,u=i.length;l<u;l++){const t=i[l];for(let e=l+1,n=i.length;e<n;e++)if(null===ce(t.bbox,i[e].bbox))return[]}const r=new Qt(_e.compare);for(let l=0,u=i.length;l<u;l++){const t=i[l].getSweepEvents();for(let e=0,n=t.length;e<n;e++)r.add(t[e])}const o=new we(r);let s=null;for(0!=r.size&&(s=r.first(),r.delete(s));s;){const t=o.process(s);for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0===n.consumedBy&&r.add(n)}0!=r.size?(s=r.first(),r.delete(s)):s=null}ue.reset();const a=ke.factory(o.segments);return new Ee(a).getGeom()}},Me=Ie,Se=0,be=class t{constructor(t,e,n,i){r(this,"id"),r(this,"leftSE"),r(this,"rightSE"),r(this,"rings"),r(this,"windings"),r(this,"ringOut"),r(this,"consumedBy"),r(this,"prev"),r(this,"_prevInResult"),r(this,"_beforeState"),r(this,"_afterState"),r(this,"_isInResult"),this.id=++Se,this.leftSE=t,t.segment=this,t.otherSE=e,this.rightSE=e,e.segment=this,e.otherSE=t,this.rings=n,this.windings=i}static compare(t,e){const n=t.leftSE.point.x,i=e.leftSE.point.x,r=t.rightSE.point.x,o=e.rightSE.point.x;if(o.isLessThan(n))return 1;if(r.isLessThan(i))return-1;const s=t.leftSE.point.y,a=e.leftSE.point.y,l=t.rightSE.point.y,u=e.rightSE.point.y;if(n.isLessThan(i)){if(a.isLessThan(s)&&a.isLessThan(l))return 1;if(a.isGreaterThan(s)&&a.isGreaterThan(l))return-1;const n=t.comparePoint(e.leftSE.point);if(n<0)return 1;if(n>0)return-1;const i=e.comparePoint(t.rightSE.point);return 0!==i?i:-1}if(n.isGreaterThan(i)){if(s.isLessThan(a)&&s.isLessThan(u))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(u))return 1;const n=e.comparePoint(t.leftSE.point);if(0!==n)return n;const i=t.comparePoint(e.rightSE.point);return i<0?1:i>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(r.isLessThan(o)){const n=e.comparePoint(t.rightSE.point);if(0!==n)return n}if(r.isGreaterThan(o)){const n=t.comparePoint(e.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!r.eq(o)){const t=l.minus(s),e=r.minus(n),h=u.minus(a),c=o.minus(i);if(t.isGreaterThan(e)&&h.isLessThan(c))return 1;if(t.isLessThan(e)&&h.isGreaterThan(c))return-1}return r.isGreaterThan(o)?1:r.isLessThan(o)||l.isLessThan(u)?-1:l.isGreaterThan(u)?1:t.id<e.id?-1:t.id>e.id?1:0}static fromRing(e,n,i){let r,o,s;const a=_e.comparePoints(e,n);if(a<0)r=e,o=n,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);r=n,o=e,s=-1}const l=new _e(r,!0),u=new _e(o,!1);return new t(l,u,[i],[s])}replaceRightSE(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const 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 ue.orient(this.leftSE.point,t,this.rightSE.point)}getIntersection(t){const e=this.bbox(),n=t.bbox(),i=ce(e,n);if(null===i)return null;const r=this.leftSE.point,o=this.rightSE.point,s=t.leftSE.point,a=t.rightSE.point,l=he(e,s)&&0===this.comparePoint(s),u=he(n,r)&&0===t.comparePoint(r),h=he(e,a)&&0===this.comparePoint(a),c=he(n,o)&&0===t.comparePoint(o);if(u&&l)return c&&!h?o:!c&&h?a:null;if(u)return h&&r.x.eq(a.x)&&r.y.eq(a.y)?null:r;if(l)return c&&o.x.eq(s.x)&&o.y.eq(s.y)?null:s;if(c&&h)return null;if(c)return o;if(h)return a;const f=((t,e,n,i)=>{if(e.x.isZero())return me(n,i,t.x);if(i.x.isZero())return me(t,e,n.x);if(e.y.isZero())return ve(n,i,t.y);if(i.y.isZero())return ve(t,e,n.y);const r=fe(e,i);if(r.isZero())return null;const o={x:n.x.minus(t.x),y:n.y.minus(t.y)},s=fe(o,e).div(r),a=fe(o,i).div(r),l=t.x.plus(a.times(e.x)),u=n.x.plus(s.times(i.x)),h=t.y.plus(a.times(e.y)),c=n.y.plus(s.times(i.y));return{x:l.plus(u).div(2),y:h.plus(c).div(2)}})(r,this.vector(),s,t.vector());return null===f?null:he(i,f)?ue.snap(f):null}split(e){const n=[],i=void 0!==e.events,r=new _e(e,!0),o=new _e(e,!1),s=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(r);const a=new t(r,s,this.rings.slice(),this.windings.slice());return _e.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),_e.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),o.checkForConsuming()),n}swapEvents(){const t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,n=this.windings.length;e<n;e++)this.windings[e]*=-1}consume(e){let n=this,i=e;for(;n.consumedBy;)n=n.consumedBy;for(;i.consumedBy;)i=i.consumedBy;const r=t.compare(n,i);if(0!==r){if(r>0){const t=n;n=i,i=t}if(n.prev===i){const t=n;n=i,i=t}for(let t=0,e=i.rings.length;t<e;t++){const e=i.rings[t],r=i.windings[t],o=n.rings.indexOf(e);-1===o?(n.rings.push(e),n.windings.push(r)):n.windings[o]+=r}i.rings=null,i.windings=null,i.consumedBy=n,i.leftSE.consumedBy=n.leftSE,i.rightSE.consumedBy=n.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};const e=this._afterState.rings,n=this._afterState.windings,i=this._afterState.multiPolys;for(let s=0,a=this.rings.length;s<a;s++){const t=this.rings[s],i=this.windings[s],r=e.indexOf(t);-1===r?(e.push(t),n.push(i)):n[r]+=i}const r=[],o=[];for(let s=0,a=e.length;s<a;s++){if(0===n[s])continue;const t=e[s],i=t.poly;if(-1===o.indexOf(i))if(t.isExterior)r.push(i);else{-1===o.indexOf(i)&&o.push(i);const e=r.indexOf(t.poly);-1!==e&&r.splice(e,1)}}for(let s=0,a=r.length;s<a;s++){const t=r[s].multiPoly;-1===i.indexOf(t)&&i.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(Me.type){case"union":{const n=0===t.length,i=0===e.length;this._isInResult=n!==i;break}case"intersection":{let n,i;t.length<e.length?(n=t.length,i=e.length):(n=e.length,i=t.length),this._isInResult=i===Me.numMultiPolys&&n<i;break}case"xor":{const n=Math.abs(t.length-e.length);this._isInResult=n%2==1;break}case"difference":{const n=t=>1===t.length&&t[0].isSubject;this._isInResult=n(t)!==n(e);break}}return this._isInResult}},Ne=class{constructor(t,e,n){if(r(this,"poly"),r(this,"isExterior"),r(this,"segments"),r(this,"bbox"),!Array.isArray(t)||0===t.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=n,this.segments=[],"number"!=typeof t[0][0]||"number"!=typeof t[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const i=ue.snap({x:new Wt(t[0][0]),y:new Wt(t[0][1])});this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};let o=i;for(let r=1,s=t.length;r<s;r++){if("number"!=typeof t[r][0]||"number"!=typeof t[r][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const e=ue.snap({x:new Wt(t[r][0]),y:new Wt(t[r][1])});e.x.eq(o.x)&&e.y.eq(o.y)||(this.segments.push(be.fromRing(o,e,this)),e.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.x),e.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.y),e.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.x),e.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.y),o=e)}i.x.eq(o.x)&&i.y.eq(o.y)||this.segments.push(be.fromRing(o,i,this))}getSweepEvents(){const t=[];for(let e=0,n=this.segments.length;e<n;e++){const n=this.segments[e];t.push(n.leftSE),t.push(n.rightSE)}return t}},Le=class{constructor(t,e){if(r(this,"multiPoly"),r(this,"exteriorRing"),r(this,"interiorRings"),r(this,"bbox"),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Ne(t[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let n=1,i=t.length;n<i;n++){const e=new Ne(t[n],this,!1);e.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.bbox.ll.x),e.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.bbox.ll.y),e.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.bbox.ur.x),e.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.bbox.ur.y),this.interiorRings.push(e)}this.multiPoly=e}getSweepEvents(){const t=this.exteriorRing.getSweepEvents();for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getSweepEvents();for(let e=0,i=n.length;e<i;e++)t.push(n[e])}return t}},Pe=class{constructor(t,e){if(r(this,"isSubject"),r(this,"polys"),r(this,"bbox"),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof t[0][0][0]&&(t=[t])}catch(n){}this.polys=[],this.bbox={ll:{x:new Wt(Number.POSITIVE_INFINITY),y:new Wt(Number.POSITIVE_INFINITY)},ur:{x:new Wt(Number.NEGATIVE_INFINITY),y:new Wt(Number.NEGATIVE_INFINITY)}};for(let i=0,r=t.length;i<r;i++){const e=new Le(t[i],this);e.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=e.bbox.ll.x),e.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=e.bbox.ll.y),e.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=e.bbox.ur.x),e.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=e.bbox.ur.y),this.polys.push(e)}this.isSubject=e}getSweepEvents(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getSweepEvents();for(let e=0,i=n.length;e<i;e++)t.push(n[e])}return t}};ue.set;var Ce=function(t,e={}){const n=[];if(q(t,t=>{n.push(t.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const i=((t,...e)=>Me.run("union",t,e))(n[0],...n.slice(1));return 0===i.length?null:1===i.length?C(i[0],e.properties):A(i,e.properties)};var Te=function(t,e={}){const n=[];if(q(t,t=>{n.push(t.coordinates)}),n.length<2)throw new Error("Must specify at least 2 geometries");const i=((t,...e)=>Me.run("intersection",t,e))(n[0],...n.slice(1));return 0===i.length?null:1===i.length?C(i[0],e.properties):A(i,e.properties)};var Oe=function(t){const e=[];if(q(t,t=>{e.push(t.coordinates)}),e.length<2)throw new Error("Must have at least two features");const n=t.features[0].properties||{},i=((t,...e)=>Me.run("difference",t,e))(e[0],...e.slice(1));return 0===i.length?null:1===i.length?C(i[0],n):A(i,n)};var Ae=function(t){const e=[];return"FeatureCollection"===t.type?B(t,function(t){G(t,function(n){e.push(P(n,t.properties))})}):"Feature"===t.type?G(t,function(n){e.push(P(n,t.properties))}):G(t,function(t){e.push(P(t))}),O(e)};function Re(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return G(t,t=>{n[0]>t[0]&&(n[0]=t[0]),n[1]>t[1]&&(n[1]=t[1]),n[2]<t[0]&&(n[2]=t[0]),n[3]<t[1]&&(n[3]=t[1])}),n}var De,Fe={exports:{}};var Ge=(De||(De=1,Fe.exports=function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e(t,e,n){return e=l(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(e,n||[],l(t).constructor):e.apply(t,n))}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){if(h())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var r=new(t.bind.apply(t,i));return n&&c(r,n.prototype),r}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,d(i.key),i)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=p(t))||e){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function a(){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},a.apply(null,arguments)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!t})()}function c(t,e){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e,n,i){var r=a(l(1&i?t.prototype:t),e,n);return 2&i&&"function"==typeof r?function(t){return r.apply(n,t)}:r}function g(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return i(t,arguments,l(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},y(t)}var v=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=t.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=t.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==t.JOIN_ROUND&&(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(t){this._joinStyle=t}},{key:"setSimplifyFactor",value:function(t){this._simplifyFactor=t<0?0:t}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(t){this._endCapStyle=t}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(t){this._mitreLimit=t}},{key:"setSingleSided",value:function(t){this._isSingleSided=t}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(i)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}])}();v.CAP_ROUND=1,v.CAP_FLAT=2,v.CAP_SQUARE=3,v.JOIN_ROUND=1,v.JOIN_MITRE=2,v.JOIN_BEVEL=3,v.DEFAULT_QUADRANT_SEGMENTS=8,v.DEFAULT_MITRE_LIMIT=5,v.DEFAULT_SIMPLIFY_FACTOR=.01;var m=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({Exception:i})[0],r}return u(i,t),o(i,[{key:"toString",value:function(){return this.message}}])}(y(Error)),_=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({IllegalArgumentException:i})[0],r}return u(i,t),o(i)}(m),k=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]);function x(){}function E(){}function w(){}var I,M,S,b,N,L,P,C,T=o(function t(){n(this,t)},null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}]),O=o(function t(e,i){n(this,t),this.low=i||0,this.high=e||0},null,[{key:"toBinaryString",value:function(t){var e,n="";for(e=2147483648;e>0;e>>>=1)n+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)n+=(t.low&e)===e?"1":"0";return n}}]);function A(){}function R(){}A.NaN=NaN,A.isNaN=function(t){return Number.isNaN(t)},A.isInfinite=function(t){return!Number.isFinite(t)},A.MAX_VALUE=Number.MAX_VALUE,A.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,A.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(L=2146435072,P=new Float64Array(1),C=new Int32Array(P.buffer),A.doubleToLongBits=function(t){P[0]=t;var e=0|C[0],n=0|C[1];return(n&L)===L&&1048575&n&&0!==e&&(e=0,n=2146959360),new O(n,e)},A.longBitsToDouble=function(t){return C[0]=t.low,C[1]=t.high,P[0]}):(I=1023,M=Math.log2,S=Math.floor,b=Math.pow,N=function(){for(var t=53;t>0;t--){var e=b(2,t)-1;if(S(M(e))+1===t)return e}return 0}(),A.doubleToLongBits=function(t){var e,n,i,r,o,s,a,l,u;if(t<0||1/t===Number.NEGATIVE_INFINITY?(s=1<<31,t=-t):s=0,0===t)return new O(l=s,u=0);if(t===1/0)return new O(l=2146435072|s,u=0);if(t!=t)return new O(l=2146959360,u=0);if(r=0,u=0,(e=S(t))>1)if(e<=N)(r=S(M(e)))<=20?(u=0,l=e<<20-r&1048575):(u=e%(n=b(2,i=r-20))<<32-i,l=e/n&1048575);else for(i=e,u=0;0!==(i=S(n=i/2));)r++,u>>>=1,u|=(1&l)<<31,l>>>=1,n!==i&&(l|=524288);if(a=r+I,o=0===e,e=t-e,r<52&&0!==e)for(i=0;;){if((n=2*e)>=1?(e=n-1,o?(a--,o=!1):(i<<=1,i|=1,r++)):(e=n,o?0==--a&&(r++,o=!1):(i<<=1,r++)),20===r)l|=i,i=0;else if(52===r){u|=i;break}if(1===n){r<20?l|=i<<20-r:r<52&&(u|=i<<52-r);break}}return l|=a<<20,new O(l|=s,u)},A.longBitsToDouble=function(t){var e,n,i,r,o=t.high,s=t.low,a=o&1<<31?-1:1;for(i=((2146435072&o)>>20)-I,r=0,n=1<<19,e=1;e<=20;e++)o&n&&(r+=b(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)s&n&&(r+=b(2,-e)),n>>>=1;if(-1023===i){if(0===r)return 0*a;i=-1022}else{if(1024===i)return 0===r?a/0:NaN;r+=1}return a*r*b(2,i)});var D=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({RuntimeException:i})[0],r}return u(i,t),o(i)}(m),F=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,null,[{key:"constructor_",value:function(){if(0===arguments.length)D.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];D.constructor_.call(this,t)}}}])}(D),G=function(){function t(){n(this,t)}return o(t,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)t.shouldNeverReachHere(null);else if(1===arguments.length){var e=arguments[0];throw new F("Should never reach here"+(null!==e?": "+e:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var e=arguments[0];t.isTrue(e,null)}else if(2===arguments.length){var n=arguments[1];if(!arguments[0])throw null===n?new F:new F(n)}}},{key:"equals",value:function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];t.equals(e,n,null)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];if(!r.equals(i))throw new F("Expected "+i+" but encountered "+r+(null!==o?": "+o:""))}}}])}(),B=new ArrayBuffer(8),q=new Float64Array(B),Y=new Int32Array(B),z=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getM",value:function(){return A.NaN}},{key:"setOrdinate",value:function(e,n){switch(e){case t.X:this.x=n;break;case t.Y:this.y=n;break;case t.Z:this.setZ(n);break;default:throw new _("Invalid ordinate index: "+e)}}},{key:"equals2D",value:function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!T.equalsWithTolerance(this.x,e.x,n)&&!!T.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(e){throw new _("Invalid ordinate index: "+t.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(e){switch(e){case t.X:return this.x;case t.Y:return this.y;case t.Z:return this.getZ()}throw new _("Invalid ordinate index: "+e)}},{key:"equals3D",value:function(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||A.isNaN(this.getZ())&&A.isNaN(t.getZ()))}},{key:"equals",value:function(e){return e instanceof t&&this.equals2D(e)}},{key:"equalInZ",value:function(t,e){return T.equalsWithTolerance(this.getZ(),t.getZ(),e)}},{key:"setX",value:function(t){this.x=t}},{key:"compareTo",value:function(t){var e=t;return this.x<e.x?-1:this.x>e.x?1:this.y<e.y?-1:this.y>e.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(t){this.z=t}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return G.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new t(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+i*i)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(t){this.y=t}},{key:"distance",value:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var e=17;return 37*(e=37*e+t.hashCode(this.x))+t.hashCode(this.y)}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}},{key:"interfaces_",get:function(){return[x,E,w]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)t.constructor_.call(this,0,0);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.x,e.y,e.getZ())}else if(2===arguments.length){var n=arguments[0],i=arguments[1];t.constructor_.call(this,n,i,t.NULL_ORDINATE)}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this.x=r,this.y=o,this.z=s}}},{key:"hashCode",value:function(t){return q[0]=t,Y[0]^Y[1]}}])}(),H=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compare",value:function(e,n){var i=t.compare(e.x,n.x);if(0!==i)return i;var r=t.compare(e.y,n.y);return 0!==r?r:this._dimensionsToTest<=2?0:t.compare(e.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[R]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)t.constructor_.call(this,2);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new _("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}},{key:"compare",value:function(t,e){return t<e?-1:t>e?1:A.isNaN(t)?A.isNaN(e)?0:-1:A.isNaN(e)?1:0}}])}();z.DimensionalComparator=H,z.NULL_ORDINATE=A.NaN,z.X=0,z.Y=1,z.Z=2,z.M=3;var U=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.isNull()?n.isNull():this._maxx===n.getMaxX()&&this._maxy===n.getMaxY()&&this._minx===n.getMinX()&&this._miny===n.getMinY()}},{key:"intersection",value:function(e){if(this.isNull()||e.isNull()||!this.intersects(e))return new t;var n=this._minx>e._minx?this._minx:e._minx,i=this._miny>e._miny?this._miny:e._miny;return new t(n,this._maxx<e._maxx?this._maxx:e._maxx,i,this._maxy<e._maxy?this._maxy:e._maxy)}},{key:"isNull",value:function(){return this._maxx<this._minx}},{key:"getMaxX",value:function(){return this._maxx}},{key:"covers",value:function(){if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];return this.covers(e.x,e.y)}if(arguments[0]instanceof t){var n=arguments[0];return!this.isNull()&&!n.isNull()&&n.getMinX()>=this._minx&&n.getMaxX()<=this._maxx&&n.getMinY()>=this._miny&&n.getMaxY()<=this._maxy}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return!this.isNull()&&i>=this._minx&&i<=this._maxx&&r>=this._miny&&r<=this._maxy}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return!this.isNull()&&!e.isNull()&&!(e._minx>this._maxx||e._maxx<this._minx||e._miny>this._maxy||e._maxy<this._miny)}if(arguments[0]instanceof z){var n=arguments[0];return this.intersects(n.x,n.y)}}else if(2===arguments.length){if(arguments[0]instanceof z&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1];return!(this.isNull()||(i.x<r.x?i.x:r.x)>this._maxx||(i.x>r.x?i.x:r.x)<this._minx||(i.y<r.y?i.y:r.y)>this._maxy||(i.y>r.y?i.y:r.y)<this._miny)}if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return!this.isNull()&&!(o>this._maxx||o<this._minx||s>this._maxy||s<this._miny)}}}},{key:"getMinY",value:function(){return this._miny}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return Math.sqrt(t*t+e*e)}},{key:"getMinX",value:function(){return this._minx}},{key:"expandToInclude",value:function(){if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.expandToInclude(e.x,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];if(n.isNull())return null;this.isNull()?(this._minx=n.getMinX(),this._maxx=n.getMaxX(),this._miny=n.getMinY(),this._maxy=n.getMaxY()):(n._minx<this._minx&&(this._minx=n._minx),n._maxx>this._maxx&&(this._maxx=n._maxx),n._miny<this._miny&&(this._miny=n._miny),n._maxy>this._maxy&&(this._maxy=n._maxy))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.isNull()?(this._minx=i,this._maxx=i,this._miny=r,this._maxy=r):(i<this._minx&&(this._minx=i),i>this._maxx&&(this._maxx=i),r<this._miny&&(this._miny=r),r>this._maxy&&(this._maxy=r))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t<e?t:e}},{key:"getWidth",value:function(){return this.isNull()?0:this._maxx-this._minx}},{key:"compareTo",value:function(t){var e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this._minx<e._minx?-1:this._minx>e._minx?1:this._miny<e._miny?-1:this._miny>e._miny?1:this._maxx<e._maxx?-1:this._maxx>e._maxx?1:this._maxy<e._maxy?-1:this._maxy>e._maxy?1:0}},{key:"translate",value:function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}},{key:"copy",value:function(){return new t(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(t){return!(!this.isNull()&&!t.isNull())||t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny}},{key:"getHeight",value:function(){return this.isNull()?0:this._maxy-this._miny}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e}},{key:"expandBy",value:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.covers(e)}if(arguments[0]instanceof z){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return this.covers(i,r)}}},{key:"centre",value:function(){return this.isNull()?null:new z((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this._minx=n._minx,this._maxx=n._maxx,this._miny=n._miny,this._maxy=n._maxy}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];o<s?(this._minx=o,this._maxx=s):(this._minx=s,this._maxx=o),a<l?(this._miny=a,this._maxy=l):(this._miny=l,this._maxy=a)}}},{key:"getMaxY",value:function(){return this._maxy}},{key:"distance",value:function(t){if(this.intersects(t))return 0;var e=0;this._maxx<t._minx?e=t._minx-this._maxx:this._minx>t._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxy<t._miny?n=t._miny-this._maxy:this._miny>t._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*(t=37*(t=37*t+z.hashCode(this._minx))+z.hashCode(this._maxx))+z.hashCode(this._miny))+z.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[x,w]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof z){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];this.init(o,s,a,l)}}},{key:"intersects",value:function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.x<e.x?t.x:e.x)&&n.x<=(t.x>e.x?t.x:e.x)&&n.y>=(t.y<e.y?t.y:e.y)&&n.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),l=Math.max(o.x,s.x),u=Math.min(i.x,r.x),h=Math.max(i.x,r.x);return!(u>l||h<a||(a=Math.min(o.y,s.y),l=Math.max(o.y,s.y),u=Math.min(i.y,r.y),h=Math.max(i.y,r.y),u>l||h<a))}}}])}(),X=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this._factory}},{key:"getGeometryN",value:function(t){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(t){return this===t||this.equalsExact(t,0)}},{key:"geometryChanged",value:function(){this.apply(t.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this._envelope=null}},{key:"equalsNorm",value:function(t){return null!==t&&this.norm().equalsExact(t.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var t;if(1===arguments.length){var e=arguments[0];return t=e,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(e)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return t=n,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(n,i)}}},{key:"getUserData",value:function(){return this._userData}},{key:"getSRID",value:function(){return this._SRID}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(e){if(e.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION)throw new _("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(t,e,n){return 0===n?t.equals(e):t.distance(e)<=n}},{key:"norm",value:function(){var t=this.copy();return t.normalize(),t}},{key:"reverse",value:function(){var t=this.reverseInternal();return null!=this.envelope&&(t.envelope=this.envelope.copy()),t.setSRID(this.getSRID()),t}},{key:"copy",value:function(){var t=this.copyInternal();return t.envelope=null==this._envelope?null:this._envelope.copy(),t._SRID=this._SRID,t._userData=this._userData,t}},{key:"getPrecisionModel",value:function(){return this._factory.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new U(this._envelope)}},{key:"setSRID",value:function(t){this._SRID=t}},{key:"setUserData",value:function(t){this._userData=t}},{key:"compare",value:function(t,e){for(var n=t.iterator(),i=e.iterator();n.hasNext()&&i.hasNext();){var r=n.next(),o=i.next(),s=r.compareTo(o);if(0!==s)return s}return n.hasNext()?1:i.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(t){return this.getClass()===t.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===t.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===t.TYPECODE_MULTIPOINT||this.getTypeCode()===t.TYPECODE_MULTILINESTRING||this.getTypeCode()===t.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[E,x,w]}},{key:"getClass",value:function(){return t}}],[{key:"hasNonEmptyElements",value:function(t){for(var e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(t){for(var e=0;e<t.length;e++)if(null===t[e])return!0;return!1}}])}();X.constructor_=function(t){t&&(this._envelope=null,this._userData=null,this._factory=t,this._SRID=t.getSRID())},X.TYPECODE_POINT=0,X.TYPECODE_MULTIPOINT=1,X.TYPECODE_LINESTRING=2,X.TYPECODE_LINEARRING=3,X.TYPECODE_MULTILINESTRING=4,X.TYPECODE_POLYGON=5,X.TYPECODE_MULTIPOLYGON=6,X.TYPECODE_GEOMETRYCOLLECTION=7,X.TYPENAME_POINT="Point",X.TYPENAME_MULTIPOINT="MultiPoint",X.TYPENAME_LINESTRING="LineString",X.TYPENAME_LINEARRING="LinearRing",X.TYPENAME_MULTILINESTRING="MultiLineString",X.TYPENAME_POLYGON="Polygon",X.TYPENAME_MULTIPOLYGON="MultiPolygon",X.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",X.geometryChangedFilter={get interfaces_(){return[k]},filter:function(t){t.geometryChangedAction()}};var V=function(){function t(){n(this,t)}return o(t,null,[{key:"toLocationSymbol",value:function(e){switch(e){case t.EXTERIOR:return"e";case t.BOUNDARY:return"b";case t.INTERIOR:return"i";case t.NONE:return"-"}throw new _("Unknown location value: "+e)}}])}();V.INTERIOR=0,V.BOUNDARY=1,V.EXTERIOR=2,V.NONE=-1;var j=o(function t(){n(this,t)},[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}]),K=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({NoSuchElementException:i})[0],r}return u(i,t),o(i)}(m),W=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({UnsupportedOperationException:i})[0],r}return u(i,t),o(i)}(m),Z=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i,[{key:"contains",value:function(){}}])}(j),J=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).map=new Map,t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"contains",value:function(t){var e=t.hashCode?t.hashCode():t;return!!this.map.has(e)}},{key:"add",value:function(t){var e=t.hashCode?t.hashCode():t;return!this.map.has(e)&&!!this.map.set(e,t)}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(r){n.e(r)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new W}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return 0===this.map.size}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new $(this.map)}},{key:Symbol.iterator,value:function(){return this.map}}])}(Z),$=o(function t(e){n(this,t),this.iterator=e.values();var i=this.iterator.next(),r=i.done,o=i.value;this.done=r,this.value=o},[{key:"next",value:function(){if(this.done)throw new K;var t=this.value,e=this.iterator.next(),n=e.done,i=e.value;return this.done=n,this.value=i,t}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new W}}]),Q=function(){function t(){n(this,t)}return o(t,null,[{key:"opposite",value:function(e){return e===t.LEFT?t.RIGHT:e===t.RIGHT?t.LEFT:e}}])}();Q.ON=0,Q.LEFT=1,Q.RIGHT=2;var tt=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({EmptyStackException:i})[0],r}return u(i,t),o(i)}(m),et=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({IndexOutOfBoundsException:i})[0],r}return u(i,t),o(i)}(m),nt=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}])}(j),it=function(t){function i(){var t;return n(this,i),(t=e(this,i)).array=[],t}return u(i,t),o(i,[{key:"add",value:function(t){return this.array.push(t),!0}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new et;return this.array[t]}},{key:"push",value:function(t){return this.array.push(t),t}},{key:"pop",value:function(){if(0===this.array.length)throw new tt;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new tt;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(t){return this.array.indexOf(t)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}])}(nt);function rt(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var ot=o(function t(e){n(this,t),this.str=e},[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),st=function(){function t(e){n(this,t),this.value=e}return o(t,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(t){return this.value<t?-1:this.value>t?1:0}}],[{key:"compare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"isNan",value:function(t){return Number.isNaN(t)}},{key:"valueOf",value:function(e){return new t(e)}}])}(),at=o(function t(){n(this,t)},null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}]),lt=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"le",value:function(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<=t._lo}},{key:"extractSignificantDigits",value:function(e,n){var i=this.abs(),r=t.magnitude(i._hi),o=t.TEN.pow(r);(i=i.divide(o)).gt(t.TEN)?(i=i.divide(t.TEN),r+=1):i.lt(t.ONE)&&(i=i.multiply(t.TEN),r-=1);for(var s=r+1,a=new ot,l=t.MAX_PRINT_DIGITS-1,u=0;u<=l;u++){e&&u===s&&a.append(".");var h=Math.trunc(i._hi);if(h<0)break;var c=!1,f=0;h>9?(c=!0,f="9"):f="0"+h,a.append(f),i=i.subtract(t.valueOf(h)).multiply(t.TEN),c&&i.selfAdd(t.TEN);var g=!0,d=t.magnitude(i._hi);if(d<0&&Math.abs(d)>=l-u&&(g=!1),!g)break}return n[0]=r,a.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 t){var e=arguments[0];return this.add(e.negate())}if("number"==typeof arguments[0]){var n=arguments[0];return this.add(-n)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof t){var e=arguments[0];return this._hi===e._hi&&this._lo===e._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e._hi,-e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.isNaN()?this:this.selfAdd(-n,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(t){return this.le(t)?this:t}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfDivide(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var i,r,o,s,a=arguments[0],l=arguments[1],u=null,h=null,c=null,f=null;return o=this._hi/a,f=(u=(c=t.SPLIT*o)-(u=c-o))*(h=(f=t.SPLIT*a)-(h=f-a))-(s=o*a)+u*(r=a-h)+(i=o-u)*h+i*r,f=o+(c=(this._hi-s-f+this._lo-o*l)/a),this._hi=f,this._lo=o-f+c,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof t){var e,n,i,r,o=arguments[0],s=null,a=null,l=null,u=null;return e=(i=this._hi/o._hi)-(s=(l=t.SPLIT*i)-(s=l-i)),u=s*(a=(u=t.SPLIT*o._hi)-(a=u-o._hi))-(r=i*o._hi)+s*(n=o._hi-a)+e*a+e*n,new t(u=i+(l=(this._hi-r-u+this._lo-i*o._lo)/o._hi),i-u+l)}if("number"==typeof arguments[0]){var h=arguments[0];return A.isNaN(h)?t.createNaN():t.copy(this).selfDivide(h,0)}}},{key:"ge",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}},{key:"pow",value:function(e){if(0===e)return t.valueOf(1);var n=new t(this),i=t.valueOf(1),r=Math.abs(e);if(r>1)for(;r>0;)r%2==1&&i.selfMultiply(n),(r/=2)>0&&(n=n.sqr());else i=n;return e<0?i.reciprocal():i}},{key:"ceil",value:function(){if(this.isNaN())return t.NaN;var e=Math.ceil(this._hi),n=0;return e===this._hi&&(n=Math.ceil(this._lo)),new t(e,n)}},{key:"compareTo",value:function(t){var e=t;return this._hi<e._hi?-1:this._hi>e._hi?1:this._lo<e._lo?-1:this._lo>e._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.init(e),this}if("number"==typeof arguments[0]){var n=arguments[0];return this.init(n),this}}},{key:"max",value:function(t){return this.ge(t)?this:t}},{key:"sqrt",value:function(){if(this.isZero())return t.valueOf(0);if(this.isNegative())return t.NaN;var e=1/Math.sqrt(this._hi),n=this._hi*e,i=t.valueOf(n),r=this.subtract(i.sqr())._hi*(.5*e);return i.add(r)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfAdd(e._hi,e._lo)}if("number"==typeof arguments[0]){var n,i,r,o,s,a=arguments[0],l=null;return l=(r=this._hi+a)-(o=r-this._hi),i=(s=(l=a-o+(this._hi-l))+this._lo)+(r-(n=r+s)),this._hi=n+i,this._lo=i+(n-this._hi),this}}else if(2===arguments.length){var u,h,c,f,g=arguments[0],d=arguments[1],p=null,y=null,v=null;c=this._hi+g,h=this._lo+d,y=c-(v=c-this._hi),p=h-(f=h-this._lo);var m=(u=c+(v=(y=g-v+(this._hi-y))+h))+(v=(p=d-f+(this._lo-p))+(v+(c-u))),_=v+(u-m);return this._hi=m,this._lo=_,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfMultiply(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var i,r,o=arguments[0],s=arguments[1],a=null,l=null,u=null,h=null;a=(u=t.SPLIT*this._hi)-this._hi,h=t.SPLIT*o,a=u-a,i=this._hi-a,l=h-o;var c=(u=this._hi*o)+(h=a*(l=h-l)-u+a*(r=o-l)+i*l+i*r+(this._hi*s+this._lo*o)),f=h+(a=u-c);return this._hi=c,this._lo=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return t.NaN;var e=Math.floor(this._hi),n=0;return e===this._hi&&(n=Math.floor(this._lo)),new t(e,n)}},{key:"negate",value:function(){return this.isNaN()?this:new t(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}},{key:"multiply",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return e.isNaN()?t.createNaN():t.copy(this).selfMultiply(e)}if("number"==typeof arguments[0]){var n=arguments[0];return A.isNaN(n)?t.createNaN():t.copy(this).selfMultiply(n,0)}}},{key:"isNaN",value:function(){return A.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var e=t.magnitude(this._hi);return e>=-3&&e<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!0,n),r=n[0]+1,o=i;if("."===i.charAt(0))o="0"+i;else if(r<0)o="0."+t.stringOfChar("0",-r)+i;else if(-1===i.indexOf(".")){var s=r-i.length;o=i+t.stringOfChar("0",s)+".0"}return this.isNegative()?"-"+o:o}},{key:"reciprocal",value:function(){var e,n,i,r,o=null,s=null,a=null,l=null;e=(i=1/this._hi)-(o=(a=t.SPLIT*i)-(o=a-i)),s=(l=t.SPLIT*this._hi)-this._hi;var u=i+(a=(1-(r=i*this._hi)-(l=o*(s=l-s)-r+o*(n=this._hi-s)+e*s+e*n)-i*this._lo)/this._hi);return new t(u,i-u+a)}},{key:"toSciNotation",value:function(){if(this.isZero())return t.SCI_NOT_ZERO;var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!1,n),r=t.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===i.charAt(0))throw new IllegalStateException("Found leading zero: "+i);var o="";i.length>1&&(o=i.substring(1));var s=i.charAt(0)+"."+o;return this.isNegative()?"-"+s+r:s+r}},{key:"abs",value:function(){return this.isNaN()?t.NaN:this.isNegative()?this.negate():new t(this)}},{key:"isPositive",value:function(){return this._hi>0||0===this._hi&&this._lo>0}},{key:"lt",value:function(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<t._lo}},{key:"add",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return t.copy(this).selfAdd(e)}if("number"==typeof arguments[0]){var n=arguments[0];return t.copy(this).selfAdd(n)}}},{key:"init",value:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this._hi=e,this._lo=0}else if(arguments[0]instanceof t){var n=arguments[0];this._hi=n._hi,this._lo=n._lo}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this._hi=i,this._lo=r}}},{key:"gt",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>t._lo}},{key:"isNegative",value:function(){return this._hi<0||0===this._hi&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?t.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[w,x,E]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var i=arguments[0];t.constructor_.call(this,t.parse(i))}}else if(2===arguments.length){var r=arguments[0],o=arguments[1];this.init(r,o)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3];return t.determinant(t.valueOf(e),t.valueOf(n),t.valueOf(i),t.valueOf(r))}if(arguments[3]instanceof t&&arguments[2]instanceof t&&arguments[0]instanceof t&&arguments[1]instanceof t){var o=arguments[1],s=arguments[2],a=arguments[3];return arguments[0].multiply(a).selfSubtract(o.multiply(s))}}},{key:"sqr",value:function(e){return t.valueOf(e).selfMultiply(e)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var e=arguments[0];return t.parse(e)}if("number"==typeof arguments[0])return new t(arguments[0])}},{key:"sqrt",value:function(e){return t.valueOf(e).sqrt()}},{key:"parse",value:function(e){for(var n=0,i=e.length;at.isWhitespace(e.charAt(n));)n++;var r=!1;if(n<i){var o=e.charAt(n);"-"!==o&&"+"!==o||(n++,"-"===o&&(r=!0))}for(var s=new t,a=0,l=0,u=0,h=!1;!(n>=i);){var c=e.charAt(n);if(n++,at.isDigit(c)){var f=c-"0";s.selfMultiply(t.TEN),s.selfAdd(f),a++}else{if("."!==c){if("e"===c||"E"===c){var g=e.substring(n);try{u=st.parseInt(g)}catch(m){throw m instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+g+" in string "+e):m}break}throw new NumberFormatException("Unexpected character '"+c+"' at position "+n+" in string "+e)}l=a,h=!0}}var d=s;h||(l=a);var p=a-l-u;if(0===p)d=s;else if(p>0){var y=t.TEN.pow(p);d=s.divide(y)}else if(p<0){var v=t.TEN.pow(-p);d=s.multiply(v)}return r?d.negate():d}},{key:"createNaN",value:function(){return new t(A.NaN,A.NaN)}},{key:"copy",value:function(e){return new t(e)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i}},{key:"stringOfChar",value:function(t,e){for(var n=new ot,i=0;i<e;i++)n.append(t);return n.toString()}}])}();lt.PI=new lt(3.141592653589793,12246467991473532e-32),lt.TWO_PI=new lt(6.283185307179586,24492935982947064e-32),lt.PI_2=new lt(1.5707963267948966,6123233995736766e-32),lt.E=new lt(2.718281828459045,14456468917292502e-32),lt.NaN=new lt(A.NaN,A.NaN),lt.EPS=123259516440783e-46,lt.SPLIT=134217729,lt.MAX_PRINT_DIGITS=32,lt.TEN=lt.valueOf(10),lt.ONE=lt.valueOf(1),lt.SCI_NOT_EXPONENT_CHAR="E",lt.SCI_NOT_ZERO="0.0E0";var ut=function(){function t(){n(this,t)}return o(t,null,[{key:"orientationIndex",value:function(e,n,i){var r=t.orientationIndexFilter(e,n,i);if(r<=1)return r;var o=lt.valueOf(n.x).selfAdd(-e.x),s=lt.valueOf(n.y).selfAdd(-e.y),a=lt.valueOf(i.x).selfAdd(-n.x),l=lt.valueOf(i.y).selfAdd(-n.y);return o.selfMultiply(l).selfSubtract(s.selfMultiply(a)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof lt&&arguments[2]instanceof lt&&arguments[0]instanceof lt&&arguments[1]instanceof lt){var t=arguments[1],e=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(t.multiply(e)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=lt.valueOf(i),l=lt.valueOf(r),u=lt.valueOf(o),h=lt.valueOf(s);return a.multiply(h).selfSubtract(l.multiply(u)).signum()}}},{key:"intersection",value:function(t,e,n,i){var r=new lt(t.y).selfSubtract(e.y),o=new lt(e.x).selfSubtract(t.x),s=new lt(t.x).selfMultiply(e.y).selfSubtract(new lt(e.x).selfMultiply(t.y)),a=new lt(n.y).selfSubtract(i.y),l=new lt(i.x).selfSubtract(n.x),u=new lt(n.x).selfMultiply(i.y).selfSubtract(new lt(i.x).selfMultiply(n.y)),h=o.multiply(u).selfSubtract(l.multiply(s)),c=a.multiply(s).selfSubtract(r.multiply(u)),f=r.multiply(l).selfSubtract(a.multiply(o)),g=h.selfDivide(f).doubleValue(),d=c.selfDivide(f).doubleValue();return A.isNaN(g)||A.isInfinite(g)||A.isNaN(d)||A.isInfinite(d)?null:new z(g,d)}},{key:"orientationIndexFilter",value:function(e,n,i){var r=null,o=(e.x-i.x)*(n.y-i.y),s=(e.y-i.y)*(n.x-i.x),a=o-s;if(o>0){if(s<=0)return t.signum(a);r=o+s}else{if(!(o<0))return t.signum(a);if(s>=0)return t.signum(a);r=-o-s}var l=t.DP_SAFE_EPSILON*r;return a>=l||-a>=l?t.signum(a):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}])}();ut.DP_SAFE_EPSILON=1e-15;var ht=o(function t(){n(this,t)},[{key:"getM",value:function(t){if(this.hasM()){var e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return A.NaN}},{key:"setOrdinate",value:function(t,e,n){}},{key:"getZ",value:function(t){return this.hasZ()?this.getOrdinate(t,2):A.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(t,e){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(t){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(t){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(t){}},{key:"copy",value:function(){}},{key:"getY",value:function(t){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[E]}}]);ht.X=0,ht.Y=1,ht.Z=2,ht.M=3;var ct=function(){function t(){n(this,t)}return o(t,null,[{key:"index",value:function(t,e,n){return ut.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var e=arguments[0],n=e.length-1;if(n<3)throw new _("Ring has fewer than 4 points, so orientation cannot be determined");for(var i=e[0],r=0,o=1;o<=n;o++){var s=e[o];s.y>i.y&&(i=s,r=o)}var a=r;do{(a-=1)<0&&(a=n)}while(e[a].equals2D(i)&&a!==r);var l=r;do{l=(l+1)%n}while(e[l].equals2D(i)&&l!==r);var u=e[a],h=e[l];if(u.equals2D(i)||h.equals2D(i)||u.equals2D(h))return!1;var c=t.index(u,i,h);return 0===c?u.x>h.x:c>0}if(rt(arguments[0],ht)){var f=arguments[0],g=f.size()-1;if(g<3)throw new _("Ring has fewer than 4 points, so orientation cannot be determined");for(var d=f.getCoordinate(0),p=0,y=1;y<=g;y++){var v=f.getCoordinate(y);v.y>d.y&&(d=v,p=y)}var m=null,k=p;do{(k-=1)<0&&(k=g),m=f.getCoordinate(k)}while(m.equals2D(d)&&k!==p);var x=null,E=p;do{E=(E+1)%g,x=f.getCoordinate(E)}while(x.equals2D(d)&&E!==p);if(m.equals2D(d)||x.equals2D(d)||m.equals2D(x))return!1;var w=t.index(m,d,x);return 0===w?m.x>x.x:w>0}}}])}();ct.CLOCKWISE=-1,ct.RIGHT=ct.CLOCKWISE,ct.COUNTERCLOCKWISE=1,ct.LEFT=ct.COUNTERCLOCKWISE,ct.COLLINEAR=0,ct.STRAIGHT=ct.COLLINEAR;var ft=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n}},{key:"findRightmostEdgeAtVertex",value:function(){var t=this._minDe.getEdge().getCoordinates();G.isTrue(this._minIndex>0&&this._minIndex<t.length,"rightmost point expected to be interior vertex of edge");var e=t[this._minIndex-1],n=t[this._minIndex+1],i=ct.index(this._minCoord,n,e),r=!1;(e.y<this._minCoord.y&&n.y<this._minCoord.y&&i===ct.COUNTERCLOCKWISE||e.y>this._minCoord.y&&n.y>this._minCoord.y&&i===ct.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var i=Q.LEFT;return n[e].y<n[e+1].y&&(i=Q.RIGHT),i}},{key:"getEdge",value:function(){return this._orientedDe}},{key:"checkForRightmostCoordinate",value:function(t){for(var e=t.getEdge().getCoordinates(),n=0;n<e.length-1;n++)(null===this._minCoord||e[n].x>this._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])}},{key:"findRightmostEdgeAtNode",value:function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}G.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Q.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),gt=function(t){function i(t,r){var o;return n(this,i),(o=e(this,i,[r?t+" [ "+r+" ]":t])).pt=r?new z(r):void 0,o.name=Object.keys({TopologyException:i})[0],o}return u(i,t),o(i,[{key:"getCoordinate",value:function(){return this.pt}}])}(D),dt=o(function t(){n(this,t),this.array=[]},[{key:"addLast",value:function(t){this.array.push(t)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}]),pt=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).array=[],t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"interfaces_",get:function(){return[nt,j]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.array.push(i)}}catch(r){n.e(r)}finally{n.f()}}},{key:"set",value:function(t,e){var n=this.array[t];return this.array[t]=e,n}},{key:"iterator",value:function(){return new yt(this)}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new et;return this.array[t]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(t){t?this.array.sort(function(e,n){return t.compare(e,n)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(t){for(var e=0,n=this.array.length;e<n;e++)if(this.array[e]===t)return!!this.array.splice(e,1);return!1}},{key:Symbol.iterator,value:function(){return this.array.values()}}])}(nt),yt=o(function t(e){n(this,t),this.arrayList=e,this.position=0},[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new K;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(t){return this.arrayList.set(this.position-1,t)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}]),vt=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"clearVisitedEdges",value:function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this._rightMostCoord}},{key:"computeNodeDepth",value:function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new gt("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var r=t.getEdges().iterator();r.hasNext();){var o=r.next();o.setVisited(!0),this.copySymDepths(o)}}},{key:"computeDepth",value:function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(Q.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)}},{key:"create",value:function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}},{key:"findResultEdges",value:function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(Q.RIGHT)>=1&&e.getDepth(Q.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}},{key:"computeDepths",value:function(t){var e=new J,n=new dt,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}}},{key:"compareTo",value:function(t){var e=t;return this._rightMostCoord.x<e._rightMostCoord.x?-1:this._rightMostCoord.x>e._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(null===this._env){for(var t=new U,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),i=0;i<n.length-1;i++)t.expandToInclude(n[i]);this._env=t}return this._env}},{key:"addReachable",value:function(t){var e=new it;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}}},{key:"copySymDepths",value:function(t){var e=t.getSym();e.setDepth(Q.LEFT,t.getDepth(Q.RIGHT)),e.setDepth(Q.RIGHT,t.getDepth(Q.LEFT))}},{key:"add",value:function(t,e){t.setVisited(!0),this._nodes.add(t);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();this._dirEdgeList.add(i);var r=i.getSym().getNode();r.isVisited()||e.push(r)}}},{key:"getNodes",value:function(){return this._nodes}},{key:"getDirectedEdges",value:function(){return this._dirEdgeList}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._finder=null,this._dirEdgeList=new pt,this._nodes=new pt,this._rightMostCoord=null,this._env=null,this._finder=new ft}}]),mt=o(function t(){n(this,t)},null,[{key:"intersection",value:function(t,e,n,i){var r=t.x<e.x?t.x:e.x,o=t.y<e.y?t.y:e.y,s=t.x>e.x?t.x:e.x,a=t.y>e.y?t.y:e.y,l=n.x<i.x?n.x:i.x,u=n.y<i.y?n.y:i.y,h=n.x>i.x?n.x:i.x,c=n.y>i.y?n.y:i.y,f=((r>l?r:l)+(s<h?s:h))/2,g=((o>u?o:u)+(a<c?a:c))/2,d=t.x-f,p=t.y-g,y=e.x-f,v=e.y-g,m=n.x-f,_=n.y-g,k=i.x-f,x=i.y-g,E=p-v,w=y-d,I=d*v-y*p,M=_-x,S=k-m,b=m*x-k*_,N=E*S-M*w,L=(w*b-S*I)/N,P=(M*I-E*b)/N;return A.isNaN(L)||A.isInfinite(L)||A.isNaN(P)||A.isInfinite(P)?null:new z(L+f,P+g)}}]),_t=o(function t(){n(this,t)},null,[{key:"arraycopy",value:function(t,e,n,i,r){for(var o=0,s=e;s<e+r;s++)n[i+o]=t[s],o++}},{key:"getProperty",value:function(t){return{"line.separator":"\n"}[t]}}]),kt=function(){function t(){n(this,t)}return o(t,null,[{key:"log10",value:function(e){var n=Math.log(e);return A.isInfinite(n)||A.isNaN(n)?n:n/t.LOG_10}},{key:"min",value:function(t,e,n,i){var r=t;return e<r&&(r=e),n<r&&(r=n),i<r&&(r=i),r}},{key:"clamp",value:function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],n=arguments[2];return t<e?e:t>n?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],o=arguments[2];return i<r?r:i>o?o:i}}},{key:"wrap",value:function(t,e){return t<0?e- -t%e:t%e}},{key:"max",value:function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var i=arguments[1],r=arguments[2],o=arguments[3],s=arguments[0];return i>s&&(s=i),r>s&&(s=r),o>s&&(s=o),s}}},{key:"average",value:function(t,e){return(t+e)/2}}])}();kt.LOG_10=Math.log(10);var xt=function(){function t(){n(this,t)}return o(t,null,[{key:"segmentToSegment",value:function(e,n,i,r){if(e.equals(n))return t.pointToSegment(e,i,r);if(i.equals(r))return t.pointToSegment(r,e,n);var o=!1;if(U.intersects(e,n,i,r)){var s=(n.x-e.x)*(r.y-i.y)-(n.y-e.y)*(r.x-i.x);if(0===s)o=!0;else{var a=(e.y-i.y)*(r.x-i.x)-(e.x-i.x)*(r.y-i.y),l=((e.y-i.y)*(n.x-e.x)-(e.x-i.x)*(n.y-e.y))/s,u=a/s;(u<0||u>1||l<0||l>1)&&(o=!0)}}else o=!0;return o?kt.min(t.pointToSegment(e,i,r),t.pointToSegment(n,i,r),t.pointToSegment(i,e,n),t.pointToSegment(r,e,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;if(r<=0)return t.distance(e);if(r>=1)return t.distance(n);var o=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(o)*Math.sqrt(i)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)}},{key:"pointToSegmentString",value:function(e,n){if(0===n.length)throw new _("Line array must contain at least one vertex");for(var i=e.distance(n[0]),r=0;r<n.length-1;r++){var o=t.pointToSegment(e,n[r],n[r+1]);o<i&&(i=o)}return i}}])}(),Et=o(function t(){n(this,t)},[{key:"create",value:function(){if(1===arguments.length)arguments[0]instanceof Array||rt(arguments[0],ht);else if(2===arguments.length);else if(3===arguments.length){var t=arguments[0],e=arguments[1];return this.create(t,e)}}}]),wt=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]),It=o(function t(){n(this,t)},null,[{key:"ofLine",value:function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new z;t.getCoordinate(0,i);for(var r=i.x,o=i.y,s=1;s<e;s++){t.getCoordinate(s,i);var a=i.x,l=i.y,u=a-r,h=l-o;n+=Math.sqrt(u*u+h*h),r=a,o=l}return n}}]),Mt=o(function t(){n(this,t)}),St=function(){function t(){n(this,t)}return o(t,null,[{key:"copyCoord",value:function(t,e,n,i){for(var r=Math.min(t.getDimension(),n.getDimension()),o=0;o<r;o++)n.setOrdinate(i,o,t.getOrdinate(e,o))}},{key:"isRing",value:function(t){var e=t.size();return 0===e||!(e<=3)&&t.getOrdinate(0,ht.X)===t.getOrdinate(e-1,ht.X)&&t.getOrdinate(0,ht.Y)===t.getOrdinate(e-1,ht.Y)}},{key:"scroll",value:function(){if(2===arguments.length){if(rt(arguments[0],ht)&&Number.isInteger(arguments[1])){var e=arguments[0],n=arguments[1];t.scroll(e,n,t.isRing(e))}else if(rt(arguments[0],ht)&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1],o=t.indexOf(r,i);if(o<=0)return null;t.scroll(i,o)}}else if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2];if(a<=0)return null;for(var u=s.copy(),h=l?s.size()-1:s.size(),c=0;c<h;c++)for(var f=0;f<s.getDimension();f++)s.setOrdinate(c,f,u.getOrdinate((a+c)%h,f));if(l)for(var g=0;g<s.getDimension();g++)s.setOrdinate(h,g,s.getOrdinate(0,g))}}},{key:"isEqual",value:function(t,e){var n=t.size();if(n!==e.size())return!1;for(var i=Math.min(t.getDimension(),e.getDimension()),r=0;r<n;r++)for(var o=0;o<i;o++){var s=t.getOrdinate(r,o),a=e.getOrdinate(r,o);if(!(t.getOrdinate(r,o)===e.getOrdinate(r,o)||A.isNaN(s)&&A.isNaN(a)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(1===arguments.length){var e=arguments[0];return t.minCoordinateIndex(e,0,e.size()-1)}if(3===arguments.length){for(var n=arguments[0],i=arguments[2],r=-1,o=null,s=arguments[1];s<=i;s++){var a=n.getCoordinate(s);(null===o||o.compareTo(a)>0)&&(o=a,r=s)}return r}}},{key:"extend",value:function(e,n,i){var r=e.create(i,n.getDimension()),o=n.size();if(t.copy(n,0,r,0,o),o>0)for(var s=o;s<i;s++)t.copy(n,o-1,r,s,1);return r}},{key:"reverse",value:function(e){for(var n=e.size()-1,i=Math.trunc(n/2),r=0;r<=i;r++)t.swap(e,r,n-r)}},{key:"swap",value:function(t,e,n){if(e===n)return null;for(var i=0;i<t.getDimension();i++){var r=t.getOrdinate(e,i);t.setOrdinate(e,i,t.getOrdinate(n,i)),t.setOrdinate(n,i,r)}}},{key:"copy",value:function(e,n,i,r,o){for(var s=0;s<o;s++)t.copyCoord(e,n+s,i,r+s)}},{key:"ensureValidRing",value:function(e,n){var i=n.size();return 0===i?n:i<=3?t.createClosedRing(e,n,4):n.getOrdinate(0,ht.X)===n.getOrdinate(i-1,ht.X)&&n.getOrdinate(0,ht.Y)===n.getOrdinate(i-1,ht.Y)?n:t.createClosedRing(e,n,i+1)}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.size();n++)if(t.x===e.getOrdinate(n,ht.X)&&t.y===e.getOrdinate(n,ht.Y))return n;return-1}},{key:"createClosedRing",value:function(e,n,i){var r=e.create(i,n.getDimension()),o=n.size();t.copy(n,0,r,0,o);for(var s=o;s<i;s++)t.copy(n,0,r,s,1);return r}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.size();n++){var i=t.getCoordinate(n);(null===e||e.compareTo(i)>0)&&(e=i)}return e}}])}(),bt=function(){function t(){n(this,t)}return o(t,null,[{key:"toDimensionSymbol",value:function(e){switch(e){case t.FALSE:return t.SYM_FALSE;case t.TRUE:return t.SYM_TRUE;case t.DONTCARE:return t.SYM_DONTCARE;case t.P:return t.SYM_P;case t.L:return t.SYM_L;case t.A:return t.SYM_A}throw new _("Unknown dimension value: "+e)}},{key:"toDimensionValue",value:function(e){switch(at.toUpperCase(e)){case t.SYM_FALSE:return t.FALSE;case t.SYM_TRUE:return t.TRUE;case t.SYM_DONTCARE:return t.DONTCARE;case t.SYM_P:return t.P;case t.SYM_L:return t.L;case t.SYM_A:return t.A}throw new _("Unknown dimension symbol: "+e)}}])}();bt.P=0,bt.L=1,bt.A=2,bt.FALSE=-1,bt.TRUE=-2,bt.DONTCARE=-3,bt.SYM_FALSE="F",bt.SYM_TRUE="T",bt.SYM_DONTCARE="*",bt.SYM_P="0",bt.SYM_L="1",bt.SYM_A="2";var Nt=o(function t(){n(this,t)},[{key:"filter",value:function(t){}}]),Lt=o(function t(){n(this,t)},[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),Pt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new U:this._points.expandEnvelope(new U)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new i(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._points.size()!==n._points.size())return!1;for(var r=0;r<this._points.size();r++)if(!this.equal(this._points.getCoordinate(r),n._points.getCoordinate(r),e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<Math.trunc(this._points.size()/2);t++){var e=this._points.size()-1-t;if(!this._points.getCoordinate(t).equals(this._points.getCoordinate(e))){if(this._points.getCoordinate(t).compareTo(this._points.getCoordinate(e))>0){var n=this._points.copy();St.reverse(n),this._points=n}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?bt.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var t=this._points.copy();return St.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return X.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return It.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e<this._points.size()&&n<t._points.size();){var i=this._points.getCoordinate(e).compareTo(t._points.getCoordinate(n));if(0!==i)return i;e++,n++}return e<this._points.size()?1:n<t._points.size()?-1:0}if(2===arguments.length){var r=arguments[0];return arguments[1].compare(this._points,r._points)}}},{key:"apply",value:function(){if(rt(arguments[0],wt))for(var t=arguments[0],e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e));else if(rt(arguments[0],Lt)){var n=arguments[0];if(0===this._points.size())return null;for(var i=0;i<this._points.size()&&(n.filter(this._points,i),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else(rt(arguments[0],Nt)||rt(arguments[0],k))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){throw new W}},{key:"isEquivalentClass",value:function(t){return t instanceof i}},{key:"getCoordinateN",value:function(t){return this._points.getCoordinate(t)}},{key:"getGeometryType",value:function(){return X.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this._points}},{key:"isEmpty",value:function(){return 0===this._points.size()}},{key:"init",value:function(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new _("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this._points=t}},{key:"isCoordinate",value:function(t){for(var e=0;e<this._points.size();e++)if(this._points.getCoordinate(e).equals(t))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(t){return this.getFactory().createPoint(this._points.getCoordinate(t))}},{key:"interfaces_",get:function(){return[Mt]}}],[{key:"constructor_",value:function(){if(this._points=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];X.constructor_.call(this,e),this.init(t)}}}])}(X),Ct=o(function t(){n(this,t)}),Tt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){if(this.isEmpty())return new U;var t=new U;return t.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),t}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new i(this._coordinates.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&(!(!this.isEmpty()||!t.isEmpty())||this.isEmpty()===t.isEmpty()&&this.equal(t.getCoordinate(),this.getCoordinate(),e))}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return bt.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this._coordinates.copy())}},{key:"getTypeCode",value:function(){return X.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0];return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length){var e=arguments[0];return arguments[1].compare(this._coordinates,e._coordinates)}}},{key:"apply",value:function(){if(rt(arguments[0],wt)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(rt(arguments[0],Lt)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else(rt(arguments[0],Nt)||rt(arguments[0],k))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return X.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this._coordinates}},{key:"getY",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return 0===this._coordinates.size()}},{key:"init",value:function(t){null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),G.isTrue(t.size()<=1),this._coordinates=t}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[Ct]}}],[{key:"constructor_",value:function(){this._coordinates=null;var t=arguments[0],e=arguments[1];X.constructor_.call(this,e),this.init(t)}}])}(X),Ot=function(){function t(){n(this,t)}return o(t,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var e=arguments[0];return Math.abs(t.ofRingSigned(e))}if(rt(arguments[0],ht)){var n=arguments[0];return Math.abs(t.ofRingSigned(n))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var t=arguments[0];if(t.length<3)return 0;for(var e=0,n=t[0].x,i=1;i<t.length-1;i++){var r=t[i].x-n,o=t[i+1].y;e+=r*(t[i-1].y-o)}return e/2}if(rt(arguments[0],ht)){var s=arguments[0],a=s.size();if(a<3)return 0;var l=new z,u=new z,h=new z;s.getCoordinate(0,u),s.getCoordinate(1,h);var c=u.x;h.x-=c;for(var f=0,g=1;g<a-1;g++)l.y=u.y,u.x=h.x,u.y=h.y,s.getCoordinate(g+1,h),h.x-=c,f+=u.x*(l.y-h.y);return f/2}}}])}(),At=o(function t(){n(this,t)},null,[{key:"sort",value:function(){var t=arguments,e=arguments[0];if(1===arguments.length)e.sort(function(t,e){return t.compareTo(e)});else if(2===arguments.length)e.sort(function(e,n){return t[1].compare(e,n)});else if(3===arguments.length){var n=e.slice(arguments[1],arguments[2]);n.sort();var i=e.slice(0,arguments[1]).concat(n,e.slice(arguments[2],e.length));e.splice(0,e.length);var r,o=s(i);try{for(o.s();!(r=o.n()).done;){var a=r.value;e.push(a)}}catch(g){o.e(g)}finally{o.f()}}else if(4===arguments.length){var l=e.slice(arguments[1],arguments[2]);l.sort(function(e,n){return t[3].compare(e,n)});var u=e.slice(0,arguments[1]).concat(l,e.slice(arguments[2],e.length));e.splice(0,e.length);var h,c=s(u);try{for(c.s();!(h=c.n()).done;){var f=h.value;e.push(f)}}catch(g){c.e(g)}finally{c.f()}}}},{key:"asList",value:function(t){var e,n=new pt,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n.add(r)}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"copyOf",value:function(t,e){return t.slice(0,e)}}]),Rt=o(function t(){n(this,t)}),Dt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){return this._shell.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=this._shell.getCoordinates(),i=0;i<n.length;i++)t[++e]=n[i];for(var r=0;r<this._holes.length;r++)for(var o=this._holes[r].getCoordinates(),s=0;s<o.length;s++)t[++e]=o[s];return t}},{key:"getArea",value:function(){var t=0;t+=Ot.ofRing(this._shell.getCoordinateSequence());for(var e=0;e<this._holes.length;e++)t-=Ot.ofRing(this._holes[e].getCoordinateSequence());return t}},{key:"copyInternal",value:function(){for(var t=this._shell.copy(),e=new Array(this._holes.length).fill(null),n=0;n<this._holes.length;n++)e[n]=this._holes[n].copy();return new i(t,e,this._factory)}},{key:"isRectangle",value:function(){if(0!==this.getNumInteriorRing())return!1;if(null===this._shell)return!1;if(5!==this._shell.getNumPoints())return!1;for(var t=this._shell.getCoordinateSequence(),e=this.getEnvelopeInternal(),n=0;n<5;n++){var i=t.getX(n);if(i!==e.getMinX()&&i!==e.getMaxX())return!1;var r=t.getY(n);if(r!==e.getMinY()&&r!==e.getMaxY())return!1}for(var o=t.getX(0),s=t.getY(0),a=1;a<=4;a++){var l=t.getX(a),u=t.getY(a);if(l!==o==(u!==s))return!1;o=l,s=u}return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t,r=this._shell,o=n._shell;if(!r.equalsExact(o,e))return!1;if(this._holes.length!==n._holes.length)return!1;for(var s=0;s<this._holes.length;s++)if(!this._holes[s].equalsExact(n._holes[s],e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){if(0===arguments.length){this._shell=this.normalized(this._shell,!0);for(var t=0;t<this._holes.length;t++)this._holes[t]=this.normalized(this._holes[t],!1);At.sort(this._holes)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(e.isEmpty())return null;var i=e.getCoordinateSequence(),r=St.minCoordinateIndex(i,0,i.size()-2);St.scroll(i,r,!0),ct.isCCW(i)===n&&St.reverse(i)}}},{key:"getCoordinate",value:function(){return this._shell.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this._holes.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var t=this.getExteriorRing().reverse(),e=new Array(this.getNumInteriorRing()).fill(null),n=0;n<e.length;n++)e[n]=this.getInteriorRingN(n).reverse();return this.getFactory().createPolygon(t,e)}},{key:"getTypeCode",value:function(){return X.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var t=0;t+=this._shell.getLength();for(var e=0;e<this._holes.length;e++)t+=this._holes[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=this._shell.getNumPoints(),e=0;e<this._holes.length;e++)t+=this._holes[e].getNumPoints();return t}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(t,e){var n=t.copy();return this.normalize(n,e),n}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=this._shell,n=t._shell;return e.compareToSameClass(n)}if(2===arguments.length){var i=arguments[1],r=arguments[0],o=this._shell,s=r._shell,a=o.compareToSameClass(s,i);if(0!==a)return a;for(var l=this.getNumInteriorRing(),u=r.getNumInteriorRing(),h=0;h<l&&h<u;){var c=this.getInteriorRingN(h),f=r.getInteriorRingN(h),g=c.compareToSameClass(f,i);if(0!==g)return g;h++}return h<l?1:h<u?-1:0}}},{key:"apply",value:function(){if(rt(arguments[0],wt)){var t=arguments[0];this._shell.apply(t);for(var e=0;e<this._holes.length;e++)this._holes[e].apply(t)}else if(rt(arguments[0],Lt)){var n=arguments[0];if(this._shell.apply(n),!n.isDone())for(var i=0;i<this._holes.length&&(this._holes[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(rt(arguments[0],Nt))arguments[0].filter(this);else if(rt(arguments[0],k)){var r=arguments[0];r.filter(this),this._shell.apply(r);for(var o=0;o<this._holes.length;o++)this._holes[o].apply(r)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var t=new Array(this._holes.length+1).fill(null);t[0]=this._shell;for(var e=0;e<this._holes.length;e++)t[e+1]=this._holes[e];return t.length<=1?this.getFactory().createLinearRing(t[0].getCoordinateSequence()):this.getFactory().createMultiLineString(t)}},{key:"getGeometryType",value:function(){return X.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this._shell}},{key:"isEmpty",value:function(){return this._shell.isEmpty()}},{key:"getInteriorRingN",value:function(t){return this._holes[t]}},{key:"interfaces_",get:function(){return[Rt]}}],[{key:"constructor_",value:function(){this._shell=null,this._holes=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(X.constructor_.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),X.hasNullElements(e))throw new _("holes must not contain null elements");if(t.isEmpty()&&X.hasNonEmptyElements(e))throw new _("shell is empty but holes are not");this._shell=t,this._holes=e}}])}(X),Ft=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i)}(Z),Gt=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).array=[],t instanceof j&&r.addAll(t),r}return u(i,t),o(i,[{key:"contains",value:function(t){var e,n=s(this.array);try{for(n.s();!(e=n.n()).done;)if(0===e.value.compareTo(t))return!0}catch(i){n.e(i)}finally{n.f()}return!1}},{key:"add",value:function(t){if(this.contains(t))return!1;for(var e=0,n=this.array.length;e<n;e++)if(1===this.array[e].compareTo(t))return!!this.array.splice(e,0,t);return this.array.push(t),!0}},{key:"addAll",value:function(t){var e,n=s(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(r){n.e(r)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new W}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new Bt(this.array)}}])}(Ft),Bt=o(function t(e){n(this,t),this.array=e,this.position=0},[{key:"next",value:function(){if(this.position===this.array.length)throw new K;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new W}}]),qt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeEnvelopeInternal",value:function(){for(var t=new U,e=0;e<this._geometries.length;e++)t.expandToInclude(this._geometries[e].getEnvelopeInternal());return t}},{key:"getGeometryN",value:function(t){return this._geometries[t]}},{key:"getCoordinates",value:function(){for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=0;n<this._geometries.length;n++)for(var i=this._geometries[n].getCoordinates(),r=0;r<i.length;r++)t[++e]=i[r];return t}},{key:"getArea",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getArea();return t}},{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._geometries.length!==n._geometries.length)return!1;for(var r=0;r<this._geometries.length;r++)if(!this._geometries[r].equalsExact(n._geometries[r],e))return!1;return!0}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<this._geometries.length;t++)this._geometries[t].normalize();At.sort(this._geometries)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var t=bt.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getBoundaryDimension());return t}},{key:"reverseInternal",value:function(){for(var t=this._geometries.length,e=new pt(t),n=0;n<t;n++)e.add(this._geometries[n].reverse());return this.getFactory().buildGeometry(e)}},{key:"getTypeCode",value:function(){return X.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var t=bt.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getDimension());return t}},{key:"getLength",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getNumPoints();return t}},{key:"getNumGeometries",value:function(){return this._geometries.length}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=new Gt(At.asList(this._geometries)),n=new Gt(At.asList(t._geometries));return this.compare(e,n)}if(2===arguments.length){for(var i=arguments[1],r=arguments[0],o=this.getNumGeometries(),s=r.getNumGeometries(),a=0;a<o&&a<s;){var l=this.getGeometryN(a),u=r.getGeometryN(a),h=l.compareToSameClass(u,i);if(0!==h)return h;a++}return a<o?1:a<s?-1:0}}},{key:"apply",value:function(){if(rt(arguments[0],wt))for(var t=arguments[0],e=0;e<this._geometries.length;e++)this._geometries[e].apply(t);else if(rt(arguments[0],Lt)){var n=arguments[0];if(0===this._geometries.length)return null;for(var i=0;i<this._geometries.length&&(this._geometries[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(rt(arguments[0],Nt)){var r=arguments[0];r.filter(this);for(var o=0;o<this._geometries.length;o++)this._geometries[o].apply(r)}else if(rt(arguments[0],k)){var s=arguments[0];s.filter(this);for(var a=0;a<this._geometries.length;a++)this._geometries[a].apply(s)}}},{key:"getBoundary",value:function(){return X.checkNotGeometryCollection(this),G.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return X.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isEmpty())return!1;return!0}}],[{key:"constructor_",value:function(){if(this._geometries=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];if(X.constructor_.call(this,e),null===t&&(t=[]),X.hasNullElements(t))throw new _("geometries must not contain null elements");this._geometries=t}}}])}(X),Yt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(1===arguments.length&&Number.isInteger(arguments[0])){var t=arguments[0];return this._geometries[t].getCoordinate()}return f(i,"getCoordinate",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return bt.FALSE}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[Ct]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];qt.constructor_.call(this,t,e)}}])}(qt),zt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){return new i(this._points.copy(),this._factory)}},{key:"getBoundaryDimension",value:function(){return bt.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||f(i,"isClosed",this,1).call(this)}},{key:"reverseInternal",value:function(){var t=this._points.copy();return St.reverse(t),this.getFactory().createLinearRing(t)}},{key:"getTypeCode",value:function(){return X.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!f(i,"isClosed",this,1).call(this))throw new _("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<i.MINIMUM_VALID_SIZE)throw new _("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")}},{key:"getGeometryType",value:function(){return X.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Pt.constructor_.call(this,t,e),this.validateConstruction()}}])}(Pt);zt.MINIMUM_VALID_SIZE=4;var Ht=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y}throw new _("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new _("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)z.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];z.constructor_.call(this,n,r,z.NULL_ORDINATE)}}}])}(z);Ht.X=0,Ht.Y=1,Ht.Z=-1,Ht.M=-1;var Ut=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;case i.M:this._m=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y;case i.M:return this._m}throw new _("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new _("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2];z.constructor_.call(this,n,r,z.NULL_ORDINATE),this._m=o}}}])}(z);Ut.X=0,Ut.Y=1,Ut.Z=-1,Ut.M=2;var Xt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case z.X:this.x=e;break;case z.Y:this.y=e;break;case z.Z:this.z=e;break;case z.M:this._m=e;break;default:throw new _("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getOrdinate",value:function(t){switch(t){case z.X:return this.x;case z.Y:return this.y;case z.Z:return this.getZ();case z.M:return this.getM()}throw new _("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];z.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3];z.constructor_.call(this,n,r,o),this._m=s}}}])}(z),Vt=function(){function t(){n(this,t)}return o(t,null,[{key:"measures",value:function(t){return t instanceof Ht?0:t instanceof Ut||t instanceof Xt?1:0}},{key:"dimension",value:function(t){return t instanceof Ht?2:t instanceof Ut?3:t instanceof Xt?4:3}},{key:"create",value:function(){if(1===arguments.length){var e=arguments[0];return t.create(e,0)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return 2===n?new Ht:3===n&&0===i?new z:3===n&&1===i?new Ut:4===n&&1===i?new Xt:new z}}}])}(),jt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&rt(arguments[0],j)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return f(i,"addAll",this,1).apply(this,arguments)}},{key:"clone",value:function(){for(var t=f(i,"clone",this,1).call(this),e=0;e<this.size();e++)t.add(e,this.get(e).clone());return t}},{key:"toCoordinateArray",value:function(){if(0===arguments.length)return this.toArray(i.coordArrayType);if(1===arguments.length){if(arguments[0])return this.toArray(i.coordArrayType);for(var t=this.size(),e=new Array(t).fill(null),n=0;n<t;n++)e[n]=this.get(t-n-1);return e}}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];return f(i,"add",this,1).call(this,t)}if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return this.add(e,n,!0),!0}if(arguments[0]instanceof z&&"boolean"==typeof arguments[1]){var r=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(r))return null;f(i,"add",this,1).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return this.add(o,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var a=arguments[0],l=arguments[1];if(arguments[2])for(var u=0;u<a.length;u++)this.add(a[u],l);else for(var h=a.length-1;h>=0;h--)this.add(a[h],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof z){var c=arguments[0],g=arguments[1];if(!arguments[2]){var d=this.size();if(d>0){if(c>0&&this.get(c-1).equals2D(g))return null;if(c<d&&this.get(c).equals2D(g))return null}}f(i,"add",this,1).call(this,c,g)}}else if(4===arguments.length){var p=arguments[0],y=arguments[1],v=arguments[2],m=arguments[3],_=1;v>m&&(_=-1);for(var k=v;k!==m;k+=_)this.add(p[k],y);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var t=this.get(0).copy();this.add(t,!1)}}}],[{key:"constructor_",value:function(){if(0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}}])}(pt);jt.coordArrayType=new Array(0).fill(null);var Kt=function(){function t(){n(this,t)}return o(t,null,[{key:"isRing",value:function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))}},{key:"ptNotInList",value:function(e,n){for(var i=0;i<e.length;i++){var r=e[i];if(t.indexOf(r,n)<0)return r}return null}},{key:"scroll",value:function(e,n){var i=t.indexOf(n,e);if(i<0)return null;var r=new Array(e.length).fill(null);_t.arraycopy(e,i,r,0,e.length-i),_t.arraycopy(e,0,r,e.length-i,i),_t.arraycopy(r,0,e,0,e.length)}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].equals(e[n]))return!1;return!0}if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];if(i===r)return!0;if(null===i||null===r)return!1;if(i.length!==r.length)return!1;for(var s=0;s<i.length;s++)if(0!==o.compare(i[s],r[s]))return!1;return!0}}},{key:"intersection",value:function(t,e){for(var n=new jt,i=0;i<t.length;i++)e.intersects(t[i])&&n.add(t[i],!0);return n.toCoordinateArray()}},{key:"measures",value:function(t){if(null===t||0===t.length)return 0;var e,n=0,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Vt.measures(r))}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"hasRepeatedPoints",value:function(t){for(var e=1;e<t.length;e++)if(t[e-1].equals(t[e]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(e){return t.hasRepeatedPoints(e)?new jt(e,!1).toCoordinateArray():e}},{key:"reverse",value:function(t){for(var e=t.length-1,n=Math.trunc(e/2),i=0;i<=n;i++){var r=t[i];t[i]=t[e-i],t[e-i]=r}}},{key:"removeNull",value:function(t){for(var e=0,n=0;n<t.length;n++)null!==t[n]&&e++;var i=new Array(e).fill(null);if(0===e)return i;for(var r=0,o=0;o<t.length;o++)null!==t[o]&&(i[r++]=t[o]);return i}},{key:"copyDeep",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new Array(t.length).fill(null),n=0;n<t.length;n++)e[n]=t[n].copy();return e}if(5===arguments.length)for(var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4],l=0;l<a;l++)o[s+l]=i[r+l].copy()}},{key:"isEqualReversed",value:function(t,e){for(var n=0;n<t.length;n++){var i=t[n],r=e[t.length-n-1];if(0!==i.compareTo(r))return!1}return!0}},{key:"envelope",value:function(t){for(var e=new U,n=0;n<t.length;n++)e.expandToInclude(t[n]);return e}},{key:"toCoordinateArray",value:function(e){return e.toArray(t.coordArrayType)}},{key:"dimension",value:function(t){if(null===t||0===t.length)return 3;var e,n=0,i=s(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Vt.dimension(r))}}catch(o){i.e(o)}finally{i.f()}return n}},{key:"atLeastNCoordinatesOrNothing",value:function(t,e){return e.length>=t?e:[]}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.length;n++)if(t.equals(e[n]))return n;return-1}},{key:"increasingDirection",value:function(t){for(var e=0;e<Math.trunc(t.length/2);e++){var n=t.length-1-e,i=t[e].compareTo(t[n]);if(0!==i)return i}return 1}},{key:"compare",value:function(t,e){for(var n=0;n<t.length&&n<e.length;){var i=t[n].compareTo(e[n]);if(0!==i)return i;n++}return n<e.length?-1:n<t.length?1:0}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.length;n++)(null===e||e.compareTo(t[n])>0)&&(e=t[n]);return e}},{key:"extract",value:function(t,e,n){e=kt.clamp(e,0,t.length);var i=(n=kt.clamp(n,-1,t.length))-e+1;n<0&&(i=0),e>=t.length&&(i=0),n<e&&(i=0);var r=new Array(i).fill(null);if(0===i)return r;for(var o=0,s=e;s<=n;s++)r[o++]=t[s];return r}}])}(),Wt=o(function t(){n(this,t)},[{key:"compare",value:function(t,e){var n=t,i=e;return Kt.compare(n,i)}},{key:"interfaces_",get:function(){return[R]}}]),Zt=o(function t(){n(this,t)},[{key:"compare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;var r=Kt.compare(n,i);return Kt.isEqualReversed(n,i)?0:r}},{key:"OLDcompare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;for(var r=Kt.increasingDirection(n),o=Kt.increasingDirection(i),s=r>0?0:n.length-1,a=o>0?0:n.length-1,l=0;l<n.length;l++){var u=n[s].compareTo(i[a]);if(0!==u)return u;s+=r,a+=o}return 0}},{key:"interfaces_",get:function(){return[R]}}]);Kt.ForwardComparator=Wt,Kt.BidirectionalComparator=Zt,Kt.coordArrayType=new Array(0).fill(null);var Jt=o(function t(e){n(this,t),this.str=e},[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),$t=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getM",value:function(t){return this.hasM()?this._coordinates[t].getM():A.NaN}},{key:"setOrdinate",value:function(t,e,n){switch(e){case ht.X:this._coordinates[t].x=n;break;case ht.Y:this._coordinates[t].y=n;break;default:this._coordinates[t].setOrdinate(e,n)}}},{key:"getZ",value:function(t){return this.hasZ()?this._coordinates[t].getZ():A.NaN}},{key:"size",value:function(){return this._coordinates.length}},{key:"getOrdinate",value:function(t,e){switch(e){case ht.X:return this._coordinates[t].x;case ht.Y:return this._coordinates[t].y;default:return this._coordinates[t].getOrdinate(e)}}},{key:"getCoordinate",value:function(){if(1===arguments.length){var t=arguments[0];return this._coordinates[t]}if(2===arguments.length){var e=arguments[0];arguments[1].setCoordinate(this._coordinates[e])}}},{key:"getCoordinateCopy",value:function(t){var e=this.createCoordinate();return e.setCoordinate(this._coordinates[t]),e}},{key:"createCoordinate",value:function(){return Vt.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this._dimension}},{key:"getX",value:function(t){return this._coordinates[t].x}},{key:"getMeasures",value:function(){return this._measures}},{key:"expandEnvelope",value:function(t){for(var e=0;e<this._coordinates.length;e++)t.expandToInclude(this._coordinates[e]);return t}},{key:"copy",value:function(){for(var e=new Array(this.size()).fill(null),n=0;n<this._coordinates.length;n++){var i=this.createCoordinate();i.setCoordinate(this._coordinates[n]),e[n]=i}return new t(e,this._dimension,this._measures)}},{key:"toString",value:function(){if(this._coordinates.length>0){var t=new Jt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e<this._coordinates.length;e++)t.append(", "),t.append(this._coordinates[e]);return t.append(")"),t.toString()}return"()"}},{key:"getY",value:function(t){return this._coordinates[t].y}},{key:"toCoordinateArray",value:function(){return this._coordinates}},{key:"interfaces_",get:function(){return[ht,w]}}],[{key:"constructor_",value:function(){if(this._dimension=3,this._measures=0,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];t.constructor_.call(this,e,Kt.dimension(e),Kt.measures(e))}else if(Number.isInteger(arguments[0])){var n=arguments[0];this._coordinates=new Array(n).fill(null);for(var i=0;i<n;i++)this._coordinates[i]=new z}else if(rt(arguments[0],ht)){var r=arguments[0];if(null===r)return this._coordinates=new Array(0).fill(null),null;this._dimension=r.getDimension(),this._measures=r.getMeasures(),this._coordinates=new Array(r.size()).fill(null);for(var o=0;o<this._coordinates.length;o++)this._coordinates[o]=r.getCoordinateCopy(o)}}else if(2===arguments.length){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var s=arguments[0],a=arguments[1];t.constructor_.call(this,s,a,Kt.measures(s))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var l=arguments[0],u=arguments[1];this._coordinates=new Array(l).fill(null),this._dimension=u;for(var h=0;h<l;h++)this._coordinates[h]=Vt.create(u)}}else if(3===arguments.length)if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var c=arguments[0],f=arguments[1],g=arguments[2];this._dimension=f,this._measures=g,this._coordinates=null===c?new Array(0).fill(null):c}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var d=arguments[0],p=arguments[1],y=arguments[2];this._coordinates=new Array(d).fill(null),this._dimension=p,this._measures=y;for(var v=0;v<d;v++)this._coordinates[v]=this.createCoordinate()}}}])}(),Qt=function(){function t(){n(this,t)}return o(t,[{key:"readResolve",value:function(){return t.instance()}},{key:"create",value:function(){if(1===arguments.length){if(arguments[0]instanceof Array)return new $t(arguments[0]);if(rt(arguments[0],ht))return new $t(arguments[0])}else{if(2===arguments.length){var t=arguments[1];return t>3&&(t=3),t<2&&(t=2),new $t(arguments[0],t)}if(3===arguments.length){var e=arguments[2],n=arguments[1]-e;return e>1&&(e=1),n>3&&(n=3),n<2&&(n=2),new $t(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[Et,w]}}],[{key:"instance",value:function(){return t.instanceObject}}])}();Qt.instanceObject=new Qt;var te=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var t=new pt,e=0;e<this._geometries.length;e++)for(var n=this._geometries[e].getBoundary(),i=0;i<n.getNumGeometries();i++)t.add(n.getGeometryN(i));var r=new Array(t.size()).fill(null);return this.getFactory().createMultiLineString(t.toArray(r))}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[Rt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];qt.constructor_.call(this,t,e)}}])}(qt),ee=o(function t(){n(this,t)},[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}]),ne=function(t){function i(){var t;return n(this,i),(t=e(this,i)).map=new Map,t}return u(i,t),o(i,[{key:"get",value:function(t){return this.map.get(t)||null}},{key:"put",value:function(t,e){return this.map.set(t,e),e}},{key:"values",value:function(){for(var t=new pt,e=this.map.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t}},{key:"entrySet",value:function(){var t=new J;return this.map.entries().forEach(function(e){return t.add(e)}),t}},{key:"size",value:function(){return this.map.size()}}])}(ee),ie=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this._modelType===n._modelType&&this._scale===n._scale}},{key:"compareTo",value:function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits();return st.compare(n,i)}},{key:"getScale",value:function(){return this._scale}},{key:"isFloating",value:function(){return this._modelType===t.FLOATING||this._modelType===t.FLOATING_SINGLE}},{key:"getType",value:function(){return this._modelType}},{key:"toString",value:function(){var e="UNKNOWN";return this._modelType===t.FLOATING?e="Floating":this._modelType===t.FLOATING_SINGLE?e="Floating-Single":this._modelType===t.FIXED&&(e="Fixed (Scale="+this.getScale()+")"),e}},{key:"makePrecise",value:function(){if("number"==typeof arguments[0]){var e=arguments[0];return A.isNaN(e)||this._modelType===t.FLOATING_SINGLE?e:this._modelType===t.FIXED?Math.round(e*this._scale)/this._scale:e}if(arguments[0]instanceof z){var n=arguments[0];if(this._modelType===t.FLOATING)return null;n.x=this.makePrecise(n.x),n.y=this.makePrecise(n.y)}}},{key:"getMaximumSignificantDigits",value:function(){var e=16;return this._modelType===t.FLOATING?e=16:this._modelType===t.FLOATING_SINGLE?e=6:this._modelType===t.FIXED&&(e=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),e}},{key:"setScale",value:function(t){this._scale=Math.abs(t)}},{key:"interfaces_",get:function(){return[w,x]}}],[{key:"constructor_",value:function(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof re){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var i=arguments[0];this._modelType=i._modelType,this._scale=i._scale}}},{key:"mostPrecise",value:function(t,e){return t.compareTo(e)>=0?t:e}}])}(),re=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"readResolve",value:function(){return t.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){this._name=null;var e=arguments[0];this._name=e,t.nameToTypeMap.put(e,this)}}])}();re.nameToTypeMap=new ne,ie.Type=re,ie.FIXED=new re("FIXED"),ie.FLOATING=new re("FLOATING"),ie.FLOATING_SINGLE=new re("FLOATING SINGLE"),ie.maximumPreciseValue=9007199254740992;var oe=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<t.length;e++)t[e]=this._geometries[e].copy();return new i(t,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&f(i,"equalsExact",this,1).call(this,t,e)}return f(i,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?bt.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return X.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new W}},{key:"getGeometryType",value:function(){return X.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[Mt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];qt.constructor_.call(this,t,e)}}])}(qt),se=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"createEmpty",value:function(t){switch(t){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new _("Invalid dimension: "+t)}}},{key:"toGeometry",value:function(t){return t.isNull()?this.createPoint():t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new z(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new z(t.getMinX(),t.getMinY()),new z(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new z(t.getMinX(),t.getMinY()),new z(t.getMinX(),t.getMaxY()),new z(t.getMaxX(),t.getMaxY()),new z(t.getMaxX(),t.getMinY()),new z(t.getMinX(),t.getMinY())]),null)}},{key:"createLineString",value:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLineString(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(rt(arguments[0],ht))return new Pt(arguments[0],this)}}},{key:"createMultiLineString",value:function(){return 0===arguments.length?new oe(null,this):1===arguments.length?new oe(arguments[0],this):void 0}},{key:"buildGeometry",value:function(e){for(var n=null,i=!1,r=!1,o=e.iterator();o.hasNext();){var s=o.next(),a=s.getTypeCode();null===n&&(n=a),a!==n&&(i=!0),s instanceof qt&&(r=!0)}if(null===n)return this.createGeometryCollection();if(i||r)return this.createGeometryCollection(t.toGeometryArray(e));var l=e.iterator().next();if(e.size()>1){if(l instanceof Dt)return this.createMultiPolygon(t.toPolygonArray(e));if(l instanceof Pt)return this.createMultiLineString(t.toLineStringArray(e));if(l instanceof Tt)return this.createMultiPoint(t.toPointArray(e));G.shouldNeverReachHere("Unhandled geometry type: "+l.getGeometryType())}return l}},{key:"createMultiPointFromCoords",value:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof z){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(rt(arguments[0],ht))return new Tt(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(rt(arguments[0],ht)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof zt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length)return new Dt(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new qt(null,this):1===arguments.length?new qt(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(rt(arguments[0],ht))return new zt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new te(null,this):1===arguments.length?new te(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new Yt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new Yt(arguments[0],this);if(rt(arguments[0],ht)){var t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));for(var e=new Array(t.size()).fill(null),n=0;n<t.size();n++){var i=this.getCoordinateSequenceFactory().create(1,t.getDimension(),t.getMeasures());St.copy(t,n,i,0,1),e[n]=this.createPoint(i)}return this.createMultiPoint(e)}}}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._precisionModel=null,this._coordinateSequenceFactory=null,this._SRID=null,0===arguments.length)t.constructor_.call(this,new ie,0);else if(1===arguments.length){if(rt(arguments[0],Et)){var e=arguments[0];t.constructor_.call(this,new ie,0,e)}else if(arguments[0]instanceof ie){var n=arguments[0];t.constructor_.call(this,n,0,t.getDefaultCoordinateSequenceFactory())}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];t.constructor_.call(this,i,r,t.getDefaultCoordinateSequenceFactory())}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this._precisionModel=o,this._coordinateSequenceFactory=a,this._SRID=s}}},{key:"toMultiPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toGeometryArray",value:function(t){if(null===t)return null;var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return Qt.instance()}},{key:"toMultiLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toMultiPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLinearRingArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"createPointFromInternalCoord",value:function(t,e){return e.getPrecisionModel().makePrecise(t),e.getFactory().createPoint(t)}}])}(),ae="XY",le="XYZ",ue="XYM",he="XYZM",ce={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},fe="EMPTY",ge=1,de=2,pe=3,ye=4,ve=5,me=6;for(var _e in ce)ce[_e].toUpperCase();var ke=o(function t(e){n(this,t),this.wkt=e,this.index_=-1},[{key:"isAlpha_",value:function(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}},{key:"isNumeric_",value:function(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}},{key:"isWhiteSpace_",value:function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var t,e=this.nextChar_(),n=this.index_,i=e;if("("==e)t=de;else if(","==e)t=ve;else if(")"==e)t=pe;else if(this.isNumeric_(e)||"-"==e)t=ye,i=this.readNumber_();else if(this.isAlpha_(e))t=ge,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=me}return{position:n,value:i,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,i=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(i=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!i&&("e"==t||"E"==t)||i&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}},{key:"readText_",value:function(){var t,e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}]),xe=o(function t(e,i){n(this,t),this.lexer_=e,this.token_,this.layout_=ae,this.factory=i},[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(t){return this.token_.type==t}},{key:"match",value:function(t){var e=this.isTokenType(t);return e&&this.consume_(),e}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var t=ae,e=this.token_;if(this.isTokenType(ge)){var n=e.value;"Z"===n?t=le:"M"===n?t=ue:"ZM"===n&&(t=he),t!==ae&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(de)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(ve));if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(de)){var t=this.parsePoint_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(de)){var t=this.parsePointList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(de)){var t=this.parseLineStringTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(de)){if(t=this.token_.type==de?this.parsePointTextList_():this.parsePointList_(),this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(de)){var t=this.parseLineStringTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(de)){var t=this.parsePolygonTextList_();if(this.match(pe))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var t=[],e=this.layout_.length,n=0;n<e;++n){var i=this.token_;if(!this.match(ye))break;t.push(i.value)}if(t.length==e)return t;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var t=[this.parsePoint_()];this.match(ve);)t.push(this.parsePoint_());return t}},{key:"parsePointTextList_",value:function(){for(var t=[this.parsePointText_()];this.match(ve);)t.push(this.parsePointText_());return t}},{key:"parseLineStringTextList_",value:function(){for(var t=[this.parseLineStringText_()];this.match(ve);)t.push(this.parseLineStringText_());return t}},{key:"parsePolygonTextList_",value:function(){for(var t=[this.parsePolygonText_()];this.match(ve);)t.push(this.parsePolygonText_());return t}},{key:"isEmptyGeometry_",value:function(){var t=this.isTokenType(ge)&&this.token_.value==fe;return t&&this.consume_(),t}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var t=this.factory,e=function(t){return i(z,g(t))},n=function(n){var i=n.map(function(n){return t.createLinearRing(n.map(e))});return i.length>1?t.createPolygon(i[0],i.slice(1)):t.createPolygon(i[0])},r=this.token_;if(this.match(ge)){var o=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==o){var s=this.parseGeometryCollectionText_();return t.createGeometryCollection(s)}switch(o){case"POINT":var a=this.parsePointText_();return a?t.createPoint(i(z,g(a))):t.createPoint();case"LINESTRING":var l=this.parseLineStringText_().map(e);return t.createLineString(l);case"LINEARRING":var u=this.parseLineStringText_().map(e);return t.createLinearRing(u);case"POLYGON":var h=this.parsePolygonText_();return h&&0!==h.length?n(h):t.createPolygon();case"MULTIPOINT":var c=this.parseMultiPointText_();if(!c||0===c.length)return t.createMultiPoint();var f=c.map(e).map(function(e){return t.createPoint(e)});return t.createMultiPoint(f);case"MULTILINESTRING":var d=this.parseMultiLineStringText_().map(function(n){return t.createLineString(n.map(e))});return t.createMultiLineString(d);case"MULTIPOLYGON":var p=this.parseMultiPolygonText_();if(!p||0===p.length)return t.createMultiPolygon();var y=p.map(n);return t.createMultiPolygon(y);default:throw new Error("Invalid geometry type: "+o)}}throw new Error(this.formatErrorMessage_())}}]);function Ee(t){if(t.isEmpty())return"";var e=t.getCoordinate(),n=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||n.push(e.z),void 0===e.m||Number.isNaN(e.m)||n.push(e.m),n.join(" ")}function we(t){for(var e=t.getCoordinates().map(function(t){var e=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||e.push(t.z),void 0===t.m||Number.isNaN(t.m)||e.push(t.m),e}),n=[],i=0,r=e.length;i<r;++i)n.push(e[i].join(" "));return n.join(", ")}function Ie(t){var e=[];e.push("("+we(t.getExteriorRing())+")");for(var n=0,i=t.getNumInteriorRing();n<i;++n)e.push("("+we(t.getInteriorRingN(n))+")");return e.join(", ")}var Me={Point:Ee,LineString:we,LinearRing:we,Polygon:Ie,MultiPoint:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+Ee(t.getGeometryN(n))+")");return e.join(", ")},MultiLineString:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+we(t.getGeometryN(n))+")");return e.join(", ")},MultiPolygon:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+Ie(t.getGeometryN(n))+")");return e.join(", ")},GeometryCollection:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push(Se(t.getGeometryN(n)));return e.join(", ")}};function Se(t){var e=t.getGeometryType(),n=Me[e];e=e.toUpperCase();var i=function(t){var e="";if(t.isEmpty())return e;var n=t.getCoordinate();return void 0===n.z||Number.isNaN(n.z)||(e+="Z"),void 0===n.m||Number.isNaN(n.m)||(e+="M"),e}(t);return i.length>0&&(e+=" "+i),t.isEmpty()?e+" "+fe:e+" ("+n(t)+")"}var be=o(function t(e){n(this,t),this.geometryFactory=e||new se,this.precisionModel=this.geometryFactory.getPrecisionModel()},[{key:"read",value:function(t){var e=new ke(t);return new xe(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return Se(t)}}]),Ne=o(function t(e){n(this,t),this.parser=new be(e)},[{key:"write",value:function(t){return this.parser.write(t)}}],[{key:"toLineString",value:function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}]),Le=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}},{key:"getTopologySummary",value:function(){var t=new Jt;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}},{key:"computeIntersection",value:function(t,e,n,i){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(t,e,n,i)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;e<this._result;e++)if(!this._intPt[e].equals2D(this._inputLines[t][0])&&!this._intPt[e].equals2D(this._inputLines[t][1]))return!0;return!1}}},{key:"getIntersection",value:function(t){return this._intPt[t]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&!this._isProper}},{key:"hasIntersection",value:function(){return this._result!==t.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(e,n){return t.computeEdgeDistance(this._intPt[n],this._inputLines[e][0],this._inputLines[e][1])}},{key:"isCollinear",value:function(){return this._result===t.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return Ne.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+Ne.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(t,e){return this._inputLines[t][e]}},{key:"isIntersection",value:function(t){for(var e=0;e<this._result;e++)if(this._intPt[e].equals2D(t))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[t][e]]}}],[{key:"constructor_",value:function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new z,this._intPt[1]=new z,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}},{key:"computeEdgeDistance",value:function(t,e,n){var i=Math.abs(n.x-e.x),r=Math.abs(n.y-e.y),o=-1;if(t.equals(e))o=0;else if(t.equals(n))o=i>r?i:r;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=i>r?s:a)||t.equals(e)||(o=Math.max(s,a))}return G.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y,o=Math.sqrt(i*i+r*r);return G.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o}}])}();Le.DONT_INTERSECT=0,Le.DO_INTERSECT=1,Le.COLLINEAR=2,Le.NO_INTERSECTION=0,Le.POINT_INTERSECTION=1,Le.COLLINEAR_INTERSECTION=2;var Pe=function(t){function i(){return n(this,i),e(this,i)}return u(i,t),o(i,[{key:"isInSegmentEnvelopes",value:function(t){var e=new U(this._inputLines[0][0],this._inputLines[0][1]),n=new U(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return f(i,"computeIntersection",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this._isProper=!1,U.intersects(e,n,t)&&0===ct.index(e,n,t)&&0===ct.index(n,e,t))return this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this._result=Le.POINT_INTERSECTION,null;this._result=Le.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,r){var o=this.intersectionSafe(t,e,n,r);return this.isInSegmentEnvelopes(o)||(o=new z(i.nearestEndpoint(t,e,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o}},{key:"checkDD",value:function(t,e,n,i,r){var o=ut.intersection(t,e,n,i),s=this.isInSegmentEnvelopes(o);_t.out.println("DD in env = "+s+" --------------------- "+o),r.distance(o)>1e-4&&_t.out.println("Distance = "+r.distance(o))}},{key:"intersectionSafe",value:function(t,e,n,r){var o=mt.intersection(t,e,n,r);return null===o&&(o=i.nearestEndpoint(t,e,n,r)),o}},{key:"computeCollinearIntersection",value:function(t,e,n,i){var r=U.intersects(t,e,n),o=U.intersects(t,e,i),s=U.intersects(n,i,t),a=U.intersects(n,i,e);return r&&o?(this._intPt[0]=n,this._intPt[1]=i,Le.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=t,this._intPt[1]=e,Le.COLLINEAR_INTERSECTION):r&&s?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||a?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):r&&a?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||s?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):o&&s?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||r||a?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):o&&a?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||r||s?Le.COLLINEAR_INTERSECTION:Le.POINT_INTERSECTION):Le.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,i){if(this._isProper=!1,!U.intersects(t,e,n,i))return Le.NO_INTERSECTION;var r=ct.index(t,e,n),o=ct.index(t,e,i);if(r>0&&o>0||r<0&&o<0)return Le.NO_INTERSECTION;var s=ct.index(n,i,t),a=ct.index(n,i,e);return s>0&&a>0||s<0&&a<0?Le.NO_INTERSECTION:0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(t,e,n,i):(0===r||0===o||0===s||0===a?(this._isProper=!1,t.equals2D(n)||t.equals2D(i)?this._intPt[0]=t:e.equals2D(n)||e.equals2D(i)?this._intPt[0]=e:0===r?this._intPt[0]=new z(n):0===o?this._intPt[0]=new z(i):0===s?this._intPt[0]=new z(t):0===a&&(this._intPt[0]=new z(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,n,i)),Le.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,i){var r=t,o=xt.pointToSegment(t,n,i),s=xt.pointToSegment(e,n,i);return s<o&&(o=s,r=e),(s=xt.pointToSegment(n,t,e))<o&&(o=s,r=n),(s=xt.pointToSegment(i,t,e))<o&&(o=s,r=i),r}}])}(Le),Ce=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"countSegment",value:function(t,e){if(t.x<this._p.x&&e.x<this._p.x)return null;if(this._p.x===e.x&&this._p.y===e.y)return this._isPointOnSegment=!0,null;if(t.y===this._p.y&&e.y===this._p.y){var n=t.x,i=e.x;return n>i&&(n=e.x,i=t.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var r=ct.index(t,e,this._p);if(r===ct.COLLINEAR)return this._isPointOnSegment=!0,null;e.y<t.y&&(r=-r),r===ct.LEFT&&this._crossingCount++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==V.EXTERIOR}},{key:"getLocation",value:function(){return this._isPointOnSegment?V.BOUNDARY:this._crossingCount%2==1?V.INTERIOR:V.EXTERIOR}},{key:"isOnSegment",value:function(){return this._isPointOnSegment}}],[{key:"constructor_",value:function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof z&&rt(arguments[1],ht)){for(var e=arguments[1],n=new t(arguments[0]),i=new z,r=new z,o=1;o<e.size();o++)if(e.getCoordinate(o,i),e.getCoordinate(o-1,r),n.countSegment(i,r),n.isOnSegment())return n.getLocation();return n.getLocation()}if(arguments[0]instanceof z&&arguments[1]instanceof Array){for(var s=arguments[1],a=new t(arguments[0]),l=1;l<s.length;l++){var u=s[l],h=s[l-1];if(a.countSegment(u,h),a.isOnSegment())return a.getLocation()}return a.getLocation()}}}])}(),Te=function(){function t(){n(this,t)}return o(t,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof z&&rt(arguments[1],ht)){for(var t=arguments[0],e=arguments[1],n=new Pe,i=new z,r=new z,o=e.size(),s=1;s<o;s++)if(e.getCoordinate(s-1,i),e.getCoordinate(s,r),n.computeIntersection(t,i,r),n.hasIntersection())return!0;return!1}if(arguments[0]instanceof z&&arguments[1]instanceof Array){for(var a=arguments[0],l=arguments[1],u=new Pe,h=1;h<l.length;h++){var c=l[h-1],f=l[h];if(u.computeIntersection(a,c,f),u.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(t,e){return Ce.locatePointInRing(t,e)}},{key:"isInRing",value:function(e,n){return t.locateInRing(e,n)!==V.EXTERIOR}}])}(),Oe=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"setAllLocations",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t}},{key:"isNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==V.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]===V.NONE&&(this.location[e]=t)}},{key:"isLine",value:function(){return 1===this.location.length}},{key:"merge",value:function(t){if(t.location.length>this.location.length){var e=new Array(3).fill(null);e[Q.ON]=this.location[Q.ON],e[Q.LEFT]=V.NONE,e[Q.RIGHT]=V.NONE,this.location=e}for(var n=0;n<this.location.length;n++)this.location[n]===V.NONE&&n<t.location.length&&(this.location[n]=t.location[n])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var t=this.location[Q.LEFT];this.location[Q.LEFT]=this.location[Q.RIGHT],this.location[Q.RIGHT]=t}},{key:"toString",value:function(){var t=new ot;return this.location.length>1&&t.append(V.toLocationSymbol(this.location[Q.LEFT])),t.append(V.toLocationSymbol(this.location[Q.ON])),this.location.length>1&&t.append(V.toLocationSymbol(this.location[Q.RIGHT])),t.toString()}},{key:"setLocations",value:function(t,e,n){this.location[Q.ON]=t,this.location[Q.LEFT]=e,this.location[Q.RIGHT]=n}},{key:"get",value:function(t){return t<this.location.length?this.location[t]:V.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===V.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(1===arguments.length){var t=arguments[0];this.setLocation(Q.ON,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.location[e]=n}}},{key:"init",value:function(t){this.location=new Array(t).fill(null),this.setAllLocations(V.NONE)}},{key:"isEqualOnSide",value:function(t,e){return this.location[e]===t.location[e]}},{key:"allPositionsEqual",value:function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0}}],[{key:"constructor_",value:function(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];this.init(e.length)}else if(Number.isInteger(arguments[0])){var n=arguments[0];this.init(1),this.location[Q.ON]=n}else if(arguments[0]instanceof t){var i=arguments[0];if(this.init(i.location.length),null!==i)for(var r=0;r<this.location.length;r++)this.location[r]=i.location[r]}}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.init(3),this.location[Q.ON]=o,this.location[Q.LEFT]=s,this.location[Q.RIGHT]=a}}}])}(),Ae=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getGeometryCount",value:function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t}},{key:"setAllLocations",value:function(t,e){this.elt[t].setAllLocations(e)}},{key:"isNull",value:function(t){return this.elt[t].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(1===arguments.length){var t=arguments[0];this.setAllLocationsIfNull(0,t),this.setAllLocationsIfNull(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.elt[e].setAllLocationsIfNull(n)}}},{key:"isLine",value:function(t){return this.elt[t].isLine()}},{key:"merge",value:function(t){for(var e=0;e<2;e++)null===this.elt[e]&&null!==t.elt[e]?this.elt[e]=new Oe(t.elt[e]):this.elt[e].merge(t.elt[e])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(1===arguments.length){var t=arguments[0];return this.elt[t].get(Q.ON)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.elt[e].get(n)}}},{key:"toString",value:function(){var t=new ot;return null!==this.elt[0]&&(t.append("A:"),t.append(this.elt[0].toString())),null!==this.elt[1]&&(t.append(" B:"),t.append(this.elt[1].toString())),t.toString()}},{key:"isArea",value:function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var t=arguments[0];return this.elt[t].isArea()}}},{key:"isAnyNull",value:function(t){return this.elt[t].isAnyNull()}},{key:"setLocation",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.elt[t].setLocation(Q.ON,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.elt[n].setLocation(i,r)}}},{key:"isEqualOnSide",value:function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)}},{key:"allPositionsEqual",value:function(t,e){return this.elt[t].allPositionsEqual(e)}},{key:"toLine",value:function(t){this.elt[t].isArea()&&(this.elt[t]=new Oe(this.elt[t].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var e=arguments[0];this.elt[0]=new Oe(e),this.elt[1]=new Oe(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.elt[0]=new Oe(n.elt[0]),this.elt[1]=new Oe(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new Oe(V.NONE),this.elt[1]=new Oe(V.NONE),this.elt[i].setLocation(r)}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.elt[0]=new Oe(o,s,a),this.elt[1]=new Oe(o,s,a)}else if(4===arguments.length){var l=arguments[0],u=arguments[1],h=arguments[2],c=arguments[3];this.elt[0]=new Oe(V.NONE,V.NONE,V.NONE),this.elt[1]=new Oe(V.NONE,V.NONE,V.NONE),this.elt[l].setLocations(u,h,c)}}},{key:"toLineLabel",value:function(e){for(var n=new t(V.NONE),i=0;i<2;i++)n.setLocation(i,e.getLocation(i));return n}}])}(),Re=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"computeRing",value:function(){if(null!==this._ring)return null;for(var t=new Array(this._pts.size()).fill(null),e=0;e<this._pts.size();e++)t[e]=this._pts.get(e);this._ring=this._geometryFactory.createLinearRing(t),this._isHole=ct.isCCW(this._ring.getCoordinates())}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"computePoints",value:function(t){this._startDe=t;var e=t,n=!0;do{if(null===e)throw new gt("Found null DirectedEdge");if(e.getEdgeRing()===this)throw new gt("Directed Edge visited twice during ring-building at "+e.getCoordinate());this._edges.add(e);var i=e.getLabel();G.isTrue(i.isArea()),this.mergeLabel(i),this.addPoints(e.getEdge(),e.isForward(),n),n=!1,this.setEdgeRing(e,this),e=this.getNext(e)}while(e!==this._startDe)}},{key:"getLinearRing",value:function(){return this._ring}},{key:"getCoordinate",value:function(t){return this._pts.get(t)}},{key:"computeMaxNodeDegree",value:function(){this._maxNodeDegree=0;var t=this._startDe;do{var e=t.getNode().getEdges().getOutgoingDegree(this);e>this._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var o=r;o<i.length;o++)this._pts.add(i[o])}else{var s=i.length-2;n&&(s=i.length-1);for(var a=s;a>=0;a--)this._pts.add(i[a])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)}},{key:"containsPoint",value:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Te.isInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0}},{key:"addHole",value:function(t){this._holes.add(t)}},{key:"isShell",value:function(){return null===this._shell}},{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(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,Q.RIGHT);if(n===V.NONE)return null;if(this._label.getLocation(e)===V.NONE)return this._label.setLocation(e,n),null}}},{key:"setShell",value:function(t){this._shell=t,null!==t&&t.addHole(this)}},{key:"toPolygon",value:function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n<this._holes.size();n++)e[n]=this._holes.get(n).getLinearRing();return t.createPolygon(this.getLinearRing(),e)}}],[{key:"constructor_",value:function(){if(this._startDe=null,this._maxNodeDegree=-1,this._edges=new pt,this._pts=new pt,this._label=new Ae(V.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new pt,this._geometryFactory=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._geometryFactory=e,this.computePoints(t),this.computeRing()}}}]),De=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"setEdgeRing",value:function(t,e){t.setMinEdgeRing(e)}},{key:"getNext",value:function(t){return t.getNextMin()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Re.constructor_.call(this,t,e)}}])}(Re),Fe=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"buildMinimalRings",value:function(){var t=new pt,e=this._startDe;do{if(null===e.getMinEdgeRing()){var n=new De(e,this._geometryFactory);t.add(n)}e=e.getNext()}while(e!==this._startDe);return t}},{key:"setEdgeRing",value:function(t,e){t.setEdgeRing(e)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var t=this._startDe;do{t.getNode().getEdges().linkMinimalDirectedEdges(this),t=t.getNext()}while(t!==this._startDe)}},{key:"getNext",value:function(t){return t.getNext()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Re.constructor_.call(this,t,e)}}])}(Re),Ge=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"setVisited",value:function(t){this._isVisited=t}},{key:"setInResult",value:function(t){this._isInResult=t}},{key:"isCovered",value:function(){return this._isCovered}},{key:"isCoveredSet",value:function(){return this._isCoveredSet}},{key:"setLabel",value:function(t){this._label=t}},{key:"getLabel",value:function(){return this._label}},{key:"setCovered",value:function(t){this._isCovered=t,this._isCoveredSet=!0}},{key:"updateIM",value:function(t){G.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(t)}},{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,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._label=t}}}]),Be=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"isIncidentEdgeInResult",value:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(t){t.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(t){}},{key:"computeMergedLocation",value:function(t,e){var n=V.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==V.BOUNDARY&&(n=i)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return f(i,"setLabel",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this._label?this._label=new Ae(t,e):this._label.setLocation(t,e)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof i){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof Ae)for(var e=arguments[0],n=0;n<2;n++){var r=this.computeMergedLocation(e,n);this._label.getLocation(n)===V.NONE&&this._label.setLocation(n,r)}}},{key:"add",value:function(t){this._edges.insert(t),t.setNode(this)}},{key:"setLabelBoundary",value:function(t){if(null===this._label)return null;var e=V.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case V.BOUNDARY:n=V.INTERIOR;break;case V.INTERIOR:default:n=V.BOUNDARY}this._label.setLocation(t,n)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var t=arguments[0],e=arguments[1];this._coord=t,this._edges=e,this._label=new Ae(0,V.NONE)}}])}(Ge),qe=function(t){function i(){return n(this,i),e(this,i,arguments)}return u(i,t),o(i)}(ee);function Ye(t){return null==t?0:t.color}function ze(t){return null==t?null:t.parent}function He(t,e){null!==t&&(t.color=e)}function Ue(t){return null==t?null:t.left}function Xe(t){return null==t?null:t.right}var Ve=function(t){function i(){var t;return n(this,i),(t=e(this,i)).root_=null,t.size_=0,t}return u(i,t),o(i,[{key:"get",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null}},{key:"put",value:function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var o=r.value;return r.value=e,o}r=r.right}}while(null!==r);var s={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null}},{key:"fixAfterInsertion",value:function(t){var e;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)ze(t)===Ue(ze(ze(t)))?1===Ye(e=Xe(ze(ze(t))))?(He(ze(t),0),He(e,0),He(ze(ze(t)),1),t=ze(ze(t))):(t===Xe(ze(t))&&(t=ze(t),this.rotateLeft(t)),He(ze(t),0),He(ze(ze(t)),1),this.rotateRight(ze(ze(t)))):1===Ye(e=Ue(ze(ze(t))))?(He(ze(t),0),He(e,0),He(ze(ze(t)),1),t=ze(ze(t))):(t===Ue(ze(t))&&(t=ze(t),this.rotateRight(t)),He(ze(t),0),He(ze(ze(t)),1),this.rotateLeft(ze(ze(t))));this.root_.color=0}},{key:"values",value:function(){var t=new pt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=i.successor(e));)t.add(e.value);return t}},{key:"entrySet",value:function(){var t=new J,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=i.successor(e));)t.add(e);return t}},{key:"rotateLeft",value:function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"rotateRight",value:function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"getFirstEntry",value:function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return!0;e=e.right}}return!1}}],[{key:"successor",value:function(t){var e;if(null===t)return null;if(null!==t.right){for(e=t.right;null!==e.left;)e=e.left;return e}e=t.parent;for(var n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e}}])}(qe),je=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof z){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Be){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}}},{key:"print",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(t){for(var e=new pt,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===V.BOUNDARY&&e.add(i)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new Ve,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}]),Ke=function(){function t(){n(this,t)}return o(t,null,[{key:"isNorthern",value:function(e){return e===t.NE||e===t.NW}},{key:"isOpposite",value:function(t,e){return t!==e&&2==(t-e+4)%4}},{key:"commonHalfPlane",value:function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=t<e?t:e;return 0===n&&3===(t>e?t:e)?3:n}},{key:"isInHalfPlane",value:function(e,n){return n===t.SE?e===t.SE||e===t.SW:e===n||e===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];if(0===e&&0===n)throw new _("Cannot compute the quadrant for point ( "+e+", "+n+" )");return e>=0?n>=0?t.NE:t.SE:n>=0?t.NW:t.SW}if(arguments[0]instanceof z&&arguments[1]instanceof z){var i=arguments[0],r=arguments[1];if(r.x===i.x&&r.y===i.y)throw new _("Cannot compute the quadrant for two identical points "+i);return r.x>=i.x?r.y>=i.y?t.NE:t.SE:r.y>=i.y?t.NW:t.SW}}}])}();Ke.NE=0,Ke.NW=1,Ke.SW=2,Ke.SE=3;var We=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compareDirection",value:function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant<t._quadrant?-1:ct.index(t._p0,t._p1,this._p1)}},{key:"getDy",value:function(){return this._dy}},{key:"getCoordinate",value:function(){return this._p0}},{key:"setNode",value:function(t){this._node=t}},{key:"print",value:function(t){var e=Math.atan2(this._dy,this._dx),n=this.getClass().getName(),i=n.lastIndexOf("."),r=n.substring(i+1);t.print(" "+r+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+e+" "+this._label)}},{key:"compareTo",value:function(t){var e=t;return this.compareDirection(e)}},{key:"getDirectedCoordinate",value:function(){return this._p1}},{key:"getDx",value:function(){return this._dx}},{key:"getLabel",value:function(){return this._label}},{key:"getEdge",value:function(){return this._edge}},{key:"getQuadrant",value:function(){return this._quadrant}},{key:"getNode",value:function(){return this._node}},{key:"toString",value:function(){var t=Math.atan2(this._dy,this._dx),e=this.getClass().getName(),n=e.lastIndexOf(".");return" "+e.substring(n+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+t+" "+this._label}},{key:"computeLabel",value:function(t){}},{key:"init",value:function(t,e){this._p0=t,this._p1=e,this._dx=e.x-t.x,this._dy=e.y-t.y,this._quadrant=Ke.quadrant(this._dx,this._dy),G.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var e=arguments[0];this._edge=e}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];t.constructor_.call(this,n,i,r,null)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];t.constructor_.call(this,o),this.init(s,a),this._label=l}}}])}(),Ze=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getNextMin",value:function(){return this._nextMin}},{key:"getDepth",value:function(t){return this._depth[t]}},{key:"setVisited",value:function(t){this._isVisited=t}},{key:"computeDirectedLabel",value:function(){this._label=new Ae(this._edge.getLabel()),this._isForward||this._label.flip()}},{key:"getNext",value:function(){return this._next}},{key:"setDepth",value:function(t,e){if(-999!==this._depth[t]&&this._depth[t]!==e)throw new gt("assigned depths do not match",this.getCoordinate());this._depth[t]=e}},{key:"isInteriorAreaEdge",value:function(){for(var t=!0,e=0;e<2;e++)this._label.isArea(e)&&this._label.getLocation(e,Q.LEFT)===V.INTERIOR&&this._label.getLocation(e,Q.RIGHT)===V.INTERIOR||(t=!1);return t}},{key:"setNextMin",value:function(t){this._nextMin=t}},{key:"print",value:function(t){f(i,"print",this,1).call(this,t),t.print(" "+this._depth[Q.LEFT]+"/"+this._depth[Q.RIGHT]),t.print(" ("+this.getDepthDelta()+")"),this._isInResult&&t.print(" inResult")}},{key:"setMinEdgeRing",value:function(t){this._minEdgeRing=t}},{key:"isLineEdge",value:function(){var t=this._label.isLine(0)||this._label.isLine(1),e=!this._label.isArea(0)||this._label.allPositionsEqual(0,V.EXTERIOR),n=!this._label.isArea(1)||this._label.allPositionsEqual(1,V.EXTERIOR);return t&&e&&n}},{key:"setEdgeRing",value:function(t){this._edgeRing=t}},{key:"getMinEdgeRing",value:function(){return this._minEdgeRing}},{key:"getDepthDelta",value:function(){var t=this._edge.getDepthDelta();return this._isForward||(t=-t),t}},{key:"setInResult",value:function(t){this._isInResult=t}},{key:"getSym",value:function(){return this._sym}},{key:"isForward",value:function(){return this._isForward}},{key:"getEdge",value:function(){return this._edge}},{key:"printEdge",value:function(t){this.print(t),t.print(" "),this._isForward?this._edge.print(t):this._edge.printReverse(t)}},{key:"setSym",value:function(t){this._sym=t}},{key:"setVisitedEdge",value:function(t){this.setVisited(t),this._sym.setVisited(t)}},{key:"setEdgeDepths",value:function(t,e){var n=this.getEdge().getDepthDelta();this._isForward||(n=-n);var i=1;t===Q.LEFT&&(i=-1);var r=Q.opposite(t),o=e+n*i;this.setDepth(t,e),this.setDepth(r,o)}},{key:"getEdgeRing",value:function(){return this._edgeRing}},{key:"isInResult",value:function(){return this._isInResult}},{key:"setNext",value:function(t){this._next=t}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999];var t=arguments[0],e=arguments[1];if(We.constructor_.call(this,t),this._isForward=e,e)this.init(t.getCoordinate(0),t.getCoordinate(1));else{var n=t.getNumPoints()-1;this.init(t.getCoordinate(n),t.getCoordinate(n-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(t,e){return t===V.EXTERIOR&&e===V.INTERIOR?1:t===V.INTERIOR&&e===V.EXTERIOR?-1:0}}])}(We),Je=o(function t(){n(this,t)},[{key:"createNode",value:function(t){return new Be(t,null)}}]),$e=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"printEdges",value:function(t){t.println("Edges:");for(var e=0;e<this._edges.size();e++){t.println("edge "+e+":");var n=this._edges.get(e);n.print(t),n.eiList.print(t)}}},{key:"find",value:function(t){return this._nodes.find(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof Be){var t=arguments[0];return this._nodes.addNode(t)}if(arguments[0]instanceof z){var e=arguments[0];return this._nodes.addNode(e)}}},{key:"getNodeIterator",value:function(){return this._nodes.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(t){_t.out.println(t)}},{key:"isBoundaryNode",value:function(t,e){var n=this._nodes.find(e);if(null===n)return!1;var i=n.getLabel();return null!==i&&i.getLocation(t)===V.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(t,e,n,i){return!!t.equals(n)&&ct.index(t,e,i)===ct.COLLINEAR&&Ke.quadrant(t,e)===Ke.quadrant(n,i)}},{key:"getEdgeEnds",value:function(){return this._edgeEndList}},{key:"debugPrint",value:function(t){_t.out.print(t)}},{key:"getEdgeIterator",value:function(){return this._edges.iterator()}},{key:"findEdgeInSameDirection",value:function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(this.matchInSameDirection(t,e,r[0],r[1]))return i;if(this.matchInSameDirection(t,e,r[r.length-1],r[r.length-2]))return i}return null}},{key:"insertEdge",value:function(t){this._edges.add(t)}},{key:"findEdgeEnd",value:function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null}},{key:"addEdges",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this._edges.add(n);var i=new Ze(n,!0),r=new Ze(n,!1);i.setSym(r),r.setSym(i),this.add(i),this.add(r)}}},{key:"add",value:function(t){this._nodes.add(t),this._edgeEndList.add(t)}},{key:"getNodes",value:function(){return this._nodes.values()}},{key:"findEdge",value:function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(t.equals(r[0])&&e.equals(r[1]))return i}return null}}],[{key:"constructor_",value:function(){if(this._edges=new pt,this._nodes=null,this._edgeEndList=new pt,0===arguments.length)this._nodes=new je(new Je);else if(1===arguments.length){var t=arguments[0];this._nodes=new je(t)}}},{key:"linkResultDirectedEdges",value:function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()}}]),Qe=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"sortShellsAndHoles",value:function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isHole()?n.add(r):e.add(r)}}},{key:"computePolygons",value:function(t){for(var e=new pt,n=t.iterator();n.hasNext();){var i=n.next().toPolygon(this._geometryFactory);e.add(i)}return e}},{key:"placeFreeHoles",value:function(e,n){for(var i=n.iterator();i.hasNext();){var r=i.next();if(null===r.getShell()){var o=t.findEdgeRingContaining(r,e);if(null===o)throw new gt("unable to assign hole to a shell",r.getCoordinate(0));r.setShell(o)}}}},{key:"buildMinimalEdgeRings",value:function(t,e,n){for(var i=new pt,r=t.iterator();r.hasNext();){var o=r.next();if(o.getMaxNodeDegree()>2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else i.add(o)}return i}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new pt,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new Fe(i,this._geometryFactory);e.add(r),r.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return G.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];$e.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new pt,o=this.buildMinimalEdgeRings(i,this._shellList,r);this.sortShellsAndHoles(o,this._shellList,r),this.placeFreeHoles(this._shellList,r)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new pt;var t=arguments[0];this._geometryFactory=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var l=a.next(),u=l.getLinearRing(),h=u.getEnvelopeInternal();if(!h.equals(i)&&h.contains(i)){r=Kt.ptNotInList(n.getCoordinates(),u.getCoordinates());var c=!1;Te.isInRing(r,u.getCoordinates())&&(c=!0),c&&(null===o||s.contains(h))&&(s=(o=l).getLinearRing().getEnvelopeInternal())}}return o}}])}(),tn=o(function t(){n(this,t)},[{key:"getBounds",value:function(){}}]),en=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[tn,w]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}}]),nn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"poll",value:function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)}},{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 0===this._size}},{key:"add",value:function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new pt,this._items.add(null)}}]),rn=o(function t(){n(this,t)},[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}]),on=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{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(t){G.isTrue(null===this._bounds),this._childBoundables.add(t)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[tn,w]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new pt,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}}}]),sn={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return sn.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?At.sort(n,e):At.sort(n);for(var i=t.iterator(),r=0,o=n.length;r<o;r++)i.next(),i.set(n[r])},singletonList:function(t){var e=new pt;return e.add(t),e}},an=function(){function t(){n(this,t)}return o(t,null,[{key:"maxDistance",value:function(e,n,i,r,o,s,a,l){var u=t.distance(e,n,o,s);return u=Math.max(u,t.distance(e,n,a,l)),u=Math.max(u,t.distance(i,r,o,s)),Math.max(u,t.distance(i,r,a,l))}},{key:"distance",value:function(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}},{key:"maximumDistance",value:function(e,n){var i=Math.min(e.getMinX(),n.getMinX()),r=Math.min(e.getMinY(),n.getMinY()),o=Math.max(e.getMaxX(),n.getMaxX()),s=Math.max(e.getMaxY(),n.getMaxY());return t.distance(i,r,o,s)}},{key:"minMaxDistance",value:function(e,n){var i=e.getMinX(),r=e.getMinY(),o=e.getMaxX(),s=e.getMaxY(),a=n.getMinX(),l=n.getMinY(),u=n.getMaxX(),h=n.getMaxY(),c=t.maxDistance(i,r,i,s,a,l,a,h);return c=Math.min(c,t.maxDistance(i,r,i,s,a,l,u,l)),c=Math.min(c,t.maxDistance(i,r,i,s,u,h,a,h)),c=Math.min(c,t.maxDistance(i,r,i,s,u,h,u,l)),c=Math.min(c,t.maxDistance(i,r,o,r,a,l,a,h)),c=Math.min(c,t.maxDistance(i,r,o,r,a,l,u,l)),c=Math.min(c,t.maxDistance(i,r,o,r,u,h,a,h)),c=Math.min(c,t.maxDistance(i,r,o,r,u,h,u,l)),c=Math.min(c,t.maxDistance(o,s,i,s,a,l,a,h)),c=Math.min(c,t.maxDistance(o,s,i,s,a,l,u,l)),c=Math.min(c,t.maxDistance(o,s,i,s,u,h,a,h)),c=Math.min(c,t.maxDistance(o,s,i,s,u,h,u,l)),c=Math.min(c,t.maxDistance(o,s,o,r,a,l,a,h)),c=Math.min(c,t.maxDistance(o,s,o,r,a,l,u,l)),c=Math.min(c,t.maxDistance(o,s,o,r,u,h,a,h)),Math.min(c,t.maxDistance(o,s,o,r,u,h,u,l))}}])}(),ln=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"maximumDistance",value:function(){return an.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}},{key:"expandToQueue",value:function(e,n){var i=t.isComposite(this._boundable1),r=t.isComposite(this._boundable2);if(i&&r)return t.area(this._boundable1)>t.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,e,n),null):(this.expand(this._boundable2,this._boundable1,!0,e,n),null);if(i)return this.expand(this._boundable1,this._boundable2,!1,e,n),null;if(r)return this.expand(this._boundable2,this._boundable1,!0,e,n),null;throw new _("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(t.isComposite(this._boundable1)||t.isComposite(this._boundable2))}},{key:"compareTo",value:function(t){var e=t;return this._distance<e._distance?-1:this._distance>e._distance?1:0}},{key:"expand",value:function(e,n,i,r,o){for(var s=e.getChildBoundables().iterator();s.hasNext();){var a=s.next(),l=null;(l=i?new t(n,a,this._itemDistance):new t(a,n,this._itemDistance)).getDistance()<o&&r.add(l)}}},{key:"getBoundable",value:function(t){return 0===t?this._boundable1:this._boundable2}},{key:"getDistance",value:function(){return this._distance}},{key:"distance",value:function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var t=arguments[0],e=arguments[1],n=arguments[2];this._boundable1=t,this._boundable2=e,this._itemDistance=n,this._distance=this.distance()}},{key:"area",value:function(t){return t.getBounds().getArea()}},{key:"isComposite",value:function(t){return t instanceof on}}])}(),un=o(function t(){n(this,t)},[{key:"visitItem",value:function(t){}}]),hn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"queryInternal",value:function(){if(rt(arguments[2],un)&&arguments[0]instanceof Object&&arguments[1]instanceof on)for(var t=arguments[0],e=arguments[2],n=arguments[1].getChildBoundables(),i=0;i<n.size();i++){var r=n.get(i);this.getIntersectsOp().intersects(r.getBounds(),t)&&(r instanceof on?this.queryInternal(t,r,e):r instanceof en?e.visitItem(r.getItem()):G.shouldNeverReachHere())}else if(rt(arguments[2],nt)&&arguments[0]instanceof Object&&arguments[1]instanceof on)for(var o=arguments[0],s=arguments[2],a=arguments[1].getChildBoundables(),l=0;l<a.size();l++){var u=a.get(l);this.getIntersectsOp().intersects(u.getBounds(),o)&&(u instanceof on?this.queryInternal(o,u,s):u instanceof en?s.add(u.getItem()):G.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this._nodeCapacity}},{key:"lastNode",value:function(t){return t.get(t.size()-1)}},{key:"size",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof on?t+=this.size(n):n instanceof en&&(t+=1)}return t}}},{key:"removeItem",value:function(t,e){for(var n=null,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof en&&r.getItem()===e&&(n=r)}return null!==n&&(t.getChildBoundables().remove(n),!0)}},{key:"itemsTree",value:function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new pt:t}if(1===arguments.length){for(var e=arguments[0],n=new pt,i=e.getChildBoundables().iterator();i.hasNext();){var r=i.next();if(r instanceof on){var o=this.itemsTree(r);null!==o&&n.add(o)}else r instanceof en?n.add(r.getItem()):G.shouldNeverReachHere()}return n.size()<=0?null:n}}},{key:"insert",value:function(t,e){G.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new en(t,e))}},{key:"boundablesAtLevel",value:function(){if(1===arguments.length){var t=arguments[0],e=new pt;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];if(G.isTrue(n>-2),i.getLevel()===n)return r.add(i),null;for(var o=i.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof on?this.boundablesAtLevel(n,s,r):(G.isTrue(s instanceof en),-1===n&&r.add(s))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new pt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,i)}}},{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(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=this.removeItem(i,r);if(o)return!0;for(var s=null,a=i.getChildBoundables().iterator();a.hasNext();){var l=a.next();if(this.getIntersectsOp().intersects(l.getBounds(),n)&&l instanceof on&&(o=this.remove(n,l,r))){s=l;break}}return null!==s&&s.getChildBoundables().isEmpty()&&i.getChildBoundables().remove(s),o}}},{key:"createHigherLevels",value:function(t,e){G.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof on){var i=this.depth(n);i>t&&(t=i)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){G.isTrue(!t.isEmpty());var n=new pt;n.add(this.createNode(e));var i=new pt(t);sn.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var o=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new pt,this._nodeCapacity=null,0===arguments.length)t.constructor_.call(this,t.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var e=arguments[0];G.isTrue(e>1,"Node capacity must be greater than 1"),this._nodeCapacity=e}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t<e?-1:0}}])}();hn.IntersectsOp=function(){},hn.DEFAULT_NODE_CAPACITY=10;var cn=o(function t(){n(this,t)},[{key:"distance",value:function(t,e){}}]),fn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"createParentBoundablesFromVerticalSlices",value:function(t,e){G.isTrue(t.length>0);for(var n=new pt,i=0;i<t.length;i++)n.addAll(this.createParentBoundablesFromVerticalSlice(t[i],e));return n}},{key:"nearestNeighbourK",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.nearestNeighbourK(t,A.POSITIVE_INFINITY,e)}if(3===arguments.length){var n=arguments[0],r=arguments[2],o=arguments[1],s=new nn;s.add(n);for(var a=new nn;!s.isEmpty()&&o>=0;){var l=s.poll(),u=l.getDistance();if(u>=o)break;l.isLeaves()?a.size()<r?a.add(l):(a.peek().getDistance()>u&&(a.poll(),a.add(l)),o=a.peek().getDistance()):l.expandToQueue(s,o)}return i.getItems(a)}}},{key:"createNode",value:function(t){return new gn(t)}},{key:"size",value:function(){return 0===arguments.length?f(i,"size",this,1).call(this):f(i,"size",this,1).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof U))return f(i,"insert",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;f(i,"insert",this,1).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return i.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),i=new Array(e).fill(null),r=t.iterator(),o=0;o<e;o++){i[o]=new pt;for(var s=0;r.hasNext()&&s<n;){var a=r.next();i[o].add(a),s++}}return i}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];return f(i,"query",this,1).call(this,t)}if(2===arguments.length){var e=arguments[0],n=arguments[1];f(i,"query",this,1).call(this,e,n)}}},{key:"getComparator",value:function(){return i.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(t,e){return f(i,"createParentBoundables",this,1).call(this,t,e)}},{key:"remove",value:function(){if(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof U){var t=arguments[0],e=arguments[1];return f(i,"remove",this,1).call(this,t,e)}return f(i,"remove",this,1).apply(this,arguments)}},{key:"depth",value:function(){return 0===arguments.length?f(i,"depth",this,1).call(this):f(i,"depth",this,1).apply(this,arguments)}},{key:"createParentBoundables",value:function(t,e){G.isTrue(!t.isEmpty());var n=Math.trunc(Math.ceil(t.size()/this.getNodeCapacity())),r=new pt(t);sn.sort(r,i.xComparator);var o=this.verticalSlices(r,Math.trunc(Math.ceil(Math.sqrt(n))));return this.createParentBoundablesFromVerticalSlices(o,e)}},{key:"nearestNeighbour",value:function(){if(1===arguments.length){if(rt(arguments[0],cn)){var t=arguments[0];if(this.isEmpty())return null;var e=new ln(this.getRoot(),this.getRoot(),t);return this.nearestNeighbour(e)}if(arguments[0]instanceof ln){var n=arguments[0],i=A.POSITIVE_INFINITY,r=null,o=new nn;for(o.add(n);!o.isEmpty()&&i>0;){var s=o.poll(),a=s.getDistance();if(a>=i)break;s.isLeaves()?(i=a,r=s):s.expandToQueue(o,i)}return null===r?null:[r.getBoundable(0).getItem(),r.getBoundable(1).getItem()]}}else{if(2===arguments.length){var l=arguments[0],u=arguments[1];if(this.isEmpty()||l.isEmpty())return null;var h=new ln(this.getRoot(),l.getRoot(),u);return this.nearestNeighbour(h)}if(3===arguments.length){var c=arguments[2],f=new en(arguments[0],arguments[1]),g=new ln(this.getRoot(),f,c);return this.nearestNeighbour(g)[0]}if(4===arguments.length){var d=arguments[2],p=arguments[3],y=new en(arguments[0],arguments[1]),v=new ln(this.getRoot(),y,d);return this.nearestNeighbourK(v,p)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=A.POSITIVE_INFINITY,i=new nn;for(i.add(t);!i.isEmpty();){var r=i.poll(),o=r.getDistance();if(o>e)return!1;if(r.maximumDistance()<=e)return!0;if(r.isLeaves()){if((n=o)<=e)return!0}else r.expandToQueue(i,n)}return!1}if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2],u=new ln(this.getRoot(),s.getRoot(),a);return this.isWithinDistance(u,l)}}},{key:"interfaces_",get:function(){return[rn,w]}}],[{key:"constructor_",value:function(){if(0===arguments.length)i.constructor_.call(this,i.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];hn.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return i.avg(t.getMinX(),t.getMaxX())}},{key:"avg",value:function(t,e){return(t+e)/2}},{key:"getItems",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;!t.isEmpty();){var i=t.poll();e[n]=i.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return i.avg(t.getMinY(),t.getMaxY())}}])}(hn),gn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new U(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];on.constructor_.call(this,t)}}])}(on);fn.STRtreeNode=gn,fn.xComparator=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[R]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreX(t.getBounds()),fn.centreX(e.getBounds()))}}])),fn.yComparator=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[R]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreY(t.getBounds()),fn.centreY(e.getBounds()))}}])),fn.intersectsOp=new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}])),fn.DEFAULT_NODE_CAPACITY=10;var dn=function(){function t(){n(this,t)}return o(t,null,[{key:"relativeSign",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"compare",value:function(e,n,i){if(n.equals2D(i))return 0;var r=t.relativeSign(n.x,i.x),o=t.relativeSign(n.y,i.y);switch(e){case 0:return t.compareValue(r,o);case 1:return t.compareValue(o,r);case 2:return t.compareValue(o,-r);case 3:return t.compareValue(-r,o);case 4:return t.compareValue(-r,-o);case 5:return t.compareValue(-o,-r);case 6:return t.compareValue(-o,r);case 7:return t.compareValue(r,-o)}return G.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}])}(),pn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(t){var e=t;return this.segmentIndex<e.segmentIndex?-1:this.segmentIndex>e.segmentIndex?1:this.coord.equals2D(e.coord)?0:this._isInterior?e._isInterior?dn.compare(this._segmentOctant,this.coord,e.coord):1:-1}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t}},{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 t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._segString=t,this.coord=new z(e),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))}}]),yn=o(function t(){n(this,t)},[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),vn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getSplitCoordinates",value:function(){var t=new jt;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new pt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}}},{key:"createSplitEdgePts",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2;if(2===n)return[new z(t.coord),new z(e.coord)];var i=this._edge.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this._edge.getCoordinate(a);return r&&(o[s]=new z(e.coord)),o}},{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"findCollapsesFromExistingVertices",value:function(t){for(var e=0;e<this._edge.size()-2;e++){var n=this._edge.getCoordinate(e);this._edge.getCoordinate(e+1);var i=this._edge.getCoordinate(e+2);n.equals2D(i)&&t.add(st.valueOf(e+1))}}},{key:"addEdgeCoordinates",value:function(t,e,n){var i=this.createSplitEdgePts(t,e);n.add(i,!1)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints(),this.addCollapsedNodes();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"findCollapseIndex",value:function(t,e,n){if(!t.coord.equals2D(e.coord))return!1;var i=e.segmentIndex-t.segmentIndex;return e.isInterior()||i--,1===i&&(n[0]=t.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(t){for(var e=new Array(1).fill(null),n=this.iterator(),i=n.next();n.hasNext();){var r=n.next();this.findCollapseIndex(i,r,e)&&t.add(st.valueOf(e[0])),i=r}}},{key:"getEdge",value:function(){return this._edge}},{key:"addEndpoints",value:function(){var t=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(t),t)}},{key:"createSplitEdge",value:function(t,e){var n=this.createSplitEdgePts(t,e);return new xn(n,this._edge.getData())}},{key:"add",value:function(t,e){var n=new pn(this._edge,t,e,this._edge.getSegmentOctant(e)),i=this._nodeMap.get(n);return null!==i?(G.isTrue(i.coord.equals2D(t),"Found equal nodes with different coordinates"),i):(this._nodeMap.put(n,n),n)}},{key:"checkSplitEdgesCorrectness",value:function(t){var e=this._edge.getCoordinates(),n=t.get(0).getCoordinate(0);if(!n.equals2D(e[0]))throw new D("bad split edge start point at "+n);var i=t.get(t.size()-1).getCoordinates(),r=i[i.length-1];if(!r.equals2D(e[e.length-1]))throw new D("bad split edge end point at "+r)}}],[{key:"constructor_",value:function(){this._nodeMap=new Ve,this._edge=null;var t=arguments[0];this._edge=t}}]),mn=function(){function t(){n(this,t)}return o(t,null,[{key:"octant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];if(0===e&&0===n)throw new _("Cannot compute the octant for point ( "+e+", "+n+" )");var i=Math.abs(e),r=Math.abs(n);return e>=0?n>=0?i>=r?0:1:i>=r?7:6:n>=0?i>=r?3:2:i>=r?4:5}if(arguments[0]instanceof z&&arguments[1]instanceof z){var o=arguments[0],s=arguments[1],a=s.x-o.x,l=s.y-o.y;if(0===a&&0===l)throw new _("Cannot compute the octant for two identical points "+o);return t.octant(a,l)}}}])}(),_n=o(function t(){n(this,t)},[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(t){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(t){}},{key:"getData",value:function(){}}]),kn=o(function t(){n(this,t)},[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[_n]}}]),xn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(t){return this._pts[t]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}},{key:"setData",value:function(t){this._data=t}},{key:"safeOctant",value:function(t,e){return t.equals2D(e)?0:mn.octant(t,e)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],i=arguments[3],r=new z(arguments[0].getIntersection(i));this.addIntersection(r,n)}}},{key:"toString",value:function(){return Ne.toLineString(new $t(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(t,e){var n=e,i=n+1;if(i<this._pts.length){var r=this._pts[i];t.equals2D(r)&&(n=i)}return this._nodeList.add(t,n)}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}},{key:"interfaces_",get:function(){return[kn]}}],[{key:"constructor_",value:function(){this._nodeList=new vn(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e}},{key:"getNodedSubstrings",value:function(){if(1===arguments.length){var e=arguments[0],n=new pt;return t.getNodedSubstrings(e,n),n}if(2===arguments.length)for(var i=arguments[1],r=arguments[0].iterator();r.hasNext();)r.next().getNodeList().addSplitEdges(i)}}])}(),En=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof t){var e=arguments[0],n=ct.index(this.p0,this.p1,e.p0),i=ct.index(this.p0,this.p1,e.p1);return n>=0&&i>=0||n<=0&&i<=0?Math.max(n,i):0}if(arguments[0]instanceof z){var r=arguments[0];return ct.index(this.p0,this.p1,r)}}},{key:"toGeometry",value:function(t){return t.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new Pe;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof z){var e=arguments[0];if(e.equals(this.p0)||e.equals(this.p1))return new z(e);var n=this.projectionFactor(e),i=new z;return i.x=this.p0.x+n*(this.p1.x-this.p0.x),i.y=this.p0.y+n*(this.p1.y-this.p0.y),i}if(arguments[0]instanceof t){var r=arguments[0],o=this.projectionFactor(r.p0),s=this.projectionFactor(r.p1);if(o>=1&&s>=1)return null;if(o<=0&&s<=0)return null;var a=this.project(r.p0);o<0&&(a=this.p0),o>1&&(a=this.p1);var l=this.project(r.p1);return s<0&&(l=this.p0),s>1&&(l=this.p1),new t(a,l)}}},{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(t){return 0===t?this.p0:this.p1}},{key:"distancePerpendicular",value:function(t){return xt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return t.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?A.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=A.MAX_VALUE,r=null,o=this.closestPoint(t.p0);i=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(r=s.distance(t.p1))<i&&(i=r,n[0]=s,n[1]=t.p1);var a=t.closestPoint(this.p0);(r=a.distance(this.p0))<i&&(i=r,n[0]=this.p0,n[1]=a);var l=t.closestPoint(this.p1);return(r=l.distance(this.p1))<i&&(i=r,n[0]=this.p1,n[1]=l),n}},{key:"closestPoint",value:function(t){var e=this.projectionFactor(t);return e>0&&e<1?this.project(t):this.p0.distance(t)<this.p1.distance(t)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(t){var e=t,n=this.p0.compareTo(e.p0);return 0!==n?n:this.p1.compareTo(e.p1)}},{key:"reverse",value:function(){var t=this.p0;this.p0=this.p1,this.p1=t}},{key:"equalsTopo",value:function(t){return this.p0.equals(t.p0)&&this.p1.equals(t.p1)||this.p0.equals(t.p1)&&this.p1.equals(t.p0)}},{key:"lineIntersection",value:function(t){return mt.intersection(this.p0,this.p1,t.p0,t.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(t,e){var n=this.p0.x+t*(this.p1.x-this.p0.x),i=this.p0.y+t*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y,s=Math.sqrt(r*r+o*o),a=0,l=0;if(0!==e){if(s<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");a=e*r/s,l=e*o/s}return new z(n-l,i+a)}},{key:"setCoordinates",value:function(){if(1===arguments.length){var t=arguments[0];this.setCoordinates(t.p0,t.p1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p0.x=e.x,this.p0.y=e.y,this.p1.x=n.x,this.p1.y=n.y}}},{key:"segmentFraction",value:function(t){var e=this.projectionFactor(t);return e<0?e=0:(e>1||A.isNaN(e))&&(e=1),e}},{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(t){var e=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),i=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=e*e+n*n,o=e*e-n*n,s=t.getX(),a=t.getY();return new z((-o*s-2*e*n*a-2*e*i)/r,(o*a-2*e*n*s-2*n*i)/r)}},{key:"distance",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return xt.segmentToSegment(this.p0,this.p1,e.p0,e.p1)}if(arguments[0]instanceof z){var n=arguments[0];return xt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new z;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e}},{key:"hashCode",value:function(){var t=A.doubleToLongBits(this.p0.x);t^=31*A.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=A.doubleToLongBits(this.p1.x);return n^=31*A.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)}},{key:"interfaces_",get:function(){return[x,w]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)t.constructor_.call(this,new z,new z);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.p0,e.p1)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.p0=n,this.p1=i}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];t.constructor_.call(this,new z(r,o),new z(s,a))}}},{key:"midPoint",value:function(t,e){return new z((t.x+e.x)/2,(t.y+e.y)/2)}}])}(),wn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"overlap",value:function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new En,this._overlapSeg2=new En}}]),In=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getLineSegment",value:function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]}},{key:"computeSelect",value:function(t,e,n,i){var r=this._pts[e],o=this._pts[n];if(n-e==1)return i.select(this,e),null;if(!t.intersects(r,o))return null;var s=Math.trunc((e+n)/2);e<s&&this.computeSelect(t,e,s,i),s<n&&this.computeSelect(t,s,n,i)}},{key:"getCoordinates",value:function(){for(var t=new Array(this._end-this._start+1).fill(null),e=0,n=this._start;n<=this._end;n++)t[e++]=this._pts[n];return t}},{key:"computeOverlaps",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.computeOverlaps(this._start,this._end,t,t._start,t._end,e)}else if(6===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=arguments[3],s=arguments[4],a=arguments[5];if(i-n==1&&s-o==1)return a.overlap(this,n,r,o),null;if(!this.overlaps(n,i,r,o,s))return null;var l=Math.trunc((n+i)/2),u=Math.trunc((o+s)/2);n<l&&(o<u&&this.computeOverlaps(n,l,r,o,u,a),u<s&&this.computeOverlaps(n,l,r,u,s,a)),l<i&&(o<u&&this.computeOverlaps(l,i,r,o,u,a),u<s&&this.computeOverlaps(l,i,r,u,s,a))}}},{key:"setId",value:function(t){this._id=t}},{key:"select",value:function(t,e){this.computeSelect(t,this._start,this._end,e)}},{key:"getEnvelope",value:function(){if(null===this._env){var t=this._pts[this._start],e=this._pts[this._end];this._env=new U(t,e)}return this._env}},{key:"overlaps",value:function(t,e,n,i,r){return U.intersects(this._pts[t],this._pts[e],n._pts[i],n._pts[r])}},{key:"getEndIndex",value:function(){return this._end}},{key:"getStartIndex",value:function(){return this._start}},{key:"getContext",value:function(){return this._context}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=i}}]),Mn=function(){function t(){n(this,t)}return o(t,null,[{key:"findChainEnd",value:function(t,e){for(var n=e;n<t.length-1&&t[n].equals2D(t[n+1]);)n++;if(n>=t.length-1)return t.length-1;for(var i=Ke.quadrant(t[n],t[n+1]),r=e+1;r<t.length&&(t[r-1].equals2D(t[r])||Ke.quadrant(t[r-1],t[r])===i);)r++;return r-1}},{key:"getChains",value:function(){if(1===arguments.length){var e=arguments[0];return t.getChains(e,null)}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=new pt,o=0;do{var s=t.findChainEnd(n,o),a=new In(n,o,s,i);r.add(a),o=s}while(o<n.length-1);return r}}}])}(),Sn=o(function t(){n(this,t)},[{key:"computeNodes",value:function(t){}},{key:"getNodedSubstrings",value:function(){}}]),bn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"setSegmentIntersector",value:function(t){this._segInt=t}},{key:"interfaces_",get:function(){return[Sn]}}],[{key:"constructor_",value:function(){if(this._segInt=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}}}]),Nn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getMonotoneChains",value:function(){return this._monoChains}},{key:"getNodedSubstrings",value:function(){return xn.getNodedSubstrings(this._nodedSegStrings)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(t){for(var e=Mn.getChains(t.getCoordinates(),t).iterator();e.hasNext();){var n=e.next();n.setId(this._idCounter++),this._index.insert(n.getEnvelope(),n),this._monoChains.add(n)}}},{key:"computeNodes",value:function(t){this._nodedSegStrings=t;for(var e=t.iterator();e.hasNext();)this.add(e.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var t=new Ln(this._segInt),e=this._monoChains.iterator();e.hasNext();)for(var n=e.next(),i=this._index.query(n.getEnvelope()).iterator();i.hasNext();){var r=i.next();if(r.getId()>n.getId()&&(n.computeOverlaps(r,t),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new pt,this._index=new fn,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];bn.constructor_.call(this,t)}}}])}(bn),Ln=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"overlap",value:function(){if(4!==arguments.length)return f(i,"overlap",this,1).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],r=arguments[0].getContext(),o=e.getContext();this._si.processIntersections(r,t,o,n)}}],[{key:"constructor_",value:function(){this._si=null;var t=arguments[0];this._si=t}}])}(wn);Nn.SegmentOverlapAction=Ln;var Pn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isDeletable",value:function(t,e,n,i){var r=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(r,o,s)&&!!this.isShallow(r,o,s,i)&&this.isShallowSampled(r,o,t,n,i)}},{key:"deleteShallowConcavities",value:function(){for(var e=1,n=this.findNextNonDeletedIndex(e),i=this.findNextNonDeletedIndex(n),r=!1;i<this._inputLine.length;){var o=!1;this.isDeletable(e,n,i,this._distanceTol)&&(this._isDeleted[n]=t.DELETE,o=!0,r=!0),e=o?i:n,n=this.findNextNonDeletedIndex(e),i=this.findNextNonDeletedIndex(n)}return r}},{key:"isShallowConcavity",value:function(t,e,n,i){return ct.index(t,e,n)===this._angleOrientation&&xt.pointToSegment(e,t,n)<i}},{key:"isShallowSampled",value:function(e,n,i,r,o){var s=Math.trunc((r-i)/t.NUM_PTS_TO_CHECK);s<=0&&(s=1);for(var a=i;a<r;a+=s)if(!this.isShallow(e,n,this._inputLine[a],o))return!1;return!0}},{key:"isConcave",value:function(t,e,n){return ct.index(t,e,n)===this._angleOrientation}},{key:"simplify",value:function(t){this._distanceTol=Math.abs(t),t<0&&(this._angleOrientation=ct.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var e=!1;do{e=this.deleteShallowConcavities()}while(e);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(e){for(var n=e+1;n<this._inputLine.length&&this._isDeleted[n]===t.DELETE;)n++;return n}},{key:"isShallow",value:function(t,e,n,i){return xt.pointToSegment(e,t,n)<i}},{key:"collapseLine",value:function(){for(var e=new jt,n=0;n<this._inputLine.length;n++)this._isDeleted[n]!==t.DELETE&&e.add(this._inputLine[n]);return e.toCoordinateArray()}}],[{key:"constructor_",value:function(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=ct.COUNTERCLOCKWISE;var t=arguments[0];this._inputLine=t}},{key:"simplify",value:function(e,n){return new t(e).simplify(n)}}])}();Pn.INIT=0,Pn.DELETE=1,Pn.KEEP=1,Pn.NUM_PTS_TO_CHECK=10;var Cn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getCoordinates",value:function(){return this._ptList.toArray(t.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"addPt",value:function(t){var e=new z(t);if(this._precisionModel.makePrecise(e),this.isRedundant(e))return null;this._ptList.add(e)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(t,e){if(e)for(var n=0;n<t.length;n++)this.addPt(t[n]);else for(var i=t.length-1;i>=0;i--)this.addPt(t[i])}},{key:"isRedundant",value:function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)<this._minimimVertexDistance}},{key:"toString",value:function(){return(new se).createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this._ptList.size()<1)return null;var t=new z(this._ptList.get(0)),e=this._ptList.get(this._ptList.size()-1);if(t.equals(e))return null;this._ptList.add(t)}},{key:"setMinimumVertexDistance",value:function(t){this._minimimVertexDistance=t}}],[{key:"constructor_",value:function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new pt}}])}();Cn.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var Tn=function(){function t(){n(this,t)}return o(t,null,[{key:"toDegrees",value:function(t){return 180*t/Math.PI}},{key:"normalize",value:function(e){for(;e>Math.PI;)e-=t.PI_TIMES_2;for(;e<=-Math.PI;)e+=t.PI_TIMES_2;return e}},{key:"angle",value:function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}}},{key:"isAcute",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)<0}},{key:"interiorAngle",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i);return Math.abs(o-r)}},{key:"normalizePositive",value:function(e){if(e<0){for(;e<0;)e+=t.PI_TIMES_2;e>=t.PI_TIMES_2&&(e=0)}else{for(;e>=t.PI_TIMES_2;)e-=t.PI_TIMES_2;e<0&&(e=0)}return e}},{key:"angleBetween",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i);return t.diff(r,o)}},{key:"diff",value:function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n}},{key:"toRadians",value:function(t){return t*Math.PI/180}},{key:"getTurn",value:function(e,n){var i=Math.sin(n-e);return i>0?t.COUNTERCLOCKWISE:i<0?t.CLOCKWISE:t.NONE}},{key:"angleBetweenOriented",value:function(e,n,i){var r=t.angle(n,e),o=t.angle(n,i)-r;return o<=-Math.PI?o+t.PI_TIMES_2:o>Math.PI?o-t.PI_TIMES_2:o}}])}();Tn.PI_TIMES_2=2*Math.PI,Tn.PI_OVER_2=Math.PI/2,Tn.PI_OVER_4=Math.PI/4,Tn.COUNTERCLOCKWISE=ct.COUNTERCLOCKWISE,Tn.CLOCKWISE=ct.CLOCKWISE,Tn.NONE=ct.COLLINEAR;var On=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"addNextSegment",value:function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,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 n=ct.index(this._s0,this._s1,this._s2),i=n===ct.CLOCKWISE&&this._side===Q.LEFT||n===ct.COUNTERCLOCKWISE&&this._side===Q.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new En(t,e),i=new En;this.computeOffsetSegment(n,Q.LEFT,this._distance,i);var r=new En;this.computeOffsetSegment(n,Q.RIGHT,this._distance,r);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case v.CAP_ROUND:this._segList.addPt(i.p1),this.addDirectedFillet(e,a+Math.PI/2,a-Math.PI/2,ct.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case v.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case v.CAP_SQUARE:var l=new z;l.x=Math.abs(this._distance)*Math.cos(a),l.y=Math.abs(this._distance)*Math.sin(a);var u=new z(i.p1.x+l.x,i.p1.y+l.y),h=new z(r.p1.x+l.x,r.p1.y+l.y);this._segList.addPt(u),this._segList.addPt(h)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,i){var r=mt.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==r&&(i<=0?1:r.distance(t)/Math.abs(i))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null;this.addLimitedMitreJoin(e,n,i,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(e,n){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*t.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===v.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===v.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(n&&this._segList.addPt(this._offset0.p1),this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,e,this._distance),this._segList.addPt(this._offset1.p0))}},{key:"createSquare",value:function(t){this._segList.addPt(new z(t.x+this._distance,t.y+this._distance)),this._segList.addPt(new z(t.x+this._distance,t.y-this._distance)),this._segList.addPt(new z(t.x-this._distance,t.y-this._distance)),this._segList.addPt(new z(t.x-this._distance,t.y+this._distance)),this._segList.closeRing()}},{key:"addSegments",value:function(t,e){this._segList.addPts(t,e)}},{key:"addFirstSegment",value:function(){this._segList.addPt(this._offset1.p0)}},{key:"addCornerFillet",value:function(t,e,n,i,r){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),l=n.x-t.x,u=n.y-t.y,h=Math.atan2(u,l);i===ct.CLOCKWISE?a<=h&&(a+=2*Math.PI):a>=h&&(a-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,a,h,i,r),this._segList.addPt(n)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(t,e,n,i){var r=this._seg0.p1,o=Tn.angle(r,this._seg0.p0),s=Tn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=Tn.normalize(o+s),l=Tn.normalize(a+Math.PI),u=i*n,h=n-u*Math.abs(Math.sin(s)),c=r.x+u*Math.cos(l),f=r.y+u*Math.sin(l),g=new z(c,f),d=new En(r,g),p=d.pointAlongOffset(1,h),y=d.pointAlongOffset(1,-h);this._side===Q.LEFT?(this._segList.addPt(p),this._segList.addPt(y)):(this._segList.addPt(y),this._segList.addPt(p))}},{key:"addDirectedFillet",value:function(t,e,n,i,r){var o=i===ct.CLOCKWISE?-1:1,s=Math.abs(e-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;for(var l=s/a,u=new z,h=0;h<a;h++){var c=e+o*h*l;u.x=t.x+r*Math.cos(c),u.y=t.y+r*Math.sin(c),this._segList.addPt(u)}}},{key:"computeOffsetSegment",value:function(t,e,n,i){var r=e===Q.LEFT?1:-1,o=t.p1.x-t.p0.x,s=t.p1.y-t.p0.y,a=Math.sqrt(o*o+s*s),l=r*n*o/a,u=r*n*s/a;i.p0.x=t.p0.x-u,i.p0.y=t.p0.y+l,i.p1.x=t.p1.x-u,i.p1.y=t.p1.y+l}},{key:"addInsideTurn",value:function(e,n){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*t.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var i=new z((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(i);var r=new z((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(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(t){var e=new z(t.x+this._distance,t.y);this._segList.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)}},{key:"init",value:function(e){this._distance=e,this._maxCurveSegmentError=e*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Cn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(e*t.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===v.JOIN_BEVEL||this._bufParams.getJoinStyle()===v.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,ct.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 e=arguments[0],n=arguments[1],i=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new Pe,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===v.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(i)}}])}();On.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,On.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,On.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,On.MAX_CLOSING_SEG_LEN_FACTOR=80;var An=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getOffsetCurve",value:function(t,e){if(this._distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var o=r.getCoordinates();return n&&Kt.reverse(o),o}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var r=Pn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Q.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{n.addSegments(t,!1);var a=Pn.simplify(t,i),l=a.length-1;n.initSideSegments(a[0],a[1],Q.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(a[u],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);e===Q.RIGHT&&(i=-i);var r=Pn.simplify(t,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(r[s],a)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this._distance),i=Pn.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],Q.LEFT);for(var o=2;o<=r;o++)e.addNextSegment(i[o],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var s=Pn.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],Q.LEFT);for(var l=a-2;l>=0;l--)e.addNextSegment(s[l],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()}},{key:"computePointCurve",value:function(t,e){switch(this._bufParams.getEndCapStyle()){case v.CAP_ROUND:e.createCircle(t);break;case v.CAP_SQUARE:e.createSquare(t)}}},{key:"getLineCurve",value:function(t,e){if(this._distance=e,this.isLineOffsetEmpty(e))return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this._bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);return i.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(t){return t*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(e,n,i){if(this._distance=i,e.length<=2)return this.getLineCurve(e,i);if(0===i)return t.copyCoordinates(e);var r=this.getSegGen(i);return this.computeRingBufferCurve(e,n,r),r.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){var r=Pn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Q.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{var a=Pn.simplify(t,i),l=a.length-1;n.initSideSegments(a[0],a[1],Q.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(a[u],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(t){return new On(this._precisionModel,this._bufParams,t)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e}},{key:"copyCoordinates",value:function(t){for(var e=new Array(t.length).fill(null),n=0;n<e.length;n++)e[n]=new z(t[n]);return e}}])}(),Rn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"findStabbedSegments",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new pt,n=this._subgraphs.iterator();n.hasNext();){var i=n.next(),r=i.getEnvelope();t.y<r.getMinY()||t.y>r.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(rt(arguments[2],nt)&&arguments[0]instanceof z&&arguments[1]instanceof Ze){for(var o=arguments[0],s=arguments[1],a=arguments[2],l=s.getEdge().getCoordinates(),u=0;u<l.length-1;u++)if(this._seg.p0=l[u],this._seg.p1=l[u+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)<o.x||this._seg.isHorizontal()||o.y<this._seg.p0.y||o.y>this._seg.p1.y||ct.index(this._seg.p0,this._seg.p1,o)===ct.RIGHT)){var h=s.getDepth(Q.LEFT);this._seg.p0.equals(l[u])||(h=s.getDepth(Q.RIGHT));var c=new Dn(this._seg,h);a.add(c)}}else if(rt(arguments[2],nt)&&arguments[0]instanceof z&&rt(arguments[1],nt))for(var f=arguments[0],g=arguments[2],d=arguments[1].iterator();d.hasNext();){var p=d.next();p.isForward()&&this.findStabbedSegments(f,p,g)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:sn.min(e)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new En;var t=arguments[0];this._subgraphs=t}}]),Dn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"compareTo",value:function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)}},{key:"compareX",value:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.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 t=arguments[0],e=arguments[1];this._upwardSeg=new En(t),this._leftDepth=e}}]);Rn.DepthSegment=Dn;var Fn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,null,[{key:"constructor_",value:function(){m.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}])}(m),Gn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getY",value:function(){var t=this.y/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getCoordinate",value:function(){var t=new z;return t.x=this.getX(),t.y=this.getY(),t}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this.x=n,this.y=i,this.w=1}else if(arguments[0]instanceof t&&arguments[1]instanceof t){var r=arguments[0],o=arguments[1];this.x=r.y*o.w-o.y*r.w,this.y=o.x*r.w-r.x*o.w,this.w=r.x*o.y-o.x*r.y}else if(arguments[0]instanceof z&&arguments[1]instanceof z){var s=arguments[0],a=arguments[1];this.x=s.y-a.y,this.y=a.x-s.x,this.w=s.x*a.y-a.x*s.y}}else if(3===arguments.length){var l=arguments[0],u=arguments[1],h=arguments[2];this.x=l,this.y=u,this.w=h}else if(4===arguments.length){var c=arguments[0],f=arguments[1],g=arguments[2],d=arguments[3],p=c.y-f.y,y=f.x-c.x,v=c.x*f.y-f.x*c.y,m=g.y-d.y,_=d.x-g.x,k=g.x*d.y-d.x*g.y;this.x=y*k-_*v,this.y=m*v-p*k,this.w=p*_-m*y}}}])}(),Bn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"area",value:function(){return t.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return t.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(e){if(null===e)throw new _("Supplied point is null.");return t.interpolateZ(e,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return t.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return t.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return t.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return t.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return t.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return t.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}},{key:"area",value:function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)}},{key:"signedArea",value:function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2}},{key:"det",value:function(t,e,n,i){return t*i-e*n}},{key:"interpolateZ",value:function(t,e,n,i){var r=e.x,o=e.y,s=n.x-r,a=i.x-r,l=n.y-o,u=i.y-o,h=s*u-a*l,c=t.x-r,f=t.y-o,g=(u*c-a*f)/h,d=(-l*c+s*f)/h;return e.getZ()+g*(n.getZ()-e.getZ())+d*(i.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var i=t.distance(e),r=e.distance(n),o=n.distance(t),s=i;return r>s&&(s=r),o>s&&(s=o),s}},{key:"circumcentreDD",value:function(t,e,n){var i=lt.valueOf(t.x).subtract(n.x),r=lt.valueOf(t.y).subtract(n.y),o=lt.valueOf(e.x).subtract(n.x),s=lt.valueOf(e.y).subtract(n.y),a=lt.determinant(i,r,o,s).multiply(2),l=i.sqr().add(r.sqr()),u=o.sqr().add(s.sqr()),h=lt.determinant(r,l,s,u),c=lt.determinant(i,l,o,u),f=lt.valueOf(n.x).subtract(h.divide(a)).doubleValue(),g=lt.valueOf(n.y).add(c.divide(a)).doubleValue();return new z(f,g)}},{key:"isAcute",value:function(t,e,n){return!!Tn.isAcute(t,e,n)&&!!Tn.isAcute(e,n,t)&&!!Tn.isAcute(n,t,e)}},{key:"circumcentre",value:function(e,n,i){var r=i.x,o=i.y,s=e.x-r,a=e.y-o,l=n.x-r,u=n.y-o,h=2*t.det(s,a,l,u),c=t.det(a,s*s+a*a,u,l*l+u*u),f=t.det(s,s*s+a*a,l,l*l+u*u);return new z(r-c/h,o+f/h)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new Gn(t.x+n/2,t.y+i/2,1),o=new Gn(t.x-i+n/2,t.y+n+i/2,1);return new Gn(r,o)}},{key:"angleBisector",value:function(t,e,n){var i=e.distance(t),r=i/(i+e.distance(n)),o=n.x-t.x,s=n.y-t.y;return new z(t.x+r*o,t.y+r*s)}},{key:"area3D",value:function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=e.getZ()-t.getZ(),s=n.x-t.x,a=n.y-t.y,l=n.getZ()-t.getZ(),u=r*l-o*a,h=o*s-i*l,c=i*a-r*s,f=u*u+h*h+c*c;return Math.sqrt(f)/2}},{key:"centroid",value:function(t,e,n){var i=(t.x+e.x+n.x)/3,r=(t.y+e.y+n.y)/3;return new z(i,r)}},{key:"inCentre",value:function(t,e,n){var i=e.distance(n),r=t.distance(n),o=t.distance(e),s=i+r+o,a=(i*t.x+r*e.x+o*n.x)/s,l=(i*t.y+r*e.y+o*n.y)/s;return new z(a,l)}}])}(),qn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"addRingSide",value:function(t,e,n,i,r){if(0===e&&t.length<zt.MINIMUM_VALID_SIZE)return null;var o=i,s=r;t.length>=zt.MINIMUM_VALID_SIZE&&ct.isCCW(t)&&(o=r,s=i,n=Q.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,Q.LEFT,V.EXTERIOR,V.INTERIOR),this.addRingSide(t,e,Q.RIGHT,V.INTERIOR,V.EXTERIOR)}},{key:"addPoint",value:function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,V.EXTERIOR,V.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this._distance,n=Q.LEFT;this._distance<0&&(e=-this._distance,n=Q.RIGHT);var i=t.getExteriorRing(),r=Kt.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addRingSide(r,e,n,V.EXTERIOR,V.INTERIOR);for(var o=0;o<t.getNumInteriorRing();o++){var s=t.getInteriorRingN(o),a=Kt.removeRepeatedPoints(s.getCoordinates());this._distance>0&&this.isErodedCompletely(s,-this._distance)||this.addRingSide(a,e,Q.opposite(n),V.INTERIOR,V.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new Bn(t[0],t[1],t[2]),i=n.inCentre();return xt.pointToSegment(i,n.p0,n.p1)<Math.abs(e)}},{key:"addLineString",value:function(t){if(this._curveBuilder.isLineOffsetEmpty(this._distance))return null;var e=Kt.removeRepeatedPoints(t.getCoordinates());if(Kt.isRing(e)&&!this._curveBuilder.getBufferParameters().isSingleSided())this.addRingBothSides(e,this._distance);else{var n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,V.EXTERIOR,V.INTERIOR)}}},{key:"addCurve",value:function(t,e,n){if(null===t||t.length<2)return null;var i=new xn(t,new Ae(0,V.BOUNDARY,e,n));this._curveList.add(i)}},{key:"getCurves",value:function(){return this.add(this._inputGeom),this._curveList}},{key:"add",value:function(t){if(t.isEmpty())return null;if(t instanceof Dt)this.addPolygon(t);else if(t instanceof Pt)this.addLineString(t);else if(t instanceof Tt)this.addPoint(t);else if(t instanceof Yt)this.addCollection(t);else if(t instanceof oe)this.addCollection(t);else if(t instanceof te)this.addCollection(t);else{if(!(t instanceof qt))throw new W(t.getGeometryType());this.addCollection(t)}}},{key:"isErodedCompletely",value:function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r}},{key:"addCollection",value:function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}}}],[{key:"constructor_",value:function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new pt;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n}}]),Yn=o(function t(){n(this,t)},[{key:"locate",value:function(t){}}]),zn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"next",value:function(){if(this._atStart)return this._atStart=!1,t.isAtomic(this._parent)&&this._index++,this._parent;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new K;var e=this._parent.getGeometryN(this._index++);return e instanceof qt?(this._subcollectionIterator=new t(e),this._subcollectionIterator.next()):e}},{key:"remove",value:function(){throw new W(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[yn]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()}},{key:"isAtomic",value:function(t){return!(t instanceof qt)}}])}(),Hn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"locate",value:function(e){return t.locate(e,this._geom)}},{key:"interfaces_",get:function(){return[Yn]}}],[{key:"constructor_",value:function(){this._geom=null;var t=arguments[0];this._geom=t}},{key:"locatePointInPolygon",value:function(e,n){if(n.isEmpty())return V.EXTERIOR;var i=n.getExteriorRing(),r=t.locatePointInRing(e,i);if(r!==V.INTERIOR)return r;for(var o=0;o<n.getNumInteriorRing();o++){var s=n.getInteriorRingN(o),a=t.locatePointInRing(e,s);if(a===V.BOUNDARY)return V.BOUNDARY;if(a===V.INTERIOR)return V.EXTERIOR}return V.INTERIOR}},{key:"locatePointInRing",value:function(t,e){return e.getEnvelopeInternal().intersects(t)?Te.locateInRing(t,e.getCoordinates()):V.EXTERIOR}},{key:"containsPointInPolygon",value:function(e,n){return V.EXTERIOR!==t.locatePointInPolygon(e,n)}},{key:"locateInGeometry",value:function(e,n){if(n instanceof Dt)return t.locatePointInPolygon(e,n);if(n instanceof qt)for(var i=new zn(n);i.hasNext();){var r=i.next();if(r!==n){var o=t.locateInGeometry(e,r);if(o!==V.EXTERIOR)return o}}return V.EXTERIOR}},{key:"isContained",value:function(e,n){return V.EXTERIOR!==t.locate(e,n)}},{key:"locate",value:function(e,n){return n.isEmpty()?V.EXTERIOR:n.getEnvelopeInternal().intersects(e)?t.locateInGeometry(e,n):V.EXTERIOR}}])}(),Un=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getNextCW",value:function(t){this.getEdges();var e=this._edgeList.indexOf(t),n=e-1;return 0===e&&(n=this._edgeList.size()-1),this._edgeList.get(n)}},{key:"propagateSideLabels",value:function(t){for(var e=V.NONE,n=this.iterator();n.hasNext();){var i=n.next().getLabel();i.isArea(t)&&i.getLocation(t,Q.LEFT)!==V.NONE&&(e=i.getLocation(t,Q.LEFT))}if(e===V.NONE)return null;for(var r=e,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getLabel();if(a.getLocation(t,Q.ON)===V.NONE&&a.setLocation(t,Q.ON,r),a.isArea(t)){var l=a.getLocation(t,Q.LEFT),u=a.getLocation(t,Q.RIGHT);if(u!==V.NONE){if(u!==r)throw new gt("side location conflict",s.getCoordinate());l===V.NONE&&G.shouldNeverReachHere("found single null side (at "+s.getCoordinate()+")"),r=l}else G.isTrue(a.getLocation(t,Q.LEFT)===V.NONE,"found single null side"),a.setLocation(t,Q.RIGHT,r),a.setLocation(t,Q.LEFT,r)}}}},{key:"getCoordinate",value:function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null}},{key:"print",value:function(t){_t.out.println("EdgeEndStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"isAreaLabelsConsistent",value:function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,i=e.get(n).getLabel().getLocation(t,Q.LEFT);G.isTrue(i!==V.NONE,"Found unlabelled area edge");for(var r=i,o=this.iterator();o.hasNext();){var s=o.next().getLabel();G.isTrue(s.isArea(t),"Found non-area edge");var a=s.getLocation(t,Q.LEFT),l=s.getLocation(t,Q.RIGHT);if(a===l)return!1;if(l!==r)return!1;r=a}return!0}},{key:"findIndex",value:function(t){this.iterator();for(var e=0;e<this._edgeList.size();e++)if(this._edgeList.get(e)===t)return e;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return null===this._edgeList&&(this._edgeList=new pt(this._edgeMap.values())),this._edgeList}},{key:"getLocation",value:function(t,e,n){return this._ptInAreaLocation[t]===V.NONE&&(this._ptInAreaLocation[t]=Hn.locate(e,n[t].getGeometry())),this._ptInAreaLocation[t]}},{key:"toString",value:function(){var t=new ot;t.append("EdgeEndStar: "+this.getCoordinate()),t.append("\n");for(var e=this.iterator();e.hasNext();){var n=e.next();t.append(n),t.append("\n")}return t.toString()}},{key:"computeEdgeEndLabels",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)}},{key:"computeLabelling",value:function(t){this.computeEdgeEndLabels(t[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var e=[!1,!1],n=this.iterator();n.hasNext();)for(var i=n.next().getLabel(),r=0;r<2;r++)i.isLine(r)&&i.getLocation(r)===V.BOUNDARY&&(e[r]=!0);for(var o=this.iterator();o.hasNext();)for(var s=o.next(),a=s.getLabel(),l=0;l<2;l++)if(a.isAnyNull(l)){var u=V.NONE;if(e[l])u=V.EXTERIOR;else{var h=s.getCoordinate();u=this.getLocation(l,h,t)}a.setAllLocationsIfNull(l,u)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(t,e){this._edgeMap.put(t,e),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new Ve,this._edgeList=null,this._ptInAreaLocation=[V.NONE,V.NONE]}}]),Xn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var t=null,e=null,n=this._SCANNING_FOR_INCOMING,i=0;i<this._resultAreaEdgeList.size();i++){var r=this._resultAreaEdgeList.get(i),o=r.getSym();if(r.getLabel().isArea())switch(null===t&&r.isInResult()&&(t=r),n){case this._SCANNING_FOR_INCOMING:if(!o.isInResult())continue;e=o,n=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!r.isInResult())continue;e.setNext(r),n=this._SCANNING_FOR_INCOMING}}if(n===this._LINKING_TO_OUTGOING){if(null===t)throw new gt("no outgoing dirEdge found",this.getCoordinate());G.isTrue(t.isInResult(),"unable to link last incoming dirEdge"),e.setNext(t)}}},{key:"insert",value:function(t){var e=t;this.insertEdgeEnd(e,e)}},{key:"getRightmostEdge",value:function(){var t=this.getEdges(),e=t.size();if(e<1)return null;var n=t.get(0);if(1===e)return n;var i=t.get(e-1),r=n.getQuadrant(),o=i.getQuadrant();return Ke.isNorthern(r)&&Ke.isNorthern(o)?n:Ke.isNorthern(r)||Ke.isNorthern(o)?0!==n.getDy()?n:0!==i.getDy()?i:(G.shouldNeverReachHere("found two horizontal edges incident on node"),null):i}},{key:"print",value:function(t){_t.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();){var n=e.next();t.print("out "),n.print(t),t.println(),t.print("in "),n.getSym().print(t),t.println()}}},{key:"getResultAreaEdges",value:function(){if(null!==this._resultAreaEdgeList)return this._resultAreaEdgeList;this._resultAreaEdgeList=new pt;for(var t=this.iterator();t.hasNext();){var e=t.next();(e.isInResult()||e.getSym().isInResult())&&this._resultAreaEdgeList.add(e)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next().getLabel();n.setAllLocationsIfNull(0,t.getLocation(0)),n.setAllLocationsIfNull(1,t.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var t=null,e=null,n=this._edgeList.size()-1;n>=0;n--){var i=this._edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(Q.LEFT),i=t.getDepth(Q.RIGHT),r=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,r)!==i)throw new gt("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a<o;a++){var l=this._edgeList.get(a);l.setEdgeDepths(Q.RIGHT,s),s=l.getDepth(Q.LEFT)}return s}}},{key:"mergeSymLabels",value:function(){for(var t=this.iterator();t.hasNext();){var e=t.next();e.getLabel().merge(e.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(t){for(var e=null,n=null,i=this._SCANNING_FOR_INCOMING,r=this._resultAreaEdgeList.size()-1;r>=0;r--){var o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),i){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(G.isTrue(null!==e,"found null for first outgoing dirEdge"),G.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();)e.next().isInResult()&&t++;return t}if(1===arguments.length){for(var n=arguments[0],i=0,r=this.iterator();r.hasNext();)r.next().getEdgeRing()===n&&i++;return i}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var t=V.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=V.INTERIOR;break}if(i.isInResult()){t=V.EXTERIOR;break}}}if(t===V.NONE)return null;for(var r=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===V.INTERIOR):(s.isInResult()&&(r=V.EXTERIOR),a.isInResult()&&(r=V.INTERIOR))}}},{key:"computeLabelling",value:function(t){f(i,"computeLabelling",this,1).call(this,t),this._label=new Ae(V.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),r=0;r<2;r++){var o=n.getLocation(r);o!==V.INTERIOR&&o!==V.BOUNDARY||this._label.setLocation(r,V.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}])}(Un),Vn=function(t){function i(){return n(this,i),e(this,i)}return u(i,t),o(i,[{key:"createNode",value:function(t){return new Be(t,new Xn)}}])}(Je),jn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"compareTo",value:function(e){var n=e;return t.compareOriented(this._pts,this._orientation,n._pts,n._orientation)}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)}},{key:"orientation",value:function(t){return 1===Kt.increasingDirection(t)}},{key:"compareOriented",value:function(t,e,n,i){for(var r=e?1:-1,o=i?1:-1,s=e?t.length:-1,a=i?n.length:-1,l=e?0:t.length-1,u=i?0:n.length-1;;){var h=t[l].compareTo(n[u]);if(0!==h)return h;var c=(l+=r)===s,f=(u+=o)===a;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}}}])}(),Kn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"print",value:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e<this._edges.size();e++){var n=this._edges.get(e);e>0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r<i.length;r++)r>0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")}},{key:"addAll",value:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())}},{key:"findEdgeIndex",value:function(t){for(var e=0;e<this._edges.size();e++)if(this._edges.get(e).equals(t))return e;return-1}},{key:"iterator",value:function(){return this._edges.iterator()}},{key:"getEdges",value:function(){return this._edges}},{key:"get",value:function(t){return this._edges.get(t)}},{key:"findEqualEdge",value:function(t){var e=new jn(t.getCoordinates());return this._ocaMap.get(e)}},{key:"add",value:function(t){this._edges.add(t);var e=new jn(t.getCoordinates());this._ocaMap.put(e,t)}}],[{key:"constructor_",value:function(){this._edges=new pt,this._ocaMap=new Ve}}]),Wn=o(function t(){n(this,t)},[{key:"processIntersections",value:function(t,e,n,i){}},{key:"isDone",value:function(){}}]),Zn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isTrivialIntersection",value:function(e,n,i,r){if(e===i&&1===this._li.getIntersectionNum()){if(t.isAdjacentSegments(n,r))return!0;if(e.isClosed()){var o=e.size()-1;if(0===n&&r===o||0===r&&n===o)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this._properIntersectionPoint}},{key:"hasProperInteriorIntersection",value:function(){return this._hasProperInterior}},{key:"getLineIntersector",value:function(){return this._li}},{key:"hasProperIntersection",value:function(){return this._hasProper}},{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))}},{key:"hasIntersection",value:function(){return this._hasIntersection}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this._hasInterior}},{key:"interfaces_",get:function(){return[Wn]}}],[{key:"constructor_",value:function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this._li=t}},{key:"isAdjacentSegments",value:function(t,e){return 1===Math.abs(t-e)}}])}(),Jn=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex),t.println(" dist = "+this.dist)}},{key:"compareTo",value:function(t){var e=t;return this.compare(e.segmentIndex,e.dist)}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===t}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(t,e){return this.segmentIndex<t?-1:this.segmentIndex>t?1:this.dist<e?-1:this.dist>e?1:0}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new z(t),this.segmentIndex=e,this.dist=n}}]),$n=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"addEndpoints",value:function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)}},{key:"createSplitEdge",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=this.edge.pts[e.segmentIndex],r=e.dist>0||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return r&&(o[s]=e.coord),new ri(o,new Ae(this.edge._label))}},{key:"add",value:function(t,e,n){var i=new Jn(t,e,n),r=this._nodeMap.get(i);return null!==r?r:(this._nodeMap.put(i,i),i)}},{key:"isIntersection",value:function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new Ve,this.edge=null;var t=arguments[0];this.edge=t}}]),Qn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])||t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))&&this._matrix[V.EXTERIOR][V.INTERIOR]===bt.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===bt.FALSE}},{key:"isCoveredBy",value:function(){return(t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])||t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))&&this._matrix[V.INTERIOR][V.EXTERIOR]===bt.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===bt.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this._matrix[n][i]=bt.toDimensionValue(t.charAt(e))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]=s}}},{key:"isContains",value:function(){return t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.EXTERIOR][V.INTERIOR]===bt.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===bt.FALSE}},{key:"setAtLeast",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this.setAtLeast(n,i,bt.toDimensionValue(t.charAt(e)))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]<s&&(this._matrix[r][o]=s)}}},{key:"setAtLeastIfValid",value:function(t,e,n){t>=0&&e>=0&&this.setAtLeast(t,e,n)}},{key:"isWithin",value:function(){return t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.INTERIOR][V.EXTERIOR]===bt.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===bt.FALSE}},{key:"isTouches",value:function(e,n){return e>n?this.isTouches(n,e):(e===bt.A&&n===bt.A||e===bt.L&&n===bt.L||e===bt.L&&n===bt.A||e===bt.P&&n===bt.A||e===bt.P&&n===bt.L)&&this._matrix[V.INTERIOR][V.INTERIOR]===bt.FALSE&&(t.isTrue(this._matrix[V.INTERIOR][V.BOUNDARY])||t.isTrue(this._matrix[V.BOUNDARY][V.INTERIOR])||t.isTrue(this._matrix[V.BOUNDARY][V.BOUNDARY]))}},{key:"isOverlaps",value:function(e,n){return e===bt.P&&n===bt.P||e===bt.A&&n===bt.A?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR]):e===bt.L&&n===bt.L&&1===this._matrix[V.INTERIOR][V.INTERIOR]&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR])}},{key:"isEquals",value:function(e,n){return e===n&&t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&this._matrix[V.INTERIOR][V.EXTERIOR]===bt.FALSE&&this._matrix[V.BOUNDARY][V.EXTERIOR]===bt.FALSE&&this._matrix[V.EXTERIOR][V.INTERIOR]===bt.FALSE&&this._matrix[V.EXTERIOR][V.BOUNDARY]===bt.FALSE}},{key:"toString",value:function(){for(var t=new Jt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,bt.toDimensionSymbol(this._matrix[e][n]));return t.toString()}},{key:"setAll",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this._matrix[e][n]=t}},{key:"get",value:function(t,e){return this._matrix[t][e]}},{key:"transpose",value:function(){var t=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=t,t=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=t,t=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=t,this}},{key:"matches",value:function(e){if(9!==e.length)throw new _("Should be length 9: "+e);for(var n=0;n<3;n++)for(var i=0;i<3;i++)if(!t.matches(this._matrix[n][i],e.charAt(3*n+i)))return!1;return!0}},{key:"add",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))}},{key:"isDisjoint",value:function(){return this._matrix[V.INTERIOR][V.INTERIOR]===bt.FALSE&&this._matrix[V.INTERIOR][V.BOUNDARY]===bt.FALSE&&this._matrix[V.BOUNDARY][V.INTERIOR]===bt.FALSE&&this._matrix[V.BOUNDARY][V.BOUNDARY]===bt.FALSE}},{key:"isCrosses",value:function(e,n){return e===bt.P&&n===bt.L||e===bt.P&&n===bt.A||e===bt.L&&n===bt.A?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.INTERIOR][V.EXTERIOR]):e===bt.L&&n===bt.P||e===bt.A&&n===bt.P||e===bt.A&&n===bt.L?t.isTrue(this._matrix[V.INTERIOR][V.INTERIOR])&&t.isTrue(this._matrix[V.EXTERIOR][V.INTERIOR]):e===bt.L&&n===bt.L&&0===this._matrix[V.INTERIOR][V.INTERIOR]}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(bt.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var e=arguments[0];t.constructor_.call(this),this.set(e)}else if(arguments[0]instanceof t){var n=arguments[0];t.constructor_.call(this),this._matrix[V.INTERIOR][V.INTERIOR]=n._matrix[V.INTERIOR][V.INTERIOR],this._matrix[V.INTERIOR][V.BOUNDARY]=n._matrix[V.INTERIOR][V.BOUNDARY],this._matrix[V.INTERIOR][V.EXTERIOR]=n._matrix[V.INTERIOR][V.EXTERIOR],this._matrix[V.BOUNDARY][V.INTERIOR]=n._matrix[V.BOUNDARY][V.INTERIOR],this._matrix[V.BOUNDARY][V.BOUNDARY]=n._matrix[V.BOUNDARY][V.BOUNDARY],this._matrix[V.BOUNDARY][V.EXTERIOR]=n._matrix[V.BOUNDARY][V.EXTERIOR],this._matrix[V.EXTERIOR][V.INTERIOR]=n._matrix[V.EXTERIOR][V.INTERIOR],this._matrix[V.EXTERIOR][V.BOUNDARY]=n._matrix[V.EXTERIOR][V.BOUNDARY],this._matrix[V.EXTERIOR][V.EXTERIOR]=n._matrix[V.EXTERIOR][V.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return n===bt.SYM_DONTCARE||n===bt.SYM_TRUE&&(e>=0||e===bt.TRUE)||n===bt.SYM_FALSE&&e===bt.FALSE||n===bt.SYM_P&&e===bt.P||n===bt.SYM_L&&e===bt.L||n===bt.SYM_A&&e===bt.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var i=arguments[1];return new t(arguments[0]).matches(i)}}},{key:"isTrue",value:function(t){return t>=0||t===bt.TRUE}}])}(),ti=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(t){return null===t||0===t.length?null:(this.ensureCapacity(this._size+t.length),_t.arraycopy(t,0,this._data,this._size,t.length),void(this._size+=t.length))}},{key:"ensureCapacity",value:function(t){if(t<=this._data.length)return null;var e=Math.max(t,2*this._data.length);this._data=At.copyOf(this._data,e)}},{key:"toArray",value:function(){var t=new Array(this._size).fill(null);return _t.arraycopy(this._data,0,t,0,this._size),t}},{key:"add",value:function(t){this.ensureCapacity(this._size+1),this._data[this._size]=t,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,0===arguments.length)t.constructor_.call(this,10);else if(1===arguments.length){var e=arguments[0];this._data=new Array(e).fill(null)}}}])}(),ei=function(){function t(){n(this,t)}return o(t,[{key:"getChainStartIndices",value:function(t){var e=0,n=new ti(Math.trunc(t.length/2));n.add(e);do{var i=this.findChainEnd(t,e);n.add(i),e=i}while(e<t.length-1);return n.toArray()}},{key:"findChainEnd",value:function(t,e){for(var n=Ke.quadrant(t[e],t[e+1]),i=e+1;i<t.length&&Ke.quadrant(t[i-1],t[i])===n;)i++;return i-1}},{key:"OLDgetChainStartIndices",value:function(e){var n=0,i=new pt;i.add(n);do{var r=this.findChainEnd(e,n);i.add(r),n=r}while(n<e.length-1);return t.toIntArray(i)}}],[{key:"toIntArray",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e}}])}(),ni=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e>n?e:n}},{key:"getMinX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e<n?e:n}},{key:"computeIntersectsForChain",value:function(){if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.computeIntersectsForChain(this.startIndex[t],this.startIndex[t+1],e,e.startIndex[n],e.startIndex[n+1],i)}else if(6===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],l=arguments[4],u=arguments[5];if(o-r==1&&l-a==1)return u.addIntersections(this.e,r,s.e,a),null;if(!this.overlaps(r,o,s,a,l))return null;var h=Math.trunc((r+o)/2),c=Math.trunc((a+l)/2);r<h&&(a<c&&this.computeIntersectsForChain(r,h,s,a,c,u),c<l&&this.computeIntersectsForChain(r,h,s,c,l,u)),h<o&&(a<c&&this.computeIntersectsForChain(h,o,s,a,c,u),c<l&&this.computeIntersectsForChain(h,o,s,c,l,u))}}},{key:"overlaps",value:function(t,e,n,i,r){return U.intersects(this.pts[t],this.pts[e],n.pts[i],n.pts[r])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(t,e){for(var n=0;n<this.startIndex.length-1;n++)for(var i=0;i<t.startIndex.length-1;i++)this.computeIntersectsForChain(n,t,i,e)}}],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var t=arguments[0];this.e=t,this.pts=t.getCoordinates();var e=new ei;this.startIndex=e.getChainStartIndices(this.pts)}}]),ii=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"getDepth",value:function(t,e){return this._depth[t][e]}},{key:"setDepth",value:function(t,e,n){this._depth[t][e]=n}},{key:"isNull",value:function(){if(0===arguments.length){for(var e=0;e<2;e++)for(var n=0;n<3;n++)if(this._depth[e][n]!==t.NULL_VALUE)return!1;return!0}if(1===arguments.length){var i=arguments[0];return this._depth[i][1]===t.NULL_VALUE}if(2===arguments.length){var r=arguments[0],o=arguments[1];return this._depth[r][o]===t.NULL_VALUE}}},{key:"normalize",value:function(){for(var t=0;t<2;t++)if(!this.isNull(t)){var e=this._depth[t][1];this._depth[t][2]<e&&(e=this._depth[t][2]),e<0&&(e=0);for(var n=1;n<3;n++){var i=0;this._depth[t][n]>e&&(i=1),this._depth[t][n]=i}}}},{key:"getDelta",value:function(t){return this._depth[t][Q.RIGHT]-this._depth[t][Q.LEFT]}},{key:"getLocation",value:function(t,e){return this._depth[t][e]<=0?V.EXTERIOR:V.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(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var i=1;i<3;i++){var r=e.getLocation(n,i);r!==V.EXTERIOR&&r!==V.INTERIOR||(this.isNull(n,i)?this._depth[n][i]=t.depthAtLocation(r):this._depth[n][i]+=t.depthAtLocation(r))}else if(3===arguments.length){var o=arguments[0],s=arguments[1];arguments[2]===V.INTERIOR&&this._depth[o][s]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var e=0;e<2;e++)for(var n=0;n<3;n++)this._depth[e][n]=t.NULL_VALUE}},{key:"depthAtLocation",value:function(e){return e===V.EXTERIOR?0:e===V.INTERIOR?1:t.NULL_VALUE}}])}();ii.NULL_VALUE=-1;var ri=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new i(t,Ae.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(t){this._isIsolated=t}},{key:"setName",value:function(t){this._name=t}},{key:"equals",value:function(t){if(!(t instanceof i))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,r=!0,o=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(e.pts[s])||(n=!1),this.pts[s].equals2D(e.pts[--o])||(r=!1),!n&&!r)return!1;return!0}},{key:"getCoordinate",value:function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}}},{key:"print",value:function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(t){i.updateIM(this._label,t)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&3===this.pts.length&&!!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(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this._mce&&(this._mce=new ni(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new U;for(var t=0;t<this.pts.length;t++)this._env.expandToInclude(this.pts[t])}return this._env}},{key:"addIntersection",value:function(t,e,n,i){var r=new z(t.getIntersection(i)),o=e,s=t.getEdgeDistance(n,i),a=o+1;if(a<this.pts.length){var l=this.pts[a];r.equals2D(l)&&(o=a,s=0)}this.eiList.add(r,o,s)}},{key:"toString",value:function(){var t=new Jt;t.append("edge "+this._name+": "),t.append("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()}},{key:"isPointwiseEqual",value:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e<this.pts.length;e++)if(!this.pts[e].equals2D(t.pts[e]))return!1;return!0}},{key:"setDepthDelta",value:function(t){this._depthDelta=t}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}}],[{key:"constructor_",value:function(){if(this.pts=null,this._env=null,this.eiList=new $n(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new ii,this._depthDelta=0,1===arguments.length){var t=arguments[0];i.constructor_.call(this,t,null)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.pts=e,this._label=n}}},{key:"updateIM",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Qn&&arguments[0]instanceof Ae))return f(i,"updateIM",this).apply(this,arguments);var t=arguments[0],e=arguments[1];e.setAtLeastIfValid(t.getLocation(0,Q.ON),t.getLocation(1,Q.ON),1),t.isArea()&&(e.setAtLeastIfValid(t.getLocation(0,Q.LEFT),t.getLocation(1,Q.LEFT),2),e.setAtLeastIfValid(t.getLocation(0,Q.RIGHT),t.getLocation(1,Q.RIGHT),2))}}])}(Ge),oi=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"setWorkingPrecisionModel",value:function(t){this._workingPrecisionModel=t}},{key:"insertUniqueEdge",value:function(e){var n=this._edgeList.findEqualEdge(e);if(null!==n){var i=n.getLabel(),r=e.getLabel();n.isPointwiseEqual(e)||(r=new Ae(e.getLabel())).flip(),i.merge(r);var o=t.depthDelta(r),s=n.getDepthDelta()+o;n.setDepthDelta(s)}else this._edgeList.add(e),e.setDepthDelta(t.depthDelta(e.getLabel()))}},{key:"buildSubgraphs",value:function(t,e){for(var n=new pt,i=t.iterator();i.hasNext();){var r=i.next(),o=r.getRightmostCoordinate(),s=new Rn(n).getDepth(o);r.computeDepth(s),r.findResultEdges(),n.add(r),e.add(r.getDirectedEdges(),r.getNodes())}}},{key:"createSubgraphs",value:function(t){for(var e=new pt,n=t.getNodes().iterator();n.hasNext();){var i=n.next();if(!i.isVisited()){var r=new vt;r.create(i),e.add(r)}}return sn.sort(e,sn.reverseOrder()),e}},{key:"createEmptyResultGeometry",value:function(){return this._geomFact.createPolygon()}},{key:"getNoder",value:function(t){if(null!==this._workingNoder)return this._workingNoder;var e=new Nn,n=new Pe;return n.setPrecisionModel(t),e.setSegmentIntersector(new Zn(n)),e}},{key:"buffer",value:function(t,e){var n=this._workingPrecisionModel;null===n&&(n=t.getPrecisionModel()),this._geomFact=t.getFactory();var i=new An(n,this._bufParams),r=new qn(t,e,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this._graph=new $e(new Vn),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),s=new Qe(this._geomFact);this.buildSubgraphs(o,s);var a=s.getPolygons();return a.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(a)}},{key:"computeNodedEdges",value:function(t,e){var n=this.getNoder(e);n.computeNodes(t);for(var i=n.getNodedSubstrings().iterator();i.hasNext();){var r=i.next(),o=r.getCoordinates();if(2!==o.length||!o[0].equals2D(o[1])){var s=r.getData(),a=new ri(r.getCoordinates(),new Ae(s));this.insertUniqueEdge(a)}}}},{key:"setNoder",value:function(t){this._workingNoder=t}}],[{key:"constructor_",value:function(){this._bufParams=null,this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Kn;var t=arguments[0];this._bufParams=t}},{key:"depthDelta",value:function(t){var e=t.getLocation(0,Q.LEFT),n=t.getLocation(0,Q.RIGHT);return e===V.INTERIOR&&n===V.EXTERIOR?1:e===V.EXTERIOR&&n===V.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(t){for(var e=new se,n=new pt;t.hasNext();){var i=t.next(),r=e.createLineString(i.getCoordinates());n.add(r)}return e.buildGeometry(n)}}])}(),si=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"rescale",value:function(){if(rt(arguments[0],j))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.rescale(e.getCoordinates())}else if(arguments[0]instanceof Array){for(var n=arguments[0],i=0;i<n.length;i++)n[i].x=n[i].x/this._scaleFactor+this._offsetX,n[i].y=n[i].y/this._scaleFactor+this._offsetY;2===n.length&&n[0].equals2D(n[1])&&_t.out.println(n)}}},{key:"scale",value:function(){if(rt(arguments[0],j)){for(var t=arguments[0],e=new pt(t.size()),n=t.iterator();n.hasNext();){var i=n.next();e.add(new xn(this.scale(i.getCoordinates()),i.getData()))}return e}if(arguments[0]instanceof Array){for(var r=arguments[0],o=new Array(r.length).fill(null),s=0;s<r.length;s++)o[s]=new z(Math.round((r[s].x-this._offsetX)*this._scaleFactor),Math.round((r[s].y-this._offsetY)*this._scaleFactor),r[s].getZ());return Kt.removeRepeatedPoints(o)}}},{key:"isIntegerPrecision",value:function(){return 1===this._scaleFactor}},{key:"getNodedSubstrings",value:function(){var t=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(t),t}},{key:"computeNodes",value:function(t){var e=t;this._isScaled&&(e=this.scale(t)),this._noder.computeNodes(e)}},{key:"interfaces_",get:function(){return[Sn]}}],[{key:"constructor_",value:function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){var e=arguments[0],n=arguments[1];t.constructor_.call(this,e,n,0,0)}else if(4===arguments.length){var i=arguments[0],r=arguments[1];this._noder=i,this._scaleFactor=r,this._isScaled=!this.isIntegerPrecision()}}}])}(),ai=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"checkEndPtVertexIntersections",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next().getCoordinates();this.checkEndPtVertexIntersections(e[0],this._segStrings),this.checkEndPtVertexIntersections(e[e.length-1],this._segStrings)}else if(2===arguments.length)for(var n=arguments[0],i=arguments[1].iterator();i.hasNext();)for(var r=i.next().getCoordinates(),o=1;o<r.length-1;o++)if(r[o].equals(n))throw new D("found endpt/interior pt intersection at index "+o+" :pt "+n)}},{key:"checkInteriorIntersections",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();)for(var e=t.next(),n=this._segStrings.iterator();n.hasNext();){var i=n.next();this.checkInteriorIntersections(e,i)}else if(2===arguments.length)for(var r=arguments[0],o=arguments[1],s=r.getCoordinates(),a=o.getCoordinates(),l=0;l<s.length-1;l++)for(var u=0;u<a.length-1;u++)this.checkInteriorIntersections(r,l,o,u);else if(4===arguments.length){var h=arguments[0],c=arguments[1],f=arguments[2],g=arguments[3];if(h===f&&c===g)return null;var d=h.getCoordinates()[c],p=h.getCoordinates()[c+1],y=f.getCoordinates()[g],v=f.getCoordinates()[g+1];if(this._li.computeIntersection(d,p,y,v),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,d,p)||this.hasInteriorIntersection(this._li,y,v)))throw new D("found non-noded intersection at "+d+"-"+p+" and "+y+"-"+v)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next();this.checkCollapses(e)}else if(1===arguments.length)for(var n=arguments[0].getCoordinates(),i=0;i<n.length-2;i++)this.checkCollapse(n[i],n[i+1],n[i+2])}},{key:"hasInteriorIntersection",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++){var r=t.getIntersection(i);if(!r.equals(e)&&!r.equals(n))return!0}return!1}},{key:"checkCollapse",value:function(e,n,i){if(e.equals(i))throw new D("found non-noded collapse at "+t.fact.createLineString([e,n,i]))}}],[{key:"constructor_",value:function(){this._li=new Pe,this._segStrings=null;var t=arguments[0];this._segStrings=t}}])}();ai.fact=new se;var li=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"intersectsScaled",value:function(t,e){var n=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.y,e.y),s=this._maxx<n||this._minx>i||this._maxy<r||this._miny>o;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return G.isTrue(!(s&&a),"Found bad envelope test"),a}},{key:"initCorners",value:function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new z(this._maxx,this._maxy),this._corner[1]=new z(this._minx,this._maxy),this._corner[2]=new z(this._minx,this._miny),this._corner[3]=new z(this._maxx,this._miny)}},{key:"intersects",value:function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(t){return Math.round(t*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._safeEnv){var e=t.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new U(this._originalPt.x-e,this._originalPt.x+e,this._originalPt.y-e,this._originalPt.y+e)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))}},{key:"intersectsToleranceSquare",value:function(t,e){var n=!1,i=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&i||t.equals(this._pt)||e.equals(this._pt)))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!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 t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new _("Scale factor must be non-zero");1!==e&&(this._pt=new z(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new z,this._p1Scaled=new z),this.initCorners(this._pt)}}])}();li.SAFE_ENV_EXPANSION_FACTOR=.75;var ui=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"select",value:function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new En}}]),hi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"snap",value:function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],i=arguments[1],r=arguments[2],s=e.getSafeEnvelope(),a=new ci(e,i,r);return this._index.query(s,new(o(function t(){n(this,t)},[{key:"interfaces_",get:function(){return[un]}},{key:"visitItem",value:function(t){t.select(s,a)}}]))),a.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}]),ci=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return u(i,t),o(i,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof In))return f(i,"select",this,1).apply(this,arguments);var t=arguments[1],e=arguments[0].getContext();if(this._parentEdge===e&&(t===this._hotPixelVertexIndex||t+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(e,t)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._hotPixel=t,this._parentEdge=e,this._hotPixelVertexIndex=n}}])}(ui);hi.HotPixelSnapAction=ci;var fi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l<this._li.getIntersectionNum();l++)this._interiorIntersections.add(this._li.getIntersection(l));t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this._interiorIntersections}},{key:"interfaces_",get:function(){return[Wn]}}],[{key:"constructor_",value:function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new pt}}]),gi=o(function t(){n(this,t),t.constructor_.apply(this,arguments)},[{key:"checkCorrectness",value:function(t){var e=xn.getNodedSubstrings(t),n=new ai(e);try{n.checkValid()}catch(i){if(!(i instanceof m))throw i;i.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return xn.getNodedSubstrings(this._nodedSegStrings)}},{key:"snapRound",value:function(t,e){var n=this.findInteriorIntersections(t,e);this.computeIntersectionSnaps(n),this.computeVertexSnaps(t)}},{key:"findInteriorIntersections",value:function(t,e){var n=new fi(e);return this._noder.setSegmentIntersector(n),this._noder.computeNodes(t),n.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(rt(arguments[0],j))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.computeVertexSnaps(e)}else if(arguments[0]instanceof xn)for(var n=arguments[0],i=n.getCoordinates(),r=0;r<i.length;r++){var o=new li(i[r],this._scaleFactor,this._li);this._pointSnapper.snap(o,n,r)&&n.addIntersection(i[r],r)}}},{key:"computeNodes",value:function(t){this._nodedSegStrings=t,this._noder=new Nn,this._pointSnapper=new hi(this._noder.getIndex()),this.snapRound(t,this._li)}},{key:"computeIntersectionSnaps",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=new li(n,this._scaleFactor,this._li);this._pointSnapper.snap(i)}}},{key:"interfaces_",get:function(){return[Sn]}}],[{key:"constructor_",value:function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var t=arguments[0];this._pm=t,this._li=new Pe,this._li.setPrecisionModel(t),this._scaleFactor=t.getScale()}}]),di=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return o(t,[{key:"bufferFixedPrecision",value:function(t){var e=new si(new gi(new ie(1)),t.getScale()),n=new oi(this._bufParams);n.setWorkingPrecisionModel(t),n.setNoder(e),this._resultGeometry=n.buffer(this._argGeom,this._distance)}},{key:"bufferReducedPrecision",value:function(){if(0===arguments.length){for(var e=t.MAX_PRECISION_DIGITS;e>=0;e--){try{this.bufferReducedPrecision(e)}catch(o){if(!(o instanceof gt))throw o;this._saveException=o}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],i=t.precisionScaleFactor(this._argGeom,this._distance,n),r=new ie(i);this.bufferFixedPrecision(r)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===ie.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this._bufParams.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new oi(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(e){if(!(e instanceof D))throw e;this._saveException=e}}},{key:"getResultGeometry",value:function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(t){this._bufParams.setEndCapStyle(t)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new v,this._resultGeometry=null,this._saveException=null,1===arguments.length){var t=arguments[0];this._argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._argGeom=e,this._bufParams=n}}},{key:"bufferOp",value:function(){if(2===arguments.length){var e=arguments[1];return new t(arguments[0]).getResultGeometry(e)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof X&&"number"==typeof arguments[1]){var n=arguments[1],i=arguments[2],r=new t(arguments[0]);return r.setQuadrantSegments(i),r.getResultGeometry(n)}if(arguments[2]instanceof v&&arguments[0]instanceof X&&"number"==typeof arguments[1]){var o=arguments[1];return new t(arguments[0],arguments[2]).getResultGeometry(o)}}else if(4===arguments.length){var s=arguments[1],a=arguments[2],l=arguments[3],u=new t(arguments[0]);return u.setQuadrantSegments(a),u.setEndCapStyle(l),u.getResultGeometry(s)}}},{key:"precisionScaleFactor",value:function(t,e,n){var i=t.getEnvelopeInternal(),r=kt.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)}}])}();di.CAP_ROUND=v.CAP_ROUND,di.CAP_BUTT=v.CAP_FLAT,di.CAP_FLAT=v.CAP_FLAT,di.CAP_SQUARE=v.CAP_SQUARE,di.MAX_PRECISION_DIGITS=12;var pi=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],yi=o(function t(e){n(this,t),this.geometryFactory=e||new se},[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!vi[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==pi.indexOf(n)?vi[n].call(this,e.coordinates):"GeometryCollection"===n?vi[n].call(this,e.geometries):vi[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!mi[e])throw new Error("Geometry is not supported");return mi[e].call(this,t)}}]),vi={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!vi[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=vi.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n<t.features.length;++n)e.features.push(this.read(t.features[n]))}return t.bbox&&(e.bbox=this.parse.bbox.call(this,t.bbox)),e},coordinates:function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n];e.push(i(z,g(r)))}return e},bbox:function(t){return this.geometryFactory.createLinearRing([new z(t[0],t[1]),new z(t[2],t[1]),new z(t[2],t[3]),new z(t[0],t[3]),new z(t[0],t[1])])},Point:function(t){var e=i(z,g(t));return this.geometryFactory.createPoint(e)},MultiPoint:function(t){for(var e=[],n=0;n<t.length;++n)e.push(vi.Point.call(this,t[n]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=vi.coordinates.call(this,t);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push(vi.LineString.call(this,t[n]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=vi.coordinates.call(this,t[0]),n=this.geometryFactory.createLinearRing(e),i=[],r=1;r<t.length;++r){var o=t[r],s=vi.coordinates.call(this,o),a=this.geometryFactory.createLinearRing(s);i.push(a)}return this.geometryFactory.createPolygon(n,i)},MultiPolygon:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(vi.Polygon.call(this,i))}return this.geometryFactory.createMultiPolygon(e)},GeometryCollection:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(this.read(i))}return this.geometryFactory.createGeometryCollection(e)}},mi={coordinate:function(t){var e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e},Point:function(t){return{type:"Point",coordinates:mi.coordinate.call(this,t.getCoordinate())}},MultiPoint:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.Point.call(this,i);e.push(r.coordinates)}return{type:"MultiPoint",coordinates:e}},LineString:function(t){for(var e=[],n=t.getCoordinates(),i=0;i<n.length;++i){var r=n[i];e.push(mi.coordinate.call(this,r))}return{type:"LineString",coordinates:e}},MultiLineString:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.LineString.call(this,i);e.push(r.coordinates)}return{type:"MultiLineString",coordinates:e}},Polygon:function(t){var e=[],n=mi.LineString.call(this,t._shell);e.push(n.coordinates);for(var i=0;i<t._holes.length;++i){var r=t._holes[i],o=mi.LineString.call(this,r);e.push(o.coordinates)}return{type:"Polygon",coordinates:e}},MultiPolygon:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=mi.Polygon.call(this,i);e.push(r.coordinates)}return{type:"MultiPolygon",coordinates:e}},GeometryCollection:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=i.getGeometryType();e.push(mi[r].call(this,i))}return{type:"GeometryCollection",geometries:e}}};return{BufferOp:di,GeoJSONReader:o(function t(e){n(this,t),this.parser=new yi(e||new se)},[{key:"read",value:function(t){return this.parser.read(t)}}]),GeoJSONWriter:o(function t(){n(this,t),this.parser=new yi(this.geometryFactory)},[{key:"write",value:function(t){return this.parser.write(t)}}])}}()),Fe.exports);const Be=H(Ge);function qe(){return new Ye}function Ye(){this.reset()}Ye.prototype={constructor:Ye,reset:function(){this.s=this.t=0},add:function(t){He(ze,t,this.t),He(this,ze.s,this.s),this.s?this.t+=ze.t:this.s=ze.t},valueOf:function(){return this.s}};var ze=new Ye;function He(t,e,n){var i=t.s=e+n,r=i-e,o=i-r;t.t=e-o+(n-r)}var Ue=1e-6,Xe=Math.PI,Ve=Xe/2,je=Xe/4,Ke=2*Xe,We=180/Xe,Ze=Xe/180,Je=Math.abs,$e=Math.atan,Qe=Math.atan2,tn=Math.cos,en=Math.sin,nn=Math.sqrt;function rn(t){return t>1?0:t<-1?Xe:Math.acos(t)}function on(t){return t>1?Ve:t<-1?-Ve:Math.asin(t)}function sn(){}function an(t,e){t&&cn.hasOwnProperty(t.type)&&cn[t.type](t,e)}var ln,un,hn={Feature:function(t,e){an(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i<r;)an(n[i].geometry,e)}},cn={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)t=n[i],e.point(t[0],t[1],t[2])},LineString:function(t,e){fn(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)fn(n[i],e,0)},Polygon:function(t,e){gn(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)gn(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,r=n.length;++i<r;)an(n[i],e)}};function fn(t,e,n){var i,r=-1,o=t.length-n;for(e.lineStart();++r<o;)i=t[r],e.point(i[0],i[1],i[2]);e.lineEnd()}function gn(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)fn(t[n],e,1);e.polygonEnd()}function dn(t){return[Qe(t[1],t[0]),on(t[2])]}function pn(t){var e=t[0],n=t[1],i=tn(n);return[i*tn(e),i*en(e),en(n)]}function yn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function vn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function mn(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _n(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function kn(t){var e=nn(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function xn(t,e){function n(n,i){return n=t(n,i),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,i){return(n=e.invert(n,i))&&t.invert(n[0],n[1])}),n}function En(t,e){return[t>Xe?t-Ke:t<-Xe?t+Ke:t,e]}function wn(t){return function(e,n){return[(e+=t)>Xe?e-Ke:e<-Xe?e+Ke:e,n]}}function In(t){var e=wn(t);return e.invert=wn(-t),e}function Mn(t,e){var n=tn(t),i=en(t),r=tn(e),o=en(e);function s(t,e){var s=tn(e),a=tn(t)*s,l=en(t)*s,u=en(e),h=u*n+a*i;return[Qe(l*r-h*o,a*n-u*i),on(h*r+l*o)]}return s.invert=function(t,e){var s=tn(e),a=tn(t)*s,l=en(t)*s,u=en(e),h=u*r-l*o;return[Qe(l*r+u*o,a*n+h*i),on(h*n-a*i)]},s}function Sn(t,e){(e=pn(e))[0]-=t,kn(e);var n=rn(-e[1]);return((-e[2]<0?-n:n)+Ke-Ue)%Ke}function bn(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:sn,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Nn(t,e){return Je(t[0]-e[0])<Ue&&Je(t[1]-e[1])<Ue}function Ln(t,e,n,i){this.x=t,this.z=e,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function Pn(t,e,n,i,r){var o,s,a=[],l=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,i=t[0],s=t[e];if(Nn(i,s)){for(r.lineStart(),o=0;o<e;++o)r.point((i=t[o])[0],i[1]);r.lineEnd()}else a.push(n=new Ln(i,t,null,!0)),l.push(n.o=new Ln(i,null,n,!1)),a.push(n=new Ln(s,t,null,!1)),l.push(n.o=new Ln(s,null,n,!0))}}),a.length){for(l.sort(e),Cn(a),Cn(l),o=0,s=l.length;o<s;++o)l[o].e=n=!n;for(var u,h,c=a[0];;){for(var f=c,g=!0;f.v;)if((f=f.n)===c)return;u=f.z,r.lineStart();do{if(f.v=f.o.v=!0,f.e){if(g)for(o=0,s=u.length;o<s;++o)r.point((h=u[o])[0],h[1]);else i(f.x,f.n.x,1,r);f=f.n}else{if(g)for(u=f.p.z,o=u.length-1;o>=0;--o)r.point((h=u[o])[0],h[1]);else i(f.x,f.p.x,-1,r);f=f.p}u=(f=f.o).z,g=!g}while(!f.v);r.lineEnd()}}}function Cn(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i<e;)r.n=n=t[i],n.p=r,r=n;r.n=n=t[0],n.p=r}}function Tn(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function On(t){for(var e,n,i,r=t.length,o=-1,s=0;++o<r;)s+=t[o].length;for(n=new Array(s);--r>=0;)for(e=(i=t[r]).length;--e>=0;)n[--s]=i[e];return n}qe(),qe(),qe(),En.invert=En,1===(ln=Tn).length&&(un=ln,ln=function(t,e){return Tn(un(t),e)});var An=1e9,Rn=-An;function Dn(t,e,n,i){function r(r,o){return t<=r&&r<=n&&e<=o&&o<=i}function o(r,o,a,u){var h=0,c=0;if(null==r||(h=s(r,a))!==(c=s(o,a))||l(r,o)<0^a>0)do{u.point(0===h||3===h?t:n,h>1?i:e)}while((h=(h+a+4)%4)!==c);else u.point(o[0],o[1])}function s(i,r){return Je(i[0]-t)<Ue?r>0?0:3:Je(i[0]-n)<Ue?r>0?2:1:Je(i[1]-e)<Ue?r>0?1:0:r>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var n=s(t,1),i=s(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(s){var l,u,h,c,f,g,d,p,y,v,m,_=s,k=bn(),x={point:E,lineStart:function(){x.point=w,u&&u.push(h=[]);v=!0,y=!1,d=p=NaN},lineEnd:function(){l&&(w(c,f),g&&y&&k.rejoin(),l.push(k.result()));x.point=E,y&&_.lineEnd()},polygonStart:function(){_=k,l=[],u=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=u.length;n<r;++n)for(var o,s,a=u[n],l=1,h=a.length,c=a[0],f=c[0],g=c[1];l<h;++l)o=f,s=g,f=(c=a[l])[0],g=c[1],s<=i?g>i&&(f-o)*(i-s)>(g-s)*(t-o)&&++e:g<=i&&(f-o)*(i-s)<(g-s)*(t-o)&&--e;return e}(),n=m&&e,r=(l=On(l)).length;(n||r)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&Pn(l,a,e,o,s),s.polygonEnd());_=s,l=u=h=null}};function E(t,e){r(t,e)&&_.point(t,e)}function w(o,s){var a=r(o,s);if(u&&h.push([o,s]),v)c=o,f=s,g=a,v=!1,a&&(_.lineStart(),_.point(o,s));else if(a&&y)_.point(o,s);else{var l=[d=Math.max(Rn,Math.min(An,d)),p=Math.max(Rn,Math.min(An,p))],k=[o=Math.max(Rn,Math.min(An,o)),s=Math.max(Rn,Math.min(An,s))];!function(t,e,n,i,r,o){var s,a=t[0],l=t[1],u=0,h=1,c=e[0]-a,f=e[1]-l;if(s=n-a,c||!(s>0)){if(s/=c,c<0){if(s<u)return;s<h&&(h=s)}else if(c>0){if(s>h)return;s>u&&(u=s)}if(s=r-a,c||!(s<0)){if(s/=c,c<0){if(s>h)return;s>u&&(u=s)}else if(c>0){if(s<u)return;s<h&&(h=s)}if(s=i-l,f||!(s>0)){if(s/=f,f<0){if(s<u)return;s<h&&(h=s)}else if(f>0){if(s>h)return;s>u&&(u=s)}if(s=o-l,f||!(s<0)){if(s/=f,f<0){if(s>h)return;s>u&&(u=s)}else if(f>0){if(s<u)return;s<h&&(h=s)}return u>0&&(t[0]=a+u*c,t[1]=l+u*f),h<1&&(e[0]=a+h*c,e[1]=l+h*f),!0}}}}}(l,k,t,e,n,i)?a&&(_.lineStart(),_.point(o,s),m=!1):(y||(_.lineStart(),_.point(l[0],l[1])),_.point(k[0],k[1]),a||_.lineEnd(),m=!1)}d=o,p=s,y=a}return x}}var Fn=qe();function Gn(t){return t}qe(),qe(),qe();var Bn=1/0,qn=Bn,Yn=-Bn,zn=Yn,Hn={point:function(t,e){t<Bn&&(Bn=t);t>Yn&&(Yn=t);e<qn&&(qn=e);e>zn&&(zn=e)},lineStart:sn,lineEnd:sn,polygonStart:sn,polygonEnd:sn,result:function(){var t=[[Bn,qn],[Yn,zn]];return Yn=zn=-(qn=Bn=1/0),t}};function Un(t,e,n,i){return function(r,o){var s,a,l,u=e(o),h=r.invert(i[0],i[1]),c=bn(),f=e(c),g=!1,d={point:p,lineStart:v,lineEnd:m,polygonStart:function(){d.point=_,d.lineStart=k,d.lineEnd=x,a=[],s=[]},polygonEnd:function(){d.point=p,d.lineStart=v,d.lineEnd=m,a=On(a);var t=function(t,e){var n=e[0],i=e[1],r=[en(n),-tn(n),0],o=0,s=0;Fn.reset();for(var a=0,l=t.length;a<l;++a)if(h=(u=t[a]).length)for(var u,h,c=u[h-1],f=c[0],g=c[1]/2+je,d=en(g),p=tn(g),y=0;y<h;++y,f=m,d=k,p=x,c=v){var v=u[y],m=v[0],_=v[1]/2+je,k=en(_),x=tn(_),E=m-f,w=E>=0?1:-1,I=w*E,M=I>Xe,S=d*k;if(Fn.add(Qe(S*w*en(I),p*x+S*tn(I))),o+=M?E+w*Ke:E,M^f>=n^m>=n){var b=vn(pn(c),pn(v));kn(b);var N=vn(r,b);kn(N);var L=(M^E>=0?-1:1)*on(N[2]);(i>L||i===L&&(b[0]||b[1]))&&(s+=M^E>=0?1:-1)}}return(o<-1e-6||o<Ue&&Fn<-1e-6)^1&s}(s,h);a.length?(g||(o.polygonStart(),g=!0),Pn(a,Vn,t,n,o)):t&&(g||(o.polygonStart(),g=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),g&&(o.polygonEnd(),g=!1),a=s=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function p(e,n){var i=r(e,n);t(e=i[0],n=i[1])&&o.point(e,n)}function y(t,e){var n=r(t,e);u.point(n[0],n[1])}function v(){d.point=y,u.lineStart()}function m(){d.point=p,u.lineEnd()}function _(t,e){l.push([t,e]);var n=r(t,e);f.point(n[0],n[1])}function k(){f.lineStart(),l=[]}function x(){_(l[0][0],l[0][1]),f.lineEnd();var t,e,n,i,r=f.clean(),u=c.result(),h=u.length;if(l.pop(),s.push(l),l=null,h)if(1&r){if((e=(n=u[0]).length-1)>0){for(g||(o.polygonStart(),g=!0),o.lineStart(),t=0;t<e;++t)o.point((i=n[t])[0],i[1]);o.lineEnd()}}else h>1&&2&r&&u.push(u.pop().concat(u.shift())),a.push(u.filter(Xn))}return d}}function Xn(t){return t.length>1}function Vn(t,e){return((t=t.x)[0]<0?t[1]-Ve-Ue:Ve-t[1])-((e=e.x)[0]<0?e[1]-Ve-Ue:Ve-e[1])}qe();const jn=Un(function(){return!0},function(t){var e,n=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?Xe:-Xe,l=Je(o-n);Je(l-Xe)<Ue?(t.point(n,i=(i+s)/2>0?Ve:-Ve),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),e=0):r!==a&&l>=Xe&&(Je(n-r)<Ue&&(n-=r*Ue),Je(o-a)<Ue&&(o-=a*Ue),i=function(t,e,n,i){var r,o,s=en(t-n);return Je(s)>Ue?$e((en(e)*(o=tn(i))*en(n)-en(i)*(r=tn(e))*en(t))/(r*o*s)):(e+i)/2}(n,i,o,s),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),e=0),t.point(n=o,i=s),r=a},lineEnd:function(){t.lineEnd(),n=i=NaN},clean:function(){return 2-e}}},function(t,e,n,i){var r;if(null==t)r=n*Ve,i.point(-Xe,r),i.point(0,r),i.point(Xe,r),i.point(Xe,0),i.point(Xe,-r),i.point(0,-r),i.point(-Xe,-r),i.point(-Xe,0),i.point(-Xe,r);else if(Je(t[0]-e[0])>Ue){var o=t[0]<e[0]?Xe:-Xe;r=n*o/2,i.point(-o,r),i.point(0,r),i.point(o,r)}else i.point(e[0],e[1])},[-Xe,-Ve]);function Kn(t,e){var n=tn(t),i=n>0,r=Je(n)>Ue;function o(t,e){return tn(t)*tn(e)>n}function s(t,e,i){var r=[1,0,0],o=vn(pn(t),pn(e)),s=yn(o,o),a=o[0],l=s-a*a;if(!l)return!i&&t;var u=n*s/l,h=-n*a/l,c=vn(r,o),f=_n(r,u);mn(f,_n(o,h));var g=c,d=yn(f,g),p=yn(g,g),y=d*d-p*(yn(f,f)-1);if(!(y<0)){var v=nn(y),m=_n(g,(-d-v)/p);if(mn(m,f),m=dn(m),!i)return m;var _,k=t[0],x=e[0],E=t[1],w=e[1];x<k&&(_=k,k=x,x=_);var I=x-k,M=Je(I-Xe)<Ue;if(!M&&w<E&&(_=E,E=w,w=_),M||I<Ue?M?E+w>0^m[1]<(Je(m[0]-k)<Ue?E:w):E<=m[1]&&m[1]<=w:I>Xe^(k<=m[0]&&m[0]<=x)){var S=_n(g,(-d+v)/p);return mn(S,f),[m,dn(S)]}}}function a(e,n){var r=i?t:Xe-t,o=0;return e<-r?o|=1:e>r&&(o|=2),n<-r?o|=4:n>r&&(o|=8),o}return Un(o,function(t){var e,n,l,u,h;return{lineStart:function(){u=l=!1,h=1},point:function(c,f){var g,d=[c,f],p=o(c,f),y=i?p?0:a(c,f):p?a(c+(c<0?Xe:-Xe),f):0;if(!e&&(u=l=p)&&t.lineStart(),p!==l&&(!(g=s(e,d))||Nn(e,g)||Nn(d,g))&&(d[0]+=Ue,d[1]+=Ue,p=o(d[0],d[1])),p!==l)h=0,p?(t.lineStart(),g=s(d,e),t.point(g[0],g[1])):(g=s(e,d),t.point(g[0],g[1]),t.lineEnd()),e=g;else if(r&&e&&i^p){var v;y&n||!(v=s(d,e,!0))||(h=0,i?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!p||e&&Nn(e,d)||t.point(d[0],d[1]),e=d,l=p,n=y},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return h|(u&&l)<<1}}},function(n,i,r,o){!function(t,e,n,i,r,o){if(n){var s=tn(e),a=en(e),l=i*n;null==r?(r=e+i*Ke,o=e-l/2):(r=Sn(s,r),o=Sn(s,o),(i>0?r<o:r>o)&&(r+=i*Ke));for(var u,h=r;i>0?h>o:h<o;h-=l)u=dn([s,-a*tn(h),-a*en(h)]),t.point(u[0],u[1])}}(o,t,e,r,n,i)},i?[0,-t]:[-Xe,t-Xe])}function Wn(t){return function(e){var n=new Zn;for(var i in t)n[i]=t[i];return n.stream=e,n}}function Zn(){}function Jn(t,e,n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),null!=o&&t.clipExtent(null),function(t,e){t&&hn.hasOwnProperty(t.type)?hn[t.type](t,e):an(t,e)}(n,t.stream(Hn));var s=Hn.result(),a=Math.min(i/(s[1][0]-s[0][0]),r/(s[1][1]-s[0][1])),l=+e[0][0]+(i-a*(s[1][0]+s[0][0]))/2,u=+e[0][1]+(r-a*(s[1][1]+s[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*a).translate([l,u])}Zn.prototype={constructor:Zn,point:function(t,e){this.stream.point(t,e)},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()}};var $n=tn(30*Ze);function Qn(t,e){return+e?function(t,e){function n(i,r,o,s,a,l,u,h,c,f,g,d,p,y){var v=u-i,m=h-r,_=v*v+m*m;if(_>4*e&&p--){var k=s+f,x=a+g,E=l+d,w=nn(k*k+x*x+E*E),I=on(E/=w),M=Je(Je(E)-1)<Ue||Je(o-c)<Ue?(o+c)/2:Qe(x,k),S=t(M,I),b=S[0],N=S[1],L=b-i,P=N-r,C=m*L-v*P;(C*C/_>e||Je((v*L+m*P)/_-.5)>.3||s*f+a*g+l*d<$n)&&(n(i,r,o,s,a,l,b,N,M,k/=w,x/=w,E,p,y),y.point(b,N),n(b,N,M,k,x,E,u,h,c,f,g,d,p,y))}}return function(e){var i,r,o,s,a,l,u,h,c,f,g,d,p={point:y,lineStart:v,lineEnd:_,polygonStart:function(){e.polygonStart(),p.lineStart=k},polygonEnd:function(){e.polygonEnd(),p.lineStart=v}};function y(n,i){n=t(n,i),e.point(n[0],n[1])}function v(){h=NaN,p.point=m,e.lineStart()}function m(i,r){var o=pn([i,r]),s=t(i,r);n(h,c,u,f,g,d,h=s[0],c=s[1],u=i,f=o[0],g=o[1],d=o[2],16,e),e.point(h,c)}function _(){p.point=y,e.lineEnd()}function k(){v(),p.point=x,p.lineEnd=E}function x(t,e){m(i=t,e),r=h,o=c,s=f,a=g,l=d,p.point=m}function E(){n(h,c,u,f,g,d,r,o,i,s,a,l,16,e),p.lineEnd=_,_()}return p}}(t,e):function(t){return Wn({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var ti=Wn({point:function(t,e){this.stream.point(t*Ze,e*Ze)}});function ei(t){return function(t){var e,n,i,r,o,s,a,l,u,h,c=150,f=480,g=250,d=0,p=0,y=0,v=0,m=0,_=null,k=jn,x=null,E=Gn,w=.5,I=Qn(b,w);function M(t){return[(t=o(t[0]*Ze,t[1]*Ze))[0]*c+n,i-t[1]*c]}function S(t){return(t=o.invert((t[0]-n)/c,(i-t[1])/c))&&[t[0]*We,t[1]*We]}function b(t,r){return[(t=e(t,r))[0]*c+n,i-t[1]*c]}function N(){o=xn(r=function(t,e,n){return(t%=Ke)?e||n?xn(In(t),Mn(e,n)):In(t):e||n?Mn(e,n):En}(y,v,m),e);var t=e(d,p);return n=f-t[0]*c,i=g+t[1]*c,L()}function L(){return u=h=null,M}return M.stream=function(t){return u&&h===t?u:u=ti(k(r,I(E(h=t))))},M.clipAngle=function(t){return arguments.length?(k=+t?Kn(_=t*Ze,6*Ze):(_=null,jn),L()):_*We},M.clipExtent=function(t){return arguments.length?(E=null==t?(x=s=a=l=null,Gn):Dn(x=+t[0][0],s=+t[0][1],a=+t[1][0],l=+t[1][1]),L()):null==x?null:[[x,s],[a,l]]},M.scale=function(t){return arguments.length?(c=+t,N()):c},M.translate=function(t){return arguments.length?(f=+t[0],g=+t[1],N()):[f,g]},M.center=function(t){return arguments.length?(d=t[0]%360*Ze,p=t[1]%360*Ze,N()):[d*We,p*We]},M.rotate=function(t){return arguments.length?(y=t[0]%360*Ze,v=t[1]%360*Ze,m=t.length>2?t[2]%360*Ze:0,N()):[y*We,v*We,m*We]},M.precision=function(t){return arguments.length?(I=Qn(b,w=t*t),L()):nn(w)},M.fitExtent=function(t,e){return Jn(M,t,e)},M.fitSize=function(t,e){return function(t,e,n){return Jn(t,[[0,0],e],n)}(M,t,e)},function(){return e=t.apply(this,arguments),M.invert=e.invert&&S,N()}}(function(){return t})()}function ni(t){return function(e,n){var i=tn(e),r=tn(n),o=t(i*r);return[o*r*en(e),o*en(n)]}}function ii(t){return function(e,n){var i=nn(e*e+n*n),r=t(i),o=en(r),s=tn(r);return[Qe(e*o,i*s),on(i&&n*o/i)]}}ni(function(t){return nn(2/(1+t))}).invert=ii(function(t){return 2*on(t/2)});var ri=ni(function(t){return(t=rn(t))&&t/en(t)});function oi(t,e){return[t,e]}ri.invert=ii(function(t){return t}),oi.invert=oi;var{BufferOp:si,GeoJSONReader:ai,GeoJSONWriter:li}=Be;function ui(t,e,n,i){var r=t.properties||{},o="Feature"===t.type?t.geometry:t;if("GeometryCollection"===o.type){var s=[];return q(t,function(t){var r=ui(t,e,n,i);r&&s.push(r)}),O(s)}var a=function(t){var e=function(t,e={}){const n=Re(t);return P([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}(t).geometry.coordinates,n=[-e[0],-e[1]];return ei(ri).scale(79.4188).clipAngle(179.999).rotate(n).scale(b)}(o),l={type:o.type,coordinates:ci(o.coordinates,a)},u=(new ai).read(l),h=R(function(t,e="kilometers"){const n=N[e];if(!n)throw new Error(e+" units is invalid");return t/n}(e,n),"meters"),c=si.bufferOp(u,h,i);if(!hi((c=(new li).write(c)).coordinates))return L({type:c.type,coordinates:fi(c.coordinates,a)},r)}function hi(t){return Array.isArray(t[0])?hi(t[0]):isNaN(t[0])}function ci(t,e){return"object"!=typeof t[0]?e(t):t.map(function(t){return ci(t,e)})}function fi(t,e){return"object"!=typeof t[0]?e.invert(t):t.map(function(t){return fi(t,e)})}var gi=function(t,e,n){var i=(n=n||{}).units||"kilometers",r=n.steps||8;if(!t)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");var o=[];switch(t.type){case"GeometryCollection":return q(t,function(t){var n=ui(t,e,i,r);n&&o.push(n)}),O(o);case"FeatureCollection":return B(t,function(t){var n=ui(t,e,i,r);n&&B(n,function(t){t&&o.push(t)})}),O(o)}return ui(t,e,i,r)};function di(t,e={}){var n="object"==typeof e?e.mutate:e;if(!t)throw new Error("geojson is required");var i=yt(t),r=[];switch(i){case"LineString":r=pi(t,i);break;case"MultiLineString":case"Polygon":dt(t).forEach(function(t){r.push(pi(t,i))});break;case"MultiPolygon":dt(t).forEach(function(t){var e=[];t.forEach(function(t){e.push(pi(t,i))}),r.push(e)});break;case"Point":return t;case"MultiPoint":var o={};dt(t).forEach(function(t){var e=t.join("-");Object.prototype.hasOwnProperty.call(o,e)||(r.push(t),o[e]=!0)});break;default:throw new Error(i+" geometry not supported")}return t.coordinates?!0===n?(t.coordinates=r,t):{type:i,coordinates:r}:!0===n?(t.geometry.coordinates=r,t):L({type:i,coordinates:r},t.properties,{bbox:t.bbox,id:t.id})}function pi(t,e){var n=dt(t);if(2===n.length&&!yi(n[0],n[1]))return n;var i=[],r=n.length-1,o=i.length;i.push(n[0]);for(var s=1;s<r;s++){var a=i[i.length-1];n[s][0]===a[0]&&n[s][1]===a[1]||(i.push(n[s]),(o=i.length)>2&&vi(i[o-3],i[o-1],i[o-2])&&i.splice(i.length-2,1))}if(i.push(n[n.length-1]),o=i.length,("Polygon"===e||"MultiPolygon"===e)&&yi(n[0],n[n.length-1])&&o<4)throw new Error("invalid polygon");return"LineString"===e&&o<3||vi(i[o-3],i[o-1],i[o-2])&&i.splice(i.length-2,1),i}function yi(t,e){return t[0]===e[0]&&t[1]===e[1]}function vi(t,e,n){var i=n[0],r=n[1],o=t[0],s=t[1],a=e[0],l=e[1],u=a-o,h=l-s;return 0===(i-o)*h-(r-s)*u&&(Math.abs(u)>=Math.abs(h)?u>0?o<=i&&i<=a:a<=i&&i<=o:h>0?s<=r&&r<=l:l<=r&&r<=s)}function mi(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return _i(t);case"FeatureCollection":return function(t){const e={type:"FeatureCollection"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"features":return;default:e[n]=t[n]}}),e.features=t.features.map(t=>_i(t)),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return xi(t);default:throw new Error("unknown GeoJSON type")}}function _i(t){const e={type:"Feature"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}),e.properties=ki(t.properties),null==t.geometry?e.geometry=null:e.geometry=xi(t.geometry),e}function ki(t){const e={};return t?(Object.keys(t).forEach(n=>{const i=t[n];"object"==typeof i?null===i?e[n]=null:Array.isArray(i)?e[n]=i.map(t=>t):e[n]=ki(i):e[n]=i}),e):e}function xi(t){const e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(t=>xi(t)),e):(e.coordinates=Ei(t.coordinates),e)}function Ei(t){const e=t;return"object"!=typeof e[0]?e.slice():e.map(t=>Ei(t))}function wi(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function Ii(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function Mi(t,e,n,i,r){for(var o,s=i,a=e+1;a<n;a++){var l=Ii(t[a],t[e],t[n]);l>s&&(o=a,s=l)}s>i&&(o-e>1&&Mi(t,e,o,i,r),r.push(t[o]),n-o>1&&Mi(t,o,n,i,r))}function Si(t,e){var n=t.length-1,i=[t[0]];return Mi(t,0,n,e,i),i.push(t[n]),i}function bi(t,e,n){if(t.length<=2)return t;var i=void 0!==e?e*e:1;return t=n?t:function(t,e){for(var n,i=t[0],r=[i],o=1,s=t.length;o<s;o++)wi(n=t[o],i)>e&&(r.push(n),i=n);return i!==n&&r.push(n),r}(t,i),t=Si(t,i)}function Ni(t,e,n){return t.map(function(t){if(t.length<4)throw new Error("invalid polygon");let i=e,r=bi(t,i,n);for(;!Li(r);)i-=.01*i,r=bi(t,i,n);return r[r.length-1][0]===r[0][0]&&r[r.length-1][1]===r[0][1]||r.push(r[0]),r})}function Li(t){return!(t.length<3)&&!(3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}var Pi=function(t,e={}){var n,i,r,o;if(null===(o=e=null!=e?e:{})||"object"!=typeof o||Array.isArray(o))throw new Error("options is invalid");const s=null!=(n=e.tolerance)?n:1,a=null!=(i=e.highQuality)&&i,l=null!=(r=e.mutate)&&r;if(!t)throw new Error("geojson is required");if(s&&s<0)throw new Error("invalid tolerance");return!0!==l&&(t=mi(t)),q(t,function(t){!function(t,e,n){const i=t.type;if("Point"===i||"MultiPoint"===i)return t;if(di(t,{mutate:!0}),"GeometryCollection"!==i)switch(i){case"LineString":t.coordinates=bi(t.coordinates,e,n);break;case"MultiLineString":t.coordinates=t.coordinates.map(t=>bi(t,e,n));break;case"Polygon":t.coordinates=Ni(t.coordinates,e,n);break;case"MultiPolygon":t.coordinates=t.coordinates.map(t=>Ni(t,e,n))}}(t,s,a)}),t};function Ci(t,e,n,i,r,o,s,a){let l,u,h,c,f;const g={x:null,y:null,onLine1:!1,onLine2:!1};return l=(a-o)*(n-t)-(s-r)*(i-e),0===l?null!==g.x&&null!==g.y&&g:(u=e-o,h=t-r,c=(s-r)*u-(a-o)*h,f=(n-t)*u-(i-e)*h,u=c/l,h=f/l,g.x=t+u*(n-t),g.y=e+u*(i-e),u>=0&&u<=1&&(g.onLine1=!0),h>=0&&h<=1&&(g.onLine2=!0),!(!g.onLine1||!g.onLine2)&&[g.x,g.y])}var Ti=function(t){let e,n;const i={type:"FeatureCollection",features:[]};if(n="Feature"===t.type?t.geometry:t,"LineString"===n.type)e=[n.coordinates];else if("MultiLineString"===n.type)e=n.coordinates;else if("MultiPolygon"===n.type)e=[].concat(...n.coordinates);else{if("Polygon"!==n.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=n.coordinates}return e.forEach(t=>{e.forEach(e=>{for(let n=0;n<t.length-1;n++)for(let r=n;r<e.length-1;r++){if(t===e){if(1===Math.abs(n-r))continue;if(0===n&&r===t.length-2&&t[n][0]===t[t.length-1][0]&&t[n][1]===t[t.length-1][1])continue}const o=Ci(t[n][0],t[n][1],t[n+1][0],t[n+1][1],e[r][0],e[r][1],e[r+1][0],e[r+1][1]);o&&i.features.push(P([o[0],o[1]]))}})}),i};function Oi(t,e,n,i,r){Ai(t,e,n||0,i||t.length-1,r||Di)}function Ai(t,e,n,i,r){for(;i>n;){if(i-n>600){var o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ai(t,e,Math.max(n,Math.floor(e-s*l/o+u)),Math.min(i,Math.floor(e+(o-s)*l/o+u)),r)}var h=t[e],c=n,f=i;for(Ri(t,n,e),r(t[i],h)>0&&Ri(t,n,i);c<f;){for(Ri(t,c,f),c++,f--;r(t[c],h)<0;)c++;for(;r(t[f],h)>0;)f--}0===r(t[n],h)?Ri(t,n,f):Ri(t,++f,i),f<=e&&(n=f+1),e<=f&&(i=f-1)}}function Ri(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function Di(t,e){return t<e?-1:t>e?1:0}class Fi{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!Wi(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?i(s):s;Wi(t,a)&&(e.leaf?n.push(s):Ki(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!Wi(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],o=e.leaf?this.toBBox(r):r;if(Wi(t,o)){if(e.leaf||Ki(t,o))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Zi([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],o=[];let s,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],s=o.pop(),l=!0),n.leaf){const i=Gi(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!Ki(n,i)?a?(s++,n=a.children[s],l=!1):n=null:(r.push(n),o.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let o,s=this._maxEntries;if(r<=s)return o=Zi(t.slice(e,n+1)),Bi(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=Zi([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));Ji(t,e,n,l,this.compareMinX);for(let u=e;u<=n;u+=l){const e=Math.min(u+l-1,n);Ji(t,u,e,a,this.compareMinY);for(let n=u;n<=e;n+=a){const r=Math.min(n+a-1,e);o.children.push(this._build(t,n,r,i-1))}}return Bi(o,this.toBBox),o}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let o=0;o<e.children.length;o++){const s=e.children[o],a=Ui(s),l=Vi(t,s)-a;l<r?(r=l,i=a<i?a:i,n=s):l===r&&a<i&&(i=a,n=s)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),Yi(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),s=Zi(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,Bi(n,this.toBBox),Bi(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=Zi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Bi(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=qi(t,0,s,this.toBBox),a=qi(t,s,n,this.toBBox),l=ji(e,a),u=Ui(e)+Ui(a);l<r?(r=l,i=s,o=u<o?u:o):l===r&&u<o&&(o=u,i=s)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:zi,r=t.leaf?this.compareMinY:Hi;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,o=qi(t,0,e,r),s=qi(t,n-e,n,r);let a=Xi(o)+Xi(s);for(let l=e;l<n-e;l++){const e=t.children[l];Yi(o,t.leaf?r(e):e),a+=Xi(o)}for(let l=n-e-1;l>=e;l--){const e=t.children[l];Yi(s,t.leaf?r(e):e),a+=Xi(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Yi(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():Bi(t[n],this.toBBox)}}function Gi(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function Bi(t,e){qi(t,0,t.children.length,e,t)}function qi(t,e,n,i,r){r||(r=Zi(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];Yi(r,t.leaf?i(e):e)}return r}function Yi(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function zi(t,e){return t.minX-e.minX}function Hi(t,e){return t.minY-e.minY}function Ui(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Xi(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Vi(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function ji(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function Ki(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Wi(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Zi(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ji(t,e,n,i,r){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=i)continue;const s=e+Math.ceil((n-e)/i/2)*i;Oi(t,s,e,n,r),o.push(e,s,s,n)}}function $i(t){return function(t,e,n){var i=n;return q(t,function(t,n,r,o,s){i=e(i,t,n,r,o,s)}),i}(t,(t,e)=>t+function(t){let e,n=0;switch(t.type){case"Polygon":return Qi(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)n+=Qi(t.coordinates[e]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e),0)}function Qi(t){let e=0;if(t&&t.length>0){e+=Math.abs(nr(t[0]));for(let n=1;n<t.length;n++)e-=Math.abs(nr(t[n]))}return e}var tr=20294876564838.72,er=Math.PI/180;function nr(t){const e=t.length-1;if(e<=2)return 0;let n=0,i=0;for(;i<e;){const r=t[i],o=t[i+1===e?0:i+1],s=t[i+2>=e?(i+2)%e:i+2],a=r[0]*er,l=o[1]*er;n+=(s[0]*er-a)*Math.sin(l),i++}return n*tr}const ir=11102230246251565e-32,rr=134217729,or=(3+8*ir)*ir;function sr(t,e,n,i,r){let o,s,a,l,u=e[0],h=i[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=i[++f]);let g=0;if(c<t&&f<n)for(h>u==h>-u?(s=u+o,a=o-(s-u),u=e[++c]):(s=h+o,a=o-(s-h),h=i[++f]),o=s,0!==a&&(r[g++]=a);c<t&&f<n;)h>u==h>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c]):(s=o+h,l=s-o,a=o-(s-l)+(h-l),h=i[++f]),o=s,0!==a&&(r[g++]=a);for(;c<t;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c],o=s,0!==a&&(r[g++]=a);for(;f<n;)s=o+h,l=s-o,a=o-(s-l)+(h-l),h=i[++f],o=s,0!==a&&(r[g++]=a);return 0===o&&0!==g||(r[g++]=o),g}function ar(t){return new Float64Array(t)}const lr=ar(4),ur=ar(8),hr=ar(12),cr=ar(16),fr=ar(4);function gr(t,e,n,i,r,o){const s=(e-o)*(n-r),a=(t-r)*(i-o),l=s-a,u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(t,e,n,i,r,o,s){let a,l,u,h,c,f,g,d,p,y,v,m,_,k,x,E,w,I;const M=t-r,S=n-r,b=e-o,N=i-o;k=M*N,f=rr*M,g=f-(f-M),d=M-g,f=rr*N,p=f-(f-N),y=N-p,x=d*y-(k-g*p-d*p-g*y),E=b*S,f=rr*b,g=f-(f-b),d=b-g,f=rr*S,p=f-(f-S),y=S-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,lr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,lr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,lr[2]=m-(I-c)+(v-c),lr[3]=I;let L=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,lr),P=22204460492503146e-32*s;if(L>=P||-L>=P)return L;if(c=t-M,a=t-(M+c)+(c-r),c=n-S,u=n-(S+c)+(c-r),c=e-b,l=e-(b+c)+(c-o),c=i-N,h=i-(N+c)+(c-o),0===a&&0===l&&0===u&&0===h)return L;if(P=11093356479670487e-47*s+or*Math.abs(L),L+=M*h+N*a-(b*u+S*l),L>=P||-L>=P)return L;k=a*N,f=rr*a,g=f-(f-a),d=a-g,f=rr*N,p=f-(f-N),y=N-p,x=d*y-(k-g*p-d*p-g*y),E=l*S,f=rr*l,g=f-(f-l),d=l-g,f=rr*S,p=f-(f-S),y=S-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,fr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,fr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,fr[2]=m-(I-c)+(v-c),fr[3]=I;const C=sr(4,lr,4,fr,ur);k=M*h,f=rr*M,g=f-(f-M),d=M-g,f=rr*h,p=f-(f-h),y=h-p,x=d*y-(k-g*p-d*p-g*y),E=b*u,f=rr*b,g=f-(f-b),d=b-g,f=rr*u,p=f-(f-u),y=u-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,fr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,fr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,fr[2]=m-(I-c)+(v-c),fr[3]=I;const T=sr(C,ur,4,fr,hr);k=a*h,f=rr*a,g=f-(f-a),d=a-g,f=rr*h,p=f-(f-h),y=h-p,x=d*y-(k-g*p-d*p-g*y),E=l*u,f=rr*l,g=f-(f-l),d=l-g,f=rr*u,p=f-(f-u),y=u-p,w=d*y-(E-g*p-d*p-g*y),v=x-w,c=x-v,fr[0]=x-(v+c)+(c-w),m=k+v,c=m-k,_=k-(m-c)+(v-c),v=_-E,c=_-v,fr[1]=_-(v+c)+(c-E),I=m+v,c=I-m,fr[2]=m-(I-c)+(v-c),fr[3]=I;const O=sr(T,hr,4,fr,cr);return cr[O-1]}(t,e,n,i,r,o,u)}function dr(t,e){var n,i,r,o,s,a,l,u,h,c=0,f=t[0],g=t[1],d=e.length;for(n=0;n<d;n++){i=0;var p=e[n],y=p.length-1;if((u=p[0])[0]!==p[y][0]&&u[1]!==p[y][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-f,s=u[1]-g;i<y;i++){if(a=(h=p[i+1])[0]-f,l=h[1]-g,0===s&&0===l){if(a<=0&&o>=0||o<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(r=gr(o,a,s,l,0,0)))return 0;(r>0&&l>0&&s<=0||r<0&&l<=0&&s>0)&&c++}u=h,s=l,o=a}}return c%2!=0}function pr(t,e,n={}){if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");const i=gt(t),r=pt(e),o=r.type,s=e.bbox;let a=r.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(i,s))return!1;"Polygon"===o&&(a=[a]);let l=!1;for(var u=0;u<a.length;++u){const t=dr(i,a[u]);if(0===t)return!n.ignoreBoundary;t&&(l=!0)}return l}var yr=pr;function vr(t,e,n){if("Polygon"!==t.geometry.type)throw new Error("The input feature must be a Polygon");void 0===n&&(n=1);var i=t.geometry.coordinates,r=[],o={};if(n){for(var s=[],a=0;a<i.length;a++)for(var l=0;l<i[a].length-1;l++)s.push(p(a,l));var u=new Fi;u.load(s)}for(var h=0;h<i.length;h++)for(var c=0;c<i[h].length-1;c++){if(n)u.search(p(h,c)).forEach(function(t){var e=t.ring,n=t.edge;d(h,c,e,n)});else for(var f=0;f<i.length;f++)for(var g=0;g<i[f].length-1;g++)d(h,c,f,g)}return e||(r={type:"Feature",geometry:{type:"MultiPoint",coordinates:r}}),r;function d(t,n,s,a){var l,u,h=i[t][n],c=i[t][n+1],f=i[s][a],g=i[s][a+1],d=function(t,e,n,i){if(mr(t,n)||mr(t,i)||mr(e,n)||mr(i,n))return null;var r=t[0],o=t[1],s=e[0],a=e[1],l=n[0],u=n[1],h=i[0],c=i[1],f=(r-s)*(u-c)-(o-a)*(l-h);return 0===f?null:[((r*a-o*s)*(l-h)-(r-s)*(l*c-u*h))/f,((r*a-o*s)*(u-c)-(o-a)*(l*c-u*h))/f]}(h,c,f,g);if(null!==d&&(l=c[0]!==h[0]?(d[0]-h[0])/(c[0]-h[0]):(d[1]-h[1])/(c[1]-h[1]),u=g[0]!==f[0]?(d[0]-f[0])/(g[0]-f[0]):(d[1]-f[1])/(g[1]-f[1]),!(l>=1||l<=0||u>=1||u<=0))){var p=d,y=!o[p];y&&(o[p]=!0),e?r.push(e(d,t,n,h,c,l,s,a,f,g,u,y)):r.push(d)}}function p(t,e){var n,r,o,s,a=i[t][e],l=i[t][e+1];return a[0]<l[0]?(n=a[0],r=l[0]):(n=l[0],r=a[0]),a[1]<l[1]?(o=a[1],s=l[1]):(o=l[1],s=a[1]),{minX:n,minY:o,maxX:r,maxY:s,ring:t,edge:e}}}function mr(t,e){if(!t||!e)return!1;if(t.length!==e.length)return!1;for(var n=0,i=t.length;n<i;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!mr(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0}function _r(t){if("Feature"!=t.type)throw new Error("The input must a geojson object of type Feature");if(void 0===t.geometry||null==t.geometry)throw new Error("The input must a geojson object with a non-empty geometry");if("Polygon"!=t.geometry.type)throw new Error("The input must be a geojson Polygon");for(var e=t.geometry.coordinates.length,n=[],i=0;i<e;i++){var r=t.geometry.coordinates[i];Ir(r[0],r[r.length-1])||r.push(r[0]);for(var o=0;o<r.length-1;o++)n.push(r[o])}if(!function(t){for(var e={},n=1,i=0,r=t.length;i<r;++i){if(Object.prototype.hasOwnProperty.call(e,t[i])){n=0;break}e[t[i]]=1}return n}(n))throw new Error("The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)");var s=n.length,a=vr(t,function(t,e,n,i,r,o,s,a,l,u,h,c){return[t,e,n,i,r,o,s,a,l,u,h,c]}),l=a.length;if(0==l){var u=[];for(i=0;i<e;i++)u.push(C([t.geometry.coordinates[i]],{parent:-1,winding:wr(t.geometry.coordinates[i])}));var h=O(u);return G(),B(),h}var c=[],f=[];for(i=0;i<e;i++){c.push([]);for(o=0;o<t.geometry.coordinates[i].length-1;o++)c[i].push([new kr(t.geometry.coordinates[i][Mr(o+1,t.geometry.coordinates[i].length-1)],1,[i,o],[i,Mr(o+1,t.geometry.coordinates[i].length-1)],void 0)]),f.push(new xr(t.geometry.coordinates[i][o],[i,Mr(o-1,t.geometry.coordinates[i].length-1)],[i,o],void 0,void 0,!1,!0))}for(i=0;i<l;i++)c[a[i][1]][a[i][2]].push(new kr(a[i][0],a[i][5],[a[i][1],a[i][2]],[a[i][6],a[i][7]],void 0)),a[i][11]&&f.push(new xr(a[i][0],[a[i][1],a[i][2]],[a[i][6],a[i][7]],void 0,void 0,!0,!0));var g=f.length;for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)c[i][o].sort(function(t,e){return t.param<e.param?-1:1});var d=[];for(i=0;i<g;i++)d.push({minX:f[i].coord[0],minY:f[i].coord[1],maxX:f[i].coord[0],maxY:f[i].coord[1],index:i});var p=new Fi;p.load(d);for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)for(var y=0;y<c[i][o].length;y++){m=y==c[i][o].length-1?c[i][Mr(o+1,t.geometry.coordinates[i].length-1)][0].coord:c[i][o][y+1].coord;var v=p.search({minX:m[0],minY:m[1],maxX:m[0],maxY:m[1]})[0];c[i][o][y].nxtIsectAlongEdgeIn=v.index}for(i=0;i<c.length;i++)for(o=0;o<c[i].length;o++)for(y=0;y<c[i][o].length;y++){var m=c[i][o][y].coord,_=(v=p.search({minX:m[0],minY:m[1],maxX:m[0],maxY:m[1]})[0]).index;_<s?f[_].nxtIsectAlongRingAndEdge2=c[i][o][y].nxtIsectAlongEdgeIn:Ir(f[_].ringAndEdge1,c[i][o][y].ringAndEdgeIn)?f[_].nxtIsectAlongRingAndEdge1=c[i][o][y].nxtIsectAlongEdgeIn:f[_].nxtIsectAlongRingAndEdge2=c[i][o][y].nxtIsectAlongEdgeIn}var k=[];for(i=0,o=0;o<e;o++){var x=i;for(y=0;y<t.geometry.coordinates[o].length-1;y++)f[i].coord[0]<f[x].coord[0]&&(x=i),i++;var E=f[x].nxtIsectAlongRingAndEdge2;for(y=0;y<f.length;y++)if(f[y].nxtIsectAlongRingAndEdge1==x||f[y].nxtIsectAlongRingAndEdge2==x){var w=y;break}var I=Er([f[w].coord,f[x].coord,f[E].coord],!0)?1:-1;k.push({isect:x,parent:-1,winding:I})}k.sort(function(t,e){return f[t.isect].coord>f[e.isect].coord?-1:1});for(u=[];k.length>0;){var M=k.pop(),S=M.isect,b=M.parent,N=M.winding,L=u.length,P=[f[S].coord],T=S;if(f[S].ringAndEdge1Walkable)var A=f[S].ringAndEdge1,R=f[S].nxtIsectAlongRingAndEdge1;else A=f[S].ringAndEdge2,R=f[S].nxtIsectAlongRingAndEdge2;for(;!Ir(f[S].coord,f[R].coord);){P.push(f[R].coord);var D=void 0;for(i=0;i<k.length;i++)if(k[i].isect==R){D=i;break}if(null!=D&&k.splice(D,1),Ir(A,f[R].ringAndEdge1)){if(A=f[R].ringAndEdge2,f[R].ringAndEdge2Walkable=!1,f[R].ringAndEdge1Walkable){var F={isect:R};Er([f[T].coord,f[R].coord,f[f[R].nxtIsectAlongRingAndEdge2].coord],1==N)?(F.parent=b,F.winding=-N):(F.parent=L,F.winding=N),k.push(F)}T=R,R=f[R].nxtIsectAlongRingAndEdge2}else{if(A=f[R].ringAndEdge1,f[R].ringAndEdge1Walkable=!1,f[R].ringAndEdge2Walkable){F={isect:R};Er([f[T].coord,f[R].coord,f[f[R].nxtIsectAlongRingAndEdge1].coord],1==N)?(F.parent=b,F.winding=-N):(F.parent=L,F.winding=N),k.push(F)}T=R,R=f[R].nxtIsectAlongRingAndEdge1}}P.push(f[R].coord),u.push(C([P],{index:L,parent:b,winding:N,netWinding:void 0}))}h=O(u);function G(){for(var t=[],e=0;e<h.features.length;e++)-1==h.features[e].properties.parent&&t.push(e);if(t.length>1)for(e=0;e<t.length;e++){for(var n=-1,i=1/0,r=0;r<h.features.length;r++)t[e]!=r&&pr(h.features[t[e]].geometry.coordinates[0][0],h.features[r],{ignoreBoundary:!0})&&$i(h.features[r])<i&&(n=r);h.features[t[e]].properties.parent=n}}function B(){for(var t=0;t<h.features.length;t++)if(-1==h.features[t].properties.parent){var e=h.features[t].properties.winding;h.features[t].properties.netWinding=e,q(t,e)}}function q(t,e){for(var n=0;n<h.features.length;n++)if(h.features[n].properties.parent==t){var i=e+h.features[n].properties.winding;h.features[n].properties.netWinding=i,q(n,i)}}return G(),B(),h}var kr=function(t,e,n,i,r){this.coord=t,this.param=e,this.ringAndEdgeIn=n,this.ringAndEdgeOut=i,this.nxtIsectAlongEdgeIn=r},xr=function(t,e,n,i,r,o,s){this.coord=t,this.ringAndEdge1=e,this.ringAndEdge2=n,this.nxtIsectAlongRingAndEdge1=i,this.nxtIsectAlongRingAndEdge2=r,this.ringAndEdge1Walkable=o,this.ringAndEdge2Walkable=s};function Er(t,e){if(void 0===e&&(e=!0),3!=t.length)throw new Error("This function requires an array of three points [x,y]");return(t[1][0]-t[0][0])*(t[2][1]-t[0][1])-(t[1][1]-t[0][1])*(t[2][0]-t[0][0])>=0==e}function wr(t){for(var e=0,n=0;n<t.length-1;n++)t[n][0]<t[e][0]&&(e=n);if(Er([t[Mr(e-1,t.length-1)],t[e],t[Mr(e+1,t.length-1)]],!0))var i=1;else i=-1;return i}function Ir(t,e){if(!t||!e)return!1;if(t.length!=e.length)return!1;for(var n=0,i=t.length;n<i;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!Ir(t[n],e[n]))return!1}else if(t[n]!=e[n])return!1;return!0}function Mr(t,e){return(t%e+e)%e}var Sr=function(t){var e=[];return Y(t,function(t){"Polygon"===t.geometry.type&&B(_r(t),function(n){e.push(C(n.geometry.coordinates,t.properties))})}),O(e)};function br(t,e,n={}){const i=gt(t),r=dt(e);for(let o=0;o<r.length-1;o++){let t=!1;if(n.ignoreEndVertices&&(0===o&&(t="start"),o===r.length-2&&(t="end"),0===o&&o+1===r.length-1&&(t="both")),Nr(r[o],r[o+1],i,t,void 0===n.epsilon?null:n.epsilon))return!0}return!1}function Nr(t,e,n,i,r){const o=n[0],s=n[1],a=t[0],l=t[1],u=e[0],h=e[1],c=u-a,f=h-l,g=(n[0]-a)*f-(n[1]-l)*c;if(null!==r){if(Math.abs(g)>r)return!1}else if(0!==g)return!1;return Math.abs(c)===Math.abs(f)&&0===Math.abs(c)?!i&&(n[0]===t[0]&&n[1]===t[1]):i?"start"===i?Math.abs(c)>=Math.abs(f)?c>0?a<o&&o<=u:u<=o&&o<a:f>0?l<s&&s<=h:h<=s&&s<l:"end"===i?Math.abs(c)>=Math.abs(f)?c>0?a<=o&&o<u:u<o&&o<=a:f>0?l<=s&&s<h:h<s&&s<=l:"both"===i&&(Math.abs(c)>=Math.abs(f)?c>0?a<o&&o<u:u<o&&o<a:f>0?l<s&&s<h:h<s&&s<l):Math.abs(c)>=Math.abs(f)?c>0?a<=o&&o<=u:u<=o&&o<=a:f>0?l<=s&&s<=h:h<=s&&s<=l}function Lr(t,e){return!(t[0]>e[0])&&(!(t[2]<e[2])&&(!(t[1]>e[1])&&!(t[3]<e[3])))}function Pr(t,e){return t[0]===e[0]&&t[1]===e[1]}function Cr(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}var Tr=function(t,e){var n=pt(t),i=pt(e),r=n.type,o=i.type;switch(r){case"Point":switch(o){case"MultiPoint":return function(t,e){var n,i=!1;for(n=0;n<e.coordinates.length;n++)if(Pr(e.coordinates[n],t.coordinates)){i=!0;break}return i}(n,i);case"LineString":return br(n,i,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return pr(n,i,{ignoreBoundary:!0});default:throw new Error("feature2 "+o+" geometry not supported")}case"MultiPoint":switch(o){case"MultiPoint":return function(t,e){for(var n=0;n<t.coordinates.length;n++){for(var i=!1,r=0;r<e.coordinates.length;r++)Pr(t.coordinates[n],e.coordinates[r])&&(i=!0);if(!i)return!1}return!0}(n,i);case"LineString":return function(t,e){for(var n=!1,i=0;i<t.coordinates.length;i++){if(!br(t.coordinates[i],e))return!1;n||(n=br(t.coordinates[i],e,{ignoreEndVertices:!0}))}return n}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){for(var n=!0,i=!1,r=0;r<t.coordinates.length;r++){if(!(i=pr(t.coordinates[r],e))){n=!1;break}i=pr(t.coordinates[r],e,{ignoreBoundary:!0})}return n&&i}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"LineString":return function(t,e){for(var n=0;n<t.coordinates.length;n++)if(!br(t.coordinates[n],e))return!1;return!0}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){var n=Re(e),i=Re(t);if(!Lr(n,i))return!1;for(var r=!1,o=0;o<t.coordinates.length;o++){if(!pr(t.coordinates[o],e))return!1;if(r||(r=pr(t.coordinates[o],e,{ignoreBoundary:!0})),!r&&o<t.coordinates.length-1)r=pr(Cr(t.coordinates[o],t.coordinates[o+1]),e,{ignoreBoundary:!0})}return r}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}case"Polygon":switch(o){case"Polygon":case"MultiPolygon":return function(t,e){var n=Re(t);if(!Lr(Re(e),n))return!1;for(var i=0;i<t.coordinates[0].length;i++)if(!pr(t.coordinates[0][i],e))return!1;return!0}(n,i);default:throw new Error("feature2 "+o+" geometry not supported")}default:throw new Error("feature1 "+r+" geometry not supported")}},Or=Object.defineProperty,Ar=(t,e)=>Or(t,"name",{value:e,configurable:!0}),Rr=class{constructor(t){var e,n,i;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(e=null==t?void 0:t.precision)?e:17),this.direction=null!=(n=null==t?void 0:t.direction)&&n,this.compareProperties=null==(i=null==t?void 0:t.compareProperties)||i}compare(t,e){if(t.type!==e.type)return!1;if(!Fr(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")){const n=Gr(t),i=Gr(e);return n.every(t=>i.some(e=>this.compare(t,e)))}}return!1}compareCoord(t,e){return t.length===e.length&&t.every((t,n)=>Math.abs(t-e[n])<this.precision)}compareLine(t,e,n=0,i=!1){if(!Fr(t,e))return!1;const r=t;let o=e;if(i&&!this.compareCoord(r[0],o[0])){const t=this.fixStartIndex(o,r);if(!t)return!1;o=t}const s=this.compareCoord(r[n],o[n]);return this.direction||s?this.comparePath(r,o):!!this.compareCoord(r[n],o[o.length-(1+n)])&&this.comparePath(r.slice().reverse(),o)}fixStartIndex(t,e){let n,i=-1;for(let r=0;r<t.length;r++)if(this.compareCoord(t[r],e[0])){i=r;break}return i>=0&&(n=[].concat(t.slice(i,t.length),t.slice(1,i+1))),n}comparePath(t,e){return t.every((t,n)=>this.compareCoord(t,e[n]))}comparePolygon(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){const n=t.coordinates.slice(1,t.coordinates.length),i=e.coordinates.slice(1,e.coordinates.length);return n.every(t=>i.some(e=>this.compareLine(t,e,1,!0)))}return!1}compareGeometryCollection(t,e){return Fr(t.geometries,e.geometries)&&this.compareBBox(t,e)&&t.geometries.every((t,n)=>this.compare(t,e.geometries[n]))}compareFeature(t,e){return t.id===e.id&&(!this.compareProperties||qr(t.properties,e.properties))&&this.compareBBox(t,e)&&this.compare(t.geometry,e.geometry)}compareFeatureCollection(t,e){return Fr(t.features,e.features)&&this.compareBBox(t,e)&&t.features.every((t,n)=>this.compare(t,e.features[n]))}compareBBox(t,e){return Boolean(!t.bbox&&!e.bbox)||!(!t.bbox||!e.bbox)&&this.compareCoord(t.bbox,e.bbox)}};Ar(Rr,"GeojsonEquality");var Dr=Rr;function Fr(t,e){return t.coordinates?t.coordinates.length===e.coordinates.length:t.length===e.length}function Gr(t){return t.coordinates.map(e=>({type:t.type.replace("Multi",""),coordinates:e}))}function Br(t,e,n){return new Dr(n).compare(t,e)}function qr(t,e){if(null===t&&null===e)return!0;if(null===t||null===e)return!1;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(var r of n){const n=t[r],i=e[r],o=Yr(n)&&Yr(i);if(o&&!qr(n,i)||!o&&n!==i)return!1}return!0}Ar(Fr,"sameLength"),Ar(Gr,"explode"),Ar(Br,"geojsonEquality"),Ar(qr,"equal");var Yr=Ar(t=>null!=t&&"object"==typeof t,"isObject");var zr=function(t,e,n={}){let i=n.precision;if(i=null==i||isNaN(i)?6:i,"number"!=typeof i||!(i>=0))throw new Error("precision must be a positive number");return pt(t).type===pt(e).type&&Br(di(t),di(e),{precision:i})};function Hr(t,e,n={}){var i=gt(t),r=gt(e),o=D(r[1]-i[1]),s=D(r[0]-i[0]),a=D(i[1]),l=D(r[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return R(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}var Ur=Object.defineProperty,Xr=Object.defineProperties,Vr=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable,Zr=(t,e,n)=>e in t?Ur(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Jr=(t,e)=>{for(var n in e||(e={}))Kr.call(e,n)&&Zr(t,n,e[n]);if(jr)for(var n of jr(e))Wr.call(e,n)&&Zr(t,n,e[n]);return t},$r=(t,e)=>Xr(t,Vr(e));var Qr=function(t,e,n={}){if(!t)throw new Error("targetPoint is required");if(!e)throw new Error("points is required");let i=1/0,r=0;B(e,(e,o)=>{const s=Hr(t,e,n);s<i&&(r=o,i=s)});const o=mi(e.features[r]);return $r(Jr({},o),{properties:$r(Jr({},o.properties),{featureIndex:r,distanceToPoint:i})})};function to(t,e){return t.length>1?function(t,e,n={}){return L({type:"MultiLineString",coordinates:t},e,n)}(t,e):T(t[0],e)}var eo=function(t,e={}){const n=pt(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return function(t,e={}){const n=pt(t),i=n.coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{};return to(i,r)}(n,e);case"MultiPolygon":return function(t,e={}){const n=pt(t),i=n.coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{},o=[];return i.forEach(t=>{o.push(to(t,r))}),O(o)}(n,e);default:throw new Error("invalid poly")}};function no(t,e,n,i){e=e||("Feature"===t.type?t.properties:{});var r=pt(t),o=r.coordinates,s=r.type;if(!o.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return n&&(o=io(o)),C([o],e);case"MultiLineString":var a=[],l=0;return o.forEach(function(t){if(n&&(t=io(t)),i){var e=(r=Re(T(t)),o=r[0],s=r[1],u=r[2],h=r[3],Math.abs(o-u)*Math.abs(s-h));e>l?(a.unshift(t),l=e):a.push(t)}else a.push(t);var r,o,s,u,h}),C(a,e);default:throw new Error("geometry type "+s+" is not supported")}}function io(t){var e=t[0],n=e[0],i=e[1],r=t[t.length-1],o=r[0],s=r[1];return n===o&&i===s||t.push(e),t}var ro=function(t,e={}){var n,i,r,o=e.properties,s=null==(n=e.autoComplete)||n,a=null==(i=e.orderCoords)||i;if(null!=(r=e.mutate)&&r||(t=mi(t)),"FeatureCollection"===t.type){var l=[];return t.features.forEach(function(t){l.push(dt(no(t,{},s,a)))}),A(l,o)}return no(t,o,s,a)},oo=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;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(let e=0;e<this.length-1;e++){const t=this.points[e],n=this.points[e+1];this.centers.push({x:(t.x+n.x)/2,y:(t.y+n.y)/2,z:(t.z+n.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(let e=0;e<this.centers.length-1;e++){const t=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,n=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,i=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+t),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+n),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+i)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+t),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+n),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+i)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}cacheSteps(t){const e=[];let n=this.pos(0);e.push(0);for(let i=0;i<this.duration;i+=10){const r=this.pos(i);Math.sqrt((r.x-n.x)*(r.x-n.x)+(r.y-n.y)*(r.y-n.y)+(r.z-n.z)*(r.z-n.z))>t&&(e.push(i),n=r)}return e}vector(t){const e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}}pos(t){let e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);const n=e/this.duration;if(n>=1)return this.points[this.length-1];const i=Math.floor((this.points.length-1)*n);return function(t,e,n,i,r){const o=function(t){const e=t*t,n=e*t;return[n,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:r.x*o[0]+i.x*o[1]+n.x*o[2]+e.x*o[3],y:r.y*o[0]+i.y*o[1]+n.y*o[2]+e.y*o[3],z:r.z*o[0]+i.z*o[1]+n.z*o[2]+e.z*o[3]}}((this.length-1)*n-i,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])}};var so=function(t,e={}){const n=e.resolution||1e4,i=e.sharpness||.85,r=[],o=pt(t).coordinates.map(t=>({x:t[0],y:t[1]})),s=new oo({duration:n,points:o,sharpness:i}),a=t=>{var e=s.pos(t);Math.floor(t/100)%2==0&&r.push([e.x,e.y])};for(var l=0;l<s.duration;l+=10)a(l);return a(s.duration),T(r,e.properties)};var ao=function(t,e={}){return z(t,(t,n)=>{const i=n.geometry.coordinates;return t+Hr(i[0],i[1],e)},0)};const lo=()=>"ontouchstart"in window||navigator.maxTouchPoints>0;function uo(){return"undefined"!=typeof vitest}class ho{static getBounds(t,e=0){const n=[];t.forEach(t=>{isNaN(t.lat)||isNaN(t.lng),n.push(t)});const i=new s.Polyline(n).getBounds();return 0!==e?i.pad(e):i}}class co{constructor(t=0,e=0,n=0,i=0){r(this,"direction",{East:new s.LatLng(0,0),North:new s.LatLng(0,0),NorthEast:new s.LatLng(0,0),NorthWest:new s.LatLng(0,0),South:new s.LatLng(0,0),SouthEast:new s.LatLng(0,0),SouthWest:new s.LatLng(0,0),West:new s.LatLng(0,0)}),this.direction.North=new s.LatLng(n,(e+i)/2),this.direction.NorthEast=new s.LatLng(n,i),this.direction.East=new s.LatLng((t+n)/2,i),this.direction.SouthEast=new s.LatLng(t,i),this.direction.South=new s.LatLng(t,(e+i)/2),this.direction.SouthWest=new s.LatLng(t,e),this.direction.West=new s.LatLng((t+n)/2,e),this.direction.NorthWest=new s.LatLng(n,e)}getDirection(t){switch(t){case u.SouthWest:return this.direction.SouthWest;case u.West:return this.direction.West;case u.NorthWest:return this.direction.NorthWest;case u.North:return this.direction.North;case u.NorthEast:return this.direction.NorthEast;case u.East:return this.direction.East;case u.SouthEast:return this.direction.SouthEast;case u.South:return this.direction.South;default:throw new Error}}getPositions(t=u.SouthWest,e=!1,n=!0){const i=[],r=this.getPositionAsArray(t,e);return r.forEach(t=>{i.push([t.lng,t.lat])}),n&&i.push([r[0].lng,r[0].lat]),i}getPositionAsArray(t=u.NorthEast,e=!1){const n=[];if(e?(n.push(this.direction.SouthWest),n.push(this.direction.West),n.push(this.direction.NorthWest),n.push(this.direction.North),n.push(this.direction.NorthEast),n.push(this.direction.East),n.push(this.direction.SouthEast),n.push(this.direction.South)):(n.push(this.direction.SouthWest),n.push(this.direction.South),n.push(this.direction.SouthEast),n.push(this.direction.East),n.push(this.direction.NorthEast),n.push(this.direction.North),n.push(this.direction.NorthWest),n.push(this.direction.West)),t!==u.SouthWest){n.splice(0,t).forEach((e,i)=>{n.splice(t+i,0,e)})}return n}}class fo{constructor(t,e){if(r(this,"metricLength",""),r(this,"metricUnit",""),r(this,"imperialLength",""),r(this,"imperialUnit",""),null!==t||void 0!==t){0===t?e.markers.markerInfoIcon.usePerimeterMinValue?(this.metricLength=e.markers.markerInfoIcon.values.min.metric,this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m,this.imperialLength=e.markers.markerInfoIcon.values.min.imperial,this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.feet):(this.metricLength=e.markers.markerInfoIcon.values.unknown.metric,this.metricUnit=e.markers.markerInfoIcon.units.unknownUnit,this.imperialLength=e.markers.markerInfoIcon.values.unknown.imperial,this.imperialUnit=e.markers.markerInfoIcon.units.unknownUnit):t<100?(this.metricLength=(10*Math.ceil(t/10)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<500?(this.metricLength=(50*Math.ceil(t/50)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<1e3?(this.metricLength=(100*Math.ceil(t/100)).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.m):t<1e4?(this.metricLength=(100*Math.ceil(t/100)/1e3).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.km):(this.metricLength=(1e3*Math.ceil(t/1e3)/1e3).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.perimeter.km);const n=t/.0254/12,i=n/3,r=i/1760;t<1e3/2.54?(this.imperialLength=(10*Math.ceil(n/10)).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.feet):t<1e3/2.54*3?(this.imperialLength=(10*Math.ceil(i/10)).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.yards):t<1609?(this.imperialLength=r.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles):t<16093?(this.imperialLength=r.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles):(this.imperialLength=r.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.perimeter.miles)}}}class go{constructor(t,e){r(this,"metricArea",""),r(this,"metricUnit",""),r(this,"imperialArea",""),r(this,"imperialUnit","");const n=t,i=e.markers.markerInfoIcon.units.metric.onlyMetrics;if(null!==n||void 0!==n){0===n?(this.metricArea="-",this.metricUnit=e.markers.markerInfoIcon.units.unknownUnit,this.imperialArea="-",this.imperialUnit=e.markers.markerInfoIcon.units.unknownUnit):n<1e4?(this.metricArea=Math.round(n).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.m2):n<1e5?i?(this.metricArea=(n/1e6).toFixed(2),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=(n/1e3).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.daa):n<1e7?i?(this.metricArea=(n/1e6).toFixed(2),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=Math.round(n/1e3).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.daa):n<1e8?i?(this.metricArea=(n/1e6).toFixed(1),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2):(this.metricArea=Math.round(n/1e4).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.ha):(this.metricArea=Math.round(n/1e6).toString(),this.metricUnit=e.markers.markerInfoIcon.units.metric.area.km2);const t=.0069444*(1550*n),r=.11111*t,o=20661e-8*r,s=3.2283e-7*r;n<92.9?(this.imperialArea=Math.round(t).toString(),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.feet2):n<836.14?(this.imperialArea=r.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.yards2):n<40469.6?(this.imperialArea=o.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<404696?(this.imperialArea=o.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<4046960?(this.imperialArea=o.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.acres):n<25900404?(this.imperialArea=s.toFixed(2),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2):n<259004040?(this.imperialArea=s.toFixed(1),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2):(this.imperialArea=s.toFixed(0),this.imperialUnit=e.markers.markerInfoIcon.units.imperial.area.miles2)}}}class po{constructor(t){r(this,"config",a),this.config={...a,...t}}union(t,e){try{const n=_([t,e]),i=Ce(n);return i?this.getTurfPolygon(i):null}catch(n){return uo()||console.warn("Error in union:",n instanceof Error?n.message:String(n)),null}}createPolygonFromTrace(t){var e;const n=(null==(e=this.config.polygonCreation)?void 0:e.method)||"concaveman";switch(n){case"concaveman":return this.turfConcaveman(t);case"convex":return this.createConvexPolygon(t);case"direct":return this.createDirectPolygon(t);case"buffer":return this.createBufferedPolygon(t);default:return uo()||console.warn(`Unknown polygon creation method: ${n}, falling back to concaveman`),this.turfConcaveman(t)}}turfConcaveman(t){const e=Ae(t).features.map(t=>t.geometry.coordinates);return m([[ut(e)]])}createConvexPolygon(t){const e=Ae(t),n=ct(e);return n?this.getTurfPolygon(n):this.createDirectPolygon(t)}createDirectPolygon(t){let e;if("LineString"===t.geometry.type)e=t.geometry.coordinates;else if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{e=Ae(t).features.map(t=>t.geometry.coordinates)}if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e.length<4?(uo()||console.warn("Not enough points for direct polygon, falling back to concaveman"),this.turfConcaveman(t)):m([[e]])}createBufferedPolygon(t){try{let e;if("LineString"===t.geometry.type)e=t;else{const n=Ae(t).features.map(t=>t.geometry.coordinates);e=y(n)}const n=gi(e,.001,{units:"kilometers"});return n?this.getTurfPolygon(n):this.createDirectPolygon(t)}catch(e){return uo()||console.warn("Buffer polygon creation failed:",e instanceof Error?e.message:String(e)),this.createDirectPolygon(t)}}getSimplified(t,e=!1){var n,i,r,o,s,a;const l=(null==(i=null==(n=this.config.polygonCreation)?void 0:n.simplification)?void 0:i.mode)||"simple";if("simple"===l){const e={tolerance:(null==(o=null==(r=this.config.polygonCreation)?void 0:r.simplification)?void 0:o.tolerance)||1e-4,highQuality:(null==(a=null==(s=this.config.polygonCreation)?void 0:s.simplification)?void 0:a.highQuality)||!1,mutate:!1};return Pi(t,e)}if("dynamic"===l){const n=t.geometry.coordinates[0][0].length,i=this.config.simplification.simplifyTolerance;if(e){let e=Pi(t,i);const r=this.config.simplification.dynamicMode.fractionGuard,o=this.config.simplification.dynamicMode.multiplier;for(;e.geometry.coordinates[0][0].length>4&&e.geometry.coordinates[0][0].length/(n+2)>r;)i.tolerance=i.tolerance*o,e=Pi(t,i);return e}return Pi(t,i)}if("none"===l)return t;uo()||console.warn(`Unknown simplification mode: ${l}, falling back to simple`);return Pi(t,{tolerance:1e-4,highQuality:!1,mutate:!1})}getTurfPolygon(t){let e;return e="Polygon"===t.geometry.type?m([t.geometry.coordinates]):m(t.geometry.coordinates),e}getMultiPolygon(t){return m(t)}getKinks(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return[t];const e=this.removeDuplicateVertices(t);if(!e||!e.geometry||!e.geometry.coordinates)return uo()||console.warn("Feature became invalid after cleaning in getKinks"),[t];if(this.polygonHasHoles(e))return this.getKinksWithHolePreservation(e);{const t=Sr(e),n=[];return B(t,t=>{n.push(t)}),n}}catch(e){return uo()||console.warn("Error processing kinks:",e instanceof Error?e.message:String(e)),[t]}}getCoords(t){return k(t)}hasKinks(t){return Ti(t).features.length>0}getConvexHull(t){try{const e=_([t]);return ct(e)}catch(e){return uo()||console.warn("Error in getConvexHull:",e instanceof Error?e.message:String(e)),null}}getMidpoint(t,e){const n=E(p([t.lng,t.lat]),p([e.lng,e.lat]));return{lat:n.geometry.coordinates[1],lng:n.geometry.coordinates[0]}}polygonIntersect(t,e){try{if(!(t&&t.geometry&&t.geometry.coordinates&&e&&e.geometry&&e.geometry.coordinates))return uo()||console.warn("Invalid features passed to polygonIntersect"),!1;const r=t=>{if(!Array.isArray(t))return!1;for(const e of t){if(!Array.isArray(e))return!1;for(const t of e){if(!Array.isArray(t)||t.length<2)return!1;if(t.some(t=>null==t||!isFinite(t)))return!1}}return!0};if(!r(t.geometry.coordinates)||!r(e.geometry.coordinates))return!1;try{const n=_([t,e]),i=Te(n);if(i&&i.geometry&&("Polygon"===i.geometry.type||"MultiPolygon"===i.geometry.type)){if(w(i)>1e-6)return!0}}catch(n){}try{const n=Ae(t),i=Ae(e);for(const e of i.features)if(yr(e,t))return!0;for(const t of n.features)if(yr(t,e))return!0}catch(n){}try{const n=k(t),r=k(e);for(const t of n){const e=t[0];if(e&&!(e.length<2))for(let t=0;t<e.length-1;t++){const n=e[t],o=e[t+1];if(!n||!o||!Array.isArray(n)||!Array.isArray(o)||n.length<2||o.length<2||n.some(t=>null==t||!isFinite(t))||o.some(t=>null==t||!isFinite(t)))continue;const s=y([n,o]);for(const t of r){const e=t[0];if(e&&!(e.length<2))for(let t=0;t<e.length-1;t++){const n=e[t],r=e[t+1];if(!n||!r||!Array.isArray(n)||!Array.isArray(r)||n.length<2||r.length<2||n.some(t=>null==t||!isFinite(t))||r.some(t=>null==t||!isFinite(t)))continue;const o=y([n,r]);try{const t=Pt(s,o);if(t&&t.features&&t.features.length>0)return!0}catch(i){}}}}}}catch(n){}return!1}catch(n){return uo()||console.warn("Error in polygonIntersect:",n instanceof Error?n.message:String(n)),!1}}getIntersection(t,e){try{const n=_([t,e]),i=Te(n);return i&&i.geometry&&("Polygon"===i.geometry.type||"MultiPolygon"===i.geometry.type)?i:null}catch(n){return uo()||console.warn("Error in getIntersection:",n instanceof Error?n.message:String(n)),null}}getDistance(t,e){return x(t,e)}isWithin(t,e){return Tr(v([t]),v([e]))}isPolygonCompletelyWithin(t,e){try{return Tr(t,e)}catch(n){const i=k(t),r=k(e);for(const t of i)for(const e of t)for(const t of e){const e=p(t);let n=!1;for(const t of r){for(const i of t){const t=v([i]);if(yr(e,t)){n=!0;break}}if(n)break}if(!n)return!1}return!0}}toPointFeature(t){var e,n;if("Feature"===(null==t?void 0:t.type)&&"Point"===(null==(e=t.geometry)?void 0:e.type))return t;if(Array.isArray(t)&&t.length>=2&&"number"==typeof t[0]&&"number"==typeof t[1])return p(t);if("number"==typeof(null==t?void 0:t.lat)&&"number"==typeof(null==t?void 0:t.lng)){const e=t;return p([e.lng,e.lat])}if((null==(n=null==t?void 0:t.geometry)?void 0:n.coordinates)&&Array.isArray(t.geometry.coordinates))return p(t.geometry.coordinates);throw new Error("Unsupported point format provided to toPointFeature")}isPointInsidePolygon(t,e){try{const n=this.toPointFeature(t);return yr(n,e)}catch(n){return!1}}equalPolygons(t,e){return zr(t,e)}convertToBoundingBoxPolygon(t){const e=function(t){const[e,n,i,r]=t;return v([[[e,n],[i,n],[i,r],[e,r],[e,n]]])}(function(t){let e=1/0,n=1/0,i=-1/0,r=-1/0;const o=t=>{if(Array.isArray(t[0]))t.forEach(o);else{const[o,s]=t;e=Math.min(e,o),n=Math.min(n,s),i=Math.max(i,o),r=Math.max(r,s)}};return o(t.geometry.coordinates),[e,n,i,r]}(t));return e}polygonToMultiPolygon(t){return m([t.geometry.coordinates])}injectPointToPolygon(t,e,n){const i=JSON.parse(JSON.stringify(t));let r;if("MultiPolygon"===i.geometry.type)r=i.geometry.coordinates[0][n];else{if("Polygon"!==i.geometry.type)return i;r=i.geometry.coordinates[n]}if(!r)return i;let o=1/0,s=0;for(let a=0;a<r.length-1;a++){const t=r[a],n=r[a+1],i=this.distanceToLineSegment(e,t,n);i<o&&(o=i,s=a+1)}return r.splice(s,0,e),i}distanceToLineSegment(t,e,n){const i=t[0]-e[0],r=t[1]-e[1],o=n[0]-e[0],s=n[1]-e[1],a=i*o+r*s,l=o*o+s*s;if(0===l)return Math.sqrt(i*i+r*r);const u=a/l;let h,c;u<0?(h=e[0],c=e[1]):u>1?(h=n[0],c=n[1]):(h=e[0]+u*o,c=e[1]+u*s);const f=t[0]-h,g=t[1]-c;return Math.sqrt(f*f+g*g)}polygonDifference(t,e){try{const n=_([t,e]),i=Oe(n);return i?this.getTurfPolygon(i):null}catch(n){return uo()||console.warn("Error in polygonDifference:",n instanceof Error?n.message:String(n)),null}}getBoundingBoxCompassPosition(t,e,n,i){return null}getNearestPointIndex(t,e){return Qr(t,e).properties.featureIndex}getCoord(t){return[t.lng,t.lat]}createPolygon(t){return v(t)}getFeaturePointCollection(t){const e=[];t.forEach(t=>{const n=p([t.lng,t.lat],{});e.push(n)});return _(e)}getPolygonArea(t){return w(t)}getPolygonPerimeter(t){return ao(t,{units:"kilometers"})}getCenterOfMass(t){return vt(t)}getDoubleElbowLatLngs(t){const e=[],n=t.length,i=t[0].lat===t[n-1].lat&&t[0].lng===t[n-1].lng?n-1:n;for(let r=0;r<i;r++){const n=t[r],o=t[(r+1)%i];e.push(new s.LatLng(n.lat,n.lng));const a=E(p([n.lng,n.lat]),p([o.lng,o.lat]));e.push(new s.LatLng(a.geometry.coordinates[1],a.geometry.coordinates[0]))}return e}getBezierMultiPolygon(t){const e=eo(this.getMultiPolygon(t));e.features[0].geometry.coordinates.push(e.features[0].geometry.coordinates[0]);const n=so(e.features[0],{resolution:this.config.bezier.resolution,sharpness:this.config.bezier.sharpness});return ro(n)}polygonHasHoles(t){try{return"Polygon"===t.geometry.type?t.geometry.coordinates.length>1:"MultiPolygon"===t.geometry.type&&t.geometry.coordinates.some(t=>t.length>1)}catch(e){return uo()||console.warn("Error checking for holes:",e instanceof Error?e.message:String(e)),!1}}getKinksWithHolePreservation(t){try{if("Polygon"===t.geometry.type){const e=t.geometry.coordinates,n=e[0],i=e.slice(1),r={type:"Feature",geometry:{type:"Polygon",coordinates:[n]},properties:t.properties||{}},o=this.hasKinks(r),s=this.checkOuterRingHoleIntersection(n,i);if(o||s){if(this.checkIfDragCompletelyThroughHole(n,i))return this.handleCompleteHoleTraversal(r,i);const t=Sr(r),e=[];return B(t,t=>{const n=this.subtractIntersectingHoles(t,i);e.push(n)}),e}return[t]}if("MultiPolygon"===t.geometry.type){const e=[];for(const n of t.geometry.coordinates){const i={type:"Feature",geometry:{type:"Polygon",coordinates:n},properties:t.properties||{}},r=this.getKinksWithHolePreservation(i);e.push(...r)}return e}return[t]}catch(e){return uo()||console.warn("Error in getKinksWithHolePreservation:",e instanceof Error?e.message:String(e)),[t]}}checkIfDragCompletelyThroughHole(t,e){try{if(this.findDuplicatePoints(t).length>0)return!0;const n=this.findSelfIntersectionLine(t);if(n&&e.length>0)for(const t of e)if(this.lineCompletelyTraversesHole(n,t))return!0;if(this.hasKinks({type:"Feature",geometry:{type:"Polygon",coordinates:[t]},properties:{}}))for(const i of e)if(this.holeIsCutByKinks(t,i))return!0;return!1}catch(n){return uo()||console.warn("Error checking complete hole traversal:",n instanceof Error?n.message:String(n)),!1}}findSelfIntersectionLine(t){try{const e=new Map;for(let n=0;n<t.length-1;n++){const i=t[n],r=`${i[0]},${i[1]}`;e.has(r)?e.get(r).indices.push(n):e.set(r,{point:i,indices:[n]})}for(const[,n]of e)if(n.indices.length>=2){const e=n.indices[0],i=n.indices[1],r=[];for(let n=e;n<=i;n++)r.push(t[n]);return r}return null}catch(e){return uo()||console.warn("Error finding self-intersection line:",e instanceof Error?e.message:String(e)),null}}lineCompletelyTraversesHole(t,e){try{if(t.length<2)return!1;const n=t[0],i=t[t.length-1],r=v([e]),o=yr(p(n),r);return o!==yr(p(i),r)}catch(n){return uo()||console.warn("Error checking line hole traversal:",n instanceof Error?n.message:String(n)),!1}}holeIsCutByKinks(t,e){try{const n=v([t]),i=v([e]),r=Ti(n);if(0===r.features.length)return!1;for(const t of r.features){const e=t.geometry.coordinates;try{if(x(p(e),I(i))<.01)return!0;if(yr(p(e),i))return!0}catch{if(yr(p(e),i))return!0}}return!1}catch(n){return uo()||console.warn("Error checking hole cut by kinks:",n.message),!1}}findDuplicatePoints(t){const e=[],n=new Set;for(let i=0;i<t.length-1;i++){const r=t[i],o=`${r[0]},${r[1]}`;n.has(o)?e.push(r):n.add(o)}return e}checkOuterRingHoleIntersection(t,e){try{if(0===e.length)return!1;const n=v([t]);for(const i of e){const e=v([i]);if(this.getIntersection(n,e))return!0;for(let n=0;n<t.length-1;n++){const i=t[n];if(yr(p(i),e))return!0}}return!1}catch(n){return!1}}handleCompleteHoleTraversal(t,e){try{const e={type:"Feature",geometry:{type:"Polygon",coordinates:[t.geometry.coordinates[0]]},properties:t.properties||{}},n=Sr(e),i=[];return B(n,t=>{t._polydrawHoleTraversalOccurred=!0,i.push(t)}),i}catch(n){uo()||console.warn("Error handling complete hole traversal:",n instanceof Error?n.message:String(n));try{const e={...t,geometry:{...t.geometry,coordinates:[t.geometry.coordinates[0]]}};return e._polydrawHoleTraversalOccurred=!0,[e]}catch(i){return[t]}}}subtractIntersectingHoles(t,e){try{let n=t;for(const t of e){const e=v([t]);if(this.getIntersection(e,n)){const t=this.polygonDifference(n,e);if(t)if("Polygon"===t.geometry.type)n=t;else if("MultiPolygon"===t.geometry.type){const e=t;let i=0,r=null;for(const t of e.geometry.coordinates){const e={type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{}},n=w(e);n>i&&(i=n,r=e)}r&&(n=r)}}}return n}catch(n){return uo()||console.warn("Error subtracting intersecting holes:",n instanceof Error?n.message:String(n)),t}}removeDuplicateVertices(t){if(!t||!t.geometry||!t.geometry.coordinates)return uo()||console.warn("Invalid feature passed to removeDuplicateVertices"),t;const e=t=>{if(!t||t.length<3)return uo()||console.warn("Invalid coordinates array - need at least 3 points for a polygon"),t||[];const e=[],n=1e-6;for(let i=0;i<t.length;i++){const r=t[i],o=t[(i+1)%t.length];if(!r||!Array.isArray(r)||r.length<2||!o||!Array.isArray(o)||o.length<2)continue;const s=Math.abs(r[1]-o[1]),a=Math.abs(r[0]-o[0]);(s>n||a>n)&&e.push(r)}if(e.length<3)return uo()||console.warn("After cleaning, polygon has less than 3 points"),t;if(e.length>0){const t=e[0],i=e[e.length-1],r=Math.abs(t[1]-i[1]),o=Math.abs(t[0]-i[0]);(r>n||o>n)&&e.push([t[0],t[1]])}return e};try{if("Polygon"===t.geometry.type){const n=t.geometry.coordinates.map(t=>e(t));return n.some(t=>t.length<4)?(uo()||console.warn("Cleaned polygon has invalid ring with less than 4 coordinates"),t):{...t,geometry:{...t.geometry,coordinates:n}}}if("MultiPolygon"===t.geometry.type){const n=t.geometry.coordinates.map(t=>t.map(t=>e(t)));return n.some(t=>t.some(t=>t.length<4))?(uo()||console.warn("Cleaned multipolygon has invalid ring with less than 4 coordinates"),t):{...t,geometry:{...t.geometry,coordinates:n}}}}catch(n){return uo()||console.warn("Error in removeDuplicateVertices:",n instanceof Error?n.message:String(n)),t}return t}}class yo{static getCenter(t){let e=0,n=0,i=0;t.forEach(t=>{let r=t.lat,o=t.lng;r*=g,o*=g,e+=Math.cos(r)*Math.cos(o),n+=Math.cos(r)*Math.sin(o),i+=Math.sin(r)});let r=Math.atan2(n,e);const o=Math.sqrt(e*e+n*n);let s=Math.atan2(i,o);s*=d,r*=d;return{lat:s,lng:r}}static getSouthWest(t){return this.getBounds(t).getSouthWest()}static getNorthEast(t){return this.getBounds(t).getNorthEast()}static getNorthWest(t){return this.getBounds(t).getNorthWest()}static getSouthEast(t){return this.getBounds(t).getSouthEast()}static getNorth(t){return this.getBounds(t).getNorth()}static getSouth(t){return this.getBounds(t).getSouth()}static getWest(t){return this.getBounds(t).getWest()}static getEast(t){return this.getBounds(t).getEast()}static getSqmArea(t){const e=new s.Polygon(t).toGeoJSON();return this.turfHelper.getPolygonArea(e)}static getPerimeter(t){const e=new s.Polygon(t).toGeoJSON();return 1e3*this.turfHelper.getPolygonPerimeter(e)}static getPolygonChecksum(t){const e=t.filter((t,e,n)=>{const i=n.find(e=>e.lat===t.lat&&e.lng===t.lng);return!!i&&n.indexOf(i)===e});return e.reduce((t,e)=>+t+ +e.lat,0)*e.reduce((t,e)=>+t+ +e.lng,0)}static getMidPoint(t,e){const n=this.turfHelper.getMidpoint(t,e);return{lat:n.lat,lng:n.lng}}static getBounds(t){const e=[];t.forEach(t=>{isNaN(t.lat)||isNaN(t.lng),e.push(t)});return new s.Polyline(e).getBounds()}static getCenterOfMass(t){const e=this.turfHelper.getCenterOfMass(t);return{lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]}}}r(yo,"turfHelper",new po(a));class vo{constructor(t){if(r(this,"polygon",[]),r(this,"trashcanPoint",[]),r(this,"sqmArea",[]),r(this,"perimeter",[]),!Array.isArray(t))return;if(t.length>0&&Array.isArray(t[0])&&t[0].length>0&&"object"==typeof t[0][0]&&"lat"in t[0][0]){const e=t[0];return this.trashcanPoint[0]=this.getTrashcanPoint(e),this.sqmArea[0]=this.calculatePolygonArea(e),this.perimeter[0]=this.calculatePolygonPerimeter(e),void(this.polygon[0]=[e])}if(t.length>0&&t[0]&&"object"==typeof t[0]&&"lat"in t[0]){const e=t,n=[[e]];return this.trashcanPoint[0]=this.getTrashcanPoint(e),this.sqmArea[0]=this.calculatePolygonArea(e),this.perimeter[0]=this.calculatePolygonPerimeter(e),void(this.polygon[0]=n[0])}t.forEach((t,e)=>{t&&Array.isArray(t)&&t[0]&&Array.isArray(t[0])&&(this.trashcanPoint[e]=this.getTrashcanPoint(t[0]),this.sqmArea[e]=this.calculatePolygonArea(t[0]),this.perimeter[e]=this.calculatePolygonPerimeter(t[0]),this.polygon[e]=t)})}setSqmArea(t){this.sqmArea[0]=t}getTrashcanPoint(t){if(!Array.isArray(t)||0===t.length)return console.warn("getTrashcanPoint: Invalid polygon array:",t),{lat:0,lng:0};const e=t.filter(t=>t&&"object"==typeof t&&"number"==typeof t.lat&&"number"==typeof t.lng&&!isNaN(t.lat)&&!isNaN(t.lng));if(0===e.length)return console.warn("getTrashcanPoint: No valid coordinates found:",t),{lat:0,lng:0};const n=Math.max(...e.map(t=>t.lat)),i=e.findIndex(t=>t.lat===n);if(-1===i)return console.warn("getTrashcanPoint: Could not find max lat coordinate"),{lat:0,lng:0};let r,o;if(i>0?(r=e[i-1],o=i<e.length-1?e[i+1]:e[0]):(r=e[e.length-1],o=e[i+1]),!r||!o)return console.warn("getTrashcanPoint: Could not determine previous/next points"),e[i]||{lat:0,lng:0};const s=r.lng<o.lng?r:o;return yo.getMidPoint(e[i],s)}calculatePolygonArea(t){return yo.getSqmArea(t)}calculatePolygonPerimeter(t){return yo.getPerimeter(t)}}class mo{constructor(t){r(this,"polygonInfoListeners",[]),r(this,"polygonDrawStateListeners",[]),r(this,"polygonInformationStorage",[]),this.mapStateService=t}onPolygonInfoUpdated(t){this.polygonInfoListeners.push(t)}emitPolygonInfoUpdated(){for(const t of this.polygonInfoListeners)t(this.polygonInformationStorage)}onPolygonDrawStateUpdated(t){this.polygonDrawStateListeners.push(t)}updatePolygons(){const t=[];this.polygonInformationStorage.length>0&&this.polygonInformationStorage.forEach(e=>{const n=[];e.polygon.forEach(t=>{t.forEach(t=>{const e=[...t];t.length>0&&t[0].toString()!==t[t.length-1].toString()&&e.push(t[0]),n.push(e)})}),t.push(n)}),this.mapStateService.updatePolygons(t),this.saveCurrentState()}saveCurrentState(){this.emitPolygonInfoUpdated()}deleteTrashcan(t){const e=this.polygonInformationStorage.findIndex(e=>e.polygon[0]===t);-1!==e&&(this.polygonInformationStorage.splice(e,1),this.updatePolygons())}deleteTrashCanOnMulti(t){let e=0;this.polygonInformationStorage.forEach((n,i)=>{const r=n.polygon.findIndex(e=>e.toString()===t.toString());r>=0&&(e=i,n.trashcanPoint.splice(r,1),n.sqmArea.splice(r,1),n.perimeter.splice(r,1),n.polygon.splice(r,1))}),this.updatePolygons(),this.polygonInformationStorage.length>1&&this.polygonInformationStorage.splice(e,1)}deletePolygonInformationStorage(){this.polygonInformationStorage=[]}createPolygonInformationStorage(t){t.length>0&&(t.forEach(t=>{var e;const n=null==(e=t.getLayers)?void 0:e.call(t);if(null==n?void 0:n[0]){const t=n[0].getLatLngs(),e=new vo(t);this.polygonInformationStorage.push(e)}}),this.updatePolygons())}}class _o{constructor(){r(this,"map",null),r(this,"mapListeners",[])}onMapUpdated(t){this.map&&t(this.map),this.mapListeners.push(t)}emitMapUpdated(){if(this.map)for(const t of this.mapListeners)t(this.map)}updateMapState(t){this.map=t,this.emitMapUpdated()}updatePolygons(t){}}class ko{constructor(){r(this,"eventListeners",new Map)}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){const n=this.eventListeners.get(t);if(n){const t=n.indexOf(e);t>-1&&n.splice(t,1)}}emit(t,e){var n;this.eventListeners.has(t)&&(null==(n=this.eventListeners.get(t))||n.forEach(t=>{t(e)}))}}class xo{constructor(t,e){r(this,"state"),r(this,"config"),r(this,"eventManager"),this.config=t,this.eventManager=e,this.state=this.createInitialState()}createInitialState(){return{polygonDragging:this.config.modes.dragPolygons??!1,markerDragging:this.config.modes.dragElbow??!1,edgeClicking:!0,polygonClicking:!0,canStartDrawing:!0,canCompletePolygon:!1,mapDragging:!0,mapZooming:!0,mapDoubleClickZoom:!0,currentMode:l.Off,isDrawingActive:!1,isModifierKeyHeld:!1,showCrosshairCursor:!1,showDragCursor:!1}}updateStateForMode(t){switch(this.state.currentMode=t,t){case l.Off:this.setOffModeState();break;case l.Add:case l.Subtract:this.setDrawingModeState();break;case l.PointToPoint:this.setPointToPointModeState()}this.state.isDrawingActive=t!==l.Off,this.eventManager.emit("polydraw:mode:change",{mode:t})}setOffModeState(){this.state.polygonDragging=this.config.modes.dragPolygons??!1,this.state.markerDragging=this.config.modes.dragElbow??!1,this.state.edgeClicking=!0,this.state.polygonClicking=!0,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!1,this.state.mapDragging=!0,this.state.mapZooming=!0,this.state.mapDoubleClickZoom=!0,this.state.showCrosshairCursor=!1,this.state.showDragCursor=!1}setDrawingModeState(){this.state.polygonDragging=!1,this.state.markerDragging=!1,this.state.edgeClicking=!1,this.state.polygonClicking=!1,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!0,this.state.mapDragging=!1,this.state.mapZooming=!1,this.state.mapDoubleClickZoom=!1,this.state.showCrosshairCursor=!0,this.state.showDragCursor=!1}setPointToPointModeState(){this.state.polygonDragging=!1,this.state.markerDragging=!1,this.state.edgeClicking=!1,this.state.polygonClicking=!1,this.state.canStartDrawing=!0,this.state.canCompletePolygon=!0,this.state.mapDragging=!1,this.state.mapZooming=!1,this.state.mapDoubleClickZoom=!1,this.state.showCrosshairCursor=!0,this.state.showDragCursor=!1}setModifierKeyState(t){this.state.isModifierKeyHeld=t,this.state.currentMode,l.Off}canPerformAction(t){switch(t){case"polygonDrag":return this.state.polygonDragging;case"markerDrag":return this.state.markerDragging;case"edgeClick":return this.state.edgeClicking;case"polygonClick":return this.state.polygonClicking;case"startDrawing":return this.state.canStartDrawing;case"completePolygon":return this.state.canCompletePolygon;case"mapDrag":return this.state.mapDragging;case"mapZoom":return this.state.mapZooming;case"mapDoubleClickZoom":return this.state.mapDoubleClickZoom;default:return!1}}isInDrawingMode(){return this.state.isDrawingActive}isInOffMode(){return this.state.currentMode===l.Off}getCurrentMode(){return this.state.currentMode}getState(){return{...this.state}}shouldShowCrosshairCursor(){return this.state.showCrosshairCursor}shouldShowDragCursor(){return this.state.showDragCursor}updateConfig(t){this.config=t,this.updateStateForMode(this.state.currentMode)}}class Eo{constructor(t){r(this,"turfHelper"),r(this,"map"),r(this,"config"),r(this,"modeManager"),r(this,"eventManager"),r(this,"tracer"),r(this,"p2pMarkers",[]),r(this,"isModifierKeyHeld",!1),r(this,"markerModifierHandlers",new WeakMap),this.turfHelper=t.turfHelper,this.map=t.map,this.config=t.config,this.modeManager=t.modeManager,this.eventManager=t.eventManager,this.tracer=t.tracer}mouseMove(t){if("latlng"in t&&t.latlng)this.tracer.addLatLng(t.latlng);else if("touches"in t&&t.touches&&t.touches.length>0){const e=this.map.getContainer().getBoundingClientRect(),n=this.map.containerPointToLatLng([t.touches[0].clientX-e.x,t.touches[0].clientY-e.y]);this.tracer.addLatLng(n)}}async mouseUpLeave(t){const e=this.tracer.toGeoJSON();if(!e||!e.geometry||!e.geometry.coordinates||e.geometry.coordinates.length<3)return{success:!1,error:"Not enough points to form a valid polygon. Event: "+JSON.stringify(t)};let n;try{n=this.turfHelper.createPolygonFromTrace(e)}catch(i){return{success:!1,error:(i instanceof Error?i.message:"Failed to create polygon from trace")+". Event: "+JSON.stringify(t)}}return n&&n.geometry&&n.geometry.coordinates&&0!==n.geometry.coordinates.length?(this.eventManager.emit("polydraw:polygon:created",{polygon:n,mode:this.modeManager.getCurrentMode()}),{success:!0,polygon:n}):{success:!1,error:"Invalid polygon created from trace. Event: "+JSON.stringify(t)}}setModifierKey(t){this.isModifierKeyHeld=t}handlePointToPointClick(t){if(t){if(this.p2pMarkers.length>=3){const e=this.p2pMarkers[0].getLatLng();if(this.isClickingFirstPoint(t,e))return void this.completePointToPointPolygon()}try{const e=0===this.p2pMarkers.length,n=e?"leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker":"leaflet-polydraw-p2p-marker",i=new s.Marker(t,{icon:s.divIcon({className:n,iconSize:e?[20,20]:[16,16]}),draggable:this.config.modes.dragElbow}).addTo(this.map);i.on("mousedown",t=>{s.DomEvent.stopPropagation(t)}),i.on("drag",()=>{this.updateP2PTracer()}),i.on("click",t=>{this.isModifierKeyHeld&&this.config.modes.edgeDeletion&&(this.deleteP2PMarker(i),s.DomEvent.stopPropagation(t))}),i.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(i,!0)),i.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(i,!1)),e&&(i.on("mouseover",()=>{if(this.p2pMarkers.length>=3){const t=i.getElement();t&&(t.style.backgroundColor=this.config.colors.p2p.closingMarker,t.style.borderColor=this.config.colors.p2p.closingMarker,t.style.cursor="pointer",t.title="Click to close polygon")}}),i.on("mouseout",()=>{const t=i.getElement();t&&(t.style.backgroundColor="",t.style.borderColor="",t.style.cursor="",t.title="")}),i.on("click",t=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion)return this.deleteP2PMarker(i),void s.DomEvent.stopPropagation(t);this.p2pMarkers.length>=3&&(s.DomEvent.stopPropagation(t),this.completePointToPointPolygon())})),this.p2pMarkers.push(i),this.updateP2PTracer()}catch(e){}}}handleDoubleClick(t){this.modeManager.getCurrentMode()===l.PointToPoint&&this.p2pMarkers.length>=3&&this.completePointToPointPolygon()}completePointToPointPolygon(){const t=this.p2pMarkers.map(t=>t.getLatLng());if(t.length<3)return;const e=[...t],n=t[0],i=t[t.length-1];n.lat===i.lat&&n.lng===i.lng||e.push(n);try{const t=e.map(t=>[t.lng,t.lat]),n=this.turfHelper.getMultiPolygon([[t]]);this.clearP2pMarkers(),this.resetTracer(),this.eventManager.emit("polydraw:polygon:created",{polygon:n,mode:l.PointToPoint,isPointToPoint:!0})}catch(r){uo()||console.warn("Error completing point-to-point polygon:",r),this.clearP2pMarkers(),this.resetTracer()}}cancelPointToPointDrawing(){this.clearP2pMarkers(),this.resetTracer(),this.eventManager.emit("polydraw:draw:cancel",{mode:l.PointToPoint})}clearP2pMarkers(){this.p2pMarkers.forEach(t=>this.map.removeLayer(t)),this.p2pMarkers=[]}resetTracer(){this.tracer.setLatLngs([]);try{this.tracer.setStyle({dashArray:void 0})}catch(t){}}isClickingFirstPoint(t,e){if(!e)return!1;const n=this.map.getZoom(),i=5e-4/Math.pow(2,Math.max(0,n-10)),r=Math.abs(t.lat-e.lat),o=Math.abs(t.lng-e.lng);return r<i&&o<i}updateP2PTracer(){const t=this.p2pMarkers.map(t=>t.getLatLng());if(this.tracer.setLatLngs(t),this.p2pMarkers.length>=2)try{this.tracer.setStyle({color:this.config.colors.polyline,dashArray:"5, 5"})}catch(e){}else try{this.tracer.setStyle({dashArray:void 0})}catch(e){}}deleteP2PMarker(t){const e=this.p2pMarkers.findIndex(e=>e===t);e>-1&&(this.p2pMarkers.splice(e,1),this.map.removeLayer(t),this.updateP2PTracer(),0===e&&this.p2pMarkers.length>0&&this.setupFirstMarker())}getP2pMarkers(){return[...this.p2pMarkers]}isInPointToPointMode(){return this.modeManager.getCurrentMode()===l.PointToPoint}getTracerPointsCount(){return this.tracer.getLatLngs().length}setupFirstMarker(){if(0===this.p2pMarkers.length)return;const t=this.p2pMarkers[0],e=t.getElement();e&&(e.classList.add("leaflet-polydraw-p2p-first-marker"),t.setIcon(s.divIcon({className:"leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker",iconSize:[20,20]}))),t.off("mouseover"),t.off("mouseout"),t.off("click"),t.on("mouseover",()=>{if(this.p2pMarkers.length>=3){const e=t.getElement();e&&(e.style.backgroundColor=this.config.colors.p2p.closingMarker,e.style.borderColor=this.config.colors.p2p.closingMarker,e.style.cursor="pointer",e.title="Click to close polygon")}}),t.on("mouseout",()=>{const e=t.getElement();e&&(e.style.backgroundColor="",e.style.borderColor="",e.style.cursor="",e.title="")}),t.on("click",e=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion)return this.deleteP2PMarker(t),void s.DomEvent.stopPropagation(e);this.p2pMarkers.length>=3&&(s.DomEvent.stopPropagation(e),this.completePointToPointPolygon())})}onMarkerHoverForEdgeDeletion(t,e){const n=t.getElement();if(n)if(e){const e=t=>{if(this.isModifierKeyHeld&&this.config.modes.edgeDeletion){n.classList.add("edge-deletion-hover");try{this.map.getContainer().style.cursor="pointer"}catch(e){}}else{n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(e){}}};this.markerModifierHandlers.set(t,e),document.addEventListener("keydown",e),document.addEventListener("keyup",e),n.addEventListener("mousemove",e)}else{n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(i){}const e=this.markerModifierHandlers.get(t);e&&(document.removeEventListener("keydown",e),document.removeEventListener("keyup",e),n.removeEventListener("mousemove",e),this.markerModifierHandlers.delete(t))}}}class wo{constructor(t){r(this,"turfHelper"),r(this,"config"),this.turfHelper=t.turfHelper,this.config=t.config}checkPolygonIntersection(t,e){try{const n=this.turfHelper.isPolygonCompletelyWithin(t,e),i=this.turfHelper.isPolygonCompletelyWithin(e,t);if(n||i)return!0}catch(n){}try{if(this.turfHelper.polygonIntersect(t,e))return!0}catch(n){}try{const n=this.turfHelper.getIntersection(t,e);if(n&&n.geometry&&("Polygon"===n.geometry.type||"MultiPolygon"===n.geometry.type)){if(this.turfHelper.getPolygonArea(n)>1e-6)return!0}}catch(n){}try{const n=this.turfHelper.getCoords(t),i=this.turfHelper.getCoords(e);for(const e of i)for(const n of e[0]){const e={type:"Feature",geometry:{type:"Point",coordinates:n},properties:{}};if(this.turfHelper.isPointInsidePolygon(e,t))return!0}for(const t of n)for(const n of t[0]){const t={type:"Feature",geometry:{type:"Point",coordinates:n},properties:{}};if(this.turfHelper.isPointInsidePolygon(t,e))return!0}}catch(n){}return!1}unionPolygons(t,e){try{let n=e;for(const e of t){const t=this.turfHelper.union(n,e);t&&(n=t)}return{success:!0,result:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in unionPolygons"}}}subtractPolygon(t,e){try{const n=this.turfHelper.polygonDifference(t,e);if(n){const t=this.turfHelper.getCoords(n),e=[];for(const n of t)e.push(this.turfHelper.getMultiPolygon([n]));return{success:!0,results:e}}return{success:!0,results:[]}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in subtractPolygon"}}}simplifyPolygon(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};const r=(null==(n=null==(e=this.config.menuOperations)?void 0:e.simplify)?void 0:n.processHoles)??!0,o=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];if(0===n||r){if(i.length<=4){e.push(i);continue}const t=[];for(let e=0;e<i.length;e+=2)t.push(i[e]);const n=t[0],r=t[t.length-1];n[0]===r[0]&&n[1]===r[1]||t.push(n),t.length<4?e.push(i):e.push(t)}else e.push(i)}return e}),s=this.turfHelper.getMultiPolygon(o);return{success:!0,result:this.turfHelper.getTurfPolygon(s)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in simplifyPolygon"}}}convertToBoundingBox(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};if(!((null==(n=null==(e=this.config.menuOperations)?void 0:e.bbox)?void 0:n.processHoles)??!0)){const e=this.turfHelper.convertToBoundingBoxPolygon(t);return{success:!0,result:this.turfHelper.getTurfPolygon(e)}}const r=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];let r=1/0,o=-1/0,s=1/0,a=-1/0;for(const t of i)if(Array.isArray(t)&&t.length>=2){const e=t[0],n=t[1];"number"!=typeof e||"number"!=typeof n||isNaN(e)||isNaN(n)||(s=Math.min(s,e),a=Math.max(a,e),r=Math.min(r,n),o=Math.max(o,n))}if(r!==1/0&&o!==-1/0&&s!==1/0&&a!==-1/0){const t=[[s,r],[s,o],[a,o],[a,r],[s,r]];e.push(t)}else e.push(i)}return e}),o=this.turfHelper.getMultiPolygon(r);return{success:!0,result:this.turfHelper.getTurfPolygon(o)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in convertToBoundingBox"}}}bezierifyPolygon(t){try{const e=this.turfHelper.getCoords(t),n=this.turfHelper.getBezierMultiPolygon(e);return{success:!0,result:this.turfHelper.getTurfPolygon(n)}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error in bezierifyPolygon"}}}doubleElbowsPolygon(t){var e,n;try{const i=this.turfHelper.getCoords(t);if(!i||0===i.length)return{success:!1,error:"Invalid polygon coordinates"};const r=(null==(n=null==(e=this.config.menuOperations)?void 0:e.doubleElbows)?void 0:n.processHoles)??!0,o=i.map(t=>{const e=[];for(let n=0;n<t.length;n++){const i=t[n];if(0===n||r){const t=i.map(t=>({lat:t[1],lng:t[0]})),n=this.turfHelper.getDoubleElbowLatLngs(t).map(t=>[t.lng,t.lat]);e.push(n)}else e.push(i)}return e}),s=this.turfHelper.getMultiPolygon(o);return{success:!0,result:this.turfHelper.getTurfPolygon(s)}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in doubleElbowsPolygon"}}}}class Io{static createDivIcon(t){const e=t.join(" ");return s.divIcon({className:e})}}class Mo{constructor(t,e){r(this,"markerFeatureGroupMap",new WeakMap),r(this,"markerModifierHandlers",new WeakMap),r(this,"_activeMarker",null),r(this,"isDraggingMarker",!1),r(this,"turfHelper"),r(this,"polygonInformation"),r(this,"map"),r(this,"config"),r(this,"modeManager"),r(this,"eventManager"),r(this,"currentDragPolygon",null),r(this,"currentModifierDragMode",!1),r(this,"isModifierKeyHeld",!1),r(this,"_openMenuPopup",null),r(this,"getFeatureGroups"),r(this,"removeFeatureGroup"),r(this,"onPolygonMouseMove",t=>{if(!this.currentDragPolygon||!this.currentDragPolygon._polydrawDragData||!this.currentDragPolygon._polydrawDragData.isDragging)return;const e=this.currentDragPolygon,n=e._polydrawDragData,i=t.originalEvent&&"metaKey"in t.originalEvent?t.originalEvent:t;this.detectDragSubtractModifierKey(i)!==this.currentModifierDragMode&&this.handleModifierToggleDuringDrag(i);const r=n.startPosition,o=t.latlng,s=o.lat-r.lat,a=o.lng-r.lng,l=this.offsetPolygonCoordinates(n.startLatLngs,s,a);e.setLatLngs(l),this.updateMarkersAndHoleLinesDuringDrag(e,s,a)}),r(this,"onPolygonMouseUp",t=>{if(!this.currentDragPolygon||!this.currentDragPolygon._polydrawDragData||!this.currentDragPolygon._polydrawDragData.isDragging)return;const e=this.currentDragPolygon;e._polydrawDragData.isDragging=!1,this.map.off("mousemove",this.onPolygonMouseMove,this),this.map.off("mouseup",this.onPolygonMouseUp,this),this.map.dragging&&this.map.dragging.enable(),e._polydrawDragData&&null!=e._polydrawDragData.originalOpacity&&e.setStyle({fillOpacity:e._polydrawDragData.originalOpacity}),this.setMarkerVisibility(e,!0);try{this.map.getContainer().style.cursor=""}catch(n){}this.updatePolygonAfterDrag(e),e._polydrawOriginalMarkerPositions&&(e._polydrawOriginalMarkerPositions.clear(),delete e._polydrawOriginalMarkerPositions),e._polydrawOriginalHoleLinePositions&&(e._polydrawOriginalHoleLinePositions.clear(),delete e._polydrawOriginalHoleLinePositions),e._polydrawCurrentDragSession&&delete e._polydrawCurrentDragSession,this.currentDragPolygon=null}),r(this,"onMarkerHoverForEdgeDeletionEvent",t=>{if(!this.isModifierKeyHeld)return;const e=t.target;e&&(e.style.backgroundColor=this.config.colors.edgeDeletion.hover,e.style.borderColor=this.config.colors.edgeDeletion.hover,e.classList.add("edge-deletion-hover"))}),r(this,"onMarkerLeaveForEdgeDeletionEvent",t=>{const e=t.target;e&&(e.style.backgroundColor="",e.style.borderColor="",e.classList.remove("edge-deletion-hover"))}),this.turfHelper=t.turfHelper,this.polygonInformation=t.polygonInformation,this.map=t.map,this.config=t.config,this.modeManager=t.modeManager,this.eventManager=t.eventManager,this.getFeatureGroups=e.getFeatureGroups,this.removeFeatureGroup=e.removeFeatureGroup}addMarkers(t,e){let n=this.getMarkerIndex(t,this.config.markers.markerMenuIcon.position),i=this.getMarkerIndex(t,this.config.markers.markerDeleteIcon.position),r=this.getMarkerIndex(t,this.config.markers.markerInfoIcon.position);const o=this.ensureMarkerSeparation(t.length,{menu:{index:n,enabled:this.config.markers.menuMarker},delete:{index:i,enabled:this.config.markers.deleteMarker},info:{index:r,enabled:this.config.markers.infoMarker}});n=o.menu,i=o.delete,r=o.info,t.forEach((o,a)=>{let l=this.config.markers.markerIcon.styleClasses;a===n&&this.config.markers.menuMarker&&(l=this.config.markers.markerMenuIcon.styleClasses),a===i&&this.config.markers.deleteMarker&&(l=this.config.markers.markerDeleteIcon.styleClasses),a===r&&this.config.markers.infoMarker&&(l=this.config.markers.markerInfoIcon.styleClasses);const u=Array.isArray(l)?l:[l],h=a===n&&this.config.markers.menuMarker||a===i&&this.config.markers.deleteMarker||a===r&&this.config.markers.infoMarker,c=new s.Marker(o,{icon:this.createDivIcon(u),draggable:this.config.modes.dragElbow,title:this.config.markers.coordsTitle?this.getLatLngInfoString(o):"",zIndexOffset:this.config.markers.markerIcon.zIndexOffset??this.config.markers.zIndexOffset});e.addLayer(c).addTo(this.map),this.markerFeatureGroupMap.set(c,e),c.on("add",()=>{const t=c.getElement();t&&(t.style.pointerEvents="auto")}),c.on("click",t=>{var e,n;this.isDraggingMarker&&(null==(n=null==(e=t.originalEvent)?void 0:e.stopPropagation)||n.call(e),s.DomEvent.stopPropagation(t))}),c.on("dragstart",()=>{this.isDraggingMarker=!0,this._activeMarker=c}),c.on("dragend",t=>{const e=this.markerFeatureGroupMap.get(c);this.modeManager.canPerformAction("markerDrag")&&e&&this.markerDragEnd(e),this._activeMarker=null,s.DomEvent.stopPropagation(t),setTimeout(()=>{this.isDraggingMarker=!1},10)});const f=c.getElement();if(f&&(f.addEventListener("touchstart",t=>{t.stopPropagation()},{passive:!0}),f.addEventListener("touchend",t=>{if(t.preventDefault(),t.stopPropagation(),c.fire("click"),this.isDraggingMarker&&!h){const t=this.markerFeatureGroupMap.get(c);this.modeManager.canPerformAction("markerDrag")&&t&&this.markerDragEnd(t)}this._activeMarker=null})),a===n||a===i||a===r){const t=c.getElement();t&&(t.style.zIndex="10000")}if(this.config.modes.dragElbow){const t=t=>()=>{this.modeManager.canPerformAction("markerDrag")&&this.markerDrag(t)};c.on("drag",t(e))}if(a===n&&this.config.markers.menuMarker&&(c.options.zIndexOffset=this.config.markers.markerMenuIcon.zIndexOffset??this.config.markers.zIndexOffset,c.on("click",()=>{const n=this.getPolygonGeoJSONFromFeatureGroup(e),i=yo.getCenterOfMass(n);this.generateMenuMarkerPopup(t,e).setLatLng(i).openOn(this.map)}),c.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),c.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})),a===r&&this.config.markers.infoMarker){const t=this.getPolygonGeoJSONFromFeatureGroup(e),n=this.turfHelper.getPolygonArea(t),i=this.getTotalPolygonPerimeter(t);c.options.zIndexOffset=this.config.markers.markerInfoIcon.zIndexOffset??this.config.markers.zIndexOffset,c.on("click",()=>{const e=this.generateInfoMarkerPopup(n,i),r=yo.getCenterOfMass(t);e.setLatLng(r).openOn(this.map)}),c.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),c.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})}c.on("mousedown",t=>{this.modeManager.isInOffMode()||(s.DomEvent.stopPropagation(t),this.map.fire("mousedown",t)),this._activeMarker=c}),c.on("click",t=>{if(this.modeManager.isInOffMode())if(this.isEdgeDeletionModifierKeyPressed(t.originalEvent)){const n=e.getLayers().find(t=>t instanceof s.Polygon);n&&this.elbowClicked(t,n,c.getLatLng())}else a===i&&this.config.markers.deleteMarker&&(this.map.closePopup(),this.removeFeatureGroup(e),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups()),this.eventManager.emit("polydraw:polygon:deleted",void 0))}),c.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(c,!0)),c.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(c,!1))});const a=this.map.getContainer();a&&(a.style.touchAction="manipulation")}addHoleMarkers(t,e){var n,i,r;const o=(null==(n=this.config.markers.holeMarkers)?void 0:n.menuMarker)??!1,a=(null==(i=this.config.markers.holeMarkers)?void 0:i.deleteMarker)??!1,l=(null==(r=this.config.markers.holeMarkers)?void 0:r.infoMarker)??!1;let u=this.getMarkerIndex(t,this.config.markers.markerMenuIcon.position),h=this.getMarkerIndex(t,this.config.markers.markerDeleteIcon.position),c=this.getMarkerIndex(t,this.config.markers.markerInfoIcon.position);const f=this.ensureMarkerSeparation(t.length,{menu:{index:u,enabled:o},delete:{index:h,enabled:a},info:{index:c,enabled:l}});u=f.menu,h=f.delete,c=f.info,t.forEach((n,i)=>{let r=this.config.markers.holeIcon.styleClasses;i===u&&o&&(r=this.config.markers.markerMenuIcon.styleClasses),i===h&&a&&(r=this.config.markers.markerDeleteIcon.styleClasses),i===c&&l&&(r=this.config.markers.markerInfoIcon.styleClasses);const f=Array.isArray(r)?r:[r],g=i===u&&o||i===h&&a||i===c&&l,d=new s.Marker(n,{icon:this.createDivIcon(f),draggable:this.config.modes.dragElbow,title:this.config.markers.coordsTitle?this.getLatLngInfoString(n):"",zIndexOffset:this.config.markers.holeIcon.zIndexOffset??this.config.markers.zIndexOffset});e.addLayer(d).addTo(this.map),this.markerFeatureGroupMap.set(d,e),d.on("add",()=>{const t=d.getElement();t&&(t.style.pointerEvents="auto")}),d.on("click",t=>{var e,n;this.isDraggingMarker&&(null==(n=null==(e=t.originalEvent)?void 0:e.stopPropagation)||n.call(e),s.DomEvent.stopPropagation(t))}),d.on("dragstart",()=>{this.isDraggingMarker=!0,this._activeMarker=d}),d.on("dragend",t=>{const e=this.markerFeatureGroupMap.get(d);this.modeManager.canPerformAction("markerDrag")&&e&&this.markerDragEnd(e),this._activeMarker=null,s.DomEvent.stopPropagation(t),setTimeout(()=>{this.isDraggingMarker=!1},10)});const p=d.getElement();if(p&&(p.addEventListener("touchstart",t=>{t.stopPropagation()},{passive:!0}),p.addEventListener("touchend",t=>{if(t.preventDefault(),t.stopPropagation(),d.fire("click"),this.isDraggingMarker&&!g){const t=this.markerFeatureGroupMap.get(d);this.modeManager.canPerformAction("markerDrag")&&t&&this.markerDragEnd(t)}this._activeMarker=null})),i===u||i===h||i===c){const t=d.getElement();t&&(t.style.zIndex="10000")}if(this.config.modes.dragElbow){const t=t=>()=>{this.modeManager.canPerformAction("markerDrag")&&this.markerDrag(t)};d.on("drag",t(e))}if(i===u&&o&&(d.options.zIndexOffset=this.config.markers.markerMenuIcon.zIndexOffset??this.config.markers.zIndexOffset,d.on("click",()=>{const n=t.map(t=>[t.lng,t.lat]);n.push(n[0]);const i={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}},r=yo.getCenterOfMass(i);this.generateMenuMarkerPopup(t,e).setLatLng(r).openOn(this.map)}),d.on("popupopen",t=>{const e=t.popup.getElement();if(!e)return;setTimeout(()=>{const t=this.map.getContainer().getBoundingClientRect(),n=e.getBoundingClientRect();n.left<t.left?e.style.transform=`translateX(${t.left-n.left}px)`:n.right>t.right&&(e.style.transform=`translateX(${t.right-n.right}px)`)},0);const n=this.map.getContainer();n&&(n.style.touchAction="manipulation")}),d.on("popupclose",()=>{const t=this.map.getContainer();t&&(t.style.touchAction="")})),i===c&&l){const e=t.map(t=>[t.lng,t.lat]);e.push(e[0]);const i={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[e]}},r=this.turfHelper.getPolygonArea(i),o=1e3*this.turfHelper.getPolygonPerimeter(i);d.options.zIndexOffset=this.config.markers.markerInfoIcon.zIndexOffset??this.config.markers.zIndexOffset,d.on("click",()=>{this.generateInfoMarkerPopup(r,o).setLatLng(n).openOn(this.map)})}d.on("mousedown",t=>{this.modeManager.isInOffMode()||(s.DomEvent.stopPropagation(t),this.map.fire("mousedown",t)),this._activeMarker=d}),d.on("click",t=>{if(this.modeManager.isInOffMode())if(this.isEdgeDeletionModifierKeyPressed(t.originalEvent)){const n=e.getLayers().find(t=>t instanceof s.Polygon);n&&this.elbowClicked(t,n,d.getLatLng())}else if(i===h&&a){this.map.closePopup();const t=e.getLayers().find(t=>t instanceof s.Polygon);if(t){const n=t.getLatLngs();let i=[];if(Array.isArray(n)&&n.length>0)if(Array.isArray(n[0])){const t=n[0];i=Array.isArray(t)&&Array.isArray(t[0])?n[0]:n}else i=[n];const r=d.getLatLng();let o=-1;for(let t=1;t<i.length;t++)if(i[t].some(t=>t.lat===r.lat&&t.lng===r.lng)){o=t;break}if(o>0){const t=i.filter((t,e)=>e!==o).map(t=>{const e=t.map(t=>[t.lng,t.lat]);if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e}),n=this.turfHelper.getMultiPolygon([t]);this.removeFeatureGroup(e),this.eventManager.emit("polydraw:polygon:updated",{operation:"removeHole",polygon:n})}}}}),d.on("mouseover",()=>this.onMarkerHoverForEdgeDeletion(d,!0)),d.on("mouseout",()=>this.onMarkerHoverForEdgeDeletion(d,!1))})}addEdgeClickListeners(t,e){const n=t.getLatLngs();let i;if(Array.isArray(n)&&n.length>0){if(Array.isArray(n[0]))if(Array.isArray(n[0][0])&&n[0][0].length>0){n[0][0][0];i=n[0]}else i=n[0][0]&&"object"==typeof n[0][0]&&"lat"in n[0][0]?n:n[0];else i=(n[0]&&"object"==typeof n[0]&&n[0],[n]);i.forEach((n,i)=>{for(let r=0;r<n.length;r++){const o=n[r],a=n[(r+1)%n.length];if(o.lat===a.lat&&o.lng===a.lng)continue;const l=s.polyline([o,a],{color:"transparent",weight:10,opacity:0,interactive:!0});l._polydrawEdgeInfo={ringIndex:i,edgeIndex:r,startPoint:o,endPoint:a,parentPolygon:t,parentFeatureGroup:e},l.on("click",t=>{this.onEdgeClick(t,l)}),l.on("mouseover",()=>{this.highlightEdgeOnHover(l,!0)}),l.on("mouseout",()=>{this.highlightEdgeOnHover(l,!1)}),e.addLayer(l)}})}}enablePolygonDragging(t,e){this.config.modes.dragPolygons&&(t._polydrawOriginalLatLngs=e,t._polydrawDragData={isDragging:!1,startPosition:null,startLatLngs:null,originalOpacity:t.options.fillOpacity},t.on("mousedown",e=>{if(!this.modeManager.isInOffMode())return s.DomEvent.stopPropagation(e),void this.map.fire("mousedown",e);if(!this.modeManager.canPerformAction("polygonDrag"))return;s.DomEvent.stopPropagation(e.originalEvent),s.DomEvent.preventDefault(e.originalEvent);const n=this.detectDragSubtractModifierKey(e.originalEvent);this.currentModifierDragMode=n,this.isModifierKeyHeld=n,t._polydrawDragData.isDragging=!0,t._polydrawDragData.startPosition=e.latlng,t._polydrawDragData.startLatLngs=t.getLatLngs(),t.setStyle({fillOpacity:this.config.dragPolygons.opacity}),this.map.dragging&&this.map.dragging.disable(),this.setSubtractVisualMode(t,n),this.setMarkerVisibility(t,!1);try{this.map.getContainer().style.cursor=this.config.dragPolygons.dragCursor||"move"}catch(i){}this.map.on("mousemove",this.onPolygonMouseMove,this),this.map.on("mouseup",this.onPolygonMouseUp,this),this.currentDragPolygon=t}),t.on("mouseover",()=>{if(!t._polydrawDragData||!t._polydrawDragData.isDragging)try{this.map.getContainer().style.cursor=this.config.dragPolygons.hoverCursor||"grab"}catch(e){}}),t.on("mouseout",()=>{if(!t._polydrawDragData||!t._polydrawDragData.isDragging)try{this.map.getContainer().style.cursor=""}catch(e){}}))}updateMarkerDraggableState(){const t=this.modeManager.canPerformAction("markerDrag");this.getFeatureGroups().forEach(e=>{e.eachLayer(e=>{if(e instanceof s.Marker){const i=e;try{i.options.draggable=t,i.dragging&&(t?i.dragging.enable():i.dragging.disable())}catch(n){}}})})}updateAllMarkersForEdgeDeletion(t){this.getFeatureGroups().forEach(e=>{e.eachLayer(e=>{e instanceof s.Marker&&this.updateMarkerForEdgeDeletion(e,t)})})}updateMarkerForEdgeDeletion(t,e){const n=t.getElement();n&&(e?(n.addEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.addEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent)):(n.removeEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.removeEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent),n.style.backgroundColor="",n.style.borderColor=""))}setModifierKeyHeld(t){this.isModifierKeyHeld=t}onEdgeClick(t,e){if(!this.config.modes.attachElbow)return;if(!this.modeManager.isInOffMode())return;const n=e._polydrawEdgeInfo;if(!n)return;const i=t.latlng,r=n.parentPolygon,o=n.parentFeatureGroup;if(r&&o)try{if("function"!=typeof r.toGeoJSON)return;const t=r.toGeoJSON();if("MultiPolygon"===t.geometry.type||"Polygon"===t.geometry.type){const e=this.turfHelper.injectPointToPolygon(t,[i.lng,i.lat],n.ringIndex);if(e){const t=r._polydrawOptimizationLevel||0;this.removeFeatureGroup(o),this.eventManager.emit("polydraw:polygon:updated",{operation:"addVertex",polygon:e,optimizationLevel:t})}}}catch(a){}s.DomEvent.stopPropagation(t)}highlightEdgeOnHover(t,e){e?t.setStyle({color:this.config.colors.edgeHover,weight:4,opacity:1}):t.setStyle({color:"transparent",weight:10,opacity:0})}elbowClicked(t,e,n){if(!this.config.modes.edgeDeletion)return;if(!this.isEdgeDeletionModifierKeyPressed(t.originalEvent))return;const i=n??t.latlng,r=e.getLatLngs();let o=[];if(!(Array.isArray(r)&&r.length>0))return;if(Array.isArray(r[0])){const t=r[0];o=Array.isArray(t)&&Array.isArray(t[0])?r[0]:r}else o=[r];let s=-1,a=-1;for(let c=0;c<o.length;c++){const t=o[c];for(let e=0;e<t.length;e++){const n=t[e];if(n.lat===i.lat&&n.lng===i.lng){s=c,a=e;break}}if(-1!==s)break}if(-1===s||-1===a)return;if(o[s].length<=this.config.edgeDeletion.minVertices)return;const l=o.map((t,e)=>{if(e!==s)return t.slice();const n=t.slice();return n.splice(a,1),n}).map(t=>{const e=t.map(t=>[t.lng,t.lat]);if(e.length>0){const t=e[0],n=e[e.length-1];t[0]===n[0]&&t[1]===n[1]||e.push([t[0],t[1]])}return e});let u=null;for(const c of this.getFeatureGroups()){let t=!1;if(c.eachLayer(n=>{n===e&&(t=!0)}),t){u=c;break}}u&&this.removeFeatureGroup(u);const h=this.turfHelper.getMultiPolygon([l]);this.eventManager.emit("polydraw:polygon:updated",{operation:"removeVertex",polygon:h})}markerDrag(t){if(!this._activeMarker)return void(uo()||console.warn("No active marker set for dragging."));const e=[];let n=[],i=[];const r=t.getLayers(),o=r.find(t=>t instanceof s.Polygon);if(!o)return void(uo()||console.warn("No polygon found in feature group for marker drag."));const a=o.getLatLngs();let l=0;const u=r.filter(t=>t instanceof s.Marker);if(a.length>1)for(let s=0;s<a.length;s++)if(n=[],i=[],0===s){if(a[0].length>1)for(let t=0;t<a[0].length;t++){for(let e=0;e<a[0][t].length;e++)u[e]&&n.push(u[e].getLatLng());i.push(n)}else{for(let t=0;t<a[0][0].length;t++)u[t]&&n.push(u[t].getLatLng());i.push(n)}e.push(i)}else{l+=a[s-1].length;for(let t=l;t<a[s][0].length+l;t++)u[t]&&n.push(u[t].getLatLng());i.push(n),e.push(i)}else{i=[];let t=0;for(let e=0;e<a[0].length;e++){if(n=[],0===e)if(a[0][e].length>1)for(let t=0;t<a[0][e].length;t++)u[t]&&n.push(u[t].getLatLng());else for(let t=0;t<a[0][0].length;t++)u[t]&&n.push(u[t].getLatLng());else{t+=a[0][e-1].length;for(let i=t;i<a[0][e].length+t;i++)u[i]&&n.push(u[i].getLatLng())}i.push(n)}e.push(i)}o.setLatLngs(e)}async markerDragEnd(t){this.polygonInformation.deletePolygonInformationStorage();const e=t.toGeoJSON();if(e.features&&0!==e.features.length){if(this.removeFeatureGroup(t),"MultiPolygon"===e.features[0].geometry.type)for(const t of e.features[0].geometry.coordinates){const e=this.turfHelper.getMultiPolygon([t]);if(this.turfHelper.hasKinks(e)){const t=this.turfHelper.getKinks(e);for(const e of t)this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:this.turfHelper.getTurfPolygon(e),allowMerge:!0,intelligentMerge:!0})}else this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:e,allowMerge:!0,intelligentMerge:!0})}else{const t=this.turfHelper.getMultiPolygon([e.features[0].geometry.coordinates]);if(this.turfHelper.hasKinks(t)){const e=this.turfHelper.getKinks(t);for(const t of e)this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:this.turfHelper.getTurfPolygon(t),allowMerge:!1})}else this.eventManager.emit("polydraw:polygon:updated",{operation:"markerDrag",polygon:t,allowMerge:!1})}this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}}offsetPolygonCoordinates(t,e,n){return t?Array.isArray(t[0])?t.map(t=>this.offsetPolygonCoordinates(t,e,n)):t.map(t=>s.latLng(t.lat+e,t.lng+n)):t}updateMarkersAndHoleLinesDuringDrag(t,e,n){try{let i=null;for(const e of this.getFeatureGroups()){let n=!1;if(e.eachLayer(e=>{e===t&&(n=!0)}),n){i=e;break}}if(!i)return;const r="_polydrawDragSession_"+Date.now()+"_"+s.Util.stamp(t);t._polydrawCurrentDragSession||(t._polydrawCurrentDragSession=r,t._polydrawOriginalMarkerPositions=new Map,t._polydrawOriginalHoleLinePositions=new Map,i.eachLayer(e=>{if(e instanceof s.Marker)t._polydrawOriginalMarkerPositions.set(e,e.getLatLng());else if(e instanceof s.Polyline&&!(e instanceof s.Polygon)){const n=e.getLatLngs();t._polydrawOriginalHoleLinePositions.set(e,n)}})),i.eachLayer(i=>{if(i instanceof s.Marker){const r=t._polydrawOriginalMarkerPositions.get(i);if(r){const t={lat:r.lat+e,lng:r.lng+n};i.setLatLng(t)}}else if(i instanceof s.Polyline&&!(i instanceof s.Polygon)){const r=t._polydrawOriginalHoleLinePositions.get(i);if(r){let t;t=Array.isArray(r[0])?r.map(t=>t.map(t=>s.latLng(t.lat+e,t.lng+n))):r.map(t=>s.latLng(t.lat+e,t.lng+n)),i.setLatLngs(t)}}})}catch(i){console.warn("Error updating markers during drag:",i)}}async updatePolygonAfterDrag(t){try{let e=null;for(const r of this.getFeatureGroups())if(r.eachLayer(n=>{n===t&&(e=r)}),e)break;if(!e)return;const n=t.toGeoJSON();if(this.isModifierDragActive())return this.performModifierSubtract(n,e),this.currentModifierDragMode=!1,void(this.isModifierKeyHeld=!1);this.removeFeatureGroup(e);const i=this.turfHelper.getTurfPolygon(n);this.eventManager.emit("polydraw:polygon:updated",{operation:"polygonDrag",polygon:i,allowMerge:!0}),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}catch(e){}}getDragSubtractModifierKey(){const{keys:t}=this.config.dragPolygons.modifierSubtract,e=navigator.userAgent.toLowerCase(),n=e.includes("mac"),i=e.includes("windows");return n&&t.mac?t.mac:i&&t.windows?t.windows:t.linux?t.linux:n?"metaKey":"ctrlKey"}detectDragSubtractModifierKey(t){if(lo())return!1;return t[this.getDragSubtractModifierKey()]||!1}setSubtractVisualMode(t,e){if(t&&t.setStyle)try{e?t.setStyle({color:this.config.colors.dragPolygons.subtract}):t.setStyle({color:this.config.colors.polygon.border}),this.updateMarkerColorsForSubtractMode(t,e)}catch(n){}}updateMarkerColorsForSubtractMode(t,e){try{let n=null;for(const e of this.getFeatureGroups())if(e.eachLayer(i=>{i===t&&(n=e)}),n)break;if(!n)return;const i=n,r=this.config.dragPolygons.modifierSubtract.hideMarkersOnDrag;i.eachLayer(t=>{if(t instanceof s.Marker){const n=t.getElement();n&&(e?r?(n.style.display="none",n.classList.add("subtract-mode-hidden")):(n.style.backgroundColor=this.config.colors.dragPolygons.subtract,n.style.borderColor=this.config.colors.dragPolygons.subtract,n.classList.add("subtract-mode")):r?(n.style.display="",n.classList.remove("subtract-mode-hidden")):(n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("subtract-mode")))}})}catch(n){}}handleModifierToggleDuringDrag(t){const e=this.detectDragSubtractModifierKey(t);this.currentModifierDragMode=e,this.isModifierKeyHeld=e,this.currentDragPolygon&&this.setSubtractVisualMode(this.currentDragPolygon,e)}isModifierDragActive(){return this.currentModifierDragMode}performModifierSubtract(t,e){try{const n=this.turfHelper.getTurfPolygon(t),i=[];this.getFeatureGroups().forEach(t=>{if(t!==e)try{const e=t.toGeoJSON();if(!e||!e.features||!e.features[0])return;const s=e.features[0];if(!s.geometry||!s.geometry.coordinates)return;const a=this.turfHelper.getTurfPolygon(s);try{const e=this.turfHelper.getIntersection(a,n);if(e&&e.geometry&&"coordinates"in e.geometry){e.geometry.coordinates.length>0&&i.push(t)}}catch(r){try{this.turfHelper.polygonIntersect(a,n)&&i.push(t)}catch(o){}}}catch(s){}}),this.removeFeatureGroup(e),i.forEach(t=>{try{const i=t.toGeoJSON(),r=this.turfHelper.getTurfPolygon(i.features[0]);this.removeFeatureGroup(t);try{const t=this.turfHelper.polygonDifference(r,n);if(t&&t.geometry){const e=this.turfHelper.getCoords(t);for(const t of e){const e=this.turfHelper.getMultiPolygon([t]);this.eventManager.emit("polydraw:polygon:updated",{operation:"modifierSubtract",polygon:this.turfHelper.getTurfPolygon(e),allowMerge:!1})}}}catch(e){uo()||console.warn("Failed to perform difference operation:",e),this.eventManager.emit("polydraw:polygon:updated",{operation:"modifierSubtractFallback",polygon:r,allowMerge:!1})}}catch(i){uo()||console.warn("Error in modifier subtract operation:",i)}}),this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups())}catch(n){uo()||console.warn("Error in performModifierSubtract:",n)}}getEdgeDeletionModifierKey(){const{keys:t}=this.config.edgeDeletion,e=navigator.userAgent.toLowerCase(),n=e.includes("mac"),i=e.includes("windows");return n&&t.mac?t.mac:i&&t.windows?t.windows:t.linux?t.linux:n?"metaKey":"ctrlKey"}isEdgeDeletionModifierKeyPressed(t){if(lo())return!1;return!!t[this.getEdgeDeletionModifierKey()]}onMarkerHoverForEdgeDeletion(t,e){const n=t.getElement();if(n)if(e){const e=t=>{if(this.isEdgeDeletionModifierKeyPressed(t)){n.style.backgroundColor=this.config.colors.edgeDeletion.hover,n.style.borderColor=this.config.colors.edgeDeletion.hover,n.classList.add("edge-deletion-hover");try{this.map.getContainer().style.cursor="pointer"}catch(e){}}else{n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(e){}}};e(new MouseEvent("mouseover")),this.markerModifierHandlers.set(t,e),document.addEventListener("keydown",e),document.addEventListener("keyup",e),n.addEventListener("mousemove",e)}else{n.style.backgroundColor="",n.style.borderColor="",n.classList.remove("edge-deletion-hover");try{this.map.getContainer().style.cursor=""}catch(i){}const e=this.markerModifierHandlers.get(t);e&&(document.removeEventListener("keydown",e),document.removeEventListener("keyup",e),n.removeEventListener("mousemove",e),this.markerModifierHandlers.delete(t))}}getMarkerIndex(t,e){const n=ho.getBounds(t,Math.sqrt(2)/2),i=new co(n.getSouth(),n.getWest(),n.getNorth(),n.getEast()).getDirection(e),r={lat:i.lat,lng:i.lng},o=this.turfHelper.getCoord(r),s=this.turfHelper.getFeaturePointCollection(t);return this.turfHelper.getNearestPointIndex(o,s)}ensureMarkerSeparation(t,e){const n=[];if(e.menu.enabled&&n.push({type:"menu",index:e.menu.index}),e.delete.enabled&&n.push({type:"delete",index:e.delete.index}),e.info.enabled&&n.push({type:"info",index:e.info.index}),n.length<2)return{menu:e.menu.index,delete:e.delete.index,info:e.info.index};const i={...e},r=new Set,o=["info","delete","menu"];for(const s of o){const e=i[s];if(e.enabled)if(r.has(e.index)){const n=this.findAlternativeMarkerPosition(t,e.index,r);i[s].index=n,r.add(n)}else r.add(e.index)}return{menu:i.menu.index,delete:i.delete.index,info:i.info.index}}findAlternativeMarkerPosition(t,e,n){const i=t,r=Math.max(1,Math.floor(t/8));for(let o=1;o<i;o++){const i=[(e+o*r)%t,(e-o*r+t)%t];for(const t of i)if(!n.has(t))return t}for(let o=0;o<t;o++)if(!n.has(o))return o;return e}createDivIcon(t){return Io.createDivIcon(t)}getLatLngInfoString(t){return"Latitude: "+t.lat+" Longitude: "+t.lng}setMarkerVisibility(t,e){const n=this.getFeatureGroups().find(e=>e.hasLayer(t));n&&n.eachLayer(t=>{if(t instanceof s.Marker){const n=t.getElement();if(n){const t=this.config.dragPolygons.markerBehavior,i=this.config.dragPolygons.markerAnimationDuration;"hide"===t?n.style.display=e?"":"none":"fade"===t&&(n.style.transition=`opacity ${i}ms ease`,n.style.opacity=e?"1":"0")}}})}generateMenuMarkerPopup(t,e){const n=document.createElement("div");n.classList.add("alter-marker-outer-wrapper");const i=document.createElement("div");i.classList.add("alter-marker-wrapper");const r=document.createElement("div");r.classList.add("content");const o=document.createElement("div");o.classList.add("marker-menu-content");const a=document.createElement("div");a.classList.add("marker-menu-button","simplify"),a.title="Simplify";const l=document.createElement("div");l.classList.add("marker-menu-button","double-elbows"),l.title="DoubleElbows";const u=document.createElement("div");u.classList.add("marker-menu-button","bbox"),u.title="Bounding box";const h=document.createElement("div");h.classList.add("marker-menu-button","bezier"),h.title="Curve";const c=document.createElement("span");c.classList.add("alpha-banner"),c.textContent="ALPHA",h.appendChild(c);const f=document.createElement("div");f.classList.add("separator"),n.appendChild(i),i.appendChild(r),r.appendChild(o),o.appendChild(a),o.appendChild(f.cloneNode()),o.appendChild(l),o.appendChild(f.cloneNode()),o.appendChild(u),o.appendChild(f.cloneNode()),o.appendChild(h);const g=()=>{this._openMenuPopup&&(this.map.closePopup(this._openMenuPopup),this._openMenuPopup=null)};a.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"simplify",latLngs:t,featureGroup:e}),g()}),a.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"simplify",latLngs:t,featureGroup:e}),g()},u.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"bbox",latLngs:t,featureGroup:e}),g()}),u.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"bbox",latLngs:t,featureGroup:e}),g()},l.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"doubleElbows",latLngs:t,featureGroup:e}),g()}),l.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"doubleElbows",latLngs:t,featureGroup:e}),g()},h.addEventListener("touchend",n=>{n.preventDefault(),n.stopPropagation(),this.eventManager.emit("polydraw:menu:action",{action:"bezier",latLngs:t,featureGroup:e}),g()}),h.onclick=()=>{this.eventManager.emit("polydraw:menu:action",{action:"bezier",latLngs:t,featureGroup:e}),g()},s.DomEvent.disableClickPropagation(n),n.style.pointerEvents="auto",n.querySelectorAll(".marker-menu-button").forEach(t=>{t.style.pointerEvents="auto",t.addEventListener("click",t=>t.stopPropagation())});const d=window.innerWidth<=600,p=s.popup({closeButton:!0,autoClose:!0,className:"menu-popup"+(d?" mobile-popup":"")}).setContent(n);return this._openMenuPopup=p,p}getPolygonGeoJSONFromFeatureGroup(t){try{const e=t.getLayers().find(t=>t instanceof s.Polygon);if(!e)throw new Error("No polygon found in feature group");return e.toGeoJSON()}catch(e){return uo()||(e instanceof Error?console.warn("Error getting polygon GeoJSON from feature group:",e.message):console.warn("Error getting polygon GeoJSON from feature group:",e)),{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}}getTotalPolygonPerimeter(t){try{if(!t||!t.geometry)return 0;let e=0;if("Polygon"===t.geometry.type){const n=t.geometry.coordinates;for(const t of n){const n={type:"Feature",geometry:{type:"Polygon",coordinates:[t]},properties:{}};e+=this.turfHelper.getPolygonPerimeter(n)}}else if("MultiPolygon"===t.geometry.type){const n=t.geometry.coordinates;for(const t of n)for(const n of t){const t={type:"Feature",geometry:{type:"Polygon",coordinates:[n]},properties:{}};e+=this.turfHelper.getPolygonPerimeter(t)}}return 1e3*e}catch(e){return uo()||(e instanceof Error?console.warn("Error calculating total polygon perimeter:",e.message):console.warn("Error calculating total polygon perimeter:",e)),1e3*this.turfHelper.getPolygonPerimeter(t)}}generateInfoMarkerPopup(t,e){const n=new fo(e,this.config),i=new go(t,this.config),r=document.createElement("div");r.classList.add("info-marker-outer-wrapper");const o=document.createElement("div");o.classList.add("info-marker-wrapper");const a=document.createElement("div");a.classList.add("content");const l=document.createElement("div");l.classList.add("info-marker-content");const u=document.createElement("div");u.classList.add("info-item","area"),u.innerHTML=`<strong>Area:</strong> ${i.metricArea} ${i.metricUnit}`;const h=document.createElement("div");h.classList.add("info-item","perimeter"),h.innerHTML=`<strong>Perimeter:</strong> ${n.metricLength} ${n.metricUnit}`,l.appendChild(u),l.appendChild(h),a.appendChild(l),r.appendChild(o),o.appendChild(a),s.DomEvent.disableClickPropagation(r),r.style.pointerEvents="auto",r.querySelectorAll("button").forEach(t=>{t.style.pointerEvents="auto",t.addEventListener("click",t=>t.stopPropagation())});const c=window.innerWidth<=600;return s.popup({closeButton:!0,autoClose:!0,className:"info-popup"+(c?" mobile-popup":"")}).setContent(r)}}class So{constructor(t){r(this,"turfHelper"),r(this,"map"),r(this,"config"),r(this,"eventManager"),r(this,"getFeatureGroups"),r(this,"geometryManager"),r(this,"interactionManager"),this.turfHelper=t.turfHelper,this.map=t.map,this.config=t.config,this.eventManager=t.eventManager,this.getFeatureGroups=t.getFeatureGroups,this.initializeSpecializedManagers(t)}initializeSpecializedManagers(t){this.geometryManager=new wo({turfHelper:t.turfHelper,config:t.config}),this.interactionManager=new Mo({turfHelper:t.turfHelper,polygonInformation:t.polygonInformation,map:t.map,config:t.config,modeManager:t.modeManager,eventManager:this.eventManager},{getFeatureGroups:this.getFeatureGroups,addFeatureGroup:t=>this.addFeatureGroupInternal(t),removeFeatureGroup:t=>this.removeFeatureGroupInternal(t)}),this.setupEventForwarding()}setupEventForwarding(){this.eventManager.on("polydraw:draw:cancel",t=>{this.emit("drawCancelled",t)}),this.eventManager.on("polydraw:polygon:updated",t=>{this.handlePolygonModified(t)}),this.eventManager.on("polydraw:menu:action",t=>{this.handleMenuAction(t)}),this.eventManager.on("polydraw:check:intersection",t=>{const e=this.geometryManager.checkPolygonIntersection(t.polygon1,t.polygon2);t.callback(e)}),this.eventManager.on("polydraw:subtract",t=>{this.subtractPolygon(t.subtractPolygon)}),this.eventManager.on("polydraw:polygon:deleted",()=>{this.emit("polygonDeleted",void 0)})}async handlePolygonModified(t){const e="addVertex"!==t.operation&&"markerDrag"!==t.operation&&"polygonDrag"!==t.operation;let n=t.allowMerge;t.intelligentMerge&&"markerDrag"===t.operation&&(n=this.shouldAllowIntelligentMerge(t.polygon));const i={simplify:e,noMerge:!n,visualOptimizationLevel:t.optimizationLevel||0};await this.addPolygon(t.polygon,i)}async handleMenuAction(t){const e=this.getCompletePolygonFromFeatureGroup(t.featureGroup);let n;switch(this.removeFeatureGroupInternal(t.featureGroup),t.action){case"simplify":n=this.geometryManager.simplifyPolygon(e);break;case"bbox":n=this.geometryManager.convertToBoundingBox(e);break;case"doubleElbows":n=this.geometryManager.doubleElbowsPolygon(e);break;case"bezier":n=this.geometryManager.bezierifyPolygon(e);break;default:return}n.success&&n.result&&await this.addPolygon(n.result,{simplify:!1})}get polygonInteractionManager(){return this.interactionManager}on(t,e){this.eventManager.on(t,e)}emit(t,e){this.eventManager.emit(t,e)}async addPolygon(t,e={}){const{noMerge:n=!1}=e;try{return this.isPolygonInsideExistingHole(t)?await this.addPolygonLayer(t,e):this.config.mergePolygons&&!n&&this.getFeatureGroups().length>0&&!this.config.kinks?await this.mergePolygon(t,e):await this.addPolygonLayer(t,e)}catch(i){return{success:!1,error:i instanceof Error?i.message:"Unknown error in addPolygon"}}}async subtractPolygon(t){try{const n=[];this.getFeatureGroups().forEach(e=>{try{const i=e.toGeoJSON();if(!i||!i.features||!i.features[0])return;const r=i.features[0];if(!r.geometry||!r.geometry.coordinates)return;const o=this.turfHelper.getTurfPolygon(r);this.geometryManager.checkPolygonIntersection(o,t)&&n.push(e)}catch(i){}});const i=[];for(const r of n)try{const e=r.toGeoJSON(),n=this.turfHelper.getTurfPolygon(e.features[0]),o=this.geometryManager.subtractPolygon(n,t);if(this.removeFeatureGroupInternal(r),o.success&&o.results)for(const t of o.results){const e=await this.addPolygonLayer(t,{simplify:!0});e.success&&e.featureGroups&&i.push(...e.featureGroups)}}catch(e){}return this.emit("polygonSubtracted",{subtractedPolygon:t,affectedFeatureGroups:n,resultFeatureGroups:i}),this.emit("polygonOperationComplete",{operation:"subtract",polygon:t,resultFeatureGroups:i}),{success:!0,featureGroups:i}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error in subtractPolygon"}}}async addPolygonLayer(t,e={}){const{simplify:n=!0,dynamicTolerance:i=!1,visualOptimizationLevel:r=0}=e;try{if(!t||!t.geometry||!t.geometry.coordinates)return{success:!1,error:"Invalid polygon data"};const e=new s.FeatureGroup,a=n?this.turfHelper.getSimplified(t,i):t;let l,u;try{if(l=this.getPolygon(a),!l)return{success:!1,error:"Failed to create polygon"};l._polydrawOptimizationLevel=r,e.addLayer(l)}catch(o){return{success:!1,error:"Failed to create polygon layer"}}try{const t=l.getLatLngs();u=this.normalizePolygonCoordinates(t)}catch(o){u=[]}try{u.forEach((t,n)=>{if(!t||!Array.isArray(t))return;const i=[];if(t.forEach(t=>{Array.isArray(t)&&t.length>=2?i.push({lat:t[1],lng:t[0]}):"object"==typeof t&&null!==t&&"lat"in t&&"lng"in t&&i.push(t)}),0!==i.length)try{if(0===n)this.interactionManager.addMarkers(i,e);else{const t=s.polyline(i,{color:this.config.colors.hole.border,weight:this.config.holeOptions.weight||2,opacity:this.config.holeOptions.opacity||1,fillColor:this.config.colors.hole.fill,fillOpacity:this.config.holeOptions.fillOpacity||.5});e.addLayer(t),this.interactionManager.addHoleMarkers(i,e)}}catch(r){}})}catch(o){}try{this.interactionManager.addEdgeClickListeners(l,e)}catch(o){}this.getFeatureGroups().push(e);try{e.addTo(this.map)}catch(o){}return this.emit("polygonAdded",{polygon:a,featureGroup:e}),this.emit("polygonOperationComplete",{operation:"add",polygon:a,featureGroup:e}),{success:!0,featureGroups:[e]}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error in addPolygonLayer"}}}async mergePolygon(t,e={}){try{const n=[],i=[];let r=!1;return this.getFeatureGroups().forEach(e=>{try{const s=e.toGeoJSON();if(!s||!s.features||!s.features[0])return;const a=s.features[0];if(!a.geometry||!a.geometry.coordinates)return;if(this.isPositionArrayofArrays(a.geometry.coordinates))a.geometry.coordinates.forEach(o=>{try{const s=this.turfHelper.getMultiPolygon([o]);r=this.geometryManager.checkPolygonIntersection(s,t),r&&(i.push(e),n.push(s))}catch(s){}});else try{const o=this.turfHelper.getTurfPolygon(a);r=this.geometryManager.checkPolygonIntersection(o,t),r&&(i.push(e),n.push(o))}catch(o){}}catch(o){}}),i.length>0?await this.unionPolygons(i,t,n,e):await this.addPolygonLayer(t,e)}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error in mergePolygon"}}}async unionPolygons(t,e,n,i={}){try{t.forEach(t=>{this.removeFeatureGroupInternal(t)});const r=this.geometryManager.unionPolygons(n,e);if(r.success&&r.result){const t=await this.addPolygonLayer(r.result,i);return this.emit("polygonsUnioned",{originalPolygons:n,resultPolygon:r.result,featureGroups:t.featureGroups}),t}return{success:!1,error:r.error||"Failed to union polygons"}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Unknown error in unionPolygons"}}}shouldAllowIntelligentMerge(t){try{for(const n of this.getFeatureGroups())try{const e=n.toGeoJSON();if(!e||!e.features||!e.features[0])continue;const i=e.features[0];if(!i.geometry||!i.geometry.coordinates)continue;const r=this.turfHelper.getTurfPolygon(i);if(this.geometryManager.checkPolygonIntersection(r,t))return!0}catch(e){continue}return!1}catch(e){return!1}}isPolygonInsideExistingHole(t){try{for(const n of this.getFeatureGroups())try{const i=n.toGeoJSON();if(!i||!i.features||!i.features[0])continue;const r=i.features[0];if(!r.geometry||!r.geometry.coordinates)continue;let o=!1,s=[];if("Polygon"===r.geometry.type)o=r.geometry.coordinates.length>1,o&&(s=r.geometry.coordinates.slice(1));else if("MultiPolygon"===r.geometry.type)for(const t of r.geometry.coordinates)t.length>1&&(o=!0,s.push(...t.slice(1)));if(o&&s.length>0)for(const n of s)try{const e=this.turfHelper.createPolygon([n]);if(this.turfHelper.isPolygonCompletelyWithin(t,e))return!0}catch(e){continue}}catch(e){continue}return!1}catch(e){return!1}}normalizePolygonCoordinates(t){if(!Array.isArray(t)||0===t.length)return[];const e=t=>null!==t&&"object"==typeof t&&"lat"in t&&"lng"in t&&"number"==typeof t.lat&&"number"==typeof t.lng,n=t=>{if(!Array.isArray(t))return[];if(t.length>0&&e(t[0]))return[t];const i=[];for(const r of t)if(Array.isArray(r))if(r.length>0&&e(r[0]))i.push(r);else{const t=n(r);i.push(...t)}return i};try{return n(t)}catch(i){return[]}}isPositionArrayofArrays(t){if(!Array.isArray(t)||0===t.length)return!1;const e=t[0];if(!Array.isArray(e)||0===e.length)return!1;const n=e[0];if(!Array.isArray(n)||0===n.length)return!1;const i=n[0];return this.isPosition(i)}isPosition(t){return Array.isArray(t)&&t.length>=2&&t.every(t=>"number"==typeof t)}getPolygon(t){const e=s.GeoJSON.geometryToLayer(t),n={...this.config.polygonOptions,color:this.config.colors.polygon.border,fillColor:this.config.colors.polygon.fill,weight:this.config.polygonOptions.weight||2,opacity:this.config.polygonOptions.opacity||1,fillOpacity:this.config.polygonOptions.fillOpacity||.2};return e.setStyle(n),e._polydrawUniqueId=s.Util.stamp(e)+"_"+Date.now(),delete e._polydrawDragData,delete e._polydrawOriginalLatLngs,delete e._polydrawCurrentDragSession,delete e._polydrawOriginalMarkerPositions,delete e._polydrawOriginalHoleLinePositions,this.config.modes.dragPolygons&&this.interactionManager.enablePolygonDragging(e,t),e}addFeatureGroupInternal(t){this.getFeatureGroups().push(t)}removeFeatureGroupInternal(t){t.clearLayers();const e=this.getFeatureGroups(),n=e.indexOf(t);n>-1&&e.splice(n,1),this.map.removeLayer(t)}getCompletePolygonFromFeatureGroup(t){try{let e=null;if(t.eachLayer(t=>{t instanceof s.Polygon&&(e=t)}),!e)throw new Error("No polygon found in feature group");return e.toGeoJSON()}catch(e){return uo()||e instanceof Error&&console.warn("Error getting complete polygon GeoJSON from feature group:",e.message),{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}}updateMarkerDraggableState(){this.interactionManager.updateMarkerDraggableState()}updateAllMarkersForEdgeDeletion(t){this.interactionManager.updateAllMarkersForEdgeDeletion(t)}setModifierKeyHeld(t){this.interactionManager.setModifierKeyHeld(t)}checkPolygonIntersection(t,e){return this.geometryManager.checkPolygonIntersection(t,e)}getPolygonCenter(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return null;let e;if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{if("MultiPolygon"!==t.geometry.type)return null;e=t.geometry.coordinates[0][0]}if(!Array.isArray(e)||0===e.length)return null;let n=0,i=0,r=0;for(const t of e)if(Array.isArray(t)&&t.length>=2){const e=t[0],o=t[1];"number"!=typeof e||"number"!=typeof o||isNaN(e)||isNaN(o)||(i+=e,n+=o,r++)}return 0===r?null:{lat:n/r,lng:i/r}}catch(e){return null}}getBoundingBox(t){try{if(!t||!t.geometry||!t.geometry.coordinates)return null;let e;if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else{if("MultiPolygon"!==t.geometry.type)return null;e=t.geometry.coordinates[0][0]}if(!Array.isArray(e)||0===e.length)return null;let n=1/0,i=-1/0,r=1/0,o=-1/0;for(const t of e)if(Array.isArray(t)&&t.length>=2){const e=t[0],s=t[1];"number"!=typeof e||"number"!=typeof s||isNaN(e)||isNaN(s)||(r=Math.min(r,e),o=Math.max(o,e),n=Math.min(n,s),i=Math.max(i,s))}return n===1/0||i===-1/0||r===1/0||o===-1/0?null:{minLat:n,maxLat:i,minLng:r,maxLng:o}}catch(e){return null}}addMarker(t,e){this.interactionManager.addMarkers(t,e)}addHoleMarker(t,e){this.interactionManager.addHoleMarkers(t,e)}addEdgeClickListeners(t,e){this.interactionManager.addEdgeClickListeners(t,e)}enablePolygonDragging(t,e){this.interactionManager.enablePolygonDragging(t,e)}getMarkerIndex(t,e){return 0}ensureMarkerSeparation(t,e){var n,i,r;return{menu:(null==(n=e.menu)?void 0:n.index)??0,delete:(null==(i=e.delete)?void 0:i.index)??1,info:(null==(r=e.info)?void 0:r.index)??2}}findAlternativeMarkerPosition(t,e,n){return(e+1)%t}createDivIcon(t){return s.divIcon({className:t.join(" ")})}getLatLngInfoString(t){return"Latitude: "+t.lat+" Longitude: "+t.lng}generateMenuMarkerPopup(t,e){const n=document.createElement("div");return n.innerHTML="Menu",n}getPolygonGeoJSONFromFeatureGroup(t){return{type:"Feature",geometry:{type:"Polygon",coordinates:[[[0,0],[0,1],[1,1],[1,0],[0,0]]]},properties:{}}}getTotalPolygonPerimeter(t){return 1e3}generateInfoMarkerPopup(t,e){const n=document.createElement("div");return n.innerHTML=`Area: ${t}, Perimeter: ${e}`,n}onMarkerHoverForEdgeDeletion(t,e){}highlightEdgeOnHover(t,e){}onEdgeClick(t,e){}removeFeatureGroup(t){this.removeFeatureGroupInternal(t)}onPolygonMouseMove(t){}onPolygonMouseUp(t){}updatePolygonAfterDrag(t){}setSubtractVisualMode(t,e){}performModifierSubtract(t,e){try{const n=this.turfHelper.getTurfPolygon(t),i=[];this.getFeatureGroups().forEach(t=>{if(t!==e)try{const e=t.toGeoJSON();if(!e||!e.features||!e.features[0])return;const r=e.features[0];if(!r.geometry||!r.geometry.coordinates)return;const o=this.turfHelper.getTurfPolygon(r);this.geometryManager.checkPolygonIntersection(o,n)&&i.push(t)}catch(r){}}),this.removeFeatureGroupInternal(e),i.forEach(t=>{try{const e=t.toGeoJSON(),i=this.turfHelper.getTurfPolygon(e.features[0]);this.removeFeatureGroupInternal(t);const r=this.geometryManager.subtractPolygon(i,n);if(r.success&&r.results)for(const t of r.results)this.addPolygonLayer(t,{simplify:!0})}catch(e){}})}catch(n){}}}class bo extends s.Control{constructor(t){super(t),r(this,"map"),r(this,"tracer"),r(this,"turfHelper"),r(this,"subContainer"),r(this,"config"),r(this,"mapStateService"),r(this,"eventManager"),r(this,"polygonInformation"),r(this,"modeManager"),r(this,"polygonDrawManager"),r(this,"polygonMutationManager"),r(this,"arrayOfFeatureGroups",[]),r(this,"drawMode",l.Off),r(this,"drawModeListeners",[]),r(this,"_boundKeyDownHandler"),r(this,"_boundKeyUpHandler"),r(this,"isModifierKeyHeld",!1),r(this,"_boundTouchMove"),r(this,"_boundTouchEnd"),r(this,"_boundTouchStart"),r(this,"_handleActivateToggle",()=>{const t=this.getContainer();if(!t)return;const e=t.querySelector(".icon-activate");s.DomUtil.hasClass(e,"active")?(s.DomUtil.removeClass(e,"active"),this.subContainer&&(this.subContainer.style.maxHeight="0px")):(s.DomUtil.addClass(e,"active"),this.subContainer&&(this.subContainer.style.maxHeight="250px")),this.updateActivateButtonIndicator()}),r(this,"_handleDrawClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.Add?(this.setDrawMode(l.Add),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"_handleSubtractClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.Subtract?(this.setDrawMode(l.Subtract),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"_handleEraseClick",t=>{this.map.closePopup(),t&&(t.preventDefault(),t.stopPropagation()),0!==this.arrayOfFeatureGroups.length&&this.removeAllFeatureGroups()}),r(this,"_handlePointToPointClick",t=>{t&&(t.preventDefault(),t.stopPropagation()),this.modeManager.getCurrentMode()!==l.PointToPoint?(this.setDrawMode(l.PointToPoint),this.polygonInformation.saveCurrentState()):this.setDrawMode(l.Off)}),r(this,"onMarkerHoverForEdgeDeletionEvent",t=>{if(!this.isModifierKeyHeld)return;const e=t.target;e&&(e.style.backgroundColor=this.config.colors.edgeDeletion.hover,e.style.borderColor=this.config.colors.edgeDeletion.hover,e.classList.add("edge-deletion-hover"))}),r(this,"onMarkerLeaveForEdgeDeletionEvent",t=>{const e=t.target;e&&(e.style.backgroundColor="",e.style.borderColor="",e.classList.remove("edge-deletion-hover"))}),this.config=a,(null==t?void 0:t.configPath)?this.loadExternalConfig(t.configPath,null==t?void 0:t.config):(this.config={...a,...(null==t?void 0:t.config)||{}},this.initializeComponents())}onAdd(t){const e=t,n=s.Browser;e._onResize=()=>{},n.touch&&n.mobile&&(e.tap=!1),this.map=t,this.setupKeyboardHandlers();const i=s.DomUtil.create("div","leaflet-control leaflet-bar");return this.initializeUI(i),this.createTracer(),this.initializeManagers(),this.setupEventListeners(),i}onRemove(t){this.removeKeyboardHandlers(),this.tracer&&this.map.removeLayer(this.tracer),this.removeAllFeatureGroups()}addTo(t){return super.addTo(t),this}getFeatureGroups(){return this.arrayOfFeatureGroups}async addPredefinedPolygon(t,e){if(!t||0===t.length)throw new Error("Cannot add empty polygon array");if(!this.map)throw new Error("Map not initialized");if(!this.polygonMutationManager)throw new Error("PolygonMutationManager not initialized");const n=(null==e?void 0:e.visualOptimizationLevel)??0;for(const[r,o]of t.entries()){if(!o||!o[0]||o[0].length<4)throw new Error(`Invalid polygon data at index ${r}: A polygon must have at least 3 unique vertices.`);try{const t=o.map(t=>t.map(t=>[t.lng,t.lat])),e=this.turfHelper.getMultiPolygon([t]),i=await this.polygonMutationManager.addPolygon(e,{simplify:!1,noMerge:!1,visualOptimizationLevel:n});if(!i.success)throw console.error("Error adding polygon via manager:",i.error),new Error(i.error||"Failed to add polygon");this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}catch(i){throw console.error("Error adding auto polygon:",i),i}}}setDrawMode(t){const e=this.drawMode;this._updateDrawModeState(t),e===l.PointToPoint&&t!==l.PointToPoint?(this.polygonDrawManager.clearP2pMarkers(),this.stopDraw()):(t===l.Off||t!==l.PointToPoint)&&this.stopDraw(),this.map&&(this._updateUIAfterDrawModeChange(t),this._updateMapInteractions())}getDrawMode(){return this.modeManager.getCurrentMode()}on(t,e){this.eventManager.on(t,e)}off(t,e){this.eventManager.off(t,e)}removeAllFeatureGroups(){this.arrayOfFeatureGroups.forEach(t=>{try{this.map.removeLayer(t)}catch(e){}}),this.arrayOfFeatureGroups.length=0,this.polygonInformation.deletePolygonInformationStorage(),this.polygonInformation.updatePolygons(),this.updateActivateButtonIndicator()}initializeUI(t){!function(t){const e=document.createElement("style");e.innerHTML=`\n .leaflet-control a { background-color: ${t.colors.styles.controlButton.backgroundColor}; color: ${t.colors.styles.controlButton.color}; display: flex; align-items: center; justify-content: center; }\n .leaflet-control a:hover { background-color: ${t.colors.styles.controlButtonHover.backgroundColor}; }\n .leaflet-control a.active { background-color: ${t.colors.styles.controlButtonActive.backgroundColor}; color: ${t.colors.styles.controlButtonActive.color}; }\n .polydraw-indicator-active { background-color: ${t.colors.styles.indicatorActive.backgroundColor} !important; }\n .crosshair-cursor-enabled { cursor: crosshair !important; }\n .crosshair-cursor-enabled * { cursor: crosshair !important; }\n .leaflet-polydraw-p2p-marker { background-color: ${t.colors.styles.p2pMarker.backgroundColor}; border: 2px solid ${t.colors.styles.p2pMarker.borderColor}; border-radius: 50%; box-sizing: border-box; }\n .leaflet-polydraw-p2p-first-marker { position: relative; }\n .leaflet-polydraw-p2p-first-marker:hover { transform: scale(1.5); transition: all 0.2s ease; }\n `,document.head.appendChild(e)}(this.config),s.DomEvent.disableClickPropagation(t),s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stopPropagation),t.style.display="flex",t.style.flexDirection="column-reverse",t.style.pointerEvents="auto",t.style.position="relative",t.style.zIndex="1000",this.subContainer=s.DomUtil.create("div","sub-buttons",t),this.subContainer.style.maxHeight="0px",this.subContainer.style.overflow="hidden",this.subContainer.style.transition="max-height 0.3s ease",this.subContainer.style.pointerEvents="auto",this.subContainer.style.position="relative",function(t,e,n,i,r,o,a,l){const u=s.DomUtil.create("a","icon-activate",t);if(u.href="#",u.title="Activate",u.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(u,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(u,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(u,"click",s.DomEvent.stop).on(u,"click",i),n.modes.draw){const t=s.DomUtil.create("a","icon-draw",e);t.href="#",t.title="Draw",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M15 7.49996L17.5 9.99996M7.5 20L19.25 8.24996C19.9404 7.5596 19.9404 6.44032 19.25 5.74996V5.74996C18.5596 5.0596 17.4404 5.05961 16.75 5.74996L5 17.5V20H7.5ZM7.5 20H15.8787C17.0503 20 18 19.0502 18 17.8786V17.8786C18 17.316 17.7765 16.7765 17.3787 16.3786L17 16M4.5 4.99996C6.5 2.99996 10 3.99996 10 5.99996C10 8.5 4 8.5 4 11C4 11.8759 4.53314 12.5256 5.22583 13" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",r)}if(n.modes.subtract){const t=s.DomUtil.create("a","icon-subtract",e);t.href="#",t.title="Subtract",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M15.0722 3.9967L20.7508 9.83395L17.0544 13.5304L13.0758 17.5H21.0041V19H7.93503L4.00195 15.0669L15.0722 3.9967ZM10.952 17.5L15.4628 12.9994L11.8268 9.3634L6.12327 15.0669L8.55635 17.5H10.952Z" fill="#1F2328"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",o)}if(n.modes.p2p&&!lo()){const t=s.DomUtil.create("a","icon-p2p",e);t.href="#",t.title="Point to Point",t.innerHTML='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",l)}if(n.modes.deleteAll){const t=s.DomUtil.create("a","icon-erase",e);t.href="#",t.title="Erase All",t.innerHTML='<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) --\x3e\n<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">\n<style type="text/css">\n\t.st0{fill:#000000}\n\t.st1{fill:#333333;fill-opacity:0;}\n</style>\n<title>trash</title>\n<rect class="st1" width="48" height="48"/>\n<polygon class="st0" points="26.6,10 26.6,7.8 21.4,7.8 21.4,10 12.6,10 12.6,12.8 35.4,12.8 35.4,10 "/>\n<path class="st0" d="M35.4,15.4H12.6v4.3h1.8V37c0,1.1,0.9,2,2,2h15.2c1.1,0,2-0.9,2-2V19.7h1.8V15.4z M19.7,34.2c0,0.5-0.4,1-1,1\n\tc-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1V34.2z M25.3,33.8c0,0.7-0.6,1.3-1.3,1.3c-0.7,0-1.3-0.6-1.3-1.3V23\n\tc0-0.7,0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3V33.8z M30.3,34.2c0,0.5-0.4,1-1,1c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1\n\tc0.5,0,1,0.4,1,1V34.2z"/>\n</svg>',s.DomEvent.on(t,"mousedown",s.DomEvent.stopPropagation),s.DomEvent.on(t,"touchstart",s.DomEvent.stopPropagation),s.DomEvent.on(t,"click",s.DomEvent.stop).on(t,"click",a)}}(t,this.subContainer,this.config,this._handleActivateToggle,this._handleDrawClick,this._handleSubtractClick,this._handleEraseClick,this._handlePointToPointClick),this.ensureButtonTouchResponsiveness(t);this.drawModeListeners.push(e=>{const n=t.querySelector(".icon-draw"),i=t.querySelector(".icon-subtract");n&&n.classList.toggle("active",e===l.Add),i&&i.classList.toggle("active",e===l.Subtract)})}setupEventListeners(){this.polygonMutationManager.on("polygonOperationComplete",()=>{this.updateActivateButtonIndicator(),this.modeManager.updateStateForMode(l.Off),this.drawMode=l.Off,this.emitDrawModeChanged(),this.updateMarkerDraggableState();const t=this.modeManager.shouldShowCrosshairCursor(),e=this.modeManager.canPerformAction("mapDrag"),n=this.modeManager.canPerformAction("mapZoom"),i=this.modeManager.canPerformAction("mapDoubleClickZoom");t?s.DomUtil.addClass(this.map.getContainer(),"crosshair-cursor-enabled"):s.DomUtil.removeClass(this.map.getContainer(),"crosshair-cursor-enabled"),this.events(!1),this.setLeafletMapEvents(e,i,n);try{this.tracer.setStyle({color:""})}catch(r){}}),this.polygonMutationManager.on("polygonDeleted",()=>{this.updateActivateButtonIndicator()}),this.eventManager.on("polydraw:polygon:created",async t=>{this.stopDraw(),t.isPointToPoint?await this.polygonMutationManager.addPolygon(t.polygon,{simplify:!1,noMerge:!1}):await this.handleFreehandDrawCompletion(t.polygon),this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}),this.eventManager.on("polydraw:draw:cancel",()=>{this.stopDraw(),this.setDrawMode(l.Off)})}createTracer(){this.tracer=s.polyline([],{...this.config.polyLineOptions,color:this.config.colors.polyline});try{this.tracer.addTo(this.map)}catch(t){}}initializeManagers(){this.polygonDrawManager=new Eo({turfHelper:this.turfHelper,map:this.map,config:this.config,modeManager:this.modeManager,eventManager:this.eventManager,tracer:this.tracer}),this.polygonMutationManager=new So({turfHelper:this.turfHelper,polygonInformation:this.polygonInformation,map:this.map,config:this.config,modeManager:this.modeManager,eventManager:this.eventManager,getFeatureGroups:()=>this.arrayOfFeatureGroups})}async loadExternalConfig(t,e){try{const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load config from ${t}: ${n.status} ${n.statusText}`);const i=await n.json();this.config={...a,...i,...e||{}},this.initializeComponents()}catch(n){console.warn("Failed to load external config, falling back to default + inline config:",n),this.config={...a,...e||{}},this.initializeComponents()}}_updateDrawModeState(t){this.drawMode=t,this.modeManager.updateStateForMode(t),this.emitDrawModeChanged(),this.updateMarkerDraggableState()}_updateUIAfterDrawModeChange(t){this.modeManager.shouldShowCrosshairCursor()?s.DomUtil.addClass(this.map.getContainer(),"crosshair-cursor-enabled"):s.DomUtil.removeClass(this.map.getContainer(),"crosshair-cursor-enabled");try{switch(t){case l.Off:this.tracer.setStyle({color:""});break;case l.Add:this.tracer.setStyle({color:this.config.colors.polyline,dashArray:void 0});break;case l.Subtract:this.tracer.setStyle({color:this.config.colors.subtractLine,dashArray:void 0});break;case l.PointToPoint:this.tracer.setStyle({color:this.config.colors.polyline,dashArray:"5, 5"})}}catch(e){}}_updateMapInteractions(){const t=this.modeManager.canPerformAction("mapDrag"),e=this.modeManager.canPerformAction("mapZoom"),n=this.modeManager.canPerformAction("mapDoubleClickZoom");this.events(this.drawMode!==l.Off),this.setLeafletMapEvents(t,n,e)}initializeComponents(){this.turfHelper=new po(this.config),this.mapStateService=new _o,this.eventManager=new ko,this.polygonInformation=new mo(this.mapStateService),this.modeManager=new xo(this.config,this.eventManager),this.polygonInformation.onPolygonInfoUpdated(t=>{this.updateActivateButtonIndicator()}),this._boundKeyDownHandler=this.handleKeyDown.bind(this)}emitDrawModeChanged(){this.eventManager.emit("polydraw:mode:change",{mode:this.modeManager.getCurrentMode()});for(const t of this.drawModeListeners)t(this.modeManager.getCurrentMode())}updateMarkerDraggableState(){const t=this.modeManager.canPerformAction("markerDrag");this.arrayOfFeatureGroups.forEach(e=>{e.eachLayer(e=>{if(e instanceof s.Marker){const i=e;try{i.options.draggable=t,i.dragging&&(t?i.dragging.enable():i.dragging.disable())}catch(n){}}})})}stopDraw(){this.resetTracker(),this.drawStartedEvents(!1)}setLeafletMapEvents(t,e,n){t?this.map.dragging.enable():this.map.dragging.disable(),e?this.map.doubleClickZoom.enable():this.map.doubleClickZoom.disable(),n?this.map.scrollWheelZoom.enable():this.map.scrollWheelZoom.disable()}resetTracker(){this.tracer.setLatLngs([])}drawStartedEvents(t){const e=t?"on":"off";this.map[e]("mousemove",this.mouseMove,this),this.map[e]("mouseup",this.mouseUpLeave,this),t?(this._boundTouchMove=t=>this.mouseMove(t),this._boundTouchEnd=t=>this.mouseUpLeave(t),this.map.getContainer().addEventListener("touchmove",this._boundTouchMove,{passive:!1}),this.map.getContainer().addEventListener("touchend",this._boundTouchEnd,{passive:!1})):(this._boundTouchMove&&this.map.getContainer().removeEventListener("touchmove",this._boundTouchMove),this._boundTouchEnd&&this.map.getContainer().removeEventListener("touchend",this._boundTouchEnd))}events(t){const e=t?"on":"off";this.map[e]("mousedown",this.mouseDown,this),this.map[e]("dblclick",this.handleDoubleClick,this),t?(this._boundTouchStart=t=>this.mouseDown(t),this.map.getContainer().addEventListener("touchstart",this._boundTouchStart,{passive:!1})):this._boundTouchStart&&this.map.getContainer().removeEventListener("touchstart",this._boundTouchStart)}mouseDown(t){if("cancelable"in t&&t.cancelable&&t.preventDefault(),this.modeManager.isInOffMode())return;let e;if("latlng"in t&&t.latlng)e=t.latlng;else if("touches"in t&&t.touches&&t.touches.length>0){const n=this.map.getContainer().getBoundingClientRect();e=this.map.containerPointToLatLng([t.touches[0].clientX-n.x,t.touches[0].clientY-n.y])}e&&(this.modeManager.getCurrentMode()!==l.PointToPoint?(this.tracer.setLatLngs([e]),this.startDraw()):this.polygonDrawManager.handlePointToPointClick(e))}mouseMove(t){if("cancelable"in t&&t.cancelable&&t.preventDefault(),"latlng"in t&&t.latlng)this.tracer.addLatLng(t.latlng);else if("touches"in t&&t.touches&&t.touches.length>0){const e=this.map.getContainer().getBoundingClientRect(),n=this.map.containerPointToLatLng([t.touches[0].clientX-e.x,t.touches[0].clientY-e.y]);this.tracer.addLatLng(n)}}async mouseUpLeave(t){"cancelable"in t&&t.cancelable&&t.preventDefault(),this.polygonInformation.deletePolygonInformationStorage();const e=this.tracer.toGeoJSON();if(!e||!e.geometry||!e.geometry.coordinates||e.geometry.coordinates.length<3)return void this.stopDraw();let n;try{n=this.turfHelper.createPolygonFromTrace(e)}catch(i){return void this.stopDraw()}if(n&&n.geometry&&n.geometry.coordinates&&0!==n.geometry.coordinates.length){this.stopDraw();try{switch(this.modeManager.getCurrentMode()){case l.Add:{const t=await this.polygonMutationManager.addPolygon(n,{simplify:!0,noMerge:!1});t.success||console.error("Error adding polygon via manager:",t.error);break}case l.Subtract:{const t=await this.polygonMutationManager.subtractPolygon(n);t.success||console.error("Error subtracting polygon via manager:",t.error);break}}}catch(i){console.error("Error in mouseUpLeave polygon operation:",i)}this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups)}else this.stopDraw()}async handleFreehandDrawCompletion(t){try{switch(this.modeManager.getCurrentMode()){case l.Add:{const e=await this.polygonMutationManager.addPolygon(t,{simplify:!0,noMerge:!1});e.success||console.error("Error adding polygon via manager:",e.error);break}case l.Subtract:{const e=await this.polygonMutationManager.subtractPolygon(t);e.success||console.error("Error subtracting polygon via manager:",e.error);break}}}catch(e){console.error("Error in mouseUpLeave polygon operation:",e)}}startDraw(){this.drawStartedEvents(!0)}setupKeyboardHandlers(){this._boundKeyUpHandler=this.handleKeyUp.bind(this),document.addEventListener("keydown",this._boundKeyDownHandler),document.addEventListener("keyup",this._boundKeyUpHandler)}removeKeyboardHandlers(){document.removeEventListener("keydown",this._boundKeyDownHandler),document.removeEventListener("keyup",this._boundKeyUpHandler)}handleKeyDown(t){"Escape"===t.key&&this.modeManager.getCurrentMode()===l.PointToPoint&&this.polygonDrawManager.cancelPointToPointDrawing();this.isModifierKeyPressed(t)&&!this.isModifierKeyHeld&&(this.isModifierKeyHeld=!0,this.polygonDrawManager.setModifierKey(!0),this.updateAllMarkersForEdgeDeletion(!0))}handleKeyUp(t){!this.isModifierKeyPressed(t)&&this.isModifierKeyHeld&&(this.isModifierKeyHeld=!1,this.polygonDrawManager.setModifierKey(!1),this.updateAllMarkersForEdgeDeletion(!1))}updateAllMarkersForEdgeDeletion(t){this.arrayOfFeatureGroups.forEach(e=>{e.eachLayer(e=>{e instanceof s.Marker&&this.updateMarkerForEdgeDeletion(e,t)})})}updateMarkerForEdgeDeletion(t,e){const n=t.getElement();n&&(e?(n.addEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.addEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent)):(n.removeEventListener("mouseenter",this.onMarkerHoverForEdgeDeletionEvent),n.removeEventListener("mouseleave",this.onMarkerLeaveForEdgeDeletionEvent),n.style.backgroundColor="",n.style.borderColor=""))}handleDoubleClick(t){this.modeManager.getCurrentMode()===l.PointToPoint&&this.polygonDrawManager.handleDoubleClick(t)}isModifierKeyPressed(t){return navigator.userAgent.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey}ensureButtonTouchResponsiveness(t){t.querySelectorAll("a").forEach(t=>{t.style.pointerEvents="auto",t.style.touchAction="manipulation",t.style.position="relative",t.style.zIndex="1";const e=t=>{t.stopPropagation(),t.target.style.pointerEvents="auto"};t.addEventListener("touchstart",e,{passive:!0}),t.addEventListener("touchend",e,{passive:!0})})}updateActivateButtonIndicator(){if("function"!=typeof this.getContainer)return;const t=this.getContainer();if(!t)return;const e=t.querySelector(".icon-activate");if(!e)return;const n=this.arrayOfFeatureGroups.length>0,i=!s.DomUtil.hasClass(e,"active");n&&i?s.DomUtil.addClass(e,"polydraw-indicator-active"):s.DomUtil.removeClass(e,"polydraw-indicator-active")}}return s.control.polydraw=function(t){return new bo(t)},bo});
|
|
2
2
|
//# sourceMappingURL=polydraw.umd.min.js.map
|