import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{t as r}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as i}from"./createLucideIcon-D477Pc8e-1776590214964.js";import{t as a}from"./button-WiAFyHfP-1776590214964.js";import{n as o,t as s}from"./card-Cby8flFO-1776590214964.js";import{t as c}from"./ReviewSummary-nB68q3io-1776590214964.js";import{t as l}from"./ReviewForm-C3ThNxep-1776590214964.js";import{t as u}from"./ReviewList-N8bijtPs-1776590214964.js";var d=i(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),f=e(t(),1),p=n();function m({product:e,reviewsData:t,ratingCounts:n,isOwner:i,canReview:m,hasReviewed:h}){let{t:g}=r(),[_,v]=(0,f.useState)(!1),y=parseFloat(e.reviews_avg_rating)||0,b=e.reviews_count||0;return(0,p.jsxs)(s,{className:`shadow-sm border-border/50 overflow-hidden mt-8`,id:`reviews`,children:[(0,p.jsxs)(`div`,{className:`border-b bg-muted/20 px-6 py-4 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4`,children:[(0,p.jsx)(`span`,{className:`text-primary font-bold text-lg`,children:g(`Customer Reviews (:count)`,{count:b})}),!i&&m&&(0,p.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>v(!_),className:`gap-2`,children:[(0,p.jsx)(d,{className:`w-4 h-4`}),g(_?`Cancel Review`:`Write a Review`)]}),!i&&h&&(0,p.jsxs)(`span`,{className:`text-xs font-bold text-green-600 bg-green-500/10 border border-green-500/20 px-3 py-1.5 rounded-full`,children:[`✓ `,g(`You reviewed this product`)]})]}),(0,p.jsxs)(o,{className:`p-6 space-y-8`,children:[(0,p.jsx)(c,{avgRating:y,totalReviews:b,ratingCounts:n}),_&&m&&(0,p.jsx)(`div`,{className:`animate-in fade-in slide-in-from-top-4 duration-300`,children:(0,p.jsx)(l,{productId:e.id,onSuccess:()=>v(!1)})}),(0,p.jsxs)(`div`,{className:`pt-4`,children:[(0,p.jsx)(u,{reviews:t.data}),t.last_page>1&&(0,p.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`Showing page :current of :last`,{current:t.current_page,last:t.last_page})})})]})]})]})}export{m as default};