!function(t){"use strict";function e(t){if(!(0<t.length))return awbOpenStreetMap.default_coords;const e=t.length;let o,a,n,i,r,s,d,p,u;for(o=0,a=0,n=0,u=0;u<t.length;u++)i=t[u][0]*Math.PI/180,r=t[u][1]*Math.PI/180,o+=s=Math.cos(i)*Math.cos(r),a+=d=Math.cos(i)*Math.sin(r),n+=p=Math.sin(i);o/=e,a/=e,n/=e,r=Math.atan2(a,o);const c=Math.sqrt(o*o+a*a);return[180*(i=Math.atan2(n,c))/Math.PI,180*r/Math.PI]}function o(e){return t(e).find(".awb-openstreet-map-marker").map(function(){const t=this.getAttribute("data-latitude"),e=this.getAttribute("data-longitude");return t&&e?[[t,e]]:null}).get()}window.fusion_open_street_map=[],t(window).on("load fusion-element-render-fusion_openstreetmap",function(a,n){var i=void 0!==n;(i?t('div[data-cid="'+n+'"]').find(".awb-openstreet-map"):t(".awb-openstreet-map")).each(function(){this.dataset.isRendered||function(a,n,i){const r=a.getAttribute("data-map-style"),s=a.getAttribute("data-zoom"),d=a.getAttribute("data-zoomcontrol"),p=a.getAttribute("data-dragging"),u=a.getAttribute("data-touchzoom"),c=a.getAttribute("data-dbclickzoom"),l=a.getAttribute("data-scrollwheelzoom"),h=a.getAttribute("data-map-type"),b=a.getAttribute("data-shape-color"),m=a.getAttribute("data-shape-weight"),g=a.getAttribute("data-fitbounds"),f={color:b,weight:m};let w=o(a);const _=[],A=[];n&&(window.fusion_open_street_map[i]=[]);const M=L.map(a,{zoomControl:d}).setView(e(w),parseInt(s));L.tileLayer(awbOpenStreetMap.tiles[r].url,{attribution:awbOpenStreetMap.tiles[r].attribute}).addTo(M),p||M.dragging.disable(),l||M.scrollWheelZoom.disable(),u||M.touchZoom.disable(),c||M.doubleClickZoom.disable(),t(a).on("awb_openstreetmap/updateCoords",function(){const t=e(o(a));M.flyTo(t)}).on("awb_openstreetmap/updateMarker",function(){if(_.forEach(function(t,e){M.removeLayer(_[e])}),n&&(window.fusion_open_street_map[i]=[]),A.forEach(function(t,e){M.removeLayer(A[e])}),w=o(a),t(a).find(".awb-openstreet-map-marker").each(function(){const e=this.getAttribute("data-latitude"),o=this.getAttribute("data-longitude"),a=t(this).find(".awb-openstreet-map-content-wrapper").html(),r=this.getAttribute("data-action"),s=t(this).find(".awb-openstreet-map-marker-icon-wrapper"),d=s.width(),p=s.height();if(!e||!o)return!0;const u=L.marker([e,o],{icon:L.divIcon({iconSize:[d,p],html:s[0].outerHTML,className:"awb-openstreet-map-marker-icon"})});switch(u.addTo(M),r){case"popup":u.bindPopup(a);break;case"static_close_on":u.bindPopup(a,{closeOnClick:!1,autoClose:!1,closeOnEscapeKey:!1}).openPopup();break;case"static_close_off":u.bindPopup(a,{closeOnClick:!1,autoClose:!1,closeButton:!1,closeOnEscapeKey:!1}).openPopup();break;case"tooltip":u.bindTooltip(a,{direction:"top",opacity:1})}_.push(u),n&&(window.fusion_open_street_map[i][this.getAttribute("data-cid")]||(window.fusion_open_street_map[i][this.getAttribute("data-cid")]=[]),window.fusion_open_street_map[i][this.getAttribute("data-cid")].push(u))}),"polygon"===h){const t=L.polygon(w,f).addTo(M);g&&M.fitBounds(t.getBounds()),A.push(t)}if("polyline"===h){const t=L.polyline(w,f).addTo(M);g&&M.fitBounds(t.getBounds()),A.push(t)}}).trigger("awb_openstreetmap/updateMarker"),a.dataset.isRendered=1}(this,i,n)})})}(jQuery);