{"version":3,"file":"ConsentRouting.BTz6n5kY.mjs","names":["useState","p"],"sources":["https:/framerusercontent.com/modules/OvJqfeiQ9BevCTpyoWnu/KAFKVdPWRNa3hv7SklLi/ConsentRouting.js"],"sourcesContent":["// ConsentRouting.tsx\n// SMS-consent-aware thank-you routing for the three Phone-or-Text style pages.\n//\n// ──────────────────────────────────────────────────────────────\n// WIRING GUIDE — apply each override to exactly the layer named.\n// ──────────────────────────────────────────────────────────────\n//\n// FORM PAGES — apply ONE form router to the FORM on each page:\n//   Expertly \"Phone or Text\" form ......  FormRouter_ExpertlyPage\n//   Studio Bloom salon form ............  FormRouter_SalonPage\n//   OneSource logistics form ...........  FormRouter_OneSourcePage\n//\n// THANK-YOU PAGE — apply ONE block override to each of the five blocks\n//   (name each block to match):\n//   Block \"Expertly — Subscribed\" ......  ThankYouBlock_Expertly_Subscribed\n//   Block \"Salon — Subscribed\" .........  ThankYouBlock_Salon_Subscribed\n//   Block \"Salon — No texts\" ...........  ThankYouBlock_Salon_NoTexts\n//   Block \"OneSource — Subscribed\" .....  ThankYouBlock_OneSource_Subscribed\n//   Block \"OneSource — No texts\" .......  ThankYouBlock_OneSource_NoTexts\n//\n// NOTE: each form must contain exactly one checkbox (the SMS consent box).\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";const THANK_YOU_PATH=\"/form-process/phone-or-text-thank-you\";const PARAM_SOURCE=\"source\";const PARAM_SMS=\"sms\";const CHECKBOX_SELECTOR='input[type=\"checkbox\"]';// ── shared submit logic (helper hook, not an override) ──\nfunction useConsentRouting(source){useEffect(()=>{if(typeof document===\"undefined\")return;let attachedForm=null;let observer=null;async function handleSubmit(e){const form=e.currentTarget;const checkbox=form.querySelector(CHECKBOX_SELECTOR);const consented=!!checkbox?.checked;e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();const action=form.action||form.getAttribute(\"action\")||\"\";if(action){try{await fetch(action,{method:\"POST\",body:new FormData(form)});}catch(err){// Framer may handle the save itself; a blocked or failed\n// fetch here should not stop the visitor continuing.\nconsole.error(\"[ConsentRouting] post failed, continuing:\",err);}}const sms=consented?\"true\":\"false\";window.location.href=`${THANK_YOU_PATH}?${PARAM_SOURCE}=${source}&${PARAM_SMS}=${sms}`;}function tryAttach(){const form=document.querySelector(\"form\");if(form&&form!==attachedForm){attachedForm=form;form.addEventListener(\"submit\",handleSubmit,{capture:true});return true;}return false;}if(!tryAttach()){observer=new MutationObserver(()=>{if(tryAttach()){observer?.disconnect();observer=null;}});observer.observe(document.body,{childList:true,subtree:true});}return()=>{if(attachedForm){attachedForm.removeEventListener(\"submit\",handleSubmit,{capture:true});}observer?.disconnect();};},[source]);}// ── FORM ROUTERS (apply to the form on each page) ──\nexport function FormRouter_ExpertlyPage(Component){return props=>{useConsentRouting(\"expertly\");return /*#__PURE__*/_jsx(Component,{...props});};}export function FormRouter_SalonPage(Component){return props=>{useConsentRouting(\"salon\");return /*#__PURE__*/_jsx(Component,{...props});};}export function FormRouter_OneSourcePage(Component){return props=>{useConsentRouting(\"onesource\");return /*#__PURE__*/_jsx(Component,{...props});};}// ── shared param reader (helper hook, not an override) ──\nfunction useRouteParams(){const[state,setState]=useState({source:null,sms:null,ready:false});useEffect(()=>{if(typeof window===\"undefined\")return;const params=new URLSearchParams(window.location.search);setState({source:params.get(PARAM_SOURCE),sms:params.get(PARAM_SMS),ready:true});},[]);return state;}// ── THANK-YOU BLOCK VISIBILITY (apply to each block) ──\nexport function ThankYouBlock_Expertly_Subscribed(Component){return props=>{const p=useRouteParams();if(!p.ready)return null;if(p.source!==\"expertly\"||p.sms!==\"true\")return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function ThankYouBlock_Salon_Subscribed(Component){return props=>{const p=useRouteParams();if(!p.ready)return null;if(p.source!==\"salon\"||p.sms!==\"true\")return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function ThankYouBlock_Salon_NoTexts(Component){return props=>{const p=useRouteParams();if(!p.ready)return null;if(p.source!==\"salon\"||p.sms!==\"false\")return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function ThankYouBlock_OneSource_Subscribed(Component){return props=>{const p=useRouteParams();if(!p.ready)return null;if(p.source!==\"onesource\"||p.sms!==\"true\")return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function ThankYouBlock_OneSource_NoTexts(Component){return props=>{const p=useRouteParams();if(!p.ready)return null;if(p.source!==\"onesource\"||p.sms!==\"false\")return null;return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"ThankYouBlock_OneSource_NoTexts\":{\"type\":\"reactHoc\",\"name\":\"ThankYouBlock_OneSource_NoTexts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FormRouter_ExpertlyPage\":{\"type\":\"reactHoc\",\"name\":\"FormRouter_ExpertlyPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ThankYouBlock_Salon_Subscribed\":{\"type\":\"reactHoc\",\"name\":\"ThankYouBlock_Salon_Subscribed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ThankYouBlock_OneSource_Subscribed\":{\"type\":\"reactHoc\",\"name\":\"ThankYouBlock_OneSource_Subscribed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FormRouter_OneSourcePage\":{\"type\":\"reactHoc\",\"name\":\"FormRouter_OneSourcePage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ThankYouBlock_Expertly_Subscribed\":{\"type\":\"reactHoc\",\"name\":\"ThankYouBlock_Expertly_Subscribed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FormRouter_SalonPage\":{\"type\":\"reactHoc\",\"name\":\"FormRouter_SalonPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ThankYouBlock_Salon_NoTexts\":{\"type\":\"reactHoc\",\"name\":\"ThankYouBlock_Salon_NoTexts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ConsentRouting.map"],"mappings":"uI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