"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[70995],{13994:(e,t,a)=>{a.d(t,{A:()=>d});var r=a(296540),o=a(112142),n=a(66706),l=a(71479),i=a(132196),s=a(294303);const m=i.AH`
  overflow: visible;
`,c=(0,l.A)(s.A,{shouldForwardProp:e=>!["innerColor","outerColor"].includes(e)})`
  g {
    transition: unset;
  }
  circle {
    &:first-child {
      ${({outerColor:e})=>e?`fill: ${e};`:""}
    }
    &:last-child {
      ${({innerColor:e})=>e?`fill: ${e};`:""}
    }
  }
`,u=({chartWidth:e,chartHeight:t,top:a,left:o,innerColor:l,outerColor:i="#fff"})=>r.createElement(c,{position:"absolute",top:0,left:0,zIndex:2,innerColor:l,outerColor:i,pointerEvents:"none"},r.createElement("svg",{width:e,height:t,className:m},o&&a&&r.createElement(n.A,{hasAnimation:!1,x:o,y:a}))),h=({topA:e,leftA:t,topB:a,leftB:o})=>r.createElement(s.A,{zIndex:1,borderLeft:"2px dashed white",top:Math.min(e,a),height:Math.max(e,a)-Math.min(e,a),left:(t+o)/2-1,position:"absolute"}),d=({width:e,topA:t,leftA:a,topB:n,leftB:l,chartWidth:i,chartHeight:s,hidden:m,description:c,innerColor:d,tooltipRenderCondition:p,tooltipProps:f={},useSideSwapping:E=!0})=>m?null:r.createElement(r.Fragment,null,p?r.createElement(o.A,{width:e,left:E?a+(a<Math.round(i/2)?8:-8):a-8,top:(t+n)/(n?2:1),description:c,hidden:m,topMargin:4,tooltipProps:{maxWidth:"auto",...!f.position&&E&&a&&i&&{position:a<Math.round(i/2)?"right":"left"},portal:!0,...f}}):null,l&&n?r.createElement(h,{topA:t,topB:n,leftA:a,leftB:l}):null,r.createElement(u,{chartWidth:i,chartHeight:s,top:t,left:a,innerColor:d}))},470995:(e,t,a)=>{a.d(t,{A:()=>F});var r=a(296540),o=a(86571),n=a(689965),l=a(469733),i=a(927099),s=a(979106),m=a(566723),c=a(294303),u=a(699784),h=a(212401),d=a(656372),p=a(584916),f=a(874734),E=a(945132);const C=e=>{switch(e){case p.l.ONE_WEEK:return f.FE.HOURLY;case p.l.ONE_MONTH:return f.FE.DAILY;case p.l.ONE_DAY:default:return f.FE.MINUTES}},g=({value:e,index:t,lessThanHour:a,scale:r,from:o,to:n,siteTimezone:l,language:i,selfHourCycle:s,formatMessage:m})=>{if(6===t)return m({id:"COMMON_NOW"});if(a)return 0===t?m({id:"COMMON_GRANULARITY_MINS_CUSTOM"},{minutes:Math.ceil((n-o)/6e4)}):null;if(r===f.FE.MINUTES)return 0===t?m({id:"COMMON_GRANULARITY_HRS_CUSTOM"},{hours:Math.ceil((n-o)/E.$_)}):null;switch(t){case 0:case 2:case 4:return new Intl.DateTimeFormat(i,{day:"numeric",month:"short",timeZone:l,hourCycle:s}).format(e);default:return null}};var y,M=a(340936),T=a(936344),A=a(998837),S=a(195462),D=a(282556),O=a(602021),P=a(198494);!function(e){e.MEMORY="memory",e.CPU="cpu"}(y||(y={}));var b=a(13994);const w=e=>{switch(e){case f.FE.MINUTES:return 3e5;case f.FE.HOURLY:return E.$_;case f.FE.DAILY:return E.jU;default:return 0}},v=({timestamp:e,siteTimezone:t,language:a,selfHourCycle:r,scale:o})=>new Intl.DateTimeFormat(a,{day:"numeric",month:"short",year:"numeric",...o!==f.FE.DAILY&&{hour:"numeric",minute:"numeric"},timeZone:t,hourCycle:r}).format(e),N=({value:e=0,clients:t=0,timestamp:a=0,top:o=0,left:n=0,memoryProps:{top:l=0,left:s=0,value:m=0},chartWidth:h,chartHeight:d,hidden:p,color:f,tooltipRenderCondition:E,siteTimezone:C,language:g,selfHourCycle:y,scale:M,hasCpuTimeSeriesData:T,hasMemoryTimeSeriesData:A})=>r.createElement(b.A,{width:300,topA:o,leftA:n,topB:l,leftB:s,chartWidth:h,chartHeight:d,hidden:p,description:r.createElement(c.A,{flexDirection:"column"},r.createElement(c.A,{justifyContent:"space-between",marginBottom:8},r.createElement(i.A,{size:"label",color:"secondary"},r.createElement(u.sA,{id:"COMMON_TIME"})),r.createElement(i.A,{size:"label",color:"secondary"},v({timestamp:a,siteTimezone:C,language:g,selfHourCycle:y,scale:M})," - ",v({timestamp:a+w(M),siteTimezone:C,language:g,selfHourCycle:y,scale:M}))),T?r.createElement(c.A,{justifyContent:"space-between",marginBottom:8},r.createElement(i.A,{size:"label",color:"secondary"},r.createElement(u.sA,{id:"COMMON_CPU"})),r.createElement(i.A,{size:"label",color:"secondary"},e.toFixed(2),"%")):null,A?r.createElement(c.A,{justifyContent:"space-between",marginBottom:8},r.createElement(i.A,{size:"label",color:"secondary"},r.createElement(u.sA,{id:"COMMON_MEMORY"})),r.createElement(i.A,{size:"label",color:"secondary"},m.toFixed(2),"%")):null,T?r.createElement(c.A,{justifyContent:"space-between"},r.createElement(i.A,{size:"label",color:"secondary"},r.createElement(u.sA,{id:"COMMON_CLIENTS"})),r.createElement(i.A,{size:"label",color:"secondary"},t)):null),innerColor:f,tooltipRenderCondition:E,useSideSwapping:!1,tooltipProps:{position:"left",portal:!0}});var R=a(964238);const _=e=>`${e}GradientId`,x=({timeSeriesData:e,maxY:t,mouseData:a,getCoordinates:o,tooltipContainer:n,renderTooltip:l,systemPerformanceGraphType:i,motifPalette:s})=>{const m=((e,t)=>t[e===y.CPU?"uBlue06":"purple06"])(i,s),c=(0,r.useCallback)(()=>r.createElement("defs",null,r.createElement("linearGradient",{id:_(i),x1:"0%",y1:"0%",x2:"0%",y2:"100%"},r.createElement("stop",{offset:"0%",stopColor:m,stopOpacity:.5}),r.createElement("stop",{offset:"100%",stopColor:m,stopOpacity:.1}))),[i,m]),u=(0,r.useCallback)(e=>l({systemPerformanceGraphType:i,gradientColor:m})(e),[m,l,i]);return r.createElement(R.A,{data:e,maxY:t,mouseData:a,getCoordinates:o,variant:"gradientArea",interpolation:"curved",lineColor:m,customGradientId:_(i),renderCustomGradient:c,tooltipPortal:n?.current,renderTooltip:u})},H=(0,r.memo)(({deviceSystemPerformanceReport:e,deviceSystemPerformanceReportData:t,cpuTimeSeriesData:a,memoryTimeSeriesData:o,hasCpuTimeSeriesData:n,hasMemoryTimeSeriesData:i,scale:s,formatMessage:m})=>{const u=(0,r.useRef)(null),h=(0,r.useRef)(null),{ref:d,width:p=0,height:f=0}=(0,M.A)(),C=(0,r.useRef)({top:0,left:0,value:0}),{motifPalette:b}=(0,A.u)(),w=(0,l.useSelector)(O.hq),v=(0,l.useSelector)(D.zi),R=(0,l.useSelector)(P.BQ),_=p+20,H=(0,r.useMemo)(()=>t.length?Math.max(...t.map(({cpu:e=0,mem:t=0})=>[Math.round(e),Math.round(t)]).flat()):100,[t]),z=(0,r.useMemo)(()=>(0,S.Y)(Math.ceil(Math.min(H+1/3*H,100)),6),[H]),I=(0,r.useMemo)(()=>{const t=e[0]?.time||Date.now()-E.jU,a=e.length>1&&e[e.length-1]?.time||Date.now();return(0,S.v)([t,a],7).map((e,r)=>({value:e,label:g({value:e,index:r,lessThanHour:a-t<E.$_,scale:s,from:t,to:a,siteTimezone:w,language:v,selfHourCycle:R,formatMessage:m})}))},[e,s,R,w,v,m]),Y=(0,r.useCallback)(({systemPerformanceGraphType:e,gradientColor:a})=>(({systemPerformanceGraphType:e,memoryProps:t,chartWidth:a,chartHeight:o,deviceSystemPerformanceReportLength:n,gradientColor:l,siteTimezone:i,language:s,selfHourCycle:m,scale:c,hasCpuTimeSeriesData:u,hasMemoryTimeSeriesData:h})=>({top:d=0,left:p=0,hidden:f,x:E,y:C,custom:g={clients:0}})=>(e===y.MEMORY&&(t.current={top:d,left:p,value:C}),r.createElement(N,{value:C,clients:g.clients,timestamp:E,top:d,left:p,memoryProps:t.current,chartWidth:a,chartHeight:o,hidden:f||n<2,color:l,tooltipRenderCondition:1===[u,h].filter(Boolean).length||e===y.CPU,siteTimezone:i,language:s,selfHourCycle:m,scale:c,hasCpuTimeSeriesData:u,hasMemoryTimeSeriesData:h})))({systemPerformanceGraphType:e,gradientColor:a,chartHeight:f,chartWidth:_,memoryProps:C,deviceSystemPerformanceReportLength:t.length,siteTimezone:w,language:v,selfHourCycle:R,scale:s,hasCpuTimeSeriesData:n,hasMemoryTimeSeriesData:i}),[f,_,w,v,R,t.length,n,i,s]),U=(0,r.useCallback)((e,t,l)=>r.createElement(r.Fragment,null,n?r.createElement(x,{timeSeriesData:a,maxY:l,mouseData:t,getCoordinates:e,systemPerformanceGraphType:y.CPU,motifPalette:b,tooltipContainer:h,renderTooltip:Y}):null,i?r.createElement(x,{timeSeriesData:o,maxY:l,mouseData:t,getCoordinates:e,systemPerformanceGraphType:y.MEMORY,motifPalette:b,tooltipContainer:h,renderTooltip:Y}):null),[o,b,a,n,i,Y]);return r.createElement(c.A,{width:"100%",height:"100%",flexDirection:"column"},r.createElement(c.A,{ref:u},r.createElement(c.A,{width:"100%",height:"100%",minHeight:190,position:"relative",ref:d},r.createElement(T.A,{xAxis:I,yAxis:z,width:_,height:f,margin:[20,20,30,20]},U),r.createElement("div",{ref:h}))))});var z=a(664967);const I=[z.E[p.l.ONE_DAY],z.E[p.l.ONE_WEEK],z.E[p.l.ONE_MONTH]];var Y=a(479546);let U=[];const B=(0,r.memo)(({mac:e,object:t})=>{const{formatMessage:a}=(0,u.tz)(),o=(0,l.useDispatch)(),[n,f]=(0,r.useState)({startTime:I.find(({id:e})=>e===p.l.ONE_DAY).getRange(new Date).startDate.getTime(),scale:C(p.l.ONE_DAY)}),E=(0,r.useMemo)(()=>I.map(({id:e,message:t})=>({id:e,label:a({id:t})})),[a]);(0,r.useEffect)(()=>{e&&n.startTime&&n.scale&&t&&o((0,d.wv)(e,n.startTime,n.scale,t))},[o,e,n,t]);const g=(0,r.useCallback)(e=>f({startTime:I.find(({id:t})=>t===e.id).getRange(new Date).startDate.getTime(),scale:C(e.id)}),[]),y=(0,l.useSelector)((0,h.U2)(e,n.startTime,n.scale,t)),M=(0,r.useMemo)(()=>[...y.length?y:U],[y]);(0,r.useEffect)(()=>{y.length&&(U=[...y])},[y]);const{cpuTimeSeriesData:T,memoryTimeSeriesData:A}=(0,r.useMemo)(()=>{const e=[],t=[];return M.forEach(({time:a,cpu:r,mem:o,num_sta:n})=>{e.push({x:a,y:r,custom:{clients:n}}),t.push({x:a,y:o,custom:{clients:n}})}),{cpuTimeSeriesData:e,memoryTimeSeriesData:t}},[M]),{hasCpuTimeSeriesData:S,hasMemoryTimeSeriesData:D}=(0,r.useMemo)(()=>({hasCpuTimeSeriesData:T.some(({y:e})=>Boolean(e)),hasMemoryTimeSeriesData:A.some(({y:e})=>Boolean(e))}),[T,A]);return r.createElement(c.A,{flexDirection:"column"},r.createElement(Y.aW,null,r.createElement(s.A,{variant:"filter",tabs:E,onSelectTab:g})),r.createElement(c.A,{justifyContent:"space-between",marginTop:m.Ln},r.createElement(i.A,{size:"body",weight:"bold"},r.createElement(u.sA,{id:"COMMON_USAGE"})," (%)"),r.createElement(c.A,null,S?r.createElement(c.A,{alignItems:"center",marginRight:m.xO},r.createElement(Y.SY,null),r.createElement(i.A,{style:{marginLeft:m.kc},size:"caption",color:"tertiary"},r.createElement(u.sA,{id:"COMMON_CPU"}))):null,D?r.createElement(c.A,{alignItems:"center"},r.createElement(Y.ZJ,null),r.createElement(i.A,{style:{marginLeft:m.kc},size:"caption",color:"tertiary"},r.createElement(u.sA,{id:"COMMON_MEMORY"}))):null)),r.createElement(H,{deviceSystemPerformanceReport:y,deviceSystemPerformanceReportData:M,cpuTimeSeriesData:T,memoryTimeSeriesData:A,hasCpuTimeSeriesData:S,hasMemoryTimeSeriesData:D,scale:n.scale,formatMessage:a}))}),F=(0,r.memo)(({mac:e,object:t})=>r.createElement(n.A,{type:n.I.ACCORDION,items:[{id:"systemPerformance",openByDefault:!1,label:r.createElement(o.A,{id:"DEVICE_PROPERTY_SYSTEM_STATISTICS"}),renderContent:()=>r.createElement(B,{mac:e,object:t})}]}))}}]);