import{v as N,u as S,r,a3 as u,b as E,e as P,o as n,c as l,i as p,a as e,F as g,k,f as h,g as x,d as A,t as m,w as T,p as C}from"./index-Cdt4oMy6.js";import{_ as I}from"./AppPagination-BbKWO8Aw.js";const M={key:0,class:"loader"},V={key:1,class:"news-page"},$=e("h1",{class:"h1"},"Новости",-1),B={class:"cards"},G={class:"cards__item-date"},b={class:"cards__item-text"},y={class:"cards__item-title"},O=e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("g",{"clip-path":"url(#clip0_4565_44816)"},[e("path",{d:"M24.1844 12.0004L12.4749 2.41992L11.5251 3.58086L20.8989 11.2504L9 11.2504V12.7504L20.8989 12.7504L11.5251 20.4199L12.4749 21.5809L24.1844 12.0004Z",fill:"#314157"}),e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 12.75L2 12.75L2 11.25L7 11.25L7 12.75Z",fill:"#017338"})]),e("defs",null,[e("clipPath",{id:"clip0_4565_44816"},[e("rect",{width:"24",height:"24",fill:"white"})])])],-1),D={__name:"NewsView",setup(R){const v=N.useMq(),c=S(),o=r(!0);localStorage.getItem(u)||c.commit("SET_NEWS_PAGINATION_PAGE",1),localStorage.removeItem(u);const d=r({}),i=r({page:c.state.newsPaginationPage,pageCount:0,pageSize:8,total:0}),_=()=>{A.get(`/articles/?populate=*&sort[1]=date:desc&pagination[pageSize]=${i.value.pageSize}&pagination[page]=${i.value.page}`).then(function(t){d.value=t.data,i.value=t.meta.pagination,o.value=!1,window.scrollTo({top:0,behavior:"smooth"})}).catch(function(t){o.value=!1,console.log(t)})},f=t=>{i.value.page=t,c.commit("SET_NEWS_PAGINATION_PAGE",t),o.value=!0,_()};E(()=>{_()});const w=t=>{let a=t.split("-");return`${a[2]}.${a[1]}.${a[0]}`};return(t,a)=>{const L=P("router-link");return n(),l(g,null,[o.value?(n(),l("div",M)):p("",!0),o.value?p("",!0):(n(),l("div",V,[$,e("div",B,[(n(!0),l(g,null,k(d.value,s=>(n(),l("div",{class:"cards__item",key:s.id},[e("div",G,m(w(s.attributes.date)),1),e("div",b,[e("div",y,m(s.attributes.title),1),h(L,{to:{name:"singleNews",params:{id:s.id}},class:"cards__item-link"},{default:T(()=>[C(" Читать "),O]),_:2},1032,["to"])])]))),128)),h(I,{pagination:i.value,center:!!x(v).smMinus,onOnChangePage:a[0]||(a[0]=s=>f(s))},null,8,["pagination","center"])])]))],64)}}};export{D as default};