{"version":3,"file":"Substack.hZIuCD3B.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/7i2Z58e7QGSkSnOhgkwX/esiO1AFZ7tCcOxDENN5C/Substack.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function SubstackSignup({workerUrl,publicationName,labelText,placeholder,successMessage,backgroundColor,borderColor,textColor,placeholderColor,gradientStart,gradientEnd,successColor,labelFont,inputFont,inputPadding,arrowSize,arrowPadding}){const[email,setEmail]=useState(\"\");const[status,setStatus]=useState(\"idle\");const[message,setMessage]=useState(\"\");const[isFocused,setIsFocused]=useState(false);const[isValid,setIsValid]=useState(false);const[showSuccessAnimation,setShowSuccessAnimation]=useState(false);// Email validation\nconst validateEmail=email=>/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);useEffect(()=>{setIsValid(validateEmail(email));},[email]);// Calculate progress\nconst getProgress=()=>{if(showSuccessAnimation)return 100;if(!email)return 0;if(isValid)return 100;const hasAt=email.includes(\"@\");const hasDot=email.includes(\".\");if(hasAt&&hasDot)return 75;if(hasAt)return 50;return 25;};const handleSubmit=async e=>{e.preventDefault();if(!email||!isValid)return;setStatus(\"loading\");try{const response=await fetch(workerUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({email,publication:publicationName})});const data=await response.json();if(data.success){setStatus(\"success\");setMessage(data.message||successMessage);setShowSuccessAnimation(true);setTimeout(()=>{setShowSuccessAnimation(false);setEmail(\"\");setIsValid(false);setStatus(\"idle\");},1500);}else{setStatus(\"error\");setMessage(data.error||\"Subscription failed\");setTimeout(()=>{setStatus(\"idle\");setMessage(\"\");},5e3);}}catch{setStatus(\"error\");setMessage(\"Network error. Please try again.\");setTimeout(()=>{setStatus(\"idle\");setMessage(\"\");},5e3);}};const progress=getProgress();const showProgress=isFocused||email||showSuccessAnimation;return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    @keyframes substackSpinner {\n                        from { transform: rotate(0deg); }\n                        to { transform: rotate(360deg); }\n                    }\n                    .substack-signup-input::placeholder {\n                        color: ${placeholderColor};\n                        opacity: 1;\n                        white-space: nowrap;\n                        overflow: hidden;\n                        text-overflow: ellipsis;\n                    }\n                `}),/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",fontFamily:labelFont},children:[labelText&&/*#__PURE__*/_jsx(\"div\",{style:{...labelFont,color:textColor,marginBottom:16,textAlign:\"center\",marginLeft:\"12%\",marginRight:\"12%\",textWrap:\"balance\"},children:labelText}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{position:\"relative\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",background:backgroundColor,border:`1px solid ${showSuccessAnimation?successColor:borderColor}`,overflow:\"visible\",transition:\"border-color 0.5s ease\"},children:[/*#__PURE__*/_jsx(\"input\",{type:\"email\",className:\"substack-signup-input\",value:email,onChange:e=>setEmail(e.target.value),onFocus:()=>setIsFocused(true),onBlur:()=>setIsFocused(false),placeholder:placeholder,disabled:status===\"loading\"||showSuccessAnimation,style:{...inputFont,color:textColor,width:\"100%\",padding:inputPadding,border:\"none\",outline:\"none\",background:\"transparent\",WebkitAppearance:\"none\",textOverflow:\"ellipsis\",whiteSpace:\"nowrap\",overflow:\"hidden\"}}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"loading\"||!isValid||showSuccessAnimation,style:{position:\"absolute\",right:8,top:\"50%\",transform:\"translateY(-50%)\",background:\"none\",border:\"none\",padding:arrowPadding,cursor:isValid&&!showSuccessAnimation?\"pointer\":\"default\",opacity:isValid||showSuccessAnimation?1:.3,transition:\"all 0.5s ease\",fontSize:arrowSize,display:\"flex\",color:showSuccessAnimation?successColor:textColor,alignItems:\"center\",justifyContent:\"center\"},children:status===\"loading\"?// Loading spinner\n/*#__PURE__*/_jsxs(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{animation:\"substackSpinner 1s linear infinite\"},children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:\"currentColor\",strokeWidth:\"3\",strokeLinecap:\"round\",strokeDasharray:\"31.4 31.4\",transform:\"rotate(-90 12 12)\",opacity:\"0.25\"}),/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:\"currentColor\",strokeWidth:\"3\",strokeLinecap:\"round\",strokeDasharray:\"15.7 47.1\",transform:\"rotate(-90 12 12)\"})]}):showSuccessAnimation?// Success checkmark\n/*#__PURE__*/_jsx(\"svg\",{width:arrowSize,height:arrowSize*.8,viewBox:\"0 0 21 17\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M19 2L7 14L2 9\",stroke:\"currentColor\",strokeWidth:\"3\"})}):// Arrow\n/*#__PURE__*/_jsx(\"svg\",{width:arrowSize+4,height:arrowSize,viewBox:\"0 0 28 25\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M25.127 10.0049L25.1328 10L27.2539 12.1211L27.248 12.126L27.2539 12.1328L25.1328 14.2539L25.127 14.248L15.2334 24.1416L13.1123 22.0205L21.6328 13.5H0V10.5H21.3789L13.1113 2.23242L15.2334 0.111328L25.127 10.0049Z\",fill:\"currentColor\"})})})]}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",bottom:0,left:0,width:\"100%\",height:4,background:showSuccessAnimation?successColor:borderColor,transition:\"background 0.5s ease, transform 0.3s ease\",transformOrigin:\"bottom\",transform:showProgress?\"scaleY(1)\":\"scaleY(0.25)\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:0,top:0,height:\"100%\",width:showProgress?`${progress}%`:\"0%\",background:showSuccessAnimation?successColor:`linear-gradient(90deg, ${gradientStart} 0%, ${gradientEnd} 100%)`,transition:\"width 0.3s ease-out\"}})})]}),message&&/*#__PURE__*/_jsx(\"div\",{style:{marginTop:16,fontSize:\"1rem\",color:status===\"error\"?\"#f02f2f\":textColor,transition:\"opacity 0.3s ease\"},children:message})]})]});}// Add Framer property controls\naddPropertyControls(SubstackSignup,{inputFont:{type:ControlType.Font,title:\"Input Font\",controls:\"extended\"},labelFont:{type:ControlType.Font,title:\"Label Font\",controls:\"extended\"},inputPadding:{type:ControlType.Padding,defaultValue:\"24px 56px 24px 29px\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:24,min:10,max:256,unit:\"px\"},arrowPadding:{type:ControlType.Padding,defaultValue:\"12px\"},workerUrl:{type:ControlType.String,title:\"Worker URL\",defaultValue:\"https://substackthing.benellisgold.workers.dev/\"},publicationName:{type:ControlType.String,title:\"Publication\",defaultValue:\"designerfund\"},labelText:{type:ControlType.String,title:\"Label\",defaultValue:\"\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"lauren.ipsum@gmail.com\"},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Check your email to finish subscribing!\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#1f2a47\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000c2d\"},placeholderColor:{type:ControlType.Color,title:\"Placeholder\",defaultValue:\"#999999\"},gradientStart:{type:ControlType.Color,title:\"Gradient Start\",defaultValue:\"#20de86\"},gradientEnd:{type:ControlType.Color,title:\"Gradient End\",defaultValue:\"#4bd1cc\"},successColor:{type:ControlType.Color,title:\"Success Color\",defaultValue:\"#20de86\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SubstackSignup\",\"slots\":[],\"annotations\":{\"framerContractVers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