{"version":3,"file":"LoopControl-3S4jnt.D707_CZT.mjs","names":["useRef","useState","startTransition","__esmMin","init_npm_react_18_3_1","te","window","_e","de","p","c","init_jsx_runtime","ce","init_ssg_sandbox_shims","addPropertyControls","init_framer_DcGZRLrs","ControlType","claimHero","w","path","owner","id","useAutoCycle","startIndex","idRef","isHero","setIsHero","index","setIndexState","ticks","setTicks","hover","setHover","focus","setFocus","userPaused","setUserPaused","active","effectiveRounds","rounds","toRest","restIndex","count","limit","done","running","t","i","n","holdMs","PauseButton","label","state","onToggle","style","color","nextId","init_LoopControl","init_LoopControl_3S4jnt"],"sources":["https:/framerusercontent.com/modules/dmHoSbTAuymUgEQMDuEs/a4BUWtReZ2O4iZGLAiQ4/LoopControl.js","https:/framer.com/m/LoopControl-3S4jnt.js"],"sourcesContent":["// Shared loop control for the self-playing Workspace demos. Loops pause while hovered, while focused (keyboard), and\n// while off-screen, and a visible pause / play / replay button makes them controllable on touch and keyboard\n// (WCAG 2.2.2). The button's hit area is 44 × 44px; the visible circle stays 30px.\n// Motion budget (impeccable quieter): one authored moment per page. The first demo on a page that starts playing\n// (the hero, at the top) may run the rounds it asks for; every later demo on the same page plays through once and then\n// rests on its chosen state. The claim is kept on window per pathname, so it works across separately loaded modules.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";let nextId=1;function claimHero(id){if(typeof window===\"undefined\")return true;const w=window;const path=window.location?.pathname||\"/\";w.__gxLoopClaims=w.__gxLoopClaims||{};const owner=w.__gxLoopClaims[path];if(owner===undefined||owner===id){w.__gxLoopClaims[path]=id;return true;}return false;}export function useAutoCycle({count,holdMs,active,rounds=2,startIndex=0,restIndex=startIndex}){const idRef=useRef(0);if(!idRef.current)idRef.current=nextId++;const[isHero,setIsHero]=useState(null);const[index,setIndexState]=useState(startIndex);const[ticks,setTicks]=useState(0);const[hover,setHover]=useState(false);const[focus,setFocus]=useState(false);const[userPaused,setUserPaused]=useState(false);// Decide once, when this demo first starts playing, whether it is the page's hero loop.\nuseEffect(()=>{if(active&&isHero===null)setIsHero(claimHero(idRef.current));},[active,isHero]);const effectiveRounds=isHero===false?1:rounds;const toRest=(restIndex-startIndex+count)%count;const limit=(effectiveRounds-1)*count+(toRest===0?count:toRest);const done=ticks>=limit;const running=active&&isHero!==null&&!hover&&!focus&&!userPaused&&!done;useEffect(()=>{if(!running)return;const t=window.setTimeout(()=>startTransition(()=>{setIndexState(i=>(i+1)%count);setTicks(n=>n+1);}),holdMs(index));return()=>window.clearTimeout(t);},[running,index,ticks,count]);const setIndex=i=>startTransition(()=>{setIndexState(i);setTicks(n=>n+(n>=limit?0:1));});const toggle=()=>startTransition(()=>{if(done){setTicks(0);setIndexState(startIndex);setUserPaused(false);}else setUserPaused(p=>!p);});const bind={onMouseEnter:()=>setHover(true),onMouseLeave:()=>setHover(false),onFocus:()=>setFocus(true),onBlur:e=>{if(!e.currentTarget.contains(e.relatedTarget))setFocus(false);}};const state=done?\"done\":userPaused?\"paused\":\"playing\";return{index,setIndex,ticks,running,state,toggle,bind};}/**\n * Pause Button\n *\n * @framerIntrinsicWidth 44\n * @framerIntrinsicHeight 44\n */export default function PauseButton({state=\"playing\",onToggle,color=\"#15397A\",style}){const label=state===\"playing\"?\"Pause animation\":state===\"paused\"?\"Play animation\":\"Replay animation\";return /*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:onToggle,\"aria-label\":label,title:label,style:{...style,cursor:\"pointer\",width:44,height:44,flex:\"0 0 auto\",border:\"none\",background:\"transparent\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",padding:0,margin:-2},children:/*#__PURE__*/_jsxs(\"span\",{style:{width:30,height:30,borderRadius:\"50%\",boxShadow:\"inset 0 0 0 1px rgba(21,57,122,0.22)\",background:\"#FFFFFF\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\"},children:[state===\"playing\"&&/*#__PURE__*/_jsxs(\"svg\",{width:\"11\",height:\"11\",viewBox:\"0 0 24 24\",fill:color,\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"rect\",{x:\"5\",y:\"4\",width:\"5\",height:\"16\",rx:\"1.5\"}),/*#__PURE__*/_jsx(\"rect\",{x:\"14\",y:\"4\",width:\"5\",height:\"16\",rx:\"1.5\"})]}),state===\"paused\"&&/*#__PURE__*/_jsx(\"svg\",{width:\"11\",height:\"11\",viewBox:\"0 0 24 24\",fill:color,\"aria-hidden\":\"true\",style:{marginLeft:2},children:/*#__PURE__*/_jsx(\"path\",{d:\"M7 4.5v15a1 1 0 0 0 1.5.86l12-7.5a1 1 0 0 0 0-1.72l-12-7.5A1 1 0 0 0 7 4.5z\"})}),state===\"done\"&&/*#__PURE__*/_jsxs(\"svg\",{width:\"12\",height:\"12\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:color,strokeWidth:\"2.6\",strokeLinecap:\"round\",strokeLinejoin:\"round\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M3 12a9 9 0 1 0 3-6.7L3 8\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M3 3v5h5\"})]})]})});}addPropertyControls(PauseButton,{state:{type:ControlType.Enum,title:\"State\",options:[\"playing\",\"paused\",\"done\"],defaultValue:\"playing\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#15397A\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"useAutoCycle\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"PauseButton\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"44\",\"framerIntrinsicWidth\":\"44\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoopControl.map","/*\n * LoopControl\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/dmHoSbTAuymUgEQMDuEs/a4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