var renderPieChart=function(e){const t=document.getElementById("apexPieChart");if(t){let a=e;if(!Array.isArray(e)||!e[0]||void 0===e[0].label){let e=[],t=[];void 0!==window.dashboardData&&window.dashboardData.pieChartLabels?(e=window.dashboardData.pieChartLabels,t=window.dashboardData.pieChartValues):"undefined"!=typeof pieChartLabels&&"undefined"!=typeof pieChartValues?(e=pieChartLabels,t=pieChartValues):void 0!==window.pieChartLabels&&void 0!==window.pieChartValues?(e=window.pieChartLabels,t=window.pieChartValues):(e=["No Data"],t=[100],console.warn("No chart data found, using fallback data")),a=e.map((e,a)=>({label:e,data:t[a]||0}))}if(Array.isArray(a)&&0!==a.length)try{var r={chart:{height:275,type:"pie"},dataLabels:{dropShadow:{enabled:!1,top:1,left:1,blur:1,opacity:1}},stroke:{show:!1},theme:{monochrome:{enabled:!(t.innerHTML=""),color:app.color.theme,shadeTo:"dark",shadeIntensity:.65}},labels:a.map(e=>e.label),legend:{labels:{colors:app.color.white,text:"currentColor"}},series:a.map(e=>e.data)};new ApexCharts(t,r).render().then(()=>{console.log("Pie chart rendered successfully with",a.length,"data points")}).catch(e=>{console.error("Error rendering pie chart:",e),t.innerHTML='<div class="d-flex align-items-center justify-content-center h-100"><span class="text-danger">Error loading chart</span></div>'})}catch(e){console.error("Error creating pie chart:",e),t.innerHTML='<div class="d-flex align-items-center justify-content-center h-100"><span class="text-danger">Chart initialization failed</span></div>'}else console.error("Invalid pie chart data structure"),t.innerHTML='<div class="d-flex align-items-center justify-content-center h-100"><span class="text-muted">Invalid data format</span></div>'}else console.warn("Pie chart container not found")},handleRenderChart=function(){handleRenderChart.retryCount||(handleRenderChart.retryCount=0);50<=handleRenderChart.retryCount?(console.error("Chart data loading timed out after",50,"attempts"),renderPieChart([{label:"No Data",data:100}])):void 0!==window.dashboardData&&window.dashboardData.pieChartLabels||"undefined"!=typeof pieChartLabels&&"undefined"!=typeof pieChartValues||void 0!==window.pieChartLabels&&void 0!==window.pieChartValues||"undefined"!=typeof pieChartData?"undefined"!=typeof pieChartData?renderPieChart(pieChartData):renderPieChart(null):(handleRenderChart.retryCount++,console.warn("Chart data not available, retrying... (attempt",handleRenderChart.retryCount,"of",50,")"),setTimeout(handleRenderChart,100))};$(document).ready(function(){handleRenderChart.retryCount=0,handleRenderChart(),document.addEventListener("theme-reload",function(){$("#apexPieChart").empty(),handleRenderChart()})}),"undefined"==typeof $&&(document.addEventListener("DOMContentLoaded",function(){handleRenderChart.retryCount=0,setTimeout(handleRenderChart,50),document.addEventListener("theme-reload",function(){var e=document.getElementById("apexPieChart");e&&(e.innerHTML=""),handleRenderChart()})}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){handleRenderChart.retryCount=0,handleRenderChart()}):(handleRenderChart.retryCount=0,handleRenderChart()));
//# sourceMappingURL=dashboard-apexcharts.js.map
