{"version":3,"file":"CMS_Random.D9a67BSh.mjs","names":["p","useState","j","Children"],"sources":["https:/framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js","https:/framer.com/m/CMSLibrary-09eo.js","https:/framerusercontent.com/modules/7pd21Y2Im834dBRxFXql/LXWz0g4kw3p6vk0SYZTW/CMS_Random.js"],"sourcesContent":["export function getCollectionData(collectionList){var _collectionList_props,_collectionList_props_children_props,_collectionList_props_children,_collectionList_props1,_collectionList_props_children_props_children_props,_collectionList_props_children_props_children,_collectionList_props_children_props1,_collectionList_props_children1,_collectionList_props2,_queryParent_props;let queryParent=null;if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props=collectionList.props)===null||_collectionList_props===void 0?void 0:_collectionList_props.query){queryParent=collectionList;}else if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props1=collectionList.props)===null||_collectionList_props1===void 0?void 0:(_collectionList_props_children=_collectionList_props1.children)===null||_collectionList_props_children===void 0?void 0:(_collectionList_props_children_props=_collectionList_props_children.props)===null||_collectionList_props_children_props===void 0?void 0:_collectionList_props_children_props.query){queryParent=collectionList.props.children;}else if(collectionList===null||collectionList===void 0?void 0:(_collectionList_props2=collectionList.props)===null||_collectionList_props2===void 0?void 0:(_collectionList_props_children1=_collectionList_props2.children)===null||_collectionList_props_children1===void 0?void 0:(_collectionList_props_children_props1=_collectionList_props_children1.props)===null||_collectionList_props_children_props1===void 0?void 0:(_collectionList_props_children_props_children=_collectionList_props_children_props1.children)===null||_collectionList_props_children_props_children===void 0?void 0:(_collectionList_props_children_props_children_props=_collectionList_props_children_props_children.props)===null||_collectionList_props_children_props_children_props===void 0?void 0:_collectionList_props_children_props_children_props.query){queryParent=collectionList.props.children.props.children;}const query=queryParent===null||queryParent===void 0?void 0:(_queryParent_props=queryParent.props)===null||_queryParent_props===void 0?void 0:_queryParent_props.query;let queryData=null;if(query===null||query===void 0?void 0:query.from){if(query.from.data){queryData=query.from.data;}else if(query.from.left){let left=query.from.left;for(let i=0;i<100;i++){if(left.type==\"Collection\"){queryData=left.data;break;}else if(left.left){left=left.left;}else{break;}}}}// Get property controls\nconst propertyControlsById=(queryData===null||queryData===void 0?void 0:queryData.propertyControls)||{};const propertyControlsByName={};for(const id in propertyControlsById){const control=propertyControlsById[id];propertyControlsByName[control.title]={id,...control};}// Get children function\nlet childrenFunction=null;if(collectionList){var _collectionList_props3,_clpc_props,_clpc_props_children_props,_clpc_props_children,_clpc_props1;const clpc=(_collectionList_props3=collectionList.props)===null||_collectionList_props3===void 0?void 0:_collectionList_props3.children;if(typeof clpc==\"function\"){childrenFunction=clpc;}else if(typeof(clpc===null||clpc===void 0?void 0:(_clpc_props=clpc.props)===null||_clpc_props===void 0?void 0:_clpc_props.children)==\"function\"){childrenFunction=clpc.props.children;}else if(typeof(clpc===null||clpc===void 0?void 0:(_clpc_props1=clpc.props)===null||_clpc_props1===void 0?void 0:(_clpc_props_children=_clpc_props1.children)===null||_clpc_props_children===void 0?void 0:(_clpc_props_children_props=_clpc_props_children.props)===null||_clpc_props_children_props===void 0?void 0:_clpc_props_children_props.children)==\"function\"){childrenFunction=clpc.props.children.props.children;}}return{query,queryParent,queryData,propertyControlsById,propertyControlsByName,childrenFunction};}export function addFieldsToSelect(fields,query,propertyControlsByName){const alias=query.alias;const select=Array.isArray(query===null||query===void 0?void 0:query.select)?[...query.select]:[];for(const fieldName of fields){var _propertyControlsByName_fieldName;const fieldId=(_propertyControlsByName_fieldName=propertyControlsByName[fieldName])===null||_propertyControlsByName_fieldName===void 0?void 0:_propertyControlsByName_fieldName.id;if(!fieldId){continue;}let matchFound=false;for(const item of select){if(item.name===fieldId&&item.type===\"Identifier\"&&item.collection===alias){matchFound=true;continue;}}if(matchFound){continue;}select.push({collection:alias,name:fieldId,type:\"Identifier\"});}return select;}\nexport const __FramerMetadata__ = {\"exports\":{\"getCollectionData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"addFieldsToSelect\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSLibrary.map","/*\n * CMSLibrary\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,Children,isValidElement}from\"react\";// @ts-ignore\nimport{useQueryData}from\"framer\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";// --- utils -------------------------------------------------------------------\nfunction normalizePath(p){if(!p)return\"\";try{// handle absolute or relative hrefs\nconst url=p.startsWith(\"http\")?new URL(p):new URL(p,window.location.origin);let path=url.pathname;// strip trailing slash\nif(path.length>1&&path.endsWith(\"/\"))path=path.slice(0,-1);return path;}catch{return p.replace(/\\/+$/,\"\");}}function findHref(node){if(!/*#__PURE__*/isValidElement(node))return undefined;// direct href on the element\nif(node.props?.href)return node.props.href;// sometimes the link is nested one level down\nconst kids=node.props?.children;if(!kids)return undefined;const arr=Array.isArray(kids)?kids:[kids];for(const k of arr){const href=findHref(k);if(href)return href;}return undefined;}function sameItemAsCurrent(child,currentPath,currentId,currentSlug){const childHref=findHref(child);const childPath=normalizePath(childHref);if(childPath&&childPath===currentPath)return true;// Try common prop shapes Framer components use\nconst item=child?.props?.item??child?.props?.data;const childId=item?.id;const childSlug=item?.slug??child?.props?.slug;if(currentId&&childId&&childId===currentId)return true;if(currentSlug&&childSlug&&currentSlug===childSlug)return true;if(childSlug&&currentPath.endsWith(`/${childSlug}`))return true;return false;}// -----------------------------------------------------------------------------\n// Shuffle the children of a CMS Collection List, excluding the current page's item\nexport function ShuffleCMSCollectionList(Component){return props=>{const items=getCollectionListItems(props);// Determine the current page path once on the client\nconst currentPath=typeof window!==\"undefined\"?normalizePath(window.location.pathname):\"\";// If your environment exposes the current item's id/slug on props, put them here:\nconst currentItemId=props?.cmsItem?.id??props?.data?.id??props?.item?.id;const currentItemSlug=props?.cmsItem?.slug??props?.data?.slug??props?.slug;// Exclude the current item\nconst filtered=items.filter(child=>!sameItemAsCurrent(child,currentPath,currentItemId,currentItemSlug));const[shuffledData,setShuffledData]=useState(filtered);// If nothing to render, just return the original component\nif(!filtered?.length){return /*#__PURE__*/_jsx(Component,{...props});}useEffect(()=>{// shuffle a copy so we don't mutate the original array\nsetShuffledData(shuffleArray([...filtered]));// re-run if items change or route changes\n},[currentPath,items.length]);return /*#__PURE__*/_jsx(Component,{...props,children:shuffledData});};}function shuffleArray(array){for(let i=array.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[array[i],array[j]]=[array[j],array[i]];}return array;}export function getCollectionListItems(props){const{query,childrenFunction}=getCollectionData({props});if(query&&childrenFunction){const data=useQueryData(query);let children=[];const clChildren=childrenFunction(data);if(Array.isArray(clChildren)){children=clChildren;}else if(Array.isArray(clChildren?.props?.children?.[0])){children=clChildren.props.children[0];}else if(Array.isArray(clChildren?.props?.children)){children=clChildren.props.children;}if(children){return Children.toArray(children);}}return[];}\nexport const __FramerMetadata__ = {\"exports\":{\"ShuffleCMSCollectionList\":{\"type\":\"reactHoc\",\"name\":\"ShuffleCMSCollectionList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getCollectionListItems\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Random.map"],"mappings":"uMAAA,SAAgB,EAAkB,EAAe,CAAC,IAA+D,EAA+B,EAA2E,EAA8C,EAAsC,EAAgC,EAA0C,IAAI,EAAY,KAAQ,GAAiB,MAA4D,EAAe,OAA2E,MAAO,EAAY,EAAwB,KAAiB,OAAsC,EAAuB,EAAe,QAAS,OAA8C,EAA+B,EAAuB,WAAY,OAA2F,EAA+B,OAAyG,MAAO,EAAY,EAAe,MAAM,SAAkB,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