import{n as u,a$ as E,d as ne,aC as ae,c as g,S as re,Q as oe,f as le,b5 as se,h as R,o as ue,j as ie,Z as y,$ as U,a0 as f,a7 as c,a5 as C,a6 as o,T as r,a9 as P,ay as T,a1 as S,ct as D,D as ce,b9 as de,C as fe,aQ as me,a4 as ve,M as pe,x as ge,aG as _e,bt as be,at as he}from"./index-a8341fa1.js";/* empty css */import"./dayjs-919e6097.js";import{R as ye,a as Ce,r as Oe}from"./pan-3c2a437f.js";import{b as j,c as F}from"./debug-cfb58f15.js";import{u as we}from"./index-7b240cde.js";var ke={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"};const Se=ke;function z(l){for(var e=1;eL.value===se.DARK),v=g({samplingIntervalNs:"0",goroutines:[],functions:[],runtimeStats:{blockingTimeNs:"",gcCount:"",gcCpuFraction:0,gcPauseTimeNs:""}}),G=g(null),_=g(null),H=()=>{Oe()},k=g("");R(N,t=>{p.value==="graph"&&(_.value&&_.value.querySelector("svg")?M(_.value.querySelector("svg")):x())}),R(p,t=>{t==="graph"?x():fe(()=>{Z(v.value)})});const $=we();ue(async()=>{try{n.value=!0,await x()}catch(t){console.error("Failed to load heap data:",t)}finally{n.value=!1;const t=await j();v.value=t}});const Z=t=>{const a=[t];a.length>0&&$.tableRef.reloadData(a)},V=t=>`${(t*1e4).toFixed(3)}‰`,b=(t,a)=>{if(a==="s")return Number(t)/1e6+"秒";if(a==="ns")return Number(t)+"纳秒";if(a==="ms")return(Number(t)/1e3).toFixed(2)+"毫秒"};async function x(){try{k.value||(k.value=await F()),ye().then(t=>{if(!_.value)return;_.value.innerHTML="";const a=t.renderSVGElement(k.value);M(a),_.value.appendChild(a),Ce(a)})}catch(t){console.error("Failed to render graph:",t)}}function M(t){if(!t)return;const a=N.value;t.style.backgroundColor=a?"var(--layout-background)":"#f8f8f8";const O=t.querySelectorAll("polygon, ellipse"),w=t.querySelectorAll("text");O.forEach(h=>{h.setAttribute("fill",a?"#1f1f1f":"#ffffff"),h.setAttribute("stroke",a?"#aaaaaa":"#000000")}),w.forEach(h=>{h.setAttribute("fill",a?"var(--text-color)":"#000000")})}const Q={maxHeight:"100%",rowConfig:{className:()=>N.value?"dark-row":"",isHover:!0},columnConfig:{useKey:!0},columns:[{field:"samplingIntervalNs",get title(){return e("routes.monitor.采样间隔")},formatter:({row:t})=>b(t.samplingIntervalNs,"s")},{field:"gcCpuFraction",get title(){return e("routes.monitor.垃圾回收占用CPU时间比例")},formatter:({row:t})=>V(t.runtimeStats.gcCpuFraction),minWidth:"100px"},{field:"gcCount",get title(){return e("routes.monitor.垃圾回收次数")},formatter:({row:t})=>t.runtimeStats.gcCount},{field:"blockingTimeNs",get title(){return e("routes.monitor.阻塞时间")},formatter:({row:t})=>b(t.runtimeStats.blockingTimeNs,"ns")},{field:"gcPauseTimeNs",get title(){return e("routes.monitor.垃圾回收暂停时间")},formatter:({row:t})=>b(t.runtimeStats.gcPauseTimeNs,"ms")},{field:"functions",get title(){return e("routes.monitor.函数调用栈数量")},formatter:({row:t})=>t.functions.length||0},{field:"goroutines",get title(){return e("routes.monitor.协程数量")},formatter:({row:t})=>t.goroutines.length||0}],data:[]},W=({key:t})=>{J(Number(t))},J=async(t=10)=>{try{n.value=!0,k.value="",m&&m.abort(),m=new AbortController,s.value=t,i&&clearInterval(i),i=setInterval(()=>{s.value>0?(s.value--,d.value=e("routes.monitor.正在分析距离完成还剩",{seconds:s.value})):i&&(clearInterval(i),i=null)},1e3),await F(!0,t,m.signal);const a=await j();v.value=a}catch(a){a.name==="AbortError"?e("routes.monitor.请求已取消"):console.error("Failed to reload data:",a)}finally{i&&(clearInterval(i),i=null),n.value=!1,d.value=e("routes.monitor.正在分析请稍等"),m=null}},X=()=>{i&&(clearInterval(i),i=null),m&&(m.abort(),m=null),n.value=!1,s.value=0,d.value=e("routes.monitor.正在分析请稍等")};return ie(()=>{i&&(clearInterval(i),i=null),m&&(m.abort(),m=null)}),(t,a)=>{const O=me,w=ve,h=pe,Y=ge,K=_e,ee=be;return y(),U(ee,{spinning:n.value,tip:d.value},{indicator:f(()=>[c("div",Ae,[s.value>0?(y(),U(O,{key:0,type:"danger",onClick:X},{default:f(()=>[C(o(r(e)("routes.monitor.取消分析")),1)]),_:1})):P("",!0)])]),default:f(()=>[c("div",{class:T(["heap-container",{"graph-view":p.value==="graph"}])},[c("div",$e,[c("button",{class:T({active:p.value==="graph"}),onClick:a[0]||(a[0]=te=>p.value="graph")},o(r(e)("routes.monitor.图形视图")),3),c("button",{class:T({active:p.value==="text"}),onClick:a[1]||(a[1]=te=>p.value="text")},o(r(e)("routes.monitor.文本视图")),3)]),!n.value&&p.value==="graph"?(y(),S("div",Ve,[c("h3",null,o(r(e)("routes.monitor.CPU统计")),1),v.value.samplingIntervalNs?(y(),S("div",Me,[c("div",null,o(r(e)("routes.monitor.采样间隔"))+": "+o(b(v.value.samplingIntervalNs,"s")),1),c("div",null,o(r(e)("routes.monitor.垃圾回收占用CPU时间比例"))+": "+o(V(v.value.runtimeStats.gcCpuFraction)),1),c("div",null,o(r(e)("routes.monitor.垃圾回收次数"))+": "+o(v.value.runtimeStats.gcCount),1),c("div",null,o(r(e)("routes.monitor.阻塞时间"))+": "+o(b(v.value.runtimeStats.blockingTimeNs,"ns")),1),c("div",null,o(r(e)("routes.monitor.垃圾回收暂停时间"))+": "+o(b(v.value.runtimeStats.gcPauseTimeNs,"ms")),1),c("div",null,o(r(e)("routes.monitor.函数调用栈数量"))+": "+o(v.value.functions.length),1),c("div",null,o(r(e)("routes.monitor.协程数量"))+": "+o(v.value.goroutines.length),1)])):P("",!0)])):P("",!0),p.value==="graph"?(y(),S("div",{key:1,class:"viz-container",ref_key:"vizContainer",ref:G},[c("div",Re,[u(K,null,{default:f(()=>[u(O,{class:"reset-btn",onClick:H},{icon:f(()=>[u(r(Ie))]),default:f(()=>[C(" "+o(r(e)("routes.monitor.重置视图")),1)]),_:1}),u(Y,null,{overlay:f(()=>[u(h,{onClick:W},{default:f(()=>[u(w,{key:"10"},{default:f(()=>[u(r(D)),C(" 10"+o(r(e)("routes.monitor.秒")),1)]),_:1}),u(w,{key:"30"},{default:f(()=>[u(r(D)),C(" 30"+o(r(e)("routes.monitor.秒")),1)]),_:1}),u(w,{key:"60"},{default:f(()=>[u(r(D)),C(" 1"+o(r(e)("routes.monitor.分钟")),1)]),_:1})]),_:1})]),default:f(()=>[u(O,{type:"primary"},{icon:f(()=>[u(r(xe))]),default:f(()=>[C(" "+o(r(e)("routes.monitor.重新分析"))+" ",1),u(r(ce))]),_:1})]),_:1})]),_:1})]),c("div",{class:"main-view",ref_key:"mainView",ref:_},null,512)],512)):(y(),S("div",Ue,[u(r(de),{uid:r($).uid,gridOptions:Q},null,8,["uid"])]))],2)]),_:1},8,["spinning","tip"])}}});const Ge=he(je,[["__scopeId","data-v-45bbc243"]]);export{Ge as default}; //# sourceMappingURL=cpu-52d6f347.js.map