import{j as e,n as c,p as r,k as P,E as W,i as R,y as E,a1 as Z,h as J}from"./index-BB3C6ia3.js";import{b as x,h as Q,u as X,n as ee,N as te}from"./vendor-q1sfVHxQ.js";import{G as O}from"./GallerySkeleton-C4Sgotyi.js";import{u as se}from"./useLayoutChanger-YzOXT8Mz.js";import{u as re,I as ae}from"./ImageZoomViewer-CG7wkUFI.js";import{S as L,a as A}from"./swiper.min-BjDUzMMs.js";import{B as ne}from"./button-5G120b2h.js";import{S as le}from"./Sanitized-DU1vp84v.js";import{S as ie}from"./StartCountdown-CMlTkPB0.js";import{u as oe}from"./useSalePeriodStatus-Dw-ZGDdg.js";import{f as ce}from"./free-mode.min-D8ybSzIe.js";import{n as $}from"./noImage-CNGZMR77.js";import{u as me}from"./useDrawDetail-DEUjg5-z.js";import{i as de,g as fe}from"./employeeDraw-D2vpuvk0.js";import"./Skeleton-jPSYsRnW.js";import"./LayoutProvider-CX1zjqgz.js";import"./useIsDesktop-DbmMhgKo.js";import"./sanitizeHtml-CNVhPZBl.js";import"./useQuery-pLogcDCk.js";import"./useBaseQuery-Ca_aEWrW.js";import"./draw-OykQxEIe.js";import"./draw.qk-9WwBdHBG.js";const G=({images:s,alt:n,onImageClick:i})=>{const[o,a]=x.useState(0);return e.jsxs("div",{className:"flex flex-col items-start gap-[0.8rem] w-full",children:[e.jsx("div",{className:"w-full overflow-hidden [&_.swiper-slide]:!h-auto",children:e.jsx(L,{slidesPerView:1,spaceBetween:8,threshold:10,onSlideChange:t=>a(t.activeIndex),children:s.map((t,m)=>e.jsx(A,{children:e.jsx("div",{className:"aspect-[936/1170] bg-[#f7f7f7] overflow-hidden cursor-zoom-in",onClick:()=>i(m),children:e.jsx("img",{src:t,alt:n||"",className:"w-full h-full object-cover"})})},m))})}),s.length>1&&e.jsx("div",{className:"flex justify-start gap-[0.2rem] w-full h-px",children:s.map((t,m)=>e.jsx("div",{className:c("w-[0.8rem] h-full",m===o?"bg-[#2e2e2e]":"bg-[#c5c5c5]")},m))})]})};G.propTypes={images:r.arrayOf(r.string).isRequired,alt:r.string,onImageClick:r.func.isRequired};const v=s=>{if(!s)return"";const[n,i=""]=s.replace(" ","T").split("T");return i?`${n} ${i.slice(0,5)}`:n},ue=s=>s==="UPCOMING"?"READY":s==="ENDED"?"END":"ONSALE",pe=({allEntered:s,isReady:n,isEnd:i,countdownUnits:o,t:a})=>s?"응모 완료":n?e.jsx(ie,{variant:"draw",countdown:o}):i?a("drawEntryEnd",{defaultValue:"응모 종료"}):a("drawEntry",{defaultValue:"응모하기"}),V=({publicCode:s,brand:n,collabBrand:i,title:o,startDate:a,endDate:t,purchaseStartDate:m,purchaseEndDate:b,resultAnnounceDate:y,phase:j,notice:C="",allEntered:I=!1})=>{const{t:f}=P("product"),{t:u}=P("common"),h=Q(),S=X(),[p,w]=x.useState({open:!1,type:"alert",message:"",onConfirm:void 0}),k=()=>w(g=>({...g,open:!1})),{isReady:l,isIng:d,isEnd:B,countdownUnits:q}=oe({salePeriodType:"PERIOD",saleStartYmdt:a,saleEndYmdt:t,saleStatusType:ue(j)}),U=x.useMemo(()=>{const g=v(a),N=v(t);return!g&&!N?"":`${g} - ${N}`},[a,t]),F=x.useMemo(()=>{const g=v(m),N=v(b);return!g&&!N?"":`${g} - ${N}`},[m,b]),M=v(y),Y=()=>{if(!R()){w({open:!0,type:"alert",message:u("loginRequiredForService"),onConfirm:()=>h("/sign-in",{state:{from:`${S.pathname}${S.search}`}})});return}h(`/draw/${s}/entry`)},H=pe({allEntered:I,isReady:l,isEnd:B,countdownUnits:q,t:f}),K=!d||I,D=B?"text-fig-text-secondary":"text-black";return e.jsxs("div",{className:c("product-info px-0 py-[6rem]","lg:px-0 lg:py-[6.4rem] lg:flex lg:flex-col lg:min-h-screen"),children:[e.jsxs("div",{className:"flex [justify-content:unset] [align-items:unset] flex-col gap-[4rem] lg:my-auto lg:shrink-0",children:[e.jsxs("div",{className:"flex flex-col items-start justify-start gap-[0.8rem]",children:[i&&e.jsx("p",{className:c("font-fig-en capitalize text-[1.2rem] leading-[1.8rem]",D),children:i}),n&&e.jsx("p",{className:c("font-fig-en font-semibold uppercase text-[1.2rem] leading-[1.8rem]",D),children:n}),o&&e.jsx("p",{className:c("font-fig-mixed text-[1.2rem] leading-[1.8rem]",D),children:o})]}),e.jsx(ne,{type:"button",variant:"solid",size:"fig-default",onClick:Y,disabled:K,className:"w-full",children:H}),e.jsxs("section",{className:"flex flex-col items-start gap-[1.6rem] border-fig-btn-disabled",children:[U&&e.jsxs("div",{className:"flex flex-col items-start justify-start w-full",children:[e.jsx("p",{className:"font-fig-mixed text-[1.2rem] leading-[1.8rem]",children:"응모기간"}),e.jsx("p",{className:"font-fig-en text-[1.2rem] leading-[1.8rem] text-black",children:U})]}),M&&e.jsxs("div",{className:"flex flex-col items-start justify-start w-full",children:[e.jsx("p",{className:"font-fig-mixed text-[1.2rem] leading-[1.8rem]",children:"당첨자 발표"}),e.jsx("p",{className:"font-fig-en text-[1.2rem] leading-[1.8rem] text-black",children:M})]}),e.jsxs("div",{className:"flex flex-col items-start justify-start w-full",children:[e.jsx("p",{className:"font-fig-mixed text-[1.2rem] leading-[1.8rem]",children:"구매 기한"}),e.jsx("p",{className:"font-fig-en text-[1.2rem] leading-[1.8rem] text-black",children:F||"-"})]}),C&&e.jsxs("div",{className:"flex flex-col items-start justify-start w-full",children:[e.jsx("p",{className:"font-fig-mixed text-[1.2rem] leading-[1.8rem]",children:"드로우 안내"}),e.jsx(le,{html:C,className:"font-fig-mixed text-[1.2rem] leading-[1.8rem] text-fig-text-secondary w-full [&_p]:m-0"})]})]})]}),p.open&&e.jsx(W,{open:p.open,onClose:k,type:p.type,message:p.message,onConfirm:p.onConfirm})]})};V.propTypes={publicCode:r.string,brand:r.string,collabBrand:r.string,title:r.string,startDate:r.string,endDate:r.string,purchaseStartDate:r.string,purchaseEndDate:r.string,resultAnnounceDate:r.string,phase:r.string,notice:r.string,allEntered:r.bool};const ge=s=>s?s.startsWith("//")?`https:${s}`:s:$,z=({index:s,brand:n,productName:i,imageUrl:o,price:a,onImageClick:t})=>{const m=()=>{t?.(s)};return e.jsxs("article",{className:"flex flex-col items-start justify-start w-full min-w-0",children:[e.jsx("div",{className:"w-full aspect-[4/5] bg-[#f7f7f7] overflow-hidden cursor-zoom-in",onClick:m,children:e.jsx("img",{src:ge(o),alt:E(i)||"",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex flex-col items-start justify-start w-full pt-[0.8rem]",children:[n&&e.jsx("p",{className:c("font-fig-en font-semibold uppercase","text-[1.2rem] leading-[1.8rem] text-black"),children:E(n)}),i&&e.jsx("p",{className:c("font-fig-mixed","text-[1.2rem] leading-[1.8rem] text-black"),children:E(i)}),Number.isFinite(a)&&e.jsxs("p",{className:c("font-fig-en","text-[1.2rem] leading-[1.8rem] text-black"),children:["₩",Z(a)]})]})]})};z.propTypes={index:r.number.isRequired,brand:r.string,productName:r.string,imageUrl:r.string,price:r.number,onImageClick:r.func};const _=({brand:s,products:n=[],onImageClick:i})=>{if(!n.length)return null;const o=(a,t)=>e.jsx(z,{index:t,brand:s,productName:a.productName,imageUrl:a.imageUrl,price:a.price,onImageClick:i});return e.jsxs("section",{className:"w-full",children:[e.jsx("h3",{className:"font-fig-mixed font-bold text-[1.2rem] leading-[1.8rem] mb-[0.8rem]",children:"진행 제품"}),e.jsx("div",{className:c("grid grid-cols-2 gap-x-[0.8rem] gap-y-[3.2rem]","md:hidden"),children:n.map((a,t)=>e.jsx("div",{children:o(a,t)},a.id??t))}),e.jsx(L,{className:"hidden md:block swiper--bleed",modules:[ce],freeMode:!0,threshold:10,slidesPerView:4,spaceBetween:8,breakpoints:{0:{slidesPerView:4,spaceBetween:8,threshold:10},1024:{slidesPerView:6,spaceBetween:8,threshold:10}},children:n.map((a,t)=>e.jsx(A,{children:o(a,t)},a.id??t))})]})};_.propTypes={brand:r.string,products:r.arrayOf(r.shape({id:r.number,productName:r.string,imageUrl:r.string,price:r.number})),onImageClick:r.func};const T=s=>s?s.startsWith("//")?`https:${s}`:s:$,Le=()=>{const{t:s}=P(["title","common"]),{publicCode:n}=ee(),{profile:i}=J(),o=de(n)&&!R()?"SIGN_IN":fe(n,i),a=o==="PASS",{data:t,isLoading:m,error:b}=me(n,{enabled:a});se({hasBackBtnOnHeader:!0,title:a&&t?.title||s("title:draw")});const[y,j]=x.useState(null),{ref:C,top:I}=re(),f=t?.products??[],u=x.useMemo(()=>{const l=[];return t?.mainImageUrl&&l.push(T(t.mainImageUrl)),(t?.detailImageUrls??[]).forEach(d=>{d&&l.push(T(d))}),l.length===0&&l.push($),l},[t?.mainImageUrl,t?.detailImageUrls]),h=x.useMemo(()=>{const l=u.map(d=>({url:d}));return f.forEach(d=>l.push({url:T(d.imageUrl)})),l},[u,f]),S=u.length,p=f.length>0&&f.every(l=>l.hasEntered===!0);if(o==="SIGN_IN")return e.jsx(te,{replace:!0,to:"/sign-in",state:{from:`/draw/${n}`}});if(o==="PENDING")return e.jsx("div",{className:"page-inner",children:e.jsx(O,{rowCount:1,colCount:1,isLoading:!0})});if(o==="BLOCKED")return e.jsx("div",{className:"page-inner flex items-center justify-center py-[6rem]",children:e.jsx("p",{className:"not-found-product",children:"유효하지 않은 페이지입니다."})});if(m)return e.jsx("div",{className:"page-inner",children:e.jsx(O,{rowCount:1,colCount:1,isLoading:!0})});if(b||!t)return e.jsx("div",{className:"page-inner flex items-center justify-center py-[6rem]",children:e.jsx("p",{className:"not-found-product",children:s("common:noProducts")})});const w=l=>{h.length&&j(l)},k=l=>{j(l+S)};return e.jsxs("div",{className:c("product-detail flex flex-col items-stretch w-full","lg:gap-[6rem] lg:px-[2rem]"),children:[e.jsxs("div",{className:c("lg:flex lg:w-full lg:items-start lg:justify-start lg:gap-[7.76vw]"),children:[e.jsxs("div",{className:c("lg:w-[48.75vw] lg:max-w-[124.8rem] lg:pt-[6rem]"),children:[e.jsx("div",{className:"lg:hidden",children:e.jsx(G,{images:u,alt:t.title,onImageClick:w})}),e.jsx("div",{className:c("hidden","lg:flex flex-col gap-[0.8rem]"),children:u.map((l,d)=>e.jsx("div",{className:"aspect-[936/1170] bg-[#f7f7f7] overflow-hidden cursor-zoom-in",onClick:()=>w(d),children:e.jsx("img",{src:l,alt:t.title||"",className:"w-full h-full object-cover"})},d))})]}),e.jsx("div",{ref:C,style:{top:I},className:c("lg:w-[32.34vw] lg:max-w-[82.8rem] lg:sticky"),children:e.jsx(V,{publicCode:t.publicCode,brand:t.brand,collabBrand:t.collabBrand,title:t.title,startDate:t.startDate,endDate:t.endDate,purchaseStartDate:t.purchaseStartDate,purchaseEndDate:t.purchaseEndDate,resultAnnounceDate:t.resultAnnounceDate,phase:t.phase,notice:t.notice,allEntered:p})})]}),e.jsx("div",{className:c("w-full pt-[6rem] pb-[6rem]","lg:px-0 lg:pt-0"),children:e.jsx(_,{brand:t.brand,products:f,onImageClick:k})}),y!==null&&h.length>0&&e.jsx(ae,{images:h,initialIndex:y,onClose:()=>j(null)})]})};export{Le as default};