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{Ft as x,W as S,Zn as C,et as w,kr as T,za as E}from"./icons-vendor-Buq6V-Ga.js";import{Et as D}from"./index-y6crcKNt.js";import{t as O}from"./MonitorChartViewer-Bf111JuV.js";import{i as k}from"./admin-monitor-Bvq7GwsD.js";import{t as A}from"./MonitorSmoothToggle-Borh7dmQ.js";import{t as j}from"./ZFilterSegment-Cj06RCbT.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:S,iconClass:`bg-zp/10 text-zp`},memory:{title:`内存使用率趋势`,icon:E,iconClass:`bg-success-soft text-success`},upload:{title:`上行速率趋势`,icon:w,iconClass:`bg-zp/10 text-zp`},download:{title:`下行速率趋势`,icon:x,iconClass:`bg-success-soft text-success`}},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-zf-sm px-2 py-1 text-xs text-secondary transition hover:text-primary disabled:cursor-not-allowed disabled:opacity-40`,title:`导出为 PNG`,onClick:Q},[u(d(T),{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(C),{class:`h-8 w-8 text-danger`}),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};