{"version":3,"file":"TableOfContents.BQpTiP4I.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/Yu8Dv9piybTgak66kCKX/1UXKIA1fkfB2DanKMUtp/TableOfContents.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";function slugify(text){return text.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/\\s+/g,\"-\").replace(/-+/g,\"-\")||\"section\";}const SAMPLE=[{id:\"s1\",text:\"Section one\",level:2},{id:\"s2\",text:\"Section two\",level:2},{id:\"s3\",text:\"Section three\",level:2}];// Desktop breakpoint min-width. Below this (tablet 810 / phone 390) the\n// table of contents hides and its rail collapses to zero width.\nconst DESKTOP_MIN=1200;// Site-wide chrome headings that must never appear in an article's ToC,\n// matched case-insensitively as substrings. The footer CTA band (\"Ready to\n// make AI work for you?\") is an <h2> that is not wrapped in a semantic\n// <footer>, so it has to be excluded explicitly.\nconst EXCLUDE_SUBSTRINGS=[\"make ai work for you\"];/**\n * On-this-page nav. Reads h2/h3 headings from the article content,\n * highlights the section in view, and smooth-scrolls on click.\n * Hidden on tablet/phone (viewport below DESKTOP_MIN); on desktop it owns\n * a fixed-width rail with right spacing so the column collapses cleanly\n * when hidden.\n *\n * @framerIntrinsicWidth 312\n * @framerIntrinsicHeight 320\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TableOfContents(props){const{title=\"On this page\",accentColor=\"#FF5A00\",activeColor=\"#F0F2F5\",mutedColor=\"#939599\",scrollOffset=110,railWidth=240,railGap=72,style}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const rootRef=useRef(null);const[headings,setHeadings]=useState(isCanvas?SAMPLE:[]);const[activeId,setActiveId]=useState(\"\");const[show,setShow]=useState(true);useEffect(()=>{if(isCanvas||typeof window===\"undefined\"||!window.matchMedia)return;const mq=window.matchMedia(`(min-width: ${DESKTOP_MIN}px)`);const update=()=>setShow(mq.matches);update();mq.addEventListener?.(\"change\",update);return()=>mq.removeEventListener?.(\"change\",update);},[isCanvas]);useEffect(()=>{if(isCanvas||typeof document===\"undefined\")return;let cancelled=false;let observer=null;// Prefer the nearest ancestor the ToC shares with the article\n// content (its own row); fall back to the document if not found.\nconst getScope=()=>{let el=rootRef.current?.parentElement||null;while(el&&el!==document.body){if(el.querySelector(\"h2, h3\"))return el;el=el.parentElement;}return document;};const isExcluded=el=>{const t=(el.textContent||\"\").trim().toLowerCase();if(!t)return true;if(el.closest(\"nav\")||el.closest(\"footer\"))return true;return EXCLUDE_SUBSTRINGS.some(s=>t.includes(s));};const collect=()=>{const scope=getScope();const nodes=Array.from(scope.querySelectorAll(\"h2, h3\")).filter(el=>!isExcluded(el));if(nodes.length===0)return false;const items=nodes.map((el,i)=>{const text=(el.textContent||\"\").trim();let id=el.id;if(!id){id=slugify(text)+\"-\"+i;el.id=id;}el.style.scrollMarginTop=scrollOffset+\"px\";return{id,text,level:el.tagName===\"H3\"?3:2};});if(!cancelled)setHeadings(items);if(observer)observer.disconnect();observer=new IntersectionObserver(entries=>{const visible=entries.filter(e=>e.isIntersecting).sort((a,b)=>a.boundingClientRect.top-b.boundingClientRect.top);if(visible[0])setActiveId(visible[0].target.id);},{rootMargin:`-${scrollOffset}px 0px -65% 0px`,threshold:0});nodes.forEach(el=>observer.observe(el));return true;};if(collect()){return()=>{cancelled=true;if(observer)observer.disconnect();};}// CMS content may mount after this component; watch for it briefly.\nconst mo=new MutationObserver(()=>{if(collect())mo.disconnect();});mo.observe(document.body,{childList:true,subtree:true});const timeout=setTimeout(()=>mo.disconnect(),5e3);return()=>{cancelled=true;mo.disconnect();clearTimeout(timeout);if(observer)observer.disconnect();};},[isCanvas,scrollOffset]);const handleClick=(e,id)=>{e.preventDefault();const el=document.getElementById(id);if(el){el.scrollIntoView({behavior:\"smooth\",block:\"start\"});setActiveId(id);}};// Hide on tablet/phone, or when there are no headings to show.\nif(!isCanvas&&(!show||headings.length===0))return null;return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{width:railWidth,paddingRight:railGap,boxSizing:\"content-box\",flexShrink:0,...style},children:/*#__PURE__*/_jsxs(\"nav\",{style:{display:\"flex\",flexDirection:\"column\",gap:16,fontFamily:\"Inter, sans-serif\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:12,fontWeight:600,letterSpacing:\"0.06em\",textTransform:\"uppercase\",color:mutedColor},children:title}),/*#__PURE__*/_jsx(\"ul\",{style:{listStyle:\"none\",margin:0,padding:0,display:\"flex\",flexDirection:\"column\",gap:2},children:headings.map(h=>{const active=h.id===activeId;return /*#__PURE__*/_jsx(\"li\",{children:/*#__PURE__*/_jsx(\"a\",{href:\"#\"+h.id,onClick:e=>handleClick(e,h.id),style:{display:\"block\",padding:\"7px 0 7px 16px\",marginLeft:h.level===3?14:0,borderLeft:`2px solid ${active?accentColor:\"rgba(255,255,255,0.12)\"}`,color:active?activeColor:mutedColor,fontSize:14,lineHeight:\"1.4em\",fontWeight:active?600:400,textDecoration:\"none\",transition:\"color 0.15s ease, border-color 0.15s ease\"},children:h.text})},h.id);})})]})});}addPropertyControls(TableOfContents,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"On this page\"},accentColor:{type:ControlType.Color,title:\"Accent\",defaultValue:\"#FF5A00\"},activeColor:{type:ControlType.Color,title:\"Active\",defaultValue:\"#F0F2F5\"},mutedColor:{type:ControlType.Color,title:\"Muted\",defaultValue:\"#939599\"},scrollOffset:{type:ControlType.Number,title:\"Scroll offset\",defaultValue:110,min:0,max:300,step:1},railWidth:{type:ControlType.Number,title:\"Rail width\",defaultValue:240,min:160,max:360,step:1},railGap:{type:ControlType.Number,title:\"Rail gap\",defaultValue:72,min:0,max:160,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"320\",\"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