{"version":3,"file":"useLeadCapture.CGyAiDIb.mjs","names":["useState","useCallback"],"sources":["https:/framerusercontent.com/modules/7WgTQHTAyxUxobEN0cKq/ZFvowTy3hd7gAJnl80vb/useLeadCapture.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{RenderTarget}from\"framer\";import{useCallback,useState}from\"react\";/**\n * FRANKLIN — SHARED LEAD CAPTURE\n *\n * Not a component: this file exports a hook and two presentation helpers, so\n * it stays out of Framer's insert menu.\n *\n * Extracted from ToolRequestForm.tsx so the site has one submit path rather\n * than one per form. Two forms that differ by a few details look like a bug,\n * not a variation — the same reasoning that produced VideoLightbox.tsx.\n *\n * Two destinations:\n *\n *  - HubSpot   Posts to the Forms API v3 submission endpoint. That endpoint\n *              is built for browser calls and answers CORS, so no server and\n *              no HubSpot script tag is needed. The `hubspotutk` cookie is\n *              passed along when it exists, which stitches the submission\n *              onto the visitor's existing tracking history instead of\n *              creating an orphan contact.\n *\n *              Franklin has ONE portal (26845829, EU-hosted on app-eu1), so\n *              that portal id is the baked-in default: an instance with an\n *              empty Portal ID still submits to the right place, and only a\n *              form id needs configuring per form. EU portals answer form\n *              submissions on api-eu1.hsforms.com — the global\n *              api.hsforms.com rejects them — which is why the EU host is\n *              the default too.\n *  - Webhook   The original three body formats, kept verbatim so existing\n *              instances behave exactly as before.\n *\n * `interestId` is the whole point of the thing: one form, many surfaces, and\n * every submission says which integration or feature it was for. Forms that\n * carry more than an email (signup) pass the rest through `values.fields`,\n * a name→value map that lands as additional contact properties. Unknown\n * property names are silently dropped by HubSpot, so a field that must be\n * stored needs its contact property to exist first.\n *\n * Every string the visitor can read is an option with an English default, so\n * two forms can be in different languages without either of them forking this\n * file.\n */export const INK=\"#232323\";/* Brand rule: one dark colour. The old brand green #29322D is retired and\n   BRAND now equals Ink, so form buttons, active states and focus borders\n   match every other dark button on the site. The export name stays so the\n   forms that import it keep working. */export const BRAND=\"#232323\";export const WHITE=\"#FFFFFF\";export const HAIRLINE=\"rgba(35, 35, 35, 0.1)\";export const EASE=\"cubic-bezier(0.65, 0, 0.35, 1)\";export const DURATION=\"0.42s\";/** Franklin's only HubSpot portal. See the header comment. */export const FRANKLIN_PORTAL_ID=\"26845829\";// Matches Framer's breakpoint ranges for this project, and FranklinButton.tsx.\nconst TABLET_MAX=1199;const PHONE_MAX=809;/**\n * Responsive size scale for a field row. Shared by every lead form so they\n * cannot drift apart. /integrations renders both forms on one page, so a row\n * height that differed between them would read as a bug.\n *\n * The row is 44px at every width, and that number is not arbitrary twice\n * over: 44 is the primary button height in the Franklin design system, and\n * 44 is the minimum comfortable touch target. It replaced an off-system 47.\n * Only padding and the button type step down on smaller screens.\n *\n * --trf-fs   the BUTTON label, which steps down with the breakpoints\n * --trf-ifs  the INPUT text, which does NOT. It is a separate variable, and\n *            it stays at 16px, because iOS Safari zooms the whole page in\n *            when a field smaller than 16px takes focus and does not zoom\n *            back out on blur. Two variables so a future type change to the\n *            button cannot quietly drag the input under the threshold with\n *            it. If 15px is ever wanted here, gate it on\n *            `(hover: hover) and (pointer: fine)` rather than on width: an\n *            iPhone in landscape is wider than the phone breakpoint.\n */export const FIELD_CSS=`\n.fk-trf {\n    --trf-h: 44px;\n    --trf-fpx: 18px;\n    --trf-bpx: 24px;\n    --trf-bax: 16px;\n    --trf-fs: 16px;\n    --trf-ifs: 16px;\n    --trf-lh: 19.327px;\n    --trf-ls: -0.32px;\n    --trf-glyph: 20.3774px;\n}\n@media (max-width: ${TABLET_MAX}px) {\n    .fk-trf {\n        --trf-fpx: 16px;\n        --trf-bpx: 20px;\n        --trf-bax: 14px;\n        --trf-fs: 15px;\n        --trf-lh: 18.12px;\n        --trf-ls: -0.3px;\n        --trf-glyph: 19px;\n    }\n}\n@media (max-width: ${PHONE_MAX}px) {\n    .fk-trf {\n        --trf-fpx: 14px;\n        --trf-bpx: 18px;\n        --trf-bax: 12px;\n        --trf-fs: 14px;\n        --trf-lh: 16.93px;\n        --trf-ls: -0.28px;\n        --trf-glyph: 18px;\n    }\n}\n`;export function ArrowGlyph({color}){return /*#__PURE__*/_jsx(\"svg\",{viewBox:\"0 0 20.3774 20.3774\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{width:\"var(--trf-glyph)\",height:\"var(--trf-glyph)\",flex:\"none\",display:\"block\"},children:/*#__PURE__*/_jsx(\"path\",{d:\"M17.6436 10.6395L11.9125 16.3706C11.793 16.4901 11.631 16.5572 11.462 16.5572C11.293 16.5572 11.1309 16.4901 11.0114 16.3706C10.892 16.2511 10.8248 16.0891 10.8248 15.9201C10.8248 15.7511 10.892 15.589 11.0114 15.4695L15.656 10.8257H3.18367C3.01478 10.8257 2.85281 10.7586 2.73339 10.6392C2.61397 10.5198 2.54688 10.3578 2.54688 10.1889C2.54688 10.0201 2.61397 9.85809 2.73339 9.73866C2.85281 9.61924 3.01478 9.55215 3.18367 9.55215H15.656L11.0114 4.90834C10.892 4.78886 10.8248 4.62679 10.8248 4.45781C10.8248 4.28883 10.892 4.12677 11.0114 4.00728C11.1309 3.88779 11.293 3.82067 11.462 3.82067C11.631 3.82067 11.793 3.88779 11.9125 4.00728L17.6436 9.73841C17.7028 9.79755 17.7498 9.86779 17.7819 9.94509C17.8139 10.0224 17.8304 10.1053 17.8304 10.1889C17.8304 10.2726 17.8139 10.3555 17.7819 10.4328C17.7498 10.5101 17.7028 10.5803 17.6436 10.6395Z\",fill:color})});}export const EMAIL_PATTERN=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;/* The hubspotutk cookie is set by HubSpot's own tracking script. It may not be\n   there at all — before consent, or when the script is not on the page — and\n   that is fine: the submission still lands, it just is not stitched onto an\n   existing visitor. */function readHubspotCookie(){if(typeof document===\"undefined\")return undefined;const match=document.cookie.match(/(?:^|;\\s*)hubspotutk=([^;]*)/);return match?decodeURIComponent(match[1]):undefined;}function pageContext(){if(typeof window===\"undefined\")return{pageUri:\"\",pageName:\"\"};return{pageUri:window.location.href,pageName:document.title};}async function submitToHubSpot(options,values){const{portalId,formId,apiHost=\"api-eu1.hsforms.com\",interestProperty=\"waitlist_interest\",sourceProperty=\"waitlist_source\",interestId,interestLabel,source,consentMode,consentText,subscriptionTypeId}=options;/* One company, one portal. An instance with an empty Portal ID means\n       \"the Franklin portal\", not \"no portal\". */const pid=(portalId??\"\").trim()||FRANKLIN_PORTAL_ID;if(!formId){throw new Error(\"HubSpot is selected but the form ID is missing.\");}/* objectTypeId 0-1 is the contact object. HubSpot accepts submissions\n       without it, but naming it keeps the payload unambiguous if a form ever\n       targets a different object. */const fields=[{objectTypeId:\"0-1\",name:\"email\",value:values.email}];/* Every custom name here has to exist as a contact property in HubSpot\n       first. HubSpot silently drops unknown ones, so a missing property\n       loses data without failing loudly. */if(interestId){fields.push({objectTypeId:\"0-1\",name:interestProperty,value:interestLabel?`${interestId}|${interestLabel}`:interestId});}if(source){fields.push({objectTypeId:\"0-1\",name:sourceProperty,value:source});}if(values.tool){fields.push({objectTypeId:\"0-1\",name:\"requested_tool\",value:values.tool});}if(values.fields){for(const[name,value]of Object.entries(values.fields)){const trimmed=(value??\"\").trim();if(!trimmed)continue;fields.push({objectTypeId:\"0-1\",name,value:trimmed});}}const{pageUri,pageName}=pageContext();const hutk=readHubspotCookie();const body={fields,context:{...hutk?{hutk}:{},pageUri,pageName}};/* Only sent in checkbox mode. The notice mode shows the line but claims no\n       explicit consent, so telling HubSpot otherwise would be a lie in a\n       compliance field. */if(consentMode===\"checkbox\"){body.legalConsentOptions={consent:{consentToProcess:true,text:consentText??\"\",...subscriptionTypeId?{communications:[{value:true,subscriptionTypeId:Number(subscriptionTypeId),text:consentText??\"\"}]}:{}}};}const response=await fetch(`https://${apiHost}/submissions/v3/integration/submit/${pid}/${formId}`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(body)});if(!response.ok){/* HubSpot answers a rejected submission with a readable reason.\n           Surface it in the console for whoever is wiring this up, but never\n           to the visitor. */let detail=`HubSpot returned ${response.status}`;try{const payload=await response.json();const first=payload?.errors?.[0];detail=first?.message??payload?.message??detail;}catch{/* Response was not JSON. The status line is all there is. */}throw new Error(detail);}}async function submitToWebhook(options,values){const{endpoint,payloadFormat=\"form\",fireAndForget=false,interestId,interestLabel,source}=options;if(!endpoint){throw new Error(\"No endpoint is configured for this form.\");}const payload={email:values.email,tool:values.tool??\"\",interestId:interestId??\"\",interestLabel:interestLabel??\"\",source:source??\"\",page:typeof window===\"undefined\"?\"\":window.location.href,submittedAt:new Date().toISOString(),...values.fields??{}};let body;const headers={};if(payloadFormat===\"form\"){body=new URLSearchParams(payload);}else if(payloadFormat===\"text\"){body=JSON.stringify(payload);headers[\"Content-Type\"]=\"text/plain;charset=utf-8\";}else{body=JSON.stringify(payload);headers[\"Content-Type\"]=\"application/json\";}const response=await fetch(endpoint,{method:\"POST\",mode:fireAndForget?\"no-cors\":\"cors\",headers,body});/* An opaque response has status 0 and cannot be inspected, so with fire\n       and forget the request leaving is all the confirmation there is. */if(!fireAndForget&&!response.ok){throw new Error(`Request failed with ${response.status}`);}}export function useLeadCapture(options){const[status,setStatus]=useState(\"idle\");const[message,setMessage]=useState(\"\");const reset=useCallback(()=>{setStatus(\"idle\");setMessage(\"\");},[]);const submit=useCallback(async values=>{if(status===\"submitting\")return;/* Nothing should leave the building from the editor. Say so out\n               loud, otherwise it looks like a button that does nothing. */if(RenderTarget.current()===RenderTarget.canvas){console.info(\"[useLeadCapture] Submissions are disabled on canvas. Test in Preview.\");return;}/* Honeypot: a bot fills every field it finds, a person never sees\n               this one. Answer as if it worked so the bot does not retry. */if(values.trap){setStatus(\"success\");setMessage(options.successMessage);return;}if(!EMAIL_PATTERN.test((values.email??\"\").trim())){setStatus(\"error\");setMessage(options.invalidEmailMessage??\"Please enter a valid email address.\");return;}if(options.consentMode===\"checkbox\"&&!values.consent){setStatus(\"error\");setMessage(options.consentRequiredMessage??\"Please accept the terms to continue.\");return;}setStatus(\"submitting\");setMessage(\"\");const clean={...values,email:values.email.trim(),tool:values.tool?.trim()};try{if(options.destination===\"hubspot\"){await submitToHubSpot(options,clean);}else{await submitToWebhook(options,clean);}setStatus(\"success\");setMessage(options.successMessage);}catch(error){console.error(\"[useLeadCapture]\",error);setStatus(\"error\");setMessage(options.errorMessage);}},[options,status]);return{status,message,submit,reset};}\nexport const __FramerMetadata__ = {\"exports\":{\"LeadCaptureOptions\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PayloadFormat\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"INK\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FIELD_CSS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"LeadDestination\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"WHITE\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"LeadStatus\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"EMAIL_PATTERN\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ArrowGlyph\":{\"type\":\"reactComponent\",\"name\":\"ArrowGlyph\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"DURATION\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HAIRLINE\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ConsentMode\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"LeadValues\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useLeadCapture\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FRANKLIN_PORTAL_ID\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"EASE\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"BRAND\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},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