"use strict";exports.id=75697,exports.ids=[75697],exports.modules={14647:(a,b,c)=>{c.d(b,{B:()=>e,J:()=>f});var d=c(48249);function e({disabled:a}){return(0,d.jsx)("button",{type:"button",disabled:a,onClick:()=>window.print(),className:"inline-flex min-h-[40px] items-center justify-center rounded-md bg-primary-700 px-4 py-2 text-sm font-medium text-white hover:bg-primary-800 disabled:opacity-50 print:hidden",children:"Print / Save PDF"})}function f({letterhead:a,title:b,subtitle:c,meta:f,children:g,actions:h}){return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2 print:hidden",children:[h,(0,d.jsx)(e,{})]}),(0,d.jsxs)("div",{id:"sms-print-report",className:"overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm print:border-0 print:shadow-none",children:[(0,d.jsxs)("div",{className:"border-b border-slate-200 bg-slate-50 px-5 py-5 text-center sm:px-8",children:[(0,d.jsx)("p",{className:"text-xl font-bold tracking-tight text-slate-900 sm:text-2xl",children:a?.academyName||"School"}),a?.tagline?(0,d.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:a.tagline}):null,(0,d.jsx)("p",{className:"mt-3 text-base font-semibold uppercase tracking-wide text-slate-800",children:b}),c?(0,d.jsx)("p",{className:"mt-1 text-sm text-slate-600",children:c}):null,f?(0,d.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:f}):null]}),(0,d.jsx)("div",{className:"px-4 py-5 sm:px-8 sm:py-6",children:g}),(0,d.jsx)("div",{className:"border-t border-slate-100 px-5 py-4 text-xs text-slate-400 sm:px-8",children:"Generated for school records \xb7 Use Print / Save PDF for a paper copy"})]}),(0,d.jsx)("style",{children:`
        @media print {
          body * { visibility: hidden !important; }
          #sms-print-report, #sms-print-report * { visibility: visible !important; }
          #sms-print-report {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            border: none !important;
            box-shadow: none !important;
          }
        }
      `})]})}},75697:(a,b,c)=>{c.r(b),c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(84466),g=c(82697),h=c(14647),i=c(81152),j=c(91115);let k=[{value:"BONAFIDE",label:"Bonafide"},{value:"CHARACTER",label:"Character"},{value:"TRANSFER",label:"Transfer"}];function l(){let[a,b]=(0,e.useState)([]),[c,l]=(0,e.useState)([]),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)("BONAFIDE"),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!0),[z,A]=(0,e.useState)(!1),B=(0,e.useMemo)(()=>c.length>0&&r.length===c.length,[c,r]),C=(0,e.useCallback)(async()=>{if(!n)return void(0,j.Qg)("Select a class first");w(!0);try{let a=await (0,i.Uy)({schoolClassId:n,userIds:r.length?r:void 0,type:p});u(a)}catch(a){(0,j.Qg)(a instanceof Error?a.message:"Failed to load certificates"),u(null)}finally{w(!1)}},[n,r,p]);return(0,d.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,d.jsx)(f.wc,{title:"Student certificates",description:"Generate printable bonafide, character, or transfer certificates with academy branding."}),(0,d.jsx)(g.a,{tone:"info",title:"Print tip",children:"Choose certificate type and class (optionally select students), then Print / Save PDF. Each certificate prints on its own page."}),x?(0,d.jsx)(g.nI,{rows:2}):(0,d.jsxs)(g.r7,{children:[(0,d.jsx)(g.yB,{label:"Certificate type",className:"min-w-0 flex-1 sm:min-w-[11rem]",children:(0,d.jsx)(g.Kd,{value:p,onChange:a=>{q(a.target.value),u(null)},children:k.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))})}),(0,d.jsx)(g.yB,{label:"Class",className:"min-w-0 flex-1 sm:min-w-[14rem]",children:(0,d.jsxs)(g.Kd,{value:n,onChange:a=>o(a.target.value),children:[(0,d.jsx)("option",{value:"",children:"Select class"}),a.map(a=>(0,d.jsx)("option",{value:a.id,children:a.displayName},a.id))]})}),(0,d.jsxs)(g.bE,{children:[(0,d.jsx)(g.kL,{type:"button",onClick:()=>void C(),disabled:!n||v,children:v?"Generating…":"Generate"}),t?.certificates.length?(0,d.jsx)(h.B,{}):null]})]}),n&&z?(0,d.jsx)(g.nI,{rows:3}):c.length>0?(0,d.jsxs)("div",{className:"rounded-lg border border-slate-100 bg-white p-4 shadow-sm print:hidden",children:[(0,d.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("p",{className:"text-sm font-medium text-slate-800",children:["Students (",r.length||"all"," selected)"]}),(0,d.jsx)("button",{type:"button",onClick:()=>{B?s([]):s(c.map(a=>a.userId))},className:"text-sm font-medium text-primary-700 hover:underline",children:B?"Clear selection":"Select all"})]}),(0,d.jsx)("ul",{className:"grid max-h-56 grid-cols-1 gap-1 overflow-y-auto sm:grid-cols-2 lg:grid-cols-3",children:c.map(a=>(0,d.jsx)("li",{children:(0,d.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-slate-50",children:[(0,d.jsx)("input",{type:"checkbox",checked:r.includes(a.userId),onChange:()=>{var b;return b=a.userId,void s(a=>a.includes(b)?a.filter(a=>a!==b):[...a,b])},className:"rounded border-slate-300"}),(0,d.jsxs)("span",{className:"truncate text-slate-800",children:[a.fullName,a.rollNumber?(0,d.jsxs)("span",{className:"text-slate-500",children:[" \xb7 Roll ",a.rollNumber]}):null]})]})},a.userId))}),(0,d.jsx)("p",{className:"mt-2 text-xs text-slate-500",children:"Leave unchecked to generate for the whole class."})]}):n?(0,d.jsx)(g.i0,{title:"No students in class",description:"This class has no active students to generate certificates for."}):null,t?.certificates.length?(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"flex justify-end print:hidden",children:(0,d.jsx)(h.B,{})}),(0,d.jsx)("div",{id:"sms-certificates",className:"space-y-6",children:t.certificates.map(a=>(0,d.jsx)(m,{cert:a,letterhead:t.letterhead,title:t.certificateTitle,purpose:t.purpose},a.userId))}),(0,d.jsx)("style",{children:`
            @media print {
              body * { visibility: hidden !important; }
              #sms-certificates, #sms-certificates * { visibility: visible !important; }
              #sms-certificates {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
              }
              .sms-certificate {
                break-after: page;
                page-break-after: always;
              }
              .sms-certificate:last-child {
                break-after: auto;
                page-break-after: auto;
              }
            }
          `})]}):v&&n?(0,d.jsx)(g.nI,{rows:4}):n&&!t?(0,d.jsx)(g.i0,{title:"No certificates generated yet",description:"Choose type and class, then click Generate.",action:(0,d.jsx)(g.kL,{type:"button",onClick:()=>void C(),disabled:v,children:"Generate"})}):null]})}function m({cert:a,letterhead:b,title:c,purpose:e}){let f=[a.fatherName,a.motherName,a.guardianName].filter(Boolean).join(" / ");return(0,d.jsxs)("article",{className:"sms-certificate overflow-hidden rounded-lg border border-slate-300 bg-white shadow-sm",children:[(0,d.jsxs)("div",{className:"border-b-2 border-slate-800 px-6 py-6 text-center sm:px-10",children:[(0,d.jsx)("p",{className:"text-2xl font-bold tracking-tight text-slate-900",children:b.academyName||"School"}),b.tagline?(0,d.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:b.tagline}):null,(0,d.jsx)("p",{className:"mt-4 text-lg font-semibold uppercase tracking-[0.12em] text-slate-800",children:c}),(0,d.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Serial ",a.serialNo," \xb7 Issued ",a.issuedOn]})]}),(0,d.jsxs)("div",{className:"space-y-5 px-6 py-6 text-sm leading-relaxed text-slate-700 sm:px-10 sm:py-8",children:[(0,d.jsx)("p",{children:e}),(0,d.jsxs)("div",{className:"rounded-lg border border-slate-100 bg-slate-50 px-4 py-4",children:[(0,d.jsx)("p",{className:"text-base font-bold text-slate-900",children:a.fullName}),(0,d.jsxs)("dl",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Class"}),(0,d.jsx)("dd",{children:a.schoolClass?.displayName||"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Academic year"}),(0,d.jsx)("dd",{children:a.academicYear?.name||"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Roll / Code"}),(0,d.jsxs)("dd",{children:[a.rollNumber||"—",a.studentCode?` \xb7 ${a.studentCode}`:""]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Admission no"}),(0,d.jsx)("dd",{children:a.admissionNumber||"—"})]}),a.dateOfBirth?(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Date of birth"}),(0,d.jsx)("dd",{children:a.dateOfBirth})]}):null,f?(0,d.jsxs)("div",{children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Parent / Guardian"}),(0,d.jsx)("dd",{children:f})]}):null,a.address?(0,d.jsxs)("div",{className:"sm:col-span-2",children:[(0,d.jsx)("dt",{className:"text-xs uppercase text-slate-500",children:"Address"}),(0,d.jsx)("dd",{children:a.address})]}):null]})]}),(0,d.jsx)("p",{children:"This certificate is issued on request for official purposes. For verification, contact the school office."}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-8 pt-10 text-center text-xs text-slate-500",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mx-auto mb-2 h-px w-32 bg-slate-300"}),"Class teacher"]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mx-auto mb-2 h-px w-32 bg-slate-300"}),"Principal / Head"]})]})]})]})}}};