{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/AI3aG70wygiQZr0qcf4K/2jQPUCwjPrDmXWv9Yt2a/CustomFormSubmit.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,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 customerReferralSourceId=form?.[\"customerReferralSourceId\"]?.value?Number(form?.[\"customerReferralSourceId\"]?.value):null;const subscribeToNewsletter=subscribeToNewsLetterNode?.checked;const caseType=form?.[\"caseType\"]?.value?form?.[\"caseType\"]?.value:null;const formData=deleteNilValues({firstName,lastName,email,phone,subscribeToNewsletter,customerReferralSourceId:customerReferralSourceId,caseType,language:isSpanishPage()?\"sp\":\"en\"});// 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\"]},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"],
  "mappings": "8JAMG,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,wBAAAC,EAAwB,qBAAAC,EAAqB,qBAAAC,EAAqB,UAAAC,CAAS,EAAE,CAAC,GAAK,CAACC,EAAUC,CAAY,EAAEC,EAAS,EAAK,EACl3BC,EAAWC,EAAQ,IAAY7B,EAAc,EAAiBgB,EAAfD,EAAgC,CAACA,EAAeC,CAAc,CAAC,EAAQc,EAAcD,EAAQ,IAAQ,CAACR,EAAwB,WAAW,UAA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iB,CAAC,KAAKwC,EAAY,MAAM,aAAa,SAAS,EAAE,cAAc,CAAC,KAAKA,EAAY,OAAO,aAAa,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,eAAe,EAAK,EAAE,uBAAuB,CAAC,KAAKA,EAAY,MAAM,aAAa,MAAM,EAAE,mBAAmB,CAAC,KAAKA,EAAY,MAAM,aAAa,SAAS,EAAE,eAAe,CAAC,KAAKA,EAAY,OAAO,MAAM,mBAAmB,aAAa,eAAe,EAAE,eAAe,CAAC,KAAKA,EAAY,OAAO,MAAM,mBAAmB,aAAa,oBAAoB,EAAE,UAAU,CAAC,KAAKA,EAAY,OAAO,aAAa,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,eAAe,EAAK,EAAE,YAAY,CAAC,KAAKA,EAAY,KAAK,aAAa,SAAS,wBAAwB,GAAK,0BAA0B,WAAW,QAAQ,CAAC,SAAS,MAAM,EAAE,aAAa,CAAC,SAAS,MAAM,CAAC,EAAE,wBAAwB,CAAC,KAAKA,EAAY,OAAO,MAAM,sBAAsB,EAAE,qBAAqB,CAAC,KAAKA,EAAY,OAAO,MAAM,wBAAwB,EAAE,qBAAqB,CAAC,KAAKA,EAAY,OAAO,MAAM,wBAAwB,EAAE,UAAU,CAAC,KAAKA,EAAY,QAAQ,MAAM,YAAY,aAAa,EAAK,CAAC,CAAC",
  "names": ["GENERIC_ERROR_MESSAGE", "AREA_CODE_ERROR_MESSAGE", "PHONE_INCOMPLETE_ERROR_MESSAGE", "isSpanishPage", "window", "showErrorMessage", "message", "errorElem", "hideErrorMessage", "extractDigits", "str", "deleteNilValues", "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", "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", "subscribeToNewsLetterNode", "customerReferralSourceId", "subscribeToNewsletter", "caseType", "formData", "response", "data", "containerStyle", "l", "addPropertyControls", "ControlType"]
}
