import{j as e,bj as x}from"./react-vendor-xYZnmIII.js";import{P as d}from"./ui-components-CQM92IK3.js";import{u as o}from"./use-lang-Dg6I_Fym.js";const j=({totalReviews:r})=>{const{common:l,frontend:m}=o(),n=(()=>{var t;if(!((t=r==null?void 0:r.rating_distribution)!=null&&t.length)||r.total_reviews===0)return 0;const s=r.rating_distribution.reduce((i,a)=>i+a.stars*(a.percentage/100),0);return Math.round(s*10)/10})(),c=(s,t=!0)=>Array.from({length:5},(i,a)=>e.jsx(x,{className:`h-4 w-4 ${t&&a<s-1||t&&a<Math.floor(s-1)+.5?"fill-amber-400 text-amber-400":"text-gray-300"}`},a));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:m.student_reviews}),e.jsxs("p",{className:"font-semibold",children:[r.total_reviews," ",r.total_reviews===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:n}),e.jsx("div",{className:"mb-2 flex gap-1",children:c(1+n)}),e.jsx("div",{className:"text-sm font-medium text-amber-600",children:l.rating})]}),e.jsx("div",{className:"w-full space-y-1.5 sm:flex-1",children:r.rating_distribution.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex w-20 flex-shrink-0 gap-1",children:c(s.stars)}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(d,{value:s.percentage})}),e.jsx("div",{className:"w-12 flex-shrink-0 text-right",children:e.jsxs("span",{className:"text-sm font-medium",children:[s.percentage?Number(s.percentage).toFixed(2):"0","%"]})})]},s.stars))})]})]})};export{j as S};
