{"version":3,"file":"useInheritedSectionBreakpoint.DSyffAMg.mjs","names":["useContext"],"sources":["https:/framerusercontent.com/modules/GXLXiYd3hoMReGGx4l0f/b4UbE0ZuqfXx81EZYOtE/useInheritedSectionBreakpoint.js"],"sourcesContent":["import{createContext,useContext,useLayoutEffect,useState}from\"react\";export const SECTION_BREAKPOINT_ATTR=\"data-bunq-section-breakpoint\";export const SectionBreakpointContext=/*#__PURE__*/createContext(undefined);function parseBreakpoint(value){if(value===\"desktop\"||value===\"tablet\"||value===\"phone\"){return value;}return undefined;}export function readInheritedSectionBreakpoint(element){if(!element)return undefined;const host=element.closest(`[${SECTION_BREAKPOINT_ATTR}]`);if(!(host instanceof HTMLElement))return undefined;return parseBreakpoint(host.getAttribute(SECTION_BREAKPOINT_ATTR));}export function useInheritedSectionBreakpoint(ref){const contextBreakpoint=useContext(SectionBreakpointContext);const[domBreakpoint,setInheritedBreakpoint]=useState();const inheritedBreakpoint=domBreakpoint??contextBreakpoint;useLayoutEffect(()=>{const element=ref.current;if(!element)return undefined;let observer;let cancelled=false;const syncBreakpoint=()=>{setInheritedBreakpoint(readInheritedSectionBreakpoint(element));};const tryAttach=()=>{const host=element.closest(`[${SECTION_BREAKPOINT_ATTR}]`);if(!(host instanceof HTMLElement))return false;syncBreakpoint();observer?.disconnect();observer=new MutationObserver(syncBreakpoint);observer.observe(host,{attributes:true,attributeFilter:[SECTION_BREAKPOINT_ATTR]});return true;};if(!tryAttach()){queueMicrotask(()=>{if(!cancelled)tryAttach();});}return()=>{cancelled=true;observer?.disconnect();};},[ref]);return inheritedBreakpoint;}export function useSlotFallbackBreakpoint(ownBreakpoint){const contextBreakpoint=useContext(SectionBreakpointContext);if(ownBreakpoint!==\"desktop\"||contextBreakpoint===undefined){return ownBreakpoint;}return contextBreakpoint;}// recompile: 1792505897503\n\nexport const __FramerMetadata__ = {\"exports\":{\"readInheritedSectionBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSlotFallbackBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SectionBreakpointContext\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SECTION_BREAKPOINT_ATTR\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useInheritedSectionBreakpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useInheritedSectionBreakpoint.map"],"mappings":"2GAAi9C,SAAgB,EAA0B,EAAc,CAAC,IAAM,EAAkBA,EAAW,CAAwB,EAAqF,OAAhF,IAAgB,WAAW,IAAoB,IAAA,GAAkB,EAAsB,CAAkB,qBAA/mD,EAAc,EAAwB,+BAA4C,EAAsC,EAAc,IAAA,EAAS"}