document.addEventListener("DOMContentLoaded",function(e){let t,a,s,o,r;t=isDarkStyle?"dark":"",config.colors.cardColor,a=config.colors.textMuted,s=config.colors.headingColor,o=config.colors.borderColor,r=config.colors.bodyBg;var n=document.querySelector("#reviewsChart"),l={chart:{height:160,width:190,type:"bar",toolbar:{show:!1}},plotOptions:{bar:{barHeight:"75%",columnWidth:"40%",startingShape:"rounded",endingShape:"rounded",borderRadius:5,distributed:!0}},grid:{show:!1,padding:{top:-3,bottom:-12}},colors:[config.colors_label.success,config.colors_label.success,config.colors_label.success,config.colors_label.success,config.colors.success,config.colors_label.success,config.colors_label.success],dataLabels:{enabled:!1},series:[{data:[20,40,60,80,100,80,60]}],legend:{show:!1},xaxis:{categories:["M","T","W","T","F","S","S"],axisBorder:{show:!1},axisTicks:{show:!1},labels:{style:{colors:a,fontSize:"13px"}}},yaxis:{labels:{show:!1}},responsive:[{breakpoint:0,options:{chart:{width:"100%"},plotOptions:{bar:{columnWidth:"40%"}}}},{breakpoint:1440,options:{chart:{height:150,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:1400,options:{plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:1200,options:{chart:{height:130,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:992,chart:{height:150,width:190,toolbar:{show:!1}},options:{plotOptions:{bar:{borderRadius:5,columnWidth:"40%"}}}},{breakpoint:883,options:{plotOptions:{bar:{borderRadius:5,columnWidth:"40%"}}}},{breakpoint:768,options:{chart:{height:150,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:4,columnWidth:"40%"}}}},{breakpoint:576,options:{chart:{width:"100%",height:"200",type:"bar"},plotOptions:{bar:{borderRadius:6,columnWidth:"30% "}}}},{breakpoint:420,options:{plotOptions:{chart:{width:"100%",height:"200",type:"bar"},bar:{borderRadius:3,columnWidth:"30%"}}}}]},n=(null!==n&&new ApexCharts(n,l).render(),document.querySelector(".datatables-review")),i={Pending:{title:"Pending",class:"bg-label-warning"},Published:{title:"Published",class:"bg-label-success"}};if(n){let e=document.createElement("div");e.classList.add("review_filter");var c=new DataTable(n,{ajax:assetsPath+"json/app-ecommerce-reviews.json",columns:[{data:"id"},{data:"id",orderable:!1,render:DataTable.render.select()},{data:"product"},{data:"reviewer"},{data:"review"},{data:"date"},{data:"status"},{data:"id"}],columnDefs:[{className:"control",searchable:!1,orderable:!1,responsivePriority:2,targets:0,render:function(e,t,a,s){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,render:function(e,t,a,s){var o=a.product,r=a.company_name,n=a.product_image;let l;return`
              <div class="d-flex justify-content-start align-items-center customer-name">
                <div class="avatar-wrapper">
                  <div class="avatar me-4 rounded-2 bg-label-secondary">${l=n?`
                <img src="${assetsPath}img/ecommerce-images/${n}" alt="Product-${a.id}" class="rounded">
              `:`<span class="avatar-initial rounded bg-label-${["success","danger","warning","info","dark","primary","secondary"][Math.floor(6*Math.random())]}">${(o.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()}</span>`}</div>
                </div>
                <div class="d-flex flex-column">
                  <span class="fw-medium text-nowrap text-heading">${o}</span>
                  <small>${r}</small>
                </div>
              </div>`}},{targets:3,responsivePriority:1,render:function(e,t,a,s){var o=a.reviewer,r=a.email,a=a.avatar;let n;return`
              <div class="d-flex justify-content-start align-items-center customer-name">
                <div class="avatar-wrapper">
                  <div class="avatar avatar-sm me-4">${n=a?`<img src="${assetsPath}img/avatars/${a}" 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())]}">${(o.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"><span class="fw-medium">${o}</span></a>
                  <small class="text-nowrap">${r}</small>
                </div>
              </div>`}},{targets:4,responsivePriority:2,sortable:!1,render:function(e,t,a,s){var o=a.review,r=a.para;var a="string"!=typeof(a=a.head)||0===a.length?a:a.charAt(0).toUpperCase()+a.slice(1),n=document.createElement("div"),l=(n.className="read-only-ratings raty",n.setAttribute("data-number","5"),parseInt(window.Helpers.getCssVar("gray-200",!0).slice(1,3),16)),i=parseInt(window.Helpers.getCssVar("gray-200",!0).slice(3,5),16),c=parseInt(window.Helpers.getCssVar("gray-200",!0).slice(5,7),16);if(n)return new Raty(n,{score:o,readOnly:!0,starOn:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='%23FFD700' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E",starOff:`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='rgb(${l},${i},${c})' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E`}).init(),`
              <div>
                ${n.outerHTML}
                <p class="h6 mb-1 text-truncate">${a}</p>
                <small class="text-break">${r}</small>
              </div>
            `}},{targets:5,render:function(e,t,a,s){return'<span class="text-nowrap">'+new Date(a.date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+"</span>"}},{targets:6,render:function(e,t,a,s){a=a.status;return'<span class="badge '+i[a].class+'" text-capitalize>'+i[a].title+"</span>"}},{targets:-1,title:"Actions",searchable:!1,orderable:!1,render:function(e,t,a,s){return`
              <div class="text-xxl-center">
                <div class="dropdown">
                  <a href="javascript:void(0);" class="btn btn-text-secondary rounded-pill waves-effect btn-icon dropdown-toggle hide-arrow p-0" data-bs-toggle="dropdown">
                    <i class="icon-base ti tabler-dots-vertical icon-md"></i>
                  </a>
                  <div class="dropdown-menu dropdown-menu-end">
                    <a href="javascript:void(0);" class="dropdown-item">Download</a>
                    <a href="javascript:void(0);" class="dropdown-item">Edit</a>
                    <a href="javascript:void(0);" class="dropdown-item">Duplicate</a>
                    <div class="dropdown-divider"></div>
                    <a href="javascript:void(0);" class="dropdown-item delete-record text-danger">Delete</a>
                  </div>
                </div>
              </div>
            `}}],select:{style:"multi",selector:"td:nth-child(2)"},order:[[2,"asc"]],layout:{topStart:{rowClass:"row m-3 my-0 justify-content-between",features:[{search:{placeholder:"Search Review",text:"_INPUT_"}}]},topEnd:{features:[{pageLength:{menu:[10,25,50,100],text:"_MENU_"}},e,{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,a){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let s="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?s+=e.lastChild.firstChild.textContent:s+=e.textContent||e.innerText||""}),s}}},customize:function(e){e.document.body.style.color=s,e.document.body.style.borderColor=o,e.document.body.style.backgroundColor=r;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,a){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let s="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?s+=e.lastChild.firstChild.textContent:s+=e.textContent||e.innerText||""}),s}}}},{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,a){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let s="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?s+=e.lastChild.firstChild.textContent:s+=e.textContent||e.innerText||""}),s}}}},{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,a){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let s="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?s+=e.lastChild.firstChild.textContent:s+=e.textContent||e.innerText||""}),s}}}},{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,a){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let s="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?s+=e.lastChild.firstChild.textContent:s+=e.textContent||e.innerText||""}),s}}}}]}]}]},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().reviewer}}),type:"column",renderer:function(e,t,a){var s,o,r,a=a.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!!a&&((s=document.createElement("div")).classList.add("table-responsive"),o=document.createElement("table"),s.appendChild(o),o.classList.add("table"),(r=document.createElement("tbody")).innerHTML=a,o.appendChild(r),s)}}},initComplete:function(){this.api().columns(6).every(function(){let t=this;if(e){let a=document.createElement("select");a.className="form-select",a.innerHTML='<option value=""> All </option>',e.appendChild(a),a.addEventListener("change",function(){var e=a.value?"^"+a.value+"$":"";t.search(e,!0,!1).draw()}),t.data().unique().sort().each(function(e){var t=document.createElement("option");t.value=e,t.className="text-capitalize",t.textContent=e,a.appendChild(t)})}})}})}document.addEventListener("click",function(e){e.target.classList.contains("delete-record")&&(c.row(e.target.closest("tr")).remove().draw(),e=document.querySelector(".dtr-bs-modal"))&&e.classList.contains("show")&&bootstrap.Modal.getInstance(e)?.hide()}),setTimeout(()=>{[{selector:".dt-buttons .btn",classToRemove:"btn-secondary",classToAdd:"btn-label-secondary"},{selector:".dt-search .form-control",classToRemove:"form-control-sm",classToAdd:"ms-0"},{selector:".dt-search",classToAdd:"mb-md-6 mb-0"},{selector:".dt-length .form-select",classToRemove:"form-select-sm",classToAdd:"me-md-4 me-0"},{selector:".dt-layout-table",classToRemove:"row mt-2"},{selector:".review_filter",classToAdd:"me-md-4"},{selector:".review_filter .form-select",classToAdd:"w-px-100"},{selector:".dt-buttons",classToAdd:"mb-0"},{selector:".dt-layout-start",classToAdd:"mt-0"},{selector:".dt-layout-end",classToAdd:"d-flex gap-md-0 gap-4 mt-0"},{selector:".dt-layout-full",classToRemove:"col-md col-12",classToAdd:"table-responsive"}].forEach(({selector:e,classToRemove:a,classToAdd:s})=>{document.querySelectorAll(e).forEach(t=>{a&&a.split(" ").forEach(e=>t.classList.remove(e)),s&&s.split(" ").forEach(e=>t.classList.add(e))})})},100)});