{"version":3,"file":"SubstackSubscribe.Y4HTaSZC.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/AkT7M5XYOaZNYXzQbZvi/9tfb97TN3jAaM7cRKG7L/SubstackSubscribe.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";var FormState;(function(FormState){FormState[\"Idle\"]=\"idle\";FormState[\"Loading\"]=\"loading\";FormState[\"Success\"]=\"success\";FormState[\"Error\"]=\"error\";})(FormState||(FormState={}));export default function SubstackSubscribe({buttonText=\"Join free\",successText=\"You're in!\",placeholder=\"Your email\",buttonColor=\"rgb(196, 104, 74)\",buttonTextColor=\"#FFFFFF\",inputBg=\"rgb(250, 250, 248)\",inputBorder=\"rgb(224, 220, 215)\",inputText=\"rgb(26, 26, 26)\",fontSize=16,borderRadius=12,height=56,substackUrl=\"stefanvilar.substack.com\",variant=\"primary\",style}){const[state,setState]=useState(\"idle\");const[email,setEmail]=useState(\"\");const resolvedButtonColor=variant===\"secondary\"?\"rgb(26, 26, 26)\":buttonColor;const resolvedHeight=variant===\"secondary\"?60:height;const handleSubmit=async e=>{e.preventDefault();if(!email||!email.includes(\"@\"))return;setState(\"loading\");try{await fetch(`https://${substackUrl}/api/v1/free?nojs=true`,{method:\"POST\",headers:{\"Content-Type\":\"application/x-www-form-urlencoded\"},body:new URLSearchParams({first_url:`https://${substackUrl}/`,first_referrer:\"\",current_url:`https://${substackUrl}/`,current_referrer:window.location.href,referral_code:\"\",source:\"embed\",referring_pub_id:\"\",additional_referring_pub_ids:\"\",email:email}).toString(),mode:\"no-cors\"});setState(\"success\");setEmail(\"\");}catch{setState(\"error\");}};const labelText=state===\"success\"?successText:state===\"error\"?\"Try again\":state===\"loading\"?\"...\":buttonText;return /*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",flexDirection:\"row\",gap:12,width:\"100%\",maxWidth:480,...style},children:[/*#__PURE__*/_jsx(\"input\",{type:\"email\",required:true,value:email,onChange:e=>{setEmail(e.target.value);if(state===\"error\"||state===\"success\"){setState(\"idle\");}},placeholder:placeholder,style:{flex:1,height:resolvedHeight,padding:\"0 20px\",fontSize,fontFamily:\"Inter, sans-serif\",fontWeight:400,color:inputText,backgroundColor:inputBg,border:`1px solid ${inputBorder}`,borderRadius,outline:\"none\",letterSpacing:\"-0.01em\",lineHeight:\"100%\",boxSizing:\"border-box\"}}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:state===\"loading\",style:{height:resolvedHeight,padding:\"0 24px\",fontSize,fontFamily:\"Inter, sans-serif\",fontWeight:500,color:buttonTextColor,backgroundColor:state===\"success\"?\"rgb(45, 45, 43)\":resolvedButtonColor,border:\"none\",borderRadius,cursor:state===\"loading\"?\"wait\":\"pointer\",opacity:state===\"loading\"?.7:1,transition:\"all 0.2s ease\",letterSpacing:\"-0.02em\",lineHeight:\"100%\",whiteSpace:\"nowrap\",boxSizing:\"border-box\"},children:labelText})]});}addPropertyControls(SubstackSubscribe,{substackUrl:{type:ControlType.String,title:\"Substack URL\",defaultValue:\"stefanvilar.substack.com\"},variant:{type:ControlType.Enum,title:\"Variant\",options:[\"primary\",\"secondary\"],optionTitles:[\"Primary (Terracotta)\",\"Secondary (Dark)\"],defaultValue:\"primary\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Join free\"},successText:{type:ControlType.String,title:\"Success Text\",defaultValue:\"You're in!\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Your email\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"rgb(196, 104, 74)\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},inputBg:{type:ControlType.Color,title:\"Input BG\",defaultValue:\"rgb(250, 250, 248)\"},inputBorder:{type:ControlType.Color,title:\"Input Border\",defaultValue:\"rgb(224, 220, 215)\"},height:{type:ControlType.Number,title:\"Height\",defaultValue:56,min:36,max:72},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:24},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:16,min:12,max:20}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SubstackSubscribe\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SubstackSubscribe.map"],"mappings":"+LAA4T,SAAwB,EAAkB,CAAC,aAAW,YAAY,cAAY,aAAa,cAAY,aAAa,cAAY,oBAAoB,kBAAgB,UAAU,UAAQ,qBAAqB,cAAY,qBAAqB,YAAU,kBAAkB,WAAS,GAAG,eAAa,GAAG,SAAO,GAAG,cAAY,2BAA2B,UAAQ,UAAU,SAAO,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,OAAO,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAO,EAAoB,IAAU,YAAY,kBAAkB,EAAkB,EAAe,IAAU,YAAY,GAAG,EAAa,EAAa,KAAM,IAAG,CAAC,KAAE,gBAAgB,CAAI,GAAC,GAAO,CAAC,EAAM,SAAS,IAAI,EAAQ,GAAS,UAAU,CAAC,GAAG,CAAC,MAAM,MAAM,WAAW,EAAY,wBAAwB,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,oCAAoC,CAAC,KAAK,IAAI,gBAAgB,CAAC,UAAU,WAAW,EAAY,GAAG,eAAe,GAAG,YAAY,WAAW,EAAY,GAAG,iBAAiB,EAAO,SAAS,KAAK,cAAc,GAAG,OAAO,QAAQ,iBAAiB,GAAG,6BAA6B,GAAS,QAAM,CAAC,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC,CAAC,EAAS,UAAU,CAAC,EAAS,GAAG,MAAO,CAAC,EAAS,QAAQ,IAAU,EAAU,IAAQ,UAAU,EAAY,IAAQ,QAAQ,YAAY,IAAQ,UAAU,MAAM,EAAW,OAAoB,EAAM,O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