@nepdatejs/core 0.0.0-bootstrap → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["bsMonths","adMonths"],"sources":["../src/errors.ts","../src/epoch.ts","../src/locale/en.ts","../src/locale/ne.ts","../src/locale/registry.ts","../src/config.ts","../src/ad/calendar.ts","../src/bs/table.ts","../src/bs/data-api.ts","../src/create.ts","../src/convert.ts","../src/projected.ts","../src/clock.ts","../src/arithmetic.ts","../src/compare.ts","../src/locale/index.ts","../src/format.ts","../src/fiscal.ts","../src/parse.ts","../src/time.ts"],"sourcesContent":["export type NepDateRangeErrorCode =\n /** The year, month or day does not exist in that calendar. */\n | 'INVALID_DATE'\n /** The date is outside the BS table, so it cannot be a BS date or be converted. */\n | 'OUT_OF_TABLE'\n /** A value of the wrong kind: not an integer, unknown time zone, bad text, … */\n | 'INVALID_ARGUMENT';\n\n/** Thrown for any invalid date or argument. Check `code`, not the message. */\nexport class NepDateRangeError extends RangeError {\n readonly code: NepDateRangeErrorCode;\n\n constructor(code: NepDateRangeErrorCode, message: string) {\n super(message);\n this.name = 'NepDateRangeError';\n this.code = code;\n }\n}\n\nexport type NepDateDataErrorCode =\n 'EMPTY' | 'BAD_MONTH_COUNT' | 'BAD_MONTH' | 'BAD_YEAR_TOTAL' | 'BAD_ANCHOR';\n\n/** Thrown when a BS table passed to `setBsData` or `patchBsYear` is not valid. */\nexport class NepDateDataError extends Error {\n readonly code: NepDateDataErrorCode;\n /** The BS year at fault, when there is one. */\n readonly year: number | undefined;\n /** The month (1–12) at fault, when there is one. */\n readonly month: number | undefined;\n\n constructor(\n code: NepDateDataErrorCode,\n message: string,\n year?: number,\n month?: number,\n ) {\n super(message);\n this.name = 'NepDateDataError';\n this.code = code;\n this.year = year;\n this.month = month;\n }\n}\n","import { NepDateRangeError } from './errors';\nimport type { EpochDay, Weekday } from './types';\n\n/** Brand a whole number of days since 1970-01-01 as an `EpochDay`. */\nexport function toEpochDay(value: number): EpochDay {\n if (!Number.isSafeInteger(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(value)} is not a whole number of days.`,\n );\n }\n\n return value as EpochDay;\n}\n\n/** The weekday of a day count. 1970-01-01 was a Thursday. */\nexport function weekdayOf(epoch: EpochDay): Weekday {\n return ((((epoch + 4) % 7) + 7) % 7) as Weekday;\n}\n","import type { LocaleData } from './registry';\n\nconst bsMonths = [\n 'Baisakh',\n 'Jestha',\n 'Asar',\n 'Shrawan',\n 'Bhadra',\n 'Ashwin',\n 'Kartik',\n 'Mangsir',\n 'Poush',\n 'Magh',\n 'Falgun',\n 'Chaitra',\n];\nconst adMonths = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n];\n\nexport const en: LocaleData = {\n digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],\n weekdays: {\n long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],\n },\n months: {\n AD: { long: adMonths, short: adMonths.map((name) => name.slice(0, 3)) },\n BS: { long: bsMonths, short: bsMonths.map((name) => name.slice(0, 3)) },\n },\n calendarNames: { AD: 'AD', BS: 'BS' },\n labels: {\n today: 'Today',\n clear: 'Clear date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n month: 'Month',\n year: 'Year',\n openCalendar: 'Open calendar',\n chooseDate: 'Choose a date',\n calendar: 'Calendar',\n presets: 'Shortcuts',\n fiscalYear: 'Fiscal year',\n time: 'Time',\n hour: 'Hour',\n minute: 'Minute',\n now: 'Now',\n done: 'Done',\n },\n time: { am: 'AM', pm: 'PM' },\n presets: {\n today: 'Today',\n yesterday: 'Yesterday',\n tomorrow: 'Tomorrow',\n thisWeek: 'This week',\n lastWeek: 'Last week',\n last7Days: 'Last 7 days',\n last30Days: 'Last 30 days',\n thisMonth: 'This month',\n lastMonth: 'Last month',\n thisYear: 'This year',\n thisFiscalYear: 'This fiscal year',\n lastFiscalYear: 'Last fiscal year',\n },\n messages: {\n invalidFormat: {\n AD: 'Enter an AD date as YYYY-MM-DD.',\n BS: 'Enter a BS date as YYYY-MM-DD.',\n },\n outOfRange: 'Choose a date from {min} to {max}.',\n onOrAfter: 'Choose {min} or later.',\n onOrBefore: 'Choose {max} or earlier.',\n unavailable: 'This date is not available.',\n rangeTooShort: 'Choose at least {min} days.',\n rangeTooLong: 'Choose at most {max} days.',\n tooManyDates: 'Choose at most {max} dates.',\n invalidTime: 'Enter a time as HH:MM.',\n },\n};\n","import type { LocaleData } from './registry';\n\nconst bsMonths = [\n 'बैशाख',\n 'जेठ',\n 'असार',\n 'साउन',\n 'भदौ',\n 'असोज',\n 'कार्तिक',\n 'मङ्सिर',\n 'पुस',\n 'माघ',\n 'फाल्गुण',\n 'चैत',\n];\nconst adMonths = [\n 'जनवरी',\n 'फेब्रुअरी',\n 'मार्च',\n 'अप्रिल',\n 'मे',\n 'जुन',\n 'जुलाई',\n 'अगस्ट',\n 'सेप्टेम्बर',\n 'अक्टोबर',\n 'नोभेम्बर',\n 'डिसेम्बर',\n];\n\nexport const ne: LocaleData = {\n digits: ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'],\n weekdays: {\n long: ['आइतबार', 'सोमबार', 'मङ्गलबार', 'बुधबार', 'बिहिबार', 'शुक्रबार', 'शनिबार'],\n short: ['आइत', 'सोम', 'मङ्गल', 'बुध', 'बिही', 'शुक्र', 'शनि'],\n narrow: ['आ', 'सो', 'मं', 'बु', 'बि', 'शु', 'श'],\n },\n months: {\n AD: { long: adMonths, short: adMonths },\n BS: { long: bsMonths, short: bsMonths },\n },\n calendarNames: { AD: 'ई.सं.', BS: 'वि.सं.' },\n labels: {\n today: 'आज',\n clear: 'मिति हटाउनुहोस्',\n previousMonth: 'अघिल्लो महिना',\n nextMonth: 'अर्को महिना',\n previousYear: 'अघिल्लो वर्ष',\n nextYear: 'अर्को वर्ष',\n month: 'महिना',\n year: 'वर्ष',\n openCalendar: 'पात्रो खोल्नुहोस्',\n chooseDate: 'मिति छान्नुहोस्',\n calendar: 'पात्रो',\n presets: 'छिटो छनोट',\n fiscalYear: 'आर्थिक वर्ष',\n time: 'समय',\n hour: 'घण्टा',\n minute: 'मिनेट',\n now: 'अहिले',\n done: 'भयो',\n },\n time: { am: 'पूर्वाह्न', pm: 'अपराह्न' },\n presets: {\n today: 'आज',\n yesterday: 'हिजो',\n tomorrow: 'भोलि',\n thisWeek: 'यो हप्ता',\n lastWeek: 'गत हप्ता',\n last7Days: 'पछिल्लो ७ दिन',\n last30Days: 'पछिल्लो ३० दिन',\n thisMonth: 'यो महिना',\n lastMonth: 'गत महिना',\n thisYear: 'यो वर्ष',\n thisFiscalYear: 'यो आर्थिक वर्ष',\n lastFiscalYear: 'गत आर्थिक वर्ष',\n },\n messages: {\n invalidFormat: {\n AD: 'ई.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।',\n BS: 'वि.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।',\n },\n outOfRange: '{min} देखि {max} सम्मको मिति छान्नुहोस्।',\n onOrAfter: '{min} वा त्यसपछिको मिति छान्नुहोस्।',\n onOrBefore: '{max} वा त्यसअघिको मिति छान्नुहोस्।',\n unavailable: 'यो मिति उपलब्ध छैन।',\n rangeTooShort: 'कम्तीमा {min} दिन छान्नुहोस्।',\n rangeTooLong: 'बढीमा {max} दिन छान्नुहोस्।',\n tooManyDates: 'बढीमा {max} मिति छान्नुहोस्।',\n invalidTime: 'समय HH:MM ढाँचामा लेख्नुहोस्।',\n },\n};\n","import { NepDateRangeError } from '../errors';\nimport type { LocaleCode } from '../types';\nimport { en } from './en';\nimport { ne } from './ne';\n\ntype Names12 = readonly string[];\n\n/** Everything a language needs: digits, names, UI labels and validation messages. */\nexport interface LocaleData {\n /** Ten digit characters, 0–9. */\n readonly digits: readonly string[];\n /** Seven names each, Sunday first. */\n readonly weekdays: {\n readonly long: readonly string[];\n readonly short: readonly string[];\n readonly narrow: readonly string[];\n };\n /** Twelve names each, first month first. */\n readonly months: {\n readonly AD: { readonly long: Names12; readonly short: Names12 };\n readonly BS: { readonly long: Names12; readonly short: Names12 };\n };\n /** How each calendar is named in this language: \"BS\" / \"वि.सं.\". */\n readonly calendarNames: { readonly AD: string; readonly BS: string };\n readonly labels: {\n readonly today: string;\n readonly clear: string;\n readonly previousMonth: string;\n readonly nextMonth: string;\n readonly previousYear: string;\n readonly nextYear: string;\n readonly month: string;\n readonly year: string;\n readonly openCalendar: string;\n readonly chooseDate: string;\n readonly calendar: string;\n /** Picker shortcuts (presets) and the name of their list. */\n readonly presets: string;\n readonly fiscalYear: string;\n readonly time: string;\n readonly hour: string;\n readonly minute: string;\n readonly now: string;\n readonly done: string;\n };\n /** Words for 12-hour times. */\n readonly time: { readonly am: string; readonly pm: string };\n /** Names of the built-in picker presets. */\n readonly presets: {\n readonly today: string;\n readonly yesterday: string;\n readonly tomorrow: string;\n readonly thisWeek: string;\n readonly lastWeek: string;\n readonly last7Days: string;\n readonly last30Days: string;\n readonly thisMonth: string;\n readonly lastMonth: string;\n readonly thisYear: string;\n readonly thisFiscalYear: string;\n readonly lastFiscalYear: string;\n };\n /** Messages may use {min} and {max} placeholders. */\n readonly messages: {\n readonly invalidFormat: { readonly AD: string; readonly BS: string };\n readonly outOfRange: string;\n readonly onOrAfter: string;\n readonly onOrBefore: string;\n readonly unavailable: string;\n /** Range pickers: {min} / {max} are day counts. */\n readonly rangeTooShort: string;\n readonly rangeTooLong: string;\n /** Multiple-date pickers: {max} is a count of dates. */\n readonly tooManyDates: string;\n readonly invalidTime: string;\n };\n}\n\nconst locales = new Map<string, LocaleData>([\n ['en', en],\n ['ne', ne],\n]);\n\n/** Add or replace a language. Lists must have the right lengths (10 digits, 7 weekdays, 12 months). */\nexport function registerLocale(code: LocaleCode, data: LocaleData): void {\n const checks: [string, readonly string[], number][] = [\n ['digits', data.digits, 10],\n ['weekdays.long', data.weekdays.long, 7],\n ['weekdays.short', data.weekdays.short, 7],\n ['weekdays.narrow', data.weekdays.narrow, 7],\n ['months.AD.long', data.months.AD.long, 12],\n ['months.AD.short', data.months.AD.short, 12],\n ['months.BS.long', data.months.BS.long, 12],\n ['months.BS.short', data.months.BS.short, 12],\n ];\n for (const [name, list, length] of checks) {\n if (list.length !== length) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `Locale \"${code}\": ${name} must have ${length} entries, not ${list.length}.`,\n );\n }\n }\n locales.set(code, data);\n}\n\nexport function hasLocale(code: LocaleCode): boolean {\n return locales.has(code);\n}\n\n/** The data for a locale, or English when the locale is not registered. */\nexport function localeData(code: LocaleCode): LocaleData {\n return locales.get(code) ?? en;\n}\n","import { NepDateRangeError } from './errors';\nimport { hasLocale } from './locale/registry';\nimport type { LocaleCode, Weekday } from './types';\n\n/**\n * Settings shared by both calendars. Calendar data is not here: the BS table is\n * managed by setBsData/patchBsYear, and AD needs no data (docs/plan D-001).\n */\nexport interface NepDateConfig {\n /** Which time zone decides \"today\" and the calendar day of an instant. */\n readonly timeZone: string;\n readonly weekStartsOn: Weekday;\n readonly weekendDays: readonly Weekday[];\n readonly defaultLocale: LocaleCode;\n}\n\nconst DEFAULTS: NepDateConfig = Object.freeze({\n timeZone: 'Asia/Kathmandu',\n weekStartsOn: 0,\n weekendDays: Object.freeze<Weekday[]>([6]),\n defaultLocale: 'en',\n});\n\nlet current: NepDateConfig = DEFAULTS;\n\n/** Change one or more settings. Every value is checked before any is applied. */\nexport function configure(changes: Partial<NepDateConfig>): void {\n const next = { ...current, ...changes };\n\n if (!isTimeZone(next.timeZone)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `\"${next.timeZone}\" is not a time zone.`,\n );\n }\n if (!isWeekday(next.weekStartsOn)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `weekStartsOn must be 0–6, not ${String(next.weekStartsOn)}.`,\n );\n }\n if (\n !next.weekendDays.every(isWeekday) ||\n new Set(next.weekendDays).size !== next.weekendDays.length\n ) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n 'weekendDays must be different weekdays, each 0–6.',\n );\n }\n if (!hasLocale(next.defaultLocale)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `Locale \"${next.defaultLocale}\" is not registered.`,\n );\n }\n\n current = Object.freeze({\n ...next,\n weekendDays: Object.freeze([...next.weekendDays]),\n });\n}\n\nexport function getConfig(): NepDateConfig {\n return current;\n}\n\n/** Back to the defaults (Kathmandu, Sunday first, Saturday weekend, English). */\nexport function resetConfig(): void {\n current = DEFAULTS;\n}\n\nexport function isWeekday(value: unknown): value is Weekday {\n return Number.isInteger(value) && (value as number) >= 0 && (value as number) <= 6;\n}\n\nfunction isTimeZone(value: string): boolean {\n try {\n new Intl.DateTimeFormat('en-US', { timeZone: value });\n\n return true;\n } catch {\n return false;\n }\n}\n","/**\n * The Gregorian (AD) calendar, by arithmetic only: no table, no BS knowledge,\n * no `Date`. Works for any year in ±MAX_AD_YEAR (docs/plan D-001).\n *\n * The day-count algorithms are Howard Hinnant's days_from_civil and\n * civil_from_days (proleptic Gregorian, March-based years).\n */\n\n/** AD years must lie within ±this value. */\nexport const MAX_AD_YEAR = 999_999;\n\nconst DAYS_BEFORE_EPOCH = 719_468; // 0000-03-01 → 1970-01-01\nconst DAYS_PER_ERA = 146_097; // 400 years\nconst MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\nexport function isAdLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\n/** Days in an AD month. The month must be 1–12. */\nexport function adMonthLength(year: number, month: number): number {\n return month === 2 && isAdLeapYear(year) ? 29 : (MONTH_DAYS[month - 1] ?? 0);\n}\n\nexport function isValidAdDate(year: number, month: number, day: number): boolean {\n return (\n Number.isInteger(year) &&\n Number.isInteger(month) &&\n Number.isInteger(day) &&\n Math.abs(year) <= MAX_AD_YEAR &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= adMonthLength(year, month)\n );\n}\n\n/** Days since 1970-01-01 of a valid AD date. */\nexport function adToEpoch(year: number, month: number, day: number): number {\n const y = month <= 2 ? year - 1 : year;\n const era = Math.floor(y / 400);\n const yearOfEra = y - era * 400;\n const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;\n const dayOfEra =\n yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\n return era * DAYS_PER_ERA + dayOfEra - DAYS_BEFORE_EPOCH;\n}\n\n/** The AD year, month and day of a day count. */\nexport function epochToAd(epoch: number): { year: number; month: number; day: number } {\n const z = epoch + DAYS_BEFORE_EPOCH;\n const era = Math.floor(z / DAYS_PER_ERA);\n const dayOfEra = z - era * DAYS_PER_ERA;\n const yearOfEra = Math.floor(\n (dayOfEra -\n Math.floor(dayOfEra / 1460) +\n Math.floor(dayOfEra / 36_524) -\n Math.floor(dayOfEra / 146_096)) /\n 365,\n );\n const dayOfYear =\n dayOfEra -\n (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n const shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);\n const day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;\n const month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;\n const year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\n return { year, month, day };\n}\n","/**\n * The Bikram Sambat calendar, from its table only. Nothing here reads or\n * produces an AD year: BS dates map to and from day counts (EpochDay) through\n * `epochStart` and the month lengths (docs/plan D-001).\n */\nimport { NepDateRangeError } from '../errors';\nimport type { BsData } from '../types';\nimport { BS_DATA } from './data/years';\n\ninterface BsTable {\n readonly data: BsData;\n readonly lastYear: number;\n /** yearStart[i] = day count of 1 Baisakh of firstYear + i; one extra entry for the end. */\n readonly yearStart: Float64Array;\n /** monthOffset[i * 12 + m] = days from 1 Baisakh to the first of month m + 1 in year i. */\n readonly monthOffset: Uint16Array;\n}\n\nlet data: BsData = freezeData(BS_DATA);\nlet table: BsTable | null = null;\n\n/** Replace the data the table is built from. Callers validate first (data-api.ts). */\nexport function useBsData(next: BsData): void {\n data = freezeData(next);\n table = null;\n}\n\nfunction freezeData(source: BsData): BsData {\n return Object.freeze({\n firstYear: source.firstYear,\n epochStart: source.epochStart,\n verifiedThrough: source.verifiedThrough,\n years: Object.freeze(source.years.map((months) => Object.freeze([...months]))),\n });\n}\n\nexport function currentBsData(): BsData {\n return data;\n}\n\nfunction buildTable(): BsTable {\n const count = data.years.length;\n const yearStart = new Float64Array(count + 1);\n const monthOffset = new Uint16Array(count * 12);\n let start = data.epochStart;\n\n for (let i = 0; i < count; i++) {\n yearStart[i] = start;\n const months = data.years[i] ?? [];\n let offset = 0;\n for (let m = 0; m < 12; m++) {\n monthOffset[i * 12 + m] = offset;\n offset += months[m] ?? 0;\n }\n start += offset;\n }\n yearStart[count] = start;\n\n return { data, lastYear: data.firstYear + count - 1, yearStart, monthOffset };\n}\n\nfunction bsTable(): BsTable {\n return (table ??= buildTable());\n}\n\nexport function bsFirstYear(): number {\n return data.firstYear;\n}\n\nexport function bsLastYear(): number {\n return bsTable().lastYear;\n}\n\n/** The first and last day counts the table covers. */\nexport function bsEpochRange(): { first: number; last: number } {\n const { yearStart } = bsTable();\n\n return { first: yearStart[0] ?? 0, last: (yearStart[yearStart.length - 1] ?? 0) - 1 };\n}\n\n/** Days in a BS month. Throws when the year is outside the table or the month is not 1–12. */\nexport function bsMonthLength(year: number, month: number): number {\n const { lastYear } = bsTable();\n if (!Number.isInteger(year) || year < data.firstYear || year > lastYear) {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `BS year ${String(year)} is outside the supported range (BS ${data.firstYear}–${lastYear}).`,\n );\n }\n if (!Number.isInteger(month) || month < 1 || month > 12) {\n throw new NepDateRangeError(\n 'INVALID_DATE',\n `BS month ${String(month)} does not exist.`,\n );\n }\n\n return data.years[year - data.firstYear]?.[month - 1] ?? 0;\n}\n\nexport function isValidBsDate(year: number, month: number, day: number): boolean {\n try {\n return Number.isInteger(day) && day >= 1 && day <= bsMonthLength(year, month);\n } catch {\n return false;\n }\n}\n\n/** Day count of a valid BS date. */\nexport function bsToEpoch(year: number, month: number, day: number): number {\n const { yearStart, monthOffset } = bsTable();\n const index = year - data.firstYear;\n\n return (yearStart[index] ?? 0) + (monthOffset[index * 12 + month - 1] ?? 0) + day - 1;\n}\n\n/** The BS year, month and day of a day count. Throws when it is outside the table. */\nexport function epochToBs(epoch: number): { year: number; month: number; day: number } {\n const { yearStart, monthOffset } = bsTable();\n const { first, last } = bsEpochRange();\n if (epoch < first || epoch > last) {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `Day ${epoch} is outside the BS table (BS ${data.firstYear}–${bsLastYear()}).`,\n );\n }\n\n // Last year whose start is on or before the day.\n let low = 0;\n let high = yearStart.length - 2;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n if ((yearStart[middle] ?? 0) <= epoch) {\n low = middle;\n } else {\n high = middle - 1;\n }\n }\n const dayOfYear = epoch - (yearStart[low] ?? 0);\n let month = 11;\n while (month > 0 && (monthOffset[low * 12 + month] ?? 0) > dayOfYear) {\n month--;\n }\n\n return {\n year: data.firstYear + low,\n month: month + 1,\n day: dayOfYear - (monthOffset[low * 12 + month] ?? 0) + 1,\n };\n}\n\n/** Whether a BS year is after the last year checked against a published calendar. */\nexport function isProjectedBsYear(year: number): boolean {\n return year > data.verifiedThrough;\n}\n","import { NepDateDataError, NepDateRangeError } from '../errors';\nimport type { BsData } from '../types';\nimport { BS_DATA } from './data/years';\nimport { currentBsData, useBsData } from './table';\n\n/** The first BS month of Nepal's fiscal year: Shrawan. */\nexport const BS_FISCAL_YEAR_START_MONTH = 4;\n\n/** Days a verified year may have. Projected years may be off by one (the bundled BS 2096 lists 364). */\nconst VERIFIED_YEAR_DAYS = [365, 366];\nconst PROJECTED_YEAR_DAYS = [364, 365, 366, 367];\n\n/** Throws NepDateDataError when the table is not usable. Same rules as scripts/gen-data.ts. */\nexport function validateBsData(table: BsData): void {\n if (!Number.isSafeInteger(table.epochStart) || !Number.isInteger(table.firstYear)) {\n throw new NepDateDataError(\n 'BAD_ANCHOR',\n 'firstYear and epochStart must be whole numbers.',\n );\n }\n if (!Number.isInteger(table.verifiedThrough)) {\n throw new NepDateDataError('BAD_ANCHOR', 'verifiedThrough must be a whole number.');\n }\n if (table.years.length === 0) {\n throw new NepDateDataError('EMPTY', 'The BS table has no years.');\n }\n\n table.years.forEach((months, index) => {\n const year = table.firstYear + index;\n if (months.length !== 12) {\n throw new NepDateDataError(\n 'BAD_MONTH_COUNT',\n `BS ${year} lists ${months.length} months, not 12.`,\n year,\n );\n }\n let total = 0;\n months.forEach((days, m) => {\n if (!Number.isInteger(days) || days < 29 || days > 32) {\n throw new NepDateDataError(\n 'BAD_MONTH',\n `BS ${year} month ${m + 1} has ${String(days)} days; expected 29–32.`,\n year,\n m + 1,\n );\n }\n total += days;\n });\n const allowed =\n year <= table.verifiedThrough ? VERIFIED_YEAR_DAYS : PROJECTED_YEAR_DAYS;\n if (!allowed.includes(total)) {\n throw new NepDateDataError(\n 'BAD_YEAR_TOTAL',\n `BS ${year} has ${total} days; expected ${allowed.join(' or ')}.`,\n year,\n );\n }\n });\n}\n\n/** The BS table in use (frozen). */\nexport function getBsData(): BsData {\n return currentBsData();\n}\n\n/** Replace the whole BS table. Only BS results change; AD functions are unaffected. */\nexport function setBsData(table: BsData): void {\n validateBsData(table);\n useBsData(table);\n}\n\n/**\n * Correct one year's month lengths, or add the year just before the first or\n * just after the last. Years after a corrected year move with it; earlier years\n * never move (adding a year before the first keeps every existing year in place).\n */\nexport function patchBsYear(year: number, months: readonly number[]): void {\n const table = currentBsData();\n const lastYear = table.firstYear + table.years.length - 1;\n let next: BsData;\n\n if (year >= table.firstYear && year <= lastYear) {\n next = {\n ...table,\n years: table.years.map((row, index) =>\n index === year - table.firstYear ? months : row,\n ),\n };\n } else if (year === lastYear + 1) {\n next = { ...table, years: [...table.years, months] };\n } else if (year === table.firstYear - 1) {\n const length = months.reduce((total, days) => total + days, 0);\n next = {\n ...table,\n firstYear: year,\n epochStart: table.epochStart - length,\n years: [months, ...table.years],\n };\n } else {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `BS ${String(year)} is not in the table and does not extend it (BS ${table.firstYear}–${lastYear}).`,\n );\n }\n\n setBsData(next);\n}\n\n/** Back to the table bundled with the package. */\nexport function resetBsData(): void {\n useBsData(BS_DATA);\n}\n","import { adMonthLength, isValidAdDate, MAX_AD_YEAR } from './ad/calendar';\nimport { bsMonthLength, isValidBsDate } from './bs/table';\nimport { NepDateRangeError } from './errors';\nimport type {\n AdDate,\n BsDate,\n CalendarDate,\n CalendarSystem,\n DateOf,\n MonthNumber,\n} from './types';\n\n/** An AD date. Any year within ±999,999 is allowed; only conversion to BS is limited. */\nexport function adDate(year: number, month: number, day: number): AdDate {\n if (!isValidAdDate(year, month, day)) {\n throw new NepDateRangeError(\n Number.isInteger(year) && Number.isInteger(month) && Number.isInteger(day)\n ? 'INVALID_DATE'\n : 'INVALID_ARGUMENT',\n Math.abs(year) > MAX_AD_YEAR\n ? `AD year ${String(year)} is outside ±${MAX_AD_YEAR}.`\n : `AD ${String(year)}-${String(month)}-${String(day)} is not a valid date.`,\n );\n }\n\n return Object.freeze({ calendar: 'AD', year, month: month as MonthNumber, day });\n}\n\n/** A BS date. The year must be in the BS table. */\nexport function bsDate(year: number, month: number, day: number): BsDate {\n const length = bsMonthLength(year, month);\n if (!Number.isInteger(day) || day < 1 || day > length) {\n throw new NepDateRangeError(\n Number.isInteger(day) ? 'INVALID_DATE' : 'INVALID_ARGUMENT',\n `BS ${year}-${month} has ${length} days, not ${String(day)}.`,\n );\n }\n\n return Object.freeze({ calendar: 'BS', year, month: month as MonthNumber, day });\n}\n\nexport function createDate<C extends CalendarSystem>(\n calendar: C,\n year: number,\n month: number,\n day: number,\n): DateOf<C> {\n return (\n calendar === 'AD' ? adDate(year, month, day) : bsDate(year, month, day)\n ) as DateOf<C>;\n}\n\nexport function isValidDate(\n calendar: CalendarSystem,\n year: number,\n month: number,\n day: number,\n): boolean {\n return calendar === 'AD'\n ? isValidAdDate(year, month, day)\n : isValidBsDate(year, month, day);\n}\n\n/** Days in a month of either calendar. */\nexport function daysInMonth(\n calendar: CalendarSystem,\n year: number,\n month: number,\n): number {\n if (calendar === 'BS') {\n return bsMonthLength(year, month);\n }\n if (!isValidAdDate(year, month, 1)) {\n throw new NepDateRangeError(\n 'INVALID_DATE',\n `AD ${String(year)}-${String(month)} is not a month.`,\n );\n }\n\n return adMonthLength(year, month);\n}\n\n/** True for a valid, frozen-or-not AD date object (e.g. from JSON). */\nexport function isAdDate(value: unknown): value is AdDate {\n return isDateLike(value, 'AD') && isValidAdDate(value.year, value.month, value.day);\n}\n\n/** True for a valid BS date object (e.g. from JSON). */\nexport function isBsDate(value: unknown): value is BsDate {\n return isDateLike(value, 'BS') && isValidBsDate(value.year, value.month, value.day);\n}\n\nexport function isCalendarDate(value: unknown): value is CalendarDate {\n return isAdDate(value) || isBsDate(value);\n}\n\nfunction isDateLike(\n value: unknown,\n calendar: CalendarSystem,\n): value is { calendar: CalendarSystem; year: number; month: number; day: number } {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const record = value as Record<string, unknown>;\n\n return (\n record['calendar'] === calendar &&\n typeof record['year'] === 'number' &&\n typeof record['month'] === 'number' &&\n typeof record['day'] === 'number'\n );\n}\n","/**\n * The only place the AD and BS calendars meet, and only through EpochDay\n * (docs/plan D-001). Nothing here looks up a year number across calendars.\n */\nimport { adToEpoch, epochToAd } from './ad/calendar';\nimport { bsEpochRange, bsToEpoch, epochToBs } from './bs/table';\nimport { getConfig } from './config';\nimport { adDate, bsDate } from './create';\nimport { toEpochDay } from './epoch';\nimport { NepDateRangeError } from './errors';\nimport type {\n AdDate,\n BsDate,\n CalendarDate,\n CalendarSystem,\n DateOf,\n EpochDay,\n} from './types';\n\n/** The day count of a date in either calendar. */\nexport function toEpoch(date: CalendarDate): EpochDay {\n return toEpochDay(\n date.calendar === 'AD'\n ? adToEpoch(date.year, date.month, date.day)\n : bsToEpoch(date.year, date.month, date.day),\n );\n}\n\n/** The date of a day count in a calendar. BS throws OUT_OF_TABLE outside the table. */\nexport function fromEpoch<C extends CalendarSystem>(\n epoch: EpochDay,\n calendar: C,\n): DateOf<C> {\n if (calendar === 'AD') {\n const { year, month, day } = epochToAd(epoch);\n\n return adDate(year, month, day) as DateOf<C>;\n }\n assertConvertible(epoch);\n const { year, month, day } = epochToBs(epoch);\n\n return bsDate(year, month, day) as DateOf<C>;\n}\n\nexport function adToBs(date: AdDate): BsDate {\n return fromEpoch(toEpoch(date), 'BS');\n}\n\nexport function bsToAd(date: BsDate): AdDate {\n return fromEpoch(toEpoch(date), 'AD');\n}\n\n/** The same day in the given calendar (the date itself when it is already in it). */\nexport function toCalendar<C extends CalendarSystem>(\n date: CalendarDate,\n calendar: C,\n): DateOf<C> {\n if (date.calendar === calendar) {\n return date as DateOf<C>;\n }\n\n return fromEpoch(toEpoch(date), calendar);\n}\n\n/** The first day that can be converted, in either calendar (the start of the BS table). */\nexport function minDate<C extends CalendarSystem>(calendar: C): DateOf<C> {\n return fromEpoch(toEpochDay(bsEpochRange().first), calendar);\n}\n\n/** The last day that can be converted, in either calendar (the end of the BS table). */\nexport function maxDate<C extends CalendarSystem>(calendar: C): DateOf<C> {\n return fromEpoch(toEpochDay(bsEpochRange().last), calendar);\n}\n\n/** Whether a date can be converted to the other calendar. */\nexport function isConvertible(date: CalendarDate): boolean {\n const epoch = toEpoch(date);\n const { first, last } = bsEpochRange();\n\n return epoch >= first && epoch <= last;\n}\n\n/** The AD day as \"YYYY-MM-DD\", the form to store and send (docs/plan D-003). */\nexport function toIsoDate(date: CalendarDate): string {\n const { year, month, day } = toCalendar(date, 'AD');\n if (year < 0 || year > 9999) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `AD year ${year} cannot be written as YYYY-MM-DD.`,\n );\n }\n\n return `${pad(year, 4)}-${pad(month, 2)}-${pad(day, 2)}`;\n}\n\n/**\n * An AD date from \"YYYY-MM-DD\", or from a longer ISO timestamp by its date part\n * (\"2026-10-18T09:30:00Z\" → 2026-10-18). Null for anything else.\n */\nexport function fromIsoDate(value: string | null | undefined): AdDate | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})(?:$|[T ])/.exec(value ?? '');\n if (!match) {\n return null;\n }\n try {\n return adDate(Number(match[1]), Number(match[2]), Number(match[3]));\n } catch {\n return null;\n }\n}\n\n/** The AD calendar day an instant falls on in a time zone (Nepal by default). */\nexport function fromJsDate(\n instant: Date,\n timeZone: string = getConfig().timeZone,\n): AdDate {\n if (Number.isNaN(instant.getTime())) {\n throw new NepDateRangeError('INVALID_ARGUMENT', 'The Date is invalid.');\n }\n let parts: Intl.DateTimeFormatPart[];\n try {\n parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n era: 'short',\n }).formatToParts(instant);\n } catch {\n throw new NepDateRangeError('INVALID_ARGUMENT', `\"${timeZone}\" is not a time zone.`);\n }\n const part = (type: Intl.DateTimeFormatPartTypes): string =>\n parts.find((item) => item.type === type)?.value ?? '';\n const year = Number(part('year'));\n\n return adDate(\n part('era') === 'BC' ? 1 - year : year,\n Number(part('month')),\n Number(part('day')),\n );\n}\n\n/**\n * The calendar day and time of an ISO timestamp *with a zone* (\"…Z\",\n * \"…+05:45\"), read in `timeZone` (Nepal by default). Null for anything else,\n * including plain dates, which have no instant.\n */\nexport function fromIsoTimestamp(\n value: string | null | undefined,\n timeZone: string = getConfig().timeZone,\n): { readonly date: AdDate; readonly time: string } | null {\n if (!value || !/T.*(?:Z|[+-]\\d{2}:?\\d{2})$/.test(value)) {\n return null;\n }\n const instant = new Date(value);\n if (Number.isNaN(instant.getTime())) {\n return null;\n }\n const time = new Intl.DateTimeFormat('en-GB', {\n timeZone,\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n }).format(instant);\n\n return { date: fromJsDate(instant, timeZone), time };\n}\n\nfunction assertConvertible(epoch: number): void {\n const { first, last } = bsEpochRange();\n if (epoch < first || epoch > last) {\n const { year, month, day } = epochToAd(epoch);\n const from = epochToAd(first);\n const to = epochToAd(last);\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `AD ${isoParts(year, month, day)} is outside the BS table (AD ${isoParts(from.year, from.month, from.day)} to ${isoParts(to.year, to.month, to.day)}).`,\n );\n }\n}\n\nfunction isoParts(year: number, month: number, day: number): string {\n return `${year}-${pad(month, 2)}-${pad(day, 2)}`;\n}\n\nfunction pad(value: number, length: number): string {\n return String(value).padStart(length, '0');\n}\n","import { isProjectedBsYear } from './bs/table';\nimport { toCalendar } from './convert';\nimport type { CalendarDate } from './types';\n\n/** Whether the date's BS year is after the last year checked against a published calendar. */\nexport function isProjected(date: CalendarDate): boolean {\n return isProjectedBsYear(toCalendar(date, 'BS').year);\n}\n","import { getConfig } from './config';\nimport { fromIsoTimestamp, fromJsDate, toCalendar } from './convert';\nimport type { AdDate, CalendarSystem, DateOf } from './types';\n\n/**\n * Today's date by the calendar day in `timeZone` (Nepal by default), not the\n * device's zone. The only function in the library that reads the clock.\n */\nexport function today(): AdDate;\nexport function today<C extends CalendarSystem>(\n calendar: C,\n timeZone?: string,\n): DateOf<C>;\nexport function today(\n calendar: CalendarSystem = 'AD',\n timeZone: string = getConfig().timeZone,\n): AdDate | DateOf<CalendarSystem> {\n return toCalendar(fromJsDate(new Date(), timeZone), calendar);\n}\n\n/** The current calendar day and time (HH:MM) in `timeZone` (Nepal by default). */\nexport function now(timeZone: string = getConfig().timeZone): {\n readonly date: AdDate;\n readonly time: { readonly hour: number; readonly minute: number };\n} {\n const current = fromIsoTimestamp(new Date().toISOString(), timeZone);\n const [hour = 0, minute = 0] = (current?.time ?? '00:00').split(':').map(Number);\n\n return {\n date: current?.date ?? fromJsDate(new Date(), timeZone),\n time: Object.freeze({ hour, minute }),\n };\n}\n","import { getConfig, isWeekday } from './config';\nimport { fromEpoch, toCalendar, toEpoch } from './convert';\nimport { createDate, daysInMonth } from './create';\nimport { toEpochDay, weekdayOf } from './epoch';\nimport { NepDateRangeError } from './errors';\nimport type { CalendarDate, DateOf, Weekday } from './types';\n\n/** A date in the same calendar as `D`. */\ntype Same<D extends CalendarDate> = DateOf<D['calendar']>;\n\nexport function addDays<D extends CalendarDate>(date: D, days: number): Same<D> {\n assertInteger(days, 'days');\n\n return fromEpoch(toEpochDay(toEpoch(date) + days), date.calendar) as Same<D>;\n}\n\n/** Move by whole months in the date's own calendar; the day is capped to the new month's length. */\nexport function addMonths<D extends CalendarDate>(date: D, months: number): Same<D> {\n assertInteger(months, 'months');\n const index = date.year * 12 + (date.month - 1) + months;\n const year = Math.floor(index / 12);\n const month = index - year * 12 + 1;\n const day = Math.min(date.day, daysInMonth(date.calendar, year, month));\n\n return createDate(date.calendar, year, month, day) as Same<D>;\n}\n\n/** Move by whole years in the date's own calendar; the day is capped (29 Feb, short BS months). */\nexport function addYears<D extends CalendarDate>(date: D, years: number): Same<D> {\n assertInteger(years, 'years');\n\n return addMonths(date, years * 12);\n}\n\nexport function startOfMonth<D extends CalendarDate>(date: D): Same<D> {\n return createDate(date.calendar, date.year, date.month, 1) as Same<D>;\n}\n\nexport function endOfMonth<D extends CalendarDate>(date: D): Same<D> {\n return createDate(\n date.calendar,\n date.year,\n date.month,\n daysInMonth(date.calendar, date.year, date.month),\n ) as Same<D>;\n}\n\nexport function startOfYear<D extends CalendarDate>(date: D): Same<D> {\n return createDate(date.calendar, date.year, 1, 1) as Same<D>;\n}\n\nexport function endOfYear<D extends CalendarDate>(date: D): Same<D> {\n return createDate(\n date.calendar,\n date.year,\n 12,\n daysInMonth(date.calendar, date.year, 12),\n ) as Same<D>;\n}\n\nexport function startOfWeek<D extends CalendarDate>(\n date: D,\n weekStartsOn: Weekday = getConfig().weekStartsOn,\n): Same<D> {\n assertWeekday(weekStartsOn);\n const back = (weekdayOf(toEpoch(date)) - weekStartsOn + 7) % 7;\n\n return addDays(date, -back);\n}\n\nexport function endOfWeek<D extends CalendarDate>(\n date: D,\n weekStartsOn: Weekday = getConfig().weekStartsOn,\n): Same<D> {\n return addDays(startOfWeek(date, weekStartsOn), 6);\n}\n\n/** Whole days from `b` to `a` (positive when `a` is later). The calendars may differ. */\nexport function differenceInDays(a: CalendarDate, b: CalendarDate): number {\n return toEpoch(a) - toEpoch(b);\n}\n\n/** Every day from `start` to `end` inclusive, in `start`'s calendar. Nothing when end < start. */\nexport function* eachDayOfInterval<D extends CalendarDate>(\n start: D,\n end: CalendarDate,\n): Generator<Same<D>, void, undefined> {\n const last = toEpoch(end);\n for (let epoch = toEpoch(start); epoch <= last; epoch++) {\n yield fromEpoch(toEpochDay(epoch), start.calendar) as Same<D>;\n }\n}\n\n/** Every day of the month the date is in. */\nexport function eachDayOfMonth<D extends CalendarDate>(date: D): Same<D>[] {\n return [...eachDayOfInterval(startOfMonth(date), endOfMonth(date))] as Same<D>[];\n}\n\n/** The date converted to `target`'s calendar; a small helper used by compare and fiscal code. */\nexport function inCalendarOf<D extends CalendarDate>(\n target: D,\n date: CalendarDate,\n): Same<D> {\n return toCalendar(date, target.calendar) as Same<D>;\n}\n\nfunction assertInteger(value: number, name: string): void {\n if (!Number.isSafeInteger(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${name} must be a whole number, not ${String(value)}.`,\n );\n }\n}\n\nfunction assertWeekday(value: number): void {\n if (!isWeekday(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(value)} is not a weekday (0–6).`,\n );\n }\n}\n","import { inCalendarOf } from './arithmetic';\nimport { getConfig } from './config';\nimport { toCalendar, toEpoch } from './convert';\nimport { weekdayOf } from './epoch';\nimport type { CalendarDate, DateOf, Weekday } from './types';\n\ntype Maybe = CalendarDate | null | undefined;\n\n/** -1, 0 or 1. Dates in different calendars compare by the day they fall on. */\nexport function compareDates(a: CalendarDate, b: CalendarDate): -1 | 0 | 1 {\n return Math.sign(toEpoch(a) - toEpoch(b)) as -1 | 0 | 1;\n}\n\n/** Same day, in any calendars. False when either is missing. */\nexport function isSameDay(a: Maybe, b: Maybe): boolean {\n return a != null && b != null && toEpoch(a) === toEpoch(b);\n}\n\n/** Whether `b` falls in the same month as `a`, judged in `a`'s calendar. */\nexport function isSameMonth(a: CalendarDate, b: CalendarDate): boolean {\n const other = inCalendarOf(a, b);\n\n return other.year === a.year && other.month === a.month;\n}\n\n/** Whether `b` falls in the same year as `a`, judged in `a`'s calendar. */\nexport function isSameYear(a: CalendarDate, b: CalendarDate): boolean {\n return inCalendarOf(a, b).year === a.year;\n}\n\nexport function isBefore(a: CalendarDate, b: CalendarDate): boolean {\n return toEpoch(a) < toEpoch(b);\n}\n\nexport function isAfter(a: CalendarDate, b: CalendarDate): boolean {\n return toEpoch(a) > toEpoch(b);\n}\n\n/** On or after `min` and on or before `max`; a missing bound is open. */\nexport function isWithin(date: CalendarDate, min?: Maybe, max?: Maybe): boolean {\n const day = toEpoch(date);\n\n return (min == null || day >= toEpoch(min)) && (max == null || day <= toEpoch(max));\n}\n\n/** The date, or the nearest bound when it is outside, in the date's calendar. */\nexport function clampDate<D extends CalendarDate>(\n date: D,\n min?: Maybe,\n max?: Maybe,\n): DateOf<D['calendar']> {\n if (min != null && isBefore(date, min)) {\n return toCalendar(min, date.calendar) as DateOf<D['calendar']>;\n }\n if (max != null && isAfter(date, max)) {\n return toCalendar(max, date.calendar) as DateOf<D['calendar']>;\n }\n\n return date as DateOf<D['calendar']>;\n}\n\n/** 0 = Sunday … 6 = Saturday. The same in both calendars. */\nexport function dayOfWeek(date: CalendarDate): Weekday {\n return weekdayOf(toEpoch(date));\n}\n\n/** Saturday by default (Nepal); set `weekendDays` in configure() or pass them here. */\nexport function isWeekend(\n date: CalendarDate,\n weekendDays: readonly Weekday[] = getConfig().weekendDays,\n): boolean {\n return weekendDays.includes(dayOfWeek(date));\n}\n","import { getConfig } from '../config';\nimport type { CalendarSystem, LocaleCode } from '../types';\nimport { localeData, type LocaleData } from './registry';\n\nexport { hasLocale, registerLocale, type LocaleData } from './registry';\n\nconst DEVANAGARI = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];\n\n/** The data for a locale (the configured default when omitted; English when unknown). */\nexport function getLocale(locale: LocaleCode = getConfig().defaultLocale): LocaleData {\n return localeData(locale);\n}\n\nexport function monthNames(\n calendar: CalendarSystem,\n locale?: LocaleCode,\n width: 'long' | 'short' = 'long',\n): readonly string[] {\n return getLocale(locale).months[calendar][width];\n}\n\nexport function weekdayNames(\n locale?: LocaleCode,\n width: 'long' | 'short' | 'narrow' = 'long',\n): readonly string[] {\n return getLocale(locale).weekdays[width];\n}\n\n/** Replace Devanagari digits with ASCII digits. */\nexport function toAsciiDigits(value: string): string {\n return value.replace(/[०-९]/g, (digit) => String(DEVANAGARI.indexOf(digit)));\n}\n\n/** Replace ASCII digits with Devanagari digits. */\nexport function toDevanagariDigits(value: string | number): string {\n return String(value).replace(/[0-9]/g, (digit) => DEVANAGARI[Number(digit)] ?? digit);\n}\n\n/** Write a number (or digit string) with the locale's digits. */\nexport function formatNumber(value: string | number, locale?: LocaleCode): string {\n const { digits } = getLocale(locale);\n\n return String(value).replace(/[0-9]/g, (digit) => digits[Number(digit)] ?? digit);\n}\n\n/** Fill {name} placeholders in a locale message. */\nexport function formatMessage(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (whole, name: string) => values[name] ?? whole);\n}\n","import { dayOfWeek } from './compare';\nimport { formatNumber, getLocale } from './locale/index';\nimport type { CalendarDate, LocaleCode } from './types';\n\n/** Named formats. `cbms` is the dotted form Nepal's tax system uses. */\nexport const DATE_FORMATS: {\n readonly iso: 'Y-m-d';\n readonly cbms: 'Y.m.d';\n readonly short: 'j M Y';\n readonly long: 'j F Y';\n readonly full: 'l, j F Y';\n} = Object.freeze({\n iso: 'Y-m-d',\n cbms: 'Y.m.d',\n short: 'j M Y',\n long: 'j F Y',\n full: 'l, j F Y',\n});\n\nexport type NamedFormat = keyof typeof DATE_FORMATS;\n/** A named format, or a pattern of tokens (see formatDate). */\nexport type DateFormatPattern = NamedFormat | (string & Record<never, never>);\n\n/**\n * Format a date in its own calendar. Tokens: Y 2083, y 83, m 06, n 6, d 09,\n * j 9, F month name, M short month name, l weekday, D short weekday. Put a\n * backslash before a letter to print it as is. Digits follow the locale.\n *\n * formatDate(bsDate(2082, 4, 1), 'full') → \"Thursday, 1 Shrawan 2082\"\n * formatDate(bsDate(2082, 4, 1), 'long', 'ne') → \"१ साउन २०८२\"\n */\nexport function formatDate(\n date: CalendarDate,\n pattern: DateFormatPattern = 'iso',\n locale?: LocaleCode,\n): string {\n const tokens: string =\n pattern in DATE_FORMATS ? DATE_FORMATS[pattern as NamedFormat] : pattern;\n const data = getLocale(locale);\n const months = data.months[date.calendar];\n const digits = (value: string | number): string => formatNumber(value, locale);\n const pad = (value: number): string => String(value).padStart(2, '0');\n let output = '';\n\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens.charAt(index);\n switch (token) {\n case '\\\\':\n index++;\n output += tokens.charAt(index);\n break;\n case 'Y':\n output += digits(date.year);\n break;\n case 'y':\n output += digits(pad(((date.year % 100) + 100) % 100));\n break;\n case 'm':\n output += digits(pad(date.month));\n break;\n case 'n':\n output += digits(date.month);\n break;\n case 'd':\n output += digits(pad(date.day));\n break;\n case 'j':\n output += digits(date.day);\n break;\n case 'F':\n output += months.long[date.month - 1] ?? '';\n break;\n case 'M':\n output += months.short[date.month - 1] ?? '';\n break;\n case 'l':\n output += data.weekdays.long[dayOfWeek(date)] ?? '';\n break;\n case 'D':\n output += data.weekdays.short[dayOfWeek(date)] ?? '';\n break;\n default:\n output += token;\n }\n }\n\n return output;\n}\n","import { BS_FISCAL_YEAR_START_MONTH } from './bs/data-api';\nimport { compareDates } from './compare';\nimport { toCalendar } from './convert';\nimport { bsDate, daysInMonth } from './create';\nimport { formatNumber } from './locale/index';\nimport type { CalendarDate, FiscalYear, LocaleCode } from './types';\n\n/** The fiscal year a date falls in: 1 Shrawan to the end of Asar. */\nexport function fiscalYear(date: CalendarDate): FiscalYear {\n const bs = toCalendar(date, 'BS');\n\n return fiscalYearRange(bs.month >= BS_FISCAL_YEAR_START_MONTH ? bs.year : bs.year - 1);\n}\n\n/** The fiscal year that starts in BS `startYear` (2083 → FY 2083/84). */\nexport function fiscalYearRange(startYear: number): FiscalYear {\n const endYear = startYear + 1;\n const lastMonth = BS_FISCAL_YEAR_START_MONTH - 1;\n\n return Object.freeze({\n startYear,\n label: `${startYear}/${String(endYear % 100).padStart(2, '0')}`,\n firstDay: bsDate(startYear, BS_FISCAL_YEAR_START_MONTH, 1),\n lastDay: bsDate(endYear, lastMonth, daysInMonth('BS', endYear, lastMonth)),\n });\n}\n\n/**\n * label \"2083/84\" · full \"2083/2084\" · cbms \"2083.084\" (the form Nepal's tax\n * system uses). Digits follow the locale.\n */\nexport function formatFiscalYear(\n fy: FiscalYear,\n style: 'label' | 'full' | 'cbms' = 'label',\n locale?: LocaleCode,\n): string {\n const end = fy.startYear + 1;\n const text =\n style === 'full'\n ? `${fy.startYear}/${end}`\n : style === 'cbms'\n ? `${fy.startYear}.${String(end % 1000).padStart(3, '0')}`\n : fy.label;\n\n return formatNumber(text, locale);\n}\n\nexport function isInFiscalYear(date: CalendarDate, fy: FiscalYear): boolean {\n return compareDates(date, fy.firstDay) >= 0 && compareDates(date, fy.lastDay) <= 0;\n}\n","import { createDate } from './create';\nimport { NepDateRangeError } from './errors';\nimport { fiscalYearRange } from './fiscal';\nimport { toAsciiDigits } from './locale/index';\nimport type { CalendarSystem, DateOf, FiscalYear } from './types';\n\nconst YEAR_FIRST = /^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})$/;\nconst COMPACT = /^(\\d{4})(\\d{2})(\\d{2})$/;\n\n/**\n * A date written year first (\"2083-06-24\", \"2083/6/24\", \"2083.06.24\", or\n * compact \"20830624\") in ASCII or Devanagari digits, in the calendar the caller names. Other orders are\n * rejected, not guessed. Returns null when the text is not a valid date.\n */\nexport function parseDate<C extends CalendarSystem>(\n text: string | null | undefined,\n calendar: C,\n): DateOf<C> | null {\n try {\n return parseDateStrict(text ?? '', calendar);\n } catch {\n return null;\n }\n}\n\n/** Like parseDate, but throws a NepDateRangeError that says what is wrong. */\nexport function parseDateStrict<C extends CalendarSystem>(\n text: string,\n calendar: C,\n): DateOf<C> {\n const ascii = toAsciiDigits(text).trim();\n const match = YEAR_FIRST.exec(ascii) ?? COMPACT.exec(ascii);\n if (!match) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `\"${text}\" is not a date written as YYYY-MM-DD.`,\n );\n }\n\n return createDate(calendar, Number(match[1]), Number(match[2]), Number(match[3]));\n}\n\n/**\n * A fiscal year from its label: \"2083/84\", \"2083/2084\", \"2083-84\" or the\n * tax form \"2083.084\", in ASCII or Devanagari digits. Null when not valid.\n */\nexport function parseFiscalYear(text: string | null | undefined): FiscalYear | null {\n const match = /^(\\d{4})\\s*[-/.]\\s*(\\d{2,4})$/.exec(toAsciiDigits(text ?? '').trim());\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ?? '';\n const next = start + 1;\n const expected =\n end.length === 4\n ? String(next)\n : String(next % 10 ** end.length).padStart(end.length, '0');\n if (end !== expected) {\n return null;\n }\n try {\n return fiscalYearRange(start);\n } catch {\n return null;\n }\n}\n","import { getConfig } from './config';\nimport { fromIsoTimestamp, toCalendar } from './convert';\nimport { adDate } from './create';\nimport { NepDateRangeError } from './errors';\nimport { formatNumber, getLocale, toAsciiDigits } from './locale/index';\nimport type { AdDate, CalendarDate, LocaleCode } from './types';\n\n/** A time of day, 00:00–23:59. Frozen like dates. */\nexport interface TimeOfDay {\n readonly hour: number;\n readonly minute: number;\n}\n\nexport function timeOfDay(hour: number, minute = 0): TimeOfDay {\n if (!isValidTime(hour, minute)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(hour)}:${String(minute)} is not a time of day.`,\n );\n }\n\n return Object.freeze({ hour, minute });\n}\n\nexport function isValidTime(hour: number, minute: number): boolean {\n return (\n Number.isInteger(hour) &&\n Number.isInteger(minute) &&\n hour >= 0 &&\n hour <= 23 &&\n minute >= 0 &&\n minute <= 59\n );\n}\n\n/** -1, 0 or 1. */\nexport function compareTimes(a: TimeOfDay, b: TimeOfDay): -1 | 0 | 1 {\n return Math.sign(a.hour * 60 + a.minute - (b.hour * 60 + b.minute)) as -1 | 0 | 1;\n}\n\n/**\n * \"14:30\", \"2:30 pm\", \"2 PM\", \"1430\", \"१४:३०\", \"२:३० अपराह्न\" → TimeOfDay.\n * Null when the text is not a time.\n */\nexport function parseTime(text: string | null | undefined): TimeOfDay | null {\n let value = toAsciiDigits(text ?? '')\n .trim()\n .toLowerCase();\n let meridiem: 'am' | 'pm' | null = null;\n for (const code of ['en', 'ne'] as const) {\n const { am, pm } = getLocale(code).time;\n for (const [word, kind] of [\n [am.toLowerCase(), 'am'],\n [pm.toLowerCase(), 'pm'],\n [am.toLowerCase().replace(/(.)/g, '$1.'), 'am'],\n [pm.toLowerCase().replace(/(.)/g, '$1.'), 'pm'],\n ] as const) {\n if (value.endsWith(word)) {\n meridiem = kind;\n value = value.slice(0, -word.length).trim();\n break;\n }\n }\n if (meridiem) {\n break;\n }\n }\n const match =\n /^(\\d{1,2})(?:[:.](\\d{2}))?$/.exec(value) ?? /^(\\d{2})(\\d{2})$/.exec(value);\n if (!match) {\n return null;\n }\n let hour = Number(match[1]);\n const minute = Number(match[2] ?? 0);\n if (meridiem) {\n if (hour < 1 || hour > 12) {\n return null;\n }\n hour = (hour % 12) + (meridiem === 'pm' ? 12 : 0);\n }\n\n return isValidTime(hour, minute) ? timeOfDay(hour, minute) : null;\n}\n\n/** \"14:30\" (24-hour) or \"2:30 PM\" (hour12), in the locale's digits and words. */\nexport function formatTime(\n time: TimeOfDay,\n options: { readonly hour12?: boolean; readonly locale?: LocaleCode } = {},\n): string {\n const minute = String(time.minute).padStart(2, '0');\n if (!options.hour12) {\n return formatNumber(\n `${String(time.hour).padStart(2, '0')}:${minute}`,\n options.locale,\n );\n }\n const { am, pm } = getLocale(options.locale).time;\n const hour = time.hour % 12 === 0 ? 12 : time.hour % 12;\n\n return `${formatNumber(`${hour}:${minute}`, options.locale)} ${time.hour < 12 ? am : pm}`;\n}\n\n/**\n * The instant of a calendar day and time in a zone (Nepal by default), as an\n * ISO timestamp with that zone's offset: \"2026-10-18T14:30:00+05:45\".\n */\nexport function toIsoDateTime(\n date: CalendarDate,\n time: TimeOfDay,\n timeZone: string = getConfig().timeZone,\n): string {\n const { year, month, day } = toCalendar(date, 'AD');\n if (year < 0 || year > 9999) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `AD year ${year} cannot be written in ISO form.`,\n );\n }\n const wall = Date.UTC(year, month - 1, day, time.hour, time.minute);\n const first = offsetMinutes(wall, timeZone);\n const offset = offsetMinutes(wall - first * 60_000, timeZone);\n const sign = offset < 0 ? '-' : '+';\n const abs = Math.abs(offset);\n const pad = (value: number, length = 2): string => String(value).padStart(length, '0');\n\n return `${pad(year, 4)}-${pad(month)}-${pad(day)}T${pad(time.hour)}:${pad(time.minute)}:00${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;\n}\n\n/**\n * The day and time of an ISO timestamp in a zone (Nepal by default). A value\n * without an offset (\"2026-10-18T14:30\", as from <input type=\"datetime-local\">)\n * is read as a wall time already in that zone. Null for anything else.\n */\nexport function fromIsoDateTime(\n value: string | null | undefined,\n timeZone: string = getConfig().timeZone,\n): { readonly date: AdDate; readonly time: TimeOfDay } | null {\n const zoned = fromIsoTimestamp(value, timeZone);\n if (zoned) {\n const time = parseTime(zoned.time);\n return time ? { date: zoned.date, time } : null;\n }\n const local = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::\\d{2}(?:\\.\\d+)?)?$/.exec(\n value ?? '',\n );\n if (!local) {\n return null;\n }\n try {\n return {\n date: adDate(Number(local[1]), Number(local[2]), Number(local[3])),\n time: timeOfDay(Number(local[4]), Number(local[5])),\n };\n } catch {\n return null;\n }\n}\n\n/** Minutes the zone is ahead of UTC at an instant. */\nfunction offsetMinutes(instant: number, timeZone: string): number {\n let parts: Intl.DateTimeFormatPart[];\n try {\n parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n }).formatToParts(new Date(instant));\n } catch {\n throw new NepDateRangeError('INVALID_ARGUMENT', `\"${timeZone}\" is not a time zone.`);\n }\n const part = (type: Intl.DateTimeFormatPartTypes): number =>\n Number(parts.find((item) => item.type === type)?.value ?? 0);\n const wall = Date.UTC(\n part('year'),\n part('month') - 1,\n part('day'),\n part('hour'),\n part('minute'),\n );\n\n return Math.round((wall - Math.floor(instant / 60_000) * 60_000) / 60_000);\n}\n"],"mappings":";;;AASA,IAAa,oBAAb,cAAuC,WAAW;CAGhD,YAAY,MAA6B,SAAiB;EACxD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;AAMA,IAAa,mBAAb,cAAsC,MAAM;CAO1C,YACE,MACA,SACA,MACA,OACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;;;;ACtCA,SAAgB,WAAW,OAAyB;CAClD,IAAI,CAAC,OAAO,cAAc,KAAK,GAC7B,MAAM,IAAI,kBACR,oBACA,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AAK,IAAI;CAC7C;CACA,MAAM,QAAQ,iEAAiE,KAC7E,SAAS,EACX;CACA,IAAI,CAAC,OACH,OAAO;CAET,IAAI;EACF,OAAO;GACL,MAAM,OAAO,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,CAAC;GACjE,MAAM,UAAU,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,CAAC;EACpD;CACF,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAS,cAAc,SAAiB,UAA0B;CAChE,IAAI;CACJ,IAAI;EACF,QAAQ,IAAI,KAAK,eAAe,SAAS;GACvC;GACA,WAAW;GACX,MAAM;GACN,OAAO;GACP,KAAK;GACL,MAAM;GACN,QAAQ;EACV,CAAC,CAAC,CAAC,cAAc,IAAI,KAAK,OAAO,CAAC;CACpC,QAAQ;EACN,MAAM,IAAI,kBAAkB,oBAAoB,IAAI,SAAS,sBAAsB;CACrF;CACA,MAAM,QAAQ,SACZ,OAAO,MAAM,MAAM,SAAS,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,CAAC;CAC7D,MAAM,OAAO,KAAK,IAChB,KAAK,MAAM,GACX,KAAK,OAAO,IAAI,GAChB,KAAK,KAAK,GACV,KAAK,MAAM,GACX,KAAK,QAAQ,CACf;CAEA,OAAO,KAAK,OAAO,OAAO,KAAK,MAAM,UAAU,GAAM,IAAI,OAAU,GAAM;AAC3E"}
@@ -0,0 +1,2 @@
1
+ var NepDate=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class extends RangeError{constructor(e,t){super(t),this.name=`NepDateRangeError`,this.code=e}},n=class extends Error{constructor(e,t,n,r){super(t),this.name=`NepDateDataError`,this.code=e,this.year=n,this.month=r}};function r(e){if(!Number.isSafeInteger(e))throw new t(`INVALID_ARGUMENT`,`${String(e)} is not a whole number of days.`);return e}function i(e){return((e+4)%7+7)%7}let a=[`Baisakh`,`Jestha`,`Asar`,`Shrawan`,`Bhadra`,`Ashwin`,`Kartik`,`Mangsir`,`Poush`,`Magh`,`Falgun`,`Chaitra`],o=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],s={digits:[`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],weekdays:{long:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],short:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],narrow:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`]},months:{AD:{long:o,short:o.map(e=>e.slice(0,3))},BS:{long:a,short:a.map(e=>e.slice(0,3))}},calendarNames:{AD:`AD`,BS:`BS`},labels:{today:`Today`,clear:`Clear date`,previousMonth:`Previous month`,nextMonth:`Next month`,previousYear:`Previous year`,nextYear:`Next year`,month:`Month`,year:`Year`,openCalendar:`Open calendar`,chooseDate:`Choose a date`,calendar:`Calendar`,presets:`Shortcuts`,fiscalYear:`Fiscal year`,time:`Time`,hour:`Hour`,minute:`Minute`,now:`Now`,done:`Done`},time:{am:`AM`,pm:`PM`},presets:{today:`Today`,yesterday:`Yesterday`,tomorrow:`Tomorrow`,thisWeek:`This week`,lastWeek:`Last week`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisYear:`This year`,thisFiscalYear:`This fiscal year`,lastFiscalYear:`Last fiscal year`},messages:{invalidFormat:{AD:`Enter an AD date as YYYY-MM-DD.`,BS:`Enter a BS date as YYYY-MM-DD.`},outOfRange:`Choose a date from {min} to {max}.`,onOrAfter:`Choose {min} or later.`,onOrBefore:`Choose {max} or earlier.`,unavailable:`This date is not available.`,rangeTooShort:`Choose at least {min} days.`,rangeTooLong:`Choose at most {max} days.`,tooManyDates:`Choose at most {max} dates.`,invalidTime:`Enter a time as HH:MM.`}},c=[`बैशाख`,`जेठ`,`असार`,`साउन`,`भदौ`,`असोज`,`कार्तिक`,`मङ्सिर`,`पुस`,`माघ`,`फाल्गुण`,`चैत`],l=[`जनवरी`,`फेब्रुअरी`,`मार्च`,`अप्रिल`,`मे`,`जुन`,`जुलाई`,`अगस्ट`,`सेप्टेम्बर`,`अक्टोबर`,`नोभेम्बर`,`डिसेम्बर`],u=/* @__PURE__ */ new Map([[`en`,s],[`ne`,{digits:[`०`,`१`,`२`,`३`,`४`,`५`,`६`,`७`,`८`,`९`],weekdays:{long:[`आइतबार`,`सोमबार`,`मङ्गलबार`,`बुधबार`,`बिहिबार`,`शुक्रबार`,`शनिबार`],short:[`आइत`,`सोम`,`मङ्गल`,`बुध`,`बिही`,`शुक्र`,`शनि`],narrow:[`आ`,`सो`,`मं`,`बु`,`बि`,`शु`,`श`]},months:{AD:{long:l,short:l},BS:{long:c,short:c}},calendarNames:{AD:`ई.सं.`,BS:`वि.सं.`},labels:{today:`आज`,clear:`मिति हटाउनुहोस्`,previousMonth:`अघिल्लो महिना`,nextMonth:`अर्को महिना`,previousYear:`अघिल्लो वर्ष`,nextYear:`अर्को वर्ष`,month:`महिना`,year:`वर्ष`,openCalendar:`पात्रो खोल्नुहोस्`,chooseDate:`मिति छान्नुहोस्`,calendar:`पात्रो`,presets:`छिटो छनोट`,fiscalYear:`आर्थिक वर्ष`,time:`समय`,hour:`घण्टा`,minute:`मिनेट`,now:`अहिले`,done:`भयो`},time:{am:`पूर्वाह्न`,pm:`अपराह्न`},presets:{today:`आज`,yesterday:`हिजो`,tomorrow:`भोलि`,thisWeek:`यो हप्ता`,lastWeek:`गत हप्ता`,last7Days:`पछिल्लो ७ दिन`,last30Days:`पछिल्लो ३० दिन`,thisMonth:`यो महिना`,lastMonth:`गत महिना`,thisYear:`यो वर्ष`,thisFiscalYear:`यो आर्थिक वर्ष`,lastFiscalYear:`गत आर्थिक वर्ष`},messages:{invalidFormat:{AD:`ई.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।`,BS:`वि.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।`},outOfRange:`{min} देखि {max} सम्मको मिति छान्नुहोस्।`,onOrAfter:`{min} वा त्यसपछिको मिति छान्नुहोस्।`,onOrBefore:`{max} वा त्यसअघिको मिति छान्नुहोस्।`,unavailable:`यो मिति उपलब्ध छैन।`,rangeTooShort:`कम्तीमा {min} दिन छान्नुहोस्।`,rangeTooLong:`बढीमा {max} दिन छान्नुहोस्।`,tooManyDates:`बढीमा {max} मिति छान्नुहोस्।`,invalidTime:`समय HH:MM ढाँचामा लेख्नुहोस्।`}}]]);function d(e,n){let r=[[`digits`,n.digits,10],[`weekdays.long`,n.weekdays.long,7],[`weekdays.short`,n.weekdays.short,7],[`weekdays.narrow`,n.weekdays.narrow,7],[`months.AD.long`,n.months.AD.long,12],[`months.AD.short`,n.months.AD.short,12],[`months.BS.long`,n.months.BS.long,12],[`months.BS.short`,n.months.BS.short,12]];for(let[n,i,a]of r)if(i.length!==a)throw new t(`INVALID_ARGUMENT`,`Locale "${e}": ${n} must have ${a} entries, not ${i.length}.`);u.set(e,n)}function ee(e){return u.has(e)}function te(e){return u.get(e)??s}let f=Object.freeze({timeZone:`Asia/Kathmandu`,weekStartsOn:0,weekendDays:Object.freeze([6]),defaultLocale:`en`}),p=f;function ne(e){let n={...p,...e};if(!ie(n.timeZone))throw new t(`INVALID_ARGUMENT`,`"${n.timeZone}" is not a time zone.`);if(!h(n.weekStartsOn))throw new t(`INVALID_ARGUMENT`,`weekStartsOn must be 0–6, not ${String(n.weekStartsOn)}.`);if(!n.weekendDays.every(h)||new Set(n.weekendDays).size!==n.weekendDays.length)throw new t(`INVALID_ARGUMENT`,`weekendDays must be different weekdays, each 0–6.`);if(!ee(n.defaultLocale))throw new t(`INVALID_ARGUMENT`,`Locale "${n.defaultLocale}" is not registered.`);p=Object.freeze({...n,weekendDays:Object.freeze([...n.weekendDays])})}function m(){return p}function re(){p=f}function h(e){return Number.isInteger(e)&&e>=0&&e<=6}function ie(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}let ae=999999,oe=719468,g=146097,se=[31,28,31,30,31,30,31,31,30,31,30,31];function ce(e){return e%4==0&&e%100!=0||e%400==0}function le(e,t){return t===2&&ce(e)?29:se[t-1]??0}function _(e,t,n){return Number.isInteger(e)&&Number.isInteger(t)&&Number.isInteger(n)&&Math.abs(e)<=999999&&t>=1&&t<=12&&n>=1&&n<=le(e,t)}function ue(e,t,n){let r=t<=2?e-1:e,i=Math.floor(r/400),a=r-i*400,o=Math.floor((153*(t+(t>2?-3:9))+2)/5)+n-1,s=a*365+Math.floor(a/4)-Math.floor(a/100)+o;return i*g+s-oe}function v(e){let t=e+oe,n=Math.floor(t/g),r=t-n*g,i=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),a=r-(365*i+Math.floor(i/4)-Math.floor(i/100)),o=Math.floor((5*a+2)/153),s=a-Math.floor((153*o+2)/5)+1,c=o<10?o+3:o-9;return{year:i+n*400+ +(c<=2),month:c,day:s}}let y={firstYear:1970,epochStart:-20717,verifiedThrough:2083,years:[[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,32,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,31,29,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,32,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,31,29,30,30,29,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,32,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[30,32,31,32,31,31,29,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,29,30,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,31,32,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,29,30,30],[31,32,31,32,31,30,30,30,29,30,29,31],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,31,31,30,29,30,29,30,30],[31,31,32,31,31,30,30,30,29,30,30,30],[31,32,31,32,30,31,30,30,29,30,30,30],[30,32,31,32,31,30,30,30,29,30,30,30],[31,31,32,31,31,31,30,30,29,30,30,30],[30,31,32,32,30,31,30,30,29,30,30,30],[30,32,31,32,31,30,30,30,29,30,30,30],[30,32,31,32,31,30,30,30,29,30,30,30],[31,31,32,31,31,31,30,30,29,30,30,30],[30,31,32,32,31,30,30,30,29,30,30,30],[30,32,31,32,31,30,30,30,29,30,30,30],[31,31,32,31,31,30,30,30,29,30,30,30],[31,31,32,31,31,31,30,29,30,30,30,30],[30,31,32,32,31,30,30,29,30,29,30,30],[31,32,31,32,31,30,30,30,29,30,30,30],[31,31,32,31,31,31,29,30,29,30,29,31],[31,31,32,31,31,31,30,29,29,30,30,30]]},b=de(y),x=null;function S(e){b=de(e),x=null}function de(e){return Object.freeze({firstYear:e.firstYear,epochStart:e.epochStart,verifiedThrough:e.verifiedThrough,years:Object.freeze(e.years.map(e=>Object.freeze([...e])))})}function C(){return b}function fe(){let e=b.years.length,t=new Float64Array(e+1),n=new Uint16Array(e*12),r=b.epochStart;for(let i=0;i<e;i++){t[i]=r;let e=b.years[i]??[],a=0;for(let t=0;t<12;t++)n[i*12+t]=a,a+=e[t]??0;r+=a}return t[e]=r,{data:b,lastYear:b.firstYear+e-1,yearStart:t,monthOffset:n}}function w(){return x??(x=fe())}function pe(){return b.firstYear}function T(){return w().lastYear}function E(){let{yearStart:e}=w();return{first:e[0]??0,last:(e[e.length-1]??0)-1}}function D(e,n){let{lastYear:r}=w();if(!Number.isInteger(e)||e<b.firstYear||e>r)throw new t(`OUT_OF_TABLE`,`BS year ${String(e)} is outside the supported range (BS ${b.firstYear}–${r}).`);if(!Number.isInteger(n)||n<1||n>12)throw new t(`INVALID_DATE`,`BS month ${String(n)} does not exist.`);return b.years[e-b.firstYear]?.[n-1]??0}function me(e,t,n){try{return Number.isInteger(n)&&n>=1&&n<=D(e,t)}catch{return!1}}function he(e,t,n){let{yearStart:r,monthOffset:i}=w(),a=e-b.firstYear;return(r[a]??0)+(i[a*12+t-1]??0)+n-1}function ge(e){let{yearStart:n,monthOffset:r}=w(),{first:i,last:a}=E();if(e<i||e>a)throw new t(`OUT_OF_TABLE`,`Day ${e} is outside the BS table (BS ${b.firstYear}–${T()}).`);let o=0,s=n.length-2;for(;o<s;){let t=Math.ceil((o+s)/2);(n[t]??0)<=e?o=t:s=t-1}let c=e-(n[o]??0),l=11;for(;l>0&&(r[o*12+l]??0)>c;)l--;return{year:b.firstYear+o,month:l+1,day:c-(r[o*12+l]??0)+1}}function _e(e){return e>b.verifiedThrough}let ve=[365,366],ye=[364,365,366,367];function be(e){if(!Number.isSafeInteger(e.epochStart)||!Number.isInteger(e.firstYear))throw new n(`BAD_ANCHOR`,`firstYear and epochStart must be whole numbers.`);if(!Number.isInteger(e.verifiedThrough))throw new n(`BAD_ANCHOR`,`verifiedThrough must be a whole number.`);if(e.years.length===0)throw new n(`EMPTY`,`The BS table has no years.`);e.years.forEach((t,r)=>{let i=e.firstYear+r;if(t.length!==12)throw new n(`BAD_MONTH_COUNT`,`BS ${i} lists ${t.length} months, not 12.`,i);let a=0;t.forEach((e,t)=>{if(!Number.isInteger(e)||e<29||e>32)throw new n(`BAD_MONTH`,`BS ${i} month ${t+1} has ${String(e)} days; expected 29–32.`,i,t+1);a+=e});let o=i<=e.verifiedThrough?ve:ye;if(!o.includes(a))throw new n(`BAD_YEAR_TOTAL`,`BS ${i} has ${a} days; expected ${o.join(` or `)}.`,i)})}function xe(){return C()}function Se(e){be(e),S(e)}function Ce(e,n){let r=C(),i=r.firstYear+r.years.length-1,a;if(e>=r.firstYear&&e<=i)a={...r,years:r.years.map((t,i)=>i===e-r.firstYear?n:t)};else if(e===i+1)a={...r,years:[...r.years,n]};else if(e===r.firstYear-1){let t=n.reduce((e,t)=>e+t,0);a={...r,firstYear:e,epochStart:r.epochStart-t,years:[n,...r.years]}}else throw new t(`OUT_OF_TABLE`,`BS ${String(e)} is not in the table and does not extend it (BS ${r.firstYear}–${i}).`);Se(a)}function we(){S(y)}function O(e,n,r){if(!_(e,n,r))throw new t(Number.isInteger(e)&&Number.isInteger(n)&&Number.isInteger(r)?`INVALID_DATE`:`INVALID_ARGUMENT`,Math.abs(e)>999999?`AD year ${String(e)} is outside ±${ae}.`:`AD ${String(e)}-${String(n)}-${String(r)} is not a valid date.`);return Object.freeze({calendar:`AD`,year:e,month:n,day:r})}function k(e,n,r){let i=D(e,n);if(!Number.isInteger(r)||r<1||r>i)throw new t(Number.isInteger(r)?`INVALID_DATE`:`INVALID_ARGUMENT`,`BS ${e}-${n} has ${i} days, not ${String(r)}.`);return Object.freeze({calendar:`BS`,year:e,month:n,day:r})}function A(e,t,n,r){return e===`AD`?O(t,n,r):k(t,n,r)}function Te(e,t,n,r){return e===`AD`?_(t,n,r):me(t,n,r)}function j(e,n,r){if(e===`BS`)return D(n,r);if(!_(n,r,1))throw new t(`INVALID_DATE`,`AD ${String(n)}-${String(r)} is not a month.`);return le(n,r)}function Ee(e){return ke(e,`AD`)&&_(e.year,e.month,e.day)}function De(e){return ke(e,`BS`)&&me(e.year,e.month,e.day)}function Oe(e){return Ee(e)||De(e)}function ke(e,t){if(typeof e!=`object`||!e)return!1;let n=e;return n.calendar===t&&typeof n.year==`number`&&typeof n.month==`number`&&typeof n.day==`number`}function M(e){return r(e.calendar===`AD`?ue(e.year,e.month,e.day):he(e.year,e.month,e.day))}function N(e,t){if(t===`AD`){let{year:t,month:n,day:r}=v(e);return O(t,n,r)}Le(e);let{year:n,month:r,day:i}=ge(e);return k(n,r,i)}function Ae(e){return N(M(e),`BS`)}function je(e){return N(M(e),`AD`)}function P(e,t){return e.calendar===t?e:N(M(e),t)}function Me(e){return N(r(E().first),e)}function Ne(e){return N(r(E().last),e)}function Pe(e){let t=M(e),{first:n,last:r}=E();return t>=n&&t<=r}function Fe(e){let{year:n,month:r,day:i}=P(e,`AD`);if(n<0||n>9999)throw new t(`INVALID_ARGUMENT`,`AD year ${n} cannot be written as YYYY-MM-DD.`);return`${R(n,4)}-${R(r,2)}-${R(i,2)}`}function Ie(e){let t=/^(\d{4})-(\d{2})-(\d{2})(?:$|[T ])/.exec(e??``);if(!t)return null;try{return O(Number(t[1]),Number(t[2]),Number(t[3]))}catch{return null}}function F(e,n=m().timeZone){if(Number.isNaN(e.getTime()))throw new t(`INVALID_ARGUMENT`,`The Date is invalid.`);let r;try{r=new Intl.DateTimeFormat(`en-US`,{timeZone:n,year:`numeric`,month:`numeric`,day:`numeric`,era:`short`}).formatToParts(e)}catch{throw new t(`INVALID_ARGUMENT`,`"${n}" is not a time zone.`)}let i=e=>r.find(t=>t.type===e)?.value??``,a=Number(i(`year`));return O(i(`era`)===`BC`?1-a:a,Number(i(`month`)),Number(i(`day`)))}function I(e,t=m().timeZone){if(!e||!/T.*(?:Z|[+-]\d{2}:?\d{2})$/.test(e))return null;let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let r=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).format(n);return{date:F(n,t),time:r}}function Le(e){let{first:n,last:r}=E();if(e<n||e>r){let{year:i,month:a,day:o}=v(e),s=v(n),c=v(r);throw new t(`OUT_OF_TABLE`,`AD ${L(i,a,o)} is outside the BS table (AD ${L(s.year,s.month,s.day)} to ${L(c.year,c.month,c.day)}).`)}}function L(e,t,n){return`${e}-${R(t,2)}-${R(n,2)}`}function R(e,t){return String(e).padStart(t,`0`)}function Re(e){return _e(P(e,`BS`).year)}function ze(e=`AD`,t=m().timeZone){return P(F(/* @__PURE__ */ new Date,t),e)}function Be(e=m().timeZone){let t=I((/* @__PURE__ */ new Date()).toISOString(),e),[n=0,r=0]=(t?.time??`00:00`).split(`:`).map(Number);return{date:t?.date??F(/* @__PURE__ */ new Date,e),time:Object.freeze({hour:n,minute:r})}}function z(e,t){return U(t,`days`),N(r(M(e)+t),e.calendar)}function B(e,t){U(t,`months`);let n=e.year*12+(e.month-1)+t,r=Math.floor(n/12),i=n-r*12+1,a=Math.min(e.day,j(e.calendar,r,i));return A(e.calendar,r,i,a)}function Ve(e,t){return U(t,`years`),B(e,t*12)}function V(e){return A(e.calendar,e.year,e.month,1)}function H(e){return A(e.calendar,e.year,e.month,j(e.calendar,e.year,e.month))}function He(e){return A(e.calendar,e.year,1,1)}function Ue(e){return A(e.calendar,e.year,12,j(e.calendar,e.year,12))}function We(e,t=m().weekStartsOn){return Xe(t),z(e,-((i(M(e))-t+7)%7))}function Ge(e,t=m().weekStartsOn){return z(We(e,t),6)}function Ke(e,t){return M(e)-M(t)}function*qe(e,t){let n=M(t);for(let t=M(e);t<=n;t++)yield N(r(t),e.calendar)}function Je(e){return[...qe(V(e),H(e))]}function Ye(e,t){return P(t,e.calendar)}function U(e,n){if(!Number.isSafeInteger(e))throw new t(`INVALID_ARGUMENT`,`${n} must be a whole number, not ${String(e)}.`)}function Xe(e){if(!h(e))throw new t(`INVALID_ARGUMENT`,`${String(e)} is not a weekday (0–6).`)}function W(e,t){return Math.sign(M(e)-M(t))}function Ze(e,t){return e!=null&&t!=null&&M(e)===M(t)}function Qe(e,t){let n=Ye(e,t);return n.year===e.year&&n.month===e.month}function $e(e,t){return Ye(e,t).year===e.year}function et(e,t){return M(e)<M(t)}function tt(e,t){return M(e)>M(t)}function nt(e,t,n){let r=M(e);return(t==null||r>=M(t))&&(n==null||r<=M(n))}function rt(e,t,n){return t!=null&&et(e,t)?P(t,e.calendar):n!=null&&tt(e,n)?P(n,e.calendar):e}function G(e){return i(M(e))}function it(e,t=m().weekendDays){return t.includes(G(e))}let K=[`०`,`१`,`२`,`३`,`४`,`५`,`६`,`७`,`८`,`९`];function q(e=m().defaultLocale){return te(e)}function at(e,t,n=`long`){return q(t).months[e][n]}function ot(e,t=`long`){return q(e).weekdays[t]}function J(e){return e.replace(/[०-९]/g,e=>String(K.indexOf(e)))}function st(e){return String(e).replace(/[0-9]/g,e=>K[Number(e)]??e)}function Y(e,t){let{digits:n}=q(t);return String(e).replace(/[0-9]/g,e=>n[Number(e)]??e)}function ct(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e)}let X=Object.freeze({iso:`Y-m-d`,cbms:`Y.m.d`,short:`j M Y`,long:`j F Y`,full:`l, j F Y`});function lt(e,t=`iso`,n){let r=t in X?X[t]:t,i=q(n),a=i.months[e.calendar],o=e=>Y(e,n),s=e=>String(e).padStart(2,`0`),c=``;for(let t=0;t<r.length;t++){let n=r.charAt(t);switch(n){case`\\`:t++,c+=r.charAt(t);break;case`Y`:c+=o(e.year);break;case`y`:c+=o(s((e.year%100+100)%100));break;case`m`:c+=o(s(e.month));break;case`n`:c+=o(e.month);break;case`d`:c+=o(s(e.day));break;case`j`:c+=o(e.day);break;case`F`:c+=a.long[e.month-1]??``;break;case`M`:c+=a.short[e.month-1]??``;break;case`l`:c+=i.weekdays.long[G(e)]??``;break;case`D`:c+=i.weekdays.short[G(e)]??``;break;default:c+=n}}return c}function ut(e){let t=P(e,`BS`);return Z(t.month>=4?t.year:t.year-1)}function Z(e){let t=e+1;return Object.freeze({startYear:e,label:`${e}/${String(t%100).padStart(2,`0`)}`,firstDay:k(e,4,1),lastDay:k(t,3,j(`BS`,t,3))})}function dt(e,t=`label`,n){let r=e.startYear+1;return Y(t===`full`?`${e.startYear}/${r}`:t===`cbms`?`${e.startYear}.${String(r%1e3).padStart(3,`0`)}`:e.label,n)}function ft(e,t){return W(e,t.firstDay)>=0&&W(e,t.lastDay)<=0}let pt=/^(\d{4})[-./](\d{1,2})[-./](\d{1,2})$/,mt=/^(\d{4})(\d{2})(\d{2})$/;function ht(e,t){try{return gt(e??``,t)}catch{return null}}function gt(e,n){let r=J(e).trim(),i=pt.exec(r)??mt.exec(r);if(!i)throw new t(`INVALID_ARGUMENT`,`"${e}" is not a date written as YYYY-MM-DD.`);return A(n,Number(i[1]),Number(i[2]),Number(i[3]))}function _t(e){let t=/^(\d{4})\s*[-/.]\s*(\d{2,4})$/.exec(J(e??``).trim());if(!t)return null;let n=Number(t[1]),r=t[2]??``,i=n+1;if(r!==(r.length===4?String(i):String(i%10**r.length).padStart(r.length,`0`)))return null;try{return Z(n)}catch{return null}}function Q(e,n=0){if(!$(e,n))throw new t(`INVALID_ARGUMENT`,`${String(e)}:${String(n)} is not a time of day.`);return Object.freeze({hour:e,minute:n})}function $(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=0&&e<=23&&t>=0&&t<=59}function vt(e,t){return Math.sign(e.hour*60+e.minute-(t.hour*60+t.minute))}function yt(e){let t=J(e??``).trim().toLowerCase(),n=null;for(let e of[`en`,`ne`]){let{am:r,pm:i}=q(e).time;for(let[e,a]of[[r.toLowerCase(),`am`],[i.toLowerCase(),`pm`],[r.toLowerCase().replace(/(.)/g,`$1.`),`am`],[i.toLowerCase().replace(/(.)/g,`$1.`),`pm`]])if(t.endsWith(e)){n=a,t=t.slice(0,-e.length).trim();break}if(n)break}let r=/^(\d{1,2})(?:[:.](\d{2}))?$/.exec(t)??/^(\d{2})(\d{2})$/.exec(t);if(!r)return null;let i=Number(r[1]),a=Number(r[2]??0);if(n){if(i<1||i>12)return null;i=i%12+(n===`pm`?12:0)}return $(i,a)?Q(i,a):null}function bt(e,t={}){let n=String(e.minute).padStart(2,`0`);if(!t.hour12)return Y(`${String(e.hour).padStart(2,`0`)}:${n}`,t.locale);let{am:r,pm:i}=q(t.locale).time;return`${Y(`${e.hour%12==0?12:e.hour%12}:${n}`,t.locale)} ${e.hour<12?r:i}`}function xt(e,n,r=m().timeZone){let{year:i,month:a,day:o}=P(e,`AD`);if(i<0||i>9999)throw new t(`INVALID_ARGUMENT`,`AD year ${i} cannot be written in ISO form.`);let s=Date.UTC(i,a-1,o,n.hour,n.minute),c=Ct(s-Ct(s,r)*6e4,r),l=c<0?`-`:`+`,u=Math.abs(c),d=(e,t=2)=>String(e).padStart(t,`0`);return`${d(i,4)}-${d(a)}-${d(o)}T${d(n.hour)}:${d(n.minute)}:00${l}${d(Math.floor(u/60))}:${d(u%60)}`}function St(e,t=m().timeZone){let n=I(e,t);if(n){let e=yt(n.time);return e?{date:n.date,time:e}:null}let r=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::\d{2}(?:\.\d+)?)?$/.exec(e??``);if(!r)return null;try{return{date:O(Number(r[1]),Number(r[2]),Number(r[3])),time:Q(Number(r[4]),Number(r[5]))}}catch{return null}}function Ct(e,n){let r;try{r=new Intl.DateTimeFormat(`en-US`,{timeZone:n,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(new Date(e))}catch{throw new t(`INVALID_ARGUMENT`,`"${n}" is not a time zone.`)}let i=e=>Number(r.find(t=>t.type===e)?.value??0),a=Date.UTC(i(`year`),i(`month`)-1,i(`day`),i(`hour`),i(`minute`));return Math.round((a-Math.floor(e/6e4)*6e4)/6e4)}return e.BS_FISCAL_YEAR_START_MONTH=4,e.DATE_FORMATS=X,e.MAX_AD_YEAR=ae,e.NepDateDataError=n,e.NepDateRangeError=t,e.adDate=O,e.adToBs=Ae,e.addDays=z,e.addMonths=B,e.addYears=Ve,e.bsDate=k,e.bsFirstYear=pe,e.bsLastYear=T,e.bsToAd=je,e.clampDate=rt,e.compareDates=W,e.compareTimes=vt,e.configure=ne,e.createDate=A,e.dayOfWeek=G,e.daysInMonth=j,e.differenceInDays=Ke,e.eachDayOfInterval=qe,e.eachDayOfMonth=Je,e.endOfMonth=H,e.endOfWeek=Ge,e.endOfYear=Ue,e.fiscalYear=ut,e.fiscalYearRange=Z,e.formatDate=lt,e.formatFiscalYear=dt,e.formatMessage=ct,e.formatNumber=Y,e.formatTime=bt,e.fromEpoch=N,e.fromIsoDate=Ie,e.fromIsoDateTime=St,e.fromIsoTimestamp=I,e.fromJsDate=F,e.getBsData=xe,e.getConfig=m,e.getLocale=q,e.hasLocale=ee,e.isAdDate=Ee,e.isAdLeapYear=ce,e.isAfter=tt,e.isBefore=et,e.isBsDate=De,e.isCalendarDate=Oe,e.isConvertible=Pe,e.isInFiscalYear=ft,e.isProjected=Re,e.isSameDay=Ze,e.isSameMonth=Qe,e.isSameYear=$e,e.isValidDate=Te,e.isValidTime=$,e.isWeekend=it,e.isWithin=nt,e.maxDate=Ne,e.minDate=Me,e.monthNames=at,e.now=Be,e.parseDate=ht,e.parseDateStrict=gt,e.parseFiscalYear=_t,e.parseTime=yt,e.patchBsYear=Ce,e.registerLocale=d,e.resetBsData=we,e.resetConfig=re,e.setBsData=Se,e.startOfMonth=V,e.startOfWeek=We,e.startOfYear=He,e.timeOfDay=Q,e.toAsciiDigits=J,e.toCalendar=P,e.toDevanagariDigits=st,e.toEpoch=M,e.toEpochDay=r,e.toIsoDate=Fe,e.toIsoDateTime=xt,e.today=ze,e.validateBsData=be,e.weekdayNames=ot,e.weekdayOf=i,e})({});
2
+ //# sourceMappingURL=nepdate.global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nepdate.global.js","names":["bsMonths","adMonths","exports","NepDateRangeError","message","code","NepDateDataError","year","month","toEpochDay","value","weekdayOf","epoch","bsMonths$1","adMonths$1","en","name","bsMonths","adMonths","locales","registerLocale","checks","data","list","length","hasLocale","localeData","DEFAULTS","current","configure","next","changes","isTimeZone","isWeekday","getConfig","resetConfig","MAX_AD_YEAR","DAYS_BEFORE_EPOCH","DAYS_PER_ERA","MONTH_DAYS","isAdLeapYear","adMonthLength","isValidAdDate","day","adToEpoch","y","era","yearOfEra","dayOfYear","dayOfEra","epochToAd","z","shiftedMonth","BS_DATA","freezeData","table","useBsData","source","months","currentBsData","buildTable","count","yearStart","monthOffset","start","offset","m","bsTable","bsFirstYear","bsLastYear","bsEpochRange","bsMonthLength","lastYear","isValidBsDate","bsToEpoch","index","epochToBs","first","last","low","high","middle","isProjectedBsYear","VERIFIED_YEAR_DAYS","PROJECTED_YEAR_DAYS","validateBsData","total","days","allowed","getBsData","setBsData","patchBsYear","row","resetBsData","adDate","bsDate","createDate","calendar","isValidDate","daysInMonth","isAdDate","isDateLike","isBsDate","isCalendarDate","record","\"calendar\"","\"year\"","\"month\"","\"day\"","toEpoch","date","fromEpoch","assertConvertible","adToBs","bsToAd","toCalendar","minDate","maxDate","isConvertible","toIsoDate","pad","fromIsoDate","match","fromJsDate","instant","parts","timeZone","part","item","type","fromIsoTimestamp","time","from","to","isoParts","isProjected","today","now","hour","minute","addDays","assertInteger","addMonths","addYears","years","startOfMonth","endOfMonth","startOfYear","endOfYear","startOfWeek","assertWeekday","weekStartsOn","endOfWeek","differenceInDays","a","b","eachDayOfInterval","end","eachDayOfMonth","inCalendarOf","target","compareDates","isSameDay","isSameMonth","other","isSameYear","isBefore","isAfter","isWithin","min","max","clampDate","dayOfWeek","isWeekend","weekendDays","DEVANAGARI","getLocale","locale","monthNames","width","weekdayNames","toAsciiDigits","digit","toDevanagariDigits","formatNumber","digits","formatMessage","template","values","whole","DATE_FORMATS","formatDate","tokens","pattern","output","token","fiscalYear","bs","fiscalYearRange","endYear","startYear","formatFiscalYear","fy","style","isInFiscalYear","YEAR_FIRST","COMPACT","parseDate","parseDateStrict","text","ascii","parseFiscalYear","timeOfDay","isValidTime","compareTimes","parseTime","meridiem","word","kind","am","pm","formatTime","options","toIsoDateTime","wall","offsetMinutes","sign","abs","fromIsoDateTime","zoned","local"],"sources":["../src/errors.ts","../src/epoch.ts","../src/locale/en.ts","../src/locale/ne.ts","../src/locale/registry.ts","../src/config.ts","../src/ad/calendar.ts","../src/bs/data/years.ts","../src/bs/table.ts","../src/bs/data-api.ts","../src/create.ts","../src/convert.ts","../src/projected.ts","../src/clock.ts","../src/arithmetic.ts","../src/compare.ts","../src/locale/index.ts","../src/format.ts","../src/fiscal.ts","../src/parse.ts","../src/time.ts"],"sourcesContent":["export type NepDateRangeErrorCode =\n /** The year, month or day does not exist in that calendar. */\n | 'INVALID_DATE'\n /** The date is outside the BS table, so it cannot be a BS date or be converted. */\n | 'OUT_OF_TABLE'\n /** A value of the wrong kind: not an integer, unknown time zone, bad text, … */\n | 'INVALID_ARGUMENT';\n\n/** Thrown for any invalid date or argument. Check `code`, not the message. */\nexport class NepDateRangeError extends RangeError {\n readonly code: NepDateRangeErrorCode;\n\n constructor(code: NepDateRangeErrorCode, message: string) {\n super(message);\n this.name = 'NepDateRangeError';\n this.code = code;\n }\n}\n\nexport type NepDateDataErrorCode =\n 'EMPTY' | 'BAD_MONTH_COUNT' | 'BAD_MONTH' | 'BAD_YEAR_TOTAL' | 'BAD_ANCHOR';\n\n/** Thrown when a BS table passed to `setBsData` or `patchBsYear` is not valid. */\nexport class NepDateDataError extends Error {\n readonly code: NepDateDataErrorCode;\n /** The BS year at fault, when there is one. */\n readonly year: number | undefined;\n /** The month (1–12) at fault, when there is one. */\n readonly month: number | undefined;\n\n constructor(\n code: NepDateDataErrorCode,\n message: string,\n year?: number,\n month?: number,\n ) {\n super(message);\n this.name = 'NepDateDataError';\n this.code = code;\n this.year = year;\n this.month = month;\n }\n}\n","import { NepDateRangeError } from './errors';\nimport type { EpochDay, Weekday } from './types';\n\n/** Brand a whole number of days since 1970-01-01 as an `EpochDay`. */\nexport function toEpochDay(value: number): EpochDay {\n if (!Number.isSafeInteger(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(value)} is not a whole number of days.`,\n );\n }\n\n return value as EpochDay;\n}\n\n/** The weekday of a day count. 1970-01-01 was a Thursday. */\nexport function weekdayOf(epoch: EpochDay): Weekday {\n return ((((epoch + 4) % 7) + 7) % 7) as Weekday;\n}\n","import type { LocaleData } from './registry';\n\nconst bsMonths = [\n 'Baisakh',\n 'Jestha',\n 'Asar',\n 'Shrawan',\n 'Bhadra',\n 'Ashwin',\n 'Kartik',\n 'Mangsir',\n 'Poush',\n 'Magh',\n 'Falgun',\n 'Chaitra',\n];\nconst adMonths = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n];\n\nexport const en: LocaleData = {\n digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],\n weekdays: {\n long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],\n },\n months: {\n AD: { long: adMonths, short: adMonths.map((name) => name.slice(0, 3)) },\n BS: { long: bsMonths, short: bsMonths.map((name) => name.slice(0, 3)) },\n },\n calendarNames: { AD: 'AD', BS: 'BS' },\n labels: {\n today: 'Today',\n clear: 'Clear date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n month: 'Month',\n year: 'Year',\n openCalendar: 'Open calendar',\n chooseDate: 'Choose a date',\n calendar: 'Calendar',\n presets: 'Shortcuts',\n fiscalYear: 'Fiscal year',\n time: 'Time',\n hour: 'Hour',\n minute: 'Minute',\n now: 'Now',\n done: 'Done',\n },\n time: { am: 'AM', pm: 'PM' },\n presets: {\n today: 'Today',\n yesterday: 'Yesterday',\n tomorrow: 'Tomorrow',\n thisWeek: 'This week',\n lastWeek: 'Last week',\n last7Days: 'Last 7 days',\n last30Days: 'Last 30 days',\n thisMonth: 'This month',\n lastMonth: 'Last month',\n thisYear: 'This year',\n thisFiscalYear: 'This fiscal year',\n lastFiscalYear: 'Last fiscal year',\n },\n messages: {\n invalidFormat: {\n AD: 'Enter an AD date as YYYY-MM-DD.',\n BS: 'Enter a BS date as YYYY-MM-DD.',\n },\n outOfRange: 'Choose a date from {min} to {max}.',\n onOrAfter: 'Choose {min} or later.',\n onOrBefore: 'Choose {max} or earlier.',\n unavailable: 'This date is not available.',\n rangeTooShort: 'Choose at least {min} days.',\n rangeTooLong: 'Choose at most {max} days.',\n tooManyDates: 'Choose at most {max} dates.',\n invalidTime: 'Enter a time as HH:MM.',\n },\n};\n","import type { LocaleData } from './registry';\n\nconst bsMonths = [\n 'बैशाख',\n 'जेठ',\n 'असार',\n 'साउन',\n 'भदौ',\n 'असोज',\n 'कार्तिक',\n 'मङ्सिर',\n 'पुस',\n 'माघ',\n 'फाल्गुण',\n 'चैत',\n];\nconst adMonths = [\n 'जनवरी',\n 'फेब्रुअरी',\n 'मार्च',\n 'अप्रिल',\n 'मे',\n 'जुन',\n 'जुलाई',\n 'अगस्ट',\n 'सेप्टेम्बर',\n 'अक्टोबर',\n 'नोभेम्बर',\n 'डिसेम्बर',\n];\n\nexport const ne: LocaleData = {\n digits: ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'],\n weekdays: {\n long: ['आइतबार', 'सोमबार', 'मङ्गलबार', 'बुधबार', 'बिहिबार', 'शुक्रबार', 'शनिबार'],\n short: ['आइत', 'सोम', 'मङ्गल', 'बुध', 'बिही', 'शुक्र', 'शनि'],\n narrow: ['आ', 'सो', 'मं', 'बु', 'बि', 'शु', 'श'],\n },\n months: {\n AD: { long: adMonths, short: adMonths },\n BS: { long: bsMonths, short: bsMonths },\n },\n calendarNames: { AD: 'ई.सं.', BS: 'वि.सं.' },\n labels: {\n today: 'आज',\n clear: 'मिति हटाउनुहोस्',\n previousMonth: 'अघिल्लो महिना',\n nextMonth: 'अर्को महिना',\n previousYear: 'अघिल्लो वर्ष',\n nextYear: 'अर्को वर्ष',\n month: 'महिना',\n year: 'वर्ष',\n openCalendar: 'पात्रो खोल्नुहोस्',\n chooseDate: 'मिति छान्नुहोस्',\n calendar: 'पात्रो',\n presets: 'छिटो छनोट',\n fiscalYear: 'आर्थिक वर्ष',\n time: 'समय',\n hour: 'घण्टा',\n minute: 'मिनेट',\n now: 'अहिले',\n done: 'भयो',\n },\n time: { am: 'पूर्वाह्न', pm: 'अपराह्न' },\n presets: {\n today: 'आज',\n yesterday: 'हिजो',\n tomorrow: 'भोलि',\n thisWeek: 'यो हप्ता',\n lastWeek: 'गत हप्ता',\n last7Days: 'पछिल्लो ७ दिन',\n last30Days: 'पछिल्लो ३० दिन',\n thisMonth: 'यो महिना',\n lastMonth: 'गत महिना',\n thisYear: 'यो वर्ष',\n thisFiscalYear: 'यो आर्थिक वर्ष',\n lastFiscalYear: 'गत आर्थिक वर्ष',\n },\n messages: {\n invalidFormat: {\n AD: 'ई.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।',\n BS: 'वि.सं. मिति YYYY-MM-DD ढाँचामा लेख्नुहोस्।',\n },\n outOfRange: '{min} देखि {max} सम्मको मिति छान्नुहोस्।',\n onOrAfter: '{min} वा त्यसपछिको मिति छान्नुहोस्।',\n onOrBefore: '{max} वा त्यसअघिको मिति छान्नुहोस्।',\n unavailable: 'यो मिति उपलब्ध छैन।',\n rangeTooShort: 'कम्तीमा {min} दिन छान्नुहोस्।',\n rangeTooLong: 'बढीमा {max} दिन छान्नुहोस्।',\n tooManyDates: 'बढीमा {max} मिति छान्नुहोस्।',\n invalidTime: 'समय HH:MM ढाँचामा लेख्नुहोस्।',\n },\n};\n","import { NepDateRangeError } from '../errors';\nimport type { LocaleCode } from '../types';\nimport { en } from './en';\nimport { ne } from './ne';\n\ntype Names12 = readonly string[];\n\n/** Everything a language needs: digits, names, UI labels and validation messages. */\nexport interface LocaleData {\n /** Ten digit characters, 0–9. */\n readonly digits: readonly string[];\n /** Seven names each, Sunday first. */\n readonly weekdays: {\n readonly long: readonly string[];\n readonly short: readonly string[];\n readonly narrow: readonly string[];\n };\n /** Twelve names each, first month first. */\n readonly months: {\n readonly AD: { readonly long: Names12; readonly short: Names12 };\n readonly BS: { readonly long: Names12; readonly short: Names12 };\n };\n /** How each calendar is named in this language: \"BS\" / \"वि.सं.\". */\n readonly calendarNames: { readonly AD: string; readonly BS: string };\n readonly labels: {\n readonly today: string;\n readonly clear: string;\n readonly previousMonth: string;\n readonly nextMonth: string;\n readonly previousYear: string;\n readonly nextYear: string;\n readonly month: string;\n readonly year: string;\n readonly openCalendar: string;\n readonly chooseDate: string;\n readonly calendar: string;\n /** Picker shortcuts (presets) and the name of their list. */\n readonly presets: string;\n readonly fiscalYear: string;\n readonly time: string;\n readonly hour: string;\n readonly minute: string;\n readonly now: string;\n readonly done: string;\n };\n /** Words for 12-hour times. */\n readonly time: { readonly am: string; readonly pm: string };\n /** Names of the built-in picker presets. */\n readonly presets: {\n readonly today: string;\n readonly yesterday: string;\n readonly tomorrow: string;\n readonly thisWeek: string;\n readonly lastWeek: string;\n readonly last7Days: string;\n readonly last30Days: string;\n readonly thisMonth: string;\n readonly lastMonth: string;\n readonly thisYear: string;\n readonly thisFiscalYear: string;\n readonly lastFiscalYear: string;\n };\n /** Messages may use {min} and {max} placeholders. */\n readonly messages: {\n readonly invalidFormat: { readonly AD: string; readonly BS: string };\n readonly outOfRange: string;\n readonly onOrAfter: string;\n readonly onOrBefore: string;\n readonly unavailable: string;\n /** Range pickers: {min} / {max} are day counts. */\n readonly rangeTooShort: string;\n readonly rangeTooLong: string;\n /** Multiple-date pickers: {max} is a count of dates. */\n readonly tooManyDates: string;\n readonly invalidTime: string;\n };\n}\n\nconst locales = new Map<string, LocaleData>([\n ['en', en],\n ['ne', ne],\n]);\n\n/** Add or replace a language. Lists must have the right lengths (10 digits, 7 weekdays, 12 months). */\nexport function registerLocale(code: LocaleCode, data: LocaleData): void {\n const checks: [string, readonly string[], number][] = [\n ['digits', data.digits, 10],\n ['weekdays.long', data.weekdays.long, 7],\n ['weekdays.short', data.weekdays.short, 7],\n ['weekdays.narrow', data.weekdays.narrow, 7],\n ['months.AD.long', data.months.AD.long, 12],\n ['months.AD.short', data.months.AD.short, 12],\n ['months.BS.long', data.months.BS.long, 12],\n ['months.BS.short', data.months.BS.short, 12],\n ];\n for (const [name, list, length] of checks) {\n if (list.length !== length) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `Locale \"${code}\": ${name} must have ${length} entries, not ${list.length}.`,\n );\n }\n }\n locales.set(code, data);\n}\n\nexport function hasLocale(code: LocaleCode): boolean {\n return locales.has(code);\n}\n\n/** The data for a locale, or English when the locale is not registered. */\nexport function localeData(code: LocaleCode): LocaleData {\n return locales.get(code) ?? en;\n}\n","import { NepDateRangeError } from './errors';\nimport { hasLocale } from './locale/registry';\nimport type { LocaleCode, Weekday } from './types';\n\n/**\n * Settings shared by both calendars. Calendar data is not here: the BS table is\n * managed by setBsData/patchBsYear, and AD needs no data (docs/plan D-001).\n */\nexport interface NepDateConfig {\n /** Which time zone decides \"today\" and the calendar day of an instant. */\n readonly timeZone: string;\n readonly weekStartsOn: Weekday;\n readonly weekendDays: readonly Weekday[];\n readonly defaultLocale: LocaleCode;\n}\n\nconst DEFAULTS: NepDateConfig = Object.freeze({\n timeZone: 'Asia/Kathmandu',\n weekStartsOn: 0,\n weekendDays: Object.freeze<Weekday[]>([6]),\n defaultLocale: 'en',\n});\n\nlet current: NepDateConfig = DEFAULTS;\n\n/** Change one or more settings. Every value is checked before any is applied. */\nexport function configure(changes: Partial<NepDateConfig>): void {\n const next = { ...current, ...changes };\n\n if (!isTimeZone(next.timeZone)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `\"${next.timeZone}\" is not a time zone.`,\n );\n }\n if (!isWeekday(next.weekStartsOn)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `weekStartsOn must be 0–6, not ${String(next.weekStartsOn)}.`,\n );\n }\n if (\n !next.weekendDays.every(isWeekday) ||\n new Set(next.weekendDays).size !== next.weekendDays.length\n ) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n 'weekendDays must be different weekdays, each 0–6.',\n );\n }\n if (!hasLocale(next.defaultLocale)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `Locale \"${next.defaultLocale}\" is not registered.`,\n );\n }\n\n current = Object.freeze({\n ...next,\n weekendDays: Object.freeze([...next.weekendDays]),\n });\n}\n\nexport function getConfig(): NepDateConfig {\n return current;\n}\n\n/** Back to the defaults (Kathmandu, Sunday first, Saturday weekend, English). */\nexport function resetConfig(): void {\n current = DEFAULTS;\n}\n\nexport function isWeekday(value: unknown): value is Weekday {\n return Number.isInteger(value) && (value as number) >= 0 && (value as number) <= 6;\n}\n\nfunction isTimeZone(value: string): boolean {\n try {\n new Intl.DateTimeFormat('en-US', { timeZone: value });\n\n return true;\n } catch {\n return false;\n }\n}\n","/**\n * The Gregorian (AD) calendar, by arithmetic only: no table, no BS knowledge,\n * no `Date`. Works for any year in ±MAX_AD_YEAR (docs/plan D-001).\n *\n * The day-count algorithms are Howard Hinnant's days_from_civil and\n * civil_from_days (proleptic Gregorian, March-based years).\n */\n\n/** AD years must lie within ±this value. */\nexport const MAX_AD_YEAR = 999_999;\n\nconst DAYS_BEFORE_EPOCH = 719_468; // 0000-03-01 → 1970-01-01\nconst DAYS_PER_ERA = 146_097; // 400 years\nconst MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\nexport function isAdLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\n/** Days in an AD month. The month must be 1–12. */\nexport function adMonthLength(year: number, month: number): number {\n return month === 2 && isAdLeapYear(year) ? 29 : (MONTH_DAYS[month - 1] ?? 0);\n}\n\nexport function isValidAdDate(year: number, month: number, day: number): boolean {\n return (\n Number.isInteger(year) &&\n Number.isInteger(month) &&\n Number.isInteger(day) &&\n Math.abs(year) <= MAX_AD_YEAR &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= adMonthLength(year, month)\n );\n}\n\n/** Days since 1970-01-01 of a valid AD date. */\nexport function adToEpoch(year: number, month: number, day: number): number {\n const y = month <= 2 ? year - 1 : year;\n const era = Math.floor(y / 400);\n const yearOfEra = y - era * 400;\n const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;\n const dayOfEra =\n yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\n return era * DAYS_PER_ERA + dayOfEra - DAYS_BEFORE_EPOCH;\n}\n\n/** The AD year, month and day of a day count. */\nexport function epochToAd(epoch: number): { year: number; month: number; day: number } {\n const z = epoch + DAYS_BEFORE_EPOCH;\n const era = Math.floor(z / DAYS_PER_ERA);\n const dayOfEra = z - era * DAYS_PER_ERA;\n const yearOfEra = Math.floor(\n (dayOfEra -\n Math.floor(dayOfEra / 1460) +\n Math.floor(dayOfEra / 36_524) -\n Math.floor(dayOfEra / 146_096)) /\n 365,\n );\n const dayOfYear =\n dayOfEra -\n (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n const shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);\n const day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;\n const month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;\n const year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\n return { year, month, day };\n}\n","// Generated by scripts/gen-data.ts from data/bikram-sambat.json. Do not edit by hand.\n// Run `pnpm gen:data` after changing the JSON.\n\n/** The bundled Bikram Sambat table: month lengths keyed by BS year, no AD dates. */\nexport interface GeneratedBsData {\n /** The BS year of the first row. */\n readonly firstYear: number;\n /** Days since 1970-01-01 of 1 Baisakh of `firstYear`. */\n readonly epochStart: number;\n /** Years after this one are projections, not yet checked against a published calendar. */\n readonly verifiedThrough: number;\n /** Twelve month lengths (Baisakh..Chaitra) per year, starting at `firstYear`. */\n readonly years: readonly (readonly number[])[];\n}\n\nexport const BS_DATA: GeneratedBsData = {\n firstYear: 1970,\n epochStart: -20717,\n verifiedThrough: 2083,\n years: [\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1970\n [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], // 1971\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1972\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 1973\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1974\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 1975\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1976\n [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], // 1977\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1978\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 1979\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1980\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 1981\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1982\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 1983\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1984\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 1985\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1986\n [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 1987\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1988\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 1989\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1990\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 1991\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 1992\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 1993\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1994\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 1995\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 1996\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1997\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 1998\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 1999\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2000\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2001\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2002\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2003\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2004\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2005\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2006\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2007\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], // 2008\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2009\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2010\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2011\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 2012\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2013\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2014\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2015\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 2016\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2017\n [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2018\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2019\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2020\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2021\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 2022\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2023\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2024\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2025\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2026\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2027\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2028\n [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], // 2029\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2030\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2031\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2032\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2033\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2034\n [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], // 2035\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2036\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2037\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2038\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 2039\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2040\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2041\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2042\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 2043\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2044\n [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2045\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2046\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2047\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2048\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 2049\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2050\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2051\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2052\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 2053\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2054\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2055\n [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], // 2056\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2057\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2058\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2059\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2060\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2061\n [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], // 2062\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2063\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2064\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2065\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], // 2066\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2067\n [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2068\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2069\n [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], // 2070\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2071\n [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2072\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], // 2073\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2074\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2075\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 2076\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2077\n [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], // 2078\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2079\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], // 2080\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], // 2081\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2082\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], // 2083\n [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], // 2084\n [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30], // 2085\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2086\n [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], // 2087\n [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30], // 2088\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2089\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2090\n [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], // 2091\n [30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2092\n [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2093\n [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], // 2094\n [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30], // 2095\n [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], // 2096\n [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], // 2097\n [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31], // 2098\n [31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], // 2099\n ],\n};\n","/**\n * The Bikram Sambat calendar, from its table only. Nothing here reads or\n * produces an AD year: BS dates map to and from day counts (EpochDay) through\n * `epochStart` and the month lengths (docs/plan D-001).\n */\nimport { NepDateRangeError } from '../errors';\nimport type { BsData } from '../types';\nimport { BS_DATA } from './data/years';\n\ninterface BsTable {\n readonly data: BsData;\n readonly lastYear: number;\n /** yearStart[i] = day count of 1 Baisakh of firstYear + i; one extra entry for the end. */\n readonly yearStart: Float64Array;\n /** monthOffset[i * 12 + m] = days from 1 Baisakh to the first of month m + 1 in year i. */\n readonly monthOffset: Uint16Array;\n}\n\nlet data: BsData = freezeData(BS_DATA);\nlet table: BsTable | null = null;\n\n/** Replace the data the table is built from. Callers validate first (data-api.ts). */\nexport function useBsData(next: BsData): void {\n data = freezeData(next);\n table = null;\n}\n\nfunction freezeData(source: BsData): BsData {\n return Object.freeze({\n firstYear: source.firstYear,\n epochStart: source.epochStart,\n verifiedThrough: source.verifiedThrough,\n years: Object.freeze(source.years.map((months) => Object.freeze([...months]))),\n });\n}\n\nexport function currentBsData(): BsData {\n return data;\n}\n\nfunction buildTable(): BsTable {\n const count = data.years.length;\n const yearStart = new Float64Array(count + 1);\n const monthOffset = new Uint16Array(count * 12);\n let start = data.epochStart;\n\n for (let i = 0; i < count; i++) {\n yearStart[i] = start;\n const months = data.years[i] ?? [];\n let offset = 0;\n for (let m = 0; m < 12; m++) {\n monthOffset[i * 12 + m] = offset;\n offset += months[m] ?? 0;\n }\n start += offset;\n }\n yearStart[count] = start;\n\n return { data, lastYear: data.firstYear + count - 1, yearStart, monthOffset };\n}\n\nfunction bsTable(): BsTable {\n return (table ??= buildTable());\n}\n\nexport function bsFirstYear(): number {\n return data.firstYear;\n}\n\nexport function bsLastYear(): number {\n return bsTable().lastYear;\n}\n\n/** The first and last day counts the table covers. */\nexport function bsEpochRange(): { first: number; last: number } {\n const { yearStart } = bsTable();\n\n return { first: yearStart[0] ?? 0, last: (yearStart[yearStart.length - 1] ?? 0) - 1 };\n}\n\n/** Days in a BS month. Throws when the year is outside the table or the month is not 1–12. */\nexport function bsMonthLength(year: number, month: number): number {\n const { lastYear } = bsTable();\n if (!Number.isInteger(year) || year < data.firstYear || year > lastYear) {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `BS year ${String(year)} is outside the supported range (BS ${data.firstYear}–${lastYear}).`,\n );\n }\n if (!Number.isInteger(month) || month < 1 || month > 12) {\n throw new NepDateRangeError(\n 'INVALID_DATE',\n `BS month ${String(month)} does not exist.`,\n );\n }\n\n return data.years[year - data.firstYear]?.[month - 1] ?? 0;\n}\n\nexport function isValidBsDate(year: number, month: number, day: number): boolean {\n try {\n return Number.isInteger(day) && day >= 1 && day <= bsMonthLength(year, month);\n } catch {\n return false;\n }\n}\n\n/** Day count of a valid BS date. */\nexport function bsToEpoch(year: number, month: number, day: number): number {\n const { yearStart, monthOffset } = bsTable();\n const index = year - data.firstYear;\n\n return (yearStart[index] ?? 0) + (monthOffset[index * 12 + month - 1] ?? 0) + day - 1;\n}\n\n/** The BS year, month and day of a day count. Throws when it is outside the table. */\nexport function epochToBs(epoch: number): { year: number; month: number; day: number } {\n const { yearStart, monthOffset } = bsTable();\n const { first, last } = bsEpochRange();\n if (epoch < first || epoch > last) {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `Day ${epoch} is outside the BS table (BS ${data.firstYear}–${bsLastYear()}).`,\n );\n }\n\n // Last year whose start is on or before the day.\n let low = 0;\n let high = yearStart.length - 2;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n if ((yearStart[middle] ?? 0) <= epoch) {\n low = middle;\n } else {\n high = middle - 1;\n }\n }\n const dayOfYear = epoch - (yearStart[low] ?? 0);\n let month = 11;\n while (month > 0 && (monthOffset[low * 12 + month] ?? 0) > dayOfYear) {\n month--;\n }\n\n return {\n year: data.firstYear + low,\n month: month + 1,\n day: dayOfYear - (monthOffset[low * 12 + month] ?? 0) + 1,\n };\n}\n\n/** Whether a BS year is after the last year checked against a published calendar. */\nexport function isProjectedBsYear(year: number): boolean {\n return year > data.verifiedThrough;\n}\n","import { NepDateDataError, NepDateRangeError } from '../errors';\nimport type { BsData } from '../types';\nimport { BS_DATA } from './data/years';\nimport { currentBsData, useBsData } from './table';\n\n/** The first BS month of Nepal's fiscal year: Shrawan. */\nexport const BS_FISCAL_YEAR_START_MONTH = 4;\n\n/** Days a verified year may have. Projected years may be off by one (the bundled BS 2096 lists 364). */\nconst VERIFIED_YEAR_DAYS = [365, 366];\nconst PROJECTED_YEAR_DAYS = [364, 365, 366, 367];\n\n/** Throws NepDateDataError when the table is not usable. Same rules as scripts/gen-data.ts. */\nexport function validateBsData(table: BsData): void {\n if (!Number.isSafeInteger(table.epochStart) || !Number.isInteger(table.firstYear)) {\n throw new NepDateDataError(\n 'BAD_ANCHOR',\n 'firstYear and epochStart must be whole numbers.',\n );\n }\n if (!Number.isInteger(table.verifiedThrough)) {\n throw new NepDateDataError('BAD_ANCHOR', 'verifiedThrough must be a whole number.');\n }\n if (table.years.length === 0) {\n throw new NepDateDataError('EMPTY', 'The BS table has no years.');\n }\n\n table.years.forEach((months, index) => {\n const year = table.firstYear + index;\n if (months.length !== 12) {\n throw new NepDateDataError(\n 'BAD_MONTH_COUNT',\n `BS ${year} lists ${months.length} months, not 12.`,\n year,\n );\n }\n let total = 0;\n months.forEach((days, m) => {\n if (!Number.isInteger(days) || days < 29 || days > 32) {\n throw new NepDateDataError(\n 'BAD_MONTH',\n `BS ${year} month ${m + 1} has ${String(days)} days; expected 29–32.`,\n year,\n m + 1,\n );\n }\n total += days;\n });\n const allowed =\n year <= table.verifiedThrough ? VERIFIED_YEAR_DAYS : PROJECTED_YEAR_DAYS;\n if (!allowed.includes(total)) {\n throw new NepDateDataError(\n 'BAD_YEAR_TOTAL',\n `BS ${year} has ${total} days; expected ${allowed.join(' or ')}.`,\n year,\n );\n }\n });\n}\n\n/** The BS table in use (frozen). */\nexport function getBsData(): BsData {\n return currentBsData();\n}\n\n/** Replace the whole BS table. Only BS results change; AD functions are unaffected. */\nexport function setBsData(table: BsData): void {\n validateBsData(table);\n useBsData(table);\n}\n\n/**\n * Correct one year's month lengths, or add the year just before the first or\n * just after the last. Years after a corrected year move with it; earlier years\n * never move (adding a year before the first keeps every existing year in place).\n */\nexport function patchBsYear(year: number, months: readonly number[]): void {\n const table = currentBsData();\n const lastYear = table.firstYear + table.years.length - 1;\n let next: BsData;\n\n if (year >= table.firstYear && year <= lastYear) {\n next = {\n ...table,\n years: table.years.map((row, index) =>\n index === year - table.firstYear ? months : row,\n ),\n };\n } else if (year === lastYear + 1) {\n next = { ...table, years: [...table.years, months] };\n } else if (year === table.firstYear - 1) {\n const length = months.reduce((total, days) => total + days, 0);\n next = {\n ...table,\n firstYear: year,\n epochStart: table.epochStart - length,\n years: [months, ...table.years],\n };\n } else {\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `BS ${String(year)} is not in the table and does not extend it (BS ${table.firstYear}–${lastYear}).`,\n );\n }\n\n setBsData(next);\n}\n\n/** Back to the table bundled with the package. */\nexport function resetBsData(): void {\n useBsData(BS_DATA);\n}\n","import { adMonthLength, isValidAdDate, MAX_AD_YEAR } from './ad/calendar';\nimport { bsMonthLength, isValidBsDate } from './bs/table';\nimport { NepDateRangeError } from './errors';\nimport type {\n AdDate,\n BsDate,\n CalendarDate,\n CalendarSystem,\n DateOf,\n MonthNumber,\n} from './types';\n\n/** An AD date. Any year within ±999,999 is allowed; only conversion to BS is limited. */\nexport function adDate(year: number, month: number, day: number): AdDate {\n if (!isValidAdDate(year, month, day)) {\n throw new NepDateRangeError(\n Number.isInteger(year) && Number.isInteger(month) && Number.isInteger(day)\n ? 'INVALID_DATE'\n : 'INVALID_ARGUMENT',\n Math.abs(year) > MAX_AD_YEAR\n ? `AD year ${String(year)} is outside ±${MAX_AD_YEAR}.`\n : `AD ${String(year)}-${String(month)}-${String(day)} is not a valid date.`,\n );\n }\n\n return Object.freeze({ calendar: 'AD', year, month: month as MonthNumber, day });\n}\n\n/** A BS date. The year must be in the BS table. */\nexport function bsDate(year: number, month: number, day: number): BsDate {\n const length = bsMonthLength(year, month);\n if (!Number.isInteger(day) || day < 1 || day > length) {\n throw new NepDateRangeError(\n Number.isInteger(day) ? 'INVALID_DATE' : 'INVALID_ARGUMENT',\n `BS ${year}-${month} has ${length} days, not ${String(day)}.`,\n );\n }\n\n return Object.freeze({ calendar: 'BS', year, month: month as MonthNumber, day });\n}\n\nexport function createDate<C extends CalendarSystem>(\n calendar: C,\n year: number,\n month: number,\n day: number,\n): DateOf<C> {\n return (\n calendar === 'AD' ? adDate(year, month, day) : bsDate(year, month, day)\n ) as DateOf<C>;\n}\n\nexport function isValidDate(\n calendar: CalendarSystem,\n year: number,\n month: number,\n day: number,\n): boolean {\n return calendar === 'AD'\n ? isValidAdDate(year, month, day)\n : isValidBsDate(year, month, day);\n}\n\n/** Days in a month of either calendar. */\nexport function daysInMonth(\n calendar: CalendarSystem,\n year: number,\n month: number,\n): number {\n if (calendar === 'BS') {\n return bsMonthLength(year, month);\n }\n if (!isValidAdDate(year, month, 1)) {\n throw new NepDateRangeError(\n 'INVALID_DATE',\n `AD ${String(year)}-${String(month)} is not a month.`,\n );\n }\n\n return adMonthLength(year, month);\n}\n\n/** True for a valid, frozen-or-not AD date object (e.g. from JSON). */\nexport function isAdDate(value: unknown): value is AdDate {\n return isDateLike(value, 'AD') && isValidAdDate(value.year, value.month, value.day);\n}\n\n/** True for a valid BS date object (e.g. from JSON). */\nexport function isBsDate(value: unknown): value is BsDate {\n return isDateLike(value, 'BS') && isValidBsDate(value.year, value.month, value.day);\n}\n\nexport function isCalendarDate(value: unknown): value is CalendarDate {\n return isAdDate(value) || isBsDate(value);\n}\n\nfunction isDateLike(\n value: unknown,\n calendar: CalendarSystem,\n): value is { calendar: CalendarSystem; year: number; month: number; day: number } {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const record = value as Record<string, unknown>;\n\n return (\n record['calendar'] === calendar &&\n typeof record['year'] === 'number' &&\n typeof record['month'] === 'number' &&\n typeof record['day'] === 'number'\n );\n}\n","/**\n * The only place the AD and BS calendars meet, and only through EpochDay\n * (docs/plan D-001). Nothing here looks up a year number across calendars.\n */\nimport { adToEpoch, epochToAd } from './ad/calendar';\nimport { bsEpochRange, bsToEpoch, epochToBs } from './bs/table';\nimport { getConfig } from './config';\nimport { adDate, bsDate } from './create';\nimport { toEpochDay } from './epoch';\nimport { NepDateRangeError } from './errors';\nimport type {\n AdDate,\n BsDate,\n CalendarDate,\n CalendarSystem,\n DateOf,\n EpochDay,\n} from './types';\n\n/** The day count of a date in either calendar. */\nexport function toEpoch(date: CalendarDate): EpochDay {\n return toEpochDay(\n date.calendar === 'AD'\n ? adToEpoch(date.year, date.month, date.day)\n : bsToEpoch(date.year, date.month, date.day),\n );\n}\n\n/** The date of a day count in a calendar. BS throws OUT_OF_TABLE outside the table. */\nexport function fromEpoch<C extends CalendarSystem>(\n epoch: EpochDay,\n calendar: C,\n): DateOf<C> {\n if (calendar === 'AD') {\n const { year, month, day } = epochToAd(epoch);\n\n return adDate(year, month, day) as DateOf<C>;\n }\n assertConvertible(epoch);\n const { year, month, day } = epochToBs(epoch);\n\n return bsDate(year, month, day) as DateOf<C>;\n}\n\nexport function adToBs(date: AdDate): BsDate {\n return fromEpoch(toEpoch(date), 'BS');\n}\n\nexport function bsToAd(date: BsDate): AdDate {\n return fromEpoch(toEpoch(date), 'AD');\n}\n\n/** The same day in the given calendar (the date itself when it is already in it). */\nexport function toCalendar<C extends CalendarSystem>(\n date: CalendarDate,\n calendar: C,\n): DateOf<C> {\n if (date.calendar === calendar) {\n return date as DateOf<C>;\n }\n\n return fromEpoch(toEpoch(date), calendar);\n}\n\n/** The first day that can be converted, in either calendar (the start of the BS table). */\nexport function minDate<C extends CalendarSystem>(calendar: C): DateOf<C> {\n return fromEpoch(toEpochDay(bsEpochRange().first), calendar);\n}\n\n/** The last day that can be converted, in either calendar (the end of the BS table). */\nexport function maxDate<C extends CalendarSystem>(calendar: C): DateOf<C> {\n return fromEpoch(toEpochDay(bsEpochRange().last), calendar);\n}\n\n/** Whether a date can be converted to the other calendar. */\nexport function isConvertible(date: CalendarDate): boolean {\n const epoch = toEpoch(date);\n const { first, last } = bsEpochRange();\n\n return epoch >= first && epoch <= last;\n}\n\n/** The AD day as \"YYYY-MM-DD\", the form to store and send (docs/plan D-003). */\nexport function toIsoDate(date: CalendarDate): string {\n const { year, month, day } = toCalendar(date, 'AD');\n if (year < 0 || year > 9999) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `AD year ${year} cannot be written as YYYY-MM-DD.`,\n );\n }\n\n return `${pad(year, 4)}-${pad(month, 2)}-${pad(day, 2)}`;\n}\n\n/**\n * An AD date from \"YYYY-MM-DD\", or from a longer ISO timestamp by its date part\n * (\"2026-10-18T09:30:00Z\" → 2026-10-18). Null for anything else.\n */\nexport function fromIsoDate(value: string | null | undefined): AdDate | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})(?:$|[T ])/.exec(value ?? '');\n if (!match) {\n return null;\n }\n try {\n return adDate(Number(match[1]), Number(match[2]), Number(match[3]));\n } catch {\n return null;\n }\n}\n\n/** The AD calendar day an instant falls on in a time zone (Nepal by default). */\nexport function fromJsDate(\n instant: Date,\n timeZone: string = getConfig().timeZone,\n): AdDate {\n if (Number.isNaN(instant.getTime())) {\n throw new NepDateRangeError('INVALID_ARGUMENT', 'The Date is invalid.');\n }\n let parts: Intl.DateTimeFormatPart[];\n try {\n parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n era: 'short',\n }).formatToParts(instant);\n } catch {\n throw new NepDateRangeError('INVALID_ARGUMENT', `\"${timeZone}\" is not a time zone.`);\n }\n const part = (type: Intl.DateTimeFormatPartTypes): string =>\n parts.find((item) => item.type === type)?.value ?? '';\n const year = Number(part('year'));\n\n return adDate(\n part('era') === 'BC' ? 1 - year : year,\n Number(part('month')),\n Number(part('day')),\n );\n}\n\n/**\n * The calendar day and time of an ISO timestamp *with a zone* (\"…Z\",\n * \"…+05:45\"), read in `timeZone` (Nepal by default). Null for anything else,\n * including plain dates, which have no instant.\n */\nexport function fromIsoTimestamp(\n value: string | null | undefined,\n timeZone: string = getConfig().timeZone,\n): { readonly date: AdDate; readonly time: string } | null {\n if (!value || !/T.*(?:Z|[+-]\\d{2}:?\\d{2})$/.test(value)) {\n return null;\n }\n const instant = new Date(value);\n if (Number.isNaN(instant.getTime())) {\n return null;\n }\n const time = new Intl.DateTimeFormat('en-GB', {\n timeZone,\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n }).format(instant);\n\n return { date: fromJsDate(instant, timeZone), time };\n}\n\nfunction assertConvertible(epoch: number): void {\n const { first, last } = bsEpochRange();\n if (epoch < first || epoch > last) {\n const { year, month, day } = epochToAd(epoch);\n const from = epochToAd(first);\n const to = epochToAd(last);\n throw new NepDateRangeError(\n 'OUT_OF_TABLE',\n `AD ${isoParts(year, month, day)} is outside the BS table (AD ${isoParts(from.year, from.month, from.day)} to ${isoParts(to.year, to.month, to.day)}).`,\n );\n }\n}\n\nfunction isoParts(year: number, month: number, day: number): string {\n return `${year}-${pad(month, 2)}-${pad(day, 2)}`;\n}\n\nfunction pad(value: number, length: number): string {\n return String(value).padStart(length, '0');\n}\n","import { isProjectedBsYear } from './bs/table';\nimport { toCalendar } from './convert';\nimport type { CalendarDate } from './types';\n\n/** Whether the date's BS year is after the last year checked against a published calendar. */\nexport function isProjected(date: CalendarDate): boolean {\n return isProjectedBsYear(toCalendar(date, 'BS').year);\n}\n","import { getConfig } from './config';\nimport { fromIsoTimestamp, fromJsDate, toCalendar } from './convert';\nimport type { AdDate, CalendarSystem, DateOf } from './types';\n\n/**\n * Today's date by the calendar day in `timeZone` (Nepal by default), not the\n * device's zone. The only function in the library that reads the clock.\n */\nexport function today(): AdDate;\nexport function today<C extends CalendarSystem>(\n calendar: C,\n timeZone?: string,\n): DateOf<C>;\nexport function today(\n calendar: CalendarSystem = 'AD',\n timeZone: string = getConfig().timeZone,\n): AdDate | DateOf<CalendarSystem> {\n return toCalendar(fromJsDate(new Date(), timeZone), calendar);\n}\n\n/** The current calendar day and time (HH:MM) in `timeZone` (Nepal by default). */\nexport function now(timeZone: string = getConfig().timeZone): {\n readonly date: AdDate;\n readonly time: { readonly hour: number; readonly minute: number };\n} {\n const current = fromIsoTimestamp(new Date().toISOString(), timeZone);\n const [hour = 0, minute = 0] = (current?.time ?? '00:00').split(':').map(Number);\n\n return {\n date: current?.date ?? fromJsDate(new Date(), timeZone),\n time: Object.freeze({ hour, minute }),\n };\n}\n","import { getConfig, isWeekday } from './config';\nimport { fromEpoch, toCalendar, toEpoch } from './convert';\nimport { createDate, daysInMonth } from './create';\nimport { toEpochDay, weekdayOf } from './epoch';\nimport { NepDateRangeError } from './errors';\nimport type { CalendarDate, DateOf, Weekday } from './types';\n\n/** A date in the same calendar as `D`. */\ntype Same<D extends CalendarDate> = DateOf<D['calendar']>;\n\nexport function addDays<D extends CalendarDate>(date: D, days: number): Same<D> {\n assertInteger(days, 'days');\n\n return fromEpoch(toEpochDay(toEpoch(date) + days), date.calendar) as Same<D>;\n}\n\n/** Move by whole months in the date's own calendar; the day is capped to the new month's length. */\nexport function addMonths<D extends CalendarDate>(date: D, months: number): Same<D> {\n assertInteger(months, 'months');\n const index = date.year * 12 + (date.month - 1) + months;\n const year = Math.floor(index / 12);\n const month = index - year * 12 + 1;\n const day = Math.min(date.day, daysInMonth(date.calendar, year, month));\n\n return createDate(date.calendar, year, month, day) as Same<D>;\n}\n\n/** Move by whole years in the date's own calendar; the day is capped (29 Feb, short BS months). */\nexport function addYears<D extends CalendarDate>(date: D, years: number): Same<D> {\n assertInteger(years, 'years');\n\n return addMonths(date, years * 12);\n}\n\nexport function startOfMonth<D extends CalendarDate>(date: D): Same<D> {\n return createDate(date.calendar, date.year, date.month, 1) as Same<D>;\n}\n\nexport function endOfMonth<D extends CalendarDate>(date: D): Same<D> {\n return createDate(\n date.calendar,\n date.year,\n date.month,\n daysInMonth(date.calendar, date.year, date.month),\n ) as Same<D>;\n}\n\nexport function startOfYear<D extends CalendarDate>(date: D): Same<D> {\n return createDate(date.calendar, date.year, 1, 1) as Same<D>;\n}\n\nexport function endOfYear<D extends CalendarDate>(date: D): Same<D> {\n return createDate(\n date.calendar,\n date.year,\n 12,\n daysInMonth(date.calendar, date.year, 12),\n ) as Same<D>;\n}\n\nexport function startOfWeek<D extends CalendarDate>(\n date: D,\n weekStartsOn: Weekday = getConfig().weekStartsOn,\n): Same<D> {\n assertWeekday(weekStartsOn);\n const back = (weekdayOf(toEpoch(date)) - weekStartsOn + 7) % 7;\n\n return addDays(date, -back);\n}\n\nexport function endOfWeek<D extends CalendarDate>(\n date: D,\n weekStartsOn: Weekday = getConfig().weekStartsOn,\n): Same<D> {\n return addDays(startOfWeek(date, weekStartsOn), 6);\n}\n\n/** Whole days from `b` to `a` (positive when `a` is later). The calendars may differ. */\nexport function differenceInDays(a: CalendarDate, b: CalendarDate): number {\n return toEpoch(a) - toEpoch(b);\n}\n\n/** Every day from `start` to `end` inclusive, in `start`'s calendar. Nothing when end < start. */\nexport function* eachDayOfInterval<D extends CalendarDate>(\n start: D,\n end: CalendarDate,\n): Generator<Same<D>, void, undefined> {\n const last = toEpoch(end);\n for (let epoch = toEpoch(start); epoch <= last; epoch++) {\n yield fromEpoch(toEpochDay(epoch), start.calendar) as Same<D>;\n }\n}\n\n/** Every day of the month the date is in. */\nexport function eachDayOfMonth<D extends CalendarDate>(date: D): Same<D>[] {\n return [...eachDayOfInterval(startOfMonth(date), endOfMonth(date))] as Same<D>[];\n}\n\n/** The date converted to `target`'s calendar; a small helper used by compare and fiscal code. */\nexport function inCalendarOf<D extends CalendarDate>(\n target: D,\n date: CalendarDate,\n): Same<D> {\n return toCalendar(date, target.calendar) as Same<D>;\n}\n\nfunction assertInteger(value: number, name: string): void {\n if (!Number.isSafeInteger(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${name} must be a whole number, not ${String(value)}.`,\n );\n }\n}\n\nfunction assertWeekday(value: number): void {\n if (!isWeekday(value)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(value)} is not a weekday (0–6).`,\n );\n }\n}\n","import { inCalendarOf } from './arithmetic';\nimport { getConfig } from './config';\nimport { toCalendar, toEpoch } from './convert';\nimport { weekdayOf } from './epoch';\nimport type { CalendarDate, DateOf, Weekday } from './types';\n\ntype Maybe = CalendarDate | null | undefined;\n\n/** -1, 0 or 1. Dates in different calendars compare by the day they fall on. */\nexport function compareDates(a: CalendarDate, b: CalendarDate): -1 | 0 | 1 {\n return Math.sign(toEpoch(a) - toEpoch(b)) as -1 | 0 | 1;\n}\n\n/** Same day, in any calendars. False when either is missing. */\nexport function isSameDay(a: Maybe, b: Maybe): boolean {\n return a != null && b != null && toEpoch(a) === toEpoch(b);\n}\n\n/** Whether `b` falls in the same month as `a`, judged in `a`'s calendar. */\nexport function isSameMonth(a: CalendarDate, b: CalendarDate): boolean {\n const other = inCalendarOf(a, b);\n\n return other.year === a.year && other.month === a.month;\n}\n\n/** Whether `b` falls in the same year as `a`, judged in `a`'s calendar. */\nexport function isSameYear(a: CalendarDate, b: CalendarDate): boolean {\n return inCalendarOf(a, b).year === a.year;\n}\n\nexport function isBefore(a: CalendarDate, b: CalendarDate): boolean {\n return toEpoch(a) < toEpoch(b);\n}\n\nexport function isAfter(a: CalendarDate, b: CalendarDate): boolean {\n return toEpoch(a) > toEpoch(b);\n}\n\n/** On or after `min` and on or before `max`; a missing bound is open. */\nexport function isWithin(date: CalendarDate, min?: Maybe, max?: Maybe): boolean {\n const day = toEpoch(date);\n\n return (min == null || day >= toEpoch(min)) && (max == null || day <= toEpoch(max));\n}\n\n/** The date, or the nearest bound when it is outside, in the date's calendar. */\nexport function clampDate<D extends CalendarDate>(\n date: D,\n min?: Maybe,\n max?: Maybe,\n): DateOf<D['calendar']> {\n if (min != null && isBefore(date, min)) {\n return toCalendar(min, date.calendar) as DateOf<D['calendar']>;\n }\n if (max != null && isAfter(date, max)) {\n return toCalendar(max, date.calendar) as DateOf<D['calendar']>;\n }\n\n return date as DateOf<D['calendar']>;\n}\n\n/** 0 = Sunday … 6 = Saturday. The same in both calendars. */\nexport function dayOfWeek(date: CalendarDate): Weekday {\n return weekdayOf(toEpoch(date));\n}\n\n/** Saturday by default (Nepal); set `weekendDays` in configure() or pass them here. */\nexport function isWeekend(\n date: CalendarDate,\n weekendDays: readonly Weekday[] = getConfig().weekendDays,\n): boolean {\n return weekendDays.includes(dayOfWeek(date));\n}\n","import { getConfig } from '../config';\nimport type { CalendarSystem, LocaleCode } from '../types';\nimport { localeData, type LocaleData } from './registry';\n\nexport { hasLocale, registerLocale, type LocaleData } from './registry';\n\nconst DEVANAGARI = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];\n\n/** The data for a locale (the configured default when omitted; English when unknown). */\nexport function getLocale(locale: LocaleCode = getConfig().defaultLocale): LocaleData {\n return localeData(locale);\n}\n\nexport function monthNames(\n calendar: CalendarSystem,\n locale?: LocaleCode,\n width: 'long' | 'short' = 'long',\n): readonly string[] {\n return getLocale(locale).months[calendar][width];\n}\n\nexport function weekdayNames(\n locale?: LocaleCode,\n width: 'long' | 'short' | 'narrow' = 'long',\n): readonly string[] {\n return getLocale(locale).weekdays[width];\n}\n\n/** Replace Devanagari digits with ASCII digits. */\nexport function toAsciiDigits(value: string): string {\n return value.replace(/[०-९]/g, (digit) => String(DEVANAGARI.indexOf(digit)));\n}\n\n/** Replace ASCII digits with Devanagari digits. */\nexport function toDevanagariDigits(value: string | number): string {\n return String(value).replace(/[0-9]/g, (digit) => DEVANAGARI[Number(digit)] ?? digit);\n}\n\n/** Write a number (or digit string) with the locale's digits. */\nexport function formatNumber(value: string | number, locale?: LocaleCode): string {\n const { digits } = getLocale(locale);\n\n return String(value).replace(/[0-9]/g, (digit) => digits[Number(digit)] ?? digit);\n}\n\n/** Fill {name} placeholders in a locale message. */\nexport function formatMessage(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (whole, name: string) => values[name] ?? whole);\n}\n","import { dayOfWeek } from './compare';\nimport { formatNumber, getLocale } from './locale/index';\nimport type { CalendarDate, LocaleCode } from './types';\n\n/** Named formats. `cbms` is the dotted form Nepal's tax system uses. */\nexport const DATE_FORMATS: {\n readonly iso: 'Y-m-d';\n readonly cbms: 'Y.m.d';\n readonly short: 'j M Y';\n readonly long: 'j F Y';\n readonly full: 'l, j F Y';\n} = Object.freeze({\n iso: 'Y-m-d',\n cbms: 'Y.m.d',\n short: 'j M Y',\n long: 'j F Y',\n full: 'l, j F Y',\n});\n\nexport type NamedFormat = keyof typeof DATE_FORMATS;\n/** A named format, or a pattern of tokens (see formatDate). */\nexport type DateFormatPattern = NamedFormat | (string & Record<never, never>);\n\n/**\n * Format a date in its own calendar. Tokens: Y 2083, y 83, m 06, n 6, d 09,\n * j 9, F month name, M short month name, l weekday, D short weekday. Put a\n * backslash before a letter to print it as is. Digits follow the locale.\n *\n * formatDate(bsDate(2082, 4, 1), 'full') → \"Thursday, 1 Shrawan 2082\"\n * formatDate(bsDate(2082, 4, 1), 'long', 'ne') → \"१ साउन २०८२\"\n */\nexport function formatDate(\n date: CalendarDate,\n pattern: DateFormatPattern = 'iso',\n locale?: LocaleCode,\n): string {\n const tokens: string =\n pattern in DATE_FORMATS ? DATE_FORMATS[pattern as NamedFormat] : pattern;\n const data = getLocale(locale);\n const months = data.months[date.calendar];\n const digits = (value: string | number): string => formatNumber(value, locale);\n const pad = (value: number): string => String(value).padStart(2, '0');\n let output = '';\n\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens.charAt(index);\n switch (token) {\n case '\\\\':\n index++;\n output += tokens.charAt(index);\n break;\n case 'Y':\n output += digits(date.year);\n break;\n case 'y':\n output += digits(pad(((date.year % 100) + 100) % 100));\n break;\n case 'm':\n output += digits(pad(date.month));\n break;\n case 'n':\n output += digits(date.month);\n break;\n case 'd':\n output += digits(pad(date.day));\n break;\n case 'j':\n output += digits(date.day);\n break;\n case 'F':\n output += months.long[date.month - 1] ?? '';\n break;\n case 'M':\n output += months.short[date.month - 1] ?? '';\n break;\n case 'l':\n output += data.weekdays.long[dayOfWeek(date)] ?? '';\n break;\n case 'D':\n output += data.weekdays.short[dayOfWeek(date)] ?? '';\n break;\n default:\n output += token;\n }\n }\n\n return output;\n}\n","import { BS_FISCAL_YEAR_START_MONTH } from './bs/data-api';\nimport { compareDates } from './compare';\nimport { toCalendar } from './convert';\nimport { bsDate, daysInMonth } from './create';\nimport { formatNumber } from './locale/index';\nimport type { CalendarDate, FiscalYear, LocaleCode } from './types';\n\n/** The fiscal year a date falls in: 1 Shrawan to the end of Asar. */\nexport function fiscalYear(date: CalendarDate): FiscalYear {\n const bs = toCalendar(date, 'BS');\n\n return fiscalYearRange(bs.month >= BS_FISCAL_YEAR_START_MONTH ? bs.year : bs.year - 1);\n}\n\n/** The fiscal year that starts in BS `startYear` (2083 → FY 2083/84). */\nexport function fiscalYearRange(startYear: number): FiscalYear {\n const endYear = startYear + 1;\n const lastMonth = BS_FISCAL_YEAR_START_MONTH - 1;\n\n return Object.freeze({\n startYear,\n label: `${startYear}/${String(endYear % 100).padStart(2, '0')}`,\n firstDay: bsDate(startYear, BS_FISCAL_YEAR_START_MONTH, 1),\n lastDay: bsDate(endYear, lastMonth, daysInMonth('BS', endYear, lastMonth)),\n });\n}\n\n/**\n * label \"2083/84\" · full \"2083/2084\" · cbms \"2083.084\" (the form Nepal's tax\n * system uses). Digits follow the locale.\n */\nexport function formatFiscalYear(\n fy: FiscalYear,\n style: 'label' | 'full' | 'cbms' = 'label',\n locale?: LocaleCode,\n): string {\n const end = fy.startYear + 1;\n const text =\n style === 'full'\n ? `${fy.startYear}/${end}`\n : style === 'cbms'\n ? `${fy.startYear}.${String(end % 1000).padStart(3, '0')}`\n : fy.label;\n\n return formatNumber(text, locale);\n}\n\nexport function isInFiscalYear(date: CalendarDate, fy: FiscalYear): boolean {\n return compareDates(date, fy.firstDay) >= 0 && compareDates(date, fy.lastDay) <= 0;\n}\n","import { createDate } from './create';\nimport { NepDateRangeError } from './errors';\nimport { fiscalYearRange } from './fiscal';\nimport { toAsciiDigits } from './locale/index';\nimport type { CalendarSystem, DateOf, FiscalYear } from './types';\n\nconst YEAR_FIRST = /^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})$/;\nconst COMPACT = /^(\\d{4})(\\d{2})(\\d{2})$/;\n\n/**\n * A date written year first (\"2083-06-24\", \"2083/6/24\", \"2083.06.24\", or\n * compact \"20830624\") in ASCII or Devanagari digits, in the calendar the caller names. Other orders are\n * rejected, not guessed. Returns null when the text is not a valid date.\n */\nexport function parseDate<C extends CalendarSystem>(\n text: string | null | undefined,\n calendar: C,\n): DateOf<C> | null {\n try {\n return parseDateStrict(text ?? '', calendar);\n } catch {\n return null;\n }\n}\n\n/** Like parseDate, but throws a NepDateRangeError that says what is wrong. */\nexport function parseDateStrict<C extends CalendarSystem>(\n text: string,\n calendar: C,\n): DateOf<C> {\n const ascii = toAsciiDigits(text).trim();\n const match = YEAR_FIRST.exec(ascii) ?? COMPACT.exec(ascii);\n if (!match) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `\"${text}\" is not a date written as YYYY-MM-DD.`,\n );\n }\n\n return createDate(calendar, Number(match[1]), Number(match[2]), Number(match[3]));\n}\n\n/**\n * A fiscal year from its label: \"2083/84\", \"2083/2084\", \"2083-84\" or the\n * tax form \"2083.084\", in ASCII or Devanagari digits. Null when not valid.\n */\nexport function parseFiscalYear(text: string | null | undefined): FiscalYear | null {\n const match = /^(\\d{4})\\s*[-/.]\\s*(\\d{2,4})$/.exec(toAsciiDigits(text ?? '').trim());\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ?? '';\n const next = start + 1;\n const expected =\n end.length === 4\n ? String(next)\n : String(next % 10 ** end.length).padStart(end.length, '0');\n if (end !== expected) {\n return null;\n }\n try {\n return fiscalYearRange(start);\n } catch {\n return null;\n }\n}\n","import { getConfig } from './config';\nimport { fromIsoTimestamp, toCalendar } from './convert';\nimport { adDate } from './create';\nimport { NepDateRangeError } from './errors';\nimport { formatNumber, getLocale, toAsciiDigits } from './locale/index';\nimport type { AdDate, CalendarDate, LocaleCode } from './types';\n\n/** A time of day, 00:00–23:59. Frozen like dates. */\nexport interface TimeOfDay {\n readonly hour: number;\n readonly minute: number;\n}\n\nexport function timeOfDay(hour: number, minute = 0): TimeOfDay {\n if (!isValidTime(hour, minute)) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `${String(hour)}:${String(minute)} is not a time of day.`,\n );\n }\n\n return Object.freeze({ hour, minute });\n}\n\nexport function isValidTime(hour: number, minute: number): boolean {\n return (\n Number.isInteger(hour) &&\n Number.isInteger(minute) &&\n hour >= 0 &&\n hour <= 23 &&\n minute >= 0 &&\n minute <= 59\n );\n}\n\n/** -1, 0 or 1. */\nexport function compareTimes(a: TimeOfDay, b: TimeOfDay): -1 | 0 | 1 {\n return Math.sign(a.hour * 60 + a.minute - (b.hour * 60 + b.minute)) as -1 | 0 | 1;\n}\n\n/**\n * \"14:30\", \"2:30 pm\", \"2 PM\", \"1430\", \"१४:३०\", \"२:३० अपराह्न\" → TimeOfDay.\n * Null when the text is not a time.\n */\nexport function parseTime(text: string | null | undefined): TimeOfDay | null {\n let value = toAsciiDigits(text ?? '')\n .trim()\n .toLowerCase();\n let meridiem: 'am' | 'pm' | null = null;\n for (const code of ['en', 'ne'] as const) {\n const { am, pm } = getLocale(code).time;\n for (const [word, kind] of [\n [am.toLowerCase(), 'am'],\n [pm.toLowerCase(), 'pm'],\n [am.toLowerCase().replace(/(.)/g, '$1.'), 'am'],\n [pm.toLowerCase().replace(/(.)/g, '$1.'), 'pm'],\n ] as const) {\n if (value.endsWith(word)) {\n meridiem = kind;\n value = value.slice(0, -word.length).trim();\n break;\n }\n }\n if (meridiem) {\n break;\n }\n }\n const match =\n /^(\\d{1,2})(?:[:.](\\d{2}))?$/.exec(value) ?? /^(\\d{2})(\\d{2})$/.exec(value);\n if (!match) {\n return null;\n }\n let hour = Number(match[1]);\n const minute = Number(match[2] ?? 0);\n if (meridiem) {\n if (hour < 1 || hour > 12) {\n return null;\n }\n hour = (hour % 12) + (meridiem === 'pm' ? 12 : 0);\n }\n\n return isValidTime(hour, minute) ? timeOfDay(hour, minute) : null;\n}\n\n/** \"14:30\" (24-hour) or \"2:30 PM\" (hour12), in the locale's digits and words. */\nexport function formatTime(\n time: TimeOfDay,\n options: { readonly hour12?: boolean; readonly locale?: LocaleCode } = {},\n): string {\n const minute = String(time.minute).padStart(2, '0');\n if (!options.hour12) {\n return formatNumber(\n `${String(time.hour).padStart(2, '0')}:${minute}`,\n options.locale,\n );\n }\n const { am, pm } = getLocale(options.locale).time;\n const hour = time.hour % 12 === 0 ? 12 : time.hour % 12;\n\n return `${formatNumber(`${hour}:${minute}`, options.locale)} ${time.hour < 12 ? am : pm}`;\n}\n\n/**\n * The instant of a calendar day and time in a zone (Nepal by default), as an\n * ISO timestamp with that zone's offset: \"2026-10-18T14:30:00+05:45\".\n */\nexport function toIsoDateTime(\n date: CalendarDate,\n time: TimeOfDay,\n timeZone: string = getConfig().timeZone,\n): string {\n const { year, month, day } = toCalendar(date, 'AD');\n if (year < 0 || year > 9999) {\n throw new NepDateRangeError(\n 'INVALID_ARGUMENT',\n `AD year ${year} cannot be written in ISO form.`,\n );\n }\n const wall = Date.UTC(year, month - 1, day, time.hour, time.minute);\n const first = offsetMinutes(wall, timeZone);\n const offset = offsetMinutes(wall - first * 60_000, timeZone);\n const sign = offset < 0 ? '-' : '+';\n const abs = Math.abs(offset);\n const pad = (value: number, length = 2): string => String(value).padStart(length, '0');\n\n return `${pad(year, 4)}-${pad(month)}-${pad(day)}T${pad(time.hour)}:${pad(time.minute)}:00${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;\n}\n\n/**\n * The day and time of an ISO timestamp in a zone (Nepal by default). A value\n * without an offset (\"2026-10-18T14:30\", as from <input type=\"datetime-local\">)\n * is read as a wall time already in that zone. Null for anything else.\n */\nexport function fromIsoDateTime(\n value: string | null | undefined,\n timeZone: string = getConfig().timeZone,\n): { readonly date: AdDate; readonly time: TimeOfDay } | null {\n const zoned = fromIsoTimestamp(value, timeZone);\n if (zoned) {\n const time = parseTime(zoned.time);\n return time ? { date: zoned.date, time } : null;\n }\n const local = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::\\d{2}(?:\\.\\d+)?)?$/.exec(\n value ?? '',\n );\n if (!local) {\n return null;\n }\n try {\n return {\n date: adDate(Number(local[1]), Number(local[2]), Number(local[3])),\n time: timeOfDay(Number(local[4]), Number(local[5])),\n };\n } catch {\n return null;\n }\n}\n\n/** Minutes the zone is ahead of UTC at an instant. */\nfunction offsetMinutes(instant: number, timeZone: string): number {\n let parts: Intl.DateTimeFormatPart[];\n try {\n parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n }).formatToParts(new Date(instant));\n } catch {\n throw new NepDateRangeError('INVALID_ARGUMENT', `\"${timeZone}\" is not a time zone.`);\n }\n const part = (type: Intl.DateTimeFormatPartTypes): number =>\n Number(parts.find((item) => item.type === type)?.value ?? 0);\n const wall = Date.UTC(\n part('year'),\n part('month') - 1,\n part('day'),\n part('hour'),\n part('minute'),\n );\n\n return Math.round((wall - Math.floor(instant / 60_000) * 60_000) / 60_000);\n}\n"],"mappings":"A,sFASA,IAAaG,EAAb,cAAuC,UAAW,CAGhD,YAAY,EAA6B,EAAiB,CACxD,MAAMC,CAAO,EACb,KAAK,KAAO,oBACZ,KAAK,KAAOC,CACd,CACF,EAMaC,EAAb,cAAsC,KAAM,CAO1C,YACE,EACA,EACA,EACA,EACA,CACA,MAAMF,CAAO,EACb,KAAK,KAAO,mBACZ,KAAK,KAAOC,EACZ,KAAK,KAAOE,EACZ,KAAK,MAAQC,CACf,CACF,ECtCA,SAAgBC,EAAW,EAAyB,CAClD,GAAI,CAAC,OAAO,cAAcC,CAAK,EAC7B,MAAM,IAAIP,EACR,mBACA,GAAG,OAAOO,CAAK,EAAE,gCACnB,EAGF,OAAOA,CACT,CAGA,SAAgBC,EAAU,EAA0B,CAClD,QAAWC,EAAQ,GAAK,EAAK,GAAK,CACpC,CChBA,IAAMZ,EAAW,CACf,UACA,SACA,OACA,UACA,SACA,SACA,SACA,UACA,QACA,OACA,SACA,SACF,EACMC,EAAW,CACf,UACA,WACA,QACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,UACF,EAEac,EAAiB,CAC5B,OAAQ,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EACzD,SAAU,CACR,KAAM,CAAC,SAAU,SAAU,UAAW,YAAa,WAAY,SAAU,UAAU,EACnF,MAAO,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EACvD,OAAQ,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,IAAI,CACnD,EACA,OAAQ,CACN,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