import{g as r,r as l}from"./api-DZ3cXm1m.js";document.addEventListener("DOMContentLoaded",function(){const{routes:n}=window;n&&n.stats&&c();async function c(){try{let t=await fetch(n.stats,{method:"GET",headers:{Authorization:`Bearer ${r()}`,Accept:"application/json"}});if(t.status===401&&await l()&&(t=await fetch(n.stats,{method:"GET",headers:{Authorization:`Bearer ${r()}`,Accept:"application/json"}})),!t.ok)throw new Error("Failed to fetch stats");const e=await t.json();e.success&&i(e.data)}catch(t){console.error("Dashboard stats error:",t),document.querySelectorAll(".spinner-border").forEach(e=>{e.parentElement.textContent="-"})}}function i(t){const e=t.daily||{},o=t.monthly||{},a=t.overall||{};s("statTotalResponses",e.total_responses??0),s("statAutonomousRate",a.autonomous_rate?a.autonomous_rate+"%":"0%"),s("statAvgConfidence",a.avg_confidence?(a.avg_confidence*100).toFixed(0)+"%":"-"),s("statTotalCost","$"+(o.total_cost_usd??0))}function s(t,e){const o=document.getElementById(t);o&&(o.textContent=e)}});
