import{b as A,r as c,j as e,u as V,c as D}from"./vendor-react-C630P38J.js";import{q as T,p as w,t as I,f as M,m as Q,O as q}from"./vendor-fxts-IS4CCBC4.js";import{P as O}from"./vendor-overlay-B61Jbn6n.js";import{u as y,t as G,bL as R,N as K,ae as Z,d as k,bM as W,j as Y,h as J}from"./feature-order-C2we0F5o.js";import"./vendor-utils-Cb1MAKRV.js";import"./useMyReviewableList-DavuWkI1.js";import{E as X,c as ee}from"./index-DQ2TQ3yY.js";import{f as B,g as te}from"./vendor-query-BjC2S-sR.js";import{f as oe,e as z}from"./usePageGuard-DezxG6D_.js";import{P as re}from"./index-BNckj-u7.js";import{S as se,b as ne}from"./vendor-swiper-CwUwDtZu.js";import{a as _,P as ce}from"./event-B2tWEq9c.js";import{u as U}from"./vendor-i18n-D_F5k183.js";import{S as ae}from"./index-D8myZodE.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-DOpJRihs.js";import"./vendor-meta-D6H5T8-B.js";import"./useProductSectionProductList-DB50oUuG.js";import"./index-nim7WYfB.js";const ie=({eventKey:r,searchParams:t,options:m})=>B(oe({eventKey:r,searchParams:t,options:m})),le=({eventNo:r,sectionNo:t,searchParams:m,options:i})=>B(z({eventNo:r,sectionNo:t,searchParams:m,options:i}));var ue="_9eferz0",me="_9eferz1",pe="_9eferz2",de="_9eferz3";const $=r=>`Section-${r}`,F=(r,t)=>Math.max(Number(r.get($(t)))||1,1),H=r=>({pageNumber:r,pageSize:_.DEFAULT_PAGE_SIZE,order:"ADMIN_SETTING",saleStatus:"RESERVATION_AND_ONSALE",includeStopProduct:!0}),Ne=({eventNo:r,section:t,showSectionLabel:m,onScrollMove:i,ref:l})=>{const{sectionNo:u,label:p}=t,{isMobile:v}=y(),[o,b]=A(),[,d]=c.useTransition(),E=c.useRef(null),x=$(u),j=F(o,u),C=c.useMemo(()=>H(j),[j]),f=c.useCallback(s=>{if(E.current=s,typeof l=="function"){l(s);return}l&&(l.current=s)},[l]),S=c.useCallback(s=>{i(u),d(()=>{b(N=>{const P=new URLSearchParams(N);return P.set(x,s.toString()),P},{replace:!0})})},[x,u,i,b,d]),{data:h}=le({eventNo:r,sectionNo:u,searchParams:C}),g=c.useMemo(()=>{var s;return((s=h==null?void 0:h.products)==null?void 0:s.map(N=>G(N)))??[]},[h]),n=(h==null?void 0:h.totalCount)??0,a=c.useMemo(()=>v?t.mobilePerRow||_.MOBILE_PER_ROW:t.pcPerRow||_.PC_PER_ROW,[v,t]);return T(g)?null:e.jsxs("div",{className:ue,id:`${u}`,ref:f,children:[m&&p&&e.jsx("h3",{className:me,children:p}),e.jsx("ul",{className:pe,style:{"--event-products-columns":a},children:g.map(s=>e.jsx("li",{children:e.jsx(re,{...s,isMobile:v})},`${u}-${s.productNo}`))}),n>_.DEFAULT_PAGE_SIZE&&e.jsx(ce,{currentPage:j,totalCount:n,pageSize:_.DEFAULT_PAGE_SIZE,onPageClick:S,className:de})]})};var Se="_1jro08b0",fe="_1jro08b1",ve="_1jro08b2",be="_1jro08b3",he="_1jro08b4",je="_1jro08b5",xe="_1jro08b6",Ee="_1jro08b7",ge="_1jro08b8",Ce="_1jro08b9",Pe="_1jro08ba",_e="_1jro08bb",Re="_1jro08bc",Te="_1jro08bd";const ye=100,we=r=>{var g;const t=c.useRef(null),m=c.useRef(null),i=c.useRef(new Map),l=c.useRef(!1),u=c.useRef(null),[p,v]=c.useState(0),[o,b]=c.useState(!1),d=p||((g=r[0])==null?void 0:g.sectionNo)||0,E=c.useCallback(n=>{t.current=n},[]),x=c.useCallback(()=>{var s;const n=parseFloat(getComputedStyle(document.body).getPropertyValue("--header-height"))||0,a=((s=m.current)==null?void 0:s.getBoundingClientRect().height)??0;return n+a},[]),j=c.useCallback(n=>{var s;v(n);const a=r.findIndex(N=>N.sectionNo===n);a>=0&&((s=t.current)==null||s.slideTo(a))},[r]),C=c.useCallback((n,a)=>{if(a){i.current.set(n,a);return}i.current.delete(n)},[]),f=c.useCallback(()=>{const n=x()+50,a=w(r,Q(N=>{const P=i.current.get(N.sectionNo);return P?{sectionNo:N.sectionNo,top:P.getBoundingClientRect().top}:null}),M(N=>N!==null),I);if(!a.length)return null;const s=q(w(a,M(N=>N.top<=n),I)??[]);return(s==null?void 0:s.sectionNo)??a[0].sectionNo},[x,r]),S=c.useCallback(()=>{const n=f();n&&j(n)},[f,j]);c.useEffect(()=>{var N;const n=()=>{l.current||S()},a=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(S,ye)};l.current||S(),window.addEventListener("resize",a);const s=(N=R)==null?void 0:N.on("scroll",n);return()=>{u.current&&clearTimeout(u.current),s==null||s(),window.removeEventListener("resize",a)}},[S]);const h=c.useCallback(n=>{const a=i.current.get(n);l.current||!a||!R||(l.current=!0,b(!0),j(n),R.scrollTo(a,{offset:-x(),lock:!0,onComplete:()=>{l.current=!1,b(!1),S()}}))},[x,j,S]);return{activeSectionNo:d,isScrollLocked:o,onScrollMove:h,setProductSectionRef:C,setSwiper:E,tabRef:m}},Ie=({sectionTabList:r,swiperSettings:t,children:m})=>{const{activeSectionNo:i,isScrollLocked:l,onScrollMove:u,setProductSectionRef:p,setSwiper:v,tabRef:o}=we(r),b=r.length>1;return e.jsxs(e.Fragment,{children:[b&&e.jsx("nav",{className:xe,ref:o,"aria-label":"기획전 섹션 메뉴",children:e.jsx(se,{className:Ee,...t,onSwiper:v,role:"tablist",children:r.map(d=>{const E=i===d.sectionNo;return e.jsx(ne,{className:ge,"data-selected":E?"true":"false",role:"presentation",children:e.jsx("button",{role:"tab",id:`${d.sectionNo}`,"aria-selected":E,"aria-controls":`${d.sectionNo}`,disabled:l,onClick:()=>{u(d.sectionNo)},children:e.jsx("span",{children:d.label})})},d.sectionNo)})})}),m({onScrollMove:u,setProductSectionRef:p,showSectionLabel:b})]})};var Me="_87431b0",L="_87431b1";const Oe=({label:r,top:t})=>{const{t:m}=U(),{isMobile:i}=y();return e.jsxs("div",{className:Me,children:[i?e.jsxs("div",{className:L,children:[t.mobile.type==="FILE"&&t.mobile.url!==""&&e.jsx("img",{src:t.mobile.url,alt:r}),t.mobile.type==="HTML"&&e.jsx("div",{dangerouslySetInnerHTML:{__html:t.mobile.url}})]}):e.jsxs("div",{className:L,children:[t.pc.type==="FILE"&&t.pc.url!==""&&e.jsx("img",{src:t.pc.url,alt:r}),t.pc.type==="HTML"&&e.jsx("div",{dangerouslySetInnerHTML:{__html:t.pc.url}})]}),(i&&!t.mobile.url||!i&&!t.pc.url)&&e.jsx(K,{text:m("상세 내용이 없습니다.")})]})},ke=c.memo(Oe),Le=({eventNo:r,sections:t,query:m,enabled:i})=>{const l=te({queries:i?t.map(p=>z({eventNo:r,sectionNo:p.sectionNo,searchParams:H(F(m,p.sectionNo))})):[]});return{sectionTabList:c.useMemo(()=>t.reduce((p,v,o)=>{var d;return(((d=l[o])==null?void 0:d.data.totalCount)??0)>0&&p.push({label:v.label,sectionNo:v.sectionNo}),p},[]),[l,t])}},it=()=>{const r=V(),{t}=U(),{isMobile:m}=y(),i=D(),[l]=A(),u=i.eventKey,p=l.get("preview")==="true",v=c.useMemo(()=>({...p&&{preview:p}}),[p]),{data:o}=ie({eventKey:u,searchParams:{includeNonMemberCoupon:!0,...v}}),b=()=>{r(J.EVENTS.MAIN)},d={slidesPerView:"auto",spaceBetween:10},E=o.orders.includes("SECTIONS")&&!T(o.section),{sectionTabList:x}=Le({eventNo:o.eventNo,sections:o.section,query:l,enabled:E}),j=f=>{if(m){O.open(S=>e.jsx(X,{...S,eventNo:f.eventNo,couponInfo:f.coupon}));return}O.open(S=>e.jsx(ee,{...S,eventNo:f.eventNo,couponInfo:f.coupon}))},C=c.useMemo(()=>o?o.coupon.coupons.length>0:!1,[o]);return e.jsxs("section",{className:Se,children:[e.jsxs("header",{className:fe,children:[e.jsx("h1",{className:ve,children:o==null?void 0:o.label}),!!(o!=null&&o.promotionText)&&e.jsx("p",{className:be,children:o.promotionText})]}),e.jsxs(Z,{gap:m?"15px":"100px",children:[o==null?void 0:o.orders.map(f=>f==="TOP"?e.jsx(ke,{label:o.label,top:o.top},"TOP"):f==="COUPONS"&&C?e.jsxs("div",{className:Ce,children:[e.jsx("p",{children:"지금 바로 기획전에서 사용할 수 있는 쿠폰을 다운 받으세요!"}),e.jsx(k,{tone:"orange",variant:"soft",className:Pe,onClick:()=>{j(o)},children:"쿠폰받기"})]},"COUPONS"):f==="SECTIONS"&&!T(o.section)?e.jsx("div",{className:he,children:e.jsx(Ie,{sectionTabList:x,swiperSettings:d,children:({onScrollMove:S,setProductSectionRef:h,showSectionLabel:g})=>e.jsx("div",{className:je,children:o.section.map((n,a)=>e.jsx(W,{children:e.jsx(Ne,{eventNo:o.eventNo,section:n,index:a,showSectionLabel:g,onScrollMove:S,ref:s=>{h(n.sectionNo,s)}})},n.sectionNo))})})},"SECTIONS"):null),e.jsxs("div",{className:_e,children:[e.jsx(k,{tone:"dark",variant:"outline",className:Re,onClick:b,children:t("목록으로")}),e.jsx(ae,{wrapperClassName:Te,iconProps:{color:Y.white}})]})]})]})};export{it as default};