import{E as T}from"./EmailDomain.C1PoEq5k.bundle.js";import{aP as y,d as t,j as s,G as h,T as j,t as b,n as M,a9 as z,k as R,bJ as W,aW as w,b8 as k,ap as I,aZ as d}from"../index.Crez7j-Y.bundle.js";function B(){var p;const{watch:f,setValue:o,getValues:i}=y(),r=f("email"),l=u=>T.includes(u),c=(p=r.split("@")[1])!=null?p:"",n=l(c)?c:"",a=t.useCallback(u=>{const A=u.target.value,[C]=i("email").split("@"),g=A?"".concat(C,"@").concat(A):C;o("email",g)},[o,i]);return{selectedDomain:n,handleChangeEmailDomain:a}}function $(){const{register:f,setValue:o}=y(),[i,r]=t.useState(!1),l=t.useCallback(()=>{r(!0)},[r]),c=t.useCallback(()=>{r(!1)},[r]),n=t.useCallback(a=>{o("address",a.address),o("detailAddress",a.detailAddress),o("zipCd",a.zipCode)},[]);return s.jsxs(s.Fragment,{children:[s.jsx(h,{item:!0,desktop:12,mobile:12,children:s.jsx(j,{variant:"body",fontWeight:500,children:"주소"})}),s.jsxs(h,{container:!0,columnSpacing:1,pt:1,children:[s.jsx(h,{item:!0,desktop:9,mobile:6,children:s.jsx(b,{...f("zipCd"),size:"small",fullWidth:!0,variant:"outlined",InputProps:{readOnly:!0},sx:{bgcolor:M}})}),s.jsx(h,{item:!0,desktop:3,mobile:6,children:s.jsx(z,{fullWidth:!0,variant:"outlined",color:"error",onClick:l,sx:{borderColor:R},children:s.jsx(j,{variant:"button",children:"우편번호 검색"})})})]}),s.jsx(h,{item:!0,desktop:12,mobile:12,children:s.jsx(b,{...f("address"),sx:{bgcolor:M},size:"small",fullWidth:!0,variant:"outlined",placeholder:"우편변호를 검색하여 배송지를 입력해주세요.",name:"address",InputProps:{readOnly:!0}})}),s.jsx(h,{item:!0,desktop:12,mobile:12,children:s.jsx(b,{...f("detailAddress"),size:"small",fullWidth:!0,placeholder:"상세주소를 입력해주세요.",variant:"outlined",name:"detailAddress"})}),s.jsx(W,{open:i,onModalClose:c,onAddressSelect:n})]})}function H(f){const[o,i]=t.useState(!1),[r,l]=t.useState(!1),[c,n]=t.useState(!1),[a,p]=t.useState(300),u=t.useRef(null);w();const{sendSMSVerificationCodeAPI:A}=k(),C=I({mutationFn:e=>A(e),onSuccess:()=>{n(!0),d("인증번호를 발송하였습니다.","success")},onError:e=>d(e==null?void 0:e.message,"error")}),g=async(e,x,m)=>{if(!m){d("휴대폰 번호를 입력해주세요.","error");return}if(!/^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})$/.test(m)){d("유효하지 않은 휴대폰 번호입니다.","error");return}i(!1);const S={usage:e,memberName:x,mobileNo:m},{remainTime:P}=await C.mutateAsync(S);p(P),n(!0)};t.useEffect(()=>(c&&a>0&&(u.current=setInterval(()=>{p(e=>e-1)},1e3)),a===0&&(n(!1),l(!1),d("인증시간이 만료되었습니다.\n다시 인증해주세요.","error")),()=>{u.current&&clearInterval(u.current)}),[c,a]);const{checkSMSVerificationCodeAPI:E}=k(),v=I({mutationFn:({usage:e,mobileNo:x,key:m})=>E(e,x,m),onError:e=>d(e==null?void 0:e.message,"error")});return{isVerified:o,setIsVerified:i,isVerificationPending:c,setIsVerificationPending:n,remainingTime:a,onSendVerifyCode:g,isEditing:r,setIsEditing:l,onCodeVerification:async(e,x,m,V)=>{const{result:S}=await v.mutateAsync({usage:e,mobileNo:x,key:m});S?(i(!0),n(!1),l(!1),V(),d("인증되었습니다.","success")):d("인증번호가 일치하지 않습니다.","error")},onCancelVerification:()=>{l(!1),i(!0),n(!1),p(180)}}}export{$ as A,B as a,H as u};