{"version":3,"file":"Form_utm.D9drplOi.mjs","names":[],"sources":["https:/framerusercontent.com/modules/46opomEnbMdef7miv4BA/U0tSx0dAo1Fyq5SXXFQX/Form_utm.js"],"sourcesContent":["// import { ComponentType, useEffect } from \"react\"\n// // Made with love by Clément: https://lionneclement.com/\n// // Full tutorial: https://framermart.com/tutorial/how-to-track-utm-parameters-in-framer-forms\n// export function withAllParams(Component): ComponentType {\n//     return (props: any) => {\n//         useEffect(() => {\n//             if (typeof window !== \"undefined\") {\n//                 const params = new URLSearchParams(window.location.search)\n//                 const form = document.querySelector(`form.${props.className}`)\n//                 if (form) {\n//                     params.forEach((value, key) => {\n//                         const input = document.createElement(\"input\")\n//                         input.type = \"hidden\"\n//                         input.name = key\n//                         input.value = value\n//                         form.appendChild(input)\n//                     })\n//                 }\n//             }\n//         }, [props.className])\n//         return <Component {...props} />\n//     }\n// }\n// export function withUTMParams(Component): ComponentType {\n//     return (props: any) => {\n//         useEffect(() => {\n//             if (typeof window !== \"undefined\") {\n//                 const params = new URLSearchParams(window.location.search)\n//                 const form = document.querySelector(`form.${props.className}`)\n//                 if (form) {\n//                     params.forEach((value, key) => {\n//                         if (key.startsWith(\"utm\")) {\n//                             const input = document.createElement(\"input\")\n//                             input.type = \"hidden\"\n//                             input.name = key\n//                             input.value = value\n//                             form.appendChild(input)\n//                         }\n//                     })\n//                 }\n//             }\n//         }, [props.className])\n//         return <Component {...props} />\n//     }\n// }\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function withAllParams(Component){return props=>{useEffect(()=>{if(typeof window===\"undefined\")return;const params=new URLSearchParams(window.location.search);const form=document.querySelector(`form.${props.className}`);if(!form)return;// Add URL Parameters\nparams.forEach((value,key)=>{if(!form.querySelector(`input[name=\"${key}\"]`)){const input=document.createElement(\"input\");input.type=\"hidden\";input.name=key;input.value=value;form.appendChild(input);}});const pincode=form.querySelector('input[name=\"Pincode\"]');const phone=form.querySelector('input[name=\"Phone number\"]');const location=form.querySelector('select[name=\"Location\"]');const submitButton=form.querySelector('button[type=\"submit\"]');const validateForm=()=>{let isValid=true;// Pincode Validation\nif(pincode){pincode.value=pincode.value.replace(/\\D/g,\"\").slice(0,6);if(pincode.value.length!==6){pincode.setCustomValidity(\"Please enter a 6-digit pincode.\");isValid=false;}else{pincode.setCustomValidity(\"\");}}// Phone Validation\nif(phone){phone.value=phone.value.replace(/\\D/g,\"\").slice(0,10);if(phone.value.length!==10){phone.setCustomValidity(\"Please enter a 10-digit phone number.\");isValid=false;}else{phone.setCustomValidity(\"\");}}// Location Validation\nif(location){if(location.value.toLowerCase()===\"other\"){location.setCustomValidity(\"Sorry! Our services are currently available in the above listed cities only.\");isValid=false;}else{location.setCustomValidity(\"\");}}// Enable / Disable Submit Button\nif(submitButton){submitButton.disabled=!isValid;submitButton.style.opacity=isValid?\"1\":\"0.5\";submitButton.style.cursor=isValid?\"pointer\":\"not-allowed\";}return isValid;};pincode?.addEventListener(\"input\",validateForm);phone?.addEventListener(\"input\",validateForm);location?.addEventListener(\"change\",validateForm);pincode?.addEventListener(\"blur\",()=>{if(pincode.value.length!==6){pincode.reportValidity();}});phone?.addEventListener(\"blur\",()=>{if(phone.value.length!==10){phone.reportValidity();}});location?.addEventListener(\"change\",()=>{if(location.value.toLowerCase()===\"other\"){location.reportValidity();}});form.addEventListener(\"submit\",e=>{if(!validateForm()){e.preventDefault();if(location&&location.value.toLowerCase()===\"other\"){location.reportValidity();return;}if(pincode&&pincode.value.length!==6){pincode.reportValidity();return;}if(phone&&phone.value.length!==10){phone.reportValidity();return;}}});validateForm();},[props.className]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withAllParams\":{\"type\":\"reactHoc\",\"name\":\"withAllParams\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Form_utm.map"],"mappings":"gIA6CwE,SAAgB,EAAc,EAAU,CAAC,MAAO,K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