{"version":3,"file":"CaseStudyLeadForm.DNg2rcD3.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/muzmGqcGAqSlJwFOmuAq/ze982b7RxRT6AbXqdIac/CaseStudyLeadForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";/**\n * Gated content lead form (case studies, thesis docs, insights).\n * Required fields: First name, Last name, Work email, Company.\n * On submit:\n *   1. Emails the submission via formsubmit.co to the address in props (alert).\n *      The email subject + an \"Asset downloaded\" line name the requested asset.\n *   2. If a HubSpot form GUID is set, also creates/updates a HubSpot contact\n *      via the public Forms submission API (no secret key required, safe for\n *      client-side use). The asset name is sent as the HubSpot pageName so the\n *      submission on the contact timeline shows what was downloaded. HubSpot\n *      submission is best-effort and never blocks the visitor's download.\n * On success, if a file is set the visitor gets an immediate download button.\n * The download is fetched as a blob so it saves with a friendly filename\n * (cross-origin CDN links otherwise ignore the download filename).\n *\n * The gated file resolves from \"Gated file (CMS)\" first — a File control you\n * can connect directly to a CMS Download File field — and falls back to the\n * text \"File URL\". So an instance can bind straight to the file field and\n * never needs a separate Download URL text field.\n *\n * Asset identity: uses \"Asset name\" if set, else the download filename, else\n * the page label. Set \"Asset name\" per instance for the cleanest label.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CaseStudyLeadForm(props){const{email,hubspotPortalId,hubspotFormGuid,heading,buttonLabel,successTitle,successBody,subjectLine,pageLabel,assetName,fileUrl:fileUrlProp,gatedFile,downloadLabel,downloadFileName,accentColor,textColor,style}=props;const asset=assetName&&String(assetName).trim()||downloadFileName||pageLabel;// Prefer a CMS file field connected via \"Gated file (CMS)\"; fall back to\n// the text \"File URL\". This lets an instance bind straight to a Download\n// File collection field instead of copying its URL into a text field.\nconst fileUrl=gatedFile&&String(gatedFile).trim()||fileUrlProp;const[firstName,setFirstName]=useState(\"\");const[lastName,setLastName]=useState(\"\");const[workEmail,setWorkEmail]=useState(\"\");const[company,setCompany]=useState(\"\");const[status,setStatus]=useState(\"idle\")// idle | submitting | success | error\n;const inputStyle={width:\"100%\",boxSizing:\"border-box\",padding:\"12px 14px\",borderRadius:8,border:\"1px solid rgba(6, 41, 34, 0.25)\",background:\"#FFFFFF\",color:\"#1C1D20\",fontSize:15,fontFamily:\"Inter, sans-serif\",outline:\"none\"};const labelStyle={fontSize:13,fontWeight:600,color:textColor,fontFamily:\"Inter, sans-serif\",marginBottom:6,display:\"block\"};// Best-effort HubSpot contact create/update via the public Forms API.\n// Uses portalId + formGuid only (no private token), safe for client side.\nasync function submitToHubSpot(){if(!hubspotPortalId||!hubspotFormGuid)return;try{await fetch(\"https://api.hsforms.com/submissions/v3/integration/submit/\"+encodeURIComponent(hubspotPortalId)+\"/\"+encodeURIComponent(hubspotFormGuid),{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({fields:[{name:\"email\",value:workEmail},{name:\"firstname\",value:firstName},{name:\"lastname\",value:lastName},{name:\"company\",value:company},{name:\"last_asset_downloaded\",value:asset}],context:{pageUri:typeof window!==\"undefined\"?window.location.href:pageLabel,pageName:asset}})});}catch(err){// Non-blocking: the email alert above is the source of truth.\n}}async function handleSubmit(e){e.preventDefault();if(!firstName||!lastName||!workEmail||!company)return;setStatus(\"submitting\");try{const res=await fetch(\"https://formsubmit.co/ajax/\"+encodeURIComponent(email),{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Accept:\"application/json\"},body:JSON.stringify({_subject:subjectLine+(asset?\" — \"+asset:\"\"),\"First name\":firstName,\"Last name\":lastName,\"Work email\":workEmail,Company:company,\"Asset downloaded\":asset,Page:pageLabel})});if(!res.ok)throw new Error(\"Request failed\");await submitToHubSpot();setStatus(\"success\");}catch(err){setStatus(\"error\");}}async function handleDownload(e){// Fetch as a blob so the file saves with a friendly name.\n// Falls back to opening the URL directly if the fetch is blocked.\ne.preventDefault();const fname=downloadFileName||\"download.pdf\";try{const r=await fetch(fileUrl);if(!r.ok)throw new Error(\"fetch failed\");const b=await r.blob();const u=URL.createObjectURL(b);const a=document.createElement(\"a\");a.href=u;a.download=fname;document.body.appendChild(a);a.click();a.remove();setTimeout(()=>URL.revokeObjectURL(u),2e3);}catch(err){window.open(fileUrl,\"_blank\");}}const fieldRowStyle={display:\"flex\",gap:12,width:\"100%\"};if(status===\"success\"){return /*#__PURE__*/_jsxs(\"div\",{style:{...style,background:\"#FFFFFF\",borderRadius:12,padding:32,fontFamily:\"Inter, sans-serif\",display:\"flex\",flexDirection:\"column\",gap:12,justifyContent:\"center\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:18,fontWeight:700,color:textColor},children:successTitle}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:14,lineHeight:1.5,color:\"#1C1D20\"},children:fileUrl?\"Your copy is ready. Download it below. We've also logged your request.\":successBody}),fileUrl&&/*#__PURE__*/_jsx(\"a\",{href:fileUrl,onClick:handleDownload,target:\"_blank\",rel:\"noopener noreferrer\",download:downloadFileName,style:{marginTop:4,padding:\"13px 20px\",borderRadius:8,background:accentColor,color:\"#FFFFFF\",fontSize:15,fontWeight:600,fontFamily:\"Inter, sans-serif\",textAlign:\"center\",textDecoration:\"none\",cursor:\"pointer\"},children:downloadLabel})]});}return /*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{...style,background:\"#FFFFFF\",borderRadius:12,padding:32,fontFamily:\"Inter, sans-serif\",display:\"flex\",flexDirection:\"column\",gap:16,boxSizing:\"border-box\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:16,fontWeight:700,color:textColor},children:heading}),/*#__PURE__*/_jsxs(\"div\",{style:fieldRowStyle,children:[/*#__PURE__*/_jsxs(\"div\",{style:{flex:1},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"First name\"}),/*#__PURE__*/_jsx(\"input\",{style:inputStyle,type:\"text\",value:firstName,onChange:e=>setFirstName(e.target.value),placeholder:\"Jane\",required:true})]}),/*#__PURE__*/_jsxs(\"div\",{style:{flex:1},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Last name\"}),/*#__PURE__*/_jsx(\"input\",{style:inputStyle,type:\"text\",value:lastName,onChange:e=>setLastName(e.target.value),placeholder:\"Smith\",required:true})]})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Work email\"}),/*#__PURE__*/_jsx(\"input\",{style:inputStyle,type:\"email\",value:workEmail,onChange:e=>setWorkEmail(e.target.value),placeholder:\"jane@yourcompany.com\",required:true})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Company\"}),/*#__PURE__*/_jsx(\"input\",{style:inputStyle,type:\"text\",value:company,onChange:e=>setCompany(e.target.value),placeholder:\"Your software company\",required:true})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"submitting\",style:{marginTop:4,padding:\"14px 20px\",borderRadius:8,border:\"none\",cursor:\"pointer\",background:accentColor,color:\"#FFFFFF\",fontSize:15,fontWeight:600,fontFamily:\"Inter, sans-serif\",opacity:status===\"submitting\"?.7:1},children:status===\"submitting\"?\"Sending...\":buttonLabel}),status===\"error\"&&/*#__PURE__*/_jsx(\"div\",{style:{fontSize:13,color:\"#B3261E\"},children:\"Something went wrong. Please try again, or email us directly.\"})]});}CaseStudyLeadForm.defaultProps={email:\"blake.rouse@valpay.com\",hubspotPortalId:\"342075271\",hubspotFormGuid:\"\",heading:\"Get the case study\",buttonLabel:\"Send me the case study\",successTitle:\"Request received\",successBody:\"Thanks, it's on its way to your inbox.\",subjectLine:\"Gated content request (ValPay website)\",pageLabel:\"Unknown page\",assetName:\"\",fileUrl:\"https://framerusercontent.com/assets/v98NereBgMEEePp1m8uks4qzV8Q.pdf\",gatedFile:\"\",downloadLabel:\"Download the paper\",downloadFileName:\"Why ValPay 2026.pdf\",accentColor:\"#0F705F\",textColor:\"#062922\"};addPropertyControls(CaseStudyLeadForm,{email:{type:ControlType.String,title:\"Notify email\"},hubspotPortalId:{type:ControlType.String,title:\"HubSpot portal ID\"},hubspotFormGuid:{type:ControlType.String,title:\"HubSpot form GUID\"},heading:{type:ControlType.String,title:\"Form heading\"},buttonLabel:{type:ControlType.String,title:\"Button label\"},successTitle:{type:ControlType.String,title:\"Success title\"},successBody:{type:ControlType.String,title:\"Success body\"},subjectLine:{type:ControlType.String,title:\"Email subject\"},pageLabel:{type:ControlType.String,title:\"Page label\"},assetName:{type:ControlType.String,title:\"Asset name\"},gatedFile:{type:ControlType.File,title:\"Gated file (CMS)\",allowedFileTypes:[\"pdf\",\"pptx\",\"mp4\"]},fileUrl:{type:ControlType.String,title:\"File URL (fallback)\"},downloadLabel:{type:ControlType.String,title:\"Download label\"},downloadFileName:{type:ControlType.String,title:\"Download filename\"},accentColor:{type:ControlType.Color,title:\"Button color\"},textColor:{type:ControlType.Color,title:\"Text color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CaseStudyLeadForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CaseStudyLeadForm.map"],"mappings":"+LAyBG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,QAAM,kBAAgB,kBAAgB,UAAQ,cAAY,eAAa,cAAY,cAAY,YAAU,YAAU,QAAQ,EAAY,YAAU,gBAAc,mBAAiB,cAAY,YAAU,SAAO,EAAY,EAAM,GAAW,OAAO,CAAS,CAAC,CAAC,KAAK,GAAG,GAAkB,EAG1U,EAAQ,GAAW,OAAO,CAAS,CAAC,CAAC,KAAK,GAAG,EAAiB,CAAC,EAAU,GAAcA,EAAS,EAAE,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAE,EAAO,CAAC,EAAU,G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