window.leadsquared||(window.leadsquared={});window.leadsquared.landingpage||(window.leadsquared.landingpage={});window.leadsquared.landingpage.phonecontrol||(window.leadsquared.landingpage.phonecontrol={});window.leadsquared.landingpage.phonecontrol.otphelper=function(){function r(){n.fieldData=JSON.parse(jQuery("#txtLoadedJson").val());jQuery.each(n.fieldData.LSQLeadFields,function(t,i){if(i.CtrlType=="phone"&&i.SMSVerification==1)return n.validate.minLength=i.MinLength,n.validate.maxLength=i.MaxLength,f(i),n.smsverifyfield=i,!1});jQuery(`#${n.smsverifyfield.SchemaName}`).on("input",function(t){var i=jQuery(t.target).val(),r=jQuery(`[data-field-name=${n.smsverifyfield.SchemaName}]`).find(".validation-msg");i.length>=n.validate.minLength&&i.length<=n.validate.maxLength?(jQuery(`#sendotp`).css("pointer-events",""),r.hide()):jQuery(`#sendotp`).css("pointer-events","none")});jQuery("#form-submit-button").click(function(r){var e=jQuery(`#${n.smsverifyfield.SchemaName}`),f=jQuery("#MXHvalidateOTP").val(),s=jQuery(`#${n.smsverifyfield.SchemaName}`).val(),h=jQuery("input[name=MXHOrgCode]").val(),c=t(jQuery("input[name='MXHencodedOTP']").val())?jQuery("input[name='MXHencodedOTP']").val():"",u=jQuery(`[data-field-name=MXHvalidateOTP]`).find(".validation-msg"),o;e!=undefined&&t(e.val())&&(t(f)?n.regex.Otp.test(f)&&(o=i.TOVL.replace("{0}",encodeURIComponent(s)).replace("{1}",f).replace("{2}",encodeURIComponent(c)).replace("{3}",h),jQuery.ajax({type:"POST",async:!1,url:o,success:function(n){try{var t=JSON.parse(n);t.Status=="Invalid"?(u.text("Invalid OTP.").show(),r.preventDefault()):u.text("").hide()}catch(i){u.text("Invalid OTP.").show();r.preventDefault()}},error:function(){console.log("Unable to validate OTP.");u.text("Invalid OTP.").show();r.preventDefault()}})):(u.text("Provide a value.").show(),r.preventDefault()))})}function u(r){var u=jQuery(`#${n.smsverifyfield.SchemaName}`),e=jQuery("input[name=MXHOrgCode]").val(),f;t(u.val())?(f=i.TOSL.replace("{0}",encodeURIComponent(u.val())).replace("{1}",e),jQuery.ajax({type:"POST",url:f,success:function(n){var t,i;try{t=JSON.parse(n);t.Status=="Success"&&(r.innerHTML=r.innerHTML.replace("Send","Resend"),i=`#MXHencodedOTP`,jQuery(`[data-field-name=MXHvalidateOTP]`).find(".validation-msg").text("").hide(),jQuery("#MXHencodedOTP").length==0?jQuery("input[name='MXHOrgCode']").after(``):jQuery(i).val(t.Code))}catch(u){console.log("Unable to send OTP.");jQuery(`[data-field-name=MXHvalidateOTP]`).find(".validation-msg").text("Unable to send OTP.").show()}},error:function(){console.log("Unable to send OTP.")}})):console.log("Unable to send OTP.")}function f(t){var f=`[data-field-name=${t.SchemaName}]`,i=jQuery(f).eq(0).clone(),u=i.find(".field-label"),r=i.find(`#${t.SchemaName}`),e,o;i.attr("data-field-name",`MXHvalidateOTP`);i.attr("data-field-type","otp");i.removeAttr("data-ph-control-type");i.removeAttr("data-seq");i.removeAttr("data-sms-verfication");u.length==0?(e=jQuery("