1"use strict";(self.webpackChunkaem_maven_archetype=self.webpackChunkaem_maven_archetype||[]).push([[7352],{2386:function(e,t,r){r.r(t);var s=r(5202),n=r(3530);class a{constructor(){const e=document.querySelector(".motoverse-event-unpaid-register");this.category=e?.getAttribute("data-category")||"trailSchool",this.pagePath=e?.getAttribute("data-page-path")||window.location.pathname,this.apiUrl=e?.getAttribute("data-api-url")||"https://api-dev2.royalenfield.com/v4/motoverse/sub-event/submit-lead",this.appId=e?.getAttribute("data-app-id")||"1",this.maxNameLength=parseInt(e?.getAttribute("data-max-name-length"))||24,this.maxPhoneLength=parseInt(e?.getAttribute("data-max-phone-length"))||10,this.defaultCountryCode=e?.getAttribute("data-default-country-code")||"+91",this.firstName=document.getElementById("firstName"),this.lastName=document.getElementById("lastName"),this.countryCode=document.getElementById("countryCode"),this.phoneNumber=document.getElementById("phoneNumber"),this.email=document.getElementById("email"),this.eventTnCCheckContinue=document.getElementById("eventTnCCheckContinue"),this.continueBtn=document.getElementById("motoverse-event-continue-btn"),this.formCard=document.querySelector(".motoverse-event-form-card"),this.btnWrap=document.querySelector(".motoverse-event-btn-wrap"),this.successWrapper=document.querySelector(".motoverse-event-success-wrapper"),this.calenderModelBtn=document.querySelector(".share-btn.calender-btn"),this.shareModelBtn=document.querySelector(".share-btn.share-btn"),this.shareModel=document.getElementById("motoverse-event-share-modal"),this.calenderModel=document.getElementById("motoverse-event-calender-modal"),this.shareModelCloseBtn=document.getElementById("event-share-modal-close-btn"),this.calenderModelCloseBtn=document.getElementById("motoverse-event-calender-modal-close-btn"),this.formData={}}validateForm(){return!!s.A.validateName(this.firstName,"first name")&&(!!s.A.validateName(this.lastName,"last name")&&(!!s.A.validatePhoneNumber(this.phoneNumber)&&(!!s.A.validateEmail(this.email)&&!!s.A.validateCheckbox(this.eventTnCCheckContinue,"Please check the terms and conditions"))))}setCountryCodeFromURL(){window.location.pathname.includes("/in/")&&(this.countryCode.value=this.defaultCountryCode,this.countryCode.disabled=!0)}clearErrorOnInput(e){e.addEventListener("input",(()=>{s.A.clearError(e)}))}clearErrorOnChange(e){e.addEventListener("change",(()=>{s.A.clearError(e)}))}initializeInputRestrictions(){[this.firstName,this.lastName].forEach((e=>{e&&(this.clearErrorOnInput(e),e.addEventListener("input",(e=>{let t=e.target.value.replace(/[^A-Za-z\s]/g,"");t.length>this.maxNameLength&&(t=t.substring(0,this.maxNameLength)),e.target.value=t})),e.addEventListener("keydown",(e=>{" "===e.key&&0===e.target.value.length&&e.preventDefault()})))})),this.phoneNumber&&(this.phoneNumber.addEventListener("input",(()=>{s.A.clearError(this.phoneNumber,this.phoneNumber.parentElement.parentElement)})),this.phoneNumber.addEventListener("input",(e=>{let t=e.target.value.replace(/\D/g,"");t.length>this.maxPhoneLength&&(t=t.substring(0,this.maxPhoneLength)),e.target.value=t})),this.phoneNumber.addEventListener("keydown",(e=>{if(0===e.target.value.length){const t=e.key;["0","1","2","3","4","5"].includes(t)&&e.preventDefault()}}))),this.email&&this.clearErrorOnInput(this.email),this.eventTnCCheckContinue&&this.eventTnCCheckContinue.addEventListener("change",(()=>{s.A.clearCheckboxError(this.eventTnCCheckContinue)}));[this.firstName,this.lastName,this.email].forEach((e=>{e&&e.addEventListener("blur",(e=>{e.target.value=e.target.value.trim()}))}))}showSuccessMessage(){this.formCard&&this.formCard.classList.add("d-none"),this.btnWrap&&this.btnWrap.classList.add("d-none"),this.successWrapper&&this.successWrapper.classList.remove("d-none")}async submitFormToAPI(e){let t="";try{const e=sessionStorage.getItem("districtLeadId");if(e){const r=JSON.parse(e);t=r?.data?._id||""}}catch(e){console.error("Error parsing districtLeadId from session storage:",e)}const r={firstName:e.firstName,lastName:e.lastName,email:e.email,mobile:e.phoneNumber,callingCode:e.countryCode.replace("+",""),category:this.category,districtLeadId:t,requestUrl:window.location.href,clientId:(0,n.N)(),pagepath:this.pagePath};console.log("Submitting to API:",this.apiUrl),console.log("Payload:",r);try{const e=await fetch(this.apiUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",pagepath:this.pagePath,pageid:this.category,app_id:this.appId},body:JSON.stringify(r)});console.log("API Response Status:",e.status);const t=await e.json();return console.log("API Response Data:",t),200===t.code||t.success?{success:!0,data:t}:{success:!1,message:t.message||"Submission failed",data:t}}catch(e){return console.error("API Submission Error:",e),{success:!1,message:"Network error occurred",error:e}}}initializeContinueBtn(){this.continueBtn&&this.continueBtn.addEventListener("click",(async()=>{let e=!1;if(e=this.validateForm(),!e)return;this.formData={firstName:this.firstName.value,lastName:this.lastName.value,countryCode:this.countryCode.value,phoneNumber:this.phoneNumber.value,email:this.email.value},console.log("Form data collected:",this.formData),this.continueBtn.disabled=!0;const t=this.continueBtn.textContent;this.continueBtn.textContent="Submitting...";const r=await this.submitFormToAPI(this.formData);this.continueBtn.disabled=!1,this.continueBtn.textContent=t,r.success?(console.log("Form submitted successfully!"),this.showSuccessMessage()):(console.error("Form submission failed:",r.message),alert(r.message||"Failed to submit form. Please try again."))}))}initializeCalenderModal(){this.calenderModelBtn&&this.calenderModel&&this.calenderModelCloseBtn&&(this.calenderModelBtn.addEventListener("click",(()=>{this.calenderModel.classList.add("show-model")}
1)),this.calenderModelCloseBtn.addEventListener("click",(()=>{this.calenderModel.classList.remove("show-model")})))}initializeShareModal(){this.shareModelBtn&&this.shareModel&&this.shareModelCloseBtn&&(this.shareModelBtn.addEventListener("click",(()=>{this.shareModel.classList.add("show-model")})),this.shareModelCloseBtn.addEventListener("click",(()=>{this.shareModel.classList.remove("show-model")})))}init(){this.setCountryCodeFromURL(),this.initializeInputRestrictions(),this.initializeContinueBtn(),this.initializeCalenderModal(),this.initializeShareModal()}}const i={init:function(){(new a).init()}};t.default=i},2580:function(e,t,r){r.r(t)},3530:function(e,t,r){function s(){function e(e){for(var t=e+"=",r=decodeURIComponent(document.cookie).split(";"),s=0;s<r.length;s++){for(var n=r[s];" "===n.charAt(0);)n=n.substring(1);if(0===n.indexOf(t))return n.substring(t.length,n.length)}return""}const t=e("CLID");if(t)return t;const r=e("_ga");let s="";if(r){const e=r.split(".");e.length>2&&(s=e.slice(2).join("."))}return s}r.d(t,{N:function(){return s}})},5202:function(e,t){t.A=class{static showError(e,t,r=null){e.classList.add("input-error");const s=r||e.parentElement,n=document.createElement("small");n.classList.add("event-error-message"),n.textContent=t,s.appendChild(n),e.focus()}static clearError(e,t=null){e.classList.remove("input-error");const r=(t||e.parentElement).querySelector(".event-error-message");r&&r.remove()}static checkEmpty(e,t){const r=e.value.trim();return this.clearError(e),!!r||(this.showError(e,`Please enter ${t}`),!1)}static validateName(e,t,r=2,s=24){const n=e.value.trim();return this.clearError(e),n?n.length<r?(this.showError(e,`${t} must be at least ${r} characters`),!1):n.length>s?(this.showError(e,`${t} must not exceed ${s} characters`),!1):!!/^[A-Za-z\s]+$/.test(n)||(this.showError(e,`${t} should only contain letters`),!1):(this.showError(e,`Please enter ${t}`),!1)}static validatePhoneNumber(e,t=10){const r=e.value.trim();if(this.clearError(e,e.parentElement.parentElement),!r)return this.showError(e,"Please enter mobile number",e.parentElement.parentElement),!1;if(!/^\d+$/.test(r))return this.showError(e,"Mobile number should only contain numbers",e.parentElement.parentElement),!1;const s=parseInt(r.charAt(0));return s>=0&&s<=5?(this.showError(e,"Mobile number cannot start with 0-5",e.parentElement.parentElement),!1):r.length===t||(this.showError(e,`Mobile number must be ${t} digits`,e.parentElement.parentElement),!1)}static validateEmail(e){const t=e.value.trim();if(this.clearError(e),!t)return this.showError(e,"Please enter email"),!1;return!!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)||(this.showError(e,"Please enter a valid email address"),!1)}static validateSelect(e,t){return this.clearError(e),!(!e.value||""===e.value.trim())||(this.showError(e,`Please select ${t}`),!1)}static validateTextLength(e,t,r=1,s=null){const n=e.value.trim();return this.clearError(e),n?n.length<r?(this.showError(e,`${t} must be at least ${r} characters`),!1):!(s&&n.length>s)||(this.showError(e,`${t} must not exceed ${s} characters`),!1):(this.showError(e,`Please enter ${t}`),!1)}static validateYear(e,t="Year",r=4){const s=e.value.trim();if(this.clearError(e),!s)return this.showError(e,`Please enter ${t}`),!1;return!!new RegExp(`^\\d{${r}}$`).test(s)||(this.showError(e,`${t} must be ${r} digits`),!1)}static validateRegistrationNumber(e,t=6,r=17){const s=e.value.trim().toUpperCase();return this.clearError(e),s?/^[A-Z0-9]+$/.test(s)?s.length<t?(this.showError(e,`Registration number must be at least ${t} characters`),!1):!(s.length>r)||(this.showError(e,`Registration number must not exceed ${r} characters`),!1):(this.showError(e,"Registration number should only contain letters and numbers"),!1):(this.showError(e,"Please enter registration number"),!1)}static validateCheckbox(e,t){if(this.clearCheckboxError(e),!e.checked){const r=document.createElement("small");return r.classList.add("event-error-message"),r.textContent=t,e.parentElement.appendChild(r),!1}return!0}static clearCheckboxError(e){const t=e.parentElement.querySelector(".event-error-message");t&&t.remove()}static validateDateOfBirth(e,t=18){const r=e.value.trim();if(this.clearError(e),!r)return this.showError(e,"Please select date of birth"),!1;const s=new Date(r),n=new Date;let a=n.getFullYear()-s.getFullYear();const i=n.getMonth()-s.getMonth();return(i<0||0===i&&n.getDate()<s.getDate())&&a--,!(a<t)||(this.showError(e,`You must be at least ${t} years old`),!1)}static validateFileUpload(e,t="Please upload documents"){return this.clearError(e),!(!e.files||0===e.files.length)||(this.showError(e,t),!1)}static trimField(e){e.value=e.value.trim()}}}}]);
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.