PageSourceSearch

https://www.smartalecks.ai/assets/ai-prediction-dashboard-CBWsHxpS.js

js smartalecks.ai collected 2026-10-05 15:05:43 UTC 17,183 bytes, 12 lines download raw bytes

1import{a as m,j as e}from"./dnd-CNQ8BvKU.js";import{c as Q,ap as p,t as G,C as j,m as f,f as v,i as y,bt as Z,aj as ee,bb as se,av as V,o as te,j as I,B as ae,ac as re,g as U,A as S}from"./index-DpuP5qk5.js";import{T as ne,f as ce,R as X,B as ie,b as L,X as R,Y as T,e as le,L as oe,c as H,A as de,d as xe,P as me,a as he,C as ue}from"./AreaChart-BbZQLzOS.js";import{B as W}from"./org-selector-mADo5AxL.js";import{T as je,a as fe}from"./trending-up-BJDOLQkF.js";import"./xyflow-C0vxhnBz.js";import"./datefns-D4dTs_7e.js";/**
2 * @license lucide-react v0.487.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 pe=[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]],ge=Q("chart-pie",pe),ve={light:"",dark:".dark"},q=m.createContext(null);function J(){const l=m.useContext(q);if(!l)throw new Error("useChart must be used within a <ChartContainer />");return l}function $({id:l,className:a,children:t,config:n,...o}){const u=m.useId(),c=`chart-${l||u.replace(/:/g,"")}`;return e.jsx(q.Provider,{value:{config:n},children:e.jsxs("div",{"data-slot":"chart","data-chart":c,className:p("[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",a),...o,children:[e.jsx(ye,{id:c,config:n}),e.jsx(X,{children:t})]})})}const ye=({id:l,config:a})=>{const t=Object.entries(a).filter(([,n])=>n.theme||n.color);return t.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(ve).map(([n,o])=>`
7${o} [data-chart=${l}] {
8${t.map(([u,c])=>{var d;const x=((d=c.theme)==null?void 0:d[n])||c.color;return x?`  --color-${u}: ${x};`:null}).join(`
9`)}
10}
11`).join(`
12`)}}):null},B=ne;function P({active:l,payload:a,className:t,indicator:n="dot",hideLabel:o=!1,hideIndicator:u=!1,label:c,labelFormatter:x,labelClassName:d,formatter:_,color:w,nameKey:C,labelKey:N}){const{config:g}=J(),A=m.useMemo(()=>{var h;if(o||!(a!=null&&a.length))return null;const[r]=a,k=`${N||(r==null?void 0:r.dataKey)||(r==null?void 0:r.name)||"value"}
12`,s=K(g,r,k),i=!N&&typeof c=="string"?((h=g[c])==null?void 0:h.label)||c:s==null?void 0:s.label;return x?e.jsx("div",{className:p("font-medium",d),children:x(i,a)}):i?e.jsx("div",{className:p("font-medium",d),children:i}):null},[c,x,a,o,d,g,N]);if(!l||!(a!=null&&a.length))return null;const b=a.length===1&&n!=="dot";return e.jsxs("div",{className:p("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",t),children:[b?null:A,e.jsx("div",{className:"grid gap-1.5",children:a.map((r,k)=>{const s=`${C||r.name||r.dataKey||"value"}`,i=K(g,r,s),h=w||r.payload.fill||r.color;return e.jsx("div",{className:p("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",n==="dot"&&"items-center"),children:_&&(r==null?void 0:r.value)!==void 0&&r.name?_(r.value,r.name,r,k,r.payload):e.jsxs(e.Fragment,{children:[i!=null&&i.icon?e.jsx(i.icon,{}):!u&&e.jsx("div",{className:p("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":b&&n==="dashed"}),style:{"--color-bg":h,"--color-border":h}}),e.jsxs("div",{className:p("flex flex-1 justify-between leading-none",b?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[b?A:null,e.jsx("span",{className:"text-muted-foreground",children:(i==null?void 0:i.label)||r.name})]}),r.value&&e.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:r.value.toLocaleString()})]})]})},r.dataKey)})})]})}const Ne=ce;function be({className:l,hideIcon:a=!1,payload:t,verticalAlign:n="bottom",nameKey:o}){const{config:u}=J();return t!=null&&t.length?e.jsx("div",{className:p("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",l),children:t.map(c=>{const x=`${o||c.dataKey||"value"}`,d=K(u,c,x);return e.jsxs("div",{className:p("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),children:[d!=null&&d.icon&&!a?e.jsx(d.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:c.color}}),d==null?void 0:d.label]},c.value)})}):null}function K(l,a,t){if(typeof a!="object"||a===null)return;const n="payload"in a&&typeof a.payload=="object"&&a.payload!==null?a.payload:void 0;let o=t;return t in a&&typeof a[t]=="string"?o=a[t]:n&&t in n&&typeof n[t]=="string"&&(o=n[t]),o in l?l[o]:l[t]}const _e={email_classify:"Email Classification",email_extract:"Email Extraction",grade_detect:"Grade Detection",subtask_breakdown:"Subtask Breakdown",time_estimate:"Time Estimation",priority_score:"Priority Scoring",tutor_response:"Tutor Response"},D={false_positive:"#ef4444",explicit_assignment_missed:"#f97316",implicit_assignment_missed:"#eab308",unknown_sender:"#a855f7",grade_vs_assignment_confusion:"#3b82f6",thread_noise:"#6b7280",extraction_field_error:"#ec4899",time_overestimate:"#14b8a6",time_underestimate:"#f59e0b"},Y={false_positive:"False Positive",explicit_assignment_missed:"Explicit Missed",implicit_assignment_missed:"Implicit Missed",unknown_sender:"Unknown Sender",grade_vs_assignment_confusion:"Grade Confusion",thread_noise:"Thread Noise",extraction_field_error:"Extraction Error",time_overestimate:"Time Overestimate",time_underestimate:"Time Underestimate"},ke={accuracy:{label:"Accuracy %",color:"hsl(var(--brand))"}},we={accuracy:{label:"Accuracy %",color:"hsl(var(--brand))"},avgIclCount:{label:"ICL Examples",color:"hsl(var(--muted-foreground))"}},Ce={accuracy:{label:"Accuracy %",color:"hsl(var(--brand))"}};function Re({userId:l,accessToken:a}={}){const[t,n]=m.useState(null),[o,u]=m.useState([]),[c,x]=m.useState([]),[d,_]=m.useState(!0),[w,C]=m.useState(null),[N,g]=m.useState(null),A=async()=>{const s=a||U();if(!s){C("Not authenticated"),_(!1);return}const i=l?`&userId=${l}`:"";try{const[h,O,z]=await Promise.all([fetch(`${S}/ai/predictions/stats?days=30${i}`,{headers:{Authorization:`Bearer ${s}`}}),fetch(`${S}/ai/predictions/actions?${i.slice(1)}`,{headers:{Authorization:`Bearer ${s}`}}),fetch(`${S}/google/gmail/examples?${i.slice(1)}`,{headers:{Authorization:`Bearer ${s}`}})]),[E,M,F]=await Promise.all([h.json(),O.json(),z.json()]);E.success&&n(E.stats),M.success&&u(M.actions),F.success&&x(F.examples||[])}catch(h){C(h.message)}finally{_(!1)}};m.useEffect(()=>{A()},[]);const b=async s=>{const i=U();if(i){g(s);try{(await(await fetch(`${S}/google/gmail/examples/${s}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}})).json()).success&&x(z=>z.filter(E=>E.id!==s))}catch{}g(null)}};if(d)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(G,{className:"size-6 animate-spin text-muted-foreground"})});if(w)return e.jsx(j,{children:e.jsxs(f,{className:"py-8 text-center text-muted-foreground",children:["Failed to load insights: ",w]})});if(!t||t.overall.totalPredictions===0)return e.jsx(j,{children:e.jsxs(f,{className:"py-8 text-center text-muted-foreground",children:[e.jsx(W,{className:"size-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No predictions yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Import some emails using the Gmail integration to start collecting performance data."})]})});const r=c.filter(s=>s.is_assignment),k=c.filter(s=>!s.is_assignment);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"size-5"}),"Accuracy Overview (30 days)"]})}),e.jsxs(f,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold",children:[t.overall.accuracy,"%"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Overall Accuracy"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold",children:t.overall.totalPredictions}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Predictions"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold",children:[t.overall.fal
12sePositiveRate,"%"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"False Positive Rate"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold",children:[t.overall.falseNegativeRate,"%"]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"False Negative Rate"})]})]}),t.byFeature.length>0&&e.jsx($,{config:ke,className:"h-[200px] w-full",children:e.jsxs(ie,{data:t.byFeature.map(s=>({name:_e[s.feature]||s.feature,accuracy:s.accuracy})),children:[e.jsx(L,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(R,{dataKey:"name",tick:{fontSize:11}}),e.jsx(T,{domain:[0,100]}),e.jsx(B,{content:e.jsx(P,{})}),e.jsx(le,{dataKey:"accuracy",fill:"var(--color-accuracy)",radius:[4,4,0,0]})]})})]})]}),t.accuracyOverTime.length>1&&e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"size-5"}),"Accuracy Trend"]})}),e.jsxs(f,{children:[e.jsx($,{config:we,className:"h-[250px] w-full",children:e.jsxs(oe,{data:t.accuracyOverTime,children:[e.jsx(L,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(R,{dataKey:"week",tick:{fontSize:11}}),e.jsx(T,{yAxisId:"left",domain:[0,100]}),e.jsx(T,{yAxisId:"right",orientation:"right"}),e.jsx(B,{content:e.jsx(P,{})}),e.jsx(Ne,{content:e.jsx(be,{})}),e.jsx(H,{yAxisId:"left",type:"monotone",dataKey:"accuracy",stroke:"var(--color-accuracy)",strokeWidth:2,dot:!0}),e.jsx(H,{yAxisId:"right",type:"monotone",dataKey:"avgIclCount",stroke:"var(--color-avgIclCount)",strokeWidth:2,strokeDasharray:"5 5",dot:!0})]})}),t.explicitVsImplicit&&e.jsxs("div",{className:"flex gap-4 mt-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Explicit (has keywords):"}),e.jsxs("span",{className:"font-medium",children:[t.explicitVsImplicit.explicit.accuracy,"% (",t.explicitVsImplicit.explicit.count,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Implicit (no keywords):"}),e.jsxs("span",{className:"font-medium",children:[t.explicitVsImplicit.implicit.accuracy,"% (",t.explicitVsImplicit.implicit.count,")"]})]})]})]})]}),t.learningCurve.some(s=>s.count>0)&&e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"size-5"}),"Learning Curve"]})}),e.jsxs(f,{children:[e.jsx($,{config:Ce,className:"h-[200px] w-full",children:e.jsxs(de,{data:t.learningCurve,children:[e.jsx(L,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(R,{dataKey:"bucket",tick:{fontSize:12}}),e.jsx(T,{domain:[0,100]}),e.jsx(B,{content:e.jsx(P,{})}),e.jsx(xe,{type:"monotone",dataKey:"accuracy",fill:"var(--color-accuracy)",fillOpacity:.2,stroke:"var(--color-accuracy)",strokeWidth:2})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Accuracy vs number of ICL training examples at prediction time"})]})]}),t.errorBreakdown.length>0&&e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"size-5"}),"Error Breakdown"]})}),e.jsx(f,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6",children:[e.jsx("div",{className:"h-[200px] w-[200px]",children:e.jsx(X,{width:"100%",height:"100%",children:e.jsx(me,{children:e.jsx(he,{data:t.errorBreakdown.map(s=>({name:Y[s.category]||s.category,value:s.count,color:D[s.category]||"#6b7280"})),dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:80,innerRadius:40,children:t.errorBreakdown.map((s,i)=>e.jsx(ue,{fill:D[s.category]||"#6b7280"},i))})})})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.errorBreakdown.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"size-3 rounded-full",style:{backgroundColor:D[s.category]||"#6b7280"}}),e.jsx("span",{children:Y[s.category]||s.category}),e.jsxs("span",{className:"text-muted-foreground",children:["(",s.count,")"]})]},s.category))})]})})]}),o.length>0&&e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"size-5"}),"Improvement Actions"]})}),e.jsx(f,{children:e.jsx("div",{className:"space-y-3",children:o.map((s,i)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/50",children:[s.severity==="high"?e.jsx(V,{className:"size-5 text-red-500 mt-0.5 shrink-0"}):s.type==="system_healthy"?e.jsx(te,{className:"size-5 text-green-500 mt-0.5 shrink-0"}):e.jsx(fe,{className:"size-5 text-yellow-500 mt-0.5 shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:s.message})}),e.jsx(I,{variant:s.severity==="high"?"destructive":s.severity==="medium"?"default":"secondary",children:s.severity})]},i))})})]}),e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(W,{className:"size-5"}),"Training Examples (",c.length,")"]})}),e.jsxs(f,{children:[e.jsxs("div",{className:"flex gap-3 mb-4",children:[e.jsxs(I,{variant:"default",className:"bg-green-600",children:[r.length," Assignment"]}),e.jsxs(I,{variant:"secondary",children:[k.length," Not Assignment"]})]}),c.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No training examples yet. Label emails during the Gmail import flow to train the system."}):e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Subject"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium hidden sm:table-cell",children:"From"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium hidden sm:table-cell",children:"Reason"}),e.jsx("th",{className:"px-3 py-2 w-10"})]})}),e.jsx("tbody",{children:c.slice(0,20).map(s=>e.jsxs("tr",{className:"border-b last:border-b-0",children:[e.jsx("td",{className:"px-3 py-2 max-w-[200px] truncate",children:s.subject}),e.jsx("td",{className:"px-3 py-2 max-w-[150px] truncate hidden sm:table-cell text-muted-foreground",children:s.from_address}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(I,{variant:s.is_assignment?"default":"secondary",className:s.is_assignment?"bg-green-600":"",children:s.is_assignment?"Yes":"No"})}),e.jsx("td",{className:"px-3 py-2 max-w-[150px] truncate hidden sm:table-cell text-muted-foreground",children:s.reason||"-"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(ae,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>b(s.id),disabled:N===s.id,children:N===s.id?e.jsx(G,{className:"size-4 animate-spin"}):e.jsx(re,{className:"size-4 text-muted-foreground hover:text-red-500"})})})]},s.id))})]}),c.length>20&&e.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground bg-muted/30",children:["Showing 20 of ",c.length," examples"]})]})]})]}),t.topMissedSenders.length>0&&e.jsxs(j,{children:[e.jsx(v,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"size-5"}),"Sender Accuracy"]})}),e.jsx(f,{children:e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Domain"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Accuracy"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Emails"})]})}),e.jsx("tbody",{children:t.topMissedSenders.map(s=>e.jsxs("tr",{className:"border-b last:border-b-0",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:s.domain}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("span",{className:s.accuracy<50?"text-red-500":s.accuracy<70?"text-yellow-500":"text-green-500",children:[s.accuracy,"%"]})}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:s.count})]},s.domain))})]})})})]})]})}export{Re as AIPredictionDashboard};

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.