{"version":3,"file":"RewindNativeFormSuccessPresenter.B6MDI-Og.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/ohSzBxgfE52qkJEIFkz3/zSJAN8jJO3fpyee3PV5n/RewindNativeFormSuccessPresenter.js"],"sourcesContent":["// User request: Create a new Framer code override file exporting an override named RewindNativeFormSuccessPresenter. It will be applied to existing canvas-native form FrameNodes. Requirements: preserve and forward all props and the ref; do not intercept submit, call preventDefault, submit data, alter validation, or touch form field values. Passively observe only the wrapped form’s DOM subtree with MutationObserver. Detect successful native submission when the form text contains either exact success heading: “Thank you for getting in touch.” or “Message received.” These headings already exist inside the native submit button’s success variant card. Once detected, identify the direct child of the form that contains the matching heading (the submit component rendered as the existing success card), keep that direct child visible, and hide every other direct form child with display:none so inputs, dropdowns, introductions, submit default UI, helper/privacy text, and other links leave no layout gap. Set the form’s gap to 0 only while successful, retain width and natural height, and add an accessible success marker/state without duplicating the existing message. Do not restyle the success card. Restore original inline display/gap values if the success text disappears or on cleanup. Scope all queries and mutations to the wrapped form; support multiple instances; guard browser APIs inside effects for SSR. The override must work on desktop/tablet/mobile inherited instances and keep the canvas structure editable.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef}from\"react\";const SUCCESS_HEADINGS=[\"Thank you for getting in touch.\",\"Message received.\"];function normalizeText(value){return(value??\"\").replace(/\\s+/g,\" \").trim();}function findSuccessHeadingInForm(form){const fullText=normalizeText(form.textContent);for(const heading of SUCCESS_HEADINGS){if(fullText.includes(heading))return heading;}return null;}function findDirectChildContainingHeading(form,heading){const children=Array.from(form.children);for(const child of children){if(normalizeText(child.textContent).includes(heading)){return child;}}return null;}export function RewindNativeFormSuccessPresenter(Component){return /*#__PURE__*/forwardRef(function RewindNativeFormSuccessPresenterOverride(props,ref){const sectionRef=useRef(null);const setRefs=useCallback(node=>{sectionRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const section=sectionRef.current;if(!section)return;const form=section.querySelector(\"form\");if(!form)return;const originalGap=form.style.gap;const originalFormAriaLive=form.getAttribute(\"aria-live\");const originalSectionSuccessState=section.getAttribute(\"data-rewind-native-success\");const originalDisplays=new Map;let activeSuccessChild=null;let observer=null;const observe=()=>{if(!observer)return;observer.observe(form,{subtree:true,childList:true,characterData:true});};const mutateSafely=mutate=>{if(observer)observer.disconnect();mutate();observe();};const restoreForm=()=>{mutateSafely(()=>{originalDisplays.forEach((display,element)=>{if(element.isConnected&&element.parentElement===form){element.style.display=display;}});form.style.gap=originalGap;form.removeAttribute(\"data-rewind-native-success\");if(originalFormAriaLive===null){form.removeAttribute(\"aria-live\");}else{form.setAttribute(\"aria-live\",originalFormAriaLive);}if(originalSectionSuccessState===null){section.removeAttribute(\"data-rewind-native-success\");}else{section.setAttribute(\"data-rewind-native-success\",originalSectionSuccessState);}activeSuccessChild=null;});};const applySuccessView=successChild=>{mutateSafely(()=>{const directChildren=Array.from(form.children);for(const child of directChildren){if(!originalDisplays.has(child)){originalDisplays.set(child,child.style.display);}if(child===successChild){child.style.display=originalDisplays.get(child)??\"\";}else{child.style.display=\"none\";}}form.style.gap=\"0\";form.setAttribute(\"data-rewind-native-success\",\"true\");form.setAttribute(\"aria-live\",\"polite\");section.setAttribute(\"data-rewind-native-success\",\"true\");activeSuccessChild=successChild;});};const syncPresentation=()=>{const heading=findSuccessHeadingInForm(form);if(!heading){if(activeSuccessChild)restoreForm();return;}const successChild=findDirectChildContainingHeading(form,heading);if(!successChild){if(activeSuccessChild)restoreForm();return;}if(activeSuccessChild===successChild){const directChildren=Array.from(form.children);let mismatch=form.style.gap!==\"0\";if(!mismatch){for(const child of directChildren){if(child===successChild){if(child.style.display!==(originalDisplays.get(child)??\"\")){mismatch=true;break;}}else if(child.style.display!==\"none\"){mismatch=true;break;}}}if(!mismatch)return;}applySuccessView(successChild);};syncPresentation();observer=new MutationObserver(()=>{syncPresentation();});observe();return()=>{if(observer){observer.disconnect();observer=null;}originalDisplays.forEach((display,element)=>{if(element.isConnected&&element.parentElement===form){element.style.display=display;}});form.style.gap=originalGap;form.removeAttribute(\"data-rewind-native-success\");if(originalFormAriaLive===null){form.removeAttribute(\"aria-live\");}else{form.setAttribute(\"aria-live\",originalFormAriaLive);}if(originalSectionSuccessState===null){section.removeAttribute(\"data-rewind-native-success\");}else{section.setAttribute(\"data-rewind-native-success\",originalSectionSuccessState);}};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRefs});});}\nexport const __FramerMetadata__ = {\"exports\":{\"RewindNativeFormSuccessPresenter\":{\"type\":\"reactHoc\",\"name\":\"RewindNativeFormSuccessPresenter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RewindNativeFormSuccessPresenter.map"],"mappings":"gJACqL,SAAS,EAAc,EAAM,CAAC,OAAO,GAAO,GAAA,CAAI,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK,CAAE,CAAC,SAAS,EAAyB,EAAK,CAAC,IAAM,EAAS,EAAc,EAAK,WAAW,EAAE,IAAI,IAAM,KAAW,EAAkB,GAAG,EAAS,SAAS,CAAO,EAAE,OAAO,EAAS,OAAO,IAAK,CAAC,SAAS,EAAiC,EAAK,EAAQ,CAAC,IAAM,EAAS,MAAM,KAAK,EAAK,QAAQ,EAAE,IAAI,IAAM,KAAS,EAAU,GAAG,EAAc,EAAM,WAAW,CAAC,CAAC,SAAS,CAAO,EAAG,OAAO,EAAQ,OAAO,IAAK,CAAC,SAAgB,EAAiC,EAAU,CAAC,OAAoB,EAAW,SAAkD,EAAM,EAAI,CAAC,IAAM,EAAWA,EAAO,IAAI,EAAQ,EAAQC,EAAY,GAAM,CAAC,EAAW,QAAQ,EAAQ,OAAO,GAAM,WAAY,EAAI,CAAI,EAAW,GAAK,OAAO,GAAM,WAAU,EAAI,QAAQ,EAAM,EAAE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