{"version":3,"file":"CustomEmailCaptureForm.BIZUcm48.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/Bk8XI7Kso6TNTWllgEwD/RmC6NPt5vdkCLckTZIiP/CustomEmailCaptureForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function addDemoTag(email){if(!/\\+demo(?=@)/.test(email)){return email.replace(/@/,\"+demo@\");}return email;}export default function CustomEmailCaptureForm(props){const[email,setEmail]=useState(\"\");const[websiteUrl,setWebsiteUrl]=useState(\"\");const[loading,setLoading]=useState(false);const[errors,setErrors]=useState({email:\"\",websiteUrl:\"\",general:\"\"});// Clear error when user starts typing\nconst handleEmailChange=e=>{setEmail(e.target.value);if(errors.email){setErrors(prev=>({...prev,email:\"\"}));}};const handleWebsiteUrlChange=e=>{setWebsiteUrl(e.target.value);if(errors.websiteUrl){setErrors(prev=>({...prev,websiteUrl:\"\"}));}};// Validate inputs before submission\nconst validateInputs=()=>{const newErrors={email:\"\",websiteUrl:\"\",general:\"\"};// Email validation\nif(!email.trim()){newErrors.email=\"Email is required\";}else if(!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)){newErrors.email=\"Please enter a valid email address\";}// Website URL validation\nif(!websiteUrl.trim()){newErrors.websiteUrl=\"Business website is required\";}else{try{const url=new URL(websiteUrl.startsWith(\"http\")?websiteUrl:`https://${websiteUrl}`);if(!url.hostname.includes(\".\")){newErrors.websiteUrl=\"Please enter a valid website URL\";}}catch{newErrors.websiteUrl=\"Please enter a valid website URL\";}}setErrors(newErrors);return!newErrors.email&&!newErrors.websiteUrl;};const handleSubmit=async e=>{e.preventDefault();// Clear any prior general error\nsetErrors(prev=>({...prev,general:\"\"}));// Validate inputs\nif(!validateInputs()){return;}setLoading(true);try{const normalizedUrl=websiteUrl.startsWith(\"http\")?websiteUrl:`https://${websiteUrl}`;const modifiedEmail=addDemoTag(email);// Build form data\nconst formData=new URLSearchParams;formData.append(\"email\",modifiedEmail);formData.append(\"websiteUrl\",normalizedUrl);// Clean direct API call - works with CORS headers\nconst response=await fetch(props.webhookUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/x-www-form-urlencoded\",\"x-api-key\":props.apiKey},body:formData.toString()});if(response.ok){const encodedEmail=encodeURIComponent(modifiedEmail);const redirectUrl=`${props.successRedirectUrl}?email=${encodedEmail}&website=${normalizedUrl}`;const user=await response.json();// Set cookies for the demo session\nif(user.userId){document.cookie=[`demo-user-v1=${user.userId}`,`domain=.bluumly.com`,`path=/`,`max-age=${7*24*60*60}`,`secure`,`samesite=None`].join(\";\");}// 🚀 Simple navigation - works everywhere!\nwindow.location.href=redirectUrl;}else{// Handle error response\nconst errorData=await response.json().catch(()=>({}));if(response.status===409){setErrors(prev=>({...prev,email:\"An account with this email already exists\"}));}else if(response.status===401){setErrors(prev=>({...prev,general:\"Authentication failed. Please try again.\"}));}else if(response.status===400){setErrors(prev=>({...prev,general:errorData.message||\"Please check your input and try again.\"}));}else{setErrors(prev=>({...prev,general:\"Submission failed. Please try again.\"}));}}}catch(error){console.error(\"Submission error:\",error);setErrors(prev=>({...prev,general:\"We have a problem generating a demo for this email. Please make sure this is the first time you request one\"}));}finally{setLoading(false);}};return /*#__PURE__*/_jsxs(\"div\",{style:{padding:\"24px\",border:\"1px solid #E0E0E0\",borderRadius:\"12px\",maxWidth:\"480px\",backgroundColor:\"#fff\",fontFamily:\"Inter, sans-serif\",boxSizing:\"border-box\"},children:[/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",flexDirection:\"column\",gap:\"16px\"},children:[errors.general&&/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px\",backgroundColor:\"#FEF2F2\",border:\"1px solid #FECACA\",borderRadius:\"8px\",color:\"#DC2626\",fontSize:\"14px\",marginBottom:\"8px\"},children:errors.general}),/*#__PURE__*/_jsxs(\"label\",{style:{fontWeight:500},children:[\"Email\",/*#__PURE__*/_jsx(\"span\",{style:{color:\"#FF4D4F\"},children:\"*\"}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",placeholder:\"What email address do you use for your business?\",value:email,onChange:handleEmailChange,required:true,style:{marginTop:\"6px\",padding:\"14px\",border:`1px solid ${errors.email?\"#FF4D4F\":\"#E0E0E0\"}`,borderRadius:\"12px\",fontSize:\"14px\",width:\"100%\",boxSizing:\"border-box\",outline:errors.email?\"none\":undefined,boxShadow:errors.email?\"0 0 0 3px rgba(255, 77, 79, 0.1)\":undefined}}),errors.email&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#FF4D4F\",fontSize:\"12px\",marginTop:\"4px\",marginLeft:\"2px\"},children:errors.email})]}),/*#__PURE__*/_jsxs(\"label\",{style:{fontWeight:500},children:[\"Business website\",/*#__PURE__*/_jsx(\"span\",{style:{color:\"#FF4D4F\"},children:\"*\"}),/*#__PURE__*/_jsx(\"input\",{type:\"text\",placeholder:\"www.example.com\",value:websiteUrl,onChange:handleWebsiteUrlChange,required:true,style:{marginTop:\"6px\",padding:\"14px\",border:`1px solid ${errors.websiteUrl?\"#FF4D4F\":\"#E0E0E0\"}`,borderRadius:\"12px\",fontSize:\"14px\",width:\"100%\",boxSizing:\"border-box\",outline:errors.websiteUrl?\"none\":undefined,boxShadow:errors.websiteUrl?\"0 0 0 3px rgba(255, 77, 79, 0.1)\":undefined}}),errors.websiteUrl&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#FF4D4F\",fontSize:\"12px\",marginTop:\"4px\",marginLeft:\"2px\"},children:errors.websiteUrl})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:loading,style:{backgroundColor:loading?\"#A0A0A0\":\"#D45500\",color:\"white\",padding:\"16px\",border:\"none\",borderRadius:\"999px\",fontSize:\"16px\",fontWeight:\"bold\",cursor:loading?\"not-allowed\":\"pointer\",marginTop:\"8px\",transition:\"background-color 0.2s ease\"},children:loading?\"Submitting...\":\"See it in action\"})]}),/*#__PURE__*/_jsxs(\"p\",{style:{fontSize:\"12px\",color:\"#333\",marginTop:\"16px\",lineHeight:\"1.4\"},children:[\"We protect your privacy. Your information is encrypted and never shared with third parties.\",/*#__PURE__*/_jsx(\"br\",{}),\"Read our\",\" \",/*#__PURE__*/_jsx(\"a\",{href:\"#\",style:{textDecoration:\"underline\",color:\"#000\"},children:\"Privacy Policy\"}),\" \",\"|\",\" \",/*#__PURE__*/_jsx(\"a\",{href:\"#\",style:{textDecoration:\"underline\",color:\"#000\"},children:\"Terms of Service\"})]})]});}addPropertyControls(CustomEmailCaptureForm,{webhookUrl:{type:ControlType.String,title:\"Webhook URL\",defaultValue:\"https://example.com/webhook\"},successRedirectUrl:{type:ControlType.String,title:\"Redirect URL\",defaultValue:\"https://yourdomain.com/success\"},apiKey:{type:ControlType.String,title:\"API Key\",defaultValue:\"\",masked:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomEmailCaptureForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomEmailCaptureForm.map"],"mappings":"+LAAyI,SAAS,EAAW,EAAM,CAAoE,MAA/D,cAAc,KAAK,EAAM,CAA6C,EAApC,EAAM,QAAQ,IAAI,SAAS,CAAgB,SAAwB,EAAuB,EAAM,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAG,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAO,GAAWA,EAAS,CAAC,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,CAAC,CACpe,EAAkB,GAAG,CAAC,EAAS,EAAE,OAAO,MAAM,CAAI,EAAO,OAAO,EAAU,IAAO,CAAC,GAAG,EAAK,MAAM,GAAG,EAAE,EAAU,EAAuB,GAAG,CAAC,EAAc,EAAE,OAAO,MAAM,CAAI,EAAO,YAAY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