"use strict";exports.id=48868,exports.ids=[48868],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;
          }
        }
      `})]})}},48868:(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(25358);c(74741);var j=c(81152),k=c(91115);function l(){let[a,b]=(0,e.useState)([]),[c,i]=(0,e.useState)([]),[l,n]=(0,e.useState)(""),[o,p]=(0,e.useState)([]),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(!1),A=(0,e.useMemo)(()=>c.length>0&&o.length===c.length,[c,o]),B=(0,e.useCallback)(async()=>{if(!l)return void(0,k.Qg)("Select a class first");t(!0);try{let a=await (0,j.aN)({schoolClassId:l,userIds:o.length?o:void 0});r(a)}catch(a){(0,k.Qg)(a instanceof Error?a.message:"Failed to load ID cards"),r(null)}finally{t(!1)}},[l,o]);return(0,d.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,d.jsx)(f.wc,{title:"Student ID cards",description:"Generate printable student identity cards with academy branding and photo."}),(0,d.jsx)(g.a,{tone:"info",title:"Print tip",children:"Generate for a class (or selected students), then use Print / Save PDF. Cards print two per row on A4 landscape or portrait."}),u?(0,d.jsx)(g.nI,{rows:2}):(0,d.jsxs)(g.r7,{children:[(0,d.jsx)(g.yB,{label:"Class",className:"min-w-0 flex-1 sm:min-w-[14rem]",children:(0,d.jsxs)(g.Kd,{value:l,onChange:a=>n(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 B(),disabled:!l||s,children:s?"Generating…":"Generate cards"}),q?.cards.length?(0,d.jsx)(h.B,{disabled:!y}):null]})]}),l&&w?(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 (",o.length||"all"," selected)"]}),(0,d.jsx)("button",{type:"button",onClick:()=>{A?p([]):p(c.map(a=>a.userId))},className:"text-sm font-medium text-primary-700 hover:underline",children:A?"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:o.includes(a.userId),onChange:()=>{var b;return b=a.userId,void p(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."})]}):l?(0,d.jsx)(g.i0,{title:"No students in class",description:"This class has no active students to generate ID cards for."}):null,q?.cards.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,{disabled:!y})}),y?(0,d.jsx)("div",{id:"sms-id-cards",className:"grid grid-cols-1 gap-4 sm:grid-cols-2 print:grid-cols-2",children:q.cards.map(a=>(0,d.jsx)(m,{card:a,letterhead:q.letterhead},a.userId))}):(0,d.jsx)(g.nI,{rows:6}),(0,d.jsx)("style",{children:`
            @media print {
              body * { visibility: hidden !important; }
              #sms-id-cards, #sms-id-cards * { visibility: visible !important; }
              #sms-id-cards {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                display: grid !important;
                grid-template-columns: 1fr 1fr;
                gap: 12px;
              }
              .sms-id-card {
                break-inside: avoid;
                page-break-inside: avoid;
              }
            }
          `})]}):s&&l?(0,d.jsx)(g.nI,{rows:4}):l&&!q?(0,d.jsx)(g.i0,{title:"No cards generated yet",description:"Select students (optional) and click Generate cards.",action:(0,d.jsx)(g.kL,{type:"button",onClick:()=>void B(),disabled:s,children:"Generate cards"})}):null]})}function m({card:a,letterhead:b}){let c=a.fullName.split(/\s+/).filter(Boolean).slice(0,2).map(a=>a[0]?.toUpperCase()||"").join("");return(0,d.jsxs)("article",{className:"sms-id-card overflow-hidden rounded-xl border border-slate-300 bg-white shadow-sm font-sans leading-tight",children:[(0,d.jsxs)("header",{className:"bg-slate-800 px-4 py-3 text-center text-white",children:[(0,d.jsx)("p",{className:"text-sm font-bold tracking-tight sm:text-base",children:b.academyName||"School"}),b.tagline?(0,d.jsx)("p",{className:"mt-0.5 text-[11px] text-slate-300",children:b.tagline}):null,(0,d.jsx)("p",{className:"mt-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-slate-200",children:"Student identity card"})]}),(0,d.jsxs)("div",{className:"flex gap-3 px-4 py-4",children:[(0,d.jsx)("div",{className:"relative h-24 w-20 shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-100",children:a.profileImage?(0,d.jsx)(i.StorageImage,{src:a.profileImage,alt:a.fullName,fill:!0,className:"object-cover"}):(0,d.jsx)("span",{className:"flex h-full w-full items-center justify-center text-lg font-semibold text-slate-400",children:c||"—"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 text-xs text-slate-700",children:[(0,d.jsx)("p",{className:"truncate text-base font-bold text-slate-900",children:a.fullName}),(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"text-slate-500",children:"Class:"})," ",a.schoolClass?.displayName||"—"]}),(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"text-slate-500",children:"Roll:"})," ",a.rollNumber||"—",a.studentCode?(0,d.jsxs)(d.Fragment,{children:[" ","\xb7 ",(0,d.jsx)("span",{className:"text-slate-500",children:"Code:"})," ",a.studentCode]}):null]}),a.admissionNumber?(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"text-slate-500",children:"Admission:"})," ",a.admissionNumber]}):null,a.bloodGroup?(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"text-slate-500",children:"Blood:"})," ",a.bloodGroup]}):null,a.dateOfBirth?(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"text-slate-500",children:"DOB:"})," ",a.dateOfBirth]}):null]})]}),(0,d.jsxs)("footer",{className:"border-t border-slate-100 bg-slate-50 px-4 py-2 text-[11px] text-slate-600",children:[(0,d.jsxs)("p",{className:"truncate",children:[a.fatherName?`Father: ${a.fatherName}`:null,a.fatherName&&a.phone?" \xb7 ":null,a.phone?`Ph: ${a.phone}`:null,a.fatherName||a.phone?null:a.academicYear?.name||"—"]}),a.address?(0,d.jsx)("p",{className:"mt-0.5 line-clamp-1",children:a.address}):null]})]})}}};