import{M as X,u as fe,Q as Z,g as Ce,a1 as ke,a2 as Me,a3 as U,a4 as z,d as T,a as B,j as e,c as u,a5 as Ee,z as xe,a6 as $,R as J,a7 as te,k as N,a8 as G,T as x,G as E,a9 as L,aa as pe,ab as be,b as R,e as q,f as K,ac as ve,m as V,ad as Le,C as Ne,ae as Re,o as ge,U as D,W as je,af as Q,ag as Oe,s as Y,ah as Be,ai as ye,aj as Pe,ak as F,al as we,am as Ie,L as We,an as Ae,ao as $e,ap as Fe,Z as Ve,aq as _e,ar as Ue,as as ze}from"../index.Crez7j-Y.bundle.js";import{u as Te,a as He}from"./useCartHooks.CwGnxama.bundle.js";import{P as Ge}from"./pagination.DC11PWmb.bundle.js";import{N as Se}from"./OrderSheetAPIs.DiQ9xHhr.bundle.js";const qe=(n,t)=>{const{getProductDetailAPI:o}=X();return fe({queryKey:Z.productDetail(n),queryFn:()=>o(n),enabled:n!==0&&!isNaN(n),...t})},Ke=(n,t)=>{const{getRelatedProductListAPI:o}=X();return fe({queryKey:Z.relatedProductList(n),queryFn:()=>o(n),enabled:n>0&&!isNaN(n),...t})};function se(n){let{swiper:t,extendParams:o,on:m}=n;o({thumbs:{swiper:null,multipleActiveThumbs:!0,autoScrollOffset:0,slideThumbActiveClass:"swiper-slide-thumb-active",thumbsContainerClass:"swiper-thumbs"}});let b=!1,s=!1;t.thumbs={swiper:null};function a(){const r=t.thumbs.swiper;if(!r||r.destroyed)return;const i=r.clickedIndex,v=r.clickedSlide;if(v&&v.classList.contains(t.params.thumbs.slideThumbActiveClass)||typeof i>"u"||i===null)return;let g;r.params.loop?g=parseInt(r.clickedSlide.getAttribute("data-swiper-slide-index"),10):g=i,t.params.loop?t.slideToLoop(g):t.slideTo(g)}function h(){const{thumbs:r}=t.params;if(b)return!1;b=!0;const i=t.constructor;if(r.swiper instanceof i)t.thumbs.swiper=r.swiper,Object.assign(t.thumbs.swiper.originalParams,{watchSlidesProgress:!0,slideToClickedSlide:!1}),Object.assign(t.thumbs.swiper.params,{watchSlidesProgress:!0,slideToClickedSlide:!1}),t.thumbs.swiper.update();else if(ke(r.swiper)){const v=Object.assign({},r.swiper);Object.assign(v,{watchSlidesProgress:!0,slideToClickedSlide:!1}),t.thumbs.swiper=new i(v),s=!0}return t.thumbs.swiper.el.classList.add(t.params.thumbs.thumbsContainerClass),t.thumbs.swiper.on("tap",a),!0}function c(r){const i=t.thumbs.swiper;if(!i||i.destroyed)return;const v=i.params.slidesPerView==="auto"?i.slidesPerViewDynamic():i.params.slidesPerView;let g=1;const l=t.params.thumbs.slideThumbActiveClass;if(t.params.slidesPerView>1&&!t.params.centeredSlides&&(g=t.params.slidesPerView),t.params.thumbs.multipleActiveThumbs||(g=1),g=Math.floor(g),i.slides.forEach(j=>j.classList.remove(l)),i.params.loop||i.params.virtual&&i.params.virtual.enabled)for(let j=0;j{d.classList.add(l)});else for(let j=0;jM.getAttribute("data-swiper-slide-index")==="".concat(t.realIndex))[0];d=i.slides.indexOf(p),k=t.activeIndex>t.previousIndex?"next":"prev"}else d=t.realIndex,k=d>t.previousIndex?"next":"prev";I&&(d+=k==="next"?f:-1*f),i.visibleSlidesIndexes&&i.visibleSlidesIndexes.indexOf(d)<0&&(i.params.centeredSlides?d>j?d=d-Math.floor(v/2)+1:d=d+Math.floor(v/2)-1:d>j&&i.params.slidesPerGroup,i.slideTo(d,r?0:void 0))}}m("beforeInit",()=>{const{thumbs:r}=t.params;if(!(!r||!r.swiper))if(typeof r.swiper=="string"||r.swiper instanceof HTMLElement){const i=Ce(),v=()=>{const l=typeof r.swiper=="string"?i.querySelector(r.swiper):r.swiper;if(l&&l.swiper)r.swiper=l.swiper,h(),c(!0);else if(l){const f="".concat(t.params.eventsPrefix,"init"),I=j=>{r.swiper=j.detail[0],l.removeEventListener(f,I),h(),c(!0),r.swiper.update(),t.update()};l.addEventListener(f,I)}return l},g=()=>{if(t.destroyed)return;v()||requestAnimationFrame(g)};requestAnimationFrame(g)}else h(),c(!0)}),m("slideChange update resize observerUpdate",()=>{c()}),m("setTransition",(r,i)=>{const v=t.thumbs.swiper;!v||v.destroyed||v.setTransition(i)}),m("beforeDestroy",()=>{const r=t.thumbs.swiper;!r||r.destroyed||s&&r.destroy()}),Object.assign(t.thumbs,{init:h,update:c})}function ne(n){let{swiper:t,extendParams:o,emit:m,once:b}=n;o({freeMode:{enabled:!1,momentum:!0,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,momentumVelocityRatio:1,sticky:!1,minimumVelocity:.02}});function s(){if(t.params.cssMode)return;const c=t.getTranslate();t.setTranslate(c),t.setTransition(0),t.touchEventsData.velocities.length=0,t.freeMode.onTouchEnd({currentPos:t.rtl?t.translate:-t.translate})}function a(){if(t.params.cssMode)return;const{touchEventsData:c,touches:r}=t;c.velocities.length===0&&c.velocities.push({position:r[t.isHorizontal()?"startX":"startY"],time:c.touchStartTime}),c.velocities.push({position:r[t.isHorizontal()?"currentX":"currentY"],time:U()})}function h(c){let{currentPos:r}=c;if(t.params.cssMode)return;const{params:i,wrapperEl:v,rtlTranslate:g,snapGrid:l,touchEventsData:f}=t,j=U()-f.touchStartTime;if(r<-t.minTranslate()){t.slideTo(t.activeIndex);return}if(r>-t.maxTranslate()){t.slides.length1){const y=f.velocities.pop(),C=f.velocities.pop(),_=y.position-C.position,ee=y.time-C.time;t.velocity=_/ee,t.velocity/=2,Math.abs(t.velocity)150||U()-y.time>300)&&(t.velocity=0)}else t.velocity=0;t.velocity*=i.freeMode.momentumVelocityRatio,f.velocities.length=0;let d=1e3*i.freeMode.momentumRatio;const k=t.velocity*d;let p=t.translate+k;g&&(p=-p);let M=!1,w;const O=Math.abs(t.velocity)*20*i.freeMode.momentumBounceRatio;let P;if(pt.minTranslate())i.freeMode.momentumBounce?(p-t.minTranslate()>O&&(p=t.minTranslate()+O),w=t.minTranslate(),M=!0,f.allowMomentumBounce=!0):p=t.minTranslate(),i.loop&&i.centeredSlides&&(P=!0);else if(i.freeMode.sticky){let y;for(let C=0;C-p){y=C;break}Math.abs(l[y]-p){t.loopFix()}),t.velocity!==0){if(g?d=Math.abs((-p-t.translate)/t.velocity):d=Math.abs((p-t.translate)/t.velocity),i.freeMode.sticky){const y=Math.abs((g?-p:p)-t.translate),C=t.slidesSizesGrid[t.activeIndex];y{!t||t.destroyed||!f.allowMomentumBounce||(m("momentumBounce"),t.setTransition(i.speed),setTimeout(()=>{t.setTranslate(w),z(v,()=>{!t||t.destroyed||t.transitionEnd()})},0))})):t.velocity?(m("_freeModeNoMomentumRelease"),t.updateProgress(p),t.setTransition(d),t.setTranslate(p),t.transitionStart(!0,t.swipeDirection),t.animating||(t.animating=!0,z(v,()=>{!t||t.destroyed||t.transitionEnd()}))):t.updateProgress(p),t.updateActiveIndex(),t.updateSlidesClasses()}else if(i.freeMode.sticky){t.slideToClosest();return}else i.freeMode&&m("_freeModeNoMomentumRelease");(!i.freeMode.momentum||j>=i.longSwipesMs)&&(m("_freeModeStaticRelease"),t.updateProgress(),t.updateActiveIndex(),t.updateSlidesClasses())}Object.assign(t,{freeMode:{onTouchStart:s,onTouchMove:a,onTouchEnd:h}})}const Qe=()=>(T.useEffect(()=>{const n=a=>(a.preventDefault(),!1),t=a=>{a.preventDefault()},o=a=>{a.preventDefault()},m=a=>{(a.target instanceof HTMLPictureElement||a.target instanceof HTMLImageElement)&&a.preventDefault()},b=a=>{a.target.tagName==="IMG"&&a.preventDefault()},s=a=>{(a.key==="PrintScreen"||a.ctrlKey&&a.shiftKey&&a.key==="I"||a.ctrlKey&&a.key==="C"||a.ctrlKey&&a.key==="U")&&a.preventDefault()};return document.removeEventListener("copy",n),document.addEventListener("selectstart",t),document.addEventListener("dragstart",o),document.addEventListener("contextmenu",m),document.addEventListener("keydown",s),document.addEventListener("mousedown",b),()=>{document.removeEventListener("copy",n),document.removeEventListener("selectstart",t),document.removeEventListener("dragstart",o),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",s),document.removeEventListener("mousedown",b)}},[]),{}),S={Product:0,Delivery:1};function ie({isPending:n,productDetail:t}){const o=T.useRef(new Map),[m,b]=T.useState(S.Product),s=(c,r)=>{b(r);const i=o.current.get(r);i&&i.scrollIntoView({behavior:"smooth"})},{isDesktop:a,isMobile:h}=B();return T.useEffect(()=>{const c=()=>{const r=o.current.get(S.Delivery);if(!r)return;const i=window.scrollY+window.innerHeight/2;r&&i<=r.offsetTop?b(S.Product):b(S.Delivery)};return a&&window.addEventListener("scroll",c),()=>{a&&window.removeEventListener("scroll",c)}},[]),e.jsxs(u,{mt:{desktop:10,mobile:0},children:[e.jsxs(Ee,{variant:"fullWidth",value:m,onChange:s,sx:{position:"sticky",top:0,zIndex:xe.Tabs,mt:{desktop:5,mobile:0},bgcolor:$,"& .MuiTabs-indicator":{backgroundColor:J}},children:[e.jsx(te,{id:"product-info",value:S.Product,sx:{borderBottom:"2px solid ".concat(N),paddingBlock:2,"&.Mui-selected":{color:G}},label:e.jsx(x,{variant:"subtitle2",fontWeight:600,children:"상품 상세정보"})}),e.jsx(te,{id:"delivery-info",value:S.Delivery,sx:{borderBottom:"2px solid ".concat(N),paddingBlock:2,"&.Mui-selected":{color:G}},label:e.jsx(x,{variant:"subtitle2",fontWeight:600,children:"배송/반품/교환 안내"})})]}),h&&e.jsxs(e.Fragment,{children:[m===S.Product&&e.jsx(u,{py:6,id:"detail-product-info",ref:c=>{const r=o.current;c?r.set(S.Product,c):r.delete(S.Product)},children:e.jsx(ce,{isPending:n,productDetail:t})}),m===S.Delivery&&e.jsx(u,{py:6,id:"detail-delivery-info",ref:c=>{const r=o.current;c?r.set(S.Delivery,c):r.delete(S.Delivery)},children:e.jsx(re,{isPending:n,productDetail:t})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(u,{my:6,id:"detail-product-info",ref:c=>{const r=o.current;c?r.set(S.Product,c):r.delete(S.Product)},children:e.jsx(ce,{isPending:n,productDetail:t})}),e.jsx(u,{my:6,id:"detail-delivery-info",ref:c=>{const r=o.current;c?r.set(S.Delivery,c):r.delete(S.Delivery)},children:e.jsx(re,{isPending:n,productDetail:t})})]})]})}function re({isPending:n,productDetail:t}){return e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"배송안내",htmlText:t==null?void 0:t.deliveryGuide,isPending:n}),e.jsx(A,{title:"AS안내",htmlText:t==null?void 0:t.afterServiceGuide,isPending:n}),e.jsx(A,{title:"환불안내",htmlText:t==null?void 0:t.refundGuide,isPending:n}),e.jsx(A,{title:"교환안내",htmlText:t==null?void 0:t.exchangeGuide,isPending:n})]})}function A({title:n,htmlText:t,isPending:o}){const[m,b]=T.useState(!0),s=()=>{b(a=>!a)};return t?e.jsxs(E,{desktop:12,mobile:11,m:"auto",mb:5,children:[e.jsxs(L,{disableRipple:!0,onClick:s,fullWidth:!0,variant:"text",color:"black",sx:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"2px solid ".concat(G),borderRadius:0,p:1,mb:3,cursor:"pointer","&:hover":{backgroundColor:"transparent"}},children:[e.jsx(x,{variant:"title",children:n}),m?e.jsx(pe,{}):e.jsx(be,{})]}),m&&e.jsxs(u,{display:"flex",flexDirection:"column",border:"1px solid ".concat(N),p:{desktop:3},children:[o&&e.jsx(R,{variant:"rounded",animation:"wave",width:"100%",height:500}),e.jsx(u,{p:{desktop:5,mobile:3},dangerouslySetInnerHTML:{__html:t!=null?t:""}})]})]}):null}const ae=4,oe=V.상세제품,W=V.상세섬네일;function le(n){const{productDetail:t}=n,[o,m]=T.useState(null),[b,s]=T.useState(0),{isDesktop:a}=B();return e.jsxs(u,{id:"product-detail-image",children:[e.jsx(q,{spaceBetween:10,thumbs:o?{swiper:o}:void 0,pagination:!0,modules:[ne,se,Ge],onSlideChange:h=>s(h.activeIndex),children:t.baseInfo.imageUrls.map((h,c)=>e.jsx(K,{children:e.jsx(u,{sx:{cursor:"pointer",border:"1px solid ".concat(N)},children:e.jsx("img",{src:"".concat(h,"?").concat(oe,"x").concat(oe),alt:"Slide ".concat(c+1),style:{width:"100%",height:"100%",aspectRatio:"1 / 1"}})})},c))}),a&&e.jsx(u,{height:150,width:W*ae,mt:1,children:e.jsx(q,{onSwiper:m,spaceBetween:15,slidesPerView:ae,freeMode:!0,watchSlidesProgress:!0,modules:[ne,se],children:t.baseInfo.imageUrls.map((h,c)=>e.jsx(K,{children:e.jsx(u,{sx:{cursor:"pointer",border:b===c?"1px solid ".concat(ve):"1px solid ".concat(N)},width:W,height:W,children:e.jsx("img",{src:"".concat(h,"?").concat(W,"x").concat(W),alt:"Thumbnail ".concat(c+1),style:{width:"100%",height:"100%",aspectRatio:"1 / 1"}})})},c))})})]})}const Ye=500;function ce({isPending:n,productDetail:t}){var g;const o=T.useRef(new Map),m=l=>{const f=o.current.get(l);f&&f.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},b=l=>()=>{m(l)},{data:s}=Te((g=t==null?void 0:t.baseInfo.productNo)!=null?g:0),a=s==null?void 0:s.optionInfos.flatMap(l=>l.options).filter(l=>l.images.length>0),h=Array.isArray(a)&&a.length>1,{isMobile:c}=B(),[r,i]=T.useState(!1),v=()=>{i(l=>!l)};return e.jsxs(u,{position:"relative",maxHeight:c&&!r?Ye:"auto",overflow:c&&!r?"hidden":"visible",pb:r?10:0,children:[!c&&e.jsx(e.Fragment,{children:h&&e.jsxs(u,{border:"1px solid ".concat(N),pt:5,pb:8,children:[e.jsx(x,{variant:"titleSuperLarge",align:"center",component:"p",color:Le,pb:5,children:"옵션상세 바로가기"}),e.jsx(u,{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:2,children:a==null?void 0:a.map(l=>e.jsx(u,{display:"flex",justifyContent:"center",onClick:b(l.value),sx:{cursor:"pointer"},children:e.jsx(x,{variant:"titleLarge",fontWeight:400,color:Ne,sx:{"&:hover":{color:ve}},children:l.value})},l.value))})]})}),s&&s.optionInfos.flatMap(l=>l.options).map(l=>e.jsx(u,{ref:f=>{const I=o.current;f&&l.images.length>0?I.set(l.value,f):I.delete(l.value)},children:l.images.filter(f=>f.main).map(f=>e.jsx(u,{id:"option-image-".concat(l.value),component:"img",src:f.url,alt:"".concat(f.url),width:"100%",height:"auto"},f.url))},l.optionNo)),e.jsx(H,{id:"product-detail-header",htmlString:t==null?void 0:t.baseInfo.contentHeader,isPending:n}),e.jsx(H,{id:"product-detail",htmlString:t==null?void 0:t.baseInfo.content,isPending:n}),e.jsx(H,{id:"product-detail-footer",htmlString:t==null?void 0:t.baseInfo.contentFooter,isPending:n}),c&&e.jsx(u,{position:"absolute",bottom:0,left:0,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",sx:{background:r?"transparent":"linear-gradient(to top, white, transparent)",padding:2,height:80},children:e.jsx(L,{fullWidth:!0,color:"white",variant:"contained",onClick:v,sx:{height:"100%"},children:e.jsx(x,{variant:"subtitle2",children:r?"상세정보 접기":"상세정보 펼쳐보기"})})})]})}function H({id:n,htmlString:t,isPending:o}){return e.jsxs(Re,{flexDirection:"column",children:[o&&e.jsx(R,{animation:"wave",variant:"rounded",width:"100%",height:500}),e.jsx(u,{id:n,display:"flex",flexDirection:"column",alignItems:"center",sx:{"& *":{maxWidth:"100%"}},dangerouslySetInnerHTML:{__html:t!=null?t:""}})]})}function de(n){const{categoryLabel:t}=n,o=ge(),m=T.useCallback(()=>{const y=window.location.href;o("".concat(D.PURCHASE_INQUIRY,"?from=").concat(y,"&category=").concat(t))},[]),[b]=je(),s=b.get("productNo"),{data:a}=Te(Number(s!=null?s:0)),h=a==null?void 0:a.optionInfos[0],{addSelectedOption:c,selectedOptionList:r,getTotalPrice:i}=Q(Be,y=>({addSelectedOption:y.addOption,selectedOptionList:y.selectedProductOptionList,getTotalPrice:y.getTotalPrice})),v=y=>{if(h){const C=h.options.find(_=>_.optionNo===Number(y.target.value||0));C&&c({buyPrice:C.buyPrice,optionNo:C.optionNo,optionValue:C.value,orderCnt:1,productNo:h.mallProductNo})}},{resetSelectedProductOption:g,onAddItemToCart:l,onPurchaseItemDirect:f}=He(),I=b.get("channelType"),j=b.get("trackingKey"),d=()=>{f(I,j)};T.useEffect(()=>{g(h)},[s,h]);const{createNaverPayOrderSheetAsync:k,createNaverPayWishAsync:p}=Oe(),{isDesktop:M,isMobile:w}=B(),O=T.useCallback(async()=>{if(r.length===0){await Y("error","옵션을 선택해주세요.");return}const y=await k();w&&y?window.location.href=y:window.open(y)},[r,k,w]),P=async()=>{try{const y=await p(Number(s));w?window.location.href=y:window.open(y)}catch(y){Y("error","네이버페이 찜 등록에 실패했습니다.")}};return e.jsxs(e.Fragment,{children:[M&&e.jsx(Xe,{...n,optionInfos:h,selectedOptionList:r,moveToPurchaseInquiryPage:m,getTotalPrice:i,onSelectProductOption:v,onAddItemToCart:l,onPurchaseItemDirect:d,onPurchaseButtonClick:O,onWishButtonClick:P}),w&&e.jsx(Ze,{...n,optionInfos:h,selectedOptionList:r,moveToPurchaseInquiryPage:m,getTotalPrice:i,onSelectProductOption:v,onAddItemToCart:l,onPurchaseItemDirect:d,onPurchaseButtonClick:O,onWishButtonClick:P})]})}const Xe=n=>{const{isPending:t,isSoldOut:o,contentsIfPausing:m,productPrice:b,moveToPurchaseInquiryPage:s,getTotalPrice:a,optionInfos:h,selectedOptionList:c,onSelectProductOption:r,onAddItemToCart:i,onPurchaseItemDirect:v,onPurchaseButtonClick:g,onWishButtonClick:l,naverPayAvailable:f}=n,{formatPriceWithCommas:I,formatPriceWithSign:j}=ye();return e.jsxs(u,{mt:2,children:[t&&e.jsx(R,{animation:"wave",height:60}),b===0&&e.jsx(u,{mt:2,width:"50%",mx:"auto",children:e.jsx(L,{fullWidth:!0,size:"large",color:"error",variant:"contained",sx:{py:1.5},disableRipple:!0,onClick:s,children:e.jsx(x,{variant:"buttonLarge",children:m||"구매문의"})})}),b>0&&e.jsxs(e.Fragment,{children:[h&&h.options.length>1&&e.jsxs(u,{pb:2,children:[e.jsx(x,{variant:"subtitle1",children:"옵션선택"}),e.jsxs(Pe,{fullWidth:!0,size:"small",value:"",disabled:o,displayEmpty:!0,onChange:r,children:[e.jsx(F,{value:"",disabled:!0,children:e.jsx(x,{variant:"body",fontWeight:500,children:h.options[0].label+"을/를 선택해주세요."})}),h.options.map(d=>e.jsxs(F,{value:d.optionNo,disabled:d.saleType==="SOLDOUT",sx:{gap:1},children:[e.jsx(x,{variant:"body",fontWeight:500,children:"".concat(d.label," : ").concat(d.value," (").concat(d.optionNo,") : ").concat(j(d.addPrice,"WON"))}),d.saleType==="SOLDOUT"&&e.jsx(x,{variant:"body",fontWeight:500,children:"(품절)"})]},d.value))]})]}),e.jsx(u,{display:"flex",flexDirection:"column",gap:3,children:c.map(d=>e.jsx(we,{isSoldOut:o,buyPrice:d.buyPrice,optionNo:d.optionNo,optionValue:d.optionValue,orderCnt:d.orderCnt,isSingleOption:(h==null?void 0:h.options.length)===1},d.optionNo))}),e.jsxs(u,{my:2,mb:5,display:"flex",alignItems:"baseline",justifyContent:"space-between",children:[e.jsx(x,{variant:"subtitle2",fontWeight:600,children:"총 상품 금액"}),e.jsx(x,{variant:"titleLarge",color:J,children:I(a(),"WON")})]}),e.jsxs(u,{mt:2,display:"flex",gap:2,children:[e.jsx(L,{disabled:o,fullWidth:!0,size:"large",color:"black",variant:"outlined",disableRipple:!0,sx:{py:1.5},onClick:()=>i(h),children:e.jsx(x,{variant:"button",children:"장바구니 담기"})}),e.jsx(L,{disabled:o,fullWidth:!0,size:"large",color:"error",variant:"contained",disableRipple:!0,sx:{py:1.5},onClick:v,children:e.jsx(x,{variant:"button",children:"구매하기"})})]}),f&&e.jsx(u,{display:"flex",justifyContent:"flex-end",mt:5,children:e.jsx(Se,{isSoldOut:o,isWishButtonShow:!0,onPurchaseButtonClick:g,onWishButtonClick:l})})]})]})},Ze=n=>{const{contentsIfPausing:t,isSoldOut:o,productPrice:m,moveToPurchaseInquiryPage:b,getTotalPrice:s,optionInfos:a,selectedOptionList:h,onSelectProductOption:c,onAddItemToCart:r,onPurchaseItemDirect:i,onPurchaseButtonClick:v,onWishButtonClick:g,naverPayAvailable:l}=n,[f,I]=T.useState(!1),[j,d]=T.useState(!1),k=T.useCallback(()=>{d(P=>!P)},[]),p=T.useCallback(()=>{I(!0),d(!0)},[]),M=T.useCallback(()=>{I(!1),d(!0)},[]),{formatPriceWithCommas:w,formatPriceWithSign:O}=ye();return e.jsxs(u,{width:"100%",position:"fixed",py:3,px:2,bottom:0,zIndex:xe.MobileCartButton,bgcolor:$,borderTop:"1px solid ".concat(N),children:[e.jsx(L,{disableRipple:!0,onClick:k,color:"black",sx:{position:"absolute",top:-20,height:20,left:"50%",width:60,border:"1px solid ".concat(N),transform:"translateX(-50%)",borderWidth:"1px 1px 0",borderRadius:"4px 4px 0 0",bgcolor:$,"&:hover":{bgcolor:$},zIndex:-1},children:j?e.jsx(pe,{}):e.jsx(be,{})}),!j&&e.jsxs(u,{height:50,display:"flex",justifyContent:"space-evenly",gap:2,children:[e.jsx(L,{disabled:o,fullWidth:!0,color:"black",variant:"outlined",disableRipple:!0,onClick:p,children:e.jsx(x,{variant:"button",children:"장바구니 담기"})}),e.jsx(L,{disabled:o,fullWidth:!0,color:"error",variant:"contained",disableRipple:!0,onClick:M,children:e.jsx(x,{variant:"button",children:"구매하기"})})]}),j&&e.jsxs(e.Fragment,{children:[m===0&&e.jsxs(u,{display:"flex",flexDirection:"column",children:[e.jsx(x,{variant:"subtitle1",pb:2,children:"구매문의를 통해 구매가능한 제품입니다."}),e.jsx(L,{fullWidth:!0,size:"large",color:"error",variant:"contained",sx:{py:1.5},disableRipple:!0,onClick:b,children:e.jsx(x,{variant:"buttonLarge",children:t||"구매문의"})})]}),m>0&&e.jsxs(e.Fragment,{children:[a&&a.options.length>1&&e.jsxs(u,{children:[e.jsx(x,{variant:"subtitle1",children:"옵션선택"}),e.jsxs(Pe,{fullWidth:!0,size:"small",value:"",disabled:o,displayEmpty:!0,onChange:c,children:[e.jsx(F,{value:"",disabled:!0,children:e.jsx(x,{variant:"body",fontWeight:500,children:a.options[0].label+"을/를 선택해주세요."})}),a.options.map(P=>e.jsxs(F,{value:P.optionNo,disabled:P.saleType==="SOLDOUT",children:[e.jsx(x,{variant:"body",fontWeight:500,children:"".concat(P.value," (").concat(P.optionNo,") : ").concat(O(P.addPrice,"WON"))}),P.saleType==="SOLDOUT"&&e.jsx(x,{variant:"body",fontWeight:500,children:"(품절)"})]},P.value))]})]}),e.jsx(u,{display:"flex",flexDirection:"column",gap:1,mt:2,children:h.map(P=>e.jsx(we,{isSoldOut:o,buyPrice:P.buyPrice,optionNo:P.optionNo,optionValue:P.optionValue,orderCnt:P.orderCnt,isSingleOption:(a==null?void 0:a.options.length)===1},P.optionNo))}),e.jsxs(u,{my:2,display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsx(u,{children:e.jsx(x,{variant:"subtitle1",children:"총 상품 금액"})}),e.jsx(u,{display:"flex",alignItems:"center",children:e.jsx(x,{variant:"titleLarge",color:J,children:w(s(),"WON")})})]}),e.jsxs(u,{display:"flex",justifyContent:"space-evenly",gap:2,children:[e.jsx(L,{disabled:o,color:"black",variant:"outlined",disableRipple:!0,onClick:()=>r(a),sx:{py:1.5,width:f?"60%":"40%"},children:e.jsx(x,{variant:"button",children:"장바구니 담기"})}),e.jsx(L,{disabled:o,color:"error",variant:"contained",disableRipple:!0,onClick:i,sx:{py:1.5,width:f?"40%":"60%"},children:e.jsx(x,{variant:"button",children:"구매하기"})})]}),l&&e.jsx(u,{display:"flex",justifyContent:"flex-end",mt:2,children:e.jsx(Se,{isSoldOut:o,isWishButtonShow:!0,onPurchaseButtonClick:v,onWishButtonClick:g})})]})]})]})};function ue({productDetail:n,isPending:t}){var m,b,s,a;const{isMobile:o}=B();return e.jsxs(u,{display:"flex",flexDirection:"column",gap:5,mb:3,children:[e.jsxs(u,{display:"flex",flexDirection:"column",gap:1,children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"text",width:"50%",height:40}),e.jsx(R,{variant:"text",width:"100%",height:40}),e.jsx(R,{variant:"text",width:"100%",height:40})]}),n&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"subtitle1",fontWeight:600,children:(b=(m=n.categories)==null?void 0:m[0].categories)==null?void 0:b[0].label}),e.jsx(x,{variant:"title",children:n.baseInfo.productName}),n.baseInfo.promotionText&&e.jsx(x,{variant:"subtitle1",fontWeight:400,children:n.baseInfo.promotionText})]}),e.jsx(Ie,{salePrice:n==null?void 0:n.price.salePrice,immediateDiscountAmt:n==null?void 0:n.price.immediateDiscountAmt,contentsIfPausing:n==null?void 0:n.price.contentsIfPausing})]}),(n==null?void 0:n.deliveryFee.deliveryType)==="PARCEL_DELIVERY"?e.jsxs(u,{display:"flex",py:2,px:3,border:"1px solid ".concat(N),borderRadius:3,children:[e.jsx(u,{flex:1,display:"flex",alignItems:"flex-start",height:"100%",children:e.jsx(x,{variant:"subtitle1",children:"배송비"})}),e.jsxs(u,{flex:o?5:3,children:[e.jsxs(x,{variant:"subtitle1",children:[t&&e.jsx(R,{variant:"text",width:"80%"}),(s=n==null?void 0:n.deliveryFee)==null?void 0:s.defaultDeliveryConditionLabel]}),e.jsxs(x,{variant:"subtitle1",children:[t&&e.jsx(R,{variant:"text",width:"80%"}),"택배",(a=n==null?void 0:n.deliveryFee)!=null&&a.deliveryPrePayment?" / 선결제":" / 착불결제"]})]})]}):e.jsx(u,{display:"flex",p:3,border:"1px solid ".concat(N),borderRadius:3,children:e.jsx(x,{variant:"subtitle1",children:"간편하게 구매 문의를 남기시면, 담당자가 확인 후 고객님께 연락드리겠습니다."})})]})}function me({relatedProductList:n}){const t=V.연관제품;return e.jsx(e.Fragment,{children:n&&n.length>0&&e.jsxs(u,{p:3,children:[e.jsx(u,{py:1,position:"relative",children:e.jsx(x,{variant:"title",children:"관련 상품"})}),e.jsx(u,{children:e.jsx(q,{spaceBetween:30,slidesPerView:"auto",centeredSlides:!1,children:n.map(o=>e.jsx(K,{style:{width:t+10},children:e.jsxs(We,{underline:"none",href:"".concat(D.PRODUCT_DETAIL,"?productNo=").concat(o.productNo),children:[e.jsx(u,{display:"flex",justifyContent:"center",border:"1px solid ".concat(N),children:e.jsx("img",{height:t,width:t,src:"".concat(o.imageUrl,"?").concat(t,"x").concat(t),alt:o.productName})}),e.jsx(Ae,{title:o.productName,children:e.jsx(x,{variant:"subtitle1",noWrap:!0,children:o.productName})}),e.jsx(Ie,{salePrice:o.salePrice,immediateDiscountAmt:o.immediateDiscountAmt,smallSize:!0})]})},o.productNo))})})]})})}const he=V.상세제품;function st(){var f,I,j,d,k,p,M;Qe();const[n]=je(),t=n.get("productNo"),o=ge(),m=Number(t);Number.isNaN(m)&&Y("error","잘못된 상품 번호입니다.").then(()=>{o(D.MAIN,{replace:!0})});const{data:b}=Ke(m),{data:s,isLoading:a}=qe(m),h=Q(Ue,w=>w.isLogin),c=Q(ze,w=>w.addItem),{addRecentViewProductAPI:r}=X(),i=$e(),v=Fe({mutationFn:w=>r(w),onSuccess:()=>{i.invalidateQueries({queryKey:Z.memberRecentViewProducts()})}});T.useEffect(()=>{if(s){const w=s.baseInfo.productNo;h?v.mutate(w):c(w)}},[s]);const{isDesktop:g,isMobile:l}=B();return e.jsxs(Ve,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(E,{item:!0,mobile:12,children:e.jsx(_e,{title:(f=s==null?void 0:s.baseInfo.productName)!=null?f:""})}),e.jsxs(E,{item:!0,mobile:12,children:[s&&e.jsx(le,{productDetail:s}),a&&e.jsx(R,{variant:"rectangular",height:"100vw",width:"100%"})]}),e.jsx(E,{item:!0,mobile:12,p:3,children:e.jsx(ue,{productDetail:s,isPending:a})}),e.jsx(E,{item:!0,mobile:12,children:e.jsx(ie,{productDetail:s,isPending:a})}),e.jsx(E,{item:!0,mobile:12,children:e.jsx(me,{relatedProductList:b})}),e.jsx(E,{mobile:12,children:e.jsx(de,{isPending:a,isSoldOut:(I=s==null?void 0:s.status.soldout)!=null?I:!1,productPrice:(j=s==null?void 0:s.price.salePrice)!=null?j:0,contentsIfPausing:(s==null?void 0:s.price.contentsIfPausing)||"",categoryLabel:(s==null?void 0:s.categories[0].categories[0].label)||"",naverPayAvailable:(d=s==null?void 0:s.limitations.naverPayHandling)!=null?d:!1})})]}),g&&e.jsxs(e.Fragment,{children:[e.jsxs(E,{item:!0,desktop:12,mt:5,component:"article",container:!0,justifyContent:"space-between",children:[e.jsxs(E,{item:!0,desktop:5,children:[s&&e.jsx(le,{productDetail:s}),a&&e.jsx(R,{variant:"rectangular",height:he,width:he})]}),e.jsxs(E,{item:!0,desktop:6,children:[e.jsx(ue,{productDetail:s,isPending:a}),e.jsx(de,{isPending:a,isSoldOut:(k=s==null?void 0:s.status.soldout)!=null?k:!1,productPrice:(p=s==null?void 0:s.price.salePrice)!=null?p:0,contentsIfPausing:(s==null?void 0:s.price.contentsIfPausing)||"",categoryLabel:(s==null?void 0:s.categories[0].categories[0].label)||"",naverPayAvailable:(M=s==null?void 0:s.limitations.naverPayHandling)!=null?M:!1})]})]}),e.jsx(E,{item:!0,desktop:12,children:e.jsx(ie,{productDetail:s,isPending:a})}),e.jsx(E,{item:!0,desktop:12,children:e.jsx(me,{relatedProductList:b})})]})]})}export{st as default};