var w=(b,_,i)=>new Promise((l,c)=>{var n=r=>{try{g(i.next(r))}catch(h){c(h)}},y=r=>{try{g(i.throw(r))}catch(h){c(h)}},g=r=>r.done?l(r.value):Promise.resolve(r.value).then(n,y);g((i=i.apply(b,_)).next())});import{b6 as f,cG as S,I as T}from"./bootstrap-Bqxdt4iG.js";import{u as A,a as C}from"./announcements-8EaxYlGv.js";import{u as M}from"./data-refresh-BZ1_-6mk.js";import{f as I}from"./format-DSCuLcwt.js";import{S as N}from"./index-D0CahMPl.js";import{T as R}from"./index-axp3BSAN.js";import{a1 as V,L as x,aa as j,U as D,ap as d,aj as u,az as a,p as v,ay as m,a9 as o,ak as E,F as $,aq as z,ax as B,aR as F,an as P}from"../jse/index-index-BUJ_4tQs.js";const G={class:"rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"},H={class:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700"},q={class:"flex items-center gap-2"},O={class:"text-base font-semibold"},U={class:"text-xs text-gray-500"},J={key:0,class:"p-6"},K={key:1,class:"flex flex-col divide-y divide-gray-200 dark:divide-gray-700"},Q={class:"mb-2 flex items-start justify-between gap-2"},W={class:"flex-1 text-sm font-semibold"},X=["innerHTML"],Y={class:"flex items-center justify-between"},Z={class:"text-xs text-gray-400"},ee=["onClick"],ce=V({__name:"announcements-section",setup(b){const _=A(),i=M(),l=x([]),c=x(!1),n=x(new Set),y=t=>{var s,e;return(e=(s=C.find(p=>p.value===t))==null?void 0:s.label)!=null?e:t},g=t=>{var s,e;return(e=(s=C.find(p=>p.value===t))==null?void 0:s.color)!=null?e:"default"},r=t=>{n.value.has(t)?n.value.delete(t):n.value.add(t),n.value=new Set(n.value)},h=t=>t.length>120||t.split(`
`).length>2,L=t=>{if(!t)return"";const s=/(https?:\/\/\S+)/g;return t.replaceAll(s,e=>`<a href="${e}" target="_blank" class="text-blue-500 hover:text-blue-600 hover:underline" @click.stop>${e}</a>`)},k=()=>w(null,null,function*(){c.value=!0;try{l.value=yield _.getActive(5)}catch(t){console.error("Failed to load announcements:",t),l.value=[]}finally{c.value=!1}});return j(k),D(()=>i.announcementsVersion,()=>{k()}),(t,s)=>(u(),d("div",G,[a("div",H,[a("div",q,[s[0]||(s[0]=a("span",{class:"text-lg"},"📢",-1)),a("h3",O,m(o(f)("page.home.announcements.title")),1)]),a("span",U,m(l.value.length),1)]),v(o(N),{spinning:c.value},{default:E(()=>[l.value.length===0?(u(),d("div",J,[v(o(S),{description:o(f)("page.home.announcements.empty"),image:o(S).PRESENTED_IMAGE_SIMPLE},null,8,["description","image"])])):(u(),d("div",K,[(u(!0),d($,null,z(l.value,e=>(u(),d("div",{key:e.id,class:"p-4 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800"},[a("div",Q,[a("h4",W,m(e.title),1),v(o(R),{color:g(e.priority),class:"shrink-0"},{default:E(()=>[B(m(y(e.priority)),1)]),_:2},1032,["color"])]),a("p",{class:F(["mb-2 whitespace-pre-wrap text-sm text-gray-700 dark:text-gray-300",n.value.has(e.id)?"":"line-clamp-2"]),innerHTML:L(e.content)},null,10,X),a("div",Y,[a("div",Z,m(o(I)(e.createdAt)),1),h(e.content)?(u(),d("button",{key:0,type:"button",class:"flex items-center gap-1 text-xs text-blue-500 hover:text-blue-600",onClick:p=>r(e.id)},[a("span",null,m(n.value.has(e.id)?o(f)("page.home.announcements.showLess"):o(f)("page.home.announcements.readMore")),1),v(o(T),{icon:n.value.has(e.id)?"lucide:chevron-up":"lucide:chevron-down",class:"size-3"},null,8,["icon"])],8,ee)):P("",!0)])]))),128))]))]),_:1},8,["spinning"])]))}});export{ce as _};
