import{_ as V,a as C,b as P,c as F}from"./BfPjfeWt.js";import{_ as S}from"./CgXve9qO.js";import{_ as j}from"./DxB0DKYp.js";import{u as R}from"./BZ7f31ti.js";import{u as U,G as q,q as A,H as E,c as l,b as i,a as e,d as y,t as a,e as t,w as k,F as G,r as z,i as J,l as m,m as K,o as c,I as O}from"./BKiFavna.js";import{u as Q}from"./BOqT4ZDK.js";import{_ as W}from"./DlAUqK2U.js";import"./DKzHUNYh.js";const X={"data-theme":"light"},Y={id:"main-content",role:"main"},Z={class:"container"},ee={class:"category-header"},te={class:"category-title"},se={class:"tag-name"},ae={class:"breadcrumb"},ne={key:0,class:"loading-box"},oe={key:1,class:"empty-box"},ce={key:2},le={class:"posts-grid"},_e={class:"post-thumb"},ie=["src","alt"],re={key:1,class:"post-emoji"},ue={class:"post-body"},de={class:"post-cat"},me={class:"post-title"},pe={class:"post-excerpt"},ge={class:"post-meta"},be={key:0,class:"load-more"},he=["disabled"],ve={key:0},fe={key:1},T=12,ye={__name:"[slug]",setup(ke){const{lang:n}=U(),{api:w}=R(),B=q(),r=K(()=>B.params.slug),g=m(""),u=m([]),p=m(!0),b=m(!1),h=m(1),x=m(!1),L=_=>_?new Date(_).toLocaleDateString(n.value==="bn"?"bn-BD":"en-US",{year:"numeric",month:"long",day:"numeric"}):"",v=async(_=!1)=>{_&&(h.value=1,u.value=[]);try{const o=await w.get("/posts",{tag:r.value,page:h.value,limit:T}),d=o.data.posts||[];u.value=_?d:[...u.value,...d],x.value=o.meta&&h.value*T<o.meta.total}catch{u.value=[]}},N=async()=>{try{const o=((await w.get("/tags")).data.tags||[]).find(d=>d.slug===r.value);o&&(g.value=n.value==="bn"?o.name_bn:o.name_en)}catch{}},$=async()=>{b.value=!0,h.value++,await v(),b.value=!1};return A(async()=>{p.value=!0,await Promise.all([N(),v(!0)]),p.value=!1}),E(r,async()=>{p.value=!0,await Promise.all([N(),v(!0)]),p.value=!1}),Q(()=>({title:`${g.value||r.value} — ${n.value==="bn"?"নিউজভার্স":"NewsVerse"}`})),(_,o)=>{const d=V,I=C,M=P,D=S,f=j,H=F;return c(),l("div",X,[i(d),i(I),i(M),i(D),e("main",Y,[e("div",Z,[e("div",ee,[e("h1",te,[y(" 🏷️ "+a(t(n)==="bn"?"ট্যাগ:":"Tag:")+" ",1),e("span",se,a(t(g)||t(r)),1)]),e("div",ae,[i(f,{to:"/"},{default:k(()=>[y(a(t(n)==="bn"?"হোম":"Home"),1)]),_:1}),o[0]||(o[0]=e("span",null," › ",-1)),e("span",null,a(t(n)==="bn"?"ট্যাগ":"Tags"),1),o[1]||(o[1]=e("span",null," › ",-1)),e("span",null,a(t(g)||t(r)),1)])]),t(p)?(c(),l("div",ne,[o[2]||(o[2]=e("div",{class:"loader"},null,-1)),e("p",null,a(t(n)==="bn"?"লোড হচ্ছে...":"Loading..."),1)])):t(u).length===0?(c(),l("div",oe,[e("p",null,a(t(n)==="bn"?"এই ট্যাগে কোনো সংবাদ পাওয়া যায়নি।":"No news found for this tag."),1),i(f,{to:"/",class:"btn-home"},{default:k(()=>[y(a(t(n)==="bn"?"হোমে ফিরুন":"Back to Home"),1)]),_:1})])):(c(),l("div",ce,[e("div",le,[(c(!0),l(G,null,z(t(u),s=>(c(),O(f,{key:s.id,to:`/news/${encodeURIComponent(t(n)==="bn"?s.slug_bn:s.slug_en||s.slug_bn)}`,class:"post-card"},{default:k(()=>[e("div",_e,[s.featured_image?(c(),l("img",{key:0,src:s.featured_image,alt:s.title_bn},null,8,ie)):(c(),l("span",re,a(s.emoji||"📰"),1))]),e("div",ue,[e("span",de,a(t(n)==="bn"?s.category_name_bn:s.category_name_en),1),e("h2",me,a(t(n)==="bn"?s.title_bn:s.title_en||s.title_bn),1),e("p",pe,a(t(n)==="bn"?s.excerpt_bn:s.excerpt_en||s.excerpt_bn),1),e("div",ge,[e("span",null,a(L(s.published_at)),1),e("span",null,"👁 "+a(s.views||0),1)])])]),_:2},1032,["to"]))),128))]),t(x)?(c(),l("div",be,[e("button",{onClick:$,disabled:t(b),class:"btn-more"},[t(b)?(c(),l("span",ve,a(t(n)==="bn"?"লোড হচ্ছে...":"Loading..."),1)):(c(),l("span",fe,a(t(n)==="bn"?"আরও দেখুন":"Load More"),1))],8,he)])):J("",!0)]))])]),i(H)])}}},Me=W(ye,[["__scopeId","data-v-91142ceb"]]);export{Me as default};
