import{u as h,j as e,A as g,by as j,e as N,L as c}from"./vendor-BKmmeuxg.js";import{B as l}from"./badge-AQfLLMpR.js";import{B as r}from"./button-BpNwv2aE.js";import{D as f,a as y,b,c as _}from"./dropdown-menu-DO-po5c1.js";import{g as v}from"./route-B4ZMN77y.js";import{c as D}from"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const K=(n,d)=>{const m=h(),i=v(m.url),o=["all","in_progress","completed","abandoned","submitted"];return[{accessorKey:"attempt_number",header:({column:t})=>e.jsx("div",{className:"flex items-center pl-4",children:e.jsx("span",{children:"Attempt"})}),cell:({row:t})=>e.jsxs("div",{className:"py-1 pl-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium",children:["Attempt #",t.getValue("attempt_number")]}),d===t.original.id&&e.jsxs(l,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(g,{className:"mr-1 h-3 w-3"}),"Best"]})]}),e.jsxs("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.jsx("div",{className:"text-center",children:"Score"}),cell:({row:t})=>{const s=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 e.jsxs("div",{className:"py-1 text-center",children:[e.jsxs("p",{className:"font-semibold",children:[t.getValue("obtained_marks"),"/",t.original.total_marks]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[s,"%"]})]})}},{accessorKey:"status",header:({column:t})=>e.jsx("div",{className:"flex justify-center",children:e.jsxs(f,{children:[e.jsx(y,{className:"flex items-center justify-center",children:e.jsxs(r,{variant:"ghost",className:"text-muted-foreground capitalize",children:[e.jsx("span",{children:i.status??"Status"}),e.jsx(j,{className:"h-3 w-3 text-gray-700"})]})}),e.jsx(b,{align:"center",className:"min-w-[120px]",children:o.map(s=>e.jsx(_,{onClick:()=>N.get(route("student.exam.show",{id:n,tab:"attempts",status:s})),className:D("cursor-pointer text-center capitalize",i.status===s&&"bg-gray-100"),children:s.replace("_"," ")},s))})]})}),cell:({row:t})=>{const s=t.getValue("status"),a=s==="completed"?"secondary":s==="in_progress"?"default":"destructive";return e.jsx("div",{className:"flex justify-center py-1",children:e.jsx(l,{variant:a,className:"capitalize",children:s.replace("_"," ")})})}},{accessorKey:"correct_answers",header:()=>e.jsx("div",{className:"text-center",children:"Answers"}),cell:({row:t})=>e.jsx("div",{className:"py-1 text-center",children:e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"text-green-600",children:t.getValue("correct_answers")})," /"," ",e.jsx("span",{className:"text-red-600",children:t.original.incorrect_answers})]})})},{accessorKey:"end_time",header:"Duration",cell:({row:t})=>{const s=t.original.start_time,a=t.getValue("end_time");if(!a)return e.jsx("div",{className:"text-muted-foreground py-1 text-center",children:"—"});const u=new Date(s),x=new Date(a),p=Math.max(0,Math.round((x.getTime()-u.getTime())/6e4));return e.jsx("div",{className:"py-1 text-center",children:e.jsxs("p",{className:"text-sm",children:[p," min"]})})}},{id:"actions",header:()=>e.jsx("div",{className:"pr-4 text-end",children:"Actions"}),cell:({row:t})=>{const s=t.original;return e.jsxs("div",{className:"flex justify-end gap-2 py-1 pr-4",children:[s.status==="completed"?e.jsx(r,{asChild:!0,variant:"secondary",className:"h-8",children:e.jsx(c,{href:route("student.exam.show",{id:n,tab:"attempts",attempt:s.id}),children:"Result"})}):e.jsx(r,{disabled:!0,variant:"secondary",className:"h-8",children:"Pending"}),s.status==="in_progress"||s.status==="abandoned"&&e.jsx(r,{asChild:!0,variant:"default",className:"h-8",children:e.jsx(c,{href:route("exam-attempts.take",s.id),children:"Continue"})})]})}}]};export{K as default};
