1import{c as Te,h as T,X as te,b as se,a as q,_ as O,B as R,p as Re}from"./index-CVuSjWCq.js";import{a as c,j as e}from"./query-vendor-BB0JUlq_.js";import{t as Fe,a as De,P as H,y as ke,v as Ee,I as Oe,c as K,b as Le,f as Ae,w as ae,r as $e,m as ze,n as ne,p as Me,T as re,o as ie,O as oe}from"./ui-vendor-CwH6wFZJ.js";import{L as Ue,D as Ve}from"./DiscussionFeed-DgfaxC1r.js";import{C as Be}from"./ChatsPanel-fiT1dbtl.js";import{C as Ge}from"./card-COxgaMnN.js";import{apiFetch as Ye}from"./api-CyvozDRd.js";import{Z as We,R as He}from"./zoom-in-Ds9-Y-UM.js";import{N as Je}from"./NotificationBell-DrucT7Pa.js";import{d as Ze,b as ee}from"./react-vendor-BIjsaQ6L.js";const Ke=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],qe=Te("upload",Ke);var J="Tabs",[Xe]=Ae(J,[ae]),le=ae(),[Qe,X]=Xe(J),ce=c.forwardRef((r,n)=>{const{__scopeTabs:o,value:l,onValueChange:f,defaultValue:j,orientation:p="horizontal",dir:b,activationMode:w="automatic",...u}=r,x=Fe(b),[d,y]=De({prop:l,onChange:f,defaultProp:j??"",caller:J});return e.jsx(Qe,{scope:o,baseId:ke(),value:d,onValueChange:y,orientation:p,dir:x,activationMode:w,children:e.jsx(H.div,{dir:x,"data-orientation":p,...u,ref:n})})});ce.displayName=J;var de="TabsList",ue=c.forwardRef((r,n)=>{const{__scopeTabs:o,loop:l=!0,...f}=r,j=X(de,o),p=le(o);return e.jsx(Ee,{asChild:!0,...p,orientation:j.orientation,dir:j.dir,loop:l,children:e.jsx(H.div,{role:"tablist","aria-orientation":j.orientation,...f,ref:n})})});ue.displayName=de;var me="TabsTrigger",pe=c.forwardRef((r,n)=>{const{__scopeTabs:o,value:l,disabled:f=!1,...j}=r,p=X(me,o),b=le(o),w=ge(p.baseId,l),u=he(p.baseId,l),x=l===p.value;return e.jsx(Oe,{asChild:!0,...b,focusable:!f,active:x,children:e.jsx(H.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":u,"data-state":x?"active":"inactive","data-disabled":f?"":void 0,disabled:f,id:w,...j,ref:n,onMouseDown:K(r.onMouseDown,d=>{!f&&d.button===0&&d.ctrlKey===!1?p.onValueChange(l):d.preventDefault()}),onKeyDown:K(r.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&p.onValueChange(l)}),onFocus:K(r.onFocus,()=>{const d=p.activationMode!=="manual";!x&&!f&&d&&p.onValueChange(l)})})})});pe.displayName=me;var fe="TabsContent",xe=c.forwardRef((r,n)=>{const{__scopeTabs:o,value:l,forceMount:f,children:j,...p}=r,b=X(fe,o),w=ge(b.baseId,l),u=he(b.baseId,l),x=l===b.value,d=c.useRef(x);return c.useEffect(()=>{const y=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(Le,{present:f||x,children:({present:y})=>e.jsx(H.div,{"data-state":x?"active":"inactive","data-orientation":b.orientation,role:"tabpanel","aria-labelledby":w,hidden:!y,id:u,tabIndex:0,...p,ref:n,style:{...r.style,animationDuration:d.current?"0s":void 0},children:y&&j})})});xe.displayName=fe;function ge(r,n){return`${r}-trigger-${n}`}function he(r,n){return`${r}-content-${n}`}var et=ce,be=ue,ve=pe,je=xe;const tt=et,ye=c.forwardRef(({className:r,...n},o)=>e.jsx(be,{ref:o,className:T("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",r),...n}));ye.displayName=be.displayName;const G=c.forwardRef(({className:r,...n},o)=>e.jsx(ve,{ref:o,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",r),...n}));G.displayName=ve.displayName;const Y=c.forwardRef(({className:r,...n},o)=>e.jsx(je,{ref:o,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",r),...n}));Y.displayName=je.displayName;const st=$e,at=ze,Ne=c.forwardRef(({className:r,...n},o)=>e.jsx(oe,{ref:o,className:T("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r),...n}));
1Ne.displayName=oe.displayName;const we=c.forwardRef(({className:r,children:n,...o},l)=>e.jsxs(at,{children:[e.jsx(Ne,{}),e.jsxs(ne,{ref:l,className:T("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",r),...o,children:[n,e.jsxs(Me,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));we.displayName=ne.displayName;const _e=({className:r,...n})=>e.jsx("div",{className:T("flex flex-col space-y-1.5 text-center sm:text-left",r),...n});_e.displayName="DialogHeader";const Ie=({className:r,...n})=>e.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",r),...n});Ie.displayName="DialogFooter";const Pe=c.forwardRef(({className:r,...n},o)=>e.jsx(re,{ref:o,className:T("text-lg font-semibold leading-none tracking-tight",r),...n}));Pe.displayName=re.displayName;const Ce=c.forwardRef(({className:r,...n},o)=>e.jsx(ie,{ref:o,className:T("text-sm text-muted-foreground",r),...n}));Ce.displayName=ie.displayName;function nt(r){return new Promise((n,o)=>{const l=new FileReader;l.onload=()=>n(l.result.split(",")[1]),l.onerror=o,l.readAsDataURL(r)})}async function rt(r){return new Promise((n,o)=>{const l=URL.createObjectURL(r),f=document.createElement("video");f.preload="metadata",f.src=l,f.onloadedmetadata=()=>{URL.revokeObjectURL(l),n(f.duration||0)},f.onerror=j=>{URL.revokeObjectURL(l),o(j)}})}function it(r){const n=new DataTransfer;return r.forEach(o=>n.items.add(o)),n.files}function ot({className:r}){const[n,o]=c.useState([]),[l,f]=c.useState(null),[j,p]=c.useState([]),[b,w]=c.useState(null),u=c.useRef(null),{toast:x}=se(),{user:d}=q(),[y,F]=c.useState(null),[L,m]=c.useState(null),[N,A]=c.useState(!1),[D,k]=c.useState([]),M=c.useRef(null);c.useEffect(()=>{(async()=>{try{const s=await(await O(async()=>{const{apiFetch:g}=await import("./api-CyvozDRd.js");return{apiFetch:g}},[])).apiFetch("/api/admin/students"),i=Array.isArray(s)?s:s&&s.rows?
1s.rows:[];if(d&&d.role==="student"){const g=i.find(P=>P.user_id===d.id);g?(o([g]),f(g.student_id||g.id||null)):(o([]),f(null))}else o(i),i.length&&f(i[0].student_id||i[0].id||null)}catch(s){console.error(s),o([])}})()},[d]),c.useEffect(()=>{if(!l){p([]),w(null);return}(async()=>{try{const s=await(await O(async()=>{const{apiFetch:g}=await import("./api-CyvozDRd.js");return{apiFetch:g}},[])).apiFetch(`/api/admin/learning/${l}`),i=Array.isArray(s)?s:s&&s.rows?s.rows:[];i.sort((g,P)=>{const E=g.created_at?new Date(g.created_at).getTime():0;return(P.created_at?new Date(P.created_at).getTime():0)-E}),p(i)}catch(s){console.error(s),p([])}})(),(async()=>{try{if(!l){w(null);return}const s=new Date,i=new Date(s);i.setDate(i.getDate()-7);const g=new Date(s);g.setDate(g.getDate()+90);const P=i.toISOString().split("T")[0],E=g.toISOString().split("T")[0],C=(await(await O(async()=>{const{apiFetch:S}=await import("./api-CyvozDRd.js");return{apiFetch:S}},[])).apiFetch(`/api/public/available-lessons/${P}/${E}`))?.lessons||[],W=[];for(const S of C)if((Array.isArray(S.studentIds)?S.studentIds:[]).includes(l))for(const B of S.occurrences||[])W.push({id:`${S.id}-${B.date}T${B.time}`,student_id:l,created_at:B.dateTime});const V=W.sort((S,Q)=>{const B=t(S),Se=t(Q);return B-Se}).filter(S=>t(S)>=s.getTime())[0];w(V||null)}catch(s){console.error(s),w(null)}})()},[l,d]);async function $(s){if(!(!s||!l))try{const g=Array.from(s).filter(C=>C.size>38797312);if(g.length>0)throw new Error(`${g.length} file(s) exceed 37MB limit: ${g.map(C=>C.name).join(", ")}`);const P=[];for(const C of Array.from(s)){if(C.type.startsWith("video")&&await rt(C)>180)throw new Error("Video too long. Maximum allowed is 3 minutes.");const W=await nt(C),V=await(await O(async()=>{const{apiFetch:S}=await import("./api-CyvozDRd.js");return{apiFetch:S}},[])).apiFetch("/api/admin/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:C.name,data:W})});if(!V||typeof V=="string")throw new Error("Upload failed");P.push({id:V.id,url:V.url,mime:C.type})}const E=await(await O(async()=>{const{apiFetch:C}=await import("./api-CyvozDRd.js");return{apiFetch:C}},[])).apiFetch(`/api/admin/learning/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Resources",description:"",media:P})}),Z=Array.isArray(E)?E:E&&E.rows?E.rows:[];p(Z),x({title:"Resources uploaded"})}catch(i){x({title:"Upload failed",description:i?.message||"Unable to upload resources"})}}function t(s){const i=s.start_time||s.created_at||"";return i?new Date(i).getTime():Number.POSITIVE_INFINITY}function a(){return n.length?e.jsx("div",{className:"mt-2 space-y-2",children:n.map(s=>{const i=s.student_id||s.id,g=l===i;return e.jsxs("div",{className:T("w-full rounded border p-2 flex items-center justify-between transition-colors",g?"bg-muted":"bg-background"),children:[e.jsxs("button",{type:"button",onClick:()=>f(i||null),className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium",children:s.name||s.email}),e.jsx("div",{className:"text-sm text-foreground/70",children:s.email})]}),d?.role==="admin"&&e.jsx("div",{className:"ml-3 flex-shrink-0",children:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>{f(i||null),k([]),A(!0)},children:"Upload material"})})]},i)})}):e.jsx("p",{className:"text-sm text-foreground/70",children:"No student records found for your account yet."})}function h(){return j.length?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:j.map(s=>e.jsxs("article",{className:"rounded border p-3",children:[e.jsxs("header",{className:"flex flex-col gap-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:s.title||"Resource"}),s.created_at&&e.jsx("time",{dateTime:s.created_at,className:"text-xs text-foreground/70",children:new Date(s.created_at).toLocaleString()})]}),s.media&&s.media.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:s.media.map(i=>e.jsx("div",{children:i.mime?.startsWith("video")?e.jsx("button",{type:"button",className:"block w-full h-40 overflow-hidden rounded",onClick:()=>{F(i.url),m(i.mime||null)},children:e.jsx("video",{src:i.url,className:"h-40 w-full object-cover","aria-hidden":!0})}
1):i.mime?.startsWith("image")?e.jsx("button",{type:"button",className:"block w-full h-40 overflow-hidden rounded",onClick:()=>{F(i.url),m(i.mime||null)},children:e.jsx("img",{src:i.url,alt:"resource",className:"h-40 w-full object-cover"})}):e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block text-sm font-medium text-primary underline",children:["Download ",i.mime?.split("/")[1]||"file"]})},i.id||i.url))})]},s.id))}):e.jsx("div",{className:"rounded border border-dashed p-6 text-center text-sm text-foreground/70",children:"No learning resources uploaded yet."})}function v(s){s.preventDefault();const i=s.dataTransfer;if(!i||!i.files)return;const g=Array.from(i.files);k(P=>[...P,...g])}function _(s){s.preventDefault()}function I(s){if(!s)return;const i=s.target.files;i&&(k(g=>[...g,...Array.from(i)]),s.target.value="")}function U(s){k(i=>i.filter((g,P)=>P!==s))}async function z(){if(!D.length||!l)return;const s=it(D);await $(s),k([]),A(!1)}return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{src:y,mime:L,onClose:()=>{F(null),m(null)}}),e.jsx(st,{open:N,onOpenChange:A,children:e.jsxs(we,{children:[e.jsxs(_e,{children:[e.jsx(Pe,{children:"Upload material"}),e.jsx(Ce,{children:"Drag and drop files here or click select. Videos must be 3 minutes or shorter."})]}),e.jsxs("div",{onDrop:v,onDragOver:_,className:"mt-4 flex h-44 flex-col items-center justify-center rounded border border-dashed bg-background/80 p-4 text-center",children:[e.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:s=>I(s)}),e.jsx("p",{className:"text-sm text-foreground/70",children:"Drop files here"}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:()=>M.current?.click(),children:"Select files"}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{k([])},children:"Clear"})]})]}),D.length>0&&e.jsx("div",{className:"mt-4 max-h-40 overflow-auto",children:D.map((s,i)=>e.jsxs("div",{className:"flex items-center justify-between border-b py-2",children:[e.jsx("div",{className:"text-sm",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"text-xs text-foreground/70",children:[(s.size/1024/1024).toFixed(2)," MB"]}),e.jsx(R,{size:"sm",variant:"outline",onClick:()=>U(i),children:"Remove"})]})]},`${s.name}-${i}`))}),e.jsx(Ie,{className:"mt-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"secondary",onClick:()=>A(!1),children:"Cancel"}),e.jsx(R,{disabled:!D.length,onClick:z,children:"Upload"})]})})]})}),e.jsxs("section",{className:T("space-y-6",r),children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"My learning"}),e.jsx("p",{className:"text-sm text-foreground/70",children:"Access shared lesson material, upcoming bookings, and practise files."})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[240px,1fr]",children:[e.jsxs("aside",{className:"rounded-lg border bg-card p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground/80",children:"Students"}),a()]}),e.jsxs("div",{className:"space-y-4",children:[b&&e.jsxs("div",{className:"rounded-lg border bg-muted/40 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Next lesson"}),e.jsx("p",{className:"text-sm text-foreground/70",children:b.start_time?new Date(b.start_time).toLocaleString():b.created_at?new Date(b.created_at).toLocaleString():"Scheduled details coming soon."}),b.metadata&&e.jsx("pre",{className:"mt-2 rounded bg-background/80 p-2 text-xs text-foreground/70",children:JSON.stringify(b.metadata,null,2)})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[d&&d.role==="admin"&&e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm text-foreground/70",children:"Upload resources to share with the selected student."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:u,id:"learningResources",type:"file",name:"learningResources",multiple:!0,className:"hidden",onChange:s=>$(s.target.files)}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>u.current?.click(),children:"Upload"})]})]}),e.jsx("div",{className:T(d?.role==="admin"?"mt-4":""),children:h()})]})]})]})]})]})}function lt(){q();const{toast:r}=se(),[n,o]=c.useState(!1),[l,f]=c.useState(null),[j,p]=c.useState(!1),[b,w]=c.useState(null),[u,x]=c.useState(1),[d,y]=c.useState(0),F=c.useRef(null),L=c.useRef(null),[m,N]=c.useState({name:"",phone:"",address:"",profile_picture_url:"",parent_name:"",parent_email:"",parent_phone:"",emergency_contacts:"",allergies:"",medications:"",instruments:[],band:""});c.useEffect(()=>{A()},[]);const A=async()=>{try{o(!0);const t=await(await O(async()=>{const{apiFetch:a}=await import("./api-CyvozDRd.js");return{apiFetch:a}},[])).apiFetch("/api/student/me");t&&(N({name:t.name||"",phone:t.phone||"",address:t.address||"",profile_picture_url:t.profile_picture_url||"",parent_name:t.parent_name||"",parent_email:t.parent_email||"",parent_phone:t.parent_phone||"",emergency_contacts:t.emergency_contacts||"",allergies:t.allergies||"",medications:t.medications||"",instruments:Array.isArray(t.instruments)?t.instruments:typeof t.instruments=="string"?JSON.parse(t.instruments):[],band:t.band||""}),t.profile_picture_url&&f(t.profile_picture_url))}catch(t){console.error("Failed to load profile:",t)}finally{o(!1)}},D=async t=>{const a=t.target.files?.[0];if(!a){console.log("ð· [PROFILE PIC] No file selected");return}if(console.log("ð· [PROFILE PIC] File selected:",{name:a.name,size:a.size,type:a.type,sizeKB:Math.round(a.size/1024)}),!a.type.startsWith("image/")){console.error("â [PROFILE PIC] Invalid file type:",a.type),r({title:"Invalid File",description:"Please select an image file (JPG, PNG, etc.)",variant:"destructive"});return}const h=10*1024*1024;if(a.size>h){console.error("â [PROFILE PIC] File too large:",a.size),r({title:"File Too Large",description:"Image must be less than 10MB",variant:"destructive"});return}console.log("â
[PROFILE PIC] File validation passed, loading preview...");const v=new FileReader;v.onload=_=>{console.log("ð¸ [PROFILE PIC] Image loaded for preview"),w(_.target?.result),x(1),y(0),p(!0)},v.onerror=()=>{console.error("â [PROFILE PIC] Failed to read file"),r({title:"Error",description:"Failed to read image file",variant:"destructive"})}
1,v.readAsDataURL(a)},k=async()=>(console.log("âï¸ [PROFILE PIC] Starting crop operation:",{zoom:u,rotation:d}),new Promise((t,a)=>{const h=F.current,v=L.current;if(!h||!v){console.error("â [PROFILE PIC] Canvas or image ref not available"),a(new Error("Canvas not ready"));return}const _=h.getContext("2d");if(!_){console.error("â [PROFILE PIC] Failed to get canvas context"),a(new Error("Canvas context not available"));return}const I=300;h.width=I,h.height=I,_.clearRect(0,0,I,I);const U=u,z=v.naturalWidth*U,s=v.naturalHeight*U;_.save(),_.translate(I/2,I/2),_.rotate(d*Math.PI/180),_.drawImage(v,-z/2,-s/2,z,s),_.restore();const i=h.toDataURL("image/jpeg",.85).split(",")[1];console.log("â [PROFILE PIC] Image cropped:",{originalSize:v.naturalWidth+"x"+v.naturalHeight,croppedSize:I+"x"+I,zoom:u,rotation:d,base64Length:i.length}),t(i)})),M=async()=>{try{o(!0),console.log(` 2ð [PROFILE PIC] Starting upload process...`);const t=await k();console.log("ð¦ [PROFILE PIC] Sending to server:",{dataSize:t.length,dataSizeKB:Math.round(t.length/1024)});const a=await Ye("/api/student/upload-profile-picture",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t})});console.log("â [PROFILE PIC] Upload successful:",{url:a.url,mediaId:a.mediaId}),f(a.url||a.profile_picture_url),N(h=>({...h,profile_picture_url:a.url||a.profile_picture_url})),p(!1),w(null),r({title:"Success",description:"Profile picture updated successfully"})}catch(t){console.error(` 3â [PROFILE PIC] CRITICAL ERROR:`,{message:t?.message,stack:t?.stack?.split(` 4`)[0]}),r({title:"Error",description:t?.message||"Failed to upload profile picture",variant:"destructive"})}finally{o(!1)}},$=async()=>{try{o(!0),await(await O(async()=>{const{apiFetch:a}=await import("./api-CyvozDRd.js");return{apiFetch:a}},[])).apiFetch("/api/student/me",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})&&r({title:"Success",description:"Profile updated successfully"})}catch(t){console.error("Update error:",t),r({title:"Error",description:"Failed to update profile",variant:"destructive"})}finally{o(!1)}};return e.jsxs(e.Fragment,{children:[j&&b&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-4",children:e.jsxs(Ge,{className:"w-full max-w-2xl p-6 space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"Adjust Your Profile Picture"}),e.jsx("button",{onClick:()=>{console.log("â [PROFILE PIC] Preview cancelled"),p(!1),w(null)},className:"text-foreground/50 hover:text-foreground",children:e.jsx(te,{size:24})})]}),e.jsxs("div",{className:"relative bg-muted rounded-lg p-4 flex items-center justify-center",children:[e.jsx("div",{className:"relative w-[300px] h-[300px] rounded-full overflow-hidden border-4 border-primary",children:e.jsx("div",{className:"absolute inset-0",style:{transform:`scale(${u}) rotate(${d}deg)`,transition:"transform 0.1s ease-out"},children:e.jsx("img",{ref:L,src:b,alt:"Preview",className:"w-full h-full object-cover"})})}),e.jsx("canvas",{ref:F,className:"hidden"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 block flex items-center gap-2",children:[e.jsx(We,{size:16}),"Zoom: ",u.toFixed(1),"x"]}),e.jsx("input",{type:"range",min:"0.5",max:"3",step:"0.1",value:u,onChange:t=>{const a=parseFloat(t.target.value);console.log("ð [PROFILE PIC] Zoom changed:",a),x(a)},className:"w-full"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 block flex items-center gap-2",children:[e.jsx(He,{size:16}),"Rotation: ",d,"°"]}),e.jsx("input",{type:"range",min:"0",max:"360",step:"15",value:d,onChange:t=>{const a=parseInt(t.target.value);console.log("ð [PROFILE PIC] Rotation changed:",a),y(a)},className:"w-full"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(R,{onClick:M,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"animate-spin mr-2",children:"â³"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{size:16,className:"mr-2"}),"Upload Picture"]})}),e.jsx(R,{onClick:()=>{console.log("â [PROFILE PIC] Upload cancelled"),p(!1),w(null)},variant:"outline",disabled:n,children:"Cancel"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"My Profile"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Profile Picture"}),e.jsxs("div",{className:"flex items-center gap-4",children:[l?e.jsx("img",{src:l,alt:"Profile",className:"w-24 h-24 rounded-full object-cover border"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-muted flex items-center justify-center text-3xl",children:"ð¤"}),e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*",onChange:D,disabled:n,id:"profilePicture",className:"hidden"}),e.jsx("label",{htmlFor:"profilePicture",className:"inline-block px-4 py-2 rounded-md border cursor-pointer hover:bg-muted disabled:opacity-50",children:n?"Uploading...":"Change Picture"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Full Name"}),e.jsx("input",{type:"text",value:m.name,onChange:t=>N({...m,name:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Your full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Phone Number"}),e.jsx("input",{type:"tel",value:m.phone,onChange:t=>N({...m,phone:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Your phone number"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Address"}),e.jsx("input",{type:"text",value:m.address,onChange:t=>N({...m,address:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Your address (optional)"})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Emergency Contact Information"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Name"}),e.jsx("input",{type:"text",value:m.parent_name,onChange:t=>N({...m,parent_name:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Parent or guardian name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Email"}),e.jsx("input",{type:"email",value:m.parent_email,onChange:t=>N({...m,parent_email:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Phone"}),e.jsx("input",{type:"tel",value:m.parent_phone,onChange:t=>N({...m,parent_phone:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Parent or guardian phone"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Additional Emergency Contacts"}),e.jsx("textarea",{value:m.emergency_contacts,onChange:t=>N({...m,emergency_contacts:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background min-h-[80px]",placeholder:"Emergency contact names and phone numbers"})]})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Medical Information"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Allergies"}),e.jsx("textarea",{value:m.allergies,onChange:t=>N({...m,allergies:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background min-h-[60
4px]",placeholder:"List any allergies (optional)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Medications"}),e.jsx("textarea",{value:m.medications,onChange:t=>N({...m,medications:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background min-h-[60px]",placeholder:"List any medications (optional)"})]})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Musical Background"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Instruments"}),e.jsx("input",{type:"text",value:m.instruments.join(", "),onChange:t=>{const a=t.target.value.split(",").map(h=>h.trim()).filter(h=>h.length>0);N({...m,instruments:a})},className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Piano, Guitar, , etc. (comma-separated)"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Separate multiple instruments with commas"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Band/Ensemble"}),e.jsx("input",{type:"text",value:m.band,onChange:t=>N({...m,band:t.target.value}),className:"w-full px-3 py-2 rounded-md border bg-background",placeholder:"Your band or ensemble name (optional)"})]})]})]}),e.jsx(R,{onClick:$,disabled:n,className:"w-full",children:n?"Saving...":"Save Profile"})]})]})]})}function vt(){const r=Ze(),{user:n,loading:o}=q(),[l,f]=c.useState("learning"),[j,p]=c.useState([]);if(c.useEffect(()=>{(async()=>{try{let u=function(a){try{let h=null;if(!a||!a.date)return Number.POSITIVE_INFINITY;typeof a.date=="string"?h=a.date.split("T")[0]:a.date instanceof Date?h=a.date.toISOString().slice(0,10):h=String(a.date);const v=a.time?String(a.time).split("+")[0]:"00:00:00",_=v.split(":");let I=v;_.length===2&&(I=`${_[0]}:${_[1]}:00`);const U=`${h}T${I}`,z=new Date(U).getTime();return Number.isNaN(z)?Number.POSITIVE_INFINITY:z}catch{return Number.POSITIVE_INFINITY}};if(!n){p([]);return}const x=await(await O(async()=>{const{apiFetch:a}=await import("./api-CyvozDRd.js");return{apiFetch:a}},[])).apiFetch("/api/admin/students"),y=(Array.isArray(x)?x:[]).find(a=>a.user_id===n.id);if(!y){p([]);return}const F=y.student_id||y.id,L=new Date,m=new Date(L);m.setDate(m.getDate()-7);const N=new Date(L);N.setDate(N.getDate()+90);const A=m.toISOString().split("T")[0],D=N.toISOString().split("T")[0],M=(await(await O(async()=>{const{apiFetch:a}=await import("./api-CyvozDRd.js");return{apiFetch:a}},[])).apiFetch(`/api/public/available-lessons/${A}/${D}`))?.lessons||[],$=[];for(const a of M)if((Array.isArray(a.studentIds)?a.studentIds:[]).includes(F))for(const v of a.occurrences||[])$.push({id:`${a.id}-${v.date}T${v.time}`,lesson_id:a.id,date:v.date,time:v.time,dateTime:v.dateTime,lesson_type:a.lessonType,teacher_id:a.teacherId,instrument:a.instrument,duration_minutes:a.durationMinutes});$.sort((a,h)=>u(a)-u(h));const t=$.filter(a=>u(a)>=L.getTime());p(t)}catch(u){console.error("Failed to load lessons",u),p([])}})()},[n]),o)return null;if(!n)return e.jsx(ee,{to:"/admin/login",replace:!0});if(n.role!=="student")return e.jsx(ee,{to:"/admin",replace:!0});const b=n.username||n.name||n.email,w=async()=>{await Re(),r("/")};return e.jsx("div",{className:"bg-muted/40 py-10",children:e.jsxs("div",{className:"container mx-auto space-y-6",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{className:"text-sm text-foreground/60",children:["Welcome back",b?`, ${b}`:""]}),e.jsx("h1",{className:"text-3xl font-semibold",children:"Student dashboard"}),e.jsx("p",{className:"text-sm text-foreground/70",children:"Manage your lessons, join discussions, and stay connected with your tutors."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{}),e.jsx(R,{variant:"ghost",onClick:w,children:"Logout"})]})]}),e.jsxs(tt,{value:l,onValueChange:f,className:"space-y-4",children:[e.jsxs(ye,{className:"w-fit",children:[e.jsx(G,{value:"profile",children:"Profile"}),e.jsx(G,{value:"learning",children:"My learning"}),e.jsx(G,{value:"discussion",children:"Discussion"}),e.jsx(G,{value:"chats",children:"Chats"})]}),e.jsx(Y,{value:"profile",className:"mt-4",children:e.jsx(lt,{})}),e.jsx(Y,{value:"learning",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Upcoming lessons"}
4),j.length===0?e.jsx("p",{className:"text-sm text-foreground/70 mt-2",children:"No upcoming lessons scheduled."}):e.jsx("ul",{className:"mt-2 space-y-2",children:j.map(u=>{let x=null;typeof u.date=="string"?x=u.date.split("T")[0]:u.date instanceof Date?x=u.date.toISOString().slice(0,10):x=u.date?String(u.date):null;let d=u.time?String(u.time).split("+")[0]:"00:00:00";const y=d.split(":");y.length===2&&(d=`${y[0]}:${y[1]}:00`);const F=x&&d?new Date(`${x}T${d}`).toLocaleString():"Invalid Date";return e.jsxs("li",{className:"flex items-center justify-between rounded border p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:u.student_name||u.student_email}),e.jsxs("div",{className:"text-xs text-foreground/70",children:[F," ⢠",u.lesson_type||"Lesson"]})]}),e.jsx("div",{children:e.jsx("span",{className:"text-sm text-foreground/70",children:"Scheduled"})})]},u.id)})})]}),e.jsx(ot,{})]})}),e.jsx(Y,{value:"discussion",className:"mt-4",children:e.jsx(Ve,{})}),e.jsx(Y,{value:"chats",className:"mt-4",children:e.jsx(Be,{})})]})]})})}export{vt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.