jQuery(document).ready((function($){$("#wf-sn-el-subtabs a").on("click",(function(e){e.preventDefault(),$("#wf-sn-el-subtabs a").removeClass("nav-tab-active"),$(".wf-sn-el-subtab").hide(),$(this).addClass("nav-tab-active");var t=$(this).attr("href");$(t).show()})),eventstable=jQuery("#sn-el-datatable").DataTable({processing:!0,serverSide:!0,ajax:{url:ajaxurl,type:"POST",data:{action:"get_events_data",nonce:datatables_object.nonce},error:function(e,t,a){var n="<strong>Error loading data:</strong><br>Status: "+e.status+" ("+e.statusText+")<br>Error: "+t+"<br>Code: "+a+"<br>Response: "+e.responseText;jQuery("#datatable-error").html(n).show()}},columns:[{data:"timestamp",title:"Time"},{data:"action",title:"Action"},{data:"user_id",title:"User"},{data:"description",title:"Event"},{data:"details",title:"Details",orderable:!1}],order:[[0,"desc"]],columnDefs:[{targets:4,data:null,defaultContent:"<button>Detail</button>"}]}),$("#sn-el-datatable tbody").on("click","button",(function(e){e.preventDefault();var t=$(this).closest("tr"),a=eventstable.row(t);if(a.child.isShown())a.child.hide(),t.removeClass("shown"),$(this).removeClass("open");else{var n=t.find(".details-content").html();a.child(n).show(),t.addClass("shown"),$(this).addClass("open")}})),$("#sn-el-truncate").on("click",(function(e){if(e.preventDefault(),confirm("Are you sure you want to delete all log entries?")){var t={action:"sn_el_truncate_log",_ajax_nonce:wf_sn_el.nonce};$.post(ajaxurl,t,(function(e){e?(alert("All log entries have been deleted."),window.location.reload()):alert("Bad AJAX response. Please reload the page.")}))}}))}));