import{d as x}from"./datatables-I6jthWPb.js";import{r as k,g as y}from"./api-DZ3cXm1m.js";import{i as v}from"./tooltip-manager-D9RaGGY4.js";import{c as C,g as T}from"./datatable-filters-CecjJm_7.js";import"./bootstrap.esm-Bb7dPm-H.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */import"./vendor-zLyX4B24.js";import"./tr-CHCA6xOE.js";const j=window.translations||{},f=C(null,{search:!0,searchPlaceholder:j.search_placeholder||"Search..."}),_=$("#cancelledOrders").DataTable({...x.getDefaultConfig(),serverSide:!0,dom:T(),ajax:{url:$("#cancelledOrders").data("records-url"),type:"GET",data:function(e){e.search={value:f.getValues().search||""}},beforeSend:function(e){e.setRequestHeader("Authorization",`Bearer ${y()}`)},error:async function(e){e.status===401&&await k()&&_.ajax.reload()}},columns:[{data:"order_number",name:"order_number",render:function(e){return`<span class="fw-bold">${e}</span>`}},{data:"client_name",name:"client_name"},{data:"products",name:"products",orderable:!1,render:function(e){if(!e||e==="-")return"-";const a=50;return e.length>a?`<span data-bs-toggle="tooltip" title="${e}">${e.substring(0,a)}...</span>`:e}},{data:"amount",name:"amount",render:function(e,a,t){return`${parseFloat(e).toFixed(2)} ${t.currency_code}`}},{data:"status",name:"status",render:function(){var e,a;return`<span class="badge bg-danger">${((a=(e=window.translations)==null?void 0:e.orders)==null?void 0:a.statuses_cancelled)||"Cancelled"}</span>`}},{data:"fraud_status",name:"fraud_status",orderable:!1,render:function(e,a,t){var c,l,d,i,p,m,g,w,b,h;if(!e)return`<span class="badge bg-secondary">${((l=(c=window.translations)==null?void 0:c.orders)==null?void 0:l.fraud_unchecked)||"-"}</span>`;let n="bg-secondary",s=e,r="fas fa-question-circle";switch(e){case"approved":n="bg-success",s=((i=(d=window.translations)==null?void 0:d.orders)==null?void 0:i.fraud_approved)||"Approved",r="fas fa-check-circle";break;case"review":n="bg-warning",s=((m=(p=window.translations)==null?void 0:p.orders)==null?void 0:m.fraud_review)||"Review",r="fas fa-exclamation-triangle";break;case"rejected":n="bg-danger",s=((w=(g=window.translations)==null?void 0:g.orders)==null?void 0:w.fraud_rejected)||"Rejected",r="fas fa-times-circle";break;case"checking":n="bg-info",s=((h=(b=window.translations)==null?void 0:b.orders)==null?void 0:h.fraud_checking)||"Checking",r="fas fa-spinner fa-spin";break}let o="";if(t.fraud_score!==null&&t.fraud_score!==void 0){const u=parseInt(t.fraud_score);o=` <small class="${u>=70?"text-danger":u>=30?"text-warning":"text-success"}">(${u})</small>`}return`<span class="badge ${n}"><i class="${r} me-1"></i>${s}</span>${o}`}},{data:"created_at",name:"created_at"},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e){var t,n,s,r,o,c,l,d;const a=[];if((n=(t=window.pageConfig)==null?void 0:t.permissions)!=null&&n.canView){const i=window.routes.orders.show.replace(":id",e);a.push(`
                        <a href="${i}"
                           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="${((r=(s=window.translations)==null?void 0:s.common)==null?void 0:r.buttons_view)||"View"}">
                            <i class="fas fa-eye"></i>
                        </a>`)}if((c=(o=window.pageConfig)==null?void 0:o.permissions)!=null&&c.canEdit){const i=window.routes.orders.edit.replace(":id",e);a.push(`
                        <a href="${i}"
                           class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center ms-1"
                           style="width: 32px; height: 32px;"
                           data-bs-toggle="tooltip"
                           title="${((d=(l=window.translations)==null?void 0:l.common)==null?void 0:d.buttons_edit)||"Edit"}">
                            <i class="fas fa-edit"></i>
                        </a>`)}return a.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${a.join("")}</div>`}}],drawCallback:function(){v()},initComplete:function(){f.init()}});f.setDataTable(_);
