import p from"./apexcharts.esm-CfSzfZrp.js";function h(){const r=document.getElementById("chart-activity");if(r){let e=[];try{e=JSON.parse(r.dataset.series||"[]")}catch{e=[]}const t=e.map(a=>{try{const[,n,o]=(a.date||"").split("-");return new Date(2e3,+n-1,+o).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return a.date||""}}),s=e.map(a=>+a.success||0),l=e.map(a=>+a.failure||0);new p(r,{chart:{type:"area",height:260,toolbar:{show:!1},fontFamily:"Plus Jakarta Sans",stacked:!0},series:[{name:"Success",data:s.length?s:Array(7).fill(0)},{name:"Failed",data:l.length?l:Array(7).fill(0)}],xaxis:{categories:t.length?t:Array.from({length:7},(a,n)=>`D${n+1}`),labels:{style:{colors:"#6B807C",fontSize:"10px",fontFamily:"JetBrains Mono"}},axisBorder:{show:!1},axisTicks:{show:!1}},yaxis:{labels:{style:{colors:"#6B807C",fontSize:"10px",fontFamily:"JetBrains Mono"}}},colors:["#075E54","#E87A5D"],stroke:{curve:"smooth",width:2},fill:{type:"gradient",gradient:{shadeIntensity:1,opacityFrom:.3,opacityTo:.05}},grid:{borderColor:"#EFEBE0",strokeDashArray:3},dataLabels:{enabled:!1},legend:{position:"top",horizontalAlign:"right",fontSize:"11px",fontFamily:"JetBrains Mono",labels:{colors:"#3A5A55"}},noData:{text:"No deliveries in the last 7 days.",style:{color:"#6B807C",fontSize:"12px"}},tooltip:{y:{formatter:a=>a+" fires"}}}).render()}const c=document.getElementById("chart-codes");if(c){let e=[];try{e=JSON.parse(c.dataset.codes||"[]")}catch{e=[]}const t=e.map(o=>o.label),s=e.map(o=>+o.count||0),l={"200 OK":"#075E54","4xx":"#E5A04E","5xx":"#E87A5D",other:"#D9CFB7"},a=t.map(o=>l[o]||"#075E54"),n=s.reduce((o,m)=>o+m,0);new p(c,{chart:{type:"donut",height:200,fontFamily:"Plus Jakarta Sans"},series:s.length?s:[1],labels:s.length?t:["No data"],colors:s.length?a:["#EFEBE0"],legend:{show:!1},dataLabels:{enabled:!1},plotOptions:{pie:{donut:{size:"68%",labels:{show:!0,total:{show:!0,label:"Total",fontFamily:"JetBrains Mono",fontSize:"11px",color:"#6B807C",formatter:()=>n.toString()},value:{fontFamily:"Fraunces",fontSize:"22px",color:"#0B1F1C"}}}}},stroke:{width:2,colors:["#FBFAF6"]}}).render()}document.querySelectorAll("#p-tabs .p-tab").forEach(e=>{e.addEventListener("click",()=>{document.querySelectorAll("#p-tabs .p-tab").forEach(t=>{t.classList.remove("bg-wa-deep","text-paper-0"),t.classList.add("text-ink-600","hover:bg-paper-100")}),e.classList.add("bg-wa-deep","text-paper-0"),e.classList.remove("text-ink-600","hover:bg-paper-100"),document.querySelectorAll(".p-pane").forEach(t=>t.classList.add("hidden")),document.getElementById("p-"+e.dataset.pane)?.classList.remove("hidden")})});const i=e=>{if(!e)return;const t=(a,n)=>{const o=document.getElementById(a);o&&(o.textContent=n??"—")};t("p-event",e.dataset.event),t("p-code",e.dataset.codeLabel),t("p-latency",e.dataset.latency),t("p-attempt",e.dataset.attempt),t("p-time",e.dataset.time);const s=document.getElementById("p-body"),l=document.getElementById("p-response");s&&(s.textContent=e.dataset.payload||"(no payload recorded)"),l&&(l.textContent=e.dataset.response||e.dataset.error||"(no response captured)"),document.querySelectorAll(".del-row").forEach(a=>a.classList.remove("bg-wa-mint/30")),e.classList.add("bg-wa-mint/30")},d=document.querySelectorAll(".del-row");d.forEach(e=>e.addEventListener("click",()=>i(e))),d.length&&i(d[0])}export{h as default};
