var f=Object.defineProperty;var k=(t,e,a)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var s=(t,e,a)=>(k(t,typeof e!="symbol"?e+"":e,a),a);import{a$ as C,a as v,r as p,cW as w,j as o,C as P,J as S,d6 as j,hG as I,hH as M,hI as N,hJ as R,hK as L,hL as T,hN as A,hM as q,hR as E,hQ as u}from"./index-DxWYYOj0.js";import{u as _,a as g}from"./unknownify-BC8oAPjr.js";import{L as D}from"./index-COns9WGJ.js";class H{constructor(e){s(this,"current",0);s(this,"all");this.all=e}next(){const e=this.all[this.current];return this.current=(this.current+1)%this.all.length,e}}const h=["circle","rect","rectRounded","rectRot","triangle"],W=(t,e)=>t.map(a=>({x:a[0],y:e(a[1])})),$=(t,e)=>({locale:e.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:t.palette.text.secondary,plugins:{tooltip:{backgroundColor:t.palette.background.paper,bodyColor:t.palette.text.primary,titleColor:t.palette.action.active,borderColor:t.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,callbacks:{title:a=>u(1e3*a[0].parsed.x,e.locale)},itemSort:(a,i)=>i.parsed.y-a.parsed.y},legend:{position:"bottom",align:"start",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0,padding:24}},title:{text:"Top 10 requests per second in the last 6 hours",position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:t.palette.text.primary,padding:{bottom:32}}},scales:{y:{type:"linear",title:{display:!0,text:"Requests per second",color:t.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:t.palette.text.secondary},grid:{color:t.palette.divider,borderColor:t.palette.divider}},x:{type:"time",time:{unit:"minute"},grid:{display:!0,color:t.palette.divider,borderColor:t.palette.divider},ticks:{callback:(a,i,r)=>u(r[i].value*1e3,e.locale)}}}});class J{constructor(e){s(this,"items");s(this,"picked",new Map);this.items=new H(e)}pick(e){return this.picked.has(e)||this.picked.set(e,this.items.next()),this.picked.get(e)}}const z=(t,e)=>{var a;if((a=e==null?void 0:e.data)!=null&&a.result){const i=new J([t.palette.success,t.palette.error,t.palette.primary,t.palette.warning]);return e.data.result.map((r,m)=>{var c,d;const n=g((c=r.metric)==null?void 0:c.endpoint),x=g((d=r.metric)==null?void 0:d.appName),l=i.pick(n),y=r.values||[];return{label:`${n}: ${x}`,borderColor:l.main,backgroundColor:l.main,data:W(y,b=>Number.parseFloat(b)),elements:{point:{radius:4,pointStyle:h[m%h.length]},line:{borderDash:[8,4]}}}})}return[]},O=()=>{const{locationSettings:t}=C(),{metrics:e}=_(),a=v(),i=p.useMemo(()=>$(a,t),[a,t]);w("Network - Traffic");const r=p.useMemo(()=>({datasets:z(a,e)}),[a,e,t]);return o.jsx(P,{condition:r.datasets.length===0,show:o.jsx(S,{severity:"warning",children:"No data available."}),elseShow:o.jsx(j,{sx:{display:"grid",gap:4},children:o.jsx("div",{style:{height:400},children:o.jsx(D,{data:r,options:i,"aria-label":"An instance metrics line chart with two lines: requests per second for admin API and requests per second for client API"})})})})};I.register(M,N,R,L,T,A,q,E);export{O as NetworkTraffic,O as default};
