{"version":3,"file":"TOCMaker_Timer.P4fcPy8_.mjs","names":["useState","useRef","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/42vT5KIJNCTgsPZlRLjU/EjDul832m6PFhvtBvnaP/TOCMaker_Timer.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";export function TableOfContentsAndReadingTime(){const[headings,setHeadings]=useState([]);const[activeHeading,setActiveHeading]=useState(null);const[readingTime,setReadingTime]=useState(0);const observerRef=useRef(null);const headingVisibilityRef=useRef({});useEffect(()=>{const blogContent=document.querySelector('[data-framer-name=\"Main Blog Content\"]');if(!blogContent)return;const extracted=Array.from(blogContent.querySelectorAll(\"h2\")).map(el=>{let id=el.id||el.textContent?.trim().toLowerCase().replace(/\\s+/g,\"-\")||\"\";el.id=id;return{id,text:el.textContent||\"\"};});setHeadings(extracted);const text=blogContent.textContent||\"\";const words=text.trim().split(/\\s+/).length;setReadingTime(Math.ceil(words/225));observerRef.current=new IntersectionObserver(entries=>{entries.forEach(entry=>{const id=entry.target.id;if(entry.isIntersecting){headingVisibilityRef.current[id]=entry.boundingClientRect.top;}else{delete headingVisibilityRef.current[id];}});const visibleEntries=Object.entries(headingVisibilityRef.current);if(visibleEntries.length>0){const[closestId]=visibleEntries.reduce((a,b)=>Math.abs(a[1])<Math.abs(b[1])?a:b);setActiveHeading(closestId);}},{rootMargin:\"-10% 0px -60% 0px\",threshold:[.25,.5,.75]});extracted.forEach(({id})=>{const el=document.getElementById(id);if(el)observerRef.current?.observe(el);});return()=>observerRef.current?.disconnect();},[]);const handleClick=(id,e)=>{e.preventDefault();const el=document.getElementById(id);if(el){const offset=-70;const y=el.getBoundingClientRect().top+window.scrollY+offset;window.scrollTo({top:y,behavior:\"smooth\"});}setActiveHeading(id);};return{children:/*#__PURE__*/_jsxs(\"aside\",{className:\"sticky top-5 w-full h-full p-2 border border-gray-200 bg-white overflow-y-auto rounded-lg\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"flex items-center text-xs mb-3 px-2 py-1 bg-gray-100 rounded-full border border-gray-300\",children:[/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"14\",height:\"14\",fill:\"currentColor\",viewBox:\"0 0 16 16\",className:\"mr-1\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M8 0a8 8 0 100 16A8 8 0 008 0zm-.5 7a.5.5 0 01.5-.5h1a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-1a.5.5 0 01-.5-.5V7z\"})}),readingTime,\" min read\"]}),/*#__PURE__*/_jsx(\"ul\",{className:\"space-y-2 px-1\",children:headings.map(({id,text})=>/*#__PURE__*/_jsx(\"li\",{children:/*#__PURE__*/_jsx(\"a\",{href:`#${id}`,onClick:e=>handleClick(id,e),className:`block transition-all duration-300 text-sm leading-tight ${activeHeading===id?\"text-orange-600 font-semibold border-b pb-1 border-orange-500\":\"text-gray-600 hover:text-gray-900\"}`,children:text})},id))})]})};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withTableOfContentsAndReadingTime(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...TableOfContentsAndReadingTime(props)});};}withTableOfContentsAndReadingTime.displayName=\"TableOfContentsAndReadingTime\";\nexport const __FramerMetadata__ = {\"exports\":{\"TableOfContentsAndReadingTime\":{\"type\":\"override\",\"name\":\"TableOfContentsAndReadingTime\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTableOfContentsAndReadingTime\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContentsAndReadingTime\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TOCMaker_Timer.map"],"mappings":"yMAAsG,SAAgB,GAA+B,CAAC,GAAK,CAAC,EAAS,GAAa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