{"version":3,"file":"HubSpotEmbed.BYe5wWSc.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/4LFKFokNw2Cd2auG0MvM/7YBgDmtK8mjR8rBtx8PV/HubSpotEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const PREFILL_KEY=\"hs_email_prefilled\";/**\n * Renders a HubSpot form inside an iframe, with automatic email\n * pre-fill from URL query parameters. Uses sessionStorage to ensure\n * the email is only pre-filled once (not on refresh).\n * On refresh, actively clears the email field.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function HubSpotEmbed(props){const{portalId=\"244134603\",formId=\"c4a5f2ae-01f1-4e4a-9acf-957006d6fbd1\",region=\"na2\",emailParam=\"email\"}=props;const iframeRef=useRef(null);// Determine if this is a fresh redirect (should pre-fill) or a refresh (should clear)\nconst{emailValue,shouldClear}=useMemo(()=>{try{const params=new URLSearchParams(window.location.search);const email=params.get(emailParam)||\"\";if(!email){// No email param at all — check if this is a refresh after we already consumed it\nconst alreadyUsed=sessionStorage.getItem(PREFILL_KEY);if(alreadyUsed){return{emailValue:\"\",shouldClear:true};}return{emailValue:\"\",shouldClear:false};}// Has email param — check if already used\nconst alreadyUsed=sessionStorage.getItem(PREFILL_KEY);if(alreadyUsed){return{emailValue:\"\",shouldClear:true};}// Fresh redirect — mark as used\nsessionStorage.setItem(PREFILL_KEY,\"true\");return{emailValue:email,shouldClear:false};}catch{return{emailValue:\"\",shouldClear:false};}},[emailParam]);// Clear the sessionStorage flag when navigating away\nuseEffect(()=>{return()=>{setTimeout(()=>{if(!window.location.pathname.includes(\"request-demo\")){sessionStorage.removeItem(PREFILL_KEY);}},1e3);};},[]);// Build the iframe HTML\nconst iframeHtml=useMemo(()=>{const escapedEmail=emailValue.replace(/\\\\/g,\"\\\\\\\\\").replace(/'/g,\"\\\\'\").replace(/\"/g,'\\\\\"');// If shouldClear, we inject JS to actively blank out the email field\nconst clearScript=shouldClear?`\n      function tryClear() {\n        var input = document.querySelector('input[name=\"email\"]');\n        if (input) {\n          input.value = '';\n          input.setAttribute('value', '');\n          input.dispatchEvent(new Event('input', { bubbles: true }));\n          input.dispatchEvent(new Event('change', { bubbles: true }));\n          return true;\n        }\n        return false;\n      }\n      if (!tryClear()) {\n        var clearAttempts = 0;\n        var clearInterval_ = setInterval(function() {\n          clearAttempts++;\n          if (tryClear() || clearAttempts > 30) clearInterval(clearInterval_);\n        }, 300);\n      }`:\"\";const prefillScript=emailValue?`\n      function tryFill() {\n        var input = document.querySelector('input[name=\"email\"]');\n        if (input) {\n          input.value = prefillEmail;\n          input.dispatchEvent(new Event('input', { bubbles: true }));\n          input.dispatchEvent(new Event('change', { bubbles: true }));\n          return true;\n        }\n        return false;\n      }\n      if (!tryFill()) {\n        var attempts = 0;\n        var interval = setInterval(function() {\n          attempts++;\n          if (tryFill() || attempts > 30) clearInterval(interval);\n        }, 300);\n      }`:\"\";return`<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<style>\n  body { margin: 0; padding: 0; background: transparent; }\n  .hs-form, .hs-form iframe, .hbspt-form, .hbspt-form form {\n    width: 100% !important; max-width: none !important;\n  }\n  @media (min-width: 720px) {\n    .hs-form .hs-form-field {\n      width: calc(50% - 10px) !important; display: inline-block !important;\n      vertical-align: top !important; margin-right: 20px !important;\n    }\n    .hs-form .hs-form-field:nth-child(2n) { margin-right: 0 !important; }\n    .hs-form .hs-form-field.full-width,\n    .hs-form .hs-form-field.hs-fieldtype-textarea,\n    .hs-form .hs-form-field.hs-fieldtype-select {\n      width: 100% !important; margin-right: 0 !important; display: block !important;\n    }\n  }\n  .hs-form .input, .hs-form input, .hs-form select, .hs-form textarea {\n    width: 100% !important; box-sizing: border-box !important;\n  }\n</style>\n</head>\n<body>\n<div id=\"hs-form-container\"></div>\n<script src=\"https://js-na2.hsforms.net/forms/embed/v2.js\" charset=\"utf-8\"></script>\n<script>\n  var prefillEmail = '${escapedEmail}';\n  hbspt.forms.create({\n    region: '${region}',\n    portalId: '${portalId}',\n    formId: '${formId}',\n    target: '#hs-form-container',\n    onFormReady: function() {\n      ${prefillScript}\n      ${clearScript}\n    }\n  });\n</script>\n</body>\n</html>`;},[portalId,formId,region,emailValue,shouldClear]);useEffect(()=>{const iframe=iframeRef.current;if(!iframe)return;const doc=iframe.contentDocument||iframe.contentWindow?.document;if(doc){doc.open();doc.write(iframeHtml);doc.close();}},[iframeHtml]);return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,style:{width:\"100%\",height:\"100%\",border:\"none\",background:\"transparent\"},title:\"HubSpot Form\"});}addPropertyControls(HubSpotEmbed,{portalId:{type:ControlType.String,title:\"Portal ID\",defaultValue:\"244134603\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"c4a5f2ae-01f1-4e4a-9acf-957006d6fbd1\"},region:{type:ControlType.String,title:\"Region\",defaultValue:\"na2\"},emailParam:{type:ControlType.String,title:\"Email Param\",defaultValue:\"email\",description:\"URL query parameter name to read the email from\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotEmbed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubSpotEmbed.map"],"mappings":"kMAQG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,WAAS,YAAY,SAAO,uCAAuC,SAAO,MAAM,aAAW,SAAS,EAAY,EAAUA,EAAO,KAAK,CACtL,CAAC,aAAW,eAAaC,MAAY,CAAC,GAAG,CAA0D,IAAM,EAAlD,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAoB,IAAI,EAAW,EAAE,GAGjG,OAHwG,EAEjI,eA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