import{_ as C,r as g,o as x,a as l,b as s,l as w,s as I,t as d,F as B,g as T,h as o,d as R,w as m,f as L,u as _}from"./index-BB0X_WMV.js";import{a as A,C as F}from"./index-09HB4Lmg.js";import{C as O,a as W,L as N,B as V,p as E,b as M,c as $,d as P,e as z}from"./chartjs-plugin-datalabels.esm-DiDzp_cw.js";const U={class:"daily-stats"},Y={class:"page-header"},Z={class:"filter-section"},j={key:0,class:"loading"},q={key:1,class:"no-data"},G={key:2,class:"server-charts"},H={class:"chart-header"},J={class:"chart-subtitle"},K={class:"chart-wrapper"},Q={class:"chart-container"},X={__name:"DailyStats",setup(tt){O.register(W,N,V,E,M,$,P);const c=g(!1),r=g([]),n=g(f());function f(){return new Date().toISOString().split("T")[0]}function b(){const t=new Date(n.value);t.setDate(t.getDate()-1),n.value=t.toISOString().split("T")[0],i()}function y(){const t=new Date(n.value);t.setDate(t.getDate()+1),n.value=t.toISOString().split("T")[0],i()}const S={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top"},tooltip:{mode:"index",intersect:!1},datalabels:{display:t=>{if(t.datasetIndex!==2)return!1;const e=t.chart.data.datasets,a=t.dataIndex;return e.reduce((u,p)=>u+(p.data[a]||0),0)>0},anchor:"end",align:"end",offset:0,font:{size:9},color:"#666",formatter:(t,e)=>{const a=e.chart.data.datasets,v=e.dataIndex;return a.reduce((u,p)=>u+(p.data[v]||0),0)}}},scales:{x:{stacked:!0,ticks:{maxRotation:0,autoSkip:!0,maxTicksLimit:24,callback:function(t,e){const a=this.getLabelForValue(t);return a&&a.endsWith(":00")?a:""}},grid:{display:!1}},y:{stacked:!0,beginAtZero:!0}},barPercentage:.8,categoryPercentage:.9},D=t=>({labels:t.timeStats.map(a=>a.time),datasets:[{label:"CRITICAL",data:t.timeStats.map(a=>a.critical),backgroundColor:"#9b59b6",borderWidth:0},{label:"ERROR",data:t.timeStats.map(a=>a.error),backgroundColor:"#e74c3c",borderWidth:0},{label:"WARN",data:t.timeStats.map(a=>a.warn),backgroundColor:"#f39c12",borderWidth:0}]}),i=async()=>{c.value=!0;try{r.value=await A.getTimeStatsByServer(n.value,15)}catch(t){console.error("Failed to load stats:",t),r.value=[]}finally{c.value=!1}},h=t=>{const e=new Date(t);return`${e.getFullYear()}년 ${e.getMonth()+1}월 ${e.getDate()}일`},k=t=>t.timeStats.reduce((e,a)=>e+a.total,0);return x(()=>{i()}),(t,e)=>(o(),l("div",U,[s("div",Y,[e[1]||(e[1]=s("h2",null,"일별 에러현황",-1)),s("div",Z,[s("button",{class:"nav-btn",onClick:b},"◀ 이전"),w(s("input",{type:"date","onUpdate:modelValue":e[0]||(e[0]=a=>n.value=a),onChange:i},null,544),[[I,n.value]]),s("button",{class:"nav-btn",onClick:y},"다음 ▶")])]),c.value?(o(),l("div",j,[...e[2]||(e[2]=[s("p",null,"로딩중...",-1)])])):r.value.length===0?(o(),l("div",q,[s("p",null,d(h(n.value))+"에 분석된 에러 데이터가 없습니다.",1)])):(o(),l("div",G,[(o(!0),l(B,null,T(r.value,a=>(o(),R(_(F),{key:a.serverId,class:"server-chart-card"},{header:m(()=>[s("div",H,[s("h3",null,"🖥️ "+d(a.serverName),1),s("span",J,d(h(n.value))+" 15분 단위 에러 ("+d(k(a))+"건)",1)])]),default:m(()=>[s("div",K,[s("div",Q,[L(_(z),{data:D(a),options:S},null,8,["data"])])])]),_:2},1024))),128))]))]))}},nt=C(X,[["__scopeId","data-v-b7241be8"]]);export{nt as default};
