'use client'

import type { ReactNode } from 'react'
import type { MissionControlBridgeStatusResponse } from '@/services/api/missionControl'
import type { ExplorerStats } from '@/services/api/stats'
import type { ChainActivityContext } from '@/utils/activityContext'
import ActivityContextPanel from '@/components/common/ActivityContextPanel'
import DisclosureSection from '@/components/common/DisclosureSection'
import FreshnessTrustNote from '@/components/common/FreshnessTrustNote'

export default function ExplorerFreshnessDisclosure({
  context,
  stats,
  bridgeStatus,
  scopeLabel,
  activityTitle = 'Recency',
  title = 'Index freshness',
  className = 'mb-4',
  children,
}: {
  context: ChainActivityContext
  stats?: ExplorerStats | null
  bridgeStatus?: MissionControlBridgeStatusResponse | null
  scopeLabel: string
  activityTitle?: string
  title?: string
  className?: string
  children?: ReactNode
}) {
  return (
    <DisclosureSection title={title} defaultOpen={false} alwaysCollapsible className={className}>
      <ActivityContextPanel compact context={context} title={activityTitle} />
      <FreshnessTrustNote
        className="mt-2"
        context={context}
        stats={stats}
        bridgeStatus={bridgeStatus}
        scopeLabel={scopeLabel}
      />
      {children}
    </DisclosureSection>
  )
}
