{"version":3,"file":"HubSpotEUFormEmbed.OXUXaLFB.mjs","names":["React.useId","React.useState","React.useMemo","React.useCallback"],"sources":["https:/framerusercontent.com/modules/qSGJjEZXQBPbRy9hfnQX/YIFoNhuUGfpWWEJ6V3X4/HubSpotEUFormEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const KNOWN_EMAIL_STORAGE_KEY=\"uare_known_email\";const CONSENT_STORAGE_KEYS=[\"cookie_consent\",\"cookieConsent\",\"cookie-consent\",\"cookies_accepted\",\"consent\",\"cookieyes-consent\",\"CookieConsent\"];const CONSENT_COOKIE_KEYS=[\"cookie_consent\",\"cookieConsent\",\"cookies_accepted\",\"consent\",\"cookieyes-consent\",\"CookieConsent\"];function normalizeEmail(value){return value.trim().toLowerCase();}function isValidEmail(value){return/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizeEmail(value));}function isAcceptedConsentValue(value){const normalized=value.trim().toLowerCase();if(!normalized)return false;if(normalized===\"true\"||normalized===\"yes\"||normalized===\"accepted\"||normalized===\"accept\"||normalized===\"allow\"||normalized===\"allow_all\"||normalized===\"all\"||normalized===\"granted\"||normalized===\"1\"){return true;}return normalized.includes(\"accept\")||normalized.includes(\"allow\")||normalized.includes(\"granted\");}function hasConsentForEmailHandoff(enableEmailHandoff){if(enableEmailHandoff)return true;if(typeof window===\"undefined\"||typeof document===\"undefined\")return false;try{for(const key of CONSENT_STORAGE_KEYS){const value=window.localStorage.getItem(key);if(value&&isAcceptedConsentValue(value))return true;}}catch{// Silent by design\n}try{const cookieSource=document.cookie||\"\";const cookies=cookieSource.split(\";\");for(const entry of cookies){const[rawName,...rest]=entry.split(\"=\");if(!rawName||rest.length===0)continue;const name=rawName.trim();if(!CONSENT_COOKIE_KEYS.includes(name))continue;const value=decodeURIComponent(rest.join(\"=\"));if(isAcceptedConsentValue(value))return true;}}catch{// Silent by design\n}return false;}function getSubmittedEmailFromHubSpotArgs(args){for(const candidate of args){if(!candidate)continue;const directEmail=candidate?.email||candidate?.Email;if(typeof directEmail===\"string\"&&isValidEmail(directEmail)){return normalizeEmail(directEmail);}const submissionValues=candidate?.submissionValues;if(submissionValues&&typeof submissionValues===\"object\"&&typeof submissionValues.email===\"string\"&&isValidEmail(submissionValues.email)){return normalizeEmail(submissionValues.email);}const fields=candidate?.fields||candidate?.data||candidate?.values;if(Array.isArray(fields)){for(const item of fields){const name=String(item?.name||item?.key||\"\").toLowerCase();const value=item?.value;if(name===\"email\"&&typeof value===\"string\"&&isValidEmail(value)){return normalizeEmail(value);}}}}return\"\";}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function HubSpotEUFormEmbed(props){const{portalID,region,formID,minHeight,enableEmailHandoff,style}=props;const reactId=React.useId();const[measuredHeight,setMeasuredHeight]=React.useState(minHeight);const targetId=React.useMemo(()=>{return`hs-form-frame-${reactId.replace(/[:]/g,\"\")}`;},[reactId]);const scriptSrc=React.useMemo(()=>{return`https://js-${region}.hsforms.net/forms/embed/v2.js`;},[region]);const updateMeasuredHeight=React.useCallback(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const frame=document.getElementById(targetId);if(!frame)return;let nextHeight=minHeight;const frameRectHeight=frame.getBoundingClientRect().height;const frameScrollHeight=frame.scrollHeight;nextHeight=Math.max(nextHeight,frameRectHeight,frameScrollHeight);const embeddedIframes=frame.querySelectorAll(\"iframe\");embeddedIframes.forEach(embeddedFrame=>{const iframeRectHeight=embeddedFrame.getBoundingClientRect().height;const iframeClientHeight=embeddedFrame.clientHeight;nextHeight=Math.max(nextHeight,iframeRectHeight,iframeClientHeight);});const firstChild=frame.firstElementChild;if(firstChild){nextHeight=Math.max(nextHeight,firstChild.getBoundingClientRect().height,firstChild.scrollHeight);}const roundedHeight=Math.ceil(nextHeight);React.startTransition(()=>{setMeasuredHeight(prevHeight=>prevHeight===roundedHeight?prevHeight:roundedHeight);});},[minHeight,targetId]);const initializeFrame=React.useCallback(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const frame=document.getElementById(targetId);if(!frame)return;if(window.hbspt?.forms?.create){frame.innerHTML=\"\";window.hbspt.forms.create({region,portalId:portalID,formId:formID,target:`#${targetId}`,onFormSubmitted:(...submissionArgs)=>{if(!hasConsentForEmailHandoff(enableEmailHandoff))return;if(typeof window===\"undefined\")return;const submittedEmail=getSubmittedEmailFromHubSpotArgs(submissionArgs);if(!submittedEmail||!isValidEmail(submittedEmail))return;try{window.localStorage.setItem(KNOWN_EMAIL_STORAGE_KEY,normalizeEmail(submittedEmail));}catch{// Silent by design\n}}});window.requestAnimationFrame(updateMeasuredHeight);window.setTimeout(updateMeasuredHeight,300);window.setTimeout(updateMeasuredHeight,1e3);}},[enableEmailHandoff,formID,portalID,region,targetId,updateMeasuredHeight]);React.useEffect(()=>{React.startTransition(()=>{setMeasuredHeight(prevHeight=>prevHeight===minHeight?prevHeight:minHeight);});},[minHeight]);React.useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const existingScript=document.querySelector(`script[src=\"${scriptSrc}\"]`);if(existingScript){if(window.hbspt?.forms?.create){initializeFrame();return;}const handleLoad=()=>initializeFrame();existingScript.addEventListener(\"load\",handleLoad);return()=>existingScript.removeEventListener(\"load\",handleLoad);}const script=document.createElement(\"script\");script.src=scriptSrc;script.defer=true;script.async=true;script.id=`hs-forms-v2-${region}`;script.addEventListener(\"load\",initializeFrame);document.body.appendChild(script);return()=>{script.removeEventListener(\"load\",initializeFrame);};},[initializeFrame,region,scriptSrc]);React.useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const frame=document.getElementById(targetId);if(!frame)return;updateMeasuredHeight();const resizeObserver=new ResizeObserver(()=>{updateMeasuredHeight();});resizeObserver.observe(frame);const mutationObserver=new MutationObserver(()=>{updateMeasuredHeight();});mutationObserver.observe(frame,{childList:true,subtree:true,attributes:true,characterData:true});const handleWindowResize=()=>updateMeasuredHeight();window.addEventListener(\"resize\",handleWindowResize);return()=>{resizeObserver.disconnect();mutationObserver.disconnect();window.removeEventListener(\"resize\",handleWindowResize);};},[targetId,updateMeasuredHeight]);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:`${Math.max(minHeight,measuredHeight)}px`,minHeight:`${minHeight}px`,overflow:\"visible\",...style},children:/*#__PURE__*/_jsx(\"div\",{id:targetId,className:\"hs-form-host\",\"data-hs-region\":region,\"data-hs-form-id\":formID,\"data-hs-portal-id\":portalID,style:{width:\"100%\",minHeight:`${minHeight}px`,overflow:\"visible\"}})});}addPropertyControls(HubSpotEUFormEmbed,{portalID:{type:ControlType.String,title:\"Portal ID\",defaultValue:\"25864264\"},region:{type:ControlType.String,title:\"Region\",defaultValue:\"eu1\"},formID:{type:ControlType.String,title:\"Form ID\",defaultValue:\"75c5146d-8359-4eaf-b78d-4a4c5b53e7a1\"},minHeight:{type:ControlType.Number,title:\"Min Height\",defaultValue:327,min:120,max:1200,unit:\"px\",step:1},enableEmailHandoff:{type:ControlType.Boolean,title:\"Email Handoff\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotEUFormEmbed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubSpotEUFormEmbed.map"],"mappings":"4NAA0b,SAAS,EAAe,EAAM,CAAC,OAAO,EAAM,KAAK,CAAC,CAAC,YAAY,CAAE,CAAC,SAAS,EAAa,EAAM,CAAC,MAAM,6BAA6B,KAAK,EAAe,CAAK,CAAC,CAAE,CAAC,SAAS,EAAuB,EAAM,CAAC,IAAM,EAAW,EAAM,KAAK,CAAC,CAAC,YAAY,EAAqP,OAA/O,EAA2B,IAAa,QAAQ,IAAa,OAA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