// Festivals & Vrats (observance reference) module barrel. Re-exports the
// module's types + data and defines the lookup helpers. Standalone like
// `tirtha/` / `vaar/` — no `Category` value and no `getContentForDeity` wiring
// (this is descriptive calendar reference, not deity-keyed recitation); reverse
// lookup is via `getFestivalsForDeity`.
import type { Bilingual, Deity } from '../types.js'
import type { FestivalCategory, FestivalEntry } from './types.js'
import { EKADASHIS } from './ekadashis.js'
import { TITHI_VRATS } from './tithi-vrats.js'
import { FESTIVALS } from './festivals.js'

export type * from './types.js'
export { EKADASHIS } from './ekadashis.js'

/**
 * Every festival/vrat entry across all categories, concatenated. Batch A = the
 * 26 Ekādaśīs; Batch B = the recurring tithi-vrats; Batch C = the major
 * festivals. Reverse lookups (`getFestivalsByCategory`, `getFestival`,
 * `getFestivalsForDeity`) flow from this, so new data files only need importing
 * + concatenating here.
 */
export function getAllFestivals(): readonly FestivalEntry[] {
  return [...EKADASHIS, ...TITHI_VRATS, ...FESTIVALS]
}

/** The 24 regular + 2 Adhika-māsa Ekādaśī vrats (Viṣṇu). */
export function getEkadashis(): readonly FestivalEntry[] {
  return EKADASHIS
}

/** Look up a single entry by its (module-unique) `id`; `undefined` if unknown. */
export function getFestival(id: string): FestivalEntry | undefined {
  return getAllFestivals().find((f) => f.id === id)
}

/** Every entry of a given category (`ekadashi` | `tithi-vrat` | `festival`). */
export function getFestivalsByCategory(category: FestivalCategory): readonly FestivalEntry[] {
  return getAllFestivals().filter((f) => f.category === category)
}

/** Every entry whose `deity` cross-links to the given roster slug. */
export function getFestivalsForDeity(deity: Deity): readonly FestivalEntry[] {
  return getAllFestivals().filter((f) => f.deity === deity)
}

/**
 * Plain disclaimer for a detail-screen footer. Deliberately names no sources —
 * research provenance lives in `festivals/SOURCES.md` and in code comments,
 * never in consumer UI. (Audited source-free, like `TIRTHA_SOURCES`.)
 */
export const FESTIVAL_SOURCES: Bilingual = {
  en: 'Festival and vrat observances, the tithi they fall on, and the stories told of them vary by tradition, region and sampradaya — this is one widely-followed account, and carries no calendar dates. For vrat observance and dates, follow local temple and pandit guidance and a current panchang.',
  hi: 'व्रत-पर्व, उनकी तिथि, एवं उनसे जुड़ी कथाएँ परम्परा, क्षेत्र एवं सम्प्रदाय के अनुसार भिन्न होती हैं — यह एक व्यापक रूप से मान्य विवरण है, एवं इसमें कोई पंचांग-तिथि नहीं दी गई है। व्रत-पालन एवं तिथियों के लिए स्थानीय मन्दिर एवं पण्डित जी के मार्गदर्शन तथा प्रचलित पंचांग का अनुसरण करें।',
}
