{"version":3,"file":"HubspotFormNew.Bff3mL-L.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/PDnLhDtWQeuhBuL8UZWO/skSm4QoWheH8fV9VxnDl/HubspotFormNew.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{RenderTarget,addPropertyControls,ControlType}from\"framer\";export default function HubSpotForm(props){const{portalId,formId,region,shareLink,fallbackDelayMs}=props;const wrapRef=React.useRef(null);const[fallbackVisible,setFallbackVisible]=React.useState(false);// Canvas-only script injection so you can design in Framer\nReact.useEffect(()=>{if(RenderTarget.current()!==RenderTarget.canvas)return;const src=`https://js.hsforms.net/forms/embed/${portalId}.js`;if(window.HubSpotFormsV4)return;if(document.querySelector(`script[src=\"${src}\"]`))return;const s=document.createElement(\"script\");s.src=src;s.defer=true;document.head.appendChild(s);},[portalId]);// ─── FIX: dynamically inject .hs-form-frame on every mount ───\n// On a fresh page load the <head> script handles discovery.\n// On SPA / client-side navigation the script is already loaded\n// but won't re-scan the DOM. Creating the element via vanilla DOM\n// (not JSX) guarantees a real insertion that triggers HubSpot's\n// MutationObserver. If that still doesn't work (observer inactive),\n// we fall back to re-adding the embed script to force a full scan.\nReact.useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;if(!formId||!portalId)return;const slot=wrapRef.current?.querySelector(\".hs-form-slot\");if(!slot)return;let cancelled=false;// Clean slate (handles re-mounts and prop changes)\nslot.innerHTML=\"\";// Create a fresh .hs-form-frame element\nconst frame=document.createElement(\"div\");frame.className=\"hs-form-frame\";frame.setAttribute(\"data-region\",region);frame.setAttribute(\"data-form-id\",formId);frame.setAttribute(\"data-portal-id\",portalId);slot.appendChild(frame);// Safety net: if HubSpot's observer didn't pick up the element,\n// re-inject the embed script to force a fresh DOM scan.\nconst safetyTimer=window.setTimeout(()=>{if(cancelled)return;// Form already rendered — nothing to do\nif(frame.querySelector(\"iframe\")||frame.querySelector(\"form\"))return;// Script hasn't loaded yet — it will discover on load\nif(!window.HubSpotFormsV4)return;// Re-inject embed script with a cache-buster so the browser\n// treats it as a new resource and HubSpot re-scans the DOM.\nconst src=`https://js.hsforms.net/forms/embed/${portalId}.js`+`?t=${Date.now()}`;const s=document.createElement(\"script\");s.src=src;document.head.appendChild(s);},1200);return()=>{cancelled=true;window.clearTimeout(safetyTimer);// Remove HubSpot's rendered form so it doesn't leak between pages\nslot.innerHTML=\"\";};},[formId,portalId,region]);// Fallback logic: show after X ms unless we get on-ready for THIS formId\nReact.useEffect(()=>{if(!shareLink)return;// optional per-form\nsetFallbackVisible(false);let ready=false;let showTimer;let pollTimer;const markReady=()=>{ready=true;setFallbackVisible(false);if(showTimer)window.clearTimeout(showTimer);if(pollTimer)window.clearInterval(pollTimer);};// Listen for HubSpot \"form ready\" (updated forms).\nconst onReady=event=>{try{if(!event?.detail?.formId)return;if(event.detail.formId!==formId)return;markReady();}catch{}};window.addEventListener(\"hs-form-event:on-ready\",onReady);// After delay, show fallback if not ready yet\nshowTimer=window.setTimeout(()=>{if(!ready)setFallbackVisible(true);// If we missed the on-ready event (race), poll for the form instance\npollTimer=window.setInterval(()=>{try{const api=window.HubSpotFormsV4;if(!api?.getForms)return;const forms=api.getForms();if(!Array.isArray(forms))return;const found=forms.some(f=>f?.getFormId?.()===formId);if(found)markReady();}catch{}},250);},fallbackDelayMs);return()=>{window.removeEventListener(\"hs-form-event:on-ready\",onReady);if(showTimer)window.clearTimeout(showTimer);if(pollTimer)window.clearInterval(pollTimer);};},[formId,shareLink,fallbackDelayMs]);const isCanvas=RenderTarget.current()===RenderTarget.canvas;return /*#__PURE__*/_jsxs(\"div\",{ref:wrapRef,className:\"hs-embed\",children:[isCanvas&&/*#__PURE__*/_jsx(\"div\",{className:\"hs-form-frame\",\"data-region\":region,\"data-form-id\":formId,\"data-portal-id\":portalId}),!isCanvas&&/*#__PURE__*/_jsx(\"div\",{className:\"hs-form-slot\"}),shareLink?/*#__PURE__*/_jsxs(\"div\",{className:\"hs-fallback\",style:{display:fallbackVisible?\"block\":\"none\"},children:[\"If the form isn't displaying, please\",\" \",/*#__PURE__*/_jsx(\"a\",{href:shareLink,target:\"_blank\",rel:\"noopener\",children:\"click here\"}),\".\"]}):null,/*#__PURE__*/_jsx(\"style\",{children:`\n        .hs-embed,\n        .hs-embed .hs-form-frame,\n        .hs-embed .hs-form-slot { width: 100% !important; max-width: 100% !important; }\n        .hs-embed .hs-form-frame iframe { width: 100% !important; max-width: 100% !important; display: block !important; }\n        .hs-fallback{\n            margin-top: 12px;\n            font-family: \"Noto Sans\", sans-serif;\n            font-size: 16px;\n            color: #3A464B;\n            text-align: center;\n            }\n        .hs-fallback a{\n            color: #3A464B;\n            text-decoration: underline;\n            }\n      `})]});}addPropertyControls(HubSpotForm,{portalId:{type:ControlType.String,defaultValue:\"43906340\"},formId:{type:ControlType.String,defaultValue:\"\"},region:{type:ControlType.String,defaultValue:\"na1\"},shareLink:{type:ControlType.String,defaultValue:\"\"},fallbackDelayMs:{type:ControlType.Number,defaultValue:3e3,min:0,max:15e3,step:250}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubspotFormNew.map"],"mappings":"oNAAsJ,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,WAAS,SAAO,SAAO,YAAU,mBAAiB,EAAY,EAAQA,EAAa,KAAK,CAAM,CAAC,EAAgB,GAAoBC,EAAe,GAAM,CAC/V,MAAoB,CAAC,GAAG,EAAa,SAAS,GAAG,EAAa,OAAO,OAAO,IAAM,EAAI,sCAAsC,EAAS,KAAqC,GAA7B,EAAO,gBAAyB,SAAS,cAAc,eAAe,EAAI,IAAI,CAAC,OAAO,IAAM,EAAE,SAAS,cAAc,SAAS,CAAC,EAAE,IAAI,EAAI,EAAE,MAAM,GAAK,SAA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