1"use strict";(self.webpackChunkaem_maven_archetype=self.webpackChunkaem_maven_archetype||[]).push([[9],{420:function(e,t){const o={razorPayGenerateOrderId:async function(e,t,s){return new Promise((async(a,n)=>{const r=document.getElementById("razorPay"),i=r.getAttribute("razor-pay-id"),l=r.getAttribute("business-name"),c=r.getAttribute("business-logo"),d=r.getAttribute("transaction-desc"),h=document.getElementById("razorPay"),u=s||h.getAttribute("handle-payment-status"),m={key:i,amount:Number(t.data.amount),currency:t.data.currency,name:l,description:d,image:c,order_id:t.data.id,handler:async function(e){try{const t=await o.sendPaymentResponce({razorpay_payment_id:e.razorpay_payment_id,razorpay_order_id:e.razorpay_order_id,razorpay_signature:e.razorpay_signature},u);a(t)}catch(e){n(e)}},modal:{ondismiss:function(){n(new Error("Payment process was dismissed"))}},prefill:{name:`${e.fname} ${e.lname}`,email:e.email,contact:e.mobileNumber},notes:{address:e.address},theme:{color:"#3399cc"}},p=new Razorpay(m);p.on("payment.failed",(async function(e){try{await o.sendPaymentResponce(e,u),n(new Error("Payment failed"))}catch(e){n(e)}})),p.open()}))},sendPaymentResponce:async function(e,t){try{const o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)return console.error("Error: ",o.statusText),null;{const e=await o.json();if(("200"===e.code||200===e.code)&&!e.error)return e}}catch(e){console.error("Error: ",e)}}};t.A=o},775:function(e,t,o){o.d(t,{B:function(){return s}});const s=new class{constructor(){this.storageKey="BTR_Utm",this.utmParameters=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_adgroup"]}captureAndStore(){try{const e=new URLSearchParams(window.location.search),t={};let o=!1;for(const s of this.utmParameters){const a=e.get(s);a&&(t[s]=a,o=!0)}o?(localStorage.setItem(this.storageKey,JSON.stringify(t)),console.log("UTM parameters captured and stored:",t)):console.log("No new UTM parameters found. Using existing or none.")}catch(e){console.error("Failed to save UTM data to localStorage:",e)}}getStored(){try{const e=localStorage.getItem(this.storageKey);if(e){const t=JSON.parse(e),o={};for(const e of this.utmParameters)o[e]=t[e]||null;return o}}catch(e){console.error("Failed to retrieve or parse UTM data:",e)}const e={};for(const t of this.utmParameters)e[t]=null;return e}clearStored(){try{localStorage.removeItem(this.storageKey),console.log("UTM data cleared from localStorage.")}catch(e){console.error("Failed to clear UTM data:",e)}}}},3530:function(e,t,o){function s(){function e(e){for(var t=e+"=",o=decodeURIComponent(document.cookie).split(";"),s=0;s<o.length;s++){for(var a=o[s];" "===a.charAt(0);)a=a.substring(1);if(0===a.indexOf(t))return a.substring(t.length,a.length)}return""}const t=e("CLID");if(t)return t;const o=e("_ga");let s="";if(o){const e=o.split(".");e.length>2&&(s=e.slice(2).join("."))}return s}o.d(t,{N:function(){return s}})},4126:function(e,t){const o={fetchData:async(e="",t={})=>(await fetch(e,t)).json(),urlEncode:function(e){const t=new URLSearchParams;for(const o in e)Object.hasOwnProperty.call(e,o)&&t.append(o,e[o]);return t},getFileExtension:function(e){const t=e.lastIndexOf(".");return-1!==t&&t<e.length-1?e.substring(t+1):""},uploadFileStep3:async function(e,t){try{const o=(t||"").replace(/\/$/,""),s=await this.fetchData(`${o}?path=${e}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!s||200!==s.code&&"success"!==s.status&&!0!==s.success)throw new Error("Failed to validate AOM authentication in step 3");return s.data&&s.data.blobPath?s.data.blobPath:s.data||e}catch(e){return console.error("Failed to validate file in step 3:",e),null}},uploadFileStep2:async function(e,t,o,s){try{const a=await fetch(e,{method:"PUT",body:t,headers:{"x-ms-blob-type":"BlockBlob"}});if(!a.ok)throw new Error(`HTTP error in step 2! status: ${a.status}`);return await this.uploadFileStep3(o,s)}catch(e){return console.error("Failed to upload file in step 2:",e),null}},uploadFileStep1:async function(e,t,o,s,a){const n=this.getFileExtension(e);let r={name:((e||"").includes(".")?e.substring(0,e.lastIndexOf(".")):e)||e,extension:n};
1a&&(r.category=a),t&&(r.leadId=t);try{const e=(s||"").replace(/\/$/,""),t=await this.fetchData(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.urlEncode(r)});if(!t||200!==t.code&&"success"!==t.status&&!0!==t.success)return console.error("Step 1 upload response error:",t),null;{const e=t.data||t,a=e.uploadURL||e.uploadUrl,n=e.filePath||e.filepath;return await this.uploadFileStep2(a,o,n,s)}}catch(e){return console.error("Failed to get file URL in step 1:",e),null}}};t.A=o},5202:function(e,t){t.A=class{static showError(e,t,o=null){e.classList.add("input-error");const s=o||e.parentElement,a=document.createElement("small");a.classList.add("event-error-message"),a.textContent=t,s.appendChild(a),e.focus()}static clearError(e,t=null){e.classList.remove("input-error");const o=(t||e.parentElement).querySelector(".event-error-message");o&&o.remove()}static checkEmpty(e,t){const o=e.value.trim();return this.clearError(e),!!o||(this.showError(e,`Please enter ${t}`),!1)}static validateName(e,t,o=2,s=24){const a=e.value.trim();return this.clearError(e),a?a.length<o?(this.showError(e,`${t} must be at least ${o} characters`),!1):a.length>s?(this.showError(e,`${t} must not exceed ${s} characters`),!1):!!/^[A-Za-z\s]+$/.test(a)||(this.showError(e,`${t} should only contain letters`),!1):(this.showError(e,`Please enter ${t}`),!1)}static validatePhoneNumber(e,t=10){const o=e.value.trim();if(this.clearError(e,e.parentElement.parentElement),!o)return this.showError(e,"Please enter mobile number",e.parentElement.parentElement),!1;if(!/^\d+$/.test(o))return this.showError(e,"Mobile number should only contain numbers",e.parentElement.parentElement),!1;const s=parseInt(o.charAt(0));return s>=0&&s<=5?(this.showError(e,"Mobile number cannot start with 0-5",e.parentElement.parentElement),!1):o.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,o=1,s=null){const a=e.value.trim();return this.clearError(e),a?a.length<o?(this.showError(e,`${t} must be at least ${o} characters`),!1):!(s&&a.length>s)||(this.showError(e,`${t} must not exceed ${s} characters`),!1):(this.showError(e,`Please enter ${t}`),!1)}static validateYear(e,t="Year",o=4){const s=e.value.trim();if(this.clearError(e),!s)return this.showError(e,`Please enter ${t}`),!1;return!!new RegExp(`^\\d{${o}}$`).test(s)||(this.showError(e,`${t} must be ${o} digits`),!1)}static validateRegistrationNumber(e,t=6,o=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>o)||(this.showError(e,`Registration number must not exceed ${o} 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 o=document.createElement("small");return o.classList.add("event-error-message"),o.textContent=t,e.parentElement.appendChild(o),!1}return!0}static clearCheckboxError(e){const t=e.parentElement.querySelector(".event-error-message");t&&t.remove()}static validateDateOfBirth(e,t=18){const o=e.value.trim();if(this.clearError(e),!o)return this.showError(e,"Please select date of birth"),!1;const s=new Date(o),a=new Date;let n=a.getFullYear()-s.getFullYear();const r=a.getMonth()-s.getMonth();return(r<0||0===r&&a.getDate()<s.getDate())&&n--,!(n<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()}}},6338:function(e,t,o){o.r(t),o.d(t,{default:function(){return d}});var s=o(4126),a=o(420),n=o(3530),r=o(775);var i=class{constructor(){const e=document.querySelector(".motoverse-event-register-form");this.baseUrls={countries:e?.getAttribute("data-countries-api"),locations:e?.getAttribute("data-locations-api")},this.stateDropdown=document.getElementById("eventState"),this.cityDropdown=document.getElementById("eventCity"),this.fileUploadUrl=e?.getAttribute("data-upload-api"),this.submitApiUrl=e?.getAttribute("data-submit-api")||"https://api-dev2.royalenfield.com/v4/motoverse/sub-event/submit-lead",this.category=e?.getAttribute("data-category")||"trailSchool",this.pagePath=e?.getAttribute("data-page-path")||window.location.pathname,this.appId=e?.getAttribute("data-app-id")||"1",this.countriesCache=null,this.statesCache=new Map,this.citiesCache=new Map,this.pendingRequests=new Map,this.detectedCountry=null}getCountryCodeFromURL(){const e=window.location.pathname.match(/\/([a-z]{2})\//i);return e?e[1].toUpperCase():null}async fetchWithTimeout(e,t={},o=1e4){const s=new AbortController,a=setTimeout((()=>s.abort()),o);try{const o=await fetch(e,{...t,signal:s.signal});return clearTimeout(a),o}catch(e){if(clearTimeout(a),"AbortError"===e.name)throw new Error("Request timeout - server is taking too long to respond");throw e}}async fetchCountries(){if(this.countriesCache)return console.log("Returning c
1ached countries"),this.countriesCache;console.log("Fetching countries from:",this.baseUrls.countries);const e=await this.fetchWithTimeout(this.baseUrls.countries,{method:"GET",headers:{"Content-Type":"application/json",Accept:"*/*"}},8e3);if(!e.ok)throw new Error(`Failed to fetch countries. Status: ${e.status}`);const t=await e.json();return this.countriesCache=t,console.log("Cached countries, count:",t.length),t}async detectCountryFromURL(){const e=this.getCountryCodeFromURL();if(console.log("Country code from URL:",e),!e)return console.log("No country code in URL, defaulting to IN"),"IN";try{const t=(await this.fetchCountries()).find((t=>t.code.toUpperCase()===e));return t?(console.log("Matched country:",t),t.code):(console.log("Country code not found in API data, defaulting to IN"),"IN")}catch(e){return console.error("Error detecting country:",e),"IN"}}populateDropdown(e,t,o="code",s="name",a="Select"){e&&(e.innerHTML=`<option value="">${a}</option>`,t&&t.length>0?(t.forEach((t=>{const a=document.createElement("option");a.value=t[o],a.textContent=t[s],e.appendChild(a)})),e.disabled=!1):e.disabled=!0)}setDropdownLoading(e,t,o="Loading..."){e&&t&&(e.disabled=!0,e.innerHTML=`<option value="">${o}</option>`)}async fetchStates(e){if(this.statesCache.has(e))return console.log("Returning cached states for country:",e),this.statesCache.get(e);const t=`states-${e}`;if(this.pendingRequests.has(t))return console.log("Waiting for pending states request for country:",e),await this.pendingRequests.get(t);const o=`${this.baseUrls.locations}/countries/${e}/states.json`;console.log("Fetching states from:",o);const s=(async()=>{try{const t=await this.fetchWithTimeout(o,{method:"GET",headers:{"Content-Type":"application/json",Accept:"*/*"}},6e3);if(!t.ok)throw new Error(`Failed to fetch states. Status: ${t.status}`);const s=await t.json();return this.statesCache.set(e,s),console.log("Cached states for country:",e,"count:",s.length),s}finally{this.pendingRequests.delete(t)}})();return this.pendingRequests.set(t,s),s}async fetchCities(e,t){const o=`${e}-${t}`;if(this.citiesCache.has(o))return console.log("Returning cached cities for country:",e,"state:",t),this.citiesCache.get(o);const s=`cities-${o}`;if(this.pendingRequests.has(s))return console.log("Waiting for pending cities request"),await this.pendingRequests.get(s);const a=`${this.baseUrls.locations}/countries/${e}/states/${t}/cities.json`;console.log("Fetching cities from:",a);const n=(async()=>{try{const s=await this.fetchWithTimeout(a,{method:"GET",headers:{"Content-Type":"application/json",Accept:"*/*"}},8e3);if(!s.ok)throw new Error(`Failed to fetch cities. Status: ${s.status}`);const n=await s.json();return this.citiesCache.set(o,n),console.log("Cached cities for country:",e,"state:",t,"count:",n.length),n}finally{this.pendingRequests.delete(s)}})();return this.pendingRequests.set(s,n),n}async uploadFiles(e){console.log("Uploading files:",e.length);const t=[];
1try{for(const o of e){(new FormData).append("file",o),t.push(`/blobpaths/${o.name}`)}return console.log("Files uploaded, blob paths:",t),t}catch(e){throw console.error("Error uploading files:",e),e}}async submitRegistrationForm(e,t=[]){let o="";try{const e=sessionStorage.getItem("districtLeadId");if(e){const t=JSON.parse(e);o=t?.data?._id||""}}catch(e){console.error("Error parsing districtLeadId from session storage:",e)}let i=[];if(t&&t.length>0)try{const e=t.map(((e,t)=>s.A.uploadFileStep1(e.name,o,e,this.fileUploadUrl,this.category)));i=await Promise.all(e)}catch(e){console.error("File upload failed:",e)}const l=r.B.getStored(),c={firstName:e.fName,lastName:e.lName,email:e.email,mobile:e.phoneNo,callingCode:e.countryCode.replace("+",""),city:e.city,state:e.state,dob:e.date,bloodGroup:e.bloodGroup,emergencyContactFirstName:e.emeFirstName,emergencyContactLastName:e.emeLastName,emergencyContactNumber:e.emePhoneNo,emergencyContactCallingCode:e.emeCountryCode.replace("+",""),link:e.submissionLink,hasMotorcycleClub:"yes"===e.motorcycleClub,motorcycleModelName:e.motorcycleModel,motorcycleModelCode:e.registrationNo,registrationNumber:e.registrationNo,day:e.eventDay,classSelected:e.motorcycleClass,selectedSlot:"",category:this.category,districtLeadId:o,requestUrl:window.location.href,clientId:(0,n.N)(),pagepath:this.pagePath,uploads:i,...l};e.motorcycleClubName&&""!==e.motorcycleClubName.trim()&&(c.clubName=e.motorcycleClubName),e.yearFounded&&""!==e.yearFounded.trim()&&(c.clubFoundedYear=e.yearFounded),console.log("Submitting registration to API:",this.submitApiUrl),console.log("Payload:",c),console.log("Uploads:",i);try{const e=await this.fetchWithTimeout(this.submitApiUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",pagepath:this.pagePath,pageid:this.category,app_id:this.appId},body:JSON.stringify(c)},15e3);console.log("API Response Status:",e.status);const t=await e.json();return console.log("API Response Data:",t),200===t.code||t.success?(await a.A.razorPayGenerateOrderId(c,t.data),{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:e.message||"Network error occurred",error:e}}}async initializeDropdowns(){if(this.baseUrls.countries&&this.baseUrls.locations)try{this.setDropdownLoading(this.stateDropdown,!0,"Detecting country..."),this.setDropdownLoading(this.cityDropdown,!0,"Select state first"),this.detectedCountry=await this.detectCountryFromURL(),console.log("Using country:",this.detectedCountry),this.setDropdownLoading(this.stateDropdown,!0,"Loading states...");const e=await this.fetchStates(this.detectedCountry);console.log("States fetched successfully:",e?.length||0),this.populateDropdown(this.stateDropdown,e,"state_id","name","Select state"),console.log("States dropdown populated"),this.stateDropdown?.addEventListener("change",(async e=>{const t=e.target.value;if(this.cityDropdown.value="",t)try{this.setDropdownLoading(this.cityDropdown,!0,"Loading cities...");const e=await this.fetchCities(this.detectedCountry,t);console.log("Cities fetched successfully:",e?.length||0),this.populateDropdown(this.cityDropdown,e,"city_id","name","Select city"),console.log("Cities dropdown populated")}catch(e){console.error("Error loading cities:",e),this.cityDropdown.innerHTML='<option value="">Error loading cities</option>',this.cityDropdown.disabled=!0}else this.setDropdownLoading(this.cityDropdown,!0,"Select state first")}))}catch(e){console.error("Error initializing dropdowns:",e),this.stateDropdown.innerHTML='<option value="">Error loading states</option>',this.stateDropdown.disabled=!0}else console.error("API URLs not configured")}},l=o(5202);class c{constructor(){this.apiService=new i;const e=document.querySelector(".motoverse-event-register-form");this.maxNameLength=parseInt(e?.getAttribute("data-max-name-length"))||24,this.maxPhoneLength=parseInt(e?.getAttribute("data-max-phone-length"))||10,this.yearLength=parseInt(e?.getAttribute("data-year-length"))||4,this.regNoMaxLength=parseInt(e?.getAttribute("data-reg-no-max-length"))||17,this.defaultCountryCode=e?.getAttribute("data-default-country-code")||"+91",this.formStepOne=document.getElementById("motoverse-event-form-step1"),this.formStepTwo=document.getElementById("motoverse-event-form-step2"),this.formStepThree=document.getElementById("motoverse-event-form-step3"),this.stepper=document.querySelectorAll(".event-stepper-item"),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.eventCity=document.getElementById("eventCity"),this.eventState=document.getElementById("eventState"),this.selectDateBtn=document.getElementById("selectDateBtn"),this.eventDate=document.getElementById("eventDate"),this.bloodGroup=document.getElementById("bloodGroup"),this.emeFirstName=document.getElementById("emeFirstName"),this.emeLastName=document.getElementById("emeLastName"),this.emeCountryCode=document.getElementById("emeCountryCode"),this.emePhoneNumber=document.getElementById("emePhoneNumber"),this.submissionLink=document.getElementById("submissionLink"),this.motorcycleClubYes=document.getElementById("motorcycleClubYes"),this.motorcycleClubNo=document.getElementById("motorcycleClubNo"),this.eventClubFieldBox=document.getElementById("event-club-field-box"),this.clubName=document.getElementById("clubName"),this.yearFounded=document.getElementById("yearFounded"),this.uploadInfoBox=document.getElementById("upload-info-box"),this.documentUpload=document.getElementById("documentUpload"),this.eventTnCCheckContinue=document.getElementById("eventTnCCheckContinue"),this.imgPreviewBox=document.getElementById("event-upload-preview-main"),this.motorcycleModel=document.getElementById("motorcycleModel"),this.motorcycleClass=document.getElementById("motorcycleClass"),this.eventDay=document.getElementById("eventDay"),this.registrationNo=document.getElementById("registrationNo"),this.eventTnCCheckPay=document.getElementById("eventTnCCheckPay"),this.eventFormFooter=document.getElementById("motoverse-event-form-footer"),this.calenderModelBtn=document.getElementById("calender-modal-btn"),this.shareModelBtn=document.getElementById("share-modal-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.continueBtn=document.getElementById("motoverse-event-continue-btn"),this.proceedBtn=document.getElementById("motoverse-event-pay-btn"),this.formData={},this.init()}handleSetFormData(e,t){this.formData[e]=t}handleGoToStep(e){this.stepper.forEach(((t,o)=>{t.classList.remove("active","complete"),o+1===e?t.classList.add("active"):o+1<=e&&t.classList.add("complete")}
1)),1===e?(this.formStepOne.classList.add("show-step"),this.formStepTwo.classList.remove("show-step"),this.formStepThree.classList.remove("show-step"),this.continueBtn.classList.add("show-btn"),this.proceedBtn.classList.remove("show-btn")):2===e?(this.formStepOne.classList.remove("show-step"),this.formStepTwo.classList.add("show-step"),this.formStepThree.classList.remove("show-step"),this.continueBtn.classList.remove("show-btn"),this.proceedBtn.classList.add("show-btn")):3===e&&(this.formStepOne.classList.remove("show-step"),this.formStepTwo.classList.remove("show-step"),this.formStepThree.classList.add("show-step"),this.stepper[2].classList.add("complete"))}handleCustomError(e,t){const o=document.createElement("small");o.classList.add("event-error-message"),o.textContent=t,e.parentElement.appendChild(o)}handleShowError(e,t){e.classList.remove("input-error");const o=e.parentElement.querySelector(".event-error-message");if(o&&o.remove(),e.value=e.value.trim(),!e.value){e.classList.add("input-error");const o=document.createElement("small");return o.classList.add("event-error-message"),o.textContent=t,e.parentElement.appendChild(o),!1}return!0}handleCheckField(e,t){return!!this.handleShowError(e,t)||(e.focus(),!1)}validateForm(){const e=this.eventClubFieldBox.parentElement.querySelector(".event-error-message");if(e&&e.remove(),!l.A.validateName(this.firstName,"first name"))return!1;if(!l.A.validateName(this.lastName,"last name"))return!1;if(!l.A.validatePhoneNumber(this.phoneNumber))return!1;if(!l.A.validateEmail(this.email))return!1;if(!l.A.validateSelect(this.eventState,"state"))return!1;if(!l.A.validateSelect(this.eventCity,"city"))return!1;if(!l.A.validateDateOfBirth(this.eventDate))return!1;if(!l.A.validateSelect(this.bloodGroup,"blood group"))return!1;if(!l.A.validateName(this.emeFirstName,"emergency contact first name"))return!1;if(!l.A.validateName(this.emeLastName,"emergency contact last name"))return!1;if(!l.A.validatePhoneNumber(this.emePhoneNumber))return!1;if(!l.A.checkEmpty(this.submissionLink,"submission link"))return!1;if(this.motorcycleClubYes.checked){if(!l.A.checkEmpty(this.clubName,"club name"))return!1;if(!l.A.validateYear(this.yearFounded,"year founded"))return!1}return this.motorcycleClubYes.checked||this.motorcycleClubNo.checked?(l.A.clearError(this.documentUpload),this.uploadedFiles&&0!==this.uploadedFiles.length?!!l.A.validateCheckbox(this.eventTnCCheckContinue,"Please check the disclaimer"):(l.A.showError(this.documentUpload,"Please upload documents"),!1)):(this.handleCustomError(this.eventClubFieldBox,"Please select any option"),!1)}validateCategoryForm(){return!!l.A.validateSelect(this.motorcycleModel,"motorcycle model")&&(!!l.A.validateSelect(this.motorcycleClass,"class")&&(!!l.A.validateSelect(this.eventDay,"day")&&(!!l.A.validateRegistrationNumber(this.registrationNo)&&(!!this.eventTnCCheckPay.checked||(this.handleCustomError(this.eventTnCCheckPay,"Please check the disclaimer"),!1)))))}initializeContinueBtn(){this.continueBtn.addEventListener("click",(()=>{let e=!1;e=this.validateForm(),e&&(this.handleSetFormData("fName",this.firstName.value),this.handleSetFormData("lName",this.lastName.value),this.handleSetFormData("c
1ountryCode",this.countryCode.value),this.handleSetFormData("phoneNo",this.phoneNumber.value),this.handleSetFormData("email",this.email.value),this.handleSetFormData("city",this.eventCity.value),this.handleSetFormData("state",this.eventState.value),this.handleSetFormData("date",this.eventDate.value),this.handleSetFormData("bloodGroup",this.bloodGroup.value),this.handleSetFormData("emeFirstName",this.emeFirstName.value),this.handleSetFormData("emeLastName",this.emeLastName.value),this.handleSetFormData("emeCountryCode",this.emeCountryCode.value),this.handleSetFormData("emePhoneNo",this.emePhoneNumber.value),this.handleSetFormData("submissionLink",this.submissionLink.value),this.motorcycleClubYes.checked&&(this.handleSetFormData("motorcycleClubName",this.clubName.value),this.handleSetFormData("yearFounded",this.yearFounded.value)),this.motorcycleClubNo.checked&&this.handleSetFormData("motorcycleClub",this.motorcycleClubNo.value),this.handleSetFormData("documentUpload",this.documentUpload.files),this.handleGoToStep(2),console.log("first"))}))}initializeDatePickerBtn(){const e=this.eventDate?.parentElement;this.selectDateBtn&&this.selectDateBtn.addEventListener("click",(()=>{this.eventDate.showPicker&&this.eventDate.showPicker()})),e&&(e.addEventListener("click",(e=>{e.target!==this.eventDate&&this.eventDate.showPicker&&this.eventDate.showPicker()})),e.addEventListener("keydown",(e=>{"Enter"===e.key&&(e.preventDefault(),this.eventDate.showPicker&&this.eventDate.showPicker())})),e.setAttribute("tabindex","0")),this.eventDate&&this.eventDate.addEventListener("change",(()=>{const e=document.querySelector(".date-input-placeholder");e&&e.remove()}))}initializeClubRadio(){this.motorcycleClubYes.addEventListener("change",(()=>{this.motorcycleClubYes.checked&&this.eventClubFieldBox.classList.remove("d-none")})),this.motorcycleClubNo.addEventListener("change",(()=>{this.motorcycleClubNo.checked&&(this.eventClubFieldBox.classList.add("d-none"),this.clubName.value="",this.yearFounded.value="")}))}initializeImageUpload(){this.uploadedFiles=[];const e=parseInt(this.documentUpload.getAttribute("data-max-files")||4),t=document.querySelector('label[for="documentUpload"]');this.documentUpload.addEventListener("change",(o=>{l.A.clearError(this.documentUpload);const s=Array.from(o.target.files);if(console.log(s),s.length>0){if(this.uploadedFiles.length+s.length>e)return void l.A.showError(this.documentUpload,`You can only upload up to ${e} files`);this.uploadedFiles=[...this.uploadedFiles,...s],this.uploadInfoBox.style.display="none",this.renderUploadedFiles(this.uploadedFiles),this.uploadedFiles.length>=e&&(this.documentUpload.disabled=!0,t&&(t.classList.add("disabled"),t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none")),this.documentUpload.value=""}else console.log("not upload")})),this.imgPreviewBox.addEventListener("click",(o=>{if(o.target.classList.contains("img-delete-btn")){const s=o.target.closest(".upload-img-card"),a=parseInt(s.getAttribute("data-index"));this.uploadedFiles.splice(a,1),this.uploadedFiles.length>0?this.renderUploadedFiles(this.uploadedFiles):(this.imgPreviewBox.innerHTML="",this.uploadInfoBox.style.display="block",this.documentUpload.value=""),this.uploadedFiles.length<e&&(this.documentUpload.disabled=!1,t&&(t.classList.remove("disabled"),t.style.opacity="1",t.style.cursor="pointer",t.style.pointerEvents="auto"))}if(o.target.classList.contains("view-img-btn")){const e=o.target.closest(".upload-img-card").querySelector("img");window.open(e.src,"_blank")}}))}renderUploadedFiles(e){this.imgPreviewBox.innerHTML="",e.forEach(((e,t)=>{const o=new FileReader;o.addEventListener("load",(e=>{this.imgPreviewBox.innerHTML+=`\n <div class="upload-img-card" data-index="${t}">\n <div class="img-box">\n <div class="view-btn-main">\n <button type="button" class="view-img-btn">View Photo</button>\n </div>\n <img src="${e.target.result}" alt="preview-img" />\n </div>\n <div class="img-card-footer">\n <button type="button" class="img-delete-btn">\n Delete\n </button>\n </div>\n </div>\n `})),o.readAsDataURL(e)}))}initializeProceedBtn(){this.proceedBtn.addEventListener("click",(async()=>{let e=!1;if(e=this.validateCategoryForm(),!e)return;this.handleSetFormData("motorcycleModel",this.motorcycleModel.value),this.handleSetFormData("motorcycleClass",this.motorcycleClass.value),this.handleSetFormData("eventDay",this.eventDay.value),this.handleSetFormData("registrationNo",this.registrationNo.value),this.motorcycleClubYes.checked?this.handleSetFormData("motorcycleClub","yes"):this.motorcycleClubNo.checked&&this.handleSetFormData("motorcycleClub","no"),console.log("Complete form data:",this.formData),this.proceedBtn.disabled=!0;const t=this.proceedBtn.textContent;this.proceedBtn.textContent="Submitting...";const o=await this.apiService.submitRegistrationForm(this.formData,this.uploadedFiles);this.proceedBtn.disabled=!1,this.proceedBtn.textContent=t,o.success?(console.log("Form submitted successfully!"),this.handleGoToStep(3),this.eventFormFooter.classList.add("d-none")):(console.error("Form submission failed:",o.message),alert(o.message||"Failed to submit form. Please try again."))}))}initializeCalenderModal(){this.calenderModelBtn.addEventListener("click",(()=>{this.calenderModel.classList.add("show-model")}
1)),this.calenderModelCloseBtn.addEventListener("click",(()=>{this.calenderModel.classList.remove("show-model")}))}initializeShareModal(){this.shareModelBtn.addEventListener("click",(()=>{this.shareModel.classList.add("show-model")})),this.shareModelCloseBtn.addEventListener("click",(()=>{this.shareModel.classList.remove("show-model")}))}setCountryCodeFromURL(){window.location.pathname.includes("/in/")&&(this.countryCode.value=this.defaultCountryCode,this.emeCountryCode.value=this.defaultCountryCode)}loadUserDataFromSession(){try{const e=sessionStorage.getItem("motoverseUserData");if(!e)return void console.log("No user data found in sessionStorage");const t=JSON.parse(e);if(console.log("Loading user data for autofill:",t),!t||!t.data)return void console.log("Invalid user data structure");const o=t.data;if(this.apiUserData={request_id:t.request_id||"",timestamp:t.timestamp||"",locality:o.locality||{country:"",language:""},_id:o._id||"",motoverseId:o.motoverseId||"",riderId:o.riderId||"",fName:o.fName||"",lName:o.lName||"",email:o.email||"",callingCode:o.callingCode||"",mobile:o.mobile||"",gender:o.gender||"",dob:o.dob||"",pincode:o.pincode||"",state:o.state||"",city:o.city||"",address:o.address||"",country:o.country||"",cluster:o.cluster||"",location:o.location||"",clubs:o.clubs||"",isMember:o.isMember||!1,reBike:o.reBike||!1,bikeModel:o.bikeModel||"",bikeReg:o.bikeReg||"",groupAdmin:o.groupAdmin||null,regType:o.regType||"",groupId:o.groupId||[],groupName:o.groupName||"",groupTotal:o.groupTotal||"",groupUrl:o.groupUrl||"",app_id:o.app_id||"",configurations:o.configurations||null,amount:o.amount||"",orderStatus:o.orderStatus||"",phase:o.phase||"",source:o.source||"",tshirtSize:o.tshirtSize||"",damImagePath:o.damImagePath||"",utm_source:o.utm_source||"",utm_medium:o.utm_medium||"",utm_campaign:o.utm_campaign||"",utm_term:o.utm_term||"",utm_content:o.utm_content||"",utm_adgroup:o.utm_adgroup||"",requestUrl:o.requestUrl||"",clientId:o.clientId||"",toWhatsapp:o.toWhatsapp||!1,createdAt:o.createdAt||"",updatedAt:o.updatedAt||""},o.fName&&(this.firstName.value=o.fName),o.lName&&(this.lastName.value=o.lName),o.mobile&&(this.phoneNumber.value=o.mobile),o.email&&(this.email.value=o.email),o.callingCode&&(this.countryCode.value="+"+o.callingCode),o.state){const e=setInterval((()=>{if(!this.eventState.disabled&&this.eventState.options.length>1&&(this.eventState.value=o.state,this.eventState.dispatchEvent(new Event("change")),clearInterval(e),o.city)){const e=setInterval((()=>{!this.eventCity.disabled&&this.eventCity.options.length>1&&(this.eventCity.value=o.city,clearInterval(e))}),100);setTimeout((()=>clearInterval(e)),5e3)}}),100);setTimeout((()=>clearInterval(e)),5e3)}if(o.dob&&(this.eventDate.value=o.dob),(o.clubs||void 0!==o.isMember)&&(!0===o.isMember||o.clubs&&""!==o.clubs.trim()?(this.motorcycleClubYes.checked=!0,this.eventClubFieldBox.classList.remove("d-none"),o.clubs&&(this.clubName.value=o.clubs)):this.motorcycleClubNo.checked=!0),o.bikeModel&&(this.motorcycleModel.value=o.bikeModel),o.bikeReg&&(this.registrationNo.value=o.bikeReg),o.tshirtSize){const e=document.getElementById("tshirtSize");e&&(e.value=o.tshirtSize)}console.log("User data autofilled successfully"),console.log("All API data stored:",this.apiUserData)}catch(e){console.error("Error loading user data from sessionStorage:",e)}}clearErrorOnInput(e){e.addEventListener("input",(()=>{l.A.clearError(e)}))}clearErrorOnChange(e){e.addEventListener("change",(()=>{l.A.clearError(e)}))}initializeInputRestrictions(){[this.firstName,this.lastName,this.emeFirstName,this.emeLastName].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.emePhoneNumber].forEach((e=>{e&&(e.addEventListener("input",(()=>{l.A.clearError(e,e.parentElement.parentElement)})),e.addEventListener("input",(e=>{let t=e.target.value.replace(/\D/g,"");t.length>
1this.maxPhoneLength&&(t=t.substring(0,this.maxPhoneLength)),e.target.value=t})),e.addEventListener("keydown",(e=>{if(0===e.target.value.length){const t=e.key;["0","1","2","3","4","5"].includes(t)&&e.preventDefault()}})))})),this.yearFounded&&(this.clearErrorOnInput(this.yearFounded),this.yearFounded.addEventListener("input",(e=>{let t=e.target.value.replace(/\D/g,"");t.length>this.yearLength&&(t=t.substring(0,this.yearLength)),e.target.value=t}))),this.registrationNo&&(this.clearErrorOnInput(this.registrationNo),this.registrationNo.addEventListener("input",(e=>{let t=e.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");t.length>this.regNoMaxLength&&(t=t.substring(0,this.regNoMaxLength)),e.target.value=t}))),this.email&&this.clearErrorOnInput(this.email),[this.eventState,this.eventCity,this.bloodGroup].forEach((e=>{e&&this.clearErrorOnChange(e)})),this.eventDate&&this.eventDate.addEventListener("change",(()=>{l.A.clearError(this.eventDate)})),this.eventTnCCheckContinue&&this.eventTnCCheckContinue.addEventListener("change",(()=>{l.A.clearCheckboxError(this.eventTnCCheckContinue)})),this.eventTnCCheckPay&&this.eventTnCCheckPay.addEventListener("change",(()=>{l.A.clearCheckboxError(this.eventTnCCheckPay)})),[this.motorcycleModel,this.motorcycleClass,this.eventDay].forEach((e=>{e&&this.clearErrorOnChange(e)})),this.submissionLink&&this.clearErrorOnInput(this.submissionLink),this.clubName&&this.clearErrorOnInput(this.clubName);[this.firstName,this.lastName,this.email,this.submissionLink,this.emeFirstName,this.emeLastName,this.clubName,this.yearFounded].forEach((e=>{e&&e.addEventListener("blur",(e=>{e.target.value=e.target.value.trim()}))}))}init(){this.setCountryCodeFromURL(),this.initializeInputRestrictions(),this.apiService.initializeDropdowns(),this.loadUserDataFromSession(),this.initializeContinueBtn(),this.initializeDatePickerBtn(),this.initializeClubRadio(),this.initializeImageUpload(),this.initializeProceedBtn(),this.initializeCalenderModal(),this.initializeShareModal()}}var d={init:function(){new c}}},6870:function(e,t,o){o.r(t)}}]);
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.