1"use strict";(self.webpackChunkstudent_management_app=self.webpackChunkstudent_management_app||[]).push([[3320],{47798:(e,t,a)=>{a.d(t,{G:()=>n,L:()=>r});const s=(e,t)=>`hca:route-view-state:${e}:${t||"default"}`,n=(e,t)=>{if("undefined"===typeof window)return{};try{const a=window.sessionStorage.getItem(s(e,t));return a?JSON.parse(a):{}}catch{return{}}},r=(e,t,a)=>{if("undefined"!==typeof window)try{window.sessionStorage.setItem(s(e,t),JSON.stringify(a))}catch{}}},82587:(e,t,a)=>{a.d(t,{$y:()=>o,Qy:()=>i,pU:()=>d});var s=a(55271),n=a(69212),r=a(29402);const l=e=>{const t=(e=>{if(!e)return null;if("object"===typeof e&&"function"===typeof e.toDate)return e.toDate();if("object"===typeof e&&"number"===typeof e.seconds)return new Date(1e3*e.seconds);if("string"===typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e))return new Date(`${e}T12:00:00`);const t=new Date(e);return isNaN(t.getTime())?null:t})(e);return t?(0,n.GP)(t,"MMM dd, yyyy"):""},o=[{key:"name",header:"Name",get:e=>{return(t=e.fullName)?t.split(" ").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(" "):"N/A";var t}},{key:"email",header:"Email",get:e=>e.email||""},{key:"phone",header:"Phone",get:e=>e.phoneNumber||""},{key:"status",header:"Status",get:e=>{return(t=e.status)?t.charAt(0).toUpperCase()+t.slice(1):"";var t}},{key:"country",header:"Country",get:e=>e.countryOfOrigin||""},{key:"employerNumber",header:"Employer Number",get:e=>(e=>{const t=Array.isArray(e.employmentHistory)?e.employmentHistory:[],a=t.find(e=>e&&e.isCurrent)||t[0];return a&&a.phone||e.employerPhone||""})(e)},{key:"emergencyContact",header:"Emergency Contact #",get:e=>(e=>e.emergencyContactPhone||e.emergencyContact||"")(e)},{key:"registrationDate",header:"Registration Date",get:e=>l(e.registrationDate)},{key:"courseStart",header:"Course Start",get:e=>l(e.courseStartDate)},{key:"completion",header:"Expected Completion",get:e=>l(e.expectedCompletionDate)},{key:"totalAmount",header:"Total Amount",money:!0,get:e=>(0,r.q5)(e)},{key:"totalPaid",header:"Total Paid",money:!0,get:(e,t)=>(0,r.tt)(e.id,t.paidMap)},{key:"balance",header:"Balance (Dues)",money:!0,get:(e,t)=>Math.max(0,(0,r.q5)(e)-(0,r.tt)(e.id,t.balanceMap))},{key:"paymentStatus",header:"Payment Status",get:(e,t)=>{const a=(0,r.q5)(e),s=(0,r.tt)(e.id,t.balanceMap);return Math.max(0,a-s)<=0?"Paid":s>0?"Partial":"Unpaid"}}],i=()=>o.reduce((e,t)=>(e[t.key]=!0,e),{}),d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balanceMap:a={},paidMap:r,selectedColumns:l=null,paidHeader:i=null,extraColumns:d=[],sheetName:c="Students"}=t,u=t.filename||`Students_${(0,n.GP)(new Date,"yyyy-MM-dd")}.xlsx`,m={paidMap:r||a,balanceMap:a},x=(l?o.filter(e=>l[e.key]):o.slice()).concat(d);if(0===x.length)return{ok:!1,reason:"no-columns"};if(!e||0===e.length)return{ok:!1,reason:"no-rows"};const p=e=>"totalPaid"===e.key&&i?i:e.header,h=e.map(e=>{const t={};return x.forEach(a=>{t[p(a)]=a.get(e,m)}),t}),g={};x.forEach((t,a)=>{const s=p(t);0===a?g[s]="TOTAL":t.money?g[s]=e.reduce((e,a)=>e+(Number(t.get(a,m))||0),0):g[s]=""});const y=s.Wp.json_to_sheet([...h,g]);y["!cols"]=x.map(e=>{const t=p(e);return{wch:e.money?Math.max(14,t.length+2):"email"===e.key?28:Math.max(12,t.length+4)}});const f=x.map((e,t)=>e.money?t:-1).filter(e=>e>=0),b=s.Wp.decode_range(y["!ref"]);for(let n=1;n<=b.e.r;n+=1)f.forEach(e=>{const t=s.Wp.encode_cell({r:n,c:e});y[t]&&(y[t].z='"$"#,##0.00')});const v=s.Wp.book_new();return s.Wp.book_append_sheet(v,y,c),s._h(v,u),{ok:!0,count:e.length}}},92375:(e,t,a)=>{a.d(t,{A:()=>l});var s=a(9950),n=a(17119),r=a(44414);const l=e=>{let{name:t,src:a,fallbackSrc:l,className:o="h-10 w-10",preview:i=!1}=e;
1const d=a||l||"",[c,u]=(0,s.useState)(d),[m,x]=(0,s.useState)(null),p=(0,s.useRef)(null),h=(0,s.useRef)(null),g=(0,s.useId)(),y=()=>clearTimeout(h.current),f=()=>{y(),h.current=setTimeout(()=>x(null),120)},b=()=>{if(y(),!i||!c||!p.current)return;const e=p.current.getBoundingClientRect(),t=Math.min(272,window.innerWidth-24),a=Math.min(320,window.innerHeight-24);x({width:t,left:Math.max(12,Math.min(e.right+12,window.innerWidth-t-12)),top:Math.max(12,Math.min(e.top,window.innerHeight-a-12))})};(0,s.useEffect)(()=>()=>clearTimeout(h.current),[]),(0,s.useEffect)(()=>{if(!m)return;const e=()=>x(null),t=t=>{"Escape"===t.key&&e()};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("keydown",t)}},[m]),(0,s.useEffect)(()=>{u(a||l||""),x(null)},[a,l]);const v=()=>{u(c===a&&l&&l!==a?l:"")},j=i&&!!c,w=j?"button":"div";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{ref:p,...j?{type:"button","aria-label":`Preview photo of ${t||"student"}`,"aria-describedby":m?g:void 0,onMouseEnter:b,onMouseLeave:f,onFocus:b,onBlur:f,onClick:e=>{e.stopPropagation(),b()}}:{},className:`${o} flex-shrink-0 overflow-hidden rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center ${j?"cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2":""}`,children:c?(0,r.jsx)("img",{src:c,alt:t||"Student",className:"h-full w-full object-cover",onError:v}):(0,r.jsx)("span",{className:"text-sm font-medium text-white",children:String(t||"").trim().charAt(0).toUpperCase()||"?"})}),j&&m&&(0,n.createPortal)((0,r.jsxs)("div",{id:g,role:"tooltip",onMouseEnter:y,onMouseLeave:f,className:"fixed z-[100] rounded-xl border border-slate-200 bg-white p-3 shadow-2xl",style:m,children:[(0,r.jsx)("img",{src:c,alt:`Enlarged photo of ${t||"student"}`,onError:v,className:"w-full rounded-lg bg-slate-50 object-contain",style:{height:Math.min(248,window.innerHeight-96)}}),(0,r.jsx)("p",{className:"mt-2 truncate text-center text-sm font-medium text-slate-800",children:t||"Student"})]}),document.body)]})}},93320:(e,t,a)=>{a.r(t),a.d(t,{default:()=>V});var s=a(9950),n=a(56600),r=a(67714),l=a(29402),o=a(82587),i=a(48153),d=a(9145),c=a(48805),u=a(47288),m=a(56790),x=a(30815),p=a(69212),h=a(23517),g=a(78010),y=a(11818),f=a(10088),b=a(43302),v=a(14776),j=a(40732),w=a(73814),N=a(38138),P=a(22135),k=a(54359),C=a(15536),E=a(44414);const D=e=>{let{isOpen:t,onClose:a,title:n,children:r,size:l="default",showCloseButton:o=!0}=e;return(0,E.jsx)(P.e.Root,{show:t,as:s.Fragment,children:(0,E.jsxs)(k.lG,{as:"div",className:"relative z-50",onClose:a,children:[(0,E.jsx)(P.e.Child,{as:s.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,E.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,E.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,E.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,E.jsx)(P.e.Child,{as:s.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,E.jsxs)(k.lG.Panel,{className:`relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full ${{small:"sm:max-w-md",default:"sm:max-w-lg",large:"sm:max-w-xl",xlarge:"sm:max-w-2xl"}[l]} sm:p-6`,children:[o&&(0,E.jsx)("div",{className:"absolute right-0 top-0 pr-4 pt-4",children:(0,E.jsxs)("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2",onClick:a,children:[(0,E.jsx)("span",{className:"sr-only",children:"Close"}),(0,E.jsx)(C.A,{className:"h-6 w-6","aria-hidden":"true"})]})}),n&&(0,E.jsx)(k.lG.Title,{as:"h3",className:"text-lg font-semibold leading-6 text-gray-900 mb-4",children:n}),(0,E.jsx)("div",{className:"mt-2",children:r})]})})})})]})})};var S=a(17818),A=a(37684),M=a(40648),F=a(674),$=a(47798),R=a(92375);const B=["credit_card","cash","check","bank_transfer","other"],L=new Set(["active","graduated"]),I=e=>{if(!e||!0===e.isDeleted)return!1;const t=String(e.status||"").trim().toLowerCase();return L.has(t)},T=e=>(e=>{if(!e)return null;if("object"===typeof e&&"function"===typeof e.toDate)return e.toDate();if("object"===typeof e&&"number"===typeof e.seconds)return new Date(1e3*e.seconds);const t=new Date(e);return isNaN(t.getTime())?null:t})(e.paymentDate||e.date||e.createdAt),O=e=>{const t=(0,i.FQ)(e);return t?(0,p.GP)(t,"MMM d, yyyy"):""},z=e=>e?e.split(" ").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(" "):"N/A",H=e=>{let{status:t}=e;return(0,E.jsx)("span",{className:`px-3 py-1 inline-flex justify-center items-center text-xs font-medium rounded-full ${(()=>{switch(t){case"paid":return"bg-emerald-100 text-emerald-800 border border-emerald-200";case"partial":return"bg-amber-100 text-amber-800 border border-amber-200";
1case"pending":return"bg-rose-100 text-rose-800 border border-rose-200";default:return"bg-gray-100 text-gray-800 border border-gray-200"}})()}`,children:t.charAt(0).toUpperCase()+t.slice(1)})},U=e=>{if(!e)return new Date;const t=new Date(e);return isNaN(t.getTime())?new Date:t},_=e=>{var t,a;let{isOpen:l,onClose:o,student:i,onSubmit:d,loading:m}=e;const{showToast:x}=(0,r.d)(),h="true"===sessionStorage.getItem("newRegistration"),[g,y]=(0,s.useState)(!1),f=()=>{const e=new Date;return(0,p.GP)(e,"yyyy-MM-dd")},[b,j]=(0,s.useState)({amount:"",paymentMethod:"cash",paymentDate:f(),receiptNumber:"",notes:""}),[w,P]=(0,s.useState)({});(0,s.useEffect)(()=>{l&&(j({amount:"",paymentMethod:"cash",paymentDate:f(),receiptNumber:"",notes:""}),P({}))},[l]),(0,s.useEffect)(()=>{l&&h&&i&&j({amount:"",paymentMethod:"cash",paymentDate:f(),receiptNumber:"",notes:""})},[l,h,i]);const k=e=>{const{name:t,value:a}=e.target;j({...b,[t]:a}),w[t]&&P({...w,[t]:null})};if(!l)return null;const C=(null===i||void 0===i||null===(t=i.paymentDetails)||void 0===t?void 0:t.totalAmount)||0,S=(null===i||void 0===i||null===(a=i.paymentDetails)||void 0===a?void 0:a.totalPaid)||0,A=C-S;return(0,E.jsx)(D,{isOpen:l,onClose:o,children:(0,E.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full max-h-[90vh] overflow-y-auto",children:[(0,E.jsxs)("div",{className:"border-b border-[#E5E7EB] px-6 py-4",children:[(0,E.jsx)("h3",{className:"text-lg font-semibold text-[#1E3A8A]",children:h?"Complete Registration Payment":"Record payment"}),(0,E.jsxs)("p",{className:"text-sm text-gray-500",children:["For ",null===i||void 0===i?void 0:i.fullName]})]}),(0,E.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),(()=>{const e={};return(!b.amount||parseFloat(b.amount)<=0)&&(e.amount="Please enter a valid amount"),b.paymentMethod||(e.paymentMethod="Please select a payment method"),b.paymentDate||(e.paymentDate="Please select a payment date"),P(e),0===Object.keys(e).length})()){y(!0);try{const e=parseFloat(b.amount),l=new Date(b.paymentDate),d=b.receiptNumber||`REC-${Math.floor(1e5+9e5*Math.random())}`;console.log("Processing payment with data:",{studentId:i.id,amount:e,method:b.paymentMethod,date:l.toISOString()});const c={studentId:i.id,amount:e,method:b.paymentMethod,notes:b.notes||"",status:"completed",createdAt:(0,n.O5)(),date:l.toISOString(),receiptNumber:d};await(0,n.c4)(n.db,async t=>{var a,s;const r=(0,n.H9)((0,n.rJ)(n.db,"payments")),o=(0,n.H9)(n.db,"students",i.id),u=await t.get(o);if(!u.exists())throw new Error("Student record not found");const m=u.data(),x=(null===(a=m.paymentDetails)||void 0===a?void 0:a.totalPaid)||0,p=(null===(s=m.paymentDetails)||void 0===s?void 0:s.totalAmount)||0,h=x+e,g=p-h,y={amount:e,date:l.toISOString(),method:b.paymentMethod,receiptId:r.id,receiptNumber:d,notes:b.notes||""};return t.set(r,c),t.update(o,{"paymentDetails.totalPaid":h,"paymentDetails.balance":g,"paymentDetails.lastPaymentDate":(0,n.O5)(),"paymentDetails.lastPaymentAmount":e,"paymentDetails.paymentStatus":g<=0?"paid":"partial","paymentDetails.paymentHistory":(0,n.hq)(y)}),{paymentRef:r,updatedBalance:g,previousBalance:p-x}}),console.log("Payment recorded successfully"),(0,n.At)("payment.recorded",{category:"payment",targetType:"student",targetId:i.id,targetLabel:i.fullName||null,details:{amount:e,method:b.paymentMethod,receiptNumber:d,notes:b.notes||""}});const u=(0,n.H9)(n.db,"students",i.id),m=await(0,n.x7)(u);if(m.exists()){var t,a,s,r;const n={id:m.id,...m.data()},l={student:n,payment:c,balance:{totalAmount:(null===(t=n.paymentDetails)||void 0===t?void 0:t.totalAmount)||0,previousBalance:((null===(a=n.paymentDetails)||void 0===a?void 0:a.totalAmount)||0)-((null===(s=n.paymentDetails)||void 0===s?void 0:s.totalPaid)||0)+e,remaining:(null===(r=n.paymentDetails)||void 0===r?void 0:r.balance)||0}};(0,N.iY)(l),x("Payment recorded successfully!","success")}o(),window.location.reload()}catch(l){console.error("Error recording payment:",l),x(`Payment failed: ${l.message}`,"error")}finally{y(!1)}}},className:"p-6 space-y-4",children:[(0,E.jsxs)("div",{className:"bg-[#F9FAFB] rounded-md p-4 mb-4",children:[(0,E.jsxs)("div",{className:"flex justify-between mb-2",children:[(0,E.jsx)("span",{className:"text-sm text-gray-500",children:"Total fee"}),(0,E.jsxs)("span",{className:"text-sm font-medium",children:["$",C.toFixed(2)]})]}),(0,E.jsxs)("div",{className:"flex justify-between mb-2",children:[(0,E.jsx)("span",{className:"text-sm text-gray-500",children:"Previously paid"}),(0,E.jsxs)("span",{className:"text-sm font-medium",children:["$",S.toFixed(2)]})]}),(0,E.jsxs)("div",{className:"flex justify-between pt-2 border-t border-[#
1E5E7EB]",children:[(0,E.jsx)("span",{className:"text-sm font-medium text-[#1E3A8A]",children:"Remaining balance"}),(0,E.jsxs)("span",{className:"text-sm font-semibold text-[#1E3A8A]",children:["$",A.toFixed(2)]})]})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-[#111827] mb-1",children:"Payment amount ($)"}),(0,E.jsx)("input",{type:"number",name:"amount",value:b.amount,onChange:k,step:"0.01",min:"0.01",max:A,className:`w-full px-3 py-2 border ${w.amount?"border-red-500":"border-[#E5E7EB]"} rounded-md shadow-sm focus:ring-[#1E3A8A] focus:border-[#1E3A8A]`,required:!0}),w.amount&&(0,E.jsx)("p",{className:"mt-1 text-sm text-red-600",children:w.amount})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-[#111827] mb-1",children:"Payment method"}),(0,E.jsx)("select",{name:"paymentMethod",value:b.paymentMethod,onChange:k,className:`w-full px-3 py-2 border ${w.paymentMethod?"border-red-500":"border-[#E5E7EB]"} rounded-md shadow-sm focus:ring-[#1E3A8A] focus:border-[#1E3A8A]`,required:!0,children:B.map(e=>(0,E.jsx)("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1).replace("_"," ")},e))}),w.paymentMethod&&(0,E.jsx)("p",{className:"mt-1 text-sm text-red-600",children:w.paymentMethod})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-[#111827] mb-1",children:"Payment date"}),(0,E.jsx)("input",{type:"date",name:"paymentDate",value:b.paymentDate,onChange:k,className:`w-full px-3 py-2 border ${w.paymentDate?"border-red-500":"border-[#E5E7EB]"} rounded-md shadow-sm focus:ring-[#1E3A8A] focus:border-[#1E3A8A]`,required:!0}),w.paymentDate&&(0,E.jsx)("p",{className:"mt-1 text-sm text-red-600",children:w.paymentDate})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-[#111827] mb-1",children:"Receipt number (optional)"}),(0,E.jsx)("input",{type:"text",name:"receiptNumber",value:b.receiptNumber,onChange:k,className:"w-full px-3 py-2 border border-[#E5E7EB] rounded-md shadow-sm focus:ring-[#1E3A8A] focus:border-[#1E3A8A]"})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-[#111827] mb-1",children:"Notes (optional)"}),(0,E.jsx)("textarea",{name:"notes",value:b.notes,onChange:k,rows:"2",className:"w-full px-3 py-2 border border-[#E5E7EB] rounded-md shadow-sm focus:ring-[#1E3A8A] focus:border-[#1E3A8A]"})]}),(0,E.jsx)("div",{className:"flex justify-end space-x-3 pt-4 border-t border-[#E5E7EB]",children:h?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(c.$,{type:"button",onClick:()=>{sessionStorage.removeItem("newRegistration"),o()},variant:"outline",className:"border border-[#E5E7EB] text-gray-700 hover:bg-gray-50",children:"Pay Later"}),(0,E.jsx)(c.$,{type:"submit",disabled:g,className:"bg-gradient-to-r from-[#1E3A8A] to-[#3B82F6] hover:from-[#1E40AF] hover:to-[#3B82F6] text-white flex items-center space-x-1.5 px-4 py-2 rounded-md transition-all duration-200 shadow-sm hover:shadow-md active:translate-y-0.5",children:g?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),(0,E.jsx)("span",{children:"Processing..."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.A,{className:"h-4 w-4"}),(0,E.jsx)("span",{children:"Complete Payment"})]})})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(c.$,{type:"button",onClick:o,variant:"outline",className:"border border-[#E5E7EB] text-gray-700 hover:bg-gray-50",children:"Cancel"}),(0,E.jsx)(c.$,{type:"submit",disabled:g,className:"bg-gradient-to-r from-[#1E3A8A] to-[#3B82F6] hover:from-[#1E40AF] hover:to-[#3B82F6] text-white flex items-center space-x-1.5 px-4 py-2 rounded-md transition-all duration-200 shadow-sm hover:shadow-md active:translate-y-0.5",children:g?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),(0,E.jsx)("span",{children:"Processing..."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.A,{className:"h-4 w-4"}),(0,E.jsx)("span",{children:"Record payment"})]})})]})})]})]})})},G=e=>{var t,a;let{isOpen:l,onClose:o,student:i,payments:d=[],onGenerateReceipt:u,onPaymentEdited:x}=e;const{showToast:h}
1=(0,r.d)(),[g,y]=(0,s.useState)(null),[f,b]=(0,s.useState)(""),[v,j]=(0,s.useState)(!1),[w,N]=(0,s.useState)(!1);if(!l||!i)return null;const P=(null===(t=i.paymentDetails)||void 0===t?void 0:t.totalAmount)||0,k=d.reduce((e,t)=>["cancelled","void","refunded","reversed"].includes((t.status||"").toLowerCase())?e:e+(parseFloat(t.amount)||0),0),C=P-k,A=d.length>0?d:(null===(a=i.paymentDetails)||void 0===a?void 0:a.paymentHistory)||[];return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(D,{isOpen:l,onClose:o,children:(0,E.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto",children:[(0,E.jsx)("div",{className:"border-b border-[#E5E7EB] px-6 py-4",children:(0,E.jsxs)("div",{className:"flex justify-between items-center",children:[(0,E.jsxs)("div",{children:[(0,E.jsx)("h3",{className:"text-lg font-semibold text-[#1E3A8A]",children:"Payment history"}),(0,E.jsx)("p",{className:"text-sm text-gray-500",children:z(i.fullName)})]}),(0,E.jsx)(c.$,{onClick:o,variant:"ghost",size:"icon",className:"text-gray-500 hover:text-gray-700",children:(0,E.jsx)(m.A,{className:"h-5 w-5"})})]})}),(0,E.jsxs)("div",{className:"p-6",children:[(0,E.jsx)("div",{className:"bg-[#F9FAFB] rounded-md p-4 mb-6",children:(0,E.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,E.jsxs)("div",{children:[(0,E.jsx)("p",{className:"text-sm text-gray-500 mb-1",children:"Total fee"}),(0,E.jsxs)("p",{className:"text-base font-medium",children:["$",P.toFixed(2)]})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("p",{className:"text-sm text-gray-500 mb-1",children:"Total paid"}),(0,E.jsxs)("p",{className:"text-base font-medium",children:["$",k.toFixed(2)]})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("p",{className:"text-sm text-gray-500 mb-1",children:"Balance"}),(0,E.jsxs)("p",{className:"text-base font-medium",children:["$",C.toFixed(2)]})]})]})}),0===A.length?(0,E.jsx)("div",{className:"text-center py-8",children:(0,E.jsx)("p",{className:"text-gray-500",children:"No payment records found"})}):(0,E.jsx)("div",{className:"divide-y divide-[#E5E7EB]",children:A.map((e,t)=>{var a;const s=null!==(a=e.amount)&&void 0!==a?a:0,n=e.paymentDate||e.date||e.createdAt,r=e.method||e.paymentMethod||"n/a",l=!(!e.id&&!e.receiptId);return(0,E.jsxs)("div",{className:"py-4",children:[(0,E.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,E.jsxs)("div",{children:[(0,E.jsxs)("p",{className:"font-medium",children:["$","number"===typeof s?s.toFixed(2):parseFloat(s||0).toFixed(2)]}),(0,E.jsx)("p",{className:"text-sm text-gray-500",children:null!==n&&void 0!==n&&n.toDate?(0,p.GP)(n.toDate(),"MMM dd, yyyy"):(0,p.GP)(U(n),"MMM dd, yyyy")})]}),(0,E.jsxs)("div",{className:"flex space-x-2 items-center",children:[(0,E.jsx)("span",{className:"px-2 py-1 text-xs rounded-full bg-blue-100 text-blue-800 capitalize",children:String(r).replace("_"," ")}),l&&(0,E.jsx)("button",{onClick:()=>(e=>{var t;y(e),b(String(null!==(t=e.amount)&&void 0!==t?t:0))})(e),className:"p-1 rounded text-gray-500 hover:text-blue-600 hover:bg-blue-50",title:"Edit amount","aria-label":"Edit payment amount",children:(0,E.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,E.jsx)("button",{onClick:()=>u(i,{...e,amount:s,date:n,method:r}),className:"px-2 py-1 text-xs rounded-full bg-green-100 text-green-800 hover:bg-green-200 transition-colors","aria-label":"Generate receipt",children:"Receipt"})]})]}),e.notes&&(0,E.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:e.notes})]},e.id||e.receiptId||t)})})]})]})}),g&&(0,E.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-[60]",children:(0,E.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full p-6",children:[(0,E.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Edit Payment Amount"}),(0,E.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:g.receiptNumber?`Receipt: ${g.receiptNumber}`:"Payment record"}),(0,E.jsxs)("div",{className:"mb-4",children:[(0,E.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Amount ($)"}),(0,E.jsx)("input",{type:"number",step:"0.01",min:"0",value:f,onChange:e=>b(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"0.00"})]}),(0,E.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,E.jsx)("button",{onClick:()=>y(null),className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),(0,E.jsx)("button",{onClick:()=>
1{if(!g||null===i||void 0===i||!i.id)return;if(!(g.id||g.receiptId))return void h("Cannot edit: payment record has no ID","error");const e=parseFloat(f);isNaN(e)||e<0?h("Please enter a valid amount","error"):N(!0)},disabled:v,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",children:v?"Saving...":"Save"})]})]})}),(0,E.jsx)(S.A,{isOpen:w,onClose:()=>N(!1),onSuccess:()=>{N(!1),(async()=>{if(!g||null===i||void 0===i||!i.id)return;const e=g.id||g.receiptId;if(!e)return void h("Cannot edit: payment record has no ID","error");const t=parseFloat(f);if(isNaN(t)||t<0)h("Please enter a valid amount","error");else{j(!0);try{await(0,n.mZ)((0,n.H9)(n.db,"payments",e),{amount:t}),await(0,M.Y2)(i.id),h("Payment amount updated successfully","success"),y(null),N(!1),null===x||void 0===x||x()}catch(a){console.error("Error updating payment:",a),h(a.message||"Failed to update payment","error")}finally{j(!1)}}})()},title:"Edit Payment Authentication"})]})},W=e=>{let{students:t,paymentsByStudent:a={}}=e;const n=(0,s.useMemo)(()=>t.filter(I).reduce((e,t)=>{const{balance:s,actualTotalPaid:n}=(0,l.Yu)(t,a),r=s<=0?"paid":n>0?"partial":"pending";return{totalRevenue:e.totalRevenue+n,totalPending:e.totalPending+s,totalStudents:e.totalStudents+1,paidStudents:e.paidStudents+("paid"===r?1:0),partialStudents:e.partialStudents+("partial"===r?1:0),pendingStudents:e.pendingStudents+("pending"===r?1:0)}},{totalRevenue:0,totalPending:0,totalStudents:0,paidStudents:0,partialStudents:0,pendingStudents:0}),[t,a]),r=e=>{let{title:t,value:a,subtext:s,icon:n,gradient:r,textColor:l,trend:o}=e;return(0,E.jsxs)("div",{className:"bg-white rounded-lg border border-slate-200 shadow-sm hover:shadow-md transition-all duration-200 p-4",children:[(0,E.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("div",{className:`p-2 rounded-lg ${r}`,children:(0,E.jsx)(n,{className:"h-4 w-4 text-white"})}),(0,E.jsx)("h3",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:t})]}),o&&(0,E.jsx)("div",{className:"text-xs font-medium "+("Excellent"===o?"text-emerald-600":"Good"===o?"text-blue-600":"Needs Attention"===o?"text-amber-600":"text-slate-600"),children:o})]}),(0,E.jsxs)("div",{className:"space-y-1",children:[(0,E.jsx)("p",{className:"text-2xl font-bold text-slate-900",children:a}),s&&(0,E.jsx)("p",{className:"text-xs text-slate-500",children:s})]})]})},o=n.totalStudents>0?Math.round(n.paidStudents/n.totalStudents*100):0,i=n.totalStudents>0?n.totalRevenue/n.totalStudents:0;return(0,E.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4",children:[(0,E.jsx)(r,{title:"Total Revenue",value:`$${n.totalRevenue.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,subtext:`$${n.totalPending.toFixed(2)} pending collection`,icon:g.A,gradient:"bg-gradient-to-br from-emerald-500 to-emerald-600",trend:"+12%"}),(0,E.jsx)(r,{title:"Payment Status",value:`${n.paidStudents}/${n.totalStudents}`,subtext:`${n.partialStudents} partial \u2022 ${n.pendingStudents} pending`,icon:y.A,gradient:"bg-gradient-to-br from-blue-500 to-blue-600"}),(0,E.jsx)(r,{title:"Collection Rate",value:`${o}%`,subtext:`${n.paidStudents} students paid in full`,icon:f.A,gradient:"bg-gradient-to-br from-purple-500 to-purple-600",trend:o>75?"Excellent":o>50?"Good":"Needs Attention"}),(0,E.jsx)(r,{title:"Avg Payment",value:`$${i.toFixed(0)}`,subtext:"Per student average",icon:x.A,gradient:"bg-gradient-to-br from-indigo-500 to-indigo-600"})]})},q=e=>{let{currentPage:t,totalPages:a,onPageChange:s}=e;const n=(()=>{const e=[];e.push(1);let s=Math.max(2,t-2),n=Math.min(a-1,t+2);t<=4&&(n=Math.min(a-1,6)),t>a-4&&(s=Math.max(2,a-5)),s>2&&e.push("...");for(let t=s;t<=n;t++)e.push(t);return n<a-1&&e.push("..."),a>1&&e.push(a),e})();return(0,E.jsxs)("div",{className:"flex justify-center items-center space-x-1.5 mt-6 py-4",children:[(0,E.jsx)("button",{onClick:()=>s(t-1),disabled:t<=1,className:"p-2 rounded-full transition-all duration-200 "+(t<=1?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:bg-gray-100 hover:text-blue-600"),"aria-label":"Previous page",children:(0,E.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,E.jsx)("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})}),n.map((e,a)=>"..."===e?(0,E.jsx)("span",{className:"px-2 py-1 text-gray-500",children:"..."},`ellipsis-${a}`):(0,E.jsx)("button",{onClick:()=>s(e),className:"w-8 h-8 flex items-center justify-center rounded-full text-sm font-medium transition-all duration-200 "+(t===e?"bg-blue-600 text-white shadow-sm":"text-gray-700 hover:bg-gray-100"),"aria-label":`Page ${e}`,"aria-current":t===e?"page":void 0,children:e},`page-${e}`)),(0,E.jsx)("button",{onClick:()=>s(t+1),disabled:t>=a,className:"p-2 rounded-full transition-all duration-200 "+(t>=a?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:bg-gray-100 hover:text-blue-600"),"aria-label":"Next page",children:(0,E.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,E.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})})]})},J=()=>{const{authenticate:e}
1=(0,A.bb)(),[t,a]=(0,s.useState)({table:!1,payment:!1,modal:!1}),[c,u]=(0,s.useState)(!1),[m,g]=(0,s.useState)(null),[y,f]=(0,s.useState)([]),[P,k]=(0,s.useState)({}),[C,D]=(0,s.useState)([]),[B,L]=(0,s.useState)(null),U=(0,w.zy)(),J=(0,$.G)("payments",U.key),[V,K]=(0,s.useState)(()=>J.searchTerm||""),[Y,Q]=(0,s.useState)(!1),[Z,X]=(0,s.useState)(!1),[ee,te]=(0,s.useState)(!1),[ae,se]=(0,s.useState)(null),[ne,re]=(0,s.useState)(()=>J.filters||{status:"all",paymentMethod:"all",dateRange:{start:null,end:null}}),[le,oe]=(0,s.useState)(()=>({currentPage:1,lastDoc:null,hasMore:!0,totalPages:1,itemsPerPage:8,...J.pagination||{}})),[ie,de]=(0,s.useState)(()=>J.sortConfig||{field:"registrationDate",direction:"desc"}),[ce,ue]=(0,s.useState)(!1),{showToast:me}=(0,r.d)(),{showLoading:xe,hideLoading:pe}=(0,h.M)(),he=(0,w.Zp)();(0,s.useEffect)(()=>{(0,$.L)("payments",U.key,{searchTerm:V,filters:ne,pagination:{currentPage:le.currentPage,itemsPerPage:le.itemsPerPage},sortConfig:ie})},[U.key,V,ne,le.currentPage,le.itemsPerPage,ie]);const ge=(0,s.useMemo)(()=>Math.ceil(y.length/le.itemsPerPage),[y.length,le.itemsPerPage]);(0,s.useEffect)(()=>{oe(e=>({...e,totalPages:ge}))},[ge]),(0,s.useEffect)(()=>{ge>0&&le.currentPage>ge&&oe(e=>({...e,currentPage:ge}))},[ge,le.currentPage]);const ye=(0,s.useCallback)(async()=>{console.log("Fetching students with filters"),a(e=>({...e,table:!0}));try{console.log("Using simplified query to get data...");const e=(await(0,n.GG)((0,n.rJ)(n.db,"students"))).docs.map(e=>({id:e.id,...e.data()}));console.log(`Fetched ${e.length} students with simple query`);const t=e.filter(e=>{var t;return!!I(e)&&("all"===ne.status||(null===(t=e.paymentDetails)||void 0===t?void 0:t.paymentStatus)===ne.status)});console.log(`After client-side filtering, have ${t.length} students`);const a=[...t].sort((e,t)=>{let a=ie.field.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:null,e),s=ie.field.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:null,t);if("registrationDate"===ie.field){const e=e=>e?e.toDate&&"function"===typeof e.toDate?e.toDate():e.seconds?new Date(1e3*e.seconds):new Date(e):new Date(0);a=e(a),s=e(s)}else{var n,r;a=null!==(n=a)&&void 0!==n?n:0,s=null!==(r=s)&&void 0!==r?r:0}return a<s?"asc"===ie.direction?-1:1:a>s?"asc"===ie.direction?1:-1:0});console.log(`Sorted students by ${ie.field} ${ie.direction}`),f(a),ue(!0),X(!0)}catch(e){console.error("Error fetching students with simple query:",e),me("Failed to fetch students. Please try again.","error"),f([]),ue(!0)}finally{a(e=>({...e,table:!1}))}},[ne.status,ie.field,ie.direction,me]),fe=(0,s.useMemo)(()=>(0,l.YM)(C),[C]);(0,s.useEffect)(()=>{let e=!1;return y.length>0?(async()=>{const t=await Promise.all(y.map(async e=>{if(e.profilePhoto)return{id:e.id,url:null};try{const t=(0,n.KR)(n.IG,`students/${e.id}/profile-photo`);return{id:e.id,url:await(0,n.qk)(t)}}catch{return{id:e.id,url:null}}}));e||k(Object.fromEntries(t.filter(e=>{let{url:t}=e;return Boolean(t)}).map(e=>{let{id:t,url:a}=e;return[t,a]})))})():k({}),()=>{e=!0}},[y]);const be=(0,s.useMemo)(()=>{const e={};
1return C.forEach(t=>{t.studentId&&(e[t.studentId]=e[t.studentId]||[]).push(t)}),e},[C]);(0,s.useEffect)(()=>{const e=(0,n.P)((0,n.rJ)(n.db,"payments"),(0,n.My)("createdAt","desc")),t=(0,n.aQ)(e,e=>{const t=e.docs.map(e=>({id:e.id,...e.data()}));D(t)});return()=>t()},[]),(0,s.useEffect)(()=>{console.log("Component mounted, fetching students...");(async()=>{try{console.log("DIRECT DB CHECK: Checking what's in Firestore...");const e=await(0,n.GG)((0,n.rJ)(n.db,"students"));if(console.log(`DIRECT DB CHECK: Found ${e.docs.length} total documents`),e.docs.length>0){const t=e.docs[0].data();console.log("DIRECT DB CHECK: First document structure:",JSON.stringify(t,null,2));let a=0,s=0,n=0;e.docs.forEach(e=>{const t=e.data();"isDeleted"in t||a++,"registrationDate"in t||s++,"paymentDetails"in t||n++}),console.log(`DIRECT DB CHECK: Fields missing - isDeleted: ${a}, registrationDate: ${s}, paymentDetails: ${n}`)}}catch(e){console.error("DIRECT DB CHECK: Error checking database:",e)}})().then(()=>{ce||t.table||ye()})},[ce,ye,t.table]),(0,s.useEffect)(()=>{if(!Z||0===y.length)return;const e=sessionStorage.getItem("registeredStudentId"),t=sessionStorage.getItem("registrationAmount");if(e&&t){const t=e;sessionStorage.removeItem("registeredStudentId"),sessionStorage.removeItem("registrationAmount"),sessionStorage.setItem("newRegistration","true");const a=y.find(e=>e.id===t);a&&(L(a),Q(!0))}},[Z,y]);const ve=(0,s.useCallback)((e,t)=>{re(a=>({...a,[e]:t})),oe(e=>({...e,currentPage:1}))},[]),je=(0,s.useCallback)(e=>{e&&((0,l.cU)(e,fe)<=0?me("This student is fully paid. No additional payment can be recorded.","info"):he(`/dashboard/payments/record/${e.id}`))},[he,fe,me]),we=(0,s.useCallback)(e=>{f(t=>t.map(t=>t.id===ae?{...t,promiseToPay:e}:t))},[ae]),Ne=(0,s.useCallback)(()=>{Q(!1),L(null),a(e=>({...e,payment:!1})),pe()},[pe]),Pe=(0,s.useCallback)(e=>(0,l.cU)(e,fe),[fe]),ke=(0,s.useMemo)(()=>{var e,t;const a=null!==(e=ne.dateRange)&&void 0!==e&&e.start?new Date(`${ne.dateRange.start}T00:00:00`):null,s=null!==(t=ne.dateRange)&&void 0!==t&&t.end?new Date(`${ne.dateRange.end}T23:59:59`):null,n=!(!a&&!s),r=ne.paymentMethod&&"all"!==ne.paymentMethod;return y.filter(e=>{var t,o;const i=V.toLowerCase();if(!I(e))return!1;const d=(null===(t=e.fullName)||void 0===t?void 0:t.toLowerCase().includes(i))||(null===(o=e.email)||void 0===o?void 0:o.toLowerCase().includes(i)),c=(0,l.cU)(e,fe),u=fe[e.id]||0,m=c<=0?"paid":u>0?"partial":"pending",x="all"===ne.status||m===ne.status;let p=!0;if(n||r){p=(be[e.id]||[]).some(e=>{if(!(0,l.B4)(e))return!1;if(r&&(e.method||e.paymentMethod)!==ne.paymentMethod)return!1;if(n){const t=T(e);if(!t)return!1;if(a&&t<a)return!1;if(s&&t>s)return!1}return!0})}return d&&x&&p})},[y,V,ne.status,ne.paymentMethod,ne.dateRange,fe,be]),Ce=(0,s.useMemo)(()=>{const e=(le.currentPage-1)*le.itemsPerPage;return ke.slice(e,e+le.itemsPerPage)},[ke,le.currentPage,le.itemsPerPage]),Ee=(0,s.useCallback)(e=>{if(e<1||e>ge)return;oe(t=>({...t,currentPage:e}));const t=document.getElementById("payment-table");t&&t.scrollIntoView({behavior:"smooth"})},[ge]),De=e=>{var t;console.log(`Row clicked for student: ${e.fullName} (${e.id})`),t=e.id,he(`/dashboard/student/${t}`)},Se=(0,s.useCallback)(async(e,t,a)=>{try{me("Payment recorded successfully!","success");const{totalAmount:e,totalPaid:s,balance:n}=a.paymentDetails||{},r={student:a,payment:t,balance:{totalAmount:e||0,previousBalance:(e||0)-(s||0)+(t.amount||0),remaining:n||0}};(0,N.iY)(r),Ne(),ce||ye()}catch(s){console.error("Error handling payment success:",s),me("Payment was recorded, but there was an issue generating the receipt.","warning"),Ne()}},[me,Ne,ye,ce]),Ae=(0,s.useCallback)(e=>{g({type:"submit",data:e}),u(!0)},[]),Me=(0,s.useCallback)(async e=>{let t;a(e=>({...e,payment:!0})),xe();try{var s,r,l,o,i,d;t=setTimeout(()=>{a(e=>({...e,payment:!1})),pe(),me("Request timed out. Please try again.","error"),Ne()},3e4);const c=parseFloat(e.amount);if(!B)throw new Error("No student selected");const u=Pe(B);if(isNaN(c)||c<=0)throw new Error("Please enter a valid payment amount");if(c>u)throw new Error("Payment amount cannot exceed remaining balance");const m=e.paymentDate?new Date(e.paymentDate):new Date;let x=c;const p=(e,t)=>{if(!e||x<=0)return 0;const a=Math.min(x,(0,F.s1)(B,t));return x-=a,a},h={studentId:B.id,amount:c,method:e.method||"cash",notes:e.notes||"",status:"completed",createdAt:(0,n.O5)(),paymentDate:m.toISOString(),breakdown:{courseFee:p(!0,"courseFee"),accommodationFee:p(null===(s=B.accommodationDetail
1s)||void 0===s?void 0:s.required,"accommodationFee"),narRegistrationFee:p(null===(r=B.optionalFees)||void 0===r?void 0:r.narRegistration,"narRegistrationFee"),stateExamRegistrationFee:p(null===(l=B.optionalFees)||void 0===l?void 0:l.stateExamRegistration,"stateExamRegistrationFee"),stateExamFee:p(null===(o=B.optionalFees)||void 0===o?void 0:o.stateExamFee,"stateExamFee")}},g=(0,n.wP)(n.db),y=(0,n.H9)((0,n.rJ)(n.db,"payments"));g.set(y,h);const f=(0,n.H9)(n.db,"students",B.id),b=((null===(i=B.paymentDetails)||void 0===i?void 0:i.totalPaid)||0)+c,v=((null===(d=B.paymentDetails)||void 0===d?void 0:d.totalAmount)||0)-b,j={amount:c,date:m.toISOString(),method:e.method||"cash",receiptId:y.id,notes:e.notes||""};e.receiptNumber&&(j.receiptNumber=e.receiptNumber,h.receiptNumber=e.receiptNumber);const w={"paymentDetails.totalPaid":b,"paymentDetails.balance":v,"paymentDetails.lastPaymentDate":(0,n.O5)(),"paymentDetails.lastPaymentAmount":c,"paymentDetails.paymentStatus":v<=0?"paid":"partial","paymentDetails.paymentHistory":(0,n.hq)(j)};g.update(f,w),await g.commit(),(0,n.At)("payment.recorded",{category:"payment",targetType:"student",targetId:B.id,targetLabel:B.fullName||null,details:{amount:c,method:e.method||"cash",receiptNumber:e.receiptNumber||h.receiptNumber||"",notes:e.notes||""}});const N=(0,n.H9)(n.db,"students",B.id),P=await(0,n.x7)(N);if(P.exists()){const e={id:P.id,...P.data()};Se(f,h,e)}else Se(f,h,B);t&&clearTimeout(t)}catch(c){console.error("Error processing payment:",c),me(c.message||"Failed to process payment","error"),a(e=>({...e,payment:!1})),pe(),t&&clearTimeout(t)}},[B,Pe,me,pe,Ne,xe,Se]),Fe=(0,s.useCallback)(async(e,t)=>{try{await(0,N.Ui)(e,t,{print:!0}),me("Receipt generated successfully!","success")}catch(a){console.error("Error generating receipt:",a),me("Failed to generate receipt","error")}},[me]);return(0,E.jsxs)("div",{className:"space-y-6 max-w-7xl mx-auto",children:[(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"bg-gradient-to-r from-slate-50 to-blue-50 rounded-xl p-6 border border-gray-100 shadow-sm",children:(0,E.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between space-y-4 lg:space-y-0",children:[(0,E.jsxs)("div",{className:"space-y-2",children:[(0,E.jsx)("h2",{className:"text-3xl font-bold bg-gradient-to-r from-gray-900 to-blue-600 bg-clip-text text-transparent",children:"Payment Tracking"}),(0,E.jsx)("p",{className:"text-gray-600 text-sm",children:"Manage student payments and generate receipts \u2022 Real-time data"})]}),(0,E.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,E.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-gray-500",children:[(0,E.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),(0,E.jsx)("span",{children:"Live data"})]}),(0,E.jsxs)("button",{onClick:()=>{var e,t;if(0===ke.length)return void me("No students match the current filters.","warning");const a=null!==(e=ne.dateRange)&&void 0!==e&&e.start?new Date(`${ne.dateRange.start}T00:00:00`):null,s=null!==(t=ne.dateRange)&&void 0!==t&&t.end?new Date(`${ne.dateRange.end}T23:59:59`):null,n=!(!a&&!s),r=n?[{key:"paidInRange",header:"Paid in Range",money:!0,get:e=>(be[e.id]||[]).reduce((e,t)=>{if(!(0,l.B4)(t))return e;const n=T(t);return a&&(!n||n<a)||s&&(!n||n>s)?e:e+(parseFloat(t.amount)||0)},0)}]:[];(0,o.pU)(ke,{balanceMap:fe,extraColumns:r,filename:`payments${n?`_${ne.dateRange.start||"start"}_to_${ne.dateRange.end||"end"}`:`_${(0,p.GP)(new Date,"yyyy-MM-dd")}`}.xlsx`}).ok||me("Nothing to export.","warning")},className:"bg-white border border-gray-200 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-50 transition-all duration-200 flex items-center space-x-2 shadow-sm",children:[(0,E.jsx)(x.A,{className:"h-4 w-4"}),(0,E.jsx)("span",{children:"Export Excel"})]})]})]})}),(0,E.jsx)("div",{className:"mt-6",children:(0,E.jsx)(W,{students:y,paymentsByStudent:fe})}),(0,E.jsx)("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm p-6 mt-8 mb-6",children:(0,E.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,E.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between space-y-4 lg:space-y-0 gap-4",children:[(0,E.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,E.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,E.jsx)("svg",{className:"h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,E.jsx)("input",{type:"text",placeholder:"Search by name or email...",className:"block w-full pl-10 pr-3 py-3 border border-gray-200 rounded-lg leading-5 bg-gray-50 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 focus:bg-white transition-all duration-200",value:V,onChange:e=>K(e.target.value)})]}),(0,E.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,E.jsx)("span",{className:"text-sm text-gray-500 font-medium",children:"Qu
1ick Actions:"}),(0,E.jsx)("button",{onClick:()=>ve("status","pending"),className:"px-3 py-1.5 text-xs font-medium text-orange-700 bg-orange-100 rounded-full hover:bg-orange-200 transition-colors",children:"Pending Only"}),(0,E.jsx)("button",{onClick:()=>ve("status","partial"),className:"px-3 py-1.5 text-xs font-medium text-yellow-700 bg-yellow-100 rounded-full hover:bg-yellow-200 transition-colors",children:"Partial Payments"}),(0,E.jsx)("button",{onClick:()=>{K(""),ve("status","all"),ve("paymentMethod","all"),ve("dateRange",{start:null,end:null})},className:"px-3 py-1.5 text-xs font-medium text-gray-700 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:"Reset Filters"})]})]}),(0,E.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,E.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:"Payment Status"}),(0,E.jsxs)("select",{className:"px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm",value:ne.status,onChange:e=>ve("status",e.target.value),children:[(0,E.jsx)("option",{value:"all",children:"All Statuses"}),(0,E.jsx)("option",{value:"paid",children:"\u2705 Paid in Full"}),(0,E.jsx)("option",{value:"partial",children:"\u26a0\ufe0f Partial Payment"}),(0,E.jsx)("option",{value:"pending",children:"\ud83d\udd34 Pending Payment"})]})]}),(0,E.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:"Payment Method"}),(0,E.jsxs)("select",{className:"px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm",value:ne.paymentMethod,onChange:e=>ve("paymentMethod",e.target.value),children:[(0,E.jsx)("option",{value:"all",children:"All Methods"}),(0,E.jsx)("option",{value:"cash",children:"\ud83d\udcb5 Cash"}),(0,E.jsx)("option",{value:"credit_card",children:"\ud83d\udcb3 Credit Card"}),(0,E.jsx)("option",{value:"bank_transfer",children:"\ud83c\udfe6 Bank Transfer"}),(0,E.jsx)("option",{value:"check",children:"\ud83d\udcdd Check"}),(0,E.jsx)("option",{value:"other",children:"\ud83d\udccb Other"})]})]}),(0,E.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:"Payment Date Range"}),(0,E.jsxs)("div",{className:"flex items-center gap-2",children:[(0,E.jsx)("input",{type:"date",value:ne.dateRange.start||"",onChange:e=>ve("dateRange",{...ne.dateRange,start:e.target.value||null}),className:"px-3 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm","aria-label":"Payments from"}),(0,E.jsx)("span",{className:"text-gray-400 text-sm",children:"to"}),(0,E.jsx)("input",{type:"date",value:ne.dateRange.end||"",onChange:e=>ve("dateRange",{...ne.dateRange,end:e.target.value||null}),className:"px-3 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm","aria-label":"Payments to"}),(ne.dateRange.start||ne.dateRange.end)&&(0,E.jsx)("button",{onClick:()=>ve("dateRange",{start:null,end:null}),className:"text-xs font-medium text-gray-500 hover:text-gray-700 underline whitespace-nowrap",children:"Clear"})]})]}),(0,E.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:"Sort By"}),(0,E.jsxs)("select",{className:"px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm",value:`${ie.field}-${ie.direction}`,onChange:e=>{const[t,a]=e.target.value.split("-");de({field:t,direction:a}),oe(e=>({...e,currentPage:1,lastDoc:null})),ue(!1),ye()},children:[(0,E.jsx)("option",{value:"registrationDate-desc",children:"\ud83d\udcc5 Newest First"}),(0,E.jsx)("option",{value:"registrationDate-asc",children:"\ud83d\udcc5 Oldest First"}),(0,E.jsx)("option",{value:"fullName-asc",children:"\ud83d\udc64 Name (A-Z)"}),(0,E.jsx)("option",{value:"fullName-desc",children:"\ud83d\udc64 Name (Z-A)"}),(0,E.jsx)("option",{value:"paymentDetails.totalAmount-desc",children:"\ud83d\udcb0 Highest Fee"}),(0,E.jsx)("option",{value:"paymentDetails.totalAmount-asc",children:"\ud83d\udcb0 Lowest Fee"}),(0,E.jsx)("option",{value:"paymentDetails.balance-desc",children:"\ud83d\udcca Highest Balance"}),(0,E.jsx)("option",{value:"paymentDetails.balance-asc",children:"\ud83d\udcca Lowest Balance"})]})]}),(0,E.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,E.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:"Items Per Page"}),(0,E.jsxs)("select",{className:"px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-sm",value:le.itemsPerPage,onChange:e=>oe(t=>({...t,itemsPerPage:parseInt(e.target.value),currentPage:1})),children:[(0,E.jsx)("option",{value:5,children:"5 per page"}),(0,E.jsx)("option",{value:8,children:"8 per page"}),(0,E.jsx)("option",{value:10,children:"10 per page"}),(0,E.jsx)("option",{value:20,children:"20 per page"})]})]})]}),(0,E.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between pt-4 border-t border-gray-100 text-sm text-gray-600",children:[(0,E.jsxs)("div",{children:["Showing ",(0,E.jsx)("span",{className:"font-medium",children:ke.length})," of ",(0,E.jsx)("span",{className:"font-medium",children:y.length})," active and graduated students"]}),(0,E.jsxs)("div",{className:"mt-2 sm:mt-0",children:["Page ",(0,E.jsx)("span",{className:"font-medium",children:le.currentPage})," of ",(0,E.jsx)("span",{className:"font-medium",children:ge})]})]})]})}),(0,E.jsx)("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden mt-4",children:t.table?(0,E.jsx)("div",{className:"flex justify-center items-center py-16",children:(0,E.jsx)(j.A,{size:"large"})}):ke.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"overflow-x-auto",children:(0,E.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,E.jsx)("thead",{className:"bg-gradient-to-r from-gray-50 to-blue-50",children:(0,E.jsxs)("tr",{children:[(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})}),(0,E.jsx)("span",{children:"Student"})]})}),(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),(0,E.jsx)("span",{children:"Total Fee"})]})}),(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,E.jsx)("span",{children:"Paid Amount"})]})}),(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0V9m0 8l-8-8-4 4-6-6"})}),(0,E.jsx)("span",{children:"Balance"})]})}),(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),(0,E.jsx)("span",{children:"Status"})]})}),(0,E.jsx)("th",{scope:"col",className:"px-6 py-4 text-center text-xs font-semibold text-gray-700 uppercase tracking-wider",children:(0,E.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,E.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})}),(0,E.jsx)("span",{children:"Actions"})]})})]})}),(0,E.jsx)("tbody",{className:"bg-white divide-y divide-gray-100",children:Ce.map((e,t)=>{var a;return(0,E.jsxs)("tr",{className:"hover:bg-blue-50 cursor-pointer transition-all duration-200 "+(t%2===0?"bg-white":"bg-gray-50/30"),onClick:()=>De(e),children:[(0,E.jsx)("td",{className:"px-6 py-5 whitespace-nowrap",children:(0,E.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,E.jsx)(R.A,{name:e.fullName,src:e.profilePhoto,fallbackSrc:P[e.id]}),(0,E.jsxs)("div",{className:"flex flex-col",children:[(0,E.jsx)("div",{className:"text-sm font-semibold text-gray-900 hover:text-blue-600 transition-colors",children:z(e.fullName)}),(0,E.jsx)("div",{className:"text-xs text-gray-500",children:e.email})]})]})}),(0,E.jsxs)("td",{className:"px-6 py-5 whitespace-nowrap",children:[(0,E.jsxs)("div",{className:"text-sm font-medium text-gray-900",children:["$",((null===(a=e.paymentDetails)||void 0===a?void 0:a.totalAmount)||0).toFixed(2)]}),(0,E.jsx)("div",{className:"text-xs text-gray-500",children:"Course fee"})]}),(0,E.jsxs)("td",{className:"px-6 py-5 whitespace-nowrap",children:[(0,E.jsxs)("div",{className:"text-sm font-medium text-green-600",children:["$",(fe[e.id]||0).toFixed(2)]}),(0,E.jsx)("div",{className:"text-xs text-gray-500",children:"Received"})]}),(0,E.jsx)("td",{className:"px-6 py-5 whitespace-nowrap",children:(()=>{const t=(0,l.cU)(e,fe);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"text-sm font-medium "+(t>0?"text-red-600":"text-green-600"),children:["$",t.toFixed(2)]}),(0,E.jsx)("div",{className:"text-xs text-gray-500",children:t>0?"Outstanding":"Cleared"})]})})()}),(0,E.jsxs)("td",{className:"px-6 py-5 whitespace-nowrap",children:[(0,E.jsx)(H,{status:(()=>{const t=(0,l.cU)(e,fe),a=fe[e.id]||0;return t<=0?"paid":a>0?"partial":"pending"})()}),(()=>{const t=(0,i.Hz)(e);if(!t)return null;const a=(0,i.ir)(t);return(0,E.jsxs)("div",{className:"mt-1.5 inline-flex items-center gap-1 text-[11px] font-medium px-1.5 py-0.5 rounded-full "+(a?"bg-red-100 text-red-700":"bg-amber-100 text-amber-700"),title:t.note||"Promise to pay",children:[(0,E.jsx)(b.A,{className:"w-3 h-3"}),"Promise ",O(t.date)]})})()]}),(0,E.jsx)("td",{className:"px-6 py-5 whitespace-nowrap text-center",children:(0,E.jsxs)("div",{className:"flex justify-center items-center space-x-2",children:[(0,E.jsxs)("button",{onClick:t=>{t.stopPropagation(),je(e)}
1,disabled:(0,l.cU)(e,fe)<=0,className:"inline-flex items-center px-3 py-1.5 border border-transparent text-xs font-medium rounded-lg transition-all duration-200 "+((0,l.cU)(e,fe)>0?"text-white bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 shadow-sm hover:shadow-md":"bg-slate-100 text-slate-400 cursor-not-allowed"),title:(0,l.cU)(e,fe)<=0?"Account paid in full":"Record payment",children:[(0,E.jsx)(v.A,{className:"h-3 w-3 mr-1"}),"Payment"]}),(0,E.jsx)("button",{onClick:t=>{t.stopPropagation(),se(e.id)},className:"inline-flex items-center p-1.5 border border-amber-300 rounded-lg text-amber-600 hover:text-amber-700 hover:bg-amber-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-amber-500 transition-all duration-200","aria-label":"Promise to pay",title:"Promise to pay",children:(0,E.jsx)(b.A,{className:"h-4 w-4"})}),(0,E.jsx)("button",{onClick:t=>{t.stopPropagation(),L(e),te(!0)},className:"inline-flex items-center p-1.5 border border-gray-300 rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200","aria-label":"View payment history",children:(0,E.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),(0,E.jsx)("button",{onClick:t=>{t.stopPropagation();const a=(0,l.cU)(e,fe);a>0&&(0,M.Ve)({studentId:e.id,amount:a}).catch(e=>{me(`Stripe error: ${e.message}`,"error")})},disabled:(0,l.cU)(e,fe)<=0,className:"inline-flex items-center p-1.5 border rounded-lg transition-all duration-200 "+((0,l.cU)(e,fe)>0?"border-indigo-300 text-indigo-600 hover:text-indigo-700 hover:bg-indigo-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500":"border-gray-200 text-gray-300 cursor-not-allowed"),"aria-label":"Pay with Stripe",title:"Pay with Stripe",children:(0,E.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,E.jsx)("path",{d:"M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.591-7.305z"})})})]})})]},e.id)})})]})}),(0,E.jsx)("div",{className:"mt-6",children:(0,E.jsx)(q,{currentPage:le.currentPage,totalPages:ge,onPageChange:Ee})})]}):(0,E.jsxs)("div",{className:"text-center py-16",children:[(0,E.jsx)("div",{className:"mx-auto flex items-center justify-center h-16 w-16 rounded-full bg-gray-100 mb-4",children:(0,E.jsx)("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,E.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z"})})}),(0,E.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No students found"}),(0,E.jsx)("p",{className:"text-gray-500 mb-6",children:V||"all"!==ne.status?"Try adjusting your search criteria or filters to find students.":"No students have been registered yet."}),(V||"all"!==ne.status)&&(0,E.jsx)("button",{onClick:()=>{K(""),ve("status","all")},className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200",children:"Clear all filters"})]})})]}),(0,E.jsx)(_,{isOpen:Y,onClose:Ne,student:B,onSubmit:Ae,loading:t.payment}),(0,E.jsx)(G,{isOpen:ee,onClose:()=>te(!1),student:B,payments:B?C.filter(e=>e.studentId===B.id):[],onGenerateReceipt:Fe,onPaymentEdited:ye}),(()=>{const e=ae?y.find(e=>e.id===ae):null;return(0,E.jsx)(d.A,{isOpen:!!ae,student:e,balance:e?(0,l.cU)(e,fe):void 0,onClose:()=>se(null),onUpdated:we})})(),(0,E.jsx)(S.A,{isOpen:c,onClose:()=>{u(!1),g(null)},onSuccess:()=>{e(),u(!1),"submit"===(null===m||void 0===m?void 0:m.type)&&Me(m.data),g(null)},title:"Payment Recording Authentication"})]})},V=s.memo(J)}}]);
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.