import{r as c,j as e,L as A,b as C}from"./vendor-react-C630P38J.js";import{q as D}from"./vendor-fxts-IS4CCBC4.js";import{E,P as I}from"./event-B2tWEq9c.js";import{d as k,k as N}from"./vendor-query-BjC2S-sR.js";import{i as O,a as Y}from"./usePageGuard-DezxG6D_.js";import{u as b,h as R,Q as $,a3 as F,L as G,T as V,N as U}from"./feature-order-C2we0F5o.js";import{d as h}from"./vendor-utils-Cb1MAKRV.js";import{u as f}from"./vendor-i18n-D_F5k183.js";import{a as q}from"./product-a1hBxOTz.js";import"./index-DOpJRihs.js";import"./vendor-meta-D6H5T8-B.js";import"./vendor-cookie-BFUm5jHE.js";import"./vendor-runtime-BrGgGswE.js";import"./vendor-swiper-CwUwDtZu.js";import"./vendor-hooks-D-WB61cZ.js";import"./vendor-overlay-B61Jbn6n.js";import"./vendor-rhf-CXRF5ML7.js";import"./vendor-zod-BNDLCzeL.js";import"./vendor-state-BxLZOG0B.js";import"./vendor-form-ui-C6F7344s.js";import"./vendor-date-XKm2J5pk.js";const w=({searchParams:r,options:a})=>k(O({searchParams:r,options:a}));var B="_1vi8xc70",H="_1vi8xc71",Q="_1vi8xc72",W="_1vi8xc73",Z="_1vi8xc74",J="_1vi8xc75";const K="2099-12-31",X=({eventNo:r,pcImageUrl:a,mobileimageUrl:g,label:m,promotionText:d,startYmdt:p,endYmdt:t})=>{const{isMobile:u}=b(),{t:l}=f(),x=c.useMemo(()=>h(t).isSame(K,"day")?h(p).format("YYYY.MM.DD")+" ~ ":`${h(p).format("YYYY.MM.DD")} ~ ${h(t).format("YYYY.MM.DD")}`,[p,t]);return e.jsx("article",{className:B,children:e.jsxs(A,{to:`${R.EVENTS.MAIN}/${r}`,children:[e.jsx("div",{className:H,children:e.jsx($,{src:F(u?g:a,600,600),alt:m,style:{objectFit:"cover"}})}),e.jsxs("div",{className:Q,children:[e.jsx("h2",{className:W,children:l(`${m}`)}),!!d&&e.jsx("p",{className:Z,children:l(`${d}`)}),e.jsx("p",{className:J,children:x})]})]})})};var ee="zjs10z0",se="zjs10z1",ae="zjs10z2",re="zjs10z3",te="zjs10z4",oe="zjs10z5";const Pe=()=>{const{t:r}=f(),{isMobile:a}=b(),[g,m]=C(),d=c.useMemo(()=>[{id:"recent",name:r("최근 등록순"),by:"REGISTER_DATE",direction:"DESC"},{id:"end_date",name:r("마감 임박순"),by:"END_DATE",direction:"ASC"}],[r]),p=Number(g.get("pageNumber"))||Number(E.DEFAULT_PAGE_NUMBER),t=g.get("by")??"REGISTER_DATE",u=g.get("direction")??"DESC",l=c.useMemo(()=>({page:{size:Number(E.DEFAULT_PAGE_SIZE),number:p},keywordInfo:{type:"NO",value:""},categoryNos:[],order:{by:t,direction:u}}),[t,u,p]),x=c.useMemo(()=>d.find(s=>s.by===t&&s.direction===u),[t,u,d]),S=c.useCallback((s,n)=>{m(L=>({...Object.fromEntries(L.entries()),by:s,direction:n}))},[m]),y=c.useCallback(s=>{m(n=>({...Object.fromEntries(n.entries()),pageNumber:s.toString()}))},[m]),{data:o,isLoading:_}=Y({searchParams:l,options:{placeholderData:N,enabled:!a}}),{data:i,hasNextPage:M,fetchNextPage:P,isLoading:T}=w({searchParams:l,options:{placeholderData:N,enabled:a}}),z=a?T:_,v=c.useMemo(()=>{var s;return(a?(s=i==null?void 0:i.pages)==null?void 0:s.flatMap(n=>n.data.contents):o==null?void 0:o.contents)??[]},[a,o,i]),j=c.useMemo(()=>{var s,n;return(a?(n=(s=i==null?void 0:i.pages[0])==null?void 0:s.data)==null?void 0:n.totalCount:o==null?void 0:o.totalCount)??0},[a,o,i]);return e.jsxs("section",{className:ee,children:[!a&&e.jsx("h1",{className:se,children:r("기획전")}),e.jsxs("div",{className:ae,children:[e.jsx("span",{className:re,dangerouslySetInnerHTML:{__html:r("총 {{count}}개",{count:j})}}),e.jsx(q,{type:"query",desktopVariant:"dropdown",selectedOption:x,options:d,onChange:s=>S(s.by,s.direction)})]}),e.jsx(G,{isLoading:z,isLoadedAnimation:!0,loadingStyle:{height:"50vh"},children:D(v)?e.jsx(U,{text:r("등록된 기획전이 없습니다.")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:te,children:v.map(s=>e.jsx(X,{...s},s.eventNo))}),a?e.jsx(V,{handleChange:P,hasNextPage:M,totalCount:j}):e.jsx("div",{className:oe,children:e.jsx(I,{totalCount:j,currentPage:l.page.number,pageSize:l.page.size,onPageClick:y})})]})})]})};export{Pe as default};