import{j as e,f as h,s as u,U as g,m as j,a3 as f,ck as b,af as p}from"./vendor-laZsiqLO.js";import{T as w,a as N,b as i,c as r,d as v,e as s}from"./table-D7zRN5YZ.js";import{B as t}from"./button-B8f8jW4H.js";import{B as n}from"./badge-CJ9RzXvO.js";import{A as y,a as k,b as T}from"./avatar-1RNhlzAH.js";import"./utils-RgT4yCq8.js";function D({posts:l,loading:c,onEdit:d,onDelete:o}){const x=a=>{const m={published:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 hover:bg-green-100 border-green-200",pending:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400 hover:bg-yellow-100 border-yellow-200",rejected:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 hover:bg-red-100 border-red-200"};return e.jsx(n,{variant:"outline",className:`capitalize border ${m[a]||""}`,children:a})};return c?e.jsxs("div",{className:"h-64 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx(h,{className:"h-8 w-8 animate-spin mb-2"}),e.jsx("p",{children:"Loading records..."})]}):l.length===0?e.jsx("div",{className:"h-64 flex flex-col items-center justify-center text-muted-foreground border rounded-md bg-muted/10",children:e.jsx("p",{children:"No news posts found matching your criteria."})}):e.jsx("div",{className:"rounded-md border bg-card overflow-x-auto w-full relative",children:e.jsxs(w,{className:"min-w-[900px]",children:[e.jsx(N,{children:e.jsxs(i,{className:"bg-muted/50",children:[e.jsx(r,{className:"w-[80px]",children:"Image"}),e.jsx(r,{children:"Article Details"}),e.jsx(r,{children:"Author"}),e.jsx(r,{className:"text-center",children:"Stats"}),e.jsx(r,{className:"text-right",children:"Actions"})]})}),e.jsx(v,{children:l.map(a=>e.jsxs(i,{className:"group hover:bg-muted/50 transition-colors",children:[e.jsx(s,{className:"py-3",children:e.jsx("div",{className:"h-12 w-16 rounded overflow-hidden bg-muted border shrink-0",children:e.jsx("img",{src:a.image_path||`https://ui-avatars.com/api/?name=${a.title}`,alt:"",className:"h-full w-full object-cover"})})}),e.jsx(s,{className:"py-3",children:e.jsxs("div",{className:"flex flex-col gap-1 max-w-[300px] md:max-w-[400px]",children:[e.jsx("span",{className:"font-semibold line-clamp-1 group-hover:text-primary transition-colors",title:a.title,children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground whitespace-nowrap",children:[e.jsx(n,{variant:"secondary",className:"text-[10px] px-1.5 h-5",children:a.category?.name||"Uncategorized"}),x(a.status),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3"}),new Date(a.created_at).toLocaleDateString()]})]})]})}),e.jsx(s,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{className:"h-6 w-6 shrink-0",children:[e.jsx(k,{src:a.user?.avatar}),e.jsx(T,{children:e.jsx(g,{className:"w-3 h-3"})})]}),e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:a.user?.name})]})}),e.jsx(s,{className:"py-3 text-center",children:e.jsxs("div",{className:"inline-flex items-center justify-center gap-1.5 bg-muted/50 px-2 py-1 rounded text-xs font-medium whitespace-nowrap border border-border",children:[e.jsx(j,{className:"w-3 h-3 text-muted-foreground"}),a.views_count?.toLocaleString()||0]})}),e.jsx(s,{className:"text-right py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex justify-end items-center gap-1",children:[a.status==="published"&&e.jsx(t,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-blue-600",asChild:!0,title:"View Live",children:e.jsx("a",{href:a.route_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(f,{className:"h-4 w-4"})})}),e.jsx(t,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-primary",onClick:()=>d(a),title:"Edit Post",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(t,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-red-600",onClick:()=>o(a.id),title:"Delete Post",children:e.jsx(p,{className:"h-4 w-4"})})]})})]},a.id))})]})})}export{D as default};
