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