@verifiedinc-public/shared-ui-elements 3.11.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,11 @@ interface PieChartProps {
62
62
  * Optional props object for the Pie component
63
63
  */
64
64
  pie?: Partial<PieProps>;
65
+ /**
66
+ * Optional flag to show all shapes as active
67
+ * @default false
68
+ */
69
+ allActive?: boolean;
65
70
  }
66
71
  /**
67
72
  * A pie chart component that visualizes proportional data.
@@ -83,5 +88,5 @@ interface PieChartProps {
83
88
  * />
84
89
  * ```
85
90
  */
86
- export declare function PieChart({ data, sx, legendLabel, legendToggle, valueText, valuePercentage, pie, needleVisible, needleValue, needleColor, }: PieChartProps): ReactElement;
91
+ export declare function PieChart({ data, sx, legendLabel, legendToggle, valueText, valuePercentage, pie, needleVisible, needleValue, needleColor, allActive, }: PieChartProps): ReactElement;
87
92
  export {};
@@ -1,8 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { SxProps } from '@mui/material';
3
- interface RiskScoreBarChartProps {
3
+ export interface RiskScoreBarChartProps {
4
4
  data: Array<Record<number, number>>;
5
5
  sx?: SxProps;
6
6
  }
7
7
  export declare function RiskScoreBarChart({ data, sx, }: RiskScoreBarChartProps): ReactElement;
8
- export {};
@@ -6,4 +6,5 @@ export * from './SimpleBarChart';
6
6
  export * from './ErrorCodesChart';
7
7
  export * from './PieChart';
8
8
  export * from './RiskScorePieChart';
9
+ export * from './RiskScoreBarChart';
9
10
  export * from './SimpleLegend';
@@ -1 +1 @@
1
- "use strict";import{j as a}from"../../shared/jsx-runtime-DHlBLioN.mjs";import*as P from"react";import{useCallback as ee,useMemo as te,createElement as Ie,useState as q,useRef as Pe,useEffect as he}from"react";import{Box as z,Stack as U,Typography as W,useTheme as V,Paper as ze}from"@mui/material";import{ResponsiveContainer as Z,LineChart as Ve,CartesianGrid as ne,XAxis as oe,YAxis as re,Label as xe,Tooltip as ae,Legend as ye,Line as Ge,AreaChart as Ke,Area as We,ComposedChart as Be,ReferenceLine as ve,ReferenceArea as ge,Bar as qe,Sector as be,PieChart as Ue,Pie as Ze,Cell as Ye}from"recharts";import{b as we,c as je}from"../../shared/date-Cq0LS2Mr.mjs";import Y,{Decimal as ie}from"decimal.js";import{AnimatePresence as He}from"framer-motion";import{u as Xe}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as se}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Je,C as Oe}from"../../shared/motions-BBPeWBPV.mjs";import{c as ke,i as Qe,_ as H,s as et,a as S,d as tt,e as nt,f as ot,h as rt,j as at,k as it,l as st,m as lt,n as ct,o as ut,p as dt,u as pt}from"../../shared/index-KVVTzcea.mjs";import{u as mt}from"../../shared/useCounter-BV32zXDQ.mjs";const ft=["ownerState"],ht=["variants"],xt=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function yt(e){return Object.keys(e).length===0}function vt(e){return typeof e=="string"&&e.charCodeAt(0)>96}function le(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const gt=ke(),bt=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function X({defaultTheme:e,theme:t,themeId:n}){return yt(t)?e:t[n]||t}function wt(e){return e?(t,n)=>n[e]:null}function J(e,t){let{ownerState:n}=t,o=H(t,ft);const r=typeof e=="function"?e(S({ownerState:n},o)):e;if(Array.isArray(r))return r.flatMap(s=>J(s,S({ownerState:n},o)));if(r&&typeof r=="object"&&Array.isArray(r.variants)){const{variants:s=[]}=r;let i=H(r,ht);return s.forEach(c=>{let l=!0;typeof c.props=="function"?l=c.props(S({ownerState:n},o,n)):Object.keys(c.props).forEach(d=>{n?.[d]!==c.props[d]&&o[d]!==c.props[d]&&(l=!1)}),l&&(Array.isArray(i)||(i=[i]),i.push(typeof c.style=="function"?c.style(S({ownerState:n},o,n)):c.style))}),i}return r}function jt(e={}){const{themeId:t,defaultTheme:n=gt,rootShouldForwardProp:o=le,slotShouldForwardProp:r=le}=e,s=i=>tt(S({},i,{theme:X(S({},i,{defaultTheme:n,themeId:t}))}));return s.__mui_systemSx=!0,(i,c={})=>{Qe(i,f=>f.filter(k=>!(k!=null&&k.__mui_systemSx)));const{name:l,slot:d,skipVariantsResolver:h,skipSx:x,overridesResolver:u=wt(bt(d))}=c,m=H(c,xt),j=h!==void 0?h:d&&d!=="Root"&&d!=="root"||!1,w=x||!1;let O,y=le;d==="Root"||d==="root"?y=o:d?y=r:vt(i)&&(y=void 0);const b=et(i,S({shouldForwardProp:y,label:O},m)),T=f=>typeof f=="function"&&f.__emotion_real!==f||nt(f)?k=>J(f,S({},k,{theme:X({theme:k.theme,defaultTheme:n,themeId:t})})):f,R=(f,...k)=>{let A=T(f);const $=k?k.map(T):[];l&&u&&$.push(v=>{const g=X(S({},v,{defaultTheme:n,themeId:t}));if(!g.components||!g.components[l]||!g.components[l].styleOverrides)return null;const N=g.components[l].styleOverrides,C={};return Object.entries(N).forEach(([_,L])=>{C[_]=J(L,S({},v,{theme:g}))}),u(v,C)}),l&&!j&&$.push(v=>{var g;const N=X(S({},v,{defaultTheme:n,themeId:t})),C=N==null||(g=N.components)==null||(g=g[l])==null?void 0:g.variants;return J({variants:C},S({},v,{theme:N}))}),w||$.push(s);const E=$.length-k.length;if(Array.isArray(f)&&E>0){const v=new Array(E).fill("");A=[...f,...v],A.raw=[...f.raw,...v]}const p=b(A,...$);return i.muiName&&(p.muiName=i.muiName),p};return b.withConfig&&(R.withConfig=b.withConfig),R}}const Ot=jt(),kt=(e,t)=>e.filter(n=>t.includes(n)),G=(e,t,n)=>{const o=e.keys[0];Array.isArray(t)?t.forEach((r,s)=>{n((i,c)=>{s<=e.keys.length-1&&(s===0?Object.assign(i,c):i[e.up(e.keys[s])]=c)},r)}):t&&typeof t=="object"?(Object.keys(t).length>e.keys.length?e.keys:kt(e.keys,Object.keys(t))).forEach(r=>{if(e.keys.indexOf(r)!==-1){const s=t[r];s!==void 0&&n((i,c)=>{o===r?Object.assign(i,c):i[e.up(r)]=c},s)}}):(typeof t=="number"||typeof t=="string")&&n((r,s)=>{Object.assign(r,s)},t)};function F(e){return e?`Level${e}`:""}function B(e){return e.unstable_level>0&&e.container}function Se(e){return function(t){return`var(--Grid-${t}Spacing${F(e.unstable_level)})`}}function ce(e){return function(t){return e.unstable_level===0?`var(--Grid-${t}Spacing)`:`var(--Grid-${t}Spacing${F(e.unstable_level-1)})`}}function ue(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${F(e.unstable_level-1)})`}const St=({theme:e,ownerState:t})=>{const n=Se(t),o={};return G(e.breakpoints,t.gridSize,(r,s)=>{let i={};s===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),s==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof s=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${s} / ${ue(t)}${B(t)?` + ${n("column")}`:""})`}),r(o,i)}),o},$t=({theme:e,ownerState:t})=>{const n={};return G(e.breakpoints,t.gridOffset,(o,r)=>{let s={};r==="auto"&&(s={marginLeft:"auto"}),typeof r=="number"&&(s={marginLeft:r===0?"0px":`calc(100% * ${r} / ${ue(t)})`}),o(n,s)}),n},Tt=({theme:e,ownerState:t})=>{if(!t.container)return{};const n=B(t)?{[`--Grid-columns${F(t.unstable_level)}`]:ue(t)}:{"--Grid-columns":12};return G(e.breakpoints,t.columns,(o,r)=>{o(n,{[`--Grid-columns${F(t.unstable_level)}`]:r})}),n},Rt=({theme:e,ownerState:t})=>{if(!t.container)return{};const n=ce(t),o=B(t)?{[`--Grid-rowSpacing${F(t.unstable_level)}`]:n("row")}:{};return G(e.breakpoints,t.rowSpacing,(r,s)=>{var i;r(o,{[`--Grid-rowSpacing${F(t.unstable_level)}`]:typeof s=="string"?s:(i=e.spacing)==null?void 0:i.call(e,s)})}),o},At=({theme:e,ownerState:t})=>{if(!t.container)return{};const n=ce(t),o=B(t)?{[`--Grid-columnSpacing${F(t.unstable_level)}`]:n("column")}:{};return G(e.breakpoints,t.columnSpacing,(r,s)=>{var i;r(o,{[`--Grid-columnSpacing${F(t.unstable_level)}`]:typeof s=="string"?s:(i=e.spacing)==null?void 0:i.call(e,s)})}),o},Ct=({theme:e,ownerState:t})=>{if(!t.container)return{};const n={};return G(e.breakpoints,t.direction,(o,r)=>{o(n,{flexDirection:r})}),n},Et=({ownerState:e})=>{const t=Se(e),n=ce(e);return S({minWidth:0,boxSizing:"border-box"},e.container&&S({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${t("row")} / -2) calc(${t("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${t("row")} * -1) 0px 0px calc(${t("column")} * -1)`}),(!e.container||B(e))&&S({padding:`calc(${n("row")} / 2) calc(${n("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${n("row")} 0px 0px ${n("column")}`}))},Nt=e=>{const t=[];return Object.entries(e).forEach(([n,o])=>{o!==!1&&o!==void 0&&t.push(`grid-${n}-${String(o)}`)}),t},_t=(e,t="xs")=>{function n(o){return o===void 0?!1:typeof o=="string"&&!Number.isNaN(Number(o))||typeof o=="number"&&o>0}if(n(e))return[`spacing-${t}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const o=[];return Object.entries(e).forEach(([r,s])=>{n(s)&&o.push(`spacing-${r}-${String(s)}`)}),o}return[]},Dt=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([t,n])=>`direction-${t}-${n}`):[`direction-xs-${String(e)}`],Lt=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],Mt=ke(),Ft=Ot("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,t)=>t.root});function It(e){return st({props:e,name:"MuiGrid",defaultTheme:Mt})}function Pt(e={}){const{createStyledComponent:t=Ft,useThemeProps:n=It,componentName:o="MuiGrid"}=e,r=P.createContext(void 0),s=(l,d)=>{const{container:h,direction:x,spacing:u,wrap:m,gridSize:j}=l,w={root:["root",h&&"container",m!=="wrap"&&`wrap-xs-${String(m)}`,...Dt(x),...Nt(j),...h?_t(u,d.breakpoints.keys[0]):[]]};return lt(w,O=>ct(o,O),{})},i=t(Tt,At,Rt,St,Ct,Et,$t),c=P.forwardRef(function(l,d){var h,x,u,m,j,w,O,y;const b=ot(),T=n(l),R=rt(T),f=P.useContext(r),{className:k,children:A,columns:$=12,container:E=!1,component:p="div",direction:v="row",wrap:g="wrap",spacing:N=0,rowSpacing:C=N,columnSpacing:_=N,disableEqualOverflow:L,unstable_level:M=0}=R,Ne=H(R,Lt);let K=L;M&&L!==void 0&&(K=l.disableEqualOverflow);const de={},pe={},me={};Object.entries(Ne).forEach(([D,I])=>{b.breakpoints.values[D]!==void 0?de[D]=I:b.breakpoints.values[D.replace("Offset","")]!==void 0?pe[D.replace("Offset","")]=I:me[D]=I});const _e=(h=l.columns)!=null?h:M?void 0:$,De=(x=l.spacing)!=null?x:M?void 0:N,Le=(u=(m=l.rowSpacing)!=null?m:l.spacing)!=null?u:M?void 0:C,Me=(j=(w=l.columnSpacing)!=null?w:l.spacing)!=null?j:M?void 0:_,fe=S({},R,{level:M,columns:_e,container:E,direction:v,wrap:g,spacing:De,rowSpacing:Le,columnSpacing:Me,gridSize:de,gridOffset:pe,disableEqualOverflow:(O=(y=K)!=null?y:f)!=null?O:!1,parentDisableEqualOverflow:f}),Fe=s(fe,b);let Q=a.jsx(i,S({ref:d,as:p,ownerState:fe,className:at(Fe.root,k)},me,{children:P.Children.map(A,D=>{if(P.isValidElement(D)&&it(D,["Grid"])){var I;return P.cloneElement(D,{unstable_level:(I=D.props.unstable_level)!=null?I:M+1})}return D})}));return K!==void 0&&K!==(f??!1)&&(Q=a.jsx(r.Provider,{value:K,children:Q})),Q});return c.muiName="Grid",c}const $e=Pt({createStyledComponent:ut("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,t)=>t.root}),componentName:"MuiGrid2",useThemeProps:e=>dt({props:e,name:"MuiGrid2"})});function zt({entry:e,payload:t}){const n=ee(x=>{var u,m,j;return(j=(m=(u=x.payload)==null?void 0:u.data)==null?void 0:m.reduce)==null?void 0:j.call(m,(w,O)=>w+O.value,0)},[]),o=ee(x=>{const u=new ie(n(x)||0),m=t?.reduce((O,y)=>O+n(y),0)||0,j=new ie(m),w=Number(u.div(j).times(100).toFixed(2,ie.ROUND_DOWN));return isNaN(w)||!isFinite(w)?0:w},[n,t]),r=te(()=>n(e),[e,n]),s=se(r),i=te(()=>Number(o(e)),[e,o]),c=se(i),l=ee(x=>Math.floor(x).toLocaleString(),[]),d=Xe({type:"text/plain"}),h=pt();return a.jsxs(Je,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[a.jsx(z,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),a.jsxs(U,{children:[a.jsxs(W,{component:"p",variant:"caption",children:[a.jsx(U,{component:"span",display:"inline-flex",mr:.5,children:a.jsx(Oe,{from:s??0,to:r,map:l,children:"0"})}),a.jsxs(U,{component:"span",direction:"row",display:"inline-flex",children:["(",a.jsx(Oe,{from:c??0,to:i,map:l,children:"0"}),"%)"]})]}),a.jsx(W,{variant:"body1",children:e.value}),e.payload.uuid&&a.jsxs(W,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{d.copy(e.payload.uuid).catch(()=>{}),h.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function Te(e){const{payload:t}=e;return a.jsx($e,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:a.jsx(He,{children:t?.map(n=>a.jsx($e,{children:a.jsx(zt,{entry:n,payload:t})},`item-${n.value}`))})})}function Vt(e){const t=V();return a.jsx(z,{sx:{width:"100%",height:"100%",...e.sx},children:a.jsx(Z,{children:a.jsxs(Ve,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[a.jsx(ne,{vertical:!1}),a.jsx(oe,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:n=>we(n,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),a.jsx(re,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:n=>Number(n).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&a.jsx(xe,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),a.jsx(ae,{cursor:{stroke:t.palette.neutral.main,strokeWidth:1},formatter:n=>Number(n).toLocaleString(),labelFormatter:n=>je(n,{timeZone:e.filter.timezone,hour12:!1})}),a.jsx(ye,{content:a.jsx(Te,{})}),e.data.map(n=>Ie(Ge,{uuid:n.uuid,key:n.uuid,name:n.name,dataKey:"value",data:n.chartData,type:"monotone",stroke:n.color,strokeWidth:2}))]})})})}const Gt=(e,t)=>{const n=new Map;return e.forEach(o=>{o.chartData.forEach(r=>{const s=new Date(r.date).getTime().toString();if(!n.has(s)){const i={date:s,total:0,diff:0,totalKey:"",originalTotal:0};t.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),n.set(s,i)}t.forEach(({key:i})=>{const c=n.get(s),l=r[i],d=typeof l=="string"?l.trim()===""?0:parseInt(l,10):typeof l=="number"?l:0;c[`${i}_absolute`]=d,c[i]=0})})}),Array.from(n.values()).map(o=>{var r;const s=(r=t.find(l=>l.isTotal))==null?void 0:r.key,i=t.filter(l=>!l.isTotal).map(l=>l.key);if(!s||i.length===0)return o;const c=o[`${s}_absolute`];return o.originalTotal=c,o.total=c,o[s]=100,i.forEach(l=>{const d=o[`${l}_absolute`],h=c>0?new Y(d.toString()).div(c).mul(100).toFixed(2,Y.ROUND_DOWN):"0.00";o[l]=parseFloat(h)}),{...o,totalKey:s}}).sort((o,r)=>parseInt(o.date)-parseInt(r.date))};function Kt(e){const t=V(),n=te(()=>e.data?Gt(e.data,e.keyValues):[],[e.data,e.keyValues]);return a.jsx(z,{sx:{width:"100%",height:"100%",...e.sx},children:a.jsx(Z,{width:"100%",height:"100%",children:a.jsxs(Ke,{data:n,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[a.jsx(ne,{strokeDasharray:"3 3"}),a.jsx(oe,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:o=>we(o,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),a.jsx(re,{textAnchor:"end",tickLine:!1,tickFormatter:o=>`${o.toFixed(2)}%`}),a.jsx(ae,{cursor:{stroke:t.palette.neutral.main,strokeWidth:1},labelFormatter:o=>je(o,{timeZone:e.filter.timezone,hour12:!1}),formatter:(o,r,s)=>{const i=s.payload.totalKey,c=s.dataKey,l=c===i,d=s.payload[`${c}_absolute`],h=s.payload.originalTotal,x=l?null:h===0?"0.00":new Y(d.toString()).div(h).mul(100).toFixed(2,Y.ROUND_DOWN);return[x?`${d.toLocaleString()} (${x}%)`:`${d.toLocaleString()} (TOTAL)`,r]}}),e.keyValues.sort((o,r)=>o.isTotal?-1:r.isTotal?1:0).map(o=>a.jsx(We,{type:"monotone",dataKey:o.key,name:o.name,stroke:o.color,fill:o.color,strokeWidth:2,fillOpacity:.6},o.key))]})})})}function Wt(e){const t=se(e.value),{ref:n}=mt({from:t??0,to:e.value,duration:1,map:e.map});return a.jsx(ze,{sx:{p:3,flex:1,...e.sx},children:a.jsxs(U,{spacing:1,alignItems:"center",children:[a.jsx(W,{ref:n,variant:"h4",fontWeight:"bold",children:e.initialValue}),a.jsx(W,{color:"text.secondary",children:e.label})]})})}const Re={margin:{top:5,right:30,left:20,bottom:5}},Bt={tickLine:!1,fontSize:12,tickMargin:12},qt={textAnchor:"end",tickLine:!1};function Ae({data:e,series:t,xAxis:n,yAxis:o,tooltip:r,bar:s,referenceLines:i,referenceAreas:c,sx:l}){const d=V(),h=u=>!u.isFront,x=u=>!!u.isFront;return a.jsx(z,{sx:{width:"100%",height:"100%",...l},children:a.jsx(Z,{children:a.jsxs(Be,{data:e,...Re,children:[a.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),a.jsx(oe,{...Bt,...n}),a.jsx(re,{...qt,...o}),a.jsx(ae,{cursor:{stroke:d.palette.neutral.main,strokeWidth:1},...r}),i?.filter(h).map((u,m)=>a.jsx(ve,{...u},u.label??m)),c?.filter(h).map((u,m)=>a.jsx(ge,{...u},u.label??m)),t.map(u=>a.jsx(qe,{name:u.key,dataKey:u.dataKey,fill:u.color,stackId:"stack",isAnimationActive:!1,...s},u.key)),i?.filter(x).map((u,m)=>a.jsx(ve,{...u},u.label??m)),c?.filter(x).map((u,m)=>a.jsx(ge,{...u},u.label??m))]})})})}function Ut({data:e,sx:t}){const n=V(),o=Object.entries(e??{}).map(([s,i])=>({key:s,[s]:i})),r=o.map(({key:s})=>({key:s,dataKey:s,color:n.palette.error.light}));return a.jsx(Ae,{sx:t,data:o,series:r,xAxis:{tickLine:!1,dataKey:"key"},yAxis:{tickLine:!1,domain:[0,"dataMax + 100"]},tooltip:{labelFormatter:s=>"Total"},referenceLines:[{y:100,stroke:n.palette.error.dark,strokeDasharray:"3 3",label:a.jsx(xe,{value:"Unhealthy threshold",position:"insideBottomRight"}),isFront:!0}]})}function Ce({payload:e=[],hiddenItems:t,onToggle:n,legendLabel:o}){return a.jsx(z,{sx:{display:"flex",justifyContent:"center",gap:"20px",paddingTop:"20px"},children:e.map((r,s)=>{const i=t.has(r.payload.name);return a.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",opacity:i?.4:1},onClick:()=>{n?.(r.payload)},children:[a.jsx("div",{style:{width:"12px",height:"12px",backgroundColor:r.color,marginRight:"8px",borderRadius:"2px"}}),a.jsx("span",{style:{color:r.color},children:o?`${o}: ${r.value}`:r.value})]},`legend-${s}`)})})}const Zt=e=>{const t=Math.PI/180,{cx:n,cy:o,midAngle:r,innerRadius:s,outerRadius:i,startAngle:c,endAngle:l,fill:d,payload:h,percent:x,value:u,valueText:m,valuePercentage:j,needleVisible:w,customText:O}=e,y=Math.sin(-t*r),b=Math.cos(-t*r),T=n+(i+5)*b,R=o+(i+5)*y,f=n+(i+15)*b,k=o+(i+15)*y,A=f+(b>=0?1:-1)*15,$=k,E=b>=0?"start":"end",p=u.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0});return a.jsxs("g",{children:[!w&&a.jsx("text",{x:n,y:o,dy:8,textAnchor:"middle",fill:"#333",fontSize:14,children:h.name}),a.jsx(be,{cx:n,cy:o,innerRadius:s,outerRadius:i,startAngle:c,endAngle:l,fill:d}),a.jsx(be,{cx:n,cy:o,startAngle:c,endAngle:l,innerRadius:i+2,outerRadius:i+6,fill:d}),a.jsx("path",{d:`M${T},${R}L${f},${k}L${A},${$}`,stroke:d,fill:"none"}),a.jsx("circle",{cx:A,cy:$,r:2,fill:d,stroke:"none"}),a.jsx("text",{x:A+(b>=0?1:-1)*8,y:$,textAnchor:E,fill:"#333",fontSize:12,children:O||(m?`${m} ${p}`:p)}),j&&a.jsxs("text",{x:A+(b>=0?1:-1)*8,y:$,dy:16,textAnchor:E,fill:"#999",fontSize:11,children:[`${(x*100).toFixed(2)}%`," (",p,")"]})]})},Yt=e=>{const{value:t,data:n,color:o,innerRadius:r,outerRadius:s,boxDimensions:i,legendDimensions:c,valueText:l}=e,d=Math.PI/180;let h=0;n.forEach(g=>{h+=g.value});const x=i?i.width/2:150,u=(i?i.height/2:200)-c.height/2,m=180*(1-Math.max(0,Math.min(1,t/h))),j=(Number(r)+2*Number(s))/3,w=Math.sin(-d*m),O=Math.cos(-d*m),y=5,b=x-y,T=u,R=b+y*w,f=T-y*O,k=b-y*w,A=T+y*O,$=b+j*O,E=T+j*w,p=t.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}),v=l??p;return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:b,cy:T,r:y,fill:o,stroke:"none",style:{pointerEvents:"none"}},"needle-circle"),a.jsx("path",{d:`M${R} ${f}L${k} ${A} L${$} ${E} L${R} ${f}`,stroke:"none",fill:o,style:{pointerEvents:"none"}},"needle-path"),a.jsx("text",{x:b+y,y:T+26,textAnchor:"middle",fill:"#333",fontSize:12,children:v},"needle-value")]})},Ht=(e,t)=>({Allow:t.palette.success.main,Flag:t.palette.warning.main,Block:t.palette.error.main})[e]??t.palette.primary.main;function Ee({data:e,sx:t,legendLabel:n,legendToggle:o=!1,valueText:r="",valuePercentage:s=!0,pie:i,needleVisible:c=!1,needleValue:l,needleColor:d="#aaa"}){const{innerRadius:h=60,outerRadius:x=100}=i??{},u=V(),[m,j]=q(),[w,O]=q(new Set),y=Pe(null),[b,T]=q(null),[R,f]=q(null),k=(p,v)=>{j(v)},A=()=>{j(void 0)},$=p=>{o&&p&&O(v=>{const g=new Set(v);return g.has(p.name)?g.delete(p.name):g.size<e.length-1&&g.add(p.name),g})},E=e.map(p=>({...p,value:w.has(p.name)?0:p.value}));return he(()=>{const p=y.current;if(!p)return;const v=new ResizeObserver(N=>{var C;const _=(C=N[0])==null?void 0:C.contentRect;_&&T(_)});v.observe(p);const g=p.getBoundingClientRect();return T(g),()=>{v.disconnect()}},[]),he(()=>{var p;const v=(p=y.current)==null?void 0:p.querySelector(".recharts-legend-wrapper");if(!v){const C=setInterval(()=>{var _;const L=(_=y.current)==null?void 0:_.querySelector(".recharts-legend-wrapper");if(L){const M=L.getBoundingClientRect();f(M),clearInterval(C)}},100);return()=>{clearInterval(C)}}const g=new ResizeObserver(C=>{var _;const L=(_=C[0])==null?void 0:_.contentRect;L&&f(L)});g.observe(v);const N=v.getBoundingClientRect();return f(N),()=>{g.disconnect()}},[]),a.jsx(z,{ref:y,sx:{width:"100%",height:"100%","& g":{outline:"none"},...t},children:a.jsx(Z,{children:a.jsxs(Ue,{...Re,children:[a.jsx(Ze,{data:E,nameKey:"name",dataKey:"value",innerRadius:h,outerRadius:x,activeIndex:m,activeShape:p=>Zt({...p,valueText:r,valuePercentage:s,needleVisible:c}),paddingAngle:0,onMouseEnter:k,onMouseLeave:A,...i,children:E.map(p=>a.jsx(Ye,{fill:p.color??Ht(p.name,u),opacity:w.has(p.name)?.5:1,stroke:"none"},p.name))}),a.jsx(ye,{content:a.jsx(Ce,{legendLabel:n,hiddenItems:w,onToggle:$})}),c&&l!==void 0&&b&&R&&Yt({data:E,value:l,color:d,innerRadius:h,outerRadius:x,boxDimensions:b,legendDimensions:R,valueText:r})]})})})}function Xt({sx:e,data:t,score:n=200,legendLabel:o}){const r=V(),s=[{name:"Allow",customText:"0-299",value:t[0].value,color:r.palette.primary.main},{name:"Flag",customText:"300-599",value:t[1].value,color:r.palette.warning.main},{name:"Block",customText:"Over 600",value:t[2].value,color:r.palette.error.main}];return a.jsx(Ee,{data:s,legendToggle:!0,needleValue:n,legendLabel:o,sx:e})}export{Wt as BigNumber,Ut as ErrorCodesChart,Ee as PieChart,Xt as RiskScorePieChart,Vt as SeriesChart,Te as SeriesChartLegend,Kt as SeriesPercentageChart,Ae as SimpleBarChart,Ce as SimpleLegend};
1
+ "use strict";import{j as i}from"../../shared/jsx-runtime-DHlBLioN.mjs";import*as P from"react";import{useCallback as te,useMemo as re,createElement as Fe,useState as K,useRef as Ie,useEffect as ge}from"react";import{Box as z,Stack as U,Typography as W,useTheme as F,Paper as Pe}from"@mui/material";import{ResponsiveContainer as Z,LineChart as ze,CartesianGrid as ne,XAxis as ae,YAxis as oe,Label as ye,Tooltip as ie,Legend as ve,Line as Ve,AreaChart as Be,Area as We,ComposedChart as qe,ReferenceLine as be,ReferenceArea as we,Bar as Ke,Sector as je,PieChart as Ue,Pie as Ze,Cell as Ye}from"recharts";import{b as ke,c as Oe}from"../../shared/date-Cq0LS2Mr.mjs";import Y,{Decimal as le}from"decimal.js";import{AnimatePresence as He}from"framer-motion";import{u as Xe}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as se}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Je,C as Se}from"../../shared/motions-BBPeWBPV.mjs";import{c as $e,i as Qe,_ as H,s as et,a as $,d as tt,e as rt,f as nt,h as at,j as ot,k as it,l as lt,m as st,n as ct,o as ut,p as dt,u as pt}from"../../shared/index-KVVTzcea.mjs";import{u as mt}from"../../shared/useCounter-BV32zXDQ.mjs";const ft=["ownerState"],ht=["variants"],xt=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function gt(e){return Object.keys(e).length===0}function yt(e){return typeof e=="string"&&e.charCodeAt(0)>96}function ce(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const vt=$e(),bt=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function X({defaultTheme:e,theme:t,themeId:r}){return gt(t)?e:t[r]||t}function wt(e){return e?(t,r)=>r[e]:null}function J(e,t){let{ownerState:r}=t,n=H(t,ft);const a=typeof e=="function"?e($({ownerState:r},n)):e;if(Array.isArray(a))return a.flatMap(l=>J(l,$({ownerState:r},n)));if(a&&typeof a=="object"&&Array.isArray(a.variants)){const{variants:l=[]}=a;let o=H(a,ht);return l.forEach(c=>{let s=!0;typeof c.props=="function"?s=c.props($({ownerState:r},n,r)):Object.keys(c.props).forEach(d=>{r?.[d]!==c.props[d]&&n[d]!==c.props[d]&&(s=!1)}),s&&(Array.isArray(o)||(o=[o]),o.push(typeof c.style=="function"?c.style($({ownerState:r},n,r)):c.style))}),o}return a}function jt(e={}){const{themeId:t,defaultTheme:r=vt,rootShouldForwardProp:n=ce,slotShouldForwardProp:a=ce}=e,l=o=>tt($({},o,{theme:X($({},o,{defaultTheme:r,themeId:t}))}));return l.__mui_systemSx=!0,(o,c={})=>{Qe(o,g=>g.filter(k=>!(k!=null&&k.__mui_systemSx)));const{name:s,slot:d,skipVariantsResolver:m,skipSx:x,overridesResolver:p=wt(bt(d))}=c,f=H(c,xt),S=m!==void 0?m:d&&d!=="Root"&&d!=="root"||!1,y=x||!1;let w,v=ce;d==="Root"||d==="root"?v=n:d?v=a:yt(o)&&(v=void 0);const b=et(o,$({shouldForwardProp:v,label:w},f)),j=g=>typeof g=="function"&&g.__emotion_real!==g||rt(g)?k=>J(g,$({},k,{theme:X({theme:k.theme,defaultTheme:r,themeId:t})})):g,A=(g,...k)=>{let L=j(g);const T=k?k.map(j):[];s&&p&&T.push(u=>{const h=X($({},u,{defaultTheme:r,themeId:t}));if(!h.components||!h.components[s]||!h.components[s].styleOverrides)return null;const O=h.components[s].styleOverrides,M={};return Object.entries(O).forEach(([_,C])=>{M[_]=J(C,$({},u,{theme:h}))}),p(u,M)}),s&&!S&&T.push(u=>{var h;const O=X($({},u,{defaultTheme:r,themeId:t})),M=O==null||(h=O.components)==null||(h=h[s])==null?void 0:h.variants;return J({variants:M},$({},u,{theme:O}))}),y||T.push(l);const E=T.length-k.length;if(Array.isArray(g)&&E>0){const u=new Array(E).fill("");L=[...g,...u],L.raw=[...g.raw,...u]}const R=b(L,...T);return o.muiName&&(R.muiName=o.muiName),R};return b.withConfig&&(A.withConfig=b.withConfig),A}}const kt=jt(),Ot=(e,t)=>e.filter(r=>t.includes(r)),V=(e,t,r)=>{const n=e.keys[0];Array.isArray(t)?t.forEach((a,l)=>{r((o,c)=>{l<=e.keys.length-1&&(l===0?Object.assign(o,c):o[e.up(e.keys[l])]=c)},a)}):t&&typeof t=="object"?(Object.keys(t).length>e.keys.length?e.keys:Ot(e.keys,Object.keys(t))).forEach(a=>{if(e.keys.indexOf(a)!==-1){const l=t[a];l!==void 0&&r((o,c)=>{n===a?Object.assign(o,c):o[e.up(a)]=c},l)}}):(typeof t=="number"||typeof t=="string")&&r((a,l)=>{Object.assign(a,l)},t)};function G(e){return e?`Level${e}`:""}function q(e){return e.unstable_level>0&&e.container}function Te(e){return function(t){return`var(--Grid-${t}Spacing${G(e.unstable_level)})`}}function ue(e){return function(t){return e.unstable_level===0?`var(--Grid-${t}Spacing)`:`var(--Grid-${t}Spacing${G(e.unstable_level-1)})`}}function de(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${G(e.unstable_level-1)})`}const St=({theme:e,ownerState:t})=>{const r=Te(t),n={};return V(e.breakpoints,t.gridSize,(a,l)=>{let o={};l===!0&&(o={flexBasis:0,flexGrow:1,maxWidth:"100%"}),l==="auto"&&(o={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof l=="number"&&(o={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${l} / ${de(t)}${q(t)?` + ${r("column")}`:""})`}),a(n,o)}),n},$t=({theme:e,ownerState:t})=>{const r={};return V(e.breakpoints,t.gridOffset,(n,a)=>{let l={};a==="auto"&&(l={marginLeft:"auto"}),typeof a=="number"&&(l={marginLeft:a===0?"0px":`calc(100% * ${a} / ${de(t)})`}),n(r,l)}),r},Tt=({theme:e,ownerState:t})=>{if(!t.container)return{};const r=q(t)?{[`--Grid-columns${G(t.unstable_level)}`]:de(t)}:{"--Grid-columns":12};return V(e.breakpoints,t.columns,(n,a)=>{n(r,{[`--Grid-columns${G(t.unstable_level)}`]:a})}),r},At=({theme:e,ownerState:t})=>{if(!t.container)return{};const r=ue(t),n=q(t)?{[`--Grid-rowSpacing${G(t.unstable_level)}`]:r("row")}:{};return V(e.breakpoints,t.rowSpacing,(a,l)=>{var o;a(n,{[`--Grid-rowSpacing${G(t.unstable_level)}`]:typeof l=="string"?l:(o=e.spacing)==null?void 0:o.call(e,l)})}),n},Rt=({theme:e,ownerState:t})=>{if(!t.container)return{};const r=ue(t),n=q(t)?{[`--Grid-columnSpacing${G(t.unstable_level)}`]:r("column")}:{};return V(e.breakpoints,t.columnSpacing,(a,l)=>{var o;a(n,{[`--Grid-columnSpacing${G(t.unstable_level)}`]:typeof l=="string"?l:(o=e.spacing)==null?void 0:o.call(e,l)})}),n},Et=({theme:e,ownerState:t})=>{if(!t.container)return{};const r={};return V(e.breakpoints,t.direction,(n,a)=>{n(r,{flexDirection:a})}),r},Ct=({ownerState:e})=>{const t=Te(e),r=ue(e);return $({minWidth:0,boxSizing:"border-box"},e.container&&$({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${t("row")} / -2) calc(${t("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${t("row")} * -1) 0px 0px calc(${t("column")} * -1)`}),(!e.container||q(e))&&$({padding:`calc(${r("row")} / 2) calc(${r("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${r("row")} 0px 0px ${r("column")}`}))},Nt=e=>{const t=[];return Object.entries(e).forEach(([r,n])=>{n!==!1&&n!==void 0&&t.push(`grid-${r}-${String(n)}`)}),t},Lt=(e,t="xs")=>{function r(n){return n===void 0?!1:typeof n=="string"&&!Number.isNaN(Number(n))||typeof n=="number"&&n>0}if(r(e))return[`spacing-${t}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const n=[];return Object.entries(e).forEach(([a,l])=>{r(l)&&n.push(`spacing-${a}-${String(l)}`)}),n}return[]},_t=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([t,r])=>`direction-${t}-${r}`):[`direction-xs-${String(e)}`],Dt=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],Mt=$e(),Gt=kt("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,t)=>t.root});function Ft(e){return lt({props:e,name:"MuiGrid",defaultTheme:Mt})}function It(e={}){const{createStyledComponent:t=Gt,useThemeProps:r=Ft,componentName:n="MuiGrid"}=e,a=P.createContext(void 0),l=(s,d)=>{const{container:m,direction:x,spacing:p,wrap:f,gridSize:S}=s,y={root:["root",m&&"container",f!=="wrap"&&`wrap-xs-${String(f)}`,..._t(x),...Nt(S),...m?Lt(p,d.breakpoints.keys[0]):[]]};return st(y,w=>ct(n,w),{})},o=t(Tt,Rt,At,St,Et,Ct,$t),c=P.forwardRef(function(s,d){var m,x,p,f,S,y,w,v;const b=nt(),j=r(s),A=at(j),g=P.useContext(a),{className:k,children:L,columns:T=12,container:E=!1,component:R="div",direction:u="row",wrap:h="wrap",spacing:O=0,rowSpacing:M=O,columnSpacing:_=O,disableEqualOverflow:C,unstable_level:N=0}=A,Q=H(A,Dt);let B=C;N&&C!==void 0&&(B=s.disableEqualOverflow);const me={},fe={},he={};Object.entries(Q).forEach(([D,I])=>{b.breakpoints.values[D]!==void 0?me[D]=I:b.breakpoints.values[D.replace("Offset","")]!==void 0?fe[D.replace("Offset","")]=I:he[D]=I});const Le=(m=s.columns)!=null?m:N?void 0:T,_e=(x=s.spacing)!=null?x:N?void 0:O,De=(p=(f=s.rowSpacing)!=null?f:s.spacing)!=null?p:N?void 0:M,Me=(S=(y=s.columnSpacing)!=null?y:s.spacing)!=null?S:N?void 0:_,xe=$({},A,{level:N,columns:Le,container:E,direction:u,wrap:h,spacing:_e,rowSpacing:De,columnSpacing:Me,gridSize:me,gridOffset:fe,disableEqualOverflow:(w=(v=B)!=null?v:g)!=null?w:!1,parentDisableEqualOverflow:g}),Ge=l(xe,b);let ee=i.jsx(o,$({ref:d,as:R,ownerState:xe,className:ot(Ge.root,k)},he,{children:P.Children.map(L,D=>{if(P.isValidElement(D)&&it(D,["Grid"])){var I;return P.cloneElement(D,{unstable_level:(I=D.props.unstable_level)!=null?I:N+1})}return D})}));return B!==void 0&&B!==(g??!1)&&(ee=i.jsx(a.Provider,{value:B,children:ee})),ee});return c.muiName="Grid",c}const Ae=It({createStyledComponent:ut("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,t)=>t.root}),componentName:"MuiGrid2",useThemeProps:e=>dt({props:e,name:"MuiGrid2"})});function Pt({entry:e,payload:t}){const r=te(x=>{var p,f,S;return(S=(f=(p=x.payload)==null?void 0:p.data)==null?void 0:f.reduce)==null?void 0:S.call(f,(y,w)=>y+w.value,0)},[]),n=te(x=>{const p=new le(r(x)||0),f=t?.reduce((w,v)=>w+r(v),0)||0,S=new le(f),y=Number(p.div(S).times(100).toFixed(2,le.ROUND_DOWN));return isNaN(y)||!isFinite(y)?0:y},[r,t]),a=re(()=>r(e),[e,r]),l=se(a),o=re(()=>Number(n(e)),[e,n]),c=se(o),s=te(x=>Math.floor(x).toLocaleString(),[]),d=Xe({type:"text/plain"}),m=pt();return i.jsxs(Je,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[i.jsx(z,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),i.jsxs(U,{children:[i.jsxs(W,{component:"p",variant:"caption",children:[i.jsx(U,{component:"span",display:"inline-flex",mr:.5,children:i.jsx(Se,{from:l??0,to:a,map:s,children:"0"})}),i.jsxs(U,{component:"span",direction:"row",display:"inline-flex",children:["(",i.jsx(Se,{from:c??0,to:o,map:s,children:"0"}),"%)"]})]}),i.jsx(W,{variant:"body1",children:e.value}),e.payload.uuid&&i.jsxs(W,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{d.copy(e.payload.uuid).catch(()=>{}),m.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function Re(e){const{payload:t}=e;return i.jsx(Ae,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:i.jsx(He,{children:t?.map(r=>i.jsx(Ae,{children:i.jsx(Pt,{entry:r,payload:t})},`item-${r.value}`))})})}function zt(e){const t=F();return i.jsx(z,{sx:{width:"100%",height:"100%",...e.sx},children:i.jsx(Z,{children:i.jsxs(ze,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[i.jsx(ne,{vertical:!1}),i.jsx(ae,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:r=>ke(r,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),i.jsx(oe,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:r=>Number(r).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&i.jsx(ye,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),i.jsx(ie,{cursor:{stroke:t.palette.neutral.main,strokeWidth:1},formatter:r=>Number(r).toLocaleString(),labelFormatter:r=>Oe(r,{timeZone:e.filter.timezone,hour12:!1})}),i.jsx(ve,{content:i.jsx(Re,{})}),e.data.map(r=>Fe(Ve,{uuid:r.uuid,key:r.uuid,name:r.name,dataKey:"value",data:r.chartData,type:"monotone",stroke:r.color,strokeWidth:2}))]})})})}const Vt=(e,t)=>{const r=new Map;return e.forEach(n=>{n.chartData.forEach(a=>{const l=new Date(a.date).getTime().toString();if(!r.has(l)){const o={date:l,total:0,diff:0,totalKey:"",originalTotal:0};t.forEach(({key:c})=>{o[c]=0,o[`${c}_absolute`]=0}),r.set(l,o)}t.forEach(({key:o})=>{const c=r.get(l),s=a[o],d=typeof s=="string"?s.trim()===""?0:parseInt(s,10):typeof s=="number"?s:0;c[`${o}_absolute`]=d,c[o]=0})})}),Array.from(r.values()).map(n=>{var a;const l=(a=t.find(s=>s.isTotal))==null?void 0:a.key,o=t.filter(s=>!s.isTotal).map(s=>s.key);if(!l||o.length===0)return n;const c=n[`${l}_absolute`];return n.originalTotal=c,n.total=c,n[l]=100,o.forEach(s=>{const d=n[`${s}_absolute`],m=c>0?new Y(d.toString()).div(c).mul(100).toFixed(2,Y.ROUND_DOWN):"0.00";n[s]=parseFloat(m)}),{...n,totalKey:l}}).sort((n,a)=>parseInt(n.date)-parseInt(a.date))};function Bt(e){const t=F(),r=re(()=>e.data?Vt(e.data,e.keyValues):[],[e.data,e.keyValues]);return i.jsx(z,{sx:{width:"100%",height:"100%",...e.sx},children:i.jsx(Z,{width:"100%",height:"100%",children:i.jsxs(Be,{data:r,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[i.jsx(ne,{strokeDasharray:"3 3"}),i.jsx(ae,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:n=>ke(n,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),i.jsx(oe,{textAnchor:"end",tickLine:!1,tickFormatter:n=>`${n.toFixed(2)}%`}),i.jsx(ie,{cursor:{stroke:t.palette.neutral.main,strokeWidth:1},labelFormatter:n=>Oe(n,{timeZone:e.filter.timezone,hour12:!1}),formatter:(n,a,l)=>{const o=l.payload.totalKey,c=l.dataKey,s=c===o,d=l.payload[`${c}_absolute`],m=l.payload.originalTotal,x=s?null:m===0?"0.00":new Y(d.toString()).div(m).mul(100).toFixed(2,Y.ROUND_DOWN);return[x?`${d.toLocaleString()} (${x}%)`:`${d.toLocaleString()} (TOTAL)`,a]}}),e.keyValues.sort((n,a)=>n.isTotal?-1:a.isTotal?1:0).map(n=>i.jsx(We,{type:"monotone",dataKey:n.key,name:n.name,stroke:n.color,fill:n.color,strokeWidth:2,fillOpacity:.6},n.key))]})})})}function Wt(e){const t=se(e.value),{ref:r}=mt({from:t??0,to:e.value,duration:1,map:e.map});return i.jsx(Pe,{sx:{p:3,flex:1,...e.sx},children:i.jsxs(U,{spacing:1,alignItems:"center",children:[i.jsx(W,{ref:r,variant:"h4",fontWeight:"bold",children:e.initialValue}),i.jsx(W,{color:"text.secondary",children:e.label})]})})}const Ee={margin:{top:5,right:30,left:20,bottom:5}},qt={tickLine:!1,fontSize:12,tickMargin:12},Kt={textAnchor:"end",tickLine:!1};function pe({data:e,series:t,xAxis:r,yAxis:n,tooltip:a,bar:l,referenceLines:o,referenceAreas:c,sx:s}){const d=F(),m=p=>!p.isFront,x=p=>!!p.isFront;return i.jsx(z,{sx:{width:"100%",height:"100%",...s},children:i.jsx(Z,{children:i.jsxs(qe,{data:e,...Ee,children:[i.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),i.jsx(ae,{...qt,...r}),i.jsx(oe,{...Kt,...n}),i.jsx(ie,{cursor:{stroke:d.palette.neutral.main,strokeWidth:1},...a}),o?.filter(m).map((p,f)=>i.jsx(be,{...p},p.label??f)),c?.filter(m).map((p,f)=>i.jsx(we,{...p},p.label??f)),t.map(p=>i.jsx(Ke,{name:p.key,dataKey:p.dataKey,fill:p.color,stackId:"stack",isAnimationActive:!1,...l},p.key)),o?.filter(x).map((p,f)=>i.jsx(be,{...p},p.label??f)),c?.filter(x).map((p,f)=>i.jsx(we,{...p},p.label??f))]})})})}function Ut({data:e,sx:t}){const r=F(),n=Object.entries(e??{}).map(([l,o])=>({key:l,[l]:o})),a=n.map(({key:l})=>({key:l,dataKey:l,color:r.palette.error.light}));return i.jsx(pe,{sx:t,data:n,series:a,xAxis:{tickLine:!1,dataKey:"key"},yAxis:{tickLine:!1,domain:[0,"dataMax + 100"]},tooltip:{labelFormatter:l=>"Total"},referenceLines:[{y:100,stroke:r.palette.error.dark,strokeDasharray:"3 3",label:i.jsx(ye,{value:"Unhealthy threshold",position:"insideBottomRight"}),isFront:!0}]})}function Ce({payload:e=[],hiddenItems:t,onToggle:r,legendLabel:n}){return i.jsx(z,{sx:{display:"flex",justifyContent:"center",gap:"20px",paddingTop:"20px"},children:e.map((a,l)=>{const o=t.has(a.payload.name);return i.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",opacity:o?.4:1},onClick:()=>{r?.(a.payload)},children:[i.jsx("div",{style:{width:"12px",height:"12px",backgroundColor:a.color,marginRight:"8px",borderRadius:"2px"}}),i.jsx("span",{style:{color:a.color},children:n?`${n}: ${a.value}`:a.value})]},`legend-${l}`)})})}const Zt=e=>{const t=Math.PI/180,{cx:r,cy:n,midAngle:a,innerRadius:l,outerRadius:o,startAngle:c,endAngle:s,fill:d,payload:m,percent:x,value:p,valueText:f,valuePercentage:S,needleVisible:y,customText:w,allActive:v}=e,b=Math.sin(-t*a),j=Math.cos(-t*a),A=r+(o+5)*j,g=n+(o+5)*b,k=r+(o+15)*j,L=n+(o+15)*b,T=k+(j>=0?1:-1)*22,E=L,R=j>=0?"start":"end",u=p.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}),h=()=>y||v?null:i.jsx("text",{x:r,y:n,dy:8,textAnchor:"middle",fill:"#333",fontSize:14,children:m.name});return i.jsxs("g",{children:[h(),i.jsx(je,{cx:r,cy:n,innerRadius:l,outerRadius:o,startAngle:c,endAngle:s,fill:d}),i.jsx(je,{cx:r,cy:n,startAngle:c,endAngle:s,innerRadius:o+2,outerRadius:o+6,fill:d}),i.jsx("path",{d:`M${A},${g}L${k},${L}L${T},${E}`,stroke:d,fill:"none"}),i.jsx("circle",{cx:T,cy:E,r:2,fill:d,stroke:"none"}),i.jsx("text",{x:T+(j>=0?1:-1)*12,y:E,textAnchor:R,fill:"#333",fontSize:12,children:w||(f?`${f} ${u}`:u)}),S&&i.jsxs("text",{x:T+(j>=0?1:-1)*12,y:E,dy:16,textAnchor:R,fill:"#999",fontSize:11,children:[`${(x*100).toFixed(2)}%`," (",u,")"]})]})},Yt=e=>{const{value:t,data:r,color:n,innerRadius:a,outerRadius:l,boxDimensions:o,legendDimensions:c,valueText:s}=e,d=Math.PI/180;let m=0;r.forEach(h=>{m+=h.value});const x=o?o.width/2:150,p=(o?o.height/2:200)-c.height/2,f=180*(1-Math.max(0,Math.min(1,t/m))),S=(Number(a)+2*Number(l))/3,y=Math.sin(-d*f),w=Math.cos(-d*f),v=5,b=x-v,j=p,A=b+v*y,g=j-v*w,k=b-v*y,L=j+v*w,T=b+S*w,E=j+S*y,R=t.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}),u=s??R;return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:b,cy:j,r:v,fill:n,stroke:"none",style:{pointerEvents:"none"}},"needle-circle"),i.jsx("path",{d:`M${A} ${g}L${k} ${L} L${T} ${E} L${A} ${g}`,stroke:"none",fill:n,style:{pointerEvents:"none"}},"needle-path"),i.jsx("text",{x:b+v,y:j+26,textAnchor:"middle",fill:"#333",fontSize:12,children:u},"needle-value")]})},Ht=(e,t)=>({Allow:t.palette.success.main,Flag:t.palette.warning.main,Block:t.palette.error.main})[e]??t.palette.primary.main;function Ne({data:e,sx:t,legendLabel:r,legendToggle:n=!1,valueText:a="",valuePercentage:l=!0,pie:o,needleVisible:c=!1,needleValue:s,needleColor:d="#aaa",allActive:m=!1}){const{innerRadius:x=60,outerRadius:p=100}=o??{},f=F(),[S,y]=K(void 0),[w,v]=K(new Set),b=Ie(null),[j,A]=K(null),[g,k]=K(null),L=(u,h)=>{m||y(h)},T=()=>{m||y(void 0)},E=u=>{n&&u&&v(h=>{const O=new Set(h);return O.has(u.name)?O.delete(u.name):O.size<e.length-1&&O.add(u.name),O})},R=e.map(u=>({...u,value:w.has(u.name)?0:u.value}));return ge(()=>{const u=b.current;if(!u)return;const h=new ResizeObserver(M=>{var _;const C=(_=M[0])==null?void 0:_.contentRect;C&&A(C)});h.observe(u);const O=u.getBoundingClientRect();return A(O),()=>{h.disconnect()}},[]),ge(()=>{var u;const h=(u=b.current)==null?void 0:u.querySelector(".recharts-legend-wrapper");if(!h){const _=setInterval(()=>{var C;const N=(C=b.current)==null?void 0:C.querySelector(".recharts-legend-wrapper");if(N){const Q=N.getBoundingClientRect();k(Q),clearInterval(_)}},100);return()=>{clearInterval(_)}}const O=new ResizeObserver(_=>{var C;const N=(C=_[0])==null?void 0:C.contentRect;N&&k(N)});O.observe(h);const M=h.getBoundingClientRect();return k(M),()=>{O.disconnect()}},[]),i.jsx(z,{ref:b,sx:{width:"100%",height:"100%","& g":{outline:"none"},...t},children:i.jsx(Z,{children:i.jsxs(Ue,{...Ee,children:[i.jsx(Ze,{data:R,nameKey:"name",dataKey:"value",innerRadius:x,outerRadius:p,activeIndex:m?R.map((u,h)=>h):S,activeShape:u=>Zt({...u,valueText:a,valuePercentage:l,needleVisible:c,allActive:m}),paddingAngle:0,onMouseEnter:L,onMouseLeave:T,...o,children:R.map(u=>i.jsx(Ye,{fill:u.color??Ht(u.name,f),opacity:w.has(u.name)?.5:1,stroke:"none"},u.name))}),i.jsx(ve,{content:i.jsx(Ce,{legendLabel:r,hiddenItems:w,onToggle:E})}),c&&s!==void 0&&j&&g&&Yt({data:R,value:s,color:d,innerRadius:x,outerRadius:p,boxDimensions:j,legendDimensions:g,valueText:a})]})})})}function Xt({sx:e,data:t,score:r=200,legendLabel:n}){const a=F(),l=[{name:"Allow",customText:"0-299",value:t[0].value,color:a.palette.primary.main},{name:"Flag",customText:"300-599",value:t[1].value,color:a.palette.warning.main},{name:"Block",customText:"Over 600",value:t[2].value,color:a.palette.error.main}];return i.jsx(Ne,{data:l,legendToggle:!0,needleValue:r,legendLabel:n,allActive:!0,sx:e})}function Jt({data:e,sx:t}){const r=F(),n=(l=>{const o={};return l.forEach(c=>{Object.entries(c).forEach(([s,d])=>{const m=parseInt(s);m<=1e3&&(o[m]=(o[m]||0)+d)})}),Array.from({length:1001},(c,s)=>({key:s.toString(),value:o[s]||0}))})(e),a=[{key:"Risk Score",dataKey:"value",color:r.palette.error.main}];return i.jsx(pe,{data:n,series:a,sx:t,yAxis:{label:{value:"Count",angle:-90,position:"insideLeft"},domain:[0,"dataMax + 10"]},xAxis:{domain:[0,"dataMax"],interval:"preserveStartEnd"},tooltip:{labelFormatter:()=>"Risk Score",formatter:(l,o,c)=>[l,c.payload.key]},referenceAreas:[{x1:0,x2:299,fill:"#ffffff00",isFront:!1,label:"Allow"},{x1:300,x2:600,fill:r.palette.warning.light,isFront:!1,label:"Flag"},{x1:600,fill:r.palette.error.light,isFront:!1,label:"Block"}]})}export{Wt as BigNumber,Ut as ErrorCodesChart,Ne as PieChart,Jt as RiskScoreBarChart,Xt as RiskScorePieChart,zt as SeriesChart,Re as SeriesChartLegend,Bt as SeriesPercentageChart,pe as SimpleBarChart,Ce as SimpleLegend};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],