"use client"

import {
  resolveMailSettingsSection,
  type MailSettingsSectionId,
} from "@/lib/mail-settings/settings-nav"
import { DisplaySettingsSection } from "@/components/gmail/settings/sections/display-settings-section"
import { AccountsSettingsSection } from "@/components/gmail/settings/sections/accounts-settings-section"
import { LabelsFoldersSettingsSection } from "@/components/gmail/settings/sections/labels-folders-settings-section"
import { NotificationsSettingsSection } from "@/components/gmail/settings/sections/notifications-settings-section"
import { AutomationSettingsSection } from "@/components/gmail/settings/sections/automation-settings-section"
import { AgendaSettingsSection } from "@/components/gmail/settings/sections/agenda-settings-section"

const SECTIONS: Record<MailSettingsSectionId, React.ComponentType> = {
  display: DisplaySettingsSection,
  accounts: AccountsSettingsSection,
  labels: LabelsFoldersSettingsSection,
  notifications: NotificationsSettingsSection,
  automation: AutomationSettingsSection,
  agenda: AgendaSettingsSection,
}

export function MailSettingsSectionView({
  sectionId,
}: {
  sectionId: MailSettingsSectionId
}) {
  const Section = SECTIONS[sectionId]
  return <Section />
}

export function MailSettingsSectionFromSegments({
  segments,
}: {
  segments?: string[]
}) {
  const sectionId = resolveMailSettingsSection(segments)
  return <MailSettingsSectionView sectionId={sectionId} />
}
