{"version":3,"file":"SignUpFormToN8N.DITHvON8.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/7PRZAzjWWlO580tokCsl/bx5EuvQ2IGXyMm406bkq/SignUpFormToN8N.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useRef,useEffect,useState}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function SignUpFormToN8N(props){const hashValue=async text=>{if(!text)return\"\";const encoder=new TextEncoder;const data=encoder.encode(text.trim().toLowerCase());const hashBuffer=await crypto.subtle.digest(\"SHA-256\",data);return Array.from(new Uint8Array(hashBuffer)).map(b=>b.toString(16).padStart(2,\"0\")).join(\"\");};const getCookie=name=>{const value=`; ${document.cookie}`;const parts=value.split(`; ${name}=`);if(parts.length===2){const cookie=parts.pop().split(\";\").shift();try{return JSON.parse(decodeURIComponent(cookie));}catch{return null;}}return null;};const setCookie=(name,value,days=30)=>{const date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3);const expires=`expires=${date.toUTCString()}`;document.cookie=`${name}=${JSON.stringify(value)};${expires};path=/`;};const{url,buttonColor,hoverButtonColor,buttonText,buttonSubText,sendAllUrlParametersWithForm}=props;const facebookPixelId=\"611894155231362\"// customizable\n;const vorwahlRef=useRef(null);const telefonRef=useRef(null);const formRef=useRef(null);const[isSubmitting,setIsSubmitting]=useState(false);useEffect(()=>{const vorwahlSelect=vorwahlRef.current;const telefonInput=telefonRef.current;const form=formRef.current;const validatePhoneNumber=(submit=false)=>{let telefon=telefonInput.value.replaceAll(\" \",\"\");telefonInput.value=telefon;const vorwahl=vorwahlSelect.value;if(vorwahl.startsWith(\"+\")){if(telefon.startsWith(\"4\"))telefon=telefon.slice(2);if(telefon.startsWith(\"04\"))telefon=telefon.slice(3);if(telefon.startsWith(\"004\"))telefon=telefon.slice(4);if(telefon.startsWith(\"0\"))telefon=telefon.slice(1);if(telefon.startsWith(\"+4\"))telefon=telefon.slice(3);if(submit)telefonInput.value=telefon;const digitCount=telefon.length;if(digitCount>=8&&digitCount<=11){telefonInput.setCustomValidity(\"\");}else{telefonInput.setCustomValidity(\"Bitte gib deine korrekte WhatsApp-Nummer an.\");}}else{const digitCount=telefon.length;if(digitCount>=7&&digitCount<=15){telefonInput.setCustomValidity(\"\");}else{telefonInput.setCustomValidity(\"Bitte gib deine korrekte WhatsApp-Nummer an.\");}}};const handleSubmit=async e=>{validatePhoneNumber(true);if(!form.checkValidity())return;setIsSubmitting(true);const formData=new FormData(form);if(sendAllUrlParametersWithForm){new URLSearchParams(window.location.search).forEach((v,k)=>{formData.append(k,v);const input=document.createElement(\"input\");input.type=\"hidden\";input.name=k;input.value=v;form.appendChild(input);});}// Also send the target URL itself\nconst sourceUrl=window.location.origin+window.location.pathname;formData.append(\"source_url\",sourceUrl);const hiddenUrl=document.createElement(\"input\");hiddenUrl.type=\"hidden\";hiddenUrl.name=\"source_url\";hiddenUrl.value=sourceUrl;form.appendChild(hiddenUrl);try{const dataObj={vorname:formData.get(\"vorname\"),nachname:formData.get(\"nachname\"),telefon:formData.get(\"telefon\"),vorwahl:formData.get(\"vorwahl\"),email:formData.get(\"email\")};// Facebook Pixel Lead event + hashed data\nif(new URLSearchParams(window.location.search).get(\"utm_campaign\")?.includes(\"-meta\")){const[fn,ln,ph,em]=await Promise.all([hashValue(dataObj.vorname.toString()),hashValue(dataObj.nachname.toString()),hashValue(dataObj.vorwahl.toString()+dataObj.telefon.toString()),hashValue(dataObj.email.toString())]);const img=document.createElement(\"img\");img.height=1;img.width=1;img.style.display=\"none\";img.src=`https://www.facebook.com/tr/?id=${facebookPixelId}&ev=Lead&ud[em]=${em}&ud[fn]=${fn}&ud[ln]=${ln}&ud[ph]=${ph}`;document.body.appendChild(img);}// const res = await fetch(url, { method: \"POST\", body: formData })\n// Save to cookie\nsetCookie(\"formData\",dataObj);}catch(err){console.error(err);}finally{setIsSubmitting(false);}};telefonInput.addEventListener(\"input\",()=>validatePhoneNumber());vorwahlSelect.addEventListener(\"change\",()=>validatePhoneNumber());form.addEventListener(\"submit\",handleSubmit);return()=>{telefonInput.removeEventListener(\"input\",()=>validatePhoneNumber());vorwahlSelect.removeEventListener(\"change\",()=>validatePhoneNumber());form.removeEventListener(\"submit\",handleSubmit);};},[url,sendAllUrlParametersWithForm,facebookPixelId]);useEffect(()=>{const saved=getCookie(\"formData\");if(saved&&formRef.current){const f=formRef.current;f.vorname.value=saved.vorname||\"\";f.nachname.value=saved.nachname||\"\";f.email.value=saved.email||\"\";f.vorwahl.value=saved.vorwahl||\"+49\";f.telefon.value=saved.telefon||\"\";}},[]);return /*#__PURE__*/_jsxs(motion.div,{style:{display:\"flex\",justifyContent:\"center\"},children:[/*#__PURE__*/_jsxs(\"form\",{action:url,method:\"POST\",className:\"form-to-n8n\",ref:formRef,children:[/*#__PURE__*/_jsx(\"div\",{className:\"form-group\",children:/*#__PURE__*/_jsx(\"input\",{type:\"text\",id:\"vorname\",name:\"vorname\",placeholder:\"Dein Vorname\",required:true})}),/*#__PURE__*/_jsx(\"div\",{className:\"form-group\",children:/*#__PURE__*/_jsx(\"input\",{type:\"text\",id:\"nachname\",name:\"nachname\",placeholder:\"Dein Nachname\",required:true})}),/*#__PURE__*/_jsx(\"div\",{className:\"form-group\",children:/*#__PURE__*/_jsxs(\"div\",{className:\"phone-group\",children:[/*#__PURE__*/_jsxs(\"select\",{name:\"vorwahl\",id:\"vorwahl\",ref:vorwahlRef,required:true,children:[/*#__PURE__*/_jsx(\"option\",{value:\"+49\",children:\"🇩🇪 +49\"}),/*#__PURE__*/_jsx(\"option\",{value:\"+43\",children:\"🇦🇹 +43\"}),/*#__PURE__*/_jsx(\"option\",{value:\"+41\",children:\"🇨🇭 +41\"}),/*#__PURE__*/_jsx(\"option\",{value:\"other\",children:\"+\"})]}),/*#__PURE__*/_jsx(\"input\",{type:\"tel\",id:\"telefon\",name:\"telefon\",placeholder:\"Deine Whatsappnummer\",pattern:\"[0-9+]*\",required:true,ref:telefonRef})]})}),/*#__PURE__*/_jsx(\"div\",{className:\"form-group\",children:/*#__PURE__*/_jsx(\"input\",{type:\"email\",id:\"email\",name:\"email\",placeholder:\"Deine beste E-Mail Adresse\",required:true})}),/*#__PURE__*/_jsxs(\"button\",{type:\"submit\",disabled:isSubmitting,children:[/*#__PURE__*/_jsx(\"p\",{children:isSubmitting?\"Wird gesendet...\":buttonText}),/*#__PURE__*/_jsx(\"p\",{className:\"subtext\",children:buttonSubText})]})]}),/*#__PURE__*/_jsx(\"style\",{children:`\n                .form-to-n8n {\n                        width: min(95vw, 300px);\n                    }\n                    .form-group {\n                        margin-bottom: 3px;\n                    }\n                    .form-group input[type=\"text\"],\n                    .form-group input[type=\"email\"] {\n                        width: 100%;\n                        box-sizing: border-box;\n                        border-radius: 4px;\n                        padding: 0px 10px 0px 12px;\n                        height: 40px;\n                        text-align: left;\n                        color: rgb(0, 0, 0);\n                        font-family: Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n                        font-size: 16px;\n                        font-weight: 400;\n                        letter-spacing: 0px;\n                        background-color: rgb(255, 255, 255);\n                        border: 1px solid rgb(148, 149, 150);\n                    }\n                    .form-group .phone-group {\n                        display: flex;\n                        align-items: center;\n                        gap: 10px;\n                        box-sizing: border-box;\n                        border-radius: 4px;\n                        background-color: rgb(255, 255, 255);\n                        border: 1px solid rgb(148, 149, 150);\n                        height: 40px;\n                    }\n                    .form-group select {\n                        width: 120px;\n                        border: none;\n                        text-align: left;\n                        color: rgb(0, 0, 0);\n                        padding: 0px 0px 0px 16px;\n                        font-family: Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n                        font-size: 16px;\n                        font-weight: 400;\n                        height: 38px;\n                        background-position: right 0px center !important;\n                    }\n                    .form-group input[type=\"tel\"] {\n                        width: 100%;\n                        padding: 0px 0px 0px 16px;\n                        text-align: left;\n                        color: rgb(0, 0, 0);\n                        font-family: Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n                        font-size: 16px;\n                        font-weight: 400;\n                        letter-spacing: 0px;\n                        height: 38px;\n                        border: none;\n                    }\n                    .form-to-n8n button {\n                        margin-top: 6px;\n                        margin-bottom: 6px;\n                        background: ${buttonColor};\n                        border-radius: 4px;\n                        border-style: none;\n                        border-color: rgb(0, 0, 0);\n                        border-width: 2px;\n                        color: rgb(255, 255, 255);\n                        font-family: Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n                        font-size: 18px;\n                        font-weight: 700;\n                        letter-spacing: 0px;\n                        font-style: normal;\n                        white-space: normal;\n                        padding-top: 0px;\n                        padding-bottom: 0px;\n                        text-align: center;\n                        word-break: break-word;\n                        align-self: flex-end;\n                        cursor: pointer;\n                        pointer-events: auto;\n                        width: 100%;\n                        /* NEU: Multi-Line Support & Zentrierung */\n                        display: flex;\n                        flex-direction: column;\n                        justify-content: center;\n                        align-items: center;\n                        /* etwas gro\\xdfz\\xfcgigere Zeilenh\\xf6he */\n                        line-height: 2.0;\n                    }\n                    .form-to-n8n button:hover {\n                        background-color: ${hoverButtonColor};\n                    }\n                    .form-to-n8n button .subtext {\n                        font-size: 14px;\n                        font-weight: 400;\n                    }\n            `})]});}addPropertyControls(SignUpFormToN8N,{url:{title:\"URL\",type:ControlType.String,defaultValue:\"https://n8n.roadtoglory.de/webhook-test/test\"},buttonText:{title:\"Button Text\",type:ControlType.String,defaultValue:\"Jetzt anmelden\"},buttonSubText:{title:\"Button SubText\",type:ControlType.String,defaultValue:\"\"},buttonColor:{title:\"Button Color\",type:ControlType.Color,defaultValue:\"#F3A813\"},hoverButtonColor:{title:\"Button Hover Color\",type:ControlType.Color,defaultValue:\"#FABC1F\"},sendAllUrlParametersWithForm:{title:\"Send all Url Parameters\",type:ControlType.Boolean,defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SignUpFormToN8N\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupported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