(()=>{var a=null;function e(a,e){var t=null;for(var n in actionConfig[a]){var i=actionConfig[a][n];i.name==e&&(t=i)}return t}function t(t,n,i,r){let o='<button class="btn btn-mini popup-action" value="';var l=t+"."+n+"."+i.name;o+=l,o+='" title="'+i.title+'">',o+='<i class="'+i.icon+'"></i>',o+="&nbsp;</button>";var p=r.next("span.popupButtonBar").find('button.popup-action[value="'+l+'"]'),s=r.next("span.popupButtonBar");0!=s.length?0==p.length?s.append(o):p.before(o):(o='<span class="popupButtonBar">'+o+"</span></br>",r.after(o)),r.find("button.btn").tooltip({placement:"bottom"}),$('div.lizmapPopupContent button.popup-action[value="'+l+'"]').click((function(){$("#lizmap-action-message").remove(),lizMap.layers.actionLayer.destroyFeatures();var t=$(this).val().split("."),n=t[0],i=t[1],r=t[2];if(a&&a==n+"."+i+"."+r)return a=null,!0;a=null;var o=e(n,r);if("confirm"in o&&""!=o.confirm.trim()){var l=o.confirm.trim();if(!confirm(l))return!1}return function(t,n,i){var r={layerId:t,featureId:n,name:i},o=e(t,i),l=actionConfigData.url;$.get(l,r,(function(a){if("errors"in a)return lizMap.addMessage(a.errors.title,"error",!0).attr("id","lizmap-action-message"),console.log(a.errors.detail),!1;var e=function(a,e,t){var n=lizMap.layers.actionLayer,i=new OpenLayers.Format.GeoJSON({externalProjection:"EPSG:4326",internalProjection:lizMap.map.getProjection()});"style"in e&&(n.styleMap.styles.default.defaultStyle=e.style);var r=i.read(t);return n.addFeatures(r),r}(0,o,a);if(e.length>0){var i="message";if("attributes"in(v=e[0])&&i in v.attributes){$("#lizmap-action-message").remove();var r=v.attributes[i].trim();r&&lizMap.addMessage(r,"info",!0).attr("id","lizmap-action-message")}}if(e.length>0&&"callbacks"in o&&o.callbacks.length>0)for(let a in o.callbacks){var l=o.callbacks[a],p=l.method,s=null;if("layerId"in l){var c=l.layerId,u=lizMap.getLayerConfigById(c);if(u){var f=u[1],m=u[0],d=lizMap.map.getLayersByName(f.cleanname);d.length>0&&(s=d[0])}}"redraw"==p&&null!==s&&s.redraw(!0);var v=e[0];if("select"==p&&null!==s){var y=v.clone();lizMap.selectLayerFeaturesFromSelectionFeature(m,y)}"zoom"==p&&lizMap.map.zoomToExtent(e[0].geometry.getBounds())}lizMap.events.triggerEvent("actionResultReceived",{layerId:t,featureId:n,action:o,features:e})}),"json"),a=t+"."+n+"."+i}(n,i,r),!1})).hover((function(){$(this).addClass("btn-primary")}),(function(){$(this).removeClass("btn-primary")}))}lizMap.events.on({uicreated:function(){var a;a=new OpenLayers.Layer.Vector("actionLayer",{styleMap:new OpenLayers.StyleMap({graphicName:"circle",pointRadius:6,fill:!0,fillColor:"lightblue",fillOpacity:.3,stroke:!0,strokeWidth:3,strokeColor:"blue",strokeOpacity:.8})}),lizMap.map.addLayer(a),lizMap.layers.actionLayer=a},lizmappopupdisplayed:function(){$("div.lizmapPopupContent input.lizmap-popup-layer-feature-id").each((function(){var a=$(this),e=a.val(),n=e.split(".").pop(),i=e.replace("."+n,"");if(!lizMap.getLayerConfigById(i))return!0;if(!(i in actionConfig))return!0;for(var r in actionConfig[i])t(i,n,actionConfig[i][r],a)}))}})})();
//# sourceMappingURL=action.js.map