import { RRStackJson, TimeZoneId, UnixTimeUnit } from '@karmaniverous/rrstack'; import { FieldValues, FieldPathByValue } from 'react-hook-form'; type RRStackJsonRule = NonNullable[number]; type RRStackJsonRuleOptions = NonNullable; type HookFormRRStackRuleOptionsData = Omit & { byhour?: string; byminute?: string; bymonthday?: string; ends?: Date | null; freq: NonNullable | 'span'; starts?: Date | null; }; type HookFormRRStackRuleData = Omit & { options: HookFormRRStackRuleOptionsData; }; type HookFormRRStackData = Omit & { rules: HookFormRRStackRuleData[]; }; type HookFormRRStackPath = FieldPathByValue; declare const conformRule: (rule: HookFormRRStackRuleData) => { conformedRule: HookFormRRStackRuleData; changed: boolean; }; interface CsvBounds { min?: number; max?: number; } /** * Parse tolerant comma-separated integer text into a number[] within optional bounds. * Returns undefined when no valid numbers are present. */ declare function csv2int(text: string | null | undefined, opts?: CsvBounds): number[] | undefined; /** * Convert a number array to a comma-separated string with spaces (e.g., [1,2] → "1, 2"). * Returns undefined for empty or missing arrays. */ declare function int2csv(vals: ReadonlyArray | undefined | null): string | undefined; /** * Map the RHF UI schedule (UI-friendly types) to the rrstack engine schedule. * - 'span' → undefined freq * - Date | null → epoch ms | undefined * - tolerant CSV text → number[] * - arrays pass through unchanged * Assumes timezone has been validated upstream. */ declare const rhf2rrstack: (rhf: HookFormRRStackData, opts?: { endDatesInclusive?: boolean; }) => RRStackJson; /** * Map a single RHF rule to engine RuleJson with timezone-aware clamps. * - Starts: date-only → midnight in tz; datetime → exact wall time in tz. * - Ends: * • endDatesInclusive=true: ignore time-of-day and clamp to midnight of the NEXT day in tz * • endDatesInclusive=false: date-only → midnight in tz; datetime → exact wall time in tz */ declare const rhfrule2rrstackrule: (rule: HookFormRRStackRuleData, timezone: TimeZoneId, timeUnit?: UnixTimeUnit, endDatesInclusive?: boolean) => RRStackJsonRule; /** * Reverse mapping of {@link rhf2rrstack}: rrstack → RHF UI shape. * * - Converts epoch clamps (starts/ends) to Date objects in the rule timezone * using epochToWallDate, preserving wall time semantics. * - Restores 'span' when rrstack freq is undefined. * - Maps numeric arrays back to tolerant CSV text for byhour/byminute/bymonthday. * - Keeps array options (bymonth/byweekday/bysetpos) as number[] or undefined. * - Optional endDatesInclusive reversal: * • When true and an rrstack `ends` falls exactly at local midnight, subtract * one calendar day so the UI reflects the original end date (date-only). */ declare const rrstack2rhf: (rrstack: RRStackJson, opts?: { endDatesInclusive?: boolean; }) => HookFormRRStackData; declare const timezoneOptions: { key: string; value: string; text: string; }[]; declare const formatTimeZone: (tz: string) => string; export { conformRule, csv2int, formatTimeZone, int2csv, rhf2rrstack, rhfrule2rrstackrule, rrstack2rhf, timezoneOptions }; export type { CsvBounds, HookFormRRStackData, HookFormRRStackPath, HookFormRRStackRuleData, HookFormRRStackRuleOptionsData, RRStackJsonRule, RRStackJsonRuleOptions };