{"version":3,"file":"TableOfContents.BVSZdBuk.mjs","names":["useState","__esmMin","init_ssg_sandbox_shims","_e","init_jsx_runtime","c","p","init_npm_react_18_3_1","ce","window","addPropertyControls","ControlType","init_framer_BWFVvmND","slugify","s","TableOfContents","props","headingLevels","items","setItems","active","setActive","cancelled","tries","selector","findHeadings","root","bodySelector","hs","h","build","used","list","id","updateActive","current","onScrollRef","pollRef","mutedColor","title","it","e","el","accent","textColor","init_TableOfContents"],"sources":["https:/framerusercontent.com/modules/OJybaMPJpD2r37d2hfgK/v7yMgAUl0yAfBTnwgHL7/TableOfContents.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function slugify(s){return(s||\"\").toLowerCase().trim().replace(/[^a-z0-9\\s-]/g,\"\").replace(/\\s+/g,\"-\").slice(0,60);}export default function TableOfContents(props){const{bodySelector=\"#article-body\",title=\"On this page\",accent=\"#2563EB\",textColor=\"#111111\",mutedColor=\"#6B7280\"}=props;// Framer derives the control id from the control title, so the value can\n// arrive under either name. Accept both rather than silently defaulting.\nconst headingLevels=props.headingLevels??props.depth??\"h2, h3\";const[items,setItems]=useState([]);const[active,setActive]=useState(\"\");useEffect(()=>{let cancelled=false;let tries=0;// Framer passes the option title (\"H2 only\" / \"H2 and H3\"), so match on\n// whether h3 is mentioned at all rather than on an exact string.\nconst selector=/h3/i.test(String(headingLevels))?\"h2, h3\":\"h2\";function findHeadings(){const root=document.querySelector(bodySelector);let hs=[];if(root)hs=Array.from(root.querySelectorAll(selector));if(hs.length===0){hs=Array.from(document.querySelectorAll(selector)).filter(h=>!h.closest(\"nav, header, footer\"));}return hs;}function build(){if(cancelled)return;const hs=findHeadings();if(hs.length===0){if(tries++<40)setTimeout(build,150);return;}const used={};const list=[];hs.forEach(h=>{let id=h.id||slugify(h.textContent||\"\");if(!id)return;if(used[id]){id=id+\"-\"+used[id]++;}else{used[id]=1;}h.id=id;h.style.scrollMarginTop=\"100px\";list.push({id:id,text:h.textContent||\"\",level:h.tagName===\"H3\"?3:2});});if(cancelled)return;setItems(list);// Deterministic active-section tracking: the current heading is the\n// last one whose top has passed the reading line. IntersectionObserver\n// alone is unreliable (it does not fire in background tabs, and a\n// programmatic jump can skip its band entirely).\nconst updateActive=()=>{if(cancelled)return;const line=140;let current=hs[0];for(const h of hs){if(h.getBoundingClientRect().top<=line)current=h;else break;}if(current)setActive(current.id);};updateActive();onScrollRef=()=>updateActive();window.addEventListener(\"scroll\",onScrollRef,{passive:true});window.addEventListener(\"resize\",onScrollRef);pollRef=setInterval(updateActive,500);}let onScrollRef=null;let pollRef=null;build();return()=>{cancelled=true;if(onScrollRef){window.removeEventListener(\"scroll\",onScrollRef);window.removeEventListener(\"resize\",onScrollRef);}if(pollRef)clearInterval(pollRef);};},[bodySelector,headingLevels]);if(items.length===0)return null;return /*#__PURE__*/_jsxs(\"nav\",{style:{display:\"flex\",flexDirection:\"column\",gap:8,fontFamily:\"Inter, sans-serif\",width:\"100%\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:12,fontWeight:600,textTransform:\"uppercase\",letterSpacing:\"0.07em\",color:mutedColor,marginBottom:6},children:title}),items.map(it=>/*#__PURE__*/_jsx(\"a\",{href:\"#\"+it.id,onClick:e=>{e.preventDefault();const el=document.getElementById(it.id);if(el){el.scrollIntoView({behavior:\"smooth\"});history.replaceState(null,\"\",\"#\"+it.id);}},style:{paddingLeft:it.level===3?14:10,fontSize:14,lineHeight:1.45,textDecoration:\"none\",color:active===it.id?accent:textColor,fontWeight:active===it.id?600:400,borderLeft:\"2px solid \"+(active===it.id?accent:\"rgba(0,0,0,0.08)\"),paddingTop:3,paddingBottom:3,transition:\"color .15s, border-color .15s\"},children:it.text},it.id))]});}addPropertyControls(TableOfContents,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"On this page\"},bodySelector:{type:ControlType.String,title:\"Body selector\",defaultValue:\"#article-body\"},headingLevels:{type:ControlType.Enum,title:\"Depth\",options:[\"h2, h3\",\"h2\"],optionTitles:[\"H2 and H3\",\"H2 only\"],defaultValue:\"h2, h3\"},accent:{type:ControlType.Color,title:\"Accent\",defaultValue:\"#2563EB\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#111111\"},mutedColor:{type:ControlType.Color,title:\"Muted\",defaultValue:\"#6B7280\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"A,sMAAmJ,SAASa,EAAQ,EAAE,CAAC,OAAOC,GAAG,GAAA,CAAI,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,gBAAgB,EAAE,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAE,CAAC,SAAwBC,EAAgB,EAAM,CAAC,GAAK,CAAC,eAAa,gBAAgB,QAAM,eAAe,SAAO,UAAU,YAAU,UAAU,aAAW,WAAWC,EAEnaC,EAAcD,EAAM,eAAeA,EAAM,OAAO,SAAc,CAACE,EAAMC,GAAUnB,EAAS,CAAC,CAAC,EAAO,CAACoB,EAAOC,GAAWrB,EAAS,EAAE,EAM0hB,OANxhBQ,MAAc,CAAC,IAAIc,EAAU,GAAUC,EAAM,EAE9KC,EAAS,MAAM,KAAK,OAAOP,CAAa,CAAC,EAAE,SAAS,KAAK,SAASQ,GAAc,CAAC,IAAMC,EAAK,SAAS,cAAcC,CAAY,EAAMC,EAAG,CAAC,EAA4K,OAAvKF,IAAK,EAAG,MAAM,KAAKA,EAAK,iBAAiBF,CAAQ,CAAC,GAAKI,EAAG,SAAS,IAAG,EAAG,MAAM,KAAK,SAAS,iBAAiBJ,CAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,CAACK,EAAE,QAAQ,qBAAqB,CA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