{"version":3,"file":"Email_Collector.DGg38IAP.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/oKDjjcv9kYVwF7JuByTT/ok2ng9XGbyRi9kXhGDXY/Email_Collector.js"],"sourcesContent":["// GatsboyEmailCollector.tsx\n// @framerDisableUnlink\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";// @framerDisableUnlink\nexport default function GatsboyEmailCollector(props){const{emailLabel,emailPlaceholder,buttonText,successMessage,errorMessage,backgroundColor,inputBackground,inputBorder,inputBorderFocus,textColor,labelColor,buttonColor,buttonTextColor,buttonHoverColor,borderRadius,inputBorderRadius,gap,previewDisabled,disabledBackgroundColor,disabledTextColor,disabledMessage}=props;const[email,setEmail]=useState(\"\");const[status,setStatus]=useState(\"idle\");const[focusedField,setFocusedField]=useState(null);const[isLive,setIsLive]=useState(false);const[siteId,setSiteId]=useState(null);useEffect(()=>{// Check if we're in a live environment (not Framer canvas)\nconst checkEnvironment=()=>{const gatsboy=window.Gatsboy;if(gatsboy?.siteId){setIsLive(true);setSiteId(gatsboy.siteId);}};checkEnvironment();// Re-check after a short delay in case runtime loads async\nconst timer=setTimeout(checkEnvironment,500);return()=>clearTimeout(timer);},[]);const handleSubmit=async e=>{e.preventDefault();if(!isLive||!siteId){// On canvas, just show success state briefly\nsetStatus(\"success\");setTimeout(()=>setStatus(\"idle\"),2e3);return;}setStatus(\"submitting\");try{const response=await fetch(\"https://xjbxfwdqtfnnpvgpykiz.supabase.co/functions/v1/form-submit\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({site_id:siteId,form_type:\"email_collector\",payload:{email},email,page_url:window.location.href,referrer:document.referrer||null})});if(!response.ok)throw new Error(\"Failed to submit\");setStatus(\"success\");setEmail(\"\");setTimeout(()=>setStatus(\"idle\"),3e3);}catch(err){console.error(\"Email collector submission error:\",err);setStatus(\"error\");setTimeout(()=>setStatus(\"idle\"),3e3);}};// Check if module should show as disabled\nconst showDisabled=previewDisabled&&!isLive;if(showDisabled){return /*#__PURE__*/_jsx(\"div\",{style:{backgroundColor:disabledBackgroundColor,borderRadius,padding:24,textAlign:\"center\"},children:/*#__PURE__*/_jsx(\"p\",{style:{color:disabledTextColor,margin:0,fontSize:14},children:disabledMessage})});}const inputStyle={width:\"100%\",padding:\"12px 16px\",fontSize:16,color:textColor,backgroundColor:inputBackground,border:\"1px solid \"+(focusedField===\"email\"?inputBorderFocus:inputBorder),borderRadius:inputBorderRadius,outline:\"none\",transition:\"border-color 0.2s ease\",boxSizing:\"border-box\"};return /*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{backgroundColor,borderRadius,padding:24,display:\"flex\",flexDirection:\"column\",gap},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:6},children:[/*#__PURE__*/_jsx(\"label\",{style:{fontSize:14,fontWeight:500,color:labelColor},children:emailLabel}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",required:true,placeholder:emailPlaceholder,value:email,onChange:e=>setEmail(e.target.value),onFocus:()=>setFocusedField(\"email\"),onBlur:()=>setFocusedField(null),disabled:status===\"submitting\",style:inputStyle})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"submitting\",style:{width:\"100%\",padding:\"14px 24px\",fontSize:16,fontWeight:600,color:buttonTextColor,backgroundColor:status===\"submitting\"?buttonHoverColor:buttonColor,border:\"none\",borderRadius:inputBorderRadius,cursor:status===\"submitting\"?\"not-allowed\":\"pointer\",transition:\"background-color 0.2s ease\",opacity:status===\"submitting\"?.7:1},onMouseEnter:e=>{if(status!==\"submitting\"){e.currentTarget.style.backgroundColor=buttonHoverColor;}},onMouseLeave:e=>{if(status!==\"submitting\"){e.currentTarget.style.backgroundColor=buttonColor;}},children:status===\"submitting\"?\"Subscribing...\":buttonText}),status===\"success\"&&/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#ECFDF5\",borderRadius:inputBorderRadius,color:\"#065F46\",fontSize:14,textAlign:\"center\"},children:successMessage}),status===\"error\"&&/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#FEF2F2\",borderRadius:inputBorderRadius,color:\"#991B1B\",fontSize:14,textAlign:\"center\"},children:errorMessage})]});}addPropertyControls(GatsboyEmailCollector,{// Labels\nemailLabel:{type:ControlType.String,title:\"Email Label\",defaultValue:\"Email\"},emailPlaceholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"you@example.com\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Subscribe\"},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Thanks for subscribing!\"},errorMessage:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Something went wrong. Please try again.\"},// Styling\nbackgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},inputBackground:{type:ControlType.Color,title:\"Input BG\",defaultValue:\"#F9FAFB\"},inputBorder:{type:ControlType.Color,title:\"Input Border\",defaultValue:\"#E5E7EB\"},inputBorderFocus:{type:ControlType.Color,title:\"Focus Border\",defaultValue:\"#3B82F6\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#111827\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#374151\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#3B82F6\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},buttonHoverColor:{type:ControlType.Color,title:\"Button Hover\",defaultValue:\"#2563EB\"},borderRadius:{type:ControlType.Number,title:\"Card Radius\",defaultValue:12,min:0,max:32,unit:\"px\"},inputBorderRadius:{type:ControlType.Number,title:\"Input Radius\",defaultValue:8,min:0,max:24,unit:\"px\"},gap:{type:ControlType.Number,title:\"Field Gap\",defaultValue:16,min:8,max:32,unit:\"px\"},// Disabled state\npreviewDisabled:{type:ControlType.Boolean,title:\"Preview Disabled\",defaultValue:false},disabledBackgroundColor:{type:ControlType.Color,title:\"Disabled BG\",defaultValue:\"#F9FAFB\"},disabledTextColor:{type:ControlType.Color,title:\"Disabled Text\",defaultValue:\"#6B7280\"},disabledMessage:{type:ControlType.String,title:\"Disabled Message\",defaultValue:\"Email signup is disabled\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GatsboyEmailCollector\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Email_Collector.map"],"mappings":"uMAGA,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,aAAW,mBAAiB,aAAW,iBAAe,eAAa,kBAAgB,kBAAgB,cAAY,mBAAiB,YAAU,aAAW,cAAY,kBAAgB,mBAAiB,eAAa,oBAAkB,MAAI,kBAAgB,0BAAwB,oBAAkB,mBAAiB,EAAW,CAAC,EAAM,GAAUA,EAAS,EAAE,EAAO,CAAC,EAAO,GAAWA,EAAS,MAAM,EAAO,CAAC,EAAa,GAAiBA,EAAS,IAAI,EAAO,CAAC,EAAO,GAAWA,EAAS,EAAK,EAAO,CAAC,EAAO,GAAWA,EAAS,IAAI,EAAE,MAAc,CAC7kB,IAAM,MAAqB,CAAC,IAAM,EAAQ,EAAO,QAAW,GAAS,SAAQ,EAAU,EAAI,EAAE,EAAU,EAAQ,MAAM,EAAG,EAAE,EAAiB,EAC3I,IAAM,EAAM,WAAW,EAAiB,GAAG,EAAE,UAAU,aAAa,CAAK,CAAE,EAAE,CAAC,CAAC,EAAE,IAAM,EAAa,KAAM,IAAG,CAAoB,GAAnB,EAAE,eAAe,EAAK,CAAC,GAAQ,CAAC,EAAO,CACrJ,EAAU,SAAS,EAAE,eAAe,EAAU,MAAM,EAAE,GAAG,EAAE,MAAO,CAAC,EAAU,YAAY,EAAE,GAAG,CAAoT,GAAG,EAAC,MAA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