UNPKG

@soon-gis/effect

Version:

@soon-gis/effect 是 Cesium 的特效库,包含了很多特效

72 lines (70 loc) 3.13 MB
var Effect=function(Ze,g,ej){"use strict";const ij=(i=>i&&typeof i=="object"&&"default"in i?i:{default:i})(ej);function rj(){let i=document.createElement("canvas");i.width=512,i.height=512;let t=i.getContext("2d"),e=t.createRadialGradient(256,256,0,256,256,256);return e.addColorStop(.1,"rgba(255, 255, 255, 1.0)"),e.addColorStop(.2,"rgba(255, 255, 255, 0.0)"),e.addColorStop(.3,"rgba(255, 255, 255, 0.9)"),e.addColorStop(.5,"rgba(255, 255, 255, 0.0)"),e.addColorStop(.9,"rgba(255, 255, 255, 0.2)"),e.addColorStop(1,"rgba(255, 255, 255, 1.0)"),t.clearRect(0,0,512,512),t.beginPath(),t.arc(256,256,256,0,Math.PI*2,!0),t.fillStyle=e,t.fill(),t.restore(),i.toDataURL("image/png").replace("image/png","image/octet-stream")}function nj(){let i=document.createElement("canvas");i.width=512,i.height=512;let t=i.getContext("2d");return t.clearRect(0,0,512,512),t.strokeStyle="rgb(255, 255, 0)",t.setLineDash([80,80]),t.lineWidth=30,t.arc(256,256,241,0,Math.PI*2,!0),t.stroke(),i.toDataURL("image/png").replace("image/png","image/octet-stream")}function lf(i){this._definitionChanged=new g.Event,this._color=void 0,this._colorSubscription=void 0,this.color=i}Object.defineProperties(lf.prototype,{isConstant:{get:function(){return!1}},definitionChanged:{get:function(){return this._definitionChanged}},color:g.createPropertyDescriptor("color")}),lf.prototype.getType=function(i){return"ConeGlowBottomCircle"},lf.prototype.getValue=function(i,t){return g.defined(t)||(t={}),t.color=g.Property.getValueOrClonedDefault(this._color,i,g.Color.WHITE,t.color),t.image=g.Material.ConeGlowBottomCircleImage,t},lf.prototype.equals=function(i){return this===i||i instanceof lf&&g.Property.equals(this._color,i._color)};const wL=lf;g.Material.ConeGlowBottomCircleType="ConeGlowBottomCircle",g.Material.ConeGlowBottomCircleImage=rj(),g.Material.ConeGlowBottomCircleSource=`czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; vec4 colorImage = texture2D(image, vec2(st )); material.alpha = colorImage.a * color.a; material.diffuse = 1.5* color.rgb ; return material; }`,g.Material._materialCache.addMaterial(g.Material.ConeGlowBottomCircleType,{fabric:{type:g.Material.ConeGlowBottomCircleType,uniforms:{color:new g.Color(1,0,0,.5),image:g.Material.ConeGlowBottomCircleImage,time:0},source:g.Material.ConeGlowBottomCircleSource},translucent:function(i){return!0}});function uf(i){this._definitionChanged=new g.Event,this._color=void 0,this._colorSubscription=void 0,this.color=i}Object.defineProperties(uf.prototype,{isConstant:{get:function(){return!1}},definitionChanged:{get:function(){return this._definitionChanged}},color:g.createPropertyDescriptor("color")}),uf.prototype.getType=function(i){return"ConeGlowBottomRotateCircle"},uf.prototype.getValue=function(i,t){return g.defined(t)||(t={}),t.color=g.Property.getValueOrClonedDefault(this._color,i,g.Color.WHITE,t.color),t.image=g.Material.ConeGlowBottomRotateCircleImage,t},uf.prototype.equals=function(i){return this===i||i instanceof uf&&g.Property.equals(this._color,i._color)};const AL=uf;g.Material.ConeGlowBottomRotateCircleType="ConeGlowBottomRotateCircle",g.Material.ConeGlowBottomRotateCircleImage=nj(),g.Material.ConeGlowBottomRotateCircleSource=`czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; vec4 colorImage = texture2D(image, vec2(st )); material.diffuse = 2.5 * color.rgb ; material.alpha = colorImage.a ; return material; }`,g.Material._materialCache.addMaterial(g.Material.ConeGlowBottomRotateCircleType,{fabric:{type:g.Material.ConeGlowBottomRotateCircleType,uniforms:{color:new g.Color(1,0,0,.5),image:g.Material.ConeGlowBottomRotateCircleImage,time:0},source:g.Material.ConeGlowBottomRotateCircleSource},translucent:function(i){return!0}});class aj{constructor(t,e,r){this.viewer=t,this.position=e,this.style=r,this.height=r.height||300,this.bottomRadius=r.bottomRadius||30,this.color=r.color||g.Color.AQUA,this.circleHeight=g.Cartographic.fromCartesian(e).height,this.addCone(),this.addBottomCircle(),this.addBottomRotateCircle()}addCone(){var t=g.Matrix4.multiplyByTranslation(g.Transforms.eastNorthUpToFixedFrame(this.position),new g.Cartesian3(0,0,this.height*.5),new g.Matrix4),e=new g.CylinderGeometry({length:this.height,topRadius:0,bottomRadius:this.bottomRadius*.7,vertexFormat:g.MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat}),r=new g.GeometryInstance({geometry:e,modelMatrix:t});this.cylinderPrimitive=this.viewer.scene.primitives.add(new g.Primitive({geometryInstances:[r],appearance:new g.MaterialAppearance({material:new g.Material({fabric:{type:"VtxfShader1",uniforms:{color:this.color,alpha:2},source:` uniform vec4 color; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; float dis = distance(st, vec2(0.5)); material.diffuse =2.9 * color.rgb; material.alpha = color.a * dis * alpha ; return material; } `},translucent:!1}),faceForward:!1,closed:!0})})),this.viewer.scene.preUpdate.addEventListener(this.preUpdateHandle,this)}preUpdateHandle(){this.cylinderPrimitive.appearance.material.uniforms.alpha+=.05,this.cylinderPrimitive.appearance.material.uniforms.alpha>2.5&&(this.cylinderPrimitive.appearance.material.uniforms.alpha=2)}addBottomCircle(){this.bottomCircle=this.viewer.entities.add({position:this.position,ellipse:{semiMinorAxis:this.bottomRadius*2,semiMajorAxis:this.bottomRadius*2,height:this.circleHeight,material:new wL(this.color)}})}addBottomRotateCircle(){let t=360;this.bottomRotateCircle=this.viewer.entities.add({position:this.position,ellipse:{semiMinorAxis:this.bottomRadius*1.45,semiMajorAxis:this.bottomRadius*1.45,height:this.circleHeight,material:new AL(this.color),stRotation:new g.CallbackProperty(e=>(t--,t<0&&(t=360),g.Math.toRadians(t)),!1)}})}remove(){this.viewer.scene.preUpdate.removeEventListener(this.preUpdateHandle,this),this.viewer.entities.remove(this.bottomRotateCircle),this.viewer.entities.remove(this.bottomCircle),this.viewer.scene.primitives.remove(this.cylinderPrimitive)}}function hf(i,t){this._definitionChanged=new g.Event,this.color=i||g.Color.YELLOW,this.speed=t||10}Object.defineProperties(hf.prototype,{isConstant:{get:function(){return!1}},definitionChanged:{get:function(){return this._definitionChanged}},color:g.createPropertyDescriptor("color")}),hf.prototype.getType=function(i){return"Scanline"},hf.prototype.getValue=function(i,t){return g.defined(t)||(t={}),t.color=g.Property.getValueOrClonedDefault(this.color,i,g.Color.WHITE,t.color),t.speed=this.speed,t},hf.prototype.equals=function(i){return this===i||i instanceof hf&&g.Property.equals(this.color,i.color)&&g.Property.equals(this.speed,i.speed)};const CL=hf;g.Material.ScanlineType="Scanline",g.Material.ScanlineSource=`uniform vec4 color; uniform float speed; float circle(vec2 uv, float r, float blur) { float d = length(uv) * 2.0; float c = smoothstep(r+blur, r, d); return c; } czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st - 0.5; material.diffuse =2.8 * color.rgb; material.emission = vec3(0); float t =fract(czm_frameNumber * speed / 1000.0); float s = 0.3; float radius1 = smoothstep(.0, s, t) * 0.5; float alpha1 = circle(st, radius1, 0.01) * circle(st, radius1, -0.01); float alpha2 = circle(st, radius1, 0.01 - radius1) * circle(st, radius1, 0.01); float radius2 = 0.5 + smoothstep(s, 1.0, t) * 0.5; float alpha3 = circle(st, radius1, radius2 + 0.01 - radius1) * circle(st, radius1, -0.01); material.alpha = smoothstep(1.0, s, t) * (alpha1 + alpha2*0.1 + alpha3*0.1); material.alpha *=color.a ; return material; } `,g.Material._materialCache.addMaterial(g.Material.ScanlineType,{fabric:{type:g.Material.ScanlineType,uniforms:{color:new g.Color(1,0,0,.5),time:0,speed:10},source:g.Material.ScanlineSource},translucent:function(i){return!0}});class oj{constructor(t,e,r){this.viewer=t,this.position=e,r=r||{},this.radius=r.radius||200,this.color=r.color||g.Color.YELLOW,this.speed=r.speed||10,this.addEnt()}addEnt(){this.ent=this.viewer.entities.add({position:this.position,ellipse:{semiMinorAxis:this.radius,semiMajorAxis:this.radius,material:new CL(this.color,this.speed),classificationType:g.ClassificationType.BOTH}})}remove(){this.viewer.remove(this.ent)}}class sj{constructor(t,e,r){this.viewer=t,this.position=e,this.radius=r.radius,this.textureUrl=r.textureUrl,this.height=g.Cartographic.fromCartesian(e).height,this.entities=[],this.addEntities()}addEntities(){let t=0,e=[{range:this.radius,url:this.textureUrl+"/kedu.png",color:new g.Color(.4,.4,.4,.8)},{range:this.radius*.92,url:this.textureUrl+"/fangxiang.png",st:-.05,color:new g.Color(.4,.4,.4,.8)},{range:this.radius*.85,url:this.textureUrl+"/keduzhi.png",color:new g.Color(1,1,1,.2)},{range:this.radius,url:this.textureUrl+"/faguang.png",color:new g.Color(1,1,1,.5)}],r;e.forEach(n=>{r=this.viewer.entities.add({position:this.position,ellipse:{height:this.height,semiMajorAxis:n.range,semiMinorAxis:n.range,material:new g.ImageMaterialProperty({image:n.url,transparent:!0,color:n.color?n.color:new g.Color(1,1,1,.7)}),stRotation:n.st?n.st:0}}),this.entities.push(r)}),r=this.viewer.entities.add({position:this.position,ellipse:{height:this.height,semiMajorAxis:this.radius*.9,semiMinorAxis:this.radius*.9,material:new g.ImageMaterialProperty({image:this.textureUrl+"/banyuan.png",transparent:!0,color:new g.Color(.4,.4,.4,.4)}),stRotation:new g.CallbackProperty(function(){return t+=.005},!1)}}),this.entities.push(r)}remove(){this.entities.forEach(t=>{this.viewer.entities.remove(t)}),this.entities=void 0}}var Rn=63710088e-1,bL={centimeters:Rn*100,centimetres:Rn*100,degrees:Rn/111325,feet:Rn*3.28084,inches:Rn*39.37,kilometers:Rn/1e3,kilometres:Rn/1e3,meters:Rn,metres:Rn,miles:Rn/1609.344,millimeters:Rn*1e3,millimetres:Rn*1e3,nauticalmiles:Rn/1852,radians:1,yards:Rn*1.0936};function mv(i,t,e){e===void 0&&(e={});var r={type:"Feature"};return(e.id===0||e.id)&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.properties=t||{},r.geometry=i,r}function yv(i,t,e){if(e===void 0&&(e={}),!i)throw new Error("coordinates is required");if(!Array.isArray(i))throw new Error("coordinates must be an Array");if(i.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!SL(i[0])||!SL(i[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:i};return mv(r,t,e)}function Zu(i,t,e){e===void 0&&(e={});for(var r=0,n=i;r<n.length;r++){var a=n[r];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<a[a.length-1].length;o++)if(a[a.length-1][o]!==a[0][o])throw new Error("First and last Position are not equivalent.")}var s={type:"Polygon",coordinates:i};return mv(s,t,e)}function $s(i,t,e){if(e===void 0&&(e={}),i.length<2)throw new Error("coordinates must be an array of two or more positions");var r={type:"LineString",coordinates:i};return mv(r,t,e)}function u_(i,t){t===void 0&&(t={});var e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=i,e}function lj(i,t,e){e===void 0&&(e={});var r={type:"MultiPolygon",coordinates:i};return mv(r,t,e)}function uj(i,t){t===void 0&&(t="kilometers");var e=bL[t];if(!e)throw new Error(t+" units is invalid");return i*e}function hj(i,t){t===void 0&&(t="kilometers");var e=bL[t];if(!e)throw new Error(t+" units is invalid");return i/e}function SL(i){return!isNaN(i)&&i!==null&&!Array.isArray(i)}function EL(i,t,e){if(i!==null)for(var r,n,a,o,s,l,u,h=0,c=0,d,f=i.type,p=f==="FeatureCollection",v=f==="Feature",m=p?i.features.length:1,y=0;y<m;y++){u=p?i.features[y].geometry:v?i.geometry:i,d=u?u.type==="GeometryCollection":!1,s=d?u.geometries.length:1;for(var _=0;_<s;_++){var x=0,w=0;if(o=d?u.geometries[_]:u,o!==null){l=o.coordinates;var A=o.type;switch(h=e&&(A==="Polygon"||A==="MultiPolygon")?1:0,A){case null:break;case"Point":if(t(l,c,y,x,w)===!1)return!1;c++,x++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(t(l[r],c,y,x,w)===!1)return!1;c++,A==="MultiPoint"&&x++}A==="LineString"&&x++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-h;n++){if(t(l[r][n],c,y,x,w)===!1)return!1;c++}A==="MultiLineString"&&x++,A==="Polygon"&&w++}A==="Polygon"&&x++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(w=0,n=0;n<l[r].length;n++){for(a=0;a<l[r][n].length-h;a++){if(t(l[r][n][a],c,y,x,w)===!1)return!1;c++}w++}x++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(EL(o.geometries[r],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function TL(i,t){if(i.type==="Feature")t(i,0);else if(i.type==="FeatureCollection")for(var e=0;e<i.features.length&&t(i.features[e],e)!==!1;e++);}function RC(i,t){var e,r,n,a,o,s,l,u,h,c,d=0,f=i.type==="FeatureCollection",p=i.type==="Feature",v=f?i.features.length:1;for(e=0;e<v;e++){for(s=f?i.features[e].geometry:p?i.geometry:i,u=f?i.features[e].properties:p?i.properties:{},h=f?i.features[e].bbox:p?i.bbox:void 0,c=f?i.features[e].id:p?i.id:void 0,l=s?s.type==="GeometryCollection":!1,o=l?s.geometries.length:1,n=0;n<o;n++){if(a=l?s.geometries[n]:s,a===null){if(t(null,d,u,h,c)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(a,d,u,h,c)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<a.geometries.length;r++)if(t(a.geometries[r],d,u,h,c)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}d++}}function cj(i,t,e){var r=e;return RC(i,function(n,a,o,s,l){a===0&&e===void 0?r=n:r=t(r,n,a,o,s,l)}),r}function yn(i){var t=[1/0,1/0,-1/0,-1/0];return EL(i,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}yn.default=yn;function PL(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return i.geometry.coordinates;if(i.type==="Point")return i.coordinates}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return i;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function DL(i){if(Array.isArray(i))return i;if(i.type==="Feature"){if(i.geometry!==null)return i.geometry.coordinates}else if(i.coordinates)return i.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function cf(i){return i.type==="Feature"?i.geometry:i}var _v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dj(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function ML(i){var t=i.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}function df(i,t,e){if(e===void 0&&(e={}),!i)throw new Error("point is required");if(!t)throw new Error("polygon is required");var r=PL(i),n=cf(t),a=n.type,o=t.bbox,s=n.coordinates;if(o&&fj(r,o)===!1)return!1;a==="Polygon"&&(s=[s]);for(var l=!1,u=0;u<s.length&&!l;u++)if(IL(r,s[u][0],e.ignoreBoundary)){for(var h=!1,c=1;c<s[u].length&&!h;)IL(r,s[u][c],!e.ignoreBoundary)&&(h=!0),c++;h||(l=!0)}return l}function IL(i,t,e){var r=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var n=0,a=t.length-1;n<t.length;a=n++){var o=t[n][0],s=t[n][1],l=t[a][0],u=t[a][1],h=i[1]*(o-l)+s*(l-i[0])+u*(i[0]-o)===0&&(o-i[0])*(l-i[0])<=0&&(s-i[1])*(u-i[1])<=0;if(h)return!e;var c=s>i[1]!=u>i[1]&&i[0]<(l-o)*(i[1]-s)/(u-s)+o;c&&(r=!r)}return r}function fj(i,t){return t[0]<=i[0]&&t[1]<=i[1]&&t[2]>=i[0]&&t[3]>=i[1]}function tu(i,t){t===void 0&&(t={});var e=Number(i[0]),r=Number(i[1]),n=Number(i[2]),a=Number(i[3]);if(i.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var o=[e,r],s=[e,a],l=[n,a],u=[n,r];return Zu([[o,u,l,s,o]],t.properties,{bbox:i,id:t.id})}function tl(i,t){t===void 0&&(t={});var e=yn(i),r=(e[0]+e[2])/2,n=(e[1]+e[3])/2;return yv([r,n],t.properties,t)}var LL=6378137;function pj(i){return cj(i,function(t,e){return t+gj(e)},0)}function gj(i){var t=0,e;switch(i.type){case"Polygon":return kL(i.coordinates);case"MultiPolygon":for(e=0;e<i.coordinates.length;e++)t+=kL(i.coordinates[e]);return t;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function kL(i){var t=0;if(i&&i.length>0){t+=Math.abs(RL(i[0]));for(var e=1;e<i.length;e++)t-=Math.abs(RL(i[e]))}return t}function RL(i){var t,e,r,n,a,o,s,l=0,u=i.length;if(u>2){for(s=0;s<u;s++)s===u-2?(n=u-2,a=u-1,o=0):s===u-1?(n=u-1,a=0,o=1):(n=s,a=s+1,o=s+2),t=i[n],e=i[a],r=i[o],l+=(OC(r[0])-OC(t[0]))*Math.sin(OC(e[1]));l=l*LL*LL/2}return l}function OC(i){return i*Math.PI/180}function xv(i,t,e){e===void 0&&(e={});for(var r=PL(i),n=DL(t),a=0;a<n.length-1;a++){var o=!1;if(e.ignoreEndVertices&&(a===0&&(o="start"),a===n.length-2&&(o="end"),a===0&&a+1===n.length-1&&(o="both")),vj(n[a],n[a+1],r,o,typeof e.epsilon>"u"?null:e.epsilon))return!0}return!1}function vj(i,t,e,r,n){var a=e[0],o=e[1],s=i[0],l=i[1],u=t[0],h=t[1],c=e[0]-s,d=e[1]-l,f=u-s,p=h-l,v=c*p-d*f;if(n!==null){if(Math.abs(v)>n)return!1}else if(v!==0)return!1;if(r){if(r==="start")return Math.abs(f)>=Math.abs(p)?f>0?s<a&&a<=u:u<=a&&a<s:p>0?l<o&&o<=h:h<=o&&o<l;if(r==="end")return Math.abs(f)>=Math.abs(p)?f>0?s<=a&&a<u:u<a&&a<=s:p>0?l<=o&&o<h:h<o&&o<=l;if(r==="both")return Math.abs(f)>=Math.abs(p)?f>0?s<a&&a<u:u<a&&a<s:p>0?l<o&&o<h:h<o&&o<l}else return Math.abs(f)>=Math.abs(p)?f>0?s<=a&&a<=u:u<=a&&a<=s:p>0?l<=o&&o<=h:h<=o&&o<=l;return!1}function OL(i){for(var t=DL(i),e=0,r=1,n,a;r<t.length;)n=a||t[0],a=t[r],e+=(a[0]-n[0])*(a[1]+n[1]),r++;return e>0}function mj(i,t){var e=cf(i),r=cf(t),n=e.type,a=r.type,o=e.coordinates,s=r.coordinates;switch(n){case"Point":switch(a){case"Point":return NC(o,s);default:throw new Error("feature2 "+a+" geometry not supported")}case"MultiPoint":switch(a){case"Point":return yj(e,r);case"MultiPoint":return _j(e,r);default:throw new Error("feature2 "+a+" geometry not supported")}case"LineString":switch(a){case"Point":return xv(r,e,{ignoreEndVertices:!0});case"LineString":return Aj(e,r);case"MultiPoint":return xj(e,r);default:throw new Error("feature2 "+a+" geometry not supported")}case"Polygon":switch(a){case"Point":return df(r,e,{ignoreBoundary:!0});case"LineString":return Cj(e,r);case"Polygon":return bj(e,r);case"MultiPoint":return wj(e,r);default:throw new Error("feature2 "+a+" geometry not supported")}default:throw new Error("feature1 "+n+" geometry not supported")}}function yj(i,t){var e,r=!1;for(e=0;e<i.coordinates.length;e++)if(NC(i.coordinates[e],t.coordinates)){r=!0;break}return r}function _j(i,t){for(var e=0,r=t.coordinates;e<r.length;e++){for(var n=r[e],a=!1,o=0,s=i.coordinates;o<s.length;o++){var l=s[o];if(NC(n,l)){a=!0;break}}if(!a)return!1}return!0}function xj(i,t){for(var e=!1,r=0,n=t.coordinates;r<n.length;r++){var a=n[r];if(xv(a,i,{ignoreEndVertices:!0})&&(e=!0),!xv(a,i))return!1}return!!e}function wj(i,t){for(var e=0,r=t.coordinates;e<r.length;e++){var n=r[e];if(!df(n,i,{ignoreBoundary:!0}))return!1}return!0}function Aj(i,t){for(var e=!1,r=0,n=t.coordinates;r<n.length;r++){var a=n[r];if(xv({type:"Point",coordinates:a},i,{ignoreEndVertices:!0})&&(e=!0),!xv({type:"Point",coordinates:a},i,{ignoreEndVertices:!1}))return!1}return e}function Cj(i,t){var e=!1,r=0,n=yn(i),a=yn(t);if(!NL(n,a))return!1;for(r;r<t.coordinates.length-1;r++){var o=Sj(t.coordinates[r],t.coordinates[r+1]);if(df({type:"Point",coordinates:o},i,{ignoreBoundary:!0})){e=!0;break}}return e}function bj(i,t){if(i.type==="Feature"&&i.geometry===null||t.type==="Feature"&&t.geometry===null)return!1;var e=yn(i),r=yn(t);if(!NL(e,r))return!1;for(var n=cf(t).coordinates,a=0,o=n;a<o.length;a++)for(var s=o[a],l=0,u=s;l<u.length;l++){var h=u[l];if(!df(h,i))return!1}return!0}function NL(i,t){return!(i[0]>t[0]||i[2]<t[2]||i[1]>t[1]||i[3]<t[3])}function NC(i,t){return i[0]===t[0]&&i[1]===t[1]}function Sj(i,t){return[(i[0]+t[0])/2,(i[1]+t[1])/2]}/** * splaytree v3.1.2 * Fast Splay tree for Node and browser * * @author Alexander Milevski <info@w8r.name> * @license MIT * @preserve *//*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function Ej(i,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(h){return l([u,h])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,n&&(a=u[0]&2?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,n=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){e.label=u[1];break}if(u[0]===6&&e.label<a[1]){e.label=a[1],a=u;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(u);break}a[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(i,e)}catch(h){u=[6,h],n=0}finally{r=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var Qu=function(){function i(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null}return i}();function Tj(i,t){return i>t?1:i<t?-1:0}function Ku(i,t,e){for(var r=new Qu(null,null),n=r,a=r;;){var o=e(i,t.key);if(o<0){if(t.left===null)break;if(e(i,t.left.key)<0){var s=t.left;if(t.left=s.right,s.right=t,t=s,t.left===null)break}a.left=t,a=t,t=t.left}else if(o>0){if(t.right===null)break;if(e(i,t.right.key)>0){var s=t.right;if(t.right=s.left,s.left=t,t=s,t.right===null)break}n.right=t,n=t,t=t.right}else break}return n.right=t.left,a.left=t.right,t.left=r.right,t.right=r.left,t}function BC(i,t,e,r){var n=new Qu(i,t);if(e===null)return n.left=n.right=null,n;e=Ku(i,e,r);var a=r(i,e.key);return a<0?(n.left=e.left,n.right=e,e.left=null):a>=0&&(n.right=e.right,n.left=e,e.right=null),n}function BL(i,t,e){var r=null,n=null;if(t){t=Ku(i,t,e);var a=e(t.key,i);a===0?(r=t.left,n=t.right):a<0?(n=t.right,t.right=null,r=t):(r=t.left,t.left=null,n=t)}return{left:r,right:n}}function Pj(i,t,e){return t===null?i:(i===null||(t=Ku(i.key,t,e),t.left=i),t)}function FC(i,t,e,r,n){if(i){r(""+t+(e?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+n(i)+` `);var a=t+(e?" ":"\u2502 ");i.left&&FC(i.left,a,!1,r,n),i.right&&FC(i.right,a,!0,r,n)}}var zC=function(){function i(t){t===void 0&&(t=Tj),this._root=null,this._size=0,this._comparator=t}return i.prototype.insert=function(t,e){return this._size++,this._root=BC(t,e,this._root,this._comparator)},i.prototype.add=function(t,e){var r=new Qu(t,e);this._root===null&&(r.left=r.right=null,this._size++,this._root=r);var n=this._comparator,a=Ku(t,this._root,n),o=n(t,a.key);return o===0?this._root=a:(o<0?(r.left=a.left,r.right=a,a.left=null):o>0&&(r.right=a.right,r.left=a,a.right=null),this._size++,this._root=r),this._root},i.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},i.prototype._remove=function(t,e,r){var n;if(e===null)return null;e=Ku(t,e,r);var a=r(t,e.key);return a===0?(e.left===null?n=e.right:(n=Ku(t,e.left,r),n.right=e.right),this._size--,n):e},i.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=Ku(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},i.prototype.findStatic=function(t){for(var e=this._root,r=this._comparator;e;){var n=r(t,e.key);if(n===0)return e;n<0?e=e.left:e=e.right}return null},i.prototype.find=function(t){return this._root&&(this._root=Ku(t,this._root,this._comparator),this._comparator(t,this._root.key)!==0)?null:this._root},i.prototype.contains=function(t){for(var e=this._root,r=this._comparator;e;){var n=r(t,e.key);if(n===0)return!0;n<0?e=e.left:e=e.right}return!1},i.prototype.forEach=function(t,e){for(var r=this._root,n=[],a=!1;!a;)r!==null?(n.push(r),r=r.left):n.length!==0?(r=n.pop(),t.call(e,r),r=r.right):a=!0;return this},i.prototype.range=function(t,e,r,n){for(var a=[],o=this._comparator,s=this._root,l;a.length!==0||s;)if(s)a.push(s),s=s.left;else{if(s=a.pop(),l=o(s.key,e),l>0)break;if(o(s.key,t)>=0&&r.call(n,s))return this;s=s.right}return this},i.prototype.keys=function(){var t=[];return this.forEach(function(e){var r=e.key;return t.push(r)}),t},i.prototype.values=function(){var t=[];return this.forEach(function(e){var r=e.data;return t.push(r)}),t},i.prototype.min=function(){return this._root?this.minNode(this._root).key:null},i.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},i.prototype.minNode=function(t){if(t===void 0&&(t=this._root),t)for(;t.left;)t=t.left;return t},i.prototype.maxNode=function(t){if(t===void 0&&(t=this._root),t)for(;t.right;)t=t.right;return t},i.prototype.at=function(t){for(var e=this._root,r=!1,n=0,a=[];!r;)if(e)a.push(e),e=e.left;else if(a.length>0){if(e=a.pop(),n===t)return e;n++,e=e.right}else r=!0;return null},i.prototype.next=function(t){var e=this._root,r=null;if(t.right){for(r=t.right;r.left;)r=r.left;return r}for(var n=this._comparator;e;){var a=n(t.key,e.key);if(a===0)break;a<0?(r=e,e=e.left):e=e.right}return r},i.prototype.prev=function(t){var e=this._root,r=null;if(t.left!==null){for(r=t.left;r.right;)r=r.right;return r}for(var n=this._comparator;e;){var a=n(t.key,e.key);if(a===0)break;a<0?e=e.left:(r=e,e=e.right)}return r},i.prototype.clear=function(){return this._root=null,this._size=0,this},i.prototype.toList=function(){return Mj(this._root)},i.prototype.load=function(t,e,r){e===void 0&&(e=[]),r===void 0&&(r=!1);var n=t.length,a=this._comparator;if(r&&UC(t,e,0,n-1,a),this._root===null)this._root=VC(t,e,0,n),this._size=n;else{var o=Ij(this.toList(),Dj(t,e),a);n=this._size+n,this._root=HC({head:o},0,n)}return this},i.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(i.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),i.prototype.toString=function(t){t===void 0&&(t=function(r){return String(r.key)});var e=[];return FC(this._root,"",!0,function(r){return e.push(r)},t),e.join("")},i.prototype.update=function(t,e,r){var n=this._comparator,a=BL(t,this._root,n),o=a.left,s=a.right;n(t,e)<0?s=BC(e,r,s,n):o=BC(e,r,o,n),this._root=Pj(o,s,n)},i.prototype.split=function(t){return BL(t,this._root,this._comparator)},i.prototype[Symbol.iterator]=function(){var t,e,r;return Ej(this,function(n){switch(n.label){case 0:t=this._root,e=[],r=!1,n.label=1;case 1:return r?[3,6]:t===null?[3,2]:(e.push(t),t=t.left,[3,5]);case 2:return e.length===0?[3,4]:(t=e.pop(),[4,t]);case 3:return n.sent(),t=t.right,[3,5];case 4:r=!0,n.label=5;case 5:return[3,1];case 6:return[2]}})},i}();function VC(i,t,e,r){var n=r-e;if(n>0){var a=e+Math.floor(n/2),o=i[a],s=t[a],l=new Qu(o,s);return l.left=VC(i,t,e,a),l.right=VC(i,t,a+1,r),l}return null}function Dj(i,t){for(var e=new Qu(null,null),r=e,n=0;n<i.length;n++)r=r.next=new Qu(i[n],t[n]);return r.next=null,e.next}function Mj(i){for(var t=i,e=[],r=!1,n=new Qu(null,null),a=n;!r;)t?(e.push(t),t=t.left):e.length>0?(t=a=a.next=e.pop(),t=t.right):r=!0;return a.next=null,n.next}function HC(i,t,e){var r=e-t;if(r>0){var n=t+Math.floor(r/2),a=HC(i,t,n),o=i.head;return o.left=a,i.head=i.head.next,o.right=HC(i,n+1,e),o}return null}function Ij(i,t,e){for(var r=new Qu(null,null),n=r,a=i,o=t;a!==null&&o!==null;)e(a.key,o.key)<0?(n.next=a,a=a.next):(n.next=o,o=o.next),n=n.next;return a!==null?n.next=a:o!==null&&(n.next=o),r.next}function UC(i,t,e,r,n){if(!(e>=r)){for(var a=i[e+r>>1],o=e-1,s=r+1;;){do o++;while(n(i[o],a)<0);do s--;while(n(i[s],a)>0);if(o>=s)break;var l=i[o];i[o]=i[s],i[s]=l,l=t[o],t[o]=t[s],t[s]=l}UC(i,t,e,s,n),UC(i,t,s+1,r,n)}}function ho(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}function FL(i,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function On(i,t,e){return t&&FL(i.prototype,t),e&&FL(i,e),i}var wv=function(t,e){return t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y},GC=function(t,e){if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;var r=t.ll.x<e.ll.x?e.ll.x:t.ll.x,n=t.ur.x<e.ur.x?t.ur.x:e.ur.x,a=t.ll.y<e.ll.y?e.ll.y:t.ll.y,o=t.ur.y<e.ur.y?t.ur.y:e.ur.y;return{ll:{x:r,y:a},ur:{x:n,y:o}}},Ju=Number.EPSILON;Ju===void 0&&(Ju=Math.pow(2,-52));var Lj=Ju*Ju,WC=function(t,e){if(-Ju<t&&t<Ju&&-Ju<e&&e<Ju)return 0;var r=t-e;return r*r<Lj*t*e?0:t<e?-1:1},kj=function(){function i(){ho(this,i),this.reset()}return On(i,[{key:"reset",value:function(){this.xRounder=new zL,this.yRounder=new zL}},{key:"round",value:function(e,r){return{x:this.xRounder.round(e),y:this.yRounder.round(r)}}}]),i}(),zL=function(){function i(){ho(this,i),this.tree=new zC,this.round(0)}return On(i,[{key:"round",value:function(e){var r=this.tree.add(e),n=this.tree.prev(r);if(n!==null&&WC(r.key,n.key)===0)return this.tree.remove(e),n.key;var a=this.tree.next(r);return a!==null&&WC(r.key,a.key)===0?(this.tree.remove(e),a.key):e}}]),i}(),Av=new kj,Cv=function(t,e){return t.x*e.y-t.y*e.x},VL=function(t,e){return t.x*e.x+t.y*e.y},HL=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},a={x:r.x-t.x,y:r.y-t.y},o=Cv(n,a);return WC(o,0)},h_=function(t){return Math.sqrt(VL(t,t))},Rj=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},a={x:r.x-t.x,y:r.y-t.y};return Cv(a,n)/h_(a)/h_(n)},Oj=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},a={x:r.x-t.x,y:r.y-t.y};return VL(a,n)/h_(a)/h_(n)},UL=function(t,e,r){return e.y===0?null:{x:t.x+e.x/e.y*(r-t.y),y:r}},GL=function(t,e,r){return e.x===0?null:{x:r,y:t.y+e.y/e.x*(r-t.x)}},Nj=function(t,e,r,n){if(e.x===0)return GL(r,n,t.x);if(n.x===0)return GL(t,e,r.x);if(e.y===0)return UL(r,n,t.y);if(n.y===0)return UL(t,e,r.y);var a=Cv(e,n);if(a==0)return null;var o={x:r.x-t.x,y:r.y-t.y},s=Cv(o,e)/a,l=Cv(o,n)/a,u=t.x+l*e.x,h=r.x+s*n.x,c=t.y+l*e.y,d=r.y+s*n.y,f=(u+h)/2,p=(c+d)/2;return{x:f,y:p}},el=function(){On(i,null,[{key:"compare",value:function(e,r){var n=i.comparePoints(e.point,r.point);return n!==0?n:(e.point!==r.point&&e.link(r),e.isLeft!==r.isLeft?e.isLeft?1:-1:c_.compare(e.segment,r.segment))}},{key:"comparePoints",value:function(e,r){return e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:e.y>r.y?1:0}}]);function i(t,e){ho(this,i),t.events===void 0?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}return On(i,[{key:"link",value:function(e){if(e.point===this.point)throw new Error("Tried to link already linked events");for(var r=e.point.events,n=0,a=r.length;n<a;n++){var o=r[n];this.point.events.push(o),o.point=this.point}this.checkForConsuming()}},{key:"checkForConsuming",value:function(){for(var e=this.point.events.length,r=0;r<e;r++){var n=this.point.events[r];if(n.segment.consumedBy===void 0)for(var a=r+1;a<e;a++){var o=this.point.events[a];o.consumedBy===void 0&&n.otherSE.point.events===o.otherSE.point.events&&n.segment.consume(o.segment)}}}},{key:"getAvailableLinkedEvents",value:function(){for(var e=[],r=0,n=this.point.events.length;r<n;r++){var a=this.point.events[r];a!==this&&!a.segment.ringOut&&a.segment.isInResult()&&e.push(a)}return e}},{key:"getLeftmostComparator",value:function(e){var r=this,n=new Map,a=function(s){var l=s.otherSE;n.set(s,{sine:Rj(r.point,e.point,l.point),cosine:Oj(r.point,e.point,l.point)})};return function(o,s){n.has(o)||a(o),n.has(s)||a(s);var l=n.get(o),u=l.sine,h=l.cosine,c=n.get(s),d=c.sine,f=c.cosine;return u>=0&&d>=0?h<f?1:h>f?-1:0:u<0&&d<0?h<f?-1:h>f?1:0:d<u?-1:d>u?1:0}}}]),i}(),Bj=0,c_=function(){On(i,null,[{key:"compare",value:function(e,r){var n=e.leftSE.point.x,a=r.leftSE.point.x,o=e.rightSE.point.x,s=r.rightSE.point.x;if(s<n)return 1;if(o<a)return-1;var l=e.leftSE.point.y,u=r.leftSE.point.y,h=e.rightSE.point.y,c=r.rightSE.point.y;if(n<a){if(u<l&&u<h)return 1;if(u>l&&u>h)return-1;var d=e.comparePoint(r.leftSE.point);if(d<0)return 1;if(d>0)return-1;var f=r.comparePoint(e.rightSE.point);return f!==0?f:-1}if(n>a){if(l<u&&l<c)return-1;if(l>u&&l>c)return 1;var p=r.comparePoint(e.leftSE.point);if(p!==0)return p;var v=e.comparePoint(r.rightSE.point);return v<0?1:v>0?-1:1}if(l<u)return-1;if(l>u)return 1;if(o<s){var m=r.comparePoint(e.rightSE.point);if(m!==0)return m}if(o>s){var y=e.comparePoint(r.rightSE.point);if(y<0)return 1;if(y>0)return-1}if(o!==s){var _=h-l,x=o-n,w=c-u,A=s-a;if(_>x&&w<A)return 1;if(_<x&&w>A)return-1}return o>s?1:o<s||h<c?-1:h>c?1:e.id<r.id?-1:e.id>r.id?1:0}}]);function i(t,e,r,n){ho(this,i),this.id=++Bj,this.leftSE=t,t.segment=this,t.otherSE=e,this.rightSE=e,e.segment=this,e.otherSE=t,this.rings=r,this.windings=n}return On(i,[{key:"replaceRightSE",value:function(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var e=this.leftSE.point.y,r=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e<r?e:r},ur:{x:this.rightSE.point.x,y:e>r?e:r}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}},{key:"comparePoint",value:function(e){if(this.isAnEndpoint(e))return 0;var r=this.leftSE.point,n=this.rightSE.point,a=this.vector();if(r.x===n.x)return e.x===r.x?0:e.x<r.x?1:-1;var o=(e.y-r.y)/a.y,s=r.x+o*a.x;if(e.x===s)return 0;var l=(e.x-r.x)/a.x,u=r.y+l*a.y;return e.y===u?0:e.y<u?-1:1}},{key:"getIntersection",value:function(e){var r=this.bbox(),n=e.bbox(),a=GC(r,n);if(a===null)return null;var o=this.leftSE.point,s=this.rightSE.point,l=e.leftSE.point,u=e.rightSE.point,h=wv(r,l)&&this.comparePoint(l)===0,c=wv(n,o)&&e.comparePoint(o)===0,d=wv(r,u)&&this.comparePoint(u)===0,f=wv(n,s)&&e.comparePoint(s)===0;if(c&&h)return f&&!d?s:!f&&d?u:null;if(c)return d&&o.x===u.x&&o.y===u.y?null:o;if(h)return f&&s.x===l.x&&s.y===l.y?null:l;if(f&&d)return null;if(f)return s;if(d)return u;var p=Nj(o,this.vector(),l,e.vector());return p===null||!wv(a,p)?null:Av.round(p.x,p.y)}},{key:"split",value:function(e){var r=[],n=e.events!==void 0,a=new el(e,!0),o=new el(e,!1),s=this.rightSE;this.replaceRightSE(o),r.push(o),r.push(a);var l=new i(a,s,this.rings.slice(),this.windings.slice());return el.comparePoints(l.leftSE.point,l.rightSE.point)>0&&l.swapEvents(),el.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(a.checkForConsuming(),o.checkForConsuming()),r}},{key:"swapEvents",value:function(){var e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var r=0,n=this.windings.length;r<n;r++)this.windings[r]*=-1}},{key:"consume",value:function(e){for(var r=this,n=e;r.consumedBy;)r=r.consumedBy;for(;n.consumedBy;)n=n.consumedBy;var a=i.compare(r,n);if(a!==0){if(a>0){var o=r;r=n,n=o}if(r.prev===n){var s=r;r=n,n=s}for(var l=0,u=n.rings.length;l<u;l++){var h=n.rings[l],c=n.windings[l],d=r.rings.indexOf(h);d===-1?(r.rings.push(h),r.windings.push(c)):r.windings[d]+=c}n.rings=null,n.windings=null,n.consumedBy=r,n.leftSE.consumedBy=r.leftSE,n.rightSE.consumedBy=r.rightSE}}},{key:"prevInResult",value:function(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}},{key:"beforeState",value:function(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{var e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}},{key:"afterState",value:function(){if(this._afterState!==void 0)return this._afterState;var e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};for(var r=this._afterState.rings,n=this._afterState.windings,a=this._afterState.multiPolys,o=0,s=this.rings.length;o<s;o++){var l=this.rings[o],u=this.windings[o],h=r.indexOf(l);h===-1?(r.push(l),n.push(u)):n[h]+=u}for(var c=[],d=[],f=0,p=r.length;f<p;f++)if(n[f]!==0){var v=r[f],m=v.poly;if(d.indexOf(m)===-1)if(v.isExterior)c.push(m);else{d.indexOf(m)===-1&&d.push(m);var y=c.indexOf(v.poly);y!==-1&&c.splice(y,1)}}for(var _=0,x=c.length;_<x;_++){var w=c[_].multiPoly;a.indexOf(w)===-1&&a.push(w)}return this._afterState}},{key:"isInResult",value:function(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;var e=this.beforeState().multiPolys,r=this.afterState().multiPolys;switch(cs.type){case"union":{var n=e.length===0,a=r.length===0;this._isInResult=n!==a;break}case"intersection":{var o,s;e.length<r.length?(o=e.length,s=r.length):(o=r.length,s=e.length),this._isInResult=s===cs.numMultiPolys&&o<s;break}case"xor":{var l=Math.abs(e.length-r.length);this._isInResult=l%2===1;break}case"difference":{var u=function(c){return c.length===1&&c[0].isSubject};this._isInResult=u(e)!==u(r);break}default:throw new Error("Unrecognized operation type found ".concat(cs.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,r,n){var a,o,s,l=el.comparePoints(e,r);if(l<0)a=e,o=r,s=1;else if(l>0)a=r,o=e,s=-1;else throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));var u=new el(a,!0),h=new el(o,!1);return new i(u,h,[n],[s])}}]),i}(),WL=function(){function i(t,e,r){if(ho(this,i),!Array.isArray(t)||t.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=r,this.segments=[],typeof t[0][0]!="number"||typeof t[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var n=Av.round(t[0][0],t[0][1]);this.bbox={ll:{x:n.x,y:n.y},ur:{x:n.x,y:n.y}};for(var a=n,o=1,s=t.length;o<s;o++){if(typeof t[o][0]!="number"||typeof t[o][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var l=Av.round(t[o][0],t[o][1]);l.x===a.x&&l.y===a.y||(this.segments.push(c_.fromRing(a,l,this)),l.x<this.bbox.ll.x&&(this.bbox.ll.x=l.x),l.y<this.bbox.ll.y&&(this.bbox.ll.y=l.y),l.x>this.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),a=l)}(n.x!==a.x||n.y!==a.y)&&this.segments.push(c_.fromRing(a,n,this))}return On(i,[{key:"getSweepEvents",value:function(){for(var e=[],r=0,n=this.segments.length;r<n;r++){var a=this.segments[r];e.push(a.leftSE),e.push(a.rightSE)}return e}}]),i}(),Fj=function(){function i(t,e){if(ho(this,i),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new WL(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(var r=1,n=t.length;r<n;r++){var a=new WL(t[r],this,!1);a.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=a.bbox.ll.x),a.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=a.bbox.ll.y),a.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=a.bbox.ur.x),a.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=a.bbox.ur.y),this.interiorRings.push(a)}this.multiPoly=e}return On(i,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),r=0,n=this.interiorRings.length;r<n;r++)for(var a=this.interiorRings[r].getSweepEvents(),o=0,s=a.length;o<s;o++)e.push(a[o]);return e}}]),i}(),qL=function(){function i(t,e){if(ho(this,i),!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof t[0][0][0]=="number"&&(t=[t])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(var r=0,n=t.length;r<n;r++){var a=new Fj(t[r],this);a.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=a.bbox.ll.x),a.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=a.bbox.ll.y),a.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=a.bbox.ur.x),a.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=a.bbox.ur.y),this.polys.push(a)}this.isSubject=e}return On(i,[{key:"getSweepEvents",value:function(){for(var e=[],r=0,n=this.polys.length;r<n;r++)for(var a=this.polys[r].getSweepEvents(),o=0,s=a.length;o<s;o++)e.push(a[o]);return e}}]),i}(),zj=function(){On(i,null,[{key:"factory",value:function(e){for(var r=[],n=0,a=e.length;n<a;n++){var o=e[n];if(!(!o.isInResult()||o.ringOut)){for(var s=null,l=o.leftSE,u=o.rightSE,h=[l],c=l.point,d=[];s=l,l=u,h.push(l),l.point!==c;)for(;;){var f=l.getAvailableLinkedEvents();if(f.length===0){var p=h[0].point,v=h[h.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(p.x,",")+" ".concat(p.y,"]. Last matching segment found ends at")+" [".concat(v.x,", ").concat(v.y,"]."))}if(f.length===1){u=f[0].otherSE;break}for(var m=null,y=0,_=d.length;y<_;y++)if(d[y].point===l.point){m=y;break}if(m!==null){var x=d.splice(m)[0],w=h.splice(x.index);w.unshift(w[0].otherSE),r.push(new i(w.reverse()));continue}d.push({index:h.length,point:l.point});var A=l.getLeftmostComparator(s);u=f.sort(A)[0].otherSE;break}r.push(new i(h))}}return r}}]);function i(t){ho(this,i),this.events=t;for(var e=0,r=t.length;e<r;e++)t[e].segment.ringOut=this;this.poly=null}return On(i,[{key:"getGeom",value:function(){for(var e=this.events[0].point,r=[e],n=1,a=this.events.length-1;n<a;n++){var o=this.events[n].point,s=this.events[n+1].point;HL(o,e,s)!==0&&(r.push(o),e=o)}if(r.length===1)return null;var l=r[0],u=r[1];HL(l,e,u)===0&&r.shift(),r.push(r[0]);for(var h=this.isExteriorRing()?1:-1,c=this.isExteriorRing()?0:r.length-1,d=this.isExteriorRing()?r.length:-1,f=[],p=c;p!=d;p+=h)f.push([r[p].x,r[p].y]);return f}},{key:"isExteriorRing",value:function(){if(this._isExteriorRing===void 0){var e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var e=this.events[0],r=1,n=this.events.length;r<n;r++){var a=this.events[r];el.compare(e,a)>0&&(e=a)}for(var o=e.segment.prevInResult(),s=o?o.prevInResult():null;;){if(!o)return null;if(!s)return o.ringOut;if(s.ringOut!==o.ringOut)return s.ringOut.enclosingRing()!==o.ringOut?o.ringOut:o.ringOut.enclosingRing();o=s.prevInResult(),s=o?o.prevInResult():null}}}]),i}(),jL=function(){function i(t){ho(this,i),this.exteriorRing=t,t.poly=this,this.interiorRings=[]}return On(i,[{key:"addInterior",value:function(e){this.interiorRings.push(e),e.poly=this}},{key:"getGeom",value:function(){var e=[this.exteriorRing.getGeom()];if(e[0]===null)return null;for(var r=0,n=this.interiorRings.length;r<n;r++){var a=this.interiorRings[r].getGeom();a!==null&&e.push(a)}return e}}]),i}(),Vj=function(){function i(t){ho(this,i),this.rings=t,this.polys=this._composePolys(t)}return On(i,[{key:"getGeom",value:function(){for(var e=[],r=0,n=this.polys.length;r<n;r++){var a=this.polys[r].getGeom();a!==null&&e.push(a)}return e}},{key:"_composePolys",value:function(e){for(var r=[],n=0,a=e.length;n<a;n++){var o=e[n];if(!o.poly)if(o.isExteriorRing())r.push(new jL(o));else{var s=o.enclosingRing();s.poly||r.push(new jL(s)),s.poly.addInterior(o)}}return r}}]),i}(),Hj=function(){function i(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c_.compare;ho(this,i),this.queue=t,this.tree=new zC(e),this.segments=[]}return On(i,[{key:"process",value:function(e){var r=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(r),n;var a=e.isLeft?this.tree.insert(r):this.tree.find(r);if(!a)throw new Error("Unable to find segment #".concat(r.id," ")+"[".concat(r.leftSE.point.x,", ").concat(r.leftSE.point.y,"] -> ")+"[".concat(r.rightSE.point.x,", ").concat(r.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var o=a,s=a,l=void 0,u=void 0;l===void 0;)o=this.tree.prev(o),o===null?l=null:o.key.consumedBy===void 0&&(l=o.key);for(;u===void 0;)s=this.tree.next(s),s===null?u=null:s.key.consumedBy===void 0&&(u=s.key);if(e.isLeft){var h=null;if(l){var c=l.getIntersection(r);if(c!==null&&(r.isAnEndpoint(c)||(h=c),!l.isAnEndpoint(c)))for(var d=this._splitSafely(l,c),f=0,p=d.length;f<p;f++)n.push(d[f])}var v=null;if(u){var m=u.getIntersection(r);if(m!==null&&(r.isAnEndpoint(m)||(v=m),!u.isAnEndpoint(m)))for(var y=this._splitSafely(u,m),_=0,x=y.length;_<x;_++)n.push(y[_])}if(h!==null||v!==null){var w=null;if(h===null)w=v;else if(v===null)w=h;else{var A=el.comparePoints(h,v);w=A<=0?h:v}this.queue.remove(r.rightSE),n.push(r.rightSE);for(var C=r.split(w),T=0,E=C.length;T<E;T++)n.push(C[T])}n.length>0?(this.tree.remove(r),n.push(e)):(this.segments.push(r),r.prev=l)}else{if(l&&u){var D=l.getIntersection(u);if(D!==null){if(!l.isAnEndpoint(D))for(var I=this._splitSafely(l,D),S=0,k=I.length;S<k;S++)n.push(I[S]);if(!u.isAnEndpoint(D))for(var P=this._splitSafely(u,D),b=0,L=P.length;b<L;b++)n.push(P[b])}}this.tree.remove(r)}return n}},{key:"_splitSafely",value:function(e,r){this.tree.remove(e);var n=e.rightSE;this.queue.remove(n);var a=e.split(r);return a.push(n),e.consumedBy===void 0&&this.tree.insert(e),a}}]),i}(),YL=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,Uj=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6,Gj=function(){function i(){ho(this,i)}return On(i,[{key:"run",value:function(e,r,n){cs.type=e,Av.reset();for(var a=[new qL(r,!0)],o=0,s=n.length;o<s;o++)a.push(new qL(n[o],!1));if(cs.numMultiPolys=a.length,cs.type==="difference")for(var l=a[0],u=1;u<a.length;)GC(a[u].bbox,l.bbox)!==null?u++:a.splice(u,1);if(cs.type==="intersection"){for(var h=0,c=a.length;h<c;h++)for(var d=a[h],f=h+1,p=a.length;f<p;f++)if(GC(d.bbox,a[f].bbox)===null)return[]}for(var v=new zC(el.compare),m=0,y=a.length;m<y;m++)for(var _=a[m].getSweepEvents(),x=0,w=_.length;x<w;x++)if(v.insert(_[x]),v.size>YL)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var A=new Hj(v),C=v.size,T=v.pop();T;){var E=T.key;if(v.size===C){var D=E.segment;throw new Error("Unable to pop() ".concat(E.isLeft?"left":"right"," SweepEvent ")+"[".concat(E.point.x,", ").concat(E.point.y,"] from segment #").concat(D.id," ")+"[".concat(D.leftSE.point.x,", ").concat(D.leftSE.point.y,"] -> ")+"[".concat(D.rightSE.point.x,", ").concat(D.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(v.size>YL)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(A.segments.length>Uj)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var I=A.process(E),S=0,k=I.length;S<k;S++){var P=I[S];P.consumedBy===void 0&&v.insert(P)}C=v.size,T=v.pop()}Av.reset();var b=zj.factory(A.segments),L=new Vj(b);return L.getGeom()}}]),i}(),cs=new Gj,Wj=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return cs.run("union",t,r)},qj=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return cs.run("intersection",t,r)},jj=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return cs.run("xor",t,r)},Yj=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return cs.run("difference",t,r)},Xj={union:Wj,intersection:qj,xor:jj,difference:Yj};function Zj(i,t){var e=cf(i),r=cf(t),n=i.properties||{},a=Xj.difference(e.coordinates,r.coordinates);return a.length===0?null:a.length===1?Zu(a[0],n):lj(a,n)}"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(t){if(this===void 0||this===null)throw new TypeError(this+" is not an object");var e=Object(this),r=Math.max(Math.min(e.length,9007199254740991),0)||0,n=1 in arguments&&parseInt(Number(arguments[1]),10)||0;n=n<0?Math.max(r+n,0):Math.min(n,r);var a=