{"version":3,"file":"CMS_Counter.Ben7jHcd.mjs","names":["React.forwardRef","_jsx","React.useRef","React.useState","React.useEffect","_jsxs","__esmMin","_e","de","p","c","J","init_jsx_runtime","init_npm_react_18_3_1","ce","RenderTarget","addPropertyControls","init_framer_ChujFWHC","ControlType","withCountedItem","Component","props","ref","ITEM","CMSItemCounter","sourceMode","sectionId","collection","alignment","format","singular","plural","color","font","style","source","count","setCount","canvas","frame","measure","root","total","item","observer","observationRoot","value","label","init_CMS_Counter"],"sources":["https:/framerusercontent.com/modules/aZ1Vy2W7bGKdc6X7Dptp/BmAJzNtsYHjA33C8bx3y/CMS_Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const ITEM=\"data-cms-counter-item\";/** Apply to the outermost repeated CMS item, once per item. */export function withCountedItem(Component){return /*#__PURE__*/React.forwardRef(function CountedItem(props,ref){return /*#__PURE__*/_jsx(Component,{...props,ref:ref,[ITEM]:\"true\"});});}/**\n * Connect a CMS Collection List and apply withCountedItem to its repeated item.\n * Counts rendered records, not unpublished or unloaded CMS records.\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 220\n * @framerIntrinsicHeight 40\n */export default function CMSItemCounter({sourceMode=\"page\",sectionId=\"presentations\",collection,alignment=\"left\",format=\"brackets\",singular=\"item\",plural=\"items\",color=\"#111111\",font={},style}){const source=React.useRef(null);const[count,setCount]=React.useState(null);const canvas=RenderTarget.current()===RenderTarget.canvas;React.useEffect(()=>{if(canvas)return;setCount(null);let frame=0;const measure=()=>{frame=0;const root=sourceMode===\"page\"?document.getElementById(sectionId.replace(/^#/,\"\")):source.current;if(!root){setCount(null);return;}const markers=Array.from(root.querySelectorAll(`[${ITEM}]`));// Nested marked elements belong to the same outer record.\nconst total=markers.filter(item=>!item.parentElement?.closest(`[${ITEM}]`)).length;setCount(total);};const schedule=()=>{if(!frame)frame=requestAnimationFrame(measure);};const observer=new MutationObserver(schedule);const observationRoot=sourceMode===\"page\"?document.body:source.current;if(!observationRoot)return;observer.observe(observationRoot,{childList:true,subtree:true,attributes:true,attributeFilter:[ITEM,\"id\"]});measure();return()=>{observer.disconnect();cancelAnimationFrame(frame);};},[collection,canvas,sourceMode,sectionId]);const value=canvas?\"123\":sourceMode===\"connection\"&&!collection||count===null?\"—\":String(count);const label=format===\"label\"?value===\"—\"?value:`${value} ${value===\"1\"?singular:plural}`:`[${value}]`;return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",fontFamily:\"Inter, sans-serif\",fontSize:24,lineHeight:\"1.2em\",...font,color,textAlign:alignment},children:[/*#__PURE__*/_jsx(\"span\",{role:\"status\",\"aria-live\":\"polite\",\"aria-atomic\":\"true\",style:{whiteSpace:\"pre-wrap\"},children:label}),!canvas&&sourceMode===\"connection\"&&/*#__PURE__*/_jsx(\"div\",{ref:source,\"aria-hidden\":\"true\",// Keep the list mounted for counting, outside layout and focus navigation.\nstyle:{position:\"absolute\",width:1,height:1,overflow:\"hidden\",visibility:\"hidden\",pointerEvents:\"none\",top:0,left:0},children:collection})]});}addPropertyControls(CMSItemCounter,{sourceMode:{type:ControlType.Enum,title:\"Source\",options:[\"page\",\"connection\"],optionTitles:[\"Page Section\",\"Connection\"],defaultValue:\"page\"},sectionId:{type:ControlType.String,title:\"Section ID\",defaultValue:\"presentations\",hidden:props=>props.sourceMode===\"connection\",description:\"Scroll Section name containing the marked CMS items, without #.\"},collection:{type:ControlType.ComponentInstance,title:\"Collection\",hidden:props=>props.sourceMode!==\"connection\",description:\"Connect a CMS list. Apply withCountedItem to its repeated item. Include all records for a total count.\"},format:{type:ControlType.Enum,title:\"Format\",options:[\"brackets\",\"label\"],optionTitles:[\"[ 12 ]\",\"12 label\"],defaultValue:\"brackets\"},singular:{type:ControlType.String,title:\"Singular\",defaultValue:\"item\",hidden:props=>props.format!==\"label\"},plural:{type:ControlType.String,title:\"Plural\",defaultValue:\"items\",hidden:props=>props.format!==\"label\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#111111\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultValue:{fontSize:\"24px\",lineHeight:\"1.2em\",fontWeight:400}},alignment:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],displaySegmentedControl:true,defaultValue:\"left\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"withCountedItem\":{\"type\":\"reactHoc\",\"name\":\"withCountedItem\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSItemCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicHeight\":\"40\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"220\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Counter.map"],"mappings":"A,8MAAwP,SAAgBmB,EAAgBC,EAAU,CAAC,MAAoBpB,gBAAiB,SAAqBqB,EAAMC,EAAI,CAAC,MAAoBrB,gBAAKmB,EAAU,CAAC,GAAGC,EAAUC,OAAKC,GAAM,MAAM,CAAC,CAAE,CAAC,CAAE,CAO7a,SAAwBC,EAAe,CAACC,aAAW,OAAOC,YAAU,gBAAgBC,aAAWC,YAAU,OAAOC,SAAO,WAAWC,WAAS,OAAOC,SAAO,QAAQC,QAAM,UAAUC,OAAK,CAAC,EAAEC,SAAO,CAAC,IAAMC,EAAOjC,EAAa,IAAI,EAAO,CAACkC,EAAMC,GAAUlC,EAAe,IAAI,EAAQmC,EAAOvB,EAAa,QAAQ,IAAIA,EAAa,OAAOX,MAAoB,CAAC,GAAGkC,EAAO,OAAOD,EAAS,IAAI,EAAE,IAAIE,EAAM,EAAQC,MAAY,CAACD,EAAM,EAAE,IAAME,EAAKhB,IAAa,OAAO,SAA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