$(()=>{const n=document.querySelector("#request_forgot_password_otp_button");if(n){const i=document.querySelector("#forgot_password_otp_type_select"),t=document.querySelector("#forgot_password_username_input");n.onclick=r=>{(r.preventDefault(),$(t).valid()!=!1)&&(n.disabled=!0,window.$.ajax({type:"POST",url:"/forgot-password/otp/request",data:JSON.stringify({username:t.value,channelType:i.value}),contentType:"application/json; charset=utf-8",dataType:"json",success:t=>{if(isNaN(t.expiryInSeconds)||t.expiryInSeconds<=0){n.innerText=n.dataset.sentMessage;const t=parseInt(n.dataset.intervalInSeconds)*1e3||3e4;setTimeout(()=>{n.disabled=!1,n.innerText=n.dataset.title},t);return}let i=t.expiryInSeconds+1;const u=n=>Math.floor(n/60).toString().padStart(2,"0")+":"+Math.floor(n%60).toString().padStart(2,"0"),r=function(){if(i-=1,i<0){n.disabled=!1;n.innerText=n.dataset.title;return}n.innerText=n.dataset.sentMessage+` [${u(i)}]`;setTimeout(r,1e3)};r()}}))}}});