{"version":3,"file":"Hubspot.Bj7OfPRI.mjs","names":["React.useState","React.useRef","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","_e","de","p","c","init_jsx_runtime","ce","addPropertyControls","ControlType","init_framer_Bf4_tcb2","useTracking","stateTitleStyle","init_styles","emptyStateStyle","stateParagraphStyle","init_integrations_styles_js_0_2","poll","i","count","f","delay","EmptyState","title","description","getActualInstanceId","url","div","HubSpotForm","isScriptLoaded","setIsScriptLoaded","ref","track","portalId","formId","trackingId","onFormSubmissionSuccess","event","region","script","element","elementId","init_Hubspot","advanced"],"sources":["https:/framer.com/m/framer/integrations-styles.js@0.2.0","https:/framerusercontent.com/modules/uGQZtcsxBzvxqsgxQ0Tz/ifR6JPfBJ84NN8DyqvOK/Hubspot.js"],"sourcesContent":["/*\n * styles (framer/integrations-styles@0.2.0)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/ZORE1BBUY4n4vHC0WFDH/bnwaYkSw2e4q5eLH4jPK/styles.js\"\n","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useTracking}from\"framer\";import{emptyStateStyle,stateParagraphStyle,stateTitleStyle}from\"https://framer.com/m/framer/integrations-styles.js@0.2.0\";// Poll for 5 minutes ...\nfunction poll(f,delay=200,count=5*60*5,i=0){if(i>count){console.error(\"poll max attempts\",f);return;}if(!f()){console.log(\"poll\",delay,count,i);setTimeout(()=>{poll(f,delay,count,i+1);},delay);}}function EmptyState({title,description}){return /*#__PURE__*/_jsxs(\"div\",{style:{...emptyStateStyle,width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(\"h1\",{style:stateTitleStyle,children:title}),/*#__PURE__*/_jsx(\"p\",{style:stateParagraphStyle,children:description})]});}/**\n * Return the actual instance id of the HubSpot form.\n *\n * window.hbspt.forms.create returns a totally different instanceId\n * from the one in the success event. This ugly code below grabs the\n * actual instance id from the iframe src. Hopefully this doesn’t break.\n */function getActualInstanceId(div){const url=div.querySelector(\"iframe\")?.getAttribute(\"src\");return url?new URL(url).searchParams.get(\"_hsInstanceId\"):null;}/**\n * HUBSPOT\n *\n * @framerIntrinsicWidth 480\n * @framerIntrinsicHeight 300\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function HubSpotForm({portalId,formId,advanced,region,trackingId}){const[isScriptLoaded,setIsScriptLoaded]=React.useState(()=>Boolean(typeof window!==\"undefined\"&&window.hbspt));const ref=React.useRef(null);const track=useTracking();// Tracking setup\nReact.useEffect(()=>{if(!portalId||!formId||!trackingId)return;function onFormSubmissionSuccess(event){if(!ref.current)return;// Because the events are global, we need to compare\n// instanceId to know which instance it is comes from.\nif(getActualInstanceId(ref.current)!==event.detail.instanceId)return;if(trackingId)track(trackingId);}// https://developers.hubspot.com/docs/guides/api/marketing/forms/global-form-events#form-events$0\ndocument.addEventListener(\"hs-form-event:on-submission:success\",onFormSubmissionSuccess);return()=>document.removeEventListener(\"hs-form-event:on-submission:success\",onFormSubmissionSuccess);},[trackingId,formId,portalId]);// Load the hubspot script\nReact.useEffect(()=>{if(!region)return;if(isScriptLoaded||typeof window===\"undefined\")return;if(window.hbspt)return setIsScriptLoaded(true);const script=document.createElement(\"script\");script.src=`https://js-${region}.hsforms.net/forms/embed/v2.js`;script.async=true;script.onload=()=>poll(()=>{if(window.hbspt){setIsScriptLoaded(true);return true;}});document.body.appendChild(script);},[isScriptLoaded,region]);React.useEffect(()=>{if(!portalId||!formId)return;if(!isScriptLoaded||!ref.current||typeof window===\"undefined\")return;const element=document.createElement(\"div\");const randomId=Math.random().toString(36).substr(2,8);const elementId=`hubspot_form_${randomId}`;element.setAttribute(\"id\",elementId);element.style.width=\"100%\";element.style.height=\"100%\";ref.current.appendChild(element);window.hbspt.forms.create({region,portalId,formId,target:`#${elementId}`});return()=>{if(ref.current)ref.current.removeChild(element);};},[isScriptLoaded,portalId,formId]);if(!portalId||!formId||!region){return /*#__PURE__*/_jsx(EmptyState,{title:\"Hubspot\",description:\"Set a portal ID and form in the Properties.\"});}return /*#__PURE__*/_jsx(\"div\",{style:{display:\"contents\"},ref:ref});}addPropertyControls(HubSpotForm,{portalId:{title:\"Portal\",type:ControlType.String,placeholder:\"25276298\",// defaultValue: \"25276298\",\ndescription:\"Create a [Hubspot](https://www.hubspot.com/) account, add a new form and copy your portal ID. [Learn more…](https://www.framer.com/plugins/hubspot/)\"},formId:{title:\"Form\",type:ControlType.String,placeholder:\"e7167571-4bc4-4c2c-bfdc-a0a8dbfd22f1\"},trackingId:{title:\"Tracking\",type:ControlType.TrackingId,placeholder:\"ID\"},advanced:{title:\"Advanced\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false},region:{title:\"Region\",type:ControlType.String,placeholder:\"eu1\",defaultValue:\"eu1\",hidden:({advanced})=>!advanced}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"480\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hubspot.map"],"mappings":"A,oUCCA,SAASqB,EAAK,EAAE,EAAM,IAAI,EAAM,KAAO,EAAE,EAAE,CAAIC,EAAEC,EAAO,QAAQ,MAAM,oBAAoBC,CAAC,EAAcA,EAAE,IAAG,QAAQ,IAAI,OAAOC,EAAMF,EAAMD,CAAC,EAAE,eAAe,CAACD,EAAKG,EAAEC,EAAMF,EAAMD,EAAE,CAAC,CAAE,EAAEG,CAAK,EAAG,CAAC,SAASC,EAAW,CAAC,QAAM,eAAa,CAAC,MAAoB,gBAAM,MAAM,CAAC,MAAM,CAAC,GAAGR,EAAgB,MAAM,OAAO,OAAO,MAAM,EAAE,SAA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