'use client'
import { Feedback } from '~/components/Feedback'
import { LegacyGuidesSidebar } from '~/components/GuidesSidebar.legacy'
import { VideoPreview } from '~/components/VideoPreview'
import { LayoutSwitchButton } from '~/features/DocsLayout/LayoutSwitchButton'
import { useDocsLayoutV2 } from '~/features/DocsLayout/useDocsLayoutV2'
import { HeadingSlotCrumb } from '~/layouts/HeadingSlot'
import { RightRailPortal } from '~/layouts/RightRail'
import { useSendTelemetryEvent } from '~/lib/telemetry'
import { isFeatureEnabled } from 'common'
import { PREFERRED_SOURCE_URL } from 'common/markdown-affordance'
import { Google } from 'icons'
import { usePathname } from 'next/navigation'
import { cn, IconGitHubSolid } from 'ui'
import { ExpandableVideo } from 'ui-patterns/ExpandableVideo'
import { TocPrimitive, TOCScrollArea } from 'ui-patterns/Toc'
import type { TOCItemType } from 'ui-patterns/Toc/server/get-toc'
import { toTocTree } from 'ui-patterns/Toc/toc'
import { useTocAnchors } from '../features/docs/GuidesMdx.state'
interface TOCHeader {
id?: string
text: string
link: string
level: number
}
interface GuidesRightRailProps {
video?: string
videoTitle?: string
hideToc?: boolean
editHref?: string
}
interface GuidesSidebarProps extends GuidesRightRailProps {
className?: string
}
interface GuidePageLinksProps {
editHref?: string
className?: string
}
interface GuideTocProps {
toc: TOCItemType[]
activeUrl: string | undefined
}
interface GuideTocLinkProps {
item: TOCItemType
isActive: boolean
hasActiveBar?: boolean
className?: string
}
const GuidesSidebar = ({ className, ...props }: GuidesSidebarProps) =>
useDocsLayoutV2() ? (