1import{U as M,j as e,a as O,W as U,u as Y,r as g,L as I,G as D,e as X,B as i,T as o,x as _,X as a,Y as H,P as Q,Z,_ as q,$ as J,a0 as u,a1 as z,a2 as A,c as m,a3 as y,a4 as N,a5 as $,a6 as T,a7 as W,a8 as v,a9 as V,aa as ee,ab as te,ac as se,ad as re,ae,af as ne,ag as ie,ah as c,ai as oe}from"./index-vvTfrasW.js";import{u as le}from"./useAdminFormatters-BzkGH8O-.js";import{f as b,a as B}from"./admin-dashboard.types-CoLfSGKc.js";const ce=M(e.jsx("path",{d:"M12 5c-3.87 0-7 3.13-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.87-3.13-7-7-7m1 9.29c.88-.39 1.5-1.26 1.5-2.29 0-1.38-1.12-2.5-2.5-2.5S9.5 10.62 9.5 12c0 1.02.62 1.9 1.5 2.29v3.3L7.59 21 9 22.41l3-3 3 3L16.41 21 13 17.59zM12 1C5.93 1 1 5.93 1 12h2c0-4.97 4.03-9 9-9s9 4.03 9 9h2c0-6.07-4.93-11-11-11"}),"SettingsInputAntenna"),xe=M(e.jsx("path",{d:"M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2"}),"Timeline"),he={async getDashboardData(x){const j=x?{month:x}:{};return(await O.get("/dashboard",{params:j})).data}},L=oe.chart;function de(){const x=new Date;return`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}`}function ue(){const x=U("admin"),{formatDateTime:j}=le(),s=Y(),[t,R]=g.useState(null),[p,k]=g.useState(!0),[C,S]=g.useState(null),[f,P]=g.useState(de),w=async()=>{k(!0),S(null);try{const n=await he.getDashboardData(f);R(n)}catch{S("Error loading dashboard data")}finally{k(!1)}};g.useEffect(()=>{w()},[f]);const d=(n,r,l,h)=>e.jsx(u,{in:!p,timeout:800,children:e.jsx(z,{variant:"elevation",elevation:2,sx:{height:"100%",background:`linear-gradient(135deg, ${h}15 0%, ${h}05 100%)`,border:`1px solid ${h}20`,transition:"all 0.3s ease-in-out","&:hover":{transform:"translateY(-4px)",boxShadow:`0 8px 25px ${h}30`,border:`1px solid ${h}40`}},children:e.jsxs(A,{sx:{p:3},children:[e.jsx(i,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,children:e.jsx(i,{sx:{p:1.5,borderRadius:2,backgroundColor:`${h}20`,color:h},children:l})}),e.jsx(o,{variant:"h3",component:"div",sx:{fontWeight:700,color:s.palette.text.primary,mb:1},children:r}),e.jsx(o,{variant:"body2",sx:{color:s.palette.text.secondary,fontWeight:500},children:n})]})})}),E=()=>
1{if(!(t!=null&&t.charts.usageEvolution))return null;const n=t.charts.usageEvolution.data.map(r=>({month:B(r.month||""),cost:r.cost??0}));return e.jsx(u,{in:!p,timeout:1e3,children:e.jsxs(m,{elevation:2,sx:{p:3,height:"100%",bgcolor:"background.paper",border:1,borderColor:"divider"},children:[e.jsxs(i,{display:"flex",alignItems:"center",mb:3,children:[e.jsx(xe,{sx:{mr:1.5,color:s.palette.primary.main}}),e.jsx(o,{variant:"h6",sx:{fontWeight:600},children:t.charts.usageEvolution.title})]}),e.jsx(y,{width:"100%",height:300,children:e.jsxs(N,{data:n,children:[e.jsx($,{strokeDasharray:"3 3",stroke:"#e0e0e0"}),e.jsx(T,{dataKey:"month",stroke:s.palette.text.secondary,fontSize:12,tick:{}}),e.jsx(W,{stroke:s.palette.text.secondary,fontSize:12,tick:{},tickFormatter:r=>b(r)}),e.jsx(v,{contentStyle:{backgroundColor:s.palette.background.paper,border:`1px solid ${s.palette.divider}`,borderRadius:8},formatter:r=>[b(r),"Cost"],labelFormatter:r=>`Month: ${r}`}),e.jsx(V,{type:"monotone",dataKey:"cost",stroke:s.palette.primary.main,strokeWidth:3,dot:{fill:s.palette.primary.main,strokeWidth:2,r:6},activeDot:{r:8,stroke:s.palette.primary.main,strokeWidth:2}})]})})]})})},K=()=>{if(!(t!=null&&t.charts.knowledgeBaseDistribution))return null;const n=t.charts.knowledgeBaseDistribution.data.map((r,l)=>({name:r.type||"",value:r.count??0,color:L[l%L.length]}));return e.jsx(u,{in:!p,timeout:1200,children:e.jsxs(m,{elevation:2,sx:{p:3,height:"100%",bgcolor:"background.paper",border:1,borderColor:"divider"},children:[e.jsxs(i,{display:"flex",alignItems:"center",mb:3,children:[e.jsx(ee,{sx:{mr:1.5,color:s.palette.secondary.main}}),e.jsx(o,{variant:"h6",sx:{fontWeight:600},children:t.charts.knowledgeBaseDistribution.title})]}),e.jsx(y,{width:"100%",height:300,children:e.jsxs(te,{children:[e.jsx(se,{data:n,cx:"50%",cy:"50%",labelLine:!1,label:({name:r,percent:l})=>`${r} (${(l*100).toFixed(0)}%)`,outerRadius:80,fill:"#8884d8",dataKey:"value",children:n.map((r,l)=>e.jsx(re,{fill:r.color},`cell-${l}`))}),e.jsx(v,{contentStyle:{backgroundColor:s.palette.background.paper,border:`1px solid ${s.palette.divider}`,borderRadius:8},formatter:r=>[r,"Quantity"]})]})}),e.jsx(i,{mt:2,children:n.map((r,l)=>e.jsxs(i,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[e.jsxs(i,{display:"flex",alignItems:"center",children:[e.jsx(i,{sx:{width:12,height:12,borderRadius:"50%",backgroundColor:r.color,mr:1}}),e.jsx(o,{variant:"body2",sx:{},children:r.name})]}),e.jsx(o,{variant:"body2",sx:{fontWeight:600},children:r.value})]},l))})]})})},F=()=>{if(!(t!=null&&t.charts.organizationGrowth))return null;const n=t.charts.organizationGrowth.data.map(r=>({month:B(r.month||""),count:r.count??0}));return e.jsx(u,{in:!p,timeout:1200,children:e.jsxs(m,{elevation:2,sx:{p:3,height:"100%",bgcolor:"background.paper",border:1,borderColor:"divider"},children:[e.jsxs(i,{display:"flex",alignItems:"center",mb:3,children:[e.jsx(ae,{sx:{mr:1.5,color:s.palette.info.main}}),e.jsx(o,{variant:"h6",sx:{fontWeight:600},children:t.charts.organizationGrowth.title})]}),e.jsx(y,{width:"100%",height:300,children:e.jsxs(ne,{data:n,children:[e.jsx($,{strokeDasharray:"3 3",stroke:"#e0e0e0"}),e.jsx(T,{dataKey:"month",stroke:s.palette.text.secondary,fontSize:12,tick:{}}),e.jsx(W,{stroke:s.palette.text.secondary,fontSize:12,tick:{}}),e.jsx(v,{contentStyle:{backgroundColor:s.palette.background.paper,border:`1px solid ${s.palette.divider}`,borderRadius:8},formatter:r=>[r,"Organizations"]}),e.jsx(ie,{dataKey:"count",fill:s.palette.info.main,radius:[4,4,0,0]})]})})]})})},G=()=>e.jsxs(a,{container:!0,spacing:3,children:[[1,2,3,4,5,6].map(n=>e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:e.jsx(z,{sx:{height:200},children:e.jsxs(A,{children:[e.jsx(c,{variant:"rectangular",height:60,sx:{mb:2}}),e.jsx(c,{variant:"text",height:40,sx:{mb:1}}),e.jsx(c,{variant:"text",height:20})]})})},n)),e.jsx(a,{item:!0,xs:12,lg:8,children:e.jsxs(m,{sx:{height:400,p:3},children:[e.jsx(c,{variant:"text",height:30,sx:{mb:2}}),e.jsx(c,{variant:"rectangular",height:300})]})}),e.jsx(a,{item:!0,xs:12,lg:4,children:e.jsxs(m,{sx:{height:400,p:3},children:[e.jsx(c,{variant:"text",height:30,sx:{mb:2}}),e.jsx(c,{variant:"rectangular",height:300})]})}),e.jsx(a,{item:!0,xs:12,children:e.jsxs(m,{sx:{height:400,p:3},children:[e.jsx(c,{variant:"text",height:30,sx:{mb:2}}),e.jsx(c,{variant:"rectangular",height:300})]})})]});return C?e.jsx(I,{children:e.jsx(D,{severity:"error",sx:{mb:3},action:e.jsx(X,{onClick:w,children:"Try Again"}),children:C})}):e.jsx(I,{children:e.jsxs(i,{children:[e.jsxs(i,{mb:4,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:2,children:[e.jsxs(i,{children:[e.jsx(o,{variant:"h3",sx:{fontWeight:700,color:s.palette.primary.main,mb:1},children:"Dashboard"}),e.jsx(o,{variant:"body1",sx:{color:s.palette.text.secondary,fontWeight:400}
1,children:"Overview of your SaaS platform"})]}),e.jsx(_,{label:"Month",type:"month",value:f,onChange:n=>P(n.target.value),InputLabelProps:{shrink:!0},size:"small",sx:{minWidth:180}})]}),p?G():e.jsxs(e.Fragment,{children:[e.jsxs(a,{container:!0,spacing:3,mb:4,children:[e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Total Organizations",(t==null?void 0:t.kpis.totalOrganizations)??0,e.jsx(H,{fontSize:"large"}),s.palette.primary.main)}),e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Total Users",(t==null?void 0:t.kpis.totalUsers)??0,e.jsx(Q,{fontSize:"large"}),s.palette.info.main)}),e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Active Conversations",(t==null?void 0:t.kpis.activeConversations)??0,e.jsx(Z,{fontSize:"large"}),s.palette.success.main)}),e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Monthly Cost",b((t==null?void 0:t.kpis.monthlyCost)??0),e.jsx(q,{fontSize:"large"}),s.palette.warning.main)}),e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Active Knowledge Bases",(t==null?void 0:t.kpis.activeKnowledgeBases)??0,e.jsx(J,{fontSize:"large"}),s.palette.secondary.main)}),e.jsx(a,{item:!0,xs:12,sm:6,lg:4,children:d("Total Channels",(t==null?void 0:t.kpis.totalChannels)??0,e.jsx(ce,{fontSize:"large"}),s.palette.error.main)})]}),e.jsxs(a,{container:!0,spacing:3,children:[e.jsx(a,{item:!0,xs:12,lg:8,children:E()}),e.jsx(a,{item:!0,xs:12,lg:4,children:K()}),e.jsx(a,{item:!0,xs:12,children:F()})]}),(t==null?void 0:t.timestamp)&&e.jsx(i,{mt:4,textAlign:"center",children:e.jsx(o,{variant:"caption",sx:{color:s.palette.text.secondary},children:x("lastUpdated",{date:j(t.timestamp)})})})]})]})})}export{ue 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.