import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{a as t,ot as n}from"./element-plus-vendor-BF9PNysW.js";import{A as r,D as i,E as a,I as o,N as s,O as c,Ot as l,P as u,Pt as d,Tt as f,Xt as p,et as m,gt as h,ht as g,k as _,ot as v,pt as y,qt as b}from"./vue-vendor-DMUmTARL.js";import{Vt as x,ar as S,hr as C,ot as w,q as T,wa as E}from"./icons-vendor-Db5MGAkr.js";import{t as D}from"./ZDialog-D5yc_FjB.js";import{t as O}from"./MonitorChartViewer-CcjrfrrU.js";import{i as k}from"./admin-monitor-DgL7mwX_.js";import{t as A}from"./MonitorSmoothToggle-CLWLevRc.js";import{t as j}from"./ZFilterSegment-D4BWXb6b.js";var M={class:`flex items-center gap-2`},N={key:0,class:`flex flex-col gap-3`},P={class:`flex items-center justify-between gap-2`},F={class:`flex items-center gap-3`},I=[`disabled`],L={key:0,class:`flex h-80 w-full flex-col items-center justify-center gap-2 sm:h-[420px]`},R={key:1,class:`min-h-80 sm:min-h-[420px]`},z=o({__name:`MonitorChartDialog`,props:{visible:{type:Boolean},type:{},history:{}},emits:[`update:visible`],setup(e,{emit:o}){let z=e,B=o,V=a({get:()=>z.visible,set:e=>B(`update:visible`,e)}),H=[{label:`近10min`,value:`recent`},{label:`1h`,value:`1h`},{label:`6h`,value:`6h`},{label:`24h`,value:`24h`},{label:`全部`,value:`all`}],U=f(`recent`),W=l([]),G=f(!1),K=f(!1),q=a(()=>U.value===`recent`?z.history||[]:W.value),J=()=>{if(U.value===`recent`){G.value=!1,K.value=!1;return}G.value=!0,K.value=!1,k(U.value).then(e=>{W.value=e.data||[],K.value=!1}).catch(()=>{K.value=!0}).finally(()=>{G.value=!1})};y(U,()=>J()),y(()=>z.visible,e=>{e&&(U.value=`recent`,W.value=[],K.value=!1,G.value=!1)});let Y={cpu:{title:`CPU 使用率趋势`,icon:T,iconClass:`bg-blue-50 text-blue-600 dark:bg-blue-500/20 dark:text-blue-300`},memory:{title:`内存使用率趋势`,icon:E,iconClass:`bg-green-50 text-green-600 dark:bg-emerald-500/20 dark:text-emerald-300`},upload:{title:`上行速率趋势`,icon:w,iconClass:`bg-blue-50 text-blue-600 dark:bg-blue-500/20 dark:text-blue-300`},download:{title:`下行速率趋势`,icon:x,iconClass:`bg-green-50 text-green-600 dark:bg-emerald-500/20 dark:text-emerald-300`}},X=a(()=>Y[z.type]),Z=f(null),Q=()=>{Z.value?.exportChart(`monitor-`+z.type)};return(a,o)=>{let l=n,f=t;return m(),c(D,{modelValue:V.value,"onUpdate:modelValue":o[1]||=e=>V.value=e,class:`zf-dialog-max-w-95`,"show-footer":!1,"hidden-full-btn":!0,width:`800px`,"destroy-on-close":``},{header:g(()=>[i(`div`,M,[i(`span`,{class:b([`flex h-7 w-7 items-center justify-center rounded-zf-md`,X.value.iconClass])},[(m(),c(v(X.value.icon),{class:`h-4 w-4`}))],2),i(`span`,null,p(X.value.title),1)])]),default:g(()=>[V.value?(m(),r(`div`,N,[i(`div`,P,[i(`div`,F,[u(A),i(`button`,{type:`button`,disabled:!Z.value,class:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-zinc-500 transition hover:text-zinc-700 disabled:cursor-not-allowed disabled:opacity-40 dark:hover:text-zinc-300`,title:`导出为 PNG`,onClick:Q},[u(d(C),{class:`h-3.5 w-3.5`}),o[2]||=s(` 导出 `,-1)],8,I)]),u(j,{modelValue:U.value,"onUpdate:modelValue":o[0]||=e=>U.value=e,options:H,"aria-label":`趋势时间范围`},null,8,[`modelValue`])]),K.value?(m(),r(`div`,L,[u(d(S),{class:`h-8 w-8 text-red-400`}),o[4]||=i(`p`,{class:`text-sm text-secondary`},`趋势数据加载失败`,-1),u(l,{size:`small`,link:``,type:`primary`,onClick:J},{default:g(()=>[...o[3]||=[s(`重试`,-1)]]),_:1})])):h((m(),r(`div`,R,[u(O,{ref_key:`viewerRef`,ref:Z,type:e.type,history:q.value},null,8,[`type`,`history`])])),[[f,G.value]])])):_(``,!0)]),_:1},8,[`modelValue`])}}}),B=e({default:()=>V}),V=z;export{B as n,V as t};