{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/AI3aG70wygiQZr0qcf4K/Mgfh1NEphF2J5ajzgSMi/CustomFormSubmit.js", "ssg:https://framerusercontent.com/modules/w1otgD76BfjqKK6Gkzzm/xwXFOweIR4ChhEzeyHu5/Validation.js"],
  "sourcesContent": ["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/components/auto-sizing\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */const GENERIC_ERROR_MESSAGE=\"An error has occurred. please try again later.\";const AREA_CODE_ERROR_MESSAGE=\"Area code cannot begin with a 0 or 1\";const PHONE_INCOMPLETE_ERROR_MESSAGE=\"Phone number is incomplete\";// written as a function to try to get around a Framer publishing issue\nconst isSpanishPage=()=>{return window?.location?.pathname?.includes(\"/es\");};const showErrorMessage=message=>{const errorElem=document.getElementById(\"customFormErrorMessage\");errorElem.style.display=\"block\";errorElem.textContent=message;};const hideErrorMessage=()=>{const errorElem=document.getElementById(\"customFormErrorMessage\");errorElem.style.display=\"none\";};const extractDigits=str=>{return str?.match(/\\d+/g)?.join(\"\")||\"\";};const deleteNilValues=obj=>{for(const key in obj){if(obj[key]===null||obj[key]===undefined){delete obj[key];}}return obj;};const BASE_URL=\"https://titoparati.com\";export default function CustomFormSubmit({background_color,border_radius,button_text_en,button_text_sp,hover_background_color,hover_border_color,font_size,font_weight,path_name,submit_data_url_or_path,success_page_path_en,success_page_path_sp,test_mode}){const[isHovered,setIsHovered]=useState(false);// const turnstile = useTurnstile()\nconst buttonText=useMemo(()=>{return!isSpanishPage()?button_text_en:button_text_sp;},[button_text_en,button_text_sp]);const submitDataUrl=useMemo(()=>{if(!submit_data_url_or_path.startsWith(\"https://\")||!submit_data_url_or_path.startsWith(\"http://\")){return`https://hub.centroparaganar.com:8080/${submit_data_url_or_path}`;}else{return submit_data_url_or_path;}},[submit_data_url_or_path]);const handleSuccess=()=>{hideErrorMessage();const submitButtonNode=document.getElementById(\"customFormSubmitButton\");submitButtonNode.innerText=\"Thank You\";submitButtonNode.setAttribute(\"disabled\",\"disabled\");if(!isSpanishPage()){window.location.href=`${BASE_URL}/${success_page_path_en}`;}else{window.location.href=`${BASE_URL}/${success_page_path_sp}`;}};useEffect(()=>{const submitButtonNode=document.getElementById(\"customFormSubmitButton\");const errorNode=document.createElement(\"div\");errorNode.id=\"customFormErrorMessage\";errorNode.style.marginTop=\"20px\";errorNode.style.color=\"#e72126\";errorNode.style.textAlign=\"center\";errorNode.style.fontSize=\"14px\";errorNode.style.display=\"none\";if(!isSpanishPage()){errorNode.textContent=\"An error has occurred. please try again later\";}else{errorNode.textContent=\"Ha ocurrido un error. Por favor, int\\xe9ntalo de nuevo m\\xe1s tarde.\";}submitButtonNode.parentNode.appendChild(errorNode);},[]);const handleSubmit=async e=>{const form=document.forms[0];if(!form.checkValidity()){form.reportValidity()// visually display valiation errors if there are any.\n;return;}// firstName, lastName, email, and phone are on all forms\nconst firstName=form?.[\"firstName\"]?.value;const lastName=form?.[\"lastName\"]?.value;const email=form?.[\"email\"]?.value;const phone=extractDigits(form?.[\"phone\"]?.value);if([\"0\",\"1\"].includes(phone[0])){showErrorMessage(AREA_CODE_ERROR_MESSAGE);return;}if(phone.length!==10){showErrorMessage(PHONE_INCOMPLETE_ERROR_MESSAGE);return;}// these properties are only on some forms.\nconst subscribeToNewsLetterNode=form?.[\"subscribeToNewsletter\"];const subscribeToNewsletter=subscribeToNewsLetterNode?.checked;const caseType=form?.[\"caseType\"]?.value?form?.[\"caseType\"]?.value:null;const formData=deleteNilValues({firstName,lastName,email,phone,subscribeToNewsletter,caseType,language:isSpanishPage()?\"sp\":\"en\"});if(path_name){formData.pathName=window.location.pathname;}// This is our way of testing the form validation functionality without actually submitting the data.\nif(!test_mode){try{const response=await fetch(submitDataUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(formData)});if(response.ok){const data=await response.json();handleSuccess();}else{showErrorMessage(GENERIC_ERROR_MESSAGE);}}catch(error){showErrorMessage(GENERIC_ERROR_MESSAGE);}}else{console.log(\"Test Submission\",formData);handleSuccess();}};const containerStyle={alignItems:\"center\",backgroundColor:!isHovered?background_color:hover_background_color,borderWidth:\"1px\",borderStyle:\"solid\",borderColor:!isHovered?background_color:hover_border_color,borderRadius:`${border_radius}px`,color:!isHovered?\"white\":background_color,cursor:\"pointer\",display:\"flex\",fontSize:`${font_size}px`,fontWeight:font_weight,justifyContent:\"center\",outline:\"none\",width:\"100%\",height:\"100%\"};return /*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsx(\"button\",{id:\"customFormSubmitButton\",style:containerStyle,onClick:handleSubmit,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),type:\"button\",children:buttonText})});}CustomFormSubmit.defaultProps={button_text_en:\"Get Connected\",button_text_sp:\"Mantente Informado\",submit_data_url_or_path:\"\"};addPropertyControls(CustomFormSubmit,{background_color:{type:ControlType.Color,defaultValue:\"#231f20\"},border_radius:{type:ControlType.Number,defaultValue:10,min:0,max:12,step:1,displayStepper:false},hover_background_color:{type:ControlType.Color,defaultValue:\"#fff\"},hover_border_color:{type:ControlType.Color,defaultValue:\"#e72126\"},button_text_en:{type:ControlType.String,title:\"Button Text (EN)\",defaultValue:\"Get Connected\"},button_text_sp:{type:ControlType.String,title:\"Button Text (SP)\",defaultValue:\"Mantente Informado\"},font_size:{type:ControlType.Number,defaultValue:20,min:8,max:24,step:1,displayStepper:false},font_weight:{type:ControlType.Enum,defaultValue:\"normal\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",options:[\"normal\",\"bold\"],optionTitles:[\"Normal\",\"Bold\"]},path_name:{type:ControlType.Boolean,title:\"Include Pathname\",defaultValue:false},submit_data_url_or_path:{type:ControlType.String,title:\"Submit Data URL/Path\"},success_page_path_en:{type:ControlType.String,title:\"Success Page Path (EN)\"},success_page_path_sp:{type:ControlType.String,title:\"Success Page Path (SP)\"},test_mode:{type:ControlType.Boolean,title:\"Test Mode\",defaultValue:false}})// Styles are written in object syntax\n// Learn more: https://reactjs.org/docs/dom-elements.html#style\n;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomFormSubmit\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomFormSubmit.map", "import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";/**\n@framerDisableUnlink\n@framerIntrinsicWidth 100\n@framerIntrinsicHeight 100\n*/export function withPhoneMaskAndNameValidation(Component){return props=>{useEffect(()=>{const applyPhoneMask=event=>{const matrix=\"(___) ___-____\"// Adjust phone matrix as needed\n;let i=0;const def=matrix.replace(/\\D/g,\"\");let currentValue=event.target.value.replace(/\\D/g,\"\");if(def.length>=currentValue.length){currentValue=def;}const newValue=matrix.replace(/./g,function(a){return/[_\\d]/.test(a)&&i<currentValue.length?currentValue.charAt(i++):i>=currentValue.length?\"\":a;});event.target.value=newValue;};const handleBlur=event=>{const currentValue=event.target.value;// Adjust 2 to 3 for country codes with two digits (e.g., +38)\nif(currentValue.length<=2){event.target.value=\"\";const customEvent=new Event(\"change\");event.target.dispatchEvent(customEvent);}};const restrictNameInput=event=>{const regex=/^[a-zA-Z\\u0400-\\u04FF\\s]*$/// Latin, Cyrillic, and spaces\n;if(!regex.test(event.target.value)){event.target.value=event.target.value.replace(/[^a-zA-Z\\u0400-\\u04FF\\s]/g,\"\");}};const phoneFields=document.querySelectorAll('input[type=\"tel\"]');const nameFields=document.querySelectorAll('input[name=\"firstName\"]');phoneFields.forEach(phoneField=>{phoneField.addEventListener(\"input\",applyPhoneMask);phoneField.addEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.addEventListener(\"input\",restrictNameInput);});// Cleanup on unmount\nreturn()=>{phoneFields.forEach(phoneField=>{phoneField.removeEventListener(\"input\",applyPhoneMask);phoneField.removeEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.removeEventListener(\"input\",restrictNameInput);});};},[]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withPhoneMaskAndNameValidation\":{\"type\":\"reactHoc\",\"name\":\"withPhoneMaskAndNameValidation\",\"annotations\":{\"framerIntrinsicHeight\":\"100\",\"framerDisableUnlink\":\"@framerIntrinsicWidth 100\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Validation.map"],
  "mappings": "yJAMG,IAAMA,EAAsB,iDAAuDC,EAAwB,uCAA6CC,EAA+B,6BACpLC,EAAc,IAAYC,GAAQ,UAAU,UAAU,SAAS,KAAK,EAAUC,EAAiBC,GAAS,CAAC,IAAMC,EAAU,SAAS,eAAe,wBAAwB,EAAEA,EAAU,MAAM,QAAQ,QAAQA,EAAU,YAAYD,CAAQ,EAAQE,EAAiB,IAAI,CAAC,IAAMD,EAAU,SAAS,eAAe,wBAAwB,EAAEA,EAAU,MAAM,QAAQ,MAAO,EAAQE,EAAcC,GAAaA,GAAK,MAAM,MAAM,GAAG,KAAK,EAAE,GAAG,GAAWC,EAAgBC,GAAK,CAAC,QAAUC,KAAOD,GAAQA,EAAIC,CAAG,IAAI,MAAMD,EAAIC,CAAG,IAAI,SAAW,OAAOD,EAAIC,CAAG,EAAI,OAAOD,CAAI,EAAQE,EAAS,yBAAwC,SAARC,EAAkC,CAAC,iBAAAC,EAAiB,cAAAC,EAAc,eAAAC,EAAe,eAAAC,EAAe,uBAAAC,EAAuB,mBAAAC,EAAmB,UAAAC,EAAU,YAAAC,EAAY,UAAAC,EAAU,wBAAAC,EAAwB,qBAAAC,EAAqB,qBAAAC,EAAqB,UAAAC,CAAS,EAAE,CAAC,GAAK,CAACC,EAAUC,CAAY,EA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ues", "obj", "key", "BASE_URL", "CustomFormSubmit", "background_color", "border_radius", "button_text_en", "button_text_sp", "hover_background_color", "hover_border_color", "font_size", "font_weight", "path_name", "submit_data_url_or_path", "success_page_path_en", "success_page_path_sp", "test_mode", "isHovered", "setIsHovered", "ye", "buttonText", "se", "submitDataUrl", "handleSuccess", "submitButtonNode", "ue", "errorNode", "handleSubmit", "e", "form", "firstName", "lastName", "email", "phone", "subscribeToNewsletter", "caseType", "formData", "response", "data", "containerStyle", "l", "addPropertyControls", "ControlType", "withPhoneMaskAndNameValidation", "Component", "props", "ue", "applyPhoneMask", "event", "matrix", "i", "def", "currentValue", "newValue", "a", "handleBlur", "customEvent", "restrictNameInput", "phoneFields", "nameFields", "phoneField", "nameField"]
}
