1import{aH as U,u as E,cj as g,fM as C,aT as h,cJ as B,r as T,dB as O,av as I,cE as o,fN as k,fO as D,j as f,aA as F,aC as x}from"./index.1t6HhxO5.js";import j from"./index.q0em1QPM.js";import{O as n,U as p,a as G,b as Y}from"./constants.CkS-HRMP.js";import"./useTimer.CAxd8BLx.js";import"./timer.DY-tp3Kq.js";const m={email:"UPDATE_PROFILE_EMAIL_OTP",mobileNo:"UPDATE_PROFILE_MOBILE_OTP",verifyEmail:"VERIFY_PROFILE_EMAIL_OTP",verifyMobileNo:"VERIFY_PROFILE_MOBILE_OTP"},v=({onValid:M,onError:S,type:t,value:s,countryId:y,setIsEmailMobileChange:L,isEmailMobileChange:w})=>{const a=U(),K=E(g);E(e=>e?.userProfile);const r=E(C),{email:u,phone:l}=E(h),_=E(B),i=E(e=>e.userProfileOtpValidation),R=T.useMemo(()=>{const e=t===n.EMAIL?O(s):O(u),c=t===n.MOBILE_NUMBER?O(s):O(l?.number);return t===n.EMAIL?s===u?p.OTP_SEND_SUCCESS_MSG_MOBILE.replace(/%s/,c):p.OTP_SEND_SUCCESS_MSG_EMAIL.replace(/%s/,e).replace(" registered",""):s===l?.number?p.OTP_SEND_SUCCESS_MSG_EMAIL.replace(/%s/,e):p.OTP_SEND_SUCCESS_MSG_MOBILE.replace(/%s/,c).replace(" registered","")},[u,l?.number,t,s]),d=()=>t===n.EMAIL?s===u?l?.number:s:s===l?.number?u:s,P=()=>t===n.EMAIL?l?.countryId:y;K?.refNo;const b=I(async()=>{a(o.generate());let e={};return e=t===n.EMAIL&&s!==u||t===n.MOBILE_NUMBER&&s===l?.number?{type:i.updatedEmailValidationKey?m.email:m.verifyEmail,id:d(),email:d()}:{type:i.updatedMobileValidationKey?m.mobileNo:m.verifyMobileNo,id:d(),mobileNo:d(),countryId:P()||0},k(e)},{onSuccess:e=>{const c=e?.success?.data;a(o.generated({newId:s,timeout:c?.timeout,length:c?.length,otpReferenceKey:c?.otpReferenceKey}))},onError:e=>{a(o.setError(e?.response?.data?.error?.errorCode)),S(e?.response?.data?.error)}}),N=I(async()=>{let e={};return e=t===n.EMAIL&&s!==u||t===n.MOBILE_NUMBER&&s===l?.number?{type:i.updatedEmailValidationKey?m.email:m.verifyEmail,otp:r.code,id:d()||"",email:d()||"",otpReferenceKey:r?.otpReferenceKey,rsaKey:_,...i.updatedEmailValidationKey?{validationKey:i?.updatedEmailValidationKey}:{}}:{type:i.updatedMobileValidationKey?m.mobileNo:m.verifyMobileNo,otp:r.code,id:d()||"",mobileNo:d()||"",countryId:P()||0,otpReferenceKey:r?.otpReferenceKey,rsaKey:_,...i.updatedMobileValidationKey?{validationKey:i?.updatedMobileValidationKey}:{}},D(e)},{onSuccess:e=>{L(!!e?.success?.data?.isEmailMobileChange),t==="email"&&!i.updatedEmailValidationKey||t!=="email"&&!i.updatedMobileValidationKey?(a(t==="email"?o.setUpdatedEmailValidationKey(e?.success?.data?.sessionToken):o.setUpdatedMobileValidationKey(e?.success?.data?.sessionToken)),M(e?.success?.data?.sessionToken)):(a(t==="email"?o.setUpdatedEmailValidationKey(null):o.setUpdatedMobileValidationKey(null)),a(o.setValid(e?.success?.data.sessionToken)),M(e?.success?.data.sessionToken))},onError:e=>{const c=e?.response?.data;a(o.setError(c.error.errorCode)),a(o.setValid("")),M("")}});T.useEffect(()=>{r.code&&N.mutate()},[r.code]),T.useEffect(()=>(b.mutate(),()=>{a(o.reset())}),[]);const V=e=>{e.length===6&&a(o.setCode(e))},A=()=>{r.token||a(o.setError(null))};return r.newId?f.jsxs(f.Fragment,{children:[f.jsx(F,{severity:"success",className:"personal-information-alert mt-4",message:R}),f.jsx(j,{className:"mt-4",labelText:p.OTP_LABEL_TEXT,isNumber:!0,autoFocus:!0,length:r.length||Y,onChangeOTP:V,OTPTimeout:r.timeout||G,onTimeUp:A,showResend:!0,onResendOTP:b.mutate,isActiveOtpResendButton:r.error,isError:r.error,errorMsg:r?.error&&(r?.errorCode?x[r?.errorCode]:""),otpVerified:!r.error&&!!r.token,disabled:r.isLoading})]}):null};export{v as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.