{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/xAd1LKohiF1easgr2BFb/eG4yeCgFAQEKJGwWdSl0/RandomCollection.js"],
  "sourcesContent": ["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": "iKAOkB,SAARA,EAAuCC,EAAM,CAAC,IAAIC,EAAiB,GAAK,CAAC,eAAAC,EAAe,SAAAC,EAAS,gBAAAC,EAAgB,YAAAC,EAAY,KAAAC,EAAK,OAAAC,EAAO,WAAAC,EAAW,MAAAC,EAAM,cAAAC,CAAa,EAAEV,EAAYW,EAASC,EAAa,QAAQ,IAAIA,EAAa,OAAaC,EAASF,EAA0L,OAAjLG,EAAqBZ,GAAiB,OAAsCD,EAAiBC,EAAe,CAAC,KAAK,MAAMD,IAAmB,OAAvE,OAAqFA,EAAiB,KAAK,EAAkBc,EAA8CF,GAAQ,MAAOG,EAAaH,EAAQ,KAAK,EAAE,CAAC,EAAO,CAACI,EAAcC,CAAgB,EAAEC,EAAS,CAAC,CAAC,EAAEC,EAAU,IAAI,CAAC,IAAMC,EAAU,IAAI,CAAC,GAAGN,EAAK,CAA0H,IAAMO,EAA7GC,EAAuDV,GAAQ,SAASE,CAAI,EAAE,MAAM,SAASZ,CAAQ,EAAgC,IAAI,CAACqB,EAAKC,IAAqBC,EAAK,MAAM,CAAC,MAAM,CAAC,YAAYtB,IAAkB,aAAaC,EAAY,EAAE,aAAaC,GAAMF,IAAkB,cAAyBA,IAAkB,WAA9BC,EAAqD,EAAE,MAAME,IAAS,QAAQC,EAAW,OAAO,UAAUD,IAAS,QAAQ,aAAa,OAAU,SAAS,GAA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AE,wBAAwB,GAAK,0BAA0B,YAAY,EAAE,YAAY,CAAC,KAAKA,EAAY,OAAO,aAAa,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,KAAKA,EAAY,QAAQ,aAAa,EAAK,EAAE,OAAO,CAAC,KAAKA,EAAY,KAAK,aAAa,OAAO,QAAQ,CAAC,OAAO,OAAO,EAAE,wBAAwB,GAAK,0BAA0B,aAAa,YAAY,4DAA4D,EAAE,WAAW,CAAC,KAAKA,EAAY,OAAO,aAAa,IAAI,IAAI,EAAE,OAAO/B,GAAOA,EAAM,SAAS,OAAO,EAAE,MAAM,CAAC,KAAK+B,EAAY,QAAQ,aAAa,GAAM,MAAM,QAAQ,aAAa,MAAM,cAAc,KAAK,YAAY;AAAA,2CAAmD,EAAE,cAAc,CAAC,KAAKA,EAAY,OAAO,aAAa,EAAE,IAAI,EAAE,OAAO/B,GAAO,CAACA,EAAM,KAAK,CAAC,CAAC,EAAE,SAASuB,EAAeS,EAAM7B,EAAS,CAAC,MAAG,CAAC6B,GAAOA,EAAM,SAAS,EAAS,CAAC,EAAuBA,EAAM,KAAK,IAAI,GAAG,KAAK,OAAO,CAAC,EAAuB,MAAM,EAAE7B,CAAQ,CAAE",
  "names": ["RandomCMSItemsDisplay", "props", "_collectionList_", "collectionList", "maxItems", "layoutDirection", "itemSpacing", "wrap", "sizing", "fixedWidth", "cycle", "cycleInterval", "isCanvas", "RenderTarget", "clProps", "findPropsBeforeQuery", "data", "useQueryData", "renderedItems", "setRenderedItems", "ye", "ue", "fetchData", "styledItems", "getRandomItems", "item", "index", "p", "q", "intervalId", "containerStyle", "addPropertyControls", "ControlType", "items"]
}
