1import{j as e,a as c}from"./vendor-mui-B3bBnIQX.js";import{u as B}from"./useTopbar-DdNCAeWW.js";import{L as H,fI as O}from"./index-K18uQlJT.js";import{S as p}from"./StatTile-Bsybp9Hf.js";import{I as j}from"./insightsStatusColors-BRdZlWrL.js";import{f as P}from"./vendor-state-3ufgB8Gu.js";import{b as N,f as Y,h as q,i as W}from"./policyApi-DbjTp9t3.js";import{a8 as y}from"./CategoricalChart-C32z8okr.js";import{B as X,a as z}from"./BarChart-DwfAoU7I.js";import{C as Q,X as U,Y as J,T as L}from"./CartesianChart-C0Wdw95N.js";import{P as S,a as T}from"./PieChart-DNlwBoSQ.js";import{C as v}from"./tooltipContext-Bl8be_Wh.js";import"./vendor-router-DjW2o810.js";import"./vendor-forms-BOKXSlZG.js";import"./getZIndexFromUnknown-UX86BcYZ.js";import"./getClassNameFromUnknown-CFdCWhIp.js";import"./PolarChart-BPPFJCrw.js";const V=(n={})=>P({queryKey:N.INSIGHTS_STATUS,queryFn:()=>Y().then(a=>a.data?.data?.records??a.data?.records??{}),...n}),Z=(n={})=>P({queryKey:N.INSIGHTS_PENDING,queryFn:()=>q().then(a=>{const m=(a.data?.data?.records??a.data?.records??{})?.resultPendingPolicy;return Array.isArray(m)?m:[]}),...n}),$=(n={})=>P({queryKey:N.INSIGHTS_DEPT_WISE,queryFn:()=>W().then(a=>a.data?.data?.records??a.data?.records??[]),...n}),R=({active:n,payload:a,label:d,formatter:m,labelFormatter:i})=>!n||!a?.length?null:e.jsxs("div",{className:"bg-surface border border-border rounded-lg shadow-lg px-3 py-2 flex flex-col gap-1 min-w-[140px]",children:[d!=null&&e.jsx("p",{className:"text-xs font-semibold text-text-primary",children:i?i(d):d}),a.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:o.color??o.payload?.fill}}),e.jsx("span",{className:"text-text-secondary truncate",children:o.name}),e.jsx("span",{className:"font-semibold text-text-primary ml-auto whitespace-nowrap",children:m?m(o.value,o):o.value})]},o.dataKey??o.name))]}),b=n=>j[n%j.length],g={acknowledgement:b(0),generic:b(1)},D=b(0),ee=n=>O(j,n);function se({active:n,payload:a}){if(!n||!a?.length)return null;const{name:d,value:m,policies:i=[]}=a[0].payload;return e.jsxs("div",{className:"bg-surface border border-border rounded-xl shadow-lg px-3 py-2 text-xs max-w-[220px]",children:[e.jsxs("p",{className:"font-semibold text-text-primary mb-1",children:[d,": ",e.jsx("span",{children:m})]}),i.length>0&&e.jsx("ul",{className:"max-h-40 overflow-y-auto list-disc pl-4 space-y-0.5",children:i.map(o=>e.jsx("li",{className:"text-text-secondary",children:o.policyName},o.id))})]})}const _={fontSize:11,fill:"var(--color-text-secondary)"};function ve(){const{data:n={},isFetching:a}=V(),{data:d=[],isFetching:m}=Z(),{data:i=[],isFetching:o}=$(),[x,u]=c.useState(null),[w,M]=c.useState({x:0,y:0}),f=c.useRef(null),F=a||m||o,I=(r,s)=>{u(r);const t=f.current?.getBoundingClientRect();if(!t||!s)return;const l=232,E=200,G=Math.max(0,Math.min(s.clientX-t.left+16,t.width-l)),K=Math.max(0,Math.min(s.clientY-t.top+16,t.height-E));M({x:G,y:K})},k=c.useRef({x:-1,y:-1});c.useEffect(()=>{const r=s=>{k.current={x:s.clientX,y:s.clientY}};return window.addEventListener("mousemove",r,!0),()=>window.removeEventListener("mousemove",r,!0)},[]),c.useEffect(()=>{const r=()=>u(null),s=t=>{t.relatedTarget||r()};return document.addEventListener("mouseout",s),window.addEventListener("blur",r),()=>{document.removeEventListener("mouseout",s),window.removeEventListener("blur",r)}},[]),c.useEffect(()=>{if(x===null)return;const r=setInterval(()=>{const s=f.current?.getBoundingClientRect();if(!s)return;const{x:t,y:l}=k.current;t>=s.left&&t<=s.right&&l>=s.top&&l<=s.bottom||u(null)},150);return()=>clearInterval(r)},[x]),B({title:"Insights",subtitle:"See policy insights",searchPlaceholder:!1,tabs:{items:[]},deps:[]});const A=c.useMemo(()=>{const r=d.reduce((s,t)=>{const l=t.policyName??"Policy";return s[l]=(s[l]??0)+(t.pendingPolicyCount??0),s},{});return Object.entries(r).map(([s,t])=>({name:s,pending:t}))},[d]),C=c.useMemo(()=>{const r=i.reduce((t,l)=>t+(l.acknowledgementPolicies??0),0),s=i.reduce((t,l)=>t+(l.genericPolicies??0),0);return[{name:"Acknowledgment Policies",value:r},{name:"Generic Policies",value:s}].filter(t=>t.value>0)},[i]),h=c.useMemo(()=>i.map(r=>({name:r.departmentName??"Dept",value:r.totalPolicies??0,policies:r.policies??[]})).filter(r=>r.value>0),[i]);return e.jsxs("div",{className:"flex flex-col gap-5",children:[F&&e.jsx(H,{}),e.jsx("div",{className:"bg-surface border border-border rounded-2xl shadow-sm hover:border-primary transition-colors p-5",children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-6 gap-6",children:[e.jsx(p,{value:n.totalCount,label:"Total",sub:"Policies(s)"}),e.jsx(p,{value:n.activeCount,label:"Active",sub:"Policies(s)"}),e.jsx(p,{value:n.inactiveCount,label:"In-Active",sub:"Policies(s)"}),e.jsx(p,{value:n.acknowledgementPolicyCount,label:"Acknowledgment",sub:"Policies(s)"})]})}),A.length>0&&e.jsxs("div",{className:"bg-surface border border-border rounded-2xl shadow-sm hover:border-primary transition-colors p-5",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary mb-4",children:"Pending Acknowledgment Per Policies"}),e.jsx(y,{width:"100%",height:280,children:e.jsxs(X,{data:A,barCategoryGap:"35%",children:[e.jsx(Q,{vertical:!1,stroke:"var(--color-border)"}
1),e.jsx(U,{dataKey:"name",tick:_,axisLine:{stroke:"var(--color-border)"},tickLine:!1}),e.jsx(J,{tick:_,axisLine:!1,tickLine:!1}),e.jsx(L,{content:e.jsx(R,{}),cursor:{fill:"var(--color-surface-hover)"}}),e.jsx(z,{dataKey:"pending",name:"Pending Acknowledgment by Polices",fill:D,radius:[4,4,0,0],maxBarSize:48})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("span",{className:"w-3 h-3 rounded-full shrink-0",style:{background:D}}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Pending Acknowledgment by Polices"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"bg-surface border border-border rounded-2xl shadow-sm hover:border-primary transition-colors p-5",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary mb-4",children:"Policies Type"}),C.length>0?e.jsxs(e.Fragment,{children:[e.jsx(y,{width:"100%",height:320,children:e.jsxs(S,{children:[e.jsxs(T,{data:C,dataKey:"value",nameKey:"name",outerRadius:160,startAngle:90,endAngle:-270,children:[e.jsx(v,{fill:g.acknowledgement}),e.jsx(v,{fill:g.generic})]}),e.jsx(L,{content:e.jsx(R,{})})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-5 mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[e.jsx("span",{className:"w-3 h-3 rounded-full shrink-0",style:{background:g.acknowledgement}}),"Acknowledgment Policies"]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[e.jsx("span",{className:"w-3 h-3 rounded-full shrink-0",style:{background:g.generic}}),"Generic Policies"]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-40 text-sm text-text-secondary",children:"No data"})]}),e.jsxs("div",{className:"bg-surface border border-border rounded-2xl shadow-sm hover:border-primary transition-colors p-5",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary mb-4",children:"Policies By Department"}),h.length>0?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"relative",ref:f,onMouseLeave:()=>u(null),children:[e.jsx(y,{width:"100%",height:320,children:e.jsx(S,{children:e.jsx(T,{data:h,dataKey:"value",nameKey:"name",innerRadius:70,outerRadius:160,startAngle:90,endAngle:-270,onMouseEnter:(r,s,t)=>I(s,t),onMouseMove:(r,s,t)=>I(s,t),onMouseLeave:()=>u(null),children:h.map((r,s)=>e.jsx(v,{fill:ee(s)},s))})})}),x!==null&&h[x]&&e.jsx("div",{className:"absolute z-10",style:{left:w.x,top:w.y},onMouseEnter:()=>u(x),onMouseLeave:()=>u(null),children:e.jsx(se,{active:!0,payload:[{payload:h[x]}]})})]})}):e.jsx("div",{className:"flex items-center justify-center h-40 text-sm text-text-secondary",children:"No data"})]})]})]})}export{ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.