import{d as Q,af as D,c as s,e as i,f as r,g as n,m as W,ag as $,a8 as l,t as d,p as g,j as z,h as X,F as I,l as K}from"./DOfG14GD.js";import{u as Z}from"./YsKoOGK6.js";const tt={class:"mx-auto w-full max-w-[1540px] px-4 md:px-8"},et={class:"flex flex-wrap items-center justify-between gap-4"},at={class:"relative flex items-center"},nt={class:"relative"},ot=["data-content-key"],lt=["data-content-key"],st=["data-content-key"],it=["data-content-key","aria-busy"],rt={key:0,class:"grid grid-cols-1 gap-x-8 gap-y-10 sm:grid-cols-2 lg:grid-cols-3"},dt=["onClick"],ct={class:"relative bg-slate-100"},ut={class:"relative aspect-[100/64] w-full overflow-hidden"},pt=["src","alt"],mt={key:1,class:"h-full w-full bg-[linear-gradient(135deg,#3a6ea5,#5b9bd5)]"},vt={class:"absolute -bottom-5 left-3 flex h-[46px] w-[52px] items-center justify-center bg-[var(--theme-primary-color)] text-[26px] font-bold leading-none text-[var(--theme-primary-contrast)]"},xt={class:"border-b border-[#e5e5e5] border-b-5 pt-3"},yt={class:"block pl-[80px] text-[16px] font-bold text-[#999]"},gt={class:"mt-3 overflow-hidden text-ellipsis whitespace-nowrap text-[17px] font-medium leading-[26px] text-[#333] transition group-hover:text-[var(--theme-primary-color)] md:text-[18px]"},ft={class:"mt-2 line-clamp-2 h-[44px] text-[13px] leading-[22px] text-[#999]"},ht={key:1,class:"border border-dashed border-slate-200 bg-slate-50 py-12 text-center text-slate-400"},bt={key:0,class:"mt-12 flex justify-center","aria-label":"Pagination"},kt={class:"inline-flex flex-wrap items-center justify-center gap-[6px] text-[13px] md:text-[15px]"},_t=["disabled"],Ct=["onClick"],wt={key:1,class:"px-2 leading-[35px] text-slate-400 md:leading-10"},Nt=["disabled"],At=Q({__name:"CompanyNewsCardsLayout",props:{content:{default:()=>[]},editable:{type:Boolean,default:!1},activeKey:{default:null},onContentClick:{},onButtonClick:{},textStyle:{},className:{},loading:{type:Boolean,default:!1},emptyText:{default:"暂无数据"}},emits:["handle-item-click","on-page-change"],setup(v,{emit:L}){const c=v,P=L,{pick:_,resolveKey:f,interactive:F,isActive:C,resolveTextStyle:w,handleClick:N}=Z({content:D(c,"content"),activeKey:D(c,"activeKey"),editable:D(c,"editable"),onContentClick:c.onContentClick,textStyle:c.textStyle});function B(t,e=""){return String(t?.attribute?.value??"").trim()||e}const u=s(()=>_("title")),h=s(()=>_("title01")),p=s(()=>_("button")),m=s(()=>c.content.find(t=>t?.type==="list"||t?.type==="grid"||t?.type==="table"));function V(t){return t?typeof t.images=="string"?t.images.split(";").find(Boolean)||"":Array.isArray(t.images)?t.images.find(Boolean)||"":t.imageUrl||t.image||t.cover||t.src||t.url||t.attribute?.src||"":""}function R(t){return typeof t!="string"?"":t.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim()}function E(t){if(typeof t!="string"||!t.trim())return null;const e=new Date(t);return Number.isNaN(e.getTime())?null:e}function H(t){const e=E(t?.date||t?.createdAt||t?.created_at||t?.updatedAt||t?.updated_at);return e?{day:String(e.getDate()).padStart(2,"0"),month:`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}:{day:"01",month:"2022-09"}}const j=s(()=>{const t=m.value;if(!t)return[];const e=Number(t.dataSource),a=Array.isArray(t.data)?t.data:[],y=Array.isArray(t.customData?.data)?t.customData.data:[];return(e===3?y:a).map((o,O)=>{const M=H(o);return{key:o?.id??O,title:o?.nameDisplay||o?.name_display||o?.title||o?.name||"",desc:R(o?.descriptionDisplay||o?.description_display||o?.description||o?.content||o?.context||""),image:V(o),day:M.day,month:M.month,rawItem:o}})}),b=s(()=>m.value?.config?.pagination||null),T=s(()=>Number(b.value?.total||0)),k=s(()=>Number(b.value?.limit||0)),x=s(()=>Number(b.value?.page||1)),S=s(()=>k.value?Math.max(1,Math.ceil(T.value/k.value)):1),U=s(()=>!!b.value?.showPagination&&T.value>k.value),Y=s(()=>{const t=S.value,e=x.value;return t<=5?Array.from({length:t},(a,y)=>y+1):e<=3?[1,2,3,"...",t]:e>=t-2?[1,"...",t-2,t-1,t]:[1,"...",e,"...",t]});function A(t){t<1||t>S.value||t===x.value||P("on-page-change",{page:t,limit:k.value})}function q(t){P("handle-item-click",t.rawItem)}function G(){N(p.value);const t=p.value?.attribute?.target;!c.editable&&t&&c.onButtonClick&&c.onButtonClick(t)}return(t,e)=>(r(),i("section",{class:g(["bg-white py-12 md:py-16 lg:py-20 px-4 md:px-8 lg:px-[12%]",v.className])},[n("div",tt,[n("div",et,[n("div",at,[e[4]||(e[4]=n("span",{class:"mr-3 h-[26px] w-[4px] shrink-0 bg-[var(--theme-primary-color)] md:h-[30px]"},null,-1)),n("div",nt,[n("span",{class:"pointer-events-none absolute left-5 bottom-0 select-none text-[34px] font-black uppercase leading-none tracking-[1px]","data-content-key":h.value&&l(f)(h.value)||void 0,style:$(l(w)(h.value))},d(B(h.value)),13,ot),n("h2",{class:g(["relative z-10 text-[24px] font-bold leading-none text-[#111] md:text-[30px]",[{"cursor-pointer":l(F),mark:v.editable&&u.value&&l(C)(u.value)}]]),"data-content-key":u.value&&l(f)(u.value)||void 0,style:$(l(w)(u.value)),onClick:e[0]||(e[0]=a=>u.value&&l(N)(u.value))},d(B(u.value)),15,lt)])]),n("button",{type:"button",class:g(["inline-flex items-center gap-2 rounded-full border border-[var(--theme-primary-color)] px-6 py-2 text-[14px] text-[var(--theme-primary-color)] transition hover:bg-[var(--theme-primary-color)] hover:text-white! cursor-pointer md:px-8 md:py-2.5",[{mark:v.editable&&p.value&&l(C)(p.value)}]]),"data-content-key":p.value&&l(f)(p.value)||void 0,style:$(l(w)(p.value)),onClick:z(G,["stop"])},[X(d(B(p.value,"了解更多"))+" ",1),e[5]||(e[5]=n("svg",{class:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1))],14,st)]),n("div",{class:g(["mt-10 md:mt-12",[{mark:v.editable&&m.value&&l(C)(m.value)}]]),"data-content-key":m.value&&l(f)(m.value)||void 0,"aria-busy":v.loading,onClick:e[1]||(e[1]=a=>m.value&&l(N)(m.value))},[j.value.length?(r(),i("div",rt,[(r(!0),i(I,null,K(j.value,a=>(r(),i("article",{key:a.key,class:"group cursor-pointer",onClick:z(y=>q(a),["stop"])},[n("div",ct,[n("div",ut,[a.image?(r(),i("img",{key:0,src:a.image,alt:a.title,class:"h-full w-full object-contain transition duration-[800ms] group-hover:scale-[1.08]",loading:"lazy"},null,8,pt)):(r(),i("div",mt))]),n("div",vt,d(a.day),1)]),n("div",xt,[n("time",yt,d(a.month),1),n("h3",gt,d(a.title),1),n("p",ft,d(a.desc),1)])],8,dt))),128))])):(r(),i("div",ht,d(v.emptyText),1))],10,it),U.value?(r(),i("nav",bt,[n("div",kt,[n("button",{type:"button",class:"min-w-10 rounded-[5px] bg-[#f5f5f5] px-2.5 leading-[35px] text-[#222] transition hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)] disabled:pointer-events-none disabled:opacity-50 md:min-w-[45px] md:leading-10",disabled:x.value===1,onClick:e[2]||(e[2]=a=>A(x.value-1))}," 上一页 ",8,_t),(r(!0),i(I,null,K(Y.value,(a,y)=>(r(),i(I,{key:`news-page-${a}-${y}`},[typeof a=="number"?(r(),i("button",{key:0,type:"button",class:g(["min-w-10 rounded-[5px] px-2.5 leading-[35px] transition md:min-w-[45px] md:leading-10",a===x.value?"bg-[var(--theme-primary-color)] text-[var(--theme-primary-contrast)]":"bg-[#f5f5f5] text-[#222] hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)]"]),onClick:J=>A(a)},d(a),11,Ct)):(r(),i("span",wt,d(a),1))],64))),128)),n("button",{type:"button",class:"min-w-10 rounded-[5px] bg-[#f5f5f5] px-2.5 leading-[35px] text-[#222] transition hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)] disabled:pointer-events-none disabled:opacity-50 md:min-w-[45px] md:leading-10",disabled:x.value===S.value,onClick:e[3]||(e[3]=a=>A(x.value+1))}," 下一页 ",8,Nt)])])):W("",!0)])],2))}});export{At as default};
