{"version":3,"file":"Hubspot.C8lMsRPo.mjs","names":["_jsxs","_jsx","React.useState","React.useRef","React.useEffect","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","_e","de","p","c","init_jsx_runtime","ce","useTracking","addPropertyControls","ControlType","init_framer_ChujFWHC","stateTitleStyle","init_styles","emptyStateStyle","stateParagraphStyle","init_integrations_styles_js_0_2","poll","f","delay","count","i","EmptyState","title","description","getActualInstanceId","div","url","HubSpotForm","portalId","formId","advanced","region","trackingId","isScriptLoaded","setIsScriptLoaded","ref","track","onFormSubmissionSuccess","event","script","element","elementId","init_Hubspot"],"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,SAASwB,EAAKC,EAAEC,EAAM,IAAIC,EAAM,KAAOC,EAAE,EAAE,CAAIA,EAAED,EAAO,QAAQ,MAAM,oBAAoBF,CAAC,EAAcA,EAAE,IAAG,QAAQ,IAAI,OAAOC,EAAMC,EAAMC,CAAC,EAAE,eAAe,CAACJ,EAAKC,EAAEC,EAAMC,EAAMC,EAAE,CAAC,CAAE,EAAEF,CAAK,EAAG,CAAC,SAASG,EAAW,CAACC,QAAMC,eAAa,CAAC,MAAoB/B,gBAAM,MAAM,CAAC,MAAM,CAAC,GAAGqB,EAAgB,MAAM,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