//#region src/ts-utils.d.ts type GrowToSize = A["length"] extends N ? A : GrowToSize; type FixedArray = GrowToSize; type ArrayOfSameLength = { [K in keyof T]: U; }; type LessThan = TNumber extends TArray["length"] ? TArray[number] : LessThan; //#endregion //#region src/types.d.ts /** * The maximum number of ayahs (verses) that can exist in any surah (chapter) of the Quran. * This maximum occurs in Surah Al-Baqarah (2), which has 286 ayahs. */ declare const maxAyahsInSurah = 286; /** * Total number of surahs (chapters) in the Quran. * This is constant across all riwayas. */ declare const numSurahs = 114; /** * Number of Rub al-Hizbs (quarters) in each Juz. * This is constant across all riwayas. */ declare const numRubsInJuz = 8; /** * Default metadata for the Quran (uses Hafs riwaya as default). * * @remarks * Hafs metadata includes: * - 6236 ayahs (verses) * - 114 surahs (chapters) * - 604 pages * - 30 juzs (parts) * - 60 hizbs (sections) * - 240 rub al-hizbs (quarters) * - 0 thumun al-hizbs (eighths) - not used in Hafs * - 15 sajdas (prostrations) * - 556 rukus * - 7 manzils * * @example * ```typescript * import { meta } from 'quran-meta/hafs' * console.log(meta.numAyahs) // 6236 * ``` */ /** * Riwaya-specific metadata type. * For tree-shakeable imports, use specific entry points: * - 'quran-meta/hafs' for Hafs only * - 'quran-meta/qalun' for Qalun only * - 'quran-meta/warsh' for Warsh only * * @example * ```typescript * import { meta } from 'quran-meta/hafs' // Only Hafs data bundled * import { meta } from 'quran-meta/qalun' // Only Qalun data bundled * ``` */ /** * Represents the complete metadata structure for Quranic information. * Contains counts for all structural divisions of the Quran. * * @remarks * Different riwayas may have different values for these properties. * Most notably, Qalun has 6214 ayahs while Hafs has 6236 ayahs. * * @example * ```typescript * import { meta, riwayaMeta } from 'quran-meta' * * // Hafs metadata (default) * console.log(meta.numAyahs) // 6236 * * // Qalun metadata * console.log(riwayaMeta.Qalun.numAyahs) // 6214 * ``` */ interface QuranMeta { /** Name of the riwaya (recitation tradition) */ riwayaName: RiwayaName; /** Total number of ayahs (verses) in this riwaya */ numAyahs: number; /** Total number of surahs (chapters) - always 114 */ numSurahs: number; /** Total number of pages - typically 604 */ numPages: number; /** Total number of juzs (parts) - always 30 */ numJuzs: number; /** Total number of hizbs (sections) - always 60 */ numHizbs: number; /** Total number of rub al-hizbs (quarters) - always 240 */ numRubAlHizbs: number; /** Total number of thumun al-hizbs (eighths) - 0 for Hafs, 480 for Qalun */ numThumunAlHizbs: number; /** Number of rubs (quarters) in each juz - always 8 */ numRubsInJuz: number; /** Total number of sajdas (prostrations) - varies by riwaya */ numSajdas: number; /** Total number of rukus (sections) - varies by riwaya */ numRukus: number; /** Total number of manzils (7-day reading divisions) - always 7 */ numManzils: number; } /** * Creates a type representing a range of numbers from TStart to TEnd (inclusive). * * @typeParam TStart - The starting number of the range * @typeParam TEnd - The ending number of the range * * * @remarks * This type uses the Exclude utility type along with a LessThan helper type * to generate a union of all numbers within the specified range. */ type NumericRange = Exclude, LessThan>; /** * Represents a valid Surah number in the Quran. * A type that ensures the number is within the valid range of Surahs (1 to 114). */ type Surah = NumericRange<1, typeof numSurahs>; /** * Represents the number of an ayah (verse) within a surah. * Valid values are between 1 and the maximum number of ayahs in any surah. * */ type AyahNo = NumericRange<1, typeof maxAyahsInSurah>; /** * Represents a valid thumun al-Hizb (Eighth of a Hizb) identifier. * The value must be a number between 1 and 480 (maximum across all riwayas). * Uses 1-based indexing where 1 is the first thumun al-hizb. * * @remarks * - Hafs: 0 ThumunAlHizbs (not supported) * - Qalun: 480 ThumunAlHizbs * - Warsh: 0 ThumunAlHizbs (no verified source data) */ type ThumunAlHizbId = NumericRange<1, 480>; /** * Represents a valid Rub al-Hizb (quarter of a Hizb) identifier. * The value must be a number between 1 and 240 (consistent across all riwayas). * Uses 1-based indexing where 1 is the first rub al-hizb. */ type RubAlHizbId = NumericRange<1, 240>; /** * Represents a valid Hizb number in the Quran. * A Hizb is one of 60 equal divisions of the Quran. * Uses 1-based indexing where 1 is the first hizb. */ type HizbId = NumericRange<1, 60>; /** * Represents a numeric identifier for an Ayah (verse) in the Quran. * The value should be between 0 and the total number of Ayahs. */ type AyahId = number; /** * Represents a valid page number within the Quran. * Uses 1-based indexing where 1 is the first page (typically 604 pages total). */ type Page = NumericRange<1, 604>; /** * Represents a Manzil number in the Quran. * A Manzil is one of seven roughly equal parts of the Quran used for sequential reading over seven days. * Uses 1-based indexing where 1 is the first manzil (1-7). */ type Manzil = NumericRange<1, 7>; /** * A type representing a valid Ruku (section) number in the Quran. * Uses 1-based indexing where 1 is the first ruku (typically 556 rukus in Hafs). */ type Ruku = NumericRange<1, 556>; /** * Represents a Juz (part) number in the Quran. * The Quran is traditionally divided into 30 Juzs for ease of recitation and memorization. * Uses 1-based indexing where 1 is the first juz (1-30). */ type Juz = NumericRange<1, 30>; /** * Represents a part (rub') number within a Juz. * A numeric value ranging from 1 to the total number of rub's (quarters) in a Juz. * A number constrained between 1 and the total number of rub's in a Juz */ type JuzPart = NumericRange<1, typeof numRubsInJuz>; type SurahInfo = [startAyahId: AyahId, ayahCount: AyahNo, surahOrder: Surah, rukuCount: Ruku, name: string, isMeccan: boolean]; type SurahListType = FixedArray; type SurahName = [name: string, translitName: string]; interface RangeMeta { firstAyahId: AyahId; lastAyahId: AyahId; first: SurahAyah; last: SurahAyah; } /** * Represents the structure of a Juz and Hizb combination in the Quran */ interface ThumunAlHizb { juz: Juz; juzPart: JuzPart; hizbId: HizbId; rubAlHizbId: RubAlHizbId; thumunAlHizbId: ThumunAlHizbId; } type ThumunAlHizbMeta = ThumunAlHizb & RangeMeta; /** * Represents the structure of a Juz and Hizb combination in the Quran */ interface RubAlHizb { juz: Juz; juzPart: JuzPart; hizbId: HizbId; rubAlHizbId: RubAlHizbId; } type RubAlHizbMeta = RubAlHizb & RangeMeta; type SurahAyah = [Surah, AyahNo]; type AyahRange = [AyahId, AyahId]; type SurahAyahSegment = [Surah, AyahNo | [AyahNo, AyahNo]]; type SurahMeta = { name: string; surahNum: Surah; ayahCount: AyahNo; surahOrder: Surah; rukuCount: Ruku; isMeccan: boolean; } & RangeMeta; type PageMeta = { pageNum: Page; } & RangeMeta; type ManzilMeta = { manzilNum: Manzil; } & RangeMeta; type JuzMeta = { juzNum: Juz; } & RangeMeta; type RukuMeta = { rukuNum: Ruku; } & RangeMeta; type AyahCountBetweenJuzSurah = NumericRange<0, typeof maxAyahsInSurah>; /** * The juz span of a surah, as returned by `findJuzMetaBySurah` */ interface SurahJuzMeta { /** The juz containing the given ayah */ leftJuz: Juz; /** * Old spelling of `leftJuz`. * * @deprecated Use `leftJuz`. */ leftjuz: Juz; /** Ayahs from the start of `leftJuz` to the start of the surah */ ayahsBetweenJuzSurah: AyahCountBetweenJuzSurah; /** The juz the surah ends in */ rightJuz: Juz; /** The first ayah id of `leftJuz` */ leftAyahId: AyahId; /** The first ayah id after `rightJuz`, i.e. `numAyahs + 1` when `rightJuz` is the last juz */ rightAyahId: AyahId; } /** * The juz an ayah belongs to and how far the start of its surah is from the start of that juz */ interface JuzAndShift { juz: Juz; /** First ayah id of the juz */ leftAyahId: AyahId; /** Ayahs between the start of the juz and the start of the surah */ ayahsBetweenJuzSurah: AyahCountBetweenJuzSurah; } type RangeMode = "juz" | "surah" | "ayah" | "page" | "ruku" | "all"; interface SurahAyahPos { surah: Surah; ayah: AyahNo; } interface AyahMeta extends SurahAyahPos { juz: Juz; juzPart: JuzPart; hizbId: HizbId; rubAlHizbId: RubAlHizbId; thumunAlHizbId?: ThumunAlHizbId; page: Page; ruku: Ruku; isStartOfQuarter: boolean; isEndOfQuarter: boolean; isSajdahAyah: boolean; isStartOfPage: boolean; isEndOfPage: boolean; isStartOfJuz: boolean; isEndOfJuz: boolean; isStartOfSurah: boolean; isEndOfSurah: boolean; isStartOfRuku: boolean; isEndOfRuku: boolean; } //#endregion //#region src/lists/types.d.ts interface RiwayaFullData { HizbEighthList: AyahId[]; HizbQuarterList: AyahId[]; JuzList: AyahId[]; ManzilList: AyahId[]; PageList: AyahId[]; RukuList: AyahId[]; SajdaList: AyahId[]; SurahList: FixedArray; meta: QuranMeta; } type RiwayasNames = ["Bazzi", "Douri", "Hafs", "Qalun", "Qunbul", "Shuba", "Sousi", "Warsh"]; type RiwayaName = RiwayasNames[number]; type AllListsNames = keyof Omit; interface MissingListsPerRiwaya { Bazzi: ["HizbEighthList"]; Douri: ["HizbEighthList"]; Hafs: ["HizbEighthList"]; Qalun: []; Qunbul: ["HizbEighthList"]; Shuba: ["HizbEighthList"]; Sousi: ["HizbEighthList"]; Warsh: ["HizbEighthList"]; } type Riwayas = { [k in RiwayaName]: Omit & { meta: QuranMeta; }; }; type RiwayaData = Riwayas[RiwayaName]; /** Riwayas that have thumun al-hizb (HizbEighthList) data */ type ThumunRiwayaName = { [R in RiwayaName]: MissingListsPerRiwaya[R] extends [] ? R : never; }[RiwayaName]; type RiwayahsWith = { [R in RiwayaName]: L extends keyof Riwayas[R] ? Riwayas[R] : never; }[RiwayaName]; declare const partNames: readonly ["surah", "juz", "rubAlHizb", "thumunAlHizb", "page", "manzil", "ruku"]; type PartType = (typeof partNames)[number]; /** Maps each {@link PartType} to the name of the list that holds its boundaries */ interface PartListNames { readonly juz: "JuzList"; readonly manzil: "ManzilList"; readonly page: "PageList"; readonly rubAlHizb: "HizbQuarterList"; readonly ruku: "RukuList"; readonly surah: "SurahList"; readonly thumunAlHizb: "HizbEighthList"; } //#endregion export { GrowToSize as $, RangeMode as A, SurahInfo as B, Manzil as C, PageMeta as D, Page as E, RukuMeta as F, ThumunAlHizb as G, SurahListType as H, Surah as I, maxAyahsInSurah as J, ThumunAlHizbId as K, SurahAyah as L, RubAlHizbId as M, RubAlHizbMeta as N, QuranMeta as O, Ruku as P, FixedArray as Q, SurahAyahPos as R, JuzPart as S, NumericRange as T, SurahMeta as U, SurahJuzMeta as V, SurahName as W, numSurahs as X, numRubsInJuz as Y, ArrayOfSameLength as Z, AyahRange as _, RiwayaData as a, JuzAndShift as b, RiwayahsWith as c, ThumunRiwayaName as d, LessThan as et, partNames as f, AyahNo as g, AyahMeta as h, PartType as i, RubAlHizb as j, RangeMeta as k, Riwayas as l, AyahId as m, MissingListsPerRiwaya as n, RiwayaFullData as o, AyahCountBetweenJuzSurah as p, ThumunAlHizbMeta as q, PartListNames as r, RiwayaName as s, AllListsNames as t, RiwayasNames as u, HizbId as v, ManzilMeta as w, JuzMeta as x, Juz as y, SurahAyahSegment as z };