{"version":3,"file":"CMSRandomizeNestedCollection.BHxCKXoQ.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/o0DMUi0wfXbp0aduEzuQ/osGVX0D6ku0Ju4zBZQJa/CMSRandomizeNestedCollection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function CMSRandomizeNestedCollection(props){const{breakpoint,collectionListDesktop,hasMobileLayout,collectionListMobile,randomize,shouldLimit,limit}=props;/* Checks */const currentTarget=RenderTarget.current();const isCanvas=currentTarget===RenderTarget.canvas||currentTarget===RenderTarget.export;const collectionList=hasMobileLayout?breakpoint===\"mobile\"?collectionListMobile?.[0]:collectionListDesktop?.[0]:collectionListDesktop?.[0];const[items,setItems]=useState([]);useEffect(()=>{if(isCanvas)return;// console.log(\"collectionList\", collectionList)\nlet finalItems=collectionList.props.children;if(randomize){finalItems=shuffleArray(finalItems);}if(shouldLimit&&limit>0){finalItems=finalItems.slice(0,limit);}setItems(finalItems);},[]);return /*#__PURE__*/_jsx(\"div\",{className:collectionList?.props?.className,style:{width:\"100%\"},children:!isCanvas?items:collectionList});}addPropertyControls(CMSRandomizeNestedCollection,{breakpoint:{type:ControlType.Enum,title:\"Breakpoint\",options:[\"desktop\",\"tablet\",\"mobile\"],optionTitles:[\"Desktop\",\"Tablet\",\"Mobile\"],defaultValue:\"desktop\"},collectionListDesktop:{type:ControlType.ComponentInstance,title:\"CMS Collection Big Layout\"},hasMobileLayout:{type:ControlType.Boolean,title:\"Has Mobile Layout\",defaultValue:false},collectionListMobile:{type:ControlType.ComponentInstance,title:\"CMS Collection Mobile Layout\",hidden(props){return!props.hasMobileLayout;}},randomize:{type:ControlType.Boolean,title:\"Randomize\",defaultValue:false},shouldLimit:{type:ControlType.Boolean,title:\"Limit\",defaultValue:false},limit:{type:ControlType.Number,title:\"Max\",defaultValue:20,min:0,hidden(props){return!props.shouldLimit;}}});function shuffleArray(array){return array.map(value=>({value,sort:Math.random()})).sort((a,b)=>a.sort-b.sort).map(({value})=>value);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSRandomizeNestedCollection\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSRandomizeNestedCollection.map"],"mappings":"yLAGG,SAAwB,EAA6B,EAAM,CAAC,GAAK,CAAC,aAAW,wBAAsB,kBAAgB,uBAAqB,YAAU,cAAY,SAAO,EAAwB,EAAc,EAAa,SAAS,CAAO,EAAS,IAAgB,EAAa,QAAQ,IAAgB,EAAa,OAAa,EAAe,GAAgB,IAAa,SAAS,IAAuB,GAAG,IAAwB,GAAmC,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAC,CAChT,OADiT,MAAc,CAAC,GAAG,EAAS,OACtgB,IAAI,EAAW,EAAe,MAAM,SAAY,IAAW,EAAW,EAAa,EAAW,EAAK,GAAa,EAAM,IAAG,EAAW,EAAW,MAAM,EAAE,EAAM,EAAE,EAAS,EAAW,EAAG,EAAE,CAAC,CAAqB,EAAK,MAAM,CAAC,UAAU,GAAgB,OAAO,UAAU,MAAM,CAAC,MAAM,OAAO,CAAC,SAAU,EAAe,EAAN,EAAqB,CAAC,CAAkxB,SAAS,EAAa,EAAM,CAAC,OAAO,EAAM,IAAI,IAAQ,CAAC,QAAM,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAS,EAAM,kBAJ7qC,IAAsC,IAAiE,CAImL,EAAoB,EAA6B,CAAC,WAAW,CAAC,KAAK,EAAY,KAAK,MAAM,aAAa,QAAQ,CAAC,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