{"version":3,"file":"GuideOverviewTOC.DpkJVG7l.mjs","names":["React.useState","React.useLayoutEffect","React.useEffect"],"sources":["https:/framerusercontent.com/modules/6D8VwsfXp17geG0EwqJp/hwQc1okLzqDGA835Ykk3/GuideOverviewTOC.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const SLUG_RE=/[^a-z0-9]+/g;// Runs before paint in the browser, and falls back to useEffect during server rendering.\nconst useIsoLayoutEffect=typeof window!==\"undefined\"?React.useLayoutEffect:React.useEffect;// Framer renders every breakpoint, so pick the article container that is actually on screen.\nconst findContainer=selector=>{const all=Array.from(document.querySelectorAll(selector));return all.find(el=>el.getClientRects().length>0)||all[0]||null;};const slugify=text=>{return text.toLowerCase().replace(SLUG_RE,\"-\").replace(/^-+|-+$/g,\"\")||\"section\";};/**\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 240\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function GuideOverviewTOC(props){const{label=\"In this guide\",contentSelector='[data-framer-name=\"ArticleContent\"]',headingSelector=\"h2\",activeColor=\"rgba(0, 0, 0, 1)\",inactiveColor=\"rgba(0, 0, 0, 0.6)\",labelColor=\"rgba(0, 0, 0, 0.5)\",fontSize=16,labelFontSize=12,lineHeight=1.5,gap=8,scrollOffset=100}=props;const[headings,setHeadings]=React.useState([]);const[activeId,setActiveId]=React.useState(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[ready,setReady]=React.useState(false);useIsoLayoutEffect(()=>{if(isCanvas)return;const read=()=>{const container=findContainer(contentSelector);const elements=container?Array.from(container.querySelectorAll(headingSelector)):[];if(elements.length===0)return false;const seen=new Map;setHeadings(elements.map((el,i)=>{const text=(el.textContent||`Section ${i+1}`).trim();const base=slugify(text);const count=seen.get(base)||0;seen.set(base,count+1);if(!el.id)el.id=count===0?base:`${base}-${count}`;return{id:el.id,text};}));return true;};// Usually the article is already in the page, so this finds the headings before first paint.\nif(read()){setReady(true);return;}// Otherwise wait for the article to appear, without polling, and stop after 3 seconds.\nconst observer=new MutationObserver(()=>{if(read()){observer.disconnect();setReady(true);}});observer.observe(document.body,{childList:true,subtree:true});const stop=window.setTimeout(()=>{observer.disconnect();setReady(true);},3e3);return()=>{observer.disconnect();window.clearTimeout(stop);};},[contentSelector,headingSelector,isCanvas]);React.useEffect(()=>{if(headings.length===0)return;const observer=new IntersectionObserver(entries=>{const intersecting=entries.filter(entry=>entry.isIntersecting);if(intersecting.length>0){intersecting.sort((a,b)=>a.boundingClientRect.top-b.boundingClientRect.top);setActiveId(intersecting[0].target.id);}},{rootMargin:\"-120px 0px -65% 0px\",threshold:0});headings.forEach(h=>{const el=document.getElementById(h.id);if(el)observer.observe(el);});return()=>observer.disconnect();},[headings]);const handleClick=id=>{const target=document.getElementById(id);if(!target)return;const top=target.getBoundingClientRect().top+window.scrollY-scrollOffset;window.scrollTo({top,behavior:\"smooth\"});setActiveId(id);};const items=isCanvas?[1,2,3].map(n=>({id:`preview-${n}`,text:`Section heading ${n}`})):headings;// No headings on this page: show nothing rather than an empty list.\nif(!isCanvas&&ready&&headings.length===0)return null;return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap,width:\"100%\",fontFamily:\"Inter, system-ui, sans-serif\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:labelFontSize,fontWeight:500,letterSpacing:\"0.08em\",textTransform:\"uppercase\",color:labelColor,marginBottom:4},children:label}),items.map(h=>{const isActive=activeId===h.id;return /*#__PURE__*/_jsx(\"div\",{onClick:()=>handleClick(h.id),style:{fontSize,lineHeight,color:isActive?activeColor:inactiveColor,fontWeight:isActive?500:400,cursor:\"pointer\",userSelect:\"none\",transition:\"color 0.2s ease, font-weight 0.2s ease\"},children:h.text},h.id);})]});}addPropertyControls(GuideOverviewTOC,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"In this guide\"},contentSelector:{type:ControlType.String,title:\"Content Selector\",defaultValue:'[data-framer-name=\"ArticleContent\"]'},headingSelector:{type:ControlType.String,title:\"Heading Tag\",defaultValue:\"h2\"},activeColor:{type:ControlType.Color,title:\"Active\",defaultValue:\"#000000\"},inactiveColor:{type:ControlType.Color,title:\"Inactive\",defaultValue:\"rgba(0, 0, 0, 0.6)\"},labelColor:{type:ControlType.Color,title:\"Label\",defaultValue:\"rgba(0, 0, 0, 0.5)\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:16,min:12,max:24},labelFontSize:{type:ControlType.Number,title:\"Label Size\",defaultValue:12,min:10,max:16},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1.5,min:1,max:2,step:.1},gap:{type:ControlType.Number,title:\"Item Gap\",defaultValue:8,min:0,max:24},scrollOffset:{type:ControlType.Number,title:\"Scroll Offset\",defaultValue:100,min:0,max:240}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GuideOverviewTOC\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"240\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"200\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GuideOverviewTOC.map"],"mappings":"0MAOG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,gBAAgB,kBAAgB,sCAAsC,kBAAgB,KAAK,cAAY,mBAAmB,gBAAc,qBAAqB,aAAW,qBAAqB,WAAS,GAAG,gBAAc,GAAG,aAAW,IAAI,MAAI,EAAE,eAAa,KAAK,EAAW,CAAC,EAAS,GAAaA,EAAe,CAAC,CAAC,EAAO,CAAC,EAAS,GAAaA,EAAe,IAAI,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAY,CAAC,EAAM,GAAUA,EAAe,EAAK,EAAE,MAAuB,CAAC,GAA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