1import{a2 as Qs,r as t,j as e,F as v,G as N,H as M,a1 as E,B as r,I as _,V as Pe,W as Ee,Z as P,_ as x,$ as Fe,a0 as h,aa as V,ab as G,ac as H,ad as B,aB as Q,ae as K,x as g,aV as Nt,a4 as _t,a5 as St,aS as wt,aW as Ct,L as Be,P as Dt,a3 as Ce,S as Pt,aM as qs,aN as Is,aO as Ls,aP as De,ai as Qe,aQ as Et,aX as Ft,aY as At,aZ as zt,y as O,z as p,aR as Rt}from"./index-CB3JrMnV.js";import{u as Ke}from"./useShowMore-Cl0V-l11.js";import{u as z}from"./index.esm-Dq4Ylxhf.js";import{a as R}from"./zod-zhjUfW1X.js";import{d as kt,e as Tt,u as Mt}from"./students-DvyFtsNT.js";import{u as Ot,a as qt,b as It,c as Lt,d as Ut,e as $t,f as Vt,g as Gt,h as Ht,i as Bt}from"./finance-BbxDK_t7.js";import{u as Qt,a as Kt,b as Jt,c as Yt,d as Wt}from"./freezeRequests-BoKPFrUk.js";import{u as Zt,a as Xt}from"./groups-DllCu0uL.js";import{S as Je,a as Ye,b as We,c as Ze,d as Xe}from"./sheet-D-dEps2U.js";import{S as Ae,a as ze,b as Re,c as ke,d as b}from"./select-D6nAVWYa.js";import{I as m}from"./input-Dx30y2II.js";import{T as _s}from"./textarea-OY3vvyZ4.js";import{F as k,a as i,b as d,c,d as o,e as Ss,f as u}from"./form-DiweD_TG.js";import{u as en,a as sn,b as tn,c as nn,F as Us,d as an}from"./studentDocuments-B1Nnf2zK.js";import{L as es}from"./label-t-RpKNtz.js";import{S as rn}from"./switch-BppRV4Yz.js";import{A as ln,a as dn,b as cn,c as on,d as un,e as mn,f as xn,g as hn}from"./alert-dialog-We_8BGEf.js";import{E as Te}from"./EmptyState-BL7aSSfW.js";import{P as ws}from"./plus-Bx0zVV28.js";import{L as y}from"./loader-circle-CX2V6PgY.js";import{D as jn}from"./download-DoEFVgAR.js";import{T as pn}from"./trash-2-dbLVetBZ.js";import{U as fn}from"./upload-B1Zv5xoP.js";import{F as $s,a as gn,P as yn}from"./presentation-CQs71Fv7.js";import{F as bn}from"./file-spreadsheet-BsccEjLu.js";import{T as Vs}from"./TableSkeleton-D7NiuVdZ.js";import{P as ss}from"./pencil-8BG3JrnF.js";import{P as vn}from"./phone-CLhnEGj4.js";import{A as Gs}from"./arrow-right-left-CkCIRbRW.js";import{E as Nn}from"./ellipsis-d1sTe-0T.js";import{H as Hs}from"./history-CNHHrSuB.js";import{n as ts}from"./coerce-Bq9eyy9z.js";import"./index-XUAbXOOE.js";const _n=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Sn=Qs("circle-minus",_n);const wn=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Cn=Qs("undo-2",wn),Bs={contract:"Contract",id:"ID",agreement:"Agreement",other:"Other"},Dn=["contract","id","agreement","other"];function Pn(l){switch(l){case"pdf":return e.jsx(Nt,{className:"h-5 w-5 text-red-500"});case"doc":return e.jsx($s,{className:"h-5 w-5 text-blue-500"});case"spreadsheet":return e.jsx(bn,{className:"h-5 w-5 text-green-600"});case"presentation":return e.jsx(yn,{className:"h-5 w-5 text-orange-500"});case"image":return e.jsx(gn,{className:"h-5 w-5 text-teal-500"});default:return e.jsx($s,{className:"h-5 w-5 text-muted-foreground"})}}function En({studentId:l}){const{data:f,isLoading:S}=en(l),a=sn(l),Me=tn(l),fe=nn(l),F=t.useRef(null),[ge,J]=t.useState(!1),[Y,Oe]=t.useState(null),[A,W]=t.useState(""),[le,ie]=t.useState("contract"),[de,ce]=t.useState(!1),[oe,ue]=t.useState(null),[q,Z]=t.useState(null),I=f??[];function me(){Oe(null),W(""),ie("contract"),ce(!1),F.current&&(F.current.value="")}async function ye(){if(!Y){g.error("Please choose a file to upload");return}try{await a.mutateAsync({file:Y,title:A.trim()||void 0,category:le,visibility:de?"student_visible":"admin_only"}),g.success("Document uploaded"),J(!1),me()}catch{}}async function xe(n){ue(n.id);try{await an(l,n.id,n.file_name)}catch{g.error("Failed to download document")}finally{ue(null)}}async function he(n){const w=n.visibility==="student_visible"?"admin_only":"student_visible";try{await Me.mutateAsync({documentId:n.id,visibility:w}),g.success(w==="student_visible"?"Document is now visible to the student":"Document is now admin-only")}catch{}}async function qe(){if(q)try{await fe.mutateAsync(q.id),g.success("Document deleted"),Z(null)}catch{}}return e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(M,{className:"text-base",children:"Documents"}),I.length>0&&e.jsx(E,{variant:"secondary",className:"text-xs",children:I.length})]}),e.jsxs(r,{size:"sm",onClick:()=>J(!0),children:[e.jsx(ws,{className:"mr-1.5 h-3.5 w-3.5"}),"Upload"]})]}),e.jsx(_,{children:S?e.jsx("div",{className:"space-y-2",children:[1,2].map(n=>e.jsx("div",{className:"h-12 animate-pulse rounded bg-muted"},n))}):I.length===0?e.jsx(Te,{icon:Us,title:"No documents",description:"Upload contracts, IDs, or agreements for this student."}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border/60",children:e.jsxs(Pe,{children:[e.jsx(Ee,{children:e.jsxs(P,{children:[e.jsx(x,{children:"Name"}),e.jsx(x,{children:"Category"}),e.jsx(x,{children:"Visibility"}),e.jsx(x,{children:"Size"}),e.jsx(x,{children:"Uploaded By"}),e.jsx(x,{children:"Date"}),e.jsx(x,{className:"w-[110px]"})]})}),e.jsx(Fe,{children:I.map(n=>e.jsxs(P,{children:[e.jsx(h,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-shrink-0",children:Pn(n.file_type)}),e.jsx("span",{className:"truncate max-w-[220px]",title:n.title,children:n.title})]})}),e.jsx(h,{children:e.jsx(E,{variant:"outline",className:"text-xs",children:Bs[n.category]??n.category})}),e.jsx(h,{children:e.jsx("button",{type:"button",onClick:()=>he(n),title:"Click to toggle visibility",disabled:Me.isPending,children:n.visibility==="student_visible"?e.jsx(E,{className:"cursor-pointer bg-emerald-100 text-emerald-700 hover:bg-emerald-200 text-xs",children:"Student visible"}):e.jsx(E,{variant:"secondary",className:"cursor-pointer text-xs",children:"Admin only"})})}),e.jsx(h,{className:"text-muted-foreground text-[13px]",children:n.formatted_file_size}),e.jsx(h,{className:"text-muted-foreground text-[13px]",children:n.uploaded_by?.full_name??"-"}),e.jsx(h,{className:"text-muted-foreground text-[13px]",children:new Date(n.created_at).toLocaleDateString()}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(r,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>xe(n),disabled:oe===n.id,children:[oe===n.id?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(jn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Download"})]}),e.jsxs(r,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Z(n),children:[e.jsx(pn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Delete"})]})]})})]},n.id))})]})})}),e.jsx(V,{open:ge,onOpenChange:n=>{J(n),n||me()}
1,children:e.jsxs(G,{children:[e.jsxs(H,{children:[e.jsx(B,{children:"Upload Document"}),e.jsx(Q,{children:"Attach a contract, ID, or agreement. Max 10 MB. Admin-only by default."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(es,{htmlFor:"doc-file",children:"File"}),e.jsx(m,{id:"doc-file",ref:F,type:"file",accept:".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.jpg,.jpeg,.png,.webp,.txt,.csv",onChange:n=>{const w=n.target.files?.[0]??null;Oe(w),w&&!A.trim()&&W(w.name.replace(/\.[^.]+$/,""))}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(es,{htmlFor:"doc-title",children:"Title"}),e.jsx(m,{id:"doc-title",value:A,onChange:n=>W(n.target.value),placeholder:"e.g., Signed enrollment contract"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(es,{children:"Category"}),e.jsxs(Ae,{value:le,onValueChange:n=>ie(n),children:[e.jsx(ze,{className:"w-full",children:e.jsx(Re,{})}),e.jsx(ke,{children:Dn.map(n=>e.jsx(b,{value:n,children:Bs[n]},n))})]})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(es,{htmlFor:"doc-visible",children:"Visible to student"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If off, only staff can see and download this file."})]}),e.jsx(rn,{id:"doc-visible",checked:de,onCheckedChange:ce})]})]}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>J(!1),children:"Cancel"}),e.jsxs(r,{onClick:ye,disabled:a.isPending||!Y,children:[a.isPending?e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(fn,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]})}),e.jsx(ln,{open:!!q,onOpenChange:n=>!n&&Z(null),children:e.jsxs(dn,{children:[e.jsxs(cn,{children:[e.jsx(on,{children:"Delete document?"}),e.jsxs(un,{children:["This will permanently delete â",q?.title,"â. This action cannot be undone."]})]}),e.jsxs(mn,{children:[e.jsx(xn,{children:"Cancel"}),e.jsxs(hn,{onClick:qe,disabled:fe.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[fe.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete"]})]})]})})]})}const Fn=O({first_name:p().min(1,"First name is required"),last_name:p().min(1,"Last name is required"),phone:p().optional(),status:Rt(["active","inactive","suspended","exited"]),notes:p().optional()}),An=O({reason:p().min(1,"Reason is required"),start_date:p().min(1,"Start date is required"),end_date:p().min(1,"End date is required")}),zn=O({reason:p().min(1,"Reason is required"),last_lesson_date:p().min(1,"Last lesson date is required")}),Rn=O({new_group_id:p().min(1,"Please select a group"),last_lesson_date:p().min(1,"Last lesson date is required"),first_lesson_date:p().min(1,"First lesson date is required")}),kn=O({amount:ts().positive("Amount must be positive"),reference_link:p().optional(),description:p().optional(),effective_date:p().optional()}),Tn=O({amount:ts().refine(l=>l!==0,"Amount cannot be zero"),description:p().min(1,"Description is required"),effective_date:p().optional()}),Mn=O({discount_type:p().optional(),discount_value:ts().min(0).optional(),discount_reason:p().optional(),notes:p().optional()}),On=O({reason:p().min(1,"Reason is required"),start_date:p().min(1,"Start date is required"),end_date:p().min(1,"End date is required")}),qn=O({amount:ts().min(0,"Amount must be non-negative"),due_date:p().min(1,"Due date is required"),status:p().min(1,"Status is required")});function In(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"h-5 w-48 animate-pulse rounded bg-muted"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"h-7 w-56 animate-pulse rounded bg-muted"})}),e.jsx("div",{className:"h-6 w-16 animate-pulse rounded-full bg-muted"})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-3",children:Array.from({length:3}).map((l,f)=>e.jsxs(v,{children:[e.jsx(N,{children:e.jsx("div",{className:"h-5 w-40 animate-pulse rounded bg-muted"})}),e.jsx(_,{className:"space-y-3",children:Array.from({length:4}).map((S,a)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"h-4 w-28 animate-pulse rounded bg-muted"})]},a))})]},f))}),e.jsxs(v,{children:[e.jsx(N,{children:e.jsx("div",{className:"h-5 w-32 animate-pulse rounded bg-muted"})}),e.jsx(_,{children:e.jsx("div",{className:"rounded-lg border border-border/60",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",children:Array.from({length:5}).map((l,f)=>e.jsx("th",{className:"px-4 py-3",children:e.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-muted"})},f))})}),e.jsx("tbody",{children:e.jsx(Vs,{columns:5,rows:3})})]})})})]}),e.jsxs(v,{children:[e.jsx(N,{children:e.jsx("div",{className:"h-5 w-36 animate-pulse rounded bg-muted"})}),e.jsx(_,{children:e.jsx("div",{className:"rounded-lg border border-border/60",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",children:Array.from({length:3}).map((l,f)=>e.jsx("th",{className:"px-4 py-3",children:e.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-muted"})},f))})}),e.jsx("tbody",{children:e.jsx(Vs,{columns:3,rows:3})})]})})})]})]})}function ya(){const{id:l}=_t(),f=St(),{symbol:S}
1=wt(),{data:a,isLoading:Me,isError:fe}=kt(l),{data:F}=Ot(l),{data:ge}=qt(l),{data:J}=It({student_id:Number(l)}),{data:Y}=Qt(),{data:Oe}=Zt({per_page:100}),{data:A}=Tt(l),W=Lt(),le=Mt(),ie=Kt(),de=Ct(),ce=Ut(),oe=$t(),ue=Jt(),q=Yt(),Z=Xt(),I=Wt(),me=Vt(),ye=Gt(),xe=Ht(),he=Bt(),qe=t.useMemo(()=>[...J?.data??[]].sort((s,j)=>j.id-s.id),[J]),n=Ke(qe),w=Ke(t.useMemo(()=>[...A??[]].sort((s,j)=>j.id-s.id),[A])),ns=Ke(t.useMemo(()=>[...a?.enrollments??[]].sort((s,j)=>j.id-s.id),[a])),as=Ke(t.useMemo(()=>(Y?.data??[]).filter(s=>s.student_id===Number(l)).sort((s,j)=>j.id-s.id),[Y,l])),[rs,Ie]=t.useState(!1),[Cs,Ks]=t.useState(null),[Ds,Js]=t.useState(null),[ls,is]=t.useState(!1),[ds,be]=t.useState(!1),[Ps,Es]=t.useState(null),[cs,Le]=t.useState(!1),[Fs,Ys]=t.useState(null),[Ws,Zs]=t.useState(null),[As,Xs]=t.useState(null),[os,us]=t.useState(!1),[ms,xs]=t.useState(!1),[hs,js]=t.useState(!1),[C,et]=t.useState(null),[ps,Ue]=t.useState(!1),[X,st]=t.useState(null),[fs,$e]=t.useState(!1),[ee,tt]=t.useState(null),[je,zs]=t.useState("all"),[ve,Ve]=t.useState(null),[Rs,Ne]=t.useState(""),[_e,Ge]=t.useState(null),[ks,Se]=t.useState(""),[Ts,we]=t.useState(""),D=z({resolver:R(Fn),defaultValues:{first_name:"",last_name:"",phone:"",status:"active",notes:""}}),se=z({resolver:R(An),defaultValues:{reason:"",start_date:"",end_date:""}}),pe=z({resolver:R(zn),defaultValues:{reason:"",last_lesson_date:new Date().toISOString().split("T")[0]}}),te=z({resolver:R(Rn),defaultValues:{new_group_id:"",last_lesson_date:new Date().toISOString().split("T")[0],first_lesson_date:new Date().toISOString().split("T")[0]}}),L=z({resolver:R(kn),defaultValues:{amount:0,reference_link:"",description:"",effective_date:new Date().toISOString().split("T")[0]}}),ne=z({resolver:R(Tn),defaultValues:{amount:0,description:"",effective_date:""}}),U=z({resolver:R(Mn),defaultValues:{discount_type:"",discount_value:0,discount_reason:"",notes:""}}),ae=z({resolver:R(On),defaultValues:{reason:"",start_date:"",end_date:""}}),re=z({resolver:R(qn),defaultValues:{amount:0,due_date:"",status:""}});if(t.useEffect(()=>{ls&&a&&D.reset({first_name:a.first_name,last_name:a.last_name,phone:a.phone??"",status:a.status,notes:a.notes??""})},[ls,a,D]),t.useEffect(()=>{ds&&se.reset({reason:"",start_date:"",end_date:""})},[ds,se]),t.useEffect(()=>{rs&&pe.reset({reason:"",last_lesson_date:new Date().toISOString().split("T")[0]})},[rs,pe]),t.useEffect(()=>{cs&&te.reset({new_group_id:"",last_lesson_date:new Date().toISOString().split("T")[0],first_lesson_date:new Date().toISOString().split("T")[0]})},[cs,te]),t.useEffect(()=>{os&&L.reset({amount:0,reference_link:"",description:"",effective_date:new Date().toISOString().split("T")[0]})},[os,L]),t.useEffect(()=>{ms&&ne.reset({amount:0,description:"",effective_date:""})},[ms,ne]),t.useEffect(()=>{hs&&C&&U.reset({discount_type:C.discount_type??"",discount_value:C.discount_value?parseFloat(C.discount_value):0,discount_reason:C.discount_reason??"",notes:C.notes??""})},[hs,C,U]),t.useEffect(()=>{ps&&X&&ae.reset({reason:X.reason,start_date:X.start_date,end_date:X.end_date})},[ps,X,ae]),t.useEffect(()=>{fs&&ee&&re.reset({amount:parseFloat(ee.amount),due_date:ee.due_date,status:ee.status})},[fs,ee,re]),Me)return e.jsx(In,{});if(fe||!a)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Student not found."}),e.jsx(r,{variant:"outline",asChild:!0,children:e.jsx(Be,{to:"/students",children:"Back to Students"})})]});const nt=a.enrollments?.length??0,gs=(ge??[]).filter(s=>s.status!=="cancelled"),ys=gs.length,He=gs.reduce((s,j)=>{const $=String(j.enrollment_id);return s[$]||(s[$]={groupName:j.group_name||`Enrollment #${j.enrollment_id}`,enrollmentId:j.enrollment_id,items:[]}),s[$].items.push(j),s},{}),Ms=Object.keys(He),bs=Ms.length>1,at=je==="all"?gs:He[je]?.items??[],vs=qe,Ns=(Y?.data??[]).filter(s=>s.student_id===Number(l)),rt=Oe?.data??[],lt=async s=>{if(Cs)try{await W.mutateAsync({enrollmentId:Cs,reason:s.reason,lastLessonDate:s.last_lesson_date}),g.success("Student exit processed"),Ie(!1)}catch{}},it=async s=>{try{await le.mutateAsync({id:a.id,...s}),g.success("Student updated successfully"),is(!1)}catch(j){const Os=j.response?.data?.errors;
1Os&&Object.entries(Os).forEach(([bt,vt])=>{D.setError(bt,{message:vt[0]})})}},dt=async s=>{if(Ps)try{await ie.mutateAsync({enrollment_id:Ps,reason:s.reason,start_date:s.start_date,end_date:s.end_date}),g.success("Freeze request created"),be(!1)}catch{}},ct=async s=>{if(Fs)try{await de.mutateAsync({enrollment_id:Fs,new_group_id:Number(s.new_group_id),last_lesson_date:s.last_lesson_date,first_lesson_date:s.first_lesson_date}),g.success("Student transferred successfully"),Le(!1)}catch{}},ot=async s=>{try{await ce.mutateAsync({student_id:Number(l),amount:s.amount,reference_link:s.reference_link||void 0,description:s.description||void 0,effective_date:s.effective_date||void 0}),f.invalidateQueries({queryKey:["student-balance",l]}),f.invalidateQueries({queryKey:["payment-schedule",l]}),g.success("Payment recorded successfully"),us(!1)}catch{}},ut=async s=>{try{await oe.mutateAsync({student_id:Number(l),amount:s.amount,description:s.description,effective_date:s.effective_date||void 0}),f.invalidateQueries({queryKey:["student-balance",l]}),f.invalidateQueries({queryKey:["payment-schedule",l]}),g.success("Adjustment recorded successfully"),xs(!1)}catch{}},mt=async s=>{try{await ue.mutateAsync(s),g.success("Freeze request approved")}catch{}},xt=async s=>{try{await q.mutateAsync({id:s}),g.success("Freeze request rejected")}catch{}},ht=async s=>{if(C)try{const j=!s.discount_type||s.discount_type==="none",{repriced:$}=await Z.mutateAsync({groupId:C.group_id,enrollmentId:C.id,discount_type:j?null:s.discount_type,discount_value:j?null:s.discount_value??void 0,discount_reason:j?null:s.discount_reason||void 0,notes:s.notes||void 0});f.invalidateQueries({queryKey:["students",l]}),g.success("Enrollment updated",{description:$>0?`${$} upcoming payment${$===1?"":"s"} re-priced. Invoices already sent are unchanged.`:void 0}),js(!1)}catch{}},jt=async s=>{if(X)try{await I.mutateAsync({id:X.id,reason:s.reason,start_date:s.start_date,end_date:s.end_date}),g.success("Freeze request updated successfully"),Ue(!1)}catch{}},pt=async s=>{if(ee)try{await me.mutateAsync({id:ee.id,amount:s.amount,due_date:s.due_date,status:s.status}),f.invalidateQueries({queryKey:["students",l]}),g.success("Payment schedule updated successfully"),$e(!1)}catch{}},ft=async s=>{try{await ye.mutateAsync(s),f.invalidateQueries({queryKey:["students",l]}),g.success("Invoice generated successfully")}catch{}},gt=async()=>{if(ve?.ameria_refund_payment_id)try{const s=await xe.mutateAsync({ameriaPaymentId:ve.ameria_refund_payment_id,reason:Rs.trim()||void 0});f.invalidateQueries({queryKey:["students",l]}),g.success(s.message||"Payment refunded"),Ve(null),Ne("")}catch{}},yt=async()=>{if(_e)try{await he.mutateAsync({id:_e.id,reference_link:Ts.trim()||void 0,effective_date:ks||void 0}),f.invalidateQueries({queryKey:["students",l]}),g.success("Payment recorded"),Ge(null),we(""),Se("")}catch{}};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("nav",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Be,{to:"/students",className:"hover:text-foreground transition-colors",children:"Students"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-foreground font-medium",children:a.full_name})]}),e.jsx(Dt,{title:a.full_name,children:e.jsx(Ce,{status:a.status,label:a.status_label})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-3",children:[e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsx(M,{className:"text-base",children:"Personal Information"}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>is(!0),children:[e.jsx(ss,{className:"mr-1 h-3.5 w-3.5"}),"Edit"]})]}),e.jsxs(_,{className:"space-y-3",children:[e.jsx(T,{label:"First Name",value:a.first_name}),e.jsx(T,{label:"Last Name",value:a.last_name}),e.jsx(T,{label:"Email",value:a.email}),e.jsx(T,{label:"Phone",value:a.phone??"-"}),a.notes&&e.jsx(T,{label:"Notes",value:a.notes})]})]}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsx(N,{children:e.jsx(M,{className:"text-base",children:"Account Details"})}),e.jsxs(_,{className:"space-y-3",children:[e.jsx(T,{label:"Status",value:e.jsx(Ce,{status:a.status,label:a.status_label})}),e.jsx(T,{label:"Referral Code",value:a.referral_code?e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:a.referral_code}):"-"}),e.jsx(T,{label:"Referred By",value:a.referrer?.full_name??"-"}),e.jsx(T,{label:"Created",value:new Date(a.created_at).toLocaleDateString()})]})]}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsx(M,{className:"text-base",children:"Balance"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(r,{size:"sm",onClick:()=>us(!0),children:[e.jsx(ws,{className:"mr-1 h-3.5 w-3.5"}),"Record Payment"]}),e.jsxs(r,{variant:"secondary",size:"sm",onClick:()=>xs(!0),children:[e.jsx(Sn,{className:"mr-1 h-3.5 w-3.5"}),"Adjustment"]})]})]}),e.jsx(_,{children:F?e.jsxs("div",{className:"flex flex-col items-center py-4",children:[e.jsx("div",{className:`flex h-24 w-24 items-center justify-center rounded-full ring-4 ${F.balance>=0?"ring-emerald-200 bg-emerald-50":"ring-red-200 bg-red-50"}`,children:e.jsxs("p",{className:`text-2xl font-bold ${F.balance>=0?"text-emerald-700":"text-red-700"}`,children:[S,Math.round(Math.abs(Number(F.balance))).toLocaleStr
1ing()]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3",children:F.balance>=0?"Credit":"Debt"})]}):e.jsxs("div",{className:"flex flex-col items-center py-4",children:[e.jsx("div",{className:"h-24 w-24 animate-pulse rounded-full bg-muted"}),e.jsx("div",{className:"mt-3 h-4 w-12 animate-pulse rounded bg-muted"})]})})]})]}),A&&A.length>0&&e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(M,{className:"text-base",children:"Phone Number History"}),e.jsx(E,{variant:"secondary",className:"text-xs",children:A.length})]})}),e.jsxs(_,{children:[e.jsx("ul",{className:"divide-y divide-border/60",children:w.visible.map(s=>e.jsxs("li",{className:"flex flex-col gap-1 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium text-muted-foreground line-through",children:s.old_value||"â"}),e.jsx(Gs,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:s.new_value||"â"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.changed_by?`by ${s.changed_by}`:"by system",s.source?` · ${s.source.replace(/_/g," ")}`:"",s.created_at?` · ${new Date(s.created_at).toLocaleString()}`:""]})]},s.id))}),w.hasMore&&e.jsx(r,{variant:"ghost",size:"sm",className:"mt-2 w-full text-muted-foreground",onClick:w.showMore,children:"Show more"})]})]}),e.jsx(En,{studentId:l}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsx(N,{className:"flex-row items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-base",children:"Enrollments"}),e.jsx(E,{variant:"secondary",className:"text-xs",children:nt})]})}),e.jsx(_,{children:!a.enrollments||a.enrollments.length===0?e.jsx(Te,{icon:Pt,title:"No enrollments yet",description:"This student has not been enrolled in any groups."}):e.jsxs("div",{className:"rounded-lg border border-border/60",children:[e.jsxs(Pe,{children:[e.jsx(Ee,{children:e.jsxs(P,{children:[e.jsx(x,{children:"Group"}),e.jsx(x,{children:"Status"}),e.jsx(x,{children:"Effective Price"}),e.jsx(x,{children:"Discount"}),e.jsx(x,{children:"Notes"}),e.jsx(x,{children:"Joined At"}),e.jsx(x,{className:"w-[50px]"})]})}),e.jsx(Fe,{children:ns.visible.map(s=>e.jsxs(P,{children:[e.jsx(h,{className:"font-medium",children:e.jsx(Be,{to:`/groups/${s.group_id}`,className:"text-primary hover:underline",children:s.group?.name??`Group #${s.group_id}`})}),e.jsx(h,{children:e.jsx(Ce,{status:s.status,label:s.status_label})}),e.jsxs(h,{children:[S,Math.round(Number(s.effective_price)).toLocaleString()]}),e.jsx(h,{className:"text-muted-foreground text-[13px]",children:s.discount_type&&s.discount_value?s.discount_type==="percentage"?`${parseFloat(s.discount_value)}%${s.discount_reason?` - ${s.discount_reason}`:""}`:`flat ${S}${Math.round(Number(s.discount_value)).toLocaleString()}${s.discount_reason?` - ${s.discount_reason}`:""}`:"-"}),e.jsx(h,{className:"text-muted-foreground text-[13px] max-w-[150px] truncate",title:s.notes??"",children:s.notes||"-"}),e.jsx(h,{children:new Date(s.joined_at).toLocaleDateString()}),e.jsx(h,{children:s.status==="active"&&e.jsxs(qs,{children:[e.jsx(Is,{asChild:!0,children:e.jsxs(r,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[e.jsx(Nn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Ls,{align:"end",children:[e.jsxs(De,{onClick:()=>{et(s),js(!0)},children:[e.jsx(ss,{className:"h-4 w-4"}),"Edit Details"]}),e.jsxs(De,{onClick:()=>{Es(s.id),be(!0)},children:[e.jsx(Qe,{className:"h-4 w-4"}),"Freeze Enrollment"]}),e.jsxs(De,{onClick:()=>{Ys(s.id),Zs(s.group_id),Xs(s.joined_at),Le(!0)},children:[e.jsx(Gs,{className:"h-4 w-4"}),"Transfer to Group"]}),e.jsx(Et,{}),e.jsxs(De,{variant:"destructive",onClick:()=>{Ks(s.id),Js(s.joined_at),Ie(!0)},children:[e.jsx(Ft,{className:"h-4 w-4"}),"Exit Enrollment"]})]})]})})]},s.id))})]}),ns.hasMore&&e.jsx("div",{className:"border-t border-border/60 p-2",children:e.jsx(r,{variant:"ghost",size:"sm",className:"w-full text-muted-foreground",onClick:ns.showMore,children:"Show more"})})]})})]}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsx(N,{className:"flex-row items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-base",children:"Payment Schedule"}),ys>0&&e.jsx(E,{variant:"secondary",className:"text-xs",children:ys})]})}),e.jsx(_,{children:!ge||ge.length===0?e.jsx(Te,{title:"No payment schedule",description:"No payment schedule entries found for this student."}):e.jsxs(e.Fragment,{children:[bs&&e.jsxs("div",{className:"flex gap-1 mb-4 flex-wrap",children:[e.jsxs(r,{variant:je==="all"?"default":"outline",size:"sm",onClick:()=>zs("all"),children:["All (",ys,")"]}),Ms.map(s=>e.jsxs(r,{variant:je===s?"default":"outline",size:"sm",onClick:()=>zs(s),children:[He[s].groupName," (",He[s].items.length,")"]},s))]}),e.jsx("div",{className:"rounded-lg border border-border/60",children:e.jsxs(Pe,{children:[e.jsx(Ee,{children:e.jsxs(P,{children:[e.jsx(x,{children:"Due Date"}),je==="all"&&bs&&e.jsx(x,{children:"Group"}),e.jsx(x,{children:"Amount"}),e.jsx(x,{children:"Status"}),e.jsx(x,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Fe,{children:at.map(s=>e.jsxs(P,{children:[e.jsx(h,{children:s.due_date}),je==="all"&&bs&&e.jsx(h,{className:"text-muted-foreground text-xs",children:s.group_name||`#${s.enrollment_id}`}),e.jsxs(h,{children:[S,Math.round(Number(s.amount)).toLocaleStr
1ing()]}),e.jsx(h,{children:e.jsx(Ce,{status:s.status,label:s.status_label})}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(r,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{tt(s),$e(!0)},children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Edit"})]}),s.status==="upcoming"&&e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>ft(s.id),disabled:ye.isPending,children:[ye.isPending?e.jsx(y,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(At,{className:"mr-1 h-3 w-3"}),"Invoice"]}),(s.status==="invoiced"||s.status==="overdue")&&e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>{we(""),Se(new Date().toISOString().slice(0,10)),Ge(s)},children:[e.jsx(zt,{className:"mr-1 h-3 w-3"}),"Record Payment"]}),s.status==="paid"&&s.ameria_refund_payment_id&&e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>{Ne(""),Ve(s)},children:[e.jsx(Cn,{className:"mr-1 h-3 w-3"}),"Refund"]})]})})]},s.id))})]})})]})})]}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsx(N,{className:"flex-row items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(M,{className:"text-base",children:"Transactions History"}),vs.length>0&&e.jsx(E,{variant:"secondary",className:"text-xs",children:vs.length})]})}),e.jsx(_,{children:vs.length===0?e.jsx(Te,{icon:Hs,title:"No transactions",description:"No transactions found for this student."}):e.jsxs("div",{className:"rounded-lg border border-border/60",children:[e.jsxs(Pe,{children:[e.jsx(Ee,{children:e.jsxs(P,{children:[e.jsx(x,{children:"Date"}),e.jsx(x,{children:"Type"}),e.jsx(x,{children:"Amount"}),e.jsx(x,{children:"Description"})]})}),e.jsx(Fe,{children:n.visible.map(s=>e.jsxs(P,{children:[e.jsx(h,{children:new Date(s.effective_date).toLocaleDateString()}),e.jsx(h,{children:e.jsx(E,{variant:"outline",className:"text-xs",children:s.type_label})}),e.jsx(h,{children:e.jsxs("span",{className:s.signed_amount>=0?"text-emerald-600 font-medium":"text-red-600 font-medium",children:[s.signed_amount>=0?"+":"",S,Math.round(Math.abs(Number(s.signed_amount))).toLocaleString()]})}),e.jsx(h,{className:"text-muted-foreground text-[13px]",children:s.description??"-"})]},s.id))})]}),n.hasMore&&e.jsx("div",{className:"border-t border-border/60 p-2",children:e.jsx(r,{variant:"ghost",size:"sm",className:"w-full text-muted-foreground",onClick:n.showMore,children:"Show more"})})]})})]}),e.jsxs(v,{className:"rounded-xl border-border/60 shadow-sm",children:[e.jsxs(N,{className:"flex-row items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(M,{className:"text-base",children:"Freeze Requests"}),Ns.length>0&&e.jsx(E,{variant:"secondary",className:"text-xs",children:Ns.length})]}),a.enrollments?.some(s=>s.status==="active")&&e.jsxs(qs,{children:[e.jsx(Is,{asChild:!0,children:e.jsxs(r,{size:"sm",children:[e.jsx(ws,{className:"mr-1.5 h-3.5 w-3.5"}),"New Freeze Request"]})}),e.jsx(Ls,{align:"end",children:a.enrollments.filter(s=>s.status==="active").map(s=>e.jsxs(De,{onClick:()=>{Es(s.id),be(!0)},children:[e.jsx(Qe,{className:"h-4 w-4"}),s.group?.name??`Group #${s.group_id}`]},s.id))})]})]}),e.jsx(_,{children:Ns.length===0?e.jsx(Te,{icon:Qe,title:"No freeze requests",description:"No freeze requests found for this student."}):e.jsxs("div",{className:"rounded-lg border border-border/60",children:[e.jsxs(Pe,{children:[e.jsx(Ee,{children:e.jsxs(P,{children:[e.jsx(x,{children:"Enrollment Group"}),e.jsx(x,{children:"Start Date"}),e.jsx(x,{children:"End Date"}),e.jsx(x,{children:"Status"}),e.jsx(x,{className:"w-[120px]"})]})}),e.jsx(Fe,{children:as.visible.map(s=>e.jsxs(P,{children:[e.jsx(h,{className:"font-medium",children:s.enrollment?e.jsx(Be,{to:`/groups/${s.enrollment.group_id}`,className:"text-primary hover:underline",children:s.enrollment.group?.name??`Group #${s.enrollment.group_id}`}):`Enrollment #${s.enrollment_id}`}),e.jsx(h,{children:s.start_date}),e.jsx(h,{children:s.end_date}),e.jsx(h,{children:e.jsx(Ce,{status:s.status,label:s.status_label})}),e.jsx(h,{children:s.status==="pending"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(r,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{st(s),Ue(!0)},children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Edit"})]}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>mt(s.id),disabled:ue.isPending,children:[ue.isPending&&e.jsx(y,{className:"mr-1 h-3 w-3 animate-spin"}),"Approve"]}),e.jsxs(r,{size:"sm",variant:"ghost",onClick:()=>xt(s.id),disabled:q.isPending,children:[q.isPending&&e.jsx(y,{className:"mr-1 h-3 w-3 animate-spin"}),"Reject"]})]})})]},s.id))})]}),as.hasMore&&e.jsx("div",{className:"border-t border-border/60 p-2",children:e.jsx(r,{variant:"ghost",size:"sm",className:"w-full text-muted-foreground",onClick:as.showMore,children:"Show more"})})]})})]}),e.jsx(V,{open:rs,onOpenChange:Ie,children:e.jsxs(G,{children:[e.jsxs(H,{
1children:[e.jsx(B,{children:"Process Student Exit"}),e.jsx(Q,{children:"This will cancel payment schedules after the last lesson date and mark the enrollment as dropped."})]}),e.jsx(k,{...pe,children:e.jsxs("form",{onSubmit:pe.handleSubmit(lt),className:"space-y-4 py-2",children:[e.jsx(i,{control:pe.control,name:"last_lesson_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Last lesson date"}),e.jsx(o,{children:e.jsx(m,{type:"date",min:Ds?Ds.slice(0,10):void 0,...s})}),e.jsx(Ss,{children:"Credit for unused sessions is calculated as of this date. Past dates are allowed."}),e.jsx(u,{})]})}),e.jsx(i,{control:pe.control,name:"reason",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Reason for exit"}),e.jsx(o,{children:e.jsx(m,{placeholder:"e.g., Personal reasons, moving abroad...",...s})}),e.jsx(u,{})]})}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>Ie(!1),children:"Cancel"}),e.jsxs(r,{variant:"destructive",type:"submit",disabled:W.isPending,children:[W.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm Exit"]})]})]})})]})}),e.jsx(Je,{open:ls,onOpenChange:is,children:e.jsxs(Ye,{children:[e.jsxs(We,{children:[e.jsx(Ze,{children:"Edit Student"}),e.jsxs(Xe,{children:["Update personal information for ",a.full_name,"."]})]}),e.jsx(k,{...D,children:e.jsxs("form",{onSubmit:D.handleSubmit(it),className:"space-y-4",children:[e.jsx(i,{control:D.control,name:"first_name",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"First Name"}),e.jsx(o,{children:e.jsx(m,{placeholder:"First name",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:D.control,name:"last_name",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Last Name"}),e.jsx(o,{children:e.jsx(m,{placeholder:"Last name",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:D.control,name:"phone",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Phone"}),e.jsx(o,{children:e.jsx(m,{placeholder:"Phone number",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:D.control,name:"status",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Status"}),e.jsxs(Ae,{value:s.value,onValueChange:s.onChange,children:[e.jsx(o,{children:e.jsx(ze,{children:e.jsx(Re,{placeholder:"Select status"})})}),e.jsxs(ke,{children:[e.jsx(b,{value:"active",children:"Active"}),e.jsx(b,{value:"inactive",children:"Inactive"}),e.jsx(b,{value:"suspended",children:"Suspended"}),e.jsx(b,{value:"exited",children:"Exited"})]})]}),e.jsx(u,{})]})}),e.jsx(i,{control:D.control,name:"notes",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Notes"}),e.jsx(o,{children:e.jsx(_s,{placeholder:"Optional notes...",...s})}),e.jsx(u,{})]})}),e.jsxs(r,{type:"submit",className:"w-full",disabled:le.isPending,children:[le.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]})})]})}),e.jsx(V,{open:ds,onOpenChange:be,children:e.jsxs(G,{children:[e.jsxs(H,{
1children:[e.jsx(B,{children:"Freeze Enrollment"}),e.jsx(Q,{children:"Submit a freeze request for this enrollment. A credit may be applied during the freeze period."})]}),e.jsx(k,{...se,children:e.jsxs("form",{onSubmit:se.handleSubmit(dt),className:"space-y-4 py-2",children:[e.jsx(i,{control:se.control,name:"reason",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Reason"}),e.jsx(o,{children:e.jsx(m,{placeholder:"e.g., Medical leave, travel...",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:se.control,name:"start_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Start Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:se.control,name:"end_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"End Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>be(!1),children:"Cancel"}),e.jsxs(r,{type:"submit",disabled:ie.isPending,children:[ie.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Freeze Request"]})]})]})})]})}),e.jsx(V,{open:cs,onOpenChange:Le,children:e.jsxs(G,{children:[e.jsxs(H,{
1children:[e.jsx(B,{children:"Transfer to Group"}),e.jsx(Q,{children:"Transfer this enrollment to a different group. The student will be moved and pricing may be adjusted."})]}),e.jsx(k,{...te,children:e.jsxs("form",{onSubmit:te.handleSubmit(ct),className:"space-y-4 py-2",children:[e.jsx(i,{control:te.control,name:"new_group_id",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Target Group"}),e.jsxs(Ae,{onValueChange:s.onChange,value:s.value,children:[e.jsx(o,{children:e.jsx(ze,{className:"w-full",children:e.jsx(Re,{placeholder:"Select a group..."})})}),e.jsx(ke,{children:rt.filter(j=>j.id!==Ws).map(j=>e.jsxs(b,{value:String(j.id),children:[j.name,j.course?` (${j.course.title})`:""]},j.id))})]}),e.jsx(u,{})]})}),e.jsx(i,{control:te.control,name:"last_lesson_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Last lesson (current group)"}),e.jsx(o,{children:e.jsx(m,{type:"date",min:As?As.slice(0,10):void 0,...s})}),e.jsx(Ss,{children:"Prorated credit for unused sessions is calculated as of this date. Past dates are allowed."}),e.jsx(u,{})]})}),e.jsx(i,{control:te.control,name:"first_lesson_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"First lesson (target group)"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(Ss,{children:"The new group's payment schedule starts from this date. Past dates are allowed."}),e.jsx(u,{})]})}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>Le(!1),children:"Cancel"}),e.jsxs(r,{type:"submit",disabled:de.isPending,children:[de.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Transfer Student"]})]})]})})]})}),e.jsx(Je,{open:os,onOpenChange:us,children:e.jsxs(Ye,{children:[e.jsxs(We,{children:[e.jsx(Ze,{children:"Record Payment"}),e.jsxs(Xe,{children:["Record a payment for ",a.full_name,"."]})]}),e.jsx(k,{...L,children:e.jsxs("form",{onSubmit:L.handleSubmit(ot),className:"space-y-4",children:[e.jsx(i,{control:L.control,name:"amount",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Amount"}),e.jsx(o,{children:e.jsx(m,{type:"number",min:"0",step:"any",placeholder:"0",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:L.control,name:"reference_link",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Reference Link"}),e.jsx(o,{children:e.jsx(m,{placeholder:"Optional reference URL or ID",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:L.control,name:"description",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Description"}),e.jsx(o,{children:e.jsx(m,{placeholder:"Optional description",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:L.control,name:"effective_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Effective Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsxs(r,{type:"submit",className:"w-full",disabled:ce.isPending,children:[ce.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Record Payment"]})]})})]})}),e.jsx(Je,{open:ms,onOpenChange:xs,children:e.jsxs(Ye,{children:[e.jsxs(We,{children:[e.jsx(Ze,{children:"Record Adjustment"}),e.jsxs(Xe,{children:["Record a balance adjustment for ",a.full_name,". Use negative values for deductions."]})]}),e.jsx(k,{...ne,children:e.jsxs("form",{onSubmit:ne.handleSubmit(ut),className:"space-y-4",children:[e.jsx(i,{control:ne.control,name:"amount",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Amount"}),e.jsx(o,{children:e.jsx(m,{type:"number",step:"any",placeholder:"Can be negative",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:ne.control,name:"description",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Description"}),e.jsx(o,{children:e.jsx(m,{placeholder:"Reason for adjustment",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:ne.control,name:"effective_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Effective Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsxs(r,{type:"submit",className:"w-full",disabled:oe.isPending,children:[oe.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Record Adjustment"]})]})})]})}),e.jsx(Je,{open:hs,onOpenChange:js,children:e.jsxs(Ye,{children:[e.jsxs(We,{children:[e.jsx(Ze,{children:"Edit Enrollment"}),e.jsx(Xe,{children:"Update discount and notes for this enrollment."})]}),e.jsx(k,{...U,children:e.jsxs("form",{onSubmit:U.handleSubmit(ht),className:"space-y-4",children:[e.jsx(i,{control:U.control,name:"discount_type",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Discount Type"}),e.jsxs(Ae,{onValueChange:s.onChange,value:s.value,children:[e.jsx(o,{children:e.jsx(ze,{className:"w-full",children:e.jsx(Re,{placeholder:"Select discount type..."})})}),e.jsxs(ke,{children:[e.jsx(b,{value:"none",children:"None"}),e.jsx(b,{value:"flat",children:"Flat"}),e.jsx(b,{value:"percentage",children:"Percentage"})]})]}),e.jsx(u,{})]})}),e.jsx(i,{control:U.control,name:"discount_value",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Discount Value"}),e.jsx(o,{children:e.jsx(m,{type:"number",min:"0",step:"any",placeholder:"0",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:U.control,name:"discount_reason",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Discount Reason"}),e.jsx(o,{children:e.jsx(m,{placeholder:"e.g., Scholarship, referral...",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:U.control,name:"notes",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Notes"}),e.jsx(o,{children:e.jsx(_s,{placeholder:"Optional notes...",...s})}),e.jsx(u,{})]})}),e.jsxs(r,{type:"submit",className:"w-full",disabled:Z.isPending,children:[Z.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Enrollment Changes"]})]})})]})}),e.jsx(V,{open:ps,onOpenChange:Ue,children:e.jsxs(G,{children:[e.jsxs(H,{
1children:[e.jsx(B,{children:"Edit Freeze Request"}),e.jsx(Q,{children:"Update the dates and reason for this freeze request."})]}),e.jsx(k,{...ae,children:e.jsxs("form",{onSubmit:ae.handleSubmit(jt),className:"space-y-4 py-2",children:[e.jsx(i,{control:ae.control,name:"reason",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Reason"}),e.jsx(o,{children:e.jsx(m,{placeholder:"e.g., Medical leave, travel...",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:ae.control,name:"start_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Start Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:ae.control,name:"end_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"End Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>Ue(!1),children:"Cancel"}),e.jsxs(r,{type:"submit",disabled:I.isPending,children:[I.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]})]})})]})}),e.jsx(V,{open:fs,onOpenChange:$e,children:e.jsxs(G,{children:[e.jsxs(H,{
1children:[e.jsx(B,{children:"Edit Payment Schedule"}),e.jsx(Q,{children:"Update the amount, due date, and status for this payment schedule entry."})]}),e.jsx(k,{...re,children:e.jsxs("form",{onSubmit:re.handleSubmit(pt),className:"space-y-4 py-2",children:[e.jsx(i,{control:re.control,name:"amount",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Amount"}),e.jsx(o,{children:e.jsx(m,{type:"number",min:"0",step:"any",placeholder:"0",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:re.control,name:"due_date",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Due Date"}),e.jsx(o,{children:e.jsx(m,{type:"date",...s})}),e.jsx(u,{})]})}),e.jsx(i,{control:re.control,name:"status",render:({field:s})=>e.jsxs(d,{children:[e.jsx(c,{children:"Status"}),e.jsxs(Ae,{onValueChange:s.onChange,value:s.value,children:[e.jsx(o,{children:e.jsx(ze,{className:"w-full",children:e.jsx(Re,{placeholder:"Select status..."})})}),e.jsxs(ke,{children:[e.jsx(b,{value:"upcoming",children:"Upcoming"}),e.jsx(b,{value:"invoiced",children:"Invoiced"}),e.jsx(b,{value:"paid",children:"Paid"}),e.jsx(b,{value:"overdue",children:"Overdue"}),e.jsx(b,{value:"cancelled",children:"Cancelled"})]})]}),e.jsx(u,{})]})}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",type:"button",onClick:()=>$e(!1),children:"Cancel"}),e.jsxs(r,{type:"submit",disabled:me.isPending,children:[me.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]})]})})]})}),e.jsx(V,{open:!!_e,onOpenChange:s=>{s||(Ge(null),we(""),Se(""))}
1,children:e.jsxs(G,{children:[e.jsxs(H,{children:[e.jsx(B,{children:"Record payment"}),e.jsx(Q,{children:_e&&e.jsxs(e.Fragment,{children:["Mark this schedule as paid and record a payment of"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[S,Math.round(Number(_e.amount)).toLocaleString()]})," ","for ",a.full_name,". Use this for cash or bank-transfer payments taken outside the app."]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",htmlFor:"settle-date",children:"Payment date"}),e.jsx(m,{id:"settle-date",type:"date",value:ks,onChange:s=>Se(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",htmlFor:"settle-reference",children:"Reference (optional)"}),e.jsx(m,{id:"settle-reference",value:Ts,onChange:s=>we(s.target.value),placeholder:"e.g. receipt no., bank transfer id"})]})]}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",onClick:()=>{Ge(null),we(""),Se("")},disabled:he.isPending,children:"Cancel"}),e.jsxs(r,{onClick:yt,disabled:he.isPending,children:[he.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Record Payment"]})]})]})}),e.jsx(V,{open:!!ve,onOpenChange:s=>{s||(Ve(null),Ne(""))}
1,children:e.jsxs(G,{children:[e.jsxs(H,{children:[e.jsx(B,{children:"Refund payment"}),e.jsx(Q,{children:ve&&e.jsxs(e.Fragment,{children:["This returns"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[S,Math.round(Number(ve.amount)).toLocaleString()]})," ","to the student's card via Ameriabank and reverses the payment on the ledger. This cannot be undone."]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",htmlFor:"refund-reason",children:"Reason (optional)"}),e.jsx(_s,{id:"refund-reason",value:Rs,onChange:s=>Ne(s.target.value),placeholder:"e.g. duplicate charge, student request",rows:3})]}),e.jsxs(K,{children:[e.jsx(r,{variant:"outline",onClick:()=>{Ve(null),Ne("")},disabled:xe.isPending,children:"Cancel"}),e.jsxs(r,{onClick:gt,disabled:xe.isPending,children:[xe.isPending&&e.jsx(y,{className:"mr-2 h-4 w-4 animate-spin"}),"Refund payment"]})]})]})})]})}function T({label:l,value:f}){return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("span",{className:"text-muted-foreground text-[13px] shrink-0",children:l}),e.jsx("span",{className:"text-sm font-medium text-right",children:f})]})}export{ya 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.