{"version":3,"file":"WaitlistSignup.BDk5WAP8.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/qYXzqngRMWXwm8qekLIn/bZO1ZsYim30rOQjUFwfa/WaitlistSignup.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";// Waitlist capture endpoint — see apps/api/src/app/v1/capture/waitlist/route.ts\n// Single Temple API endpoint — server handles Kajabi + Supabase, so no\n// secrets live in this bundle. CORS allow-list: my-temple.com.\nconst WAITLIST_API_URL=\"https://api.my-temple.com/v1/capture/waitlist\";const THANK_YOU_URL=\"/signupthankyou\";// Must match the dropdown options on /waitlist (and the existing Kajabi tag\n// names). Anything else is dropped server-side.\nconst ALLOWED_COURSES=new Set([\"ONE JOURNEY\",\"ALL JOURNEYS\",\"ALL JOURNEYS + COACHING\"]);async function submitWaitlist(data){try{const res=await fetch(WAITLIST_API_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(data)});if(!res.ok){console.error(\"Waitlist capture failed:\",res.status,await res.text());}}catch(err){console.error(\"Waitlist capture error:\",err);}}function trackEvent(name,params){const w=window;if(w.gtag)w.gtag(\"event\",name,params);}/**\n * Apply this override to a single-form waitlist signup. The form must have\n * an <input type=\"email\"> as the only required field; firstName, country\n * and a \"preferred course\" select are all optional. The override BLOCKS\n * Framer's default submit, posts to our API, then redirects to THANK_YOU_URL.\n */export function withWaitlistSignup(Component){return function WrappedComponent(props){const ref=useRef(null);useEffect(()=>{const container=ref.current;if(!container)return;const handleSubmit=e=>{const form=e.target?.closest?.(\"form\");if(!form)return;const emailInput=form.querySelector(\"input[type='email']\");if(!emailInput?.value)return;e.preventDefault();e.stopPropagation();// Probe every visible input/select for the optional fields.\n// We match by `name` first, then fall back to placeholder, so\n// it survives Framer's autogen field names without a code change.\nlet firstName;let country;let preferredCourse;const fields=form.querySelectorAll(\"input, select\");for(let i=0;i<fields.length;i++){const el=fields[i];if(!el.value)continue;const hint=(el.name||el.getAttribute(\"placeholder\")||\"\").toLowerCase();if(ALLOWED_COURSES.has(el.value)||hint.includes(\"course\")||hint.includes(\"journey\")){if(ALLOWED_COURSES.has(el.value))preferredCourse=el.value;}else if(hint.includes(\"country\")||hint.includes(\"land\")){country=el.value;}else if(hint.includes(\"name\")||hint.includes(\"f\\xf6rnamn\")||hint.includes(\"first\")){firstName=el.value;}}trackEvent(\"waitlist_signup\",{form_type:\"waitlist\",user_email:emailInput.value,preferred_course:preferredCourse??\"\"});submitWaitlist({email:emailInput.value,firstName,country,preferredCourse}).finally(()=>{window.location.href=THANK_YOU_URL;});};container.addEventListener(\"submit\",handleSubmit,true);return()=>container.removeEventListener(\"submit\",handleSubmit,true);},[]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withWaitlistSignup\":{\"type\":\"reactHoc\",\"name\":\"withWaitlistSignup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WaitlistSignup.map"],"mappings":"kIAKwF,eAAe,EAAe,EAAK,CAAC,GAAG,CAAC,IAAM,EAAI,MAAM,MAAM,EAAiB,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,CAAC,KAAK,KAAK,UAAU,EAAK,CAAC,CAAC,CAAK,EAAI,IAAI,QAAQ,MAAM,2BAA2B,EAAI,OAAO,MAAM,EAAI,MAAM,CAAC,OAAS,EAAI,CAAC,QAAQ,MAAM,0BAA0B,EAAI,EAAG,SAAS,EAAW,EAAK,EAAO,CAAC,IAAM,EAAE,EAAU,EAAE,MAAK,EAAE,KAAK,QAAQ,EAAK,EAAO,CAK9d,SAAgB,EAAmB,EAAU,CAAC,OAAO,SAA0B,EAAM,CAAC,IAAM,EAAIA,EAAO,KAAK,CAG+zB,OAH9zB,MAAc,CAAC,IAAM,EAAU,EAAI,QAAQ,GAAG,CAAC,EA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