{"version":3,"file":"RandomlyChooseOneFromCMS.DGvnWU76.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/dbbZgQBGJKUwbiFtrKLZ/r41Wf19bdxWFp6uLT9iO/RandomlyChooseOneFromCMS.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";export const withShuffledItems=Component=>{const ShuffledComponent=props=>{const componentRef=useRef(null);const shuffleAndDisplayItems=()=>{const container=componentRef.current;if(!container)return;//hide first to avoid flash of content\ncontainer.style.opacity=0;// Find all direct child elements of the CMS collection\nconst childElements=Array.from(container.children);// If there are no children or only one child, do nothing\nif(childElements.length<=1)return;// Randomly select an index to keep visible\nconst visibleIndex=Math.floor(Math.random()*childElements.length);// Apply visibility styles to all children\nchildElements.forEach((child,index)=>{if(child instanceof HTMLElement){let childCurrentDisplay=child.style.display;child.style.display=index===visibleIndex?childCurrentDisplay:\"none\";}});// show container now that it's trimmed to single item\ncontainer.style.opacity=1;};useEffect(()=>{shuffleAndDisplayItems()// Shuffle and display items on component mount\n;},[])// Empty dependency array ensures this runs once after the initial render\n;return /*#__PURE__*/_jsx(Component,{ref:componentRef,...props});};return ShuffledComponent;};\nexport const __FramerMetadata__ = {\"exports\":{\"withShuffledItems\":{\"type\":\"reactHoc\",\"name\":\"withShuffledItems\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RandomlyChooseOneFromCMS.map"],"mappings":"2LAA4F,EAAkB,GAAW,CAAC,IAAM,EAAkB,GAAO,CAAC,IAAM,EAAaA,EAAO,MAAY,MAA2B,CAAC,IAAM,EAAU,EAAa,QAAQ,GAAG,CAAC,EAAU,OAC/Q,EAAU,MAAM,QAAQ,EACxB,IAAM,EAAc,MAAM,KAAK,EAAU,UACzC,GAAG,EAAc,QAAQ,EAAE,OAC3B,IAAM,EAAa,KAAK,MAAM,KAAK,SAAS,EAAc,QAC1D,EAAc,SAAS,EAAM,IAAQ,CAAC,GAAG,aAAiB,YAAY,CAAC,IAAI,EAAoB,EAAM,MAAM,QAAQ,EAAM,MAAM,QAAQ,IAAQ,EAAa,EAAoB,MAAQ,CAAC,GACzL,EAAU,MAAM,QAAQ,CAAG,EAE1B,OAF2B,MAAc,CAAC,GACzC,EAAC,EAAE,EACgB,EAAK,EAAU,CAAC,IAAI,EAAa,GAAG,EAAM,CAAG,EAAC,OAAO,CAAmB"}