{"version":3,"file":"TableOfContents.Bm_0flrm.mjs","names":["useState"],"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":"4LAAmJ,SAAS,EAAQ,EAAE,CAAC,OAAO,GAAG,GAAA,CAAI,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,gBAAgB,EAAE,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAE,CAAC,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,eAAa,gBAAgB,QAAM,eAAe,SAAO,UAAU,YAAU,UAAU,aAAW,WAAW,EAEna,EAAc,EAAM,eAAe,EAAM,OAAO,SAAc,CAAC,EAAM,GAAUA,EAAS,CAAC,CAAC,EAAO,CAAC,EAAO,GAAWA,EAAS,EAAE,EAM0hB,OANxhB,MAAc,CAAC,IAAI,EAAU,GAAU,EAAM,EAE9K,EAAS,MAAM,KAAK,OAAO,CAAa,CAAC,EAAE,SAAS,KAAK,SAAS,GAAc,CAAC,IAAM,EAAK,SAAS,cAAc,CAAY,EAAM,EAAG,CAAC,EAA4K,OAAvK,IAAK,EAAG,MAAM,KAAK,EAAK,iBAAiB,CAAQ,CAAC,GAAK,EAAG,SAAS,IAAG,EAAG,MAAM,KAAK,SAAS,iBAAiB,CAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,EAAE,QAAQ,qBAAqB,CAAC,GAAU,CAAG,CAAC,SAAS,GAAO,CAAC,GAAG,EAAU,OAAO,IAAM,EAAG,EAAa,EAAE,GAAG,EAAG,SAAS,EAAE,CAAI,IAAQ,IAAG,WAAW,EAAM,GAAG,EAAE,MAAO,CAAC,IAAM,EAAK,CAAC,EAAQ,EAAK,CAAC,EAA2O,GAAzO,EAAG,QAAQ,GAAG,CAAC,IAAI,EAAG,EAAE,IAAI,EAAQ,EAAE,aA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