'use client' import { useEffect, useState } from 'react' import type { HeadingItem } from './headings.js' export type TableOfContentsClassNames = { item?: string label?: string /** Every link. */ link?: string /** Added to the link of the section being read. */ linkActive?: string list?: string nav?: string } export type TableOfContentsProps = { classNames?: TableOfContentsClassNames /** From extractHeadings — the same ids as the headings rendered with `headingIds`. */ items: readonly ({ level?: HeadingItem['level'] } & Pick)[] /** Text above the list (from the panel). Also the nav's accessible name. Empty → none. */ label?: null | string /** * Where the "reading line" is, as a fraction of the viewport height: the * current section is the last heading above it. Default 0.3. */ offset?: number } /** * Table of contents with no styles: a