"use client" import React, { useCallback, useEffect, useMemo, useState } from 'react' import type { Faq } from '../../types/faq' import { FaqAccordion, type FaqItem } from '../faq-accordion' import { useSelfFetch } from '../../hooks/use-self-fetch' import { buildSuggestionUrl } from '../../utils/suggestion-url' import { serializeJsonLd } from '../../utils/common' import { useScrollToHash } from '../../hooks/use-scroll-to-hash' import { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../utils/same-page-hash-nav' import { faqSectionSlug, parseFaqHash, type FaqHashTarget } from '../../utils/faq-anchor' import { cn } from '../../utils/cn' import { buildFaqJsonLdFromFaqs, type FaqSchemaOptions } from './json-ld' import { SECTION_HEADING_CLASS } from '../layout/page-heading' export interface FaqSectionProps { /** * SSR hydrate. When provided, the hook skips the first client fetch (per * useSelfFetch contract). The consuming server page resolves FAQs then drills * them into this prop — the lib never re-fetches what the host already gated on. */ initialFaqs?: Faq[] /** Both required together for entity-attached FAQs; partial → bare /api/faqs. */ entityType?: string entityId?: number | string /** * Heading node above the grouped list. `undefined` → default * `