document.addEventListener("DOMContentLoaded",function(e){var t;config.colors.borderColor,config.colors.bodyBg,config.colors.headingColor;let s=document.querySelector(".datatables-referral"),n={1:{title:"Paid",class:"bg-label-success"},2:{title:"Unpaid",class:"bg-label-warning"},3:{title:"Rejected",class:"bg-label-danger"}};s&&((t=document.createElement("h5")).classList.add("card-title","mb-0","text-md-start","text-center"),t.innerHTML="Referred users",new DataTable(s,{ajax:assetsPath+"json/ecommerce-referral.json",columns:[{data:"id"},{data:"id",orderable:!1,render:DataTable.render.select()},{data:"user"},{data:"referred_id"},{data:"status"},{data:"value"},{data:"earning"}],columnDefs:[{className:"control",searchable:!1,orderable:!1,responsivePriority:2,targets:0,render:function(e,t,s,a){return""}},{targets:1,orderable:!1,searchable:!1,responsivePriority:3,checkboxes:!0,checkboxes:{selectAllRender:'<input type="checkbox" class="form-check-input">'},render:function(){return'<input type="checkbox" class="dt-checkboxes form-check-input">'}},{targets:2,responsivePriority:1,render:function(e,t,s,a){var n=s.user,r=s.email,s=s.avatar;let o;return`
              <div class="d-flex justify-content-start align-items-center customer-name">
                <div class="avatar-wrapper">
                  <div class="avatar avatar-sm me-4">${o=s?`<img src="${assetsPath}img/avatars/${s}" alt="Avatar" class="rounded-circle">`:`<span class="avatar-initial rounded-circle bg-label-${["success","danger","warning","info","dark","primary","secondary"][Math.floor(6*Math.random())]}">${(n.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()}</span>`}</div>
                </div>
                <div class="d-flex flex-column">
                  <a href="app-ecommerce-customer-details-overview.html" class="text-heading"><span class="fw-medium">${n}</span></a>
                  <small class="text-nowrap">${r}</small>
                </div>
              </div>`}},{targets:3,render:function(e,t,s,a){return"<span>"+s.referred_id+"</span>"}},{targets:4,render:function(e,t,s,a){s=s.status;return'<span class="badge '+n[s].class+'" text-capitalized>'+n[s].title+"</span>"}},{targets:5,render:function(e,t,s,a){return"<span>"+s.value+"</span>"}},{targets:6,render:function(e,t,s,a){return'<span class="text-heading">'+s.earning+"</span > "}}],select:{style:"multi",selector:"td:nth-child(2)"},order:[[2,"asc"]],layout:{topStart:{rowClass:"row m-3 my-0 justify-content-between",features:[t]},topEnd:{features:[{pageLength:{menu:[10,25,50,100],text:"_MENU_"}},{buttons:[{extend:"collection",className:"btn btn-label-primary dropdown-toggle",text:'<span class="d-flex align-items-center gap-1"><i class="icon-base ti tabler-upload icon-xs"></i> <span class="d-none d-sm-inline-block">Export</span></span>',buttons:[{extend:"print",text:'<span class="d-flex align-items-center"><i class="icon-base ti tabler-printer me-1"></i>Print</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}},customize:function(e){e.document.body.style.color=config.colors.headingColor,e.document.body.style.borderColor=config.colors.borderColor,e.document.body.style.backgroundColor=config.colors.bodyBg;e=e.document.body.querySelector("table");e.classList.add("compact"),e.style.color="inherit",e.style.borderColor="inherit",e.style.backgroundColor="inherit"}},{extend:"csv",text:'<span class="d-flex align-items-center"><i class="icon-base ti tabler-file me-1"></i>Csv</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"excel",text:'<span class="d-flex align-items-center"><i class="icon-base ti tabler-upload me-1"></i>Excel</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"pdf",text:'<span class="d-flex align-items-center"><i class="icon-base ti tabler-file-text me-1"></i>Pdf</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"copy",text:'<i class="icon-base ti tabler-copy me-1"></i>Copy',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}}]}]}]},bottomStart:{rowClass:"row mx-3 justify-content-between",features:["info"]},bottomEnd:"paging"},language:{paginate:{next:'<i class="icon-base ti tabler-chevron-right scaleX-n1-rtl icon-18px"></i>',previous:'<i class="icon-base ti tabler-chevron-left scaleX-n1-rtl icon-18px"></i>',first:'<i class="icon-base ti tabler-chevrons-left scaleX-n1-rtl icon-18px"></i>',last:'<i class="icon-base ti tabler-chevrons-right scaleX-n1-rtl icon-18px"></i>'}},responsive:{details:{display:DataTable.Responsive.display.modal({header:function(e){return"Details of "+e.data().user}}),type:"column",renderer:function(e,t,s){var a,n,r,s=s.map(function(e){return""!==e.title?`<tr data-dt-row="${e.rowIndex}" data-dt-column="${e.columnIndex}">
                      <td>${e.title}:</td>
                      <td>${e.data}</td>
                    </tr>`:""}).join("");return!!s&&((a=document.createElement("div")).classList.add("table-responsive"),n=document.createElement("table"),a.appendChild(n),n.classList.add("table"),(r=document.createElement("tbody")).innerHTML=s,n.appendChild(r),a)}}}})),setTimeout(()=>{[{selector:".dt-buttons .btn",classToRemove:"btn-secondary",classToAdd:"btn-label-secondary"},{selector:".dt-search .form-control",classToRemove:"form-control-sm"},{selector:".dt-length .form-select",classToRemove:"form-select-sm"},{selector:".dt-length",classToAdd:"me-2 ms-n2 ms-sm-0"},{selector:".dt-buttons",classToAdd:"mb-md-0 mb-6 justify-content-center"},{selector:".dt-layout-table",classToRemove:"row mt-2"},{selector:".dt-layout-start",classToAdd:"mt-md-0 mt-4"},{selector:".dt-layout-end",classToAdd:"mt-0"},{selector:".dt-layout-full",classToRemove:"col-md col-12",classToAdd:"table-responsive"}].forEach(({selector:e,classToRemove:s,classToAdd:a})=>{document.querySelectorAll(e).forEach(t=>{s&&s.split(" ").forEach(e=>t.classList.remove(e)),a&&a.split(" ").forEach(e=>t.classList.add(e))})})},100)});