{"version":3,"file":"RandomTestimonialsOverride.DPvdICH9.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/fae9x73r77YWM8h3so0n/PG6n67zGUja1E9Mgibi8/RandomTestimonialsOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef}from\"react\";// User request: Create/recreate withRandomTestimonials override that picks exactly 3 random testimonial cards on mount, hides the rest, uses a display:contents wrapper ref anchor, applies a direct-children container heuristic, and re-applies via debounced MutationObserver without resize-based rerandomization.\nconst INITIAL_APPLY_DELAY_MS=40;const MUTATION_DEBOUNCE_MS=80;const VISIBLE_COUNT=3;function createShuffledIndices(length){const indices=Array.from({length},(_,index)=>index);for(let i=indices.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[indices[i],indices[j]]=[indices[j],indices[i]];}return indices;}function getContainerWithMostDirectChildren(root){const allCandidates=[root,...Array.from(root.querySelectorAll(\"*\"))];let bestMatch=null;let bestCount=0;for(const candidate of allCandidates){const directChildren=Array.from(candidate.children).filter(node=>node instanceof HTMLElement);const count=directChildren.length;if(count>bestCount){bestCount=count;bestMatch=candidate;}}return bestCount>0?bestMatch:null;}export function withRandomTestimonials(Component){return /*#__PURE__*/forwardRef(function WithRandomTestimonials(props,ref){const wrapperRef=useRef(null);const mutationTimeoutRef=useRef(undefined);const selectedIndicesRef=useRef(null);const selectedCountRef=useRef(null);const setForwardedRef=useCallback(node=>{if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);const applyRandomVisibility=useCallback(()=>{const root=wrapperRef.current;if(!root)return;const container=getContainerWithMostDirectChildren(root);if(!container)return;const cards=Array.from(container.children).filter(node=>node instanceof HTMLElement);if(cards.length===0)return;const visibleLimit=Math.min(VISIBLE_COUNT,cards.length);const shouldRegenerateSelection=!selectedIndicesRef.current||selectedIndicesRef.current.length!==visibleLimit||selectedCountRef.current!==cards.length;if(shouldRegenerateSelection){selectedIndicesRef.current=createShuffledIndices(cards.length).slice(0,visibleLimit);selectedCountRef.current=cards.length;}const selectedSet=new Set(selectedIndicesRef.current??[]);cards.forEach((card,index)=>{card.style.display=selectedSet.has(index)?\"\":\"none\";});},[]);useEffect(()=>{if(typeof window===\"undefined\")return;const microtaskId=window.setTimeout(()=>{applyRandomVisibility();},0);const timeoutId=window.setTimeout(()=>{applyRandomVisibility();},INITIAL_APPLY_DELAY_MS);return()=>{window.clearTimeout(microtaskId);window.clearTimeout(timeoutId);};},[applyRandomVisibility]);useEffect(()=>{if(typeof window===\"undefined\")return;const root=wrapperRef.current;if(!root)return;const observer=new MutationObserver(()=>{if(mutationTimeoutRef.current!==undefined){window.clearTimeout(mutationTimeoutRef.current);}mutationTimeoutRef.current=window.setTimeout(()=>{applyRandomVisibility();},MUTATION_DEBOUNCE_MS);});observer.observe(root,{childList:true,subtree:true});return()=>{observer.disconnect();if(mutationTimeoutRef.current!==undefined){window.clearTimeout(mutationTimeoutRef.current);}};},[applyRandomVisibility]);return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{ref:setForwardedRef,...props})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withRandomTestimonials\":{\"type\":\"reactHoc\",\"name\":\"withRandomTestimonials\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RandomTestimonialsOverride.map"],"mappings":"gJACoF,SAAS,EAAsB,EAAO,CAAC,IAAM,EAAQ,MAAM,KAAK,CAAC,QAAM,GAAG,EAAE,IAAQ,CAAK,EAAE,IAAI,IAAI,EAAE,EAAQ,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,IAAM,EAAE,KAAK,MAAM,KAAK,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,EAAQ,GAAG,EAAQ,IAAI,CAAC,EAAQ,GAAG,EAAQ,EAAE,CAAE,CAAC,OAAO,CAAQ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