window.JetMapboxMarkerClusterer=function(e){var r=this;this.map=e.map,this.activeMarkers={},this.setMarkers=function(e){this.markers=e,this.markersMap={},this.sourceData={type:"FeatureCollection",features:[]};for(var r=0;r<this.markers.length;r++)this.sourceData.features.push({type:"Feature",properties:{markerKey:""+this.markers[r].getLngLat().lng+this.markers[r].getLngLat().lat},geometry:{type:"Point",coordinates:[this.markers[r].getLngLat().lng,this.markers[r].getLngLat().lat]}}),this.markersMap[""+this.markers[r].getLngLat().lng+this.markers[r].getLngLat().lat]=this.markers[r]},this.setMapData=function(){this.clearMapData(),this.map.addSource("markerClusters",{type:"geojson",data:this.sourceData,cluster:!0,clusterMaxZoom:e.clusterMaxZoom?e.clusterMaxZoom:14,clusterRadius:e.clusterRadius?e.clusterRadius:50}),this.map.addLayer({id:"clusters",type:"circle",source:"markerClusters",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#51bbd6",100,"#f1f075",750,"#f28cb1"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),this.map.addLayer({id:"cluster-count",type:"symbol",source:"markerClusters",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12}}),this.map.addLayer({id:"unclustered-point",type:"circle",source:"markerClusters",filter:["!",["has","point_count"]],paint:{"circle-color":"#11b4da","circle-radius":1,"circle-opacity":0,"circle-stroke-width":0}})},this.clearMapData=function(){try{this.map.getLayer("clusters")&&this.map.removeLayer("clusters"),this.map.getLayer("cluster-count")&&this.map.removeLayer("cluster-count"),this.map.getLayer("unclustered-point")&&this.map.removeLayer("unclustered-point"),this.map.removeSource("markerClusters")}catch(e){this.error=e}},this.getError=function(){return this.error},this.removeMarkers=function(){this.markersMap={},this.activeMarkers={},this.clearMapData()},this.setMarkers(e.markers),this.map.on("load",function(){r.setMapData()}),this.map.on("idle",function(){if(r.markers.length){for(var e=r.map.queryRenderedFeatures(null,{layers:["unclustered-point"]}),t=[],a=0;a<e.length;a++){var s=e[a].properties.markerKey;0>t.indexOf(s)&&t.push(s)}for(markerKey in r.activeMarkers)0>t.indexOf(markerKey)&&(r.activeMarkers[markerKey].remove(),delete r.activeMarkers[markerKey]);for(a=0;a<t.length;a++)r.markersMap[t[a]]&&!r.activeMarkers[t[a]]&&(r.markersMap[t[a]].addTo(r.map),r.activeMarkers[t[a]]=r.markersMap[t[a]])}}),this.map.on("click","clusters",function(e){var t=r.map.queryRenderedFeatures(e.point,{layers:["clusters"]}),a=t[0].properties.cluster_id;r.map.getSource("markerClusters").getClusterExpansionZoom(a,function(e,a){e||r.map.easeTo({center:t[0].geometry.coordinates,zoom:a})})}),this.map.on("mouseenter","clusters",function(){r.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave","clusters",function(){r.map.getCanvas().style.cursor=""})};