1import{c as Pe,r as N,s as f,j as e,h as y,t as j,L as Y,B as q,x as J,F as Ce,H as ke,i as me,k as xe,J as Ae,A as he,m as pe,P as H,f as _e,U as ne,D as Se,G as De,T as Re,K as Me}from"./index-DLd_kDlx.js";import{S as z}from"./SuperAdminLayout-BsUvQU2j.js";import{T as Q}from"./trending-up-BU4cR3Ys.js";import{T as ue}from"./trending-down-BvA8vA3u.js";import{E as Te}from"./external-link-D0CFvOTk.js";import{A as Fe,a as Ie}from"./alert-CyfKy7ls.js";import{T as V}from"./triangle-alert-Chqk_WK7.js";import{R as F,T as I,L as Ee,a as Ge,B as oe,C as B}from"./generateCategoricalChart-ByDL-d9M.js";import{B as Be}from"./BarChart-mmA8KDsJ.js";import{C as Z}from"./CartesianGrid-ChidKd9i.js";import{X as ee,Y as te}from"./YAxis-BtEb5zMI.js";import{P as ie,a as le}from"./PieChart-Bcnc_bSW.js";import{L as Oe,a as Ue}from"./LineChart-BqKg5nac.js";import{i as Ke,C as ce}from"./calendar-CX7fcgXP.js";import{P as Xe,a as We,b as $e}from"./popover-BMD5FOmU.js";import{p as O}from"./parseISO-B4sJZ6AV.js";import{A as ze,a as He}from"./AreaChart-DvsyYnZ8.js";import{f as U}from"./format-BTXglRCX.js";import{i as de}from"./isAfter-DDRF2ylA.js";import{s as Ve}from"./subDays-B5afKHU7.js";import{u as Ye}from"./useSuperAdminPods-DR7Jcl7M.js";import{L as qe}from"./loader-circle-D2miE2xB.js";import{U as Je}from"./users-round-DunEH6L6.js";import"./NotificationIcon-C1wwYnH5.js";import"./scroll-area-BXTuUF24.js";import"./index-Deh-4PO1.js";import"./index-BdQq_4o_.js";import"./NotificationItem-Dc2WXW-y.js";import"./formatDistanceToNow-57P64IbE.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./message-square-CtxeCfRz.js";import"./trophy-DBX-jNOC.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-lTaZyIGy.js";import"./chevron-right-CD1gvy-q.js";import"./crown-hzm_bRIt.js";import"./user-check-DxoAQXwU.js";import"./star-BH1OFEcs.js";import"./globe-C057RQ73.js";import"./timer-CZhDpZys.js";import"./briefcase-business-CphIeAJd.js";import"./key-round-B79BulHq.js";import"./search-DFH5eAlA.js";import"./findIndex-Cos7Fxsp.js";import"./tiny-invariant-CopsF_GD.js";import"./PolarAngleAxis-Blx3t8Nb.js";import"./endOfWeek-6cC00CtY.js";import"./chevron-left-Wewsh5d7.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Qe=Pe("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),Ze=300*1e3;let S={data:null,fetchedAt:0};const et=()=>{const[t,s]=N.useState(S.data),[o,n]=N.useState(!S.data),[r,i]=N.useState(null);return N.useEffect(()=>{(async()=>{var m,p;if(S.data&&Date.now()-S.fetchedAt<Ze){s(S.data),n(!1);return}try{n(!0);const u=new Date;u.setMonth(u.getMonth()-1);const[w,D,L,c,C,k,E]=await Promise.all([f.from("profiles").select("user_type"),f.from("xterns_profiles").select("user_id, assessment_completed"),f.from("tech_lead_assessments").select("user_id, assessment_completed"),f.from("xtern_tech_assessments").select("id").eq("assessment_type","onboarding"),f.from("tech_lead_tech_assessment_results").select("attempt_id, passed"),f.from("pod_members").select("user_id, role, status"),f.rpc("get_daily_login_counts")]),g=w.data,l=D.data,h=L.data,d=C.data,b=k.data,P={xterns:(g==null?void 0:g.filter(a=>a.user_type==="xtern").length)||0,techLeads:(g==null?void 0:g.filter(a=>a.user_type==="tech_lead").length)||0,enterprise:(g==null?void 0:g.filter(a=>a.user_type==="corporate").length)||0},ge={total:(l==null?void 0:l.length)||0,completed:(l==null?void 0:l.filter(a=>a.assessment_completed).length)||0,rate:l!=null&&l.length?l.filter(a=>a.assessment_completed).length/l.length*100:0},fe={total:(h==null?void 0:h.length)||0,completed:(h==null?void 0:h.filter(a=>a.assessment_completed).length)||0,rate:h!=null&&h.length?h.filter(a=>a.assessment_completed).length/h.length*100:0},se=((m=c.data)==null?void 0:m.map(a=>a.id))||[];let A=[];if(se.length>0){const{data:a}=await f.from("xtern_tech_assessment_attempts").select("id").in("tech_assessment_id",se),v=(a==null?void 0:a.map(_=>_.id))||[];if(v.length>0){const{data:_}=await f.from("xtern_tech_assessment_results").select("attempt_id, score_percentage").in("attempt_id",v);A=_||[]}}
6const je={total:A.length,passed:A.filter(a=>a.score_percentage>=20).length,rate:A.length?A.filter(a=>a.score_percentage>=20).length/A.length*100:0},ve={total:(d==null?void 0:d.length)||0,passed:(d==null?void 0:d.filter(a=>a.passed).length)||0,rate:d!=null&&d.length?d.filter(a=>a.passed).length/d.length*100:0},G=(b==null?void 0:b.filter(a=>a.status==="active"))||[],be={active:G.filter(a=>a.role==="member").length,total:P.xterns,rate:P.xterns>0?G.filter(a=>a.role==="member").length/P.xterns*100:0},Ne={active:G.filter(a=>a.role==="tech_lead").length,total:P.techLeads,rate:P.techLeads>0?G.filter(a=>a.role==="tech_lead").length/P.techLeads*100:0};let X=0,R=0,W=0,ae=[];try{const{data:a,error:v}=await f.functions.invoke("fetch-dareyscore-analytics",{body:{action:"platform-scores",months:6}});if(v||a!=null&&a.error)throw new Error((v==null?void 0:v.message)||(a==null?void 0:a.error)||"API error");X=Number(a.current_month_avg??a.current_avg??0),R=Number(a.previous_month_avg??a.previous_avg??0);const _=a.growth_percent??a.growth_percentage;_!=null?W=Number(_):R>0&&(W=(X-R)/R*100),ae=(a.monthly_trend||[]).map(M=>({month:M.month,avgScore:Number(M.avg_score??M.avgScore??0),userCount:Number(M.user_count??M.userCount??0)})),console.log("[useSuperAdminMetrics] Signal Score API response used successfully")}catch(a){console.warn("[useSuperAdminMetrics] Signal Score API unavailable, chart will be empty:",a)}const $=(E.data||[]).map(a=>({date:a.login_date,count:Number(a.login_count)})),ye=new Date().toISOString().slice(0,10),we=((p=$.find(a=>a.date===ye))==null?void 0:p.count)||0,Le=$.reduce((a,v)=>a+v.count,0),re={totalUsers:P,onboardingRates:{xterns:ge,techLeads:fe},assessmentRates:{xterns:je,techLeads:ve},podParticipation:{xterns:be,techLeads:Ne},dareyScoreGrowth:{currentMonth:X,previousMonth:R,growthPercent:W,monthlyTrend:ae},platformActivity:{dailyLogins:$,todayLogins:we,totalLast30Days:Le}};S={data:re,fetchedAt:Date.now()},s(re),i(null)}catch(u){console.error("Error fetching super admin metrics:",u),i(u instanceof Error?u.message:"Failed to fetch metrics")}finally{n(!1)}})()},[]),{metrics:t,isLoading:o,error:r}},tt=({metrics:t})=>{const s=[{value:t.onboardingRates.xterns.rate,target:60},{value:t.onboardingRates.techLeads.rate,target:60},{value:t.assessmentRates.xterns.rate,target:60},{value:t.assessmentRates.techLeads.rate,target:60},{value:t.podParticipation.xterns.rate,target:55},{value:t.podParticipation.techLeads.rate,target:55},{value:t.dareyScoreGrowth.growthPercent,target:10},{value:t.platformActivity.todayLogins,target:5}],o=s.filter(m=>m.value>=m.target).length,n=Math.round(o/s.length*100),r=2*Math.PI*30,i=r-n/100*r,x=m=>m>=80?"Excellent":m>=60?"Good":m>=40?"Fair":"Needs Attention";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"transform -rotate-90 w-20 h-20",children:[e.jsx("circle",{cx:"40",cy:"40",r:"30",stroke:"rgba(255,255,255,0.2)",strokeWidth:"6",fill:"none"}),e.jsx("circle",{cx:"40",cy:"40",r:"30",stroke:"white",strokeWidth:"6",fill:"none",strokeDasharray:r,strokeDashoffset:i,strokeLinecap:"round",className:"transition-all duration-1000 ease-out"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"text-xl font-bold text-white",children:n})})]}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx("p",{className:"text-white font-semibold text-sm",children:x(n)}),e.jsxs("p",{className:"text-white/70 text-xs",children:[o,"/",s.length," KPIs on target"]})]})]})},K=({title:t,value:s,icon:o,accentColor:n,trend:r,onboardingRate:i})=>{const x=()=>r?r.direction==="up"?e.jsx(Q,{className:"h-3 w-3"}):r.direction==="down"?e.jsx(ue,{className:"h-3 w-3"}):e.jsx(Qe,{className:"h-3 w-3"}):null,m=()=>r?r.direction==="up"?"text-emerald-600":r.direction==="down"?"text-destructive":"text-muted-foreground":"",p=n==="purple";return e.jsxs(y,{className:j("p-5 bg-card transition-all duration-300 hover:shadow-md border-l-4",p?"border-l-primary":"border-l-accent"),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t}),e.jsx("h3",{className:"text-3xl font-bold text-foreground",children:s}),r&&e.jsxs("div",{className:j("inline-flex items-center gap-1 text-xs font-medium mt
6-1",m()),children:[x(),e.jsxs("span",{children:[Math.abs(r.value),"% vs last month"]})]})]}),e.jsx("div",{className:j("p-2.5 rounded-lg",p?"bg-primary/10":"bg-accent/10"),children:e.jsx(o,{className:j("h-5 w-5",p?"text-primary":"text-accent")})})]}),i!==void 0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[e.jsx("span",{children:"Onboarding"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[i.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:j("h-full rounded-full transition-all duration-500",p?"bg-primary":"bg-accent"),style:{width:`${Math.min(i,100)}%`}})})]})]})},T=({title:t,icon:s,xternValue:o,techLeadValue:n,target:r,xternsOnly:i,unit:x="%",viewDataLink:m})=>{const p=o>=r,u=n?n>=r:!0,w=2*Math.PI*35,D=w-Math.min(o,100)/100*w,L=2*Math.PI*28,c=L-(n?Math.min(n,100)/100*L:0);return e.jsx(y,{className:"p-4 hover:shadow-md hover:border-primary/30 transition-all duration-300 group bg-card",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(s,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"text-sm font-semibold",children:t})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsxs("svg",{className:"transform -rotate-90 w-24 h-24",children:[e.jsx("circle",{cx:"48",cy:"48",r:"35",strokeWidth:"8",fill:"none",className:"stroke-muted"}),!i&&e.jsx("circle",{cx:"48",cy:"48",r:"28",strokeWidth:"6",fill:"none",className:"stroke-muted"}),e.jsx("circle",{cx:"48",cy:"48",r:"35",stroke:"#6B1ECF",strokeWidth:"8",fill:"none",className:"transition-all duration-1000 ease-out",strokeDasharray:w,strokeDashoffset:D,strokeLinecap:"round"}),!i&&n!==void 0&&e.jsx("circle",{cx:"48",cy:"48",r:"28",stroke:"#F03DD9",strokeWidth:"6",fill:"none",className:"transition-all duration-1000 ease-out",strokeDasharray:L,strokeDashoffset:c,strokeLinecap:"round"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsxs("span",{className:"text-xl font-bold text-foreground",children:[o.toFixed(0),x]}),!i&&n!==void 0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.toFixed(0),x]})]})]}),e.jsxs("div",{className:"space-y-1 w-full text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-muted-foreground",children:"Xterns"}),p&&e.jsx("span",{className:"text-green-600 font-semibold",children:"â"})]}),!i&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent"}),e.jsx("span",{className:"text-muted-foreground",children:"Tech Leads"}),u&&e.jsx("span",{className:"text-green-600 font-semibold",children:"â"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground pt-1 border-t border-border",children:["Target: ",r,x]})]}),m&&e.jsx("div",{className:"mt-3 pt-3 border-t border-border",children:e.jsx(Y,{to:m,children:e.jsxs(q,{variant:"ghost",size:"sm",className:"w-full text-xs text-primary hover:text-primary hover:bg-primary/5",children:["View Data",e.jsx(Te,{className:"h-3 w-3 ml-1"})]})})})]})})},st=({metrics:t})=>{const s=[];if(t.onboardingRates.xterns.rate<60){const r=60-t.onboardingRates.xterns.rate;s.push({label:"Xtern Onboarding",value:t.onboardingRates.xterns.rate,target:60,severity:r>20?"critical":"warning"})}if(t.onboardingRates.techLeads.rate<60){const r=60-t.onboardingRates.techLeads.rate;s.push({label:"TL Onboarding",value:t.onboardingRates.techLeads.rate,target:60,severity:r>20?"critical":"warning"})}if(t.assessmentRates.xterns.rate<60){const r=60-t.assessmentRates.xterns.rate;s.push({label:"Xtern Assessment",value:t.assessmentRates.xterns.rate,target:60,severity:r>20?"critical":"warning"})}if(t.assessmentRates.techLeads.rate<60){const r=60-t.assessmentRates.techLeads.rate;s.push({label:"TL Assessment",value:t.assessmentRates.techLeads.rate,target:60,severity:r>20?"critical":"warning"})}if(t.podParticipation.xterns.rate<55){const r=55-t.podParticipation.xterns.rate;s.push({label:"Pod Participation",value:t.podParticipation.xterns.rate,target:55,severity:r>20?"critical":"warning"})}if(t.dareyScoreGrowth.growthPercent<10){const r=10-t.dareyScoreGrowth.growthPercent;s.push({label:"Score Growth",value:t.dareyScoreGrowth.growthPercent,target:10,severity:r>5?"critical":"warning"})}if(t.platformActivity.todayLogins<5&&s.push({label:"Daily Logins",value:t.platformActivity.todayLogins,target:5,severity:t.platformActivity.todayLogins<2?"critical":"warning"}),s.length===0)return e.jsxs(Fe,{className:"border-green-200 bg-green-50",children:[e.jsx(J,{className:"h-4 w-4 text-green-600"}),e.jsx(Ie,{className:"text-green-800",children:"All KPIs are meeting their targets! Platform is performing well."})]});const o=s.filter(r=>r.severity==="critical"),n=s.filter(r=>r.severity==="warning");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5 text-accent"}),e.jsx("h3",{className:"font-semibold",children:"Needs Attention"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.map((r,i)=>e.jsxs("div",{className:j("inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium","bg-accent/10 text-accent border border-accent/20"),children:[e.jsx(Ce,{className:"h-3 w-3"}),e.jsx("span",{children:r.label}),e.jsxs("span",{className:"font-bold",children:[r.value.toFixed(1),"%"]})]},i)),n.map((r,i)=>e.jsxs("div",{className:j("inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium","bg-primary/10 text-primary border border-primary/20"),children:[e.jsx(V,{className:"h-3 w-3"}),e.jsx("span",{children:r.label}),e.jsxs("span",{className:"font-bold",children:[r.value.toFixed(1),"%"]})]},i))]})]})},at=({metrics:t})=>{const s=[{name:"Onboarding",Xterns:t.onboardingRates.xterns.rate,"Tech Leads":t.onboardingRates.techLeads.rate}
6,{name:"Assessment Success",Xterns:t.assessmentRates.xterns.rate,"Tech Leads":t.assessmentRates.techLeads.rate}];return e.jsxs(y,{className:"p-6 border-l-4 border-l-primary",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Onboarding & Assessment Rates"}),e.jsx(F,{width:"100%",height:300,children:e.jsxs(Be,{data:s,children:[e.jsx(Z,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ee,{dataKey:"name",className:"text-xs"}),e.jsx(te,{className:"text-xs",domain:[0,100]}),e.jsx(I,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"},formatter:o=>`${o.toFixed(1)}%`}),e.jsx(Ee,{}),e.jsx(Ge,{y:60,stroke:"hsl(var(--destructive))",strokeDasharray:"3 3",label:"Target 60%"}),e.jsx(oe,{dataKey:"Xterns",fill:"#6B1ECF",radius:[4,4,0,0]}),e.jsx(oe,{dataKey:"Tech Leads",fill:"#F03DD9",radius:[4,4,0,0]})]})})]})},rt=({metrics:t})=>{const s=[{name:"Active in Pods",value:t.podParticipation.xterns.active},{name:"Not in Pods",value:t.podParticipation.xterns.total-t.podParticipation.xterns.active}],o=[{name:"Active in Pods",value:t.podParticipation.techLeads.active},{name:"Not in Pods",value:t.podParticipation.techLeads.total-t.podParticipation.techLeads.active}],n={xternActive:"#6B1ECF",xternInactive:"#6B1ECF33",tlActive:"#F03DD9",tlInactive:"#F03DD933"};return e.jsxs(y,{className:"p-6 border-l-4 border-l-accent",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Pod Participation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-center mb-2",children:"Xterns"}),e.jsx(F,{width:"100%",height:200,children:e.jsxs(ie,{children:[e.jsxs(le,{data:s,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",children:[e.jsx(B,{fill:n.xternActive}),e.jsx(B,{fill:n.xternInactive})]}),e.jsx(I,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}})]})}),e.jsxs("div",{className:"text-center mt-2",children:[e.jsxs("p",{className:"text-2xl font-bold",children:[t.podParticipation.xterns.rate.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.podParticipation.xterns.active," of ",t.podParticipation.xterns.total]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Target: 55%"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-center mb-2",children:"Tech Leads"}),e.jsx(F,{width:"100%",height:200,children:e.jsxs(ie,{children:[e.jsxs(le,{data:o,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",children:[e.jsx(B,{fill:n.tlActive}),e.jsx(B,{fill:n.tlInactive})]}),e.jsx(I,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}})]})}),e.jsxs("div",{className:"text-center mt-2",children:[e.jsxs("p",{className:"text-2xl font-bold",children:[t.podParticipation.techLeads.rate.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.podParticipation.techLeads.active," of ",t.podParticipation.techLeads.total]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Target: 55%"})]})]})]})]})},nt=({metrics:t})=>{const s=t.dareyScoreGrowth.monthlyTrend.map(n=>({month:new Date(n.month).toLocaleDateString("en-US",{month:"short",year:"2-digit"}),score:n.avgScore,users:n.userCount})),o=t.dareyScoreGrowth.growthPercent>=10;return e.jsxs(y,{className:"p-6 border-l-4 border-l-primary",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Signal Score Growth"}),e.jsxs("div",{className:j("flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium",o?"bg-green-100 text-green-700":"bg-accent/10 text-accent"),children:[o?e.jsx(Q,{className:"h-4 w-4"}):e.jsx(ue,{className:"h-4 w-4"}),t.dareyScoreGrowth.growthPercent.toFixed(1),"% MoM"]})]}),e.jsx(F,{width:"100%",height:300,children:e.jsxs(Oe,{data:s,children:[e.jsx(Z,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ee,{dataKey:"month",className:"text-xs"}),e.jsx(te,{className:"text-xs",domain:[0,"auto"]}),e.jsx(I,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"},formatter:n=>n.toFixed(1)}),e.jsx(Ue,{type:"monotone",dataKey:"score",stroke:"#6B1ECF",strokeWidth:2,dot:{fill:"#6B1ECF",r:4}})]})}),e.jsxs("div",{className:"mt-4 p-3 bg-primary/5 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Current Month Average"}),e.jsx("p",{className:"text-2xl font-bold",children:t.dareyScoreGrowth.currentMonth.toFixed(1)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Target: â¥10% growth per month"})]})]})},ot=({metrics:t})=>{const{platformActivity:s}=t,[o,n]=N.useState("30d"),[r,i]=N.useState(),[x,m]=N.useState(),{filteredData:p,rangeTotal:u,rangeLabel:w}=N.useMemo(()=>{const c=new Date;let C,k;if(o==="custom"&&r&&x){C=r;const l=x;k=`${U(r,"MMM d")} â ${U(x,"MMM d")}`;const h=s.dailyLogins.filter(d=>{const b=O(d.date);return!Ke(b,C)&&!de(b,l)});return{filteredData:h.map(d=>({date:d.date,label:U(O(d.date),"MMM d"),Logins:d.count})),rangeTotal:h.reduce((d,b)=>d+b.count,0),rangeLabel:k}}const E=o==="7d"?7:o==="14d"?14:30;C=Ve(c,E),k=`Last ${E} Days`;const g=s.dailyLogins.filter(l=>de(O(l.date),C));return{filteredData:g.map(l=>({date:l.date,label:U(O(l.date),"MMM d"),Logins:l.count})),rangeTotal:g.reduce((l,h)=>l+h.count,0),rangeLabel:k}},[s.dailyLogins,o,r,x]),D=p.length<=7?0:p.length<=14?1:4,L=[{value:"7d",label:"7D"},{value:"14d",label:"14D"},{value:"30d",label:"30D"}];return e.jsxs(y,{className:"p-6 border-l-4 border-l-accent",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Platform Activity"}),e.jsxs("div",{className:"flex items-center gap-1",children:[L.map(c=>e.jsx("button",{onClick:()=>
6n(c.value),className:j("px-2.5 py-1 text-xs rounded-full font-medium transition-colors",o===c.value?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:c.label},c.value)),e.jsxs(Xe,{children:[e.jsx(We,{asChild:!0,children:e.jsxs("button",{className:j("px-2.5 py-1 text-xs rounded-full font-medium transition-colors inline-flex items-center gap-1",o==="custom"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:[e.jsx(ke,{className:"h-3 w-3"}),"Custom"]})}),e.jsx($e,{className:"w-auto p-3",align:"end",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1 text-muted-foreground",children:"From"}),e.jsx(ce,{mode:"single",selected:r,onSelect:c=>{i(c),n("custom")},disabled:c=>c>new Date,className:"p-0 pointer-events-auto"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1 text-muted-foreground",children:"To"}),e.jsx(ce,{mode:"single",selected:x,onSelect:c=>{m(c),n("custom")},disabled:c=>c>new Date||(r?c<r:!1),className:"p-0 pointer-events-auto"})]})]})})]})]})]}),e.jsxs("div",{className:"mb-4 p-3 bg-primary/5 rounded-lg flex gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Today's Logins"}),e.jsx("p",{className:"text-2xl font-bold",children:s.todayLogins})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:w}),e.jsx("p",{className:"text-2xl font-bold",children:u})]})]}),e.jsx(F,{width:"100%",height:300,children:e.jsxs(ze,{data:p,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"loginFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#F03DD9",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#F03DD9",stopOpacity:.05})]})}),e.jsx(Z,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ee,{dataKey:"label",className:"text-xs",tick:{fontSize:11},interval:D}),e.jsx(te,{className:"text-xs",allowDecimals:!1}),e.jsx(I,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}}),e.jsx(He,{type:"monotone",dataKey:"Logins",stroke:"#6B1ECF",strokeWidth:2,fill:"url(#loginFill)",dot:!1,activeDot:{r:4,fill:"#6B1ECF"}})]})})]})},it=({pods:t,averageProgress:s})=>{const o=t.slice(0,5);return e.jsxs(y,{children:[e.jsxs(me,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"text-lg",children:"Ongoing Pods"}),e.jsx(Ae,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsx(Y,{to:"/super-admin/sprint-boards-pods/ongoing",children:e.jsxs(q,{variant:"ghost",size:"sm",className:"text-xs gap-1",children:["View All ",e.jsx(he,{className:"h-3 w-3"})]})})]}),e.jsxs(pe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Overall Progress"}),e.jsxs("span",{className:"font-medium",children:[s,"%"]})]}),e.jsx(H,{value:s,className:"h-2"})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No ongoing pods"}),e.jsx("div",{className:"space-y-3",children:o.map(n=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:n.pod_name}),n.atRisk&&e.jsx(V,{className:"h-3.5 w-3.5 text-destructive flex-shrink-0"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.xternCount," xterns · Sprint ",n.currentSprint??"â"]})]}),e.jsx("div",{className:"w-20 flex-shrink-0",children:e.jsx(H,{value:n.progress,className:"h-1.5"})}),e.jsxs("span",{className:"text-xs font-medium w-8 text-right",children:[n.progress,"%"]})]},n.id))})]})]})},lt=({completedCount:t,totalCount:s})=>{const o=s>0?Math.round(t/s*100):0;return e.jsxs(y,{children:[e.jsxs(me,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(xe,{className:"text-lg",children:"Completed Pods"}),e.jsx(Y,{to:"/super-admin/sprint-boards-pods/completed",children:e.jsxs(q,{variant:"ghost",size:"sm",className:"text-xs gap-1",children:["View All ",e.jsx(he,{className:"h-3 w-3"})]})})]}),e.jsxs(pe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-14 w-14 roun
6ded-full bg-primary/10 flex items-center justify-center",children:e.jsx(J,{className:"h-7 w-7 text-primary"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-3xl font-bold",children:[t," ",e.jsxs("span",{className:"text-lg text-muted-foreground font-normal",children:["/ ",s]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"pods completed"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Completion Rate"}),e.jsxs("span",{className:"font-medium",children:[o,"%"]})]}),e.jsx(H,{value:o,className:"h-2"})]})]})]})},os=()=>{var u;const{user:t}=_e(),{metrics:s,isLoading:o,error:n}=et(),{ongoingPods:r,completedPods:i,totalPods:x,averageProgress:m}=Ye();if(o)return e.jsx(z,{children:e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx(qe,{className:"h-8 w-8 animate-spin text-primary"})})});if(n||!s)return e.jsx(z,{children:e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-destructive",children:"Failed to load dashboard metrics"})})});const p=s.totalUsers.xterns+s.totalUsers.techLeads+s.totalUsers.enterprise;return e.jsx(z,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"rounded-xl bg-xterns-navy p-6 md:p-8 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold text-white",children:["Welcome back, ",(u=t==null?void 0:t.email)==null?void 0:u.split("@")[0]]}),e.jsx("p",{className:"text-white/80 mt-1 text-sm md:text-base",children:"Monitor platform health and manage system operations"})]}),e.jsx(tt,{metrics:s})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(K,{title:"Total Users",value:p,icon:Je,accentColor:"purple",trend:{value:12,direction:"up"}}),e.jsx(K,{title:"Total Xterns",value:s.totalUsers.xterns,icon:ne,accentColor:"pink",trend:{value:12,direction:"up"},onboardingRate:s.onboardingRates.xterns.rate}),e.jsx(K,{title:"Total Tech Leads",value:s.totalUsers.techLeads,icon:ne,accentColor:"purple",trend:{value:5,direction:"up"},onboardingRate:s.onboardingRates.techLeads.rate}),e.jsx(K,{title:"Enterprise Accounts",value:s.totalUsers.enterprise,icon:Se,accentColor:"pink",trend:{value:0,direction:"stable"}})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-3 lg:grid-cols-5",children:[e.jsx(T,{title:"Onboarding",icon:De,xternValue:s.onboardingRates.xterns.rate,techLeadValue:s.onboardingRates.techLeads.rate,target:60,viewDataLink:"/super-admin/metrics/onboarding"}),e.jsx(T,{title:"Assessment",icon:J,xternValue:s.assessmentRates.xterns.rate,techLeadValue:s.assessmentRates.techLeads.rate,target:60,viewDataLink:"/super-admin/metrics/assessment"}),e.jsx(T,{title:"Pod Part.",icon:Re,xternValue:s.podParticipation.xterns.rate,techLeadValue:s.podParticipation.techLeads.rate,target:55,viewDataLink:"/super-admin/metrics/pod-participation"}),e.jsx(T,{title:"Score Growth",icon:Q,xternValue:s.dareyScoreGrowth.growthPercent,target:10,xternsOnly:!0,viewDataLink:"/super-admin/metrics/score-growth"}),e.jsx(T,{title:"Activity",icon:Me,xternValue:s.platformActivity.todayLogins,target:10,xternsOnly:!0,viewDataLink:"/super-admin/metrics/engagement"})]}),e.jsx(st,{metrics:s}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(at,{metrics:s}),e.jsx(rt,{metrics:s}),e.jsx(nt,{metrics:s}),e.jsx(ot,{metrics:s})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(it,{pods:r,averageProgress:m}),e.jsx(lt,{completedCount:i.length,totalCount:x})]})]})})};export{os 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.