1var c=Object.defineProperty;var g=(r,s,t)=>s in r?c(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var e=(r,s,t)=>g(r,typeof s!="symbol"?s+"":s,t);import{L as f}from"./ListenerManager-B9zmCDZv.js";import{G as y}from"./GoogleMapsLoader-BItwxU3D.js";let i;class v{constructor({outerEl:s,latKey:t="lat",lngKey:a="lng",mapOptions:o={},onMapReady:p=function(){},onMarkerClick:h=function(){},onMarkerDragEnd:n=function(){},onMarkersBoundsChange:l=function(){},points:u=[],mapElSelector:d="[data-map]",mapEl:m=void 0}){e(this,"latKey");e(this,"lngKey");e(this,"map");e(this,"markers",[]);e(this,"onMarkersBoundsChange");e(this,"onMapReady");e(this,"onMarkerClick");e(this,"onMarkerDragEnd");e(this,"outerEl");e(this,"points");e(this,"isApiReady");e(this,"isMapReady");e(this,"mapEl");e(this,"apiKey");e(this,"mapOptions");e(this,"listenerBoss");e(this,"loadingClass","loading");e(this,"boundsHaveChanged",!0);this.isMapReady=!1,this.isApiReady=!1,this.outerEl=s,this.latKey=t,this.lngKey=a,this.mapOptions=o,this.onMapReady=p,this.onMarkerClick=h,this.onMarkerDragEnd=n,this.onMarkersBoundsChange=l,this.points=u,this.listenerBoss=new f,this.mapEl=m??this.outerEl.querySelector(d),this.mapEl?this.loadTheApi():console.error("the map element could not be found",d)}loadTheApi(){this.mapEl.classList.add(this.loadingClass),new y(s=>{i=s,this.apiIsReady()})}apiIsReady(){this.isApiReady=!0,this.mapEl.classList.remove(this.loadingClass),this.map=new i.maps.Map(this.mapEl,this.mapOptions),this.initialSetup()}initialSetup(){!this.mapEl||!this.isApiReady||(this.isMapReady?this.mapReady():i.maps.event.addListenerOnce(this.map,"idle",()=>{this.isMapReady=!0,this.mapReady()}))}mapReady(){this.setUpMarkers(),this.listenerBoss.register(window,"resize",()=>{this.boundsHaveChanged=!0,this.centerMap()}),this.listenerBoss.register(window,"site.print",()=>{this.updateMapBounds(!0),this.boundsHaveChanged=!0,this.centerMap()}),typeof this.onMapReady=="function"&&this.onMapReady.call(this,this.map,this.markers)}setUpMarkers(){this.points.forEach((s,t)=>{const a=s,o=a[this.latKey],p=a[this.lngKey];if(o&&p){const h=s?.isDraggable||!1,n=new i.maps.Marker({icon:s.hasOwnProperty("icon")?a.icon:void 0,map:this.map,opacity:s.hasOwnProperty("opacity")?a.opacity:1,optimized:!1,point:s,position:{lat:parseFloat(a[this.latKey]),lng:parseFloat(a[this.lngKey])},title:s.hasOwnProperty("title")?a.title:void 0,zIndex:t,draggable:h});this.markers.push(n),typeof this.onMarkerClick=="function"&&n.addListener("click",()=>this.onMarkerClick(n,this.map)),h&&typeof this.onMarkerDragEnd=="function"&&n.addListener("dragend",()=>this.onMarkerDragEnd(n,this.map))}else console.error("Missing lat and/or lng",s)}),this.updateMapBounds()}removePoints(){this.markers.length&&(this.markers.forEach(s=>{i.maps.event.clearInstanceListeners(s),s.setVisible(!1),s.setMap(null)}),this.markers=[]),this.points=[]}changePoints(s){this.removePoints(),this.points=s,this.initialSetup()}centerMap(){if(!this.map||!this.boundsHaveChanged)return;const s=this.map.getCenter();i.maps.event.trigger(this.map,"resize"),s&&this.map.setCenter(s)}updateMapBounds(s=!1){if(!this.map||!this.boundsHaveChanged&&!s)return;this.boundsHaveChanged=!1;let t=!1;const a=new i.maps.LatLngBounds;this.markers.forEach(o=>{o.getVisible()&&(t=!0,a.extend(o.getPosition()))}),t&&(i.maps.event.addListenerOnce(this.map,"bounds_changed",()=>{typeof this.onMarkersBoundsChange=="function"&&this.onMarkersBoundsChange(this.map),i.maps.event.addListenerOnce(this.map,"bounds_changed",()=>{this.boundsHaveChanged=!0})}),this.map.fitBounds(a))}resetMarkerZIndexes(){this.markers.forEach((s,t)=>{s.setZIndex(t)})}}export{v as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.