{"version":3,"file":"EmbeddedForm.C1jirIUt.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/lfnTkveR80i7IxWvSFl4/TNfUKkrxDgmdlzLCZGIz/EmbeddedForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";// GenAI Zürich's own HubSpot portal, EU data residency. Its forms are legacy\n// (v2) forms: the v4 `hs-form-frame` embed answers \"Form not found\" for them.\n// Award applications run on Tally instead.\nconst HUBSPOT_PORTAL_ID=\"143645693\";const HUBSPOT_REGION=\"eu1\";const EVENT_CITY=\"zurich\";const scriptPromises={};// Vendor embed scripts are strictly necessary for the form the visitor asked\n// for, so they are not consent-gated. Consent Mode governs what gtag stores.\nfunction loadScript(src){if(typeof document===\"undefined\")return Promise.resolve();const pending=scriptPromises[src];if(pending)return pending;const promise=new Promise(resolve=>{if(document.querySelector(`script[src=\"${src}\"]`)){resolve();return;}const script=document.createElement(\"script\");script.src=src;script.async=true;script.onload=()=>resolve();// Resolve on error too: a dead script must not wedge the component.\nscript.onerror=()=>resolve();document.head.appendChild(script);});scriptPromises[src]=promise;return promise;}// Never forward field values (email, name) to GA4 — that is PII and violates\n// the GA4 terms. Only ids and classifiers go out.\nfunction fireEvent(name,params){if(typeof window===\"undefined\")return;const gtag=window.gtag;if(typeof gtag!==\"function\")return;gtag(\"event\",name,params);}export default function EmbeddedForm(props){const{formId=\"\",formType=\"partner\",sourceSection=\"\",minHeight=600}=props;// Framer can hand back the option title (\"Tally\") instead of its value.\nconst provider=String(props.provider??\"hubspot\").toLowerCase()===\"tally\"?\"tally\":\"hubspot\";const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const openFiredRef=useRef(false);const leadFiredRef=useRef(false);const[failed,setFailed]=useState(false);const params={event_city:EVENT_CITY,form_type:formType,source_section:sourceSection||`/${formType}`,form_provider:provider,form_id:formId};// Deliberately NOT `form_start` (GA4 Enhanced Measurement owns that name)\n// nor `begin_checkout` (reserved for the ticket click-out to Luma).\nuseEffect(()=>{if(isStatic||!formId||openFiredRef.current)return;openFiredRef.current=true;fireEvent(\"form_open\",params);},[isStatic,formId,formType,sourceSection]);useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;function onMessage(event){const data=event.data;if(provider===\"tally\"){// Tally posts its events as a JSON string.\nif(typeof data!==\"string\"||data.indexOf(\"Tally.FormSubmitted\")===-1)return;try{if(JSON.parse(data)?.event===\"Tally.FormSubmitted\"&&!leadFiredRef.current){leadFiredRef.current=true;fireEvent(\"generate_lead\",params);}}catch{// Not a Tally payload.\n}return;}if(data&&typeof data===\"object\"&&data.type===\"hsFormCallback\"&&data.eventName===\"onFormSubmitted\"&&data.id===formId&&!leadFiredRef.current){leadFiredRef.current=true;fireEvent(\"generate_lead\",params);}}window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[isStatic,provider,formId,formType,sourceSection]);useEffect(()=>{if(isStatic||!formId)return;let cancelled=false;if(provider===\"tally\"){loadScript(\"https://tally.so/widgets/embed.js\").then(()=>{if(cancelled)return;const tally=window.Tally;if(tally?.loadEmbeds)tally.loadEmbeds();else setFailed(true);});return()=>{cancelled=true;};}loadScript(`https://js-${HUBSPOT_REGION}.hsforms.net/forms/embed/v2.js`).then(()=>{const hbspt=window.hbspt;const target=containerRef.current;if(cancelled||!target)return;if(!hbspt?.forms?.create){setFailed(true);return;}target.innerHTML=\"\";target.id=`hs-form-${formId}`;hbspt.forms.create({region:HUBSPOT_REGION,portalId:HUBSPOT_PORTAL_ID,formId,target:`#${target.id}`});});return()=>{cancelled=true;};},[isStatic,provider,formId]);const rootStyle={...props.style,position:\"relative\",width:\"100%\",minHeight};if(isStatic){return /*#__PURE__*/_jsx(\"div\",{style:{...rootStyle,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:\"#F5F5F5\",border:\"1px dashed #CCCCCC\",borderRadius:8,padding:24,boxSizing:\"border-box\",color:\"#666666\",fontSize:14,textAlign:\"center\"},children:formId?`${provider===\"tally\"?\"Tally\":\"HubSpot\"} form “${formId}” — tracked as ${formType}`:\"Set a form ID in the properties panel\"});}if(!formId)return /*#__PURE__*/_jsx(\"div\",{style:rootStyle});if(provider===\"tally\"){return /*#__PURE__*/_jsxs(\"div\",{style:rootStyle,children:[/*#__PURE__*/_jsx(\"iframe\",{// eager: the form IS the page content\nloading:\"eager\",\"data-tally-src\":`https://tally.so/embed/${formId}?alignLeft=1&hideTitle=1&transparentBackground=1&dynamicHeight=1`,width:\"100%\",height:minHeight,frameBorder:0,title:`GenAI Z\\xfcrich form: ${formType}`,style:{border:0,width:\"100%\"}}),failed&&/*#__PURE__*/_jsx(\"p\",{children:\"The form could not be loaded.\"})]});}return /*#__PURE__*/_jsxs(\"div\",{style:rootStyle,children:[/*#__PURE__*/_jsx(\"div\",{ref:containerRef}),failed&&/*#__PURE__*/_jsx(\"p\",{children:\"The form could not be loaded.\"})]});}addPropertyControls(EmbeddedForm,{provider:{type:ControlType.Enum,title:\"Provider\",options:[\"hubspot\",\"tally\"],optionTitles:[\"HubSpot\",\"Tally\"],defaultValue:\"hubspot\",displaySegmentedControl:true},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"\",placeholder:\"HubSpot form GUID, or Tally form id\",description:\"HubSpot: the form GUID from portal 143645693, not the share-link token. Tally: the id from tally.so/r/<id>.\"},formType:{type:ControlType.String,title:\"Form Type\",defaultValue:\"partner\",placeholder:\"waitlist, partner, speaker…\",description:\"Sent as form_type on the GA4 conversion.\"},sourceSection:{type:ControlType.String,title:\"Source Section\",defaultValue:\"\",placeholder:\"Defaults to /<form type>\"},minHeight:{type:ControlType.Number,title:\"Min Height\",defaultValue:600,min:200,max:2e3,step:20,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmbeddedForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},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