import{r as l,j as e,c as k,b as z}from"./vendor-react-C630P38J.js";import{S as b,a as A}from"./product-a1hBxOTz.js";import{L as P,N as y,T as F,u as w,b as H,t as j}from"./feature-order-C2we0F5o.js";import"./vendor-utils-Cb1MAKRV.js";import{b as V}from"./useProductSectionProductList-DB50oUuG.js";import{a as G}from"./vendor-query-BjC2S-sR.js";import{b as Q}from"./useBrandInfoByBrandNo-DQa2NbIq.js";import{q as U}from"./vendor-fxts-IS4CCBC4.js";import{e as W}from"./index-BNckj-u7.js";import"./vendor-swiper-CwUwDtZu.js";import{P as J}from"./event-B2tWEq9c.js";import"./vendor-overlay-B61Jbn6n.js";import"./vendor-i18n-D_F5k183.js";import"./vendor-rhf-CXRF5ML7.js";import"./vendor-zod-BNDLCzeL.js";import"./vendor-runtime-BrGgGswE.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"./index-nim7WYfB.js";import"./vendor-meta-D6H5T8-B.js";const K=s=>G(Q(s)),N=b.find(s=>s.id==="recommend")??b[0];var X="_1v5bqoe0",Y="_1v5bqoe1",Z="_1v5bqoe2",$="_1v5bqoe3",D="_1v5bqoe4",ee="_1v5bqoe5",se="_1v5bqoe6",re="_1v5bqoe7",oe="_1v5bqoe8";const f=l.memo(({description:s,descriptionTitle:i,extraInfo:n})=>e.jsxs("div",{className:Z,children:[s&&e.jsx("div",{className:$,dangerouslySetInnerHTML:{__html:s}}),n&&e.jsxs("div",{className:D,children:[e.jsx("h2",{children:i}),e.jsx("p",{children:n})]})]}));f.displayName="BrandIntro";const ae=({currentPage:s,hasNextPage:i,isLoading:n,isMobile:m,onFetchNextPage:p,onPageClick:u,pageSize:g,products:d,totalCount:h})=>e.jsxs(P,{isLoading:n,loadingStyle:{height:"50vh"},children:[U(d)?e.jsx(y,{text:"상품 목록이 없습니다.",style:{height:"50vh"}}):e.jsx(W,{isMobile:m,products:d}),m?e.jsx(F,{handleChange:p,hasNextPage:!!i,totalCount:h}):e.jsx("div",{className:oe,children:e.jsx(J,{totalCount:h,currentPage:s,onPageClick:u,pageSize:g})})]}),qe=()=>{const{isMobile:s}=w(),{brandNo:i=""}=k(),[n,m]=z(),p=Number(i)||0,u=Number(n.get("pageNumber"))||1,g=n.get("by")??N.by,d=n.get("direction")??N.direction,h=l.useMemo(()=>b.find(r=>r.by===g&&r.direction===d)??N,[g,d]),x=l.useMemo(()=>({brandNos:[p],pageSize:s?20:16,pageNumber:u,order:{by:g,direction:d},filter:{soldout:!0}}),[p,s,g,d,u]),{data:o,isLoading:C,isError:S}=K({displayBrandNo:p,options:{enabled:!!p}}),{data:a,isLoading:_}=H({searchParams:x,options:{enabled:!s&&!!i,select:r=>({items:(r.items??[]).map(j),totalCount:r.totalCount??0})}}),{fetchNextPage:B,hasNextPage:q,data:t,isLoading:T}=V({searchParams:x,options:{enabled:s&&!!i,select:r=>({...r,pages:r.pages.map(c=>({...c,data:{items:c.data.items.map(j),totalCount:c.data.totalCount??0}}))})}}),O=l.useMemo(()=>s?(t==null?void 0:t.pages.flatMap(r=>r.data.items))??[]:(a==null?void 0:a.items)??[],[t==null?void 0:t.pages,s,a==null?void 0:a.items]),v=l.useMemo(()=>{var r;return s?((r=t==null?void 0:t.pages[0])==null?void 0:r.data.totalCount)??0:(a==null?void 0:a.totalCount)??0},[t==null?void 0:t.pages,s,a==null?void 0:a.totalCount]),I=s?T:_,E=(o==null?void 0:o.mainBrandName)??"",L=(o==null?void 0:o.subBrandName)||(o==null?void 0:o.mainBrandName)||"",M=l.useCallback(r=>{r&&m(c=>({...Object.fromEntries(c.entries()),by:r.by,direction:r.direction,pageNumber:"1"}))},[m]),R=l.useCallback(r=>{m(c=>({...Object.fromEntries(c.entries()),pageNumber:r.toString()}))},[m]);return e.jsx("section",{className:X,children:e.jsx(P,{isLoading:C,loadingStyle:{height:"50vh"},children:o&&!S?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:Y,children:E}),e.jsx(f,{description:o.description,descriptionTitle:L,extraInfo:o.extraInfo}),e.jsxs("div",{className:ee,children:[e.jsxs("p",{className:se,children:["총 ",e.jsx("strong",{children:v}),"개 상품"]}),e.jsx("div",{className:re,children:e.jsx(A,{type:"query",desktopVariant:"dropdown",ariaLabel:"상품 정렬",options:b,selectedOption:h,onChange:M})})]}),e.jsx(ae,{currentPage:u,hasNextPage:q,isLoading:I,isMobile:s,onFetchNextPage:B,onPageClick:R,pageSize:x.pageSize,products:O,totalCount:v})]}):e.jsx(y,{text:"브랜드 정보를 찾을 수 없습니다.",style:{height:"50vh"}})})})};export{qe as default};