{"version":3,"file":"CMS_Counter.CaHIY9BL.mjs","names":["React.useRef","React.useState","__esmMin","_e","de","p","c","J","init_jsx_runtime","init_npm_react_18_3_1","ce","RenderTarget","addPropertyControls","init_framer_Bf4_tcb2","ControlType","withCountedItem","Component","props","ITEM","CMSItemCounter","source","count","setCount","canvas","frame","measure","root","sourceMode","sectionId","total","item","observer","observationRoot","collection","value","style","font","alignment","init_CMS_Counter"],"sources":["https:/framerusercontent.com/modules/B4nBFTl4Bul2ErKKdMMb/wXBBGSFpXij8nb9cIq9E/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\",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);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",fontFamily:\"Inter, sans-serif\",fontSize:24,lineHeight:\"1.2em\",...font,color,textAlign:alignment},children:[/*#__PURE__*/_jsxs(\"span\",{role:\"status\",\"aria-live\":\"polite\",\"aria-atomic\":\"true\",style:{whiteSpace:\"pre-wrap\"},children:[\"[\",value,\"]\"]}),!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.\"},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\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"40\",\"framerIntrinsicWidth\":\"220\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Counter.map"],"mappings":"A,8MAAwP,SAAgBe,EAAgB,EAAU,CAAC,MAAoB,gBAAiB,SAAqB,EAAM,EAAI,CAAC,MAAoB,gBAAKC,EAAU,CAAC,GAAGC,EAAU,OAAKC,GAAM,MAAM,CAAC,CAAE,CAAC,CAAE,CAO7a,SAAwBC,EAAe,CAAC,aAAW,OAAO,YAAU,gBAAgB,aAAW,YAAU,OAAO,QAAM,UAAU,OAAK,CAAC,EAAE,SAAO,CAAC,IAAMC,EAAOpB,EAAa,IAAI,EAAO,CAACqB,EAAMC,GAAUrB,EAAe,IAAI,EAAQsB,EAAOZ,EAAa,QAAQ,IAAIA,EAAa,OAAOD,MAAoB,CAAC,GAAGa,EAAO,OAAOD,EAAS,IAAI,EAAE,IAAIE,EAAM,EAAQC,MAAY,CAAC,EAAM,EAAE,IAAMC,EAAKC,IAAa,OAAO,SAAS,eAAeC,EAAU,QAAQ,KAAK,EAAE,CAAC,EAAER,EAAO,QAAQ,GAAG,CAACM,EAAK,CAACJ,EAAS,IAAI,EAAE,MAAO,CACtf,IAAMO,EAD+f,MAAM,KAAKH,EAAK,iBAAiB,IAAIR,EAAK,EAAE,CAC/hB,CAAC,CAAC,OAAO,GAAM,CAACY,EAAK,eAAe,QAAQ,IAAIZ,EAAK,EAAE,CAAC,CAAC,CAAC,OAAOI,EAASO,CAAK,CAAE,EAA6EE,EAAS,IAAI,qBAArE,CAAC,AAAUP,IAAM,sBAAsBC,CAAO,CAAE,CAA8C,EAAQO,EAAgBL,IAAa,OAAO,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