import{d as p}from"./datatables-I6jthWPb.js";import{r as w,g as d}from"./api-DZ3cXm1m.js";import{i as u}from"./tooltip-manager-D9RaGGY4.js";import"./bootstrap.esm-Bb7dPm-H.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */const{permissions:c,routes:l,translations:a}=window;let i;document.addEventListener("DOMContentLoaded",function(){m(),g(),u()});function m(){i=$("#networkStatusesTable").DataTable({...p.getDefaultConfig(),serverSide:!0,ajax:{url:l.networkStatuses.records,type:"POST",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+d())},data:function(t){t.status_filter=$("#statusFilter").val(),t.type_filter=$("#typeFilter").val(),t.impact_filter=$("#impactFilter").val()},error:async function(t){t.status===401&&await w()&&i.ajax.reload()}},order:[[6,"desc"]],columns:[{data:"title",name:"title",render:function(t,n,e){return n==="display"?t?"<strong>"+t+"</strong>":"-":t}},{data:"status",name:"status",render:function(t,n,e){if(n==="display"){const r={reported:"warning",investigating:"info",in_progress:"primary",resolved:"success",scheduled:"secondary"}[t]||"secondary",s=a.networkStatuses.status[t]||t;return'<span class="badge bg-'+r+'">'+s+"</span>"}return t}},{data:"type",name:"type",render:function(t,n,e){return n==="display"?'<span class="badge bg-outline-secondary">'+(a.networkStatuses.type[t]||t)+"</span>":t}},{data:"impact",name:"impact",render:function(t,n,e){if(n==="display"){const r={none:"secondary",minor:"warning",major:"danger",critical:"dark"}[t]||"secondary",s=a.networkStatuses.impact[t]||t;return'<span class="badge bg-'+r+'">'+s+"</span>"}return t}},{data:"started_at",name:"started_at"},{data:"sort_order",name:"sort_order"},{data:"created_at",name:"created_at"},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(t,n,e){var o,r;if(n==="display"){const s=[];if((o=c.networkStatuses)!=null&&o.update){const f=l.networkStatuses.edit.replace(":id",t);s.push('<a href="'+f+'"   class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center"   style="width: 32px; height: 32px;"   data-bs-toggle="tooltip"   title="'+(a.networkStatuses.buttons.edit||"Edit")+'">    <i class="fas fa-edit"></i></a>')}return(r=c.networkStatuses)!=null&&r.delete&&s.push('<button type="button"        class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-network-status"        style="width: 32px; height: 32px;"        data-id="'+t+'"        data-bs-toggle="tooltip"        title="'+(a.networkStatuses.buttons.delete||"Delete")+'">    <i class="fas fa-trash"></i></button>'),s.length===0?'<span class="text-muted">-</span>':'<div class="d-inline-flex">'+s.join("")+"</div>"}return t}}],drawCallback:function(){u()}})}function g(){$("#statusFilter, #typeFilter, #impactFilter").on("change",function(){i.draw()}),$("#clearFilters").on("click",function(){$("#statusFilter").val(""),$("#typeFilter").val(""),$("#impactFilter").val(""),i.draw()}),$(document).on("click",".delete-network-status",function(){const t=$(this).data("id");b(t)})}async function b(t){await window.showConfirm(a.networkStatuses.messages.deleteConfirm||"Are you sure you want to delete this network status?",{confirmClass:"btn-danger",icon:"warning"})&&fetch(l.networkStatuses.delete.replace(":id",t),{method:"DELETE",headers:{Authorization:"Bearer "+d(),Accept:"application/json"}}).then(e=>e.json()).then(e=>{e.success?(window.showSuccess&&window.showSuccess(e.message),i.draw()):window.showError&&window.showError(e.message)}).catch(e=>{console.error("Error:",e),window.showError&&window.showError("An error occurred. Please try again.")})}
