File: //opt/netdata/usr/local/share/netdata/web/v3/4597.01c9cdecd37e4c123bce.chunk.js
try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c2569802-aa84-48c1-93d0-6593c7c0e268",e._sentryDebugIdIdentifier="sentry-dbid-c2569802-aa84-48c1-93d0-6593c7c0e268")}()}catch(e){}!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"c7a85fdbc93bb7925a0f36510d6eb791929e4aa8"}}catch(e){}}(),(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[4597],{4719:(e,t,n)=>{n.d(t,{BV:()=>d,Dv:()=>g,Qb:()=>m,aV:()=>h,b:()=>u,tu:()=>l,yy:()=>c});var r=n(83488),o=n.n(r),i=n(66814),s=n(27250),a=n(74848);const l=(0,i.q6)({}),d=e=>{let{menuById:t,children:n}=e;return(0,a.jsx)(l.Provider,{value:t,children:n})},c=e=>(0,s.A)(l,e),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return c((n=>t(n?.[e]||{})))},h=(e,t)=>n=>{let{id:r,...o}=n;const i=u(r,t);return(0,a.jsx)(e,{_id:r,...i,...o})},f=(0,i.q6)([]),g=e=>{let{ids:t,children:n}=e;return(0,a.jsx)(f.Provider,{value:t,children:n})},m=e=>t=>{const n=(0,s.A)(f,r);var r;return(0,a.jsx)(e,{menuIds:n,...t})}},14512:(e,t,n)=>{n.d(t,{A:()=>A,g:()=>x});var r=n(96540),o=n(33185),i=n(63766),s=n(45087),a=n(24013),l=n(87083),d=n(19186),c=n(24609),u=n(24200),h=n(64463),f=n(74891),g=n(3319),m=n(74848);const y=(0,o.default)(i.IconComponents.LoaderIcon).withConfig({displayName:"anomalyRates__StyledLoaderIcon",componentId:"sc-1b01y04-0"})(["flex:0 0 auto;height:16px;width:16px;"]),b=(0,f.A)(i.Flex),v=()=>(0,m.jsxs)(b,{height:"20px",alignItems:"center",gap:1,tooltip:"Loading weights. This might take some time.",children:[(0,m.jsx)(y,{}),(0,m.jsx)(i.TextSmall,{children:"Loading..."})]}),p=(0,f.A)(i.Button),x=()=>{const e=(0,a.nl)(),t=(0,l.w7)();return e?[e]:t},A=()=>{const[e,t]=(0,r.useState)(),n=(0,c.vt)(),o=(0,d.ID)(),a=x(),{pause:l}=(0,h.A)(),{sendLog:f}=(0,g.A)(),[y,b,,A]=(0,u.f_)(n,o,a),w=(0,r.useCallback)((()=>{l(),y(),f({feature:"AnomalyRates-TOC",label:"Anomaly%",isStart:!0},!0)}),[l,y,f]),I=(0,r.useCallback)((e=>{let{target:n}=e;const r=n.checked;t(r),r?w():A()}),[t,w,A]);return(0,m.jsx)(i.Flex,{alignItems:"center",justifyContent:"between",width:"100%",margin:[2,0,0,0],padding:[2,0,0,0],children:b?(0,m.jsx)(v,{}):(0,m.jsxs)(i.Flex,{alignItems:"center",justifyContent:"between",width:"100%",children:[(0,m.jsx)(s.A,{content:"Overlay the maximum chart anomaly rate on each menu section.",align:"bottom",activateOn:"hover",isBasic:!0,children:(0,m.jsx)(i.Box,{children:(0,m.jsx)(i.Toggle,{colored:!0,disabled:b,checked:e,labelRight:"Anomaly Rate %",onChange:I,toggleProps:{uncheckedColor:["neutral","grey130"],checkedColor:"primary"}})})}),e?(0,m.jsx)(p,{flavour:"borderless",icon:"refresh",iconColor:"text",onClick:w,tooltip:"Refresh weights"}):null]})})}},24200:(e,t,n)=>{n.d(t,{Ay:()=>f,yD:()=>u,f_:()=>h});n(98992),n(54520),n(81454);var r=n(96540),o=n(42790),i=n(77611);const s=function(e){let{after:t,before:n}=e,{offset:r,limit:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{offset:6e4,limit:Date.now()};const i=((e,t)=>{let{offset:n,limit:r}=t;const o=n/2;return e+o<=r?o:r<e?0:r-e})(n,{offset:r,limit:o});return[t-(r-i),n+i]};var a=n(3319),l=n(81691);const d=(e,t)=>e||t?s({after:parseInt(e),before:parseInt(t)},(e=>{const t=Date.now();return{limit:t,offset:t-e<6e4?3e4:15e3}})(t)):c,c=[null,null],u=()=>{const{after:e,before:t,highlight:n}=(0,o.rW)();if(!n.after||!n.before)return c;if(e<0){const t=Date.now();if(n.before<t+e)return c;if(n.after>t)return c}else{if(n.before<e)return c;if(n.after>t)return c}return[n.after,n.before]},h=(e,t,n)=>{const[s,c]=(0,r.useState)(),[h,f]=(0,r.useState)(!1),{sendLog:g}=(0,a.A)();let[m,y]=(()=>{const e=u();return(0,r.useMemo)((()=>d(...e)),[...e])})();const{after:b,before:v}=(0,o.rW)(),[p,x]=(0,i.er)({nodeIds:n,flavour:"rhs"},e,t);return[async()=>{const e=((e,t)=>{if(e<0){const n=Date.now();e=1e3*Math.floor(n/1e3+e),t=1e3*Math.floor(n/1e3)}return{after:e,before:t}})(b,v);f(!0);try{await p({flavour:"rhs",highlightAfter:m||e.after,highlightBefore:y||e.before,baselineAfter:m?e.after:null,baselineBefore:y?e.before:null,method:"anomaly-rate",aggregation:"avg",group:"average",nodeIds:n,options:["raw","null2zero"],groupBy:["context"]}),f(!1),g({action:l.o1.elementViewed,feature:"AnomalyRates-TOC",isSuccess:!0},!0)}catch(t){if(t.isCancel)return;c(t),f(!1),g({action:l.o1.elementViewed,feature:"AnomalyRates-TOC",isFailure:!0},!0)}},h,s,x]},f=(e,t,n)=>{const[s,l]=(()=>{const[e,t]=(0,r.useState)(0);return[e,(0,r.useCallback)((()=>t((e=>e+1))),[])]})(),[d,c]=(0,r.useState)(),[h,f]=u(),{after:g,before:m}=(0,o.rW)(),{contexts:y,metadata:b,getWeights:v,loading:p}=(0,i.Yy)({nodeIds:n,flavour:"anomaly"},e,t),{sendLog:x,isReady:A}=(0,a.A)();(0,r.useEffect)((()=>{if(h&&f&&f&&h)try{x({feature:"AnomalyAdvisor",isStart:!0}),v({highlightAfter:h,highlightBefore:f,baselineAfter:g,baselineBefore:m,method:"anomaly-rate",aggregation:"avg",group:"average",nodeIds:n,options:["null2zero","raw"],groupBy:["dimension","instance","context"]})}catch(e){if(x({feature:"AnomalyAdvisor",isFailure:!0}),e.isCancel)return;c(e)}}),[n.length,f,h,s,A]);return[(0,r.useMemo)((()=>y.filter((e=>(b[e]?.weight||0)>0)).sort(((e,t)=>{const n=b[e].weight||0,r=b[t].weight||0;return n!==r?n>r?-1:1:0})).map((e=>{const t=e.split(",");return t.length>1?`${t[2]}::${t[1]}::${t[0]}`:e}))),[y,b]),y,b,p,d,l]}},25291:(e,t,n)=>{n.d(t,{A:()=>d});var r=n(64867),o=n(42790),i=n(53749),s=n(97940),a=n(96540),l=n(258);const d=function(e,t){let{spaceId:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[d,c]=(0,a.useState)(null),{after:u,before:h}=(0,o.rW)(),f=(0,a.useRef)();f.current={after:u<0?u:Math.floor(u/1e3),before:u<0?0:Math.ceil(h/1e3)};const g=(0,a.useRef)(!0),m=e=>{if(e&&e?.response){const{data:t}=e.response,{errorMsgKey:n}=t;c(n)}else v((e=>({...e,contextsHardHash:"invalid"}))),c(e)},y=(0,a.useMemo)((()=>(0,r.O)(d)?5e3:65e3),[d]),b=(0,a.useRef)(),v=(0,i.DQ)(e,!0),p=e=>{let{results:t,versions:n}=e;v((e=>({...e,contextsHardHash:"invalid",...n}))),c((!t||!Object.keys(t).length)&&"No data for this period")};return(0,s.A)((()=>({cache:!1,key:`spaces.${n}.rooms.${e}.charts`,polling:!0,autorun:!!n&&!!e,fetch:()=>(g.current=!1,(0,l.a9)(n,e,t,{...f.current})),association:{getIds:()=>(0,i.Uo)({roomId:e,merge:b.current===t}),getError:()=>(0,i.Zr)({id:e,key:"error"}),getLoaded:()=>(0,i.Zr)({id:e,key:"loaded"}),getUpdatedAt:()=>(0,i.Zr)({id:e,key:"updatedAt"})},getResource:t=>(0,i.YP)({id:e,key:t}),getResourcesInitializer:()=>{const n=(0,i.b0)({id:e,merge:b.current===t,nodeIds:t});return b.current=t,n},getResourceInitialState:e=>({fullyLoaded:!0,...e}),onFail:m,pollingOptions:{pollingInterval:y},onReceive:p,after:u,nodeIds:t,force:!0,throwAllErrors:!0})),[n,e,y,t,u,h]),d}},27250:(e,t,n)=>{n.d(t,{A:()=>d});var r=n(96540),o=n(83488),i=n.n(o),s=n(2404),a=n.n(s),l=n(66814);const d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i();const n=(0,r.useRef)();return(0,l.i7)(e,(e=>{const r=t(e);return a()(n.current,r)||(n.current=r),n.current}))}},33962:(e,t,n)=>{n.d(t,{Js:()=>h,Ny:()=>d,Ud:()=>c,W2:()=>u});var r=n(96540),o=n(66814),i=n(27250),s=n(74848);const a=(0,o.q6)(""),l=(0,o.q6)(""),d=e=>{let{menuId:t="",children:n}=e;const[o,i]=(0,r.useState)(t);return(0,s.jsx)(a.Provider,{value:i,children:(0,s.jsx)(l.Provider,{value:o,children:n})})},c=()=>(0,i.A)(a),u=e=>(0,i.A)(l,e),h=e=>u((t=>e===t))},50239:(e,t,n)=>{n.d(t,{Cs:()=>a,Gr:()=>d,UH:()=>l});var r=n(96540),o=n(74848);const i=(0,r.createContext)(),s=(0,r.createContext)(),a=e=>{let{children:t}=e;const[n,a]=(0,r.useState)();return(0,o.jsx)(i.Provider,{value:n,children:(0,o.jsx)(s.Provider,{value:a,children:t})})},l=()=>(0,r.useContext)(i),d=()=>(0,r.useContext)(s)},53749:(e,t,n)=>{n.d(t,{Zr:()=>h,b0:()=>I,YP:()=>w,Uo:()=>x,Bu:()=>B,yO:()=>j,bD:()=>O,OL:()=>v,aZ:()=>p,rx:()=>m,bo:()=>g,_0:()=>f,R7:()=>C,jI:()=>y,w1:()=>k,DQ:()=>b});n(98992),n(8872),n(37550),n(25509),n(65223),n(60321),n(41927),n(11632),n(64377),n(66771),n(12516),n(68931),n(52514),n(35694),n(52774),n(49536),n(21926),n(94483),n(16215);var r=n(96540),o=n(52035),i=n(34843),s=n(84929),a=n(30569);const l={loaded:!1,fullyLoaded:!1,loading:!1,id:"",name:"",chartType:"",context:"",family:"",firstEntry:0,lastEntry:0,module:"",plugin:"",priority:0,updateEvery:0,visible:!1,filteredOut:!1,hidden:!1,domain:"room"};var d=n(19186),c=n(57377);const u={ids:(0,s.Iz)((()=>(0,o.eU)([]))),updatedAt:(0,s.Iz)((()=>(0,o.eU)(""))),loaded:(0,s.Iz)((()=>(0,o.eU)(!1))),error:(0,s.Iz)((()=>(0,o.eU)(null))),versions:(0,s.Iz)((()=>(0,o.eU)({}))),fetchedFor:(0,s.Iz)((()=>(0,o.eU)([])))},h=(0,s.Iz)((e=>{let{id:t,key:n}=e;return(0,o.eU)((e=>e(u[n](t))),((e,r,o)=>r(u[n](t),o)))}),c.Ay),f=e=>!!(0,i.md)(h({id:e,key:"loaded"})),g=e=>(0,i.md)(h({id:e,key:"fetchedFor"})),m=e=>(0,i.md)(h({id:e,key:"error"})),y=e=>(0,i.md)(h({id:e,key:"versions"})),b=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=(0,i.Xr)(h({id:e,key:"versions"}));return(0,r.useCallback)((e=>n((n=>(e="function"===typeof e?e(n):e,t?e:(0,c.Ay)(n,e,{omit:["contextsSoftHash"]})?n:n.contextsHardHash&&"invalidating"!==n.contextsHardHash?e:n)))),[])},v=e=>(0,i.md)(h({id:e,key:"ids"})),p=(e,t)=>(0,i.md)(h({id:e,key:t})),x=(0,s.Iz)((e=>{let{roomId:t,merge:n=!0}=e;return(0,o.eU)((e=>e(u.ids(t))),((e,r,o)=>{r(u.ids(t),(e=>{const t=n?[...new Set([...o(e),...e])]:o(e);return n&&(0,c.Ay)(t,e)?e:t}))}))}),c.Ay),A=(0,s.Iz)((()=>(0,o.eU)({}))),w=(0,s.Iz)((e=>{let{id:t,key:n}=e;return(0,o.eU)((e=>{const r=e(A(t))||l;return n?r[n]:r}),((e,r,o)=>{"function"!==typeof o?Object.keys(o).length<1||r(A(t),(e=>({...e,[n]:o}))):r(A(t),(e=>({...e,[n]:o(e[n])})))}))}),((e,t)=>e.key===t.key&&e.id===t.id)),I=(0,s.Iz)((function(){let{id:e,merge:t=!0,nodeIds:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,o.eU)(null,((r,o,i)=>{let{values:s,merge:a}=i;o(h({id:e,key:"fetchedFor"}),n),o(A(e),(e=>{const n=Object.keys(s).reduce(((n,r)=>{const{id:o}=s[r];return n[o]={...l,...(t||a)&&e[o],...s[r],loaded:!0},n}),t?{...e}:{});return t&&(0,c.Ay)(n,e,{omit:["lastEntry","firstEntry","family"]})?e:n}))}))}),c.Ay),C=(e,t)=>(0,i.md)(w({id:e,key:t})),k=e=>(0,a.yF)((0,r.useCallback)(((t,n,r)=>{n(A(e),r)}),[e])),j=(e,t)=>(0,a.yF)((0,r.useCallback)(((n,r,o)=>({...n(A(e))[o],...t?.[o]||{}})),[e,t])),B=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=(0,d.ID)(),n=(0,i.md)(A(t));return e.some((e=>n[e]?.visible&&!n[e]?.filteredOut&&!n[e]?.hidden))},O=()=>{const e=(0,d.ID)(),t=(0,i.md)(A(e));return(0,r.useCallback)((function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).some((e=>t[e]?.visible&&!t[e]?.filteredOut&&!t[e]?.hidden))}),[e,t])},R=(0,s.Iz)((()=>(0,o.eU)({}))),D=(0,s.Iz)((e=>{let{id:t,context:n}=e;return(0,o.eU)((e=>{const r=e(R(t));return n?r[n]:r}),((e,r,o)=>{"function"!==typeof o?Object.keys(o).length<1||r(R(t),(e=>({...e,[n]:o}))):r(R(t),(e=>({...e,[n]:o(e[n])})))}))}),c.Ay);(0,s.Iz)((e=>(0,o.eU)(null,((t,n,r)=>{n(R(e),(e=>({...e,...r})))})))),(0,s.Iz)((e=>{let{id:t,contexts:n=[]}=e;return(0,o.eU)((e=>{const r=e(D({id:t}));return n.reduce(((e,t)=>(r[t]&&(e[t]=r[t]),e)),{})}))}),c.Ay)},61710:(e,t,n)=>{n.d(t,{Oq:()=>l,sd:()=>i,tr:()=>c,zA:()=>d});var r=n(78659),o=n.n(r);const i=e=>Math.round(10*e)/10,s=e=>{const{gutter:t,containerWidth:n,gridTracks:r}=e;return(n-t*(r-1))/r};function a(e,t,n){return Number.isFinite(e)?i(t*e+Math.max(0,e-1)*n):e}function l(e,t,n,r,o,l){const{gutter:d,rowHeight:c}=e,u=s(e),h={};return l?(h.width=a(l.width,u,d),h.height=a(l.height,c,d),h.top=i((c+d)*l.top),h.left=i((u+d)*l.left)):(h.width=a(r,u,d),h.height=a(o,c,d),h.top=i((c+d)*n),h.left=i((u+d)*t)),h}function d(e,t,n,r){const{gutter:a,gridTracks:l,rowHeight:d,maxRows:c}=e,u=s(e);let h=i((n-a)/(u+a)),f=i((t-a)/(d+a));return h=o()(h,0,l-r.width),f=o()(f,0,c-r.height),{left:h,top:f}}const c=(e,t,n,r)=>{const{gutter:a,maxRows:l,gridTracks:d,rowHeight:c}=e,u=s(e);let h=i((t+a)/(u+a)),f=i((n+a)/(c+a));return h=o()(o()(h,r.minWidth||3,d-r.left),0,d),f=o()(o()(f,r.minHeight||2,l-r.top),0,l),{width:h,height:f}}},64867:(e,t,n)=>{n.d(t,{O:()=>o});const r={ErrNoChartExist:"ErrNoChartExist"},o=function(e){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:r)[e]}},69457:(e,t,n)=>{n.d(t,{BK:()=>w,NF:()=>v,Tg:()=>x,Vt:()=>I,aA:()=>y,dd:()=>b,i8:()=>u,qR:()=>p,uy:()=>A,vN:()=>g});n(98992),n(81454);var r=n(96540),o=n(83488),i=n.n(o),s=n(66814),a=n(27250),l=n(74848);const d=r.createContext({}),c=(0,s.q6)({}),u=(0,s.q6)({}),h=(0,s.q6)([]),f=(0,s.q6)({}),g=e=>{let{container:t,menuItemAttributesById:n,getObject:o,allElements:i,stickyIds:s,children:a}=e;return(0,l.jsx)(d.Provider,{value:t,children:(0,l.jsx)(c.Provider,{value:(0,r.useCallback)((e=>({...o(e),...n[e]})),[n,o]),children:(0,l.jsx)(u.Provider,{value:n,children:(0,l.jsx)(h.Provider,{value:i,children:(0,l.jsx)(f.Provider,{value:s,children:a})})})})})},m={},y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i();return(0,a.A)(u,(n=>t(n[e]||m)))},b=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i();return(0,a.A)(u,(n=>Array.isArray(e)?e.map(((e,r)=>t(n[e]||m,e,r))):[]))},v=()=>r.useContext(d),p=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i();return(0,a.A)(h,e)},x=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i();return(0,a.A)(f,e)},A=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:i())(I()(e))},w=e=>t=>{let{id:n,...r}=t;const o=y(n),{chartId:i,contextScope:s}=o,a=A(i||n||s?.[0]);return(0,l.jsx)(e,{id:n,chart:a,menuChartAttributes:o,...r})},I=()=>(0,a.A)(c)},74518:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(96540),o=n(63766),i=n(41395),s=n(45087),a=n(74848);const l=e=>{let{text:t,TextComponent:n=o.Text,ellipsisEnd:l,...d}=e;const[c,u]=(0,r.useState)(""),[h,f]=(0,r.useState)(),g=l?i.RR:i.P3;return(0,r.useEffect)((()=>{if(!h)return;const e=h.offsetWidth;let n=0;for(;h.scrollWidth>e;)h.textContent=g(h.textContent,n),n+=1;h.textContent!==t&&u(t)}),[t,h]),(0,a.jsx)(s.A,{content:c?t:"",align:"bottom",isBasic:!0,children:(0,a.jsx)(n,{truncate:!0,ref:f,...d,children:t})})}},77611:(e,t,n)=>{n.d(t,{UG:()=>I,Ip:()=>w,er:()=>x,Yy:()=>C,G9:()=>A});n(98992),n(3949),n(8872);var r=n(96540),o=n(34843),i=n(30569),s=n(84929),a=n(42790),l=n(16015),d=n(57377);const c={byContext:{},loaded:!1,loading:!1,method:null,options:null,group:"average",totalDimensionsCount:0},u=(0,s.Iz)((()=>(0,s.tx)(c)),d.Ay),h={ci:"context",ni:"node",ii:"instance",di:"dimension"},f=(e,t)=>n=>({[h[e.name]]:t[e.dictionary][n]}),g={ni:f,ii:(e,t)=>(n,r,o)=>({[h[e.name]]:t[e.dictionary][n]?`${t[e.dictionary][n]}@${t.nodes[r[o.ni]]}`:null}),ci:f,di:f,row_type:e=>t=>({type:e.value[t]}),weight:()=>e=>({weight:e}),timeframe:e=>t=>({highlight:e.labels.reduce(((e,n,r)=>({...e,[n]:t[r]})),{})}),"baseline timeframe":e=>t=>({baseline:e.labels.reduce(((e,n,r)=>({...e,[n]:t[r]})),{})})},m={contexts:"ci",nodes:"ni",instances:"ii",dimensions:"di"},y={contexts:"id",nodes:"nodeId",instances:"id",dimensions:"id"},b=(e,t)=>null===e||e>t?t:e,v=(e,t)=>null===e||e<t?t:e,p=e=>{let{data:t,aggregation:n,options:r}=e,o={},i=0;if(t.v_schema){const e=t.v_schema?.items||[];o=t.result.reduce(((t,r)=>{let{id:o,v:i}=r;return t[o]=e.reduce(((e,t,r)=>{let{name:o,labels:s}=t;const a=s.indexOf(n);return e[o]=i[r][a],e}),{}),t}),{})}else{const e=(e=>{const t=Object.keys(e.dictionaries).reduce(((t,n)=>{t[n]||(t[n]={});const r=y[n];return e.dictionaries[n].forEach((e=>t[n][e[m[n]]]="nodeId"===r?e.nd||e.mg:e[r])),t}),{}),n={},r=e.schema.items.reduce(((e,r,o)=>{const i=(g[r.name]||g.default)(r,t);return e.push(i),n[r.name]=o,e}),[]);return e=>e.reduce(((t,o,i)=>({...t,...r[i](o,e,n)})),{})})(t);o=t.result.reduce(((t,n)=>{const{dimension:o,node:s,context:a,instance:l,type:d,weight:c,highlight:u,baseline:h}=e(n);if("node"===d)return t;const f=(g=t,m=a,function(e,t,n,r,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:b;n&&(n&&"undefined"===typeof g[m][t][n]&&(g[m][t][n]={}),"undefined"===typeof g[m][t][n][e]&&(g[m][t][n][e]=null),r&&(g[m][t][n][e]=i(g[m][t][n][e],o)))});var g,m;t[a]||(t[a]={dimensions:{},instances:{},nodes:{},weight:null});const y=!!r&&r.includes("anomaly-bit");f("weight","dimensions",o,"dimension"===d,c,y?v:b),f("weight","instances",l,"instance"===d,c,y?v:b),f("weight","nodes",s,"node"===d,c,y?v:b);const p=u?100*u.anomaly_count/u.count:0;f("arHighlight","dimensions",o,"dimension"===d,p,v),f("arHighlight","instances",l,"instance"===d,p,v),f("arHighlight","nodes",s,"node"===d,p,v);const x=h?100*(h.anomaly_count-u.anomaly_count)/(h.count-u.count)===0?1:h.count-u.count:0;f("arBaseline","dimensions",o,"dimension"===d,x,v),f("arBaseline","instances",l,"instance"===d,x,v),f("arBaseline","nodes",s,"node"===d,x,v);const A=x?p/x:0;return f("score","dimensions",o,"dimension"===d,A,v),f("score","instances",l,"instance"===d,A,v),f("score","nodes",s,"node"===d,A,v),"context"===d?t[a].weight=null===t[a].weight||t[a].weight>c?c:t[a].weight:"dimension"===d&&(i+=1),t}),{})}return{byContext:o,totalDimensionsCount:i}},x=(e,t,n)=>{const o=(0,r.useRef)();return[(0,i.yF)((0,r.useCallback)(((r,i,s)=>{let{flavour:a,highlightAfter:d,highlightBefore:h,baselineAfter:f,baselineBefore:g,method:m,options:y,group:b,context:v,nodeIds:x,aggregation:A,groupBy:w}=s;return i(u(e),{...c,loading:!0}),o.current&&o.current.cancel(),o.current=(0,l.e0)(t,n,{highlightAfter:d,highlightBefore:h,baselineAfter:f,baselineBefore:g,method:m,options:y,group:b,context:v,nodeIds:x,aggregation:A,groupBy:w}),o.current.then((t=>{let{data:n}=t;const{byContext:r,totalDimensionsCount:o}=p({flavour:a,data:n,aggregation:A,options:y});i(u(e),{loading:!1,loaded:!0,byContext:r,options:y,totalDimensionsCount:o,method:m,group:b,groupBy:w,error:null})})).catch((t=>{if(!t.isCancel)throw i(u(e),{...c,error:t?.response?.data||t}),t}))}),[e])),(0,i.yF)((0,r.useCallback)(((t,n)=>{o.current&&o.current.cancel(),n(u(e),s.Ut)}),[e]))]},A=e=>(0,o.md)(u(e)),w=e=>(0,i.AY)(u(e)),I=.01,C=(e,t,n)=>{const[o,i]=x(e,t,n),{loaded:s,loading:l,byContext:d,totalDimensionsCount:c,options:u,groupBy:h}=A(e),f=(()=>{const e=(0,a.rW)("threshold");return e?Number.parseFloat(e):I})(),[g,m,y]=(0,r.useMemo)((()=>{let e=0;const t=u?.includes("raw"),n=(h||[]).length?d:Object.keys(d).reduce(((n,r)=>{const o=Object.keys(d[r].dimensions).reduce(((e,n)=>(!t&&d[r].dimensions[n].weight>f||(e[n]=d[r].dimensions[n]),e)),{}),i=Object.keys(o).length;return e+=i,i?(n[r]={...d[r],dimensions:o},n):n}),{});return[n,Object.keys(n),e]}),[s,f]);return{threshold:f,metadata:g,contexts:m,dimensionsCount:y,totalDimensionsCount:c,loaded:s,loading:l,getWeights:o,resetWeights:i}}}}]);