PageSourceSearch

https://online.timganmath.edu.sg/_next/static/chunks/74840.8ae125fbe9cdec1a.js

js timganmath.edu.sg collected 2026-09-30 14:38:33 UTC 48,431 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[18841,74840],{9529:(e,s,t)=>{"use strict";t.d(s,{N:()=>n});var a=t(10660);t(65364);let n=(0,a.U)()},23784:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(92949).A)("zap",[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]])},32371:(e,s,t)=>{"use strict";t.d(s,{H4:()=>v,_V:()=>N,bL:()=>j});var a=t(14232),n=t(77977),r=t(91844),i=t(62146),l=t(81285),d=t(66326),c=t(37876),o=Object.defineProperty,m=(e,s)=>o(e,"name",{value:s,configurable:!0}),u="Avatar",[h,x]=(0,r.A)(u),p=[0,()=>void 0],[g,f]=h(u),j=a.forwardRef(m(function(e,s){let{__scopeAvatar:t,...n}=e,[r,i]=a.useState("idle"),[l,o]=_();return(0,c.jsx)(g,{scope:t,imageLoadingStatus:r,setImageLoadingStatus:i,imageCount:l,setImageCount:o,children:(0,c.jsx)(d.sG.span,{...n,ref:s})})},"Avatar")),N=a.forwardRef(m(function(e,s){let{__scopeAvatar:t,src:n,onLoadingStatusChange:r,...o}=e,m=f("AvatarImage",t);w(m.setImageCount);let u=y(n,{referrerPolicy:o.referrerPolicy,crossOrigin:o.crossOrigin,loadingStatus:m.imageLoadingStatus,setLoadingStatus:m.setImageLoadingStatus}),h=(0,i.c)(e=>{r?.(e)}),x=a.useRef(u);return(0,l.N)(()=>{let e=x.current;x.current=u,u!==e&&h(u)},[u,h]),"loaded"===u?(0,c.jsx)(d.sG.img,{...o,ref:s,src:n}):null},"AvatarImage")),v=a.forwardRef(m(function(e,s){let{__scopeAvatar:t,delayMs:n,...r}=e,i=f("AvatarFallback",t),[l,o]=a.useState(void 0===n);return a.useEffect(()=>{if(void 0!==n){let e=window.setTimeout(()=>o(!0),n);return()=>window.clearTimeout(e)}},[n]),l&&"loaded"!==i.imageLoadingStatus?(0,c.jsx)(d.sG.span,{...r,ref:s}):null},"AvatarFallback"));function y(e,{loadingStatus:s,setLoadingStatus:t,referrerPolicy:a,crossOrigin:n}){return(0,l.N)(()=>{if(!e)return void t("error");let s=new window.Image,r=m(e=>{t(b(e.currentTarget))},"handleLoad"),i=m(()=>t("error"),"handleError");return s.addEventListener("load",r),s.addEventListener("error",i),a&&(s.referrerPolicy=a),s.crossOrigin=n??null,s.src=e,t(b(s)),()=>{s.removeEventListener("load",r),s.removeEventListener("error",i),t("idle")}},[e,n,a,t]),s}function b(e){return e.complete?e.naturalWidth>0?"loaded":"error":"loading"}function _(){let e=p;if(n.D){let[s]=e=a.useState(0),t=a.useRef(!1);a.useEffect(()=>{s>1&&!t.current&&(t.current=!0,console.warn("Avatar: Only one `Avatar.Image` component should be rendered per `Avatar.Root`, but multiple were detected. This will lead to unexpected behavior."))},[s])}return e}function w(e){n.D&&a.useEffect(()=>(e(e=>e+1),()=>{e(e=>e-1)}),[e])}m(y,"useImageLoadingStatus"),m(b,"getImageLoadingStatus"),m(_,"useImageCount"),m(w,"useUpdateImageCount")},37337:e=>{e.exports={selectionReveal:"LessonDetailPanel_selectionReveal__H0xuF"}},48186:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(92949).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},64503:(e,s,t)=>{"use strict";t.d(s,{b:()=>u});var a=t(14232),n=t(66326),r=t(37876),i=Object.defineProperty,l=(e,s)=>i(e,"name",{value:s,configurable:!0}),d="horizontal",c=["horizontal","vertical"],o=a.forwardRef(l(function(e,s){let{decorative:t,orientation:a=d,...i}=e,l=m(a)?a:d;return(0,r.jsx)(n.sG.div,{"data-orientation":l,...t?{role:"none"}:{"aria-orientation":"vertical"===l?l:void 0,role:"separator"},...i,ref:s})},"Separator"));function m(e){return c.includes(e)}l(m,"isValidOrientation");var u=o},66874:(e,s,t)=>{"use strict";function a(e,s,t){let a=e.indexOf("#"),n=a>=0?e.slice(0,a):e,r=a>=0?e.slice(a):"",i=RegExp(`([?&]${s}=)[^&#]*`,"i");if(i.test(n))return n.replace(i,`$1${t}`)+r;let l=n.includes("?")?"&":"?";return`${n}${l}${s}=${t}${r}`}function n(e){let s=e?.trim();if(!s)return;let t=s.toLowerCase();return t.includes("youtube.com/embed/")||t.includes("youtube-nocookie.com/embed/")?a(s,"autoplay","0"):t.includes("mediadelivery.net")?a(s,"autoplay","false"):s}t.d(s,{c:()=>n})},71362:(e,s,t)=>{"use strict";t.r(s),t.d(s,{LessonDetailPanel:()=>ej,default:()=>eN});var a=t(37876),n=t(14232),r=t(37337),i=t.n(r),l=t(54587),d=t.n(l),c=t(98592),o=t(12095),m=t(83551),u=t(82480),h=t(33697),x=t(63460),p=t(50267),g=t(8525),f=t(53757),j=t(29599),N=t(83791),v=t(11481
1),y=t(97194),b=t(10511),_=t(53266),w=t(60266),k=t(23784),C=t(80073),A=t(61773);let $=(0,t(92949).A)("calendar-x",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);var S=t(48186),T=t(60067),L=t(22279),R=t(80901),E=t(83836),z=t(80504),F=t(83529),I=t(31797),P=t(15117),M=t(73548),O=t(55048),D=t(7190),U=t(98057),W=t(42779),Z=t(66344),q=t(65687),B=t(64226),G=t(10458),J=t(1773),Y=t(45273),V=t(98346),H=t(30344),K=t(75825),X=t(22124),Q=t(72895),ee=t(43e3),es=t(71442),et=t(37675),ea=t(75656),en=t(40846),er=t(59688);function ei(e){let s=(0,U.k_)(e);s&&window.open(`https://wa.me/${s}`,"_blank","noopener,noreferrer")}function el({scheduledLessonId:e,scheduledLessonIds:s,studentName:t,lessonStatus:r,trialOccurrenceStatus:i}){let{confirmation:l,readiness:c,phoneOptions:o,isLoading:m,error:u}=function(e,s=e?[e]:[]){let t=function(e,s=e?[e]:[]){let t=[...new Set(s)].sort();return e&&t.includes(e)?`/api/admin/school/attendance-confirmations/by-scheduled-lessons?ids=${encodeURIComponent(t.join(","))}`:null}(e,s),{data:a,error:n,isLoading:r,mutate:i}=(0,ea.Ay)(t,en.IU,{revalidateOnFocus:!1,dedupingInterval:1e4}),l=e?a?.confirmations[e]:null;return{confirmation:l?.confirmation??null,readiness:l?.readiness??null,phoneOptions:l?.phoneOptions??{parent:null,student:null},isLoading:r,error:n||null,refresh:i}}(e,s),[h,x]=(0,n.useState)(!1),p=o.student,g=o.parent,f=(0,n.useCallback)(()=>{p&&ei(p)}
1,[p]),j=(0,n.useCallback)(()=>{g&&ei(g)},[g]);if((0,n.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>x(!1),2e3);return()=>clearTimeout(e)},[h]),m)return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:t||"Student"}),(0,a.jsx)(Q.A,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground","aria-hidden":"true"})]});if(u)return(0,a.jsxs)("div",{className:"space-y-1.5 px-3 py-2.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:t||"Student"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[(0,a.jsx)(ee.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),u.message||"Failed to load confirmation",". Please refresh, then inform an admin if the link still cannot be loaded."]})]});if(!l)return"scheduled"===r&&"scheduled"===i?(0,a.jsxs)("div",{className:"space-y-1.5 px-3 py-2.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:t||"Student"}),(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs text-destructive",children:[(0,a.jsx)(ee.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,a.jsx)("span",{children:"Attendance link unavailable. Refresh this lesson, then inform an admin if it is still missing."})]})]}):null;let N=`${window.location.origin}/attendance/${l.token}`,v=async()=>{if(N&&c?.canCopy)try{await navigator.clipboard.writeText(N),x(!0)}catch(e){console.error("Copy failed:",e),er.oR.error(`Could not copy ${t?`${t}'s `:""}attendance link. Please inform an admin.`)}},y="confirmed"===l.status,b="expired"===l.status||c?.reason==="expired",w=y&&"admin"===l.confirmation_source,k=w?`manually${l.confirmed_by_admin?.full_name?` by ${l.confirmed_by_admin.full_name}`:""}`:l.confirmed_by_phone_type?`by ${l.confirmed_by_phone_type}`:"",C=null;return c?.reason==="locked"?C="Attendance link locked after too many failed phone checks. Please inform an admin for help.":c?.reason==="missing_phone"?C="scheduled"===i?"Attendance link unavailable: add a valid parent or student phone to the trial enquiry, then refresh this lesson or inform an admin.":"Attendance link unavailable: add a valid phone to the student or linked parent profile, then refresh this lesson or inform an admin.":c||(C="Attendance readiness unavailable. Refresh this lesson or inform an admin."),(0,a.jsxs)("div",{className:"space-y-2 px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:t||"Student"}),(0,a.jsx)("div",{className:"shrink-0",children:y?(0,a.jsxs)(E.E,{className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:[(0,a.jsx)(es.A,{className:"mr-1 h-3 w-3","aria-hidden":"true"}),"Confirmed"]}):b?(0,a.jsx)(E.E,{variant:"secondary",children:"Expired"}):(0,a.jsxs)(E.E,{variant:"outline",className:"text-foreground",children:[(0,a.jsx)(et.A,{className:"mr-1 h-3 w-3","aria-hidden":"true"}),"Pending"]})})]}),y&&l.confirmed_at&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Confirmed ",(0,B.r6)(l.confirmed_at),k?` ${k}`:""]}),w&&l.admin_confirmation_reason&&(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Reason: ",l.admin_confirmation_reason]})]}),!y&&!b&&(0,a.jsxs)("div",{className:"space-y-2",children:[C&&(0,a.jsxs)("div",{role:"status","aria-live":"polite",className:"flex items-start gap-2 rounded-md border border-border bg-muted px-2.5 py-2 text-xs text-foreground",children:[(0,a.jsx)(ee.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,a.jsx)("span",{children:C})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(T.$,{variant:"outline",size:"sm",onClick:v,disabled:!c?.canCopy,className:"min-w-0 flex-1","aria-label":t?`Copy attendance link for ${t}`:"Copy attendance link",children:[(0,a.jsx)(_.A,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":"true"}),(0,a.jsx)("span",{className:"truncate",children:h?"Copied":t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"sm:hidden",children:"Copy link"}),(0,a.jsxs)("span",{className:"hidden sm:inline",children:["Copy ",t,"'s link"]})]}):"Copy attendance link"})]}),(0,a.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:h?`${t?`${t}'s `:""}attendance link copied`:""}),p&&(0,a.jsx)(X.Bc,{delayDuration:200,children:(0,a.jsxs)(X.m_,{children:[(0,a.jsx)(X.k$,{asChild:!0,children:(0,a.jsx)("button",{type:"button",onClick:f,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open WhatsApp to ${t||"student"}`,children:(0,a.jsx)(d(),{src:"/whatsapp-icon.svg",alt:"","aria-hidden":"true",width:19,height:19,className:"inline-block"})})}),(0,a.jsx)(X.ZI,{side:"top",className:"text-xs",children:"WhatsApp Student"})]})}),g&&(0,a.jsx)(X.Bc,{delayDuration:200,children:(0,a.jsxs)(X.m_,{children:[(0,a.jsx)(X.k$,{asChild:!0,children:(0,a.jsx)("button",{type:"button",onClick:j,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open parent WhatsApp for ${t||"student"}`,children:(0,a.jsx)(d(),{src:"/whatsapp-icon-blue.svg",alt:"","aria-hidden":"true",width:19,height:19,className:"inline-block"})})}),(0,a.jsx)(X.ZI,{side:"top",className:"text-xs",children:"WhatsApp Parent"})]})})]})]})]})}var ed=t(7277),ec=t(33325),eo=t(3204),em=t(66874),eu=t(77825),eh=t(45270);let ex={ADMIN:"This lesson should not proceed",PART_TIME_TUTOR:"Please do not conduct this lesson"};var ep=t(16997);function eg({participant:e,fallbackCredits:s,showName:t=!0,isTrialParticipant:n=!1}){let{userRole:r,tutorEmploymentType:i}=(0,eh.A)(),{credits:l,isLoading:d,error:o}=(0,Y.s)({enrollmentId:e.enrollment_id,enabled:!n}),m=l||s||null;if(n)return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[t&&(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:e.full_name||"Student"}),(0,a.jsx)("span",{className:"text-xs font-medium text-green-700 dark:text-green-400",children:"Trial lesson — no credit required"})]});if(d&&!m)return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[t&&(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:e.full_name||"Student"}),(0,a.jsx)(O.c4,{size:"sm"})]});if(o&&!m)return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[t&&(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:e.full_name||"Student"}),(0,a.jsx)("span",{className:"text-xs text-destructive",children:"Unavailable"})]});let u=m?.credit_balance??0,h=m?.warning_level??"zero",x=function(e,s){switch(e){case"negative":return`${Math.abs(s)} over limit`;case"zero":return"No credits remaining";case"critical":return"Last credit";case"low":return"Low balance";default:return null}}(h,u),p=function({userRole:e,tutorEmploymentType:s,creditBalance:t,isTrialParticipant:a=!1}){if(a)return null;let n="ADMIN"===e?"ADMIN":"TUTOR"===e&&"PART_TIME"===s?"PART_TIME_TUTOR":null;return n&&"number"==typeof t&&Number.isFinite(t)&&!(t>0)?{title:"Do not proceed — credit top-up required",description:`The team has informed the parent or student to top up this account. ${ex[n]} while the credit balance is 0 or negative. A lesson that takes the balance below 0 will not be remunerated until the outstanding fees are recovered.`}:null}({userRole:r,tutorEmploymentType:i,creditBalance:m?.credit_balance,isTrialParticipant:n});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[t&&(0,a.jsx)("p",{className:"truncate text-sm font-medium",children:e.full_name||"Student"}),x&&(0,a.jsxs)("p",{className:(0,J.cn)("flex items-center gap-1 text-[11px]",(0,G.Zo)(h)),children:[(0,a.jsx)(c.A,{className:"h-3 w-3","aria-hidden":"true"}),x]})]}),(0,a.jsx)("span",{className:(0,J.cn)("shrink-0 text-lg font-bold",(0,G.Zo)(h)),children:u})]}),p&&(0,a.jsxs)(L.Fc,{variant:"destructive",className:"rounded-none border-x-0 border-b-0",children:[(0,a.jsx)(c.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,a.jsx)(L.XL,{children:p.title}),(0,a.jsx)(L.TN,{children:p.description})]})]})}function ef({participantLesson:e,attendanceLessonIds:s,creditParticipant:t,fallbackCredits:n}){return(0,a.jsxs)("section",{className:"overflow-hidden rounded-md border border-border","aria-label":`${e.student?.full_name||"Student"} attendance and credits`,children:[(0,a.jsx)(el,{scheduledLessonId:e.id,scheduledLessonIds:s,studentName:e.student?.full_name,lessonStatus:e.status,trialOccurrenceStatus:e.trial_occurrence?.status}),t&&(0,a.jsxs)("div",{className:"border-t border-border bg-muted/20",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-2.5 text-xs font-medium text-muted-foreground",children:[(0,a.jsx)(o.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Credits"]}),(0,a.jsx)(eg,{participant:t,fallbackCredits:n,showName:!1,isTrialParticipant:!!e.trial_occurrence})]})]})}function ej({lesson:e,onClose:s,onEdit:t,onCancel:r,onRestore:l,onMarkAttended:G,onAddCourse:Y,onRemoveCourse:X,isRemovingCourse:Q,credits:ee,creditParticipants:es,onBulkCancelByDay:et,recentTransactions:ea,isLoadingCredits:en,creditsError:ei,student:el,parent:ex,enrollmentId:eg,onCreditsUpdated:eN,isAdmin:ev,canManageLesson:ey=!0,sessionId:eb,primaryTutorId:e_,primaryTutorName:ew,onReliefAssignmentChanged:ek,onLessonUpdated:eC,workspace:eA=!1,selectionRevision:e$=0,animateSelection:eS=!1}
1){let eT,[eL,eR]=(0,n.useState)(!1),[eE,ez]=(0,n.useState)(""),[eF,eI]=(0,n.useState)(!1),[eP,eM]=(0,n.useState)(""),[eO,eD]=(0,n.useState)(!1),[eU,eW]=(0,n.useState)(!1),[eZ,eq]=(0,n.useState)(!1),[eB,eG]=(0,n.useState)(!1),[eJ,eY]=(0,n.useState)(!1),[eV,eH]=(0,n.useState)(""),[eK,eX]=(0,n.useState)(!1),[eQ,e0]=(0,n.useState)(!1),[e1,e4]=(0,n.useState)(!1),[e2,e3]=(0,n.useState)(!1),[e5,e6]=(0,n.useState)(!1),[e7,e9]=(0,n.useState)(""),[e8,se]=(0,n.useState)([]),[ss,st]=(0,n.useState)(!1),[sa,sn]=(0,n.useState)(null),[sr,si]=(0,n.useState)(!1),{userRole:sl,user:sd}=(0,eh.A)(),sc=n.useRef(!1),so=n.useRef(new Set),{assignment:sm,allAssignments:su,refresh:sh}=(0,eu._)(eb,e?.scheduled_date??null,e?.scheduled_date,e?.scheduled_date,e?.id??null),sx=(0,n.useCallback)(()=>{sh(),ek?.()},[ek,sh]);(0,n.useEffect)(()=>{eY(!1),eH(""),e3(!1),e6(!1),e9(e?.location||""),ez(""),eM(""),eD(!1),eI(!1)},[e?.id,e?.location]),(0,n.useEffect)(()=>{if(!e2)return;let e=setTimeout(()=>e3(!1),3e3);return()=>clearTimeout(e)},[e2]);let sp=(0,n.useMemo)(()=>(0,ep.MV)(e8).map(e=>({...e,leading:"remote"===e.kind?(0,a.jsx)(m.A,{className:"h-4 w-4","aria-hidden":"true"}):"online-room"===e.kind?(0,a.jsx)(u.A,{className:"h-4 w-4","aria-hidden":"true"}):(0,a.jsx)(h.A,{className:"h-4 w-4","aria-hidden":"true"})})),[e8]),sg=!sa&&sp.some(e=>e.value===e7),sf=(0,n.useCallback)(async()=>{if(!sc.current){sc.current=!0,st(!0),sn(null);try{let e=await fetch("/api/admin/classrooms",{credentials:"include"});if(!e.ok)throw Error("Failed to load classrooms");let s=await e.json();se(s.classrooms||s||[])}catch{se([]),sn("Could not load locations. Retry to choose a room or online location."),sc.current=!1,er.oR.error("Failed to load classrooms")}finally{st(!1)}}},[]),sj=(0,n.useCallback)(()=>{e9(e?.location||""),e6(!0),sf()},[sf,e?.location]),sN=(0,n.useCallback)((e,s)=>{if(s&&s.stopPropagation(),!e)return;let t=(0,U.k_)(e);t&&window.open(`https://wa.me/${t}`,"_blank")},[]),sv=(0,n.useCallback)(async()=>{if(e&&eb){eX(!0);try{let s=await fetch(`/api/admin/school/class-sessions/${eb}/scheduled-lessons/${e.id}/teams-meeting`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({teams_meeting_url:eV.trim()||null})}),t=await s.json();if(!s.ok)throw Error(t.error||"Failed to save Teams link");er.oR.success(eV.trim()?"Teams meeting link saved":"Teams meeting link removed"),eY(!1),eC?.(t.lesson??{teams_meeting_url:eV.trim()||null,teams_meeting_id:null,teams_join_meeting_id:null,teams_meeting_passcode:null})}catch(e){er.oR.error(e instanceof Error?e.message:"Failed to save Teams link")}finally{eX(!1)}}},[e,eC,eb,eV]),sy=(0,n.useCallback)(async s=>{if(e&&eb){e0(!0);try{let t=await fetch(`/api/admin/school/class-sessions/${eb}/scheduled-lessons/${e.id}/teams-meeting`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to generate Teams link");s&&er.oR.success(a.already_exists?"Teams link already exists for this lesson":"Teams meeting link generated"),eC?.(a.lesson??{teams_meeting_url:a.teams_meeting_url,teams_meeting_id:a.teams_meeting_id??e.teams_meeting_id,teams_join_meeting_id:a.teams_join_meeting_id??null,teams_meeting_passcode:a.teams_meeting_passcode??null})}catch(e){s&&er.oR.error(e instanceof Error?e.message:"Failed to generate Teams link")}finally{e0(!1)}}},[e,eC,eb]),sb=(0,n.useCallback)(()=>{sy(!0)},[sy]);(0,n.useEffect)(()=>{!e||!eb||!ey||"scheduled"!==e.status||!function(e,s=function(e=new Date){let s=Object.fromEntries(new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Singapore",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(e).map(e=>[e.type,e.value]));return{date:`${s.year}-${s.month}-${s.day}`,time:`${s.hour}:${s.minute}:${s.second}`}}()){return e.date>s.date||e.date===s.date&&e.endTime>s.time}({date:e.scheduled_date,endTime:e.scheduled_end_time})||(0,ec.I)(e.teams_meeting_url)||so.current.has(e.id)||(so.current.add(e.id),sy(!1))},[ey,sy,e,eb]);let s_=(0,n.useCallback)(async()=>
1{if(e&&eb){e4(!0);try{let s=await fetch(`/api/admin/school/class-sessions/${eb}/scheduled-lessons/${e.id}/teams-meeting`,{method:"DELETE",credentials:"include"}),t=await s.json();if(!s.ok)throw Error(t.error||"Failed to delete Teams link");er.oR.success("Teams meeting link removed"),e3(!1),eC?.(t.lesson??{teams_meeting_url:null,teams_meeting_id:null,teams_join_meeting_id:null,teams_meeting_passcode:null})}catch(e){er.oR.error(e instanceof Error?e.message:"Failed to delete Teams link")}finally{e4(!1)}}},[e,eC,eb]),sw=(0,n.useCallback)(async()=>{if(e&&eb&&!ss&&sg){si(!0);try{let s=e7.trim();if(!s)return void er.oR.error("Location is required");let t=await fetch(`/api/admin/school/class-sessions/${eb}/scheduled-lessons/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({location:s})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to update lesson location");er.oR.success("Lesson location updated"),e6(!1),eC?.(a.lesson??{location:s})}catch(e){er.oR.error(e instanceof Error?e.message:"Failed to update lesson location")}finally{si(!1)}}},[e,e7,ss,sg,eC,eb]),sk=(0,n.useCallback)(async()=>{if(!e)return;let s=eP.trim();if(s){eW(!0);try{let t=e.shared_slot_lessons?.find(e=>"scheduled"===e.status)||e;await G(t.id,s,eO),eI(!1),eM(""),eD(!1)}catch(e){er.oR.error(e instanceof Error?e.message:"Failed to mark lesson as attended")}finally{eW(!1)}}},[e,eP,G,eO]);if(!e)return ey?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(R.Zp,{className:"lg:sticky lg:top-4",children:[(0,a.jsx)(R.aR,{className:"pb-3",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,a.jsxs)(R.ZB,{className:"text-base flex items-center gap-2",children:[(0,a.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"}),"Credit History",el&&(0,a.jsxs)("span",{className:"text-muted-foreground font-normal",children:["— ",el.full_name]})]}),eg&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(T.$,{variant:"outline",size:"sm",onClick:()=>eG(!0),children:[(0,a.jsx)(p.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"History"]}),ev&&(0,a.jsxs)(T.$,{size:"sm",onClick:()=>eq(!0),children:[(0,a.jsx)(g.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Add Credits"]})]})]})}),(0,a.jsxs)(R.Wu,{className:"space-y-4",children:[(el?.phone_number||ex?.phone_number)&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[el?.phone_number&&(0,a.jsxs)("button",{onClick:e=>sN(el.phone_number,e),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 text-green-700 dark:text-green-400 text-sm font-medium transition-colors",title:`WhatsApp Student: ${el.full_name}`,children:[(0,a.jsx)(d(),{src:"/whatsapp-icon.svg",alt:"","aria-hidden":"true",width:16,height:16,className:"inline-block"}),"Student"]}),ex?.phone_number&&(0,a.jsxs)("button",{onClick:e=>sN(ex.phone_number,e),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 text-green-700 dark:text-green-400 text-sm font-medium transition-colors",title:`WhatsApp Parent: ${ex.full_name||"Parent"}`,children:[(0,a.jsx)(d(),{src:"/whatsapp-icon.svg",alt:"","aria-hidden":"true",width:16,height:16,className:"inline-block"}),(0,a.jsx)("span",{children:"Parent"}),(0,a.jsx)("span",{className:"font-mono text-xs",children:ex.phone_number})]})]}),ei?(0,a.jsxs)(L.Fc,{variant:"destructive",children:[(0,a.jsx)(c.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,a.jsx)(L.XL,{children:"Could not load credit history"}),(0,a.jsxs)(L.TN,{className:"space-y-3",children:[(0,a.jsx)("p",{children:ei.message||"Please try again."}),(0,a.jsx)(T.$,{size:"sm",variant:"outline",onClick:eN,children:"Try again"})]})]}):(0,a.jsxs)(a.Fragment,{children:[ee&&(0,a.jsx)("div",{className:(0,J.cn)("rounded-md p-3","negative"===ee.warning_level||"zero"===ee.warning_level?"bg-red-100 dark:bg-red-900/30":"critical"===ee.warning_level?"bg-orange-100 dark:bg-orange-900/30":"low"===ee.warning_level?"bg-yellow-100 dark:bg-yellow-900/30":"bg-green-100 dark:bg-green-900/30"),children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Current Balance"}),(0,a.jsxs)("span",{className:(0,J.cn)("font-bold text-xl","negative"===ee.warning_level||"zero"===ee.warning_level?"text-red-600 dark:text-red-400":"critical"===ee.warning_level?"text-orange-600 dar
1k:text-orange-400":"low"===ee.warning_level?"text-yellow-600 dark:text-yellow-400":"text-green-600 dark:text-green-400"),children:[ee.credit_balance," credits"]})]})}),en?(0,a.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,a.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}):ea&&ea.length>0?(0,a.jsx)(V.z,{transactions:ea,className:"max-h-[calc(100vh-350px)]",studentName:el?.full_name,currentBalance:ee?.credit_balance,showTopUpDetails:!!ev}):(0,a.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"No credit transactions yet"})]}),!eA&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t",children:"Click a lesson on the calendar to view details"})]})]}),eg&&el&&(0,a.jsx)(H.S,{open:eZ,onOpenChange:eq,enrollmentId:eg,studentName:el.full_name,currentBalance:ee?.credit_balance??0,onSuccess:()=>{eq(!1),eN?.()}}),eg&&el&&(0,a.jsx)(K.U,{open:eB,onOpenChange:eG,enrollmentId:eg,studentName:el.full_name,isAdmin:ev})]}):(0,a.jsx)(R.Zp,{className:"lg:sticky lg:top-4",children:(0,a.jsxs)(R.Wu,{className:"py-12 text-center text-muted-foreground",children:[(0,a.jsx)(x.A,{className:"mx-auto mb-3 h-8 w-8 opacity-60","aria-hidden":"true"}),(0,a.jsx)("p",{className:"text-sm",children:"Select an assigned lesson to view details"})]})});let sC=q.FJ[e.status],sA="scheduled"===e.status,s$="conducted"===e.status,sS="cancelled"===e.status,sT=e.shared_slot_lessons?.length?e.shared_slot_lessons:[e],sL=sT.filter(W.sT),sR=sL.map(e=>e.id),sE=sT.find(e=>"scheduled"===e.status)||e,sz=sT.filter(e=>"scheduled"===e.status),sF=sT.some(e=>"conducted"===e.status),sI=sT.filter(e=>"cancelled"===e.status),sP=sL.length>1,sM=sz.length>1,sO=sI.length>1,sD=sz.map(e=>e.student?.full_name||"Unknown Student"),sU=es?.length?es:eg?[{id:e.student_id,enrollment_id:eg,full_name:el?.full_name||null}]:[],sW=new Map(sU.map(e=>[e.id,e])),sZ=[...new Map(sL.flatMap(e=>e.lesson_courses||[]).map(e=>[e.course_id,e])).values()],sq=(0,W.sT)(e)&&sL.length>0,sB=ey&&sq,sG=new Set(sL.map(e=>e.id)),sJ=!!("TUTOR"===sl&&sd?.id&&su.some(e=>e.relief_tutor_id===sd.id&&"CANCELLED"!==e.status&&null!==e.scheduled_lesson_id&&sG.has(e.scheduled_lesson_id))),sY=(ey||sJ)&&sq,sV=(0,ec.I)(e.teams_meeting_url),sH=(0,em.c)(e.conducted_lesson?.recording_url);return(0,a.jsxs)(R.Zp,{className:eA?"min-w-0 border-primary/50":"lg:sticky lg:top-4",children:[(0,a.jsx)(R.aR,{className:eA?"border-b border-primary/30 bg-card p-4 sm:p-5":"pb-3",children:(0,a.jsx)("div",{className:"flex items-start justify-between",children:eA?(0,a.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-primary/40 bg-primary/10 text-sm font-semibold text-primary",children:"2"}),(0,a.jsx)("p",{className:"text-base font-semibold",children:"Selected Lesson Details"})]}),(0,a.jsxs)("div",{"data-testid":"lesson-heading-transition",className:(0,J.cn)("space-y-2",eS&&i().selectionReveal),children:[(0,a.jsxs)("h2",{className:"text-xl font-semibold leading-tight sm:text-2xl",children:[new Date(`${e.scheduled_date}T00:00:00`).toLocaleDateString("en-SG",{weekday:"long"}),", ",(0,B.Yq)(e.scheduled_date)]}),(0,a.jsxs)("p",{className:"text-sm font-medium",children:[(0,q.fU)(e.scheduled_start_time)," – ",(0,q.fU)(e.scheduled_end_time),(0,a.jsxs)("span",{className:"ml-2 font-normal",children:["(",e.duration_minutes," min)"]})]})]},`${e.id}:${e$}`)]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(R.ZB,{className:"text-base",children:"Lesson Details"}),(0,a.jsx)(T.$,{variant:"ghost",size:"icon",onClick:s,"aria-label":"Close",children:(0,a.jsx)(f.A,{className:"h-4 w-4","aria-hidden":"true"})})]})})}),(0,a.jsxs)(R.Wu,{className:eA?"space-y-4 p-4 sm:p-5":"space-y-4",children:[(0,a.jsxs)(E.E,{className:sC,children:[q.ww[e.status],e.is_recurring_instance&&" (Recurring)"]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:eA?"hidden":"flex items-center gap-2 text-sm",children:[(0,a.jsx)(j.A,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:"font-medium",children:(0,B.Yq)(e.scheduled_date)})]}),(0,a.jsxs)("div",{className:eA?"hidden":"flex items-center gap-2 text-sm",children:[(0,a.jsx)(N.A,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),(0,a.jsxs)("span",{children:[(0,q.fU)(e.scheduled_start_time)," - ",(0,q.fU)(e.scheduled_end_time)]}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:["(",e.duration_minutes," min)"]})]}),(0,a.jsx)("div",{className:"space-y-2",children:e5?(0,a.jsxs)("div",{className:"rounded-md border border-border bg-muted/30 p-3 space-y-2",children:[(0,a.jsx)(I.J,{className:"text-xs text-muted-foreground",children:"Lesson location override"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(D.q,{"aria-label":"Lesson location override",value:sg?e7:"",onValueChange:e9,options:sp,placeholder:ss?"Loading locations…":"Select location",searchPlaceholder:"Search locations…",emptyMessage:"No locations foun
1d",loading:ss,disabled:ss||!!sa||sr,className:"min-w-0 flex-1"}),(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:sw,disabled:sr||ss||!sg,className:"h-9 w-9 p-0 shrink-0","aria-label":"Save lesson location",children:sr?(0,a.jsx)(O.c4,{size:"sm"}):(0,a.jsx)(v.A,{className:"h-4 w-4 text-primary","aria-hidden":"true"})}),(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:()=>{e6(!1),e9(e.location||"")},disabled:sr,className:"h-9 w-9 p-0 shrink-0","aria-label":"Cancel editing lesson location",children:(0,a.jsx)(f.A,{className:"h-4 w-4","aria-hidden":"true"})})]}),sa&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:sa}),e7&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Saved location: ",e7]}),(0,a.jsx)(T.$,{type:"button",variant:"outline",size:"sm",onClick:sf,children:"Retry locations"})]}),!ss&&sc.current&&e7&&!sg&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",role:"status",children:["Saved location “",e7,"” is not a current option. Select a room or online location."]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"This change applies only to this lesson, not the recurring schedule."})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(h.A,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:(0,J.cn)(!e.location&&"text-muted-foreground"),children:(0,ep.Ee)(e.location)||"No lesson location set"}),ey&&sA&&eb&&(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:sj,className:"ml-auto h-7 w-7 p-0 shrink-0","aria-label":"Edit lesson location",children:(0,a.jsx)(y.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]}),eb&&(sA||sm)&&(0,a.jsx)("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:(0,a.jsx)(ed.A,{classSessionId:eb,lessonDate:e.scheduled_date,primaryTutorId:e_||null,primaryTutorName:ew||null,sessionStartTime:e.scheduled_start_time,sessionEndTime:e.scheduled_end_time,assignment:sm,isAdmin:!!ev,scheduledLessonId:e.id,onChange:sx})}),eb&&(ey||sV||sA)&&(sA||sV||eJ)&&(0,a.jsx)("div",{className:"space-y-2",children:eJ?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(I.J,{htmlFor:"one-to-one-teams-url",className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[(0,a.jsx)(u.A,{className:"h-3.5 w-3.5 text-primary","aria-hidden":"true"}),"Teams Meeting Link"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(F.p,{id:"one-to-one-teams-url",value:eV,onChange:e=>eH(e.target.value),placeholder:"https://teams.microsoft.com/l/meetup-join/...",className:"text-sm",disabled:eK}),(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:sv,disabled:eK,className:"h-9 w-9 p-0 shrink-0","aria-label":"Save Teams meeting link",children:eK?(0,a.jsx)(O.c4,{size:"sm"}):(0,a.jsx)(v.A,{className:"h-4 w-4 text-primary","aria-hidden":"true"})}),(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:()=>eY(!1),disabled:eK,className:"h-9 w-9 p-0 shrink-0","aria-label":"Cancel editing Teams meeting link",children:(0,a.jsx)(f.A,{className:"h-4 w-4","aria-hidden":"true"})})]})]}):sV?(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 p-2 bg-primary/10 rounded-md",children:[(0,a.jsx)(u.A,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":"true"}),(0,a.jsxs)("a",{href:sV,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate flex items-center gap-1",children:["Join Online Live Lesson",(0,a.jsx)(b.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto shrink-0",children:[(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(sV).then(()=>er.oR.success("Meeting link copied")).catch(()=>er.oR.error("Failed to copy to clipboard"))},className:"h-7 w-7 p-0","aria-label":"Copy Teams meeting link",children:(0,a.jsx)(_.A,{className:"h-3 w-3","aria-hidden":"true"})}),sA&&ey&&(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:()=>{eH(sV),eY(!0)},className:"h-7 w-7 p-0","aria-label":"Edit Teams meeting link",children:(0,a.jsx)(y.A,{className:"h-3 w-3","aria-hidden":"true"})}),sA&&ey&&(0,a.jsx)(T.$,{variant:"ghost",size:"sm",onClick:()=>{e2?s_():e3(!0)},disabled:e1,className:`h-7 p-0 ${e2?"w-auto px-1.5 bg-destructive/10 text-destructive":"w-7 text-muted-foreground hover:text-destructive"}`,"aria-label":e2?"Confirm delete Teams meeting link":"Delete Teams meeting link",children:e1?(0,a.jsx)(O.c4,{size:"sm"}):e2?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w.A,{className:"h-3 w-3 mr-1","aria-hidden":"true"}),(0,a.jsx)("span",{className:"text-xs",children:"Delete?"})]}):(0,a.jsx)(w.A,{className:"h-3 w-3","aria-hidden":"true"})})]})]}),(e.teams_join_meeting_id||e.teams_meeting_passcode)&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-2 text-xs text-muted-foreground",children:[e.teams_join_meeting_id&&(0,a.jsxs)("span",{children:["Meeting ID: ",(0,a.jsx)("span",{className:"font-mono font-medium text-foreground",children:e.teams_join_meeting_id})]}),e.teams_meeting_passcode&&(0,a.jsxs)("span",{children:["Passcode: ",(0,a.jsx)("span",{className:"font-mono font-medium text-foreground",children:e.teams_meeting_passcode})]}),(0,a.jsxs)(T.$,{variant:"ghost",size:"sm",onClick:()=>{let s=[`Teams Meeting Link: ${sV}`];e.teams_join_meeting_id&&s.push(`Meeting ID: ${e.teams_join_meeting_id}`),e.teams_meeting_passcode&&s.push(`Passcode: ${e.teams_meeting_passcode}`),navigator.clipboard.writeText(s.join("\n")).then(()=>er.oR.success("Meeting details copied")).catch(()=>er.oR.error("Failed to copy to clipboard"))},className:"h-6 px-1.5 py-0 text-xs ml-auto shrink-0","aria-label":"Copy all meeting details",children:[(0,a.jsx)(x.A,{className:"h-3 w-3 mr-1","aria-hidden":"true"}),"Copy All"]})]})]}):ey?(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsxs)(T.$,{variant:"ghost",size:"sm",onClick:sb,disabled:eQ,className:"w-full gap-1.5 text-primary hover:text-primary hover:bg-primary/10 justify-center",title:"Auto-generate a Teams meeting link via Microsoft Graph API",children:[eQ?(0,a.jsx)(O.c4,{size:"sm"}):(0,a.jsx)(k.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Generate Teams Link"]}),(0,a.jsxs)(T.$,{variant:"ghost",size:"sm",onClick:()=>{eH(""),eY(!0)},className:"w-full gap-1.5 text-muted-foreground hover:text-primary hover:bg-primary/10 justify-center",children:[(0,a.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Paste Link"]})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm text-muted-foreground",children:[(0,a.jsx)(u.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,a.jsx)("span",{children:"No Teams link added"})]})}),(0,a.jsx)(z.w,{}),(e.topic_title||e.topic?.name)&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(C.A,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:"font-medium",children:e.topic_title||e.topic?.name})]}),e.topic_description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground pl-6",children:e.topic_description})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("span",{className:"text-sm font-medium",children:["Courses",sZ.length?` (${sZ.length})`:""]})}),sZ.length>0?(0,a.jsx)("div",{className:"space-y-1.5",children:sZ.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/50",children:[(0,a.jsx)(A.A,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0","aria-hidden":"true"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e.course.title}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground capitalize",children:e.course.course_type?.replace("_"," ")})]}),sB&&(0,a.jsx)(T.$,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-destructive",onClick:()=>X(e.course_id),disabled:Q,children:Q?"...":"Remove"})]},e.id))}):sY?null:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"No courses attached"}),sY&&(0,a.jsxs)(T.$,{id:"add-course-to-lesson-button",variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:Y,children:[(0,a.jsx)(g.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Add Course"]})]}),e.conducted_lesson&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.w,{}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Conducted on"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:(0,B.Yq)(e.conducted_lesson.actual_date)}),sH&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"rounded-md overflow-hidden border border-border",children:(0,a.jsx)(eo.VideoPlayer,{videoUrl:sH,autoplay:!1,showInstructor:!1})}),(0,a.jsx)(T.$,{variant:"outline",size:"sm",asChild:!0,children:(0,a.jsxs)("a",{href:sH,target:"_blank",rel:"noopener",children:[(0,a.jsx)(b.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Open Recording"]})})]})]})]}),sL.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.w,{}),(0,a.jsxs)("section",{className:"space-y-2","aria-labelledby":"attendance-confirmation-heading",children:[(0,a.jsx)("h3",{id:"attendance-confirmation-heading",className:"text-sm font-medium",children:sP?"Participants":"Attendance Confirmation"}),(0,a.jsx)("div",{className:"space-y-3",children:sL.map(s=>(0,a.jsx)(ef,{participantLesson:s,attendanceLessonIds:sR,creditParticipant:ey?sU.find(e=>e.enrollment_id===s.enrollment_id)||sW.get(s.student_id)||sU.find(e=>e.full_name===s.student?.full_name):void 0,fallbackCredits:s.id===e.id?ee:null},s.id))}),(0,a.jsxs)("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:["Copy a link, then open the student or parent WhatsApp chat and paste it. They'll verify their phone and confirm; a receipt email is sent automatically.","TUTOR"===sl&&sL.some(e=>!!e.trial_occurrence)&&" If a trial student is absent, inform an admin."]})]})]}),"cancelled"===e.status&&e.cancellation_reason&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.w,{}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Cancellation Reason"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.cancellation_reason})]})]}),"rescheduled"===e.status&&e.rescheduled_to&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.w,{}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-amber-600",children:"Rescheduled to"}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,B.Yq)(e.rescheduled_to.scheduled_date)," at"," ",(0,q.fU)(e.rescheduled_to.scheduled_start_time)]})]})]}),ey&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.w,{}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[sA&&(0,a.jsxs)(a.Fragment,{children:[ev&&sz.length>0&&(0,a.jsxs)(T.$,{variant:"outline",onClick:()=>eI(!0),className:"w-full text-green-700 hover:text-green-800 hover:bg-green-50 dark:text-green-400 dark:hover:text-green-300 dark:hover:bg-green-950",children:[(0,a.jsx)(x.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),sM?"Mark Shared Lesson Attended":"Mark Attended"]}),!sF&&(0,a.jsxs)(T.$,{variant:"outline",onClick:t,className:"w-full",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),sP?"Edit Shared Lesson":"Edit"]}),!sF&&(0,a.jsxs)(T.$,{variant:"outline",onClick:()=>eR(!0),className:"w-full text-red-700 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[(0,a.jsx)($,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),sM?"Cancel Shared Lesson":"Cancel Lesson"]}),!sF&&e.is_recurring_instance&&et&&(eT=new Date(e.scheduled_date+"T00:00:00Z").getUTCDay(),(0,a.jsxs)(T.$,{variant:"outline",onClick:()=>et(eT,e.scheduled_date),className:"w-full text-red-700 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[(0,a.jsx)($,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Cancel All ",q.KP[eT]," Lessons"]}))]}),s$&&(0,a.jsxs)(T.$,{variant:"outline",onClick:t,className:"w-full",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"View Details"]}
1),sS&&(0,a.jsxs)(T.$,{variant:"outline",onClick:()=>l(e.id),className:"w-full text-green-600 hover:text-green-700 hover:bg-green-50 dark:text-green-400 dark:hover:text-green-300 dark:hover:bg-green-950",children:[(0,a.jsx)(S.A,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),sO?"Restore Shared Lesson":"Restore Lesson"]})]})]}),(0,a.jsx)(Z.Lt,{open:eL,onOpenChange:eR,children:(0,a.jsxs)(Z.EO,{children:[(0,a.jsxs)(Z.wd,{children:[(0,a.jsxs)(Z.r7,{children:["Cancel ",sM?"this shared lesson":"this lesson","?"]}),(0,a.jsxs)(Z.$v,{children:["Are you sure you want to cancel the lesson on"," ",(0,a.jsx)("span",{className:"font-medium text-foreground",children:(0,B.Yq)(e.scheduled_date)})," ","at"," ",(0,a.jsx)("span",{className:"font-medium text-foreground",children:(0,q.fU)(e.scheduled_start_time)}),"? You can restore it later if needed.",sM&&(0,a.jsxs)(a.Fragment,{children:[" This will cancel the lesson for ",sD.join(" and "),"."]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(I.J,{htmlFor:"cancel-reason",children:"Reason"}),(0,a.jsx)(P.T,{id:"cancel-reason",value:eE,onChange:e=>ez(e.target.value),placeholder:"Optional cancellation reason",rows:3,maxLength:500})]}),(0,a.jsxs)(Z.ck,{children:[(0,a.jsx)(Z.Zr,{children:"Keep Lesson"}),(0,a.jsxs)(Z.Rx,{onClick:()=>{r(sE.id,eE.trim()||void 0),eR(!1),ez("")},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:["Yes, Cancel ",sM?"Shared Lesson":"Lesson"]})]})]})}),(0,a.jsx)(Z.Lt,{open:eF,onOpenChange:e=>{!eU&&(eI(e),e||(eM(""),eD(!1)))},children:(0,a.jsxs)(Z.EO,{children:[(0,a.jsxs)(Z.wd,{children:[(0,a.jsx)(Z.r7,{children:sM?"Mark Shared Lesson Attended?":"Mark lesson attended?"}),(0,a.jsxs)(Z.$v,{children:["This will finalize attendance for"," ",(0,a.jsx)("span",{className:"font-medium text-foreground",children:(0,B.Yq)(e.scheduled_date)})," ",sM?`for ${sz.map(e=>e.student?.full_name||"Student").join(" and ")}. Each remaining participant is processed together; if one fails, none are changed.`:e.trial_occurrence?". No lesson credit will be deducted for this trial.":"and apply the student credit rules."]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(I.J,{htmlFor:"manual-attendance-reason",children:"Reason"}),(0,a.jsx)(P.T,{id:"manual-attendance-reason",value:eP,onChange:e=>eM(e.target.value),placeholder:"Why is this lesson being marked attended manually?",rows:3,maxLength:500,disabled:eU})]}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(M.S,{checked:eO,onCheckedChange:e=>eD(!0===e),disabled:eU}),"Send receipt email to each participant"]})]}),(0,a.jsxs)(Z.ck,{children:[(0,a.jsx)(Z.Zr,{disabled:eU,children:"Cancel"}),(0,a.jsx)(T.$,{onClick:sk,disabled:!eP.trim()||eU,children:eU?"Saving...":sM?"Mark Shared Lesson Attended":"Mark Attended"})]})]})})]})]})}let eN=ej},71442:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(92949).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},80504:(e,s,t)=>{"use strict";t.d(s,{w:()=>l});var a=t(37876),n=t(14232),r=t(64503),i=t(1773);let l=n.forwardRef(({className:e,orientation:s="horizontal",decorative:t=!0,...n},l)=>(0,a.jsx)(r.b,{ref:l,decorative:t,orientation:s,className:(0,i.cn)("shrink-0 bg-border","horizontal"===s?"h-[1px] w-full":"h-full w-[1px]",e),...n}));l.displayName=r.b.displayName},98057:(e,s,t)=>{"use strict";t.d(s,{FL:()=>d,G_:()=>c,K_:()=>m,WG:()=>o,XD:()=>u,k_:()=>h});let a=[{code:"+65",country:"Singapore",example:"91234567"},{code:"+60",country:"Malaysia",example:"12 345 6789"},{code:"+61",country:"Australia",example:"478 963 738"},{code:"+852",country:"Hong Kong",example:"9123 4567"},{code:"+886",country:"Taiwan",example:"912 345 678"},{code:"+673",country:"Brunei",example:"712 3456"},{code:"+62",country:"Indonesia",example:"812 3456 7890"},{code:"+63",country:"Philippines",example:"917 123 4567"},{code:"+66",country:"Thailand",example:"81 234 5678"},{code:"+84",country:"Vietnam",example:"912 345 678"},{code:"+91",country:"India",example:"98765 43210"},{code:"+86",country:"China",example:"138 0013 8000"}
1,{code:"+81",country:"Japan",example:"90 1234 5678"},{code:"+82",country:"South Korea",example:"10 1234 5678"},{code:"+64",country:"New Zealand",example:"21 123 4567"},{code:"+44",country:"United Kingdom",example:"7400 123456"},{code:"+1",country:"US / Canada",example:"415 555 0199"}].map(e=>e.code.replace(/\D/g,"")),n=(e,s)=>Array.from({length:s-e+1},(s,t)=>String(e+t)),r=Array.from(new Set([...a,"7","20","27","30","31","32","33","34","36","39","40","41","43","45","46","47","48","49",...n(51,58),...n(60,66),...n(81,86),...n(90,98),...n(211,213),"216","218",...n(220,239),...n(240,249),...n(250,258),...n(260,269),...n(290,299),...n(350,359),...n(370,389),...n(420,423),...n(500,509),...n(590,599),...n(670,679),...n(680,689),...n(690,699),...n(850,859),...n(870,879),...n(880,889),...n(960,969),...n(970,979),...n(992,999)])).sort((e,s)=>s.length-e.length);function i(e){return(e||"").replace(/\D/g,"")}function l(e){return e.trim().replace(/^00/,"+")}function d(e){return i(e)}function c(e,s="+65"){if(!e||"string"!=typeof e)return null;let t=l(e);if(!t)return null;let a=t.startsWith("+"),n=i(t);if(!n)return null;if(a||r.find(e=>n.startsWith(e)&&n.length>=e.length+8))return n.length>=8&&n.length<=15?`+${n}`:null;let d=i(s||"+65")||"65";"65"!==d&&n.startsWith("0")&&(n=n.replace(/^0+/,""));let o=`${d}${n}`;return o.length>=8&&o.length<=15?`+${o}`:null}function o(e,s){let t=i(s);if(!t)return null;let a=i(e||"+65")||"65",n="65"===a?t:t.replace(/^0+/,""),r=`${a}${n}`;return r.length>=8&&r.length<=15?`+${r}`:null}function m(e,s="+65"){let t=c(e,s);if(!t)return{countryCode:s,localNumber:e||""};let a=i(t),n=r.find(e=>a.startsWith(e));if(!n){if("string"==typeof e&&l(e).startsWith("+")&&a.length>8){let e=Math.min(3,Math.max(1,a.length-8)),s=a.slice(0,e);return{countryCode:`+${s}`,localNumber:a.slice(e)}}return{countryCode:s,localNumber:a}}return{countryCode:`+${n}`,localNumber:a.slice(n.length)}}function u(e){return null!==c(e)}function h(e){let s=c(e);return s?i(s):null}}}]);

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.