import{m as r,t as m,ab as o,v as l,aD as F,aE as Q,w as Y,L as J,Y as V,k as W,u as X,h as Z,b as ee,r as T,bg as te,ah as d,a7 as c,a8 as p,ao as u,bt as L,bj as ne,bk as se,f as ie,j as t,ak as j,P as _,c8 as re,b$ as oe,al as ae}from"./index-E0AVXOTn.js";import{e as O}from"./every-BvSgYTEb.js";import{S as M,O as ce}from"./termList-B8l_Q4qO.js";import{u as le}from"./useTermList-DZKLAniP.js";const de=r.div(["border:1px solid ",";border-radius:var(--spacing-6);width:100%;height:55px;margin-bottom:30px;> label{width:100%;height:100%;display:flex;justify-content:center;align-items:center;cursor:pointer;}"],m.gray),he=r.p(["margin-left:8px;justify-content:center;align-items:center;",";> span{",";}> button{margin-right:6px;}","{display:flex;",";> span{",";}> button{margin-right:20px;}}"],o.body2_semibold,o.body2_medium,l.SM,o.headline2_semibold,o.headline2_medium),pe=r.ul(["margin-bottom:38px;","{margin-bottom:56px;}"],l.SM),me=r.li(["border-bottom:1px solid ",";margin-bottom:60px;&:last-child{margin-bottom:0px;border-bottom:1px solid ",";}"],m.gray,m.gray),xe=r.div(["margin-bottom:40px;","{margin-bottom:68px;}"],l.SM),ge=r.p(["border-radius:var(--spacing-6);text-align:center;margin-bottom:21px;background-color:",";height:55px;",";",";","{",";}"],m.lightGray,Y,o.headline2_semibold,l.SM,o.heading_semibold),ue=r.ul([""]),Ce=r.li(["&:not(last-child){margin-bottom:12px;}"]),be=r.div(["display:flex;justify-content:space-between;align-items:center;> label{display:flex;align-items:center;cursor:pointer;}"]),ke=r.div(["display:flex;justify-content:space-between;align-items:center;padding-bottom:12px;border-bottom:2px solid ",";> label{display:flex;align-items:center;cursor:pointer;}","{padding-bottom:13px;}"],m.black,l.SM);r.img(["width:16px;height:16px;","{width:20px;height:20px;}"],l.SM);const ye=r.p(["",";margin-left:6px;> span{",";margin-right:5px;color:",";}","{",";}"],o.body1_regular,o.body1_bold,m.primary,l.SM,o.body1_regular),Te=r(J)(["display:flex;align-items:center;",";color:",";"],o.caption_regular,m.gray60),je=r.div(["overflow:auto;",";padding:10px 0 15px;> div{max-height:247px;",";span{display:inline;",";line-height:18px;}p{",";line-height:18px;}*{font:revert;}}","{padding:20px 0;> div{max-height:193px;}}"],F,Q,o.body1_regular,o.body1_regular,l.SM),fe=r(V)(["width:100%;",";","{",";}"],o.headline1_medium,l.SM,o.heading_bold),i={AllCheckContainer:de,AllCheckText:he,TermList:pe,TermItem:me,OptInContainer:xe,OptInTitle:ge,OptInList:ue,OptInListItem:Ce,CheckOptInContainer:be,CheckTermContainer:ke,TermTitle:ye,ContentAllLink:Te,TermContentContainer:je,NextButton:fe},Le=()=>{const{t:a}=W(),P=X(),[x]=Z(),{openDialog:w}=ee(),N=x.get("accessToken")??void 0,B=x.get("provider")??void 0,U=x.get("code")??void 0,D=x.get("expiry")??void 0,E=x.get("refreshToken")??void 0,R=x.get("returnUrl")??void 0,k=T.useContext(te),f=k==null?void 0:k.isAuthenticationByPhone,{data:y}=le({searchParams:{termsTypes:[...d(e=>e.type,M)]}}),[C,v]=T.useState(()=>{const e=c(y,L,u(([,n])=>n.used),d(([n])=>n.toUpperCase()),p);return c(M,u(n=>ae(n.type,e)),p)}),[b,A]=T.useState(ce),S=O(e=>e.isChecked,[...C,...b]),$=e=>{v(n=>c(n,d(s=>({...s,isChecked:!e})),p)),A(n=>c(n,d(s=>({...s,isChecked:!e})),p))},G=e=>{v(n=>c(n,d(s=>s.type===e?{...s,isChecked:!s.isChecked}:s),p))},H=e=>{A(n=>c(n,d(s=>s.type===e?{...s,isChecked:!s.isChecked}:s),p))},K=e=>{if(!y)return"";const n=c(y,L,u(([s])=>s.toUpperCase()===e),d(([,s])=>s),oe);return n?n.contents:""},{openKcpAuthRegister:q}=ne(),I=e=>{var s,g;const n=c(C,u(h=>h.isChecked),d(h=>h.type),p);P(_.SIGNUP.FORM,{state:{terms:n,smsAgreed:(s=b.find(h=>h.type==="smsAgreed"))==null?void 0:s.isChecked,directMailAgreed:(g=b.find(h=>h.type==="directMailAgreed"))==null?void 0:g.isChecked,...e}})},z=()=>{if(!c(C,u(({isRequired:n})=>n),O(({isChecked:n})=>n))){w({message:a("필수항목에 대한 동의를 체크해주세요.")});return}if(f){q();return}I({data:{provider:B,accessToken:N,refreshToken:E,code:U,expiry:D,returnUrl:R}})};return se({onNext:async e=>{if(e.provider&&e.accessToken&&e.key)try{await ie({method:"POST",url:"/profile/rename",data:{key:e.key},headers:{"Shop-By-Authorization":`Bearer ${e.accessToken}`}})}catch{}I({data:e})}}),t.jsxs("div",{children:[t.jsx(i.AllCheckContainer,{children:t.jsxs("label",{children:[t.jsx(j,{onCheckedChange:()=>$(S),checked:S,id:"allTermCheck"}),t.jsxs(i.AllCheckText,{children:[a("모든 약관을 확인하고 전체 동의합니다."),"  ",t.jsxs("span",{children:["(",a("선택정보 포함"),")"]})]})]})}),t.jsx(i.TermList,{children:C.map(({type:e,label:n,isRequired:s,isChecked:g})=>t.jsxs(i.TermItem,{children:[t.jsxs(i.CheckTermContainer,{children:[t.jsxs("label",{children:[t.jsx(j,{onCheckedChange:()=>G(e),checked:g}),t.jsxs(i.TermTitle,{children:[t.jsxs("span",{children:["[",a(s?"필수":"선택"),"]"]}),n]})]}),t.jsxs(i.ContentAllLink,{to:`${_.AUTH.TERMS.MAIN}/${e}`,children:[t.jsx("span",{children:a("전체보기")}),t.jsx(re,{})]})]}),t.jsx(i.TermContentContainer,{"data-lenis-prevent":!0,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:K(e)}})})]},e))}),t.jsxs(i.OptInContainer,{children:[t.jsx(i.OptInTitle,{children:a("혜택/정보 수신 동의")}),t.jsx(i.OptInList,{children:b.map(({type:e,label:n,isRequired:s,isChecked:g})=>t.jsx(i.OptInListItem,{children:t.jsx(i.CheckOptInContainer,{children:t.jsxs("label",{children:[t.jsx(j,{onCheckedChange:()=>H(e),checked:g}),t.jsxs(i.TermTitle,{children:[t.jsxs("span",{children:["[",a(s?"필수":"선택"),"]"]}),a(n)]})]})})},e))})]}),t.jsx(i.NextButton,{onClick:z,children:a(f?"본인 인증하기":"다음")})]})};export{Le as default};