import{jsxs as a,jsx as e}from"react/jsx-runtime";import{g as l,U as x,V as N,B as i,W as f,X as v,c as y}from"./ui-components-B24mpb8o.js";import{g as _}from"./route-D0xh7FtZ.js";import{usePage as b,router as D,Link as m}from"@inertiajs/react";import{Award as k,ChevronsUpDown as w}from"lucide-react";import"next-themes";import"sonner";import"react";import"@radix-ui/react-label";import"class-variance-authority";import"@radix-ui/react-checkbox";import"@radix-ui/react-avatar";import"@radix-ui/react-dropdown-menu";import"@radix-ui/react-scroll-area";import"@radix-ui/react-popover";import"@radix-ui/react-radio-group";import"@radix-ui/react-dialog";import"@radix-ui/react-slot";import"clsx";import"@radix-ui/react-separator";import"@radix-ui/react-tooltip";import"@radix-ui/react-tabs";import"@radix-ui/react-accordion";import"@radix-ui/react-progress";import"@radix-ui/react-select";import"cmdk";import"@radix-ui/react-switch";import"react-day-picker";import"@radix-ui/react-slider";import"embla-carousel-react";import"@radix-ui/react-toggle-group";import"vaul";import"tailwind-merge";const ie=(n,o)=>{const d=b(),c=_(d.url),p=["all","in_progress","completed","abandoned","submitted"];return[{accessorKey:"attempt_number",header:({column:t})=>e("div",{className:"flex items-center pl-4",children:e("span",{children:"Attempt"})}),cell:({row:t})=>a("div",{className:"py-1 pl-4",children:[a("div",{className:"flex items-center gap-2",children:[a("p",{className:"font-medium",children:["Attempt #",t.getValue("attempt_number")]}),o===t.original.id&&a(l,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e(k,{className:"mr-1 h-3 w-3"}),"Best"]})]}),a("p",{className:"text-muted-foreground text-xs",children:[new Date(t.original.start_time).toLocaleDateString()," • ",new Date(t.original.start_time).toLocaleTimeString()]})]})},{accessorKey:"obtained_marks",header:()=>e("div",{className:"text-center",children:"Score"}),cell:({row:t})=>{const r=t.original&&Number(t.original.total_marks)>0?Math.round(Number(t.original.obtained_marks)/Number(t.original.total_marks)*100*100)/100:0;return a("div",{className:"py-1 text-center",children:[a("p",{className:"font-semibold",children:[t.getValue("obtained_marks"),"/",t.original.total_marks]}),a("p",{className:"text-muted-foreground text-xs",children:[r,"%"]})]})}},{accessorKey:"status",header:({column:t})=>{var r;return e("div",{className:"flex justify-center",children:a(x,{children:[e(N,{className:"flex items-center justify-center",children:a(i,{variant:"ghost",className:"text-muted-foreground capitalize",children:[e("span",{children:(r=c.status)!=null?r:"Status"}),e(w,{className:"h-3 w-3 text-gray-700"})]})}),e(f,{align:"center",className:"min-w-[120px]",children:p.map(s=>e(v,{onClick:()=>D.get(route("student.exam.show",{id:n,tab:"attempts",status:s})),className:y("cursor-pointer text-center capitalize",c.status===s&&"bg-gray-100"),children:s.replace("_"," ")},s))})]})})},cell:({row:t})=>{const r=t.getValue("status");return e("div",{className:"flex justify-center py-1",children:e(l,{variant:r==="completed"?"secondary":r==="in_progress"?"default":"destructive",className:"capitalize",children:r.replace("_"," ")})})}},{accessorKey:"correct_answers",header:()=>e("div",{className:"text-center",children:"Answers"}),cell:({row:t})=>e("div",{className:"py-1 text-center",children:a("p",{className:"text-sm",children:[e("span",{className:"text-green-600",children:t.getValue("correct_answers")})," /"," ",e("span",{className:"text-red-600",children:t.original.incorrect_answers})]})})},{accessorKey:"end_time",header:"Duration",cell:({row:t})=>{const r=t.original.start_time,s=t.getValue("end_time");if(!s)return e("div",{className:"text-muted-foreground py-1 text-center",children:"—"});const u=new Date(r),h=new Date(s),g=Math.max(0,Math.round((h.getTime()-u.getTime())/6e4));return e("div",{className:"py-1 text-center",children:a("p",{className:"text-sm",children:[g," min"]})})}},{id:"actions",header:()=>e("div",{className:"pr-4 text-end",children:"Actions"}),cell:({row:t})=>{const r=t.original;return a("div",{className:"flex justify-end gap-2 py-1 pr-4",children:[r.status==="completed"?e(i,{asChild:!0,variant:"secondary",className:"h-8",children:e(m,{href:route("student.exam.show",{id:n,tab:"attempts",attempt:r.id}),children:"Result"})}):e(i,{disabled:!0,variant:"secondary",className:"h-8",children:"Pending"}),r.status==="in_progress"||r.status==="abandoned"&&e(i,{asChild:!0,variant:"default",className:"h-8",children:e(m,{href:route("exam-attempts.take",r.id),children:"Continue"})})]})}}]};export{ie as default};
