import{j as e,w as o,u as h,p}from"./vendor-rThclpOQ.js";import{P as f}from"./progress-B27dL7CW.js";import{u as j}from"./use-lang-BK6P2WMc.js";import{T as u}from"./table-footer-CXgex4hi.js";import{A as v,a as g,b as N}from"./avatar-BsP_s7dr.js";import{c as b}from"./utils-8KAaAB9H.js";import"./dropdown-menu-Cm0H42C1.js";import"./route-B4ZMN77y.js";import"./button-ZcsoqUQn.js";import"./index-DquVdLUg.js";import"./scroll-area-BCwyUKIK.js";const w=({total_reviews:r,rating_distribution:t})=>{const{common:m,frontend:n}=j(),s=(()=>{if(!(t!=null&&t.length)||r===0)return 0;const a=t.reduce((c,x)=>c+x.stars*(x.percentage/100),0);return Math.round(a*10)/10})(),l=(a,c=!0)=>Array.from({length:5},(x,d)=>e.jsx(o,{className:`h-4 w-4 ${c&&d<a-1||c&&d<Math.floor(a-1)+.5?"fill-amber-400 text-amber-400":"text-gray-300"}`},d));return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-xl font-semibold",children:n.student_reviews}),e.jsxs("p",{className:"font-semibold",children:[r," ",r===1?"Review":"Reviews"]})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex min-w-[100px] flex-col items-center sm:min-w-[120px]",children:[e.jsx("div",{className:"mb-2 text-6xl font-bold text-amber-600",children:s}),e.jsx("div",{className:"mb-2 flex gap-1",children:l(1+s)}),e.jsx("div",{className:"text-sm font-medium text-amber-600",children:m.rating})]}),e.jsx("div",{className:"w-full space-y-1.5 sm:flex-1",children:t.map(a=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex w-20 flex-shrink-0 gap-1",children:l(a.stars)}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(f,{value:a.percentage})}),e.jsx("div",{className:"w-12 flex-shrink-0 text-right",children:e.jsxs("span",{className:"text-sm font-medium",children:[a.percentage?Number(a.percentage).toFixed(2):"0","%"]})})]},a.stars))})]})]})},D=()=>{const{exam:r,reviews:t,reviewsStatistics:m,translate:n}=h().props,{frontend:i}=n;return e.jsxs(e.Fragment,{children:[e.jsx(w,{total_reviews:m.total_reviews,rating_distribution:m.rating_distribution}),e.jsxs("div",{className:"mt-6 border-t pt-6",children:[e.jsx("h3",{className:"mb-6 text-xl font-semibold",children:i.student_reviews}),e.jsx("div",{className:"space-y-6",children:t.data.length>0?t.data.map(s=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{className:"mt-1 h-8 w-8",children:[e.jsx(g,{src:s.user.photo||"",alt:s.user.name,className:"object-cover"}),e.jsx(N,{children:s.user.name.charAt(0)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:s.user.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",children:e.jsx(o,{className:b("h-4 w-4",l<=s.rating?"fill-amber-400 text-amber-400":"text-gray-300")})},l))}),e.jsx("p",{className:"text-muted-foreground text-xs",children:p(new Date(s.created_at),"MMM d, yyyy h:mm a")})]})]})]}),e.jsx("p",{className:"mt-3 text-sm",children:s.review})]},s.id)):e.jsx("p",{className:"p-3 text-center",children:i.no_reviews_found})}),e.jsx(u,{className:"mt-6",routeName:"exams.details",paginationInfo:t,routeParams:{slug:r.slug,id:r.id}})]})]})};export{D as default};
