import{p as Y,q as y,t as C,j as e,c as $,r as m}from"./vendor-react-C630P38J.js";import{p as Q,t as G,c as H,b as j,f as K,q as S}from"./vendor-fxts-IS4CCBC4.js";import{a as X,E as J}from"./vendor-runtime-BrGgGswE.js";import{S as E,a as Z}from"./product-a1hBxOTz.js";import{u as v,b as _,t as R,R as ee,z as O,L as T,N as se,T as ae}from"./feature-order-C2we0F5o.js";import{u as te,P as re,C as oe}from"./index-DrhpmguR.js";import{a as ie}from"./index-nim7WYfB.js";import"./vendor-utils-Cb1MAKRV.js";import{b as ne}from"./useProductSectionProductList-DB50oUuG.js";import{c as le,b as ce,t as me,p as de,a as pe}from"./shared.css-DH9SezeH.js";import{P as ue}from"./event-B2tWEq9c.js";import{S as ge,a as he,P as Ne,b as Pe}from"./vendor-swiper-CwUwDtZu.js";import{f as be}from"./index-DOpJRihs.js";import{f as fe,g as xe,e as ye}from"./index-BNckj-u7.js";import"./vendor-query-BjC2S-sR.js";import"./vendor-overlay-B61Jbn6n.js";import"./vendor-i18n-D_F5k183.js";import"./vendor-rhf-CXRF5ML7.js";import"./vendor-zod-BNDLCzeL.js";import"./vendor-hooks-D-WB61cZ.js";import"./vendor-cookie-BFUm5jHE.js";import"./vendor-state-BxLZOG0B.js";import"./vendor-form-ui-C6F7344s.js";import"./vendor-date-XKm2J5pk.js";import"./vendor-meta-D6H5T8-B.js";const Ce=["POPULAR","SALE_YMD","SALE_END_YMD","DISCOUNTED_PRICE","REVIEW","SALE_CNT","RECENT_PRODUCT","MD_RECOMMEND","LIKE_CNT","EXPIRATION_DATE"],je=["ASC","DESC"],Se=()=>Y({pageNumber:C.withDefault(1),selectedCategoryNo:C.withDefault(0),by:y(Ce).withDefault("RECENT_PRODUCT"),direction:y(je).withDefault("DESC")},{shallow:!1,history:"push"});var I="_1th7p5k0",Ee="_1th7p5k1",L="_1th7p5k2";const _e=({categoryNo:o})=>{const{isMobile:d}=v();return o?e.jsx(X,{...be({type:"id",banners:[`BAND_BANNER_${o}`],options:{select:a=>Q(a,j(t=>t.accounts),K(t=>d?t.accountName==="MOBILE":t.accountName==="PC"),j(t=>t.banners),H(t=>t.displayOrder),G)}}),children:({data:a})=>{if(a.length===0)return null;if(a.length===1){const[t]=a;return e.jsx("section",{className:I,children:e.jsx("img",{className:L,src:t.imageUrl,alt:t.description})})}return e.jsx("section",{className:I,children:e.jsx(ge,{className:Ee,modules:[he,Ne],autoplay:{delay:3e3,disableOnInteraction:!1},loop:!0,pagination:{clickable:!0},slidesPerView:1,children:a.map(t=>e.jsx(Pe,{children:e.jsx("img",{className:L,src:t.imageUrl,alt:t.description})},t.bannerNo))})})}}):null},Je=()=>{var x;const{isMobile:o}=v(),d=$(),a=Number(d==null?void 0:d.categoryNo)||0,[{pageNumber:t,selectedCategoryNo:A,by:P,direction:b},p]=Se(),u={categoryNos:[a],pageSize:o?20:40,pageNumber:t,order:{by:P,direction:b},filter:{soldout:!0}},M=E.find(s=>s.by===P&&s.direction===b),{data:c}=te({categoryNo:a}),f=m.useMemo(()=>c?ie(a,c.multiLevelCategories):[],[c,a]),n=m.useMemo(()=>f.find(s=>s.categoryNo===a),[f,a]),{data:r,isLoading:w,fetchNextPage:k,hasNextPage:B}=ne({searchParams:u,options:{enabled:o}}),{data:i,isLoading:U}=_({searchParams:u,options:{enabled:!o}}),{data:g,isPending:D}=_({searchParams:{categoryNos:[a],pageNumber:1,pageSize:10},options:{placeholderData:void 0,retry:!1,throwOnError:s=>{var l;return((l=s.response)==null?void 0:l.status)===503}}}),h=((x=r==null?void 0:r.pages[0])==null?void 0:x.data.totalCount)??(i==null?void 0:i.totalCount)??0,N=m.useMemo(()=>o?(r==null?void 0:r.pages.flatMap(s=>s.data.items.map(R)))??[]:(i==null?void 0:i.items.map(R))??[],[o,r==null?void 0:r.pages,i==null?void 0:i.items]),z=o?w:U,F=m.useCallback((s,l)=>{p({by:s,direction:l,pageNumber:1})},[p]),V=m.useCallback(s=>{p({pageNumber:s})},[p]),q=m.useMemo(()=>{var l;if(!o)return i;const s=(l=r==null?void 0:r.pages[0])==null?void 0:l.data;if(s)return{...s,items:r.pages.flatMap(W=>W.data.items)}},[o,r==null?void 0:r.pages,i]);return ee({searchedProduct:q,currentCategory:c}),e.jsxs("div",{className:le,children:[e.jsx(O,{fallback:e.jsx(e.Fragment,{}),errorFallback:e.jsx(e.Fragment,{}),children:e.jsx(_e,{categoryNo:a})}),!!c&&e.jsx(re,{categoryData:c}),e.jsxs("div",{className:ce,children:[!!(n!=null&&n.label)&&e.jsx("h1",{className:me,children:n.label}),!o&&e.jsx(J,{fallback:e.jsx(e.Fragment,{}),children:e.jsx(oe,{categoryNo:a,isAllButtonVisible:!1,selectedCategoryNo:A})}),D?e.jsx(T,{isLoading:!0,loadingStyle:{height:"50vh"}}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{title:`${(n==null?void 0:n.label)??"상품"} 랭킹`,products:(g==null?void 0:g.items)??[]}),e.jsx(O,{fallback:e.jsx(e.Fragment,{}),errorFallback:e.jsx(e.Fragment,{}),children:e.jsx(xe,{categoryNo:a})}),!S(N)&&e.jsxs("div",{className:de,children:[e.jsx("div",{className:pe,dangerouslySetInnerHTML:{__html:`총 ${h}개 상품`}}),e.jsx(Z,{type:"query",desktopVariant:"dropdown",selectedOption:M,options:E,onChange:s=>{F(s.by,s.direction)}})]}),e.jsxs(T,{isLoading:z,loadingStyle:{height:"50vh"},children:[S(N)?e.jsx(se,{text:"상품 목록이 없습니다.",style:{height:"50vh"}}):e.jsx(ye,{isMobile:o,products:N}),o?e.jsx(ae,{handleChange:k,hasNextPage:B,totalCount:h}):e.jsx(ue,{totalCount:h,currentPage:u.pageNumber,onPageClick:V,pageSize:u.pageSize})]})]})]})]})};export{Je as default};