{"version":3,"file":"CMSRandomizeNestedCollection.BbTEo194.mjs","names":["useState","__esmMin","init_npm_react_18_3_1","init_jsx_runtime","c","ce","_e","addPropertyControls","ControlType","init_framer_BWFVvmND","RenderTarget","CMSRandomizeNestedCollection","props","currentTarget","isCanvas","collectionList","hasMobileLayout","breakpoint","collectionListMobile","collectionListDesktop","items","setItems","finalItems","randomize","shuffleArray","shouldLimit","limit","array","a","b","value","init_CMSRandomizeNestedCollection"],"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":"A,0LAGG,SAAwBW,EAA6B,EAAM,CAAC,GAAK,CAAC,aAAW,wBAAsB,kBAAgB,uBAAqB,YAAU,cAAY,SAAOC,EAAwBC,EAAcH,EAAa,QAAQ,EAAQI,EAASD,IAAgBH,EAAa,QAAQG,IAAgBH,EAAa,OAAaK,EAAeC,GAAgBC,IAAa,SAASC,IAAuB,GAA8BC,IAAwB,GAAQ,CAACC,EAAMC,GAAUrB,EAAS,CAAC,CAAC,EAC/S,OADiTK,MAAc,CAAC,GAAGS,EAAS,OACtgB,IAAIQ,EAAWP,EAAe,MAAM,SAAYQ,IAAW,EAAWC,EAAaF,CAAU,GAAMG,GAAaC,EAAM,IAAG,EAAWJ,EAAW,MAAM,EAAEI,CAAK,GAAGL,EAASC,CAAU,CAAE,EAAE,CAAC,CAAC,EAAsB,gBAAK,MAAM,CAAC,UAAUP,GAAgB,OAAO,UAAU,MAAM,CAAC,MAAM,MAAM,EAAE,SAAUD,EAAeC,EAANK,CAAoB,CAAC,CAAE,C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