1"use strict";(globalThis.webpackChunkedupark_client||=[]).push([[8121],{67650(e,s,t){t.d(s,{A:()=>D});var n=t(58878),a=t(65852),r=t(71813),i=t(25444),l=t(62579),o=t(65140),d=t(22215),c=t(72326),u=t(60654),m=t(49350),x=t(4329),p=t(74573),g=t(74027),h=t(37508),f=t(45155),v=t(45203),j=t(75121),b=t(19765);const N=b.J1` 2 mutation DraftAtRiskOutreach($orgId: ID!, $studentUserId: ID!, $examTypeId: ID!) { 3 draftAtRiskOutreach(orgId: $orgId, studentUserId: $studentUserId, examTypeId: $examTypeId) { 4 parentEmail 5 parentEmailSubject 6 callScript 7 studentNudge 8 studentNudgeSubject 9 parentRecipients { 10 name 11 email 12 phone 13 } 14 studentRecipient { 15 name 16 email 17 phone 18 } 19 studentAccessRevoked 20 } 21 } 22`,y=b.J1` 23 mutation SendAtRiskOutreachEmail( 24 $orgId: ID! 25 $studentUserId: ID! 26 $recipientKind: AtRiskOutreachRecipientKind! 27 $subject: String! 28 $body: String! 29 ) { 30 sendAtRiskOutreachEmail( 31 orgId: $orgId 32 studentUserId: $studentUserId 33 recipientKind: $recipientKind 34 subject: $subject 35 body: $body 36 ) { 37 sentRecipients { 38 name 39 email 40 } 41 failedRecipients { 42 name 43 email 44 } 45 } 46 } 47`;var w=t(72097),k=t(27242),I=t(94731),A=t(53350),S=t(39984),C=t(90782);const E={subject:"",body:"",status:"idle",sentRecipients:[],failedRecipients:[],errorKey:null},$="w-full rounded-lg border border-border-strong bg-surface-raised shadow-elevation-sm p-3 text-sm text-text focus:outline-none focus:ring-2 focus:ring-brand disabled:opacity-60",D=e=>{let{isOpen:s,onClose:t,orgId:b,studentUserId:D,examTypeId:z,studentName:R}=e;const{t:U}
47=(0,r.B)(),P=(0,A.j)(),[L,T]=(0,n.useState)("parentEmail"),[_,M]=(0,n.useState)(null),[F,O]=(0,n.useState)(E),[B,K]=(0,n.useState)(E),[H,Z]=(0,n.useState)(""),[G,J]=(0,n.useState)(null),[Q,{loading:V,error:Y}]=(0,a.n)(N),[q]=(0,a.n)(y,{update:e=>(0,I.ve)(e)}),W="sending"===F.status||"sending"===B.status,X=n.useCallback(()=>{M(null),O(E),K(E),Z(""),Q({variables:{orgId:b,studentUserId:D,examTypeId:z}}).then(e=>{var s;const t=null===(s=e.data)||void 0===s?void 0:s.draftAtRiskOutreach;t&&(M({parentEmail:t.parentEmail,parentEmailSubject:t.parentEmailSubject,studentNudge:t.studentNudge,studentNudgeSubject:t.studentNudgeSubject,callScript:t.callScript,parentRecipients:t.parentRecipients,studentRecipient:t.studentRecipient,studentAccessRevoked:t.studentAccessRevoked}),O({...E,subject:t.parentEmailSubject,body:t.parentEmail}),K({...E,subject:t.studentNudgeSubject,body:t.studentNudge}),Z(t.callScript),(0,w.sx)({eventType:"interaction",actionName:"org_outreach_draft_generated"}))}).catch(()=>{})},[Q,b,D,z]);(0,n.useEffect)(()=>{s&&(T("parentEmail"),J(null),X())},[s]);const ee="callScript"===L?H:"parentEmail"===L?F.body:B.body,se=async()=>{try{await navigator.clipboard.writeText(ee),J(L),setTimeout(()=>J(e=>e===L?null:e),2e3)}catch{}},te=[{id:"parentEmail",label:(0,C.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,C.jsx)(i.A,{size:14,"aria-hidden":!0}),U("Parent email")]})},{id:"studentNudge",label:(0,C.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,C.jsx)(i.A,{size:14,"aria-hidden":!0}),U("Student email")]})},{id:"callScript",label:(0,C.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,C.jsx)(l.A,{size:14,"aria-hidden":!0}),U("Call script")]})}],ne="parentEmail"===L||"studentNudge"===L,ae="parentEmail"===L?F:B,re="parentEmail"===L?O:K,ie=_?"parentEmail"===L?_.parentRecipients:[_.studentRecipient]:[],le=!!_&&("parentEmail"===L?0===_.parentRecipients.length||"NO_RECIPIENT"===F.errorKey:"studentNudge"===L&&(_.studentAcce
47ssRevoked||"STUDENT_ACCESS_REVOKED"===B.errorKey)),oe=ae.sentRecipients.map(e=>e.name).join(", "),de=ae.failedRecipients.map(e=>e.name).join(", "),ce=_?!ne||le||"sent"===ae.status?(0,C.jsx)("div",{className:"flex flex-wrap justify-end gap-3",children:(0,C.jsx)(x.$,{variant:"outline",size:"md",className:"min-h-[40px]",disabled:W,onClick:t,children:U("Close")})}):(0,C.jsxs)("div",{className:"flex flex-wrap justify-end gap-3",children:[(0,C.jsx)(x.$,{variant:"outline",size:"md",className:"min-h-[40px]",disabled:W,onClick:t,children:U("Close")}),(0,C.jsx)(v.A,{variant:"primary",size:"md",className:"min-h-[40px]",isDemoViewer:P,demoHint:U("Sending is turned off in the demo."),isLoading:"sending"===ae.status,disabled:!ae.subject.trim()||!ae.body.trim(),onClick:()=>{const e="parentEmail"===L,s=e?F:B,t=e?O:K,n=s.subject.trim(),a=s.body.trim();t(e=>({...e,status:"sending"})),q({variables:{orgId:b,studentUserId:D,recipientKind:e?"PARENT":"STUDENT",subject:n,body:a}}).then(e=>{var s,n,a;const r=null===(s=e.data)||void 0===s?void 0:s.sendAtRiskOutreachEmail,i=null!==(n=null===r||void 0===r?void 0:r.sentRecipients)&&void 0!==n?n:[],l=null!==(a=null===r||void 0===r?void 0:r.failedRecipients)&&void 0!==a?a:[];i.length>0?t(e=>({...e,status:"sent",sentRecipients:i,failedRecipients:l,errorKey:null})):t(e=>({...e,status:"error",errorKey:"ALL_FAILED"}))}).catch(e=>{var s,n,a,r,i,l,o,d;if((0,k.CT)(e))return void t(e=>({...e,status:"idle"}));const c=null!==(s=null!==(n=null===e||void 0===e||null===(a=e.graphQLErrors)||void 0===a||null===(r=a[0])||void 0===r||null===(i=r.extensions)||void 0===i?void 0:i.reason)&&void 0!==n?n:null===e||void 0===e||null===(l=e.graphQLErrors)||void 0===l||null===(o=l[0])||void 0===o||null===(d=o.extensions)||void 0===d?void 0:d.code)&&void 0!==s?s:"UNKNOWN";t(e=>({...e,status:"error",errorKey:c}))})},children:U("Send email")})]}):(0,C.jsx)("div",{className:"flex flex-wrap justify-end gap-3",children:(0,C.jsx)(x.$,{variant:"outline",size:"md",className:"min-h-[40px]",onClick:t,children:U("Close")})});return(0,C.jsx)(m.a,{isOpen:s,onClose:W?()=>{}:t,title:U("Draft outreach for {{studentName}}",{studentName:R}),description:U("AI-drafted from this student's at-risk signals. Review and edit before you send or use it."),size:"lg",mobileFullScreen:!0,"aria-label":U("Draft outreach for {{studentName}}",{studentName:R}),footer:ce,children:(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsx)(h.I,{items:te,activeId:L,onChange:e=>T(e),ariaLabel:U("Outreach draft type")}),V&&(0,C.jsxs)("div",{className:"space-y-3","aria-label":U("Drafting outreach\u2026"),children:[(0,C.jsx)(f.l,{className:"h-9 w-full",rounded:"xl"}),(0,C.jsx)(f.l,{className:"h-4 w-3/4",rounded:"md"}),(0,C.jsx)(f.l,{className:"h-4 w-full",rounded:"md"}),(0,C.jsx)(f.l,{className:"h-4 w-5/6",rounded:"md"}),(0,C.jsx)(f.l,{className:"h-4 w-2/3",rounded:"md"})]}),!V&&Y&&!(0,k.CT)(Y)&&(0,C.jsx)(g.l,{tone:"error",icon:o.A,title:U("Couldn't generate outreach drafts"),description:U("Something went wrong while drafting outreach. Please try again."),action:(0,C.jsx)(x.$,{variant:"secondary",size:"sm",onClick:X,children:U("Retry")})}),!V&&!Y&&_&&"callScript"===L&&(0,C.jsxs)("div",{className:"space-y-3",children:[(0,C.jsxs)("p",{className:"flex items-start gap-2 text-sm text-text-muted",children:[(0,C.jsx)(l.A,{size:14,className:"flex-shrink-0 mt-0.5","aria-hidden":!0}),U("Read this on the call \u2014 nothing is sent from this tab.")]}),(0,C.jsx)("div",{className:"space-y-1",children:0===_.parentRecipients.length?(0,C.jsx)("p",{className:"text-sm text-text-muted",children:U("No parent contact on file")}):_.parentRecipients.map((e,s)=>e.phone?(0,C.jsxs)("a",{href:(0,j.Kz)(e.phone),className:"flex items-center gap-2 min-h-[44px] px-2 -mx-1 rounded-lg text-sm font-medium text-brand hover:bg-surface-sunken",children:[(0,C.jsx)(l.A,{size:14,className:"flex-shrink-0"}),U("Call {{name}} \xb7 {{phone}}",{name:e.name,phone:e.phone})]},s):(0,C.jsx)("p",{className:"text-sm text-text-subtle italic",children:U("No phone on file")},s))}),(0,C.jsx)("textarea",{value:H,onChange:e=>Z(e.target.value),rows:10,className:$}),(0,C.jsx)("div",{className:"flex justify-end",children:(0,C.jsx)(x.$,{variant:"secondary",size:"sm",leftIcon:"callScript"===G?(0,C.jsx)(d.A,{size:14,className:"text-success-600"}):(0,C.jsx)(c.A,{size:14}),onClick:se,children:U("callScript"===G?"Copied!":"Copy")})})]}),!V&&!Y&&_&&ne&&(0,C.jsx)("div",{className:"space-y-4",children:le?(0,C.jsx)("p",{className:"text-sm text-text-muted",children:U("studentNudge"===L?"This student's access was revoked, so they can't be emailed from here.":"No parent contact on file, so this email can't be sent from here.")}):"sent"===ae.status?(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsx)(g.l,{tone:"success",icon:u.A,title:U("Email sent"),description:(0,C.jsxs)(C.Fragment,{children:[U("Sent to {{recipients}}.",{recipients:oe}),de&&` ${U("Couldn't reach {{failed}} \u2014 check the Contact log for delivery status.",{failed:de})}`]})}),(0,C.jsx)("p",{className:"px-1 text-xs text-text-subtle",children:U("Subject: {{subject}}",{subject:ae.subject})})]}):(0,C.jsxs)("div",{className:"space-y-3",children:["error"===ae.status&&(0,C.jsx)(g.l,{tone:"error",icon:o.A,title:U("Couldn't send the email"),description:(e=>{switch(e){case"ALL_FAILED":return U("No recipient could be reached. Try again, or copy the text and send it from your own email.");case"FEATURE_DISABLED":return U("Outreach sending isn't enabled for this organization.");case"FORBIDDEN":return U("You don't have access to email this student's contacts.");case"BAD_USER_INPUT":return U("Check the subject and message, then try again.");default:return U("Something went wrong while sending. Please try again.")}})(ae.errorKey)}),(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsx)("p",{className:"text-sm font-medium text-text",children:U("To")}),ie.map((e,s)=>(0,C.jsx)("p",{className:"text-sm text-text-muted min-w-0 break-all",children:e.email===e.name?e.email:`${e.name} \xb7 ${e.email}`},s))]}),(0,C.jsx)(p.p,{label:U("Subject",{context:"email"}),value:ae.subject,onChange:e=>re(s=>({...s,subject:e.target.value})),maxLength:S.LCo,disabled:"sending"===ae.status,className:"disabled:opacity-60"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("label",{className:"text-sm font-medium text-text",children:U("Message")}),(0,C.jsx)("textarea",{value:ae.body,onChange:e=>re(s=>({...s,body:e.target.value})),rows:10,maxLength:S.IJZ,disabled:"sending"===ae.status,className:`mt-1 ${$}`})]}),(0,C.jsx)("div",{className:"flex justify-end",children:(0,C.jsx)(x.$,{variant:"secondary",size:"sm",leftIcon:G===L?(0,C.jsx)(d.A,{size:14,className:"text-success-600"}):(0,C.jsx)(c.A,{size:14}),onClick:se,children:U(G===L?"Copied!":"Copy")})})]})})]})})}},2884(e,s,t){var n=t(58878),a=t(71813),r=t(65852),i=t(65140),l=t
47(61311),o=t(38926),d=t(49350),c=t(4329),u=t(74573),m=t(74027),x=t(589),p=t(94731),g=t(39358),h=t(27242),f=t(90782);const v=e=>{let{orgId:s,studentUserId:t,studentName:v,existingGuardians:j,onClose:b,onSaved:N}=e;const{t:y}=(0,a.B)(),[w,k]=(0,n.useState)(()=>0===j.length?[{guardianName:"",guardianEmail:"",guardianPhone:""}]:j.map(e=>({guardianName:e.guardianName||"",guardianEmail:e.guardianEmail,guardianPhone:e.guardianPhone||""}))),[I,A]=(0,n.useState)(!1),[S,{loading:C,error:E}]=(0,r.n)(x.MFn,{update:p.C}),$=(e,s)=>{k(t=>t.map((t,n)=>n===e?{...t,...s}:t))},D=(0,n.useMemo)(()=>w.filter(e=>""!==e.guardianEmail.trim()),[w]),z=(0,n.useMemo)(()=>{const e=new Set;return w.map(s=>{const t=s.guardianEmail.trim().toLowerCase();return""===t?""!==s.guardianPhone.trim()||""!==s.guardianName.trim()?"Add an email for this parent \u2014 rows without an email aren't saved.":null:(0,g.cJ)(t)?e.has(t)?"Duplicate email \u2014 this parent is already listed.":(e.add(t),null):"Enter a valid email address."})},[w]),R=z.some(e=>null!==e);return(0,f.jsx)(d.a,{isOpen:!0,onClose:()=>{C||b()},title:y("Parent contacts"),description:`Progress reports for ${v} will be emailed to these parents/guardians.`,size:"md",footer:(0,f.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,f.jsx)(c.$,{variant:"outline",size:"md",onClick:b,disabled:C,children:"Cancel"}),(0,f.jsx)(c.$,{variant:"primary",size:"md",onClick:async()=>{if(A(!0),R||C)return;const e=D.map(e=>({guardianName:e.guardianName.trim()||null,guardianEmail:e.guardianEmail.trim().toLowerCase(),guardianPhone:e.guardianPhone.trim()||null}));try{await S({variables:{orgId:s,studentUserId:t,guardians:e}}),null===N||void 0===N||N(),b()}catch{}},isLoading:C,disabled:C||I&&R,children:"Save contacts"})]}),children:(0,f.jsxs)("div",{className:"space-y-4",children:[E&&!(0,h.CT)(E)&&(0,f.jsx)(m.l,{tone:"warning",icon:i.A,title:"Couldn't save parent contacts",description:E.message}),0===w.length?(0,f.jsx)("p",{className:"text-sm text-text-muted",children:"No parent contacts. Add one below, or save to remove all contacts for this student."}):(0,f.jsx)("div",{className:"space-y-3",children:w.map((e,s)=>(0,f.jsx)("div",{className:"rounded-2xl bg-surface-sunken p-3 space-y-2",children:(0,f.jsxs)("div",{className:"flex items-start gap-2",children:[(0,f.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,f.jsx)(u.p,{label:y("Parent name (optional)"),value:e.guardianName,onChange:e=>$(s,{guardianName:e.target.value}),placeholder:y("Jane Doe"),disabled:C}),(0,f.jsx)(u.p,{label:y("Parent email"),type:"email",value:e.guardianEmail,onChange:e=>$(s,{guardianEmail:e.target.value}),placeholder:"[email protected]",disabled:C,error:I&&z[s]||void 0}),(0,f.jsx)(u.p,{label:y("Parent phone (optional)"),type:"tel",value:e.guardianPhone,onChange:e=>$(s,{guardianPhone:e.target.value}),placeholder:"(555) 010-1234",disabled:C})]}),(0,f.jsx)("button",{type:"button",onClick:()=>(e=>{k(s=>s.filter((s,t)=>t!==e))})(s),disabled:C,"aria-label":y("Remove parent contact"),className:"mt-7 flex-shrink-0 text-text-subtle hover:text-error-600 disabled:opacity-50",children:(0,f.jsx)(o.A,{size:16})})]})},s))}),w.length<4&&(0,f.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>{k(e=>e.length>=4?e:[...e,{guardianName:"",guardianEmail:"",guardianPhone:""}])},disabled:C,leftIcon:(0,f.jsx)(l.A,{size:14}),children:y("Add parent contact")}),(0,f.jsx)("p",{className:"text-xs text-text-subtle",children:y("Up to {{max}} parents/guardians per student.",{max:4})})]})})};t.d(s,["A",0,v])},75121(e,s,t){t.d(s,{Ay:()=>f,Kz:()=>p,l8:()=>h,v3:()=>g});var n=t(58878),a=t(71813),r=t(25444),i=t(65220),l=t(62579),o=t(97307),d=t(72097),c=t(90523),u=t(75980),m=t(67650),x=t(90782);const p=e=>`tel:${e.replace(/[^+\d]/g,"")}`,g=e=>`mailto:${e.replace(/[^A-Za-z0-9._%+@-]/g,"")}`,h=()=>(0,d.sx)({eventType:"click",actionName:"org_guardian_call_click"}),f=e=>{var s,t;let{guardians:d,studentName:f,onEditGuardians:v,orgId:j,studentUserId:b,examTypeId:N}=e;const{t:y}=(0,a.B)(),[w,k]=(0,n.useState)(!1),I=(0,n.useRef)(null),A=(0,n.useRef)(null),[S,C]=(0,n.useState)(null),[E,$]=(0,n.use
47State)(!1),{isEnabled:D}=(0,c.u)(u._m),z=D&&!!j&&!!b&&!!N;return(0,n.useLayoutEffect)(()=>{if(!w)return;const e=I.current,s=A.current;if(!e||!s)return;const t=e.getBoundingClientRect(),n=s.offsetHeight,a=Math.max(8,Math.min(t.right-288,window.innerWidth-288-8));let r=t.bottom+6;r+n>window.innerHeight-8&&(r=Math.max(8,t.top-n-6)),C({top:r,left:a})},[w,d.length]),(0,n.useEffect)(()=>{if(!w)return;const e=e=>{var s,t;const n=e.target;null!==(s=A.current)&&void 0!==s&&s.contains(n)||null!==(t=I.current)&&void 0!==t&&t.contains(n)||k(!1)},s=e=>{var s;"Escape"===e.key&&(k(!1),null===(s=I.current)||void 0===s||s.focus())},t=()=>k(!1),n=e=>{var s;null!==(s=A.current)&&void 0!==s&&s.contains(e.target)||t()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("keydown",s),window.addEventListener("scroll",n,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("keydown",s),window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",t)}},[w]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("button",{ref:I,type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),k(e=>!e)},"aria-haspopup":"dialog","aria-expanded":w,"aria-label":`Parent contacts for ${f}`,title:y("Parent contacts"),className:"flex-shrink-0 flex items-center justify-center w-10 h-10 rounded-full text-text-muted hover:text-text hover:bg-surface-sunken transition-colors",children:(0,x.jsx)(l.A,{size:15})}),w&&(0,x.jsx)(o.A,{children:(0,x.jsxs)("div",{ref:A,role:"dialog","aria-label":`Parent contacts for ${f}`,style:{position:"fixed",top:null!==(s=null===S||void 0===S?void 0:S.top)&&void 0!==s?s:0,left:null!==(t=null===S||void 0===S?void 0:S.left)&&void 0!==t?t:0,width:288,visibility:S?"visible":"hidden",zIndex:60},className:"bg-surface-raised rounded-2xl shadow-elevation-lg ring-1 ring-neutral-100 p-3",onClick:e=>e.stopPropagation(),children:[(0,x.jsx)("p",{className:"text-xs font-semibold text-text-subtle uppercase tracking-wide px-1 mb-1",children:y("Parent contacts")}),0===d.length?(0,x.jsxs)("div",{className:"px-1 pb-1",children:[(0,x.jsx)("p",{className:"text-sm text-text-muted",children:y("No parent contact on file")}),v?(0,x.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),k(!1),v()},className:"mt-2 text-sm font-medium text-brand hover:underline",children:y("Add parent contact \u2192")}):(0,x.jsx)("p",{className:"mt-1 text-xs text-text-subtle",children:y("Ask an org admin to add one.")})]}):(0,x.jsx)("div",{className:"max-h-72 overflow-y-auto divide-y divide-border-subtle",children:d.map(e=>(0,x.jsxs)("div",{className:"py-2 px-1 first:pt-1 last:pb-1",children:[(0,x.jsx)("p",{className:"text-sm font-medium text-text truncate",children:e.guardianName||e.guardianEmail}),!e.guardianPhone&&(0,x.jsx)("p",{className:"mt-0.5 px-1 text-xs text-text-subtle italic",children:y("No phone on file")}),e.guardianPhone&&(0,x.jsxs)("a",{href:p(e.guardianPhone),onClick:e=>{e.stopPropagation(),h()},className:"mt-1 flex items-center gap-2 min-h-[44px] px-2 -mx-1 rounded-lg text-sm font-medium text-brand hover:bg-surface-sunken transition-colors",children:[(0,x.jsx)(l.A,{size:14,className:"flex-shrink-0"}),(0,x.jsx)("span",{className:"whitespace-nowrap truncate",children:e.guardianPhone})]}),(0,x.jsxs)("a",{href:g(e.guardianEmail),onClick:e=>e.stopPropagation(),className:"mt-0.5 flex items-center gap-2 min-h-[36px] px-2 -mx-1 rounded-lg text-xs text-text-muted hover:text-text hover:bg-surface-sunken transition-colors",children:[(0,x.jsx)(r.A,{size:13,className:"flex-shrink-0"}),(0,x.jsx)("span",{className:"truncate",children:e.guardianEmail})]})]},e.id))}),d.length>0&&d.some(e=>!e.guardianPhone)&&(v||!d.some(e=>e.guardianPhone))&&(0,x.jsx)("div",{className:"mt-1 px-1 pt-2 border-t border-border-subtle",children:v?(0,x.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),k(!1),v()},className:"text-sm font-medium text-brand hover:underline",children:"Add phone number \u2192"}):(0,x.jsx)("p",{className:"text-xs text-text-subtle",children:"Ask an org admin to add one."})}),z&&(0,x.jsx)("div",{className:"mt-1 px-1 pt-2 border-t border-border-subtle",children:(0,x.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),k(!1),$(!0)},className:"flex items-center gap-2 min-h-[36px] -mx-1 px-1 rounded-lg text-sm font-medium text-brand hover:bg-surface-sunken transition-colors",children:[(0,x.jsx)(i.A,{size:14,className:"flex-shrink-0"}),y("Draft outreach")]})})]})}),z&&E&&(0,x.jsx)(m.A,{isOpen:E,onClose:()=>$(!1),orgId:j,studentUserId:b,examTypeId:N,studentName:f})]})}},76967(e,s,t){var n=t(58878),a=t(71813),r=t(2884),i=t(5904),l=t(90782);const o=e=>{let{orgId:s,studentUserId:t,studentName:o,existingGuardians:d,onClose:c}=e;const{t:u}
47=(0,a.B)(),[m,x]=(0,n.useState)(!0),[p,g]=(0,n.useState)(null),h=(0,n.useRef)(!1),f={type:"success",message:u("Parent contacts saved.")};return(0,n.useEffect)(()=>{if(!p)return;const e=setTimeout(()=>{g(null),c()},2500);return()=>clearTimeout(e)},[p,c]),(0,l.jsxs)(l.Fragment,{children:[m&&(0,l.jsx)(r.A,{orgId:s,studentUserId:t,studentName:o,existingGuardians:d,onSaved:()=>{h.current=!0,g(f)},onClose:()=>{x(!1),h.current||c()}}),(0,l.jsx)(i.y,{toast:p,onDismiss:()=>{g(null),c()}})]})};t.d(s,["A",0,o])},6172(e,s,t){var n=t(58878),a=t(71813),r=t(74578),i=t(49350),l=t(4329),o=t(54830),d=t(84390),c=t(3263),u=t(73250),m=t(4368),x=t(90782);const p=(e,s)=>`${e}\0${s}`;const g=e=>{var s,t;let{items:g,reasonFilter:h,source:f,riskDismissals:v,onToast:j}=e;const{t:b}=(0,a.B)(),N=null===(s=(0,u.ad)())||void 0===s||null===(t=s.user)||void 0===t?void 0:t.id,y=(0,n.useMemo)(()=>function(e){const s=[],t=new Map;let n=0;for(const r of e)if(0!==r.reasons.length){s.push(r);for(const e of r.reasons){var a;n+=1,t.set(e,(null!==(a=t.get(e))&&void 0!==a?a:0)+1)}}return{items:s,alerts:n,byReason:t}}
47(g),[g]),[w,k]=(0,n.useState)(null),[I,A]=(0,n.useState)(!1),[S,C]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{0!==y.alerts||I||(k(null),C(!1))},[y.alerts,I]),(0,c.H)()||!v.settled||0===y.alerts)return null;const E=()=>{I||(k(null),C(!1))},$=async e=>{j(null);const{outcome:s,remaining:t}=await v.undoMany(e,f,h);"ok"===s?j({type:"success",message:b("Alerts restored")}):"failed"===s&&j({type:"error",message:b("Couldn't restore the alerts \u2014 try again."),action:t.length>0?{label:b("Try again"),onClick:()=>{$(t)}}:void 0})},D=w?m.wI.filter(e=>{var s;return(null!==(s=w.byReason.get(e))&&void 0!==s?s:0)>0}).map(e=>`${(0,d.y)(b,e)} (${w.byReason.get(e)})`).join(" \xb7 "):"";return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.$,{variant:"secondary",size:"sm",className:"min-h-[40px]",leftIcon:(0,x.jsx)(r.A,{size:14}),disabled:I||v.pendingUserIds.size>0,onClick:()=>{C(!1),k(y)},children:b("Dismiss all alerts ({{count}})",{count:y.alerts})}),(0,x.jsx)(i.a,{isOpen:null!==w,onClose:E,title:b("Dismiss all alerts?"),size:"md",footer:(0,x.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,x.jsx)(l.$,{variant:"outline",size:"md",onClick:E,disabled:I,children:b("Cancel")}),(0,x.jsx)(l.$,{variant:"primary",size:"md",onClick:async()=>{if(!w)return;const e=new Set;for(const l of y.items)for(const s of l.reasons)e.add(p(l.studentUserId,s));const s=[];for(const l of w.items){const t=l.reasons.filter(s=>e.has(p(l.studentUserId,s)));t.length>0&&s.push({...l,reasons:t})}const t={type:"warning",message:b("No alerts to dismiss \u2014 the list has changed.")};if(0===s.length)return k(null),void j(t);A(!0),C(!1);const{outcome:n,dismissed:a}=await v.dismissMany(s,f,h,N);if(A(!1),"failed"===n&&0===a.length)return void C(!0);if(k(null),"blocked"===n)return;if(0===a.length)return void j(t);const r=a.length,i="ok"===n?1===r?b("Dismissed 1 alert"):b("Dismissed {{alerts}} alerts",{alerts:r}):1===r?b("Dismissed 1 alert \u2014 the rest couldn't be dismissed. Try again."):b("Dismissed {{alerts}} alerts \u2014 the rest couldn't be dismissed. Try again.",{alerts:r});j({type:"ok"===n?"success":"warning",message:i,action:{label:b("Undo"),onClick:()=>{$(a)}}})},isLoading:I,children:b("Dismiss all")})]}),children:w&&(0,x.jsxs)("div",{className:"space-y-2",children:[(0,x.jsx)("p",{className:"text-sm text-text",children:1===w.alerts?b("Dismiss 1 alert for 1 student?"):1===w.items.length?b("Dismiss {{alerts}} alerts for 1 student?",{alerts:w.alerts}):b("Dismiss {{alerts}} alerts for {{students}} students?",{alerts:w.alerts,students:w.items.length})}),(0,x.jsx)("p",{className:o.u0.meta,children:D}),(0,x.jsx)("p",{className:"text-sm text-text-muted",children:b("Each alert comes back on its own when new evidence appears.")}),S&&(0,x.jsx)("p",{className:"text-sm text-error",role:"alert",children:b("Couldn't dismiss the alerts \u2014 try again.")})]})})]})};t.d(s,["A",0,g])},42781(e,s,t){t.d(s,{A:()=>g});var n=t(58878),a=t(71813),r=t(54079),i=t(97307),l=t(4329),o=t(54830),d=t(65576),c=t(4368),u=t(84390),m=t(90782);const x=e=>{var s,t;let{studentName:x,activeFlags:p,suppressedFlags:g,dismissals:h,canDismiss:f,onDismiss:v,onUndo:j}=e;const{t:b}=(0,a.B)(),[N,y]=(0,n.useState)(!1),w=(0,n.useRef)(null),k=(0,n.useRef)(null),[I,A]=(0,n.use
47State)(null),[S,C]=(0,n.useState)(new Set),[E,$]=(0,n.useState)(!1),D=(0,c.tp)(p).map(e=>e.reason),z=new Set(g.map(e=>e.reason)),R=(null!==h&&void 0!==h?h:[]).filter(e=>z.has(e.reason));(0,n.useLayoutEffect)(()=>{if(!N)return;const e=w.current,s=k.current;if(!e||!s)return;const t=e.getBoundingClientRect(),n=s.offsetHeight,a=Math.max(8,Math.min(t.right-288,window.innerWidth-288-8));let r=t.bottom+6;r+n>window.innerHeight-8&&(r=Math.max(8,t.top-n-6)),A({top:r,left:a})},[N,D.length,R.length,E]);const U=(0,n.useCallback)(()=>{var e;const s=document.activeElement;var t;s&&null!==(e=k.current)&&void 0!==e&&e.contains(s)&&(null===(t=w.current)||void 0===t||t.focus({preventScroll:!0}));y(!1),$(!1)},[]),P=(0,n.useCallback)(()=>{const e=k.current;if(!e)return;const s=e.querySelector("button:not([disabled])");(null!==s&&void 0!==s?s:e).focus({preventScroll:!0})},[]),L=null!==I;(0,n.useEffect)(()=>{var e;N&&L&&(null!==(e=k.current)&&void 0!==e&&e.contains(document.activeElement)||P())},[N,L,P]),(0,n.useEffect)(()=>{if(!N)return;const e=e=>{var s,t;const n=e.target;null!==(s=k.current)&&void 0!==s&&s.contains(n)||null!==(t=w.current)&&void 0!==t&&t.contains(n)||U()},s=e=>{var s;"Escape"===e.key&&(U(),null===(s=w.current)||void 0===s||s.focus())},t=e=>{var s;null!==(s=k.current)&&void 0!==s&&s.contains(e.target)||U()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("keydown",s),window.addEventListener("scroll",t,!0),window.addEventListener("resize",U),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("keydown",s),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",U)}},[N,U]);const T=async(e,s)=>{$(!1),C(s=>{const t=new Set(s);return e.forEach(e=>t.add(e)),t});const t=await s();C(s=>{const t=new Set(s);return e.forEach(e=>t.delete(e)),t}),"failed"===t&&$(!0),requestAnimationFrame(()=>{const e=k.current,s=document.activeElement,t=!s||s===document.body;e&&t&&P()})},_=`${b("Dismiss alerts")} \u2014 ${x}`;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("button",{ref:w,type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),N?U():y(!0)},"aria-haspopup":"dialog","aria-expanded":N,"aria-label":b("Dismiss alerts"),title:b("Dismiss alerts"),className:(0,d.U)("brand","h-10 w-10"),children:(0,m.jsx)(r.A,{size:16,className:"shrink-0"})}),N&&(0,m.jsx)(i.A,{children:(0,m.jsxs)("div",{ref:k,role:"dialog","aria-label":_,tabIndex:-1,style:{position:"fixed",top:null!==(s=null===I||void 0===I?void 0:I.top)&&void 0!==s?s:0,left:null!==(t=null===I||void 0===I?void 0:I.left)&&void 0!==t?t:0,width:288,visibility:I?"visible":"hidden",zIndex:60},className:"bg-surface-raised rounded-2xl shadow-elevation-lg ring-1 ring-neutral-100 p-3 focus:outline-none",onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(o.ZB,{as:"h2",className:"px-1",children:b("Dismiss alerts")}),(0,m.jsx)("p",{className:"px-1 mt-0.5 mb-2 text-xs text-text-muted",children:b("Hidden until new evidence appears")}),0===D.length?(0,m.jsx)("p",{className:"px-1 py-1 text-sm text-text-muted",children:b("No active alerts for this student.")}):(0,m.jsx)("ul",{className:"space-y-0.5",children:D.map(e=>{const s=S.has(e);return(0,m.jsxs)("li",{"data-testid":`risk-dismiss-row-${e}`,"aria-busy":s||void 0,className:"flex items-center justify-between gap-2 px-1 py-1.5 "+(s?"opacity-60":""),children:[(0,m.jsx)("span",{className:"min-w-0 truncate text-sm font-medium text-text",children:(0,u.y)(b,e)}),f&&(0,m.jsx)(l.$,{size:"xs",variant:"ghost",className:"min-h-[40px] shrink-0",isLoading:s,onClick:s=>{s.stopPropagation(),T([e],()=>v([e]))},children:b("Dismiss")})]},e)})}),f&&D.length>=2&&(0,m.jsx)("div",{className:"mt-2 px-1 flex justify-end",children:(0,m.jsx)(l.$,{size:"xs",variant:"secondary",className:"min-h-[40px]",disabled:D.some(e=>S.has(e)),onClick:e=>{e.stopPropagation(),T(D,()=>v(D))},children:b("Dismiss all")})}),R.length>0&&(0,m.jsx)("ul",{className:"mt-3 space-y-0.5",children:R.map(e=>{var s;const t=S.has(e.reason),n=null!==(s=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;const t=Date.parse(e);return Number.isNaN(t)?null:Math.max(0,Math.floor((s.getTime()-t)/864e5))}(e.dismissedAt))&&void 0!==s?s:0,a=e.dismissedByName?b("Dismissed by {{name}} \xb7 {{count}}d ago",{name:e.dismissedByName,count:n}):b("Dismissed {{count}}d ago",{count:n});return(0,m.jsxs)("li",{"data-testid":`risk-dismissed-row-${e.reason}`,"aria-busy":t||void 0,className:"flex items-center justify-between gap-2 px-1 py-1.5 opacity-60",children:[(0,m.jsxs)("span",{className:"min-w-0",children:[(0,m.jsx)("span",{className:"block truncate text-sm font-medium text-text",children:(0,u.y)(b,e.reason)}),(0,m.jsx)("span",{className:`block truncate ${o.u0.meta}`,title:a,children:a})]}),f&&(0,m.jsx)(l.$,{size:"xs",variant:"ghost",className:"min-h-[40px] shrink-0",isLoading:t,onClick:s=>{s.stopPropagation(),T([e.reason],()=>j(e.reason))},children:b("Undo")})]},e.reason)})}),E&&(0,m.jsx)("p",{role:"alert",className:"mt-2 px-1 text-xs text-error",children:b("Couldn't save \u2014 try again.")})]})})]})};var p=t(3263);const g=e=>{let{riskDismissals:s,entry:t,studentName:n,source:a,canDismiss:r}=e;if(!r||(0,p.H)())return null;const{member:i}=t;return(0,m.jsx)(x,{studentName:n,activeFlags:t.flags,suppressedFlags:t.suppressedFlags,dismissals:s.dismissalsByStudent.get(i.userId),canDismiss:!0,onDismiss:e=>s.dismiss(i.userId,e,a,i),onUndo:e=>s.undo(i.userId,e,a)})}},66778(e,s,t){var n=t(58878),a=t(39018),r=t(71813),i=t(89500),l=t(89098),o=t(65140),d=t(61232),c=t(88737),u=t(38557),m=t(87668),x=t(59793),p=t(81910),g=t(95552),h=t(18985),f=t(89583),v=t(53276),j=t(51150),b=t(45155),N=t(37508),y=t(68155),w=t(74027),k=t(4329),I=t(54830),A=t(57398),S=t(75121),C=t(42781),E=t(6172),$=t(84390),D=t(95066),z=t(62136),R=t(97607),U=t(4368),P=t(90782);const L=(e,s)=>{const t="flex-shrink-0 "+("critical"===s?"text-error-500":"text-warning-500");switch(e){case"score_regression":return(0,P.jsx)(d.A,{size:14,className:t});case"overdue":return(0,P.jsx)(l.A,{size:14,className:t});case"failing_assignments":return(0,P.jsx)(g.A,{size:14,className:t});case"rushing":return(0,P.jsx)(v.A,{size:14,className:t});case"inactive":return(0,P.jsx)(h.A,{size:14,className:t});case"low_accuracy":return(0,P.jsx)(f.A,{size:14,className:t})}},T=(e,s,t)=>{var n;switch(s.reason){case"score_regression":var a,r;return`score \u2193${(null!==(a=e.priorMockScore)&&void 0!==a?a:0)-(null!==(r=e.lastMockScore)&&void 0!==r?r:0)}`;case"overdue":{const s=e.overdueAssignmentsCount||0;return j.A.t("{{n}} overdue",{n:s})}case"failing_assignments":return`${(0,U.YV)(e.completedAssignmentAvgAccuracy||0)}% on assignments`;case"rushing":return j.A.t("{{sec}}s avg per question \u2014 may be guessing",{sec:(0,U.O8)(null!==(n=e.completedAssignmentAvgSecondsPerQuestion)&&void 0!==n?n:0)});case"inactive":return j.A.t("{{n}}d inactive",{n:null!==t&&void 0!==t?t:"?"});case"low_accuracy":return j.A.t("{{n}}% accuracy",{n:(0,U.YV)(e.accuracy||0)})}},_={score_regression:"mock-exams",overdue:"assignments",failing_assignments:"assignments",rushing:"assignments",inactive:"sessions",low_accuracy:"topics"},M=e=>{let{flags:s}=e;return(0,P.jsx)(x.A,{size:8,className:"flex-shrink-0 "+((0,U.K4)(s)?"text-error-500":"text-warning-500")})},F=e=>{let{member:s,flags:t,daysInactive:n,max:a=2,calm:r=!1,onReasonClick:i}=e;return(0,P.jsx)(P.Fragment,{children:(0,U.tp)(t).slice(0,a).map((e,t)=>{const a=r?(0,P.jsxs)("span",{className:`${A.UE} min-w-0 max-w-full`,children:[(0,P.jsx)("span",{className:`${A.y5} ${"critical"===e.severity?"bg-error-500":"bg-warning-500"}`}),(0,P.jsx)("span",{className:`${A.Af} truncate`,title:T(s,e,n),children:T(s,e,n)})]}):(0,P.jsxs)(P.Fragment,{children:[L(e.reason,e.severity),(0,P.jsx)("span",{className:"text-xs font-medium truncate "+("critical"===e.severity?"text-error-600":"text-warning-600"),title:T(s,e,n),children:T(s,e,n)})]});return i?(0,P.jsx)("button",{type:"button",onClick:s=>{s.stopPropagation(),i(e.reason)},className:r?"flex min-w-0 max-w-full hover:opacity-80 transition-opacity":"flex items-center gap-1 min-w-0 max-w-full rounded-full px-1 -mx-1 hover:bg-surface-sunken transition-colors",children:a},t):(0,P.jsx)("div",{className:r?"flex min-w-0 max-w-full":"flex items-center gap-1 min-w-0 max-w-full",children:a},t)})})},O=e=>{let{members:s,orgId:t,orgSlug:l,isLoading:d,hasError:x=!1,examTypeId:g,onRetry:h,guardiansByStudent:f,onEditGuardians:v,classId:j,isAdmin:A,riskDismissals:L,enableDismissAll:T=!1,onToast:O}=e;const{t:B}=(0,r.B)(),K=(0,a.Zp)(),{seededAt:H}
47=(0,R.C)(t),[Z,G]=(0,n.useState)(null),[J,Q]=(0,n.useState)("all"),V=null===L||void 0===L?void 0:L.getDismissals,Y=null===L||void 0===L?void 0:L.config,q=(0,n.useMemo)(()=>(0,U.Nv)((0,U.p$)(s,new Date,V,Y)),[s,V,Y]),W=(0,n.useMemo)(()=>q.filter(e=>(0,U.K4)(e.flags)).length,[q]),X=`${l}:${null!==j&&void 0!==j?j:"org"}`,ee=`orgDashboardNeedsAttentionCollapsed:${X}`,se=`orgDashboardNeedsAttentionCollapsedAtCritical:${X}`,[te,ne]=(0,n.useState)(()=>{const e=localStorage.getItem(ee);return null===e||"true"===e});if((0,n.useEffect)(()=>{d||null===localStorage.getItem(ee)&&(localStorage.setItem(se,String(W)),localStorage.setItem(ee,"true"))},[d,W,ee,se]),(0,n.useEffect)(()=>{if(!te)return;const e=Number(localStorage.getItem(se)||"0");W>e&&(ne(!1),localStorage.setItem(ee,"false"))},[W,te,se,ee]),d)return(0,P.jsxs)("div",{className:"bg-surface-raised rounded-3xl shadow-elevation-md ring-1 ring-neutral-100 p-5",children:[(0,P.jsx)(b.l,{className:"h-5 w-36 mb-4",rounded:"md"}),(0,P.jsxs)("div",{className:"space-y-2",children:[(0,P.jsx)(b.l,{className:"h-8",rounded:"lg"}),(0,P.jsx)(b.l,{className:"h-8",rounded:"lg"})]})]});if(x)return(0,P.jsxs)(y.Z,{variant:"soft",padding:"md",children:[(0,P.jsx)(y.Z.Header,{className:"!mb-2",children:(0,P.jsxs)("div",{className:"flex items-center gap-2",children:[(0,P.jsx)(o.A,{size:18,className:"text-warning-600"}),(0,P.jsx)(I.w,{children:B("Needs Attention")})]})}),(0,P.jsx)(w.l,{tone:"error",icon:i.A,title:B("Couldn't load at-risk students."),action:h?(0,P.jsx)(k.$,{variant:"ghost",size:"sm",onClick:h,children:B("Retry")}):void 0})]});if(0===q.length)return null;const ae=new Map;q.forEach(e=>{new Set(e.flags.map(e=>e.reason)).forEach(e=>ae.set(e,(ae.get(e)||0)+1))});const re=e=>(0,$.y)(B,e),ie=[{id:"all",label:`${B("All")} \xb7 ${q.length}`},...U.wI.filter(e=>(ae.get(e)||0)>0).map(e=>({id:e,label:`${re(e)} \xb7 ${ae.get(e)}`}))],le="all"!==J&&(ae.get(J)||0)>0?J:"all",oe="all"===le?q:q.filter(e=>e.flags.some(e=>e.reason===le)),de=oe.slice(0,3),ce=new URLSearchParams({filter:"atRisk"});"all"!==le&&ce.set("reason",le),j&&ce.set("classId",j);const ue=`/org/${l}/performance?${ce.toString()}`,me=(0,P.jsxs)(a.N_,{to:ue,className:"flex items-center gap-1 text-xs font-medium text-warning-700 hover:text-warning-800 flex-shrink-0",children:[B("View all"),(0,P.jsx)(c.A,{size:12})]}),xe=T&&A&&!!L&&!!O&&!te,pe=xe?oe.map(e=>({studentUserId:e.member.userId,reasons:"all"===le?e.flags.map(e=>e.reason):[le],evidence:(0,U.hC)(e.member)})):[];return(0,P.jsxs)("div",{className:"bg-warning-50 rounded-3xl shadow-elevation-md ring-1 ring-warning-200 "+(te?"py-2.5 px-4 sm:px-5":"p-5"),children:[(0,P.jsxs)(y.Z.Header,{className:"flex-wrap gap-y-1 "+(te?"!mb-0":"!mb-2"),children:[(0,P.jsxs)("button",{type:"button",onClick:()=>{ne(e=>{const s=!e;return localStorage.setItem(ee,String(s)),s&&localStorage.setItem(se,String(W)),s})},className:"flex items-center gap-2 min-w-0 hover:opacity-80 transition-opacity","aria-expanded":!te,children:[(0,P.jsx)(o.A,{size:18,className:"text-warning-600 flex-shrink-0"}),(0,P.jsx)(I.w,{className:"whitespace-nowrap",children:B("Needs Attention")}),te&&(0,P.jsxs)("span",{className:"hidden sm:inline text-xs text-warning-600 font-medium flex-shrink-0",children:[B("{{count}} students",{count:q.length}),W>0&&(0,P.jsxs)("span",{className:"text-error-600 ml-1",children:["(",B("{{count}} critical",{count:W}),")"]})]}),te?(0,P.jsx)(u.A,{size:16,className:"text-warning-600 flex-shrink-0"}):(0,P.jsx)(m.A,{size:16,className:"text-warning-600 flex-shrink-0"})]}),xe&&L&&O?(0,P.jsxs)("div",{className:"flex items-center gap-3 flex-wrap justify-end ml-auto",children:[(0,P.jsx)(E.A,{items:pe,reasonFilter:"all"===le?null:le,source:"dashboard_card",riskDismissals:L,onToast:O}),me]}):me]}),!te&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("p",{className:"text-xs text-warning-600 font-medium mb-3",children:[B("{{count}} students",{count:q.length}),W>0&&(0,P.jsxs)("span",{className:"text-error-600 ml-1",children:["(",B("{{count}} critical",{count:W}),")"]})]}),(0,P.jsx)(N.I,{items:ie,activeId:le,onChange:e=>Q(e),ariaLabel:"Filter at-risk students by reason",className:"mb-3",wrap:!0}),(0,P.jsx)("div",{className:"space-y-1.5",children:de.map(e=>{const s=e.member.user.displayName||e.member.user.email;return(0,P.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,P.jsxs)("button",{onClick:()=>{var s;const t=null===(s=(0,U.tp)(e.flags)[0])||void 0===s?void 0:s.reason,n=t&&_[t]||"assignments";K(`/org/${l}/performance?userId=${e.member.userId}${j?`&classId=${j}&from=class`:""}&tab=${n}`)},className:"min-w-[10rem] grow basis-64 flex flex-wrap items-center justify-between p-2 rounded-lg hover:bg-warning-100/50 transition-colors text-left gap-2",children:[(0,P.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,P.jsx)(M,{flags:e.flags}),(0,P.jsxs)("div",{className:"min-w-0",children:[(0,P.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,P.jsx)("span",{className:"block text-sm text-text-muted truncate",children:s}),(0,P.jsx)(z.A,{seededAt:H,email:e.member.user.email})]}),e.member.user.displayName&&(0,P.jsx)("span",{className:`block truncate ${I.u0.meta}`,children:e.member.user.email})]})]}),(0,P.jsx)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 min-w-0 max-w-full",children:(0,P.jsx)(F,{member:e.member,flags:e.flags,daysInactive:e.daysInactive})})]}),(0,P.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[A&&(0,P.jsx)("button",{type:"button",onClick:s=>{s.stopPropagation(),G(e.member.userId)},"aria-label":B("Create individual assignment for {{name}}",{name:s}),title:B("Create individual assignment"),className:"flex-shrink-0 flex items-center justify-center w-10 h-10 rounded-full text-text-muted hover:text-text hover:bg-surface-sunken transition-colors",children:(0,P.jsx)(p.A,{size:16})}),f&&(0,P.jsx)(S.Ay,{guardians:f.get(e.member.userId)||[],studentName:s,onEditGuardians:v?
47()=>v(e.member.userId):void 0,orgId:t,studentUserId:e.member.userId,examTypeId:g}),L&&(0,P.jsx)(C.A,{riskDismissals:L,entry:e,studentName:s,source:j?"class_card":"dashboard_card",canDismiss:A})]})]},e.member.userId)})})]}),A&&Z&&(0,P.jsx)(D.A,{isOpen:!0,onClose:()=>G(null),orgId:t,orgSlug:l,preselectedIds:[Z],autoConfirm:!0})]})};t.d(s,["Ay",0,O,"D2",0,_,"N1",0,F,"_I",0,M])},57398(e,s,t){t.d(s,["Af",0,"text-xs font-medium text-text-muted whitespace-nowrap","UE",0,"inline-flex items-center gap-1.5 rounded-full bg-surface-sunken ring-1 ring-border-subtle px-2.5 py-1","y5",0,"w-1.5 h-1.5 rounded-full flex-shrink-0"])},22910(e,s,t){t.d(s,{p:()=>x});var n=t(58878),a=t(65852),r=t(1060),i=t(589),l=t(4368),o=t(98639),d=t(72097),c=t(27242);const u=(e,s)=>`${e}\0${s}`;class m extends Error{constructor(e,s){super("Some at-risk dismissal writes failed"),this.committed=e,this.firstError=s}}function x(e){var s,t,x;let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{data:g,error:h,refetch:f}=(0,r.IT)(i.i1H,{...(0,o.X)("volatile"),variables:{orgId:e},skip:!e||!!p.skip}),v=null===g||void 0===g||null===(s=g.getOrgAtRiskState)||void 0===s?void 0:s.dismissals,j=null!==(t=null===g||void 0===g||null===(x=g.getOrgAtRiskState)||void 0===x?void 0:x.config)&&void 0!==t?t:void 0,b=(0,n.useMemo)(()=>{const e=new Map;for(const s of null!==v&&void 0!==v?v:[]){const t=e.get(s.studentUserId);t?t.push(s):e.set(s.studentUserId,[s])}return e},[v]),N=(0,n.useCallback)(e=>b.get(e.userId),[b]),[y,w]=(0,n.useState)(()=>new Map),k=(0,n.useMemo)(()=>new Set(y.keys()),[y]),[I]=(0,a.n)(i.DMY),[A]=(0,a.n)(i.BX_),[S]=(0,a.n)(i.CQw),[C]=(0,a.n)(i.ZoQ),E=(0,n.useCallback)(async(s,t,n,a,r)=>{if(!e||0===t.length||0===s.length)return"failed";let i,l;w(e=>{const t=new Map(e);for(const a of s){var n;t.set(a,(null!==(n=t.get(a))&&void 0!==n?n:0)+1)}return t});try{await n(),a(t),i="ok"}catch(u){const e=u instanceof m?u.firstError:u;u instanceof m&&a(u.committed),i=(0,c.CT)(e)?"blocked":"failed"}try{var o,d;const e=await(null===f||void 0===f?void 0:f());l=null===e||void 0===e||null===(o=e.data)||void 0===o||null===(d=o.getOrgAtRiskState)||void 0===d?void 0:d.dismissals}catch{}finally{w(e=>{const t=new Map(e);for(const a of s){var n;const e=(null!==(n=t.get(a))&&void 0!==n?n:1)-1;e>0?t.set(a,e):t.delete(a)}return t})}return null===r||void 0===r||r(l),i},[e,f]),$=(0,n.useCallback)((s,t,n,a)=>E([s],t,()=>I({variables:{orgId:e,studentUserId:s,reasons:t,evidence:(0,l.hC)(a)}}),()=>
47d.zS.orgRiskDismissed({orgId:e,reason:t.join(","),source:n})),[E,I,e]),D=(0,n.useCallback)((s,t,n)=>{const a=Array.isArray(t)?t:[t];return E([s],a,async()=>{const t=await Promise.allSettled(a.map(t=>A({variables:{orgId:e,studentUserId:s,reason:t}}))),n=[];let r,i=!1;if(t.forEach((e,s)=>{"fulfilled"===e.status?n.push(a[s]):i||(i=!0,r=e.reason)}),i){if(n.length>0)throw new m(n,r);throw r}},s=>d.zS.orgRiskDismissalUndone({orgId:e,reason:s.join(","),source:n}))},[E,A,e]),z=(0,n.useCallback)(async function(s,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3?arguments[3]:void 0;const r=new Map;for(const e of s){var i;const s=null!==(i=r.get(e.studentUserId))&&void 0!==i?i:{studentUserId:e.studentUserId,reasons:[]};for(const t of e.reasons)s.reasons.includes(t)||s.reasons.push(t);void 0===s.evidence&&void 0!==e.evidence&&(s.evidence=e.evidence),r.set(e.studentUserId,s)}const l=Array.from(r.values()),o=Array.from(r.keys()),c=Array.from(new Set(l.flatMap(e=>e.reasons))),x=[],p=[],g=Date.now();let h=-1,f=!1,v=await E(o,c,async()=>{for(let n=0;n<l.length;n+=500){const a=l.slice(n,n+500);try{const{data:t}=await S({variables:{orgId:e,items:a.map(e=>void 0===e.evidence?{studentUserId:e.studentUserId,reasons:e.reasons}:{studentUserId:e.studentUserId,reasons:e.reasons,evidence:e.evidence})}});for(const e of null!==(s=null===t||void 0===t?void 0:t.dismissRiskFlagsBulk)&&void 0!==s?s:[]){var s;x.push({studentUserId:e.studentUserId,reason:e.reason})}}catch(t){h=n;for(const e of a)for(const s of e.reasons)p.push({studentUserId:e.studentUserId,reason:s});if(x.length>0)throw new m([],t);throw t}}},()=>{},e=>{if(h<0||!e||!a)return;const s=new Set;for(const n of e)n.dismissedById===a&&(Date.parse(n.dismissedAt)<g-6e4||s.add(u(n.studentUserId,n.reason)));let t=0;for(const n of p)s.has(u(n.studentUserId,n.reason))&&(x.push(n),t+=1);f=p.length>0&&t===p.length});const j=500*Math.floor((l.length-1)/500);return"failed"===v&&h===j&&f&&(v="ok"),x.length>0&&d.zS.orgRiskBulkDismissed({orgId:e,studentCount:new Set(x.map(e=>e.studentUserId)).size,alertCount:x.length,reasonFilter:n,source:t}),{outcome:v,dismissed:x}},[E,S,e]),R=(0,n.useCallback)(async function(s,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const a=Array.from(new Set(s.map(e=>e.studentUserId))),r=Array.from(new Set(s.map(e=>e.reason))),i=[];let l=[];const o=await E(a,r,async()=>{for(let n=0;n<s.length;n+=3e3){const a=s.slice(n,n+3e3);try{await C({variables:{orgId:e,items:a.map(e=>({studentUserId:e.studentUserId,reason:e.reason}))}})}catch(t){if(l=s.slice(n),i.length>0)throw new m([],t);throw t}for(const e of a)i.push(e)}},()=>{0!==i.length&&d.zS.orgRiskBulkDismissalUndone({orgId:e,studentCount:new Set(i.map(e=>e.studentUserId)).size,alertCount:i.length,reasonFilter:n,source:t})},e=>{if(0===l.length||!e)return;const s=new Set(e.map(e=>u(e.studentUserId,e.reason)));l=l.filter(e=>s.has(u(e.studentUserId,e.reason)))});return{outcome:o,remaining:"ok"===o?[]:l}},[E,C,e]);return{dismissalsByStudent:b,getDismissals:N,config:j,settled:!!e&&void 0!==v,readFailed:!!e&&void 0===v&&!!h,pendingUserIds:k,dismiss:$,undo:D,dismissMany:z,undoMany:R}}},84390(e,s,t){function n(e,s){switch(s){case"score_regression":return e("Score drop");case"overdue":return e("Overdue");case"failing_assignments":return e("Failing assignments");case"rushing":return e("Rushing");case"inactive":return e("Inactive");case"low_accuracy":return e("Low accuracy")}}t.d(s,{y:()=>n})}}]);
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.