import{$ as o}from"./datatables-Bo82YvhT.js";import{T as u}from"./bootstrap.esm-Bb7dPm-H.js";import{d as m}from"./datatables-I6jthWPb.js";import{s as r}from"./toastr-helper-Wdj0mZjX.js";/* empty css                                  */function f(){[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(e=>new u(e,{boundary:document.body}))}function p(){o(document).on("click",".delete-rack",async function(){const a=o(this).data("id"),e=window.routes.racks.delete.replace(":id",a);await window.showConfirm(window.translations.racks.delete_confirm,{confirmClass:"btn-danger",icon:"warning"})&&fetch(e,{method:"DELETE",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content"),"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}}).then(t=>t.json()).then(t=>{t.success?(l.ajax.reload(),r("success",t.message)):r("danger",t.message||"An error occurred.")}).catch(t=>{console.error("Error:",t),r("danger","An error occurred.")})})}let l;document.addEventListener("DOMContentLoaded",function(){const a=document.querySelector("#racksTable").dataset.recordsUrl;l=o("#racksTable").DataTable({...m.getDefaultConfig(),serverSide:!0,ajax:{url:a,type:"GET",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}},columns:[{data:"name",name:"name"},{data:"datacenter",name:"datacenter",render:function(e){return e||"-"}},{data:"row",name:"row",render:function(e){return e||"-"}},{data:"total_u",name:"total_u"},{data:"used_u",name:"used_u",orderable:!1,searchable:!1,render:function(e){return`<span class="badge bg-info">${e}</span>`}},{data:"free_u",name:"free_u",orderable:!1,searchable:!1,render:function(e){return`<span class="badge bg-success">${e}</span>`}},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e){var t,s,i,d;const n=[];if((t=window.permissions.racks)!=null&&t.update){const c=window.routes.racks.edit.replace(":id",e);n.push(`
                            <a href="${c}"
                               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="${((s=window.translations.buttons)==null?void 0:s.edit)||"Edit"}">
                                <i class="fas fa-edit"></i>
                            </a>`)}return(i=window.permissions.racks)!=null&&i.delete&&n.push(`
                            <button type="button"
                                    class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-rack"
                                    style="width: 32px; height: 32px;"
                                    data-id="${e}"
                                    data-bs-toggle="tooltip"
                                    title="${((d=window.translations.buttons)==null?void 0:d.delete)||"Delete"}">
                                <i class="fas fa-trash"></i>
                            </button>`),n.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${n.join("")}</div>`}}],drawCallback:function(){f()}}),p()});
