{"version":3,"file":"RandomCollection.BbXUVlNg.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/j8U5BGmcx6wYvh7husW6/U9vmYX0zDZtz999aDBu4/Utlis.js","https:/framer.com/m/Utlis-SwIN.js@U9vmYX0zDZtz999aDBu4","https:/framerusercontent.com/modules/xAd1LKohiF1easgr2BFb/eG4yeCgFAQEKJGwWdSl0/RandomCollection.js"],"sourcesContent":["// new utils\nexport const findQueryInProps=obj=>{if(obj==null)return null;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return obj.query;// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){let result=findQueryInProps(obj[key]);if(result!==null)return result;}}// If `query` is not found\nreturn null;};export const updateQueryInProps=(obj,newQuery)=>{if(obj==null)return obj;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return{...obj,query:newQuery};// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){const updatedChild=updateQueryInProps(obj[key],newQuery);if(updatedChild!==obj[key]){return{...obj,[key]:updatedChild};}}}return obj;};export const findPropsBeforeQuery=obj=>{if(obj==null)return null;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return obj;// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){let result=findPropsBeforeQuery(obj[key]);if(result!==null)return result;}}// If `query` is not found\nreturn null;};\nexport const __FramerMetadata__ = {\"exports\":{\"findQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"findPropsBeforeQuery\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utlis.map","/*\n * Utlis\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/j8U5BGmcx6wYvh7husW6/U9vmYX0zDZtz999aDBu4/Utlis.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useEffect,useState}from\"react\";import{findPropsBeforeQuery}from\"https://framer.com/m/Utlis-SwIN.js@U9vmYX0zDZtz999aDBu4\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight auto\n */export default function RandomCMSItemsDisplay(props){var _collectionList_;const{collectionList,maxItems,layoutDirection,itemSpacing,wrap,sizing,fixedWidth,cycle,cycleInterval}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const clProps=!isCanvas?findPropsBeforeQuery(collectionList===null||collectionList===void 0?void 0:(_collectionList_=collectionList[0])===null||_collectionList_===void 0?void 0:_collectionList_.props):undefined;const data=(clProps===null||clProps===void 0?void 0:clProps.query)?useQueryData(clProps.query):[];const[renderedItems,setRenderedItems]=useState([]);useEffect(()=>{const fetchData=()=>{if(data){const randomItems=getRandomItems(clProps===null||clProps===void 0?void 0:clProps.children(data).props.children,maxItems);const styledItems=randomItems.map((item,index)=>/*#__PURE__*/_jsx(\"div\",{style:{marginRight:layoutDirection===\"horizontal\"?itemSpacing:0,marginBottom:wrap&&layoutDirection===\"horizontal\"?itemSpacing:layoutDirection===\"vertical\"?itemSpacing:0,width:sizing===\"fixed\"?fixedWidth:\"100%\",boxSizing:sizing===\"fixed\"?\"border-box\":undefined,minWidth:50,minHeight:50},children:/*#__PURE__*/cloneElement(item,{style:{...item.props.style}})},index));setRenderedItems(styledItems);}else{setRenderedItems([]);}};!isCanvas&&fetchData();const intervalId=cycle?setInterval(fetchData,cycleInterval*1e3):null;return()=>{if(intervalId){clearInterval(intervalId);}};},[collectionList,maxItems,layoutDirection,itemSpacing,wrap,sizing,fixedWidth,cycle,cycleInterval]);const containerStyle={...props.style,display:isCanvas?\"flex\":layoutDirection===\"horizontal\"?\"flex\":\"block\",flexDirection:isCanvas?\"column\":layoutDirection===\"horizontal\"?\"row\":undefined,justifyContent:isCanvas?\"center\":undefined,alignItems:isCanvas?\"center\":undefined,flexWrap:wrap?\"wrap\":\"nowrap\"};if(isCanvas){containerStyle.padding=10;containerStyle.border=\"1px dashed #594FEE\";containerStyle.borderRadius=\"8px\";containerStyle.backgroundColor=\"#EEEDFD\";}return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:isCanvas?renderedItems.length>0?renderedItems:/*#__PURE__*/_jsx(\"div\",{style:{color:\"#594FEE\",padding:\"20px\",textAlign:\"center\",fontFamily:\"Arial, sans-serif\"},children:\"CMS Random Items - Connect, configure & preview to see the component\"}):renderedItems.length>0?renderedItems:/*#__PURE__*/_jsx(\"div\",{children:\"Connect, configure and preview\"})});}RandomCMSItemsDisplay.displayName=\"Random CMS Items Display\";addPropertyControls(RandomCMSItemsDisplay,{collectionList:{type:ControlType.ComponentInstance},maxItems:{type:ControlType.Number,defaultValue:1,min:1},layoutDirection:{type:ControlType.Enum,defaultValue:\"vertical\",options:[\"vertical\",\"horizontal\"],displaySegmentedControl:true,segmentedControlDirection:\"horizontal\"},itemSpacing:{type:ControlType.Number,defaultValue:0,min:0},wrap:{type:ControlType.Boolean,defaultValue:false},sizing:{type:ControlType.Enum,defaultValue:\"fill\",options:[\"fill\",\"fixed\"],displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",description:\"Please ensure that the connected CMS is vertically stacked\"},fixedWidth:{type:ControlType.Number,defaultValue:100,min:0,hidden:props=>props.sizing!==\"fixed\"},cycle:{type:ControlType.Boolean,defaultValue:false,title:\"Cycle\",enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"v2.0 \\n[via SegmentUI](https://www.segmentUI.com)\"},cycleInterval:{type:ControlType.Number,defaultValue:5,min:1,hidden:props=>!props.cycle}});function getRandomItems(items,maxItems){if(!items||items.length===0){return[];}const shuffledItems=items.sort(()=>.5-Math.random());return shuffledItems.slice(0,maxItems);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RandomCMSItemsDisplay\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"600\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RandomCollection.map"],"mappings":"wNAMgO,EAAqB,GAAK,CAAC,GAAG,GAAK,KAAK,OAAO,KAC/Q,GAAG,EAAI,eAAe,QAAQ,CAAC,OAAO,EACtC,IAAI,IAAI,KAAO,EAAK,GAAG,EAAI,eAAe,EAAI,EAAE,OAAO,EAAI,IAAO,SAAS,CAAC,IAAI,EAAO,EAAqB,EAAI,GAAK,CAAC,GAAG,IAAS,KAAK,OAAO,EAC9I,OAAO,0BEFJ,SAAwB,EAAsB,EAAM,CAAsB,GAAK,CAAC,iBAAe,WAAS,kBAAgB,cAAY,OAAK,SAAO,aAAW,QAAM,iBAAe,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAS,EAA0L,IAAA,GAAjL,EAAqB,IAAuF,IAA8D,MAAM,CAAiB,EAAM,GAAgD,MAAO,EAAa,EAAQ,MAAM,CAAC,EAAE,CAAM,CAAC,EAAc,GAAkBA,EAAS,EAAE,CAAC,CAAC,MAAc,CAAC,IAAM,MAAc,CAA0jB,EAAtjB,EAAwB,EAAe,GAAgD,SAAS,EAAK,CAAC,MAAM,SAAS,EAAS,CAA+B,KAAK,EAAK,IAAqB,EAAK,MAAM,CAAC,MAAM,CAAC,YAAY,IAAkB,aAAa,EAAY,EAAE,aAAa,GAAM,IAAkB,cAAyB,IAAkB,WAA9B,EAAqD,EAAE,MAAM,IAAS,QAAQ,EAAW,OAAO,UAAU,IAAS,QAAQ,aAAa,IAAA,GAA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