{"version":3,"file":"HubSpotEmbed.suCsxei3.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/4LFKFokNw2Cd2auG0MvM/MR7VPOOIJuvZSqBytjgA/HubSpotEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Renders a HubSpot form inside an iframe, with automatic email\n * pre-fill from URL query parameters. This works because the code\n * component reads the URL params from the main page context, then\n * injects the email value directly into the iframe HTML.\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);// Read email from the parent page URL\nconst emailValue=useMemo(()=>{try{const params=new URLSearchParams(window.location.search);return params.get(emailParam)||\"\";}catch{return\"\";}},[emailParam]);// Build the iframe HTML with email baked in\nconst iframeHtml=useMemo(()=>{const escapedEmail=emailValue.replace(/\\\\/g,\"\\\\\\\\\").replace(/'/g,\"\\\\'\").replace(/\"/g,'\\\\\"');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      if (!prefillEmail) return;\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      }\n    }\n  });\n</script>\n</body>\n</html>`;},[portalId,formId,region,emailValue]);useEffect(()=>{const iframe=iframeRef.current;if(!iframe)return;// Write the HTML content directly to the iframe\nconst 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\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\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