function isValidCoords(e){if(!e||"string"!=typeof e)return!1;const t=e.split(",").map((e=>e.trim()));if(2!==t.length)return!1;const o=parseFloat(t[0]),n=parseFloat(t[1]);return!isNaN(o)&&o>=-90&&o<=90&&n>=-180&&n<=180}window.initMap=async function(){function e(){const e=document.createElement("div");return e.className="map-marker",e}function t(e,t){const o=e.content;o&&o.classList.toggle("is-active",t)}function o(){return{render:({count:e,position:t})=>{const o=document.createElement("div"),n=48;return o.style.width=n+"px",o.style.height=n+"px",o.style.borderRadius="50%",o.style.backgroundColor="#0F234D",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.color="#ffffff",o.style.fontSize="16px",o.style.fontWeight="700",o.style.fontFamily="Arial, sans-serif",o.textContent=String(e),new google.maps.marker.AdvancedMarkerElement({position:t,content:o,zIndex:Number(e)})}}}function n(e,t){const o=t.getBoundingClientRect(),n=a.getBoundingClientRect(),r=n.left+n.width/2+window.pageXOffset,s=n.top+n.height/2+window.pageYOffset,i=40,l=20,c=r-o.width/2,d=s-o.height/2-i-l;t.style.left=c+"px",t.style.top=d+"px"}function r(){h&&t(h,!1),h=null,b&&(b.remove(),b=null),k.forEach((e=>window.removeEventListener(e.name,e.handler))),k=[]}const s={mainMarkers:[],essentialsMarkers:[]},a=document.querySelector("[data-map-position-center]");if(!a)return;const i=a.getAttribute("data-map-position-center");if(!isValidCoords(i))return;const l=i.split(",").map(Number),c={lat:l[0],lng:l[1]},d=parseInt(document.querySelector("[data-map-zoom]")?.dataset.mapZoom)||16,m=google.maps.Map,p=google.maps.marker.AdvancedMarkerElement,u=new m(a,{center:c,zoom:d,mapId:"108c67d0a07f090199e913e3",mapTypeControl:!1,fullscreenControl:!0,fullscreenControlOptions:{position:google.maps.ControlPosition.TOP_RIGHT},zoomControl:!0,zoomControlOptions:{position:google.maps.ControlPosition.RIGHT_BOTTOM},streetViewControl:!1}),f=document.querySelectorAll("[data-map-position]"),g=Array.from(f).filter((e=>{const t=e.getAttribute("data-map-position"),o=isValidCoords(t);if(!o){const o=e.getAttribute("href")||"no href";s.mainMarkers.push({href:o,value:t})}return o})).map((e=>{const t=e.getAttribute("data-map-position").split(",").map((e=>parseFloat(e.trim())));return{lat:t[0],lng:t[1],modal:e}}));let h=null,b=null,k=[];const y=[];g.forEach((({lat:t,lng:o,modal:r})=>{const s=new p({position:{lat:t,lng:o},map:u,content:e(),gmpClickable:!0});s.addListener("click",(()=>{function e(){b=r.cloneNode(!0),b.removeAttribute("id"),b.style.position="absolute",b.style.zIndex="9",b.style.pointerEvents="auto",document.body.appendChild(b),n(s,b),google.maps.event.removeListener(w)}if(h&&h!==s){const e=h.__pin;e&&(e.background="#0F234D")}s.__pin&&(s.__pin.background="#0A1A38"),h=s,b&&(b.remove(),b=null),k.forEach((e=>window.removeEventListener(e.name,e.handler))),k=[];const t=r.cloneNode(!0);t.style.position="absolute",t.style.visibility="hidden",document.body.appendChild(t);const o=t.offsetHeight;t.remove();const i=a.offsetHeight,l=o/2,c=u.getProjection(),d=c.fromLatLngToPoint(s.position),m=u.getBounds(),p=c.fromLatLngToPoint(m.getNorthEast()),f=l/(i/(c.fromLatLngToPoint(m.getSouthWest()).y-p.y)),g=new google.maps.Point(d.x,d.y-f),y=c.fromPointToLatLng(g),w=u.addListener("idle",e);u.panTo(y)})),y.push(s)}));const w=document.querySelector("[data-block-essentials]");if(w){const e={Amenities:"https://cdn.prod.website-files.com/6909bb1c8f634168cba143a6/690c8b755fd060eda47fce0d_icon-marker-amentities.svg",Schools:"https://cdn.prod.website-files.com/6909bb1c8f634168cba143a6/690c8b75f8ead5a5f5124445_icon-marker-schools.svg",Transport:"https://cdn.prod.website-files.com/6909bb1c8f634168cba143a6/690c8b75dc544fabb44e864d_icon-marker-transport.svg"},t=[],n=Array.from(w.children);for(let o=0;o=-90&&o<=90&&r>=-180&&r<=180){const e=new p({position:{lat:o,lng:r},map:u,content:function(){const e=document.createElement("div");return e.className="map-marker","Amenities"===a?e.classList.add("is--amenities"):"Schools"===a?e.classList.add("is--school"):"Transport"===a&&e.classList.add("is--transport"),e}(),gmpClickable:!1});t.push(e)}else s.essentialsMarkers.push({href:e,value:`${n[1]}, ${n[2]}`})}else s.essentialsMarkers.push({href:e,value:"no coords in href"})}}}}u.addListener("dragstart",r),u.addListener("zoom_changed",r);const a=y;return a.length&&window.markerClusterer&&window.markerClusterer.MarkerClusterer&&new markerClusterer.MarkerClusterer({map:u,markers:a,renderer:o()}),void(s.mainMarkers.length||s.essentialsMarkers.length)}u.addListener("dragstart",r),u.addListener("zoom_changed",r),y.length&&window.markerClusterer&&window.markerClusterer.MarkerClusterer&&new markerClusterer.MarkerClusterer({map:u,markers:y,renderer:o()}),s.mainMarkers.length||s.essentialsMarkers.length};