{"version":3,"file":"CMSAutoHide_v07.KPMVm_eh.mjs","names":["useRef"],"sources":["https:/framer.com/m/CMSLibrary-09eo.js","https:/framerusercontent.com/modules/XcP5LiiHqt34ThbShkmm/ZyHSjVEMXL9TLa1p61rw/CMSAutoHide_v07.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 * @framerDisableUnlink\n * @framerIntrinsicWidth 40\n * @framerIntrinsicHeight 40\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{useEffect,useRef}from\"react\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";export default function CMSHideEmptyFrame(props){const{collectionList,visibilityMode,viewMode}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const ref=useRef(null);let totalItems=0;if(!isCanvas&&Array.isArray(collectionList)&&collectionList.length>0){const counts=collectionList.map(collection=>{const{query}=getCollectionData(collection);const data=useQueryData(query)||[];return data.length;});totalItems=counts.reduce((sum,count)=>sum+count,0);}else{totalItems=1;}useEffect(()=>{if(isCanvas)return;const shouldHide=visibilityMode===\"hideWhenEmpty\"&&totalItems===0||visibilityMode===\"hideWhenNotEmpty\"&&totalItems>0;if(shouldHide){requestAnimationFrame(()=>{const wrapper=ref.current?.parentElement;const frameEl=wrapper?.parentElement;if(ref.current)ref.current.style.display=\"none\";if(wrapper)wrapper.style.display=\"none\";if(frameEl)frameEl.style.display=\"none\";});}},[totalItems,visibilityMode,isCanvas]);const iconSvg=visibilityMode===\"hideWhenEmpty\"?/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"24\",height:\"24\",fill:\"#9A66FF\",viewBox:\"0 0 256 256\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z\"})}):/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"24\",height:\"24\",fill:\"#9A66FF\",viewBox:\"0 0 256 256\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z\"})});// Определяем стиль и размеры в зависимости от viewMode\nlet backgroundColor=\"transparent\";let iconVisible=false;let width=1;let height=1;if(isCanvas){switch(viewMode){case\"default\":backgroundColor=\"rgba(154, 102, 255, 0.3)\";iconVisible=true;width=40;height=40;break;case\"small\":backgroundColor=\"rgba(154, 102, 255, 0.3)\";iconVisible=false;width=16;height=16;break;case\"invisible\":backgroundColor=\"transparent\";iconVisible=false;width=1;height=1;break;}}return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{width,height,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor,borderRadius:width/2,pointerEvents:\"none\"},children:isCanvas&&iconVisible&&iconSvg});}CMSHideEmptyFrame.displayName=\"CMSAutoHide v0.7\";addPropertyControls(CMSHideEmptyFrame,{collectionList:{type:ControlType.Array,title:\"CMS Collections\",control:{type:ControlType.ComponentInstance},description:\"Connect one or more CMS Collections. Visibility will depend on summed item counts.\",defaultValue:[],maxCount:10},visibilityMode:{type:ControlType.Enum,title:\"Mode\",options:[\"hideWhenEmpty\",\"hideWhenNotEmpty\"],optionTitles:[\"Content\",\"Placeholder\"],defaultValue:\"hideWhenEmpty\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",description:\"If total CMS items equals zero:\\nContent - HIDE parent frame\\nPlaceholder - SHOW parent frame\"},viewMode:{type:ControlType.Enum,title:\"View\",options:[\"default\",\"small\",\"invisible\"],optionTitles:[\"Default\",\"Small\",\"Invisible\"],defaultValue:\"default\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",description:\"Adjusts how the component is displayed on canvas.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSHideEmptyFrame\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSAutoHide_v07.map"],"mappings":"8SAAA,SAAgB,EAAkB,EAAe,CAAC,IAA+D,EAA+B,EAA2E,EAA8C,EAAsC,EAAgC,EAA0C,IAAI,EAAY,KAAQ,GAA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