{
  "version": 3,
  "sources": ["ssg: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(\";\");}// \uD83D\uDE80 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": "gJAAyI,SAASA,EAAWC,EAAM,CAAC,MAAI,cAAc,KAAKA,CAAK,EAA8CA,EAApCA,EAAM,QAAQ,IAAI,QAAQ,CAAgB,CAAgB,SAARC,EAAwCC,EAAM,CAAC,GAAK,CAACF,EAAMG,CAAQ,EAAEC,EAAS,EAAE,EAAO,CAACC,EAAWC,CAAa,EAAEF,EAAS,EAAE,EAAO,CAACG,EAAQC,CAAU,EAAEJ,EAAS,EAAK,EAAO,CAACK,EAAOC,CAAS,EAAEN,EAAS,CAAC,MAAM,GAAG,WAAW,GAAG,QAAQ,EAAE,CAAC,EACneO,EAAkBC,GAAG,CAACT,EAASS,EAAE,OAAO,KAAK,EAAKH,EAAO,OAAOC,EAAUG,IAAO,CAAC,GAAGA,EAAK,MAAM,EAAE,EAAE,CAAG,EAAQC,EAAuBF,GAAG,CAACN,EAAc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AQ,SAAS,OAAO,WAAW,OAAO,OAAOA,EAAQ,cAAc,UAAU,UAAU,MAAM,WAAW,4BAA4B,EAAE,SAASA,EAAQ,gBAAgB,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAeU,EAAM,IAAI,CAAC,MAAM,CAAC,SAAS,OAAO,MAAM,OAAO,UAAU,OAAO,WAAW,KAAK,EAAE,SAAS,CAAC,8FAA2GW,EAAK,KAAK,CAAC,CAAC,EAAE,WAAW,IAAiBA,EAAK,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,eAAe,YAAY,MAAM,MAAM,EAAE,SAAS,gBAAgB,CAAC,EAAE,IAAI,IAAI,IAAiBA,EAAK,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,eAAe,YAAY,MAAM,MAAM,EAAE,SAAS,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAACC,EAAoB5B,EAAuB,CAAC,WAAW,CAAC,KAAK6B,EAAY,OAAO,MAAM,cAAc,aAAa,6BAA6B,EAAE,mBAAmB,CAAC,KAAKA,EAAY,OAAO,MAAM,eAAe,aAAa,gCAAgC,EAAE,OAAO,CAAC,KAAKA,EAAY,OAAO,MAAM,UAAU,aAAa,GAAG,OAAO,EAAI,CAAC,CAAC",
  "names": ["addDemoTag", "email", "CustomEmailCaptureForm", "props", "setEmail", "ye", "websiteUrl", "setWebsiteUrl", "loading", "setLoading", "errors", "setErrors", "handleEmailChange", "e", "prev", "handleWebsiteUrlChange", "validateInputs", "newErrors", "u", "normalizedUrl", "modifiedEmail", "formData", "response", "encodedEmail", "redirectUrl", "user", "window", "errorData", "error", "p", "addPropertyControls", "ControlType"]
}
