document.addEventListener("DOMContentLoaded",()=>{function n(e){var c=6;if(typeof window.SageGridSettings>"u")return c;var i=null;e==="projects"?i=window.SageGridSettings.projectsPageSize:e==="blog"&&(i=window.SageGridSettings.blogPageSize);var l=parseInt(i,10);return!isNaN(l)&&l>0?l:c}function o(e){const c=e.cardSelector,i=e.termKey,l=e.loadMoreId,t=e.pageSize,a=document.querySelectorAll(".filter-btn[data-filter]"),s=Array.from(document.querySelectorAll(c)),f=document.getElementById(l);if(!s.length)return;let m="all",d=t;function p(){return s.filter(r=>{const y=(r.dataset[i]||"").split(" ").filter(Boolean);return m==="all"||y.includes(m)})}function g(){const r=p();d>r.length&&(d=r.length),s.forEach(u=>u.classList.add("hidden")),r.slice(0,d).forEach(u=>{u.classList.remove("hidden")}),f&&(r.length>d?f.style.display="inline-flex":f.style.display="none")}a.forEach(r=>{r.addEventListener("click",()=>{m=r.dataset.filter||"all",d=t,a.forEach(y=>y.classList.remove("is-active")),r.classList.add("is-active"),g()})}),f&&f.addEventListener("click",()=>{d+=t,g()}),g()}o({cardSelector:".project-card",termKey:"tech",loadMoreId:"projects-load-more",pageSize:n("projects")}),o({cardSelector:".blog-card",termKey:"category",loadMoreId:"blog-load-more",pageSize:n("blog")})});document.addEventListener("DOMContentLoaded",()=>{const n=document.getElementById("post-toc-card"),o=document.getElementById("post-toc"),e=document.querySelector(".e-content");if(!n||!o||!e)return;const c=Array.from(e.querySelectorAll("h2, h3"));if(!c.length){n.style.display="none";return}function i(t){return t.toLowerCase().trim().replace(/[^\w]+/g,"-").replace(/^-+|-+$/g,"")}const l=document.createElement("ul");c.forEach(t=>{t.id||(t.id=i(t.textContent));const a=document.createElement("li"),s=document.createElement("a");s.href=`#${t.id}`,s.textContent=t.textContent||t.innerText||"",t.tagName.toLowerCase()==="h3"&&a.classList.add("toc-level-3"),a.appendChild(s),l.appendChild(a)}),o.innerHTML="",o.appendChild(l)});(()=>{const n=document.getElementById("site-header");if(!n||!n.classList.contains("is-sticky"))return;const o=10,e=()=>{window.scrollY>o?n.classList.add("is-sticky-scrolled"):n.classList.remove("is-sticky-scrolled")};e(),window.addEventListener("scroll",e,{passive:!0})})();
