import{r as a,j as e,g as D,a2 as C,a3 as M,a0 as S,d as B,t as j,a4 as E}from"./vendor-laZsiqLO.js";import{B as T}from"./badge-CJ9RzXvO.js";import{B as H}from"./button-B8f8jW4H.js";import{A as x}from"./AdSlot-HY9FvbmL.js";import{C as I}from"./ConfirmModal-DLCUZ7vx.js";import{u as F}from"./useTranslation-BW0o-tkY.js";import{c as L}from"./utils-RgT4yCq8.js";import O from"./ArticleHeader-BdQ5eauQ.js";import P from"./ArticleMedia-D6gXB9nZ.js";import V from"./ArticleBody-CXehf_Sc.js";import"./avatar-1RNhlzAH.js";import"./switch-52dk8qnh.js";import"./label-BDbCc0wv.js";import"./dialog-Cad__boe.js";import"./sheet-Cp4V1hdh.js";import"./VoteButtons-DwvWCLSs.js";import"./ArticleShareMenu-DQfxH8k7.js";import"./dropdown-menu-CpMN0BZ0.js";import"./carousel-C9slTU5h.js";import"./skeleton-uyR1XZG9.js";import"./app-D2josV_r.js";import"./bootstrap-CBwglqL9.js";/* empty css            */import"./InlineRelatedWidget-CmRLpMNL.js";function de({post:r,onOpenComments:p,ads:o,inlineRelated:y,auth:l}){const{t:s}=F(),f=l?.user?.id===r.user_id,n=l?.user?.role==="admin",v=f||n,b=f||n,[N,m]=a.useState(!1),[w,h]=a.useState(!1),i=a.useMemo(()=>!r.images||r.images.length===0?[]:[...r.images].sort((t,u)=>(u.is_primary===1)-(t.is_primary===1)),[r.images]),A=a.useMemo(()=>i.length>0?i.map(t=>({src:t.image_path,title:t.caption||null})):r.image_path?[{src:r.image_path,title:r.title}]:[],[i,r]),k=async()=>{h(!0);try{const t=n?`/api/admin/posts/${r.id}`:`/api/user/my-posts/${r.id}`;await B.delete(t),j.success(s("_deleted_success","Post deleted successfully")),E.visit("/")}catch(t){console.error(t),j.error(s("_delete_failed","Failed to delete post")),m(!1)}finally{h(!1)}},g=o?.article_header,c=o?.article_mobile_top,_=o?.article_after_cover,d=t=>t&&t.is_active;return e.jsxs("article",{className:"mb-20 animate-in fade-in duration-700 bg-background",children:[e.jsx(I,{open:N,onOpenChange:m,onConfirm:k,title:s("_delete_post","Delete Article?"),description:s("_delete_warning","Are you sure? This action cannot be undone."),confirmText:w?s("_deleting","Deleting..."):s("_yes_delete","Yes, Delete"),variant:"destructive"}),e.jsxs("div",{className:"mb-8 flex flex-col items-center w-full",children:[d(c)&&e.jsx("div",{className:"md:hidden w-full",children:e.jsx(x,{ad:c,className:"mx-auto"})}),d(g)&&e.jsx("div",{className:L("w-full",c?"hidden md:block":"block"),children:e.jsx(x,{ad:g,className:"max-w-[728px] mx-auto"})})]}),e.jsx(O,{post:r,auth:l,canEdit:v,canDelete:b,onOpenComments:p,setIsDeleteOpen:m}),e.jsx(P,{post:r,sortedImages:i,gallerySlides:A}),d(_)&&e.jsx("div",{className:"mb-8 flex justify-center my-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-widest mb-2",children:s("_advertisement","Advertisement")}),e.jsx(x,{ad:_,className:"mx-auto"})]})}),e.jsx(V,{post:r,inlineRelated:y}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-8",children:r.tags.map((t,u)=>e.jsx(D,{href:route("tag.show",t),children:e.jsxs(T,{variant:"secondary",className:"px-3 py-1 flex items-center gap-1 hover:bg-primary/10 hover:text-primary transition-colors",children:[e.jsx(C,{className:"w-3 h-3 opacity-50"})," ",t]})},u))}),r.source_url&&e.jsx("div",{className:"mb-10",children:e.jsxs("a",{href:r.source_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm font-semibold text-primary hover:text-primary/80 bg-primary/10 hover:bg-primary/20 px-4 py-2 rounded-full transition-colors",children:[e.jsx(M,{className:"w-4 h-4"}),s("_view_original_source","View original source")]})}),e.jsxs("div",{className:"bg-muted/30 border rounded-lg p-6 flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"font-bold flex items-center gap-2",children:[e.jsx(S,{className:"w-5 h-5 text-primary"})," ",s("_join_conversation","Join the conversation")]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("_what_do_you_think","What do you think about this story?")})]}),e.jsxs(H,{variant:"outline",onClick:()=>p(r.id),className:"hover:bg-primary hover:text-primary-foreground",children:[s("_view_comments","View Comments")," (",r.comments_count||0,")"]})]})]})}export{de as default};
