{"version":3,"file":"StackAutoAdvance.CyHx3ol9.mjs","names":["useState","__esmMin","init_ssg_sandbox_shims","_e","init_jsx_runtime","c","init_npm_react_18_3_1","ce","useReducedMotion","useMotionValue","animate","init_framer_motion_DhsWWWsN","timerBar","hidden","setHidden","stopped","group","l","listeners","Component","props","withStackTimerBar","withSlowPushIn","scale","reduceMotion","controls","init_StackAutoAdvance"],"sources":["https:/framerusercontent.com/modules/5UJX3LptyoUrGRrVGcdh/V3es0ZhVNLD5yjWhyR6T/StackAutoAdvance.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{animate,useInView,useMotionValue,useReducedMotion}from\"framer-motion\";// Once a visitor picks a tab the section stops advancing, so its timer bars\n// should stop promising that it will. Shared between the two overrides below.\nconst stopped={};const listeners=new Set;function stop(group){if(stopped[group])return;stopped[group]=true;listeners.forEach(l=>l());}const STACK_TABS=[\"Run the till\",\"Take the money\",\"Run the kitchen\",\"Fill the room\",\"Know the numbers\"];const HERO_TABS=[\"Restaurants\",\"Caf\\xe9s\",\"Bars and pubs\",\"Quick service\",\"Multi-venue groups\",\"Franchises\"];// Framer's onAppear delays survive a tap, so a click got overtaken by the\n// previous variant's timer. Here one timer owns the order: every change, by\n// click or by time, sets the variant prop and restarts the count, and the next\n// step is always the variant after the one showing.\nfunction autoAdvance(Component,tabs,stepMs,fill,group){return props=>{const[index,setIndex]=useState(0);const[tick,setTick]=useState(0);// It loops until the visitor picks a tab themselves; from then on\n// they're navigating, so it never moves again. That choice is also\n// the WCAG 2.2.2 stop mechanism.\nconst[userTook,setUserTook]=useState(false);const[focused,setFocused]=useState(false);const reduceMotion=useReducedMotion();// Off screen it holds still: panels differ in height, so advancing\n// while someone reads further down shifts the page under them.\nconst ref=useRef(null);const inView=useInView(ref,{amount:.25});const running=inView&&!focused&&!reduceMotion&&!userTook;useEffect(()=>{if(!running)return;const t=window.setTimeout(()=>setIndex(i=>(i+1)%tabs.length),stepMs);return()=>window.clearTimeout(t);},[index,tick,running]);// Layer names aren't in the published DOM; the selector labels and\n// \"Next: <tab>\" links carry the variant's name as text.\nconst select=target=>{let node=target;for(let depth=0;node&&depth<4;depth++){const k=tabs.indexOf((node.textContent??\"\").trim());if(k>=0){setIndex(k);setTick(n=>n+1);setUserTook(true);stop(group);return true;}node=node.parentElement;}return false;};// The tabs are canvas frames with no tab stop, so give each label's\n// frame one; Enter and Space then reach select() like a click does.\nuseEffect(()=>{const root=ref.current;if(!root)return;root.querySelectorAll(\"p, span\").forEach(el=>{const label=(el.textContent??\"\").trim();if(!tabs.includes(label))return;const host=el.parentElement?.parentElement;if(!host||(host.textContent??\"\").trim()!==label)return;host.tabIndex=0;host.setAttribute(\"role\",\"button\");host.setAttribute(\"aria-pressed\",String(label===tabs[index]));});},[index]);const onKeyDown=e=>{if((e.key===\"Enter\"||e.key===\" \")&&select(e.target))e.preventDefault();};// Keyboard focus holds it while someone tabs through; a mouse click also\n// focuses the tab, so only :focus-visible counts.\nconst onFocus=e=>{if(e.target.matches?.(\":focus-visible\"))setFocused(true);};const onBlur=e=>{if(!ref.current?.contains(e.relatedTarget))setFocused(false);};const{style,...rest}=props;const inner=fill?{width:\"100%\",height:\"100%\"}:{width:\"100%\"};return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style},onPointerDownCapture:e=>select(e.target),onKeyDownCapture:onKeyDown,onFocusCapture:onFocus,onBlurCapture:onBlur,children:/*#__PURE__*/_jsx(Component,{...rest,style:inner,variant:tabs[index]})});};}export function withAutoAdvance(Component){return autoAdvance(Component,STACK_TABS,4e3,false,\"stack\");}// The hero instance has a fixed height, so the component fills the wrapper.\nexport function withHeroAutoAdvance(Component){return autoAdvance(Component,HERO_TABS,4e3,true,\"hero\");}function timerBar(Component,group){return props=>{const[hidden,setHidden]=useState(!!stopped[group]);useEffect(()=>{const l=()=>setHidden(!!stopped[group]);listeners.add(l);return()=>{listeners.delete(l);};},[]);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,opacity:hidden?0:props.style?.opacity}});};}// Applied to the coral timer bars inside each section's component.\nexport function withStackTimerBar(Component){return timerBar(Component,\"stack\");}export function withHeroTimerBar(Component){return timerBar(Component,\"hero\");}// A slow push-in on the hero photos. Framer's loop effect also animates\n// opacity, which would fade in the venue photos the variants keep at 0, so\n// this drives scale alone.\nexport function withSlowPushIn(Component){return props=>{const scale=useMotionValue(1);const reduceMotion=useReducedMotion();useEffect(()=>{if(reduceMotion)return;const controls=animate(scale,1.04,{duration:12,ease:\"easeInOut\",repeat:Infinity,repeatType:\"mirror\"});return()=>controls.stop();},[reduceMotion]);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,scale}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSlowPushIn\":{\"type\":\"reactHoc\",\"name\":\"withSlowPushIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withStackTimerBar\":{\"type\":\"reactHoc\",\"name\":\"withStackTimerBar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAutoAdvance\":{\"type\":\"reactHoc\",\"name\":\"withAutoAdvance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHeroTimerBar\":{\"type\":\"reactHoc\",\"name\":\"withHeroTimerBar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHeroAutoAdvance\":{\"type\":\"reactHoc\",\"name\":\"withHeroAutoAdvance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StackAutoAdvance.map"],"mappings":"A,+LAkBwG,SAASY,EAAS,EAAU,EAAM,CAAC,MAAO,IAAO,CAAC,GAAK,CAACC,EAAOC,GAAWd,EAAS,CAAC,CAACe,EAAQC,EAAM,EAAiH,OAA/GT,MAAc,CAAC,IAAMU,MAAMH,EAAU,CAAC,CAACC,EAAQC,EAAM,EAAmB,OAAjBE,EAAU,IAAID,CAAC,MAAY,CAACC,EAAU,OAAOD,CAAC,CAAE,CAAE,EAAE,CAAC,CAAC,EAAsB,gBAAKE,EAAU,CAAC,GAAGC,EAAM,MAAM,CAAC,GAAGA,EAAM,MAAM,QAAQP,EAAO,EAAEO,EAAM,OAAO,OAAO,CAAC,CAAC,CAAE,CAAE,CAC1a,SAAgBC,EAAkB,EAAU,CAAC,OAAOT,EAASO,EAAU,OAAO,CAAE,CAGhF,SAAgBG,EAAe,EAAU,CAAC,MAAO,IAAO,CAAC,IAAMC,EAAMd,EAAe,CAAC,EAAQe,EAAahB,EAAiB,EAA0L,OAAxLD,MAAc,CAAC,GAAGiB,EAAa,OAAO,IAAMC,EAASf,EAAQa,EAAM,KAAK,CAAC,SAAS,GAAG,KAAK,YAAY,OAAO,IAAS,WAAW,QAAQ,CAAC,EAAE,UAAUE,EAAS,KAAK,CAAE,EAAE,CAACD,CAAY,CAAC,EAAsB,gBAAKL,EAAU,CAAC,GAAGC,EAAM,MAAM,CAAC,GAAGA,EAAM,MAAM,OAAK,CAAC,CAAC,CAAE,CAAE,C,sDApB7X,EAAQ,CAAC,EAAQ,kBAAU,IAAI,G"}