import{d as c}from"./datatables-I6jthWPb.js";import{i as u}from"./tooltip-manager-D9RaGGY4.js";import{r as f,g as m}from"./api-DZ3cXm1m.js";import"./bootstrap.esm-Bb7dPm-H.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){const a=document.getElementById("invoices");if(!a)return;const r=a.getAttribute("data-records-url"),{translations:d}=window,s={pending:"bg-warning",unpaid:"bg-danger",paid:"bg-success",overdue:"bg-danger",cancelled:"bg-secondary",refunded:"bg-info"},o={pending:"Pending",unpaid:"Unpaid",paid:"Paid",overdue:"Overdue",cancelled:"Cancelled",refunded:"Refunded"},l=$("#invoices").DataTable({...c.getDefaultConfig(),serverSide:!0,order:[[0,"desc"]],dom:'<"d-flex justify-content-between align-items-center mb-3"<"d-flex align-items-center"l><"d-flex align-items-center"f>>t<"d-flex justify-content-between align-items-center mt-3"<"d-flex align-items-center"i><"d-flex align-items-center"p>>',ajax:{url:r,type:"POST",data:function(e){},beforeSend:function(e){e.setRequestHeader("Authorization",`Bearer ${m()}`)},error:async function(e){e.status===401&&await f()&&l.ajax.reload()}},columns:[{data:"id",name:"id",render:function(e){return`<span class="badge bg-secondary">#${e}</span>`}},{data:"invoice_number",name:"invoice_number",render:function(e){return`<span class="fw-semibold">${e}</span>`}},{data:"status",name:"status",render:function(e){const n=s[e]||"bg-secondary",t=o[e]||e;return`<span class="badge ${n}">${t}</span>`}},{data:"total",name:"total",render:function(e,n,t){return`<span class="fw-bold">${e}</span>`}},{data:"due_date",name:"due_date",render:function(e){return`<small>${e}</small>`}},{data:"created_at",name:"created_at",render:function(e){return`<small>${e}</small>`}},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e,n,t){var i;return`
                        <a href="/admin/billing/${e}/edit"
                           class="btn btn-sm btn-outline-info d-inline-flex align-items-center justify-content-center"
                           style="width: 32px; height: 32px;"
                           data-bs-toggle="tooltip"
                           title="${((i=d.common)==null?void 0:i.buttons_edit)||"Edit"}">
                            <i class="fas fa-edit"></i>
                        </a>
                    `}}],drawCallback:function(){u()}})});
