{"version":3,"file":"BlogFilters.CMr2fPhP.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Too0VGxC9zOYYywTnkRi/0P98y56yPmMJDoVbnee7/BlogFilters.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";/**\n * Blog index behaviour — the category picker, the search field and the\n * \"Load more\" button, driven over the CMS list that renders the cards.\n *\n * The cards come from a Framer collection list, so filtering happens in the\n * DOM: every article is shown or hidden by category and title, and only a\n * page of them is visible at a time. Attached to the filter bar; it reaches\n * the grid through the document because the two are siblings on the page.\n */const PAGE=15;const RESTING=\"Filter by category\";// The rows are Framer components that re-render from their own props, so their\n// resting/hover/selected look is a stylesheet rule keyed off an attribute\n// rather than an inline style that the next render would wipe.\nconst OPTION_CSS=`\n[data-wn-filter] [data-wn-opt] {\n    border-radius: 8px !important;\n    transition: background-color .15s ease !important;\n    cursor: pointer;\n}\n/* the first row ships with a resting grey fill of its own, which now reads as\n   a second selection — only the picked row carries a fill */\n[data-wn-filter] [data-wn-opt=\"off\"] { background-color: transparent !important }\n[data-wn-filter] [data-wn-opt=\"on\"] { background-color: #F7F7F7 !important }\n[data-wn-filter] [data-wn-opt]:hover { background-color: #F2F2F2 !important }\n[data-wn-filter] [data-wn-opt=\"on\"] * { color: #121212 !important }\n`;if(typeof document!==\"undefined\"&&!document.getElementById(\"wn-blog-opt\")){const tag=document.createElement(\"style\");tag.id=\"wn-blog-opt\";tag.textContent=OPTION_CSS;document.head.appendChild(tag);}/**\n * The doc dims the whole grid on hover and lifts only the card under the\n * pointer back to full strength. Returns a teardown.\n */function dimOnHover(grid,cards){cards.forEach(c=>c.style.transition=\"opacity .18s ease\");const over=e=>{const hovered=e.target.closest('[data-framer-name=\"Article\"]');cards.forEach(c=>{if(c.style.display===\"none\")return;c.style.opacity=c===hovered?\"1\":\"0.55\";});};const out=()=>cards.forEach(c=>c.style.opacity=\"1\");grid.addEventListener(\"mouseover\",over);grid.addEventListener(\"mouseleave\",out);return()=>{grid.removeEventListener(\"mouseover\",over);grid.removeEventListener(\"mouseleave\",out);out();};}/**\n * Hover dimming on its own, for the grids that list articles without the\n * index page's category picker, search and paging — the category page.\n */export function withCardDim(Component){return props=>{const ref=useRef(null);useEffect(()=>{const grid=ref.current;if(!grid)return;const cards=Array.from(grid.querySelectorAll('[data-framer-name=\"Article\"]'));if(!cards.length)return;return dimOnHover(grid,cards);},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});};}export function withBlogFilters(Component){return props=>{const ref=useRef(null);useEffect(()=>{const host=ref.current;if(!host)return;const q1=(root,name)=>root.querySelector(`[data-framer-name=\"${name}\"]`);const qAll=(root,sel)=>Array.from(root.querySelectorAll(sel));const button=q1(host,\"Button\");const selected=q1(host,\"Selected\");const menu=q1(host,\"Menu\");const input=host.querySelector(\"input\");const cards=qAll(document,'[data-framer-name=\"Article\"]');const more=q1(document,\"Load More\");const grid=q1(document,\"Article Grid\");if(!cards.length)return;const text=el=>el?el.innerText.trim().toLowerCase():\"\";const rows=cards.map(card=>({card,cat:text(q1(card,\"Category\")),title:text(card.querySelector(\"h3\"))}));let cat=\"all\";let query=\"\";let shown=PAGE;const apply=()=>{let hits=0;rows.forEach(r=>{const ok=(cat===\"all\"||r.cat===cat)&&(!query||r.title.indexOf(query)>=0);if(ok){hits+=1;r.card.style.display=hits<=shown?\"\":\"none\";}else{r.card.style.display=\"none\";}});if(more)more.style.display=hits>shown?\"\":\"none\";};// the menu layer is always rendered so it can be opened from here;\n// the closed state is the component's own opacity 0\nlet open=false;const paintMenu=()=>{if(!menu)return;menu.style.opacity=open?\"1\":\"0\";menu.style.pointerEvents=open?\"auto\":\"none\";const chev=q1(host,\"Chevron\");if(chev){chev.style.transition=\"transform .18s ease\";chev.style.transform=open?\"rotate(180deg)\":\"none\";}};paintMenu();const offs=[];const on=(el,ev,fn)=>{if(!el)return;el.addEventListener(ev,fn);offs.push(()=>el.removeEventListener(ev,fn));};if(button){button.style.cursor=\"pointer\";on(button,\"click\",e=>{e.preventDefault();e.stopPropagation();open=!open;paintMenu();});}on(document,\"click\",e=>{if(!open)return;if(host.contains(e.target))return;open=false;paintMenu();});on(document,\"keydown\",e=>{if(e.key===\"Escape\"&&open){open=false;paintMenu();}});if(menu){host.setAttribute(\"data-wn-filter\",\"1\");const optionsNow=()=>qAll(menu,'[data-framer-name^=\"Option \"]').filter(opt=>!/^Option Label/.test(opt.getAttribute(\"data-framer-name\")||\"\"));const options=optionsNow();// one place decides which row looks selected, so the tick and the\n// fill can never disagree — including on the first render. The\n// rows are re-rendered when one is picked, which drops the\n// attribute, so this re-queries rather than holding references.\nconst paintOptions=()=>{optionsNow().forEach(opt=>{const label=opt.innerText.trim();const isAll=/^all/i.test(label);const on=isAll?cat===\"all\":label.toLowerCase()===cat;opt.setAttribute(\"data-wn-opt\",on?\"on\":\"off\");qAll(opt,'[data-framer-name^=\"Check \"]').forEach(c=>{c.style.opacity=on?\"1\":\"0\";});});};paintOptions();options.forEach(opt=>{on(opt,\"click\",e=>{e.preventDefault();e.stopPropagation();const label=opt.innerText.trim();const all=/^all/i.test(label);if(selected)selected.innerText=all?RESTING:label;cat=all?\"all\":label.toLowerCase();shown=PAGE;open=false;paintMenu();paintOptions();apply();// Framer swaps the row's node when the click changes its\n// state, so paint again once that render has landed\nrequestAnimationFrame(paintOptions);setTimeout(paintOptions,200);});});// and once more whenever the menu's contents are rebuilt\nconst watch=new MutationObserver(()=>paintOptions());watch.observe(menu,{childList:true,subtree:true});offs.push(()=>watch.disconnect());}if(grid)offs.push(dimOnHover(grid,rows.map(r=>r.card)));let debounce=null;if(input){on(input,\"input\",()=>{clearTimeout(debounce);debounce=setTimeout(()=>{query=input.value.trim().toLowerCase();shown=PAGE;apply();},150);});}if(more){more.style.cursor=\"pointer\";on(more,\"click\",e=>{e.preventDefault();shown+=PAGE;apply();});}apply();return()=>{clearTimeout(debounce);offs.forEach(f=>f());rows.forEach(r=>{r.card.style.display=\"\";r.card.style.opacity=\"1\";});};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withBlogFilters\":{\"type\":\"reactHoc\",\"name\":\"withBlogFilters\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCardDim\":{\"type\":\"reactHoc\",\"name\":\"withCardDim\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BlogFilters.map"],"mappings":"yHA0BG,SAAS,EAAW,EAAK,EAAM,CAAC,EAAM,QAAQ,GAAG,EAAE,MAAM,WAAW,mBAAmB,EAAE,IAAM,EAAK,GAAG,CAAC,IAAM,EAAQ,EAAE,OAAO,QAAQ,8BAA8B,EAAE,EAAM,QAAQ,GAAG,CAAI,EAAE,MAAM,UAAU,SAAc,EAAE,MAAM,QAAQ,IAAI,EAAQ,IAAI,OAAO,CAAC,CAAE,EAAQ,MAAQ,EAAM,QAAQ,GAAG,EAAE,MAAM,QAAQ,GAAG,EAAkF,OAAhF,EAAK,iBAAiB,YAAY,CAAI,EAAE,EAAK,iBAAiB,aAAa,CAAG,MAAY,CAAC,EAAK,oBAAoB,YAAY,CAAI,EAAE,EAAK,oBAAoB,aAAa,CAAG,EAAE,EAAI,CAAE,CAAE,CAGrf,SAAgB,EAAY,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EAAkM,OAAhM,MAAc,CAAC,IAAM,EAAK,EAAI,QAAQ,GAAG,CAAC,EAAK,OAAO,IAAM,EAAM,MAAM,KAAK,EAAK,iBAAiB,8BAA8B,CAAC,EAAM,KAAM,OAAc,OAAO,EAAW,EAAK,CAAK,CAAE,EAAE,CAAC,CAAC,EAAsB,EAAK,EAAU,CAAK,MAAI,GAAG,CAAK,CAAC,CAAE,CAAE,CAAC,SAAgB,EAAgB,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EASgM,OAT9L,MAAc,CAAC,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