{"version":3,"file":"CMSCounter.B4e8mmdK.mjs","names":["React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/OPJlnSDokJ2eD9lIXljn/mr2QJ5zw4xvkJ1Vbvzgr/CMSLibrary.js","https:/framer.com/m/CMSLibrary-09eo.js","https:/framerusercontent.com/modules/7TZuIkyfJPBXbl5J3KZg/qEsjicN69hbnSVQpsjBX/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","// CMS Item Counter — LaunchNow Design\n// Counts items in a connected Collection List. Connect a TEXT LAYER and it\n// BECOMES the counter: the layer renders with its own Framer styles (zero\n// font flash, server-rendered included) and only its text content is\n// swapped to the live count. Built-in Font controls apply when nothing is\n// connected.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import*as React from\"react\";// @ts-ignore\nimport{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";function formatNumber(value,commas,minDigits=1){let numberString=value.toFixed(0);if(minDigits>1){numberString=numberString.padStart(minDigits,\"0\");}if(commas){numberString=numberString.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");}return numberString;}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function CMSCounter(props){const{transform}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const collectionList=props.collectionList?.[0];const{query}=getCollectionData(collectionList);let items=props.placeholder;if(query&&!isCanvas){items=useQueryData(query).length;}let prefix=\"\";let suffix=\"\";if(transform){if(transform.plural){prefix=items==1?transform.singularPrefix:transform.pluralPrefix;suffix=items==1?transform.singularSuffix:transform.pluralSuffix;}else{prefix=transform.prefix;suffix=transform.suffix;}}// ---- Connected text layer: render it LIVE, swap its text ----\n// Measure-and-copy always flashes on a bare, immediately-visible\n// element: the server renders fallback styles (it cannot measure),\n// and instances can hydrate late. So the connected layer IS the\n// display — styled by Framer's own CSS from the first server byte —\n// and only its TEXT is swapped to the live count. No typography is\n// ever applied by this component, so no wrong-font frame can exist.\nconst hasTextSource=Boolean(Array.isArray(props.textStyleSource)?props.textStyleSource.length>0:props.textStyleSource);const liveLayerRef=React.useRef(null);const boundNodeRef=React.useRef(null);const output=`${prefix??\"\"}`+formatNumber(items,props.commas,props.minDigits)+`${suffix??\"\"}`;const outputRef=React.useRef(output);outputRef.current=output;const bindAndWrite=React.useCallback(()=>{const root=liveLayerRef.current;if(!root||typeof window===\"undefined\")return;let node=boundNodeRef.current;if(!node||!root.contains(node)){const walker=document.createTreeWalker(root,NodeFilter.SHOW_TEXT);let best=null;let bestLen=0;let n=walker.nextNode();while(n){const len=(n.textContent||\"\").trim().length;if(len>bestLen){bestLen=len;best=n;}n=walker.nextNode();}if(!best)return;boundNodeRef.current=best;node=best;}if(node.textContent!==outputRef.current){node.textContent=outputRef.current;}},[]);React.useLayoutEffect(()=>{if(!hasTextSource){boundNodeRef.current=null;return;}if(typeof window===\"undefined\")return;bindAndWrite();let observer;if(liveLayerRef.current&&typeof MutationObserver!==\"undefined\"){observer=new MutationObserver(()=>bindAndWrite());observer.observe(liveLayerRef.current,{childList:true,subtree:true,characterData:true});}return()=>observer?.disconnect();},[hasTextSource,bindAndWrite]);React.useEffect(()=>{if(!hasTextSource)return;bindAndWrite();},[hasTextSource,output,bindAndWrite]);if(hasTextSource){return /*#__PURE__*/_jsx(\"div\",{ref:liveLayerRef,\"aria-live\":\"polite\",style:{width:\"max-content\",userSelect:props.textSelect?\"auto\":\"none\",...props.style},children:props.textStyleSource});}return /*#__PURE__*/_jsxs(\"div\",{style:{color:props.fontColor,userSelect:props.textSelect?\"auto\":\"none\",margin:0,whiteSpace:props.style?.width?undefined:\"nowrap\",textTransform:props.textTransform,...props.font,...props.style},children:[prefix,formatNumber(items,props.commas,props.minDigits),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},minDigits:{type:ControlType.Number,title:\"Min Digits\",defaultValue:1,min:1,max:10,step:1,description:\"Minimum number of digits (pads with leading zeros).\"},textStyleSource:{type:ControlType.ComponentInstance,title:\"Text Style\",description:\"Connect a text layer and it BECOMES the counter: its own text is replaced by the live count, keeping its exact styles with zero font flash on load. Type the expected output in the layer (e.g. 10 Projects) so pre-load frames match. Font/Color controls apply only when nothing is connected.\"},fontColor:{type:ControlType.Color,defaultValue:\"#000\",hidden:p=>Boolean(p.textStyleSource)},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1},hidden:p=>Boolean(p.textStyleSource)},textTransform:{type:ControlType.Enum,title:\"Transform\",defaultValue:\"none\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],hidden:p=>Boolean(p.textStyleSource)},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,description:\"Component from [LaunchNow Design](https://launchnow.design/?utm_source=codecomponent)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLay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