PageSourceSearch

https://contributor.info/js/confidence-analytics-dashboard-DsVpAPma.js

js contributor.info collected 2026-10-10 00:35:51 UTC 29,153 bytes, 1 lines download raw bytes

1import{r as x,j as e}from"./vendor-react-core-Ba2gwJNM.js";import{C as r,i as l,v as d,c3 as O,z as F,B as A,X as B,f as c,x as z,a1 as N,az as $,m as H,A as P,aj as _,l as C,ag as q,aN as W,U,g as G,R as V,K,k as Q,j as X,aQ as J,aR as Y,c4 as Z,aS as ee,aT as se,aU as I}from"./index-D-XLV-_s.js";import{P as f}from"./progress-Bjlj8gEp.js";import{L as E}from"./label-C7mpxRQf.js";import{S as te}from"./separator-Czgj9iqU.js";import"./vendor-ui-C6PEtgd7.js";import"./vendor-utils-MSNXLbuZ.js";import"./vendor-supabase-De54M4W1.js";function ne({weights:h,onClose:D}){const[t,R]=x.useState({privilegedEventCount:5,totalEventCount:50,uniqueEventTypes:4,detectionMethods:2,daysSinceLastSeen:7,daysSinceFirstSeen:90,activitySpreadDays:25}),g=h||{privileged_events_weight:.4,activity_patterns_weight:.35,temporal_consistency_weight:.25},i=(()=>{const a=t.totalEventCount>0?t.privilegedEventCount/t.totalEventCount:0,o=Math.min(1,t.privilegedEventCount/10),y=a*.7+o*.3,v=Math.min(1,t.uniqueEventTypes/8),k=Math.min(1,t.detectionMethods/5),w=Math.min(1,Math.log10(t.totalEventCount+1)/2),b=v*.4+k*.4+w*.2;let p;t.daysSinceLastSeen<=7?p=1:t.daysSinceLastSeen<=30?p=.8:t.daysSinceLastSeen<=90?p=.6:p=.4;const n=Math.min(t.daysSinceFirstSeen,90),s=n>0?t.activitySpreadDays/n:0,m=Math.min(1,s*2),u=Math.min(1,t.daysSinceFirstSeen/180),M=p*.4+m*.4+u*.2,T=y*g.privileged_events_weight+b*g.activity_patterns_weight+M*g.temporal_consistency_weight;return{overall:Math.min(.5,T),components:{privilegedEvents:y,activityPatterns:b,temporalConsistency:M},factors:{eventDiversity:v,activityRecency:p,consistencyScore:m,privilegedRatio:a,privilegedBoost:o,methodDiversity:k,activityVolume:w,longevityScore:u}}})(),j=(a,o)=>{R(y=>({...y,[a]:Math.max(0,o)}))},S=a=>{const o=a*100;return o<=5?"text-red-600":o<=15?"text-orange-600":o<=35?"text-blue-600":"text-green-600"};return e.jsxs(r,{className:"border-2 border-blue-200 bg-blue-50/50",children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-5 w-5"}),"Confidence Algorithm Explainer"]}),e.jsx(F,{children:"Interactive calculator showing how contributor confidence scores are calculated"})]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:D,children:e.jsx(B,{className:"h-4 w-4"})})]})}),e.jsxs(c,{className:"space-y-6",children:[e.jsxs(r,{children:[e.jsx(l,{children:e.jsx(d,{className:"text-lg",children:"How the Algorithm Works"})}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:"Privileged Events"}),e.jsxs(N,{variant:"secondary",children:[(g.privileged_events_weight*100).toFixed(0),"%"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Admin actions, merge permissions, and high-privilege activities"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:"Activity Patterns"}),e.jsxs(N,{variant:"secondary",children:[(g.activity_patterns_weight*100).toFixed(0),"%"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Event diversity, detection methods, and activity volume"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-purple-600"}),e.jsx("span",{className:"font-medium",children:"Temporal Consistency"}),e.jsxs(N,{variant:"secondary",children:[(g.temporal_consistency_weight*100).toFixed(0),"%"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Activity recency, consistency over time, and contribution longevity"})]})]}),e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(P,{className:"h-4 w-4 text-amber-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-amber-800",children:"Important Note"}),e.jsxs("p",{className:"text-sm text-amber-700",children:['This algorithm measures the likelihood of outsider "self-selection" for contributions. It deliberately ',e.jsx("strong",{children:"excludes maintainers"})," from calculations and is capped at 50% to reflect realistic conversion rates."]})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(r,{children:[e.jsxs(l,{children:[e.jsx(d,{className:"text-lg",children:"Try Different Values"}
1),e.jsx(F,{children:"Adjust these parameters to see how they affect the confidence score"})]}),e.jsx(c,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(E,{htmlFor:"privileged-events",children:"Privileged Events"}),e.jsx(_,{id:"privileged-events",type:"number",value:t.privilegedEventCount,onChange:a=>j("privilegedEventCount",parseInt(a.target.value)||0),min:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Admin actions, merges, releases"})]}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"total-events",children:"Total Events"}),e.jsx(_,{id:"total-events",type:"number",value:t.totalEventCount,onChange:a=>j("totalEventCount",parseInt(a.target.value)||0),min:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"All GitHub events (PRs, issues, comments, etc.)"})]}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"event-types",children:"Unique Event Types"}),e.jsx(_,{id:"event-types",type:"number",value:t.uniqueEventTypes,onChange:a=>j("uniqueEventTypes",parseInt(a.target.value)||0),min:"0",max:"10"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Diversity of activity types (max 8 for full score)"})]}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"detection-methods",children:"Detection Methods"}),e.jsx(_,{id:"detection-methods",type:"number",value:t.detectionMethods,onChange:a=>j("detectionMethods",parseInt(a.target.value)||0),min:"0",max:"5"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Different ways privileged access was detected"})]}),e.jsx(te,{}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"days-since-last",children:"Days Since Last Activity"}),e.jsx(_,{id:"days-since-last",type:"number",value:t.daysSinceLastSeen,onChange:a=>j("daysSinceLastSeen",parseInt(a.target.value)||0),min:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recent activity is weighted higher"})]}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"days-since-first",children:"Days Since First Activity"}),e.jsx(_,{id:"days-since-first",type:"number",value:t.daysSinceFirstSeen,onChange:a=>j("daysSinceFirstSeen",parseInt(a.target.value)||0),min:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Longer history shows commitment (180 days = full score)"})]}),e.jsxs("div",{children:[e.jsx(E,{htmlFor:"activity-spread",children:"Activity Spread (Days)"}),e.jsx(_,{id:"activity-spread",type:"number",value:t.activitySpreadDays,onChange:a=>j("activitySpreadDays",parseInt(a.target.value)||0),min:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"How many unique days the contributor was active"})]})]})})]}),e.jsxs(r,{children:[e.jsxs(l,{children:[e.jsx(d,{className:"text-lg",children:"Calculated Score"}),e.jsx(F,{children:"Live calculation based on your inputs"})]}),e.jsxs(c,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:`text-4xl font-bold ${S(i.overall)}`,children:[(i.overall*100).toFixed(1),"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Overall Confidence Score"}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{value:i.overall*100,className:"h-3"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Component Breakdown"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-3 w-3"}),"Privileged Events"]}),e.jsxs("span",{className:"font-medium",children:[(i.components.privilegedEvents*100).toFixed(1),"%"]})]}),e.jsx(f,{value:i.components.privilegedEvents*100,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Ratio: ",(i.factors.privilegedRatio*100).toFixed(1),"% + Boost:"," ",(i.factors.privilegedBoost*100).toFixed(1),"%"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-3 w-3"}),"Activity Patterns"]}),e.jsxs("span",{className:"font-medium",children:[(i.components.activityPatterns*100).toFixed(1),"%"]})]}),e.jsx(f,{value:i.components.activityPatterns*100,className:"h-2"}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Event Diversity: ",(i.factors.eventDiversity*100).toFixed(1),"%"]}),e.jsxs("div",{children:["Method Diversity: ",(i.factors.methodDiversity*100).toFixed(1),"%"]}),e.jsxs("div",{children:["Activity Volume: ",(i.factors.activityVolume*100).toFixed(1),"%"]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-3 w-3"}),"Temporal Consistency"]}),e.jsxs("span",{className:"font-medium",children:[(i.components.temporalConsistency*100).toFixed(1),"%"]})]}),e.jsx(f,{value:i.components.temporalConsistency*100,className:"h-2"}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Recency: ",(i.factors.activityRecency*100).toFixed(1),"%"]}),e.jsxs("div",{children:["Consistency: ",(i.factors.consistencyScore*100).toFixed(1),"%"]}),e.jsxs("div",{children:["Longevity: ",(i.factors.longevityScore*100).toFixed(1),"%"]})]})]})]})]}),e.jsx("div",{className:"bg-gray-50 rounded-lg p-3",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"font-medium mb-2",children:"Score Interpretation:"}),i.overall*100<=5&&e.jsx("p",{className:"text-red-600",children:"Critical - Very low likelihood of external 
1contribution"}),i.overall*100>5&&i.overall*100<=15&&e.jsx("p",{className:"text-orange-600",children:"Low - Few external contributors are likely to contribute"}),i.overall*100>15&&i.overall*100<=35&&e.jsx("p",{className:"text-blue-600",children:"Medium - Some external contributors may contribute"}),i.overall*100>35&&e.jsx("p",{className:"text-green-600",children:"Good - External contributors are more likely to contribute"})]})})]})]})]})]})]})}function ie({repositoryId:h,onClose:D}){const[t,R]=x.useState(null),[g,L]=x.useState(!0),[i,j]=x.useState(null),[S,a]=x.useState(!1),[o,y]=x.useState(null),[v,k]=h.split("/");x.useEffect(()=>{(async()=>{try{L(!0),j(null);const s=await G(),{data:m,error:u}=await s.rpc("get_repository_confidence_breakdown",{p_repository_owner:v,p_repository_name:k});if(u)throw u;R(m&&m.length>0?m[0]:null)}catch(s){j(s instanceof Error?s.message:"Failed to fetch breakdown"),console.error("Error fetching confidence breakdown:",s)}finally{L(!1)}})()},[v,k]);const w=n=>n<=5?"text-red-600 dark:text-red-400":n<=15?"text-orange-600 dark:text-orange-400":n<=35?"text-blue-600 dark:text-blue-400":"text-green-600 dark:text-green-400",b=n=>n<=5?"bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-800":n<=15?"bg-orange-50 dark:bg-orange-950/20 border-orange-200 dark:border-orange-800":n<=35?"bg-blue-50 dark:bg-blue-950/20 border-blue-200 dark:border-blue-800":"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800",p=n=>`${Math.floor((Date.now()-new Date(n).getTime())/864e5)}d ago`;return g?e.jsxs(r,{className:"mt-6",children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"h-6 w-64"}),e.jsx(C,{className:"h-8 w-8"})]})}),e.jsx(c,{children:e.jsx(C,{className:"h-64 w-full"})})]}):i||!t?e.jsxs(r,{className:"mt-6",children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{className:"text-red-600",children:"Error Loading Breakdown"}),e.jsx(A,{variant:"ghost",size:"sm",onClick:D,children:e.jsx(B,{className:"h-4 w-4"})})]})}),e.jsx(c,{children:e.jsx("p",{className:"text-muted-foreground",children:i})})]}):e.jsxs(r,{className:"mt-6",children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),"Confidence Breakdown: ",h]}),e.jsx(F,{children:"Detailed analysis of contributor confidence scores and algorithm components"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>a(!S),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"How it works"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:D,children:e.jsx(B,{className:"h-4 w-4"})})]})]})}),e.jsxs(c,{className:"space-y-6",children:[S&&e.jsx(ne,{weights:t.algorithm_weights,onClose:()=>a(!1)}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(r,{className:b(t.overall_avg_confidence||0),children:e.jsxs(c,{className:"p-4",children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t.overall_avg_confidence||0).toFixed(1),"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Overall Avg"})]})}),e.jsx(r,{children:e.jsxs(c,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold text-red-600",children:t.insights?.low_confidence_count||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Low Confidence"})]})}),e.jsx(r,{children:e.jsxs(c,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:t.insights?.maintainer_count||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Maintainers"})]})}),e.jsx(r,{children:e.jsxs(c,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:t.insights?.external_contributor_count||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"External Contributors"})]})})]}),e.jsxs(r,{children:[e.jsxs(l,{children:[e.jsx(d,{className:"text-lg",children:"Algorithm Component Performance"}),e.jsx(F,{children:"How each component of the confidence algorithm is performing"})]}),e.jsx(c,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4"}
1),e.jsx("span",{className:"font-medium",children:"Privileged Events"}),e.jsxs(N,{variant:"secondary",children:[(t.algorithm_weights?.privileged_events_weight||0)*100,"%"]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Avg:"," ",t.contributor_breakdown?.length?(t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.privileged_events||0),0)/t.contributor_breakdown.length*100).toFixed(1):"0.0","%"]})]}),e.jsx(f,{value:t.contributor_breakdown?.length?t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.privileged_events||0),0)/t.contributor_breakdown.length*100:0,className:"h-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Activity Patterns"}),e.jsxs(N,{variant:"secondary",children:[(t.algorithm_weights?.activity_patterns_weight||0)*100,"%"]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Avg:"," ",t.contributor_breakdown?.length?(t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.activity_patterns||0),0)/t.contributor_breakdown.length*100).toFixed(1):"0.0","%"]})]}),e.jsx(f,{value:t.contributor_breakdown?.length?t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.activity_patterns||0),0)/t.contributor_breakdown.length*100:0,className:"h-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Temporal Consistency"}),e.jsxs(N,{variant:"secondary",children:[(t.algorithm_weights?.temporal_consistency_weight||0)*100,"%"]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Avg:"," ",t.contributor_breakdown?.length?(t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.temporal_consistency||0),0)/t.contributor_breakdown.length*100).toFixed(1):"0.0","%"]})]}),e.jsx(f,{value:t.contributor_breakdown?.length?t.contributor_breakdown.reduce((n,s)=>n+(s.component_scores?.temporal_consistency||0),0)/t.contributor_breakdown.length*100:0,className:"h-2"})]})]})})]}),t.insights?.common_issues?.length>0&&e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs(d,{className:"flex items-center gap-2 text-orange-600",children:[e.jsx(P,{className:"h-5 w-5"}),"Common Issues Detected"]})}),e.jsx(c,{children:e.jsx("ul",{className:"space-y-2",children:t.insights?.common_issues?.map((n,s)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2"}),e.jsx("span",{className:"text-sm",children:n})]},s))})})]}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5"}),"Individual Contributor Analysis"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.contributor_breakdown?.length||0," contributors"]})]})}),e.jsx(c,{children:e.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:t.contributor_breakdown?.length>0?t.contributor_breakdown.sort((n,s)=>(s.confidence_score||0)-(n.confidence_score||0)).map(n=>e.jsxs("div",{className:`p-4 border rounded-lg ${b((n.confidence_score||0)*100)} cursor-pointer hover:shadow-sm transition-shadow`,onClick:()=>y(o===n.user_id?null:n.user_id),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:n.user_id}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(N,{variant:"outline",className:"text-xs",children:n.role}),e.jsxs("span",{children:[n.total_events||0," events"]}),e.jsx("span",{children:n.last_active?p(n.last_active):"Unknown"})]})]})}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:`text-lg font-bold ${w((n.confidence_score||0)*100)}`,children:[((n.confidence_score||0)*100).toFixed(1),"%"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.privileged_events||0," privileged"]})]})})]}),o===n.user_id&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Privileged 
1Events"}),e.jsxs("div",{className:"text-lg",children:[((n.component_scores?.privileged_events||0)*100).toFixed(1),"%"]}),e.jsx(f,{value:(n.component_scores?.privileged_events||0)*100,className:"h-1 mt-1"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Activity Patterns"}),e.jsxs("div",{className:"text-lg",children:[((n.component_scores?.activity_patterns||0)*100).toFixed(1),"%"]}),e.jsx(f,{value:(n.component_scores?.activity_patterns||0)*100,className:"h-1 mt-1"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Temporal Consistency"}),e.jsxs("div",{className:"text-lg",children:[((n.component_scores?.temporal_consistency||0)*100).toFixed(1),"%"]}),e.jsx(f,{value:(n.component_scores?.temporal_consistency||0)*100,className:"h-1 mt-1"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Event Diversity"}),e.jsxs("div",{children:[n.event_diversity||0," types"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Consistency Score"}),e.jsxs("div",{children:[((n.consistency_score||0)*100).toFixed(1),"%"]})]})]}),n.detection_methods?.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm mb-2",children:"Detection Methods"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:n.detection_methods?.map((s,m)=>e.jsx(N,{variant:"outline",className:"text-xs",children:s},m))})]})]})]},n.user_id)):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No contributor data available for this repository"})})})]})]})]})}function he(){const[h,D]=x.useState(null),[t,R]=x.useState([]),[g,L]=x.useState(!0),[i,j]=x.useState(null),[S,a]=x.useState(null),[o,y]=x.useState(""),[v,k]=x.useState("all"),w=async()=>
1{try{L(!0),j(null);const s=await G(),{data:m,error:u}=await s.rpc("get_confidence_analytics_summary_simple");if(u)throw u;const{data:M,error:T}=await s.rpc("get_repository_confidence_summary_simple");if(T)throw T;D(m),R(M||[])}catch(s){j(s instanceof Error?s.message:"Failed to fetch analytics"),console.error("Error fetching confidence analytics:",s)}finally{L(!1)}};x.useEffect(()=>{w()},[]);const b=t.filter(s=>{const m=s.repository_owner?.toLowerCase().includes(o.toLowerCase())||s.repository_name?.toLowerCase().includes(o.toLowerCase()),u=s.avg_confidence_score||0,M=v==="all"||v==="low"&&u<=15||v==="medium"&&u>15&&u<=35||v==="high"&&u>35;return m&&M}),p=s=>s<=5?"destructive":s<=15?"secondary":(s<=35,"default"),n=s=>s<=5?"Critical":s<=15?"Low":s<=35?"Medium":"Good";return g?e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Confidence Analytics"}),e.jsx("p",{className:"text-muted-foreground",children:"Debug and analyze contributor confidence scores"})]}),e.jsx(C,{className:"h-10 w-32"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[...Array(4)].map((s,m)=>e.jsxs(r,{children:[e.jsx(l,{className:"pb-3",children:e.jsx(C,{className:"h-4 w-24"})}),e.jsx(c,{children:e.jsx(C,{className:"h-8 w-16"})})]},m))}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsx(C,{className:"h-6 w-48"})}),e.jsx(c,{children:e.jsx(C,{className:"h-64 w-full"})})]})]}):i?e.jsx("div",{className:"container mx-auto p-6",children:e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs(d,{className:"flex items-center gap-2 text-red-600",children:[e.jsx(P,{className:"h-5 w-5"}),"Error Loading Analytics"]})}),e.jsxs(c,{children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:i}),e.jsxs(A,{onClick:w,className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),"Retry"]})]})]})}):e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Confidence Analytics"}),e.jsx("p",{className:"text-muted-foreground",children:"Debug and analyze contributor confidence scores"})]}),e.jsxs(A,{onClick:w,className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),"Refresh Data"]})]}),h&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(r,{children:[e.jsx(l,{className:"pb-3",children:e.jsx(d,{className:"text-sm font-medium",children:"Total Repositories"})}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h?.total_repositories||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with confidence data"})]})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-3",children:e.jsx(d,{className:"text-sm font-medium",children:"Total Contributors"})}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h?.total_contributors||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"analyzed"})]})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-3",children:e.jsx(d,{className:"text-sm font-medium",children:"Average Confidence"})}),e.jsxs(c,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"text-2xl font-bold",children:[h?.avg_confidence_score?.toFixed(1)||"0.0","%"]}),(h?.avg_confidence_score||0)<15?e.jsx(K,{className:"h-4 w-4 text-red-500"}):e.jsx(Q,{className:"h-4 w-4 text-green-500"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all repos"})]})]}),e.jsxs(r,{children:[e.jsx(l,{className:"pb-3",children:e.jsx(d,{className:"text-sm font-medium",children:"Low Confidence Repos"})}),e.jsxs(c,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-2xl font-bold text-red-600",children:h?.low_confidence_repos||0}),e.jsx(P,{className:"h-4 w-4 text-red-500"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"need attention"})]})]})]}),h?.score_distribution&&e.jsxs(r,{children:[e.jsxs(l,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),"Confidence Score Distribution"]}),e.jsx(F,{children:"How confidence scores are distributed across all repositories"})]}),e.jsx(c,{children:e.jsx("div",{className:"space-y-4",children:h.score_distribution.map(s=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-24 text-sm font-medium",children:s.range}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${s.percentage}%`}})})}),e.jsxs("div",{className:"text-sm text-muted-foreground w-16 text-right",children:[s.count," repos"]}),e.jsxs("div",{className:"text-sm font-medium w-12 text-right",children:[s.percentage.toFixed(1),"%"]})]},s.range))})})]}),e.jsxs(r,{children:[e.jsx(l,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5"}),"Repository Confidence Scores"]}),e.jsx(F,{children:"Detailed confidence analysis for each repository"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(_,{placeholder:"Search repositories...",value:o,onChange:s=>y(s.target.value),className:"pl-8 w-64"})]}),e.jsxs(J,{value:v,onValueChange:s=>k(s),children:[e.jsxs(Y,{className:"w-32",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),e.jsx(ee,{})]}),e.jsxs(se,{children:[e.jsx(I,{value:"all",children:"All"}),e.jsx(I,{value:"low",children:"Low (<15%)"}),e.jsx(I,{value:"medium",children:"Medium (15-35%)"}),e.jsx(I,{value:"high",children:"High (>35%)"})]})]})]})]})}),e.jsx(c,{children:e.jsxs("div",{className:"space-y-3",children:[b.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 cursor-pointer",onClick:()=>a(`${s.repository_owner}/${s.repository_name}`),children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium",children:[s.repository_owner,"/",s.repository_name]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.contributor_count," contributors • ",s.maintainer_
1count," maintainers"]})]})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Self-Selection Rate"}),e.jsx("div",{className:"font-medium",children:s.self_selection_rate>0?`${s.self_selection_rate.toFixed(1)}%`:"N/A"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Confidence Score"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-bold text-lg",children:[s.avg_confidence_score?.toFixed(1)||"0.0","%"]}),e.jsx(N,{variant:p(s.avg_confidence_score||0),children:n(s.avg_confidence_score||0)})]})]}),e.jsx(A,{variant:"outline",size:"sm",children:"Analyze"})]})]},`${s.repository_owner}/${s.repository_name}`)),b.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No repositories match your current filters"})]})})]}),S&&e.jsx(ie,{repositoryId:S,onClose:()=>a(null)})]})}export{he as ConfidenceAnalyticsDashboard};

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.