{"version":3,"file":"CMSCounter.xnRE2w8U.mjs","names":[],"sources":["https:/framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js","https:/framer.com/m/CMSLibrary-09eo.js","https:/framerusercontent.com/modules/vUwfrXl0thYoNrUeE6tG/cLcl65GMwIpNcJKfwcAE/CMSCounter.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 * CMSLibrary\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js\"\n","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,useQueryData}from\"framer\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";function formatNumber(value,commas){let numberString=Number(value).toFixed(0);if(commas)numberString=numberString.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return numberString;}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CMSCounter(props){const{transform}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const collectionList=props.collectionList?.[0];const{query}=getCollectionData(collectionList);// Preview shows placeholder. Live uses the query length.\nlet items=props.placeholder;if(query&&!isCanvas){items=useQueryData(query)?.length??props.placeholder;}// Prefix and suffix logic\nconst pluralMode=Boolean(transform?.plural);const prefix=pluralMode?(items===1?transform?.singularPrefix:transform?.pluralPrefix)||\"\":transform?.prefix||\"\";const suffix=pluralMode?(items===1?transform?.singularSuffix:transform?.pluralSuffix)||\"\":transform?.suffix||\"\";// Intrinsic sizing for Stacks set to Fit\nconst{width,height,...restStyle}=props.style||{};const hasW=width!=null;const hasH=height!=null;return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-flex\",alignItems:\"baseline\",boxSizing:\"border-box\",userSelect:props.textSelect?\"auto\":\"none\",color:props.fontColor,...props.font||{},...restStyle,...hasW?{width}:{width:\"fit-content\"},...hasH?{height}:{height:\"fit-content\"},whiteSpace:hasW?\"normal\":\"nowrap\",margin:0},children:[/*#__PURE__*/_jsx(\"span\",{children:prefix}),/*#__PURE__*/_jsx(\"span\",{children:formatNumber(items,props.commas)}),/*#__PURE__*/_jsx(\"span\",{children:suffix})]});}CMSCounter.displayName=\"CMS Item Counter\";addPropertyControls(CMSCounter,{collectionList:{type:ControlType.ComponentInstance},placeholder:{type:ControlType.Number,defaultValue:10,min:0,step:1,description:\"Placeholder number is shown in the editor.\"},commas:{type:ControlType.Boolean,defaultValue:true},fontColor:{type:ControlType.Color,defaultValue:\"#000000\"},font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1}},transform:{type:ControlType.Object,optional:true,controls:{plural:{type:ControlType.Boolean,defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,hidden(props){return props.plural;}},suffix:{type:ControlType.String,hidden(props){return props.plural;}},singularPrefix:{type:ControlType.String,placeholder:\"Singular Prefix\",hidden(props){return!props.plural;}},singularSuffix:{type:ControlType.String,placeholder:\"Singular Suffix\",hidden(props){return!props.plural;}},pluralPrefix:{type:ControlType.String,placeholder:\"Plural Prefix\",hidden(props){return!props.plural;}},pluralSuffix:{type:ControlType.String,placeholder:\"Plural Suffix\",hidden(props){return!props.plural;}}}},textSelect:{type:ControlType.Boolean,defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSCounter.map"],"mappings":"6KAAA,SAAgB,EAAkB,EAAe,CAAC,IAA+D,EAA+B,EAA2E,EAA8C,EAAsC,EAAgC,EAA0C,IAAI,EAAY,KAAQ,GAAiB,MAA4D,EAAe,OAA2E,MAAO,EAAY,EAAwB,KAAiB,OAAsC,EAAuB,EAAe,QAAS,OAA8C,EAA+B,EAAuB,WAAY,OAA2F,EAA+B,OAAyG,MAAO,EAAY,E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