{"version":3,"file":"EmailCaptureV2.BAg9L3dC.mjs","names":["useRef","useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/vVKCtBAK8arggCQaVQsQ/rPw6Vmv6DdRwmZKDPRVN/EmailCaptureV2.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// v2.6 (14SEP26): TURNSTILE MADE FUNCTIONAL — the widget can now be seen and\n//   completed, and the token wait is realistic.\n//   ROOT CAUSE (found 14SEP26 via forms-hub production logs): every\n//   submission reaching the worker carried NO turnstileToken. Zero\n//   \"Turnstile verified OK\" lines had ever been logged. Two faults, both here:\n//   (1) `.ec-turnstile` was `height:0;overflow:hidden`, so when Cloudflare\n//       decided a visitor needed an interactive challenge, the checkbox was\n//       rendered into a clipped 0px box. No visitor on any device could ever\n//       complete it — the challenge could only time out. The container is now\n//       laid out normally and collapses only while genuinely empty, so the\n//       widget appears if and only if Cloudflare asks for interaction\n//       (appearance:\"interaction-only\" is unchanged — silent passes stay\n//       invisible, exactly as before).\n//   (2) The 2000ms cap could not cover script fetch + render + challenge on a\n//       mobile connection. Raised to 8000ms. The submit still proceeds on\n//       timeout, so the fail-open guarantee below is untouched.\n//   NOTE: forms-hub TURNSTILE_ENFORCE was set to \"false\" on 14SEP26 because\n//   enforcement had been rejecting 100% of submissions. Do NOT set it back to\n//   \"true\" until production logs show \"Turnstile verified OK\".\n// v2.5 (30JUL26): TURNSTILE → EXECUTE-ON-SUBMIT (structural fix for visible\n//   challenge + failure loop observed on flagged test sessions).\n//   No widget renders on the page — ever. On submit, we silently request a\n//   Turnstile verdict (execution:\"execute\") with a 2s cap, then submit\n//   REGARDLESS of the outcome. Token present → server verifies it. Token\n//   absent/failed → submission proceeds on honeypot + server-side checks.\n//   A visitor can never see a Cloudflare box and a lead can never be lost\n//   to a failed challenge. Widget container stays 0-height/hidden.\n//   [v2.6 NOTE: the \"never see a box\" goal is what broke verification\n//   outright. A visitor may now see a checkbox in the minority of sessions\n//   Cloudflare flags. The fail-open guarantee — a lead is never lost to a\n//   failed or skipped challenge — is fully retained.]\n// v2.4 (30JUL26): retry + refresh-expired hardening (superseded by v2.5).\n// v2.3 (30JUL26): interaction-only + lazy script load on scroll-into-view\n//   (script lazy-load retained).\n// v2.2 (30JUL26): @import removed; <style> → dangerouslySetInnerHTML; aria.\n// v2.1 (28JUL26): TURNSTILE embedded; token → forms-hub v1.3.0+; honeypot kept.\nconst FORMS_HUB=\"https://forms-hub.greg-dameron.workers.dev\";const TURNSTILE_SITE_KEY=\"0x4AAAAAAEAKGNV0V27o-3gW\";const TURNSTILE_TOKEN_CAP_MS=8e3;const CSS=`\n.ec-section{position:relative;z-index:1;padding:80px 32px;font-family:'Montserrat',sans-serif}\n.ec-inner{max-width:640px;margin:0 auto;text-align:center}\n.ec-label{font-size:11px;font-weight:700;letter-spacing:3px;text-transform:uppercase;color:#06B6D4;margin-bottom:12px;display:flex;align-items:center;gap:12px;justify-content:center}\n.ec-dash{width:24px;height:1px;background:#06B6D4}\n.ec-title{font-size:clamp(24px,4vw,32px);font-weight:800;color:#fff;margin-bottom:12px;letter-spacing:-.3px}\n.ec-desc{font-size:14px;color:#D1D3DB;line-height:1.8;margin-bottom:28px;max-width:480px;margin-left:auto;margin-right:auto}\n.ec-form{display:flex;gap:10px;max-width:480px;margin:0 auto}\n.ec-input{flex:1;padding:14px 16px;background:rgba(10,26,47,0.6);border:1px solid rgba(30,58,138,0.22);border-radius:8px;color:#fff;font-family:'Montserrat',sans-serif;font-size:16px;outline:none;-webkit-appearance:none}\n.ec-input:focus{border-color:#06B6D4}\n.ec-input::placeholder{color:#4A5568}\n.ec-btn{padding:14px 28px;background:linear-gradient(135deg,#1E3A8A,#2548A8);color:#fff;font-family:'Montserrat',sans-serif;font-size:13px;font-weight:700;letter-spacing:.5px;text-transform:uppercase;border-radius:8px;border:none;cursor:pointer;transition:all .2s;box-shadow:0 4px 16px rgba(30,58,138,0.35);white-space:nowrap}\n.ec-btn:hover{box-shadow:0 6px 24px rgba(30,58,138,0.5);transform:translateY(-1px)}\n.ec-btn:disabled{opacity:.5;cursor:not-allowed;transform:none}\n.ec-success{padding:20px;background:rgba(0,135,102,0.1);border:1px solid rgba(0,135,102,0.3);border-radius:10px;max-width:480px;margin:0 auto}\n.ec-success h4{font-size:15px;font-weight:700;color:#06B6D4;margin-bottom:4px;font-family:'Montserrat',sans-serif}\n.ec-success p{font-size:13px;color:#D1D3DB;line-height:1.7;font-family:'Montserrat',sans-serif}\n.ec-error{color:#F97316;font-size:12px;margin-top:8px}\n.ec-note{font-size:11px;color:#4A5568;margin-top:12px}\n.ec-hp{position:absolute;left:-9999px;top:-9999px;opacity:0;height:0;width:0;overflow:hidden}\n/* v2.6: laid out normally so an interactive challenge is actually visible and\n   clickable. Collapses while empty, so silent passes show nothing at all. */\n.ec-turnstile{display:flex;justify-content:center}\n.ec-turnstile:empty{display:none}\n\n@media(max-width:600px){\n  .ec-section{padding:56px 16px}\n  .ec-form{flex-direction:column}\n  .ec-btn{width:100%;padding:16px}\n  .ec-input{font-size:16px}\n}\n`;function loadTurnstileScript(){return new Promise(resolve=>{if(typeof window===\"undefined\")return resolve();if(window.turnstile)return resolve();const existing=document.querySelector('script[src*=\"challenges.cloudflare.com/turnstile\"]');if(existing){existing.addEventListener(\"load\",()=>resolve());if(window.turnstile)resolve();return;}const s=document.createElement(\"script\");s.src=\"https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit\";s.async=true;s.defer=true;s.onload=()=>resolve();document.head.appendChild(s);});}export default function EmailCaptureV2(props){const{label=\"Early Access\",title=\"Be First to Experience GovHub\",desc=\"Join the waitlist for early access. We'll notify you when GovHub launches — with priority onboarding for early subscribers.\",buttonText=\"Join Waitlist\",note=\"No spam. Unsubscribe anytime.\",bgColor=\"#0E1F3D\",source=\"home-page-footer\"}=props;const sectionRef=useRef(null);const tsRef=useRef(null);const tsWidgetId=useRef(null);const[tsReady,setTsReady]=useState(false);const[email,setEmail]=useState(\"\");const[name,setName]=useState(\"\");const[gotcha,setGotcha]=useState(\"\");const[submitting,setSubmitting]=useState(false);const[submitted,setSubmitted]=useState(false);const[error,setError]=useState(\"\");// Load the Turnstile script only when the form approaches the viewport\nuseEffect(()=>{if(typeof window===\"undefined\")return;const el=sectionRef.current;if(!el||!(\"IntersectionObserver\"in window)){setTsReady(true);return;}const io=new IntersectionObserver(entries=>entries.forEach(e=>{if(e.isIntersecting){setTsReady(true);io.disconnect();}}),{rootMargin:\"400px 0px\"});io.observe(el);return()=>io.disconnect();},[]);// Pre-warm the script + render an execute-mode widget. appearance\n// \"interaction-only\" keeps it invisible unless Cloudflare needs a click.\nuseEffect(()=>{if(submitted||!tsReady)return;let cancelled=false;loadTurnstileScript().then(()=>{if(cancelled||!window.turnstile||!tsRef.current)return;if(tsWidgetId.current!==null)return;try{tsWidgetId.current=window.turnstile.render(tsRef.current,{sitekey:TURNSTILE_SITE_KEY,execution:\"execute\",appearance:\"interaction-only\"});}catch(e){}});return()=>{cancelled=true;};},[submitted,tsReady]);// Attempt a token for up to `capMs`; resolve \"\" on timeout or error so the\n// submission always proceeds. v2.6: cap raised to 8s — 2s could not cover\n// script fetch + render + challenge on mobile, so the token was always \"\".\nconst getTokenSilently=capMs=>{return new Promise(resolve=>{let settled=false;const finish=t=>{if(!settled){settled=true;resolve(t);}};const timer=setTimeout(()=>finish(\"\"),capMs);try{if(!window.turnstile||tsWidgetId.current===null){clearTimeout(timer);finish(\"\");return;}window.turnstile.execute(tsRef.current,{sitekey:TURNSTILE_SITE_KEY,callback:token=>{clearTimeout(timer);finish(token);},\"error-callback\":()=>{clearTimeout(timer);finish(\"\");}});}catch(e){clearTimeout(timer);finish(\"\");}});};const handleSubmit=async e=>{e.preventDefault();if(!email.trim())return;setSubmitting(true);setError(\"\");// Verdict attempt — 8s cap, never blocks the submission\nlet token=\"\";try{token=await getTokenSilently(TURNSTILE_TOKEN_CAP_MS);}catch(e){token=\"\";}try{const res=await fetch(FORMS_HUB,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({formType:\"newsletter\",email,name:name||undefined,source,turnstileToken:token||undefined,_gotcha:gotcha})});const json=await res.json().catch(()=>({ok:false}));if(json.ok){setSubmitted(true);}else{setError(json.error||\"Something went wrong. Please try again.\");}}catch{setError(\"Network error. Please try again.\");}setSubmitting(false);};return /*#__PURE__*/_jsxs(\"div\",{ref:sectionRef,style:{width:\"100%\",position:\"relative\"},children:[/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:CSS}}),/*#__PURE__*/_jsx(\"section\",{className:\"ec-section\",style:{background:bgColor},children:/*#__PURE__*/_jsxs(\"div\",{className:\"ec-inner\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"ec-label\",children:[/*#__PURE__*/_jsx(\"span\",{className:\"ec-dash\"}),label,/*#__PURE__*/_jsx(\"span\",{className:\"ec-dash\"})]}),/*#__PURE__*/_jsx(\"h2\",{className:\"ec-title\",children:title}),/*#__PURE__*/_jsx(\"p\",{className:\"ec-desc\",children:desc}),!submitted?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs(\"form\",{className:\"ec-form\",onSubmit:handleSubmit,style:{flexDirection:\"column\",gap:10},children:[/*#__PURE__*/_jsx(\"input\",{type:\"text\",name:\"_gotcha\",value:gotcha,onChange:e=>setGotcha(e.target.value),className:\"ec-hp\",tabIndex:-1,autoComplete:\"off\",\"aria-hidden\":\"true\",\"aria-label\":\"Leave this field empty\"}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",gap:10},children:[/*#__PURE__*/_jsx(\"input\",{className:\"ec-input\",type:\"email\",required:true,placeholder:\"your@email.com\",\"aria-label\":\"Email address\",value:email,onChange:e=>setEmail(e.target.value)}),/*#__PURE__*/_jsx(\"button\",{className:\"ec-btn\",type:\"submit\",disabled:submitting,children:submitting?\"...\":buttonText})]}),/*#__PURE__*/_jsx(\"div\",{ref:tsRef,className:\"ec-turnstile\"})]}),error&&/*#__PURE__*/_jsx(\"div\",{className:\"ec-error\",children:error}),/*#__PURE__*/_jsx(\"div\",{className:\"ec-note\",children:note})]}):/*#__PURE__*/_jsxs(\"div\",{className:\"ec-success\",children:[/*#__PURE__*/_jsx(\"h4\",{children:\"You're on the List!\"}),/*#__PURE__*/_jsx(\"p\",{children:\"Check your inbox for a welcome email from newsletter@send.amerix.ai. We'll be in touch when there's something worth sharing.\"})]})]})})]});}addPropertyControls(EmailCaptureV2,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Early Access\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Be First to Experience GovHub\"},desc:{type:ControlType.String,title:\"Description\",defaultValue:\"Join the waitlist for early access. We'll notify you when GovHub launches — with priority onboarding for early subscribers.\"},buttonText:{type:ControlType.String,title:\"Button\",defaultValue:\"Join Waitlist\"},note:{type:ControlType.String,title:\"Note\",defaultValue:\"No spam. Unsubscribe anytime.\"},bgColor:{type:ControlType.String,title:\"Background\",defaultValue:\"#0E1F3D\"},source:{type:ControlType.String,title:\"Source Tag\",defaultValue:\"home-page-footer\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmailCaptureV2\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmailCaptureV2.map"],"mappings":"oNAmEE,SAAS,GAAqB,CAAC,OAAO,IAAI,QAAQ,GAAS,CAAiD,GAAtC,IAAS,QAAgC,EAAO,UAAU,OAAO,EAAQ,EAAE,IAAM,EAAS,SAAS,cAAc,oDAAoD,EAAE,GAAG,EAAS,CAAC,EAAS,iBAAiB,WAAW,EAAQ,CAAC,EAAK,EAAO,WAAU,EAAQ,EAAE,MAAO,CAAC,IAAM,EAAE,SAAS,cAAc,QAAQ,EAAE,EAAE,IAAI,wEAAwE,EAAE,MAAM,GAAK,E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