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