!function($,e,t,a){"use strict";var o,n,i,r,l,c,s,d,p,h,u="#ff1414",m=1,g=.3,f=t.metabox(),w=f.find(".cmb-repeatable-group"),v=null,b=!1;e.reRender=function(){b||(b=!0),clearTimeout(v),v=setTimeout((function(){y(),b=!1}),250)};var y=function(){if(o){E(),l=o.data("iterator"),i=o.find("input[data-image-url]"),r=$("#_da_hotspots_"+l+"_shape");var e=i.data("image-url");(c=new Image).onload=function(){k()},c.src=e}},k=function(){s=$(c);var e=$('
');e.append(s),i.after(e);var t=$(''),a=s.width(),o=s.height();t.css({width:a+"px",height:o+"px"}),s.after(t);var r=c.naturalHeight,f=c.naturalWidth;s.data("natW",f),s.data("natH",r);var w=[[0,0],[r,f]],v=[[-50,-50],[r+50,f+50]];n=L.map("hotspots-drawing-container-"+l,{attributionControl:!1,boxZoom:!1,crs:L.CRS.Simple,doubleClickZoom:!0,dragging:!0,keyboard:!1,maxBounds:v,maxBoundsViscosity:1,maxZoom:10,minZoom:-1,scrollWheelZoom:!1,tap:!0,touchZoom:!0,zoomControl:!0,zoomSnap:0});L.imageOverlay(s.attr("src"),w).addTo(n);n.fitBounds(w),h=new L.FeatureGroup,n.addLayer(h),(d=new L.Control.Draw({draw:{circlemarker:!1,marker:!1,polyline:!1}})).setDrawingOptions({rectangle:{shapeOptions:{color:u,weight:m,fillOpacity:g}},circle:{shapeOptions:{color:u,weight:m,fillOpacity:g},showRadius:!1},polygon:{shapeOptions:{color:u,weight:m,fillOpacity:g}}}),n.addControl(d),p=new L.Control.Draw({edit:{featureGroup:h},draw:!1}),n.on(L.Draw.Event.CREATED,(function(e){h.addLayer(e.layer),x(e.layer),S()})),n.on(L.Draw.Event.DELETED,(function(e){0===h.getLayers().length&&A()})),L.Draw.Polyline.prototype._onTouch=L.Util.falseFn,R(),C(),_()},_=function(){L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:""},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}}},C=function(){n.on("draw:created",(function(e){var t=e.layerType,a=e.layer;switch(O(t),t){case"polygon":case"rectangle":D(a.getLatLngs());break;case"circle":T(a)}})),n.on("draw:edited",(function(e){var t=e.layers,a=r.val();t.eachLayer((function(e){switch(a){case"polygon":case"rectangle":D(e.getLatLngs());break;case"circle":T(e)}}))})),n.on("draw:deleted",(function(e){i.val("")}))},x=function(e){e.on("click",(function(){let e=document.querySelector(".leaflet-draw-edit-edit"),t=document.querySelector(".leaflet-draw-edit-remove"),a=e.classList.contains("leaflet-draw-toolbar-button-enabled"),o=t.classList.contains("leaflet-draw-toolbar-button-enabled");a||o||e.click()}))},D=function(e){var t=new Array;e[0].map((function(e,a){t.push(Math.round(e.lng)),t.push(s.data("natH")-Math.round(e.lat))})),i.val(t)},T=function(e){var t=new Array,a=e.getLatLng();t.push(Math.round(a.lng)),t.push(s.data("natH")-Math.round(a.lat)),t.push(Math.round(e.getRadius())),i.val(t)},O=function(e){r.val(e),o.addClass("shape-"+e)},A=function(){n.addControl(d),n.removeControl(p)},S=function(){n.removeControl(d),n.addControl(p)},E=function(){n&&(n.remove(),$(".hotspots-drawing-wrapper").remove(),n=null)},R=function(){if(i.val()){S();var e=i.val().split(",");switch($("#_da_hotspots_"+l+"_shape").val()){case"polygon":j(e);break;case"circle":M(e);break;case"rectangle":H(e)}}},j=function(e){for(var t=[],a=[],o=0;o